@dexto/core 1.10.2 → 1.10.4
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 +7 -7
- package/dist/agent/DextoAgent.cjs +29 -13
- package/dist/agent/DextoAgent.d.ts +3 -2
- package/dist/agent/DextoAgent.d.ts.map +1 -1
- package/dist/agent/DextoAgent.js +37 -19
- package/dist/agent/agent-options.d.ts +5 -0
- package/dist/agent/agent-options.d.ts.map +1 -1
- package/dist/approval/schemas.d.ts +8 -8
- package/dist/context/manager.cjs +9 -4
- package/dist/context/manager.d.ts +3 -1
- package/dist/context/manager.d.ts.map +1 -1
- package/dist/context/manager.js +8 -3
- package/dist/context/types.d.ts +3 -1
- package/dist/context/types.d.ts.map +1 -1
- package/dist/context/utils.cjs +20 -6
- package/dist/context/utils.d.ts +5 -2
- package/dist/context/utils.d.ts.map +1 -1
- package/dist/context/utils.js +24 -7
- package/dist/events/index.d.ts +0 -4
- package/dist/events/index.d.ts.map +1 -1
- package/dist/index.browser.cjs +12 -9
- package/dist/index.browser.d.ts +1 -0
- package/dist/index.browser.d.ts.map +1 -1
- package/dist/index.browser.js +2 -0
- package/dist/llm/curation.cjs +4 -5
- package/dist/llm/curation.d.ts +3 -3
- package/dist/llm/curation.d.ts.map +1 -1
- package/dist/llm/curation.js +5 -6
- package/dist/llm/executor/provider-options.cjs +14 -8
- package/dist/llm/executor/provider-options.d.ts +2 -1
- package/dist/llm/executor/provider-options.d.ts.map +1 -1
- package/dist/llm/executor/provider-options.js +14 -8
- package/dist/llm/executor/stream-processor.cjs +16 -4
- package/dist/llm/executor/stream-processor.d.ts +1 -0
- package/dist/llm/executor/stream-processor.d.ts.map +1 -1
- package/dist/llm/executor/stream-processor.js +16 -4
- package/dist/llm/executor/turn-executor.cjs +9 -2
- package/dist/llm/executor/turn-executor.d.ts +2 -1
- package/dist/llm/executor/turn-executor.d.ts.map +1 -1
- package/dist/llm/executor/turn-executor.js +9 -2
- package/dist/llm/formatters/vercel.cjs +10 -2
- package/dist/llm/formatters/vercel.d.ts +3 -2
- package/dist/llm/formatters/vercel.d.ts.map +1 -1
- package/dist/llm/formatters/vercel.js +10 -2
- package/dist/llm/registry/auto-update.cjs +19 -4
- package/dist/llm/registry/auto-update.d.ts.map +1 -1
- package/dist/llm/registry/auto-update.js +20 -5
- package/dist/llm/registry/index.cjs +40 -15
- package/dist/llm/registry/index.d.ts +7 -7
- package/dist/llm/registry/index.d.ts.map +1 -1
- package/dist/llm/registry/index.js +42 -21
- package/dist/llm/resolver.cjs +16 -15
- package/dist/llm/resolver.d.ts +4 -3
- package/dist/llm/resolver.d.ts.map +1 -1
- package/dist/llm/resolver.js +18 -23
- package/dist/llm/schemas.cjs +137 -124
- package/dist/llm/schemas.d.ts +69 -1
- package/dist/llm/schemas.d.ts.map +1 -1
- package/dist/llm/schemas.js +136 -130
- package/dist/llm/services/factory.cjs +3 -1
- package/dist/llm/services/factory.d.ts.map +1 -1
- package/dist/llm/services/factory.js +3 -1
- package/dist/llm/services/types.d.ts +4 -0
- package/dist/llm/services/types.d.ts.map +1 -1
- package/dist/llm/services/vercel.cjs +15 -6
- package/dist/llm/services/vercel.d.ts +3 -1
- package/dist/llm/services/vercel.d.ts.map +1 -1
- package/dist/llm/services/vercel.js +15 -6
- package/dist/llm/usage-metadata.cjs +2 -2
- package/dist/llm/usage-metadata.d.ts +2 -1
- package/dist/llm/usage-metadata.d.ts.map +1 -1
- package/dist/llm/usage-metadata.js +6 -3
- package/dist/llm/validation.cjs +7 -7
- package/dist/llm/validation.d.ts +3 -2
- package/dist/llm/validation.d.ts.map +1 -1
- package/dist/llm/validation.js +12 -8
- package/dist/session/chat-session.cjs +5 -2
- package/dist/session/chat-session.d.ts +2 -0
- package/dist/session/chat-session.d.ts.map +1 -1
- package/dist/session/chat-session.js +5 -2
- package/dist/session/session-manager.cjs +2 -0
- package/dist/session/session-manager.d.ts +2 -0
- package/dist/session/session-manager.d.ts.map +1 -1
- package/dist/session/session-manager.js +2 -0
- package/dist/storage/index.cjs +9 -2
- package/dist/storage/index.d.ts +1 -0
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +9 -1
- package/dist/storage/tool-executions/types.cjs +16 -0
- package/dist/storage/tool-executions/types.d.ts +19 -4
- package/dist/storage/tool-executions/types.d.ts.map +1 -1
- package/dist/storage/tool-executions/types.js +16 -0
- package/dist/tools/display-types.cjs +41 -0
- package/dist/tools/display-types.d.ts +54 -3
- package/dist/tools/display-types.d.ts.map +1 -1
- package/dist/tools/display-types.js +36 -0
- package/dist/tools/presentation/tool-presentation.cjs +47 -0
- package/dist/tools/presentation/tool-presentation.d.ts +10 -1
- package/dist/tools/presentation/tool-presentation.d.ts.map +1 -1
- package/dist/tools/presentation/tool-presentation.js +47 -0
- package/dist/tools/presentation-schema.d.ts +2 -2
- package/dist/tools/presentation.d.ts +1 -0
- package/dist/tools/presentation.d.ts.map +1 -1
- package/dist/tools/tool-call-metadata.cjs +17 -3
- package/dist/tools/tool-call-metadata.d.ts +4 -1
- package/dist/tools/tool-call-metadata.d.ts.map +1 -1
- package/dist/tools/tool-call-metadata.js +17 -3
- package/dist/tools/tool-manager.cjs +14 -5
- package/dist/tools/tool-manager.d.ts +0 -1
- package/dist/tools/tool-manager.d.ts.map +1 -1
- package/dist/tools/tool-manager.js +14 -5
- package/dist/tools/types.d.ts +21 -0
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/utils/service-initializer.cjs +3 -2
- package/dist/utils/service-initializer.d.ts +2 -1
- package/dist/utils/service-initializer.d.ts.map +1 -1
- package/dist/utils/service-initializer.js +3 -2
- package/package.json +2 -2
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Provider-specific options builder for Vercel AI SDK's streamText/generateText.
|
|
3
3
|
*/
|
|
4
|
-
import type { LLMProvider, LLMReasoningConfig } from '@dexto/llm';
|
|
4
|
+
import type { LLMProvider, LLMReasoningConfig, ModelRegistry } from '@dexto/llm';
|
|
5
5
|
export interface ProviderOptionsConfig {
|
|
6
6
|
provider: LLMProvider;
|
|
7
7
|
model: string;
|
|
8
8
|
reasoning?: LLMReasoningConfig | undefined;
|
|
9
|
+
llmRegistry?: ModelRegistry;
|
|
9
10
|
}
|
|
10
11
|
export declare function getEffectiveReasoningBudgetTokens(providerOptions: Record<string, Record<string, unknown>> | undefined): number | undefined;
|
|
11
12
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-options.d.ts","sourceRoot":"","sources":["../../../src/llm/executor/provider-options.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"provider-options.d.ts","sourceRoot":"","sources":["../../../src/llm/executor/provider-options.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAejF,MAAM,WAAW,qBAAqB;IAClC,QAAQ,EAAE,WAAW,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,kBAAkB,GAAG,SAAS,CAAC;IAC3C,WAAW,CAAC,EAAE,aAAa,CAAC;CAC/B;AA+LD,wBAAgB,iCAAiC,CAC7C,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,GACrE,MAAM,GAAG,SAAS,CA6BpB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAChC,MAAM,EAAE,qBAAqB,GAC9B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,CAkJrD"}
|
|
@@ -28,7 +28,7 @@ function toOpenAICompatibleReasoningEffort(reasoningVariant) {
|
|
|
28
28
|
return reasoningVariant === "none" || reasoningVariant === "low" || reasoningVariant === "medium" || reasoningVariant === "high" ? reasoningVariant : void 0;
|
|
29
29
|
}
|
|
30
30
|
function getSelectedReasoningVariant(config) {
|
|
31
|
-
const profile = getReasoningProfile(config.provider, config.model);
|
|
31
|
+
const profile = getReasoningProfile(config.provider, config.model, config.llmRegistry);
|
|
32
32
|
const requested = config.reasoning?.variant;
|
|
33
33
|
if (requested !== void 0) {
|
|
34
34
|
const supported = profile.variants.some((entry) => entry.id === requested);
|
|
@@ -101,7 +101,7 @@ function buildAnthropicProviderOptions(config) {
|
|
|
101
101
|
}
|
|
102
102
|
function buildOpenRouterProviderOptions(config) {
|
|
103
103
|
const { provider, model, reasoningVariant, budgetTokens } = config;
|
|
104
|
-
const profile = getReasoningProfile(provider, model);
|
|
104
|
+
const profile = getReasoningProfile(provider, model, config.llmRegistry);
|
|
105
105
|
if (!profile.capable) {
|
|
106
106
|
return void 0;
|
|
107
107
|
}
|
|
@@ -172,11 +172,11 @@ function buildProviderOptions(config) {
|
|
|
172
172
|
return void 0;
|
|
173
173
|
}
|
|
174
174
|
if (provider === "anthropic") {
|
|
175
|
-
const capable = isReasoningCapableModel(model, "anthropic");
|
|
175
|
+
const capable = isReasoningCapableModel(model, "anthropic", config.llmRegistry);
|
|
176
176
|
return buildAnthropicProviderOptions({ model, reasoningVariant, budgetTokens, capable });
|
|
177
177
|
}
|
|
178
178
|
if (provider === "bedrock") {
|
|
179
|
-
const capable = getReasoningProfile("bedrock", model).capable;
|
|
179
|
+
const capable = getReasoningProfile("bedrock", model, config.llmRegistry).capable;
|
|
180
180
|
if (!capable) {
|
|
181
181
|
return { bedrock: {} };
|
|
182
182
|
}
|
|
@@ -211,11 +211,11 @@ function buildProviderOptions(config) {
|
|
|
211
211
|
return { bedrock };
|
|
212
212
|
}
|
|
213
213
|
if (provider === "vertex" && modelLower.includes("claude")) {
|
|
214
|
-
const capable = isReasoningCapableModel(model, "vertex");
|
|
214
|
+
const capable = isReasoningCapableModel(model, "vertex", config.llmRegistry);
|
|
215
215
|
return buildAnthropicProviderOptions({ model, reasoningVariant, budgetTokens, capable });
|
|
216
216
|
}
|
|
217
217
|
if (provider === "google" || provider === "vertex" && !modelLower.includes("claude")) {
|
|
218
|
-
const profile = getReasoningProfile(provider, model);
|
|
218
|
+
const profile = getReasoningProfile(provider, model, config.llmRegistry);
|
|
219
219
|
const includeThoughts = profile.capable && reasoningVariant !== "disabled";
|
|
220
220
|
const isThinkingLevel = profile.paradigm === "thinking-level";
|
|
221
221
|
const thinkingLevel = includeThoughts && isThinkingLevel && (reasoningVariant === "minimal" || reasoningVariant === "low" || reasoningVariant === "medium" || reasoningVariant === "high") ? reasoningVariant : void 0;
|
|
@@ -250,10 +250,16 @@ function buildProviderOptions(config) {
|
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
252
|
if (isOpenRouterGatewayProvider(provider)) {
|
|
253
|
-
return buildOpenRouterProviderOptions({
|
|
253
|
+
return buildOpenRouterProviderOptions({
|
|
254
|
+
provider,
|
|
255
|
+
model,
|
|
256
|
+
reasoningVariant,
|
|
257
|
+
budgetTokens,
|
|
258
|
+
...config.llmRegistry !== void 0 && { llmRegistry: config.llmRegistry }
|
|
259
|
+
});
|
|
254
260
|
}
|
|
255
261
|
if (provider === "openai-compatible") {
|
|
256
|
-
const profile = getReasoningProfile(provider, model);
|
|
262
|
+
const profile = getReasoningProfile(provider, model, config.llmRegistry);
|
|
257
263
|
if (!profile.capable) return void 0;
|
|
258
264
|
const reasoningEffort = toOpenAICompatibleReasoningEffort(reasoningVariant);
|
|
259
265
|
if (reasoningEffort === void 0) return void 0;
|
|
@@ -317,7 +317,10 @@ class StreamProcessor {
|
|
|
317
317
|
const pricingMetadata = (0, import_usage_metadata.getUsagePricingMetadata)({
|
|
318
318
|
provider: this.config.provider,
|
|
319
319
|
model: this.config.model,
|
|
320
|
-
tokenUsage: usage
|
|
320
|
+
tokenUsage: usage,
|
|
321
|
+
...this.config.llmRegistry !== void 0 && {
|
|
322
|
+
llmRegistry: this.config.llmRegistry
|
|
323
|
+
}
|
|
321
324
|
});
|
|
322
325
|
this.logger.info("LLM response complete", {
|
|
323
326
|
finishReason: event.finishReason,
|
|
@@ -364,7 +367,10 @@ class StreamProcessor {
|
|
|
364
367
|
const abortPricingMetadata = (0, import_usage_metadata.getUsagePricingMetadata)({
|
|
365
368
|
provider: this.config.provider,
|
|
366
369
|
model: this.config.model,
|
|
367
|
-
tokenUsage: this.actualTokens
|
|
370
|
+
tokenUsage: this.actualTokens,
|
|
371
|
+
...this.config.llmRegistry !== void 0 && {
|
|
372
|
+
llmRegistry: this.config.llmRegistry
|
|
373
|
+
}
|
|
368
374
|
});
|
|
369
375
|
await this.persistAssistantResponseMetadata(
|
|
370
376
|
this.actualTokens,
|
|
@@ -394,7 +400,10 @@ class StreamProcessor {
|
|
|
394
400
|
const abortPricingMetadata = (0, import_usage_metadata.getUsagePricingMetadata)({
|
|
395
401
|
provider: this.config.provider,
|
|
396
402
|
model: this.config.model,
|
|
397
|
-
tokenUsage: this.actualTokens
|
|
403
|
+
tokenUsage: this.actualTokens,
|
|
404
|
+
...this.config.llmRegistry !== void 0 && {
|
|
405
|
+
llmRegistry: this.config.llmRegistry
|
|
406
|
+
}
|
|
398
407
|
});
|
|
399
408
|
await this.persistAssistantResponseMetadata(
|
|
400
409
|
this.actualTokens,
|
|
@@ -421,7 +430,10 @@ class StreamProcessor {
|
|
|
421
430
|
const failurePricingMetadata = (0, import_usage_metadata.getUsagePricingMetadata)({
|
|
422
431
|
provider: this.config.provider,
|
|
423
432
|
model: this.config.model,
|
|
424
|
-
tokenUsage: this.actualTokens
|
|
433
|
+
tokenUsage: this.actualTokens,
|
|
434
|
+
...this.config.llmRegistry !== void 0 && {
|
|
435
|
+
llmRegistry: this.config.llmRegistry
|
|
436
|
+
}
|
|
425
437
|
});
|
|
426
438
|
await this.persistAssistantResponseMetadata(this.actualTokens, failurePricingMetadata, {
|
|
427
439
|
status: "stopped",
|
|
@@ -7,6 +7,7 @@ import type { LLMProvider, ReasoningVariant } from '@dexto/llm';
|
|
|
7
7
|
export interface StreamProcessorConfig {
|
|
8
8
|
provider: LLMProvider;
|
|
9
9
|
model: string;
|
|
10
|
+
llmRegistry?: import('@dexto/llm').ModelRegistry;
|
|
10
11
|
usageScopeId?: string;
|
|
11
12
|
/** Estimated input tokens before LLM call (for analytics/calibration) */
|
|
12
13
|
estimatedInputTokens?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream-processor.d.ts","sourceRoot":"","sources":["../../../src/llm/executor/stream-processor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,IAAI,CAAC;AAEhE,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAmB,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAKvD,OAAO,KAAK,EAAE,WAAW,EAAoB,gBAAgB,EAAc,MAAM,YAAY,CAAC;AA4D9F,MAAM,WAAW,qBAAqB;IAClC,QAAQ,EAAE,WAAW,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,yEAAyE;IACzE,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,0EAA0E;IAC1E,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,gFAAgF;IAChF,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAClC;AAED,qBAAa,eAAe;IA6BpB,OAAO,CAAC,cAAc;IACtB,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,MAAM;IAEd,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,eAAe;IAlC3B,OAAO,CAAC,kBAAkB,CAAuB;IACjD,OAAO,CAAC,YAAY,C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eAAe;YA8BT,gCAAgC;IA4B9C,OAAO,CAAC,sBAAsB;YAwChB,sBAAsB;IAMpC;;;;OAIG;YACW,2BAA2B;IAQzC;;OAEG;YACW,wBAAwB;YAQxB,yBAAyB;CAuC1C"}
|
|
@@ -295,7 +295,10 @@ class StreamProcessor {
|
|
|
295
295
|
const pricingMetadata = getUsagePricingMetadata({
|
|
296
296
|
provider: this.config.provider,
|
|
297
297
|
model: this.config.model,
|
|
298
|
-
tokenUsage: usage
|
|
298
|
+
tokenUsage: usage,
|
|
299
|
+
...this.config.llmRegistry !== void 0 && {
|
|
300
|
+
llmRegistry: this.config.llmRegistry
|
|
301
|
+
}
|
|
299
302
|
});
|
|
300
303
|
this.logger.info("LLM response complete", {
|
|
301
304
|
finishReason: event.finishReason,
|
|
@@ -342,7 +345,10 @@ class StreamProcessor {
|
|
|
342
345
|
const abortPricingMetadata = getUsagePricingMetadata({
|
|
343
346
|
provider: this.config.provider,
|
|
344
347
|
model: this.config.model,
|
|
345
|
-
tokenUsage: this.actualTokens
|
|
348
|
+
tokenUsage: this.actualTokens,
|
|
349
|
+
...this.config.llmRegistry !== void 0 && {
|
|
350
|
+
llmRegistry: this.config.llmRegistry
|
|
351
|
+
}
|
|
346
352
|
});
|
|
347
353
|
await this.persistAssistantResponseMetadata(
|
|
348
354
|
this.actualTokens,
|
|
@@ -372,7 +378,10 @@ class StreamProcessor {
|
|
|
372
378
|
const abortPricingMetadata = getUsagePricingMetadata({
|
|
373
379
|
provider: this.config.provider,
|
|
374
380
|
model: this.config.model,
|
|
375
|
-
tokenUsage: this.actualTokens
|
|
381
|
+
tokenUsage: this.actualTokens,
|
|
382
|
+
...this.config.llmRegistry !== void 0 && {
|
|
383
|
+
llmRegistry: this.config.llmRegistry
|
|
384
|
+
}
|
|
376
385
|
});
|
|
377
386
|
await this.persistAssistantResponseMetadata(
|
|
378
387
|
this.actualTokens,
|
|
@@ -399,7 +408,10 @@ class StreamProcessor {
|
|
|
399
408
|
const failurePricingMetadata = getUsagePricingMetadata({
|
|
400
409
|
provider: this.config.provider,
|
|
401
410
|
model: this.config.model,
|
|
402
|
-
tokenUsage: this.actualTokens
|
|
411
|
+
tokenUsage: this.actualTokens,
|
|
412
|
+
...this.config.llmRegistry !== void 0 && {
|
|
413
|
+
llmRegistry: this.config.llmRegistry
|
|
414
|
+
}
|
|
403
415
|
});
|
|
404
416
|
await this.persistAssistantResponseMetadata(this.actualTokens, failurePricingMetadata, {
|
|
405
417
|
status: "stopped",
|
|
@@ -241,6 +241,9 @@ class TurnExecutor {
|
|
|
241
241
|
...this.config.usageScopeId !== void 0 && {
|
|
242
242
|
usageScopeId: this.config.usageScopeId
|
|
243
243
|
},
|
|
244
|
+
...this.config.llmRegistry !== void 0 && {
|
|
245
|
+
llmRegistry: this.config.llmRegistry
|
|
246
|
+
},
|
|
244
247
|
...estimatedInputTokens !== void 0 && { estimatedInputTokens },
|
|
245
248
|
...reasoning?.reasoningVariant !== void 0 && {
|
|
246
249
|
reasoningVariant: reasoning.reasoningVariant
|
|
@@ -1116,7 +1119,10 @@ class TurnExecutor {
|
|
|
1116
1119
|
() => (0, import_provider_options.buildProviderOptions)({
|
|
1117
1120
|
provider: this.llmContext.provider,
|
|
1118
1121
|
model: this.llmContext.model,
|
|
1119
|
-
reasoning: this.config.reasoning
|
|
1122
|
+
reasoning: this.config.reasoning,
|
|
1123
|
+
...this.config.llmRegistry !== void 0 && {
|
|
1124
|
+
llmRegistry: this.config.llmRegistry
|
|
1125
|
+
}
|
|
1120
1126
|
}),
|
|
1121
1127
|
this.logger
|
|
1122
1128
|
);
|
|
@@ -1564,6 +1570,8 @@ class TurnExecutor {
|
|
|
1564
1570
|
executionResult.result,
|
|
1565
1571
|
{
|
|
1566
1572
|
artifactStore: this.resourceManager.getArtifactStore(),
|
|
1573
|
+
...executionResult.display !== void 0 ? { display: executionResult.display } : {},
|
|
1574
|
+
...executionResult.resultPresentation !== void 0 ? { resultPresentation: executionResult.resultPresentation } : {},
|
|
1567
1575
|
toolName: toolCall.toolName,
|
|
1568
1576
|
toolCallId: toolCall.toolCallId,
|
|
1569
1577
|
success
|
|
@@ -1608,7 +1616,6 @@ class TurnExecutor {
|
|
|
1608
1616
|
},
|
|
1609
1617
|
args: call.input,
|
|
1610
1618
|
...call.meta !== void 0 ? { meta: call.meta } : {},
|
|
1611
|
-
...call.callDescription !== void 0 && { callDescription: call.callDescription },
|
|
1612
1619
|
callId: toolCall.toolCallId,
|
|
1613
1620
|
...this.runContext?.hostRuntime !== void 0 && {
|
|
1614
1621
|
hostRuntime: this.runContext.hostRuntime
|
|
@@ -5,7 +5,7 @@ import { ContextManager } from '../../context/manager.js';
|
|
|
5
5
|
import { ToolManager } from '../../tools/tool-manager.js';
|
|
6
6
|
import type { ToolSet } from '../../tools/types.js';
|
|
7
7
|
import type { ExecutorResult, StreamProcessorResult } from './types.js';
|
|
8
|
-
import type { TokenUsage, LLMReasoningConfig, LLMContext } from '@dexto/llm';
|
|
8
|
+
import type { TokenUsage, LLMReasoningConfig, LLMContext, ModelRegistry } from '@dexto/llm';
|
|
9
9
|
import type { Logger } from '../../logger/v2/types.js';
|
|
10
10
|
import type { SessionEventBus, LLMFinishReason } from '../../events/index.js';
|
|
11
11
|
import type { ResourceManager } from '../../resources/index.js';
|
|
@@ -276,6 +276,7 @@ export declare class TurnExecutor {
|
|
|
276
276
|
baseURL?: string | undefined;
|
|
277
277
|
usageScopeId?: string | undefined;
|
|
278
278
|
executionControl?: LLMExecutionControl | undefined;
|
|
279
|
+
llmRegistry?: ModelRegistry;
|
|
279
280
|
reasoning?: LLMReasoningConfig | undefined;
|
|
280
281
|
}, llmContext: LLMContext, logger: Logger, steerQueue: MessageQueueService, followUpQueue: MessageQueueService, modelLimits?: ModelLimits | undefined, externalSignal?: AbortSignal | undefined, compactionStrategy?: CompactionStrategy | null, runContext?: AgentRunContext | undefined);
|
|
281
282
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"turn-executor.d.ts","sourceRoot":"","sources":["../../../src/llm/executor/turn-executor.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,aAAa,EAMb,KAAK,YAAY,EAEpB,MAAM,IAAI,CAAC;AACZ,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAa,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAE3E,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAS1D,OAAO,EACH,WAAW,EAId,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAMpD,OAAO,KAAK,EAAE,cAAc,EAAiB,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEvF,OAAO,KAAK,EACR,UAAU,EACV,kBAAkB,EAClB,UAAU,
|
|
1
|
+
{"version":3,"file":"turn-executor.d.ts","sourceRoot":"","sources":["../../../src/llm/executor/turn-executor.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,aAAa,EAMb,KAAK,YAAY,EAEpB,MAAM,IAAI,CAAC;AACZ,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAa,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAE3E,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAS1D,OAAO,EACH,WAAW,EAId,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAMpD,OAAO,KAAK,EAAE,cAAc,EAAiB,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEvF,OAAO,KAAK,EACR,UAAU,EACV,kBAAkB,EAClB,UAAU,EAEV,aAAa,EAEhB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OA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
usageScopeId: this.config.usageScopeId
|
|
223
223
|
},
|
|
224
|
+
...this.config.llmRegistry !== void 0 && {
|
|
225
|
+
llmRegistry: this.config.llmRegistry
|
|
226
|
+
},
|
|
224
227
|
...estimatedInputTokens !== void 0 && { estimatedInputTokens },
|
|
225
228
|
...reasoning?.reasoningVariant !== void 0 && {
|
|
226
229
|
reasoningVariant: reasoning.reasoningVariant
|
|
@@ -1096,7 +1099,10 @@ class TurnExecutor {
|
|
|
1096
1099
|
() => buildProviderOptions({
|
|
1097
1100
|
provider: this.llmContext.provider,
|
|
1098
1101
|
model: this.llmContext.model,
|
|
1099
|
-
reasoning: this.config.reasoning
|
|
1102
|
+
reasoning: this.config.reasoning,
|
|
1103
|
+
...this.config.llmRegistry !== void 0 && {
|
|
1104
|
+
llmRegistry: this.config.llmRegistry
|
|
1105
|
+
}
|
|
1100
1106
|
}),
|
|
1101
1107
|
this.logger
|
|
1102
1108
|
);
|
|
@@ -1544,6 +1550,8 @@ class TurnExecutor {
|
|
|
1544
1550
|
executionResult.result,
|
|
1545
1551
|
{
|
|
1546
1552
|
artifactStore: this.resourceManager.getArtifactStore(),
|
|
1553
|
+
...executionResult.display !== void 0 ? { display: executionResult.display } : {},
|
|
1554
|
+
...executionResult.resultPresentation !== void 0 ? { resultPresentation: executionResult.resultPresentation } : {},
|
|
1547
1555
|
toolName: toolCall.toolName,
|
|
1548
1556
|
toolCallId: toolCall.toolCallId,
|
|
1549
1557
|
success
|
|
@@ -1588,7 +1596,6 @@ class TurnExecutor {
|
|
|
1588
1596
|
},
|
|
1589
1597
|
args: call.input,
|
|
1590
1598
|
...call.meta !== void 0 ? { meta: call.meta } : {},
|
|
1591
|
-
...call.callDescription !== void 0 && { callDescription: call.callDescription },
|
|
1592
1599
|
callId: toolCall.toolCallId,
|
|
1593
1600
|
...this.runContext?.hostRuntime !== void 0 && {
|
|
1594
1601
|
hostRuntime: this.runContext.hostRuntime
|
|
@@ -21,6 +21,7 @@ __export(vercel_exports, {
|
|
|
21
21
|
VercelMessageFormatter: () => VercelMessageFormatter
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(vercel_exports);
|
|
24
|
+
var import_llm = require("@dexto/llm");
|
|
24
25
|
var import_utils = require("../../context/utils.js");
|
|
25
26
|
var import_types = require("../../logger/v2/types.js");
|
|
26
27
|
function toUrlIfString(value) {
|
|
@@ -107,8 +108,10 @@ ${text}`
|
|
|
107
108
|
}
|
|
108
109
|
class VercelMessageFormatter {
|
|
109
110
|
logger;
|
|
110
|
-
|
|
111
|
+
llmRegistry;
|
|
112
|
+
constructor(logger, llmRegistry = import_llm.DEFAULT_MODEL_REGISTRY) {
|
|
111
113
|
this.logger = logger.createChild(import_types.DextoLogComponent.LLM);
|
|
114
|
+
this.llmRegistry = llmRegistry;
|
|
112
115
|
}
|
|
113
116
|
/**
|
|
114
117
|
* Formats internal messages into Vercel AI SDK format
|
|
@@ -121,7 +124,12 @@ class VercelMessageFormatter {
|
|
|
121
124
|
const formatted = [];
|
|
122
125
|
let filteredHistory;
|
|
123
126
|
try {
|
|
124
|
-
filteredHistory = (0, import_utils.filterMessagesByLLMCapabilities)(
|
|
127
|
+
filteredHistory = (0, import_utils.filterMessagesByLLMCapabilities)(
|
|
128
|
+
[...history],
|
|
129
|
+
context,
|
|
130
|
+
this.logger,
|
|
131
|
+
this.llmRegistry
|
|
132
|
+
);
|
|
125
133
|
const modelInfo = `${context.provider}/${context.model}`;
|
|
126
134
|
this.logger.debug(`Applied Vercel filtering for ${modelInfo}`);
|
|
127
135
|
} catch (error) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ModelMessage } from 'ai';
|
|
2
|
-
import type
|
|
2
|
+
import { type LLMContext, type ModelRegistry } from '@dexto/llm';
|
|
3
3
|
import type { InternalMessage } from '../../context/types.js';
|
|
4
4
|
import type { Logger } from '../../logger/v2/types.js';
|
|
5
5
|
/**
|
|
@@ -15,7 +15,8 @@ import type { Logger } from '../../logger/v2/types.js';
|
|
|
15
15
|
*/
|
|
16
16
|
export declare class VercelMessageFormatter {
|
|
17
17
|
private logger;
|
|
18
|
-
|
|
18
|
+
private readonly llmRegistry;
|
|
19
|
+
constructor(logger: Logger, llmRegistry?: ModelRegistry);
|
|
19
20
|
/**
|
|
20
21
|
* Formats internal messages into Vercel AI SDK format
|
|
21
22
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vercel.d.ts","sourceRoot":"","sources":["../../../src/llm/formatters/vercel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAoC,MAAM,IAAI,CAAC;AACzE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"vercel.d.ts","sourceRoot":"","sources":["../../../src/llm/formatters/vercel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAoC,MAAM,IAAI,CAAC;AACzE,OAAO,EAA0B,KAAK,UAAU,EAAE,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AACzF,OAAO,KAAK,EACR,eAAe,EAIlB,MAAM,wBAAwB,CAAC;AAOhC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAyHvD;;;;;;;;;;GAUG;AACH,qBAAa,sBAAsB;IAC/B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAgB;gBAEhC,MAAM,EAAE,MAAM,EAAE,WAAW,GAAE,aAAsC;IAI/E;;;;;;OAMG;IACH,MAAM,CACF,OAAO,EAAE,QAAQ,CAAC,eAAe,EAAE,CAAC,EACpC,OAAO,EAAE,UAAU,EACnB,YAAY,EAAE,MAAM,GAAG,IAAI,GAC5B,YAAY,EAAE;IA0LjB;;;;;;OAMG;IACH,kBAAkB,IAAI,IAAI;IAI1B,OAAO,CAAC,wBAAwB;IAUhC,OAAO,CAAC,sBAAsB;IAmG9B,OAAO,CAAC,iBAAiB;CAmG5B"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import "../../chunk-C6A6W6XS.js";
|
|
2
|
+
import { DEFAULT_MODEL_REGISTRY } from "@dexto/llm";
|
|
2
3
|
import {
|
|
3
4
|
getImageData,
|
|
4
5
|
getFileData,
|
|
@@ -90,8 +91,10 @@ ${text}`
|
|
|
90
91
|
}
|
|
91
92
|
class VercelMessageFormatter {
|
|
92
93
|
logger;
|
|
93
|
-
|
|
94
|
+
llmRegistry;
|
|
95
|
+
constructor(logger, llmRegistry = DEFAULT_MODEL_REGISTRY) {
|
|
94
96
|
this.logger = logger.createChild(DextoLogComponent.LLM);
|
|
97
|
+
this.llmRegistry = llmRegistry;
|
|
95
98
|
}
|
|
96
99
|
/**
|
|
97
100
|
* Formats internal messages into Vercel AI SDK format
|
|
@@ -104,7 +107,12 @@ class VercelMessageFormatter {
|
|
|
104
107
|
const formatted = [];
|
|
105
108
|
let filteredHistory;
|
|
106
109
|
try {
|
|
107
|
-
filteredHistory = filterMessagesByLLMCapabilities(
|
|
110
|
+
filteredHistory = filterMessagesByLLMCapabilities(
|
|
111
|
+
[...history],
|
|
112
|
+
context,
|
|
113
|
+
this.logger,
|
|
114
|
+
this.llmRegistry
|
|
115
|
+
);
|
|
108
116
|
const modelInfo = `${context.provider}/${context.model}`;
|
|
109
117
|
this.logger.debug(`Applied Vercel filtering for ${modelInfo}`);
|
|
110
118
|
} catch (error) {
|
|
@@ -79,9 +79,10 @@ function isModelInfo(value) {
|
|
|
79
79
|
return typeof name === "string" && name.trim() !== "";
|
|
80
80
|
}
|
|
81
81
|
function applyModelsByProvider(modelsByProvider) {
|
|
82
|
+
const nextProviders = { ...import_llm2.LLM_REGISTRY };
|
|
82
83
|
for (const provider of UPDATABLE_PROVIDERS) {
|
|
83
84
|
const incoming = modelsByProvider[provider] ?? [];
|
|
84
|
-
const existing =
|
|
85
|
+
const existing = nextProviders[provider].models;
|
|
85
86
|
const incomingByName = /* @__PURE__ */ new Map();
|
|
86
87
|
for (const m of incoming) {
|
|
87
88
|
incomingByName.set(m.name.toLowerCase(), m);
|
|
@@ -144,7 +145,14 @@ function applyModelsByProvider(modelsByProvider) {
|
|
|
144
145
|
finalMerged[idx] = { ...finalMerged[idx], default: true };
|
|
145
146
|
}
|
|
146
147
|
}
|
|
147
|
-
|
|
148
|
+
nextProviders[provider] = {
|
|
149
|
+
...nextProviders[provider],
|
|
150
|
+
models: finalMerged
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
import_llm2.DEFAULT_MODEL_REGISTRY.replaceProviders(nextProviders);
|
|
154
|
+
for (const provider of UPDATABLE_PROVIDERS) {
|
|
155
|
+
import_llm2.LLM_REGISTRY[provider].models = nextProviders[provider].models;
|
|
148
156
|
}
|
|
149
157
|
}
|
|
150
158
|
function normalizeModelsByProvider(raw) {
|
|
@@ -199,7 +207,14 @@ function getLlmRegistryAutoUpdateStatus() {
|
|
|
199
207
|
function loadLlmRegistryCache(options) {
|
|
200
208
|
const cache = tryLoadCacheFromDisk(options?.logger);
|
|
201
209
|
if (!cache) return false;
|
|
202
|
-
|
|
210
|
+
try {
|
|
211
|
+
applyModelsByProvider(cache.modelsByProvider);
|
|
212
|
+
} catch (error) {
|
|
213
|
+
options?.logger?.warn?.(
|
|
214
|
+
`Ignored invalid LLM registry cache (${getCachePath()}): ${error instanceof Error ? error.message : String(error)}`
|
|
215
|
+
);
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
203
218
|
lastFetchedAt = cache.fetchedAt;
|
|
204
219
|
lastSource = "cache";
|
|
205
220
|
return true;
|
|
@@ -235,9 +250,9 @@ async function refreshLlmRegistryCache(options) {
|
|
|
235
250
|
userAgent: "dexto-llm-registry",
|
|
236
251
|
timeoutMs: 3e4
|
|
237
252
|
});
|
|
253
|
+
applyModelsByProvider(modelsByProvider);
|
|
238
254
|
const cachePath = getCachePath();
|
|
239
255
|
await writeCacheFile(cachePath, modelsByProvider);
|
|
240
|
-
applyModelsByProvider(modelsByProvider);
|
|
241
256
|
lastFetchedAt = Date.now();
|
|
242
257
|
lastSource = "remote";
|
|
243
258
|
log?.debug?.(`Refreshed LLM registry cache (${cachePath})`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-update.d.ts","sourceRoot":"","sources":["../../../src/llm/registry/auto-update.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAMvD,KAAK,OAAO,GAAG,IAAI,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"auto-update.d.ts","sourceRoot":"","sources":["../../../src/llm/registry/auto-update.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAMvD,KAAK,OAAO,GAAG,IAAI,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;AAgNjE,MAAM,MAAM,2BAA2B,GAAG;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,IAAI,GAAG,IAAI,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,UAAU,GAAG,OAAO,GAAG,QAAQ,CAAC;CAC3C,CAAC;AAMF,wBAAgB,8BAA8B,IAAI,2BAA2B,CAU5E;AAED,wBAAgB,oBAAoB,CAAC,OAAO,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAc5E;AAiBD,wBAAsB,uBAAuB,CAAC,OAAO,CAAC,EAAE;IACpD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CAC1B,GAAG,OAAO,CAAC,IAAI,CAAC,CAiDhB;AAED,wBAAgB,0BAA0B,CAAC,OAAO,CAAC,EAAE;IACjD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC5B,GAAG,IAAI,CA6BP"}
|
|
@@ -5,7 +5,7 @@ import path from "node:path";
|
|
|
5
5
|
import { getDextoGlobalPath } from "../../utils/path.js";
|
|
6
6
|
import { logger as defaultLogger } from "../../logger/logger.js";
|
|
7
7
|
import { LLM_PROVIDERS } from "@dexto/llm";
|
|
8
|
-
import { LLM_REGISTRY } from "@dexto/llm";
|
|
8
|
+
import { DEFAULT_MODEL_REGISTRY, LLM_REGISTRY } from "@dexto/llm";
|
|
9
9
|
import { buildModelsByProviderFromRemote } from "./sync.js";
|
|
10
10
|
const CACHE_SUBDIR = "cache";
|
|
11
11
|
const CACHE_FILENAME = "llm-registry-models.json";
|
|
@@ -44,9 +44,10 @@ function isModelInfo(value) {
|
|
|
44
44
|
return typeof name === "string" && name.trim() !== "";
|
|
45
45
|
}
|
|
46
46
|
function applyModelsByProvider(modelsByProvider) {
|
|
47
|
+
const nextProviders = { ...LLM_REGISTRY };
|
|
47
48
|
for (const provider of UPDATABLE_PROVIDERS) {
|
|
48
49
|
const incoming = modelsByProvider[provider] ?? [];
|
|
49
|
-
const existing =
|
|
50
|
+
const existing = nextProviders[provider].models;
|
|
50
51
|
const incomingByName = /* @__PURE__ */ new Map();
|
|
51
52
|
for (const m of incoming) {
|
|
52
53
|
incomingByName.set(m.name.toLowerCase(), m);
|
|
@@ -109,7 +110,14 @@ function applyModelsByProvider(modelsByProvider) {
|
|
|
109
110
|
finalMerged[idx] = { ...finalMerged[idx], default: true };
|
|
110
111
|
}
|
|
111
112
|
}
|
|
112
|
-
|
|
113
|
+
nextProviders[provider] = {
|
|
114
|
+
...nextProviders[provider],
|
|
115
|
+
models: finalMerged
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
DEFAULT_MODEL_REGISTRY.replaceProviders(nextProviders);
|
|
119
|
+
for (const provider of UPDATABLE_PROVIDERS) {
|
|
120
|
+
LLM_REGISTRY[provider].models = nextProviders[provider].models;
|
|
113
121
|
}
|
|
114
122
|
}
|
|
115
123
|
function normalizeModelsByProvider(raw) {
|
|
@@ -164,7 +172,14 @@ function getLlmRegistryAutoUpdateStatus() {
|
|
|
164
172
|
function loadLlmRegistryCache(options) {
|
|
165
173
|
const cache = tryLoadCacheFromDisk(options?.logger);
|
|
166
174
|
if (!cache) return false;
|
|
167
|
-
|
|
175
|
+
try {
|
|
176
|
+
applyModelsByProvider(cache.modelsByProvider);
|
|
177
|
+
} catch (error) {
|
|
178
|
+
options?.logger?.warn?.(
|
|
179
|
+
`Ignored invalid LLM registry cache (${getCachePath()}): ${error instanceof Error ? error.message : String(error)}`
|
|
180
|
+
);
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
168
183
|
lastFetchedAt = cache.fetchedAt;
|
|
169
184
|
lastSource = "cache";
|
|
170
185
|
return true;
|
|
@@ -200,9 +215,9 @@ async function refreshLlmRegistryCache(options) {
|
|
|
200
215
|
userAgent: "dexto-llm-registry",
|
|
201
216
|
timeoutMs: 3e4
|
|
202
217
|
});
|
|
218
|
+
applyModelsByProvider(modelsByProvider);
|
|
203
219
|
const cachePath = getCachePath();
|
|
204
220
|
await writeCacheFile(cachePath, modelsByProvider);
|
|
205
|
-
applyModelsByProvider(modelsByProvider);
|
|
206
221
|
lastFetchedAt = Date.now();
|
|
207
222
|
lastSource = "remote";
|
|
208
223
|
log?.debug?.(`Refreshed LLM registry cache (${cachePath})`);
|