@minimax-ai/code 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/CHANGELOG.md +81 -51
  2. package/CHANGELOG.zh-CN.md +36 -12
  3. package/README.md +4 -0
  4. package/README.zh-CN.md +35 -1
  5. package/chunks/{azure-openai-responses-OAPIGHCQ.js → azure-openai-responses-HOJR5DNA.js} +1 -1
  6. package/chunks/{chunk-BFVBLLWG.js → chunk-BEBFQY6O.js} +1 -1
  7. package/chunks/{chunk-GOLYEPEW.js → chunk-BEUVALD2.js} +521 -521
  8. package/chunks/{chunk-WSVP72I3.js → chunk-HEAI577S.js} +1 -1
  9. package/chunks/chunk-JCDDI4WJ.js +2 -0
  10. package/chunks/{chunk-ORVAHBJL.js → chunk-OJA2IAQ6.js} +2 -2
  11. package/chunks/chunk-SD6SJL3L.js +11 -0
  12. package/chunks/{chunk-OFHDMZSQ.js → chunk-VFMQBQ74.js} +321 -321
  13. package/chunks/{dist-UYNXCH7Y.js → dist-QF3JV3LN.js} +1 -1
  14. package/chunks/{launcher-U2WCORIY.js → launcher-TUY2TFYJ.js} +146 -146
  15. package/chunks/{lifecycle-RBOOMUY3.js → lifecycle-6JTTIEH2.js} +1 -1
  16. package/chunks/{main-WOL6V5OD.js → main-RHDM3DSB.js} +1 -1
  17. package/chunks/{openai-codex-responses-OKBVUABU.js → openai-codex-responses-5BJTY4II.js} +1 -1
  18. package/chunks/{openai-responses-4ZH3D54Q.js → openai-responses-FRXGNXAR.js} +1 -1
  19. package/chunks/{plugin-command-UFTRCOD6.js → plugin-command-34BQGAX4.js} +1 -1
  20. package/chunks/{provider-command-35G2ZJ5D.js → provider-command-XOI6VZ4Z.js} +1 -1
  21. package/chunks/{run-acp-command-TES33Q37.js → run-acp-command-BH3V7PS6.js} +3 -3
  22. package/chunks/{run-exec-command-52NJI7ZP.js → run-exec-command-FMHHG5HZ.js} +1 -1
  23. package/cli.js +1 -1
  24. package/package.json +1 -1
  25. package/chunks/chunk-IHFSGO5Y.js +0 -2
  26. package/chunks/chunk-ZA4WKJYS.js +0 -13
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __mavis_cR } from "module"; import { basename as __mavis_basename, dirname as __mavis_dirname, join as __mavis_join } from "path"; import { fileURLToPath as __mavis_fileURLToPath, pathToFileURL as __mavis_pathToFileURL } from "url"; const __mavis_tuiCurrentModuleDir = __mavis_dirname(__mavis_fileURLToPath(import.meta.url)); const __mavis_tuiPackageRoot = __mavis_basename(__mavis_tuiCurrentModuleDir) === "chunks" ? __mavis_dirname(__mavis_tuiCurrentModuleDir) : __mavis_tuiCurrentModuleDir; const __mavis_tuiPackageEntryUrl = __mavis_pathToFileURL(__mavis_join(__mavis_tuiPackageRoot, "cli.js")).href; const require = __mavis_cR(__mavis_tuiPackageEntryUrl); const __dirname = __mavis_tuiPackageRoot;
2
- import{a as Oe,b as _e}from"./chunk-GOLYEPEW.js";import"./chunk-R6GVNV7J.js";import"./chunk-4ESEMCSG.js";import{b as Re,d as Ie,e as se,f as be,g as Pe,h as N}from"./chunk-BFVBLLWG.js";import{Ed as mt,k as oe}from"./chunk-OFHDMZSQ.js";import{b as xe,c as k,d as ve}from"./chunk-A2CQYOXE.js";import{a as Me,d as Ae}from"./chunk-SLRPB56L.js";import{c as Se,q as G}from"./chunk-XYXCVIX2.js";import"./chunk-4NX3LPKA.js";import"./chunk-ORVAHBJL.js";import{a as ke,b as Ce}from"./chunk-YPMJNO4T.js";import"./chunk-PPIEC7ZM.js";import"./chunk-C3JRMX7L.js";import"./chunk-X4N2MWNJ.js";import"./chunk-75PL5LYJ.js";import"./chunk-AABEG2OJ.js";import"./chunk-6TZEW2D4.js";import"./chunk-4Y64C4JT.js";import"./chunk-HQ2U4QVQ.js";import{d as Te}from"./chunk-V7D3N7GI.js";import"./chunk-AAJMOWWM.js";import{$a as Ee,_a as we}from"./chunk-6BYKHQOV.js";import"./chunk-2ZG44JU6.js";import"./chunk-ZITT4GJK.js";import"./chunk-Y27DNFV2.js";import"./chunk-CWWDVX6C.js";import"./chunk-RPO5CDCP.js";import"./chunk-LOQ4VVEN.js";import"./chunk-ZA4WKJYS.js";import"./chunk-PWQHCWDV.js";import"./chunk-SHXPTUWI.js";import"./chunk-IIHJNKC3.js";import"./chunk-2UWBSJDH.js";import"./chunk-GUFBGYOC.js";import"./chunk-CK62QLTS.js";import"./chunk-WFWSBUYD.js";import{e as lt}from"./chunk-D76SO2ME.js";var T=Object.freeze({success:0,invocation:2,config:3,runtime:4,timeout:6,limit:7,internal:70,cancelled:130,brokenPipe:141}),m=class extends G{constructor(r,n,i){super(r,n,{code:`exec.${r}`,retryable:r==="runtime",...i});this.kind=r;this.name="TuiExecError"}};function De(e){switch(e.status){case"succeeded":return T.success;case"failed":return e.error?.category==="config"?T.config:e.error?.category==="internal"?T.internal:T.runtime;case"timeout":return T.timeout;case"cancelled":return T.cancelled;case"limit_exceeded":return T.limit}return T.internal}function $(e){return e instanceof m?T[e.kind]:T.internal}async function je(e,t){try{return Ee(e,t)}catch(r){let n=r instanceof we?r.message:`Config is invalid: ${e}${r instanceof Error?` (${r.message})`:""}`;throw new m("config",n,{cause:r})}}function L(e){return e.kind==="invocation"||e.kind==="config"||e.kind==="cancelled"||e.kind==="brokenPipe"?k(e):e.kind==="runtime"?`The run failed: ${k(e)}. Retry after the connection recovers.`:`MCode encountered an internal error: ${k(e)}. Retry; if it keeps happening, report it through an available support channel.`}function Fe(e){return e.status==="timeout"?"The run timed out. Increase --timeout or retry.":e.status==="limit_exceeded"?"The run reached its step limit. Increase --max-steps or narrow the task.":e.status==="cancelled"?"The run was cancelled.":e.error?.category==="config"?`The run could not start with the current configuration${e.error.message?`: ${k(e.error.message)}`:""}. Open MCode and run /doctor.`:e.error?.category==="internal"?`MCode encountered an internal error${e.error.message?`: ${k(e.error.message)}`:""}. Retry; if it keeps happening, report it through an available support channel.`:`The run failed${e.error?.message?`: ${k(e.error.message)}`:""}. Retry after the connection recovers.`}import{readFile as Ot,realpath as de,stat as Y}from"node:fs/promises";import{homedir as Be}from"node:os";import{basename as Je,dirname as _t,extname as Dt,isAbsolute as jt,resolve as K}from"node:path";var ae=lt(mt(),1);function ue(e,t){if(!t)return{ok:!0,value:e??null};if(!e?.trim())return{ok:!1,kind:"empty",message:"Structured output was empty."};let r;try{r=JSON.parse(e)}catch{return{ok:!1,kind:"invalid_json",message:"Structured output was not valid JSON."}}let n=new ae.Ajv({allErrors:!0,strict:!1}),i=n.compile(t);return i(r)?{ok:!0,value:r}:{ok:!1,kind:"schema_mismatch",message:`Structured output did not match --output-schema: ${n.errorsText(i.errors,{separator:"; "})}`}}function Ne(e,t){let r=e.status==="succeeded"?t.validation??ue(e.answer,t.outputSchema):void 0,n=ft(e,r);return{schemaVersion:1,type:"exec.result",runId:t.runId,sessionId:n.sessionId,turnId:n.turnId,status:n.status==="awaiting-user-continuation"?"failed":n.status,...n.status==="succeeded"&&r?.ok?{output:r.value}:{},...n.error?{error:{...n.error}}:{},...t.model?{model:{...t.model}}:{},...t.usage?{usage:{...t.usage}}:{},durationMs:n.durationMs}}function $e(e){return J(e)?e.schemaVersion===1&&e.type==="exec.result"&&typeof e.runId=="string"&&typeof e.sessionId=="string"&&typeof e.turnId=="string"&&typeof e.durationMs=="number"&&Number.isFinite(e.durationMs)&&pt(e.status)&&gt(e.model)&&yt(e.usage)&&ht(e.error):!1}function ft(e,t){return e.status==="awaiting-user-continuation"?{...e,status:"failed",error:e.error??{category:"runtime",code:"INTERACTION_NOT_AVAILABLE",message:"The Runtime requested interaction from a non-interactive Exec host.",retryable:!1}}:e.status!=="succeeded"||!t||t.ok?e:{...e,status:"failed",error:{category:"runtime",code:"STRUCTURED_OUTPUT_INVALID",message:t.message,retryable:!0}}}function Le(e){new ae.Ajv({allErrors:!0,strict:!1}).compile(e)}function pt(e){return e==="succeeded"||e==="failed"||e==="timeout"||e==="cancelled"||e==="limit_exceeded"}function gt(e){return e===void 0?!0:J(e)?typeof e.providerId=="string"&&typeof e.modelId=="string"&&U(e.variant)&&U(e.providerSource)&&U(e.providerKind)&&U(e.protocol)&&(e.structuredOutputMode===void 0||e.structuredOutputMode==="native_strict"):!1}function yt(e){return e===void 0?!0:J(e)?Object.values(e).every(t=>t===void 0||typeof t=="number"&&Number.isFinite(t)):!1}function ht(e){return e===void 0?!0:J(e)?(e.category==="config"||e.category==="runtime"||e.category==="internal")&&U(e.code)&&typeof e.message=="string"&&(e.retryable===void 0||typeof e.retryable=="boolean"):!1}function U(e){return e===void 0||typeof e=="string"}function J(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}import{createHash as wt,randomUUID as Et}from"node:crypto";import{access as Tt,constants as xt,lstat as Ue,mkdir as vt,open as St,readdir as qe,rename as Rt,unlink as It,writeFile as bt}from"node:fs/promises";import{join as X,resolve as Pt}from"node:path";var ce=256*1024,kt=4*1024*1024,Mt=5e3;function He(e){return ve(e.replace(/("(?:authorization|api[-_ ]?key|access[-_ ]?token|refresh[-_ ]?token|token|password|secret)"\s*:\s*)"(?:\\.|[^"\\])*"/giu,'$1"[redacted]"'))}function At(e){if(e.length<=ce)return e;let t=Buffer.from(`
2
+ import{a as Oe,b as _e}from"./chunk-BEUVALD2.js";import"./chunk-R6GVNV7J.js";import"./chunk-4ESEMCSG.js";import{b as Re,d as Ie,e as se,f as be,g as Pe,h as N}from"./chunk-BEBFQY6O.js";import{Ed as mt,k as oe}from"./chunk-VFMQBQ74.js";import{b as xe,c as k,d as ve}from"./chunk-A2CQYOXE.js";import{a as Me,d as Ae}from"./chunk-SLRPB56L.js";import{c as Se,q as G}from"./chunk-XYXCVIX2.js";import"./chunk-4NX3LPKA.js";import"./chunk-OJA2IAQ6.js";import{a as ke,b as Ce}from"./chunk-YPMJNO4T.js";import"./chunk-PPIEC7ZM.js";import"./chunk-C3JRMX7L.js";import"./chunk-X4N2MWNJ.js";import"./chunk-75PL5LYJ.js";import"./chunk-AABEG2OJ.js";import"./chunk-6TZEW2D4.js";import"./chunk-4Y64C4JT.js";import"./chunk-HQ2U4QVQ.js";import{d as Te}from"./chunk-V7D3N7GI.js";import"./chunk-AAJMOWWM.js";import{$a as Ee,_a as we}from"./chunk-6BYKHQOV.js";import"./chunk-2ZG44JU6.js";import"./chunk-ZITT4GJK.js";import"./chunk-Y27DNFV2.js";import"./chunk-CWWDVX6C.js";import"./chunk-RPO5CDCP.js";import"./chunk-LOQ4VVEN.js";import"./chunk-SD6SJL3L.js";import"./chunk-PWQHCWDV.js";import"./chunk-SHXPTUWI.js";import"./chunk-IIHJNKC3.js";import"./chunk-2UWBSJDH.js";import"./chunk-GUFBGYOC.js";import"./chunk-CK62QLTS.js";import"./chunk-WFWSBUYD.js";import{e as lt}from"./chunk-D76SO2ME.js";var T=Object.freeze({success:0,invocation:2,config:3,runtime:4,timeout:6,limit:7,internal:70,cancelled:130,brokenPipe:141}),m=class extends G{constructor(r,n,i){super(r,n,{code:`exec.${r}`,retryable:r==="runtime",...i});this.kind=r;this.name="TuiExecError"}};function De(e){switch(e.status){case"succeeded":return T.success;case"failed":return e.error?.category==="config"?T.config:e.error?.category==="internal"?T.internal:T.runtime;case"timeout":return T.timeout;case"cancelled":return T.cancelled;case"limit_exceeded":return T.limit}return T.internal}function $(e){return e instanceof m?T[e.kind]:T.internal}async function je(e,t){try{return Ee(e,t)}catch(r){let n=r instanceof we?r.message:`Config is invalid: ${e}${r instanceof Error?` (${r.message})`:""}`;throw new m("config",n,{cause:r})}}function L(e){return e.kind==="invocation"||e.kind==="config"||e.kind==="cancelled"||e.kind==="brokenPipe"?k(e):e.kind==="runtime"?`The run failed: ${k(e)}. Retry after the connection recovers.`:`MCode encountered an internal error: ${k(e)}. Retry; if it keeps happening, report it through an available support channel.`}function Fe(e){return e.status==="timeout"?"The run timed out. Increase --timeout or retry.":e.status==="limit_exceeded"?"The run reached its step limit. Increase --max-steps or narrow the task.":e.status==="cancelled"?"The run was cancelled.":e.error?.category==="config"?`The run could not start with the current configuration${e.error.message?`: ${k(e.error.message)}`:""}. Open MCode and run /doctor.`:e.error?.category==="internal"?`MCode encountered an internal error${e.error.message?`: ${k(e.error.message)}`:""}. Retry; if it keeps happening, report it through an available support channel.`:`The run failed${e.error?.message?`: ${k(e.error.message)}`:""}. Retry after the connection recovers.`}import{readFile as Ot,realpath as de,stat as Y}from"node:fs/promises";import{homedir as Be}from"node:os";import{basename as Je,dirname as _t,extname as Dt,isAbsolute as jt,resolve as K}from"node:path";var ae=lt(mt(),1);function ue(e,t){if(!t)return{ok:!0,value:e??null};if(!e?.trim())return{ok:!1,kind:"empty",message:"Structured output was empty."};let r;try{r=JSON.parse(e)}catch{return{ok:!1,kind:"invalid_json",message:"Structured output was not valid JSON."}}let n=new ae.Ajv({allErrors:!0,strict:!1}),i=n.compile(t);return i(r)?{ok:!0,value:r}:{ok:!1,kind:"schema_mismatch",message:`Structured output did not match --output-schema: ${n.errorsText(i.errors,{separator:"; "})}`}}function Ne(e,t){let r=e.status==="succeeded"?t.validation??ue(e.answer,t.outputSchema):void 0,n=ft(e,r);return{schemaVersion:1,type:"exec.result",runId:t.runId,sessionId:n.sessionId,turnId:n.turnId,status:n.status==="awaiting-user-continuation"?"failed":n.status,...n.status==="succeeded"&&r?.ok?{output:r.value}:{},...n.error?{error:{...n.error}}:{},...t.model?{model:{...t.model}}:{},...t.usage?{usage:{...t.usage}}:{},durationMs:n.durationMs}}function $e(e){return J(e)?e.schemaVersion===1&&e.type==="exec.result"&&typeof e.runId=="string"&&typeof e.sessionId=="string"&&typeof e.turnId=="string"&&typeof e.durationMs=="number"&&Number.isFinite(e.durationMs)&&pt(e.status)&&gt(e.model)&&yt(e.usage)&&ht(e.error):!1}function ft(e,t){return e.status==="awaiting-user-continuation"?{...e,status:"failed",error:e.error??{category:"runtime",code:"INTERACTION_NOT_AVAILABLE",message:"The Runtime requested interaction from a non-interactive Exec host.",retryable:!1}}:e.status!=="succeeded"||!t||t.ok?e:{...e,status:"failed",error:{category:"runtime",code:"STRUCTURED_OUTPUT_INVALID",message:t.message,retryable:!0}}}function Le(e){new ae.Ajv({allErrors:!0,strict:!1}).compile(e)}function pt(e){return e==="succeeded"||e==="failed"||e==="timeout"||e==="cancelled"||e==="limit_exceeded"}function gt(e){return e===void 0?!0:J(e)?typeof e.providerId=="string"&&typeof e.modelId=="string"&&U(e.variant)&&U(e.providerSource)&&U(e.providerKind)&&U(e.protocol)&&(e.structuredOutputMode===void 0||e.structuredOutputMode==="native_strict"):!1}function yt(e){return e===void 0?!0:J(e)?Object.values(e).every(t=>t===void 0||typeof t=="number"&&Number.isFinite(t)):!1}function ht(e){return e===void 0?!0:J(e)?(e.category==="config"||e.category==="runtime"||e.category==="internal")&&U(e.code)&&typeof e.message=="string"&&(e.retryable===void 0||typeof e.retryable=="boolean"):!1}function U(e){return e===void 0||typeof e=="string"}function J(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}import{createHash as wt,randomUUID as Et}from"node:crypto";import{access as Tt,constants as xt,lstat as Ue,mkdir as vt,open as St,readdir as qe,rename as Rt,unlink as It,writeFile as bt}from"node:fs/promises";import{join as X,resolve as Pt}from"node:path";var ce=256*1024,kt=4*1024*1024,Mt=5e3;function He(e){return ve(e.replace(/("(?:authorization|api[-_ ]?key|access[-_ ]?token|refresh[-_ ]?token|token|password|secret)"\s*:\s*)"(?:\\.|[^"\\])*"/giu,'$1"[redacted]"'))}function At(e){if(e.length<=ce)return e;let t=Buffer.from(`
3
3
  [diagnostic answer truncated: middle omitted]
4
4
  `),r=Math.floor((ce-t.length)/2),n=r,i=e.length-r;for(;((e[n]??0)&192)===128;)n-=1;for(;((e[i]??0)&192)===128;)i+=1;return Buffer.concat([e.subarray(0,n),t,e.subarray(i)])}async function Ve(e,t){let r=Pt(t,e);if(await vt(r,{recursive:!0,mode:448}),!(await Ue(r)).isDirectory())throw new Error("Diagnostics path must be a real directory.");if(await Tt(r,xt.W_OK),(await qe(r)).length>0)throw new Error("Diagnostics directory must be empty.");return r}function We(e){return e?wt("sha256").update(JSON.stringify(e)).digest("hex"):void 0}function q(e){return typeof e=="string"?He(e):Array.isArray(e)?e.map(q):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([t,r])=>[t,/^(authorization|api[-_ ]?key|access[-_ ]?token|refresh[-_ ]?token|token|password|secret)$/iu.test(t)?"[redacted]":q(r)])):e}var z=class e{constructor(t,r,n){this.directory=t;this.warn=r;this.progressFile=n}pending=Promise.resolve();bytes=0;droppedEvents=0;closed=!1;failed=!1;static async create(t,r){if((await qe(t)).length>0)throw Object.assign(new Error("Diagnostics directory must be empty."),{code:"EEXIST"});let n=await St(X(t,"progress.jsonl"),"wx",384);return new e(t,r,n)}record(t){if(this.closed)return;let r=`${JSON.stringify(q({timestampMs:Date.now(),...t}))}
5
5
  `,n=Buffer.byteLength(r);if(this.bytes+n>kt){this.droppedEvents+=1;return}this.bytes+=n,this.enqueue(()=>this.progressFile.appendFile(r))}execution(t){this.json("execution.json",{schemaVersion:1,...t})}failure(t,r){let n=Buffer.from(He(t??"")),i=n.length>ce,o=At(n);this.json("failure.json",{schemaVersion:1,...r,answerBytes:Buffer.byteLength(t??""),savedBytes:o.length,truncated:i,redacted:!0}),this.enqueue(()=>this.replaceFile("failure-answer.txt",o))}async flush(t={}){this.enqueue(async()=>{let[i,o]=await Promise.all([Ue(X(this.directory,"progress.jsonl")),this.progressFile.stat()]);if(!i.isFile()||i.ino!==o.ino||i.dev!==o.dev)throw new Error("Diagnostics progress file was replaced.")}),this.enqueue(()=>this.progressFile.close()),this.enqueue(()=>this.replaceFile("diagnostics-status.json",`${JSON.stringify(q({...t,recoveryReady:t.recoveryReady===!0&&!this.failed,diagnosticsComplete:!this.failed,droppedEventCount:this.droppedEvents}),null,2)}
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{f as s}from"./chunks/chunk-FLEWADRD.js";import{u as n,v as a}from"./chunks/chunk-MNN6EKX3.js";import"./chunks/chunk-O6RIRKRN.js";import"./chunks/chunk-HQ2U4QVQ.js";import{n as o,p as i}from"./chunks/chunk-AAJMOWWM.js";import"./chunks/chunk-6BYKHQOV.js";import"./chunks/chunk-2ZG44JU6.js";import"./chunks/chunk-ZITT4GJK.js";import"./chunks/chunk-Y27DNFV2.js";import"./chunks/chunk-CWWDVX6C.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-LETCXX3O.js");o({dataDir:m(),...r?{startupBuildEnvironment:r}:{}});let p=await s();try{let{runTuiCli:e}=await import("./chunks/main-WOL6V5OD.js");await e({allowStartupEnvironmentSelection:t})}finally{p.remove()}}await l();
4
+ `),process.exitCode=1;return}let{getTuiDataDirPath:m}=await import("./chunks/data-dir-LETCXX3O.js");o({dataDir:m(),...r?{startupBuildEnvironment:r}:{}});let p=await s();try{let{runTuiCli:e}=await import("./chunks/main-RHDM3DSB.js");await e({allowStartupEnvironmentSelection:t})}finally{p.remove()}}await l();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minimax-ai/code",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Minimax Code — terminal coding agent",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,2 +0,0 @@
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{b as d}from"./chunk-I3GV76MP.js";var s=class{constructor(t){this.port=t}async snapshot(t={}){let[o,a,i,r]=await Promise.all([this.port.listUserModelProviders(),this.port.getMiniMaxApiKeyStatus(),this.port.getMiniMaxModelSource(),t.includeCodexOAuth?this.port.getCodexOAuthStatus():void 0]);return{minimaxModelSource:i,providers:[...!r||r.state==="hidden"?[]:[n(r)],{providerId:"minimax_oauth",name:"MiniMax OAuth",kind:"minimax-oauth",active:i==="token_plan",enabled:!0,readOnly:!0,hasApiKey:!1,models:[]},{providerId:"minimax_api",name:"MiniMax API Key",kind:"minimax-api-key",active:i==="minimax_api_key",enabled:!0,readOnly:!1,hasApiKey:a.hasApiKey,...a.maskedApiKey?{maskedApiKey:a.maskedApiKey}:{},...a.cachedStatus?{status:a.cachedStatus}:{},models:[]},...o.map(u)]}}setMiniMaxSource(t){return this.port.setMiniMaxModelSource(t)}connectCodexOAuth(){return this.port.startCodexOAuthLogin()}async setMiniMaxApiKey(t,o=!0){await this.port.upsertMiniMaxApiKey({apiKey:t,saveAndUse:o})}async create(t){await this.port.createUserModelProvider(t)}saveCandidate(t){return this.port.saveUserModelProviderCandidate(t)}async update(t){await this.port.updateUserModelProvider(t)}async remove(t){await this.port.deleteUserModelProvider(t)}test(t,o){return o?this.port.testUserModel(t,o):this.port.testUserModelProvider(t)}};function n(e){return{providerId:e.providerId,name:"OpenAI Codex",kind:"codex-oauth",active:!1,enabled:!0,readOnly:!0,hasApiKey:!1,models:[],status:{state:e.state,...e.error?{lastErrorMessage:e.error}:{}}}}function u(e){let t=d(e.apiFormat)?e.apiFormat:void 0;return{providerId:e.providerId,name:e.name?.trim()||e.providerId,kind:"custom",active:!!(e.enabled!==!1&&e.models?.some(o=>"selected"in o&&o.selected)),enabled:e.enabled!==!1,readOnly:!1,...t?{apiFormat:t}:{},...e.baseUrl?{baseUrl:e.baseUrl}:{},hasApiKey:!!e.hasApiKey,...e.maskedApiKey?{maskedApiKey:e.maskedApiKey}:{},models:(e.models??[]).map(o=>({modelId:o.modelId,...o.displayName?{displayName:o.displayName}:{},...o.selected!==void 0?{selected:o.selected}:{},...o.status?{status:o.status}:{}})),...e.status?{status:e.status}:{}}}export{s as a};
@@ -1,13 +0,0 @@
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 v}from"./chunk-PWQHCWDV.js";import{c as x}from"./chunk-2UWBSJDH.js";import{d as $,l as T,o as C}from"./chunk-GUFBGYOC.js";import{a as _}from"./chunk-WFWSBUYD.js";function J(o,n){let l={v:1,id:o};return n&&(l.phase=n),JSON.stringify(l)}function P(o){if(o){if(o.startsWith("{"))try{let n=JSON.parse(o);if(n.v===1&&typeof n.id=="string")return n.phase==="commentary"||n.phase==="final_answer"?{id:n.id,phase:n.phase}:{id:n.id}}catch{}return{id:o}}}function W(o,n,l,y){let d=[],i=e=>{let a=e.replace(/[^a-zA-Z0-9_-]/g,"_");return(a.length>64?a.slice(0,64):a).replace(/_+$/,"")},s=e=>{let a=`fc_${v(e)}`;return a.length>64?a.slice(0,64):a},k=(e,a,r)=>{if(!l.has(o.provider)||!e.includes("|"))return i(e);let[m,h]=e.split("|"),u=i(m),f=r.provider!==o.provider||r.api!==o.api?s(h):i(h);return f.startsWith("fc_")||(f=i(`fc_${f}`)),`${u}|${f}`},c=C(n.messages,o,k);if((y?.includeSystemPrompt??!0)&&n.systemPrompt){let e=o.compat,a=o.reasoning&&e?.supportsDeveloperRole!==!1?"developer":"system";d.push({role:a,content:_(n.systemPrompt)})}let t=0;for(let e of c){if(e.role==="user")if(typeof e.content=="string")d.push({role:"user",content:[{type:"input_text",text:_(e.content)}]});else{let a=e.content.map(r=>r.type==="text"?{type:"input_text",text:_(r.text)}:{type:"input_image",detail:"auto",image_url:`data:${r.mimeType};base64,${r.data}`});if(a.length===0)continue;d.push({role:"user",content:a})}else if(e.role==="assistant"){let a=[],r=e,m=r.model!==o.id&&r.provider===o.provider&&r.api===o.api,h=0;for(let u of e.content)if(u.type==="thinking"){if(u.thinkingSignature){let p=JSON.parse(u.thinkingSignature);a.push(p)}}else if(u.type==="text"){let p=u,f=P(p.textSignature),I=h===0?`msg_pi_${t}`:`msg_pi_${t}_${h}`;h++;let g=f?.id;g?g.length>64&&(g=`msg_${v(g)}`):g=I,a.push({type:"message",role:"assistant",content:[{type:"output_text",text:_(p.text),annotations:[]}],status:"completed",id:g,phase:f?.phase})}else if(u.type==="toolCall"){let p=u,[f,I]=p.id.split("|"),g=I;m&&g?.startsWith("fc_")&&(g=void 0),a.push({type:"function_call",id:g,call_id:f,name:p.name,arguments:JSON.stringify(p.arguments)})}if(a.length===0)continue;d.push(...a)}else if(e.role==="toolResult"){let a=e.content.filter(p=>p.type==="text").map(p=>p.text).join(`
3
- `),r=e.content.some(p=>p.type==="image"),m=a.length>0,[h]=e.toolCallId.split("|"),u;if(r&&o.input.includes("image")){let p=[];m&&p.push({type:"input_text",text:_(a)});for(let f of e.content)f.type==="image"&&p.push({type:"input_image",detail:"auto",image_url:`data:${f.mimeType};base64,${f.data}`});u=p}else u=_(m?a:"(see attached image)");d.push({type:"function_call_output",call_id:h,output:u})}t++}return d}function N(o,n){let l=n?.strict===void 0?!1:n.strict;return o.map(y=>({type:"function",name:y.name,description:y.description,parameters:y.parameters,strict:l}))}async function j(o,n,l,y,d){let i=null,s=null,k=n.content,c=()=>k.length-1,S=T(o,d?.onProviderStreamEvent,y);for await(let t of S)if(t.type==="response.created")n.responseId=t.response.id;else if(t.type==="response.output_item.added"){let e=t.item;e.type==="reasoning"?(i=e,s={type:"thinking",thinking:""},n.content.push(s),l.push({type:"thinking_start",contentIndex:c(),partial:n})):e.type==="message"?(i=e,s={type:"text",text:""},n.content.push(s),l.push({type:"text_start",contentIndex:c(),partial:n})):e.type==="function_call"&&(i=e,s={type:"toolCall",id:`${e.call_id}|${e.id}`,name:e.name,arguments:{},partialJson:e.arguments||""},n.content.push(s),l.push({type:"toolcall_start",contentIndex:c(),partial:n}))}else if(t.type==="response.reasoning_summary_part.added")i&&i.type==="reasoning"&&(i.summary=i.summary||[],i.summary.push(t.part));else if(t.type==="response.reasoning_summary_text.delta"){if(i?.type==="reasoning"&&s?.type==="thinking"){i.summary=i.summary||[];let e=i.summary[i.summary.length-1];e&&(s.thinking+=t.delta,e.text+=t.delta,l.push({type:"thinking_delta",contentIndex:c(),delta:t.delta,partial:n}))}}else if(t.type==="response.reasoning_summary_part.done"){if(i?.type==="reasoning"&&s?.type==="thinking"){i.summary=i.summary||[];let e=i.summary[i.summary.length-1];e&&(s.thinking+=`
4
-
5
- `,e.text+=`
6
-
7
- `,l.push({type:"thinking_delta",contentIndex:c(),delta:`
8
-
9
- `,partial:n}))}}else if(t.type==="response.reasoning_text.delta")i?.type==="reasoning"&&s?.type==="thinking"&&(s.thinking+=t.delta,l.push({type:"thinking_delta",contentIndex:c(),delta:t.delta,partial:n}));else if(t.type==="response.content_part.added")i?.type==="message"&&(i.content=i.content||[],(t.part.type==="output_text"||t.part.type==="refusal")&&i.content.push(t.part));else if(t.type==="response.output_text.delta"){if(i?.type==="message"&&s?.type==="text"){if(!i.content||i.content.length===0)continue;let e=i.content[i.content.length-1];e?.type==="output_text"&&(s.text+=t.delta,e.text+=t.delta,l.push({type:"text_delta",contentIndex:c(),delta:t.delta,partial:n}))}}else if(t.type==="response.refusal.delta"){if(i?.type==="message"&&s?.type==="text"){if(!i.content||i.content.length===0)continue;let e=i.content[i.content.length-1];e?.type==="refusal"&&(s.text+=t.delta,e.refusal+=t.delta,l.push({type:"text_delta",contentIndex:c(),delta:t.delta,partial:n}))}}else if(t.type==="response.function_call_arguments.delta")i?.type==="function_call"&&s?.type==="toolCall"&&(s.partialJson+=t.delta,s.arguments=x(s.partialJson),l.push({type:"toolcall_delta",contentIndex:c(),delta:t.delta,partial:n}));else if(t.type==="response.function_call_arguments.done"){if(i?.type==="function_call"&&s?.type==="toolCall"){let e=s.partialJson;if(s.partialJson=t.arguments,s.arguments=x(s.partialJson),t.arguments.startsWith(e)){let a=t.arguments.slice(e.length);a.length>0&&l.push({type:"toolcall_delta",contentIndex:c(),delta:a,partial:n})}}}else if(t.type==="response.output_item.done"){let e=t.item;if(e.type==="reasoning"&&s?.type==="thinking"){let a=e.summary?.map(m=>m.text).join(`
10
-
11
- `)||"",r=e.content?.map(m=>m.text).join(`
12
-
13
- `)||"";s.thinking=a||r||s.thinking,s.thinkingSignature=JSON.stringify(e),l.push({type:"thinking_end",contentIndex:c(),content:s.thinking,partial:n}),s=null}else if(e.type==="message"&&s?.type==="text")s.text=e.content.map(a=>a.type==="output_text"?a.text:a.refusal).join(""),s.textSignature=J(e.id,e.phase??void 0),l.push({type:"text_end",contentIndex:c(),content:s.text,partial:n}),s=null;else if(e.type==="function_call"){let a=s?.type==="toolCall"&&s.partialJson?x(s.partialJson):x(e.arguments||"{}"),r;s?.type==="toolCall"?(s.arguments=a,delete s.partialJson,r=s):r={type:"toolCall",id:`${e.call_id}|${e.id}`,name:e.name,arguments:a},s=null,l.push({type:"toolcall_end",contentIndex:c(),toolCall:r,partial:n})}}else if(t.type==="response.completed"){let e=t.response;if(e?.id&&(n.responseId=e.id),e?.usage){let a=e.usage.input_tokens_details?.cached_tokens||0;n.usage={input:(e.usage.input_tokens||0)-a,output:e.usage.output_tokens||0,cacheRead:a,cacheWrite:0,totalTokens:e.usage.total_tokens||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}}}if($(y,n.usage),d?.applyServiceTierPricing){let a=d.resolveServiceTier?d.resolveServiceTier(e?.service_tier,d.serviceTier):e?.service_tier??d.serviceTier;d.applyServiceTierPricing(n.usage,a)}n.stopReason=w(e?.status),n.content.some(a=>a.type==="toolCall")&&n.stopReason==="stop"&&(n.stopReason="toolUse")}else{if(t.type==="error")throw new Error(`Error Code ${t.code}: ${t.message}`||"Unknown error");if(t.type==="response.failed"){let e=t.response?.error,a=t.response?.incomplete_details,r=e?`${e.code||"unknown"}: ${e.message||"no message"}`:a?.reason?`incomplete: ${a.reason}`:"Unknown error (no error details in response)";throw new Error(r)}}}function w(o){if(!o)return"stop";switch(o){case"completed":return"stop";case"incomplete":return"length";case"failed":case"cancelled":return"error";case"in_progress":case"queued":return"stop";default:{let n=o;throw new Error(`Unhandled stop reason: ${n}`)}}}export{W as a,N as b,j as c};