@opencode/ai 0.0.0-dev-1029 → 0.0.0-dev-1032

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/protocols/alibaba-chat.d.ts +4 -0
  2. package/dist/protocols/anthropic-messages.js +3 -3
  3. package/dist/protocols/open-responses.d.ts +1 -1
  4. package/dist/protocols/open-responses.js +31 -8
  5. package/dist/protocols/openai-chat.d.ts +24 -0
  6. package/dist/protocols/openai-chat.js +37 -11
  7. package/dist/protocols/openai-compatible-chat.d.ts +1 -0
  8. package/dist/protocols/shared.d.ts +13 -3
  9. package/dist/protocols/shared.js +27 -4
  10. package/dist/protocols/venice-chat.d.ts +4 -0
  11. package/dist/protocols/zai-chat.d.ts +4 -0
  12. package/dist/providers/alibaba.d.ts +1 -0
  13. package/dist/providers/amazon-bedrock-mantle.d.ts +1 -0
  14. package/dist/providers/azure.d.ts +1 -0
  15. package/dist/providers/baseten.d.ts +2 -0
  16. package/dist/providers/cerebras.d.ts +2 -0
  17. package/dist/providers/cloudflare-ai-gateway.d.ts +2 -0
  18. package/dist/providers/cloudflare-workers-ai.d.ts +2 -0
  19. package/dist/providers/cohere.d.ts +2 -0
  20. package/dist/providers/deepinfra.d.ts +2 -0
  21. package/dist/providers/deepseek.d.ts +2 -0
  22. package/dist/providers/digitalocean.d.ts +6 -0
  23. package/dist/providers/fireworks.d.ts +2 -0
  24. package/dist/providers/google-vertex-chat.d.ts +1 -0
  25. package/dist/providers/groq.d.ts +5 -0
  26. package/dist/providers/meta.d.ts +1 -0
  27. package/dist/providers/minimax.d.ts +1 -0
  28. package/dist/providers/moonshot.d.ts +1 -0
  29. package/dist/providers/openai-compatible.d.ts +1 -0
  30. package/dist/providers/openai.d.ts +1 -0
  31. package/dist/providers/openrouter.d.ts +7 -0
  32. package/dist/providers/togetherai.d.ts +2 -0
  33. package/dist/providers/venice.d.ts +1 -0
  34. package/dist/providers/xai.d.ts +1 -0
  35. package/dist/providers/zai-coding-plan.d.ts +1 -0
  36. package/dist/providers/zai.d.ts +1 -0
  37. package/package.json +3 -3
@@ -137,6 +137,7 @@ export declare const protocol: Protocol<{
137
137
  readonly reasoning?: string | undefined;
138
138
  readonly reasoning_text?: string | undefined;
139
139
  readonly reasoning_details?: unknown;
140
+ readonly reasoning_opaque?: string | undefined;
140
141
  })[];
