@openclaw/ai 2026.9.1-beta.1 → 2026.9.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.
Files changed (88) hide show
  1. package/dist/{anthropic-DI4PZKKB.mjs → anthropic-BDdqdVLK.mjs} +222 -216
  2. package/dist/{anthropic-compaction-replay-nhKaCXu6.mjs → anthropic-compaction-replay-DB2FGLQc.mjs} +160 -68
  3. package/dist/{anthropic-payload-policy-B_0n0enE.d.mts → anthropic-payload-policy-d46X2pR0.d.mts} +28 -4
  4. package/dist/{api-registry-CTd8NzcD.d.mts → api-registry-DWtPjzyn.d.mts} +2 -2
  5. package/dist/{azure-openai-responses-D8dI0ekg.mjs → azure-openai-responses-C5bZRfAP.mjs} +12 -9
  6. package/dist/{number-coercion-H9qHik3g.mjs → base64-CEFBpSkN.mjs} +73 -1
  7. package/dist/{diagnostics-COpOtRwq.mjs → diagnostics-CPeq9F7y.mjs} +5 -1
  8. package/dist/diagnostics-DfFyKeX_.mjs +136 -0
  9. package/dist/{diagnostics-BaTA9eVl.d.mts → diagnostics-DnPnOui6.d.mts} +5 -1
  10. package/dist/diagnostics.d.mts +8 -3
  11. package/dist/diagnostics.mjs +4 -3
  12. package/dist/{env-api-keys-DrgeBuva.mjs → env-api-keys-bktO00EJ.mjs} +2 -15
  13. package/dist/{event-stream-uSMZJ3FA.mjs → event-stream-BgDvQeum.mjs} +3 -9
  14. package/dist/{event-stream-LiXePESD.d.mts → event-stream-BhT5T1Ay.d.mts} +1 -1
  15. package/dist/event-stream-zctLx0yr.d.mts +1 -0
  16. package/dist/event-stream.d.mts +2 -2
  17. package/dist/event-stream.mjs +1 -1
  18. package/dist/{google-Od-LLdVK.mjs → google-4qeuE8iX.mjs} +9 -7
  19. package/dist/{google-shared-Bgr9lFPw.mjs → google-shared-CWeG8RIl.mjs} +27 -23
  20. package/dist/{google-vertex-aerRSXc4.mjs → google-vertex-O9BcnB6X.mjs} +8 -6
  21. package/dist/{host-D51fmkH6.mjs → host-CEvLw30U.mjs} +54 -9
  22. package/dist/{host-DsbPMFU6.d.mts → host-DjzGmdZ2.d.mts} +3 -3
  23. package/dist/index-FnHM2FcI.d.mts +117 -0
  24. package/dist/index.d.mts +10 -11
  25. package/dist/index.mjs +6 -6
  26. package/dist/internal/anthropic.d.mts +59 -55
  27. package/dist/internal/anthropic.mjs +5 -5
  28. package/dist/internal/openai-responses-payload-policy.d.mts +3 -3
  29. package/dist/internal/openai-responses-payload-policy.mjs +2 -3
  30. package/dist/internal/openai.d.mts +66 -64
  31. package/dist/internal/openai.mjs +10 -10
  32. package/dist/internal/retry-after.d.mts +2 -3
  33. package/dist/internal/runtime.d.mts +43 -43
  34. package/dist/internal/runtime.mjs +10 -8
  35. package/dist/internal/shared.d.mts +25 -25
  36. package/dist/internal/shared.mjs +95 -4
  37. package/dist/{mistral-EiHdymeb.mjs → mistral-Tb6oalqH.mjs} +30 -23
  38. package/dist/{openai-chatgpt-responses-DHpF9o1e.mjs → openai-chatgpt-responses-yUXjPNfu.mjs} +76 -137
  39. package/dist/{openai-completions-EFPiUGfS.mjs → openai-completions-BIUV3RDT.mjs} +26 -22
  40. package/dist/{openai-completions-compat-BefmHT26.d.mts → openai-completions-compat-CpjYUArk.d.mts} +5 -5
  41. package/dist/{openai-completions-stream-DUlGwRMz.mjs → openai-completions-stream-BsrBe3Gg.mjs} +103 -96
  42. package/dist/openai-prompt-cache-CGnVB74a.mjs +21 -0
  43. package/dist/openai-prompt-cache-CNoIfHYC.d.mts +16 -0
  44. package/dist/{openai-responses-BogP8OjX.mjs → openai-responses-CCL41ALM.mjs} +15 -14
  45. package/dist/openai-responses-compaction-window-BMVHFOtq.mjs +697 -0
  46. package/dist/{openai-responses-contracts-Dvj_UtPy.d.mts → openai-responses-contracts-rF5DDRNS.d.mts} +23 -6
  47. package/dist/{openai-responses-payload-policy-CNGFT9zr.d.mts → openai-responses-payload-policy-rLRPsSmB.d.mts} +1 -0
  48. package/dist/{openai-responses-prompt-observer-internal-Cd4hJG-S.mjs → openai-responses-prompt-observer-internal-D0bhBfgL.mjs} +4 -18
  49. package/dist/{openai-responses-shared-DJThc6jW.mjs → openai-responses-shared-Bmma_3Qc.mjs} +438 -309
  50. package/dist/{openai-tool-schema-ho-hIkQf.mjs → openai-tool-schema-_pTAJqKF.mjs} +30 -40
  51. package/dist/{provider-error-DDOs_Bz0.mjs → provider-error-9TraxGvt.mjs} +20 -92
  52. package/dist/{provider-options-MdMBLzlU.d.mts → provider-options-Bcc_p-TU.d.mts} +26 -6
  53. package/dist/provider-replay-context-BuSUaAk5.mjs +21 -0
  54. package/dist/{provider-transcript-transform-C01bQ5a3.mjs → provider-transcript-transform-BaMbI1hr.mjs} +1 -1
  55. package/dist/provider-types.d.mts +19 -20
  56. package/dist/providers.d.mts +6 -6
  57. package/dist/providers.mjs +11 -11
  58. package/dist/{reasoning-tag-text-partitioner-5ygO2rZc.mjs → reasoning-tag-text-partitioner-DLCNXki6.mjs} +158 -94
  59. package/dist/rolldown-runtime-BhDjJH2R.mjs +15 -0
  60. package/dist/{sanitize-unicode-DCkltN94.mjs → sanitize-unicode-D6xUvZaS.mjs} +2 -8
  61. package/dist/{simple-options-CFj7x3J4.mjs → simple-options-BjHCCh4v.mjs} +42 -6
  62. package/dist/{src-Bu3FiFAG.mjs → src-2qBGKg8O.mjs} +83 -2
  63. package/dist/{stream-first-event-timeout-MK28puvq.mjs → stream-first-event-timeout-DcNjoFQE.mjs} +1 -1
  64. package/dist/{tool-schema-json-projection-qvTEs5Am.mjs → tool-schema-json-projection-mJhXDcyz.mjs} +21 -31
  65. package/dist/{transport-stream-shared-ljShVIZB.mjs → transport-stream-shared-CZqMhfIw.mjs} +19 -6
  66. package/dist/{transport-stream-shared-rvaCyFYt.d.mts → transport-stream-shared-xnaqxmbP.d.mts} +5 -5
  67. package/dist/{transport-utils-LJ1_rbi-.mjs → transport-utils-7il795_9.mjs} +5 -8
  68. package/dist/transports.d.mts +121 -85
  69. package/dist/transports.mjs +747 -464
  70. package/dist/types-3Lnm-QSJ.d.mts +1 -0
  71. package/dist/{types-DhLoJbFm.d.mts → types-CJ1-Ht7A.d.mts} +55 -19
  72. package/dist/types.d.mts +7 -7
  73. package/dist/types.mjs +5 -5
  74. package/dist/{validation-Dk7q7NMN.d.mts → validation-AKZBDGQd.d.mts} +1 -1
  75. package/dist/{validation-B61OhAio.mjs → validation-CJZtym2g.mjs} +7 -5
  76. package/dist/validation.d.mts +1 -1
  77. package/dist/validation.mjs +1 -1
  78. package/package.json +5 -5
  79. package/dist/anthropic-BECQCNdF.d.mts +0 -98
  80. package/dist/event-stream-BKp4fOt_.d.mts +0 -1
  81. package/dist/index-Qbej8io0.d.mts +0 -3
  82. package/dist/openai-prompt-cache-2uo_1OR1.d.mts +0 -7
  83. package/dist/openai-prompt-cache-mZTCdRPo.mjs +0 -12
  84. package/dist/openai-responses-contracts-QUY12X0B.mjs +0 -233
  85. package/dist/openai-responses-payload-policy-D8EdimYe.mjs +0 -204
  86. package/dist/provider-options-AvldWZt8.mjs +0 -21
  87. package/dist/tls-certificate-errors-DXSpluKI.mjs +0 -93
  88. package/dist/types-GiAjXatj.d.mts +0 -1
