@ai-sdk/alibaba 2.0.72 → 2.0.74

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,31 @@
1
1
  # @ai-sdk/alibaba
2
2
 
3
+ ## 2.0.74
4
+
5
+ ### Patch Changes
6
+
7
+ - 43ad966: Report `interrupted` when a stream ends cleanly without its provider completion signal, preserving partial output without emitting an error solely for the interruption.
8
+
9
+ This applies to OpenAI (Chat, Responses, and Completions), Anthropic, Google (Generate Content and Interactions), Alibaba, Amazon Bedrock Converse, Cohere, DeepSeek, Groq, Hugging Face Responses, Mistral Chat, Moonshot AI, Open Responses, Perplexity, and xAI Responses. It also covers cutoffs in later Anthropic messages and Google automatic continuations.
10
+
11
+ **Compatibility notice:** These streams previously fell back to `other` or omitted the finish part. Applications must now handle `interrupted` in finish-reason switches, mappings, and custom validation. Check `finishReason === 'interrupted'` to detect incomplete responses; interruption alone does not trigger error handling.
12
+
13
+ Explicit unknown completion reasons still map to `other`. Actual provider, parsing, and transport errors retain their error paths; affected error paths that previously left the finish reason as `other` now report `error`. OpenAI-compatible remains unchanged.
14
+
15
+ - Updated dependencies [10026d1]
16
+ - @ai-sdk/provider@4.0.32
17
+ - @ai-sdk/provider-utils@5.0.66
18
+
19
+ ## 2.0.73
20
+
21
+ ### Patch Changes
22
+
23
+ - 39a776b: Add a shared encodePathSegment helper and use it to encode provider-returned identifiers in credentialed follow-up request paths.
24
+ - debdc6a: Defer construction of provider validation schemas until first use to reduce package import time.
25
+ - Updated dependencies [b089ce8]
26
+ - Updated dependencies [39a776b]
27
+ - @ai-sdk/provider-utils@5.0.65
28
+
3
29
  ## 2.0.72
4
30
 
5
31
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,15 +1,14 @@
1
1
  import { EmbeddingModelV4, Experimental_VideoModelV4, LanguageModelV4, ProviderV4 } from "@ai-sdk/provider";
2
- import { FetchFunction } from "@ai-sdk/provider-utils";
3
- import { z } from "zod/v4";
2
+ import { FetchFunction, InferSchema } from "@ai-sdk/provider-utils";
4
3
  //#region src/alibaba-chat-language-model-options.d.ts
5
4
  type AlibabaChatModelId = 'qwen3.7-max' | '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
- declare const alibabaLanguageModelChatOptions: z.ZodObject<{
7
- enableThinking: z.ZodOptional<z.ZodBoolean>;
8
- thinkingBudget: z.ZodOptional<z.ZodNumber>;
9
- preserveThinking: z.ZodOptional<z.ZodBoolean>;
10
- parallelToolCalls: z.ZodOptional<z.ZodBoolean>;
11
- }, z.core.$strip>;
12
- type AlibabaLanguageModelChatOptions = z.infer<typeof alibabaLanguageModelChatOptions>;
5
+ declare const alibabaLanguageModelChatOptions: import("@ai-sdk/provider-utils").LazySchema<{
6
+ enableThinking?: boolean | undefined;
7
+ thinkingBudget?: number | undefined;
8
+ preserveThinking?: boolean | undefined;
9
+ parallelToolCalls?: boolean | undefined;
10
+ }>;
11
+ type AlibabaLanguageModelChatOptions = InferSchema<typeof alibabaLanguageModelChatOptions>;
13
12
  //#endregion
14
13
  //#region src/alibaba-chat-prompt.d.ts
