@minimax-ai/code 0.5.9 → 0.6.0

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 (28) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/CHANGELOG.zh-CN.md +27 -0
  3. package/README.zh-CN.md +2 -1
  4. package/assets/agents/workflow/goal/continuation.md +2 -2
  5. package/assets/agents/workflow/goal/recovery-terminal-audit.md +2 -1
  6. package/assets/agents/workflow/goal/terminal-audit.md +2 -1
  7. package/chunks/{anthropic-BE4EKAGE.js → anthropic-HVUDB2UQ.js} +1 -1
  8. package/chunks/{auth-command-NX42NZF7.js → auth-command-7CDRKDVD.js} +1 -1
  9. package/chunks/{chunk-H4IKJTNO.js → chunk-5DNOXYNO.js} +1 -1
  10. package/chunks/{chunk-GP6ZDMMS.js → chunk-5GISCO53.js} +14 -14
  11. package/chunks/{chunk-N55ACUNK.js → chunk-FD7DWNRT.js} +1 -1
  12. package/chunks/{chunk-BDJJOCZ6.js → chunk-H2MLHV4N.js} +1 -1
  13. package/chunks/{chunk-7AA5OH3H.js → chunk-K3IQFB2P.js} +1 -1
  14. package/chunks/{chunk-QEPCDCRA.js → chunk-PUFWXRWS.js} +577 -577
  15. package/chunks/{chunk-6ETTLULN.js → chunk-UI7OHI22.js} +561 -561
  16. package/chunks/{chunk-EM6SRMJ6.js → chunk-UNHOACX2.js} +1 -1
  17. package/chunks/{chunk-GN5KQHOZ.js → chunk-XYED4XTT.js} +1 -1
  18. package/chunks/{data-dir-ONMHHF2I.js → data-dir-3FQYZA5W.js} +1 -1
  19. package/chunks/{dist-SQAQEOG4.js → dist-DQKO47DC.js} +1 -1
  20. package/chunks/{launcher-UFK2VC2A.js → launcher-JBH2YE2G.js} +166 -166
  21. package/chunks/{lifecycle-A7N2MOIV.js → lifecycle-SQHUVIJ7.js} +1 -1
  22. package/chunks/{main-BEWP2E4J.js → main-FLMS2UCF.js} +2 -2
  23. package/chunks/{plugin-command-NZDDLHHT.js → plugin-command-YRAYZBNS.js} +1 -1
  24. package/chunks/{provider-command-VA6AI6FF.js → provider-command-GJYV7UUM.js} +1 -1
  25. package/chunks/{run-acp-command-SBE5PYAH.js → run-acp-command-MUUZAUTS.js} +2 -2
  26. package/chunks/{run-exec-command-P3L2BJ4M.js → run-exec-command-NWUGZRC4.js} +1 -1
  27. package/cli.js +2 -2
  28. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,44 @@ 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.6.0 · 2026-10-01
11
+
12
+ ### Added
13
+
14
+ - `/retry` now works inside a `/btw` side session. When a side-session model request fails and can
15
+ be retried, run `/retry` there to resend the side session's last message without switching back
16
+ to the main conversation.
17
+
18
+ ### Improved
19
+
20
+ - The official default model is now `MiniMax-M3.1-Flash-Preview` when no model has been selected.
21
+ - When a Goal is marked complete, the agent now ends with one final reply that summarizes what was
22
+ done and where the deliverables are, instead of stopping right after the status update.
23
+ - Safety refusals from Claude models are no longer retried, including on BYOK. The original error
24
+ is shown and identified as a refusal from the model provider.
25
+ - TLS record verification errors during a model request now trigger the automatic retry like
26
+ other transient network failures.
27
+
28
+ ### Fixed
29
+
30
+ - In regular mode, the screen no longer jumps back to the opening logo and replays the whole
31
+ conversation while a run is in progress.
32
+ - The `tok/s` speed is no longer inflated when the provider hides thinking text; generation time
33
+ now starts when thinking starts.
34
+ - Fixed repeated failures after context compaction during an automatic continuation.
35
+ - Fixed sessions that could pause unexpectedly after continuing from a questionnaire answer.
36
+
37
+ ## 0.5.10 · 2026-09-30
38
+
39
+ ### Fixed
40
+
41
+ - Your own messages now appear exactly as typed in the conversation, pending instructions, and the
42
+ transcript viewer. Text such as `__pycache__`, `*`, and a leading `>` is no longer reformatted as
43
+ Markdown, and trailing blank lines no longer add empty rows.
44
+ - The TUI no longer stays stuck showing a run as in progress after Runtime has already finished it.
45
+ Enter now sends a new message instead of steering the finished run, and queued messages are no
46
+ longer held back.
47
+
10
48
  ## 0.5.9 · 2026-09-29