@@ -0,0 +1,136 @@
1
+ import { c as normalizeLowercaseStringOrEmpty } from "./utf16-slice-qz3nsy87.mjs";
2
+ import "./provider-error-9TraxGvt.mjs";
3
+ //#region packages/normalization-core/src/error-coercion.ts
4
+ /**
5
+ * Normalizes an unknown thrown value into an Error. Non-Error objects become
6
+ * the `cause` and have their enumerable fields copied so structured details
7
+ * (codes, statuses) survive the coercion.
8
+ */
9
+ function toErrorObject(value, fallbackMessage) {
10
+ if (value instanceof Error) return value;
11
+ if (typeof value === "string") return new Error(value);
12
+ const error = new Error(fallbackMessage, { cause: value });
13
+ if (typeof value === "object" && value !== null || typeof value === "function") Object.assign(error, value);
14
+ return error;
15
+ }
16
+ function extractErrorCode(err) {
17
+ if (!err || typeof err !== "object") return;
18
+ const code = err.code;
19
+ if (typeof code === "string") return code;
20
+ if (typeof code === "number") return String(code);
21
+ }
22
+ function readErrorName(err) {
23
+ if (!err || typeof err !== "object") return "";
24
+ const name = err.name;
25
+ return typeof name === "string" ? name : "";
26
+ }
27
+ function collectErrorGraphCandidates(err, resolveNested) {
28
+ const queue = [err];
29
+ const seen = /* @__PURE__ */ new Set();
30
+ const candidates = [];
31
+ while (queue.length > 0) {
32
+ const current = queue.shift();
33
+ if (current == null || seen.has(current)) continue;
34
+ seen.add(current);
35
+ candidates.push(current);
36
+ if (!current || typeof current !== "object" || !resolveNested) continue;
37
+ for (const nested of resolveNested(current)) if (nested != null && !seen.has(nested)) queue.push(nested);
38
+ }
39
+ return candidates;
40
+ }
41
+ function extractErrorCodeOrErrno(err) {
42
+ const code = extractErrorCode(err);
43
+ if (code) return code.trim().toUpperCase();
44
+ if (!err || typeof err !== "object") return;
45
+ const errno = err.errno;
46
+ if (typeof errno === "string" && errno.trim()) return errno.trim().toUpperCase();
47
+ if (typeof errno === "number" && Number.isFinite(errno)) return String(errno);
48
+ }
49
+ function collectNestedErrorCandidates(err) {
50
+ return collectErrorGraphCandidates(err, (current) => {
51
+ const nested = [
52
+ current.cause,
53
+ current.reason,
54
+ current.original,
55
+ current.error,
56
+ current.data
57
+ ];
58
+ if (Array.isArray(current.errors)) nested.push(...current.errors);
59
+ return nested;
60
+ });
61
+ }
62
+ //#endregion
63
+ //#region packages/ai/src/utils/retryable-network-errors.ts
64
+ const TRANSIENT_NETWORK_CODES = /* @__PURE__ */ new Set([
65
+ "ECONNRESET",
66
+ "ECONNREFUSED",
67
+ "ENOTFOUND",
68
+ "ETIMEDOUT",
69
+ "ESOCKETTIMEDOUT",
70
+ "ECONNABORTED",
71
+ "EPIPE",
72
+ "ENETDOWN",
73
+ "EHOSTUNREACH",
74
+ "ENETUNREACH",
75
+ "EADDRNOTAVAIL",
76
+ "EAI_AGAIN",
77
+ "UND_ERR_CONNECT_TIMEOUT",
78
+ "UND_ERR_DNS_RESOLVE_FAILED",
79
+ "UND_ERR_CONNECT",
80
+ "UND_ERR_SOCKET",
81
+ "UND_ERR_HEADERS_TIMEOUT",
82
+ "UND_ERR_BODY_TIMEOUT",
83
+ "ERR_HTTP2_INVALID_SESSION",
84
+ "EPROTO",
85
+ "ERR_SSL_WRONG_VERSION_NUMBER",
86
+ "ERR_SSL_PROTOCOL_RETURNED_AN_ERROR"
87
+ ]);
88
+ const TRANSIENT_NETWORK_ERROR_NAMES = /* @__PURE__ */ new Set([
89
+ "AbortError",
90
+ "ConnectTimeoutError",
91
+ "HeadersTimeoutError",
92
+ "BodyTimeoutError",
93
+ "TimeoutError"
94
+ ]);
95
+ const TRANSIENT_NETWORK_MESSAGE_CODE_RE = /\b(ECONNRESET|ECONNREFUSED|ENOTFOUND|ETIMEDOUT|ESOCKETTIMEDOUT|ECONNABORTED|EPIPE|ENETDOWN|EHOSTUNREACH|ENETUNREACH|EADDRNOTAVAIL|EAI_AGAIN|EPROTO|UND_ERR_CONNECT_TIMEOUT|UND_ERR_DNS_RESOLVE_FAILED|UND_ERR_CONNECT|UND_ERR_SOCKET|UND_ERR_HEADERS_TIMEOUT|UND_ERR_BODY_TIMEOUT|ERR_HTTP2_INVALID_SESSION)\b/i;
96
+ const TRANSIENT_NETWORK_MESSAGE_SNIPPETS = [
97
+ "getaddrinfo",
98
+ "socket hang up",
99
+ "client network socket disconnected before secure tls connection was established",
100
+ "network error",
101
+ "network is unreachable",
102
+ "temporary failure in name resolution",
103
+ "upstream connect error",
104
+ "disconnect/reset before headers",
105
+ "tlsv1 alert",
106
+ "ssl routines",
107
+ "packet length too long",
108
+ "write eproto"
109
+ ];
110
+ const RETRYABLE_CONNECTION_ERROR_CODE_RE = /\b(?:ECONNRESET|ECONNREFUSED|ETIMEDOUT|EPIPE|EHOSTUNREACH|ENETUNREACH|EAI_AGAIN|UND_ERR_SOCKET)\b/i;
111
+ function isWrappedFetchFailedMessage(message) {
112
+ if (message === "fetch failed") return true;
113
+ return /:\s*fetch failed$/.test(message);
114
+ }
115
+ function hasRetryableConnectionErrorCode(message) {
116
+ return RETRYABLE_CONNECTION_ERROR_CODE_RE.test(message);
117
+ }
118
+ /** Returns true when any nested error proves a transient network failure. */
119
+ function isTransientNetworkError(err) {
120
+ if (!err) return false;
121
+ for (const candidate of collectNestedErrorCandidates(err)) {
122
+ const code = extractErrorCodeOrErrno(candidate);
123
+ if (code && TRANSIENT_NETWORK_CODES.has(code)) return true;
124
+ const name = readErrorName(candidate);
125
+ if (name && TRANSIENT_NETWORK_ERROR_NAMES.has(name)) return true;
126
+ if (!candidate || typeof candidate !== "object") continue;
127
+ const message = normalizeLowercaseStringOrEmpty(candidate.message);
128
+ if (!message) continue;
129
+ if (TRANSIENT_NETWORK_MESSAGE_CODE_RE.test(message)) return true;
130
+ if (isWrappedFetchFailedMessage(message)) return true;
131
+ if (TRANSIENT_NETWORK_MESSAGE_SNIPPETS.some((snippet) => message.includes(snippet))) return true;
132
+ }
133
+ return false;
134
+ }
135
+ //#endregion
136
+ export { isTransientNetworkError as n, toErrorObject as r, hasRetryableConnectionErrorCode as t };
@@ -11,6 +11,10 @@ interface AssistantMessageDiagnostic {
11
11
  error?: DiagnosticErrorInfo;
12
12
  details?: Record<string, unknown>;
13
13
  }