15
14
  type AlibabaCacheControl = {
@@ -18,19 +17,12 @@ type AlibabaCacheControl = {
18
17
  //#endregion
19
18
  //#region src/alibaba-embedding-model-options.d.ts
20
19
  type AlibabaEmbeddingModelId = 'text-embedding-v4' | 'text-embedding-v3' | (string & {});
21
- declare const alibabaEmbeddingModelOptions: z.ZodObject<{
22
- textType: z.ZodOptional<z.ZodEnum<{
23
- query: "query";
24
- document: "document";
25
- }>>;
26
- dimension: z.ZodOptional<z.ZodNumber>;
27
- outputType: z.ZodOptional<z.ZodEnum<{
28
- dense: "dense";
29
- sparse: "sparse";
30
- "dense&sparse": "dense&sparse";
31
- }>>;
32
- }, z.core.$strip>;
33
- type AlibabaEmbeddingModelOptions = z.infer<typeof alibabaEmbeddingModelOptions>;
20
+ declare const alibabaEmbeddingModelOptions: import("@ai-sdk/provider-utils").LazySchema<{
21
+ textType?: "query" | "document" | undefined;
22
+ dimension?: number | undefined;
23
+ outputType?: "dense" | "sparse" | "dense&sparse" | undefined;
24
+ }>;
25
+ type AlibabaEmbeddingModelOptions = InferSchema<typeof alibabaEmbeddingModelOptions>;
34
26
  //#endregion
35
27
  //#region src/alibaba-video-settings.d.ts
36
28
  type AlibabaVideoModelId = 'wan2.6-t2v' | 'wan2.5-t2v-preview' | 'wan2.7-t2v' | 'wan2.7-t2v-2026-06-12' | 'wan2.6-i2v' | 'wan2.6-i2v-flash' | 'wan2.6-r2v' | 'wan2.6-r2v-flash' | 'wan2.7-r2v' | 'wan2.7-r2v-2026-06-12' | 'wan3.0-video' | (string & {});
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/alibaba-chat-language-model-options.ts","../src/alibaba-chat-prompt.ts","../src/alibaba-embedding-model-options.ts","../src/alibaba-video-settings.ts","../src/alibaba-provider.ts","../src/alibaba-video-model-options.ts","../src/convert-alibaba-usage.ts","../src/version.ts"],"mappings":";;;;KAGY;cA4BC,iCAA+B,EAAA;;;;;GA8B1C,EAAA,KAAA;KAEU,kCAAkC,EAAE,aACvC;;;KChEG;EAAwB;;;;KCExB;cAKC,8BAA4B,EAAA;;;;;;;;;;;GAqBvC,EAAA,KAAA;KAEU,+BAA+B,EAAE,aACpC;;;KC9BG;;;UCuBK,wBAAwB;GACtC,SAAS,qBAAqB;;;;EAK/B,cAAc,SAAS,qBAAqB;;;;EAK5C,UAAU,SAAS,qBAAqB;;;;EAKxC,UAAU,SAAS,0BAA0B;;;;EAK7C,eAAe,SAAS,0BAA0B;;;;EAKlD,MAAM,SAAS,sBAAsB;;;;EAKrC,WAAW,SAAS,sBAAsB;;UAG3B;;;;;EAKf;;;;;;EAOA;;;;;;EAOA;;;;;EAMA;;;;EAKA,UAAU;;;;;EAMV,QAAQ;;;;;;;EAQR;;;;;wBAMc,cACd,UAAS,0BACR;qBA4EU,SAAO;;;KCvLR;;EAEV;;EAEA;;EAEA;;;;;EAKA;;EAEA;;;;;EAKA;;;;;;EAMA;;;;;;;;;;;EAWA,QAAQ;IACN;;IASA;;IAEA;;;;;;EAMF;;EAEA;;EAEA;GACC;;;;;;;;;;;;;KCjDS;EACV;EACA;EACA;EACA;IACE;IACA;;;;;;;;IAQA;;EAEF;IACE;;;;;qBC3BS"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/alibaba-chat-language-model-options.ts","../src/alibaba-chat-prompt.ts","../src/alibaba-embedding-model-options.ts","../src/alibaba-video-settings.ts","../src/alibaba-provider.ts","../src/alibaba-video-model-options.ts","../src/convert-alibaba-usage.ts","../src/version.ts"],"mappings":";;;KAQY;cA4BC,kEAA+B;;;;;;KAoChC,kCAAkC,mBACrC;;;KCzEG;EAAwB;;;;KCOxB;cAKC,+DAA4B;;;;;KA2B7B,+BAA+B,mBAClC;;;KCvCG;;;UCuBK,wBAAwB;GACtC,SAAS,qBAAqB;;;;EAK/B,cAAc,SAAS,qBAAqB;;;;EAK5C,UAAU,SAAS,qBAAqB;;;;EAKxC,UAAU,SAAS,0BAA0B;;;;EAK7C,eAAe,SAAS,0BAA0B;;;;EAKlD,MAAM,SAAS,sBAAsB;;;;EAKrC,WAAW,SAAS,sBAAsB;;UAG3B;;;;;EAKf;;;;;;EAOA;;;;;;EAOA;;;;;EAMA;;;;EAKA,UAAU;;;;;EAMV,QAAQ;;;;;;;EAQR;;;;;wBAMc,cACd,UAAS,0BACR;qBA4EU,SAAO;;;KCvLR;;EAEV;;EAEA;;EAEA;;;;;EAKA;;EAEA;;;;;EAKA;;;;;;EAMA;;;;;;;;;;;EAWA,QAAQ;IACN;;IASA;;IAEA;;;;;;EAMF;;EAEA;;EAEA;GACC;;;;;;;;;;;;;KCjDS;EACV;EACA;EACA;EACA;IACE;IACA;;;;;;;;IAQA;;EAEF;IACE;;;;;qBC3BS"}
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { AISDKError, NoSuchModelError, TooManyEmbeddingValuesForCallError, UnsupportedFunctionalityError } from "@ai-sdk/provider";
2
- import { StreamingToolCallTracker, WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, combineHeaders, convertImageModelFileToDataUri, convertToBase64, convertUint8ArrayToBase64, createEventSourceResponseHandler, createJsonErrorResponseHandler, createJsonResponseHandler, createLanguageModelResponseMetadata, createNullLanguageModelUsage, generateId, getFromApi, getTopLevelMediaType, injectJsonInstructionIntoMessages, isCustomReasoning, lazySchema, loadApiKey, mapReasoningToProviderBudget, parseProviderOptions, postJsonToApi, resolve, resolveFullMediaType, serializeModelOptions, withUserAgentSuffix, withoutTrailingSlash, zodSchema } from "@ai-sdk/provider-utils";
2
+ import { StreamingToolCallTracker, WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, combineHeaders, convertImageModelFileToDataUri, convertToBase64, convertUint8ArrayToBase64, createEventSourceResponseHandler, createJsonErrorResponseHandler, createJsonResponseHandler, createLanguageModelResponseMetadata, createNullLanguageModelUsage, encodePathSegment, generateId, getFromApi, getTopLevelMediaType, injectJsonInstructionIntoMessages, isCustomReasoning, lazySchema, loadApiKey, mapReasoningToProviderBudget, parseProviderOptions, postJsonToApi, resolve, resolveFullMediaType, serializeModelOptions, withUserAgentSuffix, withoutTrailingSlash, zodSchema } from "@ai-sdk/provider-utils";
3
3
  import { z } from "zod/v4";