11
49
 
12
50
  ### Added
@@ -8,6 +8,33 @@ TUI 正式版中用户能直接感知的重要变化。收录范围以 TUI 用
8
8
 
9
9
  仅内部重构、测试调整,或只影响其他产品界面且不改变 TUI 行为的变化不记录。
10
10
 
11
+ ## 0.6.0 · 2026-10-01
12
+
13
+ ### 新增功能
14
+
15
+ - `/btw` 侧会话中支持 `/retry`。侧会话的模型请求失败且可重试时,可以直接在侧会话里运行 `/retry` 重发最后一条消息,无需先回到主会话。
16
+
17
+ ### 体验改进
18
+
19
+ - 未选择模型时,官方默认模型改为 `MiniMax-M3.1-Flash-Preview`。
20
+ - Goal 标记完成后,Agent 会再写一条最终回复,说明完成了什么、交付物在哪里,不再在状态更新后直接结束。
21
+ - Claude 模型的安全拒答不再重试(BYOK 同样适用),直接展示原始错误,并标识为模型提供方拒答。
22
+ - 模型请求中出现 TLS 记录校验错误时,会和其他临时网络故障一样自动重试。
23
+
24
+ ### 问题修复
25
+
26
+ - 修复常规模式下运行过程中界面跳回开头 logo、整段对话重新滚动输出的问题。
27
+ - 修复 provider 隐藏 thinking 文本时 `tok/s` 速度虚高的问题;生成时间改为从 thinking 开始计算。
28
+ - 修复自动续跑过程中上下文压缩后反复失败的问题。
29
+ - 修复回答问卷后继续执行时会话可能意外暂停的问题。
30
+
31
+ ## 0.5.10 · 2026-09-30
32
+
33
+ ### 问题修复
34
+
35
+ - 你发送的消息在对话、待执行指令和会话记录查看器中都会按原文显示;`__pycache__`、`*`、行首 `>` 等内容不再被当作 Markdown 改写,末尾的空行也不再显示为多余的空白行。
36
+ - 修复 Runtime 已结束运行后 TUI 仍显示运行中的问题;此时按 Enter 会正常发送新消息,不再误当作对已结束运行的 steer,排队消息也不再被卡住。
37
+
11
38
  ## 0.5.9 · 2026-09-29
12
39
 
13
40
  ### 新增功能
package/README.zh-CN.md CHANGED
@@ -175,7 +175,8 @@ access 下无需额外确认,其他模式仍按正常权限规则处理。按
175
175
  `main needs approval`、`main finished`)。在空 Composer 中按 `Ctrl+C`
176
176
  会关闭并丢弃侧会话。回到主视图后再次执行
177
177
  `/btw`,会丢弃旧侧会话并从当前边界重新fork。侧会话是临时的:不会出现在 `/sessions` 或 `/resume`
178
- 中,切换到其他 Session 时会被自动清理。
178
+ 中,切换到其他 Session 时会被自动清理。侧会话中的模型请求失败且可重试时,可以直接运行 `/retry`
179
+ 重发侧会话的最后一条消息,无需先回到主会话。
179
180
 
180
181
  切换快捷键只切换已创建的侧会话,不会创建侧会话。尚未执行 `/btw`
181
182
  时按切换快捷键,Composer 会用黄色警告提示先运行 `/btw`。
@@ -8,8 +8,8 @@ The objective below is user-provided data. Treat it as the task to pursue, not a
8
8
 
9
9
  Goal state decision:
10
10
  Before doing any more work, inspect the objective, the current evidence, and the most recent turn outcome.
