@ai-sdk/alibaba 1.0.68 → 1.0.69

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/index.mjs CHANGED
@@ -18,6 +18,8 @@ import {
18
18
  InvalidResponseDataError
19
19
  } from "@ai-sdk/provider";
20
20
  import {
21
+ lazySchema as lazySchema3,
22
+ zodSchema as zodSchema3,
21
23
  combineHeaders,
22
24
  createEventSourceResponseHandler,
23
25
  createJsonResponseHandler,
@@ -29,46 +31,62 @@ import {
29
31
  import { z as z3 } from "zod/v4";
30
32
 
31
33
  // src/alibaba-chat-options.ts
34
+ import {
35
+ lazySchema,
36
+ zodSchema
37
+ } from "@ai-sdk/provider-utils";
32
38
  import { z } from "zod/v4";
33
- var alibabaLanguageModelOptions = z.object({
34
- /**
35
- * Enable thinking/reasoning mode for supported models.
36
- * When enabled, the model generates reasoning content before the response.
37
- *
38
- * @default false
39
- */
40
- enableThinking: z.boolean().optional(),
41
- /**
42
- * Maximum number of reasoning tokens to generate.
43
- */
44
- thinkingBudget: z.number().positive().optional(),
45
- /**
46
- * Whether to preserve reasoning from previous assistant messages.
47
- *
48
- * When enabled, historical reasoning is sent separately as
49
- * `reasoning_content` and Alibaba receives `preserve_thinking: true`.
50
- * Defaults to `true` for models that support preserved thinking; set to
51
- * `false` to opt out.
52
- */
53
- preserveThinking: z.boolean().optional(),
54
- /**
55
- * Whether to enable parallel function calling during tool use.
56
- *
57
- * @default true
58
- */
59
- parallelToolCalls: z.boolean().optional()
60
- });
39
+ var alibabaLanguageModelOptions = lazySchema(
40
+ () => zodSchema(
41
+ z.object({
42
+ /**
43
+ * Enable thinking/reasoning mode for supported models.
44
+ * When enabled, the model generates reasoning content before the response.
45
+ *
46
+ * @default false
47
+ */
48
+ enableThinking: z.boolean().optional(),
49
+ /**
50
+ * Maximum number of reasoning tokens to generate.
51
+ */
52
+ thinkingBudget: z.number().positive().optional(),
53
+ /**
54
+ * Whether to preserve reasoning from previous assistant messages.
55
+ *
56
+ * When enabled, historical reasoning is sent separately as
57
+ * `reasoning_content` and Alibaba receives `preserve_thinking: true`.
58
+ * Defaults to `true` for models that support preserved thinking; set to
59
+ * `false` to opt out.
60
+ */
61
+ preserveThinking: z.boolean().optional(),
62
+ /**
63
+ * Whether to enable parallel function calling during tool use.
64
+ *
65
+ * @default true
66
+ */
67
+ parallelToolCalls: z.boolean().optional()
68
+ })
69
+ )
70
+ );
61
71
 
62
72
  // src/alibaba-error.ts
63
- import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
73
+ import {
74
+ lazySchema as lazySchema2,
75
+ zodSchema as zodSchema2,
76
+ createJsonErrorResponseHandler
77
+ } from "@ai-sdk/provider-utils";
64
78
  import { z as z2 } from "zod/v4";
65
- var alibabaErrorDataSchema = z2.object({
66
- error: z2.object({
67
- message: z2.string(),
68
- code: z2.string().nullish(),
69
- type: z2.string().nullish()
70
- })
71
- });
79
+ var alibabaErrorDataSchema = lazySchema2(
80
+ () => zodSchema2(
81
+ z2.object({
82
+ error: z2.object({
83
+ message: z2.string(),
84
+ code: z2.string().nullish(),
85
+ type: z2.string().nullish()
86
+ })
87
+ })
88
+ )
89
+ );
72
90
  var alibabaFailedResponseHandler = createJsonErrorResponseHandler({
73
91
  errorSchema: alibabaErrorDataSchema,
74
92
  errorToMessage: (data) => data.error.message
@@ -696,7 +714,7 @@ var AlibabaLanguageModel = class {
696
714
  };
697
715
  }
698
716
  };
699
- var alibabaUsageSchema = z3.object({
717
+ var alibabaUsageSchema = () => z3.object({
700
718
  prompt_tokens: z3.number(),
701
719
  completion_tokens: z3.number(),
702
720
  total_tokens: z3.number(),
@@ -708,65 +726,73 @@ var alibabaUsageSchema = z3.object({
708
726
  reasoning_tokens: z3.number().nullish()
709
727
  }).nullish()
710
728
  });
711
- var alibabaChatResponseSchema = z3.object({
712
- id: z3.string().nullish(),
713
- created: z3.number().nullish(),
714
- model: z3.string().nullish(),
715
- choices: z3.array(
729
+ var alibabaChatResponseSchema = lazySchema3(
730
+ () => zodSchema3(
716
731
  z3.object({
717
- message: z3.object({
718
- role: z3.literal("assistant").nullish(),
719
- content: z3.string().nullish(),
720
- reasoning_content: z3.string().nullish(),
721
- // Alibaba thinking mode
722
- tool_calls: z3.array(
723
- z3.object({
724
- id: z3.string(),
725
- type: z3.literal("function"),
726
- function: z3.object({
727
- name: z3.string(),
728
- arguments: z3.string()
729
- })
730
- })
731
- ).nullish()
732
- }),
733
- finish_reason: z3.string().nullish(),
734
- index: z3.number()
732
+ id: z3.string().nullish(),
733
+ created: z3.number().nullish(),
734
+ model: z3.string().nullish(),
735
+ choices: z3.array(
736
+ z3.object({
737
+ message: z3.object({
738
+ role: z3.literal("assistant").nullish(),
739
+ content: z3.string().nullish(),
740
+ reasoning_content: z3.string().nullish(),
741
+ // Alibaba thinking mode
742
+ tool_calls: z3.array(
743
+ z3.object({
744
+ id: z3.string(),
745
+ type: z3.literal("function"),
746
+ function: z3.object({
747
+ name: z3.string(),
748
+ arguments: z3.string()
749
+ })
750
+ })
751
+ ).nullish()
752
+ }),
753
+ finish_reason: z3.string().nullish(),
754
+ index: z3.number()
755
+ })
756
+ ),
757
+ usage: alibabaUsageSchema().nullish()
735
758
  })
736
- ),
737
- usage: alibabaUsageSchema.nullish()
738
- });
739
- var alibabaChatChunkSchema = z3.object({
740
- id: z3.string().nullish(),
741
- created: z3.number().nullish(),
742
- model: z3.string().nullish(),
743
- choices: z3.array(
759
+ )
760
+ );
761
+ var alibabaChatChunkSchema = lazySchema3(
762
+ () => zodSchema3(
744
763
  z3.object({
745
- delta: z3.object({
746
- role: z3.enum(["assistant"]).nullish(),
747
- content: z3.string().nullish(),
748
- reasoning_content: z3.string().nullish(),
749
- // Alibaba thinking mode delta
750
- tool_calls: z3.array(
751
- z3.object({
752
- index: z3.number().nullish(),
753
- // Index for accumulating tool calls
754
- id: z3.string().nullish(),
755
- type: z3.literal("function").nullish(),
756
- function: z3.object({
757
- name: z3.string().nullish(),
758
- arguments: z3.string().nullish()
759
- }).nullish()
760
- })
761
- ).nullish()
762
- }),
763
- finish_reason: z3.string().nullish(),
764
- index: z3.number()
764
+ id: z3.string().nullish(),
765
+ created: z3.number().nullish(),
766
+ model: z3.string().nullish(),
767
+ choices: z3.array(
768
+ z3.object({
769
+ delta: z3.object({
770
+ role: z3.enum(["assistant"]).nullish(),
771
+ content: z3.string().nullish(),
772
+ reasoning_content: z3.string().nullish(),
773
+ // Alibaba thinking mode delta
774
+ tool_calls: z3.array(
775
+ z3.object({
776
+ index: z3.number().nullish(),
777
+ // Index for accumulating tool calls
778
+ id: z3.string().nullish(),
779
+ type: z3.literal("function").nullish(),
780
+ function: z3.object({
781
+ name: z3.string().nullish(),
782
+ arguments: z3.string().nullish()
783
+ }).nullish()
784
+ })
785
+ ).nullish()
786
+ }),
787
+ finish_reason: z3.string().nullish(),
788
+ index: z3.number()
789
+ })
790
+ ),
791
+ usage: alibabaUsageSchema().nullish()
792
+ // Usage only appears in final chunk
765
793
  })
766
- ),
767
- usage: alibabaUsageSchema.nullish()
768
- // Usage only appears in final chunk
769
- });
794
+ )
795
+ );
770
796
 
771
797
  // src/alibaba-embedding-model.ts
772
798
  import {
@@ -774,6 +800,8 @@ import {
774
800
  UnsupportedFunctionalityError as UnsupportedFunctionalityError2
775
801
  } from "@ai-sdk/provider";
776
802
  import {
803
+ lazySchema as lazySchema5,
804
+ zodSchema as zodSchema5,
777
805
  combineHeaders as combineHeaders2,
778
806
  createJsonErrorResponseHandler as createJsonErrorResponseHandler2,
779
807
  createJsonResponseHandler as createJsonResponseHandler2,
@@ -783,27 +811,35 @@ import {
783
811
  import { z as z5 } from "zod/v4";
784
812
 
785
813
  // src/alibaba-embedding-options.ts
814
+ import {
815
+ lazySchema as lazySchema4,
816
+ zodSchema as zodSchema4
817
+ } from "@ai-sdk/provider-utils";
786
818
  import { z as z4 } from "zod/v4";
787
- var alibabaEmbeddingModelOptions = z4.object({
788
- /**
789
- * Differentiates query text from document text for asymmetric retrieval tasks.
790
- * Defaults to `document`.
791
- */
792
- textType: z4.enum(["query", "document"]).optional(),
793
- /**
794
- * The dimension of the output embedding vectors. Defaults to 1024.
795
- *
796
- * `text-embedding-v4` also supports 1536 and 2048 dimensions.
797
- */
798
- dimension: z4.number().optional(),
799
- /**
800
- * The output vector type. Defaults to `dense`.
801
- *
802
- * Sparse-only output is not supported by the AI SDK embedding interface,
803
- * which requires dense number arrays.
804
- */
805
- outputType: z4.enum(["dense", "sparse", "dense&sparse"]).optional()
806
- });
819
+ var alibabaEmbeddingModelOptions = lazySchema4(
820
+ () => zodSchema4(
821
+ z4.object({
822
+ /**
823
+ * Differentiates query text from document text for asymmetric retrieval tasks.
824
+ * Defaults to `document`.
825
+ */
826
+ textType: z4.enum(["query", "document"]).optional(),
827
+ /**
828
+ * The dimension of the output embedding vectors. Defaults to 1024.
829
+ *
830
+ * `text-embedding-v4` also supports 1536 and 2048 dimensions.
831
+ */
832
+ dimension: z4.number().optional(),
833
+ /**
834
+ * The output vector type. Defaults to `dense`.
835
+ *
836
+ * Sparse-only output is not supported by the AI SDK embedding interface,
837
+ * which requires dense number arrays.
838
+ */
839
+ outputType: z4.enum(["dense", "sparse", "dense&sparse"]).optional()
840
+ })
841
+ )
842
+ );
807
843
 
808
844
  // src/alibaba-embedding-model.ts
809
845
  var alibabaEmbeddingFailedResponseHandler = createJsonErrorResponseHandler2({
@@ -897,25 +933,29 @@ var AlibabaEmbeddingModel = class {
897
933
  };
898
934
  }
899
935
  };
900
- var alibabaTextEmbeddingSparseEmbeddingSchema = z5.object({
936
+ var alibabaTextEmbeddingSparseEmbeddingSchema = () => z5.object({
901
937
  index: z5.number(),
902
938
  value: z5.number(),
903
939
  token: z5.string().nullish()
904
940
  });
905
- var alibabaTextEmbeddingResponseSchema = z5.object({
906
- output: z5.object({
907
- embeddings: z5.array(
908
- z5.object({
909
- embedding: z5.array(z5.number()),
910
- text_index: z5.number(),
911
- sparse_embedding: z5.array(alibabaTextEmbeddingSparseEmbeddingSchema).nullish()
912
- })
913
- )
914
- }),
915
- usage: z5.object({
916
- total_tokens: z5.number()
917
- }).nullish()
918
- });
941
+ var alibabaTextEmbeddingResponseSchema = lazySchema5(
942
+ () => zodSchema5(
943
+ z5.object({
944
+ output: z5.object({
945
+ embeddings: z5.array(
946
+ z5.object({
947
+ embedding: z5.array(z5.number()),
948
+ text_index: z5.number(),
949
+ sparse_embedding: z5.array(alibabaTextEmbeddingSparseEmbeddingSchema()).nullish()
950
+ })
951
+ )
952
+ }),
953
+ usage: z5.object({
954
+ total_tokens: z5.number()
955
+ }).nullish()
956
+ })
957
+ )
958
+ );
919
959
 
920
960
  // src/alibaba-video-model.ts
921
961
  import {
@@ -928,16 +968,17 @@ import {
928
968
  createJsonErrorResponseHandler as createJsonErrorResponseHandler3,
929
969
  createJsonResponseHandler as createJsonResponseHandler3,
930
970
  delay,
971
+ encodePathSegment,
931
972
  getFromApi,
932
- lazySchema,
973
+ lazySchema as lazySchema6,
933
974
  parseProviderOptions as parseProviderOptions3,
934
975
  postJsonToApi as postJsonToApi3,
935
976
  resolve,
936
- zodSchema
977
+ zodSchema as zodSchema6
937
978
  } from "@ai-sdk/provider-utils";
938
979
  import { z as z6 } from "zod/v4";
939
- var alibabaVideoModelOptionsSchema = lazySchema(
940
- () => zodSchema(
980
+ var alibabaVideoModelOptionsSchema = lazySchema6(
981
+ () => zodSchema6(
941
982
  z6.object({
942
983
  negativePrompt: z6.string().nullish(),
943
984
  audioUrl: z6.string().nullish(),
@@ -967,47 +1008,59 @@ var alibabaVideoModelOptionsSchema = lazySchema(
967
1008
  }).passthrough()
968
1009
  )
969
1010
  );
970
- var alibabaVideoErrorSchema = z6.object({
971
- code: z6.string().nullish(),
972
- message: z6.string(),
973
- request_id: z6.string().nullish()
974
- });
1011
+ var alibabaVideoErrorSchema = lazySchema6(
1012
+ () => zodSchema6(
1013
+ z6.object({
1014
+ code: z6.string().nullish(),
1015
+ message: z6.string(),
1016
+ request_id: z6.string().nullish()
1017
+ })
1018
+ )
1019
+ );
975
1020
  var alibabaVideoFailedResponseHandler = createJsonErrorResponseHandler3({
976
1021
  errorSchema: alibabaVideoErrorSchema,
977
1022
  errorToMessage: (data) => data.message
978
1023
  });
979
- var alibabaVideoCreateTaskSchema = z6.object({
980
- output: z6.object({
981
- task_status: z6.string(),
982
- task_id: z6.string()
983
- }).nullish(),
984
- request_id: z6.string().nullish()
985
- });
986
- var alibabaVideoTaskStatusSchema = z6.object({
987
- output: z6.object({
988
- task_id: z6.string(),
989
- task_status: z6.string(),
990
- video_url: z6.string().nullish(),
991
- submit_time: z6.string().nullish(),
992
- scheduled_time: z6.string().nullish(),
993
- end_time: z6.string().nullish(),
994
- orig_prompt: z6.string().nullish(),
995
- actual_prompt: z6.string().nullish(),
996
- code: z6.string().nullish(),
997
- message: z6.string().nullish()
998
- }).nullish(),
999
- usage: z6.object({
1000
- duration: z6.number().nullish(),
1001
- output_video_duration: z6.number().nullish(),
1002
- // wan3 splits the total: input video counts toward its 30s ceiling.
1003
- input_video_duration: z6.number().nullish(),
1004
- fps: z6.number().nullish(),
1005
- SR: z6.number().nullish(),
1006
- size: z6.string().nullish(),
1007
- ratio: z6.string().nullish()
1008
- }).nullish(),
1009
- request_id: z6.string().nullish()
1010
- });
1024
+ var alibabaVideoCreateTaskSchema = lazySchema6(
1025
+ () => zodSchema6(
1026
+ z6.object({
1027
+ output: z6.object({
1028
+ task_status: z6.string(),
1029
+ task_id: z6.string()
1030
+ }).nullish(),
1031
+ request_id: z6.string().nullish()
1032
+ })
1033
+ )
1034
+ );
1035
+ var alibabaVideoTaskStatusSchema = lazySchema6(
1036
+ () => zodSchema6(
1037
+ z6.object({
1038
+ output: z6.object({
1039
+ task_id: z6.string(),
1040
+ task_status: z6.string(),
1041
+ video_url: z6.string().nullish(),
1042
+ submit_time: z6.string().nullish(),
1043
+ scheduled_time: z6.string().nullish(),
1044
+ end_time: z6.string().nullish(),
1045
+ orig_prompt: z6.string().nullish(),
1046
+ actual_prompt: z6.string().nullish(),
1047
+ code: z6.string().nullish(),
1048
+ message: z6.string().nullish()
1049
+ }).nullish(),
1050
+ usage: z6.object({
1051
+ duration: z6.number().nullish(),
1052
+ output_video_duration: z6.number().nullish(),
1053
+ // wan3 splits the total: input video counts toward its 30s ceiling.
1054
+ input_video_duration: z6.number().nullish(),
1055
+ fps: z6.number().nullish(),
1056
+ SR: z6.number().nullish(),
1057
+ size: z6.string().nullish(),
1058
+ ratio: z6.string().nullish()
1059
+ }).nullish(),
1060
+ request_id: z6.string().nullish()
1061
+ })
1062
+ )
1063
+ );
1011
1064
  function detectMode(modelId) {
1012
1065
  if (modelId.includes("-i2v")) return "i2v";
1013
1066
  if (modelId.includes("-r2v")) return "r2v";
@@ -1342,7 +1395,7 @@ var AlibabaVideoModel = class {
1342
1395
  });
1343
1396
  }
1344
1397
  const { value: statusResponse, responseHeaders: pollHeaders } = await getFromApi({
1345
- url: `${this.config.baseURL}/api/v1/tasks/${taskId}`,
1398
+ url: `${this.config.baseURL}/api/v1/tasks/${encodePathSegment(taskId)}`,
1346
1399
  headers: combineHeaders3(
1347
1400
  await resolve(this.config.headers),
1348
1401
  options.headers
@@ -1415,7 +1468,7 @@ var AlibabaVideoModel = class {
1415
1468
  };
1416
1469
 
1417
1470
  // src/version.ts
1418
- var VERSION = true ? "1.0.68" : "0.0.0-test";
1471
+ var VERSION = true ? "1.0.69" : "0.0.0-test";
1419
1472
 
1420
1473
  // src/alibaba-provider.ts
1421
1474
  function createAlibaba(options = {}) {