alchemylab-opencode 2.0.1 → 2.0.4

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.
Files changed (232) hide show
  1. package/NODE_COMPAT.md +8 -1
  2. package/dist/20260127222353_familiar_lady_ursula-YYOFSQD5.js +18 -0
  3. package/dist/20260211171708_add_project_commands-3GKQTPBZ.js +18 -0
  4. package/dist/20260213144116_wakeful_the_professor-ROO7OAVL.js +18 -0
  5. package/dist/20260225215848_workspace-V2OZTNFF.js +18 -0
  6. package/dist/20260227213759_add_session_workspace_id-GVDWAXKM.js +18 -0
  7. package/dist/20260228203230_blue_harpoon-Z5QP2II5.js +18 -0
  8. package/dist/20260303231226_add_workspace_fields-QOVAFN7W.js +18 -0
  9. package/dist/20260309230000_move_org_to_state-RQURSDZD.js +18 -0
  10. package/dist/20260312043431_session_message_cursor-VBISKDXL.js +18 -0
  11. package/dist/20260323234822_events-PILJHLNA.js +18 -0
  12. package/dist/20260410174513_workspace-name-63YCZ5NS.js +18 -0
  13. package/dist/20260413175956_chief_energizer-NMAZYGDO.js +18 -0
  14. package/dist/20260423070820_add_icon_url_override-RAJCVNEP.js +18 -0
  15. package/dist/20260427172553_slow_nightmare-ULYYZLR4.js +18 -0
  16. package/dist/20260428004200_add_session_path-U4WO2TGE.js +18 -0
  17. package/dist/20260501142318_next_venus-6BCYATSC.js +18 -0
  18. package/dist/20260504145000_add_sync_owner-RGVHV6LN.js +18 -0
  19. package/dist/20260507164347_add_workspace_time-GE6UHNPM.js +18 -0
  20. package/dist/{20260510033149_session_usage-UGBVOXZB.js → 20260510033149_session_usage-7XHCFVKY.js} +5 -1
  21. package/dist/20260511000411_data_migration_state-2EGZKFLB.js +18 -0
  22. package/dist/20260511173437_session-metadata-K322YY33.js +18 -0
  23. package/dist/20260601010001_normalize_storage_paths-VZDTY366.js +18 -0
  24. package/dist/{20260225215848_workspace-ZMSOZSPA.js → 20260601202201_amazing_prowler-YT6PLK3L.js} +5 -1
  25. package/dist/{20260228203230_blue_harpoon-IW3Z4TQZ.js → 20260602002951_lowly_union_jack-6VLQTBVB.js} +5 -1
  26. package/dist/20260602182828_add_project_directories-TVSRD25A.js +18 -0
  27. package/dist/20260603001617_session_message_projection_indexes-PHKTF6HK.js +18 -0
  28. package/dist/{20260622170816_reset_v2_session_state-5JPHJTZG.js → 20260603040000_session_message_projection_order-7RTV2POG.js} +5 -1
  29. package/dist/20260603141458_session_input_inbox-RSBWABG7.js +18 -0
  30. package/dist/20260603160727_jittery_ezekiel_stane-DXBLLRVV.js +18 -0
  31. package/dist/20260604172448_event_sourced_session_input-H6Z3JEBD.js +18 -0
  32. package/dist/20260605003541_add_session_context_snapshot-6FDPM2TK.js +18 -0
  33. package/dist/20260605042240_add_context_epoch_agent-C2OF2UKR.js +18 -0
  34. package/dist/20260611035744_credential-YNZ47FSH.js +18 -0
  35. package/dist/20260611192811_lush_chimera-E357VI6P.js +18 -0
  36. package/dist/20260612174303_project_dir_strategy-VUGGK42O.js +18 -0
  37. package/dist/20260622142730_simplify_session_context_epoch-UYGXZ5BX.js +18 -0
  38. package/dist/20260622170816_reset_v2_session_state-EILLPCJQ.js +18 -0
  39. package/dist/20260622202450_simplify_session_input-Y65GDGBO.js +18 -0
  40. package/dist/NodeSdk-AGMQWBHH.js +18 -0
  41. package/dist/anthropic-45OFTLAW.js +18 -0
  42. package/dist/anthropic-FVULF7C3.js +18 -0
  43. package/dist/app-runtime-LDQWNGWP.js +18 -0
  44. package/dist/chunk-2JE3QYG6.js +18 -0
  45. package/dist/chunk-2MRHL4B2.js +18 -0
  46. package/dist/chunk-4GJE6OMN.js +190 -0
  47. package/dist/chunk-4MBUHJHY.js +22 -0
  48. package/dist/chunk-5BLZCAU6.js +55 -0
  49. package/dist/chunk-7XX6TY62.js +259 -0
  50. package/dist/chunk-ANF3QA3Z.js +48 -0
  51. package/dist/chunk-AZUMH3TO.js +18 -0
  52. package/dist/chunk-B74WSFN4.js +878 -0
  53. package/dist/chunk-BQ4IEPN3.js +19 -0
  54. package/dist/chunk-CYRZU5QM.js +33 -0
  55. package/dist/chunk-DADVNQTM.js +1490 -0
  56. package/dist/chunk-DO2UZ6NY.js +18 -0
  57. package/dist/chunk-DWEYXIQI.js +780 -0
  58. package/dist/chunk-EK6FQQHY.js +20 -0
  59. package/dist/chunk-ELPXQ32J.js +90 -0
  60. package/dist/chunk-FGLPSSRK.js +19 -0
  61. package/dist/chunk-FOHYZ7MJ.js +55 -0
  62. package/dist/chunk-FV7U6PVP.js +18 -0
  63. package/dist/chunk-FYYAOZPU.js +18 -0
  64. package/dist/chunk-G7PFO5HG.js +920 -0
  65. package/dist/chunk-GDWO6EXN.js +22 -0
  66. package/dist/chunk-GW3ZRKAI.js +20 -0
  67. package/dist/chunk-IYUSBBGY.js +35 -0
  68. package/dist/chunk-JPOFLMNH.js +18 -0
  69. package/dist/{chunk-VURLSDCB.js → chunk-K5LKDIVU.js} +4 -0
  70. package/dist/chunk-KS4WLVK5.js +19 -0
  71. package/dist/chunk-LIXP4TPL.js +18 -0
  72. package/dist/chunk-LSC4RT5V.js +36 -0
  73. package/dist/chunk-M5A6NFHQ.js +28 -0
  74. package/dist/chunk-M6E6KNLV.js +30 -0
  75. package/dist/chunk-MLFZXUGQ.js +18 -0
  76. package/dist/chunk-NDI67DRG.js +31 -0
  77. package/dist/chunk-NGT6LCW6.js +18 -0
  78. package/dist/chunk-OCWGUTZJ.js +36 -0
  79. package/dist/chunk-OGDRUXMJ.js +18 -0
  80. package/dist/chunk-OGJKLJC7.js +29 -0
  81. package/dist/chunk-OT2YNR56.js +19 -0
  82. package/dist/chunk-OUVSKG2H.js +19 -0
  83. package/dist/chunk-P5RLCJUV.js +18 -0
  84. package/dist/chunk-Q3WIUQXB.js +18 -0
  85. package/dist/{20260227213759_add_session_workspace_id-ROENWPKA.js → chunk-QCRIXKIC.js} +5 -1
  86. package/dist/chunk-QD24DLUD.js +18 -0
  87. package/dist/chunk-R2GWBJEP.js +18 -0
  88. package/dist/chunk-RPAXSOGH.js +18 -0
  89. package/dist/chunk-TK5R7QUN.js +18 -0
  90. package/dist/chunk-TNQWZFIZ.js +28 -0
  91. package/dist/chunk-UCLPBO4I.js +18 -0
  92. package/dist/chunk-UPEPL4I2.js +18 -0
  93. package/dist/chunk-V6FDDNGV.js +117 -0
  94. package/dist/chunk-V6HERYFV.js +18 -0
  95. package/dist/chunk-V7XKKJ7X.js +24 -0
  96. package/dist/chunk-VHDYUBBS.js +23 -0
  97. package/dist/chunk-VWLJXTZ5.js +18 -0
  98. package/dist/chunk-VXAPFOIL.js +22 -0
  99. package/dist/chunk-WKZYINC7.js +29 -0
  100. package/dist/chunk-WPMP2ZFE.js +40 -0
  101. package/dist/chunk-WRTNIOI3.js +18 -0
  102. package/dist/chunk-X5F46HR5.js +18 -0
  103. package/dist/chunk-XPS7TQZG.js +22 -0
  104. package/dist/chunk-YJPP6IQ3.js +23 -0
  105. package/dist/chunk-ZYQWFC55.js +22 -0
  106. package/dist/code-mode-YYOGD36U.js +502 -0
  107. package/dist/copilot-provider-QVMLQZZC.js +18 -0
  108. package/dist/dist-5NQOHNPL.js +18 -0
  109. package/dist/dist-7CT3XCNN.js +32 -0
  110. package/dist/dist-CL46WFZG.js +18 -0
  111. package/dist/{20260605042240_add_context_epoch_agent-W6IQYZXE.js → dist-CYBRID2F.js} +5 -1
  112. package/dist/dist-HXJTF22W.js +32 -0
  113. package/dist/dist-JFXI53ZF.js +22 -0
  114. package/dist/dist-KBYKWVT5.js +22 -0
  115. package/dist/dist-KM5HCPZX.js +35 -0
  116. package/dist/dist-KTNLTEHB.js +18 -0
  117. package/dist/dist-KZ5R5QM5.js +24 -0
  118. package/dist/dist-NLXUYBW7.js +32 -0
  119. package/dist/dist-O4DF72J2.js +22 -0
  120. package/dist/dist-PH4MEGVR.js +22 -0
  121. package/dist/{20260511000411_data_migration_state-FB4LBFSE.js → dist-QJPOJCLB.js} +5 -1
  122. package/dist/dist-QYH62TCJ.js +22 -0
  123. package/dist/{20260303231226_add_workspace_fields-OUVZMNAG.js → dist-RIC4WKHC.js} +5 -1
  124. package/dist/dist-T776XKTM.js +22 -0
  125. package/dist/dist-TCE5MKZQ.js +23 -0
  126. package/dist/dist-TH2Q44RX.js +50 -0
  127. package/dist/dist-VV5FV5RT.js +101 -0
  128. package/dist/dist-XAFENVUS.js +22 -0
  129. package/dist/dist-XPFB35TX.js +32 -0
  130. package/dist/dist-YUH4RKR5.js +28 -0
  131. package/dist/dist-es-43ZM44MP.js +18 -0
  132. package/dist/dist-es-6PLFRCS4.js +18 -0
  133. package/dist/dist-es-G5UIJOU7.js +26 -0
  134. package/dist/{20260428004200_add_session_path-LGW75WYA.js → dist-es-HYIIGUNX.js} +5 -1
  135. package/dist/dist-es-L2GU465G.js +18 -0
  136. package/dist/dist-es-LSR2QCFZ.js +18 -0
  137. package/dist/dist-es-RGEIM2BP.js +18 -0
  138. package/dist/dist-es-SITTNOGV.js +18 -0
  139. package/dist/dist-es-W5GYOX6F.js +18 -0
  140. package/dist/esm-NN5W7YCL.js +18 -0
  141. package/dist/esm-XWJSHYHG.js +18 -0
  142. package/dist/getMachineId-bsd-L5I5TZ5I.js +18 -0
  143. package/dist/getMachineId-darwin-YB7KG37W.js +19 -0
  144. package/dist/getMachineId-linux-EL47KXX7.js +18 -0
  145. package/dist/getMachineId-unsupported-QOWPEBPN.js +18 -0
  146. package/dist/getMachineId-win-HCRYRDFJ.js +18 -0
  147. package/dist/lib-ZP7Q6A3E.js +199 -0
  148. package/dist/loadCognitoIdentity-EWT55EI7.js +18 -0
  149. package/dist/loadSso-AGOUE6RL.js +18 -0
  150. package/dist/{20260213144116_wakeful_the_professor-ZVDD54AK.js → loadSts-RH5L3PIX.js} +5 -1
  151. package/dist/mantle-IJXDXT4M.js +25 -0
  152. package/dist/mime-types-46EO4HOZ.js +18 -0
  153. package/dist/multipart-parser-KZWMKXA4.js +19 -0
  154. package/dist/{20260211171708_add_project_commands-GDOHPDPF.js → open-7KXTRM37.js} +5 -1
  155. package/dist/openai-ZOJI6I5R.js +18 -0
  156. package/dist/p-map-CYL6ILJW.js +18 -0
  157. package/dist/photon-W56QZY4L.js +18 -0
  158. package/dist/{20260423070820_add_icon_url_override-X5SHFGTI.js → pkce-VT4ITJTB.js} +5 -1
  159. package/dist/{pty.node-Y3N2XKYG.js → pty.node-IWULXXG6.js} +5 -1
  160. package/dist/run.js +5 -1
  161. package/dist/serve.js +143 -1
  162. package/dist/server-LVIHYOCY.js +21 -0
  163. package/dist/session-6OPJNJMK.js +18 -0
  164. package/dist/signin-OCIW23YM.js +18 -0
  165. package/dist/src-3NCXEROI.js +18 -0
  166. package/dist/src-LXWGIUZH.js +18 -0
  167. package/dist/src-WDYKISPD.js +20 -0
  168. package/dist/src-YAAFIGTW.js +18 -0
  169. package/dist/sso-oidc-OMMKINFE.js +18 -0
  170. package/dist/sts-MWK22JIX.js +18 -0
  171. package/dist/token-QPO3OAGS.js +18 -0
  172. package/dist/token-util-YGPCEEPO.js +18 -0
  173. package/dist/unified-W3ZKZ4HG.js +18 -0
  174. package/dist/worktree-32M5MTFE.js +18 -0
  175. package/package.json +40 -40
  176. package/postinstall.cjs +4 -2
  177. package/dist/20260127222353_familiar_lady_ursula-KV747FJX.js +0 -14
  178. package/dist/20260309230000_move_org_to_state-NOXAPU5V.js +0 -14
  179. package/dist/20260312043431_session_message_cursor-DJ4T3T4R.js +0 -14
  180. package/dist/20260323234822_events-72GIKJ2A.js +0 -14
  181. package/dist/20260410174513_workspace-name-JXSWFBJN.js +0 -14
  182. package/dist/20260413175956_chief_energizer-4HEWZ6U3.js +0 -14
  183. package/dist/20260427172553_slow_nightmare-PS5T2AH2.js +0 -14
  184. package/dist/20260501142318_next_venus-J3TLVXZ6.js +0 -14
  185. package/dist/20260504145000_add_sync_owner-3R52GB4C.js +0 -14
  186. package/dist/20260507164347_add_workspace_time-JHDRCZAR.js +0 -14
  187. package/dist/20260511173437_session-metadata-T2XHGWHS.js +0 -14
  188. package/dist/20260601010001_normalize_storage_paths-5MAY5GT3.js +0 -14
  189. package/dist/20260601202201_amazing_prowler-PET224YG.js +0 -14
  190. package/dist/20260602002951_lowly_union_jack-PG6XDMGL.js +0 -14
  191. package/dist/20260602182828_add_project_directories-ZCH2ACGG.js +0 -14
  192. package/dist/20260603001617_session_message_projection_indexes-XVLJTUF2.js +0 -14
  193. package/dist/20260603040000_session_message_projection_order-XG6RACZQ.js +0 -14
  194. package/dist/20260603141458_session_input_inbox-K2VQ7V6E.js +0 -14
  195. package/dist/20260603160727_jittery_ezekiel_stane-WKJLRDO7.js +0 -14
  196. package/dist/20260604172448_event_sourced_session_input-NTXOECR7.js +0 -14
  197. package/dist/20260605003541_add_session_context_snapshot-DXMQEXMT.js +0 -14
  198. package/dist/20260611035744_credential-XTMSYTJD.js +0 -14
  199. package/dist/20260611192811_lush_chimera-XPLIQMJD.js +0 -14
  200. package/dist/20260612174303_project_dir_strategy-FR2NGQKK.js +0 -14
  201. package/dist/20260622142730_simplify_session_context_epoch-NTQZR3RE.js +0 -14
  202. package/dist/20260622202450_simplify_session_input-2EXF2HMV.js +0 -14
  203. package/dist/app-runtime-HQBOCDV5.js +0 -14
  204. package/dist/chunk-4FEBIOI5.js +0 -865
  205. package/dist/chunk-4K2RXRZL.js +0 -14
  206. package/dist/chunk-4RFMKEKM.js +0 -1455
  207. package/dist/chunk-BM2C7NHL.js +0 -41
  208. package/dist/chunk-MKEMZFJI.js +0 -393
  209. package/dist/chunk-OMDJ6ZZ2.js +0 -684
  210. package/dist/chunk-OWMG4NNF.js +0 -186
  211. package/dist/chunk-QRABYJKL.js +0 -14
  212. package/dist/chunk-RHIWAYN5.js +0 -14
  213. package/dist/chunk-Z5TLIUAI.js +0 -28
  214. package/dist/code-mode-7BQJUARW.js +0 -40
  215. package/dist/copilot-provider-TX4YFKJZ.js +0 -14
  216. package/dist/photon-VQS5F5BI.js +0 -14
  217. package/dist/server-BFUQR7MX.js +0 -17
  218. package/dist/session-6RNXZNG6.js +0 -14
  219. package/dist/worktree-QHQHX3SG.js +0 -14
  220. package/patches/@ai-sdk%2Famazon-bedrock@4.0.166.patch +0 -164
  221. package/patches/@ai-sdk%2Fanthropic@3.0.111.patch +0 -528
  222. package/patches/@ai-sdk%2Fgoogle@3.0.73.patch +0 -69
  223. package/patches/@ai-sdk%2Fgroq@3.0.31.patch +0 -79
  224. package/patches/@ai-sdk%2Fmistral@3.0.51.patch +0 -714
  225. package/patches/@ai-sdk%2Fopenai-compatible@2.0.41.patch +0 -39
  226. package/patches/@ai-sdk%2Fopenai@3.0.88.patch +0 -280
  227. package/patches/@ai-sdk%2Fxai@3.0.139.patch +0 -296
  228. package/patches/@modelcontextprotocol%2Fsdk@1.29.0.patch +0 -647
  229. package/patches/@npmcli%2Fagent@4.0.2.patch +0 -13
  230. package/patches/effect@4.0.0-beta.83.patch +0 -57
  231. package/patches/gcp-metadata@8.1.2.patch +0 -14
  232. package/patches/pacote@21.5.0.patch +0 -18
