@kodax-ai/kodax 0.7.55 → 0.7.56

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 (52) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +1 -1
  3. package/README_CN.md +1 -1
  4. package/dist/chunks/agent-MAAKRAF2.js +2 -0
  5. package/dist/chunks/argument-completer-OWEXGWNL.js +2 -0
  6. package/dist/chunks/{chunk-RGPPZOD5.js → chunk-4OHXHC2S.js} +4 -4
  7. package/dist/chunks/{chunk-HQCLPWRI.js → chunk-5YJIAP6C.js} +2 -2
  8. package/dist/chunks/{chunk-FRI7UQSB.js → chunk-7EAGBLRV.js} +1 -1
  9. package/dist/chunks/{chunk-7C2QUBLE.js → chunk-CDGOEK3T.js} +6 -6
  10. package/dist/chunks/{chunk-MX4G42EV.js → chunk-DHETLULC.js} +3 -3
  11. package/dist/chunks/{chunk-THAKTCPE.js → chunk-NZVJ3DFC.js} +174 -170
  12. package/dist/chunks/chunk-QI3MRJGU.js +5 -0
  13. package/dist/chunks/chunk-XXQ3RLA2.js +2 -0
  14. package/dist/chunks/{construction-bootstrap-4CIVZMQ5.js → construction-bootstrap-EDDVNP2B.js} +1 -1
  15. package/dist/chunks/dist-2267YGB5.js +2 -0
  16. package/dist/chunks/dist-GW32CHO5.js +2 -0
  17. package/dist/chunks/paste-5IDBBQQ3.js +2 -0
  18. package/dist/chunks/utils-J7XBBZGB.js +2 -0
  19. package/dist/index.d.ts +12 -11
  20. package/dist/index.js +2 -2
  21. package/dist/kodax_cli.js +874 -870
  22. package/dist/provider-capabilities.json +2 -0
  23. package/dist/sdk-agent.d.ts +9 -8
  24. package/dist/sdk-coding.d.ts +99 -14
  25. package/dist/sdk-coding.js +1 -1
  26. package/dist/sdk-llm.d.ts +10 -5
  27. package/dist/sdk-llm.js +1 -1
  28. package/dist/sdk-media.d.ts +99 -0
  29. package/dist/sdk-media.js +2 -0
  30. package/dist/sdk-repl.d.ts +11 -10
  31. package/dist/sdk-repl.js +1 -1
  32. package/dist/sdk-session.d.ts +6 -5
  33. package/dist/sdk-session.js +1 -1
  34. package/dist/types-chunks/base.d-CwPfI8WQ.d.ts +271 -0
  35. package/dist/types-chunks/{bash-prefix-extractor.d-LUGkQHcd.d.ts → bash-prefix-extractor.d-DZF1gDDz.d.ts} +14 -10
  36. package/dist/types-chunks/{capsule.d-CNonpwAZ.d.ts → capsule.d-D0kjnqYy.d.ts} +3 -3
  37. package/dist/types-chunks/{guardrail.d-B18oO1gt.d.ts → guardrail.d-DQQknOfb.d.ts} +3 -3
  38. package/dist/types-chunks/{process.d-Bj82oJhD.d.ts → process.d-BdiIUr8T.d.ts} +1 -1
  39. package/dist/types-chunks/{resolver.d-CCX9NXWP.d.ts → resolver.d-Djq8KlCE.d.ts} +2 -1
  40. package/dist/types-chunks/{sdk-session-SjrnWb4-.d.ts → sdk-session-BP6ZNpOp.d.ts} +4 -4
  41. package/dist/types-chunks/{storage.d-BAuJ0Ks7.d.ts → storage.d-CkydxFsV.d.ts} +2 -2
  42. package/dist/types-chunks/{base.d-BBNUF9nz.d.ts → types.d-BJmoMf5H.d.ts} +1 -269
  43. package/dist/types-chunks/{types.d-D4jL-gAA.d.ts → types.d-BKuHSiR0.d.ts} +1 -1
  44. package/dist/types-chunks/{utils.d-C9MUY8n3.d.ts → utils.d-bC97IuQZ.d.ts} +5 -5
  45. package/package.json +5 -1
  46. package/dist/chunks/agent-PYSVWY7M.js +0 -2
  47. package/dist/chunks/argument-completer-CTDNNWV3.js +0 -2
  48. package/dist/chunks/chunk-EVIDQWMF.js +0 -5
  49. package/dist/chunks/dist-7KTO2PUU.js +0 -2
  50. package/dist/chunks/dist-BNKIZRCP.js +0 -2
  51. package/dist/chunks/paste-5DSTHQGK.js +0 -2
  52. package/dist/chunks/utils-2QXBKYPJ.js +0 -2
@@ -1,5 +1,5 @@
1
1
  // @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
