@kodax-ai/kodax 0.7.51 → 0.7.52

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 (37) hide show
  1. package/CHANGELOG.md +20 -6
  2. package/dist/chunks/{agent-EFA7BSE7.js → agent-XXTR7T37.js} +1 -1
  3. package/dist/chunks/{argument-completer-MAJVHSE7.js → argument-completer-VMH6VZ4X.js} +1 -1
  4. package/dist/chunks/{chunk-E3HENKTX.js → chunk-4RVSFOUT.js} +3 -3
  5. package/dist/chunks/{chunk-WQTVG2T5.js → chunk-5USNUSTL.js} +3 -3
  6. package/dist/chunks/{chunk-ODVA5VTE.js → chunk-7X7SOVER.js} +2 -2
  7. package/dist/chunks/{chunk-CCZMQE3Q.js → chunk-BFXFSEHK.js} +1 -1
  8. package/dist/chunks/chunk-LE6STNVN.js +31 -0
  9. package/dist/chunks/{chunk-FAIGYAEX.js → chunk-MFPYZT52.js} +4 -4
  10. package/dist/chunks/{construction-bootstrap-WY5MDXRX.js → construction-bootstrap-BXRMA3KL.js} +1 -1
  11. package/dist/chunks/{dist-BTWS2ENP.js → dist-IHH4BYIU.js} +1 -1
  12. package/dist/chunks/{dist-B73FQEAA.js → dist-Z6U7TWKJ.js} +1 -1
  13. package/dist/chunks/{utils-HVOJRR5C.js → utils-6WZHBMCC.js} +1 -1
  14. package/dist/index.d.ts +10 -10
  15. package/dist/index.js +1 -1
  16. package/dist/kodax_cli.js +628 -628
  17. package/dist/sdk-agent.d.ts +8 -8
  18. package/dist/sdk-coding.d.ts +12 -12
  19. package/dist/sdk-coding.js +1 -1
  20. package/dist/sdk-llm.d.ts +3 -3
  21. package/dist/sdk-llm.js +1 -1
  22. package/dist/sdk-repl.d.ts +10 -10
  23. package/dist/sdk-repl.js +1 -1
  24. package/dist/sdk-session.d.ts +5 -5
  25. package/dist/sdk-session.js +1 -1
  26. package/dist/types-chunks/{base.d-GZ6jvICS.d.ts → base.d-BBNUF9nz.d.ts} +1 -0
  27. package/dist/types-chunks/{bash-prefix-extractor.d-DTOiDMlG.d.ts → bash-prefix-extractor.d-DBFZEwop.d.ts} +2 -2
  28. package/dist/types-chunks/{capsule.d-CXGdLGAn.d.ts → capsule.d-CNonpwAZ.d.ts} +3 -3
  29. package/dist/types-chunks/{guardrail.d-D47yu9AO.d.ts → guardrail.d-B18oO1gt.d.ts} +3 -3
  30. package/dist/types-chunks/{process.d-B8kEBnQD.d.ts → process.d-Bj82oJhD.d.ts} +1 -1
  31. package/dist/types-chunks/{resolver.d-D75XFRH2.d.ts → resolver.d-CCX9NXWP.d.ts} +2 -1
  32. package/dist/types-chunks/{sdk-session-BKQJN9oH.d.ts → sdk-session-D4tqRl0_.d.ts} +4 -4
  33. package/dist/types-chunks/{storage.d-BN1xIn8R.d.ts → storage.d-CabW10Nt.d.ts} +2 -2
  34. package/dist/types-chunks/{types.d-DQ_hdN70.d.ts → types.d-D4jL-gAA.d.ts} +1 -1
  35. package/dist/types-chunks/{utils.d-ZfRDo-kX.d.ts → utils.d-23Gn14zP.d.ts} +5 -5
  36. package/package.json +2 -2
  37. package/dist/chunks/chunk-PEWH3AAL.js +0 -31
@@ -1,5 +1,5 @@
1
1
  // @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
