@linxiraos/pi-ai 1.1.26 → 1.2.0

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 (237) hide show
  1. package/CHANGELOG.md +9 -8
  2. package/README.md +15 -0
  3. package/dist/types/auth/affinity.d.ts +33 -6
  4. package/dist/types/auth/cascade.d.ts +44 -7
  5. package/dist/types/auth/oauth.d.ts +9 -6
  6. package/dist/types/auth/policy.d.ts +1 -0
  7. package/dist/types/auth/refresh.d.ts +1 -2
  8. package/dist/types/auth/select.d.ts +6 -4
  9. package/dist/types/auth/sqlite-credential-store.d.ts +21 -1
  10. package/dist/types/auth/store.d.ts +8 -2
  11. package/dist/types/auth/types.d.ts +99 -15
  12. package/dist/types/auth-broker/client.d.ts +3 -3
  13. package/dist/types/auth-broker/discover.d.ts +1 -1
  14. package/dist/types/auth-broker/refresher.d.ts +6 -1
  15. package/dist/types/auth-broker/remote-store.d.ts +6 -4
  16. package/dist/types/auth-broker/server.d.ts +2 -0
  17. package/dist/types/auth-broker/snapshot-cache.d.ts +12 -0
  18. package/dist/types/auth-gateway/dispatch.d.ts +13 -5
  19. package/dist/types/auth-gateway/http.d.ts +0 -2
  20. package/dist/types/auth-gateway/index.d.ts +1 -0
  21. package/dist/types/auth-gateway/routes/embeddings.d.ts +2 -2
  22. package/dist/types/auth-gateway/routes/images.d.ts +3 -3
  23. package/dist/types/auth-gateway/routes/rerank.d.ts +2 -2
  24. package/dist/types/auth-gateway/routes/speech.d.ts +2 -2
  25. package/dist/types/auth-gateway/routes/systemone.d.ts +2 -2
  26. package/dist/types/auth-gateway/routes/transcriptions.d.ts +2 -2
  27. package/dist/types/auth-gateway/routes/video.d.ts +4 -4
  28. package/dist/types/auth-gateway/server.d.ts +22 -5
  29. package/dist/types/auth-gateway/session-state.d.ts +6 -0
  30. package/dist/types/auth-gateway/stdio.d.ts +12 -0
  31. package/dist/types/auth-storage.d.ts +7 -6
  32. package/dist/types/dialect/terminator-wait.d.ts +19 -0
  33. package/dist/types/env-api-key.d.ts +21 -0
  34. package/dist/types/error/auth.d.ts +10 -0
  35. package/dist/types/error/flags.d.ts +38 -0
  36. package/dist/types/images/index.d.ts +2 -3
  37. package/dist/types/images/shared.d.ts +6 -0
  38. package/dist/types/index.d.ts +2 -1
  39. package/dist/types/judgment/index.d.ts +2 -1
  40. package/dist/types/judgment/native.d.ts +80 -0
  41. package/dist/types/judgment/openai-decisions.d.ts +3 -0
  42. package/dist/types/judgment/question-file.d.ts +52 -0
  43. package/dist/types/judgment/systemone.d.ts +7 -0
  44. package/dist/types/judgment/types.d.ts +2 -2
  45. package/dist/types/judgment/wire.d.ts +36 -0
  46. package/dist/types/provider-details.d.ts +1 -1
  47. package/dist/types/provider-session-state.d.ts +2 -2
  48. package/dist/types/providers/anthropic-client.d.ts +10 -0
  49. package/dist/types/providers/anthropic-state.d.ts +2 -0
  50. package/dist/types/providers/anthropic.d.ts +38 -3
  51. package/dist/types/providers/aws-credentials.d.ts +4 -8
  52. package/dist/types/providers/connect-error-detail.d.ts +9 -0
  53. package/dist/types/providers/connect-frame.d.ts +44 -0
  54. package/dist/types/providers/cursor/interaction-query.d.ts +0 -2
  55. package/dist/types/providers/cursor.d.ts +8 -8
  56. package/dist/types/providers/google-auth.d.ts +4 -1
  57. package/dist/types/providers/google-shared.d.ts +24 -4
  58. package/dist/types/providers/inference-headers.d.ts +6 -0
  59. package/dist/types/providers/mock.d.ts +3 -1
  60. package/dist/types/providers/openai-codex/request-transformer.d.ts +2 -0
  61. package/dist/types/providers/openai-codex-responses.d.ts +1 -1
  62. package/dist/types/providers/openai-configuration-update.d.ts +20 -11
  63. package/dist/types/providers/openai-responses-wire.d.ts +1 -55
  64. package/dist/types/providers/openai-responses.d.ts +40 -3
  65. package/dist/types/providers/openai-shared.d.ts +30 -5
  66. package/dist/types/providers/pi-native-client.d.ts +1 -1
  67. package/dist/types/providers/transform-messages.d.ts +25 -0
  68. package/dist/types/providers/vision-guard.d.ts +1 -1
  69. package/dist/types/registry/oauth/cloudflare-workers-ai.d.ts +3 -0
  70. package/dist/types/registry/oauth/cursor.d.ts +10 -2
  71. package/dist/types/registry/oauth/index.d.ts +2 -0
  72. package/dist/types/registry/oauth/snowflake.d.ts +3 -0
  73. package/dist/types/registry/snowflake.d.ts +4 -0
  74. package/dist/types/stream.d.ts +0 -21
  75. package/dist/types/transcription/types.d.ts +2 -1
  76. package/dist/types/types.d.ts +116 -14
  77. package/dist/types/usage.d.ts +2 -0
  78. package/dist/types/utils/anthropic-auth.d.ts +21 -7
  79. package/dist/types/utils/aws-profile.d.ts +5 -0
  80. package/dist/types/utils/block-symbols.d.ts +14 -0
  81. package/dist/types/utils/dsml-leak.d.ts +29 -0
  82. package/dist/types/utils/glyph-codec.d.ts +1 -1
  83. package/dist/types/utils/idle-iterator.d.ts +11 -0
  84. package/dist/types/utils/leaked-thinking-stream.d.ts +1 -1
  85. package/dist/types/utils/resolve-peer.d.ts +2 -0
  86. package/dist/types/utils/retry-wait.d.ts +9 -0
  87. package/dist/types/utils/schema/normalize.d.ts +8 -3
  88. package/dist/types/utils/stream-markup-healing.d.ts +4 -4
  89. package/dist/types/utils/tool-call-arguments.d.ts +8 -0
  90. package/dist/types/utils.d.ts +6 -0
  91. package/package.json +6 -6
  92. package/src/auth/affinity.ts +130 -37
  93. package/src/auth/blocks.ts +94 -15
  94. package/src/auth/cascade.ts +112 -17
  95. package/src/auth/health.ts +3 -2
  96. package/src/auth/oauth.ts +25 -10
  97. package/src/auth/policy.ts +10 -1
  98. package/src/auth/pool.ts +0 -5
  99. package/src/auth/refresh.ts +17 -12
  100. package/src/auth/resets.ts +1 -1
  101. package/src/auth/rotation.ts +8 -2
  102. package/src/auth/select.ts +102 -30
  103. package/src/auth/sqlite-credential-store.ts +119 -49
  104. package/src/auth/store.ts +8 -2
  105. package/src/auth/types.ts +108 -17
  106. package/src/auth/usage-cache.ts +16 -5
  107. package/src/auth/usage.ts +2 -2
  108. package/src/auth-broker/client.ts +7 -4
  109. package/src/auth-broker/discover.ts +6 -5
  110. package/src/auth-broker/refresher.ts +8 -1
  111. package/src/auth-broker/remote-store.ts +200 -62
  112. package/src/auth-broker/server.ts +316 -130
  113. package/src/auth-broker/snapshot-cache.ts +142 -2
  114. package/src/auth-gateway/dispatch.ts +15 -7
  115. package/src/auth-gateway/http.ts +0 -8
  116. package/src/auth-gateway/index.ts +1 -0
  117. package/src/auth-gateway/routes/embeddings.ts +2 -2
  118. package/src/auth-gateway/routes/images.ts +4 -4
  119. package/src/auth-gateway/routes/rerank.ts +2 -2
  120. package/src/auth-gateway/routes/speech.ts +2 -2
  121. package/src/auth-gateway/routes/systemone.ts +22 -14
  122. package/src/auth-gateway/routes/transcriptions.ts +2 -2
  123. package/src/auth-gateway/routes/video.ts +7 -7
  124. package/src/auth-gateway/server.ts +175 -134
  125. package/src/auth-gateway/session-state.ts +51 -9
  126. package/src/auth-gateway/stdio.ts +132 -0
  127. package/src/auth-storage.ts +23 -9
  128. package/src/dialect/deepseek.ts +67 -8
  129. package/src/dialect/gemini.ts +8 -2
  130. package/src/dialect/hermes.ts +8 -2
  131. package/src/dialect/kimi.ts +8 -2
  132. package/src/dialect/qwen-xml.ts +8 -2
  133. package/src/dialect/qwen3.ts +8 -2
  134. package/src/dialect/terminator-wait.ts +42 -0
  135. package/src/env-api-key.ts +78 -0
  136. package/src/error/auth.ts +20 -0
  137. package/src/error/flags.ts +143 -24
  138. package/src/error/rate-limit.ts +8 -6
  139. package/src/images/google-antigravity.ts +0 -1
  140. package/src/images/index.ts +3 -17
  141. package/src/images/openai-hosted.ts +13 -4
  142. package/src/images/openai-images.ts +19 -13
  143. package/src/images/shared.ts +10 -2
  144. package/src/index.ts +2 -1
  145. package/src/judgment/index.ts +2 -1
  146. package/src/judgment/native.ts +333 -0
  147. package/src/judgment/openai-decisions-predicate.md +9 -0
  148. package/src/judgment/openai-decisions.ts +129 -0
  149. package/src/judgment/question-file.ts +90 -0
  150. package/src/judgment/systemone.ts +65 -0
  151. package/src/judgment/text.ts +9 -1
  152. package/src/judgment/types.ts +2 -2
  153. package/src/judgment/wire.ts +42 -0
  154. package/src/provider-details.ts +1 -1
  155. package/src/provider-session-state.ts +2 -2
  156. package/src/providers/amazon-bedrock.ts +19 -8
  157. package/src/providers/anthropic-client.ts +16 -1
  158. package/src/providers/anthropic-state.ts +6 -0
  159. package/src/providers/anthropic.ts +962 -238
  160. package/src/providers/apple-foundation-models.ts +10 -4
  161. package/src/providers/aws-credentials.ts +65 -5
  162. package/src/providers/azure-openai-responses.ts +1 -1
  163. package/src/providers/connect-error-detail.ts +21 -0
  164. package/src/providers/connect-frame.ts +107 -0
  165. package/src/providers/cursor/interaction-query.ts +1 -9
  166. package/src/providers/cursor.ts +590 -133
  167. package/src/providers/devin.ts +68 -58
  168. package/src/providers/factory-droid/gemini.ts +38 -51
  169. package/src/providers/factory-droid.ts +2 -0
  170. package/src/providers/gitlab-duo-workflow.ts +5 -2
  171. package/src/providers/gitlab-duo.ts +1 -0
  172. package/src/providers/google-auth.ts +10 -3
  173. package/src/providers/google-gemini-cli.ts +4 -0
  174. package/src/providers/google-shared.ts +134 -105
  175. package/src/providers/google-vertex.ts +0 -1
  176. package/src/providers/google.ts +1 -1
  177. package/src/providers/inference-headers.ts +19 -0
  178. package/src/providers/mock.ts +4 -0
  179. package/src/providers/ollama.ts +1 -1
  180. package/src/providers/openai-anthropic-shim.ts +1 -0
  181. package/src/providers/openai-codex/request-transformer.ts +16 -11
  182. package/src/providers/openai-codex-responses.ts +201 -76
  183. package/src/providers/openai-completions.ts +12 -2
  184. package/src/providers/openai-configuration-update.ts +54 -15
  185. package/src/providers/openai-responses-wire.ts +1 -55
  186. package/src/providers/openai-responses.ts +437 -33
  187. package/src/providers/openai-shared.ts +267 -72
  188. package/src/providers/pi-native-client.ts +2 -2
  189. package/src/providers/pi-native-server.ts +1 -0
  190. package/src/providers/systemone-server.ts +1 -1
  191. package/src/providers/transcriptions-server.ts +1 -1
  192. package/src/providers/transform-messages.ts +240 -84
  193. package/src/providers/vision-guard.ts +1 -1
  194. package/src/registry/aws.ts +51 -14
  195. package/src/registry/cloudflare-ai-gateway.ts +26 -3
  196. package/src/registry/hooks/api-key.ts +1 -0
  197. package/src/registry/hooks/custom.ts +2 -0
  198. package/src/registry/hooks/env.ts +2 -5
  199. package/src/registry/oauth/callback-server.ts +6 -1
  200. package/src/registry/oauth/cloudflare-ai-gateway.ts +2 -2
  201. package/src/registry/oauth/cloudflare-workers-ai.ts +32 -0
  202. package/src/registry/oauth/cursor.ts +80 -17
  203. package/src/registry/oauth/index.ts +5 -0
  204. package/src/registry/oauth/snowflake.ts +183 -0
  205. package/src/registry/registry.ts +2 -0
  206. package/src/registry/snowflake.ts +149 -0
  207. package/src/stream.ts +85 -107
  208. package/src/transcription/types.ts +2 -1
  209. package/src/types.ts +142 -15
  210. package/src/usage/claude.ts +19 -12
  211. package/src/usage/commandcode.ts +1 -1
  212. package/src/usage/cursor.ts +14 -25
  213. package/src/usage/github-copilot.ts +1 -1
  214. package/src/usage/kimi.ts +1 -1
  215. package/src/usage/minimax-code.ts +8 -1
  216. package/src/usage.ts +8 -0
  217. package/src/utils/anthropic-auth.ts +34 -10
  218. package/src/utils/aws-profile.ts +10 -4
  219. package/src/utils/block-symbols.ts +17 -0
  220. package/src/utils/dsml-leak.ts +109 -0
  221. package/src/utils/empty-completion-retry.ts +2 -3
  222. package/src/utils/glyph-codec.ts +200 -7
  223. package/src/utils/idle-iterator.ts +80 -35
  224. package/src/utils/leaked-thinking-stream.ts +47 -25
  225. package/src/utils/resolve-peer.ts +7 -0
  226. package/src/utils/retry-wait.ts +19 -0
  227. package/src/utils/schema/CONSTRAINTS.md +9 -7
  228. package/src/utils/schema/fields.ts +20 -0
  229. package/src/utils/schema/normalize.ts +65 -23
  230. package/src/utils/schema/wire.ts +3 -3
  231. package/src/utils/stream-markup-healing.ts +4 -4
  232. package/src/utils/thinking-loop.ts +36 -13
  233. package/src/utils/tool-call-arguments.ts +16 -0
  234. package/src/utils/transport-fetch.ts +1 -1
  235. package/src/utils.ts +41 -10
  236. package/dist/types/judgment/typesafe.d.ts +0 -49
  237. package/src/judgment/typesafe.ts +0 -183