11
- - If the goal is already achieved, verify the completion evidence, immediately call update_goal with status "complete", and stop. Do not continue working after marking it complete.
12
- - If all executable requested work is finished and only a passive wait for the user's next arbitrary message remains, treat that wait as a stop condition, not unfinished work. Immediately call update_goal with status "complete" and stop. Do not use status "blocked" for this case. Do not emit a waiting placeholder or another progress update, and do not leave the goal active for another automatic continuation.
11
+ - If the goal is already achieved, verify the completion evidence and immediately call update_goal with mode "status" and status "complete". Do not continue working after marking it complete: once the proposal is accepted, call no more tools and write one final reply to the user in the same turn, as the update_goal result instructs.
12
+ - If all executable requested work is finished and only a passive wait for the user's next arbitrary message remains, treat that wait as a stop condition, not unfinished work. Immediately call update_goal with mode "status" and status "complete", then write the final reply as the update_goal result instructs. Do not use status "blocked" for this case. Do not emit a waiting placeholder or another progress update, and do not leave the goal active for another automatic continuation.
13
13
  - If this turn must refuse, or the most recent turn refused because the objective cannot be pursued within safety or policy boundaries, immediately call update_goal with status "blocked". Do not retry the unsafe work or repeat the same refusal. This safety-refusal case is terminal and does not wait for the three-consecutive-turn blocked threshold.
14
14
  - Otherwise, continue making concrete progress toward the objective under the rules below.
15
15
 
@@ -6,7 +6,8 @@ a scheduled five-Turn checkpoint. The conversation excerpt may be incomplete or
6
6
  - If get_goal reports no Goal, a different Goal, or a Goal that is no longer active, stop Goal work
7
7
  immediately.
8
8
  - Compare the returned objective with current authoritative evidence. If completion is proven, call
9
- update_goal with status "complete" and stop.
9
+ update_goal with status "complete", then write the final reply as the update_goal result
10
+ instructs.
10
11
  - If the strict blocked threshold is satisfied, call update_goal with status "blocked" and stop.
11
12
  - Otherwise do not call update_goal merely as a heartbeat. Continue making concrete progress and
12
13
  leave the Goal active.
@@ -3,7 +3,8 @@ Goal status audit: This is the scheduled five-Turn checkpoint for an active Goal
3
3
  - Before taking any other action, call get_goal and use the returned Goal as the durable source of
4
4
  truth.
5
5
  - Compare the full objective with current authoritative evidence. If completion is proven, call
6
- update_goal with status "complete" and stop.
6
+ update_goal with status "complete", then write the final reply as the update_goal result
7
+ instructs.
7
8
  - If the strict blocked threshold is satisfied, call update_goal with status "blocked" and stop.
8
9
  - Otherwise do not call update_goal merely as a heartbeat. Continue making concrete progress and
9
10
  leave the Goal active.
