@kodax-ai/kodax 0.7.96-beta.7 → 0.7.96-beta.8
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 +18 -0
- package/README.md +9 -1
- package/README_CN.md +7 -1
- package/dist/chunks/{agent-MUNSGDNO.js → agent-XBT4ZUCG.js} +1 -1
- package/dist/chunks/argument-completer-WF7FTTWB.js +2 -0
- package/dist/chunks/{chunk-7SAZJDEK.js → chunk-57PKLDQI.js} +1 -1
- package/dist/chunks/{chunk-UGYCXOTE.js → chunk-6ABV6WUL.js} +1 -1
- package/dist/chunks/{chunk-ZSJJECST.js → chunk-DGMNCSI3.js} +1 -1
- package/dist/chunks/{chunk-HXH5TOAV.js → chunk-FZUPRAHK.js} +1 -1
- package/dist/chunks/{chunk-LCGEVHAP.js → chunk-HFTCGOBB.js} +2 -2
- package/dist/chunks/{chunk-VLYL7HSL.js → chunk-JBOJY7LE.js} +1 -1
- package/dist/chunks/{chunk-H6NNJO5M.js → chunk-KHPUDIG7.js} +4 -4
- package/dist/chunks/chunk-MO3TCAKM.js +384 -0
- package/dist/chunks/chunk-P4OGLGQF.js +321 -0
- package/dist/chunks/{chunk-3YOSYV3S.js → chunk-R6JRHSQR.js} +1 -1
- package/dist/chunks/{chunk-B4FK5XVU.js → chunk-ROSCR2VP.js} +2 -2
- package/dist/chunks/{chunk-4KYG5QCO.js → chunk-VNTIH7QD.js} +1 -1
- package/dist/chunks/{chunk-NIGQTWGU.js → chunk-WAKPBFEA.js} +2 -2
- package/dist/chunks/{chunk-POVUU6P2.js → chunk-ZMXVACRD.js} +1 -1
- package/dist/chunks/{construction-bootstrap-CETEMU4E.js → construction-bootstrap-JWUX7O3Z.js} +1 -1
- package/dist/chunks/{dist-EZMYRAZF.js → dist-7K3VYIPU.js} +1 -1
- package/dist/chunks/{host-34WITC4H.js → host-CZG5BNSF.js} +1 -1
- package/dist/chunks/{run-manager-MPPLTV4V.js → run-manager-PIGUJW3L.js} +1 -1
- package/dist/chunks/{utils-VHU6GKSZ.js → utils-VEOO7TBI.js} +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/kodax_bootstrap.js +1 -1
- package/dist/kodax_cli.js +1242 -1240
- package/dist/native/win32-x64/kodax-windows-sandbox.exe +0 -0
- package/dist/native/win32-x64/kodax-windows-text-transaction.node +0 -0
- package/dist/native/win32-x64/manifest.json +2 -2
- package/dist/runtime-worker.js +1132 -1130
- package/dist/sdk-a2a.d.ts +2 -2
- package/dist/sdk-a2a.js +1 -1
- package/dist/sdk-coding.js +1 -1
- package/dist/sdk-repl.d.ts +6 -6
- package/dist/sdk-repl.js +1 -1
- package/dist/sdk-runtime.d.ts +25 -5
- package/dist/sdk-runtime.js +1 -1
- package/dist/sdk-sandbox.js +1 -1
- package/dist/sdk-session.d.ts +2 -2
- package/dist/sdk-session.js +1 -1
- package/dist/types-chunks/{public-api.d-DaNnTFmp.d.ts → public-api.d-D9-qDqh8.d.ts} +29 -4
- package/dist/types-chunks/{sdk-session-DVAIxfbI.d.ts → sdk-session-DpYJAre-.d.ts} +1 -1
- package/dist/types-chunks/{trusted-repl-entry-DdhLTgkI.d.ts → trusted-repl-entry-BLBfln-c.d.ts} +2 -2
- package/dist/types-chunks/{utils.d-7ADGZ4BM.d.ts → utils.d-BGPRMOUS.d.ts} +1 -1
- package/package.json +1 -1
- package/public_docs/README.md +2 -2
- package/public_docs/sdk/embedder-guide.md +2 -2
- package/dist/chunks/argument-completer-6TSU5AEB.js +0 -2
- package/dist/chunks/chunk-3SKK7NFC.js +0 -319
- package/dist/chunks/chunk-URJHQKP5.js +0 -384
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,24 @@ All notable changes to this project will be documented in this file.
|
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
11
|
+
## [0.7.96-beta.8] - 2026-09-11
|
|
12
|
+
|
|
13
|
+
Eighth beta pre-release of the v0.7.96 line: an explicit, audited opt-in for
|
|
14
|
+
legacy interrupt identities, retaining every beta.7 contract. npm
|
|
15
|
+
publication remains a manual maintainer action.
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- Add `runtime.sessions.confirmIdentityAlias` for explicitly confirmed legacy
|
|
20
|
+
interrupt identities. Registration verifies the original delivery receipt and
|
|
21
|
+
session revision, preserves an immutable audit record, and rejects competing
|
|
22
|
+
claims. Subsequent conversation, page and chunk reads apply the alias across
|
|
23
|
+
saves, compaction and restart; older caches rebuild. Original messages and
|
|
24
|
+
journal events remain intact. Unconfirmed historical identities are not inferred
|
|
25
|
+
from text, timestamps or turn IDs.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
11
29
|
## [0.7.96-beta.7] - 2026-09-11
|
|
12
30
|
|
|
13
31
|
The seventh beta pre-release of the v0.7.96 line: it carries every numbered-beta
|
package/README.md
CHANGED
|
@@ -784,6 +784,14 @@ provider's model, REPL `/compact` clears the UI only after a durable save, and
|
|
|
784
784
|
successful reports carry bounded `summaryRequests` plus `commitMs` per
|
|
785
785
|
physical summary call.
|
|
786
786
|
|
|
787
|
+
**v0.7.96-beta.8 release:** Adds `runtime.sessions.confirmIdentityAlias`
|
|
788
|
+
for explicitly confirmed legacy interrupt identities: registration verifies
|
|
789
|
+
the original delivery receipt and session revision, preserves an immutable
|
|
790
|
+
audit record, and rejects competing claims. The alias applies across saves,
|
|
791
|
+
compaction, restart, and pagination; original messages and journal events
|
|
792
|
+
stay intact, and unconfirmed historical identities are never inferred from
|
|
793
|
+
text, timestamps, or turn IDs.
|
|
794
|
+
|
|
787
795
|
**v0.7.96-beta.7 release:** The seventh beta pre-release of the v0.7.96 line. It
|
|
788
796
|
adds multimodal result fidelity — text/image tool results survive direct and
|
|
789
797
|
managed dispatch, Worker RPC, guardrails, capacity recovery, and MCP
|
|
@@ -841,7 +849,7 @@ requests, preserves structured Child Agent Provider failures, honors exact
|
|
|
841
849
|
run-scoped credential verification, and omits empty `tools` arrays for strict
|
|
842
850
|
vLLM gateways (Issues 329-332). npm publication remains a
|
|
843
851
|
manual maintainer action. See the
|
|
844
|
-
[release checklist](docs/release.md#v0796-
|
|
852
|
+
[release checklist](docs/release.md#v0796-beta8-release-preparation).
|
|
845
853
|
|
|
846
854
|
**v0.7.96-alpha.3 release:** Provider credentials are lazy, scoped,
|
|
847
855
|
revocable capabilities (ADR-068). The v2 credential broker keeps Provider
|
package/README_CN.md
CHANGED
|
@@ -296,6 +296,12 @@ SDK 系统代码契约更新,但没有放宽 shell/sandbox 的 fail-closed 边
|
|
|
296
296
|
`handleRuntimePermissionRequest()` 管理 SDK 权限 UI,并在 prepared Session 尾部遇到
|
|
297
297
|
`data_changed` 时通过权威 delta 合并恢复;后台持久化失败会显示为诊断,不再静默丢失。
|
|
298
298
|
|
|
299
|
+
**v0.7.96-beta.8 发布**:新增 `runtime.sessions.confirmIdentityAlias`,
|
|
300
|
+
用于显式确认的遗留中断标识:注册时验证原始投递回执与 session revision,
|
|
301
|
+
保留不可变审计记录并拒绝竞争声明。别名跨保存、压缩、重启与分页生效;
|
|
302
|
+
原始消息与 journal 事件保持不变,且绝不从文本、时间戳或 turn ID 推断
|
|
303
|
+
未确认的历史标识。
|
|
304
|
+
|
|
299
305
|
**v0.7.96-beta.7 发布**:新增多模态结果保真——
|
|
300
306
|
文本/图片工具结果在直接与托管分发、Worker RPC、guardrail、容量恢复与 MCP
|
|
301
307
|
适配器中完整保留(MCP 图片持久化为附件);本地执行失败以类型化错误贯穿
|
|
@@ -356,7 +362,7 @@ scope 在 SDK、Agent 摘要、CLI 与 Runtime Worker 请求间共享,保留
|
|
|
356
362
|
失败信息,精确遵循 run-scoped 凭据校验,并为严格 vLLM 网关省略空 `tools` 数组(Issues 329-332)。
|
|
357
363
|
npm 发布仍由
|
|
358
364
|
npm 发布仍由
|
|
359
|
-
维护者手动执行。详见 [v0.7.96-beta.
|
|
365
|
+
维护者手动执行。详见 [v0.7.96-beta.8 发布清单](docs/release.md#v0796-beta8-release-preparation)。
|
|
360
366
|
|
|
361
367
|
**v0.7.96-alpha.3 发布**:Provider 凭据成为惰性、受限、可撤销的能力(ADR-068)。v2
|
|
362
368
|
credential broker 将 Provider 密钥保留在 OS keychain,按每次 wire call、为单一封闭
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
|
|
2
|
-
import{Aa as e,Ba as f,Ra as g,Ta as h,a as c,hb as i,ib as j,qb as k,za as d}from"./chunk-
|
|
2
|
+
import{Aa as e,Ba as f,Ra as g,Ta as h,a as c,hb as i,ib as j,qb as k,za as d}from"./chunk-ZMXVACRD.js";import"./chunk-JA2DY4EC.js";import"./chunk-KHPUDIG7.js";import"./chunk-5KG5LAUO.js";import"./chunk-Y6VGGIKD.js";import{Ob as a,Pb as b}from"./chunk-F7JMG426.js";import"./chunk-WXBRPZMI.js";import"./chunk-V7ZTP5SV.js";import"./chunk-ONUPGMER.js";export{e as bucketProviderPayloadSize,g as buildAutoRepoIntelligenceContext,f as checkPromiseSignal,b as cleanupIncompleteToolCalls,h as describeTransientProviderRetry,c as emitResilienceDebug,d as estimateProviderPayloadBytes,k as runKodaX,j as saveRequiredSessionSnapshot,i as saveSessionSnapshot,a as validateAndFixToolHistory};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
|
|
2
|
+
import{Ma as a,Na as b}from"./chunk-HFTCGOBB.js";import"./chunk-WAKPBFEA.js";import"./chunk-YURCMKAL.js";import"./chunk-DGMNCSI3.js";import"./chunk-FZUPRAHK.js";import"./chunk-ZMXVACRD.js";import"./chunk-JA2DY4EC.js";import"./chunk-ROSCR2VP.js";import"./chunk-KHPUDIG7.js";import"./chunk-5KG5LAUO.js";import"./chunk-Y6VGGIKD.js";import"./chunk-F7JMG426.js";import"./chunk-WXBRPZMI.js";import"./chunk-V7ZTP5SV.js";import"./chunk-ONUPGMER.js";export{a as ArgumentCompleter,b as createArgumentCompleter};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
|
|
2
|
-
import{a as hn,b as vn,c as De,d as xn,e as kn,f as En,g as cr,h as Rn,k as en,l as lr,m as ur,n as fr,o as nn,p as wr}from"./chunk-
|
|
2
|
+
import{a as hn,b as vn,c as De,d as xn,e as kn,f as En,g as cr,h as Rn,k as en,l as lr,m as ur,n as fr,o as nn,p as wr}from"./chunk-JBOJY7LE.js";import{Fc as dr,Ka as me,Ya as rr,_a as tr,ab as xe,bb as or,fb as Sn,hb as ke,kb as Oe,ob as ir,pb as sr,rb as ar,v as L}from"./chunk-F7JMG426.js";import{a}from"./chunk-ONUPGMER.js";import{spawn as qe,spawnSync as we}from"node:child_process";import{createHash as Xe,randomInt as jt,randomUUID as B}from"node:crypto";import{once as Ut}from"node:events";import{closeSync as Dn,constants as an,existsSync as qn,fsyncSync as Ft,lstatSync as ae,mkdirSync as qr,openSync as Xr,readFileSync as Ie,readSync as Vt,readdirSync as Jr,realpathSync as K,renameSync as Kt,rmSync as un,statSync as _e,writeFileSync as Hr,writeSync as qt}from"node:fs";import{copyFile as zr,lstat as Xt,mkdir as ne,readFile as Me,realpath as je,rm as H,stat as dn,writeFile as Ue}from"node:fs/promises";import{createRequire as Jt}from"node:module";import{createServer as Ht}from"node:net";import U from"node:os";import l from"node:path";import{lstatSync as vt,readFileSync as xt,readdirSync as pr,realpathSync as kt}from"node:fs";import C from"node:path";import{globSync as Et}from"glob";var Rt=[".ssh",".tsh",".brev",".gnupg",".aws",".azure",".kube",".docker",".config",".npm",".pki",".terraform.d"],At=new Set(["certificatefile","controlpath","globalknownhostsfile","identityagent","identityfile","revokedhostkeys","userknownhostsfile"]);function oe(e){try{return kt.native(e).toLowerCase()}catch(r){return["ENOENT","ENOTDIR"].includes(r.code??"")||L({source:"sandbox:ssh-config",level:"warn",message:`Cannot canonicalize SSH ACL path: ${e}`,detail:r}),C.resolve(e).toLowerCase()}}a(oe,"pathKey");function gr(e,r){return r===e||r.startsWith(e.endsWith(C.sep)?e:`${e}${C.sep}`)}a(gr,"inside");function Wt(e){let r=[],n="",t;for(let o=0;o<e.length;o+=1){let i=e[o];if(i==="#"&&t===void 0)break;if(i===t){t=void 0;continue}if((i==='"'||i==="'")&&t===void 0){t=i;continue}let s=e[o+1];i==="\\"&&s!==void 0&&(['"',"'","\\"].includes(s)||t===void 0&&s===" ")?(n+=s,o+=1):/\s/.test(i)&&t===void 0?(n&&r.push(n),n=""):n+=i}return n&&r.push(n),r}a(Wt,"sshWords");function Ct(e,r,n){if(e.toLowerCase()==="none")return;if(["~","%d","${HOME}"].includes(e))return r;let t=e.replace(/^(?:~|%d|\$\{HOME\})[/\\]/,`${r}${C.sep}`);return C.isAbsolute(t)?C.resolve(t):n===void 0?void 0:C.resolve(n,t)}a(Ct,"sshPath");function An(e,r,n,t,o=0){let i=oe(e);if(t.has(i))return;if(o>=32){L({source:"sandbox:ssh-config",level:"warn",message:`SSH Include depth limit reached; dependencies beyond this config were not inspected: ${e}`});return}t.add(i);let s;try{s=xt(e,"utf8")}catch(d){if(d.code==="ENOENT")return;L({source:"sandbox:ssh-config",level:"warn",message:`Cannot inspect SSH configuration dependencies: ${e}`,detail:d});return}for(let d of s.split(/\r?\n/)){let c=Wt(d.replace(/^(\s*[^\s=]+)\s*=\s*/,"$1 ")),u=c.shift()?.toLowerCase();if(u!==void 0)for(let f of c){let p=Ct(f,r,u==="include"?C.join(r,".ssh"):void 0);if(p!==void 0)if(u==="include")for(let g of Et(p.replace(/\\/g,"/"),{nodir:!0}))n.push(g),An(g,r,n,t,o+1);else At.has(u)&&n.push(p)}}}a(An,"visitSshConfig");function de(e){let r=[];An(C.join(e,".ssh","config"),e,r,new Set);let n=oe(e),t=Rt.map(o=>C.join(e,o));for(let o of r){let i=C.relative(n,oe(o));i&&!i.startsWith(`..${C.sep}`)&&i!==".."&&!C.isAbsolute(i)&&t.push(C.join(e,i.split(C.sep)[0]))}return[...new Set(t.map(o=>C.resolve(o)))]}a(de,"windowsSandboxAclExclusions");function mr(e){let r=[];An(C.join(e,".ssh","config"),e,r,new Set);let n=[C.join(e,".ssh")];for(;n.length>0;){let t=n.pop();r.push(t);let o;try{if(vt(t).isSymbolicLink())continue;o=pr(t,{withFileTypes:!0})}catch(i){if(i.code==="ENOENT")continue;throw i}for(let i of o){if(i.isSymbolicLink())continue;let s=C.join(t,i.name);r.push(s),i.isDirectory()&&n.push(s)}}return[...new Set(r.filter(t=>gr(oe(e),oe(t))))]}a(mr,"windowsSandboxSshCleanupRoots");function Ee(e,r,n){let t=oe(r),o=n.flatMap(s=>[C.resolve(s).toLowerCase(),oe(s)]),i=e.flatMap(s=>oe(s)===t?pr(r,{withFileTypes:!0}).filter(d=>!d.isSymbolicLink()).map(d=>C.join(r,d.name)):[s]);return[...new Set(i)].filter(s=>![C.resolve(s).toLowerCase(),oe(s)].some(c=>o.some(u=>gr(u,c))))}a(Ee,"windowsSandboxAclRoots");import{fileURLToPath as _r,pathToFileURL as Yr}from"node:url";import{realpathSync as Pt,statSync as Nt}from"node:fs";import _t from"node:path";function Wn(e){let r=e.code;return r==="ENOENT"||r==="ENOTDIR"}a(Wn,"isMissingGitTrustPath");function br(e,r,n){try{let t=r(e).replaceAll("\\","/").replace(/\/+$/,"");return t===""?void 0:/^[A-Za-z]:$/.test(t)?`${t}/`:t}catch(t){if(n(t))return;throw t}}a(br,"normalizeGitSafeDirectoryRootImplementation");function Tt(e){return br(e,Pt,Wn)}a(Tt,"normalizeGitSafeDirectoryRoot");function Sr(e,r,n,t){try{let i=r(n.join(e,".git"));if(i.isDirectory()||i.isFile())return!0}catch(i){if(!t(i))throw i}if(!(n.basename(e).toLowerCase()===".git"||/[/\\]\.git[/\\]modules[/\\]/i.test(e)))return!1;try{return r(n.join(e,"HEAD")).isFile()}catch(i){if(t(i))return!1;throw i}}a(Sr,"isRepoBearingGitReadRootImplementation");function It(e){return Sr(e,Nt,_t,Wn)}a(It,"isRepoBearingGitReadRoot");function hr(e,r,n,t,o){let i=[];typeof e=="string"&&e!==""&&i.push(e);for(let c of n??[])o(c)&&i.push(c);i.push(...r??[]);let s=[],d=new Set;for(let c of i){if(s.length>=8)break;let u=t(c);if(u===void 0)continue;let f=u.toLowerCase();d.has(f)||(d.add(f),s.push(u))}return s}a(hr,"windowsGitTrustRootsImplementation");function vr(e,r,n){return hr(e,r,n,Tt,It)}a(vr,"windowsGitTrustRoots");function xr(e){if(e==="git_config_count")return"count";if(/^git_config_key_\d+$/.test(e))return"key";if(/^git_config_value_\d+$/.test(e))return"value"}a(xr,"gitConfigEnvKind");function Ot(e,r,n,t,o){let i=new Map,s=[],d,c=!1;for(let u=0;u<r;u+=1){if(e[u]!=="--env"||u+1>=r)continue;let f=e[u+1],p=f.indexOf("="),g=(p<0?f:f.slice(0,p)).toLowerCase(),w=n(g);if(w===void 0)continue;c=!0,s.push(u);let m=p<0?"":f.slice(p+1);if(w==="count"){let W=Number.parseInt(m,10);(d!==void 0||!Number.isSafeInteger(W)||W<0||String(W)!==m)&&t(),d=W;continue}let S=Number.parseInt(g.slice(`git_config_${w}_`.length),10),h=i.get(S)??{};(!Number.isSafeInteger(S)||S<0||h[w]!==void 0)&&t(),h[w]=m,i.set(S,h)}return o(i,s,d,c,t)}a(Ot,"parseGitConfigEnvironmentImplementation");function rn(){throw new Error("ASRT GIT_CONFIG environment has an unexpected shape.")}a(rn,"throwUnexpectedGitConfigShape");function kr(e,r,n,t,o){!t||n!==void 0&&e.size===n&&[...e].every(([d,c])=>d<n&&c.key!==void 0&&c.value!==void 0)||o();let s=[...e].map(([d,c])=>({slot:d,key:c.key,value:c.value}));return{argumentIndices:r,pairs:s,sawAny:t}}a(kr,"finishParsedGitConfigEnvironment");function Er(e,r){let n=[];for(let o of e)n.push({key:"safe.directory",value:o},{key:"safe.directory",value:`${o}/*`});n.push(...r);let t=n.flatMap((o,i)=>[`GIT_CONFIG_KEY_${i}=${o.key}`,`GIT_CONFIG_VALUE_${i}=${o.value}`]);return t.push(`GIT_CONFIG_COUNT=${n.length}`),t}a(Er,"gitSafeDirectoryAssignments");function yr(e,r){let n=[],t=new Set;for(let[o,i]of Object.entries(e)){if(i===void 0)continue;if(o===""||o.includes("=")||o.includes("\0")||i.includes("\0"))throw new Error(`Invalid ${r} environment entry.`);let s=o.toUpperCase();if(t.has(s))throw new Error(`Ambiguous ${r} environment variable: ${o}.`);t.add(s),n.push([o,i])}return n}a(yr,"validatedEnvironmentEntries");function Dt(e,r){let n=new Map,t=[],o,i=!1;for(let[u,f]of Object.entries(e)){let p=u.toLowerCase(),g=xr(p);if(g===void 0){t.push([u,f]);continue}if(i=!0,g==="count"){let S=Number.parseInt(f,10);(o!==void 0||!Number.isSafeInteger(S)||S<0||String(S)!==f)&&rn(),o=S;continue}let w=Number.parseInt(p.slice(`git_config_${g}_`.length),10),m=n.get(w)??{};(!Number.isSafeInteger(w)||w<0||m[g]!==void 0)&&rn(),m[g]=f,n.set(w,m)}let d=kr(n,[],o,i,rn).pairs.filter(u=>u.key.toLowerCase()!=="safe.directory").sort((u,f)=>u.slot-f.slot),c=Object.fromEntries(t);for(let u of Er(r,d)){let f=u.indexOf("=");c[u.slice(0,f)]=u.slice(f+1)}return c}a(Dt,"rewriteWindowsGitSafeDirectoryEnvironment");function Rr(e,r,n){let t=yr(e,"ASRT-controlled"),o=yr(r,"Windows target"),i=new Map;for(let s of t)i.set(s[0].toUpperCase(),s);for(let s of o){let d=s[0].toUpperCase();i.has(d)&&d!=="PATH"&&d!=="PATHEXT"||i.set(d,s)}return Dt(Object.fromEntries(i.values()),n)}a(Rr,"mergeWindowsSandboxTargetEnvironment");function Lt(e,r,n,t){let o=new Set(n.argumentIndices),i=[],s=!1;for(let d=0;d<e.length;d+=1)if(o.has(d)){if(!s){for(let c of t)i.push("--env",c);s=!0}d+=1}else i.push(e[d]);return n.sawAny||i.splice(r,0,...t.flatMap(d=>["--env",d])),i}a(Lt,"replaceGitConfigEnvironment");function Bt(e,r,n,t,o){let i=e.lastIndexOf("--");if(i<0)throw new Error("ASRT Windows wrapper omitted its child separator.");let s=n(e,i),d=s.pairs.filter(u=>u.key.toLowerCase()!=="safe.directory").sort((u,f)=>u.slot-f.slot),c=t(r,d);return o(e,i,s,c)}a(Bt,"rewriteWindowsGitSafeDirectoryArgvImplementation");function Ar(){return String.raw`
|
|
3
3
|
const isMissingGitTrustPath = ${Wn.toString()};
|
|
4
4
|
const normalizeGitSafeDirectoryRootImplementation = ${br.toString()};
|
|
5
5
|
const normalizeGitSafeDirectoryRoot = (root) => (
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
|
|
2
|
-
import{g as m,i as h,j as x}from"./chunk-
|
|
2
|
+
import{g as m,i as h,j as x}from"./chunk-JBOJY7LE.js";import{c as u}from"./chunk-KHPUDIG7.js";import{a as s}from"./chunk-ONUPGMER.js";import l from"node:fs";import{createHash as b}from"node:crypto";import{createRequire as O}from"node:module";import d from"node:path";var p=4;var C=O(import.meta.url),P=3e4,T;function E(e,n){let t=e.replaceAll("/","\\"),r=t.toLowerCase(),a=t.slice(3),o=(a===""?[]:a.split("\\")).some(i=>{let f=i.split(".",1)[0].toUpperCase(),R=["CON","PRN","AUX","NUL","CONIN$","CONOUT$"].includes(f)||/^(?:COM|LPT)[1-9¹²³]$/.test(f);return i===""||i==="."||i===".."||i.endsWith(".")||i.endsWith(" ")||/[\u0000-\u001f<>"|?*]/.test(i)||/~[0-9¹²³]/.test(i)||R});if(e.includes("\0")||t.startsWith("\\\\")||r.startsWith("\\??\\")||r.startsWith("\\device\\")||r.startsWith("\\global??\\")||r.startsWith("globalroot\\")||!/^[A-Za-z]:\\/.test(t)||t.slice(2).includes(":")||o)throw new u({code:"text_mutation_unsafe_path",path:e,message:`Trusted text mutation ${n} must use a local drive-absolute path; UNC and device namespaces are denied: ${e}`})}s(E,"assertLocalDriveAbsolutePath");function g(e,n){if(process.platform==="win32"){E(e,n);return}if(e.includes("\0")||!d.isAbsolute(e)||e.startsWith("//"))throw new u({code:"text_mutation_unsafe_path",path:e,message:`Trusted text mutation ${n} must use a local absolute path: ${e}`})}s(g,"assertSupportedAbsolutePath");function v(e,n){let t=d.relative(e,n);return t===""||!t.startsWith("..")&&!d.isAbsolute(t)}s(v,"sameOrInside");function S(e){let n=new Map;for(let t of e){let r=d.resolve(t),a=process.platform==="win32"?r.toLowerCase():r;n.has(a)||n.set(a,r)}return[...n.values()].sort((t,r)=>r.length-t.length)}s(S,"normalizedRootCandidates");function y(e,n){g(e,"target");for(let o of n)g(o,"write root");let t=d.resolve(e),r=S(n),a=r.find(o=>o!==t&&v(o,t)),c=s(o=>{try{if(!l.lstatSync(o).isDirectory())throw new Error("write root is not a directory");return l.realpathSync.native(o)}catch(i){throw new u({code:"text_mutation_unsafe_path",path:e,message:`Trusted text mutation write root is unavailable: ${o}`,cause:i})}},"canonicalizeRoot");if(a!==void 0){let o=c(a);return{canonicalRoot:o,canonicalTarget:d.join(o,d.relative(a,t))}}for(let o of r){let i=c(o);if(i!==t&&v(i,t))return{canonicalRoot:i,canonicalTarget:t}}throw new u({code:"text_mutation_policy_denied",path:e,message:`Trusted text mutation target is outside the Runtime write roots: ${e}`})}s(y,"authorizeTarget");function _(e){if(m(e),T!==void 0)return T;let n=x(import.meta.url,p,e),t=B(n);return T=A(t),T}s(_,"loadNativeBinding");function A(e){if(typeof e.textTransactionProtocol!="function"||typeof e.TrustedTextTransactionRoot!="function"||e.textTransactionProtocol()!==p)throw new Error(`The KodaX trusted text transaction binding must implement protocol ${p}.`);return e}s(A,"validateNativeBinding");function B(e){if(process.platform==="win32")return C(e);let n=l.openSync(e,l.constants.O_RDONLY|l.constants.O_NOFOLLOW);try{let t=l.fstatSync(n);if(!t.isFile()||t.nlink!==1||t.size>64*1024*1024)throw new Error("The protected native text binding has an unsafe identity.");let r=d.basename(d.dirname(e)).toLowerCase(),a=l.readFileSync(n),c=b("sha256").update(a).digest("hex");if(!/^[0-9a-f]{64}$/.test(r)||c!==r)throw new Error("The protected native text binding changed after provisioning.");let o={exports:{}},i=process.platform==="linux"?`/proc/self/fd/${n}`:`/dev/fd/${n}`;return process.dlopen(o,i),o.exports}finally{l.closeSync(n)}}s(B,"loadNativeBindingFile");function w(e,n){return process.platform==="win32"?new e.TrustedTextTransactionRoot(n):new e.TrustedTextTransactionRoot(n,h())}s(w,"createNativeRoot");function W(e){switch(e){case"invalid_path":case"reparse_point":case"hard_link":return"text_mutation_unsafe_path";case"unauthorized_path":return"text_mutation_policy_denied";case"remote_filesystem":case"unsupported_filesystem":case"unsupported_platform":return"text_mutation_unsupported_filesystem";case"contended":return"text_mutation_contended";case"stale":return"text_mutation_stale";case"metadata_preservation":return"text_mutation_metadata_preservation_failed";default:return"text_mutation_io_failed"}}s(W,"mappedNativeErrorCode");function N(e,n){if(n instanceof u)throw n;let t=n instanceof Error?n.message:String(n),r="KODAX_TEXT_TRANSACTION:",a=t.indexOf(r),c={};if(a>=0)try{let o=JSON.parse(t.slice(a+r.length));o!==null&&typeof o=="object"&&!Array.isArray(o)&&(c=o)}catch{c={}}throw new u({code:W(c.code),path:e,message:c.message??t,...typeof c.os_code=="number"?{osCode:c.os_code}:{},cause:n})}s(N,"translateNativeError");function X(e){return{state:e.state,content:e.content,revision:e.revision,slot:e.slotId,canonicalPath:e.canonicalPath}}s(X,"publicSnapshot");function I(e,n,t){if(t.status==="stale"){if(typeof t.currentRevision!="string")throw new Error("Native text transaction returned a stale result without a revision.");return{status:"stale",currentRevision:t.currentRevision}}if(typeof t.slotId!="string"||typeof t.preContent!="string"||typeof t.preRevision!="string"||typeof t.postRevision!="string")throw new Error("Native text transaction returned an incomplete commit receipt.");let r={before:{state:t.preRevision.startsWith("missing:")?"missing":"present",content:t.preContent,revision:t.preRevision,slot:t.slotId,canonicalPath:e},after:{state:"present",content:n,revision:t.postRevision,slot:t.slotId,canonicalPath:e},recoveredAbandonedLock:t.abandonedLock===!0};if(t.status==="committed_uncertain"){if(typeof t.message!="string"||t.message==="")throw new Error("Native text transaction returned an uncertain commit without a reason.");return{status:"committed_uncertain",...r,reason:t.message}}return{status:"written",...r}}s(I,"requireWrittenOutcome");function D(e,n){return{async snapshot(t){if(t.signal?.aborted)throw t.signal.reason;g(t.path,"target");let r=y(t.path,e());n(r.canonicalTarget);try{let a=_(e()),c=w(a,r.canonicalRoot);return X(await c.snapshot(r.canonicalTarget))}catch(a){N(r.canonicalTarget,a)}},async commit(t){if(t.signal?.aborted)throw t.signal.reason;g(t.path,"target");let r=y(t.path,e());n(r.canonicalTarget);try{let a=_(e()),o=await w(a,r.canonicalRoot).commit(r.canonicalTarget,t.expectedRevision,t.content,t.createParentDirectories,P);return I(r.canonicalTarget,t.content,o)}catch(a){N(r.canonicalTarget,a)}}}}s(D,"createTrustedTextMutationHost");export{D as a};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
|
|
2
|
-
import{$ as Gi,$a as ta,A as $i,Aa as ml,Ca as Ji,Da as pl,E as yo,Ea as Qi,F as Hd,Fa as hl,G as ut,Ga as gl,H as zd,Ha as hr,I as Li,Ia as bl,J as qd,Ja as vl,Ka as yl,La as wl,M as Kd,Ma as Rn,N as Xd,Na as Tl,O as Yd,Oa as Sl,P as fr,Pa as kl,Q as Di,Qa as Pl,Ra as Nl,Sa as $l,T as Wi,Ta as Ll,U as ji,Ua as So,V as Fi,Va as kt,W as Bi,Wa as Dl,X as rl,Xa as Wl,Y as ol,Ya as jl,Za as Fl,_ as Ui,_a as ko,a as Pe,ab as na,ba as Vi,bb as ra,cb as Bl,da as Hi,db as Ul,ea as sl,eb as Gl,f as Zs,fa as il,fb as Vl,ga as wo,gb as Hl,h as pd,ha as zi,hb as oa,i as ei,ib as zl,jb as ql,k as ti,kb as Kl,l as to,la as mr,na as al,nb as Xl,o as ir,oa as cl,ob as Yl,pa as qi,pb as Jl,qb as dt,ra as Ki,ta as Xi,ua as ul,va as pr,wa as dl,x as lr,xa as ll,ya as Yi,za as fl}from"./chunk-POVUU6P2.js";import{a as Zi}from"./chunk-JA2DY4EC.js";import{A as ea,o as Rl,t as Cl,u as Al,v as Il,y as Ml}from"./chunk-B4FK5XVU.js";import{$ as Cd,$b as uo,A as no,Ad as Gd,B as Sd,C as ar,Ca as fi,D as kd,Da as mi,De as El,Ea as $d,Ed as vo,Ee as To,F as ri,Fa as Ld,Fd as dr,Fe as _l,G as Kt,H as xd,He as Ol,I as _n,J as Ed,Ja as so,Jd as Ii,Ka as pi,Kd as Mi,Lb as rt,Ma as io,Md as Oi,N as oi,O as si,Q as ii,Sa as cr,Sd as St,Ta as hi,Td as Pi,Va as gi,Wa as bi,Wb as Wd,Xb as jd,Ya as vi,Yb as Fd,Za as yi,_ as Rd,_d as Ni,a as eo,b as md,ba as Ad,bb as wi,bc as lo,ca as Id,cc as fo,da as ai,de as Vd,e as or,ea as Md,eb as Ti,ee as Jd,f as sr,fc as mo,g as hd,gc as po,ge as Qd,h as gd,he as Zd,i as bd,ib as ao,ic as Ei,ie as el,jb as co,jc as Tt,je as tl,kc as _i,l as vd,la as ro,lc as ur,mb as Si,mc as Ri,me as nl,na as ci,nc as ho,nd as Ai,o as ni,oa as ui,oc as go,p as yd,pa as oo,pb as ki,pc as bo,qa as Od,qb as xi,qc as Ci,ra as di,rb as Dd,rc as Bd,sa as li,ta as Pd,ua as Xt,wa as Nd,xe as xl,y as wd,z as Td,zd as Ud}from"./chunk-H6NNJO5M.js";import{h as _d}from"./chunk-5KG5LAUO.js";import{$d as nd,Ab as Ku,Ba as Fu,Ca as Ks,D as $u,Df as Qs,Dg as fd,Fb as Xu,Ia as Bu,Ib as Yu,Jb as Ju,Ka as xe,Lb as Qu,Ld as ed,Ma as B,Md as td,N as Lu,Na as tt,Ob as Xs,Pb as Ys,Q as Du,Sb as xn,Se as Zr,Tb as Zu,de as rd,ee as od,eg as En,fg as ad,g as Xr,hb as Uu,ja as qs,k as fe,kb as Gu,l as vt,mf as sd,o as ct,q as Yr,qg as cd,r as Nu,t as zs,ug as ud,v as yt,va as wt,vb as nt,vf as Js,vg as dd,wa as Wu,wf as id,xb as Vu,xg as ld,ya as ju}from"./chunk-F7JMG426.js";import{F as qu,b as Jr,d as Qr,e as Hu,k as zu}from"./chunk-WXBRPZMI.js";import{$a as Ge,Fa as qt,O as Ht,aa as Pu,ca as zr,g as kn,l as Fs,m as Bs,mb as Us,n as Ou,nb as qr,ob as Gs,pb as Vs,rb as Hs,tb as Kr,u as Hr,ya as zt}from"./chunk-V7ZTP5SV.js";import{a as i,b as js,d as gv}from"./chunk-ONUPGMER.js";var Ph=js((Yj,Oh)=>{"use strict";Oh.exports=i(function(t){return t.map(function(n){return n===""?"''":n&&typeof n=="object"?n.op.replace(/(.)/g,"\\$1"):/["\s\\]/.test(n)&&!/'/.test(n)?"'"+n.replace(/(['])/g,"\\$1")+"'":/["'\s]/.test(n)?'"'+n.replace(/(["\\$`!])/g,"\\$1")+'"':String(n).replace(/([A-Za-z]:)?([#!"$&'()*,:;<=>?@[\\\]^`{|}])/g,"$1\\$2")}).join(" ")},"quote")});var Fh=js((Qj,jh)=>{"use strict";var Wh="(?:"+["\\|\\|","\\&\\&",";;","\\|\\&","\\<\\(","\\<\\<\\<",">>",">\\&","<\\&","[&;()|<>]"].join("|")+")",Nh=new RegExp("^"+Wh+"$"),$h="|&;()<> \\t",_E='"((\\\\"|[^"])*?)"',RE="'((\\\\'|[^'])*?)'",CE=/^#$/,Lh="'",Dh='"',yc="$",sn="",AE=4294967296;for(wc=0;wc<4;wc++)sn+=(AE*Math.random()).toString(16);var wc,IE=new RegExp("^"+sn);function ME(e,t){for(var n=t.lastIndex,r=[],o;o=t.exec(e);)r.push(o),t.lastIndex===o.index&&(t.lastIndex+=1);return t.lastIndex=n,r}i(ME,"matchAll");function OE(e,t,n){var r=typeof e=="function"?e(n):e[n];return typeof r>"u"&&n!=""?r="":typeof r>"u"&&(r="$"),typeof r=="object"?t+sn+JSON.stringify(r)+sn:t+r}i(OE,"getVar");function PE(e,t,n){n||(n={});var r=n.escape||"\\",o="(\\"+r+`['"`+$h+`]|[^\\s'"`+$h+"])+",s=new RegExp(["("+Wh+")","("+o+"|"+_E+"|"+RE+")+"].join("|"),"g"),a=ME(e,s);if(a.length===0)return[];t||(t={});var c=!1;return a.map(function(u){var d=u[0];if(!d||c)return;if(Nh.test(d))return{op:d};var l=!1,f=!1,p="",h=!1,m;function g(){m+=1;var y,w,S=d.charAt(m);if(S==="{"){if(m+=1,d.charAt(m)==="}")throw new Error("Bad substitution: "+d.slice(m-2,m+1));if(y=d.indexOf("}",m),y<0)throw new Error("Bad substitution: "+d.slice(m));w=d.slice(m,y),m=y}else if(/[*@#?$!_-]/.test(S))w=S,m+=1;else{var T=d.slice(m);y=T.match(/[^\w\d_]/),y?(w=T.slice(0,y.index),m+=y.index-1):(w=T,m=d.length)}return OE(t,"",w)}for(i(g,"parseEnvVar"),m=0;m<d.length;m++){var b=d.charAt(m);if(h=h||!l&&(b==="*"||b==="?"),f)p+=b,f=!1;else if(l)b===l?l=!1:l==Lh?p+=b:b===r?(m+=1,b=d.charAt(m),b===Dh||b===r||b===yc?p+=b:p+=r+b):b===yc?p+=g():p+=b;else if(b===Dh||b===Lh)l=b;else{if(Nh.test(b))return{op:d};if(CE.test(b)){c=!0;var v={comment:e.slice(u.index+m+1)};return p.length?[p,v]:[v]}else b===r?f=!0:b===yc?p+=g():p+=b}}return h?{op:"glob",pattern:p}:p}).reduce(function(u,d){return typeof d>"u"?u:u.concat(d)},[])}i(PE,"parseInternal");jh.exports=i(function(t,n,r){var o=PE(t,n,r);return typeof n!="function"?o:o.reduce(function(s,a){if(typeof a=="object")return s.concat(a);var c=a.split(RegExp("("+sn+".*?"+sn+")","g"));return c.length===1?s.concat(c[0]):s.concat(c.filter(Boolean).map(function(u){return IE.test(u)?JSON.parse(u.split(sn)[1]):u}))},[])},"parse")});var Bh=js(Tc=>{"use strict";Tc.quote=Ph();Tc.parse=Fh()});function bv(){return{retained:[]}}i(bv,"createOutputSegmentProjection");function vv(e,t){if(t.type==="segment.started"){if(e.active?.responseId===t.responseId&&e.active.providerRequestId===t.providerRequestId&&e.active.mode===t.mode)return{state:e,accepted:!0};let n=e.active?.responseId??e.retained[e.retained.length-1]?.responseId,r=n===void 0||n===t.responseId,o=t.mode==="append"?e.active:void 0;return{accepted:!0,state:{retained:r?o?[...e.retained,o]:e.retained:[],active:{responseId:t.responseId,providerRequestId:t.providerRequestId,mode:t.mode,...t.startedAtSeq!==void 0?{startedAtSeq:t.startedAtSeq}:{},assistantText:"",thinkingText:""}}}}return e.active?.providerRequestId!==t.providerRequestId?{state:e,accepted:!1}:{accepted:!0,state:{...e,active:{...e.active,...t.type==="assistant.delta"?{assistantText:e.active.assistantText+t.text}:{thinkingText:e.active.thinkingText+t.text}}}}}i(vv,"reduceOutputSegmentProjection");function yv(e,t){let n=t==="assistant"?"assistantText":"thinkingText";return e.retained.map(r=>r[n]).join("")+(e.active?.[n]??"")}i(yv,"effectiveOutputSegmentText");var gr=class extends Error{static{i(this,"KodaXError")}code;constructor(t,n="KODAX_ERROR"){super(t),this.code=n,this.name="KodaXError"}};var sa=class extends gr{static{i(this,"KodaXToolError")}toolName;toolId;constructor(t,n,r){super(t,"TOOL_ERROR"),this.toolName=n,this.toolId=r,this.name="KodaXToolError"}};var ia=class extends gr{static{i(this,"KodaXSessionError")}sessionId;constructor(t,n){super(t,"SESSION_ERROR"),this.sessionId=n,this.name="KodaXSessionError"}},aa=class extends gr{static{i(this,"KodaXTerminalError")}suggestions;constructor(t,n=[]){super(t,"TERMINAL_ERROR"),this.name="KodaXTerminalError",this.suggestions=n}};function wv(){return new xo}i(wv,"createSessionControl");function ca(e,t){let n=new AbortController,r=!1,o=i(h=>{r||(r=!0,n.abort(h))},"markAborted");e.abortSignal&&(e.abortSignal.aborted?o(e.abortSignal.reason):e.abortSignal.addEventListener("abort",()=>o(e.abortSignal.reason),{once:!0}));let s=new xo;s.seed({provider:e.provider,model:e.modelOverride??e.model,reasoning:e.reasoningMode});let a=e.session?.id,c=a!=null,u=a??Tv(),l=!c&&e.session?.autoResume!==!0&&e.session?.resume!==!0?Hl({...e.session??{},id:u}):e.session,f={...e,...e.agentMode!==void 0?{agentMode:ir(e.agentMode)}:{},...l!==void 0?{session:l}:{},abortSignal:n.signal,sessionControl:s},p=dt(f,t);return{id:u,get currentProvider(){return s.getProvider()},get currentModel(){return s.getModel()},get currentReasoning(){return s.getReasoning()},get aborted(){return r},get attached(){return s.isAttached()},setProvider:i(h=>s.setProvider(h),"setProvider"),setModel:i(h=>s.setModel(h),"setModel"),setReasoning:i(h=>s.setReasoning(h),"setReasoning"),abort:i(h=>o(h),"abort"),result:p}}i(ca,"startKodaX");function Tv(){return`sess_${Date.now()}_${Math.random().toString(36).slice(2,10)}`}i(Tv,"generateSessionId");var xo=class{static{i(this,"SessionControlImpl")}mutators=null;providerValue;modelValue;reasoningValue;hasPendingProvider=!1;hasPendingModel=!1;hasPendingReasoning=!1;seed(t){this.providerValue=t.provider,this.modelValue=t.model,this.reasoningValue=t.reasoning}setProvider(t){this.providerValue=t,this.mutators?this.mutators.setProvider(t):this.hasPendingProvider=!0}setModel(t){this.modelValue=t,this.mutators?this.mutators.setModel(t):this.hasPendingModel=!0}setReasoning(t){this.reasoningValue=t,this.mutators?this.mutators.setReasoning(t):this.hasPendingReasoning=!0}getProvider(){return this.providerValue??""}getModel(){return this.modelValue}getReasoning(){return this.reasoningValue}isAttached(){return this.mutators!==null}_attach(t){this.mutators,this.mutators=t,this.hasPendingProvider&&this.providerValue!==void 0&&t.setProvider(this.providerValue),this.hasPendingModel&&t.setModel(this.modelValue),this.hasPendingReasoning&&t.setReasoning(this.reasoningValue),this.hasPendingProvider=!1,this.hasPendingModel=!1,this.hasPendingReasoning=!1}};function Sv(e,t){return e.kind!=="revise_count"?{ok:!0}:e.count<=3?{ok:!0}:{ok:!1,severity:"warn",reason:`boundedRevise: revise_count for harness="${e.harness}" reached ${e.count}, exceeding soft threshold 3`}}i(Sv,"observe");var ua={id:"boundedRevise",description:"Per-harness revise count must stay within the soft threshold; crossings emit a warn signal for dispatch-eval (hard cap enforced by the budget controller).",observe:Sv};function kv(e,t){return typeof e.maxBudget!="number"?{ok:!0}:e.maxBudget<=t.systemCap.maxBudget?{ok:!0}:{ok:!1,severity:"clamp",reason:`budgetCeiling: manifest.maxBudget=${e.maxBudget} exceeds systemCap.maxBudget=${t.systemCap.maxBudget}`,patch:{clampMaxBudget:t.systemCap.maxBudget}}}i(kv,"admit");var da={id:"budgetCeiling",description:"manifest.maxBudget must be \u2264 systemCap.maxBudget; over-cap declarations are clamped down to the cap.",admit:kv};function xv(e,t){return{ok:!0}}i(xv,"observe");var Ql={id:"harnessSelectionTiming",description:"FEATURE_193 V2 no-op shell \u2014 predicate always admits since V1 Scout retired. Kept registered for admission-framework / audit-array compat.",observe:xv};function Ev(e,t){if(e.kind!=="mutation_recorded")return{ok:!0};let n=t.recorder;return typeof n.todoUpdateCount!="number"?{ok:!0}:n.todoUpdateCount>0?{ok:!0}:n.workerTrivialDeclaration===!0?{ok:!0}:{ok:!1,severity:"warn",reason:`planBeforeMutate: Worker mutated ${e.file} without a prior todo_update plan commit and without a trivial declaration`}}i(Ev,"observe");var Zl={id:"planBeforeMutate",description:"Worker mutations should be preceded by a todo_update plan commit (or an explicit trivial declaration). Missing plan is a warn-only signal in v0.7.36.",observe:Ev};function la(e){switch(e){case"read":case"glob":case"grep":case"code_search":case"semantic_lookup":case"lsp_definition":case"lsp_hover":case"lsp_references":case"lsp_document_symbols":case"lsp_workspace_symbols":case"lsp_implementation":case"lsp_prepare_call_hierarchy":case"lsp_incoming_calls":case"lsp_outgoing_calls":case"repo_overview":case"changed_scope":case"changed_diff":case"changed_diff_bundle":case"module_context":case"symbol_context":case"process_context":case"impact_estimate":case"relationship_scan":case"cyclic_dependencies":case"ask_user_question":case"exit_plan_mode":return"read";case"write":case"edit":case"multi_edit":case"insert_after_anchor":case"undo":return"edit";case"bash":return"bash:mutating";case"web_search":case"web_fetch":case"mcp_search":case"mcp_describe":case"mcp_call":case"mcp_read_resource":case"mcp_get_prompt":return"bash:network";case"spawn_agent":case"send_message":case"followup_task":case"wait_agent":case"interrupt_agent":case"list_agents":case"agent_output":case"emit_verdict":case"scaffold_tool":case"validate_tool":case"stage_construction":case"test_tool":case"activate_tool":case"scaffold_agent":case"validate_agent":case"stage_agent_construction":case"test_agent":case"activate_agent":case"worktree_create":case"worktree_remove":return"subagent";default:return"subagent"}}i(la,"resolveToolCapability");function _v(e){if(typeof e=="object"&&e!==null&&"name"in e){let t=e.name;if(typeof t=="string"&&t.length>0)return t}}i(_v,"getToolName");function Rv(e,t){if(!e.tools||e.tools.length===0)return{ok:!0};let n=new Set(t.systemCap.allowedToolCapabilities),r=[];for(let a of e.tools){let c=_v(a);if(!c)continue;let u=la(c);n.has(u)||r.push({name:c,capability:u})}if(r.length===0)return{ok:!0};let o=r.map(a=>a.name);return{ok:!1,severity:"clamp",reason:`toolPermission: tools requiring disallowed capabilities \u2014 ${r.map(a=>`${a.name}=${a.capability}`).join(", ")}`,patch:{removeTools:o}}}i(Rv,"admit");var fa={id:"toolPermission",description:"Every tool in manifest.tools must resolve to a capability tier that systemCap.allowedToolCapabilities permits; offending tools are clamped via removeTools.",admit:Rv};var ef=[da,fa,ua,Ql,Zl];function Cv(){Bu();for(let e of ef)Du(e)}i(Cv,"registerCodingInvariants");var Eo=class{static{i(this,"KodaXClient")}options;sessionId;messages=[];contextTokenSnapshot;constructor(t){this.options=t,this.sessionId=t.session?.id??"",this.messages=t.session?.initialMessages?[...t.session.initialMessages]:[],this.contextTokenSnapshot=t.context?.contextTokenSnapshot}async send(t){let n=this.messages.length>0?this.messages:this.options.session?.initialMessages,r=await dt({...this.options,session:{...this.options.session,id:this.sessionId||void 0,initialMessages:n},context:{...this.options.context,contextTokenSnapshot:this.contextTokenSnapshot}},t);return this.sessionId=r.sessionId,this.messages=r.messages,this.contextTokenSnapshot=r.contextTokenSnapshot,r}getSessionId(){return this.sessionId}getMessages(){return[...this.messages]}clear(){this.messages=[],this.sessionId="",this.contextTokenSnapshot=void 0}};function tf(e){return/\bworkflows?\b|工作流(?!程)|ワークフロー|워크플로우/iu.test(e)}i(tf,"hasExplicitNaturalLanguageWorkflowIntent");function nO(e){return{action:e.source==="command"?"suggest":"none"}}i(nO,"decideWorkflowInvocation");function rO(e){return e.outcome==="started"||e.outcome==="cancelled"}i(rO,"workflowStartOutcomeConsumesTurn");var Av="KODAX_VERIFIER_PROVIDER",Iv="KODAX_VERIFIER_MODEL";function Mv(e){if(qt(e))try{return zt(e)}catch{return}}i(Mv,"tryGetProvider");function _o(e){let t=e.env??process.env,n=t[Av],r=t[Iv];if(n&&r){let o=Mv(n);if(o)return{provider:o,model:r,providerName:n,source:"explicit-env"}}return{provider:e.mainProvider,model:e.mainModel,providerName:e.mainProviderName,source:"inherit-main"}}i(_o,"resolveVerifierProvider");function ma(e){let t=e.context?.agentProfile;if(!t)return;let n=t.verification,r=e.context?.taskVerification;if(!n&&!r)return;let o={...n,...r};return Array.isArray(r?.criteria)&&r.criteria.length===0&&Array.isArray(n?.criteria)&&n.criteria.length>0?{...o,criteria:n.criteria}:o}i(ma,"resolveEffectiveVerification");function Ov(e){let t=e.provider??"anthropic";if(qt(t))try{let n=_o({mainProvider:zt(t),mainProviderName:t,mainModel:e.modelOverride??e.model});return{provider:n.providerName,...n.model!==void 0?{model:n.model}:{}}}catch{return}}i(Ov,"resolveVerifierAttribution");function pa(e,t){let n=e.events?.onEffectiveConfig;if(!n)return;let r=t.verifier??Ov(e),o={agentMode:t.agentMode,agentProfile:e.context?.agentProfile,toolScope:t.toolScope,verification:ma(e),...r?{verifier:r}:{}};try{n(o)}catch{}}i(pa,"emitEffectiveTaskConfig");var nf="kodax-review-findings",rf="kodax-investigation-shards",of="kodax-lookup-shards",sf="kodax-child-result";var af="kodax-budget-request";function Yt(e,t=!1){return{globalWorkBudget:e?.totalBudget,budgetUsage:e?.spentBudget,budgetApprovalRequired:t}}i(Yt,"buildManagedStatusBudgetFields");function br(e,t=1){e.spentBudget=Math.max(0,e.spentBudget+t)}i(br,"incrementManagedBudgetUsage");function Nv(e,t=200){e.totalBudget+=t}i(Nv,"extendManagedWorkBudget");function Co(e,t,n=!1){if(!e?.askUser)return!1;if(!n){let r=Math.ceil(t.totalBudget*.9);if(t.spentBudget<r)return!1}return t.lastApprovalBudgetTotal!==t.totalBudget}i(Co,"canRequestAdditionalWorkBudget");async function ha(e,t,n){let r=e?.askUser;if(!r||!Co(e,t,n.force))return"skipped";let o=n.additionalUnits??200,s=Math.min(100,Math.round(t.spentBudget/Math.max(1,t.totalBudget)*100)),a=/[\u4e00-\u9fff]/.test(n.originalTask??n.summary),c=nt(await r({question:a?`\u5F53\u524D AMA \u8FD0\u884C\u5DF2\u4F7F\u7528 ${t.spentBudget}/${t.totalBudget} \u5DE5\u4F5C\u5355\u5143\uFF08${s}%\uFF09\uFF0C\u9700\u8981\u66F4\u591A\u5DE5\u4F5C\u91CF\u3002\u662F\u5426\u8FFD\u52A0 ${o} \u5355\u5143\uFF1F`:`This AMA run has used ${t.spentBudget}/${t.totalBudget} work units (${s}%) and needs more work. Add ${o} more work units?`,allowCustomInput:!1,options:[{label:a?`\u7EE7\u7EED (+${o})`:`Continue (+${o})`,value:"continue",description:a?`\u8FFD\u52A0 ${o} \u5DE5\u4F5C\u5355\u5143\uFF0C\u4ECE\u7B2C ${n.currentRound}/${n.maxRounds} \u8F6E\u7EE7\u7EED\u3002`:`Grant ${o} more work units and continue from round ${n.currentRound}/${n.maxRounds}.`},{label:a?"\u505C\u6B62":"Stop here",value:"stop",description:a?`\u4F7F\u7528\u5F53\u524D\u6700\u4F73\u7ED3\u679C\u3002\u6700\u65B0\u8FDB\u5C55\uFF1A${Li(n.summary,80)}`:`Finish now with the current best result. Latest note: ${Li(n.summary,80)}`}],default:"continue"})),u=t.totalBudget;return c==="continue"?(t.lastApprovalBudgetTotal=u,Nv(t,o),"approved"):(t.lastApprovalBudgetTotal=u,"denied")}i(ha,"maybeRequestAdditionalWorkBudget");import{readdir as Wv,readFile as uf,stat as jv}from"node:fs/promises";import{execFile as Fv}from"node:child_process";import{promisify as Bv}from"node:util";import Cn from"node:path";import ga from"node:path";import{mkdir as $v,unlink as Lv,writeFile as Dv}from"node:fs/promises";function xt(e){return e.context?.taskSurface??"cli"}i(xt,"getManagedTaskSurface");function Et(e,t){if(e.context?.managedTaskWorkspaceDir?.trim())return ga.resolve(e.context.managedTaskWorkspaceDir);let n=e.context?.executionCwd??e.context?.gitRoot??process.cwd();return ga.resolve(n,".agent","managed-tasks")}i(Et,"getManagedTaskWorkspaceRoot");async function ie(e,t,n="utf8"){await ni(e,async()=>{await $v(ga.dirname(e),{recursive:!0}),await Dv(e,t,"utf8")})}i(ie,"writeManagedTaskFile");async function cf(e){await ni(e,async()=>{try{await Lv(e)}catch(t){if(t.code!=="ENOENT")throw t}})}i(cf,"deleteManagedTaskFile");var Uv=Bv(Fv),df=3600*1e3,Ao="checkpoint.json";function ba(e){let t=e.session?.id?.trim();return t||void 0}i(ba,"getCheckpointSessionId");function Gv(e,t){return t?e.sessionId===t:!1}i(Gv,"checkpointBelongsToSession");async function Io(e){let t=Cn.resolve(e?.trim()||process.cwd());try{let{stdout:n}=await Uv("git",["rev-parse","--short","HEAD"],{cwd:t,windowsHide:!0});return n.trim()||void 0}catch{return}}i(Io,"getGitHeadCommit");async function va(e,t){await ie(Cn.join(e,Ao),`${JSON.stringify(t,null,2)}
|
|
2
|
+
import{$ as Gi,$a as ta,A as $i,Aa as ml,Ca as Ji,Da as pl,E as yo,Ea as Qi,F as Hd,Fa as hl,G as ut,Ga as gl,H as zd,Ha as hr,I as Li,Ia as bl,J as qd,Ja as vl,Ka as yl,La as wl,M as Kd,Ma as Rn,N as Xd,Na as Tl,O as Yd,Oa as Sl,P as fr,Pa as kl,Q as Di,Qa as Pl,Ra as Nl,Sa as $l,T as Wi,Ta as Ll,U as ji,Ua as So,V as Fi,Va as kt,W as Bi,Wa as Dl,X as rl,Xa as Wl,Y as ol,Ya as jl,Za as Fl,_ as Ui,_a as ko,a as Pe,ab as na,ba as Vi,bb as ra,cb as Bl,da as Hi,db as Ul,ea as sl,eb as Gl,f as Zs,fa as il,fb as Vl,ga as wo,gb as Hl,h as pd,ha as zi,hb as oa,i as ei,ib as zl,jb as ql,k as ti,kb as Kl,l as to,la as mr,na as al,nb as Xl,o as ir,oa as cl,ob as Yl,pa as qi,pb as Jl,qb as dt,ra as Ki,ta as Xi,ua as ul,va as pr,wa as dl,x as lr,xa as ll,ya as Yi,za as fl}from"./chunk-ZMXVACRD.js";import{a as Zi}from"./chunk-JA2DY4EC.js";import{A as ea,o as Rl,t as Cl,u as Al,v as Il,y as Ml}from"./chunk-ROSCR2VP.js";import{$ as Cd,$b as uo,A as no,Ad as Gd,B as Sd,C as ar,Ca as fi,D as kd,Da as mi,De as El,Ea as $d,Ed as vo,Ee as To,F as ri,Fa as Ld,Fd as dr,Fe as _l,G as Kt,H as xd,He as Ol,I as _n,J as Ed,Ja as so,Jd as Ii,Ka as pi,Kd as Mi,Lb as rt,Ma as io,Md as Oi,N as oi,O as si,Q as ii,Sa as cr,Sd as St,Ta as hi,Td as Pi,Va as gi,Wa as bi,Wb as Wd,Xb as jd,Ya as vi,Yb as Fd,Za as yi,_ as Rd,_d as Ni,a as eo,b as md,ba as Ad,bb as wi,bc as lo,ca as Id,cc as fo,da as ai,de as Vd,e as or,ea as Md,eb as Ti,ee as Jd,f as sr,fc as mo,g as hd,gc as po,ge as Qd,h as gd,he as Zd,i as bd,ib as ao,ic as Ei,ie as el,jb as co,jc as Tt,je as tl,kc as _i,l as vd,la as ro,lc as ur,mb as Si,mc as Ri,me as nl,na as ci,nc as ho,nd as Ai,o as ni,oa as ui,oc as go,p as yd,pa as oo,pb as ki,pc as bo,qa as Od,qb as xi,qc as Ci,ra as di,rb as Dd,rc as Bd,sa as li,ta as Pd,ua as Xt,wa as Nd,xe as xl,y as wd,z as Td,zd as Ud}from"./chunk-KHPUDIG7.js";import{h as _d}from"./chunk-5KG5LAUO.js";import{$d as nd,Ab as Ku,Ba as Fu,Ca as Ks,D as $u,Df as Qs,Dg as fd,Fb as Xu,Ia as Bu,Ib as Yu,Jb as Ju,Ka as xe,Lb as Qu,Ld as ed,Ma as B,Md as td,N as Lu,Na as tt,Ob as Xs,Pb as Ys,Q as Du,Sb as xn,Se as Zr,Tb as Zu,de as rd,ee as od,eg as En,fg as ad,g as Xr,hb as Uu,ja as qs,k as fe,kb as Gu,l as vt,mf as sd,o as ct,q as Yr,qg as cd,r as Nu,t as zs,ug as ud,v as yt,va as wt,vb as nt,vf as Js,vg as dd,wa as Wu,wf as id,xb as Vu,xg as ld,ya as ju}from"./chunk-F7JMG426.js";import{F as qu,b as Jr,d as Qr,e as Hu,k as zu}from"./chunk-WXBRPZMI.js";import{$a as Ge,Fa as qt,O as Ht,aa as Pu,ca as zr,g as kn,l as Fs,m as Bs,mb as Us,n as Ou,nb as qr,ob as Gs,pb as Vs,rb as Hs,tb as Kr,u as Hr,ya as zt}from"./chunk-V7ZTP5SV.js";import{a as i,b as js,d as gv}from"./chunk-ONUPGMER.js";var Ph=js((Yj,Oh)=>{"use strict";Oh.exports=i(function(t){return t.map(function(n){return n===""?"''":n&&typeof n=="object"?n.op.replace(/(.)/g,"\\$1"):/["\s\\]/.test(n)&&!/'/.test(n)?"'"+n.replace(/(['])/g,"\\$1")+"'":/["'\s]/.test(n)?'"'+n.replace(/(["\\$`!])/g,"\\$1")+'"':String(n).replace(/([A-Za-z]:)?([#!"$&'()*,:;<=>?@[\\\]^`{|}])/g,"$1\\$2")}).join(" ")},"quote")});var Fh=js((Qj,jh)=>{"use strict";var Wh="(?:"+["\\|\\|","\\&\\&",";;","\\|\\&","\\<\\(","\\<\\<\\<",">>",">\\&","<\\&","[&;()|<>]"].join("|")+")",Nh=new RegExp("^"+Wh+"$"),$h="|&;()<> \\t",_E='"((\\\\"|[^"])*?)"',RE="'((\\\\'|[^'])*?)'",CE=/^#$/,Lh="'",Dh='"',yc="$",sn="",AE=4294967296;for(wc=0;wc<4;wc++)sn+=(AE*Math.random()).toString(16);var wc,IE=new RegExp("^"+sn);function ME(e,t){for(var n=t.lastIndex,r=[],o;o=t.exec(e);)r.push(o),t.lastIndex===o.index&&(t.lastIndex+=1);return t.lastIndex=n,r}i(ME,"matchAll");function OE(e,t,n){var r=typeof e=="function"?e(n):e[n];return typeof r>"u"&&n!=""?r="":typeof r>"u"&&(r="$"),typeof r=="object"?t+sn+JSON.stringify(r)+sn:t+r}i(OE,"getVar");function PE(e,t,n){n||(n={});var r=n.escape||"\\",o="(\\"+r+`['"`+$h+`]|[^\\s'"`+$h+"])+",s=new RegExp(["("+Wh+")","("+o+"|"+_E+"|"+RE+")+"].join("|"),"g"),a=ME(e,s);if(a.length===0)return[];t||(t={});var c=!1;return a.map(function(u){var d=u[0];if(!d||c)return;if(Nh.test(d))return{op:d};var l=!1,f=!1,p="",h=!1,m;function g(){m+=1;var y,w,S=d.charAt(m);if(S==="{"){if(m+=1,d.charAt(m)==="}")throw new Error("Bad substitution: "+d.slice(m-2,m+1));if(y=d.indexOf("}",m),y<0)throw new Error("Bad substitution: "+d.slice(m));w=d.slice(m,y),m=y}else if(/[*@#?$!_-]/.test(S))w=S,m+=1;else{var T=d.slice(m);y=T.match(/[^\w\d_]/),y?(w=T.slice(0,y.index),m+=y.index-1):(w=T,m=d.length)}return OE(t,"",w)}for(i(g,"parseEnvVar"),m=0;m<d.length;m++){var b=d.charAt(m);if(h=h||!l&&(b==="*"||b==="?"),f)p+=b,f=!1;else if(l)b===l?l=!1:l==Lh?p+=b:b===r?(m+=1,b=d.charAt(m),b===Dh||b===r||b===yc?p+=b:p+=r+b):b===yc?p+=g():p+=b;else if(b===Dh||b===Lh)l=b;else{if(Nh.test(b))return{op:d};if(CE.test(b)){c=!0;var v={comment:e.slice(u.index+m+1)};return p.length?[p,v]:[v]}else b===r?f=!0:b===yc?p+=g():p+=b}}return h?{op:"glob",pattern:p}:p}).reduce(function(u,d){return typeof d>"u"?u:u.concat(d)},[])}i(PE,"parseInternal");jh.exports=i(function(t,n,r){var o=PE(t,n,r);return typeof n!="function"?o:o.reduce(function(s,a){if(typeof a=="object")return s.concat(a);var c=a.split(RegExp("("+sn+".*?"+sn+")","g"));return c.length===1?s.concat(c[0]):s.concat(c.filter(Boolean).map(function(u){return IE.test(u)?JSON.parse(u.split(sn)[1]):u}))},[])},"parse")});var Bh=js(Tc=>{"use strict";Tc.quote=Ph();Tc.parse=Fh()});function bv(){return{retained:[]}}i(bv,"createOutputSegmentProjection");function vv(e,t){if(t.type==="segment.started"){if(e.active?.responseId===t.responseId&&e.active.providerRequestId===t.providerRequestId&&e.active.mode===t.mode)return{state:e,accepted:!0};let n=e.active?.responseId??e.retained[e.retained.length-1]?.responseId,r=n===void 0||n===t.responseId,o=t.mode==="append"?e.active:void 0;return{accepted:!0,state:{retained:r?o?[...e.retained,o]:e.retained:[],active:{responseId:t.responseId,providerRequestId:t.providerRequestId,mode:t.mode,...t.startedAtSeq!==void 0?{startedAtSeq:t.startedAtSeq}:{},assistantText:"",thinkingText:""}}}}return e.active?.providerRequestId!==t.providerRequestId?{state:e,accepted:!1}:{accepted:!0,state:{...e,active:{...e.active,...t.type==="assistant.delta"?{assistantText:e.active.assistantText+t.text}:{thinkingText:e.active.thinkingText+t.text}}}}}i(vv,"reduceOutputSegmentProjection");function yv(e,t){let n=t==="assistant"?"assistantText":"thinkingText";return e.retained.map(r=>r[n]).join("")+(e.active?.[n]??"")}i(yv,"effectiveOutputSegmentText");var gr=class extends Error{static{i(this,"KodaXError")}code;constructor(t,n="KODAX_ERROR"){super(t),this.code=n,this.name="KodaXError"}};var sa=class extends gr{static{i(this,"KodaXToolError")}toolName;toolId;constructor(t,n,r){super(t,"TOOL_ERROR"),this.toolName=n,this.toolId=r,this.name="KodaXToolError"}};var ia=class extends gr{static{i(this,"KodaXSessionError")}sessionId;constructor(t,n){super(t,"SESSION_ERROR"),this.sessionId=n,this.name="KodaXSessionError"}},aa=class extends gr{static{i(this,"KodaXTerminalError")}suggestions;constructor(t,n=[]){super(t,"TERMINAL_ERROR"),this.name="KodaXTerminalError",this.suggestions=n}};function wv(){return new xo}i(wv,"createSessionControl");function ca(e,t){let n=new AbortController,r=!1,o=i(h=>{r||(r=!0,n.abort(h))},"markAborted");e.abortSignal&&(e.abortSignal.aborted?o(e.abortSignal.reason):e.abortSignal.addEventListener("abort",()=>o(e.abortSignal.reason),{once:!0}));let s=new xo;s.seed({provider:e.provider,model:e.modelOverride??e.model,reasoning:e.reasoningMode});let a=e.session?.id,c=a!=null,u=a??Tv(),l=!c&&e.session?.autoResume!==!0&&e.session?.resume!==!0?Hl({...e.session??{},id:u}):e.session,f={...e,...e.agentMode!==void 0?{agentMode:ir(e.agentMode)}:{},...l!==void 0?{session:l}:{},abortSignal:n.signal,sessionControl:s},p=dt(f,t);return{id:u,get currentProvider(){return s.getProvider()},get currentModel(){return s.getModel()},get currentReasoning(){return s.getReasoning()},get aborted(){return r},get attached(){return s.isAttached()},setProvider:i(h=>s.setProvider(h),"setProvider"),setModel:i(h=>s.setModel(h),"setModel"),setReasoning:i(h=>s.setReasoning(h),"setReasoning"),abort:i(h=>o(h),"abort"),result:p}}i(ca,"startKodaX");function Tv(){return`sess_${Date.now()}_${Math.random().toString(36).slice(2,10)}`}i(Tv,"generateSessionId");var xo=class{static{i(this,"SessionControlImpl")}mutators=null;providerValue;modelValue;reasoningValue;hasPendingProvider=!1;hasPendingModel=!1;hasPendingReasoning=!1;seed(t){this.providerValue=t.provider,this.modelValue=t.model,this.reasoningValue=t.reasoning}setProvider(t){this.providerValue=t,this.mutators?this.mutators.setProvider(t):this.hasPendingProvider=!0}setModel(t){this.modelValue=t,this.mutators?this.mutators.setModel(t):this.hasPendingModel=!0}setReasoning(t){this.reasoningValue=t,this.mutators?this.mutators.setReasoning(t):this.hasPendingReasoning=!0}getProvider(){return this.providerValue??""}getModel(){return this.modelValue}getReasoning(){return this.reasoningValue}isAttached(){return this.mutators!==null}_attach(t){this.mutators,this.mutators=t,this.hasPendingProvider&&this.providerValue!==void 0&&t.setProvider(this.providerValue),this.hasPendingModel&&t.setModel(this.modelValue),this.hasPendingReasoning&&t.setReasoning(this.reasoningValue),this.hasPendingProvider=!1,this.hasPendingModel=!1,this.hasPendingReasoning=!1}};function Sv(e,t){return e.kind!=="revise_count"?{ok:!0}:e.count<=3?{ok:!0}:{ok:!1,severity:"warn",reason:`boundedRevise: revise_count for harness="${e.harness}" reached ${e.count}, exceeding soft threshold 3`}}i(Sv,"observe");var ua={id:"boundedRevise",description:"Per-harness revise count must stay within the soft threshold; crossings emit a warn signal for dispatch-eval (hard cap enforced by the budget controller).",observe:Sv};function kv(e,t){return typeof e.maxBudget!="number"?{ok:!0}:e.maxBudget<=t.systemCap.maxBudget?{ok:!0}:{ok:!1,severity:"clamp",reason:`budgetCeiling: manifest.maxBudget=${e.maxBudget} exceeds systemCap.maxBudget=${t.systemCap.maxBudget}`,patch:{clampMaxBudget:t.systemCap.maxBudget}}}i(kv,"admit");var da={id:"budgetCeiling",description:"manifest.maxBudget must be \u2264 systemCap.maxBudget; over-cap declarations are clamped down to the cap.",admit:kv};function xv(e,t){return{ok:!0}}i(xv,"observe");var Ql={id:"harnessSelectionTiming",description:"FEATURE_193 V2 no-op shell \u2014 predicate always admits since V1 Scout retired. Kept registered for admission-framework / audit-array compat.",observe:xv};function Ev(e,t){if(e.kind!=="mutation_recorded")return{ok:!0};let n=t.recorder;return typeof n.todoUpdateCount!="number"?{ok:!0}:n.todoUpdateCount>0?{ok:!0}:n.workerTrivialDeclaration===!0?{ok:!0}:{ok:!1,severity:"warn",reason:`planBeforeMutate: Worker mutated ${e.file} without a prior todo_update plan commit and without a trivial declaration`}}i(Ev,"observe");var Zl={id:"planBeforeMutate",description:"Worker mutations should be preceded by a todo_update plan commit (or an explicit trivial declaration). Missing plan is a warn-only signal in v0.7.36.",observe:Ev};function la(e){switch(e){case"read":case"glob":case"grep":case"code_search":case"semantic_lookup":case"lsp_definition":case"lsp_hover":case"lsp_references":case"lsp_document_symbols":case"lsp_workspace_symbols":case"lsp_implementation":case"lsp_prepare_call_hierarchy":case"lsp_incoming_calls":case"lsp_outgoing_calls":case"repo_overview":case"changed_scope":case"changed_diff":case"changed_diff_bundle":case"module_context":case"symbol_context":case"process_context":case"impact_estimate":case"relationship_scan":case"cyclic_dependencies":case"ask_user_question":case"exit_plan_mode":return"read";case"write":case"edit":case"multi_edit":case"insert_after_anchor":case"undo":return"edit";case"bash":return"bash:mutating";case"web_search":case"web_fetch":case"mcp_search":case"mcp_describe":case"mcp_call":case"mcp_read_resource":case"mcp_get_prompt":return"bash:network";case"spawn_agent":case"send_message":case"followup_task":case"wait_agent":case"interrupt_agent":case"list_agents":case"agent_output":case"emit_verdict":case"scaffold_tool":case"validate_tool":case"stage_construction":case"test_tool":case"activate_tool":case"scaffold_agent":case"validate_agent":case"stage_agent_construction":case"test_agent":case"activate_agent":case"worktree_create":case"worktree_remove":return"subagent";default:return"subagent"}}i(la,"resolveToolCapability");function _v(e){if(typeof e=="object"&&e!==null&&"name"in e){let t=e.name;if(typeof t=="string"&&t.length>0)return t}}i(_v,"getToolName");function Rv(e,t){if(!e.tools||e.tools.length===0)return{ok:!0};let n=new Set(t.systemCap.allowedToolCapabilities),r=[];for(let a of e.tools){let c=_v(a);if(!c)continue;let u=la(c);n.has(u)||r.push({name:c,capability:u})}if(r.length===0)return{ok:!0};let o=r.map(a=>a.name);return{ok:!1,severity:"clamp",reason:`toolPermission: tools requiring disallowed capabilities \u2014 ${r.map(a=>`${a.name}=${a.capability}`).join(", ")}`,patch:{removeTools:o}}}i(Rv,"admit");var fa={id:"toolPermission",description:"Every tool in manifest.tools must resolve to a capability tier that systemCap.allowedToolCapabilities permits; offending tools are clamped via removeTools.",admit:Rv};var ef=[da,fa,ua,Ql,Zl];function Cv(){Bu();for(let e of ef)Du(e)}i(Cv,"registerCodingInvariants");var Eo=class{static{i(this,"KodaXClient")}options;sessionId;messages=[];contextTokenSnapshot;constructor(t){this.options=t,this.sessionId=t.session?.id??"",this.messages=t.session?.initialMessages?[...t.session.initialMessages]:[],this.contextTokenSnapshot=t.context?.contextTokenSnapshot}async send(t){let n=this.messages.length>0?this.messages:this.options.session?.initialMessages,r=await dt({...this.options,session:{...this.options.session,id:this.sessionId||void 0,initialMessages:n},context:{...this.options.context,contextTokenSnapshot:this.contextTokenSnapshot}},t);return this.sessionId=r.sessionId,this.messages=r.messages,this.contextTokenSnapshot=r.contextTokenSnapshot,r}getSessionId(){return this.sessionId}getMessages(){return[...this.messages]}clear(){this.messages=[],this.sessionId="",this.contextTokenSnapshot=void 0}};function tf(e){return/\bworkflows?\b|工作流(?!程)|ワークフロー|워크플로우/iu.test(e)}i(tf,"hasExplicitNaturalLanguageWorkflowIntent");function nO(e){return{action:e.source==="command"?"suggest":"none"}}i(nO,"decideWorkflowInvocation");function rO(e){return e.outcome==="started"||e.outcome==="cancelled"}i(rO,"workflowStartOutcomeConsumesTurn");var Av="KODAX_VERIFIER_PROVIDER",Iv="KODAX_VERIFIER_MODEL";function Mv(e){if(qt(e))try{return zt(e)}catch{return}}i(Mv,"tryGetProvider");function _o(e){let t=e.env??process.env,n=t[Av],r=t[Iv];if(n&&r){let o=Mv(n);if(o)return{provider:o,model:r,providerName:n,source:"explicit-env"}}return{provider:e.mainProvider,model:e.mainModel,providerName:e.mainProviderName,source:"inherit-main"}}i(_o,"resolveVerifierProvider");function ma(e){let t=e.context?.agentProfile;if(!t)return;let n=t.verification,r=e.context?.taskVerification;if(!n&&!r)return;let o={...n,...r};return Array.isArray(r?.criteria)&&r.criteria.length===0&&Array.isArray(n?.criteria)&&n.criteria.length>0?{...o,criteria:n.criteria}:o}i(ma,"resolveEffectiveVerification");function Ov(e){let t=e.provider??"anthropic";if(qt(t))try{let n=_o({mainProvider:zt(t),mainProviderName:t,mainModel:e.modelOverride??e.model});return{provider:n.providerName,...n.model!==void 0?{model:n.model}:{}}}catch{return}}i(Ov,"resolveVerifierAttribution");function pa(e,t){let n=e.events?.onEffectiveConfig;if(!n)return;let r=t.verifier??Ov(e),o={agentMode:t.agentMode,agentProfile:e.context?.agentProfile,toolScope:t.toolScope,verification:ma(e),...r?{verifier:r}:{}};try{n(o)}catch{}}i(pa,"emitEffectiveTaskConfig");var nf="kodax-review-findings",rf="kodax-investigation-shards",of="kodax-lookup-shards",sf="kodax-child-result";var af="kodax-budget-request";function Yt(e,t=!1){return{globalWorkBudget:e?.totalBudget,budgetUsage:e?.spentBudget,budgetApprovalRequired:t}}i(Yt,"buildManagedStatusBudgetFields");function br(e,t=1){e.spentBudget=Math.max(0,e.spentBudget+t)}i(br,"incrementManagedBudgetUsage");function Nv(e,t=200){e.totalBudget+=t}i(Nv,"extendManagedWorkBudget");function Co(e,t,n=!1){if(!e?.askUser)return!1;if(!n){let r=Math.ceil(t.totalBudget*.9);if(t.spentBudget<r)return!1}return t.lastApprovalBudgetTotal!==t.totalBudget}i(Co,"canRequestAdditionalWorkBudget");async function ha(e,t,n){let r=e?.askUser;if(!r||!Co(e,t,n.force))return"skipped";let o=n.additionalUnits??200,s=Math.min(100,Math.round(t.spentBudget/Math.max(1,t.totalBudget)*100)),a=/[\u4e00-\u9fff]/.test(n.originalTask??n.summary),c=nt(await r({question:a?`\u5F53\u524D AMA \u8FD0\u884C\u5DF2\u4F7F\u7528 ${t.spentBudget}/${t.totalBudget} \u5DE5\u4F5C\u5355\u5143\uFF08${s}%\uFF09\uFF0C\u9700\u8981\u66F4\u591A\u5DE5\u4F5C\u91CF\u3002\u662F\u5426\u8FFD\u52A0 ${o} \u5355\u5143\uFF1F`:`This AMA run has used ${t.spentBudget}/${t.totalBudget} work units (${s}%) and needs more work. Add ${o} more work units?`,allowCustomInput:!1,options:[{label:a?`\u7EE7\u7EED (+${o})`:`Continue (+${o})`,value:"continue",description:a?`\u8FFD\u52A0 ${o} \u5DE5\u4F5C\u5355\u5143\uFF0C\u4ECE\u7B2C ${n.currentRound}/${n.maxRounds} \u8F6E\u7EE7\u7EED\u3002`:`Grant ${o} more work units and continue from round ${n.currentRound}/${n.maxRounds}.`},{label:a?"\u505C\u6B62":"Stop here",value:"stop",description:a?`\u4F7F\u7528\u5F53\u524D\u6700\u4F73\u7ED3\u679C\u3002\u6700\u65B0\u8FDB\u5C55\uFF1A${Li(n.summary,80)}`:`Finish now with the current best result. Latest note: ${Li(n.summary,80)}`}],default:"continue"})),u=t.totalBudget;return c==="continue"?(t.lastApprovalBudgetTotal=u,Nv(t,o),"approved"):(t.lastApprovalBudgetTotal=u,"denied")}i(ha,"maybeRequestAdditionalWorkBudget");import{readdir as Wv,readFile as uf,stat as jv}from"node:fs/promises";import{execFile as Fv}from"node:child_process";import{promisify as Bv}from"node:util";import Cn from"node:path";import ga from"node:path";import{mkdir as $v,unlink as Lv,writeFile as Dv}from"node:fs/promises";function xt(e){return e.context?.taskSurface??"cli"}i(xt,"getManagedTaskSurface");function Et(e,t){if(e.context?.managedTaskWorkspaceDir?.trim())return ga.resolve(e.context.managedTaskWorkspaceDir);let n=e.context?.executionCwd??e.context?.gitRoot??process.cwd();return ga.resolve(n,".agent","managed-tasks")}i(Et,"getManagedTaskWorkspaceRoot");async function ie(e,t,n="utf8"){await ni(e,async()=>{await $v(ga.dirname(e),{recursive:!0}),await Dv(e,t,"utf8")})}i(ie,"writeManagedTaskFile");async function cf(e){await ni(e,async()=>{try{await Lv(e)}catch(t){if(t.code!=="ENOENT")throw t}})}i(cf,"deleteManagedTaskFile");var Uv=Bv(Fv),df=3600*1e3,Ao="checkpoint.json";function ba(e){let t=e.session?.id?.trim();return t||void 0}i(ba,"getCheckpointSessionId");function Gv(e,t){return t?e.sessionId===t:!1}i(Gv,"checkpointBelongsToSession");async function Io(e){let t=Cn.resolve(e?.trim()||process.cwd());try{let{stdout:n}=await Uv("git",["rev-parse","--short","HEAD"],{cwd:t,windowsHide:!0});return n.trim()||void 0}catch{return}}i(Io,"getGitHeadCommit");async function va(e,t){await ie(Cn.join(e,Ao),`${JSON.stringify(t,null,2)}
|
|
3
3
|
`,"utf8")}i(va,"writeCheckpoint");async function Jt(e){await cf(Cn.join(e,Ao))}i(Jt,"deleteCheckpoint");async function ya(e){let t=e.context?.gitRoot,n=xt(e),r=Et(e,n),o;try{o=await Wv(r)}catch{return}let s=await Io(t),a=ba(e),c=Date.now();for(let u of o){let d=Cn.join(r,u),l=Cn.join(d,Ao);try{let f=await jv(l);if(!f.isFile())continue;let p=await uf(l,"utf8"),h=JSON.parse(p);if(!h||typeof h!="object")continue;let m=h;if(m.version!==1||typeof m.taskId!="string"||typeof m.createdAt!="string"||typeof m.gitCommit!="string"||typeof m.harnessProfile!="string"||m.sessionId!==void 0&&typeof m.sessionId!="string")continue;if(m.processId!==void 0||m.pid!==void 0){let _=m.processId??m.pid;if(typeof _!="number"||!Number.isFinite(_))continue}let g=m.processId??m.pid,b={version:1,taskId:m.taskId,...typeof m.sessionId=="string"&&m.sessionId.trim()?{sessionId:m.sessionId}:{},...typeof g=="number"&&Number.isFinite(g)?{processId:g}:{},createdAt:m.createdAt,gitCommit:m.gitCommit,objective:typeof m.objective=="string"?m.objective:"",harnessProfile:m.harnessProfile,currentRound:typeof m.currentRound=="number"?m.currentRound:1,completedWorkerIds:Array.isArray(m.completedWorkerIds)?m.completedWorkerIds.filter(_=>typeof _=="string"):[],scoutCompleted:m.scoutCompleted===!0},v=new Date(b.createdAt).getTime();if(Number.isNaN(v))continue;let y=c-f.mtimeMs;if(y>df||y<0){await Jt(d);continue}if(!Gv(b,a))continue;if(s&&b.gitCommit&&b.gitCommit!==s){await Jt(d);continue}let w=Cn.join(d,"managed-task.json"),S=await uf(w,"utf8"),T=JSON.parse(S);if(!T||typeof T!="object")continue;let E=T;if(!E.contract?.taskId||!E.evidence?.workspaceDir)continue;return{checkpoint:b,workspaceDir:d,managedTask:E}}catch{continue}}}i(ya,"findValidCheckpoint");import z from"node:path";function wa(e){let t=e?.runtime;return t?`${["# Runtime Execution Guide","","Use this guide to drive live verification against the runtime under test.","",t.cwd?`- Working directory: ${t.cwd}`:void 0,t.startupCommand?`- Startup command: ${t.startupCommand}`:void 0,t.readySignal?`- Ready signal: ${t.readySignal}`:void 0,t.baseUrl?`- Base URL: ${t.baseUrl}`:void 0,t.env&&Object.keys(t.env).length>0?`- Environment keys: ${Object.keys(t.env).join(", ")}`:void 0,"","Execution protocol:",t.startupCommand?"1. Start or confirm the runtime using the declared startup command before accepting the task.":"1. Confirm the target runtime is available before accepting the task.",t.readySignal||t.baseUrl?"2. Wait until the runtime is ready, using the ready signal or base URL when available.":"2. Confirm runtime readiness using the strongest observable signal you have.",t.uiFlows?.length?["3. Execute the declared UI flows:",...t.uiFlows.map((r,o)=>` ${o+1}. ${r}`)].join(`
|
|
4
4
|
`):"3. Execute the critical user-facing flow when browser verification is required.",t.apiChecks?.length?["4. Run the declared API checks:",...t.apiChecks.map((r,o)=>` ${o+1}. ${r}`)].join(`
|
|
5
5
|
`):void 0,t.dbChecks?.length?["5. Run the declared DB checks:",...t.dbChecks.map((r,o)=>` ${o+1}. ${r}`)].join(`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
|
|
2
|
-
import{D,J as F}from"./chunk-
|
|
2
|
+
import{D,J as F}from"./chunk-ROSCR2VP.js";import{r as q,s as j,t as N,u as P,va as C}from"./chunk-KHPUDIG7.js";import{Bg as _,Cg as b,Dg as x,Nd as W,Od as M,Td as I,wg as $,xg as k,yg as y}from"./chunk-F7JMG426.js";import{$a as E,tb as O,x as v,y as T}from"./chunk-V7ZTP5SV.js";import{a as o}from"./chunk-ONUPGMER.js";import{join as Le}from"node:path";var ae=["You generate KodaX Dynamic Workflow scripts.","Return JSON only. Do not wrap the answer in prose.","For simple tasks that do not benefit from multiple agents, return:",'{"action":"decline","reason":"..."}',"For complex tasks, return:",'{"action":"generate","manifest":{...},"source":"async function run(wf, args) { ... }","approvalSummary":"..."}',"Generated source may only coordinate agents through wf and args.","Generated source must return displayable final text for the user.","Never use import, require, process, fs, child_process, network APIs, shell commands, or direct file access."].join(`
|
|
3
3
|
`),G=12e4,le="KODAX_WORKFLOW_GENERATION_TIMEOUT_SEC",ce="KODAX_WORKFLOW_GENERATION_TIMEOUT_MS",ue=64,fe=2,de=2e3,pe=[{name:"default"},{name:"variant-results",finalText:o((e,n)=>`Variant smoke child report from ${e} (${n}).`,"finalText"),synthesizeText:"Variant smoke synthesis report."},{name:"unverified-success",status:o(()=>"completed_unverified","status"),finalText:o(e=>`Smoke result for ${e}: completed with verification warnings.`,"finalText"),synthesizeText:"Smoke synthesis: completed with verification warnings."},{name:"empty-args-rerun",args:o(()=>({}),"args")}],me=[{id:"import",pattern:/\bimport\s*(?:\(|['"*{]|\w+\s+from\b)/},{id:"require",pattern:/\brequire\s*\(/},{id:"process",pattern:/\bprocess\s*(?:\.|\[)/},{id:"fs",pattern:/\b(?:node:)?fs\b/},{id:"child_process",pattern:/\bchild_process\b/},{id:"shell",pattern:/\b(?:exec|spawn|execFile)\s*\(/},{id:"fetch",pattern:/\bfetch\s*\(/},{id:"Deno",pattern:/\bDeno\s*(?:\.|\[)/},{id:"Bun",pattern:/\bBun\s*(?:\.|\[)/},{id:"globalThis-index",pattern:/\bglobalThis\s*\[/}];function we(e=process.env,n){let t=v(n?.workflow?.generationTimeoutSec,"timeouts.workflow.generationTimeoutSec");if(t!==void 0)return t;let r=T(e[le]);if(r!==void 0)return r;let s=e[ce];if(s===void 0||s.trim().length===0)return G;let i=Number(s);return!Number.isFinite(i)||i<=0?G:Math.floor(i)}o(we,"resolveWorkflowGenerationTimeoutMs");function he(e,n){if(typeof e!="object"||e===null)throw new Error(`${n} must be an object`);return e}o(he,"readRecord");function K(e,n){let t=e[n];if(typeof t!="string"||t.trim().length===0)throw new Error(`workflow generation ${n} must be a non-empty string`);return t}o(K,"readNonEmptyString");function ge(e){let n=e.trim(),t=/^```(?:json)?\s*([\s\S]*?)\s*```$/i.exec(n);if(t?.[1])return t[1].trim();let r=n.indexOf("{"),s=n.lastIndexOf("}");if(r>=0&&s>r)return n.slice(r,s+1);throw new Error("workflow generation output did not contain a JSON object")}o(ge,"extractJsonText");function ke(e){let n=ge(e);return he(JSON.parse(n),"workflow generation output")}o(ke,"parseGenerationJson");function ye(e){if(typeof e=="string"){let t=e.trim();return t.length>0?t:void 0}if(typeof e!="object"||e===null)return;let n=e;for(let t of["name","id","title","phase"]){let r=n[t];if(typeof r=="string"&&r.trim().length>0)return r.trim()}}o(ye,"normalizePhaseEntry");function be(e){return e.split(/(?:->|\u2192|,|\n)/).map(n=>n.trim()).filter(n=>n.length>0)}o(be,"splitPhaseString");function xe(e){if(typeof e!="object"||e===null)return e;let n=e,t=n.phases,r;if(Array.isArray(t)){let s=t.map(ye);s.every(i=>i!==void 0)&&(r=s)}else if(typeof t=="string"){let s=be(t);s.length>0&&(r=s)}return r?{...n,phases:r}:e}o(xe,"normalizeGeneratedManifestCandidate");function ve(e){return e.match(/\bwf\.(?:runAgent|spawnAgent|synthesize)\s*\(/g)?.length??0}o(ve,"estimateDirectAgentCalls");function Se(e,n){let t=e.maxConcurrency*Math.max(1,e.phases.length)+2,r=ve(n)+2,s=Math.min(ue,Math.max(e.maxAgents,t,r));return s>e.maxAgents?{...e,maxAgents:s}:e}o(Se,"reserveGeneratedWorkflowAgentCapacity");function w(e){let n="",t=0,r=["code"],s=[0];for(;t<e.length;){let i=e[t],a=e[t+1];if(r[r.length-1]==="template"){if(i==="\\"){n+=" ",t+=2;continue}if(i==="`"){n+=" ",t+=1,r.pop(),s.pop();continue}if(i==="$"&&a==="{"){n+=" ",t+=2,r.push("code"),s.push(0);continue}n+=i===`
|
|
4
4
|
`?`
|
|
5
5
|
`:" ",t+=1;continue}if(i==="/"&&a==="/"){for(n+=" ",t+=2;t<e.length&&e[t]!==`
|
|
@@ -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 Ai,D as Ri,E as Ci,F as nt,I as on,K as Ei,O as Ii,Q as nn,Z as Ce,c as vi,ca as Pi,d as ki,ea as Ti,f as bi,fa as Li,ga as Mi,h as et,i as ot,m as Si,n as $i,y as xi}from"./chunk-NIGQTWGU.js";import{a as _i}from"./chunk-YURCMKAL.js";import{Ab as gi,Ba as Zo,Bb as wi,Ca as vo,Ea as Qn,Fb as hi,Hb as yi,Ka as en,La as Zn}from"./chunk-ZSJJECST.js";import{i as Vo}from"./chunk-HXH5TOAV.js";import{$a as fi,aa as si,ab as mi,bb as pi,i as Xn,n as Jr}from"./chunk-POVUU6P2.js";import{A as ui,D as Re,J as Ke,m as Yo,n as Jo,o as He,q as ho,r as Qo,s as ai,t as li,v as ci,w as Jn,x as di,y as yo}from"./chunk-B4FK5XVU.js";import{Bc as Yn,Cc as Xo,Fc as ri,bc as oi,dc as ni,ec as ti,hb as zo,hc as Vn,ja as ei,r as Qr,s as Zr,td as ii,vd as ae}from"./chunk-H6NNJO5M.js";import{$b as _r,$d as Kr,Ef as Gr,Gf as zr,Ic as Ko,Ka as we,Kc as Bo,Kf as Xr,Kg as Yr,La as N,Lc as jr,Ma as he,Na as Tr,Nc as Ur,Nd as V,Od as ne,Sa as Lr,Ta as Mr,Td as Fr,Ua as Gn,Xd as Hr,Yd as qo,bc as Wr,eg as Fe,fc as wo,fg as Vr,jg as zn,k as Ae,rc as Nr,re as Br,sc as Or,tc as Dr,tg as Go,v as oe,wf as qr}from"./chunk-F7JMG426.js";import{$a as go,Ja as qn,N as Pr,ab as je,bb as Ue,va as po,xa as Bn}from"./chunk-V7ZTP5SV.js";import{a}from"./chunk-ONUPGMER.js";import*as Dn from"fs";import*as Uo from"path";import*as Wn from"fs";import _n from"path";import i from"chalk";var tn=["plan","accept-edits","auto","full-access","auto-in-project"],ol=["plan","accept-edits","auto","full-access"];function nl(e){return e==="auto"||e==="auto-in-project"}a(nl,"isAutoMode");function Ee(e){return e==="auto-in-project"?"auto":e}a(Ee,"canonicalizePermissionMode");function tl(e){switch(e){case"plan":return"Plan";case"accept-edits":return"Edits";case"auto":case"auto-in-project":return"Auto";case"full-access":return"Full Access"}}a(tl,"permissionModeDisplayName");function Ni(e){switch(e){case"plan":return new Set(["bash","write","edit","undo"]);case"accept-edits":return new Set(["bash"]);case"auto":case"full-access":case"auto-in-project":return new Set}}a(Ni,"computeConfirmTools");function Oi(e){return e!==void 0&&tn.includes(e)}a(Oi,"isPermissionMode");function ko(e,o){return Oi(e)?Ee(e):o===void 0?void 0:Ee(o)}a(ko,"normalizePermissionMode");import{createHash as rl,randomUUID as il}from"node:crypto";import qe from"node:fs";import Di from"node:path";var So=class extends Error{static{a(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{a(this,"ProviderSetupInvalidConfigError")}constructor(o,n){super(`KodaX configuration cannot be safely updated: ${o}. ${n}`),this.name="ProviderSetupInvalidConfigError"}},Bi=/^[A-Za-z_][A-Za-z0-9_]*$/,sl=new Set(["accesskey","apikey","accesstoken","auth","authorization","bearertoken","clientsecret","credential","key","password","privatekey","refreshtoken","secret","sig","signature","token","xapikey"]);function ze(){return Object.entries(po).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===Bn?-1:o.name===Bn?1:e.name.localeCompare(o.name))}a(ze,"getProviderSetupCatalog");function qi(e={}){let o=e.configPath??N("config.json"),n=e.catalog??ze(),t=e.environment??process.env,r=rt(o);if(!r.config)return{status:"invalid-config",configPath:o,configRevision:r.revision,reason:r.error??"config.json is not a JSON object."};let s=Xi(r.config);if(s)return{status:"invalid-config",configPath:o,configRevision:r.revision,reason:s};let l=Fi(e.explicitProvider);if(l){let d=Ki(r.config,l,n);return d&&(!d.requiresCredential||Hi(t,d.apiKeyEnv))?ji(o,r.revision,l):Ui(o,r.revision,l,d?.apiKeyEnv)}if(!r.exists)return{status:"needs-provider",configPath:o,configRevision:r.revision};let c=Fi(r.config.provider);if(c){let d=Ki(r.config,c,n);return d?!d.requiresCredential||Hi(t,d.apiKeyEnv)?ji(o,r.revision,c):Ui(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}}a(qi,"inspectProviderSetupReadiness");function Gi(e){let o=e.configPath??N("config.json"),n=e.catalog??ze();try{return bi(o,()=>{let t=rt(o);if(!t.config)throw new Ge(o,t.error??"config.json is invalid JSON.");if(t.revision!==e.expectedRevision)throw new So(o);al(t.config,o);let r=cl(e.choice,n,t.config),s={...t.config,provider:r.provider,model:r.model,...r.customProviders?{customProviders:r.customProviders}:{}};if(rt(o).revision!==e.expectedRevision)throw new So(o);return dl(o,s),{provider:r.provider,model:r.model,apiKeyEnv:r.apiKeyEnv,configPath:o}})}catch(t){throw t instanceof ki?new So(o):t}}a(Gi,"persistProviderSetupChoice");function zi(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."]}a(zi,"providerSetupRestartInstructions");function ji(e,o,n){return{status:"ready",configPath:e,configRevision:o,...n?{provider:n}:{}}}a(ji,"ready");function Ui(e,o,n,t){return{status:"needs-credential",configPath:e,configRevision:o,provider:n,...t?{apiKeyEnv:t}:{}}}a(Ui,"needsCredential");function Fi(e){return typeof e=="string"&&e.trim()?e.trim():void 0}a(Fi,"normalizedString");function Hi(e,o){return o!==void 0&&!!e[o]?.trim()}a(Hi,"hasEnvironmentValue");function Ki(e,o,n){let t=n.find(l=>l.name===o);if(t)return{apiKeyEnv:t.apiKeyEnv,requiresCredential:!0};if(Object.entries(po).find(([l])=>l===o)?.[1]?.capabilityProfile.transport==="cli-bridge")return{requiresCredential:!1};let s=ll(e,o);return s?{apiKeyEnv:s.apiKeyEnv,requiresCredential:!0}:void 0}a(Ki,"resolveConfiguredProvider");function al(e,o){let n=Xi(e);if(n)throw new Ge(o,n)}a(al,"assertCustomProvidersPreservable");function Xi(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=it(t);if(!r)return"Existing customProviders contains an invalid entry; repair it before running setup.";let s=Vi(r.baseUrl);if(s)return`Existing customProviders entry "${r.name}" is unsafe: ${s}`;if(n.has(r.name))return`Existing customProviders contains duplicate name "${r.name}"; repair it before running setup.`;n.add(r.name)}}a(Xi,"existingCustomProvidersError");function ll(e,o){let n=e.customProviders;if(Array.isArray(n))for(let t of n){let r=it(t);if(r?.name===o)return r}}a(ll,"findValidCustomProvider");function it(e){if(!Yi(e))return;let{name:o,protocol:n,baseUrl:t,apiKeyEnv:r,model:s}=e;if(typeof o!="string"||n!=="openai"&&n!=="anthropic"||typeof t!="string"||typeof r!="string"||typeof s!="string")return;let l={...e,name:o,protocol:n,baseUrl:t,apiKeyEnv:r,model:s};try{return qn(l),Bi.test(l.apiKeyEnv)?l:void 0}catch{return}}a(it,"toValidCustomProvider");function cl(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=st(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,s=Array.isArray(r)?r.flatMap(d=>{let u=it(d);return u?[u]:[]}):[],c=s.find(d=>d.name===t.name)?s.map(d=>d.name===t.name?t:d):[...s,t];return{provider:t.name,model:t.model,apiKeyEnv:t.apiKeyEnv,customProviders:c}}a(cl,"normalizeProviderSetupChoice");function st(e){let o={name:e.name.trim(),protocol:e.protocol,baseUrl:e.baseUrl.trim(),apiKeyEnv:e.apiKeyEnv.trim(),model:e.model.trim()},n=Vi(o.baseUrl);if(n)throw new Error(n);if(qn(o),!Bi.test(o.apiKeyEnv))throw new Error("Custom provider API key environment variable name is invalid.");return o}a(st,"validateProviderSetupCustomMetadata");function Vi(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=>sl.has(t.toLowerCase().replace(/[-_.]/g,"")));return n===void 0?void 0:`Custom provider Base URL must not contain credential query parameter "${n}".`}a(Vi,"customProviderEndpointError");function rt(e){if(!qe.existsSync(e))return{configPath:e,revision:bo(void 0),exists:!1,config:{}};let o;try{o=qe.readFileSync(e,"utf8")}catch(n){return{configPath:e,revision:bo(void 0),exists:!0,error:n instanceof Error?n.message:"config.json cannot be read."}}try{let n=JSON.parse(o);return Yi(n)?{configPath:e,revision:bo(o),exists:!0,config:n}:{configPath:e,revision:bo(o),exists:!0,error:"config.json must contain a JSON object."}}catch(n){return{configPath:e,revision:bo(o),exists:!0,error:n instanceof Error?n.message:"config.json is invalid JSON."}}}a(rt,"readConfig");function bo(e){return rl("sha256").update(e??"<missing>","utf8").digest("hex")}a(bo,"revisionFor");function Yi(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}a(Yi,"isRecord");function dl(e,o){let n=Di.dirname(e);qe.mkdirSync(n,{recursive:!0});let t=Di.join(n,`.config.${process.pid}.${il()}.tmp`);try{qe.writeFileSync(t,`${JSON.stringify(o,null,2)}
|
|
2
|
+
import{A as Be,C as Ai,D as Ri,E as Ci,F as nt,I as on,K as Ei,O as Ii,Q as nn,Z as Ce,c as vi,ca as Pi,d as ki,ea as Ti,f as bi,fa as Li,ga as Mi,h as et,i as ot,m as Si,n as $i,y as xi}from"./chunk-WAKPBFEA.js";import{a as _i}from"./chunk-YURCMKAL.js";import{Ab as gi,Ba as Zo,Bb as wi,Ca as vo,Ea as Qn,Fb as hi,Hb as yi,Ka as en,La as Zn}from"./chunk-DGMNCSI3.js";import{i as Vo}from"./chunk-FZUPRAHK.js";import{$a as fi,aa as si,ab as mi,bb as pi,i as Xn,n as Jr}from"./chunk-ZMXVACRD.js";import{A as ui,D as Re,J as Ke,m as Yo,n as Jo,o as He,q as ho,r as Qo,s as ai,t as li,v as ci,w as Jn,x as di,y as yo}from"./chunk-ROSCR2VP.js";import{Bc as Yn,Cc as Xo,Fc as ri,bc as oi,dc as ni,ec as ti,hb as zo,hc as Vn,ja as ei,r as Qr,s as Zr,td as ii,vd as ae}from"./chunk-KHPUDIG7.js";import{$b as _r,$d as Kr,Ef as Gr,Gf as zr,Ic as Ko,Ka as we,Kc as Bo,Kf as Xr,Kg as Yr,La as N,Lc as jr,Ma as he,Na as Tr,Nc as Ur,Nd as V,Od as ne,Sa as Lr,Ta as Mr,Td as Fr,Ua as Gn,Xd as Hr,Yd as qo,bc as Wr,eg as Fe,fc as wo,fg as Vr,jg as zn,k as Ae,rc as Nr,re as Br,sc as Or,tc as Dr,tg as Go,v as oe,wf as qr}from"./chunk-F7JMG426.js";import{$a as go,Ja as qn,N as Pr,ab as je,bb as Ue,va as po,xa as Bn}from"./chunk-V7ZTP5SV.js";import{a}from"./chunk-ONUPGMER.js";import*as Dn from"fs";import*as Uo from"path";import*as Wn from"fs";import _n from"path";import i from"chalk";var tn=["plan","accept-edits","auto","full-access","auto-in-project"],ol=["plan","accept-edits","auto","full-access"];function nl(e){return e==="auto"||e==="auto-in-project"}a(nl,"isAutoMode");function Ee(e){return e==="auto-in-project"?"auto":e}a(Ee,"canonicalizePermissionMode");function tl(e){switch(e){case"plan":return"Plan";case"accept-edits":return"Edits";case"auto":case"auto-in-project":return"Auto";case"full-access":return"Full Access"}}a(tl,"permissionModeDisplayName");function Ni(e){switch(e){case"plan":return new Set(["bash","write","edit","undo"]);case"accept-edits":return new Set(["bash"]);case"auto":case"full-access":case"auto-in-project":return new Set}}a(Ni,"computeConfirmTools");function Oi(e){return e!==void 0&&tn.includes(e)}a(Oi,"isPermissionMode");function ko(e,o){return Oi(e)?Ee(e):o===void 0?void 0:Ee(o)}a(ko,"normalizePermissionMode");import{createHash as rl,randomUUID as il}from"node:crypto";import qe from"node:fs";import Di from"node:path";var So=class extends Error{static{a(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{a(this,"ProviderSetupInvalidConfigError")}constructor(o,n){super(`KodaX configuration cannot be safely updated: ${o}. ${n}`),this.name="ProviderSetupInvalidConfigError"}},Bi=/^[A-Za-z_][A-Za-z0-9_]*$/,sl=new Set(["accesskey","apikey","accesstoken","auth","authorization","bearertoken","clientsecret","credential","key","password","privatekey","refreshtoken","secret","sig","signature","token","xapikey"]);function ze(){return Object.entries(po).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===Bn?-1:o.name===Bn?1:e.name.localeCompare(o.name))}a(ze,"getProviderSetupCatalog");function qi(e={}){let o=e.configPath??N("config.json"),n=e.catalog??ze(),t=e.environment??process.env,r=rt(o);if(!r.config)return{status:"invalid-config",configPath:o,configRevision:r.revision,reason:r.error??"config.json is not a JSON object."};let s=Xi(r.config);if(s)return{status:"invalid-config",configPath:o,configRevision:r.revision,reason:s};let l=Fi(e.explicitProvider);if(l){let d=Ki(r.config,l,n);return d&&(!d.requiresCredential||Hi(t,d.apiKeyEnv))?ji(o,r.revision,l):Ui(o,r.revision,l,d?.apiKeyEnv)}if(!r.exists)return{status:"needs-provider",configPath:o,configRevision:r.revision};let c=Fi(r.config.provider);if(c){let d=Ki(r.config,c,n);return d?!d.requiresCredential||Hi(t,d.apiKeyEnv)?ji(o,r.revision,c):Ui(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}}a(qi,"inspectProviderSetupReadiness");function Gi(e){let o=e.configPath??N("config.json"),n=e.catalog??ze();try{return bi(o,()=>{let t=rt(o);if(!t.config)throw new Ge(o,t.error??"config.json is invalid JSON.");if(t.revision!==e.expectedRevision)throw new So(o);al(t.config,o);let r=cl(e.choice,n,t.config),s={...t.config,provider:r.provider,model:r.model,...r.customProviders?{customProviders:r.customProviders}:{}};if(rt(o).revision!==e.expectedRevision)throw new So(o);return dl(o,s),{provider:r.provider,model:r.model,apiKeyEnv:r.apiKeyEnv,configPath:o}})}catch(t){throw t instanceof ki?new So(o):t}}a(Gi,"persistProviderSetupChoice");function zi(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."]}a(zi,"providerSetupRestartInstructions");function ji(e,o,n){return{status:"ready",configPath:e,configRevision:o,...n?{provider:n}:{}}}a(ji,"ready");function Ui(e,o,n,t){return{status:"needs-credential",configPath:e,configRevision:o,provider:n,...t?{apiKeyEnv:t}:{}}}a(Ui,"needsCredential");function Fi(e){return typeof e=="string"&&e.trim()?e.trim():void 0}a(Fi,"normalizedString");function Hi(e,o){return o!==void 0&&!!e[o]?.trim()}a(Hi,"hasEnvironmentValue");function Ki(e,o,n){let t=n.find(l=>l.name===o);if(t)return{apiKeyEnv:t.apiKeyEnv,requiresCredential:!0};if(Object.entries(po).find(([l])=>l===o)?.[1]?.capabilityProfile.transport==="cli-bridge")return{requiresCredential:!1};let s=ll(e,o);return s?{apiKeyEnv:s.apiKeyEnv,requiresCredential:!0}:void 0}a(Ki,"resolveConfiguredProvider");function al(e,o){let n=Xi(e);if(n)throw new Ge(o,n)}a(al,"assertCustomProvidersPreservable");function Xi(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=it(t);if(!r)return"Existing customProviders contains an invalid entry; repair it before running setup.";let s=Vi(r.baseUrl);if(s)return`Existing customProviders entry "${r.name}" is unsafe: ${s}`;if(n.has(r.name))return`Existing customProviders contains duplicate name "${r.name}"; repair it before running setup.`;n.add(r.name)}}a(Xi,"existingCustomProvidersError");function ll(e,o){let n=e.customProviders;if(Array.isArray(n))for(let t of n){let r=it(t);if(r?.name===o)return r}}a(ll,"findValidCustomProvider");function it(e){if(!Yi(e))return;let{name:o,protocol:n,baseUrl:t,apiKeyEnv:r,model:s}=e;if(typeof o!="string"||n!=="openai"&&n!=="anthropic"||typeof t!="string"||typeof r!="string"||typeof s!="string")return;let l={...e,name:o,protocol:n,baseUrl:t,apiKeyEnv:r,model:s};try{return qn(l),Bi.test(l.apiKeyEnv)?l:void 0}catch{return}}a(it,"toValidCustomProvider");function cl(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=st(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,s=Array.isArray(r)?r.flatMap(d=>{let u=it(d);return u?[u]:[]}):[],c=s.find(d=>d.name===t.name)?s.map(d=>d.name===t.name?t:d):[...s,t];return{provider:t.name,model:t.model,apiKeyEnv:t.apiKeyEnv,customProviders:c}}a(cl,"normalizeProviderSetupChoice");function st(e){let o={name:e.name.trim(),protocol:e.protocol,baseUrl:e.baseUrl.trim(),apiKeyEnv:e.apiKeyEnv.trim(),model:e.model.trim()},n=Vi(o.baseUrl);if(n)throw new Error(n);if(qn(o),!Bi.test(o.apiKeyEnv))throw new Error("Custom provider API key environment variable name is invalid.");return o}a(st,"validateProviderSetupCustomMetadata");function Vi(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=>sl.has(t.toLowerCase().replace(/[-_.]/g,"")));return n===void 0?void 0:`Custom provider Base URL must not contain credential query parameter "${n}".`}a(Vi,"customProviderEndpointError");function rt(e){if(!qe.existsSync(e))return{configPath:e,revision:bo(void 0),exists:!1,config:{}};let o;try{o=qe.readFileSync(e,"utf8")}catch(n){return{configPath:e,revision:bo(void 0),exists:!0,error:n instanceof Error?n.message:"config.json cannot be read."}}try{let n=JSON.parse(o);return Yi(n)?{configPath:e,revision:bo(o),exists:!0,config:n}:{configPath:e,revision:bo(o),exists:!0,error:"config.json must contain a JSON object."}}catch(n){return{configPath:e,revision:bo(o),exists:!0,error:n instanceof Error?n.message:"config.json is invalid JSON."}}}a(rt,"readConfig");function bo(e){return rl("sha256").update(e??"<missing>","utf8").digest("hex")}a(bo,"revisionFor");function Yi(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}a(Yi,"isRecord");function dl(e,o){let n=Di.dirname(e);qe.mkdirSync(n,{recursive:!0});let t=Di.join(n,`.config.${process.pid}.${il()}.tmp`);try{qe.writeFileSync(t,`${JSON.stringify(o,null,2)}
|
|
3
3
|
`,{encoding:"utf8",mode:384}),qe.renameSync(t,e)}catch(r){throw qe.rmSync(t,{force:!0}),r}}a(dl,"writeConfigAtomically");import{existsSync as Ji,mkdirSync as ul,readFileSync as Qi,writeFileSync as fl}from"node:fs";import Xe from"node:path";var ml={core:{},mcp:{version:1,servers:{}},extensions:{version:1,paths:[]},a2a:{version:2,agents:{}}},pl=["core","mcp","extensions","a2a"];function at(e,o){return o==="core"?Xe.join(e,"config.json"):Xe.join(e,"integrations",`${o}.json`)}a(at,"activePath");function gl(e,o){return o==="core"?Xe.join(e,"config.example.jsonc"):Xe.join(e,"integrations",`${o}.example.jsonc`)}a(gl,"templatePath");function wl(e){let o=e.replaceAll("\\","/");return pl.flatMap(n=>[{domain:n,kind:"active",path:at(e,n),content:`${JSON.stringify(ml[n],null,2)}
|
|
4
4
|
`},{domain:n,kind:"template",path:gl(e,n),content:vi(n).replaceAll("~/.kodax",o)}])}a(wl,"configFiles");function $o(e,o){if(e===null||typeof e!="object"||Array.isArray(e))throw new Error(`${o} must contain a JSON object.`);return e}a($o,"requireRecord");function hl(e,o){let n=$o(e,"A2A config"),t=Object.keys(n).find(s=>!["version","agents","server"].includes(s));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=$o(n.agents,"A2A config agents");if(n.server!==void 0&&$o(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.")}a(hl,"validateA2ADocument");function yl(e,o){let n=Qi(e.path,"utf8"),t;try{t=JSON.parse(n)}catch{throw new Error(`${e.domain} config is invalid JSON.`)}e.domain==="core"?$o(t,"Core config"):e.domain==="mcp"?et(t):e.domain==="extensions"?ot(t):hl(t,o)}a(yl,"validateActiveFile");function Zi(e,o){if(!Ji(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 yl(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.`}}}a(Zi,"existingFileResult");function vl(e){return e instanceof Error&&"code"in e&&e.code==="EEXIST"}a(vl,"isAlreadyExists");function kl(e,o){ul(Xe.dirname(e.path),{recursive:!0,mode:448});try{return fl(e.path,e.content,{encoding:"utf8",flag:"wx",mode:384}),{domain:e.domain,kind:e.kind,path:e.path,status:"created"}}catch(n){if(vl(n))return Zi(e,o);throw n}}a(kl,"createIfMissing");function bl(e){let o=at(e,"core");if(Ji(o))try{let n=$o(JSON.parse(Qi(o,"utf8")),"Core config"),t=Si(e);t.mcp.action==="create"&&et({version:1,servers:n.mcpServers}),t.extensions.action==="create"&&ot({version:1,paths:n.extensions})}catch(n){return`Legacy integration configuration is invalid: ${n instanceof Error?n.message:"Legacy integration config is invalid."}`}}a(bl,"legacyIntegrationDiagnostic");function es(e={}){let o=Xe.resolve(e.configHome??we()),n=wl(o),t=n.map(s=>Zi(s,e.validateA2A));if(t.some(s=>s.status==="invalid"))return{configHome:o,files:t};let r=bl(o);if(r){let s=at(o,"core");return t=t.map(l=>l.path===s?{...l,status:"invalid",diagnostic:r}:l),{configHome:o,files:t}}return $i({configHome:o}),{configHome:o,files:n.map(s=>kl(s,e.validateA2A))}}a(es,"initializeSetupConfiguration");import Ie from"node:path";var os=[{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, full-access",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 Sl(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("+")}a(Sl,"formatBinding");function lt(e){let n=os.find(t=>t.id===e)?.defaultBindings[0];return n?Sl(n):"<unavailable>"}a(lt,"shortcut");function $l(){return Object.entries(po).filter(([,e])=>e.capabilityProfile.transport==="cli-bridge").map(([e])=>e).sort()}a($l,"defaultCliBridges");function ct(e={}){let o=Ie.resolve(e.configHome??we()),n=e.catalog??ze(),t=e.cliBridges??$l(),r=n.map(s=>` ${s.name.padEnd(18)} ${s.apiKeyEnv} (default model: ${s.defaultModel})`);return["KodaX setup guide","","Configuration files (existing files are never overwritten by setup):",` Core: ${Ie.join(o,"config.json")}`,` Annotated template: ${Ie.join(o,"config.example.jsonc")}`,` MCP: ${Ie.join(o,"integrations","mcp.json")}`,` Extensions: ${Ie.join(o,"integrations","extensions.json")}`,` A2A: ${Ie.join(o,"integrations","a2a.json")}`,` Integration templates: ${Ie.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 documents the four permission profiles and Auto review.","","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 (Edits and Auto attempt it before a host-boundary decision):"," `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."," Interactive Windows CLI startup verifies the installed generation once. A missing or"," stale generation runs the same setup boundary before the REPL; concurrent startups"," converge through the setup-only lock, and ready state stays silent."," Headless, print-mode, daemon, and SDK startup never trigger UAC automatically."," Ordinary tool calls never run setup, wait on its lock, or repeat an installer."," In the REPL, use `/sandbox` to inspect readiness."," Run `kodax sandbox doctor` directly in a host terminal, not through the Bash tool."," Activate explicitly from a host terminal with `kodax sandbox setup`."," Sandboxed commands inherit the host environment, including normal development identity."," Fixed KodaX/Electron execution-control variables remain blocked."," Restart KodaX (and any persistent daemon) after changing 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|full-access] 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:",` ${lt("toggleThinking")} Cycle reasoning effort`,` ${lt("togglePermissionMode")} Cycle permission mode`,` ${lt("toggleAgentMode")} Cycle AMA/SA`," Tab Accept completion"," Esc Cancel or clear input"].join(`
|
|
5
5
|
`)}a(ct,"renderSetupGuide");import*as ns from"node:readline";import dt from"chalk";async function ts(e={}){let o=e.catalog??ze(),n=qi({...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??Cl({input:e.input??process.stdin,output:e.output??process.stdout});try{let s=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(!s||s==="cancel")return{status:"cancelled"};let l=s==="custom"?await Al(r):await xl(r,o,s.slice(8));if(!l)return{status:"cancelled"};let c=Rl(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:Gi({configPath:n.configPath,expectedRevision:n.configRevision,catalog:o,choice:l})}:{status:"cancelled"}}finally{t&&r.close?.()}}a(ts,"runProviderSetupWizard");async function xl(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)],s=await e.choose(`Choose a model for ${t.name}.`,r.map(l=>({value:l,label:l===t.defaultModel?`${l} (default)`:l})));return s?{kind:"builtin",provider:t.name,model:s}:void 0}a(xl,"collectBuiltinChoice");async function Al(e){let o=await rn(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 rn(e,"API Base URL from the provider documentation, for example https://example.com/v1");if(!t)return;let r=await rn(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 s=await rn(e,"Model identifier from the provider documentation, for example provider/model-name");if(s)return{kind:"custom",provider:st({name:o,protocol:n,baseUrl:t,apiKeyEnv:r,model:s})}}a(Al,"collectCustomChoice");async function rn(e,o){let t=(await e.text(o))?.trim();return t||void 0}a(rn,"requiredText");function Rl(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>"}`}a(Rl,"summarizeChoice");function Cl(e){let o=ns.createInterface({input:e.input,output:e.output}),n=!1;o.on("close",()=>{n=!0}),o.on("SIGINT",()=>o.close());let t=a(r=>new Promise((s,l)=>{let c=!1,d=a(f=>{c||(c=!0,o.removeListener("close",u),s(f))},"finish"),u=a(()=>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,s){for(e.output.write(`
|
|
@@ -671,4 +671,4 @@ ${f.message}
|
|
|
671
671
|
[Skill not found: ${t}]`)),!1;console.log(i.cyan(`
|
|
672
672
|
[Invoking skill: ${t}]`)),s.argumentHint&&console.log(i.dim(`Arguments: ${r||"(none)"}`)),console.log();let l=await ht(t,r,{workingDirectory:o.runtimeInfo?.executionCwd??process.cwd(),projectRoot:o.gitRoot??void 0,sessionId:o.sessionId,environment:{},executeDynamicContext:o.skillDynamicContext?.execute,disableDynamicContext:o.skillDynamicContext?.disable});return l?(console.log(i.green(`Skill activated: ${t}`)),console.log(i.dim("The skill context has been prepared for the AI.")),console.log(),{invocation:l}):!1}catch(s){return console.log(i.red(`
|
|
673
673
|
[Error invoking skill: ${s instanceof Error?s.message:String(s)}]`)),!1}}a(wr,"executeSkillCommand");var On=class{static{a(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=V(this.gitRoot);return o.size===0&&await ne(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 Kf}from"node:child_process";import*as ao from"node:path";import{promisify as Bf}from"node:util";var qa=Bf(Kf);function qf(e){let o=e.slice(3);if(!o)return;let n=o.indexOf(" -> ");return(n===-1?o:o.slice(n+4)).replace(/^"(.*)"$/,"$1").trim()||void 0}a(qf,"pathFromPorcelainLine");async function Ga(e,o=10){try{let[{stdout:n},{stdout:t}]=await Promise.all([qa("git rev-parse --show-toplevel",{cwd:e,windowsHide:!0}),qa("git status --porcelain=v1 -uall",{cwd:e,windowsHide:!0})]),r=n.trim(),s=[],l=new Set;for(let c of t.split(`
|
|
674
|
-
`)){if(!c.trim())continue;let d=qf(c);if(!d)continue;let u=ao.resolve(r,d),f=ao.relative(e,u).split(ao.sep).join("/");if(!(!f||f.startsWith("..")||l.has(f))&&(l.add(f),s.push(f),s.length>=o))break}return s}catch{return[]}}a(Ga,"getRecentWorkingSetFiles");function lo(e){let o=e.lastIndexOf("/");if(o===-1)return-1;for(;o>0&&!/\s/.test(e[o-1]??"");)if(o=e.lastIndexOf("/",o-1),o===-1)return-1;return o}a(lo,"findCommandSlashIndex");var vr=class{static{a(this,"FileCompleter")}cwdSource;cache=new Map;cacheTimeout=5e3;recentCache=new Map;recentFilesProvider;constructor(o,n=Ga){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 s=t.slice(r+1),l=[],c=this.resolveCwd(),d=s.lastIndexOf("/"),u=d===-1?c:Uo.join(c,s.slice(0,d)),f=d===-1?s:s.slice(d+1);try{let b=(await this.readdir(u)).filter(S=>S.toLowerCase().startsWith(f.toLowerCase()));for(let S of b){let R=Uo.join(u,S),A=await this.isDirectory(R),y=d===-1?S:s.slice(0,d+1)+S;l.push({text:"@"+y+(A?"/":""),display:S+(A?"/":""),description:A?"directory":"file",type:"file"})}}catch{}if(d===-1){let p=await this.getRecentFiles(c),b=new Set(l.map(A=>A.text)),S=f.toLowerCase(),R=[];for(let A of p){if(f&&!Uo.basename(A).toLowerCase().startsWith(S))continue;let y="@"+A;b.has(y)||(b.add(y),R.push({text:y,display:A,description:"recent",type:"file"}))}l.unshift(...R)}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=>{Dn.readdir(o,(s,l)=>{s?r([]):(this.cache.set(o,{entries:l,expiresAt:Date.now()+this.cacheTimeout}),r(l))})}))}async isDirectory(o){return new Promise(n=>{Dn.stat(o,(t,r)=>{n(!t&&r.isDirectory())})})}},kr=class{static{a(this,"CommandCompleter")}commands;constructor(){this.commands=new Map,this.loadCommands()}loadCommands(){for(let n of so().getAll())n.userInvocable!==!1&&this.commands.set(n.name,{description:n.description,aliases:n.aliases??[]});let o=ae();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=lo(t);return r===-1?!1:!t.slice(r).includes(" ")}async getCompletions(o,n){let t=o.slice(0,n),r=lo(t);if(r===-1)return[];this.commands.clear(),this.loadCommands();let s=t.slice(r+1).toLowerCase(),l=[];for(let[c,d]of this.commands){this.fuzzyMatch(s,c)&&l.push({text:"/"+c,display:"/"+c,description:d.description,type:"command"});for(let u of d.aliases)u!==c&&this.fuzzyMatch(s,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(),s=0;for(let l=0;l<r.length&&s<t.length;l++)r[l]===t[s]&&s++;return s===t.length}};function Uv(e){let o=new vr(e),n=new On,t=new kr;return async r=>{let s=r.includes("@"),l=r.includes("/");if(!s&&!l)return[[],r];let c=[];if(l){let u=await Gf(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(s&&o.canComplete(r,r.length)){let u=await o.getCompletions(r,r.length);c.push(...u)}return[c.map(u=>zf(r,u)),r]}}a(Uv,"createCompleter");async function Gf(e,o){let{ArgumentCompleter:n}=await import("./argument-completer-6TSU5AEB.js"),t=new n;return t.canComplete(e,o)?t.getCompletions(e,o):[]}a(Gf,"getArgumentCompletions");function zf(e,o){if(o.type!=="argument")return o.text;let n=lo(e);if(n!==-1&&!/\s/.test(e.slice(n)))return`${e} ${o.text}`;let r=e.match(/\S+$/)?.[0]??"";return`${r?e.slice(0,e.length-r.length):e}${o.text}`}a(zf,"formatReadlineCompletion");import{existsSync as jn,readdirSync as Ya,readFileSync as Ja}from"node:fs";import{join as Un}from"node:path";var Xf=[{name:"plan",description:"Read-only planning mode - blocks all modifications",type:"enum"},{name:"accept-edits",description:"Sandbox first; user decides only at the host boundary",type:"enum"},{name:"auto",description:"Use sandbox execution with LLM review at the host boundary",type:"enum"},{name:"full-access",description:"Direct host execution without sandbox or approval prompts",type:"enum"}],co=[{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 Vf(e){if(e&&e.includes("/")){let o=e.indexOf("/"),n=e.slice(0,o),t=e.slice(o+1);if(je(n))try{return Be(n).filter(s=>!t||s.toLowerCase().includes(t.toLowerCase())).map(s=>({name:`${n}/${s}`,description:s,type:"enum"}))}catch{}return[]}return Ue().map(o=>({name:o,description:`Switch to ${o} provider`,type:"enum"}))}a(Vf,"getModelArgs");var br=[{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"}],Sr=[{name:"all",description:"Delete ALL sessions",type:"enum"}],Yf=[{name:"status",description:"Show MCP server status",type:"enum"},{name:"refresh",description:"Refresh MCP server catalogs",type:"enum"}],Jf=[{name:"status",description:"Show child-task fallback order",type:"enum"},{name:"off",description:"Disable child-task fallback providers",type:"enum"}],za=[{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"}],Xa=[{name:"on",description:"Enable logging",type:"enum"},{name:"off",description:"Disable logging",type:"enum"}],Qf=[{name:"list",description:"Summarize accepted Memory",type:"enum"},{name:"remember",description:"Remember one explicit keyed claim now",type:"enum"},{name:"forget",description:"Forget one exact accepted Memory",type:"enum"},{name:"decisions",description:"List exceptional changes that need you",type:"enum"},{name:"show",description:"Show one accepted Memory or decision",type:"enum"},{name:"approve",description:"Approve one reviewed decision",type:"enum"},{name:"reject",description:"Reject one reviewed decision",type:"enum"},{name:"doctor",description:"Diagnose the Memory pipeline",type:"enum"},{name:"open",description:"Open Memory in an external editor",type:"enum"},{name:"help",description:"Show memory help",type:"enum"}],Zf=[{name:"list",description:"List learned capabilities",type:"enum"},{name:"ready",description:"List capabilities ready for review/control",type:"enum"},{name:"pending",description:"Compatibility alias for ready 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 em(e){let[o=""]=e,n=o.toLowerCase(),t=e.length===1&&e[0]===""?0:e.length;return t<=1?Zf: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"}]:[]}a(em,"getLearnArgs");var om=[{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"}],nm=[{name:"show",description:"Show a captured paste by id",type:"enum"},{name:"list",description:"List captured pastes",type:"enum"}],tm=[{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"}],rm=[{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"}],im=[{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"}],sm=[{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"}],am=[{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"}],lm=[{name:"status",description:"Deprecated alias for /repo-intel status",type:"enum"}],cm=[{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"}],dm=new Set(["show","pause","resume","stop","delete","rerun","save","rename","revise"]),um=new Set(["show","delete","rerun","save","rename","revise"]),fm=[{name:"--all",description:"Show all persisted workflow runs",type:"enum"},{name:"--limit",description:"Show at most N persisted workflow runs",type:"enum"}],mm=[{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"}],pm=[{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"}],gm=[".workflow.json",".ts",".mjs",".js"];function wm(e,o){switch(e){case"pause":return o==="running";case"resume":return o==="paused";case"stop":return o==="running"||o==="paused";case"delete":return o!=="running"&&o!=="paused";default:return!0}}a(wm,"workflowRunMatchesSubcommand");function Fn(e){return/^[a-zA-Z0-9._-]{1,120}$/.test(e)&&!e.startsWith(".")&&!e.includes("..")}a(Fn,"isWorkflowRunEntryName");function hm(e,o){let n=Un(e,"workflow-metadata.json");if(jn(n))try{let r=JSON.parse(Ja(n,"utf8"));if(typeof r=="object"&&r!==null){let s=r.displayName;if(typeof s=="string"&&Fn(s.trim()))return s.trim()}}catch{}let t=o.displayName;return typeof t=="string"&&Fn(t.trim())?t.trim():void 0}a(hm,"readWorkflowRunDisplayName");function ym(){let e=ke(process.cwd()).key,o=N("workflow-runs",e);if(!jn(o))return[];let n=[];for(let t of Ya(o)){if(!Fn(t))continue;let r=Un(o,t,"run.json");if(jn(r))try{let s=JSON.parse(Ja(r,"utf8")),l=typeof s.workflow=="string"?s.workflow:"?",c=typeof s.status=="string"?s.status:"?",d=typeof s.endedAt=="number"?s.endedAt:0;n.push({arg:{name:t,description:`${l} - ${c}`,type:"string"},endedAt:d});let u=hm(Un(o,t),s);u&&u!==t&&n.push({arg:{name:u,description:`${l} alias for ${t} - ${c}`,type:"string"},endedAt:d})}catch{}}return n.sort((t,r)=>r.endedAt-t.endedAt).map(t=>t.arg)}a(ym,"getPersistedWorkflowRunIdArgs");function Hn(e){let o=Ke().list().filter(r=>wm(e,r.status)).map(r=>({name:r.runId,description:`${r.workflow} - ${r.status}`,type:"string"})),n=um.has(e)?ym():[],t=new Set;return[...o,...n].filter(r=>t.has(r.name)?!1:(t.add(r.name),!0))}a(Hn,"getWorkflowRunIdArgs");function vm(e){for(let o of gm)if(e.endsWith(o)){let n=e.slice(0,-o.length);return Fn(n)?n:void 0}}a(vm,"savedWorkflowNameFromFile");function Fo(e={}){let o=[{path:N("workflows"),source:"personal"},{path:Un(process.cwd(),".kodax","workflows"),source:"project"}],n=new Map;for(let t of o)if(jn(t.path))try{for(let r of Ya(t.path)){if(e.generatedOnly===!0&&!r.endsWith(".workflow.json"))continue;let s=vm(r);s&&n.set(s,{name:s,description:`${t.source} saved workflow`,type:"enum"})}}catch{}return[...n.values()].sort((t,r)=>t.name.localeCompare(r.name))}a(Fo,"getSavedWorkflowNameArgs");function km(){let e=new Map;for(let o of Hn("rerun"))e.set(o.name,{...o,description:`recent run: ${o.description}`,type:"string"});for(let o of Fo()){let n=e.get(o.name);if(n){e.set(o.name,{...n,description:`${n.description}; also ${o.description}`});continue}e.set(o.name,{...o,description:o.description,type:"string"})}return[...e.values()]}a(km,"getWorkflowRerunArgs");function $r(e){let o=new Map;for(let n of Hn(e))o.set(n.name,{...n,description:`workflow run: ${n.description}`,type:"string"});for(let n of Fo({generatedOnly:e==="delete"})){let t=o.get(n.name);if(t){o.set(n.name,{...t,description:`${t.description}; also ${n.description}`});continue}o.set(n.name,{...n,description:n.description,type:"string"})}return[...o.values()]}a($r,"getWorkflowRunOrSavedNameArgs");function Va(e){let o=new Set(e.slice(1).filter(n=>n.startsWith("--")));return o.has("--saved")?Fo({generatedOnly:!0}):o.has("--run")?Hn("delete"):$r("delete")}a(Va,"getWorkflowDeleteTargetArgs");function bm(e){let[o=""]=e,n=o.toLowerCase(),t=e.length===1&&e[0]===""?0:e.length;if(t<=1)return[...cm,...Jo().map(r=>({name:r.name,description:r.description,type:"enum"})),...Fo()];if(n==="rerun"&&t<=2)return km();if(n==="rename"&&t<=2)return $r("rename");if(n==="delete"&&t<=2)return[...pm,...Va(e)];if(n==="delete"&&t<=3&&e.slice(1).some(r=>r.startsWith("--")))return Va(e);if(n==="revise"){if(t<=2)return[{name:"--replace",description:"Replace a saved workflow after confirmation",type:"enum"},...$r("revise")];if(e[1]==="--replace"&&t<=3)return Fo()}return dm.has(n)&&t<=2?Hn(n):n==="runs"&&t<=2?fm:n==="prune"&&t<=2?mm:[]}a(bm,"getWorkflowArgs");function Sm(e){let[o=""]=e,n=o.toLowerCase(),t=e.length===1&&e[0]===""?0:e.length;return t<=1?im:t>2?[]:n==="mode"?sm:n==="trace"?am:[]}a(Sm,"getRepoIntelArgs");var $m=new Map([["mode",Xf],["thinking",co],["think",co],["t",co],["reasoning",co],["reason",co],["effort",co],["status",br],["info",br],["ctx",br],["mcp",Yf],["fallback",Jf],["agent-mode",za],["am",za],["verifier-log",Xa],["stall-log",Xa],["memory",Qf],["goal",om],["paste",nm],["review",tm],["agents",rm],["delete",Sr],["rm",Sr],["del",Sr]]),xm=new Set(["model","m","provider"]),Am=new Set(["repo-intel"]),Rm=new Set(["repointel","ri"]),Cm=new Set(["workflow"]),Em=new Set(["learn"]);function xr(e,o,n=[]){let t=e.toLowerCase();return xm.has(t)?Vf(o):Am.has(t)?Sm(n):Rm.has(t)?n.length<=1?lm:[]:Cm.has(t)?bm(n):Em.has(t)?em(n):$m.get(t)??[]}a(xr,"getCommandArguments");var Ar=class{static{a(this,"ArgumentCompleter")}canComplete(o,n){let t=o.slice(0,n),r=lo(t);if(r===-1)return!1;let s=t.slice(r),l=s.split(/\s+/);if(l.length>=2&&l[0]!=="")return!0;let c=s.slice(1).toLowerCase();return xr(c).length>0}async getCompletions(o,n){let t=o.slice(0,n),r=lo(t);if(r===-1)return[];let s=t.slice(r),l=s.indexOf(" "),c=(l===-1?s.slice(1):s.slice(1,l)).toLowerCase(),d=l===-1?"":s.slice(l+1),u=d?d.split(/\s+/):[""],f=u.length-1,p=u[f]??"",b=p.toLowerCase(),S=xr(c,p,u);if(!S||S.length===0)return[];let R=new Set(u.slice(0,-1).map(y=>y.toLowerCase()));return S.filter(y=>!R.has(y.name.toLowerCase())).filter(y=>!b||y.name.includes("/")?!0:y.name.toLowerCase().includes(b)).map(y=>({text:y.name,display:y.name,description:y.description,type:"argument"})).sort((y,k)=>{if(!b)return 0;let C=y.display.toLowerCase().startsWith(b),L=k.display.toLowerCase().startsWith(b);return C&&!L?-1:!C&&L?1:y.display.length-k.display.length})}};function Zv(){return new Ar}a(Zv,"createArgumentCompleter");export{kt as a,q as b,yg as c,ks as d,vg as e,tn as f,ol as g,nl as h,Ee as i,tl as j,Ni as k,Oi as l,ko as m,So as n,Ge as o,ze as p,qi as q,Gi as r,zi as s,es as t,os as u,ct as v,ts as w,jl as x,Mp as y,zp as z,Ul as A,gt as B,Xp as C,Vp as D,ms as E,Ao as F,ng as G,ht as H,tg as I,rg as J,cg as K,dg as L,vs as M,le as N,$s as O,xs as P,Ag as Q,ic as R,vc as S,Rg as T,un as U,St as V,Cg as W,_s as X,Eg as Y,Ig as Z,Pg as _,tw as $,rw as aa,iw as ba,sw as ca,Vs as da,It as ea,Ys as fa,ke as ga,Ad as ha,fw as ia,Io as ja,Wt as ka,Me as la,ou as ma,nu as na,ga as oa,Dw as pa,jw as qa,gu as ra,Wh as sa,Nh as ta,Oh as ua,ny as va,ty as wa,ry as xa,iy as ya,sy as za,Ea as Aa,fy as Ba,my as Ca,Pa as Da,py as Ea,My as Fa,Ta as Ga,so as Ha,xv as Ia,Av as Ja,Rv as Ka,On as La,Ar as Ma,Zv as Na,lo as Oa,vr as Pa,kr as Qa,Uv as Ra};
|
|
674
|
+
`)){if(!c.trim())continue;let d=qf(c);if(!d)continue;let u=ao.resolve(r,d),f=ao.relative(e,u).split(ao.sep).join("/");if(!(!f||f.startsWith("..")||l.has(f))&&(l.add(f),s.push(f),s.length>=o))break}return s}catch{return[]}}a(Ga,"getRecentWorkingSetFiles");function lo(e){let o=e.lastIndexOf("/");if(o===-1)return-1;for(;o>0&&!/\s/.test(e[o-1]??"");)if(o=e.lastIndexOf("/",o-1),o===-1)return-1;return o}a(lo,"findCommandSlashIndex");var vr=class{static{a(this,"FileCompleter")}cwdSource;cache=new Map;cacheTimeout=5e3;recentCache=new Map;recentFilesProvider;constructor(o,n=Ga){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 s=t.slice(r+1),l=[],c=this.resolveCwd(),d=s.lastIndexOf("/"),u=d===-1?c:Uo.join(c,s.slice(0,d)),f=d===-1?s:s.slice(d+1);try{let b=(await this.readdir(u)).filter(S=>S.toLowerCase().startsWith(f.toLowerCase()));for(let S of b){let R=Uo.join(u,S),A=await this.isDirectory(R),y=d===-1?S:s.slice(0,d+1)+S;l.push({text:"@"+y+(A?"/":""),display:S+(A?"/":""),description:A?"directory":"file",type:"file"})}}catch{}if(d===-1){let p=await this.getRecentFiles(c),b=new Set(l.map(A=>A.text)),S=f.toLowerCase(),R=[];for(let A of p){if(f&&!Uo.basename(A).toLowerCase().startsWith(S))continue;let y="@"+A;b.has(y)||(b.add(y),R.push({text:y,display:A,description:"recent",type:"file"}))}l.unshift(...R)}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=>{Dn.readdir(o,(s,l)=>{s?r([]):(this.cache.set(o,{entries:l,expiresAt:Date.now()+this.cacheTimeout}),r(l))})}))}async isDirectory(o){return new Promise(n=>{Dn.stat(o,(t,r)=>{n(!t&&r.isDirectory())})})}},kr=class{static{a(this,"CommandCompleter")}commands;constructor(){this.commands=new Map,this.loadCommands()}loadCommands(){for(let n of so().getAll())n.userInvocable!==!1&&this.commands.set(n.name,{description:n.description,aliases:n.aliases??[]});let o=ae();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=lo(t);return r===-1?!1:!t.slice(r).includes(" ")}async getCompletions(o,n){let t=o.slice(0,n),r=lo(t);if(r===-1)return[];this.commands.clear(),this.loadCommands();let s=t.slice(r+1).toLowerCase(),l=[];for(let[c,d]of this.commands){this.fuzzyMatch(s,c)&&l.push({text:"/"+c,display:"/"+c,description:d.description,type:"command"});for(let u of d.aliases)u!==c&&this.fuzzyMatch(s,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(),s=0;for(let l=0;l<r.length&&s<t.length;l++)r[l]===t[s]&&s++;return s===t.length}};function Uv(e){let o=new vr(e),n=new On,t=new kr;return async r=>{let s=r.includes("@"),l=r.includes("/");if(!s&&!l)return[[],r];let c=[];if(l){let u=await Gf(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(s&&o.canComplete(r,r.length)){let u=await o.getCompletions(r,r.length);c.push(...u)}return[c.map(u=>zf(r,u)),r]}}a(Uv,"createCompleter");async function Gf(e,o){let{ArgumentCompleter:n}=await import("./argument-completer-WF7FTTWB.js"),t=new n;return t.canComplete(e,o)?t.getCompletions(e,o):[]}a(Gf,"getArgumentCompletions");function zf(e,o){if(o.type!=="argument")return o.text;let n=lo(e);if(n!==-1&&!/\s/.test(e.slice(n)))return`${e} ${o.text}`;let r=e.match(/\S+$/)?.[0]??"";return`${r?e.slice(0,e.length-r.length):e}${o.text}`}a(zf,"formatReadlineCompletion");import{existsSync as jn,readdirSync as Ya,readFileSync as Ja}from"node:fs";import{join as Un}from"node:path";var Xf=[{name:"plan",description:"Read-only planning mode - blocks all modifications",type:"enum"},{name:"accept-edits",description:"Sandbox first; user decides only at the host boundary",type:"enum"},{name:"auto",description:"Use sandbox execution with LLM review at the host boundary",type:"enum"},{name:"full-access",description:"Direct host execution without sandbox or approval prompts",type:"enum"}],co=[{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 Vf(e){if(e&&e.includes("/")){let o=e.indexOf("/"),n=e.slice(0,o),t=e.slice(o+1);if(je(n))try{return Be(n).filter(s=>!t||s.toLowerCase().includes(t.toLowerCase())).map(s=>({name:`${n}/${s}`,description:s,type:"enum"}))}catch{}return[]}return Ue().map(o=>({name:o,description:`Switch to ${o} provider`,type:"enum"}))}a(Vf,"getModelArgs");var br=[{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"}],Sr=[{name:"all",description:"Delete ALL sessions",type:"enum"}],Yf=[{name:"status",description:"Show MCP server status",type:"enum"},{name:"refresh",description:"Refresh MCP server catalogs",type:"enum"}],Jf=[{name:"status",description:"Show child-task fallback order",type:"enum"},{name:"off",description:"Disable child-task fallback providers",type:"enum"}],za=[{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"}],Xa=[{name:"on",description:"Enable logging",type:"enum"},{name:"off",description:"Disable logging",type:"enum"}],Qf=[{name:"list",description:"Summarize accepted Memory",type:"enum"},{name:"remember",description:"Remember one explicit keyed claim now",type:"enum"},{name:"forget",description:"Forget one exact accepted Memory",type:"enum"},{name:"decisions",description:"List exceptional changes that need you",type:"enum"},{name:"show",description:"Show one accepted Memory or decision",type:"enum"},{name:"approve",description:"Approve one reviewed decision",type:"enum"},{name:"reject",description:"Reject one reviewed decision",type:"enum"},{name:"doctor",description:"Diagnose the Memory pipeline",type:"enum"},{name:"open",description:"Open Memory in an external editor",type:"enum"},{name:"help",description:"Show memory help",type:"enum"}],Zf=[{name:"list",description:"List learned capabilities",type:"enum"},{name:"ready",description:"List capabilities ready for review/control",type:"enum"},{name:"pending",description:"Compatibility alias for ready 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 em(e){let[o=""]=e,n=o.toLowerCase(),t=e.length===1&&e[0]===""?0:e.length;return t<=1?Zf: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"}]:[]}a(em,"getLearnArgs");var om=[{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"}],nm=[{name:"show",description:"Show a captured paste by id",type:"enum"},{name:"list",description:"List captured pastes",type:"enum"}],tm=[{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"}],rm=[{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"}],im=[{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"}],sm=[{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"}],am=[{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"}],lm=[{name:"status",description:"Deprecated alias for /repo-intel status",type:"enum"}],cm=[{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"}],dm=new Set(["show","pause","resume","stop","delete","rerun","save","rename","revise"]),um=new Set(["show","delete","rerun","save","rename","revise"]),fm=[{name:"--all",description:"Show all persisted workflow runs",type:"enum"},{name:"--limit",description:"Show at most N persisted workflow runs",type:"enum"}],mm=[{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"}],pm=[{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"}],gm=[".workflow.json",".ts",".mjs",".js"];function wm(e,o){switch(e){case"pause":return o==="running";case"resume":return o==="paused";case"stop":return o==="running"||o==="paused";case"delete":return o!=="running"&&o!=="paused";default:return!0}}a(wm,"workflowRunMatchesSubcommand");function Fn(e){return/^[a-zA-Z0-9._-]{1,120}$/.test(e)&&!e.startsWith(".")&&!e.includes("..")}a(Fn,"isWorkflowRunEntryName");function hm(e,o){let n=Un(e,"workflow-metadata.json");if(jn(n))try{let r=JSON.parse(Ja(n,"utf8"));if(typeof r=="object"&&r!==null){let s=r.displayName;if(typeof s=="string"&&Fn(s.trim()))return s.trim()}}catch{}let t=o.displayName;return typeof t=="string"&&Fn(t.trim())?t.trim():void 0}a(hm,"readWorkflowRunDisplayName");function ym(){let e=ke(process.cwd()).key,o=N("workflow-runs",e);if(!jn(o))return[];let n=[];for(let t of Ya(o)){if(!Fn(t))continue;let r=Un(o,t,"run.json");if(jn(r))try{let s=JSON.parse(Ja(r,"utf8")),l=typeof s.workflow=="string"?s.workflow:"?",c=typeof s.status=="string"?s.status:"?",d=typeof s.endedAt=="number"?s.endedAt:0;n.push({arg:{name:t,description:`${l} - ${c}`,type:"string"},endedAt:d});let u=hm(Un(o,t),s);u&&u!==t&&n.push({arg:{name:u,description:`${l} alias for ${t} - ${c}`,type:"string"},endedAt:d})}catch{}}return n.sort((t,r)=>r.endedAt-t.endedAt).map(t=>t.arg)}a(ym,"getPersistedWorkflowRunIdArgs");function Hn(e){let o=Ke().list().filter(r=>wm(e,r.status)).map(r=>({name:r.runId,description:`${r.workflow} - ${r.status}`,type:"string"})),n=um.has(e)?ym():[],t=new Set;return[...o,...n].filter(r=>t.has(r.name)?!1:(t.add(r.name),!0))}a(Hn,"getWorkflowRunIdArgs");function vm(e){for(let o of gm)if(e.endsWith(o)){let n=e.slice(0,-o.length);return Fn(n)?n:void 0}}a(vm,"savedWorkflowNameFromFile");function Fo(e={}){let o=[{path:N("workflows"),source:"personal"},{path:Un(process.cwd(),".kodax","workflows"),source:"project"}],n=new Map;for(let t of o)if(jn(t.path))try{for(let r of Ya(t.path)){if(e.generatedOnly===!0&&!r.endsWith(".workflow.json"))continue;let s=vm(r);s&&n.set(s,{name:s,description:`${t.source} saved workflow`,type:"enum"})}}catch{}return[...n.values()].sort((t,r)=>t.name.localeCompare(r.name))}a(Fo,"getSavedWorkflowNameArgs");function km(){let e=new Map;for(let o of Hn("rerun"))e.set(o.name,{...o,description:`recent run: ${o.description}`,type:"string"});for(let o of Fo()){let n=e.get(o.name);if(n){e.set(o.name,{...n,description:`${n.description}; also ${o.description}`});continue}e.set(o.name,{...o,description:o.description,type:"string"})}return[...e.values()]}a(km,"getWorkflowRerunArgs");function $r(e){let o=new Map;for(let n of Hn(e))o.set(n.name,{...n,description:`workflow run: ${n.description}`,type:"string"});for(let n of Fo({generatedOnly:e==="delete"})){let t=o.get(n.name);if(t){o.set(n.name,{...t,description:`${t.description}; also ${n.description}`});continue}o.set(n.name,{...n,description:n.description,type:"string"})}return[...o.values()]}a($r,"getWorkflowRunOrSavedNameArgs");function Va(e){let o=new Set(e.slice(1).filter(n=>n.startsWith("--")));return o.has("--saved")?Fo({generatedOnly:!0}):o.has("--run")?Hn("delete"):$r("delete")}a(Va,"getWorkflowDeleteTargetArgs");function bm(e){let[o=""]=e,n=o.toLowerCase(),t=e.length===1&&e[0]===""?0:e.length;if(t<=1)return[...cm,...Jo().map(r=>({name:r.name,description:r.description,type:"enum"})),...Fo()];if(n==="rerun"&&t<=2)return km();if(n==="rename"&&t<=2)return $r("rename");if(n==="delete"&&t<=2)return[...pm,...Va(e)];if(n==="delete"&&t<=3&&e.slice(1).some(r=>r.startsWith("--")))return Va(e);if(n==="revise"){if(t<=2)return[{name:"--replace",description:"Replace a saved workflow after confirmation",type:"enum"},...$r("revise")];if(e[1]==="--replace"&&t<=3)return Fo()}return dm.has(n)&&t<=2?Hn(n):n==="runs"&&t<=2?fm:n==="prune"&&t<=2?mm:[]}a(bm,"getWorkflowArgs");function Sm(e){let[o=""]=e,n=o.toLowerCase(),t=e.length===1&&e[0]===""?0:e.length;return t<=1?im:t>2?[]:n==="mode"?sm:n==="trace"?am:[]}a(Sm,"getRepoIntelArgs");var $m=new Map([["mode",Xf],["thinking",co],["think",co],["t",co],["reasoning",co],["reason",co],["effort",co],["status",br],["info",br],["ctx",br],["mcp",Yf],["fallback",Jf],["agent-mode",za],["am",za],["verifier-log",Xa],["stall-log",Xa],["memory",Qf],["goal",om],["paste",nm],["review",tm],["agents",rm],["delete",Sr],["rm",Sr],["del",Sr]]),xm=new Set(["model","m","provider"]),Am=new Set(["repo-intel"]),Rm=new Set(["repointel","ri"]),Cm=new Set(["workflow"]),Em=new Set(["learn"]);function xr(e,o,n=[]){let t=e.toLowerCase();return xm.has(t)?Vf(o):Am.has(t)?Sm(n):Rm.has(t)?n.length<=1?lm:[]:Cm.has(t)?bm(n):Em.has(t)?em(n):$m.get(t)??[]}a(xr,"getCommandArguments");var Ar=class{static{a(this,"ArgumentCompleter")}canComplete(o,n){let t=o.slice(0,n),r=lo(t);if(r===-1)return!1;let s=t.slice(r),l=s.split(/\s+/);if(l.length>=2&&l[0]!=="")return!0;let c=s.slice(1).toLowerCase();return xr(c).length>0}async getCompletions(o,n){let t=o.slice(0,n),r=lo(t);if(r===-1)return[];let s=t.slice(r),l=s.indexOf(" "),c=(l===-1?s.slice(1):s.slice(1,l)).toLowerCase(),d=l===-1?"":s.slice(l+1),u=d?d.split(/\s+/):[""],f=u.length-1,p=u[f]??"",b=p.toLowerCase(),S=xr(c,p,u);if(!S||S.length===0)return[];let R=new Set(u.slice(0,-1).map(y=>y.toLowerCase()));return S.filter(y=>!R.has(y.name.toLowerCase())).filter(y=>!b||y.name.includes("/")?!0:y.name.toLowerCase().includes(b)).map(y=>({text:y.name,display:y.name,description:y.description,type:"argument"})).sort((y,k)=>{if(!b)return 0;let C=y.display.toLowerCase().startsWith(b),L=k.display.toLowerCase().startsWith(b);return C&&!L?-1:!C&&L?1:y.display.length-k.display.length})}};function Zv(){return new Ar}a(Zv,"createArgumentCompleter");export{kt as a,q as b,yg as c,ks as d,vg as e,tn as f,ol as g,nl as h,Ee as i,tl as j,Ni as k,Oi as l,ko as m,So as n,Ge as o,ze as p,qi as q,Gi as r,zi as s,es as t,os as u,ct as v,ts as w,jl as x,Mp as y,zp as z,Ul as A,gt as B,Xp as C,Vp as D,ms as E,Ao as F,ng as G,ht as H,tg as I,rg as J,cg as K,dg as L,vs as M,le as N,$s as O,xs as P,Ag as Q,ic as R,vc as S,Rg as T,un as U,St as V,Cg as W,_s as X,Eg as Y,Ig as Z,Pg as _,tw as $,rw as aa,iw as ba,sw as ca,Vs as da,It as ea,Ys as fa,ke as ga,Ad as ha,fw as ia,Io as ja,Wt as ka,Me as la,ou as ma,nu as na,ga as oa,Dw as pa,jw as qa,gu as ra,Wh as sa,Nh as ta,Oh as ua,ny as va,ty as wa,ry as xa,iy as ya,sy as za,Ea as Aa,fy as Ba,my as Ca,Pa as Da,py as Ea,My as Fa,Ta as Ga,so as Ha,xv as Ia,Av as Ja,Rv as Ka,On as La,Ar as Ma,Zv as Na,lo as Oa,vr as Pa,kr as Qa,Uv as Ra};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
|
|
2
|
-
import{Ka as v}from"./chunk-F7JMG426.js";import{a}from"./chunk-ONUPGMER.js";import{spawnSync as O}from"node:child_process";import{createHash as F}from"node:crypto";import c from"node:fs";import H from"node:os";import i from"node:path";import{fileURLToPath as W}from"node:url";var q=64*1024*1024,z="v2";function x(){{let e=JSON.parse('{"darwin-arm64":"{\\n \\"version\\": 1,\\n \\"platform\\": \\"darwin\\",\\n \\"arch\\": \\"arm64\\",\\n \\"textTransaction\\": {\\n \\"file\\": \\"kodax-text-transaction.node\\",\\n \\"protocol\\": 4,\\n \\"sha256\\": \\"69800bd84ddb8847795d9f58767c55a649fea6eead749d4909b0d2e61fe28a89\\"\\n },\\n \\"legal\\": [\\n {\\n \\"file\\": \\"LICENSE-APACHE.txt\\",\\n \\"sha256\\": \\"6bdadfab6d5d2b0d4e0ccea244f5e412d1597dc84c56db645556ce192b131e98\\"\\n }\\n ]\\n}\\n","darwin-x64":"{\\n \\"version\\": 1,\\n \\"platform\\": \\"darwin\\",\\n \\"arch\\": \\"x64\\",\\n \\"textTransaction\\": {\\n \\"file\\": \\"kodax-text-transaction.node\\",\\n \\"protocol\\": 4,\\n \\"sha256\\": \\"e8869134d922b402ddf28a5b0363fdf5cd4062a3691f271b9abc7e7f31d76c01\\"\\n },\\n \\"legal\\": [\\n {\\n \\"file\\": \\"LICENSE-APACHE.txt\\",\\n \\"sha256\\": \\"6bdadfab6d5d2b0d4e0ccea244f5e412d1597dc84c56db645556ce192b131e98\\"\\n }\\n ]\\n}\\n","linux-arm64":"{\\n \\"version\\": 1,\\n \\"platform\\": \\"linux\\",\\n \\"arch\\": \\"arm64\\",\\n \\"textTransaction\\": {\\n \\"file\\": \\"kodax-text-transaction.node\\",\\n \\"protocol\\": 4,\\n \\"sha256\\": \\"d2b3a6bdddfd756a88bfa181dbf1a8270923fe8c9be0524eb19aa4273b80aef3\\"\\n },\\n \\"legal\\": [\\n {\\n \\"file\\": \\"LICENSE-APACHE.txt\\",\\n \\"sha256\\": \\"6bdadfab6d5d2b0d4e0ccea244f5e412d1597dc84c56db645556ce192b131e98\\"\\n }\\n ]\\n}\\n","linux-x64":"{\\n \\"version\\": 1,\\n \\"platform\\": \\"linux\\",\\n \\"arch\\": \\"x64\\",\\n \\"textTransaction\\": {\\n \\"file\\": \\"kodax-text-transaction.node\\",\\n \\"protocol\\": 4,\\n \\"sha256\\": \\"79a903f9088a6929b2c0771c1f82aa4f33440d5eb8bca7f3f7fcf021d0be0805\\"\\n },\\n \\"legal\\": [\\n {\\n \\"file\\": \\"LICENSE-APACHE.txt\\",\\n \\"sha256\\": \\"6bdadfab6d5d2b0d4e0ccea244f5e412d1597dc84c56db645556ce192b131e98\\"\\n }\\n ]\\n}\\n","win32-x64":"{\\n \\"version\\": 1,\\n \\"platform\\": \\"win32\\",\\n \\"arch\\": \\"x64\\",\\n \\"textTransaction\\": {\\n \\"file\\": \\"kodax-windows-text-transaction.node\\",\\n \\"protocol\\": 4,\\n \\"sha256\\": \\"
|
|
2
|
+
import{Ka as v}from"./chunk-F7JMG426.js";import{a}from"./chunk-ONUPGMER.js";import{spawnSync as O}from"node:child_process";import{createHash as F}from"node:crypto";import c from"node:fs";import H from"node:os";import i from"node:path";import{fileURLToPath as W}from"node:url";var q=64*1024*1024,z="v2";function x(){{let e=JSON.parse('{"darwin-arm64":"{\\n \\"version\\": 1,\\n \\"platform\\": \\"darwin\\",\\n \\"arch\\": \\"arm64\\",\\n \\"textTransaction\\": {\\n \\"file\\": \\"kodax-text-transaction.node\\",\\n \\"protocol\\": 4,\\n \\"sha256\\": \\"69800bd84ddb8847795d9f58767c55a649fea6eead749d4909b0d2e61fe28a89\\"\\n },\\n \\"legal\\": [\\n {\\n \\"file\\": \\"LICENSE-APACHE.txt\\",\\n \\"sha256\\": \\"6bdadfab6d5d2b0d4e0ccea244f5e412d1597dc84c56db645556ce192b131e98\\"\\n }\\n ]\\n}\\n","darwin-x64":"{\\n \\"version\\": 1,\\n \\"platform\\": \\"darwin\\",\\n \\"arch\\": \\"x64\\",\\n \\"textTransaction\\": {\\n \\"file\\": \\"kodax-text-transaction.node\\",\\n \\"protocol\\": 4,\\n \\"sha256\\": \\"e8869134d922b402ddf28a5b0363fdf5cd4062a3691f271b9abc7e7f31d76c01\\"\\n },\\n \\"legal\\": [\\n {\\n \\"file\\": \\"LICENSE-APACHE.txt\\",\\n \\"sha256\\": \\"6bdadfab6d5d2b0d4e0ccea244f5e412d1597dc84c56db645556ce192b131e98\\"\\n }\\n ]\\n}\\n","linux-arm64":"{\\n \\"version\\": 1,\\n \\"platform\\": \\"linux\\",\\n \\"arch\\": \\"arm64\\",\\n \\"textTransaction\\": {\\n \\"file\\": \\"kodax-text-transaction.node\\",\\n \\"protocol\\": 4,\\n \\"sha256\\": \\"d2b3a6bdddfd756a88bfa181dbf1a8270923fe8c9be0524eb19aa4273b80aef3\\"\\n },\\n \\"legal\\": [\\n {\\n \\"file\\": \\"LICENSE-APACHE.txt\\",\\n \\"sha256\\": \\"6bdadfab6d5d2b0d4e0ccea244f5e412d1597dc84c56db645556ce192b131e98\\"\\n }\\n ]\\n}\\n","linux-x64":"{\\n \\"version\\": 1,\\n \\"platform\\": \\"linux\\",\\n \\"arch\\": \\"x64\\",\\n \\"textTransaction\\": {\\n \\"file\\": \\"kodax-text-transaction.node\\",\\n \\"protocol\\": 4,\\n \\"sha256\\": \\"79a903f9088a6929b2c0771c1f82aa4f33440d5eb8bca7f3f7fcf021d0be0805\\"\\n },\\n \\"legal\\": [\\n {\\n \\"file\\": \\"LICENSE-APACHE.txt\\",\\n \\"sha256\\": \\"6bdadfab6d5d2b0d4e0ccea244f5e412d1597dc84c56db645556ce192b131e98\\"\\n }\\n ]\\n}\\n","win32-x64":"{\\n \\"version\\": 1,\\n \\"platform\\": \\"win32\\",\\n \\"arch\\": \\"x64\\",\\n \\"textTransaction\\": {\\n \\"file\\": \\"kodax-windows-text-transaction.node\\",\\n \\"protocol\\": 4,\\n \\"sha256\\": \\"2ccf28d6fabbe4a319b682664e13289da352b1dbfa3bdbb6767c0e7011255482\\"\\n },\\n \\"legal\\": [\\n {\\n \\"file\\": \\"LICENSE-APACHE.txt\\",\\n \\"sha256\\": \\"f8dd90eb71a7af4048bde3ff1d18b7d7280522e0a429ff71b7270a4189cf3568\\"\\n },\\n {\\n \\"file\\": \\"NOTICE-windows-sandbox.txt\\",\\n \\"sha256\\": \\"78723eb162f0782c5e27928f46c681996edc1907d552eba9d0f7f53e014c20c9\\"\\n }\\n ],\\n \\"shellSandbox\\": {\\n \\"file\\": \\"kodax-windows-sandbox.exe\\",\\n \\"protocol\\": 10,\\n \\"sha256\\": \\"cfc4a97141005053f3a2328e07370230f0c1c969057bb652156444acb81a9b89\\"\\n },\\n \\"asrtRunner\\": {\\n \\"file\\": \\"srt-win.exe\\",\\n \\"version\\": \\"0.0.65\\",\\n \\"sha256\\": \\"777736e17d6cf9b4280f155f5cda731fdff0f789fa16e6cb3adc0006073e241a\\"\\n }\\n}\\n"}');if(e===null||typeof e!="object"||Array.isArray(e))throw new Error("embedded native manifest map is invalid");let t=e[`${process.platform}-${process.arch}`];if(typeof t!="string"||t==="")throw new Error(`embedded native manifest is missing for ${process.platform}-${process.arch}`);return t}return process.platform==="win32",`{
|
|
3
3
|
"version": 1,
|
|
4
4
|
"platform": "linux",
|
|
5
5
|
"arch": "x64",
|