Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions bindings/typescript/src/generated/Agent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { UserContent } from "./UserContent";

export type Agent = { name?: string, version?: string, metadata: Record<string, unknown>, instructions?: UserContent, };
5 changes: 5 additions & 0 deletions bindings/typescript/src/generated/AgentResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { AssistantContent } from "./AssistantContent";
import type { UniversalUsage } from "./UniversalUsage";

export type AgentResponse = { response?: AssistantContent, usage?: UniversalUsage, start_time?: string, end_time?: string, };
3 changes: 3 additions & 0 deletions bindings/typescript/src/generated/Compaction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type Compaction = { id: string, replaced_message_count?: number, };
3 changes: 3 additions & 0 deletions bindings/typescript/src/generated/EvidenceField.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type EvidenceField = "input" | "output" | "error";
3 changes: 3 additions & 0 deletions bindings/typescript/src/generated/EvidencePart.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type EvidencePart = "reasoning" | "arguments";
5 changes: 5 additions & 0 deletions bindings/typescript/src/generated/Finding.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { FindingEvidence } from "./FindingEvidence";
import type { FindingSeverity } from "./FindingSeverity";

export type Finding = { title?: string, severity?: FindingSeverity, kind?: string, hypothesis?: string, root_cause?: string, next_steps?: Array<string>, evidence?: Array<FindingEvidence>, pattern_id?: string, };
5 changes: 5 additions & 0 deletions bindings/typescript/src/generated/FindingEvidence.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { EvidenceField } from "./EvidenceField";
import type { EvidencePart } from "./EvidencePart";

export type FindingEvidence = { step_id: string, field?: EvidenceField, part?: EvidencePart, explanation?: string, quote?: string, highlight_terms?: Array<string>, leading_text?: string, trailing_text?: string, };
3 changes: 3 additions & 0 deletions bindings/typescript/src/generated/FindingSeverity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type FindingSeverity = "critical" | "high" | "medium" | "low";
24 changes: 24 additions & 0 deletions bindings/typescript/src/generated/InputTokenDetails.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { ModalityTokenCount } from "./ModalityTokenCount";
import type { TokenBreakdown } from "./TokenBreakdown";

/**
* Detailed subsets of inclusive prompt/input usage.
*/
export type InputTokenDetails = {
/**
* User/request content tokens by modality. Provider-generated tool prompts are separate.
*/
content_by_modality?: Array<ModalityTokenCount>,
/**
* Cache-read tokens, which are included in `UniversalUsage::prompt_tokens`.
*/
cached?: TokenBreakdown,
/**
* Cache-write tokens, which are included in `UniversalUsage::prompt_tokens` when reported.
*/
cache_creation?: TokenBreakdown,
/**
* Provider-generated tool prompt tokens included in `UniversalUsage::prompt_tokens`.
*/
tool_prompt?: TokenBreakdown, };
6 changes: 6 additions & 0 deletions bindings/typescript/src/generated/LLMAnalysis.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { Message } from "./Message";
import type { UniversalParams } from "./UniversalParams";
import type { UniversalUsage } from "./UniversalUsage";

export type LLMAnalysis = { work?: Array<Message>, model?: string, params?: UniversalParams, usage?: UniversalUsage, };
7 changes: 7 additions & 0 deletions bindings/typescript/src/generated/ModalityTokenCount.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { TokenModality } from "./TokenModality";

/**
* Token count for one modality.
*/
export type ModalityTokenCount = { modality?: TokenModality, token_count?: number, };
16 changes: 16 additions & 0 deletions bindings/typescript/src/generated/OutputTokenDetails.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { ModalityTokenCount } from "./ModalityTokenCount";
import type { TokenBreakdown } from "./TokenBreakdown";

/**
* Detailed subsets of inclusive completion/output usage.
*/
export type OutputTokenDetails = {
/**
* Returned candidate content tokens by modality. Reasoning tokens are separate.
*/
content_by_modality?: Array<ModalityTokenCount>,
/**
* Reasoning/thinking tokens included in `UniversalUsage::completion_tokens`.
*/
reasoning?: TokenBreakdown, };
3 changes: 3 additions & 0 deletions bindings/typescript/src/generated/Scope.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type Scope = { "type": "span", id: string, } | { "type": "trace", trace_id: string, } | { "type": "thread", key: string, value: string, };
3 changes: 3 additions & 0 deletions bindings/typescript/src/generated/Section.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type Section = { name: string, description: string, step_ids: Array<string>, };
7 changes: 7 additions & 0 deletions bindings/typescript/src/generated/TokenBreakdown.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { ModalityTokenCount } from "./ModalityTokenCount";