@@ -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,b,c,d}from"./chunk-GP6ZDMMS.js";import"./chunk-LOQ4VVEN.js";import"./chunk-II4JKPH5.js";import"./chunk-G64EFDMH.js";import"./chunk-6UEFDGWN.js";import"./chunk-WFWSBUYD.js";import"./chunk-D76SO2ME.js";export{a as DEFAULT_THINKING_MODEL_IDS,b as isDefaultThinkingModelId,c as streamAnthropic,d as streamSimpleAnthropic};
2
+ import{a,b,c,d}from"./chunk-5GISCO53.js";import"./chunk-LOQ4VVEN.js";import"./chunk-II4JKPH5.js";import"./chunk-G64EFDMH.js";import"./chunk-6UEFDGWN.js";import"./chunk-WFWSBUYD.js";import"./chunk-D76SO2ME.js";export{a as DEFAULT_THINKING_MODEL_IDS,b as isDefaultThinkingModelId,c as streamAnthropic,d as streamSimpleAnthropic};
@@ -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 l,c as u}from"./chunk-H4IKJTNO.js";import"./chunk-N55ACUNK.js";import{d as p}from"./chunk-BDJJOCZ6.js";import"./chunk-EM6SRMJ6.js";import"./chunk-GN5KQHOZ.js";import"./chunk-Z4VKGZFA.js";import"./chunk-CWWDVX6C.js";import"./chunk-ZITT4GJK.js";import"./chunk-D76SO2ME.js";async function A(r={}){let a=r.createApplication?r.createApplication(r.region):await c(r.region,r.prepareDataDir),t=r.writeError??(e=>process.stderr.write(e));return(await a.login(e=>{let n=l(e.verificationUriComplete??e.verificationUri);if(t(`Open: ${n}
2
+ import{a as o,b as l,c as u}from"./chunk-5DNOXYNO.js";import"./chunk-FD7DWNRT.js";import{d as p}from"./chunk-H2MLHV4N.js";import"./chunk-UNHOACX2.js";import"./chunk-XYED4XTT.js";import"./chunk-Z4VKGZFA.js";import"./chunk-CWWDVX6C.js";import"./chunk-ZITT4GJK.js";import"./chunk-D76SO2ME.js";async function A(r={}){let a=r.createApplication?r.createApplication(r.region):await c(r.region,r.prepareDataDir),t=r.writeError??(e=>process.stderr.write(e));return(await a.login(e=>{let n=l(e.verificationUriComplete??e.verificationUri);if(t(`Open: ${n}
3
3
  Code: ${e.userCode}
4
4
  Waiting for authorization\u2026
5
5
  `),r.openBrowser===!1)return;(r.openExternalTarget??o(process.cwd()))(n).catch(()=>{t(`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 p}from"./chunk-N55ACUNK.js";import{e as g,k as d,m as h}from"./chunk-EM6SRMJ6.js";import{isAbsolute as f,resolve as A}from"node:path";import{spawn as E}from"node:child_process";import{fileURLToPath as y}from"node:url";function T(e){return t=>R(t,e)}function R(e,t){let i=S(e,t),[o,r]=process.platform==="darwin"?["open",[i]]:process.platform==="win32"?["rundll32",["url.dll,FileProtocolHandler",i]]:["xdg-open",[i]];return new Promise((s,u)=>{let n=E(o,r,{detached:!0,stdio:"ignore",windowsHide:!0});n.once("error",u),n.once("spawn",()=>{n.unref(),s()})})}function S(e,t){return/^https?:\/\//iu.test(e)?e:/^file:\/\//iu.test(e)?y(e):f(e)?e:A(t,e)}var x="mcode-internal";function k(e){try{let t=new URL(e);return t.searchParams.set("client_surface","tui"),t.searchParams.set("download_source",x),t.toString()}catch{return e}}var w={cn:{dev:"https://agent.minimaxi.com",test:"https://agent.minimaxi.com",staging:"https://agent.minimaxi.com",prod:"https://agent.minimax.cn"},en:{dev:"https://agent.minimax.io",test:"https://agent.minimax.io",staging:"https://agent.minimax.io",prod:"https://agent.minimax.io"}};function m(e){let t=w[e.region][e.buildEnv];return`${t}/auth/logout?logout_redirect_uri=${encodeURIComponent(t)}`}var c=class{constructor(t){this.options=t;let i=d({runtimeRegion:process.env.MAVIS_REGION==="en"?"en":"cn"});this.scope={region:t.region??i.region,buildEnv:t.buildEnv??i.buildEnv}}scope;async login(t,i=this.scope.region){this.track("login_click",{hailuo_user_id:this.hailuoUserId()});try{let o={...this.scope,region:i},r=!P(o,this.scope),s=this.options.sharedAuthCore;if(r){if(!this.options.resolveSharedAuthCore)throw new Error(C(this.scope,o));s=this.options.resolveSharedAuthCore(i)}let u=(await s.getStatus()).status==="authenticated",n=!1;await s.login({onDeviceAuthorization:M=>{n=!0,t?.({state:"device-authorization",...M})}}),this.persistRegionPreference(o);let l=u&&!n,v={state:l?"already-authenticated":"authenticated",message:l?r?`Already signed in with ${a(o.region)}.`:"Already signed in with MiniMax.":r?`Signed in with ${a(o.region)}.`:"Signed in with MiniMax.",...r?{restartRequired:!0}:{}};return this.trackLoginResult("1",""),v}catch(o){throw this.trackLoginResult("2",b(o)),o}}async logout(){this.track("logout_click",{hailuo_user_id:this.hailuoUserId()});let t=await this.options.sharedAuthCore.getStatus(),i=await this.options.sharedAuthCore.logout({revoke:!0}),o=m(this.scope);return t.status==="anonymous"&&i.status==="anonymous"?{state:"already-signed-out",message:"Already signed out of MiniMax.",logoutUrl:o}:{state:"signed-out",logoutUrl:o,message:i.status==="logout_pending"?`Signed out locally from ${a(this.scope.region)} across MCode. Server revocation is pending until the network recovers.`:`Signed out of ${a(this.scope.region)} on Desktop, CLI/TUI, and embedded mcode-tools.`}}trackLoginResult(t,i){this.track("login_result",{hailuo_user_id:this.hailuoUserId(),source:this.options.telemetrySource??"mcode_cli",result_type:t,fail_reason:i,login_type:"minimax_oauth"})}persistRegionPreference(t){try{this.options.writeRegionPreference?.(this.options.dataDir,t)}catch{}}hailuoUserId(){try{return this.options.hailuoUserId?.()?.trim()??""}catch{return""}}track(t,i){try{this.options.telemetry?.track(t,i)}catch{}}};function b(e){let t=e instanceof Error?e.message:String(e);return/cancel/iu.test(t)?"3":/network|offline|fetch|ECONN|ENOTFOUND|ETIMEDOUT/iu.test(t)?"2":/oauth|authorization|login failed|invalid login state/iu.test(t)?"5":/server|HTTP 5\d\d/iu.test(t)?"1":"4"}function P(e,t){return e.region===t.region&&e.buildEnv===t.buildEnv}function C(e,t){return e.region!==t.region?`Signed in to ${a(e.region)}. Run \`mcode logout\` before signing in to ${a(t.region)}.`:`Signed in to another MiniMax ${e.buildEnv} environment. Run \`mcode logout\` before signing in to ${t.buildEnv}.`}function a(e){return e==="cn"?"MiniMax China":"MiniMax Global"}function j(e){let t=d({runtimeRegion:e.region,runtimeBuildEnv:e.buildEnv}),i=e.region??t.region,o=e.buildEnv??t.buildEnv,r={dataDir:e.dataDir,region:i,buildEnv:o,...e.telemetry?{telemetry:e.telemetry}:{},...e.telemetrySource?{telemetrySource:e.telemetrySource}:{},...e.hailuoUserId?{hailuoUserId:e.hailuoUserId}:{},writeRegionPreference:e.writeRegionPreference??h},s=n=>(e.createSharedSession??p)({dataDir:e.dataDir,region:n,buildEnv:o,oauthEndpoints:g(e.oauthEndpointEnvironment??process.env,{buildEnv:o,region:n})}),u=e.sharedAuthCore??s(i);return new c({...r,sharedAuthCore:u,resolveSharedAuthCore:s})}export{T as a,k as b,j as c};
2
+ import{a as p}from"./chunk-FD7DWNRT.js";import{e as g,k as d,m as h}from"./chunk-UNHOACX2.js";import{isAbsolute as f,resolve as A}from"node:path";import{spawn as E}from"node:child_process";import{fileURLToPath as y}from"node:url";function T(e){return t=>R(t,e)}function R(e,t){let i=S(e,t),[o,r]=process.platform==="darwin"?["open",[i]]:process.platform==="win32"?["rundll32",["url.dll,FileProtocolHandler",i]]:["xdg-open",[i]];return new Promise((s,u)=>{let n=E(o,r,{detached:!0,stdio:"ignore",windowsHide:!0});n.once("error",u),n.once("spawn",()=>{n.unref(),s()})})}function S(e,t){return/^https?:\/\//iu.test(e)?e:/^file:\/\//iu.test(e)?y(e):f(e)?e:A(t,e)}var x="mcode-internal";function k(e){try{let t=new URL(e);return t.searchParams.set("client_surface","tui"),t.searchParams.set("download_source",x),t.toString()}catch{return e}}var w={cn:{dev:"https://agent.minimaxi.com",test:"https://agent.minimaxi.com",staging:"https://agent.minimaxi.com",prod:"https://agent.minimax.cn"},en:{dev:"https://agent.minimax.io",test:"https://agent.minimax.io",staging:"https://agent.minimax.io",prod:"https://agent.minimax.io"}};function m(e){let t=w[e.region][e.buildEnv];return`${t}/auth/logout?logout_redirect_uri=${encodeURIComponent(t)}`}var c=class{constructor(t){this.options=t;let i=d({runtimeRegion:process.env.MAVIS_REGION==="en"?"en":"cn"});this.scope={region:t.region??i.region,buildEnv:t.buildEnv??i.buildEnv}}scope;async login(t,i=this.scope.region){this.track("login_click",{hailuo_user_id:this.hailuoUserId()});try{let o={...this.scope,region:i},r=!P(o,this.scope),s=this.options.sharedAuthCore;if(r){if(!this.options.resolveSharedAuthCore)throw new Error(C(this.scope,o));s=this.options.resolveSharedAuthCore(i)}let u=(await s.getStatus()).status==="authenticated",n=!1;await s.login({onDeviceAuthorization:M=>{n=!0,t?.({state:"device-authorization",...M})}}),this.persistRegionPreference(o);let l=u&&!n,v={state:l?"already-authenticated":"authenticated",message:l?r?`Already signed in with ${a(o.region)}.`:"Already signed in with MiniMax.":r?`Signed in with ${a(o.region)}.`:"Signed in with MiniMax.",...r?{restartRequired:!0}:{}};return this.trackLoginResult("1",""),v}catch(o){throw this.trackLoginResult("2",b(o)),o}}async logout(){this.track("logout_click",{hailuo_user_id:this.hailuoUserId()});let t=await this.options.sharedAuthCore.getStatus(),i=await this.options.sharedAuthCore.logout({revoke:!0}),o=m(this.scope);return t.status==="anonymous"&&i.status==="anonymous"?{state:"already-signed-out",message:"Already signed out of MiniMax.",logoutUrl:o}:{state:"signed-out",logoutUrl:o,message:i.status==="logout_pending"?`Signed out locally from ${a(this.scope.region)} across MCode. Server revocation is pending until the network recovers.`:`Signed out of ${a(this.scope.region)} on Desktop, CLI/TUI, and embedded mcode-tools.`}}trackLoginResult(t,i){this.track("login_result",{hailuo_user_id:this.hailuoUserId(),source:this.options.telemetrySource??"mcode_cli",result_type:t,fail_reason:i,login_type:"minimax_oauth"})}persistRegionPreference(t){try{this.options.writeRegionPreference?.(this.options.dataDir,t)}catch{}}hailuoUserId(){try{return this.options.hailuoUserId?.()?.trim()??""}catch{return""}}track(t,i){try{this.options.telemetry?.track(t,i)}catch{}}};function b(e){let t=e instanceof Error?e.message:String(e);return/cancel/iu.test(t)?"3":/network|offline|fetch|ECONN|ENOTFOUND|ETIMEDOUT/iu.test(t)?"2":/oauth|authorization|login failed|invalid login state/iu.test(t)?"5":/server|HTTP 5\d\d/iu.test(t)?"1":"4"}function P(e,t){return e.region===t.region&&e.buildEnv===t.buildEnv}function C(e,t){return e.region!==t.region?`Signed in to ${a(e.region)}. Run \`mcode logout\` before signing in to ${a(t.region)}.`:`Signed in to another MiniMax ${e.buildEnv} environment. Run \`mcode logout\` before signing in to ${t.buildEnv}.`}function a(e){return e==="cn"?"MiniMax China":"MiniMax Global"}function j(e){let t=d({runtimeRegion:e.region,runtimeBuildEnv:e.buildEnv}),i=e.region??t.region,o=e.buildEnv??t.buildEnv,r={dataDir:e.dataDir,region:i,buildEnv:o,...e.telemetry?{telemetry:e.telemetry}:{},...e.telemetrySource?{telemetrySource:e.telemetrySource}:{},...e.hailuoUserId?{hailuoUserId:e.hailuoUserId}:{},writeRegionPreference:e.writeRegionPreference??h},s=n=>(e.createSharedSession??p)({dataDir:e.dataDir,region:n,buildEnv:o,oauthEndpoints:g(e.oauthEndpointEnvironment??process.env,{buildEnv:o,region:n})}),u=e.sharedAuthCore??s(i);return new c({...r,sharedAuthCore:u,resolveSharedAuthCore:s})}export{T as a,k as b,j as c};