@ai-sdk/alibaba 2.0.0-beta.1 → 2.0.0-beta.11

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/CHANGELOG.md CHANGED
@@ -1,5 +1,89 @@
1
1
  # @ai-sdk/alibaba
2
2
 
3
+ ## 2.0.0-beta.11
4
+
5
+ ### Patch Changes
6
+
7
+ - 74d520f: feat: migrate providers to support new top-level `reasoning` parameter
8
+ - Updated dependencies [74d520f]
9
+ - @ai-sdk/openai-compatible@3.0.0-beta.9
10
+
11
+ ## 2.0.0-beta.10
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [3887c70]
16
+ - @ai-sdk/provider-utils@5.0.0-beta.6
17
+ - @ai-sdk/provider@4.0.0-beta.4
18
+ - @ai-sdk/openai-compatible@3.0.0-beta.8
19
+
20
+ ## 2.0.0-beta.9
21
+
22
+ ### Patch Changes
23
+
24
+ - Updated dependencies [776b617]
25
+ - @ai-sdk/provider-utils@5.0.0-beta.5
26
+ - @ai-sdk/provider@4.0.0-beta.3
27
+ - @ai-sdk/openai-compatible@3.0.0-beta.7
28
+
29
+ ## 2.0.0-beta.8
30
+
31
+ ### Patch Changes
32
+
33
+ - Updated dependencies [61753c3]
34
+ - @ai-sdk/provider-utils@5.0.0-beta.4
35
+ - @ai-sdk/openai-compatible@3.0.0-beta.6
36
+
37
+ ## 2.0.0-beta.7
38
+
39
+ ### Patch Changes
40
+
41
+ - 811cd8e: fix(provider/alibaba): handle single-item content array cache control
42
+
43
+ ## 2.0.0-beta.6
44
+
45
+ ### Patch Changes
46
+
47
+ - Updated dependencies [f7d4f01]
48
+ - @ai-sdk/provider-utils@5.0.0-beta.3
49
+ - @ai-sdk/provider@4.0.0-beta.2
50
+ - @ai-sdk/openai-compatible@3.0.0-beta.5
51
+
52
+ ## 2.0.0-beta.5
53
+
54
+ ### Patch Changes
55
+
56
+ - Updated dependencies [5c2a5a2]
57
+ - @ai-sdk/provider@4.0.0-beta.1
58
+ - @ai-sdk/openai-compatible@3.0.0-beta.4
59
+ - @ai-sdk/provider-utils@5.0.0-beta.2
60
+
61
+ ## 2.0.0-beta.4
62
+
63
+ ### Patch Changes
64
+
65
+ - Updated dependencies [8f3e1da]
66
+ - @ai-sdk/openai-compatible@3.0.0-beta.3
67
+
68
+ ## 2.0.0-beta.3
69
+
70
+ ### Patch Changes
71
+
72
+ - 4ab27b9: chore(alibaba): update v3 specs to v4
73
+
74
+ ## 2.0.0-beta.2
75
+
76
+ ### Patch Changes
77
+
78
+ - 45b3d76: fix(security): prevent streaming tool calls from finalizing on parsable partial JSON
79
+
80
+ Streaming tool call arguments were finalized using `isParsableJson()` as a heuristic for completion. If partial accumulated JSON happened to be valid JSON before all chunks arrived, the tool call would be executed with incomplete arguments. Tool call finalization now only occurs in `flush()` after the stream is fully consumed.
81
+
82
+ - f7295cb: revert incorrect fix https://github.com/vercel/ai/pull/13172
83
+ - Updated dependencies [45b3d76]
84
+ - Updated dependencies [f7295cb]
85
+ - @ai-sdk/openai-compatible@3.0.0-beta.2
86
+
3
87
  ## 2.0.0-beta.1
4
88
 
5
89
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod/v4';
2
2
  import { FetchFunction } from '@ai-sdk/provider-utils';
3
- import { ProviderV3, LanguageModelV3, Experimental_VideoModelV3 } from '@ai-sdk/provider';
3
+ import { ProviderV4, LanguageModelV4, Experimental_VideoModelV4 } from '@ai-sdk/provider';
4
4
 