/**
* A token subset with an optional modality breakdown.
*/
export type TokenBreakdown = { total_tokens?: number, by_modality?: Array<ModalityTokenCount>, };
6 changes: 6 additions & 0 deletions bindings/typescript/src/generated/TokenModality.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

/**
* A provider-independent token modality.
*/
export type TokenModality = "unspecified" | "text" | "image" | "audio" | "video" | "document";
4 changes: 4 additions & 0 deletions bindings/typescript/src/generated/ToolResult.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { ToolContentPart } from "./ToolContentPart";

export type ToolResult = { input?: unknown, content?: Array<ToolContentPart>, };
8 changes: 8 additions & 0 deletions bindings/typescript/src/generated/Trajectory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { Agent } from "./Agent";
import type { Finding } from "./Finding";
import type { Scope } from "./Scope";
import type { Section } from "./Section";
import type { Turn } from "./Turn";

export type Trajectory = { scope: Array<Scope>, agent: Agent, sections?: Array<Section>, findings?: Array<Finding>, turns: Array<Turn>, metadata: Record<string, unknown>, version?: string, };
8 changes: 8 additions & 0 deletions bindings/typescript/src/generated/Turn.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { AgentResponse } from "./AgentResponse";
import type { Compaction } from "./Compaction";
import type { Message } from "./Message";
import type { UniversalParams } from "./UniversalParams";
import type { WorkStep } from "./WorkStep";

export type Turn = { request_id: string, response_id?: string, request?: Array<Message>, response?: AgentResponse, work: Array<WorkStep>, model?: string, params?: UniversalParams, start_time: string, end_time?: string, interrupted?: boolean, compaction?: Compaction, };
60 changes: 60 additions & 0 deletions bindings/typescript/src/generated/UniversalUsage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { InputTokenDetails } from "./InputTokenDetails";
import type { OutputTokenDetails } from "./OutputTokenDetails";

/**
* Token usage statistics.
*/
export type UniversalUsage = {
/**
* Tokens in the prompt/input, including provider-generated tool prompts when reported.
*/
prompt_tokens?: number,
/**
* Tokens in the completion/output
*/
completion_tokens?: number,
/**
* Total tokens. Preserves a provider-reported value or falls back to prompt plus completion.
*/
total_tokens?: number,
/**
* Cached tokens in the prompt (from prompt caching)
*/
prompt_cached_tokens?: number,
/**
* Tokens written to cache during this request
*/
prompt_cache_creation_tokens?: number,
/**
* Tokens written to the 5-minute-TTL cache (Anthropic split cache writes)
*/
prompt_cache_creation_5m_tokens?: number,
/**
* Tokens written to the 1-hour-TTL cache (Anthropic split cache writes)
*/
prompt_cache_creation_1h_tokens?: number,
/**
* True when `prompt_tokens` excludes the cache read/creation buckets.
* Anthropic-style usage reports `input_tokens` exclusive of cache
* tokens, while OpenAI-style usage reports `prompt_tokens` inclusive of
* them. Consumers that want an OpenAI-style inclusive prompt total must
* add the cache buckets back when this is set; see
* [`UniversalUsage::inclusive_prompt_tokens`]. Consumers that want an
* Anthropic-style exclusive input count must subtract the cache buckets
* when this is not set; see [`UniversalUsage::exclusive_prompt_tokens`].
*/
prompt_tokens_exclude_cache?: boolean,
/**
* Reasoning/thinking tokens used in the completion.
* `Some(n)` only when `n > 0`; otherwise `None`.
*/
completion_reasoning_tokens?: number,
/**
* Detailed prompt/input token subsets and modality breakdowns.
*/
input_details?: InputTokenDetails,
/**
* Detailed completion/output token subsets and modality breakdowns.
*/
output_details?: OutputTokenDetails, };
6 changes: 6 additions & 0 deletions bindings/typescript/src/generated/Work.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { AgentResponse } from "./AgentResponse";
import type { LLMAnalysis } from "./LLMAnalysis";
import type { ToolResult } from "./ToolResult";

export type Work = { "type": "agent_response" } & AgentResponse | { "type": "tool_result" } & ToolResult | { "type": "llm_analysis" } & LLMAnalysis;
5 changes: 5 additions & 0 deletions bindings/typescript/src/generated/WorkStep.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { Trajectory } from "./Trajectory";
import type { Work } from "./Work";

