@minimax-ai/code 0.3.4 → 0.3.6
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 +42 -0
- package/CHANGELOG.zh-CN.md +21 -0
- package/README.md +21 -2
- package/README.zh-CN.md +23 -3
- package/chunks/{application-2DVWZRSC.js → application-NV4X3RV4.js} +1 -1
- package/chunks/{auth-command-BYZBT26P.js → auth-command-AYTFOBP7.js} +1 -1
- package/chunks/{azure-openai-responses-FWEOB2GJ.js → azure-openai-responses-TYAI4QCH.js} +1 -1
- package/chunks/{chunk-FJNVTQRZ.js → chunk-BN5ADI2D.js} +495 -495
- package/chunks/{chunk-3JJ4GGTW.js → chunk-EJS4KRR2.js} +1 -1
- package/chunks/{chunk-BLWZ6QN5.js → chunk-G7PNCKMS.js} +1 -1
- package/chunks/chunk-GF6XEUE6.js +2 -0
- package/chunks/{chunk-JAU52A7E.js → chunk-GMXY243M.js} +1 -1
- package/chunks/{chunk-XAM5MDT7.js → chunk-ISF4HEC4.js} +1 -1
- package/chunks/{chunk-KIJODLFS.js → chunk-J63OB7U2.js} +4 -4
- package/chunks/chunk-KXO2REWJ.js +164 -0
- package/chunks/{chunk-SAVPNWES.js → chunk-RM42PCDV.js} +20 -20
- package/chunks/chunk-RWIFT2VZ.js +3 -0
- package/chunks/{chunk-3BG5GJ7D.js → chunk-TJUTHJIS.js} +544 -544
- package/chunks/{chunk-XRVRMFGU.js → chunk-VBDTVEVF.js} +1 -1
- package/chunks/chunk-ZXOZXMWQ.js +33 -0
- package/chunks/{data-dir-VQU534BQ.js → data-dir-2ZJFRWW6.js} +1 -1
- package/chunks/dist-S32WQUVY.js +2 -0
- package/chunks/install-source-O2EK6H3D.js +2 -0
- package/chunks/{launcher-CUOP2LLI.js → launcher-FVXKFL4F.js} +133 -133
- package/chunks/{lifecycle-4233WOSA.js → lifecycle-E2PPZ25G.js} +1 -1
- package/chunks/{main-45BYDYEP.js → main-5I5LJBKT.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-TYRSMPKK.js → plugin-command-P3VM77DS.js} +1 -1
- package/chunks/{provider-command-GO6JOVHN.js → provider-command-GUP4G3TR.js} +1 -1
- package/chunks/{run-acp-command-ROVIUCO5.js → run-acp-command-2YNDWCTK.js} +2 -2
- package/chunks/{run-exec-command-ZW4RIF64.js → run-exec-command-O7SOL3RW.js} +1 -1
- package/chunks/{update-N3TZCYN3.js → update-JJ5EYXC6.js} +1 -1
- package/cli.js +2 -2
- package/package.json +1 -1
- package/verify-native-install.mjs +4 -4
- package/chunks/chunk-OYVCWRBD.js +0 -155
- package/chunks/chunk-TYJKJAGQ.js +0 -33
- package/chunks/chunk-UF7HXY5Q.js +0 -2
- package/chunks/dist-K5PPY2Q5.js +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,48 @@ 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.6 · 2026-09-07
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- When MCode shares its data directory with MiniMax Desktop, official model endpoints are now
|
|
15
|
+
resolved in memory for the current environment: reading configuration or first-run
|
|
16
|
+
initialization no longer writes new official endpoints into the shared config file, so older
|
|
17
|
+
Desktop versions keep working alongside the TUI. Custom (BYOK) endpoints behave as before.
|
|
18
|
+
- Legacy model recovery now also covers numbered model aliases and retired default models, and
|
|
19
|
+
applies consistently to the model list, Goal model checks, and login checks: selections
|
|
20
|
+
pointing at the legacy official gateway resolve to the same-name official model, then the
|
|
21
|
+
configured default model, then the current official default. Shared default models, session
|
|
22
|
+
model references, and migration records are preserved; only explicit user selections are
|
|
23
|
+
written back to configuration.
|
|
24
|
+
- Installing or updating with npm 12 no longer breaks the native SQLite module: install and
|
|
25
|
+
update authorize the MCode and `better-sqlite3` lifecycle scripts and keep optional native
|
|
26
|
+
dependencies. When native SQLite fails to load, startup prints a repair command matching the
|
|
27
|
+
install registry, and early startup errors are reported instead of failing silently.
|
|
28
|
+
|
|
29
|
+
## 0.3.5 · 2026-09-07
|
|
30
|
+
|
|
31
|
+
### Fixed
|
|
32
|
+
|
|
33
|
+
- Legacy model repair now also covers resuming sessions and queued messages, not just startup:
|
|
34
|
+
selections from the legacy custom provider switch to the same model on the official MiniMax
|
|
35
|
+
provider, or to the official default model when the same model is unavailable, and the repair
|
|
36
|
+
is saved to the session or default configuration. The model list no longer shows legacy
|
|
37
|
+
entries.
|
|
38
|
+
- After a response fails or is stopped, queued messages that have not run yet are kept and shown
|
|
39
|
+
as paused. Run `/queue` and press `c` to continue from the front of the queue; pending
|
|
40
|
+
messages can also be edited, restored, or deleted. Sending a new message while paused offers
|
|
41
|
+
to send it first and then continue the original queue, or to clear pending messages first;
|
|
42
|
+
cancelling keeps your draft. Reopening the session shows the paused queue and waits for you to
|
|
43
|
+
continue.
|
|
44
|
+
- In-TUI updates now run npm with MCode's own Node runtime and validate the new version's native
|
|
45
|
+
modules with that exact runtime before activation, fixing startup failures after updating on
|
|
46
|
+
machines whose system Node version differs. If validation fails, the previous version stays
|
|
47
|
+
active.
|
|
48
|
+
- The macOS/Linux installer resolves the selected Node to its real path for install, launcher,
|
|
49
|
+
and receipt, and re-checks native modules with that runtime on reruns. Broken same-version
|
|
50
|
+
installations now enter a repair install automatically instead of being reported as healthy.
|
|
51
|
+
|
|
10
52
|
## 0.3.4 · 2026-09-06
|
|
11
53
|
|
|
12
54
|
### Improved
|
package/CHANGELOG.zh-CN.md
CHANGED
|
@@ -8,6 +8,27 @@ TUI 正式版中用户能直接感知的重要变化。收录范围以 TUI 用
|
|
|
8
8
|
|
|
9
9
|
仅内部重构、测试调整,或只影响其他产品界面且不改变 TUI 行为的变化不记录。
|
|
10
10
|
|
|
11
|
+
## 0.3.6 · 2026-09-07
|
|
12
|
+
|
|
13
|
+
### 问题修复
|
|
14
|
+
|
|
15
|
+
- 与 MiniMax 桌面端共用数据目录时,官方模型地址改为在 TUI 内按当前环境解析:读取配置和首次初始化不再向共享配置文件写入新的官方地址,避免影响旧版桌面端;自定义(BYOK)服务地址行为不变。
|
|
16
|
+
- 遗留模型自动恢复扩展到编号模型别名和已下线的默认模型,并统一覆盖模型列表、Goal
|
|
17
|
+
模型校验和登录检查:指向旧官方网关的模型选择依次解析为官方同名模型、配置默认模型和当前官方默认模型;共享默认模型、会话模型引用和迁移记录保持不变,仅用户主动选择模型才会写回配置。
|
|
18
|
+
- 修复 npm 12 下安装或更新导致 SQLite 原生模块损坏的问题:安装和更新会授权 MCode 与
|
|
19
|
+
`better-sqlite3` 的安装脚本并保留可选原生依赖;原生模块加载失败时,启动会按安装来源给出对应的修复命令,启动早期错误也会如实报告而不是静默失败。
|
|
20
|
+
|
|
21
|
+
## 0.3.5 · 2026-09-07
|
|
22
|
+
|
|
23
|
+
### 问题修复
|
|
24
|
+
|
|
25
|
+
- 旧版自定义渠道模型的自动修复从启动时扩展到恢复会话和排队消息:遗留模型选择会切换为官方渠道同名模型,同名模型不可用时使用官方默认模型,并保存到对应会话或默认配置;模型列表不再显示遗留渠道入口。
|
|
26
|
+
- 响应失败或被停止后,尚未执行的排队消息会保留并显示暂停状态。运行 `/queue` 后按 `c`
|
|
27
|
+
可从队首继续,也可以编辑、恢复或删除待发送消息;暂停期间发送新消息时,可选择先发送新消息再继续原队列,或先清空待发送消息,取消则保留草稿。重新打开会话会显示暂停队列,等待主动继续。
|
|
28
|
+
- TUI 内更新改用 MCode 自带的 Node 运行 npm,并在激活前用同一运行时校验新版本的原生模块,修复系统
|
|
29
|
+
Node 版本不同导致更新后无法启动的问题;校验失败时保持旧版本可用。
|
|
30
|
+
- macOS/Linux 安装器将所选 Node 解析为真实路径,统一用于安装、启动器和安装回执,重跑时按该运行时检查原生模块;同版本安装损坏时自动进入修复安装,无需手动清理安装目录。
|
|
31
|
+
|
|
11
32
|
## 0.3.4 · 2026-09-06
|
|
12
33
|
|
|
13
34
|
### 体验改进
|
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,30 @@ 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>Missing native SQLite dependency or blocked installation scripts</summary>
|
|
272
|
+
|
|
273
|
+
npm 12 blocks unapproved installation scripts by default. Allow scripts for the current MCode
|
|
274
|
+
package and `better-sqlite3` when installing. Setting `ignore-scripts=false` still requires
|
|
275
|
+
approval through `--allow-scripts`.
|
|
276
|
+
|
|
277
|
+
If startup reports `Could not locate the bindings file` or a missing `better_sqlite3.node`,
|
|
278
|
+
reinstall with the installation log visible:
|
|
279
|
+
|
|
280
|
+
```bash
|
|
281
|
+
npm install -g @minimax-ai/code --registry=https://registry.npmjs.org/ --foreground-scripts --ignore-scripts=false --include=optional --allow-scripts=@minimax-ai/code,better-sqlite3
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
Start `mcode` after `[MCode] Native SQLite check passed.` appears. This repairs native dependencies
|
|
285
|
+
in the installation directory and preserves existing configuration and Sessions.
|
|
286
|
+
|
|
287
|
+
</details>
|
|
288
|
+
|
|
270
289
|
<details>
|
|
271
290
|
<summary>Authentication or Provider problems</summary>
|
|
272
291
|
|
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
|
```
|
|
@@ -141,7 +141,11 @@ mcode login
|
|
|
141
141
|
MCode 登录态时,broker 调用会因需要认证而失败。在 TUI 进程之外仍可直接调用 `mcode-tools`;TUI 不会改写
|
|
142
142
|
该进程的环境或配置。
|
|
143
143
|
|
|
144
|
-
TUI
|
|
144
|
+
TUI 启动和恢复会话时,会将遗留的 `custom_provider:minimax-legacy` 选择修复为官方 `minimax` 同名模型;同名模型不可用时,使用有效的官方默认模型。修复会保存到对应的默认配置或会话。执行排队消息前也会检查其遗留模型引用,模型列表隐藏 legacy 入口。
|
|
145
|
+
|
|
146
|
+
响应失败或被停止后,尚未执行的 Queue 消息会保留并显示暂停状态。运行 `/queue` 后按 `c` 可从队首继续;也可以编辑、恢复或删除待发送消息。暂停时发送新消息,可选择先发送新消息再继续原队列,或清空待发送消息后发送;取消选择会保留草稿。重新打开会话会显示暂停队列,等待主动继续。
|
|
147
|
+
|
|
148
|
+
进入或退出 Plan 的下一条消息也使用上述恢复选择。选择 `Keep my draft` 或按 Esc 后,草稿可继续编辑、重新发送,不会发布本次发送的结果;尚未生效的 Plan 切换会保留。如果恢复发送时会话已经被另一轮占用,草稿会保留并提示失败,由用户再次发送。
|
|
145
149
|
|
|
146
150
|
在 TUI 中使用 `/model` 选择模型和推理强度。选择 `Add 3rd-party provider…` 可从 models.dev
|
|
147
151
|
搜索已知 Provider 和模型,或配置 Custom Provider。API Key 在表单中保持掩码,Runtime
|
|
@@ -218,9 +222,25 @@ Code:
|
|
|
218
222
|
|
|
219
223
|
```bash
|
|
220
224
|
node --version
|
|
221
|
-
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
|
+
```
|
|
227
|
+
|
|
228
|
+
</details>
|
|
229
|
+
|
|
230
|
+
<details>
|
|
231
|
+
<summary>SQLite 原生依赖缺失或安装脚本被阻止</summary>
|
|
232
|
+
|
|
233
|
+
npm 12 默认阻止未经授权的安装脚本。安装 MCode 时,需要允许当前 MCode 包和 `better-sqlite3`
|
|
234
|
+
的脚本执行;`ignore-scripts=false` 只解除全局禁用,仍需 `--allow-scripts` 授权。
|
|
235
|
+
|
|
236
|
+
如果启动提示 `Could not locate the bindings file` 或缺少 `better_sqlite3.node`,重新安装并显示安装日志:
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
npm install -g @minimax-ai/code --registry=https://registry.npmjs.org/ --foreground-scripts --ignore-scripts=false --include=optional --allow-scripts=@minimax-ai/code,better-sqlite3
|
|
222
240
|
```
|
|
223
241
|
|
|
242
|
+
看到 `[MCode] Native SQLite check passed.` 后再启动 `mcode`。此操作修复安装目录中的原生依赖,保留已有配置和会话。
|
|
243
|
+
|
|
224
244
|
</details>
|
|
225
245
|
|
|
226
246
|
<details>
|
|
@@ -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-ZXOZXMWQ.js";import"./chunk-C3JRMX7L.js";import"./chunk-KXO2REWJ.js";import"./chunk-RWIFT2VZ.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-G7PNCKMS.js";import"./chunk-ISF4HEC4.js";import{d as n}from"./chunk-VBDTVEVF.js";import"./chunk-J63OB7U2.js";import"./chunk-RM42PCDV.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};
|