4
4
  //#region src/alibaba-chat-language-model-options.ts
5
- const alibabaLanguageModelChatOptions = z.object({
5
+ const alibabaLanguageModelChatOptions = lazySchema(() => zodSchema(z.object({
6
6
  /**
7
7
  * Enable thinking/reasoning mode for supported models.
8
8
  * When enabled, the model generates reasoning content before the response.
@@ -29,14 +29,14 @@ const alibabaLanguageModelChatOptions = z.object({
29
29
  * @default true
30
30
  */
31
31
  parallelToolCalls: z.boolean().optional()
32
- });
32
+ })));
33
33
  //#endregion
34
34
  //#region src/alibaba-error.ts
35
- const alibabaErrorDataSchema = z.object({ error: z.object({
35
+ const alibabaErrorDataSchema = lazySchema(() => zodSchema(z.object({ error: z.object({
36
36
  message: z.string(),
37
37
  code: z.string().nullish(),
38
38
  type: z.string().nullish()
39
- }) });
39
+ }) })));
40
40
  const alibabaFailedResponseHandler = createJsonErrorResponseHandler({
41
41
  errorSchema: alibabaErrorDataSchema,
42
42
  errorToMessage: (data) => data.error.message
@@ -489,7 +489,7 @@ var AlibabaChatLanguageModel = class AlibabaChatLanguageModel {
489
489
  fetch: this.config.fetch
490
490
  });
491
491
  let finishReason = {
492
- unified: "other",
492
+ unified: "interrupted",
493
493
  raw: void 0
494
494
  };
495
495
  let usage = void 0;
@@ -512,6 +512,10 @@ var AlibabaChatLanguageModel = class AlibabaChatLanguageModel {
512
512
  rawValue: chunk.rawValue
513
513
  });
