@minimax-ai/code 0.6.8 → 0.6.10
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 +22 -0
- package/CHANGELOG.zh-CN.md +22 -0
- package/README.md +88 -20
- package/README.zh-CN.md +24 -9
- package/assets/agents/_default/prompt-base-windows.md +0 -1
- package/assets/agents/_default/prompt-base-windows.md.hbs +0 -1
- package/assets/agents/mavis/skills/control-in-app-browser/SKILL.md +66 -1
- package/chunks/{auth-command-VRPOVPAG.js → auth-command-YIBIYLYL.js} +1 -1
- package/chunks/chunk-2BNOPHYG.js +9 -0
- package/chunks/{chunk-TJWBPT2F.js → chunk-2LP3AAE5.js} +1 -1
- package/chunks/chunk-52LBQEEC.js +2 -0
- package/chunks/{chunk-G7Q4HUMC.js → chunk-5JU6ZMXS.js} +1 -1
- package/chunks/{chunk-TBUCWZJV.js → chunk-72PMKZ7Y.js} +1 -1
- package/chunks/{chunk-RCKQIK7B.js → chunk-CRTW4JM6.js} +1 -1
- package/chunks/{chunk-HTUJPI64.js → chunk-F5767MLW.js} +1030 -715
- package/chunks/{chunk-3LM4G7WV.js → chunk-FPCUX6KP.js} +1 -1
- package/chunks/{chunk-VRCVX3OX.js → chunk-G7FSWJID.js} +58 -58
- package/chunks/{chunk-W2YPWDHA.js → chunk-GZAO7QYD.js} +684 -682
- package/chunks/{chunk-WROGTDVD.js → chunk-MESLFKP6.js} +1 -1
- package/chunks/{chunk-F5BJTVSP.js → chunk-UQ2YIDWV.js} +1 -1
- package/chunks/{data-dir-5RSS75A3.js → data-dir-AVW455BT.js} +1 -1
- package/chunks/{dist-VUHPFVW3.js → dist-B52TV5OC.js} +1 -1
- package/chunks/{launcher-UXZG5P2R.js → launcher-AFCZTEJU.js} +147 -146
- package/chunks/{lifecycle-LWEBNCGO.js → lifecycle-RBCNKJ7Z.js} +1 -1
- package/chunks/{main-ZF4GAXGG.js → main-SSCI3MRX.js} +2 -2
- package/chunks/{plugin-command-DE7EI72Q.js → plugin-command-ZQV7YMWK.js} +1 -1
- package/chunks/{provider-command-WEUFNCBJ.js → provider-command-UMQZDUGQ.js} +1 -1
- package/chunks/{run-acp-command-RJGV3PNR.js → run-acp-command-YUXNSZ3D.js} +2 -2
- package/chunks/{run-exec-command-LDQWWWXK.js → run-exec-command-HAIRHPYT.js} +13 -13
- package/cli.js +2 -2
- package/package.json +1 -1
- package/chunks/chunk-CF3YFDG4.js +0 -2
- package/chunks/chunk-K7X2ELVZ.js +0 -9
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __mavis_cR } from "module"; import { basename as __mavis_basename, dirname as __mavis_dirname, join as __mavis_join } from "path"; import { fileURLToPath as __mavis_fileURLToPath, pathToFileURL as __mavis_pathToFileURL } from "url"; const __mavis_tuiCurrentModuleDir = __mavis_dirname(__mavis_fileURLToPath(import.meta.url)); const __mavis_tuiPackageRoot = __mavis_basename(__mavis_tuiCurrentModuleDir) === "chunks" ? __mavis_dirname(__mavis_tuiCurrentModuleDir) : __mavis_tuiCurrentModuleDir; const __mavis_tuiPackageEntryUrl = __mavis_pathToFileURL(__mavis_join(__mavis_tuiPackageRoot, "cli.js")).href; const require = __mavis_cR(__mavis_tuiPackageEntryUrl); const __dirname = __mavis_tuiPackageRoot;
|
|
2
|
-
import{q as O}from"./chunk-K7X2ELVZ.js";import{a as p}from"./chunk-PRXIML4F.js";var b=["totalTokens","inputTokens","outputTokens","reasoningTokens","cacheReadTokens","cacheWriteTokens"];function v(e,t){return e.role==="assistant"&&(e.turnId===void 0||e.turnId===t)&&e.kind?.startsWith("compaction")===!0}function L(e,t){if(e.role!=="assistant"||e.turnId!==void 0&&e.turnId!==t||v(e,t))return;let i=Object.fromEntries(b.flatMap(r=>T(e.usage?.[r])?[[r,e.usage?.[r]]]:[])),n=b.some(r=>e.usage?.[r]!==void 0&&!T(e.usage?.[r]));return{...e.id?.trim()?{messageId:e.id}:{},...Object.keys(i).length?{usage:i}:{},...n?{usageIncomplete:!0}:{}}}function N(e,t){let i=t.messageId?e.findIndex(r=>r.messageId===t.messageId):-1,n=e[i];if(!n){e.push(t);return}e[i]={...n,...t,...n.usage||t.usage?{usage:{...n.usage,...t.usage}}:{}}}function Q(e){let t=e.length===0||e.some(n=>!T(n.usage?.inputTokens)||!T(n.usage?.outputTokens)||n.usageIncomplete),i=Object.fromEntries(b.flatMap(n=>{let r=e.map(a=>a.usage?.[n]).filter(T);if(!r.length)return[];let o=r.reduce((a,c)=>a+c,0);return Number.isFinite(o)?[[n,o]]:(t=!0,[])}));return{...Object.keys(i).length?{usage:i}:{},usageIncomplete:t}}function T(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}function D(e,t){let i=e.type==="message"?e.message.turnId:e.turnId;return i&&i!==t?!1:(e.type==="message"?e.message.toolCalls:e.type==="delta"?e.toolCalls:void 0)?.some(r=>{if(r.error||r.status!==2&&r.status!=="2"&&r.status!=="finished"||!r.output||typeof r.output!="object"||Array.isArray(r.output))return!1;let o=r.output.details;return typeof o=="object"&&o!==null&&!Array.isArray(o)&&o.waiting_for_user===!0})??!1}async function F(e,t,i,n=O,r){let o=await e.getPendingQuestionnaire?.(n,t,r);return o?.requester?.sessionId===t&&o.requester.runId===i?o:void 0}var $=1e3,j=class{constructor(t,i={}){this.runtime=t;this.options=i;this.nowMs=i.nowMs??Date.now}activeRun;retiringRun;nowMs;activeTurnId(){return this.activeRun?.turnId}detachActiveRun(t){let i=this.activeRun;return!i||t!==void 0&&i.turnId!==t?!1:(this.activeRun=void 0,!0)}retiringTurnId(){return this.retiringRun?.turnId}retirement(){return this.retiringRun?.settlement}async*sendWithQueueRecovery(t,i,n,r){let o=V(t,i,r),a=!1;try{for await(let c of this.runtime.sendMessage(o,n))a=!0,yield c}catch(c){if(a||r!==void 0||!(c instanceof p)||c.code!=="local_session_queue_paused"||!t.onQueuePaused||n.aborted)throw c;let d=await t.onQueuePaused(i.sessionId,n);if(n.throwIfAborted(),d==="cancel")throw new p("cancelled","The draft was kept.",{code:"PAUSED_QUEUE_SEND_CANCELLED"});yield*this.runtime.sendMessage(o,n,{pausedQueueAction:d==="paused-queue-clear"?"clear":"keep"})}}async execute(t,i=()=>{},n,r){if(this.activeRun)throw new Error("A run is already active.");if(this.retiringRun)throw new Error("The previous run is still stopping.");let o=te(t.turnId);this.activeRun=o;let a=this.nowMs(),c,d,w=!1,u="succeeded",m=null,g="",l,E=0,y=[],P=!1,_=!1;try{if(d=await ne(t.session,o.controller.signal),!d)throw o.controller.signal.reason??new Error("Turn cancelled before Session setup.");o.sessionId=d.sessionId;let f;t.policy?.timeoutMs!==void 0&&(f=this.nowMs()+t.policy.timeoutMs,c=setTimeout(()=>{this.stopActive(o,"timeout").catch(()=>{})},t.policy.timeoutMs),c.unref?.());let M=this.sendWithQueueRecovery(t,d,o.controller.signal,f)[Symbol.asyncIterator]();try{for(;;){let k=await M.next();if(k.done)break;let s=k.value;_||=D(s,t.turnId),w||(w=!0,n?.());let C=J(s);if(C){u="awaiting-user-continuation",l=C,await G(i,s);break}if(H(s)){P||=v(s.message,t.turnId);let U=L(s.message,t.turnId);if(U&&N(y,U),t.policy?.maxSteps!==void 0&&E>=t.policy.maxSteps){u="limit_exceeded",await this.stopActive(o,"limit");break}if(E+=1,s.message.toolCalls?.length)this.reportAnswerSelection({kind:"answer_excluded",messageId:s.message.id,reason:"tool_calls"}),m=null,g="";else{let A=s.message.content?.trim()?s.message.content:g;m=A.trim()?A:null,this.reportAnswerSelection({kind:"answer_selected",messageId:s.message.id,answerSource:s.message.content?.trim()?"completed_message":"completed_message_draft",answerBytes:Buffer.byteLength(A),finishReason:s.message.finishReason}),g=""}}else K(s)&&(g+=s.content);let h=Z(s);h&&(u=h.status,l=h.error),await G(i,s)}}finally{await M.return?.(void 0)}g.trim()&&(this.reportAnswerSelection({kind:"answer_selected",answerSource:"trailing_draft",answerBytes:Buffer.byteLength(g),replacedAnswer:m!==null}),m=g),u==="succeeded"&&!o.controller.signal.aborted&&(_||await F(this.runtime,d.sessionId,t.turnId,d.agentName,o.controller.signal))&&(u="awaiting-user-continuation",m=null,l=W()),t.policy?.requireAnswer===!0&&u==="succeeded"&&m===null&&(u="failed",l={category:"runtime",code:"EMPTY_RESPONSE",message:"Runtime completed without a final assistant response.",retryable:!0}),u=B(o.stopReason,u)}catch(f){o.stopReason||o.controller.signal.aborted?u=B(o.stopReason,"cancelled"):(u="failed",l=ee(f))}finally{c&&clearTimeout(c),this.activeRun===o&&(this.activeRun=void 0)}let{usage:x}=Q(y),R={sessionId:d?.sessionId??"",turnId:t.turnId,status:u,answer:m,...t.model?{model:{...t.model}}:{},...x?{usage:x}:{},...y.length?{usageResponses:y}:{},...P?{usageIncomplete:!0}:{},...l?{error:l}:{},durationMs:Math.max(0,this.nowMs()-a)};if(r)try{await r(R)}catch{u="failed";let f={category:"internal",code:"AUTOMATION_RESULT_WRITE_FAILED",message:"Could not publish the TUI automation result.",retryable:!0};l=f,R={...R,status:u,error:f}}return o.resolveSettled(),{turnId:t.turnId,...d?{session:d}:{},status:u,outcome:R,...l?.message?{error:l.message}:{}}}async abort(){let t=this.activeRun;return t?(t.abortPromise??=this.stopAndSettle(t),t.abortPromise):!1}reportAnswerSelection(t){try{this.options.onAnswerSelection?.(t)}catch{}}async stopAndSettle(t){let i=await this.stopActive(t,"user_stop"),n=t.settled.then(()=>i),r=await ie(n,this.options.cancellationSettlementTimeoutMs??$);if(this.activeRun===t&&(this.activeRun=void 0),r.settled)return r.value;let o={turnId:t.turnId,settlement:n};return o.settlement=n.finally(()=>{this.retiringRun===o&&(this.retiringRun=void 0)}),this.retiringRun=o,i}async stopActive(t,i){t.stopReason??=i;let n=t.sessionId,r=n?this.runtime.abortSession({id:n,turnId:t.turnId,reason:i==="limit"?"max_steps":i}).catch(()=>!1):Promise.resolve(!0);return t.controller.abort(new Error(`Turn stopped: ${i}`)),r}};function V(e,t,i){return{id:t.sessionId,turnId:e.turnId,content:e.content,...e.displayContent!==void 0?{displayContent:e.displayContent}:{},...i!==void 0?{executionDeadlineAtMs:i}:{},...e.executionDiagnostics?{executionDiagnostics:!0}:{},...e.clientIntent?{clientIntent:e.clientIntent}:{},...e.reviewRequest?{reviewRequest:e.reviewRequest}:{},...e.attachments?.length?{attachments:e.attachments.map(n=>({meta:{attachmentType:n.type,fileName:n.fileName,mimeType:n.mimeType,sizeBytes:n.sizeBytes},local:{...n.filePath?{filePath:n.filePath}:{},...n.assetId?{assetId:n.assetId}:{}}}))}:{},...e.model?{model:{...e.model}}:{},...e.outputSchema?{outputSchema:e.outputSchema}:{}}}function H(e){return e.type==="message"&&e.message.role==="assistant"}function K(e){return e.type==="delta"&&e.role==="assistant"&&typeof e.content=="string"}function Y(e){return e.type==="generic"&&(e.eventType==="questionnaire.ask"||e.eventType==="runtime.action-required"&&e.data.kind==="questionnaire")}function J(e){if(Y(e))return W()}function W(){return{category:"runtime",code:"QUESTIONNAIRE_REQUIRED",message:"Questionnaire requires user input.",retryable:!0}}function Z(e){if(e.type==="generic"&&e.eventType==="messages-rewound")return{status:"failed",error:{category:"runtime",code:"CONTENT_REVIEW_BLOCKED",message:"Content review blocked the request.",retryable:!0}};if(e.type==="error")return{status:"failed",error:{category:"runtime",message:e.message,retryable:!0}};if(e.type==="session-status"){if(e.status==="error")return{status:"failed",error:{category:"runtime",message:e.message??"Runtime turn failed.",retryable:!0}};if(e.status==="aborted"||e.status==="interrupted")return{status:"cancelled"}}}function ee(e){if(e instanceof p)return{category:e.category==="config"||e.category==="internal"?e.category:"runtime",code:e.code,message:e.message,retryable:e.retryable};if(e&&typeof e=="object"){let t=e;if(typeof t.message=="string")return{category:t.category==="config"||t.category==="internal"?t.category:"runtime",...typeof t.code=="string"?{code:t.code}:{},message:t.message,...typeof t.retryable=="boolean"?{retryable:t.retryable}:{retryable:!0}}}return{category:"runtime",message:e instanceof Error?e.message:String(e),retryable:!0}}function B(e,t){return e==="timeout"?"timeout":e==="limit"?"limit_exceeded":e==="user_stop"?"cancelled":t}async function G(e,t){try{await e(t)}catch{}}function te(e){let t=()=>{},i=new Promise(n=>{t=n});return{turnId:e,controller:new AbortController,settled:i,resolveSettled:t}}async function ne(e,t){if(!t.aborted)return new Promise((i,n)=>{let r=()=>t.removeEventListener("abort",o),o=()=>{r(),i(void 0)};t.addEventListener("abort",o,{once:!0}),e.then(a=>{r(),i(a)},a=>{r(),n(a)})})}async function ie(e,t){if(t<=0)return{settled:!1};let i,n=await Promise.race([e.then(r=>({settled:!0,value:r})),new Promise(r=>{i=setTimeout(()=>r({settled:!1}),t),i.unref?.()})]);return i&&clearTimeout(i),n}var q="Sign in to MiniMax to use Agent features. Run /login, then retry.",I="Sign in to MiniMax to use Agent features. Run `mcode login`, then retry.",S=class extends p{constructor(i,n=I){super("config",n,{code:"auth.login_required",retryable:!1});this.account=i;this.name="TuiLoginRequiredError"}};function re(e){return e.modelSource?e.modelSource==="token-plan":e.authMode==="managed-login"}function X(e){return e.status==="needs-login"||re(e)&&e.managedTokenPresent!==!0}function Te(e){return X(e)}async function z(e,t,i,n){let r=await e.getAccountStatus(t,n);return i?.(r),r}async function oe(e,t,i=I,n){let r=await z(e,t,n);if(X(r))throw new S(r,i);return r}async function se(e,t,i=I,n){let r=await z(e,t,n,{requireManagedAuth:!0});if(r.managedTokenPresent!==!0)throw new S(r,i);return r}async function ye(e,t,i){let n=e.getAccountStatus;n&&await oe({getAccountStatus:n.bind(e)},t,q,i)}async function Re(e,t,i){let n=e.getAccountStatus;n&&await se({getAccountStatus:n.bind(e)},t,q,i)}import{stripVTControlCharacters as ue}from"node:util";function Ae(e){let t=e.replace(/(?:\u001b\]|\u009d)[\s\S]*?(?:\u0007|\u001b\\|\u009c|$)|(?:\u001b[P^_X]|[\u0090\u0098\u009e\u009f])[\s\S]*?(?:\u001b\\|\u009c|$)/gu,"");return ue(t).replace(/\r\n/gu,`
|
|
2
|
+
import{q as O}from"./chunk-2BNOPHYG.js";import{a as p}from"./chunk-PRXIML4F.js";var b=["totalTokens","inputTokens","outputTokens","reasoningTokens","cacheReadTokens","cacheWriteTokens"];function v(e,t){return e.role==="assistant"&&(e.turnId===void 0||e.turnId===t)&&e.kind?.startsWith("compaction")===!0}function L(e,t){if(e.role!=="assistant"||e.turnId!==void 0&&e.turnId!==t||v(e,t))return;let i=Object.fromEntries(b.flatMap(r=>T(e.usage?.[r])?[[r,e.usage?.[r]]]:[])),n=b.some(r=>e.usage?.[r]!==void 0&&!T(e.usage?.[r]));return{...e.id?.trim()?{messageId:e.id}:{},...Object.keys(i).length?{usage:i}:{},...n?{usageIncomplete:!0}:{}}}function N(e,t){let i=t.messageId?e.findIndex(r=>r.messageId===t.messageId):-1,n=e[i];if(!n){e.push(t);return}e[i]={...n,...t,...n.usage||t.usage?{usage:{...n.usage,...t.usage}}:{}}}function Q(e){let t=e.length===0||e.some(n=>!T(n.usage?.inputTokens)||!T(n.usage?.outputTokens)||n.usageIncomplete),i=Object.fromEntries(b.flatMap(n=>{let r=e.map(a=>a.usage?.[n]).filter(T);if(!r.length)return[];let o=r.reduce((a,c)=>a+c,0);return Number.isFinite(o)?[[n,o]]:(t=!0,[])}));return{...Object.keys(i).length?{usage:i}:{},usageIncomplete:t}}function T(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}function D(e,t){let i=e.type==="message"?e.message.turnId:e.turnId;return i&&i!==t?!1:(e.type==="message"?e.message.toolCalls:e.type==="delta"?e.toolCalls:void 0)?.some(r=>{if(r.error||r.status!==2&&r.status!=="2"&&r.status!=="finished"||!r.output||typeof r.output!="object"||Array.isArray(r.output))return!1;let o=r.output.details;return typeof o=="object"&&o!==null&&!Array.isArray(o)&&o.waiting_for_user===!0})??!1}async function F(e,t,i,n=O,r){let o=await e.getPendingQuestionnaire?.(n,t,r);return o?.requester?.sessionId===t&&o.requester.runId===i?o:void 0}var $=1e3,j=class{constructor(t,i={}){this.runtime=t;this.options=i;this.nowMs=i.nowMs??Date.now}activeRun;retiringRun;nowMs;activeTurnId(){return this.activeRun?.turnId}detachActiveRun(t){let i=this.activeRun;return!i||t!==void 0&&i.turnId!==t?!1:(this.activeRun=void 0,!0)}retiringTurnId(){return this.retiringRun?.turnId}retirement(){return this.retiringRun?.settlement}async*sendWithQueueRecovery(t,i,n,r){let o=V(t,i,r),a=!1;try{for await(let c of this.runtime.sendMessage(o,n))a=!0,yield c}catch(c){if(a||r!==void 0||!(c instanceof p)||c.code!=="local_session_queue_paused"||!t.onQueuePaused||n.aborted)throw c;let d=await t.onQueuePaused(i.sessionId,n);if(n.throwIfAborted(),d==="cancel")throw new p("cancelled","The draft was kept.",{code:"PAUSED_QUEUE_SEND_CANCELLED"});yield*this.runtime.sendMessage(o,n,{pausedQueueAction:d==="paused-queue-clear"?"clear":"keep"})}}async execute(t,i=()=>{},n,r){if(this.activeRun)throw new Error("A run is already active.");if(this.retiringRun)throw new Error("The previous run is still stopping.");let o=te(t.turnId);this.activeRun=o;let a=this.nowMs(),c,d,w=!1,u="succeeded",m=null,g="",l,E=0,y=[],P=!1,_=!1;try{if(d=await ne(t.session,o.controller.signal),!d)throw o.controller.signal.reason??new Error("Turn cancelled before Session setup.");o.sessionId=d.sessionId;let f;t.policy?.timeoutMs!==void 0&&(f=this.nowMs()+t.policy.timeoutMs,c=setTimeout(()=>{this.stopActive(o,"timeout").catch(()=>{})},t.policy.timeoutMs),c.unref?.());let M=this.sendWithQueueRecovery(t,d,o.controller.signal,f)[Symbol.asyncIterator]();try{for(;;){let k=await M.next();if(k.done)break;let s=k.value;_||=D(s,t.turnId),w||(w=!0,n?.());let C=J(s);if(C){u="awaiting-user-continuation",l=C,await G(i,s);break}if(H(s)){P||=v(s.message,t.turnId);let U=L(s.message,t.turnId);if(U&&N(y,U),t.policy?.maxSteps!==void 0&&E>=t.policy.maxSteps){u="limit_exceeded",await this.stopActive(o,"limit");break}if(E+=1,s.message.toolCalls?.length)this.reportAnswerSelection({kind:"answer_excluded",messageId:s.message.id,reason:"tool_calls"}),m=null,g="";else{let A=s.message.content?.trim()?s.message.content:g;m=A.trim()?A:null,this.reportAnswerSelection({kind:"answer_selected",messageId:s.message.id,answerSource:s.message.content?.trim()?"completed_message":"completed_message_draft",answerBytes:Buffer.byteLength(A),finishReason:s.message.finishReason}),g=""}}else K(s)&&(g+=s.content);let h=Z(s);h&&(u=h.status,l=h.error),await G(i,s)}}finally{await M.return?.(void 0)}g.trim()&&(this.reportAnswerSelection({kind:"answer_selected",answerSource:"trailing_draft",answerBytes:Buffer.byteLength(g),replacedAnswer:m!==null}),m=g),u==="succeeded"&&!o.controller.signal.aborted&&(_||await F(this.runtime,d.sessionId,t.turnId,d.agentName,o.controller.signal))&&(u="awaiting-user-continuation",m=null,l=W()),t.policy?.requireAnswer===!0&&u==="succeeded"&&m===null&&(u="failed",l={category:"runtime",code:"EMPTY_RESPONSE",message:"Runtime completed without a final assistant response.",retryable:!0}),u=B(o.stopReason,u)}catch(f){o.stopReason||o.controller.signal.aborted?u=B(o.stopReason,"cancelled"):(u="failed",l=ee(f))}finally{c&&clearTimeout(c),this.activeRun===o&&(this.activeRun=void 0)}let{usage:x}=Q(y),R={sessionId:d?.sessionId??"",turnId:t.turnId,status:u,answer:m,...t.model?{model:{...t.model}}:{},...x?{usage:x}:{},...y.length?{usageResponses:y}:{},...P?{usageIncomplete:!0}:{},...l?{error:l}:{},durationMs:Math.max(0,this.nowMs()-a)};if(r)try{await r(R)}catch{u="failed";let f={category:"internal",code:"AUTOMATION_RESULT_WRITE_FAILED",message:"Could not publish the TUI automation result.",retryable:!0};l=f,R={...R,status:u,error:f}}return o.resolveSettled(),{turnId:t.turnId,...d?{session:d}:{},status:u,outcome:R,...l?.message?{error:l.message}:{}}}async abort(){let t=this.activeRun;return t?(t.abortPromise??=this.stopAndSettle(t),t.abortPromise):!1}reportAnswerSelection(t){try{this.options.onAnswerSelection?.(t)}catch{}}async stopAndSettle(t){let i=await this.stopActive(t,"user_stop"),n=t.settled.then(()=>i),r=await ie(n,this.options.cancellationSettlementTimeoutMs??$);if(this.activeRun===t&&(this.activeRun=void 0),r.settled)return r.value;let o={turnId:t.turnId,settlement:n};return o.settlement=n.finally(()=>{this.retiringRun===o&&(this.retiringRun=void 0)}),this.retiringRun=o,i}async stopActive(t,i){t.stopReason??=i;let n=t.sessionId,r=n?this.runtime.abortSession({id:n,turnId:t.turnId,reason:i==="limit"?"max_steps":i}).catch(()=>!1):Promise.resolve(!0);return t.controller.abort(new Error(`Turn stopped: ${i}`)),r}};function V(e,t,i){return{id:t.sessionId,turnId:e.turnId,content:e.content,...e.displayContent!==void 0?{displayContent:e.displayContent}:{},...i!==void 0?{executionDeadlineAtMs:i}:{},...e.executionDiagnostics?{executionDiagnostics:!0}:{},...e.clientIntent?{clientIntent:e.clientIntent}:{},...e.reviewRequest?{reviewRequest:e.reviewRequest}:{},...e.attachments?.length?{attachments:e.attachments.map(n=>({meta:{attachmentType:n.type,fileName:n.fileName,mimeType:n.mimeType,sizeBytes:n.sizeBytes},local:{...n.filePath?{filePath:n.filePath}:{},...n.assetId?{assetId:n.assetId}:{}}}))}:{},...e.model?{model:{...e.model}}:{},...e.outputSchema?{outputSchema:e.outputSchema}:{}}}function H(e){return e.type==="message"&&e.message.role==="assistant"}function K(e){return e.type==="delta"&&e.role==="assistant"&&typeof e.content=="string"}function Y(e){return e.type==="generic"&&(e.eventType==="questionnaire.ask"||e.eventType==="runtime.action-required"&&e.data.kind==="questionnaire")}function J(e){if(Y(e))return W()}function W(){return{category:"runtime",code:"QUESTIONNAIRE_REQUIRED",message:"Questionnaire requires user input.",retryable:!0}}function Z(e){if(e.type==="generic"&&e.eventType==="messages-rewound")return{status:"failed",error:{category:"runtime",code:"CONTENT_REVIEW_BLOCKED",message:"Content review blocked the request.",retryable:!0}};if(e.type==="error")return{status:"failed",error:{category:"runtime",message:e.message,retryable:!0}};if(e.type==="session-status"){if(e.status==="error")return{status:"failed",error:{category:"runtime",message:e.message??"Runtime turn failed.",retryable:!0}};if(e.status==="aborted"||e.status==="interrupted")return{status:"cancelled"}}}function ee(e){if(e instanceof p)return{category:e.category==="config"||e.category==="internal"?e.category:"runtime",code:e.code,message:e.message,retryable:e.retryable};if(e&&typeof e=="object"){let t=e;if(typeof t.message=="string")return{category:t.category==="config"||t.category==="internal"?t.category:"runtime",...typeof t.code=="string"?{code:t.code}:{},message:t.message,...typeof t.retryable=="boolean"?{retryable:t.retryable}:{retryable:!0}}}return{category:"runtime",message:e instanceof Error?e.message:String(e),retryable:!0}}function B(e,t){return e==="timeout"?"timeout":e==="limit"?"limit_exceeded":e==="user_stop"?"cancelled":t}async function G(e,t){try{await e(t)}catch{}}function te(e){let t=()=>{},i=new Promise(n=>{t=n});return{turnId:e,controller:new AbortController,settled:i,resolveSettled:t}}async function ne(e,t){if(!t.aborted)return new Promise((i,n)=>{let r=()=>t.removeEventListener("abort",o),o=()=>{r(),i(void 0)};t.addEventListener("abort",o,{once:!0}),e.then(a=>{r(),i(a)},a=>{r(),n(a)})})}async function ie(e,t){if(t<=0)return{settled:!1};let i,n=await Promise.race([e.then(r=>({settled:!0,value:r})),new Promise(r=>{i=setTimeout(()=>r({settled:!1}),t),i.unref?.()})]);return i&&clearTimeout(i),n}var q="Sign in to MiniMax to use Agent features. Run /login, then retry.",I="Sign in to MiniMax to use Agent features. Run `mcode login`, then retry.",S=class extends p{constructor(i,n=I){super("config",n,{code:"auth.login_required",retryable:!1});this.account=i;this.name="TuiLoginRequiredError"}};function re(e){return e.modelSource?e.modelSource==="token-plan":e.authMode==="managed-login"}function X(e){return e.status==="needs-login"||re(e)&&e.managedTokenPresent!==!0}function Te(e){return X(e)}async function z(e,t,i,n){let r=await e.getAccountStatus(t,n);return i?.(r),r}async function oe(e,t,i=I,n){let r=await z(e,t,n);if(X(r))throw new S(r,i);return r}async function se(e,t,i=I,n){let r=await z(e,t,n,{requireManagedAuth:!0});if(r.managedTokenPresent!==!0)throw new S(r,i);return r}async function ye(e,t,i){let n=e.getAccountStatus;n&&await oe({getAccountStatus:n.bind(e)},t,q,i)}async function Re(e,t,i){let n=e.getAccountStatus;n&&await se({getAccountStatus:n.bind(e)},t,q,i)}import{stripVTControlCharacters as ue}from"node:util";function Ae(e){let t=e.replace(/(?:\u001b\]|\u009d)[\s\S]*?(?:\u0007|\u001b\\|\u009c|$)|(?:\u001b[P^_X]|[\u0090\u0098\u009e\u009f])[\s\S]*?(?:\u001b\\|\u009c|$)/gu,"");return ue(t).replace(/\r\n/gu,`
|
|
3
3
|
`).replace(/\r/gu," ").replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]/gu,"")}export{Ae as a,v as b,L as c,N as d,Q as e,F as f,$ as g,j as h,S as i,Te as j,oe as k,ye as l,Re as m};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __mavis_cR } from "module"; import { basename as __mavis_basename, dirname as __mavis_dirname, join as __mavis_join } from "path"; import { fileURLToPath as __mavis_fileURLToPath, pathToFileURL as __mavis_pathToFileURL } from "url"; const __mavis_tuiCurrentModuleDir = __mavis_dirname(__mavis_fileURLToPath(import.meta.url)); const __mavis_tuiPackageRoot = __mavis_basename(__mavis_tuiCurrentModuleDir) === "chunks" ? __mavis_dirname(__mavis_tuiCurrentModuleDir) : __mavis_tuiCurrentModuleDir; const __mavis_tuiPackageEntryUrl = __mavis_pathToFileURL(__mavis_join(__mavis_tuiPackageRoot, "cli.js")).href; const require = __mavis_cR(__mavis_tuiPackageEntryUrl); const __dirname = __mavis_tuiPackageRoot;
|
|
2
|
-
import{a as p}from"./chunk-
|
|
2
|
+
import{a as p}from"./chunk-FPCUX6KP.js";import{e as g,k as d,m as h}from"./chunk-2LP3AAE5.js";import{isAbsolute as f,resolve as A}from"node:path";import{spawn as E}from"node:child_process";import{fileURLToPath as y}from"node:url";function T(e){return t=>R(t,e)}function R(e,t){let i=S(e,t),[o,r]=process.platform==="darwin"?["open",[i]]:process.platform==="win32"?["rundll32",["url.dll,FileProtocolHandler",i]]:["xdg-open",[i]];return new Promise((s,u)=>{let n=E(o,r,{detached:!0,stdio:"ignore",windowsHide:!0});n.once("error",u),n.once("spawn",()=>{n.unref(),s()})})}function S(e,t){return/^https?:\/\//iu.test(e)?e:/^file:\/\//iu.test(e)?y(e):f(e)?e:A(t,e)}var x="mcode-internal";function k(e){try{let t=new URL(e);return t.searchParams.set("client_surface","tui"),t.searchParams.set("download_source",x),t.toString()}catch{return e}}var w={cn:{dev:"https://agent.minimaxi.com",test:"https://agent.minimaxi.com",staging:"https://agent.minimaxi.com",prod:"https://agent.minimax.cn"},en:{dev:"https://agent.minimax.io",test:"https://agent.minimax.io",staging:"https://agent.minimax.io",prod:"https://agent.minimax.io"}};function m(e){let t=w[e.region][e.buildEnv];return`${t}/auth/logout?logout_redirect_uri=${encodeURIComponent(t)}`}var c=class{constructor(t){this.options=t;let i=d({runtimeRegion:process.env.MAVIS_REGION==="en"?"en":"cn"});this.scope={region:t.region??i.region,buildEnv:t.buildEnv??i.buildEnv}}scope;async login(t,i=this.scope.region){this.track("login_click",{hailuo_user_id:this.hailuoUserId()});try{let o={...this.scope,region:i},r=!P(o,this.scope),s=this.options.sharedAuthCore;if(r){if(!this.options.resolveSharedAuthCore)throw new Error(C(this.scope,o));s=this.options.resolveSharedAuthCore(i)}let u=(await s.getStatus()).status==="authenticated",n=!1;await s.login({onDeviceAuthorization:M=>{n=!0,t?.({state:"device-authorization",...M})}}),this.persistRegionPreference(o);let l=u&&!n,v={state:l?"already-authenticated":"authenticated",message:l?r?`Already signed in with ${a(o.region)}.`:"Already signed in with MiniMax.":r?`Signed in with ${a(o.region)}.`:"Signed in with MiniMax.",...r?{restartRequired:!0}:{}};return this.trackLoginResult("1",""),v}catch(o){throw this.trackLoginResult("2",b(o)),o}}async logout(){this.track("logout_click",{hailuo_user_id:this.hailuoUserId()});let t=await this.options.sharedAuthCore.getStatus(),i=await this.options.sharedAuthCore.logout({revoke:!0}),o=m(this.scope);return t.status==="anonymous"&&i.status==="anonymous"?{state:"already-signed-out",message:"Already signed out of MiniMax.",logoutUrl:o}:{state:"signed-out",logoutUrl:o,message:i.status==="logout_pending"?`Signed out locally from ${a(this.scope.region)} across MCode. Server revocation is pending until the network recovers.`:`Signed out of ${a(this.scope.region)} on Desktop, CLI/TUI, and embedded mcode-tools.`}}trackLoginResult(t,i){this.track("login_result",{hailuo_user_id:this.hailuoUserId(),source:this.options.telemetrySource??"mcode_cli",result_type:t,fail_reason:i,login_type:"minimax_oauth"})}persistRegionPreference(t){try{this.options.writeRegionPreference?.(this.options.dataDir,t)}catch{}}hailuoUserId(){try{return this.options.hailuoUserId?.()?.trim()??""}catch{return""}}track(t,i){try{this.options.telemetry?.track(t,i)}catch{}}};function b(e){let t=e instanceof Error?e.message:String(e);return/cancel/iu.test(t)?"3":/network|offline|fetch|ECONN|ENOTFOUND|ETIMEDOUT/iu.test(t)?"2":/oauth|authorization|login failed|invalid login state/iu.test(t)?"5":/server|HTTP 5\d\d/iu.test(t)?"1":"4"}function P(e,t){return e.region===t.region&&e.buildEnv===t.buildEnv}function C(e,t){return e.region!==t.region?`Signed in to ${a(e.region)}. Run \`mcode logout\` before signing in to ${a(t.region)}.`:`Signed in to another MiniMax ${e.buildEnv} environment. Run \`mcode logout\` before signing in to ${t.buildEnv}.`}function a(e){return e==="cn"?"MiniMax China":"MiniMax Global"}function j(e){let t=d({runtimeRegion:e.region,runtimeBuildEnv:e.buildEnv}),i=e.region??t.region,o=e.buildEnv??t.buildEnv,r={dataDir:e.dataDir,region:i,buildEnv:o,...e.telemetry?{telemetry:e.telemetry}:{},...e.telemetrySource?{telemetrySource:e.telemetrySource}:{},...e.hailuoUserId?{hailuoUserId:e.hailuoUserId}:{},writeRegionPreference:e.writeRegionPreference??h},s=n=>(e.createSharedSession??p)({dataDir:e.dataDir,region:n,buildEnv:o,oauthEndpoints:g(e.oauthEndpointEnvironment??process.env,{buildEnv:o,region:n})}),u=e.sharedAuthCore??s(i);return new c({...r,sharedAuthCore:u,resolveSharedAuthCore:s})}export{T as a,k as b,j as c};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __mavis_cR } from "module"; import { basename as __mavis_basename, dirname as __mavis_dirname, join as __mavis_join } from "path"; import { fileURLToPath as __mavis_fileURLToPath, pathToFileURL as __mavis_pathToFileURL } from "url"; const __mavis_tuiCurrentModuleDir = __mavis_dirname(__mavis_fileURLToPath(import.meta.url)); const __mavis_tuiPackageRoot = __mavis_basename(__mavis_tuiCurrentModuleDir) === "chunks" ? __mavis_dirname(__mavis_tuiCurrentModuleDir) : __mavis_tuiCurrentModuleDir; const __mavis_tuiPackageEntryUrl = __mavis_pathToFileURL(__mavis_join(__mavis_tuiPackageRoot, "cli.js")).href; const require = __mavis_cR(__mavis_tuiPackageEntryUrl); const __dirname = __mavis_tuiPackageRoot;
|
|
2
|
-
import{a,b,c,d}from"./chunk-
|
|
2
|
+
import{a,b,c,d}from"./chunk-CRTW4JM6.js";import"./chunk-2LP3AAE5.js";import"./chunk-G7FSWJID.js";import"./chunk-3FETZOUF.js";import"./chunk-CWWDVX6C.js";import"./chunk-ZITT4GJK.js";import"./chunk-D76SO2ME.js";export{b as getTuiDataDirPath,d as prepareTuiDataDir,a as resolveDefaultTuiDataDir,c as resolveTuiDataDir};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __mavis_cR } from "module"; import { basename as __mavis_basename, dirname as __mavis_dirname, join as __mavis_join } from "path"; import { fileURLToPath as __mavis_fileURLToPath, pathToFileURL as __mavis_pathToFileURL } from "url"; const __mavis_tuiCurrentModuleDir = __mavis_dirname(__mavis_fileURLToPath(import.meta.url)); const __mavis_tuiPackageRoot = __mavis_basename(__mavis_tuiCurrentModuleDir) === "chunks" ? __mavis_dirname(__mavis_tuiCurrentModuleDir) : __mavis_tuiCurrentModuleDir; const __mavis_tuiPackageEntryUrl = __mavis_pathToFileURL(__mavis_join(__mavis_tuiPackageRoot, "cli.js")).href; const require = __mavis_cR(__mavis_tuiPackageEntryUrl); const __dirname = __mavis_tuiPackageRoot;
|
|
2
|
-
import{$ as W,$a as cb,A as v,Aa as ua,B as w,Ba as va,C as x,Ca as wa,D as y,Da as xa,E as z,Ea as ya,F as A,Fa as za,G as B,Ga as Aa,H as C,Ha as Ba,I as D,Ia as Ca,J as E,Ja as Da,K as F,Ka as Ea,L as G,La as Fa,M as H,Ma as Ga,N as I,Na as Ha,O as J,Oa as Ia,P as K,Pa as Ja,Q as L,Qa as Ka,R as M,Ra as La,S as N,Sa as Ma,T as O,Ta as Na,U as P,Ua as Oa,V as Q,Va as Pa,W as R,Wa as Qa,X as S,Xa as Ra,Y as T,Ya as Sa,Z as U,Za as Ta,_ as V,_a as bb,aa as X,ab as db,ba as Y,bb as eb,cb as fb,d as a,da as Z,db as gb,ea as _,eb as hb,f as b,fa as $,fb as ib,g as c,ga as aa,gb as jb,h as d,ha as ba,hb as kb,ia as ca,ib as lb,j as e,ja as da,jb as mb,k as f,ka as ea,kb as nb,l as g,la as fa,lb as ob,m as h,ma as ga,mb as pb,n as i,na as ha,o as j,oa as ia,p as k,pa as ja,q as l,qa as ka,r as m,ra as la,s as n,sa as ma,t as o,ta as na,u as p,ua as oa,v as q,va as pa,w as r,wa as qa,x as s,xa as ra,y as t,ya as sa,z as u,za as ta}from"./chunk-
|
|
2
|
+
import{$ as W,$a as cb,A as v,Aa as ua,B as w,Ba as va,C as x,Ca as wa,D as y,Da as xa,E as z,Ea as ya,F as A,Fa as za,G as B,Ga as Aa,H as C,Ha as Ba,I as D,Ia as Ca,J as E,Ja as Da,K as F,Ka as Ea,L as G,La as Fa,M as H,Ma as Ga,N as I,Na as Ha,O as J,Oa as Ia,P as K,Pa as Ja,Q as L,Qa as Ka,R as M,Ra as La,S as N,Sa as Ma,T as O,Ta as Na,U as P,Ua as Oa,V as Q,Va as Pa,W as R,Wa as Qa,X as S,Xa as Ra,Y as T,Ya as Sa,Z as U,Za as Ta,_ as V,_a as bb,aa as X,ab as db,ba as Y,bb as eb,cb as fb,d as a,da as Z,db as gb,ea as _,eb as hb,f as b,fa as $,fb as ib,g as c,ga as aa,gb as jb,h as d,ha as ba,hb as kb,ia as ca,ib as lb,j as e,ja as da,jb as mb,k as f,ka as ea,kb as nb,l as g,la as fa,lb as ob,m as h,ma as ga,mb as pb,n as i,na as ha,o as j,oa as ia,p as k,pa as ja,q as l,qa as ka,r as m,ra as la,s as n,sa as ma,t as o,ta as na,u as p,ua as oa,v as q,va as pa,w as r,wa as qa,x as s,xa as ra,y as t,ya as sa,z as u,za as ta}from"./chunk-G7FSWJID.js";import"./chunk-3FETZOUF.js";import"./chunk-CWWDVX6C.js";import{a as Ua,b as Va,c as Wa,d as Xa,e as Ya,f as Za,g as _a,h as $a,i as ab}from"./chunk-ZITT4GJK.js";import"./chunk-D76SO2ME.js";export{z as AGENT_BUILTIN_MCP_TOOL_IDS,A as AGENT_BUILTIN_SKILL_IDS,y as AGENT_BUILTIN_TOOL_IDS,B as AGENT_CAPABILITY_OWNED_SKILL_IDS,n as AGENT_RUNTIME_FRAMEWORKS,Ya as ASR_PROXY_AUTH_ENV_KEYS,ka as BRAND,X as BROWSER_CONFIG_DEFAULTS,Ha as CUSTOM_PROVIDER_ID_PREFIX,nb as ConfigFileError,I as DATA_CONTRIBUTION_CONFIG_DEFAULTS,o as DEFAULT_AGENT_RUNTIME_FRAMEWORK,ua as DEFAULT_MODEL_PRESETS,ma as DEFAULT_PORT,k as DEFAULT_SKILLS_CONFIG,m as EXTERNAL_SOURCE_KIND_LIST,Q as GOAL_CONFIG_DEFAULTS,R as GOAL_CONFIG_LIMITS,N as GOAL_EVALUATOR_MODEL_POLICIES,P as GOAL_SUBAGENT_PROFILES,M as GOAL_VERIFICATION_EVIDENCE_MODES,L as GOAL_VERIFICATION_MODES,O as GOAL_VERIFIER_READONLY_PROFILE,s as LEGACY_DATA_DIR_BASENAME,Va as LEGACY_RUNTIME_ENV_KEYS,eb as LOCAL_RUNTIME_AUTH_CONTEXT_FILE,Fa as MANAGED_MINIMAX_PROVIDER_ID,Ua as MANAGED_RUNTIME_KEYS,h as MEMORY_V2_DEFAULTS,Ga as MINIMAX_API_PROVIDER_ID,r as NEW_DATA_DIR_BASENAME,na as OPENCODE_PORT_OFFSET,Xa as PARENT_HINT_KEYS,V as REQUEST_MEDIA_DEFAULTS,la as RUNTIME_ENV_PREFIX,Wa as RUNTIME_IDENTITY_KEYS,_ as SANDBOX_CONFIG_DEFAULTS,aa as SUBAGENT_CONFIG_DEFAULTS,lb as TEST_PORT_ROLE_FLOOR,kb as TEST_PORT_ROLE_OFFSET,T as TOOL_RESULT_COMPACTION_DEFAULTS,ta as allowsManagedMinimaxProviderOverride,Za as buildChildEnv,jb as clearLocalRuntimeAuthContextFile,Ta as compareAndSetLocalModelContext,Ma as credentialEnvReferenceName,pa as detectGitPortInfo,db as detectPidOwner,ab as findLegacyRuntimeEnvKeys,cb as formatPidFile,ya as getConfig,sa as getConfigPath,ra as getDataDir,u as getLegacyDataDirPath,Ba as getOpenCodePort,t as getPrimaryDataDirPath,qa as getProfile,ea as getRuntimeBuildEnv,ga as getRuntimePresetKey,da as getRuntimeRegion,Z as getSandboxConfigDefaults,G as isAgentBuiltinMcpToolEnabled,H as isAgentBuiltinSkillEnabled,F as isAgentBuiltinToolEnabled,ia as isBetaFeatureProdReady,Ia as isFirstPartyMinimaxMessagesRoute,ja as isInternalBuild,Ca as isLegacyManagedMinimaxProvider,i as isLegacyMemoryRecallEnabled,a as isLocalSourceProvenanceEnabled,Da as isManagedProviderBaseUrl,fa as isManagedRuntime,g as isMemoryV2Enabled,ca as isProposalEligibleAgent,Ka as listRouteModelIds,ob as loadConfigFromFile,w as migrateDefaultDataDir,x as migrateProfileDataDir,j as minimaxApiModels,fb as normalizeLocalRuntimeAuthContext,D as parseAgentCapabilityConfig,q as parseAgentRuntimeConfig,p as parseAgentRuntimeFramework,C as parseAgentsConfig,Y as parseBrowserConfig,e as parseConfigText,J as parseDataContributionConfig,S as parseGoalConfig,bb as parsePidFile,W as parseRequestMediaConfig,c as parseRunawayGuardOverride,$ as parseSandboxConfig,l as parseSkillsConfig,ba as parseSubagentConfig,U as parseToolResultCompactionConfig,mb as pickTestPort,Oa as probeProviderCredential,K as readDataContributionEnabled,pb as readExplicitBetaFeatureFromFile,hb as readLocalRuntimeAuthContext,Pa as removeLocalProviderConfig,Qa as replaceLocalManagedMinimaxProvider,xa as resetConfig,oa as resetGitDetect,E as resolveAgentCapabilities,ha as resolveBetaFeature,v as resolveDataDir,gb as resolveLocalRuntimeAuthContextPath,La as resolveModelAvailability,Ja as resolveModelCallRoute,Aa as resolvePort,za as resolvePromptConfig,Ea as resolveProviderAuthMode,Na as resolveProviderCredential,d as resolveRunawayGuardConfig,f as serializeConfigPreservingComments,va as setLegacyByokProviderMigrationEnabled,wa as setManagedPresetBaseUrlSyncEnabled,_a as stripManagedRuntimeEnv,$a as stripRuntimeBoundaryKeysFrom,Ra as updateLocalByokConfig,Sa as updateLocalModelSelection,ib as writeLocalRuntimeAuthContext,b as writeTuiStatusLineSetting};
|