14
+ /** True when the provider explicitly refused the request payload. */
15
+ declare function isProviderRefusalAssistantError(message: {
16
+ diagnostics?: AssistantMessageDiagnostic[];
17
+ } | null | undefined): boolean;
14
18
  /** Formats arbitrary thrown values into diagnostic-safe text. */
15
19
  declare function formatThrownValue(value: unknown): string;
16
20
  /** Extracts serializable diagnostic error fields from Error and non-Error throws. */
@@ -22,4 +26,4 @@ declare function appendAssistantMessageDiagnostic(message: {
22
26
  diagnostics?: AssistantMessageDiagnostic[];
23
27
  }, diagnostic: AssistantMessageDiagnostic): void;
24
28
  //#endregion
25
- export { extractDiagnosticError as a, createAssistantMessageDiagnostic as i, DiagnosticErrorInfo as n, formatThrownValue as o, appendAssistantMessageDiagnostic as r, AssistantMessageDiagnostic as t };
29
+ export { extractDiagnosticError as a, createAssistantMessageDiagnostic as i, DiagnosticErrorInfo as n, formatThrownValue as o, appendAssistantMessageDiagnostic as r, isProviderRefusalAssistantError as s, AssistantMessageDiagnostic as t };
@@ -1,4 +1,4 @@
1
- import { a as extractDiagnosticError, i as createAssistantMessageDiagnostic, n as DiagnosticErrorInfo, o as formatThrownValue, r as appendAssistantMessageDiagnostic, t as AssistantMessageDiagnostic } from "./diagnostics-BaTA9eVl.mjs";
1
+ import { a as extractDiagnosticError, i as createAssistantMessageDiagnostic, n as DiagnosticErrorInfo, o as formatThrownValue, r as appendAssistantMessageDiagnostic, s as isProviderRefusalAssistantError, t as AssistantMessageDiagnostic } from "./diagnostics-DnPnOui6.mjs";
2
2
  import { n as ProviderErrorRedactor, r as configureProviderErrorRedactor } from "./provider-error-CzNw4BWX.mjs";
