@opencode/ai 0.0.0-beta-19296 → 0.0.0-beta-19378

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.
@@ -0,0 +1,86 @@
1
+ import { AlibabaChat } from "../protocols/alibaba-chat.js";
2
+ import { AlibabaMessages } from "../protocols/alibaba-messages.js";
3
+ import { AlibabaResponses } from "../protocols/alibaba-responses.js";
4
+ import { AuthOptions } from "../route/auth-options.js";
5
+ import { Route } from "../route/client.js";
6
+ import { Endpoint } from "../route/endpoint.js";
7
+ import { Framing } from "../route/framing.js";
8
+ import { ProviderID, ToolDefinition } from "../schema/index.js";
9
+ export const id = ProviderID.make("alibaba");
10
+ const hosts = new Map([
11
+ ["ap-southeast-1", "dashscope-intl.aliyuncs.com"],
12
+ ["cn-beijing", "dashscope.aliyuncs.com"],
13
+ ["cn-hongkong", "cn-hongkong.dashscope.aliyuncs.com"],
14
+ ["us-east-1", "dashscope-us.aliyuncs.com"],
15
+ ]);
16
+ const chatRoute = Route.make({
17
+ id: "alibaba-chat",
18
+ provider: id,
19
+ providerMetadataKey: "alibaba",
20
+ protocol: AlibabaChat.protocol,
21
+ endpoint: Endpoint.path("/chat/completions"),
22
+ framing: Framing.sse,
23
+ });
24
+ const messagesRoute = Route.make({
25
+ id: "alibaba-messages",
26
+ provider: id,
27
+ providerMetadataKey: "alibaba",
28
+ protocol: AlibabaMessages.protocol,
29
+ endpoint: Endpoint.path("/messages"),
30
+ framing: Framing.sse,
31
+ headers: () => ({ "anthropic-version": "2023-06-01" }),
32
+ });
33
+ const responsesRoute = Route.make({
34
+ id: "alibaba-responses",
35
+ provider: id,
36
+ providerMetadataKey: "alibaba",
37
+ protocol: AlibabaResponses.protocol,
38
+ endpoint: Endpoint.path("/responses"),
39
+ framing: Framing.sse,
40
+ });
41
+ export const routes = [chatRoute, messagesRoute, responsesRoute];
42
+ export const configure = (input) => {
43
+ const { apiKey: _key, auth: _auth, region, workspaceID, baseURL, ...rest } = input;
44
+ const host = region === undefined
45
+ ? undefined
46
+ : workspaceID === undefined
47
+ ? hosts.get(region)
48
+ : `${workspaceID}.${region}.maas.aliyuncs.com`;
49
+ if (baseURL === undefined) {
50
+ if (region === undefined)
51
+ throw new Error("Alibaba requires region or baseURL");
52
+ if (host === undefined)
53
+ throw new Error(`Alibaba region ${region} requires workspaceID or baseURL`);
54
+ }
55
+ const opts = { ...rest, auth: AuthOptions.bearer(input, ["DASHSCOPE_API_KEY", "ALIBABA_API_KEY"]) };
56
+ const common = { ...opts, endpoint: { baseURL: baseURL ?? `https://${host}/compatible-mode/v1` } };
57
+ const chat = (id) => chatRoute.with(common).model({ id, compatibility: AlibabaChat.compatibility });
58
+ const messages = (id) => messagesRoute
59
+ .with({
60
+ ...opts,
61
+ endpoint: { baseURL: baseURL ?? `https://${host}/apps/anthropic/v1` },
62
+ })
63
+ .model({ id, compatibility: { requireSignature: false } });
64
+ const responses = (id) => responsesRoute.with(common).model({ id });
65
+ return { id, model: chat, chat, messages, responses, configure };
66
+ };
67
+ export const provider = { id, configure };
68
+ export const model = (id, input) => fromSettings(input).chat(id);
69
+ export const messagesModel = (id, input) => fromSettings(input).messages(id);
70
+ export const responsesModel = (id, input) => fromSettings(input).responses(id);
71
+ function fromSettings(input) {
72
+ const { body, ...rest } = input;
73
+ return configure({ ...rest, http: body === undefined ? undefined : { body } });
74
+ }
75
+ export const webSearch = () => hostedTool("web_search", "Search the web with Alibaba's hosted search tool.");
76
+ export const webExtractor = () => hostedTool("web_extractor", "Extract web page content with Alibaba's hosted tool.");
77
+ export const codeInterpreter = () => hostedTool("code_interpreter", "Execute code with Alibaba's hosted interpreter.");
78
+ function hostedTool(type, description) {
79
+ return ToolDefinition.make({
80
+ name: type,
81
+ description,
82
+ inputSchema: { type: "object", properties: {} },
83
+ native: { alibaba: { type } },
84
+ });
85
+ }
86
+ export * as Alibaba from "./alibaba.js";
@@ -237,9 +237,15 @@ export declare const routes: import("../route/client.js").Route<{
237
237
  readonly type: "enabled";
238
238
  readonly budget_tokens: number;
239
239
  readonly display?: "summarized" | "omitted" | undefined;
240
+ readonly block_binding?: {
241
+ readonly prefix_mismatch_behavior?: string | undefined;
242
+ } | undefined;
240
243
  } | {
241
244
  readonly type: "adaptive";
242
245
  readonly display?: "summarized" | "omitted" | undefined;
246
+ readonly block_binding?: {
247
+ readonly prefix_mismatch_behavior?: string | undefined;
248
+ } | undefined;
243
249
  } | {
244
250
  readonly type: "disabled";
245
251
  } | undefined;
