@codelia/core 0.1.65 → 0.1.66
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/dist/index.cjs +102 -32
- package/dist/index.d.cts +15 -2
- package/dist/index.d.ts +15 -2
- package/dist/index.js +99 -31
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -47,12 +47,14 @@ __export(index_exports, {
|
|
|
47
47
|
createModelRegistry: () => createModelRegistry,
|
|
48
48
|
defineTool: () => defineTool,
|
|
49
49
|
getDefaultSystemPromptPath: () => getDefaultSystemPromptPath,
|
|
50
|
+
isUsableModelSpec: () => isUsableModelSpec,
|
|
50
51
|
listModels: () => listModels,
|
|
51
52
|
registerModels: () => registerModels,
|
|
52
53
|
resolveModel: () => resolveModel,
|
|
53
54
|
resolveProviderModelId: () => resolveProviderModelId,
|
|
54
55
|
stringifyContent: () => stringifyContent,
|
|
55
|
-
stringifyContentParts: () => stringifyContentParts
|
|
56
|
+
stringifyContentParts: () => stringifyContentParts,
|
|
57
|
+
supportsFastMode: () => supportsFastMode
|
|
56
58
|
});
|
|
57
59
|
module.exports = __toCommonJS(index_exports);
|
|
58
60
|
|
|
@@ -69,12 +71,34 @@ var OPENAI_MODELS = [
|
|
|
69
71
|
provider: "openai",
|
|
70
72
|
aliases: ["default"]
|
|
71
73
|
},
|
|
74
|
+
{
|
|
75
|
+
id: "gpt-5.5",
|
|
76
|
+
provider: "openai",
|
|
77
|
+
contextWindow: 105e4,
|
|
78
|
+
maxInputTokens: 27e4,
|
|
79
|
+
maxOutputTokens: 13e4,
|
|
80
|
+
supportsFast: true
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
id: "gpt-5.5-1M",
|
|
84
|
+
provider: "openai",
|
|
85
|
+
providerModelId: "gpt-5.5",
|
|
86
|
+
aliases: ["gpt-5.5-1m", "gpt-5.5-full"],
|
|
87
|
+
contextWindow: 105e4,
|
|
88
|
+
maxInputTokens: 92e4,
|
|
89
|
+
maxOutputTokens: 13e4
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
id: "gpt-5.5-pro",
|
|
93
|
+
provider: "openai"
|
|
94
|
+
},
|
|
72
95
|
{
|
|
73
96
|
id: "gpt-5.4",
|
|
74
97
|
provider: "openai",
|
|
75
98
|
contextWindow: 105e4,
|
|
76
99
|
maxInputTokens: GPT_5_4_CAPPED_INPUT_TOKENS,
|
|
77
|
-
maxOutputTokens: 128e3
|
|
100
|
+
maxOutputTokens: 128e3,
|
|
101
|
+
supportsFast: true
|
|
78
102
|
},
|
|
79
103
|
{
|
|
80
104
|
id: "gpt-5.4-1M",
|
|
@@ -96,11 +120,13 @@ var OPENAI_MODELS = [
|
|
|
96
120
|
},
|
|
97
121
|
{
|
|
98
122
|
id: "gpt-5.2-2025-12-11",
|
|
99
|
-
provider: "openai"
|
|
123
|
+
provider: "openai",
|
|
124
|
+
supportsFast: true
|
|
100
125
|
},
|
|
101
126
|
{
|
|
102
127
|
id: "gpt-5.2",
|
|
103
|
-
provider: "openai"
|
|
128
|
+
provider: "openai",
|
|
129
|
+
supportsFast: true
|
|
104
130
|
},
|
|
105
131
|
{
|
|
106
132
|
id: "gpt-5.2-pro",
|
|
@@ -112,23 +138,28 @@ var OPENAI_MODELS = [
|
|
|
112
138
|
},
|
|
113
139
|
{
|
|
114
140
|
id: "gpt-5.1",
|
|
115
|
-
provider: "openai"
|
|
141
|
+
provider: "openai",
|
|
142
|
+
supportsFast: true
|
|
116
143
|
},
|
|
117
144
|
{
|
|
118
145
|
id: "gpt-5.1-2025-11-13",
|
|
119
|
-
provider: "openai"
|
|
146
|
+
provider: "openai",
|
|
147
|
+
supportsFast: true
|
|
120
148
|
},
|
|
121
149
|
{
|
|
122
150
|
id: "gpt-5",
|
|
123
|
-
provider: "openai"
|
|
151
|
+
provider: "openai",
|
|
152
|
+
supportsFast: true
|
|
124
153
|
},
|
|
125
154
|
{
|
|
126
155
|
id: "gpt-5-mini",
|
|
127
|
-
provider: "openai"
|
|
156
|
+
provider: "openai",
|
|
157
|
+
supportsFast: true
|
|
128
158
|
},
|
|
129
159
|
{
|
|
130
160
|
id: "gpt-5-mini-2025-08-07",
|
|
131
|
-
provider: "openai"
|
|
161
|
+
provider: "openai",
|
|
162
|
+
supportsFast: true
|
|
132
163
|
},
|
|
133
164
|
{
|
|
134
165
|
id: "gpt-5-nano",
|
|
@@ -140,7 +171,8 @@ var OPENAI_MODELS = [
|
|
|
140
171
|
},
|
|
141
172
|
{
|
|
142
173
|
id: "gpt-5.1-codex",
|
|
143
|
-
provider: "openai"
|
|
174
|
+
provider: "openai",
|
|
175
|
+
supportsFast: true
|
|
144
176
|
},
|
|
145
177
|
{
|
|
146
178
|
id: "gpt-5.1-codex-max",
|
|
@@ -152,7 +184,8 @@ var OPENAI_MODELS = [
|
|
|
152
184
|
},
|
|
153
185
|
{
|
|
154
186
|
id: "gpt-5-codex",
|
|
155
|
-
provider: "openai"
|
|
187
|
+
provider: "openai",
|
|
188
|
+
supportsFast: true
|
|
156
189
|
},
|
|
157
190
|
{
|
|
158
191
|
id: "gpt-5-codex-mini",
|
|
@@ -268,9 +301,18 @@ var ANTHROPIC_MODELS = [
|
|
|
268
301
|
provider: "anthropic",
|
|
269
302
|
aliases: ["default"]
|
|
270
303
|
},
|
|
304
|
+
{
|
|
305
|
+
id: "claude-opus-4-7",
|
|
306
|
+
provider: "anthropic",
|
|
307
|
+
contextWindow: 1e6,
|
|
308
|
+
maxInputTokens: 1e6,
|
|
309
|
+
maxOutputTokens: 128e3,
|
|
310
|
+
supportsFast: true
|
|
311
|
+
},
|
|
271
312
|
{
|
|
272
313
|
id: "claude-opus-4-6",
|
|
273
|
-
provider: "anthropic"
|
|
314
|
+
provider: "anthropic",
|
|
315
|
+
supportsFast: true
|
|
274
316
|
},
|
|
275
317
|
{
|
|
276
318
|
id: "claude-opus-4-5",
|
|
@@ -365,10 +407,18 @@ function listModels(registry, provider) {
|
|
|
365
407
|
const all = Object.values(registry.modelsById);
|
|
366
408
|
return provider ? all.filter((model) => model.provider === provider) : all;
|
|
367
409
|
}
|
|
410
|
+
var isPositiveFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value) && value > 0;
|
|
411
|
+
function isUsableModelSpec(spec) {
|
|
412
|
+
return isPositiveFiniteNumber(spec?.maxInputTokens) || isPositiveFiniteNumber(spec?.contextWindow);
|
|
413
|
+
}
|
|
368
414
|
function resolveProviderModelId(registry, idOrAlias, provider) {
|
|
369
415
|
const spec = resolveModel(registry, idOrAlias, provider);
|
|
370
416
|
return spec ? spec.providerModelId ?? spec.id : void 0;
|
|
371
417
|
}
|
|
418
|
+
function supportsFastMode(registry, idOrAlias, provider) {
|
|
419
|
+
const spec = resolveModel(registry, idOrAlias, provider);
|
|
420
|
+
return spec?.supportsFast === true;
|
|
421
|
+
}
|
|
372
422
|
function cloneAliases(aliasesByProvider) {
|
|
373
423
|
return {
|
|
374
424
|
openai: { ...aliasesByProvider.openai },
|
|
@@ -2292,12 +2342,14 @@ var DEFAULT_CLIENT_TIMEOUT_MS = 20 * 60 * 1e3;
|
|
|
2292
2342
|
var DEFAULT_PROMPT_CACHE_CONTROL = {
|
|
2293
2343
|
type: "ephemeral"
|
|
2294
2344
|
};
|
|
2345
|
+
var FAST_MODE_BETA = "fast-mode-2026-02-01";
|
|
2295
2346
|
var ChatAnthropic = class {
|
|
2296
2347
|
provider = PROVIDER_NAME;
|
|
2297
2348
|
model;
|
|
2298
2349
|
client;
|
|
2299
2350
|
defaultMaxTokens;
|
|
2300
2351
|
defaultInvokeOptions;
|
|
2352
|
+
fastMode;
|
|
2301
2353
|
reasoningLevelMeta;
|
|
2302
2354
|
debugInvokeSeq = 0;
|
|
2303
2355
|
lastDebugRequestPayload = null;
|
|
@@ -2309,6 +2361,7 @@ var ChatAnthropic = class {
|
|
|
2309
2361
|
this.model = options.model ?? DEFAULT_MODEL;
|
|
2310
2362
|
this.defaultMaxTokens = options.maxTokens ?? DEFAULT_MAX_TOKENS;
|
|
2311
2363
|
this.defaultInvokeOptions = { ...options.invokeOptions ?? {} };
|
|
2364
|
+
this.fastMode = options.fastMode === true;
|
|
2312
2365
|
this.reasoningLevelMeta = {
|
|
2313
2366
|
requested: options.reasoningLevelRequested,
|
|
2314
2367
|
applied: options.reasoningLevelApplied,
|
|
@@ -2346,14 +2399,17 @@ var ChatAnthropic = class {
|
|
|
2346
2399
|
if (request.cache_control === void 0) {
|
|
2347
2400
|
request.cache_control = DEFAULT_PROMPT_CACHE_CONTROL;
|
|
2348
2401
|
}
|
|
2402
|
+
if (this.fastMode) {
|
|
2403
|
+
request.speed = "fast";
|
|
2404
|
+
request.betas = [...request.betas ?? [], FAST_MODE_BETA];
|
|
2405
|
+
}
|
|
2349
2406
|
const debugSeq = this.nextDebugInvokeSeq();
|
|
2350
2407
|
await this.debugRequestIfEnabled(request, debugSeq);
|
|
2351
|
-
const
|
|
2408
|
+
const requestOptions = signal ? { signal } : void 0;
|
|
2409
|
+
const response = this.fastMode ? await this.client.beta.messages.create(
|
|
2352
2410
|
request,
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
} : void 0
|
|
2356
|
-
);
|
|
2411
|
+
requestOptions
|
|
2412
|
+
) : await this.client.messages.create(request, requestOptions);
|
|
2357
2413
|
await this.debugResponseIfEnabled(response, debugSeq);
|
|
2358
2414
|
return toChatInvokeCompletion(response, {
|
|
2359
2415
|
reasoning_requested: this.reasoningLevelMeta.requested,
|
|
@@ -2671,7 +2727,11 @@ var OpenAiResponseAccumulator = class {
|
|
|
2671
2727
|
break;
|
|
2672
2728
|
}
|
|
2673
2729
|
case "response.content_part.added": {
|
|
2674
|
-
this.addContentPart(
|
|
2730
|
+
this.addContentPart(
|
|
2731
|
+
event.output_index,
|
|
2732
|
+
event.content_index,
|
|
2733
|
+
event.part
|
|
2734
|
+
);
|
|
2675
2735
|
break;
|
|
2676
2736
|
}
|
|
2677
2737
|
case "response.output_text.delta": {
|
|
@@ -2683,7 +2743,11 @@ var OpenAiResponseAccumulator = class {
|
|
|
2683
2743
|
break;
|
|
2684
2744
|
}
|
|
2685
2745
|
case "response.output_text.done": {
|
|
2686
|
-
this.setMessageText(
|
|
2746
|
+
this.setMessageText(
|
|
2747
|
+
event.output_index,
|
|
2748
|
+
event.content_index,
|
|
2749
|
+
event.text
|
|
2750
|
+
);
|
|
2687
2751
|
break;
|
|
2688
2752
|
}
|
|
2689
2753
|
case "response.refusal.delta": {
|
|
@@ -2822,13 +2886,17 @@ var OpenAiResponseAccumulator = class {
|
|
|
2822
2886
|
}
|
|
2823
2887
|
if (output.type === "message" && part.type !== "reasoning_text") {
|
|
2824
2888
|
ensureArrayIndex(output.content, contentIndex);
|
|
2825
|
-
output.content[contentIndex] = cloneValue(
|
|
2889
|
+
output.content[contentIndex] = cloneValue(
|
|
2890
|
+
part
|
|
2891
|
+
);
|
|
2826
2892
|
return;
|
|
2827
2893
|
}
|
|
2828
2894
|
if (output.type === "reasoning" && part.type === "reasoning_text") {
|
|
2829
2895
|
const content = output.content ?? [];
|
|
2830
2896
|
ensureArrayIndex(content, contentIndex);
|
|
2831
|
-
content[contentIndex] = cloneValue(
|
|
2897
|
+
content[contentIndex] = cloneValue(
|
|
2898
|
+
part
|
|
2899
|
+
);
|
|
2832
2900
|
output.content = content;
|
|
2833
2901
|
}
|
|
2834
2902
|
}
|
|
@@ -2991,9 +3059,7 @@ var OpenAiResponseAccumulator = class {
|
|
|
2991
3059
|
}
|
|
2992
3060
|
loggedUnhandledResponseEventTypes.add(event.type);
|
|
2993
3061
|
const payload = getResponseStreamEventDebugPayload(event);
|
|
2994
|
-
console.error(
|
|
2995
|
-
`[openai.stream.unhandled] ${safeJsonStringify(payload)}`
|
|
2996
|
-
);
|
|
3062
|
+
console.error(`[openai.stream.unhandled] ${safeJsonStringify(payload)}`);
|
|
2997
3063
|
}
|
|
2998
3064
|
};
|
|
2999
3065
|
|
|
@@ -3608,9 +3674,7 @@ var OpenAiWsTransport = class {
|
|
|
3608
3674
|
if (settled || !terminalCompletedWithoutUsage) {
|
|
3609
3675
|
return;
|
|
3610
3676
|
}
|
|
3611
|
-
resolveOnce(
|
|
3612
|
-
accumulator.buildResponse(terminalCompletedWithoutUsage)
|
|
3613
|
-
);
|
|
3677
|
+
resolveOnce(accumulator.buildResponse(terminalCompletedWithoutUsage));
|
|
3614
3678
|
}, WS_TERMINAL_DONE_GRACE_MS);
|
|
3615
3679
|
};
|
|
3616
3680
|
const resetResponseTimeout = () => {
|
|
@@ -3650,9 +3714,7 @@ var OpenAiWsTransport = class {
|
|
|
3650
3714
|
}
|
|
3651
3715
|
if (type === "response.done" && terminalCompletedWithoutUsage) {
|
|
3652
3716
|
clearDoneGraceTimer();
|
|
3653
|
-
resolveOnce(
|
|
3654
|
-
accumulator.buildResponse(terminalCompletedWithoutUsage)
|
|
3655
|
-
);
|
|
3717
|
+
resolveOnce(accumulator.buildResponse(terminalCompletedWithoutUsage));
|
|
3656
3718
|
return;
|
|
3657
3719
|
}
|
|
3658
3720
|
rejectOnce(
|
|
@@ -4188,6 +4250,7 @@ var ChatOpenAI = class {
|
|
|
4188
4250
|
defaultReasoningEffort;
|
|
4189
4251
|
reasoningLevelMeta;
|
|
4190
4252
|
defaultTextVerbosity;
|
|
4253
|
+
defaultServiceTier;
|
|
4191
4254
|
websocketMode;
|
|
4192
4255
|
websocketApiVersion;
|
|
4193
4256
|
wsTransport;
|
|
@@ -4207,6 +4270,7 @@ var ChatOpenAI = class {
|
|
|
4207
4270
|
fallbackApplied: options.reasoningFallbackApplied
|
|
4208
4271
|
};
|
|
4209
4272
|
this.defaultTextVerbosity = options.textVerbosity;
|
|
4273
|
+
this.defaultServiceTier = options.serviceTier;
|
|
4210
4274
|
this.websocketMode = options.websocketMode ?? "off";
|
|
4211
4275
|
this.websocketApiVersion = options.websocketApiVersion ?? "v2";
|
|
4212
4276
|
this.wsTransport = new OpenAiWsTransport({
|
|
@@ -4230,7 +4294,7 @@ var ChatOpenAI = class {
|
|
|
4230
4294
|
const instructions = extractInstructions(messages);
|
|
4231
4295
|
const tools = toResponsesTools(toolDefs);
|
|
4232
4296
|
const tool_choice = toResponsesToolChoice(toolChoice);
|
|
4233
|
-
const { reasoningEffort, textVerbosity, ...rest } = options ?? {};
|
|
4297
|
+
const { reasoningEffort, textVerbosity, serviceTier, ...rest } = options ?? {};
|
|
4234
4298
|
const request = {
|
|
4235
4299
|
model: model ?? this.providerModel,
|
|
4236
4300
|
input: inputItems,
|
|
@@ -4262,6 +4326,10 @@ var ChatOpenAI = class {
|
|
|
4262
4326
|
verbosity
|
|
4263
4327
|
};
|
|
4264
4328
|
}
|
|
4329
|
+
const resolvedServiceTier = serviceTier ?? this.defaultServiceTier;
|
|
4330
|
+
if (resolvedServiceTier) {
|
|
4331
|
+
request.service_tier = resolvedServiceTier;
|
|
4332
|
+
}
|
|
4265
4333
|
if (context?.sessionKey && !request.prompt_cache_key) {
|
|
4266
4334
|
request.prompt_cache_key = context.sessionKey;
|
|
4267
4335
|
}
|
|
@@ -5520,10 +5588,12 @@ function defineTool(toolOptions) {
|
|
|
5520
5588
|
createModelRegistry,
|
|
5521
5589
|
defineTool,
|
|
5522
5590
|
getDefaultSystemPromptPath,
|
|
5591
|
+
isUsableModelSpec,
|
|
5523
5592
|
listModels,
|
|
5524
5593
|
registerModels,
|
|
5525
5594
|
resolveModel,
|
|
5526
5595
|
resolveProviderModelId,
|
|
5527
5596
|
stringifyContent,
|
|
5528
|
-
stringifyContentParts
|
|
5597
|
+
stringifyContentParts,
|
|
5598
|
+
supportsFastMode
|
|
5529
5599
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -250,6 +250,7 @@ type ModelSpec = {
|
|
|
250
250
|
supportsTools?: boolean;
|
|
251
251
|
supportsVision?: boolean;
|
|
252
252
|
supportsReasoning?: boolean;
|
|
253
|
+
supportsFast?: boolean;
|
|
253
254
|
supportsJsonSchema?: boolean;
|
|
254
255
|
};
|
|
255
256
|
type ModelRegistry = {
|
|
@@ -260,7 +261,9 @@ declare function createModelRegistry(specs: ModelSpec[]): ModelRegistry;
|
|
|
260
261
|
declare function registerModels(registry: ModelRegistry, specs: ModelSpec[]): void;
|
|
261
262
|
declare function resolveModel(registry: ModelRegistry, idOrAlias: string, provider?: ProviderName): ModelSpec | undefined;
|
|
262
263
|
declare function listModels(registry: ModelRegistry, provider?: ProviderName): ModelSpec[];
|
|
264
|
+
declare function isUsableModelSpec(spec: ModelSpec | undefined): boolean;
|
|
263
265
|
declare function resolveProviderModelId(registry: ModelRegistry, idOrAlias: string, provider?: ProviderName): string | undefined;
|
|
266
|
+
declare function supportsFastMode(registry: ModelRegistry, idOrAlias: string, provider?: ProviderName): boolean;
|
|
264
267
|
declare function applyModelMetadata(registry: ModelRegistry, index: ModelMetadataIndex): ModelRegistry;
|
|
265
268
|
|
|
266
269
|
type CompactionConfig = {
|
|
@@ -376,6 +379,7 @@ type SessionHeader = {
|
|
|
376
379
|
provider?: string;
|
|
377
380
|
name?: string;
|
|
378
381
|
reasoning?: string;
|
|
382
|
+
fast?: boolean;
|
|
379
383
|
};
|
|
380
384
|
prompts?: {
|
|
381
385
|
system?: string;
|
|
@@ -452,6 +456,7 @@ type LlmRequestRecord = {
|
|
|
452
456
|
provider?: string;
|
|
453
457
|
name?: string;
|
|
454
458
|
reasoning?: string;
|
|
459
|
+
fast?: boolean;
|
|
455
460
|
};
|
|
456
461
|
input: {
|
|
457
462
|
messages: BaseMessage[];
|
|
@@ -625,7 +630,10 @@ interface StoragePathService {
|
|
|
625
630
|
}
|
|
626
631
|
|
|
627
632
|
declare const PROVIDER_NAME$2: "anthropic";
|
|
628
|
-
type AnthropicMessageCreateParams = MessageCreateParamsNonStreaming
|
|
633
|
+
type AnthropicMessageCreateParams = MessageCreateParamsNonStreaming & {
|
|
634
|
+
speed?: "standard" | "fast" | null;
|
|
635
|
+
betas?: string[];
|
|
636
|
+
};
|
|
629
637
|
type AnthropicInvokeOptions = Partial<Omit<AnthropicMessageCreateParams, "model" | "messages" | "tools" | "tool_choice" | "system" | "stream">>;
|
|
630
638
|
type ChatAnthropicOptions = {
|
|
631
639
|
client?: Anthropic;
|
|
@@ -633,6 +641,7 @@ type ChatAnthropicOptions = {
|
|
|
633
641
|
model?: string;
|
|
634
642
|
maxTokens?: number;
|
|
635
643
|
invokeOptions?: AnthropicInvokeOptions;
|
|
644
|
+
fastMode?: boolean;
|
|
636
645
|
reasoningLevelRequested?: "low" | "medium" | "high" | "xhigh";
|
|
637
646
|
reasoningLevelApplied?: "low" | "medium" | "high" | "xhigh";
|
|
638
647
|
reasoningFallbackApplied?: boolean;
|
|
@@ -644,6 +653,7 @@ declare class ChatAnthropic implements BaseChatModel<typeof PROVIDER_NAME$2, Ant
|
|
|
644
653
|
private readonly client;
|
|
645
654
|
private readonly defaultMaxTokens;
|
|
646
655
|
private readonly defaultInvokeOptions;
|
|
656
|
+
private readonly fastMode;
|
|
647
657
|
private readonly reasoningLevelMeta;
|
|
648
658
|
private debugInvokeSeq;
|
|
649
659
|
private lastDebugRequestPayload;
|
|
@@ -673,6 +683,7 @@ type OpenAITextVerbosity = Exclude<ResponseTextConfig["verbosity"], null>;
|
|
|
673
683
|
type OpenAIInvokeOptions = Omit<ResponseCreateParamsBase, "model" | "input" | "tools" | "tool_choice" | "stream"> & {
|
|
674
684
|
reasoningEffort?: ReasoningEffort;
|
|
675
685
|
textVerbosity?: OpenAITextVerbosity;
|
|
686
|
+
serviceTier?: ResponseCreateParamsBase["service_tier"];
|
|
676
687
|
};
|
|
677
688
|
type OpenAIReasoningLevel = "low" | "medium" | "high" | "xhigh";
|
|
678
689
|
|
|
@@ -686,6 +697,7 @@ type ChatOpenAIOptions = {
|
|
|
686
697
|
reasoningLevelApplied?: OpenAIReasoningLevel;
|
|
687
698
|
reasoningFallbackApplied?: boolean;
|
|
688
699
|
textVerbosity?: OpenAITextVerbosity;
|
|
700
|
+
serviceTier?: ResponseCreateParamsBase["service_tier"];
|
|
689
701
|
websocketMode?: OpenAiWebsocketMode;
|
|
690
702
|
websocketApiVersion?: OpenAiWebsocketApiVersion;
|
|
691
703
|
createResponsesWs?: (client: OpenAI, options?: ConstructorParameters<typeof ResponsesWS>[1]) => OpenAiResponsesWsLike;
|
|
@@ -700,6 +712,7 @@ declare class ChatOpenAI implements BaseChatModel<typeof PROVIDER_NAME$1, OpenAI
|
|
|
700
712
|
private readonly defaultReasoningEffort?;
|
|
701
713
|
private readonly reasoningLevelMeta;
|
|
702
714
|
private readonly defaultTextVerbosity?;
|
|
715
|
+
private readonly defaultServiceTier?;
|
|
703
716
|
private readonly websocketMode;
|
|
704
717
|
private readonly websocketApiVersion;
|
|
705
718
|
private readonly wsTransport;
|
|
@@ -790,4 +803,4 @@ declare class TaskComplete extends Error {
|
|
|
790
803
|
constructor(finalMessage?: string);
|
|
791
804
|
}
|
|
792
805
|
|
|
793
|
-
export { ANTHROPIC_DEFAULT_MODEL, ANTHROPIC_MODELS, Agent, type AgentEventRecord, type AgentOptions, type AgentRunOptions, type AgentServices, type AgentSession, type BaseChatModel, type BaseMessage, ChatAnthropic, type ChatInvokeContext, type ChatInvokeInput, ChatOpenAI, ChatOpenRouter, type ContentPart, DEFAULT_MODEL_REGISTRY, type DependencyKey, GOOGLE_MODELS, type LlmRequestRecord, type LlmResponseRecord, type ModelCost, type ModelEntry, type ModelLimits, type ModelMetadataIndex, type ModelMetadataService, type ModelRegistry, type ModelSpec, OPENAI_DEFAULT_MODEL, OPENAI_DEFAULT_REASONING_EFFORT, OPENAI_MODELS, type ResolveStorageOptions, type RunContextRecord, type RunEndRecord, type RunErrorRecord, type RunEventStoreFactory, type RunEventStoreInit, type RunStartRecord, type RunStatusRecord, type SessionHeader, type SessionRecord, type SessionState, type SessionStateStore, type SessionStateSummary, type SessionStore, type StorageLayout, type StoragePathService, type StoragePaths, type StringifyContentMode, type StringifyContentOptions, TaskComplete, type Tool, type ToolContext, type ToolDefinition, type ToolExecution, type ToolOutputCacheConfig, type ToolOutputCacheReadOptions, type ToolOutputCacheRecord, type ToolOutputCacheSearchOptions, ToolOutputCacheService, type ToolOutputCacheStore, type ToolOutputRecord, type ToolOutputRef, type ToolPermissionDecision, type ToolPermissionHook, applyModelMetadata, createModelRegistry, defineTool, getDefaultSystemPromptPath, listModels, registerModels, resolveModel, resolveProviderModelId, stringifyContent, stringifyContentParts };
|
|
806
|
+
export { ANTHROPIC_DEFAULT_MODEL, ANTHROPIC_MODELS, Agent, type AgentEventRecord, type AgentOptions, type AgentRunOptions, type AgentServices, type AgentSession, type BaseChatModel, type BaseMessage, ChatAnthropic, type ChatInvokeContext, type ChatInvokeInput, ChatOpenAI, ChatOpenRouter, type ContentPart, DEFAULT_MODEL_REGISTRY, type DependencyKey, GOOGLE_MODELS, type LlmRequestRecord, type LlmResponseRecord, type ModelCost, type ModelEntry, type ModelLimits, type ModelMetadataIndex, type ModelMetadataService, type ModelRegistry, type ModelSpec, OPENAI_DEFAULT_MODEL, OPENAI_DEFAULT_REASONING_EFFORT, OPENAI_MODELS, type ResolveStorageOptions, type RunContextRecord, type RunEndRecord, type RunErrorRecord, type RunEventStoreFactory, type RunEventStoreInit, type RunStartRecord, type RunStatusRecord, type SessionHeader, type SessionRecord, type SessionState, type SessionStateStore, type SessionStateSummary, type SessionStore, type StorageLayout, type StoragePathService, type StoragePaths, type StringifyContentMode, type StringifyContentOptions, TaskComplete, type Tool, type ToolContext, type ToolDefinition, type ToolExecution, type ToolOutputCacheConfig, type ToolOutputCacheReadOptions, type ToolOutputCacheRecord, type ToolOutputCacheSearchOptions, ToolOutputCacheService, type ToolOutputCacheStore, type ToolOutputRecord, type ToolOutputRef, type ToolPermissionDecision, type ToolPermissionHook, applyModelMetadata, createModelRegistry, defineTool, getDefaultSystemPromptPath, isUsableModelSpec, listModels, registerModels, resolveModel, resolveProviderModelId, stringifyContent, stringifyContentParts, supportsFastMode };
|
package/dist/index.d.ts
CHANGED
|
@@ -250,6 +250,7 @@ type ModelSpec = {
|
|
|
250
250
|
supportsTools?: boolean;
|
|
251
251
|
supportsVision?: boolean;
|
|
252
252
|
supportsReasoning?: boolean;
|
|
253
|
+
supportsFast?: boolean;
|
|
253
254
|
supportsJsonSchema?: boolean;
|
|
254
255
|
};
|
|
255
256
|
type ModelRegistry = {
|
|
@@ -260,7 +261,9 @@ declare function createModelRegistry(specs: ModelSpec[]): ModelRegistry;
|
|
|
260
261
|
declare function registerModels(registry: ModelRegistry, specs: ModelSpec[]): void;
|
|
261
262
|
declare function resolveModel(registry: ModelRegistry, idOrAlias: string, provider?: ProviderName): ModelSpec | undefined;
|
|
262
263
|
declare function listModels(registry: ModelRegistry, provider?: ProviderName): ModelSpec[];
|
|
264
|
+
declare function isUsableModelSpec(spec: ModelSpec | undefined): boolean;
|
|
263
265
|
declare function resolveProviderModelId(registry: ModelRegistry, idOrAlias: string, provider?: ProviderName): string | undefined;
|
|
266
|
+
declare function supportsFastMode(registry: ModelRegistry, idOrAlias: string, provider?: ProviderName): boolean;
|
|
264
267
|
declare function applyModelMetadata(registry: ModelRegistry, index: ModelMetadataIndex): ModelRegistry;
|
|
265
268
|
|
|
266
269
|
type CompactionConfig = {
|
|
@@ -376,6 +379,7 @@ type SessionHeader = {
|
|
|
376
379
|
provider?: string;
|
|
377
380
|
name?: string;
|
|
378
381
|
reasoning?: string;
|
|
382
|
+
fast?: boolean;
|
|
379
383
|
};
|
|
380
384
|
prompts?: {
|
|
381
385
|
system?: string;
|
|
@@ -452,6 +456,7 @@ type LlmRequestRecord = {
|
|
|
452
456
|
provider?: string;
|
|
453
457
|
name?: string;
|
|
454
458
|
reasoning?: string;
|
|
459
|
+
fast?: boolean;
|
|
455
460
|
};
|
|
456
461
|
input: {
|
|
457
462
|
messages: BaseMessage[];
|
|
@@ -625,7 +630,10 @@ interface StoragePathService {
|
|
|
625
630
|
}
|
|
626
631
|
|
|
627
632
|
declare const PROVIDER_NAME$2: "anthropic";
|
|
628
|
-
type AnthropicMessageCreateParams = MessageCreateParamsNonStreaming
|
|
633
|
+
type AnthropicMessageCreateParams = MessageCreateParamsNonStreaming & {
|
|
634
|
+
speed?: "standard" | "fast" | null;
|
|
635
|
+
betas?: string[];
|
|
636
|
+
};
|
|
629
637
|
type AnthropicInvokeOptions = Partial<Omit<AnthropicMessageCreateParams, "model" | "messages" | "tools" | "tool_choice" | "system" | "stream">>;
|
|
630
638
|
type ChatAnthropicOptions = {
|
|
631
639
|
client?: Anthropic;
|
|
@@ -633,6 +641,7 @@ type ChatAnthropicOptions = {
|
|
|
633
641
|
model?: string;
|
|
634
642
|
maxTokens?: number;
|
|
635
643
|
invokeOptions?: AnthropicInvokeOptions;
|
|
644
|
+
fastMode?: boolean;
|
|
636
645
|
reasoningLevelRequested?: "low" | "medium" | "high" | "xhigh";
|
|
637
646
|
reasoningLevelApplied?: "low" | "medium" | "high" | "xhigh";
|
|
638
647
|
reasoningFallbackApplied?: boolean;
|
|
@@ -644,6 +653,7 @@ declare class ChatAnthropic implements BaseChatModel<typeof PROVIDER_NAME$2, Ant
|
|
|
644
653
|
private readonly client;
|
|
645
654
|
private readonly defaultMaxTokens;
|
|
646
655
|
private readonly defaultInvokeOptions;
|
|
656
|
+
private readonly fastMode;
|
|
647
657
|
private readonly reasoningLevelMeta;
|
|
648
658
|
private debugInvokeSeq;
|
|
649
659
|
private lastDebugRequestPayload;
|
|
@@ -673,6 +683,7 @@ type OpenAITextVerbosity = Exclude<ResponseTextConfig["verbosity"], null>;
|
|
|
673
683
|
type OpenAIInvokeOptions = Omit<ResponseCreateParamsBase, "model" | "input" | "tools" | "tool_choice" | "stream"> & {
|
|
674
684
|
reasoningEffort?: ReasoningEffort;
|
|
675
685
|
textVerbosity?: OpenAITextVerbosity;
|
|
686
|
+
serviceTier?: ResponseCreateParamsBase["service_tier"];
|
|
676
687
|
};
|
|
677
688
|
type OpenAIReasoningLevel = "low" | "medium" | "high" | "xhigh";
|
|
678
689
|
|
|
@@ -686,6 +697,7 @@ type ChatOpenAIOptions = {
|
|
|
686
697
|
reasoningLevelApplied?: OpenAIReasoningLevel;
|
|
687
698
|
reasoningFallbackApplied?: boolean;
|
|
688
699
|
textVerbosity?: OpenAITextVerbosity;
|
|
700
|
+
serviceTier?: ResponseCreateParamsBase["service_tier"];
|
|
689
701
|
websocketMode?: OpenAiWebsocketMode;
|
|
690
702
|
websocketApiVersion?: OpenAiWebsocketApiVersion;
|
|
691
703
|
createResponsesWs?: (client: OpenAI, options?: ConstructorParameters<typeof ResponsesWS>[1]) => OpenAiResponsesWsLike;
|
|
@@ -700,6 +712,7 @@ declare class ChatOpenAI implements BaseChatModel<typeof PROVIDER_NAME$1, OpenAI
|
|
|
700
712
|
private readonly defaultReasoningEffort?;
|
|
701
713
|
private readonly reasoningLevelMeta;
|
|
702
714
|
private readonly defaultTextVerbosity?;
|
|
715
|
+
private readonly defaultServiceTier?;
|
|
703
716
|
private readonly websocketMode;
|
|
704
717
|
private readonly websocketApiVersion;
|
|
705
718
|
private readonly wsTransport;
|
|
@@ -790,4 +803,4 @@ declare class TaskComplete extends Error {
|
|
|
790
803
|
constructor(finalMessage?: string);
|
|
791
804
|
}
|
|
792
805
|
|
|
793
|
-
export { ANTHROPIC_DEFAULT_MODEL, ANTHROPIC_MODELS, Agent, type AgentEventRecord, type AgentOptions, type AgentRunOptions, type AgentServices, type AgentSession, type BaseChatModel, type BaseMessage, ChatAnthropic, type ChatInvokeContext, type ChatInvokeInput, ChatOpenAI, ChatOpenRouter, type ContentPart, DEFAULT_MODEL_REGISTRY, type DependencyKey, GOOGLE_MODELS, type LlmRequestRecord, type LlmResponseRecord, type ModelCost, type ModelEntry, type ModelLimits, type ModelMetadataIndex, type ModelMetadataService, type ModelRegistry, type ModelSpec, OPENAI_DEFAULT_MODEL, OPENAI_DEFAULT_REASONING_EFFORT, OPENAI_MODELS, type ResolveStorageOptions, type RunContextRecord, type RunEndRecord, type RunErrorRecord, type RunEventStoreFactory, type RunEventStoreInit, type RunStartRecord, type RunStatusRecord, type SessionHeader, type SessionRecord, type SessionState, type SessionStateStore, type SessionStateSummary, type SessionStore, type StorageLayout, type StoragePathService, type StoragePaths, type StringifyContentMode, type StringifyContentOptions, TaskComplete, type Tool, type ToolContext, type ToolDefinition, type ToolExecution, type ToolOutputCacheConfig, type ToolOutputCacheReadOptions, type ToolOutputCacheRecord, type ToolOutputCacheSearchOptions, ToolOutputCacheService, type ToolOutputCacheStore, type ToolOutputRecord, type ToolOutputRef, type ToolPermissionDecision, type ToolPermissionHook, applyModelMetadata, createModelRegistry, defineTool, getDefaultSystemPromptPath, listModels, registerModels, resolveModel, resolveProviderModelId, stringifyContent, stringifyContentParts };
|
|
806
|
+
export { ANTHROPIC_DEFAULT_MODEL, ANTHROPIC_MODELS, Agent, type AgentEventRecord, type AgentOptions, type AgentRunOptions, type AgentServices, type AgentSession, type BaseChatModel, type BaseMessage, ChatAnthropic, type ChatInvokeContext, type ChatInvokeInput, ChatOpenAI, ChatOpenRouter, type ContentPart, DEFAULT_MODEL_REGISTRY, type DependencyKey, GOOGLE_MODELS, type LlmRequestRecord, type LlmResponseRecord, type ModelCost, type ModelEntry, type ModelLimits, type ModelMetadataIndex, type ModelMetadataService, type ModelRegistry, type ModelSpec, OPENAI_DEFAULT_MODEL, OPENAI_DEFAULT_REASONING_EFFORT, OPENAI_MODELS, type ResolveStorageOptions, type RunContextRecord, type RunEndRecord, type RunErrorRecord, type RunEventStoreFactory, type RunEventStoreInit, type RunStartRecord, type RunStatusRecord, type SessionHeader, type SessionRecord, type SessionState, type SessionStateStore, type SessionStateSummary, type SessionStore, type StorageLayout, type StoragePathService, type StoragePaths, type StringifyContentMode, type StringifyContentOptions, TaskComplete, type Tool, type ToolContext, type ToolDefinition, type ToolExecution, type ToolOutputCacheConfig, type ToolOutputCacheReadOptions, type ToolOutputCacheRecord, type ToolOutputCacheSearchOptions, ToolOutputCacheService, type ToolOutputCacheStore, type ToolOutputRecord, type ToolOutputRef, type ToolPermissionDecision, type ToolPermissionHook, applyModelMetadata, createModelRegistry, defineTool, getDefaultSystemPromptPath, isUsableModelSpec, listModels, registerModels, resolveModel, resolveProviderModelId, stringifyContent, stringifyContentParts, supportsFastMode };
|
package/dist/index.js
CHANGED
|
@@ -11,12 +11,34 @@ var OPENAI_MODELS = [
|
|
|
11
11
|
provider: "openai",
|
|
12
12
|
aliases: ["default"]
|
|
13
13
|
},
|
|
14
|
+
{
|
|
15
|
+
id: "gpt-5.5",
|
|
16
|
+
provider: "openai",
|
|
17
|
+
contextWindow: 105e4,
|
|
18
|
+
maxInputTokens: 27e4,
|
|
19
|
+
maxOutputTokens: 13e4,
|
|
20
|
+
supportsFast: true
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: "gpt-5.5-1M",
|
|
24
|
+
provider: "openai",
|
|
25
|
+
providerModelId: "gpt-5.5",
|
|
26
|
+
aliases: ["gpt-5.5-1m", "gpt-5.5-full"],
|
|
27
|
+
contextWindow: 105e4,
|
|
28
|
+
maxInputTokens: 92e4,
|
|
29
|
+
maxOutputTokens: 13e4
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
id: "gpt-5.5-pro",
|
|
33
|
+
provider: "openai"
|
|
34
|
+
},
|
|
14
35
|
{
|
|
15
36
|
id: "gpt-5.4",
|
|
16
37
|
provider: "openai",
|
|
17
38
|
contextWindow: 105e4,
|
|
18
39
|
maxInputTokens: GPT_5_4_CAPPED_INPUT_TOKENS,
|
|
19
|
-
maxOutputTokens: 128e3
|
|
40
|
+
maxOutputTokens: 128e3,
|
|
41
|
+
supportsFast: true
|
|
20
42
|
},
|
|
21
43
|
{
|
|
22
44
|
id: "gpt-5.4-1M",
|
|
@@ -38,11 +60,13 @@ var OPENAI_MODELS = [
|
|
|
38
60
|
},
|
|
39
61
|
{
|
|
40
62
|
id: "gpt-5.2-2025-12-11",
|
|
41
|
-
provider: "openai"
|
|
63
|
+
provider: "openai",
|
|
64
|
+
supportsFast: true
|
|
42
65
|
},
|
|
43
66
|
{
|
|
44
67
|
id: "gpt-5.2",
|
|
45
|
-
provider: "openai"
|
|
68
|
+
provider: "openai",
|
|
69
|
+
supportsFast: true
|
|
46
70
|
},
|
|
47
71
|
{
|
|
48
72
|
id: "gpt-5.2-pro",
|
|
@@ -54,23 +78,28 @@ var OPENAI_MODELS = [
|
|
|
54
78
|
},
|
|
55
79
|
{
|
|
56
80
|
id: "gpt-5.1",
|
|
57
|
-
provider: "openai"
|
|
81
|
+
provider: "openai",
|
|
82
|
+
supportsFast: true
|
|
58
83
|
},
|
|
59
84
|
{
|
|
60
85
|
id: "gpt-5.1-2025-11-13",
|
|
61
|
-
provider: "openai"
|
|
86
|
+
provider: "openai",
|
|
87
|
+
supportsFast: true
|
|
62
88
|
},
|
|
63
89
|
{
|
|
64
90
|
id: "gpt-5",
|
|
65
|
-
provider: "openai"
|
|
91
|
+
provider: "openai",
|
|
92
|
+
supportsFast: true
|
|
66
93
|
},
|
|
67
94
|
{
|
|
68
95
|
id: "gpt-5-mini",
|
|
69
|
-
provider: "openai"
|
|
96
|
+
provider: "openai",
|
|
97
|
+
supportsFast: true
|
|
70
98
|
},
|
|
71
99
|
{
|
|
72
100
|
id: "gpt-5-mini-2025-08-07",
|
|
73
|
-
provider: "openai"
|
|
101
|
+
provider: "openai",
|
|
102
|
+
supportsFast: true
|
|
74
103
|
},
|
|
75
104
|
{
|
|
76
105
|
id: "gpt-5-nano",
|
|
@@ -82,7 +111,8 @@ var OPENAI_MODELS = [
|
|
|
82
111
|
},
|
|
83
112
|
{
|
|
84
113
|
id: "gpt-5.1-codex",
|
|
85
|
-
provider: "openai"
|
|
114
|
+
provider: "openai",
|
|
115
|
+
supportsFast: true
|
|
86
116
|
},
|
|
87
117
|
{
|
|
88
118
|
id: "gpt-5.1-codex-max",
|
|
@@ -94,7 +124,8 @@ var OPENAI_MODELS = [
|
|
|
94
124
|
},
|
|
95
125
|
{
|
|
96
126
|
id: "gpt-5-codex",
|
|
97
|
-
provider: "openai"
|
|
127
|
+
provider: "openai",
|
|
128
|
+
supportsFast: true
|
|
98
129
|
},
|
|
99
130
|
{
|
|
100
131
|
id: "gpt-5-codex-mini",
|
|
@@ -210,9 +241,18 @@ var ANTHROPIC_MODELS = [
|
|
|
210
241
|
provider: "anthropic",
|
|
211
242
|
aliases: ["default"]
|
|
212
243
|
},
|
|
244
|
+
{
|
|
245
|
+
id: "claude-opus-4-7",
|
|
246
|
+
provider: "anthropic",
|
|
247
|
+
contextWindow: 1e6,
|
|
248
|
+
maxInputTokens: 1e6,
|
|
249
|
+
maxOutputTokens: 128e3,
|
|
250
|
+
supportsFast: true
|
|
251
|
+
},
|
|
213
252
|
{
|
|
214
253
|
id: "claude-opus-4-6",
|
|
215
|
-
provider: "anthropic"
|
|
254
|
+
provider: "anthropic",
|
|
255
|
+
supportsFast: true
|
|
216
256
|
},
|
|
217
257
|
{
|
|
218
258
|
id: "claude-opus-4-5",
|
|
@@ -307,10 +347,18 @@ function listModels(registry, provider) {
|
|
|
307
347
|
const all = Object.values(registry.modelsById);
|
|
308
348
|
return provider ? all.filter((model) => model.provider === provider) : all;
|
|
309
349
|
}
|
|
350
|
+
var isPositiveFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value) && value > 0;
|
|
351
|
+
function isUsableModelSpec(spec) {
|
|
352
|
+
return isPositiveFiniteNumber(spec?.maxInputTokens) || isPositiveFiniteNumber(spec?.contextWindow);
|
|
353
|
+
}
|
|
310
354
|
function resolveProviderModelId(registry, idOrAlias, provider) {
|
|
311
355
|
const spec = resolveModel(registry, idOrAlias, provider);
|
|
312
356
|
return spec ? spec.providerModelId ?? spec.id : void 0;
|
|
313
357
|
}
|
|
358
|
+
function supportsFastMode(registry, idOrAlias, provider) {
|
|
359
|
+
const spec = resolveModel(registry, idOrAlias, provider);
|
|
360
|
+
return spec?.supportsFast === true;
|
|
361
|
+
}
|
|
314
362
|
function cloneAliases(aliasesByProvider) {
|
|
315
363
|
return {
|
|
316
364
|
openai: { ...aliasesByProvider.openai },
|
|
@@ -2234,12 +2282,14 @@ var DEFAULT_CLIENT_TIMEOUT_MS = 20 * 60 * 1e3;
|
|
|
2234
2282
|
var DEFAULT_PROMPT_CACHE_CONTROL = {
|
|
2235
2283
|
type: "ephemeral"
|
|
2236
2284
|
};
|
|
2285
|
+
var FAST_MODE_BETA = "fast-mode-2026-02-01";
|
|
2237
2286
|
var ChatAnthropic = class {
|
|
2238
2287
|
provider = PROVIDER_NAME;
|
|
2239
2288
|
model;
|
|
2240
2289
|
client;
|
|
2241
2290
|
defaultMaxTokens;
|
|
2242
2291
|
defaultInvokeOptions;
|
|
2292
|
+
fastMode;
|
|
2243
2293
|
reasoningLevelMeta;
|
|
2244
2294
|
debugInvokeSeq = 0;
|
|
2245
2295
|
lastDebugRequestPayload = null;
|
|
@@ -2251,6 +2301,7 @@ var ChatAnthropic = class {
|
|
|
2251
2301
|
this.model = options.model ?? DEFAULT_MODEL;
|
|
2252
2302
|
this.defaultMaxTokens = options.maxTokens ?? DEFAULT_MAX_TOKENS;
|
|
2253
2303
|
this.defaultInvokeOptions = { ...options.invokeOptions ?? {} };
|
|
2304
|
+
this.fastMode = options.fastMode === true;
|
|
2254
2305
|
this.reasoningLevelMeta = {
|
|
2255
2306
|
requested: options.reasoningLevelRequested,
|
|
2256
2307
|
applied: options.reasoningLevelApplied,
|
|
@@ -2288,14 +2339,17 @@ var ChatAnthropic = class {
|
|
|
2288
2339
|
if (request.cache_control === void 0) {
|
|
2289
2340
|
request.cache_control = DEFAULT_PROMPT_CACHE_CONTROL;
|
|
2290
2341
|
}
|
|
2342
|
+
if (this.fastMode) {
|
|
2343
|
+
request.speed = "fast";
|
|
2344
|
+
request.betas = [...request.betas ?? [], FAST_MODE_BETA];
|
|
2345
|
+
}
|
|
2291
2346
|
const debugSeq = this.nextDebugInvokeSeq();
|
|
2292
2347
|
await this.debugRequestIfEnabled(request, debugSeq);
|
|
2293
|
-
const
|
|
2348
|
+
const requestOptions = signal ? { signal } : void 0;
|
|
2349
|
+
const response = this.fastMode ? await this.client.beta.messages.create(
|
|
2294
2350
|
request,
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
} : void 0
|
|
2298
|
-
);
|
|
2351
|
+
requestOptions
|
|
2352
|
+
) : await this.client.messages.create(request, requestOptions);
|
|
2299
2353
|
await this.debugResponseIfEnabled(response, debugSeq);
|
|
2300
2354
|
return toChatInvokeCompletion(response, {
|
|
2301
2355
|
reasoning_requested: this.reasoningLevelMeta.requested,
|
|
@@ -2613,7 +2667,11 @@ var OpenAiResponseAccumulator = class {
|
|
|
2613
2667
|
break;
|
|
2614
2668
|
}
|
|
2615
2669
|
case "response.content_part.added": {
|
|
2616
|
-
this.addContentPart(
|
|
2670
|
+
this.addContentPart(
|
|
2671
|
+
event.output_index,
|
|
2672
|
+
event.content_index,
|
|
2673
|
+
event.part
|
|
2674
|
+
);
|
|
2617
2675
|
break;
|
|
2618
2676
|
}
|
|
2619
2677
|
case "response.output_text.delta": {
|
|
@@ -2625,7 +2683,11 @@ var OpenAiResponseAccumulator = class {
|
|
|
2625
2683
|
break;
|
|
2626
2684
|
}
|
|
2627
2685
|
case "response.output_text.done": {
|
|
2628
|
-
this.setMessageText(
|
|
2686
|
+
this.setMessageText(
|
|
2687
|
+
event.output_index,
|
|
2688
|
+
event.content_index,
|
|
2689
|
+
event.text
|
|
2690
|
+
);
|
|
2629
2691
|
break;
|
|
2630
2692
|
}
|
|
2631
2693
|
case "response.refusal.delta": {
|
|
@@ -2764,13 +2826,17 @@ var OpenAiResponseAccumulator = class {
|
|
|
2764
2826
|
}
|
|
2765
2827
|
if (output.type === "message" && part.type !== "reasoning_text") {
|
|
2766
2828
|
ensureArrayIndex(output.content, contentIndex);
|
|
2767
|
-
output.content[contentIndex] = cloneValue(
|
|
2829
|
+
output.content[contentIndex] = cloneValue(
|
|
2830
|
+
part
|
|
2831
|
+
);
|
|
2768
2832
|
return;
|
|
2769
2833
|
}
|
|
2770
2834
|
if (output.type === "reasoning" && part.type === "reasoning_text") {
|
|
2771
2835
|
const content = output.content ?? [];
|
|
2772
2836
|
ensureArrayIndex(content, contentIndex);
|
|
2773
|
-
content[contentIndex] = cloneValue(
|
|
2837
|
+
content[contentIndex] = cloneValue(
|
|
2838
|
+
part
|
|
2839
|
+
);
|
|
2774
2840
|
output.content = content;
|
|
2775
2841
|
}
|
|
2776
2842
|
}
|
|
@@ -2933,9 +2999,7 @@ var OpenAiResponseAccumulator = class {
|
|
|
2933
2999
|
}
|
|
2934
3000
|
loggedUnhandledResponseEventTypes.add(event.type);
|
|
2935
3001
|
const payload = getResponseStreamEventDebugPayload(event);
|
|
2936
|
-
console.error(
|
|
2937
|
-
`[openai.stream.unhandled] ${safeJsonStringify(payload)}`
|
|
2938
|
-
);
|
|
3002
|
+
console.error(`[openai.stream.unhandled] ${safeJsonStringify(payload)}`);
|
|
2939
3003
|
}
|
|
2940
3004
|
};
|
|
2941
3005
|
|
|
@@ -3550,9 +3614,7 @@ var OpenAiWsTransport = class {
|
|
|
3550
3614
|
if (settled || !terminalCompletedWithoutUsage) {
|
|
3551
3615
|
return;
|
|
3552
3616
|
}
|
|
3553
|
-
resolveOnce(
|
|
3554
|
-
accumulator.buildResponse(terminalCompletedWithoutUsage)
|
|
3555
|
-
);
|
|
3617
|
+
resolveOnce(accumulator.buildResponse(terminalCompletedWithoutUsage));
|
|
3556
3618
|
}, WS_TERMINAL_DONE_GRACE_MS);
|
|
3557
3619
|
};
|
|
3558
3620
|
const resetResponseTimeout = () => {
|
|
@@ -3592,9 +3654,7 @@ var OpenAiWsTransport = class {
|
|
|
3592
3654
|
}
|
|
3593
3655
|
if (type === "response.done" && terminalCompletedWithoutUsage) {
|
|
3594
3656
|
clearDoneGraceTimer();
|
|
3595
|
-
resolveOnce(
|
|
3596
|
-
accumulator.buildResponse(terminalCompletedWithoutUsage)
|
|
3597
|
-
);
|
|
3657
|
+
resolveOnce(accumulator.buildResponse(terminalCompletedWithoutUsage));
|
|
3598
3658
|
return;
|
|
3599
3659
|
}
|
|
3600
3660
|
rejectOnce(
|
|
@@ -4130,6 +4190,7 @@ var ChatOpenAI = class {
|
|
|
4130
4190
|
defaultReasoningEffort;
|
|
4131
4191
|
reasoningLevelMeta;
|
|
4132
4192
|
defaultTextVerbosity;
|
|
4193
|
+
defaultServiceTier;
|
|
4133
4194
|
websocketMode;
|
|
4134
4195
|
websocketApiVersion;
|
|
4135
4196
|
wsTransport;
|
|
@@ -4149,6 +4210,7 @@ var ChatOpenAI = class {
|
|
|
4149
4210
|
fallbackApplied: options.reasoningFallbackApplied
|
|
4150
4211
|
};
|
|
4151
4212
|
this.defaultTextVerbosity = options.textVerbosity;
|
|
4213
|
+
this.defaultServiceTier = options.serviceTier;
|
|
4152
4214
|
this.websocketMode = options.websocketMode ?? "off";
|
|
4153
4215
|
this.websocketApiVersion = options.websocketApiVersion ?? "v2";
|
|
4154
4216
|
this.wsTransport = new OpenAiWsTransport({
|
|
@@ -4172,7 +4234,7 @@ var ChatOpenAI = class {
|
|
|
4172
4234
|
const instructions = extractInstructions(messages);
|
|
4173
4235
|
const tools = toResponsesTools(toolDefs);
|
|
4174
4236
|
const tool_choice = toResponsesToolChoice(toolChoice);
|
|
4175
|
-
const { reasoningEffort, textVerbosity, ...rest } = options ?? {};
|
|
4237
|
+
const { reasoningEffort, textVerbosity, serviceTier, ...rest } = options ?? {};
|
|
4176
4238
|
const request = {
|
|
4177
4239
|
model: model ?? this.providerModel,
|
|
4178
4240
|
input: inputItems,
|
|
@@ -4204,6 +4266,10 @@ var ChatOpenAI = class {
|
|
|
4204
4266
|
verbosity
|
|
4205
4267
|
};
|
|
4206
4268
|
}
|
|
4269
|
+
const resolvedServiceTier = serviceTier ?? this.defaultServiceTier;
|
|
4270
|
+
if (resolvedServiceTier) {
|
|
4271
|
+
request.service_tier = resolvedServiceTier;
|
|
4272
|
+
}
|
|
4207
4273
|
if (context?.sessionKey && !request.prompt_cache_key) {
|
|
4208
4274
|
request.prompt_cache_key = context.sessionKey;
|
|
4209
4275
|
}
|
|
@@ -5460,10 +5526,12 @@ export {
|
|
|
5460
5526
|
createModelRegistry,
|
|
5461
5527
|
defineTool,
|
|
5462
5528
|
getDefaultSystemPromptPath,
|
|
5529
|
+
isUsableModelSpec,
|
|
5463
5530
|
listModels,
|
|
5464
5531
|
registerModels,
|
|
5465
5532
|
resolveModel,
|
|
5466
5533
|
resolveProviderModelId,
|
|
5467
5534
|
stringifyContent,
|
|
5468
|
-
stringifyContentParts
|
|
5535
|
+
stringifyContentParts,
|
|
5536
|
+
supportsFastMode
|
|
5469
5537
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codelia/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.66",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@anthropic-ai/sdk": "^0.78.0",
|
|
28
|
-
"@codelia/config": "0.1.
|
|
29
|
-
"@codelia/shared-types": "0.1.
|
|
28
|
+
"@codelia/config": "0.1.66",
|
|
29
|
+
"@codelia/shared-types": "0.1.66",
|
|
30
30
|
"@google-cloud/vertexai": "^1.10.0",
|
|
31
31
|
"@google/genai": "^1.43.0",
|
|
32
32
|
"json-schema": "^0.4.0",
|