3
3
  //#region packages/ai/src/utils/credential-redaction.d.ts
4
4
  type DiagnosticMediaField = {
@@ -16,9 +16,14 @@ type DiagnosticProjectionPolicy = {
16
16
  kind: "redacted";
17
17
  }>) => Record<string, unknown>;
18
18
  };
19
- declare function projectDiagnosticValue(value: unknown, policy?: DiagnosticProjectionPolicy, seen?: WeakSet<object>, mediaPayload?: boolean, state?: {
19
+ export declare function projectDiagnosticValue(value: unknown, policy?: DiagnosticProjectionPolicy, seen?: WeakSet<object>, mediaPayload?: boolean, state?: {
20
20
  changed: boolean;
21
21
  nodesRemaining: number;
22
22
  }): unknown;
23
23
  //#endregion
24
- export { AssistantMessageDiagnostic, DiagnosticErrorInfo, type DiagnosticProjectionPolicy, type ProviderErrorRedactor, appendAssistantMessageDiagnostic, configureProviderErrorRedactor, createAssistantMessageDiagnostic, extractDiagnosticError, formatThrownValue, projectDiagnosticValue };
24
+ //#region packages/ai/src/utils/retryable-network-errors.d.ts
25
+ export declare function hasRetryableConnectionErrorCode(message: string): boolean;
26
+ /** Returns true when any nested error proves a transient network failure. */
27
+ export declare function isTransientNetworkError(err: unknown): boolean;
28
+ //#endregion
29
+ export { AssistantMessageDiagnostic, DiagnosticErrorInfo, type DiagnosticProjectionPolicy, type ProviderErrorRedactor, appendAssistantMessageDiagnostic, configureProviderErrorRedactor, createAssistantMessageDiagnostic, extractDiagnosticError, formatThrownValue, isProviderRefusalAssistantError };
@@ -1,3 +1,4 @@
1
- import { i as formatThrownValue, n as createAssistantMessageDiagnostic, r as extractDiagnosticError, t as appendAssistantMessageDiagnostic } from "./diagnostics-COpOtRwq.mjs";
2
- import { r as projectDiagnosticValue, t as configureProviderErrorRedactor } from "./provider-error-DDOs_Bz0.mjs";
3
- export { appendAssistantMessageDiagnostic, configureProviderErrorRedactor, createAssistantMessageDiagnostic, extractDiagnosticError, formatThrownValue, projectDiagnosticValue };
1
+ import { a as isProviderRefusalAssistantError, i as formatThrownValue, n as createAssistantMessageDiagnostic, r as extractDiagnosticError, t as appendAssistantMessageDiagnostic } from "./diagnostics-CPeq9F7y.mjs";
2
+ import { r as projectDiagnosticValue, t as configureProviderErrorRedactor } from "./provider-error-9TraxGvt.mjs";
3
+ import { n as isTransientNetworkError, t as hasRetryableConnectionErrorCode } from "./diagnostics-DfFyKeX_.mjs";
4
+ export { appendAssistantMessageDiagnostic, configureProviderErrorRedactor, createAssistantMessageDiagnostic, extractDiagnosticError, formatThrownValue, hasRetryableConnectionErrorCode, isProviderRefusalAssistantError, isTransientNetworkError, projectDiagnosticValue };
@@ -1,17 +1,4 @@
1
- import { createRequire } from "node:module";
2
- //#region \0rolldown/runtime.js
3
- var __defProp = Object.defineProperty;
4
- var __exportAll = (all, no_symbols) => {
5
- let target = {};
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: true
9
- });
10
- if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
11
- return target;
12
- };
13
- var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
14
- //#endregion
1
+ import { n as __require } from "./rolldown-runtime-BhDjJH2R.mjs";
15
2
  //#region packages/ai/src/env-api-keys.ts
16
3
  let existsSync = null;
17
4
  let homedir = null;
@@ -169,4 +156,4 @@ function getEnvApiKey(provider) {
169
156
  }
170
157
  }
171
158
  //#endregion