@@ -221,9 +221,15 @@ export declare const routes: import("../route/client.js").Route<{
221
221
  readonly type: "enabled";
222
222
  readonly budget_tokens: number;
223
223
  readonly display?: "summarized" | "omitted" | undefined;
224
+ readonly block_binding?: {
225
+ readonly prefix_mismatch_behavior?: string | undefined;
226
+ } | undefined;
224
227
  } | {
225
228
  readonly type: "adaptive";
226
229
  readonly display?: "summarized" | "omitted" | undefined;
230
+ readonly block_binding?: {
231
+ readonly prefix_mismatch_behavior?: string | undefined;
232
+ } | undefined;
227
233
  } | {
228
234
  readonly type: "disabled";
229
235
  } | undefined;
@@ -235,9 +235,15 @@ export declare const routes: Route<{
235
235
  readonly type: "enabled";
236
236
  readonly budget_tokens: number;
237
237
  readonly display?: "summarized" | "omitted" | undefined;
238
+ readonly block_binding?: {
239
+ readonly prefix_mismatch_behavior?: string | undefined;
240
+ } | undefined;
238
241
  } | {
239
242
  readonly type: "adaptive";
240
243
  readonly display?: "summarized" | "omitted" | undefined;
244
+ readonly block_binding?: {
245
+ readonly prefix_mismatch_behavior?: string | undefined;
246
+ } | undefined;
241
247
  } | {
242
248
  readonly type: "disabled";
243
249
  } | undefined;
@@ -1,3 +1,4 @@
1
+ export * as Alibaba from "./alibaba.js";
1
2
  export * as Anthropic from "./anthropic.js";
2
3
  export * as AnthropicCompatible from "./anthropic-compatible.js";
3
4
  export * as AmazonBedrock from "./amazon-bedrock.js";
@@ -1,3 +1,4 @@
1
+ export * as Alibaba from "./alibaba.js";
1
2
  export * as Anthropic from "./anthropic.js";
2
3
  export * as AnthropicCompatible from "./anthropic-compatible.js";
3
4
  export * as AmazonBedrock from "./amazon-bedrock.js";