@@ -906,60 +906,6 @@ export declare namespace Response {
906
906
  */
907
907
  type: "error";
908
908
  }
909
- /**
910
- * A moderation result produced for the response input or output.
911
- */
912
- interface ModerationResult {
913
- /**
914
- * A dictionary of moderation categories to booleans, True if the input is flagged
915
- * under this category.
916
- */
917
- categories: {
918
- [key: string]: boolean;
919
- };
920
- /**
921
- * Which modalities of input are reflected by the score for each category.
922
- */
923
- category_applied_input_types: {
924
- [key: string]: Array<"text" | "image">;
925
- };
926
- /**
927
- * A dictionary of moderation categories to scores.
928
- */
929
- category_scores: {
930
- [key: string]: number;
931
- };
932
- /**
933
- * A boolean indicating whether the content was flagged by any category.
934
- */
935
- flagged: boolean;
936
- /**
937
- * The moderation model that produced this result.
938
- */
939
- model: string;
940
- /**
941
- * The object type, which was always `moderation_result` for successful moderation
942
- * results.
943
- */
944
- type: "moderation_result";
945
- }
946
- /**
947
- * An error produced while attempting moderation for the response input or output.
948
- */
949
- interface Error {
950
- /**
951
- * The error code.
952
- */
953
- code: string;
954
- /**
955
- * The error message.
956
- */
957
- message: string;
958
- /**
959
- * The object type, which was always `error` for moderation failures.
960
- */
961
- type: "error";
962
- }
963
909
  }
