@opencode-ai/ai 0.0.0-beta-18045 → 0.0.0-beta-18135
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/protocols/anthropic-messages.d.ts +259 -17
- package/dist/protocols/anthropic-messages.js +337 -24
- package/dist/protocols/gemini.d.ts +4 -31
- package/dist/protocols/gemini.js +23 -4
- package/dist/protocols/open-responses.d.ts +8 -4
- package/dist/protocols/open-responses.js +73 -38
- package/dist/protocols/openai-chat.d.ts +25 -11
- package/dist/protocols/openai-chat.js +124 -8
- package/dist/protocols/openai-compatible-chat.d.ts +3 -1
- package/dist/protocols/openai-compatible-responses.d.ts +1 -1
- package/dist/protocols/openai-responses.d.ts +5 -5
- package/dist/protocols/openai-responses.js +21 -5
- package/dist/protocols/utils/bedrock-media.d.ts +1 -0
- package/dist/protocols/xai-responses.d.ts +1 -1
- package/dist/protocols/xai-responses.js +2 -10
- package/dist/providers/amazon-bedrock-mantle.d.ts +4 -2
- package/dist/providers/anthropic-compatible.d.ts +75 -4
- package/dist/providers/anthropic.d.ts +75 -4
- package/dist/providers/azure.d.ts +4 -2
- package/dist/providers/cloudflare.d.ts +9 -3
- package/dist/providers/google-vertex-chat.d.ts +3 -1
- package/dist/providers/google-vertex-messages.d.ts +75 -4
- package/dist/providers/google-vertex-responses.d.ts +1 -1
- package/dist/providers/google-vertex.d.ts +1 -1
- package/dist/providers/google.d.ts +1 -1
- package/dist/providers/openai-compatible-responses.d.ts +1 -1
- package/dist/providers/openai-compatible.d.ts +3 -1
- package/dist/providers/openai.d.ts +4 -2
- package/dist/providers/openrouter.d.ts +11 -3
- package/dist/providers/xai.d.ts +3 -1
- package/dist/schema/messages.d.ts +4 -0
- package/dist/schema/messages.js +2 -0
- package/dist/schema/options.d.ts +5 -0
- package/dist/schema/options.js +5 -0
- package/package.json +3 -3
|
@@ -434,6 +434,7 @@ export declare const Event: Schema.StructWithRest<Schema.Struct<{
|
|
|
434
434
|
readonly headers: Schema.optional<Schema.Unknown>;
|
|
435
435
|
}>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>;
|
|
436
436
|
export type Event = Schema.Schema.Type<typeof Event>;
|
|
437
|
+
export type ItemKind = "message" | "reasoning" | "function-call" | "reference";
|
|
437
438
|
export interface Extension {
|
|
438
439
|
readonly id: string;
|
|
439
440
|
readonly name: string;
|
|
@@ -442,6 +443,7 @@ export interface Extension {
|
|
|
442
443
|
readonly media: ProviderShared.NormalizedMedia;
|
|
443
444
|
readonly request: LLMRequest;
|
|
444
445
|
}) => MediaInput | undefined;
|
|
446
|
+
readonly acceptsItemID?: (kind: ItemKind, id: string) => boolean;
|
|
445
447
|
}
|
|
446
448
|
export interface ParserState {
|
|
447
449
|
readonly id: string;
|
|
@@ -459,6 +461,7 @@ type ReasoningSummaryStatus = "active" | "can-conclude" | "concluded";
|
|
|
459
461
|
interface ReasoningStreamItem {
|
|
460
462
|
readonly encryptedContent: string | null | undefined;
|
|
461
463
|
readonly summaryParts: Readonly<Record<number, ReasoningSummaryStatus>>;
|
|
464
|
+
readonly deltaIndexes: ReadonlySet<number>;
|
|
462
465
|
}
|
|
463
466
|
export declare const lowerTool: (protocolName: string, tool: ToolDefinition, inputSchema: {
|
|
464
467
|
readonly [x: string]: unknown;
|
|
@@ -475,6 +478,7 @@ export declare const lowerToolChoice: (protocolName: string, toolChoice: NonNull
|
|
|
475
478
|
type: "function";
|
|
476
479
|
name: string;
|
|
477
480
|
}, AIError, never>;
|
|
481
|
+
export declare const resolveParallelToolCalls: (request: LLMRequest) => boolean | undefined;
|
|
478
482
|
export declare const fromRequestWithExtension: (request: LLMRequest, extension: Extension) => Effect.Effect<{
|
|
479
483
|
truncation?: "auto" | "disabled" | undefined;
|
|
480
484
|
parallel_tool_calls?: boolean | undefined;
|
|
@@ -617,6 +621,7 @@ export declare const fromRequest: (request: LLMRequest) => Effect.Effect<{
|
|
|
617
621
|
readonly verbosity?: OpenResponsesOptions.TextVerbosity | undefined;
|
|
618
622
|
} | undefined;
|
|
619
623
|
readonly temperature?: number | undefined;
|
|
624
|
+
readonly service_tier?: OpenResponsesOptions.ServiceTier | undefined;
|
|
620
625
|
readonly tool_choice?: "required" | "auto" | "none" | {
|
|
621
626
|
readonly type: "function";
|
|
622
627
|
readonly name: string;
|
|
@@ -640,7 +645,6 @@ export declare const fromRequest: (request: LLMRequest) => Effect.Effect<{
|
|
|
640
645
|
readonly presence_penalty?: number | undefined;
|
|
641
646
|
readonly safety_identifier?: string | undefined;
|
|
642
647
|
readonly top_logprobs?: number | undefined;
|
|
643
|
-
readonly service_tier?: OpenResponsesOptions.ServiceTier | undefined;
|
|
644
648
|
readonly max_output_tokens?: number | undefined;
|
|
645
649
|
readonly max_tool_calls?: number | undefined;
|
|
646
650
|
readonly parallel_tool_calls?: boolean | undefined;
|
|
@@ -649,7 +653,7 @@ export declare const providerMetadata: (state: ParserState, metadata: Record<str
|
|
|
649
653
|
export type StepResult = readonly [ParserState, ReadonlyArray<LLMEvent>];
|
|
650
654
|
export declare const terminal: (event: Event) => boolean;
|
|
651
655
|
export declare const onReasoningDelta: (state: ParserState, event: Event, itemID: string) => StepResult;
|
|
652
|
-
export declare const onReasoningDone: (state: ParserState,
|
|
656
|
+
export declare const onReasoningDone: (state: ParserState, event: Event, itemID: string) => StepResult;
|
|
653
657
|
export declare const providerFailure: (id: string, event: Event, fallback: string) => AIError;
|
|
654
658
|
export declare const step: (state: ParserState, event: Event) => AIError | Effect.Effect<StepResult, never, never> | Effect.Effect<[ParserState, readonly ({
|
|
655
659
|
readonly type: "step-start";
|
|
@@ -927,6 +931,7 @@ export declare const protocol: Protocol<{
|
|
|
927
931
|
readonly verbosity?: OpenResponsesOptions.TextVerbosity | undefined;
|
|
928
932
|
} | undefined;
|
|
929
933
|
readonly temperature?: number | undefined;
|
|
934
|
+
readonly service_tier?: OpenResponsesOptions.ServiceTier | undefined;
|
|
930
935
|
readonly tool_choice?: "required" | "auto" | "none" | {
|
|
931
936
|
readonly type: "function";
|
|
932
937
|
readonly name: string;
|
|
@@ -950,7 +955,6 @@ export declare const protocol: Protocol<{
|
|
|
950
955
|
readonly presence_penalty?: number | undefined;
|
|
951
956
|
readonly safety_identifier?: string | undefined;
|
|
952
957
|
readonly top_logprobs?: number | undefined;
|
|
953
|
-
readonly service_tier?: OpenResponsesOptions.ServiceTier | undefined;
|
|
954
958
|
readonly max_output_tokens?: number | undefined;
|
|
955
959
|
readonly max_tool_calls?: number | undefined;
|
|
956
960
|
readonly parallel_tool_calls?: boolean | undefined;
|
|
@@ -1098,6 +1102,7 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
1098
1102
|
readonly verbosity?: OpenResponsesOptions.TextVerbosity | undefined;
|
|
1099
1103
|
} | undefined;
|
|
1100
1104
|
readonly temperature?: number | undefined;
|
|
1105
|
+
readonly service_tier?: OpenResponsesOptions.ServiceTier | undefined;
|
|
1101
1106
|
readonly tool_choice?: "required" | "auto" | "none" | {
|
|
1102
1107
|
readonly type: "function";
|
|
1103
1108
|
readonly name: string;
|
|
@@ -1121,7 +1126,6 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
1121
1126
|
readonly presence_penalty?: number | undefined;
|
|
1122
1127
|
readonly safety_identifier?: string | undefined;
|
|
1123
1128
|
readonly top_logprobs?: number | undefined;
|
|
1124
|
-
readonly service_tier?: OpenResponsesOptions.ServiceTier | undefined;
|
|
1125
1129
|
readonly max_output_tokens?: number | undefined;
|
|
1126
1130
|
readonly max_tool_calls?: number | undefined;
|
|
1127
1131
|
readonly parallel_tool_calls?: boolean | undefined;
|
|
@@ -245,26 +245,34 @@ export const lowerToolChoice = (protocolName, toolChoice) => ProviderShared.matc
|
|
|
245
245
|
required: () => "required",
|
|
246
246
|
tool: (toolName) => ({ type: "function", name: toolName }),
|
|
247
247
|
});
|
|
248
|
+
// Servers validate item ids on replayed history, and a malformed or oversized
|
|
249
|
+
// id can fail an otherwise valid request. Only server-issued tokens are worth
|
|
250
|
+
// resending; anything else is treated as absent so the item is resent without
|
|
251
|
+
// an id (or skipped, for items that cannot be expressed without one).
|
|
252
|
+
const ITEM_ID_PATTERN = /^[A-Za-z0-9_-]{1,64}$/;
|
|
248
253
|
const itemID = (providerMetadata, providerMetadataKey) => {
|
|
249
254
|
const metadata = providerMetadata?.[providerMetadataKey];
|
|
250
|
-
return ProviderShared.isRecord(metadata) &&
|
|
255
|
+
return ProviderShared.isRecord(metadata) &&
|
|
256
|
+
typeof metadata.itemId === "string" &&
|
|
257
|
+
ITEM_ID_PATTERN.test(metadata.itemId)
|
|
251
258
|
? metadata.itemId
|
|
252
259
|
: undefined;
|
|
253
260
|
};
|
|
254
|
-
const
|
|
261
|
+
const acceptsItemID = (extension, kind, id) => id !== undefined && (extension.acceptsItemID?.(kind, id) ?? true);
|
|
262
|
+
const lowerToolCall = (part, providerMetadataKey, extension) => {
|
|
255
263
|
const id = itemID(part.providerMetadata, providerMetadataKey);
|
|
256
264
|
return {
|
|
257
265
|
type: "function_call",
|
|
258
|
-
...(id ? { id } : {}),
|
|
266
|
+
...(acceptsItemID(extension, "function-call", id) ? { id } : {}),
|
|
259
267
|
call_id: part.id,
|
|
260
268
|
name: part.name,
|
|
261
269
|
arguments: ProviderShared.encodeJson(part.input),
|
|
262
270
|
};
|
|
263
271
|
};
|
|
264
|
-
const lowerReasoning = (part, providerMetadataKey) => {
|
|
272
|
+
const lowerReasoning = (part, providerMetadataKey, extension) => {
|
|
265
273
|
const metadata = part.providerMetadata?.[providerMetadataKey];
|
|
266
274
|
const id = itemID(part.providerMetadata, providerMetadataKey);
|
|
267
|
-
if (!ProviderShared.isRecord(metadata) || !id)
|
|
275
|
+
if (!ProviderShared.isRecord(metadata) || !acceptsItemID(extension, "reasoning", id))
|
|
268
276
|
return undefined;
|
|
269
277
|
const encryptedContent = typeof metadata.reasoningEncryptedContent === "string" || metadata.reasoningEncryptedContent === null
|
|
270
278
|
? metadata.reasoningEncryptedContent
|
|
@@ -359,7 +367,8 @@ const lowerMessages = Effect.fn("OpenResponses.lowerMessages")(function* (reques
|
|
|
359
367
|
return;
|
|
360
368
|
const groups = content.reduce((groups, part) => {
|
|
361
369
|
const metadata = part.providerMetadata?.[providerMetadataKey];
|
|
362
|
-
const
|
|
370
|
+
const rawID = itemID(part.providerMetadata, providerMetadataKey);
|
|
371
|
+
const id = acceptsItemID(extension, "message", rawID) ? rawID : undefined;
|
|
363
372
|
const phase = ProviderShared.isRecord(metadata) ? messagePhase(metadata.phase) : undefined;
|
|
364
373
|
const group = groups.at(-1);
|
|
365
374
|
if (group && group.id === id && group.phase === phase)
|
|
@@ -384,7 +393,7 @@ const lowerMessages = Effect.fn("OpenResponses.lowerMessages")(function* (reques
|
|
|
384
393
|
}
|
|
385
394
|
if (part.type === "reasoning") {
|
|
386
395
|
flushText();
|
|
387
|
-
const reasoning = lowerReasoning(part, providerMetadataKey);
|
|
396
|
+
const reasoning = lowerReasoning(part, providerMetadataKey, extension);
|
|
388
397
|
if (!reasoning)
|
|
389
398
|
continue;
|
|
390
399
|
if (store !== false) {
|
|
@@ -408,14 +417,15 @@ const lowerMessages = Effect.fn("OpenResponses.lowerMessages")(function* (reques
|
|
|
408
417
|
flushText();
|
|
409
418
|
if (part.providerExecuted === true)
|
|
410
419
|
continue;
|
|
411
|
-
input.push(lowerToolCall(part, providerMetadataKey));
|
|
420
|
+
input.push(lowerToolCall(part, providerMetadataKey, extension));
|
|
412
421
|
continue;
|
|
413
422
|
}
|
|
414
423
|
if (part.type === "tool-result" && part.providerExecuted === true) {
|
|
415
424
|
flushText();
|
|
416
425
|
const id = itemID(part.providerMetadata, providerMetadataKey);
|
|
417
|
-
|
|
418
|
-
|
|
426
|
+
const reference = acceptsItemID(extension, "reference", id) ? id : undefined;
|
|
427
|
+
if (store !== false && reference && !hostedToolReferences.has(reference))
|
|
428
|
+
input.push({ type: "item_reference", id: reference });
|
|
419
429
|
if (store === false) {
|
|
420
430
|
// The server is not storing this exchange, so the tool outcome has to
|
|
421
431
|
// travel in the input. Non-content results degrade to their text form.
|
|
@@ -427,8 +437,8 @@ const lowerMessages = Effect.fn("OpenResponses.lowerMessages")(function* (reques
|
|
|
427
437
|
content: yield* Effect.forEach(content, (item) => lowerHostedToolResultContentItem(item, request, extension)),
|
|
428
438
|
});
|
|
429
439
|
}
|
|
430
|
-
if (
|
|
431
|
-
hostedToolReferences.add(
|
|
440
|
+
if (reference)
|
|
441
|
+
hostedToolReferences.add(reference);
|
|
432
442
|
continue;
|
|
433
443
|
}
|
|
434
444
|
return yield* ProviderShared.unsupportedContent(extension.name, "assistant", [
|
|
@@ -461,6 +471,7 @@ const lowerMessages = Effect.fn("OpenResponses.lowerMessages")(function* (reques
|
|
|
461
471
|
const lowerOptions = (request) => {
|
|
462
472
|
const options = OpenResponsesOptions.resolve(request);
|
|
463
473
|
const cacheKey = ProviderShared.clampPromptCacheKey(request.promptCacheKey);
|
|
474
|
+
const parallelToolCalls = resolveParallelToolCalls(request);
|
|
464
475
|
return {
|
|
465
476
|
...(options.instructions ? { instructions: options.instructions } : {}),
|
|
466
477
|
...(options.store !== undefined ? { store: options.store } : {}),
|
|
@@ -478,10 +489,17 @@ const lowerOptions = (request) => {
|
|
|
478
489
|
...(options.textVerbosity ? { text: { verbosity: options.textVerbosity } } : {}),
|
|
479
490
|
...(options.serviceTier ? { service_tier: options.serviceTier } : {}),
|
|
480
491
|
...(options.maxToolCalls !== undefined ? { max_tool_calls: options.maxToolCalls } : {}),
|
|
481
|
-
...(
|
|
492
|
+
...(parallelToolCalls !== undefined ? { parallel_tool_calls: parallelToolCalls } : {}),
|
|
482
493
|
...(options.truncation ? { truncation: options.truncation } : {}),
|
|
483
494
|
};
|
|
484
495
|
};
|
|
496
|
+
export const resolveParallelToolCalls = (request) => {
|
|
497
|
+
const configured = OpenResponsesOptions.resolve(request).parallelToolCalls;
|
|
498
|
+
if (configured !== undefined)
|
|
499
|
+
return configured;
|
|
500
|
+
const disabled = request.toolChoice?.disableParallelToolUse;
|
|
501
|
+
return disabled === undefined ? undefined : !disabled;
|
|
502
|
+
};
|
|
485
503
|
const allowedToolChoice = (request) => {
|
|
486
504
|
const allowed = OpenResponsesOptions.resolve(request).allowedTools;
|
|
487
505
|
if (!allowed)
|
|
@@ -567,7 +585,7 @@ const NO_EVENTS = [];
|
|
|
567
585
|
const TERMINAL_TYPES = new Set(["error", "response.completed", "response.incomplete", "response.failed"]);
|
|
568
586
|
export const terminal = (event) => TERMINAL_TYPES.has(event.type);
|
|
569
587
|
const onOutputTextDelta = (state, event, id) => {
|
|
570
|
-
if (!event.delta)
|
|
588
|
+
if (!event.delta || !state.messageItems.has(id))
|
|
571
589
|
return [state, NO_EVENTS];
|
|
572
590
|
const events = [];
|
|
573
591
|
const phase = state.messagePhases[id];
|
|
@@ -585,19 +603,35 @@ const onOutputTextDone = (state, event, id) => {
|
|
|
585
603
|
return [{ ...state, lifecycle: Lifecycle.textEnd(state.lifecycle, events, id) }, events];
|
|
586
604
|
};
|
|
587
605
|
export const onReasoningDelta = (state, event, itemID) => {
|
|
588
|
-
|
|
606
|
+
const item = state.reasoningItems[itemID];
|
|
607
|
+
if (!event.delta || !item)
|
|
589
608
|
return [state, NO_EVENTS];
|
|
609
|
+
const index = event.summary_index ?? 0;
|
|
590
610
|
const events = [];
|
|
591
|
-
const id = event.summary_index !== undefined || state.reasoningItems[itemID] ? `${itemID}:${event.summary_index ?? 0}` : itemID;
|
|
592
611
|
return [
|
|
593
612
|
{
|
|
594
613
|
...state,
|
|
595
|
-
lifecycle: Lifecycle.reasoningDelta(state.lifecycle, events,
|
|
614
|
+
lifecycle: Lifecycle.reasoningDelta(state.lifecycle, events, `${itemID}:${index}`, event.delta),
|
|
615
|
+
reasoningItems: {
|
|
616
|
+
...state.reasoningItems,
|
|
617
|
+
[itemID]: { ...item, deltaIndexes: new Set([...item.deltaIndexes, index]) },
|
|
618
|
+
},
|
|
596
619
|
},
|
|
597
620
|
events,
|
|
598
621
|
];
|
|
599
622
|
};
|
|
600
|
-
|
|
623
|
+
// Some compatible gateways emit a reasoning final without streaming any
|
|
624
|
+
// deltas, mirroring `response.output_text.done`. Reconcile the complete text
|
|
625
|
+
// as a single delta unless that summary index already streamed one.
|
|
626
|
+
export const onReasoningDone = (state, event, itemID) => {
|
|
627
|
+
const item = state.reasoningItems[itemID];
|
|
628
|
+
if (!item || typeof event.text !== "string")
|
|
629
|
+
return [state, NO_EVENTS];
|
|
630
|
+
const index = event.summary_index ?? 0;
|
|
631
|
+
if (item.deltaIndexes.has(index))
|
|
632
|
+
return [state, NO_EVENTS];
|
|
633
|
+
return onReasoningDelta(state, { ...event, delta: event.text }, itemID);
|
|
634
|
+
};
|
|
601
635
|
const reasoningMetadata = (state, item) => providerMetadata(state, { itemId: item.id, reasoningEncryptedContent: item.encrypted_content ?? null });
|
|
602
636
|
// Responses APIs stream reasoning items in a stable order:
|
|
603
637
|
// `output_item.added` (reasoning) →
|
|
@@ -632,7 +666,11 @@ const onOutputItemAdded = (state, event) => {
|
|
|
632
666
|
lifecycle: Lifecycle.reasoningStart(state.lifecycle, events, `${item.id}:0`, reasoningMetadata(state, item)),
|
|
633
667
|
reasoningItems: {
|
|
634
668
|
...state.reasoningItems,
|
|
635
|
-
[item.id]: {
|
|
669
|
+
[item.id]: {
|
|
670
|
+
encryptedContent: item.encrypted_content,
|
|
671
|
+
summaryParts: { 0: "active" },
|
|
672
|
+
deltaIndexes: new Set(),
|
|
673
|
+
},
|
|
636
674
|
},
|
|
637
675
|
},
|
|
638
676
|
events,
|
|
@@ -663,23 +701,11 @@ const onOutputItemAdded = (state, event) => {
|
|
|
663
701
|
const onReasoningSummaryPartAdded = (state, event) => {
|
|
664
702
|
if (!event.item_id || event.summary_index === undefined)
|
|
665
703
|
return [state, NO_EVENTS];
|
|
666
|
-
const item = state.reasoningItems[event.item_id]
|
|
667
|
-
if (
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
return [
|
|
672
|
-
{
|
|
673
|
-
...state,
|
|
674
|
-
lifecycle: Lifecycle.reasoningStart(state.lifecycle, events, `${event.item_id}:0`, providerMetadata(state, { itemId: event.item_id, reasoningEncryptedContent: null })),
|
|
675
|
-
reasoningItems: {
|
|
676
|
-
...state.reasoningItems,
|
|
677
|
-
[event.item_id]: { ...item, summaryParts: { 0: "active" } },
|
|
678
|
-
},
|
|
679
|
-
},
|
|
680
|
-
events,
|
|
681
|
-
];
|
|
682
|
-
}
|
|
704
|
+
const item = state.reasoningItems[event.item_id];
|
|
705
|
+
if (!item)
|
|
706
|
+
return [state, NO_EVENTS];
|
|
707
|
+
if (event.summary_index === 0)
|
|
708
|
+
return [state, NO_EVENTS];
|
|
683
709
|
const events = [];
|
|
684
710
|
const closed = Object.entries(item.summaryParts)
|
|
685
711
|
.filter((entry) => entry[1] === "can-conclude")
|
|
@@ -730,7 +756,7 @@ const onReasoningSummaryPartDone = (state, event) => {
|
|
|
730
756
|
];
|
|
731
757
|
};
|
|
732
758
|
const onFunctionCallArgumentsDelta = Effect.fn("OpenResponses.onFunctionCallArgumentsDelta")(function* (state, event) {
|
|
733
|
-
if (!event.item_id || !event.delta)
|
|
759
|
+
if (!event.item_id || !event.delta || !state.tools[event.item_id])
|
|
734
760
|
return [state, NO_EVENTS];
|
|
735
761
|
const result = ToolStream.appendExisting(state.id, state.tools, event.item_id, event.delta, `${state.name} tool argument delta is missing its tool call`);
|
|
736
762
|
if (ToolStream.isError(result))
|
|
@@ -897,6 +923,13 @@ export const step = (state, event) => {
|
|
|
897
923
|
return ProviderShared.eventError(state.id, `${event.type} is missing item_id`);
|
|
898
924
|
return Effect.succeed(onReasoningDelta(state, event, event.item_id));
|
|
899
925
|
}
|
|
926
|
+
if (event.type === "response.reasoning.done" ||
|
|
927
|
+
event.type === "response.reasoning_summary_text.done" ||
|
|
928
|
+
event.type === "response.reasoning_text.done") {
|
|
929
|
+
if (!event.item_id)
|
|
930
|
+
return ProviderShared.eventError(state.id, `${event.type} is missing item_id`);
|
|
931
|
+
return Effect.succeed(onReasoningDone(state, event, event.item_id));
|
|
932
|
+
}
|
|
900
933
|
if (event.type === "response.reasoning_summary_part.added")
|
|
901
934
|
return event.item_id
|
|
902
935
|
? Effect.succeed(onReasoningSummaryPartAdded(state, event))
|
|
@@ -911,7 +944,9 @@ export const step = (state, event) => {
|
|
|
911
944
|
return Effect.succeed(onOutputItemAdded(state, event));
|
|
912
945
|
}
|
|
913
946
|
if (event.type === "response.function_call_arguments.delta")
|
|
914
|
-
return
|
|
947
|
+
return event.item_id
|
|
948
|
+
? onFunctionCallArgumentsDelta(state, event)
|
|
949
|
+
: ProviderShared.eventError(state.id, `${event.type} is missing item_id`);
|
|
915
950
|
if (event.type === "response.output_item.done") {
|
|
916
951
|
if (event.item?.type === "message" && !event.item.id)
|
|
917
952
|
return ProviderShared.eventError(state.id, `${event.type} message is missing id`);
|
|
@@ -77,6 +77,7 @@ export declare const bodyFields: {
|
|
|
77
77
|
readonly name: Schema.String;
|
|
78
78
|
readonly description: Schema.String;
|
|
79
79
|
readonly parameters: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
80
|
+
readonly strict: Schema.optional<Schema.Boolean>;
|
|
80
81
|
}>;
|
|
81
82
|
readonly cache_control: Schema.optional<Schema.Struct<{
|
|
82
83
|
readonly type: Schema.Literal<"ephemeral">;
|
|
@@ -96,6 +97,7 @@ export declare const bodyFields: {
|
|
|
96
97
|
store: Schema.optional<Schema.Boolean>;
|
|
97
98
|
prompt_cache_key: Schema.optional<Schema.String>;
|
|
98
99
|
reasoning_effort: Schema.optional<Schema.declare<import("./utils/open-responses-options.js").ReasoningEffort, import("./utils/open-responses-options.js").ReasoningEffort>>;
|
|
100
|
+
tool_stream: Schema.optional<Schema.Boolean>;
|
|
99
101
|
max_completion_tokens: Schema.optional<Schema.Number>;
|
|
100
102
|
max_tokens: Schema.optional<Schema.Number>;
|
|
101
103
|
temperature: Schema.optional<Schema.Number>;
|
|
@@ -171,6 +173,7 @@ declare const OpenAIChatBody: Schema.Struct<{
|
|
|
171
173
|
readonly name: Schema.String;
|
|
172
174
|
readonly description: Schema.String;
|
|
173
175
|
readonly parameters: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
176
|
+
readonly strict: Schema.optional<Schema.Boolean>;
|
|
174
177
|
}>;
|
|
175
178
|
readonly cache_control: Schema.optional<Schema.Struct<{
|
|
176
179
|
readonly type: Schema.Literal<"ephemeral">;
|
|
@@ -190,6 +193,7 @@ declare const OpenAIChatBody: Schema.Struct<{
|
|
|
190
193
|
store: Schema.optional<Schema.Boolean>;
|
|
191
194
|
prompt_cache_key: Schema.optional<Schema.String>;
|
|
192
195
|
reasoning_effort: Schema.optional<Schema.declare<import("./utils/open-responses-options.js").ReasoningEffort, import("./utils/open-responses-options.js").ReasoningEffort>>;
|
|
196
|
+
tool_stream: Schema.optional<Schema.Boolean>;
|
|
193
197
|
max_completion_tokens: Schema.optional<Schema.Number>;
|
|
194
198
|
max_tokens: Schema.optional<Schema.Number>;
|
|
195
199
|
temperature: Schema.optional<Schema.Number>;
|
|
@@ -292,6 +296,10 @@ export declare const fromRequest: (request: LLMRequest, options?: LoweringOption
|
|
|
292
296
|
seed: number | undefined;
|
|
293
297
|
stop: readonly string[] | undefined;
|
|
294
298
|
max_completion_tokens: number | undefined;
|
|
299
|
+
tool_stream?: boolean | undefined;
|
|
300
|
+
stream_options?: {
|
|
301
|
+
include_usage: boolean;
|
|
302
|
+
} | undefined;
|
|
295
303
|
model: string & import("effect/Brand").Brand<"AI.ModelID">;
|
|
296
304
|
messages: ({
|
|
297
305
|
readonly role: "system";
|
|
@@ -354,11 +362,12 @@ export declare const fromRequest: (request: LLMRequest, options?: LoweringOption
|
|
|
354
362
|
})[];
|
|
355
363
|
tools: {
|
|
356
364
|
readonly function: {
|
|
357
|
-
readonly name: string;
|
|
358
365
|
readonly description: string;
|
|
366
|
+
readonly name: string;
|
|
359
367
|
readonly parameters: {
|
|
360
368
|
readonly [x: string]: unknown;
|
|
361
369
|
};
|
|
370
|
+
readonly strict?: boolean | undefined;
|
|
362
371
|
};
|
|
363
372
|
readonly type: "function";
|
|
364
373
|
readonly cache_control?: {
|
|
@@ -373,9 +382,6 @@ export declare const fromRequest: (request: LLMRequest, options?: LoweringOption
|
|
|
373
382
|
};
|
|
374
383
|
} | undefined;
|
|
375
384
|
stream: true;
|
|
376
|
-
stream_options: {
|
|
377
|
-
include_usage: boolean;
|
|
378
|
-
};
|
|
379
385
|
} | {
|
|
380
386
|
reasoning_effort?: import("./utils/open-responses-options.js").ReasoningEffort | undefined;
|
|
381
387
|
prompt_cache_key?: string | undefined;
|
|
@@ -387,6 +393,10 @@ export declare const fromRequest: (request: LLMRequest, options?: LoweringOption
|
|
|
387
393
|
seed: number | undefined;
|
|
388
394
|
stop: readonly string[] | undefined;
|
|
389
395
|
max_tokens: number | undefined;
|
|
396
|
+
tool_stream?: boolean | undefined;
|
|
397
|
+
stream_options?: {
|
|
398
|
+
include_usage: boolean;
|
|
399
|
+
} | undefined;
|
|
390
400
|
model: string & import("effect/Brand").Brand<"AI.ModelID">;
|
|
391
401
|
messages: ({
|
|
392
402
|
readonly role: "system";
|
|
@@ -449,11 +459,12 @@ export declare const fromRequest: (request: LLMRequest, options?: LoweringOption
|
|
|
449
459
|
})[];
|
|
450
460
|
tools: {
|
|
451
461
|
readonly function: {
|
|
452
|
-
readonly name: string;
|
|
453
462
|
readonly description: string;
|
|
463
|
+
readonly name: string;
|
|
454
464
|
readonly parameters: {
|
|
455
465
|
readonly [x: string]: unknown;
|
|
456
466
|
};
|
|
467
|
+
readonly strict?: boolean | undefined;
|
|
457
468
|
};
|
|
458
469
|
readonly type: "function";
|
|
459
470
|
readonly cache_control?: {
|
|
@@ -468,9 +479,6 @@ export declare const fromRequest: (request: LLMRequest, options?: LoweringOption
|
|
|
468
479
|
};
|
|
469
480
|
} | undefined;
|
|
470
481
|
stream: true;
|
|
471
|
-
stream_options: {
|
|
472
|
-
include_usage: boolean;
|
|
473
|
-
};
|
|
474
482
|
}, AIError, never>;
|
|
475
483
|
/**
|
|
476
484
|
* The OpenAI Chat protocol — request body construction, body schema, and the
|
|
@@ -544,11 +552,12 @@ export declare const protocol: Protocol<{
|
|
|
544
552
|
readonly max_tokens?: number | undefined;
|
|
545
553
|
readonly tools?: readonly {
|
|
546
554
|
readonly function: {
|
|
547
|
-
readonly name: string;
|
|
548
555
|
readonly description: string;
|
|
556
|
+
readonly name: string;
|
|
549
557
|
readonly parameters: {
|
|
550
558
|
readonly [x: string]: unknown;
|
|
551
559
|
};
|
|
560
|
+
readonly strict?: boolean | undefined;
|
|
552
561
|
};
|
|
553
562
|
readonly type: "function";
|
|
554
563
|
readonly cache_control?: {
|
|
@@ -572,6 +581,7 @@ export declare const protocol: Protocol<{
|
|
|
572
581
|
} | undefined;
|
|
573
582
|
readonly prompt_cache_key?: string | undefined;
|
|
574
583
|
readonly reasoning_effort?: import("./utils/open-responses-options.js").ReasoningEffort | undefined;
|
|
584
|
+
readonly tool_stream?: boolean | undefined;
|
|
575
585
|
readonly frequency_penalty?: number | undefined;
|
|
576
586
|
readonly presence_penalty?: number | undefined;
|
|
577
587
|
}, string, {
|
|
@@ -706,11 +716,12 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
706
716
|
readonly max_tokens?: number | undefined;
|
|
707
717
|
readonly tools?: readonly {
|
|
708
718
|
readonly function: {
|
|
709
|
-
readonly name: string;
|
|
710
719
|
readonly description: string;
|
|
720
|
+
readonly name: string;
|
|
711
721
|
readonly parameters: {
|
|
712
722
|
readonly [x: string]: unknown;
|
|
713
723
|
};
|
|
724
|
+
readonly strict?: boolean | undefined;
|
|
714
725
|
};
|
|
715
726
|
readonly type: "function";
|
|
716
727
|
readonly cache_control?: {
|
|
@@ -734,6 +745,7 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
734
745
|
} | undefined;
|
|
735
746
|
readonly prompt_cache_key?: string | undefined;
|
|
736
747
|
readonly reasoning_effort?: import("./utils/open-responses-options.js").ReasoningEffort | undefined;
|
|
748
|
+
readonly tool_stream?: boolean | undefined;
|
|
737
749
|
readonly frequency_penalty?: number | undefined;
|
|
738
750
|
readonly presence_penalty?: number | undefined;
|
|
739
751
|
}, string>;
|
|
@@ -803,11 +815,12 @@ export declare const route: Route<{
|
|
|
803
815
|
readonly max_tokens?: number | undefined;
|
|
804
816
|
readonly tools?: readonly {
|
|
805
817
|
readonly function: {
|
|
806
|
-
readonly name: string;
|
|
807
818
|
readonly description: string;
|
|
819
|
+
readonly name: string;
|
|
808
820
|
readonly parameters: {
|
|
809
821
|
readonly [x: string]: unknown;
|
|
810
822
|
};
|
|
823
|
+
readonly strict?: boolean | undefined;
|
|
811
824
|
};
|
|
812
825
|
readonly type: "function";
|
|
813
826
|
readonly cache_control?: {
|
|
@@ -831,6 +844,7 @@ export declare const route: Route<{
|
|
|
831
844
|
} | undefined;
|
|
832
845
|
readonly prompt_cache_key?: string | undefined;
|
|
833
846
|
readonly reasoning_effort?: import("./utils/open-responses-options.js").ReasoningEffort | undefined;
|
|
847
|
+
readonly tool_stream?: boolean | undefined;
|
|
834
848
|
readonly frequency_penalty?: number | undefined;
|
|
835
849
|
readonly presence_penalty?: number | undefined;
|
|
836
850
|
}, HttpTransport.HttpPrepared<string>>;
|