@kodax-ai/kodax 0.7.82 → 0.7.83
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/README.md +10 -0
- package/README_CN.md +8 -0
- package/dist/chunks/{agent-4UTCCMD5.js → agent-S7LMMTG7.js} +1 -1
- package/dist/chunks/argument-completer-SQHG2LYE.js +2 -0
- package/dist/chunks/chunk-37RT45HT.js +379 -0
- package/dist/chunks/{chunk-ZOBNDWOA.js → chunk-3DKQC7A2.js} +1 -1
- package/dist/chunks/{chunk-WMYCNECP.js → chunk-45E23YJI.js} +142 -67
- package/dist/chunks/{chunk-GIVYTXQW.js → chunk-6QILIBOU.js} +155 -155
- package/dist/chunks/{chunk-JDZFNWMZ.js → chunk-DSFHIUHZ.js} +2 -2
- package/dist/chunks/{chunk-7ZN2MLVM.js → chunk-DZUMH6GJ.js} +1 -1
- package/dist/chunks/{chunk-VQBJMNFD.js → chunk-HI6RCW5Y.js} +2 -2
- package/dist/chunks/{chunk-XTCDCU2Q.js → chunk-LF2JBTBG.js} +4 -4
- package/dist/chunks/{chunk-NINELPXH.js → chunk-RAQGGVIF.js} +1 -1
- package/dist/chunks/{chunk-ZZUIO5KL.js → chunk-TC2VHPG5.js} +1 -1
- package/dist/chunks/{chunk-S6JTWDN6.js → chunk-URCS6CVP.js} +1 -1
- package/dist/chunks/{chunk-KH2HED37.js → chunk-XB2JNLXH.js} +2 -2
- package/dist/chunks/{compaction-config-IDL5JQVI.js → compaction-config-SSQ5NXUP.js} +1 -1
- package/dist/chunks/{construction-bootstrap-STYUR6XA.js → construction-bootstrap-E4M3CY3N.js} +1 -1
- package/dist/chunks/{dist-RKBHBUHV.js → dist-MIXP4ULB.js} +1 -1
- package/dist/chunks/{host-RF2IX3N6.js → host-ZCPI7SMC.js} +1 -1
- package/dist/chunks/{run-manager-WE2KPAKZ.js → run-manager-4RYG7HSP.js} +1 -1
- package/dist/chunks/{utils-Z2RSAENX.js → utils-7DKE2EKT.js} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -5
- package/dist/kodax_bootstrap.js +1 -1
- package/dist/kodax_cli.js +1522 -1098
- package/dist/kodax_resume.js +140 -65
- package/dist/runtime-worker.js +1415 -991
- package/dist/sandbox-workspace-session.js +121 -46
- package/dist/sdk-a2a.js +1 -1
- package/dist/sdk-agent.d.ts +8 -1
- package/dist/sdk-agent.js +1 -1
- package/dist/sdk-coding.js +1 -1
- package/dist/sdk-mcp.js +1 -1
- package/dist/sdk-repl.js +1 -1
- package/dist/sdk-runtime.d.ts +47 -2
- package/dist/sdk-runtime.js +1 -1
- package/dist/sdk-sandbox.js +1 -1
- package/dist/sdk-session.js +1 -1
- package/dist/sdk-skills.js +1 -1
- package/dist/semantic-worker.js +120 -45
- package/docs/SDK_EMBEDDER_GUIDE.md +35 -8
- package/package.json +2 -1
- package/dist/chunks/argument-completer-N7ORRJBS.js +0 -2
- package/dist/chunks/chunk-PGTU7JQX.js +0 -30
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
|
|
2
|
-
import{A as Be,C as cs,D as ds,E as us,F as Zn,I as Vo,K as fs,O as ms,Q as Yo,Y as Se,ba as ps,c as ts,d as rs,da as gs,ea as ws,f as ss,fa as hs,h as Yn,i as Jn,m as is,n as as,y as ls}from"./chunk-VQBJMNFD.js";import{a as ys}from"./chunk-7ZN2MLVM.js";import{Ba as Xn,Ga as po,Ha as Vn,ea as He,sb as Qr,ta as mo,tb as es,xb as os,ya as Xo,za as be,zb as ns}from"./chunk-ZOBNDWOA.js";import{Ta as Jr,Ua as Zr,Z as Gr}from"./chunk-ZZUIO5KL.js";import{i as Ko}from"./chunk-NINELPXH.js";import{A as Yr,D as ke,J as Fe,m as Go,n as qo,o as je,q as uo,r as zo,s as qr,t as zr,v as Xr,w as zn,x as Vr,y as fo}from"./chunk-KH2HED37.js";import{$b as qn,Gb as jr,Ib as Fr,Jb as Hr,Mb as Gn,Na as Ho,S as Ur,Tc as Kr,Vc as ne,ac as Bo,dc as Br}from"./chunk-GIVYTXQW.js";import{C as Sr,Pa as Hn,Qa as Oe,Ra as Ne,ka as co,ma as jn,ya as Fn}from"./chunk-TRNAWSXP.js";import{Ac as Or,Fa as xr,Ga as Ar,Ha as Bn,Od as Dr,id as Ue,jd as Nr,nd as Kn,xd as Fo}from"./chunk-WMYCNECP.js";import{$a as ve,J as Ir,K as Tr,L as Pr,X as Uo,Z as jo,_ as Lr,a as Do,aa as Mr,ab as De,d as K,fb as _r,g as ue,h as _,i as oe,j as $r,lb as Wr,s as Rr,t as Er,y as Cr}from"./chunk-EVXIJPZ6.js";import{a as i}from"./chunk-ONUPGMER.js";import*as _n from"fs";import*as Wo from"path";import*as Tn from"fs";import In from"path";import s from"chalk";var Jo=["plan","accept-edits","auto","auto-in-project"];function _a(e){return e==="auto"||e==="auto-in-project"}i(_a,"isAutoMode");function zf(e,o){return _a(e)&&o==="llm"}i(zf,"isAutoLlmMode");function Wa(e){switch(e){case"plan":return"Plan";case"accept-edits":return"Edits";case"auto":case"auto-in-project":return"Auto"}}i(Wa,"permissionModeDisplayName");var Oa='[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 Xf(e=o=>{K({source:"repl:permission",level:"warn",message:o})}){let o=!1;return()=>{o||(o=!0,e(Oa))}}i(Xf,"createAutoInProjectDeprecationEmitter");function Zo(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}}i(Zo,"computeConfirmTools");function ks(e){return e!==void 0&&Jo.includes(e)}i(ks,"isPermissionMode");function go(e,o){return ks(e)?e:o}i(go,"normalizePermissionMode");import{createHash as Na,randomUUID as Da}from"node:crypto";import Ke from"node:fs";import bs from"node:path";var ho=class extends Error{static{i(this,"ProviderSetupConfigConflictError")}constructor(o){super(`KodaX configuration changed while setup was open: ${o}. Re-run \`kodax setup\`.`),this.name="ProviderSetupConfigConflictError"}},Ge=class extends Error{static{i(this,"ProviderSetupInvalidConfigError")}constructor(o,n){super(`KodaX configuration cannot be safely updated: ${o}. ${n}`),this.name="ProviderSetupInvalidConfigError"}},Es=/^[A-Za-z_][A-Za-z0-9_]*$/,Ua=new Set(["accesskey","apikey","accesstoken","auth","authorization","bearertoken","clientsecret","credential","key","password","privatekey","refreshtoken","secret","sig","signature","token","xapikey"]);function qe(){return Object.entries(co).filter(([,e])=>e.capabilityProfile.transport!=="cli-bridge").map(([e,o])=>({name:e,apiKeyEnv:o.apiKeyEnv,defaultModel:o.model,models:[...new Set(o.models?[o.model,...o.models.map(n=>n.id)]:[o.model])]})).sort((e,o)=>e.name===jn?-1:o.name===jn?1:e.name.localeCompare(o.name))}i(qe,"getProviderSetupCatalog");function Cs(e={}){let o=e.configPath??_("config.json"),n=e.catalog??qe(),t=e.environment??process.env,r=Qn(o);if(!r.config)return{status:"invalid-config",configPath:o,configRevision:r.revision,reason:r.error??"config.json is not a JSON object."};let a=Ps(r.config);if(a)return{status:"invalid-config",configPath:o,configRevision:r.revision,reason:a};let l=xs(e.explicitProvider);if(l){let d=Rs(r.config,l,n);return d&&(!d.requiresCredential||As(t,d.apiKeyEnv))?Ss(o,r.revision,l):$s(o,r.revision,l,d?.apiKeyEnv)}if(!r.exists)return{status:"needs-provider",configPath:o,configRevision:r.revision};let c=xs(r.config.provider);if(c){let d=Rs(r.config,c,n);return d?!d.requiresCredential||As(t,d.apiKeyEnv)?Ss(o,r.revision,c):$s(o,r.revision,c,d.apiKeyEnv):{status:"invalid-config",configPath:o,configRevision:r.revision,reason:`provider "${c}" is not a valid built-in or custom provider.`}}return{status:"needs-provider",configPath:o,configRevision:r.revision}}i(Cs,"inspectProviderSetupReadiness");function Is(e){let o=e.configPath??_("config.json"),n=e.catalog??qe();try{return ss(o,()=>{let t=Qn(o);if(!t.config)throw new Ge(o,t.error??"config.json is invalid JSON.");if(t.revision!==e.expectedRevision)throw new ho(o);ja(t.config,o);let r=Ha(e.choice,n,t.config),a={...t.config,provider:r.provider,model:r.model,...r.customProviders?{customProviders:r.customProviders}:{}};if(Qn(o).revision!==e.expectedRevision)throw new ho(o);return Ba(o,a),{provider:r.provider,model:r.model,apiKeyEnv:r.apiKeyEnv,configPath:o}})}catch(t){throw t instanceof rs?new ho(o):t}}i(Is,"persistProviderSetupChoice");function Ts(e){let n=(e.platform??process.platform)==="win32"?`Required next step: use this provider's API key as the value of the user environment variable "${e.apiKeyEnv}" in Windows Environment Variables.`:`Required next step: use this provider's API key as the value of the environment variable "${e.apiKeyEnv}" in your shell profile.`;return[`config.json stores the environment-variable name only: "${e.apiKeyEnv}"; it never stores the API key.`,n,"KodaX cannot set this environment variable for you.","Close and restart this terminal so the environment is refreshed.","Then run `kodax` again.","Optional: run `kodax doctor` to verify local configuration without an LLM request."]}i(Ts,"providerSetupRestartInstructions");function Ss(e,o,n){return{status:"ready",configPath:e,configRevision:o,...n?{provider:n}:{}}}i(Ss,"ready");function $s(e,o,n,t){return{status:"needs-credential",configPath:e,configRevision:o,provider:n,...t?{apiKeyEnv:t}:{}}}i($s,"needsCredential");function xs(e){return typeof e=="string"&&e.trim()?e.trim():void 0}i(xs,"normalizedString");function As(e,o){return o!==void 0&&!!e[o]?.trim()}i(As,"hasEnvironmentValue");function Rs(e,o,n){let t=n.find(l=>l.name===o);if(t)return{apiKeyEnv:t.apiKeyEnv,requiresCredential:!0};if(Object.entries(co).find(([l])=>l===o)?.[1]?.capabilityProfile.transport==="cli-bridge")return{requiresCredential:!1};let a=Fa(e,o);return a?{apiKeyEnv:a.apiKeyEnv,requiresCredential:!0}:void 0}i(Rs,"resolveConfiguredProvider");function ja(e,o){let n=Ps(e);if(n)throw new Ge(o,n)}i(ja,"assertCustomProvidersPreservable");function Ps(e){let o=e.customProviders;if(o===void 0)return;if(!Array.isArray(o))return"Existing customProviders must be an array; repair it before running setup.";let n=new Set;for(let t of o){let r=et(t);if(!r)return"Existing customProviders contains an invalid entry; repair it before running setup.";let a=Ls(r.baseUrl);if(a)return`Existing customProviders entry "${r.name}" is unsafe: ${a}`;if(n.has(r.name))return`Existing customProviders contains duplicate name "${r.name}"; repair it before running setup.`;n.add(r.name)}}i(Ps,"existingCustomProvidersError");function Fa(e,o){let n=e.customProviders;if(Array.isArray(n))for(let t of n){let r=et(t);if(r?.name===o)return r}}i(Fa,"findValidCustomProvider");function et(e){if(!Ms(e))return;let{name:o,protocol:n,baseUrl:t,apiKeyEnv:r,model:a}=e;if(typeof o!="string"||n!=="openai"&&n!=="anthropic"||typeof t!="string"||typeof r!="string"||typeof a!="string")return;let l={...e,name:o,protocol:n,baseUrl:t,apiKeyEnv:r,model:a};try{return Fn(l),Es.test(l.apiKeyEnv)?l:void 0}catch{return}}i(et,"toValidCustomProvider");function Ha(e,o,n){if(e.kind==="builtin"){let d=o.find(u=>u.name===e.provider);if(!d||!d.models.includes(e.model))throw new Error("Choose a supported built-in provider and model.");return{provider:d.name,model:e.model,apiKeyEnv:d.apiKeyEnv}}let t=ot(e.provider);if(o.some(d=>d.name===t.name))throw new Error(`Custom provider name "${t.name}" conflicts with a built-in provider.`);let r=n.customProviders,a=Array.isArray(r)?r.flatMap(d=>{let u=et(d);return u?[u]:[]}):[],c=a.find(d=>d.name===t.name)?a.map(d=>d.name===t.name?t:d):[...a,t];return{provider:t.name,model:t.model,apiKeyEnv:t.apiKeyEnv,customProviders:c}}i(Ha,"normalizeProviderSetupChoice");function ot(e){let o={name:e.name.trim(),protocol:e.protocol,baseUrl:e.baseUrl.trim(),apiKeyEnv:e.apiKeyEnv.trim(),model:e.model.trim()},n=Ls(o.baseUrl);if(n)throw new Error(n);if(Fn(o),!Es.test(o.apiKeyEnv))throw new Error("Custom provider API key environment variable name is invalid.");return o}i(ot,"validateProviderSetupCustomMetadata");function Ls(e){let o;try{o=new URL(e)}catch{return"Custom provider Base URL must be a valid absolute URL."}if(o.protocol!=="https:"&&o.protocol!=="http:")return"Custom provider Base URL must use http or https.";if(o.username||o.password)return"Custom provider Base URL must not contain credentials.";let n=[...o.searchParams.keys()].find(t=>Ua.has(t.toLowerCase().replace(/[-_.]/g,"")));return n===void 0?void 0:`Custom provider Base URL must not contain credential query parameter "${n}".`}i(Ls,"customProviderEndpointError");function Qn(e){if(!Ke.existsSync(e))return{configPath:e,revision:wo(void 0),exists:!1,config:{}};let o;try{o=Ke.readFileSync(e,"utf8")}catch(n){return{configPath:e,revision:wo(void 0),exists:!0,error:n instanceof Error?n.message:"config.json cannot be read."}}try{let n=JSON.parse(o);return Ms(n)?{configPath:e,revision:wo(o),exists:!0,config:n}:{configPath:e,revision:wo(o),exists:!0,error:"config.json must contain a JSON object."}}catch(n){return{configPath:e,revision:wo(o),exists:!0,error:n instanceof Error?n.message:"config.json is invalid JSON."}}}i(Qn,"readConfig");function wo(e){return Na("sha256").update(e??"<missing>","utf8").digest("hex")}i(wo,"revisionFor");function Ms(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}i(Ms,"isRecord");function Ba(e,o){let n=bs.dirname(e);Ke.mkdirSync(n,{recursive:!0});let t=bs.join(n,`.config.${process.pid}.${Da()}.tmp`);try{Ke.writeFileSync(t,`${JSON.stringify(o,null,2)}
|
|
2
|
+
import{A as Be,C as cs,D as ds,E as us,F as Zn,I as Vo,K as fs,O as ms,Q as Yo,Y as Se,ba as ps,c as ts,d as rs,da as gs,ea as ws,f as ss,fa as hs,h as Yn,i as Jn,m as is,n as as,y as ls}from"./chunk-HI6RCW5Y.js";import{a as ys}from"./chunk-DZUMH6GJ.js";import{Ba as Xn,Ga as po,Ha as Vn,ea as He,sb as Qr,ta as mo,tb as es,xb as os,ya as Xo,za as be,zb as ns}from"./chunk-3DKQC7A2.js";import{Ta as Jr,Ua as Zr,Z as Gr}from"./chunk-TC2VHPG5.js";import{i as Ko}from"./chunk-RAQGGVIF.js";import{A as Yr,D as ke,J as Fe,m as Go,n as qo,o as je,q as uo,r as zo,s as qr,t as zr,v as Xr,w as zn,x as Vr,y as fo}from"./chunk-XB2JNLXH.js";import{$b as qn,Gb as jr,Ib as Fr,Jb as Hr,Mb as Gn,Na as Ho,S as Ur,Tc as Kr,Vc as ne,ac as Bo,dc as Br}from"./chunk-6QILIBOU.js";import{C as Sr,Pa as Hn,Qa as Oe,Ra as Ne,ka as co,ma as jn,ya as Fn}from"./chunk-TRNAWSXP.js";import{Bc as Or,Fa as xr,Ga as Ar,Ha as Bn,Pd as Dr,jd as Ue,kd as Nr,od as Kn,yd as Fo}from"./chunk-45E23YJI.js";import{$a as ve,J as Ir,K as Tr,L as Pr,X as Uo,Z as jo,_ as Lr,a as Do,aa as Mr,ab as De,d as K,fb as _r,g as ue,h as _,i as oe,j as $r,lb as Wr,s as Rr,t as Er,y as Cr}from"./chunk-EVXIJPZ6.js";import{a as i}from"./chunk-ONUPGMER.js";import*as _n from"fs";import*as Wo from"path";import*as Tn from"fs";import In from"path";import s from"chalk";var Jo=["plan","accept-edits","auto","auto-in-project"];function _a(e){return e==="auto"||e==="auto-in-project"}i(_a,"isAutoMode");function zf(e,o){return _a(e)&&o==="llm"}i(zf,"isAutoLlmMode");function Wa(e){switch(e){case"plan":return"Plan";case"accept-edits":return"Edits";case"auto":case"auto-in-project":return"Auto"}}i(Wa,"permissionModeDisplayName");var Oa='[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 Xf(e=o=>{K({source:"repl:permission",level:"warn",message:o})}){let o=!1;return()=>{o||(o=!0,e(Oa))}}i(Xf,"createAutoInProjectDeprecationEmitter");function Zo(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}}i(Zo,"computeConfirmTools");function ks(e){return e!==void 0&&Jo.includes(e)}i(ks,"isPermissionMode");function go(e,o){return ks(e)?e:o}i(go,"normalizePermissionMode");import{createHash as Na,randomUUID as Da}from"node:crypto";import Ke from"node:fs";import bs from"node:path";var ho=class extends Error{static{i(this,"ProviderSetupConfigConflictError")}constructor(o){super(`KodaX configuration changed while setup was open: ${o}. Re-run \`kodax setup\`.`),this.name="ProviderSetupConfigConflictError"}},Ge=class extends Error{static{i(this,"ProviderSetupInvalidConfigError")}constructor(o,n){super(`KodaX configuration cannot be safely updated: ${o}. ${n}`),this.name="ProviderSetupInvalidConfigError"}},Es=/^[A-Za-z_][A-Za-z0-9_]*$/,Ua=new Set(["accesskey","apikey","accesstoken","auth","authorization","bearertoken","clientsecret","credential","key","password","privatekey","refreshtoken","secret","sig","signature","token","xapikey"]);function qe(){return Object.entries(co).filter(([,e])=>e.capabilityProfile.transport!=="cli-bridge").map(([e,o])=>({name:e,apiKeyEnv:o.apiKeyEnv,defaultModel:o.model,models:[...new Set(o.models?[o.model,...o.models.map(n=>n.id)]:[o.model])]})).sort((e,o)=>e.name===jn?-1:o.name===jn?1:e.name.localeCompare(o.name))}i(qe,"getProviderSetupCatalog");function Cs(e={}){let o=e.configPath??_("config.json"),n=e.catalog??qe(),t=e.environment??process.env,r=Qn(o);if(!r.config)return{status:"invalid-config",configPath:o,configRevision:r.revision,reason:r.error??"config.json is not a JSON object."};let a=Ps(r.config);if(a)return{status:"invalid-config",configPath:o,configRevision:r.revision,reason:a};let l=xs(e.explicitProvider);if(l){let d=Rs(r.config,l,n);return d&&(!d.requiresCredential||As(t,d.apiKeyEnv))?Ss(o,r.revision,l):$s(o,r.revision,l,d?.apiKeyEnv)}if(!r.exists)return{status:"needs-provider",configPath:o,configRevision:r.revision};let c=xs(r.config.provider);if(c){let d=Rs(r.config,c,n);return d?!d.requiresCredential||As(t,d.apiKeyEnv)?Ss(o,r.revision,c):$s(o,r.revision,c,d.apiKeyEnv):{status:"invalid-config",configPath:o,configRevision:r.revision,reason:`provider "${c}" is not a valid built-in or custom provider.`}}return{status:"needs-provider",configPath:o,configRevision:r.revision}}i(Cs,"inspectProviderSetupReadiness");function Is(e){let o=e.configPath??_("config.json"),n=e.catalog??qe();try{return ss(o,()=>{let t=Qn(o);if(!t.config)throw new Ge(o,t.error??"config.json is invalid JSON.");if(t.revision!==e.expectedRevision)throw new ho(o);ja(t.config,o);let r=Ha(e.choice,n,t.config),a={...t.config,provider:r.provider,model:r.model,...r.customProviders?{customProviders:r.customProviders}:{}};if(Qn(o).revision!==e.expectedRevision)throw new ho(o);return Ba(o,a),{provider:r.provider,model:r.model,apiKeyEnv:r.apiKeyEnv,configPath:o}})}catch(t){throw t instanceof rs?new ho(o):t}}i(Is,"persistProviderSetupChoice");function Ts(e){let n=(e.platform??process.platform)==="win32"?`Required next step: use this provider's API key as the value of the user environment variable "${e.apiKeyEnv}" in Windows Environment Variables.`:`Required next step: use this provider's API key as the value of the environment variable "${e.apiKeyEnv}" in your shell profile.`;return[`config.json stores the environment-variable name only: "${e.apiKeyEnv}"; it never stores the API key.`,n,"KodaX cannot set this environment variable for you.","Close and restart this terminal so the environment is refreshed.","Then run `kodax` again.","Optional: run `kodax doctor` to verify local configuration without an LLM request."]}i(Ts,"providerSetupRestartInstructions");function Ss(e,o,n){return{status:"ready",configPath:e,configRevision:o,...n?{provider:n}:{}}}i(Ss,"ready");function $s(e,o,n,t){return{status:"needs-credential",configPath:e,configRevision:o,provider:n,...t?{apiKeyEnv:t}:{}}}i($s,"needsCredential");function xs(e){return typeof e=="string"&&e.trim()?e.trim():void 0}i(xs,"normalizedString");function As(e,o){return o!==void 0&&!!e[o]?.trim()}i(As,"hasEnvironmentValue");function Rs(e,o,n){let t=n.find(l=>l.name===o);if(t)return{apiKeyEnv:t.apiKeyEnv,requiresCredential:!0};if(Object.entries(co).find(([l])=>l===o)?.[1]?.capabilityProfile.transport==="cli-bridge")return{requiresCredential:!1};let a=Fa(e,o);return a?{apiKeyEnv:a.apiKeyEnv,requiresCredential:!0}:void 0}i(Rs,"resolveConfiguredProvider");function ja(e,o){let n=Ps(e);if(n)throw new Ge(o,n)}i(ja,"assertCustomProvidersPreservable");function Ps(e){let o=e.customProviders;if(o===void 0)return;if(!Array.isArray(o))return"Existing customProviders must be an array; repair it before running setup.";let n=new Set;for(let t of o){let r=et(t);if(!r)return"Existing customProviders contains an invalid entry; repair it before running setup.";let a=Ls(r.baseUrl);if(a)return`Existing customProviders entry "${r.name}" is unsafe: ${a}`;if(n.has(r.name))return`Existing customProviders contains duplicate name "${r.name}"; repair it before running setup.`;n.add(r.name)}}i(Ps,"existingCustomProvidersError");function Fa(e,o){let n=e.customProviders;if(Array.isArray(n))for(let t of n){let r=et(t);if(r?.name===o)return r}}i(Fa,"findValidCustomProvider");function et(e){if(!Ms(e))return;let{name:o,protocol:n,baseUrl:t,apiKeyEnv:r,model:a}=e;if(typeof o!="string"||n!=="openai"&&n!=="anthropic"||typeof t!="string"||typeof r!="string"||typeof a!="string")return;let l={...e,name:o,protocol:n,baseUrl:t,apiKeyEnv:r,model:a};try{return Fn(l),Es.test(l.apiKeyEnv)?l:void 0}catch{return}}i(et,"toValidCustomProvider");function Ha(e,o,n){if(e.kind==="builtin"){let d=o.find(u=>u.name===e.provider);if(!d||!d.models.includes(e.model))throw new Error("Choose a supported built-in provider and model.");return{provider:d.name,model:e.model,apiKeyEnv:d.apiKeyEnv}}let t=ot(e.provider);if(o.some(d=>d.name===t.name))throw new Error(`Custom provider name "${t.name}" conflicts with a built-in provider.`);let r=n.customProviders,a=Array.isArray(r)?r.flatMap(d=>{let u=et(d);return u?[u]:[]}):[],c=a.find(d=>d.name===t.name)?a.map(d=>d.name===t.name?t:d):[...a,t];return{provider:t.name,model:t.model,apiKeyEnv:t.apiKeyEnv,customProviders:c}}i(Ha,"normalizeProviderSetupChoice");function ot(e){let o={name:e.name.trim(),protocol:e.protocol,baseUrl:e.baseUrl.trim(),apiKeyEnv:e.apiKeyEnv.trim(),model:e.model.trim()},n=Ls(o.baseUrl);if(n)throw new Error(n);if(Fn(o),!Es.test(o.apiKeyEnv))throw new Error("Custom provider API key environment variable name is invalid.");return o}i(ot,"validateProviderSetupCustomMetadata");function Ls(e){let o;try{o=new URL(e)}catch{return"Custom provider Base URL must be a valid absolute URL."}if(o.protocol!=="https:"&&o.protocol!=="http:")return"Custom provider Base URL must use http or https.";if(o.username||o.password)return"Custom provider Base URL must not contain credentials.";let n=[...o.searchParams.keys()].find(t=>Ua.has(t.toLowerCase().replace(/[-_.]/g,"")));return n===void 0?void 0:`Custom provider Base URL must not contain credential query parameter "${n}".`}i(Ls,"customProviderEndpointError");function Qn(e){if(!Ke.existsSync(e))return{configPath:e,revision:wo(void 0),exists:!1,config:{}};let o;try{o=Ke.readFileSync(e,"utf8")}catch(n){return{configPath:e,revision:wo(void 0),exists:!0,error:n instanceof Error?n.message:"config.json cannot be read."}}try{let n=JSON.parse(o);return Ms(n)?{configPath:e,revision:wo(o),exists:!0,config:n}:{configPath:e,revision:wo(o),exists:!0,error:"config.json must contain a JSON object."}}catch(n){return{configPath:e,revision:wo(o),exists:!0,error:n instanceof Error?n.message:"config.json is invalid JSON."}}}i(Qn,"readConfig");function wo(e){return Na("sha256").update(e??"<missing>","utf8").digest("hex")}i(wo,"revisionFor");function Ms(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}i(Ms,"isRecord");function Ba(e,o){let n=bs.dirname(e);Ke.mkdirSync(n,{recursive:!0});let t=bs.join(n,`.config.${process.pid}.${Da()}.tmp`);try{Ke.writeFileSync(t,`${JSON.stringify(o,null,2)}
|
|
3
3
|
`,{encoding:"utf8",mode:384}),Ke.renameSync(t,e)}catch(r){throw Ke.rmSync(t,{force:!0}),r}}i(Ba,"writeConfigAtomically");import{existsSync as _s,mkdirSync as Ka,readFileSync as Ws,writeFileSync as Ga}from"node:fs";import ze from"node:path";var qa={core:{},mcp:{version:1,servers:{}},extensions:{version:1,paths:[]},a2a:{version:2,agents:{}}},za=["core","mcp","extensions","a2a"];function nt(e,o){return o==="core"?ze.join(e,"config.json"):ze.join(e,"integrations",`${o}.json`)}i(nt,"activePath");function Xa(e,o){return o==="core"?ze.join(e,"config.example.jsonc"):ze.join(e,"integrations",`${o}.example.jsonc`)}i(Xa,"templatePath");function Va(e){let o=e.replaceAll("\\","/");return za.flatMap(n=>[{domain:n,kind:"active",path:nt(e,n),content:`${JSON.stringify(qa[n],null,2)}
|
|
4
4
|
`},{domain:n,kind:"template",path:Xa(e,n),content:ts(n).replaceAll("~/.kodax",o)}])}i(Va,"configFiles");function yo(e,o){if(e===null||typeof e!="object"||Array.isArray(e))throw new Error(`${o} must contain a JSON object.`);return e}i(yo,"requireRecord");function Ya(e,o){let n=yo(e,"A2A config"),t=Object.keys(n).find(a=>!["version","agents","server"].includes(a));if(t)throw new Error(`A2A config contains unknown field "${t}".`);if(n.version!==1&&n.version!==2)throw new Error("A2A config version must be 1 or 2.");let r=yo(n.agents,"A2A config agents");if(n.server!==void 0&&yo(n.server,"A2A config server"),o)o(e);else if(Object.keys(r).length>0||n.server!==void 0)throw new Error("A2A config contains active declarations that require the KodaX host validator.")}i(Ya,"validateA2ADocument");function Ja(e,o){let n=Ws(e.path,"utf8"),t;try{t=JSON.parse(n)}catch{throw new Error(`${e.domain} config is invalid JSON.`)}e.domain==="core"?yo(t,"Core config"):e.domain==="mcp"?Yn(t):e.domain==="extensions"?Jn(t):Ya(t,o)}i(Ja,"validateActiveFile");function Os(e,o){if(!_s(e.path))return{domain:e.domain,kind:e.kind,path:e.path,status:"missing"};if(e.kind==="template")return{domain:e.domain,kind:e.kind,path:e.path,status:"existing"};try{return Ja(e,o),{domain:e.domain,kind:e.kind,path:e.path,status:"existing"}}catch(n){return{domain:e.domain,kind:e.kind,path:e.path,status:"invalid",diagnostic:n instanceof Error?n.message:`${e.domain} config is invalid.`}}}i(Os,"existingFileResult");function Za(e){return e instanceof Error&&"code"in e&&e.code==="EEXIST"}i(Za,"isAlreadyExists");function Qa(e,o){Ka(ze.dirname(e.path),{recursive:!0,mode:448});try{return Ga(e.path,e.content,{encoding:"utf8",flag:"wx",mode:384}),{domain:e.domain,kind:e.kind,path:e.path,status:"created"}}catch(n){if(Za(n))return Os(e,o);throw n}}i(Qa,"createIfMissing");function el(e){let o=nt(e,"core");if(_s(o))try{let n=yo(JSON.parse(Ws(o,"utf8")),"Core config"),t=is(e);t.mcp.action==="create"&&Yn({version:1,servers:n.mcpServers}),t.extensions.action==="create"&&Jn({version:1,paths:n.extensions})}catch(n){return`Legacy integration configuration is invalid: ${n instanceof Error?n.message:"Legacy integration config is invalid."}`}}i(el,"legacyIntegrationDiagnostic");function Ns(e={}){let o=ze.resolve(e.configHome??ue()),n=Va(o),t=n.map(a=>Os(a,e.validateA2A));if(t.some(a=>a.status==="invalid"))return{configHome:o,files:t};let r=el(o);if(r){let a=nt(o,"core");return t=t.map(l=>l.path===a?{...l,status:"invalid",diagnostic:r}:l),{configHome:o,files:t}}return as({configHome:o}),{configHome:o,files:n.map(a=>Qa(a,e.validateA2A))}}i(Ns,"initializeSetupConfiguration");import $e from"node:path";var Ds=[{id:"interrupt",name:"Interrupt",description:"Interrupt the current streaming response",defaultBindings:[{key:"c",ctrl:!0}],context:"global",priority:200,category:"global",configurable:!1},{id:"showHelp",name:"Toggle Help",description:"Show or hide shortcut help when the input is empty",defaultBindings:[{key:"?"}],context:"global",priority:150,category:"global",configurable:!0},{id:"toggleThinking",name:"Cycle Reasoning Effort",description:"Cycle reasoning effort for the active model: off, low \u2026 max, auto",defaultBindings:[{key:"t",ctrl:!0}],context:"global",priority:150,category:"mode",configurable:!0},{id:"toggleTranscriptMode",name:"Toggle Transcript Mode",description:"Toggle transcript mode on or off",defaultBindings:[{key:"o",ctrl:!0}],context:"global",priority:150,category:"mode",configurable:!0},{id:"openTranscriptSearch",name:"Search Transcript",description:"Open transcript search",defaultBindings:[{key:"f",ctrl:!0}],context:"global",priority:150,category:"navigation",configurable:!0},{id:"togglePermissionMode",name:"Cycle Permissions",description:"Cycle permission mode: plan, accept-edits, auto-in-project",defaultBindings:[{key:"tab",shift:!0}],context:"global",priority:150,category:"mode",configurable:!0},{id:"toggleAgentMode",name:"Cycle Agent Mode",description:"Cycle agent mode: AMA, SA",defaultBindings:[{key:"m",meta:!0}],context:"global",priority:150,category:"mode",configurable:!0},{id:"submitInput",name:"Submit Input",description:"Submit the current input",defaultBindings:[{key:"enter"}],context:"input",priority:50,category:"global",configurable:!1},{id:"acceptCompletion",name:"Accept Completion",description:"Accept the current autocomplete suggestion",defaultBindings:[{key:"tab"}],context:"input",priority:60,category:"editing",configurable:!0},{id:"cancelInput",name:"Cancel Input",description:"Cancel or clear the current input",defaultBindings:[{key:"escape"}],context:"input",priority:70,category:"editing",configurable:!0},{id:"newline",name:"Insert Newline",description:"Insert a newline in the current input",defaultBindings:[{key:"enter",shift:!0},{key:"j",ctrl:!0}],context:"input",priority:40,category:"editing",configurable:!0},{id:"historyUp",name:"History Up",description:"Browse previous input history",defaultBindings:[{key:"up"}],context:"input",priority:30,category:"navigation",configurable:!0},{id:"historyDown",name:"History Down",description:"Browse next input history",defaultBindings:[{key:"down"}],context:"input",priority:30,category:"navigation",configurable:!0},{id:"moveLeft",name:"Move Left",description:"Move the cursor left",defaultBindings:[{key:"left"}],context:"input",priority:20,category:"navigation",configurable:!1},{id:"moveRight",name:"Move Right",description:"Move the cursor right",defaultBindings:[{key:"right"}],context:"input",priority:20,category:"navigation",configurable:!1},{id:"moveToStart",name:"Move To Start",description:"Move the cursor to the start of the line",defaultBindings:[{key:"a",ctrl:!0}],context:"input",priority:25,category:"navigation",configurable:!0},{id:"moveToEnd",name:"Move To End",description:"Move the cursor to the end of the line",defaultBindings:[{key:"e",ctrl:!0}],context:"input",priority:25,category:"navigation",configurable:!0},{id:"killLineRight",name:"Delete To End",description:"Delete from the cursor to the end of the current line",defaultBindings:[{key:"k",ctrl:!0}],context:"input",priority:25,category:"editing",configurable:!0},{id:"killLineLeft",name:"Delete To Start",description:"Delete from the start of the line to the cursor",defaultBindings:[{key:"u",ctrl:!0}],context:"input",priority:25,category:"editing",configurable:!0},{id:"deleteWordLeft",name:"Delete Word Left",description:"Delete the word before the cursor",defaultBindings:[{key:"w",ctrl:!0},{key:"backspace",meta:!0}],context:"input",priority:25,category:"editing",configurable:!0},{id:"moveLineUp",name:"Move Line Up",description:"Move to the previous visual line in multiline input",defaultBindings:[{key:"up",ctrl:!0}],context:"input",priority:20,category:"navigation",configurable:!0},{id:"moveLineDown",name:"Move Line Down",description:"Move to the next visual line in multiline input",defaultBindings:[{key:"down",ctrl:!0}],context:"input",priority:20,category:"navigation",configurable:!0},{id:"backspace",name:"Backspace",description:"Delete the previous character",defaultBindings:[{key:"backspace"}],context:"input",priority:10,category:"editing",configurable:!1},{id:"delete",name:"Delete",description:"Delete the next character",defaultBindings:[{key:"delete"}],context:"input",priority:10,category:"editing",configurable:!1}];function ol(e){let o=[];e.ctrl&&o.push("Ctrl"),e.meta&&o.push("Alt"),e.shift&&o.push("Shift");let n={tab:"Tab",escape:"Esc",enter:"Enter",backspace:"Backspace"};return o.push(n[e.key]??(e.key.length===1?e.key.toUpperCase():e.key)),o.join("+")}i(ol,"formatBinding");function tt(e){let n=Ds.find(t=>t.id===e)?.defaultBindings[0];return n?ol(n):"<unavailable>"}i(tt,"shortcut");function nl(){return Object.entries(co).filter(([,e])=>e.capabilityProfile.transport==="cli-bridge").map(([e])=>e).sort()}i(nl,"defaultCliBridges");function rt(e={}){let o=$e.resolve(e.configHome??ue()),n=e.catalog??qe(),t=e.cliBridges??nl(),r=n.map(a=>` ${a.name.padEnd(18)} ${a.apiKeyEnv} (default model: ${a.defaultModel})`);return["KodaX setup guide","","Configuration files (existing files are never overwritten by setup):",` Core: ${$e.join(o,"config.json")}`,` Annotated template: ${$e.join(o,"config.example.jsonc")}`,` MCP: ${$e.join(o,"integrations","mcp.json")}`,` Extensions: ${$e.join(o,"integrations","extensions.json")}`,` A2A: ${$e.join(o,"integrations","a2a.json")}`,` Integration templates: ${$e.join(o,"integrations","*.example.jsonc")}`," Existing active files are validated first. If one is invalid, setup reports"," it and stops without creating or overwriting any configuration file."," The annotated core template includes `sandbox.envPass` for exact command-target"," environment passthrough; setup never stores an environment-variable value.","","Built-in API providers and credential environment variables:",...r,...t.length>0?[` CLI bridges: ${t.join(", ")} (authenticate with the provider CLI; no KodaX API-key variable)`]:[],"","Set the variable named for your provider; keep the credential out of config.json:"," Custom providers: `apiKeyEnv` is the environment-variable name stored in config.json,"," never the API key value."," Put the provider's actual API key in the value of that exact environment variable."," KodaX does not set this environment variable for you."," Windows PowerShell (persistent user variable):",' [Environment]::SetEnvironmentVariable("OPENAI_API_KEY", "<your-key>", "User")'," macOS/Linux shell profile:",' export OPENAI_API_KEY="<your-key>"'," Obtain the key from the provider console, then close and restart the terminal."," Run `kodax doctor` to verify local configuration without sending an LLM request.","","Setup commands:"," kodax setup Initialize missing files and choose a built-in or custom provider"," kodax setup --custom Configure only a custom OpenAI/Anthropic-compatible provider"," kodax setup --help Show this guide without changing files","","Sandbox containment (optional; permission decisions still work when it is unavailable):"," `kodax setup`, first-run setup, and `/setup` check sandbox readiness once."," Windows: setup can launch the one-time UAC provisioning flow; the terminal itself"," does not need to run as Administrator. Declining UAC is non-fatal."," macOS: ASRT uses Seatbelt/sandbox-exec; install ripgrep with `brew install ripgrep`."," Linux: ASRT uses bubblewrap; install bubblewrap, socat, and ripgrep with apt,"," dnf, or pacman. KodaX never invokes sudo or a package manager automatically."," Ordinary startup and tool calls do not repeat setup reminders or trigger UAC."," Inspect/activate explicitly: `kodax sandbox doctor` / `kodax sandbox setup`."," Model-issued commands filter credential-shaped variables by default. Add exact names"," such as GH_TOKEN to user-level `sandbox.envPass` only when command access is intended."," The default list is empty; NODE_OPTIONS and BASH_ENV remain blocked."," Restart KodaX (and any persistent daemon) after changing the list or host variables."," SDK: `@kodax-ai/kodax/sandbox` exposes doctor, activation, capability metadata,"," and policy-controlled command execution independent of Auto[LLM].","","CLI basics:"," kodax Enter the interactive REPL",' kodax -p "task" Run one task and exit'," kodax -r Search and resume a saved session"," kodax -c Continue the most recent non-empty session","","Inside the REPL:"," /model [provider[/model]] List or switch provider/model"," /mode [plan|accept-edits|auto] Switch permission mode"," /effort [off|auto|low|medium|high|xhigh|max] Set reasoning depth"," /agent-mode [ama|sa|toggle] Switch AMA/SA execution"," /setup --help Show this guide","","Default shortcuts:",` ${tt("toggleThinking")} Cycle reasoning effort`,` ${tt("togglePermissionMode")} Cycle permission mode`,` ${tt("toggleAgentMode")} Cycle AMA/SA`," Tab Accept completion"," Esc Cancel or clear input"].join(`
|
|
5
5
|
`)}i(rt,"renderSetupGuide");import*as Us from"node:readline";import st from"chalk";async function js(e={}){let o=e.catalog??qe(),n=Cs({...e.configPath?{configPath:e.configPath}:{},catalog:o});if(n.status==="invalid-config")throw new Ge(n.configPath,n.reason);if(o.length===0)throw new Error("No built-in API providers are available for setup.");let t=e.interaction===void 0,r=e.interaction??il({input:e.input??process.stdin,output:e.output??process.stdout});try{let a=e.customOnly?"custom":await r.choose("Choose a provider. KodaX will save metadata only and will never ask for an API key.",[...o.map(u=>({value:`builtin:${u.name}`,label:`${u.name} \u2014 ${u.defaultModel} (set ${u.apiKeyEnv})`})),{value:"custom",label:"Custom OpenAI/Anthropic-compatible provider"},{value:"cancel",label:"Cancel"}]);if(!a||a==="cancel")return{status:"cancelled"};let l=a==="custom"?await rl(r):await tl(r,o,a.slice(8));if(!l)return{status:"cancelled"};let c=sl(l,o);return await r.confirm(`Save ${c}? config.json will store the environment-variable name only. You must set that variable to the provider's API key after setup. No credential value will be written.`)?{status:"configured",selection:Is({configPath:n.configPath,expectedRevision:n.configRevision,catalog:o,choice:l})}:{status:"cancelled"}}finally{t&&r.close?.()}}i(js,"runProviderSetupWizard");async function tl(e,o,n){let t=o.find(l=>l.name===n);if(!t)throw new Error(`Unknown setup provider: ${n}`);let r=[...new Set(t.models)],a=await e.choose(`Choose a model for ${t.name}.`,r.map(l=>({value:l,label:l===t.defaultModel?`${l} (default)`:l})));return a?{kind:"builtin",provider:t.name,model:a}:void 0}i(tl,"collectBuiltinChoice");async function rl(e){let o=await Qo(e,"Custom provider name (a unique local alias used by /model and config.json)");if(!o)return;let n=await e.choose("Protocol family (check the provider API documentation for OpenAI or Anthropic compatibility)",[{value:"openai",label:"OpenAI-compatible"},{value:"anthropic",label:"Anthropic-compatible"}]);if(n!=="openai"&&n!=="anthropic")return;let t=await Qo(e,"API Base URL from the provider documentation, for example https://example.com/v1");if(!t)return;let r=await Qo(e,["Environment-variable name only (for example MY_PROVIDER_API_KEY).","Do not paste an API key here.","config.json stores this name only.","After setup, set this environment variable's value to this provider's API key."].join(" "));if(!r)return;let a=await Qo(e,"Model identifier from the provider documentation, for example provider/model-name");if(a)return{kind:"custom",provider:ot({name:o,protocol:n,baseUrl:t,apiKeyEnv:r,model:a})}}i(rl,"collectCustomChoice");async function Qo(e,o){let t=(await e.text(o))?.trim();return t||void 0}i(Qo,"requiredText");function sl(e,o){if(e.kind==="custom"){let t=e.provider;return`provider=${t.name}, protocol=${t.protocol}, baseUrl=${t.baseUrl}, model=${t.model}, apiKeyEnv=${t.apiKeyEnv}`}let n=o.find(t=>t.name===e.provider);return`provider=${e.provider}, model=${e.model}, apiKeyEnv=${n?.apiKeyEnv??"<unknown>"}`}i(sl,"summarizeChoice");function il(e){let o=Us.createInterface({input:e.input,output:e.output}),n=!1;o.on("close",()=>{n=!0}),o.on("SIGINT",()=>o.close());let t=i(r=>new Promise((a,l)=>{let c=!1,d=i(f=>{c||(c=!0,o.removeListener("close",u),a(f))},"finish"),u=i(()=>d(void 0),"onClose");if(n){d(void 0);return}o.once("close",u);try{o.question(r,f=>d(f))}catch(f){o.removeListener("close",u),n?d(void 0):l(f)}}),"question");return{async choose(r,a){for(e.output.write(`
|
|
@@ -652,4 +652,4 @@ Available Skills:
|
|
|
652
652
|
[Skill "${t}" is not user-invocable]`)),!1;console.log(s.cyan(`
|
|
653
653
|
[Invoking skill: ${t}]`)),a.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:{},executeDynamicContext:o.skillDynamicContext?.execute,disableDynamicContext:o.skillDynamicContext?.disable},d=await _r(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(a){return console.log(s.red(`
|
|
654
654
|
[Error invoking skill: ${a instanceof Error?a.message:String(a)}]`)),!1}}i(lr,"executeSkillCommand");var Mn=class{static{i(this,"SkillCompleter")}gitRoot;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)}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(){try{let o=ve(this.gitRoot);return o.size===0&&await De(this.gitRoot),o.listUserInvocable()}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 of}from"node:child_process";import*as to from"node:path";import{promisify as nf}from"node:util";var xa=nf(of);function tf(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}i(tf,"pathFromPorcelainLine");async function Aa(e,o=10){try{let[{stdout:n},{stdout:t}]=await Promise.all([xa("git rev-parse --show-toplevel",{cwd:e,windowsHide:!0}),xa("git status --porcelain=v1 -uall",{cwd:e,windowsHide:!0})]),r=n.trim(),a=[],l=new Set;for(let c of t.split(`
|
|
655
|
-
`)){if(!c.trim())continue;let d=tf(c);if(!d)continue;let u=to.resolve(r,d),f=to.relative(e,u).split(to.sep).join("/");if(!(!f||f.startsWith("..")||l.has(f))&&(l.add(f),a.push(f),a.length>=o))break}return a}catch{return[]}}i(Aa,"getRecentWorkingSetFiles");function ro(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}i(ro,"findCommandSlashIndex");var ur=class{static{i(this,"FileCompleter")}cwdSource;cache=new Map;cacheTimeout=5e3;recentCache=new Map;recentFilesProvider;constructor(o,n=Aa){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 a=t.slice(r+1),l=[],c=this.resolveCwd(),d=a.lastIndexOf("/"),u=d===-1?c:Wo.join(c,a.slice(0,d)),f=d===-1?a:a.slice(d+1);try{let b=(await this.readdir(u)).filter(S=>S.toLowerCase().startsWith(f.toLowerCase()));for(let S of b){let C=Wo.join(u,S),A=await this.isDirectory(C),v=d===-1?S:a.slice(0,d+1)+S;l.push({text:"@"+v+(A?"/":""),display:S+(A?"/":""),description:A?"directory":"file",type:"file"})}}catch{}if(d===-1){let m=await this.getRecentFiles(c),b=new Set(l.map(A=>A.text)),S=f.toLowerCase(),C=[];for(let A of m){if(f&&!Wo.basename(A).toLowerCase().startsWith(S))continue;let v="@"+A;b.has(v)||(b.add(v),C.push({text:v,display:A,description:"recent",type:"file"}))}l.unshift(...C)}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=>{_n.readdir(o,(a,l)=>{a?r([]):(this.cache.set(o,{entries:l,expiresAt:Date.now()+this.cacheTimeout}),r(l))})}))}async isDirectory(o){return new Promise(n=>{_n.stat(o,(t,r)=>{n(!t&&r.isDirectory())})})}},fr=class{static{i(this,"CommandCompleter")}commands;constructor(){this.commands=new Map,this.loadCommands()}loadCommands(){for(let n of _o().getAll())n.userInvocable!==!1&&this.commands.set(n.name,{description:n.description,aliases:n.aliases??[]});let o=ne();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=ro(t);return r===-1?!1:!t.slice(r).includes(" ")}async getCompletions(o,n){let t=o.slice(0,n),r=ro(t);if(r===-1)return[];this.commands.clear(),this.loadCommands();let a=t.slice(r+1).toLowerCase(),l=[];for(let[c,d]of this.commands){this.fuzzyMatch(a,c)&&l.push({text:"/"+c,display:"/"+c,description:d.description,type:"command"});for(let u of d.aliases)u!==c&&this.fuzzyMatch(a,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(),a=0;for(let l=0;l<r.length&&a<t.length;l++)r[l]===t[a]&&a++;return a===t.length}};function Jy(e){let o=new ur(e),n=new Mn,t=new fr;return async r=>{let a=r.includes("@"),l=r.includes("/");if(!a&&!l)return[[],r];let c=[];if(l){let u=await rf(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(a&&o.canComplete(r,r.length)){let u=await o.getCompletions(r,r.length);c.push(...u)}return[c.map(u=>sf(r,u)),r]}}i(Jy,"createCompleter");async function rf(e,o){let{ArgumentCompleter:n}=await import("./argument-completer-N7ORRJBS.js"),t=new n;return t.canComplete(e,o)?t.getCompletions(e,o):[]}i(rf,"getArgumentCompletions");function sf(e,o){if(o.type!=="argument")return o.text;let n=ro(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}`}i(sf,"formatReadlineCompletion");import{existsSync as Wn,readdirSync as Ia,readFileSync as Ta}from"node:fs";import{join as On}from"node:path";var af=[{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"}],so=[{name:"none",description:"Disable reasoning when the model supports it",type:"enum"},{name:"auto",description:"Clear the explicit effort override",type:"enum"},{name:"low",description:"Use low reasoning effort",type:"enum"},{name:"medium",description:"Use medium reasoning effort",type:"enum"},{name:"high",description:"Use high reasoning effort",type:"enum"},{name:"xhigh",description:"Use extra-high reasoning effort",type:"enum"},{name:"max",description:"Use maximum reasoning effort",type:"enum"}];function lf(e){if(e&&e.includes("/")){let o=e.indexOf("/"),n=e.slice(0,o),t=e.slice(o+1);if(Oe(n))try{return Be(n).filter(a=>!t||a.toLowerCase().includes(t.toLowerCase())).map(a=>({name:`${n}/${a}`,description:a,type:"enum"}))}catch{}return[]}return Ne().map(o=>({name:o,description:`Switch to ${o} provider`,type:"enum"}))}i(lf,"getModelArgs");var mr=[{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"}],pr=[{name:"all",description:"Delete ALL sessions",type:"enum"}],cf=[{name:"status",description:"Show MCP server status",type:"enum"},{name:"refresh",description:"Refresh MCP server catalogs",type:"enum"}],df=[{name:"status",description:"Show child-task fallback order",type:"enum"},{name:"off",description:"Disable child-task fallback providers",type:"enum"}],uf=[{name:"llm",description:"Use LLM classifier for auto mode",type:"enum"},{name:"rules",description:"Use rules-only auto mode",type:"enum"}],Ra=[{name:"ama",description:"Use AMA agent mode",type:"enum"},{name:"sa",description:"Use single-agent mode",type:"enum"},{name:"toggle",description:"Cycle to the next agent mode",type:"enum"}],Ea=[{name:"on",description:"Enable logging",type:"enum"},{name:"off",description:"Disable logging",type:"enum"}],ff=[{name:"list",description:"List project memory files",type:"enum"},{name:"pending",description:"List pending memory proposals",type:"enum"},{name:"show",description:"Preview a memory proposal",type:"enum"},{name:"approve",description:"Approve a memory proposal",type:"enum"},{name:"reject",description:"Reject a memory proposal",type:"enum"},{name:"curate",description:"Report memory governance findings",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"}],mf=[{name:"list",description:"List learned capabilities",type:"enum"},{name:"show",description:"Inspect one exact learned capability",type:"enum"},{name:"review",description:"Start or restart bounded canary review",type:"enum"},{name:"trust",description:"Explicitly trust a reviewed revision",type:"enum"},{name:"reject",description:"Reject a learned capability",type:"enum"},{name:"disable",description:"Disable an active learned capability",type:"enum"},{name:"rollback",description:"Restore the previous good revision",type:"enum"},{name:"promote",description:"Promote an exact revision to the user Skill catalog",type:"enum"},{name:"help",description:"Show Learning Center help",type:"enum"}];function pf(e){let[o=""]=e,n=o.toLowerCase(),t=e.length===1&&e[0]===""?0:e.length;return t<=1?mf:n==="help"&&t<=2?[{name:"promote",description:"Show dedicated promotion help",type:"enum"}]:n!=="promote"?[]:t<=2?[{name:"--help",description:"Show dedicated promotion help",type:"enum"}]:t<=3?[{name:"--scope",description:"Choose the formal user Skill scope",type:"enum"}]:e[2]?.toLowerCase()==="--scope"&&t<=4?[{name:"user",description:"Promote to the formal user Skill catalog",type:"enum"}]:[]}i(pf,"getLearnArgs");var gf=[{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"}],wf=[{name:"show",description:"Show a captured paste by id",type:"enum"},{name:"list",description:"List captured pastes",type:"enum"}],hf=[{name:"--lean",description:"Add a minimal-diff/YAGNI review pass",type:"enum"},{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"},{name:"help",description:"Show review help",type:"enum"}],yf=[{name:"init",description:"Create AGENTS.md in the target project if absent",type:"enum"},{name:"lean",description:"Initialize or LLM-review AGENTS.md for Lean Mode guidance",type:"enum"},{name:"help",description:"Show agents help",type:"enum"}],vf=[{name:"status",description:"Inspect the current repo-intelligence runtime state",type:"enum"},{name:"mode",description:"Switch repo-intelligence runtime mode",type:"enum"},{name:"trace",description:"Toggle repo-intelligence trace output",type:"enum"}],kf=[{name:"auto",description:"Let KodaX pick the best repo-intelligence engine",type:"enum"},{name:"full",description:"Prefer the full repo-intelligence engine",type:"enum"},{name:"light",description:"Use the light repo-intelligence engine",type:"enum"},{name:"off",description:"Disable repo-intelligence injection",type:"enum"}],bf=[{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"}],Sf=[{name:"status",description:"Deprecated alias for /repo-intel status",type:"enum"}],$f=[{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"}],xf=new Set(["show","pause","resume","stop","delete","rerun","save","rename","revise"]),Af=new Set(["show","delete","rerun","save","rename","revise"]),Rf=[{name:"--all",description:"Show all persisted workflow runs",type:"enum"},{name:"--limit",description:"Show at most N persisted workflow runs",type:"enum"}],Ef=[{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"}],Cf=[{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"}],If=[".workflow.json",".ts",".mjs",".js"];function Tf(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}}i(Tf,"workflowRunMatchesSubcommand");function Nn(e){return/^[a-zA-Z0-9._-]{1,120}$/.test(e)&&!e.startsWith(".")&&!e.includes("..")}i(Nn,"isWorkflowRunEntryName");function Pf(e,o){let n=On(e,"workflow-metadata.json");if(Wn(n))try{let r=JSON.parse(Ta(n,"utf8"));if(typeof r=="object"&&r!==null){let a=r.displayName;if(typeof a=="string"&&Nn(a.trim()))return a.trim()}}catch{}let t=o.displayName;return typeof t=="string"&&Nn(t.trim())?t.trim():void 0}i(Pf,"readWorkflowRunDisplayName");function Lf(){let e=Re(process.cwd()).key,o=_("workflow-runs",e);if(!Wn(o))return[];let n=[];for(let t of Ia(o)){if(!Nn(t))continue;let r=On(o,t,"run.json");if(Wn(r))try{let a=JSON.parse(Ta(r,"utf8")),l=typeof a.workflow=="string"?a.workflow:"?",c=typeof a.status=="string"?a.status:"?",d=typeof a.endedAt=="number"?a.endedAt:0;n.push({arg:{name:t,description:`${l} - ${c}`,type:"string"},endedAt:d});let u=Pf(On(o,t),a);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)}i(Lf,"getPersistedWorkflowRunIdArgs");function Dn(e){let o=Fe().list().filter(r=>Tf(e,r.status)).map(r=>({name:r.runId,description:`${r.workflow} - ${r.status}`,type:"string"})),n=Af.has(e)?Lf():[],t=new Set;return[...o,...n].filter(r=>t.has(r.name)?!1:(t.add(r.name),!0))}i(Dn,"getWorkflowRunIdArgs");function Mf(e){for(let o of If)if(e.endsWith(o)){let n=e.slice(0,-o.length);return Nn(n)?n:void 0}}i(Mf,"savedWorkflowNameFromFile");function Oo(e={}){let o=[{path:_("workflows"),source:"personal"},{path:On(process.cwd(),".kodax","workflows"),source:"project"}],n=new Map;for(let t of o)if(Wn(t.path))try{for(let r of Ia(t.path)){if(e.generatedOnly===!0&&!r.endsWith(".workflow.json"))continue;let a=Mf(r);a&&n.set(a,{name:a,description:`${t.source} saved workflow`,type:"enum"})}}catch{}return[...n.values()].sort((t,r)=>t.name.localeCompare(r.name))}i(Oo,"getSavedWorkflowNameArgs");function _f(){let e=new Map;for(let o of Dn("rerun"))e.set(o.name,{...o,description:`recent run: ${o.description}`,type:"string"});for(let o of Oo()){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()]}i(_f,"getWorkflowRerunArgs");function gr(e){let o=new Map;for(let n of Dn(e))o.set(n.name,{...n,description:`workflow run: ${n.description}`,type:"string"});for(let n of Oo({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()]}i(gr,"getWorkflowRunOrSavedNameArgs");function Ca(e){let o=new Set(e.slice(1).filter(n=>n.startsWith("--")));return o.has("--saved")?Oo({generatedOnly:!0}):o.has("--run")?Dn("delete"):gr("delete")}i(Ca,"getWorkflowDeleteTargetArgs");function Wf(e){let[o=""]=e,n=o.toLowerCase(),t=e.length===1&&e[0]===""?0:e.length;if(t<=1)return[...$f,...qo().map(r=>({name:r.name,description:r.description,type:"enum"})),...Oo()];if(n==="rerun"&&t<=2)return _f();if(n==="rename"&&t<=2)return gr("rename");if(n==="delete"&&t<=2)return[...Cf,...Ca(e)];if(n==="delete"&&t<=3&&e.slice(1).some(r=>r.startsWith("--")))return Ca(e);if(n==="revise"){if(t<=2)return[{name:"--replace",description:"Replace a saved workflow after confirmation",type:"enum"},...gr("revise")];if(e[1]==="--replace"&&t<=3)return Oo()}return xf.has(n)&&t<=2?Dn(n):n==="runs"&&t<=2?Rf:n==="prune"&&t<=2?Ef:[]}i(Wf,"getWorkflowArgs");function Of(e){let[o=""]=e,n=o.toLowerCase(),t=e.length===1&&e[0]===""?0:e.length;return t<=1?vf:t>2?[]:n==="mode"?kf:n==="trace"?bf:[]}i(Of,"getRepoIntelArgs");var Nf=new Map([["mode",af],["thinking",so],["think",so],["t",so],["reasoning",so],["reason",so],["effort",so],["status",mr],["info",mr],["ctx",mr],["mcp",cf],["fallback",df],["auto-engine",uf],["agent-mode",Ra],["am",Ra],["verifier-log",Ea],["stall-log",Ea],["memory",ff],["goal",gf],["paste",wf],["review",hf],["agents",yf],["delete",pr],["rm",pr],["del",pr]]),Df=new Set(["model","m","provider"]),Uf=new Set(["repo-intel"]),jf=new Set(["repointel","ri"]),Ff=new Set(["workflow"]),Hf=new Set(["learn"]);function wr(e,o,n=[]){let t=e.toLowerCase();return Df.has(t)?lf(o):Uf.has(t)?Of(n):jf.has(t)?n.length<=1?Sf:[]:Ff.has(t)?Wf(n):Hf.has(t)?pf(n):Nf.get(t)??[]}i(wr,"getCommandArguments");var hr=class{static{i(this,"ArgumentCompleter")}canComplete(o,n){let t=o.slice(0,n),r=ro(t);if(r===-1)return!1;let a=t.slice(r),l=a.split(/\s+/);if(l.length>=2&&l[0]!=="")return!0;let c=a.slice(1).toLowerCase();return wr(c).length>0}async getCompletions(o,n){let t=o.slice(0,n),r=ro(t);if(r===-1)return[];let a=t.slice(r),l=a.indexOf(" "),c=(l===-1?a.slice(1):a.slice(1,l)).toLowerCase(),d=l===-1?"":a.slice(l+1),u=d?d.split(/\s+/):[""],f=u.length-1,m=(u[f]??"").toLowerCase(),b=wr(c,m,u);if(!b||b.length===0)return[];let S=new Set(u.slice(0,-1).map(A=>A.toLowerCase()));return b.filter(A=>!S.has(A.name.toLowerCase())).filter(A=>!m||A.name.includes("/")?!0:A.name.toLowerCase().includes(m)).map(A=>({text:A.name,display:A.name,description:A.description,type:"argument"})).sort((A,v)=>{if(!m)return 0;let x=A.display.toLowerCase().startsWith(m),M=v.display.toLowerCase().startsWith(m);return x&&!M?-1:!x&&M?1:A.display.length-v.display.length})}};function dv(){return new hr}i(dv,"createArgumentCompleter");export{pt as a,B as b,_p as c,si as d,Wp as e,Jo as f,_a as g,zf as h,Wa as i,Xf as j,Zo as k,ks as l,go as m,ho as n,Ge as o,qe as p,Cs as q,Is as r,Ts as s,Ns as t,Ds as u,rt as v,js as w,pl as x,hl as y,np as z,hp as A,yl as B,dt as C,yp as D,vp as E,Qs as F,Rp as G,ri as H,te as I,li as J,ci as K,Fp as L,_l as M,Xl as N,Hp as O,rn as P,wt as Q,Bp as R,vi as S,Kp as T,Gp as U,qp as V,hg as W,yg as X,vg as Y,Ci as Z,bt as _,Ii as $,Re as aa,Ag as ba,xo as ca,Et as da,Ie as ea,pd as fa,gd as ga,Xi as ha,Jg as ia,Zg as ja,Cd as ka,Xw as la,Vw as ma,Yw as na,gh as oa,wh as pa,hh as qa,yh as ra,vh as sa,aa as ta,Ah as ua,Rh as va,ca as wa,Eh as xa,qh as ya,da as za,_o as Aa,Oy as Ba,Ny as Ca,Mn as Da,hr as Ea,dv as Fa,ro as Ga,ur as Ha,fr as Ia,Jy as Ja};
|
|
655
|
+
`)){if(!c.trim())continue;let d=tf(c);if(!d)continue;let u=to.resolve(r,d),f=to.relative(e,u).split(to.sep).join("/");if(!(!f||f.startsWith("..")||l.has(f))&&(l.add(f),a.push(f),a.length>=o))break}return a}catch{return[]}}i(Aa,"getRecentWorkingSetFiles");function ro(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}i(ro,"findCommandSlashIndex");var ur=class{static{i(this,"FileCompleter")}cwdSource;cache=new Map;cacheTimeout=5e3;recentCache=new Map;recentFilesProvider;constructor(o,n=Aa){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 a=t.slice(r+1),l=[],c=this.resolveCwd(),d=a.lastIndexOf("/"),u=d===-1?c:Wo.join(c,a.slice(0,d)),f=d===-1?a:a.slice(d+1);try{let b=(await this.readdir(u)).filter(S=>S.toLowerCase().startsWith(f.toLowerCase()));for(let S of b){let C=Wo.join(u,S),A=await this.isDirectory(C),v=d===-1?S:a.slice(0,d+1)+S;l.push({text:"@"+v+(A?"/":""),display:S+(A?"/":""),description:A?"directory":"file",type:"file"})}}catch{}if(d===-1){let m=await this.getRecentFiles(c),b=new Set(l.map(A=>A.text)),S=f.toLowerCase(),C=[];for(let A of m){if(f&&!Wo.basename(A).toLowerCase().startsWith(S))continue;let v="@"+A;b.has(v)||(b.add(v),C.push({text:v,display:A,description:"recent",type:"file"}))}l.unshift(...C)}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=>{_n.readdir(o,(a,l)=>{a?r([]):(this.cache.set(o,{entries:l,expiresAt:Date.now()+this.cacheTimeout}),r(l))})}))}async isDirectory(o){return new Promise(n=>{_n.stat(o,(t,r)=>{n(!t&&r.isDirectory())})})}},fr=class{static{i(this,"CommandCompleter")}commands;constructor(){this.commands=new Map,this.loadCommands()}loadCommands(){for(let n of _o().getAll())n.userInvocable!==!1&&this.commands.set(n.name,{description:n.description,aliases:n.aliases??[]});let o=ne();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=ro(t);return r===-1?!1:!t.slice(r).includes(" ")}async getCompletions(o,n){let t=o.slice(0,n),r=ro(t);if(r===-1)return[];this.commands.clear(),this.loadCommands();let a=t.slice(r+1).toLowerCase(),l=[];for(let[c,d]of this.commands){this.fuzzyMatch(a,c)&&l.push({text:"/"+c,display:"/"+c,description:d.description,type:"command"});for(let u of d.aliases)u!==c&&this.fuzzyMatch(a,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(),a=0;for(let l=0;l<r.length&&a<t.length;l++)r[l]===t[a]&&a++;return a===t.length}};function Jy(e){let o=new ur(e),n=new Mn,t=new fr;return async r=>{let a=r.includes("@"),l=r.includes("/");if(!a&&!l)return[[],r];let c=[];if(l){let u=await rf(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(a&&o.canComplete(r,r.length)){let u=await o.getCompletions(r,r.length);c.push(...u)}return[c.map(u=>sf(r,u)),r]}}i(Jy,"createCompleter");async function rf(e,o){let{ArgumentCompleter:n}=await import("./argument-completer-SQHG2LYE.js"),t=new n;return t.canComplete(e,o)?t.getCompletions(e,o):[]}i(rf,"getArgumentCompletions");function sf(e,o){if(o.type!=="argument")return o.text;let n=ro(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}`}i(sf,"formatReadlineCompletion");import{existsSync as Wn,readdirSync as Ia,readFileSync as Ta}from"node:fs";import{join as On}from"node:path";var af=[{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"}],so=[{name:"none",description:"Disable reasoning when the model supports it",type:"enum"},{name:"auto",description:"Clear the explicit effort override",type:"enum"},{name:"low",description:"Use low reasoning effort",type:"enum"},{name:"medium",description:"Use medium reasoning effort",type:"enum"},{name:"high",description:"Use high reasoning effort",type:"enum"},{name:"xhigh",description:"Use extra-high reasoning effort",type:"enum"},{name:"max",description:"Use maximum reasoning effort",type:"enum"}];function lf(e){if(e&&e.includes("/")){let o=e.indexOf("/"),n=e.slice(0,o),t=e.slice(o+1);if(Oe(n))try{return Be(n).filter(a=>!t||a.toLowerCase().includes(t.toLowerCase())).map(a=>({name:`${n}/${a}`,description:a,type:"enum"}))}catch{}return[]}return Ne().map(o=>({name:o,description:`Switch to ${o} provider`,type:"enum"}))}i(lf,"getModelArgs");var mr=[{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"}],pr=[{name:"all",description:"Delete ALL sessions",type:"enum"}],cf=[{name:"status",description:"Show MCP server status",type:"enum"},{name:"refresh",description:"Refresh MCP server catalogs",type:"enum"}],df=[{name:"status",description:"Show child-task fallback order",type:"enum"},{name:"off",description:"Disable child-task fallback providers",type:"enum"}],uf=[{name:"llm",description:"Use LLM classifier for auto mode",type:"enum"},{name:"rules",description:"Use rules-only auto mode",type:"enum"}],Ra=[{name:"ama",description:"Use AMA agent mode",type:"enum"},{name:"sa",description:"Use single-agent mode",type:"enum"},{name:"toggle",description:"Cycle to the next agent mode",type:"enum"}],Ea=[{name:"on",description:"Enable logging",type:"enum"},{name:"off",description:"Disable logging",type:"enum"}],ff=[{name:"list",description:"List project memory files",type:"enum"},{name:"pending",description:"List pending memory proposals",type:"enum"},{name:"show",description:"Preview a memory proposal",type:"enum"},{name:"approve",description:"Approve a memory proposal",type:"enum"},{name:"reject",description:"Reject a memory proposal",type:"enum"},{name:"curate",description:"Report memory governance findings",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"}],mf=[{name:"list",description:"List learned capabilities",type:"enum"},{name:"show",description:"Inspect one exact learned capability",type:"enum"},{name:"review",description:"Start or restart bounded canary review",type:"enum"},{name:"trust",description:"Explicitly trust a reviewed revision",type:"enum"},{name:"reject",description:"Reject a learned capability",type:"enum"},{name:"disable",description:"Disable an active learned capability",type:"enum"},{name:"rollback",description:"Restore the previous good revision",type:"enum"},{name:"promote",description:"Promote an exact revision to the user Skill catalog",type:"enum"},{name:"help",description:"Show Learning Center help",type:"enum"}];function pf(e){let[o=""]=e,n=o.toLowerCase(),t=e.length===1&&e[0]===""?0:e.length;return t<=1?mf:n==="help"&&t<=2?[{name:"promote",description:"Show dedicated promotion help",type:"enum"}]:n!=="promote"?[]:t<=2?[{name:"--help",description:"Show dedicated promotion help",type:"enum"}]:t<=3?[{name:"--scope",description:"Choose the formal user Skill scope",type:"enum"}]:e[2]?.toLowerCase()==="--scope"&&t<=4?[{name:"user",description:"Promote to the formal user Skill catalog",type:"enum"}]:[]}i(pf,"getLearnArgs");var gf=[{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"}],wf=[{name:"show",description:"Show a captured paste by id",type:"enum"},{name:"list",description:"List captured pastes",type:"enum"}],hf=[{name:"--lean",description:"Add a minimal-diff/YAGNI review pass",type:"enum"},{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"},{name:"help",description:"Show review help",type:"enum"}],yf=[{name:"init",description:"Create AGENTS.md in the target project if absent",type:"enum"},{name:"lean",description:"Initialize or LLM-review AGENTS.md for Lean Mode guidance",type:"enum"},{name:"help",description:"Show agents help",type:"enum"}],vf=[{name:"status",description:"Inspect the current repo-intelligence runtime state",type:"enum"},{name:"mode",description:"Switch repo-intelligence runtime mode",type:"enum"},{name:"trace",description:"Toggle repo-intelligence trace output",type:"enum"}],kf=[{name:"auto",description:"Let KodaX pick the best repo-intelligence engine",type:"enum"},{name:"full",description:"Prefer the full repo-intelligence engine",type:"enum"},{name:"light",description:"Use the light repo-intelligence engine",type:"enum"},{name:"off",description:"Disable repo-intelligence injection",type:"enum"}],bf=[{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"}],Sf=[{name:"status",description:"Deprecated alias for /repo-intel status",type:"enum"}],$f=[{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"}],xf=new Set(["show","pause","resume","stop","delete","rerun","save","rename","revise"]),Af=new Set(["show","delete","rerun","save","rename","revise"]),Rf=[{name:"--all",description:"Show all persisted workflow runs",type:"enum"},{name:"--limit",description:"Show at most N persisted workflow runs",type:"enum"}],Ef=[{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"}],Cf=[{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"}],If=[".workflow.json",".ts",".mjs",".js"];function Tf(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}}i(Tf,"workflowRunMatchesSubcommand");function Nn(e){return/^[a-zA-Z0-9._-]{1,120}$/.test(e)&&!e.startsWith(".")&&!e.includes("..")}i(Nn,"isWorkflowRunEntryName");function Pf(e,o){let n=On(e,"workflow-metadata.json");if(Wn(n))try{let r=JSON.parse(Ta(n,"utf8"));if(typeof r=="object"&&r!==null){let a=r.displayName;if(typeof a=="string"&&Nn(a.trim()))return a.trim()}}catch{}let t=o.displayName;return typeof t=="string"&&Nn(t.trim())?t.trim():void 0}i(Pf,"readWorkflowRunDisplayName");function Lf(){let e=Re(process.cwd()).key,o=_("workflow-runs",e);if(!Wn(o))return[];let n=[];for(let t of Ia(o)){if(!Nn(t))continue;let r=On(o,t,"run.json");if(Wn(r))try{let a=JSON.parse(Ta(r,"utf8")),l=typeof a.workflow=="string"?a.workflow:"?",c=typeof a.status=="string"?a.status:"?",d=typeof a.endedAt=="number"?a.endedAt:0;n.push({arg:{name:t,description:`${l} - ${c}`,type:"string"},endedAt:d});let u=Pf(On(o,t),a);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)}i(Lf,"getPersistedWorkflowRunIdArgs");function Dn(e){let o=Fe().list().filter(r=>Tf(e,r.status)).map(r=>({name:r.runId,description:`${r.workflow} - ${r.status}`,type:"string"})),n=Af.has(e)?Lf():[],t=new Set;return[...o,...n].filter(r=>t.has(r.name)?!1:(t.add(r.name),!0))}i(Dn,"getWorkflowRunIdArgs");function Mf(e){for(let o of If)if(e.endsWith(o)){let n=e.slice(0,-o.length);return Nn(n)?n:void 0}}i(Mf,"savedWorkflowNameFromFile");function Oo(e={}){let o=[{path:_("workflows"),source:"personal"},{path:On(process.cwd(),".kodax","workflows"),source:"project"}],n=new Map;for(let t of o)if(Wn(t.path))try{for(let r of Ia(t.path)){if(e.generatedOnly===!0&&!r.endsWith(".workflow.json"))continue;let a=Mf(r);a&&n.set(a,{name:a,description:`${t.source} saved workflow`,type:"enum"})}}catch{}return[...n.values()].sort((t,r)=>t.name.localeCompare(r.name))}i(Oo,"getSavedWorkflowNameArgs");function _f(){let e=new Map;for(let o of Dn("rerun"))e.set(o.name,{...o,description:`recent run: ${o.description}`,type:"string"});for(let o of Oo()){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()]}i(_f,"getWorkflowRerunArgs");function gr(e){let o=new Map;for(let n of Dn(e))o.set(n.name,{...n,description:`workflow run: ${n.description}`,type:"string"});for(let n of Oo({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()]}i(gr,"getWorkflowRunOrSavedNameArgs");function Ca(e){let o=new Set(e.slice(1).filter(n=>n.startsWith("--")));return o.has("--saved")?Oo({generatedOnly:!0}):o.has("--run")?Dn("delete"):gr("delete")}i(Ca,"getWorkflowDeleteTargetArgs");function Wf(e){let[o=""]=e,n=o.toLowerCase(),t=e.length===1&&e[0]===""?0:e.length;if(t<=1)return[...$f,...qo().map(r=>({name:r.name,description:r.description,type:"enum"})),...Oo()];if(n==="rerun"&&t<=2)return _f();if(n==="rename"&&t<=2)return gr("rename");if(n==="delete"&&t<=2)return[...Cf,...Ca(e)];if(n==="delete"&&t<=3&&e.slice(1).some(r=>r.startsWith("--")))return Ca(e);if(n==="revise"){if(t<=2)return[{name:"--replace",description:"Replace a saved workflow after confirmation",type:"enum"},...gr("revise")];if(e[1]==="--replace"&&t<=3)return Oo()}return xf.has(n)&&t<=2?Dn(n):n==="runs"&&t<=2?Rf:n==="prune"&&t<=2?Ef:[]}i(Wf,"getWorkflowArgs");function Of(e){let[o=""]=e,n=o.toLowerCase(),t=e.length===1&&e[0]===""?0:e.length;return t<=1?vf:t>2?[]:n==="mode"?kf:n==="trace"?bf:[]}i(Of,"getRepoIntelArgs");var Nf=new Map([["mode",af],["thinking",so],["think",so],["t",so],["reasoning",so],["reason",so],["effort",so],["status",mr],["info",mr],["ctx",mr],["mcp",cf],["fallback",df],["auto-engine",uf],["agent-mode",Ra],["am",Ra],["verifier-log",Ea],["stall-log",Ea],["memory",ff],["goal",gf],["paste",wf],["review",hf],["agents",yf],["delete",pr],["rm",pr],["del",pr]]),Df=new Set(["model","m","provider"]),Uf=new Set(["repo-intel"]),jf=new Set(["repointel","ri"]),Ff=new Set(["workflow"]),Hf=new Set(["learn"]);function wr(e,o,n=[]){let t=e.toLowerCase();return Df.has(t)?lf(o):Uf.has(t)?Of(n):jf.has(t)?n.length<=1?Sf:[]:Ff.has(t)?Wf(n):Hf.has(t)?pf(n):Nf.get(t)??[]}i(wr,"getCommandArguments");var hr=class{static{i(this,"ArgumentCompleter")}canComplete(o,n){let t=o.slice(0,n),r=ro(t);if(r===-1)return!1;let a=t.slice(r),l=a.split(/\s+/);if(l.length>=2&&l[0]!=="")return!0;let c=a.slice(1).toLowerCase();return wr(c).length>0}async getCompletions(o,n){let t=o.slice(0,n),r=ro(t);if(r===-1)return[];let a=t.slice(r),l=a.indexOf(" "),c=(l===-1?a.slice(1):a.slice(1,l)).toLowerCase(),d=l===-1?"":a.slice(l+1),u=d?d.split(/\s+/):[""],f=u.length-1,m=(u[f]??"").toLowerCase(),b=wr(c,m,u);if(!b||b.length===0)return[];let S=new Set(u.slice(0,-1).map(A=>A.toLowerCase()));return b.filter(A=>!S.has(A.name.toLowerCase())).filter(A=>!m||A.name.includes("/")?!0:A.name.toLowerCase().includes(m)).map(A=>({text:A.name,display:A.name,description:A.description,type:"argument"})).sort((A,v)=>{if(!m)return 0;let x=A.display.toLowerCase().startsWith(m),M=v.display.toLowerCase().startsWith(m);return x&&!M?-1:!x&&M?1:A.display.length-v.display.length})}};function dv(){return new hr}i(dv,"createArgumentCompleter");export{pt as a,B as b,_p as c,si as d,Wp as e,Jo as f,_a as g,zf as h,Wa as i,Xf as j,Zo as k,ks as l,go as m,ho as n,Ge as o,qe as p,Cs as q,Is as r,Ts as s,Ns as t,Ds as u,rt as v,js as w,pl as x,hl as y,np as z,hp as A,yl as B,dt as C,yp as D,vp as E,Qs as F,Rp as G,ri as H,te as I,li as J,ci as K,Fp as L,_l as M,Xl as N,Hp as O,rn as P,wt as Q,Bp as R,vi as S,Kp as T,Gp as U,qp as V,hg as W,yg as X,vg as Y,Ci as Z,bt as _,Ii as $,Re as aa,Ag as ba,xo as ca,Et as da,Ie as ea,pd as fa,gd as ga,Xi as ha,Jg as ia,Zg as ja,Cd as ka,Xw as la,Vw as ma,Yw as na,gh as oa,wh as pa,hh as qa,yh as ra,vh as sa,aa as ta,Ah as ua,Rh as va,ca as wa,Eh as xa,qh as ya,da as za,_o as Aa,Oy as Ba,Ny as Ca,Mn as Da,hr as Ea,dv as Fa,ro as Ga,ur as Ha,fr as Ia,Jy as Ja};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
|
|
2
|
-
import{
|
|
2
|
+
import{qc as o}from"./chunk-45E23YJI.js";import{h as c}from"./chunk-EVXIJPZ6.js";import{a as n}from"./chunk-ONUPGMER.js";import{readFile as a}from"fs/promises";var i={enabled:!0,triggerPercent:75};async function s(r){let t=c("config.json");try{let e=await f(t);if(e?.compaction)return o({...i,...e.compaction})}catch{}return o(i)}n(s,"loadCompactionConfig");async function f(r){try{let t=await a(r,"utf-8");return JSON.parse(t)}catch{return null}}n(f,"readConfigFile");export{s as a};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
|
|
2
|
-
import{fa as Se,ha as Ce}from"./chunk-
|
|
2
|
+
import{fa as Se,ha as Ce}from"./chunk-TC2VHPG5.js";import{Aa as Ee,Ba as R,C as B,Ea as Z,F as q,G as me,H as J,Pa as xe,Ua as be,oa as he,pa as ge,q as pe,qa as ve,ra as ye,sa as we,ta as Y}from"./chunk-TRNAWSXP.js";import{Fa as ke}from"./chunk-45E23YJI.js";import{g as Pe}from"./chunk-EVXIJPZ6.js";import{a as r}from"./chunk-ONUPGMER.js";import m from"fs";import h from"path";import{exec as yt,spawnSync as wt}from"child_process";import{promisify as Et}from"util";import{fileURLToPath as xt}from"url";var Q="en";function Je(){return(process.env.LC_ALL||process.env.LC_MESSAGES||process.env.LANG||"").toLowerCase().startsWith("zh")?"zh":"en"}r(Je,"detectSystemLocale");function Me(e){if(!e||e==="auto"){Q=Je();return}Q=e.toLowerCase().replace(/[-_].*/,"")==="zh"?"zh":"en"}r(Me,"setLocale");var _e={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.runtime_session":"Press (y) allow once, (s) allow this Runtime scope for the session, (n) no","confirm.instruction.runtime_persistent":"Press (y) allow once, (s) allow this Runtime scope for the session, (a) always allow this Runtime scope, (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.approved_session":"Approved (this session)","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.multiselect_min":"Select at least {min} option(s) with Space before confirming.","select.multiselect_max":"Select at most {max} option(s) 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","todo.progress":"{completed}/{total} completed","todo.transcript.progress":"Plan {completed}/{total} completed","todo.summary.done":"{count} done","todo.summary.more":"+{count} more",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.runtime_session":"\u6309 (y) \u4EC5\u5141\u8BB8\u4E00\u6B21, (s) \u672C\u4F1A\u8BDD\u59CB\u7EC8\u5141\u8BB8\u8FD9\u9879\u7CBE\u786E\u64CD\u4F5C, (n) \u62D2\u7EDD","confirm.instruction.runtime_persistent":"\u6309 (y) \u4EC5\u5141\u8BB8\u4E00\u6B21, (s) \u672C\u4F1A\u8BDD\u59CB\u7EC8\u5141\u8BB8\u8FD9\u9879\u7CBE\u786E\u64CD\u4F5C, (a) \u59CB\u7EC8\u5141\u8BB8\u8FD9\u9879\u7CBE\u786E\u64CD\u4F5C, (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.approved_session":"\u5DF2\u6279\u51C6 (\u672C\u4F1A\u8BDD)","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.multiselect_min":"\u8BF7\u5148\u4F7F\u7528\u7A7A\u683C\u81F3\u5C11\u9009\u62E9 {min} \u4E2A\u9009\u9879\u3002","select.multiselect_max":"\u6700\u591A\u53EA\u80FD\u9009\u62E9 {max} \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","todo.progress":"{completed}/{total} \u5DF2\u5B8C\u6210","todo.transcript.progress":"\u8BA1\u5212 {completed}/{total} \u5DF2\u5B8C\u6210","todo.summary.done":"{count} \u9879\u5DF2\u5B8C\u6210","todo.summary.more":"\u53E6\u6709 {count} \u9879",cancelled:"[\u5DF2\u53D6\u6D88] \u64CD\u4F5C\u5DF2\u88AB\u7528\u6237\u53D6\u6D88"}};function qt(e,t){let o=_e[Q][e]??_e.en[e]??e;if(t)for(let[i,s]of Object.entries(t))o=o.replace(`{${i}}`,String(s));return o}r(qt,"t");var Ae={core:`// Split configs: ~/.kodax/integrations/mcp.json, extensions.json, and a2a.json.
|
|
3
3
|
// KodaX core configuration template.
|
|
4
4
|
// Copy only the fields you need to ~/.kodax/config.json (strict JSON).
|
|
5
5
|
// MCP, A2A, and Extensions live in ~/.kodax/integrations/*.json; use
|
|
@@ -275,4 +275,4 @@ import{fa as Se,ha as Ce}from"./chunk-ZZUIO5KL.js";import{Aa as Ee,Ba as R,C as
|
|
|
275
275
|
}
|
|
276
276
|
`};function Oe(e){return Ae[e]}r(Oe,"getConfigTemplate");import{closeSync as ne,existsSync as d,fsyncSync as Le,linkSync as rt,mkdirSync as re,openSync as ie,readFileSync as Ne,renameSync as $e,statSync as it,unlinkSync as j,watch as st,writeFileSync as je}from"node:fs";import{createHash as at}from"node:crypto";import f from"node:path";import{closeSync as Ye,mkdirSync as Ze,openSync as Qe,rmSync as et}from"node:fs";import tt from"node:path";var ee=class extends Error{static{r(this,"CoreConfigWriteConflictError")}constructor(t){super(`Core configuration is being changed by another KodaX writer: ${t}`),this.name="CoreConfigWriteConflictError"}};function nt(e){return`${e}.write.lock`}r(nt,"coreConfigWriteLockPath");function ot(e){if(!(!(e instanceof Error)||!("code"in e)))return typeof e.code=="string"?e.code:void 0}r(ot,"errorCode");function E(e,t){Ze(tt.dirname(e),{recursive:!0,mode:448});let n=nt(e),o;try{o=Qe(n,"wx",384)}catch(i){throw ot(i)==="EEXIST"?new ee(e):new Error(`Failed to acquire the core configuration write lock: ${e}`,{cause:i})}try{return t()}finally{Ye(o),et(n,{force:!0})}}r(E,"withCoreConfigWriteLock");var k=class extends Error{static{r(this,"IntegrationConfigConflictError")}constructor(t,n,o){super(`Integration configuration revision changed for ${f.basename(t)} (expected ${n??"missing"}, actual ${o??"missing"}).`),this.name="IntegrationConfigConflictError"}},ct={mcp:"mcp.json",a2a:"a2a.json",extensions:"extensions.json"},lt=new Set(["type","command","args","cwd","env","url","headers","connect","startupTimeoutMs","requestTimeoutMs","auth"]);function P(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}r(P,"isRecord");function x(e,t){if(!P(e))throw new Error(`${t} must be an object.`);return e}r(x,"requireRecord");function K(e,t,n){let o=Object.keys(e).find(i=>!t.has(i));if(o!==void 0)throw new Error(`${n} has unknown field "${o}".`)}r(K,"assertNoUnknownKeys");function Ke(e,t){if(e.version!==1)throw new Error(`${t} version must be 1.`)}r(Ke,"requireVersionOne");function Ie(e,t){let n=x(e,t);for(let[o,i]of Object.entries(n))if(o.trim().length===0||typeof i!="string")throw new Error(`${t} must contain non-empty string keys and string values.`);return structuredClone(n)}r(Ie,"requireStringMap");function oe(e,t){if(!Array.isArray(e)||!e.every(n=>typeof n=="string"&&n.trim().length>0))throw new Error(`${t} must be an array of non-empty strings.`);return e.map(n=>n.trim())}r(oe,"requireStringArray");function te(e,t){if(e!==void 0&&(!Number.isFinite(e)||Number(e)<=0))throw new Error(`${t} must be a positive number.`)}r(te,"validatePositiveNumber");function dt(e,t){if(e.trim().length===0)throw new Error("MCP server names must not be empty.");let n=x(t,`MCP server "${e}"`);K(n,lt,`MCP server "${e}"`);let o=n.type??"stdio";if(!["stdio","sse","streamable-http","http"].includes(String(o)))throw new Error(`MCP server "${e}" has an unsupported transport type.`);if(o==="stdio"){if(typeof n.command!="string"||n.command.trim().length===0)throw new Error(`MCP server "${e}" stdio transport requires command.`)}else if(typeof n.url!="string"||n.url.trim().length===0)throw new Error(`MCP server "${e}" ${String(o)} transport requires url.`);if(n.args!==void 0&&oe(n.args,`MCP server "${e}" args`),n.cwd!==void 0&&typeof n.cwd!="string")throw new Error(`MCP server "${e}" cwd must be a string.`);if(n.env!==void 0&&Ie(n.env,`MCP server "${e}" env`),n.headers!==void 0&&Ie(n.headers,`MCP server "${e}" headers`),n.connect!==void 0&&!["lazy","prewarm","disabled"].includes(String(n.connect)))throw new Error(`MCP server "${e}" has an unsupported connect mode.`);if(te(n.startupTimeoutMs,`MCP server "${e}" startupTimeoutMs`),te(n.requestTimeoutMs,`MCP server "${e}" requestTimeoutMs`),n.auth!==void 0){let i=x(n.auth,`MCP server "${e}" auth`);if(K(i,new Set(["type","clientId","authorizationUrl","tokenUrl","scopes","redirectPort"]),`MCP server "${e}" auth`),i.type!=="oauth2")throw new Error(`MCP server "${e}" auth type must be oauth2.`);for(let a of["clientId","authorizationUrl","tokenUrl"])if(i[a]!==void 0&&typeof i[a]!="string")throw new Error(`MCP server "${e}" auth.${a} must be a string.`);i.scopes!==void 0&&oe(i.scopes,`MCP server "${e}" auth.scopes`),te(i.redirectPort,`MCP server "${e}" auth.redirectPort`)}return structuredClone(n)}r(dt,"parseMcpServer");function S(e){let t=x(e,"MCP integration config");K(t,new Set(["version","servers"]),"MCP integration config"),Ke(t,"MCP integration config");let n=x(t.servers,"MCP integration config servers"),o={};for(let[i,s]of Object.entries(n))o[i]=dt(i,s);return{version:1,servers:o}}r(S,"parseMcpIntegrationDocument");function C(e){let t=x(e,"Extensions integration config");K(t,new Set(["version","paths"]),"Extensions integration config"),Ke(t,"Extensions integration config");let n=oe(t.paths,"Extensions integration config paths");if(new Set(n).size!==n.length)throw new Error("Extensions integration config paths must not contain duplicates.");return{version:1,paths:n}}r(C,"parseExtensionsIntegrationDocument");function _(e,t){return f.join(f.resolve(t),"integrations",ct[e])}r(_,"resolveIntegrationConfigPath");function A(e){return f.join(f.resolve(e),"config.json")}r(A,"coreConfigPath");function Xe(e){return at("sha256").update(e).digest("hex")}r(Xe,"hashText");function se(e){let t=Ne(e,"utf8");try{return{raw:t,value:JSON.parse(t)}}catch(n){let o=n instanceof Error?n.message:String(n);throw new Error(`Invalid JSON: ${o}`)}}r(se,"readJsonFile");function M(e){return{domain:e.domain,source:e.source,path:e.path,revision:Xe(e.raw),document:structuredClone(e.document),loadedAt:new Date().toISOString()}}r(M,"snapshot");function X(e){let t=A(e);return d(t)?x(se(t).value,"Core config"):{}}r(X,"readCoreConfig");function F(e){let t=_("mcp",e);if(d(t)){let s=se(t);return M({domain:"mcp",source:"user",path:t,raw:s.raw,document:S(s.value)})}let n=A(e),o=X(e).mcpServers,i=S({version:1,servers:o===void 0?{}:o});return M({domain:"mcp",source:o===void 0?"default":"legacy-user",path:o===void 0?t:n,raw:JSON.stringify(i),document:i})}r(F,"readMcpIntegration");function U(e){let t=_("extensions",e);if(d(t)){let s=se(t);return M({domain:"extensions",source:"user",path:t,raw:s.raw,document:C(s.value)})}let n=A(e),o=X(e).extensions,i=C({version:1,paths:o===void 0?[]:o});return M({domain:"extensions",source:o===void 0?"default":"legacy-user",path:o===void 0?t:n,raw:JSON.stringify(i),document:i})}r(U,"readExtensionsIntegration");function ut(e){if(!P(e))return[];let t=[],n=/(token|secret|password|api[_-]?key|authorization)/i;for(let[o,i]of Object.entries(e))if(P(i))for(let s of["env","headers"]){let a=i[s];if(P(a))for(let[c,l]of Object.entries(a))n.test(c)&&typeof l=="string"&&!l.startsWith("${env:")&&t.push(`MCP server "${o}" ${s}.${c} may contain a literal secret.`)}return t}r(ut,"likelySecretWarnings");function ft(e){let t=X(e),n=_("mcp",e),o=_("extensions",e),i=t.mcpServers,s=t.extensions,a=P(i)?Object.keys(i).length:0,c=Array.isArray(s)?s.length:0,l=r((g,L,N)=>d(g)?{action:"none",entries:L,destination:g,reason:"destination-exists"}:N?{action:"create",entries:L,destination:g}:{action:"none",entries:0,destination:g,reason:"legacy-absent"},"domainPlan");return{mcp:l(n,a,i!==void 0),extensions:l(o,c,s!==void 0),warnings:ut(i)}}r(ft,"planLegacyIntegrationMigration");function pt(e,t){let n=A(e);re(f.dirname(n),{recursive:!0,mode:448});let o=`${n}.${process.pid}.${Date.now()}.tmp`,i=ie(o,"wx",384);try{je(i,`${JSON.stringify(t,null,2)}
|
|
277
277
|
`,"utf8"),Le(i)}finally{ne(i)}try{$e(o,n)}catch(s){throw d(o)&&j(o),new Error("Failed to atomically clean legacy integration fields.",{cause:s})}}r(pt,"writeCoreConfigAtomically");function ln(e){return E(A(e.configHome),()=>mt(e))}r(ln,"migrateLegacyIntegrationConfig");function mt(e){let t=ft(e.configHome),n=X(e.configHome),o=t.mcp.action==="create"?S({version:1,servers:P(n.mcpServers)?n.mcpServers:{}}):void 0,i=t.extensions.action==="create"?C({version:1,paths:Array.isArray(n.extensions)?n.extensions:[]}):void 0,s=[];if(o)try{T({domain:"mcp",configHome:e.configHome,expectedRevision:null,document:o,validate:S}),s.push("mcp")}catch(c){if(!(c instanceof k))throw c}if(i)try{T({domain:"extensions",configHome:e.configHome,expectedRevision:null,document:i,validate:C}),s.push("extensions")}catch(c){if(!(c instanceof k))throw c}let a=!1;if(e.cleanupLegacy&&d(A(e.configHome))){let c={...n};d(t.mcp.destination)&&delete c.mcpServers,d(t.extensions.destination)&&delete c.extensions,ht(n,c)||(pt(e.configHome,c),a=!0)}return{...t,applied:s,cleanedLegacy:a}}r(mt,"migrateLegacyIntegrationConfigUnlocked");function ht(e,t){return JSON.stringify(e)===JSON.stringify(t)}r(ht,"isDeepStrictEqualForConfig");function Re(e){return d(e)?Xe(Ne(e,"utf8")):void 0}r(Re,"currentUserRevision");function gt(e){let t=`${e}.lock`;try{return{fd:ie(t,"wx",384),path:t}}catch(n){throw new Error(`Integration configuration is busy: ${f.basename(e)}`,{cause:n})}}r(gt,"acquireWriteLock");function T(e){let t=_(e.domain,e.configHome),n=e.validate(e.document);re(f.dirname(t),{recursive:!0,mode:448});let o=gt(t);try{let i=Re(t),s=e.expectedRevision===null?void 0:e.expectedRevision;if(e.expectedRevision!==void 0&&i!==s)throw new k(t,s,i);let a=`${JSON.stringify(n,null,2)}
|
|
278
|
-
`,c=`${t}.${process.pid}.${Date.now()}.tmp`,l=ie(c,"wx",384);try{je(l,a,"utf8"),Le(l)}finally{ne(l)}try{e.expectedRevision===null?(rt(c,t),j(c)):$e(c,t)}catch(g){throw d(c)&&j(c),e.expectedRevision===null&&d(t)?new k(t,void 0,Re(t)):new Error(`Failed to atomically replace ${f.basename(t)}.`,{cause:g})}return M({domain:e.domain,source:"user",path:t,raw:a,document:n})}finally{ne(o.fd),d(o.path)&&j(o.path)}}r(T,"writeIntegrationDocument");function vt(e){if(!d(e))return"missing";let t=it(e);return`${t.dev}:${t.ino}:${t.size}:${t.mtimeMs}`}r(vt,"metadataSignature");function Te(e){return e.map(t=>`${t}:${vt(t)}`).join("|")}r(Te,"observationSignature");function $(e,t){return{code:e,message:t,time:new Date().toISOString()}}r($,"safeDiagnostic");var De=class{static{r(this,"IntegrationConfigController")}#u;#n;#r;#a;#m;#f;#p;#e;#t;#c;#l;#h="";#s=[];#o;#i;#g=Promise.resolve();#d=new Set;constructor(t){this.#u=t.domain,this.#n=_(t.domain,t.configHome),this.#r=t.fallbackPath===void 0?void 0:f.resolve(t.fallbackPath),this.#a=this.#r===void 0?[this.#n]:[this.#n,this.#r],this.#f=t.validate,this.#m=t.read,this.#p=t.coldStartDefault===void 0?void 0:structuredClone(this.#f(t.coldStartDefault))}async initialize(){let t=await this.reload();if(!t.ok&&!this.#e&&this.#p!==void 0){let n=structuredClone(this.#p);this.#e=M({domain:this.#u,source:"default",path:this.#n,raw:JSON.stringify(n),document:n})}if(!this.#e)throw new Error(t.ok?"Integration configuration did not produce a snapshot.":t.error);return structuredClone(this.#e)}snapshot(){return this.#e?structuredClone(this.#e):void 0}status(){let t=this.#t?this.#c:void 0,n=this.#t?this.#l:void 0;return{domain:this.#u,path:t??this.#e?.path??this.#n,...this.#e?{revision:this.#e.revision,lastReloadAt:this.#e.loadedAt}:{},...n??this.#e?.source?{source:n??this.#e?.source}:{},...this.#t?{diagnostic:this.#t}:{},watching:this.#s.length>0}}subscribe(t){return this.#d.add(t),()=>{this.#d.delete(t)}}reload(){let t=this.#g.then(()=>this.#v());return this.#g=t.then(()=>{},()=>{}),t}async#v(){this.#h=Te(this.#a);let t;try{t=this.#m(),this.#f(t.document)}catch{let o=this.#y();return this.#c=o.path,this.#l=o.source,this.#t=$("invalid-config","Integration configuration is invalid; check the file against its versioned schema."),{ok:!1,error:this.#t.message}}let n=this.#e?structuredClone(this.#e):void 0;try{for(let o of this.#d)await o(structuredClone(t),n)}catch{return this.#c=t.path,this.#l=t.source,this.#t=$("activation-failed","Integration configuration could not be activated; the previous configuration remains active."),{ok:!1,error:this.#t.message}}return this.#e=t,this.#t=void 0,this.#c=void 0,this.#l=void 0,{ok:!0,snapshot:structuredClone(t)}}async ensureCurrent(){return Te(this.#a)===this.#h&&this.#e?{ok:!0,snapshot:structuredClone(this.#e)}:this.reload()}startWatching(t=100,n=2e3){if(this.#s.length>0||this.#i)return;re(f.dirname(this.#n),{recursive:!0,mode:448});let o=new Map;for(let i of this.#a){let s=f.dirname(i),a=o.get(s)??new Set;a.add(f.basename(i)),o.set(s,a)}for(let[i,s]of o)try{let a=st(i,(c,l)=>{l!==null&&!s.has(l.toString())||(this.#o&&clearTimeout(this.#o),this.#o=setTimeout(()=>{this.#o=void 0,this.reload()},t),this.#o.unref?.())});a.unref(),a.on("error",()=>{this.#t=$("watcher-degraded","Integration watcher is degraded; metadata polling remains active.")}),this.#s.push(a)}catch{this.#t=$("watcher-degraded","Integration watcher is degraded; metadata polling remains active.")}this.#i=setInterval(()=>{this.ensureCurrent()},n),this.#i.unref?.()}close(){this.#o&&clearTimeout(this.#o),this.#o=void 0,this.#i&&clearInterval(this.#i),this.#i=void 0;for(let t of this.#s)t.close();this.#s.length=0,this.#d.clear()}#y(){return d(this.#n)?{path:this.#n,source:"user"}:this.#r&&d(this.#r)?{path:this.#r,source:"legacy-user"}:{path:this.#n,source:"default"}}};var bt=Et(yt),Fe=2,Ue=!1,u=Pe(),kn=h.join(u,"sessions"),p=h.join(u,"config.json"),Sn=60,v=null,ce=!1,Pt="dumb";function kt(e){let t=h.basename(e).toLowerCase(),n="__KODAX_SHELL_ENV_START__",o=`printf '%s\\0' '${n}'; env -0`;return t==="fish"?{args:["-i","-c",o],sentinel:n}:{args:t==="bash"||t==="zsh"?["-ic",o]:["-lc",o],sentinel:n}}r(kt,"buildShellEnvCommand");function St(e,t){let n=`${t}\0`,o=e.lastIndexOf(n);if(o===-1)return{};let i=e.slice(o+n.length),s={};for(let a of i.split("\0")){if(!a)continue;let c=a.indexOf("=");c<=0||(s[a.slice(0,c)]=a.slice(c+1))}return s}r(St,"parseNullDelimitedShellEnv");function Ct(e={}){let t=e.env??process.env;if((e.platform??process.platform)==="win32"||t.KODAX_DISABLE_SHELL_ENV_HYDRATION==="1")return!1;let o=e.shell??t.SHELL;if(!o||!h.isAbsolute(o))return!1;let{args:i,sentinel:s}=kt(o),a=e.run??wt,c={...t,TERM:Pt},l=a(o,i,{encoding:"utf8",env:c,maxBuffer:1024*1024,timeout:5e3,windowsHide:!0,detached:!0,stdio:["ignore","pipe","pipe"]});if(l.status!==0||!l.stdout)return!1;let g=typeof l.stdout=="string"?l.stdout:l.stdout.toString("utf8"),L=St(g,s),N=!1;for(let[z,qe]of Object.entries(L))z!=="TERM"&&t[z]===void 0&&(t[z]=qe,N=!0);return N}r(Ct,"hydrateProcessEnvFromShell");function _t(){if(!ce){ce=!0;try{Ct()}catch{}}}r(_t,"ensureShellEnvironmentHydrated");function Cn(){ce=!1}r(Cn,"resetShellEnvironmentHydrationForTesting");function Mt(e){Ee(e.customProviders??[])}r(Mt,"registerConfiguredCustomProviders");function le(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:[]}r(le,"normalizeConfiguredExtensions");function At(e){if(e===void 0||e===null||typeof e!="object"||Array.isArray(e))return;let t=e.envPass;if(!Array.isArray(t))return;let n=t.filter(o=>typeof o=="string").map(o=>o.trim()).filter(o=>/^[A-Za-z_][A-Za-z0-9_]*$/.test(o));return{envPass:[...new Set(n)]}}r(At,"normalizeSandboxConfig");function ue(){let e=m.readFileSync(p,"utf8"),t=JSON.parse(e);if(!(t===null||typeof t!="object"||Array.isArray(t)))return{raw:e,value:t}}r(ue,"readPersistedCoreConfig");function Ve(e){m.writeFileSync(p,JSON.stringify(e,null,2))}r(Ve,"writePersistedCoreConfig");function Ot(e){if(e.permissionMode!=="default")return e;let t={...e,permissionMode:"accept-edits"};try{E(p,()=>{let n=ue();n?.value.permissionMode==="default"&&Ve({...n.value,permissionMode:"accept-edits"})})}catch{}return t}r(Ot,"migrateLegacyPermissionModeInConfig");function It(e){if(e.permissionMode!=="auto-in-project")return e;try{E(p,()=>{let t=ue();if(t?.value.permissionMode!=="auto-in-project")return;let n=t.raw.replace(/("permissionMode"\s*:\s*)"auto-in-project"/,'$1"auto"');n!==t.raw&&m.writeFileSync(p,n)})}catch{}return{...e,permissionMode:"auto"}}r(It,"migrateAutoInProjectAliasInConfig");function Rt(){if(v)return v;let e="0.7.82";if(e)return v=e,v;let t=h.join(h.dirname(xt(import.meta.url)),"../../package.json");if(m.existsSync(t))try{return v=JSON.parse(m.readFileSync(t,"utf-8")).version??"0.0.0",v??"0.0.0"}catch{}return v="0.0.0",v}r(Rt,"getVersion");var _n=Rt();function Tt(e){return ge(e)}r(Tt,"getProviderModel");function de(e,t){let n=new Set(e.map(i=>i.toLowerCase())),o=[...e];for(let i of t)n.has(i.toLowerCase())||o.push(i);return o}r(de,"mergeModels");function Dt(e,t){t||(t=fe().providerModels);let n=t?.[e];if(n&&n.length>0){try{let o=Y(e);if(o.length>0)return de(n,o)}catch{}try{let o=R(e);if(o)return de(n,o.getAvailableModels())}catch{}return n}try{let o=Y(e);if(o.length>0)return o}catch{}try{let o=R(e);if(o)return o.getAvailableModels()}catch{}return[]}r(Dt,"getProviderAvailableModels");function Lt(e,t){let n=ve(e,t);if(n!=="unknown")return n;try{let o=R(e);if(o)return o.getReasoningCapability(t)}catch{}return"unknown"}r(Lt,"getProviderReasoningCapability");function Nt(e){let t=ye(e);if(t)return t;try{return Z().find(o=>o.name===e)?.capabilityProfile??null}catch{return null}}r(Nt,"getProviderCapabilityProfile");function ze(e,t){let n=Nt(e),o=Lt(e,t);if(n)return{capabilityProfile:n,reasoningCapability:o};try{let i=xe(e);return{capabilityProfile:i.getCapabilityProfile(),reasoningCapability:i.getReasoningCapability(t)}}catch{return null}}r(ze,"getProviderCapabilityMetadata");function Mn(e,t){let n=ze(e,t);return n?Se({providerName:e,model:t,capabilityProfile:n.capabilityProfile,reasoningCapability:n.reasoningCapability==="unknown"?void 0:n.reasoningCapability}):null}r(Mn,"getProviderCapabilitySnapshot");function $t(e,t,n,o){let i=ze(e,t);return i?Ce({providerName:e,model:t,capabilityProfile:i.capabilityProfile,reasoningCapability:i.reasoningCapability==="unknown"?void 0:i.reasoningCapability,reasoningMode:n,hints:o}):null}r($t,"getProviderPolicyDecision");function An(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",o=e.mcpSupport==="native"?"MCP available":"MCP unavailable";return`${t}; ${n}; ${o}`}r(An,"describeProviderCapabilitySummary");function On(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"-"}}r(On,"formatReasoningCapabilityShort");function I(e){if(e)return e==="none"?"off":e}r(I,"formatReasoningEffortForDisplay");function G(e,t){let n=I(t);n&&!e.includes(n)&&e.push(n)}r(G,"pushUniqueEffortDisplay");function In(e,t){let n=["auto"],i=V(e,t)?.supportedEfforts?.filter(s=>s.isUserVisible!==!1);if(!i||i.length===0){for(let s of["off","low","medium","high"])G(n,s);return n}for(let s of i)G(n,s.value);return n}r(In,"getProviderReasoningEffortOptions");function Rn(e,t){let n=V(e,t),o=new Set(n?.disabledEfforts??[]),i=n?.supportedEfforts?.filter(l=>l.isUserVisible!==!1),s=[],a=n?.supportsDisabledThinking===!0;if(!i||i.length===0){for(let l of["low","medium","high"])G(s,l);a=!0}else for(let l of i){if(l.value==="none"){a=!0;continue}if(o.has(l.value)){a=!0;continue}G(s,l.value)}let c=[];return a&&c.push("off"),c.push(...s),c.push("auto"),c}r(Rn,"getProviderReasoningEffortCycle");function jt(e,t){if(t===!1)return"off";switch(e){case"off":return"off";case"quick":return"low";case"balanced":return"medium";case"deep":return"high";default:return"auto"}}r(jt,"legacyReasoningModeToEffortDisplay");function V(e,t){let n=t??Tt(e);if(!n)return;let o=be(e,n)?.reasoningProfile;if(o)return pe(o,ke(e,n))}r(V,"resolveReasoningProfileForDisplay");function Tn(e){let t=I(e.effort)??jt(e.reasoningMode,e.thinking),n=V(e.provider,e.model);if(!n)return t;try{let o=me({capability:n,explicitEffort:e.effortOverride?e.effort:void 0,sessionEffort:e.effortOverride?void 0:e.effort,legacyReasoningMode:e.reasoningMode,thinking:e.thinking}),i=I(o.configuredEffort)??t,a=o.configuredEffort!==void 0&&n.disabledEfforts?.includes(o.configuredEffort)===!0?"off":I(o.effectiveEffort);return a&&a!==i?`${i}->${a}`:i}catch{if(e.effort)try{let o=J({currentEffort:e.effort,capability:n}),i=I(e.effort)??t,s=I(o.effectiveEffort);return s&&s!==i?`${i}->${s}`:i}catch{return t}return t}}r(Tn,"formatReasoningEffortStatusLabel");function Dn(e){let t=zt(e);if(!t)return{preserved:!0};let n=V(e.provider,e.model);if(!n)return{configuredEffort:t,runtimeEffort:t,preserved:!0};let o=J({currentEffort:t,capability:n});return{configuredEffort:t,runtimeEffort:o.effectiveEffort,preserved:o.preserved,diagnostic:o.diagnostic}}r(Dn,"resolveProviderReasoningRuntimeEffort");function Kt(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"}}r(Kt,"describeReasoningCapabilityControl");function Ln(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"}}r(Ln,"describeReasoningExecution");function Nn(e){let t=[];e||(e=fe().providerModels);for(let n of we())t.push({name:n.name,model:n.model,models:Dt(n.name,e),configured:n.capabilityProfile.transport==="cli-bridge"?!0:n.configured,reasoningCapability:n.reasoningCapability,capabilityProfile:n.capabilityProfile});try{let n=Z().map(o=>({...o,models:(()=>{let i=e?.[o.name];return i&&i.length>0?de(i,o.models):o.models})()}));t.push(...n)}catch{}return t}r(Nn,"getProviderList");function $n(e){if(he(e))return!0;try{return R(e)?.isConfigured()??!1}catch{return!1}}r($n,"isProviderConfigured");var H=class extends Error{static{r(this,"InvalidAgentModeConfigError")}};function Xt(e){let t=e.agentMode;if(t===void 0||t==="ama"||t==="sa")return e;if(t!=="amaw"&&t!=="ama-workflow")throw new H(`Invalid agentMode "${t}" in ${p}. Expected "ama" or "sa".`);let n={...e,agentMode:"ama",schemaVersion:Math.max(e.schemaVersion??0,Fe)};try{E(p,()=>{let o=ue();if(!o)return;let i=o.value.agentMode;i!=="amaw"&&i!=="ama-workflow"||Ve({...o.value,agentMode:"ama",schemaVersion:Math.max(typeof o.value.schemaVersion=="number"?o.value.schemaVersion:0,Fe)})})}catch{}return Ue||(process.emitWarning(`Migrated persisted agentMode "${t}" to "ama". Workflow use is now explicit intent.`,{code:"KODAX_AGENT_MODE_MIGRATED"}),Ue=!0),n}r(Xt,"migrateLegacyAgentModeConfig");function fe(){try{if(m.existsSync(p)){let n=JSON.parse(m.readFileSync(p,"utf-8")),o=Xt(n),i=o.reasoningCeiling??o.reasoningMode,s=[],a={};try{s=[...U(u).document.paths]}catch{}try{a=F(u).document.servers}catch{}return It(Ot({...o,reasoningMode:i,extensions:le(s),mcpServers:a,sandbox:At(o.sandbox)}))}}catch(n){if(n instanceof H)throw n}let e,t;try{let n=U(u);n.source!=="default"&&(e=le([...n.document.paths]))}catch{}try{let n=F(u);n.source!=="default"&&(t=n.document.servers)}catch{}return{...e===void 0?{}:{extensions:e},...t===void 0?{}:{mcpServers:t}}}r(fe,"loadConfig");var Ft=h.join(u,"config.example.jsonc"),ae={mcp:h.join(u,"integrations","mcp.example.jsonc"),a2a:h.join(u,"integrations","a2a.example.jsonc"),extensions:h.join(u,"integrations","extensions.example.jsonc")},Ut=[{name:"core",path:Ft},{name:"mcp",path:ae.mcp},{name:"a2a",path:ae.a2a},{name:"extensions",path:ae.extensions}];function Wt(){let e=[];for(let t of Ut)try{if(m.existsSync(t.path))continue;m.mkdirSync(h.dirname(t.path),{recursive:!0}),m.writeFileSync(t.path,Oe(t.name),"utf8"),e.push(t.path)}catch{}return e}r(Wt,"ensureExampleConfigFiles");function jn(){return Wt()[0]}r(jn,"ensureExampleConfigFile");var W=new Map;function Gt(e,t){let n=process.env[e],o=W.get(e),i=o!==void 0&&n===o;if(n!==void 0&&!i){W.delete(e);return}if(t===void 0){i&&delete process.env[e],W.delete(e);return}process.env[e]=t,W.set(e,t)}r(Gt,"projectConfigEnvironment");var Be=[{configPath:"streamIdleTimeoutMs",env:"KODAX_STREAM_IDLE_TIMEOUT_MS",value:r(e=>b(e.streamIdleTimeoutMs),"value")},{configPath:"repoIntelligenceMode",env:"KODAX_REPO_INTELLIGENCE",value:r(e=>e.repoIntelligenceMode,"value")},{configPath:"repoIntelligenceTrace",env:"KODAX_REPO_INTELLIGENCE_TRACE",value:r(e=>O(e.repoIntelligenceTrace),"value")},{configPath:"verifierLog",env:"KODAX_VERIFIER_LOG",value:r(e=>O(e.verifierLog),"value")},{configPath:"stallLog",env:"KODAX_STALL_LOG",value:r(e=>O(e.stallLog),"value")},{configPath:"fallbackProviders",env:"KODAX_FALLBACK_PROVIDERS",value:r(e=>We(e.fallbackProviders),"value")},{configPath:"fastProvider",env:"KODAX_FAST_PROVIDER",value:r(e=>y(e.fastProvider),"value")},{configPath:"fastModel",env:"KODAX_FAST_MODEL",value:r(e=>y(e.fastModel),"value")},{configPath:"deepProvider",env:"KODAX_DEEP_PROVIDER",value:r(e=>y(e.deepProvider),"value")},{configPath:"deepModel",env:"KODAX_DEEP_MODEL",value:r(e=>y(e.deepModel),"value")},{configPath:"provider",env:"KODAX_PROVIDER",value:r(e=>y(e.provider),"value")},{configPath:"effort",env:"KODAX_EFFORT",value:r(e=>y(e.effort),"value")},{configPath:"runtimeMode",env:"KODAX_RUNTIME_MODE",value:r(e=>e.runtimeMode,"value")},{configPath:"sessionRetentionDays",env:"KODAX_SESSION_RETENTION_DAYS",value:r(e=>b(e.sessionRetentionDays),"value")},{configPath:"maxOutputTokens",env:"KODAX_MAX_OUTPUT_TOKENS",value:r(e=>b(e.maxOutputTokens),"value")},{configPath:"disablePromptCache",env:"KODAX_DISABLE_PROMPT_CACHE",value:r(e=>O(e.disablePromptCache),"value")},{configPath:"lsp",env:"KODAX_LSP",value:r(e=>O(e.lsp),"value")},{configPath:"lspAutoDownload",env:"KODAX_LSP_DOWNLOAD",value:r(e=>O(e.lspAutoDownload),"value")},{configPath:"acpLogLevel",env:"KODAX_ACP_LOG",value:r(e=>y(e.acpLogLevel),"value")},{configPath:"repoIntelligence.toolWaitMs",env:"KODAX_REPO_INTELLIGENCE_TOOL_WAIT_MS",value:r(e=>b(e.repoIntelligence?.toolWaitMs),"value")},{configPath:"repoIntelligence.workerTimeoutMs",env:"KODAX_REPO_INTELLIGENCE_WORKER_TIMEOUT_MS",value:r(e=>b(e.repoIntelligence?.workerTimeoutMs),"value")},{configPath:"repoIntelligence.workerOldSpaceMb",env:"KODAX_REPO_INTELLIGENCE_WORKER_OLD_SPACE_MB",value:r(e=>b(e.repoIntelligence?.workerOldSpaceMb),"value")},{configPath:"repoIntelligence.storageDir",env:"KODAX_REPO_INTELLIGENCE_STORAGE_DIR",value:r(e=>y(e.repoIntelligence?.storageDir),"value")},{configPath:"workflow.maxConcurrency",env:"KODAX_WORKFLOW_MAX_CONCURRENCY",value:r(e=>b(e.workflow?.maxConcurrency),"value")},{configPath:"sandbox.envPass",env:"KODAX_SANDBOX_ENV_PASS",value:r(e=>We(e.sandbox?.envPass)||void 0,"value")}];function Ht(e){for(let t of Be)Gt(t.env,t.value(e))}r(Ht,"applyConfigSurfaceBridges");function y(e){return e?.trim()||void 0}r(y,"normalizedConfigString");function b(e){return typeof e=="number"&&Number.isFinite(e)?String(e):void 0}r(b,"configNumberString");function O(e){return e===void 0?void 0:e?"1":"0"}r(O,"configBooleanString");function We(e){return e?.filter(t=>t.trim().length>0).join(",")}r(We,"configStringList");var Kn=[...Be.map(({configPath:e,env:t})=>({configPath:e,env:t}))];function Vt(e){Ht(e)}r(Vt,"applyConfigEnvironment");function Xn(){_t();let e=fe();return Vt(e),Mt(e),Me(e.locale),e}r(Xn,"prepareRuntimeConfig");function Fn(e){let{extensions:t,mcpServers:n,...o}=e;if(E(p,()=>{let i={};if(m.existsSync(p))try{let a=JSON.parse(m.readFileSync(p,"utf8"));a&&typeof a=="object"&&!Array.isArray(a)&&(i=a)}catch{}let s={...i,...o};for(let a of Object.keys(o))o[a]===void 0&&delete s[a];m.writeFileSync(p,JSON.stringify(s,null,2))}),t!==void 0){let i=U(u);T({domain:"extensions",configHome:u,...i.source==="user"?{expectedRevision:i.revision}:{},document:{version:1,paths:le(t)??[]},validate:C})}if(n!==void 0){let i=F(u);T({domain:"mcp",configHome:u,...i.source==="user"?{expectedRevision:i.revision}:{},document:{version:1,servers:n},validate:S})}}r(Fn,"saveConfig");function Un(e,t,n){return e.effort!==void 0||q(n).kind==="value"||t.effort!==void 0}r(Un,"resolveInitialEffortOverride");function w(e){return e?.trim()?e:void 0}r(w,"nonEmptySelection");function Wn(e){return w(e.explicitProvider)??w(e.environmentProvider)??w(e.configuredProvider)??e.defaultProvider}r(Wn,"resolveRuntimeProviderSelection");function Gn(e){let t=w(e.explicitModel);if(t)return t;let n=w(e.configuredModel);if(!n)return;let o=w(e.explicitProvider)??w(e.environmentProvider);return o?w(e.configuredProvider)===o?n:void 0:n}r(Gn,"resolveRuntimeModelSelection");function Hn(e){if(e.explicitEffort!==void 0)return B(e.explicitEffort);let t=q(e.environmentEffort);return t.kind==="value"?t.value:e.configuredEffort===void 0?void 0:B(e.configuredEffort)}r(Hn,"resolveRuntimeEffortSelection");function zt(e){return e.permissionMode==="plan"&&e.effortOverride!==!0&&e.planModeEffort!==void 0?e.planModeEffort:e.effort}r(zt,"resolvePermissionModeEffort");async function Vn(e){try{let{stdout:t}=await bt("git rev-parse --show-toplevel",{cwd:e,windowsHide:!0});return t.trim()}catch{return null}}r(Vn,"getGitRoot");function Bt(e){switch(e){case"builtin":return"Built-in";case"runtime":return"Runtime extension";case"custom":return"Custom config";default:return"Unknown"}}r(Bt,"formatProviderSourceKind");function zn(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: ${Bt(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: ${Kt(e.reasoningCapability)}`]}r(zn,"formatProviderCapabilityDetailLines");function Bn(e,t,n){return[{label:"General coding",hints:{}},{label:"Evidence-heavy review",hints:{evidenceHeavy:!0}},{label:"Long-running task",hints:{longRunning:!0}}].map(i=>({label:i.label,decision:$t(e,t,n,i.hints)})).filter(i=>i.decision!==null)}r(Bn,"getProviderCommonPolicyScenarios");var Ge=.5,He=0,D={locked:!1,queue:[]};async function qn(e){for(;D.locked;)await new Promise(t=>D.queue.push(t));D.locked=!0;try{let t=(Date.now()-He)/1e3;t<Ge&&await new Promise(o=>setTimeout(o,(Ge-t)*1e3));let n=await e();return He=Date.now(),n}finally{D.locked=!1;let t=D.queue.shift();t&&t()}}r(qn,"rateLimitedCall");export{qt as a,Ae as b,Oe as c,ee as d,nt as e,E as f,k as g,S as h,C as i,_ as j,F as k,U as l,ft as m,ln as n,T as o,De as p,u as q,kn as r,p as s,Sn as t,Ct as u,Cn as v,Mt as w,Rt as x,_n as y,Tt as z,Dt as A,Lt as B,Nt as C,Mn as D,$t as E,An as F,On as G,I as H,In as I,Rn as J,Tn as K,Dn as L,Kt as M,Ln as N,Nn as O,$n as P,fe as Q,Ft as R,ae as S,Wt as T,jn as U,Kn as V,Vt as W,Xn as X,Fn as Y,Un as Z,Wn as _,Gn as $,Hn as aa,zt as ba,Vn as ca,Bt as da,zn as ea,Bn as fa,qn as ga};
|
|
278
|
+
`,c=`${t}.${process.pid}.${Date.now()}.tmp`,l=ie(c,"wx",384);try{je(l,a,"utf8"),Le(l)}finally{ne(l)}try{e.expectedRevision===null?(rt(c,t),j(c)):$e(c,t)}catch(g){throw d(c)&&j(c),e.expectedRevision===null&&d(t)?new k(t,void 0,Re(t)):new Error(`Failed to atomically replace ${f.basename(t)}.`,{cause:g})}return M({domain:e.domain,source:"user",path:t,raw:a,document:n})}finally{ne(o.fd),d(o.path)&&j(o.path)}}r(T,"writeIntegrationDocument");function vt(e){if(!d(e))return"missing";let t=it(e);return`${t.dev}:${t.ino}:${t.size}:${t.mtimeMs}`}r(vt,"metadataSignature");function Te(e){return e.map(t=>`${t}:${vt(t)}`).join("|")}r(Te,"observationSignature");function $(e,t){return{code:e,message:t,time:new Date().toISOString()}}r($,"safeDiagnostic");var De=class{static{r(this,"IntegrationConfigController")}#u;#n;#r;#a;#m;#f;#p;#e;#t;#c;#l;#h="";#s=[];#o;#i;#g=Promise.resolve();#d=new Set;constructor(t){this.#u=t.domain,this.#n=_(t.domain,t.configHome),this.#r=t.fallbackPath===void 0?void 0:f.resolve(t.fallbackPath),this.#a=this.#r===void 0?[this.#n]:[this.#n,this.#r],this.#f=t.validate,this.#m=t.read,this.#p=t.coldStartDefault===void 0?void 0:structuredClone(this.#f(t.coldStartDefault))}async initialize(){let t=await this.reload();if(!t.ok&&!this.#e&&this.#p!==void 0){let n=structuredClone(this.#p);this.#e=M({domain:this.#u,source:"default",path:this.#n,raw:JSON.stringify(n),document:n})}if(!this.#e)throw new Error(t.ok?"Integration configuration did not produce a snapshot.":t.error);return structuredClone(this.#e)}snapshot(){return this.#e?structuredClone(this.#e):void 0}status(){let t=this.#t?this.#c:void 0,n=this.#t?this.#l:void 0;return{domain:this.#u,path:t??this.#e?.path??this.#n,...this.#e?{revision:this.#e.revision,lastReloadAt:this.#e.loadedAt}:{},...n??this.#e?.source?{source:n??this.#e?.source}:{},...this.#t?{diagnostic:this.#t}:{},watching:this.#s.length>0}}subscribe(t){return this.#d.add(t),()=>{this.#d.delete(t)}}reload(){let t=this.#g.then(()=>this.#v());return this.#g=t.then(()=>{},()=>{}),t}async#v(){this.#h=Te(this.#a);let t;try{t=this.#m(),this.#f(t.document)}catch{let o=this.#y();return this.#c=o.path,this.#l=o.source,this.#t=$("invalid-config","Integration configuration is invalid; check the file against its versioned schema."),{ok:!1,error:this.#t.message}}let n=this.#e?structuredClone(this.#e):void 0;try{for(let o of this.#d)await o(structuredClone(t),n)}catch{return this.#c=t.path,this.#l=t.source,this.#t=$("activation-failed","Integration configuration could not be activated; the previous configuration remains active."),{ok:!1,error:this.#t.message}}return this.#e=t,this.#t=void 0,this.#c=void 0,this.#l=void 0,{ok:!0,snapshot:structuredClone(t)}}async ensureCurrent(){return Te(this.#a)===this.#h&&this.#e?{ok:!0,snapshot:structuredClone(this.#e)}:this.reload()}startWatching(t=100,n=2e3){if(this.#s.length>0||this.#i)return;re(f.dirname(this.#n),{recursive:!0,mode:448});let o=new Map;for(let i of this.#a){let s=f.dirname(i),a=o.get(s)??new Set;a.add(f.basename(i)),o.set(s,a)}for(let[i,s]of o)try{let a=st(i,(c,l)=>{l!==null&&!s.has(l.toString())||(this.#o&&clearTimeout(this.#o),this.#o=setTimeout(()=>{this.#o=void 0,this.reload()},t),this.#o.unref?.())});a.unref(),a.on("error",()=>{this.#t=$("watcher-degraded","Integration watcher is degraded; metadata polling remains active.")}),this.#s.push(a)}catch{this.#t=$("watcher-degraded","Integration watcher is degraded; metadata polling remains active.")}this.#i=setInterval(()=>{this.ensureCurrent()},n),this.#i.unref?.()}close(){this.#o&&clearTimeout(this.#o),this.#o=void 0,this.#i&&clearInterval(this.#i),this.#i=void 0;for(let t of this.#s)t.close();this.#s.length=0,this.#d.clear()}#y(){return d(this.#n)?{path:this.#n,source:"user"}:this.#r&&d(this.#r)?{path:this.#r,source:"legacy-user"}:{path:this.#n,source:"default"}}};var bt=Et(yt),Fe=2,Ue=!1,u=Pe(),kn=h.join(u,"sessions"),p=h.join(u,"config.json"),Sn=60,v=null,ce=!1,Pt="dumb";function kt(e){let t=h.basename(e).toLowerCase(),n="__KODAX_SHELL_ENV_START__",o=`printf '%s\\0' '${n}'; env -0`;return t==="fish"?{args:["-i","-c",o],sentinel:n}:{args:t==="bash"||t==="zsh"?["-ic",o]:["-lc",o],sentinel:n}}r(kt,"buildShellEnvCommand");function St(e,t){let n=`${t}\0`,o=e.lastIndexOf(n);if(o===-1)return{};let i=e.slice(o+n.length),s={};for(let a of i.split("\0")){if(!a)continue;let c=a.indexOf("=");c<=0||(s[a.slice(0,c)]=a.slice(c+1))}return s}r(St,"parseNullDelimitedShellEnv");function Ct(e={}){let t=e.env??process.env;if((e.platform??process.platform)==="win32"||t.KODAX_DISABLE_SHELL_ENV_HYDRATION==="1")return!1;let o=e.shell??t.SHELL;if(!o||!h.isAbsolute(o))return!1;let{args:i,sentinel:s}=kt(o),a=e.run??wt,c={...t,TERM:Pt},l=a(o,i,{encoding:"utf8",env:c,maxBuffer:1024*1024,timeout:5e3,windowsHide:!0,detached:!0,stdio:["ignore","pipe","pipe"]});if(l.status!==0||!l.stdout)return!1;let g=typeof l.stdout=="string"?l.stdout:l.stdout.toString("utf8"),L=St(g,s),N=!1;for(let[z,qe]of Object.entries(L))z!=="TERM"&&t[z]===void 0&&(t[z]=qe,N=!0);return N}r(Ct,"hydrateProcessEnvFromShell");function _t(){if(!ce){ce=!0;try{Ct()}catch{}}}r(_t,"ensureShellEnvironmentHydrated");function Cn(){ce=!1}r(Cn,"resetShellEnvironmentHydrationForTesting");function Mt(e){Ee(e.customProviders??[])}r(Mt,"registerConfiguredCustomProviders");function le(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:[]}r(le,"normalizeConfiguredExtensions");function At(e){if(e===void 0||e===null||typeof e!="object"||Array.isArray(e))return;let t=e.envPass;if(!Array.isArray(t))return;let n=t.filter(o=>typeof o=="string").map(o=>o.trim()).filter(o=>/^[A-Za-z_][A-Za-z0-9_]*$/.test(o));return{envPass:[...new Set(n)]}}r(At,"normalizeSandboxConfig");function ue(){let e=m.readFileSync(p,"utf8"),t=JSON.parse(e);if(!(t===null||typeof t!="object"||Array.isArray(t)))return{raw:e,value:t}}r(ue,"readPersistedCoreConfig");function Ve(e){m.writeFileSync(p,JSON.stringify(e,null,2))}r(Ve,"writePersistedCoreConfig");function Ot(e){if(e.permissionMode!=="default")return e;let t={...e,permissionMode:"accept-edits"};try{E(p,()=>{let n=ue();n?.value.permissionMode==="default"&&Ve({...n.value,permissionMode:"accept-edits"})})}catch{}return t}r(Ot,"migrateLegacyPermissionModeInConfig");function It(e){if(e.permissionMode!=="auto-in-project")return e;try{E(p,()=>{let t=ue();if(t?.value.permissionMode!=="auto-in-project")return;let n=t.raw.replace(/("permissionMode"\s*:\s*)"auto-in-project"/,'$1"auto"');n!==t.raw&&m.writeFileSync(p,n)})}catch{}return{...e,permissionMode:"auto"}}r(It,"migrateAutoInProjectAliasInConfig");function Rt(){if(v)return v;let e="0.7.83";if(e)return v=e,v;let t=h.join(h.dirname(xt(import.meta.url)),"../../package.json");if(m.existsSync(t))try{return v=JSON.parse(m.readFileSync(t,"utf-8")).version??"0.0.0",v??"0.0.0"}catch{}return v="0.0.0",v}r(Rt,"getVersion");var _n=Rt();function Tt(e){return ge(e)}r(Tt,"getProviderModel");function de(e,t){let n=new Set(e.map(i=>i.toLowerCase())),o=[...e];for(let i of t)n.has(i.toLowerCase())||o.push(i);return o}r(de,"mergeModels");function Dt(e,t){t||(t=fe().providerModels);let n=t?.[e];if(n&&n.length>0){try{let o=Y(e);if(o.length>0)return de(n,o)}catch{}try{let o=R(e);if(o)return de(n,o.getAvailableModels())}catch{}return n}try{let o=Y(e);if(o.length>0)return o}catch{}try{let o=R(e);if(o)return o.getAvailableModels()}catch{}return[]}r(Dt,"getProviderAvailableModels");function Lt(e,t){let n=ve(e,t);if(n!=="unknown")return n;try{let o=R(e);if(o)return o.getReasoningCapability(t)}catch{}return"unknown"}r(Lt,"getProviderReasoningCapability");function Nt(e){let t=ye(e);if(t)return t;try{return Z().find(o=>o.name===e)?.capabilityProfile??null}catch{return null}}r(Nt,"getProviderCapabilityProfile");function ze(e,t){let n=Nt(e),o=Lt(e,t);if(n)return{capabilityProfile:n,reasoningCapability:o};try{let i=xe(e);return{capabilityProfile:i.getCapabilityProfile(),reasoningCapability:i.getReasoningCapability(t)}}catch{return null}}r(ze,"getProviderCapabilityMetadata");function Mn(e,t){let n=ze(e,t);return n?Se({providerName:e,model:t,capabilityProfile:n.capabilityProfile,reasoningCapability:n.reasoningCapability==="unknown"?void 0:n.reasoningCapability}):null}r(Mn,"getProviderCapabilitySnapshot");function $t(e,t,n,o){let i=ze(e,t);return i?Ce({providerName:e,model:t,capabilityProfile:i.capabilityProfile,reasoningCapability:i.reasoningCapability==="unknown"?void 0:i.reasoningCapability,reasoningMode:n,hints:o}):null}r($t,"getProviderPolicyDecision");function An(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",o=e.mcpSupport==="native"?"MCP available":"MCP unavailable";return`${t}; ${n}; ${o}`}r(An,"describeProviderCapabilitySummary");function On(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"-"}}r(On,"formatReasoningCapabilityShort");function I(e){if(e)return e==="none"?"off":e}r(I,"formatReasoningEffortForDisplay");function G(e,t){let n=I(t);n&&!e.includes(n)&&e.push(n)}r(G,"pushUniqueEffortDisplay");function In(e,t){let n=["auto"],i=V(e,t)?.supportedEfforts?.filter(s=>s.isUserVisible!==!1);if(!i||i.length===0){for(let s of["off","low","medium","high"])G(n,s);return n}for(let s of i)G(n,s.value);return n}r(In,"getProviderReasoningEffortOptions");function Rn(e,t){let n=V(e,t),o=new Set(n?.disabledEfforts??[]),i=n?.supportedEfforts?.filter(l=>l.isUserVisible!==!1),s=[],a=n?.supportsDisabledThinking===!0;if(!i||i.length===0){for(let l of["low","medium","high"])G(s,l);a=!0}else for(let l of i){if(l.value==="none"){a=!0;continue}if(o.has(l.value)){a=!0;continue}G(s,l.value)}let c=[];return a&&c.push("off"),c.push(...s),c.push("auto"),c}r(Rn,"getProviderReasoningEffortCycle");function jt(e,t){if(t===!1)return"off";switch(e){case"off":return"off";case"quick":return"low";case"balanced":return"medium";case"deep":return"high";default:return"auto"}}r(jt,"legacyReasoningModeToEffortDisplay");function V(e,t){let n=t??Tt(e);if(!n)return;let o=be(e,n)?.reasoningProfile;if(o)return pe(o,ke(e,n))}r(V,"resolveReasoningProfileForDisplay");function Tn(e){let t=I(e.effort)??jt(e.reasoningMode,e.thinking),n=V(e.provider,e.model);if(!n)return t;try{let o=me({capability:n,explicitEffort:e.effortOverride?e.effort:void 0,sessionEffort:e.effortOverride?void 0:e.effort,legacyReasoningMode:e.reasoningMode,thinking:e.thinking}),i=I(o.configuredEffort)??t,a=o.configuredEffort!==void 0&&n.disabledEfforts?.includes(o.configuredEffort)===!0?"off":I(o.effectiveEffort);return a&&a!==i?`${i}->${a}`:i}catch{if(e.effort)try{let o=J({currentEffort:e.effort,capability:n}),i=I(e.effort)??t,s=I(o.effectiveEffort);return s&&s!==i?`${i}->${s}`:i}catch{return t}return t}}r(Tn,"formatReasoningEffortStatusLabel");function Dn(e){let t=zt(e);if(!t)return{preserved:!0};let n=V(e.provider,e.model);if(!n)return{configuredEffort:t,runtimeEffort:t,preserved:!0};let o=J({currentEffort:t,capability:n});return{configuredEffort:t,runtimeEffort:o.effectiveEffort,preserved:o.preserved,diagnostic:o.diagnostic}}r(Dn,"resolveProviderReasoningRuntimeEffort");function Kt(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"}}r(Kt,"describeReasoningCapabilityControl");function Ln(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"}}r(Ln,"describeReasoningExecution");function Nn(e){let t=[];e||(e=fe().providerModels);for(let n of we())t.push({name:n.name,model:n.model,models:Dt(n.name,e),configured:n.capabilityProfile.transport==="cli-bridge"?!0:n.configured,reasoningCapability:n.reasoningCapability,capabilityProfile:n.capabilityProfile});try{let n=Z().map(o=>({...o,models:(()=>{let i=e?.[o.name];return i&&i.length>0?de(i,o.models):o.models})()}));t.push(...n)}catch{}return t}r(Nn,"getProviderList");function $n(e){if(he(e))return!0;try{return R(e)?.isConfigured()??!1}catch{return!1}}r($n,"isProviderConfigured");var H=class extends Error{static{r(this,"InvalidAgentModeConfigError")}};function Xt(e){let t=e.agentMode;if(t===void 0||t==="ama"||t==="sa")return e;if(t!=="amaw"&&t!=="ama-workflow")throw new H(`Invalid agentMode "${t}" in ${p}. Expected "ama" or "sa".`);let n={...e,agentMode:"ama",schemaVersion:Math.max(e.schemaVersion??0,Fe)};try{E(p,()=>{let o=ue();if(!o)return;let i=o.value.agentMode;i!=="amaw"&&i!=="ama-workflow"||Ve({...o.value,agentMode:"ama",schemaVersion:Math.max(typeof o.value.schemaVersion=="number"?o.value.schemaVersion:0,Fe)})})}catch{}return Ue||(process.emitWarning(`Migrated persisted agentMode "${t}" to "ama". Workflow use is now explicit intent.`,{code:"KODAX_AGENT_MODE_MIGRATED"}),Ue=!0),n}r(Xt,"migrateLegacyAgentModeConfig");function fe(){try{if(m.existsSync(p)){let n=JSON.parse(m.readFileSync(p,"utf-8")),o=Xt(n),i=o.reasoningCeiling??o.reasoningMode,s=[],a={};try{s=[...U(u).document.paths]}catch{}try{a=F(u).document.servers}catch{}return It(Ot({...o,reasoningMode:i,extensions:le(s),mcpServers:a,sandbox:At(o.sandbox)}))}}catch(n){if(n instanceof H)throw n}let e,t;try{let n=U(u);n.source!=="default"&&(e=le([...n.document.paths]))}catch{}try{let n=F(u);n.source!=="default"&&(t=n.document.servers)}catch{}return{...e===void 0?{}:{extensions:e},...t===void 0?{}:{mcpServers:t}}}r(fe,"loadConfig");var Ft=h.join(u,"config.example.jsonc"),ae={mcp:h.join(u,"integrations","mcp.example.jsonc"),a2a:h.join(u,"integrations","a2a.example.jsonc"),extensions:h.join(u,"integrations","extensions.example.jsonc")},Ut=[{name:"core",path:Ft},{name:"mcp",path:ae.mcp},{name:"a2a",path:ae.a2a},{name:"extensions",path:ae.extensions}];function Wt(){let e=[];for(let t of Ut)try{if(m.existsSync(t.path))continue;m.mkdirSync(h.dirname(t.path),{recursive:!0}),m.writeFileSync(t.path,Oe(t.name),"utf8"),e.push(t.path)}catch{}return e}r(Wt,"ensureExampleConfigFiles");function jn(){return Wt()[0]}r(jn,"ensureExampleConfigFile");var W=new Map;function Gt(e,t){let n=process.env[e],o=W.get(e),i=o!==void 0&&n===o;if(n!==void 0&&!i){W.delete(e);return}if(t===void 0){i&&delete process.env[e],W.delete(e);return}process.env[e]=t,W.set(e,t)}r(Gt,"projectConfigEnvironment");var Be=[{configPath:"streamIdleTimeoutMs",env:"KODAX_STREAM_IDLE_TIMEOUT_MS",value:r(e=>b(e.streamIdleTimeoutMs),"value")},{configPath:"repoIntelligenceMode",env:"KODAX_REPO_INTELLIGENCE",value:r(e=>e.repoIntelligenceMode,"value")},{configPath:"repoIntelligenceTrace",env:"KODAX_REPO_INTELLIGENCE_TRACE",value:r(e=>O(e.repoIntelligenceTrace),"value")},{configPath:"verifierLog",env:"KODAX_VERIFIER_LOG",value:r(e=>O(e.verifierLog),"value")},{configPath:"stallLog",env:"KODAX_STALL_LOG",value:r(e=>O(e.stallLog),"value")},{configPath:"fallbackProviders",env:"KODAX_FALLBACK_PROVIDERS",value:r(e=>We(e.fallbackProviders),"value")},{configPath:"fastProvider",env:"KODAX_FAST_PROVIDER",value:r(e=>y(e.fastProvider),"value")},{configPath:"fastModel",env:"KODAX_FAST_MODEL",value:r(e=>y(e.fastModel),"value")},{configPath:"deepProvider",env:"KODAX_DEEP_PROVIDER",value:r(e=>y(e.deepProvider),"value")},{configPath:"deepModel",env:"KODAX_DEEP_MODEL",value:r(e=>y(e.deepModel),"value")},{configPath:"provider",env:"KODAX_PROVIDER",value:r(e=>y(e.provider),"value")},{configPath:"effort",env:"KODAX_EFFORT",value:r(e=>y(e.effort),"value")},{configPath:"runtimeMode",env:"KODAX_RUNTIME_MODE",value:r(e=>e.runtimeMode,"value")},{configPath:"sessionRetentionDays",env:"KODAX_SESSION_RETENTION_DAYS",value:r(e=>b(e.sessionRetentionDays),"value")},{configPath:"maxOutputTokens",env:"KODAX_MAX_OUTPUT_TOKENS",value:r(e=>b(e.maxOutputTokens),"value")},{configPath:"disablePromptCache",env:"KODAX_DISABLE_PROMPT_CACHE",value:r(e=>O(e.disablePromptCache),"value")},{configPath:"lsp",env:"KODAX_LSP",value:r(e=>O(e.lsp),"value")},{configPath:"lspAutoDownload",env:"KODAX_LSP_DOWNLOAD",value:r(e=>O(e.lspAutoDownload),"value")},{configPath:"acpLogLevel",env:"KODAX_ACP_LOG",value:r(e=>y(e.acpLogLevel),"value")},{configPath:"repoIntelligence.toolWaitMs",env:"KODAX_REPO_INTELLIGENCE_TOOL_WAIT_MS",value:r(e=>b(e.repoIntelligence?.toolWaitMs),"value")},{configPath:"repoIntelligence.workerTimeoutMs",env:"KODAX_REPO_INTELLIGENCE_WORKER_TIMEOUT_MS",value:r(e=>b(e.repoIntelligence?.workerTimeoutMs),"value")},{configPath:"repoIntelligence.workerOldSpaceMb",env:"KODAX_REPO_INTELLIGENCE_WORKER_OLD_SPACE_MB",value:r(e=>b(e.repoIntelligence?.workerOldSpaceMb),"value")},{configPath:"repoIntelligence.storageDir",env:"KODAX_REPO_INTELLIGENCE_STORAGE_DIR",value:r(e=>y(e.repoIntelligence?.storageDir),"value")},{configPath:"workflow.maxConcurrency",env:"KODAX_WORKFLOW_MAX_CONCURRENCY",value:r(e=>b(e.workflow?.maxConcurrency),"value")},{configPath:"sandbox.envPass",env:"KODAX_SANDBOX_ENV_PASS",value:r(e=>We(e.sandbox?.envPass)||void 0,"value")}];function Ht(e){for(let t of Be)Gt(t.env,t.value(e))}r(Ht,"applyConfigSurfaceBridges");function y(e){return e?.trim()||void 0}r(y,"normalizedConfigString");function b(e){return typeof e=="number"&&Number.isFinite(e)?String(e):void 0}r(b,"configNumberString");function O(e){return e===void 0?void 0:e?"1":"0"}r(O,"configBooleanString");function We(e){return e?.filter(t=>t.trim().length>0).join(",")}r(We,"configStringList");var Kn=[...Be.map(({configPath:e,env:t})=>({configPath:e,env:t}))];function Vt(e){Ht(e)}r(Vt,"applyConfigEnvironment");function Xn(){_t();let e=fe();return Vt(e),Mt(e),Me(e.locale),e}r(Xn,"prepareRuntimeConfig");function Fn(e){let{extensions:t,mcpServers:n,...o}=e;if(E(p,()=>{let i={};if(m.existsSync(p))try{let a=JSON.parse(m.readFileSync(p,"utf8"));a&&typeof a=="object"&&!Array.isArray(a)&&(i=a)}catch{}let s={...i,...o};for(let a of Object.keys(o))o[a]===void 0&&delete s[a];m.writeFileSync(p,JSON.stringify(s,null,2))}),t!==void 0){let i=U(u);T({domain:"extensions",configHome:u,...i.source==="user"?{expectedRevision:i.revision}:{},document:{version:1,paths:le(t)??[]},validate:C})}if(n!==void 0){let i=F(u);T({domain:"mcp",configHome:u,...i.source==="user"?{expectedRevision:i.revision}:{},document:{version:1,servers:n},validate:S})}}r(Fn,"saveConfig");function Un(e,t,n){return e.effort!==void 0||q(n).kind==="value"||t.effort!==void 0}r(Un,"resolveInitialEffortOverride");function w(e){return e?.trim()?e:void 0}r(w,"nonEmptySelection");function Wn(e){return w(e.explicitProvider)??w(e.environmentProvider)??w(e.configuredProvider)??e.defaultProvider}r(Wn,"resolveRuntimeProviderSelection");function Gn(e){let t=w(e.explicitModel);if(t)return t;let n=w(e.configuredModel);if(!n)return;let o=w(e.explicitProvider)??w(e.environmentProvider);return o?w(e.configuredProvider)===o?n:void 0:n}r(Gn,"resolveRuntimeModelSelection");function Hn(e){if(e.explicitEffort!==void 0)return B(e.explicitEffort);let t=q(e.environmentEffort);return t.kind==="value"?t.value:e.configuredEffort===void 0?void 0:B(e.configuredEffort)}r(Hn,"resolveRuntimeEffortSelection");function zt(e){return e.permissionMode==="plan"&&e.effortOverride!==!0&&e.planModeEffort!==void 0?e.planModeEffort:e.effort}r(zt,"resolvePermissionModeEffort");async function Vn(e){try{let{stdout:t}=await bt("git rev-parse --show-toplevel",{cwd:e,windowsHide:!0});return t.trim()}catch{return null}}r(Vn,"getGitRoot");function Bt(e){switch(e){case"builtin":return"Built-in";case"runtime":return"Runtime extension";case"custom":return"Custom config";default:return"Unknown"}}r(Bt,"formatProviderSourceKind");function zn(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: ${Bt(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: ${Kt(e.reasoningCapability)}`]}r(zn,"formatProviderCapabilityDetailLines");function Bn(e,t,n){return[{label:"General coding",hints:{}},{label:"Evidence-heavy review",hints:{evidenceHeavy:!0}},{label:"Long-running task",hints:{longRunning:!0}}].map(i=>({label:i.label,decision:$t(e,t,n,i.hints)})).filter(i=>i.decision!==null)}r(Bn,"getProviderCommonPolicyScenarios");var Ge=.5,He=0,D={locked:!1,queue:[]};async function qn(e){for(;D.locked;)await new Promise(t=>D.queue.push(t));D.locked=!0;try{let t=(Date.now()-He)/1e3;t<Ge&&await new Promise(o=>setTimeout(o,(Ge-t)*1e3));let n=await e();return He=Date.now(),n}finally{D.locked=!1;let t=D.queue.shift();t&&t()}}r(qn,"rateLimitedCall");export{qt as a,Ae as b,Oe as c,ee as d,nt as e,E as f,k as g,S as h,C as i,_ as j,F as k,U as l,ft as m,ln as n,T as o,De as p,u as q,kn as r,p as s,Sn as t,Ct as u,Cn as v,Mt as w,Rt as x,_n as y,Tt as z,Dt as A,Lt as B,Nt as C,Mn as D,$t as E,An as F,On as G,I as H,In as I,Rn as J,Tn as K,Dn as L,Kt as M,Ln as N,Nn as O,$n as P,fe as Q,Ft as R,ae as S,Wt as T,jn as U,Kn as V,Vt as W,Xn as X,Fn as Y,Un as Z,Wn as _,Gn as $,Hn as aa,zt as ba,Vn as ca,Bt as da,zn as ea,Bn as fa,qn as ga};
|