@joshuaswarren/openclaw-engram 9.1.19 → 9.1.21

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.
@@ -3,12 +3,12 @@ import {
3
3
  EngramAccessService,
4
4
  Orchestrator,
5
5
  parseConfig
6
- } from "./chunk-KZMICTC7.js";
7
- import "./chunk-OLJAEA5I.js";
6
+ } from "./chunk-3ILF2OUT.js";
7
+ import "./chunk-EM2BU45W.js";
8
8
  import "./chunk-IMMYYNXG.js";
9
- import "./chunk-DTCQ2KEX.js";
9
+ import "./chunk-Y6DMH5LN.js";
10
10
  import "./chunk-6KX4XLQJ.js";
11
- import "./chunk-KIA3HVQD.js";
11
+ import "./chunk-FP3MUEPD.js";
12
12
  import "./chunk-MKM2BCQH.js";
13
13
  import "./chunk-DEIBZP3O.js";
14
14
  import "./chunk-SSIIJJKA.js";
@@ -1,7 +1,7 @@
1
1
  // openclaw-engram: Local-first memory plugin
2
2
  import {
3
3
  FallbackLlmClient
4
- } from "./chunk-KIA3HVQD.js";
4
+ } from "./chunk-FP3MUEPD.js";
5
5
  import {
6
6
  listJsonFiles
7
7
  } from "./chunk-DEIBZP3O.js";
@@ -233,4 +233,4 @@ export {
233
233
  runCalibrationIfEnabled,
234
234
  synthesizeCalibrationRules
235
235
  };
236
- //# sourceMappingURL=calibration-OOOYE2ID.js.map
236
+ //# sourceMappingURL=calibration-UY5SQU5K.js.map
@@ -1,7 +1,7 @@
1
1
  // openclaw-engram: Local-first memory plugin
2
2
  import {
3
3
  FallbackLlmClient
4
- } from "./chunk-KIA3HVQD.js";
4
+ } from "./chunk-FP3MUEPD.js";
5
5
  import {
6
6
  readChainIndex,
7
7
  resolveChainsDir
@@ -203,4 +203,4 @@ export {
203
203
  deriveCausalPromotionCandidates,
204
204
  synthesizeCausalPreferencesViaLlm
205
205
  };
206
- //# sourceMappingURL=causal-consolidation-BDMZMX2D.js.map
206
+ //# sourceMappingURL=causal-consolidation-5RFIDR74.js.map
@@ -3,7 +3,7 @@ import {
3
3
  CompoundingEngine,
4
4
  SharedContextManager,
5
5
  defaultTierMigrationCycleBudget
6
- } from "./chunk-OLJAEA5I.js";
6
+ } from "./chunk-EM2BU45W.js";
7
7
  import {
8
8
  searchCausalTrajectories
9
9
  } from "./chunk-IMMYYNXG.js";
@@ -27,7 +27,7 @@ import {
27
27
  setCachedQmdSearch,
28
28
  setCachedRuleMemories,
29
29
  toMemoryPathRel
30
- } from "./chunk-DTCQ2KEX.js";
30
+ } from "./chunk-Y6DMH5LN.js";
31
31
  import {
32
32
  GraphIndex
33
33
  } from "./chunk-6KX4XLQJ.js";
@@ -36,7 +36,7 @@ import {
36
36
  buildChatCompletionTokenLimit,
37
37
  extractJsonCandidates,
38
38
  shouldAssumeOpenAiChatCompletions
39
- } from "./chunk-KIA3HVQD.js";
39
+ } from "./chunk-FP3MUEPD.js";
40
40
  import {
41
41
  BoxBuilder,
42
42
  assertIsoRecordedAt,
@@ -22309,7 +22309,7 @@ var Orchestrator = class _Orchestrator {
22309
22309
  );
22310
22310
  return result;
22311
22311
  }
22312
- const { FallbackLlmClient: FallbackLlmClient2 } = await import("./fallback-llm-46JU5PST.js");
22312
+ const { FallbackLlmClient: FallbackLlmClient2 } = await import("./fallback-llm-3DXDWI5H.js");
22313
22313
  const useGateway = this.config.modelSource === "gateway";
22314
22314
  const modelSetting = this.config.semanticConsolidationModel;