2
- import{A as _r,B as Pr,C as Mr,j as Rr,l as We,m as Rn,n as Cr,o as Tr,p as Ir,q as Cn,s as Tn,t as In,u as Er,w as Eo,y as ye}from"./chunk-FRI7UQSB.js";import{a as Lr}from"./chunk-ZBK3DZ3S.js";import{Ja as yr,Ma as he,Qa as Me,Sa as Je,Ta as To,Ua as kr,Va as vr,Xa as $r,Ya as An,Za as Sr,_a as Ze,ab as Le,cb as br,lb as Io,mb as xr,sb as Ar,tb as Qe}from"./chunk-MX4G42EV.js";import{$d as hr,Fd as mr,Hd as pr,Id as gr,Ld as xn,Zd as wr,_ as lr,ba as Ye,ca as cr,eb as dr,hd as oe,ld as ur,md as fr,w as ar}from"./chunk-THAKTCPE.js";import{j as $n,sa as Vt,ta as Te,ua as Ie}from"./chunk-7C2QUBLE.js";import{Ib as Ao,Id as ir,Kb as Ro,Lb as Qt,Ld as bn,Mc as Ee,Nb as er,Nc as _e,Sc as rr,Ud as Co,k as Sn,sb as Yt,sd as Pe,tb as Jt,td as sr,va as xo,wa as F,xb as Zt,xc as or,yc as nr,zc as tr}from"./chunk-JCDO2FR4.js";import{a,b as vn,c as Oi}from"./chunk-V4WSBIXB.js";var Hr=vn((tu,jr)=>{"use strict";jr.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 Vr=vn((su,Xr)=>{"use strict";var Kr="(?:"+["\\|\\|","\\&\\&",";;","\\|\\&","\\<\\(","\\<\\<\\<",">>",">\\&","<\\&","[&;()|<>]"].join("|")+")",Br=new RegExp("^"+Kr+"$"),Gr="|&;()<> \\t",Ui='"((\\\\"|[^"])*?)"',Fi="'((\\\\'|[^'])*?)'",ji=/^#$/,zr="'",qr='"',En="$",ke="",Hi=4294967296;for(_n=0;_n<4;_n++)ke+=(Hi*Math.random()).toString(16);var _n,Bi=new RegExp("^"+ke);function Gi(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(Gi,"matchAll");function zi(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+ke+JSON.stringify(t)+ke:o+t}a(zi,"getVar");function qi(e,o,n){n||(n={});var t=n.escape||"\\",r="(\\"+t+`['"`+Gr+`]|[^\\s'"`+Gr+"])+",i=new RegExp(["("+Kr+")","("+r+"|"+Ui+"|"+Fi+")+"].join("|"),"g"),l=Gi(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(Br.test(u))return{op:u};var g=!1,f=!1,k="",v=!1,h;function y(){h+=1;var C,G,z=u.charAt(h);if(z==="{"){if(h+=1,u.charAt(h)==="}")throw new Error("Bad substitution: "+u.slice(h-2,h+1));if(C=u.indexOf("}",h),C<0)throw new Error("Bad substitution: "+u.slice(h));G=u.slice(h,C),h=C}else if(/[*@#?$!_-]/.test(z))G=z,h+=1;else{var Y=u.slice(h);C=Y.match(/[^\w\d_]/),C?(G=Y.slice(0,C.index),h+=C.index-1):(G=Y,h=u.length)}return zi(o,"",G)}for(a(y,"parseEnvVar"),h=0;h<u.length;h++){var m=u.charAt(h);if(v=v||!g&&(m==="*"||m==="?"),f)k+=m,f=!1;else if(g)m===g?g=!1:g==zr?k+=m:m===t?(h+=1,m=u.charAt(h),m===qr||m===t||m===En?k+=m:k+=t+m):m===En?k+=y():k+=m;else if(m===qr||m===zr)g=m;else{if(Br.test(m))return{op:u};if(ji.test(m)){c=!0;var R={comment:e.slice(d.index+h+1)};return k.length?[k,R]:[R]}else m===t?f=!0:m===En?k+=y():k+=m}}return v?{op:"glob",pattern:k}:k}).reduce(function(d,u){return typeof u>"u"?d:d.concat(u)},[])}a(qi,"parseInternal");Xr.exports=a(function(o,n,t){var r=qi(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("("+ke+".*?"+ke+")","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(ke)[1]):d}))},[])},"parse")});var Yr=vn(Pn=>{"use strict";Pn.quote=Hr();Pn.parse=Vr()});import*as mn from"fs";import*as vo from"path";import s from"chalk";var _o=["plan","accept-edits","auto","auto-in-project"];function Qd(e){return e==="auto"||e==="auto-in-project"}a(Qd,"isAutoMode");function Ni(e){switch(e){case"plan":return"Plan";case"accept-edits":return"Edits";case"auto":case"auto-in-project":return"Auto"}}a(Ni,"permissionModeDisplayName");var Di='[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 eu(e=console.warn){let o=!1;return()=>{o||(o=!0,e(Di))}}a(eu,"createAutoInProjectDeprecationEmitter");var Wr=wr(),eo=new Set(Wr.filter(e=>e.sideEffect==="mutates-fs"&&e.requiredParams.includes("path")).map(e=>e.name)),Or=new Set(Wr.filter(e=>e.sideEffect!=="readonly").map(e=>e.name)),Nr=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"]),Dr=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 Ur(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(Ur,"computeConfirmTools");function Fr(e){return e!==void 0&&_o.includes(e)}a(Fr,"isPermissionMode");function oo(e,o){return Fr(e)?e:o}a(oo,"normalizePermissionMode");import No from"fs";import ds from"path";import Po from"fs";import L from"path";import to from"os";var Qr=Oi(Yr(),1);var Jr=new Set(["/dev/null","nul","NUL"]);function Mn(e){return Jr.has(e)||Jr.has(e.toLowerCase())}a(Mn,"isNullDevice");function no(e){let o=e.trim();if(!o)return{statements:[],unparseable:!1};if(o.includes("`"))return{statements:[],unparseable:!0};let n;try{n=(0,Qr.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"),g=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===";"){g(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(Zr(`&${h.op}`,y)),f+=2;continue}d=!0;continue}if(Xi(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(Zr(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 g(null),{statements:t,unparseable:d}}a(no,"parseBashCommand");var Ki=new Set([">",">>","<","<<","<<<","&>","&>>"]),es=/^([0-9]+|&)(>>?|<<?)$/;function Xi(e){return Ki.has(e)||es.test(e)}a(Xi,"isRedirectionOp");function Zr(e,o){let n=null,t=e,r=es.exec(e);return r&&(n=r[1],t=r[2]),{op:e,fd:n,append:t===">>"||e==="&>>",input:t==="<"||t==="<<"||e==="<<<",target:o}}a(Zr,"parseRedirection");var Vi=L.join(".agent","plan_mode_doc.md"),Mo=new Map,Lo=null;function Yi(e){if(!e||!e.trim())return!1;let o=e.trim().replace(/\s+/g," ").toLowerCase();for(let n of Dr)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(Yi,"isSingleBashReadCommand");var Ji=/^[a-zA-Z0-9]+$/;function Zi(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(!Ji.test(t))return!1;return n}a(Zi,"isHelpCommand");function Wn(e){if(!e||!e.trim())return!1;if(Zi(e))return!0;let o=e.trim().replace(/\\\r?\n/g," "),n=no(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||!Mn(c.target))return!1;let l=i.argv.join(" ");if(l&&!(t&&i.argv[0]?.toLowerCase()==="cd"&&i.argv.length>=2)&&!Yi(l))return!1}}return!0}a(Wn,"isBashReadCommand");function Qi(e){let o=e.trim();return o?Wn(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(Qi,"getDirectShellBypassBlockReason");var ns=new Set(["remove-item","set-content","add-content","out-file","new-item","copy-item","move-item","rename-item","ni"]);function On(e){if(!e||!e.trim())return!1;let o=no(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 Nr)if(c===i||l!==null&&c===l)return!0}for(let i of r)if(ns.has(i))return!0;for(let i of t.redirections)if(!i.input&&!Mn(i.target))return!0}return!1}a(On,"isBashWriteCommand");function Nn(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(Nn,"parseAllowedToolPattern");function ea(e,o){if(o==="*")return!1;if(o.endsWith(":*")){let n=o.slice(0,-2);return e.startsWith(n)}return e===o}a(ea,"matchesBashPatternLegacy");function oa(e,o){if(o==="*")return!1;if(o.endsWith(":*")){let n=o.slice(0,-2);return e===n}return e===o}a(oa,"matchesBashPatternByExtractedPrefix");async function Dn(e,o,n,t,r){if(e.toLowerCase()!=="bash")return!1;let i=o.command??"",l=[];for(let c of n){let d=Nn(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&&oa(c.value,d))return!0;return!1}for(let{pattern:c}of l)if(c&&ea(i,c))return!0;return!1}a(Dn,"isToolCallAllowed");function Un(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(Un,"generateSavePattern");function ro(e,o){try{let n=L.resolve(e),t=L.resolve(o),r=xo(),i=L.join(t,".kodax");return Oe(n,i)||Oe(n,r)?!0:!(Oe(n,t)||ss().some(c=>Oe(n,c)))}catch{return!1}}a(ro,"isAlwaysConfirmPath");function os(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"&&na.test(e)):!!(e.startsWith(".")&&/[/\\]/.test(e))}a(os,"looksLikePath");var na=/^\/[A-Za-z][A-Za-z0-9]*(?::[A-Za-z0-9]+)?$/;function ta(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(ta,"legacyRegexPathScan");function Oo(e){let o=new Set,n=no(e);if(!n.unparseable)for(let t of n.statements)for(let r of t.stages){for(let i of r.argv)os(i)&&o.add(i);for(let i of r.redirections)os(i.target)&&o.add(i.target)}for(let t of ta(e))o.add(t);return Array.from(o)}a(Oo,"extractPathsFromCommand");function ra(e,o){let n=Oo(e);for(let t of n)if(ro(t,o))return!0;return!1}a(ra,"isCommandOnProtectedPath");function Wo(e){let o=L.normalize(e);return process.platform==="win32"?o.toLowerCase():o}a(Wo,"normalizePathForComparison");function sa(e,o){return Wo(e)===Wo(o)}a(sa,"pathsEqual");function Oe(e,o){let n=Wo(e),t=Wo(o);return n===t||n.startsWith(t+L.sep)}a(Oe,"isPathInsideDirectory");function Fn(e,o){try{let n=L.resolve(o),t=L.resolve(n,rs(ts(e)));return Oe(t,n)}catch{return!1}}a(Fn,"isPathInsideProject");function ia(e){let o=e.match(/[A-Za-z]:[\\/][^\s;|&<>(){}'"]+|\/[^\s;|&<>(){}'"]+/g);return o?o.filter(n=>!/^(?:\/dev\/|\/proc\/)/i.test(n)):[]}a(ia,"collectAbsolutePathCandidates");function jn(e){let o=L.resolve(e),n=Mo.get(o);if(n)return n;if(Po.existsSync(o)){let c=Po.realpathSync.native(o);return Mo.set(o,c),c}let t=[],r=o;for(;!Po.existsSync(r);){let c=L.dirname(r);if(c===r)return Mo.set(o,o),o;t.unshift(L.basename(r)),r=c}let i=Po.realpathSync.native(r),l=L.join(i,...t);return Mo.set(o,l),l}a(jn,"resolveExistingPathPrefix");function ts(e){return e==="~"?to.homedir():e.startsWith(`~${L.sep}`)||e.startsWith("~/")||e.startsWith("~\\")?L.join(to.homedir(),e.slice(2)):e}a(ts,"expandHomeDirectory");function rs(e){let o=to.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(rs,"expandSystemTempAlias");function aa(e,o){let n=L.resolve(o??process.cwd()),t=rs(ts(e)),r=L.isAbsolute(t)?L.resolve(t):L.resolve(n,t);return jn(r)}a(aa,"resolvePermissionPath");function ss(){if(Lo)return Lo;let e=new Set,o=[to.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(jn(n))}catch{}return Lo=Array.from(e),Lo}a(ss,"getSystemTempDirectories");function Hn(e){let o=jn(e??process.cwd());return{projectPlanDoc:L.join(o,Vi),systemTempDirs:ss()}}a(Hn,"getPlanModeAllowedWritablePaths");function Ln(e,o){let n=aa(e,o),{projectPlanDoc:t,systemTempDirs:r}=Hn(o);return sa(n,t)?!0:r.some(i=>Oe(n,i))}a(Ln,"isPlanModeAllowedPath");function la(e){let{projectPlanDoc:o,systemTempDirs:n}=Hn(e),t=n[0]??to.tmpdir();return`${o} or the system temp directory (${t})`}a(la,"formatPlanModeAllowedLocations");var ca=new Set(["-a","--append","-i","--ignore-interrupts"]);function da(e){let o=[];for(let n=1;n<e.argv.length;n+=1){let t=e.argv[n];ca.has(t)||t.startsWith("-")||o.push(t)}return o}a(da,"collectTeeTargets");function ua(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(ua,"collectPowerShellWriteTargets");function Ne(e){let o=new Set,n=a(r=>{let i=r?.trim();i&&o.add(i)},"pushTarget");for(let r of Oo(e))n(r);let t=no(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 da(i))n(c);else if(ns.has(l))for(let c of ua(i))n(c)}}return Array.from(o)}a(Ne,"collectBashWriteTargets");function is(e,o){if(!On(e))return{dangerous:!1};let n=new Set([...Ne(e),...ia(e)]);for(let t of n)if(!Fn(t,o))return{dangerous:!0,reason:`Command may modify file outside project: ${t}`};return{dangerous:!1}}a(is,"getBashOutsideProjectWriteRisk");function as(e,o,n){let t=la(n);if(hr(e))return null;if(eo.has(e)){let r=typeof o.path=="string"?o.path:"";return r?Ln(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(!On(r))return null;let i=Ne(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=>!Ln(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(as,"getPlanModeBlockReason");import de from"node:path";import fa from"node:os";function De(e,o){try{let n=de.resolve(e),t=de.resolve(o);return n===t?!0:n.startsWith(t+de.sep)}catch{return!1}}a(De,"isPathUnder");function ma(){try{return xo()}catch{return}}a(ma,"safeGetAgentConfigHome");function ls(e,o){let n=ma();if(n&&De(e,n))return"user-kodax";let t=de.join(de.resolve(o),".kodax");if(De(e,t))return"project-kodax"}a(ls,"resolveProtectedZone");function pa(){let e=new Set;try{e.add(fa.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(pa,"getSystemTempDirs");var ga=new Set(["bash"]),wa={toolNames:ga,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=pa(),c=de.resolve(o);for(let d of Oo(n)){let u;try{u=de.resolve(o,d)}catch{continue}let g=ls(u,o);if(g){r.has(u)||(r.add(u),t.push({kind:"protected_path",path:d,zone:g}));continue}if(ro(d,o)){let f=l.some(v=>De(u,v)),k=De(u,c);!f&&!k&&!i.has(u)&&(i.add(u),t.push({kind:"outside_project",path:d}))}}for(let d of Ne(n)){let u;try{u=de.resolve(o,d)}catch{continue}ls(u,o)||De(u,c)||l.some(k=>De(u,k))||t.push({kind:"shell_redirect_outside",target:d})}return t}};var Do=F("config.json");function us(){return ds.join(process.cwd(),".kodax","config.local.json")}a(us,"getProjectConfigFile");function Gu(e=process.env){let n=so(Do).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=cs(n.classifierModel),d=cs(e.KODAX_AUTO_MODE_CLASSIFIER_MODEL),u=e.KODAX_AUTO_MODE_TIMEOUT_MS?.trim(),g=u!==void 0?Number(u):NaN,f=Number.isFinite(g)&&g>0?Math.floor(g):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(Gu,"loadAutoModeSettings");function cs(e){if(typeof e!="string")return;let o=e.trim();return o.length===0?void 0:o}a(cs,"nonEmptyString");function so(e){try{if(No.existsSync(e))return JSON.parse(No.readFileSync(e,"utf-8"))}catch{}return{}}a(so,"readJsonFile");function fs(e,o){No.mkdirSync(ds.dirname(e),{recursive:!0}),No.writeFileSync(e,JSON.stringify(o,null,2))}a(fs,"writeJsonFile");function Bn(e){let o=so(Do);fs(Do,{...o,permissionMode:e})}a(Bn,"savePermissionModeUser");function zu(){let e=so(Do),o=so(us()),n=e.alwaysAllowTools??[],t=o.alwaysAllowTools??[];return[...new Set([...n,...t])]}a(zu,"loadAlwaysAllowTools");function qu(e,o,n=!1){let t=Un(e,o,n);if(!t)return;let r=us(),i=so(r),l=i.alwaysAllowTools??[];l.includes(t)||fs(r,{...i,alwaysAllowTools:[...l,t]})}a(qu,"saveAlwaysAllowToolPattern");var Gn=["ama","amaw","sa"];function ms(e){let o=Gn.indexOf(e);return Gn[(o+1)%Gn.length]??"ama"}a(ms,"nextAgentMode");var Ue=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}},ha=new Ue;import K from"chalk";import{Buffer as hs}from"node:buffer";import{spawn as ya}from"node:child_process";import ps from"node:process";var ve="\x1B",ka="\x07",zn=`${ve}\\`;function gs(e,o){return e.SSH_CONNECTION?!1:o==="win32"||o==="darwin"||o==="linux"}a(gs,"shouldPreferNativeClipboard");function va(e,o){let n=hs.from(e,"utf8").toString("base64"),t=o.TERM==="xterm-kitty"?zn:ka,r=`${ve}]52;c;${n}${t}`;return o.TMUX?`${ve}Ptmux;${r.replaceAll(ve,`${ve}${ve}`)}${zn}`:o.STY?`${ve}P${r}${zn}`:r}a(va,"buildOscSequence");async function Uo(e,o,n){return new Promise((t,r)=>{let i=ya(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(Uo,"execClipboardCommand");function $a(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=hs.from(e,"utf8");return[["powershell",["-NoProfile","-NonInteractive","-Command",o],n],["pwsh",["-NoProfile","-NonInteractive","-Command",o],n],["cmd",["/c","chcp 65001 >nul & clip"],n]]}a($a,"buildWindowsClipboardCandidates");async function ws(e,o,n){if(o.SSH_CONNECTION)return!1;switch(n){case"win32":{let t=$a(e);for(let[r,i,l]of t)try{if(await Uo(r,i,l))return!0}catch{}return!1}case"darwin":return Uo("pbcopy",[],e);case"linux":{let t=[["wl-copy",[]],["xclip",["-selection","clipboard"]],["xsel",["--clipboard","--input"]]];for(let[r,i]of t)try{if(await Uo(r,i,e))return!0}catch{}return!1}default:return!1}}a(ws,"tryNativeClipboard");async function Sa(e,o){if(!o.TMUX)return!1;let n=o.LC_TERMINAL==="iTerm2"?["load-buffer","-"]:["load-buffer","-w","-"];try{return await Uo("tmux",n,e)}catch{return!1}}a(Sa,"tryTmuxClipboard");async function ys(e,o={}){let n=o.env??ps.env,t=o.platform??ps.platform,r=e.trimEnd(),i=va(r,n);if(!r)throw new Error("Nothing to copy.");if(gs(n,t))try{if(await ws(r,n,t))return{path:"native"}}catch{}if(await Sa(r,n))return{path:"tmux-buffer"};if(o.terminalWrite?.(i))return{path:"osc52"};if(!gs(n,t))try{if(await ws(r,n,t))return{path:"native"}}catch{}throw new Error("Unable to access any clipboard path.")}a(ys,"copyTextToClipboard");var qn;(function(e){e.Idle="idle",e.Responding="responding",e.WaitingForConfirmation="waiting_for_confirmation"})(qn||(qn={}));var B;(function(e){e.Scheduled="scheduled",e.Validating="validating",e.AwaitingApproval="awaiting_approval",e.Executing="executing",e.Success="success",e.Error="error",e.Cancelled="cancelled"})(B||(B={}));var rf={[B.Scheduled]:"\u25CB",[B.Validating]:"\u25CC",[B.AwaitingApproval]:"?",[B.Executing]:"\u25CB",[B.Success]:"\u2713",[B.Error]:"\u2717",[B.Cancelled]:"-"},ks;(function(e){e[e.Low=-100]="Low",e[e.Normal=0]="Normal",e[e.High=100]="High",e[e.Critical=200]="Critical"})(ks||(ks={}));var sf={streamingState:qn.Idle,currentResponse:"",history:[],pendingToolCalls:[],sessionId:"",provider:"",model:"",isLoading:!1};var ba="[redacted]",vs="[truncated]";function ne(e,o=2e3){return e.length>o?`${e.slice(0,o-3)}...`:e}a(ne,"truncateToolReplayText");function xa(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(xa,"isSensitiveToolInputKey");function $s(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}a($s,"isRecord");function Kn(e,o=0,n=new WeakSet){if(e===null||typeof e=="number"||typeof e=="boolean")return e;if(typeof e=="string")return ne(e);if(o>=6)return vs;if(typeof e=="object"&&e!==null){if(n.has(e))return vs;if(n.add(e),Array.isArray(e))return e.slice(0,50).map(r=>Kn(r,o+1,n));if(!$s(e))return ne(String(e));let t={};for(let[r,i]of Object.entries(e).slice(0,50))t[r]=xa(r)?ba:Kn(i,o+1,n);return t}return ne(String(e))}a(Kn,"sanitizeToolJsonValue");function Ss(e){if(!e)return;let o=Kn(e);return $s(o)?o:void 0}a(Ss,"sanitizeToolInput");function bs(e){if(e!==void 0){if(typeof e=="string")return ne(e);try{return ne(JSON.stringify(e))}catch{return ne(String(e))}}}a(bs,"stringifyToolReplayValue");function ff(e){return e.type==="tool_summary"?{type:"event",text:e.text,icon:"tool"}:e.type==="tool_group"?{type:"tool_group",tools:e.tools.map(Pa)}:e}a(ff,"seedToHistoryItem");var Aa="[Thinking]",Ra="[/Thinking]",Ca="Untitled Session",xs=50,Ta=60,Rs="...",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:"],Ts=[/(?:^|\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:/],Ia=/(^|\r?\n)\[Thinking\]\r?\n([\s\S]*?)\r?\n\[\/Thinking\](?=\r?\n|$)/g,Ea="Session ended before the tool completed.";function _a(e){switch(e){case"success":return B.Success;case"error":return B.Error;case"cancelled":return B.Cancelled;case"awaiting_approval":return B.AwaitingApproval;default:return e}}a(_a,"toolCallSeedToHistoryToolStatus");function Pa(e){return{id:e.id,name:e.name,status:_a(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(Pa,"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 Ts){let t=n.exec(e);t&&t.index>=0&&(o===-1||t.index<o)&&(o=t.index)}return o}a(Ma,"findControlPlaneCutIndex");function La(e){return Cs.some(o=>e.includes(o))||Ts.some(o=>o.test(e))}a(La,"hasControlPlaneSignal");function Is(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(Is,"collectTextBlocks");function Fo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}a(Fo,"isRecord");function Wa(e){if(typeof e=="string")return ne(e);if(e===void 0)return"";try{return bs(e)??""}catch{return ne(String(e))}}a(Wa,"toolResultContentToString");function Oa(e){let o=Wa(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(Oa,"inferToolResultSeed");function Na(e){let o=new Map;if(!e||e.role!=="user"||!Array.isArray(e.content))return o;for(let n of e.content)!Fo(n)||n.type!=="tool_result"||typeof n.tool_use_id!="string"||o.set(n.tool_use_id,Oa(n));return o}a(Na,"collectToolResultSeeds");function Da(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:Ea};return{id:e.id,name:e.name,status:n.status,...e.input!==void 0?{input:Ss(Fo(e.input)?e.input:{})??{}}:{},...n.output!==void 0?{output:n.output}:{},...n.error!==void 0?{error:n.error}:{}}}a(Da,"buildToolCallSeed");function Ua(e){return typeof e=="string"?e:Array.isArray(e)?Is(e).join(`
2
+ import{A as _r,B as Pr,C as Mr,j as Rr,l as We,m as Rn,n as Cr,o as Tr,p as Ir,q as Cn,s as Tn,t as In,u as Er,w as Eo,y as ye}from"./chunk-7EAGBLRV.js";import{a as Lr}from"./chunk-ZBK3DZ3S.js";import{Ja as yr,Ma as he,Qa as Me,Sa as Je,Ta as To,Ua as kr,Va as vr,Xa as $r,Ya as An,Za as Sr,_a as Ze,ab as Le,cb as br,lb as Io,mb as xr,sb as Ar,tb as Qe}from"./chunk-DHETLULC.js";import{$d as hr,Fd as mr,Hd as pr,Id as gr,Ld as xn,Zd as wr,_ as lr,ba as Ye,ca as cr,eb as dr,hd as oe,ld as ur,md as fr,w as ar}from"./chunk-NZVJ3DFC.js";import{j as $n,sa as Vt,ta as Te,ua as Ie}from"./chunk-CDGOEK3T.js";import{Ib as Ao,Id as ir,Kb as Ro,Lb as Qt,Ld as bn,Mc as Ee,Nb as er,Nc as _e,Sc as rr,Ud as Co,k as Sn,sb as Yt,sd as Pe,tb as Jt,td as sr,va as xo,wa as F,xb as Zt,xc as or,yc as nr,zc as tr}from"./chunk-JCDO2FR4.js";import{a,b as vn,c as Oi}from"./chunk-V4WSBIXB.js";var Hr=vn((tu,jr)=>{"use strict";jr.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 Vr=vn((su,Xr)=>{"use strict";var Kr="(?:"+["\\|\\|","\\&\\&",";;","\\|\\&","\\<\\(","\\<\\<\\<",">>",">\\&","<\\&","[&;()|<>]"].join("|")+")",Br=new RegExp("^"+Kr+"$"),Gr="|&;()<> \\t",Ui='"((\\\\"|[^"])*?)"',Fi="'((\\\\'|[^'])*?)'",ji=/^#$/,zr="'",qr='"',En="$",ke="",Hi=4294967296;for(_n=0;_n<4;_n++)ke+=(Hi*Math.random()).toString(16);var _n,Bi=new RegExp("^"+ke);function Gi(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(Gi,"matchAll");function zi(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+ke+JSON.stringify(t)+ke:o+t}a(zi,"getVar");function qi(e,o,n){n||(n={});var t=n.escape||"\\",r="(\\"+t+`['"`+Gr+`]|[^\\s'"`+Gr+"])+",i=new RegExp(["("+Kr+")","("+r+"|"+Ui+"|"+Fi+")+"].join("|"),"g"),l=Gi(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(Br.test(u))return{op:u};var g=!1,f=!1,k="",v=!1,h;function y(){h+=1;var C,G,z=u.charAt(h);if(z==="{"){if(h+=1,u.charAt(h)==="}")throw new Error("Bad substitution: "+u.slice(h-2,h+1));if(C=u.indexOf("}",h),C<0)throw new Error("Bad substitution: "+u.slice(h));G=u.slice(h,C),h=C}else if(/[*@#?$!_-]/.test(z))G=z,h+=1;else{var Y=u.slice(h);C=Y.match(/[^\w\d_]/),C?(G=Y.slice(0,C.index),h+=C.index-1):(G=Y,h=u.length)}return zi(o,"",G)}for(a(y,"parseEnvVar"),h=0;h<u.length;h++){var m=u.charAt(h);if(v=v||!g&&(m==="*"||m==="?"),f)k+=m,f=!1;else if(g)m===g?g=!1:g==zr?k+=m:m===t?(h+=1,m=u.charAt(h),m===qr||m===t||m===En?k+=m:k+=t+m):m===En?k+=y():k+=m;else if(m===qr||m===zr)g=m;else{if(Br.test(m))return{op:u};if(ji.test(m)){c=!0;var R={comment:e.slice(d.index+h+1)};return k.length?[k,R]:[R]}else m===t?f=!0:m===En?k+=y():k+=m}}return v?{op:"glob",pattern:k}:k}).reduce(function(d,u){return typeof u>"u"?d:d.concat(u)},[])}a(qi,"parseInternal");Xr.exports=a(function(o,n,t){var r=qi(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("("+ke+".*?"+ke+")","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(ke)[1]):d}))},[])},"parse")});var Yr=vn(Pn=>{"use strict";Pn.quote=Hr();Pn.parse=Vr()});import*as mn from"fs";import*as vo from"path";import s from"chalk";var _o=["plan","accept-edits","auto","auto-in-project"];function Qd(e){return e==="auto"||e==="auto-in-project"}a(Qd,"isAutoMode");function Ni(e){switch(e){case"plan":return"Plan";case"accept-edits":return"Edits";case"auto":case"auto-in-project":return"Auto"}}a(Ni,"permissionModeDisplayName");var Di='[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 eu(e=console.warn){let o=!1;return()=>{o||(o=!0,e(Di))}}a(eu,"createAutoInProjectDeprecationEmitter");var Wr=wr(),eo=new Set(Wr.filter(e=>e.sideEffect==="mutates-fs"&&e.requiredParams.includes("path")).map(e=>e.name)),Or=new Set(Wr.filter(e=>e.sideEffect!=="readonly").map(e=>e.name)),Nr=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"]),Dr=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 Ur(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(Ur,"computeConfirmTools");function Fr(e){return e!==void 0&&_o.includes(e)}a(Fr,"isPermissionMode");function oo(e,o){return Fr(e)?e:o}a(oo,"normalizePermissionMode");import No from"fs";import ds from"path";import Po from"fs";import L from"path";import to from"os";var Qr=Oi(Yr(),1);var Jr=new Set(["/dev/null","nul","NUL"]);function Mn(e){return Jr.has(e)||Jr.has(e.toLowerCase())}a(Mn,"isNullDevice");function no(e){let o=e.trim();if(!o)return{statements:[],unparseable:!1};if(o.includes("`"))return{statements:[],unparseable:!0};let n;try{n=(0,Qr.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"),g=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===";"){g(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(Zr(`&${h.op}`,y)),f+=2;continue}d=!0;continue}if(Xi(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(Zr(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 g(null),{statements:t,unparseable:d}}a(no,"parseBashCommand");var Ki=new Set([">",">>","<","<<","<<<","&>","&>>"]),es=/^([0-9]+|&)(>>?|<<?)$/;function Xi(e){return Ki.has(e)||es.test(e)}a(Xi,"isRedirectionOp");function Zr(e,o){let n=null,t=e,r=es.exec(e);return r&&(n=r[1],t=r[2]),{op:e,fd:n,append:t===">>"||e==="&>>",input:t==="<"||t==="<<"||e==="<<<",target:o}}a(Zr,"parseRedirection");var Vi=L.join(".agent","plan_mode_doc.md"),Mo=new Map,Lo=null;function Yi(e){if(!e||!e.trim())return!1;let o=e.trim().replace(/\s+/g," ").toLowerCase();for(let n of Dr)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(Yi,"isSingleBashReadCommand");var Ji=/^[a-zA-Z0-9]+$/;function Zi(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(!Ji.test(t))return!1;return n}a(Zi,"isHelpCommand");function Wn(e){if(!e||!e.trim())return!1;if(Zi(e))return!0;let o=e.trim().replace(/\\\r?\n/g," "),n=no(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||!Mn(c.target))return!1;let l=i.argv.join(" ");if(l&&!(t&&i.argv[0]?.toLowerCase()==="cd"&&i.argv.length>=2)&&!Yi(l))return!1}}return!0}a(Wn,"isBashReadCommand");function Qi(e){let o=e.trim();return o?Wn(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(Qi,"getDirectShellBypassBlockReason");var ns=new Set(["remove-item","set-content","add-content","out-file","new-item","copy-item","move-item","rename-item","ni"]);function On(e){if(!e||!e.trim())return!1;let o=no(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 Nr)if(c===i||l!==null&&c===l)return!0}for(let i of r)if(ns.has(i))return!0;for(let i of t.redirections)if(!i.input&&!Mn(i.target))return!0}return!1}a(On,"isBashWriteCommand");function Nn(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(Nn,"parseAllowedToolPattern");function ea(e,o){if(o==="*")return!1;if(o.endsWith(":*")){let n=o.slice(0,-2);return e.startsWith(n)}return e===o}a(ea,"matchesBashPatternLegacy");function oa(e,o){if(o==="*")return!1;if(o.endsWith(":*")){let n=o.slice(0,-2);return e===n}return e===o}a(oa,"matchesBashPatternByExtractedPrefix");async function Dn(e,o,n,t,r){if(e.toLowerCase()!=="bash")return!1;let i=o.command??"",l=[];for(let c of n){let d=Nn(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&&oa(c.value,d))return!0;return!1}for(let{pattern:c}of l)if(c&&ea(i,c))return!0;return!1}a(Dn,"isToolCallAllowed");function Un(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(Un,"generateSavePattern");function ro(e,o){try{let n=L.resolve(e),t=L.resolve(o),r=xo(),i=L.join(t,".kodax");return Oe(n,i)||Oe(n,r)?!0:!(Oe(n,t)||ss().some(c=>Oe(n,c)))}catch{return!1}}a(ro,"isAlwaysConfirmPath");function os(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"&&na.test(e)):!!(e.startsWith(".")&&/[/\\]/.test(e))}a(os,"looksLikePath");var na=/^\/[A-Za-z][A-Za-z0-9]*(?::[A-Za-z0-9]+)?$/;function ta(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(ta,"legacyRegexPathScan");function Oo(e){let o=new Set,n=no(e);if(!n.unparseable)for(let t of n.statements)for(let r of t.stages){for(let i of r.argv)os(i)&&o.add(i);for(let i of r.redirections)os(i.target)&&o.add(i.target)}for(let t of ta(e))o.add(t);return Array.from(o)}a(Oo,"extractPathsFromCommand");function ra(e,o){let n=Oo(e);for(let t of n)if(ro(t,o))return!0;return!1}a(ra,"isCommandOnProtectedPath");function Wo(e){let o=L.normalize(e);return process.platform==="win32"?o.toLowerCase():o}a(Wo,"normalizePathForComparison");function sa(e,o){return Wo(e)===Wo(o)}a(sa,"pathsEqual");function Oe(e,o){let n=Wo(e),t=Wo(o);return n===t||n.startsWith(t+L.sep)}a(Oe,"isPathInsideDirectory");function Fn(e,o){try{let n=L.resolve(o),t=L.resolve(n,rs(ts(e)));return Oe(t,n)}catch{return!1}}a(Fn,"isPathInsideProject");function ia(e){let o=e.match(/[A-Za-z]:[\\/][^\s;|&<>(){}'"]+|\/[^\s;|&<>(){}'"]+/g);return o?o.filter(n=>!/^(?:\/dev\/|\/proc\/)/i.test(n)):[]}a(ia,"collectAbsolutePathCandidates");function jn(e){let o=L.resolve(e),n=Mo.get(o);if(n)return n;if(Po.existsSync(o)){let c=Po.realpathSync.native(o);return Mo.set(o,c),c}let t=[],r=o;for(;!Po.existsSync(r);){let c=L.dirname(r);if(c===r)return Mo.set(o,o),o;t.unshift(L.basename(r)),r=c}let i=Po.realpathSync.native(r),l=L.join(i,...t);return Mo.set(o,l),l}a(jn,"resolveExistingPathPrefix");function ts(e){return e==="~"?to.homedir():e.startsWith(`~${L.sep}`)||e.startsWith("~/")||e.startsWith("~\\")?L.join(to.homedir(),e.slice(2)):e}a(ts,"expandHomeDirectory");function rs(e){let o=to.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(rs,"expandSystemTempAlias");function aa(e,o){let n=L.resolve(o??process.cwd()),t=rs(ts(e)),r=L.isAbsolute(t)?L.resolve(t):L.resolve(n,t);return jn(r)}a(aa,"resolvePermissionPath");function ss(){if(Lo)return Lo;let e=new Set,o=[to.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(jn(n))}catch{}return Lo=Array.from(e),Lo}a(ss,"getSystemTempDirectories");function Hn(e){let o=jn(e??process.cwd());return{projectPlanDoc:L.join(o,Vi),systemTempDirs:ss()}}a(Hn,"getPlanModeAllowedWritablePaths");function Ln(e,o){let n=aa(e,o),{projectPlanDoc:t,systemTempDirs:r}=Hn(o);return sa(n,t)?!0:r.some(i=>Oe(n,i))}a(Ln,"isPlanModeAllowedPath");function la(e){let{projectPlanDoc:o,systemTempDirs:n}=Hn(e),t=n[0]??to.tmpdir();return`${o} or the system temp directory (${t})`}a(la,"formatPlanModeAllowedLocations");var ca=new Set(["-a","--append","-i","--ignore-interrupts"]);function da(e){let o=[];for(let n=1;n<e.argv.length;n+=1){let t=e.argv[n];ca.has(t)||t.startsWith("-")||o.push(t)}return o}a(da,"collectTeeTargets");function ua(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(ua,"collectPowerShellWriteTargets");function Ne(e){let o=new Set,n=a(r=>{let i=r?.trim();i&&o.add(i)},"pushTarget");for(let r of Oo(e))n(r);let t=no(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 da(i))n(c);else if(ns.has(l))for(let c of ua(i))n(c)}}return Array.from(o)}a(Ne,"collectBashWriteTargets");function is(e,o){if(!On(e))return{dangerous:!1};let n=new Set([...Ne(e),...ia(e)]);for(let t of n)if(!Fn(t,o))return{dangerous:!0,reason:`Command may modify file outside project: ${t}`};return{dangerous:!1}}a(is,"getBashOutsideProjectWriteRisk");function as(e,o,n){let t=la(n);if(hr(e))return null;if(eo.has(e)){let r=typeof o.path=="string"?o.path:"";return r?Ln(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(!On(r))return null;let i=Ne(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=>!Ln(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(as,"getPlanModeBlockReason");import de from"node:path";import fa from"node:os";function De(e,o){try{let n=de.resolve(e),t=de.resolve(o);return n===t?!0:n.startsWith(t+de.sep)}catch{return!1}}a(De,"isPathUnder");function ma(){try{return xo()}catch{return}}a(ma,"safeGetAgentConfigHome");function ls(e,o){let n=ma();if(n&&De(e,n))return"user-kodax";let t=de.join(de.resolve(o),".kodax");if(De(e,t))return"project-kodax"}a(ls,"resolveProtectedZone");function pa(){let e=new Set;try{e.add(fa.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(pa,"getSystemTempDirs");var ga=new Set(["bash"]),wa={toolNames:ga,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=pa(),c=de.resolve(o);for(let d of Oo(n)){let u;try{u=de.resolve(o,d)}catch{continue}let g=ls(u,o);if(g){r.has(u)||(r.add(u),t.push({kind:"protected_path",path:d,zone:g}));continue}if(ro(d,o)){let f=l.some(v=>De(u,v)),k=De(u,c);!f&&!k&&!i.has(u)&&(i.add(u),t.push({kind:"outside_project",path:d}))}}for(let d of Ne(n)){let u;try{u=de.resolve(o,d)}catch{continue}ls(u,o)||De(u,c)||l.some(k=>De(u,k))||t.push({kind:"shell_redirect_outside",target:d})}return t}};var Do=F("config.json");function us(){return ds.join(process.cwd(),".kodax","config.local.json")}a(us,"getProjectConfigFile");function Gu(e=process.env){let n=so(Do).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=cs(n.classifierModel),d=cs(e.KODAX_AUTO_MODE_CLASSIFIER_MODEL),u=e.KODAX_AUTO_MODE_TIMEOUT_MS?.trim(),g=u!==void 0?Number(u):NaN,f=Number.isFinite(g)&&g>0?Math.floor(g):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(Gu,"loadAutoModeSettings");function cs(e){if(typeof e!="string")return;let o=e.trim();return o.length===0?void 0:o}a(cs,"nonEmptyString");function so(e){try{if(No.existsSync(e))return JSON.parse(No.readFileSync(e,"utf-8"))}catch{}return{}}a(so,"readJsonFile");function fs(e,o){No.mkdirSync(ds.dirname(e),{recursive:!0}),No.writeFileSync(e,JSON.stringify(o,null,2))}a(fs,"writeJsonFile");function Bn(e){let o=so(Do);fs(Do,{...o,permissionMode:e})}a(Bn,"savePermissionModeUser");function zu(){let e=so(Do),o=so(us()),n=e.alwaysAllowTools??[],t=o.alwaysAllowTools??[];return[...new Set([...n,...t])]}a(zu,"loadAlwaysAllowTools");function qu(e,o,n=!1){let t=Un(e,o,n);if(!t)return;let r=us(),i=so(r),l=i.alwaysAllowTools??[];l.includes(t)||fs(r,{...i,alwaysAllowTools:[...l,t]})}a(qu,"saveAlwaysAllowToolPattern");var Gn=["ama","amaw","sa"];function ms(e){let o=Gn.indexOf(e);return Gn[(o+1)%Gn.length]??"ama"}a(ms,"nextAgentMode");var Ue=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}},ha=new Ue;import K from"chalk";import{Buffer as hs}from"node:buffer";import{spawn as ya}from"node:child_process";import ps from"node:process";var ve="\x1B",ka="\x07",zn=`${ve}\\`;function gs(e,o){return e.SSH_CONNECTION?!1:o==="win32"||o==="darwin"||o==="linux"}a(gs,"shouldPreferNativeClipboard");function va(e,o){let n=hs.from(e,"utf8").toString("base64"),t=o.TERM==="xterm-kitty"?zn:ka,r=`${ve}]52;c;${n}${t}`;return o.TMUX?`${ve}Ptmux;${r.replaceAll(ve,`${ve}${ve}`)}${zn}`:o.STY?`${ve}P${r}${zn}`:r}a(va,"buildOscSequence");async function Uo(e,o,n){return new Promise((t,r)=>{let i=ya(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(Uo,"execClipboardCommand");function $a(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=hs.from(e,"utf8");return[["powershell",["-NoProfile","-NonInteractive","-Command",o],n],["pwsh",["-NoProfile","-NonInteractive","-Command",o],n],["cmd",["/c","chcp 65001 >nul & clip"],n]]}a($a,"buildWindowsClipboardCandidates");async function ws(e,o,n){if(o.SSH_CONNECTION)return!1;switch(n){case"win32":{let t=$a(e);for(let[r,i,l]of t)try{if(await Uo(r,i,l))return!0}catch{}return!1}case"darwin":return Uo("pbcopy",[],e);case"linux":{let t=[["wl-copy",[]],["xclip",["-selection","clipboard"]],["xsel",["--clipboard","--input"]]];for(let[r,i]of t)try{if(await Uo(r,i,e))return!0}catch{}return!1}default:return!1}}a(ws,"tryNativeClipboard");async function Sa(e,o){if(!o.TMUX)return!1;let n=o.LC_TERMINAL==="iTerm2"?["load-buffer","-"]:["load-buffer","-w","-"];try{return await Uo("tmux",n,e)}catch{return!1}}a(Sa,"tryTmuxClipboard");async function ys(e,o={}){let n=o.env??ps.env,t=o.platform??ps.platform,r=e.trimEnd(),i=va(r,n);if(!r)throw new Error("Nothing to copy.");if(gs(n,t))try{if(await ws(r,n,t))return{path:"native"}}catch{}if(await Sa(r,n))return{path:"tmux-buffer"};if(o.terminalWrite?.(i))return{path:"osc52"};if(!gs(n,t))try{if(await ws(r,n,t))return{path:"native"}}catch{}throw new Error("Unable to access any clipboard path.")}a(ys,"copyTextToClipboard");var qn;(function(e){e.Idle="idle",e.Responding="responding",e.WaitingForConfirmation="waiting_for_confirmation"})(qn||(qn={}));var B;(function(e){e.Scheduled="scheduled",e.Validating="validating",e.AwaitingApproval="awaiting_approval",e.Executing="executing",e.Success="success",e.Error="error",e.Cancelled="cancelled"})(B||(B={}));var rf={[B.Scheduled]:"\u25CB",[B.Validating]:"\u25CC",[B.AwaitingApproval]:"?",[B.Executing]:"\u25CB",[B.Success]:"\u2713",[B.Error]:"\u2717",[B.Cancelled]:"-"},ks;(function(e){e[e.Low=-100]="Low",e[e.Normal=0]="Normal",e[e.High=100]="High",e[e.Critical=200]="Critical"})(ks||(ks={}));var sf={streamingState:qn.Idle,currentResponse:"",history:[],pendingToolCalls:[],sessionId:"",provider:"",model:"",isLoading:!1};var ba="[redacted]",vs="[truncated]";function ne(e,o=2e3){return e.length>o?`${e.slice(0,o-3)}...`:e}a(ne,"truncateToolReplayText");function xa(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(xa,"isSensitiveToolInputKey");function $s(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}a($s,"isRecord");function Kn(e,o=0,n=new WeakSet){if(e===null||typeof e=="number"||typeof e=="boolean")return e;if(typeof e=="string")return ne(e);if(o>=6)return vs;if(typeof e=="object"&&e!==null){if(n.has(e))return vs;if(n.add(e),Array.isArray(e))return e.slice(0,50).map(r=>Kn(r,o+1,n));if(!$s(e))return ne(String(e));let t={};for(let[r,i]of Object.entries(e).slice(0,50))t[r]=xa(r)?ba:Kn(i,o+1,n);return t}return ne(String(e))}a(Kn,"sanitizeToolJsonValue");function Ss(e){if(!e)return;let o=Kn(e);return $s(o)?o:void 0}a(Ss,"sanitizeToolInput");function bs(e){if(e!==void 0){if(typeof e=="string")return ne(e);try{return ne(JSON.stringify(e))}catch{return ne(String(e))}}}a(bs,"stringifyToolReplayValue");function ff(e){return e.type==="tool_summary"?{type:"event",text:e.text,icon:"tool"}:e.type==="tool_group"?{type:"tool_group",tools:e.tools.map(Pa)}:e}a(ff,"seedToHistoryItem");var Aa="[Thinking]",Ra="[/Thinking]",Ca="Untitled Session",xs=50,Ta=60,Rs="...",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:"],Ts=[/(?:^|\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:/],Ia=/(^|\r?\n)\[Thinking\]\r?\n([\s\S]*?)\r?\n\[\/Thinking\](?=\r?\n|$)/g,Ea="Session ended before the tool completed.";function _a(e){switch(e){case"success":return B.Success;case"error":return B.Error;case"cancelled":return B.Cancelled;case"awaiting_approval":return B.AwaitingApproval;default:return e}}a(_a,"toolCallSeedToHistoryToolStatus");function Pa(e){return{id:e.id,name:e.name,status:_a(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(Pa,"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 Ts){let t=n.exec(e);t&&t.index>=0&&(o===-1||t.index<o)&&(o=t.index)}return o}a(Ma,"findControlPlaneCutIndex");function La(e){return Cs.some(o=>e.includes(o))||Ts.some(o=>o.test(e))}a(La,"hasControlPlaneSignal");function Is(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(Is,"collectTextBlocks");function Fo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}a(Fo,"isRecord");function Wa(e){if(typeof e=="string")return ne(e);if(e===void 0)return"";try{return bs(e)??""}catch{return ne(String(e))}}a(Wa,"toolResultContentToString");function Oa(e){let o=Wa(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(Oa,"inferToolResultSeed");function Na(e){let o=new Map;if(!e||e.role!=="user"||!Array.isArray(e.content))return o;for(let n of e.content)!Fo(n)||n.type!=="tool_result"||typeof n.tool_use_id!="string"||o.set(n.tool_use_id,Oa(n));return o}a(Na,"collectToolResultSeeds");function Da(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:Ea};return{id:e.id,name:e.name,status:n.status,...e.input!==void 0?{input:Ss(Fo(e.input)?e.input:{})??{}}:{},...n.output!==void 0?{output:n.output}:{},...n.error!==void 0?{error:n.error}:{}}}a(Da,"buildToolCallSeed");function Ua(e){return typeof e=="string"?e:Array.isArray(e)?Is(e).join(`
3
3
  `):""}a(Ua,"extractAssistantTextOnly");function ao(e,o,n){n.trim().length!==0&&e.push({type:o,text:n})}a(ao,"pushSeed");function As(e){return e.replace(/^\n+/,"").replace(/\n+$/,"")}a(As,"stripLegacyTagBoundaryNewlines");function Fa(e){let o=e.name,n=e.input;if(!n)return`\u26A1 ${o}`;let t=o==="bash"?io(String(n.command??"")):o==="read"||o==="write"||o==="edit"?io(String(n.file_path??n.path??"")):o==="grep"||o==="glob"?io(String(n.pattern??"")):o==="web_search"||o==="web_fetch"?io(String(n.query??n.url??"")):void 0;return t?`\u26A1 ${o}(${t})`:`\u26A1 ${o}`}a(Fa,"formatToolUseSummary");function io(e,o=60){let n=e.replace(/\s+/g," ").trim();return n.length>o?`${n.slice(0,o)}...`:n}a(io,"truncateToolHint");function ja(e){if(!e.includes(Aa)||!e.includes(Ra))return e.trim().length>0?[{type:"assistant",text:e}]:[];let o=[],n=0;for(let t of e.matchAll(Ia)){let r=t.index??-1,i=t[1]??"",l=t[2]??"";if(r<0)continue;let c=r+i.length;ao(o,"assistant",As(e.slice(n,c))),ao(o,"thinking",l),n=r+t[0].length}return ao(o,"assistant",As(e.slice(n))),o.length===0?e.trim().length>0?[{type:"assistant",text:e}]:[]:o}a(ja,"parseLegacyAssistantContent");function Es(e,o){if(typeof e=="string")return ja(e);if(!Array.isArray(e))return[];let n=[],t=[],r=[],i=a(()=>{t.length!==0&&(ao(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(!(!Fo(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&&ao(n,"thinking",String(c.thinking));break;case"tool_use":if(i(),o){let d=Da(c,o);d&&r.push(d)}else if(typeof c.name=="string"){let d=Fa({name:c.name,...Fo(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(Es,"extractAssistantHistorySeeds");var Ha=["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 Ga(e){return Ha.some(o=>e.includes(o))}a(Ga,"isManagedWorkerPrompt");function _s(e){return e.replace(Ba,"").trim()}a(_s,"stripManagedProtocolBlocks");function za(e){switch(e.role){case"assistant":return Es(e.content).flatMap(n=>{if(n.type!=="assistant")return[n];let t=_s(n.text);return t.length>0?[{...n,text:t}]:[]});case"user":{if(e._synthetic)return[];let o=Ps(e.content);return o.trim().length===0||Ga(o)?[]:[{type:"user",text:o}]}case"system":return[];default:return[]}}a(za,"extractHistorySeedsFromMessage");function mf(e){let o=[];for(let n=0;n<e.length;n+=1){let t=e[n];if(t){if(t.role==="assistant"){let r=Na(e[n+1]),i=Es(t.content,r);o.push(...i.map(l=>l.type==="assistant"?{...l,text:_s(l.text)}:l).filter(l=>l.type!=="assistant"||l.text.length>0));continue}o.push(...za(t))}}return o}a(mf,"extractHistorySeedsFromMessages");function Ps(e){return typeof e=="string"?e:Array.isArray(e)?Is(e).join(`
5
5
  `):""}a(Ps,"extractTextContent");function qa(e){let o=e.replace(/\s+/g," ").trim();return o?o.length>xs?`${o.slice(0,xs)}${Rs}`:o:Ca}a(qa,"formatSessionTitle");function Xn(e){for(let o=e.length-1;o>=0;o--){let n=e[o];if(n?.role!=="assistant")continue;let t=Ua(n.content);if(t)return t}return""}a(Xn,"extractLastAssistantText");function pf(e,o,n,t){let r=[Xn(e),o.trim(),n?.trim()??"",t?.trim()??""];for(let i of r){let l=Ms(i);if(l)return l}return""}a(pf,"resolveCompletedAssistantText");function Ms(e){let o=e.trim();if(!o)return"";let n=Ma(o);return n===0?"":(n>0?o.slice(0,n):o).trim()}a(Ms,"sanitizeUserFacingAssistantText");function gf(e){let o=e.trim();return o.length>0&&Ms(o).length===0&&La(o)}a(gf,"isControlPlaneOnlyAssistantText");function wf(e){let o=e.find(t=>t.role==="user"),n=o?Ps(o.content):"";return qa(n)}a(wf,"extractTitle");function hf(e,o=Ta){let n=e.replace(/\n/g," "),t=n.length>o?Rs:"";return n.slice(0,o)+t}a(hf,"formatMessagePreview");var Vn={name:"copy",description:"Copy last assistant message to clipboard",usage:"/copy",handler:a(async(e,o)=>{let n=Xn(o.messages);if(!n){console.log(K.yellow(`
@@ -548,4 +548,4 @@ Available Skills:
548
548
  [Skill "${t}" is not user-invocable]`)),!1;console.log(s.cyan(`
549
549
  [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 rr(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(`
550
550
  [Error invoking skill: ${i instanceof Error?i.message:String(i)}]`)),!1}}a(Ot,"executeSkillCommand");var fn=class{static{a(this,"SkillCompleter")}gitRoot;skillsCache=null;cacheTimestamp=0;cacheTtlMs=5e3;constructor(o){this.gitRoot=o}canComplete(o,n){return this.parseTrigger(o.slice(0,n))!==void 0}async getCompletions(o,n){let t=this.parseTrigger(o.slice(0,n));if(!t)return[];let r=t.partial.toLowerCase();return(await this.getSkills()).filter(l=>{let c=l.name.toLowerCase();return c.includes(r)||this.fuzzyIncludes(r,c)}).map(l=>({text:`${t.invocationPrefix}${l.name}`,display:l.name,description:this.truncateDescription(l.description),type:"skill"})).sort((l,c)=>{let d=l.display.toLowerCase().startsWith(r),u=c.display.toLowerCase().startsWith(r);return d&&!u?-1:!d&&u?1:l.display.length-c.display.length})}setGitRoot(o){this.gitRoot!==o&&(this.gitRoot=o,this.skillsCache=null)}parseTrigger(o){let n=o.match(/(^|\s)\/skill:([^\s]*)$/);if(n)return{partial:n[2]??"",invocationPrefix:"/skill:"};let t=o.match(/(^|\s)\/([^\s]*)$/);if(t)return{partial:t[2]??"",invocationPrefix:"/"}}async getSkills(){let o=Date.now();if(this.skillsCache&&o-this.cacheTimestamp<this.cacheTtlMs)return this.skillsCache;try{let n=Ee(this.gitRoot);return n.size===0&&await _e(this.gitRoot),this.skillsCache=n.listUserInvocable(),this.cacheTimestamp=o,this.skillsCache}catch{return[]}}fuzzyIncludes(o,n){let t=0;for(let r=0;r<n.length&&t<o.length;r+=1)n[r]===o[t]&&(t+=1);return t===o.length}truncateDescription(o,n=50){return o.length<=n?o:o.slice(0,n-3)+"..."}};import{exec as wd}from"node:child_process";import*as qe from"node:path";import{promisify as hd}from"node:util";var Ai=hd(wd);function yd(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(yd,"pathFromPorcelainLine");async function Ri(e,o=10){try{let[{stdout:n},{stdout:t}]=await Promise.all([Ai("git rev-parse --show-toplevel",{cwd:e}),Ai("git status --porcelain=v1 -uall",{cwd:e})]),r=n.trim(),i=[],l=new Set;for(let c of t.split(`
551
- `)){if(!c.trim())continue;let d=yd(c);if(!d)continue;let u=qe.resolve(r,d),g=qe.relative(e,u).split(qe.sep).join("/");if(!(!g||g.startsWith("..")||l.has(g))&&(l.add(g),i.push(g),i.length>=o))break}return i}catch{return[]}}a(Ri,"getRecentWorkingSetFiles");function Ke(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(Ke,"findCommandSlashIndex");var Dt=class{static{a(this,"FileCompleter")}cwdSource;cache=new Map;cacheTimeout=5e3;recentCache=new Map;recentFilesProvider;constructor(o,n=Ri){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:vo.join(c,i.slice(0,d)),g=d===-1?i:i.slice(d+1);try{let k=(await this.readdir(u)).filter(v=>v.toLowerCase().startsWith(g.toLowerCase()));for(let v of k){let h=vo.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=g.toLowerCase(),h=[];for(let y of f){if(g&&!vo.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=>{mn.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=>{mn.stat(o,(t,r)=>{n(!t&&r.isDirectory())})})}},Ut=class{static{a(this,"CommandCompleter")}commands;constructor(){this.commands=new Map,this.loadCommands()}loadCommands(){for(let n of ko().getAll())n.userInvocable!==!1&&this.commands.set(n.name,{description:n.description,aliases:n.aliases??[]});let o=oe();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=Ke(t);return r===-1?!1:!t.slice(r).includes(" ")}async getCompletions(o,n){let t=o.slice(0,n),r=Ke(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 Jg(e){let o=new Dt(e),n=new fn,t=new Ut;return async r=>{let i=r.includes("@"),l=r.includes("/");if(!i&&!l)return[[],r];let c=[];if(l){let u=await kd(r,r.length);c.push(...u)}if(l&&n.canComplete(r,r.length)){let u=await n.getCompletions(r,r.length);c.push(...u)}if(l&&t.canComplete(r,r.length)){let u=await t.getCompletions(r,r.length);c.push(...u)}if(i&&o.canComplete(r,r.length)){let u=await o.getCompletions(r,r.length);c.push(...u)}return[c.map(u=>vd(r,u)),r]}}a(Jg,"createCompleter");async function kd(e,o){let{ArgumentCompleter:n}=await import("./argument-completer-CTDNNWV3.js"),t=new n;return t.canComplete(e,o)?t.getCompletions(e,o):[]}a(kd,"getArgumentCompletions");function vd(e,o){if(o.type!=="argument")return o.text;let n=Ke(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(vd,"formatReadlineCompletion");import{existsSync as gn,readdirSync as Pi,readFileSync as Mi}from"node:fs";import{join as wn}from"node:path";var $d=[{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",description:"Use auto-mode classifier for tool permissions",type:"enum"}],pn=[{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"}],Ci=pn.slice(2).concat([{name:"off",description:"Disable reasoning",type:"enum"}]);function Sd(e){if(e&&e.includes("/")){let o=e.indexOf("/"),n=e.slice(0,o),t=e.slice(o+1);if(Te(n))try{return We(n).filter(i=>!t||i.toLowerCase().includes(t.toLowerCase())).map(i=>({name:`${n}/${i}`,description:i,type:"enum"}))}catch{}return[]}return Ie().map(o=>({name:o,description:`Switch to ${o} provider`,type:"enum"}))}a(Sd,"getModelArgs");var Ft=[{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"}],jt=[{name:"all",description:"Delete ALL sessions",type:"enum"}],bd=[{name:"status",description:"Show MCP server status",type:"enum"},{name:"refresh",description:"Refresh MCP server catalogs",type:"enum"}],xd=[{name:"status",description:"Show child-task fallback order",type:"enum"},{name:"off",description:"Disable child-task fallback providers",type:"enum"}],Ad=[{name:"llm",description:"Use LLM classifier for auto mode",type:"enum"},{name:"rules",description:"Use rules-only auto mode",type:"enum"}],Ti=[{name:"ama",description:"Use AMA agent mode",type:"enum"},{name:"amaw",description:"Use AMA workflow agent mode",type:"enum"},{name:"ama-workflow",description:"Alias for amaw",type:"enum"},{name:"sa",description:"Use single-agent mode",type:"enum"},{name:"toggle",description:"Cycle to the next agent mode",type:"enum"}],Ii=[{name:"on",description:"Enable logging",type:"enum"},{name:"off",description:"Disable logging",type:"enum"}],Rd=[{name:"list",description:"List project memory files",type:"enum"},{name:"rebuild",description:"Rebuild MEMORY.md index",type:"enum"},{name:"open",description:"Print the memory entrypoint path",type:"enum"},{name:"help",description:"Show memory help",type:"enum"}],Cd=[{name:"status",description:"Show current persistent goal",type:"enum"},{name:"pause",description:"Pause the active goal",type:"enum"},{name:"resume",description:"Resume a paused goal",type:"enum"},{name:"clear",description:"Clear the current goal",type:"enum"},{name:"help",description:"Show goal help",type:"enum"},{name:"--tokens",description:"Set an optional goal token budget",type:"enum"}],Td=[{name:"show",description:"Show a captured paste by id",type:"enum"},{name:"list",description:"List captured pastes",type:"enum"}],Id=[{name:"--workflow",description:"Review through a dynamic workflow",type:"enum"},{name:"base",description:"Review changes against the detected base branch",type:"enum"},{name:"sha",description:"Review a specific commit",type:"enum"}],Ed=[{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"}],_d=[{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"}],Pd=[{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"}],Ei=[{name:"default",description:"Clear the override and use the default value again",type:"enum"}],Md=[{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"}],Ld=new Set(["show","pause","resume","stop","delete","rerun","save","rename","revise"]),Wd=new Set(["show","delete","rerun","save","rename","revise"]),Od=[{name:"--all",description:"Show all persisted workflow runs",type:"enum"},{name:"--limit",description:"Show at most N persisted workflow runs",type:"enum"}],Nd=[{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"}],Dd=[{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"}],Ud=[".workflow.json",".ts",".mjs",".js"];function Fd(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(Fd,"workflowRunMatchesSubcommand");function hn(e){return/^[a-zA-Z0-9._-]{1,120}$/.test(e)&&!e.startsWith(".")&&!e.includes("..")}a(hn,"isWorkflowRunEntryName");function jd(e,o){let n=wn(e,"workflow-metadata.json");if(gn(n))try{let r=JSON.parse(Mi(n,"utf8"));if(typeof r=="object"&&r!==null){let i=r.displayName;if(typeof i=="string"&&hn(i.trim()))return i.trim()}}catch{}let t=o.displayName;return typeof t=="string"&&hn(t.trim())?t.trim():void 0}a(jd,"readWorkflowRunDisplayName");function Hd(){let e=Se(process.cwd()).key,o=F("workflow-runs",e);if(!gn(o))return[];let n=[];for(let t of Pi(o)){if(!hn(t))continue;let r=wn(o,t,"run.json");if(gn(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=jd(wn(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(Hd,"getPersistedWorkflowRunIdArgs");function yn(e){let o=Le().list().filter(r=>Fd(e,r.status)).map(r=>({name:r.runId,description:`${r.workflow} - ${r.status}`,type:"string"})),n=Wd.has(e)?Hd():[],t=new Set;return[...o,...n].filter(r=>t.has(r.name)?!1:(t.add(r.name),!0))}a(yn,"getWorkflowRunIdArgs");function Bd(e){for(let o of Ud)if(e.endsWith(o)){let n=e.slice(0,-o.length);return hn(n)?n:void 0}}a(Bd,"savedWorkflowNameFromFile");function $o(e={}){let o=[{path:F("workflows"),source:"personal"},{path:wn(process.cwd(),".kodax","workflows"),source:"project"}],n=new Map;for(let t of o)if(gn(t.path))try{for(let r of Pi(t.path)){if(e.generatedOnly===!0&&!r.endsWith(".workflow.json"))continue;let i=Bd(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($o,"getSavedWorkflowNameArgs");function Gd(){let e=new Map;for(let o of yn("rerun"))e.set(o.name,{...o,description:`recent run: ${o.description}`,type:"string"});for(let o of $o()){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(Gd,"getWorkflowRerunArgs");function Ht(e){let o=new Map;for(let n of yn(e))o.set(n.name,{...n,description:`workflow run: ${n.description}`,type:"string"});for(let n of $o({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(Ht,"getWorkflowRunOrSavedNameArgs");function _i(e){let o=new Set(e.slice(1).filter(n=>n.startsWith("--")));return o.has("--saved")?$o({generatedOnly:!0}):o.has("--run")?yn("delete"):Ht("delete")}a(_i,"getWorkflowDeleteTargetArgs");function zd(e){let[o=""]=e,n=o.toLowerCase(),t=e.length===1&&e[0]===""?0:e.length;if(t<=1)return[...Md,...Qe().map(r=>({name:r.name,description:r.description,type:"enum"})),...$o()];if(n==="rerun"&&t<=2)return Gd();if(n==="rename"&&t<=2)return Ht("rename");if(n==="delete"&&t<=2)return[...Dd,..._i(e)];if(n==="delete"&&t<=3&&e.slice(1).some(r=>r.startsWith("--")))return _i(e);if(n==="revise"){if(t<=2)return[{name:"--replace",description:"Replace a saved workflow after confirmation",type:"enum"},...Ht("revise")];if(e[1]==="--replace"&&t<=3)return $o()}return Ld.has(n)&&t<=2?yn(n):n==="runs"&&t<=2?Od:n==="prune"&&t<=2?Nd:[]}a(zd,"getWorkflowArgs");function qd(e){let[o=""]=e,n=o.toLowerCase(),t=e.length===1&&e[0]===""?0:e.length;return t<=1?Ed:t>2?[]:n==="mode"?_d:n==="trace"?Pd:n==="endpoint"?[...Ei,{name:lr,description:"Default local repointel daemon endpoint",type:"string"}]:n==="bin"?Ei:[]}a(qd,"getRepointelArgs");var Kd=new Map([["mode",$d],["thinking",pn],["think",pn],["t",pn],["reasoning",Ci],["reason",Ci],["status",Ft],["info",Ft],["ctx",Ft],["mcp",bd],["fallback",xd],["auto-engine",Ad],["agent-mode",Ti],["am",Ti],["verifier-log",Ii],["stall-log",Ii],["memory",Rd],["goal",Cd],["paste",Td],["review",Id],["delete",jt],["rm",jt],["del",jt]]),Xd=new Set(["model","m","provider"]),Vd=new Set(["repointel","ri"]),Yd=new Set(["workflow"]);function Bt(e,o,n=[]){let t=e.toLowerCase();return Xd.has(t)?Sd(o):Vd.has(t)?qd(n):Yd.has(t)?zd(n):Kd.get(t)??[]}a(Bt,"getCommandArguments");var Gt=class{static{a(this,"ArgumentCompleter")}canComplete(o,n){let t=o.slice(0,n),r=Ke(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 Bt(c).length>0}async getCompletions(o,n){let t=o.slice(0,n),r=Ke(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+/):[""],g=u.length-1,f=(u[g]??"").toLowerCase(),k=Bt(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 R=y.display.toLowerCase().startsWith(f),C=m.display.toLowerCase().startsWith(f);return R&&!C?-1:!R&&C?1:y.display.length-m.display.length})}};function dw(){return new Gt}a(dw,"createArgumentCompleter");export{qn as a,B as b,rf as c,ks as d,sf as e,_o as f,Qd as g,Ni as h,eu as i,eo as j,Ur as k,Fr as l,oo as m,Wn as n,Qi as o,On as p,Dn as q,Un as r,ro as s,ra as t,Fn as u,Ne as v,is as w,as as x,wa as y,Gu as z,Bn as A,zu as B,qu as C,ms as D,ys as E,ne as F,Ss as G,bs as H,ff as I,Pa as J,za as K,mf as L,Ps as M,Xn as N,pf as O,Ms as P,gf as Q,wf as R,hf as S,Kf as T,Xf as U,Vf as V,Us as W,Qn as X,Fs as Y,Se as Z,om as _,xe as $,Zl as aa,Ql as ba,bm as ca,xm as da,kt as ea,gp as fa,wp as ga,hp as ha,Tp as ia,Ip as ja,Ep as ka,_p as la,Pp as ma,mi as na,Dp as oa,Up as pa,gi as qa,Fp as ra,wi as sa,Og as ta,Ng as ua,fn as va,Gt as wa,dw as xa,Ke as ya,Dt as za,Ut as Aa,Jg as Ba};
551
+ `)){if(!c.trim())continue;let d=yd(c);if(!d)continue;let u=qe.resolve(r,d),g=qe.relative(e,u).split(qe.sep).join("/");if(!(!g||g.startsWith("..")||l.has(g))&&(l.add(g),i.push(g),i.length>=o))break}return i}catch{return[]}}a(Ri,"getRecentWorkingSetFiles");function Ke(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(Ke,"findCommandSlashIndex");var Dt=class{static{a(this,"FileCompleter")}cwdSource;cache=new Map;cacheTimeout=5e3;recentCache=new Map;recentFilesProvider;constructor(o,n=Ri){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:vo.join(c,i.slice(0,d)),g=d===-1?i:i.slice(d+1);try{let k=(await this.readdir(u)).filter(v=>v.toLowerCase().startsWith(g.toLowerCase()));for(let v of k){let h=vo.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=g.toLowerCase(),h=[];for(let y of f){if(g&&!vo.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=>{mn.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=>{mn.stat(o,(t,r)=>{n(!t&&r.isDirectory())})})}},Ut=class{static{a(this,"CommandCompleter")}commands;constructor(){this.commands=new Map,this.loadCommands()}loadCommands(){for(let n of ko().getAll())n.userInvocable!==!1&&this.commands.set(n.name,{description:n.description,aliases:n.aliases??[]});let o=oe();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=Ke(t);return r===-1?!1:!t.slice(r).includes(" ")}async getCompletions(o,n){let t=o.slice(0,n),r=Ke(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 Jg(e){let o=new Dt(e),n=new fn,t=new Ut;return async r=>{let i=r.includes("@"),l=r.includes("/");if(!i&&!l)return[[],r];let c=[];if(l){let u=await kd(r,r.length);c.push(...u)}if(l&&n.canComplete(r,r.length)){let u=await n.getCompletions(r,r.length);c.push(...u)}if(l&&t.canComplete(r,r.length)){let u=await t.getCompletions(r,r.length);c.push(...u)}if(i&&o.canComplete(r,r.length)){let u=await o.getCompletions(r,r.length);c.push(...u)}return[c.map(u=>vd(r,u)),r]}}a(Jg,"createCompleter");async function kd(e,o){let{ArgumentCompleter:n}=await import("./argument-completer-OWEXGWNL.js"),t=new n;return t.canComplete(e,o)?t.getCompletions(e,o):[]}a(kd,"getArgumentCompletions");function vd(e,o){if(o.type!=="argument")return o.text;let n=Ke(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(vd,"formatReadlineCompletion");import{existsSync as gn,readdirSync as Pi,readFileSync as Mi}from"node:fs";import{join as wn}from"node:path";var $d=[{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",description:"Use auto-mode classifier for tool permissions",type:"enum"}],pn=[{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"}],Ci=pn.slice(2).concat([{name:"off",description:"Disable reasoning",type:"enum"}]);function Sd(e){if(e&&e.includes("/")){let o=e.indexOf("/"),n=e.slice(0,o),t=e.slice(o+1);if(Te(n))try{return We(n).filter(i=>!t||i.toLowerCase().includes(t.toLowerCase())).map(i=>({name:`${n}/${i}`,description:i,type:"enum"}))}catch{}return[]}return Ie().map(o=>({name:o,description:`Switch to ${o} provider`,type:"enum"}))}a(Sd,"getModelArgs");var Ft=[{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"}],jt=[{name:"all",description:"Delete ALL sessions",type:"enum"}],bd=[{name:"status",description:"Show MCP server status",type:"enum"},{name:"refresh",description:"Refresh MCP server catalogs",type:"enum"}],xd=[{name:"status",description:"Show child-task fallback order",type:"enum"},{name:"off",description:"Disable child-task fallback providers",type:"enum"}],Ad=[{name:"llm",description:"Use LLM classifier for auto mode",type:"enum"},{name:"rules",description:"Use rules-only auto mode",type:"enum"}],Ti=[{name:"ama",description:"Use AMA agent mode",type:"enum"},{name:"amaw",description:"Use AMA workflow agent mode",type:"enum"},{name:"ama-workflow",description:"Alias for amaw",type:"enum"},{name:"sa",description:"Use single-agent mode",type:"enum"},{name:"toggle",description:"Cycle to the next agent mode",type:"enum"}],Ii=[{name:"on",description:"Enable logging",type:"enum"},{name:"off",description:"Disable logging",type:"enum"}],Rd=[{name:"list",description:"List project memory files",type:"enum"},{name:"rebuild",description:"Rebuild MEMORY.md index",type:"enum"},{name:"open",description:"Print the memory entrypoint path",type:"enum"},{name:"help",description:"Show memory help",type:"enum"}],Cd=[{name:"status",description:"Show current persistent goal",type:"enum"},{name:"pause",description:"Pause the active goal",type:"enum"},{name:"resume",description:"Resume a paused goal",type:"enum"},{name:"clear",description:"Clear the current goal",type:"enum"},{name:"help",description:"Show goal help",type:"enum"},{name:"--tokens",description:"Set an optional goal token budget",type:"enum"}],Td=[{name:"show",description:"Show a captured paste by id",type:"enum"},{name:"list",description:"List captured pastes",type:"enum"}],Id=[{name:"--workflow",description:"Review through a dynamic workflow",type:"enum"},{name:"base",description:"Review changes against the detected base branch",type:"enum"},{name:"sha",description:"Review a specific commit",type:"enum"}],Ed=[{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"}],_d=[{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"}],Pd=[{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"}],Ei=[{name:"default",description:"Clear the override and use the default value again",type:"enum"}],Md=[{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"}],Ld=new Set(["show","pause","resume","stop","delete","rerun","save","rename","revise"]),Wd=new Set(["show","delete","rerun","save","rename","revise"]),Od=[{name:"--all",description:"Show all persisted workflow runs",type:"enum"},{name:"--limit",description:"Show at most N persisted workflow runs",type:"enum"}],Nd=[{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"}],Dd=[{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"}],Ud=[".workflow.json",".ts",".mjs",".js"];function Fd(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(Fd,"workflowRunMatchesSubcommand");function hn(e){return/^[a-zA-Z0-9._-]{1,120}$/.test(e)&&!e.startsWith(".")&&!e.includes("..")}a(hn,"isWorkflowRunEntryName");function jd(e,o){let n=wn(e,"workflow-metadata.json");if(gn(n))try{let r=JSON.parse(Mi(n,"utf8"));if(typeof r=="object"&&r!==null){let i=r.displayName;if(typeof i=="string"&&hn(i.trim()))return i.trim()}}catch{}let t=o.displayName;return typeof t=="string"&&hn(t.trim())?t.trim():void 0}a(jd,"readWorkflowRunDisplayName");function Hd(){let e=Se(process.cwd()).key,o=F("workflow-runs",e);if(!gn(o))return[];let n=[];for(let t of Pi(o)){if(!hn(t))continue;let r=wn(o,t,"run.json");if(gn(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=jd(wn(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(Hd,"getPersistedWorkflowRunIdArgs");function yn(e){let o=Le().list().filter(r=>Fd(e,r.status)).map(r=>({name:r.runId,description:`${r.workflow} - ${r.status}`,type:"string"})),n=Wd.has(e)?Hd():[],t=new Set;return[...o,...n].filter(r=>t.has(r.name)?!1:(t.add(r.name),!0))}a(yn,"getWorkflowRunIdArgs");function Bd(e){for(let o of Ud)if(e.endsWith(o)){let n=e.slice(0,-o.length);return hn(n)?n:void 0}}a(Bd,"savedWorkflowNameFromFile");function $o(e={}){let o=[{path:F("workflows"),source:"personal"},{path:wn(process.cwd(),".kodax","workflows"),source:"project"}],n=new Map;for(let t of o)if(gn(t.path))try{for(let r of Pi(t.path)){if(e.generatedOnly===!0&&!r.endsWith(".workflow.json"))continue;let i=Bd(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($o,"getSavedWorkflowNameArgs");function Gd(){let e=new Map;for(let o of yn("rerun"))e.set(o.name,{...o,description:`recent run: ${o.description}`,type:"string"});for(let o of $o()){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(Gd,"getWorkflowRerunArgs");function Ht(e){let o=new Map;for(let n of yn(e))o.set(n.name,{...n,description:`workflow run: ${n.description}`,type:"string"});for(let n of $o({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(Ht,"getWorkflowRunOrSavedNameArgs");function _i(e){let o=new Set(e.slice(1).filter(n=>n.startsWith("--")));return o.has("--saved")?$o({generatedOnly:!0}):o.has("--run")?yn("delete"):Ht("delete")}a(_i,"getWorkflowDeleteTargetArgs");function zd(e){let[o=""]=e,n=o.toLowerCase(),t=e.length===1&&e[0]===""?0:e.length;if(t<=1)return[...Md,...Qe().map(r=>({name:r.name,description:r.description,type:"enum"})),...$o()];if(n==="rerun"&&t<=2)return Gd();if(n==="rename"&&t<=2)return Ht("rename");if(n==="delete"&&t<=2)return[...Dd,..._i(e)];if(n==="delete"&&t<=3&&e.slice(1).some(r=>r.startsWith("--")))return _i(e);if(n==="revise"){if(t<=2)return[{name:"--replace",description:"Replace a saved workflow after confirmation",type:"enum"},...Ht("revise")];if(e[1]==="--replace"&&t<=3)return $o()}return Ld.has(n)&&t<=2?yn(n):n==="runs"&&t<=2?Od:n==="prune"&&t<=2?Nd:[]}a(zd,"getWorkflowArgs");function qd(e){let[o=""]=e,n=o.toLowerCase(),t=e.length===1&&e[0]===""?0:e.length;return t<=1?Ed:t>2?[]:n==="mode"?_d:n==="trace"?Pd:n==="endpoint"?[...Ei,{name:lr,description:"Default local repointel daemon endpoint",type:"string"}]:n==="bin"?Ei:[]}a(qd,"getRepointelArgs");var Kd=new Map([["mode",$d],["thinking",pn],["think",pn],["t",pn],["reasoning",Ci],["reason",Ci],["status",Ft],["info",Ft],["ctx",Ft],["mcp",bd],["fallback",xd],["auto-engine",Ad],["agent-mode",Ti],["am",Ti],["verifier-log",Ii],["stall-log",Ii],["memory",Rd],["goal",Cd],["paste",Td],["review",Id],["delete",jt],["rm",jt],["del",jt]]),Xd=new Set(["model","m","provider"]),Vd=new Set(["repointel","ri"]),Yd=new Set(["workflow"]);function Bt(e,o,n=[]){let t=e.toLowerCase();return Xd.has(t)?Sd(o):Vd.has(t)?qd(n):Yd.has(t)?zd(n):Kd.get(t)??[]}a(Bt,"getCommandArguments");var Gt=class{static{a(this,"ArgumentCompleter")}canComplete(o,n){let t=o.slice(0,n),r=Ke(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 Bt(c).length>0}async getCompletions(o,n){let t=o.slice(0,n),r=Ke(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+/):[""],g=u.length-1,f=(u[g]??"").toLowerCase(),k=Bt(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 R=y.display.toLowerCase().startsWith(f),C=m.display.toLowerCase().startsWith(f);return R&&!C?-1:!R&&C?1:y.display.length-m.display.length})}};function dw(){return new Gt}a(dw,"createArgumentCompleter");export{qn as a,B as b,rf as c,ks as d,sf as e,_o as f,Qd as g,Ni as h,eu as i,eo as j,Ur as k,Fr as l,oo as m,Wn as n,Qi as o,On as p,Dn as q,Un as r,ro as s,ra as t,Fn as u,Ne as v,is as w,as as x,wa as y,Gu as z,Bn as A,zu as B,qu as C,ms as D,ys as E,ne as F,Ss as G,bs as H,ff as I,Pa as J,za as K,mf as L,Ps as M,Xn as N,pf as O,Ms as P,gf as Q,wf as R,hf as S,Kf as T,Xf as U,Vf as V,Us as W,Qn as X,Fs as Y,Se as Z,om as _,xe as $,Zl as aa,Ql as ba,bm as ca,xm as da,kt as ea,gp as fa,wp as ga,hp as ha,Tp as ia,Ip as ja,Ep as ka,_p as la,Pp as ma,mi as na,Dp as oa,Up as pa,gi as qa,Fp as ra,wi as sa,Og as ta,Ng as ua,fn as va,Gt as wa,dw as xa,Ke as ya,Dt as za,Ut as Aa,Jg as Ba};
@@ -1,2 +1,2 @@
1
1
  // @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
2
- import{vb as k,xb as D}from"./chunk-THAKTCPE.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-7C2QUBLE.js";import{va as R}from"./chunk-JCDO2FR4.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.55";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{vb as k,xb as D}from"./chunk-NZVJ3DFC.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-CDGOEK3T.js";import{va as R}from"./chunk-JCDO2FR4.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.56";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};