@@ -545,9 +545,15 @@ export declare const routes: (Route<{
545
545
  readonly type: "enabled";
546
546
  readonly budget_tokens: number;
547
547
  readonly display?: "summarized" | "omitted" | undefined;
548
+ readonly block_binding?: {
549
+ readonly prefix_mismatch_behavior?: string | undefined;
550
+ } | undefined;
548
551
  } | {
549
552
  readonly type: "adaptive";
550
553
  readonly display?: "summarized" | "omitted" | undefined;
554
+ readonly block_binding?: {
555
+ readonly prefix_mismatch_behavior?: string | undefined;
556
+ } | undefined;
551
557
  } | {
552
558
  readonly type: "disabled";
553
559
  } | undefined;
@@ -248,9 +248,15 @@ export declare const routes: (Route<{
248
248
  readonly type: "enabled";
249
249
  readonly budget_tokens: number;
250
250
  readonly display?: "summarized" | "omitted" | undefined;
251
+ readonly block_binding?: {
252
+ readonly prefix_mismatch_behavior?: string | undefined;
253
+ } | undefined;
251
254
  } | {
252
255
  readonly type: "adaptive";
253
256
  readonly display?: "summarized" | "omitted" | undefined;
257
+ readonly block_binding?: {
258
+ readonly prefix_mismatch_behavior?: string | undefined;
259
+ } | undefined;
254
260
  } | {
255
261
  readonly type: "disabled";
256
262
  } | undefined;
@@ -246,9 +246,15 @@ export declare const routes: (Route<{
246
246
  readonly type: "enabled";
247
247
  readonly budget_tokens: number;
248
248
  readonly display?: "summarized" | "omitted" | undefined;
249
+ readonly block_binding?: {
250
+ readonly prefix_mismatch_behavior?: string | undefined;
251
+ } | undefined;
249
252
  } | {
250
253
  readonly type: "adaptive";
251
254
  readonly display?: "summarized" | "omitted" | undefined;
255
+ readonly block_binding?: {
256
+ readonly prefix_mismatch_behavior?: string | undefined;
257
+ } | undefined;
252
258
  } | {
253
259
  readonly type: "disabled";
254
260
  } | undefined;
@@ -82,6 +82,8 @@ declare const LanguageModelCompatibility_base: Schema.Class<LanguageModelCompati
82
82
  readonly supportsStrictMode: Schema.optional<Schema.Boolean>;
83
83
  readonly zaiToolStream: Schema.optional<Schema.Boolean>;
84
84
  readonly requireSignature: Schema.optional<Schema.Boolean>;
85
+ /** Supports Anthropic's thinking-prefix mismatch controls. Overrides model-ID detection. */
86
+ readonly supportsThinkingBlockBinding: Schema.optional<Schema.Boolean>;
85
87
  }>, {}>;
86
88
  export declare class LanguageModelCompatibility extends LanguageModelCompatibility_base {
87
89
  }
@@ -109,6 +109,8 @@ export class LanguageModelCompatibility extends Schema.Class("LLM.LanguageModelC
109
109
  supportsStrictMode: Schema.optional(Schema.Boolean),
110
110
  zaiToolStream: Schema.optional(Schema.Boolean),
111
111
  requireSignature: Schema.optional(Schema.Boolean),
112
+ /** Supports Anthropic's thinking-prefix mismatch controls. Overrides model-ID detection. */
113
+ supportsThinkingBlockBinding: Schema.optional(Schema.Boolean),
112
114
  }) {
113
115
  }
114
116
  (function (LanguageModelCompatibility) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
- "version": "0.0.0-beta-19296",
3
+ "version": "0.0.0-beta-19378",
4
4
  "name": "@opencode/ai",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -30,7 +30,7 @@
30
30
  "devDependencies": {
31
31
  "@clack/prompts": "1.0.0-alpha.1",
32
32
  "@effect/platform-node": "4.0.0-rc.112",
33
- "@opencode/http-recorder": "0.0.0-beta-19296",
33
+ "@opencode/http-recorder": "0.0.0-beta-19378",
34
34
  "@tsconfig/bun": "1.0.9",
35
35
  "@types/bun": "1.4.0",
36
36
  "@typescript/native-preview": "7.0.0-dev.20251207.1",
@@ -40,7 +40,7 @@
40
40
  "@aws-sdk/credential-providers": "3.1057.0",
41
41
  "@smithy/eventstream-codec": "4.2.14",
42
42
  "@smithy/util-utf8": "4.2.2",
43
- "@opencode/schema": "0.0.0-beta-19296",
43
+ "@opencode/schema": "0.0.0-beta-19378",
44
44
  "aws4fetch": "1.0.20",
45
45
  "effect": "4.0.0-rc.112",
46
46
  "google-auth-library": "10.5.0"