22315
22315
  if (modelSetting === "fast" && this.fastLlm && !useGateway) {
@@ -24546,7 +24546,7 @@ ${trimmedBody}`;
24546
24546
  return null;
24547
24547
  }
24548
24548
  try {
24549
- const { getCalibrationRulesForRecall, buildCalibrationRecallSection } = await import("./calibration-OOOYE2ID.js");
24549
+ const { getCalibrationRulesForRecall, buildCalibrationRecallSection } = await import("./calibration-UY5SQU5K.js");
24550
24550
  const rules = await getCalibrationRulesForRecall(this.config.memoryDir);
24551
24551
  if (rules.length === 0) {
24552
24552
  recordRecallSectionMetric({
@@ -31534,4 +31534,4 @@ export {
31534
31534
  EngramAccessInputError,
31535
31535
  EngramAccessService
31536
31536
  };
31537
- //# sourceMappingURL=chunk-KZMICTC7.js.map
31537
+ //# sourceMappingURL=chunk-3ILF2OUT.js.map
@@ -4,7 +4,7 @@ import {
4
4
  parseContinuityImprovementLoops,
5
5
  parseContinuityIncident,
6
6
  sanitizeMemoryContent
7
- } from "./chunk-DTCQ2KEX.js";
7
+ } from "./chunk-Y6DMH5LN.js";
8
8
  import {
9
9
  log
10
10
  } from "./chunk-SSIIJJKA.js";
@@ -830,7 +830,7 @@ var CompoundingEngine = class {
830
830
  let promotionCandidates = this.config.compoundingSemanticEnabled ? this.derivePromotionCandidates(outcomeSummary, mistakes.registry, rubrics) : [];
831
831
  if (this.config.cmcConsolidationEnabled) {
832
832
  try {
833
- const { deriveCausalPromotionCandidates } = await import("./causal-consolidation-BDMZMX2D.js");
833
+ const { deriveCausalPromotionCandidates } = await import("./causal-consolidation-5RFIDR74.js");
834
834
  const causalCandidates = await deriveCausalPromotionCandidates({
835
835
  memoryDir: this.config.memoryDir,
836
836
  causalTrajectoryStoreDir: this.config.causalTrajectoryStoreDir,
@@ -851,7 +851,7 @@ var CompoundingEngine = class {
851
851
  }
852
852
  if (this.config.calibrationEnabled) {
853
853
  try {
854
- const { runCalibrationConsolidation } = await import("./calibration-OOOYE2ID.js");
854
+ const { runCalibrationConsolidation } = await import("./calibration-UY5SQU5K.js");
855
855
  const calRules = await runCalibrationConsolidation({
856
856
  memoryDir: this.config.memoryDir,
857
857
  gatewayConfig: this.config.gatewayConfig,
@@ -1839,4 +1839,4 @@ export {
1839
1839
  defaultTierMigrationCycleBudget,
1840
1840
  CompoundingEngine
1841
1841
  };
1842
- //# sourceMappingURL=chunk-OLJAEA5I.js.map
1842
+ //# sourceMappingURL=chunk-EM2BU45W.js.map
@@ -95,270 +95,138 @@ function buildChatCompletionTokenLimit(model, maxTokens, options) {
95
95
  }
96
96
 
97
97
  // src/resolve-provider-secret.ts
98
- import { execFileSync } from "child_process";
99
- import { readFileSync, existsSync } from "fs";
100
98
  import path from "path";
101
99
  import os from "os";
100
+ var _resolveApiKeyForProvider = null;
101
+ var _resolverLoaded = false;
102
+ var _resolverNextRetryAt = 0;
103
+ var RESOLVER_RETRY_BACKOFF_MS = 6e4;
102
104
  var resolvedCache = /* @__PURE__ */ new Map();
103
- var DEFAULT_OP_VAULT = "OpenClaw";
104
- var OP_SERVICE_ACCOUNT_TOKEN_PATH = path.join(os.homedir(), ".openclaw", "secrets", "op-service-account-token");
105
- var OP_VAULT_PATH = path.join(os.homedir(), ".openclaw", "secrets", "op-vault-name");
106
- function getOpVault() {
107
- try {
108
- if (existsSync(OP_VAULT_PATH)) {
109
- const vault = readFileSync(OP_VAULT_PATH, "utf-8").trim();
110
- if (vault) return vault;
111
- }
112
- } catch {
105
+ async function getGatewayResolver() {
106
+ if (_resolverLoaded) {
107
+ return _resolveApiKeyForProvider;
113
108
  }
114
- return process.env.OP_VAULT ?? DEFAULT_OP_VAULT;
115
- }
116
- function buildOpEnv() {
117
- if (process.env.OP_SERVICE_ACCOUNT_TOKEN) {
118
- return process.env;
109
+ if (_resolverNextRetryAt > 0 && Date.now() < _resolverNextRetryAt) {
110
+ return null;
119
111
  }
120
112
  try {
121
- if (existsSync(OP_SERVICE_ACCOUNT_TOKEN_PATH)) {
122
- const token = readFileSync(OP_SERVICE_ACCOUNT_TOKEN_PATH, "utf-8").trim();
123
- if (token) {
124
- return { ...process.env, OP_SERVICE_ACCOUNT_TOKEN: token };
113
+ const candidates = [
114
+ // Try glob-matching the runtime module name (hash varies per build)
115
+ ...await findRuntimeModules()
116
+ ];
117
+ const { pathToFileURL } = await import("url");
118
+ for (const candidate of candidates) {
119
+ try {
120
+ const importUrl = pathToFileURL(candidate).href;
121
+ const mod = await import(importUrl);
122
+ if (typeof mod.resolveApiKeyForProvider === "function") {
123
+ _resolveApiKeyForProvider = mod.resolveApiKeyForProvider;
124
+ _resolverLoaded = true;
125
+ log.debug("loaded gateway resolveApiKeyForProvider from runtime module");
126
+ return _resolveApiKeyForProvider;
127
+ }
128
+ } catch {
125
129
  }
126
130
  }
127
131
  } catch {
128
132
  }
129
- return process.env;
130
- }
131
- async function resolveProviderApiKey(providerId, apiKeyValue, gatewayConfig) {
132
- if (typeof apiKeyValue === "string") {
133
- if (apiKeyValue === "secretref-managed") {
134
- return resolveSecretRefManaged(providerId, gatewayConfig);
135
- }
136
- if (apiKeyValue.endsWith("-oauth") || apiKeyValue.endsWith("-local") || apiKeyValue === "lm-studio" || apiKeyValue.startsWith("gcp-")) {
137
- return void 0;
138
- }
139
- return apiKeyValue;
140
- }
141
- if (isSecretRefObject(apiKeyValue)) {
142
- return resolveSecretRef(providerId, apiKeyValue);
143
- }
144
- return void 0;
145
- }
146
- function isSecretRefObject(value) {
147
- return typeof value === "object" && value !== null && "source" in value && "id" in value && typeof value.source === "string" && typeof value.id === "string";
133
+ _resolverNextRetryAt = Date.now() + RESOLVER_RETRY_BACKOFF_MS;
134
+ log.debug(`gateway resolveApiKeyForProvider not available \u2014 will retry after ${RESOLVER_RETRY_BACKOFF_MS / 1e3}s`);
135
+ return null;
148
136
  }
149
- async function resolveSecretRef(providerId, ref) {
150
- const cacheKey = `ref:${ref.source}:${ref.provider ?? ""}:${ref.id}:${ref.command ?? ""}:${(ref.args ?? []).join(",")}`;
151
- const cached = resolvedCache.get(cacheKey);
152
- if (cached !== void 0) {
153
- if (cached !== null) return cached;
154
- }
155
- let resolved;
137
+ async function findRuntimeModules() {
138
+ const { readdirSync } = await import("fs");
139
+ const { createRequire } = await import("module");
140
+ const candidates = [];
141
+ const distDirs = [];
156
142
  try {
157
- switch (ref.source) {
158
- case "exec":
159
- resolved = resolveExecSecret(ref);
160
- break;
161
- case "file":
162
- resolved = resolveFileSecret(ref);
163
- break;
164
- case "env":
165
- resolved = process.env[ref.id] ?? void 0;
166
- break;
167
- }
168
- } catch (err) {
169
- log.warn(
170
- `secret resolution failed for provider "${providerId}" (${ref.source}/${ref.provider}): ${err instanceof Error ? err.message : String(err)}`
171
- );
172
- }
173
- if (resolved) {
174
- resolvedCache.set(cacheKey, resolved);
175
- }
176
- if (resolved) {
177
- log.debug(`resolved API key for provider "${providerId}" via ${ref.source}/${ref.provider ?? "default"}`);
178
- }
179
- return resolved;
180
- }
181
- function resolveExecSecret(ref) {
182
- const command = ref.command ?? (ref.provider === "op" ? "op" : void 0);
183
- if (!command) {
184
- log.warn(`exec secret ref has no command and provider "${ref.provider}" is not a known exec provider`);
185
- return void 0;
143
+ const req = createRequire(import.meta.url);
144
+ const openclawMain = req.resolve("openclaw");
145
+ const openclawDist = path.join(path.dirname(openclawMain), "..", "dist");
146
+ if (openclawDist) distDirs.push(path.resolve(openclawDist));
147
+ } catch {
186
148
  }
187
- const args = ref.args ?? (ref.provider === "op" ? ["read", ref.id] : [ref.id]);
188
- const env = ref.provider === "op" ? buildOpEnv() : process.env;
189
149
  try {
190
- const result = execFileSync(command, args, {
191
- encoding: "utf-8",
192
- timeout: 15e3,
193
- stdio: ["pipe", "pipe", "pipe"],
194
- env
195
- }).trim();
196
- return result || void 0;
197
- } catch (err) {
198
- log.warn(`exec secret resolution failed (${command}): ${err instanceof Error ? err.message : String(err)}`);
199
- return void 0;
200
- }
201
- }
202
- function resolveFileSecret(ref) {
203
- if (ref.provider === "op") {
204
- const env = buildOpEnv();
205
- if (ref.id.startsWith("op://")) {
206
- try {
207
- const result = execFileSync("op", ["read", ref.id], {
208
- encoding: "utf-8",
209
- timeout: 15e3,
210
- stdio: ["pipe", "pipe", "pipe"],
211
- env
212
- }).trim();
213
- return result || void 0;
214
- } catch {
215
- }
216
- } else {
217
- const itemName = ref.id.replace(/^\//, "");
218
- const vault = getOpVault();
219
- try {
220
- const result = execFileSync("op", [
221
- "item",
222
- "get",
223
- itemName,
224
- "--vault",
225
- vault,
226
- "--fields",
227
- "credential",
228
- "--format",
229
- "json"
230
- ], {
231
- encoding: "utf-8",
232
- timeout: 15e3,
233
- stdio: ["pipe", "pipe", "pipe"],
234
- env
235
- }).trim();
236
- if (result) {
237
- try {
238
- const parsed = JSON.parse(result);
239
- const field = Array.isArray(parsed) ? parsed[0] : parsed;
240
- const value = field?.value ?? field;
241
- if (typeof value === "string" && value.length > 0) {
242
- return value;
243
- }
244
- } catch {
245
- if (result.length > 0 && !result.startsWith("{") && !result.startsWith("[")) {
246
- return result;
247
- }
248
- }
249
- }
250
- } catch {
150
+ const { realpathSync } = await import("fs");
151
+ const mainScript = process.argv[1];
152
+ if (mainScript) {
153
+ const realScript = realpathSync(mainScript);
154
+ if (realScript.includes("openclaw")) {
155
+ const distDir = path.dirname(realScript);
156
+ if (!distDirs.includes(distDir)) distDirs.push(distDir);
251
157
  }
252
158
  }
253
- const secretsDir = path.join(os.homedir(), ".openclaw", "secrets");
254
- const filePath = path.join(secretsDir, ref.id.replace(/^\//, ""));
255
- if (existsSync(filePath)) {
256
- try {
257
- return readFileSync(filePath, "utf-8").trim() || void 0;
258
- } catch {
259
- }
260
- }
261
- } else {
262
- const filePath = path.isAbsolute(ref.id) ? ref.id : path.join(os.homedir(), ".openclaw", "secrets", ref.id.replace(/^\//, ""));
263
- if (existsSync(filePath)) {
264
- try {
265
- return readFileSync(filePath, "utf-8").trim() || void 0;
266
- } catch {
159
+ } catch {
160
+ }
161
+ for (const dir of distDirs) {
162
+ try {
163
+ const files = readdirSync(dir);
164
+ for (const f of files) {
165
+ if (f.startsWith("runtime-model-auth.runtime-") && f.endsWith(".js")) {
166
+ candidates.push(path.join(dir, f));
167
+ }
267
168
  }
169
+ } catch {
268
170
  }
269
171
  }
270
- return void 0;
172
+ return candidates;
271
173
  }
272
- function resolveSecretRefManaged(providerId, gatewayConfig) {
273
- const cacheKey = `managed:${providerId}`;
274
- const cached = resolvedCache.get(cacheKey);
275
- if (cached !== void 0 && cached !== null) {
276
- return cached;
174
+ async function resolveProviderApiKey(providerId, apiKeyValue, gatewayConfig, agentDir) {
175
+ const cacheKey = `provider:${providerId}`;
176
+ if (resolvedCache.has(cacheKey)) {
177
+ return resolvedCache.get(cacheKey);
277
178
  }
278
179
  let resolved;
279
- const profiles = gatewayConfig?.auth?.profiles;
280
- if (profiles) {
281
- const candidates = [
282
- `${providerId}:default`,
283
- `${providerId}:manual`,
284
- providerId
285
- ];
286
- for (const profileKey of candidates) {
287
- const raw = profiles[profileKey];
288
- if (!raw || typeof raw !== "object") continue;
289
- const profile = raw;
290
- if (profile.token) {
291
- if (typeof profile.token === "string" && !profile.token.startsWith("{")) {
292
- resolved = profile.token;
293
- break;
294
- }
295
- if (isSecretRefObject(profile.token)) {
296
- try {
297
- resolved = resolveSecretRefSync(providerId, profile.token);
298
- } catch {
299
- }
300
- if (resolved) break;
301
- }
302
- }
303
- if (profile.apiKey && typeof profile.apiKey === "string") {
304
- resolved = profile.apiKey;
305
- break;
306
- }
307
- if (profile.access && typeof profile.access === "string") {
308
- resolved = profile.access;
309
- break;
310
- }
180
+ if (typeof apiKeyValue === "string" && apiKeyValue.trim().length > 0) {
181
+ if (apiKeyValue === "secretref-managed" || apiKeyValue.endsWith("-oauth") || apiKeyValue.endsWith("-local") || apiKeyValue === "lm-studio" || apiKeyValue.startsWith("gcp-")) {
182
+ } else {
183
+ resolved = apiKeyValue;
184
+ resolvedCache.set(cacheKey, resolved);
185
+ return resolved;
311
186
  }
312
187
  }
313
- if (!resolved) {
314
- const envCandidates = [
315
- `${providerId.toUpperCase().replace(/-/g, "_")}_API_KEY`,
316
- `${providerId.toUpperCase().replace(/-/g, "_")}_TOKEN`
317
- ];
318
- for (const envVar of envCandidates) {
319
- if (process.env[envVar]) {
320
- resolved = process.env[envVar];
321
- break;
188
+ const resolver = await getGatewayResolver();
189
+ if (resolver) {
190
+ try {
191
+ const resolvedAgentDir = agentDir ?? path.join(os.homedir(), ".openclaw", "agents", "main", "agent");
192
+ const auth = await resolver({ provider: providerId, cfg: gatewayConfig, agentDir: resolvedAgentDir });
193
+ if (auth?.apiKey) {
194
+ resolved = auth.apiKey;
195
+ log.debug(`resolved API key for provider "${providerId}" via gateway auth (source: ${auth.source ?? "unknown"}, mode: ${auth.mode ?? "unknown"})`);
196
+ resolvedCache.set(cacheKey, resolved);
197
+ return resolved;
322
198
  }
199
+ } catch (err) {
200
+ log.debug(
201
+ `gateway auth resolution failed for provider "${providerId}": ${err instanceof Error ? err.message : String(err)}`
202
+ );
323
203
  }
324
204
  }
205
+ resolved = resolveFromEnv(providerId);
325
206
  if (resolved) {
326
- resolvedCache.set(cacheKey, resolved);
327
- log.debug(`resolved managed API key for provider "${providerId}" via auth profile`);
207
+ log.debug(`resolved API key for provider "${providerId}" from environment variable`);
328
208
  } else {
329
- log.debug(`could not resolve managed API key for provider "${providerId}"`);
330
- }
331
- return resolved;
332
- }
333
- function resolveSecretRefSync(providerId, ref) {
334
- const cacheKey = `ref:${ref.source}:${ref.provider ?? ""}:${ref.id}:${ref.command ?? ""}:${(ref.args ?? []).join(",")}`;
335
- const cached = resolvedCache.get(cacheKey);
336
- if (cached !== void 0 && cached !== null) {
337
- return cached;
338
- }
339
- let resolved;
340
- try {
341
- switch (ref.source) {
342
- case "exec":
343
- resolved = resolveExecSecret(ref);
344
- break;
345
- case "file":
346
- resolved = resolveFileSecret(ref);
347
- break;
348
- case "env":
349
- resolved = process.env[ref.id] ?? void 0;
350
- break;
351
- }
352
- } catch (err) {
353
- log.warn(
354
- `sync secret resolution failed for provider "${providerId}": ${err instanceof Error ? err.message : String(err)}`
355
- );
209
+ log.debug(`could not resolve API key for provider "${providerId}" \u2014 skipping`);
356
210
  }
357
211
  if (resolved) {
358
212
  resolvedCache.set(cacheKey, resolved);
359
213
  }
360
214
  return resolved;
361
215
  }
216
+ function resolveFromEnv(providerId) {
217
+ const normalized = providerId.toUpperCase().replace(/[^A-Z0-9]/g, "_");
218
+ const candidates = [
219
+ `${normalized}_API_KEY`,
220
+ `${normalized}_TOKEN`
221
+ ];
222
+ for (const envVar of candidates) {
223
+ const value = process.env[envVar];
224
+ if (value && value.trim().length > 0) {
225
+ return value.trim();
226
+ }
227
+ }
228
+ return void 0;
229
+ }
362
230
 
363
231
  // src/fallback-llm.ts
364
232
  var FallbackLlmClient = class {
@@ -531,11 +399,7 @@ var FallbackLlmClient = class {
531
399
  * Results are cached per provider so exec calls only happen once.
532
400
  */
533
401
  async resolveApiKey(providerId, providerConfig) {
534
- return resolveProviderApiKey(
535
- providerId,
536
- providerConfig.apiKey,
537
- this.gatewayConfig
538
- );
402
+ return resolveProviderApiKey(providerId, providerConfig.apiKey, this.gatewayConfig);
539
403
  }
540
404
  /**
541
405
  * Try to call a single model.
@@ -667,4 +531,4 @@ export {
667
531
  buildChatCompletionTokenLimit,
668
532
  FallbackLlmClient
669
533
  };
670
- //# sourceMappingURL=chunk-KIA3HVQD.js.map
534
+ //# sourceMappingURL=chunk-FP3MUEPD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/json-extract.ts","../src/openai-chat-compat.ts","../src/resolve-provider-secret.ts","../src/fallback-llm.ts"],"sourcesContent":["/**\n * Utilities for extracting JSON payloads from LLM outputs.\n *\n * We see common failure modes:\n * - \"Here's an example: {..}\\nHere's the real answer: {..}\" (multiple JSON blocks)\n * - fenced ```json blocks\n * - leading/trailing prose around JSON\n *\n * These helpers attempt multiple candidates and let callers validate with schemas.\n */\n\nexport function stripCodeFences(text: string): string {\n return text.replace(/```(?:json)?\\s*([\\s\\S]*?)```/gi, (_m, inner) => String(inner).trim());\n}\n\nexport function extractJsonCandidates(text: string): string[] {\n const trimmed = text.trim();\n const cleaned = stripCodeFences(trimmed);\n const candidates: string[] = [];\n\n if (cleaned.length > 0) candidates.push(cleaned);\n candidates.push(...scanBalancedJsonBlocks(cleaned));\n\n // Legacy regex fallback (single object)\n const objMatch = cleaned.match(/\\{[\\s\\S]*\\}/);\n if (objMatch) candidates.push(objMatch[0]);\n\n const seen = new Set<string>();\n return candidates\n .map((c) => c.trim())\n .filter((c) => c.length > 0)\n .filter((c) => {\n if (seen.has(c)) return false;\n seen.add(c);\n return true;\n });\n}\n\nfunction scanBalancedJsonBlocks(text: string): string[] {\n const out: string[] = [];\n const opens = new Set([\"{\", \"[\"]);\n const closes: Record<string, string> = { \"{\": \"}\", \"[\": \"]\" };\n\n for (let i = 0; i < text.length; i++) {\n const start = text[i];\n if (!opens.has(start)) continue;\n\n const expectedClose = closes[start];\n let depth = 0;\n let inString = false;\n let escape = false;\n\n for (let j = i; j < text.length; j++) {\n const ch = text[j];\n\n if (inString) {\n if (escape) {\n escape = false;\n } else if (ch === \"\\\\\") {\n escape = true;\n } else if (ch === \"\\\"\") {\n inString = false;\n }\n continue;\n }\n\n if (ch === \"\\\"\") {\n inString = true;\n continue;\n }\n\n if (ch === start) depth++;\n if (ch === expectedClose) depth--;\n\n if (depth === 0) {\n out.push(text.slice(i, j + 1).trim());\n i = j;\n break;\n }\n }\n }\n\n return out;\n}\n\n","function normalizedModel(model: string): string {\n return model.trim().toLowerCase();\n}\n\nfunction matchesModelFamily(normalized: string, familyPattern: RegExp): boolean {\n return familyPattern.test(normalized);\n}\n\nexport function shouldAssumeOpenAiChatCompletions(baseUrl?: string): boolean {\n if (!baseUrl) return true;\n try {\n return new URL(baseUrl).hostname.toLowerCase() === \"api.openai.com\";\n } catch {\n return false;\n }\n}\n\nexport function usesMaxCompletionTokens(model: string, options?: { assumeOpenAI?: boolean }): boolean {\n const normalized = normalizedModel(model);\n if (options?.assumeOpenAI !== true) return false;\n if (matchesModelFamily(normalized, /^gpt-5(?:$|[-.])/)) return true;\n if (matchesModelFamily(normalized, /^gpt-4o(?:$|[-.])/)) return true;\n if (matchesModelFamily(normalized, /^gpt-4\\.1(?:$|[-.])/)) return true;\n if (matchesModelFamily(normalized, /^o1(?:$|[-.])/)) return true;\n if (matchesModelFamily(normalized, /^o3(?:$|[-.])/)) return true;\n return matchesModelFamily(normalized, /^o4-mini(?:$|[-.])/);\n}\n\nexport function buildChatCompletionTokenLimit(\n model: string,\n maxTokens: number,\n options?: { assumeOpenAI?: boolean },\n): { max_tokens: number } | { max_completion_tokens: number } {\n const safeMaxTokens = Math.max(0, Math.floor(maxTokens));\n if (usesMaxCompletionTokens(model, options)) {\n return { max_completion_tokens: safeMaxTokens };\n }\n return { max_tokens: safeMaxTokens };\n}\n","import { log } from \"./logger.js\";\nimport path from \"node:path\";\nimport os from \"node:os\";\n\n/**\n * Resolve a provider API key using OpenClaw's own auth resolution system.\n *\n * This module delegates to the gateway's `resolveApiKeyForProvider()` function,\n * which handles all secret reference formats (SecretRef objects, auth profiles,\n * \"secretref-managed\" markers, environment variables, etc.) using the same\n * codepath the gateway uses for its own agent sessions.\n *\n * For plain-text API keys, a fast path returns them directly without\n * involving the gateway auth system.\n *\n * Results are cached per provider for the gateway process lifetime.\n */\n\ntype ResolveApiKeyFn = (params: {\n provider: string;\n cfg?: unknown;\n agentDir?: string;\n}) => Promise<{ apiKey?: string; source?: string; mode?: string } | null>;\n\nlet _resolveApiKeyForProvider: ResolveApiKeyFn | null = null;\nlet _resolverLoaded = false;\nlet _resolverNextRetryAt = 0;\nconst RESOLVER_RETRY_BACKOFF_MS = 60_000; // 1 minute between retries after first failure\nconst resolvedCache = new Map<string, string | undefined>();\n\n/**\n * Lazily load the gateway's resolveApiKeyForProvider function.\n * Returns null if not available (e.g., running outside the gateway process).\n */\nasync function getGatewayResolver(): Promise<ResolveApiKeyFn | null> {\n if (_resolverLoaded) {\n return _resolveApiKeyForProvider;\n }\n // Backoff: don't re-scan filesystem on every call when module wasn't found.\n // After a failure, wait RESOLVER_RETRY_BACKOFF_MS before trying again.\n if (_resolverNextRetryAt > 0 && Date.now() < _resolverNextRetryAt) {\n return null;\n }\n\n try {\n // The gateway bundles this in a runtime chunk — import it dynamically.\n // This import path is stable across gateway versions since it's a named runtime export.\n const candidates = [\n // Try glob-matching the runtime module name (hash varies per build)\n ...await findRuntimeModules(),\n ];\n\n const { pathToFileURL } = await import(\"node:url\");\n for (const candidate of candidates) {\n try {\n // Convert native path to file:// URL for cross-platform ESM import compatibility\n const importUrl = pathToFileURL(candidate).href;\n const mod = await import(importUrl);\n if (typeof mod.resolveApiKeyForProvider === \"function\") {\n _resolveApiKeyForProvider = mod.resolveApiKeyForProvider;\n _resolverLoaded = true;\n log.debug(\"loaded gateway resolveApiKeyForProvider from runtime module\");\n return _resolveApiKeyForProvider;\n }\n } catch {\n // Try next candidate\n }\n }\n } catch {\n // Silent\n }\n\n // Backoff before retrying — avoid repeated fs scanning.\n // Retries after RESOLVER_RETRY_BACKOFF_MS so the resolver can\n // recover if the gateway restarts or the module becomes available.\n _resolverNextRetryAt = Date.now() + RESOLVER_RETRY_BACKOFF_MS;\n log.debug(`gateway resolveApiKeyForProvider not available — will retry after ${RESOLVER_RETRY_BACKOFF_MS / 1000}s`);\n return null;\n}\n\n/**\n * Find the gateway's model-auth runtime module by scanning the dist directory.\n * Uses require.resolve to find the openclaw package regardless of install method.\n */\nasync function findRuntimeModules(): Promise<string[]> {\n const { readdirSync } = await import(\"node:fs\");\n const { createRequire } = await import(\"node:module\");\n const candidates: string[] = [];\n\n // Discover the openclaw dist directory from the installed package,\n // regardless of how it was installed (Homebrew, npm global, local, etc.)\n const distDirs: string[] = [];\n\n try {\n // require.resolve finds the package from the current process context\n const req = createRequire(import.meta.url);\n const openclawMain = req.resolve(\"openclaw\");\n const openclawDist = path.join(path.dirname(openclawMain), \"..\", \"dist\");\n if (openclawDist) distDirs.push(path.resolve(openclawDist));\n } catch {\n // openclaw not resolvable from plugin context — try alternate paths\n }\n\n // Fallback: infer from the running process (gateway runs from its own dist/)\n // Use fs.realpathSync to resolve symlinks (e.g., /usr/local/bin/openclaw → actual path)\n try {\n const { realpathSync } = await import(\"node:fs\");\n const mainScript = process.argv[1];\n if (mainScript) {\n const realScript = realpathSync(mainScript);\n if (realScript.includes(\"openclaw\")) {\n const distDir = path.dirname(realScript);\n if (!distDirs.includes(distDir)) distDirs.push(distDir);\n }\n }\n } catch {\n // Silent\n }\n\n for (const dir of distDirs) {\n try {\n const files = readdirSync(dir);\n for (const f of files) {\n if (f.startsWith(\"runtime-model-auth.runtime-\") && f.endsWith(\".js\")) {\n candidates.push(path.join(dir, f));\n }\n }\n } catch {\n // Directory doesn't exist — skip\n }\n }\n\n return candidates;\n}\n\n/**\n * Resolve a provider API key from various OpenClaw formats.\n *\n * Resolution order:\n * 1. Plain-text string → returned immediately\n * 2. Gateway's resolveApiKeyForProvider → handles all secret ref formats\n * 3. Environment variable fallback (PROVIDER_NAME_API_KEY)\n * 4. undefined → provider is skipped in the fallback chain\n */\nexport async function resolveProviderApiKey(\n providerId: string,\n apiKeyValue: unknown,\n gatewayConfig?: unknown,\n agentDir?: string,\n): Promise<string | undefined> {\n // Check cache first\n const cacheKey = `provider:${providerId}`;\n if (resolvedCache.has(cacheKey)) {\n return resolvedCache.get(cacheKey);\n }\n\n let resolved: string | undefined;\n\n // Fast path: plain-text string that looks like an actual API key\n if (typeof apiKeyValue === \"string\" && apiKeyValue.trim().length > 0) {\n // Skip known non-API-key markers used by the gateway for auth modes\n // that don't use bearer tokens (OAuth, local endpoints, GCP credentials)\n if (\n apiKeyValue === \"secretref-managed\" ||\n apiKeyValue.endsWith(\"-oauth\") ||\n apiKeyValue.endsWith(\"-local\") ||\n apiKeyValue === \"lm-studio\" ||\n apiKeyValue.startsWith(\"gcp-\")\n ) {\n // Fall through to gateway resolver / env var fallback\n } else {\n resolved = apiKeyValue;\n resolvedCache.set(cacheKey, resolved);\n return resolved;\n }\n }\n\n // The API key is either a SecretRef object, \"secretref-managed\", or empty.\n // Try the gateway's own auth resolution system first.\n const resolver = await getGatewayResolver();\n if (resolver) {\n try {\n const resolvedAgentDir = agentDir ?? path.join(os.homedir(), \".openclaw\", \"agents\", \"main\", \"agent\");\n const auth = await resolver({ provider: providerId, cfg: gatewayConfig, agentDir: resolvedAgentDir });\n if (auth?.apiKey) {\n resolved = auth.apiKey;\n log.debug(`resolved API key for provider \"${providerId}\" via gateway auth (source: ${auth.source ?? \"unknown\"}, mode: ${auth.mode ?? \"unknown\"})`);\n resolvedCache.set(cacheKey, resolved);\n return resolved;\n }\n } catch (err) {\n log.debug(\n `gateway auth resolution failed for provider \"${providerId}\": ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n }\n\n // Environment variable fallback\n resolved = resolveFromEnv(providerId);\n if (resolved) {\n log.debug(`resolved API key for provider \"${providerId}\" from environment variable`);\n } else {\n log.debug(`could not resolve API key for provider \"${providerId}\" — skipping`);\n }\n\n // Only cache successful resolutions — failures are retried on next call\n // so providers can recover after transient issues (e.g., 1Password agent restart)\n if (resolved) {\n resolvedCache.set(cacheKey, resolved);\n }\n return resolved;\n}\n\n/**\n * Try to resolve an API key from environment variables.\n */\nfunction resolveFromEnv(providerId: string): string | undefined {\n const normalized = providerId.toUpperCase().replace(/[^A-Z0-9]/g, \"_\");\n const candidates = [\n `${normalized}_API_KEY`,\n `${normalized}_TOKEN`,\n ];\n for (const envVar of candidates) {\n const value = process.env[envVar];\n if (value && value.trim().length > 0) {\n return value.trim();\n }\n }\n return undefined;\n}\n\n/**\n * Clear the resolution cache (useful for testing or key rotation).\n */\nexport function clearSecretCache(): void {\n resolvedCache.clear();\n _resolveApiKeyForProvider = null;\n _resolverLoaded = false;\n _resolverNextRetryAt = 0;\n}\n","import { log } from \"./logger.js\";\nimport type { GatewayConfig, ModelProviderConfig, AgentPersona } from \"./types.js\";\nimport { extractJsonCandidates } from \"./json-extract.js\";\nimport {\n buildChatCompletionTokenLimit,\n shouldAssumeOpenAiChatCompletions,\n} from \"./openai-chat-compat.js\";\nimport { resolveProviderApiKey } from \"./resolve-provider-secret.js\";\n\nexport interface FallbackLlmOptions {\n temperature?: number;\n maxTokens?: number;\n timeoutMs?: number;\n /** Override which agent persona's model chain to use (by ID from agents.list[]). */\n agentId?: string;\n}\n\nexport interface FallbackLlmResponse {\n content: string;\n modelUsed: string;\n usage?: {\n inputTokens?: number;\n outputTokens?: number;\n totalTokens?: number;\n };\n}\n\ninterface ModelRef {\n providerId: string;\n modelId: string;\n providerConfig: ModelProviderConfig;\n modelString: string;\n}\n\n/**\n * Generic fallback LLM client that uses the gateway's default AI configuration\n * and walks through the full fallback chain (primary + fallbacks).\n * Supports OpenAI and Anthropic API formats.\n */\nexport class FallbackLlmClient {\n private gatewayConfig: GatewayConfig | undefined;\n\n constructor(gatewayConfig?: GatewayConfig) {\n this.gatewayConfig = gatewayConfig;\n }\n\n /**\n * Check if fallback is available (gateway config has at least one model).\n */\n isAvailable(agentId?: string): boolean {\n const models = this.getModelChain(agentId);\n return models.length > 0;\n }\n\n /**\n * Make a chat completion request using the gateway's default AI chain.\n * Tries primary first, then each fallback in order.\n * When agentId is provided, uses that agent persona's model chain instead of defaults.\n */\n async chatCompletion(\n messages: Array<{ role: \"system\" | \"user\" | \"assistant\"; content: string }>,\n options: FallbackLlmOptions = {},\n ): Promise<FallbackLlmResponse | null> {\n const models = this.getModelChain(options.agentId);\n if (models.length === 0) {\n log.warn(\"fallback LLM: no models configured in gateway\");\n return null;\n }\n\n const runChain = async (): Promise<FallbackLlmResponse | null> => {\n // Try each model in the chain\n for (let i = 0; i < models.length; i++) {\n const model = models[i];\n const isFallback = i > 0;\n\n try {\n const result = await this.tryModel(model, messages, options);\n if (result) {\n if (isFallback) {\n log.info(`fallback LLM: succeeded using ${model.modelString} (fallback ${i})`);\n }\n return {\n content: result.content,\n modelUsed: model.modelString,\n usage: result.usage,\n };\n }\n } catch (err) {\n const errorMsg = err instanceof Error ? err.message : String(err);\n log.debug(`fallback LLM: ${model.modelString} failed (${errorMsg}), trying next...`);\n // Continue to next model in chain\n }\n }\n\n log.warn(`fallback LLM: all ${models.length} models in chain failed`);\n return null;\n };\n\n if (typeof options.timeoutMs === \"number\") {\n if (options.timeoutMs <= 0) {\n log.warn(\"fallback LLM: timed out before request started\");\n return null;\n }\n let timeoutHandle: ReturnType<typeof setTimeout> | undefined;\n try {\n return await Promise.race([\n runChain(),\n new Promise<null>((resolve) => {\n timeoutHandle = setTimeout(() => {\n log.warn(`fallback LLM: timed out after ${options.timeoutMs}ms`);\n resolve(null);\n }, options.timeoutMs);\n }),\n ]);\n } finally {\n if (timeoutHandle) clearTimeout(timeoutHandle);\n }\n }\n\n return await runChain();\n }\n\n /**\n * Make a request with structured output (Zod schema).\n * Returns parsed JSON or null on failure.\n */\n async parseWithSchema<T>(\n messages: Array<{ role: \"system\" | \"user\" | \"assistant\"; content: string }>,\n schema: { parse: (data: unknown) => T },\n options: FallbackLlmOptions = {},\n ): Promise<T | null> {\n const detailed = await this.parseWithSchemaDetailed(messages, schema, options);\n return detailed?.result ?? null;\n }\n\n /**\n * Like parseWithSchema but also returns the model that was used,\n * so callers can emit accurate trace events.\n */\n async parseWithSchemaDetailed<T>(\n messages: Array<{ role: \"system\" | \"user\" | \"assistant\"; content: string }>,\n schema: { parse: (data: unknown) => T },\n options: FallbackLlmOptions = {},\n ): Promise<{ result: T; modelUsed: string } | null> {\n const response = await this.chatCompletion(messages, options);\n if (!response?.content) return null;\n\n try {\n const candidates = extractJsonCandidates(response.content);\n for (const c of candidates) {\n try {\n const parsed = JSON.parse(c);\n return { result: schema.parse(parsed), modelUsed: response.modelUsed };\n } catch {\n // keep trying other candidates\n }\n }\n return null;\n } catch (err) {\n log.warn(\"fallback LLM: failed to parse structured output:\", err);\n return null;\n }\n }\n\n /**\n * Get the full model chain from gateway config.\n * Returns array of models in order: [primary, fallback1, fallback2, ...]\n *\n * When agentId is provided, looks up the matching entry in agents.list[]\n * and uses that persona's model chain. Falls back to agents.defaults.model\n * if agentId is not found or not provided.\n */\n private getModelChain(agentId?: string): ModelRef[] {\n const chain: ModelRef[] = [];\n const providers = this.gatewayConfig?.models?.providers;\n\n if (!providers) return chain;\n\n // Resolve the model config: agent persona chain or global defaults\n let modelConfig: { primary?: string; fallbacks?: string[] } | undefined;\n\n if (agentId) {\n const persona = this.gatewayConfig?.agents?.list?.find(\n (a) => a.id === agentId,\n );\n if (persona?.model) {\n modelConfig = persona.model;\n log.debug(`fallback LLM: using agent persona \"${agentId}\" model chain`);\n } else {\n log.warn(\n `fallback LLM: agent persona \"${agentId}\" not found or has no model config, falling back to defaults`,\n );\n }\n }\n\n if (!modelConfig) {\n modelConfig = this.gatewayConfig?.agents?.defaults?.model;\n }\n\n // Build list of model strings: primary + fallbacks\n const modelStrings: string[] = [];\n\n if (modelConfig?.primary) {\n modelStrings.push(modelConfig.primary);\n }\n\n if (Array.isArray(modelConfig?.fallbacks)) {\n for (const fb of modelConfig.fallbacks) {\n if (typeof fb === \"string\" && !modelStrings.includes(fb)) {\n modelStrings.push(fb);\n }\n }\n }\n\n // Parse each model string and look up provider config\n for (const modelString of modelStrings) {\n const modelRef = this.parseModelString(modelString, providers);\n if (modelRef) {\n chain.push(modelRef);\n }\n }\n\n return chain;\n }\n\n /**\n * Parse a \"provider/model\" string and look up its config.\n */\n private parseModelString(\n modelString: string,\n providers: Record<string, ModelProviderConfig>,\n ): ModelRef | null {\n // Parse \"provider/model\" format (e.g., \"openai/gpt-5.2\", \"anthropic/claude-opus-4-6\")\n const parts = modelString.split(\"/\");\n if (parts.length < 2) {\n log.warn(`fallback LLM: invalid model format: ${modelString}`);\n return null;\n }\n\n const providerId = parts[0];\n const modelId = parts.slice(1).join(\"/\"); // Handle cases like \"openai/gpt-5.2-turbo\"\n\n const providerConfig = providers[providerId];\n if (!providerConfig) {\n log.warn(`fallback LLM: provider not found: ${providerId}`);\n return null;\n }\n\n return { providerId, modelId, providerConfig, modelString };\n }\n\n /**\n * Resolve the API key for a provider, handling OpenClaw secret ref formats.\n * Results are cached per provider so exec calls only happen once.\n */\n private async resolveApiKey(\n providerId: string,\n providerConfig: ModelProviderConfig,\n ): Promise<string | undefined> {\n return resolveProviderApiKey(providerId, providerConfig.apiKey, this.gatewayConfig);\n }\n\n /**\n * Try to call a single model.\n */\n private async tryModel(\n model: ModelRef,\n messages: Array<{ role: \"system\" | \"user\" | \"assistant\"; content: string }>,\n options: FallbackLlmOptions,\n ): Promise<{ content: string; usage?: FallbackLlmResponse[\"usage\"] } | null> {\n // Resolve the API key from secret refs before making the call.\n // If the raw key looks like an unresolved secret ref and resolution fails,\n // skip this provider entirely so the chain falls through to the next.\n const rawKey = model.providerConfig.apiKey;\n const needsResolution = rawKey === \"secretref-managed\"\n || (typeof rawKey === \"object\" && rawKey !== null);\n const resolvedApiKey = await this.resolveApiKey(model.providerId, model.providerConfig);\n\n if (needsResolution && !resolvedApiKey) {\n throw new Error(`API key for provider \"${model.providerId}\" could not be resolved from secret ref`);\n }\n\n const configWithResolvedKey = resolvedApiKey\n ? { ...model.providerConfig, apiKey: resolvedApiKey }\n : model.providerConfig;\n\n switch (model.providerConfig.api) {\n case \"anthropic-messages\":\n return await this.callAnthropic(configWithResolvedKey, model.modelId, messages, options);\n case \"openai-completions\":\n default:\n return await this.callOpenAI(\n configWithResolvedKey,\n model.modelId,\n messages,\n options,\n shouldAssumeOpenAiChatCompletions(model.providerConfig.baseUrl),\n );\n }\n }\n\n /**\n * Call OpenAI-compatible API.\n */\n private async callOpenAI(\n config: ModelProviderConfig,\n modelId: string,\n messages: Array<{ role: \"system\" | \"user\" | \"assistant\"; content: string }>,\n options: FallbackLlmOptions,\n assumeOpenAI: boolean,\n ): Promise<{ content: string; usage?: FallbackLlmResponse[\"usage\"] } | null> {\n const base = config.baseUrl.replace(/\\/$/, \"\");\n const url = base.endsWith(\"/v1\")\n ? `${base}/chat/completions`\n : `${base}/v1/chat/completions`;\n\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n ...config.headers,\n };\n\n // Handle auth — apiKey is already resolved to a string by tryModel()\n if (config.apiKey && typeof config.apiKey === \"string\") {\n if (config.authHeader !== false) {\n headers[\"Authorization\"] = `Bearer ${config.apiKey}`;\n }\n }\n\n const body = {\n model: modelId,\n messages,\n temperature: options.temperature ?? 0.3,\n ...buildChatCompletionTokenLimit(modelId, options.maxTokens ?? 4096, {\n assumeOpenAI,\n }),\n };\n\n const response = await fetch(url, {\n method: \"POST\",\n headers,\n body: JSON.stringify(body),\n });\n\n if (!response.ok) {\n const error = await response.text();\n throw new Error(`OpenAI API error: ${response.status} ${error}`);\n }\n\n const data = (await response.json()) as {\n choices: Array<{\n message: {\n content: string;\n };\n }>;\n usage?: {\n prompt_tokens?: number;\n completion_tokens?: number;\n total_tokens?: number;\n };\n };\n\n const content = data.choices?.[0]?.message?.content;\n if (!content) {\n throw new Error(\"Empty response from OpenAI API\");\n }\n\n return {\n content,\n usage: data.usage\n ? {\n inputTokens: data.usage.prompt_tokens,\n outputTokens: data.usage.completion_tokens,\n totalTokens: data.usage.total_tokens,\n }\n : undefined,\n };\n }\n\n /**\n * Call Anthropic Messages API.\n */\n private async callAnthropic(\n config: ModelProviderConfig,\n modelId: string,\n messages: Array<{ role: \"system\" | \"user\" | \"assistant\"; content: string }>,\n options: FallbackLlmOptions,\n ): Promise<{ content: string; usage?: FallbackLlmResponse[\"usage\"] } | null> {\n const url = `${config.baseUrl.replace(/\\/$/, \"\")}/messages`;\n\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n \"anthropic-version\": \"2023-06-01\",\n ...config.headers,\n };\n\n // Handle auth - Anthropic uses x-api-key header (apiKey resolved by tryModel)\n if (config.apiKey && typeof config.apiKey === \"string\") {\n headers[\"x-api-key\"] = config.apiKey;\n }\n\n // Extract system message (Anthropic handles it separately)\n const systemMessage = messages.find((m) => m.role === \"system\")?.content;\n const nonSystemMessages = messages.filter((m) => m.role !== \"system\");\n\n // Convert messages to Anthropic format\n const anthropicMessages = nonSystemMessages.map((m) => ({\n role: m.role,\n content: m.content,\n }));\n\n const body: Record<string, unknown> = {\n model: modelId,\n messages: anthropicMessages,\n max_tokens: options.maxTokens ?? 4096,\n temperature: options.temperature ?? 0.3,\n };\n\n if (systemMessage) {\n body.system = systemMessage;\n }\n\n const response = await fetch(url, {\n method: \"POST\",\n headers,\n body: JSON.stringify(body),\n });\n\n if (!response.ok) {\n const error = await response.text();\n throw new Error(`Anthropic API error: ${response.status} ${error}`);\n }\n\n const data = (await response.json()) as {\n content: Array<{\n type: string;\n text: string;\n }>;\n usage?: {\n input_tokens?: number;\n output_tokens?: number;\n };\n };\n\n const content = data.content?.[0]?.text;\n if (!content) {\n throw new Error(\"Empty response from Anthropic API\");\n }\n\n return {\n content,\n usage: data.usage\n ? {\n inputTokens: data.usage.input_tokens,\n outputTokens: data.usage.output_tokens,\n totalTokens: (data.usage.input_tokens ?? 0) + (data.usage.output_tokens ?? 0),\n }\n : undefined,\n };\n }\n}\n"],"mappings":";;;;;;AAWO,SAAS,gBAAgB,MAAsB;AACpD,SAAO,KAAK,QAAQ,kCAAkC,CAAC,IAAI,UAAU,OAAO,KAAK,EAAE,KAAK,CAAC;AAC3F;AAEO,SAAS,sBAAsB,MAAwB;AAC5D,QAAM,UAAU,KAAK,KAAK;AAC1B,QAAM,UAAU,gBAAgB,OAAO;AACvC,QAAM,aAAuB,CAAC;AAE9B,MAAI,QAAQ,SAAS,EAAG,YAAW,KAAK,OAAO;AAC/C,aAAW,KAAK,GAAG,uBAAuB,OAAO,CAAC;AAGlD,QAAM,WAAW,QAAQ,MAAM,aAAa;AAC5C,MAAI,SAAU,YAAW,KAAK,SAAS,CAAC,CAAC;AAEzC,QAAM,OAAO,oBAAI,IAAY;AAC7B,SAAO,WACJ,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EACnB,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC,EAC1B,OAAO,CAAC,MAAM;AACb,QAAI,KAAK,IAAI,CAAC,EAAG,QAAO;AACxB,SAAK,IAAI,CAAC;AACV,WAAO;AAAA,EACT,CAAC;AACL;AAEA,SAAS,uBAAuB,MAAwB;AACtD,QAAM,MAAgB,CAAC;AACvB,QAAM,QAAQ,oBAAI,IAAI,CAAC,KAAK,GAAG,CAAC;AAChC,QAAM,SAAiC,EAAE,KAAK,KAAK,KAAK,IAAI;AAE5D,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,UAAM,QAAQ,KAAK,CAAC;AACpB,QAAI,CAAC,MAAM,IAAI,KAAK,EAAG;AAEvB,UAAM,g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EAAE;AAAA,IACb,EAAE;AAEF,UAAM,OAAgC;AAAA,MACpC,OAAO;AAAA,MACP,UAAU;AAAA,MACV,YAAY,QAAQ,aAAa;AAAA,MACjC,aAAa,QAAQ,eAAe;AAAA,IACtC;AAEA,QAAI,eAAe;AACjB,WAAK,SAAS;AAAA,IAChB;AAEA,UAAM,WAAW,MAAM,MAAM,KAAK;AAAA,MAChC,QAAQ;AAAA,MACR;AAAA,MACA,MAAM,KAAK,UAAU,IAAI;AAAA,IAC3B,CAAC;AAED,QAAI,CAAC,SAAS,IAAI;AAChB,YAAM,QAAQ,MAAM,SAAS,KAAK;AAClC,YAAM,IAAI,MAAM,wBAAwB,SAAS,MAAM,IAAI,KAAK,EAAE;AAAA,IACpE;AAEA,UAAM,OAAQ,MAAM,SAAS,KAAK;AAWlC,UAAM,UAAU,KAAK,UAAU,CAAC,GAAG;AACnC,QAAI,CAAC,SAAS;AACZ,YAAM,IAAI,MAAM,mCAAmC;AAAA,IACrD;AAEA,WAAO;AAAA,MACL;AAAA,MACA,OAAO,KAAK,QACR;AAAA,QACE,aAAa,KAAK,MAAM;AAAA,QACxB,cAAc,KAAK,MAAM;AAAA,QACzB,cAAc,KAAK,MAAM,gBAAgB,MAAM,KAAK,MAAM,iBAAiB;AAAA,MAC7E,IACA;AAAA,IACN;AAAA,EACF;AACF;","names":[]}
@@ -4088,4 +4088,4 @@ export {
4088
4088
  serializeEntityFile,
4089
4089
  StorageManager
4090
4090
  };
4091
- //# sourceMappingURL=chunk-DTCQ2KEX.js.map
4091
+ //# sourceMappingURL=chunk-Y6DMH5LN.js.map