172
- export { getEnvApiKey as n, __exportAll as r, findEnvKeys as t };
159
+ export { getEnvApiKey as n, findEnvKeys as t };
@@ -9,17 +9,10 @@ var EventStream = class {
9
9
  this.resultSettled = false;
10
10
  this.isComplete = isComplete;
11
11
  this.extractResult = extractResult;
12
- const resolvers = [];
13
- const rejecters = [];
14
12
  this.finalResultPromise = new Promise((resolve, reject) => {
15
- resolvers.push(resolve);
16
- rejecters.push(reject);
13
+ this.resolveFinalResult = resolve;
14
+ this.rejectFinalResult = reject;
17
15
  });
18
- const resolveFinalResult = resolvers.at(0);
19
- const rejectFinalResult = rejecters.at(0);
20
- if (!resolveFinalResult || !rejectFinalResult) throw new Error("event stream result promise did not initialize its resolver");
21
- this.resolveFinalResult = resolveFinalResult;
22
- this.rejectFinalResult = rejectFinalResult;
23
16
  }
24
17
  push(event) {
25
18
  if (this.done) return;
@@ -57,6 +50,7 @@ var EventStream = class {
57
50
  async *[Symbol.asyncIterator]() {
58
51
  while (true) if (this.queueHead < this.queue.length) {
59
52
  const event = this.queue[this.queueHead];
53
+ this.queue[this.queueHead] = void 0;
60
54
  this.queueHead += 1;
61
55
  if (this.queueHead >= 1024 && this.queueHead * 2 >= this.queue.length) {
62
56
  this.queue = this.queue.slice(this.queueHead);
@@ -1,4 +1,4 @@
1
- import { a as AssistantMessage, o as AssistantMessageEvent, s as AssistantMessageEventStreamContract } from "./types-DhLoJbFm.mjs";
1
+ import { a as AssistantMessage, o as AssistantMessageEvent, s as AssistantMessageEventStreamContract } from "./types-CJ1-Ht7A.mjs";
2
2
  //#region packages/llm-core/src/utils/event-stream.d.ts
3
3
  /** Generic async-iterable event stream with a separately awaited final result. */
4
4
  declare class EventStream<T, R = T> implements AsyncIterable<T> {
@@ -0,0 +1 @@
1
+ import "./event-stream-BhT5T1Ay.mjs";
@@ -1,3 +1,3 @@
1
- import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-LiXePESD.mjs";
2
- import "./event-stream-BKp4fOt_.mjs";
1
+ import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-BhT5T1Ay.mjs";
2
+ import "./event-stream-zctLx0yr.mjs";
3
3
  export { AssistantMessageEventStream, EventStream, createAssistantMessageEventStream };
@@ -1,2 +1,2 @@
1
- import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-uSMZJ3FA.mjs";
1
+ import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-BgDvQeum.mjs";
2
2
  export { AssistantMessageEventStream, EventStream, createAssistantMessageEventStream };
@@ -1,17 +1,18 @@
1
- import { n as getEnvApiKey } from "./env-api-keys-DrgeBuva.mjs";
2
- import { t as AssistantMessageEventStream } from "./event-stream-uSMZJ3FA.mjs";
3
- import { n as getAiTransportHost, r as resolveAiTransportHeaderSentinels } from "./host-D51fmkH6.mjs";
4
- import { n as buildBaseOptions } from "./simple-options-CFj7x3J4.mjs";
5
- import { i as runGoogleGenerateContentLifecycle, n as buildGoogleSimpleThinking, r as createGoogleAssistantOutput, t as buildGoogleGenerateContentParams } from "./google-shared-Bgr9lFPw.mjs";
1
+ import { t as AssistantMessageEventStream } from "./event-stream-BgDvQeum.mjs";
2
+ import { n as getAiTransportHost, r as resolveAiTransportHeaderSentinels } from "./host-CEvLw30U.mjs";
3
+ import { n as buildBaseOptions } from "./simple-options-BjHCCh4v.mjs";
4
+ import { n as getEnvApiKey } from "./env-api-keys-bktO00EJ.mjs";
5
+ import { i as runGoogleGenerateContentLifecycle, n as buildGoogleSimpleThinking, r as createGoogleAssistantOutput, t as buildGoogleGenerateContentParams } from "./google-shared-CWeG8RIl.mjs";
6
6
  import { GoogleGenAI } from "@google/genai";
7
7
  //#region packages/ai/src/providers/google.ts
8
8
  let toolCallCounter = 0;
9
9
  const streamGoogle = (model, context, options) => {
10
10
  const stream = new AssistantMessageEventStream();
11
+ const output = createGoogleAssistantOutput(model, "google-generative-ai");
11
12
  runGoogleGenerateContentLifecycle({
12
13
  stream,
13
14
  model,
14
- output: createGoogleAssistantOutput(model, "google-generative-ai"),
15
+ output,
15
16
  options,
16
17
  createClient: () => {
17
18
  return createClient(model, options?.apiKey || getEnvApiKey(model.provider) || "", options?.headers);
@@ -43,8 +44,9 @@ function createClient(model, apiKey, optionsHeaders) {
43
44
  ...model.headers,
44
45
  ...optionsHeaders
45
46
  });
47
+ const resolvedApiKey = apiKey ? getAiTransportHost().resolveSecretSentinel(apiKey) : void 0;
46
48
  return new GoogleGenAI({
47
- apiKey: apiKey ? getAiTransportHost().resolveSecretSentinel(apiKey) : void 0,
49
+ apiKey: resolvedApiKey,
48
50
  httpOptions: Object.keys(httpOptions).length > 0 ? httpOptions : void 0
49
51
  });
50
52
  }
@@ -1,9 +1,10 @@
1
- import { i as clampThinkingLevel, r as calculateCost, t as sanitizeSurrogates } from "./sanitize-unicode-DCkltN94.mjs";
2
- import { a as describeToolResultMediaPlaceholder, c as extractToolResultText, d as isImageWithMediaPayload } from "./host-D51fmkH6.mjs";
3
- import { f as sortPromptCacheToolsByName, l as stripSystemPromptCacheBoundary } from "./simple-options-CFj7x3J4.mjs";
4
- import { _ as transportAbortError, n as coerceTransportToolCallArguments, p as notifyProviderStreamOpened, t as assignTransportErrorDetails } from "./transport-stream-shared-ljShVIZB.mjs";
1
+ import { i as clampThinkingLevel, r as calculateCost, t as sanitizeSurrogates } from "./sanitize-unicode-D6xUvZaS.mjs";
2
+ import { a as describeToolResultMediaPlaceholder, c as extractToolResultText, d as isImageWithMediaPayload } from "./host-CEvLw30U.mjs";
3
+ import { d as stripSystemPromptCacheBoundary, m as sortPromptCacheToolsByName } from "./simple-options-BjHCCh4v.mjs";
4
+ import { _ as transportAbortError, n as coerceTransportToolCallArguments, p as notifyProviderStreamOpened, t as assignTransportErrorDetails } from "./transport-stream-shared-CZqMhfIw.mjs";
5
+ import { t as notifyLlmRequestActivity } from "./llm-request-activity-BjtkplhG.mjs";
5
6
  import { t as googleFlashSupportsMinimalThinking } from "./google-thinking-level-C-V3tecN.mjs";
6
- import { t as transformProviderMessages } from "./provider-transcript-transform-C01bQ5a3.mjs";
7
+ import { t as transformProviderMessages } from "./provider-transcript-transform-BaMbI1hr.mjs";
7
8
  import { FinishReason, FunctionCallingConfigMode, ThinkingLevel } from "@google/genai";
8
9
  //#region packages/ai/src/providers/google-shared.ts
9
10
  /**
@@ -94,25 +95,26 @@ function convertMessages(model, context) {
94
95
  };
95
96
  for (const msg of transformedMessages) {
96
97
  if (msg.role !== "toolResult") flushToolResultRun();
97
- if (msg.role === "user") if (typeof msg.content === "string") contents.push({
98
- role: "user",
99
- parts: [{ text: sanitizeSurrogates(msg.content) || " " }]
100
- });
101
- else {
102
- const parts = msg.content.map((item) => {
103
- if (item.type === "text") return { text: sanitizeSurrogates(item.text) || " " };
104
- return { inlineData: {
105
- mimeType: item.mimeType,
106
- data: item.data
107
- } };
108
- });
109
- if (parts.length === 0) parts.push({ text: " " });
110
- contents.push({
98
+ if (msg.role === "user") {
99
+ if (typeof msg.content === "string") contents.push({
111
100
  role: "user",
112
- parts
101
+ parts: [{ text: sanitizeSurrogates(msg.content) || " " }]
113
102
  });
114
- }
115
- else if (msg.role === "assistant") {
103
+ else {
104
+ const parts = msg.content.map((item) => {
105
+ if (item.type === "text") return { text: sanitizeSurrogates(item.text) || " " };
106
+ return { inlineData: {
107
+ mimeType: item.mimeType,
108
+ data: item.data
109
+ } };
110
+ });
111
+ if (parts.length === 0) parts.push({ text: " " });
112
+ contents.push({
113
+ role: "user",
114
+ parts
115
+ });
116
+ }
117
+ } else if (msg.role === "assistant") {
116
118
  const parts = [];
117
119
  let sawFunctionCall = false;
118
120
  const isSameProviderAndModel = msg.provider === model.provider && msg.api === model.api && msg.model === model.id;
@@ -265,7 +267,8 @@ async function runGoogleGenerateContentLifecycle(params) {
265
267
  });
266
268
  } catch (error) {
267
269
  for (const block of output.content) if ("index" in block) delete block.index;
268
- assignTransportErrorDetails(output, options?.signal?.aborted ? transportAbortError(options.signal) : error, options?.signal);
270
+ const failure = options?.signal?.aborted ? transportAbortError(options.signal) : error;
271
+ assignTransportErrorDetails(output, failure, options?.signal);
269
272
  stream.push({
270
273
  type: "error",
271
274
  reason: output.stopReason === "aborted" ? "aborted" : "error",
@@ -457,6 +460,7 @@ async function consumeGoogleGenerateContentStream(params) {
457
460
  currentBlock = null;
458
461
  };
459
462
  for await (const chunk of params.chunks) {
463
+ notifyLlmRequestActivity(params.signal);
460
464
  params.output.responseId ||= chunk.responseId;
461
465
  const responseModel = chunk.modelVersion?.trim();
462
466
  if (responseModel && params.model.id.replace(GOOGLE_MODEL_RESOURCE_PREFIX, "") !== responseModel.replace(GOOGLE_MODEL_RESOURCE_PREFIX, "")) params.output.responseModel ||= responseModel;
@@ -1,8 +1,8 @@
1
- import { t as AssistantMessageEventStream } from "./event-stream-uSMZJ3FA.mjs";
1
+ import { t as AssistantMessageEventStream } from "./event-stream-BgDvQeum.mjs";
2
2
  import { d as normalizeOptionalString } from "./utf16-slice-qz3nsy87.mjs";
3
- import { n as getAiTransportHost, r as resolveAiTransportHeaderSentinels } from "./host-D51fmkH6.mjs";
4
- import { n as buildBaseOptions } from "./simple-options-CFj7x3J4.mjs";
5
- import { i as runGoogleGenerateContentLifecycle, n as buildGoogleSimpleThinking, r as createGoogleAssistantOutput, t as buildGoogleGenerateContentParams } from "./google-shared-Bgr9lFPw.mjs";
3
+ import { n as getAiTransportHost, r as resolveAiTransportHeaderSentinels } from "./host-CEvLw30U.mjs";
4
+ import { n as buildBaseOptions } from "./simple-options-BjHCCh4v.mjs";
5
+ import { i as runGoogleGenerateContentLifecycle, n as buildGoogleSimpleThinking, r as createGoogleAssistantOutput, t as buildGoogleGenerateContentParams } from "./google-shared-CWeG8RIl.mjs";
6
6
  import { GoogleGenAI, ResourceScope } from "@google/genai";
7
7
  //#region packages/ai/src/providers/google-vertex.ts
8
8
  const API_VERSION = "v1";
@@ -10,10 +10,11 @@ const GCP_VERTEX_CREDENTIALS_MARKER = "gcp-vertex-credentials";
10
10
  let toolCallCounter = 0;
11
11
  const streamGoogleVertex = (model, context, options) => {
12
12
  const stream = new AssistantMessageEventStream();
13
+ const output = createGoogleAssistantOutput(model, "google-vertex");
13
14
  runGoogleGenerateContentLifecycle({
14
15
  stream,
15
16
  model,
16
- output: createGoogleAssistantOutput(model, "google-vertex"),
17
+ output,
17
18
  options,
18
19
  createClient: () => {
19
20
  const apiKey = resolveApiKey(options);
@@ -44,9 +45,10 @@ function createClient(model, project, location, optionsHeaders) {
44
45
  });
45
46
  }
46
47
  function createClientWithApiKey(model, apiKey, optionsHeaders) {
48
+ const resolvedApiKey = getAiTransportHost().resolveSecretSentinel(apiKey);
47
49
  return new GoogleGenAI({
48
50
  vertexai: true,
49
- apiKey: getAiTransportHost().resolveSecretSentinel(apiKey),
51
+ apiKey: resolvedApiKey,
50
52
  apiVersion: API_VERSION,
51
53
  httpOptions: buildHttpOptions(model, optionsHeaders)
52
54
  });
@@ -1,6 +1,6 @@
1
- import { a as requiresClaudeMandatoryAdaptiveThinking, c as resolveClaudeMythos5ModelIdentity, d as resolveClaudeSonnet5ModelIdentity, g as supportsClaudeNativeXhighEffort, h as supportsClaudeNativeMaxEffort, i as requiresClaudeDefaultSampling, l as resolveClaudeNativeThinkingLevelMap, o as resolveClaudeFable5ModelIdentity, u as resolveClaudeOpus5ModelIdentity } from "./src-Bu3FiFAG.mjs";
1
+ import { b as supportsClaudeNativeXhighEffort, c as requiresClaudeDefaultSampling, f as resolveClaudeMythos5ModelIdentity, h as resolveClaudeSonnet5ModelIdentity, l as requiresClaudeMandatoryAdaptiveThinking, m as resolveClaudeOpus5ModelIdentity, p as resolveClaudeNativeThinkingLevelMap, u as resolveClaudeFable5ModelIdentity, y as supportsClaudeNativeMaxEffort } from "./src-2qBGKg8O.mjs";
2
2
  import { c as normalizeLowercaseStringOrEmpty, o as isRecord, t as truncateUtf16Safe } from "./utf16-slice-qz3nsy87.mjs";
3
- import { i as clampThinkingLevel, t as sanitizeSurrogates } from "./sanitize-unicode-DCkltN94.mjs";
3
+ import { i as clampThinkingLevel, t as sanitizeSurrogates } from "./sanitize-unicode-D6xUvZaS.mjs";
4
4
  //#region packages/ai/src/providers/anthropic-model-contract.ts
5
5
  const ANTHROPIC_CLAUDE_CODE_VERSION = "2.1.75";
6
6
  const ANTHROPIC_CLAUDE_CODE_BILLING_SYSTEM_BLOCK = `x-anthropic-billing-header: cc_version=${ANTHROPIC_CLAUDE_CODE_VERSION}; cc_entrypoint=sdk-cli;`;
@@ -107,6 +107,20 @@ function resolveReplayModelBoundIdentity(ref) {
107
107
  const sonnetIdentity = resolveClaudeSonnet5ModelIdentity(modelRef);
108
108
  return sonnetIdentity ? `sonnet:${sonnetIdentity}` : void 0;
109
109
  }
110
+ /**
111
+ * Fable 5.1 reads thinking from every earlier Claude generation (verified live:
112
+ * Opus 5, Sonnet 5, Opus 4.8 replay with no drops), while the API silently
113
+ * drops anything it cannot read. Moving onto it therefore keeps prior reasoning;
114
+ * every other cross-identity move, including unregistered Mythos targets, is
115
+ * still dropped here until its replay contract is proven separately.
116
+ */
117
+ function readsPriorClaudeThinking(targetIdentity) {
118
+ return targetIdentity !== void 0 && /^fable:claude-fable-5-1(?=$|[^a-z0-9])/.test(targetIdentity);
119
+ }
120
+ function isClaudeReplaySource(ref) {
121
+ const modelId = hasConcreteResponseModel(ref) ? ref.responseModelId : ref.modelId;
122
+ return /(?:^|[-/])claude-/.test(normalizeModelId(modelId));
123
+ }
110
124
  function resolveModelBoundThinkingReplayMode(params) {
111
125
  const sourceApi = normalizeApi(params.source.api);
112
126
  const targetApi = normalizeApi(params.target.api);
@@ -114,6 +128,7 @@ function resolveModelBoundThinkingReplayMode(params) {
114
128
  const targetIdentity = resolveReplayModelBoundIdentity(params.target);
115
129
  const sameRoute = normalizeLowercaseStringOrEmpty(params.source.provider) === normalizeLowercaseStringOrEmpty(params.target.provider) && sourceApi === targetApi && normalizeModelId(params.source.modelId) === normalizeModelId(params.target.modelId);
116
130
  if (!sourceIdentity && !targetIdentity) return "default";
131
+ if (sourceApi === targetApi && readsPriorClaudeThinking(targetIdentity) && isClaudeReplaySource(params.source)) return "preserve";
117
132
  if (!sourceIdentity && !hasConcreteResponseModel(params.source) && targetIdentity && sameRoute) return "preserve";
118
133
  return sourceApi === targetApi && sourceIdentity === targetIdentity ? "preserve" : "drop";
119
134
  }
@@ -240,9 +255,9 @@ function extractToolResultText(blocks, options) {
240
255
  }
241
256
  if (explicitTexts.length > 0) {
242
257
  const text = (options?.includeStructured ? [...explicitTexts, ...structuredTexts] : explicitTexts).join("\n");
243
- return sanitizeSurrogates(options?.includeStructured ? truncateProviderToolText(text) : text);
258
+ return options?.includeStructured ? truncateProviderToolText(text) : text;
244
259
  }
245
- return sanitizeSurrogates(truncateProviderToolText(structuredTexts.join("\n")));
260
+ return truncateProviderToolText(structuredTexts.join("\n"));
246
261
  }
247
262
  /** Describe media that cannot be represented on the target provider wire. */
248
263
  function describeUnsupportedToolResultMedia(blocks, support) {
@@ -322,7 +337,7 @@ function transformAssistant(message, model, toolCallIdMap, normalizeToolCallId)
322
337
  type: "text",
323
338
  text: block.text
324
339
  };
325
- const { thoughtSignature: _, ...unsigned } = block;
340
+ const { thoughtSignature: _, async: _async, ...unsigned } = block;
326
341
  const trimmedId = block.id.trim();
327
342
  if (sameModel) return trimmedId === block.id ? block : Object.assign({}, block, { id: trimmedId });
328
343
  const id = normalizeToolCallId?.(trimmedId, model, message) ?? trimmedId;
@@ -336,7 +351,26 @@ function transformAssistant(message, model, toolCallIdMap, normalizeToolCallId)
336
351
  }
337
352
  function transformMessages(messages, model, normalizeToolCallId) {
338
353
  const toolCallIdMap = /* @__PURE__ */ new Map();
339
- const transformed = downgradeUnsupportedImages(messages.map((message) => message.content == null ? Object.assign({}, message, { content: [] }) : message), model).map((message) => {
354
+ const asyncOwners = /* @__PURE__ */ new Map();
355
+ const relocated = /* @__PURE__ */ new Map();
356
+ const movedResults = /* @__PURE__ */ new Set();
357
+ for (const message of messages) if (message.role === "assistant") {
358
+ const sameModel = message.provider === model.provider && message.api === model.api && message.model === model.id;
359
+ for (const block of message.content ?? []) if (block.type === "toolCall") {
360
+ if (block.async && !sameModel) asyncOwners.set(block.id, message);
361
+ else asyncOwners.delete(block.id);
362
+ }
363
+ } else if (message.role === "toolResult") {
364
+ const owner = asyncOwners.get(message.toolCallId);
365
+ if (owner) {
366
+ const results = relocated.get(owner) ?? [];
367
+ results.push(message);
368
+ relocated.set(owner, results);
369
+ movedResults.add(message);
370
+ asyncOwners.delete(message.toolCallId);
371
+ }
372
+ }
373
+ const transformed = downgradeUnsupportedImages((movedResults.size > 0 ? messages.flatMap((message) => movedResults.has(message) ? [] : [message, ...message.role === "assistant" ? relocated.get(message) ?? [] : []]) : messages).map((message) => message.content == null ? Object.assign({}, message, { content: [] }) : message), model).map((message) => {
340
374
  if (message.role === "assistant") return transformAssistant(message, model, toolCallIdMap, normalizeToolCallId);
341
375
  if (message.role !== "toolResult") return message;
342
376
  const trimmedId = message.toolCallId.trim();
@@ -344,6 +378,7 @@ function transformMessages(messages, model, normalizeToolCallId) {
344
378
  return toolCallId === message.toolCallId ? message : Object.assign({}, message, { toolCallId });
345
379
  });
346
380
  const result = [];
381
+ const pendingAsyncCalls = /* @__PURE__ */ new Map();
347
382
  let pendingToolCalls = [];
348
383
  let existingToolResultIds = /* @__PURE__ */ new Set();
349
384
  const flushToolCalls = () => {
@@ -365,11 +400,21 @@ function transformMessages(messages, model, normalizeToolCallId) {
365
400
  if (message.role === "assistant") {
366
401
  flushToolCalls();
367
402
  if (message.stopReason === "error" || message.stopReason === "aborted") continue;
368
- pendingToolCalls = message.content.filter((block) => block.type === "toolCall");
369
- } else if (message.role === "toolResult") existingToolResultIds.add(message.toolCallId);
370
- else flushToolCalls();
403
+ pendingToolCalls = message.content.filter((block) => {
404
+ if (block.type !== "toolCall") return false;
405
+ if (block.async) {
406
+ pendingAsyncCalls.set(block.id, block);
407
+ return false;
408
+ }
409
+ return true;
410
+ });
411
+ } else if (message.role === "toolResult") {
412
+ existingToolResultIds.add(message.toolCallId);
413
+ pendingAsyncCalls.delete(message.toolCallId);
414
+ } else flushToolCalls();
371
415
  result.push(message);
372
416
  }
417
+ pendingToolCalls.push(...pendingAsyncCalls.values());
373
418
  flushToolCalls();
374
419
  return result;
375
420
  }
@@ -1,6 +1,6 @@
1
- import { D as Model, V as StreamFn, d as Context, n as Api } from "./types-DhLoJbFm.mjs";
2
- import "./index-Qbej8io0.mjs";
3
- import { n as ApiRegistry } from "./api-registry-CTd8NzcD.mjs";
1
+ import "./index-FnHM2FcI.mjs";
2
+ import { D as Model, K as StreamFn, d as Context, n as Api } from "./types-CJ1-Ht7A.mjs";
3
+ import { n as ApiRegistry } from "./api-registry-DWtPjzyn.mjs";
4
4
  //#region packages/ai/src/host.d.ts
5
5
  /** Provider capability facts needed by the package-owned transports. */
6
6
  interface AiProviderRequestCapabilities {