@opencode/ai 0.0.0-dev-482 → 0.0.0-dev-491
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/effect.d.ts +1 -12
- package/dist/effect.js +1 -5
- package/dist/effort-updates.d.ts +2 -2
- package/dist/image-client.d.ts +4 -4
- package/dist/index.d.ts +1 -12
- package/dist/index.js +1 -5
- package/dist/protocols/alibaba-responses.js +8 -20
- package/dist/protocols/meta-responses.js +1 -1
- package/dist/protocols/open-responses.js +1 -3
- package/dist/protocols/openai-compatible-chat.d.ts +1 -1
- package/dist/protocols/openai-compatible-responses.d.ts +2 -2
- package/dist/protocols/openai-responses.js +8 -26
- package/dist/protocols/utils/image-sizing.d.ts +1 -1
- package/dist/protocols/utils/responses-hosted-tools.d.ts +97 -1
- package/dist/protocols/utils/responses-hosted-tools.js +31 -0
- package/dist/protocols/utils/tool-stream.d.ts +3 -209
- package/dist/protocols/utils/tool-stream.js +3 -13
- package/dist/protocols/xai-responses.js +4 -24
- package/dist/providers/baseten.js +3 -11
- package/dist/providers/cerebras.js +2 -7
- package/dist/providers/cohere/chat.js +2 -7
- package/dist/providers/cohere.js +2 -7
- package/dist/providers/deepinfra.js +2 -7
- package/dist/providers/deepseek.js +2 -7
- package/dist/providers/fireworks.js +2 -7
- package/dist/providers/google/interactions.js +2 -7
- package/dist/providers/google.js +3 -11
- package/dist/providers/groq.js +2 -7
- package/dist/providers/meta.js +5 -13
- package/dist/providers/minimax/chat.js +2 -7
- package/dist/providers/minimax/responses.js +2 -7
- package/dist/providers/minimax.js +3 -11
- package/dist/providers/mistral.js +2 -7
- package/dist/providers/moonshot/messages.js +2 -7
- package/dist/providers/moonshot/responses.js +2 -7
- package/dist/providers/moonshot.js +2 -7
- package/dist/providers/openai-compatible-responses.js +2 -8
- package/dist/providers/openai-compatible.js +3 -9
- package/dist/providers/opencode.d.ts +1 -1
- package/dist/providers/opencode.js +5 -1
- package/dist/providers/openrouter.js +5 -13
- package/dist/providers/settings.d.ts +19 -0
- package/dist/providers/settings.js +9 -0
- package/dist/providers/togetherai.js +2 -7
- package/dist/providers/typesafe-ai.d.ts +1 -1
- package/dist/providers/typesafe-ai.js +5 -1
- package/dist/providers/vercel-ai-gateway.js +7 -15
- package/dist/providers/xai.js +3 -11
- package/dist/providers/zai-coding-plan/messages.js +2 -7
- package/dist/providers/zai-coding-plan/responses.js +2 -7
- package/dist/providers/zai-coding-plan.js +2 -7
- package/dist/providers/zai.js +3 -11
- package/dist/public.d.ts +12 -0
- package/dist/public.js +5 -0
- package/dist/speech-client.d.ts +4 -4
- package/dist/transcription-client.d.ts +4 -4
- package/dist/video-client.d.ts +4 -4
- package/package.json +3 -3
package/dist/effect.d.ts
CHANGED
|
@@ -47,22 +47,11 @@ export { LLMClient } from "./route/client.js";
|
|
|
47
47
|
export { ImageClient } from "./image-client.js";
|
|
48
48
|
export { Auth } from "./route/auth.js";
|
|
49
49
|
export { ProviderPackage } from "./provider-package.js";
|
|
50
|
-
export { isContextOverflow, isContextOverflowFailure, isRetryable } from "./provider-error.js";
|
|
51
50
|
export type { LLMClientService } from "./route/client.js";
|
|
52
|
-
export { ProtocolID, RouteID, ModelID, ProviderID, ResponseID, ContentBlockID, ToolCallID, JsonSchema, ProviderOptions, ProviderMetadata, HttpTimeout, RequestEncoding, HttpOptions, GenerationOptions, LanguageModelDefaults, ReasoningEfforts, ReasoningEffort, LanguageModelCompatibility, LanguageModel, LanguageModelSchema, CacheTTL, CacheHint, CachePolicyObject, CachePolicy, MessageRole, SystemPart, TextPart, MediaPart, ToolResultValue, ToolOutput, ToolCallPart, ToolResultPart, ReasoningPart, CompactionPart, EffortPart, ContentPart, Message, Freeform, ToolDefinition, ToolNamespace, ToolEntry, ToolChoice, FinishReason, Usage, MediaUsage, CompactionResponse, CompactionCheckpointResponse, StepStart, TextStart, TextDelta, TextEnd, ReasoningStart, ReasoningDelta, ReasoningEnd, ToolInputStart, ToolInputDelta, ToolInputEnd, ToolInputError, ToolCall, ToolResult, FinishReasonDetails, StepFinish, Finish, MediaEvent, RawEvent, LLMEvent, LLMResponse, HttpContext, HttpRateLimitDetails, InvalidRequestError, UnsupportedOperationError, ProviderConfigurationError, AuthenticationError, RateLimitError, QuotaExceededError, ContentPolicyError, ProviderInternalError, TransportType, TransportOperation, TransportError, InvalidProviderOutputError, UnknownProviderError, TimeoutError, AIErrorReason, AIError, } from "./schema/index.js";
|
|
53
|
-
export type { GenerationOptionsFields, GenerationOptionsInput, LanguageModelInput, LanguageModelProviderOptions, LLMRequest, ToolDefinitionInput, ToolNamespaceInput, ToolNamespaceEntryInput, ToolEntryInput, UsageInput, } from "./schema/index.js";
|
|
54
|
-
export { ImageAspectRatio, ImageEvent, ImageModel, ImageModelSchema, ImageResponse } from "./image.js";
|
|
55
|
-
export type { ImageModelOptions, ImageOptions, ImageRequest, ImageRequestInput, ImageResolution, ImageRoute, } from "./image.js";
|
|
56
51
|
export { DecisionClient } from "./decision-client.js";
|
|
57
|
-
export { ChoiceAnswer, ChoiceQuestion, ChoiceValue, DecisionAnswer, DecisionJsonPart, DecisionMediaPart, DecisionModel, DecisionModelCompatibility, DecisionModelSchema, DecisionPart, DecisionQuestion, DecisionResponse, DecisionTextPart, DecisionUsage, ErrorAnswer, ErrorReason, PredicateAnswer, PredicateQuestion, ScoreAnswer, ScoreQuestion, } from "./decision.js";
|
|
58
|
-
export type { AnswerFor, AnswersFor, DecisionInput, DecisionModelOptions, DecisionOptions, DecisionQuestions, DecisionRequest, DecisionRequestInput, DecisionResponseFor, DecisionModelRoute, } from "./decision.js";
|
|
59
52
|
export { DecisionRoute } from "./route/decision.js";
|
|
60
|
-
export { Media } from "./media.js";
|
|
61
53
|
export { Generation } from "./generation.js";
|
|
62
|
-
export type { AwaitOptions as GenerationAwaitOptions, Event as GenerationEvent, Poll, Route as GenerationRoute, Snapshot as GenerationSnapshot, Status as GenerationStatus, } from "./generation.js";
|
|
63
54
|
export { ToolFailure, emptyInputJsonSchema, toDefinitions, tool } from "./tool.js";
|
|
64
55
|
export { ToolRuntime } from "./tool-runtime.js";
|
|
65
56
|
export type { ToolSettlement } from "./tool-runtime.js";
|
|
66
|
-
export
|
|
67
|
-
export type { LLM } from "./llm.js";
|
|
68
|
-
export type { LLMLoopInput, LLMRequestInput } from "./llm.js";
|
|
57
|
+
export * from "./public.js";
|
package/dist/effect.js
CHANGED
|
@@ -27,13 +27,9 @@ export { LLMClient } from "./route/client.js";
|
|
|
27
27
|
export { ImageClient } from "./image-client.js";
|
|
28
28
|
export { Auth } from "./route/auth.js";
|
|
29
29
|
export { ProviderPackage } from "./provider-package.js";
|
|
30
|
-
export { isContextOverflow, isContextOverflowFailure, isRetryable } from "./provider-error.js";
|
|
31
|
-
export { ProtocolID, RouteID, ModelID, ProviderID, ResponseID, ContentBlockID, ToolCallID, JsonSchema, ProviderOptions, ProviderMetadata, HttpTimeout, RequestEncoding, HttpOptions, GenerationOptions, LanguageModelDefaults, ReasoningEfforts, ReasoningEffort, LanguageModelCompatibility, LanguageModel, LanguageModelSchema, CacheTTL, CacheHint, CachePolicyObject, CachePolicy, MessageRole, SystemPart, TextPart, MediaPart, ToolResultValue, ToolOutput, ToolCallPart, ToolResultPart, ReasoningPart, CompactionPart, EffortPart, ContentPart, Message, Freeform, ToolDefinition, ToolNamespace, ToolEntry, ToolChoice, FinishReason, Usage, MediaUsage, CompactionResponse, CompactionCheckpointResponse, StepStart, TextStart, TextDelta, TextEnd, ReasoningStart, ReasoningDelta, ReasoningEnd, ToolInputStart, ToolInputDelta, ToolInputEnd, ToolInputError, ToolCall, ToolResult, FinishReasonDetails, StepFinish, Finish, MediaEvent, RawEvent, LLMEvent, LLMResponse, HttpContext, HttpRateLimitDetails, InvalidRequestError, UnsupportedOperationError, ProviderConfigurationError, AuthenticationError, RateLimitError, QuotaExceededError, ContentPolicyError, ProviderInternalError, TransportType, TransportOperation, TransportError, InvalidProviderOutputError, UnknownProviderError, TimeoutError, AIErrorReason, AIError, } from "./schema/index.js";
|
|
32
|
-
export { ImageAspectRatio, ImageEvent, ImageModel, ImageModelSchema, ImageResponse } from "./image.js";
|
|
33
30
|
export { DecisionClient } from "./decision-client.js";
|
|
34
|
-
export { ChoiceAnswer, ChoiceQuestion, ChoiceValue, DecisionAnswer, DecisionJsonPart, DecisionMediaPart, DecisionModel, DecisionModelCompatibility, DecisionModelSchema, DecisionPart, DecisionQuestion, DecisionResponse, DecisionTextPart, DecisionUsage, ErrorAnswer, ErrorReason, PredicateAnswer, PredicateQuestion, ScoreAnswer, ScoreQuestion, } from "./decision.js";
|
|
35
31
|
export { DecisionRoute } from "./route/decision.js";
|
|
36
|
-
export { Media } from "./media.js";
|
|
37
32
|
export { Generation } from "./generation.js";
|
|
38
33
|
export { ToolFailure, emptyInputJsonSchema, toDefinitions, tool } from "./tool.js";
|
|
39
34
|
export { ToolRuntime } from "./tool-runtime.js";
|
|
35
|
+
export * from "./public.js";
|
package/dist/effort-updates.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { type LLMRequest, type EffortPart, type Message } from "./schema/messages.js";
|
|
2
2
|
export declare const effortUpdate: (message: Message) => EffortPart | undefined;
|
|
3
|
-
export declare const stripEffortUpdates: (request: LLMRequest) => LLMRequest<import("./
|
|
3
|
+
export declare const stripEffortUpdates: (request: LLMRequest) => LLMRequest<import("./public.js").LanguageModel<{
|
|
4
4
|
readonly [x: string]: unknown;
|
|
5
5
|
}, import("./route.js").CompactionOperations | undefined>>;
|
|
6
6
|
export declare const applyEffortUpdates: (request: LLMRequest) => LLMRequest;
|
|
7
7
|
export declare const resolveEffortUpdates: (request: LLMRequest, current: string | undefined) => {
|
|
8
|
-
request: LLMRequest<import("./
|
|
8
|
+
request: LLMRequest<import("./public.js").LanguageModel<{
|
|
9
9
|
readonly [x: string]: unknown;
|
|
10
10
|
}, import("./route.js").CompactionOperations | undefined>>;
|
|
11
11
|
effort: string | undefined;
|
package/dist/image-client.d.ts
CHANGED
|
@@ -56,7 +56,7 @@ export declare const ImageClient: {
|
|
|
56
56
|
readonly layer: import("effect/Layer").Layer<ImageClientService, never, import("./route.js").RequestExecutorService>;
|
|
57
57
|
readonly generate: (request: ImageRequest<import("./image.js").ImageModel<{
|
|
58
58
|
readonly [x: string]: unknown;
|
|
59
|
-
}>>, options?: import("./generation.js").AwaitOptions) => import("effect/Effect").Effect<ImageResponse, import("./
|
|
59
|
+
}>>, options?: import("./generation.js").AwaitOptions) => import("effect/Effect").Effect<ImageResponse, import("./public.js").AIError, ImageClientService>;
|
|
60
60
|
readonly stream: (request: ImageRequest<import("./image.js").ImageModel<{
|
|
61
61
|
readonly [x: string]: unknown;
|
|
62
62
|
}>>, options?: import("./generation.js").AwaitOptions) => import("effect/Stream").Stream<{
|
|
@@ -95,13 +95,13 @@ export declare const ImageClient: {
|
|
|
95
95
|
readonly [x: string]: unknown;
|
|
96
96
|
};
|
|
97
97
|
} | undefined;
|
|
98
|
-
} | import("./generation.js").Observation, import("./
|
|
98
|
+
} | import("./generation.js").Observation, import("./public.js").AIError, ImageClientService>;
|
|
99
99
|
readonly start: (request: ImageRequest<import("./image.js").ImageModel<{
|
|
100
100
|
readonly [x: string]: unknown;
|
|
101
|
-
}>>) => import("effect/Effect").Effect<import("./generation.js").Generation<ImageResponse>, import("./
|
|
101
|
+
}>>) => import("effect/Effect").Effect<import("./generation.js").Generation<ImageResponse>, import("./public.js").AIError, ImageClientService>;
|
|
102
102
|
readonly resume: (model: import("./image.js").ImageModel<{
|
|
103
103
|
readonly [x: string]: unknown;
|
|
104
|
-
}>, token: unknown) => import("effect/Effect").Effect<import("./generation.js").Generation<ImageResponse>, import("./
|
|
104
|
+
}>, token: unknown) => import("effect/Effect").Effect<import("./generation.js").Generation<ImageResponse>, import("./public.js").AIError, ImageClientService>;
|
|
105
105
|
readonly Service: typeof ImageClientService;
|
|
106
106
|
};
|
|
107
107
|
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -318,15 +318,4 @@ export declare const tool: <Input extends ToolInput = typeof Schema.Unknown, Suc
|
|
|
318
318
|
/** Default client over `RequestExecutor.fetchLayer`; the runtime builds its layer on first use and holds nothing to dispose. */
|
|
319
319
|
export declare const ai: Omit<Client, "dispose">;
|
|
320
320
|
export * as AI from "./index.js";
|
|
321
|
-
export
|
|
322
|
-
export { ProtocolID, RouteID, ModelID, ProviderID, ResponseID, ContentBlockID, ToolCallID, JsonSchema, ProviderOptions, ProviderMetadata, HttpTimeout, RequestEncoding, HttpOptions, GenerationOptions, LanguageModelDefaults, ReasoningEfforts, ReasoningEffort, LanguageModelCompatibility, LanguageModel, LanguageModelSchema, CacheTTL, CacheHint, CachePolicyObject, CachePolicy, MessageRole, SystemPart, TextPart, MediaPart, ToolResultValue, ToolOutput, ToolCallPart, ToolResultPart, ReasoningPart, CompactionPart, EffortPart, ContentPart, Message, Freeform, ToolDefinition, ToolNamespace, ToolEntry, ToolChoice, FinishReason, Usage, MediaUsage, CompactionResponse, CompactionCheckpointResponse, StepStart, TextStart, TextDelta, TextEnd, ReasoningStart, ReasoningDelta, ReasoningEnd, ToolInputStart, ToolInputDelta, ToolInputEnd, ToolInputError, ToolCall, ToolResult, FinishReasonDetails, StepFinish, Finish, MediaEvent, RawEvent, LLMEvent, LLMResponse, HttpContext, HttpRateLimitDetails, InvalidRequestError, UnsupportedOperationError, ProviderConfigurationError, AuthenticationError, RateLimitError, QuotaExceededError, ContentPolicyError, ProviderInternalError, TransportType, TransportOperation, TransportError, InvalidProviderOutputError, UnknownProviderError, TimeoutError, AIErrorReason, AIError, } from "./schema/index.js";
|
|
323
|
-
export type { GenerationOptionsFields, GenerationOptionsInput, LanguageModelInput, LanguageModelProviderOptions, LLMRequest, ToolDefinitionInput, ToolNamespaceInput, ToolNamespaceEntryInput, ToolEntryInput, UsageInput, } from "./schema/index.js";
|
|
324
|
-
export { ImageAspectRatio, ImageEvent, ImageModel, ImageModelSchema, ImageResponse } from "./image.js";
|
|
325
|
-
export type { ImageModelOptions, ImageOptions, ImageRequest, ImageRequestInput, ImageResolution, ImageRoute, } from "./image.js";
|
|
326
|
-
export { ChoiceAnswer, ChoiceQuestion, ChoiceValue, DecisionAnswer, DecisionJsonPart, DecisionMediaPart, DecisionModel, DecisionModelCompatibility, DecisionModelSchema, DecisionPart, DecisionQuestion, DecisionResponse, DecisionTextPart, DecisionUsage, ErrorAnswer, ErrorReason, PredicateAnswer, PredicateQuestion, ScoreAnswer, ScoreQuestion, } from "./decision.js";
|
|
327
|
-
export type { AnswerFor, AnswersFor, DecisionInput, DecisionModelOptions, DecisionOptions, DecisionQuestions, DecisionRequest, DecisionRequestInput, DecisionResponseFor, DecisionModelRoute, } from "./decision.js";
|
|
328
|
-
export { Media } from "./media.js";
|
|
329
|
-
export type { AwaitOptions as GenerationAwaitOptions, Event as GenerationEvent, Poll, Route as GenerationRoute, Snapshot as GenerationSnapshot, Status as GenerationStatus, } from "./generation.js";
|
|
330
|
-
export type { ExecutableTool, Tool, ToolExecute, ToolExecuteContext, ToolInput, ToolInputType, ToolModelOutputInput, ToolOptions, ToolSchema, ToolToModelOutput, } from "./tool.js";
|
|
331
|
-
export type { LLM } from "./llm.js";
|
|
332
|
-
export type { LLMLoopInput, LLMRequestInput } from "./llm.js";
|
|
321
|
+
export * from "./public.js";
|
package/dist/index.js
CHANGED
|
@@ -141,8 +141,4 @@ export const tool = (config) => {
|
|
|
141
141
|
/** Default client over `RequestExecutor.fetchLayer`; the runtime builds its layer on first use and holds nothing to dispose. */
|
|
142
142
|
export const ai = make();
|
|
143
143
|
export * as AI from "./index.js";
|
|
144
|
-
export
|
|
145
|
-
export { ProtocolID, RouteID, ModelID, ProviderID, ResponseID, ContentBlockID, ToolCallID, JsonSchema, ProviderOptions, ProviderMetadata, HttpTimeout, RequestEncoding, HttpOptions, GenerationOptions, LanguageModelDefaults, ReasoningEfforts, ReasoningEffort, LanguageModelCompatibility, LanguageModel, LanguageModelSchema, CacheTTL, CacheHint, CachePolicyObject, CachePolicy, MessageRole, SystemPart, TextPart, MediaPart, ToolResultValue, ToolOutput, ToolCallPart, ToolResultPart, ReasoningPart, CompactionPart, EffortPart, ContentPart, Message, Freeform, ToolDefinition, ToolNamespace, ToolEntry, ToolChoice, FinishReason, Usage, MediaUsage, CompactionResponse, CompactionCheckpointResponse, StepStart, TextStart, TextDelta, TextEnd, ReasoningStart, ReasoningDelta, ReasoningEnd, ToolInputStart, ToolInputDelta, ToolInputEnd, ToolInputError, ToolCall, ToolResult, FinishReasonDetails, StepFinish, Finish, MediaEvent, RawEvent, LLMEvent, LLMResponse, HttpContext, HttpRateLimitDetails, InvalidRequestError, UnsupportedOperationError, ProviderConfigurationError, AuthenticationError, RateLimitError, QuotaExceededError, ContentPolicyError, ProviderInternalError, TransportType, TransportOperation, TransportError, InvalidProviderOutputError, UnknownProviderError, TimeoutError, AIErrorReason, AIError, } from "./schema/index.js";
|
|
146
|
-
export { ImageAspectRatio, ImageEvent, ImageModel, ImageModelSchema, ImageResponse } from "./image.js";
|
|
147
|
-
export { ChoiceAnswer, ChoiceQuestion, ChoiceValue, DecisionAnswer, DecisionJsonPart, DecisionMediaPart, DecisionModel, DecisionModelCompatibility, DecisionModelSchema, DecisionPart, DecisionQuestion, DecisionResponse, DecisionTextPart, DecisionUsage, ErrorAnswer, ErrorReason, PredicateAnswer, PredicateQuestion, ScoreAnswer, ScoreQuestion, } from "./decision.js";
|
|
148
|
-
export { Media } from "./media.js";
|
|
144
|
+
export * from "./public.js";
|
|
@@ -32,7 +32,7 @@ const adapter = {
|
|
|
32
32
|
restoreHostedToolItem: (item) => (Schema.is(WebExtractorItem)(item) ? item : undefined),
|
|
33
33
|
};
|
|
34
34
|
const tools = {
|
|
35
|
-
web_search_call:
|
|
35
|
+
web_search_call: ResponsesHostedTools.common.web_search_call,
|
|
36
36
|
code_interpreter_call: { name: "code_interpreter", input: (item) => ({ code: item.code }) },
|
|
37
37
|
};
|
|
38
38
|
export const protocol = Protocol.make({
|
|
@@ -55,24 +55,12 @@ export const protocol = Protocol.make({
|
|
|
55
55
|
};
|
|
56
56
|
}),
|
|
57
57
|
},
|
|
58
|
-
stream: {
|
|
59
|
-
event
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (event.item.type === "web_extractor_call") {
|
|
66
|
-
const item = yield* Schema.decodeUnknownEffect(WebExtractorItem)(event.item).pipe(Effect.mapError((cause) => ProviderShared.eventError(adapter.id, "Alibaba returned an invalid web extraction item", ProviderShared.encodeJson(event), cause)));
|
|
67
|
-
return yield* ResponsesHostedTools.onDone(state, item, {
|
|
68
|
-
web_extractor_call: { name: "web_extractor", input: () => ({ urls: item.urls, goal: item.goal }) },
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
if (ResponsesHostedTools.isItem(event.item, tools))
|
|
72
|
-
return yield* ResponsesHostedTools.onDone(state, event.item, tools);
|
|
73
|
-
return yield* OpenResponses.step(state, event);
|
|
74
|
-
}),
|
|
75
|
-
terminal: OpenResponses.terminal,
|
|
76
|
-
},
|
|
58
|
+
stream: ResponsesHostedTools.stream(adapter, tools, (state, event) => {
|
|
59
|
+
if (event.type !== "response.output_item.done" || event.item?.type !== "web_extractor_call")
|
|
60
|
+
return undefined;
|
|
61
|
+
return Schema.decodeUnknownEffect(WebExtractorItem)(event.item).pipe(Effect.mapError((cause) => ProviderShared.eventError(adapter.id, "Alibaba returned an invalid web extraction item", ProviderShared.encodeJson(event), cause)), Effect.flatMap((item) => ResponsesHostedTools.onDone(state, item, {
|
|
62
|
+
web_extractor_call: { name: "web_extractor", input: () => ({ urls: item.urls, goal: item.goal }) },
|
|
63
|
+
})));
|
|
64
|
+
}),
|
|
77
65
|
});
|
|
78
66
|
export * as AlibabaResponses from "./alibaba-responses.js";
|
|
@@ -100,7 +100,7 @@ const fromRequest = Effect.fn("MetaResponses.fromRequest")(function* (request) {
|
|
|
100
100
|
// Hosted replay items have an open `type`, so a plain tag check does not narrow the union.
|
|
101
101
|
const isFunctionCallOutput = (item) => item.type === "function_call_output" || item.type === "custom_tool_call_output";
|
|
102
102
|
const HOSTED_TOOLS = {
|
|
103
|
-
web_search_call:
|
|
103
|
+
web_search_call: ResponsesHostedTools.common.web_search_call,
|
|
104
104
|
image_generation_call: {
|
|
105
105
|
name: "image_generation",
|
|
106
106
|
input: () => ({}),
|
|
@@ -1036,9 +1036,7 @@ const onOutputItemDone = Effect.fnUntraced(function* (state, item) {
|
|
|
1036
1036
|
namespace: item.namespace,
|
|
1037
1037
|
providerMetadata: metadata,
|
|
1038
1038
|
});
|
|
1039
|
-
const result =
|
|
1040
|
-
? yield* ToolStream.finish(state.id, tools, item.id)
|
|
1041
|
-
: yield* ToolStream.finishWithInput(state.id, tools, item.id, input);
|
|
1039
|
+
const result = yield* ToolStream.finish(state.id, tools, item.id, input);
|
|
1042
1040
|
const events = [];
|
|
1043
1041
|
const finished = [...(closed?.events ?? []), ...(result.events ?? [])];
|
|
1044
1042
|
// A done-only call never streamed a start event, so open its lifecycle here.
|
|
@@ -162,7 +162,7 @@ export declare const route: Route<{
|
|
|
162
162
|
readonly prompt_cache_options?: {
|
|
163
163
|
readonly ttl?: string | undefined;
|
|
164
164
|
} | undefined;
|
|
165
|
-
readonly reasoning_effort?: import("../
|
|
165
|
+
readonly reasoning_effort?: import("../public.js").ReasoningEffort | undefined;
|
|
166
166
|
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
167
167
|
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
168
168
|
readonly parallel_tool_calls?: boolean | undefined;
|
|
@@ -9,7 +9,7 @@ export declare const route: Route<{
|
|
|
9
9
|
readonly input: readonly ({
|
|
10
10
|
readonly type: "configuration_update";
|
|
11
11
|
readonly reasoning: {
|
|
12
|
-
readonly effort: import("../
|
|
12
|
+
readonly effort: import("../public.js").ReasoningEffort;
|
|
13
13
|
};
|
|
14
14
|
} | {
|
|
15
15
|
readonly type: "message";
|
|
@@ -187,7 +187,7 @@ export declare const route: Route<{
|
|
|
187
187
|
readonly prompt_cache_key?: string | undefined;
|
|
188
188
|
readonly include?: readonly import("../schema/options.js").OpenString<"code_interpreter_call.outputs" | "computer_call_output.output.image_url" | "file_search_call.results" | "message.input_image.image_url" | "message.output_text.logprobs" | "reasoning.encrypted_content" | "web_search_call.action.sources" | "web_search_call.results">[] | undefined;
|
|
189
189
|
readonly reasoning?: {
|
|
190
|
-
readonly effort?: import("../
|
|
190
|
+
readonly effort?: import("../public.js").ReasoningEffort | undefined;
|
|
191
191
|
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
192
192
|
} | undefined;
|
|
193
193
|
readonly text?: {
|
|
@@ -249,29 +249,10 @@ const hostedToolResult = Effect.fnUntraced(function* (item) {
|
|
|
249
249
|
return isError ? { type: "error", value: item.error } : { type: "json", value: item };
|
|
250
250
|
});
|
|
251
251
|
const HOSTED_TOOLS = {
|
|
252
|
-
|
|
252
|
+
...ResponsesHostedTools.common,
|
|
253
253
|
web_search_preview_call: { name: "web_search_preview", input: (item) => item.action ?? {} },
|
|
254
|
-
file_search_call: { name: "file_search", input: (item) => ({ queries: item.queries ?? [] }) },
|
|
255
|
-
code_interpreter_call: {
|
|
256
|
-
name: "code_interpreter",
|
|
257
|
-
input: (item) => ({ code: item.code, container_id: item.container_id }),
|
|
258
|
-
},
|
|
259
254
|
computer_call: { name: "computer_use", input: (item) => item.action ?? {} },
|
|
260
255
|
image_generation_call: { name: "image_generation", input: () => ({}), result: hostedToolResult },
|
|
261
|
-
mcp_call: {
|
|
262
|
-
name: "mcp",
|
|
263
|
-
input: (item) => ({ server_label: item.server_label, name: item.name, arguments: item.arguments }),
|
|
264
|
-
},
|
|
265
|
-
};
|
|
266
|
-
const step = (state, input) => {
|
|
267
|
-
const event = OpenResponses.normalize(state, input);
|
|
268
|
-
if (event.type === "response.reasoning_text.delta")
|
|
269
|
-
return event.item_id !== undefined
|
|
270
|
-
? Effect.succeed(OpenResponses.onReasoningDelta(state, event, event.item_id))
|
|
271
|
-
: ProviderShared.eventError(ADAPTER, `${event.type} is missing item_id`);
|
|
272
|
-
if (event.type === "response.output_item.done" && event.item && ResponsesHostedTools.isItem(event.item, HOSTED_TOOLS))
|
|
273
|
-
return ResponsesHostedTools.onDone(state, event.item, HOSTED_TOOLS);
|
|
274
|
-
return OpenResponses.step(state, event);
|
|
275
256
|
};
|
|
276
257
|
export const protocol = Protocol.make({
|
|
277
258
|
id: ADAPTER,
|
|
@@ -279,12 +260,13 @@ export const protocol = Protocol.make({
|
|
|
279
260
|
schema: OpenAIResponsesBody,
|
|
280
261
|
from: fromRequest,
|
|
281
262
|
},
|
|
282
|
-
stream: {
|
|
283
|
-
event
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
263
|
+
stream: ResponsesHostedTools.stream(adapter, HOSTED_TOOLS, (state, event) => {
|
|
264
|
+
if (event.type !== "response.reasoning_text.delta")
|
|
265
|
+
return undefined;
|
|
266
|
+
return event.item_id !== undefined
|
|
267
|
+
? Effect.succeed(OpenResponses.onReasoningDelta(state, event, event.item_id))
|
|
268
|
+
: ProviderShared.eventError(ADAPTER, `${event.type} is missing item_id`);
|
|
269
|
+
}),
|
|
288
270
|
supportsEffortUpdates,
|
|
289
271
|
});
|
|
290
272
|
const endpoint = Endpoint.path(PATH, { baseURL: DEFAULT_BASE_URL });
|
|
@@ -27,5 +27,5 @@ export declare const fit: (shape: Shape, limits: Limits) => Size;
|
|
|
27
27
|
/** The listed size closest to the shape: nearest aspect ratio first, then nearest pixel count. */
|
|
28
28
|
export declare const nearest: (shape: Shape, sizes: ReadonlyArray<Size>) => Size;
|
|
29
29
|
/** Free width and height that must honor the shape; a size that misses it fails. */
|
|
30
|
-
export declare const exact: (route: MediaProtocol.Identity, shape: Shape, limits: Limits) => Effect.Effect<undefined, never, never> | Effect.Effect<never, import("../../
|
|
30
|
+
export declare const exact: (route: MediaProtocol.Identity, shape: Shape, limits: Limits) => Effect.Effect<undefined, never, never> | Effect.Effect<never, import("../../public.js").AIError, never> | Effect.Effect<Size, never, never>;
|
|
31
31
|
export * as ImageSizing from "./image-sizing.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
-
import { type AIError, type ToolResultPart } from "../../schema/index.js";
|
|
2
|
+
import { type AIError, type LLMRequest, type ToolResultPart } from "../../schema/index.js";
|
|
3
3
|
import { OpenResponses } from "../open-responses.js";
|
|
4
4
|
export type Item = OpenResponses.OutputItem & {
|
|
5
5
|
readonly status?: string;
|
|
@@ -21,6 +21,102 @@ export interface Definition {
|
|
|
21
21
|
readonly result?: (item: Item) => Effect.Effect<ToolResultPart["result"], AIError>;
|
|
22
22
|
}
|
|
23
23
|
export type Definitions = Readonly<Record<string, Definition>>;
|
|
24
|
+
/** Hosted tools that several Responses providers report with the same item shape. */
|
|
25
|
+
export declare const common: {
|
|
26
|
+
readonly web_search_call: {
|
|
27
|
+
readonly name: "web_search";
|
|
28
|
+
readonly input: (item: Item) => {};
|
|
29
|
+
};
|
|
30
|
+
readonly file_search_call: {
|
|
31
|
+
readonly name: "file_search";
|
|
32
|
+
readonly input: (item: Item) => {
|
|
33
|
+
queries: {};
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
readonly code_interpreter_call: {
|
|
37
|
+
readonly name: "code_interpreter";
|
|
38
|
+
readonly input: (item: Item) => {
|
|
39
|
+
code: string | undefined;
|
|
40
|
+
container_id: string | undefined;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
readonly mcp_call: {
|
|
44
|
+
readonly name: "mcp";
|
|
45
|
+
readonly input: (item: Item) => {
|
|
46
|
+
server_label: string | undefined;
|
|
47
|
+
name: string | undefined;
|
|
48
|
+
arguments: string | undefined;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
};
|
|
24
52
|
export declare const isItem: <Tools extends Definitions>(item: OpenResponses.OutputItem, tools: Tools) => item is Item;
|
|
53
|
+
/**
|
|
54
|
+
* Responses stream that turns completed hosted tool items into a provider-executed
|
|
55
|
+
* tool call and result. `override` sees each normalized event first and may handle it.
|
|
56
|
+
*/
|
|
57
|
+
export declare const stream: (adapter: OpenResponses.ProviderAdapter, tools: Definitions, override?: (state: OpenResponses.ParserState, event: OpenResponses.NormalizedEvent) => Effect.Effect<OpenResponses.StepResult, AIError> | undefined) => {
|
|
58
|
+
event: import("effect/Schema").Codec<{
|
|
59
|
+
readonly [x: string]: unknown;
|
|
60
|
+
readonly type: string;
|
|
61
|
+
readonly delta?: string | undefined;
|
|
62
|
+
readonly arguments?: string | undefined;
|
|
63
|
+
readonly text?: string | undefined;
|
|
64
|
+
readonly item_id?: string | undefined;
|
|
65
|
+
readonly output_index?: number | undefined;
|
|
66
|
+
readonly summary_index?: number | undefined;
|
|
67
|
+
readonly item?: {
|
|
68
|
+
readonly [x: string]: unknown;
|
|
69
|
+
readonly type: string;
|
|
70
|
+
readonly id?: string | undefined;
|
|
71
|
+
readonly call_id?: string | undefined;
|
|
72
|
+
readonly name?: string | undefined;
|
|
73
|
+
readonly namespace?: string | undefined;
|
|
74
|
+
readonly arguments?: string | undefined;
|
|
75
|
+
readonly encrypted_content?: string | null | undefined;
|
|
76
|
+
} | null | undefined;
|
|
77
|
+
readonly response?: {
|
|
78
|
+
readonly [x: string]: unknown;
|
|
79
|
+
readonly id?: string | undefined;
|
|
80
|
+
readonly service_tier?: string | null | undefined;
|
|
81
|
+
readonly incomplete_details?: {
|
|
82
|
+
readonly reason?: string | undefined;
|
|
83
|
+
} | null | undefined;
|
|
84
|
+
readonly output?: readonly {
|
|
85
|
+
readonly [x: string]: unknown;
|
|
86
|
+
readonly type: string;
|
|
87
|
+
readonly id?: string | undefined;
|
|
88
|
+
readonly call_id?: string | undefined;
|
|
89
|
+
readonly name?: string | undefined;
|
|
90
|
+
readonly namespace?: string | undefined;
|
|
91
|
+
readonly arguments?: string | undefined;
|
|
92
|
+
readonly encrypted_content?: string | null | undefined;
|
|
93
|
+
}[] | undefined;
|
|
94
|
+
readonly usage?: {
|
|
95
|
+
readonly [x: string]: unknown;
|
|
96
|
+
readonly input_tokens?: number | undefined;
|
|
97
|
+
readonly input_tokens_details?: {
|
|
98
|
+
readonly [x: string]: unknown;
|
|
99
|
+
readonly cached_tokens?: number | undefined;
|
|
100
|
+
readonly cache_write_tokens?: number | undefined;
|
|
101
|
+
} | null | undefined;
|
|
102
|
+
readonly output_tokens?: number | undefined;
|
|
103
|
+
readonly output_tokens_details?: {
|
|
104
|
+
readonly [x: string]: unknown;
|
|
105
|
+
readonly reasoning_tokens?: number | undefined;
|
|
106
|
+
} | null | undefined;
|
|
107
|
+
readonly total_tokens?: number | undefined;
|
|
108
|
+
} | null | undefined;
|
|
109
|
+
readonly error?: unknown;
|
|
110
|
+
} | undefined;
|
|
111
|
+
readonly code?: unknown;
|
|
112
|
+
readonly message?: unknown;
|
|
113
|
+
readonly error?: unknown;
|
|
114
|
+
readonly status?: unknown;
|
|
115
|
+
readonly status_code?: unknown;
|
|
116
|
+
}, string, never, never>;
|
|
117
|
+
initial: (request: LLMRequest) => OpenResponses.ParserState;
|
|
118
|
+
step: (state: OpenResponses.ParserState, input: OpenResponses.Event) => AIError | Effect.Effect<OpenResponses.StepResult, AIError, never>;
|
|
119
|
+
terminal: typeof OpenResponses.terminal;
|
|
120
|
+
};
|
|
25
121
|
export declare const onDone: (state: OpenResponses.ParserState, item: Item, tools: Definitions) => Effect.Effect<OpenResponses.StepResult, AIError>;
|
|
26
122
|
export * as ResponsesHostedTools from "./responses-hosted-tools.js";
|
|
@@ -2,7 +2,38 @@ import { Effect } from "effect";
|
|
|
2
2
|
import { LLMEvent } from "../../schema/index.js";
|
|
3
3
|
import { OpenResponses } from "../open-responses.js";
|
|
4
4
|
import { Lifecycle } from "./lifecycle.js";
|
|
5
|
+
/** Hosted tools that several Responses providers report with the same item shape. */
|
|
6
|
+
export const common = {
|
|
7
|
+
web_search_call: { name: "web_search", input: (item) => item.action ?? {} },
|
|
8
|
+
file_search_call: { name: "file_search", input: (item) => ({ queries: item.queries ?? [] }) },
|
|
9
|
+
code_interpreter_call: {
|
|
10
|
+
name: "code_interpreter",
|
|
11
|
+
input: (item) => ({ code: item.code, container_id: item.container_id }),
|
|
12
|
+
},
|
|
13
|
+
mcp_call: {
|
|
14
|
+
name: "mcp",
|
|
15
|
+
input: (item) => ({ server_label: item.server_label, name: item.name, arguments: item.arguments }),
|
|
16
|
+
},
|
|
17
|
+
};
|
|
5
18
|
export const isItem = (item, tools) => item.type in tools;
|
|
19
|
+
/**
|
|
20
|
+
* Responses stream that turns completed hosted tool items into a provider-executed
|
|
21
|
+
* tool call and result. `override` sees each normalized event first and may handle it.
|
|
22
|
+
*/
|
|
23
|
+
export const stream = (adapter, tools, override) => ({
|
|
24
|
+
event: OpenResponses.protocol.stream.event,
|
|
25
|
+
initial: (request) => OpenResponses.initial(request, adapter),
|
|
26
|
+
step: (state, input) => {
|
|
27
|
+
const event = OpenResponses.normalize(state, input);
|
|
28
|
+
const handled = override?.(state, event);
|
|
29
|
+
if (handled)
|
|
30
|
+
return handled;
|
|
31
|
+
if (event.type === "response.output_item.done" && event.item && isItem(event.item, tools))
|
|
32
|
+
return onDone(state, event.item, tools);
|
|
33
|
+
return OpenResponses.step(state, event);
|
|
34
|
+
},
|
|
35
|
+
terminal: OpenResponses.terminal,
|
|
36
|
+
});
|
|
6
37
|
export const onDone = Effect.fnUntraced(function* (state, item, tools) {
|
|
7
38
|
const tool = tools[item.type];
|
|
8
39
|
if (!tool)
|
|
@@ -70,218 +70,12 @@ export declare const appendExisting: <K extends StreamKey>(route: string, tools:
|
|
|
70
70
|
* from state, and reject malformed local arguments without repairing them.
|
|
71
71
|
* Missing keys are a no-op because some providers emit stop events for
|
|
72
72
|
* non-tool content blocks.
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
tools: Partial<Record<K, PendingTool>>;
|
|
76
|
-
events?: undefined;
|
|
77
|
-
} | {
|
|
78
|
-
tools: Partial<Record<K, PendingTool>>;
|
|
79
|
-
events: readonly ({
|
|
80
|
-
readonly type: "step-start";
|
|
81
|
-
readonly index: number;
|
|
82
|
-
} | {
|
|
83
|
-
readonly type: "raw";
|
|
84
|
-
readonly data: unknown;
|
|
85
|
-
} | {
|
|
86
|
-
readonly type: "text-start";
|
|
87
|
-
readonly id: string;
|
|
88
|
-
readonly providerMetadata?: {
|
|
89
|
-
readonly [x: string]: {
|
|
90
|
-
readonly [x: string]: unknown;
|
|
91
|
-
};
|
|
92
|
-
} | undefined;
|
|
93
|
-
} | {
|
|
94
|
-
readonly type: "text-delta";
|
|
95
|
-
readonly id: string;
|
|
96
|
-
readonly text: string;
|
|
97
|
-
readonly providerMetadata?: {
|
|
98
|
-
readonly [x: string]: {
|
|
99
|
-
readonly [x: string]: unknown;
|
|
100
|
-
};
|
|
101
|
-
} | undefined;
|
|
102
|
-
} | {
|
|
103
|
-
readonly type: "text-end";
|
|
104
|
-
readonly id: string;
|
|
105
|
-
readonly text?: string | undefined;
|
|
106
|
-
readonly providerMetadata?: {
|
|
107
|
-
readonly [x: string]: {
|
|
108
|
-
readonly [x: string]: unknown;
|
|
109
|
-
};
|
|
110
|
-
} | undefined;
|
|
111
|
-
} | {
|
|
112
|
-
readonly type: "reasoning-start";
|
|
113
|
-
readonly id: string;
|
|
114
|
-
readonly providerMetadata?: {
|
|
115
|
-
readonly [x: string]: {
|
|
116
|
-
readonly [x: string]: unknown;
|
|
117
|
-
};
|
|
118
|
-
} | undefined;
|
|
119
|
-
} | {
|
|
120
|
-
readonly type: "reasoning-delta";
|
|
121
|
-
readonly id: string;
|
|
122
|
-
readonly text: string;
|
|
123
|
-
readonly providerMetadata?: {
|
|
124
|
-
readonly [x: string]: {
|
|
125
|
-
readonly [x: string]: unknown;
|
|
126
|
-
};
|
|
127
|
-
} | undefined;
|
|
128
|
-
} | {
|
|
129
|
-
readonly type: "reasoning-end";
|
|
130
|
-
readonly id: string;
|
|
131
|
-
readonly text?: string | undefined;
|
|
132
|
-
readonly providerMetadata?: {
|
|
133
|
-
readonly [x: string]: {
|
|
134
|
-
readonly [x: string]: unknown;
|
|
135
|
-
};
|
|
136
|
-
} | undefined;
|
|
137
|
-
} | {
|
|
138
|
-
readonly type: "tool-input-start";
|
|
139
|
-
readonly id: string;
|
|
140
|
-
readonly name: string;
|
|
141
|
-
readonly namespace?: string | undefined;
|
|
142
|
-
readonly providerExecuted?: boolean | undefined;
|
|
143
|
-
readonly providerMetadata?: {
|
|
144
|
-
readonly [x: string]: {
|
|
145
|
-
readonly [x: string]: unknown;
|
|
146
|
-
};
|
|
147
|
-
} | undefined;
|
|
148
|
-
} | {
|
|
149
|
-
readonly type: "tool-input-delta";
|
|
150
|
-
readonly id: string;
|
|
151
|
-
readonly name: string;
|
|
152
|
-
readonly namespace?: string | undefined;
|
|
153
|
-
readonly text: string;
|
|
154
|
-
readonly input?: unknown;
|
|
155
|
-
} | {
|
|
156
|
-
readonly type: "tool-input-end";
|
|
157
|
-
readonly id: string;
|
|
158
|
-
readonly name: string;
|
|
159
|
-
readonly namespace?: string | undefined;
|
|
160
|
-
readonly providerMetadata?: {
|
|
161
|
-
readonly [x: string]: {
|
|
162
|
-
readonly [x: string]: unknown;
|
|
163
|
-
};
|
|
164
|
-
} | undefined;
|
|
165
|
-
} | {
|
|
166
|
-
readonly type: "tool-input-error";
|
|
167
|
-
readonly id: string;
|
|
168
|
-
readonly name: string;
|
|
169
|
-
readonly namespace?: string | undefined;
|
|
170
|
-
readonly raw: string;
|
|
171
|
-
} | {
|
|
172
|
-
readonly type: "tool-call";
|
|
173
|
-
readonly id: string;
|
|
174
|
-
readonly name: string;
|
|
175
|
-
readonly namespace?: string | undefined;
|
|
176
|
-
readonly input: unknown;
|
|
177
|
-
readonly providerExecuted?: boolean | undefined;
|
|
178
|
-
readonly providerMetadata?: {
|
|
179
|
-
readonly [x: string]: {
|
|
180
|
-
readonly [x: string]: unknown;
|
|
181
|
-
};
|
|
182
|
-
} | undefined;
|
|
183
|
-
} | {
|
|
184
|
-
readonly type: "tool-result";
|
|
185
|
-
readonly id: string;
|
|
186
|
-
readonly name: string;
|
|
187
|
-
readonly namespace?: string | undefined;
|
|
188
|
-
readonly result: {
|
|
189
|
-
readonly type: "json";
|
|
190
|
-
readonly value: unknown;
|
|
191
|
-
} | {
|
|
192
|
-
readonly type: "text";
|
|
193
|
-
readonly value: unknown;
|
|
194
|
-
} | {
|
|
195
|
-
readonly type: "error";
|
|
196
|
-
readonly value: unknown;
|
|
197
|
-
} | {
|
|
198
|
-
readonly type: "content";
|
|
199
|
-
readonly value: readonly ({
|
|
200
|
-
readonly type: "text";
|
|
201
|
-
readonly text: string;
|
|
202
|
-
} | {
|
|
203
|
-
readonly type: "file";
|
|
204
|
-
readonly uri: string;
|
|
205
|
-
readonly mime: string;
|
|
206
|
-
readonly name?: string | undefined;
|
|
207
|
-
})[];
|
|
208
|
-
};
|
|
209
|
-
readonly output?: {
|
|
210
|
-
readonly structured: unknown;
|
|
211
|
-
readonly content: readonly ({
|
|
212
|
-
readonly type: "text";
|
|
213
|
-
readonly text: string;
|
|
214
|
-
} | {
|
|
215
|
-
readonly type: "file";
|
|
216
|
-
readonly uri: string;
|
|
217
|
-
readonly mime: string;
|
|
218
|
-
readonly name?: string | undefined;
|
|
219
|
-
})[];
|
|
220
|
-
} | undefined;
|
|
221
|
-
readonly providerExecuted?: boolean | undefined;
|
|
222
|
-
readonly providerMetadata?: {
|
|
223
|
-
readonly [x: string]: {
|
|
224
|
-
readonly [x: string]: unknown;
|
|
225
|
-
};
|
|
226
|
-
} | undefined;
|
|
227
|
-
} | {
|
|
228
|
-
readonly type: "step-finish";
|
|
229
|
-
readonly index: number;
|
|
230
|
-
readonly reason: {
|
|
231
|
-
readonly normalized: "content-filter" | "error" | "length" | "stop" | "tool-calls" | "unknown";
|
|
232
|
-
readonly raw?: string | undefined;
|
|
233
|
-
readonly category?: string | undefined;
|
|
234
|
-
readonly explanation?: string | undefined;
|
|
235
|
-
};
|
|
236
|
-
readonly usage?: import("../../schema/events.js").Usage | undefined;
|
|
237
|
-
readonly providerMetadata?: {
|
|
238
|
-
readonly [x: string]: {
|
|
239
|
-
readonly [x: string]: unknown;
|
|
240
|
-
};
|
|
241
|
-
} | undefined;
|
|
242
|
-
} | {
|
|
243
|
-
readonly type: "finish";
|
|
244
|
-
readonly reason: {
|
|
245
|
-
readonly normalized: "content-filter" | "error" | "length" | "stop" | "tool-calls" | "unknown";
|
|
246
|
-
readonly raw?: string | undefined;
|
|
247
|
-
readonly category?: string | undefined;
|
|
248
|
-
readonly explanation?: string | undefined;
|
|
249
|
-
};
|
|
250
|
-
readonly usage?: import("../../schema/events.js").Usage | undefined;
|
|
251
|
-
readonly message?: import("../../schema/messages.js").Message | undefined;
|
|
252
|
-
readonly providerMetadata?: {
|
|
253
|
-
readonly [x: string]: {
|
|
254
|
-
readonly [x: string]: unknown;
|
|
255
|
-
};
|
|
256
|
-
} | undefined;
|
|
257
|
-
} | {
|
|
258
|
-
readonly type: "media";
|
|
259
|
-
readonly media: import("../../media.js").Asset;
|
|
260
|
-
readonly providerMetadata?: {
|
|
261
|
-
readonly [x: string]: {
|
|
262
|
-
readonly [x: string]: unknown;
|
|
263
|
-
};
|
|
264
|
-
} | undefined;
|
|
265
|
-
} | ({
|
|
266
|
-
readonly type: "compaction";
|
|
267
|
-
readonly provider: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
268
|
-
readonly id?: string | undefined;
|
|
269
|
-
readonly encrypted?: string | undefined;
|
|
270
|
-
readonly text?: string | null | undefined;
|
|
271
|
-
} & ({
|
|
272
|
-
readonly encrypted: string;
|
|
273
|
-
readonly text?: never;
|
|
274
|
-
} | {
|
|
275
|
-
readonly text: string | null;
|
|
276
|
-
readonly encrypted?: never;
|
|
277
|
-
})))[];
|
|
278
|
-
}, AIError, never>;
|
|
279
|
-
/**
|
|
280
|
-
* Finalize one pending tool call with an authoritative final input string.
|
|
73
|
+
*
|
|
74
|
+
* Pass `input` when the provider sends an authoritative final input string.
|
|
281
75
|
* OpenAI Responses can send accumulated deltas and then repeat the completed
|
|
282
76
|
* arguments on `response.output_item.done`; the final value wins.
|
|
283
77
|
*/
|
|
284
|
-
export declare const
|
|
78
|
+
export declare const finish: <K extends StreamKey>(route: string, tools: State<K>, key: K, input?: string) => Effect.Effect<{
|
|
285
79
|
tools: Partial<Record<K, PendingTool>>;
|
|
286
80
|
events?: undefined;
|
|
287
81
|
} | {
|