@oh-my-pi/pi-ai 18.1.1 → 18.1.2

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [18.1.2] - 2026-09-01
6
+
7
+ ### Added
8
+
9
+ - Added thinking controls for Amazon Bedrock models.
10
+ - Added dynamic mid-conversation updates for Anthropic system prompts, tools, and reasoning effort.
11
+ - Added deferred tool loading and prompt caching for Anthropic models.
12
+ - Added configurable handling for invalid Anthropic thinking blocks through `anthropicPrefixMismatchBehavior`.
13
+
14
+ ### Fixed
15
+
16
+ - Fixed compatibility issues with Anthropic thinking and prompt-cache breakpoints across deployments, preserving valid reasoning context while preventing invalid-signature errors.
17
+ - Fixed incorrect operating-system information reported in request headers on non-Linux systems.
18
+ - Fixed Google Antigravity quota handling so requests rotate to another account with available usage instead of unnecessarily switching models.
19
+ - Fixed Anthropic authentication for newer models by updating the Claude Code request fingerprint.
20
+
5
21
  ## [18.1.0] - 2026-09-01
6
22
 
7
23
  ### Added
@@ -60,6 +60,8 @@ export interface AuthGatewayParsedRequestOptions {
60
60
  hideThinkingSummary?: boolean;
61
61
  /** Anthropic `output_config.task_budget` advisory loop budget. */
62
62
  taskBudget?: TokenTaskBudget;
63
+ /** Anthropic preserved-thinking behavior for a changed conversation prefix. */
64
+ anthropicPrefixMismatchBehavior?: "drop_block" | "error";
63
65
  /** OpenAI service tier (auto|default|flex|scale|priority). */
64
66
  serviceTier?: ServiceTier;
65
67
  /** Cache retention hint derived from inbound `cache_control` markers. */
@@ -196,24 +196,56 @@ export declare const userMessageSchema: import("@oh-my-pi/omptype").FluentType<{
196
196
  role: "user";
197
197
  }>;
198
198
  export declare const systemMessageSchema: import("@oh-my-pi/omptype").FluentType<{
199
- content: string | {
199
+ clear_at?: "never" | "next_user_message" | undefined;
200
+ content: string | ({
200
201
  cache_control?: {
201
202
  ttl?: "1h" | "5m" | undefined;
202
203
  type: "ephemeral";
203
204
  } | undefined;
204
205
  text: string;
205
206
  type: "text";
206
- }[];
207
+ } | {
208
+ tool: {
209
+ name: string;
210
+ type: "tool_reference";
211
+ };
212
+ type: "tool_addition";
213
+ } | {
214
+ tool: {
215
+ name: string;
216
+ type: "tool_reference";
217
+ };
218
+ type: "tool_removal";
219
+ })[];
220
+ output_config?: {
221
+ effort?: "high" | "low" | "max" | "medium" | "xhigh" | undefined;
222
+ } | undefined;
207
223
  role: "system";
208
224
  }, {
209
- content: string | {
225
+ clear_at?: "never" | "next_user_message" | undefined;
226
+ content: string | ({
210
227
  cache_control?: {
211
228
  ttl?: "1h" | "5m" | undefined;
212
229
  type: "ephemeral";
213
230
  } | undefined;
214
231
  text: string;
215
232
  type: "text";
216
- }[];
233
+ } | {
234
+ tool: {
235
+ name: string;
236
+ type: "tool_reference";
237
+ };
238
+ type: "tool_addition";
239
+ } | {
240
+ tool: {
241
+ name: string;
242
+ type: "tool_reference";
243
+ };
244
+ type: "tool_removal";
245
+ })[];
246
+ output_config?: {
247
+ effort?: "high" | "low" | "max" | "medium" | "xhigh" | undefined;
248
+ } | undefined;
217
249
  role: "system";
218
250
  }>;
219
251
  export declare const assistantMessageSchema: import("@oh-my-pi/omptype").FluentType<{
@@ -352,14 +384,30 @@ export declare const messageSchema: import("@oh-my-pi/omptype").FluentType<{
352
384
  })[];
353
385
  role: "user";
354
386
  } | {
355
- content: string | {
387
+ clear_at?: "never" | "next_user_message" | undefined;
388
+ content: string | ({
356
389
  cache_control?: {
357
390
  ttl?: "1h" | "5m" | undefined;
358
391
  type: "ephemeral";
359
392
  } | undefined;
360
393
  text: string;
361
394
  type: "text";
362
- }[];
395
+ } | {
396
+ tool: {
397
+ name: string;
398
+ type: "tool_reference";
399
+ };
400
+ type: "tool_addition";
401
+ } | {
402
+ tool: {
403
+ name: string;
404
+ type: "tool_reference";
405
+ };
406
+ type: "tool_removal";
407
+ })[];
408
+ output_config?: {
409
+ effort?: "high" | "low" | "max" | "medium" | "xhigh" | undefined;
410
+ } | undefined;
363
411
  role: "system";
364
412
  } | {
365
413
  content: string | ({
@@ -460,14 +508,30 @@ export declare const messageSchema: import("@oh-my-pi/omptype").FluentType<{
460
508
  })[];
461
509
  role: "user";
462
510
  } | {
463
- content: string | {
511
+ clear_at?: "never" | "next_user_message" | undefined;
512
+ content: string | ({
464
513
  cache_control?: {
465
514
  ttl?: "1h" | "5m" | undefined;
466
515
  type: "ephemeral";
467
516
  } | undefined;
468
517
  text: string;
469
518
  type: "text";
470
- }[];
519
+ } | {
520
+ tool: {
521
+ name: string;
522
+ type: "tool_reference";
523
+ };
524
+ type: "tool_addition";
525
+ } | {
526
+ tool: {
527
+ name: string;
528
+ type: "tool_reference";
529
+ };
530
+ type: "tool_removal";
531
+ })[];
532
+ output_config?: {
533
+ effort?: "high" | "low" | "max" | "medium" | "xhigh" | undefined;
534
+ } | undefined;
471
535
  role: "system";
472
536
  } | {
473
537
  content: string | ({
@@ -511,6 +575,7 @@ export declare const toolSchema: import("@oh-my-pi/omptype").FluentType<{
511
575
  ttl?: "1h" | "5m" | undefined;
512
576
  type: "ephemeral";
513
577
  } | undefined;
578
+ defer_loading?: boolean | undefined;
514
579
  description?: string | undefined;
515
580
  input_schema: Record<string, unknown>;
516
581
  name: string;
@@ -519,6 +584,7 @@ export declare const toolSchema: import("@oh-my-pi/omptype").FluentType<{
519
584
  ttl?: "1h" | "5m" | undefined;
520
585
  type: "ephemeral";
521
586
  } | undefined;
587
+ defer_loading?: boolean | undefined;
522
588
  description?: string | undefined;
523
589
  input_schema: Record<string, unknown>;
524
590
  name: string;
@@ -554,14 +620,23 @@ export declare const thinkingConfigSchema: import("@oh-my-pi/omptype").FluentTyp
554
620
  display?: unknown;
555
621
  type: "disabled";
556
622
  } | {
623
+ block_binding?: {
624
+ prefix_mismatch_behavior: "drop_block" | "error";
625
+ } | undefined;
557
626
  budget_tokens?: number | undefined;
558
627
  display?: unknown;
559
628
  type: "adaptive";
560
629
  } | {
630
+ block_binding?: {
631
+ prefix_mismatch_behavior: "drop_block" | "error";
632
+ } | undefined;
561
633
  budget_tokens: number;
562
634
  display?: unknown;
563
635
  type: "enabled";
564
636
  }, {
637
+ block_binding?: {
638
+ prefix_mismatch_behavior: "drop_block" | "error";
639
+ } | undefined;
565
640
  budget_tokens: number;
566
641
  display?: unknown;
567
642
  type: "enabled";
@@ -569,6 +644,9 @@ export declare const thinkingConfigSchema: import("@oh-my-pi/omptype").FluentTyp
569
644
  display?: unknown;
570
645
  type: "disabled";
571
646
  } | {
647
+ block_binding?: {
648
+ prefix_mismatch_behavior: "drop_block" | "error";
649
+ } | undefined;
572
650
  budget_tokens?: number | undefined;
573
651
  display?: unknown;
574
652
  type: "adaptive";
@@ -641,14 +719,30 @@ export declare const anthropicMessagesRequestSchema: import("@oh-my-pi/omptype")
641
719
  })[];
642
720
  role: "user";
643
721
  } | {
644
- content: string | {
722
+ clear_at?: "never" | "next_user_message" | undefined;
723
+ content: string | ({
645
724
  cache_control?: {
646
725
  ttl?: "1h" | "5m" | undefined;
647
726
  type: "ephemeral";
648
727
  } | undefined;
649
728
  text: string;
650
729
  type: "text";
651
- }[];
730
+ } | {
731
+ tool: {
732
+ name: string;
733
+ type: "tool_reference";
734
+ };
735
+ type: "tool_addition";
736
+ } | {
737
+ tool: {
738
+ name: string;
739
+ type: "tool_reference";
740
+ };
741
+ type: "tool_removal";
742
+ })[];
743
+ output_config?: {
744
+ effort?: "high" | "low" | "max" | "medium" | "xhigh" | undefined;
745
+ } | undefined;
652
746
  role: "system";
653
747
  } | {
654
748
  content: string | ({
@@ -714,10 +808,16 @@ export declare const anthropicMessagesRequestSchema: import("@oh-my-pi/omptype")
714
808
  display?: unknown;
715
809
  type: "disabled";
716
810
  } | {
811
+ block_binding?: {
812
+ prefix_mismatch_behavior: "drop_block" | "error";
813
+ } | undefined;
717
814
  budget_tokens?: number | undefined;
718
815
  display?: unknown;
719
816
  type: "adaptive";
720
817
  } | {
818
+ block_binding?: {
819
+ prefix_mismatch_behavior: "drop_block" | "error";
820
+ } | undefined;
721
821
  budget_tokens: number;
722
822
  display?: unknown;
723
823
  type: "enabled";
@@ -741,6 +841,7 @@ export declare const anthropicMessagesRequestSchema: import("@oh-my-pi/omptype")
741
841
  ttl?: "1h" | "5m" | undefined;
742
842
  type: "ephemeral";
743
843
  } | undefined;
844
+ defer_loading?: boolean | undefined;
744
845
  description?: string | undefined;
745
846
  input_schema: Record<string, unknown>;
746
847
  name: string;
@@ -815,14 +916,30 @@ export declare const anthropicMessagesRequestSchema: import("@oh-my-pi/omptype")
815
916
  })[];
816
917
  role: "user";
817
918
  } | {
818
- content: string | {
919
+ clear_at?: "never" | "next_user_message" | undefined;
920
+ content: string | ({
819
921
  cache_control?: {
820
922
  ttl?: "1h" | "5m" | undefined;
821
923
  type: "ephemeral";
822
924
  } | undefined;
823
925
  text: string;
824
926
  type: "text";
825
- }[];
927
+ } | {
928
+ tool: {
929
+ name: string;
930
+ type: "tool_reference";
931
+ };
932
+ type: "tool_addition";
933
+ } | {
934
+ tool: {
935
+ name: string;
936
+ type: "tool_reference";
937
+ };
938
+ type: "tool_removal";
939
+ })[];
940
+ output_config?: {
941
+ effort?: "high" | "low" | "max" | "medium" | "xhigh" | undefined;
942
+ } | undefined;
826
943
  role: "system";
827
944
  } | {
828
945
  content: string | ({
@@ -885,6 +1002,9 @@ export declare const anthropicMessagesRequestSchema: import("@oh-my-pi/omptype")
885
1002
  }[] | undefined;
886
1003
  temperature?: number | undefined;
887
1004
  thinking?: {
1005
+ block_binding?: {
1006
+ prefix_mismatch_behavior: "drop_block" | "error";
1007
+ } | undefined;
888
1008
  budget_tokens: number;
889
1009
  display?: unknown;
890
1010
  type: "enabled";
@@ -892,6 +1012,9 @@ export declare const anthropicMessagesRequestSchema: import("@oh-my-pi/omptype")
892
1012
  display?: unknown;
893
1013
  type: "disabled";
894
1014
  } | {
1015
+ block_binding?: {
1016
+ prefix_mismatch_behavior: "drop_block" | "error";
1017
+ } | undefined;
895
1018
  budget_tokens?: number | undefined;
896
1019
  display?: unknown;
897
1020
  type: "adaptive";
@@ -915,6 +1038,7 @@ export declare const anthropicMessagesRequestSchema: import("@oh-my-pi/omptype")
915
1038
  ttl?: "1h" | "5m" | undefined;
916
1039
  type: "ephemeral";
917
1040
  } | undefined;
1041
+ defer_loading?: boolean | undefined;
918
1042
  description?: string | undefined;
919
1043
  input_schema: Record<string, unknown>;
920
1044
  name: string;
@@ -8,7 +8,7 @@ import type { AuthGatewayStreamControl, AuthGatewayParsedRequest as ParsedReques
8
8
  export type { ParsedRequest };
9
9
  export declare function parseRequest(body: unknown, headers?: Headers): ParsedRequest;
10
10
  export declare function encodeResponse(message: AssistantMessage, requestedModelId: string): Record<string, unknown>;
11
- export declare function encodeStream(events: AssistantMessageEventStream, requestedModelId: string, _options?: ParsedRequest["options"], control?: AuthGatewayStreamControl): ReadableStream<Uint8Array>;
11
+ export declare function encodeStream(events: AssistantMessageEventStream, requestedModelId: string, options?: ParsedRequest["options"], control?: AuthGatewayStreamControl): ReadableStream<Uint8Array>;
12
12
  /**
13
13
  * Anthropic error envelope: `{ type: "error", error: { type, message } }`.
14
14
  * See https://docs.anthropic.com/en/api/errors. Returned as a `Response` so
@@ -11,7 +11,9 @@
11
11
  * `scope`, tool `strict`/`eager_input_streaming`, mid-conversation `system`
12
12
  * role) are first-class here instead of being patched in via casts.
13
13
  */
14
- import type { TokenTaskBudget } from "../types.js";
14
+ import type { ProviderInputTransformation, TokenTaskBudget } from "../types.js";
15
+ /** Beta enabling preserved-thinking block controls and transformation reports. */
16
+ export declare const THINKING_BINDING_CONTROLS_BETA = "thinking-binding-controls-2026-08-01";
15
17
  /** Ephemeral prefix-cache breakpoint marker. */
16
18
  export type CacheControlEphemeral = {
17
19
  type: "ephemeral";
@@ -87,6 +89,18 @@ export type ToolSearchToolResultBlockParam = {
87
89
  content: unknown;
88
90
  [key: string]: unknown;
89
91
  };
92
+ export type ToolChangeReferenceParam = {
93
+ type: "tool_reference";
94
+ name: string;
95
+ };
96
+ export type ToolAdditionBlockParam = {
97
+ type: "tool_addition";
98
+ tool: ToolChangeReferenceParam;
99
+ };
100
+ export type ToolRemovalBlockParam = {
101
+ type: "tool_removal";
102
+ tool: ToolChangeReferenceParam;
103
+ };
90
104
  /** Anthropic server-tool history variants omp can replay atomically. */
91
105
  export type AnthropicServerToolHistoryBlockParam = WebSearchServerToolUseBlockParam | WebSearchToolResultBlockParam | ToolSearchServerToolUseBlockParam | ToolSearchToolResultBlockParam;
92
106
  /** True when a block is complete Anthropic server-tool history omp can replay. */
@@ -121,7 +135,7 @@ export type FallbackBlockParam = {
121
135
  model: string;
122
136
  };
123
137
  };
124
- export type ContentBlockParam = TextBlockParam | ImageBlockParam | ToolUseBlockParam | ToolResultBlockParam | ServerToolUseBlockParam | WebSearchToolResultBlockParam | ToolSearchToolResultBlockParam | ThinkingBlockParam | RedactedThinkingBlockParam | FallbackBlockParam;
138
+ export type ContentBlockParam = TextBlockParam | ImageBlockParam | ToolUseBlockParam | ToolResultBlockParam | ServerToolUseBlockParam | WebSearchToolResultBlockParam | ToolSearchToolResultBlockParam | ToolAdditionBlockParam | ToolRemovalBlockParam | ThinkingBlockParam | RedactedThinkingBlockParam | FallbackBlockParam;
125
139
  /**
126
140
  * A single conversation turn.
127
141
  *
@@ -132,6 +146,10 @@ export type ContentBlockParam = TextBlockParam | ImageBlockParam | ToolUseBlockP
132
146
  export type MessageParam = {
133
147
  role: "user" | "assistant" | "system";
134
148
  content: string | ContentBlockParam[];
149
+ /** Turn-scoped system-message lifetime. */
150
+ clear_at?: "never" | "next_user_message";
151
+ /** Per-message effort override. */
152
+ output_config?: OutputConfig;
135
153
  };
136
154
  export type ToolInputSchema = {
137
155
  type: "object";
@@ -148,6 +166,8 @@ export type Tool = {
148
166
  strict?: boolean;
149
167
  /** Fine-grained tool streaming beta: stream tool input as it is generated. */
150
168
  eager_input_streaming?: boolean;
169
+ /** Withhold this tool until a later `tool_addition` block references it. */
170
+ defer_loading?: boolean;
151
171
  };
152
172
  export type ToolChoiceAuto = {
153
173
  type: "auto";
@@ -169,11 +189,16 @@ export type ToolChoice = ToolChoiceAuto | ToolChoiceAny | ToolChoiceTool | ToolC
169
189
  export type Metadata = {
170
190
  user_id?: string | null;
171
191
  };
192
+ export type ThinkingBlockBinding = {
193
+ prefix_mismatch_behavior: "drop_block" | "error";
194
+ };
172
195
  export type ThinkingConfigEnabled = {
173
196
  type: "enabled";
174
197
  budget_tokens: number;
175
198
  /** Opus 4.7+ reasoning display mode. */
176
199
  display?: "summarized" | "omitted";
200
+ /** Preserved-thinking prefix mismatch policy. */
201
+ block_binding?: ThinkingBlockBinding;
177
202
  };
178
203
  export type ThinkingConfigDisabled = {
179
204
  type: "disabled";
@@ -182,6 +207,8 @@ export type ThinkingConfigAdaptive = {
182
207
  type: "adaptive";
183
208
  /** Opus 4.7+ reasoning display mode. */
184
209
  display?: "summarized" | "omitted";
210
+ /** Preserved-thinking prefix mismatch policy. */
211
+ block_binding?: ThinkingBlockBinding;
185
212
  };
186
213
  export type ThinkingConfigParam = ThinkingConfigEnabled | ThinkingConfigDisabled | ThinkingConfigAdaptive;
187
214
  export type OutputConfig = {
@@ -228,6 +255,8 @@ export type MessageCreateParams = {
228
255
  speed?: "fast";
229
256
  /** Claude Code context-management beta. */
230
257
  context_management?: ContextManagement;
258
+ /** Google Cloud rawPredict carries Anthropic beta names in the body. */
259
+ anthropic_beta?: string[];
231
260
  /**
232
261
  * Server-side fallback beta chain — up to three fallback models the API
233
262
  * retries when a classifier blocks the primary. Required companion beta
@@ -271,6 +300,14 @@ export type Usage = {
271
300
  iterations?: UsageIteration[] | null;
272
301
  };
273
302
  /** The `message` envelope carried by `message_start`. */
303
+ export type InputTransformation = {
304
+ type: string;
305
+ path?: string;
306
+ reason?: string;
307
+ [key: string]: unknown;
308
+ };
309
+ /** Parse Anthropic's forward-compatible input transformation list. */
310
+ export declare function parseAnthropicInputTransformations(value: unknown): ProviderInputTransformation[];
274
311
  export type ResponseMessage = {
275
312
  id: string;
276
313
  type?: "message";
@@ -279,6 +316,7 @@ export type ResponseMessage = {
279
316
  content?: unknown[];
280
317
  stop_reason?: StopReason | null;
281
318
  stop_sequence?: string | null;
319
+ input_transformations?: InputTransformation[];
282
320
  usage: Usage;
283
321
  };
284
322
  /** `content_block` payload carried by `content_block_start`. */
@@ -351,6 +389,7 @@ export type RawMessageDeltaEvent = {
351
389
  type: "message_delta";
352
390
  delta: MessageDelta;
353
391
  usage: Usage;
392
+ input_transformations?: InputTransformation[];
354
393
  };
355
394
  export type RawMessageStopEvent = {
356
395
  type: "message_stop";
@@ -1,6 +1,6 @@
1
1
  import type { Api, FetchImpl, Message, Model, ProviderSessionState, ServiceTier, SimpleStreamOptions, StreamFunction, StreamOptions, Usage } from "../types.js";
2
2
  import { type AnthropicFetchOptions, type AnthropicMessagesClientLike } from "./anthropic-client.js";
3
- import { type FallbackParam, type MessageParam } from "./anthropic-wire.js";
3
+ import { type FallbackParam, type MessageParam, type TextBlockParam } from "./anthropic-wire.js";
4
4
  export type AnthropicHeaderOptions = {
5
5
  apiKey: string;
6
6
  baseUrl?: string;
@@ -10,13 +10,14 @@ export type AnthropicHeaderOptions = {
10
10
  modelHeaders?: Record<string, string>;
11
11
  isCloudflareAiGateway?: boolean;
12
12
  claudeCodeSessionId?: string;
13
- coworkBetas?: readonly string[];
13
+ claudeCodeBetas?: readonly string[];
14
14
  /** Allow explicit fingerprint headers to replace OAuth defaults on non-official endpoints. */
15
15
  allowAnthropicHeaderOverrides?: boolean;
16
16
  };
17
17
  export declare function normalizeAnthropicBaseUrl(baseUrl?: string): string | undefined;
18
18
  export declare function buildBetaHeader(baseBetas: readonly string[], extraBetas: readonly string[]): string;
19
19
  export declare function buildAnthropicHeaders(options: AnthropicHeaderOptions): Record<string, string>;
20
+ type AnthropicCacheControl = NonNullable<TextBlockParam["cache_control"]>;
20
21
  /**
21
22
  * Clears the in-session "server rejected fast mode" sticky flag. Call when the
22
23
  * caller is explicitly re-arming `serviceTier: "priority"` (e.g. user toggled
@@ -32,12 +33,15 @@ export declare function clearAnthropicFastModeFallback(providerSessionState: Map
32
33
  */
33
34
  export declare function isAnthropicFastModeFallbackDisabled(providerSessionState: Map<string, ProviderSessionState> | undefined, model: Model<Api>): boolean;
34
35
  export * from "./claude-code-fingerprint.js";
36
+ /** Maps Node's platform identifier to the Stainless wire value. */
37
+ export declare function mapStainlessOs(platform: string): "MacOS" | "Windows" | "Linux" | "FreeBSD" | `Other::${string}`;
38
+ /** Maps Node's architecture identifier to the Stainless wire value. */
35
39
  export declare function mapStainlessArch(arch: string): "x64" | "arm64" | "x86" | `other::${string}`;
36
- /** Static headers emitted by Cowork's Linux Claude runtime. */
37
- export declare const coworkHeaders: {
40
+ /** Static headers emitted by Claude Code's CLI runtime. */
41
+ export declare const claudeCodeHeaders: {
38
42
  "X-Stainless-Arch": "arm64" | "x64" | "x86" | `other::${string}`;
39
43
  "X-Stainless-Lang": string;
40
- "X-Stainless-OS": string;
44
+ "X-Stainless-OS": "FreeBSD" | "Linux" | "MacOS" | "Windows" | `Other::${string}`;
41
45
  "X-Stainless-Package-Version": string;
42
46
  "X-Stainless-Retry-Count": string;
43
47
  "X-Stainless-Runtime": string;
@@ -207,6 +211,8 @@ export type AnthropicUsageLike = {
207
211
  * zero-valued objects clear prior extras from earlier stream usage snapshots.
208
212
  */
209
213
  export declare function applyAnthropicUsageExtras(usage: Usage, source: AnthropicUsageLike): void;
214
+ /** Detects the preserved-thinking error caused by rewriting a signed block's conversation prefix. */
215
+ export declare function isThinkingPrefixBindingError(message: string): boolean;
210
216
  export declare function isInvalidThinkingSignatureError(message: string): boolean;
211
217
  /**
212
218
  * Prepend a pointed remediation to Anthropic's `Invalid signature in thinking
@@ -225,12 +231,15 @@ export declare const streamAnthropic: StreamFunction<"anthropic-messages">;
225
231
  export type AnthropicSystemBlock = {
226
232
  type: "text";
227
233
  text: string;
234
+ cache_control?: AnthropicCacheControl;
228
235
  };
229
236
  type SystemBlockOptions = {
230
237
  includeClaudeCodeInstruction?: boolean;
231
238
  extraInstructions?: string[];
232
239
  /** Text of the first user message — used as fingerprint seed for the billing header. */
233
240
  firstUserMessageText?: string;
241
+ /** Cache lifetime shared by the OAuth system breakpoint and later message breakpoints. */
242
+ cacheControl?: AnthropicCacheControl;
234
243
  };
235
244
  export declare function buildAnthropicSystemBlocks(systemPrompt: readonly string[] | undefined, options?: SystemBlockOptions): AnthropicSystemBlock[] | undefined;
236
245
  export declare function normalizeExtraBetas(betas?: string[] | string): string[];
@@ -251,5 +260,7 @@ export type AnthropicMessageParam = MessageParam;
251
260
  */
252
261
  export declare function convertAnthropicMessages(messages: Message[], model: Model<"anthropic-messages">, isOAuthToken: boolean, opts?: {
253
262
  serverSideFallbackEnabled?: boolean;
263
+ dropAllThinking?: boolean;
264
+ droppedThinkingBlocks?: ReadonlySet<string>;
254
265
  }): AnthropicMessageParam[];
255
266
  export declare function normalizeAnthropicToolSchema(schema: unknown): unknown;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Cowork inference-fingerprint constants, kept in a leaf module so consumers
2
+ * Claude Code inference-fingerprint constants, kept in a leaf module so consumers
3
3
  * outside the provider (`registry/oauth/anthropic`, `usage/claude`) don't
4
4
  * import the heavy `providers/anthropic` module.
5
5
  *
@@ -7,15 +7,15 @@
7
7
  * `registry` → `registry/oauth/anthropic` → back into the still-initializing
8
8
  * provider module.
9
9
  */
10
- /** Claude runtime version bundled by the current Cowork desktop release. */
11
- export declare const claudeCodeVersion = "2.1.246";
12
- /** `@anthropic-ai/sdk` version bundled by the current Cowork desktop release. */
10
+ /** Current Claude Code CLI version represented on the Anthropic wire. */
11
+ export declare const claudeCodeVersion = "2.1.257";
12
+ /** `@anthropic-ai/sdk` version bundled by the current Claude Code release. */
13
13
  export declare const claudeCodeSdkVersion = "0.112.1";
14
- /** User-Agent emitted by Cowork's `claude-desktop` inference entrypoint. */
15
- export declare const coworkUserAgent = "claude-cli/2.1.246 (external, claude-desktop)";
14
+ /** User-Agent emitted by Claude Code's CLI inference entrypoint. */
15
+ export declare const claudeCodeUserAgent = "claude-cli/2.1.257 (external, cli)";
16
16
  /** Prefix used to isolate custom Anthropic OAuth tools from built-in tools. */
17
17
  export declare const claudeToolPrefix: string;
18
- /** Identity block prepended by Cowork's Claude runtime. */
19
- export declare const claudeCodeSystemInstruction = "You are a Claude agent, built on Anthropic's Claude Agent SDK.";
20
- /** Cowork's per-request output-token ceiling. */
18
+ /** Identity block prepended by Claude Code's CLI runtime. */
19
+ export declare const claudeCodeSystemInstruction = "You are Claude Code, Anthropic's official CLI for Claude.";
20
+ /** Claude Code's per-request output-token ceiling. */
21
21
  export declare const CLAUDE_CODE_MAX_OUTPUT_TOKENS = 64000;
@@ -236,6 +236,11 @@ export interface StreamOptions {
236
236
  * Side-channel and advisor requests must leave it unset.
237
237
  */
238
238
  anthropicCacheRefresh?: boolean;
239
+ /**
240
+ * Anthropic preserved-thinking behavior when a signed block no longer matches
241
+ * its conversation prefix. Binding-capable models default to `"drop_block"`.
242
+ */
243
+ anthropicPrefixMismatchBehavior?: "drop_block" | "error";
239
244
  /** @internal Marks a replay-only Anthropic request that must use non-streaming `max_tokens: 0`. */
240
245
  anthropicCacheRefreshRequest?: boolean;
241
246
  /**
@@ -679,7 +684,24 @@ export interface OpenAIResponsesHistoryPayload {
679
684
  dt?: boolean;
680
685
  items: Array<Record<string, unknown>>;
681
686
  }
682
- export type ProviderPayload = OpenAIResponsesHistoryPayload;
687
+ /** Anthropic-only controls attached to a mid-conversation system message. */
688
+ export interface AnthropicMessagePayload {
689
+ type: "anthropicMessage";
690
+ clearAt?: "never" | "next_user_message";
691
+ effort?: "low" | "medium" | "high" | "xhigh" | "max";
692
+ toolChanges?: Array<{
693
+ type: "tool_addition" | "tool_removal";
694
+ name: string;
695
+ }>;
696
+ }
697
+ export type ProviderPayload = OpenAIResponsesHistoryPayload | AnthropicMessagePayload;
698
+ /** Provider-reported rewrite applied to request content before inference. */
699
+ export interface ProviderInputTransformation {
700
+ type: string;
701
+ path?: string;
702
+ reason?: string;
703
+ [key: string]: unknown;
704
+ }
683
705
  export interface UserMessage {
684
706
  role: "user";
685
707
  content: string | (TextContent | ImageContent)[];
@@ -687,6 +709,8 @@ export interface UserMessage {
687
709
  synthetic?: boolean;
688
710
  /** True when injected mid-turn as a steer; consumed by the agent's pre-LLM transform to wrap it for emphasis. Never rendered. */
689
711
  steering?: boolean;
712
+ /** Timestamp of a client-side history rewrite represented by this message. */
713
+ historyRewriteAt?: number;
690
714
  /** Who initiated this message for billing/attribution semantics. */
691
715
  attribution?: MessageAttribution;
692
716
  /** Provider-specific opaque payload used to reconstruct transport-native history. */
@@ -782,6 +806,8 @@ export interface AssistantMessage {
782
806
  * server's actual state.
783
807
  */
784
808
  disabledFeatures?: string[];
809
+ /** Provider-reported input rewrites such as dropped bound-thinking blocks. */
810
+ inputTransformations?: ProviderInputTransformation[];
785
811
  /** Provider-specific opaque payload used to reconstruct transport-native history. */
786
812
  providerPayload?: ProviderPayload;
787
813
  timestamp: number;
@@ -1033,6 +1059,8 @@ export interface Tool<TParameters extends TSchema = TSchema> {
1033
1059
  parameters: TParameters;
1034
1060
  /** If true, tool is strictly typed and validated against the parameters schema before execution */
1035
1061
  strict?: boolean;
1062
+ /** Withhold this Anthropic tool until a `tool_addition` message references it. */
1063
+ deferLoading?: boolean;
1036
1064
  /**
1037
1065
  * Optional grammar constraint for OpenAI custom-tool emission.
1038
1066
  * When set, providers that support grammar-constrained tools (currently only
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@oh-my-pi/pi-ai",
4
- "version": "18.1.1",
4
+ "version": "18.1.2",
5
5
  "description": "Unified LLM API with automatic model discovery and provider configuration",
6
6
  "homepage": "https://omp.sh",
7
7
  "author": "Stencil Labs, Inc.",
@@ -37,10 +37,10 @@
37
37
  "fmt": "oxfmt --no-error-on-unmatched-pattern 'src/**/*.{ts,tsx}' '{test,bench,examples,scripts}/**/*.ts' '*.ts'"
38
38
  },
39
39
  "dependencies": {
40
- "@oh-my-pi/omptype": "18.1.1",
41
- "@oh-my-pi/pi-catalog": "18.1.1",
42
- "@oh-my-pi/pi-utils": "18.1.1",
43
- "@oh-my-pi/pi-wire": "18.1.1"
40
+ "@oh-my-pi/omptype": "18.1.2",
41
+ "@oh-my-pi/pi-catalog": "18.1.2",
42
+ "@oh-my-pi/pi-utils": "18.1.2",
43
+ "@oh-my-pi/pi-wire": "18.1.2"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/bun": "^1.3.14"
@@ -159,6 +159,9 @@ function buildStreamOptions(parsed: ParsedFormatRequest, api: Api, signal: Abort
159
159
  if (options.disableReasoning !== undefined) opts.disableReasoning = options.disableReasoning;
160
160
  if (options.hideThinkingSummary !== undefined) opts.hideThinkingSummary = options.hideThinkingSummary;
161
161
  if (options.taskBudget !== undefined) opts.taskBudget = options.taskBudget;
162
+ if (options.anthropicPrefixMismatchBehavior !== undefined) {
163
+ opts.anthropicPrefixMismatchBehavior = options.anthropicPrefixMismatchBehavior;
164
+ }
162
165
  if (options.serviceTier !== undefined) opts.serviceTier = options.serviceTier;
163
166
  if (options.cacheRetention !== undefined) opts.cacheRetention = options.cacheRetention;
164
167
  if (options.include !== undefined) opts.include = options.include;