5
5
  type AlibabaChatModelId = 'qwen3-max' | 'qwen3-max-preview' | 'qwen-plus' | 'qwen-plus-latest' | 'qwen-flash' | 'qwen-turbo' | 'qwen-turbo-latest' | 'qwen3-235b-a22b' | 'qwen3-32b' | 'qwen3-30b-a3b' | 'qwen3-14b' | 'qwen3-next-80b-a3b-thinking' | 'qwen3-235b-a22b-thinking-2507' | 'qwen3-30b-a3b-thinking-2507' | 'qwq-plus' | 'qwq-plus-latest' | 'qwq-32b' | 'qwen-coder' | 'qwen3-coder-plus' | 'qwen3-coder-flash' | (string & {});
6
6
  declare const alibabaLanguageModelOptions: z.ZodObject<{
@@ -16,24 +16,24 @@ type AlibabaCacheControl = {
16
16
 
17
17
  type AlibabaVideoModelId = 'wan2.6-t2v' | 'wan2.5-t2v-preview' | 'wan2.6-i2v' | 'wan2.6-i2v-flash' | 'wan2.6-r2v' | 'wan2.6-r2v-flash' | (string & {});
18
18
 
19
- interface AlibabaProvider extends ProviderV3 {
20
- (modelId: AlibabaChatModelId): LanguageModelV3;
19
+ interface AlibabaProvider extends ProviderV4 {
20
+ (modelId: AlibabaChatModelId): LanguageModelV4;
21
21
  /**
22
22
  * Creates a model for text generation.
23
23
  */
24
- languageModel(modelId: AlibabaChatModelId): LanguageModelV3;
24
+ languageModel(modelId: AlibabaChatModelId): LanguageModelV4;
25
25
  /**
26
26
  * Creates a chat model for text generation.
27
27
  */
28
- chatModel(modelId: AlibabaChatModelId): LanguageModelV3;
28
+ chatModel(modelId: AlibabaChatModelId): LanguageModelV4;
29
29
  /**
30
30
  * Creates a model for video generation.
31
31
  */
32
- video(modelId: AlibabaVideoModelId): Experimental_VideoModelV3;
32
+ video(modelId: AlibabaVideoModelId): Experimental_VideoModelV4;
33
33
  /**
34
34
  * Creates a model for video generation.
35
35
  */
36
- videoModel(modelId: AlibabaVideoModelId): Experimental_VideoModelV3;
36
+ videoModel(modelId: AlibabaVideoModelId): Experimental_VideoModelV4;
37
37
  }
38
38
  interface AlibabaProviderSettings {
39
39
  /**
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod/v4';
2
2
  import { FetchFunction } from '@ai-sdk/provider-utils';
3
- import { ProviderV3, LanguageModelV3, Experimental_VideoModelV3 } from '@ai-sdk/provider';
3
+ import { ProviderV4, LanguageModelV4, Experimental_VideoModelV4 } from '@ai-sdk/provider';
4
4
 
5
5
  type AlibabaChatModelId = 'qwen3-max' | 'qwen3-max-preview' | 'qwen-plus' | 'qwen-plus-latest' | 'qwen-flash' | 'qwen-turbo' | 'qwen-turbo-latest' | 'qwen3-235b-a22b' | 'qwen3-32b' | 'qwen3-30b-a3b' | 'qwen3-14b' | 'qwen3-next-80b-a3b-thinking' | 'qwen3-235b-a22b-thinking-2507' | 'qwen3-30b-a3b-thinking-2507' | 'qwq-plus' | 'qwq-plus-latest' | 'qwq-32b' | 'qwen-coder' | 'qwen3-coder-plus' | 'qwen3-coder-flash' | (string & {});
6
6
  declare const alibabaLanguageModelOptions: z.ZodObject<{
@@ -16,24 +16,24 @@ type AlibabaCacheControl = {
16
16
 
17
17
  type AlibabaVideoModelId = 'wan2.6-t2v' | 'wan2.5-t2v-preview' | 'wan2.6-i2v' | 'wan2.6-i2v-flash' | 'wan2.6-r2v' | 'wan2.6-r2v-flash' | (string & {});
18
18
 
19
- interface AlibabaProvider extends ProviderV3 {
20
- (modelId: AlibabaChatModelId): LanguageModelV3;
19
+ interface AlibabaProvider extends ProviderV4 {
20
+ (modelId: AlibabaChatModelId): LanguageModelV4;
21
21
  /**
22
22
  * Creates a model for text generation.
23
23
  */
24
- languageModel(modelId: AlibabaChatModelId): LanguageModelV3;
24
+ languageModel(modelId: AlibabaChatModelId): LanguageModelV4;
25
25
  /**
26
26
  * Creates a chat model for text generation.
27
27
  */
28
- chatModel(modelId: AlibabaChatModelId): LanguageModelV3;
28
+ chatModel(modelId: AlibabaChatModelId): LanguageModelV4;
29
29
  /**
30
30
  * Creates a model for video generation.
31
31
  */
32
- video(modelId: AlibabaVideoModelId): Experimental_VideoModelV3;
32
+ video(modelId: AlibabaVideoModelId): Experimental_VideoModelV4;
33
33
  /**
34
34
  * Creates a model for video generation.
35
35
  */
36
- videoModel(modelId: AlibabaVideoModelId): Experimental_VideoModelV3;
36
+ videoModel(modelId: AlibabaVideoModelId): Experimental_VideoModelV4;
37
37
  }
38
38
  interface AlibabaProviderSettings {
39
39
  /**
package/dist/index.js CHANGED
@@ -18,13 +18,13 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
20
  // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
23
  VERSION: () => VERSION,
24
24
  alibaba: () => alibaba,
25
25
  createAlibaba: () => createAlibaba
26
26
  });
27
- module.exports = __toCommonJS(src_exports);
27
+ module.exports = __toCommonJS(index_exports);
28
28
 
29
29
  // src/alibaba-provider.ts
30
30
  var import_provider4 = require("@ai-sdk/provider");
@@ -89,7 +89,7 @@ function convertToAlibabaChatMessages({
89
89
  prompt,
90
90
  cacheControlValidator
91
91
  }) {
92
- var _a;
92
+ var _a, _b;
93
93
  const messages = [];
94
94
  for (const { role, content, ...message } of prompt) {
95
95
  const messageCacheControl = cacheControlValidator == null ? void 0 : cacheControlValidator.getCacheControl(
@@ -114,18 +114,12 @@ function convertToAlibabaChatMessages({
114
114
  break;
115
115
  }
116
116
  case "user": {
117
- const isSinglePart = content.length === 1;
118
- if (isSinglePart && content[0].type === "text" && !messageCacheControl) {
119
- messages.push({
120
- role: "user",
121
- content: content[0].text
122
- });
123
- break;
124
- }
125
117
  messages.push({
126
118
  role: "user",
127
- content: content.map((part) => {
128
- const partCacheControl = isSinglePart ? messageCacheControl : cacheControlValidator == null ? void 0 : cacheControlValidator.getCacheControl(part.providerOptions);
119
+ content: content.map((part, index) => {
120
+ var _a2;
121
+ const isLastPart = index === content.length - 1;
122
+ const partCacheControl = (_a2 = cacheControlValidator == null ? void 0 : cacheControlValidator.getCacheControl(part.providerOptions)) != null ? _a2 : isLastPart ? messageCacheControl : void 0;
129
123
  switch (part.type) {
130
124
  case "text": {
131
125
  return {
@@ -192,13 +186,13 @@ function convertToAlibabaChatMessages({
192
186
  const toolResponses = content.filter(
193
187
  (r) => r.type !== "tool-approval-response"
194
188
  );
195
- const isSinglePart = toolResponses.length === 1;
196
189
  for (let i = 0; i < toolResponses.length; i++) {
197
190
  const toolResponse = toolResponses[i];
198
191
  const output = toolResponse.output;
199
- const partCacheControl = isSinglePart ? messageCacheControl : cacheControlValidator == null ? void 0 : cacheControlValidator.getCacheControl(
192
+ const isLastPart = i === toolResponses.length - 1;
193
+ const partCacheControl = (_a = cacheControlValidator == null ? void 0 : cacheControlValidator.getCacheControl(
200
194
  toolResponse.providerOptions
201
- );
195
+ )) != null ? _a : isLastPart ? messageCacheControl : void 0;
202
196
  let contentValue;
203
197
  switch (output.type) {
204
198
  case "text":
@@ -206,7 +200,7 @@ function convertToAlibabaChatMessages({
206
200
  contentValue = output.value;
207
201
  break;
208
202
  case "execution-denied":
209
- contentValue = (_a = output.reason) != null ? _a : "Tool execution denied.";
203
+ contentValue = (_b = output.reason) != null ? _b : "Tool execution denied.";
210
204
  break;
211
205
  case "content":
212
206
  case "json":
@@ -272,7 +266,7 @@ var CacheControlValidator = class {
272
266
  // src/alibaba-chat-language-model.ts
273
267
  var AlibabaLanguageModel = class {
274
268
  constructor(modelId, config) {
275
- this.specificationVersion = "v3";
269
+ this.specificationVersion = "v4";
276
270
  this.supportedUrls = {
277
271
  "image/*": [/^https?:\/\/.*$/]
278
272
  };
@@ -297,6 +291,7 @@ var AlibabaLanguageModel = class {
297
291
  stopSequences,
298
292
  responseFormat,
299
293
  seed,
294
+ reasoning,
300
295
  providerOptions,
301
296
  tools,
302
297
  toolChoice
@@ -329,9 +324,11 @@ var AlibabaLanguageModel = class {
329
324
  description: responseFormat.description
330
325
  }
331
326
  } : { type: "json_object" } : void 0,
332
- // Alibaba-specific options
333
- ...(alibabaOptions == null ? void 0 : alibabaOptions.enableThinking) != null ? { enable_thinking: alibabaOptions.enableThinking } : {},
334
- ...(alibabaOptions == null ? void 0 : alibabaOptions.thinkingBudget) != null ? { thinking_budget: alibabaOptions.thinkingBudget } : {},
327
+ ...resolveAlibabaThinking({
328
+ reasoning,
329
+ alibabaOptions,
330
+ warnings
331
+ }),
335
332
  // Convert messages with cache control support
336
333
  messages: convertToAlibabaChatMessages({
337
334
  prompt,
@@ -626,6 +623,34 @@ var AlibabaLanguageModel = class {
626
623
  };
627
624
  }
628
625
  };
626
+ function resolveAlibabaThinking({
627
+ reasoning,
628
+ alibabaOptions,
629
+ warnings
630
+ }) {
631
+ if ((alibabaOptions == null ? void 0 : alibabaOptions.enableThinking) != null || (alibabaOptions == null ? void 0 : alibabaOptions.thinkingBudget) != null) {
632
+ return {
633
+ ...alibabaOptions.enableThinking != null ? { enable_thinking: alibabaOptions.enableThinking } : {},
634
+ ...alibabaOptions.thinkingBudget != null ? { thinking_budget: alibabaOptions.thinkingBudget } : {}
635
+ };
636
+ }
637
+ if (!(0, import_provider_utils2.isCustomReasoning)(reasoning)) {
638
+ return {};
639
+ }
640
+ if (reasoning === "none") {
641
+ return { enable_thinking: false };
642
+ }
643
+ const thinkingBudget = (0, import_provider_utils2.mapReasoningToProviderBudget)({
644
+ reasoning,
645
+ maxOutputTokens: 16384,
646
+ maxReasoningBudget: 16384,
647
+ warnings
648
+ });
649
+ return {
650
+ enable_thinking: true,
651
+ ...thinkingBudget != null ? { thinking_budget: thinkingBudget } : {}
652
+ };
653
+ }
629
654
  var alibabaUsageSchema = import_v42.z.object({
630
655
  prompt_tokens: import_v42.z.number(),
631
656
  completion_tokens: import_v42.z.number(),
@@ -763,7 +788,7 @@ var AlibabaVideoModel = class {
763
788
  constructor(modelId, config) {
764
789
  this.modelId = modelId;
765
790
  this.config = config;
766
- this.specificationVersion = "v3";
791
+ this.specificationVersion = "v4";
767
792
  this.maxVideosPerCall = 1;
768
793
  }
769
794
  get provider() {
@@ -970,7 +995,7 @@ var AlibabaVideoModel = class {
970
995
  };
971
996
 
972
997
  // src/version.ts
973
- var VERSION = "2.0.0-beta.1";
998
+ var VERSION = "2.0.0-beta.11";
974
999
 
975
1000
  // src/alibaba-provider.ts
976
1001
  var alibabaErrorDataSchema = import_v44.z.object({
@@ -1023,7 +1048,7 @@ function createAlibaba(options = {}) {
1023
1048
  }
1024
1049
  return createLanguageModel(modelId);
1025
1050
  };
1026
- provider.specificationVersion = "v3";
1051
+ provider.specificationVersion = "v4";
1027
1052
  provider.languageModel = createLanguageModel;
1028
1053
  provider.chatModel = createLanguageModel;
1029
1054
  provider.video = createVideoModel;