@minimax-ai/code 0.4.8 → 0.4.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 +27 -0
- package/CHANGELOG.zh-CN.md +23 -0
- package/README.md +16 -3
- package/README.zh-CN.md +20 -2
- package/chunks/{chunk-E6MMSL54.js → chunk-CYA33574.js} +469 -469
- package/chunks/{chunk-SLRPB56L.js → chunk-HJ6CAPCI.js} +1 -1
- package/chunks/{chunk-LOASZMQB.js → chunk-PMTJEVJF.js} +407 -407
- package/chunks/{chunk-DIMUZAUA.js → chunk-VOK3LP4U.js} +1 -1
- package/chunks/{launcher-NIEXEZF5.js → launcher-BO2AIPOJ.js} +138 -138
- package/chunks/{lifecycle-EEX754QU.js → lifecycle-JTZ4IFVL.js} +1 -1
- package/chunks/{main-ANDH2IE5.js → main-RV5CLB2O.js} +10 -10
- package/chunks/{plugin-command-STBEQNGX.js → plugin-command-XCLCU4X3.js} +1 -1
- package/chunks/{provider-command-MKVRALX5.js → provider-command-TITVCVLJ.js} +1 -1
- package/chunks/{run-acp-command-2AEYGDBH.js → run-acp-command-2SHKZJNF.js} +2 -2
- package/chunks/run-exec-command-BQ2G5OY7.js +17 -0
- package/cli.js +1 -1
- package/package.json +1 -1
- package/chunks/run-exec-command-LVG3YSVK.js +0 -17
|
@@ -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{q as g}from"./chunk-XYXCVIX2.js";var L=1e3,P=class{constructor(t,n={}){this.runtime=t;this.options=n;this.nowMs=n.nowMs??Date.now}activeRun;retiringRun;nowMs;activeTurnId(){return this.activeRun?.turnId}detachActiveRun(t){let n=this.activeRun;return!n||t!==void 0&&n.turnId!==t?!1:(this.activeRun=void 0,!0)}retiringTurnId(){return this.retiringRun?.turnId}retirement(){return this.retiringRun?.settlement}async*sendWithQueueRecovery(t,n,i){let r=N(t,n),s=!1;try{for await(let a of this.runtime.sendMessage(r,i))s=!0,yield a}catch(a){if(s||!(a instanceof g)||a.code!=="local_session_queue_paused"||!t.onQueuePaused||i.aborted)throw a;let d=await t.onQueuePaused(n.sessionId,i);if(i.throwIfAborted(),d==="cancel")throw new g("cancelled","The draft was kept.",{code:"PAUSED_QUEUE_SEND_CANCELLED"});yield*this.runtime.sendMessage(r,i,{pausedQueueAction:d==="paused-queue-clear"?"clear":"keep"})}}async execute(t,n=()=>{},i,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 s=W(t.turnId);this.activeRun=s;let a=this.nowMs(),d,l,w=!1,u="succeeded",
|
|
2
|
+
import{q as g}from"./chunk-XYXCVIX2.js";var L=1e3,P=class{constructor(t,n={}){this.runtime=t;this.options=n;this.nowMs=n.nowMs??Date.now}activeRun;retiringRun;nowMs;activeTurnId(){return this.activeRun?.turnId}detachActiveRun(t){let n=this.activeRun;return!n||t!==void 0&&n.turnId!==t?!1:(this.activeRun=void 0,!0)}retiringTurnId(){return this.retiringRun?.turnId}retirement(){return this.retiringRun?.settlement}async*sendWithQueueRecovery(t,n,i){let r=N(t,n),s=!1;try{for await(let a of this.runtime.sendMessage(r,i))s=!0,yield a}catch(a){if(s||!(a instanceof g)||a.code!=="local_session_queue_paused"||!t.onQueuePaused||i.aborted)throw a;let d=await t.onQueuePaused(n.sessionId,i);if(i.throwIfAborted(),d==="cancel")throw new g("cancelled","The draft was kept.",{code:"PAUSED_QUEUE_SEND_CANCELLED"});yield*this.runtime.sendMessage(r,i,{pausedQueueAction:d==="paused-queue-clear"?"clear":"keep"})}}async execute(t,n=()=>{},i,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 s=W(t.turnId);this.activeRun=s;let a=this.nowMs(),d,l,w=!1,u="succeeded",T=null,m="",c,b=0,y;try{if(l=await G(t.session,s.controller.signal),!l)throw s.controller.signal.reason??new Error("Turn cancelled before Session setup.");s.sessionId=l.sessionId,t.policy?.timeoutMs!==void 0&&(d=setTimeout(()=>{this.stopActive(s,"timeout").catch(()=>{})},t.policy.timeoutMs),d.unref?.());let f=this.sendWithQueueRecovery(t,l,s.controller.signal)[Symbol.asyncIterator]();try{for(;;){let E=await f.next();if(E.done)break;let o=E.value;w||(w=!0,i?.());let I=B(o);if(I){u="awaiting-user-continuation",c=I,await M(n,o);break}if(U(o)){if(y=C(y,o.message.usage),t.policy?.maxSteps!==void 0&&b>=t.policy.maxSteps){u="limit_exceeded",await this.stopActive(s,"limit");break}if(b+=1,o.message.toolCalls?.length)this.reportAnswerSelection({kind:"answer_excluded",messageId:o.message.id,reason:"tool_calls"}),T=null,m="";else{let A=o.message.content?.trim()?o.message.content:m;T=A.trim()?A:null,this.reportAnswerSelection({kind:"answer_selected",messageId:o.message.id,answerSource:o.message.content?.trim()?"completed_message":"completed_message_draft",answerBytes:Buffer.byteLength(A),finishReason:o.message.finishReason}),m=""}}else D(o)&&(m+=o.content);let v=F(o);v&&(u=v.status,c=v.error),await M(n,o)}}finally{await f.return?.(void 0)}m.trim()&&(this.reportAnswerSelection({kind:"answer_selected",answerSource:"trailing_draft",answerBytes:Buffer.byteLength(m),replacedAnswer:T!==null}),T=m),t.policy?.requireAnswer===!0&&u==="succeeded"&&T===null&&(u="failed",c={category:"runtime",code:"EMPTY_RESPONSE",message:"Runtime completed without a final assistant response.",retryable:!0}),u=_(s.stopReason,u)}catch(f){s.stopReason||s.controller.signal.aborted?u=_(s.stopReason,"cancelled"):(u="failed",c=j(f))}finally{d&&clearTimeout(d),this.activeRun===s&&(this.activeRun=void 0)}let R={sessionId:l?.sessionId??"",turnId:t.turnId,status:u,answer:T,...t.model?{model:{...t.model}}:{},...y?{usage:y}:{},...c?{error:c}:{},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};c=f,R={...R,status:u,error:f}}return s.resolveSettled(),{turnId:t.turnId,...l?{session:l}:{},status:u,outcome:R,...c?.message?{error:c.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 n=await this.stopActive(t,"user_stop"),i=t.settled.then(()=>n),r=await q(i,this.options.cancellationSettlementTimeoutMs??L);if(this.activeRun===t&&(this.activeRun=void 0),r.settled)return r.value;let s={turnId:t.turnId,settlement:i};return s.settlement=i.finally(()=>{this.retiringRun===s&&(this.retiringRun=void 0)}),this.retiringRun=s,n}async stopActive(t,n){t.stopReason??=n;let i=t.sessionId,r=i?this.runtime.abortSession({id:i,turnId:t.turnId,reason:n==="limit"?"max_steps":n}).catch(()=>!1):Promise.resolve(!0);return t.controller.abort(new Error(`Turn stopped: ${n}`)),r}};function C(e,t){if(!t)return e;let n={...p(e,t,"totalTokens"),...p(e,t,"inputTokens"),...p(e,t,"outputTokens"),...p(e,t,"reasoningTokens"),...p(e,t,"cacheReadTokens"),...p(e,t,"cacheWriteTokens")};return Object.keys(n).length>0?n:e}function p(e,t,n){let i=t[n];return typeof i!="number"||!Number.isFinite(i)?{}:{[n]:(e?.[n]??0)+i}}function N(e,t){return{id:t.sessionId,turnId:e.turnId,content:e.content,...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 U(e){return e.type==="message"&&e.message.role==="assistant"}function D(e){return e.type==="delta"&&e.role==="assistant"&&typeof e.content=="string"}function Q(e){return e.type==="generic"&&(e.eventType.includes("questionnaire")||e.eventType==="runtime.action-required"&&e.data.kind==="questionnaire")}function B(e){if(Q(e))return{category:"runtime",code:"QUESTIONNAIRE_REQUIRED",message:"Questionnaire requires user input.",retryable:!0}}function F(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 j(e){if(e instanceof g)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 _(e,t){return e==="timeout"?"timeout":e==="limit"?"limit_exceeded":e==="user_stop"?"cancelled":t}async function M(e,t){try{await e(t)}catch{}}function W(e){let t=()=>{},n=new Promise(i=>{t=i});return{turnId:e,controller:new AbortController,settled:n,resolveSettled:t}}async function G(e,t){if(!t.aborted)return new Promise((n,i)=>{let r=()=>t.removeEventListener("abort",s),s=()=>{r(),n(void 0)};t.addEventListener("abort",s,{once:!0}),e.then(a=>{r(),n(a)},a=>{r(),i(a)})})}async function q(e,t){if(t<=0)return{settled:!1};let n,i=await Promise.race([e.then(r=>({settled:!0,value:r})),new Promise(r=>{n=setTimeout(()=>r({settled:!1}),t),n.unref?.()})]);return n&&clearTimeout(n),i}var x="Sign in to MiniMax to use Agent features. Run /login, then retry.",h="Sign in to MiniMax to use Agent features. Run `mcode login`, then retry.",S=class extends g{constructor(n,i=h){super("config",i,{code:"auth.login_required",retryable:!1});this.account=n;this.name="TuiLoginRequiredError"}};function z(e){return e.modelSource?e.modelSource==="token-plan":e.authMode==="managed-login"}function k(e){return e.status==="needs-login"||z(e)&&e.managedTokenPresent!==!0}function $(e){return k(e)||e.managedTokenPresent===!1}async function O(e,t,n,i){let r=await e.getAccountStatus(t,i);return n?.(r),r}async function X(e,t,n=h,i){let r=await O(e,t,i);if(k(r))throw new S(r,n);return r}async function H(e,t,n=h,i){let r=await O(e,t,i,{requireManagedAuth:!0});if(r.managedTokenPresent!==!0)throw new S(r,n);return r}async function J(e,t,n){let i=e.getAccountStatus;i&&await X({getAccountStatus:i.bind(e)},t,x,n)}async function Z(e,t,n){let i=e.getAccountStatus;i&&await H({getAccountStatus:i.bind(e)},t,x,n)}export{P as a,S as b,$ as c,X as d,J as e,Z as f};
|