@minimax-ai/code 0.3.5 → 0.3.7
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 +37 -0
- package/CHANGELOG.zh-CN.md +23 -0
- package/README.md +33 -2
- package/README.zh-CN.md +28 -2
- package/chunks/{application-HUWMCHND.js → application-LFPFVITL.js} +1 -1
- package/chunks/{auth-command-BYZBT26P.js → auth-command-ZZXFBWOS.js} +1 -1
- package/chunks/{azure-openai-responses-FWEOB2GJ.js → azure-openai-responses-TYAI4QCH.js} +1 -1
- package/chunks/{chunk-XRVRMFGU.js → chunk-5MDJKLXG.js} +1 -1
- package/chunks/{chunk-XAM5MDT7.js → chunk-ACTS7L64.js} +1 -1
- package/chunks/{chunk-MZPFHOPH.js → chunk-E3Y7YZFG.js} +1 -1
- package/chunks/{chunk-JAU52A7E.js → chunk-GMXY243M.js} +1 -1
- package/chunks/{chunk-B3RZOZAM.js → chunk-MQKRH5EW.js} +426 -426
- package/chunks/chunk-NW6DSOE3.js +3 -0
- package/chunks/{chunk-H3N3OSTE.js → chunk-RTN2VVTR.js} +495 -495
- package/chunks/{chunk-BLWZ6QN5.js → chunk-RXHPXCVW.js} +1 -1
- package/chunks/chunk-SEVVS6ZS.js +5 -0
- package/chunks/chunk-UQHSY5YK.js +164 -0
- package/chunks/{chunk-LA56ACSJ.js → chunk-WMOPXI4T.js} +7 -7
- package/chunks/{chunk-SAVPNWES.js → chunk-XO2KLR35.js} +20 -20
- package/chunks/{data-dir-VQU534BQ.js → data-dir-BYKXIBNJ.js} +1 -1
- package/chunks/dist-2YKPF46H.js +2 -0
- package/chunks/install-source-6JLUO3MG.js +2 -0
- package/chunks/{launcher-MX2NVH43.js → launcher-N4XF6G4T.js} +147 -146
- package/chunks/{lifecycle-FOX6WX4K.js → lifecycle-2Z6U4ZFY.js} +1 -1
- package/chunks/{main-QMF5ARJ7.js → main-LM42U7RA.js} +15 -14
- package/chunks/{openai-codex-responses-4DFNORNB.js → openai-codex-responses-HB3H25XX.js} +1 -1
- package/chunks/{openai-completions-7UHFNP2X.js → openai-completions-4CWNFN62.js} +1 -1
- package/chunks/{openai-responses-FVDPT4UA.js → openai-responses-3ODEYAEO.js} +1 -1
- package/chunks/{plugin-command-PPXN6LWR.js → plugin-command-ENLMEUEV.js} +1 -1
- package/chunks/{provider-command-B3MUOIKK.js → provider-command-SHDAR5N3.js} +1 -1
- package/chunks/{run-acp-command-VU6B46YW.js → run-acp-command-IIRG3KK2.js} +2 -2
- package/chunks/{run-exec-command-3MEFVBVG.js → run-exec-command-CWJBGPN7.js} +1 -1
- package/chunks/{update-UUNJOWUN.js → update-HTLJYRQR.js} +1 -1
- package/cli.js +2 -2
- package/package.json +1 -1
- package/verify-native-install.mjs +4 -4
- package/chunks/chunk-GGVSHD4M.js +0 -165
- package/chunks/chunk-KIJODLFS.js +0 -5
- package/chunks/dist-K5PPY2Q5.js +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,43 @@ This changelog covers important changes that directly affect MCode TUI users. It
|
|
|
7
7
|
|
|
8
8
|
Internal refactors, test-only changes, and changes limited to other product surfaces are excluded.
|
|
9
9
|
|
|
10
|
+
## 0.3.7 · 2026-09-07
|
|
11
|
+
|
|
12
|
+
### Improved
|
|
13
|
+
|
|
14
|
+
- Long sessions search and render more smoothly, with cached search indexes and stable Markdown,
|
|
15
|
+
fewer history replays during terminal resizing, and clearer tool retry summaries.
|
|
16
|
+
- The default status line warns when remaining context reaches 25% or less. Explicitly configuring
|
|
17
|
+
`context-remaining` keeps valid usage visible; narrow terminals prioritize essential status.
|
|
18
|
+
- Terminal notifications support focus-aware policies and configurable delivery methods, with improved
|
|
19
|
+
compatibility for cmux. Composer keyboard hints follow the current platform.
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
|
|
23
|
+
- Improved shared login recovery when switching accounts, cancelling login, or starting offline,
|
|
24
|
+
including concurrent credential renewal and delayed logout synchronization.
|
|
25
|
+
- Installation and repair guidance now preserves the selected package, version, and registry and
|
|
26
|
+
explains how to restore native SQLite dependencies when npm 12 blocks installation scripts.
|
|
27
|
+
|
|
28
|
+
## 0.3.6 · 2026-09-07
|
|
29
|
+
|
|
30
|
+
### Fixed
|
|
31
|
+
|
|
32
|
+
- When MCode shares its data directory with MiniMax Desktop, official model endpoints are now
|
|
33
|
+
resolved in memory for the current environment: reading configuration or first-run
|
|
34
|
+
initialization no longer writes new official endpoints into the shared config file, so older
|
|
35
|
+
Desktop versions keep working alongside the TUI. Custom (BYOK) endpoints behave as before.
|
|
36
|
+
- Legacy model recovery now also covers numbered model aliases and retired default models, and
|
|
37
|
+
applies consistently to the model list, Goal model checks, and login checks: selections
|
|
38
|
+
pointing at the legacy official gateway resolve to the same-name official model, then the
|
|
39
|
+
configured default model, then the current official default. Shared default models, session
|
|
40
|
+
model references, and migration records are preserved; only explicit user selections are
|
|
41
|
+
written back to configuration.
|
|
42
|
+
- Installing or updating with npm 12 no longer breaks the native SQLite module: install and
|
|
43
|
+
update authorize the MCode and `better-sqlite3` lifecycle scripts and keep optional native
|
|
44
|
+
dependencies. When native SQLite fails to load, startup prints a repair command matching the
|
|
45
|
+
install registry, and early startup errors are reported instead of failing silently.
|
|
46
|
+
|
|
10
47
|
## 0.3.5 · 2026-09-07
|
|
11
48
|
|
|
12
49
|
### Fixed
|
package/CHANGELOG.zh-CN.md
CHANGED
|
@@ -8,6 +8,29 @@ TUI 正式版中用户能直接感知的重要变化。收录范围以 TUI 用
|
|
|
8
8
|
|
|
9
9
|
仅内部重构、测试调整,或只影响其他产品界面且不改变 TUI 行为的变化不记录。
|
|
10
10
|
|
|
11
|
+
## 0.3.7 · 2026-09-07
|
|
12
|
+
|
|
13
|
+
### 改进
|
|
14
|
+
|
|
15
|
+
- 长会话搜索和渲染更流畅:缓存搜索索引和稳定的 Markdown 内容,减少调整终端尺寸时的历史重绘,并更清晰地展示工具重试摘要。
|
|
16
|
+
- 默认状态栏在剩余上下文不超过 25% 时提示;显式配置 `context-remaining` 可持续显示有效用量,窄屏优先保留关键状态。
|
|
17
|
+
- 终端通知支持按焦点状态和发送方式配置,改善 cmux 兼容性;输入框快捷键提示适配当前平台。
|
|
18
|
+
|
|
19
|
+
### 修复
|
|
20
|
+
|
|
21
|
+
- 改善切换账号、取消登录和离线启动时的共享登录恢复,处理并发凭据续期与延迟登出同步。
|
|
22
|
+
- 安装和修复指引保留选定的包名、版本和 registry,并说明 npm 12 阻止安装脚本时如何恢复原生 SQLite 依赖。
|
|
23
|
+
|
|
24
|
+
## 0.3.6 · 2026-09-07
|
|
25
|
+
|
|
26
|
+
### 问题修复
|
|
27
|
+
|
|
28
|
+
- 与 MiniMax 桌面端共用数据目录时,官方模型地址改为在 TUI 内按当前环境解析:读取配置和首次初始化不再向共享配置文件写入新的官方地址,避免影响旧版桌面端;自定义(BYOK)服务地址行为不变。
|
|
29
|
+
- 遗留模型自动恢复扩展到编号模型别名和已下线的默认模型,并统一覆盖模型列表、Goal
|
|
30
|
+
模型校验和登录检查:指向旧官方网关的模型选择依次解析为官方同名模型、配置默认模型和当前官方默认模型;共享默认模型、会话模型引用和迁移记录保持不变,仅用户主动选择模型才会写回配置。
|
|
31
|
+
- 修复 npm 12 下安装或更新导致 SQLite 原生模块损坏的问题:安装和更新会授权 MCode 与
|
|
32
|
+
`better-sqlite3` 的安装脚本并保留可选原生依赖;原生模块加载失败时,启动会按安装来源给出对应的修复命令,启动早期错误也会如实报告而不是静默失败。
|
|
33
|
+
|
|
11
34
|
## 0.3.5 · 2026-09-07
|
|
12
35
|
|
|
13
36
|
### 问题修复
|
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ ACP-compatible client.
|
|
|
13
13
|
Requires Node.js `22.19+` on Node 22, or Node.js `24–26`.
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
npm install -g @minimax-ai/code
|
|
16
|
+
npm install -g @minimax-ai/code --allow-scripts=@minimax-ai/code,better-sqlite3 --registry=https://registry.npmjs.org/
|
|
17
17
|
cd your-project
|
|
18
18
|
mcode
|
|
19
19
|
```
|
|
@@ -262,11 +262,42 @@ switching Node.js versions, reinstall MiniMax Code:
|
|
|
262
262
|
|
|
263
263
|
```bash
|
|
264
264
|
node --version
|
|
265
|
-
npm install -g @minimax-ai/code
|
|
265
|
+
npm install -g @minimax-ai/code --allow-scripts=@minimax-ai/code,better-sqlite3 --registry=https://registry.npmjs.org/
|
|
266
266
|
```
|
|
267
267
|
|
|
268
268
|
</details>
|
|
269
269
|
|
|
270
|
+
<details>
|
|
271
|
+
<summary>npm 12 blocks installation scripts, or startup reports a missing native SQLite dependency</summary>
|
|
272
|
+
|
|
273
|
+
npm 12 blocks unapproved installation scripts by default. If `npm warn install-scripts` lists
|
|
274
|
+
MCode's `postinstall` and `better-sqlite3`'s `install` as blocked, SQLite may be unavailable even
|
|
275
|
+
when npm reports `added` or `changed packages`. Startup may report `Could not locate the bindings
|
|
276
|
+
file`, a missing `better_sqlite3.node`, or an outer `migration_failed` error.
|
|
277
|
+
|
|
278
|
+
For official Shell/PowerShell installations, rerun the original installer command. The installer
|
|
279
|
+
and `/update` handle the required script options and native dependencies. If MCode cannot start,
|
|
280
|
+
repair it with the installer first.
|
|
281
|
+
|
|
282
|
+
For `npm install -g` installations, prefer the repair command printed in the startup error.
|
|
283
|
+
Use the following command when installing `latest`:
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
npm install -g @minimax-ai/code@latest --registry=https://registry.npmjs.org/ --foreground-scripts --ignore-scripts=false --include=optional --allow-scripts=@minimax-ai/code,better-sqlite3
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
Keep the package name, version, and registry from the original installation command. For a Preview
|
|
290
|
+
or pinned installation, retain the exact version instead of switching to `latest`. List the same
|
|
291
|
+
MCode package name and `better-sqlite3` in `--allow-scripts`. Setting `--ignore-scripts=false` alone
|
|
292
|
+
does not approve scripts in npm 12; `--include=optional` ensures the SQLite dependency is installed.
|
|
293
|
+
|
|
294
|
+
Start `mcode` after `[MCode] Native SQLite check passed.` appears. This repairs native dependencies
|
|
295
|
+
in the installation directory and preserves existing configuration and Sessions. If it still fails,
|
|
296
|
+
provide the complete new installation log and the output of `node --version` and `npm --version`
|
|
297
|
+
to investigate download, build, or runtime errors.
|
|
298
|
+
|
|
299
|
+
</details>
|
|
300
|
+
|
|
270
301
|
<details>
|
|
271
302
|
<summary>Authentication or Provider problems</summary>
|
|
272
303
|
|
package/README.zh-CN.md
CHANGED
|
@@ -12,7 +12,7 @@ Code 能理解代码库、修改文件、执行命令和测试,并把每次工
|
|
|
12
12
|
需要 Node.js `22.19+`(Node 22)或 Node.js `24–26`。
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
|
-
npm install -g @minimax-ai/code
|
|
15
|
+
npm install -g @minimax-ai/code --allow-scripts=@minimax-ai/code,better-sqlite3 --registry=https://registry.npmjs.org/
|
|
16
16
|
cd your-project
|
|
17
17
|
mcode
|
|
18
18
|
```
|
|
@@ -222,11 +222,37 @@ Code:
|
|
|
222
222
|
|
|
223
223
|
```bash
|
|
224
224
|
node --version
|
|
225
|
-
npm install -g @minimax-ai/code
|
|
225
|
+
npm install -g @minimax-ai/code --allow-scripts=@minimax-ai/code,better-sqlite3 --registry=https://registry.npmjs.org/
|
|
226
226
|
```
|
|
227
227
|
|
|
228
228
|
</details>
|
|
229
229
|
|
|
230
|
+
<details>
|
|
231
|
+
<summary>npm 12 安装脚本被阻止,或启动时提示 SQLite 原生依赖缺失</summary>
|
|
232
|
+
|
|
233
|
+
npm 12 默认阻止未经授权的安装脚本。如果安装日志出现 `npm warn install-scripts`,并列出 MCode 的
|
|
234
|
+
`postinstall` 和 `better-sqlite3` 的 `install` 被阻止,即使 npm 显示 `added` 或 `changed packages`,
|
|
235
|
+
SQLite 原生模块也可能没有准备好。启动时可能提示 `Could not locate the bindings file`、缺少
|
|
236
|
+
`better_sqlite3.node`,或外层的 `migration_failed`。
|
|
237
|
+
|
|
238
|
+
通过官方 Shell/PowerShell 安装器安装的用户,重跑原安装命令即可。安装器和 `/update` 会处理所需的
|
|
239
|
+
脚本参数与原生依赖;如果 MCode 已无法启动,先重跑安装器修复。
|
|
240
|
+
|
|
241
|
+
通过 `npm install -g` 安装的用户,优先执行启动错误中给出的修复命令。下面的命令适用于安装 `latest`:
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
npm install -g @minimax-ai/code@latest --registry=https://registry.npmjs.org/ --foreground-scripts --ignore-scripts=false --include=optional --allow-scripts=@minimax-ai/code,better-sqlite3
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
保留原安装命令的包名、版本和 registry;安装 Preview 或指定版本时,沿用原来的精确版本,避免切换到
|
|
248
|
+
`latest`。`--allow-scripts` 中填写相同的 MCode 包名及 `better-sqlite3`。只加
|
|
249
|
+
`--ignore-scripts=false` 不能代替 npm 12 的脚本授权;`--include=optional` 确保安装 SQLite 依赖。
|
|
250
|
+
|
|
251
|
+
看到 `[MCode] Native SQLite check passed.` 后再启动 `mcode`。此操作修复安装目录中的原生依赖,保留已有配置和会话。
|
|
252
|
+
若仍失败,提供本次完整安装日志,以及 `node --version` 和 `npm --version` 的输出,以继续排查下载、编译或运行时错误。
|
|
253
|
+
|
|
254
|
+
</details>
|
|
255
|
+
|
|
230
256
|
<details>
|
|
231
257
|
<summary>登录或 Provider 异常</summary>
|
|
232
258
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __mavis_cR } from "module"; import { basename as __mavis_basename, dirname as __mavis_dirname, join as __mavis_join } from "path"; import { fileURLToPath as __mavis_fileURLToPath, pathToFileURL as __mavis_pathToFileURL } from "url"; const __mavis_tuiCurrentModuleDir = __mavis_dirname(__mavis_fileURLToPath(import.meta.url)); const __mavis_tuiPackageRoot = __mavis_basename(__mavis_tuiCurrentModuleDir) === "chunks" ? __mavis_dirname(__mavis_tuiCurrentModuleDir) : __mavis_tuiCurrentModuleDir; const __mavis_tuiPackageEntryUrl = __mavis_pathToFileURL(__mavis_join(__mavis_tuiPackageRoot, "cli.js")).href; const require = __mavis_cR(__mavis_tuiPackageEntryUrl); const __dirname = __mavis_tuiPackageRoot;
|
|
2
|
-
import{c as a}from"./chunk-
|
|
2
|
+
import{c as a}from"./chunk-WMOPXI4T.js";import"./chunk-C3JRMX7L.js";import"./chunk-UQHSY5YK.js";import"./chunk-NW6DSOE3.js";import"./chunk-O6RIRKRN.js";import"./chunk-HQ2U4QVQ.js";import"./chunk-MMRA4VD2.js";import"./chunk-CWWDVX6C.js";import"./chunk-D76SO2ME.js";export{a as McodeUpdateApplication};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire as __mavis_cR } from "module"; import { basename as __mavis_basename, dirname as __mavis_dirname, join as __mavis_join } from "path"; import { fileURLToPath as __mavis_fileURLToPath, pathToFileURL as __mavis_pathToFileURL } from "url"; const __mavis_tuiCurrentModuleDir = __mavis_dirname(__mavis_fileURLToPath(import.meta.url)); const __mavis_tuiPackageRoot = __mavis_basename(__mavis_tuiCurrentModuleDir) === "chunks" ? __mavis_dirname(__mavis_tuiCurrentModuleDir) : __mavis_tuiCurrentModuleDir; const __mavis_tuiPackageEntryUrl = __mavis_pathToFileURL(__mavis_join(__mavis_tuiPackageRoot, "cli.js")).href; const require = __mavis_cR(__mavis_tuiPackageEntryUrl); const __dirname = __mavis_tuiPackageRoot;
|
|
2
|
-
import{a as o,b as p,c as u}from"./chunk-
|
|
2
|
+
import{a as o,b as p,c as u}from"./chunk-RXHPXCVW.js";import"./chunk-ACTS7L64.js";import{d as n}from"./chunk-5MDJKLXG.js";import"./chunk-SEVVS6ZS.js";import"./chunk-XO2KLR35.js";import"./chunk-ZITT4GJK.js";import"./chunk-MMRA4VD2.js";import"./chunk-CWWDVX6C.js";import"./chunk-D76SO2ME.js";async function f(e={}){let t=e.createApplication?e.createApplication(e.region):await c(e.region,e.prepareDataDir),a=e.writeError??(r=>process.stderr.write(r));return(await t.login(r=>{let i=p(r.verificationUriComplete??r.verificationUri);if(a(`Open: ${i}
|
|
3
3
|
Code: ${r.userCode}
|
|
4
4
|
Waiting for authorization\u2026
|
|
5
5
|
`),e.openBrowser===!1)return;(e.openExternalTarget??o(process.cwd()))(i).catch(()=>{a(`Couldn't open the default browser. Open the authorization URL above manually.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __mavis_cR } from "module"; import { basename as __mavis_basename, dirname as __mavis_dirname, join as __mavis_join } from "path"; import { fileURLToPath as __mavis_fileURLToPath, pathToFileURL as __mavis_pathToFileURL } from "url"; const __mavis_tuiCurrentModuleDir = __mavis_dirname(__mavis_fileURLToPath(import.meta.url)); const __mavis_tuiPackageRoot = __mavis_basename(__mavis_tuiCurrentModuleDir) === "chunks" ? __mavis_dirname(__mavis_tuiCurrentModuleDir) : __mavis_tuiCurrentModuleDir; const __mavis_tuiPackageEntryUrl = __mavis_pathToFileURL(__mavis_join(__mavis_tuiPackageRoot, "cli.js")).href; const require = __mavis_cR(__mavis_tuiPackageEntryUrl); const __dirname = __mavis_tuiPackageRoot;
|
|
2
|
-
import{a as R,b as g,c as h}from"./chunk-ECV3PLKX.js";import
|
|
2
|
+
import{a as R,b as g,c as h}from"./chunk-ECV3PLKX.js";import{a as y}from"./chunk-SHXPTUWI.js";import"./chunk-PWQHCWDV.js";import{b as f}from"./chunk-IIHJNKC3.js";import"./chunk-II4JKPH5.js";import{f as d,g as l,h as A,j as E}from"./chunk-KSPFS4MM.js";import{a as m}from"./chunk-CK62QLTS.js";import"./chunk-WFWSBUYD.js";import"./chunk-D76SO2ME.js";var w="v1",U=new Set(["openai","openai-codex","opencode","azure-openai-responses"]);function O(r){let t=new Map;if(!r)return t;for(let e of r.split(",")){let s=e.trim();if(!s)continue;let[a,n]=s.split("=",2);!a||!n||t.set(a.trim(),n.trim())}return t}function I(r,t){return t?.azureDeploymentName?t.azureDeploymentName:O(process.env.AZURE_OPENAI_DEPLOYMENT_NAME_MAP).get(r.id)||r.id}function z(r){if(r instanceof Error){let t=r.status,e=typeof t=="number"?t:void 0;return e!==void 0?`Azure OpenAI API error (${e}): ${r.message}`:r.message}try{return JSON.stringify(r)}catch{return String(r)}}var N=(r,t,e)=>{let s=new l;return(async()=>{let a=I(r,e),n={role:"assistant",content:[],api:"azure-openai-responses",provider:r.provider,model:r.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{let o=e?.apiKey;if(!o)throw new Error(`No API key for provider: ${r.provider}`);let i=L(r,o,e),u=M(r,t,e,a),c=await e?.onPayload?.(u,r);c!==void 0&&(u=c);let _={...e?.signal?{signal:e.signal}:{},...e?.timeoutMs!==void 0?{timeout:e.timeoutMs}:{},maxRetries:e?.maxRetries??0},{data:v,response:p}=await i.responses.create(u,_).withResponse();if(await e?.onResponse?.({status:p.status,headers:m(p.headers)},r),s.push({type:"start",partial:n}),await h(v,n,s,r),e?.signal?.aborted)throw new Error("Request was aborted");if(n.stopReason==="aborted"||n.stopReason==="error")throw new Error("An unknown error occurred");s.push({type:"done",reason:n.stopReason,message:n}),s.end()}catch(o){A(e?.onProviderError,o,r);for(let i of n.content)delete i.index,delete i.partialJson;n.stopReason=e?.signal?.aborted?"aborted":"error",n.errorMessage=z(o),s.push({type:"error",reason:n.stopReason,error:n}),s.end()}})(),s},V=(r,t,e)=>{let s=e?.apiKey;if(!s)throw new Error(`No API key for provider: ${r.provider}`);let a=E(r,e,s),n=e?.reasoning?d(r,e.reasoning):void 0;return N(r,t,{...a,reasoningEffort:n==="off"?void 0:n})};function P(r){let t=r.trim().replace(/\/+$/,""),e;try{e=new URL(t)}catch{throw new Error(`Invalid Azure OpenAI base URL: ${r}`)}let s=e.hostname.endsWith(".openai.azure.com")||e.hostname.endsWith(".cognitiveservices.azure.com"),a=e.pathname.replace(/\/+$/,"");return s&&(a===""||a==="/"||a==="/openai")&&(e.pathname="/openai/v1",e.search=""),e.toString().replace(/\/+$/,"")}function b(r){return`https://${r}.openai.azure.com/openai/v1`}function S(r,t){let e=t?.azureApiVersion||process.env.AZURE_OPENAI_API_VERSION||w,s=t?.azureBaseUrl?.trim()||process.env.AZURE_OPENAI_BASE_URL?.trim()||void 0,a=t?.azureResourceName||process.env.AZURE_OPENAI_RESOURCE_NAME,n=s;if(!n&&a&&(n=b(a)),!n&&r.baseUrl&&(n=r.baseUrl),!n)throw new Error("Azure OpenAI base URL is required. Set AZURE_OPENAI_BASE_URL or AZURE_OPENAI_RESOURCE_NAME, or pass azureBaseUrl, azureResourceName, or model.baseUrl.");return{baseUrl:P(n),apiVersion:e}}function L(r,t,e){let s={...r.headers};e?.headers&&Object.assign(s,e.headers);let{baseUrl:a,apiVersion:n}=S(r,e);return new f({apiKey:t,apiVersion:n,dangerouslyAllowBrowser:!0,defaultHeaders:s,baseURL:a})}function M(r,t,e,s){let a=R(r,t,U),n={model:s,input:a,stream:!0,prompt_cache_key:y(e?.sessionId),store:!1};if(e?.maxTokens&&(n.max_output_tokens=e?.maxTokens),e?.temperature!==void 0&&(n.temperature=e?.temperature),t.tools&&t.tools.length>0&&(n.tools=g(t.tools)),r.reasoning)if(e?.reasoningEffort||e?.reasoningSummary){let o=e?.reasoningEffort?r.thinkingLevelMap?.[e.reasoningEffort]??e.reasoningEffort:"medium";n.reasoning={effort:o,summary:e?.reasoningSummary||"auto"},n.include=["reasoning.encrypted_content"]}else r.thinkingLevelMap?.off!==null&&(n.reasoning={effort:r.thinkingLevelMap?.off??"none"});return n}export{N as streamAzureOpenAIResponses,V as streamSimpleAzureOpenAIResponses};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __mavis_cR } from "module"; import { basename as __mavis_basename, dirname as __mavis_dirname, join as __mavis_join } from "path"; import { fileURLToPath as __mavis_fileURLToPath, pathToFileURL as __mavis_pathToFileURL } from "url"; const __mavis_tuiCurrentModuleDir = __mavis_dirname(__mavis_fileURLToPath(import.meta.url)); const __mavis_tuiPackageRoot = __mavis_basename(__mavis_tuiCurrentModuleDir) === "chunks" ? __mavis_dirname(__mavis_tuiCurrentModuleDir) : __mavis_tuiCurrentModuleDir; const __mavis_tuiPackageEntryUrl = __mavis_pathToFileURL(__mavis_join(__mavis_tuiPackageRoot, "cli.js")).href; const require = __mavis_cR(__mavis_tuiPackageEntryUrl); const __dirname = __mavis_tuiPackageRoot;
|
|
2
|
-
import{
|
|
2
|
+
import{k as i,m as D}from"./chunk-SEVVS6ZS.js";import{$ as a,p as n}from"./chunk-XO2KLR35.js";function o(t,r=n,e=a){return r(void 0,e())}function u(){return o(i())}function m(t){let r=t.MINIMAX_DATA_DIR?.trim();return r||t.MAVIS_DATA_DIR?.trim()||void 0}function f(t=process.env,r=u){return m(t)??r()}function v(t=u,r=process.env){return f(r,t)}function p(t={}){let r=(t.getBuildEnv??i)(),e=v(t.getDefaultDataDir??(()=>o(r)),t.environment??process.env);return(t.configureRuntimeEnvironment??D)({dataDir:e}),Promise.resolve(e)}export{o as a,f as b,v as c,p as d};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __mavis_cR } from "module"; import { basename as __mavis_basename, dirname as __mavis_dirname, join as __mavis_join } from "path"; import { fileURLToPath as __mavis_fileURLToPath, pathToFileURL as __mavis_pathToFileURL } from "url"; const __mavis_tuiCurrentModuleDir = __mavis_dirname(__mavis_fileURLToPath(import.meta.url)); const __mavis_tuiPackageRoot = __mavis_basename(__mavis_tuiCurrentModuleDir) === "chunks" ? __mavis_dirname(__mavis_tuiCurrentModuleDir) : __mavis_tuiCurrentModuleDir; const __mavis_tuiPackageEntryUrl = __mavis_pathToFileURL(__mavis_join(__mavis_tuiPackageRoot, "cli.js")).href; const require = __mavis_cR(__mavis_tuiPackageEntryUrl); const __dirname = __mavis_tuiPackageRoot;
|
|
2
|
-
import{b as i,c as n,d as o,
|
|
2
|
+
import{b as i,c as n,d as o,h as a,i as r}from"./chunk-SEVVS6ZS.js";function s(t){let e=i({dataDir:t.dataDir,buildEnv:t.buildEnv,region:t.region}),u=t.oauthClient??h(t.oauthEndpoints),d=r({authHome:e.namespaceHome});return new a({namespace:e,oauthClient:u,credentialStore:d,initialize:()=>n(e)})}function h(t){if(!t)throw new TypeError("Shared MCode OAuth requires explicit device authorization, token, and revocation endpoints.");return new o(t)}export{s as a};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire as __mavis_cR } from "module"; import { basename as __mavis_basename, dirname as __mavis_dirname, join as __mavis_join } from "path"; import { fileURLToPath as __mavis_fileURLToPath, pathToFileURL as __mavis_pathToFileURL } from "url"; const __mavis_tuiCurrentModuleDir = __mavis_dirname(__mavis_fileURLToPath(import.meta.url)); const __mavis_tuiPackageRoot = __mavis_basename(__mavis_tuiCurrentModuleDir) === "chunks" ? __mavis_dirname(__mavis_tuiCurrentModuleDir) : __mavis_tuiCurrentModuleDir; const __mavis_tuiPackageEntryUrl = __mavis_pathToFileURL(__mavis_join(__mavis_tuiPackageRoot, "cli.js")).href; const require = __mavis_cR(__mavis_tuiPackageEntryUrl); const __dirname = __mavis_tuiPackageRoot;
|
|
2
|
-
import{c as d,i as f}from"./chunk-
|
|
2
|
+
import{c as d,i as f}from"./chunk-MQKRH5EW.js";var h=/<(?:deliver[-_]assets|media|publish[_-]artifact|preview_card|genui-|mavis-widget|mavis-thinking|mavis-progress|think|final|permission-(?:ask|response)|questionnaire-(?:ask|response))\b|^\s*preview_cards?:\s*$/imu;function L(t){let n=k(t);return n.assets.length===0?n.text:[n.text,T(n.assets)].filter(Boolean).join(`
|
|
3
3
|
|
|
4
4
|
`)}function k(t){if(!t||!h.test(t))return{text:t,assets:[]};let n=d(t),e=[],s=[],r="\uE000mcode-protected";for(;t.includes(r);)r+="-";let i=!1,o=n.map(a=>{if(a.type==="protected"){let c=e.push(a.content)-1;return`${r}-${c}\uE001`}return h.test(a.content)?(i=!0,A(a.content,s)):a.content}).join("");if(!i)return{text:t,assets:[]};let u=_(o);e.forEach((a,c)=>{u=u.replace(`${r}-${c}\uE001`,a)});let l=[...new Map(s.map(a=>[a.path.trim(),a])).values()];return{text:u,assets:l.map(a=>({path:a.path.trim(),...a.name?.trim()?{name:a.name.trim()}:{}}))}}function A(t,n){let e=t;return e=p(e,"mavis-thinking"),e=p(e,"think"),e=w(e,"mavis-progress"),e=p(e,"permission-ask"),e=p(e,"permission-response"),e=p(e,"questionnaire-ask"),e=p(e,"questionnaire-response"),e=e.replace(/<\/?final\b[^>]*>/giu,""),e=y(e),e=$(e),e=D(e),e=E(e),e=I(e,n),e=e.replace(/<\/?(?:deliver-assets|deliver_assets)\b[^>]*>/giu,"file attachment").replace(/<media\b[^>]*\/?>/giu,"file attachment").replace(/<media\b[^>]*$/iu,""),e}function p(t,n){let e=new RegExp(`<${n}\\b[^>]*>((?:(?!<${n}\\b)[\\s\\S])*?)<\\/${n}\\s*>`,"giu"),s=t,r=t.replace(e,"");for(;r!==s;)s=r,r=r.replace(e,"");return r}function w(t,n){let e=new RegExp(`<${n}\\b[^>]*>((?:(?!<${n}\\b)[\\s\\S])*?)<\\/${n}\\s*>`,"giu"),s=t,r=t.replace(e,(i,o)=>o.trim());for(;r!==s;)s=r,r=r.replace(e,(i,o)=>o.trim());return r}function y(t){let n=/<mavis-widget\b([^>]*)>([\s\S]*?)<\/mavis-widget\s*>/giu,e=t.replace(n,(s,r,i)=>{let o=/<mavis-fallback\b[^>]*>([\s\S]*?)<\/mavis-fallback\s*>/iu.exec(i)?.[1];return o?.trim()?o.trim():v(g(r))});return e=e.replace(/<mavis-widget\b([^>]*)>[\s\S]*$/iu,(s,r)=>v(g(r))),e.replace(/<mavis-widget\b[^>]*$/iu,"Interactive content is loading\u2026")}function v(t){let n=t.kind?.trim(),e=t.title?.trim();return n&&e?`Interactive ${n}: ${e} (open in Desktop).`:e?`Interactive content: ${e} (open in Desktop).`:"Interactive content available in Desktop."}function $(t){let n=/<genui-([\w-]+)\b([^>]*)>[\s\S]*?<\/genui-\1\s*>/giu,e=/<genui-([\w-]+)\b([^>]*?)\/\s*>/giu,s=t.replace(n,(r,i,o)=>b(i,g(o)));return s=s.replace(e,(r,i,o)=>b(i,g(o))),s.replace(/<genui-[\w-]*\b[^>]*$/iu,"Interactive content is loading\u2026")}function b(t,n){if(t.toLocaleLowerCase()==="mcp-auth"){let e=n.label?.trim()||n["server-id"]?.trim();return e?`MCP authorization required: ${e} (open in Desktop).`:"MCP authorization required (open in Desktop)."}if(t.toLocaleLowerCase()==="agent-team-recommendation"){let e=n.status?.trim().toLocaleLowerCase();return e==="accepted"?"Team recommendation accepted.":e==="skipped"?"Team recommendation skipped.":"Team recommendation available in Desktop."}return"Interactive content available in Desktop."}function g(t){let n={},e=/([\w-]+)\s*=\s*(["'])(.*?)\2/gu,s;for(;(s=e.exec(t))!==null;){let r=s[1],i=s[3];r&&i!==void 0&&(n[r]=C(i))}return n}function D(t){let n=/<(deliver-assets|deliver_assets)\b[^>]*>\s*<\/\1\s*>/giu,e=t,s=t.replace(n,"");for(;s!==e;)e=s,s=s.replace(n,"");return s}function C(t){return t.replace(/"/gu,'"').replace(/'|'/gu,"'").replace(/</gu,"<").replace(/>/gu,">").replace(/&/gu,"&")}function E(t){let n=/<\/?(deliver-assets|deliver_assets)\b[^>]*>/giu,e=[],s;for(;(s=n.exec(t))!==null;)e.push({start:s.index,end:n.lastIndex,name:s[1]?.toLocaleLowerCase()??"",closing:s[0].startsWith("</")});if(e.length===0)return t;let r=[],i=new Set;if(e.forEach((l,a)=>{if(!l.closing){r.push(a);return}for(let c=r.length-1;c>=0;c-=1){let m=r[c];if(!(m===void 0||e[m]?.name!==l.name)){r.splice(c,1),i.add(m),i.add(a);return}}}),i.size===e.length)return t;let o=0,u="";return e.forEach((l,a)=>{u+=t.slice(o,l.start),u+=i.has(a)?t.slice(l.start,l.end):"file attachment",o=l.end}),u+t.slice(o)}function I(t,n){let e=t;for(let s=0;s<3;s+=1){let r=f(e),i=R(r);if(i.assets.length===0)break;n.push(...i.assets),e=i.text}return e}function R(t){let n=[],e=[];for(let s of t)s.type==="deliver-assets"||s.type==="image-gallery"?e.push(...s.items):s.content.trim()&&n.push(s.content.trim());return{text:n.join(`
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire as __mavis_cR } from "module"; import { basename as __mavis_basename, dirname as __mavis_dirname, join as __mavis_join } from "path"; import { fileURLToPath as __mavis_fileURLToPath, pathToFileURL as __mavis_pathToFileURL } from "url"; const __mavis_tuiCurrentModuleDir = __mavis_dirname(__mavis_fileURLToPath(import.meta.url)); const __mavis_tuiPackageRoot = __mavis_basename(__mavis_tuiCurrentModuleDir) === "chunks" ? __mavis_dirname(__mavis_tuiCurrentModuleDir) : __mavis_tuiCurrentModuleDir; const __mavis_tuiPackageEntryUrl = __mavis_pathToFileURL(__mavis_join(__mavis_tuiPackageRoot, "cli.js")).href; const require = __mavis_cR(__mavis_tuiPackageEntryUrl); const __dirname = __mavis_tuiPackageRoot;
|
|
2
|
-
import{a as
|
|
2
|
+
import{a as J}from"./chunk-SHXPTUWI.js";import{a as P}from"./chunk-IIHJNKC3.js";import{a as U,b as H,c as W,d as $}from"./chunk-LOQ4VVEN.js";import{b}from"./chunk-II4JKPH5.js";import{d as L,f as B,g as z,h as N,i as D,j,l as G}from"./chunk-KSPFS4MM.js";import{a as O}from"./chunk-CK62QLTS.js";import{a as A}from"./chunk-WFWSBUYD.js";function oe(e){for(let n of e)if(n.role==="toolResult"||n.role==="assistant"&&n.content.some(t=>t.type==="toolCall"))return!0;return!1}function K(e){return e.type==="text"}function re(e){return e.type==="thinking"}function se(e){return e.type==="toolCall"}function ie(e){return e.type==="image"}function Z(e){return e||(typeof process<"u"&&process.env.PI_CACHE_RETENTION==="long"?"long":"short")}var ae=(e,n,t)=>{let o=new z;return(async()=>{let s={role:"assistant",content:[],api:e.api,provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{let c=t?.apiKey;if(!c)throw new Error(`No API key for provider: ${e.provider}`);let g=q(e),r=Z(t?.cacheRetention),i=r==="none"?void 0:t?.sessionId,u=le(e,n,c,t?.headers,i,g,t?.fetch),h=ce(e,n,t,g,r),k=await t?.onPayload?.(h,e);k!==void 0&&(h=k);let _={...t?.signal?{signal:t.signal}:{},...t?.timeoutMs!==void 0?{timeout:t.timeoutMs}:{},maxRetries:t?.maxRetries??0},{data:T,response:R}=await u.chat.completions.create(h,_).withResponse();await t?.onResponse?.({status:R.status,headers:O(R.headers)},e),o.push({type:"start",partial:s});let x=null,l=null,y=!1,S=new Map,w=new Map,M=s.content,C=a=>M.indexOf(a),X=a=>{let f=C(a);f!==-1&&(a.type==="text"?o.push({type:"text_end",contentIndex:f,content:a.text,partial:s}):a.type==="thinking"?o.push({type:"thinking_end",contentIndex:f,content:a.thinking,partial:s}):a.type==="toolCall"&&(a.arguments=b(a.partialArgs),delete a.partialArgs,delete a.streamIndex,o.push({type:"toolcall_end",contentIndex:f,toolCall:a,partial:s})))},Y=()=>(x||(x={type:"text",text:""},M.push(x),o.push({type:"text_start",contentIndex:C(x),partial:s})),x),ee=a=>(l||(l={type:"thinking",thinking:"",thinkingSignature:a},M.push(l),o.push({type:"thinking_start",contentIndex:C(l),partial:s})),l),te=a=>{let f=typeof a.index=="number"?a.index:void 0,d=f!==void 0?S.get(f):void 0;return!d&&a.id&&(d=w.get(a.id)),d||(d={type:"toolCall",id:a.id||"",name:a.function?.name||"",arguments:{},partialArgs:"",streamIndex:f},f!==void 0&&S.set(f,d),a.id&&w.set(a.id,d),M.push(d),o.push({type:"toolcall_start",contentIndex:C(d),partial:s})),f!==void 0&&d.streamIndex===void 0&&(d.streamIndex=f,S.set(f,d)),a.id&&w.set(a.id,d),d},ne=D(T,t?.onProviderStreamEvent,e);for await(let a of ne){if(!a||typeof a!="object")continue;s.responseId||=a.id,typeof a.model=="string"&&a.model.length>0&&a.model!==e.id&&(s.responseModel||=a.model),a.usage&&(s.usage=V(a.usage,e));let f=Array.isArray(a.choices)?a.choices[0]:void 0;if(f){if(!a.usage&&f.usage&&(s.usage=V(f.usage,e)),f.finish_reason){let d=Re(f.finish_reason);s.stopReason=d.stopReason,d.errorMessage&&(s.errorMessage=d.errorMessage),y=!0}if(f.delta){if(f.delta.content!==null&&f.delta.content!==void 0&&f.delta.content.length>0){let p=Y();p.text+=f.delta.content,o.push({type:"text_delta",contentIndex:C(p),delta:f.delta.content,partial:s})}let d=["reasoning_content","reasoning","reasoning_text"],F=f.delta,E=null;for(let p of d){let m=F[p];if(typeof m=="string"&&m.length>0){E=p;break}}if(E){let p=F[E];if(typeof p=="string"&&p.length>0){let m=e.provider==="opencode-go"&&E==="reasoning"?"reasoning_content":E,v=ee(m);v.thinking+=p,o.push({type:"thinking_delta",contentIndex:C(v),delta:p,partial:s})}}if(f?.delta?.tool_calls)for(let p of f.delta.tool_calls){let m=te(p);!m.id&&p.id&&(m.id=p.id,w.set(p.id,m)),!m.name&&p.function?.name&&(m.name=p.function.name);let v="";p.function?.arguments&&(v=p.function.arguments,m.partialArgs=(m.partialArgs??"")+p.function.arguments,m.arguments=b(m.partialArgs)),o.push({type:"toolcall_delta",contentIndex:C(m),delta:v,partial:s})}let I=f.delta.reasoning_details;if(I&&Array.isArray(I)){for(let p of I)if(p.type==="reasoning.encrypted"&&p.id&&p.data){let m=s.content.find(v=>v.type==="toolCall"&&v.id===p.id);m&&(m.thoughtSignature=JSON.stringify(p))}}}}}for(let a of M)X(a);if(t?.signal?.aborted)throw new Error("Request was aborted");if(s.stopReason==="aborted")throw new Error("Request was aborted");if(s.stopReason==="error")throw new Error(s.errorMessage||"Provider returned an error stop reason");if(!y)throw new Error("Stream ended without finish_reason");o.push({type:"done",reason:s.stopReason,message:s}),o.end()}catch(c){N(t?.onProviderError,c,e);for(let r of s.content)delete r.index,delete r.partialArgs,delete r.streamIndex;s.stopReason=t?.signal?.aborted?"aborted":"error",s.errorMessage=c instanceof Error?c.message:JSON.stringify(c);let g=c?.error?.metadata?.raw;g&&(s.errorMessage+=`
|
|
3
3
|
${g}`),o.push({type:"error",reason:s.stopReason,error:s}),o.end()}})(),o},Fe=(e,n,t)=>{let o=t?.apiKey;if(!o)throw new Error(`No API key for provider: ${e.provider}`);let s=j(e,t,o),c=t?.reasoning?B(e,t.reasoning):void 0,g=c==="off"?void 0:c,r=t?.toolChoice;return ae(e,n,{...s,reasoningEffort:g,toolChoice:r})};function le(e,n,t,o,s,c=q(e),g){let r={...e.headers};if(e.provider==="github-copilot"){let u=W(n.messages),h=$({messages:n.messages,hasImages:u});Object.assign(r,h)}s&&c.sendSessionAffinityHeaders&&(r.session_id=s,r["x-client-request-id"]=s,r["x-session-affinity"]=s),o&&Object.assign(r,o);let i=e.provider==="cloudflare-ai-gateway"?{...r,Authorization:r.Authorization??null,"cf-aig-authorization":`Bearer ${t}`}:r;return new P({apiKey:t,baseURL:U(e.provider)?H(e):e.baseUrl,dangerouslyAllowBrowser:!0,...g?{fetch:g}:{},defaultHeaders:i})}function ce(e,n,t,o=q(e),s=Z(t?.cacheRetention)){let c=ke(e,n,o),g=ue(o,s),r={model:e.id,messages:c,stream:!0,prompt_cache_key:e.baseUrl.includes("api.openai.com")&&s!=="none"||s==="long"&&o.supportsLongCacheRetention?J(t?.sessionId):void 0,prompt_cache_retention:s==="long"&&o.supportsLongCacheRetention?"24h":void 0};if(o.supportsUsageInStreaming!==!1&&(r.stream_options={include_usage:!0}),o.supportsStore&&(r.store=!1),t?.maxTokens&&(o.maxTokensField==="max_tokens"?r.max_tokens=t.maxTokens:r.max_completion_tokens=t.maxTokens),t?.temperature!==void 0&&(r.temperature=t.temperature),n.tools&&n.tools.length>0?(r.tools=ye(n.tools,o),o.zaiToolStream&&(r.tool_stream=!0)):oe(n.messages)&&(r.tools=[]),g&&fe(c,r.tools,g),t?.toolChoice&&(r.tool_choice=t.toolChoice),o.thinkingFormat==="zai"&&e.reasoning){let i=r;i.thinking={type:t?.reasoningEffort?"enabled":"disabled"}}else if(o.thinkingFormat==="qwen"&&e.reasoning)r.enable_thinking=!!t?.reasoningEffort;else if(o.thinkingFormat==="qwen-chat-template"&&e.reasoning)r.chat_template_kwargs={enable_thinking:!!t?.reasoningEffort,preserve_thinking:!0};else if(o.thinkingFormat==="deepseek"&&e.reasoning)r.thinking={type:t?.reasoningEffort?"enabled":"disabled"},t?.reasoningEffort&&o.supportsReasoningEffort&&(r.reasoning_effort=e.thinkingLevelMap?.[t.reasoningEffort]??t.reasoningEffort);else if(o.thinkingFormat==="openrouter"&&e.reasoning){let i=r;t?.reasoningEffort?i.reasoning={effort:e.thinkingLevelMap?.[t.reasoningEffort]??t.reasoningEffort}:e.thinkingLevelMap?.off!==null&&(i.reasoning={effort:e.thinkingLevelMap?.off??"none"})}else if(o.thinkingFormat==="ant-ling"&&e.reasoning&&t?.reasoningEffort){let i=e.thinkingLevelMap?.[t.reasoningEffort];typeof i=="string"&&(r.reasoning={effort:i})}else if(o.thinkingFormat==="together"&&e.reasoning){let i=r;i.reasoning={enabled:!!t?.reasoningEffort},t?.reasoningEffort&&o.supportsReasoningEffort&&(i.reasoning_effort=e.thinkingLevelMap?.[t.reasoningEffort]??t.reasoningEffort)}else if(o.thinkingFormat==="string-thinking"&&e.reasoning){let i=r;t?.reasoningEffort?i.thinking=e.thinkingLevelMap?.[t.reasoningEffort]??t.reasoningEffort:e.thinkingLevelMap?.off!==null&&(i.thinking=e.thinkingLevelMap?.off??"none")}else if(t?.reasoningEffort&&e.reasoning&&o.supportsReasoningEffort)r.reasoning_effort=e.thinkingLevelMap?.[t.reasoningEffort]??t.reasoningEffort;else if(!t?.reasoningEffort&&e.reasoning&&o.supportsReasoningEffort){let i=e.thinkingLevelMap?.off;typeof i=="string"&&(r.reasoning_effort=i)}if(e.compat?.openRouterRouting&&(r.provider=e.compat.openRouterRouting),e.baseUrl.includes("ai-gateway.vercel.sh")&&e.compat?.vercelGatewayRouting){let i=e.compat.vercelGatewayRouting;if(i.only||i.order){let u={};i.only&&(u.only=i.only),i.order&&(u.order=i.order),r.providerOptions={gateway:u}}}return r}function ue(e,n){if(e.cacheControlFormat!=="anthropic"||n==="none")return;let t=n==="long"&&e.supportsLongCacheRetention?"1h":void 0;return{type:"ephemeral",...t?{ttl:t}:{}}}function fe(e,n,t){pe(e,t),he(n,t),ge(e,t)}function pe(e,n){for(let t of e)if(t.role==="system"||t.role==="developer"){de(t,n);return}}function ge(e,n){for(let t=e.length-1;t>=0;t--){let o=e[t];if((o.role==="user"||o.role==="assistant")&&me(o,n))return}}function he(e,n){if(!e||e.length===0)return;let t=e[e.length-1];t.cache_control=n}function de(e,n){return Q(e,n)}function me(e,n){return e.role==="user"||e.role==="assistant"?Q(e,n):!1}function Q(e,n){let t=e.content;if(typeof t=="string")return t.length===0?!1:(e.content=[{type:"text",text:t,cache_control:n}],!0);if(!Array.isArray(t))return!1;for(let o=t.length-1;o>=0;o--){let s=t[o];if(s?.type==="text"){let c=s;return c.cache_control=n,!0}}return!1}function ke(e,n,t){let o=[],s=r=>{if(r.includes("|")){let[i]=r.split("|");return i.replace(/[^a-zA-Z0-9_-]/g,"_").slice(0,40)}return e.provider==="openai"&&r.length>40?r.slice(0,40):r},c=G(n.messages,e,r=>s(r));if(n.systemPrompt){let i=e.reasoning&&t.supportsDeveloperRole?"developer":"system";o.push({role:i,content:A(n.systemPrompt)})}let g=null;for(let r=0;r<c.length;r++){let i=c[r];if(t.requiresAssistantAfterToolResult&&g==="toolResult"&&i.role==="user"&&o.push({role:"assistant",content:"I have processed the tool results."}),i.role==="user")if(typeof i.content=="string")o.push({role:"user",content:A(i.content)});else{let u=i.content.map(h=>h.type==="text"?{type:"text",text:A(h.text)}:{type:"image_url",image_url:{url:`data:${h.mimeType};base64,${h.data}`}});if(u.length===0)continue;o.push({role:"user",content:u})}else if(i.role==="assistant"){let u={role:"assistant",content:t.requiresAssistantAfterToolResult?"":null},h=i.content.filter(K).filter(l=>l.text.trim().length>0).map(l=>({type:"text",text:A(l.text)})),k=h.map(l=>l.text).join(""),_=i.content.filter(re).filter(l=>l.thinking.trim().length>0);if(_.length>0)if(t.requiresThinkingAsText){let l=_.map(y=>A(y.thinking)).join(`
|
|
4
4
|
|
|
5
5
|
`);u.content=[{type:"text",text:l},...h]}else{k.length>0&&(u.content=k);let l=_[0].thinkingSignature;e.provider==="opencode-go"&&l==="reasoning"&&(l="reasoning_content"),l&&l.length>0&&(u[l]=_.map(y=>y.thinking).join(`
|