@opencode/ai 0.0.0-dev-482 → 0.0.0-dev-513
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/anthropic-messages.js +35 -89
- package/dist/protocols/bedrock-converse.js +2 -3
- package/dist/protocols/gemini.js +26 -40
- package/dist/protocols/meta-responses.js +1 -1
- package/dist/protocols/open-responses-channel.js +6 -19
- package/dist/protocols/open-responses-continuation.d.ts +1 -5
- package/dist/protocols/open-responses-continuation.js +1 -3
- 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/bedrock-cache.js +2 -5
- package/dist/protocols/utils/cache.d.ts +3 -0
- package/dist/protocols/utils/cache.js +15 -2
- 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.d.ts +1 -1
- package/dist/providers/baseten.js +7 -21
- package/dist/providers/cerebras.d.ts +1 -1
- package/dist/providers/cerebras.js +3 -14
- package/dist/providers/cloudflare-ai-gateway.js +5 -25
- package/dist/providers/cloudflare-shared.d.ts +9 -0
- package/dist/providers/cloudflare-shared.js +25 -0
- package/dist/providers/cloudflare-workers-ai.js +4 -20
- package/dist/providers/cohere/chat.js +2 -7
- package/dist/providers/cohere.d.ts +1 -1
- package/dist/providers/cohere.js +5 -12
- package/dist/providers/deepinfra.d.ts +1 -1
- package/dist/providers/deepinfra.js +4 -12
- package/dist/providers/deepseek.d.ts +1 -1
- package/dist/providers/deepseek.js +3 -14
- package/dist/providers/digitalocean.d.ts +1 -1
- package/dist/providers/digitalocean.js +5 -7
- package/dist/providers/fireworks.d.ts +1 -1
- package/dist/providers/fireworks.js +3 -14
- package/dist/providers/google/interactions.js +2 -7
- package/dist/providers/google-vertex-chat.js +3 -29
- package/dist/providers/google-vertex-messages.js +3 -29
- package/dist/providers/google-vertex-mistral.js +3 -29
- package/dist/providers/google-vertex-responses.js +3 -29
- package/dist/providers/google-vertex-shared.d.ts +30 -0
- package/dist/providers/google-vertex-shared.js +25 -0
- package/dist/providers/google.js +3 -11
- package/dist/providers/groq.d.ts +1 -1
- package/dist/providers/groq.js +3 -14
- package/dist/providers/meta.d.ts +1 -1
- package/dist/providers/meta.js +6 -20
- package/dist/providers/minimax/chat.js +2 -7
- package/dist/providers/minimax/responses.js +2 -7
- package/dist/providers/minimax.d.ts +1 -1
- package/dist/providers/minimax.js +5 -20
- package/dist/providers/mistral.d.ts +1 -1
- package/dist/providers/mistral.js +3 -14
- package/dist/providers/moonshot/messages.js +2 -7
- package/dist/providers/moonshot/responses.js +2 -7
- package/dist/providers/moonshot.d.ts +1 -1
- package/dist/providers/moonshot.js +3 -14
- 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.d.ts +1 -1
- package/dist/providers/openrouter.js +9 -20
- package/dist/providers/settings.d.ts +40 -0
- package/dist/providers/settings.js +19 -0
- package/dist/providers/togetherai.d.ts +1 -1
- package/dist/providers/togetherai.js +3 -14
- package/dist/providers/typesafe-ai.d.ts +1 -1
- package/dist/providers/typesafe-ai.js +5 -1
- package/dist/providers/vercel-ai-gateway.d.ts +1 -1
- package/dist/providers/vercel-ai-gateway.js +8 -22
- 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.d.ts +1 -1
- package/dist/providers/zai-coding-plan.js +3 -14
- package/dist/providers/zai.d.ts +1 -1
- package/dist/providers/zai.js +6 -22
- package/dist/public.d.ts +12 -0
- package/dist/public.js +5 -0
- package/dist/schema/events.js +31 -64
- 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";
|
|
@@ -402,11 +402,8 @@ const ANTHROPIC_BREAKPOINT_CAP = 4;
|
|
|
402
402
|
const cacheControl = (breakpoints, cache) => {
|
|
403
403
|
if (cache?.type !== "ephemeral" && cache?.type !== "persistent")
|
|
404
404
|
return undefined;
|
|
405
|
-
if (breakpoints
|
|
406
|
-
breakpoints.dropped += 1;
|
|
405
|
+
if (!Cache.take(breakpoints))
|
|
407
406
|
return undefined;
|
|
408
|
-
}
|
|
409
|
-
breakpoints.remaining -= 1;
|
|
410
407
|
return { type: "ephemeral", ...(cache.ttl === undefined ? {} : { ttl: cache.ttl }) };
|
|
411
408
|
};
|
|
412
409
|
const providerMetadata = (key, metadata) => ({ [key]: metadata });
|
|
@@ -568,104 +565,55 @@ const lowerMedia = Effect.fnUntraced(function* (part, request, breakpoints) {
|
|
|
568
565
|
};
|
|
569
566
|
}
|
|
570
567
|
const fileId = fileIdFromMetadata(part.metadata);
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
568
|
+
const image = (source) => {
|
|
569
|
+
const transformations = transformationsFromMetadata(part.metadata);
|
|
570
|
+
return {
|
|
571
|
+
type: "image",
|
|
572
|
+
source,
|
|
573
|
+
...(cacheControlValue === undefined ? {} : { cache_control: cacheControlValue }),
|
|
574
|
+
...(transformations === undefined ? {} : { transformations }),
|
|
575
|
+
};
|
|
576
|
+
};
|
|
577
|
+
const document = (source) => {
|
|
578
|
+
const title = documentTitleFromPart(part);
|
|
579
|
+
const context = documentContextFromMetadata(part.metadata);
|
|
580
|
+
const citations = citationsFromMetadata(part.metadata);
|
|
582
581
|
return {
|
|
583
582
|
type: "document",
|
|
584
|
-
source
|
|
583
|
+
source,
|
|
585
584
|
...(cacheControlValue === undefined ? {} : { cache_control: cacheControlValue }),
|
|
586
|
-
...(
|
|
587
|
-
...(
|
|
588
|
-
|
|
589
|
-
: { context: documentContextFromMetadata(part.metadata) }),
|
|
590
|
-
...(citationsFromMetadata(part.metadata) === undefined
|
|
591
|
-
? {}
|
|
592
|
-
: { citations: citationsFromMetadata(part.metadata) }),
|
|
585
|
+
...(title === undefined ? {} : { title }),
|
|
586
|
+
...(context === undefined ? {} : { context }),
|
|
587
|
+
...(citations === undefined ? {} : { citations }),
|
|
593
588
|
};
|
|
589
|
+
};
|
|
590
|
+
// SDK file sources: FileImageSource:2350 / FileDocumentSource:2344 {type:"file", file_id}
|
|
591
|
+
if (fileId) {
|
|
592
|
+
if (mime.startsWith("image/"))
|
|
593
|
+
return image({ type: "file", file_id: fileId });
|
|
594
|
+
return document({ type: "file", file_id: fileId });
|
|
594
595
|
}
|
|
595
596
|
const rawString = ProviderShared.mediaUrl(part.media)?.trim();
|
|
596
597
|
// SDK URL sources: URLImageSource:3817 / URLPDFSource:3823 {type:"url", url}
|
|
597
598
|
if (rawString && isHttpUrl(rawString)) {
|
|
598
599
|
if (mime.startsWith("image/"))
|
|
599
|
-
return {
|
|
600
|
-
type: "image",
|
|
601
|
-
source: { type: "url", url: rawString },
|
|
602
|
-
...(cacheControlValue === undefined ? {} : { cache_control: cacheControlValue }),
|
|
603
|
-
...(transformationsFromMetadata(part.metadata) === undefined
|
|
604
|
-
? {}
|
|
605
|
-
: { transformations: transformationsFromMetadata(part.metadata) }),
|
|
606
|
-
};
|
|
600
|
+
return image({ type: "url", url: rawString });
|
|
607
601
|
if (mime === "application/pdf")
|
|
608
|
-
return {
|
|
609
|
-
type: "document",
|
|
610
|
-
source: { type: "url", url: rawString },
|
|
611
|
-
...(cacheControlValue === undefined ? {} : { cache_control: cacheControlValue }),
|
|
612
|
-
...(documentTitleFromPart(part) === undefined ? {} : { title: documentTitleFromPart(part) }),
|
|
613
|
-
...(documentContextFromMetadata(part.metadata) === undefined
|
|
614
|
-
? {}
|
|
615
|
-
: { context: documentContextFromMetadata(part.metadata) }),
|
|
616
|
-
...(citationsFromMetadata(part.metadata) === undefined
|
|
617
|
-
? {}
|
|
618
|
-
: { citations: citationsFromMetadata(part.metadata) }),
|
|
619
|
-
};
|
|
602
|
+
return document({ type: "url", url: rawString });
|
|
620
603
|
}
|
|
621
604
|
const media = yield* ProviderShared.requireInlineMedia("Anthropic Messages", part.media);
|
|
622
605
|
// SDK PlainTextSource:2716 {type:"text", media_type:"text/plain", data}
|
|
623
|
-
if (mime === "text/plain")
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
...(documentTitleFromPart(part) === undefined ? {} : { title: documentTitleFromPart(part) }),
|
|
630
|
-
...(documentContextFromMetadata(part.metadata) === undefined
|
|
631
|
-
? {}
|
|
632
|
-
: { context: documentContextFromMetadata(part.metadata) }),
|
|
633
|
-
...(citationsFromMetadata(part.metadata) === undefined
|
|
634
|
-
? {}
|
|
635
|
-
: { citations: citationsFromMetadata(part.metadata) }),
|
|
636
|
-
};
|
|
637
|
-
}
|
|
606
|
+
if (mime === "text/plain")
|
|
607
|
+
return document({
|
|
608
|
+
type: "text",
|
|
609
|
+
media_type: "text/plain",
|
|
610
|
+
data: Buffer.from(media.base64, "base64").toString("utf8"),
|
|
611
|
+
});
|
|
638
612
|
if (media.mime === "application/pdf")
|
|
639
|
-
return {
|
|
640
|
-
type: "document",
|
|
641
|
-
source: {
|
|
642
|
-
type: "base64",
|
|
643
|
-
media_type: "application/pdf",
|
|
644
|
-
data: media.base64,
|
|
645
|
-
},
|
|
646
|
-
...(cacheControlValue === undefined ? {} : { cache_control: cacheControlValue }),
|
|
647
|
-
...(documentTitleFromPart(part) === undefined ? {} : { title: documentTitleFromPart(part) }),
|
|
648
|
-
...(documentContextFromMetadata(part.metadata) === undefined
|
|
649
|
-
? {}
|
|
650
|
-
: { context: documentContextFromMetadata(part.metadata) }),
|
|
651
|
-
...(citationsFromMetadata(part.metadata) === undefined
|
|
652
|
-
? {}
|
|
653
|
-
: { citations: citationsFromMetadata(part.metadata) }),
|
|
654
|
-
};
|
|
613
|
+
return document({ type: "base64", media_type: "application/pdf", data: media.base64 });
|
|
655
614
|
if (!media.mime.startsWith("image/"))
|
|
656
615
|
return yield* invalid(`Anthropic Messages does not support media type ${part.media.mediaType}`);
|
|
657
|
-
return {
|
|
658
|
-
type: "image",
|
|
659
|
-
source: {
|
|
660
|
-
type: "base64",
|
|
661
|
-
media_type: media.mime,
|
|
662
|
-
data: media.base64,
|
|
663
|
-
},
|
|
664
|
-
...(cacheControlValue === undefined ? {} : { cache_control: cacheControlValue }),
|
|
665
|
-
...(transformationsFromMetadata(part.metadata) === undefined
|
|
666
|
-
? {}
|
|
667
|
-
: { transformations: transformationsFromMetadata(part.metadata) }),
|
|
668
|
-
};
|
|
616
|
+
return image({ type: "base64", media_type: media.mime, data: media.base64 });
|
|
669
617
|
});
|
|
670
618
|
// Tool results may carry structured text, images, and documents. Keep media as provider-native
|
|
671
619
|
// content instead of JSON-stringifying base64 into a prompt string.
|
|
@@ -931,9 +879,7 @@ const fromRequest = Effect.fn("AnthropicMessages.fromRequest")(function* (reques
|
|
|
931
879
|
cache_control: cacheControl(breakpoints, part.cache),
|
|
932
880
|
}));
|
|
933
881
|
const messages = yield* lowerMessages(flattened.request, breakpoints);
|
|
934
|
-
|
|
935
|
-
yield* Effect.logWarning(`Anthropic Messages: dropped ${breakpoints.dropped} cache breakpoint(s); the API allows at most ${ANTHROPIC_BREAKPOINT_CAP} per request.`);
|
|
936
|
-
}
|
|
882
|
+
yield* Cache.warnDropped(breakpoints, "Anthropic Messages", ANTHROPIC_BREAKPOINT_CAP);
|
|
937
883
|
const output_config = updates.effort === undefined && format === undefined ? undefined : { effort: updates.effort, format };
|
|
938
884
|
const maxTokens = generation?.maxTokens ?? DEFAULT_MAX_TOKENS;
|
|
939
885
|
const body = {
|
|
@@ -9,6 +9,7 @@ import { classifyProviderFailure } from "../provider-error.js";
|
|
|
9
9
|
import { JsonObject, optionalArray, ProviderShared } from "./shared.js";
|
|
10
10
|
import { BedrockAuth } from "./utils/bedrock-auth.js";
|
|
11
11
|
import { BedrockCache } from "./utils/bedrock-cache.js";
|
|
12
|
+
import { warnDropped } from "./utils/cache.js";
|
|
12
13
|
import { BedrockMedia } from "./utils/bedrock-media.js";
|
|
13
14
|
import { claudeVersion, supportsThinkingBlockBinding, THINKING_BINDING_BETA } from "./utils/claude-model.js";
|
|
14
15
|
import { Lifecycle } from "./utils/lifecycle.js";
|
|
@@ -501,9 +502,7 @@ const fromRequest = Effect.fn("BedrockConverse.fromRequest")(function* (request)
|
|
|
501
502
|
})();
|
|
502
503
|
const system = lowerSystem(breakpoints, request.system);
|
|
503
504
|
const messages = yield* lowerMessages(flattened.request, breakpoints);
|
|
504
|
-
|
|
505
|
-
yield* Effect.logWarning(`Bedrock Converse: dropped ${breakpoints.dropped} cache breakpoint(s); the API allows at most ${BedrockCache.BEDROCK_BREAKPOINT_CAP} per request.`);
|
|
506
|
-
}
|
|
505
|
+
yield* warnDropped(breakpoints, "Bedrock Converse", BedrockCache.BEDROCK_BREAKPOINT_CAP);
|
|
507
506
|
const inferenceConfig = (() => {
|
|
508
507
|
if (maxTokens === undefined &&
|
|
509
508
|
generation?.temperature === undefined &&
|
package/dist/protocols/gemini.js
CHANGED
|
@@ -202,6 +202,7 @@ const lowerContentPart = Effect.fnUntraced(function* (part) {
|
|
|
202
202
|
return yield* GeminiGenerateContent.mediaPart("Gemini", part.media);
|
|
203
203
|
});
|
|
204
204
|
const providerMetadata = (key, metadata) => ({ [key]: metadata });
|
|
205
|
+
const signatureMetadata = (key, signature) => signature ? providerMetadata(key, { thoughtSignature: signature }) : undefined;
|
|
205
206
|
const thoughtSignature = (metadata, key) => {
|
|
206
207
|
const value = metadata?.[key];
|
|
207
208
|
return typeof value?.thoughtSignature === "string" ? value.thoughtSignature : undefined;
|
|
@@ -472,13 +473,9 @@ const finish = (state) => {
|
|
|
472
473
|
const events = [];
|
|
473
474
|
let lifecycle = state.lifecycle;
|
|
474
475
|
if (state.reasoningId !== undefined)
|
|
475
|
-
lifecycle = Lifecycle.reasoningEnd(lifecycle, events, state.reasoningId, state.reasoningSignature
|
|
476
|
-
? undefined
|
|
477
|
-
: providerMetadata(state.providerMetadataKey, { thoughtSignature: state.reasoningSignature }));
|
|
476
|
+
lifecycle = Lifecycle.reasoningEnd(lifecycle, events, state.reasoningId, signatureMetadata(state.providerMetadataKey, state.reasoningSignature));
|
|
478
477
|
if (state.textId !== undefined)
|
|
479
|
-
lifecycle = Lifecycle.textEnd(lifecycle, events, state.textId, state.textSignature
|
|
480
|
-
? undefined
|
|
481
|
-
: providerMetadata(state.providerMetadataKey, { thoughtSignature: state.textSignature }));
|
|
478
|
+
lifecycle = Lifecycle.textEnd(lifecycle, events, state.textId, signatureMetadata(state.providerMetadataKey, state.textSignature));
|
|
482
479
|
Lifecycle.finish(lifecycle, events, {
|
|
483
480
|
reason: {
|
|
484
481
|
normalized: promptBlockReason === undefined ? mapFinishReason(finishReason, state.hasToolCalls) : "content-filter",
|
|
@@ -546,6 +543,21 @@ const step = (state, event) => {
|
|
|
546
543
|
let nextTextId = nextState.nextTextId;
|
|
547
544
|
// Supplier ids must be tracked across chunks of the same response, not just within one event's parts.
|
|
548
545
|
const seenCallIds = new Set(nextState.seenCallIds);
|
|
546
|
+
const signed = (signature) => signatureMetadata(state.providerMetadataKey, signature);
|
|
547
|
+
const endReasoning = () => {
|
|
548
|
+
if (reasoningId === undefined)
|
|
549
|
+
return;
|
|
550
|
+
lifecycle = Lifecycle.reasoningEnd(lifecycle, events, reasoningId, signed(reasoningSignature));
|
|
551
|
+
reasoningId = undefined;
|
|
552
|
+
reasoningSignature = undefined;
|
|
553
|
+
};
|
|
554
|
+
const endText = () => {
|
|
555
|
+
if (textId === undefined)
|
|
556
|
+
return;
|
|
557
|
+
lifecycle = Lifecycle.textEnd(lifecycle, events, textId, signed(textSignature));
|
|
558
|
+
textId = undefined;
|
|
559
|
+
textSignature = undefined;
|
|
560
|
+
};
|
|
549
561
|
for (const input of candidate.content.parts ?? []) {
|
|
550
562
|
if (ProviderShared.isRecord(input) &&
|
|
551
563
|
!("text" in input) &&
|
|
@@ -569,40 +581,26 @@ const step = (state, event) => {
|
|
|
569
581
|
lifecycle = Lifecycle.stepStart(lifecycle, events);
|
|
570
582
|
events.push(LLMEvent.media({
|
|
571
583
|
media: Media.base64(part.inlineData.data, part.inlineData.mimeType),
|
|
572
|
-
providerMetadata: signature
|
|
573
|
-
? providerMetadata(state.providerMetadataKey, { thoughtSignature: signature })
|
|
574
|
-
: undefined,
|
|
584
|
+
providerMetadata: signed(signature),
|
|
575
585
|
}));
|
|
576
586
|
continue;
|
|
577
587
|
}
|
|
578
588
|
if ("text" in part && part.text.length > 0) {
|
|
579
589
|
if (part.thought) {
|
|
580
|
-
|
|
581
|
-
lifecycle = Lifecycle.textEnd(lifecycle, events, textId, textSignature
|
|
582
|
-
? providerMetadata(state.providerMetadataKey, { thoughtSignature: textSignature })
|
|
583
|
-
: undefined);
|
|
584
|
-
textId = undefined;
|
|
585
|
-
textSignature = undefined;
|
|
586
|
-
}
|
|
590
|
+
endText();
|
|
587
591
|
if (reasoningId === undefined) {
|
|
588
592
|
reasoningId = `reasoning-${nextReasoningId}`;
|
|
589
593
|
nextReasoningId += 1;
|
|
590
594
|
}
|
|
591
|
-
lifecycle = Lifecycle.reasoningDelta(lifecycle, events, reasoningId, part.text,
|
|
595
|
+
lifecycle = Lifecycle.reasoningDelta(lifecycle, events, reasoningId, part.text, signed(signature));
|
|
592
596
|
continue;
|
|
593
597
|
}
|
|
594
|
-
|
|
595
|
-
lifecycle = Lifecycle.reasoningEnd(lifecycle, events, reasoningId, reasoningSignature
|
|
596
|
-
? providerMetadata(state.providerMetadataKey, { thoughtSignature: reasoningSignature })
|
|
597
|
-
: undefined);
|
|
598
|
-
reasoningId = undefined;
|
|
599
|
-
reasoningSignature = undefined;
|
|
600
|
-
}
|
|
598
|
+
endReasoning();
|
|
601
599
|
if (textId === undefined) {
|
|
602
600
|
textId = `text-${nextTextId}`;
|
|
603
601
|
nextTextId += 1;
|
|
604
602
|
}
|
|
605
|
-
lifecycle = Lifecycle.textDelta(lifecycle, events, textId, part.text,
|
|
603
|
+
lifecycle = Lifecycle.textDelta(lifecycle, events, textId, part.text, signed(textSignature));
|
|
606
604
|
textSignature = undefined;
|
|
607
605
|
continue;
|
|
608
606
|
}
|
|
@@ -617,26 +615,14 @@ const step = (state, event) => {
|
|
|
617
615
|
if (supplied !== undefined)
|
|
618
616
|
seenCallIds.add(supplied);
|
|
619
617
|
const id = supplied !== undefined && !duplicate ? supplied : `tool_${crypto.randomUUID().replaceAll("-", "")}`;
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
? providerMetadata(state.providerMetadataKey, { thoughtSignature: reasoningSignature })
|
|
623
|
-
: undefined);
|
|
624
|
-
reasoningId = undefined;
|
|
625
|
-
reasoningSignature = undefined;
|
|
626
|
-
}
|
|
627
|
-
if (textId !== undefined) {
|
|
628
|
-
lifecycle = Lifecycle.textEnd(lifecycle, events, textId, textSignature ? providerMetadata(state.providerMetadataKey, { thoughtSignature: textSignature }) : undefined);
|
|
629
|
-
textId = undefined;
|
|
630
|
-
textSignature = undefined;
|
|
631
|
-
}
|
|
618
|
+
endReasoning();
|
|
619
|
+
endText();
|
|
632
620
|
lifecycle = Lifecycle.stepStart(lifecycle, events);
|
|
633
621
|
events.push(LLMEvent.toolCall({
|
|
634
622
|
id,
|
|
635
623
|
name: part.functionCall.name,
|
|
636
624
|
input,
|
|
637
|
-
providerMetadata:
|
|
638
|
-
? providerMetadata(state.providerMetadataKey, { thoughtSignature: part.thoughtSignature })
|
|
639
|
-
: undefined,
|
|
625
|
+
providerMetadata: signed(signature),
|
|
640
626
|
}));
|
|
641
627
|
hasToolCalls = true;
|
|
642
628
|
}
|
|
@@ -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: () => ({}),
|
|
@@ -9,18 +9,16 @@ const WebSocketResponseCreate = Schema.StructWithRest(Schema.Struct({ type: Sche
|
|
|
9
9
|
Schema.Record(Schema.String, Schema.Unknown),
|
|
10
10
|
]);
|
|
11
11
|
const decodeMessage = ProviderShared.validateWith(Schema.decodeUnknownEffect(WebSocketResponseCreate));
|
|
12
|
-
const encodeMessage = Schema.encodeSync(Schema.fromJsonString(WebSocketResponseCreate));
|
|
13
12
|
const message = (body) => Effect.gen(function* () {
|
|
14
13
|
if (!ProviderShared.isRecord(body))
|
|
15
14
|
return yield* ProviderShared.invalidRequest("Open Responses WebSocket body must be a JSON object");
|
|
16
15
|
const { stream: _stream, stream_options: _streamOptions, background: _background, ...request } = body;
|
|
17
|
-
|
|
18
|
-
return { request: decoded, message: encodeMessage(decoded) };
|
|
16
|
+
return yield* decodeMessage({ ...request, type: "response.create" });
|
|
19
17
|
});
|
|
20
|
-
const
|
|
18
|
+
const observer = (options) => {
|
|
21
19
|
let responseID;
|
|
22
20
|
let terminal = false;
|
|
23
|
-
|
|
21
|
+
return Effect.fnUntraced(function* (_create, frame, event) {
|
|
24
22
|
if (terminal)
|
|
25
23
|
return yield* ProviderShared.eventError(options.id, `${options.name} emitted ${event.type} after a terminal event`, frame);
|
|
26
24
|
if (event.type === "error") {
|
|
@@ -65,15 +63,6 @@ const driver = (options, body) => {
|
|
|
65
63
|
}
|
|
66
64
|
return { type: "frame", frame };
|
|
67
65
|
});
|
|
68
|
-
return {
|
|
69
|
-
create: () => Effect.sync(() => {
|
|
70
|
-
responseID = undefined;
|
|
71
|
-
terminal = false;
|
|
72
|
-
return { message: body, mode: "full" };
|
|
73
|
-
}),
|
|
74
|
-
observeEvent,
|
|
75
|
-
observe: (create, frame) => OpenResponses.decodeChannelEvent(frame).pipe(Effect.mapError((cause) => ProviderShared.eventError(options.id, `Invalid ${options.name} WebSocket event`, frame, cause)), Effect.flatMap((event) => observeEvent(create, frame, event))),
|
|
76
|
-
};
|
|
77
66
|
};
|
|
78
67
|
export const transport = (options) => {
|
|
79
68
|
const http = HttpTransport.sseJson.with();
|
|
@@ -84,8 +73,7 @@ export const transport = (options) => {
|
|
|
84
73
|
const headers = Headers.remove(options.headers?.(parts.headers) ?? parts.headers, "content-length");
|
|
85
74
|
const channel = input.webSocket && (options.enabled?.(parts.url) ?? true)
|
|
86
75
|
? yield* Effect.gen(function* () {
|
|
87
|
-
const
|
|
88
|
-
const base = driver(options, create.message);
|
|
76
|
+
const request = yield* message(parts.jsonBody);
|
|
89
77
|
return {
|
|
90
78
|
url: yield* WebSocketTransport.toWebSocketUrl(options.url?.(parts.url) ?? parts.url),
|
|
91
79
|
headers,
|
|
@@ -93,9 +81,8 @@ export const transport = (options) => {
|
|
|
93
81
|
driver: OpenResponsesContinuation.driver({
|
|
94
82
|
id: options.id,
|
|
95
83
|
name: options.name,
|
|
96
|
-
request
|
|
97
|
-
|
|
98
|
-
base,
|
|
84
|
+
request,
|
|
85
|
+
base: observer(options),
|
|
99
86
|
continuation: options.continuation,
|
|
100
87
|
}),
|
|
101
88
|
};
|
|
@@ -7,15 +7,11 @@ import { OpenResponses } from "./open-responses.js";
|
|
|
7
7
|
* Whether omitted fields carry over from the continued response is provider behavior the route must know.
|
|
8
8
|
*/
|
|
9
9
|
export type Shape = (request: Readonly<Record<string, unknown>>) => Readonly<Record<string, unknown>> | undefined;
|
|
10
|
-
export interface BaseDriver extends WebSocketChannelDriver {
|
|
11
|
-
readonly observeEvent?: (create: ChannelCreate, frame: string, event: OpenResponses.Event) => Effect.Effect<ChannelObservation, AIError>;
|
|
12
|
-
}
|
|
13
10
|
export interface DriverInput {
|
|
14
11
|
readonly id: string;
|
|
15
12
|
readonly name: string;
|
|
16
13
|
readonly request: Readonly<Record<string, unknown>>;
|
|
17
|
-
readonly
|
|
18
|
-
readonly base: BaseDriver;
|
|
14
|
+
readonly base: (create: ChannelCreate, frame: string, event: OpenResponses.Event) => Effect.Effect<ChannelObservation, AIError>;
|
|
19
15
|
readonly continuation?: Shape;
|
|
20
16
|
}
|
|
21
17
|
export declare const driver: (input: DriverInput) => WebSocketChannelDriver;
|
|
@@ -121,9 +121,7 @@ export const driver = (input) => {
|
|
|
121
121
|
}),
|
|
122
122
|
observe: (create, frame) => Effect.gen(function* () {
|
|
123
123
|
const event = yield* OpenResponses.decodeChannelEvent(frame).pipe(Effect.mapError((cause) => ProviderShared.eventError(input.id, `Invalid ${input.name} WebSocket event`, frame, cause)));
|
|
124
|
-
const observation = yield* input.base
|
|
125
|
-
? input.base.observeEvent(create, frame, event)
|
|
126
|
-
: input.base.observe(create, frame);
|
|
124
|
+
const observation = yield* input.base(create, frame, event);
|
|
127
125
|
if (event.type === "response.output_item.done" && event.item)
|
|
128
126
|
output.push(event.item);
|
|
129
127
|
if (observation.type === "provider-failure") {
|
|
@@ -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?: {
|