514
514
  if (!chunk.success) {
515
+ finishReason = {
516
+ unified: "error",
517
+ raw: void 0
518
+ };
515
519
  controller.enqueue({
516
520
  type: "error",
517
521
  error: chunk.error
@@ -638,7 +642,7 @@ function resolveAlibabaThinking({ reasoning, alibabaOptions, warnings }) {
638
642
  * Reference for schemas below:
639
643
  * https://www.alibabacloud.com/help/en/model-studio/qwen-api-via-openai-chat-completions
640
644
  */
641
- const alibabaUsageSchema = z.looseObject({
645
+ const alibabaUsageSchema = () => z.looseObject({
642
646
  prompt_tokens: z.number(),
643
647
  completion_tokens: z.number(),
644
648
  total_tokens: z.number(),
@@ -649,7 +653,7 @@ const alibabaUsageSchema = z.looseObject({
649
653
  }).nullish(),
650
654
  completion_tokens_details: z.looseObject({ reasoning_tokens: z.number().nullish() }).nullish()
651
655
  });
652
- const alibabaChatResponseSchema = z.object({
656
+ const alibabaChatResponseSchema = lazySchema(() => zodSchema(z.object({
653
657
  id: z.string().nullish(),
654
658
  created: z.number().nullish(),
655
659
  model: z.string().nullish(),
@@ -670,9 +674,9 @@ const alibabaChatResponseSchema = z.object({
670
674
  finish_reason: z.string().nullish(),
671
675
  index: z.number()
672
676
  })),
673
- usage: alibabaUsageSchema.nullish()
674
- });
675
- const alibabaChatChunkSchema = z.object({
677
+ usage: alibabaUsageSchema().nullish()
678
+ })));
679
+ const alibabaChatChunkSchema = lazySchema(() => zodSchema(z.object({
676
680
  id: z.string().nullish(),
677
681
  created: z.number().nullish(),
678
682
  model: z.string().nullish(),
@@ -694,11 +698,11 @@ const alibabaChatChunkSchema = z.object({
694
698
  finish_reason: z.string().nullish(),
695
699
  index: z.number()
696
700
  })),
697
- usage: alibabaUsageSchema.nullish()
698
- });
701
+ usage: alibabaUsageSchema().nullish()
702
+ })));
699
703
  //#endregion
700
704
  //#region src/alibaba-embedding-model-options.ts
701
- const alibabaEmbeddingModelOptions = z.object({
705
+ const alibabaEmbeddingModelOptions = lazySchema(() => zodSchema(z.object({
702
706
  /**
703
707
  * Differentiates query text from document text for asymmetric retrieval tasks.
704
708
  * Defaults to `document`.
@@ -721,7 +725,7 @@ const alibabaEmbeddingModelOptions = z.object({
721
725
  "sparse",
722
726
  "dense&sparse"
723
727
  ]).optional()
724
- });
728
+ })));
725
729
  //#endregion
726
730
  //#region src/alibaba-embedding-model.ts
727
731
  const alibabaEmbeddingFailedResponseHandler = createJsonErrorResponseHandler({
@@ -802,19 +806,19 @@ var AlibabaEmbeddingModel = class AlibabaEmbeddingModel {
802
806
  };
803
807
  }
804
808
  };
805
- const alibabaTextEmbeddingSparseEmbeddingSchema = z.object({
809
+ const alibabaTextEmbeddingSparseEmbeddingSchema = () => z.object({
806
810
  index: z.number(),
807
811
  value: z.number(),
808
812
  token: z.string().nullish()
809
813
  });
810
- const alibabaTextEmbeddingResponseSchema = z.object({
814
+ const alibabaTextEmbeddingResponseSchema = lazySchema(() => zodSchema(z.object({
811
815
  output: z.object({ embeddings: z.array(z.object({
812
816
  embedding: z.array(z.number()),
813
817
  text_index: z.number(),
814
- sparse_embedding: z.array(alibabaTextEmbeddingSparseEmbeddingSchema).nullish()
818
+ sparse_embedding: z.array(alibabaTextEmbeddingSparseEmbeddingSchema()).nullish()
815
819
  })) }),
816
820
  usage: z.object({ total_tokens: z.number() }).nullish()
817
- });
821
+ })));
818
822
  //#endregion
819
823
  //#region src/alibaba-video-model-options.ts
820
824
  const alibabaVideoModelOptionsSchema = lazySchema(() => zodSchema(z.looseObject({
@@ -851,23 +855,23 @@ const alibabaVideoModelOptionsSchema = lazySchema(() => zodSchema(z.looseObject(
851
855
  })));
852
856
  //#endregion
853
857
  //#region src/alibaba-video-model.ts
854
- const alibabaVideoErrorSchema = z.object({
858
+ const alibabaVideoErrorSchema = lazySchema(() => zodSchema(z.object({
855
859
  code: z.string().nullish(),
856
860
  message: z.string(),
857
861
  request_id: z.string().nullish()
858
- });
862
+ })));
859
863
  const alibabaVideoFailedResponseHandler = createJsonErrorResponseHandler({
860
864
  errorSchema: alibabaVideoErrorSchema,
861
865
  errorToMessage: (data) => data.message
862
866
  });
863
- const alibabaVideoCreateTaskSchema = z.object({
867
+ const alibabaVideoCreateTaskSchema = lazySchema(() => zodSchema(z.object({
864
868
  output: z.object({
865
869
  task_status: z.string(),
866
870
  task_id: z.string()
867
871
  }).nullish(),
868
872
  request_id: z.string().nullish()
869
- });
870
- const alibabaVideoTaskStatusSchema = z.object({
873
+ })));
874
+ const alibabaVideoTaskStatusSchema = lazySchema(() => zodSchema(z.object({
871
875
  output: z.object({
872
876
  task_id: z.string(),
873
877
  task_status: z.string(),
@@ -890,7 +894,7 @@ const alibabaVideoTaskStatusSchema = z.object({
890
894
  ratio: z.string().nullish()
891
895
  }).nullish(),
892
896
  request_id: z.string().nullish()
893
- });
897
+ })));
894
898
  function detectMode(modelId) {
895
899
  if (modelId.includes("-i2v")) return "i2v";
896
900
  if (modelId.includes("-r2v")) return "r2v";
@@ -1186,7 +1190,7 @@ var AlibabaVideoModel = class {
1186
1190
  const currentDate = this.config._internal?.currentDate?.() ?? /* @__PURE__ */ new Date();
1187
1191
  const { taskId } = options.operation;
1188
1192
  const { value: statusResponse, responseHeaders } = await getFromApi({
1189
- url: `${this.config.baseURL}/api/v1/tasks/${taskId}`,
1193
+ url: `${this.config.baseURL}/api/v1/tasks/${encodePathSegment(taskId)}`,
1190
1194
  validateUrl: false,
1191
1195
  headers: combineHeaders(await resolve(this.config.headers), options.headers),
1192
1196
  successfulResponseHandler: createJsonResponseHandler(alibabaVideoTaskStatusSchema),
@@ -1217,7 +1221,7 @@ var AlibabaVideoModel = class {
1217
1221
  };
1218
1222
  //#endregion
1219
1223
  //#region src/version.ts
1220
- const VERSION = "2.0.72";
1224
+ const VERSION = "2.0.74";
1221
1225
  //#endregion
1222
1226
  //#region src/alibaba-provider.ts
1223
1227
  /**