2
- import{A as mr,B as gr,C as pr,j as lr,l as Ie,m as mn,n as cr,o as dr,p as ur,q as gn,s as pn,t as wn,u as fr,w as ko,y as pe}from"./chunk-CCZMQE3Q.js";import{a as wr}from"./chunk-JJTUBNQX.js";import{Ja as er,Ma as ge,Qa as Te,Sa as Be,Ta as ho,Ua as or,Va as nr,Xa as tr,Ya as fn,Za as rr,_a as qe,ab as Ee,cb as sr,lb as yo,mb as ir,sb as ar,tb as ze}from"./chunk-E3HENKTX.js";import{Hd as Zt,Jd as Qt,Wc as Z,Yc as Gt,Z as zt,Zc as Xt,aa as He,ba as Kt,nd as Vt,pd as Yt,qd as Jt,td as un,v as qt}from"./chunk-WQTVG2T5.js";import{j as an,sa as Wt,ta as xe,ua as Ae}from"./chunk-PEWH3AAL.js";import{Zc as Re,_c as Ht,cc as Dt,dc as Ut,ec as Ft,k as ln,nd as Bt,rc as cn,sb as Lt,sc as dn,tb as Ot,va as po,wa as N,xb as Nt,xc as jt,xd as wo}from"./chunk-HMATTIU6.js";import{a,b as sn,c as wi}from"./chunk-V4WSBIXB.js";var xr=sn((yd,br)=>{"use strict";br.exports=a(function(o){return o.map(function(n){return n===""?"''":n&&typeof n=="object"?n.op.replace(/(.)/g,"\\$1"):/["\s\\]/.test(n)&&!/'/.test(n)?"'"+n.replace(/(['])/g,"\\$1")+"'":/["'\s]/.test(n)?'"'+n.replace(/(["\\$`!])/g,"\\$1")+'"':String(n).replace(/([A-Za-z]:)?([#!"$&'()*,:;<=>?@[\\\]^`{|}])/g,"$1\\$2")}).join(" ")},"quote")});var _r=sn((vd,Cr)=>{"use strict";var Ir="(?:"+["\\|\\|","\\&\\&",";;","\\|\\&","\\<\\(","\\<\\<\\<",">>",">\\&","<\\&","[&;()|<>]"].join("|")+")",Ar=new RegExp("^"+Ir+"$"),Rr="|&;()<> \\t",ki='"((\\\\"|[^"])*?)"',vi="'((\\\\'|[^'])*?)'",Si=/^#$/,Tr="'",Er='"',hn="$",we="",$i=4294967296;for(yn=0;yn<4;yn++)we+=($i*Math.random()).toString(16);var yn,bi=new RegExp("^"+we);function xi(e,o){for(var n=o.lastIndex,t=[],r;r=o.exec(e);)t.push(r),o.lastIndex===r.index&&(o.lastIndex+=1);return o.lastIndex=n,t}a(xi,"matchAll");function Ai(e,o,n){var t=typeof e=="function"?e(n):e[n];return typeof t>"u"&&n!=""?t="":typeof t>"u"&&(t="$"),typeof t=="object"?o+we+JSON.stringify(t)+we:o+t}a(Ai,"getVar");function Ri(e,o,n){n||(n={});var t=n.escape||"\\",r="(\\"+t+`['"`+Rr+`]|[^\\s'"`+Rr+"])+",i=new RegExp(["("+Ir+")","("+r+"|"+ki+"|"+vi+")+"].join("|"),"g"),l=xi(e,i);if(l.length===0)return[];o||(o={});var c=!1;return l.map(function(d){var u=d[0];if(!u||c)return;if(Ar.test(u))return{op:u};var w=!1,f=!1,k="",v=!1,h;function y(){h+=1;var A,j,H=u.charAt(h);if(H==="{"){if(h+=1,u.charAt(h)==="}")throw new Error("Bad substitution: "+u.slice(h-2,h+1));if(A=u.indexOf("}",h),A<0)throw new Error("Bad substitution: "+u.slice(h));j=u.slice(h,A),h=A}else if(/[*@#?$!_-]/.test(H))j=H,h+=1;else{var G=u.slice(h);A=G.match(/[^\w\d_]/),A?(j=G.slice(0,A.index),h+=A.index-1):(j=G,h=u.length)}return Ai(o,"",j)}for(a(y,"parseEnvVar"),h=0;h<u.length;h++){var m=u.charAt(h);if(v=v||!w&&(m==="*"||m==="?"),f)k+=m,f=!1;else if(w)m===w?w=!1:w==Tr?k+=m:m===t?(h+=1,m=u.charAt(h),m===Er||m===t||m===hn?k+=m:k+=t+m):m===hn?k+=y():k+=m;else if(m===Er||m===Tr)w=m;else{if(Ar.test(m))return{op:u};if(Si.test(m)){c=!0;var x={comment:e.slice(d.index+h+1)};return k.length?[k,x]:[x]}else m===t?f=!0:m===hn?k+=y():k+=m}}return v?{op:"glob",pattern:k}:k}).reduce(function(d,u){return typeof u>"u"?d:d.concat(u)},[])}a(Ri,"parseInternal");Cr.exports=a(function(o,n,t){var r=Ri(o,n,t);return typeof n!="function"?r:r.reduce(function(i,l){if(typeof l=="object")return i.concat(l);var c=l.split(RegExp("("+we+".*?"+we+")","g"));return c.length===1?i.concat(c[0]):i.concat(c.filter(Boolean).map(function(d){return bi.test(d)?JSON.parse(d.split(we)[1]):d}))},[])},"parse")});var Pr=sn(kn=>{"use strict";kn.quote=xr();kn.parse=_r()});import*as Zo from"fs";import*as uo from"path";import s from"chalk";var vo=["plan","accept-edits","auto","auto-in-project"];function gd(e){return e==="auto"||e==="auto-in-project"}a(gd,"isAutoMode");function hi(e){switch(e){case"plan":return"Plan";case"accept-edits":return"Edits";case"auto":case"auto-in-project":return"Auto"}}a(hi,"permissionModeDisplayName");var yi='[deprecated] permissionMode "auto-in-project" is now an alias for "auto" (FEATURE_092, v0.7.33). The alias will be removed in v0.7.38 \u2014 please update ~/.kodax/config.json to use "auto".';function pd(e=console.warn){let o=!1;return()=>{o||(o=!0,e(yi))}}a(pd,"createAutoInProjectDeprecationEmitter");var hr=Zt(),Ke=new Set(hr.filter(e=>e.sideEffect==="mutates-fs"&&e.requiredParams.includes("path")).map(e=>e.name)),yr=new Set(hr.filter(e=>e.sideEffect!=="readonly").map(e=>e.name)),kr=new Set(["npm install","npm i","npm uninstall","npm remove","npm update","npm ci","yarn add","yarn remove","yarn upgrade","pnpm add","pnpm remove","pnpm update","git clean","git reset","git checkout","git switch","git merge","git rebase","git cherry-pick","git revert","git commit","git push","git pull","rm","mv","cp","mkdir","rmdir","touch","chmod","chown","del","erase","rd","copy","move","ren","curl","wget","dd","tar","kill","pkill","killall"]),vr=new Set(["ls","cat","pwd","echo","whoami","date","which","whereis","tree","dir","type","get-childitem","get-content","select-string","get-location","where","grep","find","awk","sed","head","tail","less","more","wc","findstr","fc","git status","git diff","git log","git show","git branch","git remote","git ls-files","git rev-parse","git grep","git tag","git stash list","git describe","git config --get","node","npm","yarn","pnpm","tsc","python","pip","go","cargo","rustc"]);function Sr(e){switch(e){case"plan":return new Set(["bash","write","edit","undo"]);case"accept-edits":return new Set(["bash"]);case"auto":case"auto-in-project":return new Set}}a(Sr,"computeConfirmTools");function $r(e){return e!==void 0&&vo.includes(e)}a($r,"isPermissionMode");function Ge(e,o){return $r(e)?e:o}a(Ge,"normalizePermissionMode");import Ro from"fs";import Kr from"path";import So from"fs";import P from"path";import Ve from"os";var Lr=wi(Pr(),1);var Mr=new Set(["/dev/null","nul","NUL"]);function vn(e){return Mr.has(e)||Mr.has(e.toLowerCase())}a(vn,"isNullDevice");function Xe(e){let o=e.trim();if(!o)return{statements:[],unparseable:!1};if(o.includes("`"))return{statements:[],unparseable:!0};let n;try{n=(0,Lr.parse)(o)}catch{return{statements:[],unparseable:!0}}let t=[],r=[],i=[],l=[],c=null,d=!1,u=a(()=>{(i.length>0||l.length>0)&&(r.push({argv:i,redirections:l}),i=[],l=[])},"flushStage"),w=a(f=>{u(),r.length>0&&(t.push({precedingOp:c,stages:r}),r=[]),c=f},"flushStatement");for(let f=0;f<n.length;f+=1){let k=n[f];if(typeof k=="string"){i.push(k);continue}if("op"in k){let v=k.op;if(v==="&&"||v==="||"||v===";"){w(v);continue}if(v==="|"){u();continue}if(v==="&"){let h=n[f+1];if(h!==void 0&&typeof h!="string"&&"op"in h&&(h.op===">"||h.op===">>")){let y=n[f+2];if(typeof y!="string"){d=!0,f+=1;continue}l.push(Wr(`&${h.op}`,y)),f+=2;continue}d=!0;continue}if(Ei(v)){let h=null,y=i[i.length-1];y!==void 0&&/^[0-9]+$/.test(y)&&(h=y,i.pop());let m=n[f+1];if(typeof m!="string"){d=!0;continue}l.push(Wr(h?`${h}${v}`:v,m)),f+=1;continue}if(v==="glob"){let h=k.pattern;typeof h=="string"?i.push(h):d=!0;continue}d=!0;continue}if("comment"in k)break;d=!0}return w(null),{statements:t,unparseable:d}}a(Xe,"parseBashCommand");var Ti=new Set([">",">>","<","<<","<<<","&>","&>>"]),Or=/^([0-9]+|&)(>>?|<<?)$/;function Ei(e){return Ti.has(e)||Or.test(e)}a(Ei,"isRedirectionOp");function Wr(e,o){let n=null,t=e,r=Or.exec(e);return r&&(n=r[1],t=r[2]),{op:e,fd:n,append:t===">>"||e==="&>>",input:t==="<"||t==="<<"||e==="<<<",target:o}}a(Wr,"parseRedirection");var Ii=P.join(".agent","plan_mode_doc.md"),$o=new Map,bo=null;function Ci(e){if(!e||!e.trim())return!1;let o=e.trim().replace(/\s+/g," ").toLowerCase();for(let n of vr)if(o===n||o.startsWith(n+" ")){if(n==="sed"&&o.split(/\s+/).some(i=>i.startsWith("-i")||i==="--in-place"))return!1;if(n==="awk"){let r=o.split(/\s+/);if(r.includes("-f")||r.includes("--file"))return!1}if(["node","npm","yarn","pnpm","tsc","python","pip","go","cargo","rustc","ruby","perl"].includes(n)){let r=o.split(/\s+/).slice(1);if(r.length>0&&!r.every(i=>/^(-v|--version|-h|--help)$/.test(i)))return!1}return!0}return!1}a(Ci,"isSingleBashReadCommand");var _i=/^[a-zA-Z0-9]+$/;function Pi(e){let o=e.trim();if(!o.endsWith("--help")||o.includes('"')||o.includes("'"))return!1;let n=!1;for(let t of o.split(/\s+/))if(t.startsWith("-"))if(t==="--help")n=!0;else return!1;else if(!_i.test(t))return!1;return n}a(Pi,"isHelpCommand");function $n(e){if(!e||!e.trim())return!1;if(Pi(e))return!0;let o=e.trim().replace(/\\\r?\n/g," "),n=Xe(o);if(n.unparseable||n.statements.length===0)return!1;let t=n.statements.length>1||(n.statements[0]?.stages.length??0)>1;for(let r of n.statements){if(r.precedingOp!==null&&r.precedingOp!=="&&")return!1;for(let i of r.stages){for(let c of i.redirections)if(c.input||!vn(c.target))return!1;let l=i.argv.join(" ");if(l&&!(t&&i.argv[0]?.toLowerCase()==="cd"&&i.argv.length>=2)&&!Ci(l))return!1}}return!0}a($n,"isBashReadCommand");function Mi(e){let o=e.trim();return o?$n(o)?null:"[Blocked] Direct !command execution only supports safe read-only commands. Use the bash tool for commands that write files, invoke shells, or require confirmation.":"[Shell: No command provided]"}a(Mi,"getDirectShellBypassBlockReason");var Dr=new Set(["remove-item","set-content","add-content","out-file","new-item","copy-item","move-item","rename-item","ni"]);function bn(e){if(!e||!e.trim())return!1;let o=Xe(e);if(o.unparseable)return!1;for(let n of o.statements)for(let t of n.stages){let r=t.argv.map(i=>i.toLowerCase());if(r.length>0){let i=r[0],l=r.length>=2?`${r[0]} ${r[1]}`:null;for(let c of kr)if(c===i||l!==null&&c===l)return!0}for(let i of r)if(Dr.has(i))return!0;for(let i of t.redirections)if(!i.input&&!vn(i.target))return!0}return!1}a(bn,"isBashWriteCommand");function xn(e){let o=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\((.+)\)$/);return o?{tool:o[1].toLowerCase(),pattern:o[2]}:{tool:e.toLowerCase(),pattern:null}}a(xn,"parseAllowedToolPattern");function Wi(e,o){if(o==="*")return!1;if(o.endsWith(":*")){let n=o.slice(0,-2);return e.startsWith(n)}return e===o}a(Wi,"matchesBashPatternLegacy");function Li(e,o){if(o==="*")return!1;if(o.endsWith(":*")){let n=o.slice(0,-2);return e===n}return e===o}a(Li,"matchesBashPatternByExtractedPrefix");async function An(e,o,n,t,r){if(e.toLowerCase()!=="bash")return!1;let i=o.command??"",l=[];for(let c of n){let d=xn(c);if(d.tool==="bash"){if(d.pattern===null)return!0;l.push({pattern:d.pattern})}}if(l.length===0)return!1;if(t){let c;try{c=await t.extract(i,r)}catch{return!1}if(c.kind!=="prefix")return!1;for(let{pattern:d}of l)if(d&&Li(c.value,d))return!0;return!1}for(let{pattern:c}of l)if(c&&Wi(i,c))return!0;return!1}a(An,"isToolCallAllowed");function Rn(e,o,n){if(e.toLowerCase()!=="bash")return"";let t=o.command??"",r=t.split(" ");return r.length>1?`Bash(${r.slice(0,2).join(" ")}:*)`:`Bash(${t})`}a(Rn,"generateSavePattern");function Ye(e,o){try{let n=P.resolve(e),t=P.resolve(o),r=po(),i=P.join(t,".kodax");return Ce(n,i)||Ce(n,r)?!0:!(Ce(n,t)||jr().some(c=>Ce(n,c)))}catch{return!1}}a(Ye,"isAlwaysConfirmPath");function Nr(e){return!e||e.startsWith("-")?!1:/^\.\.?[/\\]/.test(e)||e.startsWith("~/")||e.startsWith("~\\")||/^[a-zA-Z]:[/\\]/.test(e)?!0:e.startsWith("/")&&e.length>1?!(process.platform==="win32"&&Oi.test(e)):!!(e.startsWith(".")&&/[/\\]/.test(e))}a(Nr,"looksLikePath");var Oi=/^\/[A-Za-z][A-Za-z0-9]*(?::[A-Za-z0-9]+)?$/;function Ni(e){let o=[],n=/["']([^"']+)["']/g,t;for(;(t=n.exec(e))!==null;)o.push(t[1]);let r=/(?:^|\s)(\.\.?\/[^\s]+|\.\.?\\[^\s]+|[a-zA-Z]:\\[^\s]+|~\/[^\s]+|\.[^\s]*[/\\][^\s]*)/g;for(;(t=r.exec(e))!==null;)o.push(t[1]);return o}a(Ni,"legacyRegexPathScan");function Ao(e){let o=new Set,n=Xe(e);if(!n.unparseable)for(let t of n.statements)for(let r of t.stages){for(let i of r.argv)Nr(i)&&o.add(i);for(let i of r.redirections)Nr(i.target)&&o.add(i.target)}for(let t of Ni(e))o.add(t);return Array.from(o)}a(Ao,"extractPathsFromCommand");function Di(e,o){let n=Ao(e);for(let t of n)if(Ye(t,o))return!0;return!1}a(Di,"isCommandOnProtectedPath");function xo(e){let o=P.normalize(e);return process.platform==="win32"?o.toLowerCase():o}a(xo,"normalizePathForComparison");function Ui(e,o){return xo(e)===xo(o)}a(Ui,"pathsEqual");function Ce(e,o){let n=xo(e),t=xo(o);return n===t||n.startsWith(t+P.sep)}a(Ce,"isPathInsideDirectory");function Tn(e,o){try{let n=P.resolve(o),t=P.resolve(n,Fr(Ur(e)));return Ce(t,n)}catch{return!1}}a(Tn,"isPathInsideProject");function Fi(e){let o=e.match(/[A-Za-z]:[\\/][^\s;|&<>(){}'"]+|\/[^\s;|&<>(){}'"]+/g);return o?o.filter(n=>!/^(?:\/dev\/|\/proc\/)/i.test(n)):[]}a(Fi,"collectAbsolutePathCandidates");function En(e){let o=P.resolve(e),n=$o.get(o);if(n)return n;if(So.existsSync(o)){let c=So.realpathSync.native(o);return $o.set(o,c),c}let t=[],r=o;for(;!So.existsSync(r);){let c=P.dirname(r);if(c===r)return $o.set(o,o),o;t.unshift(P.basename(r)),r=c}let i=So.realpathSync.native(r),l=P.join(i,...t);return $o.set(o,l),l}a(En,"resolveExistingPathPrefix");function Ur(e){return e==="~"?Ve.homedir():e.startsWith(`~${P.sep}`)||e.startsWith("~/")||e.startsWith("~\\")?P.join(Ve.homedir(),e.slice(2)):e}a(Ur,"expandHomeDirectory");function Fr(e){let o=Ve.tmpdir(),n=[[/^%temp%/i,o],[/^%tmp%/i,o],[/^\$env:temp\b/i,o],[/^\$env:tmp\b/i,o],[/^\$tmpdir\b/i,o],[/^\$temp\b/i,o],[/^\$tmp\b/i,o]];for(let[t,r]of n)if(t.test(e))return e.replace(t,r);return e}a(Fr,"expandSystemTempAlias");function ji(e,o){let n=P.resolve(o??process.cwd()),t=Fr(Ur(e)),r=P.isAbsolute(t)?P.resolve(t):P.resolve(n,t);return En(r)}a(ji,"resolvePermissionPath");function jr(){if(bo)return bo;let e=new Set,o=[Ve.tmpdir(),process.env.TEMP,process.env.TMP,process.env.TMPDIR].filter(n=>typeof n=="string"&&n.trim().length>0);for(let n of o)try{e.add(En(n))}catch{}return bo=Array.from(e),bo}a(jr,"getSystemTempDirectories");function In(e){let o=En(e??process.cwd());return{projectPlanDoc:P.join(o,Ii),systemTempDirs:jr()}}a(In,"getPlanModeAllowedWritablePaths");function Sn(e,o){let n=ji(e,o),{projectPlanDoc:t,systemTempDirs:r}=In(o);return Ui(n,t)?!0:r.some(i=>Ce(n,i))}a(Sn,"isPlanModeAllowedPath");function Hi(e){let{projectPlanDoc:o,systemTempDirs:n}=In(e),t=n[0]??Ve.tmpdir();return`${o} or the system temp directory (${t})`}a(Hi,"formatPlanModeAllowedLocations");var Bi=new Set(["-a","--append","-i","--ignore-interrupts"]);function qi(e){let o=[];for(let n=1;n<e.argv.length;n+=1){let t=e.argv[n];Bi.has(t)||t.startsWith("-")||o.push(t)}return o}a(qi,"collectTeeTargets");function zi(e){let o=[],n=1,t=!1;for(;n<e.argv.length;){let r=e.argv[n],i=r.toLowerCase();if(i==="-path"||i==="-literalpath"||i==="-destination"){let l=e.argv[n+1];if(l!==void 0&&!l.startsWith("-")){o.push(l),n+=2;continue}}!r.startsWith("-")&&!t&&(o.push(r),t=!0),n+=1}return o}a(zi,"collectPowerShellWriteTargets");function _e(e){let o=new Set,n=a(r=>{let i=r?.trim();i&&o.add(i)},"pushTarget");for(let r of Ao(e))n(r);let t=Xe(e);if(t.unparseable)return Array.from(o);for(let r of t.statements)for(let i of r.stages){for(let c of i.redirections)c.input||n(c.target);let l=i.argv[0]?.toLowerCase();if(l){if(l==="tee")for(let c of qi(i))n(c);else if(Dr.has(l))for(let c of zi(i))n(c)}}return Array.from(o)}a(_e,"collectBashWriteTargets");function Hr(e,o){if(!bn(e))return{dangerous:!1};let n=new Set([..._e(e),...Fi(e)]);for(let t of n)if(!Tn(t,o))return{dangerous:!0,reason:`Command may modify file outside project: ${t}`};return{dangerous:!1}}a(Hr,"getBashOutsideProjectWriteRisk");function Br(e,o,n){let t=Hi(n);if(Qt(e))return null;if(Ke.has(e)){let r=typeof o.path=="string"?o.path:"";return r?Sn(r,n)?null:`[Blocked] Plan mode only allows file modifications in ${t}. Requested path: ${r}`:`[Blocked] Tool '${e}' is not allowed in plan mode unless it targets ${t}.`}if(e==="bash"){let r=o.command??"";if(!bn(r))return null;let i=_e(r);if(i.length===0)return`[Blocked] Plan mode only allows bash write operations when every target is either ${t}. Could not determine a safe target from: ${r.slice(0,80)}${r.length>80?"...":""}`;let l=i.find(c=>!Sn(c,n));return l?`[Blocked] Plan mode only allows bash write operations in ${t}. Blocked target: ${l}`:null}return`[Blocked] Tool '${e}' has side effects and is not permitted in plan mode. Switch to accept-edits or auto mode to use it, or work within ${t}.`}a(Br,"getPlanModeBlockReason");import ae from"node:path";import Ki from"node:os";function Pe(e,o){try{let n=ae.resolve(e),t=ae.resolve(o);return n===t?!0:n.startsWith(t+ae.sep)}catch{return!1}}a(Pe,"isPathUnder");function Gi(){try{return po()}catch{return}}a(Gi,"safeGetAgentConfigHome");function qr(e,o){let n=Gi();if(n&&Pe(e,n))return"user-kodax";let t=ae.join(ae.resolve(o),".kodax");if(Pe(e,t))return"project-kodax"}a(qr,"resolveProtectedZone");function Xi(){let e=new Set;try{e.add(Ki.tmpdir())}catch{}for(let o of["TEMP","TMP","TMPDIR"]){let n=process.env[o];n&&n.length>0&&e.add(n)}return Array.from(e)}a(Xi,"getSystemTempDirs");var Vi=new Set(["bash"]),Yi={toolNames:Vi,collect(e,o){let n=typeof e.input.command=="string"?e.input.command:"";if(!n||!o)return[];let t=[],r=new Set,i=new Set,l=Xi(),c=ae.resolve(o);for(let d of Ao(n)){let u;try{u=ae.resolve(o,d)}catch{continue}let w=qr(u,o);if(w){r.has(u)||(r.add(u),t.push({kind:"protected_path",path:d,zone:w}));continue}if(Ye(d,o)){let f=l.some(v=>Pe(u,v)),k=Pe(u,c);!f&&!k&&!i.has(u)&&(i.add(u),t.push({kind:"outside_project",path:d}))}}for(let d of _e(n)){let u;try{u=ae.resolve(o,d)}catch{continue}qr(u,o)||Pe(u,c)||l.some(k=>Pe(u,k))||t.push({kind:"shell_redirect_outside",target:d})}return t}};var To=N("config.json");function Gr(){return Kr.join(process.cwd(),".kodax","config.local.json")}a(Gr,"getProjectConfigFile");function su(e=process.env){let n=Je(To).autoMode??{},t=e.KODAX_AUTO_MODE_ENGINE?.trim(),r=t==="llm"||t==="rules"?t:void 0,i=n.engine==="llm"||n.engine==="rules"?n.engine:void 0,l=r??i??"llm",c=zr(n.classifierModel),d=zr(e.KODAX_AUTO_MODE_CLASSIFIER_MODEL),u=e.KODAX_AUTO_MODE_TIMEOUT_MS?.trim(),w=u!==void 0?Number(u):NaN,f=Number.isFinite(w)&&w>0?Math.floor(w):void 0,k=typeof n.timeoutMs=="number"&&n.timeoutMs>0?Math.floor(n.timeoutMs):void 0;return{engine:l,classifierModel:c,classifierModelEnv:d,timeoutMs:f??k}}a(su,"loadAutoModeSettings");function zr(e){if(typeof e!="string")return;let o=e.trim();return o.length===0?void 0:o}a(zr,"nonEmptyString");function Je(e){try{if(Ro.existsSync(e))return JSON.parse(Ro.readFileSync(e,"utf-8"))}catch{}return{}}a(Je,"readJsonFile");function Xr(e,o){Ro.mkdirSync(Kr.dirname(e),{recursive:!0}),Ro.writeFileSync(e,JSON.stringify(o,null,2))}a(Xr,"writeJsonFile");function Cn(e){let o=Je(To);Xr(To,{...o,permissionMode:e})}a(Cn,"savePermissionModeUser");function iu(){let e=Je(To),o=Je(Gr()),n=e.alwaysAllowTools??[],t=o.alwaysAllowTools??[];return[...new Set([...n,...t])]}a(iu,"loadAlwaysAllowTools");function au(e,o,n=!1){let t=Rn(e,o,n);if(!t)return;let r=Gr(),i=Je(r),l=i.alwaysAllowTools??[];l.includes(t)||Xr(r,{...i,alwaysAllowTools:[...l,t]})}a(au,"saveAlwaysAllowToolPattern");var _n=["ama","amaw","sa"];function Vr(e){let o=_n.indexOf(e);return _n[(o+1)%_n.length]??"ama"}a(Vr,"nextAgentMode");var Me=class{static{a(this,"CommandRegistry")}commands=new Map;aliases=new Map;register(o){let n=o.name.toLowerCase();if(this.commands.has(n))throw new Error(`Command "${o.name}" is already registered`);if(this.aliases.has(n)){let r=this.aliases.get(n);throw new Error(`Command "${o.name}" conflicts with existing alias for "${r}"`)}let t=new Set;for(let r of o.aliases??[]){let i=r.toLowerCase();if(i!==n){if(t.has(i))throw new Error(`Alias "${r}" is duplicated within command "${o.name}"`);if(this.commands.has(i))throw new Error(`Alias "${r}" conflicts with existing command "${i}"`);if(this.aliases.has(i)){let l=this.aliases.get(i);throw new Error(`Alias "${r}" is already registered for "${l}"`)}t.add(i)}}if(this.commands.set(n,{...o,source:o.source??"builtin"}),o.aliases)for(let r of o.aliases){let i=r.toLowerCase();i!==n&&this.aliases.set(i,n)}}unregister(o){let n=o.toLowerCase(),t=this.aliases.get(n)??n;if(!this.commands.has(t))return!1;let r=this.commands.get(t);if(r?.aliases)for(let i of r.aliases)this.aliases.delete(i.toLowerCase());return this.commands.delete(t),!0}get(o){let n=o.toLowerCase(),t=this.aliases.get(n)??n;return this.commands.get(t)}has(o){let n=o.toLowerCase(),t=this.aliases.get(n)??n;return this.commands.has(t)}getAll(o){let n=new Map;for(let[t,r]of this.commands)o&&r.source!==o||n.has(t)||n.set(t,{name:r.name,aliases:r.aliases,description:r.description,source:r.source??"builtin",usage:r.usage,priority:r.priority,location:r.location,path:r.path,userInvocable:r.userInvocable,disableModelInvocation:r.disableModelInvocation,allowedTools:r.allowedTools,context:r.context,agent:r.agent,argumentHint:r.argumentHint,model:r.model});return Array.from(n.values()).sort((t,r)=>t.name.localeCompare(r.name))}getBySource(o){return this.getAll(o)}getNames(){return Array.from(this.commands.keys()).sort()}clear(){this.commands.clear(),this.aliases.clear()}get size(){return this.commands.size}get aliasCount(){return this.aliases.size}},Ji=new Me;import q from"chalk";import{Buffer as Qr}from"node:buffer";import{spawn as Zi}from"node:child_process";import Yr from"node:process";var he="\x1B",Qi="\x07",Pn=`${he}\\`;function Jr(e,o){return e.SSH_CONNECTION?!1:o==="win32"||o==="darwin"||o==="linux"}a(Jr,"shouldPreferNativeClipboard");function ea(e,o){let n=Qr.from(e,"utf8").toString("base64"),t=o.TERM==="xterm-kitty"?Pn:Qi,r=`${he}]52;c;${n}${t}`;return o.TMUX?`${he}Ptmux;${r.replaceAll(he,`${he}${he}`)}${Pn}`:o.STY?`${he}P${r}${Pn}`:r}a(ea,"buildOscSequence");async function Eo(e,o,n){return new Promise((t,r)=>{let i=Zi(e,o,{stdio:["pipe","ignore","pipe"],windowsHide:!0}),l="";i.on("error",r),i.stderr?.on("data",c=>{l+=c.toString()}),i.on("close",c=>{if(c===0){t(!0);return}r(new Error(l.trim()||`${e} exited with code ${c??"unknown"}`))}),i.stdin?.write(n),i.stdin?.end()})}a(Eo,"execClipboardCommand");function oa(e){let o="$stream = [Console]::OpenStandardInput(); $buffer = New-Object byte[] 8192; $memory = New-Object System.IO.MemoryStream; while (($read = $stream.Read($buffer, 0, $buffer.Length)) -gt 0) { $memory.Write($buffer, 0, $read) }; $text = [System.Text.Encoding]::UTF8.GetString($memory.ToArray()); Set-Clipboard -Value $text",n=Qr.from(e,"utf8");return[["powershell",["-NoProfile","-NonInteractive","-Command",o],n],["pwsh",["-NoProfile","-NonInteractive","-Command",o],n],["cmd",["/c","chcp 65001 >nul & clip"],n]]}a(oa,"buildWindowsClipboardCandidates");async function Zr(e,o,n){if(o.SSH_CONNECTION)return!1;switch(n){case"win32":{let t=oa(e);for(let[r,i,l]of t)try{if(await Eo(r,i,l))return!0}catch{}return!1}case"darwin":return Eo("pbcopy",[],e);case"linux":{let t=[["wl-copy",[]],["xclip",["-selection","clipboard"]],["xsel",["--clipboard","--input"]]];for(let[r,i]of t)try{if(await Eo(r,i,e))return!0}catch{}return!1}default:return!1}}a(Zr,"tryNativeClipboard");async function na(e,o){if(!o.TMUX)return!1;let n=o.LC_TERMINAL==="iTerm2"?["load-buffer","-"]:["load-buffer","-w","-"];try{return await Eo("tmux",n,e)}catch{return!1}}a(na,"tryTmuxClipboard");async function es(e,o={}){let n=o.env??Yr.env,t=o.platform??Yr.platform,r=e.trimEnd(),i=ea(r,n);if(!r)throw new Error("Nothing to copy.");if(Jr(n,t))try{if(await Zr(r,n,t))return{path:"native"}}catch{}if(await na(r,n))return{path:"tmux-buffer"};if(o.terminalWrite?.(i))return{path:"osc52"};if(!Jr(n,t))try{if(await Zr(r,n,t))return{path:"native"}}catch{}throw new Error("Unable to access any clipboard path.")}a(es,"copyTextToClipboard");var Mn;(function(e){e.Idle="idle",e.Responding="responding",e.WaitingForConfirmation="waiting_for_confirmation"})(Mn||(Mn={}));var F;(function(e){e.Scheduled="scheduled",e.Validating="validating",e.AwaitingApproval="awaiting_approval",e.Executing="executing",e.Success="success",e.Error="error",e.Cancelled="cancelled"})(F||(F={}));var ku={[F.Scheduled]:"\u25CB",[F.Validating]:"\u25CC",[F.AwaitingApproval]:"?",[F.Executing]:"\u25CB",[F.Success]:"\u2713",[F.Error]:"\u2717",[F.Cancelled]:"-"},os;(function(e){e[e.Low=-100]="Low",e[e.Normal=0]="Normal",e[e.High=100]="High",e[e.Critical=200]="Critical"})(os||(os={}));var vu={streamingState:Mn.Idle,currentResponse:"",history:[],pendingToolCalls:[],sessionId:"",provider:"",model:"",isLoading:!1};var ta="[redacted]",ns="[truncated]";function Q(e,o=2e3){return e.length>o?`${e.slice(0,o-3)}...`:e}a(Q,"truncateToolReplayText");function ra(e){let o=e.toLowerCase().replace(/[\s_-]/g,"");return o.includes("token")||o.includes("password")||o.includes("secret")||o.includes("apikey")||o.includes("accesstoken")||o==="authorization"||o==="cookie"||o==="setcookie"}a(ra,"isSensitiveToolInputKey");function ts(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}a(ts,"isRecord");function Wn(e,o=0,n=new WeakSet){if(e===null||typeof e=="number"||typeof e=="boolean")return e;if(typeof e=="string")return Q(e);if(o>=6)return ns;if(typeof e=="object"&&e!==null){if(n.has(e))return ns;if(n.add(e),Array.isArray(e))return e.slice(0,50).map(r=>Wn(r,o+1,n));if(!ts(e))return Q(String(e));let t={};for(let[r,i]of Object.entries(e).slice(0,50))t[r]=ra(r)?ta:Wn(i,o+1,n);return t}return Q(String(e))}a(Wn,"sanitizeToolJsonValue");function rs(e){if(!e)return;let o=Wn(e);return ts(o)?o:void 0}a(rs,"sanitizeToolInput");function ss(e){if(e!==void 0){if(typeof e=="string")return Q(e);try{return Q(JSON.stringify(e))}catch{return Q(String(e))}}}a(ss,"stringifyToolReplayValue");function Ru(e){return e.type==="tool_summary"?{type:"event",text:e.text,icon:"tool"}:e.type==="tool_group"?{type:"tool_group",tools:e.tools.map(fa)}:e}a(Ru,"seedToHistoryItem");var sa="[Thinking]",ia="[/Thinking]",aa="Untitled Session",is=50,la=60,ls="...",cs=["[Managed Task]","[Managed Task Protocol Retry]","Assigned native agent identity:","Tool policy:","Blocked tools:","Allowed shell patterns:","Dependency handoff artifacts:","Dependency summary preview:","Preferred agent:","Read structured bundle first:","Read human summary next:"],ds=[/(?:^|\n)You are the [^\n]+ role for a managed KodaX task\./,/(?:^|\n)Primary task:/,/(?:^|\n)Work intent:/,/(?:^|\n)Complexity:/,/(?:^|\n)Risk:/,/(?:^|\n)Harness:/,/(?:^|\n)Brainstorm required:/],ca=/(^|\r?\n)\[Thinking\]\r?\n([\s\S]*?)\r?\n\[\/Thinking\](?=\r?\n|$)/g,da="Session ended before the tool completed.";function ua(e){switch(e){case"success":return F.Success;case"error":return F.Error;case"cancelled":return F.Cancelled;case"awaiting_approval":return F.AwaitingApproval;default:return e}}a(ua,"toolCallSeedToHistoryToolStatus");function fa(e){return{id:e.id,name:e.name,status:ua(e.status),...e.input!==void 0?{input:e.input}:{},...e.preview!==void 0?{preview:e.preview}:{},...e.output!==void 0?{output:e.output}:{},...e.error!==void 0?{error:e.error}:{},startTime:e.startTime??Date.now(),...e.endTime!==void 0?{endTime:e.endTime}:{}}}a(fa,"toolCallSeedToHistoryToolCall");function ma(e){let o=-1;for(let n of cs){let t=e.indexOf(n);t>=0&&(o===-1||t<o)&&(o=t)}for(let n of ds){let t=n.exec(e);t&&t.index>=0&&(o===-1||t.index<o)&&(o=t.index)}return o}a(ma,"findControlPlaneCutIndex");function ga(e){return cs.some(o=>e.includes(o))||ds.some(o=>o.test(e))}a(ga,"hasControlPlaneSignal");function us(e){let o=[];for(let n of e)n&&typeof n=="object"&&"type"in n&&n.type==="text"&&"text"in n&&o.push(String(n.text));return o}a(us,"collectTextBlocks");function Io(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}a(Io,"isRecord");function pa(e){if(typeof e=="string")return Q(e);if(e===void 0)return"";try{return ss(e)??""}catch{return Q(String(e))}}a(pa,"toolResultContentToString");function wa(e){let o=pa(e.content),n=o.trimStart(),t=e.is_error===!0||n.startsWith("[Tool Error]")||n.startsWith("[Error]"),r=n.startsWith("[Cancelled]")||n.startsWith("[Blocked]");return t?{status:"error",error:o}:r?{status:"cancelled",error:o}:{status:"success",output:o}}a(wa,"inferToolResultSeed");function ha(e){let o=new Map;if(!e||e.role!=="user"||!Array.isArray(e.content))return o;for(let n of e.content)!Io(n)||n.type!=="tool_result"||typeof n.tool_use_id!="string"||o.set(n.tool_use_id,wa(n));return o}a(ha,"collectToolResultSeeds");function ya(e,o){if(e.type!=="tool_use"||typeof e.id!="string"||typeof e.name!="string")return;let n=o.get(e.id)??{status:"cancelled",error:da};return{id:e.id,name:e.name,status:n.status,...e.input!==void 0?{input:rs(Io(e.input)?e.input:{})??{}}:{},...n.output!==void 0?{output:n.output}:{},...n.error!==void 0?{error:n.error}:{}}}a(ya,"buildToolCallSeed");function ka(e){return typeof e=="string"?e:Array.isArray(e)?us(e).join(`
2
+ import{A as mr,B as gr,C as pr,j as lr,l as Ie,m as mn,n as cr,o as dr,p as ur,q as gn,s as pn,t as wn,u as fr,w as ko,y as pe}from"./chunk-BFXFSEHK.js";import{a as wr}from"./chunk-JJTUBNQX.js";import{Ja as er,Ma as ge,Qa as Te,Sa as Be,Ta as ho,Ua as or,Va as nr,Xa as tr,Ya as fn,Za as rr,_a as qe,ab as Ee,cb as sr,lb as yo,mb as ir,sb as ar,tb as ze}from"./chunk-4RVSFOUT.js";import{Hd as Zt,Jd as Qt,Wc as Z,Yc as Gt,Z as zt,Zc as Xt,aa as He,ba as Kt,nd as Vt,pd as Yt,qd as Jt,td as un,v as qt}from"./chunk-5USNUSTL.js";import{j as an,sa as Wt,ta as xe,ua as Ae}from"./chunk-LE6STNVN.js";import{Zc as Re,_c as Ht,cc as Dt,dc as Ut,ec as Ft,k as ln,nd as Bt,rc as cn,sb as Lt,sc as dn,tb as Ot,va as po,wa as N,xb as Nt,xc as jt,xd as wo}from"./chunk-HMATTIU6.js";import{a,b as sn,c as wi}from"./chunk-V4WSBIXB.js";var xr=sn((yd,br)=>{"use strict";br.exports=a(function(o){return o.map(function(n){return n===""?"''":n&&typeof n=="object"?n.op.replace(/(.)/g,"\\$1"):/["\s\\]/.test(n)&&!/'/.test(n)?"'"+n.replace(/(['])/g,"\\$1")+"'":/["'\s]/.test(n)?'"'+n.replace(/(["\\$`!])/g,"\\$1")+'"':String(n).replace(/([A-Za-z]:)?([#!"$&'()*,:;<=>?@[\\\]^`{|}])/g,"$1\\$2")}).join(" ")},"quote")});var _r=sn((vd,Cr)=>{"use strict";var Ir="(?:"+["\\|\\|","\\&\\&",";;","\\|\\&","\\<\\(","\\<\\<\\<",">>",">\\&","<\\&","[&;()|<>]"].join("|")+")",Ar=new RegExp("^"+Ir+"$"),Rr="|&;()<> \\t",ki='"((\\\\"|[^"])*?)"',vi="'((\\\\'|[^'])*?)'",Si=/^#$/,Tr="'",Er='"',hn="$",we="",$i=4294967296;for(yn=0;yn<4;yn++)we+=($i*Math.random()).toString(16);var yn,bi=new RegExp("^"+we);function xi(e,o){for(var n=o.lastIndex,t=[],r;r=o.exec(e);)t.push(r),o.lastIndex===r.index&&(o.lastIndex+=1);return o.lastIndex=n,t}a(xi,"matchAll");function Ai(e,o,n){var t=typeof e=="function"?e(n):e[n];return typeof t>"u"&&n!=""?t="":typeof t>"u"&&(t="$"),typeof t=="object"?o+we+JSON.stringify(t)+we:o+t}a(Ai,"getVar");function Ri(e,o,n){n||(n={});var t=n.escape||"\\",r="(\\"+t+`['"`+Rr+`]|[^\\s'"`+Rr+"])+",i=new RegExp(["("+Ir+")","("+r+"|"+ki+"|"+vi+")+"].join("|"),"g"),l=xi(e,i);if(l.length===0)return[];o||(o={});var c=!1;return l.map(function(d){var u=d[0];if(!u||c)return;if(Ar.test(u))return{op:u};var w=!1,f=!1,k="",v=!1,h;function y(){h+=1;var A,j,H=u.charAt(h);if(H==="{"){if(h+=1,u.charAt(h)==="}")throw new Error("Bad substitution: "+u.slice(h-2,h+1));if(A=u.indexOf("}",h),A<0)throw new Error("Bad substitution: "+u.slice(h));j=u.slice(h,A),h=A}else if(/[*@#?$!_-]/.test(H))j=H,h+=1;else{var G=u.slice(h);A=G.match(/[^\w\d_]/),A?(j=G.slice(0,A.index),h+=A.index-1):(j=G,h=u.length)}return Ai(o,"",j)}for(a(y,"parseEnvVar"),h=0;h<u.length;h++){var m=u.charAt(h);if(v=v||!w&&(m==="*"||m==="?"),f)k+=m,f=!1;else if(w)m===w?w=!1:w==Tr?k+=m:m===t?(h+=1,m=u.charAt(h),m===Er||m===t||m===hn?k+=m:k+=t+m):m===hn?k+=y():k+=m;else if(m===Er||m===Tr)w=m;else{if(Ar.test(m))return{op:u};if(Si.test(m)){c=!0;var x={comment:e.slice(d.index+h+1)};return k.length?[k,x]:[x]}else m===t?f=!0:m===hn?k+=y():k+=m}}return v?{op:"glob",pattern:k}:k}).reduce(function(d,u){return typeof u>"u"?d:d.concat(u)},[])}a(Ri,"parseInternal");Cr.exports=a(function(o,n,t){var r=Ri(o,n,t);return typeof n!="function"?r:r.reduce(function(i,l){if(typeof l=="object")return i.concat(l);var c=l.split(RegExp("("+we+".*?"+we+")","g"));return c.length===1?i.concat(c[0]):i.concat(c.filter(Boolean).map(function(d){return bi.test(d)?JSON.parse(d.split(we)[1]):d}))},[])},"parse")});var Pr=sn(kn=>{"use strict";kn.quote=xr();kn.parse=_r()});import*as Zo from"fs";import*as uo from"path";import s from"chalk";var vo=["plan","accept-edits","auto","auto-in-project"];function gd(e){return e==="auto"||e==="auto-in-project"}a(gd,"isAutoMode");function hi(e){switch(e){case"plan":return"Plan";case"accept-edits":return"Edits";case"auto":case"auto-in-project":return"Auto"}}a(hi,"permissionModeDisplayName");var yi='[deprecated] permissionMode "auto-in-project" is now an alias for "auto" (FEATURE_092, v0.7.33). The alias will be removed in v0.7.38 \u2014 please update ~/.kodax/config.json to use "auto".';function pd(e=console.warn){let o=!1;return()=>{o||(o=!0,e(yi))}}a(pd,"createAutoInProjectDeprecationEmitter");var hr=Zt(),Ke=new Set(hr.filter(e=>e.sideEffect==="mutates-fs"&&e.requiredParams.includes("path")).map(e=>e.name)),yr=new Set(hr.filter(e=>e.sideEffect!=="readonly").map(e=>e.name)),kr=new Set(["npm install","npm i","npm uninstall","npm remove","npm update","npm ci","yarn add","yarn remove","yarn upgrade","pnpm add","pnpm remove","pnpm update","git clean","git reset","git checkout","git switch","git merge","git rebase","git cherry-pick","git revert","git commit","git push","git pull","rm","mv","cp","mkdir","rmdir","touch","chmod","chown","del","erase","rd","copy","move","ren","curl","wget","dd","tar","kill","pkill","killall"]),vr=new Set(["ls","cat","pwd","echo","whoami","date","which","whereis","tree","dir","type","get-childitem","get-content","select-string","get-location","where","grep","find","awk","sed","head","tail","less","more","wc","findstr","fc","git status","git diff","git log","git show","git branch","git remote","git ls-files","git rev-parse","git grep","git tag","git stash list","git describe","git config --get","node","npm","yarn","pnpm","tsc","python","pip","go","cargo","rustc"]);function Sr(e){switch(e){case"plan":return new Set(["bash","write","edit","undo"]);case"accept-edits":return new Set(["bash"]);case"auto":case"auto-in-project":return new Set}}a(Sr,"computeConfirmTools");function $r(e){return e!==void 0&&vo.includes(e)}a($r,"isPermissionMode");function Ge(e,o){return $r(e)?e:o}a(Ge,"normalizePermissionMode");import Ro from"fs";import Kr from"path";import So from"fs";import P from"path";import Ve from"os";var Lr=wi(Pr(),1);var Mr=new Set(["/dev/null","nul","NUL"]);function vn(e){return Mr.has(e)||Mr.has(e.toLowerCase())}a(vn,"isNullDevice");function Xe(e){let o=e.trim();if(!o)return{statements:[],unparseable:!1};if(o.includes("`"))return{statements:[],unparseable:!0};let n;try{n=(0,Lr.parse)(o)}catch{return{statements:[],unparseable:!0}}let t=[],r=[],i=[],l=[],c=null,d=!1,u=a(()=>{(i.length>0||l.length>0)&&(r.push({argv:i,redirections:l}),i=[],l=[])},"flushStage"),w=a(f=>{u(),r.length>0&&(t.push({precedingOp:c,stages:r}),r=[]),c=f},"flushStatement");for(let f=0;f<n.length;f+=1){let k=n[f];if(typeof k=="string"){i.push(k);continue}if("op"in k){let v=k.op;if(v==="&&"||v==="||"||v===";"){w(v);continue}if(v==="|"){u();continue}if(v==="&"){let h=n[f+1];if(h!==void 0&&typeof h!="string"&&"op"in h&&(h.op===">"||h.op===">>")){let y=n[f+2];if(typeof y!="string"){d=!0,f+=1;continue}l.push(Wr(`&${h.op}`,y)),f+=2;continue}d=!0;continue}if(Ei(v)){let h=null,y=i[i.length-1];y!==void 0&&/^[0-9]+$/.test(y)&&(h=y,i.pop());let m=n[f+1];if(typeof m!="string"){d=!0;continue}l.push(Wr(h?`${h}${v}`:v,m)),f+=1;continue}if(v==="glob"){let h=k.pattern;typeof h=="string"?i.push(h):d=!0;continue}d=!0;continue}if("comment"in k)break;d=!0}return w(null),{statements:t,unparseable:d}}a(Xe,"parseBashCommand");var Ti=new Set([">",">>","<","<<","<<<","&>","&>>"]),Or=/^([0-9]+|&)(>>?|<<?)$/;function Ei(e){return Ti.has(e)||Or.test(e)}a(Ei,"isRedirectionOp");function Wr(e,o){let n=null,t=e,r=Or.exec(e);return r&&(n=r[1],t=r[2]),{op:e,fd:n,append:t===">>"||e==="&>>",input:t==="<"||t==="<<"||e==="<<<",target:o}}a(Wr,"parseRedirection");var Ii=P.join(".agent","plan_mode_doc.md"),$o=new Map,bo=null;function Ci(e){if(!e||!e.trim())return!1;let o=e.trim().replace(/\s+/g," ").toLowerCase();for(let n of vr)if(o===n||o.startsWith(n+" ")){if(n==="sed"&&o.split(/\s+/).some(i=>i.startsWith("-i")||i==="--in-place"))return!1;if(n==="awk"){let r=o.split(/\s+/);if(r.includes("-f")||r.includes("--file"))return!1}if(["node","npm","yarn","pnpm","tsc","python","pip","go","cargo","rustc","ruby","perl"].includes(n)){let r=o.split(/\s+/).slice(1);if(r.length>0&&!r.every(i=>/^(-v|--version|-h|--help)$/.test(i)))return!1}return!0}return!1}a(Ci,"isSingleBashReadCommand");var _i=/^[a-zA-Z0-9]+$/;function Pi(e){let o=e.trim();if(!o.endsWith("--help")||o.includes('"')||o.includes("'"))return!1;let n=!1;for(let t of o.split(/\s+/))if(t.startsWith("-"))if(t==="--help")n=!0;else return!1;else if(!_i.test(t))return!1;return n}a(Pi,"isHelpCommand");function $n(e){if(!e||!e.trim())return!1;if(Pi(e))return!0;let o=e.trim().replace(/\\\r?\n/g," "),n=Xe(o);if(n.unparseable||n.statements.length===0)return!1;let t=n.statements.length>1||(n.statements[0]?.stages.length??0)>1;for(let r of n.statements){if(r.precedingOp!==null&&r.precedingOp!=="&&")return!1;for(let i of r.stages){for(let c of i.redirections)if(c.input||!vn(c.target))return!1;let l=i.argv.join(" ");if(l&&!(t&&i.argv[0]?.toLowerCase()==="cd"&&i.argv.length>=2)&&!Ci(l))return!1}}return!0}a($n,"isBashReadCommand");function Mi(e){let o=e.trim();return o?$n(o)?null:"[Blocked] Direct !command execution only supports safe read-only commands. Use the bash tool for commands that write files, invoke shells, or require confirmation.":"[Shell: No command provided]"}a(Mi,"getDirectShellBypassBlockReason");var Dr=new Set(["remove-item","set-content","add-content","out-file","new-item","copy-item","move-item","rename-item","ni"]);function bn(e){if(!e||!e.trim())return!1;let o=Xe(e);if(o.unparseable)return!1;for(let n of o.statements)for(let t of n.stages){let r=t.argv.map(i=>i.toLowerCase());if(r.length>0){let i=r[0],l=r.length>=2?`${r[0]} ${r[1]}`:null;for(let c of kr)if(c===i||l!==null&&c===l)return!0}for(let i of r)if(Dr.has(i))return!0;for(let i of t.redirections)if(!i.input&&!vn(i.target))return!0}return!1}a(bn,"isBashWriteCommand");function xn(e){let o=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\((.+)\)$/);return o?{tool:o[1].toLowerCase(),pattern:o[2]}:{tool:e.toLowerCase(),pattern:null}}a(xn,"parseAllowedToolPattern");function Wi(e,o){if(o==="*")return!1;if(o.endsWith(":*")){let n=o.slice(0,-2);return e.startsWith(n)}return e===o}a(Wi,"matchesBashPatternLegacy");function Li(e,o){if(o==="*")return!1;if(o.endsWith(":*")){let n=o.slice(0,-2);return e===n}return e===o}a(Li,"matchesBashPatternByExtractedPrefix");async function An(e,o,n,t,r){if(e.toLowerCase()!=="bash")return!1;let i=o.command??"",l=[];for(let c of n){let d=xn(c);if(d.tool==="bash"){if(d.pattern===null)return!0;l.push({pattern:d.pattern})}}if(l.length===0)return!1;if(t){let c;try{c=await t.extract(i,r)}catch{return!1}if(c.kind!=="prefix")return!1;for(let{pattern:d}of l)if(d&&Li(c.value,d))return!0;return!1}for(let{pattern:c}of l)if(c&&Wi(i,c))return!0;return!1}a(An,"isToolCallAllowed");function Rn(e,o,n){if(e.toLowerCase()!=="bash")return"";let t=o.command??"",r=t.split(" ");return r.length>1?`Bash(${r.slice(0,2).join(" ")}:*)`:`Bash(${t})`}a(Rn,"generateSavePattern");function Ye(e,o){try{let n=P.resolve(e),t=P.resolve(o),r=po(),i=P.join(t,".kodax");return Ce(n,i)||Ce(n,r)?!0:!(Ce(n,t)||jr().some(c=>Ce(n,c)))}catch{return!1}}a(Ye,"isAlwaysConfirmPath");function Nr(e){return!e||e.startsWith("-")?!1:/^\.\.?[/\\]/.test(e)||e.startsWith("~/")||e.startsWith("~\\")||/^[a-zA-Z]:[/\\]/.test(e)?!0:e.startsWith("/")&&e.length>1?!(process.platform==="win32"&&Oi.test(e)):!!(e.startsWith(".")&&/[/\\]/.test(e))}a(Nr,"looksLikePath");var Oi=/^\/[A-Za-z][A-Za-z0-9]*(?::[A-Za-z0-9]+)?$/;function Ni(e){let o=[],n=/["']([^"']+)["']/g,t;for(;(t=n.exec(e))!==null;)o.push(t[1]);let r=/(?:^|\s)(\.\.?\/[^\s]+|\.\.?\\[^\s]+|[a-zA-Z]:\\[^\s]+|~\/[^\s]+|\.[^\s]*[/\\][^\s]*)/g;for(;(t=r.exec(e))!==null;)o.push(t[1]);return o}a(Ni,"legacyRegexPathScan");function Ao(e){let o=new Set,n=Xe(e);if(!n.unparseable)for(let t of n.statements)for(let r of t.stages){for(let i of r.argv)Nr(i)&&o.add(i);for(let i of r.redirections)Nr(i.target)&&o.add(i.target)}for(let t of Ni(e))o.add(t);return Array.from(o)}a(Ao,"extractPathsFromCommand");function Di(e,o){let n=Ao(e);for(let t of n)if(Ye(t,o))return!0;return!1}a(Di,"isCommandOnProtectedPath");function xo(e){let o=P.normalize(e);return process.platform==="win32"?o.toLowerCase():o}a(xo,"normalizePathForComparison");function Ui(e,o){return xo(e)===xo(o)}a(Ui,"pathsEqual");function Ce(e,o){let n=xo(e),t=xo(o);return n===t||n.startsWith(t+P.sep)}a(Ce,"isPathInsideDirectory");function Tn(e,o){try{let n=P.resolve(o),t=P.resolve(n,Fr(Ur(e)));return Ce(t,n)}catch{return!1}}a(Tn,"isPathInsideProject");function Fi(e){let o=e.match(/[A-Za-z]:[\\/][^\s;|&<>(){}'"]+|\/[^\s;|&<>(){}'"]+/g);return o?o.filter(n=>!/^(?:\/dev\/|\/proc\/)/i.test(n)):[]}a(Fi,"collectAbsolutePathCandidates");function En(e){let o=P.resolve(e),n=$o.get(o);if(n)return n;if(So.existsSync(o)){let c=So.realpathSync.native(o);return $o.set(o,c),c}let t=[],r=o;for(;!So.existsSync(r);){let c=P.dirname(r);if(c===r)return $o.set(o,o),o;t.unshift(P.basename(r)),r=c}let i=So.realpathSync.native(r),l=P.join(i,...t);return $o.set(o,l),l}a(En,"resolveExistingPathPrefix");function Ur(e){return e==="~"?Ve.homedir():e.startsWith(`~${P.sep}`)||e.startsWith("~/")||e.startsWith("~\\")?P.join(Ve.homedir(),e.slice(2)):e}a(Ur,"expandHomeDirectory");function Fr(e){let o=Ve.tmpdir(),n=[[/^%temp%/i,o],[/^%tmp%/i,o],[/^\$env:temp\b/i,o],[/^\$env:tmp\b/i,o],[/^\$tmpdir\b/i,o],[/^\$temp\b/i,o],[/^\$tmp\b/i,o]];for(let[t,r]of n)if(t.test(e))return e.replace(t,r);return e}a(Fr,"expandSystemTempAlias");function ji(e,o){let n=P.resolve(o??process.cwd()),t=Fr(Ur(e)),r=P.isAbsolute(t)?P.resolve(t):P.resolve(n,t);return En(r)}a(ji,"resolvePermissionPath");function jr(){if(bo)return bo;let e=new Set,o=[Ve.tmpdir(),process.env.TEMP,process.env.TMP,process.env.TMPDIR].filter(n=>typeof n=="string"&&n.trim().length>0);for(let n of o)try{e.add(En(n))}catch{}return bo=Array.from(e),bo}a(jr,"getSystemTempDirectories");function In(e){let o=En(e??process.cwd());return{projectPlanDoc:P.join(o,Ii),systemTempDirs:jr()}}a(In,"getPlanModeAllowedWritablePaths");function Sn(e,o){let n=ji(e,o),{projectPlanDoc:t,systemTempDirs:r}=In(o);return Ui(n,t)?!0:r.some(i=>Ce(n,i))}a(Sn,"isPlanModeAllowedPath");function Hi(e){let{projectPlanDoc:o,systemTempDirs:n}=In(e),t=n[0]??Ve.tmpdir();return`${o} or the system temp directory (${t})`}a(Hi,"formatPlanModeAllowedLocations");var Bi=new Set(["-a","--append","-i","--ignore-interrupts"]);function qi(e){let o=[];for(let n=1;n<e.argv.length;n+=1){let t=e.argv[n];Bi.has(t)||t.startsWith("-")||o.push(t)}return o}a(qi,"collectTeeTargets");function zi(e){let o=[],n=1,t=!1;for(;n<e.argv.length;){let r=e.argv[n],i=r.toLowerCase();if(i==="-path"||i==="-literalpath"||i==="-destination"){let l=e.argv[n+1];if(l!==void 0&&!l.startsWith("-")){o.push(l),n+=2;continue}}!r.startsWith("-")&&!t&&(o.push(r),t=!0),n+=1}return o}a(zi,"collectPowerShellWriteTargets");function _e(e){let o=new Set,n=a(r=>{let i=r?.trim();i&&o.add(i)},"pushTarget");for(let r of Ao(e))n(r);let t=Xe(e);if(t.unparseable)return Array.from(o);for(let r of t.statements)for(let i of r.stages){for(let c of i.redirections)c.input||n(c.target);let l=i.argv[0]?.toLowerCase();if(l){if(l==="tee")for(let c of qi(i))n(c);else if(Dr.has(l))for(let c of zi(i))n(c)}}return Array.from(o)}a(_e,"collectBashWriteTargets");function Hr(e,o){if(!bn(e))return{dangerous:!1};let n=new Set([..._e(e),...Fi(e)]);for(let t of n)if(!Tn(t,o))return{dangerous:!0,reason:`Command may modify file outside project: ${t}`};return{dangerous:!1}}a(Hr,"getBashOutsideProjectWriteRisk");function Br(e,o,n){let t=Hi(n);if(Qt(e))return null;if(Ke.has(e)){let r=typeof o.path=="string"?o.path:"";return r?Sn(r,n)?null:`[Blocked] Plan mode only allows file modifications in ${t}. Requested path: ${r}`:`[Blocked] Tool '${e}' is not allowed in plan mode unless it targets ${t}.`}if(e==="bash"){let r=o.command??"";if(!bn(r))return null;let i=_e(r);if(i.length===0)return`[Blocked] Plan mode only allows bash write operations when every target is either ${t}. Could not determine a safe target from: ${r.slice(0,80)}${r.length>80?"...":""}`;let l=i.find(c=>!Sn(c,n));return l?`[Blocked] Plan mode only allows bash write operations in ${t}. Blocked target: ${l}`:null}return`[Blocked] Tool '${e}' has side effects and is not permitted in plan mode. Switch to accept-edits or auto mode to use it, or work within ${t}.`}a(Br,"getPlanModeBlockReason");import ae from"node:path";import Ki from"node:os";function Pe(e,o){try{let n=ae.resolve(e),t=ae.resolve(o);return n===t?!0:n.startsWith(t+ae.sep)}catch{return!1}}a(Pe,"isPathUnder");function Gi(){try{return po()}catch{return}}a(Gi,"safeGetAgentConfigHome");function qr(e,o){let n=Gi();if(n&&Pe(e,n))return"user-kodax";let t=ae.join(ae.resolve(o),".kodax");if(Pe(e,t))return"project-kodax"}a(qr,"resolveProtectedZone");function Xi(){let e=new Set;try{e.add(Ki.tmpdir())}catch{}for(let o of["TEMP","TMP","TMPDIR"]){let n=process.env[o];n&&n.length>0&&e.add(n)}return Array.from(e)}a(Xi,"getSystemTempDirs");var Vi=new Set(["bash"]),Yi={toolNames:Vi,collect(e,o){let n=typeof e.input.command=="string"?e.input.command:"";if(!n||!o)return[];let t=[],r=new Set,i=new Set,l=Xi(),c=ae.resolve(o);for(let d of Ao(n)){let u;try{u=ae.resolve(o,d)}catch{continue}let w=qr(u,o);if(w){r.has(u)||(r.add(u),t.push({kind:"protected_path",path:d,zone:w}));continue}if(Ye(d,o)){let f=l.some(v=>Pe(u,v)),k=Pe(u,c);!f&&!k&&!i.has(u)&&(i.add(u),t.push({kind:"outside_project",path:d}))}}for(let d of _e(n)){let u;try{u=ae.resolve(o,d)}catch{continue}qr(u,o)||Pe(u,c)||l.some(k=>Pe(u,k))||t.push({kind:"shell_redirect_outside",target:d})}return t}};var To=N("config.json");function Gr(){return Kr.join(process.cwd(),".kodax","config.local.json")}a(Gr,"getProjectConfigFile");function su(e=process.env){let n=Je(To).autoMode??{},t=e.KODAX_AUTO_MODE_ENGINE?.trim(),r=t==="llm"||t==="rules"?t:void 0,i=n.engine==="llm"||n.engine==="rules"?n.engine:void 0,l=r??i??"llm",c=zr(n.classifierModel),d=zr(e.KODAX_AUTO_MODE_CLASSIFIER_MODEL),u=e.KODAX_AUTO_MODE_TIMEOUT_MS?.trim(),w=u!==void 0?Number(u):NaN,f=Number.isFinite(w)&&w>0?Math.floor(w):void 0,k=typeof n.timeoutMs=="number"&&n.timeoutMs>0?Math.floor(n.timeoutMs):void 0;return{engine:l,classifierModel:c,classifierModelEnv:d,timeoutMs:f??k}}a(su,"loadAutoModeSettings");function zr(e){if(typeof e!="string")return;let o=e.trim();return o.length===0?void 0:o}a(zr,"nonEmptyString");function Je(e){try{if(Ro.existsSync(e))return JSON.parse(Ro.readFileSync(e,"utf-8"))}catch{}return{}}a(Je,"readJsonFile");function Xr(e,o){Ro.mkdirSync(Kr.dirname(e),{recursive:!0}),Ro.writeFileSync(e,JSON.stringify(o,null,2))}a(Xr,"writeJsonFile");function Cn(e){let o=Je(To);Xr(To,{...o,permissionMode:e})}a(Cn,"savePermissionModeUser");function iu(){let e=Je(To),o=Je(Gr()),n=e.alwaysAllowTools??[],t=o.alwaysAllowTools??[];return[...new Set([...n,...t])]}a(iu,"loadAlwaysAllowTools");function au(e,o,n=!1){let t=Rn(e,o,n);if(!t)return;let r=Gr(),i=Je(r),l=i.alwaysAllowTools??[];l.includes(t)||Xr(r,{...i,alwaysAllowTools:[...l,t]})}a(au,"saveAlwaysAllowToolPattern");var _n=["ama","amaw","sa"];function Vr(e){let o=_n.indexOf(e);return _n[(o+1)%_n.length]??"ama"}a(Vr,"nextAgentMode");var Me=class{static{a(this,"CommandRegistry")}commands=new Map;aliases=new Map;register(o){let n=o.name.toLowerCase();if(this.commands.has(n))throw new Error(`Command "${o.name}" is already registered`);if(this.aliases.has(n)){let r=this.aliases.get(n);throw new Error(`Command "${o.name}" conflicts with existing alias for "${r}"`)}let t=new Set;for(let r of o.aliases??[]){let i=r.toLowerCase();if(i!==n){if(t.has(i))throw new Error(`Alias "${r}" is duplicated within command "${o.name}"`);if(this.commands.has(i))throw new Error(`Alias "${r}" conflicts with existing command "${i}"`);if(this.aliases.has(i)){let l=this.aliases.get(i);throw new Error(`Alias "${r}" is already registered for "${l}"`)}t.add(i)}}if(this.commands.set(n,{...o,source:o.source??"builtin"}),o.aliases)for(let r of o.aliases){let i=r.toLowerCase();i!==n&&this.aliases.set(i,n)}}unregister(o){let n=o.toLowerCase(),t=this.aliases.get(n)??n;if(!this.commands.has(t))return!1;let r=this.commands.get(t);if(r?.aliases)for(let i of r.aliases)this.aliases.delete(i.toLowerCase());return this.commands.delete(t),!0}get(o){let n=o.toLowerCase(),t=this.aliases.get(n)??n;return this.commands.get(t)}has(o){let n=o.toLowerCase(),t=this.aliases.get(n)??n;return this.commands.has(t)}getAll(o){let n=new Map;for(let[t,r]of this.commands)o&&r.source!==o||n.has(t)||n.set(t,{name:r.name,aliases:r.aliases,description:r.description,source:r.source??"builtin",usage:r.usage,priority:r.priority,location:r.location,path:r.path,userInvocable:r.userInvocable,disableModelInvocation:r.disableModelInvocation,allowedTools:r.allowedTools,context:r.context,agent:r.agent,argumentHint:r.argumentHint,model:r.model});return Array.from(n.values()).sort((t,r)=>t.name.localeCompare(r.name))}getBySource(o){return this.getAll(o)}getNames(){return Array.from(this.commands.keys()).sort()}clear(){this.commands.clear(),this.aliases.clear()}get size(){return this.commands.size}get aliasCount(){return this.aliases.size}},Ji=new Me;import q from"chalk";import{Buffer as Qr}from"node:buffer";import{spawn as Zi}from"node:child_process";import Yr from"node:process";var he="\x1B",Qi="\x07",Pn=`${he}\\`;function Jr(e,o){return e.SSH_CONNECTION?!1:o==="win32"||o==="darwin"||o==="linux"}a(Jr,"shouldPreferNativeClipboard");function ea(e,o){let n=Qr.from(e,"utf8").toString("base64"),t=o.TERM==="xterm-kitty"?Pn:Qi,r=`${he}]52;c;${n}${t}`;return o.TMUX?`${he}Ptmux;${r.replaceAll(he,`${he}${he}`)}${Pn}`:o.STY?`${he}P${r}${Pn}`:r}a(ea,"buildOscSequence");async function Eo(e,o,n){return new Promise((t,r)=>{let i=Zi(e,o,{stdio:["pipe","ignore","pipe"],windowsHide:!0}),l="";i.on("error",r),i.stderr?.on("data",c=>{l+=c.toString()}),i.on("close",c=>{if(c===0){t(!0);return}r(new Error(l.trim()||`${e} exited with code ${c??"unknown"}`))}),i.stdin?.write(n),i.stdin?.end()})}a(Eo,"execClipboardCommand");function oa(e){let o="$stream = [Console]::OpenStandardInput(); $buffer = New-Object byte[] 8192; $memory = New-Object System.IO.MemoryStream; while (($read = $stream.Read($buffer, 0, $buffer.Length)) -gt 0) { $memory.Write($buffer, 0, $read) }; $text = [System.Text.Encoding]::UTF8.GetString($memory.ToArray()); Set-Clipboard -Value $text",n=Qr.from(e,"utf8");return[["powershell",["-NoProfile","-NonInteractive","-Command",o],n],["pwsh",["-NoProfile","-NonInteractive","-Command",o],n],["cmd",["/c","chcp 65001 >nul & clip"],n]]}a(oa,"buildWindowsClipboardCandidates");async function Zr(e,o,n){if(o.SSH_CONNECTION)return!1;switch(n){case"win32":{let t=oa(e);for(let[r,i,l]of t)try{if(await Eo(r,i,l))return!0}catch{}return!1}case"darwin":return Eo("pbcopy",[],e);case"linux":{let t=[["wl-copy",[]],["xclip",["-selection","clipboard"]],["xsel",["--clipboard","--input"]]];for(let[r,i]of t)try{if(await Eo(r,i,e))return!0}catch{}return!1}default:return!1}}a(Zr,"tryNativeClipboard");async function na(e,o){if(!o.TMUX)return!1;let n=o.LC_TERMINAL==="iTerm2"?["load-buffer","-"]:["load-buffer","-w","-"];try{return await Eo("tmux",n,e)}catch{return!1}}a(na,"tryTmuxClipboard");async function es(e,o={}){let n=o.env??Yr.env,t=o.platform??Yr.platform,r=e.trimEnd(),i=ea(r,n);if(!r)throw new Error("Nothing to copy.");if(Jr(n,t))try{if(await Zr(r,n,t))return{path:"native"}}catch{}if(await na(r,n))return{path:"tmux-buffer"};if(o.terminalWrite?.(i))return{path:"osc52"};if(!Jr(n,t))try{if(await Zr(r,n,t))return{path:"native"}}catch{}throw new Error("Unable to access any clipboard path.")}a(es,"copyTextToClipboard");var Mn;(function(e){e.Idle="idle",e.Responding="responding",e.WaitingForConfirmation="waiting_for_confirmation"})(Mn||(Mn={}));var F;(function(e){e.Scheduled="scheduled",e.Validating="validating",e.AwaitingApproval="awaiting_approval",e.Executing="executing",e.Success="success",e.Error="error",e.Cancelled="cancelled"})(F||(F={}));var ku={[F.Scheduled]:"\u25CB",[F.Validating]:"\u25CC",[F.AwaitingApproval]:"?",[F.Executing]:"\u25CB",[F.Success]:"\u2713",[F.Error]:"\u2717",[F.Cancelled]:"-"},os;(function(e){e[e.Low=-100]="Low",e[e.Normal=0]="Normal",e[e.High=100]="High",e[e.Critical=200]="Critical"})(os||(os={}));var vu={streamingState:Mn.Idle,currentResponse:"",history:[],pendingToolCalls:[],sessionId:"",provider:"",model:"",isLoading:!1};var ta="[redacted]",ns="[truncated]";function Q(e,o=2e3){return e.length>o?`${e.slice(0,o-3)}...`:e}a(Q,"truncateToolReplayText");function ra(e){let o=e.toLowerCase().replace(/[\s_-]/g,"");return o.includes("token")||o.includes("password")||o.includes("secret")||o.includes("apikey")||o.includes("accesstoken")||o==="authorization"||o==="cookie"||o==="setcookie"}a(ra,"isSensitiveToolInputKey");function ts(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}a(ts,"isRecord");function Wn(e,o=0,n=new WeakSet){if(e===null||typeof e=="number"||typeof e=="boolean")return e;if(typeof e=="string")return Q(e);if(o>=6)return ns;if(typeof e=="object"&&e!==null){if(n.has(e))return ns;if(n.add(e),Array.isArray(e))return e.slice(0,50).map(r=>Wn(r,o+1,n));if(!ts(e))return Q(String(e));let t={};for(let[r,i]of Object.entries(e).slice(0,50))t[r]=ra(r)?ta:Wn(i,o+1,n);return t}return Q(String(e))}a(Wn,"sanitizeToolJsonValue");function rs(e){if(!e)return;let o=Wn(e);return ts(o)?o:void 0}a(rs,"sanitizeToolInput");function ss(e){if(e!==void 0){if(typeof e=="string")return Q(e);try{return Q(JSON.stringify(e))}catch{return Q(String(e))}}}a(ss,"stringifyToolReplayValue");function Ru(e){return e.type==="tool_summary"?{type:"event",text:e.text,icon:"tool"}:e.type==="tool_group"?{type:"tool_group",tools:e.tools.map(fa)}:e}a(Ru,"seedToHistoryItem");var sa="[Thinking]",ia="[/Thinking]",aa="Untitled Session",is=50,la=60,ls="...",cs=["[Managed Task]","[Managed Task Protocol Retry]","Assigned native agent identity:","Tool policy:","Blocked tools:","Allowed shell patterns:","Dependency handoff artifacts:","Dependency summary preview:","Preferred agent:","Read structured bundle first:","Read human summary next:"],ds=[/(?:^|\n)You are the [^\n]+ role for a managed KodaX task\./,/(?:^|\n)Primary task:/,/(?:^|\n)Work intent:/,/(?:^|\n)Complexity:/,/(?:^|\n)Risk:/,/(?:^|\n)Harness:/,/(?:^|\n)Brainstorm required:/],ca=/(^|\r?\n)\[Thinking\]\r?\n([\s\S]*?)\r?\n\[\/Thinking\](?=\r?\n|$)/g,da="Session ended before the tool completed.";function ua(e){switch(e){case"success":return F.Success;case"error":return F.Error;case"cancelled":return F.Cancelled;case"awaiting_approval":return F.AwaitingApproval;default:return e}}a(ua,"toolCallSeedToHistoryToolStatus");function fa(e){return{id:e.id,name:e.name,status:ua(e.status),...e.input!==void 0?{input:e.input}:{},...e.preview!==void 0?{preview:e.preview}:{},...e.output!==void 0?{output:e.output}:{},...e.error!==void 0?{error:e.error}:{},startTime:e.startTime??Date.now(),...e.endTime!==void 0?{endTime:e.endTime}:{}}}a(fa,"toolCallSeedToHistoryToolCall");function ma(e){let o=-1;for(let n of cs){let t=e.indexOf(n);t>=0&&(o===-1||t<o)&&(o=t)}for(let n of ds){let t=n.exec(e);t&&t.index>=0&&(o===-1||t.index<o)&&(o=t.index)}return o}a(ma,"findControlPlaneCutIndex");function ga(e){return cs.some(o=>e.includes(o))||ds.some(o=>o.test(e))}a(ga,"hasControlPlaneSignal");function us(e){let o=[];for(let n of e)n&&typeof n=="object"&&"type"in n&&n.type==="text"&&"text"in n&&o.push(String(n.text));return o}a(us,"collectTextBlocks");function Io(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}a(Io,"isRecord");function pa(e){if(typeof e=="string")return Q(e);if(e===void 0)return"";try{return ss(e)??""}catch{return Q(String(e))}}a(pa,"toolResultContentToString");function wa(e){let o=pa(e.content),n=o.trimStart(),t=e.is_error===!0||n.startsWith("[Tool Error]")||n.startsWith("[Error]"),r=n.startsWith("[Cancelled]")||n.startsWith("[Blocked]");return t?{status:"error",error:o}:r?{status:"cancelled",error:o}:{status:"success",output:o}}a(wa,"inferToolResultSeed");function ha(e){let o=new Map;if(!e||e.role!=="user"||!Array.isArray(e.content))return o;for(let n of e.content)!Io(n)||n.type!=="tool_result"||typeof n.tool_use_id!="string"||o.set(n.tool_use_id,wa(n));return o}a(ha,"collectToolResultSeeds");function ya(e,o){if(e.type!=="tool_use"||typeof e.id!="string"||typeof e.name!="string")return;let n=o.get(e.id)??{status:"cancelled",error:da};return{id:e.id,name:e.name,status:n.status,...e.input!==void 0?{input:rs(Io(e.input)?e.input:{})??{}}:{},...n.output!==void 0?{output:n.output}:{},...n.error!==void 0?{error:n.error}:{}}}a(ya,"buildToolCallSeed");function ka(e){return typeof e=="string"?e:Array.isArray(e)?us(e).join(`
3
3
  `):""}a(ka,"extractAssistantTextOnly");function Qe(e,o,n){n.trim().length!==0&&e.push({type:o,text:n})}a(Qe,"pushSeed");function as(e){return e.replace(/^\n+/,"").replace(/\n+$/,"")}a(as,"stripLegacyTagBoundaryNewlines");function va(e){let o=e.name,n=e.input;if(!n)return`\u26A1 ${o}`;let t=o==="bash"?Ze(String(n.command??"")):o==="read"||o==="write"||o==="edit"?Ze(String(n.file_path??n.path??"")):o==="grep"||o==="glob"?Ze(String(n.pattern??"")):o==="web_search"||o==="web_fetch"?Ze(String(n.query??n.url??"")):void 0;return t?`\u26A1 ${o}(${t})`:`\u26A1 ${o}`}a(va,"formatToolUseSummary");function Ze(e,o=60){let n=e.replace(/\s+/g," ").trim();return n.length>o?`${n.slice(0,o)}...`:n}a(Ze,"truncateToolHint");function Sa(e){if(!e.includes(sa)||!e.includes(ia))return e.trim().length>0?[{type:"assistant",text:e}]:[];let o=[],n=0;for(let t of e.matchAll(ca)){let r=t.index??-1,i=t[1]??"",l=t[2]??"";if(r<0)continue;let c=r+i.length;Qe(o,"assistant",as(e.slice(n,c))),Qe(o,"thinking",l),n=r+t[0].length}return Qe(o,"assistant",as(e.slice(n))),o.length===0?e.trim().length>0?[{type:"assistant",text:e}]:[]:o}a(Sa,"parseLegacyAssistantContent");function fs(e,o){if(typeof e=="string")return Sa(e);if(!Array.isArray(e))return[];let n=[],t=[],r=[],i=a(()=>{t.length!==0&&(Qe(n,"assistant",t.join(`
4
4
  `)),t.length=0)},"flushAssistantBuffer"),l=a(()=>{r.length!==0&&(n.push({type:"tool_group",tools:[...r]}),r.length=0)},"flushToolBuffer");for(let c of e)if(!(!Io(c)||typeof c.type!="string"))switch(c.type){case"text":l(),"text"in c&&t.push(String(c.text));break;case"thinking":i(),l(),"thinking"in c&&Qe(n,"thinking",String(c.thinking));break;case"tool_use":if(i(),o){let d=ya(c,o);d&&r.push(d)}else if(typeof c.name=="string"){let d=va({name:c.name,...Io(c.input)?{input:c.input}:{}});d&&n.push({type:"tool_summary",text:d})}break;case"tool_result":case"redacted_thinking":break;default:break}return l(),i(),n}a(fs,"extractAssistantHistorySeeds");var $a=["You are the Scout role","You are the Generator role","You are the Planner role","You are the Evaluator role"],ba=/\r?\n?\`\`\`kodax[\w-]*[\s\S]*?\`\`\`\s*/g;function xa(e){return $a.some(o=>e.includes(o))}a(xa,"isManagedWorkerPrompt");function ms(e){return e.replace(ba,"").trim()}a(ms,"stripManagedProtocolBlocks");function Aa(e){switch(e.role){case"assistant":return fs(e.content).flatMap(n=>{if(n.type!=="assistant")return[n];let t=ms(n.text);return t.length>0?[{...n,text:t}]:[]});case"user":{if(e._synthetic)return[];let o=gs(e.content);return o.trim().length===0||xa(o)?[]:[{type:"user",text:o}]}case"system":return[];default:return[]}}a(Aa,"extractHistorySeedsFromMessage");function Tu(e){let o=[];for(let n=0;n<e.length;n+=1){let t=e[n];if(t){if(t.role==="assistant"){let r=ha(e[n+1]),i=fs(t.content,r);o.push(...i.map(l=>l.type==="assistant"?{...l,text:ms(l.text)}:l).filter(l=>l.type!=="assistant"||l.text.length>0));continue}o.push(...Aa(t))}}return o}a(Tu,"extractHistorySeedsFromMessages");function gs(e){return typeof e=="string"?e:Array.isArray(e)?us(e).join(`
5
5
  `):""}a(gs,"extractTextContent");function Ra(e){let o=e.replace(/\s+/g," ").trim();return o?o.length>is?`${o.slice(0,is)}${ls}`:o:aa}a(Ra,"formatSessionTitle");function Ln(e){for(let o=e.length-1;o>=0;o--){let n=e[o];if(n?.role!=="assistant")continue;let t=ka(n.content);if(t)return t}return""}a(Ln,"extractLastAssistantText");function Eu(e,o,n,t){let r=[Ln(e),o.trim(),n?.trim()??"",t?.trim()??""];for(let i of r){let l=ps(i);if(l)return l}return""}a(Eu,"resolveCompletedAssistantText");function ps(e){let o=e.trim();if(!o)return"";let n=ma(o);return n===0?"":(n>0?o.slice(0,n):o).trim()}a(ps,"sanitizeUserFacingAssistantText");function Iu(e){let o=e.trim();return o.length>0&&ps(o).length===0&&ga(o)}a(Iu,"isControlPlaneOnlyAssistantText");function Cu(e){let o=e.find(t=>t.role==="user"),n=o?gs(o.content):"";return Ra(n)}a(Cu,"extractTitle");function _u(e,o=la){let n=e.replace(/\n/g," "),t=n.length>o?ls:"";return n.slice(0,o)+t}a(_u,"formatMessagePreview");var On={name:"copy",description:"Copy last assistant message to clipboard",usage:"/copy",handler:a(async(e,o)=>{let n=Ln(o.messages);if(!n){console.log(q.yellow(`
@@ -489,4 +489,4 @@ Available Skills:
489
489
  [Skill "${t}" is not user-invocable]`)),!1;console.log(s.cyan(`
490
490
  [Invoking skill: ${t}]`)),i.argumentHint&&console.log(s.dim(`Arguments: ${r||"(none)"}`)),console.log();let l=await n.loadFull(t),c={workingDirectory:process.cwd(),projectRoot:o.gitRoot??void 0,sessionId:o.sessionId,environment:{}},d=await jt(l,r,c);return console.log(s.green(`Skill activated: ${t}`)),console.log(s.dim("The skill context has been prepared for the AI.")),console.log(),{invocation:{prompt:d.content,source:"skill",displayName:t,path:l.skillFilePath,disableModelInvocation:d.disableModelInvocation,userInvocable:l.userInvocable,allowedTools:l.allowedTools,context:l.context,agent:l.agent,argumentHint:l.argumentHint,model:l.model,hooks:l.hooks,skillInvocation:{name:t,path:l.skillFilePath,description:l.description,arguments:r||void 0,allowedTools:l.allowedTools,context:l.context,agent:l.agent,argumentHint:l.argumentHint,model:l.model,hookEvents:l.hooks?Object.entries(l.hooks).filter(([,u])=>Array.isArray(u)&&u.length>0).map(([u])=>u):void 0,expandedContent:d.content}}}}catch(i){return console.log(s.red(`
491
491
  [Error invoking skill: ${i instanceof Error?i.message:String(i)}]`)),!1}}a(Nc,"executeSkillCommand");import{exec as Dc}from"node:child_process";import*as De from"node:path";import{promisify as Uc}from"node:util";var ii=Uc(Dc);function Fc(e){let o=e.slice(3);if(!o)return;let n=o.indexOf(" -> ");return(n===-1?o:o.slice(n+4)).replace(/^"(.*)"$/,"$1").trim()||void 0}a(Fc,"pathFromPorcelainLine");async function ai(e,o=10){try{let[{stdout:n},{stdout:t}]=await Promise.all([ii("git rev-parse --show-toplevel",{cwd:e}),ii("git status --porcelain=v1 -uall",{cwd:e})]),r=n.trim(),i=[],l=new Set;for(let c of t.split(`
492
- `)){if(!c.trim())continue;let d=Fc(c);if(!d)continue;let u=De.resolve(r,d),w=De.relative(e,u).split(De.sep).join("/");if(!(!w||w.startsWith("..")||l.has(w))&&(l.add(w),i.push(w),i.length>=o))break}return i}catch{return[]}}a(ai,"getRecentWorkingSetFiles");function Ue(e){let o=e.lastIndexOf("/");if(o===-1)return-1;for(;o>0&&!/\s/.test(e[o-1]??"");)if(o=e.lastIndexOf("/",o-1),o===-1)return-1;return o}a(Ue,"findCommandSlashIndex");var bt=class{static{a(this,"FileCompleter")}cwdSource;cache=new Map;cacheTimeout=5e3;recentCache=new Map;recentFilesProvider;constructor(o,n=ai){this.cwdSource=o,this.recentFilesProvider=n}canComplete(o,n){let t=o.slice(0,n),r=t.lastIndexOf("@");return!(r===-1||r>0&&!/\s/.test(t[r-1]??"")||t.slice(r+1).includes(" "))}async getCompletions(o,n){let t=o.slice(0,n),r=t.lastIndexOf("@");if(r===-1)return[];let i=t.slice(r+1),l=[],c=this.resolveCwd(),d=i.lastIndexOf("/"),u=d===-1?c:uo.join(c,i.slice(0,d)),w=d===-1?i:i.slice(d+1);try{let k=(await this.readdir(u)).filter(v=>v.toLowerCase().startsWith(w.toLowerCase()));for(let v of k){let h=uo.join(u,v),y=await this.isDirectory(h),m=d===-1?v:i.slice(0,d+1)+v;l.push({text:"@"+m+(y?"/":""),display:v+(y?"/":""),description:y?"directory":"file",type:"file"})}}catch{}if(d===-1){let f=await this.getRecentFiles(c),k=new Set(l.map(y=>y.text)),v=w.toLowerCase(),h=[];for(let y of f){if(w&&!uo.basename(y).toLowerCase().startsWith(v))continue;let m="@"+y;k.has(m)||(k.add(m),h.push({text:m,display:y,description:"recent",type:"file"}))}l.unshift(...h)}return l}async getRecentFiles(o){let n=Date.now(),t=this.recentCache.get(o);if(t&&t.expiresAt>n)return t.files;let r=await this.recentFilesProvider(o);return this.recentCache.set(o,{files:r,expiresAt:Date.now()+this.cacheTimeout}),r}resolveCwd(){return typeof this.cwdSource=="function"?this.cwdSource():this.cwdSource??process.cwd()}async readdir(o){let n=Date.now(),t=this.cache.get(o);return t&&t.expiresAt>n?t.entries:(t&&this.cache.delete(o),new Promise(r=>{Zo.readdir(o,(i,l)=>{i?r([]):(this.cache.set(o,{entries:l,expiresAt:Date.now()+this.cacheTimeout}),r(l))})}))}async isDirectory(o){return new Promise(n=>{Zo.stat(o,(t,r)=>{n(!t&&r.isDirectory())})})}},xt=class{static{a(this,"CommandCompleter")}commands;constructor(){this.commands=new Map,this.loadCommands()}loadCommands(){for(let n of Jo().getAll())n.userInvocable!==!1&&this.commands.set(n.name,{description:n.description,aliases:n.aliases??[]});let o=Z();for(let n of o?.listCommands()??[])n.metadata?.userInvocable!==!1&&this.commands.set(n.name,{description:n.description,aliases:n.aliases??[]})}canComplete(o,n){let t=o.slice(0,n),r=Ue(t);return r===-1?!1:!t.slice(r).includes(" ")}async getCompletions(o,n){let t=o.slice(0,n),r=Ue(t);if(r===-1)return[];this.commands.clear(),this.loadCommands();let i=t.slice(r+1).toLowerCase(),l=[];for(let[c,d]of this.commands){this.fuzzyMatch(i,c)&&l.push({text:"/"+c,display:"/"+c,description:d.description,type:"command"});for(let u of d.aliases)u!==c&&this.fuzzyMatch(i,u)&&l.push({text:"/"+u,display:"/"+u,description:`Alias for /${c}: ${d.description}`,type:"command"})}return l}fuzzyMatch(o,n){if(!o)return!0;let t=o.toLowerCase(),r=n.toLowerCase(),i=0;for(let l=0;l<r.length&&i<t.length;l++)r[l]===t[i]&&i++;return i===t.length}};function Lg(e){let o=new bt(e),n=new xt;return async t=>{let r=t.includes("@"),i=t.includes("/");if(!r&&!i)return[[],t];let l=[];if(i){let d=await jc(t,t.length);l.push(...d)}if(i&&n.canComplete(t,t.length)){let d=await n.getCompletions(t,t.length);l.push(...d)}if(r&&o.canComplete(t,t.length)){let d=await o.getCompletions(t,t.length);l.push(...d)}return[l.map(d=>Hc(t,d)),t]}}a(Lg,"createCompleter");async function jc(e,o){let{ArgumentCompleter:n}=await import("./argument-completer-MAJVHSE7.js"),t=new n;return t.canComplete(e,o)?t.getCompletions(e,o):[]}a(jc,"getArgumentCompletions");function Hc(e,o){if(o.type!=="argument")return o.display;let n=Ue(e);if(n!==-1&&!/\s/.test(e.slice(n)))return`${e} ${o.text}`;let r=e.match(/\S+$/)?.[0]??"";return`${r?e.slice(0,e.length-r.length):e}${o.text}`}a(Hc,"formatReadlineCompletion");import{existsSync as en,readdirSync as fi,readFileSync as mi}from"node:fs";import{join as on}from"node:path";var Bc=[{name:"plan",description:"Read-only planning mode - blocks all modifications",type:"enum"},{name:"accept-edits",description:"File edits auto-approved, bash requires confirmation",type:"enum"},{name:"auto-in-project",description:"All tools auto within project directory",type:"enum"}],Qo=[{name:"on",description:"Map to reasoning auto",type:"enum"},{name:"off",description:"Disable reasoning",type:"enum"},{name:"auto",description:"Use semantic routing with adaptive depth",type:"enum"},{name:"quick",description:"Low-depth reasoning mode",type:"enum"},{name:"balanced",description:"Medium-depth reasoning mode",type:"enum"},{name:"deep",description:"High-depth reasoning mode",type:"enum"}],li=Qo.slice(2).concat([{name:"off",description:"Disable reasoning",type:"enum"}]);function qc(e){if(e&&e.includes("/")){let o=e.indexOf("/"),n=e.slice(0,o),t=e.slice(o+1);if(xe(n))try{return Ie(n).filter(i=>!t||i.toLowerCase().includes(t.toLowerCase())).map(i=>({name:`${n}/${i}`,description:i,type:"enum"}))}catch{}return[]}return Ae().map(o=>({name:o,description:`Switch to ${o} provider`,type:"enum"}))}a(qc,"getModelArgs");var ci=[{name:"on",description:"Enable plan mode for all requests",type:"enum"},{name:"off",description:"Disable plan mode",type:"enum"},{name:"once",description:"Run plan mode for a single request (followed by task)",type:"enum"},{name:"list",description:"List all saved plans",type:"enum"},{name:"resume",description:"Resume a saved plan (followed by plan ID)",type:"enum"},{name:"clear",description:"Clear completed plans",type:"enum"}],At=[{name:"workspace",description:"Inspect current workspace/runtime truth in more detail",type:"enum"},{name:"runtime",description:"Alias for workspace runtime inspection",type:"enum"},{name:"worktree",description:"Alias for workspace runtime inspection",type:"enum"}],Rt=[{name:"all",description:"Delete ALL sessions",type:"enum"}],zc=[{name:"status",description:"Inspect the current repo-intelligence runtime state",type:"enum"},{name:"warm",description:"Warm or start the local premium runtime if available",type:"enum"},{name:"mode",description:"Switch repo-intelligence runtime mode",type:"enum"},{name:"trace",description:"Toggle repo-intelligence trace output",type:"enum"},{name:"endpoint",description:"Inspect or override the local repointel daemon endpoint",type:"enum"},{name:"bin",description:"Inspect or override the local repointel command or path",type:"enum"}],Kc=[{name:"auto",description:"Resolve to premium-native when available, otherwise fall back to oss",type:"enum"},{name:"off",description:"Disable repo-intelligence injection",type:"enum"},{name:"oss",description:"Use only the public OSS repo-intelligence baseline",type:"enum"},{name:"premium-shared",description:"Use premium without the native KodaX auto lane",type:"enum"},{name:"premium-native",description:"Use premium through the native KodaX bridge",type:"enum"}],Gc=[{name:"on",description:"Enable repo-intelligence trace output",type:"enum"},{name:"off",description:"Disable repo-intelligence trace output",type:"enum"},{name:"toggle",description:"Toggle repo-intelligence trace output",type:"enum"}],di=[{name:"default",description:"Clear the override and use the default value again",type:"enum"}],Xc=[{name:"list",description:"List built-in and saved workflows",type:"enum"},{name:"create",description:"Generate and run a workflow from a request",type:"enum"},{name:"runs",description:"List active and recent workflow runs",type:"enum"},{name:"show",description:"Show latest run or a specific workflow run",type:"enum"},{name:"pause",description:"Pause future child launches for a run",type:"enum"},{name:"resume",description:"Resume a paused run",type:"enum"},{name:"stop",description:"Stop an active workflow run",type:"enum"},{name:"delete",description:"Delete one persisted workflow run or generated saved capsule",type:"enum"},{name:"prune",description:"Preview or delete old terminal workflow runs",type:"enum"},{name:"rerun",description:"Rerun a run id or saved workflow name",type:"enum"},{name:"save",description:"Save a generated run as a workflow capsule",type:"enum"},{name:"rename",description:"Rename a run display name or saved workflow capsule",type:"enum"},{name:"revise",description:"Generate a revised workflow capsule",type:"enum"},{name:"help",description:"Show workflow help",type:"enum"}],Vc=new Set(["show","pause","resume","stop","delete","rerun","save","rename","revise"]),Yc=new Set(["show","delete","rerun","save","rename","revise"]),Jc=[{name:"--all",description:"Show all persisted workflow runs",type:"enum"},{name:"--limit",description:"Show at most N persisted workflow runs",type:"enum"}],Zc=[{name:"--dry-run",description:"Preview cleanup without deleting runs",type:"enum"},{name:"--keep",description:"Keep the newest N terminal runs",type:"enum"},{name:"--older-than",description:"Delete terminal runs older than Nd or Nh",type:"enum"}],Qc=[{name:"--force",description:"Delete stale non-terminal run records",type:"enum"},{name:"--run",description:"Treat the target as a workflow run record",type:"enum"},{name:"--saved",description:"Treat the target as a generated saved workflow capsule",type:"enum"}],ed=[".workflow.json",".ts",".mjs",".js"];function od(e,o){switch(e){case"pause":return o==="running";case"resume":return o==="paused";case"stop":return o==="running"||o==="paused";case"delete":return o!=="running"&&o!=="paused";default:return!0}}a(od,"workflowRunMatchesSubcommand");function nn(e){return/^[a-zA-Z0-9._-]{1,120}$/.test(e)&&!e.startsWith(".")&&!e.includes("..")}a(nn,"isWorkflowRunEntryName");function nd(e,o){let n=on(e,"workflow-metadata.json");if(en(n))try{let r=JSON.parse(mi(n,"utf8"));if(typeof r=="object"&&r!==null){let i=r.displayName;if(typeof i=="string"&&nn(i.trim()))return i.trim()}}catch{}let t=o.displayName;return typeof t=="string"&&nn(t.trim())?t.trim():void 0}a(nd,"readWorkflowRunDisplayName");function td(){let e=ye(process.cwd()).key,o=N("workflow-runs",e);if(!en(o))return[];let n=[];for(let t of fi(o)){if(!nn(t))continue;let r=on(o,t,"run.json");if(en(r))try{let i=JSON.parse(mi(r,"utf8")),l=typeof i.workflow=="string"?i.workflow:"?",c=typeof i.status=="string"?i.status:"?",d=typeof i.endedAt=="number"?i.endedAt:0;n.push({arg:{name:t,description:`${l} - ${c}`,type:"string"},endedAt:d});let u=nd(on(o,t),i);u&&u!==t&&n.push({arg:{name:u,description:`${l} alias for ${t} - ${c}`,type:"string"},endedAt:d})}catch{}}return n.sort((t,r)=>r.endedAt-t.endedAt).map(t=>t.arg)}a(td,"getPersistedWorkflowRunIdArgs");function tn(e){let o=Ee().list().filter(r=>od(e,r.status)).map(r=>({name:r.runId,description:`${r.workflow} - ${r.status}`,type:"string"})),n=Yc.has(e)?td():[],t=new Set;return[...o,...n].filter(r=>t.has(r.name)?!1:(t.add(r.name),!0))}a(tn,"getWorkflowRunIdArgs");function rd(e){for(let o of ed)if(e.endsWith(o)){let n=e.slice(0,-o.length);return nn(n)?n:void 0}}a(rd,"savedWorkflowNameFromFile");function fo(e={}){let o=[{path:N("workflows"),source:"personal"},{path:on(process.cwd(),".kodax","workflows"),source:"project"}],n=new Map;for(let t of o)if(en(t.path))try{for(let r of fi(t.path)){if(e.generatedOnly===!0&&!r.endsWith(".workflow.json"))continue;let i=rd(r);i&&n.set(i,{name:i,description:`${t.source} saved workflow`,type:"enum"})}}catch{}return[...n.values()].sort((t,r)=>t.name.localeCompare(r.name))}a(fo,"getSavedWorkflowNameArgs");function sd(){let e=new Map;for(let o of tn("rerun"))e.set(o.name,{...o,description:`recent run: ${o.description}`,type:"string"});for(let o of fo()){let n=e.get(o.name);if(n){e.set(o.name,{...n,description:`${n.description}; also ${o.description}`});continue}e.set(o.name,{...o,description:o.description,type:"string"})}return[...e.values()]}a(sd,"getWorkflowRerunArgs");function Tt(e){let o=new Map;for(let n of tn(e))o.set(n.name,{...n,description:`workflow run: ${n.description}`,type:"string"});for(let n of fo({generatedOnly:e==="delete"})){let t=o.get(n.name);if(t){o.set(n.name,{...t,description:`${t.description}; also ${n.description}`});continue}o.set(n.name,{...n,description:n.description,type:"string"})}return[...o.values()]}a(Tt,"getWorkflowRunOrSavedNameArgs");function ui(e){let o=new Set(e.slice(1).filter(n=>n.startsWith("--")));return o.has("--saved")?fo({generatedOnly:!0}):o.has("--run")?tn("delete"):Tt("delete")}a(ui,"getWorkflowDeleteTargetArgs");function id(e){let[o=""]=e,n=o.toLowerCase(),t=e.length===1&&e[0]===""?0:e.length;if(t<=1)return[...Xc,...ze().map(r=>({name:r.name,description:r.description,type:"enum"})),...fo()];if(n==="rerun"&&t<=2)return sd();if(n==="rename"&&t<=2)return Tt("rename");if(n==="delete"&&t<=2)return[...Qc,...ui(e)];if(n==="delete"&&t<=3&&e.slice(1).some(r=>r.startsWith("--")))return ui(e);if(n==="revise"){if(t<=2)return[{name:"--replace",description:"Replace a saved workflow after confirmation",type:"enum"},...Tt("revise")];if(e[1]==="--replace"&&t<=3)return fo()}return Vc.has(n)&&t<=2?tn(n):n==="runs"&&t<=2?Jc:n==="prune"&&t<=2?Zc:[]}a(id,"getWorkflowArgs");function ad(e){let[o=""]=e,n=o.toLowerCase(),t=e.length===1&&e[0]===""?0:e.length;return t<=1?zc:t>2?[]:n==="mode"?Kc:n==="trace"?Gc:n==="endpoint"?[...di,{name:zt,description:"Default local repointel daemon endpoint",type:"string"}]:n==="bin"?di:[]}a(ad,"getRepointelArgs");var ld=new Map([["mode",Bc],["thinking",Qo],["think",Qo],["t",Qo],["reasoning",li],["reason",li],["plan",ci],["p",ci],["status",At],["info",At],["ctx",At],["delete",Rt],["rm",Rt],["del",Rt]]),cd=new Set(["model","m"]),dd=new Set(["repointel","ri"]),ud=new Set(["workflow"]);function Et(e,o,n=[]){let t=e.toLowerCase();return cd.has(t)?qc(o):dd.has(t)?ad(n):ud.has(t)?id(n):ld.get(t)??[]}a(Et,"getCommandArguments");var It=class{static{a(this,"ArgumentCompleter")}canComplete(o,n){let t=o.slice(0,n),r=Ue(t);if(r===-1)return!1;let i=t.slice(r),l=i.split(/\s+/);if(l.length>=2&&l[0]!=="")return!0;let c=i.slice(1).toLowerCase();return Et(c).length>0}async getCompletions(o,n){let t=o.slice(0,n),r=Ue(t);if(r===-1)return[];let i=t.slice(r),l=i.indexOf(" "),c=(l===-1?i.slice(1):i.slice(1,l)).toLowerCase(),d=l===-1?"":i.slice(l+1),u=d?d.split(/\s+/):[""],w=u.length-1,f=(u[w]??"").toLowerCase(),k=Et(c,f,u);if(!k||k.length===0)return[];let v=new Set(u.slice(0,-1).map(y=>y.toLowerCase()));return k.filter(y=>!v.has(y.name.toLowerCase())).filter(y=>!f||y.name.includes("/")?!0:y.name.toLowerCase().includes(f)).map(y=>({text:y.name,display:y.name,description:y.description,type:"argument"})).sort((y,m)=>{if(!f)return 0;let x=y.display.toLowerCase().startsWith(f),A=m.display.toLowerCase().startsWith(f);return x&&!A?-1:!x&&A?1:y.display.length-m.display.length})}};function Xg(){return new It}a(Xg,"createArgumentCompleter");export{Mn as a,F as b,ku as c,os as d,vu as e,vo as f,gd as g,hi as h,pd as i,Ke as j,Sr as k,$r as l,Ge as m,$n as n,Mi as o,bn as p,An as q,Rn as r,Ye as s,Di as t,Tn as u,_e as v,Hr as w,Br as x,Yi as y,su as z,Cn as A,iu as B,au as C,Vr as D,es as E,Q as F,rs as G,ss as H,Ru as I,fa as J,Aa as K,Tu as L,gs as M,Ln as N,Eu as O,ps as P,Iu as Q,Cu as R,_u as S,Zu as T,Qu as U,ef as V,vs as W,Un as X,Ss as Y,ye as Z,af as _,ve as $,Sl as aa,$l as ba,If as ca,Cf as da,st as ea,Sm as fa,$m as ga,bm as ha,xm as ia,Am as ja,Xs as ka,_m as la,Pm as ma,Ys as na,Mm as oa,Js as pa,xg as qa,Ag as ra,It as sa,Xg as ta,Ue as ua,bt as va,xt as wa,Lg as xa};
492
+ `)){if(!c.trim())continue;let d=Fc(c);if(!d)continue;let u=De.resolve(r,d),w=De.relative(e,u).split(De.sep).join("/");if(!(!w||w.startsWith("..")||l.has(w))&&(l.add(w),i.push(w),i.length>=o))break}return i}catch{return[]}}a(ai,"getRecentWorkingSetFiles");function Ue(e){let o=e.lastIndexOf("/");if(o===-1)return-1;for(;o>0&&!/\s/.test(e[o-1]??"");)if(o=e.lastIndexOf("/",o-1),o===-1)return-1;return o}a(Ue,"findCommandSlashIndex");var bt=class{static{a(this,"FileCompleter")}cwdSource;cache=new Map;cacheTimeout=5e3;recentCache=new Map;recentFilesProvider;constructor(o,n=ai){this.cwdSource=o,this.recentFilesProvider=n}canComplete(o,n){let t=o.slice(0,n),r=t.lastIndexOf("@");return!(r===-1||r>0&&!/\s/.test(t[r-1]??"")||t.slice(r+1).includes(" "))}async getCompletions(o,n){let t=o.slice(0,n),r=t.lastIndexOf("@");if(r===-1)return[];let i=t.slice(r+1),l=[],c=this.resolveCwd(),d=i.lastIndexOf("/"),u=d===-1?c:uo.join(c,i.slice(0,d)),w=d===-1?i:i.slice(d+1);try{let k=(await this.readdir(u)).filter(v=>v.toLowerCase().startsWith(w.toLowerCase()));for(let v of k){let h=uo.join(u,v),y=await this.isDirectory(h),m=d===-1?v:i.slice(0,d+1)+v;l.push({text:"@"+m+(y?"/":""),display:v+(y?"/":""),description:y?"directory":"file",type:"file"})}}catch{}if(d===-1){let f=await this.getRecentFiles(c),k=new Set(l.map(y=>y.text)),v=w.toLowerCase(),h=[];for(let y of f){if(w&&!uo.basename(y).toLowerCase().startsWith(v))continue;let m="@"+y;k.has(m)||(k.add(m),h.push({text:m,display:y,description:"recent",type:"file"}))}l.unshift(...h)}return l}async getRecentFiles(o){let n=Date.now(),t=this.recentCache.get(o);if(t&&t.expiresAt>n)return t.files;let r=await this.recentFilesProvider(o);return this.recentCache.set(o,{files:r,expiresAt:Date.now()+this.cacheTimeout}),r}resolveCwd(){return typeof this.cwdSource=="function"?this.cwdSource():this.cwdSource??process.cwd()}async readdir(o){let n=Date.now(),t=this.cache.get(o);return t&&t.expiresAt>n?t.entries:(t&&this.cache.delete(o),new Promise(r=>{Zo.readdir(o,(i,l)=>{i?r([]):(this.cache.set(o,{entries:l,expiresAt:Date.now()+this.cacheTimeout}),r(l))})}))}async isDirectory(o){return new Promise(n=>{Zo.stat(o,(t,r)=>{n(!t&&r.isDirectory())})})}},xt=class{static{a(this,"CommandCompleter")}commands;constructor(){this.commands=new Map,this.loadCommands()}loadCommands(){for(let n of Jo().getAll())n.userInvocable!==!1&&this.commands.set(n.name,{description:n.description,aliases:n.aliases??[]});let o=Z();for(let n of o?.listCommands()??[])n.metadata?.userInvocable!==!1&&this.commands.set(n.name,{description:n.description,aliases:n.aliases??[]})}canComplete(o,n){let t=o.slice(0,n),r=Ue(t);return r===-1?!1:!t.slice(r).includes(" ")}async getCompletions(o,n){let t=o.slice(0,n),r=Ue(t);if(r===-1)return[];this.commands.clear(),this.loadCommands();let i=t.slice(r+1).toLowerCase(),l=[];for(let[c,d]of this.commands){this.fuzzyMatch(i,c)&&l.push({text:"/"+c,display:"/"+c,description:d.description,type:"command"});for(let u of d.aliases)u!==c&&this.fuzzyMatch(i,u)&&l.push({text:"/"+u,display:"/"+u,description:`Alias for /${c}: ${d.description}`,type:"command"})}return l}fuzzyMatch(o,n){if(!o)return!0;let t=o.toLowerCase(),r=n.toLowerCase(),i=0;for(let l=0;l<r.length&&i<t.length;l++)r[l]===t[i]&&i++;return i===t.length}};function Lg(e){let o=new bt(e),n=new xt;return async t=>{let r=t.includes("@"),i=t.includes("/");if(!r&&!i)return[[],t];let l=[];if(i){let d=await jc(t,t.length);l.push(...d)}if(i&&n.canComplete(t,t.length)){let d=await n.getCompletions(t,t.length);l.push(...d)}if(r&&o.canComplete(t,t.length)){let d=await o.getCompletions(t,t.length);l.push(...d)}return[l.map(d=>Hc(t,d)),t]}}a(Lg,"createCompleter");async function jc(e,o){let{ArgumentCompleter:n}=await import("./argument-completer-VMH6VZ4X.js"),t=new n;return t.canComplete(e,o)?t.getCompletions(e,o):[]}a(jc,"getArgumentCompletions");function Hc(e,o){if(o.type!=="argument")return o.display;let n=Ue(e);if(n!==-1&&!/\s/.test(e.slice(n)))return`${e} ${o.text}`;let r=e.match(/\S+$/)?.[0]??"";return`${r?e.slice(0,e.length-r.length):e}${o.text}`}a(Hc,"formatReadlineCompletion");import{existsSync as en,readdirSync as fi,readFileSync as mi}from"node:fs";import{join as on}from"node:path";var Bc=[{name:"plan",description:"Read-only planning mode - blocks all modifications",type:"enum"},{name:"accept-edits",description:"File edits auto-approved, bash requires confirmation",type:"enum"},{name:"auto-in-project",description:"All tools auto within project directory",type:"enum"}],Qo=[{name:"on",description:"Map to reasoning auto",type:"enum"},{name:"off",description:"Disable reasoning",type:"enum"},{name:"auto",description:"Use semantic routing with adaptive depth",type:"enum"},{name:"quick",description:"Low-depth reasoning mode",type:"enum"},{name:"balanced",description:"Medium-depth reasoning mode",type:"enum"},{name:"deep",description:"High-depth reasoning mode",type:"enum"}],li=Qo.slice(2).concat([{name:"off",description:"Disable reasoning",type:"enum"}]);function qc(e){if(e&&e.includes("/")){let o=e.indexOf("/"),n=e.slice(0,o),t=e.slice(o+1);if(xe(n))try{return Ie(n).filter(i=>!t||i.toLowerCase().includes(t.toLowerCase())).map(i=>({name:`${n}/${i}`,description:i,type:"enum"}))}catch{}return[]}return Ae().map(o=>({name:o,description:`Switch to ${o} provider`,type:"enum"}))}a(qc,"getModelArgs");var ci=[{name:"on",description:"Enable plan mode for all requests",type:"enum"},{name:"off",description:"Disable plan mode",type:"enum"},{name:"once",description:"Run plan mode for a single request (followed by task)",type:"enum"},{name:"list",description:"List all saved plans",type:"enum"},{name:"resume",description:"Resume a saved plan (followed by plan ID)",type:"enum"},{name:"clear",description:"Clear completed plans",type:"enum"}],At=[{name:"workspace",description:"Inspect current workspace/runtime truth in more detail",type:"enum"},{name:"runtime",description:"Alias for workspace runtime inspection",type:"enum"},{name:"worktree",description:"Alias for workspace runtime inspection",type:"enum"}],Rt=[{name:"all",description:"Delete ALL sessions",type:"enum"}],zc=[{name:"status",description:"Inspect the current repo-intelligence runtime state",type:"enum"},{name:"warm",description:"Warm or start the local premium runtime if available",type:"enum"},{name:"mode",description:"Switch repo-intelligence runtime mode",type:"enum"},{name:"trace",description:"Toggle repo-intelligence trace output",type:"enum"},{name:"endpoint",description:"Inspect or override the local repointel daemon endpoint",type:"enum"},{name:"bin",description:"Inspect or override the local repointel command or path",type:"enum"}],Kc=[{name:"auto",description:"Resolve to premium-native when available, otherwise fall back to oss",type:"enum"},{name:"off",description:"Disable repo-intelligence injection",type:"enum"},{name:"oss",description:"Use only the public OSS repo-intelligence baseline",type:"enum"},{name:"premium-shared",description:"Use premium without the native KodaX auto lane",type:"enum"},{name:"premium-native",description:"Use premium through the native KodaX bridge",type:"enum"}],Gc=[{name:"on",description:"Enable repo-intelligence trace output",type:"enum"},{name:"off",description:"Disable repo-intelligence trace output",type:"enum"},{name:"toggle",description:"Toggle repo-intelligence trace output",type:"enum"}],di=[{name:"default",description:"Clear the override and use the default value again",type:"enum"}],Xc=[{name:"list",description:"List built-in and saved workflows",type:"enum"},{name:"create",description:"Generate and run a workflow from a request",type:"enum"},{name:"runs",description:"List active and recent workflow runs",type:"enum"},{name:"show",description:"Show latest run or a specific workflow run",type:"enum"},{name:"pause",description:"Pause future child launches for a run",type:"enum"},{name:"resume",description:"Resume a paused run",type:"enum"},{name:"stop",description:"Stop an active workflow run",type:"enum"},{name:"delete",description:"Delete one persisted workflow run or generated saved capsule",type:"enum"},{name:"prune",description:"Preview or delete old terminal workflow runs",type:"enum"},{name:"rerun",description:"Rerun a run id or saved workflow name",type:"enum"},{name:"save",description:"Save a generated run as a workflow capsule",type:"enum"},{name:"rename",description:"Rename a run display name or saved workflow capsule",type:"enum"},{name:"revise",description:"Generate a revised workflow capsule",type:"enum"},{name:"help",description:"Show workflow help",type:"enum"}],Vc=new Set(["show","pause","resume","stop","delete","rerun","save","rename","revise"]),Yc=new Set(["show","delete","rerun","save","rename","revise"]),Jc=[{name:"--all",description:"Show all persisted workflow runs",type:"enum"},{name:"--limit",description:"Show at most N persisted workflow runs",type:"enum"}],Zc=[{name:"--dry-run",description:"Preview cleanup without deleting runs",type:"enum"},{name:"--keep",description:"Keep the newest N terminal runs",type:"enum"},{name:"--older-than",description:"Delete terminal runs older than Nd or Nh",type:"enum"}],Qc=[{name:"--force",description:"Delete stale non-terminal run records",type:"enum"},{name:"--run",description:"Treat the target as a workflow run record",type:"enum"},{name:"--saved",description:"Treat the target as a generated saved workflow capsule",type:"enum"}],ed=[".workflow.json",".ts",".mjs",".js"];function od(e,o){switch(e){case"pause":return o==="running";case"resume":return o==="paused";case"stop":return o==="running"||o==="paused";case"delete":return o!=="running"&&o!=="paused";default:return!0}}a(od,"workflowRunMatchesSubcommand");function nn(e){return/^[a-zA-Z0-9._-]{1,120}$/.test(e)&&!e.startsWith(".")&&!e.includes("..")}a(nn,"isWorkflowRunEntryName");function nd(e,o){let n=on(e,"workflow-metadata.json");if(en(n))try{let r=JSON.parse(mi(n,"utf8"));if(typeof r=="object"&&r!==null){let i=r.displayName;if(typeof i=="string"&&nn(i.trim()))return i.trim()}}catch{}let t=o.displayName;return typeof t=="string"&&nn(t.trim())?t.trim():void 0}a(nd,"readWorkflowRunDisplayName");function td(){let e=ye(process.cwd()).key,o=N("workflow-runs",e);if(!en(o))return[];let n=[];for(let t of fi(o)){if(!nn(t))continue;let r=on(o,t,"run.json");if(en(r))try{let i=JSON.parse(mi(r,"utf8")),l=typeof i.workflow=="string"?i.workflow:"?",c=typeof i.status=="string"?i.status:"?",d=typeof i.endedAt=="number"?i.endedAt:0;n.push({arg:{name:t,description:`${l} - ${c}`,type:"string"},endedAt:d});let u=nd(on(o,t),i);u&&u!==t&&n.push({arg:{name:u,description:`${l} alias for ${t} - ${c}`,type:"string"},endedAt:d})}catch{}}return n.sort((t,r)=>r.endedAt-t.endedAt).map(t=>t.arg)}a(td,"getPersistedWorkflowRunIdArgs");function tn(e){let o=Ee().list().filter(r=>od(e,r.status)).map(r=>({name:r.runId,description:`${r.workflow} - ${r.status}`,type:"string"})),n=Yc.has(e)?td():[],t=new Set;return[...o,...n].filter(r=>t.has(r.name)?!1:(t.add(r.name),!0))}a(tn,"getWorkflowRunIdArgs");function rd(e){for(let o of ed)if(e.endsWith(o)){let n=e.slice(0,-o.length);return nn(n)?n:void 0}}a(rd,"savedWorkflowNameFromFile");function fo(e={}){let o=[{path:N("workflows"),source:"personal"},{path:on(process.cwd(),".kodax","workflows"),source:"project"}],n=new Map;for(let t of o)if(en(t.path))try{for(let r of fi(t.path)){if(e.generatedOnly===!0&&!r.endsWith(".workflow.json"))continue;let i=rd(r);i&&n.set(i,{name:i,description:`${t.source} saved workflow`,type:"enum"})}}catch{}return[...n.values()].sort((t,r)=>t.name.localeCompare(r.name))}a(fo,"getSavedWorkflowNameArgs");function sd(){let e=new Map;for(let o of tn("rerun"))e.set(o.name,{...o,description:`recent run: ${o.description}`,type:"string"});for(let o of fo()){let n=e.get(o.name);if(n){e.set(o.name,{...n,description:`${n.description}; also ${o.description}`});continue}e.set(o.name,{...o,description:o.description,type:"string"})}return[...e.values()]}a(sd,"getWorkflowRerunArgs");function Tt(e){let o=new Map;for(let n of tn(e))o.set(n.name,{...n,description:`workflow run: ${n.description}`,type:"string"});for(let n of fo({generatedOnly:e==="delete"})){let t=o.get(n.name);if(t){o.set(n.name,{...t,description:`${t.description}; also ${n.description}`});continue}o.set(n.name,{...n,description:n.description,type:"string"})}return[...o.values()]}a(Tt,"getWorkflowRunOrSavedNameArgs");function ui(e){let o=new Set(e.slice(1).filter(n=>n.startsWith("--")));return o.has("--saved")?fo({generatedOnly:!0}):o.has("--run")?tn("delete"):Tt("delete")}a(ui,"getWorkflowDeleteTargetArgs");function id(e){let[o=""]=e,n=o.toLowerCase(),t=e.length===1&&e[0]===""?0:e.length;if(t<=1)return[...Xc,...ze().map(r=>({name:r.name,description:r.description,type:"enum"})),...fo()];if(n==="rerun"&&t<=2)return sd();if(n==="rename"&&t<=2)return Tt("rename");if(n==="delete"&&t<=2)return[...Qc,...ui(e)];if(n==="delete"&&t<=3&&e.slice(1).some(r=>r.startsWith("--")))return ui(e);if(n==="revise"){if(t<=2)return[{name:"--replace",description:"Replace a saved workflow after confirmation",type:"enum"},...Tt("revise")];if(e[1]==="--replace"&&t<=3)return fo()}return Vc.has(n)&&t<=2?tn(n):n==="runs"&&t<=2?Jc:n==="prune"&&t<=2?Zc:[]}a(id,"getWorkflowArgs");function ad(e){let[o=""]=e,n=o.toLowerCase(),t=e.length===1&&e[0]===""?0:e.length;return t<=1?zc:t>2?[]:n==="mode"?Kc:n==="trace"?Gc:n==="endpoint"?[...di,{name:zt,description:"Default local repointel daemon endpoint",type:"string"}]:n==="bin"?di:[]}a(ad,"getRepointelArgs");var ld=new Map([["mode",Bc],["thinking",Qo],["think",Qo],["t",Qo],["reasoning",li],["reason",li],["plan",ci],["p",ci],["status",At],["info",At],["ctx",At],["delete",Rt],["rm",Rt],["del",Rt]]),cd=new Set(["model","m"]),dd=new Set(["repointel","ri"]),ud=new Set(["workflow"]);function Et(e,o,n=[]){let t=e.toLowerCase();return cd.has(t)?qc(o):dd.has(t)?ad(n):ud.has(t)?id(n):ld.get(t)??[]}a(Et,"getCommandArguments");var It=class{static{a(this,"ArgumentCompleter")}canComplete(o,n){let t=o.slice(0,n),r=Ue(t);if(r===-1)return!1;let i=t.slice(r),l=i.split(/\s+/);if(l.length>=2&&l[0]!=="")return!0;let c=i.slice(1).toLowerCase();return Et(c).length>0}async getCompletions(o,n){let t=o.slice(0,n),r=Ue(t);if(r===-1)return[];let i=t.slice(r),l=i.indexOf(" "),c=(l===-1?i.slice(1):i.slice(1,l)).toLowerCase(),d=l===-1?"":i.slice(l+1),u=d?d.split(/\s+/):[""],w=u.length-1,f=(u[w]??"").toLowerCase(),k=Et(c,f,u);if(!k||k.length===0)return[];let v=new Set(u.slice(0,-1).map(y=>y.toLowerCase()));return k.filter(y=>!v.has(y.name.toLowerCase())).filter(y=>!f||y.name.includes("/")?!0:y.name.toLowerCase().includes(f)).map(y=>({text:y.name,display:y.name,description:y.description,type:"argument"})).sort((y,m)=>{if(!f)return 0;let x=y.display.toLowerCase().startsWith(f),A=m.display.toLowerCase().startsWith(f);return x&&!A?-1:!x&&A?1:y.display.length-m.display.length})}};function Xg(){return new It}a(Xg,"createArgumentCompleter");export{Mn as a,F as b,ku as c,os as d,vu as e,vo as f,gd as g,hi as h,pd as i,Ke as j,Sr as k,$r as l,Ge as m,$n as n,Mi as o,bn as p,An as q,Rn as r,Ye as s,Di as t,Tn as u,_e as v,Hr as w,Br as x,Yi as y,su as z,Cn as A,iu as B,au as C,Vr as D,es as E,Q as F,rs as G,ss as H,Ru as I,fa as J,Aa as K,Tu as L,gs as M,Ln as N,Eu as O,ps as P,Iu as Q,Cu as R,_u as S,Zu as T,Qu as U,ef as V,vs as W,Un as X,Ss as Y,ye as Z,af as _,ve as $,Sl as aa,$l as ba,If as ca,Cf as da,st as ea,Sm as fa,$m as ga,bm as ha,xm as ia,Am as ja,Xs as ka,_m as la,Pm as ma,Ys as na,Mm as oa,Js as pa,xg as qa,Ag as ra,It as sa,Xg as ta,Ue as ua,bt as va,xt as wa,Lg as xa};
@@ -1,2 +1,2 @@
1
1
  // @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
2
- import{tb as k,vb as D}from"./chunk-WQTVG2T5.js";import{U as S,V as w,W as L,X as I,Y as O,Z as h,ea as x,fa as m,ia as b,sa as A}from"./chunk-PEWH3AAL.js";import{va as R}from"./chunk-HMATTIU6.js";import{a as o}from"./chunk-V4WSBIXB.js";import s from"fs";import c from"path";import{exec as H,spawnSync as z}from"child_process";import{promisify as U}from"util";import{fileURLToPath as q}from"url";var E="en";function G(){return(process.env.LC_ALL||process.env.LC_MESSAGES||process.env.LANG||"").toLowerCase().startsWith("zh")?"zh":"en"}o(G,"detectSystemLocale");function T(e){if(!e||e==="auto"){E=G();return}E=e.toLowerCase().replace(/[-_].*/,"")==="zh"?"zh":"en"}o(T,"setLocale");var M={en:{"dialog.confirm":"[Confirm]","dialog.select":"[Select]","dialog.input":"[Input]","confirm.instruction.basic":"Press (y) yes, (n) no","confirm.instruction.always":"Press (y) yes, (a) always yes for this tool, (n) no","confirm.instruction.protected":"Press (y) to confirm, (n) to cancel (protected path)","confirm.result.approved":"Approved","confirm.result.approved_always":"Approved (always)","confirm.result.denied":"Denied","tool.bash.title":"Execute bash command?","tool.shell.title":"Execute shell command?","tool.write.title":"Write to file?","tool.edit.title":"Edit file?","tool.generic.title":"Execute {tool}?","field.reason":"Reason","field.intent":"Intent","field.target":"Target","field.scope":"Scope","field.risk":"Risk","field.summary":"Summary","intent.read":"Read project files","intent.delete":"Delete files","intent.deps":"Modify dependencies or environment","intent.modify":"Modify files","intent.execute":"Execute command","intent.write_file":"Write file","intent.edit_file":"Edit file","intent.use_tool":"Use {tool}","risk.destructive":"Destructive change","risk.deps":"May change dependencies or local tools","risk.modify":"May modify files","risk.unknown":"Command effects depend on its arguments","risk.network":"May access network","scope.outside":"Outside project","scope.protected":"Protected path","waiting.confirm":"Waiting: approval required","waiting.select":"Waiting: choose an option","waiting.input":"Waiting: answer the prompt","placeholder.confirm":"Respond to the approval prompt above...","placeholder.select":"Choose an option above...","placeholder.input":"Answer the prompt above...","placeholder.busy":"Agent is busy...","placeholder.queue":"Queue a follow-up for the next round...","placeholder.idle":"Type a message...","select.choice":"Choice:","select.type_number":"(type a number)","select.more":"{count} more choices...","select.more_above":"\u2191 {count} more above","select.more_below":"\u2193 {count} more below","select.confirm_hint":"Press Enter to confirm, Esc to cancel","select.navigate_hint":"Use \u2191\u2193 to navigate, Enter to confirm, Esc to cancel","select.multiselect_hint":"Use \u2191\u2193 to navigate, Space to toggle, Enter to confirm, Esc to cancel","select.multiselect_empty":"Select at least one option with Space before confirming.","select.back_prev":"\u2190 Back to previous question","input.default":"Default:","input.value":"Value:","input.type_response":"(type your response)","managed.completed":"Task completed","managed.completed.blocked":"Task blocked","managed.completed.continuation":"Task needs continuation",cancelled:"[Cancelled] Operation cancelled by user"},zh:{"dialog.confirm":"[\u786E\u8BA4]","dialog.select":"[\u9009\u62E9]","dialog.input":"[\u8F93\u5165]","confirm.instruction.basic":"\u6309 (y) \u786E\u8BA4, (n) \u62D2\u7EDD","confirm.instruction.always":"\u6309 (y) \u786E\u8BA4, (a) \u59CB\u7EC8\u5141\u8BB8\u6B64\u5DE5\u5177, (n) \u62D2\u7EDD","confirm.instruction.protected":"\u6309 (y) \u786E\u8BA4, (n) \u53D6\u6D88 (\u53D7\u4FDD\u62A4\u8DEF\u5F84)","confirm.result.approved":"\u5DF2\u6279\u51C6","confirm.result.approved_always":"\u5DF2\u6279\u51C6 (\u59CB\u7EC8\u5141\u8BB8)","confirm.result.denied":"\u5DF2\u62D2\u7EDD","tool.bash.title":"\u6267\u884C bash \u547D\u4EE4\uFF1F","tool.shell.title":"\u6267\u884C shell \u547D\u4EE4\uFF1F","tool.write.title":"\u5199\u5165\u6587\u4EF6\uFF1F","tool.edit.title":"\u7F16\u8F91\u6587\u4EF6\uFF1F","tool.generic.title":"\u6267\u884C {tool}\uFF1F","field.reason":"\u539F\u56E0","field.intent":"\u610F\u56FE","field.target":"\u76EE\u6807","field.scope":"\u8303\u56F4","field.risk":"\u98CE\u9669","field.summary":"\u6458\u8981","intent.read":"\u8BFB\u53D6\u9879\u76EE\u6587\u4EF6","intent.delete":"\u5220\u9664\u6587\u4EF6","intent.deps":"\u4FEE\u6539\u4F9D\u8D56\u6216\u73AF\u5883","intent.modify":"\u4FEE\u6539\u6587\u4EF6","intent.execute":"\u6267\u884C\u547D\u4EE4","intent.write_file":"\u5199\u5165\u6587\u4EF6","intent.edit_file":"\u7F16\u8F91\u6587\u4EF6","intent.use_tool":"\u4F7F\u7528 {tool}","risk.destructive":"\u7834\u574F\u6027\u53D8\u66F4","risk.deps":"\u53EF\u80FD\u4FEE\u6539\u4F9D\u8D56\u6216\u672C\u5730\u5DE5\u5177","risk.modify":"\u53EF\u80FD\u4FEE\u6539\u6587\u4EF6","risk.unknown":"\u547D\u4EE4\u6548\u679C\u53D6\u51B3\u4E8E\u53C2\u6570","risk.network":"\u53EF\u80FD\u8BBF\u95EE\u7F51\u7EDC","scope.outside":"\u9879\u76EE\u5916\u90E8","scope.protected":"\u53D7\u4FDD\u62A4\u8DEF\u5F84","waiting.confirm":"\u7B49\u5F85\u4E2D\uFF1A\u9700\u8981\u5BA1\u6279","waiting.select":"\u7B49\u5F85\u4E2D\uFF1A\u8BF7\u9009\u62E9","waiting.input":"\u7B49\u5F85\u4E2D\uFF1A\u8BF7\u56DE\u7B54","placeholder.confirm":"\u8BF7\u56DE\u5E94\u4E0A\u65B9\u7684\u5BA1\u6279\u63D0\u793A...","placeholder.select":"\u8BF7\u5728\u4E0A\u65B9\u9009\u62E9\u4E00\u4E2A\u9009\u9879...","placeholder.input":"\u8BF7\u56DE\u7B54\u4E0A\u65B9\u7684\u63D0\u793A...","placeholder.busy":"\u667A\u80FD\u4F53\u6B63\u5728\u5DE5\u4F5C\u4E2D...","placeholder.queue":"\u6392\u961F\u7B49\u5F85\u4E0B\u4E00\u8F6E\u8DDF\u8FDB...","placeholder.idle":"\u8F93\u5165\u6D88\u606F...","select.choice":"\u9009\u9879\uFF1A","select.type_number":"(\u8F93\u5165\u7F16\u53F7)","select.more":"\u8FD8\u6709 {count} \u4E2A\u9009\u9879...","select.more_above":"\u2191 \u4E0A\u65B9\u8FD8\u6709 {count} \u4E2A","select.more_below":"\u2193 \u4E0B\u65B9\u8FD8\u6709 {count} \u4E2A","select.confirm_hint":"\u6309 Enter \u786E\u8BA4\uFF0CEsc \u53D6\u6D88","select.navigate_hint":"\u4F7F\u7528 \u2191\u2193 \u5BFC\u822A\uFF0CEnter \u786E\u8BA4\uFF0CEsc \u53D6\u6D88","select.multiselect_hint":"\u4F7F\u7528 \u2191\u2193 \u5BFC\u822A\uFF0C\u7A7A\u683C \u5207\u6362\u9009\u4E2D\uFF0CEnter \u786E\u8BA4\uFF0CEsc \u53D6\u6D88","select.multiselect_empty":"\u8BF7\u5148\u4F7F\u7528\u7A7A\u683C\u9009\u62E9\u81F3\u5C11\u4E00\u4E2A\u9009\u9879\u3002","select.back_prev":"\u2190 \u8FD4\u56DE\u4E0A\u4E00\u9898","input.default":"\u9ED8\u8BA4\u503C\uFF1A","input.value":"\u503C\uFF1A","input.type_response":"(\u8F93\u5165\u4F60\u7684\u56DE\u7B54)","managed.completed":"\u4EFB\u52A1\u5B8C\u6210","managed.completed.blocked":"\u4EFB\u52A1\u53D7\u963B","managed.completed.continuation":"\u4EFB\u52A1\u9700\u8981\u7EE7\u7EED",cancelled:"[\u5DF2\u53D6\u6D88] \u64CD\u4F5C\u5DF2\u88AB\u7528\u6237\u53D6\u6D88"}};function ve(e,t){let i=M[E][e]??M.en[e]??e;if(t)for(let[r,u]of Object.entries(t))i=i.replace(`{${r}}`,String(u));return i}o(ve,"t");var W=U(H),X=R(),Ie=c.join(X,"sessions"),l=c.join(X,"config.json"),Oe=60,a=null,_=!1,J="dumb";function Q(e){let t=c.basename(e).toLowerCase(),n="__KODAX_SHELL_ENV_START__",i=`printf '%s\\0' '${n}'; env -0`;return t==="fish"?{args:["-i","-c",i],sentinel:n}:{args:t==="bash"||t==="zsh"?["-ic",i]:["-lc",i],sentinel:n}}o(Q,"buildShellEnvCommand");function Y(e,t){let n=`${t}\0`,i=e.lastIndexOf(n);if(i===-1)return{};let r=e.slice(i+n.length),u={};for(let p of r.split("\0")){if(!p)continue;let d=p.indexOf("=");d<=0||(u[p.slice(0,d)]=p.slice(d+1))}return u}o(Y,"parseNullDelimitedShellEnv");function Z(e={}){let t=e.env??process.env;if((e.platform??process.platform)==="win32"||t.KODAX_DISABLE_SHELL_ENV_HYDRATION==="1")return!1;let i=e.shell??t.SHELL;if(!i||!c.isAbsolute(i))return!1;let{args:r,sentinel:u}=Q(i),p=e.run??z,d={...t,TERM:J},f=p(i,r,{encoding:"utf8",env:d,maxBuffer:1024*1024,timeout:5e3,windowsHide:!0,detached:!0,stdio:["ignore","pipe","pipe"]});if(f.status!==0||!f.stdout)return!1;let j=typeof f.stdout=="string"?f.stdout:f.stdout.toString("utf8"),B=Y(j,u),C=!1;for(let[y,V]of Object.entries(B))y!=="TERM"&&t[y]===void 0&&(t[y]=V,C=!0);return C}o(Z,"hydrateProcessEnvFromShell");function ee(){if(!_){_=!0;try{Z()}catch{}}}o(ee,"ensureShellEnvironmentHydrated");function xe(){_=!1}o(xe,"resetShellEnvironmentHydrationForTesting");function te(e){x(e.customProviders??[])}o(te,"registerConfiguredCustomProviders");function $(e){if(!Array.isArray(e))return;let t=e.filter(n=>typeof n=="string").map(n=>n.trim()).filter(n=>n.length>0);return t.length>0?t:[]}o($,"normalizeConfiguredExtensions");function ne(e){if(e.permissionMode!=="default")return e;let t={...e,permissionMode:"accept-edits"};try{s.mkdirSync(c.dirname(l),{recursive:!0}),s.writeFileSync(l,JSON.stringify(t,null,2))}catch{}return t}o(ne,"migrateLegacyPermissionModeInConfig");function ie(e){if(e.permissionMode!=="auto-in-project")return e;try{let t=s.readFileSync(l,"utf-8"),n=t.replace(/("permissionMode"\s*:\s*)"auto-in-project"/,'$1"auto"');n!==t&&s.writeFileSync(l,n)}catch{}return{...e,permissionMode:"auto"}}o(ie,"migrateAutoInProjectAliasInConfig");function oe(){if(a)return a;let e="0.7.51";if(e)return a=e,a;let t=c.join(c.dirname(q(import.meta.url)),"../../package.json");if(s.existsSync(t))try{return a=JSON.parse(s.readFileSync(t,"utf-8")).version??"0.0.0",a??"0.0.0"}catch{}return a="0.0.0",a}o(oe,"getVersion");var Ae=oe();function Re(e){return w(e)}o(Re,"getProviderModel");function P(e,t){let n=new Set(e.map(r=>r.toLowerCase())),i=[...e];for(let r of t)n.has(r.toLowerCase())||i.push(r);return i}o(P,"mergeModels");function re(e,t){t||(t=v().providerModels);let n=t?.[e];if(n&&n.length>0){try{let i=h(e);if(i.length>0)return P(n,i)}catch{}try{let i=m(e);if(i)return P(n,i.getAvailableModels())}catch{}return n}try{let i=h(e);if(i.length>0)return i}catch{}try{let i=m(e);if(i)return i.getAvailableModels()}catch{}return[]}o(re,"getProviderAvailableModels");function se(e,t){let n=L(e,t);if(n!=="unknown")return n;try{let i=m(e);if(i)return i.getReasoningCapability(t)}catch{}return"unknown"}o(se,"getProviderReasoningCapability");function ae(e){let t=I(e);if(t)return t;try{return b().find(i=>i.name===e)?.capabilityProfile??null}catch{return null}}o(ae,"getProviderCapabilityProfile");function F(e,t){let n=ae(e),i=se(e,t);if(n)return{capabilityProfile:n,reasoningCapability:i};try{let r=A(e);return{capabilityProfile:r.getCapabilityProfile(),reasoningCapability:r.getReasoningCapability(t)}}catch{return null}}o(F,"getProviderCapabilityMetadata");function ke(e,t){let n=F(e,t);return n?k({providerName:e,model:t,capabilityProfile:n.capabilityProfile,reasoningCapability:n.reasoningCapability==="unknown"?void 0:n.reasoningCapability}):null}o(ke,"getProviderCapabilitySnapshot");function ce(e,t,n,i){let r=F(e,t);return r?D({providerName:e,model:t,capabilityProfile:r.capabilityProfile,reasoningCapability:r.reasoningCapability==="unknown"?void 0:r.reasoningCapability,reasoningMode:n,hints:i}):null}o(ce,"getProviderPolicyDecision");function De(e){let t=e.transport==="cli-bridge"?"CLI bridge":"Native API",n=e.conversationSemantics==="last-user-message"?"forwards only the latest user message":"preserves full conversation history",i=e.mcpSupport==="native"?"MCP available":"MCP unavailable";return`${t}; ${n}; ${i}`}o(De,"describeProviderCapabilitySummary");function Me(e){switch(e){case"native-budget":return"B";case"native-effort":return"E";case"native-toggle":return"T";case"native-adaptive":return"A";default:return"-"}}o(Me,"formatReasoningCapabilityShort");function le(e){switch(e){case"native-budget":return"budget";case"native-effort":return"effort";case"native-toggle":return"toggle";case"native-adaptive":return"adaptive";default:return"none"}}o(le,"describeReasoningCapabilityControl");function Te(e,t){if(e==="off")return"Reasoning disabled";switch(t){case"native-budget":return"Uses native thinking budget control";case"native-effort":return"Uses native reasoning effort control";case"native-toggle":return"Uses provider-native thinking toggle only";case"native-adaptive":return"Model adaptively decides thinking depth (Opus 4.7+)";case"none":return"Runs without native reasoning parameters";case"prompt-only":return"Uses prompt overlays only; no native reasoning parameter";default:return"Runs without native reasoning parameters"}}o(Te,"describeReasoningExecution");function Ne(e){let t=[];e||(e=v().providerModels);for(let n of O())t.push({name:n.name,model:n.model,models:re(n.name,e),configured:n.capabilityProfile.transport==="cli-bridge"?!0:n.configured,reasoningCapability:n.reasoningCapability,capabilityProfile:n.capabilityProfile});try{let n=b().map(i=>({...i,models:(()=>{let r=e?.[i.name];return r&&r.length>0?P(r,i.models):i.models})()}));t.push(...n)}catch{}return t}o(Ne,"getProviderList");function Ke(e){if(S(e))return!0;try{return m(e)?.isConfigured()??!1}catch{return!1}}o(Ke,"isProviderConfigured");function v(){try{if(s.existsSync(l)){let e=JSON.parse(s.readFileSync(l,"utf-8")),t=e.reasoningCeiling??e.reasoningMode;return ie(ne({...e,reasoningMode:t,extensions:$(e.extensions)}))}}catch{}return{}}o(v,"loadConfig");function ue(e){e.streamIdleTimeoutMs&&!process.env.KODAX_STREAM_IDLE_TIMEOUT_MS&&(process.env.KODAX_STREAM_IDLE_TIMEOUT_MS=String(e.streamIdleTimeoutMs))}o(ue,"applyResilienceRuntimeEnv");function pe(e){e.repoIntelligenceMode&&!process.env.KODAX_REPO_INTELLIGENCE_MODE&&(process.env.KODAX_REPO_INTELLIGENCE_MODE=e.repoIntelligenceMode),e.repointelEndpoint&&!process.env.KODAX_REPOINTEL_ENDPOINT&&(process.env.KODAX_REPOINTEL_ENDPOINT=e.repointelEndpoint),e.repointelBin&&!process.env.KODAX_REPOINTEL_BIN&&(process.env.KODAX_REPOINTEL_BIN=e.repointelBin),e.repoIntelligenceTrace===!0&&!process.env.KODAX_REPO_INTELLIGENCE_TRACE&&(process.env.KODAX_REPO_INTELLIGENCE_TRACE="1")}o(pe,"applyRepoIntelligenceRuntimeEnv");function de(e){e.verifierLog===!0&&!process.env.KODAX_VERIFIER_LOG&&(process.env.KODAX_VERIFIER_LOG="1")}o(de,"applyVerifierRuntimeEnv");function fe(e){e.stallLog===!0&&!process.env.KODAX_STALL_LOG&&(process.env.KODAX_STALL_LOG="1")}o(fe,"applyStallSidecarRuntimeEnv");function me(e){let t=e.fallbackProviders?.filter(n=>n.trim().length>0)??[];t.length>0&&!process.env.KODAX_FALLBACK_PROVIDERS&&(process.env.KODAX_FALLBACK_PROVIDERS=t.join(","))}o(me,"applyFallbackRuntimeEnv");function Xe(){ee();let e=v();return ue(e),pe(e),de(e),fe(e),me(e),te(e),T(e.locale),e}o(Xe,"prepareRuntimeConfig");function $e(e){let n={...v(),...e},i=$(n.extensions);i!==void 0&&(n.extensions=i);for(let r of Object.keys(e))e[r]===void 0&&delete n[r];s.mkdirSync(c.dirname(l),{recursive:!0}),s.writeFileSync(l,JSON.stringify(n,null,2))}o($e,"saveConfig");async function Fe(e){try{let{stdout:t}=await W("git rev-parse --show-toplevel",{cwd:e});return t.trim()}catch{return null}}o(Fe,"getGitRoot");function ge(e){switch(e){case"builtin":return"Built-in";case"runtime":return"Runtime extension";case"custom":return"Custom config";default:return"Unknown"}}o(ge,"formatProviderSourceKind");function je(e){let t=e.transport==="cli-bridge"?"CLI bridge":"Native API",n=e.conversationSemantics==="last-user-message"?"latest-user-message only":"full conversation history";return[`Source: ${ge(e.sourceKind)}`,`Transport: ${t}`,`Conversation semantics: ${n}`,`Context fidelity: ${e.contextFidelity}`,`Tool calling: ${e.toolCallingFidelity}`,`Session behavior: ${e.sessionSupport}`,`Long-running support: ${e.longRunningSupport}`,`Evidence-heavy flows: ${e.evidenceSupport}`,`Multimodal support: ${e.multimodalSupport}`,`MCP support: ${e.mcpSupport}`,`Reasoning control: ${le(e.reasoningCapability)}`]}o(je,"formatProviderCapabilityDetailLines");function Be(e,t,n){return[{label:"General coding",hints:{}},{label:"Evidence-heavy review",hints:{evidenceHeavy:!0}},{label:"Long-running task",hints:{longRunning:!0}}].map(r=>({label:r.label,decision:ce(e,t,n,r.hints)})).filter(r=>r.decision!==null)}o(Be,"getProviderCommonPolicyScenarios");var N=.5,K=0,g={locked:!1,queue:[]};async function Ve(e){for(;g.locked;)await new Promise(t=>g.queue.push(t));g.locked=!0;try{let t=(Date.now()-K)/1e3;t<N&&await new Promise(i=>setTimeout(i,(N-t)*1e3));let n=await e();return K=Date.now(),n}finally{g.locked=!1;let t=g.queue.shift();t&&t()}}o(Ve,"rateLimitedCall");export{ve as a,X as b,Ie as c,l as d,Oe as e,Z as f,xe as g,te as h,oe as i,Ae as j,Re as k,re as l,se as m,ae as n,ke as o,ce as p,De as q,Me as r,le as s,Te as t,Ne as u,Ke as v,v as w,Xe as x,$e as y,Fe as z,ge as A,je as B,Be as C,Ve as D};
2
+ import{tb as k,vb as D}from"./chunk-5USNUSTL.js";import{U as S,V as w,W as L,X as I,Y as O,Z as h,ea as x,fa as m,ia as b,sa as A}from"./chunk-LE6STNVN.js";import{va as R}from"./chunk-HMATTIU6.js";import{a as o}from"./chunk-V4WSBIXB.js";import s from"fs";import c from"path";import{exec as H,spawnSync as z}from"child_process";import{promisify as U}from"util";import{fileURLToPath as q}from"url";var E="en";function G(){return(process.env.LC_ALL||process.env.LC_MESSAGES||process.env.LANG||"").toLowerCase().startsWith("zh")?"zh":"en"}o(G,"detectSystemLocale");function T(e){if(!e||e==="auto"){E=G();return}E=e.toLowerCase().replace(/[-_].*/,"")==="zh"?"zh":"en"}o(T,"setLocale");var M={en:{"dialog.confirm":"[Confirm]","dialog.select":"[Select]","dialog.input":"[Input]","confirm.instruction.basic":"Press (y) yes, (n) no","confirm.instruction.always":"Press (y) yes, (a) always yes for this tool, (n) no","confirm.instruction.protected":"Press (y) to confirm, (n) to cancel (protected path)","confirm.result.approved":"Approved","confirm.result.approved_always":"Approved (always)","confirm.result.denied":"Denied","tool.bash.title":"Execute bash command?","tool.shell.title":"Execute shell command?","tool.write.title":"Write to file?","tool.edit.title":"Edit file?","tool.generic.title":"Execute {tool}?","field.reason":"Reason","field.intent":"Intent","field.target":"Target","field.scope":"Scope","field.risk":"Risk","field.summary":"Summary","intent.read":"Read project files","intent.delete":"Delete files","intent.deps":"Modify dependencies or environment","intent.modify":"Modify files","intent.execute":"Execute command","intent.write_file":"Write file","intent.edit_file":"Edit file","intent.use_tool":"Use {tool}","risk.destructive":"Destructive change","risk.deps":"May change dependencies or local tools","risk.modify":"May modify files","risk.unknown":"Command effects depend on its arguments","risk.network":"May access network","scope.outside":"Outside project","scope.protected":"Protected path","waiting.confirm":"Waiting: approval required","waiting.select":"Waiting: choose an option","waiting.input":"Waiting: answer the prompt","placeholder.confirm":"Respond to the approval prompt above...","placeholder.select":"Choose an option above...","placeholder.input":"Answer the prompt above...","placeholder.busy":"Agent is busy...","placeholder.queue":"Queue a follow-up for the next round...","placeholder.idle":"Type a message...","select.choice":"Choice:","select.type_number":"(type a number)","select.more":"{count} more choices...","select.more_above":"\u2191 {count} more above","select.more_below":"\u2193 {count} more below","select.confirm_hint":"Press Enter to confirm, Esc to cancel","select.navigate_hint":"Use \u2191\u2193 to navigate, Enter to confirm, Esc to cancel","select.multiselect_hint":"Use \u2191\u2193 to navigate, Space to toggle, Enter to confirm, Esc to cancel","select.multiselect_empty":"Select at least one option with Space before confirming.","select.back_prev":"\u2190 Back to previous question","input.default":"Default:","input.value":"Value:","input.type_response":"(type your response)","managed.completed":"Task completed","managed.completed.blocked":"Task blocked","managed.completed.continuation":"Task needs continuation",cancelled:"[Cancelled] Operation cancelled by user"},zh:{"dialog.confirm":"[\u786E\u8BA4]","dialog.select":"[\u9009\u62E9]","dialog.input":"[\u8F93\u5165]","confirm.instruction.basic":"\u6309 (y) \u786E\u8BA4, (n) \u62D2\u7EDD","confirm.instruction.always":"\u6309 (y) \u786E\u8BA4, (a) \u59CB\u7EC8\u5141\u8BB8\u6B64\u5DE5\u5177, (n) \u62D2\u7EDD","confirm.instruction.protected":"\u6309 (y) \u786E\u8BA4, (n) \u53D6\u6D88 (\u53D7\u4FDD\u62A4\u8DEF\u5F84)","confirm.result.approved":"\u5DF2\u6279\u51C6","confirm.result.approved_always":"\u5DF2\u6279\u51C6 (\u59CB\u7EC8\u5141\u8BB8)","confirm.result.denied":"\u5DF2\u62D2\u7EDD","tool.bash.title":"\u6267\u884C bash \u547D\u4EE4\uFF1F","tool.shell.title":"\u6267\u884C shell \u547D\u4EE4\uFF1F","tool.write.title":"\u5199\u5165\u6587\u4EF6\uFF1F","tool.edit.title":"\u7F16\u8F91\u6587\u4EF6\uFF1F","tool.generic.title":"\u6267\u884C {tool}\uFF1F","field.reason":"\u539F\u56E0","field.intent":"\u610F\u56FE","field.target":"\u76EE\u6807","field.scope":"\u8303\u56F4","field.risk":"\u98CE\u9669","field.summary":"\u6458\u8981","intent.read":"\u8BFB\u53D6\u9879\u76EE\u6587\u4EF6","intent.delete":"\u5220\u9664\u6587\u4EF6","intent.deps":"\u4FEE\u6539\u4F9D\u8D56\u6216\u73AF\u5883","intent.modify":"\u4FEE\u6539\u6587\u4EF6","intent.execute":"\u6267\u884C\u547D\u4EE4","intent.write_file":"\u5199\u5165\u6587\u4EF6","intent.edit_file":"\u7F16\u8F91\u6587\u4EF6","intent.use_tool":"\u4F7F\u7528 {tool}","risk.destructive":"\u7834\u574F\u6027\u53D8\u66F4","risk.deps":"\u53EF\u80FD\u4FEE\u6539\u4F9D\u8D56\u6216\u672C\u5730\u5DE5\u5177","risk.modify":"\u53EF\u80FD\u4FEE\u6539\u6587\u4EF6","risk.unknown":"\u547D\u4EE4\u6548\u679C\u53D6\u51B3\u4E8E\u53C2\u6570","risk.network":"\u53EF\u80FD\u8BBF\u95EE\u7F51\u7EDC","scope.outside":"\u9879\u76EE\u5916\u90E8","scope.protected":"\u53D7\u4FDD\u62A4\u8DEF\u5F84","waiting.confirm":"\u7B49\u5F85\u4E2D\uFF1A\u9700\u8981\u5BA1\u6279","waiting.select":"\u7B49\u5F85\u4E2D\uFF1A\u8BF7\u9009\u62E9","waiting.input":"\u7B49\u5F85\u4E2D\uFF1A\u8BF7\u56DE\u7B54","placeholder.confirm":"\u8BF7\u56DE\u5E94\u4E0A\u65B9\u7684\u5BA1\u6279\u63D0\u793A...","placeholder.select":"\u8BF7\u5728\u4E0A\u65B9\u9009\u62E9\u4E00\u4E2A\u9009\u9879...","placeholder.input":"\u8BF7\u56DE\u7B54\u4E0A\u65B9\u7684\u63D0\u793A...","placeholder.busy":"\u667A\u80FD\u4F53\u6B63\u5728\u5DE5\u4F5C\u4E2D...","placeholder.queue":"\u6392\u961F\u7B49\u5F85\u4E0B\u4E00\u8F6E\u8DDF\u8FDB...","placeholder.idle":"\u8F93\u5165\u6D88\u606F...","select.choice":"\u9009\u9879\uFF1A","select.type_number":"(\u8F93\u5165\u7F16\u53F7)","select.more":"\u8FD8\u6709 {count} \u4E2A\u9009\u9879...","select.more_above":"\u2191 \u4E0A\u65B9\u8FD8\u6709 {count} \u4E2A","select.more_below":"\u2193 \u4E0B\u65B9\u8FD8\u6709 {count} \u4E2A","select.confirm_hint":"\u6309 Enter \u786E\u8BA4\uFF0CEsc \u53D6\u6D88","select.navigate_hint":"\u4F7F\u7528 \u2191\u2193 \u5BFC\u822A\uFF0CEnter \u786E\u8BA4\uFF0CEsc \u53D6\u6D88","select.multiselect_hint":"\u4F7F\u7528 \u2191\u2193 \u5BFC\u822A\uFF0C\u7A7A\u683C \u5207\u6362\u9009\u4E2D\uFF0CEnter \u786E\u8BA4\uFF0CEsc \u53D6\u6D88","select.multiselect_empty":"\u8BF7\u5148\u4F7F\u7528\u7A7A\u683C\u9009\u62E9\u81F3\u5C11\u4E00\u4E2A\u9009\u9879\u3002","select.back_prev":"\u2190 \u8FD4\u56DE\u4E0A\u4E00\u9898","input.default":"\u9ED8\u8BA4\u503C\uFF1A","input.value":"\u503C\uFF1A","input.type_response":"(\u8F93\u5165\u4F60\u7684\u56DE\u7B54)","managed.completed":"\u4EFB\u52A1\u5B8C\u6210","managed.completed.blocked":"\u4EFB\u52A1\u53D7\u963B","managed.completed.continuation":"\u4EFB\u52A1\u9700\u8981\u7EE7\u7EED",cancelled:"[\u5DF2\u53D6\u6D88] \u64CD\u4F5C\u5DF2\u88AB\u7528\u6237\u53D6\u6D88"}};function ve(e,t){let i=M[E][e]??M.en[e]??e;if(t)for(let[r,u]of Object.entries(t))i=i.replace(`{${r}}`,String(u));return i}o(ve,"t");var W=U(H),X=R(),Ie=c.join(X,"sessions"),l=c.join(X,"config.json"),Oe=60,a=null,_=!1,J="dumb";function Q(e){let t=c.basename(e).toLowerCase(),n="__KODAX_SHELL_ENV_START__",i=`printf '%s\\0' '${n}'; env -0`;return t==="fish"?{args:["-i","-c",i],sentinel:n}:{args:t==="bash"||t==="zsh"?["-ic",i]:["-lc",i],sentinel:n}}o(Q,"buildShellEnvCommand");function Y(e,t){let n=`${t}\0`,i=e.lastIndexOf(n);if(i===-1)return{};let r=e.slice(i+n.length),u={};for(let p of r.split("\0")){if(!p)continue;let d=p.indexOf("=");d<=0||(u[p.slice(0,d)]=p.slice(d+1))}return u}o(Y,"parseNullDelimitedShellEnv");function Z(e={}){let t=e.env??process.env;if((e.platform??process.platform)==="win32"||t.KODAX_DISABLE_SHELL_ENV_HYDRATION==="1")return!1;let i=e.shell??t.SHELL;if(!i||!c.isAbsolute(i))return!1;let{args:r,sentinel:u}=Q(i),p=e.run??z,d={...t,TERM:J},f=p(i,r,{encoding:"utf8",env:d,maxBuffer:1024*1024,timeout:5e3,windowsHide:!0,detached:!0,stdio:["ignore","pipe","pipe"]});if(f.status!==0||!f.stdout)return!1;let j=typeof f.stdout=="string"?f.stdout:f.stdout.toString("utf8"),B=Y(j,u),C=!1;for(let[y,V]of Object.entries(B))y!=="TERM"&&t[y]===void 0&&(t[y]=V,C=!0);return C}o(Z,"hydrateProcessEnvFromShell");function ee(){if(!_){_=!0;try{Z()}catch{}}}o(ee,"ensureShellEnvironmentHydrated");function xe(){_=!1}o(xe,"resetShellEnvironmentHydrationForTesting");function te(e){x(e.customProviders??[])}o(te,"registerConfiguredCustomProviders");function $(e){if(!Array.isArray(e))return;let t=e.filter(n=>typeof n=="string").map(n=>n.trim()).filter(n=>n.length>0);return t.length>0?t:[]}o($,"normalizeConfiguredExtensions");function ne(e){if(e.permissionMode!=="default")return e;let t={...e,permissionMode:"accept-edits"};try{s.mkdirSync(c.dirname(l),{recursive:!0}),s.writeFileSync(l,JSON.stringify(t,null,2))}catch{}return t}o(ne,"migrateLegacyPermissionModeInConfig");function ie(e){if(e.permissionMode!=="auto-in-project")return e;try{let t=s.readFileSync(l,"utf-8"),n=t.replace(/("permissionMode"\s*:\s*)"auto-in-project"/,'$1"auto"');n!==t&&s.writeFileSync(l,n)}catch{}return{...e,permissionMode:"auto"}}o(ie,"migrateAutoInProjectAliasInConfig");function oe(){if(a)return a;let e="0.7.52";if(e)return a=e,a;let t=c.join(c.dirname(q(import.meta.url)),"../../package.json");if(s.existsSync(t))try{return a=JSON.parse(s.readFileSync(t,"utf-8")).version??"0.0.0",a??"0.0.0"}catch{}return a="0.0.0",a}o(oe,"getVersion");var Ae=oe();function Re(e){return w(e)}o(Re,"getProviderModel");function P(e,t){let n=new Set(e.map(r=>r.toLowerCase())),i=[...e];for(let r of t)n.has(r.toLowerCase())||i.push(r);return i}o(P,"mergeModels");function re(e,t){t||(t=v().providerModels);let n=t?.[e];if(n&&n.length>0){try{let i=h(e);if(i.length>0)return P(n,i)}catch{}try{let i=m(e);if(i)return P(n,i.getAvailableModels())}catch{}return n}try{let i=h(e);if(i.length>0)return i}catch{}try{let i=m(e);if(i)return i.getAvailableModels()}catch{}return[]}o(re,"getProviderAvailableModels");function se(e,t){let n=L(e,t);if(n!=="unknown")return n;try{let i=m(e);if(i)return i.getReasoningCapability(t)}catch{}return"unknown"}o(se,"getProviderReasoningCapability");function ae(e){let t=I(e);if(t)return t;try{return b().find(i=>i.name===e)?.capabilityProfile??null}catch{return null}}o(ae,"getProviderCapabilityProfile");function F(e,t){let n=ae(e),i=se(e,t);if(n)return{capabilityProfile:n,reasoningCapability:i};try{let r=A(e);return{capabilityProfile:r.getCapabilityProfile(),reasoningCapability:r.getReasoningCapability(t)}}catch{return null}}o(F,"getProviderCapabilityMetadata");function ke(e,t){let n=F(e,t);return n?k({providerName:e,model:t,capabilityProfile:n.capabilityProfile,reasoningCapability:n.reasoningCapability==="unknown"?void 0:n.reasoningCapability}):null}o(ke,"getProviderCapabilitySnapshot");function ce(e,t,n,i){let r=F(e,t);return r?D({providerName:e,model:t,capabilityProfile:r.capabilityProfile,reasoningCapability:r.reasoningCapability==="unknown"?void 0:r.reasoningCapability,reasoningMode:n,hints:i}):null}o(ce,"getProviderPolicyDecision");function De(e){let t=e.transport==="cli-bridge"?"CLI bridge":"Native API",n=e.conversationSemantics==="last-user-message"?"forwards only the latest user message":"preserves full conversation history",i=e.mcpSupport==="native"?"MCP available":"MCP unavailable";return`${t}; ${n}; ${i}`}o(De,"describeProviderCapabilitySummary");function Me(e){switch(e){case"native-budget":return"B";case"native-effort":return"E";case"native-toggle":return"T";case"native-adaptive":return"A";default:return"-"}}o(Me,"formatReasoningCapabilityShort");function le(e){switch(e){case"native-budget":return"budget";case"native-effort":return"effort";case"native-toggle":return"toggle";case"native-adaptive":return"adaptive";default:return"none"}}o(le,"describeReasoningCapabilityControl");function Te(e,t){if(e==="off")return"Reasoning disabled";switch(t){case"native-budget":return"Uses native thinking budget control";case"native-effort":return"Uses native reasoning effort control";case"native-toggle":return"Uses provider-native thinking toggle only";case"native-adaptive":return"Model adaptively decides thinking depth (Opus 4.7+)";case"none":return"Runs without native reasoning parameters";case"prompt-only":return"Uses prompt overlays only; no native reasoning parameter";default:return"Runs without native reasoning parameters"}}o(Te,"describeReasoningExecution");function Ne(e){let t=[];e||(e=v().providerModels);for(let n of O())t.push({name:n.name,model:n.model,models:re(n.name,e),configured:n.capabilityProfile.transport==="cli-bridge"?!0:n.configured,reasoningCapability:n.reasoningCapability,capabilityProfile:n.capabilityProfile});try{let n=b().map(i=>({...i,models:(()=>{let r=e?.[i.name];return r&&r.length>0?P(r,i.models):i.models})()}));t.push(...n)}catch{}return t}o(Ne,"getProviderList");function Ke(e){if(S(e))return!0;try{return m(e)?.isConfigured()??!1}catch{return!1}}o(Ke,"isProviderConfigured");function v(){try{if(s.existsSync(l)){let e=JSON.parse(s.readFileSync(l,"utf-8")),t=e.reasoningCeiling??e.reasoningMode;return ie(ne({...e,reasoningMode:t,extensions:$(e.extensions)}))}}catch{}return{}}o(v,"loadConfig");function ue(e){e.streamIdleTimeoutMs&&!process.env.KODAX_STREAM_IDLE_TIMEOUT_MS&&(process.env.KODAX_STREAM_IDLE_TIMEOUT_MS=String(e.streamIdleTimeoutMs))}o(ue,"applyResilienceRuntimeEnv");function pe(e){e.repoIntelligenceMode&&!process.env.KODAX_REPO_INTELLIGENCE_MODE&&(process.env.KODAX_REPO_INTELLIGENCE_MODE=e.repoIntelligenceMode),e.repointelEndpoint&&!process.env.KODAX_REPOINTEL_ENDPOINT&&(process.env.KODAX_REPOINTEL_ENDPOINT=e.repointelEndpoint),e.repointelBin&&!process.env.KODAX_REPOINTEL_BIN&&(process.env.KODAX_REPOINTEL_BIN=e.repointelBin),e.repoIntelligenceTrace===!0&&!process.env.KODAX_REPO_INTELLIGENCE_TRACE&&(process.env.KODAX_REPO_INTELLIGENCE_TRACE="1")}o(pe,"applyRepoIntelligenceRuntimeEnv");function de(e){e.verifierLog===!0&&!process.env.KODAX_VERIFIER_LOG&&(process.env.KODAX_VERIFIER_LOG="1")}o(de,"applyVerifierRuntimeEnv");function fe(e){e.stallLog===!0&&!process.env.KODAX_STALL_LOG&&(process.env.KODAX_STALL_LOG="1")}o(fe,"applyStallSidecarRuntimeEnv");function me(e){let t=e.fallbackProviders?.filter(n=>n.trim().length>0)??[];t.length>0&&!process.env.KODAX_FALLBACK_PROVIDERS&&(process.env.KODAX_FALLBACK_PROVIDERS=t.join(","))}o(me,"applyFallbackRuntimeEnv");function Xe(){ee();let e=v();return ue(e),pe(e),de(e),fe(e),me(e),te(e),T(e.locale),e}o(Xe,"prepareRuntimeConfig");function $e(e){let n={...v(),...e},i=$(n.extensions);i!==void 0&&(n.extensions=i);for(let r of Object.keys(e))e[r]===void 0&&delete n[r];s.mkdirSync(c.dirname(l),{recursive:!0}),s.writeFileSync(l,JSON.stringify(n,null,2))}o($e,"saveConfig");async function Fe(e){try{let{stdout:t}=await W("git rev-parse --show-toplevel",{cwd:e});return t.trim()}catch{return null}}o(Fe,"getGitRoot");function ge(e){switch(e){case"builtin":return"Built-in";case"runtime":return"Runtime extension";case"custom":return"Custom config";default:return"Unknown"}}o(ge,"formatProviderSourceKind");function je(e){let t=e.transport==="cli-bridge"?"CLI bridge":"Native API",n=e.conversationSemantics==="last-user-message"?"latest-user-message only":"full conversation history";return[`Source: ${ge(e.sourceKind)}`,`Transport: ${t}`,`Conversation semantics: ${n}`,`Context fidelity: ${e.contextFidelity}`,`Tool calling: ${e.toolCallingFidelity}`,`Session behavior: ${e.sessionSupport}`,`Long-running support: ${e.longRunningSupport}`,`Evidence-heavy flows: ${e.evidenceSupport}`,`Multimodal support: ${e.multimodalSupport}`,`MCP support: ${e.mcpSupport}`,`Reasoning control: ${le(e.reasoningCapability)}`]}o(je,"formatProviderCapabilityDetailLines");function Be(e,t,n){return[{label:"General coding",hints:{}},{label:"Evidence-heavy review",hints:{evidenceHeavy:!0}},{label:"Long-running task",hints:{longRunning:!0}}].map(r=>({label:r.label,decision:ce(e,t,n,r.hints)})).filter(r=>r.decision!==null)}o(Be,"getProviderCommonPolicyScenarios");var N=.5,K=0,g={locked:!1,queue:[]};async function Ve(e){for(;g.locked;)await new Promise(t=>g.queue.push(t));g.locked=!0;try{let t=(Date.now()-K)/1e3;t<N&&await new Promise(i=>setTimeout(i,(N-t)*1e3));let n=await e();return K=Date.now(),n}finally{g.locked=!1;let t=g.queue.shift();t&&t()}}o(Ve,"rateLimitedCall");export{ve as a,X as b,Ie as c,l as d,Oe as e,Z as f,xe as g,te as h,oe as i,Ae as j,Re as k,re as l,se as m,ae as n,ke as o,ce as p,De as q,Me as r,le as s,Te as t,Ne as u,Ke as v,v as w,Xe as x,$e as y,Fe as z,ge as A,je as B,Be as C,Ve as D};