diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8e1d827db..91712a826 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -382,11 +382,12 @@ jobs: - name: DTO vector codecs if: matrix.settings.test && runner.os == 'Linux' run: python3 scripts/check_dto_vectors.py node - - name: Check burst stream contract + - name: Check text return size and burst stream contract if: matrix.settings.test && runner.os == 'Linux' env: TOKIO_WORKER_THREADS: 2 run: | + node bindings/node/bench/bench_data_plane.cjs bindings/node request-200k-no-bodies 1 1 0 node bindings/node/bench/bench_data_plane.cjs bindings/node stream-burst 1 1 0 # index.js / index.d.ts are tracked (they ship to npm) but produced by the # napi build above — fail if the committed copies have drifted from it. diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a827b998..44f13e80e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,47 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 byte-for-byte identical JSON and digest; enable `runtime-manifest` to access `TypeRef::schema` and `aimux_ops::manifest::generate_manifest`. +#### Compact text result JSON (RFC-0049) + +The JSON returned by `text.generate`, `text.consume`, `toolRepair.applyResult` +and language-model `replay.live` contains `steps`, `totalUsage`, optional +`output`, and optional `outputParsed`. Upgrade the C library and generated +bindings together to match the new manifest digest. In C and other raw JSON +consumers, let `last` be `steps[steps.length - 1]` and derive the former +top-level fields as follows. + +| Field or option | Value or derivation | +|---|---| +| `steps` | Read `steps`, in call order. | +| `totalUsage` | Read `totalUsage`, the usage summed over the call. | +| `output` | Use the value if the `output` key exists, including JSON `null`. If `output` is absent and `outputParsed` is `false`, no output was generated (`Err(NoOutputGenerated)` in Rust; `undefined` / `None` / `nil` / absent in bindings). Otherwise use the derived `text`. Providing both `output` and `outputParsed: false` is rejected. | +| `outputParsed` | Present and `false` only when no output was generated (for example, a final `tool-calls` step without an output spec, or a failed streamed output parse). Omitted when an output was produced. | +| `text` | Join the `text` values of `last.content` parts with type `text`, in order, with no separator. | +| `content` | Concatenate each step's `content` in step and part order. | +| `reasoning` | Select `reasoning` and `reasoning-file` from `last.content`. | +| `reasoningText` | Join the `text` values of `reasoning` parts from `last.content`. An empty string means absent. | +| `files` | Map `file` parts across all steps to their inner `file` values. | +| `sources` | Select `source` parts across all steps. | +| `toolCalls` | Select `tool-call` parts across all steps. | +| `staticToolCalls` / `dynamicToolCalls` | From `toolCalls`, select calls with `dynamic` absent or false / exactly true. | +| `toolResults` | Select `tool-result` parts across all steps. | +| `staticToolResults` / `dynamicToolResults` | From `toolResults`, select results with `dynamic` absent or false / exactly true. | +| `finishReason` / `rawFinishReason` | Read the corresponding field from `last`. | +| `usage` | Read `totalUsage` for call usage and `steps[i].usage` for step usage. | +| `warnings` | Concatenate each step's `warnings` in step order. | +| `request` / `response` | Read the corresponding field from `last`. | +| `providerMetadata` | Read `last.providerMetadata` when present. | +| `responseMessages` | Concatenate each step's `response.messages` in step and message order. | +| `include.requestBody` / `include.responseBody` | Each defaults to `false`, including when `include` is omitted. Set each desired field to `true` to return an available body on the step. | +| Node result copying | The typed client attaches non-enumerable getters. `JSON.stringify`, object spread (`{ ...result }`), and `structuredClone` carry only the enumerable wire facts. Read derived properties on the original typed result. | + +Typed bindings provide these values through properties or methods, such as +`result.Text()` in Go and `result.text` in Node. For a streamed call, +`responseBody` opts into any body supplied as response metadata by the model. +Rust implementations that construct `StreamResponseInfo` can set its new +`body` field to `None` when they only supply headers. Trace fingerprints and +recording capture have access to the full request body. + ## [0.7.0] - 2026-11-24 **Breaking release** (pre-1.0 SemVer). The Rust API surface changes in a few diff --git a/aimux-core/src/generate.rs b/aimux-core/src/generate.rs index 3267f2a1b..c1616c4de 100644 --- a/aimux-core/src/generate.rs +++ b/aimux-core/src/generate.rs @@ -109,6 +109,28 @@ async fn resolve_file( // User-facing options // ───────────────────────────────────────────────────────────────────────────── +/// Controls which raw body fields are exposed in generation results. +#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize, JsonSchema)] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +pub struct IncludeOptions { + /// Whether to return the request body. Defaults to false. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub request_body: Option, + /// Whether to return the response body. Defaults to false. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub response_body: Option, +} + +impl IncludeOptions { + fn request_body(self) -> bool { + self.request_body.unwrap_or(false) + } + + fn response_body(self) -> bool { + self.response_body.unwrap_or(false) + } +} + /// User-facing options for `generate_text` and `stream_text`. /// /// Unlike `CallOptions` (provider-facing), this does not include `prompt` @@ -141,6 +163,9 @@ pub struct GenerateTextOptions { /// takes the text as the output. #[serde(default, skip_serializing_if = "Option::is_none")] pub output: Option, + /// Controls the raw bodies exposed in the result. Both default to `false`. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub include: Option, #[serde(default, skip_serializing_if = "Option::is_none")] pub seed: Option, #[serde(default, skip_serializing_if = "Option::is_none")] @@ -261,10 +286,9 @@ impl GenerateTextOptions { /// /// It stores the steps, the usage summed over them and the parsed output, as /// `DefaultGenerateTextResult` does (`generate-text.ts:1691-1808`); every -/// other value is derived from the steps by an accessor. The serialized form -/// is a snapshot that writes the derived values next to the stored ones, so -/// a binding reads `text`, `tool_calls`, `usage` and the rest directly. Only -/// `steps`, `total_usage` and `output` are read back. +/// other value is derived from the steps by an accessor. The wire form carries +/// `steps`, `totalUsage`, optional `output` (when explicitly parsed), and +/// optional `outputParsed: false` (when no output was generated). #[derive(Debug, Clone, Deserialize)] #[serde(try_from = "GenerateTextResultFacts")] #[derive(JsonSchema)] @@ -278,7 +302,9 @@ pub struct GenerateTextResult { /// The output of a result. #[derive(Debug, Clone)] pub(crate) enum OutputState { - /// Parsed by the output specification. + /// Parsed by the default text output, which is implicit on the wire. + PlainText(Value), + /// Parsed by an explicit output specification. Parsed(Value), /// Not parsed: `generate_text` parses only a final step that finished /// with `stop`, or with text and not with tool calls @@ -290,9 +316,6 @@ pub(crate) enum OutputState { Failed(AiMuxError), } -/// The text output, used when no output is configured (`output ?? text()`). -static TEXT_OUTPUT: Output = Output::Text {}; - impl GenerateTextResult { /// Aggregate the steps of a call with the usage summed over them /// (`generate-text.ts:1526-1544`). @@ -503,7 +526,7 @@ impl GenerateTextResult { /// streamed result, the parse error when parsing failed. pub fn output(&self) -> Result<&Value, AiMuxError> { match &self.output { - OutputState::Parsed(value) => Ok(value), + OutputState::Parsed(value) | OutputState::PlainText(value) => Ok(value), OutputState::NotParsed => Err(AiMuxError::no_output_generated("No output generated.")), OutputState::Failed(error) => Err(error.clone()), } @@ -512,109 +535,57 @@ impl GenerateTextResult { pub(crate) fn steps_mut(&mut self) -> &mut [StepResult] { &mut self.steps } - - fn snapshot(&self) -> GenerateTextResultSnapshot<'_> { - let final_step = self.final_step(); - GenerateTextResultSnapshot { - content: self.content(), - text: final_step.text(), - reasoning: final_step.reasoning_outputs(), - reasoning_text: final_step.reasoning_text(), - files: self.files(), - sources: self.sources(), - tool_calls: self.tool_calls(), - tool_results: self.tool_results(), - finish_reason: final_step.finish_reason, - raw_finish_reason: final_step.raw_finish_reason.as_deref(), - usage: &self.total_usage, - total_usage: &self.total_usage, - warnings: self.warnings(), - request: &final_step.request, - response: &final_step.response, - response_messages: self.response_messages(), - provider_metadata: final_step.provider_metadata.as_ref(), - steps: &self.steps, - output: match &self.output { - OutputState::Parsed(value) => Some(value), - OutputState::NotParsed | OutputState::Failed(_) => None, - }, - } - } } -/// The serialized [`GenerateTextResult`]: the stored values and the values -/// the AI SDK's result derives from them (`generate-text.ts:1714-1808`). -/// `finalStep` and the static/dynamic subsets are left out: they are the -/// last entry of `steps` and a filter on `dynamic`. +/// Facts shared by the output and input wire contracts. #[derive(Serialize, JsonSchema)] #[serde(rename_all = "camelCase")] -struct GenerateTextResultSnapshot<'a> { - content: Vec<&'a ContentPart>, - text: String, - /// Deprecated upstream: the last step's reasoning. - reasoning: Vec, - /// Deprecated upstream: the last step's reasoning text. - #[serde(skip_serializing_if = "Option::is_none")] - reasoning_text: Option, - files: Vec<&'a GeneratedFile>, - /// Each with its `type` tag (`generate-text-result.ts:73`). - #[serde(with = "crate::wire::typed_vec")] - #[schemars(with = "Vec", extend("x-aimux-codec" = "tagged"))] - sources: Vec<&'a Source>, - /// Each with its `type` tag (`generate-text-result.ts:78`). - #[serde(with = "crate::wire::typed_vec")] - #[schemars(with = "Vec", extend("x-aimux-codec" = "tagged"))] - tool_calls: Vec<&'a ToolCall>, - /// Each with its `type` tag (`generate-text-result.ts:93`). - #[serde(with = "crate::wire::typed_vec")] - #[schemars(with = "Vec", extend("x-aimux-codec" = "tagged"))] - tool_results: Vec<&'a TypedToolResult>, - finish_reason: FinishReasonUnified, - #[serde(skip_serializing_if = "Option::is_none")] - raw_finish_reason: Option<&'a str>, - usage: &'a LanguageModelUsage, - /// Deprecated upstream: equal to `usage`. - total_usage: &'a LanguageModelUsage, - warnings: Vec<&'a Warning>, - /// Deprecated upstream: the last step's request. - request: &'a RequestInfo, - /// Deprecated upstream: the last step's response. - response: &'a StepResponse, - response_messages: Vec<&'a ModelMessage>, - /// Deprecated upstream: the last step's provider metadata. - #[serde(skip_serializing_if = "Option::is_none")] - provider_metadata: Option<&'a ProviderMetadata>, +struct GenerateTextResultWire<'a> { + #[schemars(length(min = 1))] steps: &'a [StepResult], - /// Absent when the output was not parsed. - #[serde(skip_serializing_if = "Option::is_none")] + total_usage: &'a LanguageModelUsage, + /// An explicit parsed output, including JSON `null`. When absent and + /// `outputParsed` is not `false`, bindings expose the final step's text. + #[serde(default, skip_serializing_if = "Option::is_none")] #[schemars(extend("x-aimux-codec" = "presence"))] output: Option<&'a Value>, + /// Present and `false` when no output was generated (for example, a final + /// `tool-calls` step without an output spec). Omitted when an output was + /// produced. + #[serde(default, skip_serializing_if = "Option::is_none")] + output_parsed: Option, } fn text_result_schema(generator: &mut schemars::SchemaGenerator) -> schemars::Schema { - if generator.contract().is_serialize() { - GenerateTextResultSnapshot::json_schema(generator) - } else { - GenerateTextResultFacts::json_schema(generator) - } + GenerateTextResultWire::json_schema(generator) } impl Serialize for GenerateTextResult { fn serialize(&self, serializer: S) -> Result { - self.snapshot().serialize(serializer) + let (output, output_parsed) = match &self.output { + OutputState::Parsed(value) => (Some(value), None), + OutputState::PlainText(_) => (None, None), + OutputState::NotParsed | OutputState::Failed(_) => (None, Some(false)), + }; + GenerateTextResultWire { + steps: &self.steps, + total_usage: &self.total_usage, + output, + output_parsed, + } + .serialize(serializer) } } -/// The values a serialized [`GenerateTextResult`] is read back from. -#[derive(Deserialize, JsonSchema)] +#[derive(Deserialize)] #[serde(rename_all = "camelCase")] struct GenerateTextResultFacts { - #[schemars(length(min = 1))] steps: Vec, total_usage: LanguageModelUsage, #[serde(default, deserialize_with = "present_value")] - #[schemars(extend("x-aimux-codec" = "presence"))] output: Option, + #[serde(default)] + output_parsed: Option, } /// A present `output` is `Some`, JSON `null` included. @@ -626,15 +597,22 @@ impl TryFrom for GenerateTextResult { type Error = String; fn try_from(facts: GenerateTextResultFacts) -> Result { - if facts.steps.is_empty() { - return Err("a text result has at least one step".into()); - } + let step = facts + .steps + .last() + .ok_or("a text result has at least one step")?; + let output = match (facts.output, facts.output_parsed) { + (Some(_), Some(false)) => { + return Err("a text result cannot carry output when outputParsed is false".into()); + } + (Some(value), _) => OutputState::Parsed(value), + (None, Some(false)) => OutputState::NotParsed, + (None, _) => OutputState::PlainText(Value::String(step.text())), + }; Ok(Self::with_total_usage( facts.steps, facts.total_usage, - facts - .output - .map_or(OutputState::NotParsed, OutputState::Parsed), + output, )) } } @@ -647,10 +625,10 @@ fn generate_output(step: &StepResult, output: Option<&Output>) -> Result spec.parse_complete_output(&text).map(OutputState::Parsed), + None => Ok(OutputState::PlainText(Value::String(text))), + } } else { Ok(OutputState::NotParsed) } @@ -659,12 +637,13 @@ fn generate_output(step: &StepResult, output: Option<&Output>) -> Result) -> OutputState { - match output - .unwrap_or(&TEXT_OUTPUT) - .parse_complete_output(&step.text()) - { - Ok(value) => OutputState::Parsed(value), - Err(error) => OutputState::Failed(error), + let text = step.text(); + match output { + Some(spec) => match spec.parse_complete_output(&text) { + Ok(value) => OutputState::Parsed(value), + Err(error) => OutputState::Failed(error), + }, + None => OutputState::PlainText(Value::String(text)), } } @@ -719,6 +698,7 @@ pub struct StreamTextResult { pub response_headers: Option>, call_id: String, model: StepModel, + response_body: Option, output: Option, } @@ -764,6 +744,7 @@ impl StreamTextResult { stream, call_id, model, + mut response_body, output, .. } = self; @@ -863,7 +844,7 @@ impl StreamTextResult { timestamp: response.timestamp, model_id: response.model_id, headers: response.headers, - body: None, + body: response_body.take(), messages: assembled.messages, }, provider_metadata, @@ -1071,6 +1052,7 @@ async fn generate_in_operation( options: GenerateTextOptions, settings: OperationSettings, ) -> Result { + let include = options.include.unwrap_or_default(); let repair_tool_call = options.repair_tool_call.clone(); let tools = options.tools.clone(); let operation_instructions = options.instructions.clone(); @@ -1163,7 +1145,13 @@ async fn generate_in_operation( if let Some(context) = &context { let _ = context.start_attempt(); } - do_generate_with_logging(model, &call_options, span.clone(), started) + do_generate_with_logging( + model, + &call_options, + include.response_body(), + span.clone(), + started, + ) }), ); let result = match timeout::run(operation, abort_signal.as_ref(), operation_timeout).await { @@ -1230,6 +1218,7 @@ async fn generate_in_operation( content, response_time_ms, step_time_ms, + include, )) } .await; @@ -1414,6 +1403,7 @@ fn build_generated_step( content: crate::response_messages::ResponseMessages, response_time_ms: f64, step_time_ms: f64, + include: IncludeOptions, ) -> StepResult { let GenerateResult { finish_reason, @@ -1424,6 +1414,10 @@ fn build_generated_step( response, .. } = result; + let mut request = request.unwrap_or_default(); + if !include.request_body() { + request.body = None; + } let response = response.unwrap_or_default(); let metadata = response_metadata_defaults( crate::types::ResponseMetadata { @@ -1448,7 +1442,7 @@ fn build_generated_step( usage, performance, warnings, - request: request.unwrap_or_default(), + request, response: StepResponse { id: metadata.id.unwrap_or_default(), timestamp: metadata @@ -1456,7 +1450,7 @@ fn build_generated_step( .unwrap_or_else(crate::timestamp::Timestamp::now), model_id: metadata.model_id.unwrap_or_default(), headers: response.headers, - body: response.body, + body: response.body.filter(|_| include.response_body()), messages: content.messages, }, provider_metadata, @@ -1614,6 +1608,7 @@ async fn stream_in_operation( settings: OperationSettings, ) -> Result { // 1. Convert user prompt to provider-facing prompt. + let include = options.include.unwrap_or_default(); let repair_tool_call = options.repair_tool_call.clone(); let tools = options.tools.clone(); let operation_instructions = options.instructions.clone(); @@ -1746,8 +1741,12 @@ async fn stream_in_operation( request, response, } = result; - let request_body = request.and_then(|request| request.body); - let response_headers = response.and_then(|response| response.headers); + let request_body = request + .and_then(|request| request.body) + .filter(|_| include.request_body()); + let response = response.unwrap_or_default(); + let response_headers = response.headers; + let response_body = response.body.filter(|_| include.response_body()); // The consumption phase keeps observing the same deadlines: the // first-chunk budget armed at operation start continues until the first @@ -2117,6 +2116,7 @@ async fn stream_in_operation( response_headers, call_id: step_call_id, model: step_model, + response_body, output, }) } @@ -2460,16 +2460,30 @@ impl Drop for AbortOnDrop { self.0.abort(); } } +tokio::task_local! { + static PROVIDER_RESPONSE_BODY: bool; +} + +/// The generation operation's response-body preference, including its default. +/// Direct model calls retain the provider's default. +#[doc(hidden)] +#[must_use] +pub fn provider_response_body_preference() -> Option { + PROVIDER_RESPONSE_BODY.try_with(|include| *include).ok() +} + /// Run `do_generate` inside the RFC-0014 `generate` span and emit the /// `generate_end` event. A plain async fn (rather than an inline async block) /// so the `?` error type is pinned by the declared return type. async fn do_generate_with_logging( model: &dyn LanguageModel, call_options: &CallOptions, + response_body: bool, span: tracing::Span, started: Instant, ) -> Result { - let r = async { model.do_generate(call_options).await } + let r = PROVIDER_RESPONSE_BODY + .scope(response_body, model.do_generate(call_options)) .instrument(span) .await?; tracing::info!( diff --git a/aimux-core/src/generate/tests.rs b/aimux-core/src/generate/tests.rs index 3b2961383..70c25f15a 100644 --- a/aimux-core/src/generate/tests.rs +++ b/aimux-core/src/generate/tests.rs @@ -77,6 +77,7 @@ impl LanguageModel for ScriptedModel { "x-request-id".to_string(), "req-1".to_string(), )])), + body: Some(json!({ "id": "resp-1" })), }), }) } @@ -230,7 +231,7 @@ async fn the_stream_is_framed_as_the_ai_sdk_full_stream() { let TextStreamPart::StartStep { request, warnings } = &parts[1] else { unreachable!() }; - assert_eq!(request.body, Some(json!({ "model": "mock-model" }))); + assert_eq!(request.body, None); assert_eq!( serde_json::to_value(warnings).unwrap(), json!([{ "type": "other", "message": "careful" }]) @@ -323,7 +324,7 @@ async fn a_consumed_stream_aggregates_its_step() { assert_eq!(step.text(), "Hello"); assert_eq!(step.response.id, "resp-1"); assert_eq!(step.response.body, None); - assert_eq!(step.request.body, Some(json!({ "model": "mock-model" }))); + assert_eq!(step.request.body, None); assert_eq!(step.warnings.len(), 1); assert_eq!(result.text(), "Hello"); assert_eq!(result.finish_reason(), FinishReasonUnified::Stop); @@ -376,7 +377,7 @@ async fn generate_text_derives_its_result_from_the_step() { assert_eq!(step.response.model_id, "mock-model"); // The call layer stamps a response without a timestamp. assert!(step.response.timestamp.unix_millis() > 0); - assert_eq!(step.response.body, Some(json!({ "id": "resp-1" }))); + assert_eq!(step.response.body, None); assert_eq!(step.performance.time_to_first_output_ms, None); assert_eq!(step.performance.output_tokens_per_second, None); assert_eq!(step.performance.time_between_output_chunks_ms, None); @@ -407,13 +408,12 @@ async fn generate_text_derives_its_result_from_the_step() { )); } -/// The serialized result writes the derived values next to the stored ones -/// and reads back only `steps`, `total_usage` and `output`. The finish reason +/// The serialized result carries only the stored facts. The finish reason /// is a string and the usage is the flat `LanguageModelUsage` (usage.ts:10-67), /// camelCase with an unknown count absent; a step is its own fields /// (step-result.ts:138-278), camelCase. #[tokio::test] -async fn the_result_snapshot_round_trips() { +async fn the_result_facts_round_trip() { let model = ScriptedModel::generating(generated( vec![text_content("Hello")], FinishReasonUnified::Stop, @@ -422,16 +422,14 @@ async fn the_result_snapshot_round_trips() { .await .unwrap(); let wire = serde_json::to_value(&result).unwrap(); - assert_eq!(wire["text"], json!("Hello")); - assert_eq!(wire["finishReason"], json!("stop")); - assert_eq!(wire["rawFinishReason"], json!("stop")); - assert_eq!(wire["usage"]["inputTokens"], json!(10)); + assert_eq!(wire.as_object().unwrap().len(), 2); + assert_eq!(wire["totalUsage"]["inputTokens"], json!(10)); assert_eq!( - wire["usage"]["inputTokenDetails"], + wire["totalUsage"]["inputTokenDetails"], json!({ "noCacheTokens": 6, "cacheReadTokens": 4 }) ); - assert_eq!(wire["usage"]["totalTokens"], json!(16)); - assert_eq!(wire["output"], json!("Hello")); + assert_eq!(wire["totalUsage"]["totalTokens"], json!(16)); + assert!(wire.get("output").is_none()); assert_eq!(wire["steps"].as_array().unwrap().len(), 1); let step = &wire["steps"][0]; assert_eq!(step["stepNumber"], json!(0)); @@ -447,6 +445,37 @@ async fn the_result_snapshot_round_trips() { let back: GenerateTextResult = serde_json::from_value(wire.clone()).unwrap(); assert_eq!(serde_json::to_value(&back).unwrap(), wire); + for value in [Value::Null, json!("Hello"), json!({"parsed": true})] { + let mut explicit = wire.clone(); + explicit["output"] = value.clone(); + let result: GenerateTextResult = serde_json::from_value(explicit.clone()).unwrap(); + assert_eq!(result.output().unwrap(), &value); + assert_eq!(serde_json::to_value(&result).unwrap(), explicit); + } + + // NotParsed (e.g. a tool-calls step with no output spec) carries + // `outputParsed: false` and round-trips to `Err(NoOutputGenerated)`. + let tool_model = ScriptedModel::generating(generated( + vec![text_content("Calling tool")], + FinishReasonUnified::ToolCalls, + )); + let unparsed = generate_text(&tool_model, "hi", GenerateTextOptions::default()) + .await + .unwrap(); + let unparsed_wire = serde_json::to_value(&unparsed).unwrap(); + assert!(unparsed_wire.get("output").is_none()); + assert_eq!(unparsed_wire["outputParsed"], json!(false)); + let unparsed_back: GenerateTextResult = serde_json::from_value(unparsed_wire.clone()).unwrap(); + assert!(matches!( + unparsed_back.output(), + Err(AiMuxError::NoOutputGenerated { .. }) + )); + assert_eq!(serde_json::to_value(&unparsed_back).unwrap(), unparsed_wire); + + let mut contradictory = unparsed_wire; + contradictory["output"] = Value::Null; + assert!(serde_json::from_value::(contradictory).is_err()); + let mut no_steps = wire; no_steps["steps"] = json!([]); assert!(serde_json::from_value::(no_steps).is_err()); @@ -684,7 +713,7 @@ async fn generate_object_wraps_the_output() { assert_eq!(result.finish_reason, FinishReasonUnified::Stop); assert_eq!(result.usage.input_tokens, Some(10)); assert_eq!(result.response.id, "resp-1"); - assert_eq!(result.response.body, Some(json!({ "id": "resp-1" }))); + assert_eq!(result.response.body, None); assert_eq!(result.reasoning, None); let wire = serde_json::to_value(&result).unwrap(); assert!(wire.get("raw").is_none()); @@ -2562,3 +2591,69 @@ async fn consumer_polling_after_deadline_delivers_sync_tool_call_but_times_out_h assert!(dropped.load(Ordering::SeqCst)); } } + +#[tokio::test] +async fn include_controls_body_echoes_without_removing_metadata() { + for (include, request, response) in [ + (None, false, false), + (Some(IncludeOptions::default()), false, false), + ( + Some(IncludeOptions { + request_body: Some(true), + response_body: None, + }), + true, + false, + ), + ( + Some(IncludeOptions { + request_body: None, + response_body: Some(true), + }), + false, + true, + ), + ( + Some(IncludeOptions { + request_body: Some(true), + response_body: Some(true), + }), + true, + true, + ), + ] { + let options = GenerateTextOptions { + include, + ..Default::default() + }; + let generating = ScriptedModel::generating(generated( + vec![text_content("hi")], + FinishReasonUnified::Stop, + )); + let streaming = ScriptedModel::streaming(text_stream(&["hi"], FinishReasonUnified::Stop)); + let generated = generate_text(&generating, "hi", options.clone()) + .await + .unwrap(); + let streamed = stream_text(&streaming, "hi", options).await.unwrap(); + assert_eq!(streamed.request_body.is_some(), request); + for result in [generated, streamed.consume().await.unwrap()] { + let wire = serde_json::to_value(&result).unwrap(); + assert_eq!(wire.as_object().unwrap().len(), 2); + assert!(wire.get("totalUsage").is_some()); + let step = &wire["steps"][0]; + assert_eq!( + step["request"].get("body"), + request.then(|| json!({"model": "mock-model"})).as_ref() + ); + assert_eq!( + step["response"].get("body"), + response.then(|| json!({"id": "resp-1"})).as_ref() + ); + assert_eq!(step["response"]["id"], "resp-1"); + assert_eq!(result.text(), "hi"); + assert_eq!(result.output().unwrap(), "hi"); + let round_trip: GenerateTextResult = serde_json::from_value(wire).unwrap(); + assert_eq!(round_trip.output().unwrap(), "hi"); + } + } +} diff --git a/aimux-core/src/lib.rs b/aimux-core/src/lib.rs index c951f6c9f..4c042792c 100644 --- a/aimux-core/src/lib.rs +++ b/aimux-core/src/lib.rs @@ -95,7 +95,7 @@ pub mod prelude { pub use crate::generate::generate_object; pub use crate::generate::{ GenerateObjectResponse, GenerateObjectResult, GenerateTextOptions, GenerateTextResult, - StreamTextResult, generate_text, generate_text_as_openai, + IncludeOptions, StreamTextResult, generate_text, generate_text_as_openai, generate_text_result_to_chat_completion, stream_text, stream_text_as_openai, }; pub use crate::image_model::{ImageCallOptions, ImageModel, ImageResult, generate_image}; diff --git a/aimux-core/src/replay.rs b/aimux-core/src/replay.rs index 468d8fb26..0f121e476 100644 --- a/aimux-core/src/replay.rs +++ b/aimux-core/src/replay.rs @@ -1129,6 +1129,7 @@ fn generate_options_from_call_options( presence_penalty: o.presence_penalty, frequency_penalty: o.frequency_penalty, output: o.response_format.map(output_for_response_format), + include: None, seed: o.seed, tools: o.tools, tool_choice: o.tool_choice.map(user_tool_choice), diff --git a/aimux-core/src/shared.rs b/aimux-core/src/shared.rs index 97fe64abc..3b1e59812 100644 --- a/aimux-core/src/shared.rs +++ b/aimux-core/src/shared.rs @@ -436,6 +436,14 @@ pub struct RequestInfo { pub struct StreamResponseInfo { #[serde(default, skip_serializing_if = "Option::is_none")] pub headers: Option, + /// Optional opaque response body supplied with the stream metadata. + #[serde( + default, + deserialize_with = "crate::wire::present", + skip_serializing_if = "Option::is_none" + )] + #[schemars(extend("x-aimux-codec" = "presence"))] + pub body: Option, } impl From for ResponseInfo { diff --git a/aimux-core/tests/ai_sdk_json_test.rs b/aimux-core/tests/ai_sdk_json_test.rs index dfd409ae0..cdccb7b26 100644 --- a/aimux-core/tests/ai_sdk_json_test.rs +++ b/aimux-core/tests/ai_sdk_json_test.rs @@ -577,18 +577,11 @@ fn standalone_tool_calls_and_sources_are_tagged() { })) .unwrap(); let written = serde_json::to_value(&generated).unwrap(); - assert_eq!(written["toolCalls"], json!([call])); - assert_eq!(written["sources"], json!([url, document])); - // The tag comes first, as in the AI SDK's objects. - let text = serde_json::to_string(&generated).unwrap(); - assert!( - text.contains(r#""toolCalls":[{"type":"tool-call","toolCallId":"call-1""#), - "{text}" - ); - assert!( - text.contains(r#""sources":[{"type":"source","sourceType":"url","id":"s1""#), - "{text}" - ); + assert_eq!(written["steps"][0]["content"], json!([call, url, document])); + assert!(written.get("toolCalls").is_none()); + assert!(written.get("sources").is_none()); + assert_eq!(generated.tool_calls().len(), 1); + assert_eq!(generated.sources().len(), 2); // An approval request's call is tagged, standalone and in `content`. assert_json_back::(json!({ "approvalId": "a1", "toolCall": call })); @@ -688,12 +681,14 @@ fn steps_usage_and_tool_outputs_are_the_ai_sdk_json() { })) .unwrap(); let written = serde_json::to_value(&generated).unwrap(); - assert_eq!(written["toolResults"], json!([result])); + assert_eq!(written["steps"][0]["content"][1], result); + assert!(written.get("toolResults").is_none()); + assert_eq!(generated.tool_results().len(), 1); assert_eq!( written["totalUsage"], json!({ "inputTokenDetails": {}, "outputTokenDetails": {} }) ); - assert_eq!(written["response"]["modelId"], "model"); + assert_eq!(written["steps"][0]["response"]["modelId"], "model"); assert!(written.get("rawFinishReason").is_none()); assert_json_back::(json!({ diff --git a/aimux-core/tests/trace_stream_text_test.rs b/aimux-core/tests/trace_stream_text_test.rs index 23695261e..25d597ce2 100644 --- a/aimux-core/tests/trace_stream_text_test.rs +++ b/aimux-core/tests/trace_stream_text_test.rs @@ -4,7 +4,7 @@ use std::sync::Arc; use aimux_core::error::AiMuxError; -use aimux_core::generate::{GenerateTextOptions, stream_text}; +use aimux_core::generate::{GenerateTextOptions, IncludeOptions, stream_text}; use aimux_core::language_model::LanguageModel; use aimux_core::options::CallOptions; use aimux_core::result::{GenerateResult, StreamResult}; @@ -13,7 +13,6 @@ use aimux_core::stream_part::StreamPart; use aimux_core::trace::{RingTraceStore, TraceLayer, TraceRecord}; use aimux_core::types::{FinishReason, FinishReasonUnified, InputTokenUsage, Usage}; use async_trait::async_trait; -use futures::StreamExt; use serde_json::json; /// Streams one delta and `Finish` for a request body of over two 4 KiB blocks. @@ -43,11 +42,19 @@ impl LanguageModel for Streaming { }; let parts: Vec> = vec![ Ok(StreamPart::StreamStart { warnings: vec![] }), + Ok(StreamPart::TextStart { + id: "t".into(), + provider_metadata: None, + }), Ok(StreamPart::TextDelta { id: "t".into(), delta: "ok".into(), provider_metadata: None, }), + Ok(StreamPart::TextEnd { + id: "t".into(), + provider_metadata: None, + }), Ok(StreamPart::Finish { finish_reason: FinishReason { unified: FinishReasonUnified::Stop, @@ -88,11 +95,28 @@ fn records(store: &RingTraceStore) -> Vec { async fn a_completed_stream_text_call_is_traced_as_completed() { let store = Arc::new(RingTraceStore::new()); let layer = TraceLayer::new(Arc::new(Streaming), store.clone()); - for _ in 0..2 { - let result = stream_text(&layer, "hi", GenerateTextOptions::default()) - .await - .unwrap(); - result.stream.collect::>().await; + for include in [ + None, + Some(IncludeOptions { + request_body: Some(true), + response_body: None, + }), + ] { + let result = stream_text( + &layer, + "hi", + GenerateTextOptions { + include, + ..GenerateTextOptions::default() + }, + ) + .await + .unwrap(); + let result = result.consume().await.unwrap(); + assert_eq!( + result.final_step().request.body.is_some(), + include.is_some() + ); } // The pump task, not the consumer, lets go of the provider stream. for _ in 0..100 { @@ -104,6 +128,8 @@ async fn a_completed_stream_text_call_is_traced_as_completed() { let recs = records(&store); assert_eq!(recs.len(), 2); + assert_eq!(recs[0].fingerprint.body_hash, recs[1].fingerprint.body_hash); + assert!(recs[0].fingerprint.len_bytes > 8400); for rec in &recs { assert_eq!(rec.error, None, "{rec:?}"); } diff --git a/aimux-ffi/include/aimux.h b/aimux-ffi/include/aimux.h index 4d5c1c15f..dc45a125a 100644 --- a/aimux-ffi/include/aimux.h +++ b/aimux-ffi/include/aimux.h @@ -1,4 +1,4 @@ -/* Generated by aimux-codegen. Do not edit. Manifest SHA-256: cd147fa9595ede3951744fa261da98cc18c204e65b4081073ad3a3c1b68bfd92 */ +/* Generated by aimux-codegen. Do not edit. Manifest SHA-256: 6914772fdc03df08cba497def41cb354fe52e40eba49844a66938b4cd38c5d83 */ #ifndef AIMUX_H #define AIMUX_H @@ -11,7 +11,7 @@ extern "C" { #define AIMUX_ABI_VERSION UINT32_C(65536) #define AIMUX_OPS_VERSION "1.0" -#define AIMUX_MANIFEST_DIGEST "cd147fa9595ede3951744fa261da98cc18c204e65b4081073ad3a3c1b68bfd92" +#define AIMUX_MANIFEST_DIGEST "6914772fdc03df08cba497def41cb354fe52e40eba49844a66938b4cd38c5d83" #define AIMUX_OP_ABORT_CREATE "abort.create" #define AIMUX_OP_ABORT_SIGNAL "abort.signal" diff --git a/aimux-ops/src/dto_vectors.rs b/aimux-ops/src/dto_vectors.rs index 87ad8f825..b7d93f65b 100644 --- a/aimux-ops/src/dto_vectors.rs +++ b/aimux-ops/src/dto_vectors.rs @@ -265,8 +265,8 @@ fn dto_vectors_round_trip_through_rust() { } } -/// Keep realistic business vectors tied to Rust serialization, including derived -/// result fields. Set UPDATE_DTO_VECTORS=1 to refresh these three files. +/// Keep realistic business vectors tied to Rust serialization, including compact +/// result facts. Set UPDATE_DTO_VECTORS=1 to refresh these files. #[test] fn business_vectors_match_rust_serialization() { use aimux_core::generate::GenerateTextResult; @@ -294,7 +294,7 @@ fn business_vectors_match_rust_serialization() { "timestamp": "2026-01-01T00:00:00.000Z", "messages": [{"role": "assistant", "content": [{"type": "text", "text": "Hello, world!"}]}]}, "providerMetadata": {"openai": {"serviceTier": "default", "opaque": null}} - }], "totalUsage": usage, "output": "Hello, world!" + }], "totalUsage": usage })).unwrap(); let cassette: Value = serde_json::from_str(include_str!( "../../aimux-providers/tests/cassettes/openai/completions_api_agent_prompt.json" @@ -352,18 +352,58 @@ fn business_vectors_match_rust_serialization() { })) .unwrap(); let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../contract-tests/dto"); - for (name, value) in [ - ("GenerateTextResult", serde_json::to_value(result).unwrap()), - ("Recording", serde_json::to_value(recording).unwrap()), - ("TraceRecord", serde_json::to_value(trace).unwrap()), + let plain = serde_json::to_value(result).unwrap(); + let mut structured = plain.clone(); + structured["output"] = Value::Null; + let structured: GenerateTextResult = serde_json::from_value(structured).unwrap(); + for (file, value) in [ + ("GenerateTextResult/001.json", plain), + ( + "GenerateTextResult/002.json", + serde_json::to_value(structured).unwrap(), + ), + ( + "Recording/001.json", + serde_json::to_value(recording).unwrap(), + ), + ("TraceRecord/001.json", serde_json::to_value(trace).unwrap()), ] { - let path = root.join(name).join("001.json"); + let path = root.join(file); if std::env::var_os("UPDATE_DTO_VECTORS").is_some() { std::fs::create_dir_all(path.parent().unwrap()).unwrap(); std::fs::write(&path, serde_json::to_string_pretty(&value).unwrap() + "\n").unwrap(); } let expected: Value = serde_json::from_str(&std::fs::read_to_string(path).unwrap()).unwrap(); - assert_eq!(value, expected, "{name}"); + assert_eq!(value, expected, "{file}"); } } + +#[test] +fn aimux_error_vectors_match_legacy_value_bytes() { + use crate::dispatch::{Params, WireParams, decode}; + use aimux_core::error::AiMuxError; + + let root = + std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../contract-tests/dto/AiMuxError"); + let mut checked = 0; + for entry in std::fs::read_dir(root).unwrap() { + let path = entry.unwrap().path(); + if path.extension().and_then(|ext| ext.to_str()) != Some("json") { + continue; + } + let json = std::fs::read(&path).unwrap(); + let value: Value = serde_json::from_slice(&json).unwrap(); + let expected = round_trip::(value).unwrap().to_string(); + let direct = + decode::(Params::Wire(WireParams::new(&json, "params_json"))).unwrap(); + assert_eq!( + crate::dispatch::serialize_result(direct).unwrap(), + expected, + "{}", + path.display() + ); + checked += 1; + } + assert!(checked > 0); +} diff --git a/aimux-ops/src/manifest.digest b/aimux-ops/src/manifest.digest index e7c08e9a4..3a97fb6d1 100644 --- a/aimux-ops/src/manifest.digest +++ b/aimux-ops/src/manifest.digest @@ -1 +1 @@ -cd147fa9595ede3951744fa261da98cc18c204e65b4081073ad3a3c1b68bfd92 +6914772fdc03df08cba497def41cb354fe52e40eba49844a66938b4cd38c5d83 diff --git a/aimux-ops/src/manifest.json.zlib b/aimux-ops/src/manifest.json.zlib index 6d2d88f6f..8faf853d9 100644 Binary files a/aimux-ops/src/manifest.json.zlib and b/aimux-ops/src/manifest.json.zlib differ diff --git a/aimux-ops/src/manifest.rs b/aimux-ops/src/manifest.rs index a1411a39a..71504d753 100644 --- a/aimux-ops/src/manifest.rs +++ b/aimux-ops/src/manifest.rs @@ -403,12 +403,16 @@ fn type_contract(serialize: bool) -> (Vec, Value) { } } if serialize { - // Bindings also read errors, recordings and trace records, which no op returns. + // Bindings also use these standalone DTOs outside operation results. use crate::op::TypeRef; for ty in [ TypeRef::of::(), TypeRef::of::(), TypeRef::of::(), + // These content projections were previously reachable from the text snapshot. + TypeRef::of::(), + TypeRef::of::(), + TypeRef::of::(), ] { roots.insert((ty.id)().into_owned(), ty); } @@ -451,6 +455,10 @@ mod tests { #[test] fn manifest_has_stable_versions_kinds_codes_and_registered_ops() { let value = manifest(); + assert_eq!( + manifest_digest(), + "6914772fdc03df08cba497def41cb354fe52e40eba49844a66938b4cd38c5d83", + ); assert_eq!(value["abiVersion"], 65536); assert_eq!(value["opsVersion"], "1.0"); assert_eq!(value["generatorVersion"], env!("CARGO_PKG_VERSION")); diff --git a/aimux-ops/src/ops/misc.rs b/aimux-ops/src/ops/misc.rs index b7d5b25e9..638454dd7 100644 --- a/aimux-ops/src/ops/misc.rs +++ b/aimux-ops/src/ops/misc.rs @@ -576,9 +576,12 @@ mod tests { .unwrap(); let actual: Value = serde_json::from_str(&actual).unwrap(); assert_eq!(actual, expected); - assert_eq!(actual["toolCalls"][0]["input"], json!({"city":"Tokyo"})); assert_eq!( - actual["responseMessages"][0]["content"][0]["input"], + actual["steps"][0]["content"][0]["input"], + json!({"city":"Tokyo"}) + ); + assert_eq!( + actual["steps"][0]["response"]["messages"][0]["content"][0]["input"], json!({"city":"Tokyo"}) ); } diff --git a/aimux-ops/src/ops/text.rs b/aimux-ops/src/ops/text.rs index 6e6a8a6fb..726498749 100644 --- a/aimux-ops/src/ops/text.rs +++ b/aimux-ops/src/ops/text.rs @@ -669,7 +669,7 @@ mod tests { .await .unwrap(); let result: Value = serde_json::from_str(&result).unwrap(); - assert_eq!(result["text"], "你好 🌏"); + assert_eq!(result["steps"][0]["content"][0]["text"], "你好 🌏"); assert_eq!(result["steps"].as_array().unwrap().len(), 1); let seen = model.seen.lock().unwrap().clone().unwrap(); assert_eq!(seen.max_output_tokens, Some(7)); @@ -679,7 +679,7 @@ mod tests { .await .unwrap(); let result: Value = serde_json::from_str(&result).unwrap(); - assert_eq!(result["text"], "你好 🌏"); + assert_eq!(result["steps"][0]["content"][0]["text"], "你好 🌏"); let result = generate_openai(ctx(), model.entry(), request().into()) .await .unwrap(); @@ -1026,7 +1026,7 @@ mod tests { assert_eq!(result["object"], "chat.completion"); assert_eq!(result["choices"][0]["message"]["content"], model.text); } - _ => assert_eq!(result["text"], model.text), + _ => assert_eq!(result["steps"][0]["content"][0]["text"], model.text), } } for name in ["text.stream", "text.streamOpenAI"] { diff --git a/aimux-providers/examples/perf_data_plane.rs b/aimux-providers/examples/perf_data_plane.rs index 1794779c7..fccfdd985 100644 --- a/aimux-providers/examples/perf_data_plane.rs +++ b/aimux-providers/examples/perf_data_plane.rs @@ -5,7 +5,7 @@ use std::sync::Arc; use std::sync::atomic::{AtomicBool, AtomicU64, Ordering::Relaxed}; use std::time::{Duration, Instant}; -use aimux_core::generate::{GenerateTextOptions, generate_text, stream_text}; +use aimux_core::generate::{GenerateTextOptions, IncludeOptions, generate_text, stream_text}; use aimux_core::parse_tool_call::parse_tool_call; use aimux_core::result::ContentPart; use aimux_core::stream_part::TextStreamPart; @@ -140,7 +140,9 @@ fn main() { assert!(samples > 0); let (prompt, text, tool_count, streaming) = match scenario { "request-small" => ("hi".into(), "hello".into(), 0, false), - "request-200k" | "serialize-200k" => ("a".repeat(200_000), "b".repeat(50_000), 0, false), + "request-200k" | "request-200k-omit-body" | "serialize-200k" => { + ("a".repeat(200_000), "b".repeat(50_000), 0, false) + } "gen-tools-loop" | "validate-tool" => ("hi".into(), "hello".into(), 30, false), "stream-1k-chunks" => ("hi".into(), DELTA_TEXT.repeat(DELTAS), 0, true), "id-control" | "id-text" | "id-reasoning" | "active-hashset" | "active-vec" @@ -166,7 +168,13 @@ fn main() { }) .unwrap() .chat("gpt-4o"); - let options = options(tool_count); + let mut options = options(tool_count); + if scenario == "request-200k-omit-body" { + options.include = Some(IncludeOptions { + response_body: Some(false), + ..IncludeOptions::default() + }); + } let tool_call = RawToolCall { tool_call_id: "lookup".into(), tool_name: "lookup_0".into(), diff --git a/aimux-providers/src/anthropic/language_model.rs b/aimux-providers/src/anthropic/language_model.rs index c2087e8e7..726a99a26 100644 --- a/aimux-providers/src/anthropic/language_model.rs +++ b/aimux-providers/src/anthropic/language_model.rs @@ -1326,7 +1326,9 @@ pub(crate) async fn anthropic_generate_core( let resp = aimux_provider_utils::post_json_to_api( request, body.clone(), - aimux_provider_utils::create_json_response_handler(), + aimux_provider_utils::create_json_response_handler_with_body( + aimux_core::generate::provider_response_body_preference().unwrap_or(true), + ), config.failed_response_handler(), ) .await?; @@ -1498,6 +1500,7 @@ pub(crate) async fn anthropic_stream_core( request: Some(aimux_core::shared::RequestInfo { body: Some(body) }), response: Some(aimux_core::shared::StreamResponseInfo { headers: Some(response_headers), + body: None, }), }, options, diff --git a/aimux-providers/src/bedrock/chat_language_model.rs b/aimux-providers/src/bedrock/chat_language_model.rs index 4afba3cf7..b03b6a13d 100644 --- a/aimux-providers/src/bedrock/chat_language_model.rs +++ b/aimux-providers/src/bedrock/chat_language_model.rs @@ -107,7 +107,9 @@ impl LanguageModel for BedrockModel { let resp = aimux_provider_utils::post_to_api( exchange.request(url, options), HttpBody::Bytes(body_str.into_bytes(), "application/json".to_string()), - aimux_provider_utils::create_json_response_handler_with_body(false), + aimux_provider_utils::create_json_response_handler_with_body( + aimux_core::generate::provider_response_body_preference() == Some(true), + ), super::error::bedrock_failed_response_handler(), ) .await?; @@ -190,7 +192,7 @@ impl LanguageModel for BedrockModel { .and_then(|date| aimux_core::Timestamp::from_http_date(date)), model_id: Some(self.model_id.clone()), headers: Some(response_headers), - body: None, + body: resp.raw_value, }), request: Some(aimux_core::shared::RequestInfo { body: Some(body) }), }) @@ -251,6 +253,7 @@ impl LanguageModel for BedrockModel { request: Some(aimux_core::shared::RequestInfo { body: Some(body) }), response: Some(aimux_core::shared::StreamResponseInfo { headers: Some(response_headers), + body: None, }), }, options, diff --git a/aimux-providers/src/codex/responses_model.rs b/aimux-providers/src/codex/responses_model.rs index 86d062f1a..bbef7c582 100644 --- a/aimux-providers/src/codex/responses_model.rs +++ b/aimux-providers/src/codex/responses_model.rs @@ -249,6 +249,7 @@ impl CodexModel { request: Some(aimux_core::shared::RequestInfo { body: Some(body) }), response: Some(aimux_core::shared::StreamResponseInfo { headers: Some(response_headers), + body: None, }), }, options, diff --git a/aimux-providers/src/cohere/chat_language_model.rs b/aimux-providers/src/cohere/chat_language_model.rs index 5663a0346..83941d0a8 100644 --- a/aimux-providers/src/cohere/chat_language_model.rs +++ b/aimux-providers/src/cohere/chat_language_model.rs @@ -253,6 +253,7 @@ impl LanguageModel for CohereModel { request: Some(aimux_core::shared::RequestInfo { body: Some(body) }), response: Some(aimux_core::shared::StreamResponseInfo { headers: Some(response_headers), + body: None, }), }, options, diff --git a/aimux-providers/src/deepseek/chat/chat_language_model.rs b/aimux-providers/src/deepseek/chat/chat_language_model.rs index f56a7ac60..cdb26dd9f 100644 --- a/aimux-providers/src/deepseek/chat/chat_language_model.rs +++ b/aimux-providers/src/deepseek/chat/chat_language_model.rs @@ -507,6 +507,7 @@ impl LanguageModel for DeepSeekChatLanguageModel { request: Some(RequestInfo { body: Some(body) }), response: Some(StreamResponseInfo { headers: Some(response_headers), + body: None, }), }, options, diff --git a/aimux-providers/src/google/language_model.rs b/aimux-providers/src/google/language_model.rs index 5e02ed94d..5e36898c1 100644 --- a/aimux-providers/src/google/language_model.rs +++ b/aimux-providers/src/google/language_model.rs @@ -179,7 +179,9 @@ impl LanguageModel for GoogleModel { let resp = aimux_provider_utils::post_json_to_api( exchange.request(url, options), body.clone(), - aimux_provider_utils::create_json_response_handler(), + aimux_provider_utils::create_json_response_handler_with_body( + aimux_core::generate::provider_response_body_preference().unwrap_or(true), + ), super::google_failed_response_handler(), ) .await?; @@ -291,6 +293,7 @@ impl LanguageModel for GoogleModel { request: Some(aimux_core::shared::RequestInfo { body: Some(body) }), response: Some(aimux_core::shared::StreamResponseInfo { headers: Some(response_headers), + body: None, }), }, options, diff --git a/aimux-providers/src/groq/chat_language_model.rs b/aimux-providers/src/groq/chat_language_model.rs index a8745aecc..00e268b54 100644 --- a/aimux-providers/src/groq/chat_language_model.rs +++ b/aimux-providers/src/groq/chat_language_model.rs @@ -371,6 +371,7 @@ impl LanguageModel for GroqChatLanguageModel { request: Some(RequestInfo { body: Some(body) }), response: Some(StreamResponseInfo { headers: Some(response_headers), + body: None, }), }, options, diff --git a/aimux-providers/src/huggingface/responses/responses_language_model.rs b/aimux-providers/src/huggingface/responses/responses_language_model.rs index 3aa2caf5b..90034f091 100644 --- a/aimux-providers/src/huggingface/responses/responses_language_model.rs +++ b/aimux-providers/src/huggingface/responses/responses_language_model.rs @@ -280,6 +280,7 @@ impl LanguageModel for HuggingFaceResponsesModel { request: Some(aimux_core::shared::RequestInfo { body: Some(body) }), response: Some(aimux_core::shared::StreamResponseInfo { headers: Some(response_headers), + body: None, }), }, options, diff --git a/aimux-providers/src/mistral/chat_language_model.rs b/aimux-providers/src/mistral/chat_language_model.rs index d382c9a7d..e6f69f644 100644 --- a/aimux-providers/src/mistral/chat_language_model.rs +++ b/aimux-providers/src/mistral/chat_language_model.rs @@ -262,6 +262,7 @@ impl LanguageModel for MistralModel { request: Some(aimux_core::shared::RequestInfo { body: Some(body) }), response: Some(aimux_core::shared::StreamResponseInfo { headers: Some(response_headers), + body: None, }), }, options, diff --git a/aimux-providers/src/open_responses/responses/language_model.rs b/aimux-providers/src/open_responses/responses/language_model.rs index 13801d3ce..897feff1b 100644 --- a/aimux-providers/src/open_responses/responses/language_model.rs +++ b/aimux-providers/src/open_responses/responses/language_model.rs @@ -406,6 +406,7 @@ impl LanguageModel for OpenResponsesModel { request: Some(aimux_core::shared::RequestInfo { body: Some(body) }), response: Some(aimux_core::shared::StreamResponseInfo { headers: Some(response_headers), + body: None, }), }, options, diff --git a/aimux-providers/src/openai/chat/chat_language_model.rs b/aimux-providers/src/openai/chat/chat_language_model.rs index bbca0a1de..8778c9968 100644 --- a/aimux-providers/src/openai/chat/chat_language_model.rs +++ b/aimux-providers/src/openai/chat/chat_language_model.rs @@ -176,7 +176,9 @@ pub(crate) async fn execute_generate( http, header_layers, aimux_provider_utils::HttpBody::Json(body.clone()), - aimux_provider_utils::create_json_response_handler::(), + aimux_provider_utils::create_json_response_handler_with_body::( + aimux_core::generate::provider_response_body_preference().unwrap_or(true), + ), crate::openai::error::openai_failed_response_handler(), ) .await?; @@ -386,6 +388,7 @@ pub(crate) async fn execute_stream( request: Some(aimux_core::shared::RequestInfo { body: Some(body) }), response: Some(aimux_core::shared::StreamResponseInfo { headers: Some(response_headers), + body: None, }), }, options, diff --git a/aimux-providers/src/openai/completion/completion_language_model.rs b/aimux-providers/src/openai/completion/completion_language_model.rs index db1103206..4d4ef5b8e 100644 --- a/aimux-providers/src/openai/completion/completion_language_model.rs +++ b/aimux-providers/src/openai/completion/completion_language_model.rs @@ -477,6 +477,7 @@ impl LanguageModel for OpenAICompletionModel { request: Some(RequestInfo { body: Some(body) }), response: Some(StreamResponseInfo { headers: Some(response_headers), + body: None, }), }, options, diff --git a/aimux-providers/src/openai/responses/responses_language_model.rs b/aimux-providers/src/openai/responses/responses_language_model.rs index 5bb76898a..0029e44a4 100644 --- a/aimux-providers/src/openai/responses/responses_language_model.rs +++ b/aimux-providers/src/openai/responses/responses_language_model.rs @@ -323,6 +323,7 @@ impl LanguageModel for OpenAIResponsesModel { request: Some(aimux_core::shared::RequestInfo { body: Some(body) }), response: Some(aimux_core::shared::StreamResponseInfo { headers: Some(response_headers), + body: None, }), }, options, diff --git a/aimux-providers/src/openai/tests/chat/chat_language_model.rs b/aimux-providers/src/openai/tests/chat/chat_language_model.rs index 7f8dd9c42..b31c25f4d 100644 --- a/aimux-providers/src/openai/tests/chat/chat_language_model.rs +++ b/aimux-providers/src/openai/tests/chat/chat_language_model.rs @@ -3240,3 +3240,63 @@ mod older_stream { ); } } + +#[tokio::test] +async fn generate_retains_raw_usage_and_request_when_response_body_is_omitted() { + use aimux_core::generate::{GenerateTextOptions, IncludeOptions, generate_text}; + + use aimux_core::language_model_middleware::{LanguageModelMiddleware, wrap_language_model}; + use aimux_core::result::{GenerateResult, StreamResult}; + use futures::future::BoxFuture; + + struct ObserveBodies(bool); + + #[async_trait::async_trait] + impl LanguageModelMiddleware for ObserveBodies { + async fn wrap_generate( + &self, + _: &CallOptions, + _: &dyn LanguageModel, + generate: &( + dyn Fn() -> BoxFuture<'_, Result> + Send + Sync + ), + _: &(dyn Fn() -> BoxFuture<'_, Result> + Send + Sync), + ) -> Result { + let result = generate().await?; + assert!(result.request.as_ref().unwrap().body.is_some()); + assert_eq!(result.response.as_ref().unwrap().body.is_some(), self.0); + Ok(result) + } + } + + let mut response: Value = serde_json::from_str(OPENAI_TEXT_JSON).unwrap(); + response["usage"]["extension"] = json!({"counter": 19, "missing": null}); + for response_body in [None, Some(true), Some(false)] { + let retained = response_body.unwrap_or(false); + let mock = MockFetch::new(vec![json_value(&response)]); + let model = wrap_language_model( + Arc::new(provider(&mock).chat("gpt-4o")), + &[Arc::new(ObserveBodies(retained))], + None, + None, + ); + let result = generate_text( + model.as_ref(), + "Hello", + GenerateTextOptions { + include: response_body.map(|response_body| IncludeOptions { + response_body: Some(response_body), + request_body: Some(true), + }), + max_retries: Some(0), + ..GenerateTextOptions::default() + }, + ) + .await + .unwrap(); + let step = result.final_step(); + assert_eq!(step.response.body.as_ref(), retained.then_some(&response)); + assert_eq!(step.usage.raw.as_ref(), response["usage"].as_object()); + assert_eq!(step.request.body.is_some(), response_body.is_some()); + } +} diff --git a/aimux-providers/src/openai_compatible/chat/chat_language_model.rs b/aimux-providers/src/openai_compatible/chat/chat_language_model.rs index b5ee691d6..81289d7b7 100644 --- a/aimux-providers/src/openai_compatible/chat/chat_language_model.rs +++ b/aimux-providers/src/openai_compatible/chat/chat_language_model.rs @@ -660,6 +660,7 @@ impl LanguageModel for OpenAICompatibleChatModel { request: Some(RequestInfo { body: Some(body) }), response: Some(StreamResponseInfo { headers: Some(response_headers), + body: None, }), }, options, diff --git a/aimux-providers/src/openai_compatible/completion/completion_language_model.rs b/aimux-providers/src/openai_compatible/completion/completion_language_model.rs index 09ddb008b..b559bc59a 100644 --- a/aimux-providers/src/openai_compatible/completion/completion_language_model.rs +++ b/aimux-providers/src/openai_compatible/completion/completion_language_model.rs @@ -297,6 +297,7 @@ impl LanguageModel for OpenAICompatibleCompletionModel { request: Some(RequestInfo { body: Some(body) }), response: Some(StreamResponseInfo { headers: Some(response_headers), + body: None, }), }, options, diff --git a/aimux-providers/src/xai/responses/responses_language_model.rs b/aimux-providers/src/xai/responses/responses_language_model.rs index 1baba32fc..89cbe3979 100644 --- a/aimux-providers/src/xai/responses/responses_language_model.rs +++ b/aimux-providers/src/xai/responses/responses_language_model.rs @@ -600,6 +600,7 @@ impl LanguageModel for XaiResponsesModel { request: Some(aimux_core::shared::RequestInfo { body: Some(body) }), response: Some(aimux_core::shared::StreamResponseInfo { headers: Some(response_headers), + body: None, }), }, options, diff --git a/aimux-providers/tests/data_loss_regression_test.rs b/aimux-providers/tests/data_loss_regression_test.rs index 0743a885f..ad4be7c72 100644 --- a/aimux-providers/tests/data_loss_regression_test.rs +++ b/aimux-providers/tests/data_loss_regression_test.rs @@ -427,8 +427,9 @@ async fn generated_file_is_base64_and_media_type_in_text_results() { .await .expect("generate_text should succeed"); - let wire = serde_json::to_value(&result).unwrap(); - let file = &wire["files"][0]; + let files = result.files(); + assert_eq!(files.len(), 1); + let file = serde_json::to_value(files[0]).unwrap(); assert_eq!(file["mediaType"], "image/png"); assert!( file["base64"] @@ -437,9 +438,11 @@ async fn generated_file_is_base64_and_media_type_in_text_results() { .starts_with(PNG_BASE64_PREFIX) ); assert!(file.get("data").is_none(), "no tagged data: {file}"); - let part = &wire["content"][1]; + let wire = serde_json::to_value(&result).unwrap(); + assert!(wire.get("files").is_none()); + let part = &wire["steps"][0]["content"][1]; assert_eq!(part["type"], "file"); - assert_eq!(part["file"], *file); + assert_eq!(part["file"], file); } #[tokio::test] diff --git a/aimux-providers/tests/e2e_test.rs b/aimux-providers/tests/e2e_test.rs index c8166919a..af8eac5c9 100644 --- a/aimux-providers/tests/e2e_test.rs +++ b/aimux-providers/tests/e2e_test.rs @@ -8,7 +8,7 @@ use aimux_core::content::{AssistantContentPart, ToolContentPart, ToolResultOutput}; use aimux_core::error::AiMuxError; -use aimux_core::generate::{GenerateTextOptions, generate_text, stream_text}; +use aimux_core::generate::{GenerateTextOptions, IncludeOptions, generate_text, stream_text}; use aimux_core::message::ModelMessage; use aimux_core::stream_part::TextStreamPart; use aimux_core::tool::{FunctionTool, Tool, ToolCall, ToolChoice}; @@ -1028,9 +1028,19 @@ async fn e2e_google_stream_text() { .unwrap(); let model = provider.chat("gemini-2.0-flash"); - let result = stream_text(&model, "Say hello", GenerateTextOptions::default()) - .await - .expect("stream_text should succeed"); + let result = stream_text( + &model, + "Say hello", + GenerateTextOptions { + include: Some(IncludeOptions { + request_body: Some(true), + ..Default::default() + }), + ..GenerateTextOptions::default() + }, + ) + .await + .expect("stream_text should succeed"); let request_body = result.request_body.clone(); let text = result.text().await.expect("should collect text"); @@ -1122,9 +1132,19 @@ async fn e2e_mistral_stream_text() { .expect("valid settings"); let model = provider.chat("mistral-small-latest"); - let result = stream_text(&model, "Say hello", GenerateTextOptions::default()) - .await - .expect("stream_text should succeed"); + let result = stream_text( + &model, + "Say hello", + GenerateTextOptions { + include: Some(IncludeOptions { + request_body: Some(true), + ..Default::default() + }), + ..GenerateTextOptions::default() + }, + ) + .await + .expect("stream_text should succeed"); let request_body = result.request_body.clone(); let text = result.text().await.expect("should collect text"); @@ -1226,9 +1246,19 @@ async fn e2e_cohere_stream_text() { .expect("valid settings"); let model = provider.chat("command-r-plus"); - let result = stream_text(&model, "Say hello", GenerateTextOptions::default()) - .await - .expect("stream_text should succeed"); + let result = stream_text( + &model, + "Say hello", + GenerateTextOptions { + include: Some(IncludeOptions { + request_body: Some(true), + ..Default::default() + }), + ..GenerateTextOptions::default() + }, + ) + .await + .expect("stream_text should succeed"); let request_body = result.request_body.clone(); let text = result.text().await.expect("should collect text"); diff --git a/bindings/flutter/lib/generated/ops.dart b/bindings/flutter/lib/generated/ops.dart index 2fde0c5dd..8c4519f25 100644 --- a/bindings/flutter/lib/generated/ops.dart +++ b/bindings/flutter/lib/generated/ops.dart @@ -1,7 +1,7 @@ -// Generated by aimux-codegen. Do not edit. Manifest SHA-256: cd147fa9595ede3951744fa261da98cc18c204e65b4081073ad3a3c1b68bfd92 +// Generated by aimux-codegen. Do not edit. Manifest SHA-256: 6914772fdc03df08cba497def41cb354fe52e40eba49844a66938b4cd38c5d83 const int ABI_VERSION = 65536; const String OPS_VERSION = "1.0"; -const String MANIFEST_DIGEST = "cd147fa9595ede3951744fa261da98cc18c204e65b4081073ad3a3c1b68bfd92"; +const String MANIFEST_DIGEST = "6914772fdc03df08cba497def41cb354fe52e40eba49844a66938b4cd38c5d83"; const String OP_ABORT_CREATE = "abort.create"; const String OP_ABORT_SIGNAL = "abort.signal"; const String OP_AUTH_CODEX_REFRESH = "auth.codexRefresh"; @@ -92,7 +92,7 @@ const Map TYPE_SCHEMA_HASHES = { "aimux_core::embedding_model::EmbeddingResult": "af3ce0787db6208be114613c78dc02f038cb5dc2f7abcf6a4ade2be79085342e", "aimux_core::files_model::UploadFileResult": "0d17fd3dbfa601e45c9fabf62f9bb1e5028591443eafccd4eecacef0dcda0368", "aimux_core::generate::GenerateObjectResult": "21cca82de06d366b0f47d781bd49141bb63215accdd1133bb360113a60b7cc00", - "aimux_core::generate::GenerateTextResult": "c5c6016de2c926c85144959d9436c9d2214a27a9724e75d68393e933ef7263f5", + "aimux_core::generate::GenerateTextResult": "c75d0e0c2d207f9dfeffe7eb42efb9040d93a8062cdc678054f9bbcb8049e041", "aimux_core::image_model::ImageCallOptions": "ddacb8970cef4590bcdcc572ced361b181d501d3b474a2d6c50a9c0c02af3eb2", "aimux_core::image_model::ImageResult": "a9d2d939f3dc153a5b5ebc8083bea1226ff63ff2e54e4e275c9ab2b136b9e880", "aimux_core::openai_output::ChatCompletion": "503195cbe7fe458d9403a9de20b93bd17c20bbee0de40a8088bf3847ee835ad9", @@ -100,6 +100,9 @@ const Map TYPE_SCHEMA_HASHES = { "aimux_core::recording::Recording": "56fa358fb2023da68837722ed573e00fc997506403d7c7aa516c586c45b4fd54", "aimux_core::reranking_model::RerankingCallOptions": "c481b6e7c4d5e71ea7db00166ab2952c8a893443f786a61374c7398b4e475e4c", "aimux_core::reranking_model::RerankingResult": "d757826963b3ce836e4d76fca8f42455a3a3146c20f3fb74f58cabe465348d01", + "aimux_core::result::ReasoningPart": "6210a367b8c084e55a60e0ead74a7ff233b7f357020a028c6879b54ffa8b9b87", + "aimux_core::result::TaggedToolResult": "a8f688a021397c1159b88546156d5a418e50d6482d39f88c46476297d208e069", + "aimux_core::result::TypedSource": "0a36b617c3f1bbcd82e4d09c329ad41aba62330b4d0e950125fd62b2053a9368", "aimux_core::search_model::SearchCallOptions": "3b963a871e6f1858db03b68adc74c5f898d4a2c3c0506e4e359b8d8198d30b22", "aimux_core::search_model::SearchResult": "61075439fcb4276085a11113195dd13220b710cc0c2199ceefa4ec3d07d0195f", "aimux_core::speech_model::SpeechCallOptions": "418be167c89bca652fb0a9dd52a1da359c1ecc2b069b9d2a0859ab76a7f7f431", @@ -127,10 +130,10 @@ const Map TYPE_SCHEMA_HASHES = { "aimux_ops::ops::handles::TransportParams": "86e40584fcc21dab8f0017f8e892b776ac24aaa9afc943ba805828cecc6e1a4c", "aimux_ops::ops::misc::CatalogueFetchRequest": "2ceed496996ec6cf32d3e3115ab6a4346a1bb201dc8a970eefbd46eb700a310e", "aimux_ops::ops::misc::CodexRefreshRequest": "59f1075ed68cb79896d4bac1d0ab32d21fb5855012c6336652bea0c4969ac926", - "aimux_ops::ops::misc::OpenAiOutputRequest": "b0c6acc344f0b23b9ea3b693aeadf7aed7eb4fbdfce4b957be83af1154b842b4", - "aimux_ops::ops::misc::ToolRepairApplyRequest": "0f430fdb223759ef7c48c4d7f824e7be74d29295a6b4f7caaf82b5acba25e538", - "aimux_ops::ops::misc::ToolRepairApplyResultRequest": "fa092862004654e065233b2df2abdbec3befe88d9d734d494679968a5b6e954a", - "aimux_ops::ops::misc::ToolRepairContextRequest": "81bae04c56aac3380b75de639d162f819a2dd5717147a53cf1a75281727d78a1", + "aimux_ops::ops::misc::OpenAiOutputRequest": "d30e30aa75703e1404a202d437e69a6873fd2b515c5ed322ab488363be8d2fb0", + "aimux_ops::ops::misc::ToolRepairApplyRequest": "c1c5f81107f334a94583a4ff4ed394097580bea2f2a66266c11890fe2a3ab3d0", + "aimux_ops::ops::misc::ToolRepairApplyResultRequest": "649f2b4ff1a2dd0d552e2930b694d7efa3346b2f15a9fb0f14cffd4b6955b508", + "aimux_ops::ops::misc::ToolRepairContextRequest": "fa4802ac20a2b1b540cb727d798ad2a4c44cad6a8f9ad45281fc91ebb065e65f", "aimux_ops::ops::misc::ToolRepairContextResult": "fd8173e6ec40724fa4207e3571e290ac12e4db1fed08a709273e2982a82b504f", "aimux_ops::ops::operation::EmptyParams": "1612408252a424283a43a92193bb8ea24f72c08b9f0d2117b4ef7f5a090e37f8", "aimux_ops::ops::operation::OperationNextParams": "127fea618826e51576ae488dcccaca03c04b774a847a33ec9c47565396862bb7", @@ -164,7 +167,7 @@ const Map TYPE_SCHEMA_HASHES = { "aimux_ops::ops::replay::ReplayCreateParams": "ee64b5b5843103f76ca2166aed2f58995e472be93cb7bb18dea8238c8a2d9e44", "aimux_ops::ops::replay::ReplayInspection": "7ac2af62f3421f8c7c50867a838f0aff90f35b6a4f192f6c0d5347ab4699108c", "aimux_ops::ops::replay::ReplayLiveParams": "e99c7d51fb194def185f5a03d84bfc226eb1b101eade0b885216332605318a4d", - "aimux_ops::ops::replay::ReplayLiveResult": "bd9959dd7e0300cb57e6929b2ed29b7e07dcb5aaf65be16b96e34bf8d6577a7f", + "aimux_ops::ops::replay::ReplayLiveResult": "9163acd59ee54db1db2213c0756283b8b27e04a52451dfeef314d63efebbc730", "aimux_ops::ops::replay::ReplayPlan": "5cc6667b9fac6de173bf5b55c1a76a491255f89f0fa7a27c0fd33fd790259799", "aimux_ops::ops::replay::ReplaySessionHandle": "5e779b71ce2a54e59948c605cdfc48797d0760027ad5f44966df958fe9781d11", "aimux_ops::ops::runtime::RuntimeConfigureParams": "e3b24b9f1fbdf2be7da210f15060803cf8bfdef77c8b2ad330a5b501263dfb0f", @@ -172,8 +175,8 @@ const Map TYPE_SCHEMA_HASHES = { "aimux_ops::ops::session::SessionStoreCallsParams": "ddd482204fdd305bbfd28d43ae829d8c286f3f8906302ca6679743ea680fedda", "aimux_ops::ops::session::SessionStoreCreateParams": "080d865c349ec86553f72b99ab1c65ddbb72d0c348a96dc17135a934d787cd86", "aimux_ops::ops::session::SessionStoreHandle": "755d437d47d362474942fc4a09f5f8c80b75cf362ac16b25b262e33a760b4c6a", - "aimux_ops::ops::text::OpenAiTextRequest": "59293b18b6124a9a394113b8f94f637c65dc35ac44a30f7e0df70855e885f8e4", - "aimux_ops::ops::text::TextRequest": "3a6f59c1f0c3b7ded5f5509d93afe9bddd2b80a8a3cd752d79f97edadae40c3d", + "aimux_ops::ops::text::OpenAiTextRequest": "d5afbf2b24ab74b82433d344afb190c18f8aef52988c54ab8b5388579c212f67", + "aimux_ops::ops::text::TextRequest": "eb0c25fcbf741834943882d7f901af7439ba30923a391b273526d1887ed156ab", "aimux_ops::ops::trace::TraceAggregateParams": "1b207f0bbe1b7ce7e9b8b0beb9334cf3cc4f9f05382911aaacfe0425dc8ff2c8", "aimux_ops::ops::trace::TraceCreateParams": "59fef52f382800570e861ae9ca92433dcae8807679d914a89ce99705713301d9", "aimux_ops::ops::trace::TraceSessionParams": "3e2300f6c65f6dcd52a016eba648a29abeff3a9d67c3b04a95617aa66832f810", diff --git a/bindings/flutter/lib/src/generated/dto_vectors.dart b/bindings/flutter/lib/src/generated/dto_vectors.dart index 90c631fdc..4a473ef5a 100644 --- a/bindings/flutter/lib/src/generated/dto_vectors.dart +++ b/bindings/flutter/lib/src/generated/dto_vectors.dart @@ -204,6 +204,8 @@ Object? roundTripDto(String type, Object? value) { return ImageResult.fromJson(value as Map).toJson(); case 'ImageUsage': return ImageUsage.fromJson(value as Map).toJson(); + case 'IncludeOptions': + return IncludeOptions.fromJson(value as Map).toJson(); case 'InputAudioFormat': return InputAudioFormat.fromJson(value as Map).toJson(); case 'InputRecord': diff --git a/bindings/flutter/lib/src/generated/types.dart b/bindings/flutter/lib/src/generated/types.dart index ec8c0aec4..913b38e1e 100644 --- a/bindings/flutter/lib/src/generated/types.dart +++ b/bindings/flutter/lib/src/generated/types.dart @@ -5843,6 +5843,9 @@ final class GenerateTextOptions { final double? frequencyPenalty; final Map? headers; + /// Controls the raw bodies exposed in the result. Both default to `false`. + final IncludeOptions? include; + /// Emit raw provider stream chunks as `StreamPart::Raw` (debugging aid). final bool? includeRawChunks; @@ -5891,6 +5894,7 @@ final class GenerateTextOptions { const GenerateTextOptions({ this.frequencyPenalty, this.headers, + this.include, this.includeRawChunks, this.instructions, this.maxOutputTokens, @@ -5911,7 +5915,7 @@ final class GenerateTextOptions { this.topP, }); factory GenerateTextOptions.fromJson(Map json) { - const allowedKeys = {'frequencyPenalty', 'headers', 'includeRawChunks', 'instructions', 'maxOutputTokens', 'maxRetries', 'output', 'presencePenalty', 'providerOptions', 'reasoning', 'seed', 'sessionId', 'stopSequences', 'strictStream', 'temperature', 'timeout', 'toolChoice', 'tools', 'topK', 'topP'}; + const allowedKeys = {'frequencyPenalty', 'headers', 'include', 'includeRawChunks', 'instructions', 'maxOutputTokens', 'maxRetries', 'output', 'presencePenalty', 'providerOptions', 'reasoning', 'seed', 'sessionId', 'stopSequences', 'strictStream', 'temperature', 'timeout', 'toolChoice', 'tools', 'topK', 'topP'}; for (final key in json.keys) { if (!allowedKeys.contains(key)) { throw FormatException('Unknown field $key for GenerateTextOptions'); @@ -5924,6 +5928,9 @@ final class GenerateTextOptions { headers: json['headers'] == null ? null : Map.from(json['headers'] as Map), + include: json['include'] == null + ? null + : IncludeOptions.fromJson(json['include'] as Map), includeRawChunks: json['includeRawChunks'] as bool?, instructions: json['instructions'] as String?, maxOutputTokens: json['maxOutputTokens'] as int?, @@ -5970,6 +5977,7 @@ final class GenerateTextOptions { Map toJson() => { if (frequencyPenalty != null) 'frequencyPenalty': frequencyPenalty, if (headers != null) 'headers': headers, + if (include != null) 'include': include!.toJson(), if (includeRawChunks != null) 'includeRawChunks': includeRawChunks, if (instructions != null) 'instructions': instructions, if (maxOutputTokens != null) 'maxOutputTokens': maxOutputTokens, @@ -5997,142 +6005,95 @@ final class GenerateTextOptions { /// /// It stores the steps, the usage summed over them and the parsed output, as /// `DefaultGenerateTextResult` does (`generate-text.ts:1691-1808`); every -/// other value is derived from the steps by an accessor. The serialized form -/// is a snapshot that writes the derived values next to the stored ones, so -/// a binding reads `text`, `tool_calls`, `usage` and the rest directly. Only -/// `steps`, `total_usage` and `output` are read back. +/// other value is derived from the steps by an accessor. The wire form carries +/// `steps`, `totalUsage`, optional `output` (when explicitly parsed), and +/// optional `outputParsed: false` (when no output was generated). final class GenerateTextResult { - final List content; - final List files; - final FinishReasonUnified finishReason; - - /// Absent when the output was not parsed. - final Field output; - - /// Deprecated upstream: the last step's provider metadata. - final Map>? providerMetadata; - final String? rawFinishReason; - - /// Deprecated upstream: the last step's reasoning. - final List reasoning; - - /// Deprecated upstream: the last step's reasoning text. - final String? reasoningText; - - /// Deprecated upstream: the last step's request. - final RequestInfo request; - - /// Deprecated upstream: the last step's response. - final StepResponse response; - final List responseMessages; - - /// Each with its `type` tag (`generate-text-result.ts:73`). - final List sources; + /// An explicit parsed output, including JSON `null`. When absent and + /// `outputParsed` is not `false`, bindings expose the final step's text. + final Field outputValue; + + /// Present and `false` when no output was generated (for example, a final + /// `tool-calls` step without an output spec). Omitted when an output was + /// produced. + final bool? outputParsed; final List steps; - final String text; - - /// Each with its `type` tag (`generate-text-result.ts:78`). - final List toolCalls; - - /// Each with its `type` tag (`generate-text-result.ts:93`). - final List toolResults; - - /// Deprecated upstream: equal to `usage`. final LanguageModelUsage totalUsage; - final LanguageModelUsage usage; - final List warnings; const GenerateTextResult({ - required this.content, - required this.files, - required this.finishReason, - this.output = const Field.absent(), - this.providerMetadata, - this.rawFinishReason, - required this.reasoning, - this.reasoningText, - required this.request, - required this.response, - required this.responseMessages, - required this.sources, + this.outputValue = const Field.absent(), + this.outputParsed, required this.steps, - required this.text, - required this.toolCalls, - required this.toolResults, required this.totalUsage, - required this.usage, - required this.warnings, }); factory GenerateTextResult.fromJson(Map json) { + if ((json['steps'] as List).isEmpty) { + throw const FormatException('GenerateTextResult requires at least one step'); + } + if (json.containsKey('output') && json['outputParsed'] == false) { + throw const FormatException('GenerateTextResult cannot carry output when outputParsed is false'); + } return GenerateTextResult( - content: (json['content'] as List) - .map((item) => ContentPart.fromJson(item as Map)) - .toList(), - files: (json['files'] as List) - .map((item) => GeneratedFile.fromJson(item as Map)) - .toList(), - finishReason: FinishReasonUnified.fromJson(json['finishReason']), - output: json.containsKey('output') + outputValue: json.containsKey('output') ? Field.of(json['output']) : const Field.absent(), - providerMetadata: json['providerMetadata'] == null - ? null - : (json['providerMetadata'] as Map).map((key, item) => - MapEntry(key as String, Map.from(item as Map))), - rawFinishReason: json['rawFinishReason'] as String?, - reasoning: (json['reasoning'] as List) - .map((item) => ReasoningPart.fromJson(item as Map)) - .toList(), - reasoningText: json['reasoningText'] as String?, - request: RequestInfo.fromJson(json['request'] as Map), - response: StepResponse.fromJson(json['response'] as Map), - responseMessages: (json['responseMessages'] as List) - .map((item) => ModelMessage.fromJson(item as Map)) - .toList(), - sources: (json['sources'] as List) - .map((item) => TypedSource.fromJson(item as Map)) - .toList(), + outputParsed: json['outputParsed'] as bool?, steps: (json['steps'] as List) .map((item) => StepResult.fromJson(item as Map)) .toList(), - text: json['text'] as String, - toolCalls: (json['toolCalls'] as List) - .map((item) => TypedToolCall.fromJson(item as Map)) - .toList(), - toolResults: (json['toolResults'] as List) - .map( - (item) => TaggedToolResult.fromJson(item as Map)) - .toList(), totalUsage: LanguageModelUsage.fromJson( json['totalUsage'] as Map), - usage: LanguageModelUsage.fromJson(json['usage'] as Map), - warnings: (json['warnings'] as List) - .map((item) => Warning.fromJson(item as Map)) - .toList(), ); } Map toJson() => { - 'content': content.map((item) => item.toJson()).toList(), - 'files': files.map((item) => item.toJson()).toList(), - 'finishReason': finishReason.toJson(), - if (output.isPresent) 'output': output.value, - if (providerMetadata != null) 'providerMetadata': providerMetadata, - if (rawFinishReason != null) 'rawFinishReason': rawFinishReason, - 'reasoning': reasoning.map((item) => item.toJson()).toList(), - if (reasoningText != null) 'reasoningText': reasoningText, - 'request': request.toJson(), - 'response': response.toJson(), - 'responseMessages': - responseMessages.map((item) => item.toJson()).toList(), - 'sources': sources.map((item) => item.toJson()).toList(), + if (outputValue.isPresent) 'output': outputValue.value, + if (outputParsed != null) 'outputParsed': outputParsed, 'steps': steps.map((item) => item.toJson()).toList(), - 'text': text, - 'toolCalls': toolCalls.map((item) => item.toJson()).toList(), - 'toolResults': toolResults.map((item) => item.toJson()).toList(), 'totalUsage': totalUsage.toJson(), - 'usage': usage.toJson(), - 'warnings': warnings.map((item) => item.toJson()).toList(), }; + + StepResult get finalStep => steps.last; + String get text => + finalStep.content.whereType().map((p) => p.text).join(); + List get content => steps.expand((step) => step.content).toList(); + List get reasoning => finalStep.content + .where((p) => p is ContentPartReasoning || p is ContentPartReasoningFile) + .toList(); + String? get reasoningText { + final text = reasoning.whereType().map((p) => p.text).join(); + return text.isEmpty ? null : text; + } + + List get files => + content.whereType().map((p) => p.file).toList(); + List get sources => content + .where((p) => p is ContentPartSourceUrl || p is ContentPartSourceDocument) + .toList(); + List get toolCalls => + content.whereType().toList(); + List get staticToolCalls => + toolCalls.where((p) => p.dynamic_ != true).toList(); + List get dynamicToolCalls => + toolCalls.where((p) => p.dynamic_ == true).toList(); + List get toolResults => + content.whereType().toList(); + List get staticToolResults => + toolResults.where((p) => p.dynamic_ != true).toList(); + List get dynamicToolResults => + toolResults.where((p) => p.dynamic_ == true).toList(); + FinishReasonUnified get finishReason => finalStep.finishReason; + String? get rawFinishReason => finalStep.rawFinishReason; + LanguageModelUsage get usage => totalUsage; + List get warnings => steps.expand((step) => step.warnings).toList(); + RequestInfo get request => finalStep.request; + StepResponse get response => finalStep.response; + Map>? get providerMetadata => + finalStep.providerMetadata; + List get responseMessages => + steps.expand((step) => step.response.messages).toList(); + Field get output => outputValue.isPresent + ? outputValue + : (outputParsed == false ? const Field.absent() : Field.of(text)); } /// Result of `generate_text` and of a consumed `stream_text`: the AI SDK's @@ -6140,16 +6101,23 @@ final class GenerateTextResult { /// /// It stores the steps, the usage summed over them and the parsed output, as /// `DefaultGenerateTextResult` does (`generate-text.ts:1691-1808`); every -/// other value is derived from the steps by an accessor. The serialized form -/// is a snapshot that writes the derived values next to the stored ones, so -/// a binding reads `text`, `tool_calls`, `usage` and the rest directly. Only -/// `steps`, `total_usage` and `output` are read back. +/// other value is derived from the steps by an accessor. The wire form carries +/// `steps`, `totalUsage`, optional `output` (when explicitly parsed), and +/// optional `outputParsed: false` (when no output was generated). final class GenerateTextResultInput { + /// An explicit parsed output, including JSON `null`. When absent and + /// `outputParsed` is not `false`, bindings expose the final step's text. final Field output; + + /// Present and `false` when no output was generated (for example, a final + /// `tool-calls` step without an output spec). Omitted when an output was + /// produced. + final bool? outputParsed; final List steps; final LanguageModelUsageInput totalUsage; const GenerateTextResultInput({ this.output = const Field.absent(), + this.outputParsed, required this.steps, required this.totalUsage, }); @@ -6158,6 +6126,7 @@ final class GenerateTextResultInput { output: json.containsKey('output') ? Field.of(json['output']) : const Field.absent(), + outputParsed: json['outputParsed'] as bool?, steps: (json['steps'] as List) .map((item) => StepResultInput.fromJson(item as Map)) .toList(), @@ -6168,6 +6137,7 @@ final class GenerateTextResultInput { Map toJson() => { if (output.isPresent) 'output': output.value, + if (outputParsed != null) 'outputParsed': outputParsed, 'steps': steps.map((item) => item.toJson()).toList(), 'totalUsage': totalUsage.toJson(), }; @@ -6776,6 +6746,36 @@ final class ImageUsage { }; } +/// Controls which raw body fields are exposed in generation results. +final class IncludeOptions { + /// Whether to return the request body. Defaults to false. + final bool? requestBody; + + /// Whether to return the response body. Defaults to false. + final bool? responseBody; + const IncludeOptions({ + this.requestBody, + this.responseBody, + }); + factory IncludeOptions.fromJson(Map json) { + const allowedKeys = {'requestBody', 'responseBody'}; + for (final key in json.keys) { + if (!allowedKeys.contains(key)) { + throw FormatException('Unknown field $key for IncludeOptions'); + } + } + return IncludeOptions( + requestBody: json['requestBody'] as bool?, + responseBody: json['responseBody'] as bool?, + ); + } + + Map toJson() => { + if (requestBody != null) 'requestBody': requestBody, + if (responseBody != null) 'responseBody': responseBody, + }; +} + /// The input audio format for a streaming transcription request. final class InputAudioFormat { /// Audio format type, e.g. `"audio/pcm"`, `"audio/pcmu"`, `"audio/pcma"`. @@ -8617,6 +8617,9 @@ final class Options { final double? frequencyPenalty; final Map? headers; + /// Controls the raw bodies exposed in the result. Both default to `false`. + final IncludeOptions? include; + /// Emit raw provider stream chunks as `StreamPart::Raw` (debugging aid). final bool? includeRawChunks; @@ -8665,6 +8668,7 @@ final class Options { const Options({ this.frequencyPenalty, this.headers, + this.include, this.includeRawChunks, this.instructions, this.maxOutputTokens, @@ -8685,7 +8689,7 @@ final class Options { this.topP, }); factory Options.fromJson(Map json) { - const allowedKeys = {'frequencyPenalty', 'headers', 'includeRawChunks', 'instructions', 'maxOutputTokens', 'maxRetries', 'output', 'presencePenalty', 'providerOptions', 'reasoning', 'seed', 'sessionId', 'stopSequences', 'strictStream', 'temperature', 'timeout', 'toolChoice', 'tools', 'topK', 'topP'}; + const allowedKeys = {'frequencyPenalty', 'headers', 'include', 'includeRawChunks', 'instructions', 'maxOutputTokens', 'maxRetries', 'output', 'presencePenalty', 'providerOptions', 'reasoning', 'seed', 'sessionId', 'stopSequences', 'strictStream', 'temperature', 'timeout', 'toolChoice', 'tools', 'topK', 'topP'}; for (final key in json.keys) { if (!allowedKeys.contains(key)) { throw FormatException('Unknown field $key for Options'); @@ -8698,6 +8702,9 @@ final class Options { headers: json['headers'] == null ? null : Map.from(json['headers'] as Map), + include: json['include'] == null + ? null + : IncludeOptions.fromJson(json['include'] as Map), includeRawChunks: json['includeRawChunks'] as bool?, instructions: json['instructions'] as String?, maxOutputTokens: json['maxOutputTokens'] as int?, @@ -8744,6 +8751,7 @@ final class Options { Map toJson() => { if (frequencyPenalty != null) 'frequencyPenalty': frequencyPenalty, if (headers != null) 'headers': headers, + if (include != null) 'include': include!.toJson(), if (includeRawChunks != null) 'includeRawChunks': includeRawChunks, if (instructions != null) 'instructions': instructions, if (maxOutputTokens != null) 'maxOutputTokens': maxOutputTokens, diff --git a/bindings/flutter/native/aimux_ops.h b/bindings/flutter/native/aimux_ops.h index 4d5c1c15f..dc45a125a 100644 --- a/bindings/flutter/native/aimux_ops.h +++ b/bindings/flutter/native/aimux_ops.h @@ -1,4 +1,4 @@ -/* Generated by aimux-codegen. Do not edit. Manifest SHA-256: cd147fa9595ede3951744fa261da98cc18c204e65b4081073ad3a3c1b68bfd92 */ +/* Generated by aimux-codegen. Do not edit. Manifest SHA-256: 6914772fdc03df08cba497def41cb354fe52e40eba49844a66938b4cd38c5d83 */ #ifndef AIMUX_H #define AIMUX_H @@ -11,7 +11,7 @@ extern "C" { #define AIMUX_ABI_VERSION UINT32_C(65536) #define AIMUX_OPS_VERSION "1.0" -#define AIMUX_MANIFEST_DIGEST "cd147fa9595ede3951744fa261da98cc18c204e65b4081073ad3a3c1b68bfd92" +#define AIMUX_MANIFEST_DIGEST "6914772fdc03df08cba497def41cb354fe52e40eba49844a66938b4cd38c5d83" #define AIMUX_OP_ABORT_CREATE "abort.create" #define AIMUX_OP_ABORT_SIGNAL "abort.signal" diff --git a/bindings/flutter/test/typed_round_trip_test.dart b/bindings/flutter/test/typed_round_trip_test.dart index 972fcdf3f..7f4d6c498 100644 --- a/bindings/flutter/test/typed_round_trip_test.dart +++ b/bindings/flutter/test/typed_round_trip_test.dart @@ -365,43 +365,63 @@ void main() { test('GenerateTextResult round-trips', () { final json = jsonDecode(jsonEncode({ - 'content': [ - {'type': 'text', 'text': 'hi'} - ], - 'text': 'hi', - 'reasoning': [], - 'files': [], - 'sources': [], - 'toolCalls': [ - {'type': 'tool-call', 'toolCallId': 'c', 'toolName': 't', 'input': {}} - ], - 'toolResults': [], - 'finishReason': 'tool-calls', - 'rawFinishReason': 'tool_calls', - 'usage': _lmUsage, 'totalUsage': _lmUsage, - 'warnings': [], - 'request': {}, - 'response': { - 'id': 'r', - 'modelId': 'gpt-4o', - 'timestamp': '2026-01-01T00:00:00.000Z', - 'messages': [] - }, - 'responseMessages': [ - {'role': 'assistant', 'content': 'hi'} - ], - 'steps': [], + 'steps': [{ + 'callId': 'c', + 'stepNumber': 0, + 'model': {'modelId': 'gpt-4o', 'provider': 'openai'}, + 'content': [ + {'type': 'text', 'text': 'hi'}, + {'type': 'tool-call', 'toolCallId': 'c', 'toolName': 't', 'input': {}} + ], + 'finishReason': 'tool-calls', + 'rawFinishReason': 'tool_calls', + 'usage': _lmUsage, + 'performance': { + 'effectiveOutputTokensPerSecond': 0.0, + 'effectiveTotalTokensPerSecond': 0.0, + 'responseTimeMs': 0.0, + 'stepTimeMs': 0.0, + 'toolExecutionMs': {}, + }, + 'warnings': [], + 'request': {}, + 'response': { + 'id': 'r', + 'modelId': 'gpt-4o', + 'timestamp': '2026-01-01T00:00:00.000Z', + 'messages': [ + {'role': 'assistant', 'content': 'hi'} + ], + }, + }], })) as Map; + expect( + () => GenerateTextResult.fromJson({...json, 'steps': []}), + throwsFormatException, + ); final result = GenerateTextResult.fromJson(json); expect(result.finishReason, FinishReasonUnified.toolCalls); expect(result.usage.totalTokens, 5); expect(result.totalUsage.inputTokenDetails.cacheReadTokens, 1); expect(result.reasoningText, isNull); - expect(result.output.isPresent, isFalse); - expect(result.steps, isEmpty); + expect(result.output.value, 'hi'); + expect(result.outputValue.isPresent, isFalse); + expect(result.staticToolCalls.single.toolName, 't'); + expect(result.steps, hasLength(1)); expect(jsonDecode(jsonEncode(result)), json); + // An unparsed result (`outputParsed: false`) keeps `output` absent. + final notParsed = Map.of(json)..['outputParsed'] = false; + final unparsedResult = GenerateTextResult.fromJson(notParsed); + expect(unparsedResult.output.isPresent, isFalse); + expect(unparsedResult.outputParsed, isFalse); + expect(jsonDecode(jsonEncode(unparsedResult)), notParsed); + expect( + () => GenerateTextResult.fromJson({...notParsed, 'output': null}), + throwsFormatException, + ); + // A parsed JSON null output is written back as null, apart from no // output (the public JSON keeps null apart from undefined). final parsedNull = Map.of(json)..['output'] = null; diff --git a/bindings/go/README.md b/bindings/go/README.md index bc418fabe..9ec2265ec 100644 --- a/bindings/go/README.md +++ b/bindings/go/README.md @@ -26,7 +26,7 @@ result, err := aimux.CallInto[aimux.GenerateTextResult](ctx, model, "text.genera "prompt": "Hello", "options": aimux.GenerateTextOptions{}, }) if err != nil { return err } -fmt.Println(result.Text) +fmt.Println(result.Text()) ``` `Call` invokes a global operation; `Handle.Call` invokes one on an owned diff --git a/bindings/go/examples/generate/main.go b/bindings/go/examples/generate/main.go index 5c977a0bf..32fc3d26b 100644 --- a/bindings/go/examples/generate/main.go +++ b/bindings/go/examples/generate/main.go @@ -32,5 +32,5 @@ func main() { if err != nil { log.Fatal(err) } - fmt.Println(result.Text) + fmt.Println(result.Text()) } diff --git a/bindings/go/generated/ops.go b/bindings/go/generated/ops.go index c4717b2e9..b9029d368 100644 --- a/bindings/go/generated/ops.go +++ b/bindings/go/generated/ops.go @@ -1,10 +1,10 @@ -// Generated by aimux-codegen. Do not edit. Manifest SHA-256: cd147fa9595ede3951744fa261da98cc18c204e65b4081073ad3a3c1b68bfd92 +// Generated by aimux-codegen. Do not edit. Manifest SHA-256: 6914772fdc03df08cba497def41cb354fe52e40eba49844a66938b4cd38c5d83 package generated const ( ABI_VERSION = 65536 OPS_VERSION = "1.0" - MANIFEST_DIGEST = "cd147fa9595ede3951744fa261da98cc18c204e65b4081073ad3a3c1b68bfd92" + MANIFEST_DIGEST = "6914772fdc03df08cba497def41cb354fe52e40eba49844a66938b4cd38c5d83" OP_ABORT_CREATE = "abort.create" OP_ABORT_SIGNAL = "abort.signal" OP_AUTH_CODEX_REFRESH = "auth.codexRefresh" @@ -97,7 +97,7 @@ var TYPE_SCHEMA_HASHES = map[string]string{ "aimux_core::embedding_model::EmbeddingResult": "af3ce0787db6208be114613c78dc02f038cb5dc2f7abcf6a4ade2be79085342e", "aimux_core::files_model::UploadFileResult": "0d17fd3dbfa601e45c9fabf62f9bb1e5028591443eafccd4eecacef0dcda0368", "aimux_core::generate::GenerateObjectResult": "21cca82de06d366b0f47d781bd49141bb63215accdd1133bb360113a60b7cc00", - "aimux_core::generate::GenerateTextResult": "c5c6016de2c926c85144959d9436c9d2214a27a9724e75d68393e933ef7263f5", + "aimux_core::generate::GenerateTextResult": "c75d0e0c2d207f9dfeffe7eb42efb9040d93a8062cdc678054f9bbcb8049e041", "aimux_core::image_model::ImageCallOptions": "ddacb8970cef4590bcdcc572ced361b181d501d3b474a2d6c50a9c0c02af3eb2", "aimux_core::image_model::ImageResult": "a9d2d939f3dc153a5b5ebc8083bea1226ff63ff2e54e4e275c9ab2b136b9e880", "aimux_core::openai_output::ChatCompletion": "503195cbe7fe458d9403a9de20b93bd17c20bbee0de40a8088bf3847ee835ad9", @@ -105,6 +105,9 @@ var TYPE_SCHEMA_HASHES = map[string]string{ "aimux_core::recording::Recording": "56fa358fb2023da68837722ed573e00fc997506403d7c7aa516c586c45b4fd54", "aimux_core::reranking_model::RerankingCallOptions": "c481b6e7c4d5e71ea7db00166ab2952c8a893443f786a61374c7398b4e475e4c", "aimux_core::reranking_model::RerankingResult": "d757826963b3ce836e4d76fca8f42455a3a3146c20f3fb74f58cabe465348d01", + "aimux_core::result::ReasoningPart": "6210a367b8c084e55a60e0ead74a7ff233b7f357020a028c6879b54ffa8b9b87", + "aimux_core::result::TaggedToolResult": "a8f688a021397c1159b88546156d5a418e50d6482d39f88c46476297d208e069", + "aimux_core::result::TypedSource": "0a36b617c3f1bbcd82e4d09c329ad41aba62330b4d0e950125fd62b2053a9368", "aimux_core::search_model::SearchCallOptions": "3b963a871e6f1858db03b68adc74c5f898d4a2c3c0506e4e359b8d8198d30b22", "aimux_core::search_model::SearchResult": "61075439fcb4276085a11113195dd13220b710cc0c2199ceefa4ec3d07d0195f", "aimux_core::speech_model::SpeechCallOptions": "418be167c89bca652fb0a9dd52a1da359c1ecc2b069b9d2a0859ab76a7f7f431", @@ -132,10 +135,10 @@ var TYPE_SCHEMA_HASHES = map[string]string{ "aimux_ops::ops::handles::TransportParams": "86e40584fcc21dab8f0017f8e892b776ac24aaa9afc943ba805828cecc6e1a4c", "aimux_ops::ops::misc::CatalogueFetchRequest": "2ceed496996ec6cf32d3e3115ab6a4346a1bb201dc8a970eefbd46eb700a310e", "aimux_ops::ops::misc::CodexRefreshRequest": "59f1075ed68cb79896d4bac1d0ab32d21fb5855012c6336652bea0c4969ac926", - "aimux_ops::ops::misc::OpenAiOutputRequest": "b0c6acc344f0b23b9ea3b693aeadf7aed7eb4fbdfce4b957be83af1154b842b4", - "aimux_ops::ops::misc::ToolRepairApplyRequest": "0f430fdb223759ef7c48c4d7f824e7be74d29295a6b4f7caaf82b5acba25e538", - "aimux_ops::ops::misc::ToolRepairApplyResultRequest": "fa092862004654e065233b2df2abdbec3befe88d9d734d494679968a5b6e954a", - "aimux_ops::ops::misc::ToolRepairContextRequest": "81bae04c56aac3380b75de639d162f819a2dd5717147a53cf1a75281727d78a1", + "aimux_ops::ops::misc::OpenAiOutputRequest": "d30e30aa75703e1404a202d437e69a6873fd2b515c5ed322ab488363be8d2fb0", + "aimux_ops::ops::misc::ToolRepairApplyRequest": "c1c5f81107f334a94583a4ff4ed394097580bea2f2a66266c11890fe2a3ab3d0", + "aimux_ops::ops::misc::ToolRepairApplyResultRequest": "649f2b4ff1a2dd0d552e2930b694d7efa3346b2f15a9fb0f14cffd4b6955b508", + "aimux_ops::ops::misc::ToolRepairContextRequest": "fa4802ac20a2b1b540cb727d798ad2a4c44cad6a8f9ad45281fc91ebb065e65f", "aimux_ops::ops::misc::ToolRepairContextResult": "fd8173e6ec40724fa4207e3571e290ac12e4db1fed08a709273e2982a82b504f", "aimux_ops::ops::operation::EmptyParams": "1612408252a424283a43a92193bb8ea24f72c08b9f0d2117b4ef7f5a090e37f8", "aimux_ops::ops::operation::OperationNextParams": "127fea618826e51576ae488dcccaca03c04b774a847a33ec9c47565396862bb7", @@ -169,7 +172,7 @@ var TYPE_SCHEMA_HASHES = map[string]string{ "aimux_ops::ops::replay::ReplayCreateParams": "ee64b5b5843103f76ca2166aed2f58995e472be93cb7bb18dea8238c8a2d9e44", "aimux_ops::ops::replay::ReplayInspection": "7ac2af62f3421f8c7c50867a838f0aff90f35b6a4f192f6c0d5347ab4699108c", "aimux_ops::ops::replay::ReplayLiveParams": "e99c7d51fb194def185f5a03d84bfc226eb1b101eade0b885216332605318a4d", - "aimux_ops::ops::replay::ReplayLiveResult": "bd9959dd7e0300cb57e6929b2ed29b7e07dcb5aaf65be16b96e34bf8d6577a7f", + "aimux_ops::ops::replay::ReplayLiveResult": "9163acd59ee54db1db2213c0756283b8b27e04a52451dfeef314d63efebbc730", "aimux_ops::ops::replay::ReplayPlan": "5cc6667b9fac6de173bf5b55c1a76a491255f89f0fa7a27c0fd33fd790259799", "aimux_ops::ops::replay::ReplaySessionHandle": "5e779b71ce2a54e59948c605cdfc48797d0760027ad5f44966df958fe9781d11", "aimux_ops::ops::runtime::RuntimeConfigureParams": "e3b24b9f1fbdf2be7da210f15060803cf8bfdef77c8b2ad330a5b501263dfb0f", @@ -177,8 +180,8 @@ var TYPE_SCHEMA_HASHES = map[string]string{ "aimux_ops::ops::session::SessionStoreCallsParams": "ddd482204fdd305bbfd28d43ae829d8c286f3f8906302ca6679743ea680fedda", "aimux_ops::ops::session::SessionStoreCreateParams": "080d865c349ec86553f72b99ab1c65ddbb72d0c348a96dc17135a934d787cd86", "aimux_ops::ops::session::SessionStoreHandle": "755d437d47d362474942fc4a09f5f8c80b75cf362ac16b25b262e33a760b4c6a", - "aimux_ops::ops::text::OpenAiTextRequest": "59293b18b6124a9a394113b8f94f637c65dc35ac44a30f7e0df70855e885f8e4", - "aimux_ops::ops::text::TextRequest": "3a6f59c1f0c3b7ded5f5509d93afe9bddd2b80a8a3cd752d79f97edadae40c3d", + "aimux_ops::ops::text::OpenAiTextRequest": "d5afbf2b24ab74b82433d344afb190c18f8aef52988c54ab8b5388579c212f67", + "aimux_ops::ops::text::TextRequest": "eb0c25fcbf741834943882d7f901af7439ba30923a391b273526d1887ed156ab", "aimux_ops::ops::trace::TraceAggregateParams": "1b207f0bbe1b7ce7e9b8b0beb9334cf3cc4f9f05382911aaacfe0425dc8ff2c8", "aimux_ops::ops::trace::TraceCreateParams": "59fef52f382800570e861ae9ca92433dcae8807679d914a89ce99705713301d9", "aimux_ops::ops::trace::TraceSessionParams": "3e2300f6c65f6dcd52a016eba648a29abeff3a9d67c3b04a95617aa66832f810", diff --git a/bindings/go/roundtrip_test.go b/bindings/go/roundtrip_test.go index 7a25a3278..9d6cf4b60 100644 --- a/bindings/go/roundtrip_test.go +++ b/bindings/go/roundtrip_test.go @@ -140,8 +140,60 @@ func TestParseFinishPayload(t *testing.T) { } } +func TestGenerateTextResultRejectsEmptySteps(t *testing.T) { + raw := []byte(`{"steps":[],"totalUsage":{"inputTokenDetails":{},"outputTokenDetails":{}}}`) + var result GenerateTextResult + if err := json.Unmarshal(raw, &result); err == nil { + t.Fatal("decoded a text result without any steps") + } +} + func TestGenerateTextResultWithWarningsRoundTrip(t *testing.T) { - roundTripDTO[GenerateTextResult](t, `{"content":[],"text":"ok","reasoning":[],"files":[],"sources":[],"toolCalls":[],"toolResults":[],"finishReason":"stop","usage":{"inputTokenDetails":{},"outputTokenDetails":{}},"totalUsage":{"inputTokenDetails":{},"outputTokenDetails":{}},"warnings":[{"type":"other","message":"some warning"}],"request":{},"response":{"id":"r1","timestamp":"2026-10-16T00:00:00Z","modelId":"model","messages":[]},"responseMessages":[],"steps":[]}`) + const facts = `{ + "steps": [{ + "callId":"c1","stepNumber":0,"content":[{"type":"text","text":"ok"}], + "model":{"modelId":"model","provider":"openai"},"finishReason":"stop", + "usage":{"inputTokenDetails":{},"outputTokenDetails":{}}, + "performance":{"effectiveOutputTokensPerSecond":0,"effectiveTotalTokensPerSecond":0, + "responseTimeMs":0,"stepTimeMs":0,"toolExecutionMs":{}}, + "warnings":[{"type":"other","message":"some warning"}],"request":{}, + "response":{"id":"r1","timestamp":"2026-10-16T00:00:00Z","modelId":"model","messages":[]} + }], + "totalUsage":{"inputTokenDetails":{},"outputTokenDetails":{}} + }` + roundTripDTO[GenerateTextResult](t, facts) + var result GenerateTextResult + if err := json.Unmarshal([]byte(facts), &result); err != nil { + t.Fatal(err) + } + if result.Text() != "ok" || string(result.Output()) != `"ok"` || len(result.Warnings()) != 1 { + t.Fatalf("unexpected derived result: %q, %s, %v", result.Text(), result.Output(), result.Warnings()) + } + + var parsedNull GenerateTextResult + withNull := facts[:len(facts)-1] + `,"output":null}` + if err := json.Unmarshal([]byte(withNull), &parsedNull); err != nil { + t.Fatal(err) + } + if string(parsedNull.Output()) != "null" { + t.Fatalf("expected explicit null output, got %q", parsedNull.Output()) + } + + unparsed := facts[:len(facts)-1] + `,"outputParsed":false}` + roundTripDTO[GenerateTextResult](t, unparsed) + var notParsed GenerateTextResult + if err := json.Unmarshal([]byte(unparsed), ¬Parsed); err != nil { + t.Fatal(err) + } + if notParsed.Output() != nil { + t.Fatalf("expected nil output when outputParsed is false, got %q", notParsed.Output()) + } + + contradictory := facts[:len(facts)-1] + `,"output":null,"outputParsed":false}` + var bad GenerateTextResult + if err := json.Unmarshal([]byte(contradictory), &bad); err == nil { + t.Fatal("decoded a text result with both output and outputParsed=false") + } } // Provider-tool deferred-result support follows the Rust wire contract. diff --git a/bindings/go/types_gen.go b/bindings/go/types_gen.go index 0335342fe..a3f1a32da 100644 --- a/bindings/go/types_gen.go +++ b/bindings/go/types_gen.go @@ -4478,6 +4478,8 @@ type GenerateObjectResult struct { type GenerateTextOptions struct { FrequencyPenalty *float64 `json:"frequencyPenalty,omitzero"` Headers map[string]string `json:"headers,omitzero"` + // Controls the raw bodies exposed in the result. Both default to `false`. + Include *IncludeOptions `json:"include,omitzero"` // Emit raw provider stream chunks as `StreamPart::Raw` (debugging aid). IncludeRawChunks *bool `json:"includeRawChunks,omitzero"` // System instructions prepended to the prompt. @@ -4528,7 +4530,7 @@ func (v *GenerateTextOptions) UnmarshalJSON(data []byte) error { } for key := range raw { switch key { - case "frequencyPenalty", "headers", "includeRawChunks", "instructions", "maxOutputTokens", "maxRetries", "output", "presencePenalty", "providerOptions", "reasoning", "seed", "sessionId", "stopSequences", "strictStream", "temperature", "timeout", "toolChoice", "tools", "topK", "topP": + case "frequencyPenalty", "headers", "include", "includeRawChunks", "instructions", "maxOutputTokens", "maxRetries", "output", "presencePenalty", "providerOptions", "reasoning", "seed", "sessionId", "stopSequences", "strictStream", "temperature", "timeout", "toolChoice", "tools", "topK", "topP": default: return fmt.Errorf("unknown field %q in GenerateTextOptions", key) } @@ -4547,40 +4549,193 @@ func (v *GenerateTextOptions) UnmarshalJSON(data []byte) error { // // It stores the steps, the usage summed over them and the parsed output, as // `DefaultGenerateTextResult` does (`generate-text.ts:1691-1808`); every -// other value is derived from the steps by an accessor. The serialized form -// is a snapshot that writes the derived values next to the stored ones, so -// a binding reads `text`, `tool_calls`, `usage` and the rest directly. Only -// `steps`, `total_usage` and `output` are read back. +// other value is derived from the steps by an accessor. The wire form carries +// `steps`, `totalUsage`, optional `output` (when explicitly parsed), and +// optional `outputParsed: false` (when no output was generated). type GenerateTextResult struct { - Content []ContentPart `json:"content"` - Files []GeneratedFile `json:"files"` - FinishReason FinishReasonUnified `json:"finishReason"` - // Absent when the output was not parsed. - Output Field[json.RawMessage] `json:"output,omitzero"` - // Deprecated upstream: the last step's provider metadata. - ProviderMetadata map[string]map[string]json.RawMessage `json:"providerMetadata,omitzero"` - RawFinishReason *string `json:"rawFinishReason,omitzero"` - // Deprecated upstream: the last step's reasoning. - Reasoning []ReasoningPart `json:"reasoning"` - // Deprecated upstream: the last step's reasoning text. - ReasoningText *string `json:"reasoningText,omitzero"` - // Deprecated upstream: the last step's request. - Request RequestInfo `json:"request"` - // Deprecated upstream: the last step's response. - Response StepResponse `json:"response"` - ResponseMessages []ModelMessage `json:"responseMessages"` - // Each with its `type` tag (`generate-text-result.ts:73`). - Sources []TypedSource `json:"sources"` - Steps []StepResult `json:"steps"` - Text string `json:"text"` - // Each with its `type` tag (`generate-text-result.ts:78`). - ToolCalls []TypedToolCall `json:"toolCalls"` - // Each with its `type` tag (`generate-text-result.ts:93`). - ToolResults []TaggedToolResult `json:"toolResults"` - // Deprecated upstream: equal to `usage`. - TotalUsage LanguageModelUsage `json:"totalUsage"` - Usage LanguageModelUsage `json:"usage"` - Warnings []Warning `json:"warnings"` + // An explicit parsed output, including JSON `null`. When absent and + // `outputParsed` is not `false`, bindings expose the final step's text. + OutputValue Field[json.RawMessage] `json:"output,omitzero"` + // Present and `false` when no output was generated (for example, a final + // `tool-calls` step without an output spec). Omitted when an output was + // produced. + OutputParsed *bool `json:"outputParsed,omitzero"` + Steps []StepResult `json:"steps"` + TotalUsage LanguageModelUsage `json:"totalUsage"` +} + +func (v *GenerateTextResult) UnmarshalJSON(data []byte) error { + type facts GenerateTextResult + var result facts + if err := json.Unmarshal(data, &result); err != nil { + return err + } + if len(result.Steps) == 0 { + return fmt.Errorf("GenerateTextResult requires at least one step") + } + if result.OutputValue.Present && result.OutputParsed != nil && !*result.OutputParsed { + return fmt.Errorf("GenerateTextResult cannot carry output when outputParsed is false") + } + *v = GenerateTextResult(result) + return nil +} + +// FinalStep is the last model call in the result. +func (v GenerateTextResult) FinalStep() StepResult { return v.Steps[len(v.Steps)-1] } + +func (v GenerateTextResult) Text() string { + text := "" + for _, part := range v.FinalStep().Content { + if part, ok := part.Value.(ContentPartVariantText); ok { + text += part.Text + } + } + return text +} + +func (v GenerateTextResult) Content() []ContentPart { + out := []ContentPart{} + for _, step := range v.Steps { + out = append(out, step.Content...) + } + return out +} + +// resultParts selects payloads directly from ordered content. +func resultParts[T ContentPartVariant](content []ContentPart) []T { + out := []T{} + for _, part := range content { + if value, ok := part.Value.(T); ok { + out = append(out, value) + } + } + return out +} + +func (v GenerateTextResult) Reasoning() []ContentPart { + out := []ContentPart{} + for _, part := range v.FinalStep().Content { + switch part.Value.(type) { + case ContentPartVariantReasoning, ContentPartVariantReasoningFile: + out = append(out, part) + } + } + return out +} + +func (v GenerateTextResult) ReasoningText() *string { + text := "" + for _, part := range resultParts[ContentPartVariantReasoning](v.FinalStep().Content) { + text += part.Text + } + if text == "" { + return nil + } + return &text +} + +func (v GenerateTextResult) Files() []GeneratedFile { + out := []GeneratedFile{} + for _, part := range resultParts[ContentPartVariantFile](v.Content()) { + out = append(out, part.File) + } + return out +} + +func (v GenerateTextResult) Sources() []ContentPart { + out := []ContentPart{} + for _, part := range v.Content() { + switch part.Value.(type) { + case ContentPartVariantSourceURL, ContentPartVariantSourceDocument: + out = append(out, part) + } + } + return out +} + +func (v GenerateTextResult) ToolCalls() []ContentPartVariantToolCall { + return resultParts[ContentPartVariantToolCall](v.Content()) +} + +func (v GenerateTextResult) toolCallsByDynamic(dynamic bool) []ContentPartVariantToolCall { + out := []ContentPartVariantToolCall{} + for _, part := range v.ToolCalls() { + if (part.Dynamic != nil && *part.Dynamic) == dynamic { + out = append(out, part) + } + } + return out +} + +func (v GenerateTextResult) StaticToolCalls() []ContentPartVariantToolCall { + return v.toolCallsByDynamic(false) +} + +func (v GenerateTextResult) DynamicToolCalls() []ContentPartVariantToolCall { + return v.toolCallsByDynamic(true) +} + +func (v GenerateTextResult) ToolResults() []ContentPartVariantToolResult { + return resultParts[ContentPartVariantToolResult](v.Content()) +} + +func (v GenerateTextResult) toolResultsByDynamic(dynamic bool) []ContentPartVariantToolResult { + out := []ContentPartVariantToolResult{} + for _, part := range v.ToolResults() { + if (part.Dynamic != nil && *part.Dynamic) == dynamic { + out = append(out, part) + } + } + return out +} + +func (v GenerateTextResult) StaticToolResults() []ContentPartVariantToolResult { + return v.toolResultsByDynamic(false) +} + +func (v GenerateTextResult) DynamicToolResults() []ContentPartVariantToolResult { + return v.toolResultsByDynamic(true) +} + +func (v GenerateTextResult) FinishReason() FinishReasonUnified { return v.FinalStep().FinishReason } +func (v GenerateTextResult) RawFinishReason() *string { return v.FinalStep().RawFinishReason } +func (v GenerateTextResult) Usage() LanguageModelUsage { return v.TotalUsage } +func (v GenerateTextResult) Request() RequestInfo { return v.FinalStep().Request } +func (v GenerateTextResult) Response() StepResponse { return v.FinalStep().Response } +func (v GenerateTextResult) ProviderMetadata() map[string]map[string]json.RawMessage { + return v.FinalStep().ProviderMetadata +} + +func (v GenerateTextResult) Warnings() []Warning { + out := []Warning{} + for _, step := range v.Steps { + out = append(out, step.Warnings...) + } + return out +} + +func (v GenerateTextResult) ResponseMessages() []ModelMessage { + out := []ModelMessage{} + for _, step := range v.Steps { + out = append(out, step.Response.Messages...) + } + return out +} + +// Output returns the parsed JSON value, the final step's text as a JSON string +// when parsed as plain text, or nil when no output was generated. +func (v GenerateTextResult) Output() json.RawMessage { + if v.OutputValue.Present { + if v.OutputValue.Null { + return json.RawMessage("null") + } + return v.OutputValue.Value + } + if v.OutputParsed != nil && !*v.OutputParsed { + return nil + } + value, _ := json.Marshal(v.Text()) + return value } // Result of `generate_text` and of a consumed `stream_text`: the AI SDK's @@ -4588,14 +4743,19 @@ type GenerateTextResult struct { // // It stores the steps, the usage summed over them and the parsed output, as // `DefaultGenerateTextResult` does (`generate-text.ts:1691-1808`); every -// other value is derived from the steps by an accessor. The serialized form -// is a snapshot that writes the derived values next to the stored ones, so -// a binding reads `text`, `tool_calls`, `usage` and the rest directly. Only -// `steps`, `total_usage` and `output` are read back. +// other value is derived from the steps by an accessor. The wire form carries +// `steps`, `totalUsage`, optional `output` (when explicitly parsed), and +// optional `outputParsed: false` (when no output was generated). type GenerateTextResultInput struct { - Output Field[json.RawMessage] `json:"output,omitzero"` - Steps []StepResultInput `json:"steps"` - TotalUsage LanguageModelUsageInput `json:"totalUsage"` + // An explicit parsed output, including JSON `null`. When absent and + // `outputParsed` is not `false`, bindings expose the final step's text. + Output Field[json.RawMessage] `json:"output,omitzero"` + // Present and `false` when no output was generated (for example, a final + // `tool-calls` step without an output spec). Omitted when an output was + // produced. + OutputParsed *bool `json:"outputParsed,omitzero"` + Steps []StepResultInput `json:"steps"` + TotalUsage LanguageModelUsageInput `json:"totalUsage"` } // A generated file (`ai` `generate-text/generated-file.ts:10-32`), the @@ -4960,6 +5120,38 @@ type ImageUsage struct { TotalTokens *uint32 `json:"totalTokens,omitzero"` } +// Controls which raw body fields are exposed in generation results. +type IncludeOptions struct { + // Whether to return the request body. Defaults to false. + RequestBody *bool `json:"requestBody,omitzero"` + // Whether to return the response body. Defaults to false. + ResponseBody *bool `json:"responseBody,omitzero"` +} + +func (v *IncludeOptions) UnmarshalJSON(data []byte) error { + var raw map[string]json.RawMessage + if err := json.Unmarshal(data, &raw); err != nil { + return err + } + if raw == nil { + return fmt.Errorf("expected object for IncludeOptions, got null") + } + for key := range raw { + switch key { + case "requestBody", "responseBody": + default: + return fmt.Errorf("unknown field %q in IncludeOptions", key) + } + } + type alias IncludeOptions + var tmp alias + if err := json.Unmarshal(data, &tmp); err != nil { + return err + } + *v = IncludeOptions(tmp) + return nil +} + // The input audio format for a streaming transcription request. type InputAudioFormat struct { // Audio format type, e.g. `"audio/pcm"`, `"audio/pcmu"`, `"audio/pcma"`. @@ -6575,6 +6767,8 @@ type OperationStatus struct { type Options struct { FrequencyPenalty *float64 `json:"frequencyPenalty,omitzero"` Headers map[string]string `json:"headers,omitzero"` + // Controls the raw bodies exposed in the result. Both default to `false`. + Include *IncludeOptions `json:"include,omitzero"` // Emit raw provider stream chunks as `StreamPart::Raw` (debugging aid). IncludeRawChunks *bool `json:"includeRawChunks,omitzero"` // System instructions prepended to the prompt. @@ -6625,7 +6819,7 @@ func (v *Options) UnmarshalJSON(data []byte) error { } for key := range raw { switch key { - case "frequencyPenalty", "headers", "includeRawChunks", "instructions", "maxOutputTokens", "maxRetries", "output", "presencePenalty", "providerOptions", "reasoning", "seed", "sessionId", "stopSequences", "strictStream", "temperature", "timeout", "toolChoice", "tools", "topK", "topP": + case "frequencyPenalty", "headers", "include", "includeRawChunks", "instructions", "maxOutputTokens", "maxRetries", "output", "presencePenalty", "providerOptions", "reasoning", "seed", "sessionId", "stopSequences", "strictStream", "temperature", "timeout", "toolChoice", "tools", "topK", "topP": default: return fmt.Errorf("unknown field %q in Options", key) } @@ -8206,7 +8400,7 @@ func (v *ReplayLiveResult) UnmarshalJSON(data []byte) error { var err error { var next GenerateTextResult - if err = decodeUnionBranch(data, &next, false, "content", "files", "finishReason", "reasoning", "request", "response", "responseMessages", "sources", "steps", "text", "toolCalls", "toolResults", "totalUsage", "usage", "warnings"); err == nil { + if err = decodeUnionBranch(data, &next, false, "steps", "totalUsage"); err == nil { v.Value = ReplayLiveResultBranchGenerateTextResult{Value: next} return nil } @@ -13932,6 +14126,8 @@ func NewDTO(name string) (any, error) { return new(ImageResult), nil case "ImageUsage": return new(ImageUsage), nil + case "IncludeOptions": + return new(IncludeOptions), nil case "InputAudioFormat": return new(InputAudioFormat), nil case "InputRecord": diff --git a/bindings/java/generated/AimuxOps.java b/bindings/java/generated/AimuxOps.java index c1a5df588..5a2b4c55f 100644 --- a/bindings/java/generated/AimuxOps.java +++ b/bindings/java/generated/AimuxOps.java @@ -1,11 +1,11 @@ -// Generated by aimux-codegen. Do not edit. Manifest SHA-256: cd147fa9595ede3951744fa261da98cc18c204e65b4081073ad3a3c1b68bfd92 +// Generated by aimux-codegen. Do not edit. Manifest SHA-256: 6914772fdc03df08cba497def41cb354fe52e40eba49844a66938b4cd38c5d83 package ai.arcships.aimux.generated; public final class AimuxOps { private AimuxOps() {} public static final long ABI_VERSION = 65536L; public static final String OPS_VERSION = "1.0"; - public static final String MANIFEST_DIGEST = "cd147fa9595ede3951744fa261da98cc18c204e65b4081073ad3a3c1b68bfd92"; + public static final String MANIFEST_DIGEST = "6914772fdc03df08cba497def41cb354fe52e40eba49844a66938b4cd38c5d83"; public static final String OP_ABORT_CREATE = "abort.create"; public static final String OP_ABORT_SIGNAL = "abort.signal"; public static final String OP_AUTH_CODEX_REFRESH = "auth.codexRefresh"; @@ -98,7 +98,7 @@ private AimuxOps() {} hashes.put("aimux_core::embedding_model::EmbeddingResult", "af3ce0787db6208be114613c78dc02f038cb5dc2f7abcf6a4ade2be79085342e"); hashes.put("aimux_core::files_model::UploadFileResult", "0d17fd3dbfa601e45c9fabf62f9bb1e5028591443eafccd4eecacef0dcda0368"); hashes.put("aimux_core::generate::GenerateObjectResult", "21cca82de06d366b0f47d781bd49141bb63215accdd1133bb360113a60b7cc00"); - hashes.put("aimux_core::generate::GenerateTextResult", "c5c6016de2c926c85144959d9436c9d2214a27a9724e75d68393e933ef7263f5"); + hashes.put("aimux_core::generate::GenerateTextResult", "c75d0e0c2d207f9dfeffe7eb42efb9040d93a8062cdc678054f9bbcb8049e041"); hashes.put("aimux_core::image_model::ImageCallOptions", "ddacb8970cef4590bcdcc572ced361b181d501d3b474a2d6c50a9c0c02af3eb2"); hashes.put("aimux_core::image_model::ImageResult", "a9d2d939f3dc153a5b5ebc8083bea1226ff63ff2e54e4e275c9ab2b136b9e880"); hashes.put("aimux_core::openai_output::ChatCompletion", "503195cbe7fe458d9403a9de20b93bd17c20bbee0de40a8088bf3847ee835ad9"); @@ -106,6 +106,9 @@ private AimuxOps() {} hashes.put("aimux_core::recording::Recording", "56fa358fb2023da68837722ed573e00fc997506403d7c7aa516c586c45b4fd54"); hashes.put("aimux_core::reranking_model::RerankingCallOptions", "c481b6e7c4d5e71ea7db00166ab2952c8a893443f786a61374c7398b4e475e4c"); hashes.put("aimux_core::reranking_model::RerankingResult", "d757826963b3ce836e4d76fca8f42455a3a3146c20f3fb74f58cabe465348d01"); + hashes.put("aimux_core::result::ReasoningPart", "6210a367b8c084e55a60e0ead74a7ff233b7f357020a028c6879b54ffa8b9b87"); + hashes.put("aimux_core::result::TaggedToolResult", "a8f688a021397c1159b88546156d5a418e50d6482d39f88c46476297d208e069"); + hashes.put("aimux_core::result::TypedSource", "0a36b617c3f1bbcd82e4d09c329ad41aba62330b4d0e950125fd62b2053a9368"); hashes.put("aimux_core::search_model::SearchCallOptions", "3b963a871e6f1858db03b68adc74c5f898d4a2c3c0506e4e359b8d8198d30b22"); hashes.put("aimux_core::search_model::SearchResult", "61075439fcb4276085a11113195dd13220b710cc0c2199ceefa4ec3d07d0195f"); hashes.put("aimux_core::speech_model::SpeechCallOptions", "418be167c89bca652fb0a9dd52a1da359c1ecc2b069b9d2a0859ab76a7f7f431"); @@ -133,10 +136,10 @@ private AimuxOps() {} hashes.put("aimux_ops::ops::handles::TransportParams", "86e40584fcc21dab8f0017f8e892b776ac24aaa9afc943ba805828cecc6e1a4c"); hashes.put("aimux_ops::ops::misc::CatalogueFetchRequest", "2ceed496996ec6cf32d3e3115ab6a4346a1bb201dc8a970eefbd46eb700a310e"); hashes.put("aimux_ops::ops::misc::CodexRefreshRequest", "59f1075ed68cb79896d4bac1d0ab32d21fb5855012c6336652bea0c4969ac926"); - hashes.put("aimux_ops::ops::misc::OpenAiOutputRequest", "b0c6acc344f0b23b9ea3b693aeadf7aed7eb4fbdfce4b957be83af1154b842b4"); - hashes.put("aimux_ops::ops::misc::ToolRepairApplyRequest", "0f430fdb223759ef7c48c4d7f824e7be74d29295a6b4f7caaf82b5acba25e538"); - hashes.put("aimux_ops::ops::misc::ToolRepairApplyResultRequest", "fa092862004654e065233b2df2abdbec3befe88d9d734d494679968a5b6e954a"); - hashes.put("aimux_ops::ops::misc::ToolRepairContextRequest", "81bae04c56aac3380b75de639d162f819a2dd5717147a53cf1a75281727d78a1"); + hashes.put("aimux_ops::ops::misc::OpenAiOutputRequest", "d30e30aa75703e1404a202d437e69a6873fd2b515c5ed322ab488363be8d2fb0"); + hashes.put("aimux_ops::ops::misc::ToolRepairApplyRequest", "c1c5f81107f334a94583a4ff4ed394097580bea2f2a66266c11890fe2a3ab3d0"); + hashes.put("aimux_ops::ops::misc::ToolRepairApplyResultRequest", "649f2b4ff1a2dd0d552e2930b694d7efa3346b2f15a9fb0f14cffd4b6955b508"); + hashes.put("aimux_ops::ops::misc::ToolRepairContextRequest", "fa4802ac20a2b1b540cb727d798ad2a4c44cad6a8f9ad45281fc91ebb065e65f"); hashes.put("aimux_ops::ops::misc::ToolRepairContextResult", "fd8173e6ec40724fa4207e3571e290ac12e4db1fed08a709273e2982a82b504f"); hashes.put("aimux_ops::ops::operation::EmptyParams", "1612408252a424283a43a92193bb8ea24f72c08b9f0d2117b4ef7f5a090e37f8"); hashes.put("aimux_ops::ops::operation::OperationNextParams", "127fea618826e51576ae488dcccaca03c04b774a847a33ec9c47565396862bb7"); @@ -170,7 +173,7 @@ private AimuxOps() {} hashes.put("aimux_ops::ops::replay::ReplayCreateParams", "ee64b5b5843103f76ca2166aed2f58995e472be93cb7bb18dea8238c8a2d9e44"); hashes.put("aimux_ops::ops::replay::ReplayInspection", "7ac2af62f3421f8c7c50867a838f0aff90f35b6a4f192f6c0d5347ab4699108c"); hashes.put("aimux_ops::ops::replay::ReplayLiveParams", "e99c7d51fb194def185f5a03d84bfc226eb1b101eade0b885216332605318a4d"); - hashes.put("aimux_ops::ops::replay::ReplayLiveResult", "bd9959dd7e0300cb57e6929b2ed29b7e07dcb5aaf65be16b96e34bf8d6577a7f"); + hashes.put("aimux_ops::ops::replay::ReplayLiveResult", "9163acd59ee54db1db2213c0756283b8b27e04a52451dfeef314d63efebbc730"); hashes.put("aimux_ops::ops::replay::ReplayPlan", "5cc6667b9fac6de173bf5b55c1a76a491255f89f0fa7a27c0fd33fd790259799"); hashes.put("aimux_ops::ops::replay::ReplaySessionHandle", "5e779b71ce2a54e59948c605cdfc48797d0760027ad5f44966df958fe9781d11"); hashes.put("aimux_ops::ops::runtime::RuntimeConfigureParams", "e3b24b9f1fbdf2be7da210f15060803cf8bfdef77c8b2ad330a5b501263dfb0f"); @@ -178,8 +181,8 @@ private AimuxOps() {} hashes.put("aimux_ops::ops::session::SessionStoreCallsParams", "ddd482204fdd305bbfd28d43ae829d8c286f3f8906302ca6679743ea680fedda"); hashes.put("aimux_ops::ops::session::SessionStoreCreateParams", "080d865c349ec86553f72b99ab1c65ddbb72d0c348a96dc17135a934d787cd86"); hashes.put("aimux_ops::ops::session::SessionStoreHandle", "755d437d47d362474942fc4a09f5f8c80b75cf362ac16b25b262e33a760b4c6a"); - hashes.put("aimux_ops::ops::text::OpenAiTextRequest", "59293b18b6124a9a394113b8f94f637c65dc35ac44a30f7e0df70855e885f8e4"); - hashes.put("aimux_ops::ops::text::TextRequest", "3a6f59c1f0c3b7ded5f5509d93afe9bddd2b80a8a3cd752d79f97edadae40c3d"); + hashes.put("aimux_ops::ops::text::OpenAiTextRequest", "d5afbf2b24ab74b82433d344afb190c18f8aef52988c54ab8b5388579c212f67"); + hashes.put("aimux_ops::ops::text::TextRequest", "eb0c25fcbf741834943882d7f901af7439ba30923a391b273526d1887ed156ab"); hashes.put("aimux_ops::ops::trace::TraceAggregateParams", "1b207f0bbe1b7ce7e9b8b0beb9334cf3cc4f9f05382911aaacfe0425dc8ff2c8"); hashes.put("aimux_ops::ops::trace::TraceCreateParams", "59fef52f382800570e861ae9ca92433dcae8807679d914a89ce99705713301d9"); hashes.put("aimux_ops::ops::trace::TraceSessionParams", "3e2300f6c65f6dcd52a016eba648a29abeff3a9d67c3b04a95617aa66832f810"); diff --git a/bindings/java/generated/ai/arcships/aimux/types/DtoTypes.java b/bindings/java/generated/ai/arcships/aimux/types/DtoTypes.java index cd9661b3e..916d69156 100644 --- a/bindings/java/generated/ai/arcships/aimux/types/DtoTypes.java +++ b/bindings/java/generated/ai/arcships/aimux/types/DtoTypes.java @@ -189,6 +189,8 @@ public static JsonNode roundTrip(String type, JsonNode value) throws java.io.IOE return DtoJson.MAPPER.valueToTree(DtoJson.MAPPER.treeToValue(value, ImageResult.class)); case "ImageUsage": return DtoJson.MAPPER.valueToTree(DtoJson.MAPPER.treeToValue(value, ImageUsage.class)); + case "IncludeOptions": + return DtoJson.MAPPER.valueToTree(DtoJson.MAPPER.treeToValue(value, IncludeOptions.class)); case "InputAudioFormat": return DtoJson.MAPPER.valueToTree(DtoJson.MAPPER.treeToValue(value, InputAudioFormat.class)); case "InputRecord": diff --git a/bindings/java/generated/ai/arcships/aimux/types/GenerateTextOptions.java b/bindings/java/generated/ai/arcships/aimux/types/GenerateTextOptions.java index 9583236c5..202109617 100644 --- a/bindings/java/generated/ai/arcships/aimux/types/GenerateTextOptions.java +++ b/bindings/java/generated/ai/arcships/aimux/types/GenerateTextOptions.java @@ -25,6 +25,11 @@ public final class GenerateTextOptions { private final BigDecimal frequencyPenalty; @JsonProperty("headers") private final Map headers; + /** + * Controls the raw bodies exposed in the result. Both default to `false`. + */ + @JsonProperty("include") + private final IncludeOptions include; /** * Emit raw provider stream chunks as `StreamPart::Raw` (debugging aid). */ @@ -102,6 +107,7 @@ public final class GenerateTextOptions { public GenerateTextOptions( @JsonProperty(value = "frequencyPenalty") BigDecimal frequencyPenalty, @JsonProperty(value = "headers") Map headers, + @JsonProperty(value = "include") IncludeOptions include, @JsonProperty(value = "includeRawChunks") Boolean includeRawChunks, @JsonProperty(value = "instructions") String instructions, @JsonProperty(value = "maxOutputTokens") Long maxOutputTokens, @@ -122,6 +128,7 @@ public GenerateTextOptions( @JsonProperty(value = "topP") BigDecimal topP) { this.frequencyPenalty = frequencyPenalty; this.headers = headers == null ? null : Collections.unmodifiableMap(new LinkedHashMap<>(headers)); + this.include = include; this.includeRawChunks = includeRawChunks; this.instructions = instructions; this.maxOutputTokens = maxOutputTokens; @@ -145,6 +152,7 @@ public GenerateTextOptions( public static Builder builder() { return new Builder(); } public BigDecimal getFrequencyPenalty() { return frequencyPenalty; } public Map getHeaders() { return headers; } + public IncludeOptions getInclude() { return include; } public Boolean getIncludeRawChunks() { return includeRawChunks; } public String getInstructions() { return instructions; } public Long getMaxOutputTokens() { return maxOutputTokens; } @@ -167,6 +175,7 @@ public GenerateTextOptions( public static final class Builder { private BigDecimal frequencyPenalty; private Map headers; + private IncludeOptions include; private Boolean includeRawChunks; private String instructions; private Long maxOutputTokens; @@ -196,6 +205,11 @@ public Builder headers(Map value) { return this; } + public Builder include(IncludeOptions value) { + this.include = value; + return this; + } + public Builder includeRawChunks(Boolean value) { this.includeRawChunks = value; return this; @@ -286,6 +300,6 @@ public Builder topP(BigDecimal value) { return this; } - public GenerateTextOptions build() { return new GenerateTextOptions(frequencyPenalty, headers, includeRawChunks, instructions, maxOutputTokens, maxRetries, output, presencePenalty, providerOptions, reasoning, seed, sessionId, stopSequences, strictStream, temperature, timeout, toolChoice, tools, topK, topP); } + public GenerateTextOptions build() { return new GenerateTextOptions(frequencyPenalty, headers, include, includeRawChunks, instructions, maxOutputTokens, maxRetries, output, presencePenalty, providerOptions, reasoning, seed, sessionId, stopSequences, strictStream, temperature, timeout, toolChoice, tools, topK, topP); } } } diff --git a/bindings/java/generated/ai/arcships/aimux/types/GenerateTextResult.java b/bindings/java/generated/ai/arcships/aimux/types/GenerateTextResult.java index 52990cbab..79cc611e1 100644 --- a/bindings/java/generated/ai/arcships/aimux/types/GenerateTextResult.java +++ b/bindings/java/generated/ai/arcships/aimux/types/GenerateTextResult.java @@ -13,184 +13,151 @@ * * It stores the steps, the usage summed over them and the parsed output, as * `DefaultGenerateTextResult` does (`generate-text.ts:1691-1808`); every - * other value is derived from the steps by an accessor. The serialized form - * is a snapshot that writes the derived values next to the stored ones, so - * a binding reads `text`, `tool_calls`, `usage` and the rest directly. Only - * `steps`, `total_usage` and `output` are read back. + * other value is derived from the steps by an accessor. The wire form carries + * `steps`, `totalUsage`, optional `output` (when explicitly parsed), and + * optional `outputParsed: false` (when no output was generated). */ @JsonIgnoreProperties(ignoreUnknown = true) @JsonInclude(JsonInclude.Include.NON_NULL) @JsonAutoDetect(getterVisibility = JsonAutoDetect.Visibility.NONE, isGetterVisibility = JsonAutoDetect.Visibility.NONE) public final class GenerateTextResult { - @JsonProperty("content") - private final List content; - @JsonProperty("files") - private final List files; - @JsonProperty("finishReason") - private final FinishReasonUnified finishReason; /** - * Absent when the output was not parsed. + * An explicit parsed output, including JSON `null`. When absent and + * `outputParsed` is not `false`, bindings expose the final step's text. */ @JsonProperty("output") @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = FieldPresence.Absent.class) private final FieldPresence output; /** - * Deprecated upstream: the last step's provider metadata. + * Present and `false` when no output was generated (for example, a final + * `tool-calls` step without an output spec). Omitted when an output was + * produced. */ - @JsonProperty("providerMetadata") - private final Map> providerMetadata; - @JsonProperty("rawFinishReason") - private final String rawFinishReason; - /** - * Deprecated upstream: the last step's reasoning. - */ - @JsonProperty("reasoning") - private final List reasoning; - /** - * Deprecated upstream: the last step's reasoning text. - */ - @JsonProperty("reasoningText") - private final String reasoningText; - /** - * Deprecated upstream: the last step's request. - */ - @JsonProperty("request") - private final RequestInfo request; - /** - * Deprecated upstream: the last step's response. - */ - @JsonProperty("response") - private final StepResponse response; - @JsonProperty("responseMessages") - private final List responseMessages; - /** - * Each with its `type` tag (`generate-text-result.ts:73`). - */ - @JsonProperty("sources") - private final List sources; + @JsonProperty("outputParsed") + private final Boolean outputParsed; @JsonProperty("steps") private final List steps; - @JsonProperty("text") - private final String text; - /** - * Each with its `type` tag (`generate-text-result.ts:78`). - */ - @JsonProperty("toolCalls") - private final List toolCalls; - /** - * Each with its `type` tag (`generate-text-result.ts:93`). - */ - @JsonProperty("toolResults") - private final List toolResults; - /** - * Deprecated upstream: equal to `usage`. - */ @JsonProperty("totalUsage") private final LanguageModelUsage totalUsage; - @JsonProperty("usage") - private final LanguageModelUsage usage; - @JsonProperty("warnings") - private final List warnings; @JsonCreator public GenerateTextResult( - @JsonProperty(value = "content", required = true) List content, - @JsonProperty(value = "files", required = true) List files, - @JsonProperty(value = "finishReason", required = true) FinishReasonUnified finishReason, @JsonProperty(value = "output") FieldPresence output, - @JsonProperty(value = "providerMetadata") Map> providerMetadata, - @JsonProperty(value = "rawFinishReason") String rawFinishReason, - @JsonProperty(value = "reasoning", required = true) List reasoning, - @JsonProperty(value = "reasoningText") String reasoningText, - @JsonProperty(value = "request", required = true) RequestInfo request, - @JsonProperty(value = "response", required = true) StepResponse response, - @JsonProperty(value = "responseMessages", required = true) List responseMessages, - @JsonProperty(value = "sources", required = true) List sources, + @JsonProperty(value = "outputParsed") Boolean outputParsed, @JsonProperty(value = "steps", required = true) List steps, - @JsonProperty(value = "text", required = true) String text, - @JsonProperty(value = "toolCalls", required = true) List toolCalls, - @JsonProperty(value = "toolResults", required = true) List toolResults, - @JsonProperty(value = "totalUsage", required = true) LanguageModelUsage totalUsage, - @JsonProperty(value = "usage", required = true) LanguageModelUsage usage, - @JsonProperty(value = "warnings", required = true) List warnings) { - this.content = content == null ? null : Collections.unmodifiableList(new ArrayList<>(content)); - this.files = files == null ? null : Collections.unmodifiableList(new ArrayList<>(files)); - this.finishReason = finishReason; + @JsonProperty(value = "totalUsage", required = true) LanguageModelUsage totalUsage) { + if (steps == null || steps.isEmpty()) throw new IllegalArgumentException("GenerateTextResult requires at least one step"); + if (output != null && output.isPresent() && Boolean.FALSE.equals(outputParsed)) throw new IllegalArgumentException("GenerateTextResult cannot carry output when outputParsed is false"); this.output = output == null ? FieldPresence.absent() : output; - this.providerMetadata = providerMetadata == null ? null : Collections.unmodifiableMap(new LinkedHashMap<>(providerMetadata)); - this.rawFinishReason = rawFinishReason; - this.reasoning = reasoning == null ? null : Collections.unmodifiableList(new ArrayList<>(reasoning)); - this.reasoningText = reasoningText; - this.request = request; - this.response = response; - this.responseMessages = responseMessages == null ? null : Collections.unmodifiableList(new ArrayList<>(responseMessages)); - this.sources = sources == null ? null : Collections.unmodifiableList(new ArrayList<>(sources)); + this.outputParsed = outputParsed; this.steps = steps == null ? null : Collections.unmodifiableList(new ArrayList<>(steps)); - this.text = text; - this.toolCalls = toolCalls == null ? null : Collections.unmodifiableList(new ArrayList<>(toolCalls)); - this.toolResults = toolResults == null ? null : Collections.unmodifiableList(new ArrayList<>(toolResults)); this.totalUsage = totalUsage; - this.usage = usage; - this.warnings = warnings == null ? null : Collections.unmodifiableList(new ArrayList<>(warnings)); } public static Builder builder() { return new Builder(); } - public List getContent() { return content; } - public List getFiles() { return files; } - public FinishReasonUnified getFinishReason() { return finishReason; } - public JsonNode getOutput() { return output.getValue() == null ? null : output.getValue().deepCopy(); } - public boolean hasOutput() { return output.isPresent(); } - public Map> getProviderMetadata() { return providerMetadata; } - public String getRawFinishReason() { return rawFinishReason; } - public List getReasoning() { return reasoning; } - public String getReasoningText() { return reasoningText; } - public RequestInfo getRequest() { return request; } - public StepResponse getResponse() { return response; } - public List getResponseMessages() { return responseMessages; } - public List getSources() { return sources; } + public JsonNode getOutput() { return output.isPresent() ? (output.getValue() == null ? null : output.getValue().deepCopy()) : (Boolean.FALSE.equals(outputParsed) ? null : com.fasterxml.jackson.databind.node.TextNode.valueOf(getText())); } + public boolean hasOutput() { return output.isPresent() || !Boolean.FALSE.equals(outputParsed); } + public Boolean getOutputParsed() { return outputParsed; } public List getSteps() { return steps; } - public String getText() { return text; } - public List getToolCalls() { return toolCalls; } - public List getToolResults() { return toolResults; } public LanguageModelUsage getTotalUsage() { return totalUsage; } - public LanguageModelUsage getUsage() { return usage; } - public List getWarnings() { return warnings; } + + public StepResult getFinalStep() { return steps.get(steps.size() - 1); } + public String getText() { + return getFinalStep().getContent().stream().filter(ContentPart.Text.class::isInstance) + .map(ContentPart::getText).collect(java.util.stream.Collectors.joining()); + } + public List getContent() { + return steps.stream().flatMap(step -> step.getContent().stream()) + .collect(java.util.stream.Collectors.toList()); + } + public List getReasoning() { + List reasoning = new ArrayList<>(); + for (ContentPart part : getFinalStep().getContent()) { + if (part instanceof ContentPart.Reasoning) { + reasoning.add(new ReasoningPart.Reasoning(part.getProviderMetadata(), part.getText())); + } else if (part instanceof ContentPart.ReasoningFile) { + reasoning.add(new ReasoningPart.ReasoningFile(part.getFile(), part.getProviderMetadata())); + } + } + return reasoning; + } + public String getReasoningText() { + String text = getFinalStep().getContent().stream().filter(ContentPart.Reasoning.class::isInstance) + .map(ContentPart::getText).collect(java.util.stream.Collectors.joining()); + return text.isEmpty() ? null : text; + } + private java.util.stream.Stream parts(Class type) { + return steps.stream().flatMap(step -> step.getContent().stream()) + .filter(type::isInstance).map(type::cast); + } + public List getFiles() { + return parts(ContentPart.File.class).map(ContentPart::getFile) + .collect(java.util.stream.Collectors.toList()); + } + public List getSources() { + List sources = new ArrayList<>(); + parts(ContentPart.SourceUrlGroup.class).forEach(part -> { + if (part instanceof ContentPart.SourceUrl) { + ContentPart.SourceUrl url = (ContentPart.SourceUrl) part; + sources.add(new TypedSource.Url(url.getId(), url.getProviderMetadata(), url.getTitle(), + url.getType(), url.getUrl())); + } else if (part instanceof ContentPart.SourceDocument) { + ContentPart.SourceDocument doc = (ContentPart.SourceDocument) part; + sources.add(new TypedSource.Document(doc.getFilename(), doc.getId(), doc.getMediaType(), + doc.getProviderMetadata(), doc.getTitle(), doc.getType())); + } + }); + return sources; + } + public List getToolCalls() { + return parts(ContentPart.ToolCallVariant.class) + .map(part -> new TypedToolCall(part.getDynamic(), part.getError(), part.getInput(), part.getInvalid(), + part.getProviderExecuted(), part.getProviderMetadata(), part.getToolCallId(), part.getToolName(), + part.getType())) + .collect(java.util.stream.Collectors.toList()); + } + public List getStaticToolCalls() { + return getToolCalls().stream().filter(part -> !Boolean.TRUE.equals(part.getDynamic())) + .collect(java.util.stream.Collectors.toList()); + } + public List getDynamicToolCalls() { + return getToolCalls().stream().filter(part -> Boolean.TRUE.equals(part.getDynamic())) + .collect(java.util.stream.Collectors.toList()); + } + public List getToolResults() { + return parts(ContentPart.ToolResultVariant.class) + .map(part -> new TaggedToolResult(part.getDynamic(), part.getInput(), part.getOutput(), + part.getPreliminary(), part.getProviderExecuted(), part.getProviderMetadata(), part.getToolCallId(), + part.getToolName(), part.getType())) + .collect(java.util.stream.Collectors.toList()); + } + public List getStaticToolResults() { + return getToolResults().stream().filter(part -> !Boolean.TRUE.equals(part.getDynamic())) + .collect(java.util.stream.Collectors.toList()); + } + public List getDynamicToolResults() { + return getToolResults().stream().filter(part -> Boolean.TRUE.equals(part.getDynamic())) + .collect(java.util.stream.Collectors.toList()); + } + public FinishReasonUnified getFinishReason() { return getFinalStep().getFinishReason(); } + public String getRawFinishReason() { return getFinalStep().getRawFinishReason(); } + public LanguageModelUsage getUsage() { return totalUsage; } + public RequestInfo getRequest() { return getFinalStep().getRequest(); } + public StepResponse getResponse() { return getFinalStep().getResponse(); } + public Map> getProviderMetadata() { return getFinalStep().getProviderMetadata(); } + public List getWarnings() { + return steps.stream().flatMap(step -> step.getWarnings().stream()).collect(java.util.stream.Collectors.toList()); + } + public List getResponseMessages() { + return steps.stream().flatMap(step -> step.getResponse().getMessages().stream()) + .collect(java.util.stream.Collectors.toList()); + } public static final class Builder { - private List content; - private List files; - private FinishReasonUnified finishReason; private FieldPresence output = FieldPresence.absent(); - private Map> providerMetadata; - private String rawFinishReason; - private List reasoning; - private String reasoningText; - private RequestInfo request; - private StepResponse response; - private List responseMessages; - private List sources; + private Boolean outputParsed; private List steps; - private String text; - private List toolCalls; - private List toolResults; private LanguageModelUsage totalUsage; - private LanguageModelUsage usage; - private List warnings; - - public Builder content(List value) { - this.content = value; - return this; - } - - public Builder files(List value) { - this.files = value; - return this; - } - - public Builder finishReason(FinishReasonUnified value) { - this.finishReason = value; - return this; - } public Builder output(JsonNode value) { this.output = FieldPresence.of(value == null ? null : value.deepCopy()); @@ -202,43 +169,8 @@ public Builder omitOutput() { return this; } - public Builder providerMetadata(Map> value) { - this.providerMetadata = value; - return this; - } - - public Builder rawFinishReason(String value) { - this.rawFinishReason = value; - return this; - } - - public Builder reasoning(List value) { - this.reasoning = value; - return this; - } - - public Builder reasoningText(String value) { - this.reasoningText = value; - return this; - } - - public Builder request(RequestInfo value) { - this.request = value; - return this; - } - - public Builder response(StepResponse value) { - this.response = value; - return this; - } - - public Builder responseMessages(List value) { - this.responseMessages = value; - return this; - } - - public Builder sources(List value) { - this.sources = value; + public Builder outputParsed(Boolean value) { + this.outputParsed = value; return this; } @@ -247,36 +179,11 @@ public Builder steps(List value) { return this; } - public Builder text(String value) { - this.text = value; - return this; - } - - public Builder toolCalls(List value) { - this.toolCalls = value; - return this; - } - - public Builder toolResults(List value) { - this.toolResults = value; - return this; - } - public Builder totalUsage(LanguageModelUsage value) { this.totalUsage = value; return this; } - public Builder usage(LanguageModelUsage value) { - this.usage = value; - return this; - } - - public Builder warnings(List value) { - this.warnings = value; - return this; - } - - public GenerateTextResult build() { return new GenerateTextResult(content, files, finishReason, output, providerMetadata, rawFinishReason, reasoning, reasoningText, request, response, responseMessages, sources, steps, text, toolCalls, toolResults, totalUsage, usage, warnings); } + public GenerateTextResult build() { return new GenerateTextResult(output, outputParsed, steps, totalUsage); } } } diff --git a/bindings/java/generated/ai/arcships/aimux/types/GenerateTextResultInput.java b/bindings/java/generated/ai/arcships/aimux/types/GenerateTextResultInput.java index 5b2ad41fb..98b8a5e65 100644 --- a/bindings/java/generated/ai/arcships/aimux/types/GenerateTextResultInput.java +++ b/bindings/java/generated/ai/arcships/aimux/types/GenerateTextResultInput.java @@ -13,18 +13,28 @@ * * It stores the steps, the usage summed over them and the parsed output, as * `DefaultGenerateTextResult` does (`generate-text.ts:1691-1808`); every - * other value is derived from the steps by an accessor. The serialized form - * is a snapshot that writes the derived values next to the stored ones, so - * a binding reads `text`, `tool_calls`, `usage` and the rest directly. Only - * `steps`, `total_usage` and `output` are read back. + * other value is derived from the steps by an accessor. The wire form carries + * `steps`, `totalUsage`, optional `output` (when explicitly parsed), and + * optional `outputParsed: false` (when no output was generated). */ @JsonIgnoreProperties(ignoreUnknown = true) @JsonInclude(JsonInclude.Include.NON_NULL) @JsonAutoDetect(getterVisibility = JsonAutoDetect.Visibility.NONE, isGetterVisibility = JsonAutoDetect.Visibility.NONE) public final class GenerateTextResultInput { + /** + * An explicit parsed output, including JSON `null`. When absent and + * `outputParsed` is not `false`, bindings expose the final step's text. + */ @JsonProperty("output") @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = FieldPresence.Absent.class) private final FieldPresence output; + /** + * Present and `false` when no output was generated (for example, a final + * `tool-calls` step without an output spec). Omitted when an output was + * produced. + */ + @JsonProperty("outputParsed") + private final Boolean outputParsed; @JsonProperty("steps") private final List steps; @JsonProperty("totalUsage") @@ -33,9 +43,11 @@ public final class GenerateTextResultInput { @JsonCreator public GenerateTextResultInput( @JsonProperty(value = "output") FieldPresence output, + @JsonProperty(value = "outputParsed") Boolean outputParsed, @JsonProperty(value = "steps", required = true) List steps, @JsonProperty(value = "totalUsage", required = true) LanguageModelUsageInput totalUsage) { this.output = output == null ? FieldPresence.absent() : output; + this.outputParsed = outputParsed; this.steps = steps == null ? null : Collections.unmodifiableList(new ArrayList<>(steps)); this.totalUsage = totalUsage; } @@ -43,11 +55,13 @@ public GenerateTextResultInput( public static Builder builder() { return new Builder(); } public JsonNode getOutput() { return output.getValue() == null ? null : output.getValue().deepCopy(); } public boolean hasOutput() { return output.isPresent(); } + public Boolean getOutputParsed() { return outputParsed; } public List getSteps() { return steps; } public LanguageModelUsageInput getTotalUsage() { return totalUsage; } public static final class Builder { private FieldPresence output = FieldPresence.absent(); + private Boolean outputParsed; private List steps; private LanguageModelUsageInput totalUsage; @@ -61,6 +75,11 @@ public Builder omitOutput() { return this; } + public Builder outputParsed(Boolean value) { + this.outputParsed = value; + return this; + } + public Builder steps(List value) { this.steps = value; return this; @@ -71,6 +90,6 @@ public Builder totalUsage(LanguageModelUsageInput value) { return this; } - public GenerateTextResultInput build() { return new GenerateTextResultInput(output, steps, totalUsage); } + public GenerateTextResultInput build() { return new GenerateTextResultInput(output, outputParsed, steps, totalUsage); } } } diff --git a/bindings/java/generated/ai/arcships/aimux/types/IncludeOptions.java b/bindings/java/generated/ai/arcships/aimux/types/IncludeOptions.java new file mode 100644 index 000000000..3fbe8880c --- /dev/null +++ b/bindings/java/generated/ai/arcships/aimux/types/IncludeOptions.java @@ -0,0 +1,56 @@ +// Generated by aimux-codegen. Do not edit. +package ai.arcships.aimux.types; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.*; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.math.BigDecimal; +import java.util.*; + +/** + * Controls which raw body fields are exposed in generation results. + */ +@JsonIgnoreProperties(ignoreUnknown = false) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonAutoDetect(getterVisibility = JsonAutoDetect.Visibility.NONE, isGetterVisibility = JsonAutoDetect.Visibility.NONE) +public final class IncludeOptions { + /** + * Whether to return the request body. Defaults to false. + */ + @JsonProperty("requestBody") + private final Boolean requestBody; + /** + * Whether to return the response body. Defaults to false. + */ + @JsonProperty("responseBody") + private final Boolean responseBody; + + @JsonCreator + public IncludeOptions( + @JsonProperty(value = "requestBody") Boolean requestBody, + @JsonProperty(value = "responseBody") Boolean responseBody) { + this.requestBody = requestBody; + this.responseBody = responseBody; + } + + public static Builder builder() { return new Builder(); } + public Boolean getRequestBody() { return requestBody; } + public Boolean getResponseBody() { return responseBody; } + + public static final class Builder { + private Boolean requestBody; + private Boolean responseBody; + + public Builder requestBody(Boolean value) { + this.requestBody = value; + return this; + } + + public Builder responseBody(Boolean value) { + this.responseBody = value; + return this; + } + + public IncludeOptions build() { return new IncludeOptions(requestBody, responseBody); } + } +} diff --git a/bindings/java/generated/ai/arcships/aimux/types/Options.java b/bindings/java/generated/ai/arcships/aimux/types/Options.java index a1341a6da..fae2ace94 100644 --- a/bindings/java/generated/ai/arcships/aimux/types/Options.java +++ b/bindings/java/generated/ai/arcships/aimux/types/Options.java @@ -25,6 +25,11 @@ public final class Options { private final BigDecimal frequencyPenalty; @JsonProperty("headers") private final Map headers; + /** + * Controls the raw bodies exposed in the result. Both default to `false`. + */ + @JsonProperty("include") + private final IncludeOptions include; /** * Emit raw provider stream chunks as `StreamPart::Raw` (debugging aid). */ @@ -102,6 +107,7 @@ public final class Options { public Options( @JsonProperty(value = "frequencyPenalty") BigDecimal frequencyPenalty, @JsonProperty(value = "headers") Map headers, + @JsonProperty(value = "include") IncludeOptions include, @JsonProperty(value = "includeRawChunks") Boolean includeRawChunks, @JsonProperty(value = "instructions") String instructions, @JsonProperty(value = "maxOutputTokens") Long maxOutputTokens, @@ -122,6 +128,7 @@ public Options( @JsonProperty(value = "topP") BigDecimal topP) { this.frequencyPenalty = frequencyPenalty; this.headers = headers == null ? null : Collections.unmodifiableMap(new LinkedHashMap<>(headers)); + this.include = include; this.includeRawChunks = includeRawChunks; this.instructions = instructions; this.maxOutputTokens = maxOutputTokens; @@ -145,6 +152,7 @@ public Options( public static Builder builder() { return new Builder(); } public BigDecimal getFrequencyPenalty() { return frequencyPenalty; } public Map getHeaders() { return headers; } + public IncludeOptions getInclude() { return include; } public Boolean getIncludeRawChunks() { return includeRawChunks; } public String getInstructions() { return instructions; } public Long getMaxOutputTokens() { return maxOutputTokens; } @@ -167,6 +175,7 @@ public Options( public static final class Builder { private BigDecimal frequencyPenalty; private Map headers; + private IncludeOptions include; private Boolean includeRawChunks; private String instructions; private Long maxOutputTokens; @@ -196,6 +205,11 @@ public Builder headers(Map value) { return this; } + public Builder include(IncludeOptions value) { + this.include = value; + return this; + } + public Builder includeRawChunks(Boolean value) { this.includeRawChunks = value; return this; @@ -286,6 +300,6 @@ public Builder topP(BigDecimal value) { return this; } - public Options build() { return new Options(frequencyPenalty, headers, includeRawChunks, instructions, maxOutputTokens, maxRetries, output, presencePenalty, providerOptions, reasoning, seed, sessionId, stopSequences, strictStream, temperature, timeout, toolChoice, tools, topK, topP); } + public Options build() { return new Options(frequencyPenalty, headers, include, includeRawChunks, instructions, maxOutputTokens, maxRetries, output, presencePenalty, providerOptions, reasoning, seed, sessionId, stopSequences, strictStream, temperature, timeout, toolChoice, tools, topK, topP); } } } diff --git a/bindings/java/scripts/dto-vectors.py b/bindings/java/scripts/dto-vectors.py index 28f46ba63..3ff3ef4a8 100644 --- a/bindings/java/scripts/dto-vectors.py +++ b/bindings/java/scripts/dto-vectors.py @@ -7,7 +7,8 @@ import sys root = Path(__file__).resolve().parents[1] -cache = Path.home() / '.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core' +gradle_home = Path(os.environ.get('GRADLE_USER_HOME', Path.home() / '.gradle')) +cache = gradle_home / 'caches/modules-2/files-2.1/com.fasterxml.jackson.core' jars = [] for artifact in ('jackson-annotations', 'jackson-core', 'jackson-databind'): matches = sorted((cache / artifact / '2.17.2').glob('*/*.jar')) diff --git a/bindings/java/src/test/java/ai/arcships/aimux/MultimodalTypesTest.java b/bindings/java/src/test/java/ai/arcships/aimux/MultimodalTypesTest.java index b6d03ffa5..a635630ea 100644 --- a/bindings/java/src/test/java/ai/arcships/aimux/MultimodalTypesTest.java +++ b/bindings/java/src/test/java/ai/arcships/aimux/MultimodalTypesTest.java @@ -27,6 +27,34 @@ private static void assertSameJson(Object actual, Object expected) { assertThat(M.valueToTree(actual)).isEqualTo(M.valueToTree(expected)); } + @Test void generateTextResultRejectsEmptySteps() { + assertThatThrownBy(() -> M.readValue( + "{\"steps\":[],\"totalUsage\":{\"inputTokenDetails\":{},\"outputTokenDetails\":{}}}", + GenerateTextResult.class)) + .isInstanceOf(com.fasterxml.jackson.databind.JsonMappingException.class) + .hasRootCauseInstanceOf(IllegalArgumentException.class); + } + + @Test void generateTextResultOutputStates() throws Exception { + String base = "{\"steps\":[{\"callId\":\"c1\",\"stepNumber\":0,\"model\":{\"provider\":\"openai\",\"modelId\":\"gpt-4o\"},\"content\":[{\"type\":\"text\",\"text\":\"ok\"}],\"finishReason\":\"stop\",\"usage\":{\"inputTokenDetails\":{},\"outputTokenDetails\":{}},\"performance\":{\"effectiveOutputTokensPerSecond\":0.0,\"effectiveTotalTokensPerSecond\":0.0,\"responseTimeMs\":0.0,\"stepTimeMs\":0.0,\"toolExecutionMs\":{}},\"warnings\":[],\"request\":{},\"response\":{\"id\":\"r1\",\"timestamp\":\"2026-01-01T00:00:00Z\",\"modelId\":\"gpt-4o\",\"messages\":[]}}],\"totalUsage\":{\"inputTokenDetails\":{},\"outputTokenDetails\":{}}"; + GenerateTextResult plain = roundTrip(base + "}", GenerateTextResult.class); + assertThat(plain.hasOutput()).isTrue(); + assertThat(plain.getOutput().asText()).isEqualTo("ok"); + + GenerateTextResult parsedNull = roundTrip(base + ",\"output\":null}", GenerateTextResult.class); + assertThat(parsedNull.hasOutput()).isTrue(); + assertThat(parsedNull.getOutput()).isNull(); + + GenerateTextResult notParsed = roundTrip(base + ",\"outputParsed\":false}", GenerateTextResult.class); + assertThat(notParsed.hasOutput()).isFalse(); + assertThat(notParsed.getOutput()).isNull(); + assertThat(notParsed.getOutputParsed()).isFalse(); + + assertThatThrownBy(() -> M.readValue(base + ",\"output\":null,\"outputParsed\":false}", GenerateTextResult.class)) + .isInstanceOf(com.fasterxml.jackson.databind.JsonMappingException.class) + .hasRootCauseInstanceOf(IllegalArgumentException.class); + } + @Test void embeddingResultRoundTrip() throws Exception { EmbeddingResult result = roundTrip("{\"embeddings\":[[0.1,0.2,0.3],[0.4,0.5,0.6]],\"usage\":{\"tokens\":5},\"warnings\":[]}", EmbeddingResult.class); assertThat(result.getEmbeddings()).hasSize(2); diff --git a/bindings/java/src/test/native/abi_fixture.c b/bindings/java/src/test/native/abi_fixture.c index b297aa591..040812cfd 100644 --- a/bindings/java/src/test/native/abi_fixture.c +++ b/bindings/java/src/test/native/abi_fixture.c @@ -81,7 +81,7 @@ aimux_error_t *aimux_call(uint64_t handle, const char *op, const char *params, } else if (!strcmp(op, "test.protocol")) { return failure(300, "{\"kind\":\"protocol\",\"code\":300,\"message\":\"unknown op\",\"error\":{\"name\":\"InvalidOp\"}}"); } else if (!strcmp(op, AIMUX_OP_TEXT_GENERATE) || !strcmp(op, AIMUX_OP_TEXT_CONSUME)) { - *out = owned("{\"text\":\"你好 🌏\",\"content\":[],\"files\":[],\"finishReason\":\"stop\",\"reasoning\":[],\"request\":{},\"response\":{\"id\":\"fixture\",\"timestamp\":\"2025-01-01T00:00:00Z\",\"modelId\":\"fixture\",\"messages\":[]},\"responseMessages\":[],\"sources\":[],\"steps\":[],\"toolCalls\":[],\"toolResults\":[],\"totalUsage\":{\"inputTokenDetails\":{},\"outputTokenDetails\":{}},\"usage\":{\"inputTokenDetails\":{},\"outputTokenDetails\":{}},\"warnings\":[]}"); + *out = owned("{\"steps\":[{\"callId\":\"fixture\",\"stepNumber\":0,\"model\":{\"provider\":\"fixture\",\"modelId\":\"fixture\"},\"content\":[{\"type\":\"text\",\"text\":\"你好 🌏\"}],\"finishReason\":\"stop\",\"usage\":{\"inputTokenDetails\":{},\"outputTokenDetails\":{}},\"performance\":{\"effectiveOutputTokensPerSecond\":0,\"effectiveTotalTokensPerSecond\":0,\"responseTimeMs\":0,\"stepTimeMs\":0,\"toolExecutionMs\":{}},\"request\":{},\"response\":{\"id\":\"fixture\",\"timestamp\":\"2025-01-01T00:00:00Z\",\"modelId\":\"fixture\",\"messages\":[]},\"warnings\":[]}],\"totalUsage\":{\"inputTokenDetails\":{},\"outputTokenDetails\":{}}}"); } else { *out = owned(params); } diff --git a/bindings/kotlin/generated/AimuxOps.kt b/bindings/kotlin/generated/AimuxOps.kt index ea67af67b..5e537d6f3 100644 --- a/bindings/kotlin/generated/AimuxOps.kt +++ b/bindings/kotlin/generated/AimuxOps.kt @@ -1,10 +1,10 @@ -// Generated by aimux-codegen. Do not edit. Manifest SHA-256: cd147fa9595ede3951744fa261da98cc18c204e65b4081073ad3a3c1b68bfd92 +// Generated by aimux-codegen. Do not edit. Manifest SHA-256: 6914772fdc03df08cba497def41cb354fe52e40eba49844a66938b4cd38c5d83 package ai.arcships.aimux.generated object AimuxKotlinOps { const val ABI_VERSION: Long = 65536 const val OPS_VERSION = "1.0" - const val MANIFEST_DIGEST = "cd147fa9595ede3951744fa261da98cc18c204e65b4081073ad3a3c1b68bfd92" + const val MANIFEST_DIGEST = "6914772fdc03df08cba497def41cb354fe52e40eba49844a66938b4cd38c5d83" const val OP_ABORT_CREATE = "abort.create" const val OP_ABORT_SIGNAL = "abort.signal" const val OP_AUTH_CODEX_REFRESH = "auth.codexRefresh" @@ -95,7 +95,7 @@ object AimuxKotlinOps { "aimux_core::embedding_model::EmbeddingResult" to "af3ce0787db6208be114613c78dc02f038cb5dc2f7abcf6a4ade2be79085342e", "aimux_core::files_model::UploadFileResult" to "0d17fd3dbfa601e45c9fabf62f9bb1e5028591443eafccd4eecacef0dcda0368", "aimux_core::generate::GenerateObjectResult" to "21cca82de06d366b0f47d781bd49141bb63215accdd1133bb360113a60b7cc00", - "aimux_core::generate::GenerateTextResult" to "c5c6016de2c926c85144959d9436c9d2214a27a9724e75d68393e933ef7263f5", + "aimux_core::generate::GenerateTextResult" to "c75d0e0c2d207f9dfeffe7eb42efb9040d93a8062cdc678054f9bbcb8049e041", "aimux_core::image_model::ImageCallOptions" to "ddacb8970cef4590bcdcc572ced361b181d501d3b474a2d6c50a9c0c02af3eb2", "aimux_core::image_model::ImageResult" to "a9d2d939f3dc153a5b5ebc8083bea1226ff63ff2e54e4e275c9ab2b136b9e880", "aimux_core::openai_output::ChatCompletion" to "503195cbe7fe458d9403a9de20b93bd17c20bbee0de40a8088bf3847ee835ad9", @@ -103,6 +103,9 @@ object AimuxKotlinOps { "aimux_core::recording::Recording" to "56fa358fb2023da68837722ed573e00fc997506403d7c7aa516c586c45b4fd54", "aimux_core::reranking_model::RerankingCallOptions" to "c481b6e7c4d5e71ea7db00166ab2952c8a893443f786a61374c7398b4e475e4c", "aimux_core::reranking_model::RerankingResult" to "d757826963b3ce836e4d76fca8f42455a3a3146c20f3fb74f58cabe465348d01", + "aimux_core::result::ReasoningPart" to "6210a367b8c084e55a60e0ead74a7ff233b7f357020a028c6879b54ffa8b9b87", + "aimux_core::result::TaggedToolResult" to "a8f688a021397c1159b88546156d5a418e50d6482d39f88c46476297d208e069", + "aimux_core::result::TypedSource" to "0a36b617c3f1bbcd82e4d09c329ad41aba62330b4d0e950125fd62b2053a9368", "aimux_core::search_model::SearchCallOptions" to "3b963a871e6f1858db03b68adc74c5f898d4a2c3c0506e4e359b8d8198d30b22", "aimux_core::search_model::SearchResult" to "61075439fcb4276085a11113195dd13220b710cc0c2199ceefa4ec3d07d0195f", "aimux_core::speech_model::SpeechCallOptions" to "418be167c89bca652fb0a9dd52a1da359c1ecc2b069b9d2a0859ab76a7f7f431", @@ -130,10 +133,10 @@ object AimuxKotlinOps { "aimux_ops::ops::handles::TransportParams" to "86e40584fcc21dab8f0017f8e892b776ac24aaa9afc943ba805828cecc6e1a4c", "aimux_ops::ops::misc::CatalogueFetchRequest" to "2ceed496996ec6cf32d3e3115ab6a4346a1bb201dc8a970eefbd46eb700a310e", "aimux_ops::ops::misc::CodexRefreshRequest" to "59f1075ed68cb79896d4bac1d0ab32d21fb5855012c6336652bea0c4969ac926", - "aimux_ops::ops::misc::OpenAiOutputRequest" to "b0c6acc344f0b23b9ea3b693aeadf7aed7eb4fbdfce4b957be83af1154b842b4", - "aimux_ops::ops::misc::ToolRepairApplyRequest" to "0f430fdb223759ef7c48c4d7f824e7be74d29295a6b4f7caaf82b5acba25e538", - "aimux_ops::ops::misc::ToolRepairApplyResultRequest" to "fa092862004654e065233b2df2abdbec3befe88d9d734d494679968a5b6e954a", - "aimux_ops::ops::misc::ToolRepairContextRequest" to "81bae04c56aac3380b75de639d162f819a2dd5717147a53cf1a75281727d78a1", + "aimux_ops::ops::misc::OpenAiOutputRequest" to "d30e30aa75703e1404a202d437e69a6873fd2b515c5ed322ab488363be8d2fb0", + "aimux_ops::ops::misc::ToolRepairApplyRequest" to "c1c5f81107f334a94583a4ff4ed394097580bea2f2a66266c11890fe2a3ab3d0", + "aimux_ops::ops::misc::ToolRepairApplyResultRequest" to "649f2b4ff1a2dd0d552e2930b694d7efa3346b2f15a9fb0f14cffd4b6955b508", + "aimux_ops::ops::misc::ToolRepairContextRequest" to "fa4802ac20a2b1b540cb727d798ad2a4c44cad6a8f9ad45281fc91ebb065e65f", "aimux_ops::ops::misc::ToolRepairContextResult" to "fd8173e6ec40724fa4207e3571e290ac12e4db1fed08a709273e2982a82b504f", "aimux_ops::ops::operation::EmptyParams" to "1612408252a424283a43a92193bb8ea24f72c08b9f0d2117b4ef7f5a090e37f8", "aimux_ops::ops::operation::OperationNextParams" to "127fea618826e51576ae488dcccaca03c04b774a847a33ec9c47565396862bb7", @@ -167,7 +170,7 @@ object AimuxKotlinOps { "aimux_ops::ops::replay::ReplayCreateParams" to "ee64b5b5843103f76ca2166aed2f58995e472be93cb7bb18dea8238c8a2d9e44", "aimux_ops::ops::replay::ReplayInspection" to "7ac2af62f3421f8c7c50867a838f0aff90f35b6a4f192f6c0d5347ab4699108c", "aimux_ops::ops::replay::ReplayLiveParams" to "e99c7d51fb194def185f5a03d84bfc226eb1b101eade0b885216332605318a4d", - "aimux_ops::ops::replay::ReplayLiveResult" to "bd9959dd7e0300cb57e6929b2ed29b7e07dcb5aaf65be16b96e34bf8d6577a7f", + "aimux_ops::ops::replay::ReplayLiveResult" to "9163acd59ee54db1db2213c0756283b8b27e04a52451dfeef314d63efebbc730", "aimux_ops::ops::replay::ReplayPlan" to "5cc6667b9fac6de173bf5b55c1a76a491255f89f0fa7a27c0fd33fd790259799", "aimux_ops::ops::replay::ReplaySessionHandle" to "5e779b71ce2a54e59948c605cdfc48797d0760027ad5f44966df958fe9781d11", "aimux_ops::ops::runtime::RuntimeConfigureParams" to "e3b24b9f1fbdf2be7da210f15060803cf8bfdef77c8b2ad330a5b501263dfb0f", @@ -175,8 +178,8 @@ object AimuxKotlinOps { "aimux_ops::ops::session::SessionStoreCallsParams" to "ddd482204fdd305bbfd28d43ae829d8c286f3f8906302ca6679743ea680fedda", "aimux_ops::ops::session::SessionStoreCreateParams" to "080d865c349ec86553f72b99ab1c65ddbb72d0c348a96dc17135a934d787cd86", "aimux_ops::ops::session::SessionStoreHandle" to "755d437d47d362474942fc4a09f5f8c80b75cf362ac16b25b262e33a760b4c6a", - "aimux_ops::ops::text::OpenAiTextRequest" to "59293b18b6124a9a394113b8f94f637c65dc35ac44a30f7e0df70855e885f8e4", - "aimux_ops::ops::text::TextRequest" to "3a6f59c1f0c3b7ded5f5509d93afe9bddd2b80a8a3cd752d79f97edadae40c3d", + "aimux_ops::ops::text::OpenAiTextRequest" to "d5afbf2b24ab74b82433d344afb190c18f8aef52988c54ab8b5388579c212f67", + "aimux_ops::ops::text::TextRequest" to "eb0c25fcbf741834943882d7f901af7439ba30923a391b273526d1887ed156ab", "aimux_ops::ops::trace::TraceAggregateParams" to "1b207f0bbe1b7ce7e9b8b0beb9334cf3cc4f9f05382911aaacfe0425dc8ff2c8", "aimux_ops::ops::trace::TraceCreateParams" to "59fef52f382800570e861ae9ca92433dcae8807679d914a89ce99705713301d9", "aimux_ops::ops::trace::TraceSessionParams" to "3e2300f6c65f6dcd52a016eba648a29abeff3a9d67c3b04a95617aa66832f810", diff --git a/bindings/node/__test__/contract.native.ts b/bindings/node/__test__/contract.native.ts index 064e921eb..edfeab543 100644 --- a/bindings/node/__test__/contract.native.ts +++ b/bindings/node/__test__/contract.native.ts @@ -135,3 +135,136 @@ test('accepted native streams preserve one terminal and support return during ne assert.equal((await pending).done, true) } finally { await Promise.all([model.close(), provider.close()]) } }) + +test('omitted bodies stay available to trace and recording', async (t) => { + const { Client } = await import('../src/index.ts') + const { createServer } = await import('node:http') + const { once } = await import('node:events') + const requests: string[] = [] + const server = createServer(async (req, res) => { + const chunks: Buffer[] = [] + for await (const chunk of req) chunks.push(chunk) + const body = Buffer.concat(chunks).toString() + requests.push(body) + if (JSON.parse(body).stream === true) { + res.writeHead(200, { 'content-type': 'text/event-stream' }) + res.end('data: ' + JSON.stringify({ + id: 'local', model: 'test-model', + choices: [{ delta: { content: 'ok' }, finish_reason: 'stop' }], + }) + '\n\ndata: [DONE]\n\n') + return + } + res.writeHead(200, { 'content-type': 'application/json' }) + res.end(JSON.stringify({ + id: 'local', model: 'test-model', + choices: [{ message: { role: 'assistant', content: 'ok' }, finish_reason: 'stop' }], + usage: { prompt_tokens: 1, completion_tokens: 1, total_tokens: 2 }, + })) + }) + server.listen(0, '127.0.0.1') + await once(server, 'listening') + t.after(() => { server.close(); server.closeAllConnections() }) + const address = server.address() + assert.ok(address && typeof address === 'object') + + const client = new Client() + const provider = await client.provider({ + package: 'deepseek', + settings: { apiKey: 'local-test-key', baseUrl: `http://127.0.0.1:${address.port}` }, + }) + const model = await provider.model('test-model', 'languageModel') + const trace = await client.trace({ capacity: 16 }) + const middleware = await client.middleware({ kind: 'trace', traceStore: trace.handle }) + const wrapped = await model.wrap([middleware]) + const recorder = await client.recorder({ backend: { type: 'ring', capacity: 16 }, capturePolicy: 'full' }) + try { + await recorder.attach() + const prompt = 'x'.repeat(1024) + const compact = await wrapped.generate(prompt) + assert.equal(compact.text, 'ok') + assert.equal(compact.output, 'ok') + assert.equal(Object.hasOwn(compact.request, 'body'), false) + assert.equal(Object.hasOwn(compact.response, 'body'), false) + assert.deepEqual(Object.keys(JSON.parse(JSON.stringify(compact))).sort(), ['steps', 'totalUsage']) + + const full = await wrapped.generate(prompt, { include: { requestBody: true, responseBody: true } }) + assert.deepEqual(full.request.body, JSON.parse(requests[1]!)) + assert.equal((full.response.body as { id: string }).id, 'local') + + const streamed = await wrapped.consume({ prompt }) + assert.equal(streamed.text, 'ok') + assert.equal(streamed.output, 'ok') + assert.equal(Object.hasOwn(streamed.request, 'body'), false) + assert.deepEqual(Object.keys(JSON.parse(JSON.stringify(streamed))).sort(), ['steps', 'totalUsage']) + const completion = await client.call(wrapped.handle, ops.OP_OUTPUT_TO_OPEN_AI, { + result: compact, metadataNamespace: 'deepseek', + }) as { choices: Array<{ message: { content: string } }> } + assert.equal(completion.choices[0]?.message.content, 'ok') + + const traceJsonl = await trace.export() as string + const records = traceJsonl.trim().split('\n').map(line => JSON.parse(line)) + assert.equal(records.length, 3) + const fingerprints = [compact, full, streamed].map(result => + records.find(record => record.callId === result.finalStep.callId).fingerprint) + assert.ok(fingerprints.every(fingerprint => fingerprint.lenBytes > 1024)) + assert.equal(fingerprints[0].bodyHash, fingerprints[1].bodyHash) + + await recorder.flush() + const { jsonl } = await recorder.export() as { jsonl: string } + const recordings = jsonl.trim().split('\n').map(line => JSON.parse(line)) + assert.equal(recordings.length, 3) + for (const [result, request] of [[compact, requests[0]], [streamed, requests[2]]] as const) { + assert.equal(recordings.find(record => record.callId === result.finalStep.callId) + .exchanges[0].request.body, request) + } + } finally { + await recorder.stop() + for (const resource of [recorder, wrapped, middleware, trace, model, provider]) resource.close() + } +}) + +test('unparsed tool-call generation sets outputParsed=false and exposes undefined output', async (t) => { + const { Client } = await import('../src/index.ts') + const { createServer } = await import('node:http') + const { once } = await import('node:events') + const server = createServer((_req, res) => { + res.writeHead(200, { 'content-type': 'application/json' }) + res.end(JSON.stringify({ + id: 'local-tool', model: 'test-model', + choices: [{ + message: { + role: 'assistant', + content: 'Calling tool', + tool_calls: [{ id: 'call_1', type: 'function', function: { name: 'ping', arguments: '{}' } }], + }, + finish_reason: 'tool_calls', + }], + usage: { prompt_tokens: 1, completion_tokens: 1, total_tokens: 2 }, + })) + }) + server.listen(0, '127.0.0.1') + await once(server, 'listening') + t.after(() => { server.close(); server.closeAllConnections() }) + const address = server.address() + assert.ok(address && typeof address === 'object') + + const client = new Client() + const provider = await client.provider({ + package: 'deepseek', + settings: { apiKey: 'local-test-key', baseUrl: `http://127.0.0.1:${address.port}` }, + }) + const model = await provider.model('test-model', 'languageModel') + try { + const result = await model.generate('call ping', { + tools: [{ type: 'function', name: 'ping', inputSchema: { type: 'object', properties: {} } }], + }) + assert.equal(result.finishReason, 'tool-calls') + assert.equal(result.text, 'Calling tool') + assert.equal(result.outputParsed, false) + assert.equal(result.output, undefined) + assert.equal(Object.hasOwn(result, 'output'), false) + assert.deepEqual(Object.keys(JSON.parse(JSON.stringify(result))).sort(), ['outputParsed', 'steps', 'totalUsage']) + } finally { + await Promise.all([model.close(), provider.close()]) + } +}) diff --git a/bindings/node/__test__/dto.test.ts b/bindings/node/__test__/dto.test.ts index a6590a1c3..6a9f89acc 100644 --- a/bindings/node/__test__/dto.test.ts +++ b/bindings/node/__test__/dto.test.ts @@ -39,3 +39,86 @@ test('DTO vectors reject strict unknown keys, bad enums, non-objects, and invali assert.equal(roundTrip('HandleId', '"0001"'), '0001') assert.deepEqual(roundTrip('BackendConfig', '{"type":"ring","capacity":1}'), { type: 'ring', capacity: 1 }) }) + +test('GenerateTextResult getters derive ordered values without expanding JSON', async () => { + const { readFileSync } = await import('node:fs') + const { attachGenerateTextResult } = await import('../src/generated/text_result.ts') + const fixture = JSON.parse(readFileSync(new URL( + '../../../contract-tests/dto/GenerateTextResult/001.json', import.meta.url), 'utf8')) + assert.throws(() => attachGenerateTextResult({ ...fixture, steps: [] }), TypeError) + const first = fixture.steps[0] + const toolCall = (toolCallId: string, dynamic?: boolean) => + ({ type: 'tool-call', toolCallId, toolName: 'tool', input: {}, ...(dynamic === undefined ? {} : { dynamic }) }) + const toolResult = (toolCallId: string, dynamic?: boolean) => + ({ type: 'tool-result', toolCallId, toolName: 'tool', output: null, ...(dynamic === undefined ? {} : { dynamic }) }) + const file = { base64: 'aGk=', mediaType: 'text/plain' } + const source = { type: 'source', sourceType: 'url', id: 'source', url: 'https://example.com' } + const earlyWarning = { type: 'other', message: 'first' } + const finalWarning = { type: 'other', message: 'second' } + first.content.push({ type: 'reasoning', text: 'ignored' }, source, toolCall('a'), toolResult('a', false)) + first.warnings = [earlyWarning] + const last = { + ...first, + stepNumber: 1, + finishReason: 'length', + rawFinishReason: 'max_tokens', + content: [ + { type: 'text', text: 'Final ' }, + { type: 'reasoning', text: 'think ' }, + { type: 'reasoning-file', file }, + { type: 'reasoning', text: 'more' }, + { type: 'text', text: 'answer' }, + { type: 'file', file }, + toolCall('b', true), toolResult('b', true), toolCall('c', false), toolResult('c'), + { type: 'tool-error', toolCallId: 'd', toolName: 'tool', error: 'error' }, + ], + warnings: [finalWarning], + request: { body: { prompt: 'final' } }, + response: { ...first.response, messages: [{ role: 'assistant', content: 'Final answer' }] }, + providerMetadata: { last: { key: 1 } }, + } + fixture.steps.push(last) + const wire = JSON.stringify(fixture) + const result = attachGenerateTextResult(fixture) + assert.equal(result.finalStep, last) + assert.equal(result.text, 'Final answer') + assert.equal(result.output, result.text) + assert.deepEqual(result.content, [...first.content, ...last.content]) + assert.deepEqual(result.reasoning, last.content.slice(1, 4)) + assert.equal(result.reasoningText, 'think more') + assert.deepEqual(result.files, [file]) + assert.deepEqual(result.sources, [source]) + assert.deepEqual(result.toolCalls.map(part => part.toolCallId), ['a', 'b', 'c']) + assert.deepEqual(result.staticToolCalls.map(part => part.toolCallId), ['a', 'c']) + assert.deepEqual(result.dynamicToolCalls.map(part => part.toolCallId), ['b']) + assert.deepEqual(result.toolResults.map(part => part.toolCallId), ['a', 'b', 'c']) + assert.deepEqual(result.staticToolResults.map(part => part.toolCallId), ['a', 'c']) + assert.deepEqual(result.dynamicToolResults.map(part => part.toolCallId), ['b']) + assert.equal(result.finishReason, 'length') + assert.equal(result.rawFinishReason, 'max_tokens') + assert.equal(result.request, last.request) + assert.equal(result.response, last.response) + assert.equal(result.providerMetadata, last.providerMetadata) + assert.equal(result.usage, fixture.totalUsage) + assert.deepEqual(result.warnings, [earlyWarning, finalWarning]) + assert.deepEqual(result.responseMessages, [...first.response.messages, ...last.response.messages]) + assert.equal(JSON.stringify(result), wire) + assert.deepEqual({ ...result }, fixture) + assert.deepEqual(structuredClone(result), JSON.parse(wire)) + assert.deepEqual(Object.keys(result).sort(), ['steps', 'totalUsage']) + + const explicitNull = { ...JSON.parse(wire), output: null } + const explicitWire = JSON.stringify(explicitNull) + assert.equal(attachGenerateTextResult(explicitNull).output, null) + assert.equal(JSON.stringify(explicitNull), explicitWire) + + const notParsed = { ...JSON.parse(wire), outputParsed: false } + const notParsedWire = JSON.stringify(notParsed) + const unparsedResult = attachGenerateTextResult(notParsed) + assert.equal(unparsedResult.output, undefined) + assert.equal(Object.hasOwn(unparsedResult, 'output'), false) + assert.equal(unparsedResult.outputParsed, false) + assert.equal(JSON.stringify(unparsedResult), notParsedWire) + + assert.throws(() => attachGenerateTextResult({ ...JSON.parse(wire), output: null, outputParsed: false }), TypeError) +}) diff --git a/bindings/node/__test__/event_loop.spec.ts b/bindings/node/__test__/event_loop.spec.ts index b966d7e61..a90848796 100644 --- a/bindings/node/__test__/event_loop.spec.ts +++ b/bindings/node/__test__/event_loop.spec.ts @@ -169,7 +169,7 @@ test('event loop: timers advance with bounded drift during a native call', async try { const result = await bounded(api.call(model), 'generate call') gaps.push(performance.now() - previous) - assert.equal(result.text, 'ok') + assert.equal(result.steps[0].content[0].text, 'ok') assert.ok(gaps.length >= 15, `Only ${gaps.length} timer samples during the delayed call`) assert.ok(Math.max(...gaps) < 250, `Maximum timer gap: ${Math.max(...gaps)}ms`) } finally { diff --git a/bindings/node/__test__/facade.test.ts b/bindings/node/__test__/facade.test.ts index dd813f4aa..bfe627ddd 100644 --- a/bindings/node/__test__/facade.test.ts +++ b/bindings/node/__test__/facade.test.ts @@ -24,13 +24,33 @@ test('raw and typed preserve the same DTO, null, nested provider options and 64- const params = { prompt: '你好 🚀', options: { providerOptions: { openai: { nested: [null, { enabled: true }] } }, toolChoice: 'required' as const } } const raw = JSON.parse(await client.raw.call(model.handle, ops.OP_TEXT_GENERATE, JSON.stringify(params))) const typed = await (model as InstanceType).generate(params.prompt, params.options) - assert.deepEqual(typed, raw) + assert.equal(typed.text, params.prompt) + assert.deepEqual(typed.request.body, { nested: params.options, raw: null }) + assert.deepEqual(JSON.parse(JSON.stringify(typed)), raw) const embedding = await provider.model('embed', 'embeddingModel') assert.ok(embedding instanceof EmbeddingModel) await (embedding as InstanceType).embedMany({ values: ['one', 'two', '三'] }) await Promise.all([model.close(), embedding.close(), provider.close()]) }) +test('language replay results stay compact when nested in a repair request', async () => { + const client = new Client() + const replay = await client.replay({}) + const recorded = require('../../../contract-tests/dto/GenerateTextResult/001.json') + try { + const replayed = await replay.live({ recorded }) + assert.ok('steps' in replayed) + assert.equal(replayed.text, recorded.steps[0].content[0].text) + assert.deepEqual(JSON.parse(JSON.stringify(replayed)), recorded) + + const repaired = await client.call('0', ops.OP_TOOL_REPAIR_APPLY_RESULT, { result: replayed }) + assert.equal(repaired.text, replayed.text) + assert.deepEqual(JSON.parse(JSON.stringify(repaired)), recorded) + } finally { + await replay.close() + } +}) + test('error properties and prototype match for both layers, including response headers', async () => { const client = new Client() for (const call of [() => client.raw.call('0', 'fixture.error', '{}'), () => client.call('0', 'fixture.error')]) { diff --git a/bindings/node/__test__/fixtures/native.cjs b/bindings/node/__test__/fixtures/native.cjs index a39f0c43a..c6174513e 100644 --- a/bindings/node/__test__/fixtures/native.cjs +++ b/bindings/node/__test__/fixtures/native.cjs @@ -40,7 +40,14 @@ class Runtime { case ops.OP_REPLAY_CREATE: return JSON.stringify({ handle: this.create('ReplaySession').handle }) case ops.OP_MIDDLEWARE_CREATE: return JSON.stringify(this.create('Middleware')) case ops.OP_TRANSCRIPTION_START: return JSON.stringify(this.create('Operation').handle) - case ops.OP_TEXT_GENERATE: return JSON.stringify({ text: params.prompt, nested: params.options, raw: null }) + case ops.OP_TEXT_GENERATE: { + const facts = structuredClone(require('../../../../contract-tests/dto/GenerateTextResult/001.json')) + facts.steps[0].content[0].text = params.prompt + facts.steps[0].request.body = { nested: params.options, raw: null } + return JSON.stringify(facts) + } + case ops.OP_REPLAY_LIVE: return JSON.stringify(params.recorded) + case ops.OP_TOOL_REPAIR_APPLY_RESULT: return JSON.stringify(params.result) case ops.OP_OPERATION_NEXT: return JSON.stringify({ type: 'ended' }) case 'fixture.cause': throw envelope('aimux', 11, 'AI_APICallError', 'Cannot connect to API: error sending request', { cause: { message: 'error sending request', cause: { message: 'Connection refused (os error 111)' } } }) case 'fixture.error': throw Object.assign(envelope('aimux', 1, 'AI_APICallError', 'rate limit', { statusCode: 429, isRetryable: true, responseHeaders: { 'retry-after': '0' }, data: { unicode: '你好' } })) diff --git a/bindings/node/bench/README.md b/bindings/node/bench/README.md index 68e6216c5..f3793352f 100644 --- a/bindings/node/bench/README.md +++ b/bindings/node/bench/README.md @@ -37,6 +37,12 @@ a size with variable step timing removed. On a build with the `include` option, `request-200k-no-bodies` also checks the body fields are absent and enforces the 360,000-byte phase 1 budget. +For Stage 2, set `AIMUX_STAGE2_GATE=1` on the candidate commands. The default +`request-200k` must return only `steps` and `totalUsage` in at most 110,000 +wire bytes, with both bodies absent. With `TOKIO_WORKER_THREADS=2`, +`stream-burst` must reach 150,000 frames per second. The reported frame rate +counts every validated frame across the timed batch. + For direct Rust, copy the same example source to both revisions, build once per revision, and keep each resulting executable separately: diff --git a/bindings/node/src/generated/dto_vectors.ts b/bindings/node/src/generated/dto_vectors.ts index 0d07e2adc..4ba0ffd9d 100644 --- a/bindings/node/src/generated/dto_vectors.ts +++ b/bindings/node/src/generated/dto_vectors.ts @@ -90,6 +90,7 @@ export interface DtoTypes { "ImageResponse": T.ImageResponse "ImageResult": T.ImageResult "ImageUsage": T.ImageUsage + "IncludeOptions": T.IncludeOptions "InputAudioFormat": T.InputAudioFormat "InputRecord": T.InputRecord "InputTokenDetails": T.InputTokenDetails @@ -458,6 +459,7 @@ export const dtoTypeNames = [ "ImageResponse", "ImageResult", "ImageUsage", + "IncludeOptions", "InputAudioFormat", "InputRecord", "InputTokenDetails", @@ -690,7 +692,7 @@ export const dtoTypeNames = [ "Warning", ] as const satisfies readonly (keyof DtoTypes)[] -const dtoSchemas: Record = {"AiMuxError":{"k":"t","g":"name","v":[{"tv":"AI_APICallError","c":false,"f":{"cause":[false,["n",["r","ErrorCause"]]],"data":[false,"j"],"isRetryable":[true,"b"],"message":[true,"s"],"origin":[false,["r","ApiCallErrorOrigin"]],"providerCode":[false,["n","s"]],"requestBodyValues":[true,"j"],"responseBody":[false,["n","s"]],"responseHeaders":[false,["n",["m","s"]]],"statusCode":[false,["n",["i",true,16]]],"url":[true,"s"]}},{"tv":"AI_RetryError","c":false,"f":{"errors":[true,["a",["r","AiMuxError"]]],"reason":[true,["r","RetryErrorReason"]]}},{"tv":"AI_JSONParseError","c":false,"f":{"cause":[false,["n",["r","ErrorCause"]]],"message":[true,"s"]}},{"tv":"AI_NoOutputGeneratedError","c":false,"f":{"cause":[false,["n",["r","ErrorCause"]]],"message":[true,"s"]}},{"tv":"AI_InvalidResponseDataError","c":false,"f":{"cause":[false,["n",["r","ErrorCause"]]],"message":[true,"s"]}},{"tv":"AI_TypeValidationError","c":false,"f":{"cause":[false,["n",["r","ErrorCause"]]],"message":[true,"s"],"value":[true,"j"]}},{"tv":"AI_ToolCallNotFoundForApprovalError","c":false,"f":{"approvalId":[true,"s"],"toolCallId":[true,"s"]}},{"tv":"AI_NoSuchToolError","c":false,"f":{"availableTools":[false,["n",["a","s"]]],"toolInput":[false,["n","s"]],"toolName":[true,"s"]}},{"tv":"AI_InvalidToolInputError","c":false,"f":{"cause":[true,["r","ErrorCause"]],"toolInput":[true,"s"],"toolName":[true,"s"]}},{"tv":"AI_ToolCallRepairError","c":false,"f":{"cause":[true,["r","AiMuxError"]],"originalError":[true,["r","AiMuxError"]]}},{"tv":"AI_InvalidArgumentError","c":false,"f":{"cause":[false,["n",["r","ErrorCause"]]],"message":[true,"s"]}},{"tv":"AI_InvalidPromptError","c":false,"f":{"cause":[false,["n",["r","ErrorCause"]]],"message":[true,"s"]}},{"tv":"AI_LoadAPIKeyError","c":false,"f":{"description":[true,"s"],"envVar":[true,"s"]}},{"tv":"AI_LoadSettingError","c":false,"f":{"envVar":[true,"s"],"settingName":[true,"s"]}},{"tv":"AI_TokenExpiredError","c":false,"f":{"message":[true,"s"]}},{"tv":"AI_UnsupportedFunctionalityError","c":false,"f":{"message":[true,"s"]}},{"tv":"AI_NoSuchModelError","c":false,"f":{"modelId":[true,"s"],"modelType":[true,"s"]}},{"tv":"AI_NoSuchProviderError","c":false,"f":{"availableProviders":[true,["a","s"]],"modelId":[true,"s"],"modelType":[true,"s"],"providerId":[true,"s"]}},{"tv":"AI_MissingToolResultsError","c":false,"f":{"toolCallIds":[true,["a","s"]]}},{"tv":"AI_ToolChoiceViolationError","c":false,"f":{"content":[true,["a",["r","GenerateContent"]]],"finishReason":[true,["r","FinishReasonUnified"]],"modelId":[true,"s"],"provider":[true,"s"],"toolChoice":[true,["r","LanguageModelV4ToolChoice"]]}},{"tv":"TimeoutError","c":false,"f":{"message":[true,"s"]}},{"tv":"AbortError","c":false,"f":{"message":[true,"s"]}},{"tv":"AI_Error","c":false,"f":{"cause":[false,["n",["r","ErrorCause"]]],"message":[true,"s"]}}]},"AiMuxErrorInput":{"k":"t","g":"name","v":[{"tv":"AI_APICallError","c":false,"f":{"cause":[false,["n",["r","ErrorCauseInput"]]],"data":[false,"j"],"isRetryable":[false,"b"],"message":[true,"s"],"origin":[false,["r","ApiCallErrorOrigin"]],"providerCode":[false,["n","s"]],"requestBodyValues":[true,"j"],"responseBody":[false,["n","s"]],"responseHeaders":[false,["n",["m","s"]]],"statusCode":[false,["n",["i",true,16]]],"url":[true,"s"]}},{"tv":"AI_RetryError","c":false,"f":{"errors":[true,["a",["r","AiMuxErrorInput"]]],"reason":[true,["r","RetryErrorReason"]]}},{"tv":"AI_JSONParseError","c":false,"f":{"cause":[false,["n",["r","ErrorCauseInput"]]],"message":[true,"s"]}},{"tv":"AI_NoOutputGeneratedError","c":false,"f":{"cause":[false,["n",["r","ErrorCauseInput"]]],"message":[true,"s"]}},{"tv":"AI_InvalidResponseDataError","c":false,"f":{"cause":[false,["n",["r","ErrorCauseInput"]]],"message":[true,"s"]}},{"tv":"AI_TypeValidationError","c":false,"f":{"cause":[false,["n",["r","ErrorCauseInput"]]],"message":[true,"s"],"value":[true,"j"]}},{"tv":"AI_ToolCallNotFoundForApprovalError","c":false,"f":{"approvalId":[true,"s"],"toolCallId":[true,"s"]}},{"tv":"AI_NoSuchToolError","c":false,"f":{"availableTools":[false,["n",["a","s"]]],"toolInput":[false,["n","s"]],"toolName":[true,"s"]}},{"tv":"AI_InvalidToolInputError","c":false,"f":{"cause":[true,["r","ErrorCauseInput"]],"toolInput":[true,"s"],"toolName":[true,"s"]}},{"tv":"AI_ToolCallRepairError","c":false,"f":{"cause":[true,["r","AiMuxErrorInput"]],"originalError":[true,["r","AiMuxErrorInput"]]}},{"tv":"AI_InvalidArgumentError","c":false,"f":{"cause":[false,["n",["r","ErrorCauseInput"]]],"message":[true,"s"]}},{"tv":"AI_InvalidPromptError","c":false,"f":{"cause":[false,["n",["r","ErrorCauseInput"]]],"message":[true,"s"]}},{"tv":"AI_LoadAPIKeyError","c":false,"f":{"description":[true,"s"],"envVar":[true,"s"]}},{"tv":"AI_LoadSettingError","c":false,"f":{"envVar":[true,"s"],"settingName":[true,"s"]}},{"tv":"AI_TokenExpiredError","c":false,"f":{"message":[true,"s"]}},{"tv":"AI_UnsupportedFunctionalityError","c":false,"f":{"message":[true,"s"]}},{"tv":"AI_NoSuchModelError","c":false,"f":{"modelId":[true,"s"],"modelType":[false,"s"]}},{"tv":"AI_NoSuchProviderError","c":false,"f":{"availableProviders":[true,["a","s"]],"modelId":[true,"s"],"modelType":[true,"s"],"providerId":[true,"s"]}},{"tv":"AI_MissingToolResultsError","c":false,"f":{"toolCallIds":[true,["a","s"]]}},{"tv":"AI_ToolChoiceViolationError","c":false,"f":{"content":[true,["a",["r","GenerateContent"]]],"finishReason":[true,["r","FinishReasonUnified"]],"modelId":[true,"s"],"provider":[true,"s"],"toolChoice":[true,["r","LanguageModelV4ToolChoice"]]}},{"tv":"TimeoutError","c":false,"f":{"message":[true,"s"]}},{"tv":"AbortError","c":false,"f":{"message":[true,"s"]}},{"tv":"AI_Error","c":false,"f":{"cause":[false,["n",["r","ErrorCauseInput"]]],"message":[true,"s"]}}]},"ApiCallError":{"k":"s","c":false,"f":{"cause":[false,["n",["r","ErrorCause"]]],"data":[false,"j"],"isRetryable":[true,"b"],"message":[true,"s"],"origin":[false,["r","ApiCallErrorOrigin"]],"providerCode":[false,["n","s"]],"requestBodyValues":[true,"j"],"responseBody":[false,["n","s"]],"responseHeaders":[false,["n",["m","s"]]],"statusCode":[false,["n",["i",true,16]]],"url":[true,"s"]}},"ApiCallErrorInput":{"k":"s","c":false,"f":{"cause":[false,["n",["r","ErrorCauseInput"]]],"data":[false,"j"],"isRetryable":[false,"b"],"message":[true,"s"],"origin":[false,["r","ApiCallErrorOrigin"]],"providerCode":[false,["n","s"]],"requestBodyValues":[true,"j"],"responseBody":[false,["n","s"]],"responseHeaders":[false,["n",["m","s"]]],"statusCode":[false,["n",["i",true,16]]],"url":[true,"s"]}},"ApiCallErrorOrigin":{"k":"e","v":["transport","httpResponse","streamEvent","local","unknown"]},"AspectRatio":{"k":"a","t":"s"},"AssistantContent":{"k":"u","b":["s",["a",["r","AssistantContentPart"]]]},"AssistantContentPart":{"k":"t","g":"type","v":[{"tv":"text","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"text":[true,"s"]}},{"tv":"custom","c":false,"f":{"kind":[true,["r","NamespacedKind"]],"providerOptions":[false,["n",["m",["m","j"]]]]}},{"tv":"file","c":false,"f":{"data":[true,["r","FilePartData"]],"filename":[false,["n","s"]],"mediaType":[true,"s"],"providerOptions":[false,["n",["m",["m","j"]]]]}},{"tv":"reasoning","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"text":[true,"s"]}},{"tv":"reasoning-file","c":false,"f":{"data":[true,["r","ReasoningFilePartData"]],"mediaType":[true,"s"],"providerOptions":[false,["n",["m",["m","j"]]]]}},{"tv":"tool-call","c":false,"f":{"input":[true,"j"],"providerExecuted":[false,["n","b"]],"providerOptions":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},{"tv":"tool-result","c":false,"f":{"output":[true,["r","ToolResultOutput"]],"providerOptions":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[false,["n","s"]]}},{"tv":"tool-approval-request","c":false,"f":{"approvalId":[true,"s"],"inputSchemaInput":[false,"j"],"isAutomatic":[false,["n","b"]],"reason":[false,["n","s"]],"signature":[false,["n","s"]],"toolCallId":[true,"s"]}}]},"AssistantPart":{"k":"t","g":"type","v":[{"tv":"text","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"text":[true,"s"]}},{"tv":"file","c":false,"f":{"data":[true,["r","FileData"]],"filename":[false,["n","s"]],"mediaType":[true,"s"],"providerOptions":[false,["n",["m",["m","j"]]]]}},{"tv":"reasoning","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"text":[true,"s"]}},{"tv":"reasoning-file","c":false,"f":{"data":[true,["r","GeneratedFileData"]],"mediaType":[true,"s"],"providerOptions":[false,["n",["m",["m","j"]]]]}},{"tv":"custom","c":false,"f":{"kind":[true,["r","NamespacedKind"]],"providerOptions":[false,["n",["m",["m","j"]]]]}},{"tv":"tool-call","c":false,"f":{"input":[true,"j"],"providerExecuted":[false,["n","b"]],"providerOptions":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},{"tv":"tool-result","c":false,"f":{"output":[true,["r","LanguageModelToolResultOutput"]],"providerOptions":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}}]},"AudioData":{"k":"a","t":"s"},"AudioInput":{"k":"a","t":"s"},"BackendConfig":{"k":"t","g":"type","v":[{"tv":"ring","c":true,"f":{"capacity":[false,["n",["i",true,64]]]}},{"tv":"jsonl","c":true,"f":{"directory":[true,"s"]}}]},"BreakKind":{"k":"e","v":["SystemChanged","ToolsChanged","ConversationReset","Unknown"]},"CancelResult":{"k":"e","v":["first","alreadyRequested","alreadyTerminal"]},"CapturePolicy":{"k":"e","v":["full"]},"Catalogue":{"k":"s","c":false,"f":{"specs":[true,["m",["m",["r","ModelSpec"]]]],"unmapped":[false,["m",["m",["r","ModelSpec"]]]],"updatedAt":[true,["i",true,64]]}},"CatalogueFetchRequest":{"k":"s","c":true,"f":{"abort":[false,["n",["r","HandleIdInput"]]],"sourceUrl":[false,["n","s"]]}},"CatalogueSource":{"k":"e","v":["Anya2a","ModelsDev","Manual"]},"ChatCompletion":{"k":"s","c":false,"f":{"choices":[true,["a",["r","ChatCompletionChoice"]]],"created":[true,["i",true,64]],"id":[true,"s"],"model":[true,"s"],"object":[true,"s"],"system_fingerprint":[false,["n","s"]],"usage":[true,["r","ChatCompletionUsage"]]}},"ChatCompletionChoice":{"k":"s","c":false,"f":{"finish_reason":[true,["n","s"]],"index":[true,["i",true,32]],"logprobs":[false,"j"],"message":[true,["r","ChatCompletionMessage"]]}},"ChatCompletionChunk":{"k":"s","c":false,"f":{"choices":[true,["a",["r","ChatCompletionChunkChoice"]]],"created":[true,["i",true,64]],"id":[true,"s"],"model":[true,"s"],"object":[true,"s"],"usage":[false,["n",["r","ChatCompletionUsage"]]]}},"ChatCompletionChunkChoice":{"k":"s","c":false,"f":{"delta":[true,["r","ChatCompletionDelta"]],"finish_reason":[true,["n","s"]],"index":[true,["i",true,32]],"logprobs":[false,"j"]}},"ChatCompletionChunkFunction":{"k":"s","c":false,"f":{"arguments":[false,["n","s"]],"name":[false,["n","s"]]}},"ChatCompletionChunkToolCall":{"k":"s","c":false,"f":{"function":[true,["r","ChatCompletionChunkFunction"]],"id":[false,["n","s"]],"index":[true,["i",true,32]],"type":[false,["n","s"]]}},"ChatCompletionDelta":{"k":"s","c":false,"f":{"content":[false,["n","s"]],"reasoning_content":[false,["n","s"]],"role":[false,["n","s"]],"tool_calls":[false,["n",["a",["r","ChatCompletionChunkToolCall"]]]]}},"ChatCompletionFunction":{"k":"s","c":false,"f":{"arguments":[true,"s"],"name":[true,"s"]}},"ChatCompletionMessage":{"k":"s","c":false,"f":{"annotations":[false,["n",["a","j"]]],"content":[true,["n","s"]],"reasoning_content":[false,["n","s"]],"role":[true,"s"],"tool_calls":[false,["n",["a",["r","ChatCompletionToolCall"]]]]}},"ChatCompletionToolCall":{"k":"s","c":false,"f":{"function":[true,["r","ChatCompletionFunction"]],"id":[true,"s"],"type":[true,"s"]}},"ChatCompletionUsage":{"k":"s","c":false,"f":{"completion_tokens":[true,["i",true,32]],"completion_tokens_details":[false,["n",["r","CompletionTokensDetails"]]],"prompt_tokens":[true,["i",true,32]],"prompt_tokens_details":[false,["n",["r","PromptTokensDetails"]]],"total_tokens":[true,["i",true,32]]}},"CodexModeSpec":{"k":"t","g":"type","v":[{"tv":"apiKey","c":true,"f":{"apiKey":[false,["n",["r","StringOrEnv"]]]}},{"tv":"chatGptAccount","c":true,"f":{"accountId":[false,["n","s"]],"token":[true,["r","StringOrEnv"]]}}]},"CodexRefreshRequest":{"k":"s","c":true,"f":{"clientId":[true,"s"],"refreshToken":[true,"s"]}},"CodexTokens":{"k":"s","c":false,"f":{"access_token":[true,"s"],"expires_in_secs":[true,["n",["i",true,64]]],"refresh_token":[true,["n","s"]]}},"CompletionTokensDetails":{"k":"s","c":false,"f":{"reasoning_tokens":[false,["n",["i",true,32]]]}},"ContentPart":{"k":"t","g":"type","v":[{"tv":"text","c":false,"f":{"providerMetadata":[false,["n",["m",["m","j"]]]],"text":[true,"s"]}},{"tv":"custom","c":false,"f":{"kind":[true,["r","NamespacedKind"]],"providerMetadata":[false,["n",["m",["m","j"]]]]}},{"tv":"reasoning","c":false,"f":{"providerMetadata":[false,["n",["m",["m","j"]]]],"text":[true,"s"]}},{"tv":"reasoning-file","c":false,"f":{"file":[true,["r","GeneratedFile"]],"providerMetadata":[false,["n",["m",["m","j"]]]]}},{"tv":"source","c":false,"f":{"id":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]],"sourceType":[true,["l","url"]],"title":[false,["n","s"]],"url":[true,"s"]}},{"tv":"source","c":false,"f":{"filename":[false,["n","s"]],"id":[true,"s"],"mediaType":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]],"sourceType":[true,["l","document"]],"title":[true,"s"]}},{"tv":"file","c":false,"f":{"file":[true,["r","GeneratedFile"]],"providerMetadata":[false,["n",["m",["m","j"]]]]}},{"tv":"tool-call","c":false,"f":{"dynamic":[false,["n","b"]],"error":[false,["n",["r","AiMuxError"]]],"input":[true,"j"],"invalid":[false,["n","b"]],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},{"tv":"tool-result","c":false,"f":{"dynamic":[false,["n","b"]],"input":[false,"j"],"output":[true,"j"],"preliminary":[false,["n","b"]],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},{"tv":"tool-error","c":false,"f":{"dynamic":[false,["n","b"]],"error":[true,"j"],"input":[false,"j"],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},{"tv":"tool-approval-request","c":false,"f":{"approvalId":[true,"s"],"isAutomatic":[false,["n","b"]],"reason":[false,["n","s"]],"signature":[false,["n","s"]],"toolCall":[true,["r","TypedToolCall"]]}},{"tv":"tool-approval-response","c":false,"f":{"approvalId":[true,"s"],"approved":[true,"b"],"providerExecuted":[false,["n","b"]],"reason":[false,["n","s"]],"toolCall":[true,["r","TypedToolCall"]]}}]},"ContentPartInput":{"k":"t","g":"type","v":[{"tv":"text","c":false,"f":{"providerMetadata":[false,["n",["m",["m","j"]]]],"text":[true,"s"]}},{"tv":"custom","c":false,"f":{"kind":[true,["r","NamespacedKind"]],"providerMetadata":[false,["n",["m",["m","j"]]]]}},{"tv":"reasoning","c":false,"f":{"providerMetadata":[false,["n",["m",["m","j"]]]],"text":[true,"s"]}},{"tv":"reasoning-file","c":false,"f":{"file":[true,["r","GeneratedFile"]],"providerMetadata":[false,["n",["m",["m","j"]]]]}},{"tv":"source","c":false,"f":{"id":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]],"sourceType":[true,["l","url"]],"title":[false,["n","s"]],"url":[true,"s"]}},{"tv":"source","c":false,"f":{"filename":[false,["n","s"]],"id":[true,"s"],"mediaType":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]],"sourceType":[true,["l","document"]],"title":[true,"s"]}},{"tv":"file","c":false,"f":{"file":[true,["r","GeneratedFile"]],"providerMetadata":[false,["n",["m",["m","j"]]]]}},{"tv":"tool-call","c":false,"f":{"dynamic":[false,["n","b"]],"error":[false,["n",["r","AiMuxErrorInput"]]],"input":[true,"j"],"invalid":[false,["n","b"]],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},{"tv":"tool-result","c":false,"f":{"dynamic":[false,["n","b"]],"input":[false,"j"],"output":[true,"j"],"preliminary":[false,["n","b"]],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},{"tv":"tool-error","c":false,"f":{"dynamic":[false,["n","b"]],"error":[true,"j"],"input":[false,"j"],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},{"tv":"tool-approval-request","c":false,"f":{"approvalId":[true,"s"],"isAutomatic":[false,["n","b"]],"reason":[false,["n","s"]],"signature":[false,["n","s"]],"toolCall":[true,["r","TypedToolCallInput"]]}},{"tv":"tool-approval-response","c":false,"f":{"approvalId":[true,"s"],"approved":[true,"b"],"providerExecuted":[false,["n","b"]],"reason":[false,["n","s"]],"toolCall":[true,["r","TypedToolCallInput"]]}}]},"CreateRecorderParams":{"k":"s","c":true,"f":{"backend":[true,["r","BackendConfig"]],"capturePolicy":[true,["r","CapturePolicy"]]}},"CredentialParams":{"k":"s","c":true,"f":{"kind":[true,"s"]}},"CustomPart":{"k":"s","c":false,"f":{"kind":[true,["r","NamespacedKind"]],"providerOptions":[false,["n",["m",["m","j"]]]]}},"DecideOptions":{"k":"s","c":true,"f":{"headers":[false,["n",["m","s"]]],"maxRetries":[false,["n",["i",true,32]]],"providerOptions":[false,["n",["m",["m","j"]]]],"questions":[true,["m",["r","DecisionQuestion"]]],"state":[true,["r","DecisionInput"]],"timeout":[false,["n",["r","TimeoutConfiguration"]]]}},"DecideResult":{"k":"s","c":false,"f":{"answers":[true,["m",["r","DecisionAnswer"]]],"providerMetadata":[false,["n",["m",["m","j"]]]],"response":[true,["r","ResponseInfo"]],"rounding":[false,["n",["r","DecisionRounding"]]],"usage":[true,["r","DecideUsage"]],"warnings":[true,["a",["r","Warning"]]]}},"DecideUsage":{"k":"s","c":false,"f":{"inputTokens":[false,["n",["i",true,32]]],"outputTokens":[false,["n",["i",true,32]]],"totalTokens":[false,["n",["i",true,32]]]}},"DecisionAnswer":{"k":"t","g":"type","v":[{"tv":"choice","c":false,"f":{"choice":[true,"s"],"probabilities":[false,["n",["m","f"]]]}},{"tv":"score","c":false,"f":{"probabilities":[false,["n",["m","f"]]],"score":[true,"f"]}},{"tv":"boolean","c":false,"f":{"probability":[true,"f"]}}]},"DecisionBooleanCriteria":{"k":"s","c":true,"f":{"false":[false,["n",["r","DecisionInput"]]],"true":[false,["n",["r","DecisionInput"]]]}},"DecisionDecideRequest":{"k":"s","c":true,"f":{"abort":[false,["n",["r","HandleIdInput"]]],"options":[true,["r","DecideOptions"]]}},"DecisionInput":{"k":"u","b":["s",["m","j"],["a","j"]]},"DecisionQuestion":{"k":"t","g":"type","v":[{"tv":"choice","c":false,"f":{"criteria":[true,["m",["n",["r","DecisionInput"]]]],"instructions":[true,["r","DecisionInput"]]}},{"tv":"score","c":false,"f":{"criteria":[true,["a",["n",["r","DecisionInput"]]]],"instructions":[true,["r","DecisionInput"]]}},{"tv":"boolean","c":false,"f":{"criteria":[false,["n",["r","DecisionBooleanCriteria"]]],"instructions":[true,["r","DecisionInput"]]}}]},"DecisionRounding":{"k":"s","c":false,"f":{"probabilityDecimals":[false,["n",["i",true,32]]],"scoreDecimals":[false,["n",["i",true,32]]]}},"EmbeddingCallOptions":{"k":"s","c":true,"f":{"headers":[false,["n",["m","s"]]],"maxRetries":[false,["n",["i",true,32]]],"providerOptions":[false,["n",["m",["m","j"]]]],"timeout":[false,["n",["r","TimeoutConfiguration"]]],"values":[true,["a","s"]]}},"EmbeddingResponse":{"k":"s","c":false,"f":{"body":[false,"j"],"headers":[false,["n",["m","s"]]]}},"EmbeddingResult":{"k":"s","c":false,"f":{"embeddings":[true,["a",["a","f"]]],"providerMetadata":[false,["n",["m",["m","j"]]]],"response":[false,["n",["r","EmbeddingResponse"]]],"usage":[false,["n",["r","EmbeddingUsage"]]],"warnings":[true,["a",["r","Warning"]]]}},"EmbeddingUsage":{"k":"s","c":false,"f":{"tokens":[true,["i",true,32]]}},"EmptyParams":{"k":"s","c":true,"f":{}},"EnvVarRef":{"k":"s","c":true,"f":{"env":[true,"s"]}},"ErrorCause":{"k":"u","b":[["r","AiMuxError"],["r","SourceError"]]},"ErrorCauseInput":{"k":"u","b":[["r","AiMuxErrorInput"],["r","SourceError"]]},"ErrorDomain":{"k":"e","v":["aimux","recording","binding","protocol"]},"ErrorEnvelope":{"k":"s","c":false,"f":{"code":[true,["i",false,32]],"error":[true,"j"],"kind":[true,["r","ErrorDomain"]],"message":[true,"s"]}},"Fallback":{"k":"e","v":["on-error","none"]},"FileBytes":{"k":"a","t":"s"},"FileData":{"k":"t","g":"type","v":[{"tv":"data","c":false,"f":{"data":[true,["r","FileBytes"]]}},{"tv":"url","c":false,"f":{"originalUrl":[false,["n","s"]],"url":[true,"s"]}},{"tv":"reference","c":false,"f":{"reference":[true,["m","s"]]}},{"tv":"text","c":false,"f":{"text":[true,"s"]}}]},"FilePart":{"k":"s","c":false,"f":{"data":[true,["r","FileData"]],"filename":[false,["n","s"]],"mediaType":[true,"s"],"providerOptions":[false,["n",["m",["m","j"]]]]}},"FilePartData":{"k":"u","b":[["r","FileData"],"s",["m","s"]]},"Fingerprint":{"k":"s","c":false,"f":{"blockHashes":[true,["a","s"]],"blockSize":[true,["i",true,64]],"bodyHash":[true,"s"],"lenBytes":[true,["i",true,64]],"tokenEstimate":[true,["i",true,64]]}},"FinishReasonUnified":{"k":"e","v":["stop","length","content-filter","tool-calls","error","other"]},"FunctionTool":{"k":"s","c":false,"f":{"description":[false,["n","s"]],"inputExamples":[false,["n",["a",["r","FunctionToolInputExample"]]]],"inputSchema":[true,"j"],"name":[true,"s"],"providerOptions":[false,["n",["m",["m","j"]]]],"strict":[false,["n","b"]]}},"FunctionToolInputExample":{"k":"s","c":false,"f":{"input":[true,["m","j"]]}},"GenerateContent":{"k":"t","g":"type","v":[{"tv":"text","c":false,"f":{"providerMetadata":[false,["n",["m",["m","j"]]]],"text":[true,"s"]}},{"tv":"tool-call","c":false,"f":{"dynamic":[false,["n","b"]],"input":[true,"s"],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},{"tv":"source","c":false,"f":{"id":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]],"sourceType":[true,["l","url"]],"title":[false,["n","s"]],"url":[true,"s"]}},{"tv":"source","c":false,"f":{"filename":[false,["n","s"]],"id":[true,"s"],"mediaType":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]],"sourceType":[true,["l","document"]],"title":[true,"s"]}},{"tv":"reasoning","c":false,"f":{"providerMetadata":[false,["n",["m",["m","j"]]]],"text":[true,"s"]}},{"tv":"file","c":false,"f":{"data":[true,["r","GeneratedFileData"]],"mediaType":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]]}},{"tv":"reasoning-file","c":false,"f":{"data":[true,["r","GeneratedFileData"]],"mediaType":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]]}},{"tv":"custom","c":false,"f":{"kind":[true,["r","NamespacedKind"]],"providerMetadata":[false,["n",["m",["m","j"]]]]}},{"tv":"tool-approval-request","c":false,"f":{"approvalId":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"]}},{"tv":"tool-result","c":false,"f":{"dynamic":[false,["n","b"]],"isError":[false,["n","b"]],"preliminary":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"result":[true,"j"],"toolCallId":[true,"s"],"toolName":[true,"s"]}}]},"GenerateObjectResponse":{"k":"s","c":false,"f":{"body":[false,"j"],"headers":[false,["n",["m","s"]]],"id":[true,"s"],"modelId":[true,"s"],"timestamp":[true,["r","Timestamp"]]}},"GenerateObjectResult":{"k":"s","c":false,"f":{"finishReason":[true,["r","FinishReasonUnified"]],"object":[true,"j"],"providerMetadata":[false,["n",["m",["m","j"]]]],"reasoning":[false,["n","s"]],"request":[true,["r","RequestInfo"]],"response":[true,["r","GenerateObjectResponse"]],"usage":[true,["r","LanguageModelUsage"]],"warnings":[true,["a",["r","Warning"]]]}},"GenerateTextOptions":{"k":"s","c":true,"f":{"frequencyPenalty":[false,["n","f"]],"headers":[false,["n",["m","s"]]],"includeRawChunks":[false,["n","b"]],"instructions":[false,["n","s"]],"maxOutputTokens":[false,["n",["i",true,32]]],"maxRetries":[false,["n",["i",true,32]]],"output":[false,["n",["r","Output"]]],"presencePenalty":[false,["n","f"]],"providerOptions":[false,["n",["m",["m","j"]]]],"reasoning":[false,["n",["r","ReasoningEffort"]]],"seed":[false,["n",["i",true,64]]],"sessionId":[false,["n","s"]],"stopSequences":[false,["n",["a","s"]]],"strictStream":[false,["n","b"]],"temperature":[false,["n","f"]],"timeout":[false,["n",["r","TimeoutConfiguration"]]],"toolChoice":[false,["n",["r","ToolChoice"]]],"tools":[false,["n",["a",["r","Tool"]]]],"topK":[false,["n","f"]],"topP":[false,["n","f"]]}},"GenerateTextResult":{"k":"s","c":false,"f":{"content":[true,["a",["r","ContentPart"]]],"files":[true,["a",["r","GeneratedFile"]]],"finishReason":[true,["r","FinishReasonUnified"]],"output":[false,"j"],"providerMetadata":[false,["n",["m",["m","j"]]]],"rawFinishReason":[false,["n","s"]],"reasoning":[true,["a",["r","ReasoningPart"]]],"reasoningText":[false,["n","s"]],"request":[true,["r","RequestInfo"]],"response":[true,["r","StepResponse"]],"responseMessages":[true,["a",["r","ModelMessage"]]],"sources":[true,["a",["r","TypedSource"]]],"steps":[true,["a",["r","StepResult"]]],"text":[true,"s"],"toolCalls":[true,["a",["r","TypedToolCall"]]],"toolResults":[true,["a",["r","TaggedToolResult"]]],"totalUsage":[true,["r","LanguageModelUsage"]],"usage":[true,["r","LanguageModelUsage"]],"warnings":[true,["a",["r","Warning"]]]}},"GenerateTextResultInput":{"k":"s","c":false,"f":{"output":[false,"j"],"steps":[true,["a",["r","StepResultInput"]]],"totalUsage":[true,["r","LanguageModelUsageInput"]]}},"GeneratedFile":{"k":"s","c":false,"f":{"base64":[true,["r","FileBytes"]],"mediaType":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]]}},"GeneratedFileData":{"k":"t","g":"type","v":[{"tv":"data","c":false,"f":{"data":[true,["r","FileBytes"]]}},{"tv":"url","c":false,"f":{"originalUrl":[false,["n","s"]],"url":[true,"s"]}}]},"GeneratedFileOutput":{"k":"s","c":false,"f":{"file":[true,["r","GeneratedFile"]],"providerMetadata":[false,["n",["m",["m","j"]]]]}},"HandleId":{"k":"a","t":"u64"},"HandleIdInput":{"k":"a","t":"u64"},"HandleKind":{"k":"e","v":["Provider","Registry","Language","Embedding","Image","Speech","Transcription","Reranking","Video","Search","Decision","Files","Operation","Abort","Fetch","WebSocket","Download","CredentialResolver","Middleware","TraceStore","Recorder","SessionStore","ReplaySession"]},"HandleResult":{"k":"s","c":false,"f":{"handle":[true,["r","HandleId"]],"kind":[true,["r","HandleKind"]]}},"HttpExchange":{"k":"s","c":false,"f":{"attempt":[true,["i",true,32]],"error":[false,["n","s"]],"exchangeIndex":[true,["i",true,32]],"finalized":[true,"b"],"request":[true,["r","HttpRecord"]],"response":[false,["n",["r","ResponseRecord"]]],"step":[false,["n","s"]],"timing":[true,["r","TimingRecord"]]}},"HttpRecord":{"k":"s","c":false,"f":{"body":[false,["n","s"]],"headers":[true,["a",["a","s"]]],"method":[true,"s"],"url":[true,"s"]}},"ImageCallOptions":{"k":"s","c":true,"f":{"aspectRatio":[false,["n",["r","AspectRatio"]]],"files":[false,["n",["a",["r","ImageFile"]]]],"headers":[false,["n",["m","s"]]],"mask":[false,["n",["r","ImageFile"]]],"maxRetries":[false,["n",["i",true,32]]],"n":[true,["i",true,32]],"prompt":[false,["n","s"]],"providerOptions":[true,["m",["m","j"]]],"seed":[false,["n",["i",true,64]]],"size":[false,["n",["r","Size"]]],"timeout":[false,["n",["r","TimeoutConfiguration"]]]}},"ImageFile":{"k":"t","g":"type","v":[{"tv":"file","c":false,"f":{"data":[true,["r","ImageFileData"]],"mediaType":[true,"s"]}},{"tv":"url","c":false,"f":{"url":[true,"s"]}}]},"ImageFileData":{"k":"a","t":"s"},"ImageOutputs":{"k":"a","t":["a","s"]},"ImageResponse":{"k":"s","c":false,"f":{"headers":[false,["n",["m","s"]]],"modelId":[false,["n","s"]],"timestamp":[false,["n",["r","Timestamp"]]]}},"ImageResult":{"k":"s","c":false,"f":{"images":[true,["r","ImageOutputs"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"response":[true,["r","ImageResponse"]],"usage":[false,["n",["r","ImageUsage"]]],"warnings":[true,["a",["r","Warning"]]]}},"ImageUsage":{"k":"s","c":false,"f":{"inputTokens":[false,["n",["i",true,32]]],"outputTokens":[false,["n",["i",true,32]]],"totalTokens":[false,["n",["i",true,32]]]}},"InputAudioFormat":{"k":"s","c":true,"f":{"formatType":[true,"s"],"rate":[false,["n",["i",true,32]]]}},"InputRecord":{"k":"s","c":false,"f":{"operation":[false,["r","RecordingOperation"]],"options":[true,"j"],"prompt":[true,["a",["r","LanguageModelMessage"]]]}},"InputTokenDetails":{"k":"s","c":false,"f":{"cacheReadTokens":[false,["n",["i",true,32]]],"cacheWriteTokens":[false,["n",["i",true,32]]],"noCacheTokens":[false,["n",["i",true,32]]]}},"LanguageApi":{"k":"e","v":["chat","responses","completion","messages"]},"LanguageModelFile":{"k":"s","c":false,"f":{"data":[true,["r","GeneratedFileData"]],"mediaType":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]]}},"LanguageModelMessage":{"k":"t","g":"role","v":[{"tv":"system","c":false,"f":{"content":[true,"s"],"providerOptions":[false,["n",["m",["m","j"]]]]}},{"tv":"user","c":false,"f":{"content":[true,["a",["r","UserPart"]]],"providerOptions":[false,["n",["m",["m","j"]]]]}},{"tv":"assistant","c":false,"f":{"content":[true,["a",["r","AssistantPart"]]],"providerOptions":[false,["n",["m",["m","j"]]]]}},{"tv":"tool","c":false,"f":{"content":[true,["a",["r","ToolPart"]]],"providerOptions":[false,["n",["m",["m","j"]]]]}}]},"LanguageModelReasoningPart":{"k":"s","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"text":[true,"s"]}},"LanguageModelToolResultOutput":{"k":"t","g":"type","v":[{"tv":"text","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"value":[true,"s"]}},{"tv":"json","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"value":[true,"j"]}},{"tv":"execution-denied","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"reason":[false,["n","s"]]}},{"tv":"error-text","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"value":[true,"s"]}},{"tv":"error-json","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"value":[true,"j"]}},{"tv":"content","c":false,"f":{"isError":[false,["n","b"]],"value":[true,["a",["r","ToolResultContent"]]]}}]},"LanguageModelToolResultPart":{"k":"s","c":false,"f":{"output":[true,["r","LanguageModelToolResultOutput"]],"providerOptions":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},"LanguageModelUsage":{"k":"s","c":false,"f":{"inputTokenDetails":[true,["r","InputTokenDetails"]],"inputTokens":[false,["n",["i",true,32]]],"outputTokenDetails":[true,["r","OutputTokenDetails"]],"outputTokens":[false,["n",["i",true,32]]],"raw":[false,["n",["m","j"]]],"totalTokens":[false,["n",["i",true,32]]]}},"LanguageModelUsageInput":{"k":"s","c":false,"f":{"inputTokenDetails":[false,["r","InputTokenDetails"]],"inputTokens":[false,["n",["i",true,32]]],"outputTokenDetails":[false,["r","OutputTokenDetails"]],"outputTokens":[false,["n",["i",true,32]]],"raw":[false,["n",["m","j"]]],"totalTokens":[false,["n",["i",true,32]]]}},"LanguageModelV4ToolChoice":{"k":"t","g":"type","v":[{"tv":"auto","c":false,"f":{}},{"tv":"none","c":false,"f":{}},{"tv":"required","c":false,"f":{}},{"tv":"tool","c":false,"f":{"toolName":[true,"s"]}}]},"LiveTarget":{"k":"t","g":"kind","v":[{"tv":"model","c":true,"f":{"handle":[true,["r","HandleIdInput"]]}},{"tv":"registry","c":true,"f":{"handle":[true,["r","HandleIdInput"]]}}]},"LogLevel":{"k":"e","v":["off","error","warn","info","debug","trace"]},"LoggingConfig":{"k":"s","c":true,"f":{"level":[true,["r","LogLevel"]]}},"MiddlewareAuditMode":{"k":"e","v":["disabled","shared","strict"]},"MiddlewareParams":{"k":"s","c":true,"f":{"auditMode":[false,["n",["r","MiddlewareAuditMode"]]],"kind":[true,"s"],"scopeName":[false,["n","s"]],"traceStore":[false,["n",["r","HandleIdInput"]]]}},"MoaFailMode":{"k":"e","v":["best-effort","fail-fast"]},"MoaParams":{"k":"s","c":true,"f":{"aggregator":[true,"s"],"aggregatorInstructions":[false,["n","s"]],"failMode":[false,["r","MoaFailMode"]],"modelId":[false,"s"],"providerName":[false,"s"],"references":[true,["a","s"]],"stripReferenceTools":[false,"b"]}},"Modality":{"k":"e","v":["Text","Image","Audio","Video","Pdf","Other","Embedding","Score"]},"ModalityKind":{"k":"e","v":["languageModel","embeddingModel","imageModel","speechModel","transcriptionModel","rerankingModel","videoModel","searchModel","decision"]},"ModelCapabilities":{"k":"s","c":false,"f":{"attachment":[true,"b"],"structuredOutput":[true,"b"],"temperature":[true,"b"],"toolCall":[true,"b"]}},"ModelCost":{"k":"s","c":false,"f":{"cacheRead":[false,["n","f"]],"cacheWrite":[false,["n","f"]],"input":[false,["n","f"]],"output":[false,["n","f"]]}},"ModelInfo":{"k":"s","c":false,"f":{"capabilities":[true,"j"],"modality":[true,"s"],"modelId":[true,"s"],"provider":[true,"s"],"source":[true,"j"]}},"ModelInfoParams":{"k":"s","c":true,"f":{}},"ModelLimits":{"k":"s","c":false,"f":{"context":[false,["n",["i",true,64]]],"input":[false,["n",["i",true,64]]],"output":[false,["n",["i",true,64]]]}},"ModelMessage":{"k":"t","g":"role","v":[{"tv":"system","c":false,"f":{"content":[true,"s"],"providerOptions":[false,["n",["m",["m","j"]]]]}},{"tv":"user","c":false,"f":{"content":[true,["r","UserContent"]],"providerOptions":[false,["n",["m",["m","j"]]]]}},{"tv":"assistant","c":false,"f":{"content":[true,["r","AssistantContent"]],"providerOptions":[false,["n",["m",["m","j"]]]]}},{"tv":"tool","c":false,"f":{"content":[true,["a",["r","ToolContentPart"]]],"providerOptions":[false,["n",["m",["m","j"]]]]}}]},"ModelMethod":{"k":"e","v":["languageModel","chat","responses","completion","messages","embeddingModel","imageModel","speechModel","transcriptionModel","rerankingModel","videoModel","searchModel","decision"]},"ModelModalities":{"k":"s","c":false,"f":{"input":[false,["a",["r","Modality"]]],"output":[false,["a",["r","Modality"]]]}},"ModelPrompt":{"k":"u","b":["s",["a",["r","ModelMessage"]]]},"ModelRef":{"k":"s","c":true,"f":{"key":[true,"s"],"method":[true,["r","ModelMethod"]],"modelId":[true,"s"],"namespace":[true,"s"]}},"ModelResolveParams":{"k":"s","c":true,"f":{"modelRef":[true,["r","ModelRef"]]}},"ModelSpec":{"k":"s","c":false,"f":{"capabilities":[true,["r","ModelCapabilities"]],"cost":[false,["n",["r","ModelCost"]]],"displayName":[false,["n","s"]],"limits":[true,["r","ModelLimits"]],"modalities":[true,["r","ModelModalities"]],"provider":[false,["n","s"]],"raw":[false,"j"],"reasoning":[false,["n",["r","ReasoningSpec"]]],"source":[true,["r","CatalogueSource"]],"type":[true,["r","ModelType"]]}},"ModelType":{"k":"e","v":["Chat","Completion","Embedding","Rerank","ImageGen","ImageEdit","Video","Audio","Other"]},"ModelWrapParams":{"k":"s","c":true,"f":{"middleware":[true,["a","s"]]}},"NamespacedKind":{"k":"a","t":"s"},"OpenAiOutputRequest":{"k":"s","c":true,"f":{"metadataNamespace":[true,"s"],"result":[true,["r","GenerateTextResultInput"]]}},"OpenAiTextRequest":{"k":"s","c":true,"f":{"abort":[false,["n",["r","HandleIdInput"]]],"options":[false,["r","Options"]],"prompt":[true,["r","ModelPrompt"]],"streamOptions":[false,["r","StreamOptions"]]}},"OperationCapabilities":{"k":"s","c":false,"f":{"cancel":[true,"b"],"inputDone":[true,"b"],"next":[true,"b"],"push":[true,"b"]}},"OperationNextParams":{"k":"s","c":true,"f":{"timeoutMs":[false,["i",true,64]]}},"OperationOutcome":{"k":"e","v":["success","error","cancelled"]},"OperationPollResult":{"k":"t","g":"type","v":[{"tv":"part","c":false,"f":{"part":[true,["r","TranscriptionStreamPart"]]}},{"tv":"ended","c":false,"f":{}},{"tv":"timeout","c":false,"f":{}}]},"OperationState":{"k":"e","v":["running","inputClosed","terminal"]},"OperationStatus":{"k":"s","c":false,"f":{"capabilities":[true,["r","OperationCapabilities"]],"cleanupFailure":[false,["n","s"]],"consumerClosed":[true,"b"],"inputDoneSequence":[false,["n","s"]],"queuedInputBytes":[true,["i",true,64]],"queuedInputItems":[true,["i",true,64]],"queuedOutputBytes":[true,["i",true,64]],"queuedOutputItems":[true,["i",true,64]],"state":[true,["r","OperationState"]],"subkind":[true,"s"],"terminal":[false,["n",["r","TerminalSummary"]]]}},"Options":{"k":"s","c":true,"f":{"frequencyPenalty":[false,["n","f"]],"headers":[false,["n",["m","s"]]],"includeRawChunks":[false,["n","b"]],"instructions":[false,["n","s"]],"maxOutputTokens":[false,["n",["i",true,32]]],"maxRetries":[false,["n",["i",true,32]]],"output":[false,["n",["r","Output"]]],"presencePenalty":[false,["n","f"]],"providerOptions":[false,["n",["m",["m","j"]]]],"reasoning":[false,["n",["r","ReasoningEffort"]]],"seed":[false,["n",["i",true,64]]],"sessionId":[false,["n","s"]],"stopSequences":[false,["n",["a","s"]]],"strictStream":[false,["n","b"]],"temperature":[false,["n","f"]],"timeout":[false,["n",["r","TimeoutConfiguration"]]],"toolChoice":[false,["n",["r","ToolChoice"]]],"tools":[false,["n",["a",["r","Tool"]]]],"topK":[false,["n","f"]],"topP":[false,["n","f"]]}},"Outcome":{"k":"e","v":["success","error","cancelled"]},"OutcomeRecord":{"k":"s","c":false,"f":{"decisionResult":[false,"j"],"error":[false,["n","s"]],"errorValue":[false,"j"],"finishReason":[false,["n","s"]],"status":[true,["r","OutcomeStatus"]],"usage":[false,"j"]}},"OutcomeStatus":{"k":"e","v":["success","pending","error","incomplete","cancelled"]},"Output":{"k":"t","g":"type","v":[{"tv":"text","c":false,"f":{}},{"tv":"object","c":false,"f":{"description":[false,["n","s"]],"name":[false,["n","s"]],"schema":[true,"j"]}},{"tv":"array","c":false,"f":{"description":[false,["n","s"]],"element":[true,"j"],"maxItems":[false,["n",["i",true,32]]],"minItems":[false,["n",["i",true,32]]],"name":[false,["n","s"]]}},{"tv":"choice","c":false,"f":{"description":[false,["n","s"]],"name":[false,["n","s"]],"options":[true,["a","s"]]}},{"tv":"json","c":false,"f":{"description":[false,["n","s"]],"name":[false,["n","s"]]}}]},"OutputChunkTimingStats":{"k":"s","c":false,"f":{"avg":[true,"f"],"max":[true,"f"],"median":[true,"f"],"min":[true,"f"],"p10":[true,"f"],"p90":[true,"f"]}},"OutputTokenDetails":{"k":"s","c":false,"f":{"reasoningTokens":[false,["n",["i",true,32]]],"textTokens":[false,["n",["i",true,32]]]}},"PackageAuthKind":{"k":"e","v":["bearer","header","queryParam","basic","awsSigV4","awsBearerOrSigV4","anthropicAws","googleVertex","azureApiKeyOrToken","codexChannel","optionalBearer","none"]},"PackageDescriptor":{"k":"s","c":true,"f":{"apiKeyEnv":[false,["n","s"]],"authKind":[true,["r","PackageAuthKind"]],"baseUrlEnv":[false,["n","s"]],"defaultBaseUrl":[false,["n","s"]],"defaultMethod":[false,["n",["r","ModalityKind"]]],"id":[true,"s"],"kind":[true,["r","PackageKind"]],"languageApis":[true,["a",["r","LanguageApi"]]],"modalities":[true,["a",["r","ModalityKind"]]],"settings":[true,["a",["r","SettingFieldSpec"]]],"supportsDefaultInstance":[true,"b"],"supportsDiscovery":[true,"b"],"supportsFiles":[true,"b"],"supportsSkills":[true,"b"],"templateParams":[true,["a",["r","TemplateParamDescriptor"]]]}},"PackageKind":{"k":"e","v":["native","protocol","preset","specialized"]},"PrefixBreak":{"k":"s","c":false,"f":{"atRecordId":[true,"s"],"expectedBreak":[true,"b"],"kind":[true,["r","BreakKind"]],"lcpBytes":[true,["i",true,64]],"prevRecordId":[true,"s"]}},"PromptTokensDetails":{"k":"s","c":false,"f":{"cache_write_tokens":[false,["n",["i",true,32]]],"cached_tokens":[true,["i",true,32]]}},"ProviderConfigDocument":{"k":"s","c":true,"f":{"providers":[true,["m",["r","ProviderEntrySpec"]]]}},"ProviderConfigSettings":{"k":"s","c":true,"f":{"accessKeyId":[false,["n",["r","StringOrEnv"]]],"accessToken":[false,["n",["r","StringOrEnv"]]],"apiKey":[false,["n",["r","StringOrEnv"]]],"apiVersion":[false,["n","s"]],"authToken":[false,["n",["r","StringOrEnv"]]],"baseUrl":[false,["n","s"]],"codexMode":[false,["n",["r","CodexModeSpec"]]],"cx":[false,["n","s"]],"endpoint":[false,["n","s"]],"headers":[false,["m",["n","s"]]],"includeUsage":[false,["n","b"]],"location":[false,["n","s"]],"login":[false,["n",["r","StringOrEnv"]]],"name":[false,["n","s"]],"organization":[false,["n","s"]],"originator":[false,["n","s"]],"params":[false,["m","s"]],"password":[false,["n",["r","StringOrEnv"]]],"probabilitySource":[false,["n","s"]],"project":[false,["n","s"]],"queryParams":[false,["m","s"]],"region":[false,["n","s"]],"resourceName":[false,["n","s"]],"secretAccessKey":[false,["n",["r","StringOrEnv"]]],"sessionToken":[false,["n",["r","StringOrEnv"]]],"speechBaseUrl":[false,["n","s"]],"supportsMultiPartToolContent":[false,["n","b"]],"supportsStructuredOutputs":[false,["n","b"]],"useDeploymentBasedUrls":[false,["n","b"]],"workspaceId":[false,["n","s"]]}},"ProviderCreateParams":{"k":"s","c":true,"f":{"envAllowlist":[false,["n",["a","s"]]],"package":[true,"s"],"settings":[false,["r","ProviderSettings"]]}},"ProviderCustomParams":{"k":"s","c":true,"f":{"chatModels":[false,["m",["r","HandleIdInput"]]],"completionModels":[false,["m",["r","HandleIdInput"]]],"decisionModels":[false,["m",["r","HandleIdInput"]]],"defaultMethod":[false,["n","s"]],"embeddingModels":[false,["m",["r","HandleIdInput"]]],"fallbackProvider":[false,["n",["r","HandleIdInput"]]],"files":[false,["n",["r","HandleIdInput"]]],"imageModelMiddleware":[false,["a",["r","HandleIdInput"]]],"imageModels":[false,["m",["r","HandleIdInput"]]],"languageModelMiddleware":[false,["a",["r","HandleIdInput"]]],"languageModels":[false,["m",["r","HandleIdInput"]]],"messagesModels":[false,["m",["r","HandleIdInput"]]],"rerankingModels":[false,["m",["r","HandleIdInput"]]],"responsesModels":[false,["m",["r","HandleIdInput"]]],"searchModels":[false,["m",["r","HandleIdInput"]]],"speechModels":[false,["m",["r","HandleIdInput"]]],"transcriptionModels":[false,["m",["r","HandleIdInput"]]],"videoModels":[false,["m",["r","HandleIdInput"]]]}},"ProviderDefaultParams":{"k":"s","c":true,"f":{"package":[true,"s"]}},"ProviderDescriptorsParams":{"k":"s","c":true,"f":{"package":[false,["n","s"]]}},"ProviderEntrySpec":{"k":"s","c":true,"f":{"package":[true,"s"],"settings":[false,["r","ProviderConfigSettings"]]}},"ProviderInvokeParams":{"k":"s","c":true,"f":{"abort":[false,["n",["r","HandleIdInput"]]],"method":[true,"s"]}},"ProviderModelParams":{"k":"s","c":true,"f":{"method":[false,["n","s"]],"modelId":[true,"s"]}},"ProviderRecord":{"k":"s","c":false,"f":{"modelId":[true,"s"],"provider":[true,"s"],"providerId":[true,"s"]}},"ProviderSettings":{"k":"s","c":true,"f":{"accessKeyId":[false,["n",["r","StringOrEnv"]]],"accessToken":[false,["n",["r","StringOrEnv"]]],"apiKey":[false,["n",["r","StringOrEnv"]]],"apiVersion":[false,["n","s"]],"authToken":[false,["n",["r","StringOrEnv"]]],"baseUrl":[false,["n","s"]],"codexMode":[false,["n",["r","CodexModeSpec"]]],"credentialResolver":[false,["n",["r","HandleIdInput"]]],"cx":[false,["n","s"]],"endpoint":[false,["n","s"]],"fetch":[false,["n",["r","HandleIdInput"]]],"headers":[false,["m",["n","s"]]],"includeUsage":[false,["n","b"]],"location":[false,["n","s"]],"login":[false,["n",["r","StringOrEnv"]]],"name":[false,["n","s"]],"organization":[false,["n","s"]],"originator":[false,["n","s"]],"params":[false,["m","s"]],"password":[false,["n",["r","StringOrEnv"]]],"probabilitySource":[false,["n","s"]],"project":[false,["n","s"]],"queryParams":[false,["m","s"]],"region":[false,["n","s"]],"resourceName":[false,["n","s"]],"secretAccessKey":[false,["n",["r","StringOrEnv"]]],"sessionToken":[false,["n",["r","StringOrEnv"]]],"speechBaseUrl":[false,["n","s"]],"supportsMultiPartToolContent":[false,["n","b"]],"supportsStructuredOutputs":[false,["n","b"]],"useDeploymentBasedUrls":[false,["n","b"]],"webSocket":[false,["n",["r","HandleIdInput"]]],"workspaceId":[false,["n","s"]]}},"ProviderTool":{"k":"s","c":false,"f":{"args":[true,["m","j"]],"id":[true,["r","NamespacedKind"]],"name":[true,"s"],"supportsDeferredResults":[false,["n","b"]]}},"ProviderWrapParams":{"k":"s","c":true,"f":{"imageModelMiddleware":[false,["a",["r","HandleIdInput"]]],"languageModelMiddleware":[false,["a",["r","HandleIdInput"]]]}},"RawToolApprovalRequest":{"k":"s","c":false,"f":{"approvalId":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"]}},"RawToolCall":{"k":"s","c":false,"f":{"dynamic":[false,["n","b"]],"input":[true,"s"],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},"ReasoningEffort":{"k":"e","v":["provider-default","none","minimal","low","medium","high","xhigh"]},"ReasoningFilePart":{"k":"s","c":false,"f":{"data":[true,["r","GeneratedFileData"]],"mediaType":[true,"s"],"providerOptions":[false,["n",["m",["m","j"]]]]}},"ReasoningFilePartData":{"k":"u","b":[["r","GeneratedFileData"],"s"]},"ReasoningMode":{"k":"e","v":["Other","Budget","Effort","Level","Fixed","Mixed","Toggle"]},"ReasoningOutput":{"k":"s","c":false,"f":{"providerMetadata":[false,["n",["m",["m","j"]]]],"text":[true,"s"]}},"ReasoningPart":{"k":"t","g":"type","v":[{"tv":"reasoning","c":false,"f":{"providerMetadata":[false,["n",["m",["m","j"]]]],"text":[true,"s"]}},{"tv":"reasoning-file","c":false,"f":{"file":[true,["r","GeneratedFile"]],"providerMetadata":[false,["n",["m",["m","j"]]]]}}]},"ReasoningSpec":{"k":"s","c":false,"f":{"budgetMin":[false,["n",["i",true,64]]],"defaultEnabled":[true,"b"],"effortDefault":[false,["n","s"]],"effortOptions":[false,["a","s"]],"interleaved":[true,"b"],"mode":[false,["n",["r","ReasoningMode"]]],"supported":[true,"b"],"visibility":[false,["n",["r","ReasoningVisibility"]]]}},"ReasoningVisibility":{"k":"e","v":["Hidden","Summary","Full","Mixed","Omitted","Other"]},"RecorderExport":{"k":"s","c":false,"f":{"jsonl":[true,"s"]}},"RecorderHandleResult":{"k":"s","c":false,"f":{"handle":[true,["r","HandleId"]]}},"RecorderStats":{"k":"t","g":"type","v":[{"tv":"ring","c":false,"f":{"completed":[true,["i",true,64]],"dropped":[true,["i",true,64]],"inconsistentCallIds":[true,["a","s"]],"pending":[true,["i",true,64]],"pendingEvicted":[true,["i",true,64]]}},{"tv":"jsonl","c":false,"f":{"dropped":[true,["i",true,64]],"inconsistentCallIds":[true,["a","s"]],"lastWriteError":[true,["n","s"]],"path":[true,"s"]}}]},"Recording":{"k":"s","c":false,"f":{"callId":[true,"s"],"complete":[true,"b"],"exchanges":[true,["a",["r","HttpExchange"]]],"input":[true,["r","InputRecord"]],"outcome":[true,["r","OutcomeRecord"]],"provider":[true,["r","ProviderRecord"]],"recordedAt":[true,"s"],"schema":[true,["i",true,32]],"sessionId":[false,["n","s"]],"step":[false,["n",["i",true,32]]],"transportClosed":[true,"b"]}},"RecordingOperation":{"k":"e","v":["language-model","decision"]},"RegistryCreateParams":{"k":"s","c":true,"f":{"entries":[true,["a",["r","RegistryEntry"]]],"namespace":[false,"s"],"separator":[false,["n","s"]]}},"RegistryEntry":{"k":"s","c":true,"f":{"key":[true,"s"],"provider":[true,"s"]}},"RegistryFromConfigParams":{"k":"s","c":true,"f":{"config":[true,["r","ProviderConfigDocument"]],"envAllowlist":[false,["n",["a","s"]]],"namespace":[false,"s"],"separator":[false,["n","s"]]}},"RegistryListParams":{"k":"s","c":true,"f":{}},"RegistryListResult":{"k":"s","c":false,"f":{"keys":[true,["a","s"]],"namespace":[true,"s"],"separator":[true,"s"]}},"RegistryProviderParams":{"k":"s","c":true,"f":{"key":[true,"s"]}},"RegistryUpdateParams":{"k":"s","c":true,"f":{"derive":[false,"b"],"remove":[false,["a","s"]],"replace":[false,"b"],"set":[false,["a",["r","RegistryEntry"]]]}},"RegistryUpdateResult":{"k":"s","c":false,"f":{"handle":[false,["n",["r","HandleId"]]],"keys":[true,["a","s"]],"kind":[false,["n",["r","HandleKind"]]]}},"RepairedToolCall":{"k":"s","c":false,"f":{"dynamic":[false,["n","b"]],"input":[true,"s"],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"],"type":[false,["l","tool-call"]]}},"ReplayCreateParams":{"k":"s","c":true,"f":{"recordingsJsonl":[true,"s"]}},"ReplayInspection":{"k":"s","c":false,"f":{"recordings":[true,["a",["r","ReplayRecordingInfo"]]]}},"ReplayLiveParams":{"k":"s","c":true,"f":{"abort":[false,["n",["r","HandleIdInput"]]],"callId":[true,"s"],"target":[true,["r","LiveTarget"]]}},"ReplayLiveResult":{"k":"u","b":[["r","GenerateTextResult"],["r","DecideResult"]]},"ReplayPlan":{"k":"s","c":false,"f":{"calls":[true,["a",["r","ReplayPlannedCall"]]]}},"ReplayPlannedCall":{"k":"s","c":false,"f":{"callId":[true,"s"],"liveSupported":[true,"b"],"operation":[true,["r","RecordingOperation"]],"provider":[true,["r","ProviderRecord"]],"requiresTarget":[true,"b"]}},"ReplayRecordingInfo":{"k":"s","c":false,"f":{"callId":[true,"s"],"complete":[true,"b"],"exchangeCount":[true,["i",true,64]],"operation":[true,["r","RecordingOperation"]],"provider":[true,["r","ProviderRecord"]],"transportClosed":[true,"b"]}},"ReplaySessionHandle":{"k":"s","c":false,"f":{"handle":[true,["r","HandleId"]]}},"RequestCacheHints":{"k":"s","c":false,"f":{"requestedWrite":[true,"b"]}},"RequestInfo":{"k":"s","c":false,"f":{"body":[false,"j"]}},"RerankingCallOptions":{"k":"s","c":true,"f":{"documents":[true,["r","RerankingDocuments"]],"headers":[false,["n",["m","s"]]],"maxRetries":[false,["n",["i",true,32]]],"providerOptions":[false,["n",["m",["m","j"]]]],"query":[true,"s"],"timeout":[false,["n",["r","TimeoutConfiguration"]]],"topN":[false,["n",["i",true,32]]]}},"RerankingDocuments":{"k":"t","g":"type","v":[{"tv":"text","c":false,"f":{"values":[true,["a","s"]]}},{"tv":"object","c":false,"f":{"values":[true,["a","j"]]}}]},"RerankingRank":{"k":"s","c":false,"f":{"index":[true,["i",true,32]],"relevanceScore":[true,"f"]}},"RerankingResponse":{"k":"s","c":false,"f":{"body":[false,"j"],"headers":[false,["n",["m","s"]]],"id":[false,["n","s"]],"modelId":[false,["n","s"]],"timestamp":[false,["n",["r","Timestamp"]]]}},"RerankingResult":{"k":"s","c":false,"f":{"providerMetadata":[false,["n",["m",["m","j"]]]],"ranking":[true,["a",["r","RerankingRank"]]],"response":[false,["n",["r","RerankingResponse"]]],"warnings":[false,["n",["a",["r","Warning"]]]]}},"ResponseInfo":{"k":"s","c":false,"f":{"body":[false,"j"],"headers":[false,["n",["m","s"]]],"id":[false,["n","s"]],"modelId":[false,["n","s"]],"timestamp":[false,["n",["r","Timestamp"]]]}},"ResponseRecord":{"k":"s","c":false,"f":{"body":[false,["n","s"]],"headers":[true,["a",["a","s"]]],"status":[true,["i",true,16]],"streamChunks":[false,["n",["i",true,64]]],"ttfbMs":[false,["n",["i",true,64]]]}},"RetryError":{"k":"s","c":false,"f":{"errors":[true,["a",["r","AiMuxError"]]],"reason":[true,["r","RetryErrorReason"]]}},"RetryErrorInput":{"k":"s","c":false,"f":{"errors":[true,["a",["r","AiMuxErrorInput"]]],"reason":[true,["r","RetryErrorReason"]]}},"RetryErrorReason":{"k":"e","v":["maxRetriesExceeded","errorNotRetryable"]},"RouterParams":{"k":"s","c":true,"f":{"children":[true,["a","s"]],"fallback":[false,["r","Fallback"]],"modelId":[false,["n","s"]],"providerName":[false,["n","s"]],"strategy":[true,["r","Strategy"]]}},"RuntimeConfigureParams":{"k":"s","c":true,"f":{"logging":[false,["n",["r","LoggingConfig"]]],"proxy":[false,["n",["r","TransportProxy"]]]}},"RuntimeDescribeParams":{"k":"s","c":true,"f":{}},"RuntimeModel":{"k":"s","c":false,"f":{"created":[false,["n",["i",true,64]]],"id":[true,"s"],"limits":[false,["n",["r","ModelLimits"]]],"ownedBy":[false,["n","s"]]}},"SearchCallOptions":{"k":"s","c":true,"f":{"excludeDomains":[false,["n",["a","s"]]],"headers":[false,["n",["m","s"]]],"includeDomains":[false,["n",["a","s"]]],"includeRawContent":[false,["n","b"]],"maxResults":[false,["n",["i",true,32]]],"maxRetries":[false,["n",["i",true,32]]],"providerOptions":[false,["n",["m",["m","j"]]]],"query":[true,"s"],"timeRange":[false,["n","s"]],"timeout":[false,["n",["r","TimeoutConfiguration"]]]}},"SearchResponse":{"k":"s","c":false,"f":{"body":[false,"j"],"headers":[false,["n",["m","s"]]]}},"SearchResult":{"k":"s","c":false,"f":{"answer":[false,["n","s"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"response":[false,["n",["r","SearchResponse"]]],"results":[true,["a",["r","SearchResultItem"]]],"warnings":[true,["a",["r","Warning"]]]}},"SearchResultItem":{"k":"s","c":false,"f":{"content":[false,["n","s"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"rawContent":[false,["n","s"]],"score":[false,["n","f"]],"title":[false,["n","s"]],"url":[false,["n","s"]]}},"SessionCall":{"k":"s","c":false,"f":{"callId":[true,"s"],"recordedAt":[true,"s"],"step":[true,["i",true,32]]}},"SessionChainView":{"k":"s","c":false,"f":{"breaks":[true,["a",["r","PrefixBreak"]]],"prefixStability":[true,"f"],"recordIds":[true,["a","s"]],"sessionId":[true,"s"]}},"SessionSource":{"k":"e","v":["Explicit","Inferred"]},"SessionStepStat":{"k":"s","c":false,"f":{"callId":[true,"s"],"error":[false,["n","s"]],"hitRate":[false,["n","f"]],"step":[true,["i",true,32]],"verdict":[false,["n",["r","Verdict"]]]}},"SessionStoreCallsParams":{"k":"s","c":true,"f":{"sessionId":[true,"s"]}},"SessionStoreCreateParams":{"k":"s","c":true,"f":{"infer":[true,"b"]}},"SessionStoreHandle":{"k":"s","c":false,"f":{"handle":[true,["r","HandleId"]]}},"SessionView":{"k":"s","c":false,"f":{"calls":[true,["a",["r","SessionCall"]]],"sessionId":[true,"s"],"source":[true,["r","SessionSource"]]}},"SettingFieldKind":{"k":"e","v":["string","credential","boolean","headerMap","stringMap","codexMode"]},"SettingFieldSpec":{"k":"s","c":true,"f":{"credential":[true,"b"],"envVar":[false,["n","s"]],"kind":[true,["r","SettingFieldKind"]],"name":[true,"s"],"required":[true,"b"]}},"Size":{"k":"a","t":"s"},"Source":{"k":"t","g":"sourceType","v":[{"tv":"url","c":false,"f":{"id":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]],"title":[false,["n","s"]],"url":[true,"s"]}},{"tv":"document","c":false,"f":{"filename":[false,["n","s"]],"id":[true,"s"],"mediaType":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]],"title":[true,"s"]}}]},"SourceError":{"k":"s","c":false,"f":{"cause":[false,["n",["r","SourceError"]]],"message":[true,"s"]}},"SpeechCallOptions":{"k":"s","c":true,"f":{"headers":[false,["n",["m","s"]]],"instructions":[false,["n","s"]],"language":[false,["n","s"]],"maxRetries":[false,["n",["i",true,32]]],"outputFormat":[false,["n","s"]],"providerOptions":[false,["n",["m",["m","j"]]]],"speed":[false,["n","f"]],"text":[true,"s"],"timeout":[false,["n",["r","TimeoutConfiguration"]]],"voice":[false,["n","s"]]}},"SpeechRequest":{"k":"s","c":false,"f":{"body":[false,"j"]}},"SpeechResponse":{"k":"s","c":false,"f":{"body":[false,"j"],"headers":[false,["n",["m","s"]]],"modelId":[false,["n","s"]],"timestamp":[false,["n",["r","Timestamp"]]]}},"SpeechResult":{"k":"s","c":false,"f":{"audio":[true,["r","AudioData"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"request":[false,["n",["r","SpeechRequest"]]],"response":[true,["r","SpeechResponse"]],"usage":[true,["n",["m","j"]]],"warnings":[true,["a",["r","Warning"]]]}},"StepModel":{"k":"s","c":false,"f":{"modelId":[true,"s"],"provider":[true,"s"]}},"StepResponse":{"k":"s","c":false,"f":{"body":[false,"j"],"headers":[false,["n",["m","s"]]],"id":[true,"s"],"messages":[true,["a",["r","ModelMessage"]]],"modelId":[true,"s"],"timestamp":[true,["r","Timestamp"]]}},"StepResponseInput":{"k":"s","c":false,"f":{"body":[false,"j"],"headers":[false,["n",["m","s"]]],"id":[true,"s"],"messages":[false,["a",["r","ModelMessage"]]],"modelId":[true,"s"],"timestamp":[true,["r","Timestamp"]]}},"StepResponseMetadata":{"k":"s","c":false,"f":{"headers":[false,["n",["m","s"]]],"id":[true,"s"],"modelId":[true,"s"],"timestamp":[true,["r","Timestamp"]]}},"StepResult":{"k":"s","c":false,"f":{"callId":[true,"s"],"content":[true,["a",["r","ContentPart"]]],"finishReason":[true,["r","FinishReasonUnified"]],"model":[true,["r","StepModel"]],"performance":[true,["r","StepResultPerformance"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"rawFinishReason":[false,["n","s"]],"request":[true,["r","RequestInfo"]],"response":[true,["r","StepResponse"]],"stepNumber":[true,["i",true,32]],"usage":[true,["r","LanguageModelUsage"]],"warnings":[true,["a",["r","Warning"]]]}},"StepResultInput":{"k":"s","c":false,"f":{"callId":[true,"s"],"content":[true,["a",["r","ContentPartInput"]]],"finishReason":[true,["r","FinishReasonUnified"]],"model":[true,["r","StepModel"]],"performance":[true,["r","StepResultPerformanceInput"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"rawFinishReason":[false,["n","s"]],"request":[false,["r","RequestInfo"]],"response":[true,["r","StepResponseInput"]],"stepNumber":[true,["i",true,32]],"usage":[true,["r","LanguageModelUsageInput"]],"warnings":[false,["a",["r","Warning"]]]}},"StepResultPerformance":{"k":"s","c":false,"f":{"effectiveOutputTokensPerSecond":[true,"f"],"effectiveTotalTokensPerSecond":[true,"f"],"inputTokensPerSecond":[false,["n","f"]],"outputTokensPerSecond":[false,["n","f"]],"responseTimeMs":[true,"f"],"stepTimeMs":[true,"f"],"timeBetweenOutputChunksMs":[false,["n",["r","OutputChunkTimingStats"]]],"timeToFirstOutputMs":[false,["n","f"]],"toolExecutionMs":[true,["m","f"]]}},"StepResultPerformanceInput":{"k":"s","c":false,"f":{"effectiveOutputTokensPerSecond":[true,"f"],"effectiveTotalTokensPerSecond":[true,"f"],"inputTokensPerSecond":[false,["n","f"]],"outputTokensPerSecond":[false,["n","f"]],"responseTimeMs":[true,"f"],"stepTimeMs":[true,"f"],"timeBetweenOutputChunksMs":[false,["n",["r","OutputChunkTimingStats"]]],"timeToFirstOutputMs":[false,["n","f"]],"toolExecutionMs":[false,["m","f"]]}},"Strategy":{"k":"t","g":"type","v":[{"tv":"rule","c":true,"f":{}},{"tv":"weighted","c":true,"f":{"weights":[true,["a","f"]]}}]},"StreamEvent":{"k":"u","b":[["r","TextStreamPart"],["r","ChatCompletionChunk"]]},"StreamFrame":{"k":"t","g":"type","v":[{"tv":"event","c":true,"f":{"event":[true,["r","StreamEvent"]],"seq":[true,"u64"]}},{"tv":"end","c":true,"f":{"error":[false,["n",["r","ErrorEnvelope"]]],"outcome":[true,["r","Outcome"]],"seq":[true,"u64"]}}]},"StreamOptions":{"k":"s","c":true,"f":{"includeReasoning":[false,"b"],"includeUsage":[false,"b"]}},"StringOrEnv":{"k":"u","b":["s",["r","EnvVarRef"]]},"TaggedRawToolCall":{"k":"s","c":false,"f":{"dynamic":[false,["n","b"]],"input":[true,"s"],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"],"type":[true,["l","tool-call"]]}},"TaggedToolResult":{"k":"s","c":false,"f":{"dynamic":[false,["n","b"]],"input":[false,"j"],"output":[true,"j"],"preliminary":[false,["n","b"]],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"],"type":[true,["l","tool-result"]]}},"TemplateParamDescriptor":{"k":"s","c":true,"f":{"envVar":[true,"s"],"name":[true,"s"]}},"TerminalSummary":{"k":"s","c":false,"f":{"error":[false,["n",["r","ErrorEnvelope"]]],"outcome":[true,["r","OperationOutcome"]]}},"TextPart":{"k":"s","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"text":[true,"s"]}},"TextRequest":{"k":"s","c":true,"f":{"abort":[false,["n",["r","HandleIdInput"]]],"options":[false,["r","Options"]],"prompt":[true,["r","ModelPrompt"]]}},"TextStreamPart":{"k":"t","g":"type","v":[{"tv":"text-start","c":false,"f":{"id":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]]}},{"tv":"text-end","c":false,"f":{"id":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]]}},{"tv":"text-delta","c":false,"f":{"id":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]],"text":[true,"s"]}},{"tv":"reasoning-start","c":false,"f":{"id":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]]}},{"tv":"reasoning-end","c":false,"f":{"id":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]]}},{"tv":"reasoning-delta","c":false,"f":{"id":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]],"text":[true,"s"]}},{"tv":"custom","c":false,"f":{"kind":[true,["r","NamespacedKind"]],"providerMetadata":[false,["n",["m",["m","j"]]]]}},{"tv":"tool-input-start","c":false,"f":{"dynamic":[false,["n","b"]],"id":[true,"s"],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"title":[false,["n","s"]],"toolName":[true,"s"]}},{"tv":"tool-input-end","c":false,"f":{"id":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]]}},{"tv":"tool-input-delta","c":false,"f":{"delta":[true,"s"],"id":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]]}},{"tv":"source","c":false,"f":{"id":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]],"sourceType":[true,["l","url"]],"title":[false,["n","s"]],"url":[true,"s"]}},{"tv":"source","c":false,"f":{"filename":[false,["n","s"]],"id":[true,"s"],"mediaType":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]],"sourceType":[true,["l","document"]],"title":[true,"s"]}},{"tv":"file","c":false,"f":{"file":[true,["r","GeneratedFile"]],"providerMetadata":[false,["n",["m",["m","j"]]]]}},{"tv":"reasoning-file","c":false,"f":{"file":[true,["r","GeneratedFile"]],"providerMetadata":[false,["n",["m",["m","j"]]]]}},{"tv":"tool-call","c":false,"f":{"dynamic":[false,["n","b"]],"error":[false,["n",["r","AiMuxError"]]],"input":[true,"j"],"invalid":[false,["n","b"]],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},{"tv":"tool-result","c":false,"f":{"dynamic":[false,["n","b"]],"input":[false,"j"],"output":[true,"j"],"preliminary":[false,["n","b"]],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},{"tv":"tool-error","c":false,"f":{"dynamic":[false,["n","b"]],"error":[true,"j"],"input":[false,"j"],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},{"tv":"tool-output-denied","c":false,"f":{"dynamic":[false,["n","b"]],"providerExecuted":[false,["n","b"]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},{"tv":"tool-approval-request","c":false,"f":{"approvalId":[true,"s"],"isAutomatic":[false,["n","b"]],"reason":[false,["n","s"]],"signature":[false,["n","s"]],"toolCall":[true,["r","TypedToolCall"]]}},{"tv":"tool-approval-response","c":false,"f":{"approvalId":[true,"s"],"approved":[true,"b"],"providerExecuted":[false,["n","b"]],"reason":[false,["n","s"]],"toolCall":[true,["r","TypedToolCall"]]}},{"tv":"start-step","c":false,"f":{"request":[true,["r","RequestInfo"]],"warnings":[true,["a",["r","Warning"]]]}},{"tv":"finish-step","c":false,"f":{"finishReason":[true,["r","FinishReasonUnified"]],"performance":[true,["r","StepResultPerformance"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"rawFinishReason":[false,["n","s"]],"response":[true,["r","StepResponseMetadata"]],"usage":[true,["r","LanguageModelUsage"]]}},{"tv":"start","c":false,"f":{}},{"tv":"finish","c":false,"f":{"finishReason":[true,["r","FinishReasonUnified"]],"rawFinishReason":[false,["n","s"]],"totalUsage":[true,["r","LanguageModelUsage"]]}},{"tv":"abort","c":false,"f":{"reason":[false,["n","s"]]}},{"tv":"error","c":false,"f":{"error":[true,["r","AiMuxError"]]}},{"tv":"raw","c":false,"f":{"rawValue":[true,"j"]}}]},"TimeoutConfiguration":{"k":"s","c":true,"f":{"chunkMs":[false,["n",["i",true,64]]],"firstChunkMs":[false,["n",["i",true,64]]],"stepMs":[false,["n",["i",true,64]]],"totalMs":[false,["n",["i",true,64]]]}},"Timestamp":{"k":"a","t":"s"},"TimingRecord":{"k":"s","c":false,"f":{"latencyMs":[true,["i",true,64]],"ttfbMs":[false,["n",["i",true,64]]]}},"Tool":{"k":"t","g":"type","v":[{"tv":"function","c":false,"f":{"description":[false,["n","s"]],"inputExamples":[false,["n",["a",["r","FunctionToolInputExample"]]]],"inputSchema":[true,"j"],"name":[true,"s"],"providerOptions":[false,["n",["m",["m","j"]]]],"strict":[false,["n","b"]]}},{"tv":"provider","c":false,"f":{"args":[true,["m","j"]],"id":[true,["r","NamespacedKind"]],"name":[true,"s"],"supportsDeferredResults":[false,["n","b"]]}}]},"ToolApprovalRequestOutput":{"k":"s","c":false,"f":{"approvalId":[true,"s"],"isAutomatic":[false,["n","b"]],"reason":[false,["n","s"]],"signature":[false,["n","s"]],"toolCall":[true,["r","TypedToolCall"]]}},"ToolApprovalRequestOutputInput":{"k":"s","c":false,"f":{"approvalId":[true,"s"],"isAutomatic":[false,["n","b"]],"reason":[false,["n","s"]],"signature":[false,["n","s"]],"toolCall":[true,["r","TypedToolCallInput"]]}},"ToolApprovalResponseOutput":{"k":"s","c":false,"f":{"approvalId":[true,"s"],"approved":[true,"b"],"providerExecuted":[false,["n","b"]],"reason":[false,["n","s"]],"toolCall":[true,["r","TypedToolCall"]]}},"ToolApprovalResponseOutputInput":{"k":"s","c":false,"f":{"approvalId":[true,"s"],"approved":[true,"b"],"providerExecuted":[false,["n","b"]],"reason":[false,["n","s"]],"toolCall":[true,["r","TypedToolCallInput"]]}},"ToolApprovalResponsePart":{"k":"s","c":false,"f":{"approvalId":[true,"s"],"approved":[true,"b"],"providerOptions":[false,["n",["m",["m","j"]]]],"reason":[false,["n","s"]]}},"ToolCall":{"k":"s","c":false,"f":{"dynamic":[false,["n","b"]],"error":[false,["n",["r","AiMuxError"]]],"input":[true,"j"],"invalid":[false,["n","b"]],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},"ToolCallInput":{"k":"s","c":false,"f":{"dynamic":[false,["n","b"]],"error":[false,["n",["r","AiMuxErrorInput"]]],"input":[true,"j"],"invalid":[false,["n","b"]],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},"ToolCallPart":{"k":"s","c":false,"f":{"input":[true,"j"],"providerExecuted":[false,["n","b"]],"providerOptions":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},"ToolCallRepairReply":{"k":"t","g":"type","v":[{"tv":"repaired","c":true,"f":{"toolCall":[true,["r","RepairedToolCall"]]}},{"tv":"unchanged","c":true,"f":{}},{"tv":"failed","c":true,"f":{"message":[true,"s"]}}]},"ToolChoice":{"k":"u","b":[["r","ToolChoiceMode"],["r","ToolChoiceTool"]]},"ToolChoiceMode":{"k":"e","v":["auto","none","required"]},"ToolChoiceTool":{"k":"s","c":false,"f":{"toolName":[true,"s"],"type":[true,["l","tool"]]}},"ToolChoiceViolationError":{"k":"s","c":false,"f":{"content":[true,["a",["r","GenerateContent"]]],"finishReason":[true,["r","FinishReasonUnified"]],"modelId":[true,"s"],"provider":[true,"s"],"toolChoice":[true,["r","LanguageModelV4ToolChoice"]]}},"ToolContentPart":{"k":"t","g":"type","v":[{"tv":"tool-result","c":false,"f":{"output":[true,["r","ToolResultOutput"]],"providerOptions":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[false,["n","s"]]}},{"tv":"tool-approval-response","c":false,"f":{"approvalId":[true,"s"],"approved":[true,"b"],"providerExecuted":[false,["n","b"]],"reason":[false,["n","s"]]}}]},"ToolOutputDenied":{"k":"s","c":false,"f":{"dynamic":[false,["n","b"]],"providerExecuted":[false,["n","b"]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},"ToolPart":{"k":"t","g":"type","v":[{"tv":"tool-result","c":false,"f":{"output":[true,["r","LanguageModelToolResultOutput"]],"providerOptions":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},{"tv":"tool-approval-response","c":false,"f":{"approvalId":[true,"s"],"approved":[true,"b"],"providerOptions":[false,["n",["m",["m","j"]]]],"reason":[false,["n","s"]]}}]},"ToolRepairApplyRequest":{"k":"s","c":true,"f":{"options":[false,["r","GenerateTextOptions"]],"reply":[true,["r","ToolCallRepairReply"]],"toolCall":[true,["r","ToolCallInput"]]}},"ToolRepairApplyResultRequest":{"k":"s","c":true,"f":{"options":[false,["r","GenerateTextOptions"]],"reply":[true,["r","ToolCallRepairReply"]],"result":[true,["r","GenerateTextResultInput"]],"toolCallId":[true,"s"]}},"ToolRepairContextRequest":{"k":"s","c":true,"f":{"options":[false,["r","GenerateTextOptions"]],"prompt":[true,["r","ModelPrompt"]],"toolCall":[true,["r","ToolCallInput"]]}},"ToolRepairContextResult":{"k":"a","t":["n",["r","ToolRepairContextSchema"]]},"ToolRepairContextSchema":{"k":"s","c":false,"f":{"error":[true,["r","AiMuxError"]],"inputSchema":[true,"j"],"instructions":[true,["n","s"]],"messages":[true,["a",["r","ModelMessage"]]],"toolCall":[true,["r","TaggedRawToolCall"]],"tools":[true,["a",["r","Tool"]]]}},"ToolResult":{"k":"s","c":false,"f":{"dynamic":[false,["n","b"]],"isError":[false,["n","b"]],"preliminary":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"result":[true,"j"],"toolCallId":[true,"s"],"toolName":[true,"s"]}},"ToolResultContent":{"k":"t","g":"type","v":[{"tv":"text","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"text":[true,"s"]}},{"tv":"file","c":false,"f":{"data":[true,["r","FileData"]],"filename":[false,["n","s"]],"mediaType":[true,"s"],"providerOptions":[false,["n",["m",["m","j"]]]]}},{"tv":"custom","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]]}}]},"ToolResultContentPart":{"k":"t","g":"type","v":[{"tv":"text","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"text":[true,"s"]}},{"tv":"file","c":false,"f":{"data":[true,["r","FileData"]],"filename":[false,["n","s"]],"mediaType":[true,"s"],"providerOptions":[false,["n",["m",["m","j"]]]]}},{"tv":"file-data","c":false,"f":{"data":[true,"s"],"filename":[false,["n","s"]],"mediaType":[true,"s"],"providerOptions":[false,["n",["m",["m","j"]]]]}},{"tv":"file-url","c":false,"f":{"mediaType":[false,["n","s"]],"providerOptions":[false,["n",["m",["m","j"]]]],"url":[true,"s"]}},{"tv":"file-id","c":false,"f":{"fileId":[true,["r","ToolResultFileId"]],"providerOptions":[false,["n",["m",["m","j"]]]]}},{"tv":"file-reference","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"providerReference":[true,["m","s"]]}},{"tv":"image-data","c":false,"f":{"data":[true,"s"],"mediaType":[true,"s"],"providerOptions":[false,["n",["m",["m","j"]]]]}},{"tv":"image-url","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"url":[true,"s"]}},{"tv":"image-file-id","c":false,"f":{"fileId":[true,["r","ToolResultFileId"]],"providerOptions":[false,["n",["m",["m","j"]]]]}},{"tv":"image-file-reference","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"providerReference":[true,["m","s"]]}},{"tv":"custom","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]]}}]},"ToolResultFileId":{"k":"u","b":["s",["m","s"]]},"ToolResultOutput":{"k":"t","g":"type","v":[{"tv":"text","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"value":[true,"s"]}},{"tv":"json","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"value":[true,"j"]}},{"tv":"execution-denied","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"reason":[false,["n","s"]]}},{"tv":"error-text","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"value":[true,"s"]}},{"tv":"error-json","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"value":[true,"j"]}},{"tv":"content","c":false,"f":{"value":[true,["a",["r","ToolResultContentPart"]]]}}]},"ToolResultPart":{"k":"s","c":false,"f":{"output":[true,["r","ToolResultOutput"]],"providerOptions":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[false,["n","s"]]}},"TraceAggregateFilter":{"k":"s","c":true,"f":{"model":[false,["n","s"]],"provider":[false,["n","s"]],"sessionId":[false,["n","s"]],"sinceUnixMs":[false,["n",["i",false,64]]]}},"TraceAggregateParams":{"k":"s","c":true,"f":{"filter":[false,["r","TraceAggregateFilter"]]}},"TraceAuditMode":{"k":"e","v":["off","shared","strict"]},"TraceCreateParams":{"k":"s","c":true,"f":{"auditMode":[false,["r","TraceAuditMode"]],"capacity":[false,["i",true,64]],"perScopeCapacity":[false,["i",true,64]]}},"TraceRecord":{"k":"s","c":false,"f":{"callId":[true,"s"],"error":[false,["n","s"]],"fingerprint":[true,["r","Fingerprint"]],"lcpTokenUpper":[false,["n",["i",true,64]]],"model":[true,"s"],"provider":[true,"s"],"requestCacheHints":[false,["n",["r","RequestCacheHints"]]],"requestId":[false,["n","s"]],"responseCacheHeaders":[false,["n",["m","s"]]],"sentAtUnixMs":[true,["i",false,64]],"sessionId":[false,["n","s"]],"ttftMs":[false,["n",["i",true,64]]],"usage":[true,["r","UsageSnapshot"]],"verdict":[false,["n",["r","Verdict"]]]}},"TraceSessionParams":{"k":"s","c":true,"f":{"sessionId":[true,"s"]}},"TraceStats":{"k":"s","c":false,"f":{"claimedCacheReadTotal":[true,["i",true,64]],"claimedCacheWriteTotal":[true,["i",true,64]],"clientUpperBoundHitRate":[false,["n","f"]],"errors":[true,["i",true,64]],"inputTokensTotal":[true,["i",true,64]],"model":[true,"s"],"provider":[true,"s"],"reportedHitRate":[false,["n","f"]],"requests":[true,["i",true,64]],"ttftP50Ms":[false,["n",["i",true,64]]],"ttftP95Ms":[false,["n",["i",true,64]]],"verdictCounts":[true,["m",["i",true,64]]]}},"TranscriptionCallOptions":{"k":"s","c":true,"f":{"audio":[true,["r","AudioInput"]],"headers":[false,["n",["m","s"]]],"maxRetries":[false,["n",["i",true,32]]],"mediaType":[true,"s"],"providerOptions":[false,["n",["m",["m","j"]]]],"timeout":[false,["n",["r","TimeoutConfiguration"]]]}},"TranscriptionRequest":{"k":"s","c":false,"f":{"body":[false,["n","s"]]}},"TranscriptionResponse":{"k":"s","c":false,"f":{"body":[false,"j"],"headers":[false,["n",["m","s"]]],"modelId":[false,["n","s"]],"timestamp":[false,["n",["r","Timestamp"]]]}},"TranscriptionResult":{"k":"s","c":false,"f":{"durationInSeconds":[false,["n","f"]],"language":[false,["n","s"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"request":[false,["n",["r","TranscriptionRequest"]]],"response":[true,["r","TranscriptionResponse"]],"segments":[true,["a",["r","TranscriptionSegment"]]],"text":[true,"s"],"warnings":[true,["a",["r","Warning"]]]}},"TranscriptionSegment":{"k":"s","c":false,"f":{"endSecond":[true,"f"],"startSecond":[true,"f"],"text":[true,"s"]}},"TranscriptionStartParams":{"k":"s","c":true,"f":{"abort":[false,["n",["r","HandleIdInput"]]],"headers":[false,["n",["m","s"]]],"includeRawChunks":[false,"b"],"inputAudioFormat":[false,["n",["r","InputAudioFormat"]]],"providerOptions":[false,["n",["m",["m","j"]]]],"timeout":[false,["n",["r","TimeoutConfiguration"]]]}},"TranscriptionStreamPart":{"k":"t","g":"type","v":[{"tv":"stream-start","c":false,"f":{"warnings":[true,["a",["r","Warning"]]]}},{"tv":"transcript-delta","c":false,"f":{"delta":[true,"s"],"id":[false,["n","s"]],"providerMetadata":[false,["n",["m",["m","j"]]]]}},{"tv":"transcript-partial","c":false,"f":{"channelIndex":[false,["n",["i",true,32]]],"durationInSeconds":[false,["n","f"]],"id":[false,["n","s"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"startSecond":[false,["n","f"]],"text":[true,"s"]}},{"tv":"transcript-final","c":false,"f":{"channelIndex":[false,["n",["i",true,32]]],"endSecond":[false,["n","f"]],"id":[false,["n","s"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"startSecond":[false,["n","f"]],"text":[true,"s"]}},{"tv":"response-metadata","c":false,"f":{"body":[false,"j"],"headers":[false,["n",["m","s"]]],"modelId":[false,["n","s"]],"timestamp":[false,["n",["r","Timestamp"]]]}},{"tv":"finish","c":false,"f":{"durationInSeconds":[false,["n","f"]],"language":[false,["n","s"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"segments":[true,["a",["r","TranscriptionSegment"]]],"text":[true,"s"]}},{"tv":"raw","c":false,"f":{"rawValue":[true,"j"]}},{"tv":"error","c":false,"f":{"error":[true,"j"]}}]},"TransportParams":{"k":"t","g":"kind","v":[{"tv":"fetch","c":true,"f":{"proxy":[false,["r","TransportProxy"]]}},{"tv":"ws","c":true,"f":{"proxy":[false,["r","TransportProxy"]]}},{"tv":"download","c":true,"f":{"maxBytes":[false,["n",["i",true,64]]]}}]},"TransportProxy":{"k":"s","c":true,"f":{"all_url":[false,["n","s"]],"http_url":[false,["n","s"]],"https_url":[false,["n","s"]],"no_proxy":[false,["n","s"]]}},"TypedSource":{"k":"t","g":"sourceType","v":[{"tv":"url","c":false,"f":{"id":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]],"title":[false,["n","s"]],"type":[true,["l","source"]],"url":[true,"s"]}},{"tv":"document","c":false,"f":{"filename":[false,["n","s"]],"id":[true,"s"],"mediaType":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]],"title":[true,"s"],"type":[true,["l","source"]]}}]},"TypedToolCall":{"k":"s","c":false,"f":{"dynamic":[false,["n","b"]],"error":[false,["n",["r","AiMuxError"]]],"input":[true,"j"],"invalid":[false,["n","b"]],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"],"type":[true,["l","tool-call"]]}},"TypedToolCallInput":{"k":"s","c":false,"f":{"dynamic":[false,["n","b"]],"error":[false,["n",["r","AiMuxErrorInput"]]],"input":[true,"j"],"invalid":[false,["n","b"]],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"],"type":[false,["l","tool-call"]]}},"TypedToolError":{"k":"s","c":false,"f":{"dynamic":[false,["n","b"]],"error":[true,"j"],"input":[false,"j"],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},"TypedToolResult":{"k":"s","c":false,"f":{"dynamic":[false,["n","b"]],"input":[false,"j"],"output":[true,"j"],"preliminary":[false,["n","b"]],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},"UploadFileData":{"k":"t","g":"type","v":[{"tv":"data","c":true,"f":{"data":[true,["r","FileBytes"]]}},{"tv":"text","c":true,"f":{"text":[true,"s"]}}]},"UploadFileParams":{"k":"s","c":true,"f":{"abort":[false,["n",["r","HandleIdInput"]]],"data":[true,["r","UploadFileData"]],"filename":[false,["n","s"]],"mediaType":[true,"s"],"providerOptions":[false,["n",["m",["m","j"]]]]}},"UploadFileResult":{"k":"s","c":false,"f":{"filename":[false,["n","s"]],"mediaType":[false,["n","s"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"providerReference":[true,["m","s"]],"warnings":[true,["a",["r","Warning"]]]}},"UsageSnapshot":{"k":"s","c":false,"f":{"cacheRead":[false,["n",["i",true,64]]],"cacheWrite":[false,["n",["i",true,64]]],"inputNoCache":[false,["n",["i",true,64]]],"inputTotal":[false,["n",["i",true,64]]],"outputReasoning":[false,["n",["i",true,64]]],"outputText":[false,["n",["i",true,64]]],"outputTotal":[false,["n",["i",true,64]]],"raw":[false,"j"]}},"UserContent":{"k":"u","b":["s",["a",["r","UserContentPart"]]]},"UserContentPart":{"k":"t","g":"type","v":[{"tv":"text","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"text":[true,"s"]}},{"tv":"image","c":false,"f":{"image":[true,"s"],"mediaType":[true,"s"],"providerOptions":[false,["n",["m",["m","j"]]]]}},{"tv":"file","c":false,"f":{"data":[true,["r","FilePartData"]],"filename":[false,["n","s"]],"mediaType":[true,"s"],"providerOptions":[false,["n",["m",["m","j"]]]]}}]},"UserPart":{"k":"t","g":"type","v":[{"tv":"text","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"text":[true,"s"]}},{"tv":"file","c":false,"f":{"data":[true,["r","FileData"]],"filename":[false,["n","s"]],"mediaType":[true,"s"],"providerOptions":[false,["n",["m",["m","j"]]]]}}]},"Verdict":{"k":"s","c":false,"f":{"claimed":[true,["i",true,64]],"confidence":[true,["r","VerdictConfidence"]],"expectedMax":[true,["i",true,64]],"kind":[true,["r","VerdictKind"]],"lcpBytes":[true,["i",true,64]],"notes":[true,["a","s"]],"violated":[true,["a","s"]]}},"VerdictConfidence":{"k":"e","v":["High","Medium","Low"]},"VerdictKind":{"k":"e","v":["Trusted","SuspectOverclaim","SuspectUnderclaim","Unknown"]},"VideoCallOptions":{"k":"s","c":true,"f":{"aspectRatio":[false,["n",["r","AspectRatio"]]],"duration":[false,["n",["i",true,32]]],"fps":[false,["n",["i",true,32]]],"frameImages":[false,["n",["a",["r","VideoFrameImage"]]]],"generateAudio":[false,["n","b"]],"headers":[false,["n",["m","s"]]],"image":[false,["n",["r","VideoFile"]]],"inputReferences":[false,["n",["a",["r","VideoFile"]]]],"maxRetries":[false,["n",["i",true,32]]],"n":[false,["i",true,32]],"poll":[false,["n",["r","VideoPollOptions"]]],"prompt":[false,["n","s"]],"providerOptions":[false,["m",["m","j"]]],"resolution":[false,["n",["r","Size"]]],"seed":[false,["n",["i",true,64]]],"timeout":[false,["n",["r","TimeoutConfiguration"]]]}},"VideoData":{"k":"t","g":"type","v":[{"tv":"url","c":false,"f":{"mediaType":[true,"s"],"url":[true,"s"]}},{"tv":"base64","c":false,"f":{"data":[true,"s"],"mediaType":[true,"s"]}},{"tv":"binary","c":false,"f":{"data":[true,"s"],"mediaType":[true,"s"]}}]},"VideoFile":{"k":"t","g":"type","v":[{"tv":"file","c":false,"f":{"data":[true,["r","VideoFileData"]],"mediaType":[true,"s"]}},{"tv":"url","c":false,"f":{"mediaType":[false,["n","s"]],"url":[true,"s"]}}]},"VideoFileData":{"k":"a","t":"s"},"VideoFrameImage":{"k":"s","c":false,"f":{"frameType":[true,["r","VideoFrameType"]],"image":[true,["r","VideoFile"]]}},"VideoFrameType":{"k":"e","v":["first_frame","last_frame"]},"VideoPollOptions":{"k":"s","c":true,"f":{"intervalMs":[false,["n",["i",true,64]]],"timeoutMs":[false,["n",["i",true,64]]]}},"VideoResponse":{"k":"s","c":false,"f":{"headers":[false,["n",["m","s"]]],"modelId":[false,["n","s"]],"timestamp":[false,["n",["r","Timestamp"]]]}},"VideoResult":{"k":"s","c":false,"f":{"providerMetadata":[false,["n",["m",["m","j"]]]],"response":[true,["r","VideoResponse"]],"videos":[true,["a",["r","VideoData"]]],"warnings":[true,["a",["r","Warning"]]]}},"Warning":{"k":"t","g":"type","v":[{"tv":"unsupported","c":false,"f":{"details":[false,["n","s"]],"feature":[true,"s"]}},{"tv":"compatibility","c":false,"f":{"details":[false,["n","s"]],"feature":[true,"s"]}},{"tv":"deprecated","c":false,"f":{"message":[true,"s"],"setting":[true,"s"]}},{"tv":"other","c":false,"f":{"message":[true,"s"]}}]}} +const dtoSchemas: Record = {"AiMuxError":{"k":"t","g":"name","v":[{"tv":"AI_APICallError","c":false,"f":{"cause":[false,["n",["r","ErrorCause"]]],"data":[false,"j"],"isRetryable":[true,"b"],"message":[true,"s"],"origin":[false,["r","ApiCallErrorOrigin"]],"providerCode":[false,["n","s"]],"requestBodyValues":[true,"j"],"responseBody":[false,["n","s"]],"responseHeaders":[false,["n",["m","s"]]],"statusCode":[false,["n",["i",true,16]]],"url":[true,"s"]}},{"tv":"AI_RetryError","c":false,"f":{"errors":[true,["a",["r","AiMuxError"]]],"reason":[true,["r","RetryErrorReason"]]}},{"tv":"AI_JSONParseError","c":false,"f":{"cause":[false,["n",["r","ErrorCause"]]],"message":[true,"s"]}},{"tv":"AI_NoOutputGeneratedError","c":false,"f":{"cause":[false,["n",["r","ErrorCause"]]],"message":[true,"s"]}},{"tv":"AI_InvalidResponseDataError","c":false,"f":{"cause":[false,["n",["r","ErrorCause"]]],"message":[true,"s"]}},{"tv":"AI_TypeValidationError","c":false,"f":{"cause":[false,["n",["r","ErrorCause"]]],"message":[true,"s"],"value":[true,"j"]}},{"tv":"AI_ToolCallNotFoundForApprovalError","c":false,"f":{"approvalId":[true,"s"],"toolCallId":[true,"s"]}},{"tv":"AI_NoSuchToolError","c":false,"f":{"availableTools":[false,["n",["a","s"]]],"toolInput":[false,["n","s"]],"toolName":[true,"s"]}},{"tv":"AI_InvalidToolInputError","c":false,"f":{"cause":[true,["r","ErrorCause"]],"toolInput":[true,"s"],"toolName":[true,"s"]}},{"tv":"AI_ToolCallRepairError","c":false,"f":{"cause":[true,["r","AiMuxError"]],"originalError":[true,["r","AiMuxError"]]}},{"tv":"AI_InvalidArgumentError","c":false,"f":{"cause":[false,["n",["r","ErrorCause"]]],"message":[true,"s"]}},{"tv":"AI_InvalidPromptError","c":false,"f":{"cause":[false,["n",["r","ErrorCause"]]],"message":[true,"s"]}},{"tv":"AI_LoadAPIKeyError","c":false,"f":{"description":[true,"s"],"envVar":[true,"s"]}},{"tv":"AI_LoadSettingError","c":false,"f":{"envVar":[true,"s"],"settingName":[true,"s"]}},{"tv":"AI_TokenExpiredError","c":false,"f":{"message":[true,"s"]}},{"tv":"AI_UnsupportedFunctionalityError","c":false,"f":{"message":[true,"s"]}},{"tv":"AI_NoSuchModelError","c":false,"f":{"modelId":[true,"s"],"modelType":[true,"s"]}},{"tv":"AI_NoSuchProviderError","c":false,"f":{"availableProviders":[true,["a","s"]],"modelId":[true,"s"],"modelType":[true,"s"],"providerId":[true,"s"]}},{"tv":"AI_MissingToolResultsError","c":false,"f":{"toolCallIds":[true,["a","s"]]}},{"tv":"AI_ToolChoiceViolationError","c":false,"f":{"content":[true,["a",["r","GenerateContent"]]],"finishReason":[true,["r","FinishReasonUnified"]],"modelId":[true,"s"],"provider":[true,"s"],"toolChoice":[true,["r","LanguageModelV4ToolChoice"]]}},{"tv":"TimeoutError","c":false,"f":{"message":[true,"s"]}},{"tv":"AbortError","c":false,"f":{"message":[true,"s"]}},{"tv":"AI_Error","c":false,"f":{"cause":[false,["n",["r","ErrorCause"]]],"message":[true,"s"]}}]},"AiMuxErrorInput":{"k":"t","g":"name","v":[{"tv":"AI_APICallError","c":false,"f":{"cause":[false,["n",["r","ErrorCauseInput"]]],"data":[false,"j"],"isRetryable":[false,"b"],"message":[true,"s"],"origin":[false,["r","ApiCallErrorOrigin"]],"providerCode":[false,["n","s"]],"requestBodyValues":[true,"j"],"responseBody":[false,["n","s"]],"responseHeaders":[false,["n",["m","s"]]],"statusCode":[false,["n",["i",true,16]]],"url":[true,"s"]}},{"tv":"AI_RetryError","c":false,"f":{"errors":[true,["a",["r","AiMuxErrorInput"]]],"reason":[true,["r","RetryErrorReason"]]}},{"tv":"AI_JSONParseError","c":false,"f":{"cause":[false,["n",["r","ErrorCauseInput"]]],"message":[true,"s"]}},{"tv":"AI_NoOutputGeneratedError","c":false,"f":{"cause":[false,["n",["r","ErrorCauseInput"]]],"message":[true,"s"]}},{"tv":"AI_InvalidResponseDataError","c":false,"f":{"cause":[false,["n",["r","ErrorCauseInput"]]],"message":[true,"s"]}},{"tv":"AI_TypeValidationError","c":false,"f":{"cause":[false,["n",["r","ErrorCauseInput"]]],"message":[true,"s"],"value":[true,"j"]}},{"tv":"AI_ToolCallNotFoundForApprovalError","c":false,"f":{"approvalId":[true,"s"],"toolCallId":[true,"s"]}},{"tv":"AI_NoSuchToolError","c":false,"f":{"availableTools":[false,["n",["a","s"]]],"toolInput":[false,["n","s"]],"toolName":[true,"s"]}},{"tv":"AI_InvalidToolInputError","c":false,"f":{"cause":[true,["r","ErrorCauseInput"]],"toolInput":[true,"s"],"toolName":[true,"s"]}},{"tv":"AI_ToolCallRepairError","c":false,"f":{"cause":[true,["r","AiMuxErrorInput"]],"originalError":[true,["r","AiMuxErrorInput"]]}},{"tv":"AI_InvalidArgumentError","c":false,"f":{"cause":[false,["n",["r","ErrorCauseInput"]]],"message":[true,"s"]}},{"tv":"AI_InvalidPromptError","c":false,"f":{"cause":[false,["n",["r","ErrorCauseInput"]]],"message":[true,"s"]}},{"tv":"AI_LoadAPIKeyError","c":false,"f":{"description":[true,"s"],"envVar":[true,"s"]}},{"tv":"AI_LoadSettingError","c":false,"f":{"envVar":[true,"s"],"settingName":[true,"s"]}},{"tv":"AI_TokenExpiredError","c":false,"f":{"message":[true,"s"]}},{"tv":"AI_UnsupportedFunctionalityError","c":false,"f":{"message":[true,"s"]}},{"tv":"AI_NoSuchModelError","c":false,"f":{"modelId":[true,"s"],"modelType":[false,"s"]}},{"tv":"AI_NoSuchProviderError","c":false,"f":{"availableProviders":[true,["a","s"]],"modelId":[true,"s"],"modelType":[true,"s"],"providerId":[true,"s"]}},{"tv":"AI_MissingToolResultsError","c":false,"f":{"toolCallIds":[true,["a","s"]]}},{"tv":"AI_ToolChoiceViolationError","c":false,"f":{"content":[true,["a",["r","GenerateContent"]]],"finishReason":[true,["r","FinishReasonUnified"]],"modelId":[true,"s"],"provider":[true,"s"],"toolChoice":[true,["r","LanguageModelV4ToolChoice"]]}},{"tv":"TimeoutError","c":false,"f":{"message":[true,"s"]}},{"tv":"AbortError","c":false,"f":{"message":[true,"s"]}},{"tv":"AI_Error","c":false,"f":{"cause":[false,["n",["r","ErrorCauseInput"]]],"message":[true,"s"]}}]},"ApiCallError":{"k":"s","c":false,"f":{"cause":[false,["n",["r","ErrorCause"]]],"data":[false,"j"],"isRetryable":[true,"b"],"message":[true,"s"],"origin":[false,["r","ApiCallErrorOrigin"]],"providerCode":[false,["n","s"]],"requestBodyValues":[true,"j"],"responseBody":[false,["n","s"]],"responseHeaders":[false,["n",["m","s"]]],"statusCode":[false,["n",["i",true,16]]],"url":[true,"s"]}},"ApiCallErrorInput":{"k":"s","c":false,"f":{"cause":[false,["n",["r","ErrorCauseInput"]]],"data":[false,"j"],"isRetryable":[false,"b"],"message":[true,"s"],"origin":[false,["r","ApiCallErrorOrigin"]],"providerCode":[false,["n","s"]],"requestBodyValues":[true,"j"],"responseBody":[false,["n","s"]],"responseHeaders":[false,["n",["m","s"]]],"statusCode":[false,["n",["i",true,16]]],"url":[true,"s"]}},"ApiCallErrorOrigin":{"k":"e","v":["transport","httpResponse","streamEvent","local","unknown"]},"AspectRatio":{"k":"a","t":"s"},"AssistantContent":{"k":"u","b":["s",["a",["r","AssistantContentPart"]]]},"AssistantContentPart":{"k":"t","g":"type","v":[{"tv":"text","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"text":[true,"s"]}},{"tv":"custom","c":false,"f":{"kind":[true,["r","NamespacedKind"]],"providerOptions":[false,["n",["m",["m","j"]]]]}},{"tv":"file","c":false,"f":{"data":[true,["r","FilePartData"]],"filename":[false,["n","s"]],"mediaType":[true,"s"],"providerOptions":[false,["n",["m",["m","j"]]]]}},{"tv":"reasoning","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"text":[true,"s"]}},{"tv":"reasoning-file","c":false,"f":{"data":[true,["r","ReasoningFilePartData"]],"mediaType":[true,"s"],"providerOptions":[false,["n",["m",["m","j"]]]]}},{"tv":"tool-call","c":false,"f":{"input":[true,"j"],"providerExecuted":[false,["n","b"]],"providerOptions":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},{"tv":"tool-result","c":false,"f":{"output":[true,["r","ToolResultOutput"]],"providerOptions":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[false,["n","s"]]}},{"tv":"tool-approval-request","c":false,"f":{"approvalId":[true,"s"],"inputSchemaInput":[false,"j"],"isAutomatic":[false,["n","b"]],"reason":[false,["n","s"]],"signature":[false,["n","s"]],"toolCallId":[true,"s"]}}]},"AssistantPart":{"k":"t","g":"type","v":[{"tv":"text","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"text":[true,"s"]}},{"tv":"file","c":false,"f":{"data":[true,["r","FileData"]],"filename":[false,["n","s"]],"mediaType":[true,"s"],"providerOptions":[false,["n",["m",["m","j"]]]]}},{"tv":"reasoning","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"text":[true,"s"]}},{"tv":"reasoning-file","c":false,"f":{"data":[true,["r","GeneratedFileData"]],"mediaType":[true,"s"],"providerOptions":[false,["n",["m",["m","j"]]]]}},{"tv":"custom","c":false,"f":{"kind":[true,["r","NamespacedKind"]],"providerOptions":[false,["n",["m",["m","j"]]]]}},{"tv":"tool-call","c":false,"f":{"input":[true,"j"],"providerExecuted":[false,["n","b"]],"providerOptions":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},{"tv":"tool-result","c":false,"f":{"output":[true,["r","LanguageModelToolResultOutput"]],"providerOptions":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}}]},"AudioData":{"k":"a","t":"s"},"AudioInput":{"k":"a","t":"s"},"BackendConfig":{"k":"t","g":"type","v":[{"tv":"ring","c":true,"f":{"capacity":[false,["n",["i",true,64]]]}},{"tv":"jsonl","c":true,"f":{"directory":[true,"s"]}}]},"BreakKind":{"k":"e","v":["SystemChanged","ToolsChanged","ConversationReset","Unknown"]},"CancelResult":{"k":"e","v":["first","alreadyRequested","alreadyTerminal"]},"CapturePolicy":{"k":"e","v":["full"]},"Catalogue":{"k":"s","c":false,"f":{"specs":[true,["m",["m",["r","ModelSpec"]]]],"unmapped":[false,["m",["m",["r","ModelSpec"]]]],"updatedAt":[true,["i",true,64]]}},"CatalogueFetchRequest":{"k":"s","c":true,"f":{"abort":[false,["n",["r","HandleIdInput"]]],"sourceUrl":[false,["n","s"]]}},"CatalogueSource":{"k":"e","v":["Anya2a","ModelsDev","Manual"]},"ChatCompletion":{"k":"s","c":false,"f":{"choices":[true,["a",["r","ChatCompletionChoice"]]],"created":[true,["i",true,64]],"id":[true,"s"],"model":[true,"s"],"object":[true,"s"],"system_fingerprint":[false,["n","s"]],"usage":[true,["r","ChatCompletionUsage"]]}},"ChatCompletionChoice":{"k":"s","c":false,"f":{"finish_reason":[true,["n","s"]],"index":[true,["i",true,32]],"logprobs":[false,"j"],"message":[true,["r","ChatCompletionMessage"]]}},"ChatCompletionChunk":{"k":"s","c":false,"f":{"choices":[true,["a",["r","ChatCompletionChunkChoice"]]],"created":[true,["i",true,64]],"id":[true,"s"],"model":[true,"s"],"object":[true,"s"],"usage":[false,["n",["r","ChatCompletionUsage"]]]}},"ChatCompletionChunkChoice":{"k":"s","c":false,"f":{"delta":[true,["r","ChatCompletionDelta"]],"finish_reason":[true,["n","s"]],"index":[true,["i",true,32]],"logprobs":[false,"j"]}},"ChatCompletionChunkFunction":{"k":"s","c":false,"f":{"arguments":[false,["n","s"]],"name":[false,["n","s"]]}},"ChatCompletionChunkToolCall":{"k":"s","c":false,"f":{"function":[true,["r","ChatCompletionChunkFunction"]],"id":[false,["n","s"]],"index":[true,["i",true,32]],"type":[false,["n","s"]]}},"ChatCompletionDelta":{"k":"s","c":false,"f":{"content":[false,["n","s"]],"reasoning_content":[false,["n","s"]],"role":[false,["n","s"]],"tool_calls":[false,["n",["a",["r","ChatCompletionChunkToolCall"]]]]}},"ChatCompletionFunction":{"k":"s","c":false,"f":{"arguments":[true,"s"],"name":[true,"s"]}},"ChatCompletionMessage":{"k":"s","c":false,"f":{"annotations":[false,["n",["a","j"]]],"content":[true,["n","s"]],"reasoning_content":[false,["n","s"]],"role":[true,"s"],"tool_calls":[false,["n",["a",["r","ChatCompletionToolCall"]]]]}},"ChatCompletionToolCall":{"k":"s","c":false,"f":{"function":[true,["r","ChatCompletionFunction"]],"id":[true,"s"],"type":[true,"s"]}},"ChatCompletionUsage":{"k":"s","c":false,"f":{"completion_tokens":[true,["i",true,32]],"completion_tokens_details":[false,["n",["r","CompletionTokensDetails"]]],"prompt_tokens":[true,["i",true,32]],"prompt_tokens_details":[false,["n",["r","PromptTokensDetails"]]],"total_tokens":[true,["i",true,32]]}},"CodexModeSpec":{"k":"t","g":"type","v":[{"tv":"apiKey","c":true,"f":{"apiKey":[false,["n",["r","StringOrEnv"]]]}},{"tv":"chatGptAccount","c":true,"f":{"accountId":[false,["n","s"]],"token":[true,["r","StringOrEnv"]]}}]},"CodexRefreshRequest":{"k":"s","c":true,"f":{"clientId":[true,"s"],"refreshToken":[true,"s"]}},"CodexTokens":{"k":"s","c":false,"f":{"access_token":[true,"s"],"expires_in_secs":[true,["n",["i",true,64]]],"refresh_token":[true,["n","s"]]}},"CompletionTokensDetails":{"k":"s","c":false,"f":{"reasoning_tokens":[false,["n",["i",true,32]]]}},"ContentPart":{"k":"t","g":"type","v":[{"tv":"text","c":false,"f":{"providerMetadata":[false,["n",["m",["m","j"]]]],"text":[true,"s"]}},{"tv":"custom","c":false,"f":{"kind":[true,["r","NamespacedKind"]],"providerMetadata":[false,["n",["m",["m","j"]]]]}},{"tv":"reasoning","c":false,"f":{"providerMetadata":[false,["n",["m",["m","j"]]]],"text":[true,"s"]}},{"tv":"reasoning-file","c":false,"f":{"file":[true,["r","GeneratedFile"]],"providerMetadata":[false,["n",["m",["m","j"]]]]}},{"tv":"source","c":false,"f":{"id":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]],"sourceType":[true,["l","url"]],"title":[false,["n","s"]],"url":[true,"s"]}},{"tv":"source","c":false,"f":{"filename":[false,["n","s"]],"id":[true,"s"],"mediaType":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]],"sourceType":[true,["l","document"]],"title":[true,"s"]}},{"tv":"file","c":false,"f":{"file":[true,["r","GeneratedFile"]],"providerMetadata":[false,["n",["m",["m","j"]]]]}},{"tv":"tool-call","c":false,"f":{"dynamic":[false,["n","b"]],"error":[false,["n",["r","AiMuxError"]]],"input":[true,"j"],"invalid":[false,["n","b"]],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},{"tv":"tool-result","c":false,"f":{"dynamic":[false,["n","b"]],"input":[false,"j"],"output":[true,"j"],"preliminary":[false,["n","b"]],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},{"tv":"tool-error","c":false,"f":{"dynamic":[false,["n","b"]],"error":[true,"j"],"input":[false,"j"],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},{"tv":"tool-approval-request","c":false,"f":{"approvalId":[true,"s"],"isAutomatic":[false,["n","b"]],"reason":[false,["n","s"]],"signature":[false,["n","s"]],"toolCall":[true,["r","TypedToolCall"]]}},{"tv":"tool-approval-response","c":false,"f":{"approvalId":[true,"s"],"approved":[true,"b"],"providerExecuted":[false,["n","b"]],"reason":[false,["n","s"]],"toolCall":[true,["r","TypedToolCall"]]}}]},"ContentPartInput":{"k":"t","g":"type","v":[{"tv":"text","c":false,"f":{"providerMetadata":[false,["n",["m",["m","j"]]]],"text":[true,"s"]}},{"tv":"custom","c":false,"f":{"kind":[true,["r","NamespacedKind"]],"providerMetadata":[false,["n",["m",["m","j"]]]]}},{"tv":"reasoning","c":false,"f":{"providerMetadata":[false,["n",["m",["m","j"]]]],"text":[true,"s"]}},{"tv":"reasoning-file","c":false,"f":{"file":[true,["r","GeneratedFile"]],"providerMetadata":[false,["n",["m",["m","j"]]]]}},{"tv":"source","c":false,"f":{"id":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]],"sourceType":[true,["l","url"]],"title":[false,["n","s"]],"url":[true,"s"]}},{"tv":"source","c":false,"f":{"filename":[false,["n","s"]],"id":[true,"s"],"mediaType":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]],"sourceType":[true,["l","document"]],"title":[true,"s"]}},{"tv":"file","c":false,"f":{"file":[true,["r","GeneratedFile"]],"providerMetadata":[false,["n",["m",["m","j"]]]]}},{"tv":"tool-call","c":false,"f":{"dynamic":[false,["n","b"]],"error":[false,["n",["r","AiMuxErrorInput"]]],"input":[true,"j"],"invalid":[false,["n","b"]],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},{"tv":"tool-result","c":false,"f":{"dynamic":[false,["n","b"]],"input":[false,"j"],"output":[true,"j"],"preliminary":[false,["n","b"]],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},{"tv":"tool-error","c":false,"f":{"dynamic":[false,["n","b"]],"error":[true,"j"],"input":[false,"j"],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},{"tv":"tool-approval-request","c":false,"f":{"approvalId":[true,"s"],"isAutomatic":[false,["n","b"]],"reason":[false,["n","s"]],"signature":[false,["n","s"]],"toolCall":[true,["r","TypedToolCallInput"]]}},{"tv":"tool-approval-response","c":false,"f":{"approvalId":[true,"s"],"approved":[true,"b"],"providerExecuted":[false,["n","b"]],"reason":[false,["n","s"]],"toolCall":[true,["r","TypedToolCallInput"]]}}]},"CreateRecorderParams":{"k":"s","c":true,"f":{"backend":[true,["r","BackendConfig"]],"capturePolicy":[true,["r","CapturePolicy"]]}},"CredentialParams":{"k":"s","c":true,"f":{"kind":[true,"s"]}},"CustomPart":{"k":"s","c":false,"f":{"kind":[true,["r","NamespacedKind"]],"providerOptions":[false,["n",["m",["m","j"]]]]}},"DecideOptions":{"k":"s","c":true,"f":{"headers":[false,["n",["m","s"]]],"maxRetries":[false,["n",["i",true,32]]],"providerOptions":[false,["n",["m",["m","j"]]]],"questions":[true,["m",["r","DecisionQuestion"]]],"state":[true,["r","DecisionInput"]],"timeout":[false,["n",["r","TimeoutConfiguration"]]]}},"DecideResult":{"k":"s","c":false,"f":{"answers":[true,["m",["r","DecisionAnswer"]]],"providerMetadata":[false,["n",["m",["m","j"]]]],"response":[true,["r","ResponseInfo"]],"rounding":[false,["n",["r","DecisionRounding"]]],"usage":[true,["r","DecideUsage"]],"warnings":[true,["a",["r","Warning"]]]}},"DecideUsage":{"k":"s","c":false,"f":{"inputTokens":[false,["n",["i",true,32]]],"outputTokens":[false,["n",["i",true,32]]],"totalTokens":[false,["n",["i",true,32]]]}},"DecisionAnswer":{"k":"t","g":"type","v":[{"tv":"choice","c":false,"f":{"choice":[true,"s"],"probabilities":[false,["n",["m","f"]]]}},{"tv":"score","c":false,"f":{"probabilities":[false,["n",["m","f"]]],"score":[true,"f"]}},{"tv":"boolean","c":false,"f":{"probability":[true,"f"]}}]},"DecisionBooleanCriteria":{"k":"s","c":true,"f":{"false":[false,["n",["r","DecisionInput"]]],"true":[false,["n",["r","DecisionInput"]]]}},"DecisionDecideRequest":{"k":"s","c":true,"f":{"abort":[false,["n",["r","HandleIdInput"]]],"options":[true,["r","DecideOptions"]]}},"DecisionInput":{"k":"u","b":["s",["m","j"],["a","j"]]},"DecisionQuestion":{"k":"t","g":"type","v":[{"tv":"choice","c":false,"f":{"criteria":[true,["m",["n",["r","DecisionInput"]]]],"instructions":[true,["r","DecisionInput"]]}},{"tv":"score","c":false,"f":{"criteria":[true,["a",["n",["r","DecisionInput"]]]],"instructions":[true,["r","DecisionInput"]]}},{"tv":"boolean","c":false,"f":{"criteria":[false,["n",["r","DecisionBooleanCriteria"]]],"instructions":[true,["r","DecisionInput"]]}}]},"DecisionRounding":{"k":"s","c":false,"f":{"probabilityDecimals":[false,["n",["i",true,32]]],"scoreDecimals":[false,["n",["i",true,32]]]}},"EmbeddingCallOptions":{"k":"s","c":true,"f":{"headers":[false,["n",["m","s"]]],"maxRetries":[false,["n",["i",true,32]]],"providerOptions":[false,["n",["m",["m","j"]]]],"timeout":[false,["n",["r","TimeoutConfiguration"]]],"values":[true,["a","s"]]}},"EmbeddingResponse":{"k":"s","c":false,"f":{"body":[false,"j"],"headers":[false,["n",["m","s"]]]}},"EmbeddingResult":{"k":"s","c":false,"f":{"embeddings":[true,["a",["a","f"]]],"providerMetadata":[false,["n",["m",["m","j"]]]],"response":[false,["n",["r","EmbeddingResponse"]]],"usage":[false,["n",["r","EmbeddingUsage"]]],"warnings":[true,["a",["r","Warning"]]]}},"EmbeddingUsage":{"k":"s","c":false,"f":{"tokens":[true,["i",true,32]]}},"EmptyParams":{"k":"s","c":true,"f":{}},"EnvVarRef":{"k":"s","c":true,"f":{"env":[true,"s"]}},"ErrorCause":{"k":"u","b":[["r","AiMuxError"],["r","SourceError"]]},"ErrorCauseInput":{"k":"u","b":[["r","AiMuxErrorInput"],["r","SourceError"]]},"ErrorDomain":{"k":"e","v":["aimux","recording","binding","protocol"]},"ErrorEnvelope":{"k":"s","c":false,"f":{"code":[true,["i",false,32]],"error":[true,"j"],"kind":[true,["r","ErrorDomain"]],"message":[true,"s"]}},"Fallback":{"k":"e","v":["on-error","none"]},"FileBytes":{"k":"a","t":"s"},"FileData":{"k":"t","g":"type","v":[{"tv":"data","c":false,"f":{"data":[true,["r","FileBytes"]]}},{"tv":"url","c":false,"f":{"originalUrl":[false,["n","s"]],"url":[true,"s"]}},{"tv":"reference","c":false,"f":{"reference":[true,["m","s"]]}},{"tv":"text","c":false,"f":{"text":[true,"s"]}}]},"FilePart":{"k":"s","c":false,"f":{"data":[true,["r","FileData"]],"filename":[false,["n","s"]],"mediaType":[true,"s"],"providerOptions":[false,["n",["m",["m","j"]]]]}},"FilePartData":{"k":"u","b":[["r","FileData"],"s",["m","s"]]},"Fingerprint":{"k":"s","c":false,"f":{"blockHashes":[true,["a","s"]],"blockSize":[true,["i",true,64]],"bodyHash":[true,"s"],"lenBytes":[true,["i",true,64]],"tokenEstimate":[true,["i",true,64]]}},"FinishReasonUnified":{"k":"e","v":["stop","length","content-filter","tool-calls","error","other"]},"FunctionTool":{"k":"s","c":false,"f":{"description":[false,["n","s"]],"inputExamples":[false,["n",["a",["r","FunctionToolInputExample"]]]],"inputSchema":[true,"j"],"name":[true,"s"],"providerOptions":[false,["n",["m",["m","j"]]]],"strict":[false,["n","b"]]}},"FunctionToolInputExample":{"k":"s","c":false,"f":{"input":[true,["m","j"]]}},"GenerateContent":{"k":"t","g":"type","v":[{"tv":"text","c":false,"f":{"providerMetadata":[false,["n",["m",["m","j"]]]],"text":[true,"s"]}},{"tv":"tool-call","c":false,"f":{"dynamic":[false,["n","b"]],"input":[true,"s"],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},{"tv":"source","c":false,"f":{"id":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]],"sourceType":[true,["l","url"]],"title":[false,["n","s"]],"url":[true,"s"]}},{"tv":"source","c":false,"f":{"filename":[false,["n","s"]],"id":[true,"s"],"mediaType":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]],"sourceType":[true,["l","document"]],"title":[true,"s"]}},{"tv":"reasoning","c":false,"f":{"providerMetadata":[false,["n",["m",["m","j"]]]],"text":[true,"s"]}},{"tv":"file","c":false,"f":{"data":[true,["r","GeneratedFileData"]],"mediaType":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]]}},{"tv":"reasoning-file","c":false,"f":{"data":[true,["r","GeneratedFileData"]],"mediaType":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]]}},{"tv":"custom","c":false,"f":{"kind":[true,["r","NamespacedKind"]],"providerMetadata":[false,["n",["m",["m","j"]]]]}},{"tv":"tool-approval-request","c":false,"f":{"approvalId":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"]}},{"tv":"tool-result","c":false,"f":{"dynamic":[false,["n","b"]],"isError":[false,["n","b"]],"preliminary":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"result":[true,"j"],"toolCallId":[true,"s"],"toolName":[true,"s"]}}]},"GenerateObjectResponse":{"k":"s","c":false,"f":{"body":[false,"j"],"headers":[false,["n",["m","s"]]],"id":[true,"s"],"modelId":[true,"s"],"timestamp":[true,["r","Timestamp"]]}},"GenerateObjectResult":{"k":"s","c":false,"f":{"finishReason":[true,["r","FinishReasonUnified"]],"object":[true,"j"],"providerMetadata":[false,["n",["m",["m","j"]]]],"reasoning":[false,["n","s"]],"request":[true,["r","RequestInfo"]],"response":[true,["r","GenerateObjectResponse"]],"usage":[true,["r","LanguageModelUsage"]],"warnings":[true,["a",["r","Warning"]]]}},"GenerateTextOptions":{"k":"s","c":true,"f":{"frequencyPenalty":[false,["n","f"]],"headers":[false,["n",["m","s"]]],"include":[false,["n",["r","IncludeOptions"]]],"includeRawChunks":[false,["n","b"]],"instructions":[false,["n","s"]],"maxOutputTokens":[false,["n",["i",true,32]]],"maxRetries":[false,["n",["i",true,32]]],"output":[false,["n",["r","Output"]]],"presencePenalty":[false,["n","f"]],"providerOptions":[false,["n",["m",["m","j"]]]],"reasoning":[false,["n",["r","ReasoningEffort"]]],"seed":[false,["n",["i",true,64]]],"sessionId":[false,["n","s"]],"stopSequences":[false,["n",["a","s"]]],"strictStream":[false,["n","b"]],"temperature":[false,["n","f"]],"timeout":[false,["n",["r","TimeoutConfiguration"]]],"toolChoice":[false,["n",["r","ToolChoice"]]],"tools":[false,["n",["a",["r","Tool"]]]],"topK":[false,["n","f"]],"topP":[false,["n","f"]]}},"GenerateTextResult":{"k":"s","c":false,"f":{"output":[false,"j"],"outputParsed":[false,["n","b"]],"steps":[true,["a",["r","StepResult"]]],"totalUsage":[true,["r","LanguageModelUsage"]]}},"GenerateTextResultInput":{"k":"s","c":false,"f":{"output":[false,"j"],"outputParsed":[false,["n","b"]],"steps":[true,["a",["r","StepResultInput"]]],"totalUsage":[true,["r","LanguageModelUsageInput"]]}},"GeneratedFile":{"k":"s","c":false,"f":{"base64":[true,["r","FileBytes"]],"mediaType":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]]}},"GeneratedFileData":{"k":"t","g":"type","v":[{"tv":"data","c":false,"f":{"data":[true,["r","FileBytes"]]}},{"tv":"url","c":false,"f":{"originalUrl":[false,["n","s"]],"url":[true,"s"]}}]},"GeneratedFileOutput":{"k":"s","c":false,"f":{"file":[true,["r","GeneratedFile"]],"providerMetadata":[false,["n",["m",["m","j"]]]]}},"HandleId":{"k":"a","t":"u64"},"HandleIdInput":{"k":"a","t":"u64"},"HandleKind":{"k":"e","v":["Provider","Registry","Language","Embedding","Image","Speech","Transcription","Reranking","Video","Search","Decision","Files","Operation","Abort","Fetch","WebSocket","Download","CredentialResolver","Middleware","TraceStore","Recorder","SessionStore","ReplaySession"]},"HandleResult":{"k":"s","c":false,"f":{"handle":[true,["r","HandleId"]],"kind":[true,["r","HandleKind"]]}},"HttpExchange":{"k":"s","c":false,"f":{"attempt":[true,["i",true,32]],"error":[false,["n","s"]],"exchangeIndex":[true,["i",true,32]],"finalized":[true,"b"],"request":[true,["r","HttpRecord"]],"response":[false,["n",["r","ResponseRecord"]]],"step":[false,["n","s"]],"timing":[true,["r","TimingRecord"]]}},"HttpRecord":{"k":"s","c":false,"f":{"body":[false,["n","s"]],"headers":[true,["a",["a","s"]]],"method":[true,"s"],"url":[true,"s"]}},"ImageCallOptions":{"k":"s","c":true,"f":{"aspectRatio":[false,["n",["r","AspectRatio"]]],"files":[false,["n",["a",["r","ImageFile"]]]],"headers":[false,["n",["m","s"]]],"mask":[false,["n",["r","ImageFile"]]],"maxRetries":[false,["n",["i",true,32]]],"n":[true,["i",true,32]],"prompt":[false,["n","s"]],"providerOptions":[true,["m",["m","j"]]],"seed":[false,["n",["i",true,64]]],"size":[false,["n",["r","Size"]]],"timeout":[false,["n",["r","TimeoutConfiguration"]]]}},"ImageFile":{"k":"t","g":"type","v":[{"tv":"file","c":false,"f":{"data":[true,["r","ImageFileData"]],"mediaType":[true,"s"]}},{"tv":"url","c":false,"f":{"url":[true,"s"]}}]},"ImageFileData":{"k":"a","t":"s"},"ImageOutputs":{"k":"a","t":["a","s"]},"ImageResponse":{"k":"s","c":false,"f":{"headers":[false,["n",["m","s"]]],"modelId":[false,["n","s"]],"timestamp":[false,["n",["r","Timestamp"]]]}},"ImageResult":{"k":"s","c":false,"f":{"images":[true,["r","ImageOutputs"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"response":[true,["r","ImageResponse"]],"usage":[false,["n",["r","ImageUsage"]]],"warnings":[true,["a",["r","Warning"]]]}},"ImageUsage":{"k":"s","c":false,"f":{"inputTokens":[false,["n",["i",true,32]]],"outputTokens":[false,["n",["i",true,32]]],"totalTokens":[false,["n",["i",true,32]]]}},"IncludeOptions":{"k":"s","c":true,"f":{"requestBody":[false,["n","b"]],"responseBody":[false,["n","b"]]}},"InputAudioFormat":{"k":"s","c":true,"f":{"formatType":[true,"s"],"rate":[false,["n",["i",true,32]]]}},"InputRecord":{"k":"s","c":false,"f":{"operation":[false,["r","RecordingOperation"]],"options":[true,"j"],"prompt":[true,["a",["r","LanguageModelMessage"]]]}},"InputTokenDetails":{"k":"s","c":false,"f":{"cacheReadTokens":[false,["n",["i",true,32]]],"cacheWriteTokens":[false,["n",["i",true,32]]],"noCacheTokens":[false,["n",["i",true,32]]]}},"LanguageApi":{"k":"e","v":["chat","responses","completion","messages"]},"LanguageModelFile":{"k":"s","c":false,"f":{"data":[true,["r","GeneratedFileData"]],"mediaType":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]]}},"LanguageModelMessage":{"k":"t","g":"role","v":[{"tv":"system","c":false,"f":{"content":[true,"s"],"providerOptions":[false,["n",["m",["m","j"]]]]}},{"tv":"user","c":false,"f":{"content":[true,["a",["r","UserPart"]]],"providerOptions":[false,["n",["m",["m","j"]]]]}},{"tv":"assistant","c":false,"f":{"content":[true,["a",["r","AssistantPart"]]],"providerOptions":[false,["n",["m",["m","j"]]]]}},{"tv":"tool","c":false,"f":{"content":[true,["a",["r","ToolPart"]]],"providerOptions":[false,["n",["m",["m","j"]]]]}}]},"LanguageModelReasoningPart":{"k":"s","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"text":[true,"s"]}},"LanguageModelToolResultOutput":{"k":"t","g":"type","v":[{"tv":"text","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"value":[true,"s"]}},{"tv":"json","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"value":[true,"j"]}},{"tv":"execution-denied","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"reason":[false,["n","s"]]}},{"tv":"error-text","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"value":[true,"s"]}},{"tv":"error-json","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"value":[true,"j"]}},{"tv":"content","c":false,"f":{"isError":[false,["n","b"]],"value":[true,["a",["r","ToolResultContent"]]]}}]},"LanguageModelToolResultPart":{"k":"s","c":false,"f":{"output":[true,["r","LanguageModelToolResultOutput"]],"providerOptions":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},"LanguageModelUsage":{"k":"s","c":false,"f":{"inputTokenDetails":[true,["r","InputTokenDetails"]],"inputTokens":[false,["n",["i",true,32]]],"outputTokenDetails":[true,["r","OutputTokenDetails"]],"outputTokens":[false,["n",["i",true,32]]],"raw":[false,["n",["m","j"]]],"totalTokens":[false,["n",["i",true,32]]]}},"LanguageModelUsageInput":{"k":"s","c":false,"f":{"inputTokenDetails":[false,["r","InputTokenDetails"]],"inputTokens":[false,["n",["i",true,32]]],"outputTokenDetails":[false,["r","OutputTokenDetails"]],"outputTokens":[false,["n",["i",true,32]]],"raw":[false,["n",["m","j"]]],"totalTokens":[false,["n",["i",true,32]]]}},"LanguageModelV4ToolChoice":{"k":"t","g":"type","v":[{"tv":"auto","c":false,"f":{}},{"tv":"none","c":false,"f":{}},{"tv":"required","c":false,"f":{}},{"tv":"tool","c":false,"f":{"toolName":[true,"s"]}}]},"LiveTarget":{"k":"t","g":"kind","v":[{"tv":"model","c":true,"f":{"handle":[true,["r","HandleIdInput"]]}},{"tv":"registry","c":true,"f":{"handle":[true,["r","HandleIdInput"]]}}]},"LogLevel":{"k":"e","v":["off","error","warn","info","debug","trace"]},"LoggingConfig":{"k":"s","c":true,"f":{"level":[true,["r","LogLevel"]]}},"MiddlewareAuditMode":{"k":"e","v":["disabled","shared","strict"]},"MiddlewareParams":{"k":"s","c":true,"f":{"auditMode":[false,["n",["r","MiddlewareAuditMode"]]],"kind":[true,"s"],"scopeName":[false,["n","s"]],"traceStore":[false,["n",["r","HandleIdInput"]]]}},"MoaFailMode":{"k":"e","v":["best-effort","fail-fast"]},"MoaParams":{"k":"s","c":true,"f":{"aggregator":[true,"s"],"aggregatorInstructions":[false,["n","s"]],"failMode":[false,["r","MoaFailMode"]],"modelId":[false,"s"],"providerName":[false,"s"],"references":[true,["a","s"]],"stripReferenceTools":[false,"b"]}},"Modality":{"k":"e","v":["Text","Image","Audio","Video","Pdf","Other","Embedding","Score"]},"ModalityKind":{"k":"e","v":["languageModel","embeddingModel","imageModel","speechModel","transcriptionModel","rerankingModel","videoModel","searchModel","decision"]},"ModelCapabilities":{"k":"s","c":false,"f":{"attachment":[true,"b"],"structuredOutput":[true,"b"],"temperature":[true,"b"],"toolCall":[true,"b"]}},"ModelCost":{"k":"s","c":false,"f":{"cacheRead":[false,["n","f"]],"cacheWrite":[false,["n","f"]],"input":[false,["n","f"]],"output":[false,["n","f"]]}},"ModelInfo":{"k":"s","c":false,"f":{"capabilities":[true,"j"],"modality":[true,"s"],"modelId":[true,"s"],"provider":[true,"s"],"source":[true,"j"]}},"ModelInfoParams":{"k":"s","c":true,"f":{}},"ModelLimits":{"k":"s","c":false,"f":{"context":[false,["n",["i",true,64]]],"input":[false,["n",["i",true,64]]],"output":[false,["n",["i",true,64]]]}},"ModelMessage":{"k":"t","g":"role","v":[{"tv":"system","c":false,"f":{"content":[true,"s"],"providerOptions":[false,["n",["m",["m","j"]]]]}},{"tv":"user","c":false,"f":{"content":[true,["r","UserContent"]],"providerOptions":[false,["n",["m",["m","j"]]]]}},{"tv":"assistant","c":false,"f":{"content":[true,["r","AssistantContent"]],"providerOptions":[false,["n",["m",["m","j"]]]]}},{"tv":"tool","c":false,"f":{"content":[true,["a",["r","ToolContentPart"]]],"providerOptions":[false,["n",["m",["m","j"]]]]}}]},"ModelMethod":{"k":"e","v":["languageModel","chat","responses","completion","messages","embeddingModel","imageModel","speechModel","transcriptionModel","rerankingModel","videoModel","searchModel","decision"]},"ModelModalities":{"k":"s","c":false,"f":{"input":[false,["a",["r","Modality"]]],"output":[false,["a",["r","Modality"]]]}},"ModelPrompt":{"k":"u","b":["s",["a",["r","ModelMessage"]]]},"ModelRef":{"k":"s","c":true,"f":{"key":[true,"s"],"method":[true,["r","ModelMethod"]],"modelId":[true,"s"],"namespace":[true,"s"]}},"ModelResolveParams":{"k":"s","c":true,"f":{"modelRef":[true,["r","ModelRef"]]}},"ModelSpec":{"k":"s","c":false,"f":{"capabilities":[true,["r","ModelCapabilities"]],"cost":[false,["n",["r","ModelCost"]]],"displayName":[false,["n","s"]],"limits":[true,["r","ModelLimits"]],"modalities":[true,["r","ModelModalities"]],"provider":[false,["n","s"]],"raw":[false,"j"],"reasoning":[false,["n",["r","ReasoningSpec"]]],"source":[true,["r","CatalogueSource"]],"type":[true,["r","ModelType"]]}},"ModelType":{"k":"e","v":["Chat","Completion","Embedding","Rerank","ImageGen","ImageEdit","Video","Audio","Other"]},"ModelWrapParams":{"k":"s","c":true,"f":{"middleware":[true,["a","s"]]}},"NamespacedKind":{"k":"a","t":"s"},"OpenAiOutputRequest":{"k":"s","c":true,"f":{"metadataNamespace":[true,"s"],"result":[true,["r","GenerateTextResultInput"]]}},"OpenAiTextRequest":{"k":"s","c":true,"f":{"abort":[false,["n",["r","HandleIdInput"]]],"options":[false,["r","Options"]],"prompt":[true,["r","ModelPrompt"]],"streamOptions":[false,["r","StreamOptions"]]}},"OperationCapabilities":{"k":"s","c":false,"f":{"cancel":[true,"b"],"inputDone":[true,"b"],"next":[true,"b"],"push":[true,"b"]}},"OperationNextParams":{"k":"s","c":true,"f":{"timeoutMs":[false,["i",true,64]]}},"OperationOutcome":{"k":"e","v":["success","error","cancelled"]},"OperationPollResult":{"k":"t","g":"type","v":[{"tv":"part","c":false,"f":{"part":[true,["r","TranscriptionStreamPart"]]}},{"tv":"ended","c":false,"f":{}},{"tv":"timeout","c":false,"f":{}}]},"OperationState":{"k":"e","v":["running","inputClosed","terminal"]},"OperationStatus":{"k":"s","c":false,"f":{"capabilities":[true,["r","OperationCapabilities"]],"cleanupFailure":[false,["n","s"]],"consumerClosed":[true,"b"],"inputDoneSequence":[false,["n","s"]],"queuedInputBytes":[true,["i",true,64]],"queuedInputItems":[true,["i",true,64]],"queuedOutputBytes":[true,["i",true,64]],"queuedOutputItems":[true,["i",true,64]],"state":[true,["r","OperationState"]],"subkind":[true,"s"],"terminal":[false,["n",["r","TerminalSummary"]]]}},"Options":{"k":"s","c":true,"f":{"frequencyPenalty":[false,["n","f"]],"headers":[false,["n",["m","s"]]],"include":[false,["n",["r","IncludeOptions"]]],"includeRawChunks":[false,["n","b"]],"instructions":[false,["n","s"]],"maxOutputTokens":[false,["n",["i",true,32]]],"maxRetries":[false,["n",["i",true,32]]],"output":[false,["n",["r","Output"]]],"presencePenalty":[false,["n","f"]],"providerOptions":[false,["n",["m",["m","j"]]]],"reasoning":[false,["n",["r","ReasoningEffort"]]],"seed":[false,["n",["i",true,64]]],"sessionId":[false,["n","s"]],"stopSequences":[false,["n",["a","s"]]],"strictStream":[false,["n","b"]],"temperature":[false,["n","f"]],"timeout":[false,["n",["r","TimeoutConfiguration"]]],"toolChoice":[false,["n",["r","ToolChoice"]]],"tools":[false,["n",["a",["r","Tool"]]]],"topK":[false,["n","f"]],"topP":[false,["n","f"]]}},"Outcome":{"k":"e","v":["success","error","cancelled"]},"OutcomeRecord":{"k":"s","c":false,"f":{"decisionResult":[false,"j"],"error":[false,["n","s"]],"errorValue":[false,"j"],"finishReason":[false,["n","s"]],"status":[true,["r","OutcomeStatus"]],"usage":[false,"j"]}},"OutcomeStatus":{"k":"e","v":["success","pending","error","incomplete","cancelled"]},"Output":{"k":"t","g":"type","v":[{"tv":"text","c":false,"f":{}},{"tv":"object","c":false,"f":{"description":[false,["n","s"]],"name":[false,["n","s"]],"schema":[true,"j"]}},{"tv":"array","c":false,"f":{"description":[false,["n","s"]],"element":[true,"j"],"maxItems":[false,["n",["i",true,32]]],"minItems":[false,["n",["i",true,32]]],"name":[false,["n","s"]]}},{"tv":"choice","c":false,"f":{"description":[false,["n","s"]],"name":[false,["n","s"]],"options":[true,["a","s"]]}},{"tv":"json","c":false,"f":{"description":[false,["n","s"]],"name":[false,["n","s"]]}}]},"OutputChunkTimingStats":{"k":"s","c":false,"f":{"avg":[true,"f"],"max":[true,"f"],"median":[true,"f"],"min":[true,"f"],"p10":[true,"f"],"p90":[true,"f"]}},"OutputTokenDetails":{"k":"s","c":false,"f":{"reasoningTokens":[false,["n",["i",true,32]]],"textTokens":[false,["n",["i",true,32]]]}},"PackageAuthKind":{"k":"e","v":["bearer","header","queryParam","basic","awsSigV4","awsBearerOrSigV4","anthropicAws","googleVertex","azureApiKeyOrToken","codexChannel","optionalBearer","none"]},"PackageDescriptor":{"k":"s","c":true,"f":{"apiKeyEnv":[false,["n","s"]],"authKind":[true,["r","PackageAuthKind"]],"baseUrlEnv":[false,["n","s"]],"defaultBaseUrl":[false,["n","s"]],"defaultMethod":[false,["n",["r","ModalityKind"]]],"id":[true,"s"],"kind":[true,["r","PackageKind"]],"languageApis":[true,["a",["r","LanguageApi"]]],"modalities":[true,["a",["r","ModalityKind"]]],"settings":[true,["a",["r","SettingFieldSpec"]]],"supportsDefaultInstance":[true,"b"],"supportsDiscovery":[true,"b"],"supportsFiles":[true,"b"],"supportsSkills":[true,"b"],"templateParams":[true,["a",["r","TemplateParamDescriptor"]]]}},"PackageKind":{"k":"e","v":["native","protocol","preset","specialized"]},"PrefixBreak":{"k":"s","c":false,"f":{"atRecordId":[true,"s"],"expectedBreak":[true,"b"],"kind":[true,["r","BreakKind"]],"lcpBytes":[true,["i",true,64]],"prevRecordId":[true,"s"]}},"PromptTokensDetails":{"k":"s","c":false,"f":{"cache_write_tokens":[false,["n",["i",true,32]]],"cached_tokens":[true,["i",true,32]]}},"ProviderConfigDocument":{"k":"s","c":true,"f":{"providers":[true,["m",["r","ProviderEntrySpec"]]]}},"ProviderConfigSettings":{"k":"s","c":true,"f":{"accessKeyId":[false,["n",["r","StringOrEnv"]]],"accessToken":[false,["n",["r","StringOrEnv"]]],"apiKey":[false,["n",["r","StringOrEnv"]]],"apiVersion":[false,["n","s"]],"authToken":[false,["n",["r","StringOrEnv"]]],"baseUrl":[false,["n","s"]],"codexMode":[false,["n",["r","CodexModeSpec"]]],"cx":[false,["n","s"]],"endpoint":[false,["n","s"]],"headers":[false,["m",["n","s"]]],"includeUsage":[false,["n","b"]],"location":[false,["n","s"]],"login":[false,["n",["r","StringOrEnv"]]],"name":[false,["n","s"]],"organization":[false,["n","s"]],"originator":[false,["n","s"]],"params":[false,["m","s"]],"password":[false,["n",["r","StringOrEnv"]]],"probabilitySource":[false,["n","s"]],"project":[false,["n","s"]],"queryParams":[false,["m","s"]],"region":[false,["n","s"]],"resourceName":[false,["n","s"]],"secretAccessKey":[false,["n",["r","StringOrEnv"]]],"sessionToken":[false,["n",["r","StringOrEnv"]]],"speechBaseUrl":[false,["n","s"]],"supportsMultiPartToolContent":[false,["n","b"]],"supportsStructuredOutputs":[false,["n","b"]],"useDeploymentBasedUrls":[false,["n","b"]],"workspaceId":[false,["n","s"]]}},"ProviderCreateParams":{"k":"s","c":true,"f":{"envAllowlist":[false,["n",["a","s"]]],"package":[true,"s"],"settings":[false,["r","ProviderSettings"]]}},"ProviderCustomParams":{"k":"s","c":true,"f":{"chatModels":[false,["m",["r","HandleIdInput"]]],"completionModels":[false,["m",["r","HandleIdInput"]]],"decisionModels":[false,["m",["r","HandleIdInput"]]],"defaultMethod":[false,["n","s"]],"embeddingModels":[false,["m",["r","HandleIdInput"]]],"fallbackProvider":[false,["n",["r","HandleIdInput"]]],"files":[false,["n",["r","HandleIdInput"]]],"imageModelMiddleware":[false,["a",["r","HandleIdInput"]]],"imageModels":[false,["m",["r","HandleIdInput"]]],"languageModelMiddleware":[false,["a",["r","HandleIdInput"]]],"languageModels":[false,["m",["r","HandleIdInput"]]],"messagesModels":[false,["m",["r","HandleIdInput"]]],"rerankingModels":[false,["m",["r","HandleIdInput"]]],"responsesModels":[false,["m",["r","HandleIdInput"]]],"searchModels":[false,["m",["r","HandleIdInput"]]],"speechModels":[false,["m",["r","HandleIdInput"]]],"transcriptionModels":[false,["m",["r","HandleIdInput"]]],"videoModels":[false,["m",["r","HandleIdInput"]]]}},"ProviderDefaultParams":{"k":"s","c":true,"f":{"package":[true,"s"]}},"ProviderDescriptorsParams":{"k":"s","c":true,"f":{"package":[false,["n","s"]]}},"ProviderEntrySpec":{"k":"s","c":true,"f":{"package":[true,"s"],"settings":[false,["r","ProviderConfigSettings"]]}},"ProviderInvokeParams":{"k":"s","c":true,"f":{"abort":[false,["n",["r","HandleIdInput"]]],"method":[true,"s"]}},"ProviderModelParams":{"k":"s","c":true,"f":{"method":[false,["n","s"]],"modelId":[true,"s"]}},"ProviderRecord":{"k":"s","c":false,"f":{"modelId":[true,"s"],"provider":[true,"s"],"providerId":[true,"s"]}},"ProviderSettings":{"k":"s","c":true,"f":{"accessKeyId":[false,["n",["r","StringOrEnv"]]],"accessToken":[false,["n",["r","StringOrEnv"]]],"apiKey":[false,["n",["r","StringOrEnv"]]],"apiVersion":[false,["n","s"]],"authToken":[false,["n",["r","StringOrEnv"]]],"baseUrl":[false,["n","s"]],"codexMode":[false,["n",["r","CodexModeSpec"]]],"credentialResolver":[false,["n",["r","HandleIdInput"]]],"cx":[false,["n","s"]],"endpoint":[false,["n","s"]],"fetch":[false,["n",["r","HandleIdInput"]]],"headers":[false,["m",["n","s"]]],"includeUsage":[false,["n","b"]],"location":[false,["n","s"]],"login":[false,["n",["r","StringOrEnv"]]],"name":[false,["n","s"]],"organization":[false,["n","s"]],"originator":[false,["n","s"]],"params":[false,["m","s"]],"password":[false,["n",["r","StringOrEnv"]]],"probabilitySource":[false,["n","s"]],"project":[false,["n","s"]],"queryParams":[false,["m","s"]],"region":[false,["n","s"]],"resourceName":[false,["n","s"]],"secretAccessKey":[false,["n",["r","StringOrEnv"]]],"sessionToken":[false,["n",["r","StringOrEnv"]]],"speechBaseUrl":[false,["n","s"]],"supportsMultiPartToolContent":[false,["n","b"]],"supportsStructuredOutputs":[false,["n","b"]],"useDeploymentBasedUrls":[false,["n","b"]],"webSocket":[false,["n",["r","HandleIdInput"]]],"workspaceId":[false,["n","s"]]}},"ProviderTool":{"k":"s","c":false,"f":{"args":[true,["m","j"]],"id":[true,["r","NamespacedKind"]],"name":[true,"s"],"supportsDeferredResults":[false,["n","b"]]}},"ProviderWrapParams":{"k":"s","c":true,"f":{"imageModelMiddleware":[false,["a",["r","HandleIdInput"]]],"languageModelMiddleware":[false,["a",["r","HandleIdInput"]]]}},"RawToolApprovalRequest":{"k":"s","c":false,"f":{"approvalId":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"]}},"RawToolCall":{"k":"s","c":false,"f":{"dynamic":[false,["n","b"]],"input":[true,"s"],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},"ReasoningEffort":{"k":"e","v":["provider-default","none","minimal","low","medium","high","xhigh"]},"ReasoningFilePart":{"k":"s","c":false,"f":{"data":[true,["r","GeneratedFileData"]],"mediaType":[true,"s"],"providerOptions":[false,["n",["m",["m","j"]]]]}},"ReasoningFilePartData":{"k":"u","b":[["r","GeneratedFileData"],"s"]},"ReasoningMode":{"k":"e","v":["Other","Budget","Effort","Level","Fixed","Mixed","Toggle"]},"ReasoningOutput":{"k":"s","c":false,"f":{"providerMetadata":[false,["n",["m",["m","j"]]]],"text":[true,"s"]}},"ReasoningPart":{"k":"t","g":"type","v":[{"tv":"reasoning","c":false,"f":{"providerMetadata":[false,["n",["m",["m","j"]]]],"text":[true,"s"]}},{"tv":"reasoning-file","c":false,"f":{"file":[true,["r","GeneratedFile"]],"providerMetadata":[false,["n",["m",["m","j"]]]]}}]},"ReasoningSpec":{"k":"s","c":false,"f":{"budgetMin":[false,["n",["i",true,64]]],"defaultEnabled":[true,"b"],"effortDefault":[false,["n","s"]],"effortOptions":[false,["a","s"]],"interleaved":[true,"b"],"mode":[false,["n",["r","ReasoningMode"]]],"supported":[true,"b"],"visibility":[false,["n",["r","ReasoningVisibility"]]]}},"ReasoningVisibility":{"k":"e","v":["Hidden","Summary","Full","Mixed","Omitted","Other"]},"RecorderExport":{"k":"s","c":false,"f":{"jsonl":[true,"s"]}},"RecorderHandleResult":{"k":"s","c":false,"f":{"handle":[true,["r","HandleId"]]}},"RecorderStats":{"k":"t","g":"type","v":[{"tv":"ring","c":false,"f":{"completed":[true,["i",true,64]],"dropped":[true,["i",true,64]],"inconsistentCallIds":[true,["a","s"]],"pending":[true,["i",true,64]],"pendingEvicted":[true,["i",true,64]]}},{"tv":"jsonl","c":false,"f":{"dropped":[true,["i",true,64]],"inconsistentCallIds":[true,["a","s"]],"lastWriteError":[true,["n","s"]],"path":[true,"s"]}}]},"Recording":{"k":"s","c":false,"f":{"callId":[true,"s"],"complete":[true,"b"],"exchanges":[true,["a",["r","HttpExchange"]]],"input":[true,["r","InputRecord"]],"outcome":[true,["r","OutcomeRecord"]],"provider":[true,["r","ProviderRecord"]],"recordedAt":[true,"s"],"schema":[true,["i",true,32]],"sessionId":[false,["n","s"]],"step":[false,["n",["i",true,32]]],"transportClosed":[true,"b"]}},"RecordingOperation":{"k":"e","v":["language-model","decision"]},"RegistryCreateParams":{"k":"s","c":true,"f":{"entries":[true,["a",["r","RegistryEntry"]]],"namespace":[false,"s"],"separator":[false,["n","s"]]}},"RegistryEntry":{"k":"s","c":true,"f":{"key":[true,"s"],"provider":[true,"s"]}},"RegistryFromConfigParams":{"k":"s","c":true,"f":{"config":[true,["r","ProviderConfigDocument"]],"envAllowlist":[false,["n",["a","s"]]],"namespace":[false,"s"],"separator":[false,["n","s"]]}},"RegistryListParams":{"k":"s","c":true,"f":{}},"RegistryListResult":{"k":"s","c":false,"f":{"keys":[true,["a","s"]],"namespace":[true,"s"],"separator":[true,"s"]}},"RegistryProviderParams":{"k":"s","c":true,"f":{"key":[true,"s"]}},"RegistryUpdateParams":{"k":"s","c":true,"f":{"derive":[false,"b"],"remove":[false,["a","s"]],"replace":[false,"b"],"set":[false,["a",["r","RegistryEntry"]]]}},"RegistryUpdateResult":{"k":"s","c":false,"f":{"handle":[false,["n",["r","HandleId"]]],"keys":[true,["a","s"]],"kind":[false,["n",["r","HandleKind"]]]}},"RepairedToolCall":{"k":"s","c":false,"f":{"dynamic":[false,["n","b"]],"input":[true,"s"],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"],"type":[false,["l","tool-call"]]}},"ReplayCreateParams":{"k":"s","c":true,"f":{"recordingsJsonl":[true,"s"]}},"ReplayInspection":{"k":"s","c":false,"f":{"recordings":[true,["a",["r","ReplayRecordingInfo"]]]}},"ReplayLiveParams":{"k":"s","c":true,"f":{"abort":[false,["n",["r","HandleIdInput"]]],"callId":[true,"s"],"target":[true,["r","LiveTarget"]]}},"ReplayLiveResult":{"k":"u","b":[["r","GenerateTextResult"],["r","DecideResult"]]},"ReplayPlan":{"k":"s","c":false,"f":{"calls":[true,["a",["r","ReplayPlannedCall"]]]}},"ReplayPlannedCall":{"k":"s","c":false,"f":{"callId":[true,"s"],"liveSupported":[true,"b"],"operation":[true,["r","RecordingOperation"]],"provider":[true,["r","ProviderRecord"]],"requiresTarget":[true,"b"]}},"ReplayRecordingInfo":{"k":"s","c":false,"f":{"callId":[true,"s"],"complete":[true,"b"],"exchangeCount":[true,["i",true,64]],"operation":[true,["r","RecordingOperation"]],"provider":[true,["r","ProviderRecord"]],"transportClosed":[true,"b"]}},"ReplaySessionHandle":{"k":"s","c":false,"f":{"handle":[true,["r","HandleId"]]}},"RequestCacheHints":{"k":"s","c":false,"f":{"requestedWrite":[true,"b"]}},"RequestInfo":{"k":"s","c":false,"f":{"body":[false,"j"]}},"RerankingCallOptions":{"k":"s","c":true,"f":{"documents":[true,["r","RerankingDocuments"]],"headers":[false,["n",["m","s"]]],"maxRetries":[false,["n",["i",true,32]]],"providerOptions":[false,["n",["m",["m","j"]]]],"query":[true,"s"],"timeout":[false,["n",["r","TimeoutConfiguration"]]],"topN":[false,["n",["i",true,32]]]}},"RerankingDocuments":{"k":"t","g":"type","v":[{"tv":"text","c":false,"f":{"values":[true,["a","s"]]}},{"tv":"object","c":false,"f":{"values":[true,["a","j"]]}}]},"RerankingRank":{"k":"s","c":false,"f":{"index":[true,["i",true,32]],"relevanceScore":[true,"f"]}},"RerankingResponse":{"k":"s","c":false,"f":{"body":[false,"j"],"headers":[false,["n",["m","s"]]],"id":[false,["n","s"]],"modelId":[false,["n","s"]],"timestamp":[false,["n",["r","Timestamp"]]]}},"RerankingResult":{"k":"s","c":false,"f":{"providerMetadata":[false,["n",["m",["m","j"]]]],"ranking":[true,["a",["r","RerankingRank"]]],"response":[false,["n",["r","RerankingResponse"]]],"warnings":[false,["n",["a",["r","Warning"]]]]}},"ResponseInfo":{"k":"s","c":false,"f":{"body":[false,"j"],"headers":[false,["n",["m","s"]]],"id":[false,["n","s"]],"modelId":[false,["n","s"]],"timestamp":[false,["n",["r","Timestamp"]]]}},"ResponseRecord":{"k":"s","c":false,"f":{"body":[false,["n","s"]],"headers":[true,["a",["a","s"]]],"status":[true,["i",true,16]],"streamChunks":[false,["n",["i",true,64]]],"ttfbMs":[false,["n",["i",true,64]]]}},"RetryError":{"k":"s","c":false,"f":{"errors":[true,["a",["r","AiMuxError"]]],"reason":[true,["r","RetryErrorReason"]]}},"RetryErrorInput":{"k":"s","c":false,"f":{"errors":[true,["a",["r","AiMuxErrorInput"]]],"reason":[true,["r","RetryErrorReason"]]}},"RetryErrorReason":{"k":"e","v":["maxRetriesExceeded","errorNotRetryable"]},"RouterParams":{"k":"s","c":true,"f":{"children":[true,["a","s"]],"fallback":[false,["r","Fallback"]],"modelId":[false,["n","s"]],"providerName":[false,["n","s"]],"strategy":[true,["r","Strategy"]]}},"RuntimeConfigureParams":{"k":"s","c":true,"f":{"logging":[false,["n",["r","LoggingConfig"]]],"proxy":[false,["n",["r","TransportProxy"]]]}},"RuntimeDescribeParams":{"k":"s","c":true,"f":{}},"RuntimeModel":{"k":"s","c":false,"f":{"created":[false,["n",["i",true,64]]],"id":[true,"s"],"limits":[false,["n",["r","ModelLimits"]]],"ownedBy":[false,["n","s"]]}},"SearchCallOptions":{"k":"s","c":true,"f":{"excludeDomains":[false,["n",["a","s"]]],"headers":[false,["n",["m","s"]]],"includeDomains":[false,["n",["a","s"]]],"includeRawContent":[false,["n","b"]],"maxResults":[false,["n",["i",true,32]]],"maxRetries":[false,["n",["i",true,32]]],"providerOptions":[false,["n",["m",["m","j"]]]],"query":[true,"s"],"timeRange":[false,["n","s"]],"timeout":[false,["n",["r","TimeoutConfiguration"]]]}},"SearchResponse":{"k":"s","c":false,"f":{"body":[false,"j"],"headers":[false,["n",["m","s"]]]}},"SearchResult":{"k":"s","c":false,"f":{"answer":[false,["n","s"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"response":[false,["n",["r","SearchResponse"]]],"results":[true,["a",["r","SearchResultItem"]]],"warnings":[true,["a",["r","Warning"]]]}},"SearchResultItem":{"k":"s","c":false,"f":{"content":[false,["n","s"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"rawContent":[false,["n","s"]],"score":[false,["n","f"]],"title":[false,["n","s"]],"url":[false,["n","s"]]}},"SessionCall":{"k":"s","c":false,"f":{"callId":[true,"s"],"recordedAt":[true,"s"],"step":[true,["i",true,32]]}},"SessionChainView":{"k":"s","c":false,"f":{"breaks":[true,["a",["r","PrefixBreak"]]],"prefixStability":[true,"f"],"recordIds":[true,["a","s"]],"sessionId":[true,"s"]}},"SessionSource":{"k":"e","v":["Explicit","Inferred"]},"SessionStepStat":{"k":"s","c":false,"f":{"callId":[true,"s"],"error":[false,["n","s"]],"hitRate":[false,["n","f"]],"step":[true,["i",true,32]],"verdict":[false,["n",["r","Verdict"]]]}},"SessionStoreCallsParams":{"k":"s","c":true,"f":{"sessionId":[true,"s"]}},"SessionStoreCreateParams":{"k":"s","c":true,"f":{"infer":[true,"b"]}},"SessionStoreHandle":{"k":"s","c":false,"f":{"handle":[true,["r","HandleId"]]}},"SessionView":{"k":"s","c":false,"f":{"calls":[true,["a",["r","SessionCall"]]],"sessionId":[true,"s"],"source":[true,["r","SessionSource"]]}},"SettingFieldKind":{"k":"e","v":["string","credential","boolean","headerMap","stringMap","codexMode"]},"SettingFieldSpec":{"k":"s","c":true,"f":{"credential":[true,"b"],"envVar":[false,["n","s"]],"kind":[true,["r","SettingFieldKind"]],"name":[true,"s"],"required":[true,"b"]}},"Size":{"k":"a","t":"s"},"Source":{"k":"t","g":"sourceType","v":[{"tv":"url","c":false,"f":{"id":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]],"title":[false,["n","s"]],"url":[true,"s"]}},{"tv":"document","c":false,"f":{"filename":[false,["n","s"]],"id":[true,"s"],"mediaType":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]],"title":[true,"s"]}}]},"SourceError":{"k":"s","c":false,"f":{"cause":[false,["n",["r","SourceError"]]],"message":[true,"s"]}},"SpeechCallOptions":{"k":"s","c":true,"f":{"headers":[false,["n",["m","s"]]],"instructions":[false,["n","s"]],"language":[false,["n","s"]],"maxRetries":[false,["n",["i",true,32]]],"outputFormat":[false,["n","s"]],"providerOptions":[false,["n",["m",["m","j"]]]],"speed":[false,["n","f"]],"text":[true,"s"],"timeout":[false,["n",["r","TimeoutConfiguration"]]],"voice":[false,["n","s"]]}},"SpeechRequest":{"k":"s","c":false,"f":{"body":[false,"j"]}},"SpeechResponse":{"k":"s","c":false,"f":{"body":[false,"j"],"headers":[false,["n",["m","s"]]],"modelId":[false,["n","s"]],"timestamp":[false,["n",["r","Timestamp"]]]}},"SpeechResult":{"k":"s","c":false,"f":{"audio":[true,["r","AudioData"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"request":[false,["n",["r","SpeechRequest"]]],"response":[true,["r","SpeechResponse"]],"usage":[true,["n",["m","j"]]],"warnings":[true,["a",["r","Warning"]]]}},"StepModel":{"k":"s","c":false,"f":{"modelId":[true,"s"],"provider":[true,"s"]}},"StepResponse":{"k":"s","c":false,"f":{"body":[false,"j"],"headers":[false,["n",["m","s"]]],"id":[true,"s"],"messages":[true,["a",["r","ModelMessage"]]],"modelId":[true,"s"],"timestamp":[true,["r","Timestamp"]]}},"StepResponseInput":{"k":"s","c":false,"f":{"body":[false,"j"],"headers":[false,["n",["m","s"]]],"id":[true,"s"],"messages":[false,["a",["r","ModelMessage"]]],"modelId":[true,"s"],"timestamp":[true,["r","Timestamp"]]}},"StepResponseMetadata":{"k":"s","c":false,"f":{"headers":[false,["n",["m","s"]]],"id":[true,"s"],"modelId":[true,"s"],"timestamp":[true,["r","Timestamp"]]}},"StepResult":{"k":"s","c":false,"f":{"callId":[true,"s"],"content":[true,["a",["r","ContentPart"]]],"finishReason":[true,["r","FinishReasonUnified"]],"model":[true,["r","StepModel"]],"performance":[true,["r","StepResultPerformance"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"rawFinishReason":[false,["n","s"]],"request":[true,["r","RequestInfo"]],"response":[true,["r","StepResponse"]],"stepNumber":[true,["i",true,32]],"usage":[true,["r","LanguageModelUsage"]],"warnings":[true,["a",["r","Warning"]]]}},"StepResultInput":{"k":"s","c":false,"f":{"callId":[true,"s"],"content":[true,["a",["r","ContentPartInput"]]],"finishReason":[true,["r","FinishReasonUnified"]],"model":[true,["r","StepModel"]],"performance":[true,["r","StepResultPerformanceInput"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"rawFinishReason":[false,["n","s"]],"request":[false,["r","RequestInfo"]],"response":[true,["r","StepResponseInput"]],"stepNumber":[true,["i",true,32]],"usage":[true,["r","LanguageModelUsageInput"]],"warnings":[false,["a",["r","Warning"]]]}},"StepResultPerformance":{"k":"s","c":false,"f":{"effectiveOutputTokensPerSecond":[true,"f"],"effectiveTotalTokensPerSecond":[true,"f"],"inputTokensPerSecond":[false,["n","f"]],"outputTokensPerSecond":[false,["n","f"]],"responseTimeMs":[true,"f"],"stepTimeMs":[true,"f"],"timeBetweenOutputChunksMs":[false,["n",["r","OutputChunkTimingStats"]]],"timeToFirstOutputMs":[false,["n","f"]],"toolExecutionMs":[true,["m","f"]]}},"StepResultPerformanceInput":{"k":"s","c":false,"f":{"effectiveOutputTokensPerSecond":[true,"f"],"effectiveTotalTokensPerSecond":[true,"f"],"inputTokensPerSecond":[false,["n","f"]],"outputTokensPerSecond":[false,["n","f"]],"responseTimeMs":[true,"f"],"stepTimeMs":[true,"f"],"timeBetweenOutputChunksMs":[false,["n",["r","OutputChunkTimingStats"]]],"timeToFirstOutputMs":[false,["n","f"]],"toolExecutionMs":[false,["m","f"]]}},"Strategy":{"k":"t","g":"type","v":[{"tv":"rule","c":true,"f":{}},{"tv":"weighted","c":true,"f":{"weights":[true,["a","f"]]}}]},"StreamEvent":{"k":"u","b":[["r","TextStreamPart"],["r","ChatCompletionChunk"]]},"StreamFrame":{"k":"t","g":"type","v":[{"tv":"event","c":true,"f":{"event":[true,["r","StreamEvent"]],"seq":[true,"u64"]}},{"tv":"end","c":true,"f":{"error":[false,["n",["r","ErrorEnvelope"]]],"outcome":[true,["r","Outcome"]],"seq":[true,"u64"]}}]},"StreamOptions":{"k":"s","c":true,"f":{"includeReasoning":[false,"b"],"includeUsage":[false,"b"]}},"StringOrEnv":{"k":"u","b":["s",["r","EnvVarRef"]]},"TaggedRawToolCall":{"k":"s","c":false,"f":{"dynamic":[false,["n","b"]],"input":[true,"s"],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"],"type":[true,["l","tool-call"]]}},"TaggedToolResult":{"k":"s","c":false,"f":{"dynamic":[false,["n","b"]],"input":[false,"j"],"output":[true,"j"],"preliminary":[false,["n","b"]],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"],"type":[true,["l","tool-result"]]}},"TemplateParamDescriptor":{"k":"s","c":true,"f":{"envVar":[true,"s"],"name":[true,"s"]}},"TerminalSummary":{"k":"s","c":false,"f":{"error":[false,["n",["r","ErrorEnvelope"]]],"outcome":[true,["r","OperationOutcome"]]}},"TextPart":{"k":"s","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"text":[true,"s"]}},"TextRequest":{"k":"s","c":true,"f":{"abort":[false,["n",["r","HandleIdInput"]]],"options":[false,["r","Options"]],"prompt":[true,["r","ModelPrompt"]]}},"TextStreamPart":{"k":"t","g":"type","v":[{"tv":"text-start","c":false,"f":{"id":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]]}},{"tv":"text-end","c":false,"f":{"id":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]]}},{"tv":"text-delta","c":false,"f":{"id":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]],"text":[true,"s"]}},{"tv":"reasoning-start","c":false,"f":{"id":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]]}},{"tv":"reasoning-end","c":false,"f":{"id":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]]}},{"tv":"reasoning-delta","c":false,"f":{"id":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]],"text":[true,"s"]}},{"tv":"custom","c":false,"f":{"kind":[true,["r","NamespacedKind"]],"providerMetadata":[false,["n",["m",["m","j"]]]]}},{"tv":"tool-input-start","c":false,"f":{"dynamic":[false,["n","b"]],"id":[true,"s"],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"title":[false,["n","s"]],"toolName":[true,"s"]}},{"tv":"tool-input-end","c":false,"f":{"id":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]]}},{"tv":"tool-input-delta","c":false,"f":{"delta":[true,"s"],"id":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]]}},{"tv":"source","c":false,"f":{"id":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]],"sourceType":[true,["l","url"]],"title":[false,["n","s"]],"url":[true,"s"]}},{"tv":"source","c":false,"f":{"filename":[false,["n","s"]],"id":[true,"s"],"mediaType":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]],"sourceType":[true,["l","document"]],"title":[true,"s"]}},{"tv":"file","c":false,"f":{"file":[true,["r","GeneratedFile"]],"providerMetadata":[false,["n",["m",["m","j"]]]]}},{"tv":"reasoning-file","c":false,"f":{"file":[true,["r","GeneratedFile"]],"providerMetadata":[false,["n",["m",["m","j"]]]]}},{"tv":"tool-call","c":false,"f":{"dynamic":[false,["n","b"]],"error":[false,["n",["r","AiMuxError"]]],"input":[true,"j"],"invalid":[false,["n","b"]],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},{"tv":"tool-result","c":false,"f":{"dynamic":[false,["n","b"]],"input":[false,"j"],"output":[true,"j"],"preliminary":[false,["n","b"]],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},{"tv":"tool-error","c":false,"f":{"dynamic":[false,["n","b"]],"error":[true,"j"],"input":[false,"j"],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},{"tv":"tool-output-denied","c":false,"f":{"dynamic":[false,["n","b"]],"providerExecuted":[false,["n","b"]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},{"tv":"tool-approval-request","c":false,"f":{"approvalId":[true,"s"],"isAutomatic":[false,["n","b"]],"reason":[false,["n","s"]],"signature":[false,["n","s"]],"toolCall":[true,["r","TypedToolCall"]]}},{"tv":"tool-approval-response","c":false,"f":{"approvalId":[true,"s"],"approved":[true,"b"],"providerExecuted":[false,["n","b"]],"reason":[false,["n","s"]],"toolCall":[true,["r","TypedToolCall"]]}},{"tv":"start-step","c":false,"f":{"request":[true,["r","RequestInfo"]],"warnings":[true,["a",["r","Warning"]]]}},{"tv":"finish-step","c":false,"f":{"finishReason":[true,["r","FinishReasonUnified"]],"performance":[true,["r","StepResultPerformance"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"rawFinishReason":[false,["n","s"]],"response":[true,["r","StepResponseMetadata"]],"usage":[true,["r","LanguageModelUsage"]]}},{"tv":"start","c":false,"f":{}},{"tv":"finish","c":false,"f":{"finishReason":[true,["r","FinishReasonUnified"]],"rawFinishReason":[false,["n","s"]],"totalUsage":[true,["r","LanguageModelUsage"]]}},{"tv":"abort","c":false,"f":{"reason":[false,["n","s"]]}},{"tv":"error","c":false,"f":{"error":[true,["r","AiMuxError"]]}},{"tv":"raw","c":false,"f":{"rawValue":[true,"j"]}}]},"TimeoutConfiguration":{"k":"s","c":true,"f":{"chunkMs":[false,["n",["i",true,64]]],"firstChunkMs":[false,["n",["i",true,64]]],"stepMs":[false,["n",["i",true,64]]],"totalMs":[false,["n",["i",true,64]]]}},"Timestamp":{"k":"a","t":"s"},"TimingRecord":{"k":"s","c":false,"f":{"latencyMs":[true,["i",true,64]],"ttfbMs":[false,["n",["i",true,64]]]}},"Tool":{"k":"t","g":"type","v":[{"tv":"function","c":false,"f":{"description":[false,["n","s"]],"inputExamples":[false,["n",["a",["r","FunctionToolInputExample"]]]],"inputSchema":[true,"j"],"name":[true,"s"],"providerOptions":[false,["n",["m",["m","j"]]]],"strict":[false,["n","b"]]}},{"tv":"provider","c":false,"f":{"args":[true,["m","j"]],"id":[true,["r","NamespacedKind"]],"name":[true,"s"],"supportsDeferredResults":[false,["n","b"]]}}]},"ToolApprovalRequestOutput":{"k":"s","c":false,"f":{"approvalId":[true,"s"],"isAutomatic":[false,["n","b"]],"reason":[false,["n","s"]],"signature":[false,["n","s"]],"toolCall":[true,["r","TypedToolCall"]]}},"ToolApprovalRequestOutputInput":{"k":"s","c":false,"f":{"approvalId":[true,"s"],"isAutomatic":[false,["n","b"]],"reason":[false,["n","s"]],"signature":[false,["n","s"]],"toolCall":[true,["r","TypedToolCallInput"]]}},"ToolApprovalResponseOutput":{"k":"s","c":false,"f":{"approvalId":[true,"s"],"approved":[true,"b"],"providerExecuted":[false,["n","b"]],"reason":[false,["n","s"]],"toolCall":[true,["r","TypedToolCall"]]}},"ToolApprovalResponseOutputInput":{"k":"s","c":false,"f":{"approvalId":[true,"s"],"approved":[true,"b"],"providerExecuted":[false,["n","b"]],"reason":[false,["n","s"]],"toolCall":[true,["r","TypedToolCallInput"]]}},"ToolApprovalResponsePart":{"k":"s","c":false,"f":{"approvalId":[true,"s"],"approved":[true,"b"],"providerOptions":[false,["n",["m",["m","j"]]]],"reason":[false,["n","s"]]}},"ToolCall":{"k":"s","c":false,"f":{"dynamic":[false,["n","b"]],"error":[false,["n",["r","AiMuxError"]]],"input":[true,"j"],"invalid":[false,["n","b"]],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},"ToolCallInput":{"k":"s","c":false,"f":{"dynamic":[false,["n","b"]],"error":[false,["n",["r","AiMuxErrorInput"]]],"input":[true,"j"],"invalid":[false,["n","b"]],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},"ToolCallPart":{"k":"s","c":false,"f":{"input":[true,"j"],"providerExecuted":[false,["n","b"]],"providerOptions":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},"ToolCallRepairReply":{"k":"t","g":"type","v":[{"tv":"repaired","c":true,"f":{"toolCall":[true,["r","RepairedToolCall"]]}},{"tv":"unchanged","c":true,"f":{}},{"tv":"failed","c":true,"f":{"message":[true,"s"]}}]},"ToolChoice":{"k":"u","b":[["r","ToolChoiceMode"],["r","ToolChoiceTool"]]},"ToolChoiceMode":{"k":"e","v":["auto","none","required"]},"ToolChoiceTool":{"k":"s","c":false,"f":{"toolName":[true,"s"],"type":[true,["l","tool"]]}},"ToolChoiceViolationError":{"k":"s","c":false,"f":{"content":[true,["a",["r","GenerateContent"]]],"finishReason":[true,["r","FinishReasonUnified"]],"modelId":[true,"s"],"provider":[true,"s"],"toolChoice":[true,["r","LanguageModelV4ToolChoice"]]}},"ToolContentPart":{"k":"t","g":"type","v":[{"tv":"tool-result","c":false,"f":{"output":[true,["r","ToolResultOutput"]],"providerOptions":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[false,["n","s"]]}},{"tv":"tool-approval-response","c":false,"f":{"approvalId":[true,"s"],"approved":[true,"b"],"providerExecuted":[false,["n","b"]],"reason":[false,["n","s"]]}}]},"ToolOutputDenied":{"k":"s","c":false,"f":{"dynamic":[false,["n","b"]],"providerExecuted":[false,["n","b"]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},"ToolPart":{"k":"t","g":"type","v":[{"tv":"tool-result","c":false,"f":{"output":[true,["r","LanguageModelToolResultOutput"]],"providerOptions":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},{"tv":"tool-approval-response","c":false,"f":{"approvalId":[true,"s"],"approved":[true,"b"],"providerOptions":[false,["n",["m",["m","j"]]]],"reason":[false,["n","s"]]}}]},"ToolRepairApplyRequest":{"k":"s","c":true,"f":{"options":[false,["r","GenerateTextOptions"]],"reply":[true,["r","ToolCallRepairReply"]],"toolCall":[true,["r","ToolCallInput"]]}},"ToolRepairApplyResultRequest":{"k":"s","c":true,"f":{"options":[false,["r","GenerateTextOptions"]],"reply":[true,["r","ToolCallRepairReply"]],"result":[true,["r","GenerateTextResultInput"]],"toolCallId":[true,"s"]}},"ToolRepairContextRequest":{"k":"s","c":true,"f":{"options":[false,["r","GenerateTextOptions"]],"prompt":[true,["r","ModelPrompt"]],"toolCall":[true,["r","ToolCallInput"]]}},"ToolRepairContextResult":{"k":"a","t":["n",["r","ToolRepairContextSchema"]]},"ToolRepairContextSchema":{"k":"s","c":false,"f":{"error":[true,["r","AiMuxError"]],"inputSchema":[true,"j"],"instructions":[true,["n","s"]],"messages":[true,["a",["r","ModelMessage"]]],"toolCall":[true,["r","TaggedRawToolCall"]],"tools":[true,["a",["r","Tool"]]]}},"ToolResult":{"k":"s","c":false,"f":{"dynamic":[false,["n","b"]],"isError":[false,["n","b"]],"preliminary":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"result":[true,"j"],"toolCallId":[true,"s"],"toolName":[true,"s"]}},"ToolResultContent":{"k":"t","g":"type","v":[{"tv":"text","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"text":[true,"s"]}},{"tv":"file","c":false,"f":{"data":[true,["r","FileData"]],"filename":[false,["n","s"]],"mediaType":[true,"s"],"providerOptions":[false,["n",["m",["m","j"]]]]}},{"tv":"custom","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]]}}]},"ToolResultContentPart":{"k":"t","g":"type","v":[{"tv":"text","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"text":[true,"s"]}},{"tv":"file","c":false,"f":{"data":[true,["r","FileData"]],"filename":[false,["n","s"]],"mediaType":[true,"s"],"providerOptions":[false,["n",["m",["m","j"]]]]}},{"tv":"file-data","c":false,"f":{"data":[true,"s"],"filename":[false,["n","s"]],"mediaType":[true,"s"],"providerOptions":[false,["n",["m",["m","j"]]]]}},{"tv":"file-url","c":false,"f":{"mediaType":[false,["n","s"]],"providerOptions":[false,["n",["m",["m","j"]]]],"url":[true,"s"]}},{"tv":"file-id","c":false,"f":{"fileId":[true,["r","ToolResultFileId"]],"providerOptions":[false,["n",["m",["m","j"]]]]}},{"tv":"file-reference","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"providerReference":[true,["m","s"]]}},{"tv":"image-data","c":false,"f":{"data":[true,"s"],"mediaType":[true,"s"],"providerOptions":[false,["n",["m",["m","j"]]]]}},{"tv":"image-url","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"url":[true,"s"]}},{"tv":"image-file-id","c":false,"f":{"fileId":[true,["r","ToolResultFileId"]],"providerOptions":[false,["n",["m",["m","j"]]]]}},{"tv":"image-file-reference","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"providerReference":[true,["m","s"]]}},{"tv":"custom","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]]}}]},"ToolResultFileId":{"k":"u","b":["s",["m","s"]]},"ToolResultOutput":{"k":"t","g":"type","v":[{"tv":"text","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"value":[true,"s"]}},{"tv":"json","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"value":[true,"j"]}},{"tv":"execution-denied","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"reason":[false,["n","s"]]}},{"tv":"error-text","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"value":[true,"s"]}},{"tv":"error-json","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"value":[true,"j"]}},{"tv":"content","c":false,"f":{"value":[true,["a",["r","ToolResultContentPart"]]]}}]},"ToolResultPart":{"k":"s","c":false,"f":{"output":[true,["r","ToolResultOutput"]],"providerOptions":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[false,["n","s"]]}},"TraceAggregateFilter":{"k":"s","c":true,"f":{"model":[false,["n","s"]],"provider":[false,["n","s"]],"sessionId":[false,["n","s"]],"sinceUnixMs":[false,["n",["i",false,64]]]}},"TraceAggregateParams":{"k":"s","c":true,"f":{"filter":[false,["r","TraceAggregateFilter"]]}},"TraceAuditMode":{"k":"e","v":["off","shared","strict"]},"TraceCreateParams":{"k":"s","c":true,"f":{"auditMode":[false,["r","TraceAuditMode"]],"capacity":[false,["i",true,64]],"perScopeCapacity":[false,["i",true,64]]}},"TraceRecord":{"k":"s","c":false,"f":{"callId":[true,"s"],"error":[false,["n","s"]],"fingerprint":[true,["r","Fingerprint"]],"lcpTokenUpper":[false,["n",["i",true,64]]],"model":[true,"s"],"provider":[true,"s"],"requestCacheHints":[false,["n",["r","RequestCacheHints"]]],"requestId":[false,["n","s"]],"responseCacheHeaders":[false,["n",["m","s"]]],"sentAtUnixMs":[true,["i",false,64]],"sessionId":[false,["n","s"]],"ttftMs":[false,["n",["i",true,64]]],"usage":[true,["r","UsageSnapshot"]],"verdict":[false,["n",["r","Verdict"]]]}},"TraceSessionParams":{"k":"s","c":true,"f":{"sessionId":[true,"s"]}},"TraceStats":{"k":"s","c":false,"f":{"claimedCacheReadTotal":[true,["i",true,64]],"claimedCacheWriteTotal":[true,["i",true,64]],"clientUpperBoundHitRate":[false,["n","f"]],"errors":[true,["i",true,64]],"inputTokensTotal":[true,["i",true,64]],"model":[true,"s"],"provider":[true,"s"],"reportedHitRate":[false,["n","f"]],"requests":[true,["i",true,64]],"ttftP50Ms":[false,["n",["i",true,64]]],"ttftP95Ms":[false,["n",["i",true,64]]],"verdictCounts":[true,["m",["i",true,64]]]}},"TranscriptionCallOptions":{"k":"s","c":true,"f":{"audio":[true,["r","AudioInput"]],"headers":[false,["n",["m","s"]]],"maxRetries":[false,["n",["i",true,32]]],"mediaType":[true,"s"],"providerOptions":[false,["n",["m",["m","j"]]]],"timeout":[false,["n",["r","TimeoutConfiguration"]]]}},"TranscriptionRequest":{"k":"s","c":false,"f":{"body":[false,["n","s"]]}},"TranscriptionResponse":{"k":"s","c":false,"f":{"body":[false,"j"],"headers":[false,["n",["m","s"]]],"modelId":[false,["n","s"]],"timestamp":[false,["n",["r","Timestamp"]]]}},"TranscriptionResult":{"k":"s","c":false,"f":{"durationInSeconds":[false,["n","f"]],"language":[false,["n","s"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"request":[false,["n",["r","TranscriptionRequest"]]],"response":[true,["r","TranscriptionResponse"]],"segments":[true,["a",["r","TranscriptionSegment"]]],"text":[true,"s"],"warnings":[true,["a",["r","Warning"]]]}},"TranscriptionSegment":{"k":"s","c":false,"f":{"endSecond":[true,"f"],"startSecond":[true,"f"],"text":[true,"s"]}},"TranscriptionStartParams":{"k":"s","c":true,"f":{"abort":[false,["n",["r","HandleIdInput"]]],"headers":[false,["n",["m","s"]]],"includeRawChunks":[false,"b"],"inputAudioFormat":[false,["n",["r","InputAudioFormat"]]],"providerOptions":[false,["n",["m",["m","j"]]]],"timeout":[false,["n",["r","TimeoutConfiguration"]]]}},"TranscriptionStreamPart":{"k":"t","g":"type","v":[{"tv":"stream-start","c":false,"f":{"warnings":[true,["a",["r","Warning"]]]}},{"tv":"transcript-delta","c":false,"f":{"delta":[true,"s"],"id":[false,["n","s"]],"providerMetadata":[false,["n",["m",["m","j"]]]]}},{"tv":"transcript-partial","c":false,"f":{"channelIndex":[false,["n",["i",true,32]]],"durationInSeconds":[false,["n","f"]],"id":[false,["n","s"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"startSecond":[false,["n","f"]],"text":[true,"s"]}},{"tv":"transcript-final","c":false,"f":{"channelIndex":[false,["n",["i",true,32]]],"endSecond":[false,["n","f"]],"id":[false,["n","s"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"startSecond":[false,["n","f"]],"text":[true,"s"]}},{"tv":"response-metadata","c":false,"f":{"body":[false,"j"],"headers":[false,["n",["m","s"]]],"modelId":[false,["n","s"]],"timestamp":[false,["n",["r","Timestamp"]]]}},{"tv":"finish","c":false,"f":{"durationInSeconds":[false,["n","f"]],"language":[false,["n","s"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"segments":[true,["a",["r","TranscriptionSegment"]]],"text":[true,"s"]}},{"tv":"raw","c":false,"f":{"rawValue":[true,"j"]}},{"tv":"error","c":false,"f":{"error":[true,"j"]}}]},"TransportParams":{"k":"t","g":"kind","v":[{"tv":"fetch","c":true,"f":{"proxy":[false,["r","TransportProxy"]]}},{"tv":"ws","c":true,"f":{"proxy":[false,["r","TransportProxy"]]}},{"tv":"download","c":true,"f":{"maxBytes":[false,["n",["i",true,64]]]}}]},"TransportProxy":{"k":"s","c":true,"f":{"all_url":[false,["n","s"]],"http_url":[false,["n","s"]],"https_url":[false,["n","s"]],"no_proxy":[false,["n","s"]]}},"TypedSource":{"k":"t","g":"sourceType","v":[{"tv":"url","c":false,"f":{"id":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]],"title":[false,["n","s"]],"type":[true,["l","source"]],"url":[true,"s"]}},{"tv":"document","c":false,"f":{"filename":[false,["n","s"]],"id":[true,"s"],"mediaType":[true,"s"],"providerMetadata":[false,["n",["m",["m","j"]]]],"title":[true,"s"],"type":[true,["l","source"]]}}]},"TypedToolCall":{"k":"s","c":false,"f":{"dynamic":[false,["n","b"]],"error":[false,["n",["r","AiMuxError"]]],"input":[true,"j"],"invalid":[false,["n","b"]],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"],"type":[true,["l","tool-call"]]}},"TypedToolCallInput":{"k":"s","c":false,"f":{"dynamic":[false,["n","b"]],"error":[false,["n",["r","AiMuxErrorInput"]]],"input":[true,"j"],"invalid":[false,["n","b"]],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"],"type":[false,["l","tool-call"]]}},"TypedToolError":{"k":"s","c":false,"f":{"dynamic":[false,["n","b"]],"error":[true,"j"],"input":[false,"j"],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},"TypedToolResult":{"k":"s","c":false,"f":{"dynamic":[false,["n","b"]],"input":[false,"j"],"output":[true,"j"],"preliminary":[false,["n","b"]],"providerExecuted":[false,["n","b"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"toolCallId":[true,"s"],"toolName":[true,"s"]}},"UploadFileData":{"k":"t","g":"type","v":[{"tv":"data","c":true,"f":{"data":[true,["r","FileBytes"]]}},{"tv":"text","c":true,"f":{"text":[true,"s"]}}]},"UploadFileParams":{"k":"s","c":true,"f":{"abort":[false,["n",["r","HandleIdInput"]]],"data":[true,["r","UploadFileData"]],"filename":[false,["n","s"]],"mediaType":[true,"s"],"providerOptions":[false,["n",["m",["m","j"]]]]}},"UploadFileResult":{"k":"s","c":false,"f":{"filename":[false,["n","s"]],"mediaType":[false,["n","s"]],"providerMetadata":[false,["n",["m",["m","j"]]]],"providerReference":[true,["m","s"]],"warnings":[true,["a",["r","Warning"]]]}},"UsageSnapshot":{"k":"s","c":false,"f":{"cacheRead":[false,["n",["i",true,64]]],"cacheWrite":[false,["n",["i",true,64]]],"inputNoCache":[false,["n",["i",true,64]]],"inputTotal":[false,["n",["i",true,64]]],"outputReasoning":[false,["n",["i",true,64]]],"outputText":[false,["n",["i",true,64]]],"outputTotal":[false,["n",["i",true,64]]],"raw":[false,"j"]}},"UserContent":{"k":"u","b":["s",["a",["r","UserContentPart"]]]},"UserContentPart":{"k":"t","g":"type","v":[{"tv":"text","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"text":[true,"s"]}},{"tv":"image","c":false,"f":{"image":[true,"s"],"mediaType":[true,"s"],"providerOptions":[false,["n",["m",["m","j"]]]]}},{"tv":"file","c":false,"f":{"data":[true,["r","FilePartData"]],"filename":[false,["n","s"]],"mediaType":[true,"s"],"providerOptions":[false,["n",["m",["m","j"]]]]}}]},"UserPart":{"k":"t","g":"type","v":[{"tv":"text","c":false,"f":{"providerOptions":[false,["n",["m",["m","j"]]]],"text":[true,"s"]}},{"tv":"file","c":false,"f":{"data":[true,["r","FileData"]],"filename":[false,["n","s"]],"mediaType":[true,"s"],"providerOptions":[false,["n",["m",["m","j"]]]]}}]},"Verdict":{"k":"s","c":false,"f":{"claimed":[true,["i",true,64]],"confidence":[true,["r","VerdictConfidence"]],"expectedMax":[true,["i",true,64]],"kind":[true,["r","VerdictKind"]],"lcpBytes":[true,["i",true,64]],"notes":[true,["a","s"]],"violated":[true,["a","s"]]}},"VerdictConfidence":{"k":"e","v":["High","Medium","Low"]},"VerdictKind":{"k":"e","v":["Trusted","SuspectOverclaim","SuspectUnderclaim","Unknown"]},"VideoCallOptions":{"k":"s","c":true,"f":{"aspectRatio":[false,["n",["r","AspectRatio"]]],"duration":[false,["n",["i",true,32]]],"fps":[false,["n",["i",true,32]]],"frameImages":[false,["n",["a",["r","VideoFrameImage"]]]],"generateAudio":[false,["n","b"]],"headers":[false,["n",["m","s"]]],"image":[false,["n",["r","VideoFile"]]],"inputReferences":[false,["n",["a",["r","VideoFile"]]]],"maxRetries":[false,["n",["i",true,32]]],"n":[false,["i",true,32]],"poll":[false,["n",["r","VideoPollOptions"]]],"prompt":[false,["n","s"]],"providerOptions":[false,["m",["m","j"]]],"resolution":[false,["n",["r","Size"]]],"seed":[false,["n",["i",true,64]]],"timeout":[false,["n",["r","TimeoutConfiguration"]]]}},"VideoData":{"k":"t","g":"type","v":[{"tv":"url","c":false,"f":{"mediaType":[true,"s"],"url":[true,"s"]}},{"tv":"base64","c":false,"f":{"data":[true,"s"],"mediaType":[true,"s"]}},{"tv":"binary","c":false,"f":{"data":[true,"s"],"mediaType":[true,"s"]}}]},"VideoFile":{"k":"t","g":"type","v":[{"tv":"file","c":false,"f":{"data":[true,["r","VideoFileData"]],"mediaType":[true,"s"]}},{"tv":"url","c":false,"f":{"mediaType":[false,["n","s"]],"url":[true,"s"]}}]},"VideoFileData":{"k":"a","t":"s"},"VideoFrameImage":{"k":"s","c":false,"f":{"frameType":[true,["r","VideoFrameType"]],"image":[true,["r","VideoFile"]]}},"VideoFrameType":{"k":"e","v":["first_frame","last_frame"]},"VideoPollOptions":{"k":"s","c":true,"f":{"intervalMs":[false,["n",["i",true,64]]],"timeoutMs":[false,["n",["i",true,64]]]}},"VideoResponse":{"k":"s","c":false,"f":{"headers":[false,["n",["m","s"]]],"modelId":[false,["n","s"]],"timestamp":[false,["n",["r","Timestamp"]]]}},"VideoResult":{"k":"s","c":false,"f":{"providerMetadata":[false,["n",["m",["m","j"]]]],"response":[true,["r","VideoResponse"]],"videos":[true,["a",["r","VideoData"]]],"warnings":[true,["a",["r","Warning"]]]}},"Warning":{"k":"t","g":"type","v":[{"tv":"unsupported","c":false,"f":{"details":[false,["n","s"]],"feature":[true,"s"]}},{"tv":"compatibility","c":false,"f":{"details":[false,["n","s"]],"feature":[true,"s"]}},{"tv":"deprecated","c":false,"f":{"message":[true,"s"],"setting":[true,"s"]}},{"tv":"other","c":false,"f":{"message":[true,"s"]}}]}} type SchemaTy = | 's' | 'b' | 'f' | 'j' | 'u64' diff --git a/bindings/node/src/generated/ops.ts b/bindings/node/src/generated/ops.ts index f833a62f2..4c86098dc 100644 --- a/bindings/node/src/generated/ops.ts +++ b/bindings/node/src/generated/ops.ts @@ -1,7 +1,7 @@ -// Generated by aimux-codegen. Do not edit. Manifest SHA-256: cd147fa9595ede3951744fa261da98cc18c204e65b4081073ad3a3c1b68bfd92 +// Generated by aimux-codegen. Do not edit. Manifest SHA-256: 6914772fdc03df08cba497def41cb354fe52e40eba49844a66938b4cd38c5d83 export const ABI_VERSION = 65536 as const; export const OPS_VERSION = "1.0" as const; -export const MANIFEST_DIGEST = "cd147fa9595ede3951744fa261da98cc18c204e65b4081073ad3a3c1b68bfd92" as const; +export const MANIFEST_DIGEST = "6914772fdc03df08cba497def41cb354fe52e40eba49844a66938b4cd38c5d83" as const; export const OP_ABORT_CREATE = "abort.create" as const; export const OP_ABORT_SIGNAL = "abort.signal" as const; export const OP_AUTH_CODEX_REFRESH = "auth.codexRefresh" as const; @@ -92,7 +92,7 @@ export const TYPE_SCHEMA_HASHES: Readonly> = { "aimux_core::embedding_model::EmbeddingResult": "af3ce0787db6208be114613c78dc02f038cb5dc2f7abcf6a4ade2be79085342e", "aimux_core::files_model::UploadFileResult": "0d17fd3dbfa601e45c9fabf62f9bb1e5028591443eafccd4eecacef0dcda0368", "aimux_core::generate::GenerateObjectResult": "21cca82de06d366b0f47d781bd49141bb63215accdd1133bb360113a60b7cc00", - "aimux_core::generate::GenerateTextResult": "c5c6016de2c926c85144959d9436c9d2214a27a9724e75d68393e933ef7263f5", + "aimux_core::generate::GenerateTextResult": "c75d0e0c2d207f9dfeffe7eb42efb9040d93a8062cdc678054f9bbcb8049e041", "aimux_core::image_model::ImageCallOptions": "ddacb8970cef4590bcdcc572ced361b181d501d3b474a2d6c50a9c0c02af3eb2", "aimux_core::image_model::ImageResult": "a9d2d939f3dc153a5b5ebc8083bea1226ff63ff2e54e4e275c9ab2b136b9e880", "aimux_core::openai_output::ChatCompletion": "503195cbe7fe458d9403a9de20b93bd17c20bbee0de40a8088bf3847ee835ad9", @@ -100,6 +100,9 @@ export const TYPE_SCHEMA_HASHES: Readonly> = { "aimux_core::recording::Recording": "56fa358fb2023da68837722ed573e00fc997506403d7c7aa516c586c45b4fd54", "aimux_core::reranking_model::RerankingCallOptions": "c481b6e7c4d5e71ea7db00166ab2952c8a893443f786a61374c7398b4e475e4c", "aimux_core::reranking_model::RerankingResult": "d757826963b3ce836e4d76fca8f42455a3a3146c20f3fb74f58cabe465348d01", + "aimux_core::result::ReasoningPart": "6210a367b8c084e55a60e0ead74a7ff233b7f357020a028c6879b54ffa8b9b87", + "aimux_core::result::TaggedToolResult": "a8f688a021397c1159b88546156d5a418e50d6482d39f88c46476297d208e069", + "aimux_core::result::TypedSource": "0a36b617c3f1bbcd82e4d09c329ad41aba62330b4d0e950125fd62b2053a9368", "aimux_core::search_model::SearchCallOptions": "3b963a871e6f1858db03b68adc74c5f898d4a2c3c0506e4e359b8d8198d30b22", "aimux_core::search_model::SearchResult": "61075439fcb4276085a11113195dd13220b710cc0c2199ceefa4ec3d07d0195f", "aimux_core::speech_model::SpeechCallOptions": "418be167c89bca652fb0a9dd52a1da359c1ecc2b069b9d2a0859ab76a7f7f431", @@ -127,10 +130,10 @@ export const TYPE_SCHEMA_HASHES: Readonly> = { "aimux_ops::ops::handles::TransportParams": "86e40584fcc21dab8f0017f8e892b776ac24aaa9afc943ba805828cecc6e1a4c", "aimux_ops::ops::misc::CatalogueFetchRequest": "2ceed496996ec6cf32d3e3115ab6a4346a1bb201dc8a970eefbd46eb700a310e", "aimux_ops::ops::misc::CodexRefreshRequest": "59f1075ed68cb79896d4bac1d0ab32d21fb5855012c6336652bea0c4969ac926", - "aimux_ops::ops::misc::OpenAiOutputRequest": "b0c6acc344f0b23b9ea3b693aeadf7aed7eb4fbdfce4b957be83af1154b842b4", - "aimux_ops::ops::misc::ToolRepairApplyRequest": "0f430fdb223759ef7c48c4d7f824e7be74d29295a6b4f7caaf82b5acba25e538", - "aimux_ops::ops::misc::ToolRepairApplyResultRequest": "fa092862004654e065233b2df2abdbec3befe88d9d734d494679968a5b6e954a", - "aimux_ops::ops::misc::ToolRepairContextRequest": "81bae04c56aac3380b75de639d162f819a2dd5717147a53cf1a75281727d78a1", + "aimux_ops::ops::misc::OpenAiOutputRequest": "d30e30aa75703e1404a202d437e69a6873fd2b515c5ed322ab488363be8d2fb0", + "aimux_ops::ops::misc::ToolRepairApplyRequest": "c1c5f81107f334a94583a4ff4ed394097580bea2f2a66266c11890fe2a3ab3d0", + "aimux_ops::ops::misc::ToolRepairApplyResultRequest": "649f2b4ff1a2dd0d552e2930b694d7efa3346b2f15a9fb0f14cffd4b6955b508", + "aimux_ops::ops::misc::ToolRepairContextRequest": "fa4802ac20a2b1b540cb727d798ad2a4c44cad6a8f9ad45281fc91ebb065e65f", "aimux_ops::ops::misc::ToolRepairContextResult": "fd8173e6ec40724fa4207e3571e290ac12e4db1fed08a709273e2982a82b504f", "aimux_ops::ops::operation::EmptyParams": "1612408252a424283a43a92193bb8ea24f72c08b9f0d2117b4ef7f5a090e37f8", "aimux_ops::ops::operation::OperationNextParams": "127fea618826e51576ae488dcccaca03c04b774a847a33ec9c47565396862bb7", @@ -164,7 +167,7 @@ export const TYPE_SCHEMA_HASHES: Readonly> = { "aimux_ops::ops::replay::ReplayCreateParams": "ee64b5b5843103f76ca2166aed2f58995e472be93cb7bb18dea8238c8a2d9e44", "aimux_ops::ops::replay::ReplayInspection": "7ac2af62f3421f8c7c50867a838f0aff90f35b6a4f192f6c0d5347ab4699108c", "aimux_ops::ops::replay::ReplayLiveParams": "e99c7d51fb194def185f5a03d84bfc226eb1b101eade0b885216332605318a4d", - "aimux_ops::ops::replay::ReplayLiveResult": "bd9959dd7e0300cb57e6929b2ed29b7e07dcb5aaf65be16b96e34bf8d6577a7f", + "aimux_ops::ops::replay::ReplayLiveResult": "9163acd59ee54db1db2213c0756283b8b27e04a52451dfeef314d63efebbc730", "aimux_ops::ops::replay::ReplayPlan": "5cc6667b9fac6de173bf5b55c1a76a491255f89f0fa7a27c0fd33fd790259799", "aimux_ops::ops::replay::ReplaySessionHandle": "5e779b71ce2a54e59948c605cdfc48797d0760027ad5f44966df958fe9781d11", "aimux_ops::ops::runtime::RuntimeConfigureParams": "e3b24b9f1fbdf2be7da210f15060803cf8bfdef77c8b2ad330a5b501263dfb0f", @@ -172,8 +175,8 @@ export const TYPE_SCHEMA_HASHES: Readonly> = { "aimux_ops::ops::session::SessionStoreCallsParams": "ddd482204fdd305bbfd28d43ae829d8c286f3f8906302ca6679743ea680fedda", "aimux_ops::ops::session::SessionStoreCreateParams": "080d865c349ec86553f72b99ab1c65ddbb72d0c348a96dc17135a934d787cd86", "aimux_ops::ops::session::SessionStoreHandle": "755d437d47d362474942fc4a09f5f8c80b75cf362ac16b25b262e33a760b4c6a", - "aimux_ops::ops::text::OpenAiTextRequest": "59293b18b6124a9a394113b8f94f637c65dc35ac44a30f7e0df70855e885f8e4", - "aimux_ops::ops::text::TextRequest": "3a6f59c1f0c3b7ded5f5509d93afe9bddd2b80a8a3cd752d79f97edadae40c3d", + "aimux_ops::ops::text::OpenAiTextRequest": "d5afbf2b24ab74b82433d344afb190c18f8aef52988c54ab8b5388579c212f67", + "aimux_ops::ops::text::TextRequest": "eb0c25fcbf741834943882d7f901af7439ba30923a391b273526d1887ed156ab", "aimux_ops::ops::trace::TraceAggregateParams": "1b207f0bbe1b7ce7e9b8b0beb9334cf3cc4f9f05382911aaacfe0425dc8ff2c8", "aimux_ops::ops::trace::TraceCreateParams": "59fef52f382800570e861ae9ca92433dcae8807679d914a89ce99705713301d9", "aimux_ops::ops::trace::TraceSessionParams": "3e2300f6c65f6dcd52a016eba648a29abeff3a9d67c3b04a95617aa66832f810", diff --git a/bindings/node/src/generated/text_result.ts b/bindings/node/src/generated/text_result.ts new file mode 100644 index 000000000..31641733c --- /dev/null +++ b/bindings/node/src/generated/text_result.ts @@ -0,0 +1,55 @@ +// Generated by aimux-codegen. Do not edit. +import type { ContentPart, GenerateTextResult, GenerateTextResultWire } from './types.ts' + +const allParts = (result: GenerateTextResultWire) => result.steps.flatMap(step => step.content) + +function partsOf(parts: ContentPart[], type: K) { + return parts.filter((part): part is Extract => part.type === type) +} + +const getters: PropertyDescriptorMap = { + finalStep: { get(this: GenerateTextResult) { return this.steps[this.steps.length - 1] } }, + content: { get(this: GenerateTextResult) { return allParts(this) } }, + text: { get(this: GenerateTextResult) { + return partsOf(this.finalStep.content, 'text').map(part => part.text).join('') + } }, + reasoning: { get(this: GenerateTextResult) { + return this.finalStep.content.filter(part => part.type === 'reasoning' || part.type === 'reasoning-file') + } }, + reasoningText: { get(this: GenerateTextResult) { + return partsOf(this.finalStep.content, 'reasoning').map(part => part.text).join('') || undefined + } }, + files: { get(this: GenerateTextResult) { return partsOf(this.content, 'file').map(part => part.file) } }, + sources: { get(this: GenerateTextResult) { return partsOf(this.content, 'source') } }, + toolCalls: { get(this: GenerateTextResult) { return partsOf(this.content, 'tool-call') } }, + staticToolCalls: { get(this: GenerateTextResult) { return this.toolCalls.filter(part => part.dynamic !== true) } }, + dynamicToolCalls: { get(this: GenerateTextResult) { return this.toolCalls.filter(part => part.dynamic === true) } }, + toolResults: { get(this: GenerateTextResult) { return partsOf(this.content, 'tool-result') } }, + staticToolResults: { get(this: GenerateTextResult) { return this.toolResults.filter(part => part.dynamic !== true) } }, + dynamicToolResults: { get(this: GenerateTextResult) { return this.toolResults.filter(part => part.dynamic === true) } }, + finishReason: { get(this: GenerateTextResult) { return this.finalStep.finishReason } }, + rawFinishReason: { get(this: GenerateTextResult) { return this.finalStep.rawFinishReason } }, + usage: { get(this: GenerateTextResult) { return this.totalUsage } }, + warnings: { get(this: GenerateTextResult) { return this.steps.flatMap(step => step.warnings) } }, + request: { get(this: GenerateTextResult) { return this.finalStep.request } }, + response: { get(this: GenerateTextResult) { return this.finalStep.response } }, + providerMetadata: { get(this: GenerateTextResult) { return this.finalStep.providerMetadata } }, + responseMessages: { get(this: GenerateTextResult) { + return this.steps.flatMap(step => step.response.messages) + } }, +} + +export function attachGenerateTextResult(result: GenerateTextResultWire): GenerateTextResult { + if (!Array.isArray(result?.steps) || result.steps.length === 0) { + throw new TypeError('GenerateTextResult requires at least one step') + } + const hasExplicitOutput = Object.prototype.hasOwnProperty.call(result, 'output') + if (hasExplicitOutput && result.outputParsed === false) { + throw new TypeError('GenerateTextResult cannot carry output when outputParsed is false') + } + Object.defineProperties(result, getters) + if (!hasExplicitOutput && result.outputParsed !== false) { + Object.defineProperty(result, 'output', { get(this: GenerateTextResult) { return this.text } }) + } + return result as GenerateTextResult +} diff --git a/bindings/node/src/generated/types.ts b/bindings/node/src/generated/types.ts index 612f37312..13b6964e2 100644 --- a/bindings/node/src/generated/types.ts +++ b/bindings/node/src/generated/types.ts @@ -1852,6 +1852,10 @@ export interface GenerateObjectResult { export interface GenerateTextOptions { frequencyPenalty?: number | null headers?: Record | null + /** + * Controls the raw bodies exposed in the result. Both default to `false`. + */ + include?: IncludeOptions | null /** * Emit raw provider stream chunks as `StreamPart::Raw` (debugging aid). */ @@ -1914,76 +1918,74 @@ export interface GenerateTextOptions { * * It stores the steps, the usage summed over them and the parsed output, as * `DefaultGenerateTextResult` does (`generate-text.ts:1691-1808`); every - * other value is derived from the steps by an accessor. The serialized form - * is a snapshot that writes the derived values next to the stored ones, so - * a binding reads `text`, `tool_calls`, `usage` and the rest directly. Only - * `steps`, `total_usage` and `output` are read back. + * other value is derived from the steps by an accessor. The wire form carries + * `steps`, `totalUsage`, optional `output` (when explicitly parsed), and + * optional `outputParsed: false` (when no output was generated). */ -export interface GenerateTextResult { - content: Array - files: Array - finishReason: FinishReasonUnified +export interface GenerateTextResultWire { /** - * Absent when the output was not parsed. + * An explicit parsed output, including JSON `null`. When absent and + * `outputParsed` is not `false`, bindings expose the final step's text. */ output?: unknown /** - * Deprecated upstream: the last step's provider metadata. - */ - providerMetadata?: Record> | null - rawFinishReason?: string | null - /** - * Deprecated upstream: the last step's reasoning. - */ - reasoning: Array - /** - * Deprecated upstream: the last step's reasoning text. - */ - reasoningText?: string | null - /** - * Deprecated upstream: the last step's request. - */ - request: RequestInfo - /** - * Deprecated upstream: the last step's response. + * Present and `false` when no output was generated (for example, a final + * `tool-calls` step without an output spec). Omitted when an output was + * produced. */ - response: StepResponse - responseMessages: Array - /** - * Each with its `type` tag (`generate-text-result.ts:73`). - */ - sources: Array + outputParsed?: boolean | null steps: Array - text: string - /** - * Each with its `type` tag (`generate-text-result.ts:78`). - */ - toolCalls: Array - /** - * Each with its `type` tag (`generate-text-result.ts:93`). - */ - toolResults: Array - /** - * Deprecated upstream: equal to `usage`. - */ totalUsage: LanguageModelUsage - usage: LanguageModelUsage - warnings: Array } + +/** A text result returned by the typed client. Derived properties are non-enumerable. */ +export interface GenerateTextResult extends GenerateTextResultWire { + readonly output?: unknown + readonly finalStep: StepResult + readonly content: ContentPart[] + readonly text: string + readonly reasoning: ReasoningPart[] + readonly reasoningText?: string + readonly files: GeneratedFile[] + readonly sources: TypedSource[] + readonly toolCalls: TypedToolCall[] + readonly staticToolCalls: GenerateTextResult['toolCalls'] + readonly dynamicToolCalls: GenerateTextResult['toolCalls'] + readonly toolResults: TaggedToolResult[] + readonly staticToolResults: GenerateTextResult['toolResults'] + readonly dynamicToolResults: GenerateTextResult['toolResults'] + readonly finishReason: FinishReasonUnified + readonly rawFinishReason?: string | null + readonly usage: LanguageModelUsage + readonly warnings: Warning[] + readonly request: RequestInfo + readonly response: StepResponse + readonly providerMetadata?: StepResult['providerMetadata'] + readonly responseMessages: ModelMessage[] +} /** * Result of `generate_text` and of a consumed `stream_text`: the AI SDK's * `GenerateTextResult` (ai@7.0.127 `generate-text/generate-text-result.ts`). * * It stores the steps, the usage summed over them and the parsed output, as * `DefaultGenerateTextResult` does (`generate-text.ts:1691-1808`); every - * other value is derived from the steps by an accessor. The serialized form - * is a snapshot that writes the derived values next to the stored ones, so - * a binding reads `text`, `tool_calls`, `usage` and the rest directly. Only - * `steps`, `total_usage` and `output` are read back. + * other value is derived from the steps by an accessor. The wire form carries + * `steps`, `totalUsage`, optional `output` (when explicitly parsed), and + * optional `outputParsed: false` (when no output was generated). */ export interface GenerateTextResultInput { + /** + * An explicit parsed output, including JSON `null`. When absent and + * `outputParsed` is not `false`, bindings expose the final step's text. + */ output?: unknown + /** + * Present and `false` when no output was generated (for example, a final + * `tool-calls` step without an output spec). Omitted when an output was + * produced. + */ + outputParsed?: boolean | null steps: Array totalUsage: LanguageModelUsageInput } @@ -2262,6 +2264,20 @@ export interface ImageUsage { totalTokens?: number | null } +/** + * Controls which raw body fields are exposed in generation results. + */ +export interface IncludeOptions { + /** + * Whether to return the request body. Defaults to false. + */ + requestBody?: boolean | null + /** + * Whether to return the response body. Defaults to false. + */ + responseBody?: boolean | null +} + /** * The input audio format for a streaming transcription request. */ @@ -2816,6 +2832,10 @@ export interface OperationStatus { export interface Options { frequencyPenalty?: number | null headers?: Record | null + /** + * Controls the raw bodies exposed in the result. Both default to `false`. + */ + include?: IncludeOptions | null /** * Emit raw provider stream chunks as `StreamPart::Raw` (debugging aid). */ diff --git a/bindings/node/src/index.ts b/bindings/node/src/index.ts index f84bc5d60..94136a864 100644 --- a/bindings/node/src/index.ts +++ b/bindings/node/src/index.ts @@ -1,3 +1,4 @@ +import { attachGenerateTextResult } from './generated/text_result.ts' import * as ops from './generated/ops.ts' import { Runtime } from './native.ts' import type { Abort as RawAbort, Manifest } from './native.ts' @@ -10,6 +11,8 @@ import type { GenerateObjectResult, GenerateTextOptions, GenerateTextResult, + GenerateTextResultWire, + ReplayLiveResult, HandleKind, HandleResult, ImageCallOptions, @@ -74,7 +77,18 @@ export class Client { async call(handle: string, op: string, params: unknown = {}, options: CallOptions = {}): Promise { const abort = this.bridge(options) - return JSON.parse(await this.raw.call(handle, op, json(params), abort)) as T + const result = JSON.parse(await this.raw.call(handle, op, json(params), abort)) + switch (op) { + case ops.OP_TEXT_GENERATE: + case ops.OP_TEXT_CONSUME: + case ops.OP_TOOL_REPAIR_APPLY_RESULT: + return attachGenerateTextResult(result as GenerateTextResultWire) as T + case ops.OP_REPLAY_LIVE: + if (Object.prototype.hasOwnProperty.call(result, 'steps')) { + return attachGenerateTextResult(result as GenerateTextResultWire) as T + } + } + return result as T } async stream(handle: string, op: string, params: unknown = {}, options: CallOptions = {}): Promise> { @@ -270,7 +284,7 @@ export class ReplaySession extends Resource { async capabilities(): Promise { return this.call(ops.OP_REPLAY_CAPABILITIES) } async inspect(): Promise { return this.call(ops.OP_REPLAY_INSPECT) } async dryRun(params: unknown = {}): Promise { return this.call(ops.OP_REPLAY_DRY_RUN, params) } - async live(params: unknown): Promise { return this.call(ops.OP_REPLAY_LIVE, params) } + async live(params: unknown): Promise { return this.call(ops.OP_REPLAY_LIVE, params) } } function mapIterator(inner: AsyncIterableIterator, map: (value: A) => B, cancel: () => void): AsyncIterableIterator { diff --git a/bindings/python/python/aimux/_types.py b/bindings/python/python/aimux/_types.py index bcf50d570..2ebca547f 100644 --- a/bindings/python/python/aimux/_types.py +++ b/bindings/python/python/aimux/_types.py @@ -9,7 +9,7 @@ from pydantic import ( BaseModel, BeforeValidator, ConfigDict, Discriminator, Field, Tag, - model_serializer, + model_serializer, model_validator, ) from typing_extensions import TypeAliasType @@ -1768,6 +1768,8 @@ class GenerateTextOptions(_Wire): model_config = ConfigDict(extra="forbid") frequency_penalty: Optional[float] = Field(default=None, alias="frequencyPenalty") headers: Optional[Dict[str, str]] = Field(default=None, alias="headers") + #: Controls the raw bodies exposed in the result. Both default to `false`. + include: Optional["_dto.IncludeOptions"] = Field(default=None, alias="include") #: Emit raw provider stream chunks as `StreamPart::Raw` (debugging aid). include_raw_chunks: Optional[bool] = Field(default=None, alias="includeRawChunks") #: System instructions prepended to the prompt. @@ -1806,7 +1808,7 @@ class GenerateTextOptions(_Wire): tools: Optional[List["_dto.Tool"]] = Field(default=None, alias="tools") top_k: Optional[float] = Field(default=None, alias="topK") top_p: Optional[float] = Field(default=None, alias="topP") - _omit_null: ClassVar[frozenset[str]] = frozenset(["frequency_penalty", "headers", "include_raw_chunks", "instructions", "max_output_tokens", "max_retries", "output", "presence_penalty", "provider_options", "reasoning", "seed", "session_id", "stop_sequences", "strict_stream", "temperature", "timeout", "tool_choice", "tools", "top_k", "top_p"]) + _omit_null: ClassVar[frozenset[str]] = frozenset(["frequency_penalty", "headers", "include", "include_raw_chunks", "instructions", "max_output_tokens", "max_retries", "output", "presence_penalty", "provider_options", "reasoning", "seed", "session_id", "stop_sequences", "strict_stream", "temperature", "timeout", "tool_choice", "tools", "top_k", "top_p"]) #: Result of `generate_text` and of a consumed `stream_text`: the AI SDK's @@ -1814,41 +1816,119 @@ class GenerateTextOptions(_Wire): #: #: It stores the steps, the usage summed over them and the parsed output, as #: `DefaultGenerateTextResult` does (`generate-text.ts:1691-1808`); every -#: other value is derived from the steps by an accessor. The serialized form -#: is a snapshot that writes the derived values next to the stored ones, so -#: a binding reads `text`, `tool_calls`, `usage` and the rest directly. Only -#: `steps`, `total_usage` and `output` are read back. +#: other value is derived from the steps by an accessor. The wire form carries +#: `steps`, `totalUsage`, optional `output` (when explicitly parsed), and +#: optional `outputParsed: false` (when no output was generated). class GenerateTextResult(_Wire): - content: List["_dto.ContentPart"] = Field(alias="content") - files: List["_dto.GeneratedFile"] = Field(alias="files") - finish_reason: "_dto.FinishReasonUnified" = Field(alias="finishReason") - #: Absent when the output was not parsed. - output: Optional[Any] = Field(default=None, alias="output") - #: Deprecated upstream: the last step's provider metadata. - provider_metadata: Optional[Dict[str, Dict[str, Any]]] = Field(default=None, alias="providerMetadata") - raw_finish_reason: Optional[str] = Field(default=None, alias="rawFinishReason") - #: Deprecated upstream: the last step's reasoning. - reasoning: List["_dto.ReasoningPart"] = Field(alias="reasoning") - #: Deprecated upstream: the last step's reasoning text. - reasoning_text: Optional[str] = Field(default=None, alias="reasoningText") - #: Deprecated upstream: the last step's request. - request: "_dto.RequestInfo" = Field(alias="request") - #: Deprecated upstream: the last step's response. - response: "_dto.StepResponse" = Field(alias="response") - response_messages: List["_dto.ModelMessage"] = Field(alias="responseMessages") - #: Each with its `type` tag (`generate-text-result.ts:73`). - sources: List["_dto.TypedSource"] = Field(alias="sources") - steps: List["_dto.StepResult"] = Field(alias="steps") - text: str = Field(alias="text") - #: Each with its `type` tag (`generate-text-result.ts:78`). - tool_calls: List["_dto.TypedToolCall"] = Field(alias="toolCalls") - #: Each with its `type` tag (`generate-text-result.ts:93`). - tool_results: List["_dto.TaggedToolResult"] = Field(alias="toolResults") - #: Deprecated upstream: equal to `usage`. + #: An explicit parsed output, including JSON `null`. When absent and + #: `outputParsed` is not `false`, bindings expose the final step's text. + output_value: Optional[Any] = Field(default=None, alias="output") + #: Present and `false` when no output was generated (for example, a final + #: `tool-calls` step without an output spec). Omitted when an output was + #: produced. + output_parsed: Optional[bool] = Field(default=None, alias="outputParsed") + steps: List["_dto.StepResult"] = Field(min_length=1, alias="steps") total_usage: "_dto.LanguageModelUsage" = Field(alias="totalUsage") - usage: "_dto.LanguageModelUsage" = Field(alias="usage") - warnings: List["_dto.Warning"] = Field(alias="warnings") - _omit_null: ClassVar[frozenset[str]] = frozenset(["provider_metadata", "raw_finish_reason", "reasoning_text"]) + _omit_null: ClassVar[frozenset[str]] = frozenset(["output_parsed"]) + + @property + def final_step(self) -> StepResult: + return self.steps[-1] + + @property + def text(self) -> str: + return "".join(part.text for part in self.final_step.content if isinstance(part, ContentPartText)) + + @property + def content(self) -> list[ContentPart]: + return [part for step in self.steps for part in step.content] + + @property + def reasoning(self) -> list[ContentPartReasoning | ContentPartReasoningFile]: + return [part for part in self.final_step.content + if isinstance(part, (ContentPartReasoning, ContentPartReasoningFile))] + + @property + def reasoning_text(self) -> Optional[str]: + return "".join(part.text for part in self.reasoning if isinstance(part, ContentPartReasoning)) or None + + @property + def files(self) -> list[GeneratedFile]: + return [part.file for part in self.content if isinstance(part, ContentPartFile)] + + @property + def sources(self) -> list[ContentPartSourceUrl | ContentPartSourceDocument]: + return [part for part in self.content if isinstance(part, (ContentPartSourceUrl, ContentPartSourceDocument))] + + @property + def tool_calls(self) -> list[ContentPartToolCall]: + return [part for part in self.content if isinstance(part, ContentPartToolCall)] + + @property + def static_tool_calls(self) -> list[ContentPartToolCall]: + return [part for part in self.tool_calls if part.dynamic is not True] + + @property + def dynamic_tool_calls(self) -> list[ContentPartToolCall]: + return [part for part in self.tool_calls if part.dynamic is True] + + @property + def tool_results(self) -> list[ContentPartToolResult]: + return [part for part in self.content if isinstance(part, ContentPartToolResult)] + + @property + def static_tool_results(self) -> list[ContentPartToolResult]: + return [part for part in self.tool_results if part.dynamic is not True] + + @property + def dynamic_tool_results(self) -> list[ContentPartToolResult]: + return [part for part in self.tool_results if part.dynamic is True] + + @property + def finish_reason(self) -> FinishReasonUnified: + return self.final_step.finish_reason + + @property + def raw_finish_reason(self) -> Optional[str]: + return self.final_step.raw_finish_reason + + @property + def usage(self) -> LanguageModelUsage: + return self.total_usage + + @property + def warnings(self) -> list[Warning]: + return [warning for step in self.steps for warning in step.warnings] + + @property + def request(self) -> RequestInfo: + return self.final_step.request + + @property + def response(self) -> StepResponse: + return self.final_step.response + + @property + def provider_metadata(self) -> Optional[dict[str, dict[str, Any]]]: + return self.final_step.provider_metadata + + @property + def response_messages(self) -> list[ModelMessage]: + return [message for step in self.steps for message in step.response.messages] + + @model_validator(mode="after") + def _validate_output_state(self) -> "GenerateTextResult": + if "output_value" in self.model_fields_set and self.output_parsed is False: + raise ValueError("GenerateTextResult cannot carry output when outputParsed is false") + return self + + @property + def output(self) -> Any: + if "output_value" in self.model_fields_set: + return self.output_value + if self.output_parsed is False: + return None + return self.text #: Result of `generate_text` and of a consumed `stream_text`: the AI SDK's @@ -1856,14 +1936,20 @@ class GenerateTextResult(_Wire): #: #: It stores the steps, the usage summed over them and the parsed output, as #: `DefaultGenerateTextResult` does (`generate-text.ts:1691-1808`); every -#: other value is derived from the steps by an accessor. The serialized form -#: is a snapshot that writes the derived values next to the stored ones, so -#: a binding reads `text`, `tool_calls`, `usage` and the rest directly. Only -#: `steps`, `total_usage` and `output` are read back. +#: other value is derived from the steps by an accessor. The wire form carries +#: `steps`, `totalUsage`, optional `output` (when explicitly parsed), and +#: optional `outputParsed: false` (when no output was generated). class GenerateTextResultInput(_Wire): + #: An explicit parsed output, including JSON `null`. When absent and + #: `outputParsed` is not `false`, bindings expose the final step's text. output: Optional[Any] = Field(default=None, alias="output") + #: Present and `false` when no output was generated (for example, a final + #: `tool-calls` step without an output spec). Omitted when an output was + #: produced. + output_parsed: Optional[bool] = Field(default=None, alias="outputParsed") steps: List["_dto.StepResultInput"] = Field(alias="steps") total_usage: "_dto.LanguageModelUsageInput" = Field(alias="totalUsage") + _omit_null: ClassVar[frozenset[str]] = frozenset(["output_parsed"]) #: A generated file (`ai` `generate-text/generated-file.ts:10-32`), the @@ -2062,6 +2148,16 @@ class ImageUsage(_Wire): _omit_null: ClassVar[frozenset[str]] = frozenset(["input_tokens", "output_tokens", "total_tokens"]) +#: Controls which raw body fields are exposed in generation results. +class IncludeOptions(_Wire): + model_config = ConfigDict(extra="forbid") + #: Whether to return the request body. Defaults to false. + request_body: Optional[bool] = Field(default=None, alias="requestBody") + #: Whether to return the response body. Defaults to false. + response_body: Optional[bool] = Field(default=None, alias="responseBody") + _omit_null: ClassVar[frozenset[str]] = frozenset(["request_body", "response_body"]) + + #: The input audio format for a streaming transcription request. class InputAudioFormat(_Wire): model_config = ConfigDict(extra="forbid") @@ -2562,6 +2658,8 @@ class Options(_Wire): model_config = ConfigDict(extra="forbid") frequency_penalty: Optional[float] = Field(default=None, alias="frequencyPenalty") headers: Optional[Dict[str, str]] = Field(default=None, alias="headers") + #: Controls the raw bodies exposed in the result. Both default to `false`. + include: Optional["_dto.IncludeOptions"] = Field(default=None, alias="include") #: Emit raw provider stream chunks as `StreamPart::Raw` (debugging aid). include_raw_chunks: Optional[bool] = Field(default=None, alias="includeRawChunks") #: System instructions prepended to the prompt. @@ -2600,7 +2698,7 @@ class Options(_Wire): tools: Optional[List["_dto.Tool"]] = Field(default=None, alias="tools") top_k: Optional[float] = Field(default=None, alias="topK") top_p: Optional[float] = Field(default=None, alias="topP") - _omit_null: ClassVar[frozenset[str]] = frozenset(["frequency_penalty", "headers", "include_raw_chunks", "instructions", "max_output_tokens", "max_retries", "output", "presence_penalty", "provider_options", "reasoning", "seed", "session_id", "stop_sequences", "strict_stream", "temperature", "timeout", "tool_choice", "tools", "top_k", "top_p"]) + _omit_null: ClassVar[frozenset[str]] = frozenset(["frequency_penalty", "headers", "include", "include_raw_chunks", "instructions", "max_output_tokens", "max_retries", "output", "presence_penalty", "provider_options", "reasoning", "seed", "session_id", "stop_sequences", "strict_stream", "temperature", "timeout", "tool_choice", "tools", "top_k", "top_p"]) Outcome = TypeAliasType("Outcome", Literal["success", "error", "cancelled"]) @@ -5655,6 +5753,7 @@ class WarningOther(_Wire): ImageResponse.model_rebuild(_types_namespace=globals()) ImageResult.model_rebuild(_types_namespace=globals()) ImageUsage.model_rebuild(_types_namespace=globals()) +IncludeOptions.model_rebuild(_types_namespace=globals()) InputAudioFormat.model_rebuild(_types_namespace=globals()) InputRecord.model_rebuild(_types_namespace=globals()) InputTokenDetails.model_rebuild(_types_namespace=globals()) @@ -6032,6 +6131,7 @@ class WarningOther(_Wire): "ImageResponse": ImageResponse, "ImageResult": ImageResult, "ImageUsage": ImageUsage, + "IncludeOptions": IncludeOptions, "InputAudioFormat": InputAudioFormat, "InputRecord": InputRecord, "InputTokenDetails": InputTokenDetails, @@ -6469,6 +6569,7 @@ class WarningOther(_Wire): "ImageResponse", "ImageResult", "ImageUsage", + "IncludeOptions", "InputAudioFormat", "InputRecord", "InputTokenDetails", diff --git a/bindings/python/python/aimux/ops.py b/bindings/python/python/aimux/ops.py index 732da9317..b4f900bb1 100644 --- a/bindings/python/python/aimux/ops.py +++ b/bindings/python/python/aimux/ops.py @@ -1,7 +1,7 @@ -# Generated by aimux-codegen. Do not edit. Manifest SHA-256: cd147fa9595ede3951744fa261da98cc18c204e65b4081073ad3a3c1b68bfd92 +# Generated by aimux-codegen. Do not edit. Manifest SHA-256: 6914772fdc03df08cba497def41cb354fe52e40eba49844a66938b4cd38c5d83 ABI_VERSION = 65536 OPS_VERSION = "1.0" -MANIFEST_DIGEST = "cd147fa9595ede3951744fa261da98cc18c204e65b4081073ad3a3c1b68bfd92" +MANIFEST_DIGEST = "6914772fdc03df08cba497def41cb354fe52e40eba49844a66938b4cd38c5d83" OP_ABORT_CREATE = "abort.create" OP_ABORT_SIGNAL = "abort.signal" OP_AUTH_CODEX_REFRESH = "auth.codexRefresh" @@ -92,7 +92,7 @@ "aimux_core::embedding_model::EmbeddingResult": "af3ce0787db6208be114613c78dc02f038cb5dc2f7abcf6a4ade2be79085342e", "aimux_core::files_model::UploadFileResult": "0d17fd3dbfa601e45c9fabf62f9bb1e5028591443eafccd4eecacef0dcda0368", "aimux_core::generate::GenerateObjectResult": "21cca82de06d366b0f47d781bd49141bb63215accdd1133bb360113a60b7cc00", - "aimux_core::generate::GenerateTextResult": "c5c6016de2c926c85144959d9436c9d2214a27a9724e75d68393e933ef7263f5", + "aimux_core::generate::GenerateTextResult": "c75d0e0c2d207f9dfeffe7eb42efb9040d93a8062cdc678054f9bbcb8049e041", "aimux_core::image_model::ImageCallOptions": "ddacb8970cef4590bcdcc572ced361b181d501d3b474a2d6c50a9c0c02af3eb2", "aimux_core::image_model::ImageResult": "a9d2d939f3dc153a5b5ebc8083bea1226ff63ff2e54e4e275c9ab2b136b9e880", "aimux_core::openai_output::ChatCompletion": "503195cbe7fe458d9403a9de20b93bd17c20bbee0de40a8088bf3847ee835ad9", @@ -100,6 +100,9 @@ "aimux_core::recording::Recording": "56fa358fb2023da68837722ed573e00fc997506403d7c7aa516c586c45b4fd54", "aimux_core::reranking_model::RerankingCallOptions": "c481b6e7c4d5e71ea7db00166ab2952c8a893443f786a61374c7398b4e475e4c", "aimux_core::reranking_model::RerankingResult": "d757826963b3ce836e4d76fca8f42455a3a3146c20f3fb74f58cabe465348d01", + "aimux_core::result::ReasoningPart": "6210a367b8c084e55a60e0ead74a7ff233b7f357020a028c6879b54ffa8b9b87", + "aimux_core::result::TaggedToolResult": "a8f688a021397c1159b88546156d5a418e50d6482d39f88c46476297d208e069", + "aimux_core::result::TypedSource": "0a36b617c3f1bbcd82e4d09c329ad41aba62330b4d0e950125fd62b2053a9368", "aimux_core::search_model::SearchCallOptions": "3b963a871e6f1858db03b68adc74c5f898d4a2c3c0506e4e359b8d8198d30b22", "aimux_core::search_model::SearchResult": "61075439fcb4276085a11113195dd13220b710cc0c2199ceefa4ec3d07d0195f", "aimux_core::speech_model::SpeechCallOptions": "418be167c89bca652fb0a9dd52a1da359c1ecc2b069b9d2a0859ab76a7f7f431", @@ -127,10 +130,10 @@ "aimux_ops::ops::handles::TransportParams": "86e40584fcc21dab8f0017f8e892b776ac24aaa9afc943ba805828cecc6e1a4c", "aimux_ops::ops::misc::CatalogueFetchRequest": "2ceed496996ec6cf32d3e3115ab6a4346a1bb201dc8a970eefbd46eb700a310e", "aimux_ops::ops::misc::CodexRefreshRequest": "59f1075ed68cb79896d4bac1d0ab32d21fb5855012c6336652bea0c4969ac926", - "aimux_ops::ops::misc::OpenAiOutputRequest": "b0c6acc344f0b23b9ea3b693aeadf7aed7eb4fbdfce4b957be83af1154b842b4", - "aimux_ops::ops::misc::ToolRepairApplyRequest": "0f430fdb223759ef7c48c4d7f824e7be74d29295a6b4f7caaf82b5acba25e538", - "aimux_ops::ops::misc::ToolRepairApplyResultRequest": "fa092862004654e065233b2df2abdbec3befe88d9d734d494679968a5b6e954a", - "aimux_ops::ops::misc::ToolRepairContextRequest": "81bae04c56aac3380b75de639d162f819a2dd5717147a53cf1a75281727d78a1", + "aimux_ops::ops::misc::OpenAiOutputRequest": "d30e30aa75703e1404a202d437e69a6873fd2b515c5ed322ab488363be8d2fb0", + "aimux_ops::ops::misc::ToolRepairApplyRequest": "c1c5f81107f334a94583a4ff4ed394097580bea2f2a66266c11890fe2a3ab3d0", + "aimux_ops::ops::misc::ToolRepairApplyResultRequest": "649f2b4ff1a2dd0d552e2930b694d7efa3346b2f15a9fb0f14cffd4b6955b508", + "aimux_ops::ops::misc::ToolRepairContextRequest": "fa4802ac20a2b1b540cb727d798ad2a4c44cad6a8f9ad45281fc91ebb065e65f", "aimux_ops::ops::misc::ToolRepairContextResult": "fd8173e6ec40724fa4207e3571e290ac12e4db1fed08a709273e2982a82b504f", "aimux_ops::ops::operation::EmptyParams": "1612408252a424283a43a92193bb8ea24f72c08b9f0d2117b4ef7f5a090e37f8", "aimux_ops::ops::operation::OperationNextParams": "127fea618826e51576ae488dcccaca03c04b774a847a33ec9c47565396862bb7", @@ -164,7 +167,7 @@ "aimux_ops::ops::replay::ReplayCreateParams": "ee64b5b5843103f76ca2166aed2f58995e472be93cb7bb18dea8238c8a2d9e44", "aimux_ops::ops::replay::ReplayInspection": "7ac2af62f3421f8c7c50867a838f0aff90f35b6a4f192f6c0d5347ab4699108c", "aimux_ops::ops::replay::ReplayLiveParams": "e99c7d51fb194def185f5a03d84bfc226eb1b101eade0b885216332605318a4d", - "aimux_ops::ops::replay::ReplayLiveResult": "bd9959dd7e0300cb57e6929b2ed29b7e07dcb5aaf65be16b96e34bf8d6577a7f", + "aimux_ops::ops::replay::ReplayLiveResult": "9163acd59ee54db1db2213c0756283b8b27e04a52451dfeef314d63efebbc730", "aimux_ops::ops::replay::ReplayPlan": "5cc6667b9fac6de173bf5b55c1a76a491255f89f0fa7a27c0fd33fd790259799", "aimux_ops::ops::replay::ReplaySessionHandle": "5e779b71ce2a54e59948c605cdfc48797d0760027ad5f44966df958fe9781d11", "aimux_ops::ops::runtime::RuntimeConfigureParams": "e3b24b9f1fbdf2be7da210f15060803cf8bfdef77c8b2ad330a5b501263dfb0f", @@ -172,8 +175,8 @@ "aimux_ops::ops::session::SessionStoreCallsParams": "ddd482204fdd305bbfd28d43ae829d8c286f3f8906302ca6679743ea680fedda", "aimux_ops::ops::session::SessionStoreCreateParams": "080d865c349ec86553f72b99ab1c65ddbb72d0c348a96dc17135a934d787cd86", "aimux_ops::ops::session::SessionStoreHandle": "755d437d47d362474942fc4a09f5f8c80b75cf362ac16b25b262e33a760b4c6a", - "aimux_ops::ops::text::OpenAiTextRequest": "59293b18b6124a9a394113b8f94f637c65dc35ac44a30f7e0df70855e885f8e4", - "aimux_ops::ops::text::TextRequest": "3a6f59c1f0c3b7ded5f5509d93afe9bddd2b80a8a3cd752d79f97edadae40c3d", + "aimux_ops::ops::text::OpenAiTextRequest": "d5afbf2b24ab74b82433d344afb190c18f8aef52988c54ab8b5388579c212f67", + "aimux_ops::ops::text::TextRequest": "eb0c25fcbf741834943882d7f901af7439ba30923a391b273526d1887ed156ab", "aimux_ops::ops::trace::TraceAggregateParams": "1b207f0bbe1b7ce7e9b8b0beb9334cf3cc4f9f05382911aaacfe0425dc8ff2c8", "aimux_ops::ops::trace::TraceCreateParams": "59fef52f382800570e861ae9ca92433dcae8807679d914a89ce99705713301d9", "aimux_ops::ops::trace::TraceSessionParams": "3e2300f6c65f6dcd52a016eba648a29abeff3a9d67c3b04a95617aa66832f810", diff --git a/bindings/python/tests/test_ops_integration.py b/bindings/python/tests/test_ops_integration.py index aba5ab1e8..a2c23ba99 100644 --- a/bindings/python/tests/test_ops_integration.py +++ b/bindings/python/tests/test_ops_integration.py @@ -224,8 +224,12 @@ def test_text_and_streams(self): self.assertEqual(result['choices'][0]['message']['content'], 'Rust is a systems programming language.') else: - self.assertEqual(result['text'], 'Hello world' if op == ops.OP_TEXT_CONSUME + from aimux.wrapper import GenerateTextResult + typed = GenerateTextResult.model_validate(result) + self.assertEqual(typed.text, 'Hello world' if op == ops.OP_TEXT_CONSUME else 'Rust is a systems programming language.') + self.assertEqual(typed.output, typed.text) + self.assertEqual(set(result), {'steps', 'totalUsage'}) def test_video_and_decision(self): from gil_ops import video, decision diff --git a/bindings/python/tests/test_ops_wrapper.py b/bindings/python/tests/test_ops_wrapper.py index 43e4a3766..0fe786a0b 100644 --- a/bindings/python/tests/test_ops_wrapper.py +++ b/bindings/python/tests/test_ops_wrapper.py @@ -84,17 +84,33 @@ def test_standalone_tool_calls_and_sources_are_tagged(self): call = {"type": "tool-call", "toolCallId": "call-1", "toolName": "weather", "input": {"city": "SG"}} url = {"type": "source", "sourceType": "url", "id": "s1", "url": "https://example.com"} - result = GenerateTextResult.model_validate( - {"text": "", "finishReason": "stop", "toolCalls": [call], "sources": [url], - "content": [], "reasoning": [], "files": [], "toolResults": [], - "usage": {"inputTokenDetails": {}, "outputTokenDetails": {}}, - "totalUsage": {"inputTokenDetails": {}, "outputTokenDetails": {}}, "warnings": [], "request": {}, - "response": {"id": "r", "timestamp": "2026-01-01T00:00:00Z", "modelId": "m", "messages": []}, - "responseMessages": [], "steps": []} - ) - dumped = result.model_dump(by_alias=True) - assert dumped["toolCalls"] == [call] - assert dumped["sources"] == [url] + usage = {"inputTokenDetails": {}, "outputTokenDetails": {}} + step = { + "callId": "c", "stepNumber": 0, "model": {"modelId": "m", "provider": "openai"}, + "content": [call, url, {"type": "text", "text": "ok"}], "finishReason": "stop", + "usage": usage, "warnings": [], "request": {}, + "response": {"id": "r", "timestamp": "2026-01-01T00:00:00Z", "modelId": "m", "messages": []}, + "performance": {"effectiveOutputTokensPerSecond": 0, "effectiveTotalTokensPerSecond": 0, + "responseTimeMs": 0, "stepTimeMs": 0, "toolExecutionMs": {}}, + } + facts = {"steps": [step], "totalUsage": usage} + from pydantic import ValidationError + with self.assertRaises(ValidationError): + GenerateTextResult.model_validate({**facts, "steps": []}) + result = GenerateTextResult.model_validate(facts) + assert [part.model_dump(by_alias=True) for part in result.tool_calls] == [call] + assert [part.model_dump(by_alias=True) for part in result.sources] == [url] + assert result.output == "ok" + parsed_null = GenerateTextResult.model_validate({**facts, "output": None}) + assert parsed_null.output is None + assert parsed_null.model_dump(by_alias=True)["output"] is None + not_parsed = GenerateTextResult.model_validate({**facts, "outputParsed": False}) + assert not_parsed.output is None + assert not_parsed.output_parsed is False + assert not_parsed.model_dump(by_alias=True) == {**facts, "outputParsed": False} + with self.assertRaises(ValidationError): + GenerateTextResult.model_validate({**facts, "output": None, "outputParsed": False}) + assert set(result.model_dump(by_alias=True)) == {"steps", "totalUsage"} assert TaggedRawToolCall(type="tool-call", tool_call_id="c", tool_name="t", input="{}").model_dump(by_alias=True) == { "type": "tool-call", "toolCallId": "c", "toolName": "t", "input": "{}", } diff --git a/bindings/swift/Tests/AimuxTests/WireTests.swift b/bindings/swift/Tests/AimuxTests/WireTests.swift index 074dce15d..1bcfb7473 100644 --- a/bindings/swift/Tests/AimuxTests/WireTests.swift +++ b/bindings/swift/Tests/AimuxTests/WireTests.swift @@ -151,55 +151,42 @@ struct WireTests { static func testGenerateTextResultRoundTrip() throws { let json = """ { - "content": [ - {"type":"text","text":"hello"}, - {"type":"tool-call","toolCallId":"call_1","toolName":"get_weather","input":{"location":"Tokyo"}} - ], - "text": "hello", - "reasoning": [{"type":"reasoning","text":"hmm"}], - "reasoningText": "hmm", - "files": [], - "sources": [{"type":"source","sourceType":"url","id":"s1","url":"https://example.com"}], - "toolCalls": [ - {"type":"tool-call","toolCallId":"call_1","toolName":"get_weather","input":{"location":"Tokyo"}} - ], - "toolResults": [], - "finishReason": "tool-calls", - "rawFinishReason": "tool_calls", - "usage": {"inputTokens":3,"inputTokenDetails":{},"outputTokens":2,"outputTokenDetails":{},"totalTokens":5}, "totalUsage": {"inputTokens":3,"inputTokenDetails":{},"outputTokens":2,"outputTokenDetails":{},"totalTokens":5}, - "warnings": [{"type":"other","message":"careful"}], - "request": {}, - "response": {"id":"resp_1","timestamp":"2026-01-01T00:00:00.000Z","modelId":"gpt-4o","messages":[]}, - "responseMessages": [ - {"role":"assistant","content":[ - {"type":"tool-call","toolCallId":"call_1","toolName":"get_weather","input":{"location":"Tokyo"}} - ]}, - {"role":"tool","content":[ - {"type":"tool-result","toolCallId":"call_1","toolName":"get_weather", - "output":{"type":"json","value":{"temp":22}}} - ]} - ], "steps": [{ - "callId":"c1", "stepNumber":0, "content":[], "finishReason":"stop", + "callId":"c1", "stepNumber":0, "content":[ + {"type":"text","text":"hello"}, + {"type":"reasoning","text":"hmm"}, + {"type":"source","sourceType":"url","id":"s1","url":"https://example.com"}, + {"type":"tool-call","toolCallId":"call_1","toolName":"get_weather","input":{"location":"Tokyo"}} + ], "finishReason":"tool-calls", "rawFinishReason":"tool_calls", "model":{"modelId":"gpt-4o","provider":"openai"}, "performance":{"effectiveOutputTokensPerSecond":0,"effectiveTotalTokensPerSecond":0, "responseTimeMs":0,"stepTimeMs":0,"toolExecutionMs":{}}, "request":{}, - "response":{"id":"resp_1","timestamp":"2026-01-01T00:00:00.000Z","modelId":"gpt-4o","messages":[]}, - "usage":{"inputTokenDetails":{},"outputTokenDetails":{}}, "warnings":[] - }] + "response":{"id":"resp_1","timestamp":"2026-01-01T00:00:00.000Z","modelId":"gpt-4o","messages":[ + {"role":"assistant","content":"hello"}, + {"role":"tool","content":[ + {"type":"tool-result","toolCallId":"call_1","toolName":"get_weather", + "output":{"type":"json","value":{"temp":22}}} + ]} + ]}, + "usage":{"inputTokenDetails":{},"outputTokenDetails":{}}, + "warnings":[{"type":"other","message":"careful"}] + }], + "outputParsed": false } """ let original = try JSONDecoder().decode(GenerateTextResult.self, from: json.data(using: .utf8)!) try assertEqual(original.text, "hello") - try assertEqual(original.toolCalls[0].toolName, "get_weather") + try assertEqual(original.staticToolCalls[0].toolName, "get_weather") try assertEqual(original.finishReason, .toolCalls) try assertEqual(original.rawFinishReason, "tool_calls") try assertEqual(original.usage.totalTokens, 5) try assertEqual(original.reasoningText, "hmm") try assertEqual(original.output, .missing) + try assertEqual(original.outputValue, .missing) + try assertEqual(original.outputParsed, false) try assertEqual(original.response.id, "resp_1") try assertEqual(original.response.modelId, "gpt-4o") try assertEqual(original.warnings, [.other(message: "careful")]) @@ -213,6 +200,29 @@ struct WireTests { // Encode → decode yields an equal value. let reencoded = try JSONEncoder().encode(original) + let encoded = try JSONDecoder().decode([String: JSONValue].self, from: reencoded) + try assertEqual(Set(encoded.keys), ["steps", "totalUsage", "outputParsed"]) + + var plainText = encoded + plainText.removeValue(forKey: "outputParsed") + let plain = try JSONDecoder().decode(GenerateTextResult.self, from: try JSONEncoder().encode(plainText)) + try assertEqual(plain.output, .value(.string("hello"))) + try assertEqual(plain.outputValue, .missing) + + var parsedNull = plainText + parsedNull["output"] = .null + let withNull = try JSONDecoder().decode(GenerateTextResult.self, from: try JSONEncoder().encode(parsedNull)) + try assertEqual(withNull.output, .null) + try assertEqual(withNull.outputValue, .null) + + var contradictory = encoded + contradictory["output"] = .null + try assertThrows(JSONDecoder().decode(GenerateTextResult.self, from: try JSONEncoder().encode(contradictory))) + + var empty = encoded + empty["steps"] = .array([]) + let malformed = try JSONEncoder().encode(empty) + try assertThrows(JSONDecoder().decode(GenerateTextResult.self, from: malformed)) let decoded = try JSONDecoder().decode(GenerateTextResult.self, from: reencoded) try assertEqual(original, decoded) } diff --git a/bindings/swift/generated/AimuxOps.swift b/bindings/swift/generated/AimuxOps.swift index b8b2e8975..f3276e2ee 100644 --- a/bindings/swift/generated/AimuxOps.swift +++ b/bindings/swift/generated/AimuxOps.swift @@ -1,8 +1,8 @@ -// Generated by aimux-codegen. Do not edit. Manifest SHA-256: cd147fa9595ede3951744fa261da98cc18c204e65b4081073ad3a3c1b68bfd92 +// Generated by aimux-codegen. Do not edit. Manifest SHA-256: 6914772fdc03df08cba497def41cb354fe52e40eba49844a66938b4cd38c5d83 public enum AimuxOps { public static let ABI_VERSION: UInt32 = 65536 public static let OPS_VERSION = "1.0" - public static let MANIFEST_DIGEST = "cd147fa9595ede3951744fa261da98cc18c204e65b4081073ad3a3c1b68bfd92" + public static let MANIFEST_DIGEST = "6914772fdc03df08cba497def41cb354fe52e40eba49844a66938b4cd38c5d83" public static let OP_ABORT_CREATE = "abort.create" public static let OP_ABORT_SIGNAL = "abort.signal" public static let OP_AUTH_CODEX_REFRESH = "auth.codexRefresh" @@ -93,7 +93,7 @@ public enum AimuxOps { "aimux_core::embedding_model::EmbeddingResult": "af3ce0787db6208be114613c78dc02f038cb5dc2f7abcf6a4ade2be79085342e", "aimux_core::files_model::UploadFileResult": "0d17fd3dbfa601e45c9fabf62f9bb1e5028591443eafccd4eecacef0dcda0368", "aimux_core::generate::GenerateObjectResult": "21cca82de06d366b0f47d781bd49141bb63215accdd1133bb360113a60b7cc00", - "aimux_core::generate::GenerateTextResult": "c5c6016de2c926c85144959d9436c9d2214a27a9724e75d68393e933ef7263f5", + "aimux_core::generate::GenerateTextResult": "c75d0e0c2d207f9dfeffe7eb42efb9040d93a8062cdc678054f9bbcb8049e041", "aimux_core::image_model::ImageCallOptions": "ddacb8970cef4590bcdcc572ced361b181d501d3b474a2d6c50a9c0c02af3eb2", "aimux_core::image_model::ImageResult": "a9d2d939f3dc153a5b5ebc8083bea1226ff63ff2e54e4e275c9ab2b136b9e880", "aimux_core::openai_output::ChatCompletion": "503195cbe7fe458d9403a9de20b93bd17c20bbee0de40a8088bf3847ee835ad9", @@ -101,6 +101,9 @@ public enum AimuxOps { "aimux_core::recording::Recording": "56fa358fb2023da68837722ed573e00fc997506403d7c7aa516c586c45b4fd54", "aimux_core::reranking_model::RerankingCallOptions": "c481b6e7c4d5e71ea7db00166ab2952c8a893443f786a61374c7398b4e475e4c", "aimux_core::reranking_model::RerankingResult": "d757826963b3ce836e4d76fca8f42455a3a3146c20f3fb74f58cabe465348d01", + "aimux_core::result::ReasoningPart": "6210a367b8c084e55a60e0ead74a7ff233b7f357020a028c6879b54ffa8b9b87", + "aimux_core::result::TaggedToolResult": "a8f688a021397c1159b88546156d5a418e50d6482d39f88c46476297d208e069", + "aimux_core::result::TypedSource": "0a36b617c3f1bbcd82e4d09c329ad41aba62330b4d0e950125fd62b2053a9368", "aimux_core::search_model::SearchCallOptions": "3b963a871e6f1858db03b68adc74c5f898d4a2c3c0506e4e359b8d8198d30b22", "aimux_core::search_model::SearchResult": "61075439fcb4276085a11113195dd13220b710cc0c2199ceefa4ec3d07d0195f", "aimux_core::speech_model::SpeechCallOptions": "418be167c89bca652fb0a9dd52a1da359c1ecc2b069b9d2a0859ab76a7f7f431", @@ -128,10 +131,10 @@ public enum AimuxOps { "aimux_ops::ops::handles::TransportParams": "86e40584fcc21dab8f0017f8e892b776ac24aaa9afc943ba805828cecc6e1a4c", "aimux_ops::ops::misc::CatalogueFetchRequest": "2ceed496996ec6cf32d3e3115ab6a4346a1bb201dc8a970eefbd46eb700a310e", "aimux_ops::ops::misc::CodexRefreshRequest": "59f1075ed68cb79896d4bac1d0ab32d21fb5855012c6336652bea0c4969ac926", - "aimux_ops::ops::misc::OpenAiOutputRequest": "b0c6acc344f0b23b9ea3b693aeadf7aed7eb4fbdfce4b957be83af1154b842b4", - "aimux_ops::ops::misc::ToolRepairApplyRequest": "0f430fdb223759ef7c48c4d7f824e7be74d29295a6b4f7caaf82b5acba25e538", - "aimux_ops::ops::misc::ToolRepairApplyResultRequest": "fa092862004654e065233b2df2abdbec3befe88d9d734d494679968a5b6e954a", - "aimux_ops::ops::misc::ToolRepairContextRequest": "81bae04c56aac3380b75de639d162f819a2dd5717147a53cf1a75281727d78a1", + "aimux_ops::ops::misc::OpenAiOutputRequest": "d30e30aa75703e1404a202d437e69a6873fd2b515c5ed322ab488363be8d2fb0", + "aimux_ops::ops::misc::ToolRepairApplyRequest": "c1c5f81107f334a94583a4ff4ed394097580bea2f2a66266c11890fe2a3ab3d0", + "aimux_ops::ops::misc::ToolRepairApplyResultRequest": "649f2b4ff1a2dd0d552e2930b694d7efa3346b2f15a9fb0f14cffd4b6955b508", + "aimux_ops::ops::misc::ToolRepairContextRequest": "fa4802ac20a2b1b540cb727d798ad2a4c44cad6a8f9ad45281fc91ebb065e65f", "aimux_ops::ops::misc::ToolRepairContextResult": "fd8173e6ec40724fa4207e3571e290ac12e4db1fed08a709273e2982a82b504f", "aimux_ops::ops::operation::EmptyParams": "1612408252a424283a43a92193bb8ea24f72c08b9f0d2117b4ef7f5a090e37f8", "aimux_ops::ops::operation::OperationNextParams": "127fea618826e51576ae488dcccaca03c04b774a847a33ec9c47565396862bb7", @@ -165,7 +168,7 @@ public enum AimuxOps { "aimux_ops::ops::replay::ReplayCreateParams": "ee64b5b5843103f76ca2166aed2f58995e472be93cb7bb18dea8238c8a2d9e44", "aimux_ops::ops::replay::ReplayInspection": "7ac2af62f3421f8c7c50867a838f0aff90f35b6a4f192f6c0d5347ab4699108c", "aimux_ops::ops::replay::ReplayLiveParams": "e99c7d51fb194def185f5a03d84bfc226eb1b101eade0b885216332605318a4d", - "aimux_ops::ops::replay::ReplayLiveResult": "bd9959dd7e0300cb57e6929b2ed29b7e07dcb5aaf65be16b96e34bf8d6577a7f", + "aimux_ops::ops::replay::ReplayLiveResult": "9163acd59ee54db1db2213c0756283b8b27e04a52451dfeef314d63efebbc730", "aimux_ops::ops::replay::ReplayPlan": "5cc6667b9fac6de173bf5b55c1a76a491255f89f0fa7a27c0fd33fd790259799", "aimux_ops::ops::replay::ReplaySessionHandle": "5e779b71ce2a54e59948c605cdfc48797d0760027ad5f44966df958fe9781d11", "aimux_ops::ops::runtime::RuntimeConfigureParams": "e3b24b9f1fbdf2be7da210f15060803cf8bfdef77c8b2ad330a5b501263dfb0f", @@ -173,8 +176,8 @@ public enum AimuxOps { "aimux_ops::ops::session::SessionStoreCallsParams": "ddd482204fdd305bbfd28d43ae829d8c286f3f8906302ca6679743ea680fedda", "aimux_ops::ops::session::SessionStoreCreateParams": "080d865c349ec86553f72b99ab1c65ddbb72d0c348a96dc17135a934d787cd86", "aimux_ops::ops::session::SessionStoreHandle": "755d437d47d362474942fc4a09f5f8c80b75cf362ac16b25b262e33a760b4c6a", - "aimux_ops::ops::text::OpenAiTextRequest": "59293b18b6124a9a394113b8f94f637c65dc35ac44a30f7e0df70855e885f8e4", - "aimux_ops::ops::text::TextRequest": "3a6f59c1f0c3b7ded5f5509d93afe9bddd2b80a8a3cd752d79f97edadae40c3d", + "aimux_ops::ops::text::OpenAiTextRequest": "d5afbf2b24ab74b82433d344afb190c18f8aef52988c54ab8b5388579c212f67", + "aimux_ops::ops::text::TextRequest": "eb0c25fcbf741834943882d7f901af7439ba30923a391b273526d1887ed156ab", "aimux_ops::ops::trace::TraceAggregateParams": "1b207f0bbe1b7ce7e9b8b0beb9334cf3cc4f9f05382911aaacfe0425dc8ff2c8", "aimux_ops::ops::trace::TraceCreateParams": "59fef52f382800570e861ae9ca92433dcae8807679d914a89ce99705713301d9", "aimux_ops::ops::trace::TraceSessionParams": "3e2300f6c65f6dcd52a016eba648a29abeff3a9d67c3b04a95617aa66832f810", diff --git a/bindings/swift/generated/DtoVectorTypes.swift b/bindings/swift/generated/DtoVectorTypes.swift index 860518989..907d01013 100644 --- a/bindings/swift/generated/DtoVectorTypes.swift +++ b/bindings/swift/generated/DtoVectorTypes.swift @@ -94,6 +94,7 @@ enum DtoVectorTypes { case "ImageResponse": return try encoder.encode(decoder.decode(ImageResponse.self, from: data)) case "ImageResult": return try encoder.encode(decoder.decode(ImageResult.self, from: data)) case "ImageUsage": return try encoder.encode(decoder.decode(ImageUsage.self, from: data)) + case "IncludeOptions": return try encoder.encode(decoder.decode(IncludeOptions.self, from: data)) case "InputAudioFormat": return try encoder.encode(decoder.decode(InputAudioFormat.self, from: data)) case "InputRecord": return try encoder.encode(decoder.decode(InputRecord.self, from: data)) case "InputTokenDetails": return try encoder.encode(decoder.decode(InputTokenDetails.self, from: data)) diff --git a/bindings/swift/generated/Types.swift b/bindings/swift/generated/Types.swift index d6e704455..359a0d712 100644 --- a/bindings/swift/generated/Types.swift +++ b/bindings/swift/generated/Types.swift @@ -3135,6 +3135,8 @@ public struct GenerateObjectResult: Codable, Equatable, Sendable { public struct GenerateTextOptions: Codable, Equatable, Sendable { public var frequencyPenalty: Double? public var headers: [String: String]? + /// Controls the raw bodies exposed in the result. Both default to `false`. + public var include: IncludeOptions? /// Emit raw provider stream chunks as `StreamPart::Raw` (debugging aid). public var includeRawChunks: Bool? /// System instructions prepended to the prompt. @@ -3174,9 +3176,10 @@ public struct GenerateTextOptions: Codable, Equatable, Sendable { public var topK: Double? public var topP: Double? - public init(frequencyPenalty: Double? = nil, headers: [String: String]? = nil, includeRawChunks: Bool? = nil, instructions: String? = nil, maxOutputTokens: UInt32? = nil, maxRetries: UInt32? = nil, output: Output? = nil, presencePenalty: Double? = nil, providerOptions: [String: [String: JSONValue]]? = nil, reasoning: ReasoningEffort? = nil, seed: UInt64? = nil, sessionId: String? = nil, stopSequences: [String]? = nil, strictStream: Bool? = nil, temperature: Double? = nil, timeout: TimeoutConfiguration? = nil, toolChoice: ToolChoice? = nil, tools: [Tool]? = nil, topK: Double? = nil, topP: Double? = nil) { + public init(frequencyPenalty: Double? = nil, headers: [String: String]? = nil, include: IncludeOptions? = nil, includeRawChunks: Bool? = nil, instructions: String? = nil, maxOutputTokens: UInt32? = nil, maxRetries: UInt32? = nil, output: Output? = nil, presencePenalty: Double? = nil, providerOptions: [String: [String: JSONValue]]? = nil, reasoning: ReasoningEffort? = nil, seed: UInt64? = nil, sessionId: String? = nil, stopSequences: [String]? = nil, strictStream: Bool? = nil, temperature: Double? = nil, timeout: TimeoutConfiguration? = nil, toolChoice: ToolChoice? = nil, tools: [Tool]? = nil, topK: Double? = nil, topP: Double? = nil) { self.frequencyPenalty = frequencyPenalty self.headers = headers + self.include = include self.includeRawChunks = includeRawChunks self.instructions = instructions self.maxOutputTokens = maxOutputTokens @@ -3199,6 +3202,7 @@ public struct GenerateTextOptions: Codable, Equatable, Sendable { private enum CodingKeys: String, CodingKey { case frequencyPenalty = "frequencyPenalty" case headers = "headers" + case include = "include" case includeRawChunks = "includeRawChunks" case instructions = "instructions" case maxOutputTokens = "maxOutputTokens" @@ -3228,6 +3232,7 @@ public struct GenerateTextOptions: Codable, Equatable, Sendable { let c = try decoder.container(keyedBy: CodingKeys.self) self.frequencyPenalty = try c.decodeIfPresent(Double.self, forKey: .frequencyPenalty) self.headers = try c.decodeIfPresent([String: String].self, forKey: .headers) + self.include = try c.decodeIfPresent(IncludeOptions.self, forKey: .include) self.includeRawChunks = try c.decodeIfPresent(Bool.self, forKey: .includeRawChunks) self.instructions = try c.decodeIfPresent(String.self, forKey: .instructions) self.maxOutputTokens = try c.decodeIfPresent(UInt32.self, forKey: .maxOutputTokens) @@ -3251,6 +3256,7 @@ public struct GenerateTextOptions: Codable, Equatable, Sendable { var c = encoder.container(keyedBy: CodingKeys.self) try c.encodeIfPresent(self.frequencyPenalty, forKey: .frequencyPenalty) try c.encodeIfPresent(self.headers, forKey: .headers) + try c.encodeIfPresent(self.include, forKey: .include) try c.encodeIfPresent(self.includeRawChunks, forKey: .includeRawChunks) try c.encodeIfPresent(self.instructions, forKey: .instructions) try c.encodeIfPresent(self.maxOutputTokens, forKey: .maxOutputTokens) @@ -3277,126 +3283,135 @@ public struct GenerateTextOptions: Codable, Equatable, Sendable { /// /// It stores the steps, the usage summed over them and the parsed output, as /// `DefaultGenerateTextResult` does (`generate-text.ts:1691-1808`); every -/// other value is derived from the steps by an accessor. The serialized form -/// is a snapshot that writes the derived values next to the stored ones, so -/// a binding reads `text`, `tool_calls`, `usage` and the rest directly. Only -/// `steps`, `total_usage` and `output` are read back. +/// other value is derived from the steps by an accessor. The wire form carries +/// `steps`, `totalUsage`, optional `output` (when explicitly parsed), and +/// optional `outputParsed: false` (when no output was generated). public struct GenerateTextResult: Codable, Equatable, Sendable { - public var content: [ContentPart] - public var files: [GeneratedFile] - public var finishReason: FinishReasonUnified - /// Absent when the output was not parsed. - public var output: FieldPresence - /// Deprecated upstream: the last step's provider metadata. - public var providerMetadata: [String: [String: JSONValue]]? - public var rawFinishReason: String? - /// Deprecated upstream: the last step's reasoning. - public var reasoning: [ReasoningPart] - /// Deprecated upstream: the last step's reasoning text. - public var reasoningText: String? - /// Deprecated upstream: the last step's request. - public var request: RequestInfo - /// Deprecated upstream: the last step's response. - public var response: StepResponse - public var responseMessages: [ModelMessage] - /// Each with its `type` tag (`generate-text-result.ts:73`). - public var sources: [TypedSource] + /// An explicit parsed output, including JSON `null`. When absent and + /// `outputParsed` is not `false`, bindings expose the final step's text. + public var outputValue: FieldPresence + /// Present and `false` when no output was generated (for example, a final + /// `tool-calls` step without an output spec). Omitted when an output was + /// produced. + public var outputParsed: Bool? public var steps: [StepResult] - public var text: String - /// Each with its `type` tag (`generate-text-result.ts:78`). - public var toolCalls: [TypedToolCall] - /// Each with its `type` tag (`generate-text-result.ts:93`). - public var toolResults: [TaggedToolResult] - /// Deprecated upstream: equal to `usage`. public var totalUsage: LanguageModelUsage - public var usage: LanguageModelUsage - public var warnings: [Warning] - public init(content: [ContentPart], files: [GeneratedFile], finishReason: FinishReasonUnified, output: FieldPresence = .missing, providerMetadata: [String: [String: JSONValue]]? = nil, rawFinishReason: String? = nil, reasoning: [ReasoningPart], reasoningText: String? = nil, request: RequestInfo, response: StepResponse, responseMessages: [ModelMessage], sources: [TypedSource], steps: [StepResult], text: String, toolCalls: [TypedToolCall], toolResults: [TaggedToolResult], totalUsage: LanguageModelUsage, usage: LanguageModelUsage, warnings: [Warning]) { - self.content = content - self.files = files - self.finishReason = finishReason - self.output = output - self.providerMetadata = providerMetadata - self.rawFinishReason = rawFinishReason - self.reasoning = reasoning - self.reasoningText = reasoningText - self.request = request - self.response = response - self.responseMessages = responseMessages - self.sources = sources + public init(output: FieldPresence = .missing, outputParsed: Bool? = nil, steps: [StepResult], totalUsage: LanguageModelUsage) { + self.outputValue = output + self.outputParsed = outputParsed self.steps = steps - self.text = text - self.toolCalls = toolCalls - self.toolResults = toolResults self.totalUsage = totalUsage - self.usage = usage - self.warnings = warnings } private enum CodingKeys: String, CodingKey { - case content = "content" - case files = "files" - case finishReason = "finishReason" case output = "output" - case providerMetadata = "providerMetadata" - case rawFinishReason = "rawFinishReason" - case reasoning = "reasoning" - case reasoningText = "reasoningText" - case request = "request" - case response = "response" - case responseMessages = "responseMessages" - case sources = "sources" + case outputParsed = "outputParsed" case steps = "steps" - case text = "text" - case toolCalls = "toolCalls" - case toolResults = "toolResults" case totalUsage = "totalUsage" - case usage = "usage" - case warnings = "warnings" } public init(from decoder: any Decoder) throws { let c = try decoder.container(keyedBy: CodingKeys.self) - self.content = try c.decode([ContentPart].self, forKey: .content) - self.files = try c.decode([GeneratedFile].self, forKey: .files) - self.finishReason = try c.decode(FinishReasonUnified.self, forKey: .finishReason) - self.output = try c.decodePresence(JSONValue.self, forKey: .output) - self.providerMetadata = try c.decodeIfPresent([String: [String: JSONValue]].self, forKey: .providerMetadata) - self.rawFinishReason = try c.decodeIfPresent(String.self, forKey: .rawFinishReason) - self.reasoning = try c.decode([ReasoningPart].self, forKey: .reasoning) - self.reasoningText = try c.decodeIfPresent(String.self, forKey: .reasoningText) - self.request = try c.decode(RequestInfo.self, forKey: .request) - self.response = try c.decode(StepResponse.self, forKey: .response) - self.responseMessages = try c.decode([ModelMessage].self, forKey: .responseMessages) - self.sources = try c.decode([TypedSource].self, forKey: .sources) + self.outputValue = try c.decodePresence(JSONValue.self, forKey: .output) + self.outputParsed = try c.decodeIfPresent(Bool.self, forKey: .outputParsed) self.steps = try c.decode([StepResult].self, forKey: .steps) - self.text = try c.decode(String.self, forKey: .text) - self.toolCalls = try c.decode([TypedToolCall].self, forKey: .toolCalls) - self.toolResults = try c.decode([TaggedToolResult].self, forKey: .toolResults) self.totalUsage = try c.decode(LanguageModelUsage.self, forKey: .totalUsage) - self.usage = try c.decode(LanguageModelUsage.self, forKey: .usage) - self.warnings = try c.decode([Warning].self, forKey: .warnings) + guard !steps.isEmpty else { + throw DecodingError.dataCorruptedError(forKey: .steps, in: c, debugDescription: "GenerateTextResult requires at least one step") + } + if case .missing = outputValue {} else if outputParsed == false { + throw DecodingError.dataCorruptedError(forKey: .outputParsed, in: c, debugDescription: "GenerateTextResult cannot carry output when outputParsed is false") + } } public func encode(to encoder: any Encoder) throws { var c = encoder.container(keyedBy: CodingKeys.self) - try c.encode(self.content, forKey: .content) - try c.encode(self.files, forKey: .files) - try c.encode(self.finishReason, forKey: .finishReason) - try c.encodePresence(self.output, forKey: .output) - try c.encodeIfPresent(self.providerMetadata, forKey: .providerMetadata) - try c.encodeIfPresent(self.rawFinishReason, forKey: .rawFinishReason) - try c.encode(self.reasoning, forKey: .reasoning) - try c.encodeIfPresent(self.reasoningText, forKey: .reasoningText) - try c.encode(self.request, forKey: .request) - try c.encode(self.response, forKey: .response) - try c.encode(self.responseMessages, forKey: .responseMessages) - try c.encode(self.sources, forKey: .sources) + try c.encodePresence(self.outputValue, forKey: .output) + try c.encodeIfPresent(self.outputParsed, forKey: .outputParsed) try c.encode(self.steps, forKey: .steps) - try c.encode(self.text, forKey: .text) - try c.encode(self.toolCalls, forKey: .toolCalls) - try c.encode(self.toolResults, forKey: .toolResults) try c.encode(self.totalUsage, forKey: .totalUsage) - try c.encode(self.usage, forKey: .usage) - try c.encode(self.warnings, forKey: .warnings) + } +} + +// Computed result properties are excluded from Codable. +extension GenerateTextResult { + public var finalStep: StepResult { steps[steps.count - 1] } + public var text: String { + finalStep.content.compactMap { part in + if case let .text(_, text) = part { return text } + return nil + }.joined() + } + public var content: [ContentPart] { steps.flatMap(\.content) } + public var reasoning: [ReasoningPart] { + finalStep.content.compactMap { + switch $0 { + case let .reasoning(metadata, text): .reasoning(providerMetadata: metadata, text: text) + case let .reasoningFile(file, metadata): .reasoningFile(file: file, providerMetadata: metadata) + default: nil + } + } + } + public var reasoningText: String? { + let text = reasoning.compactMap { part in + if case let .reasoning(_, text) = part { return text } + return nil + }.joined() + return text.isEmpty ? nil : text + } + public var files: [GeneratedFile] { + content.compactMap { + if case let .file(file, _) = $0 { return file } + return nil + } + } + public var sources: [TypedSource] { + content.compactMap { + switch $0 { + case let .sourceUrl(id, metadata, _, title, url): + .url(id: id, providerMetadata: metadata, title: title, type: "source", url: url) + case let .sourceDocument(filename, id, mediaType, metadata, _, title): + .document(filename: filename, id: id, mediaType: mediaType, + providerMetadata: metadata, title: title, type: "source") + default: nil + } + } + } + public var toolCalls: [TypedToolCall] { + content.compactMap { + guard case let .toolCall(dynamic, error, input, invalid, executed, metadata, id, name) = $0 else { + return nil + } + return TypedToolCall(dynamic: dynamic, error: error, input: input, invalid: invalid, + providerExecuted: executed, providerMetadata: metadata, + toolCallId: id, toolName: name, type: "tool-call") + } + } + public var staticToolCalls: [TypedToolCall] { toolCalls.filter { $0.dynamic != true } } + public var dynamicToolCalls: [TypedToolCall] { toolCalls.filter { $0.dynamic == true } } + public var toolResults: [TaggedToolResult] { + content.compactMap { + guard case let .toolResult(dynamic, input, output, preliminary, executed, metadata, id, name) = $0 else { + return nil + } + return TaggedToolResult(dynamic: dynamic, input: input, output: output, preliminary: preliminary, + providerExecuted: executed, providerMetadata: metadata, + toolCallId: id, toolName: name, type: "tool-result") + } + } + public var staticToolResults: [TaggedToolResult] { toolResults.filter { $0.dynamic != true } } + public var dynamicToolResults: [TaggedToolResult] { toolResults.filter { $0.dynamic == true } } + public var finishReason: FinishReasonUnified { finalStep.finishReason } + public var rawFinishReason: String? { finalStep.rawFinishReason } + public var usage: LanguageModelUsage { totalUsage } + public var warnings: [Warning] { steps.flatMap(\.warnings) } + public var request: RequestInfo { finalStep.request } + public var response: StepResponse { finalStep.response } + public var providerMetadata: [String: [String: JSONValue]]? { finalStep.providerMetadata } + public var responseMessages: [ModelMessage] { steps.flatMap { $0.response.messages } } + public var output: FieldPresence { + if case .missing = outputValue { + return outputParsed == false ? .missing : .value(.string(text)) + } + return outputValue } } @@ -3405,34 +3420,43 @@ public struct GenerateTextResult: Codable, Equatable, Sendable { /// /// It stores the steps, the usage summed over them and the parsed output, as /// `DefaultGenerateTextResult` does (`generate-text.ts:1691-1808`); every -/// other value is derived from the steps by an accessor. The serialized form -/// is a snapshot that writes the derived values next to the stored ones, so -/// a binding reads `text`, `tool_calls`, `usage` and the rest directly. Only -/// `steps`, `total_usage` and `output` are read back. +/// other value is derived from the steps by an accessor. The wire form carries +/// `steps`, `totalUsage`, optional `output` (when explicitly parsed), and +/// optional `outputParsed: false` (when no output was generated). public struct GenerateTextResultInput: Codable, Equatable, Sendable { + /// An explicit parsed output, including JSON `null`. When absent and + /// `outputParsed` is not `false`, bindings expose the final step's text. public var output: FieldPresence + /// Present and `false` when no output was generated (for example, a final + /// `tool-calls` step without an output spec). Omitted when an output was + /// produced. + public var outputParsed: Bool? public var steps: [StepResultInput] public var totalUsage: LanguageModelUsageInput - public init(output: FieldPresence = .missing, steps: [StepResultInput], totalUsage: LanguageModelUsageInput) { + public init(output: FieldPresence = .missing, outputParsed: Bool? = nil, steps: [StepResultInput], totalUsage: LanguageModelUsageInput) { self.output = output + self.outputParsed = outputParsed self.steps = steps self.totalUsage = totalUsage } private enum CodingKeys: String, CodingKey { case output = "output" + case outputParsed = "outputParsed" case steps = "steps" case totalUsage = "totalUsage" } public init(from decoder: any Decoder) throws { let c = try decoder.container(keyedBy: CodingKeys.self) self.output = try c.decodePresence(JSONValue.self, forKey: .output) + self.outputParsed = try c.decodeIfPresent(Bool.self, forKey: .outputParsed) self.steps = try c.decode([StepResultInput].self, forKey: .steps) self.totalUsage = try c.decode(LanguageModelUsageInput.self, forKey: .totalUsage) } public func encode(to encoder: any Encoder) throws { var c = encoder.container(keyedBy: CodingKeys.self) try c.encodePresence(self.output, forKey: .output) + try c.encodeIfPresent(self.outputParsed, forKey: .outputParsed) try c.encode(self.steps, forKey: .steps) try c.encode(self.totalUsage, forKey: .totalUsage) } @@ -3809,6 +3833,39 @@ public struct ImageUsage: Codable, Equatable, Sendable { } } +/// Controls which raw body fields are exposed in generation results. +public struct IncludeOptions: Codable, Equatable, Sendable { + /// Whether to return the request body. Defaults to false. + public var requestBody: Bool? + /// Whether to return the response body. Defaults to false. + public var responseBody: Bool? + + public init(requestBody: Bool? = nil, responseBody: Bool? = nil) { + self.requestBody = requestBody + self.responseBody = responseBody + } + private enum CodingKeys: String, CodingKey { + case requestBody = "requestBody" + case responseBody = "responseBody" + } + public init(from decoder: any Decoder) throws { + let raw = try decoder.container(keyedBy: WireKey.self) + for key in raw.allKeys { + if CodingKeys(stringValue: key.stringValue) == nil { + throw DecodingError.dataCorrupted(.init(codingPath: decoder.codingPath + [key], debugDescription: "Unknown field \(key.stringValue)")) + } + } + let c = try decoder.container(keyedBy: CodingKeys.self) + self.requestBody = try c.decodeIfPresent(Bool.self, forKey: .requestBody) + self.responseBody = try c.decodeIfPresent(Bool.self, forKey: .responseBody) + } + public func encode(to encoder: any Encoder) throws { + var c = encoder.container(keyedBy: CodingKeys.self) + try c.encodeIfPresent(self.requestBody, forKey: .requestBody) + try c.encodeIfPresent(self.responseBody, forKey: .responseBody) + } +} + /// The input audio format for a streaming transcription request. public struct InputAudioFormat: Codable, Equatable, Sendable { /// Audio format type, e.g. `"audio/pcm"`, `"audio/pcmu"`, `"audio/pcma"`. @@ -4920,6 +4977,8 @@ public struct OperationStatus: Codable, Equatable, Sendable { public struct Options: Codable, Equatable, Sendable { public var frequencyPenalty: Double? public var headers: [String: String]? + /// Controls the raw bodies exposed in the result. Both default to `false`. + public var include: IncludeOptions? /// Emit raw provider stream chunks as `StreamPart::Raw` (debugging aid). public var includeRawChunks: Bool? /// System instructions prepended to the prompt. @@ -4959,9 +5018,10 @@ public struct Options: Codable, Equatable, Sendable { public var topK: Double? public var topP: Double? - public init(frequencyPenalty: Double? = nil, headers: [String: String]? = nil, includeRawChunks: Bool? = nil, instructions: String? = nil, maxOutputTokens: UInt32? = nil, maxRetries: UInt32? = nil, output: Output? = nil, presencePenalty: Double? = nil, providerOptions: [String: [String: JSONValue]]? = nil, reasoning: ReasoningEffort? = nil, seed: UInt64? = nil, sessionId: String? = nil, stopSequences: [String]? = nil, strictStream: Bool? = nil, temperature: Double? = nil, timeout: TimeoutConfiguration? = nil, toolChoice: ToolChoice? = nil, tools: [Tool]? = nil, topK: Double? = nil, topP: Double? = nil) { + public init(frequencyPenalty: Double? = nil, headers: [String: String]? = nil, include: IncludeOptions? = nil, includeRawChunks: Bool? = nil, instructions: String? = nil, maxOutputTokens: UInt32? = nil, maxRetries: UInt32? = nil, output: Output? = nil, presencePenalty: Double? = nil, providerOptions: [String: [String: JSONValue]]? = nil, reasoning: ReasoningEffort? = nil, seed: UInt64? = nil, sessionId: String? = nil, stopSequences: [String]? = nil, strictStream: Bool? = nil, temperature: Double? = nil, timeout: TimeoutConfiguration? = nil, toolChoice: ToolChoice? = nil, tools: [Tool]? = nil, topK: Double? = nil, topP: Double? = nil) { self.frequencyPenalty = frequencyPenalty self.headers = headers + self.include = include self.includeRawChunks = includeRawChunks self.instructions = instructions self.maxOutputTokens = maxOutputTokens @@ -4984,6 +5044,7 @@ public struct Options: Codable, Equatable, Sendable { private enum CodingKeys: String, CodingKey { case frequencyPenalty = "frequencyPenalty" case headers = "headers" + case include = "include" case includeRawChunks = "includeRawChunks" case instructions = "instructions" case maxOutputTokens = "maxOutputTokens" @@ -5013,6 +5074,7 @@ public struct Options: Codable, Equatable, Sendable { let c = try decoder.container(keyedBy: CodingKeys.self) self.frequencyPenalty = try c.decodeIfPresent(Double.self, forKey: .frequencyPenalty) self.headers = try c.decodeIfPresent([String: String].self, forKey: .headers) + self.include = try c.decodeIfPresent(IncludeOptions.self, forKey: .include) self.includeRawChunks = try c.decodeIfPresent(Bool.self, forKey: .includeRawChunks) self.instructions = try c.decodeIfPresent(String.self, forKey: .instructions) self.maxOutputTokens = try c.decodeIfPresent(UInt32.self, forKey: .maxOutputTokens) @@ -5036,6 +5098,7 @@ public struct Options: Codable, Equatable, Sendable { var c = encoder.container(keyedBy: CodingKeys.self) try c.encodeIfPresent(self.frequencyPenalty, forKey: .frequencyPenalty) try c.encodeIfPresent(self.headers, forKey: .headers) + try c.encodeIfPresent(self.include, forKey: .include) try c.encodeIfPresent(self.includeRawChunks, forKey: .includeRawChunks) try c.encodeIfPresent(self.instructions, forKey: .instructions) try c.encodeIfPresent(self.maxOutputTokens, forKey: .maxOutputTokens) diff --git a/contract-tests/dto/GenerateTextOptions/002.json b/contract-tests/dto/GenerateTextOptions/002.json new file mode 100644 index 000000000..cd5221f08 --- /dev/null +++ b/contract-tests/dto/GenerateTextOptions/002.json @@ -0,0 +1,15 @@ +{ + "include": { + "requestBody": false, + "responseBody": true + }, + "tools": [ + { + "type": "function", + "name": "lookup", + "inputSchema": { + "type": "object" + } + } + ] +} diff --git a/contract-tests/dto/GenerateTextResult/001.json b/contract-tests/dto/GenerateTextResult/001.json index 88a395209..3c6ebcfce 100644 --- a/contract-tests/dto/GenerateTextResult/001.json +++ b/contract-tests/dto/GenerateTextResult/001.json @@ -1,77 +1,4 @@ { - "content": [ - { - "type": "text", - "text": "Hello, world!" - } - ], - "text": "Hello, world!", - "reasoning": [], - "files": [], - "sources": [], - "toolCalls": [], - "toolResults": [], - "finishReason": "stop", - "rawFinishReason": "stop", - "usage": { - "inputTokens": 12, - "inputTokenDetails": { - "noCacheTokens": 12 - }, - "outputTokens": 3, - "outputTokenDetails": { - "textTokens": 3 - }, - "totalTokens": 15 - }, - "totalUsage": { - "inputTokens": 12, - "inputTokenDetails": { - "noCacheTokens": 12 - }, - "outputTokens": 3, - "outputTokenDetails": { - "textTokens": 3 - }, - "totalTokens": 15 - }, - "warnings": [], - "request": { - "body": null - }, - "response": { - "id": "resp-dto-1", - "timestamp": "2026-01-01T00:00:00.000Z", - "modelId": "gpt-4o", - "messages": [ - { - "role": "assistant", - "content": [ - { - "type": "text", - "text": "Hello, world!" - } - ] - } - ] - }, - "responseMessages": [ - { - "role": "assistant", - "content": [ - { - "type": "text", - "text": "Hello, world!" - } - ] - } - ], - "providerMetadata": { - "openai": { - "serviceTier": "default", - "opaque": null - } - }, "steps": [ { "callId": "call-dto-1", @@ -134,5 +61,15 @@ } } ], - "output": "Hello, world!" + "totalUsage": { + "inputTokens": 12, + "inputTokenDetails": { + "noCacheTokens": 12 + }, + "outputTokens": 3, + "outputTokenDetails": { + "textTokens": 3 + }, + "totalTokens": 15 + } } diff --git a/contract-tests/dto/GenerateTextResult/002.json b/contract-tests/dto/GenerateTextResult/002.json new file mode 100644 index 000000000..56bf39baa --- /dev/null +++ b/contract-tests/dto/GenerateTextResult/002.json @@ -0,0 +1,76 @@ +{ + "steps": [ + { + "callId": "call-dto-1", + "stepNumber": 0, + "model": { + "provider": "openai.chat", + "modelId": "gpt-4o" + }, + "content": [ + { + "type": "text", + "text": "Hello, world!" + } + ], + "finishReason": "stop", + "rawFinishReason": "stop", + "usage": { + "inputTokens": 12, + "inputTokenDetails": { + "noCacheTokens": 12 + }, + "outputTokens": 3, + "outputTokenDetails": { + "textTokens": 3 + }, + "totalTokens": 15 + }, + "performance": { + "effectiveOutputTokensPerSecond": 12.0, + "effectiveTotalTokensPerSecond": 60.0, + "stepTimeMs": 260.0, + "responseTimeMs": 250.0, + "toolExecutionMs": {} + }, + "warnings": [], + "request": { + "body": null + }, + "response": { + "id": "resp-dto-1", + "timestamp": "2026-01-01T00:00:00.000Z", + "modelId": "gpt-4o", + "messages": [ + { + "role": "assistant", + "content": [ + { + "type": "text", + "text": "Hello, world!" + } + ] + } + ] + }, + "providerMetadata": { + "openai": { + "serviceTier": "default", + "opaque": null + } + } + } + ], + "totalUsage": { + "inputTokens": 12, + "inputTokenDetails": { + "noCacheTokens": 12 + }, + "outputTokens": 3, + "outputTokenDetails": { + "textTokens": 3 + }, + "totalTokens": 15 + }, + "output": null +} diff --git a/contract-tests/dto/GenerateTextResult/003.json b/contract-tests/dto/GenerateTextResult/003.json new file mode 100644 index 000000000..9c18dc4b9 --- /dev/null +++ b/contract-tests/dto/GenerateTextResult/003.json @@ -0,0 +1,84 @@ +{ + "steps": [ + { + "callId": "call-dto-3", + "stepNumber": 0, + "model": { + "provider": "openai.chat", + "modelId": "gpt-4o" + }, + "content": [ + { + "type": "text", + "text": "Calling weather tool" + }, + { + "type": "tool-call", + "toolCallId": "call_1", + "toolName": "get_weather", + "input": { + "location": "Tokyo" + } + } + ], + "finishReason": "tool-calls", + "rawFinishReason": "tool_calls", + "usage": { + "inputTokens": 12, + "inputTokenDetails": { + "noCacheTokens": 12 + }, + "outputTokens": 5, + "outputTokenDetails": { + "textTokens": 5 + }, + "totalTokens": 17 + }, + "performance": { + "effectiveOutputTokensPerSecond": 12.0, + "effectiveTotalTokensPerSecond": 60.0, + "stepTimeMs": 260.0, + "responseTimeMs": 250.0, + "toolExecutionMs": {} + }, + "warnings": [], + "request": {}, + "response": { + "id": "resp-dto-3", + "timestamp": "2026-01-01T00:00:00.000Z", + "modelId": "gpt-4o", + "messages": [ + { + "role": "assistant", + "content": [ + { + "type": "text", + "text": "Calling weather tool" + }, + { + "type": "tool-call", + "toolCallId": "call_1", + "toolName": "get_weather", + "input": { + "location": "Tokyo" + } + } + ] + } + ] + } + } + ], + "totalUsage": { + "inputTokens": 12, + "inputTokenDetails": { + "noCacheTokens": 12 + }, + "outputTokens": 5, + "outputTokenDetails": { + "textTokens": 5 + }, + "totalTokens": 17 + }, + "outputParsed": false +} diff --git a/contract-tests/dto/index.json b/contract-tests/dto/index.json index 7c09438c5..720999bc4 100644 --- a/contract-tests/dto/index.json +++ b/contract-tests/dto/index.json @@ -413,10 +413,22 @@ "type": "GenerateTextOptions", "file": "GenerateTextOptions/001.json" }, + { + "type": "GenerateTextOptions", + "file": "GenerateTextOptions/002.json" + }, { "type": "GenerateTextResult", "file": "GenerateTextResult/001.json" }, + { + "type": "GenerateTextResult", + "file": "GenerateTextResult/002.json" + }, + { + "type": "GenerateTextResult", + "file": "GenerateTextResult/003.json" + }, { "type": "GeneratedFile", "file": "GeneratedFile/001.json" diff --git a/docs/upgrading-to-ops-abi.md b/docs/upgrading-to-ops-abi.md index 11aa94d69..4af9632a3 100644 --- a/docs/upgrading-to-ops-abi.md +++ b/docs/upgrading-to-ops-abi.md @@ -37,6 +37,20 @@ original files. A future recording change can make rollback unable to read new data; no automatic converter or compatibility release is promised. Pin the entire previous release when rolling back, including packages and native assets. +## Compact text result JSON + +Update code that reads text-generation results from `aimux_call`. Read +`steps` and `totalUsage` from the result and check key presence for +`output`, where a present JSON `null` is a value. When `output` is absent, +check `outputParsed`: `false` means no output was generated (such as a final +`tool-calls` step); otherwise the output is the final step's derived `text`. +The last step supplies `request` and `response`. To retrieve their bodies +when available, pass `options.include.requestBody` and +`options.include.responseBody` as `true` in the text request. The full field +migration covers generation, stream consumption, tool repair, and language +replay. +[Compact text result field mapping](../CHANGELOG.md#compact-text-result-json-rfc-0049) + ## Load and validate Read the ABI and manifest before creating resources. Raw C consumers must check diff --git a/schema/manifest.json b/schema/manifest.json index 6d6815fd7..47cea0db9 100644 --- a/schema/manifest.json +++ b/schema/manifest.json @@ -1,6 +1,6 @@ { "abiVersion": 65536, - "digest": "cd147fa9595ede3951744fa261da98cc18c204e65b4081073ad3a3c1b68bfd92", + "digest": "6914772fdc03df08cba497def41cb354fe52e40eba49844a66938b4cd38c5d83", "errorCodes": [ { "aliases": [], @@ -271,7 +271,7 @@ "SessionStore", "ReplaySession" ], - "inputHash": "cd147fa9595ede3951744fa261da98cc18c204e65b4081073ad3a3c1b68bfd92", + "inputHash": "6914772fdc03df08cba497def41cb354fe52e40eba49844a66938b4cd38c5d83", "manifestRevision": "1", "ops": [ { @@ -4702,6 +4702,17 @@ "null" ] }, + "include": { + "anyOf": [ + { + "$ref": "#/typeDefs/input/IncludeOptions" + }, + { + "type": "null" + } + ], + "description": "Controls the raw bodies exposed in the result. Both default to `false`." + }, "includeRawChunks": { "description": "Emit raw provider stream chunks as `StreamPart::Raw` (debugging aid).", "type": [ @@ -4858,12 +4869,19 @@ "type": "object" }, "GenerateTextResult": { - "description": "Result of `generate_text` and of a consumed `stream_text`: the AI SDK's\n`GenerateTextResult` (ai@7.0.127 `generate-text/generate-text-result.ts`).\n\nIt stores the steps, the usage summed over them and the parsed output, as\n`DefaultGenerateTextResult` does (`generate-text.ts:1691-1808`); every\nother value is derived from the steps by an accessor. The serialized form\nis a snapshot that writes the derived values next to the stored ones, so\na binding reads `text`, `tool_calls`, `usage` and the rest directly. Only\n`steps`, `total_usage` and `output` are read back.", + "description": "Result of `generate_text` and of a consumed `stream_text`: the AI SDK's\n`GenerateTextResult` (ai@7.0.127 `generate-text/generate-text-result.ts`).\n\nIt stores the steps, the usage summed over them and the parsed output, as\n`DefaultGenerateTextResult` does (`generate-text.ts:1691-1808`); every\nother value is derived from the steps by an accessor. The wire form carries\n`steps`, `totalUsage`, optional `output` (when explicitly parsed), and\noptional `outputParsed: false` (when no output was generated).", "properties": { "output": { - "default": null, + "description": "An explicit parsed output, including JSON `null`. When absent and\n`outputParsed` is not `false`, bindings expose the final step's text.", "x-aimux-codec": "presence" }, + "outputParsed": { + "description": "Present and `false` when no output was generated (for example, a final\n`tool-calls` step without an output spec). Omitted when an output was\nproduced.", + "type": [ + "boolean", + "null" + ] + }, "steps": { "items": { "$ref": "#/typeDefs/input/StepResult" @@ -5148,6 +5166,27 @@ "type": "string", "x-aimux-codec": "base64" }, + "IncludeOptions": { + "additionalProperties": false, + "description": "Controls which raw body fields are exposed in generation results.", + "properties": { + "requestBody": { + "description": "Whether to return the request body. Defaults to false.", + "type": [ + "boolean", + "null" + ] + }, + "responseBody": { + "description": "Whether to return the response body. Defaults to false.", + "type": [ + "boolean", + "null" + ] + } + }, + "type": "object" + }, "InputAudioFormat": { "additionalProperties": false, "description": "The input audio format for a streaming transcription request.", @@ -5799,6 +5838,17 @@ "null" ] }, + "include": { + "anyOf": [ + { + "$ref": "#/typeDefs/input/IncludeOptions" + }, + { + "type": "null" + } + ], + "description": "Controls the raw bodies exposed in the result. Both default to `false`." + }, "includeRawChunks": { "description": "Emit raw provider stream chunks as `StreamPart::Raw` (debugging aid).", "type": [ @@ -12761,135 +12811,33 @@ "type": "object" }, "GenerateTextResult": { - "description": "Result of `generate_text` and of a consumed `stream_text`: the AI SDK's\n`GenerateTextResult` (ai@7.0.127 `generate-text/generate-text-result.ts`).\n\nIt stores the steps, the usage summed over them and the parsed output, as\n`DefaultGenerateTextResult` does (`generate-text.ts:1691-1808`); every\nother value is derived from the steps by an accessor. The serialized form\nis a snapshot that writes the derived values next to the stored ones, so\na binding reads `text`, `tool_calls`, `usage` and the rest directly. Only\n`steps`, `total_usage` and `output` are read back.", + "description": "Result of `generate_text` and of a consumed `stream_text`: the AI SDK's\n`GenerateTextResult` (ai@7.0.127 `generate-text/generate-text-result.ts`).\n\nIt stores the steps, the usage summed over them and the parsed output, as\n`DefaultGenerateTextResult` does (`generate-text.ts:1691-1808`); every\nother value is derived from the steps by an accessor. The wire form carries\n`steps`, `totalUsage`, optional `output` (when explicitly parsed), and\noptional `outputParsed: false` (when no output was generated).", "properties": { - "content": { - "items": { - "$ref": "#/typeDefs/output/ContentPart" - }, - "type": "array" - }, - "files": { - "items": { - "$ref": "#/typeDefs/output/GeneratedFile" - }, - "type": "array" - }, - "finishReason": { - "$ref": "#/typeDefs/output/FinishReasonUnified" - }, "output": { - "description": "Absent when the output was not parsed.", + "description": "An explicit parsed output, including JSON `null`. When absent and\n`outputParsed` is not `false`, bindings expose the final step's text.", "x-aimux-codec": "presence" }, - "providerMetadata": { - "additionalProperties": { - "additionalProperties": true, - "type": "object" - }, - "description": "Deprecated upstream: the last step's provider metadata.", - "type": [ - "object", - "null" - ] - }, - "rawFinishReason": { - "type": [ - "string", - "null" - ] - }, - "reasoning": { - "description": "Deprecated upstream: the last step's reasoning.", - "items": { - "$ref": "#/typeDefs/output/ReasoningPart" - }, - "type": "array" - }, - "reasoningText": { - "description": "Deprecated upstream: the last step's reasoning text.", + "outputParsed": { + "description": "Present and `false` when no output was generated (for example, a final\n`tool-calls` step without an output spec). Omitted when an output was\nproduced.", "type": [ - "string", + "boolean", "null" ] }, - "request": { - "$ref": "#/typeDefs/output/RequestInfo", - "description": "Deprecated upstream: the last step's request." - }, - "response": { - "$ref": "#/typeDefs/output/StepResponse", - "description": "Deprecated upstream: the last step's response." - }, - "responseMessages": { - "items": { - "$ref": "#/typeDefs/output/ModelMessage" - }, - "type": "array" - }, - "sources": { - "description": "Each with its `type` tag (`generate-text-result.ts:73`).", - "items": { - "$ref": "#/typeDefs/output/TypedSource" - }, - "type": "array", - "x-aimux-codec": "tagged" - }, "steps": { "items": { "$ref": "#/typeDefs/output/StepResult" }, + "minItems": 1, "type": "array" }, - "text": { - "type": "string" - }, - "toolCalls": { - "description": "Each with its `type` tag (`generate-text-result.ts:78`).", - "items": { - "$ref": "#/typeDefs/output/TypedToolCall" - }, - "type": "array", - "x-aimux-codec": "tagged" - }, - "toolResults": { - "description": "Each with its `type` tag (`generate-text-result.ts:93`).", - "items": { - "$ref": "#/typeDefs/output/TaggedToolResult" - }, - "type": "array", - "x-aimux-codec": "tagged" - }, "totalUsage": { - "$ref": "#/typeDefs/output/LanguageModelUsage", - "description": "Deprecated upstream: equal to `usage`." - }, - "usage": { "$ref": "#/typeDefs/output/LanguageModelUsage" - }, - "warnings": { - "items": { - "$ref": "#/typeDefs/output/Warning" - }, - "type": "array" } }, "required": [ - "content", - "text", - "reasoning", - "files", - "sources", - "toolCalls", - "toolResults", - "finishReason", - "usage", - "totalUsage", - "warnings", - "request", - "response", - "responseMessages", - "steps" + "steps", + "totalUsage" ], "type": "object" }, @@ -20025,7 +19973,7 @@ "output": "GenerateTextResult", "revision": "1", "rustPath": "aimux_core::generate::GenerateTextResult", - "schemaHash": "c5c6016de2c926c85144959d9436c9d2214a27a9724e75d68393e933ef7263f5" + "schemaHash": "c75d0e0c2d207f9dfeffe7eb42efb9040d93a8062cdc678054f9bbcb8049e041" }, { "id": "aimux_core::image_model::ImageCallOptions", @@ -20076,6 +20024,27 @@ "rustPath": "aimux_core::reranking_model::RerankingResult", "schemaHash": "d757826963b3ce836e4d76fca8f42455a3a3146c20f3fb74f58cabe465348d01" }, + { + "id": "aimux_core::result::ReasoningPart", + "output": "ReasoningPart", + "revision": "1", + "rustPath": "aimux_core::result::ReasoningPart", + "schemaHash": "6210a367b8c084e55a60e0ead74a7ff233b7f357020a028c6879b54ffa8b9b87" + }, + { + "id": "aimux_core::result::TaggedToolResult", + "output": "TaggedToolResult", + "revision": "1", + "rustPath": "aimux_core::result::TaggedToolResult", + "schemaHash": "a8f688a021397c1159b88546156d5a418e50d6482d39f88c46476297d208e069" + }, + { + "id": "aimux_core::result::TypedSource", + "output": "TypedSource", + "revision": "1", + "rustPath": "aimux_core::result::TypedSource", + "schemaHash": "0a36b617c3f1bbcd82e4d09c329ad41aba62330b4d0e950125fd62b2053a9368" + }, { "id": "aimux_core::search_model::SearchCallOptions", "input": "SearchCallOptions", @@ -20270,28 +20239,28 @@ "input": "OpenAiOutputRequest", "revision": "1", "rustPath": "aimux_ops::ops::misc::OpenAiOutputRequest", - "schemaHash": "b0c6acc344f0b23b9ea3b693aeadf7aed7eb4fbdfce4b957be83af1154b842b4" + "schemaHash": "d30e30aa75703e1404a202d437e69a6873fd2b515c5ed322ab488363be8d2fb0" }, { "id": "aimux_ops::ops::misc::ToolRepairApplyRequest", "input": "ToolRepairApplyRequest", "revision": "1", "rustPath": "aimux_ops::ops::misc::ToolRepairApplyRequest", - "schemaHash": "0f430fdb223759ef7c48c4d7f824e7be74d29295a6b4f7caaf82b5acba25e538" + "schemaHash": "c1c5f81107f334a94583a4ff4ed394097580bea2f2a66266c11890fe2a3ab3d0" }, { "id": "aimux_ops::ops::misc::ToolRepairApplyResultRequest", "input": "ToolRepairApplyResultRequest", "revision": "1", "rustPath": "aimux_ops::ops::misc::ToolRepairApplyResultRequest", - "schemaHash": "fa092862004654e065233b2df2abdbec3befe88d9d734d494679968a5b6e954a" + "schemaHash": "649f2b4ff1a2dd0d552e2930b694d7efa3346b2f15a9fb0f14cffd4b6955b508" }, { "id": "aimux_ops::ops::misc::ToolRepairContextRequest", "input": "ToolRepairContextRequest", "revision": "1", "rustPath": "aimux_ops::ops::misc::ToolRepairContextRequest", - "schemaHash": "81bae04c56aac3380b75de639d162f819a2dd5717147a53cf1a75281727d78a1" + "schemaHash": "fa4802ac20a2b1b540cb727d798ad2a4c44cad6a8f9ad45281fc91ebb065e65f" }, { "id": "aimux_ops::ops::misc::ToolRepairContextResult", @@ -20529,7 +20498,7 @@ "output": "ReplayLiveResult", "revision": "1", "rustPath": "aimux_ops::ops::replay::ReplayLiveResult", - "schemaHash": "bd9959dd7e0300cb57e6929b2ed29b7e07dcb5aaf65be16b96e34bf8d6577a7f" + "schemaHash": "9163acd59ee54db1db2213c0756283b8b27e04a52451dfeef314d63efebbc730" }, { "id": "aimux_ops::ops::replay::ReplayPlan", @@ -20585,14 +20554,14 @@ "input": "OpenAiTextRequest", "revision": "1", "rustPath": "aimux_ops::ops::text::OpenAiTextRequest", - "schemaHash": "59293b18b6124a9a394113b8f94f637c65dc35ac44a30f7e0df70855e885f8e4" + "schemaHash": "d5afbf2b24ab74b82433d344afb190c18f8aef52988c54ab8b5388579c212f67" }, { "id": "aimux_ops::ops::text::TextRequest", "input": "TextRequest", "revision": "1", "rustPath": "aimux_ops::ops::text::TextRequest", - "schemaHash": "3a6f59c1f0c3b7ded5f5509d93afe9bddd2b80a8a3cd752d79f97edadae40c3d" + "schemaHash": "eb0c25fcbf741834943882d7f901af7439ba30923a391b273526d1887ed156ab" }, { "id": "aimux_ops::ops::trace::TraceAggregateParams", diff --git a/schema/types/GenerateTextOptions.json b/schema/types/GenerateTextOptions.json index fcffefeb0..ff4f661b9 100644 --- a/schema/types/GenerateTextOptions.json +++ b/schema/types/GenerateTextOptions.json @@ -21,6 +21,17 @@ "null" ] }, + "include": { + "anyOf": [ + { + "$ref": "IncludeOptions.json" + }, + { + "type": "null" + } + ], + "description": "Controls the raw bodies exposed in the result. Both default to `false`." + }, "includeRawChunks": { "description": "Emit raw provider stream chunks as `StreamPart::Raw` (debugging aid).", "type": [ diff --git a/schema/types/GenerateTextResult.json b/schema/types/GenerateTextResult.json index 67f08a29b..ba22650ff 100644 --- a/schema/types/GenerateTextResult.json +++ b/schema/types/GenerateTextResult.json @@ -2,135 +2,33 @@ "$comment": "Generated by aimux-codegen. Do not edit.", "$id": "https://aimux.dev/schema/types/GenerateTextResult.json", "$schema": "https://json-schema.org/draft/2020-12/schema", - "description": "Result of `generate_text` and of a consumed `stream_text`: the AI SDK's\n`GenerateTextResult` (ai@7.0.127 `generate-text/generate-text-result.ts`).\n\nIt stores the steps, the usage summed over them and the parsed output, as\n`DefaultGenerateTextResult` does (`generate-text.ts:1691-1808`); every\nother value is derived from the steps by an accessor. The serialized form\nis a snapshot that writes the derived values next to the stored ones, so\na binding reads `text`, `tool_calls`, `usage` and the rest directly. Only\n`steps`, `total_usage` and `output` are read back.", + "description": "Result of `generate_text` and of a consumed `stream_text`: the AI SDK's\n`GenerateTextResult` (ai@7.0.127 `generate-text/generate-text-result.ts`).\n\nIt stores the steps, the usage summed over them and the parsed output, as\n`DefaultGenerateTextResult` does (`generate-text.ts:1691-1808`); every\nother value is derived from the steps by an accessor. The wire form carries\n`steps`, `totalUsage`, optional `output` (when explicitly parsed), and\noptional `outputParsed: false` (when no output was generated).", "properties": { - "content": { - "items": { - "$ref": "ContentPart.json" - }, - "type": "array" - }, - "files": { - "items": { - "$ref": "GeneratedFile.json" - }, - "type": "array" - }, - "finishReason": { - "$ref": "FinishReasonUnified.json" - }, "output": { - "description": "Absent when the output was not parsed.", + "description": "An explicit parsed output, including JSON `null`. When absent and\n`outputParsed` is not `false`, bindings expose the final step's text.", "x-aimux-codec": "presence" }, - "providerMetadata": { - "additionalProperties": { - "additionalProperties": true, - "type": "object" - }, - "description": "Deprecated upstream: the last step's provider metadata.", - "type": [ - "object", - "null" - ] - }, - "rawFinishReason": { - "type": [ - "string", - "null" - ] - }, - "reasoning": { - "description": "Deprecated upstream: the last step's reasoning.", - "items": { - "$ref": "ReasoningPart.json" - }, - "type": "array" - }, - "reasoningText": { - "description": "Deprecated upstream: the last step's reasoning text.", + "outputParsed": { + "description": "Present and `false` when no output was generated (for example, a final\n`tool-calls` step without an output spec). Omitted when an output was\nproduced.", "type": [ - "string", + "boolean", "null" ] }, - "request": { - "$ref": "RequestInfo.json", - "description": "Deprecated upstream: the last step's request." - }, - "response": { - "$ref": "StepResponse.json", - "description": "Deprecated upstream: the last step's response." - }, - "responseMessages": { - "items": { - "$ref": "ModelMessage.json" - }, - "type": "array" - }, - "sources": { - "description": "Each with its `type` tag (`generate-text-result.ts:73`).", - "items": { - "$ref": "TypedSource.json" - }, - "type": "array", - "x-aimux-codec": "tagged" - }, "steps": { "items": { "$ref": "StepResult.json" }, + "minItems": 1, "type": "array" }, - "text": { - "type": "string" - }, - "toolCalls": { - "description": "Each with its `type` tag (`generate-text-result.ts:78`).", - "items": { - "$ref": "TypedToolCall.json" - }, - "type": "array", - "x-aimux-codec": "tagged" - }, - "toolResults": { - "description": "Each with its `type` tag (`generate-text-result.ts:93`).", - "items": { - "$ref": "TaggedToolResult.json" - }, - "type": "array", - "x-aimux-codec": "tagged" - }, "totalUsage": { - "$ref": "LanguageModelUsage.json", - "description": "Deprecated upstream: equal to `usage`." - }, - "usage": { "$ref": "LanguageModelUsage.json" - }, - "warnings": { - "items": { - "$ref": "Warning.json" - }, - "type": "array" } }, "required": [ - "content", - "text", - "reasoning", - "files", - "sources", - "toolCalls", - "toolResults", - "finishReason", - "usage", - "totalUsage", - "warnings", - "request", - "response", - "responseMessages", - "steps" + "steps", + "totalUsage" ], "type": "object" } diff --git a/schema/types/GenerateTextResultInput.json b/schema/types/GenerateTextResultInput.json index c3605e602..76f1d75e4 100644 --- a/schema/types/GenerateTextResultInput.json +++ b/schema/types/GenerateTextResultInput.json @@ -2,12 +2,19 @@ "$comment": "Generated by aimux-codegen. Do not edit.", "$id": "https://aimux.dev/schema/types/GenerateTextResultInput.json", "$schema": "https://json-schema.org/draft/2020-12/schema", - "description": "Result of `generate_text` and of a consumed `stream_text`: the AI SDK's\n`GenerateTextResult` (ai@7.0.127 `generate-text/generate-text-result.ts`).\n\nIt stores the steps, the usage summed over them and the parsed output, as\n`DefaultGenerateTextResult` does (`generate-text.ts:1691-1808`); every\nother value is derived from the steps by an accessor. The serialized form\nis a snapshot that writes the derived values next to the stored ones, so\na binding reads `text`, `tool_calls`, `usage` and the rest directly. Only\n`steps`, `total_usage` and `output` are read back.", + "description": "Result of `generate_text` and of a consumed `stream_text`: the AI SDK's\n`GenerateTextResult` (ai@7.0.127 `generate-text/generate-text-result.ts`).\n\nIt stores the steps, the usage summed over them and the parsed output, as\n`DefaultGenerateTextResult` does (`generate-text.ts:1691-1808`); every\nother value is derived from the steps by an accessor. The wire form carries\n`steps`, `totalUsage`, optional `output` (when explicitly parsed), and\noptional `outputParsed: false` (when no output was generated).", "properties": { "output": { - "default": null, + "description": "An explicit parsed output, including JSON `null`. When absent and\n`outputParsed` is not `false`, bindings expose the final step's text.", "x-aimux-codec": "presence" }, + "outputParsed": { + "description": "Present and `false` when no output was generated (for example, a final\n`tool-calls` step without an output spec). Omitted when an output was\nproduced.", + "type": [ + "boolean", + "null" + ] + }, "steps": { "items": { "$ref": "StepResultInput.json" diff --git a/schema/types/IncludeOptions.json b/schema/types/IncludeOptions.json new file mode 100644 index 000000000..f43e547f2 --- /dev/null +++ b/schema/types/IncludeOptions.json @@ -0,0 +1,24 @@ +{ + "$comment": "Generated by aimux-codegen. Do not edit.", + "$id": "https://aimux.dev/schema/types/IncludeOptions.json", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "description": "Controls which raw body fields are exposed in generation results.", + "properties": { + "requestBody": { + "description": "Whether to return the request body. Defaults to false.", + "type": [ + "boolean", + "null" + ] + }, + "responseBody": { + "description": "Whether to return the response body. Defaults to false.", + "type": [ + "boolean", + "null" + ] + } + }, + "type": "object" +} diff --git a/schema/types/Options.json b/schema/types/Options.json index 9ac62ca52..a35d7cd20 100644 --- a/schema/types/Options.json +++ b/schema/types/Options.json @@ -21,6 +21,17 @@ "null" ] }, + "include": { + "anyOf": [ + { + "$ref": "IncludeOptions.json" + }, + { + "type": "null" + } + ], + "description": "Controls the raw bodies exposed in the result. Both default to `false`." + }, "includeRawChunks": { "description": "Emit raw provider stream chunks as `StreamPart::Raw` (debugging aid).", "type": [ diff --git a/tools/aimux-codegen/README.md b/tools/aimux-codegen/README.md index 08fb776b3..3afafa8b6 100644 --- a/tools/aimux-codegen/README.md +++ b/tools/aimux-codegen/README.md @@ -59,6 +59,11 @@ upper bound. The inventory lives at The TypeScript emitter also writes the console wire types to `tools/aimux-web/web/src/types/generated/`. +For `GenerateTextResult`, the DTO codecs use the facts in the manifest. +The emitters add derived accessors from `src/emit/text_result/`. Kotlin +uses the same generated JavaBean getters as Java. Node attaches its generated +accessors when the typed client parses a result, leaving the wire JSON compact. + Drift is guarded by `cargo run -p aimux-codegen -- --check` (CI step "Ops manifest and generated artifact drift") and by the DTO vectors: `python3 scripts/check_dto_vectors.py ` round-trips diff --git a/tools/aimux-codegen/generated-files.json b/tools/aimux-codegen/generated-files.json index 6fe298bf4..d0dd37fe1 100644 --- a/tools/aimux-codegen/generated-files.json +++ b/tools/aimux-codegen/generated-files.json @@ -102,6 +102,7 @@ "bindings/java/generated/ai/arcships/aimux/types/ImageResponse.java", "bindings/java/generated/ai/arcships/aimux/types/ImageResult.java", "bindings/java/generated/ai/arcships/aimux/types/ImageUsage.java", + "bindings/java/generated/ai/arcships/aimux/types/IncludeOptions.java", "bindings/java/generated/ai/arcships/aimux/types/InputAudioFormat.java", "bindings/java/generated/ai/arcships/aimux/types/InputRecord.java", "bindings/java/generated/ai/arcships/aimux/types/InputTokenDetails.java", @@ -335,6 +336,7 @@ "bindings/kotlin/generated/AimuxOps.kt", "bindings/node/src/generated/dto_vectors.ts", "bindings/node/src/generated/ops.ts", + "bindings/node/src/generated/text_result.ts", "bindings/node/src/generated/types.ts", "bindings/python/python/aimux/_error_payloads.py", "bindings/python/python/aimux/_types.py", @@ -436,6 +438,7 @@ "schema/types/ImageResponse.json", "schema/types/ImageResult.json", "schema/types/ImageUsage.json", + "schema/types/IncludeOptions.json", "schema/types/InputAudioFormat.json", "schema/types/InputRecord.json", "schema/types/InputTokenDetails.json", @@ -678,5 +681,5 @@ "tools/aimux-web/web/src/types/generated/WireOptions.ts", "tools/aimux-web/web/src/types/generated/WireTool.ts" ], - "manifestDigest": "cd147fa9595ede3951744fa261da98cc18c204e65b4081073ad3a3c1b68bfd92" + "manifestDigest": "6914772fdc03df08cba497def41cb354fe52e40eba49844a66938b4cd38c5d83" } diff --git a/tools/aimux-codegen/src/emit/dart.rs b/tools/aimux-codegen/src/emit/dart.rs index 75edb0fae..dfae45fa0 100644 --- a/tools/aimux-codegen/src/emit/dart.rs +++ b/tools/aimux-codegen/src/emit/dart.rs @@ -497,6 +497,13 @@ fn class( closed: bool, model: &Model, ) -> Result<()> { + let member = |f: &Field| { + if name == "GenerateTextResult" && f.json_name == "output" { + "outputValue".into() + } else { + ident(&f.json_name) + } + }; let base = parent.map_or(String::new(), |(base, _, _)| format!(" extends {base}")); let declaration = format!("final class {name}{base} {{"); if declaration.len() > 80 { @@ -509,7 +516,7 @@ fn class( out.push('\n'); } docs(out, f.doc.as_deref(), " "); - writeln!(out, " final {} {};", field_type(f), ident(&f.json_name)).unwrap(); + writeln!(out, " final {} {};", field_type(f), member(f)).unwrap(); } if fields.is_empty() { writeln!(out, " const {name}();").unwrap(); @@ -520,7 +527,7 @@ fn class( out, " {}this.{}{},", if f.required { "required " } else { "" }, - ident(&f.json_name), + member(f), if !f.required && presence(&f.ty) { " = const Field.absent()" } else { @@ -559,6 +566,9 @@ fn class( ) .unwrap(); } + if name == "GenerateTextResult" { + out.push_str(" if ((json['steps'] as List).isEmpty) {\n throw const FormatException('GenerateTextResult requires at least one step');\n }\n if (json.containsKey('output') && json['outputParsed'] == false) {\n throw const FormatException('GenerateTextResult cannot carry output when outputParsed is false');\n }\n"); + } writeln!( out, " return {name}{}", @@ -582,13 +592,7 @@ fn class( decode(&f.ty, &v, model) .map_err(|e| format!("{name} #/properties/{}: {e}", escape(&f.json_name)))? }; - expression( - out, - &format!(" {}: ", ident(&f.json_name)), - &expr, - ",", - 6, - ); + expression(out, &format!(" {}: ", member(f)), &expr, ",", 6); } if !fields.is_empty() { out.push_str(" );\n"); @@ -603,7 +607,7 @@ fn class( writeln!(out, " {}: {},", quote(tag), quote(value)).unwrap(); } for f in fields { - let field = ident(&f.json_name); + let field = member(f); let key = quote(&f.json_name); let (condition, value) = if !f.required && presence(&f.ty) { (format!("if ({field}.isPresent) "), encode(&f.ty, &field)) @@ -622,7 +626,11 @@ fn class( expression(out, &format!(" {condition}{key}: "), &value, ",", 8); } } - out.push_str(" };\n}\n\n"); + out.push_str(" };\n"); + if name == "GenerateTextResult" { + out.push_str(include_str!("text_result/dart.inc")); + } + out.push_str("}\n\n"); Ok(()) } diff --git a/tools/aimux-codegen/src/emit/go.rs b/tools/aimux-codegen/src/emit/go.rs index 8f8614d6f..5b5a1e5f0 100644 --- a/tools/aimux-codegen/src/emit/go.rs +++ b/tools/aimux-codegen/src/emit/go.rs @@ -180,7 +180,11 @@ fn structure( .iter() .map(|f| { Ok(( - ident(&f.json_name), + if name == "GenerateTextResult" && f.json_name == "output" { + "OutputValue".into() + } else { + ident(&f.json_name) + }, field_ty(f, model).map_err(|e| { format!("{name} #/properties/{}: {e}", escape(&f.json_name)) })?, @@ -209,7 +213,10 @@ fn structure( } } out.push_str("}\n\n"); - if closed { + if name == "GenerateTextResult" { + out.push_str(include_str!("text_result/go.inc")); + out.push('\n'); + } else if closed { writeln!(out, "func (v *{name}) UnmarshalJSON(data []byte) error {{").unwrap(); write_closed_check(out); writeln!( diff --git a/tools/aimux-codegen/src/emit/java.rs b/tools/aimux-codegen/src/emit/java.rs index 9f40d9f24..fb96b9351 100644 --- a/tools/aimux-codegen/src/emit/java.rs +++ b/tools/aimux-codegen/src/emit/java.rs @@ -385,6 +385,10 @@ fn object( ) .unwrap(); } + if n == "GenerateTextResult" { + writeln!(out, "{i} if (steps == null || steps.isEmpty()) throw new IllegalArgumentException(\"GenerateTextResult requires at least one step\");").unwrap(); + writeln!(out, "{i} if (output != null && output.isPresent() && Boolean.FALSE.equals(outputParsed)) throw new IllegalArgumentException(\"GenerateTextResult cannot carry output when outputParsed is false\");").unwrap(); + } for f in fields { let id = ident(&f.json_name); let expr = if presence(&f.ty) { @@ -416,7 +420,9 @@ fn object( } for f in fields { let id = ident(&f.json_name); - let expr = if presence(&f.ty) { + let expr = if n == "GenerateTextResult" && f.json_name == "output" { + "output.isPresent() ? (output.getValue() == null ? null : output.getValue().deepCopy()) : (Boolean.FALSE.equals(outputParsed) ? null : com.fasterxml.jackson.databind.node.TextNode.valueOf(getText()))".into() + } else if presence(&f.ty) { getter(&f.ty, &format!("{id}.getValue()")) } else { getter(&f.ty, &id) @@ -429,14 +435,23 @@ fn object( ) .unwrap(); if presence(&f.ty) { + let has_expr = if n == "GenerateTextResult" && f.json_name == "output" { + format!("{id}.isPresent() || !Boolean.FALSE.equals(outputParsed)") + } else { + format!("{id}.isPresent()") + }; writeln!( out, - "{i}public boolean has{}() {{ return {id}.isPresent(); }}", + "{i}public boolean has{}() {{ return {has_expr}; }}", cap(&id) ) .unwrap(); } } + if n == "GenerateTextResult" { + // Kotlin's DTOs use these same JavaBean properties. + out.push_str(include_str!("text_result/java.inc")); + } writeln!(out, "\n{i}public static final class Builder {{").unwrap(); for f in fields { let initial = if presence(&f.ty) { diff --git a/tools/aimux-codegen/src/emit/node.rs b/tools/aimux-codegen/src/emit/node.rs index 4746141c2..0a2f7a7b1 100644 --- a/tools/aimux-codegen/src/emit/node.rs +++ b/tools/aimux-codegen/src/emit/node.rs @@ -13,6 +13,7 @@ impl Emitter for Node { "bindings/node/src/generated/types.ts", "bindings/node/src/generated/dto_vectors.ts", WEB_DIR, + "bindings/node/src/generated/text_result.ts", ] } @@ -27,7 +28,12 @@ impl Emitter for Node { let mut names = String::from("export const dtoTypeNames = [\n"); let mut schemas = serde_json::Map::new(); for named in &model.types { - write_declaration(&mut out, named); + if named.name == "GenerateTextResult" { + write_declaration_as(&mut out, named, "GenerateTextResultWire"); + out.push_str(include_str!("text_result/node-types.ts")); + } else { + write_declaration(&mut out, named); + } if let Kind::Tagged { tag, variants } = &named.kind { writeln!( tags, @@ -61,6 +67,10 @@ impl Emitter for Node { Ok(vec![ (self.owned()[0].into(), out), (self.owned()[1].into(), table), + ( + self.owned()[3].into(), + include_str!("text_result/node-runtime.ts").into(), + ), ]) } } @@ -297,7 +307,10 @@ pub fn web_files(model: &Model) -> Vec<(PathBuf, String)> { } fn write_declaration(out: &mut String, named: &NamedType) { - let name = &named.name; + write_declaration_as(out, named, &named.name); +} + +fn write_declaration_as(out: &mut String, named: &NamedType, name: &str) { docs(out, named.doc.as_deref(), ""); match &named.kind { Kind::Struct { fields, .. } => { diff --git a/tools/aimux-codegen/src/emit/python.rs b/tools/aimux-codegen/src/emit/python.rs index 0d92d95e6..d660b47fe 100644 --- a/tools/aimux-codegen/src/emit/python.rs +++ b/tools/aimux-codegen/src/emit/python.rs @@ -323,8 +323,18 @@ fn class( writeln!( out, " {}: {annotation} = Field({}alias={})", - ident(&field.json_name), - if field.required { "" } else { "default=None, " }, + if name == "GenerateTextResult" && field.json_name == "output" { + "output_value".into() + } else { + ident(&field.json_name) + }, + if name == "GenerateTextResult" && field.json_name == "steps" { + "min_length=1, " + } else if field.required { + "" + } else { + "default=None, " + }, quote(&field.json_name) ) .unwrap(); @@ -342,6 +352,9 @@ fn class( ) .unwrap(); } + if name == "GenerateTextResult" { + out.push_str(include_str!("text_result/python.inc")); + } if fields.is_empty() && tag.is_none() && !closed { out.push_str(" pass\n"); } @@ -439,7 +452,7 @@ from typing import Annotated, Any, ClassVar, Dict, List, Literal, Optional, Unio from pydantic import ( BaseModel, BeforeValidator, ConfigDict, Discriminator, Field, Tag, - model_serializer, + model_serializer, model_validator, ) from typing_extensions import TypeAliasType diff --git a/tools/aimux-codegen/src/emit/swift.rs b/tools/aimux-codegen/src/emit/swift.rs index 685ab564c..ad36a4f83 100644 --- a/tools/aimux-codegen/src/emit/swift.rs +++ b/tools/aimux-codegen/src/emit/swift.rs @@ -247,6 +247,13 @@ fn storage(field: &Field) -> String { } fn structure(out: &mut String, name: &str, fields: &[Field], closed: bool) { + let member = |field: &Field| { + if name == "GenerateTextResult" && field.json_name == "output" { + "outputValue".into() + } else { + camel(&field.json_name) + } + }; writeln!( out, "public struct {}: Codable, Equatable, Sendable {{", @@ -255,7 +262,7 @@ fn structure(out: &mut String, name: &str, fields: &[Field], closed: bool) { .unwrap(); for field in fields { docs(out, field.doc.as_deref(), " "); - let key = camel(&field.json_name); + let key = member(field); if boxed(name, field) { let storage = storage(field); writeln!( @@ -291,7 +298,7 @@ fn structure(out: &mut String, name: &str, fields: &[Field], closed: bool) { } out.push_str(") {\n"); for field in fields { - let key = camel(&field.json_name); + let key = member(field); if boxed(name, field) { writeln!( out, @@ -300,7 +307,7 @@ fn structure(out: &mut String, name: &str, fields: &[Field], closed: bool) { ) .unwrap(); } else { - writeln!(out, " self.{key} = {key}").unwrap(); + writeln!(out, " self.{key} = {}", camel(&field.json_name)).unwrap(); } } out.push_str(" }\n"); @@ -315,7 +322,7 @@ fn structure(out: &mut String, name: &str, fields: &[Field], closed: bool) { { if fields .iter() - .any(|field| camel(&field.json_name).trim_matches('`') != field.json_name) + .any(|field| member(field).trim_matches('`') != field.json_name) { keys(out, fields, None); } @@ -348,31 +355,27 @@ fn structure(out: &mut String, name: &str, fields: &[Field], closed: bool) { ) .unwrap(); } else { - writeln!( - out, - " self.{} = {}", - camel(&field.json_name), - decode(field) - ) - .unwrap(); + writeln!(out, " self.{} = {}", member(field), decode(field)).unwrap(); } } } + if name == "GenerateTextResult" { + out.push_str(" guard !steps.isEmpty else {\n throw DecodingError.dataCorruptedError(forKey: .steps, in: c, debugDescription: \"GenerateTextResult requires at least one step\")\n }\n if case .missing = outputValue {} else if outputParsed == false {\n throw DecodingError.dataCorruptedError(forKey: .outputParsed, in: c, debugDescription: \"GenerateTextResult cannot carry output when outputParsed is false\")\n }\n"); + } out.push_str(" }\n public func encode(to encoder: any Encoder) throws {\n"); if fields.is_empty() { out.push_str(" _ = encoder.container(keyedBy: WireKey.self)\n"); } else { out.push_str(" var c = encoder.container(keyedBy: CodingKeys.self)\n"); for field in fields { - encode( - out, - field, - &format!("self.{}", camel(&field.json_name)), - " ", - ); + encode(out, field, &format!("self.{}", member(field)), " "); } } out.push_str(" }\n}\n\n"); + if name == "GenerateTextResult" { + out.push_str(include_str!("text_result/swift.inc")); + out.push('\n'); + } } impl Emitter for Swift { diff --git a/tools/aimux-codegen/src/emit/text_result/dart.inc b/tools/aimux-codegen/src/emit/text_result/dart.inc new file mode 100644 index 000000000..cb343b7f2 --- /dev/null +++ b/tools/aimux-codegen/src/emit/text_result/dart.inc @@ -0,0 +1,43 @@ + + StepResult get finalStep => steps.last; + String get text => + finalStep.content.whereType().map((p) => p.text).join(); + List get content => steps.expand((step) => step.content).toList(); + List get reasoning => finalStep.content + .where((p) => p is ContentPartReasoning || p is ContentPartReasoningFile) + .toList(); + String? get reasoningText { + final text = reasoning.whereType().map((p) => p.text).join(); + return text.isEmpty ? null : text; + } + + List get files => + content.whereType().map((p) => p.file).toList(); + List get sources => content + .where((p) => p is ContentPartSourceUrl || p is ContentPartSourceDocument) + .toList(); + List get toolCalls => + content.whereType().toList(); + List get staticToolCalls => + toolCalls.where((p) => p.dynamic_ != true).toList(); + List get dynamicToolCalls => + toolCalls.where((p) => p.dynamic_ == true).toList(); + List get toolResults => + content.whereType().toList(); + List get staticToolResults => + toolResults.where((p) => p.dynamic_ != true).toList(); + List get dynamicToolResults => + toolResults.where((p) => p.dynamic_ == true).toList(); + FinishReasonUnified get finishReason => finalStep.finishReason; + String? get rawFinishReason => finalStep.rawFinishReason; + LanguageModelUsage get usage => totalUsage; + List get warnings => steps.expand((step) => step.warnings).toList(); + RequestInfo get request => finalStep.request; + StepResponse get response => finalStep.response; + Map>? get providerMetadata => + finalStep.providerMetadata; + List get responseMessages => + steps.expand((step) => step.response.messages).toList(); + Field get output => outputValue.isPresent + ? outputValue + : (outputParsed == false ? const Field.absent() : Field.of(text)); diff --git a/tools/aimux-codegen/src/emit/text_result/go.inc b/tools/aimux-codegen/src/emit/text_result/go.inc new file mode 100644 index 000000000..579851719 --- /dev/null +++ b/tools/aimux-codegen/src/emit/text_result/go.inc @@ -0,0 +1,173 @@ +func (v *GenerateTextResult) UnmarshalJSON(data []byte) error { + type facts GenerateTextResult + var result facts + if err := json.Unmarshal(data, &result); err != nil { + return err + } + if len(result.Steps) == 0 { + return fmt.Errorf("GenerateTextResult requires at least one step") + } + if result.OutputValue.Present && result.OutputParsed != nil && !*result.OutputParsed { + return fmt.Errorf("GenerateTextResult cannot carry output when outputParsed is false") + } + *v = GenerateTextResult(result) + return nil +} + +// FinalStep is the last model call in the result. +func (v GenerateTextResult) FinalStep() StepResult { return v.Steps[len(v.Steps)-1] } + +func (v GenerateTextResult) Text() string { + text := "" + for _, part := range v.FinalStep().Content { + if part, ok := part.Value.(ContentPartVariantText); ok { + text += part.Text + } + } + return text +} + +func (v GenerateTextResult) Content() []ContentPart { + out := []ContentPart{} + for _, step := range v.Steps { + out = append(out, step.Content...) + } + return out +} + +// resultParts selects payloads directly from ordered content. +func resultParts[T ContentPartVariant](content []ContentPart) []T { + out := []T{} + for _, part := range content { + if value, ok := part.Value.(T); ok { + out = append(out, value) + } + } + return out +} + +func (v GenerateTextResult) Reasoning() []ContentPart { + out := []ContentPart{} + for _, part := range v.FinalStep().Content { + switch part.Value.(type) { + case ContentPartVariantReasoning, ContentPartVariantReasoningFile: + out = append(out, part) + } + } + return out +} + +func (v GenerateTextResult) ReasoningText() *string { + text := "" + for _, part := range resultParts[ContentPartVariantReasoning](v.FinalStep().Content) { + text += part.Text + } + if text == "" { + return nil + } + return &text +} + +func (v GenerateTextResult) Files() []GeneratedFile { + out := []GeneratedFile{} + for _, part := range resultParts[ContentPartVariantFile](v.Content()) { + out = append(out, part.File) + } + return out +} + +func (v GenerateTextResult) Sources() []ContentPart { + out := []ContentPart{} + for _, part := range v.Content() { + switch part.Value.(type) { + case ContentPartVariantSourceURL, ContentPartVariantSourceDocument: + out = append(out, part) + } + } + return out +} + +func (v GenerateTextResult) ToolCalls() []ContentPartVariantToolCall { + return resultParts[ContentPartVariantToolCall](v.Content()) +} + +func (v GenerateTextResult) toolCallsByDynamic(dynamic bool) []ContentPartVariantToolCall { + out := []ContentPartVariantToolCall{} + for _, part := range v.ToolCalls() { + if (part.Dynamic != nil && *part.Dynamic) == dynamic { + out = append(out, part) + } + } + return out +} + +func (v GenerateTextResult) StaticToolCalls() []ContentPartVariantToolCall { + return v.toolCallsByDynamic(false) +} + +func (v GenerateTextResult) DynamicToolCalls() []ContentPartVariantToolCall { + return v.toolCallsByDynamic(true) +} + +func (v GenerateTextResult) ToolResults() []ContentPartVariantToolResult { + return resultParts[ContentPartVariantToolResult](v.Content()) +} + +func (v GenerateTextResult) toolResultsByDynamic(dynamic bool) []ContentPartVariantToolResult { + out := []ContentPartVariantToolResult{} + for _, part := range v.ToolResults() { + if (part.Dynamic != nil && *part.Dynamic) == dynamic { + out = append(out, part) + } + } + return out +} + +func (v GenerateTextResult) StaticToolResults() []ContentPartVariantToolResult { + return v.toolResultsByDynamic(false) +} + +func (v GenerateTextResult) DynamicToolResults() []ContentPartVariantToolResult { + return v.toolResultsByDynamic(true) +} + +func (v GenerateTextResult) FinishReason() FinishReasonUnified { return v.FinalStep().FinishReason } +func (v GenerateTextResult) RawFinishReason() *string { return v.FinalStep().RawFinishReason } +func (v GenerateTextResult) Usage() LanguageModelUsage { return v.TotalUsage } +func (v GenerateTextResult) Request() RequestInfo { return v.FinalStep().Request } +func (v GenerateTextResult) Response() StepResponse { return v.FinalStep().Response } +func (v GenerateTextResult) ProviderMetadata() map[string]map[string]json.RawMessage { + return v.FinalStep().ProviderMetadata +} + +func (v GenerateTextResult) Warnings() []Warning { + out := []Warning{} + for _, step := range v.Steps { + out = append(out, step.Warnings...) + } + return out +} + +func (v GenerateTextResult) ResponseMessages() []ModelMessage { + out := []ModelMessage{} + for _, step := range v.Steps { + out = append(out, step.Response.Messages...) + } + return out +} + +// Output returns the parsed JSON value, the final step's text as a JSON string +// when parsed as plain text, or nil when no output was generated. +func (v GenerateTextResult) Output() json.RawMessage { + if v.OutputValue.Present { + if v.OutputValue.Null { + return json.RawMessage("null") + } + return v.OutputValue.Value + } + if v.OutputParsed != nil && !*v.OutputParsed { + return nil + } + value, _ := json.Marshal(v.Text()) + return value +} diff --git a/tools/aimux-codegen/src/emit/text_result/java.inc b/tools/aimux-codegen/src/emit/text_result/java.inc new file mode 100644 index 000000000..0d73ec42b --- /dev/null +++ b/tools/aimux-codegen/src/emit/text_result/java.inc @@ -0,0 +1,92 @@ + + public StepResult getFinalStep() { return steps.get(steps.size() - 1); } + public String getText() { + return getFinalStep().getContent().stream().filter(ContentPart.Text.class::isInstance) + .map(ContentPart::getText).collect(java.util.stream.Collectors.joining()); + } + public List getContent() { + return steps.stream().flatMap(step -> step.getContent().stream()) + .collect(java.util.stream.Collectors.toList()); + } + public List getReasoning() { + List reasoning = new ArrayList<>(); + for (ContentPart part : getFinalStep().getContent()) { + if (part instanceof ContentPart.Reasoning) { + reasoning.add(new ReasoningPart.Reasoning(part.getProviderMetadata(), part.getText())); + } else if (part instanceof ContentPart.ReasoningFile) { + reasoning.add(new ReasoningPart.ReasoningFile(part.getFile(), part.getProviderMetadata())); + } + } + return reasoning; + } + public String getReasoningText() { + String text = getFinalStep().getContent().stream().filter(ContentPart.Reasoning.class::isInstance) + .map(ContentPart::getText).collect(java.util.stream.Collectors.joining()); + return text.isEmpty() ? null : text; + } + private java.util.stream.Stream parts(Class type) { + return steps.stream().flatMap(step -> step.getContent().stream()) + .filter(type::isInstance).map(type::cast); + } + public List getFiles() { + return parts(ContentPart.File.class).map(ContentPart::getFile) + .collect(java.util.stream.Collectors.toList()); + } + public List getSources() { + List sources = new ArrayList<>(); + parts(ContentPart.SourceUrlGroup.class).forEach(part -> { + if (part instanceof ContentPart.SourceUrl) { + ContentPart.SourceUrl url = (ContentPart.SourceUrl) part; + sources.add(new TypedSource.Url(url.getId(), url.getProviderMetadata(), url.getTitle(), + url.getType(), url.getUrl())); + } else if (part instanceof ContentPart.SourceDocument) { + ContentPart.SourceDocument doc = (ContentPart.SourceDocument) part; + sources.add(new TypedSource.Document(doc.getFilename(), doc.getId(), doc.getMediaType(), + doc.getProviderMetadata(), doc.getTitle(), doc.getType())); + } + }); + return sources; + } + public List getToolCalls() { + return parts(ContentPart.ToolCallVariant.class) + .map(part -> new TypedToolCall(part.getDynamic(), part.getError(), part.getInput(), part.getInvalid(), + part.getProviderExecuted(), part.getProviderMetadata(), part.getToolCallId(), part.getToolName(), + part.getType())) + .collect(java.util.stream.Collectors.toList()); + } + public List getStaticToolCalls() { + return getToolCalls().stream().filter(part -> !Boolean.TRUE.equals(part.getDynamic())) + .collect(java.util.stream.Collectors.toList()); + } + public List getDynamicToolCalls() { + return getToolCalls().stream().filter(part -> Boolean.TRUE.equals(part.getDynamic())) + .collect(java.util.stream.Collectors.toList()); + } + public List getToolResults() { + return parts(ContentPart.ToolResultVariant.class) + .map(part -> new TaggedToolResult(part.getDynamic(), part.getInput(), part.getOutput(), + part.getPreliminary(), part.getProviderExecuted(), part.getProviderMetadata(), part.getToolCallId(), + part.getToolName(), part.getType())) + .collect(java.util.stream.Collectors.toList()); + } + public List getStaticToolResults() { + return getToolResults().stream().filter(part -> !Boolean.TRUE.equals(part.getDynamic())) + .collect(java.util.stream.Collectors.toList()); + } + public List getDynamicToolResults() { + return getToolResults().stream().filter(part -> Boolean.TRUE.equals(part.getDynamic())) + .collect(java.util.stream.Collectors.toList()); + } + public FinishReasonUnified getFinishReason() { return getFinalStep().getFinishReason(); } + public String getRawFinishReason() { return getFinalStep().getRawFinishReason(); } + public LanguageModelUsage getUsage() { return totalUsage; } + public RequestInfo getRequest() { return getFinalStep().getRequest(); } + public StepResponse getResponse() { return getFinalStep().getResponse(); } + public Map> getProviderMetadata() { return getFinalStep().getProviderMetadata(); } + public List getWarnings() { + return steps.stream().flatMap(step -> step.getWarnings().stream()).collect(java.util.stream.Collectors.toList()); + } + public List getResponseMessages() { + return steps.stream().flatMap(step -> step.getResponse().getMessages().stream()) + .collect(java.util.stream.Collectors.toList()); + } diff --git a/tools/aimux-codegen/src/emit/text_result/node-runtime.ts b/tools/aimux-codegen/src/emit/text_result/node-runtime.ts new file mode 100644 index 000000000..31641733c --- /dev/null +++ b/tools/aimux-codegen/src/emit/text_result/node-runtime.ts @@ -0,0 +1,55 @@ +// Generated by aimux-codegen. Do not edit. +import type { ContentPart, GenerateTextResult, GenerateTextResultWire } from './types.ts' + +const allParts = (result: GenerateTextResultWire) => result.steps.flatMap(step => step.content) + +function partsOf(parts: ContentPart[], type: K) { + return parts.filter((part): part is Extract => part.type === type) +} + +const getters: PropertyDescriptorMap = { + finalStep: { get(this: GenerateTextResult) { return this.steps[this.steps.length - 1] } }, + content: { get(this: GenerateTextResult) { return allParts(this) } }, + text: { get(this: GenerateTextResult) { + return partsOf(this.finalStep.content, 'text').map(part => part.text).join('') + } }, + reasoning: { get(this: GenerateTextResult) { + return this.finalStep.content.filter(part => part.type === 'reasoning' || part.type === 'reasoning-file') + } }, + reasoningText: { get(this: GenerateTextResult) { + return partsOf(this.finalStep.content, 'reasoning').map(part => part.text).join('') || undefined + } }, + files: { get(this: GenerateTextResult) { return partsOf(this.content, 'file').map(part => part.file) } }, + sources: { get(this: GenerateTextResult) { return partsOf(this.content, 'source') } }, + toolCalls: { get(this: GenerateTextResult) { return partsOf(this.content, 'tool-call') } }, + staticToolCalls: { get(this: GenerateTextResult) { return this.toolCalls.filter(part => part.dynamic !== true) } }, + dynamicToolCalls: { get(this: GenerateTextResult) { return this.toolCalls.filter(part => part.dynamic === true) } }, + toolResults: { get(this: GenerateTextResult) { return partsOf(this.content, 'tool-result') } }, + staticToolResults: { get(this: GenerateTextResult) { return this.toolResults.filter(part => part.dynamic !== true) } }, + dynamicToolResults: { get(this: GenerateTextResult) { return this.toolResults.filter(part => part.dynamic === true) } }, + finishReason: { get(this: GenerateTextResult) { return this.finalStep.finishReason } }, + rawFinishReason: { get(this: GenerateTextResult) { return this.finalStep.rawFinishReason } }, + usage: { get(this: GenerateTextResult) { return this.totalUsage } }, + warnings: { get(this: GenerateTextResult) { return this.steps.flatMap(step => step.warnings) } }, + request: { get(this: GenerateTextResult) { return this.finalStep.request } }, + response: { get(this: GenerateTextResult) { return this.finalStep.response } }, + providerMetadata: { get(this: GenerateTextResult) { return this.finalStep.providerMetadata } }, + responseMessages: { get(this: GenerateTextResult) { + return this.steps.flatMap(step => step.response.messages) + } }, +} + +export function attachGenerateTextResult(result: GenerateTextResultWire): GenerateTextResult { + if (!Array.isArray(result?.steps) || result.steps.length === 0) { + throw new TypeError('GenerateTextResult requires at least one step') + } + const hasExplicitOutput = Object.prototype.hasOwnProperty.call(result, 'output') + if (hasExplicitOutput && result.outputParsed === false) { + throw new TypeError('GenerateTextResult cannot carry output when outputParsed is false') + } + Object.defineProperties(result, getters) + if (!hasExplicitOutput && result.outputParsed !== false) { + Object.defineProperty(result, 'output', { get(this: GenerateTextResult) { return this.text } }) + } + return result as GenerateTextResult +} diff --git a/tools/aimux-codegen/src/emit/text_result/node-types.ts b/tools/aimux-codegen/src/emit/text_result/node-types.ts new file mode 100644 index 000000000..66e1d2ca5 --- /dev/null +++ b/tools/aimux-codegen/src/emit/text_result/node-types.ts @@ -0,0 +1,26 @@ + +/** A text result returned by the typed client. Derived properties are non-enumerable. */ +export interface GenerateTextResult extends GenerateTextResultWire { + readonly output?: unknown + readonly finalStep: StepResult + readonly content: ContentPart[] + readonly text: string + readonly reasoning: ReasoningPart[] + readonly reasoningText?: string + readonly files: GeneratedFile[] + readonly sources: TypedSource[] + readonly toolCalls: TypedToolCall[] + readonly staticToolCalls: GenerateTextResult['toolCalls'] + readonly dynamicToolCalls: GenerateTextResult['toolCalls'] + readonly toolResults: TaggedToolResult[] + readonly staticToolResults: GenerateTextResult['toolResults'] + readonly dynamicToolResults: GenerateTextResult['toolResults'] + readonly finishReason: FinishReasonUnified + readonly rawFinishReason?: string | null + readonly usage: LanguageModelUsage + readonly warnings: Warning[] + readonly request: RequestInfo + readonly response: StepResponse + readonly providerMetadata?: StepResult['providerMetadata'] + readonly responseMessages: ModelMessage[] +} diff --git a/tools/aimux-codegen/src/emit/text_result/python.inc b/tools/aimux-codegen/src/emit/text_result/python.inc new file mode 100644 index 000000000..7d214b8e8 --- /dev/null +++ b/tools/aimux-codegen/src/emit/text_result/python.inc @@ -0,0 +1,99 @@ + + @property + def final_step(self) -> StepResult: + return self.steps[-1] + + @property + def text(self) -> str: + return "".join(part.text for part in self.final_step.content if isinstance(part, ContentPartText)) + + @property + def content(self) -> list[ContentPart]: + return [part for step in self.steps for part in step.content] + + @property + def reasoning(self) -> list[ContentPartReasoning | ContentPartReasoningFile]: + return [part for part in self.final_step.content + if isinstance(part, (ContentPartReasoning, ContentPartReasoningFile))] + + @property + def reasoning_text(self) -> Optional[str]: + return "".join(part.text for part in self.reasoning if isinstance(part, ContentPartReasoning)) or None + + @property + def files(self) -> list[GeneratedFile]: + return [part.file for part in self.content if isinstance(part, ContentPartFile)] + + @property + def sources(self) -> list[ContentPartSourceUrl | ContentPartSourceDocument]: + return [part for part in self.content if isinstance(part, (ContentPartSourceUrl, ContentPartSourceDocument))] + + @property + def tool_calls(self) -> list[ContentPartToolCall]: + return [part for part in self.content if isinstance(part, ContentPartToolCall)] + + @property + def static_tool_calls(self) -> list[ContentPartToolCall]: + return [part for part in self.tool_calls if part.dynamic is not True] + + @property + def dynamic_tool_calls(self) -> list[ContentPartToolCall]: + return [part for part in self.tool_calls if part.dynamic is True] + + @property + def tool_results(self) -> list[ContentPartToolResult]: + return [part for part in self.content if isinstance(part, ContentPartToolResult)] + + @property + def static_tool_results(self) -> list[ContentPartToolResult]: + return [part for part in self.tool_results if part.dynamic is not True] + + @property + def dynamic_tool_results(self) -> list[ContentPartToolResult]: + return [part for part in self.tool_results if part.dynamic is True] + + @property + def finish_reason(self) -> FinishReasonUnified: + return self.final_step.finish_reason + + @property + def raw_finish_reason(self) -> Optional[str]: + return self.final_step.raw_finish_reason + + @property + def usage(self) -> LanguageModelUsage: + return self.total_usage + + @property + def warnings(self) -> list[Warning]: + return [warning for step in self.steps for warning in step.warnings] + + @property + def request(self) -> RequestInfo: + return self.final_step.request + + @property + def response(self) -> StepResponse: + return self.final_step.response + + @property + def provider_metadata(self) -> Optional[dict[str, dict[str, Any]]]: + return self.final_step.provider_metadata + + @property + def response_messages(self) -> list[ModelMessage]: + return [message for step in self.steps for message in step.response.messages] + + @model_validator(mode="after") + def _validate_output_state(self) -> "GenerateTextResult": + if "output_value" in self.model_fields_set and self.output_parsed is False: + raise ValueError("GenerateTextResult cannot carry output when outputParsed is false") + return self + + @property + def output(self) -> Any: + if "output_value" in self.model_fields_set: + return self.output_value + if self.output_parsed is False: + return None + return self.text diff --git a/tools/aimux-codegen/src/emit/text_result/swift.inc b/tools/aimux-codegen/src/emit/text_result/swift.inc new file mode 100644 index 000000000..3480667e9 --- /dev/null +++ b/tools/aimux-codegen/src/emit/text_result/swift.inc @@ -0,0 +1,83 @@ +// Computed result properties are excluded from Codable. +extension GenerateTextResult { + public var finalStep: StepResult { steps[steps.count - 1] } + public var text: String { + finalStep.content.compactMap { part in + if case let .text(_, text) = part { return text } + return nil + }.joined() + } + public var content: [ContentPart] { steps.flatMap(\.content) } + public var reasoning: [ReasoningPart] { + finalStep.content.compactMap { + switch $0 { + case let .reasoning(metadata, text): .reasoning(providerMetadata: metadata, text: text) + case let .reasoningFile(file, metadata): .reasoningFile(file: file, providerMetadata: metadata) + default: nil + } + } + } + public var reasoningText: String? { + let text = reasoning.compactMap { part in + if case let .reasoning(_, text) = part { return text } + return nil + }.joined() + return text.isEmpty ? nil : text + } + public var files: [GeneratedFile] { + content.compactMap { + if case let .file(file, _) = $0 { return file } + return nil + } + } + public var sources: [TypedSource] { + content.compactMap { + switch $0 { + case let .sourceUrl(id, metadata, _, title, url): + .url(id: id, providerMetadata: metadata, title: title, type: "source", url: url) + case let .sourceDocument(filename, id, mediaType, metadata, _, title): + .document(filename: filename, id: id, mediaType: mediaType, + providerMetadata: metadata, title: title, type: "source") + default: nil + } + } + } + public var toolCalls: [TypedToolCall] { + content.compactMap { + guard case let .toolCall(dynamic, error, input, invalid, executed, metadata, id, name) = $0 else { + return nil + } + return TypedToolCall(dynamic: dynamic, error: error, input: input, invalid: invalid, + providerExecuted: executed, providerMetadata: metadata, + toolCallId: id, toolName: name, type: "tool-call") + } + } + public var staticToolCalls: [TypedToolCall] { toolCalls.filter { $0.dynamic != true } } + public var dynamicToolCalls: [TypedToolCall] { toolCalls.filter { $0.dynamic == true } } + public var toolResults: [TaggedToolResult] { + content.compactMap { + guard case let .toolResult(dynamic, input, output, preliminary, executed, metadata, id, name) = $0 else { + return nil + } + return TaggedToolResult(dynamic: dynamic, input: input, output: output, preliminary: preliminary, + providerExecuted: executed, providerMetadata: metadata, + toolCallId: id, toolName: name, type: "tool-result") + } + } + public var staticToolResults: [TaggedToolResult] { toolResults.filter { $0.dynamic != true } } + public var dynamicToolResults: [TaggedToolResult] { toolResults.filter { $0.dynamic == true } } + public var finishReason: FinishReasonUnified { finalStep.finishReason } + public var rawFinishReason: String? { finalStep.rawFinishReason } + public var usage: LanguageModelUsage { totalUsage } + public var warnings: [Warning] { steps.flatMap(\.warnings) } + public var request: RequestInfo { finalStep.request } + public var response: StepResponse { finalStep.response } + public var providerMetadata: [String: [String: JSONValue]]? { finalStep.providerMetadata } + public var responseMessages: [ModelMessage] { steps.flatMap { $0.response.messages } } + public var output: FieldPresence { + if case .missing = outputValue { + return outputParsed == false ? .missing : .value(.string(text)) + } + return outputValue + } +}