141
142
  readonly tools?: readonly ({
142
143
  readonly type: "function";
@@ -243,6 +244,7 @@ export declare const protocol: Protocol<{
243
244
  readonly reasoning?: string | null | undefined;
244
245
  readonly reasoning_text?: string | null | undefined;
245
246
  readonly reasoning_details?: unknown;
247
+ readonly reasoning_opaque?: string | null | undefined;
246
248
  readonly tool_calls?: readonly {
247
249
  readonly index?: number | null | undefined;
248
250
  readonly id?: string | null | undefined;
@@ -268,6 +270,7 @@ export declare const protocol: Protocol<{
268
270
  readonly prompt_cache_hit_tokens?: number | null | undefined;
269
271
  readonly cache_read_input_tokens?: number | null | undefined;
270
272
  readonly cache_created_input_tokens?: number | null | undefined;
273
+ readonly reasoning_tokens?: number | null | undefined;
271
274
  readonly prompt_tokens_details?: {
272
275
  readonly [x: string]: unknown;
273
276
  readonly cached_tokens?: number | null | undefined;
@@ -290,6 +293,7 @@ export declare const protocol: Protocol<{
290
293
  readonly prompt_cache_hit_tokens?: number | null | undefined;
291
294
  readonly cache_read_input_tokens?: number | null | undefined;
292
295
  readonly cache_created_input_tokens?: number | null | undefined;
296
+ readonly reasoning_tokens?: number | null | undefined;
293
297
  readonly prompt_tokens_details?: {
294
298
  readonly [x: string]: unknown;
295
299
  readonly cached_tokens?: number | null | undefined;
@@ -878,7 +878,7 @@ const mapFinishReason = (reason) => {
878
878
  // inclusive `inputTokens` the rest of the contract expects. Extended
879
879
  // thinking tokens are included in `output_tokens`; newer responses also
880
880
  // expose that subset through `output_tokens_details.thinking_tokens`.
881
- const mapUsage = (usage, providerMetadataKey) => {
881
+ const mapUsage = (usage, providerMetadataKey, frame) => {
882
882
  if (!usage)
883
883
  return undefined;
884
884
  const iterations = usage.iterations?.length ? usage.iterations : [usage];
@@ -899,7 +899,7 @@ const mapUsage = (usage, providerMetadataKey) => {
899
899
  cacheWriteInputTokens: cacheWrite,
900
900
  reasoningTokens: ProviderShared.sumTokens(...iterations.map((item) => item.output_tokens_details?.thinking_tokens)),
901
901
  totalTokens: ProviderShared.totalTokens(inputTokens, outputTokens, undefined),
902
- ...ProviderShared.reportedBilling(usage),
902
+ ...ProviderShared.reportedBilling(usage, frame),
903
903
  providerMetadata: { [providerMetadataKey]: usage },
904
904
  });
905
905
  };
@@ -1128,7 +1128,7 @@ const onContentBlockStop = Effect.fnUntraced(function* (state, event) {
1128
1128
  return [{ ...state, lifecycle, tools: result.tools, reasoningSignatures }, events];
1129
1129
  });
1130
1130
  const onMessageDelta = (state, event) => {
1131
- const usage = mergeUsage(state.usage, mapUsage(event.usage, state.providerMetadataKey), state.providerMetadataKey);
1131
+ const usage = mergeUsage(state.usage, mapUsage(event.usage, state.providerMetadataKey, event), state.providerMetadataKey);
1132
1132
  const pendingFinish = (() => {
1133
1133
  const stopReason = event.delta?.stop_reason;
1134
1134
  if (stopReason === null || stopReason === undefined)
@@ -1566,7 +1566,7 @@ export declare const fromRequest: (request: LLMRequest) => Effect.Effect<{
1566
1566
  }[];
1567
1567
  } | undefined;
1568
1568
  }, AIError, never>;
1569
- export declare const mapUsage: (usage: OpenResponsesUsage | null | undefined, providerMetadataKey: string) => Usage | undefined;
1569
+ export declare const mapUsage: (usage: OpenResponsesUsage | null | undefined, providerMetadataKey: string, ...frames: ReadonlyArray<unknown>) => Usage | undefined;
1570
1570
  export declare const metadataKey: (model: LLMRequest["model"]) => string;
1571
1571
  export declare const providerMetadata: (state: ParserState, metadata: Record<string, unknown>) => ProviderMetadata;
1572
1572
  export type StepResult = readonly [ParserState, ReadonlyArray<LLMEvent>];
@@ -671,7 +671,7 @@ export const fromRequest = (request) => fromRequestWithAdapter(request, BASE_ADA
671
671
  // cached-read and cache-write subsets, and `output_tokens` (inclusive total)
672
672
  // with a `reasoning_tokens` subset. Pass the totals through and derive the
673
673
  // non-cached breakdown.
674
- export const mapUsage = (usage, providerMetadataKey) => {
674
+ export const mapUsage = (usage, providerMetadataKey, ...frames) => {
675
675
  if (!usage)
676
676
  return undefined;
677
677
  const cached = usage.input_tokens_details?.cached_tokens;
@@ -686,10 +686,29 @@ export const mapUsage = (usage, providerMetadataKey) => {
686
686
  cacheWriteInputTokens: cacheWrite,
687
687
  reasoningTokens: reasoning,
688
688
  totalTokens: ProviderShared.totalTokens(usage.input_tokens, usage.output_tokens, usage.total_tokens),
689
- ...ProviderShared.reportedBilling(usage),
689
+ ...ProviderShared.reportedBilling(usage, ...frames),
690
690
  providerMetadata: { [providerMetadataKey]: usage },
691
691
  });
692
692
  };
693
+ // GitHub Copilot lists the filters that ran; the blocking one names its rule in `content_filter_raw`.
694
+ const decodeContentFilters = Schema.decodeUnknownOption(Schema.Array(Schema.Struct({
695
+ source_type: Schema.optional(Schema.String),
696
+ blocked: Schema.optional(Schema.Boolean),
697
+ content_filter_raw: Schema.optional(Schema.Array(Schema.Struct({
698
+ action: Schema.optional(Schema.String),
699
+ label: Schema.optional(Schema.String),
700
+ result: Schema.optional(Schema.Unknown),
701
+ }))),
702
+ content_filter_results: Schema.optional(Schema.Unknown),
703
+ })));
704
+ const contentFilterCategory = (raw) => {
705
+ const blocked = Option.getOrElse(decodeContentFilters(raw), () => []).filter((filter) => filter.blocked);
706
+ const filter = blocked.find((item) => item.source_type === "completion") ?? blocked[0];
707
+ if (!filter)
708
+ return undefined;
709
+ return (filter.content_filter_raw?.find((rule) => rule.action === "BLOCK" && rule.result === true)?.label ??
710
+ ProviderShared.contentFilterCategory(filter.content_filter_results));
711
+ };
693
712
  const mapFinishReason = (event, hasFunctionCall) => {
694
713
  const reason = event.response?.incomplete_details?.reason;
695
714
  if (reason === undefined) {
@@ -749,12 +768,13 @@ const ITEM_ID_PREFIX = {
749
768
  custom_tool_call: "ctc",
750
769
  compaction: "cmp",
751
770
  };
752
- // An item without an id adopts the id already open in its output slot,
753
- // otherwise it gets a locally minted one.
771
+ // An item adopts the id already open in its output slot, since GitHub Copilot
772
+ // sends a different id on every event, including the item's own done event.
773
+ // Otherwise it keeps its id or gets a locally minted one.
754
774
  const resolveItem = (state, item, index) => ({
755
775
  ...item,
756
- id: item.id ??
757
- (index === undefined ? undefined : state.outputItems[index]) ??
776
+ id: (index === undefined ? undefined : state.outputItems[index]) ??
777
+ item.id ??
758
778
  `${ITEM_ID_PREFIX[item.type] ?? "item"}_${crypto.randomUUID().replaceAll("-", "")}`,
759
779
  });
760
780
  // Registered output slots are authoritative for `item_id` routing, and items
@@ -1128,12 +1148,15 @@ const onResponseFinish = Effect.fnUntraced(function* (state, event) {
1128
1148
  };
1129
1149
  events.push(...pending.events);
1130
1150
  }
1151
+ const normalized = mapFinishReason(event, current.hasFunctionCall);
1131
1152
  const lifecycle = Lifecycle.finish(current.lifecycle, events, {
1132
1153
  reason: {
1133
- normalized: mapFinishReason(event, current.hasFunctionCall),
1154
+ normalized,
1134
1155
  raw: event.response?.incomplete_details?.reason,
1156
+ ...(normalized === "content-filter" ? { category: contentFilterCategory(event.response?.content_filters) } : {}),
1135
1157
  },
1136
- usage: mapUsage(event.response?.usage, current.providerMetadataKey),
1158
+ // Copilot reports its billing on the terminal event, beside `response`.
1159
+ usage: mapUsage(event.response?.usage, current.providerMetadataKey, event, event.response),
1137
1160
  providerMetadata: event.response?.id || event.response?.service_tier
1138
1161
  ? providerMetadata(current, {
1139
1162
  responseId: event.response.id,
@@ -158,6 +158,7 @@ export declare const OpenAIChatMessage: Schema.toTaggedUnion<"role", readonly [S
158
158
  readonly reasoning: Schema.optional<Schema.String>;
159
159
  readonly reasoning_text: Schema.optional<Schema.String>;
160
160
  readonly reasoning_details: Schema.optional<Schema.Unknown>;
161
+ readonly reasoning_opaque: Schema.optional<Schema.String>;
161
162
  }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>, Schema.Struct<{
162
163
  readonly role: Schema.Literal<"tool">;
163
164
  readonly tool_call_id: Schema.String;
@@ -259,6 +260,7 @@ export declare const bodyFields: {
259
260
  readonly reasoning: Schema.optional<Schema.String>;
260
261
  readonly reasoning_text: Schema.optional<Schema.String>;
261
262
  readonly reasoning_details: Schema.optional<Schema.Unknown>;
263
+ readonly reasoning_opaque: Schema.optional<Schema.String>;
262
264
  }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>, Schema.Struct<{
263
265
  readonly role: Schema.Literal<"tool">;
264
266
  readonly tool_call_id: Schema.String;
@@ -428,6 +430,7 @@ declare const OpenAIChatBody: Schema.Struct<{
428
430
  readonly reasoning: Schema.optional<Schema.String>;
429
431
  readonly reasoning_text: Schema.optional<Schema.String>;
430
432
  readonly reasoning_details: Schema.optional<Schema.Unknown>;
433
+ readonly reasoning_opaque: Schema.optional<Schema.String>;
431
434
  }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>, Schema.Struct<{
432
435
  readonly role: Schema.Literal<"tool">;
433
436
  readonly tool_call_id: Schema.String;
@@ -518,6 +521,7 @@ export declare const OpenAIChatUsage: Schema.StructWithRest<Schema.Struct<{
518
521
  readonly prompt_cache_hit_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
519
522
  readonly cache_read_input_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
520
523
  readonly cache_created_input_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
524
+ readonly reasoning_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
521
525
  readonly prompt_tokens_details: Schema.optional<Schema.NullOr<Schema.StructWithRest<Schema.Struct<{
522
526
  readonly cached_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
523
527
  readonly cache_write_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
@@ -548,6 +552,7 @@ export declare const OpenAIChatDelta: Schema.StructWithRest<Schema.Struct<{
548
552
  readonly reasoning: Schema.optional<Schema.NullOr<Schema.String>>;
549
553
  readonly reasoning_text: Schema.optional<Schema.NullOr<Schema.String>>;
550
554
  readonly reasoning_details: Schema.optional<Schema.NullOr<Schema.Unknown>>;
555
+ readonly reasoning_opaque: Schema.optional<Schema.NullOr<Schema.String>>;
551
556
  readonly tool_calls: Schema.optional<Schema.NullOr<Schema.$Array<Schema.Struct<{
552
557
  readonly index: Schema.optional<Schema.NullOr<Schema.Number>>;
553
558
  readonly id: Schema.optional<Schema.NullOr<Schema.String>>;
@@ -570,6 +575,7 @@ export declare const OpenAIChatChoice: Schema.StructWithRest<Schema.Struct<{
570
575
  readonly reasoning: Schema.optional<Schema.NullOr<Schema.String>>;
571
576
  readonly reasoning_text: Schema.optional<Schema.NullOr<Schema.String>>;
572
577
  readonly reasoning_details: Schema.optional<Schema.NullOr<Schema.Unknown>>;
578
+ readonly reasoning_opaque: Schema.optional<Schema.NullOr<Schema.String>>;
573
579
  readonly tool_calls: Schema.optional<Schema.NullOr<Schema.$Array<Schema.Struct<{
574
580
  readonly index: Schema.optional<Schema.NullOr<Schema.Number>>;
575
581
  readonly id: Schema.optional<Schema.NullOr<Schema.String>>;
@@ -594,6 +600,7 @@ export declare const OpenAIChatChoice: Schema.StructWithRest<Schema.Struct<{
594
600
  readonly prompt_cache_hit_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
595
601
  readonly cache_read_input_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
596
602
  readonly cache_created_input_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
603
+ readonly reasoning_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
597
604
  readonly prompt_tokens_details: Schema.optional<Schema.NullOr<Schema.StructWithRest<Schema.Struct<{
598
605
  readonly cached_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
599
606
  readonly cache_write_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
@@ -614,6 +621,7 @@ export declare const OpenAIChatEvent: Schema.StructWithRest<Schema.Struct<{
614
621
  readonly reasoning: Schema.optional<Schema.NullOr<Schema.String>>;
615
622
  readonly reasoning_text: Schema.optional<Schema.NullOr<Schema.String>>;
616
623
  readonly reasoning_details: Schema.optional<Schema.NullOr<Schema.Unknown>>;
624
+ readonly reasoning_opaque: Schema.optional<Schema.NullOr<Schema.String>>;
617
625
  readonly tool_calls: Schema.optional<Schema.NullOr<Schema.$Array<Schema.Struct<{
618
626
  readonly index: Schema.optional<Schema.NullOr<Schema.Number>>;
619
627
  readonly id: Schema.optional<Schema.NullOr<Schema.String>>;
@@ -638,6 +646,7 @@ export declare const OpenAIChatEvent: Schema.StructWithRest<Schema.Struct<{
638
646
  readonly prompt_cache_hit_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
639
647
  readonly cache_read_input_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
640
648
  readonly cache_created_input_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
649
+ readonly reasoning_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
641
650
  readonly prompt_tokens_details: Schema.optional<Schema.NullOr<Schema.StructWithRest<Schema.Struct<{
642
651
  readonly cached_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
643
652
  readonly cache_write_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
@@ -657,6 +666,7 @@ export declare const OpenAIChatEvent: Schema.StructWithRest<Schema.Struct<{
657
666
  readonly prompt_cache_hit_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
658
667
  readonly cache_read_input_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
659
668
  readonly cache_created_input_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
669
+ readonly reasoning_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
660
670
  readonly prompt_tokens_details: Schema.optional<Schema.NullOr<Schema.StructWithRest<Schema.Struct<{
661
671
  readonly cached_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
662
672
  readonly cache_write_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
@@ -695,6 +705,8 @@ export interface ParserState {
695
705
  readonly reasoningTextObserved: boolean;
696
706
  readonly reasoningDetails: Array<ReasoningDetail>;
697
707
  readonly reasoningDetailsObserved: boolean;
708
+ /** Latest `reasoning_opaque`; interleaved reasoning sends a new one before each tool call. */
709
+ readonly reasoningOpaque?: string;
698
710
  readonly reasoningEmitted: boolean;
699
711
  readonly latestToolIndex?: number;
700
712
  readonly nextToolIndex: number;
@@ -820,6 +832,7 @@ export declare const fromRequest: (request: LLMRequest<import("../schema/options
820
832
  readonly reasoning?: string | undefined;
821
833
  readonly reasoning_text?: string | undefined;
822
834
  readonly reasoning_details?: unknown;
835
+ readonly reasoning_opaque?: string | undefined;
823
836
  })[];
824
837
  tools: ({
825
838
  readonly type: "function";
@@ -992,6 +1005,7 @@ export declare const fromRequest: (request: LLMRequest<import("../schema/options
992
1005
  readonly reasoning?: string | undefined;
993
1006
  readonly reasoning_text?: string | undefined;
994
1007
  readonly reasoning_details?: unknown;
1008
+ readonly reasoning_opaque?: string | undefined;
995
1009
  })[];
996
1010
  tools: ({
997
1011
  readonly type: "function";
@@ -1166,6 +1180,7 @@ export declare const fromRequest: (request: LLMRequest<import("../schema/options
1166
1180
  readonly reasoning?: string | undefined;
1167
1181
  readonly reasoning_text?: string | undefined;
1168
1182
  readonly reasoning_details?: unknown;
1183
+ readonly reasoning_opaque?: string | undefined;
1169
1184
  })[];
1170
1185
  tools: ({
1171
1186
  readonly type: "function";
@@ -1338,6 +1353,7 @@ export declare const fromRequest: (request: LLMRequest<import("../schema/options
1338
1353
  readonly reasoning?: string | undefined;
1339
1354
  readonly reasoning_text?: string | undefined;
1340
1355
  readonly reasoning_details?: unknown;
1356
+ readonly reasoning_opaque?: string | undefined;
1341
1357
  })[];
1342
1358
  tools: ({
1343
1359
  readonly type: "function";
@@ -1510,6 +1526,7 @@ export declare const fromRequest: (request: LLMRequest<import("../schema/options
1510
1526
  readonly reasoning?: string | undefined;
1511
1527
  readonly reasoning_text?: string | undefined;
1512
1528
  readonly reasoning_details?: unknown;
1529
+ readonly reasoning_opaque?: string | undefined;
1513
1530
  })[];
1514
1531
  tools: ({
1515
1532
  readonly type: "function";
@@ -1684,6 +1701,7 @@ export declare const fromRequest: (request: LLMRequest<import("../schema/options
1684
1701
  readonly reasoning?: string | undefined;
1685
1702
  readonly reasoning_text?: string | undefined;
1686
1703
  readonly reasoning_details?: unknown;
1704
+ readonly reasoning_opaque?: string | undefined;
1687
1705
  })[];
1688
1706
  tools: ({
1689
1707
  readonly type: "function";
@@ -2050,6 +2068,7 @@ export declare const protocol: Protocol<{
2050
2068
  readonly reasoning?: string | undefined;
2051
2069
  readonly reasoning_text?: string | undefined;
2052
2070
  readonly reasoning_details?: unknown;
2071
+ readonly reasoning_opaque?: string | undefined;
2053
2072
  })[];
2054
2073
  readonly tools?: readonly ({
2055
2074
  readonly type: "function";
@@ -2135,6 +2154,7 @@ export declare const protocol: Protocol<{
2135
2154
  readonly reasoning?: string | null | undefined;
2136
2155
  readonly reasoning_text?: string | null | undefined;
2137
2156
  readonly reasoning_details?: unknown;
2157
+ readonly reasoning_opaque?: string | null | undefined;
2138
2158
  readonly tool_calls?: readonly {
2139
2159
  readonly index?: number | null | undefined;
2140
2160
  readonly id?: string | null | undefined;
@@ -2160,6 +2180,7 @@ export declare const protocol: Protocol<{
2160
2180
  readonly prompt_cache_hit_tokens?: number | null | undefined;
2161
2181
  readonly cache_read_input_tokens?: number | null | undefined;
2162
2182
  readonly cache_created_input_tokens?: number | null | undefined;
2183
+ readonly reasoning_tokens?: number | null | undefined;
2163
2184
  readonly prompt_tokens_details?: {
2164
2185
  readonly [x: string]: unknown;
2165
2186
  readonly cached_tokens?: number | null | undefined;
@@ -2182,6 +2203,7 @@ export declare const protocol: Protocol<{
2182
2203
  readonly prompt_cache_hit_tokens?: number | null | undefined;
2183
2204
  readonly cache_read_input_tokens?: number | null | undefined;
2184
2205
  readonly cache_created_input_tokens?: number | null | undefined;
2206
+ readonly reasoning_tokens?: number | null | undefined;
2185
2207
  readonly prompt_tokens_details?: {
2186
2208
  readonly [x: string]: unknown;
2187
2209
  readonly cached_tokens?: number | null | undefined;
@@ -2301,6 +2323,7 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
2301
2323
  readonly reasoning?: string | undefined;
2302
2324
  readonly reasoning_text?: string | undefined;
2303
2325
  readonly reasoning_details?: unknown;
2326
+ readonly reasoning_opaque?: string | undefined;
2304
2327
  })[];
2305
2328
  readonly tools?: readonly ({
2306
2329
  readonly type: "function";
@@ -2475,6 +2498,7 @@ export declare const route: Route<{
2475
2498
  readonly reasoning?: string | undefined;
2476
2499
  readonly reasoning_text?: string | undefined;
2477
2500
  readonly reasoning_details?: unknown;
2501
+ readonly reasoning_opaque?: string | undefined;
2478
2502
  })[];
2479
2503
  readonly tools?: readonly ({
2480
2504
  readonly type: "function";
@@ -148,6 +148,7 @@ export const OpenAIChatMessage = Schema.Union([
148
148
  reasoning: Schema.optional(Schema.String),
149
149
  reasoning_text: Schema.optional(Schema.String),
150
150
  reasoning_details: Schema.optional(Schema.Unknown),
151
+ reasoning_opaque: Schema.optional(Schema.String),
151
152
  }), [Schema.Record(Schema.String, Schema.Unknown)]),
152
153
  Schema.Struct({
153
154
  role: Schema.Literal("tool"),
@@ -209,6 +210,8 @@ export const OpenAIChatUsage = Schema.StructWithRest(Schema.Struct({
209
210
  prompt_cache_hit_tokens: optionalNull(Schema.Number),
210
211
  cache_read_input_tokens: optionalNull(Schema.Number),
211
212
  cache_created_input_tokens: optionalNull(Schema.Number),
213
+ // GitHub Copilot reports reasoning at the top level instead of in `completion_tokens_details`.
214
+ reasoning_tokens: optionalNull(Schema.Number),
212
215
  prompt_tokens_details: optionalNull(Schema.StructWithRest(Schema.Struct({
213
216
  cached_tokens: optionalNull(Schema.Number),
214
217
  cache_write_tokens: optionalNull(Schema.Number),
@@ -237,6 +240,8 @@ export const OpenAIChatDelta = Schema.StructWithRest(Schema.Struct({
237
240
  reasoning: optionalNull(Schema.String),
238
241
  reasoning_text: optionalNull(Schema.String),
239
242
  reasoning_details: optionalNull(Schema.Unknown),
243
+ // GitHub Copilot's opaque reasoning state, which must be replayed for multi-turn reasoning.
244
+ reasoning_opaque: optionalNull(Schema.String),
240
245
  tool_calls: optionalNull(Schema.Array(OpenAIChatToolCallDelta)),
241
246
  }), [Schema.Record(Schema.String, Schema.Unknown)]);
242
247
  export const OpenAIChatChoice = Schema.StructWithRest(Schema.Struct({
@@ -346,6 +351,11 @@ const lowerReasoningDetail = (detail) => {
346
351
  return { type: detail.type, encrypted: detail.encrypted };
347
352
  return detail;
348
353
  };
354
+ // Interleaved reasoning yields one opaque value per segment; like the Copilot VS Code
355
+ // client, replay the latest one with the concatenated reasoning text.
356
+ const reasoningOpaque = (parts, providerMetadataKey) => parts
357
+ .map((part) => part.providerMetadata?.[providerMetadataKey]?.reasoningOpaque)
358
+ .findLast((value) => typeof value === "string");
349
359
  const isKimiDetail = (detail) => detail.type === "summary" || detail.type === "encrypted";
350
360
  const lowerUserMessage = Effect.fnUntraced(function* (message, options) {
351
361
  const content = [];
@@ -406,7 +416,8 @@ const lowerAssistantMessage = Effect.fnUntraced(function* (message, configuredFi
406
416
  if (details?.some(isKimiDetail))
407
417
  return "reasoning_content";
408
418
  })();
409
- const reasoningText = reasoning.length === 0 ? (requireReasoning ? "" : undefined) : text;
419
+ const opaque = reasoningOpaque(reasoning, options.providerMetadataKey);
420
+ const reasoningText = reasoning.length === 0 || (opaque !== undefined && text === "") ? (requireReasoning ? "" : undefined) : text;
410
421
  const result = {
411
422
  role: "assistant",
412
423
  content: (() => {
@@ -418,6 +429,7 @@ const lowerAssistantMessage = Effect.fnUntraced(function* (message, configuredFi
418
429
  })(),
419
430
  ...(toolCalls.length > 0 ? { tool_calls: toolCalls } : {}),
420
431
  ...(details !== undefined ? { reasoning_details: details } : {}),
432
+ ...(opaque !== undefined ? { reasoning_opaque: opaque } : {}),
421
433
  };
422
434
  if (field === undefined || reasoningText === undefined)
423
435
  return result;
@@ -749,18 +761,24 @@ const mapFinishReason = Effect.fnUntraced(function* (event, reason) {
749
761
  // `prompt_tokens_details.cached_tokens`, DeepSeek uses
750
762
  // `prompt_cache_hit_tokens`, Zai uses top-level `cached_tokens`, and
751
763
  // DigitalOcean uses top-level `cache_read_input_tokens` / `cache_created_input_tokens`.
752
- const mapUsage = (usage, providerMetadataKey) => {
764
+ const mapUsage = (usage, providerMetadataKey, frame) => {
753
765
  if (!usage)
754
766
  return undefined;
755
767
  const input = usage.prompt_tokens ?? undefined;
756
- const output = usage.completion_tokens ?? undefined;
768
+ const completion = usage.completion_tokens ?? undefined;
757
769
  const cached = usage.prompt_tokens_details?.cached_tokens ??
758
770
  usage.prompt_cache_hit_tokens ??
759
771
  usage.cached_tokens ??
760
772
  usage.cache_read_input_tokens ??
761
773
  undefined;
762
774
  const cacheWrite = usage.prompt_tokens_details?.cache_write_tokens ?? usage.cache_created_input_tokens ?? undefined;
763
- const reasoning = usage.completion_tokens_details?.reasoning_tokens ?? undefined;
775
+ const reasoning = usage.completion_tokens_details?.reasoning_tokens ?? usage.reasoning_tokens ?? undefined;
776
+ // Copilot's Gemini counts reasoning beside `completion_tokens` rather than inside it; the total tells which.
777
+ const output = completion !== undefined &&
778
+ reasoning !== undefined &&
779
+ usage.total_tokens === ProviderShared.sumTokens(input, completion, reasoning)
780
+ ? completion + reasoning
781
+ : completion;
764
782
  const nonCached = ProviderShared.subtractTokens(input, ProviderShared.sumTokens(cached, cacheWrite));
765
783
  return new Usage({
766
784
  inputTokens: input,
@@ -770,7 +788,7 @@ const mapUsage = (usage, providerMetadataKey) => {
770
788
  cacheWriteInputTokens: cacheWrite,
771
789
  reasoningTokens: reasoning,
772
790
  totalTokens: ProviderShared.totalTokens(input, output, usage.total_tokens ?? undefined),
773
- ...ProviderShared.reportedBilling(usage),
791
+ ...ProviderShared.reportedBilling(usage, frame),
774
792
  providerMetadata: { [providerMetadataKey]: usage },
775
793
  });
776
794
  };
@@ -857,10 +875,11 @@ const conflictingReasoningDetails = (previous, current) => conflictingDetailValu
857
875
  conflictingDetailValue(previous.format, current.format) ||
858
876
  (Boolean(previous.signature) && Boolean(current.signature) && previous.signature !== current.signature);
859
877
  const conflictingDetailValue = (previous, current) => previous !== undefined && previous !== null && current !== undefined && current !== null && previous !== current;
860
- const reasoningMetadata = (providerMetadataKey, field, details) => ({
878
+ const reasoningMetadata = (providerMetadataKey, field, details, opaque) => ({
861
879
  [providerMetadataKey]: {
862
880
  ...(field ? { reasoningField: field } : {}),
863
881
  ...(details ? { reasoningDetails: details } : {}),
882
+ ...(opaque ? { reasoningOpaque: opaque } : {}),
864
883
  },
865
884
  });
866
885
  const step = (state, event) => Effect.gen(function* () {
@@ -878,14 +897,19 @@ const step = (state, event) => Effect.gen(function* () {
878
897
  const choice = event.choices?.[0];
879
898
  // Moonshot (and a few other OpenAI-compatible providers) attach usage to
880
899
  // `choice.usage` instead of the top-level `usage` field.
881
- const usage = mapUsage(event.usage, state.providerMetadataKey) ??
882
- mapUsage(choice?.usage, state.providerMetadataKey) ??
900
+ const usage = mapUsage(event.usage, state.providerMetadataKey, event) ??
901
+ mapUsage(choice?.usage, state.providerMetadataKey, event) ??
883
902
  state.usage;
884
903
  const rawFinishReason = choice?.finish_reason;
885
904
  const finishReason = rawFinishReason
886
905
  ? {
887
906
  normalized: yield* mapFinishReason(event, rawFinishReason),
888
907
  raw: choice?.native_finish_reason ?? rawFinishReason,
908
+ ...(rawFinishReason === "content_filter"
909
+ ? {
910
+ category: ProviderShared.contentFilterCategory(choice?.delta?.copilot_annotations, choice?.content_filter_results),
911
+ }
912
+ : {}),
889
913
  }
890
914
  : state.finishReason;
891
915
  const delta = choice?.delta;
@@ -911,13 +935,14 @@ const step = (state, event) => Effect.gen(function* () {
911
935
  if (detailDelta !== undefined)
912
936
  appendReasoningDetails(state.reasoningDetails, detailDelta);
913
937
  const reasoningDetailsObserved = state.reasoningDetailsObserved || detailDelta !== undefined;
938
+ const reasoningOpaque = delta?.reasoning_opaque || state.reasoningOpaque;
914
939
  const deltaMetadata = reasoningMetadata(state.providerMetadataKey, reasoningField);
915
940
  const text = detailDelta?.length
916
941
  ? (detailText(detailDelta, reasoningTextObserved) ?? reasoning?.text)
917
942
  : reasoning?.text;
918
943
  if (text !== undefined)
919
944
  lifecycle = Lifecycle.reasoningDelta(lifecycle, events, "reasoning-0", text, deltaMetadata);
920
- else if (reasoningDetailsObserved &&
945
+ else if ((reasoningDetailsObserved || reasoningOpaque !== undefined) &&
921
946
  !lifecycle.reasoning.has("reasoning-0") &&
922
947
  (Boolean(delta?.content) || Boolean(delta?.refusal) || toolDeltas.length > 0))
923
948
  lifecycle = Lifecycle.reasoningStart(lifecycle, events, "reasoning-0", deltaMetadata);
@@ -1013,6 +1038,7 @@ const step = (state, event) => Effect.gen(function* () {
1013
1038
  reasoningTextObserved,
1014
1039
  reasoningDetails: state.reasoningDetails,
1015
1040
  reasoningDetailsObserved,
1041
+ reasoningOpaque,
1016
1042
  reasoningEmitted,
1017
1043
  latestToolIndex,
1018
1044
  nextToolIndex,
@@ -1049,8 +1075,8 @@ export const finishEvents = Effect.fnUntraced(function* (state) {
1049
1075
  : { normalized: hasToolCalls ? "tool-calls" : "stop" };
1050
1076
  // Snapshot details at publish time so the emitted event never observes later
1051
1077
  // mutation of the accumulated `reasoningDetails` array.
1052
- const metadata = reasoningMetadata(state.providerMetadataKey, state.reasoningField, state.reasoningDetailsObserved ? [...state.reasoningDetails] : undefined);
1053
- const started = state.reasoningDetailsObserved && !state.reasoningEmitted
1078
+ const metadata = reasoningMetadata(state.providerMetadataKey, state.reasoningField, state.reasoningDetailsObserved ? [...state.reasoningDetails] : undefined, state.reasoningOpaque);
1079
+ const started = (state.reasoningDetailsObserved || state.reasoningOpaque !== undefined) && !state.reasoningEmitted
1054
1080
  ? Lifecycle.reasoningStart(state.lifecycle, events, "reasoning-0", reasoningMetadata(state.providerMetadataKey, state.reasoningField))
1055
1081
  : state.lifecycle;
1056
1082
  const ended = Lifecycle.reasoningEnd(started, events, "reasoning-0", metadata);
@@ -106,6 +106,7 @@ export declare const route: Route<{
106
106
  readonly reasoning?: string | undefined;
107
107
  readonly reasoning_text?: string | undefined;
108
108
  readonly reasoning_details?: unknown;
109
+ readonly reasoning_opaque?: string | undefined;
109
110
  })[];
110
111
  readonly tools?: readonly ({
111
112
  readonly type: "function";
@@ -17,10 +17,20 @@ export declare const lenient: <const S extends Schema.Top>(schema: S) => Schema.
17
17
  export declare const ReportedBilling: Schema.Struct<{
18
18
  readonly cost: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Finite>, never>>;
19
19
  }>;
20
- /** Reads `ReportedBilling` from a raw usage object, which provider metadata keeps as the endpoint sent it. */
21
- export declare const reportedBilling: (usage: unknown) => {} | {
22
- cost: number | undefined;
20
+ /**
21
+ * Reads `ReportedBilling` from a raw usage object, which provider metadata keeps as the endpoint sent it, or
22
+ * Copilot's billing from the frames that carry the usage.
23
+ */
24
+ export declare const reportedBilling: (usage: unknown, ...frames: ReadonlyArray<unknown>) => {
25
+ cost: number;
26
+ } | {
27
+ cost?: undefined;
23
28
  };
29
+ /**
30
+ * The filter that blocked a response, from maps keyed by filter name: Azure's `content_filter_results`
31
+ * (`{ hate: { filtered: true } }`) or GitHub Copilot's `copilot_annotations` (`{ TextCopyright: [...] }`).
32
+ */
33
+ export declare const contentFilterCategory: (...sources: ReadonlyArray<unknown>) => string | undefined;
24
34
  /**
25
35
  * Accepts stream frames that carry no `type`, alongside the typed event schema. Gateways inject such frames as
26
36
  * keep-alives, so they decode as an ignored event; one with an `error` still decodes as an error event.
@@ -23,11 +23,34 @@ const billedAmount = lenient(Schema.Finite.check(Schema.isGreaterThanOrEqualTo(0
23
23
  export const ReportedBilling = Schema.Struct({
24
24
  cost: billedAmount,
25
25
  });
26
- /** Reads `ReportedBilling` from a raw usage object, which provider metadata keeps as the endpoint sent it. */
27
- export const reportedBilling = (usage) => Option.match(Schema.decodeUnknownOption(ReportedBilling)(usage), {
28
- onNone: () => ({}),
29
- onSome: (billing) => ({ cost: billing.cost }),
26
+ /**
27
+ * GitHub Copilot reports its charge beside usage on the frame that carries it, as `copilot_usage.total_nano_aiu`:
28
+ * billionths of an AI credit, which costs $0.01.
29
+ */
30
+ const CopilotBilling = Schema.Struct({
31
+ copilot_usage: Schema.Struct({ total_nano_aiu: Schema.Finite.check(Schema.isGreaterThanOrEqualTo(0)) }),
30
32
  });
33
+ const decodeCopilotBilling = Schema.decodeUnknownOption(CopilotBilling);
34
+ /**
35
+ * Reads `ReportedBilling` from a raw usage object, which provider metadata keeps as the endpoint sent it, or
36
+ * Copilot's billing from the frames that carry the usage.
37
+ */
38
+ export const reportedBilling = (usage, ...frames) => {
39
+ const reported = Option.getOrUndefined(Schema.decodeUnknownOption(ReportedBilling)(usage))?.cost;
40
+ if (reported !== undefined)
41
+ return { cost: reported };
42
+ const nanoAiu = frames
43
+ .map((frame) => Option.getOrUndefined(decodeCopilotBilling(frame))?.copilot_usage.total_nano_aiu)
44
+ .find((value) => value !== undefined);
45
+ return nanoAiu === undefined ? {} : { cost: nanoAiu / 100_000_000_000 };
46
+ };
47
+ /**
48
+ * The filter that blocked a response, from maps keyed by filter name: Azure's `content_filter_results`
49
+ * (`{ hate: { filtered: true } }`) or GitHub Copilot's `copilot_annotations` (`{ TextCopyright: [...] }`).
50
+ */
51
+ export const contentFilterCategory = (...sources) => sources
52
+ .flatMap((source) => (isRecord(source) ? Object.entries(source) : []))
53
+ .find(([, value]) => (isRecord(value) && "filtered" in value ? value.filtered === true : Boolean(value)))?.[0];
31
54
  /**
32
55
  * Accepts stream frames that carry no `type`, alongside the typed event schema. Gateways inject such frames as
33
56
  * keep-alives, so they decode as an ignored event; one with an `error` still decodes as an error event.
@@ -202,6 +202,7 @@ export declare const protocol: Protocol<{
202
202
  readonly reasoning?: string | undefined;
203
203
  readonly reasoning_text?: string | undefined;
204
204
  readonly reasoning_details?: unknown;
205
+ readonly reasoning_opaque?: string | undefined;
205
206
  readonly tool_calls?: readonly ({
206
207
  readonly id: string;
207
208
  readonly type: "custom";
@@ -262,6 +263,7 @@ export declare const protocol: Protocol<{
262
263
  readonly prompt_cache_hit_tokens?: number | null | undefined;
263
264
  readonly cache_read_input_tokens?: number | null | undefined;
264
265
  readonly cache_created_input_tokens?: number | null | undefined;
266
+ readonly reasoning_tokens?: number | null | undefined;
265
267
  readonly prompt_tokens_details?: {
266
268
  readonly [x: string]: unknown;
267
269
  readonly cached_tokens?: number | null | undefined;
@@ -282,6 +284,7 @@ export declare const protocol: Protocol<{
282
284
  readonly reasoning?: string | null | undefined;
283
285
  readonly reasoning_text?: string | null | undefined;
284
286
  readonly reasoning_details?: unknown;
287
+ readonly reasoning_opaque?: string | null | undefined;
285
288
  readonly tool_calls?: readonly {
286
289
  readonly index?: number | null | undefined;
287
290
  readonly id?: string | null | undefined;
@@ -308,6 +311,7 @@ export declare const protocol: Protocol<{
308
311
  readonly prompt_cache_hit_tokens?: number | null | undefined;
309
312
  readonly cache_read_input_tokens?: number | null | undefined;
310
313
  readonly cache_created_input_tokens?: number | null | undefined;
314
+ readonly reasoning_tokens?: number | null | undefined;
311
315
  readonly completion_tokens_details?: {
312
316
  readonly [x: string]: unknown;
313
317
  readonly reasoning_tokens?: number | null | undefined;
@@ -129,6 +129,7 @@ export declare const protocol: Protocol<{
129
129
  readonly reasoning?: string | undefined;
130
130
  readonly reasoning_text?: string | undefined;
131
131
  readonly reasoning_details?: unknown;
132
+ readonly reasoning_opaque?: string | undefined;
132
133
  })[];
133
134
  readonly tools?: readonly ({
134
135
  readonly type: "function";
@@ -224,6 +225,7 @@ export declare const protocol: Protocol<{
224
225
  readonly reasoning?: string | null | undefined;
225
226
  readonly reasoning_text?: string | null | undefined;
226
227
  readonly reasoning_details?: unknown;
228
+ readonly reasoning_opaque?: string | null | undefined;
227
229
  readonly tool_calls?: readonly {
228
230
  readonly index?: number | null | undefined;
229
231
  readonly id?: string | null | undefined;
@@ -249,6 +251,7 @@ export declare const protocol: Protocol<{
249
251
  readonly prompt_cache_hit_tokens?: number | null | undefined;
250
252
  readonly cache_read_input_tokens?: number | null | undefined;
251
253
  readonly cache_created_input_tokens?: number | null | undefined;
254
+ readonly reasoning_tokens?: number | null | undefined;
252
255
  readonly prompt_tokens_details?: {
253
256
  readonly [x: string]: unknown;
254
257
  readonly cached_tokens?: number | null | undefined;
@@ -271,6 +274,7 @@ export declare const protocol: Protocol<{
271
274
  readonly prompt_cache_hit_tokens?: number | null | undefined;
272
275
  readonly cache_read_input_tokens?: number | null | undefined;
273
276
  readonly cache_created_input_tokens?: number | null | undefined;
277
+ readonly reasoning_tokens?: number | null | undefined;
274
278
  readonly prompt_tokens_details?: {
275
279
  readonly [x: string]: unknown;
276
280
  readonly cached_tokens?: number | null | undefined;
@@ -124,6 +124,7 @@ export declare const routes: (Route<{
124
124
  readonly reasoning?: string | undefined;
125
125
  readonly reasoning_text?: string | undefined;
126
126
  readonly reasoning_details?: unknown;
127
+ readonly reasoning_opaque?: string | undefined;
127
128
  })[];
128
129
  readonly tools?: readonly ({
129
130
  readonly type: "function";
@@ -641,6 +641,7 @@ export declare const routes: (Route<{
641
641
  readonly reasoning?: string | undefined;
642
642
  readonly reasoning_text?: string | undefined;
643
643
  readonly reasoning_details?: unknown;
644
+ readonly reasoning_opaque?: string | undefined;
644
645
  })[];
645
646
  readonly tools?: readonly ({
646
647
  readonly type: "function";
@@ -661,6 +661,7 @@ export declare const routes: (Route<{
661
661
  readonly reasoning?: string | undefined;
662
662
  readonly reasoning_text?: string | undefined;
663
663
  readonly reasoning_details?: unknown;
664
+ readonly reasoning_opaque?: string | undefined;
664
665
  })[];
665
666
  readonly tools?: readonly ({
666
667
  readonly type: "function";
@@ -116,6 +116,7 @@ export declare const route: Route<{
116
116
  readonly reasoning?: string | undefined;
117
117
  readonly reasoning_text?: string | undefined;
118
118
  readonly reasoning_details?: unknown;
119
+ readonly reasoning_opaque?: string | undefined;
119
120
  })[];
120
121
  readonly tools?: readonly ({
121
122
  readonly type: "function";
@@ -290,6 +291,7 @@ export declare const routes: Route<{
290
291
  readonly reasoning?: string | undefined;
291
292
  readonly reasoning_text?: string | undefined;
292
293
  readonly reasoning_details?: unknown;
294
+ readonly reasoning_opaque?: string | undefined;
293
295
  })[];
294
296
  readonly tools?: readonly ({
295
297
  readonly type: "function";
@@ -112,6 +112,7 @@ export declare const route: Route<{
112
112
  readonly reasoning?: string | undefined;
113
113
  readonly reasoning_text?: string | undefined;
114
114
  readonly reasoning_details?: unknown;
115
+ readonly reasoning_opaque?: string | undefined;
115
116
  })[];
116
117
  readonly tools?: readonly ({
117
118
  readonly type: "function";
@@ -286,6 +287,7 @@ export declare const routes: Route<{
286
287
  readonly reasoning?: string | undefined;
287
288
  readonly reasoning_text?: string | undefined;
288
289
  readonly reasoning_details?: unknown;
290
+ readonly reasoning_opaque?: string | undefined;
289
291
  })[];
290
292
  readonly tools?: readonly ({
291
293
  readonly type: "function";
@@ -669,6 +669,7 @@ export declare const route: import("../route.js").Route<{
669
669
  readonly reasoning?: string | undefined;
670
670
  readonly reasoning_text?: string | undefined;
671
671
  readonly reasoning_details?: unknown;
672
+ readonly reasoning_opaque?: string | undefined;
672
673
  })[];
673
674
  readonly tools?: readonly ({
674
675
  readonly type: "function";
@@ -1150,6 +1151,7 @@ export declare const routes: (import("../route.js").Route<{
1150
1151
  readonly reasoning?: string | undefined;
1151
1152
  readonly reasoning_text?: string | undefined;
1152
1153
  readonly reasoning_details?: unknown;
1154
+ readonly reasoning_opaque?: string | undefined;
1153
1155
  })[];
1154
1156
  readonly tools?: readonly ({
1155
1157
  readonly type: "function";
@@ -119,6 +119,7 @@ export declare const route: Route<{
119
119
  readonly reasoning?: string | undefined;
120
120
  readonly reasoning_text?: string | undefined;
121
121
  readonly reasoning_details?: unknown;
122
+ readonly reasoning_opaque?: string | undefined;
122
123
  })[];
123
124
  readonly tools?: readonly ({
124
125
  readonly type: "function";
@@ -293,6 +294,7 @@ export declare const routes: Route<{
293
294
  readonly reasoning?: string | undefined;
294
295
  readonly reasoning_text?: string | undefined;
295
296
  readonly reasoning_details?: unknown;
297
+ readonly reasoning_opaque?: string | undefined;
296
298
  })[];
297
299
  readonly tools?: readonly ({
298
300
  readonly type: "function";
@@ -168,6 +168,7 @@ export declare const chatRoute: Route<{
168
168
  readonly reasoning?: string | undefined;
169
169
  readonly reasoning_text?: string | undefined;
170
170
  readonly reasoning_details?: unknown;
171
+ readonly reasoning_opaque?: string | undefined;
171
172
  })[];
172
173
  readonly tools?: readonly ({
173
174
  readonly type: "function";
@@ -393,6 +394,7 @@ export declare const routes: (Route<{
393
394
  readonly reasoning?: string | undefined;
394
395
  readonly reasoning_text?: string | undefined;
395
396
  readonly reasoning_details?: unknown;
397
+ readonly reasoning_opaque?: string | undefined;
396
398
  })[];
397
399
  readonly tools?: readonly ({
398
400
  readonly type: "function";
@@ -112,6 +112,7 @@ export declare const route: Route<{
112
112
  readonly reasoning?: string | undefined;
113
113
  readonly reasoning_text?: string | undefined;
114
114
  readonly reasoning_details?: unknown;
115
+ readonly reasoning_opaque?: string | undefined;
115
116
  })[];
116
117
  readonly tools?: readonly ({
117
118
  readonly type: "function";
@@ -286,6 +287,7 @@ export declare const routes: Route<{
286
287
  readonly reasoning?: string | undefined;
287
288
  readonly reasoning_text?: string | undefined;
288
289
  readonly reasoning_details?: unknown;
290
+ readonly reasoning_opaque?: string | undefined;
289
291
  })[];
290
292
  readonly tools?: readonly ({
291
293
  readonly type: "function";
@@ -112,6 +112,7 @@ export declare const route: Route<{
112
112
  readonly reasoning?: string | undefined;
113
113
  readonly reasoning_text?: string | undefined;
114
114
  readonly reasoning_details?: unknown;
115
+ readonly reasoning_opaque?: string | undefined;
115
116
  })[];
116
117
  readonly tools?: readonly ({
117
118
  readonly type: "function";
@@ -286,6 +287,7 @@ export declare const routes: Route<{
286
287
  readonly reasoning?: string | undefined;
287
288
  readonly reasoning_text?: string | undefined;
288
289
  readonly reasoning_details?: unknown;
290
+ readonly reasoning_opaque?: string | undefined;
289
291
  })[];
290
292
  readonly tools?: readonly ({
291
293
  readonly type: "function";
@@ -114,6 +114,7 @@ export declare const protocol: Protocol<{
114
114
  readonly reasoning?: string | undefined;
115
115
  readonly reasoning_text?: string | undefined;
116
116
  readonly reasoning_details?: unknown;
117
+ readonly reasoning_opaque?: string | undefined;
117
118
  })[];
118
119
  readonly tools?: readonly ({
119
120
  readonly type: "function";
@@ -199,6 +200,7 @@ export declare const protocol: Protocol<{
199
200
  readonly reasoning?: string | null | undefined;
200
201
  readonly reasoning_text?: string | null | undefined;
201
202
  readonly reasoning_details?: unknown;
203
+ readonly reasoning_opaque?: string | null | undefined;
202
204
  readonly tool_calls?: readonly {
203
205
  readonly index?: number | null | undefined;
204
206
  readonly id?: string | null | undefined;
@@ -224,6 +226,7 @@ export declare const protocol: Protocol<{
224
226
  readonly prompt_cache_hit_tokens?: number | null | undefined;
225
227
  readonly cache_read_input_tokens?: number | null | undefined;
226
228
  readonly cache_created_input_tokens?: number | null | undefined;
229
+ readonly reasoning_tokens?: number | null | undefined;
227
230
  readonly prompt_tokens_details?: {
228
231
  readonly [x: string]: unknown;
229
232
  readonly cached_tokens?: number | null | undefined;
@@ -246,6 +249,7 @@ export declare const protocol: Protocol<{
246
249
  readonly prompt_cache_hit_tokens?: number | null | undefined;
247
250
  readonly cache_read_input_tokens?: number | null | undefined;
248
251
  readonly cache_created_input_tokens?: number | null | undefined;
252
+ readonly reasoning_tokens?: number | null | undefined;
249
253
  readonly prompt_tokens_details?: {
250
254
  readonly [x: string]: unknown;
251
255
  readonly cached_tokens?: number | null | undefined;
@@ -364,6 +368,7 @@ export declare const route: Route<{
364
368
  readonly reasoning?: string | undefined;
365
369
  readonly reasoning_text?: string | undefined;
366
370
  readonly reasoning_details?: unknown;
371
+ readonly reasoning_opaque?: string | undefined;
367
372
  })[];
368
373
  readonly tools?: readonly ({
369
374
  readonly type: "function";
@@ -735,6 +740,7 @@ export declare const routes: (Route<{
735
740
  readonly reasoning?: string | undefined;
736
741
  readonly reasoning_text?: string | undefined;
737
742
  readonly reasoning_details?: unknown;
743
+ readonly reasoning_opaque?: string | undefined;
738
744
  })[];
739
745
  readonly tools?: readonly ({
740
746
  readonly type: "function";
@@ -112,6 +112,7 @@ export declare const route: Route<{
112
112
  readonly reasoning?: string | undefined;
113
113
  readonly reasoning_text?: string | undefined;
114
114
  readonly reasoning_details?: unknown;
115
+ readonly reasoning_opaque?: string | undefined;
115
116
  })[];
116
117
  readonly tools?: readonly ({
117
118
  readonly type: "function";
@@ -286,6 +287,7 @@ export declare const routes: Route<{
286
287
  readonly reasoning?: string | undefined;
287
288
  readonly reasoning_text?: string | undefined;
288
289
  readonly reasoning_details?: unknown;
290
+ readonly reasoning_opaque?: string | undefined;
289
291
  })[];
290
292
  readonly tools?: readonly ({
291
293
  readonly type: "function";
@@ -117,6 +117,7 @@ export declare const routes: Route<{
117
117
  readonly reasoning?: string | undefined;
118
118
  readonly reasoning_text?: string | undefined;
119
119
  readonly reasoning_details?: unknown;
120
+ readonly reasoning_opaque?: string | undefined;
120
121
  })[];
121
122
  readonly tools?: readonly ({
122
123
  readonly type: "function";
@@ -121,6 +121,7 @@ export declare const protocol: Protocol<{
121
121
  readonly reasoning?: string | undefined;
122
122
  readonly reasoning_text?: string | undefined;
123
123
  readonly reasoning_details?: unknown;
124
+ readonly reasoning_opaque?: string | undefined;
124
125
  })[];
125
126
  readonly tools?: readonly ({
126
127
  readonly type: "function";
@@ -209,6 +210,7 @@ export declare const protocol: Protocol<{
209
210
  readonly reasoning?: string | null | undefined;
210
211
  readonly reasoning_text?: string | null | undefined;
211
212
  readonly reasoning_details?: unknown;
213
+ readonly reasoning_opaque?: string | null | undefined;
212
214
  readonly tool_calls?: readonly {
213
215
  readonly index?: number | null | undefined;
214
216
  readonly id?: string | null | undefined;
@@ -234,6 +236,7 @@ export declare const protocol: Protocol<{
234
236
  readonly prompt_cache_hit_tokens?: number | null | undefined;
235
237
  readonly cache_read_input_tokens?: number | null | undefined;
236
238
  readonly cache_created_input_tokens?: number | null | undefined;
239
+ readonly reasoning_tokens?: number | null | undefined;
237
240
  readonly prompt_tokens_details?: {
238
241
  readonly [x: string]: unknown;
239
242
  readonly cached_tokens?: number | null | undefined;
@@ -256,6 +259,7 @@ export declare const protocol: Protocol<{
256
259
  readonly prompt_cache_hit_tokens?: number | null | undefined;
257
260
  readonly cache_read_input_tokens?: number | null | undefined;
258
261
  readonly cache_created_input_tokens?: number | null | undefined;
262
+ readonly reasoning_tokens?: number | null | undefined;
259
263
  readonly prompt_tokens_details?: {
260
264
  readonly [x: string]: unknown;
261
265
  readonly cached_tokens?: number | null | undefined;
@@ -374,6 +378,7 @@ export declare const route: Route<{
374
378
  readonly reasoning?: string | undefined;
375
379
  readonly reasoning_text?: string | undefined;
376
380
  readonly reasoning_details?: unknown;
381
+ readonly reasoning_opaque?: string | undefined;
377
382
  })[];
378
383
  readonly tools?: readonly ({
379
384
  readonly type: "function";
@@ -335,6 +335,7 @@ export declare const routes: (Route<{
335
335
  readonly reasoning?: string | undefined;
336
336
  readonly reasoning_text?: string | undefined;
337
337
  readonly reasoning_details?: unknown;
338
+ readonly reasoning_opaque?: string | undefined;
338
339
  })[];
339
340
  readonly tools?: readonly ({
340
341
  readonly type: "function";
@@ -639,6 +639,7 @@ export declare const routes: (Route<{
639
639
  readonly reasoning?: string | undefined;
640
640
  readonly reasoning_text?: string | undefined;
641
641
  readonly reasoning_details?: unknown;
642
+ readonly reasoning_opaque?: string | undefined;
642
643
  })[];
643
644
  readonly tools?: readonly ({
644
645
  readonly type: "function";
@@ -635,6 +635,7 @@ export declare const routes: (Route<{
635
635
  readonly reasoning?: string | undefined;
636
636
  readonly reasoning_text?: string | undefined;
637
637
  readonly reasoning_details?: unknown;
638
+ readonly reasoning_opaque?: string | undefined;
638
639
  })[];
639
640
  readonly tools?: readonly ({
640
641
  readonly type: "function";
@@ -113,6 +113,7 @@ export declare const routes: import("../route.js").Route<{
113
113
  readonly reasoning?: string | undefined;
114
114
  readonly reasoning_text?: string | undefined;
115
115
  readonly reasoning_details?: unknown;
116
+ readonly reasoning_opaque?: string | undefined;
116
117
  })[];
117
118
  readonly tools?: readonly ({
118
119
  readonly type: "function";
@@ -111,6 +111,7 @@ export declare const routes: (Route<{
111
111
  readonly reasoning?: string | undefined;
112
112
  readonly reasoning_text?: string | undefined;
113
113
  readonly reasoning_details?: unknown;
114
+ readonly reasoning_opaque?: string | undefined;
114
115
  })[];
115
116
  readonly tools?: readonly ({
116
117
  readonly type: "function";
@@ -178,6 +178,7 @@ declare const OpenRouterBody: Schema.StructWithRest<Schema.Struct<{
178
178
  readonly reasoning: Schema.optional<Schema.String>;
179
179
  readonly reasoning_text: Schema.optional<Schema.String>;
180
180
  readonly reasoning_details: Schema.optional<Schema.Unknown>;
181
+ readonly reasoning_opaque: Schema.optional<Schema.String>;
181
182
  }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>, Schema.Struct<{
182
183
  readonly role: Schema.Literal<"tool">;
183
184
  readonly tool_call_id: Schema.String;
@@ -368,6 +369,7 @@ export declare const protocol: Protocol<{
368
369
  readonly reasoning?: string | undefined;
369
370
  readonly reasoning_text?: string | undefined;
370
371
  readonly reasoning_details?: unknown;
372
+ readonly reasoning_opaque?: string | undefined;
371
373
  })[];
372
374
  tools?: readonly ({
373
375
  readonly type: "function";
@@ -471,6 +473,7 @@ export declare const protocol: Protocol<{
471
473
  readonly reasoning?: string | null | undefined;
472
474
  readonly reasoning_text?: string | null | undefined;
473
475
  readonly reasoning_details?: unknown;
476
+ readonly reasoning_opaque?: string | null | undefined;
474
477
  readonly tool_calls?: readonly {
475
478
  readonly index?: number | null | undefined;
476
479
  readonly id?: string | null | undefined;
@@ -496,6 +499,7 @@ export declare const protocol: Protocol<{
496
499
  readonly prompt_cache_hit_tokens?: number | null | undefined;
497
500
  readonly cache_read_input_tokens?: number | null | undefined;
498
501
  readonly cache_created_input_tokens?: number | null | undefined;
502
+ readonly reasoning_tokens?: number | null | undefined;
499
503
  readonly prompt_tokens_details?: {
500
504
  readonly [x: string]: unknown;
501
505
  readonly cached_tokens?: number | null | undefined;
@@ -518,6 +522,7 @@ export declare const protocol: Protocol<{
518
522
  readonly prompt_cache_hit_tokens?: number | null | undefined;
519
523
  readonly cache_read_input_tokens?: number | null | undefined;
520
524
  readonly cache_created_input_tokens?: number | null | undefined;
525
+ readonly reasoning_tokens?: number | null | undefined;
521
526
  readonly prompt_tokens_details?: {
522
527
  readonly [x: string]: unknown;
523
528
  readonly cached_tokens?: number | null | undefined;
@@ -636,6 +641,7 @@ export declare const route: Route<{
636
641
  readonly reasoning?: string | undefined;
637
642
  readonly reasoning_text?: string | undefined;
638
643
  readonly reasoning_details?: unknown;
644
+ readonly reasoning_opaque?: string | undefined;
639
645
  })[];
640
646
  tools?: readonly ({
641
647
  readonly type: "function";
@@ -1036,6 +1042,7 @@ export declare const routes: (Route<{
1036
1042
  readonly reasoning?: string | undefined;
1037
1043
  readonly reasoning_text?: string | undefined;
1038
1044
  readonly reasoning_details?: unknown;
1045
+ readonly reasoning_opaque?: string | undefined;
1039
1046
  })[];
1040
1047
  tools?: readonly ({
1041
1048
  readonly type: "function";
@@ -112,6 +112,7 @@ export declare const route: Route<{
112
112
  readonly reasoning?: string | undefined;
113
113
  readonly reasoning_text?: string | undefined;
114
114
  readonly reasoning_details?: unknown;
115
+ readonly reasoning_opaque?: string | undefined;
115
116
  })[];
116
117
  readonly tools?: readonly ({
117
118
  readonly type: "function";
@@ -286,6 +287,7 @@ export declare const routes: Route<{
286
287
  readonly reasoning?: string | undefined;
287
288
  readonly reasoning_text?: string | undefined;
288
289
  readonly reasoning_details?: unknown;
290
+ readonly reasoning_opaque?: string | undefined;
289
291
  })[];
290
292
  readonly tools?: readonly ({
291
293
  readonly type: "function";
@@ -363,6 +363,7 @@ export declare const routes: (Route<{
363
363
  readonly reasoning?: string | undefined;
364
364
  readonly reasoning_text?: string | undefined;
365
365
  readonly reasoning_details?: unknown;
366
+ readonly reasoning_opaque?: string | undefined;
366
367
  readonly tool_calls?: readonly ({
367
368
  readonly id: string;
368
369
  readonly type: "custom";
@@ -123,6 +123,7 @@ export declare const routes: (Route<unknown, import("../protocols/open-responses
123
123
  readonly reasoning?: string | undefined;
124
124
  readonly reasoning_text?: string | undefined;
125
125
  readonly reasoning_details?: unknown;
126
+ readonly reasoning_opaque?: string | undefined;
126
127
  })[];
127
128
  readonly tools?: readonly ({
128
129
  readonly type: "function";
@@ -316,6 +316,7 @@ export declare const routes: (Route<{
316
316
  readonly reasoning?: string | undefined;
317
317
  readonly reasoning_text?: string | undefined;
318
318
  readonly reasoning_details?: unknown;
319
+ readonly reasoning_opaque?: string | undefined;
319
320
  })[];
320
321
  readonly tools?: readonly ({
321
322
  readonly type: "function";
@@ -114,6 +114,7 @@ export declare const routes: Route<{
114
114
  readonly reasoning?: string | undefined;
115
115
  readonly reasoning_text?: string | undefined;
116
116
  readonly reasoning_details?: unknown;
117
+ readonly reasoning_opaque?: string | undefined;
117
118
  })[];
118
119
  readonly tools?: readonly ({
119
120
  readonly type: "function";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
- "version": "0.0.0-dev-1029",
3
+ "version": "0.0.0-dev-1032",
4
4
  "name": "@opencode/ai",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -520,7 +520,7 @@
520
520
  "devDependencies": {
521
521
  "@clack/prompts": "1.0.0-alpha.1",
522
522
  "@effect/platform-node": "4.1.0",
523
- "@opencode/http-recorder": "0.0.0-dev-1029",
523
+ "@opencode/http-recorder": "0.0.0-dev-1032",
524
524
  "@tsconfig/bun": "1.0.9",
525
525
  "@types/bun": "1.4.3",
526
526
  "@typescript/native": "npm:typescript@7.1.0-beta",
@@ -530,7 +530,7 @@
530
530
  "@aws-sdk/credential-providers": "3.1057.0",
531
531
  "@smithy/eventstream-codec": "4.2.14",
532
532
  "@smithy/util-utf8": "4.2.2",
533
- "@opencode/schema": "0.0.0-dev-1029",
533
+ "@opencode/schema": "0.0.0-dev-1032",
534
534
  "aws4fetch": "1.0.20",
535
535
  "effect": "4.1.0",
536
536
  "google-auth-library": "10.5.0"