@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
package/dist/llm/schemas.js
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
import "../chunk-C6A6W6XS.js";
|
|
2
2
|
import { LLMErrorCode } from "./error-codes.js";
|
|
3
3
|
import { ErrorScope, ErrorType } from "../errors/types.js";
|
|
4
|
-
import { DextoRuntimeError } from "../errors/index.js";
|
|
5
4
|
import { NonEmptyTrimmed, EnvExpandedString, OptionalURL } from "../utils/result.js";
|
|
6
5
|
import { z } from "zod";
|
|
7
6
|
import {
|
|
8
|
-
|
|
9
|
-
acceptsAnyModel,
|
|
10
|
-
supportsCustomModels,
|
|
11
|
-
hasAllRegistryModelsSupport,
|
|
12
|
-
getSupportedModels,
|
|
7
|
+
DEFAULT_MODEL_REGISTRY,
|
|
13
8
|
getReasoningProfile,
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
supportsReasoningVariant,
|
|
10
|
+
LlmCatalogError
|
|
16
11
|
} from "@dexto/llm";
|
|
17
|
-
import { getMaxInputTokensForModel } from "./registry/index.js";
|
|
18
12
|
import { LLM_PROVIDERS } from "@dexto/llm";
|
|
19
13
|
const LLMConfigFields = {
|
|
20
14
|
provider: z.enum(LLM_PROVIDERS).describe("LLM provider (e.g., 'openai', 'anthropic', 'google', 'groq')"),
|
|
@@ -58,130 +52,134 @@ const LLMConfigBaseSchema = z.object({
|
|
|
58
52
|
// Provider-specific options
|
|
59
53
|
reasoning: LLMConfigFields.reasoning
|
|
60
54
|
}).strict();
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
code: z.ZodIssueCode.custom,
|
|
67
|
-
path: ["model"],
|
|
68
|
-
message: `Provider '${data.provider}' requires OpenRouter-format model IDs (e.g. 'openai/gpt-5-mini' or 'anthropic/claude-sonnet-4.5'). You provided '${data.model}'.`,
|
|
69
|
-
params: {
|
|
70
|
-
code: LLMErrorCode.MODEL_INCOMPATIBLE,
|
|
71
|
-
scope: ErrorScope.LLM,
|
|
72
|
-
type: ErrorType.USER
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
if (baseURLIsSet) {
|
|
77
|
-
if (!supportsBaseURL(data.provider)) {
|
|
55
|
+
function createLLMConfigSchema(registry = DEFAULT_MODEL_REGISTRY) {
|
|
56
|
+
return LLMConfigBaseSchema.superRefine((data, ctx) => {
|
|
57
|
+
const baseURLIsSet = data.baseURL != null && data.baseURL.trim() !== "";
|
|
58
|
+
const maxInputTokensIsSet = data.maxInputTokens != null;
|
|
59
|
+
if (registry.hasAllRegistryModelsSupport(data.provider) && !data.model.includes("/")) {
|
|
78
60
|
ctx.addIssue({
|
|
79
61
|
code: z.ZodIssueCode.custom,
|
|
80
|
-
path: ["
|
|
81
|
-
message: `Provider '${data.provider}'
|
|
62
|
+
path: ["model"],
|
|
63
|
+
message: `Provider '${data.provider}' requires OpenRouter-format model IDs (e.g. 'openai/gpt-5-mini' or 'anthropic/claude-sonnet-4.5'). You provided '${data.model}'.`,
|
|
82
64
|
params: {
|
|
83
|
-
code: LLMErrorCode.
|
|
65
|
+
code: LLMErrorCode.MODEL_INCOMPATIBLE,
|
|
84
66
|
scope: ErrorScope.LLM,
|
|
85
67
|
type: ErrorType.USER
|
|
86
68
|
}
|
|
87
69
|
});
|
|
88
70
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if (!acceptsAnyModel(data.provider) && !supportsCustomModels(data.provider)) {
|
|
92
|
-
const supportedModelsList = getSupportedModels(data.provider);
|
|
93
|
-
if (!isValidProviderModel(data.provider, data.model)) {
|
|
71
|
+
if (baseURLIsSet) {
|
|
72
|
+
if (!registry.supportsBaseURL(data.provider)) {
|
|
94
73
|
ctx.addIssue({
|
|
95
74
|
code: z.ZodIssueCode.custom,
|
|
96
|
-
path: ["
|
|
97
|
-
message: `
|
|
75
|
+
path: ["provider"],
|
|
76
|
+
message: `Provider '${data.provider}' does not support baseURL. Use an 'openai-compatible' provider if you need a custom base URL.`,
|
|
98
77
|
params: {
|
|
99
|
-
code: LLMErrorCode.
|
|
78
|
+
code: LLMErrorCode.BASE_URL_INVALID,
|
|
100
79
|
scope: ErrorScope.LLM,
|
|
101
80
|
type: ErrorType.USER
|
|
102
81
|
}
|
|
103
82
|
});
|
|
104
83
|
}
|
|
105
84
|
}
|
|
106
|
-
if (
|
|
107
|
-
|
|
108
|
-
const
|
|
109
|
-
if (data.
|
|
110
|
-
ctx.addIssue({
|
|
111
|
-
code: z.ZodIssueCode.custom,
|
|
112
|
-
path: ["maxInputTokens"],
|
|
113
|
-
message: `Max input tokens for model '${data.model}' is ${cap}. You provided ${data.maxInputTokens}`,
|
|
114
|
-
params: {
|
|
115
|
-
code: LLMErrorCode.TOKENS_EXCEEDED,
|
|
116
|
-
scope: ErrorScope.LLM,
|
|
117
|
-
type: ErrorType.USER
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
} catch (error) {
|
|
122
|
-
if (error instanceof DextoRuntimeError && error.code === LLMErrorCode.MODEL_UNKNOWN) {
|
|
85
|
+
if (!baseURLIsSet || registry.supportsBaseURL(data.provider)) {
|
|
86
|
+
if (!registry.acceptsAnyModel(data.provider) && !registry.supportsCustomModels(data.provider)) {
|
|
87
|
+
const supportedModelsList = registry.getSupportedModels(data.provider);
|
|
88
|
+
if (!registry.isValidProviderModel(data.provider, data.model)) {
|
|
123
89
|
ctx.addIssue({
|
|
124
90
|
code: z.ZodIssueCode.custom,
|
|
125
91
|
path: ["model"],
|
|
126
|
-
message:
|
|
92
|
+
message: `Model '${data.model}' is not supported for provider '${data.provider}'. Supported: ${supportedModelsList.join(", ")}`,
|
|
127
93
|
params: {
|
|
128
|
-
code:
|
|
129
|
-
scope: error.scope,
|
|
130
|
-
type: error.type
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
} else {
|
|
134
|
-
const message = error instanceof Error ? error.message : "Unknown error occurred";
|
|
135
|
-
ctx.addIssue({
|
|
136
|
-
code: z.ZodIssueCode.custom,
|
|
137
|
-
path: ["model"],
|
|
138
|
-
message,
|
|
139
|
-
params: {
|
|
140
|
-
code: LLMErrorCode.REQUEST_INVALID_SCHEMA,
|
|
94
|
+
code: LLMErrorCode.MODEL_INCOMPATIBLE,
|
|
141
95
|
scope: ErrorScope.LLM,
|
|
142
|
-
type: ErrorType.
|
|
96
|
+
type: ErrorType.USER
|
|
143
97
|
}
|
|
144
98
|
});
|
|
145
99
|
}
|
|
146
100
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
101
|
+
if (maxInputTokensIsSet && !registry.acceptsAnyModel(data.provider) && !registry.supportsCustomModels(data.provider)) {
|
|
102
|
+
try {
|
|
103
|
+
const cap = registry.getMaxInputTokensForModel(data.provider, data.model);
|
|
104
|
+
if (data.maxInputTokens > cap) {
|
|
105
|
+
ctx.addIssue({
|
|
106
|
+
code: z.ZodIssueCode.custom,
|
|
107
|
+
path: ["maxInputTokens"],
|
|
108
|
+
message: `Max input tokens for model '${data.model}' is ${cap}. You provided ${data.maxInputTokens}`,
|
|
109
|
+
params: {
|
|
110
|
+
code: LLMErrorCode.TOKENS_EXCEEDED,
|
|
111
|
+
scope: ErrorScope.LLM,
|
|
112
|
+
type: ErrorType.USER
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
} catch (error) {
|
|
117
|
+
if (error instanceof LlmCatalogError && error.code === "MODEL_UNKNOWN") {
|
|
118
|
+
ctx.addIssue({
|
|
119
|
+
code: z.ZodIssueCode.custom,
|
|
120
|
+
path: ["model"],
|
|
121
|
+
message: error.message,
|
|
122
|
+
params: {
|
|
123
|
+
code: LLMErrorCode.MODEL_UNKNOWN,
|
|
124
|
+
scope: ErrorScope.LLM,
|
|
125
|
+
type: ErrorType.USER
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
} else {
|
|
129
|
+
const message = error instanceof Error ? error.message : "Unknown error occurred";
|
|
130
|
+
ctx.addIssue({
|
|
131
|
+
code: z.ZodIssueCode.custom,
|
|
132
|
+
path: ["model"],
|
|
133
|
+
message,
|
|
134
|
+
params: {
|
|
135
|
+
code: LLMErrorCode.REQUEST_INVALID_SCHEMA,
|
|
136
|
+
scope: ErrorScope.LLM,
|
|
137
|
+
type: ErrorType.SYSTEM
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
162
141
|
}
|
|
163
|
-
}
|
|
142
|
+
}
|
|
164
143
|
}
|
|
165
|
-
if (
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
code:
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
144
|
+
if (data.reasoning) {
|
|
145
|
+
const profile = getReasoningProfile(data.provider, data.model, registry);
|
|
146
|
+
const variant = data.reasoning.variant;
|
|
147
|
+
const budgetTokens = data.reasoning.budgetTokens;
|
|
148
|
+
if (!supportsReasoningVariant(profile, variant)) {
|
|
149
|
+
ctx.addIssue({
|
|
150
|
+
code: z.ZodIssueCode.custom,
|
|
151
|
+
path: ["reasoning", "variant"],
|
|
152
|
+
message: `Reasoning variant '${variant}' is not supported for provider '${data.provider}' model '${data.model}'. Supported: ${profile.variants.map((entry) => entry.id).join(", ")}`,
|
|
153
|
+
params: {
|
|
154
|
+
code: LLMErrorCode.MODEL_INCOMPATIBLE,
|
|
155
|
+
scope: ErrorScope.LLM,
|
|
156
|
+
type: ErrorType.USER
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
if (typeof budgetTokens === "number" && !profile.supportsBudgetTokens) {
|
|
161
|
+
ctx.addIssue({
|
|
162
|
+
code: z.ZodIssueCode.custom,
|
|
163
|
+
path: ["reasoning", "budgetTokens"],
|
|
164
|
+
message: `Reasoning budgetTokens are not supported for provider '${data.provider}' model '${data.model}'. Remove reasoning.budgetTokens to use provider defaults.`,
|
|
165
|
+
params: {
|
|
166
|
+
code: LLMErrorCode.MODEL_INCOMPATIBLE,
|
|
167
|
+
scope: ErrorScope.LLM,
|
|
168
|
+
type: ErrorType.USER
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}
|
|
176
172
|
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
const
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
const LLMConfigSchema = createLLMConfigSchema();
|
|
176
|
+
const LLMUpdatesBaseSchema = z.object({
|
|
180
177
|
...LLMConfigFields,
|
|
181
178
|
// Special-case: allow `null` as an explicit "clear reasoning config" sentinel for switch flows.
|
|
182
179
|
// Full configs (LLMConfigSchema) still require `reasoning` to be an object when present.
|
|
183
180
|
reasoning: LLMConfigFields.reasoning.nullable()
|
|
184
|
-
}).partial().
|
|
181
|
+
}).partial().strict();
|
|
182
|
+
const LLMUpdatesShapeSchema = LLMUpdatesBaseSchema.superRefine((data, ctx) => {
|
|
185
183
|
if (!data.model && !data.provider) {
|
|
186
184
|
ctx.addIssue({
|
|
187
185
|
code: z.ZodIssueCode.custom,
|
|
@@ -189,38 +187,46 @@ const LLMUpdatesSchema = z.object({
|
|
|
189
187
|
path: []
|
|
190
188
|
});
|
|
191
189
|
}
|
|
192
|
-
if (data.reasoning && data.reasoning !== null && typeof data.provider === "string" && typeof data.model === "string") {
|
|
193
|
-
const profile = getReasoningProfile(data.provider, data.model);
|
|
194
|
-
const variant = data.reasoning.variant;
|
|
195
|
-
const budgetTokens = data.reasoning.budgetTokens;
|
|
196
|
-
if (!supportsReasoningVariant(profile, variant)) {
|
|
197
|
-
ctx.addIssue({
|
|
198
|
-
code: z.ZodIssueCode.custom,
|
|
199
|
-
path: ["reasoning", "variant"],
|
|
200
|
-
message: `Reasoning variant '${variant}' is not supported for provider '${data.provider}' model '${data.model}'. Supported: ${profile.variants.map((entry) => entry.id).join(", ")}`,
|
|
201
|
-
params: {
|
|
202
|
-
code: LLMErrorCode.MODEL_INCOMPATIBLE,
|
|
203
|
-
scope: ErrorScope.LLM,
|
|
204
|
-
type: ErrorType.USER
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
if (typeof budgetTokens === "number" && !profile.supportsBudgetTokens) {
|
|
209
|
-
ctx.addIssue({
|
|
210
|
-
code: z.ZodIssueCode.custom,
|
|
211
|
-
path: ["reasoning", "budgetTokens"],
|
|
212
|
-
message: `Reasoning budgetTokens are not supported for provider '${data.provider}' model '${data.model}'. Remove reasoning.budgetTokens to use provider defaults.`,
|
|
213
|
-
params: {
|
|
214
|
-
code: LLMErrorCode.MODEL_INCOMPATIBLE,
|
|
215
|
-
scope: ErrorScope.LLM,
|
|
216
|
-
type: ErrorType.USER
|
|
217
|
-
}
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
190
|
});
|
|
191
|
+
function createLLMUpdatesSchema(registry = DEFAULT_MODEL_REGISTRY) {
|
|
192
|
+
return LLMUpdatesShapeSchema.superRefine((data, ctx) => {
|
|
193
|
+
if (data.reasoning && data.reasoning !== null && typeof data.provider === "string" && typeof data.model === "string") {
|
|
194
|
+
const profile = getReasoningProfile(data.provider, data.model, registry);
|
|
195
|
+
const variant = data.reasoning.variant;
|
|
196
|
+
const budgetTokens = data.reasoning.budgetTokens;
|
|
197
|
+
if (!supportsReasoningVariant(profile, variant)) {
|
|
198
|
+
ctx.addIssue({
|
|
199
|
+
code: z.ZodIssueCode.custom,
|
|
200
|
+
path: ["reasoning", "variant"],
|
|
201
|
+
message: `Reasoning variant '${variant}' is not supported for provider '${data.provider}' model '${data.model}'. Supported: ${profile.variants.map((entry) => entry.id).join(", ")}`,
|
|
202
|
+
params: {
|
|
203
|
+
code: LLMErrorCode.MODEL_INCOMPATIBLE,
|
|
204
|
+
scope: ErrorScope.LLM,
|
|
205
|
+
type: ErrorType.USER
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
if (typeof budgetTokens === "number" && !profile.supportsBudgetTokens) {
|
|
210
|
+
ctx.addIssue({
|
|
211
|
+
code: z.ZodIssueCode.custom,
|
|
212
|
+
path: ["reasoning", "budgetTokens"],
|
|
213
|
+
message: `Reasoning budgetTokens are not supported for provider '${data.provider}' model '${data.model}'. Remove reasoning.budgetTokens to use provider defaults.`,
|
|
214
|
+
params: {
|
|
215
|
+
code: LLMErrorCode.MODEL_INCOMPATIBLE,
|
|
216
|
+
scope: ErrorScope.LLM,
|
|
217
|
+
type: ErrorType.USER
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
const LLMUpdatesSchema = createLLMUpdatesSchema();
|
|
222
225
|
export {
|
|
223
226
|
LLMConfigBaseSchema,
|
|
224
227
|
LLMConfigSchema,
|
|
225
|
-
LLMUpdatesSchema
|
|
228
|
+
LLMUpdatesSchema,
|
|
229
|
+
LLMUpdatesShapeSchema,
|
|
230
|
+
createLLMConfigSchema,
|
|
231
|
+
createLLMUpdatesSchema
|
|
226
232
|
};
|
|
@@ -358,6 +358,7 @@ async function createLLMService(config, toolManager, systemPromptManager, conver
|
|
|
358
358
|
const { usageScopeId, compactionStrategy, executionControl, steerQueue, followUpQueue } = options;
|
|
359
359
|
const providerContext = {
|
|
360
360
|
sessionId,
|
|
361
|
+
...options.llmRegistry !== void 0 ? { llmRegistry: options.llmRegistry } : {},
|
|
361
362
|
...options.cwd !== void 0 ? { cwd: options.cwd } : {},
|
|
362
363
|
authResolver: options.authResolver ?? null,
|
|
363
364
|
logger,
|
|
@@ -388,7 +389,8 @@ async function createLLMService(config, toolManager, systemPromptManager, conver
|
|
|
388
389
|
followUpQueue,
|
|
389
390
|
usageScopeId,
|
|
390
391
|
executionControl,
|
|
391
|
-
compactionStrategy
|
|
392
|
+
compactionStrategy,
|
|
393
|
+
options.llmRegistry
|
|
392
394
|
);
|
|
393
395
|
}
|
|
394
396
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/llm/services/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE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Aa,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,KAAK,EACR,uBAAuB,EACvB,oBAAoB,EACpB,oBAAoB,EACvB,MAAM,YAAY,CAAC;AAoHpB;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CACnC,SAAS,EAAE,kBAAkB,EAC7B,OAAO,CAAC,EAAE,oBAAoB,GAC/B,OAAO,CAAC,aAAa,CAAC,CAyUxB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,gBAAgB,CAClC,MAAM,EAAE,kBAAkB,EAC1B,WAAW,EAAE,WAAW,EACxB,mBAAmB,EAAE,mBAAmB,EACxC,iBAAiB,EAAE,iBAAiB,EACpC,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,OAAO,0BAA0B,EAAE,eAAe,EACnE,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,uBAAuB,EAChC,oBAAoB,CAAC,EAAE,oBAAoB,GAC5C,OAAO,CAAC,gBAAgB,CAAC,CA0C3B"}
|
|
@@ -330,6 +330,7 @@ async function createLLMService(config, toolManager, systemPromptManager, conver
|
|
|
330
330
|
const { usageScopeId, compactionStrategy, executionControl, steerQueue, followUpQueue } = options;
|
|
331
331
|
const providerContext = {
|
|
332
332
|
sessionId,
|
|
333
|
+
...options.llmRegistry !== void 0 ? { llmRegistry: options.llmRegistry } : {},
|
|
333
334
|
...options.cwd !== void 0 ? { cwd: options.cwd } : {},
|
|
334
335
|
authResolver: options.authResolver ?? null,
|
|
335
336
|
logger,
|
|
@@ -360,7 +361,8 @@ async function createLLMService(config, toolManager, systemPromptManager, conver
|
|
|
360
361
|
followUpQueue,
|
|
361
362
|
usageScopeId,
|
|
362
363
|
executionControl,
|
|
363
|
-
compactionStrategy
|
|
364
|
+
compactionStrategy,
|
|
365
|
+
options.llmRegistry
|
|
364
366
|
);
|
|
365
367
|
}
|
|
366
368
|
export {
|
|
@@ -5,6 +5,7 @@ import type { ValidatedLLMConfig } from '../schemas.js';
|
|
|
5
5
|
import type { LlmAuthResolver } from '../auth/types.js';
|
|
6
6
|
import type { Logger } from '../../logger/v2/types.js';
|
|
7
7
|
import type { LLMProvider } from '@dexto/llm';
|
|
8
|
+
import type { ModelRegistry } from '@dexto/llm';
|
|
8
9
|
import type { MessageQueueService } from '../../session/message-queue.js';
|
|
9
10
|
import type { AgentRunContext } from '../../runtime/run-context.js';
|
|
10
11
|
import type { TurnDriverState } from '../executor/turn-executor.js';
|
|
@@ -25,6 +26,7 @@ export interface CreateLLMServiceOptions {
|
|
|
25
26
|
authResolver?: LlmAuthResolver | null | undefined;
|
|
26
27
|
steerQueue: MessageQueueService;
|
|
27
28
|
followUpQueue: MessageQueueService;
|
|
29
|
+
llmRegistry?: ModelRegistry;
|
|
28
30
|
}
|
|
29
31
|
export type LLMExecutionControl = {
|
|
30
32
|
/**
|
|
@@ -51,6 +53,8 @@ export interface DextoProviderContext {
|
|
|
51
53
|
cwd?: string;
|
|
52
54
|
/** Runtime auth resolver for profile-backed API keys, OAuth, and external accounts. */
|
|
53
55
|
authResolver?: LlmAuthResolver | null;
|
|
56
|
+
/** Registry selected by the host for this agent/session. */
|
|
57
|
+
llmRegistry?: ModelRegistry;
|
|
54
58
|
/** Logger for non-secret runtime provider/auth observability. */
|
|
55
59
|
logger?: Logger | undefined;
|
|
56
60
|
/** Optional callback for ChatGPT Login rate-limit status updates from Codex. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/llm/services/types.ts"],"names":[],"mappings":"AAA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ACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC7B"}
|
|
@@ -78,6 +78,7 @@ var import_DextoRuntimeError = require("../../errors/DextoRuntimeError.js");
|
|
|
78
78
|
var import_types4 = require("../../errors/types.js");
|
|
79
79
|
var import_error_codes = require("../error-codes.js");
|
|
80
80
|
var import_operation_span = require("../../telemetry/operation-span.js");
|
|
81
|
+
var import_llm = require("@dexto/llm");
|
|
81
82
|
var _VercelLLMService_decorators, _init;
|
|
82
83
|
function ensureRunContextMatchesServiceSession(serviceSessionId, runContext) {
|
|
83
84
|
if (runContext !== void 0 && runContext.sessionId !== serviceSessionId) {
|
|
@@ -113,13 +114,14 @@ class VercelLLMService {
|
|
|
113
114
|
modelLimits;
|
|
114
115
|
usageScopeId;
|
|
115
116
|
executionControl;
|
|
117
|
+
llmRegistry;
|
|
116
118
|
/**
|
|
117
119
|
* Helper to extract model ID from LanguageModel union type (string | LanguageModelV2)
|
|
118
120
|
*/
|
|
119
121
|
getModelId() {
|
|
120
122
|
return typeof this.model === "string" ? this.model : this.model.modelId;
|
|
121
123
|
}
|
|
122
|
-
constructor(toolManager, model, systemPromptManager, conversationStore, sessionEventBus, config, sessionId, resourceManager, logger, steerQueue, followUpQueue, usageScopeId, executionControl, compactionStrategy) {
|
|
124
|
+
constructor(toolManager, model, systemPromptManager, conversationStore, sessionEventBus, config, sessionId, resourceManager, logger, steerQueue, followUpQueue, usageScopeId, executionControl, compactionStrategy, llmRegistry = import_llm.DEFAULT_MODEL_REGISTRY) {
|
|
123
125
|
this.logger = logger.createChild(import_types.DextoLogComponent.LLM);
|
|
124
126
|
this.model = model;
|
|
125
127
|
this.config = config;
|
|
@@ -129,11 +131,12 @@ class VercelLLMService {
|
|
|
129
131
|
this.resourceManager = resourceManager;
|
|
130
132
|
this.usageScopeId = usageScopeId;
|
|
131
133
|
this.executionControl = executionControl;
|
|
134
|
+
this.llmRegistry = llmRegistry;
|
|
132
135
|
this.compactionStrategy = compactionStrategy ?? null;
|
|
133
136
|
this.steerQueue = steerQueue;
|
|
134
137
|
this.followUpQueue = followUpQueue;
|
|
135
|
-
const formatter = new import_vercel.VercelMessageFormatter(this.logger);
|
|
136
|
-
const maxInputTokens = (0, import_registry.getEffectiveMaxInputTokens)(config, this.logger);
|
|
138
|
+
const formatter = new import_vercel.VercelMessageFormatter(this.logger, this.llmRegistry);
|
|
139
|
+
const maxInputTokens = (0, import_registry.getEffectiveMaxInputTokens)(config, this.logger, this.llmRegistry);
|
|
137
140
|
if (this.compactionStrategy) {
|
|
138
141
|
this.modelLimits = this.compactionStrategy.getModelLimits(maxInputTokens);
|
|
139
142
|
}
|
|
@@ -145,7 +148,8 @@ class VercelLLMService {
|
|
|
145
148
|
conversationStore,
|
|
146
149
|
sessionId,
|
|
147
150
|
resourceManager,
|
|
148
|
-
this.logger
|
|
151
|
+
this.logger,
|
|
152
|
+
this.llmRegistry
|
|
149
153
|
);
|
|
150
154
|
this.logger.debug(
|
|
151
155
|
`[VercelLLMService] Initialized for model: ${this.getModelId()}, provider: ${this.config.provider}, temperature: ${this.config.temperature}, maxOutputTokens: ${this.config.maxOutputTokens}`
|
|
@@ -212,10 +216,14 @@ class VercelLLMService {
|
|
|
212
216
|
...this.executionControl !== void 0 && {
|
|
213
217
|
executionControl: this.executionControl
|
|
214
218
|
},
|
|
219
|
+
llmRegistry: this.llmRegistry,
|
|
215
220
|
// Provider-specific options
|
|
216
221
|
reasoning: this.config.reasoning
|
|
217
222
|
},
|
|
218
|
-
{
|
|
223
|
+
{
|
|
224
|
+
provider: this.config.provider,
|
|
225
|
+
model: this.getModelId()
|
|
226
|
+
},
|
|
219
227
|
this.logger,
|
|
220
228
|
this.steerQueue,
|
|
221
229
|
this.followUpQueue,
|
|
@@ -287,7 +295,8 @@ class VercelLLMService {
|
|
|
287
295
|
modelMaxInputTokens = (0, import_registry.getMaxInputTokensForModel)(
|
|
288
296
|
this.config.provider,
|
|
289
297
|
this.getModelId(),
|
|
290
|
-
this.logger
|
|
298
|
+
this.logger,
|
|
299
|
+
this.llmRegistry
|
|
291
300
|
);
|
|
292
301
|
} catch (error) {
|
|
293
302
|
if (error instanceof import_DextoRuntimeError.DextoRuntimeError && error.code === import_error_codes.LLMErrorCode.MODEL_UNKNOWN) {
|
|
@@ -13,6 +13,7 @@ import { MessageQueueService } from '../../session/message-queue.js';
|
|
|
13
13
|
import type { ResourceManager } from '../../resources/index.js';
|
|
14
14
|
import type { ContentInput } from '../../agent/types.js';
|
|
15
15
|
import type { AgentRunContext } from '../../runtime/run-context.js';
|
|
16
|
+
import { type ModelRegistry } from '@dexto/llm';
|
|
16
17
|
export declare function ensureRunContextMatchesServiceSession(serviceSessionId: string, runContext?: AgentRunContext): string;
|
|
17
18
|
/**
|
|
18
19
|
* Vercel AI SDK implementation of the core session LLM runtime
|
|
@@ -43,11 +44,12 @@ export declare class VercelLLMService {
|
|
|
43
44
|
private modelLimits?;
|
|
44
45
|
private readonly usageScopeId;
|
|
45
46
|
private readonly executionControl;
|
|
47
|
+
private readonly llmRegistry;
|
|
46
48
|
/**
|
|
47
49
|
* Helper to extract model ID from LanguageModel union type (string | LanguageModelV2)
|
|
48
50
|
*/
|
|
49
51
|
private getModelId;
|
|
50
|
-
constructor(toolManager: ToolManager, model: LanguageModel, systemPromptManager: SystemPromptManager, conversationStore: ConversationStore, sessionEventBus: SessionEventBus, config: ValidatedLLMConfig, sessionId: string, resourceManager: ResourceManager, logger: Logger, steerQueue: MessageQueueService, followUpQueue: MessageQueueService, usageScopeId?: string, executionControl?: LLMExecutionControl, compactionStrategy?: import('../../context/compaction/types.js').CompactionStrategy | null);
|
|
52
|
+
constructor(toolManager: ToolManager, model: LanguageModel, systemPromptManager: SystemPromptManager, conversationStore: ConversationStore, sessionEventBus: SessionEventBus, config: ValidatedLLMConfig, sessionId: string, resourceManager: ResourceManager, logger: Logger, steerQueue: MessageQueueService, followUpQueue: MessageQueueService, usageScopeId?: string, executionControl?: LLMExecutionControl, compactionStrategy?: import('../../context/compaction/types.js').CompactionStrategy | null, llmRegistry?: ModelRegistry);
|
|
51
53
|
getAllTools(): Promise<ToolSet>;
|
|
52
54
|
getEnabledTools(): Promise<ToolSet>;
|
|
53
55
|
createTurnDriver(options?: CreateTurnDriverOptions): Promise<TurnDriver>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vercel.d.ts","sourceRoot":"","sources":["../../../src/llm/services/vercel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAqB,MAAM,IAAI,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,KAAK,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACjG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAI1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAEzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAGxD,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAIhE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,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AOG;IACG,MAAM,CACR,OAAO,EAAE,YAAY,EACrB,OAAO,CAAC,EAAE;QACN,MAAM,CAAC,EAAE,WAAW,CAAC;QACrB,UAAU,CAAC,EAAE,eAAe,CAAC;KAChC,GACF,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IA+D5B;;;OAGG;IACH,SAAS,IAAI,gBAAgB;IAgC7B;;OAEG;IACH,iBAAiB,IAAI,cAAc,CAAC,OAAO,CAAC;IAI5C;;OAEG;IACH,aAAa,IAAI,mBAAmB;IAIpC,gBAAgB,IAAI,mBAAmB;IAIvC;;OAEG;IACH,qBAAqB,IAAI,OAAO,mCAAmC,EAAE,kBAAkB,GAAG,IAAI;IAI9F,gBAAgB,IAAI,aAAa;CAGpC"}
|
|
@@ -15,6 +15,7 @@ import { DextoRuntimeError } from "../../errors/DextoRuntimeError.js";
|
|
|
15
15
|
import { ErrorScope, ErrorType } from "../../errors/types.js";
|
|
16
16
|
import { LLMErrorCode } from "../error-codes.js";
|
|
17
17
|
import { recordOperationSpan } from "../../telemetry/operation-span.js";
|
|
18
|
+
import { DEFAULT_MODEL_REGISTRY } from "@dexto/llm";
|
|
18
19
|
function ensureRunContextMatchesServiceSession(serviceSessionId, runContext) {
|
|
19
20
|
if (runContext !== void 0 && runContext.sessionId !== serviceSessionId) {
|
|
20
21
|
throw new DextoRuntimeError(
|
|
@@ -49,13 +50,14 @@ class VercelLLMService {
|
|
|
49
50
|
modelLimits;
|
|
50
51
|
usageScopeId;
|
|
51
52
|
executionControl;
|
|
53
|
+
llmRegistry;
|
|
52
54
|
/**
|
|
53
55
|
* Helper to extract model ID from LanguageModel union type (string | LanguageModelV2)
|
|
54
56
|
*/
|
|
55
57
|
getModelId() {
|
|
56
58
|
return typeof this.model === "string" ? this.model : this.model.modelId;
|
|
57
59
|
}
|
|
58
|
-
constructor(toolManager, model, systemPromptManager, conversationStore, sessionEventBus, config, sessionId, resourceManager, logger, steerQueue, followUpQueue, usageScopeId, executionControl, compactionStrategy) {
|
|
60
|
+
constructor(toolManager, model, systemPromptManager, conversationStore, sessionEventBus, config, sessionId, resourceManager, logger, steerQueue, followUpQueue, usageScopeId, executionControl, compactionStrategy, llmRegistry = DEFAULT_MODEL_REGISTRY) {
|
|
59
61
|
this.logger = logger.createChild(DextoLogComponent.LLM);
|
|
60
62
|
this.model = model;
|
|
61
63
|
this.config = config;
|
|
@@ -65,11 +67,12 @@ class VercelLLMService {
|
|
|
65
67
|
this.resourceManager = resourceManager;
|
|
66
68
|
this.usageScopeId = usageScopeId;
|
|
67
69
|
this.executionControl = executionControl;
|
|
70
|
+
this.llmRegistry = llmRegistry;
|
|
68
71
|
this.compactionStrategy = compactionStrategy ?? null;
|
|
69
72
|
this.steerQueue = steerQueue;
|
|
70
73
|
this.followUpQueue = followUpQueue;
|
|
71
|
-
const formatter = new VercelMessageFormatter(this.logger);
|
|
72
|
-
const maxInputTokens = getEffectiveMaxInputTokens(config, this.logger);
|
|
74
|
+
const formatter = new VercelMessageFormatter(this.logger, this.llmRegistry);
|
|
75
|
+
const maxInputTokens = getEffectiveMaxInputTokens(config, this.logger, this.llmRegistry);
|
|
73
76
|
if (this.compactionStrategy) {
|
|
74
77
|
this.modelLimits = this.compactionStrategy.getModelLimits(maxInputTokens);
|
|
75
78
|
}
|
|
@@ -81,7 +84,8 @@ class VercelLLMService {
|
|
|
81
84
|
conversationStore,
|
|
82
85
|
sessionId,
|
|
83
86
|
resourceManager,
|
|
84
|
-
this.logger
|
|
87
|
+
this.logger,
|
|
88
|
+
this.llmRegistry
|
|
85
89
|
);
|
|
86
90
|
this.logger.debug(
|
|
87
91
|
`[VercelLLMService] Initialized for model: ${this.getModelId()}, provider: ${this.config.provider}, temperature: ${this.config.temperature}, maxOutputTokens: ${this.config.maxOutputTokens}`
|
|
@@ -148,10 +152,14 @@ class VercelLLMService {
|
|
|
148
152
|
...this.executionControl !== void 0 && {
|
|
149
153
|
executionControl: this.executionControl
|
|
150
154
|
},
|
|
155
|
+
llmRegistry: this.llmRegistry,
|
|
151
156
|
// Provider-specific options
|
|
152
157
|
reasoning: this.config.reasoning
|
|
153
158
|
},
|
|
154
|
-
{
|
|
159
|
+
{
|
|
160
|
+
provider: this.config.provider,
|
|
161
|
+
model: this.getModelId()
|
|
162
|
+
},
|
|
155
163
|
this.logger,
|
|
156
164
|
this.steerQueue,
|
|
157
165
|
this.followUpQueue,
|
|
@@ -223,7 +231,8 @@ class VercelLLMService {
|
|
|
223
231
|
modelMaxInputTokens = getMaxInputTokensForModel(
|
|
224
232
|
this.config.provider,
|
|
225
233
|
this.getModelId(),
|
|
226
|
-
this.logger
|
|
234
|
+
this.logger,
|
|
235
|
+
this.llmRegistry
|
|
227
236
|
);
|
|
228
237
|
} catch (error) {
|
|
229
238
|
if (error instanceof DextoRuntimeError && error.code === LLMErrorCode.MODEL_UNKNOWN) {
|
|
@@ -46,11 +46,11 @@ function hasMeaningfulTokenUsage(tokenUsage) {
|
|
|
46
46
|
return (normalized.inputTokens ?? 0) > 0 || (normalized.outputTokens ?? 0) > 0 || (normalized.reasoningTokens ?? 0) > 0 || (normalized.cacheReadTokens ?? 0) > 0 || (normalized.cacheWriteTokens ?? 0) > 0 || (normalized.totalTokens ?? 0) > 0;
|
|
47
47
|
}
|
|
48
48
|
function getUsagePricingMetadata(config) {
|
|
49
|
-
const { provider, model, tokenUsage } = config;
|
|
49
|
+
const { provider, model, tokenUsage, llmRegistry = import_llm.DEFAULT_MODEL_REGISTRY } = config;
|
|
50
50
|
if (!provider || !model || !tokenUsage || !hasMeaningfulTokenUsage(tokenUsage)) {
|
|
51
51
|
return {};
|
|
52
52
|
}
|
|
53
|
-
const pricing =
|
|
53
|
+
const pricing = llmRegistry.getModelPricing(provider, model);
|
|
54
54
|
if (!pricing) {
|
|
55
55
|
return { pricingStatus: "unpriced" };
|
|
56
56
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type TokenUsageCostBreakdown } from '@dexto/llm';
|
|
1
|
+
import { type ModelRegistry, type TokenUsageCostBreakdown } from '@dexto/llm';
|
|
2
2
|
import type { LLMProvider, LLMPricingStatus, TokenUsage } from '@dexto/llm';
|
|
3
3
|
export interface LLMUsagePricingMetadata {
|
|
4
4
|
estimatedCost?: number;
|
|
@@ -11,5 +11,6 @@ export declare function getUsagePricingMetadata(config: {
|
|
|
11
11
|
provider?: LLMProvider;
|
|
12
12
|
model?: string;
|
|
13
13
|
tokenUsage?: TokenUsage;
|
|
14
|
+
llmRegistry?: ModelRegistry;
|
|
14
15
|
}): LLMUsagePricingMetadata;
|
|
15
16
|
//# sourceMappingURL=usage-metadata.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usage-metadata.d.ts","sourceRoot":"","sources":["../../src/llm/usage-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"usage-metadata.d.ts","sourceRoot":"","sources":["../../src/llm/usage-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,KAAK,aAAa,EAClB,KAAK,uBAAuB,EAC/B,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE5E,MAAM,WAAW,uBAAuB;IACpC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,gBAAgB,CAAC;IACjC,aAAa,CAAC,EAAE,uBAAuB,CAAC;CAC3C;AAMD,wBAAgB,gCAAgC,CAAC,UAAU,EAAE,UAAU,GAAG,SAAS,GAAG,UAAU,CAW/F;AAED,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAcnF;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE;IAC5C,QAAQ,CAAC,EAAE,WAAW,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,WAAW,CAAC,EAAE,aAAa,CAAC;CAC/B,GAAG,uBAAuB,CAqB1B"}
|