@minimax-ai/code 0.6.0 → 0.6.1
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
CHANGED
|
@@ -7,6 +7,13 @@ 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.1 · 2026-10-01
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- `/doctor` and `/feedback` now work inside a `/btw` side session, so you can diagnose or report a
|
|
15
|
+
failed side response without leaving it.
|
|
16
|
+
|
|
10
17
|
## 0.6.0 · 2026-10-01
|
|
11
18
|
|
|
12
19
|
### Added
|
package/CHANGELOG.zh-CN.md
CHANGED
package/README.md
CHANGED
|
@@ -89,6 +89,7 @@ Runtime 从已持久化历史选择最近的完整前缀:工具调用已有全
|
|
|
89
89
|
按 `Ctrl+/` 切换主会话和侧会话,或用 `/parent` 返回主会话。侧会话底栏显示主任务状态。
|
|
90
90
|
在空输入框按 `Ctrl+C` 会关闭并丢弃侧会话;返回主会话后再次执行 `/btw` 会创建新的侧会话。
|
|
91
91
|
临时侧会话不出现在 `/sessions` 或 `/resume` 中,导航到其他会话时会被清理。
|
|
92
|
+
侧会话中可以直接运行 `/retry`、`/doctor` 和 `/feedback`,无需先回到主会话。
|
|
92
93
|
|
|
93
94
|
历史边界尚未准备好时显示等待提示。创建或加载失败时,诊断上传中的 MCode observability 日志
|
|
94
95
|
记录 `session.side.failed`,包括 `create` / `activate` 阶段、会话 ID 和经过脱敏、长度限制的异常原因链。
|
package/README.zh-CN.md
CHANGED
|
@@ -176,7 +176,8 @@ access 下无需额外确认,其他模式仍按正常权限规则处理。按
|
|
|
176
176
|
会关闭并丢弃侧会话。回到主视图后再次执行
|
|
177
177
|
`/btw`,会丢弃旧侧会话并从当前边界重新fork。侧会话是临时的:不会出现在 `/sessions` 或 `/resume`
|
|
178
178
|
中,切换到其他 Session 时会被自动清理。侧会话中的模型请求失败且可重试时,可以直接运行 `/retry`
|
|
179
|
-
|
|
179
|
+
重发侧会话的最后一条消息,无需先回到主会话;也可以直接运行 `/doctor` 检查配置,或用 `/feedback`
|
|
180
|
+
提交反馈。
|
|
180
181
|
|
|
181
182
|
切换快捷键只切换已创建的侧会话,不会创建侧会话。尚未执行 `/btw`
|
|
182
183
|
时按切换快捷键,Composer 会用黄色警告提示先运行 `/btw`。
|
|
@@ -202,7 +202,7 @@ Provider: ${n.errorProviderId?ft(n.errorProviderId):"configured"}`}var Wr=class{
|
|
|
202
202
|
`?e+1:fs(n,e)};if(t==="delete-line-start")return{start:n.lastIndexOf(`
|
|
203
203
|
`,Math.max(0,e-1))+1,end:e};let i=n.indexOf(`
|
|
204
204
|
`,e);return{start:e,end:i<0?n.length:i===e?i+1:i}}function k6(n,e){return[...new Intl.Segmenter(void 0,{granularity:"grapheme"}).segment(n.slice(0,e))].at(-1)?.index??0}function P6(n,e){let t=[...new Intl.Segmenter(void 0,{granularity:"grapheme"}).segment(n.slice(e))][0]?.segment;return t?e+t.length:e}function Yw(n){if(!n||n.schemaVersion!==1||typeof n.text!="string"||!_a(n.text,n.pluginMentions)||!Number.isInteger(n.cursor)||n.cursor<0||n.cursor>n.text.length||!Number.isInteger(n.pasteCounter)||n.pasteCounter<0||!Array.isArray(n.pastes)||n.attachmentPlaceholders!==void 0&&!Array.isArray(n.attachmentPlaceholders))return!1;let e=new Set;if(!n.pastes.every(({id:s,content:r})=>!Number.isInteger(s)||s<=0||s>n.pasteCounter||e.has(s)||typeof r!="string"?!1:(e.add(s),!0)))return!1;let t=new Set,i=[];return(n.attachmentPlaceholders??[]).every(s=>!Xw(s)||t.has(s.id)||s.end>n.text.length||n.text.slice(s.start,s.end)!==s.label||s.leadingSpace===!0&&n.text[s.start-1]!==" "||i.some(r=>Gr(n.text,s)<r.end&&s.end>r.start)?!1:(t.add(s.id),i.push({start:Gr(n.text,s),end:s.end}),!0))}function Xw(n){if(!n||typeof n!="object")return!1;let e=n;return typeof e.id=="string"&&e.id.length>0&&typeof e.label=="string"&&e.label.length>0&&Number.isInteger(e.start)&&Number.isInteger(e.end)&&(e.start??-1)>=0&&(e.end??0)>(e.start??-1)&&(e.leadingSpace===void 0||typeof e.leadingSpace=="boolean")}function _6(n,e){let t=[...n.text.matchAll($6)].flatMap(r=>{let o=Number(r[1]),a=n.pastes.find(u=>u.id===o);return!a||r.index===void 0?[]:[{start:r.index,end:r.index+r[0].length,paste:a,marker:r[0]}]}).map((r,o)=>{let a=e+o+1;return{...r,id:a,text:r.marker.replace(`#${String(r.paste.id)}`,`#${String(a)}`)}}),i=r=>r+t.filter(({end:o})=>o<=r).reduce((o,a)=>o+a.text.length-a.marker.length,0),s=n.text;for(let r of[...t].reverse())s=`${s.slice(0,r.start)}${r.text}${s.slice(r.end)}`;return{schemaVersion:1,text:s,cursor:i(n.cursor),pastes:t.map(({id:r,paste:o})=>({id:r,content:o.content})),pasteCounter:e+t.length,pluginMentions:n.pluginMentions?.map(r=>({...r,start:i(r.start),end:i(r.end)})),attachmentPlaceholders:(n.attachmentPlaceholders??[]).map(r=>({...r,start:i(r.start),end:i(r.end)}))}}function Jw(n){return new Map([...n].map(([e,t])=>[e,{...t}]))}function Yf(n,e){return n.slice(e.start,e.end)===e.label}function Gr(n,e){return e.leadingSpace===!0&&n[e.start-1]===" "?e.start-1:e.start}function bi(n,e){return e.end+(n[e.end]===" "?1:0)}function L6(n,e){let t=n,i=t.length,s=new Map;for(let[r,o]of e){let a=i>0&&!/\s/u.test(t[i-1]??"")?" ":"",u=i+a.length;t=`${t}${a}${o.label} `,s.set(r,{id:r,label:o.label,start:u,end:u+o.label.length,leadingSpace:a.length>0}),i=t.length}return{text:t,cursor:i,elements:s}}function Dc(n){let e=O6(n.text,n.attachmentPlaceholders??[]);return Xf(e,n.pastes).trim()}function Yi(n){if(!n.pluginMentions?.length)return;let e=n.text,t=[...n.pluginMentions.map(i=>({start:i.start,end:i.end,text:jr(i.label,[{...i,start:0,end:i.label.length}])})),...(n.attachmentPlaceholders??[]).map(i=>({start:Gr(e,i),end:bi(e,i),text:""}))].sort((i,s)=>s.start-i.start);for(let i of t)e=e.slice(0,i.start)+i.text+e.slice(i.end);return Xf(e,n.pastes).trim()}function O6(n,e){let t=n,i=e.filter(s=>Yf(n,s)).map(s=>({start:Gr(n,s),end:bi(n,s)})).sort((s,r)=>r.start-s.start);for(let s of i)t=`${t.slice(0,s.start)}${t.slice(s.end)}`;return t}function N6(n,e,t){let i=new Map,s=new Set,r=D6(n,e);if(!r)return{elements:Jw(t),deletedIds:s};let o=r.nextEnd-r.previousEnd;for(let[a,u]of t){if(u.end<=r.start){i.set(a,{...u});continue}if(u.start>=r.previousEnd){let l=u.start+o;i.set(a,{...u,start:l,end:u.end+o,leadingSpace:u.leadingSpace===!0&&e[l-1]===" "});continue}s.add(a)}return{elements:i,deletedIds:s}}function D6(n,e){if(n===e)return;let t=0;for(;t<n.length&&t<e.length&&n[t]===e[t];)t+=1;let i=n.length,s=e.length;for(;i>t&&s>t&&n[i-1]===e[s-1];)i-=1,s-=1;return{start:t,previousEnd:i,nextEnd:s}}function Xf(n,e){let t=n;for(let{id:i,content:s}of e)t=t.replace(new RegExp(`\\[paste #${i}(?: (?:\\+\\d+ lines|\\d+ chars))?\\]`,"gu"),()=>s);return t}function F6(n){if(!(!n||n.includes("\x1B")))return[...n].every(e=>{let t=e.codePointAt(0)??0;return t>=32&&t!==127})?n:void 0}var $6=/\[paste #(\d+)(?: (?:\+\d+ lines|\d+ chars))?\]/gu;var st=class extends gs{selection;constructor(e,t,i,s={}){let r={text:""},o=a=>u=>{let l=a(u.replace(/^→ /u,"\u203A "));return r.text=l,l};super(e,t,{...i,selectedText:o(i.selectedText),selectedPrefix:o(i.selectedPrefix)},{minPrimaryColumnWidth:12,maxPrimaryColumnWidth:32,...s}),this.selection=r}renderViewport(e,t){if(t<=0)return[];this.selection.text="";let i=this.render(e),s=this.selection.text?i.findIndex(o=>o.includes(this.selection.text)):0,r=Math.max(0,Math.min(s-Math.floor(t/2),i.length-t));return i.slice(r,r+t)}};var Zw={title:"History",helper:"Search previous prompts, inspect their impact, and choose a safe action.",loading:"Loading Session history\u2026",loadingHint:"Esc cancel",loadErrorHint:"Enter retry \xB7 Esc close",compactHint:"\u2191\u2193 \xB7 Enter \xB7 Esc",search:"Search",noResults:"No matching history points.",forkAvailable:"fork available",forkUnavailable:"Fork unavailable until the Assistant response is complete.",preparingFork:"Checking fork details\u2026",preparingEdit:"Loading edit impact\u2026",preparingRewind:"Loading rewind impact\u2026",preparingTarget:"Loading the selected message\u2026",hint:"\u2191\u2193 move \xB7 Enter actions \xB7 Esc close",filterHint:"\u2191\u2193 move \xB7 Enter actions \xB7 Esc clear search",incomplete:"Response incomplete",actions:"Choose history action",actionsHint:"\u2191\u2193 select \xB7 Enter continue \xB7 Esc back",mutationUnavailable:"Stop the running response before changing Session history.",fork:"Fork from here",forkDescription:"Create a child Session without changing this Session or its files.",edit:"Edit this input",editDescription:"Replace this prompt and regenerate from this point.",rewindConversation:"Rewind conversation",rewindConversationDescription:"Remove later messages while leaving workspace files unchanged.",rewindFiles:"Rewind conversation and files",rewindFilesDescription:"Remove later messages and restore eligible file changes.",running:"History is read-only until the current response finishes.",noSession:"Start or resume a Session before browsing history.",editPreviewHeading:"Edit preview",commandDescription:"Browse previous prompts and choose Fork, Edit, or Rewind",commandUnavailable:"Start or resume a Session before browsing history."},ex={"sessionMutation.history.fork.title":"Fork from a previous message","sessionMutation.history.fork.helper":"Pick a user message to fork the session from.","sessionMutation.history.rewind.title":"Rewind to a previous message","sessionMutation.history.rewind.helper":"Pick a user message to rewind to. Files are reset based on the scope you choose next.","sessionMutation.history.edit.title":"Edit a previous message","sessionMutation.history.edit.helper":"Pick a user message to replace. Later conversation and file changes will be removed.","sessionMutation.history.empty":"No previous user messages. Send one to enable edit, rewind, or fork.","sessionMutation.history.fork.hint":"\u2191\u2193 select \xB7 Enter fork \xB7 Esc cancel","sessionMutation.history.rewind.hint":"\u2191\u2193 select \xB7 Enter rewind \xB7 Esc cancel","sessionMutation.history.edit.hint":"\u2191\u2193 select \xB7 Enter edit \xB7 Esc cancel","sessionMutation.history.incomplete.one":"1 incomplete message hidden","sessionMutation.history.incomplete.many":"{count} incomplete messages hidden","sessionMutation.scope.title":"Choose what to rewind","sessionMutation.scope.helper":"Pick how the rewind should affect this session.","sessionMutation.scope.conversation.label":"Conversation only","sessionMutation.scope.conversation.description":"Drop messages and tool results after the target. Files stay as they are.","sessionMutation.scope.both.label":"Conversation and files","sessionMutation.scope.both.description":"Drop messages after the target and revert the file changes from that turn.","sessionMutation.scope.hint":"\u2191\u2193 select \xB7 Enter confirm \xB7 Esc cancel","sessionMutation.preview.heading":"Rewind preview","sessionMutation.preview.editHeading":"Edit preview","sessionMutation.preview.empty":"No file changes are queued for this turn.","sessionMutation.preview.noSafe":"No diff to rewind \u2014 every file is already up to date or skipped.","sessionMutation.preview.ready":"Ready to rewind","sessionMutation.preview.skipped":"Skipped","sessionMutation.preview.close":"Esc close","sessionMutation.preview.editHint":"Enter edit this message \xB7 Esc back","sessionMutation.preview.rewindHint":"Enter choose rewind scope \xB7 Esc cancel","sessionMutation.preview.confirmRewindHint":"Enter rewind \xB7 Esc back","sessionMutation.preview.scrollHint":"\u2191\u2193/PgUp/PgDn scroll","sessionMutation.preview.loading":"Rewinding Session\u2026","sessionMutation.preview.summary":"{ready} ready \xB7 {skipped} skipped \xB7 {turns}","sessionMutation.preview.summaryEmpty":"{turns} \xB7 no file changes","sessionMutation.format.unknownTime":"unknown time","sessionMutation.format.noPrompt":"(no prompt text)","sessionMutation.format.assistantReplied":"assistant replied","sessionMutation.format.files.one":"{count} file","sessionMutation.format.files.many":"{count} files","sessionMutation.format.affected.one":"{count} turn affected","sessionMutation.format.affected.many":"{count} turns affected","sessionMutation.format.turn.one":"{count} turn","sessionMutation.format.turn.many":"{count} turns","sessionMutation.format.action.modified":"modified","sessionMutation.format.action.created":"created","sessionMutation.format.action.deleted":"deleted","sessionMutation.format.action.unknown":"unknown","sessionMutation.outcome.boundaryUnavailable":"This conversation point is no longer available.","sessionMutation.outcome.noSafeFiles":"No file changes can be safely rewound at this point.","sessionMutation.outcome.conversationSuccess":"Rewound {turns} \xB7 Workspace files unchanged","sessionMutation.outcome.filesSuccess":"Rewound {turns} \xB7 {files} restored","sessionMutation.error.conflict":"This action was already submitted or became stale.","sessionMutation.error.busy":"Stop the running response and try again.","sessionMutation.error.retry":"Couldn't rewind this session. Press Enter to retry or Esc to cancel.","sessionMutation.error.retrySameOperation":"Rewind failed. Press Enter to retry with the same operation id.","sessionMutation.error.loadHistory":"Couldn't load previous messages.","sessionMutation.error.retryFork":"Retry /fork.","sessionMutation.error.retryRewind":"Retry /rewind.","sessionMutation.error.retryEdit":"Retry /edit.","sessionMutation.error.loadPreview":"Couldn't load rewind preview.","sessionMutation.error.loadForkOptions":"Couldn't load fork options.","sessionMutation.error.chooseAgain":"Choose a message again or cancel with Esc.","sessionMutation.error.sessionUnchanged":"Session is unchanged.","sessionMutation.error.sourceUnchanged":"Source session is unchanged.","sessionMutation.error.forkRequest":"Couldn't fork this session.","sessionMutation.error.forkRetry":"Press Enter to retry or Esc to cancel.","sessionMutation.error.forkRetrySameOperation":"Fork failed. Press Enter to retry with the same operation id.","sessionMutation.error.activateFork":"Couldn't switch to the forked session.","sessionMutation.error.openForkManually":"Open it manually from /sessions: {sessionId}.","sessionMutation.error.refresh":"Rewind completed, but the current Session view could not be refreshed. Reopen the Session to verify its state.","sessionMutation.error.editRefresh":"The message was edited, but the current Session view could not be refreshed. Reopen the Session to verify its state.","sessionMutation.error.pendingInteraction":"Resolve the pending Agent interaction first.","sessionMutation.error.exitPlan":"Exit Plan Mode before rewinding this Session.","sessionMutation.error.openParent":"Open the parent Session before rewinding.","sessionMutation.error.editExitPlan":"Exit Plan Mode before editing Session history.","sessionMutation.error.editOpenParent":"Open the parent Session before editing its history.","sessionMutation.error.editRequest":"Couldn't edit this message.","sessionMutation.error.editNeedsNewOperation":"The saved edit operation cannot be resumed. Submit again with a new operation id.","sessionMutation.error.editNeedsResubmit":"History was rewound, but the edited prompt was not submitted. Your edited draft is preserved; press Enter to send it as a new message.","sessionMutation.error.editSubmitAfterRewind":"History was rewound, but the edited prompt could not be submitted. Your edited draft is preserved; press Enter to retry the same edit.","sessionMutation.hint.forkRunning":"Wait for the current response or press Esc to interrupt before forking.","sessionMutation.hint.forkNoSession":"Start or resume a Session before creating a Fork.","sessionMutation.hint.rewindNoSession":"Start or resume a Session before rewinding.","sessionMutation.hint.editNoSession":"Start or resume a Session before editing a message.","sessionMutation.hint.editRunning":"Wait for the current response or press Esc to interrupt before editing the latest message.","sessionMutation.hint.editing":"Editing the selected message \xB7 Enter replace and regenerate \xB7 Esc cancel","sessionMutation.hint.editSubmitting":"Replacing the message and rewinding history\u2026","sessionMutation.hint.editResubmit":"Edited draft preserved \xB7 Enter resubmit \xB7 Esc cancel","sessionMutation.hint.loadingFork":"Loading fork history\u2026","sessionMutation.hint.loadingRewind":"Finding messages to rewind to\u2026","sessionMutation.hint.loadingEdit":"Loading the latest message\u2026","sessionMutation.hint.noForkPrompts":"No persisted user prompts are available. Send a message, then retry /fork.","sessionMutation.confirm.fork.title":"Confirm fork","sessionMutation.confirm.fork.helper":"This creates a child session. The source session and files stay unchanged.","sessionMutation.confirm.fork.suggestedTitle":"Suggested fork","sessionMutation.confirm.fork.currentSession":"Current session","sessionMutation.confirm.fork.workspaceEligible":"Workspace: current files \xB7 isolated worktree available but disabled for this fork.","sessionMutation.confirm.fork.workspaceUnavailable":"Workspace: current files \xB7 {reason}.","sessionMutation.confirm.fork.worktreeUnavailable":"isolated worktree unavailable","sessionMutation.confirm.fork.workspaceCurrent":"Workspace: current files \xB7 no isolated worktree will be created.","sessionMutation.confirm.titleLabel":"Title","sessionMutation.confirm.sourceLabel":"Source","sessionMutation.confirm.fromLabel":"From","sessionMutation.confirm.confirmHint":"Enter confirm \xB7 Esc cancel","sessionMutation.confirm.fork.busy":"Creating fork\u2026","sessionMutation.confirm.rewind.title":"Confirm rewind","sessionMutation.confirm.rewind.filesWarning":"Files may have changed since this preview; skipped files will not be overwritten.","sessionMutation.confirm.rewind.conversationWarning":"Conversation messages will be removed; files stay unchanged.","sessionMutation.confirm.scopeLabel":"Scope","sessionMutation.confirm.targetLabel":"Target","sessionMutation.confirm.impactLabel":"Impact","sessionMutation.confirm.filesUnchanged":"unchanged","sessionMutation.confirm.filesLabel":"Files","sessionMutation.confirm.fileCounts":"{ready} ready \xB7 {skipped} skipped","sessionMutation.confirm.rewind.busy":"Rewinding\u2026","sessionMutation.outcome.partial":"Conversation rewound, but some file changes could not be restored.{error}","sessionMutation.outcome.failedAfterRewind":"Conversation rewound, but file restoration did not complete.{error}","sessionMutation.outcome.unsafe":"Rewind did not complete safely ({status}). {ready} file changes remain ready and {skipped} were skipped.","sessionMutation.outcome.errorSuffix":" Error: {code}.","sessionMutation.fork.unavailableReason":"Fork unavailable: {reason}","sessionMutation.fork.unavailableDefault":"Fork unavailable: Runtime refused this fork.","sessionMutation.command.fork.description":"Fork from a persisted user prompt without changing files","sessionMutation.command.rewind.description":"Rewind conversation and file changes to a previous prompt","sessionMutation.command.edit.description":"Edit the latest prompt and regenerate its response","sessionMutation.command.fork.unavailable":"Start or resume a Session before creating a Fork.","sessionMutation.command.rewind.unavailable":"Start or resume a Session before rewinding it.","sessionMutation.command.edit.unavailable":"Start or resume a Session before editing it."};var tx={title:"\u5386\u53F2",helper:"\u641C\u7D22\u4E4B\u524D\u7684\u63D0\u793A\u8BCD\uFF0C\u68C0\u67E5\u5F71\u54CD\u5E76\u9009\u62E9\u5B89\u5168\u64CD\u4F5C\u3002",loading:"\u6B63\u5728\u52A0\u8F7D\u4F1A\u8BDD\u5386\u53F2\u2026",loadingHint:"Esc \u53D6\u6D88",loadErrorHint:"Enter \u91CD\u8BD5 \xB7 Esc \u5173\u95ED",compactHint:"\u2191\u2193 \xB7 Enter \xB7 Esc",search:"\u641C\u7D22",noResults:"\u6CA1\u6709\u5339\u914D\u7684\u5386\u53F2\u4F4D\u7F6E\u3002",forkAvailable:"\u53EF\u521B\u5EFA\u5206\u652F",forkUnavailable:"\u52A9\u624B\u56DE\u590D\u5B8C\u6210\u540E\u624D\u53EF\u521B\u5EFA\u5206\u652F\u3002",preparingFork:"\u6B63\u5728\u68C0\u67E5\u5206\u652F\u8BE6\u60C5\u2026",preparingEdit:"\u6B63\u5728\u52A0\u8F7D\u7F16\u8F91\u5F71\u54CD\u2026",preparingRewind:"\u6B63\u5728\u52A0\u8F7D\u56DE\u9000\u5F71\u54CD\u2026",preparingTarget:"\u6B63\u5728\u52A0\u8F7D\u6240\u9009\u6D88\u606F\u2026",hint:"\u2191\u2193 \u79FB\u52A8 \xB7 Enter \u9009\u62E9\u64CD\u4F5C \xB7 Esc \u5173\u95ED",filterHint:"\u2191\u2193 \u79FB\u52A8 \xB7 Enter \u9009\u62E9\u64CD\u4F5C \xB7 Esc \u6E05\u9664\u641C\u7D22",incomplete:"\u56DE\u590D\u672A\u5B8C\u6210",actions:"\u9009\u62E9\u5386\u53F2\u64CD\u4F5C",actionsHint:"\u2191\u2193 \u9009\u62E9 \xB7 Enter \u7EE7\u7EED \xB7 Esc \u8FD4\u56DE",mutationUnavailable:"\u505C\u6B62\u5F53\u524D\u56DE\u590D\u540E\u624D\u80FD\u4FEE\u6539\u4F1A\u8BDD\u5386\u53F2\u3002",fork:"\u4ECE\u8FD9\u91CC\u521B\u5EFA\u5206\u652F",forkDescription:"\u521B\u5EFA\u5B50\u4F1A\u8BDD\uFF0C\u4E0D\u4FEE\u6539\u5F53\u524D\u4F1A\u8BDD\u6216\u6587\u4EF6\u3002",edit:"\u7F16\u8F91\u6B64\u8F93\u5165",editDescription:"\u66FF\u6362\u6B64\u63D0\u793A\u8BCD\uFF0C\u5E76\u4ECE\u8FD9\u91CC\u91CD\u65B0\u751F\u6210\u3002",rewindConversation:"\u56DE\u9000\u4F1A\u8BDD",rewindConversationDescription:"\u79FB\u9664\u540E\u7EED\u6D88\u606F\uFF0C\u5DE5\u4F5C\u533A\u6587\u4EF6\u4FDD\u6301\u4E0D\u53D8\u3002",rewindFiles:"\u56DE\u9000\u4F1A\u8BDD\u548C\u6587\u4EF6",rewindFilesDescription:"\u79FB\u9664\u540E\u7EED\u6D88\u606F\uFF0C\u5E76\u8FD8\u539F\u53EF\u5B89\u5168\u6062\u590D\u7684\u6587\u4EF6\u6539\u52A8\u3002",running:"\u5F53\u524D\u56DE\u590D\u5B8C\u6210\u524D\uFF0C\u5386\u53F2\u4EC5\u53EF\u67E5\u770B\u3002",noSession:"\u8BF7\u5148\u5F00\u59CB\u6216\u6062\u590D\u4E00\u4E2A\u4F1A\u8BDD\uFF0C\u518D\u6D4F\u89C8\u5386\u53F2\u3002",editPreviewHeading:"\u7F16\u8F91\u9884\u89C8",commandDescription:"\u6D4F\u89C8\u4E4B\u524D\u7684\u63D0\u793A\u8BCD\uFF0C\u5E76\u9009\u62E9\u5206\u652F\u3001\u7F16\u8F91\u6216\u56DE\u9000",commandUnavailable:"\u8BF7\u5148\u5F00\u59CB\u6216\u6062\u590D\u4E00\u4E2A\u4F1A\u8BDD\uFF0C\u518D\u6D4F\u89C8\u5386\u53F2\u3002"},nx={"sessionMutation.history.fork.title":"\u4ECE\u5386\u53F2\u6D88\u606F\u521B\u5EFA\u5206\u652F","sessionMutation.history.fork.helper":"\u9009\u62E9\u4E00\u6761\u7528\u6237\u6D88\u606F\u4F5C\u4E3A\u65B0\u4F1A\u8BDD\u7684\u5206\u652F\u70B9\u3002","sessionMutation.history.rewind.title":"\u56DE\u9000\u5230\u5386\u53F2\u6D88\u606F","sessionMutation.history.rewind.helper":"\u9009\u62E9\u8981\u56DE\u9000\u5230\u7684\u7528\u6237\u6D88\u606F\uFF0C\u4E0B\u4E00\u6B65\u53EF\u9009\u62E9\u6587\u4EF6\u5904\u7406\u8303\u56F4\u3002","sessionMutation.history.edit.title":"\u7F16\u8F91\u5386\u53F2\u6D88\u606F","sessionMutation.history.edit.helper":"\u9009\u62E9\u8981\u66FF\u6362\u7684\u7528\u6237\u6D88\u606F\uFF1B\u540E\u7EED\u5BF9\u8BDD\u548C\u6587\u4EF6\u6539\u52A8\u5C06\u88AB\u79FB\u9664\u3002","sessionMutation.history.empty":"\u6682\u65E0\u5386\u53F2\u7528\u6237\u6D88\u606F\u3002\u53D1\u9001\u6D88\u606F\u540E\u5373\u53EF\u4F7F\u7528\u7F16\u8F91\u3001\u56DE\u9000\u6216\u5206\u652F\u3002","sessionMutation.history.fork.hint":"\u2191\u2193 \u9009\u62E9 \xB7 Enter \u521B\u5EFA\u5206\u652F \xB7 Esc \u53D6\u6D88","sessionMutation.history.rewind.hint":"\u2191\u2193 \u9009\u62E9 \xB7 Enter \u56DE\u9000 \xB7 Esc \u53D6\u6D88","sessionMutation.history.edit.hint":"\u2191\u2193 \u9009\u62E9 \xB7 Enter \u7F16\u8F91 \xB7 Esc \u53D6\u6D88","sessionMutation.history.incomplete.one":"\u5DF2\u9690\u85CF 1 \u6761\u672A\u5B8C\u6210\u6D88\u606F","sessionMutation.history.incomplete.many":"\u5DF2\u9690\u85CF {count} \u6761\u672A\u5B8C\u6210\u6D88\u606F","sessionMutation.scope.title":"\u9009\u62E9\u56DE\u9000\u8303\u56F4","sessionMutation.scope.helper":"\u9009\u62E9\u6B64\u6B21\u56DE\u9000\u8981\u5F71\u54CD\u7684\u5185\u5BB9\u3002","sessionMutation.scope.conversation.label":"\u4EC5\u4F1A\u8BDD","sessionMutation.scope.conversation.description":"\u79FB\u9664\u76EE\u6807\u4E4B\u540E\u7684\u6D88\u606F\u548C\u5DE5\u5177\u7ED3\u679C\uFF0C\u6587\u4EF6\u4FDD\u6301\u4E0D\u53D8\u3002","sessionMutation.scope.both.label":"\u4F1A\u8BDD\u548C\u6587\u4EF6","sessionMutation.scope.both.description":"\u79FB\u9664\u76EE\u6807\u4E4B\u540E\u7684\u6D88\u606F\uFF0C\u5E76\u8FD8\u539F\u8BE5 turn \u7684\u6587\u4EF6\u6539\u52A8\u3002","sessionMutation.scope.hint":"\u2191\u2193 \u9009\u62E9 \xB7 Enter \u786E\u8BA4 \xB7 Esc \u53D6\u6D88","sessionMutation.preview.heading":"\u56DE\u9000\u9884\u89C8","sessionMutation.preview.editHeading":"\u7F16\u8F91\u9884\u89C8","sessionMutation.preview.empty":"\u8BE5 turn \u6CA1\u6709\u5F85\u56DE\u9000\u7684\u6587\u4EF6\u6539\u52A8\u3002","sessionMutation.preview.noSafe":"\u6CA1\u6709\u53EF\u5B89\u5168\u56DE\u9000\u7684 diff\uFF0C\u6240\u6709\u6587\u4EF6\u5747\u5DF2\u662F\u6700\u65B0\u72B6\u6001\u6216\u88AB\u8DF3\u8FC7\u3002","sessionMutation.preview.ready":"\u53EF\u56DE\u9000","sessionMutation.preview.skipped":"\u5DF2\u8DF3\u8FC7","sessionMutation.preview.close":"Esc \u5173\u95ED","sessionMutation.preview.editHint":"Enter \u7F16\u8F91\u6B64\u6D88\u606F \xB7 Esc \u8FD4\u56DE","sessionMutation.preview.rewindHint":"Enter \u9009\u62E9\u56DE\u9000\u8303\u56F4 \xB7 Esc \u53D6\u6D88","sessionMutation.preview.confirmRewindHint":"Enter \u56DE\u9000 \xB7 Esc \u8FD4\u56DE","sessionMutation.preview.scrollHint":"\u2191\u2193/PgUp/PgDn \u6EDA\u52A8","sessionMutation.preview.loading":"\u6B63\u5728\u56DE\u9000\u4F1A\u8BDD\u2026","sessionMutation.preview.summary":"{ready} \u53EF\u56DE\u9000 \xB7 {skipped} \u5DF2\u8DF3\u8FC7 \xB7 {turns}","sessionMutation.preview.summaryEmpty":"{turns} \xB7 \u65E0\u6587\u4EF6\u6539\u52A8","sessionMutation.format.unknownTime":"\u672A\u77E5\u65F6\u95F4","sessionMutation.format.noPrompt":"\uFF08\u65E0\u63D0\u793A\u8BCD\u6587\u672C\uFF09","sessionMutation.format.assistantReplied":"\u52A9\u624B\u5DF2\u56DE\u590D","sessionMutation.format.files.one":"{count} \u4E2A\u6587\u4EF6","sessionMutation.format.files.many":"{count} \u4E2A\u6587\u4EF6","sessionMutation.format.affected.one":"\u5F71\u54CD {count} \u4E2A turn","sessionMutation.format.affected.many":"\u5F71\u54CD {count} \u4E2A turn","sessionMutation.format.turn.one":"{count} \u4E2A turn","sessionMutation.format.turn.many":"{count} \u4E2A turn","sessionMutation.format.action.modified":"\u5DF2\u4FEE\u6539","sessionMutation.format.action.created":"\u5DF2\u521B\u5EFA","sessionMutation.format.action.deleted":"\u5DF2\u5220\u9664","sessionMutation.format.action.unknown":"\u672A\u77E5","sessionMutation.outcome.boundaryUnavailable":"\u8BE5\u4F1A\u8BDD\u4F4D\u7F6E\u5DF2\u4E0D\u53EF\u7528\u3002","sessionMutation.outcome.noSafeFiles":"\u6B64\u4F4D\u7F6E\u6CA1\u6709\u53EF\u5B89\u5168\u56DE\u9000\u7684\u6587\u4EF6\u6539\u52A8\u3002","sessionMutation.outcome.conversationSuccess":"\u5DF2\u56DE\u9000 {turns} \xB7 \u5DE5\u4F5C\u533A\u6587\u4EF6\u672A\u53D8","sessionMutation.outcome.filesSuccess":"\u5DF2\u56DE\u9000 {turns} \xB7 \u5DF2\u8FD8\u539F {files}","sessionMutation.error.conflict":"\u8BE5\u64CD\u4F5C\u5DF2\u63D0\u4EA4\u6216\u5DF2\u7ECF\u5931\u6548\u3002","sessionMutation.error.busy":"\u8BF7\u5148\u505C\u6B62\u6B63\u5728\u8FD0\u884C\u7684\u56DE\u590D\uFF0C\u7136\u540E\u91CD\u8BD5\u3002","sessionMutation.error.retry":"\u65E0\u6CD5\u56DE\u9000\u6B64\u4F1A\u8BDD\u3002\u6309 Enter \u91CD\u8BD5\uFF0C\u6216\u6309 Esc \u53D6\u6D88\u3002","sessionMutation.error.retrySameOperation":"\u56DE\u9000\u5931\u8D25\u3002\u6309 Enter \u4F7F\u7528\u540C\u4E00 operation id \u91CD\u8BD5\u3002","sessionMutation.error.loadHistory":"\u65E0\u6CD5\u52A0\u8F7D\u5386\u53F2\u6D88\u606F\u3002","sessionMutation.error.retryFork":"\u8BF7\u91CD\u8BD5 /fork\u3002","sessionMutation.error.retryRewind":"\u8BF7\u91CD\u8BD5 /rewind\u3002","sessionMutation.error.retryEdit":"\u8BF7\u91CD\u8BD5 /edit\u3002","sessionMutation.error.loadPreview":"\u65E0\u6CD5\u52A0\u8F7D\u56DE\u9000\u9884\u89C8\u3002","sessionMutation.error.loadForkOptions":"\u65E0\u6CD5\u52A0\u8F7D\u5206\u652F\u9009\u9879\u3002","sessionMutation.error.chooseAgain":"\u8BF7\u91CD\u65B0\u9009\u62E9\u4E00\u6761\u6D88\u606F\uFF0C\u6216\u6309 Esc \u53D6\u6D88\u3002","sessionMutation.error.sessionUnchanged":"\u4F1A\u8BDD\u672A\u53D1\u751F\u53D8\u5316\u3002","sessionMutation.error.sourceUnchanged":"\u6E90\u4F1A\u8BDD\u672A\u53D1\u751F\u53D8\u5316\u3002","sessionMutation.error.forkRequest":"\u65E0\u6CD5\u521B\u5EFA\u4F1A\u8BDD\u5206\u652F\u3002","sessionMutation.error.forkRetry":"\u6309 Enter \u91CD\u8BD5\uFF0C\u6216\u6309 Esc \u53D6\u6D88\u3002","sessionMutation.error.forkRetrySameOperation":"\u521B\u5EFA\u5206\u652F\u5931\u8D25\u3002\u6309 Enter \u4F7F\u7528\u540C\u4E00 operation id \u91CD\u8BD5\u3002","sessionMutation.error.activateFork":"\u65E0\u6CD5\u5207\u6362\u5230\u65B0\u5EFA\u7684\u5206\u652F\u4F1A\u8BDD\u3002","sessionMutation.error.openForkManually":"\u8BF7\u4ECE /sessions \u624B\u52A8\u6253\u5F00\uFF1A{sessionId}\u3002","sessionMutation.error.refresh":"\u56DE\u9000\u5DF2\u5B8C\u6210\uFF0C\u4F46\u5F53\u524D\u4F1A\u8BDD\u89C6\u56FE\u5237\u65B0\u5931\u8D25\u3002\u8BF7\u91CD\u65B0\u6253\u5F00\u4F1A\u8BDD\u5E76\u786E\u8BA4\u72B6\u6001\u3002","sessionMutation.error.editRefresh":"\u6D88\u606F\u5DF2\u7F16\u8F91\uFF0C\u4F46\u5F53\u524D\u4F1A\u8BDD\u89C6\u56FE\u5237\u65B0\u5931\u8D25\u3002\u8BF7\u91CD\u65B0\u6253\u5F00\u4F1A\u8BDD\u5E76\u786E\u8BA4\u72B6\u6001\u3002","sessionMutation.error.pendingInteraction":"\u8BF7\u5148\u5904\u7406\u5F85\u5B8C\u6210\u7684 Agent \u4EA4\u4E92\u3002","sessionMutation.error.exitPlan":"\u8BF7\u9000\u51FA\u8BA1\u5212\u6A21\u5F0F\u540E\u518D\u56DE\u9000\u6B64\u4F1A\u8BDD\u3002","sessionMutation.error.openParent":"\u8BF7\u6253\u5F00\u7236\u4F1A\u8BDD\u540E\u518D\u6267\u884C\u56DE\u9000\u3002","sessionMutation.error.editExitPlan":"\u8BF7\u9000\u51FA\u8BA1\u5212\u6A21\u5F0F\u540E\u518D\u7F16\u8F91\u4F1A\u8BDD\u5386\u53F2\u3002","sessionMutation.error.editOpenParent":"\u8BF7\u6253\u5F00\u7236\u4F1A\u8BDD\u540E\u518D\u7F16\u8F91\u5176\u5386\u53F2\u6D88\u606F\u3002","sessionMutation.error.editRequest":"\u65E0\u6CD5\u7F16\u8F91\u8FD9\u6761\u6D88\u606F\u3002","sessionMutation.error.editNeedsNewOperation":"\u5DF2\u4FDD\u5B58\u7684\u7F16\u8F91\u64CD\u4F5C\u65E0\u6CD5\u6062\u590D\uFF0C\u8BF7\u4F7F\u7528\u65B0\u7684 operation id \u518D\u6B21\u63D0\u4EA4\u3002","sessionMutation.error.editNeedsResubmit":"\u5386\u53F2\u5DF2\u56DE\u9000\uFF0C\u4F46\u4FEE\u6539\u540E\u7684\u63D0\u793A\u8BCD\u672A\u63D0\u4EA4\u3002\u7F16\u8F91\u8349\u7A3F\u5DF2\u4FDD\u7559\uFF0C\u6309 Enter \u5C06\u5176\u4F5C\u4E3A\u65B0\u6D88\u606F\u53D1\u9001\u3002","sessionMutation.error.editSubmitAfterRewind":"\u5386\u53F2\u5DF2\u56DE\u9000\uFF0C\u4F46\u4FEE\u6539\u540E\u7684\u63D0\u793A\u8BCD\u63D0\u4EA4\u5931\u8D25\u3002\u7F16\u8F91\u8349\u7A3F\u5DF2\u4FDD\u7559\uFF1B\u6309 Enter \u91CD\u8BD5\u540C\u4E00\u6B21\u7F16\u8F91\u3002","sessionMutation.hint.forkRunning":"\u8BF7\u7B49\u5F85\u5F53\u524D\u56DE\u590D\u7ED3\u675F\uFF0C\u6216\u6309 Esc \u4E2D\u65AD\u540E\u518D\u521B\u5EFA\u5206\u652F\u3002","sessionMutation.hint.forkNoSession":"\u8BF7\u5148\u5F00\u59CB\u6216\u6062\u590D\u4E00\u4E2A\u4F1A\u8BDD\uFF0C\u518D\u521B\u5EFA\u5206\u652F\u3002","sessionMutation.hint.rewindNoSession":"\u8BF7\u5148\u5F00\u59CB\u6216\u6062\u590D\u4E00\u4E2A\u4F1A\u8BDD\uFF0C\u518D\u6267\u884C\u56DE\u9000\u3002","sessionMutation.hint.editNoSession":"\u8BF7\u5148\u5F00\u59CB\u6216\u6062\u590D\u4E00\u4E2A\u4F1A\u8BDD\uFF0C\u518D\u7F16\u8F91\u6D88\u606F\u3002","sessionMutation.hint.editRunning":"\u8BF7\u7B49\u5F85\u5F53\u524D\u56DE\u590D\u7ED3\u675F\uFF0C\u6216\u6309 Esc \u4E2D\u65AD\u540E\u518D\u7F16\u8F91\u6700\u540E\u4E00\u6761\u6D88\u606F\u3002","sessionMutation.hint.editing":"\u6B63\u5728\u7F16\u8F91\u6240\u9009\u6D88\u606F \xB7 Enter \u66FF\u6362\u5E76\u91CD\u65B0\u751F\u6210 \xB7 Esc \u53D6\u6D88","sessionMutation.hint.editSubmitting":"\u6B63\u5728\u66FF\u6362\u6D88\u606F\u5E76\u56DE\u9000\u5386\u53F2\u2026","sessionMutation.hint.editResubmit":"\u7F16\u8F91\u8349\u7A3F\u5DF2\u4FDD\u7559 \xB7 Enter \u91CD\u65B0\u63D0\u4EA4 \xB7 Esc \u53D6\u6D88","sessionMutation.hint.loadingFork":"\u6B63\u5728\u52A0\u8F7D\u5206\u652F\u5386\u53F2\u2026","sessionMutation.hint.loadingRewind":"\u6B63\u5728\u67E5\u627E\u53EF\u56DE\u9000\u7684\u6D88\u606F\u2026","sessionMutation.hint.loadingEdit":"\u6B63\u5728\u52A0\u8F7D\u6700\u65B0\u6D88\u606F\u2026","sessionMutation.hint.noForkPrompts":"\u6682\u65E0\u53EF\u7528\u7684\u5DF2\u6301\u4E45\u5316\u7528\u6237\u63D0\u793A\u8BCD\u3002\u53D1\u9001\u6D88\u606F\u540E\u8BF7\u91CD\u8BD5 /fork\u3002","sessionMutation.confirm.fork.title":"\u786E\u8BA4\u521B\u5EFA\u5206\u652F","sessionMutation.confirm.fork.helper":"\u8FD9\u4F1A\u521B\u5EFA\u4E00\u4E2A\u5B50\u4F1A\u8BDD\uFF0C\u6E90\u4F1A\u8BDD\u548C\u6587\u4EF6\u4FDD\u6301\u4E0D\u53D8\u3002","sessionMutation.confirm.fork.suggestedTitle":"\u5EFA\u8BAE\u7684\u5206\u652F\u6807\u9898","sessionMutation.confirm.fork.currentSession":"\u5F53\u524D\u4F1A\u8BDD","sessionMutation.confirm.fork.workspaceEligible":"\u5DE5\u4F5C\u533A\uFF1A\u5F53\u524D\u6587\u4EF6 \xB7 \u53EF\u4F7F\u7528\u9694\u79BB worktree\uFF0C\u4F46\u672C\u6B21\u5206\u652F\u4E0D\u4F1A\u542F\u7528\u3002","sessionMutation.confirm.fork.workspaceUnavailable":"\u5DE5\u4F5C\u533A\uFF1A\u5F53\u524D\u6587\u4EF6 \xB7 {reason}\u3002","sessionMutation.confirm.fork.worktreeUnavailable":"\u9694\u79BB worktree \u4E0D\u53EF\u7528","sessionMutation.confirm.fork.workspaceCurrent":"\u5DE5\u4F5C\u533A\uFF1A\u5F53\u524D\u6587\u4EF6 \xB7 \u4E0D\u4F1A\u521B\u5EFA\u9694\u79BB worktree\u3002","sessionMutation.confirm.titleLabel":"\u6807\u9898","sessionMutation.confirm.sourceLabel":"\u6765\u6E90","sessionMutation.confirm.fromLabel":"\u5206\u652F\u70B9","sessionMutation.confirm.confirmHint":"Enter \u786E\u8BA4 \xB7 Esc \u53D6\u6D88","sessionMutation.confirm.fork.busy":"\u6B63\u5728\u521B\u5EFA\u5206\u652F\u2026","sessionMutation.confirm.rewind.title":"\u786E\u8BA4\u56DE\u9000","sessionMutation.confirm.rewind.filesWarning":"\u9884\u89C8\u540E\u6587\u4EF6\u53EF\u80FD\u5DF2\u53D8\u5316\uFF1B\u5DF2\u8DF3\u8FC7\u7684\u6587\u4EF6\u4E0D\u4F1A\u88AB\u8986\u76D6\u3002","sessionMutation.confirm.rewind.conversationWarning":"\u5C06\u79FB\u9664\u4F1A\u8BDD\u6D88\u606F\uFF0C\u6587\u4EF6\u4FDD\u6301\u4E0D\u53D8\u3002","sessionMutation.confirm.scopeLabel":"\u8303\u56F4","sessionMutation.confirm.targetLabel":"\u76EE\u6807","sessionMutation.confirm.impactLabel":"\u5F71\u54CD","sessionMutation.confirm.filesUnchanged":"\u4E0D\u53D8","sessionMutation.confirm.filesLabel":"\u6587\u4EF6","sessionMutation.confirm.fileCounts":"{ready} \u53EF\u56DE\u9000 \xB7 {skipped} \u5DF2\u8DF3\u8FC7","sessionMutation.confirm.rewind.busy":"\u6B63\u5728\u56DE\u9000\u2026","sessionMutation.outcome.partial":"\u4F1A\u8BDD\u5DF2\u56DE\u9000\uFF0C\u4F46\u90E8\u5206\u6587\u4EF6\u6539\u52A8\u672A\u80FD\u8FD8\u539F\u3002{error}","sessionMutation.outcome.failedAfterRewind":"\u4F1A\u8BDD\u5DF2\u56DE\u9000\uFF0C\u4F46\u6587\u4EF6\u8FD8\u539F\u672A\u5B8C\u6210\u3002{error}","sessionMutation.outcome.unsafe":"\u56DE\u9000\u672A\u5B89\u5168\u5B8C\u6210\uFF08{status}\uFF09\u3002\u4ECD\u6709 {ready} \u4E2A\u6587\u4EF6\u6539\u52A8\u53EF\u56DE\u9000\uFF0C{skipped} \u4E2A\u5DF2\u8DF3\u8FC7\u3002","sessionMutation.outcome.errorSuffix":" \u9519\u8BEF\uFF1A{code}\u3002","sessionMutation.fork.unavailableReason":"\u65E0\u6CD5\u521B\u5EFA\u5206\u652F\uFF1A{reason}","sessionMutation.fork.unavailableDefault":"\u65E0\u6CD5\u521B\u5EFA\u5206\u652F\uFF1ARuntime \u62D2\u7EDD\u4E86\u6B64\u6B21\u64CD\u4F5C\u3002","sessionMutation.command.fork.description":"\u4ECE\u5DF2\u6301\u4E45\u5316\u7684\u7528\u6237\u63D0\u793A\u8BCD\u521B\u5EFA\u5206\u652F\uFF0C\u4E0D\u4FEE\u6539\u6587\u4EF6","sessionMutation.command.rewind.description":"\u5C06\u4F1A\u8BDD\u548C\u6587\u4EF6\u6539\u52A8\u56DE\u9000\u5230\u5386\u53F2\u63D0\u793A\u8BCD","sessionMutation.command.edit.description":"\u7F16\u8F91\u6700\u540E\u4E00\u6761\u63D0\u793A\u8BCD\uFF0C\u5E76\u91CD\u65B0\u751F\u6210\u56DE\u590D","sessionMutation.command.fork.unavailable":"\u8BF7\u5148\u5F00\u59CB\u6216\u6062\u590D\u4E00\u4E2A\u4F1A\u8BDD\uFF0C\u518D\u521B\u5EFA\u5206\u652F\u3002","sessionMutation.command.rewind.unavailable":"\u8BF7\u5148\u5F00\u59CB\u6216\u6062\u590D\u4E00\u4E2A\u4F1A\u8BDD\uFF0C\u518D\u6267\u884C\u56DE\u9000\u3002","sessionMutation.command.edit.unavailable":"\u8BF7\u5148\u5F00\u59CB\u6216\u6062\u590D\u4E00\u4E2A\u4F1A\u8BDD\uFF0C\u518D\u7F16\u8F91\u6D88\u606F\u3002"};function $s(){try{return Intl.DateTimeFormat().resolvedOptions().locale}catch{return"en"}}function ix(n){return ki(n)==="zh"}function ge(n,e=$s()){return ix(e)?tx[n]:Zw[n]}function L(n,e=$s()){return ix(e)?nx[n]:ex[n]}function Ne(n,e,t=$s()){return Object.entries(e).reduce((i,[s,r])=>i.replaceAll(`{${s}}`,String(r)),L(n,t))}var Fc=48;function La(n,e,t){let i=t??$s();return!Number.isFinite(n)||n<=0?L("sessionMutation.format.unknownTime",i):Su(n,{preset:"community-relative",nowMs:e,locale:i})||L("sessionMutation.format.unknownTime",i)}function Xi(n,e){let t=Math.max(8,Math.floor(e)),i=(n??"").replace(/\s+/gu," ").trim();if(!i)return L("sessionMutation.format.noPrompt");let s=[...i];return s.length<=t?i:`${s.slice(0,Math.max(0,t-1)).join("").trimEnd()}\u2026`}function Bs(n,e=$s()){let t=Number.isFinite(n)&&n>0?Math.floor(n):0;return Ne(t===1?"sessionMutation.format.files.one":"sessionMutation.format.files.many",{count:t},e)}function Jf(n,e){let t=e.promptMaxWidth??Fc,i=Xi(n.contentHead,t),s=[],r=e.locale??$s();if(s.push(Bs(n.fileChangeCount,r)),s.push(La(n.timestamp,e.nowMs,r)),e.affectedTurnCount!==void 0){let o=Math.max(1,Math.floor(e.affectedTurnCount));s.push(Ne(o===1?"sessionMutation.format.affected.one":"sessionMutation.format.affected.many",{count:o},r))}return n.assistantMessageId&&s.push(L("sessionMutation.format.assistantReplied",r)),{title:i,subtitle:s.join(" \xB7 ")}}function sx(n){let e=(n.action??"").trim(),t=B6(e)??e.toLocaleLowerCase();return{status:n.skipped?"skipped":"ready",action:e,actionLabel:t}}function B6(n){if(n==="modified"||n==="created"||n==="deleted")return L(`sessionMutation.format.action.${n}`);if(!n)return L("sessionMutation.format.action.unknown")}var q6=8,rx="session-mutation:history",Oa=class{constructor(e){this.options=e;if(this.summaries=[...e.summaries].filter(t=>e.mode!=="fork"||!!t.assistantMessageId).reverse(),this.hiddenIncompleteCount=e.summaries.length-this.summaries.length,this.nowMs=()=>e.nowMs??Date.now(),this.summaries.length===0){this.list=void 0;return}this.list=new st(this.summaries.map((t,i)=>({value:`${String(i)}:${t.userMessageId}`,label:Jf(t,{nowMs:this.nowMs(),promptMaxWidth:Fc,...e.mode!=="fork"?{affectedTurnCount:i+1}:{}}).title,description:Jf(t,{nowMs:this.nowMs(),promptMaxWidth:Fc,...e.mode!=="fork"?{affectedTurnCount:i+1}:{}}).subtitle})),Math.min(this.summaries.length,q6),lt,{minPrimaryColumnWidth:20,maxPrimaryColumnWidth:40,truncatePrimary:({text:t,maxWidth:i})=>E(t,i,"\u2026")}),this.list.setSelectedIndex(0),this.list.onSelect=t=>this.handleSelect(t.value),this.list.onCancel=()=>this.handleCancel()}id=rx;layoutRoot=this;handlesViewportKeys=!0;summaries;hiddenIncompleteCount;list;nowMs;_focused=!1;cancelInvoked=!1;selectInvoked=!1;busy=!1;error;get focused(){return this._focused}set focused(e){this._focused=e}handleInput(e){if(this.busy){(S(e,"escape")||S(e,"ctrl+c"))&&this.handleCancel();return}if(S(e,"escape")||S(e,"ctrl+c")){this.handleCancel();return}if(S(e,"enter")||S(e,"space")){let t=this.list?.getSelectedItem();t&&this.handleSelect(t.value);return}this.list?.handleInput(e)}invalidate(){this.list?.invalidate()}render(e){return this.renderViewport(e,24)}renderViewport(e,t){let i=ae(e,t,this.renderFooter(Number.MAX_SAFE_INTEGER)),s=i.bodyHeight>=5?[p.hex(d.muted)(L(`sessionMutation.history.${this.options.mode}.helper`))]:[],r=this.error?[p.hex(d.warning)(C(this.error))]:[],o=this.list?this.list.renderViewport(i.contentWidth,Math.max(1,i.bodyHeight-s.length-r.length)):this.renderEmpty(i.contentWidth),a=[...s,...o,...r];if(Number.isFinite(i.bodyHeight))for(;a.length<i.bodyHeight;)a.push("");return i.render({title:L(`sessionMutation.history.${this.options.mode}.title`),body:a})}resetSelection(e){this.selectInvoked=!1,this.busy=!1,this.error=e,this.list&&this.list.setSelectedIndex(0),this.invalidate(),this.options.requestRender?.()}renderEmpty(e){let t=L("sessionMutation.history.empty");return[p.hex(d.muted)($c(C(t),e))]}renderFooter(e){if(this.busy){let s=this.options.mode==="fork"?"Checking fork details\u2026":this.options.mode==="edit"?"Loading the selected message\u2026":"Loading rewind impact\u2026";return[$c(`${p.hex(d.signal)(`\u280B ${s}`)}${p.hex(d.dim)(" \xB7 ")}${z("Esc cancel")}`,e)]}let t=L(`sessionMutation.history.${this.options.mode}.hint`),i=[z($c(C(t),e))];return this.hiddenIncompleteCount>0&&i.unshift(p.hex(d.muted)($c(C(this.hiddenIncompleteCount===1?L("sessionMutation.history.incomplete.one"):Ne("sessionMutation.history.incomplete.many",{count:this.hiddenIncompleteCount})),e))),i}handleSelect(e){if(this.selectInvoked||this.cancelInvoked)return;let t=this.resolveSummary(e);t&&(this.selectInvoked=!0,this.busy=!0,this.error=void 0,this.options.requestRender?.(),this.options.onSelect(t))}handleCancel(){this.cancelInvoked||(this.cancelInvoked=!0,this.options.onCancel())}resolveSummary(e){let t=e.indexOf(":");if(t<0)return;let i=Number.parseInt(e.slice(0,t),10),s=e.slice(t+1);if(!Number.isFinite(i)||i<0||i>=this.summaries.length)return;let r=this.summaries[i];if(!(!r||r.userMessageId!==s))return r}};function $c(n,e){return w(n)<=e?n:E(n,e,p.hex(d.dim)("\u2026"))}function H6(n){let e=[],t=[];for(let i of n)for(let s of i.files){let r=sx(s);r.status==="skipped"?t.push({file:s,actionLabel:r.actionLabel}):e.push({file:s,actionLabel:r.actionLabel})}return{ready:{status:"ready",files:e},skipped:{status:"skipped",files:t},totalReady:e.length,totalSkipped:t.length}}var Na=class{constructor(e){this.options=e}id="session-mutation:rewind-preview";layoutRoot=this;handlesViewportKeys=!0;_focused=!1;closed=!1;busy=!1;error;scrollOffset=0;pageSize=1;maxScrollOffset=0;get focused(){return this._focused}set focused(e){this._focused=e}handleInput(e){if(!this.busy){if(S(e,"escape")||S(e,"ctrl+c")){this.close();return}if(S(e,"enter")){this.options.onContinue?this.options.onContinue():this.close();return}if(S(e,"up"))return this.scroll(-1);if(S(e,"down"))return this.scroll(1);if(S(e,V.pageUp))return this.scroll(-this.pageSize);if(S(e,V.pageDown))return this.scroll(this.pageSize)}}invalidate(){}render(e){let t=Math.max(0,Math.floor(e));return this.renderViewport(t,Number.MAX_SAFE_INTEGER)}renderViewport(e,t){let i=ct(e,e>=12&&t>=6),s=Math.max(1,Math.floor(t));if(i===0)return[];let{ready:r,skipped:o,totalReady:a,totalSkipped:u}=H6(this.options.preview.turns),l=C(this.options.heading??L("sessionMutation.preview.heading")),c=[p.hex(d.muted)(vi(this.summaryLine(a,u,this.options.preview.turns.length),i))];this.options.target&&c.push(p.bold.hex(d.text)(vi(C(this.options.target),i))),this.options.impact&&c.push(p.hex(d.muted)(vi(C(this.options.impact),i))),c.push("");let h=[];a===0&&u===0?h.push(p.hex(d.muted)(vi(L("sessionMutation.preview.empty"),i))):a===0?h.push(p.hex(d.warning)(vi(L("sessionMutation.preview.noSafe"),i))):(h.push(p.bold.hex(d.text)(vi(L("sessionMutation.preview.ready"),i))),h.push(...this.renderGroup(r,i,d.success))),u>0&&(h.push(""),h.push(p.bold.hex(d.text)(vi(L("sessionMutation.preview.skipped"),i))),h.push(...this.renderGroup(o,i,d.muted)));let m=this.options.continueHint??(this.options.onContinue?L("sessionMutation.preview.rewindHint"):L("sessionMutation.preview.close")),f=Math.max(1,ae(e,s,m).bodyHeight-c.length-(this.error?1:0)),y=h.length>f,T=[...this.error?[p.hex(d.warning)(vi(C(this.error),i))]:[],...y?[z(L("sessionMutation.preview.scrollHint"))]:[],"",this.busy?p.hex(d.signal)(L("sessionMutation.preview.loading")):z(m)],b=ae(e,t,T.filter(Boolean)),v=c.slice(0,Math.max(0,b.bodyHeight-1));return this.pageSize=Math.max(0,b.bodyHeight-v.length),this.maxScrollOffset=Math.max(0,h.length-this.pageSize),this.scrollOffset=Math.max(0,Math.min(this.scrollOffset,this.maxScrollOffset)),b.render({title:l,body:[...v,...h.slice(this.scrollOffset,this.scrollOffset+this.pageSize)]})}isClosed(){return this.closed}setBusy(e){this.busy=e,e&&(this.error=void 0),this.options.requestRender?.()}setError(e){this.error=e,this.options.requestRender?.()}scroll(e){let t=Math.max(0,Math.min(this.maxScrollOffset,this.scrollOffset+e));t!==this.scrollOffset&&(this.scrollOffset=t,this.options.requestRender?.())}renderGroup(e,t,i){return e.files.length===0?[]:e.files.map(({file:s,actionLabel:r})=>{let o=C(s.filePath),a=`[${r}] ${o}`;return p.hex(i)(vi(a,t))})}summaryLine(e,t,i){let s=Ne(i===1?"sessionMutation.format.turn.one":"sessionMutation.format.turn.many",{count:i});return e===0&&t===0?Ne("sessionMutation.preview.summaryEmpty",{turns:s}):Ne("sessionMutation.preview.summary",{ready:e,skipped:t,turns:s})}close(){this.closed||(this.closed=!0,this.options.onCancel())}};function vi(n,e){return w(n)<=e?n:E(n,e,p.hex(d.dim)("\u2026"))}function U6(){return[{scope:"conversation",label:L("sessionMutation.scope.conversation.label"),description:L("sessionMutation.scope.conversation.description")},{scope:"conversation_and_files",label:L("sessionMutation.scope.both.label"),description:L("sessionMutation.scope.both.description")}]}var Bc=class{constructor(e){this.options=e;let t=U6();this.list=new st(t.map(s=>({value:s.scope,label:s.label,description:s.description})),t.length,lt,{minPrimaryColumnWidth:22,maxPrimaryColumnWidth:36});let i=t.findIndex(s=>s.scope===(e.initialScope??"conversation"));this.list.setSelectedIndex(i>=0?i:0),this.list.onSelect=s=>this.handleSelect(s.value),this.list.onCancel=()=>this.handleCancel()}id="session-mutation:scope";layoutRoot=this;handlesViewportKeys=!0;list;_focused=!1;cancelInvoked=!1;selectInvoked=!1;busy=!1;error;get focused(){return this._focused}set focused(e){this._focused=e}handleInput(e){if(!this.busy){if(S(e,"escape")||S(e,"ctrl+c")){this.handleCancel();return}if(S(e,"enter")||S(e,"space")){let t=this.list.getSelectedItem();t&&this.handleSelect(t.value);return}this.list.handleInput(e)}}invalidate(){this.list.invalidate()}render(e){let t=Math.max(0,Math.floor(e));return this.renderViewport(t,Number.MAX_SAFE_INTEGER)}renderViewport(e,t){let i=ae(e,t,this.busy?"Preparing rewind confirmation\u2026":L("sessionMutation.scope.hint")),s=i.bodyHeight>=5?[p.hex(d.muted)(L("sessionMutation.scope.helper"))]:[],r=this.error?[p.hex(d.warning)(C(this.error))]:[];return i.render({title:L("sessionMutation.scope.title"),body:[...s,...this.list.renderViewport(i.contentWidth,Math.max(1,i.bodyHeight-s.length-r.length)),...r]})}isClosed(){return this.cancelInvoked}resetSelection(){this.selectInvoked=!1,this.invalidate()}setBusy(e){this.busy=e,this.invalidate(),this.options.requestRender?.()}setError(e){this.error=e,this.invalidate(),this.options.requestRender?.()}handleSelect(e){this.selectInvoked||this.cancelInvoked||K6(e)&&(this.selectInvoked=!0,this.options.onSelect(e))}handleCancel(){this.cancelInvoked||(this.cancelInvoked=!0,this.options.onCancel())}};function K6(n){return n==="conversation"||n==="conversation_and_files"}var ox=n=>n.replace(/\r\n?|\n/gu," ").replace(/\t/gu," "),et=class extends qe{constructor(e={}){super({prompt:"",transformPaste:ox,...e})}setValue(e){super.setValue(ox(e))}};var ax=8,qc=class{constructor(e){this.options=e;this.summaries=[...e.summaries].sort((t,i)=>i.timestamp-t.timestamp),this.nowMs=()=>e.nowMs??Date.now(),this.loading=e.loading??!1,this.searchInput.onSubmit=()=>this.openActions(),this.clampSelection()}id="session-history:explorer";layoutRoot=this;handlesViewportKeys=!0;searchInput=new et;summaries;nowMs;selectedIndex=0;visibleEntryCount=ax;selectedMessageId;actionIndex=0;mode="list";busy=!1;busyLabel;loading;loadError;error;_focused=!1;closed=!1;get focused(){return this._focused}set focused(e){this._focused=e,this.searchInput.focused=e&&this.mode==="list"&&!this.busy}handleInput(e){if(this.closed)return;if(this.loading){(S(e,"escape")||S(e,"ctrl+c"))&&this.close();return}if(this.loadError){if(S(e,"escape")||S(e,"ctrl+c")){this.close();return}S(e,"enter")&&(this.loading=!0,this.loadError=void 0,this.options.requestRender(),this.options.onRetryLoad?.());return}if(this.busy){(S(e,"escape")||S(e,"ctrl+c"))&&this.close();return}if(this.mode==="actions"){if(S(e,"escape")||S(e,"ctrl+c")){this.mode="list",this.error=void 0,this.syncFocus(),this.options.requestRender();return}if(S(e,"up"))return this.moveAction(-1);if(S(e,"down"))return this.moveAction(1);(S(e,"enter")||S(e,"space"))&&this.chooseAction();return}if(S(e,"escape")||S(e,"ctrl+c")){this.searchInput.getValue()?(this.searchInput.setValue(""),this.resetSelection()):this.close();return}if(S(e,"up"))return this.moveSelection(-1);if(S(e,"down"))return this.moveSelection(1);if(S(e,V.pageUp))return this.moveSelection(-this.visibleEntryCount);if(S(e,V.pageDown))return this.moveSelection(this.visibleEntryCount);if(S(e,"enter")||S(e,"space")){this.openActions();return}let t=this.searchInput.getValue();this.searchInput.handleInput(e),t!==this.searchInput.getValue()?this.resetSelection():this.options.requestRender()}invalidate(){this.searchInput.invalidate()}render(e){return this.renderViewport(e,24)}renderViewport(e,t){let i=Math.max(0,Math.floor(e)),s=Math.max(1,Math.floor(t));if(i===0)return[];let r=this.busy?V6(this.busyLabel??ge("preparingRewind")):ge(this.loading?"loadingHint":this.loadError?"loadErrorHint":this.mode==="actions"?"actionsHint":s<10?"compactHint":this.searchInput.getValue()?"filterHint":"hint"),o=ae(i,s,r),a=o.contentWidth,u=o.bodyHeight,l=this.loading?[p.hex(d.signal)(`\u280B ${ge("loading")}`)]:this.loadError?[p.hex(d.warning)(C(this.loadError))]:this.mode==="actions"?this.renderActions(a,u):this.renderList(a,u),h=o.render({title:this.mode==="actions"?ge("actions"):ge("title"),meta:this.options.sessionTitle?.trim()?Xi(C(this.options.sessionTitle),Math.floor(i/2)):void 0,body:l}).map(m=>j6(m,i));if(h.length>=s)return h.slice(0,s);for(;h.length<s;)h.push("");return h}setBusy(e,t){this.busy=e,this.busyLabel=e?t:void 0,e&&(this.error=void 0),this.syncFocus(),this.options.requestRender()}restoreAfterAction(e){this.busy=!1,this.busyLabel=void 0,this.mode="list",this.error=e,this.syncFocus(),this.options.requestRender()}setSummaries(e){this.summaries=[...e].sort((t,i)=>i.timestamp-t.timestamp),this.loading=!1,this.loadError=void 0,this.resetSelection()}setLoadError(e){this.loading=!1,this.loadError=e,this.options.requestRender()}renderList(e,t){let i=this.visibleSummaries();this.clampSelection(i);let s=`${ge("search")}: `,r=this.searchInput.render(Math.max(1,e-w(s)))[0]??"",o=t>=2?[`${p.hex(d.muted)(s)}${r}`,...t>=5?[""]:[]]:[],a=Math.max(1,t-o.length-(this.error?1:0));if(i.length===0)o.push(p.hex(d.muted)(this.searchInput.getValue().trim()?ge("noResults"):L("sessionMutation.history.empty")));else{let u=a>=2?2:1,l=a>=10?1:0;this.visibleEntryCount=Math.max(1,Math.min(ax,Math.floor((a+l)/(u+l))));let c=Math.max(0,Math.min(this.selectedIndex-Math.floor(this.visibleEntryCount/2),i.length-this.visibleEntryCount)),h=Math.min(i.length,c+this.visibleEntryCount);for(let m=c;m<h;m+=1){let f=i[m];if(!f)continue;let y=f.userMessageId===this.selectedMessageId,T=Xi(C(f.contentHead??""),e-2);if(o.push((y?p.bold.hex(d.signal):p.hex(d.text))(`${y?"\u203A":" "} ${T}`)),u>1){let b=[La(f.timestamp,this.nowMs()),Bs(f.fileChangeCount),...f.assistantMessageId?[]:[ge("incomplete")]];o.push(p.hex(d.muted)(` ${b.join(" \xB7 ")}`))}l&&m<h-1&&o.push("")}}return this.error&&o.push(p.hex(d.warning)(C(this.error))),o}renderActions(e,t){let i=this.selectedSummary();if(!i)return[p.hex(d.muted)(L("sessionMutation.history.empty"))];let s=this.actions(i),r=this.affectedTurnCount(i),o=[Bs(i.fileChangeCount),Ne(r===1?"sessionMutation.format.affected.one":"sessionMutation.format.affected.many",{count:r}),La(i.timestamp,this.nowMs())].join(" \xB7 "),a=[p.hex(d.muted)(Xi(i.contentHead,Math.max(16,e-2))),p.hex(d.muted)(o)].slice(0,Math.max(0,t-2)),u=s.flatMap((m,f)=>{let y=f===this.actionIndex,T=y?p.bold.hex(d.signal)("\u203A "):" ",b=m.disabledReason?p.hex(d.dim)(m.label):y?p.bold.hex(d.signal)(m.label):p.hex(d.text)(m.label);return[`${T}${b}`,p.hex(m.disabledReason?d.warning:d.muted)(` ${m.disabledReason??m.description}`)]});this.error&&u.push("",p.hex(d.warning)(C(this.error)));let l=Math.max(0,t-a.length),c=this.actionIndex*2,h=Math.max(0,Math.min(c,Math.max(0,u.length-l)));return[...a,...u.slice(h,h+l)]}visibleSummaries(){let e=this.searchInput.getValue().trim().toLocaleLowerCase().split(/\s+/u).filter(Boolean);return e.length===0?[...this.summaries]:this.summaries.filter(t=>e.every(i=>W6(t,i,this.nowMs())))}affectedTurnCount(e){let t=this.summaries.findIndex(i=>i.userMessageId===e.userMessageId);return t>=0?t+1:1}moveSelection(e){let t=this.visibleSummaries();t.length!==0&&(this.clampSelection(t),this.selectedIndex=Math.max(0,Math.min(t.length-1,this.selectedIndex+e)),this.selectedMessageId=t[this.selectedIndex]?.userMessageId,this.error=void 0,this.options.requestRender())}resetSelection(){this.selectedIndex=0,this.selectedMessageId=this.visibleSummaries()[0]?.userMessageId,this.error=void 0,this.options.requestRender()}clampSelection(e=this.visibleSummaries()){if(e.length===0){this.selectedIndex=0,this.selectedMessageId=void 0;return}let t=this.selectedMessageId?e.findIndex(i=>i.userMessageId===this.selectedMessageId):-1;this.selectedIndex=t>=0?t:Math.max(0,Math.min(this.selectedIndex,e.length-1)),this.selectedMessageId=e[this.selectedIndex]?.userMessageId}selectedSummary(e=this.visibleSummaries()){if(this.selectedMessageId){let t=e.find(i=>i.userMessageId===this.selectedMessageId);if(t)return t}return e[this.selectedIndex]}openActions(){this.selectedSummary()&&(this.mode="actions",this.actionIndex=0,this.error=void 0,this.syncFocus(),this.options.requestRender())}moveAction(e){let t=this.selectedSummary();if(!t)return;let i=this.actions(t);this.actionIndex=(this.actionIndex+e+i.length)%Math.max(1,i.length),this.error=void 0,this.options.requestRender()}chooseAction(){let e=this.selectedSummary();if(!e)return;let t=this.actions(e)[this.actionIndex];if(t){if(t.disabledReason){this.error=t.disabledReason,this.options.requestRender();return}this.busy=!0,this.busyLabel=this.preparingLabel(t.action),this.error=void 0,this.syncFocus(),this.options.requestRender(),this.options.onAction(t.action,e,this.affectedTurnCount(e))}}preparingLabel(e){return e==="fork"?ge("preparingFork"):e==="edit"?ge("preparingEdit"):ge("preparingRewind")}actions(e){let t=this.options.mutationAvailable?void 0:this.options.mutationUnavailableReason??ge("mutationUnavailable"),i=t??(e.assistantMessageId?void 0:ge("forkUnavailable"));return[{action:"fork",label:ge("fork"),description:ge("forkDescription"),...i?{disabledReason:i}:{}},{action:"edit",label:ge("edit"),description:ge("editDescription"),...t?{disabledReason:t}:{}},{action:"rewind-conversation",label:ge("rewindConversation"),description:ge("rewindConversationDescription"),...t?{disabledReason:t}:{}},{action:"rewind-conversation-and-files",label:ge("rewindFiles"),description:ge("rewindFilesDescription"),...t?{disabledReason:t}:{}}]}close(){this.closed||(this.closed=!0,this.searchInput.focused=!1,this.options.onCancel())}syncFocus(){this.searchInput.focused=this._focused&&this.mode==="list"&&!this.busy}};function W6(n,e,t){if(e==="forkable")return!!n.assistantMessageId;if(e.startsWith("files:")){let s=Number.parseInt(e.slice(6),10);return Number.isFinite(s)&&n.fileChangeCount===s}return[n.contentHead,La(n.timestamp,t),n.assistantMessageId?"forkable assistant replied":""].filter(Boolean).join(" ").toLocaleLowerCase().includes(e)}function j6(n,e){return w(n)<=e?n:E(n,e,p.hex(d.dim)("\u2026"))}function V6(n){return`${p.hex(d.signal)(`\u280B ${n}`)}${p.hex(d.dim)(" \xB7 ")}${z("Esc cancel")}`}var Da=100,Hc=class{constructor(e){this.options=e}mutationScreen;historyScreen;historyExplorer;historySourceSessionId;historyLoadSequence=0;mutationSequence=0;invocations=new Map;startFork(){if(this.options.hasLiveRun()){this.options.editor.setText("/fork"),this.options.surfaceHost.setChatFocus(this.options.editor),this.options.setHint(L("sessionMutation.hint.forkRunning")),this.options.onChanged();return}let t=this.options.controller.snapshot().session?.sessionId;if(!t){this.options.setHint(L("sessionMutation.hint.forkNoSession")),this.options.onChanged();return}this.options.setHint(L("sessionMutation.hint.loadingFork")),this.options.onChanged(),this.beginInvocation("fork",t)}startRewind(){if(this.options.hasLiveRun()){this.options.editor.setText("/rewind"),this.options.surfaceHost.setChatFocus(this.options.editor),this.options.setHint(L("sessionMutation.error.busy")),this.options.onChanged();return}let e=this.options.controller.snapshot().session?.sessionId;if(!e){this.options.setHint(L("sessionMutation.hint.rewindNoSession")),this.options.onChanged();return}this.options.setHint(L("sessionMutation.hint.loadingRewind")),this.options.onChanged(),this.beginInvocation("rewind",e)}startEdit(){if(this.options.hasLiveRun()){this.options.editor.setText("/edit"),this.options.surfaceHost.setChatFocus(this.options.editor),this.options.setHint(L("sessionMutation.hint.editRunning")),this.options.onChanged();return}let e=this.options.controller.snapshot().session?.sessionId;if(!e){this.options.setHint(L("sessionMutation.hint.editNoSession")),this.options.onChanged();return}this.options.setHint(L("sessionMutation.hint.loadingEdit")),this.options.onChanged(),this.beginInvocation("edit",e)}startHistory(){let e=this.options.controller.snapshot().session;if(!e){this.options.setHint(ge("noSession")),this.options.onChanged();return}this.closeHistoryScreen();let t=e.sessionId;this.historySourceSessionId=t;let i,s=!this.options.hasLiveRun(),r=()=>{},o=new qc({...e.title?{sessionTitle:e.title}:{},summaries:[],loading:!0,mutationAvailable:s,...s?{}:{mutationUnavailableReason:ge("running")},onAction:(a,u,l)=>this.startHistoryAction(a,u,l),onRetryLoad:()=>r(),onCancel:()=>{let a=this.invocations.get(this.mutationSequence);a?.sourceSessionId===t&&this.invalidateMutation(a.sequence),i?.close()&&this.clearHistoryScreen(i)},requestRender:this.options.onChanged,...this.options.nowMs?{nowMs:this.options.nowMs()}:{}});r=()=>{let a=++this.historyLoadSequence;this.historySourceSessionId=t,this.options.runtime.listSessionInputSummaries(t,{limit:Da}).then(u=>{a!==this.historyLoadSequence||this.options.controller.snapshot().session?.sessionId!==t||o.setSummaries(u)}).catch(u=>{a===this.historyLoadSequence&&o.setLoadError(N(u,{summary:L("sessionMutation.error.loadHistory"),nextStep:"Press Enter to retry.",preservation:L("sessionMutation.error.sessionUnchanged")}))})},i=this.options.surfaceHost.pushFeature({screen:o,focus:o}),this.historyExplorer=o,this.historyScreen=i,this.options.onChanged(),r()}isEditing(){let e=this.getEditInvocation(this.mutationSequence);return e?.phase==="editing"||e?.phase==="submitting"||e?.phase==="resubmit"}editAttachmentEntries(e=!0){let t=this.getEditInvocation(this.mutationSequence);return!t||e&&!this.isCurrentMutation(t)?[]:(ux(t.targetMessage?.attachments??[],[])??[]).map((i,s)=>({attachment:i,id:`edit:${t.sourceSessionId}:${t.targetMessage?.id}:${s}`,label:va(i,s)}))}editAttachmentCount(){return this.retainedEditAttachments().length}retainedEditAttachments(e){let t=this.editAttachmentEntries();if(t.length===0)return[];let i=new Set((e??this.options.editor.captureDraft()).attachmentPlaceholders?.map(({id:s})=>s));return t.filter(({id:s})=>i.has(s)).map(({attachment:s,id:r},o)=>({...s,id:r,label:va(s,o)}))}clearEditAttachmentPlaceholders(){let e=new Set(this.editAttachmentEntries(!1).map(({id:t})=>t));e.size!==0&&this.options.editor.syncAttachmentPlaceholders((this.options.editor.captureDraft().attachmentPlaceholders??[]).filter(({id:t})=>!e.has(t)))}cancelActiveEdit(){let e=this.getEditInvocation(this.mutationSequence);return!e||e.phase!=="editing"&&e.phase!=="resubmit"?!1:(this.clearEditAttachmentPlaceholders(),this.options.editor.setText(""),this.options.setHint(void 0),this.options.setEditTranscriptBoundary?.(void 0),this.invocations.delete(e.sequence),this.options.onChanged(),!0)}settleEditResubmit(e){let t=this.getEditInvocation(this.mutationSequence);!t||t.phase!=="resubmitting"||(e?(this.options.setEditTranscriptBoundary?.(void 0),this.invocations.delete(t.sequence),this.options.setHint(void 0)):(this.invocations.set(t.sequence,{...t,phase:"resubmit"}),this.options.setHint(L("sessionMutation.hint.editResubmit"))),this.options.onChanged())}async submitEdit(e,t=[],i){let s=this.getEditInvocation(this.mutationSequence);if(s?.phase==="submitting")return"retained";if(!s||s.phase!=="editing"&&s.phase!=="resubmit"||!s.selectedSummary)return;if(!this.isCurrentMutation(s))return this.invalidateMutation(s.sequence),"retained";if(this.options.hasLiveRun())return this.options.setHint(ge("running")),this.options.onChanged(),"retained";let r=ux(this.retainedEditAttachments(i),t);if(!e.trim())return this.options.setHint(L("sessionMutation.hint.editing")),this.options.onChanged(),"retained";let o=i?Yi(i)??e:e,a=Ti(s.targetMessage?.editContent??s.targetMessage?.content,o)??o;if(s.phase==="resubmit")return this.invocations.set(s.sequence,{...s,phase:"resubmitting"}),this.options.setHint(L("sessionMutation.hint.editSubmitting")),this.options.onChanged(),{kind:"resubmit",transportContent:a,...r?{attachments:r}:{}};let u=this.options.controller.getTerminalDurationId();this.invocations.set(s.sequence,{...s,phase:"submitting"}),this.options.setHint(L("sessionMutation.hint.editSubmitting")),this.options.onChanged();try{await this.options.runtime.editSessionMessage({sessionId:s.sourceSessionId,userMessageId:s.selectedSummary.userMessageId,clientRequestId:s.operationId,content:a,attachments:r,rewindTurnDiff:!0})}catch(c){let h=this.getEditInvocation(s.sequence);if(!h||!this.isCurrentMutation(h))return this.invalidateMutation(s.sequence),"retained";let m=zr(c);return(m==="EDIT_RESTART_NEEDS_RESUBMIT"||m==="EDIT_SUBMIT_FAILED_AFTER_REWIND"||m==="REWIND_DISPLAY_COMMIT_FAILED")&&this.options.controller.dismissTerminalDuration(u),m==="EDIT_RESTART_NEEDS_NEW_OPERATION"?(this.invocations.set(s.sequence,{...h,operationId:this.createOperationId("edit",h.operationId),phase:"editing"}),this.options.setHint(L("sessionMutation.hint.editing")),this.options.onChanged(),this.options.append(L("sessionMutation.error.editNeedsNewOperation"),"warning"),"retained"):m==="EDIT_RESTART_NEEDS_RESUBMIT"?(this.invocations.set(s.sequence,{...h,phase:"resubmit"}),this.options.setHint(L("sessionMutation.hint.editResubmit")),this.options.onChanged(),this.options.append(L("sessionMutation.error.editNeedsResubmit"),"warning"),"retained"):(this.invocations.set(s.sequence,{...h,phase:"editing"}),this.options.setHint(L("sessionMutation.hint.editing")),this.options.onChanged(),this.options.append(m==="EDIT_SUBMIT_FAILED_AFTER_REWIND"?L("sessionMutation.error.editSubmitAfterRewind"):X6(c),"warning"),"retained")}this.isCurrentMutation(s)&&this.options.controller.dismissTerminalDuration(u);try{await this.options.refreshProjection?.(s.sourceSessionId)}catch{this.isCurrentMutation(s)&&this.options.append(L("sessionMutation.error.editRefresh"),"warning")}let l=this.getEditInvocation(s.sequence);return!l||!this.isCurrentMutation(l)||(this.options.setEditTranscriptBoundary?.(void 0),this.invocations.delete(s.sequence),this.options.setHint(void 0),this.options.onChanged()),"consumed"}isRewindPickerActive(){return!!this.mutationScreen?.isActive()}async loadEditHistoryPreview(e,t){let i=this.getEditInvocation(e);if(!(!i||!this.isCurrentMutation(i))){this.invocations.set(e,{...i,selectedSummary:t,phase:"preview-loading"});try{let s=await this.options.runtime.getSessionRewindPreview({sessionId:i.sourceSessionId,userMessageId:t.userMessageId}),r=this.getEditInvocation(e);if(!r||!this.isCurrentMutation(r))return this.invalidateMutation(e);this.historyExplorer?.restoreAfterAction();let o=new Na({preview:s,heading:ge("editPreviewHeading"),target:lx(t),impact:cx(r.affectedTurnCount,t.fileChangeCount),continueHint:L("sessionMutation.preview.editHint"),requestRender:this.options.onChanged,onCancel:()=>this.invalidateMutation(e),onContinue:()=>{let u=this.getEditInvocation(e);!u?.selectedSummary||!this.isCurrentMutation(u)||(this.historyExplorer?.setBusy(!0,ge("preparingTarget")),this.closeMutationScreen(),this.invocations.set(e,{...u,phase:"loading"}),this.loadEditTarget(e,u.selectedSummary))}}),a=this.options.surfaceHost.pushFeature({screen:o,focus:o});this.mutationScreen=a,this.invocations.set(e,{...r,preview:s,previewPanel:o,screenHandle:a,phase:"preview"})}catch(s){let r=this.getEditInvocation(e);if(!r||!this.isCurrentMutation(r))return this.invalidateMutation(e);this.invocations.delete(e),this.historyExplorer?.restoreAfterAction(N(s,{summary:L("sessionMutation.error.loadPreview"),nextStep:L("sessionMutation.error.chooseAgain"),preservation:L("sessionMutation.error.sessionUnchanged")}))}}}async loadEditSummaries(e){let t=this.getEditInvocation(e);if(!(!t||!this.isCurrentMutation(t)))try{let i=await this.options.runtime.listSessionInputSummaries(t.sourceSessionId,{limit:Da});if(!this.isCurrentMutation(t))return this.invalidateMutation(e);let s=J6(i);if(!s){this.invalidateMutation(e),this.options.setHint(L("sessionMutation.history.empty")),this.options.onChanged();return}this.loadEditTarget(e,s)}catch(i){if(!this.isCurrentMutation(t))return this.invalidateMutation(e);this.invalidateMutation(e),this.options.append(N(i,{summary:L("sessionMutation.error.loadHistory"),nextStep:L("sessionMutation.error.retryEdit"),preservation:L("sessionMutation.error.sessionUnchanged")}),"warning")}}async loadEditTarget(e,t){let i=this.getEditInvocation(e);if(!i||i.phase!=="loading"||!this.isCurrentMutation(i))return this.invalidateMutation(e);this.invocations.set(e,{...i,selectedSummary:t,phase:"target-loading"});try{let s=await this.findMessage(i.sourceSessionId,t.userMessageId),r=this.getEditInvocation(e);if(!r||!this.isCurrentMutation(r))return this.invalidateMutation(e);if(!s||s.role!=="user")throw new Error("The selected committed user message could not be loaded.");this.beginEditing(e,r,s)}catch(s){let r=this.getEditInvocation(e);if(!r||!this.isCurrentMutation(r))return this.invalidateMutation(e);let o=N(s,{summary:L("sessionMutation.error.loadPreview"),nextStep:L("sessionMutation.error.retryEdit"),preservation:L("sessionMutation.error.sessionUnchanged")});this.invalidateMutation(e),this.historyExplorer?this.historyExplorer.restoreAfterAction(o):this.options.append(o,"warning")}}beginEditing(e,t,i){if(t.phase!=="target-loading"||!this.isCurrentMutation(t))return this.invalidateMutation(e);if(this.options.hasLiveRun()){let o=ge("running");this.invalidateMutation(e),this.historyExplorer?this.historyExplorer.restoreAfterAction(o):this.options.append(o,"warning");return}this.closeMutationScreen(),this.closeHistoryScreen(),this.options.setEditTranscriptBoundary?.(i.id),this.invocations.set(e,{...t,targetMessage:i,phase:"editing"});let s=Rn(i.editContent??i.content),r=this.editAttachmentEntries();r.length>0?this.options.editor.restoreMessageDraft(s,r):this.options.editor.setText(s),this.options.surfaceHost.setChatFocus(this.options.editor),this.options.setHint(L("sessionMutation.hint.editing")),this.options.onChanged()}async findMessage(e,t){let i,s=new Set;do{let r=await this.options.runtime.listMessagePage(e,{limit:Da,...i?{before:i}:{}}),o=r.messages.find(a=>a.id===t);if(o)return o;if(!r.hasMore||!r.nextCursor||s.has(r.nextCursor))return;s.add(r.nextCursor),i=r.nextCursor}while(i)}async loadRewindSummaries(e){let t=this.getRewindInvocation(e);if(!(!t||!this.isCurrentMutation(t)))try{let i=await this.options.runtime.listSessionInputSummaries(t.sourceSessionId,{limit:Da});if(!this.isCurrentMutation(t))return this.invalidateMutation(e);this.openRewindPicker(e,i)}catch(i){if(!this.isCurrentMutation(t))return this.invalidateMutation(e);this.invalidateMutation(e),this.options.append(N(i,{summary:L("sessionMutation.error.loadHistory"),nextStep:L("sessionMutation.error.retryRewind"),preservation:L("sessionMutation.error.sessionUnchanged")}),"warning")}}openRewindPicker(e,t){let i=this.getRewindInvocation(e);if(!i||!this.isCurrentMutation(i))return;this.closeMutationScreen();let s=new Oa({summaries:t,mode:"rewind",onSelect:o=>void this.loadRewindPreview(e,o),onCancel:()=>this.cancelRewind(e),requestRender:this.options.onChanged,...this.options.nowMs?{nowMs:this.options.nowMs()}:{}});this.options.setHint(void 0),this.options.onChanged();let r=this.options.surfaceHost.pushFeature({screen:s,focus:s});this.mutationScreen=r,this.invocations.set(e,{...i,picker:s,screenHandle:r,phase:"picking"})}async loadRewindPreview(e,t){let i=this.getRewindInvocation(e);if(!i||i.phase!=="picking"||!this.isCurrentMutation(i))return this.invalidateMutation(e);this.invocations.set(e,{...i,selectedSummary:t,phase:"preview-loading"});try{let s=await this.options.runtime.getSessionRewindPreview({sessionId:i.sourceSessionId,userMessageId:t.userMessageId}),r=this.getRewindInvocation(e);if(!r||!this.isCurrentMutation(r))return this.invalidateMutation(e);this.historyExplorer?.restoreAfterAction(),this.openRewindPreview(e,r,s)}catch(s){let r=this.getRewindInvocation(e);if(!r||!this.isCurrentMutation(r))return this.invalidateMutation(e);let o=N(s,{summary:L("sessionMutation.error.loadPreview"),nextStep:L("sessionMutation.error.chooseAgain"),preservation:L("sessionMutation.error.sessionUnchanged")});if(this.historyExplorer){this.invocations.delete(e),this.historyExplorer.restoreAfterAction(o);return}r.picker?.resetSelection(o),this.invocations.set(e,{...r,phase:"picking"}),this.options.append(o,"warning")}}openRewindPreview(e,t,i){this.closeMutationScreen();let s=new Na({preview:i,...t.selectedSummary?{target:lx(t.selectedSummary),impact:cx(t.affectedTurnCount??i.turns.length,t.selectedSummary.fileChangeCount)}:{},continueHint:t.scope==="conversation_and_files"?L("sessionMutation.preview.confirmRewindHint"):L("sessionMutation.preview.rewindHint"),requestRender:this.options.onChanged,onCancel:()=>this.cancelRewind(e),onContinue:()=>this.continueRewindAfterPreview(e)}),r=this.options.surfaceHost.pushFeature({screen:s,focus:s});this.mutationScreen=r,this.invocations.set(e,{...t,preview:i,previewPanel:s,screenHandle:r,phase:"preview"})}continueRewindAfterPreview(e){let t=this.getRewindInvocation(e);if(t?.phase==="confirming"&&t.scope==="conversation_and_files"&&this.historyExplorer&&this.isCurrentMutation(t)){this.confirmRewind(e,t.scope);return}if(!t||t.phase!=="preview"||!t.preview||!this.isCurrentMutation(t))return this.invalidateMutation(e);if(t.scope){t.scope==="conversation_and_files"&&this.historyExplorer?(this.invocations.set(e,{...t,phase:"confirming"}),this.confirmRewind(e,t.scope)):this.openRewindConfirmation(e,t,t.scope);return}this.openRewindScope(e)}openRewindScope(e){let t=this.getRewindInvocation(e);if(!t||!t.preview||!this.isCurrentMutation(t))return this.invalidateMutation(e);this.closeMutationScreen();let i=new Bc({onSelect:r=>this.handleRewindScope(e,r),onCancel:()=>this.cancelRewind(e),requestRender:this.options.onChanged}),s=this.options.surfaceHost.pushFeature({screen:i,focus:i});this.mutationScreen=s,this.invocations.set(e,{...t,scopePicker:i,screenHandle:s,phase:"scope"})}handleRewindScope(e,t){let i=this.getRewindInvocation(e);if(!i||i.phase!=="scope"||!this.isCurrentMutation(i))return this.invalidateMutation(e);this.openRewindConfirmation(e,i,t)}openRewindConfirmation(e,t,i){if(i==="conversation_and_files"&&!t.preview)return this.invalidateMutation(e);this.closeMutationScreen();let s=new n1({preview:t.preview,summary:t.selectedSummary,affectedTurnCount:t.affectedTurnCount,scope:i,onConfirm:()=>void this.confirmRewind(e,i),onCancel:()=>this.cancelRewind(e),requestRender:this.options.onChanged}),r=this.options.surfaceHost.pushFeature({screen:s,focus:s});this.mutationScreen=r,this.invocations.set(e,{...t,scope:i,confirmation:s,screenHandle:r,phase:"confirming"})}async confirmRewind(e,t){let i=this.getRewindInvocation(e);if(!i||!i.selectedSummary||!this.isCurrentMutation(i))return this.invalidateMutation(e);if(i.phase!=="confirming")return;if(this.options.hasLiveRun()){let a=ge("running");i.confirmation?.setError(a),i.previewPanel?.setError(a),i.scopePicker?.setError(a),this.options.onChanged();return}i.confirmation?.setBusy(!0),i.previewPanel?.setBusy(!0),i.scopePicker?.setBusy(!0),this.invocations.set(e,{...i,scope:t,phase:"rewinding"});let s;try{s=await this.options.runtime.rewindSession({sessionId:i.sourceSessionId,userMessageId:i.selectedSummary.userMessageId,clientRequestId:i.operationId,...t==="conversation_and_files"?{rewindTurnDiff:!0}:{}})}catch(a){let u=this.getRewindInvocation(e);if(!u||!this.isCurrentMutation(u))return this.invalidateMutation(e);u.confirmation?.setBusy(!1),u.previewPanel?.setBusy(!1),u.scopePicker?.setBusy(!1),u.confirmation?.setError(Zf(a)),u.previewPanel?.setError(Zf(a)),u.scopePicker?.resetSelection(),u.scopePicker?.setError(Zf(a)),this.invocations.set(e,{...u,...Z6(a)?{operationId:this.createOperationId("rewind",u.operationId)}:{},phase:"confirming"}),this.options.append(px(a),"warning");return}let r=Y6(t,s,i.preview);try{await this.options.reloadSessionProjection(i.sourceSessionId)}catch{let a=this.getRewindInvocation(e);if(!a||!this.isCurrentMutation(a))return this.invalidateMutation(e);this.options.append(L("sessionMutation.error.refresh"),"warning"),this.closeMutationScreen(),this.closeHistoryScreen(),this.invocations.delete(e);return}let o=this.getRewindInvocation(e);if(!o||!this.isCurrentMutation(o))return this.invalidateMutation(e);if(this.closeMutationScreen(),this.closeHistoryScreen(),this.invocations.delete(e),r)this.options.append(r.message,r.kind);else{let a=Math.max(1,i.affectedTurnCount??i.preview?.turns.length??1),u=Ne(a===1?"sessionMutation.format.turn.one":"sessionMutation.format.turn.many",{count:a}),l=hx(i.preview);this.options.setHint(t==="conversation"?Ne("sessionMutation.outcome.conversationSuccess",{turns:u}):Ne("sessionMutation.outcome.filesSuccess",{turns:u,files:Bs(l.ready)})),this.options.onChanged()}}cancelRewind(e){this.invocations.has(e)&&(this.historyExplorer?.restoreAfterAction(),this.invalidateMutation(e))}closeMutationScreen(){let e=this.mutationScreen;this.mutationScreen=void 0,e?.close()}closeHistoryScreen(){this.historyLoadSequence+=1;let e=this.historyScreen;this.historyScreen=void 0,this.historyExplorer=void 0,this.historySourceSessionId=void 0,e?.close()}clearHistoryScreen(e){this.historyScreen===e&&(this.historyLoadSequence+=1,this.historyScreen=void 0,this.historyExplorer=void 0,this.historySourceSessionId=void 0)}isForkPickerActive(){return!!this.mutationScreen?.isActive()}startHistoryAction(e,t,i){let s=this.historySourceSessionId;if(!s||this.options.controller.snapshot().session?.sessionId!==s){this.closeHistoryScreen();return}if(this.options.hasLiveRun()){this.historyExplorer?.restoreAfterAction(ge("running"));return}let r=this.beginMutationInvocation();if(e==="fork"){let u={sequence:r,sourceSessionId:s,mode:"fork",operationId:this.createOperationId("fork"),token:r,screenHandle:void 0,phase:"picking"};this.invocations.set(r,u),this.handleSelection(r,t);return}if(e==="edit"){let u={sequence:r,sourceSessionId:s,mode:"edit",operationId:this.createOperationId("edit"),token:r,selectedSummary:t,affectedTurnCount:i,phase:"loading"};this.invocations.set(r,u),this.loadEditHistoryPreview(r,t);return}let o=e==="rewind-conversation"?"conversation":"conversation_and_files",a={sequence:r,sourceSessionId:s,mode:"rewind",operationId:this.createOperationId("rewind"),token:r,scope:o,affectedTurnCount:i,selectedSummary:t,phase:"picking"};if(this.invocations.set(r,a),o==="conversation"){this.openRewindConfirmation(r,a,o);return}this.loadRewindPreview(r,t)}beginMutationInvocation(){this.closeMutationScreen(),[...this.invocations.values()].some(t=>t.mode==="edit")&&this.options.setEditTranscriptBoundary?.(void 0);let e=++this.mutationSequence;return this.invocations.clear(),e}beginInvocation(e,t){this.closeHistoryScreen();let i=this.beginMutationInvocation(),s=this.createOperationId(e);if(e==="rewind"){this.invocations.set(i,{sequence:i,sourceSessionId:t,mode:e,operationId:s,token:i,phase:"loading"}),this.loadRewindSummaries(i);return}if(e==="edit"){this.invocations.set(i,{sequence:i,sourceSessionId:t,mode:e,operationId:s,token:i,phase:"loading"}),this.loadEditSummaries(i);return}this.invocations.set(i,{sequence:i,sourceSessionId:t,mode:e,operationId:s,token:i,screenHandle:void 0,phase:"loading"}),this.loadSummaries(i)}createOperationId(e,t){let i=this.options.createOperationId?.()??dx(),s=e==="rewind"?i.replace("tui-fork_","tui-rewind_"):e==="edit"?i.replace("tui-fork_","tui-edit_"):i;if(s!==t)return s;let r=dx();return e==="rewind"?r.replace("tui-fork_","tui-rewind_"):e==="edit"?r.replace("tui-fork_","tui-edit_"):r}async loadSummaries(e){let t=this.getForkInvocation(e);if(!t)return;if(this.hasSessionChanged(t)){this.invocations.delete(e);return}let i;try{i=await this.options.runtime.listSessionInputSummaries(t.sourceSessionId,{limit:Da})}catch(s){if(!this.isCurrentMutation(t)){this.invalidateMutation(e);return}this.invalidateMutation(e),this.options.append(N(s,{summary:L("sessionMutation.error.loadHistory"),nextStep:L("sessionMutation.error.retryFork"),preservation:L("sessionMutation.error.sourceUnchanged")}),"warning");return}if(!this.isCurrentMutation(t)){this.invalidateMutation(e);return}if(this.options.hasLiveRun()){t.confirmation?.setError(ge("running")),this.options.onChanged();return}i.length===0&&(this.options.setHint(L("sessionMutation.hint.noForkPrompts")),this.options.onChanged()),this.openPicker(e,i)}openPicker(e,t){let i=this.getForkInvocation(e);if(!i)return;this.closeMutationScreen();let s=new Oa({summaries:t,mode:i.mode,onSelect:o=>this.handleSelection(e,o),onCancel:()=>this.handleCancel(e),requestRender:this.options.onChanged,...this.options.nowMs?{nowMs:this.options.nowMs()}:{}});this.options.setHint(void 0),this.options.onChanged();let r=this.options.surfaceHost.pushFeature({screen:s,focus:s});this.mutationScreen=r,this.invocations.set(e,{...i,screenHandle:r,picker:s,phase:"picking"})}handleCancel(e){this.getForkInvocation(e)&&(this.mutationSequence===e&&this.closeMutationScreen(),this.invocations.delete(e))}async handleSelection(e,t){let i=this.getForkInvocation(e);if(!i||i.phase!=="picking")return;if(!this.isCurrentMutation(i)){this.invalidateMutation(e);return}this.invocations.set(e,{...i,selectedSummary:t,phase:"options"});let s=await this.fetchForkOptions(e,i,t);if(!s)return;let r=this.getForkInvocation(e);if(!r||!this.isCurrentMutation(r)){this.invalidateMutation(e);return}if(!s.canFork){let o=e3(s);if(this.historyExplorer){this.invocations.delete(e),this.historyExplorer.restoreAfterAction(o);return}r.picker?.resetSelection(o),this.invocations.set(e,{...r,phase:"picking"}),this.options.append(o,"warning");return}this.openConfirmation(e,r,t,s)}openConfirmation(e,t,i,s){if(!this.isCurrentMutation(t)){this.invalidateMutation(e);return}this.historyExplorer?.restoreAfterAction(),this.closeMutationScreen();let r=new t1({summary:i,options:s,onConfirm:()=>this.confirmFork(e),onCancel:()=>this.handleCancel(e),requestRender:this.options.onChanged}),o=this.options.surfaceHost.pushFeature({screen:r,focus:r});this.mutationScreen=o,this.invocations.set(e,{...t,screenHandle:o,confirmation:r,selectedSummary:i,forkOptions:s,phase:"confirming"})}async confirmFork(e){let t=this.getForkInvocation(e);if(!t||t.phase!=="confirming"||!t.selectedSummary)return;if(!this.isCurrentMutation(t)){this.invalidateMutation(e);return}this.invocations.set(e,{...t,phase:"forking"}),t.confirmation?.setBusy(!0);let i,s;try{i=await this.forkSession(t,t.selectedSummary)}catch(r){s=r}if(!i){let r=this.getForkInvocation(e);if(!r||!this.isCurrentMutation(r)){this.invalidateMutation(e);return}this.options.append(N(s??new Error("Runtime fork request failed."),{summary:L("sessionMutation.error.forkRequest"),nextStep:L("sessionMutation.error.forkRetry"),preservation:L("sessionMutation.error.sourceUnchanged")}),"warning"),r.confirmation?.setBusy(!1),r.confirmation?.setError(zr(s)?L("sessionMutation.error.forkRetry"):L("sessionMutation.error.forkRetrySameOperation")),this.invocations.set(e,{...r,...zr(s)?{operationId:this.createOperationId("fork",r.operationId)}:{},phase:"confirming"});return}if(!this.isCurrentMutation(t)){this.invalidateMutation(e);return}this.closeMutationScreen(),this.closeHistoryScreen(),this.invocations.delete(e);try{await this.options.sessionFlow.activateSessionById(i.session.sessionId)}catch(r){this.options.append(N(r,{summary:L("sessionMutation.error.activateFork"),nextStep:Ne("sessionMutation.error.openForkManually",{sessionId:i.session.sessionId}),preservation:L("sessionMutation.error.sourceUnchanged")}),"warning")}}async fetchForkOptions(e,t,i){let s=this.options.runtime.getSessionForkOptions;if(!s){this.invalidateMutation(e);let r=L("sessionMutation.error.forkRequest");this.historyExplorer?this.historyExplorer.restoreAfterAction(r):this.options.append(r,"warning");return}try{return await s.call(this.options.runtime,t.sourceSessionId,i.assistantMessageId)}catch(r){if(this.mutationSequence!==e)return;let o=this.getForkInvocation(e);if(!o||!this.isCurrentMutation(o)){this.invalidateMutation(e);return}let a=N(r,{summary:L("sessionMutation.error.loadForkOptions"),nextStep:L("sessionMutation.error.chooseAgain"),preservation:L("sessionMutation.error.sourceUnchanged")});if(this.historyExplorer){this.invocations.delete(e),this.historyExplorer.restoreAfterAction(a);return}o.picker?.resetSelection(a),this.invocations.set(e,{...o,phase:"picking"}),this.options.append(a,"warning");return}}async forkSession(e,t){let i=this.options.runtime.forkSession;if(i)return await i.call(this.options.runtime,{sessionId:e.sourceSessionId,...t.assistantMessageId?{assistantMessageId:t.assistantMessageId}:{},clientRequestId:e.operationId,useSuggestedTitle:!0,createIsolatedWorktree:!1})}getInvocationCountForTesting(){return this.invocations.size}reconcileSession(){let e=this.invocations.get(this.mutationSequence);e&&this.hasSessionChanged(e)&&this.invalidateMutation(e.sequence);let t=this.options.controller.snapshot().session?.sessionId;this.historySourceSessionId&&this.historySourceSessionId!==t&&this.closeHistoryScreen()}invalidateMutation(e){let t=this.invocations.get(e);t?.mode==="edit"&&e===this.mutationSequence&&this.clearEditAttachmentPlaceholders(),t?.mode==="edit"&&(t.phase==="editing"||t.phase==="submitting")&&this.options.setHint(void 0),t?.mode==="edit"&&this.options.setEditTranscriptBoundary?.(void 0),e===this.mutationSequence&&(this.closeMutationScreen(),this.options.setHint(void 0),this.options.onChanged()),this.invocations.delete(e)}isCurrentMutation(e){let t=this.invocations.get(e.sequence);return t?.token===e.token&&t.mode===e.mode&&e.sequence===this.mutationSequence&&!this.hasSessionChanged(e)}getForkInvocation(e){let t=this.invocations.get(e);return t?.mode==="fork"?t:void 0}getRewindInvocation(e){let t=this.invocations.get(e);return t?.mode==="rewind"?t:void 0}getEditInvocation(e){let t=this.invocations.get(e);return t?.mode==="edit"?t:void 0}hasSessionChanged(e){return this.options.controller.snapshot().session?.sessionId!==e.sourceSessionId}},G6="session-mutation:fork-confirm",t1=class{constructor(e){this.options=e}id=G6;layoutRoot=this;focused=!1;busy=!1;error;closed=!1;handleInput(e){if(!this.busy){if(S(e,"escape")||S(e,"ctrl+c")){if(this.closed)return;this.closed=!0,this.options.onCancel();return}!this.busy&&S(e,"enter")&&this.options.onConfirm()}}invalidate(){}render(e){return this.renderViewport(e,24)}renderViewport(e,t){let i=Math.max(0,Math.floor(e)),s=Math.max(1,Math.floor(t));if(i===0)return[];let r=C(this.options.options.suggestedTitle?.trim()||L("sessionMutation.confirm.fork.suggestedTitle")),o=C(this.options.options.sourceTitle?.trim()||L("sessionMutation.confirm.fork.currentSession")),a=C(this.options.summary.contentHead?.trim()||L("sessionMutation.format.noPrompt")),u=this.options.options.worktreeVisible?this.options.options.worktreeEligible?L("sessionMutation.confirm.fork.workspaceEligible"):Ne("sessionMutation.confirm.fork.workspaceUnavailable",{reason:this.options.options.worktreeUnavailableReason?.trim()||L("sessionMutation.confirm.fork.worktreeUnavailable")}):L("sessionMutation.confirm.fork.workspaceCurrent"),l=this.busy?p.hex(d.signal)(L("sessionMutation.confirm.fork.busy")):z(L("sessionMutation.confirm.confirmHint")),c=[p.bold.hex(d.signal)(L("sessionMutation.confirm.fork.title")),p.hex(d.muted)(L("sessionMutation.confirm.fork.helper")),"",`${p.hex(d.muted)(L("sessionMutation.confirm.titleLabel"))} ${p.hex(d.text)(r)}`,`${p.hex(d.muted)(L("sessionMutation.confirm.sourceLabel"))} ${p.hex(d.text)(o)}`,`${p.hex(d.muted)(L("sessionMutation.confirm.fromLabel"))} ${p.hex(d.text)(a)}`,p.hex(d.muted)(C(u)),...this.error?["",p.hex(d.warning)(C(this.error))]:[]],h=fx(c,["",l],s).map(f=>mx(f,i));if(h.length>=s)return h.slice(0,s);let m=[...h];for(;m.length<s;)m.push("");return m}setBusy(e){this.busy=e,e&&(this.error=void 0),this.options.requestRender()}setError(e){this.error=e,this.options.requestRender()}},z6="session-mutation:rewind-confirm",n1=class{constructor(e){this.options=e}id=z6;layoutRoot=this;focused=!1;busy=!1;error;handleInput(e){if(!this.busy){if(S(e,"escape")||S(e,"ctrl+c"))return this.options.onCancel();S(e,"enter")&&this.options.onConfirm()}}invalidate(){}render(e){return this.renderViewport(e,24)}renderViewport(e,t){let i=Math.max(0,Math.floor(e)),s=Math.max(1,Math.floor(t));if(!i)return[];let r=(this.options.preview?.turns??[]).flatMap(y=>y.files).filter(y=>!y.skipped).length,o=(this.options.preview?.turns??[]).flatMap(y=>y.files).filter(y=>y.skipped).length,a=Math.max(1,this.options.affectedTurnCount??this.options.preview?.turns.length??1),u=Ne(a===1?"sessionMutation.format.affected.one":"sessionMutation.format.affected.many",{count:a}),l=Xi(this.options.summary?.contentHead,Math.max(16,i-10)),c=this.options.scope==="conversation_and_files"?L("sessionMutation.confirm.rewind.filesWarning"):L("sessionMutation.confirm.rewind.conversationWarning"),h=[p.bold.hex(d.signal)(L("sessionMutation.confirm.rewind.title")),p.hex(d.muted)(C(c)),`${p.hex(d.muted)(L("sessionMutation.confirm.targetLabel"))} ${p.hex(d.text)(C(l))}`,`${p.hex(d.muted)(L("sessionMutation.confirm.impactLabel"))} ${p.hex(d.text)(u)}`,`${p.hex(d.muted)(L("sessionMutation.confirm.scopeLabel"))} ${p.hex(d.text)(Q6(this.options.scope))}`,`${p.hex(d.muted)(L("sessionMutation.confirm.filesLabel"))} ${this.options.scope==="conversation"?L("sessionMutation.confirm.filesUnchanged"):Ne("sessionMutation.confirm.fileCounts",{ready:r,skipped:o})}`,...r===0&&this.options.scope==="conversation_and_files"?[p.hex(d.warning)("No file changes can be safely rewound at this point.")]:[],...this.error?[p.hex(d.warning)(C(this.error))]:[]],m=["",this.busy?p.hex(d.signal)(L("sessionMutation.confirm.rewind.busy")):z(L("sessionMutation.confirm.confirmHint"))],f=fx(h,m,s).map(y=>mx(y,i));if(f.length>=s)return f.slice(0,s);for(;f.length<s;)f.push("");return f}setBusy(e){this.busy=e,this.options.requestRender()}setError(e){this.error=e,this.options.requestRender()}};function hx(n){let e=0,t=0;for(let i of n?.turns??[])for(let s of i.files)s.skipped?t+=1:e+=1;return{ready:e,skipped:t}}function Q6(n){return n==="conversation"?L("sessionMutation.scope.conversation.label"):L("sessionMutation.scope.both.label")}function Y6(n,e,t){let i=e.turnDiffRewind;if(n==="conversation"){if(e.rewound&&(!i||i.status==="not-requested"))return;if(!e.rewound||i?.status==="no-diff")return{message:L("sessionMutation.outcome.boundaryUnavailable"),kind:"warning"}}if(!i||i.status==="no-diff"||i.status==="skipped")return{message:L("sessionMutation.outcome.noSafeFiles"),kind:"warning"};let s=hx(t);if(i.status==="partial"){let r=i.errorCode?Ne("sessionMutation.outcome.errorSuffix",{code:e1(i.errorCode)}):"";return{message:Ne("sessionMutation.outcome.partial",{error:r}),kind:"warning"}}if(i.status==="failed-after-rewind"){let r=i.errorCode?Ne("sessionMutation.outcome.errorSuffix",{code:e1(i.errorCode)}):"";return{message:Ne("sessionMutation.outcome.failedAfterRewind",{error:r}),kind:"warning"}}if(!(i.status==="rewound"&&(i.revertedTurnIds?.length??0)>0))return{message:Ne("sessionMutation.outcome.unsafe",{status:e1(i.status),ready:s.ready,skipped:s.skipped}),kind:"warning"}}function px(n){let e=zr(n);return e==="STALE"||e==="INVALID_BOUNDARY"||e==="MESSAGE_NOT_FOUND"||e==="MESSAGE_BOUNDARY_NOT_FOUND"||e==="MESSAGE_BOUNDARY_INVALID"?L("sessionMutation.outcome.boundaryUnavailable"):e==="CONFLICT"||e==="ALREADY_SUBMITTED"||e==="DUPLICATE"||e==="CONVERSATION_MUTATION_REQUEST_CONFLICT"?L("sessionMutation.error.conflict"):e==="BUSY"||e==="ACTIVE_TURN"||e==="CONVERSATION_MUTATION_BUSY"?L("sessionMutation.error.busy"):L("sessionMutation.error.retry")}function Zf(n){let e=px(n);return e===L("sessionMutation.error.retry")?L("sessionMutation.error.retrySameOperation"):e}function X6(n){let e=zr(n);return e==="MESSAGE_BOUNDARY_INVALID"||e==="MESSAGE_BOUNDARY_NOT_FOUND"||e==="MESSAGE_NOT_FOUND"?L("sessionMutation.outcome.boundaryUnavailable"):e==="CONVERSATION_MUTATION_REQUEST_CONFLICT"?L("sessionMutation.error.conflict"):e==="CONVERSATION_MUTATION_BUSY"?L("sessionMutation.error.busy"):L("sessionMutation.error.editRequest")}function ux(n,e){let t=n.filter(s=>!!(s.filePath||s.assetId)).map(s=>({type:s.type,fileName:s.fileName,mimeType:s.mimeType,...s.sizeBytes!==void 0?{sizeBytes:s.sizeBytes}:{},...s.filePath?{filePath:s.filePath}:{},...s.assetId?{assetId:s.assetId}:{}})),i=new Map;for(let s of[...t,...e]){let r=s.assetId??s.filePath??`${s.type}:${s.fileName}`;i.set(r,s)}return i.size>0?[...i.values()]:void 0}function J6(n){return n.reduce((e,t)=>!e||t.timestamp>=e.timestamp?t:e,void 0)}function zr(n){if(!n||typeof n!="object")return"";let e=n;return(typeof e.code=="string"?e.code:typeof e.key=="string"?e.key:"").toUpperCase().replace(/[^A-Z0-9_-]/gu,"")}function Z6(n){let e=zr(n);return!!(e&&e!=="REWIND_DISPLAY_COMMIT_FAILED")}function e1(n){return n.toUpperCase().replace(/[^A-Z0-9_-]/gu,"").slice(0,64)||"UNKNOWN"}function mx(n,e){return w(n)<=e?n:E(n,e,p.hex(d.dim)("\u2026"))}function fx(n,e,t){return t<=e.length?e.slice(Math.max(0,e.length-t)):[...n.slice(0,t-e.length),...e]}function e3(n){let e=n.unavailableReason?.trim();return e?Ne("sessionMutation.fork.unavailableReason",{reason:e}):L("sessionMutation.fork.unavailableDefault")}function lx(n){return`${L("sessionMutation.confirm.targetLabel")} ${Xi(n.contentHead,72)}`}function cx(n,e){let t=Math.max(1,n??1);return`${Ne(t===1?"sessionMutation.format.affected.one":"sessionMutation.format.affected.many",{count:t})} \xB7 ${Bs(e)}`}function dx(){return`tui-fork_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`}var Uc=class{constructor(e,t){this.base=e;this.plugins=t}triggerCharacters=["@"];async getSuggestions(e,t,i,s){let r=(e[t]??"").slice(0,i),o=/(?:^|\s)(@[^\s"/]*)$/u.exec(r)?.[1];if(!o||e.join(`
|
|
205
|
-
`).trimStart().startsWith("!")||!this.plugins?.listInstalledPlugins)return this.base.getSuggestions(e,t,i,s);let[a,u]=await Promise.allSettled([this.base.getSuggestions(e,t,i,s),this.plugins.listInstalledPlugins()]);if(s.signal.aborted)return null;let l=a.status==="fulfilled"?a.value:null,c=o.slice(1).normalize("NFKC").toLocaleLowerCase(),h=u.status==="fulfilled"?u.value.filter(f=>f.installed&&f.enabled&&[f.name,f.displayName,f.pluginId].some(y=>y.normalize("NFKC").toLocaleLowerCase().includes(c))).sort((f,y)=>f.displayName.localeCompare(y.displayName)||f.pluginId.localeCompare(y.pluginId)).map(f=>{let y=C(f.displayName).replace(/[[\]\\]/gu," ").replace(/\s+/gu," ").trim().slice(0,256)||f.name;return{value:`@${y}`,label:`@${y}`,pluginId:f.pluginId,groupLabel:" Plugins",description:`${f.marketplace} \xB7 ${E(C(f.description??f.name).replace(/\s+/gu," ").trim(),64,"\u2026")}`}}):[],m=[...h,...(l?.items??[]).map(f=>({...f,...h.length>0?{groupLabel:" Files"}:{}}))];return m.length?{prefix:o,items:m}:null}applyCompletion(e,t,i,s,r){if(!("pluginId"in s))return this.base.applyCompletion(e,t,i,s,r);let o=e[t]??"",a=i-r.length,u=`${s.value} `,l=[...e];return l[t]=o.slice(0,a)+u+o.slice(i),{lines:l,cursorLine:t,cursorCol:a+u.length}}shouldAutoTriggerCompletion(e,t,i){return this.base.shouldAutoTriggerCompletion?.(e,t,i)}shouldTriggerFileCompletion(e,t,i){return this.base.shouldTriggerFileCompletion?.(e,t,i)??!1}};var t3=new Set(["help","changelog","context","status","usage","export","transcript","copy","parent","retry"]),n3=[{...nn.help,category:"Application",readiness:"immediate"},{...nn.new,aliases:["clear"],category:"Session",runAvailability:"idle"},{name:"update",description:"Check for and install an MCode update",category:"Application",discoverability:"search-only"},{name:"changelog",description:"Show the packaged MCode update history",category:"Application"},{name:"sessions",aliases:["resume"],description:"Search, resume, and manage sessions",category:"Session",argumentHint:"[query]",runAvailability:"idle"},{name:"goal",description:"Start or manage the current Session Goal",category:"Session",argumentHint:"<objective | action>",getArgumentCompletions:r1([["pause","Pause Goal auto-continuation"],["resume","Resume a paused or blocked Goal"],["edit","Edit the current Goal objective"],["clear","Remove the current Goal"],["help","Show Goal syntax and budget examples"],["budget=","Set token budget; enter a value such as 50K"],["budget=clear","Remove the Goal token budget"]])},{name:"plan",description:"Switch Plan Mode or view the latest Plan",category:"Session",argumentHint:"[on | off | status | view]",getArgumentCompletions:r1([["on","Enable Plan Mode"],["off","Return to default mode"],["status","Show the current Plan Mode"],["view","View the latest Plan"]]),shortcut:"Shift+Tab"},{name:"review",description:"Review staged, unstaged, and untracked local changes",category:"Capability"},{name:"parent",description:"Return from a sub-agent session to its parent",category:"Session",discoverability:"contextual",visibleWhen:n=>n.hasParentSession,unavailableReason:"The current Session has no parent."},{name:"btw",aliases:["side"],description:"Ask a side question without interrupting the running task",category:"Session",discoverability:"contextual",argumentHint:"[question]",visibleWhen:n=>n.hasSession,unavailableReason:"Open a Session before starting a side conversation."},{name:"history",description:ge("commandDescription","en"),category:"Session",discoverability:"contextual",visibleWhen:n=>n.hasSession,unavailableReason:ge("commandUnavailable","en")},{name:"fork",description:L("sessionMutation.command.fork.description","en"),category:"Session",discoverability:"contextual",runAvailability:"idle",visibleWhen:n=>n.hasSession,unavailableReason:L("sessionMutation.command.fork.unavailable","en")},{name:"rewind",description:L("sessionMutation.command.rewind.description","en"),category:"Session",discoverability:"contextual",runAvailability:"idle",visibleWhen:n=>n.hasSession,unavailableReason:L("sessionMutation.command.rewind.unavailable","en")},{name:"edit",description:L("sessionMutation.command.edit.description","en"),category:"Session",discoverability:"contextual",runAvailability:"idle",visibleWhen:n=>n.hasSession,unavailableReason:L("sessionMutation.command.edit.unavailable","en")},{name:"retry",description:"Resend the last message after a failed response",category:"Session",discoverability:"contextual",visibleWhen:n=>n.canRetry&&!n.hasLiveRun,unavailableReason:"There is no failed response to retry in this Session."},{name:"rename",description:"Rename the active session",category:"Session",discoverability:"contextual",visibleWhen:n=>n.hasSession,unavailableReason:"Start or resume a Session before renaming it.",argumentHint:"[title]",runAvailability:"idle"},{name:"archive",description:"Archive the active session",category:"Session",audience:"internal"},{...nn.compact,category:"Session",argumentHint:"[instructions]",discoverability:"contextual",runAvailability:"idle",visibleWhen:n=>n.hasSession,unavailableReason:"Start or resume a Session before compacting it."},{...nn.status,category:"Runtime",readiness:"controller",preparingHint:"Loading account status\u2026"},{name:"tasks",description:"Inspect background agents and Runtime tasks",category:"Runtime",discoverability:"contextual",visibleWhen:n=>n.hasSession,unavailableReason:"Start or resume a Session before opening background tasks."},{name:"permission",description:"Choose or inspect the Runtime permission mode",category:"Runtime",argumentHint:"[status | ask | auto | full]",getArgumentCompletions:r1([["status","Show the current permission mode"],["ask","Use Ask mode"],["auto","Use Auto mode"],["full","Use Full Access mode"]]),shortcut:"Alt+M"},{name:"login",description:"Sign in to use MiniMax Code Agent features",category:"Runtime",discoverability:"contextual",visibleWhen:n=>!n.managedTokenPresent},{name:"logout",description:"Sign out of the shared Desktop account",category:"Runtime",discoverability:"contextual",visibleWhen:n=>n.managedTokenPresent,unavailableReason:"No managed MiniMax account is signed in."},{...nn.doctor,category:"Runtime",discoverability:"search-only",readiness:"immediate",preparingHint:"Loading configuration check\u2026"},{name:"config",description:"Show the effective read-only configuration",category:"Runtime",audience:"internal"},{...nn.context,category:"Runtime",discoverability:"contextual",visibleWhen:n=>n.hasSession,unavailableReason:"Start or resume a Session before viewing context."},{name:"steer",description:"Steer current work without interrupting it",category:"Runtime",argumentHint:"<message>"},{name:"feedback",description:"Review and submit redacted product feedback",category:"Application",argumentHint:"<message>",discoverability:"search-only"},{name:"checkin",description:"Claim the daily MiniMax account reward",category:"Application",readiness:"controller",preparingHint:"Checking daily reward\u2026"},{name:"settings",description:"Configure the MCode terminal interface",category:"Application"},{name:"statusline",description:"Choose, reorder, and preview status line items",category:"Application",readiness:"immediate",visibleWhen:n=>!n.hasPendingInteraction,unavailableReason:"Finish the pending interaction before configuring the status line."},{name:"theme",description:"Choose the MCode color theme and terminal appearance",category:"Application",discoverability:"search-only",readiness:"immediate"},{name:"hotkeys",description:"View and customize TUI keyboard shortcuts",category:"Application",runAvailability:"idle",unavailableReason:"Stop the active Turn before opening TUI keyboard shortcuts."},{name:"reload",description:"Reload TUI configuration and Plugins",category:"Application",runAvailability:"idle",unavailableReason:"Stop the active Turn before reloading TUI configuration."},{...nn.model,category:"Runtime",argumentHint:"[filter]"},{name:"provider",description:"View providers and edit MiniMax credentials",category:"Runtime"},{name:"plugins",description:"Browse, install, enable, and remove Plugins",category:"Capability",argumentHint:"[filter]"},{...nn.skills,category:"Capability",argumentHint:"[filter]",discoverability:"search-only"},{...nn.mcp,category:"Capability",argumentHint:"[filter|reload]",discoverability:"search-only"},{name:"add-dir",description:"Add a readable and writable workspace directory",category:"Input",argumentHint:"<path>",discoverability:"search-only"},{name:"decision",description:"Reopen the pending action panel",category:"Decision",audience:"internal"},{...nn.usage,category:"Transcript",discoverability:"contextual"},{...nn.export,category:"Transcript",argumentHint:"[path.md]",discoverability:"contextual",visibleWhen:n=>n.hasSession,unavailableReason:"Start or resume a Session before exporting it."},{name:"transcript",description:"Browse, search, and inspect the full conversation",category:"Transcript",discoverability:"contextual",visibleWhen:n=>n.hasSession,unavailableReason:"Start or resume a Session before opening the Transcript."},{name:"copy",description:"Copy last response as Markdown",category:"Transcript",discoverability:"contextual",visibleWhen:n=>n.hasSession,unavailableReason:"Start or resume a Session before copying a response."},{name:"allow",description:"Allow the pending tool once",category:"Decision",audience:"internal",inputWhen:n=>n.hasPendingInteraction===!0},{name:"always",description:"Always allow this action class",category:"Decision",audience:"internal",inputWhen:n=>n.hasPendingInteraction===!0},{name:"deny",description:"Deny the pending tool",category:"Decision",audience:"internal",inputWhen:n=>n.hasPendingInteraction===!0},{name:"permissions",description:"Show pending Runtime-owned permission requests",category:"Decision",audience:"internal"},{name:"stop",description:"Interrupt the running turn",category:"Application",audience:"internal",readiness:"immediate"},{name:"queue",description:"Manage messages that run after the current response",category:"Input",discoverability:"contextual",visibleWhen:n=>n.queueEnabled&&(n.hasLiveRun||n.queuedCount>0),unavailableReason:"No messages are waiting and no response is currently running."},{name:"quit",aliases:["exit"],description:"Exit Minimax Code",category:"Application",readiness:"immediate"}],i3=[],s3={hasSession:!1,hasParentSession:!1,managedTokenPresent:!1,queueEnabled:!1,hasLiveRun:!1,queuedCount:0,canRetry:!1,sideMode:!1};function a1(n=[],e={},t=()=>s3){let i=new My;n3.forEach((c,h)=>i.register({id:`core/command/${c.name}`,order:h,source:c,execute:e[c.name]})),i3.forEach((c,h)=>i.register({id:`core/active-run/${c.name}`,order:h,kind:"active-run",source:c,execute:e[c.name]})),i.registerAll(n);let s=i.freeze(),r=new Set,o=s.filter(c=>(c.kind??"command")==="command").map(c=>i1(c.source,r)),a=s.filter(c=>c.kind==="active-run").map(c=>i1(c.source,r)),u=new Set(s.filter(c=>(c.kind??"command")==="command"&&!!c.execute).map(c=>c.source.name));return{commands:o,get inputCommands(){let c=t();return o.filter(h=>o1(h,c)&&(u.has(h.name)||h.inputWhen?.(c)===!0))},activeRunCommands:a,get discoverableCommands(){return s1(o,t(),"default")},get searchableCommands(){return s1(o,t(),"search")},get slashCommands(){return s1(o,t(),"default").map(({name:c,description:h,argumentHint:m,getArgumentCompletions:f})=>({name:c,description:h,...m?{argumentHint:m}:{},...f?{getArgumentCompletions:f}:{}}))},resolve:c=>{let h=gx(c,s);if(h)return[...o,...a].find(m=>m.name===h.command.name)},dispatch:async c=>{let h=gx(c,s);if(!h)return{status:"unrecognized"};let m=o.find(b=>b.name===h.command.name),f=t(),y=m??i1(h.contribution.source,new Set);if(y.audience!=="internal"&&!o1(y,f))return{status:"unavailable",reason:r3(y)};if(m&&m.audience!=="internal"&&!yx(m,f))return{status:"unavailable",reason:m.runAvailability==="idle"&&f.hasLiveRun?`Stop the running turn before using ${m.usage}.`:m.unavailableReason??`${m.usage} is unavailable right now.`};let T=await h.contribution.execute?.(h.command);return h.contribution.execute?{status:"handled",...T?{disposition:T}:{}}:{status:"unrecognized"}}}}function gx(n,e){let t=Fa(n,e.map(({source:s})=>s));if(!t)return;let i=e.find(({source:s})=>s===t.source);if(i)return{contribution:i,command:{raw:t.raw,name:i.source.name,args:t.args}}}function Fa(n,e){let t=n.trim(),i=t.split(/\s+/u,1)[0];if(!i||!i.startsWith("/")&&!i.startsWith("@"))return;let r=(i.startsWith("/")?i.slice(1):i).toLocaleLowerCase(),o=e.find(u=>[u.name,...u.aliases??[]].some(l=>l.toLocaleLowerCase()===r));if(!o)return;let a=t.slice(i.length).trim();if(!(a&&!o.argumentHint))return{source:o,raw:t,token:i,args:a}}function i1(n,e){let t=[n.name,...n.aliases??[]].map(s=>s.toLocaleLowerCase());for(let s of t){if(e.has(s))throw new Error(`Duplicate command name or alias: ${s}`);e.add(s)}let i=`/${n.name}${n.argumentHint?` ${n.argumentHint}`:""}`;return{...n,usage:i,composerTemplate:`/${n.name}${n.argumentHint?" ":""}`}}function $a(n){return n.audience!=="internal"}function s1(n,e,t){return n.filter(i=>!$a(i)||!yx(i,e)?!1:t==="search"||i.discoverability!=="search-only")}function o1(n,e){return e.sideMode?t3.has(n.name.toLocaleLowerCase()):!0}function r3(n){return n.name.toLocaleLowerCase()==="rename"?"Side conversations are ephemeral and cannot be renamed.":`${n.usage} is unavailable in side conversations. Press Ctrl+C to return to the main session first.`}function yx(n,e){return!o1(n,e)||n.runAvailability==="idle"&&e.hasLiveRun?!1:n.visibleWhen?.(e)??!0}var u1=a1(),Kc=u1.commands,Tx=u1.activeRunCommands,Wc=u1.discoverableCommands;function l1(n){let e=n.aliases?.join(", ");return e?`${n.usage} (${e})`:n.usage}function r1(n){let e=n.map(([t,i])=>({value:t,label:t,description:i}));return t=>{let i=t.trimStart();return/\s/u.test(i)?null:tr(e,i,s=>s.value)}}var jc=class{fullscreenViewport=!0;handlesViewportKeys=!0;commands;options;scrollTop=0;viewportRows=9;constructor(e){this.options=e,this.commands=o3(e.commands).filter($a).sort((t,i)=>t.name.localeCompare(i.name))}handleInput(e){let t=tt(e)??e;if(S(e,"escape")||S(e,"enter")||S(e,"ctrl+c")||t==="q"||t==="Q"){this.options.onCancel();return}if(S(e,"up")){this.scrollTop=Math.max(0,this.scrollTop-1);return}if(S(e,"down")){this.scrollTop+=1;return}if(S(e,"pageUp")){this.scrollTop=Math.max(0,this.scrollTop-this.pageStep());return}S(e,"pageDown")&&(this.scrollTop+=this.pageStep())}invalidate(){}render(e){return this.renderViewport(e,this.currentMaxRows()??1/0)}renderViewport(e,t){let i=ae(e,t,this.renderFooter()),s=this.renderContent(i.contentWidth),r=this.renderFooter({first:s.length,last:s.length,total:s.length}),o=ae(e,t,r),a=Math.max(1,o.bodyHeight);this.viewportRows=Number.isFinite(a)?a:s.length,this.scrollTop=Math.max(0,Math.min(this.scrollTop,Math.max(0,s.length-a)));let u=s.slice(this.scrollTop,this.scrollTop+a),l=s.length>a?{first:this.scrollTop+1,last:this.scrollTop+u.length,total:s.length}:void 0;return ae(e,t,this.renderFooter(l)).render({title:"Help",body:u})}renderContent(e){let t=this.options.queueEnabled??!0,s=[...(this.options.keybindings??si()).helpRows(t).map(a=>({keys:a.keys,description:a.description})),{keys:"Enter",description:t?"Send; while MCode works it sends next":"Send while idle"}],r=bx(this.commands.map(l1),e,12),o=bx(s.map(a=>a.keys),e,8);return[` ${p.bold.hex(d.text)("Keyboard shortcuts")}`,...s.map(a=>vx(a.keys,a.description,o,e,u=>p.hex(d.signal)(u))),"",` ${p.bold.hex(d.text)("Slash commands")}`,...this.commands.map(a=>{let u=l1(a);return vx(u,a.description,r,e,l=>p.hex(d.signal)(l))})]}renderFooter(e){let t=this.options.keybindings??si(),i=be("app.interrupt",t),s=i==="Esc"?"Esc close":`Esc close \xB7 ${i} to close`,r=e?`showing ${String(e.first)}-${String(e.last)} of ${String(e.total)}`:"",o=`\u2191\u2193 / ${be("interaction.scroll-up",t)} / ${be("interaction.scroll-down",t)} scroll`;return z([r,o,s].filter(Boolean).join(" \xB7 "))}pageStep(){return Math.max(1,this.viewportRows-1)}currentMaxRows(){let e=typeof this.options.maxRows=="function"?this.options.maxRows():this.options.maxRows;return e===void 0?void 0:Math.max(4,Math.floor(e))}};function bx(n,e,t){let i=Math.max(t,...n.map(r=>r.length)),s=Math.max(t,e-6);return Math.min(i,Math.max(t,Math.floor(s*.4)))}function vx(n,e,t,i,s){let r=E(n,t,"\u2026"),o=`${r}${" ".repeat(Math.max(0,t-r.length))}`;return E(` ${s(o)} ${p.hex(d.muted)(e)}`,i)}function o3(n){let e=new Set;return n.filter(t=>e.has(t.name)?!1:(e.add(t.name),!0))}function Vc(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function Sx(n){return ft(n)}function Gc(n){return Vc(n)?n.status===404||n.status===501||n.statusCode===404||n.statusCode===501||n.code==="NOT_IMPLEMENTED":!1}function Cx(n,e){return Vc(n)&&n.code===e}function c1(n,e){return e.aborted?Promise.resolve():new Promise(t=>{let i,s=()=>{i&&clearTimeout(i),e.removeEventListener("abort",s),t()};i=setTimeout(s,n),e.addEventListener("abort",s,{once:!0})})}function Qr(n){if(n==="default")return n;try{let e=new URL(n);return e.username="",e.password="",e.search="",e.hash="",C(e.toString().replace(/\/$/u,""))}catch{return C((n.split(/[?#]/u,1)[0]??n).replace(/\/\/[^/@\s]+@/gu,"//"))}}function Si(n){let e=n.thinkingConfig?.mode;if(e==="forced_on")return"on";if(e==="forced_off")return"off";if(e==="switchable")return n.variant==="thinking"?"on":n.variant===""?"off":n.thinkingConfig?.defaultValue==="true"?"on":"off"}function d1(n,e){return n.thinkingConfig?.mode!=="switchable"?n:{...n,variant:e==="on"?"thinking":""}}function wx(n,e,t){let i=Ys(n);if(i.length===0)return;let s=e?i.indexOf(e.trim()):-1,r=s>=0?s:Math.floor(i.length/2),o=Math.min(i.length-1,Math.max(0,r+t));return i[o]}function zc(n){if(!n)return;let e=h1(n.inputTokens),t=h1(n.cacheReadTokens),i=h1(n.cacheWriteTokens),s=e+t+i;if(!(s<=0))return{freshInputTokens:e,cacheReadTokens:t,cacheWriteTokens:i,promptTokens:s,cacheReadRatio:t/s}}function h1(n){return typeof n=="number"&&Number.isFinite(n)&&n>0?n:0}function p1(n,e={}){return Jc(Xc(n,e))}function Xc(n,e={}){let t=e.model,i=n?.status??"unknown",s=i==="needs-login"||n?.managedTokenPresent===!1,r=n?.identity?.email?.trim()||n?.identity?.name?.trim(),o=e.accountLoading?"Loading\u2026":s?n?.modelSource==="byok"?"Not signed in":"Sign in with /login":r?Qe(r):i==="ready"?"Connected with MiniMax":i==="warning"?"Connected with warnings":"MiniMax account unavailable",a=t?Dn(t,e.effort):void 0,u=t?`${Qe(t.providerId)}/${Qe(t.modelId)}${t.variant&&!a?`#${Qe(t.variant)}`:""}`:Je(n?.defaultModel??"not selected"),l=[{title:"Account",rows:[{label:"Account",value:o,tone:e.accountLoading?"neutral":s?"warning":b3(i)},{label:"Provider",value:Je(n?.providerId??"not configured")},{label:"Auth",value:Je(n?.authMode??"unknown")},...n?.tokenPlanSummary?.tier?[{label:"Plan",value:Qe(n.tokenPlanSummary.tier),tone:"accent"}]:[],...n?.modelSource?[{label:"Model source",value:n.modelSource==="byok"?"API key":"Token Plan"}]:[]]}];if(l.push({title:"Model",rows:[{label:"Model",value:u,tone:t?"accent":"neutral"},...a?[{label:"Think effort",value:a}]:[{label:"Thinking",value:a3(t)}],{label:"Source",value:t&&e.session?"session selection":"configured default"}]}),e.workspaceDir!==void 0){l.push({title:"Workspace",rows:[{label:"Directory",value:Qe(e.workspaceDir)},{label:"Branch",value:u3(e.workspaceGit)},{label:"Worktree",value:l3(e.workspaceGit)}]}),l.push({title:"Session",rows:[{label:"Session ID",value:Qe(e.session?.sessionId??"Not started")},{label:"Title",value:Qe(e.session?.title??"Untitled")}]}),l.push({title:"Permissions",rows:[{label:"Permissions",value:e.permissionMode?$n(e.permissionMode):"Unavailable",tone:e.permissionMode&&wu(e.permissionMode)?"warning":"neutral"}]});let h=e.planMode?.displayMode??e.session?.interactionMode??"default",m=e.session?.interactionMode==="plan"?"Plan":"Default",f=h==="plan"?"Plan":"Default";l.push({title:"Mode",rows:[{label:"Mode",value:e.planMode?.transition?`${m} \u2192 ${f} (${e.planMode.transition==="next-message"?"next message":"submitting"})`:f}]}),l.push({title:"Instructions",rows:e.instructionSources?.length?e.instructionSources.map(y=>({label:y.scope==="global"?"Global rules":"Project rules",value:Qe(y.path)})):[{label:"Instructions",value:e.instructionSources?"None":"Unavailable"}]})}let c=Ax(n).filter(h=>h.label!=="Video");return c.length>0&&l.push({title:"Quota",rows:c}),{title:`MCode status${e.version?` \xB7 v${Qe(e.version)}`:""}`,badge:e.accountLoading?{label:"Loading account\u2026",tone:"neutral"}:T3(i),sections:l,warnings:n?.warnings.map(Je),footer:"Current configuration \xB7 /usage for details",visualization:{kind:"status",...c.length?{quotaRows:c}:{}}}}function a3(n){if(!n)return"Unknown";let e=Si(n);return e===void 0?"Not configurable":e==="on"?"On":"Off"}function u3(n){return n?n.isGitRepo?n.detached?"Detached HEAD":Qe(n.branch||"Unborn branch"):"Not a Git repository":"Unavailable"}function l3(n){return n?n.isGitRepo?n.isWorktree?"Linked":"Primary checkout":"Not applicable":"Unavailable"}function c3(n,e){if(e)return[{label:"Plan",value:"Run /login to view plan and quota",tone:"warning"}];let t=n?.tokenPlanSummary;return n?.modelSource==="token-plan"||n?.tokenPlanQuotaState!==void 0||!!t?[{label:"Plan",value:Je(t?.tier??"Token Plan"),tone:"accent"},...t?.expiresAtMs?[{label:"Expires",value:p3(t.expiresAtMs)}]:[],...t?.creditBalance?[{label:"Credits",value:S3(t.creditBalance)}]:[]]:[]}function Ax(n){if(n?.tokenPlanQuotaState==="not-subscribed")return[{label:"Quota",value:"No Token Plan subscription",tone:"warning"}];let e=n?.tokenPlanQuota;return e?[{label:"5-hour",value:Ix(e.fiveHour),...e.fiveHour.unlimited?{}:xx(e.fiveHour.remainingPercent)},{label:"Weekly",value:Ix(e.weekly),...e.weekly.unlimited?{}:xx(e.weekly.remainingPercent)},...e.video?[{label:"Video",value:h3(e.video),...e.video.unlimited?{}:d3(e.video.remainingCount,e.video.totalCount)}]:[]]:n?.tokenPlanQuotaState==="unavailable"?[{label:"Quota",value:"Temporarily unavailable",tone:"warning"}]:[]}function xx(n){return typeof n=="number"&&Number.isFinite(n)?{remainingRatio:Math.min(1,Math.max(0,n/100))}:{}}function d3(n,e){return typeof n=="number"&&Number.isFinite(n)&&typeof e=="number"&&Number.isFinite(e)&&e>0?{remainingRatio:Math.min(1,Math.max(0,n/e))}:{}}function Ix(n){if(n.unlimited)return"Unlimited";let e=typeof n.remainingPercent=="number"?`${fn(n.remainingPercent)}% left`:"\u2014";return Ex(e,n.resetAtMs)}function h3(n){if(!n)return"\u2014";if(n.unlimited)return"Unlimited";let e=n.remainingCount===void 0?"\u2014":n.totalCount===void 0?`${fn(n.remainingCount)} left`:`${fn(n.remainingCount)}/${fn(n.totalCount)} left`;return Ex(e,n.resetAtMs)}function Ex(n,e){if(e===void 0||!Number.isFinite(e))return n;let t=e-Date.now();if(t<=0)return`${n} \xB7 reset pending`;let i=Math.ceil(t/6e4),s=i<60?`${i}m`:i<1440?`${Math.floor(i/60)}h ${i%60}m`:`${Math.floor(i/1440)}d ${Math.floor(i%1440/60)}h`;return`${n} \xB7 resets in ${s}`}function p3(n){return new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric"}).format(new Date(n))}function Mx(n){return Jc(m1(n))}function Rx(n){return Jc(f1(n))}function m1(n){let e=Je(n.status??"unknown"),t=v3(e),i=t==="success",s=n.warnings.map(Je);return{title:"Configuration check",badge:{label:i?"VALID":"ISSUES",tone:t},sections:[{title:"Config file",rows:[{label:"Status",value:i?"Valid":"Needs attention",tone:t},{label:"Path",value:Je(n.configPath??"unavailable")},{label:"File",value:Qc(n.configPresent)}]},...i?[{title:"Model",rows:[{label:"Default model",value:Je(n.defaultModel??"not configured")},{label:"Provider",value:Je(n.providerId??"unknown")}]}]:[],...s.length>0?[{title:"Issues",rows:s.map(r=>({label:"Issue",value:r,tone:t}))}]:[],...i?[]:[{title:"Impact",rows:[{label:"Current run",value:"MCode may use built-in defaults until the config is fixed and restarted.",tone:"warning"}]},{title:"Next step",rows:[{label:"Action",value:m3(n)}]}]],footer:"Read only \xB7 no files changed"}}function m3(n){let e=Je(n.configPath??"the config file");return n.warnings.some(t=>t.includes("does not exist"))?`Create or restore ${e}, restart MCode, then run /doctor again.`:n.warnings.some(t=>t.includes("cannot be read"))?`Check access to ${e}, restart MCode, then run /doctor again.`:n.warnings.some(t=>t.includes("defaultModel"))?`Set defaultModel in ${e} to an available provider/model, restart MCode, then run /doctor again.`:`Fix ${e}, restart MCode, then run /doctor again.`}function f1(n){return{title:"Effective configuration",badge:{label:"READ ONLY",tone:"accent"},sections:[{title:"Location",rows:[{label:"Source",value:Je(n.configPath??"Runtime default config")},{label:"Config file",value:Qc(n.configPresent)},{label:"Data directory",value:Je(n.dataDir??"unavailable")}]},{title:"Model",rows:[{label:"Default",value:Je(n.defaultModel??"not configured")},{label:"Provider",value:Je(n.providerId??"unknown")},{label:"Endpoint",value:Qr(n.providerBaseUrl??"default")}]},{title:"Credentials",rows:[{label:"Auth mode",value:Je(n.authMode??"unknown")},{label:"Auth source",value:Je(n.authModeSource??"unknown")},{label:"Provider API key",value:Qc(n.apiKeyPresent)},{label:"Managed credential",value:Qc(n.managedTokenPresent)},{label:"Custom providers",value:fn(n.customProviderCount??0)}]}],footer:"Credential values are hidden"}}function kx(n,e={}){let t=_x(n,e);return t?Jc({title:Lx(e),sections:[],visualization:t}):e.scope==="account"?"No account usage is available. Sign in with /login to view plan and quota.":"No usage has been recorded for this Session."}function Px(n,e={}){let t=_x(n,e);if(t)return{title:Lx(e),sections:[],visualization:t}}function _x(n,e){let t=n.summary,i=f3(e.account);if(!t&&i.length===0)return;let s=e.context?.contextUsage,r=s?Yc(s.contextWindowTokens)?s.contextWindowTokens:e.context?.model?.contextWindow:void 0,o=s&&Yc(r)?{usedTokens:s.usedTokens,windowTokens:r,utilization:s.usedTokens/r}:null,a=e.model?`${Qe(e.model.providerId)}/${Qe(e.model.modelId)}`:"Model unavailable",u=zc(t);return{kind:"usage",model:a,sessionRecorded:t!==void 0,inputTokens:t?.inputTokens??0,outputTokens:t?.outputTokens??0,totalTokens:t?.totalTokens??(t?y3(t):0),...u?{cacheMetrics:u}:{},context:o,...i.length>0?{accountRows:i}:{}}}function f3(n){if(!n)return[];let t=!(n.tokenPlanQuotaState!==void 0||n.tokenPlanSummary!==void 0||n.tokenPlanQuota!==void 0)&&(n.status==="needs-login"||n.managedTokenPresent===!1);return[...c3(n,t),...Ax(n)]}function Lx(n){return n.scope==="account"?"Account usage":"Session usage"}function Ox(n,e){if(n.status==="loading")return"Context is loading. Run /context again after the active Run starts.";let t=n.contextUsage;if(!t||n.status==="empty")return"No Runtime context snapshot is available for this Session yet.";let i=Yc(t.contextWindowTokens)?t.contextWindowTokens:n.model?.contextWindow,s=i===void 0?void 0:Math.max(0,i-t.usedTokens),r=i===void 0?void 0:Math.min(1,t.usedTokens/i),o=n.model?`${Qe(n.model.provider)}/${Qe(n.model.id)}`:e?`${Qe(e.providerId)}/${Qe(e.modelId)}`:"not selected";return[`Context \xB7 ${n.status==="stale"?"stale snapshot":"live snapshot"}`,`Budget: ${fn(t.usedTokens)} used \xB7 ${s===void 0?"unknown":`${fn(s)} remaining`} \xB7 ${r===void 0?"unknown":`${Math.round(r*100)}%`}`,`Model: ${o}`,`Compaction: ${n.compaction?.state??"never"}`,...t.components.length>0?["","Components:",...t.components.map(a=>`- ${$x(a.kind)}: ${fn(a.tokens)} tokens`)]:[],...n.status==="stale"?["","This snapshot belongs to the most recently completed Run."]:[]].join(`
|
|
205
|
+
`).trimStart().startsWith("!")||!this.plugins?.listInstalledPlugins)return this.base.getSuggestions(e,t,i,s);let[a,u]=await Promise.allSettled([this.base.getSuggestions(e,t,i,s),this.plugins.listInstalledPlugins()]);if(s.signal.aborted)return null;let l=a.status==="fulfilled"?a.value:null,c=o.slice(1).normalize("NFKC").toLocaleLowerCase(),h=u.status==="fulfilled"?u.value.filter(f=>f.installed&&f.enabled&&[f.name,f.displayName,f.pluginId].some(y=>y.normalize("NFKC").toLocaleLowerCase().includes(c))).sort((f,y)=>f.displayName.localeCompare(y.displayName)||f.pluginId.localeCompare(y.pluginId)).map(f=>{let y=C(f.displayName).replace(/[[\]\\]/gu," ").replace(/\s+/gu," ").trim().slice(0,256)||f.name;return{value:`@${y}`,label:`@${y}`,pluginId:f.pluginId,groupLabel:" Plugins",description:`${f.marketplace} \xB7 ${E(C(f.description??f.name).replace(/\s+/gu," ").trim(),64,"\u2026")}`}}):[],m=[...h,...(l?.items??[]).map(f=>({...f,...h.length>0?{groupLabel:" Files"}:{}}))];return m.length?{prefix:o,items:m}:null}applyCompletion(e,t,i,s,r){if(!("pluginId"in s))return this.base.applyCompletion(e,t,i,s,r);let o=e[t]??"",a=i-r.length,u=`${s.value} `,l=[...e];return l[t]=o.slice(0,a)+u+o.slice(i),{lines:l,cursorLine:t,cursorCol:a+u.length}}shouldAutoTriggerCompletion(e,t,i){return this.base.shouldAutoTriggerCompletion?.(e,t,i)}shouldTriggerFileCompletion(e,t,i){return this.base.shouldTriggerFileCompletion?.(e,t,i)??!1}};var t3=new Set(["help","changelog","context","status","usage","export","transcript","copy","parent","retry","doctor","feedback"]),n3=[{...nn.help,category:"Application",readiness:"immediate"},{...nn.new,aliases:["clear"],category:"Session",runAvailability:"idle"},{name:"update",description:"Check for and install an MCode update",category:"Application",discoverability:"search-only"},{name:"changelog",description:"Show the packaged MCode update history",category:"Application"},{name:"sessions",aliases:["resume"],description:"Search, resume, and manage sessions",category:"Session",argumentHint:"[query]",runAvailability:"idle"},{name:"goal",description:"Start or manage the current Session Goal",category:"Session",argumentHint:"<objective | action>",getArgumentCompletions:r1([["pause","Pause Goal auto-continuation"],["resume","Resume a paused or blocked Goal"],["edit","Edit the current Goal objective"],["clear","Remove the current Goal"],["help","Show Goal syntax and budget examples"],["budget=","Set token budget; enter a value such as 50K"],["budget=clear","Remove the Goal token budget"]])},{name:"plan",description:"Switch Plan Mode or view the latest Plan",category:"Session",argumentHint:"[on | off | status | view]",getArgumentCompletions:r1([["on","Enable Plan Mode"],["off","Return to default mode"],["status","Show the current Plan Mode"],["view","View the latest Plan"]]),shortcut:"Shift+Tab"},{name:"review",description:"Review staged, unstaged, and untracked local changes",category:"Capability"},{name:"parent",description:"Return from a sub-agent session to its parent",category:"Session",discoverability:"contextual",visibleWhen:n=>n.hasParentSession,unavailableReason:"The current Session has no parent."},{name:"btw",aliases:["side"],description:"Ask a side question without interrupting the running task",category:"Session",discoverability:"contextual",argumentHint:"[question]",visibleWhen:n=>n.hasSession,unavailableReason:"Open a Session before starting a side conversation."},{name:"history",description:ge("commandDescription","en"),category:"Session",discoverability:"contextual",visibleWhen:n=>n.hasSession,unavailableReason:ge("commandUnavailable","en")},{name:"fork",description:L("sessionMutation.command.fork.description","en"),category:"Session",discoverability:"contextual",runAvailability:"idle",visibleWhen:n=>n.hasSession,unavailableReason:L("sessionMutation.command.fork.unavailable","en")},{name:"rewind",description:L("sessionMutation.command.rewind.description","en"),category:"Session",discoverability:"contextual",runAvailability:"idle",visibleWhen:n=>n.hasSession,unavailableReason:L("sessionMutation.command.rewind.unavailable","en")},{name:"edit",description:L("sessionMutation.command.edit.description","en"),category:"Session",discoverability:"contextual",runAvailability:"idle",visibleWhen:n=>n.hasSession,unavailableReason:L("sessionMutation.command.edit.unavailable","en")},{name:"retry",description:"Resend the last message after a failed response",category:"Session",discoverability:"contextual",visibleWhen:n=>n.canRetry&&!n.hasLiveRun,unavailableReason:"There is no failed response to retry in this Session."},{name:"rename",description:"Rename the active session",category:"Session",discoverability:"contextual",visibleWhen:n=>n.hasSession,unavailableReason:"Start or resume a Session before renaming it.",argumentHint:"[title]",runAvailability:"idle"},{name:"archive",description:"Archive the active session",category:"Session",audience:"internal"},{...nn.compact,category:"Session",argumentHint:"[instructions]",discoverability:"contextual",runAvailability:"idle",visibleWhen:n=>n.hasSession,unavailableReason:"Start or resume a Session before compacting it."},{...nn.status,category:"Runtime",readiness:"controller",preparingHint:"Loading account status\u2026"},{name:"tasks",description:"Inspect background agents and Runtime tasks",category:"Runtime",discoverability:"contextual",visibleWhen:n=>n.hasSession,unavailableReason:"Start or resume a Session before opening background tasks."},{name:"permission",description:"Choose or inspect the Runtime permission mode",category:"Runtime",argumentHint:"[status | ask | auto | full]",getArgumentCompletions:r1([["status","Show the current permission mode"],["ask","Use Ask mode"],["auto","Use Auto mode"],["full","Use Full Access mode"]]),shortcut:"Alt+M"},{name:"login",description:"Sign in to use MiniMax Code Agent features",category:"Runtime",discoverability:"contextual",visibleWhen:n=>!n.managedTokenPresent},{name:"logout",description:"Sign out of the shared Desktop account",category:"Runtime",discoverability:"contextual",visibleWhen:n=>n.managedTokenPresent,unavailableReason:"No managed MiniMax account is signed in."},{...nn.doctor,category:"Runtime",discoverability:"search-only",readiness:"immediate",preparingHint:"Loading configuration check\u2026"},{name:"config",description:"Show the effective read-only configuration",category:"Runtime",audience:"internal"},{...nn.context,category:"Runtime",discoverability:"contextual",visibleWhen:n=>n.hasSession,unavailableReason:"Start or resume a Session before viewing context."},{name:"steer",description:"Steer current work without interrupting it",category:"Runtime",argumentHint:"<message>"},{name:"feedback",description:"Review and submit redacted product feedback",category:"Application",argumentHint:"<message>",discoverability:"search-only"},{name:"checkin",description:"Claim the daily MiniMax account reward",category:"Application",readiness:"controller",preparingHint:"Checking daily reward\u2026"},{name:"settings",description:"Configure the MCode terminal interface",category:"Application"},{name:"statusline",description:"Choose, reorder, and preview status line items",category:"Application",readiness:"immediate",visibleWhen:n=>!n.hasPendingInteraction,unavailableReason:"Finish the pending interaction before configuring the status line."},{name:"theme",description:"Choose the MCode color theme and terminal appearance",category:"Application",discoverability:"search-only",readiness:"immediate"},{name:"hotkeys",description:"View and customize TUI keyboard shortcuts",category:"Application",runAvailability:"idle",unavailableReason:"Stop the active Turn before opening TUI keyboard shortcuts."},{name:"reload",description:"Reload TUI configuration and Plugins",category:"Application",runAvailability:"idle",unavailableReason:"Stop the active Turn before reloading TUI configuration."},{...nn.model,category:"Runtime",argumentHint:"[filter]"},{name:"provider",description:"View providers and edit MiniMax credentials",category:"Runtime"},{name:"plugins",description:"Browse, install, enable, and remove Plugins",category:"Capability",argumentHint:"[filter]"},{...nn.skills,category:"Capability",argumentHint:"[filter]",discoverability:"search-only"},{...nn.mcp,category:"Capability",argumentHint:"[filter|reload]",discoverability:"search-only"},{name:"add-dir",description:"Add a readable and writable workspace directory",category:"Input",argumentHint:"<path>",discoverability:"search-only"},{name:"decision",description:"Reopen the pending action panel",category:"Decision",audience:"internal"},{...nn.usage,category:"Transcript",discoverability:"contextual"},{...nn.export,category:"Transcript",argumentHint:"[path.md]",discoverability:"contextual",visibleWhen:n=>n.hasSession,unavailableReason:"Start or resume a Session before exporting it."},{name:"transcript",description:"Browse, search, and inspect the full conversation",category:"Transcript",discoverability:"contextual",visibleWhen:n=>n.hasSession,unavailableReason:"Start or resume a Session before opening the Transcript."},{name:"copy",description:"Copy last response as Markdown",category:"Transcript",discoverability:"contextual",visibleWhen:n=>n.hasSession,unavailableReason:"Start or resume a Session before copying a response."},{name:"allow",description:"Allow the pending tool once",category:"Decision",audience:"internal",inputWhen:n=>n.hasPendingInteraction===!0},{name:"always",description:"Always allow this action class",category:"Decision",audience:"internal",inputWhen:n=>n.hasPendingInteraction===!0},{name:"deny",description:"Deny the pending tool",category:"Decision",audience:"internal",inputWhen:n=>n.hasPendingInteraction===!0},{name:"permissions",description:"Show pending Runtime-owned permission requests",category:"Decision",audience:"internal"},{name:"stop",description:"Interrupt the running turn",category:"Application",audience:"internal",readiness:"immediate"},{name:"queue",description:"Manage messages that run after the current response",category:"Input",discoverability:"contextual",visibleWhen:n=>n.queueEnabled&&(n.hasLiveRun||n.queuedCount>0),unavailableReason:"No messages are waiting and no response is currently running."},{name:"quit",aliases:["exit"],description:"Exit Minimax Code",category:"Application",readiness:"immediate"}],i3=[],s3={hasSession:!1,hasParentSession:!1,managedTokenPresent:!1,queueEnabled:!1,hasLiveRun:!1,queuedCount:0,canRetry:!1,sideMode:!1};function a1(n=[],e={},t=()=>s3){let i=new My;n3.forEach((c,h)=>i.register({id:`core/command/${c.name}`,order:h,source:c,execute:e[c.name]})),i3.forEach((c,h)=>i.register({id:`core/active-run/${c.name}`,order:h,kind:"active-run",source:c,execute:e[c.name]})),i.registerAll(n);let s=i.freeze(),r=new Set,o=s.filter(c=>(c.kind??"command")==="command").map(c=>i1(c.source,r)),a=s.filter(c=>c.kind==="active-run").map(c=>i1(c.source,r)),u=new Set(s.filter(c=>(c.kind??"command")==="command"&&!!c.execute).map(c=>c.source.name));return{commands:o,get inputCommands(){let c=t();return o.filter(h=>o1(h,c)&&(u.has(h.name)||h.inputWhen?.(c)===!0))},activeRunCommands:a,get discoverableCommands(){return s1(o,t(),"default")},get searchableCommands(){return s1(o,t(),"search")},get slashCommands(){return s1(o,t(),"default").map(({name:c,description:h,argumentHint:m,getArgumentCompletions:f})=>({name:c,description:h,...m?{argumentHint:m}:{},...f?{getArgumentCompletions:f}:{}}))},resolve:c=>{let h=gx(c,s);if(h)return[...o,...a].find(m=>m.name===h.command.name)},dispatch:async c=>{let h=gx(c,s);if(!h)return{status:"unrecognized"};let m=o.find(b=>b.name===h.command.name),f=t(),y=m??i1(h.contribution.source,new Set);if(y.audience!=="internal"&&!o1(y,f))return{status:"unavailable",reason:r3(y)};if(m&&m.audience!=="internal"&&!yx(m,f))return{status:"unavailable",reason:m.runAvailability==="idle"&&f.hasLiveRun?`Stop the running turn before using ${m.usage}.`:m.unavailableReason??`${m.usage} is unavailable right now.`};let T=await h.contribution.execute?.(h.command);return h.contribution.execute?{status:"handled",...T?{disposition:T}:{}}:{status:"unrecognized"}}}}function gx(n,e){let t=Fa(n,e.map(({source:s})=>s));if(!t)return;let i=e.find(({source:s})=>s===t.source);if(i)return{contribution:i,command:{raw:t.raw,name:i.source.name,args:t.args}}}function Fa(n,e){let t=n.trim(),i=t.split(/\s+/u,1)[0];if(!i||!i.startsWith("/")&&!i.startsWith("@"))return;let r=(i.startsWith("/")?i.slice(1):i).toLocaleLowerCase(),o=e.find(u=>[u.name,...u.aliases??[]].some(l=>l.toLocaleLowerCase()===r));if(!o)return;let a=t.slice(i.length).trim();if(!(a&&!o.argumentHint))return{source:o,raw:t,token:i,args:a}}function i1(n,e){let t=[n.name,...n.aliases??[]].map(s=>s.toLocaleLowerCase());for(let s of t){if(e.has(s))throw new Error(`Duplicate command name or alias: ${s}`);e.add(s)}let i=`/${n.name}${n.argumentHint?` ${n.argumentHint}`:""}`;return{...n,usage:i,composerTemplate:`/${n.name}${n.argumentHint?" ":""}`}}function $a(n){return n.audience!=="internal"}function s1(n,e,t){return n.filter(i=>!$a(i)||!yx(i,e)?!1:t==="search"||i.discoverability!=="search-only")}function o1(n,e){return e.sideMode?t3.has(n.name.toLocaleLowerCase()):!0}function r3(n){return n.name.toLocaleLowerCase()==="rename"?"Side conversations are ephemeral and cannot be renamed.":`${n.usage} is unavailable in side conversations. Press Ctrl+C to return to the main session first.`}function yx(n,e){return!o1(n,e)||n.runAvailability==="idle"&&e.hasLiveRun?!1:n.visibleWhen?.(e)??!0}var u1=a1(),Kc=u1.commands,Tx=u1.activeRunCommands,Wc=u1.discoverableCommands;function l1(n){let e=n.aliases?.join(", ");return e?`${n.usage} (${e})`:n.usage}function r1(n){let e=n.map(([t,i])=>({value:t,label:t,description:i}));return t=>{let i=t.trimStart();return/\s/u.test(i)?null:tr(e,i,s=>s.value)}}var jc=class{fullscreenViewport=!0;handlesViewportKeys=!0;commands;options;scrollTop=0;viewportRows=9;constructor(e){this.options=e,this.commands=o3(e.commands).filter($a).sort((t,i)=>t.name.localeCompare(i.name))}handleInput(e){let t=tt(e)??e;if(S(e,"escape")||S(e,"enter")||S(e,"ctrl+c")||t==="q"||t==="Q"){this.options.onCancel();return}if(S(e,"up")){this.scrollTop=Math.max(0,this.scrollTop-1);return}if(S(e,"down")){this.scrollTop+=1;return}if(S(e,"pageUp")){this.scrollTop=Math.max(0,this.scrollTop-this.pageStep());return}S(e,"pageDown")&&(this.scrollTop+=this.pageStep())}invalidate(){}render(e){return this.renderViewport(e,this.currentMaxRows()??1/0)}renderViewport(e,t){let i=ae(e,t,this.renderFooter()),s=this.renderContent(i.contentWidth),r=this.renderFooter({first:s.length,last:s.length,total:s.length}),o=ae(e,t,r),a=Math.max(1,o.bodyHeight);this.viewportRows=Number.isFinite(a)?a:s.length,this.scrollTop=Math.max(0,Math.min(this.scrollTop,Math.max(0,s.length-a)));let u=s.slice(this.scrollTop,this.scrollTop+a),l=s.length>a?{first:this.scrollTop+1,last:this.scrollTop+u.length,total:s.length}:void 0;return ae(e,t,this.renderFooter(l)).render({title:"Help",body:u})}renderContent(e){let t=this.options.queueEnabled??!0,s=[...(this.options.keybindings??si()).helpRows(t).map(a=>({keys:a.keys,description:a.description})),{keys:"Enter",description:t?"Send; while MCode works it sends next":"Send while idle"}],r=bx(this.commands.map(l1),e,12),o=bx(s.map(a=>a.keys),e,8);return[` ${p.bold.hex(d.text)("Keyboard shortcuts")}`,...s.map(a=>vx(a.keys,a.description,o,e,u=>p.hex(d.signal)(u))),"",` ${p.bold.hex(d.text)("Slash commands")}`,...this.commands.map(a=>{let u=l1(a);return vx(u,a.description,r,e,l=>p.hex(d.signal)(l))})]}renderFooter(e){let t=this.options.keybindings??si(),i=be("app.interrupt",t),s=i==="Esc"?"Esc close":`Esc close \xB7 ${i} to close`,r=e?`showing ${String(e.first)}-${String(e.last)} of ${String(e.total)}`:"",o=`\u2191\u2193 / ${be("interaction.scroll-up",t)} / ${be("interaction.scroll-down",t)} scroll`;return z([r,o,s].filter(Boolean).join(" \xB7 "))}pageStep(){return Math.max(1,this.viewportRows-1)}currentMaxRows(){let e=typeof this.options.maxRows=="function"?this.options.maxRows():this.options.maxRows;return e===void 0?void 0:Math.max(4,Math.floor(e))}};function bx(n,e,t){let i=Math.max(t,...n.map(r=>r.length)),s=Math.max(t,e-6);return Math.min(i,Math.max(t,Math.floor(s*.4)))}function vx(n,e,t,i,s){let r=E(n,t,"\u2026"),o=`${r}${" ".repeat(Math.max(0,t-r.length))}`;return E(` ${s(o)} ${p.hex(d.muted)(e)}`,i)}function o3(n){let e=new Set;return n.filter(t=>e.has(t.name)?!1:(e.add(t.name),!0))}function Vc(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function Sx(n){return ft(n)}function Gc(n){return Vc(n)?n.status===404||n.status===501||n.statusCode===404||n.statusCode===501||n.code==="NOT_IMPLEMENTED":!1}function Cx(n,e){return Vc(n)&&n.code===e}function c1(n,e){return e.aborted?Promise.resolve():new Promise(t=>{let i,s=()=>{i&&clearTimeout(i),e.removeEventListener("abort",s),t()};i=setTimeout(s,n),e.addEventListener("abort",s,{once:!0})})}function Qr(n){if(n==="default")return n;try{let e=new URL(n);return e.username="",e.password="",e.search="",e.hash="",C(e.toString().replace(/\/$/u,""))}catch{return C((n.split(/[?#]/u,1)[0]??n).replace(/\/\/[^/@\s]+@/gu,"//"))}}function Si(n){let e=n.thinkingConfig?.mode;if(e==="forced_on")return"on";if(e==="forced_off")return"off";if(e==="switchable")return n.variant==="thinking"?"on":n.variant===""?"off":n.thinkingConfig?.defaultValue==="true"?"on":"off"}function d1(n,e){return n.thinkingConfig?.mode!=="switchable"?n:{...n,variant:e==="on"?"thinking":""}}function wx(n,e,t){let i=Ys(n);if(i.length===0)return;let s=e?i.indexOf(e.trim()):-1,r=s>=0?s:Math.floor(i.length/2),o=Math.min(i.length-1,Math.max(0,r+t));return i[o]}function zc(n){if(!n)return;let e=h1(n.inputTokens),t=h1(n.cacheReadTokens),i=h1(n.cacheWriteTokens),s=e+t+i;if(!(s<=0))return{freshInputTokens:e,cacheReadTokens:t,cacheWriteTokens:i,promptTokens:s,cacheReadRatio:t/s}}function h1(n){return typeof n=="number"&&Number.isFinite(n)&&n>0?n:0}function p1(n,e={}){return Jc(Xc(n,e))}function Xc(n,e={}){let t=e.model,i=n?.status??"unknown",s=i==="needs-login"||n?.managedTokenPresent===!1,r=n?.identity?.email?.trim()||n?.identity?.name?.trim(),o=e.accountLoading?"Loading\u2026":s?n?.modelSource==="byok"?"Not signed in":"Sign in with /login":r?Qe(r):i==="ready"?"Connected with MiniMax":i==="warning"?"Connected with warnings":"MiniMax account unavailable",a=t?Dn(t,e.effort):void 0,u=t?`${Qe(t.providerId)}/${Qe(t.modelId)}${t.variant&&!a?`#${Qe(t.variant)}`:""}`:Je(n?.defaultModel??"not selected"),l=[{title:"Account",rows:[{label:"Account",value:o,tone:e.accountLoading?"neutral":s?"warning":b3(i)},{label:"Provider",value:Je(n?.providerId??"not configured")},{label:"Auth",value:Je(n?.authMode??"unknown")},...n?.tokenPlanSummary?.tier?[{label:"Plan",value:Qe(n.tokenPlanSummary.tier),tone:"accent"}]:[],...n?.modelSource?[{label:"Model source",value:n.modelSource==="byok"?"API key":"Token Plan"}]:[]]}];if(l.push({title:"Model",rows:[{label:"Model",value:u,tone:t?"accent":"neutral"},...a?[{label:"Think effort",value:a}]:[{label:"Thinking",value:a3(t)}],{label:"Source",value:t&&e.session?"session selection":"configured default"}]}),e.workspaceDir!==void 0){l.push({title:"Workspace",rows:[{label:"Directory",value:Qe(e.workspaceDir)},{label:"Branch",value:u3(e.workspaceGit)},{label:"Worktree",value:l3(e.workspaceGit)}]}),l.push({title:"Session",rows:[{label:"Session ID",value:Qe(e.session?.sessionId??"Not started")},{label:"Title",value:Qe(e.session?.title??"Untitled")}]}),l.push({title:"Permissions",rows:[{label:"Permissions",value:e.permissionMode?$n(e.permissionMode):"Unavailable",tone:e.permissionMode&&wu(e.permissionMode)?"warning":"neutral"}]});let h=e.planMode?.displayMode??e.session?.interactionMode??"default",m=e.session?.interactionMode==="plan"?"Plan":"Default",f=h==="plan"?"Plan":"Default";l.push({title:"Mode",rows:[{label:"Mode",value:e.planMode?.transition?`${m} \u2192 ${f} (${e.planMode.transition==="next-message"?"next message":"submitting"})`:f}]}),l.push({title:"Instructions",rows:e.instructionSources?.length?e.instructionSources.map(y=>({label:y.scope==="global"?"Global rules":"Project rules",value:Qe(y.path)})):[{label:"Instructions",value:e.instructionSources?"None":"Unavailable"}]})}let c=Ax(n).filter(h=>h.label!=="Video");return c.length>0&&l.push({title:"Quota",rows:c}),{title:`MCode status${e.version?` \xB7 v${Qe(e.version)}`:""}`,badge:e.accountLoading?{label:"Loading account\u2026",tone:"neutral"}:T3(i),sections:l,warnings:n?.warnings.map(Je),footer:"Current configuration \xB7 /usage for details",visualization:{kind:"status",...c.length?{quotaRows:c}:{}}}}function a3(n){if(!n)return"Unknown";let e=Si(n);return e===void 0?"Not configurable":e==="on"?"On":"Off"}function u3(n){return n?n.isGitRepo?n.detached?"Detached HEAD":Qe(n.branch||"Unborn branch"):"Not a Git repository":"Unavailable"}function l3(n){return n?n.isGitRepo?n.isWorktree?"Linked":"Primary checkout":"Not applicable":"Unavailable"}function c3(n,e){if(e)return[{label:"Plan",value:"Run /login to view plan and quota",tone:"warning"}];let t=n?.tokenPlanSummary;return n?.modelSource==="token-plan"||n?.tokenPlanQuotaState!==void 0||!!t?[{label:"Plan",value:Je(t?.tier??"Token Plan"),tone:"accent"},...t?.expiresAtMs?[{label:"Expires",value:p3(t.expiresAtMs)}]:[],...t?.creditBalance?[{label:"Credits",value:S3(t.creditBalance)}]:[]]:[]}function Ax(n){if(n?.tokenPlanQuotaState==="not-subscribed")return[{label:"Quota",value:"No Token Plan subscription",tone:"warning"}];let e=n?.tokenPlanQuota;return e?[{label:"5-hour",value:Ix(e.fiveHour),...e.fiveHour.unlimited?{}:xx(e.fiveHour.remainingPercent)},{label:"Weekly",value:Ix(e.weekly),...e.weekly.unlimited?{}:xx(e.weekly.remainingPercent)},...e.video?[{label:"Video",value:h3(e.video),...e.video.unlimited?{}:d3(e.video.remainingCount,e.video.totalCount)}]:[]]:n?.tokenPlanQuotaState==="unavailable"?[{label:"Quota",value:"Temporarily unavailable",tone:"warning"}]:[]}function xx(n){return typeof n=="number"&&Number.isFinite(n)?{remainingRatio:Math.min(1,Math.max(0,n/100))}:{}}function d3(n,e){return typeof n=="number"&&Number.isFinite(n)&&typeof e=="number"&&Number.isFinite(e)&&e>0?{remainingRatio:Math.min(1,Math.max(0,n/e))}:{}}function Ix(n){if(n.unlimited)return"Unlimited";let e=typeof n.remainingPercent=="number"?`${fn(n.remainingPercent)}% left`:"\u2014";return Ex(e,n.resetAtMs)}function h3(n){if(!n)return"\u2014";if(n.unlimited)return"Unlimited";let e=n.remainingCount===void 0?"\u2014":n.totalCount===void 0?`${fn(n.remainingCount)} left`:`${fn(n.remainingCount)}/${fn(n.totalCount)} left`;return Ex(e,n.resetAtMs)}function Ex(n,e){if(e===void 0||!Number.isFinite(e))return n;let t=e-Date.now();if(t<=0)return`${n} \xB7 reset pending`;let i=Math.ceil(t/6e4),s=i<60?`${i}m`:i<1440?`${Math.floor(i/60)}h ${i%60}m`:`${Math.floor(i/1440)}d ${Math.floor(i%1440/60)}h`;return`${n} \xB7 resets in ${s}`}function p3(n){return new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric"}).format(new Date(n))}function Mx(n){return Jc(m1(n))}function Rx(n){return Jc(f1(n))}function m1(n){let e=Je(n.status??"unknown"),t=v3(e),i=t==="success",s=n.warnings.map(Je);return{title:"Configuration check",badge:{label:i?"VALID":"ISSUES",tone:t},sections:[{title:"Config file",rows:[{label:"Status",value:i?"Valid":"Needs attention",tone:t},{label:"Path",value:Je(n.configPath??"unavailable")},{label:"File",value:Qc(n.configPresent)}]},...i?[{title:"Model",rows:[{label:"Default model",value:Je(n.defaultModel??"not configured")},{label:"Provider",value:Je(n.providerId??"unknown")}]}]:[],...s.length>0?[{title:"Issues",rows:s.map(r=>({label:"Issue",value:r,tone:t}))}]:[],...i?[]:[{title:"Impact",rows:[{label:"Current run",value:"MCode may use built-in defaults until the config is fixed and restarted.",tone:"warning"}]},{title:"Next step",rows:[{label:"Action",value:m3(n)}]}]],footer:"Read only \xB7 no files changed"}}function m3(n){let e=Je(n.configPath??"the config file");return n.warnings.some(t=>t.includes("does not exist"))?`Create or restore ${e}, restart MCode, then run /doctor again.`:n.warnings.some(t=>t.includes("cannot be read"))?`Check access to ${e}, restart MCode, then run /doctor again.`:n.warnings.some(t=>t.includes("defaultModel"))?`Set defaultModel in ${e} to an available provider/model, restart MCode, then run /doctor again.`:`Fix ${e}, restart MCode, then run /doctor again.`}function f1(n){return{title:"Effective configuration",badge:{label:"READ ONLY",tone:"accent"},sections:[{title:"Location",rows:[{label:"Source",value:Je(n.configPath??"Runtime default config")},{label:"Config file",value:Qc(n.configPresent)},{label:"Data directory",value:Je(n.dataDir??"unavailable")}]},{title:"Model",rows:[{label:"Default",value:Je(n.defaultModel??"not configured")},{label:"Provider",value:Je(n.providerId??"unknown")},{label:"Endpoint",value:Qr(n.providerBaseUrl??"default")}]},{title:"Credentials",rows:[{label:"Auth mode",value:Je(n.authMode??"unknown")},{label:"Auth source",value:Je(n.authModeSource??"unknown")},{label:"Provider API key",value:Qc(n.apiKeyPresent)},{label:"Managed credential",value:Qc(n.managedTokenPresent)},{label:"Custom providers",value:fn(n.customProviderCount??0)}]}],footer:"Credential values are hidden"}}function kx(n,e={}){let t=_x(n,e);return t?Jc({title:Lx(e),sections:[],visualization:t}):e.scope==="account"?"No account usage is available. Sign in with /login to view plan and quota.":"No usage has been recorded for this Session."}function Px(n,e={}){let t=_x(n,e);if(t)return{title:Lx(e),sections:[],visualization:t}}function _x(n,e){let t=n.summary,i=f3(e.account);if(!t&&i.length===0)return;let s=e.context?.contextUsage,r=s?Yc(s.contextWindowTokens)?s.contextWindowTokens:e.context?.model?.contextWindow:void 0,o=s&&Yc(r)?{usedTokens:s.usedTokens,windowTokens:r,utilization:s.usedTokens/r}:null,a=e.model?`${Qe(e.model.providerId)}/${Qe(e.model.modelId)}`:"Model unavailable",u=zc(t);return{kind:"usage",model:a,sessionRecorded:t!==void 0,inputTokens:t?.inputTokens??0,outputTokens:t?.outputTokens??0,totalTokens:t?.totalTokens??(t?y3(t):0),...u?{cacheMetrics:u}:{},context:o,...i.length>0?{accountRows:i}:{}}}function f3(n){if(!n)return[];let t=!(n.tokenPlanQuotaState!==void 0||n.tokenPlanSummary!==void 0||n.tokenPlanQuota!==void 0)&&(n.status==="needs-login"||n.managedTokenPresent===!1);return[...c3(n,t),...Ax(n)]}function Lx(n){return n.scope==="account"?"Account usage":"Session usage"}function Ox(n,e){if(n.status==="loading")return"Context is loading. Run /context again after the active Run starts.";let t=n.contextUsage;if(!t||n.status==="empty")return"No Runtime context snapshot is available for this Session yet.";let i=Yc(t.contextWindowTokens)?t.contextWindowTokens:n.model?.contextWindow,s=i===void 0?void 0:Math.max(0,i-t.usedTokens),r=i===void 0?void 0:Math.min(1,t.usedTokens/i),o=n.model?`${Qe(n.model.provider)}/${Qe(n.model.id)}`:e?`${Qe(e.providerId)}/${Qe(e.modelId)}`:"not selected";return[`Context \xB7 ${n.status==="stale"?"stale snapshot":"live snapshot"}`,`Budget: ${fn(t.usedTokens)} used \xB7 ${s===void 0?"unknown":`${fn(s)} remaining`} \xB7 ${r===void 0?"unknown":`${Math.round(r*100)}%`}`,`Model: ${o}`,`Compaction: ${n.compaction?.state??"never"}`,...t.components.length>0?["","Components:",...t.components.map(a=>`- ${$x(a.kind)}: ${fn(a.tokens)} tokens`)]:[],...n.status==="stale"?["","This snapshot belongs to the most recently completed Run."]:[]].join(`
|
|
206
206
|
`)}function Nx(n){let e=n.contextUsage;if(!e||n.status==="loading"||n.status==="empty")return;let t=Yc(e.contextWindowTokens)?e.contextWindowTokens:n.model?.contextWindow,i=t===void 0?void 0:Math.max(0,t-e.usedTokens),s=t===void 0?void 0:Math.min(1,e.usedTokens/t),r=n.status==="stale",o={kind:"context",model:n.model?`${Qe(n.model.provider)}/${Qe(n.model.id)}`:"not selected",snapshotState:r?"stale":"live",usedTokens:e.usedTokens,remainingTokens:i??null,contextWindow:t??null,utilization:s??null,basis:e.totalCountSource==="PROVIDER_USAGE_ANCHORED"?"provider-usage":"runtime-estimate",compaction:n.compaction?.state??"never",compactionThresholdTokens:null,components:e.components};return{title:"Context",badge:{label:r?"STALE":"LIVE",tone:r?"warning":"success"},sections:[{title:"Runtime",rows:[{label:"Model",value:n.model?`${Qe(n.model.provider)}/${Qe(n.model.id)}`:"not selected"},{label:"Compaction",value:n.compaction?.state??"never"},{label:"Snapshot",value:r?"Most recently completed Run":"Current context"}]},{title:"Budget",rows:[{label:"Used",value:fn(e.usedTokens),tone:"accent"},{label:"Remaining",value:i===void 0?"unknown":fn(i)},{label:"Utilization",value:s===void 0?"unknown":`${Math.round(s*100)}%`},{label:"Window",value:t===void 0?"unknown":fn(t)}]},...e.components.length>0?[{title:"Components",rows:e.components.map(a=>({label:$x(a.kind),value:fn(a.tokens)}))}]:[]],footer:e.totalCountSource==="PROVIDER_USAGE_ANCHORED"?"Provider usage anchored \xB7 contents redacted":"Runtime estimate \xB7 contents redacted",visualization:o}}var g3=new Set(["MCP server transport is incomplete. Configure a command or URL and retry.","MCP connection support is unavailable in this Runtime.","MCP server connection failed. Retry or check its configuration.","MCP server connection timed out. Retry or check its configuration."]);function Dx(n){if(!n)return{};try{let e=JSON.parse(n),t=e.status==="available"||e.status==="configured"||e.status==="disabled"||e.status==="error"||e.status==="unavailable"?e.status:void 0,i=typeof e.error=="string"?e.error:void 0;return{...t?{status:t}:{},...i&&g3.has(i)?{error:i}:t==="error"||t==="unavailable"?{error:"MCP server is unavailable. Retry or check its configuration."}:{}}}catch{return{}}}function Fx(n){return n.length===0?["No pending permission requests.","Permission policy remains owned by Runtime."].join(`
|
|
207
207
|
`):[`Pending permissions \xB7 ${n.length}`,...n.map((e,t)=>{let i=e.toolDescription??e.reason??"Awaiting a decision";return`${t+1}. ${Je(e.toolName??"tool")} \xB7 ${Je(i)}`}),"","Choose an action above to continue."].join(`
|
|
208
208
|
`)}function y3(n){return(n.inputTokens??0)+(n.outputTokens??0)+(n.reasoningTokens??0)}function Jc(n){let e=[n.title];for(let t of n.sections)for(let i of t.rows)e.push(`${i.label}: ${i.value}`);return n.warnings?.length&&e.push("","Warnings:",...n.warnings.map(t=>`- ${t}`)),n.footer&&e.push("",n.footer),e.join(`
|
|
@@ -27,4 +27,4 @@ Expecting one of '${i.join("', '")}'`);let n=`${e}Help`;return this.on(n,r=>{let
|
|
|
27
27
|
`),n="natural"},runPlugin:async(s,l)=>{let a=o.runPlugin??at;e.stdout.write(`${await a(s,w,l)}
|
|
28
28
|
`),n="natural"}}).parseAsync(e.argv,{from:"node"}),n){let s=typeof e.exitCode=="number"?e.exitCode:0;await Promise.all([Ee(e.stdout,o.outputDrainTimeoutMs??xe),Ee(e.stderr,o.outputDrainTimeoutMs??xe)]),(o.platform??process.platform)==="win32"&&n==="natural"?e.exitCode=s:e.exit(s)}}catch(r){e.stderr.write(`${await Ze(r)}
|
|
29
29
|
`),e.exitCode=1}}async function Ze(o){let e=Q(o);if(!/better[-_]sqlite3/iu.test(e)||!/Could not locate the bindings file|Cannot find (?:module|package)|NODE_MODULE_VERSION|Module did not self-register/iu.test(e))return e;let{buildMcodePackageManagerCommand:t}=await import("./install-source-KWOIXLTZ.js");return["MCode could not load its native SQLite dependency.","If npm reported blocked install scripts, the installation needs explicit script approval.","Reinstall with the original installer. For npm installations, run:",` ${t("npm-global",w).display} --foreground-scripts`,"",`Original error: ${e}`].join(`
|
|
30
|
-
`)}function Ee(o,e){return o.destroyed||o.writableEnded?Promise.resolve():new Promise(t=>{let i=!1,n,r=()=>s(!0),s=(l=!1)=>{i||(i=!0,n&&clearTimeout(n),l||o.off?.("error",r),t())};n=setTimeout(s,e),n.unref?.(),o.once?.("error",r);try{o.write("",l=>s(!!l))}catch{s()}})}async function et(o){let{launchTui:e}=await import("./launcher-
|
|
30
|
+
`)}function Ee(o,e){return o.destroyed||o.writableEnded?Promise.resolve():new Promise(t=>{let i=!1,n,r=()=>s(!0),s=(l=!1)=>{i||(i=!0,n&&clearTimeout(n),l||o.off?.("error",r),t())};n=setTimeout(s,e),n.unref?.(),o.once?.("error",r);try{o.write("",l=>s(!!l))}catch{s()}})}async function et(o){let{launchTui:e}=await import("./launcher-Z2CKZB4R.js");await e(o)}async function tt(o,e,t){let{runTuiExecCommand:i}=await import("./run-exec-command-NWUGZRC4.js");await i(o,e,t)}async function it(o,e){let{runTuiAcpCommand:t}=await import("./run-acp-command-MUUZAUTS.js");await t(o,{},e)}async function nt(o,e=!0,t){let{runTuiLogin:i}=await import("./auth-command-7CDRKDVD.js");return i({region:o,openBrowser:e,lane:t})}async function rt(o){let{runTuiLogout:e}=await import("./auth-command-7CDRKDVD.js");return e({region:o})}async function ot(o){let{runMcodeUpdate:e}=await import("./update-XSUZQSPB.js");await e(o)}async function st(o,e,t){let{runMcodeProviderCommand:i}=await import("./provider-command-GJYV7UUM.js");return i({request:o,version:e,lane:t})}async function at(o,e,t){let{runMcodePluginCommand:i}=await import("./plugin-command-YRAYZBNS.js");return i({request:o,version:e,lane:t})}export{Ee as drainTuiOutput,jt as runTuiCli};
|
package/cli.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
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;
|
|
3
3
|
import{g as s}from"./chunks/chunk-WJZDMLYV.js";import{u as n,v as a}from"./chunks/chunk-22LFXEGJ.js";import"./chunks/chunk-HQ2U4QVQ.js";import{n as o,p as i}from"./chunks/chunk-UNHOACX2.js";import"./chunks/chunk-XYED4XTT.js";import"./chunks/chunk-Z4VKGZFA.js";import"./chunks/chunk-CWWDVX6C.js";import"./chunks/chunk-ZITT4GJK.js";import"./chunks/chunk-D76SO2ME.js";import{fileURLToPath as u}from"node:url";async function l(){let c=n(u(__mavis_tuiPackageEntryUrl)),t=a(c),r;try{r=i(process.argv.slice(2),t)}catch(e){process.stderr.write(`${e instanceof Error?e.message:String(e)}
|
|
4
|
-
`),process.exitCode=1;return}let{getTuiDataDirPath:m}=await import("./chunks/data-dir-3FQYZA5W.js");o({dataDir:m(),...r?{startupBuildEnvironment:r}:{}});let p=await s();try{let{runTuiCli:e}=await import("./chunks/main-
|
|
4
|
+
`),process.exitCode=1;return}let{getTuiDataDirPath:m}=await import("./chunks/data-dir-3FQYZA5W.js");o({dataDir:m(),...r?{startupBuildEnvironment:r}:{}});let p=await s();try{let{runTuiCli:e}=await import("./chunks/main-2G4XWJUW.js");await e({allowStartupEnvironmentSelection:t})}finally{p.remove()}}await l();
|