export type WorkStep = { id: string, span_type: string, name?: string, error?: unknown, start_time: string, end_time?: string, work: Work, sub_agent?: Trajectory, };
5 changes: 5 additions & 0 deletions bindings/typescript/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,8 @@ export type { TokenBudget } from "./generated/TokenBudget";
export type { ChatCompletionRequestMessage } from "./generated/openai/ChatCompletionRequestMessage";
export type { InputItem } from "./generated/openai/InputItem";
export type { InputMessage } from "./generated/anthropic/InputMessage";
export type { Trajectory } from "./generated/Trajectory";
export type { Turn } from "./generated/Turn";
export type { WorkStep } from "./generated/WorkStep";
export type { AgentResponse } from "./generated/AgentResponse";
export type { UniversalUsage } from "./generated/UniversalUsage";
Comment on lines +45 to +49

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Export all new trajectory constituent types

Because the package export map exposes only the root barrel, exporting just these five types leaves most of the newly generated public schema—such as Scope, Agent, Finding, FindingEvidence, Work, ToolResult, LLMAnalysis, and the token-detail types—unimportable by TypeScript consumers. This affects consumers as soon as they need a helper accepting one of these nested types or want to switch directly on the Work union; re-export the complete public trajectory type graph from this barrel.

AGENTS.md reference: AGENTS.md:L11-L14

Useful? React with 👍 / 👎.

3 changes: 2 additions & 1 deletion crates/lingua/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ serde_json.workspace = true
bytes.workspace = true
yaml_serde.workspace = true
serde_with.workspace = true
ts-rs.workspace = true
chrono.workspace = true
ts-rs = { workspace = true, features = ["chrono-impl"] }
thiserror.workspace = true
url.workspace = true
urlencoding.workspace = true
Expand Down
1 change: 1 addition & 0 deletions crates/lingua/src/universal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub mod response_format;
pub mod stream;
pub mod tool_choice;
pub mod tools;
pub mod trajectory;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Re-export the trajectory API

When Rust consumers import universal types through the established public API, use lingua::universal::Trajectory and use lingua::Trajectory both fail because this only exposes the submodule and neither universal/mod.rs nor lib.rs re-exports its types. Re-export at least Trajectory—and preferably its public constituent types—through universal and add the main type to the crate-root export list.

AGENTS.md reference: AGENTS.md:L42-L50

Useful? React with 👍 / 👎.

pub mod transform;

// Re-export main types for convenience
Expand Down
12 changes: 6 additions & 6 deletions crates/lingua/src/universal/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub enum TokenBudget {
///
/// Uses canonical names - adapters handle mapping to provider-specific names.
/// Provider-specific fields without canonical mappings are stored in `extras`.
#[derive(Debug, Clone, Default, Serialize, TS)]
#[derive(Debug, Clone, Default, Serialize, Deserialize, TS)]
#[ts(export)]
pub struct UniversalParams {
// === Sampling parameters ===
Expand Down Expand Up @@ -509,7 +509,7 @@ impl AsRef<str> for SummaryMode {
/// - OpenAI Chat: `"auto"` | `"none"` | `"required"` | `{ type: "function", function: { name } }`
/// - OpenAI Responses: `"auto"` | `{ type: "function", name }`
/// - Anthropic: `{ type: "auto" | "any" | "none" | "tool", name?, disable_parallel_tool_use? }`
#[derive(Debug, Clone, Default, Serialize, TS)]
#[derive(Debug, Clone, Default, Serialize, Deserialize, TS)]
#[ts(export)]
pub struct ToolChoiceConfig {
/// Selection mode - the semantic intent of the tool choice
Expand All @@ -520,7 +520,7 @@ pub struct ToolChoiceConfig {
}

/// Tool selection mode (portable across providers).
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, TS)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, TS)]
#[ts(export)]
pub enum ToolChoiceMode {
/// Provider decides whether to use tools
Expand Down Expand Up @@ -595,7 +595,7 @@ impl AsRef<str> for ToolChoiceMode {
/// - OpenAI Responses: nested under `text.format`
/// - Google: `response_mime_type` + `response_schema`
/// - Anthropic: `{ type: "json_schema", schema, name?, strict?, description? }`
#[derive(Debug, Clone, Default, Serialize, TS)]
#[derive(Debug, Clone, Default, Serialize, Deserialize, TS)]
#[ts(export)]
pub struct ResponseFormatConfig {
/// Output format type
Expand All @@ -615,7 +615,7 @@ impl ResponseFormatConfig {
}

/// Response format type (portable across providers).
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, TS)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, TS)]
#[ts(export)]
pub enum ResponseFormatType {
/// Plain text output (default)
Expand Down Expand Up @@ -666,7 +666,7 @@ impl AsRef<str> for ResponseFormatType {
}

/// JSON schema configuration for structured output.
#[derive(Debug, Clone, Serialize, TS)]
#[derive(Debug, Clone, Serialize, Deserialize, TS)]
#[ts(export)]
pub struct JsonSchemaConfig {
/// Schema name (required by OpenAI)
Expand Down
Loading
Loading