@remnic/core 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -0
- package/dist/access-cli.js +10 -9
- package/dist/access-cli.js.map +1 -1
- package/dist/access-schema.d.ts +6 -6
- package/dist/calibration.js +3 -2
- package/dist/calibration.js.map +1 -1
- package/dist/causal-consolidation.js +3 -2
- package/dist/causal-consolidation.js.map +1 -1
- package/dist/{chunk-QFQVZOGA.js → chunk-6UJQNRIO.js} +2 -2
- package/dist/{chunk-CDW777AI.js → chunk-LP47L3ZX.js} +2 -2
- package/dist/{chunk-LU3GQNDQ.js → chunk-M5ZBBBJI.js} +12 -1
- package/dist/chunk-M5ZBBBJI.js.map +1 -0
- package/dist/chunk-OOSWAUYB.js +47 -0
- package/dist/chunk-OOSWAUYB.js.map +1 -0
- package/dist/{chunk-YAPUAHAY.js → chunk-OTFNI3OO.js} +32 -32
- package/dist/{chunk-TKO4HZCK.js → chunk-UYSKNO6E.js} +1 -1
- package/dist/{chunk-KT4NEUNF.js → chunk-XUHI52HK.js} +80 -22
- package/dist/chunk-XUHI52HK.js.map +1 -0
- package/dist/cli.js +1 -1
- package/dist/{engine-P26JFSVY.js → engine-2A6J4XEX.js} +2 -2
- package/dist/extraction.js +4 -3
- package/dist/fallback-llm.d.ts +22 -3
- package/dist/fallback-llm.js +3 -2
- package/dist/index.js +10 -9
- package/dist/index.js.map +1 -1
- package/dist/models-json.d.ts +17 -0
- package/dist/models-json.js +12 -0
- package/dist/models-json.js.map +1 -0
- package/dist/orchestrator.js +10 -9
- package/dist/resolve-provider-secret.d.ts +29 -1
- package/dist/resolve-provider-secret.js +3 -1
- package/dist/schemas.d.ts +18 -18
- package/dist/summarizer.js +4 -3
- package/package.json +2 -1
- package/dist/chunk-KT4NEUNF.js.map +0 -1
- package/dist/chunk-LU3GQNDQ.js.map +0 -1
- /package/dist/{chunk-QFQVZOGA.js.map → chunk-6UJQNRIO.js.map} +0 -0
- /package/dist/{chunk-CDW777AI.js.map → chunk-LP47L3ZX.js.map} +0 -0
- /package/dist/{chunk-YAPUAHAY.js.map → chunk-OTFNI3OO.js.map} +0 -0
- /package/dist/{chunk-TKO4HZCK.js.map → chunk-UYSKNO6E.js.map} +0 -0
- /package/dist/{engine-P26JFSVY.js.map → engine-2A6J4XEX.js.map} +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CompoundingEngine,
|
|
3
|
+
SharedContextManager,
|
|
4
|
+
defaultTierMigrationCycleBudget
|
|
5
|
+
} from "./chunk-UYSKNO6E.js";
|
|
1
6
|
import {
|
|
2
7
|
applyUtilityPromotionRuntimePolicy,
|
|
3
8
|
applyUtilityRankingRuntimeDelta,
|
|
4
9
|
loadUtilityRuntimeValues
|
|
5
10
|
} from "./chunk-IFFFR3MR.js";
|
|
6
|
-
import {
|
|
7
|
-
CompoundingEngine,
|
|
8
|
-
SharedContextManager,
|
|
9
|
-
defaultTierMigrationCycleBudget
|
|
10
|
-
} from "./chunk-TKO4HZCK.js";
|
|
11
11
|
import {
|
|
12
12
|
TierMigrationExecutor
|
|
13
13
|
} from "./chunk-Z5AAYHUC.js";
|
|
@@ -25,25 +25,7 @@ import {
|
|
|
25
25
|
} from "./chunk-ZKYI7UVO.js";
|
|
26
26
|
import {
|
|
27
27
|
HourlySummarizer
|
|
28
|
-
} from "./chunk-
|
|
29
|
-
import {
|
|
30
|
-
applyRuntimeRetrievalPolicy
|
|
31
|
-
} from "./chunk-G3AG3KZN.js";
|
|
32
|
-
import {
|
|
33
|
-
buildConsolidationPrompt,
|
|
34
|
-
findSimilarClusters,
|
|
35
|
-
parseConsolidationResponse
|
|
36
|
-
} from "./chunk-2CJCWDMR.js";
|
|
37
|
-
import {
|
|
38
|
-
findUnresolvedEntityRefs
|
|
39
|
-
} from "./chunk-X7XN6YU4.js";
|
|
40
|
-
import {
|
|
41
|
-
RelevanceStore
|
|
42
|
-
} from "./chunk-BRK4ODMI.js";
|
|
43
|
-
import {
|
|
44
|
-
RerankCache,
|
|
45
|
-
rerankLocalOrNoop
|
|
46
|
-
} from "./chunk-C7VW7C3F.js";
|
|
28
|
+
} from "./chunk-LP47L3ZX.js";
|
|
47
29
|
import {
|
|
48
30
|
mergeWithAgentResults,
|
|
49
31
|
runDirectAgent,
|
|
@@ -62,6 +44,29 @@ import {
|
|
|
62
44
|
recencyWindowFromPrompt,
|
|
63
45
|
resolvePromptTagPrefilterAsync
|
|
64
46
|
} from "./chunk-V3RXWQIE.js";
|
|
47
|
+
import {
|
|
48
|
+
applyRuntimeRetrievalPolicy
|
|
49
|
+
} from "./chunk-G3AG3KZN.js";
|
|
50
|
+
import {
|
|
51
|
+
buildConsolidationPrompt,
|
|
52
|
+
findSimilarClusters,
|
|
53
|
+
parseConsolidationResponse
|
|
54
|
+
} from "./chunk-2CJCWDMR.js";
|
|
55
|
+
import {
|
|
56
|
+
LastRecallStore,
|
|
57
|
+
TierMigrationStatusStore,
|
|
58
|
+
clampGraphRecallExpandedEntries
|
|
59
|
+
} from "./chunk-HG2NKWR2.js";
|
|
60
|
+
import {
|
|
61
|
+
findUnresolvedEntityRefs
|
|
62
|
+
} from "./chunk-X7XN6YU4.js";
|
|
63
|
+
import {
|
|
64
|
+
RelevanceStore
|
|
65
|
+
} from "./chunk-BRK4ODMI.js";
|
|
66
|
+
import {
|
|
67
|
+
RerankCache,
|
|
68
|
+
rerankLocalOrNoop
|
|
69
|
+
} from "./chunk-C7VW7C3F.js";
|
|
65
70
|
import {
|
|
66
71
|
buildQmdRecallCacheKey,
|
|
67
72
|
getCachedQmdRecall,
|
|
@@ -70,11 +75,6 @@ import {
|
|
|
70
75
|
import {
|
|
71
76
|
createRecallSectionMetricRecorder
|
|
72
77
|
} from "./chunk-L5RPWGFK.js";
|
|
73
|
-
import {
|
|
74
|
-
LastRecallStore,
|
|
75
|
-
TierMigrationStatusStore,
|
|
76
|
-
clampGraphRecallExpandedEntries
|
|
77
|
-
} from "./chunk-HG2NKWR2.js";
|
|
78
78
|
import {
|
|
79
79
|
NegativeExampleStore
|
|
80
80
|
} from "./chunk-GJR6D6KC.js";
|
|
@@ -89,7 +89,7 @@ import {
|
|
|
89
89
|
} from "./chunk-WWIQTB2Y.js";
|
|
90
90
|
import {
|
|
91
91
|
ExtractionEngine
|
|
92
|
-
} from "./chunk-
|
|
92
|
+
} from "./chunk-6UJQNRIO.js";
|
|
93
93
|
import {
|
|
94
94
|
parseMemoryActionEligibilityContext
|
|
95
95
|
} from "./chunk-MWGVGUIS.js";
|
|
@@ -199,7 +199,7 @@ import {
|
|
|
199
199
|
} from "./chunk-XYIK4LF6.js";
|
|
200
200
|
import {
|
|
201
201
|
FallbackLlmClient
|
|
202
|
-
} from "./chunk-
|
|
202
|
+
} from "./chunk-XUHI52HK.js";
|
|
203
203
|
import {
|
|
204
204
|
BoxBuilder
|
|
205
205
|
} from "./chunk-M5KEYE5E.js";
|
|
@@ -10758,4 +10758,4 @@ export {
|
|
|
10758
10758
|
resolvePersistedMemoryRelativePath,
|
|
10759
10759
|
Orchestrator
|
|
10760
10760
|
};
|
|
10761
|
-
//# sourceMappingURL=chunk-
|
|
10761
|
+
//# sourceMappingURL=chunk-OTFNI3OO.js.map
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
+
getGatewayRuntimeAuthForModel,
|
|
2
3
|
resolveProviderApiKey
|
|
3
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-M5ZBBBJI.js";
|
|
5
|
+
import {
|
|
6
|
+
loadModelsJsonProviders
|
|
7
|
+
} from "./chunk-OOSWAUYB.js";
|
|
4
8
|
import {
|
|
5
9
|
buildChatCompletionTokenLimit,
|
|
6
10
|
shouldAssumeOpenAiChatCompletions
|
|
@@ -122,8 +126,7 @@ var FallbackLlmClient = class {
|
|
|
122
126
|
*/
|
|
123
127
|
getModelChain(agentId) {
|
|
124
128
|
const chain = [];
|
|
125
|
-
const providers = this.gatewayConfig?.models?.providers;
|
|
126
|
-
if (!providers) return chain;
|
|
129
|
+
const providers = this.gatewayConfig?.models?.providers ?? {};
|
|
127
130
|
let modelConfig;
|
|
128
131
|
if (agentId) {
|
|
129
132
|
const persona = this.gatewayConfig?.agents?.list?.find(
|
|
@@ -171,7 +174,7 @@ var FallbackLlmClient = class {
|
|
|
171
174
|
}
|
|
172
175
|
const providerId = parts[0];
|
|
173
176
|
const modelId = parts.slice(1).join("/");
|
|
174
|
-
const providerConfig = providers[providerId];
|
|
177
|
+
const providerConfig = providers[providerId] ?? this.resolveFromModelsJson(providerId);
|
|
175
178
|
if (!providerConfig) {
|
|
176
179
|
log.warn(`fallback LLM: provider not found: ${providerId}`);
|
|
177
180
|
return null;
|
|
@@ -179,36 +182,91 @@ var FallbackLlmClient = class {
|
|
|
179
182
|
return { providerId, modelId, providerConfig, modelString };
|
|
180
183
|
}
|
|
181
184
|
/**
|
|
182
|
-
*
|
|
183
|
-
*
|
|
185
|
+
* Look up a provider from the gateway's materialized models.json, which
|
|
186
|
+
* contains all providers including built-in ones (openai-codex, google-vertex,
|
|
187
|
+
* etc.) that aren't in the user's openclaw.json but are registered by
|
|
188
|
+
* gateway plugins. Returns null if the provider isn't found there either.
|
|
184
189
|
*/
|
|
185
|
-
|
|
186
|
-
|
|
190
|
+
resolveFromModelsJson(providerId) {
|
|
191
|
+
const allProviders = loadModelsJsonProviders();
|
|
192
|
+
const config = allProviders[providerId];
|
|
193
|
+
if (config) {
|
|
194
|
+
log.debug(`fallback LLM: resolved provider "${providerId}" from models.json (api: ${config.api ?? "default"})`);
|
|
195
|
+
return config;
|
|
196
|
+
}
|
|
197
|
+
return null;
|
|
187
198
|
}
|
|
188
199
|
/**
|
|
189
200
|
* Try to call a single model.
|
|
201
|
+
*
|
|
202
|
+
* Uses the gateway's native getRuntimeAuthForModel when available — this
|
|
203
|
+
* handles all provider-specific auth transforms (OAuth token exchange,
|
|
204
|
+
* base URL overrides for codex/copilot/etc.) through the same codepath
|
|
205
|
+
* the gateway itself uses. Falls back to resolveProviderApiKey for
|
|
206
|
+
* simpler providers or when the runtime module isn't loaded.
|
|
190
207
|
*/
|
|
191
208
|
async tryModel(model, messages, options) {
|
|
209
|
+
const runtimeAuth = await this.resolveRuntimeAuth(model);
|
|
210
|
+
const effectiveBaseUrl = runtimeAuth?.baseUrl ?? model.providerConfig.baseUrl;
|
|
211
|
+
const resolvedApiKey = runtimeAuth?.apiKey ?? await this.resolveFallbackApiKey(model);
|
|
192
212
|
const rawKey = model.providerConfig.apiKey;
|
|
193
213
|
const needsResolution = rawKey === "secretref-managed" || typeof rawKey === "object" && rawKey !== null;
|
|
194
|
-
const resolvedApiKey = await this.resolveApiKey(model.providerId, model.providerConfig);
|
|
195
214
|
if (needsResolution && !resolvedApiKey) {
|
|
196
215
|
throw new Error(`API key for provider "${model.providerId}" could not be resolved from secret ref`);
|
|
197
216
|
}
|
|
198
|
-
const
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
217
|
+
const effectiveConfig = {
|
|
218
|
+
...model.providerConfig,
|
|
219
|
+
baseUrl: effectiveBaseUrl,
|
|
220
|
+
...resolvedApiKey ? { apiKey: resolvedApiKey } : {}
|
|
221
|
+
};
|
|
222
|
+
if (model.providerConfig.api === "anthropic-messages") {
|
|
223
|
+
return await this.callAnthropic(effectiveConfig, model.modelId, messages, options);
|
|
224
|
+
}
|
|
225
|
+
return await this.callOpenAI(
|
|
226
|
+
effectiveConfig,
|
|
227
|
+
model.modelId,
|
|
228
|
+
messages,
|
|
229
|
+
options,
|
|
230
|
+
shouldAssumeOpenAiChatCompletions(effectiveConfig.baseUrl)
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Resolve request-ready auth through the gateway's native runtime, which
|
|
235
|
+
* handles provider-specific transforms (OAuth token exchange for codex/copilot,
|
|
236
|
+
* base URL rewrite, etc.). Returns null if the runtime isn't available.
|
|
237
|
+
*/
|
|
238
|
+
async resolveRuntimeAuth(model) {
|
|
239
|
+
try {
|
|
240
|
+
const getRuntimeAuth = await getGatewayRuntimeAuthForModel();
|
|
241
|
+
if (!getRuntimeAuth) return null;
|
|
242
|
+
const result = await getRuntimeAuth({
|
|
243
|
+
model: {
|
|
244
|
+
provider: model.providerId,
|
|
245
|
+
id: model.modelId,
|
|
246
|
+
api: model.providerConfig.api,
|
|
247
|
+
baseUrl: model.providerConfig.baseUrl
|
|
248
|
+
},
|
|
249
|
+
cfg: this.gatewayConfig
|
|
250
|
+
});
|
|
251
|
+
if (result?.apiKey || result?.baseUrl) {
|
|
252
|
+
log.debug(
|
|
253
|
+
`fallback LLM: resolved runtime auth for "${model.modelString}" (source: ${result.source ?? "unknown"}, mode: ${result.mode ?? "unknown"})`
|
|
210
254
|
);
|
|
255
|
+
return { apiKey: result.apiKey, baseUrl: result.baseUrl };
|
|
256
|
+
}
|
|
257
|
+
} catch (err) {
|
|
258
|
+
log.debug(
|
|
259
|
+
`fallback LLM: gateway runtime auth failed for "${model.modelString}": ${err instanceof Error ? err.message : String(err)}`
|
|
260
|
+
);
|
|
211
261
|
}
|
|
262
|
+
return null;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Resolve API key through the existing provider-level resolution (env vars,
|
|
266
|
+
* secret refs, etc.). Used as fallback when gateway runtime auth isn't available.
|
|
267
|
+
*/
|
|
268
|
+
async resolveFallbackApiKey(model) {
|
|
269
|
+
return resolveProviderApiKey(model.providerId, model.providerConfig.apiKey, this.gatewayConfig);
|
|
212
270
|
}
|
|
213
271
|
/**
|
|
214
272
|
* Call OpenAI-compatible API.
|
|
@@ -312,4 +370,4 @@ var FallbackLlmClient = class {
|
|
|
312
370
|
export {
|
|
313
371
|
FallbackLlmClient
|
|
314
372
|
};
|
|
315
|
-
//# sourceMappingURL=chunk-
|
|
373
|
+
//# sourceMappingURL=chunk-XUHI52HK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/fallback-llm.ts"],"sourcesContent":["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, getGatewayRuntimeAuthForModel } from \"./resolve-provider-secret.js\";\nimport { loadModelsJsonProviders } from \"./models-json.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.debug(`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 // 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 // Look up explicit config first; fall back to the gateway's materialized\n // models.json which contains built-in providers (openai-codex, etc.)\n const providerConfig = providers[providerId] ?? this.resolveFromModelsJson(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 * Look up a provider from the gateway's materialized models.json, which\n * contains all providers including built-in ones (openai-codex, google-vertex,\n * etc.) that aren't in the user's openclaw.json but are registered by\n * gateway plugins. Returns null if the provider isn't found there either.\n */\n private resolveFromModelsJson(providerId: string): ModelProviderConfig | null {\n const allProviders = loadModelsJsonProviders();\n const config = allProviders[providerId];\n if (config) {\n log.debug(`fallback LLM: resolved provider \"${providerId}\" from models.json (api: ${config.api ?? \"default\"})`);\n return config;\n }\n return null;\n }\n\n /**\n * Try to call a single model.\n *\n * Uses the gateway's native getRuntimeAuthForModel when available — this\n * handles all provider-specific auth transforms (OAuth token exchange,\n * base URL overrides for codex/copilot/etc.) through the same codepath\n * the gateway itself uses. Falls back to resolveProviderApiKey for\n * simpler providers or when the runtime module isn't loaded.\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 // Try the gateway's native runtime auth first — it handles all provider-\n // specific transforms (OAuth exchange, base URL rewrite, etc.)\n const runtimeAuth = await this.resolveRuntimeAuth(model);\n const effectiveBaseUrl = runtimeAuth?.baseUrl ?? model.providerConfig.baseUrl;\n const resolvedApiKey = runtimeAuth?.apiKey ?? await this.resolveFallbackApiKey(model);\n\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 if (needsResolution && !resolvedApiKey) {\n throw new Error(`API key for provider \"${model.providerId}\" could not be resolved from secret ref`);\n }\n\n const effectiveConfig: ModelProviderConfig = {\n ...model.providerConfig,\n baseUrl: effectiveBaseUrl,\n ...(resolvedApiKey ? { apiKey: resolvedApiKey } : {}),\n };\n\n if (model.providerConfig.api === \"anthropic-messages\") {\n return await this.callAnthropic(effectiveConfig, model.modelId, messages, options);\n }\n\n // For OpenAI-compatible APIs (openai-completions, openai-responses,\n // openai-codex-responses, ollama, etc.) and unknown formats, use\n // OpenAI chat completions — the gateway's runtime auth resolver returns\n // request-ready base URL and credentials for most providers.\n return await this.callOpenAI(\n effectiveConfig,\n model.modelId,\n messages,\n options,\n shouldAssumeOpenAiChatCompletions(effectiveConfig.baseUrl),\n );\n }\n\n /**\n * Resolve request-ready auth through the gateway's native runtime, which\n * handles provider-specific transforms (OAuth token exchange for codex/copilot,\n * base URL rewrite, etc.). Returns null if the runtime isn't available.\n */\n private async resolveRuntimeAuth(\n model: ModelRef,\n ): Promise<{ apiKey?: string; baseUrl?: string } | null> {\n try {\n const getRuntimeAuth = await getGatewayRuntimeAuthForModel();\n if (!getRuntimeAuth) return null;\n\n const result = await getRuntimeAuth({\n model: {\n provider: model.providerId,\n id: model.modelId,\n api: model.providerConfig.api,\n baseUrl: model.providerConfig.baseUrl,\n },\n cfg: this.gatewayConfig,\n });\n\n if (result?.apiKey || result?.baseUrl) {\n log.debug(\n `fallback LLM: resolved runtime auth for \"${model.modelString}\" (source: ${result.source ?? \"unknown\"}, mode: ${result.mode ?? \"unknown\"})`,\n );\n return { apiKey: result.apiKey, baseUrl: result.baseUrl };\n }\n } catch (err) {\n log.debug(\n `fallback LLM: gateway runtime auth failed for \"${model.modelString}\": ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n return null;\n }\n\n /**\n * Resolve API key through the existing provider-level resolution (env vars,\n * secret refs, etc.). Used as fallback when gateway runtime auth isn't available.\n */\n private async resolveFallbackApiKey(model: ModelRef): Promise<string | undefined> {\n return resolveProviderApiKey(model.providerId, model.providerConfig.apiKey, this.gatewayConfig);\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":";;;;;;;;;;;;;;;;;;;AAwCO,IAAM,oBAAN,MAAwB;AAAA,EACrB;AAAA,EAER,YAAY,eAA+B;AACzC,SAAK,gBAAgB;AAAA,EACvB;AAA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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":[]}
|
package/dist/cli.js
CHANGED
|
@@ -3643,7 +3643,7 @@ async function runSemanticRulePromoteCliCommand(options) {
|
|
|
3643
3643
|
});
|
|
3644
3644
|
}
|
|
3645
3645
|
async function runCompoundingPromoteCliCommand(options) {
|
|
3646
|
-
const { CompoundingEngine } = await import("./engine-
|
|
3646
|
+
const { CompoundingEngine } = await import("./engine-2A6J4XEX.js");
|
|
3647
3647
|
const config = parseConfig({
|
|
3648
3648
|
memoryDir: options.memoryDir,
|
|
3649
3649
|
qmdEnabled: false,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CompoundingEngine,
|
|
3
3
|
defaultTierMigrationCycleBudget
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-UYSKNO6E.js";
|
|
5
5
|
import "./chunk-QWUUMMIK.js";
|
|
6
6
|
import "./chunk-U4PV25RD.js";
|
|
7
7
|
import "./chunk-ESSMF2FR.js";
|
|
@@ -16,4 +16,4 @@ export {
|
|
|
16
16
|
CompoundingEngine,
|
|
17
17
|
defaultTierMigrationCycleBudget
|
|
18
18
|
};
|
|
19
|
-
//# sourceMappingURL=engine-
|
|
19
|
+
//# sourceMappingURL=engine-2A6J4XEX.js.map
|
package/dist/extraction.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ExtractionEngine
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-6UJQNRIO.js";
|
|
4
4
|
import "./chunk-MWGVGUIS.js";
|
|
5
5
|
import "./chunk-763GUIOU.js";
|
|
6
6
|
import "./chunk-ONRU4L2N.js";
|
|
@@ -8,8 +8,9 @@ import "./chunk-MDDAA2AO.js";
|
|
|
8
8
|
import "./chunk-2PO5ZRKV.js";
|
|
9
9
|
import "./chunk-VEWZZM3H.js";
|
|
10
10
|
import "./chunk-LK6SGL53.js";
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-XUHI52HK.js";
|
|
12
|
+
import "./chunk-M5ZBBBJI.js";
|
|
13
|
+
import "./chunk-OOSWAUYB.js";
|
|
13
14
|
import "./chunk-Y27UJK6V.js";
|
|
14
15
|
import "./chunk-UZB5KHKX.js";
|
|
15
16
|
import "./chunk-MARWOCVP.js";
|
package/dist/fallback-llm.d.ts
CHANGED
|
@@ -74,14 +74,33 @@ declare class FallbackLlmClient {
|
|
|
74
74
|
*/
|
|
75
75
|
private parseModelString;
|
|
76
76
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
77
|
+
* Look up a provider from the gateway's materialized models.json, which
|
|
78
|
+
* contains all providers including built-in ones (openai-codex, google-vertex,
|
|
79
|
+
* etc.) that aren't in the user's openclaw.json but are registered by
|
|
80
|
+
* gateway plugins. Returns null if the provider isn't found there either.
|
|
79
81
|
*/
|
|
80
|
-
private
|
|
82
|
+
private resolveFromModelsJson;
|
|
81
83
|
/**
|
|
82
84
|
* Try to call a single model.
|
|
85
|
+
*
|
|
86
|
+
* Uses the gateway's native getRuntimeAuthForModel when available — this
|
|
87
|
+
* handles all provider-specific auth transforms (OAuth token exchange,
|
|
88
|
+
* base URL overrides for codex/copilot/etc.) through the same codepath
|
|
89
|
+
* the gateway itself uses. Falls back to resolveProviderApiKey for
|
|
90
|
+
* simpler providers or when the runtime module isn't loaded.
|
|
83
91
|
*/
|
|
84
92
|
private tryModel;
|
|
93
|
+
/**
|
|
94
|
+
* Resolve request-ready auth through the gateway's native runtime, which
|
|
95
|
+
* handles provider-specific transforms (OAuth token exchange for codex/copilot,
|
|
96
|
+
* base URL rewrite, etc.). Returns null if the runtime isn't available.
|
|
97
|
+
*/
|
|
98
|
+
private resolveRuntimeAuth;
|
|
99
|
+
/**
|
|
100
|
+
* Resolve API key through the existing provider-level resolution (env vars,
|
|
101
|
+
* secret refs, etc.). Used as fallback when gateway runtime auth isn't available.
|
|
102
|
+
*/
|
|
103
|
+
private resolveFallbackApiKey;
|
|
85
104
|
/**
|
|
86
105
|
* Call OpenAI-compatible API.
|
|
87
106
|
*/
|
package/dist/fallback-llm.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FallbackLlmClient
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-XUHI52HK.js";
|
|
4
|
+
import "./chunk-M5ZBBBJI.js";
|
|
5
|
+
import "./chunk-OOSWAUYB.js";
|
|
5
6
|
import "./chunk-Y27UJK6V.js";
|
|
6
7
|
import "./chunk-UZB5KHKX.js";
|
|
7
8
|
import "./chunk-MARWOCVP.js";
|
package/dist/index.js
CHANGED
|
@@ -14,32 +14,32 @@ import {
|
|
|
14
14
|
migrateFromEngram,
|
|
15
15
|
rollbackFromEngramMigration,
|
|
16
16
|
sanitizeSessionKeyForFilename
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-OTFNI3OO.js";
|
|
18
|
+
import "./chunk-UYSKNO6E.js";
|
|
18
19
|
import "./chunk-IFFFR3MR.js";
|
|
19
|
-
import "./chunk-TKO4HZCK.js";
|
|
20
20
|
import "./chunk-Z5AAYHUC.js";
|
|
21
21
|
import "./chunk-4A24LIM2.js";
|
|
22
22
|
import "./chunk-TPB3I2AC.js";
|
|
23
23
|
import "./chunk-UHGBNIOS.js";
|
|
24
24
|
import "./chunk-ZKYI7UVO.js";
|
|
25
|
-
import "./chunk-
|
|
25
|
+
import "./chunk-LP47L3ZX.js";
|
|
26
26
|
import "./chunk-ETOW6ACV.js";
|
|
27
|
+
import "./chunk-GPGBSNKM.js";
|
|
28
|
+
import "./chunk-V3RXWQIE.js";
|
|
27
29
|
import "./chunk-G3AG3KZN.js";
|
|
28
30
|
import "./chunk-2CJCWDMR.js";
|
|
31
|
+
import "./chunk-HG2NKWR2.js";
|
|
29
32
|
import "./chunk-X7XN6YU4.js";
|
|
30
33
|
import "./chunk-BRK4ODMI.js";
|
|
31
34
|
import "./chunk-C7VW7C3F.js";
|
|
32
|
-
import "./chunk-GPGBSNKM.js";
|
|
33
|
-
import "./chunk-V3RXWQIE.js";
|
|
34
35
|
import "./chunk-YCN4BVDK.js";
|
|
35
36
|
import "./chunk-L5RPWGFK.js";
|
|
36
|
-
import "./chunk-HG2NKWR2.js";
|
|
37
37
|
import "./chunk-GJR6D6KC.js";
|
|
38
38
|
import "./chunk-H63EDPFJ.js";
|
|
39
39
|
import "./chunk-WWIQTB2Y.js";
|
|
40
40
|
import {
|
|
41
41
|
ExtractionEngine
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-6UJQNRIO.js";
|
|
43
43
|
import "./chunk-MWGVGUIS.js";
|
|
44
44
|
import "./chunk-763GUIOU.js";
|
|
45
45
|
import "./chunk-ONRU4L2N.js";
|
|
@@ -93,8 +93,9 @@ import {
|
|
|
93
93
|
} from "./chunk-YNI4S5WT.js";
|
|
94
94
|
import "./chunk-DORBM6OB.js";
|
|
95
95
|
import "./chunk-XYIK4LF6.js";
|
|
96
|
-
import "./chunk-
|
|
97
|
-
import "./chunk-
|
|
96
|
+
import "./chunk-XUHI52HK.js";
|
|
97
|
+
import "./chunk-M5ZBBBJI.js";
|
|
98
|
+
import "./chunk-OOSWAUYB.js";
|
|
98
99
|
import "./chunk-Y27UJK6V.js";
|
|
99
100
|
import "./chunk-UZB5KHKX.js";
|
|
100
101
|
import "./chunk-M5KEYE5E.js";
|