@opencode/ai 0.0.0-reserved → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +879 -2
- package/dist/cache-policy.d.ts +2 -0
- package/dist/cache-policy.js +129 -0
- package/dist/image-client.d.ts +19 -0
- package/dist/image-client.js +28 -0
- package/dist/image.d.ts +110 -0
- package/dist/image.js +103 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +12 -0
- package/dist/llm.d.ts +252 -0
- package/dist/llm.js +74 -0
- package/dist/protocols/alibaba-chat.d.ts +225 -0
- package/dist/protocols/alibaba-chat.js +75 -0
- package/dist/protocols/alibaba-messages.d.ts +350 -0
- package/dist/protocols/alibaba-messages.js +40 -0
- package/dist/protocols/alibaba-responses.d.ts +255 -0
- package/dist/protocols/alibaba-responses.js +80 -0
- package/dist/protocols/anthropic-messages.d.ts +980 -0
- package/dist/protocols/anthropic-messages.js +1460 -0
- package/dist/protocols/bedrock-converse.d.ts +499 -0
- package/dist/protocols/bedrock-converse.js +643 -0
- package/dist/protocols/bedrock-event-stream.d.ts +9 -0
- package/dist/protocols/bedrock-event-stream.js +97 -0
- package/dist/protocols/gemini.d.ts +285 -0
- package/dist/protocols/gemini.js +671 -0
- package/dist/protocols/google-images.d.ts +30 -0
- package/dist/protocols/google-images.js +181 -0
- package/dist/protocols/index.d.ts +12 -0
- package/dist/protocols/index.js +12 -0
- package/dist/protocols/meta-images.d.ts +26 -0
- package/dist/protocols/meta-images.js +89 -0
- package/dist/protocols/meta-messages.d.ts +356 -0
- package/dist/protocols/meta-messages.js +41 -0
- package/dist/protocols/meta-responses.d.ts +473 -0
- package/dist/protocols/meta-responses.js +173 -0
- package/dist/protocols/mistral-chat.d.ts +540 -0
- package/dist/protocols/mistral-chat.js +624 -0
- package/dist/protocols/open-responses-channel.d.ts +25 -0
- package/dist/protocols/open-responses-channel.js +141 -0
- package/dist/protocols/open-responses-continuation.d.ts +16 -0
- package/dist/protocols/open-responses-continuation.js +170 -0
- package/dist/protocols/open-responses.d.ts +1715 -0
- package/dist/protocols/open-responses.js +1228 -0
- package/dist/protocols/openai-chat.d.ts +860 -0
- package/dist/protocols/openai-chat.js +966 -0
- package/dist/protocols/openai-compatible-chat.d.ts +109 -0
- package/dist/protocols/openai-compatible-chat.js +19 -0
- package/dist/protocols/openai-compatible-responses.d.ts +172 -0
- package/dist/protocols/openai-compatible-responses.js +18 -0
- package/dist/protocols/openai-images.d.ts +32 -0
- package/dist/protocols/openai-images.js +183 -0
- package/dist/protocols/openai-responses.d.ts +1389 -0
- package/dist/protocols/openai-responses.js +260 -0
- package/dist/protocols/shared.d.ts +193 -0
- package/dist/protocols/shared.js +290 -0
- package/dist/protocols/utils/bedrock-auth.d.ts +60 -0
- package/dist/protocols/utils/bedrock-auth.js +85 -0
- package/dist/protocols/utils/bedrock-cache.d.ts +19 -0
- package/dist/protocols/utils/bedrock-cache.js +49 -0
- package/dist/protocols/utils/bedrock-media.d.ts +55 -0
- package/dist/protocols/utils/bedrock-media.js +73 -0
- package/dist/protocols/utils/cache.d.ts +6 -0
- package/dist/protocols/utils/cache.js +5 -0
- package/dist/protocols/utils/gemini-tool-schema.d.ts +2 -0
- package/dist/protocols/utils/gemini-tool-schema.js +103 -0
- package/dist/protocols/utils/image-input.d.ts +21 -0
- package/dist/protocols/utils/image-input.js +20 -0
- package/dist/protocols/utils/lifecycle.d.ts +24 -0
- package/dist/protocols/utils/lifecycle.js +72 -0
- package/dist/protocols/utils/meta-image.d.ts +2 -0
- package/dist/protocols/utils/meta-image.js +13 -0
- package/dist/protocols/utils/open-responses-options.d.ts +56 -0
- package/dist/protocols/utils/open-responses-options.js +61 -0
- package/dist/protocols/utils/openai-image.d.ts +5 -0
- package/dist/protocols/utils/openai-image.js +18 -0
- package/dist/protocols/utils/openai-options.d.ts +16 -0
- package/dist/protocols/utils/openai-options.js +14 -0
- package/dist/protocols/utils/partial-json-options.d.ts +62 -0
- package/dist/protocols/utils/partial-json-options.js +52 -0
- package/dist/protocols/utils/partial-json.d.ts +8 -0
- package/dist/protocols/utils/partial-json.js +279 -0
- package/dist/protocols/utils/responses-checkpoint.d.ts +4 -0
- package/dist/protocols/utils/responses-checkpoint.js +107 -0
- package/dist/protocols/utils/responses-compaction.d.ts +4 -0
- package/dist/protocols/utils/responses-compaction.js +129 -0
- package/dist/protocols/utils/responses-hosted-tools.d.ts +26 -0
- package/dist/protocols/utils/responses-hosted-tools.js +32 -0
- package/dist/protocols/utils/tool-schema.d.ts +8 -0
- package/dist/protocols/utils/tool-schema.js +54 -0
- package/dist/protocols/utils/tool-stream.d.ts +710 -0
- package/dist/protocols/utils/tool-stream.js +155 -0
- package/dist/protocols/xai-images.d.ts +26 -0
- package/dist/protocols/xai-images.js +106 -0
- package/dist/protocols/xai-responses.d.ts +250 -0
- package/dist/protocols/xai-responses.js +81 -0
- package/dist/protocols/zai-chat.d.ts +202 -0
- package/dist/protocols/zai-chat.js +49 -0
- package/dist/protocols/zai-images.d.ts +22 -0
- package/dist/protocols/zai-images.js +79 -0
- package/dist/protocols/zai-messages.d.ts +344 -0
- package/dist/protocols/zai-messages.js +27 -0
- package/dist/protocols.d.ts +1 -0
- package/dist/protocols.js +1 -0
- package/dist/provider-error.d.ts +15 -0
- package/dist/provider-error.js +125 -0
- package/dist/provider-package.d.ts +15 -0
- package/dist/provider-package.js +1 -0
- package/dist/provider.d.ts +23 -0
- package/dist/provider.js +2 -0
- package/dist/providers/alibaba/chat.d.ts +1 -0
- package/dist/providers/alibaba/chat.js +1 -0
- package/dist/providers/alibaba/messages.d.ts +3 -0
- package/dist/providers/alibaba/messages.js +1 -0
- package/dist/providers/alibaba/responses.d.ts +3 -0
- package/dist/providers/alibaba/responses.js +1 -0
- package/dist/providers/alibaba.d.ts +711 -0
- package/dist/providers/alibaba.js +94 -0
- package/dist/providers/amazon-bedrock/mantle/chat.d.ts +2 -0
- package/dist/providers/amazon-bedrock/mantle/chat.js +1 -0
- package/dist/providers/amazon-bedrock/mantle/responses.d.ts +2 -0
- package/dist/providers/amazon-bedrock/mantle/responses.js +1 -0
- package/dist/providers/amazon-bedrock/mantle.d.ts +2 -0
- package/dist/providers/amazon-bedrock/mantle.js +1 -0
- package/dist/providers/amazon-bedrock-mantle.d.ts +313 -0
- package/dist/providers/amazon-bedrock-mantle.js +79 -0
- package/dist/providers/amazon-bedrock.d.ts +173 -0
- package/dist/providers/amazon-bedrock.js +41 -0
- package/dist/providers/anthropic-compatible.d.ts +309 -0
- package/dist/providers/anthropic-compatible.js +50 -0
- package/dist/providers/anthropic.d.ts +307 -0
- package/dist/providers/anthropic.js +42 -0
- package/dist/providers/azure/chat.d.ts +2 -0
- package/dist/providers/azure/chat.js +1 -0
- package/dist/providers/azure/responses.d.ts +2 -0
- package/dist/providers/azure/responses.js +1 -0
- package/dist/providers/azure.d.ts +598 -0
- package/dist/providers/azure.js +115 -0
- package/dist/providers/baseten.d.ts +228 -0
- package/dist/providers/baseten.js +38 -0
- package/dist/providers/cerebras.d.ts +227 -0
- package/dist/providers/cerebras.js +40 -0
- package/dist/providers/cloudflare-ai-gateway.d.ts +237 -0
- package/dist/providers/cloudflare-ai-gateway.js +65 -0
- package/dist/providers/cloudflare-workers-ai.d.ts +231 -0
- package/dist/providers/cloudflare-workers-ai.js +51 -0
- package/dist/providers/deepinfra.d.ts +227 -0
- package/dist/providers/deepinfra.js +43 -0
- package/dist/providers/deepseek.d.ts +228 -0
- package/dist/providers/deepseek.js +41 -0
- package/dist/providers/fireworks.d.ts +228 -0
- package/dist/providers/fireworks.js +38 -0
- package/dist/providers/google-vertex/chat.d.ts +2 -0
- package/dist/providers/google-vertex/chat.js +1 -0
- package/dist/providers/google-vertex/gemini.d.ts +2 -0
- package/dist/providers/google-vertex/gemini.js +1 -0
- package/dist/providers/google-vertex/messages.d.ts +2 -0
- package/dist/providers/google-vertex/messages.js +1 -0
- package/dist/providers/google-vertex/responses.d.ts +2 -0
- package/dist/providers/google-vertex/responses.js +1 -0
- package/dist/providers/google-vertex-chat.d.ts +132 -0
- package/dist/providers/google-vertex-chat.js +55 -0
- package/dist/providers/google-vertex-messages.d.ts +306 -0
- package/dist/providers/google-vertex-messages.js +75 -0
- package/dist/providers/google-vertex-responses.d.ts +197 -0
- package/dist/providers/google-vertex-responses.js +56 -0
- package/dist/providers/google-vertex-shared.d.ts +22 -0
- package/dist/providers/google-vertex-shared.js +72 -0
- package/dist/providers/google-vertex.d.ts +119 -0
- package/dist/providers/google-vertex.js +98 -0
- package/dist/providers/google.d.ts +114 -0
- package/dist/providers/google.js +42 -0
- package/dist/providers/groq.d.ts +314 -0
- package/dist/providers/groq.js +81 -0
- package/dist/providers/index.d.ts +31 -0
- package/dist/providers/index.js +31 -0
- package/dist/providers/meta/chat.d.ts +2 -0
- package/dist/providers/meta/chat.js +1 -0
- package/dist/providers/meta/messages.d.ts +2 -0
- package/dist/providers/meta/messages.js +1 -0
- package/dist/providers/meta/responses.d.ts +2 -0
- package/dist/providers/meta/responses.js +1 -0
- package/dist/providers/meta.d.ts +636 -0
- package/dist/providers/meta.js +113 -0
- package/dist/providers/minimax/chat.d.ts +4 -0
- package/dist/providers/minimax/chat.js +8 -0
- package/dist/providers/minimax/messages.d.ts +1 -0
- package/dist/providers/minimax/messages.js +1 -0
- package/dist/providers/minimax/responses.d.ts +4 -0
- package/dist/providers/minimax/responses.js +8 -0
- package/dist/providers/minimax.d.ts +598 -0
- package/dist/providers/minimax.js +89 -0
- package/dist/providers/mistral.d.ts +207 -0
- package/dist/providers/mistral.js +28 -0
- package/dist/providers/moonshot/chat.d.ts +1 -0
- package/dist/providers/moonshot/chat.js +1 -0
- package/dist/providers/moonshot/messages.d.ts +4 -0
- package/dist/providers/moonshot/messages.js +8 -0
- package/dist/providers/moonshot/responses.d.ts +4 -0
- package/dist/providers/moonshot/responses.js +8 -0
- package/dist/providers/moonshot.d.ts +596 -0
- package/dist/providers/moonshot.js +90 -0
- package/dist/providers/open-responses-options.d.ts +6 -0
- package/dist/providers/open-responses-options.js +1 -0
- package/dist/providers/openai/chat.d.ts +2 -0
- package/dist/providers/openai/chat.js +1 -0
- package/dist/providers/openai/responses.d.ts +2 -0
- package/dist/providers/openai/responses.js +1 -0
- package/dist/providers/openai-compatible/responses.d.ts +1 -0
- package/dist/providers/openai-compatible/responses.js +1 -0
- package/dist/providers/openai-compatible-responses.d.ts +195 -0
- package/dist/providers/openai-compatible-responses.js +32 -0
- package/dist/providers/openai-compatible.d.ts +130 -0
- package/dist/providers/openai-compatible.js +33 -0
- package/dist/providers/openai-options.d.ts +26 -0
- package/dist/providers/openai-options.js +41 -0
- package/dist/providers/openai.d.ts +404 -0
- package/dist/providers/openai.js +82 -0
- package/dist/providers/openrouter.d.ts +563 -0
- package/dist/providers/openrouter.js +114 -0
- package/dist/providers/togetherai.d.ts +227 -0
- package/dist/providers/togetherai.js +40 -0
- package/dist/providers/xai.d.ts +163 -0
- package/dist/providers/xai.js +88 -0
- package/dist/providers/zai/chat.d.ts +1 -0
- package/dist/providers/zai/chat.js +1 -0
- package/dist/providers/zai-coding-plan/chat.d.ts +1 -0
- package/dist/providers/zai-coding-plan/chat.js +1 -0
- package/dist/providers/zai-coding-plan/messages.d.ts +4 -0
- package/dist/providers/zai-coding-plan/messages.js +8 -0
- package/dist/providers/zai-coding-plan/responses.d.ts +4 -0
- package/dist/providers/zai-coding-plan/responses.js +8 -0
- package/dist/providers/zai-coding-plan.d.ts +577 -0
- package/dist/providers/zai-coding-plan.js +63 -0
- package/dist/providers/zai.d.ts +149 -0
- package/dist/providers/zai.js +53 -0
- package/dist/providers.d.ts +1 -0
- package/dist/providers.js +1 -0
- package/dist/route/auth-options.d.ts +34 -0
- package/dist/route/auth-options.js +14 -0
- package/dist/route/auth.d.ts +51 -0
- package/dist/route/auth.js +87 -0
- package/dist/route/client.d.ts +430 -0
- package/dist/route/client.js +307 -0
- package/dist/route/endpoint.d.ts +28 -0
- package/dist/route/endpoint.js +21 -0
- package/dist/route/executor.d.ts +27 -0
- package/dist/route/executor.js +183 -0
- package/dist/route/framing.d.ts +29 -0
- package/dist/route/framing.js +14 -0
- package/dist/route/index.d.ts +16 -0
- package/dist/route/index.js +9 -0
- package/dist/route/protocol.d.ts +76 -0
- package/dist/route/protocol.js +16 -0
- package/dist/route/transport/http.d.ts +34 -0
- package/dist/route/transport/http.js +68 -0
- package/dist/route/transport/index.d.ts +41 -0
- package/dist/route/transport/index.js +4 -0
- package/dist/route/transport/websocket-channel.d.ts +57 -0
- package/dist/route/transport/websocket-channel.js +1 -0
- package/dist/route/transport/websocket.d.ts +56 -0
- package/dist/route/transport/websocket.js +370 -0
- package/dist/route.d.ts +1 -0
- package/dist/route.js +1 -0
- package/dist/schema/errors.d.ts +170 -0
- package/dist/schema/errors.js +131 -0
- package/dist/schema/events.d.ts +8123 -0
- package/dist/schema/events.js +550 -0
- package/dist/schema/ids.d.ts +17 -0
- package/dist/schema/ids.js +10 -0
- package/dist/schema/index.d.ts +5 -0
- package/dist/schema/index.js +5 -0
- package/dist/schema/messages.d.ts +646 -0
- package/dist/schema/messages.js +301 -0
- package/dist/schema/options.d.ts +159 -0
- package/dist/schema/options.js +189 -0
- package/dist/testing.d.ts +1693 -0
- package/dist/testing.js +129 -0
- package/dist/tool-history.d.ts +2 -0
- package/dist/tool-history.js +84 -0
- package/dist/tool-runtime.d.ts +15 -0
- package/dist/tool-runtime.js +62 -0
- package/dist/tool.d.ts +136 -0
- package/dist/tool.js +66 -0
- package/dist/utils/record.d.ts +2 -0
- package/dist/utils/record.js +2 -0
- package/dist/utils/sanitize.d.ts +1 -0
- package/dist/utils/sanitize.js +12 -0
- package/package.json +43 -10
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import type { RouteDefaultsInput } from "../route/client.js";
|
|
2
|
+
import type { ProviderPackage } from "../provider-package.js";
|
|
3
|
+
import { type ModelID } from "../schema/index.js";
|
|
4
|
+
import type { BedrockCredentials } from "../protocols/bedrock-converse.js";
|
|
5
|
+
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
6
|
+
export type Config = RouteDefaultsInput & {
|
|
7
|
+
/** Bedrock API key. Falls back to `AWS_BEARER_TOKEN_BEDROCK`; bearer auth takes precedence over SigV4. */
|
|
8
|
+
readonly apiKey?: string;
|
|
9
|
+
/** `sigv4` ignores `apiKey` fallbacks from the environment; `bearer` requires a token. */
|
|
10
|
+
readonly auth?: "bearer" | "sigv4";
|
|
11
|
+
readonly headers?: Record<string, string>;
|
|
12
|
+
/** Static SigV4 credentials. When omitted the AWS default credential chain resolves them per request. */
|
|
13
|
+
readonly credentials?: BedrockCredentials;
|
|
14
|
+
/** Shared config profile for the default credential chain. */
|
|
15
|
+
readonly profile?: string;
|
|
16
|
+
/** AWS region. Falls back to `credentials.region`, `AWS_REGION`, `AWS_DEFAULT_REGION`, then `us-east-1`. */
|
|
17
|
+
readonly region?: string;
|
|
18
|
+
/** Override the computed `https://bedrock-runtime.<region>.amazonaws.com` URL. */
|
|
19
|
+
readonly baseURL?: string;
|
|
20
|
+
};
|
|
21
|
+
export interface Settings extends ProviderPackage.Settings {
|
|
22
|
+
readonly apiKey?: string;
|
|
23
|
+
readonly auth?: "bearer" | "sigv4";
|
|
24
|
+
readonly baseURL?: string;
|
|
25
|
+
readonly credentials?: BedrockCredentials;
|
|
26
|
+
readonly profile?: string;
|
|
27
|
+
readonly region?: string;
|
|
28
|
+
readonly topP?: number;
|
|
29
|
+
}
|
|
30
|
+
export declare const routes: import("../route/client.js").Route<{
|
|
31
|
+
readonly messages: readonly ({
|
|
32
|
+
readonly role: "user";
|
|
33
|
+
readonly content: readonly ({
|
|
34
|
+
readonly cachePoint: {
|
|
35
|
+
readonly type: "default";
|
|
36
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
37
|
+
};
|
|
38
|
+
} | {
|
|
39
|
+
readonly image: {
|
|
40
|
+
readonly format: "png" | "jpeg" | "gif" | "webp";
|
|
41
|
+
readonly source: {
|
|
42
|
+
readonly bytes: string;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
} | {
|
|
46
|
+
readonly document: {
|
|
47
|
+
readonly format: "pdf" | "csv" | "doc" | "docx" | "xls" | "xlsx" | "html" | "txt" | "md";
|
|
48
|
+
readonly name: string;
|
|
49
|
+
readonly source: {
|
|
50
|
+
readonly bytes: string;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
} | {
|
|
54
|
+
readonly text: string;
|
|
55
|
+
} | {
|
|
56
|
+
readonly toolResult: {
|
|
57
|
+
readonly content: readonly ({
|
|
58
|
+
readonly image: {
|
|
59
|
+
readonly format: "png" | "jpeg" | "gif" | "webp";
|
|
60
|
+
readonly source: {
|
|
61
|
+
readonly bytes: string;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
} | {
|
|
65
|
+
readonly document: {
|
|
66
|
+
readonly format: "pdf" | "csv" | "doc" | "docx" | "xls" | "xlsx" | "html" | "txt" | "md";
|
|
67
|
+
readonly name: string;
|
|
68
|
+
readonly source: {
|
|
69
|
+
readonly bytes: string;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
} | {
|
|
73
|
+
readonly text: string;
|
|
74
|
+
} | {
|
|
75
|
+
readonly json: unknown;
|
|
76
|
+
})[];
|
|
77
|
+
readonly toolUseId: string;
|
|
78
|
+
readonly status?: "error" | "success" | undefined;
|
|
79
|
+
};
|
|
80
|
+
})[];
|
|
81
|
+
} | {
|
|
82
|
+
readonly role: "assistant";
|
|
83
|
+
readonly content: readonly ({
|
|
84
|
+
readonly cachePoint: {
|
|
85
|
+
readonly type: "default";
|
|
86
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
87
|
+
};
|
|
88
|
+
} | {
|
|
89
|
+
readonly text: string;
|
|
90
|
+
} | {
|
|
91
|
+
readonly toolUse: {
|
|
92
|
+
readonly toolUseId: string;
|
|
93
|
+
readonly name: string;
|
|
94
|
+
readonly input: unknown;
|
|
95
|
+
};
|
|
96
|
+
} | {
|
|
97
|
+
readonly reasoningContent: {
|
|
98
|
+
readonly reasoningText: {
|
|
99
|
+
readonly text: string;
|
|
100
|
+
readonly signature?: string | undefined;
|
|
101
|
+
};
|
|
102
|
+
} | {
|
|
103
|
+
readonly redactedContent: string;
|
|
104
|
+
};
|
|
105
|
+
})[];
|
|
106
|
+
})[];
|
|
107
|
+
readonly modelId: string;
|
|
108
|
+
readonly system?: readonly ({
|
|
109
|
+
readonly cachePoint: {
|
|
110
|
+
readonly type: "default";
|
|
111
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
112
|
+
};
|
|
113
|
+
} | {
|
|
114
|
+
readonly text: string;
|
|
115
|
+
})[] | undefined;
|
|
116
|
+
readonly inferenceConfig?: {
|
|
117
|
+
readonly maxTokens?: number | undefined;
|
|
118
|
+
readonly temperature?: number | undefined;
|
|
119
|
+
readonly topP?: number | undefined;
|
|
120
|
+
readonly stopSequences?: readonly string[] | undefined;
|
|
121
|
+
} | undefined;
|
|
122
|
+
readonly toolConfig?: {
|
|
123
|
+
readonly tools: readonly ({
|
|
124
|
+
readonly cachePoint: {
|
|
125
|
+
readonly type: "default";
|
|
126
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
127
|
+
};
|
|
128
|
+
} | {
|
|
129
|
+
readonly toolSpec: {
|
|
130
|
+
readonly name: string;
|
|
131
|
+
readonly inputSchema: {
|
|
132
|
+
readonly json: {
|
|
133
|
+
readonly [x: string]: unknown;
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
readonly description?: string | undefined;
|
|
137
|
+
};
|
|
138
|
+
})[];
|
|
139
|
+
readonly toolChoice?: {
|
|
140
|
+
readonly auto: {};
|
|
141
|
+
} | {
|
|
142
|
+
readonly any: {};
|
|
143
|
+
} | {
|
|
144
|
+
readonly tool: {
|
|
145
|
+
readonly name: string;
|
|
146
|
+
};
|
|
147
|
+
} | undefined;
|
|
148
|
+
} | undefined;
|
|
149
|
+
readonly additionalModelRequestFields?: {
|
|
150
|
+
readonly [x: string]: unknown;
|
|
151
|
+
} | undefined;
|
|
152
|
+
}, import("../route/transport/http.js").HttpPrepared<object>, import("../route/client.js").CompactionOperations | undefined>[];
|
|
153
|
+
export declare const configure: (input?: Config) => {
|
|
154
|
+
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
155
|
+
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<{
|
|
156
|
+
readonly [x: string]: unknown;
|
|
157
|
+
}, import("../route/client.js").CompactionOperations | undefined>;
|
|
158
|
+
configure: (input?: Config) => /*elided*/ any;
|
|
159
|
+
};
|
|
160
|
+
export declare const provider: {
|
|
161
|
+
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
162
|
+
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<{
|
|
163
|
+
readonly [x: string]: unknown;
|
|
164
|
+
}, import("../route/client.js").CompactionOperations | undefined>;
|
|
165
|
+
configure: (input?: Config) => {
|
|
166
|
+
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
167
|
+
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<{
|
|
168
|
+
readonly [x: string]: unknown;
|
|
169
|
+
}, import("../route/client.js").CompactionOperations | undefined>;
|
|
170
|
+
configure: /*elided*/ any;
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
export declare const model: ProviderPackage.Definition<Settings>["model"];
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ProviderConfigurationError, ProviderID } from "../schema/index.js";
|
|
2
|
+
import * as BedrockConverse from "../protocols/bedrock-converse.js";
|
|
3
|
+
import { BedrockAuth } from "../protocols/utils/bedrock-auth.js";
|
|
4
|
+
export const id = ProviderID.make("amazon-bedrock");
|
|
5
|
+
export const routes = [BedrockConverse.route];
|
|
6
|
+
const bedrockBaseURL = (region) => `https://bedrock-runtime.${region}.amazonaws.com`;
|
|
7
|
+
const configuredRoute = (input) => {
|
|
8
|
+
const { apiKey, auth, credentials, profile, region, baseURL, ...rest } = input;
|
|
9
|
+
if (auth === "bearer" && apiKey === undefined && process.env.AWS_BEARER_TOKEN_BEDROCK === undefined)
|
|
10
|
+
throw new ProviderConfigurationError({ provider: id, message: "Amazon Bedrock bearer auth requires apiKey" });
|
|
11
|
+
if (auth === "sigv4" && apiKey !== undefined)
|
|
12
|
+
throw new ProviderConfigurationError({ provider: id, message: "Amazon Bedrock SigV4 auth does not accept apiKey" });
|
|
13
|
+
const resolvedRegion = BedrockAuth.resolveRegion(input);
|
|
14
|
+
return BedrockConverse.route.with({
|
|
15
|
+
...rest,
|
|
16
|
+
provider: id,
|
|
17
|
+
providerMetadataKey: "bedrock",
|
|
18
|
+
endpoint: { baseURL: baseURL ?? bedrockBaseURL(resolvedRegion) },
|
|
19
|
+
auth: BedrockAuth.resolveAuth({ apiKey, credentials, profile }, resolvedRegion, { mode: auth }),
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
export const configure = (input = {}) => {
|
|
23
|
+
const route = configuredRoute(input);
|
|
24
|
+
return {
|
|
25
|
+
id,
|
|
26
|
+
model: (modelID) => route.model({ id: modelID }),
|
|
27
|
+
configure,
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export const provider = configure();
|
|
31
|
+
export const model = (modelID, settings) => configure({
|
|
32
|
+
apiKey: settings.apiKey,
|
|
33
|
+
auth: settings.auth,
|
|
34
|
+
baseURL: settings.baseURL,
|
|
35
|
+
credentials: settings.credentials,
|
|
36
|
+
generation: settings.topP === undefined ? undefined : { topP: settings.topP },
|
|
37
|
+
headers: settings.headers === undefined ? undefined : { ...settings.headers },
|
|
38
|
+
http: settings.body === undefined ? undefined : { body: { ...settings.body } },
|
|
39
|
+
profile: settings.profile,
|
|
40
|
+
region: settings.region,
|
|
41
|
+
}).model(modelID);
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import type { ProviderPackage } from "../provider-package.js";
|
|
2
|
+
import { AnthropicMessages } from "../protocols/anthropic-messages.js";
|
|
3
|
+
import type { ProviderAuthOption } from "../route/auth-options.js";
|
|
4
|
+
import type { RouteDefaultsInput } from "../route/client.js";
|
|
5
|
+
import { type ModelID } from "../schema/index.js";
|
|
6
|
+
export type AnthropicOptionsInput = AnthropicMessages.OptionsInput;
|
|
7
|
+
export type AnthropicProviderOptionsInput = AnthropicMessages.ProviderOptionsInput;
|
|
8
|
+
export type AnthropicThinkingInput = AnthropicMessages.ThinkingInput;
|
|
9
|
+
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
10
|
+
export type Config = RouteDefaultsInput & ProviderAuthOption<"optional"> & {
|
|
11
|
+
readonly provider?: string;
|
|
12
|
+
readonly baseURL: string;
|
|
13
|
+
readonly providerOptions?: AnthropicMessages.ProviderOptionsInput;
|
|
14
|
+
};
|
|
15
|
+
export type Settings = ProviderPackage.Settings & AnthropicMessages.ProviderOptionsInput & ({
|
|
16
|
+
readonly apiKey?: string;
|
|
17
|
+
readonly authToken?: never;
|
|
18
|
+
} | {
|
|
19
|
+
readonly apiKey?: never;
|
|
20
|
+
readonly authToken?: string;
|
|
21
|
+
}) & {
|
|
22
|
+
readonly baseURL: string;
|
|
23
|
+
readonly provider?: string;
|
|
24
|
+
};
|
|
25
|
+
export declare const routes: import("../route/client.js").Route<{
|
|
26
|
+
readonly max_tokens: number;
|
|
27
|
+
readonly model: string;
|
|
28
|
+
readonly messages: readonly ({
|
|
29
|
+
readonly role: "user";
|
|
30
|
+
readonly content: readonly ({
|
|
31
|
+
readonly type: "text";
|
|
32
|
+
readonly text: string;
|
|
33
|
+
readonly cache_control?: {
|
|
34
|
+
readonly type: "ephemeral";
|
|
35
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
36
|
+
} | undefined;
|
|
37
|
+
} | {
|
|
38
|
+
readonly type: "image";
|
|
39
|
+
readonly source: {
|
|
40
|
+
readonly type: "base64";
|
|
41
|
+
readonly media_type: string;
|
|
42
|
+
readonly data: string;
|
|
43
|
+
} | {
|
|
44
|
+
readonly type: "url";
|
|
45
|
+
readonly url: string;
|
|
46
|
+
} | {
|
|
47
|
+
readonly type: "file";
|
|
48
|
+
readonly file_id: string;
|
|
49
|
+
};
|
|
50
|
+
readonly cache_control?: {
|
|
51
|
+
readonly type: "ephemeral";
|
|
52
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
53
|
+
} | undefined;
|
|
54
|
+
readonly transformations?: {
|
|
55
|
+
readonly oversized_image?: "error" | "downsize" | undefined;
|
|
56
|
+
} | undefined;
|
|
57
|
+
} | {
|
|
58
|
+
readonly type: "document";
|
|
59
|
+
readonly source: {
|
|
60
|
+
readonly type: "base64";
|
|
61
|
+
readonly media_type: "application/pdf";
|
|
62
|
+
readonly data: string;
|
|
63
|
+
} | {
|
|
64
|
+
readonly type: "text";
|
|
65
|
+
readonly media_type: "text/plain";
|
|
66
|
+
readonly data: string;
|
|
67
|
+
} | {
|
|
68
|
+
readonly type: "url";
|
|
69
|
+
readonly url: string;
|
|
70
|
+
} | {
|
|
71
|
+
readonly type: "file";
|
|
72
|
+
readonly file_id: string;
|
|
73
|
+
};
|
|
74
|
+
readonly title?: string | undefined;
|
|
75
|
+
readonly context?: string | undefined;
|
|
76
|
+
readonly cache_control?: {
|
|
77
|
+
readonly type: "ephemeral";
|
|
78
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
79
|
+
} | undefined;
|
|
80
|
+
readonly citations?: {
|
|
81
|
+
readonly enabled: boolean;
|
|
82
|
+
} | undefined;
|
|
83
|
+
} | {
|
|
84
|
+
readonly type: "tool_result";
|
|
85
|
+
readonly content: string | readonly ({
|
|
86
|
+
readonly type: "text";
|
|
87
|
+
readonly text: string;
|
|
88
|
+
readonly cache_control?: {
|
|
89
|
+
readonly type: "ephemeral";
|
|
90
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
91
|
+
} | undefined;
|
|
92
|
+
} | {
|
|
93
|
+
readonly type: "image";
|
|
94
|
+
readonly source: {
|
|
95
|
+
readonly type: "base64";
|
|
96
|
+
readonly media_type: string;
|
|
97
|
+
readonly data: string;
|
|
98
|
+
} | {
|
|
99
|
+
readonly type: "url";
|
|
100
|
+
readonly url: string;
|
|
101
|
+
} | {
|
|
102
|
+
readonly type: "file";
|
|
103
|
+
readonly file_id: string;
|
|
104
|
+
};
|
|
105
|
+
readonly cache_control?: {
|
|
106
|
+
readonly type: "ephemeral";
|
|
107
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
108
|
+
} | undefined;
|
|
109
|
+
readonly transformations?: {
|
|
110
|
+
readonly oversized_image?: "error" | "downsize" | undefined;
|
|
111
|
+
} | undefined;
|
|
112
|
+
} | {
|
|
113
|
+
readonly type: "document";
|
|
114
|
+
readonly source: {
|
|
115
|
+
readonly type: "base64";
|
|
116
|
+
readonly media_type: "application/pdf";
|
|
117
|
+
readonly data: string;
|
|
118
|
+
} | {
|
|
119
|
+
readonly type: "text";
|
|
120
|
+
readonly media_type: "text/plain";
|
|
121
|
+
readonly data: string;
|
|
122
|
+
} | {
|
|
123
|
+
readonly type: "url";
|
|
124
|
+
readonly url: string;
|
|
125
|
+
} | {
|
|
126
|
+
readonly type: "file";
|
|
127
|
+
readonly file_id: string;
|
|
128
|
+
};
|
|
129
|
+
readonly title?: string | undefined;
|
|
130
|
+
readonly context?: string | undefined;
|
|
131
|
+
readonly cache_control?: {
|
|
132
|
+
readonly type: "ephemeral";
|
|
133
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
134
|
+
} | undefined;
|
|
135
|
+
readonly citations?: {
|
|
136
|
+
readonly enabled: boolean;
|
|
137
|
+
} | undefined;
|
|
138
|
+
})[];
|
|
139
|
+
readonly tool_use_id: string;
|
|
140
|
+
readonly cache_control?: {
|
|
141
|
+
readonly type: "ephemeral";
|
|
142
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
143
|
+
} | undefined;
|
|
144
|
+
readonly is_error?: boolean | undefined;
|
|
145
|
+
})[];
|
|
146
|
+
} | {
|
|
147
|
+
readonly role: "assistant";
|
|
148
|
+
readonly content: readonly ({
|
|
149
|
+
readonly type: "text";
|
|
150
|
+
readonly text: string;
|
|
151
|
+
readonly cache_control?: {
|
|
152
|
+
readonly type: "ephemeral";
|
|
153
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
154
|
+
} | undefined;
|
|
155
|
+
} | {
|
|
156
|
+
readonly id: string;
|
|
157
|
+
readonly type: "tool_use";
|
|
158
|
+
readonly name: string;
|
|
159
|
+
readonly input: unknown;
|
|
160
|
+
readonly cache_control?: {
|
|
161
|
+
readonly type: "ephemeral";
|
|
162
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
163
|
+
} | undefined;
|
|
164
|
+
} | {
|
|
165
|
+
readonly id: string;
|
|
166
|
+
readonly type: "server_tool_use";
|
|
167
|
+
readonly name: string;
|
|
168
|
+
readonly input: unknown;
|
|
169
|
+
readonly cache_control?: {
|
|
170
|
+
readonly type: "ephemeral";
|
|
171
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
172
|
+
} | undefined;
|
|
173
|
+
} | {
|
|
174
|
+
readonly type: "web_search_tool_result" | "code_execution_tool_result" | "web_fetch_tool_result";
|
|
175
|
+
readonly content: unknown;
|
|
176
|
+
readonly tool_use_id: string;
|
|
177
|
+
readonly cache_control?: {
|
|
178
|
+
readonly type: "ephemeral";
|
|
179
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
180
|
+
} | undefined;
|
|
181
|
+
} | {
|
|
182
|
+
readonly type: "thinking";
|
|
183
|
+
readonly thinking: string;
|
|
184
|
+
readonly signature: string;
|
|
185
|
+
readonly cache_control?: {
|
|
186
|
+
readonly type: "ephemeral";
|
|
187
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
188
|
+
} | undefined;
|
|
189
|
+
} | {
|
|
190
|
+
readonly data: string;
|
|
191
|
+
readonly type: "redacted_thinking";
|
|
192
|
+
readonly cache_control?: {
|
|
193
|
+
readonly type: "ephemeral";
|
|
194
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
195
|
+
} | undefined;
|
|
196
|
+
} | {
|
|
197
|
+
readonly type: "compaction";
|
|
198
|
+
readonly content: string | null;
|
|
199
|
+
})[];
|
|
200
|
+
} | {
|
|
201
|
+
readonly role: "system";
|
|
202
|
+
readonly content: readonly {
|
|
203
|
+
readonly type: "text";
|
|
204
|
+
readonly text: string;
|
|
205
|
+
readonly cache_control?: {
|
|
206
|
+
readonly type: "ephemeral";
|
|
207
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
208
|
+
} | undefined;
|
|
209
|
+
}[];
|
|
210
|
+
})[];
|
|
211
|
+
readonly stream: true;
|
|
212
|
+
readonly metadata?: {
|
|
213
|
+
readonly user_id?: string | null | undefined;
|
|
214
|
+
} | undefined;
|
|
215
|
+
readonly tools?: readonly {
|
|
216
|
+
readonly description: string;
|
|
217
|
+
readonly name: string;
|
|
218
|
+
readonly input_schema: {
|
|
219
|
+
readonly [x: string]: unknown;
|
|
220
|
+
};
|
|
221
|
+
readonly cache_control?: {
|
|
222
|
+
readonly type: "ephemeral";
|
|
223
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
224
|
+
} | undefined;
|
|
225
|
+
}[] | undefined;
|
|
226
|
+
readonly system?: readonly {
|
|
227
|
+
readonly type: "text";
|
|
228
|
+
readonly text: string;
|
|
229
|
+
readonly cache_control?: {
|
|
230
|
+
readonly type: "ephemeral";
|
|
231
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
232
|
+
} | undefined;
|
|
233
|
+
}[] | undefined;
|
|
234
|
+
readonly temperature?: number | undefined;
|
|
235
|
+
readonly thinking?: {
|
|
236
|
+
readonly type: "enabled";
|
|
237
|
+
readonly budget_tokens: number;
|
|
238
|
+
readonly display?: "summarized" | "omitted" | undefined;
|
|
239
|
+
readonly block_binding?: {
|
|
240
|
+
readonly prefix_mismatch_behavior?: string | undefined;
|
|
241
|
+
} | undefined;
|
|
242
|
+
} | {
|
|
243
|
+
readonly type: "adaptive";
|
|
244
|
+
readonly display?: "summarized" | "omitted" | undefined;
|
|
245
|
+
readonly block_binding?: {
|
|
246
|
+
readonly prefix_mismatch_behavior?: string | undefined;
|
|
247
|
+
} | undefined;
|
|
248
|
+
} | {
|
|
249
|
+
readonly type: "disabled";
|
|
250
|
+
} | undefined;
|
|
251
|
+
readonly service_tier?: "auto" | "standard_only" | undefined;
|
|
252
|
+
readonly container?: string | {
|
|
253
|
+
readonly id?: string | null | undefined;
|
|
254
|
+
readonly skills?: readonly {
|
|
255
|
+
readonly [x: string]: unknown;
|
|
256
|
+
}[] | null | undefined;
|
|
257
|
+
} | null | undefined;
|
|
258
|
+
readonly inference_geo?: string | null | undefined;
|
|
259
|
+
readonly cache_control?: {
|
|
260
|
+
readonly type: "ephemeral";
|
|
261
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
262
|
+
} | undefined;
|
|
263
|
+
readonly output_config?: {
|
|
264
|
+
readonly format?: {
|
|
265
|
+
readonly type: "json_schema";
|
|
266
|
+
readonly schema: {
|
|
267
|
+
readonly [x: string]: unknown;
|
|
268
|
+
};
|
|
269
|
+
} | null | undefined;
|
|
270
|
+
readonly effort?: string | undefined;
|
|
271
|
+
} | undefined;
|
|
272
|
+
readonly context_management?: {
|
|
273
|
+
readonly edits: readonly {
|
|
274
|
+
readonly type: "compact_20260112";
|
|
275
|
+
readonly instructions?: string | undefined;
|
|
276
|
+
readonly trigger?: {
|
|
277
|
+
readonly type: "input_tokens";
|
|
278
|
+
readonly value: number;
|
|
279
|
+
} | undefined;
|
|
280
|
+
readonly pause_after_compaction?: boolean | undefined;
|
|
281
|
+
}[];
|
|
282
|
+
} | undefined;
|
|
283
|
+
readonly tool_choice?: {
|
|
284
|
+
readonly type: "auto" | "none" | "any";
|
|
285
|
+
readonly disable_parallel_tool_use?: boolean | undefined;
|
|
286
|
+
} | {
|
|
287
|
+
readonly type: "tool";
|
|
288
|
+
readonly name: string;
|
|
289
|
+
readonly disable_parallel_tool_use?: boolean | undefined;
|
|
290
|
+
} | undefined;
|
|
291
|
+
readonly top_p?: number | undefined;
|
|
292
|
+
readonly top_k?: number | undefined;
|
|
293
|
+
readonly stop_sequences?: readonly string[] | undefined;
|
|
294
|
+
}, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined>[];
|
|
295
|
+
export declare const configure: (input: Config) => {
|
|
296
|
+
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
297
|
+
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<AnthropicMessages.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
298
|
+
configure: (input: Config) => /*elided*/ any;
|
|
299
|
+
};
|
|
300
|
+
export declare const provider: {
|
|
301
|
+
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
302
|
+
configure: (input: Config) => {
|
|
303
|
+
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
304
|
+
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<AnthropicMessages.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
305
|
+
configure: /*elided*/ any;
|
|
306
|
+
};
|
|
307
|
+
};
|
|
308
|
+
export declare const model: ProviderPackage.Definition<Settings, AnthropicMessages.ProviderOptionsInput>["model"];
|
|
309
|
+
export * as AnthropicCompatible from "./anthropic-compatible.js";
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { AnthropicMessages } from "../protocols/anthropic-messages.js";
|
|
2
|
+
import { Auth } from "../route/auth.js";
|
|
3
|
+
import { ProviderConfigurationError, ProviderID } from "../schema/index.js";
|
|
4
|
+
export const id = ProviderID.make("anthropic-compatible");
|
|
5
|
+
export const routes = [AnthropicMessages.route];
|
|
6
|
+
const auth = (input) => {
|
|
7
|
+
if ("auth" in input && input.auth)
|
|
8
|
+
return input.auth;
|
|
9
|
+
return Auth.optional("apiKey" in input ? input.apiKey : undefined, "apiKey").pipe(Auth.header("x-api-key"));
|
|
10
|
+
};
|
|
11
|
+
export const configure = (input) => {
|
|
12
|
+
const provider = input.provider ?? "anthropic-compatible";
|
|
13
|
+
if (!input.baseURL)
|
|
14
|
+
throw new ProviderConfigurationError({
|
|
15
|
+
provider: ProviderID.make(provider),
|
|
16
|
+
message: "Anthropic-compatible providers require a baseURL",
|
|
17
|
+
});
|
|
18
|
+
const { provider: _, baseURL, apiKey: _apiKey, auth: _auth, ...rest } = input;
|
|
19
|
+
const route = AnthropicMessages.route.with({
|
|
20
|
+
...rest,
|
|
21
|
+
provider,
|
|
22
|
+
endpoint: { baseURL },
|
|
23
|
+
auth: auth(input),
|
|
24
|
+
});
|
|
25
|
+
return {
|
|
26
|
+
id: ProviderID.make(provider),
|
|
27
|
+
model: (modelID) => route.model({ id: modelID }),
|
|
28
|
+
configure,
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export const provider = {
|
|
32
|
+
id,
|
|
33
|
+
configure,
|
|
34
|
+
};
|
|
35
|
+
export const model = (modelID, { apiKey, authToken, baseURL, body, headers, provider, ...providerOptions }) => {
|
|
36
|
+
if (apiKey !== undefined && authToken !== undefined)
|
|
37
|
+
throw new ProviderConfigurationError({
|
|
38
|
+
provider: ProviderID.make(provider ?? id),
|
|
39
|
+
message: "Anthropic-compatible apiKey cannot be combined with authToken",
|
|
40
|
+
});
|
|
41
|
+
return configure({
|
|
42
|
+
...(authToken === undefined ? { apiKey: apiKey } : { auth: Auth.bearer(authToken) }),
|
|
43
|
+
baseURL,
|
|
44
|
+
headers: headers === undefined ? undefined : { ...headers },
|
|
45
|
+
http: body === undefined ? undefined : { body: { ...body } },
|
|
46
|
+
provider,
|
|
47
|
+
providerOptions,
|
|
48
|
+
}).model(modelID);
|
|
49
|
+
};
|
|
50
|
+
export * as AnthropicCompatible from "./anthropic-compatible.js";
|