964
910
  }
965
911
  /**
@@ -3506,7 +3452,7 @@ export declare namespace ResponseInputItem {
3506
3452
  }
3507
3453
  /**
3508
3454
  * Changes reasoning effort for subsequent responses without touching the
3509
- * request-level `reasoning.effort` (GPT-6 Astra). Must not be adjacent to
3455
+ * request-level `reasoning.effort` (GPT-6 family). Must not be adjacent to
3510
3456
  * another `configuration_update`.
3511
3457
  */
3512
3458
  interface ConfigurationUpdate {
@@ -16,9 +16,9 @@ export interface OpenAIResponsesOptions extends StreamOptions {
16
16
  /**
17
17
  * Stateful turns: chain via `previous_response_id` + delta input instead of
18
18
  * replaying the full transcript. Forces `store: true` (the platform only
19
- * resolves stored responses). Defaults ON against the official OpenAI API
20
- * and OFF for other Responses endpoints; `PI_OPENAI_STATEFUL` overrides the
21
- * default, and `false` here vetoes everything. Requires `sessionId` +
19
+ * resolves stored responses). Precedence: this option, then
20
+ * `PI_OPENAI_STATEFUL`, then `compat.statefulResponses`, then ON against the
21
+ * official OpenAI API and OFF elsewhere. Requires `sessionId` +
22
22
  * `providerSessionState`. Falls back to a full replay whenever history
23
23
  * mutates or the server reports a stale id.
24
24
  */
@@ -60,8 +60,36 @@ export interface OpenAIResponsesOptions extends StreamOptions {
60
60
  /** Opt-in GPT-5.6+ prompt-cache policy. Unsupported explicit mode fails locally. */
61
61
  promptCache?: OpenAIPromptCacheOptions;
62
62
  }
63
+ /**
64
+ * Poll a stored Responses result until it reaches an adoptable terminal state.
65
+ * 404s, 5xx, and transport failures mean "not yet" (an in-flight run only
66
+ * becomes retrievable once the server finishes it); any other status, a
67
+ * mismatched id, or a failed/cancelled run ends the poll immediately. The
68
+ * whole recovery is bounded by one wall-clock deadline: each request's timeout
69
+ * is clamped to the time left, and no sleep may cross the deadline, so a
70
+ * stalled host cannot hold an already-failed turn past it. Returns the
71
+ * terminal object, or undefined on give-up/abort.
72
+ *
73
+ * @internal Exported for tests.
74
+ */
75
+ export declare function pollOpenAIResponsesResultForCompletion(args: {
76
+ fetchImpl: NonNullable<StreamOptions["fetch"]>;
77
+ url: string;
78
+ headers: Record<string, string>;
79
+ responseId: string;
80
+ signal?: AbortSignal;
81
+ /** Sleep between polls; defaults to a real wait honoring `signal`. */
82
+ wait?: (ms: number, signal?: AbortSignal) => Promise<void>;
83
+ }): Promise<Record<string, unknown> | undefined>;
63
84
  interface OpenAIResponsesProviderSessionState extends ProviderSessionState, OpenAIStrictToolsState, OpenAIReasoningEffortFallbackState {
85
+ /**
86
+ * Replay native history items. Starts false only on connection-bound hosts;
87
+ * `close()` clears it so the next request rebuilds history from message
88
+ * content; the first successful response sets it.
89
+ */
64
90
  nativeHistoryReplayWarmed: boolean;
91
+ /** Bumped by `close()`; a response warms the state only if no close happened since its request started. */
92
+ closeCount: number;
65
93
  /** Stateful `previous_response_id` chain baselines, keyed by baseUrl/model/session. */
66
94
  chains: Map<string, OpenAIResponsesChainState>;
67
95
  /** `configuration_update` effort baselines, keyed by baseUrl/model/session. */
@@ -70,6 +98,7 @@ interface OpenAIResponsesProviderSessionState extends ProviderSessionState, Open
70
98
  /** Wire efforts a `configuration_update` can carry: every real tier, never `none`/null. */
71
99
  type ResponsesStableEffort = Exclude<ReasoningEffort, "none" | null>;
72
100
  interface OpenAIResponsesChainState {
101
+ sessionId: string;
73
102
  /**
74
103
  * Wire params of the last successful turn; never carries
75
104
  * `previous_response_id`.
@@ -85,6 +114,14 @@ interface OpenAIResponsesChainState {
85
114
  /** Set once chaining is judged unsupported for this session (circuit breaker). */
86
115
  disabled: boolean;
87
116
  }
117
+ /**
118
+ * Set the process-wide storage default per provider id, used when a request
119
+ * leaves `storeResponses` unset. Hosts call this from their settings so every
120
+ * request follows the setting, including direct `streamSimple`/`completeSimple`
121
+ * side calls that do not pass per-request options. `PI_MUSE_STORE_RESPONSES`
122
+ * still overrides it.
123
+ */
124
+ export declare function configureProviderStoreResponses(byProvider: Readonly<Record<string, boolean>> | undefined): void;
88
125
  /**
89
126
  * Drop the account-bound half of every retained `openai-responses` record in
90
127
  * `states`: the stateful `previous_response_id` chain baselines.
@@ -27,7 +27,7 @@ export interface OpenAIStrictToolsState {
27
27
  export interface OpenAIRequestSetupModel extends OpenAIModelIdentity {
28
28
  headers?: Record<string, string>;
29
29
  premiumMultiplier?: number;
30
- compat?: Pick<ResolvedOpenAISharedCompat, "promptCacheSessionHeader">;
30
+ compat?: Pick<ResolvedOpenAISharedCompat, "promptCacheSessionHeader" | "sessionHeader">;
31
31
  }
32
32
  /** Cache identity controls shared by OpenAI-family transports. */
33
33
  export interface OpenAICacheOptions {
@@ -76,9 +76,18 @@ export declare function applyOpenAIServiceTier(params: {
76
76
  * resolved request tier. Scoped to `provider: "openai"` (the only standard
77
77
  * Responses biller) so an echoed `service_tier` from an Azure/OpenRouter/Copilot
78
78
  * proxy can never skew those costs.
79
+ *
80
+ * Returns the tier the turn ran on for the caller to record on the message, and
81
+ * counts the premium request the tier bills.
82
+ */
83
+ export declare function applyOpenAIResponsesServiceTierCost(model: Pick<Model, "provider" | "serviceTierCost" | "api" | "identity">, usage: AssistantMessage["usage"], responseServiceTier: unknown, requestServiceTier: ServiceTier | null | undefined): ServiceTier | undefined;
84
+ /**
85
+ * Reconcile token-price estimates with a gateway's authoritative account charge.
86
+ * BYOK turns (`is_byok: true`) price from the provider spend in
87
+ * `cost_details.upstream_inference_cost` plus whatever credits charge
88
+ * OpenRouter reports in `cost` (its BYOK fee is plan-dependent and can be $0),
89
+ * so both are covered.
79
90
  */
80
- export declare function applyOpenAIResponsesServiceTierCost(model: Pick<Model, "provider" | "serviceTierCost">, usage: AssistantMessage["usage"], responseServiceTier: unknown, requestServiceTier: ServiceTier | null | undefined): void;
81
- /** Reconcile token-price estimates with a gateway's authoritative account charge. */
82
91
  export declare function applyProviderReportedCost(model: Pick<Model, "provider">, usage: Usage, rawUsage: unknown): void;
83
92
  export interface OpenAIUsageAccountingInput {
84
93
  promptTokens: number;
@@ -470,6 +479,13 @@ export interface BuildResponsesInputOptions<TApi extends Api> {
470
479
  supportsImageDetailOriginal: boolean;
471
480
  systemRole?: "system" | "developer";
472
481
  nativeHistory?: {
482
+ /**
483
+ * Replay same-provider native history. `false` marks a cold provider
484
+ * session (#489): native items are withheld except remote-compaction
485
+ * history and assistant turns that carry no server-issued state
486
+ * ({@link isColdReplayableResponsesTurn}); other turns are rebuilt from
487
+ * message content.
488
+ */
473
489
  replay: boolean;
474
490
  filterReasoning: boolean;
475
491
  };
@@ -577,12 +593,20 @@ export interface SequentialCutoffSummaryState {
577
593
  export declare function createSequentialCutoffSummaryState(): SequentialCutoffSummaryState;
578
594
  /** Chooses final reasoning text without making sequential-cutoff results disagree with emitted deltas. */
579
595
  export declare function finalizeReasoningThinking(item: ResponseReasoningItem, streamedThinking: string, cutoff?: SequentialCutoffSummaryState): string;
596
+ /**
597
+ * Records whether a finalized reasoning block holds a provider-written summary
598
+ * or the model's own trace, following `finalizeReasoningThinking`'s choice of
599
+ * text: the done item's summary wins, then its `reasoning_text` content, then
600
+ * the streamed deltas, which the summary handlers mark on the block as they
601
+ * append.
602
+ */
603
+ export declare function settleReasoningSummary(item: ResponseReasoningItem, block: ThinkingContent): void;
580
604
  export declare function appendReasoningSummaryTextDelta(item: ResponseReasoningItem, block: ThinkingContent, delta: string, stream: AssistantMessageEventStream, output: AssistantMessage, contentIndex: number, summaryIndex?: number): void;
581
605
  /**
582
606
  * Applies a completed reasoning-summary snapshot, including providers that omit
583
607
  * the preceding summary-part event.
584
608
  */
585
- export declare function applyReasoningSummaryTextDone(item: ResponseReasoningItem, block: ThinkingContent, text: string, summaryIndex: number, stream: AssistantMessageEventStream, output: AssistantMessage, contentIndex: number): void;
609
+ export declare function applyReasoningSummaryTextDone(item: ResponseReasoningItem, block: ThinkingContent, text: string, summaryIndex: number | undefined, stream: AssistantMessageEventStream, output: AssistantMessage, contentIndex: number): void;
586
610
  export declare function appendReasoningSummaryPartDone(item: ResponseReasoningItem, block: ThinkingContent, stream: AssistantMessageEventStream, output: AssistantMessage, contentIndex: number): void;
587
611
  /**
588
612
  * Applies an atomic `response.reasoning_summary_text.done` snapshot.
@@ -606,7 +630,8 @@ export declare function accumulateToolCallArgumentsDelta(block: ResponsesToolCal
606
630
  * Finalize streamed function-call arguments from the authoritative `.done`
607
631
  * payload. The caller owns the `argumentsDone` flag (generic Responses sets it;
608
632
  * Codex's block shape has no such field), so this only rewrites `arguments` and
609
- * drops the transient accumulation fields.
633
+ * drops the transient accumulation fields. A blank payload is not authoritative:
634
+ * it parses the buffered deltas and keeps them so the final item can still win.
610
635
  */
611
636
  export declare function finalizeToolCallArgumentsDone(block: ResponsesToolCallBlock, args: string): void;
612
637
  export declare function accumulateCustomToolCallInputDelta(block: ResponsesToolCallBlock, delta: string, stream: AssistantMessageEventStream, output: AssistantMessage, contentIndex: number): void;
@@ -1,6 +1,6 @@
1
1
  import type { Api, AssistantMessageEventStream as AssistantMessageEventStreamType, Context, Model, SimpleStreamOptions } from "../types.js";
2
2
  /**
3
- * Stream a turn through an `omp auth-gateway` over the pi-native protocol.
3
+ * Stream a turn through an `zetacode auth-gateway` over the pi-native protocol.
4
4
  *
5
5
  * The returned {@link AssistantMessageEventStream} receives each parsed
6
6
  * `AssistantMessageEvent` verbatim from the gateway; the terminal `done` /
@@ -1,4 +1,29 @@
1
1
  import type { Api, AssistantMessage, Message, Model } from "../types.js";
2
+ /**
3
+ * Maximum tool-call id length the strictest replay provider accepts.
4
+ *
5
+ * Anthropic requires `^[a-zA-Z0-9_-]+$` with a 64-char cap; Google and Codex
6
+ * `normalizeToolCallId` implementations cap individual id segments to the same
7
+ * 64-char ceiling. Replacement ids minted here flow back through
8
+ * `convertAnthropicMessages` (and friends) unchanged, so the `_dupN` suffix
9
+ * MUST not push a normalized id past this bound.
10
+ */
11
+ export declare const MAX_TOOL_CALL_ID_LENGTH = 64;
12
+ /**
13
+ * OpenAI Responses-family APIs mint composite tool ids (`call_id|item_id`);
14
+ * opaque Chat Completions ids do not (openai-completions preserves same-model
15
+ * ids verbatim as provider correlation tokens), so ONLY these origins may be
16
+ * canonicalized to their `call_` component for pairing.
17
+ */
18
+ export declare function isResponsesFamilyApi(api: Api | undefined): boolean;
19
+ /**
20
+ * The wire `call_id` component of a (possibly composite) Responses id: the
21
+ * FIRST segment before `|`. A degenerate `|itemId` (empty call half, pipe at
22
+ * index 0) keeps its full id so unrelated empty-half ids never collapse onto
23
+ * one empty-string bucket.
24
+ */
25
+ export declare function responsesCallComponent(id: string): string;
26
+ export declare function appendDuplicateSuffix(originalId: string, suffix: string, maxLength: number): string;
2
27
  /**
3
28
  * Whether a tool-call name cannot belong to any declared tool: missing, empty,
4
29
  * longer than OpenAI's 128-character replay limit, or containing whitespace or
@@ -23,7 +23,7 @@ export declare function isOpenAICompletionsVisionSupported(model: Model<"openai-
23
23
  * guard, as does the OpenRouter chat fallback (`PI_OPENROUTER_RESPONSES=0`,
24
24
  * which dispatches `openrouter` models through `streamOpenAICompletions`);
25
25
  * every other API ships the modalities the model declares. Callers that report
26
- * or gate on the wire (for example the `omp models` table) read this
26
+ * or gate on the wire (for example the `zetacode models` table) read this
27
27
  * predicate; declared capability reads `model.input`.
28
28
  */
29
29
  export declare function sendsImageInputOnWire(model: Model<Api>): boolean;
@@ -0,0 +1,3 @@
1
+ import type { OAuthController } from "./types.js";
2
+ /** Collect the Workers AI API token and account id used by CLI, setup-wizard, and TUI login callers. */
3
+ export declare function loginCloudflareWorkersAi(options: OAuthController): Promise<string>;
@@ -1,3 +1,4 @@
1
+ import type { FetchImpl } from "../../types.js";
1
2
  import type { OAuthController, OAuthCredentials } from "./types.js";
2
3
  export interface CursorAuthParams {
3
4
  verifier: string;
@@ -12,7 +13,14 @@ export declare function pollCursorAuth(uuid: string, verifier: string): Promise<
12
13
  }>;
13
14
  export declare function loginCursor(onAuthUrl: (url: string) => void, onPollStart?: () => void): Promise<OAuthCredentials>;
14
15
  export declare function loginCursorHook(callbacks: OAuthController): Promise<OAuthCredentials>;
15
- export declare function refreshCursorToken(apiKeyOrRefreshToken: string): Promise<OAuthCredentials>;
16
- export declare function refreshCursorHook(credentials: OAuthCredentials): Promise<OAuthCredentials>;
16
+ export declare function refreshCursorToken(refreshToken: string): Promise<OAuthCredentials>;
17
+ export declare function refreshCursorHook(credentials: OAuthCredentials, signal?: AbortSignal): Promise<OAuthCredentials>;
18
+ /** Request headers that present `accessToken` to cursor.com as its user's web session. */
19
+ export declare function cursorSessionHeaders(userId: string, accessToken: string): Record<string, string>;
20
+ /**
21
+ * Email of the Cursor account that owns `accessToken`, read from its cursor.com
22
+ * profile. Undefined when the token names no user or the profile names another.
23
+ */
24
+ export declare function fetchCursorAccountEmail(accessToken: string, fetchImpl?: FetchImpl, signal?: AbortSignal): Promise<string | undefined>;
17
25
  export declare function extractCursorAccessTokenUserId(accessToken: string): string | undefined;
18
26
  export declare function isCursorTokenExpiringSoon(token: string, thresholdSeconds?: number): boolean;
@@ -43,3 +43,5 @@ export declare function getOAuthApiKey(provider: OAuthProvider, credentials: Rec
43
43
  * Get list of OAuth providers.
44
44
  */
45
45
  export declare function getOAuthProviders(): OAuthProviderInfo[];
46
+ /** Provider id that stores `providerId`'s credentials: login aliases (`openai-codex-device`) map to their target (`openai-codex`). */
47
+ export declare function getOAuthCredentialProvider(providerId: string): string;
@@ -0,0 +1,3 @@
1
+ import type { OAuthController, OAuthCredentials } from "./types.js";
2
+ export declare function loginSnowflake(ctrl: OAuthController): Promise<OAuthCredentials>;
3
+ export declare function refreshSnowflakeToken(credentials: OAuthCredentials, signal?: AbortSignal): Promise<OAuthCredentials>;
@@ -0,0 +1,4 @@
1
+ import type { ProviderTransport } from "./build.js";
2
+ /** Normalize account identifiers and Snowsight links without accepting arbitrary credential-receiving hosts. */
3
+ export declare function normalizeSnowflakeAccountUrl(input: string): string;
4
+ export declare const snowflakeTransport: ProviderTransport;
@@ -31,27 +31,6 @@ export declare const __providerInFlightForTesting: {
31
31
  captureStaleLockRelease(provider: string): Promise<(() => Promise<void>) | null>;
32
32
  captureLockDirRelease(provider: string): Promise<(() => Promise<void>) | null>;
33
33
  };
34
- /**
35
- * Get API key for provider from known environment variables, e.g. OPENAI_API_KEY.
36
- *
37
- * Will not return API keys for providers that require OAuth tokens.
38
- * Checks Bun.env, then cwd/.env, then ~/.env.
39
- */
40
- export declare function getEnvApiKey(provider: string): string | undefined;
41
- /**
42
- * Name of the environment variable that backs `getEnvApiKey` for a provider,
43
- * when that provider maps to a single named variable (e.g. `github-copilot` →
44
- * `COPILOT_GITHUB_TOKEN`). Returns undefined for providers whose env fallback
45
- * is computed (multi-var pickers, Vertex ADC / Bedrock probes, …) since no
46
- * single variable name describes the source.
47
- */
48
- export declare function getEnvApiKeyName(provider: string): string | undefined;
49
- /**
50
- * Enumerate every provider that has an env-var fallback for `getEnvApiKey`.
51
- * Used by `zeta-c auth-broker migrate --include-env` to discover env-sourced keys
52
- * that should be uploaded to the broker.
53
- */
54
- export declare function listProvidersWithEnvKey(): string[];
55
34
  export declare function stream<TApi extends Api>(model: Model<TApi>, context: Context, options?: OptionsForApi<TApi>): AssistantMessageEventStream;
56
35
  export declare function complete<TApi extends Api>(model: Model<TApi>, context: Context, options?: OptionsForApi<TApi>): Promise<AssistantMessage>;
57
36
  export declare function streamSimple<TApi extends Api>(model: Model<TApi>, context: Context, options?: SimpleStreamOptions): AssistantMessageEventStream;
@@ -2,7 +2,8 @@ import type { Usage } from "@linxiraos/pi-catalog/types";
2
2
  export type TranscriptionResponseFormat = "json" | "verbose_json";
3
3
  export type TranscriptionTimestampGranularity = "word" | "segment";
4
4
  export interface TranscriptionRequest {
5
- audio: Uint8Array;
5
+ /** Audio bytes. A `Blob`/`File` (e.g. a parsed multipart upload) is sent without copying. */
6
+ audio: Uint8Array | Blob;
6
7
  mimeType: string;
7
8
  fileName?: string;
8
9
  language?: string;
@@ -157,18 +157,31 @@ export declare function shouldSendServiceTier(serviceTier: ServiceTier | null |
157
157
  */
158
158
  export declare function realizesPriorityServiceTier(serviceTier: ServiceTier | null | undefined, model: ServiceTierModel): boolean;
159
159
  /**
160
- * Premium-request weight contributed by a priority request to a provider that
161
- * realizes it and bills extra. Mirrors GitHub Copilot's `premiumRequests`
162
- * accounting so the "premium requests" stat aggregates priority traffic across
163
- * the OpenAI family, direct Anthropic fast mode, and Google priority.
160
+ * Premium-request weight contributed by a request a provider bills above
161
+ * standard. Priority (Fast mode) counts 1 on every provider that realizes it;
162
+ * `ultrafast` counts 1 on the OpenAI family, where it is a premium serving tier
163
+ * (its cost premium is recorded separately in `usage.cost`). Mirrors GitHub
164
+ * Copilot's `premiumRequests` accounting so the "premium requests" stat
165
+ * aggregates premium traffic across the OpenAI family, direct Anthropic fast
166
+ * mode, and Google priority.
164
167
  *
165
- * Returns 1 only when priority is actually realized on the wire for `model`
166
- * (see {@link realizesPriorityServiceTier}) and the provider bills it as a
167
- * premium request. OpenRouter is excluded — it bills per its own pricing, not
168
- * Copilot-premium semantics — as are Bedrock/Vertex Claude, where priority is
169
- * silently dropped.
168
+ * Returns 1 only when the tier is actually realized on the wire for `model`
169
+ * (see {@link realizesPriorityServiceTier} and {@link shouldSendServiceTier})
170
+ * and the provider bills it as a premium request. OpenRouter is excluded — it
171
+ * bills per its own pricing, not Copilot-premium semantics — as are
172
+ * Bedrock/Vertex Claude, where priority is silently dropped.
173
+ *
174
+ * Pass `served: true` when the tier is the one the provider reported serving
175
+ * (an assistant message's {@link AssistantMessage.serviceTier}) rather than a
176
+ * requested setting: realization is then already proven, so the wire gate is
177
+ * skipped and a model without discovery metadata (a stats-backfill row) still
178
+ * counts.
170
179
  */
171
- export declare function getPriorityPremiumRequests(serviceTier: ServiceTier | null | undefined, model: ServiceTierModel): number;
180
+ export declare function getPremiumServiceTierRequests(serviceTier: ServiceTier | null | undefined, model: ServiceTierModel, options?: {
181
+ served?: boolean;
182
+ }): number;
183
+ /** Parse a provider-reported `service_tier` echo into a known tier, or `undefined` for anything else. */
184
+ export declare function parseServiceTier(value: unknown): ServiceTier | undefined;
172
185
  /**
173
186
  * Coerce a persisted service-tier value to a {@link ServiceTierByFamily}. Newer
174
187
  * sessions store the family map directly; legacy sessions stored a single
@@ -178,6 +191,8 @@ export declare function getPriorityPremiumRequests(serviceTier: ServiceTier | nu
178
191
  export declare function coerceServiceTierByFamily(value: unknown): ServiceTierByFamily | undefined;
179
192
  export interface ProviderSessionState {
180
193
  close(): void;
194
+ /** Release one routing session after its final request, preserving shared provider fallbacks. */
195
+ releaseSession?(sessionId: string): void;
181
196
  }
182
197
  export interface ProviderResponseMetadata {
183
198
  status: number;
@@ -215,6 +230,11 @@ export interface CodexCompactionRequestContext extends CodexCompactionMetadata {
215
230
  export interface AnthropicCompactionRequest {
216
231
  /** Custom summarization prompt; replaces the API default entirely when set. */
217
232
  instructions?: string;
233
+ /**
234
+ * Replayed summaries' file metadata due before this time (ms) ends the request;
235
+ * later metadata replays with the retained tail, which the new summary carries.
236
+ */
237
+ filesDueBefore?: number;
218
238
  }
219
239
  /** OpenAI's GPT-5.6+ explicit prompt-cache controls. */
220
240
  export interface OpenAIPromptCacheOptions {
@@ -333,6 +353,16 @@ export interface StreamOptions {
333
353
  * `false` so `previous_response_id` cannot explain a result.
334
354
  */
335
355
  statefulResponses?: boolean;
356
+ /**
357
+ * Store this request's result server-side on hosts that support it
358
+ * (`compat.storeResponses`, e.g. Muse Code), so a stream that drops
359
+ * mid-turn resumes from `GET /responses/{id}` instead of re-running the
360
+ * turn. Privacy: stored runs retain prompts and outputs on the provider.
361
+ * Unset falls back to `PI_MUSE_STORE_RESPONSES`, then the host's
362
+ * `configureProviderStoreResponses` default, else off. Ignored on hosts
363
+ * without the capability.
364
+ */
365
+ storeResponses?: boolean;
336
366
  /**
337
367
  * Disable native reasoning when the caller supplies an external scratchpad.
338
368
  * OpenAI Responses emits `reasoning: { effort: "none" }`; Anthropic and
@@ -344,6 +374,21 @@ export interface StreamOptions {
344
374
  * Providers can use this to persist transport/session state between turns.
345
375
  */
346
376
  providerSessionState?: Map<string, ProviderSessionState>;
377
+ /**
378
+ * Session a side request branches from, so it can read the parent's cached
379
+ * prefix. Providers that keep per-conversation request controls (OpenAI
380
+ * `configuration_update` effort baselines) plan the request against a copy
381
+ * of that session's controls, never changing the parent's state; the Codex
382
+ * backend also routes it with the parent's cache affinity (session headers).
383
+ */
384
+ parentSessionId?: string;
385
+ /**
386
+ * Run at the model's lowest effort where the transport carries the change as
387
+ * a per-message control that keeps the cached prefix (Anthropic per-message
388
+ * effort, OpenAI `configuration_update`). Elsewhere the requested effort
389
+ * applies unchanged: changing request-level reasoning forfeits the cache.
390
+ */
391
+ minimizeEffort?: boolean;
347
392
  /**
348
393
  * Source of user steering a provider may deliver into the response it is
349
394
  * streaming (OpenAI Responses `response.steer` over the Codex WebSocket).
@@ -363,6 +408,8 @@ export interface StreamOptions {
363
408
  * are not covered.
364
409
  */
365
410
  maxInFlightRequests?: Record<string, number>;
411
+ /** @internal Keep the in-flight permit until a provider's bounded terminal drain finishes. */
412
+ waitForTerminalDrain?: boolean;
366
413
  /**
367
414
  * Optional callback for inspecting or replacing provider payloads before sending.
368
415
  * Return undefined to keep the payload unchanged.
@@ -587,6 +634,17 @@ export interface ThinkingContent {
587
634
  thinking: string;
588
635
  thinkingSignature?: string;
589
636
  itemId?: string;
637
+ /**
638
+ * `true`: `thinking` is a provider-written summary of the model's reasoning
639
+ * (OpenAI Responses `summary_text`, Gemini thought summaries). `false`: the
640
+ * wire delivered it as the reasoning itself, not marked as a summary
641
+ * (chat-completions reasoning fields, Responses `reasoning_text`, Devin
642
+ * `thinking`); whether that is the full trace is vouched for per family by
643
+ * the catalog's `portable-reasoning`. Unset when provenance is unknown,
644
+ * including turns recorded before parsers set it. Only `false` blocks
645
+ * replay natively on another host.
646
+ */
647
+ summary?: boolean;
590
648
  }
591
649
  export interface RedactedThinkingContent {
592
650
  type: "redactedThinking";
@@ -820,13 +878,48 @@ export interface AnthropicCompactionPayload {
820
878
  encryptedContent?: string;
821
879
  /**
822
880
  * Harness-appended file metadata (`<files>` section) kept out of the
823
- * byte-identical block. Replayed as a user message after the native block:
824
- * the converter replaces the summary message with the block and skips its
825
- * text, so without this the metadata would be invisible to this provider.
881
+ * byte-identical block. The converter replaces the summary message with the
882
+ * block and skips its text, so it replays this as a user message after the
883
+ * block's retained tail: before the first message created after the summary.
826
884
  */
827
885
  filesText?: string;
886
+ /**
887
+ * File metadata of earlier summaries whose replay position lies inside this
888
+ * summary's retained tail. Retained messages must reach the API unchanged,
889
+ * so each keeps replaying where it did: before the first message created
890
+ * after `after` (the earlier summary's commit time).
891
+ */
892
+ retainedFiles?: AnthropicCompactionFiles[];
893
+ /**
894
+ * Set on summaries whose retained tail replays unchanged: file metadata
895
+ * after the tail, earlier metadata at `retainedFiles`. Summaries persisted
896
+ * without it keep their original layout (metadata after the first retained
897
+ * turn), since later thinking was signed against those bytes.
898
+ */
899
+ exactTail?: true;
828
900
  }
829
- export type ProviderPayload = OpenAIResponsesHistoryPayload | AnthropicMessagePayload | AnthropicCompactionPayload;
901
+ /** File metadata replayed at a fixed point of a natively compacted conversation. */
902
+ export interface AnthropicCompactionFiles {
903
+ text: string;
904
+ /** Replays before the first message created after this time (ms). */
905
+ after: number;
906
+ }
907
+ /**
908
+ * Records Cursor's server wrote into the client's conversation store for one
909
+ * assistant turn: the `rootPromptMessagesJson` entries after the user's message,
910
+ * reasoning signatures and redacted reasoning included. Written and read by the
911
+ * Cursor provider, which sends them back unchanged to the wire model that produced them.
912
+ */
913
+ export interface CursorHistoryPayload {
914
+ type: "cursorHistory";
915
+ /** Wire route the records were written under, as sent (requested model, details id, max mode, parameters). */
916
+ wireRoute: string;
917
+ /** Digest of the turn's opening user message, content and paired tool results when recorded; a rewritten turn rebuilds instead. */
918
+ digest: string;
919
+ /** Record bytes (UTF-8 JSON) in conversation order; each blob id is the SHA-256 of its bytes. */
920
+ records: string[];
921
+ }
922
+ export type ProviderPayload = OpenAIResponsesHistoryPayload | AnthropicMessagePayload | AnthropicCompactionPayload | CursorHistoryPayload;
830
923
  /** Provider-reported rewrite applied to request content before inference. */
831
924
  export interface ProviderInputTransformation {
832
925
  type: string;
@@ -928,6 +1021,15 @@ export interface AssistantMessage {
928
1021
  * other than what was requested.
929
1022
  */
930
1023
  upstreamModel?: string;
1024
+ /**
1025
+ * Service tier the provider reported serving this turn, when the API echoes
1026
+ * one (`response.service_tier`), falling back to the tier the request carried
1027
+ * when the response omits the echo. Absent when the provider reports no tier
1028
+ * or the echo cannot be trusted (proxies). This is the tier the turn actually
1029
+ * ran on, which is what cost, premium-request, and speed accounting key on —
1030
+ * the session's live setting may already have changed.
1031
+ */
1032
+ serviceTier?: ServiceTier;
931
1033
  usage: Usage;
932
1034
  stopReason: StopReason;
933
1035
  stopDetails?: StopDetails | null;
@@ -142,6 +142,8 @@ export interface UsageReport {
142
142
  * explicit fraction > used/limit > percent-unit used > inverted remaining.
143
143
  */
144
144
  export declare function resolveUsedFraction(limit: UsageLimit): number | undefined;
145
+ /** Whether remaining quota is at or below the reserve (both 0..1 fractions). */
146
+ export declare function isWithinUsageReserve(remainingFraction: number, reserveFraction: number): boolean;
145
147
  /**
146
148
  * One recorded usage-limit snapshot: a single limit window of one account at
147
149
  * a point in time. The usage cache itself is latest-snapshot-only; history
@@ -9,6 +9,11 @@ export declare function resolveAnthropicBaseUrlFromEnv(): string | undefined;
9
9
  * Checks if a token is an OAuth token by looking for sk-ant-oat prefix.
10
10
  */
11
11
  export declare function isOAuthToken(apiKey: string): boolean;
12
+ /** Optional request-shaping overrides for an already-resolved Anthropic credential. */
13
+ export interface AnthropicAuthOptions {
14
+ /** Override token detection; false explicitly disables OAuth-style request shaping. */
15
+ isOAuth?: boolean;
16
+ }
12
17
  /**
13
18
  * Build an {@link AnthropicAuthConfig} from an already-resolved API key.
14
19
  *
@@ -17,18 +22,27 @@ export declare function isOAuthToken(apiKey: string): boolean;
17
22
  * env-derived base; pass `undefined` to fall back to FOUNDRY/ANTHROPIC env
18
23
  * resolution and finally `DEFAULT_BASE_URL`.
19
24
  *
20
- * `isOAuth` is derived from the token prefix so the helper stays pure: callers
21
- * never have to thread the OAuth flag through their own resolution logic.
25
+ * `options.isOAuth` defaults to token detection. Pass the selected model's
26
+ * `isOAuth` to match the streaming path, which lets the model override the
27
+ * prefix (custom `anthropic-messages` providers default to OAuth shaping).
22
28
  */
23
- export declare function buildAnthropicAuthConfig(apiKey: string, baseUrl?: string): AnthropicAuthConfig;
29
+ export declare function buildAnthropicAuthConfig(apiKey: string, baseUrl?: string, options?: AnthropicAuthOptions): AnthropicAuthConfig;
30
+ /** Configured headers and fingerprint override policy for Anthropic hosted web search. */
31
+ export interface AnthropicSearchHeaderOptions {
32
+ /** The selected model's configured headers (`ModelRegistry.resolveModelHeaders`). */
33
+ modelHeaders?: Record<string, string>;
34
+ /** The selected model's `compat.allowAnthropicHeaderOverrides`. */
35
+ allowAnthropicHeaderOverrides?: boolean;
36
+ }
24
37
  /**
25
38
  * Builds HTTP headers for Anthropic API requests (search variant).
26
39
  *
27
- * Forwards `ANTHROPIC_CUSTOM_HEADERS` when the resolver deems them applicable
28
- * (Foundry mode, or a non-Anthropic base URL — typically an enterprise
29
- * gateway), matching the streaming path so web search behaves identically.
40
+ * Model headers and `ANTHROPIC_CUSTOM_HEADERS` (when the resolver deems them
41
+ * applicable: Foundry mode, or a non-Anthropic base URL such as an enterprise
42
+ * gateway) go through the same case-insensitive merge and enforced-header
43
+ * filtering as the streaming path, so web search behaves identically.
30
44
  */
31
- export declare function buildAnthropicSearchHeaders(auth: AnthropicAuthConfig): Record<string, string>;
45
+ export declare function buildAnthropicSearchHeaders(auth: AnthropicAuthConfig, options?: AnthropicSearchHeaderOptions): Record<string, string>;
32
46
  /**
33
47
  * Builds the full API URL for Anthropic messages endpoint.
34
48
  */
@@ -9,6 +9,11 @@ export declare function resolveAwsProfile(profile?: string): string;
9
9
  * the AWS SDK's `AWS_SDK_LOAD_CONFIG` opt-in.
10
10
  */
11
11
  export declare function shouldLoadAwsSharedConfig(profile?: string): boolean;
12
+ /** Shared credentials and config file locations, honoring their env overrides. */
13
+ export declare function awsSharedFilePaths(): {
14
+ credentialsPath: string;
15
+ configPath: string;
16
+ };
12
17
  export declare function resolveAwsProfileRegion(profile?: string): string | undefined;
13
18
  /** Region selected by the environment or active shared-config profile. */
14
19
  export declare function resolveAwsAmbientRegion(profile?: string): string | undefined;
@@ -72,6 +72,20 @@ export type DemotedThinkingCarrier = object & {
72
72
  };
73
73
  /** True for text blocks synthesized by cross-model thinking demotion. */
74
74
  export declare function isDemotedThinking(block: DemotedThinkingCarrier | null | undefined): boolean;
75
+ /**
76
+ * Marks a thinking block that `transformMessages` carried natively from
77
+ * another host serving the same model (see `compat/reasoning-carry` in the
78
+ * catalog). Its host-bound signature and item id are gone, so encoders that
79
+ * replay reasoning from stored payloads (Responses) emit a plaintext item for
80
+ * it instead. Symbol-keyed so the marker never persists or reaches the wire.
81
+ */
82
+ export declare const kCarriedReasoning: unique symbol;
83
+ /** Carries the carried-reasoning marker without exposing a string-keyed property. */
84
+ export type CarriedReasoningCarrier = object & {
85
+ [kCarriedReasoning]?: boolean;
86
+ };
87
+ /** True for thinking blocks carried natively from another host of the same model. */
88
+ export declare function isCarriedReasoning(block: CarriedReasoningCarrier | null | undefined): boolean;
75
89
  /**
76
90
  * Marks an Anthropic wire message that was serialized from a source
77
91
  * `role: "user"` message.