@@ -1,714 +0,0 @@
1
- diff --git a/dist/index.d.mts b/dist/index.d.mts
2
- index 1bde0b9f8cbe6771a52c1041095c9dddfe8e5b6c..0ca2ffb2a0c9327aed5ddcf0004500dc8b42569f 100644
3
- --- a/dist/index.d.mts
4
- +++ b/dist/index.d.mts
5
- @@ -13,7 +13,5 @@ declare const mistralLanguageModelOptions: z.ZodObject<{
6
- - reasoningEffort: z.ZodOptional<z.ZodEnum<{
7
- - none: "none";
8
- - high: "high";
9
- - }>>;
10
- + reasoningEffort: z.ZodOptional<z.ZodString>;
11
- + promptCacheKey: z.ZodOptional<z.ZodString>;
12
- }, z.core.$strip>;
13
- type MistralLanguageModelOptions = z.infer<typeof mistralLanguageModelOptions>;
14
-
15
- diff --git a/dist/index.d.ts b/dist/index.d.ts
16
- index 1bde0b9f8cbe6771a52c1041095c9dddfe8e5b6c..0ca2ffb2a0c9327aed5ddcf0004500dc8b42569f 100644
17
- --- a/dist/index.d.ts
18
- +++ b/dist/index.d.ts
19
- @@ -13,7 +13,5 @@ declare const mistralLanguageModelOptions: z.ZodObject<{
20
- - reasoningEffort: z.ZodOptional<z.ZodEnum<{
21
- - none: "none";
22
- - high: "high";
23
- - }>>;
24
- + reasoningEffort: z.ZodOptional<z.ZodString>;
25
- + promptCacheKey: z.ZodOptional<z.ZodString>;
26
- }, z.core.$strip>;
27
- type MistralLanguageModelOptions = z.infer<typeof mistralLanguageModelOptions>;
28
-
29
- diff --git a/dist/index.js b/dist/index.js
30
- index d3f904c12a1d582cc7b9e9a2d30273e1a8505b28..267f34e20ea392b7a85ad5259d72d50605a6f971 100644
31
- --- a/dist/index.js
32
- +++ b/dist/index.js
33
- @@ -128,11 +128,14 @@ function convertToMistralChatMessages(prompt) {
34
- }
35
- case "assistant": {
36
- let text = "";
37
- + const structuredContent = [];
38
- + let hasNativeReasoning = false;
39
- const toolCalls = [];
40
- for (const part of content) {
41
- switch (part.type) {
42
- case "text": {
43
- text += part.text;
44
- + structuredContent.push({ type: "text", text: part.text });
45
- break;
46
- }
47
- case "tool-call": {
48
- @@ -148,6 +151,13 @@ function convertToMistralChatMessages(prompt) {
49
- }
50
- case "reasoning": {
51
- text += part.text;
52
- + const native = part.providerOptions?.mistral?.thinking;
53
- + if (native?.type === "thinking") {
54
- + hasNativeReasoning = true;
55
- + structuredContent.push(native);
56
- + break;
57
- + }
58
- + structuredContent.push({ type: "text", text: part.text });
59
- break;
60
- }
61
- default: {
62
- @@ -159,7 +169,7 @@ function convertToMistralChatMessages(prompt) {
63
- }
64
- messages.push({
65
- role: "assistant",
66
- - content: text,
67
- + content: hasNativeReasoning ? structuredContent : text,
68
- prefix: isLastMessage ? true : void 0,
69
- tool_calls: toolCalls.length > 0 ? toolCalls : void 0
70
- });
71
- @@ -268,7 +278,8 @@ var mistralLanguageModelOptions = import_v4.z.object({
72
- * - `'high'`: Enable reasoning
73
- * - `'none'`: Disable reasoning
74
- */
75
- - reasoningEffort: import_v4.z.enum(["high", "none"]).optional()
76
- + reasoningEffort: import_v4.z.string().optional(),
77
- + promptCacheKey: import_v4.z.string().optional()
78
- });
79
-
80
- // src/mistral-error.ts
81
- @@ -407,6 +418,7 @@ var MistralChatLanguageModel = class {
82
- stop: stopSequences,
83
- random_seed: seed,
84
- reasoning_effort: options.reasoningEffort,
85
- + prompt_cache_key: options.promptCacheKey,
86
- // response format:
87
- response_format: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? structuredOutputs && (responseFormat == null ? void 0 : responseFormat.schema) != null ? {
88
- type: "json_schema",
89
- @@ -465,9 +477,11 @@ var MistralChatLanguageModel = class {
90
- for (const part of choice.message.content) {
91
- if (part.type === "thinking") {
92
- const reasoningText = extractReasoningContent(part.thinking);
93
- - if (reasoningText.length > 0) {
94
- - content.push({ type: "reasoning", text: reasoningText });
95
- - }
96
- + content.push({
97
- + type: "reasoning",
98
- + text: reasoningText,
99
- + providerMetadata: { mistral: { thinking: part } }
100
- + });
101
- } else if (part.type === "text") {
102
- if (part.text.length > 0) {
103
- content.push({ type: "text", text: part.text });
104
- @@ -528,6 +542,7 @@ var MistralChatLanguageModel = class {
105
- let isFirstChunk = true;
106
- let activeText = false;
107
- let activeReasoningId = null;
108
- + let activeThinking = null;
109
- const generateId2 = this.generateId;
110
- return {
111
- stream: response.pipeThrough(
112
- @@ -561,18 +576,19 @@ var MistralChatLanguageModel = class {
113
- for (const part of delta.content) {
114
- if (part.type === "thinking") {
115
- const reasoningDelta = extractReasoningContent(part.thinking);
116
- - if (reasoningDelta.length > 0) {
117
- - if (activeReasoningId == null) {
118
- - if (activeText) {
119
- - controller.enqueue({ type: "text-end", id: "0" });
120
- - activeText = false;
121
- - }
122
- - activeReasoningId = generateId2();
123
- - controller.enqueue({
124
- - type: "reasoning-start",
125
- - id: activeReasoningId
126
- - });
127
- + activeThinking = mergeThinking(activeThinking, part);
128
- + if (activeReasoningId == null) {
129
- + if (activeText) {
130
- + controller.enqueue({ type: "text-end", id: "0" });
131
- + activeText = false;
132
- }
133
- + activeReasoningId = generateId2();
134
- + controller.enqueue({
135
- + type: "reasoning-start",
136
- + id: activeReasoningId
137
- + });
138
- + }
139
- + if (reasoningDelta.length > 0) {
140
- controller.enqueue({
141
- type: "reasoning-delta",
142
- id: activeReasoningId,
143
- @@ -587,9 +603,11 @@ var MistralChatLanguageModel = class {
144
- if (activeReasoningId != null) {
145
- controller.enqueue({
146
- type: "reasoning-end",
147
- - id: activeReasoningId
148
- + id: activeReasoningId,
149
- + providerMetadata: { mistral: { thinking: activeThinking } }
150
- });
151
- activeReasoningId = null;
152
- + activeThinking = null;
153
- }
154
- controller.enqueue({ type: "text-start", id: "0" });
155
- activeText = true;
156
- @@ -638,7 +656,8 @@ var MistralChatLanguageModel = class {
157
- if (activeReasoningId != null) {
158
- controller.enqueue({
159
- type: "reasoning-end",
160
- - id: activeReasoningId
161
- + id: activeReasoningId,
162
- + providerMetadata: { mistral: { thinking: activeThinking } }
163
- });
164
- }
165
- if (activeText) {
166
- @@ -660,6 +679,13 @@ var MistralChatLanguageModel = class {
167
- function extractReasoningContent(thinking) {
168
- return thinking.filter((chunk) => chunk.type === "text").map((chunk) => chunk.text).join("");
169
- }
170
- +function mergeThinking(current, next) {
171
- + if (current === null) return { ...next, thinking: [...next.thinking] };
172
- + current.thinking.push(...next.thinking);
173
- + if (next.closed !== void 0) current.closed = next.closed;
174
- + if (next.signature !== void 0) current.signature = next.signature;
175
- + return current;
176
- +}
177
- function extractTextContent(content) {
178
- if (typeof content === "string") {
179
- return content;
180
- @@ -686,6 +712,30 @@ function extractTextContent(content) {
181
- }
182
- return textContent.length ? textContent.join("") : void 0;
183
- }
184
- +var mistralThinkingContentSchema = import_v43.z.discriminatedUnion("type", [
185
- + import_v43.z.object({
186
- + type: import_v43.z.literal("text"),
187
- + text: import_v43.z.string()
188
- + }),
189
- + import_v43.z.object({
190
- + type: import_v43.z.literal("tool_reference"),
191
- + tool: import_v43.z.string(),
192
- + title: import_v43.z.string(),
193
- + url: import_v43.z.string().nullish(),
194
- + favicon: import_v43.z.string().nullish(),
195
- + description: import_v43.z.string().nullish()
196
- + }),
197
- + import_v43.z.object({
198
- + type: import_v43.z.literal("reference"),
199
- + reference_ids: import_v43.z.array(import_v43.z.union([import_v43.z.string(), import_v43.z.number().int()]))
200
- + })
201
- +]);
202
- +var mistralThinkChunkSchema = import_v43.z.object({
203
- + type: import_v43.z.literal("thinking"),
204
- + thinking: import_v43.z.array(mistralThinkingContentSchema),
205
- + closed: import_v43.z.boolean().optional(),
206
- + signature: import_v43.z.string().nullish()
207
- +});
208
- var mistralContentSchema = import_v43.z.union([
209
- import_v43.z.string(),
210
- import_v43.z.array(
211
- @@ -708,15 +758,7 @@ var mistralContentSchema = import_v43.z.union([
212
- type: import_v43.z.literal("reference"),
213
- reference_ids: import_v43.z.array(import_v43.z.union([import_v43.z.string(), import_v43.z.number()]))
214
- }),
215
- - import_v43.z.object({
216
- - type: import_v43.z.literal("thinking"),
217
- - thinking: import_v43.z.array(
218
- - import_v43.z.object({
219
- - type: import_v43.z.literal("text"),
220
- - text: import_v43.z.string()
221
- - })
222
- - )
223
- - })
224
- + mistralThinkChunkSchema
225
- ])
226
- )
227
- ]).nullish();
228
- diff --git a/dist/index.mjs b/dist/index.mjs
229
- index d2eff622c1b84a96bdeb4012cb0206a33012a04d..3bff11ddd6136ada45809568828cbc8f2493a42a 100644
230
- --- a/dist/index.mjs
231
- +++ b/dist/index.mjs
232
- @@ -116,11 +116,14 @@ function convertToMistralChatMessages(prompt) {
233
- }
234
- case "assistant": {
235
- let text = "";
236
- + const structuredContent = [];
237
- + let hasNativeReasoning = false;
238
- const toolCalls = [];
239
- for (const part of content) {
240
- switch (part.type) {
241
- case "text": {
242
- text += part.text;
243
- + structuredContent.push({ type: "text", text: part.text });
244
- break;
245
- }
246
- case "tool-call": {
247
- @@ -136,6 +139,13 @@ function convertToMistralChatMessages(prompt) {
248
- }
249
- case "reasoning": {
250
- text += part.text;
251
- + const native = part.providerOptions?.mistral?.thinking;
252
- + if (native?.type === "thinking") {
253
- + hasNativeReasoning = true;
254
- + structuredContent.push(native);
255
- + break;
256
- + }
257
- + structuredContent.push({ type: "text", text: part.text });
258
- break;
259
- }
260
- default: {
261
- @@ -147,7 +157,7 @@ function convertToMistralChatMessages(prompt) {
262
- }
263
- messages.push({
264
- role: "assistant",
265
- - content: text,
266
- + content: hasNativeReasoning ? structuredContent : text,
267
- prefix: isLastMessage ? true : void 0,
268
- tool_calls: toolCalls.length > 0 ? toolCalls : void 0
269
- });
270
- @@ -256,7 +266,8 @@ var mistralLanguageModelOptions = z.object({
271
- * - `'high'`: Enable reasoning
272
- * - `'none'`: Disable reasoning
273
- */
274
- - reasoningEffort: z.enum(["high", "none"]).optional()
275
- + reasoningEffort: z.string().optional(),
276
- + promptCacheKey: z.string().optional()
277
- });
278
-
279
- // src/mistral-error.ts
280
- @@ -397,6 +408,7 @@ var MistralChatLanguageModel = class {
281
- stop: stopSequences,
282
- random_seed: seed,
283
- reasoning_effort: options.reasoningEffort,
284
- + prompt_cache_key: options.promptCacheKey,
285
- // response format:
286
- response_format: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? structuredOutputs && (responseFormat == null ? void 0 : responseFormat.schema) != null ? {
287
- type: "json_schema",
288
- @@ -455,9 +467,11 @@ var MistralChatLanguageModel = class {
289
- for (const part of choice.message.content) {
290
- if (part.type === "thinking") {
291
- const reasoningText = extractReasoningContent(part.thinking);
292
- - if (reasoningText.length > 0) {
293
- - content.push({ type: "reasoning", text: reasoningText });
294
- - }
295
- + content.push({
296
- + type: "reasoning",
297
- + text: reasoningText,
298
- + providerMetadata: { mistral: { thinking: part } }
299
- + });
300
- } else if (part.type === "text") {
301
- if (part.text.length > 0) {
302
- content.push({ type: "text", text: part.text });
303
- @@ -518,6 +532,7 @@ var MistralChatLanguageModel = class {
304
- let isFirstChunk = true;
305
- let activeText = false;
306
- let activeReasoningId = null;
307
- + let activeThinking = null;
308
- const generateId2 = this.generateId;
309
- return {
310
- stream: response.pipeThrough(
311
- @@ -551,18 +566,19 @@ var MistralChatLanguageModel = class {
312
- for (const part of delta.content) {
313
- if (part.type === "thinking") {
314
- const reasoningDelta = extractReasoningContent(part.thinking);
315
- - if (reasoningDelta.length > 0) {
316
- - if (activeReasoningId == null) {
317
- - if (activeText) {
318
- - controller.enqueue({ type: "text-end", id: "0" });
319
- - activeText = false;
320
- - }
321
- - activeReasoningId = generateId2();
322
- - controller.enqueue({
323
- - type: "reasoning-start",
324
- - id: activeReasoningId
325
- - });
326
- + activeThinking = mergeThinking(activeThinking, part);
327
- + if (activeReasoningId == null) {
328
- + if (activeText) {
329
- + controller.enqueue({ type: "text-end", id: "0" });
330
- + activeText = false;
331
- }
332
- + activeReasoningId = generateId2();
333
- + controller.enqueue({
334
- + type: "reasoning-start",
335
- + id: activeReasoningId
336
- + });
337
- + }
338
- + if (reasoningDelta.length > 0) {
339
- controller.enqueue({
340
- type: "reasoning-delta",
341
- id: activeReasoningId,
342
- @@ -577,9 +593,11 @@ var MistralChatLanguageModel = class {
343
- if (activeReasoningId != null) {
344
- controller.enqueue({
345
- type: "reasoning-end",
346
- - id: activeReasoningId
347
- + id: activeReasoningId,
348
- + providerMetadata: { mistral: { thinking: activeThinking } }
349
- });
350
- activeReasoningId = null;
351
- + activeThinking = null;
352
- }
353
- controller.enqueue({ type: "text-start", id: "0" });
354
- activeText = true;
355
- @@ -628,7 +646,8 @@ var MistralChatLanguageModel = class {
356
- if (activeReasoningId != null) {
357
- controller.enqueue({
358
- type: "reasoning-end",
359
- - id: activeReasoningId
360
- + id: activeReasoningId,
361
- + providerMetadata: { mistral: { thinking: activeThinking } }
362
- });
363
- }
364
- if (activeText) {
365
- @@ -650,6 +669,13 @@ var MistralChatLanguageModel = class {
366
- function extractReasoningContent(thinking) {
367
- return thinking.filter((chunk) => chunk.type === "text").map((chunk) => chunk.text).join("");
368
- }
369
- +function mergeThinking(current, next) {
370
- + if (current === null) return { ...next, thinking: [...next.thinking] };
371
- + current.thinking.push(...next.thinking);
372
- + if (next.closed !== void 0) current.closed = next.closed;
373
- + if (next.signature !== void 0) current.signature = next.signature;
374
- + return current;
375
- +}
376
- function extractTextContent(content) {
377
- if (typeof content === "string") {
378
- return content;
379
- @@ -676,6 +702,30 @@ function extractTextContent(content) {
380
- }
381
- return textContent.length ? textContent.join("") : void 0;
382
- }
383
- +var mistralThinkingContentSchema = z3.discriminatedUnion("type", [
384
- + z3.object({
385
- + type: z3.literal("text"),
386
- + text: z3.string()
387
- + }),
388
- + z3.object({
389
- + type: z3.literal("tool_reference"),
390
- + tool: z3.string(),
391
- + title: z3.string(),
392
- + url: z3.string().nullish(),
393
- + favicon: z3.string().nullish(),
394
- + description: z3.string().nullish()
395
- + }),
396
- + z3.object({
397
- + type: z3.literal("reference"),
398
- + reference_ids: z3.array(z3.union([z3.string(), z3.number().int()]))
399
- + })
400
- +]);
401
- +var mistralThinkChunkSchema = z3.object({
402
- + type: z3.literal("thinking"),
403
- + thinking: z3.array(mistralThinkingContentSchema),
404
- + closed: z3.boolean().optional(),
405
- + signature: z3.string().nullish()
406
- +});
407
- var mistralContentSchema = z3.union([
408
- z3.string(),
409
- z3.array(
410
- @@ -698,15 +748,7 @@ var mistralContentSchema = z3.union([
411
- type: z3.literal("reference"),
412
- reference_ids: z3.array(z3.union([z3.string(), z3.number()]))
413
- }),
414
- - z3.object({
415
- - type: z3.literal("thinking"),
416
- - thinking: z3.array(
417
- - z3.object({
418
- - type: z3.literal("text"),
419
- - text: z3.string()
420
- - })
421
- - )
422
- - })
423
- + mistralThinkChunkSchema
424
- ])
425
- )
426
- ]).nullish();
427
- diff --git a/src/convert-to-mistral-chat-messages.ts b/src/convert-to-mistral-chat-messages.ts
428
- index 3c6914f8da615d7517bc43dd56198298d0a50247..8cd6f4c7577f746ef41e8a0aee682234c473667a 100644
429
- --- a/src/convert-to-mistral-chat-messages.ts
430
- +++ b/src/convert-to-mistral-chat-messages.ts
431
- @@ -3,7 +3,11 @@ import {
432
- type LanguageModelV3DataContent,
433
- type LanguageModelV3Prompt,
434
- } from '@ai-sdk/provider';
435
- -import type { MistralPrompt } from './mistral-chat-prompt';
436
- +import type {
437
- + MistralAssistantMessageContent,
438
- + MistralPrompt,
439
- + MistralThinkChunk,
440
- +} from './mistral-chat-prompt';
441
- import { convertToBase64 } from '@ai-sdk/provider-utils';
442
-
443
- function formatFileUrl({
444
- @@ -76,6 +80,8 @@ export function convertToMistralChatMessages(
445
-
446
- case 'assistant': {
447
- let text = '';
448
- + const structuredContent: Array<MistralAssistantMessageContent> = [];
449
- + let hasNativeReasoning = false;
450
- const toolCalls: Array<{
451
- id: string;
452
- type: 'function';
453
- @@ -86,6 +92,7 @@ export function convertToMistralChatMessages(
454
- switch (part.type) {
455
- case 'text': {
456
- text += part.text;
457
- + structuredContent.push({ type: 'text', text: part.text });
458
- break;
459
- }
460
- case 'tool-call': {
461
- @@ -101,6 +108,14 @@ export function convertToMistralChatMessages(
462
- }
463
- case 'reasoning': {
464
- text += part.text;
465
- + const native = part.providerOptions?.mistral
466
- + ?.thinking as MistralThinkChunk | undefined;
467
- + if (native?.type === 'thinking') {
468
- + hasNativeReasoning = true;
469
- + structuredContent.push(native);
470
- + break;
471
- + }
472
- + structuredContent.push({ type: 'text', text: part.text });
473
- break;
474
- }
475
- default: {
476
- @@ -113,7 +128,7 @@ export function convertToMistralChatMessages(
477
-
478
- messages.push({
479
- role: 'assistant',
480
- - content: text,
481
- + content: hasNativeReasoning ? structuredContent : text,
482
- prefix: isLastMessage ? true : undefined,
483
- tool_calls: toolCalls.length > 0 ? toolCalls : undefined,
484
- });
485
- diff --git a/src/mistral-chat-language-model.ts b/src/mistral-chat-language-model.ts
486
- index 7e4a7ab552f1b41b7074e1b3cada8a51d791268d..847d26f9dfe03572a969a122f8c96b8bbfda8066 100644
487
- --- a/src/mistral-chat-language-model.ts
488
- +++ b/src/mistral-chat-language-model.ts
489
- @@ -122,6 +122,7 @@ export class MistralChatLanguageModel implements LanguageModelV3 {
490
- stop: stopSequences,
491
- random_seed: seed,
492
- reasoning_effort: options.reasoningEffort,
493
- + prompt_cache_key: options.promptCacheKey,
494
-
495
- // response format:
496
- response_format:
497
- @@ -201,9 +202,11 @@ export class MistralChatLanguageModel implements LanguageModelV3 {
498
- for (const part of choice.message.content) {
499
- if (part.type === 'thinking') {
500
- const reasoningText = extractReasoningContent(part.thinking);
501
- - if (reasoningText.length > 0) {
502
- - content.push({ type: 'reasoning', text: reasoningText });
503
- - }
504
- + content.push({
505
- + type: 'reasoning',
506
- + text: reasoningText,
507
- + providerMetadata: { mistral: { thinking: part } },
508
- + });
509
- } else if (part.type === 'text') {
510
- if (part.text.length > 0) {
511
- content.push({ type: 'text', text: part.text });
512
- @@ -278,6 +281,7 @@ export class MistralChatLanguageModel implements LanguageModelV3 {
513
- let isFirstChunk = true;
514
- let activeText = false;
515
- let activeReasoningId: string | null = null;
516
- + let activeThinking: z.infer<typeof mistralThinkChunkSchema> | null = null;
517
-
518
- const generateId = this.generateId;
519
-
520
- @@ -326,20 +330,21 @@ export class MistralChatLanguageModel implements LanguageModelV3 {
521
- for (const part of delta.content) {
522
- if (part.type === 'thinking') {
523
- const reasoningDelta = extractReasoningContent(part.thinking);
524
- - if (reasoningDelta.length > 0) {
525
- - if (activeReasoningId == null) {
526
- - // end any active text before starting reasoning
527
- - if (activeText) {
528
- - controller.enqueue({ type: 'text-end', id: '0' });
529
- - activeText = false;
530
- - }
531
- -
532
- - activeReasoningId = generateId();
533
- - controller.enqueue({
534
- - type: 'reasoning-start',
535
- - id: activeReasoningId,
536
- - });
537
- + activeThinking = mergeThinking(activeThinking, part);
538
- + if (activeReasoningId == null) {
539
- + // end any active text before starting reasoning
540
- + if (activeText) {
541
- + controller.enqueue({ type: 'text-end', id: '0' });
542
- + activeText = false;
543
- }
544
- +
545
- + activeReasoningId = generateId();
546
- + controller.enqueue({
547
- + type: 'reasoning-start',
548
- + id: activeReasoningId,
549
- + });
550
- + }
551
- + if (reasoningDelta.length > 0) {
552
- controller.enqueue({
553
- type: 'reasoning-delta',
554
- id: activeReasoningId,
555
- @@ -357,8 +362,12 @@ export class MistralChatLanguageModel implements LanguageModelV3 {
556
- controller.enqueue({
557
- type: 'reasoning-end',
558
- id: activeReasoningId,
559
- + providerMetadata: {
560
- + mistral: { thinking: activeThinking },
561
- + },
562
- });
563
- activeReasoningId = null;
564
- + activeThinking = null;
565
- }
566
- controller.enqueue({ type: 'text-start', id: '0' });
567
- activeText = true;
568
- @@ -416,6 +425,9 @@ export class MistralChatLanguageModel implements LanguageModelV3 {
569
- controller.enqueue({
570
- type: 'reasoning-end',
571
- id: activeReasoningId,
572
- + providerMetadata: {
573
- + mistral: { thinking: activeThinking },
574
- + },
575
- });
576
- }
577
- if (activeText) {
578
- @@ -437,7 +449,7 @@ export class MistralChatLanguageModel implements LanguageModelV3 {
579
- }
580
-
581
- function extractReasoningContent(
582
- - thinking: Array<{ type: string; text: string }>,
583
- + thinking: Array<z.infer<typeof mistralThinkingContentSchema>>,
584
- ) {
585
- return thinking
586
- .filter(chunk => chunk.type === 'text')
587
- @@ -445,6 +457,17 @@ function extractReasoningContent(
588
- .join('');
589
- }
590
-
591
- +function mergeThinking(
592
- + current: z.infer<typeof mistralThinkChunkSchema> | null,
593
- + next: z.infer<typeof mistralThinkChunkSchema>,
594
- +) {
595
- + if (current === null) return { ...next, thinking: [...next.thinking] };
596
- + current.thinking.push(...next.thinking);
597
- + if (next.closed !== undefined) current.closed = next.closed;
598
- + if (next.signature !== undefined) current.signature = next.signature;
599
- + return current;
600
- +}
601
- +
602
- function extractTextContent(content: z.infer<typeof mistralContentSchema>) {
603
- if (typeof content === 'string') {
604
- return content;
605
- @@ -478,6 +501,32 @@ function extractTextContent(content: z.infer<typeof mistralContentSchema>) {
606
- return textContent.length ? textContent.join('') : undefined;
607
- }
608
-
609
- +const mistralThinkingContentSchema = z.discriminatedUnion('type', [
610
- + z.object({
611
- + type: z.literal('text'),
612
- + text: z.string(),
613
- + }),
614
- + z.object({
615
- + type: z.literal('tool_reference'),
616
- + tool: z.string(),
617
- + title: z.string(),
618
- + url: z.string().nullish(),
619
- + favicon: z.string().nullish(),
620
- + description: z.string().nullish(),
621
- + }),
622
- + z.object({
623
- + type: z.literal('reference'),
624
- + reference_ids: z.array(z.union([z.string(), z.number().int()])),
625
- + }),
626
- +]);
627
- +
628
- +const mistralThinkChunkSchema = z.object({
629
- + type: z.literal('thinking'),
630
- + thinking: z.array(mistralThinkingContentSchema),
631
- + closed: z.boolean().optional(),
632
- + signature: z.string().nullish(),
633
- +});
634
- +
635
- const mistralContentSchema = z
636
- .union([
637
- z.string(),
638
- @@ -501,15 +550,7 @@ const mistralContentSchema = z
639
- type: z.literal('reference'),
640
- reference_ids: z.array(z.union([z.string(), z.number()])),
641
- }),
642
- - z.object({
643
- - type: z.literal('thinking'),
644
- - thinking: z.array(
645
- - z.object({
646
- - type: z.literal('text'),
647
- - text: z.string(),
648
- - }),
649
- - ),
650
- - }),
651
- + mistralThinkChunkSchema,
652
- ]),
653
- ),
654
- ])
655
- diff --git a/src/mistral-chat-options.ts b/src/mistral-chat-options.ts
656
- index 54b29c08517d348995b6ca093b11160e453d5c8b..de30c3e7d924889339e38b1067cb26e9ada05d11 100644
657
- --- a/src/mistral-chat-options.ts
658
- +++ b/src/mistral-chat-options.ts
659
- @@ -64,6 +64,11 @@ export const mistralLanguageModelOptions = z.object({
660
- * - `'none'`: Disable reasoning
661
- */
662
- - reasoningEffort: z.enum(['high', 'none']).optional(),
663
- + reasoningEffort: z.string().optional(),
664
- +
665
- + /**
666
- + * A stable identifier used to route requests with shared prompt prefixes.
667
- + */
668
- + promptCacheKey: z.string().optional(),
669
- });
670
-
671
- export type MistralLanguageModelOptions = z.infer<
672
- diff --git a/src/mistral-chat-prompt.ts b/src/mistral-chat-prompt.ts
673
- index 13f1dced55ac4be084128127a57fbdd58115bc28..172b11dde3dd326c2f3befd99237474ed8c79285 100644
674
- --- a/src/mistral-chat-prompt.ts
675
- +++ b/src/mistral-chat-prompt.ts
676
- @@ -23,7 +23,7 @@ export type MistralUserMessageContent =
677
-
678
- export interface MistralAssistantMessage {
679
- role: 'assistant';
680
- - content: string;
681
- + content: string | Array<MistralAssistantMessageContent>;
682
- prefix?: boolean;
683
- tool_calls?: Array<{
684
- id: string;
685
- @@ -32,6 +32,29 @@ export interface MistralAssistantMessage {
686
- }>;
687
- }
688
-
689
- +export type MistralAssistantMessageContent =
690
- + | { type: 'text'; text: string }
691
- + | MistralThinkChunk;
692
- +
693
- +export type MistralThinkChunk = {
694
- + type: 'thinking';
695
- + thinking: Array<MistralThinkingContent>;
696
- + closed?: boolean;
697
- + signature?: string | null;
698
- +};
699
- +
700
- +export type MistralThinkingContent =
701
- + | { type: 'text'; text: string }
702
- + | {
703
- + type: 'tool_reference';
704
- + tool: string;
705
- + title: string;
706
- + url?: string | null;
707
- + favicon?: string | null;
708
- + description?: string | null;
709
- + }
710
- + | { type: 'reference'; reference_ids: Array<string | number> };
711
- +
712
- export interface MistralToolMessage {
713
- role: 'tool';
714
- name: string;