@kodax-ai/kodax 0.7.96-alpha.7 → 0.7.96-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/README.md +14 -5
  3. package/README_CN.md +11 -5
  4. package/dist/chunks/{agent-SV3OH5VR.js → agent-QGVCIM5U.js} +1 -1
  5. package/dist/chunks/argument-completer-NG4VLIRD.js +2 -0
  6. package/dist/chunks/{chunk-2O2HZCBH.js → chunk-3PIOVQVB.js} +2 -2
  7. package/dist/chunks/{chunk-N5VUIPXE.js → chunk-7EXZQBG2.js} +2 -2
  8. package/dist/chunks/{chunk-UQJOGEDC.js → chunk-AZTPF2HX.js} +1 -1
  9. package/dist/chunks/{chunk-O3SCJ4HT.js → chunk-DWLYVWFJ.js} +1 -1
  10. package/dist/chunks/{chunk-W4QOFCVD.js → chunk-FWSGQ5OS.js} +1 -1
  11. package/dist/chunks/{chunk-MXJFGVTT.js → chunk-HK4767SO.js} +1 -1
  12. package/dist/chunks/chunk-HV4L23QZ.js +351 -0
  13. package/dist/chunks/{chunk-LNPTCPLR.js → chunk-IOR23YGO.js} +1 -1
  14. package/dist/chunks/chunk-JM6QBNUM.js +1476 -0
  15. package/dist/chunks/{chunk-YYPZCZ6O.js → chunk-KFVJYB7D.js} +1 -1
  16. package/dist/chunks/{chunk-ZD5NDQ53.js → chunk-KGG5EDZN.js} +1 -1
  17. package/dist/chunks/{chunk-BRZO5ZGS.js → chunk-LQ2TYOUF.js} +1 -1
  18. package/dist/chunks/{chunk-RNJPYIXJ.js → chunk-N3ODBSEC.js} +4 -4
  19. package/dist/chunks/chunk-PYNO4NC2.js +471 -0
  20. package/dist/chunks/{chunk-52FEJJMH.js → chunk-R5P3CH5N.js} +2 -2
  21. package/dist/chunks/chunk-SHXBOMIB.js +124 -0
  22. package/dist/chunks/{chunk-ZXNXMFXJ.js → chunk-TWXMMQ26.js} +163 -163
  23. package/dist/chunks/{chunk-IDEPSEPH.js → chunk-V5HJTYS5.js} +2 -2
  24. package/dist/chunks/{chunk-5XD3D47Z.js → chunk-VWO4I6T3.js} +1 -1
  25. package/dist/chunks/chunk-W764RSKQ.js +5 -0
  26. package/dist/chunks/chunk-ZIM3DRTW.js +384 -0
  27. package/dist/chunks/client-WH5AZEVW.js +2 -0
  28. package/dist/chunks/compaction-config-BBXT6VDZ.js +2 -0
  29. package/dist/chunks/{construction-bootstrap-3ITEEWHD.js → construction-bootstrap-UT2Z7WNQ.js} +1 -1
  30. package/dist/chunks/dist-34SJ2QO3.js +2 -0
  31. package/dist/chunks/dist-YHRZ7WJQ.js +2 -0
  32. package/dist/chunks/host-OYXSGVJK.js +2 -0
  33. package/dist/chunks/run-manager-B46VII2V.js +2 -0
  34. package/dist/chunks/{utils-GYD2CE2X.js → utils-O6O24H33.js} +1 -1
  35. package/dist/index.d.ts +14 -14
  36. package/dist/index.js +1 -1
  37. package/dist/kodax_bootstrap.js +1 -1
  38. package/dist/kodax_cli.js +1391 -1478
  39. package/dist/kodax_resume.js +1 -1
  40. package/dist/native/darwin-arm64/kodax-text-transaction.node +0 -0
  41. package/dist/native/darwin-arm64/manifest.json +1 -1
  42. package/dist/native/linux-arm64/kodax-text-transaction.node +0 -0
  43. package/dist/native/linux-arm64/manifest.json +1 -1
  44. package/dist/native/linux-x64/kodax-text-transaction.node +0 -0
  45. package/dist/native/linux-x64/manifest.json +1 -1
  46. package/dist/native/win32-x64/kodax-windows-sandbox.exe +0 -0
  47. package/dist/native/win32-x64/kodax-windows-text-transaction.node +0 -0
  48. package/dist/native/win32-x64/manifest.json +2 -2
  49. package/dist/runtime-worker.js +1292 -1379
  50. package/dist/sandbox-network-broker.js +88 -88
  51. package/dist/sdk-a2a.d.ts +9 -9
  52. package/dist/sdk-a2a.js +1 -1
  53. package/dist/sdk-agent.d.ts +20 -11
  54. package/dist/sdk-agent.js +1 -1
  55. package/dist/sdk-coding.d.ts +17 -16
  56. package/dist/sdk-coding.js +1 -1
  57. package/dist/sdk-experimental-memory.js +1 -1
  58. package/dist/sdk-llm.d.ts +4 -4
  59. package/dist/sdk-llm.js +1 -1
  60. package/dist/sdk-mcp.js +1 -1
  61. package/dist/sdk-media.js +1 -1
  62. package/dist/sdk-repl.d.ts +13 -13
  63. package/dist/sdk-repl.js +1 -1
  64. package/dist/sdk-runtime.d.ts +17 -9
  65. package/dist/sdk-runtime.js +1 -1
  66. package/dist/sdk-sandbox.js +1 -1
  67. package/dist/sdk-session.d.ts +5 -5
  68. package/dist/sdk-session.js +1 -1
  69. package/dist/sdk-skills.js +1 -1
  70. package/dist/semantic-worker.js +57 -57
  71. package/dist/types-chunks/{base.d-COo8E2dk.d.ts → base.d-BGa4Hcp5.d.ts} +66 -2
  72. package/dist/types-chunks/{bash-prefix-extractor.d-C_D7FK95.d.ts → bash-prefix-extractor.d-BrE20uli.d.ts} +33 -4
  73. package/dist/types-chunks/{capsule.d-DxNgcs9n.d.ts → capsule.d-BflmZWY-.d.ts} +1 -1
  74. package/dist/types-chunks/{controller.d-BGNtJc05.d.ts → controller.d-CZwtXQUP.d.ts} +2 -1
  75. package/dist/types-chunks/{exec-policy.d-D5a3OUjN.d.ts → exec-policy.d-DyGbAvbV.d.ts} +4 -4
  76. package/dist/types-chunks/{public-api.d-WT1wNQz9.d.ts → public-api.d-CWxtGx0W.d.ts} +2 -2
  77. package/dist/types-chunks/{resolver.d-BAHV5zRk.d.ts → resolver.d-HWh9mm7u.d.ts} +3 -55
  78. package/dist/types-chunks/{run-manager.d-T6uxxiWl.d.ts → run-manager.d-CdyG8BEa.d.ts} +1 -1
  79. package/dist/types-chunks/{sdk-session-D5fn3-IW.d.ts → sdk-session-C2Ud3V39.d.ts} +1 -1
  80. package/dist/types-chunks/{shell-command-sets.d-PnzbcF4X.d.ts → shell-command-sets.d-D1QMUzh8.d.ts} +1 -1
  81. package/dist/types-chunks/{side-query.d-DPzDnl3k.d.ts → side-query.d-DdJ1OPz0.d.ts} +1 -1
  82. package/dist/types-chunks/{trusted-repl-entry-BLTJoxdD.d.ts → trusted-repl-entry-DoEcjDAA.d.ts} +4 -4
  83. package/dist/types-chunks/{types.d-DXS_I8Yw.d.ts → types.d-BnLnc7av.d.ts} +1 -1
  84. package/dist/types-chunks/{types.d-Duj2w9bT.d.ts → types.d-DeRjor4h.d.ts} +2 -2
  85. package/dist/types-chunks/{utils.d-thZMKPNO.d.ts → utils.d-C9GY2BXS.d.ts} +4 -4
  86. package/package.json +2 -1
  87. package/public_docs/README.md +7 -3
  88. package/public_docs/sdk/embedder-guide.md +2 -2
  89. package/dist/chunks/argument-completer-TTUEXPZ4.js +0 -2
  90. package/dist/chunks/chunk-4IH2OTLC.js +0 -471
  91. package/dist/chunks/chunk-7CPZTMYD.js +0 -92
  92. package/dist/chunks/chunk-S5USXWS2.js +0 -1476
  93. package/dist/chunks/chunk-TD2PU67Z.js +0 -124
  94. package/dist/chunks/chunk-UTUAC7YQ.js +0 -351
  95. package/dist/chunks/chunk-Z64NI33Q.js +0 -384
  96. package/dist/chunks/client-452BLUKG.js +0 -2
  97. package/dist/chunks/compaction-config-LTWENSAR.js +0 -2
  98. package/dist/chunks/dist-QSSK3PCI.js +0 -2
  99. package/dist/chunks/dist-WQ6ONBGT.js +0 -2
  100. package/dist/chunks/host-4QGM5DQ7.js +0 -2
  101. package/dist/chunks/run-manager-CVR6JPLK.js +0 -2
package/CHANGELOG.md CHANGED
@@ -6,6 +6,62 @@ All notable changes to this project will be documented in this file.
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.7.96-beta.2] - 2026-09-07
10
+
11
+ Second beta pre-release of the v0.7.96 line: it retains the beta.1 sandbox-
12
+ first, trusted-text, and permission-profile feature set plus the Linux glibc
13
+ 2.28 native build fix, and adds long-session context-boundary recovery and
14
+ Provider correctness fixes below. npm publication remains a separate manual
15
+ maintainer action.
16
+
17
+ ### Fixed
18
+
19
+ - Recover long coding sessions at context boundaries: parse vLLM prompt counts
20
+ without confusing output tokens or bounds, reclaim response reserve before
21
+ terminal checks, and persist recoverable tool-output previews when protected
22
+ recent history cannot fit. SA and AMA retry a rejected generation once after
23
+ actual history reduction without replaying tools. Capacity diagnostics include
24
+ safety margin and distinguish upstream bounds from exact token counts.
25
+ - Keep bundled Provider credential scopes shared across SDK, Agent summaries,
26
+ CLI, and Runtime Worker requests, restoring keychain-only manual and managed
27
+ compaction. Add bundle identity checks and real daemon broker regressions
28
+ to CI and release gates (Issue 332).
29
+ - Omit empty `tools` arrays from OpenAI- and Anthropic-compatible streaming and
30
+ non-streaming wire requests, so tool-free side queries such as Auto[LLM]
31
+ classification remain compatible with strict vLLM gateways (Issue 329).
32
+ - Preserve a bounded, credential-safe structured Provider failure from Child
33
+ Agent execution through Actor settlement and SDK Runtime diagnostics instead
34
+ of replacing failures after tool execution with `failed without output`; the
35
+ existing no-replay child fallback boundary is unchanged (Issue 330).
36
+ - Make custom Provider credential verification honor exact and lazy run-scoped
37
+ credential authority, include credential acquisition in the timeout, fail
38
+ closed for denied scopes, and redact opaque scoped credentials from returned
39
+ diagnostics (Issue 331).
40
+ - Keep the cap-006 post-tool-result failure contract off the full-workspace
41
+ repo-intelligence indexing path (`repoIntelligenceMode: 'off'`, matching the
42
+ cap-057/cap-091/cap-095 precedent). The contract test previously indexed the
43
+ whole workspace before `onSessionStart` and exceeded its 30-second budget
44
+ under CI parallelism; the failure-shape contract is unchanged.
45
+
46
+ ## [0.7.96-beta.1] - 2026-09-03
47
+
48
+ The first beta pre-release of the v0.7.96 line: it retains the full alpha.7
49
+ sandbox-first, trusted-text, and permission-profile feature set and adds the
50
+ Linux native compatibility fix below. npm publication remains a separate
51
+ manual maintainer action.
52
+
53
+ ### Fixed
54
+
55
+ - Restored Linux glibc 2.28 compatibility for the FEATURE_295 native text
56
+ authority (Issue 328). Linux x64/arm64 addons now compile with Rust 1.98.0
57
+ inside architecture-matched, digest-pinned `manylinux_2_28` builders, and the
58
+ normal staging path hashes and packages those prebuilt bytes without
59
+ recompiling on the Ubuntu host. CI and release lanes scan every staged Linux
60
+ addon and fail if any required symbol exceeds `GLIBC_2.28`, so private
61
+ Kylin V10 / glibc 2.28 deployments can load the trusted text authority
62
+ again. No text-transaction, CAS, lock, atomic-replace, receipt, or fail-closed
63
+ runtime path changed.
64
+
9
65
  ## [0.7.96-alpha.7] - 2026-09-03
10
66
 
11
67
  ### Fixed
package/README.md CHANGED
@@ -759,7 +759,7 @@ permission UI, and recovers stale prepared Session tails through an
759
759
  authoritative merge. Background persistence failures are surfaced as
760
760
  diagnostics rather than hidden.
761
761
 
762
- **v0.7.96-alpha.7 release:** Windows shell admission now follows the
762
+ **v0.7.96-beta.2 release:** Windows shell admission now follows the
763
763
  Codex concurrency boundary: versioned setup performs legacy migration once,
764
764
  while ordinary admission accepts effective inherited normal-token access and
765
765
  only converges a missing exact-root restricted capability using `SET_ACCESS`
@@ -793,13 +793,22 @@ protected-cache generation across later `npm link` rebuilds; another build
793
793
  cannot swap a long-lived process onto a mismatched native evidence schema.
794
794
  Unlowerable nested shell bodies remain opaque for exact Exec Policy plus the
795
795
  normal Edits/Auto[LLM] host boundary, rather than becoming a parser-generated
796
- hard forbid. Alpha.7 also self-heals a stale Windows setup
796
+ hard forbid. The release also self-heals a stale Windows setup
797
797
  generation before an interactive REPL starts, keeps current-marker startup on a
798
798
  fast path, shows live elapsed time only while real recovery runs, and documents
799
799
  that sandbox doctor is a host control-plane operation (`/sandbox` in the REPL or
800
- `kodax sandbox doctor` directly in a user terminal). npm publication remains a
800
+ `kodax sandbox doctor` directly in a user terminal). Linux x64/arm64 native
801
+ text authorities compile in digest-pinned `manylinux_2_28` builders and are
802
+ gated to `GLIBC_2.28`, restoring the supported private-deployment floor
803
+ (Issue 328). Beta.2 also recovers long coding sessions at context capacity
804
+ boundaries — a confirmed upstream overflow permits one generation retry after
805
+ persisted history reduction without replaying tools — keeps bundled Provider
806
+ credential scopes shared across SDK, Agent summaries, CLI, and Runtime Worker
807
+ requests, preserves structured Child Agent Provider failures, honors exact
808
+ run-scoped credential verification, and omits empty `tools` arrays for strict
809
+ vLLM gateways (Issues 329-332). npm publication remains a
801
810
  manual maintainer action. See the
802
- [release checklist](docs/release.md#v0796-alpha7-release-preparation).
811
+ [release checklist](docs/release.md#v0796-beta2-release-preparation).
803
812
 
804
813
  **v0.7.96-alpha.3 release:** Provider credentials are lazy, scoped,
805
814
  revocable capabilities (ADR-068). The v2 credential broker keeps Provider
@@ -1389,7 +1398,7 @@ kodax "your task"
1389
1398
 
1390
1399
  KodaX can be packaged into a single executable + a small `builtin/` sidecar directory using `bun --compile`. The target machine does **not** need Node.js or any other runtime.
1391
1400
 
1392
- Supported targets: `win-x64`, `linux-x64`, `linux-arm64`, `darwin-x64`, `darwin-arm64`. Win7 / pre-glibc-2.27 distros / LoongArch are not supported.
1401
+ Supported targets: `win-x64`, `linux-x64`, `linux-arm64`, `darwin-x64`, `darwin-arm64`. Win7 / pre-glibc-2.28 distros / LoongArch are not supported.
1393
1402
 
1394
1403
  **Build locally**:
1395
1404
 
package/README_CN.md CHANGED
@@ -296,7 +296,7 @@ SDK 系统代码契约更新,但没有放宽 shell/sandbox 的 fail-closed 边
296
296
  `handleRuntimePermissionRequest()` 管理 SDK 权限 UI,并在 prepared Session 尾部遇到
297
297
  `data_changed` 时通过权威 delta 合并恢复;后台持久化失败会显示为诊断,不再静默丢失。
298
298
 
299
- **v0.7.96-alpha.7 发布**:Windows shell 准入现在遵循 Codex 的并发边界:
299
+ **v0.7.96-beta.2 发布**:Windows shell 准入现在遵循 Codex 的并发边界:
300
300
  版本化 setup 只执行一次 legacy 迁移;普通准入在 capability 已存在时只读,只有缺失
301
301
  精确 root restricted capability 时才用 `SET_ACCESS` 与 DACL 回读收敛,且不等待任何
302
302
  跨进程目标互斥锁。稳定 filesystem capability SID 保留在对象上,每条命令的 token
@@ -324,11 +324,17 @@ shell 内容保留为 opaque 完整 argv,由精确 Exec Policy 与正常 Edits
324
324
  失败的 broker 代际会立即脱离复用但不会停止仍在运行的 holder,并继续计入固定端口容量直到进程
325
325
  实际关闭;启动/控制阶段各自以 15 秒为界,不会缩短命令执行 deadline。多个 npm-link/`kodax -r`
326
326
  客户端同时遇到空闲旧 daemon 时,会以认证临时身份选出一个替换者,其余客户端脱离后等待或续跑
327
- 同一精确 prepared ticket;忙碌或不可信的 daemon 仍保持不动并返回结构化边界。alpha.7 还会在
327
+ 同一精确 prepared ticket;忙碌或不可信的 daemon 仍保持不动并返回结构化边界。本版本还会在
328
328
  交互式 REPL 启动前自愈陈旧的 Windows setup generation;当前 marker 走快速路径,只有实际恢复
329
329
  才显示持续更新的等待时间。sandbox doctor 明确属于宿主控制面:REPL 内使用 `/sandbox`,或直接
330
- 在用户终端运行 `kodax sandbox doctor`,不能通过 sandbox-first Bash 工具调用。npm 发布仍由
331
- 维护者手动执行。详见 [v0.7.96-alpha.7 发布清单](docs/release.md#v0796-alpha7-release-preparation)。
330
+ 在用户终端运行 `kodax sandbox doctor`,不能通过 sandbox-first Bash 工具调用。Linux x64/arm64
331
+ native 文本权威改在摘要固定的 `manylinux_2_28` 构建器中编译,并要求所需 `GLIBC_*` 符号不超过
332
+ 2.28,恢复了受支持的私有化部署下限(Issue 328)。beta.2 还能在上下文容量边界恢复长会话——
333
+ 确认的上游溢出在历史实际缩减后允许一次生成重试且不重放工具调用——并让捆绑的 Provider 凭据
334
+ scope 在 SDK、Agent 摘要、CLI 与 Runtime Worker 请求间共享,保留结构化的 Child Agent Provider
335
+ 失败信息,精确遵循 run-scoped 凭据校验,并为严格 vLLM 网关省略空 `tools` 数组(Issues 329-332)。
336
+ npm 发布仍由
337
+ 维护者手动执行。详见 [v0.7.96-beta.2 发布清单](docs/release.md#v0796-beta2-release-preparation)。
332
338
 
333
339
  **v0.7.96-alpha.3 发布**:Provider 凭据成为惰性、受限、可撤销的能力(ADR-068)。v2
334
340
  credential broker 将 Provider 密钥保留在 OS keychain,按每次 wire call、为单一封闭
@@ -957,7 +963,7 @@ kodax -p "检查这个仓库" --runtime-mode daemon
957
963
 
958
964
  KodaX 可以用 `bun --compile` 打包成单可执行文件 + 一个 `builtin/` sidecar 目录,目标机器**不需要安装 Node.js 或任何运行时**。
959
965
 
960
- 支持目标:`win-x64`、`linux-x64`、`linux-arm64`、`darwin-x64`、`darwin-arm64`。Win7 / glibc < 2.27 的发行版 / 龙芯 LoongArch 暂不支持。
966
+ 支持目标:`win-x64`、`linux-x64`、`linux-arm64`、`darwin-x64`、`darwin-arm64`。Win7 / glibc < 2.28 的发行版 / 龙芯 LoongArch 暂不支持。
961
967
 
962
968
  本地构建:
963
969
 
@@ -1,2 +1,2 @@
1
1
  // @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
2
- import{Aa as f,Qa as g,Sa as h,a as c,db as i,eb as j,mb as k,ya as d,za as e}from"./chunk-UTUAC7YQ.js";import"./chunk-MXJFGVTT.js";import"./chunk-ZXNXMFXJ.js";import"./chunk-LNPTCPLR.js";import"./chunk-ZD5NDQ53.js";import"./chunk-TD2PU67Z.js";import{Ob as a,Pb as b}from"./chunk-S5USXWS2.js";import"./chunk-7CPZTMYD.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};
2
+ import{Aa as e,Ba as f,Ra as g,Ta as h,a as c,gb as i,hb as j,pb as k,za as d}from"./chunk-HV4L23QZ.js";import"./chunk-HK4767SO.js";import"./chunk-TWXMMQ26.js";import"./chunk-IOR23YGO.js";import"./chunk-KGG5EDZN.js";import{Ob as a,Pb as b}from"./chunk-JM6QBNUM.js";import"./chunk-W764RSKQ.js";import"./chunk-SHXBOMIB.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-7EXZQBG2.js";import"./chunk-R5P3CH5N.js";import"./chunk-DWLYVWFJ.js";import"./chunk-PYNO4NC2.js";import"./chunk-KFVJYB7D.js";import"./chunk-HV4L23QZ.js";import"./chunk-HK4767SO.js";import"./chunk-V5HJTYS5.js";import"./chunk-TWXMMQ26.js";import"./chunk-IOR23YGO.js";import"./chunk-KGG5EDZN.js";import"./chunk-JM6QBNUM.js";import"./chunk-W764RSKQ.js";import"./chunk-SHXBOMIB.js";import"./chunk-ONUPGMER.js";export{a as ArgumentCompleter,b as createArgumentCompleter};
@@ -1,12 +1,12 @@
1
1
  // @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
2
- import{Ka as v}from"./chunk-S5USXWS2.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\\": \\"1e97f7b76ef08446be731e3dad2c50b2c9040aa1f590f59d366bcab3f42ab37b\\"\\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\\": \\"7ead104d167fd65560bfe1d24ea222d85d4ca53bfe91245a004e87d4d7f29d84\\"\\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\\": \\"6cef66472facf03fad1796764f4e7c76c710ec89baafcb12197a7466b0ce7f56\\"\\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\\": \\"ee3c704ba5c2b8e861eb862919b608e61d3093f91f23309763f5e311658fa38a\\"\\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\\": \\"5519fa743d8b5adb41cad5bffca7059da6e6fe096dcf249ed0b2d52b93f491b7\\"\\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",`{
2
+ import{Ka as v}from"./chunk-JM6QBNUM.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\\": \\"294c71941767c163ddbb4eddaeab62cbb8be88b37488f34e8d99b406f99df4a2\\"\\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\\": \\"f46d888f35c6a3a4b01238818f7a32b1617df7b40e5b573f914671bd41f7725e\\"\\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\\": \\"e519420ce8c4d2439165f2d4fa6f59903111cc135ee35bc060f3a3768edd8857\\"\\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",
6
6
  "textTransaction": {
7
7
  "file": "kodax-text-transaction.node",
8
8
  "protocol": 4,
9
- "sha256": "6cef66472facf03fad1796764f4e7c76c710ec89baafcb12197a7466b0ce7f56"
9
+ "sha256": "79a903f9088a6929b2c0771c1f82aa4f33440d5eb8bca7f3f7fcf021d0be0805"
10
10
  },
11
11
  "legal": [
12
12
  {
@@ -1,5 +1,5 @@
1
1
  // @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
2
- import{A as Ke,C as bi,D as $i,E as Si,F as nt,I as on,K as xi,O as Ai,Q as nn,Z as Re,c as gi,ca as Ri,d as wi,ea as Ci,f as hi,fa as Ei,ga as Ii,h as et,i as ot,m as yi,n as vi,y as ki}from"./chunk-52FEJJMH.js";import{a as Pi}from"./chunk-O3SCJ4HT.js";import{Ab as ui,Ba as Zo,Bb as fi,Ca as yo,Ea as Qn,Fb as mi,Hb as pi,Ka as en,La as Zn}from"./chunk-4IH2OTLC.js";import{i as Vo}from"./chunk-YYPZCZ6O.js";import{$ as ti,$a as di,_a as ci,i as Xn,n as Xr}from"./chunk-UTUAC7YQ.js";import{A as li,D as Ae,J as He,m as Yo,n as Jo,o as Fe,q as wo,r as Qo,s as ri,t as ii,v as si,w as Jn,x as ai,y as ho}from"./chunk-IDEPSEPH.js";import{Cc as oi,_b as Qr,ac as Zr,bc as ei,ec as Vn,fb as zo,ja as Jr,qd as ni,r as Vr,s as Yr,sd as ae,yc as Yn,zc as Xo}from"./chunk-ZXNXMFXJ.js";import{$a as je,Ha as qn,L as Pr,Za as po,_a as De,ta as mo,va as Bn}from"./chunk-TD2PU67Z.js";import{$b as _r,$d as Kr,Ic as Ko,Ka as we,Kc as Bo,Kg as zr,La as W,Lc as jr,Ma as he,Na as Tr,Nc as Ur,Nd as X,Od as oe,Sa as Mr,Ta as Lr,Td as Fr,Ua as Gn,Xd as Hr,Yd as qo,bc as Wr,eg as Ue,fc as go,fg as Gr,jg as zn,k as Ho,rc as Nr,re as Br,sc as Or,tc as Dr,tg as Go,v as ee,wf as qr}from"./chunk-S5USXWS2.js";import{a}from"./chunk-ONUPGMER.js";import*as Dn from"fs";import*as jo 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"],Ja=["plan","accept-edits","auto","full-access"];function Qa(e){return e==="auto"||e==="auto-in-project"}a(Qa,"isAutoMode");function Ce(e){return e==="auto-in-project"?"auto":e}a(Ce,"canonicalizePermissionMode");function Za(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(Za,"permissionModeDisplayName");function Mi(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(Mi,"computeConfirmTools");function Li(e){return e!==void 0&&tn.includes(e)}a(Li,"isPermissionMode");function vo(e,o){return Li(e)?Ce(e):o===void 0?void 0:Ce(o)}a(vo,"normalizePermissionMode");import{createHash as el,randomUUID as ol}from"node:crypto";import Be from"node:fs";import _i from"node:path";var bo=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"}},qe=class extends Error{static{a(this,"ProviderSetupInvalidConfigError")}constructor(o,n){super(`KodaX configuration cannot be safely updated: ${o}. ${n}`),this.name="ProviderSetupInvalidConfigError"}},Ui=/^[A-Za-z_][A-Za-z0-9_]*$/,nl=new Set(["accesskey","apikey","accesstoken","auth","authorization","bearertoken","clientsecret","credential","key","password","privatekey","refreshtoken","secret","sig","signature","token","xapikey"]);function Ge(){return Object.entries(mo).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(Ge,"getProviderSetupCatalog");function Fi(e={}){let o=e.configPath??W("config.json"),n=e.catalog??Ge(),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=Bi(r.config);if(s)return{status:"invalid-config",configPath:o,configRevision:r.revision,reason:s};let l=Oi(e.explicitProvider);if(l){let d=ji(r.config,l,n);return d&&(!d.requiresCredential||Di(t,d.apiKeyEnv))?Wi(o,r.revision,l):Ni(o,r.revision,l,d?.apiKeyEnv)}if(!r.exists)return{status:"needs-provider",configPath:o,configRevision:r.revision};let c=Oi(r.config.provider);if(c){let d=ji(r.config,c,n);return d?!d.requiresCredential||Di(t,d.apiKeyEnv)?Wi(o,r.revision,c):Ni(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(Fi,"inspectProviderSetupReadiness");function Hi(e){let o=e.configPath??W("config.json"),n=e.catalog??Ge();try{return hi(o,()=>{let t=rt(o);if(!t.config)throw new qe(o,t.error??"config.json is invalid JSON.");if(t.revision!==e.expectedRevision)throw new bo(o);tl(t.config,o);let r=il(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 bo(o);return sl(o,s),{provider:r.provider,model:r.model,apiKeyEnv:r.apiKeyEnv,configPath:o}})}catch(t){throw t instanceof wi?new bo(o):t}}a(Hi,"persistProviderSetupChoice");function Ki(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(Ki,"providerSetupRestartInstructions");function Wi(e,o,n){return{status:"ready",configPath:e,configRevision:o,...n?{provider:n}:{}}}a(Wi,"ready");function Ni(e,o,n,t){return{status:"needs-credential",configPath:e,configRevision:o,provider:n,...t?{apiKeyEnv:t}:{}}}a(Ni,"needsCredential");function Oi(e){return typeof e=="string"&&e.trim()?e.trim():void 0}a(Oi,"normalizedString");function Di(e,o){return o!==void 0&&!!e[o]?.trim()}a(Di,"hasEnvironmentValue");function ji(e,o,n){let t=n.find(l=>l.name===o);if(t)return{apiKeyEnv:t.apiKeyEnv,requiresCredential:!0};if(Object.entries(mo).find(([l])=>l===o)?.[1]?.capabilityProfile.transport==="cli-bridge")return{requiresCredential:!1};let s=rl(e,o);return s?{apiKeyEnv:s.apiKeyEnv,requiresCredential:!0}:void 0}a(ji,"resolveConfiguredProvider");function tl(e,o){let n=Bi(e);if(n)throw new qe(o,n)}a(tl,"assertCustomProvidersPreservable");function Bi(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=qi(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(Bi,"existingCustomProvidersError");function rl(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(rl,"findValidCustomProvider");function it(e){if(!Gi(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),Ui.test(l.apiKeyEnv)?l:void 0}catch{return}}a(it,"toValidCustomProvider");function il(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(il,"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=qi(o.baseUrl);if(n)throw new Error(n);if(qn(o),!Ui.test(o.apiKeyEnv))throw new Error("Custom provider API key environment variable name is invalid.");return o}a(st,"validateProviderSetupCustomMetadata");function qi(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=>nl.has(t.toLowerCase().replace(/[-_.]/g,"")));return n===void 0?void 0:`Custom provider Base URL must not contain credential query parameter "${n}".`}a(qi,"customProviderEndpointError");function rt(e){if(!Be.existsSync(e))return{configPath:e,revision:ko(void 0),exists:!1,config:{}};let o;try{o=Be.readFileSync(e,"utf8")}catch(n){return{configPath:e,revision:ko(void 0),exists:!0,error:n instanceof Error?n.message:"config.json cannot be read."}}try{let n=JSON.parse(o);return Gi(n)?{configPath:e,revision:ko(o),exists:!0,config:n}:{configPath:e,revision:ko(o),exists:!0,error:"config.json must contain a JSON object."}}catch(n){return{configPath:e,revision:ko(o),exists:!0,error:n instanceof Error?n.message:"config.json is invalid JSON."}}}a(rt,"readConfig");function ko(e){return el("sha256").update(e??"<missing>","utf8").digest("hex")}a(ko,"revisionFor");function Gi(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}a(Gi,"isRecord");function sl(e,o){let n=_i.dirname(e);Be.mkdirSync(n,{recursive:!0});let t=_i.join(n,`.config.${process.pid}.${ol()}.tmp`);try{Be.writeFileSync(t,`${JSON.stringify(o,null,2)}
2
+ import{A as Ke,C as bi,D as $i,E as Si,F as nt,I as on,K as xi,O as Ai,Q as nn,Z as Re,c as gi,ca as Ri,d as wi,ea as Ci,f as hi,fa as Ei,ga as Ii,h as et,i as ot,m as yi,n as vi,y as ki}from"./chunk-R5P3CH5N.js";import{a as Pi}from"./chunk-DWLYVWFJ.js";import{Ab as ui,Ba as Zo,Bb as fi,Ca as yo,Ea as Qn,Fb as mi,Hb as pi,Ka as en,La as Zn}from"./chunk-PYNO4NC2.js";import{i as Vo}from"./chunk-KFVJYB7D.js";import{$a as ci,aa as ti,ab as di,i as Xn,n as Xr}from"./chunk-HV4L23QZ.js";import{A as li,D as Ae,J as He,m as Yo,n as Jo,o as Fe,q as wo,r as Qo,s as ri,t as ii,v as si,w as Jn,x as ai,y as ho}from"./chunk-V5HJTYS5.js";import{$b as Qr,Ac as Xo,Dc as oi,bc as Zr,cc as ei,fc as Vn,gb as zo,ja as Jr,r as Vr,rd as ni,s as Yr,td as ae,zc as Yn}from"./chunk-TWXMMQ26.js";import{$b as _r,$d as Kr,Ic as Ko,Ka as we,Kc as Bo,Kg as zr,La as W,Lc as jr,Ma as he,Na as Tr,Nc as Ur,Nd as X,Od as oe,Sa as Mr,Ta as Lr,Td as Fr,Ua as Gn,Xd as Hr,Yd as qo,bc as Wr,eg as Ue,fc as go,fg as Gr,jg as zn,k as Ho,rc as Nr,re as Br,sc as Or,tc as Dr,tg as Go,v as ee,wf as qr}from"./chunk-JM6QBNUM.js";import{$a as De,Ia as qn,M as Pr,_a as po,ab as je,ua as mo,wa as Bn}from"./chunk-SHXBOMIB.js";import{a}from"./chunk-ONUPGMER.js";import*as Dn from"fs";import*as jo 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"],Ja=["plan","accept-edits","auto","full-access"];function Qa(e){return e==="auto"||e==="auto-in-project"}a(Qa,"isAutoMode");function Ce(e){return e==="auto-in-project"?"auto":e}a(Ce,"canonicalizePermissionMode");function Za(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(Za,"permissionModeDisplayName");function Mi(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(Mi,"computeConfirmTools");function Li(e){return e!==void 0&&tn.includes(e)}a(Li,"isPermissionMode");function vo(e,o){return Li(e)?Ce(e):o===void 0?void 0:Ce(o)}a(vo,"normalizePermissionMode");import{createHash as el,randomUUID as ol}from"node:crypto";import Be from"node:fs";import _i from"node:path";var bo=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"}},qe=class extends Error{static{a(this,"ProviderSetupInvalidConfigError")}constructor(o,n){super(`KodaX configuration cannot be safely updated: ${o}. ${n}`),this.name="ProviderSetupInvalidConfigError"}},Ui=/^[A-Za-z_][A-Za-z0-9_]*$/,nl=new Set(["accesskey","apikey","accesstoken","auth","authorization","bearertoken","clientsecret","credential","key","password","privatekey","refreshtoken","secret","sig","signature","token","xapikey"]);function Ge(){return Object.entries(mo).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(Ge,"getProviderSetupCatalog");function Fi(e={}){let o=e.configPath??W("config.json"),n=e.catalog??Ge(),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=Bi(r.config);if(s)return{status:"invalid-config",configPath:o,configRevision:r.revision,reason:s};let l=Oi(e.explicitProvider);if(l){let d=ji(r.config,l,n);return d&&(!d.requiresCredential||Di(t,d.apiKeyEnv))?Wi(o,r.revision,l):Ni(o,r.revision,l,d?.apiKeyEnv)}if(!r.exists)return{status:"needs-provider",configPath:o,configRevision:r.revision};let c=Oi(r.config.provider);if(c){let d=ji(r.config,c,n);return d?!d.requiresCredential||Di(t,d.apiKeyEnv)?Wi(o,r.revision,c):Ni(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(Fi,"inspectProviderSetupReadiness");function Hi(e){let o=e.configPath??W("config.json"),n=e.catalog??Ge();try{return hi(o,()=>{let t=rt(o);if(!t.config)throw new qe(o,t.error??"config.json is invalid JSON.");if(t.revision!==e.expectedRevision)throw new bo(o);tl(t.config,o);let r=il(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 bo(o);return sl(o,s),{provider:r.provider,model:r.model,apiKeyEnv:r.apiKeyEnv,configPath:o}})}catch(t){throw t instanceof wi?new bo(o):t}}a(Hi,"persistProviderSetupChoice");function Ki(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(Ki,"providerSetupRestartInstructions");function Wi(e,o,n){return{status:"ready",configPath:e,configRevision:o,...n?{provider:n}:{}}}a(Wi,"ready");function Ni(e,o,n,t){return{status:"needs-credential",configPath:e,configRevision:o,provider:n,...t?{apiKeyEnv:t}:{}}}a(Ni,"needsCredential");function Oi(e){return typeof e=="string"&&e.trim()?e.trim():void 0}a(Oi,"normalizedString");function Di(e,o){return o!==void 0&&!!e[o]?.trim()}a(Di,"hasEnvironmentValue");function ji(e,o,n){let t=n.find(l=>l.name===o);if(t)return{apiKeyEnv:t.apiKeyEnv,requiresCredential:!0};if(Object.entries(mo).find(([l])=>l===o)?.[1]?.capabilityProfile.transport==="cli-bridge")return{requiresCredential:!1};let s=rl(e,o);return s?{apiKeyEnv:s.apiKeyEnv,requiresCredential:!0}:void 0}a(ji,"resolveConfiguredProvider");function tl(e,o){let n=Bi(e);if(n)throw new qe(o,n)}a(tl,"assertCustomProvidersPreservable");function Bi(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=qi(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(Bi,"existingCustomProvidersError");function rl(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(rl,"findValidCustomProvider");function it(e){if(!Gi(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),Ui.test(l.apiKeyEnv)?l:void 0}catch{return}}a(it,"toValidCustomProvider");function il(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(il,"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=qi(o.baseUrl);if(n)throw new Error(n);if(qn(o),!Ui.test(o.apiKeyEnv))throw new Error("Custom provider API key environment variable name is invalid.");return o}a(st,"validateProviderSetupCustomMetadata");function qi(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=>nl.has(t.toLowerCase().replace(/[-_.]/g,"")));return n===void 0?void 0:`Custom provider Base URL must not contain credential query parameter "${n}".`}a(qi,"customProviderEndpointError");function rt(e){if(!Be.existsSync(e))return{configPath:e,revision:ko(void 0),exists:!1,config:{}};let o;try{o=Be.readFileSync(e,"utf8")}catch(n){return{configPath:e,revision:ko(void 0),exists:!0,error:n instanceof Error?n.message:"config.json cannot be read."}}try{let n=JSON.parse(o);return Gi(n)?{configPath:e,revision:ko(o),exists:!0,config:n}:{configPath:e,revision:ko(o),exists:!0,error:"config.json must contain a JSON object."}}catch(n){return{configPath:e,revision:ko(o),exists:!0,error:n instanceof Error?n.message:"config.json is invalid JSON."}}}a(rt,"readConfig");function ko(e){return el("sha256").update(e??"<missing>","utf8").digest("hex")}a(ko,"revisionFor");function Gi(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}a(Gi,"isRecord");function sl(e,o){let n=_i.dirname(e);Be.mkdirSync(n,{recursive:!0});let t=_i.join(n,`.config.${process.pid}.${ol()}.tmp`);try{Be.writeFileSync(t,`${JSON.stringify(o,null,2)}
3
3
  `,{encoding:"utf8",mode:384}),Be.renameSync(t,e)}catch(r){throw Be.rmSync(t,{force:!0}),r}}a(sl,"writeConfigAtomically");import{existsSync as zi,mkdirSync as al,readFileSync as Xi,writeFileSync as ll}from"node:fs";import ze from"node:path";var cl={core:{},mcp:{version:1,servers:{}},extensions:{version:1,paths:[]},a2a:{version:2,agents:{}}},dl=["core","mcp","extensions","a2a"];function at(e,o){return o==="core"?ze.join(e,"config.json"):ze.join(e,"integrations",`${o}.json`)}a(at,"activePath");function ul(e,o){return o==="core"?ze.join(e,"config.example.jsonc"):ze.join(e,"integrations",`${o}.example.jsonc`)}a(ul,"templatePath");function fl(e){let o=e.replaceAll("\\","/");return dl.flatMap(n=>[{domain:n,kind:"active",path:at(e,n),content:`${JSON.stringify(cl[n],null,2)}
4
4
  `},{domain:n,kind:"template",path:ul(e,n),content:gi(n).replaceAll("~/.kodax",o)}])}a(fl,"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 ml(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(ml,"validateA2ADocument");function pl(e,o){let n=Xi(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):ml(t,o)}a(pl,"validateActiveFile");function Vi(e,o){if(!zi(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 pl(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(Vi,"existingFileResult");function gl(e){return e instanceof Error&&"code"in e&&e.code==="EEXIST"}a(gl,"isAlreadyExists");function wl(e,o){al(ze.dirname(e.path),{recursive:!0,mode:448});try{return ll(e.path,e.content,{encoding:"utf8",flag:"wx",mode:384}),{domain:e.domain,kind:e.kind,path:e.path,status:"created"}}catch(n){if(gl(n))return Vi(e,o);throw n}}a(wl,"createIfMissing");function hl(e){let o=at(e,"core");if(zi(o))try{let n=$o(JSON.parse(Xi(o,"utf8")),"Core config"),t=yi(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(hl,"legacyIntegrationDiagnostic");function Yi(e={}){let o=ze.resolve(e.configHome??we()),n=fl(o),t=n.map(s=>Vi(s,e.validateA2A));if(t.some(s=>s.status==="invalid"))return{configHome:o,files:t};let r=hl(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 vi({configHome:o}),{configHome:o,files:n.map(s=>wl(s,e.validateA2A))}}a(Yi,"initializeSetupConfiguration");import Ee from"node:path";var Ji=[{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 yl(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(yl,"formatBinding");function lt(e){let n=Ji.find(t=>t.id===e)?.defaultBindings[0];return n?yl(n):"<unavailable>"}a(lt,"shortcut");function vl(){return Object.entries(mo).filter(([,e])=>e.capabilityProfile.transport==="cli-bridge").map(([e])=>e).sort()}a(vl,"defaultCliBridges");function ct(e={}){let o=Ee.resolve(e.configHome??we()),n=e.catalog??Ge(),t=e.cliBridges??vl(),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: ${Ee.join(o,"config.json")}`,` Annotated template: ${Ee.join(o,"config.example.jsonc")}`,` MCP: ${Ee.join(o,"integrations","mcp.json")}`,` Extensions: ${Ee.join(o,"integrations","extensions.json")}`,` A2A: ${Ee.join(o,"integrations","a2a.json")}`,` Integration templates: ${Ee.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 Qi from"node:readline";import dt from"chalk";async function Zi(e={}){let o=e.catalog??Ge(),n=Fi({...e.configPath?{configPath:e.configPath}:{},catalog:o});if(n.status==="invalid-config")throw new qe(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??Sl({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 bl(r):await kl(r,o,s.slice(8));if(!l)return{status:"cancelled"};let c=$l(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:Hi({configPath:n.configPath,expectedRevision:n.configRevision,catalog:o,choice:l})}:{status:"cancelled"}}finally{t&&r.close?.()}}a(Zi,"runProviderSetupWizard");async function kl(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(kl,"collectBuiltinChoice");async function bl(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(bl,"collectCustomChoice");async function rn(e,o){let t=(await e.text(o))?.trim();return t||void 0}a(rn,"requiredText");function $l(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($l,"summarizeChoice");function Sl(e){let o=Qi.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=X(this.gitRoot);return o.size===0&&await oe(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 jf}from"node:child_process";import*as so from"node:path";import{promisify as Uf}from"node:util";var Fa=Uf(jf);function Ff(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(Ff,"pathFromPorcelainLine");async function Ha(e,o=10){try{let[{stdout:n},{stdout:t}]=await Promise.all([Fa("git rev-parse --show-toplevel",{cwd:e,windowsHide:!0}),Fa("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=Ff(c);if(!d)continue;let u=so.resolve(r,d),f=so.relative(e,u).split(so.sep).join("/");if(!(!f||f.startsWith("..")||l.has(f))&&(l.add(f),s.push(f),s.length>=o))break}return s}catch{return[]}}a(Ha,"getRecentWorkingSetFiles");function ao(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(ao,"findCommandSlashIndex");var vr=class{static{a(this,"FileCompleter")}cwdSource;cache=new Map;cacheTimeout=5e3;recentCache=new Map;recentFilesProvider;constructor(o,n=Ha){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:jo.join(c,s.slice(0,d)),f=d===-1?s:s.slice(d+1);try{let b=(await this.readdir(u)).filter($=>$.toLowerCase().startsWith(f.toLowerCase()));for(let $ of b){let R=jo.join(u,$),A=await this.isDirectory(R),v=d===-1?$:s.slice(0,d+1)+$;l.push({text:"@"+v+(A?"/":""),display:$+(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)),$=f.toLowerCase(),R=[];for(let A of p){if(f&&!jo.basename(A).toLowerCase().startsWith($))continue;let v="@"+A;b.has(v)||(b.add(v),R.push({text:v,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 io().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=ao(t);return r===-1?!1:!t.slice(r).includes(" ")}async getCompletions(o,n){let t=o.slice(0,n),r=ao(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 Nv(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 Hf(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=>Kf(r,u)),r]}}a(Nv,"createCompleter");async function Hf(e,o){let{ArgumentCompleter:n}=await import("./argument-completer-TTUEXPZ4.js"),t=new n;return t.canComplete(e,o)?t.getCompletions(e,o):[]}a(Hf,"getArgumentCompletions");function Kf(e,o){if(o.type!=="argument")return o.text;let n=ao(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(Kf,"formatReadlineCompletion");import{existsSync as jn,readdirSync as Ga,readFileSync as za}from"node:fs";import{join as Un}from"node:path";var Bf=[{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"}],lo=[{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 qf(e){if(e&&e.includes("/")){let o=e.indexOf("/"),n=e.slice(0,o),t=e.slice(o+1);if(De(n))try{return Ke(n).filter(s=>!t||s.toLowerCase().includes(t.toLowerCase())).map(s=>({name:`${n}/${s}`,description:s,type:"enum"}))}catch{}return[]}return je().map(o=>({name:o,description:`Switch to ${o} provider`,type:"enum"}))}a(qf,"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"}],$r=[{name:"all",description:"Delete ALL sessions",type:"enum"}],Gf=[{name:"status",description:"Show MCP server status",type:"enum"},{name:"refresh",description:"Refresh MCP server catalogs",type:"enum"}],zf=[{name:"status",description:"Show child-task fallback order",type:"enum"},{name:"off",description:"Disable child-task fallback providers",type:"enum"}],Ka=[{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"}],Ba=[{name:"on",description:"Enable logging",type:"enum"},{name:"off",description:"Disable logging",type:"enum"}],Xf=[{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"}],Vf=[{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 Yf(e){let[o=""]=e,n=o.toLowerCase(),t=e.length===1&&e[0]===""?0:e.length;return t<=1?Vf: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(Yf,"getLearnArgs");var Jf=[{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"}],Qf=[{name:"show",description:"Show a captured paste by id",type:"enum"},{name:"list",description:"List captured pastes",type:"enum"}],Zf=[{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"}],em=[{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"}],om=[{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"}],nm=[{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"}],tm=[{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"}],rm=[{name:"status",description:"Deprecated alias for /repo-intel status",type:"enum"}],im=[{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"}],sm=new Set(["show","pause","resume","stop","delete","rerun","save","rename","revise"]),am=new Set(["show","delete","rerun","save","rename","revise"]),lm=[{name:"--all",description:"Show all persisted workflow runs",type:"enum"},{name:"--limit",description:"Show at most N persisted workflow runs",type:"enum"}],cm=[{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"}],dm=[{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"}],um=[".workflow.json",".ts",".mjs",".js"];function fm(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(fm,"workflowRunMatchesSubcommand");function Fn(e){return/^[a-zA-Z0-9._-]{1,120}$/.test(e)&&!e.startsWith(".")&&!e.includes("..")}a(Fn,"isWorkflowRunEntryName");function mm(e,o){let n=Un(e,"workflow-metadata.json");if(jn(n))try{let r=JSON.parse(za(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(mm,"readWorkflowRunDisplayName");function pm(){let e=ke(process.cwd()).key,o=W("workflow-runs",e);if(!jn(o))return[];let n=[];for(let t of Ga(o)){if(!Fn(t))continue;let r=Un(o,t,"run.json");if(jn(r))try{let s=JSON.parse(za(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=mm(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(pm,"getPersistedWorkflowRunIdArgs");function Hn(e){let o=He().list().filter(r=>fm(e,r.status)).map(r=>({name:r.runId,description:`${r.workflow} - ${r.status}`,type:"string"})),n=am.has(e)?pm():[],t=new Set;return[...o,...n].filter(r=>t.has(r.name)?!1:(t.add(r.name),!0))}a(Hn,"getWorkflowRunIdArgs");function gm(e){for(let o of um)if(e.endsWith(o)){let n=e.slice(0,-o.length);return Fn(n)?n:void 0}}a(gm,"savedWorkflowNameFromFile");function Uo(e={}){let o=[{path:W("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 Ga(t.path)){if(e.generatedOnly===!0&&!r.endsWith(".workflow.json"))continue;let s=gm(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(Uo,"getSavedWorkflowNameArgs");function wm(){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 Uo()){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(wm,"getWorkflowRerunArgs");function Sr(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 Uo({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(Sr,"getWorkflowRunOrSavedNameArgs");function qa(e){let o=new Set(e.slice(1).filter(n=>n.startsWith("--")));return o.has("--saved")?Uo({generatedOnly:!0}):o.has("--run")?Hn("delete"):Sr("delete")}a(qa,"getWorkflowDeleteTargetArgs");function hm(e){let[o=""]=e,n=o.toLowerCase(),t=e.length===1&&e[0]===""?0:e.length;if(t<=1)return[...im,...Jo().map(r=>({name:r.name,description:r.description,type:"enum"})),...Uo()];if(n==="rerun"&&t<=2)return wm();if(n==="rename"&&t<=2)return Sr("rename");if(n==="delete"&&t<=2)return[...dm,...qa(e)];if(n==="delete"&&t<=3&&e.slice(1).some(r=>r.startsWith("--")))return qa(e);if(n==="revise"){if(t<=2)return[{name:"--replace",description:"Replace a saved workflow after confirmation",type:"enum"},...Sr("revise")];if(e[1]==="--replace"&&t<=3)return Uo()}return sm.has(n)&&t<=2?Hn(n):n==="runs"&&t<=2?lm:n==="prune"&&t<=2?cm:[]}a(hm,"getWorkflowArgs");function ym(e){let[o=""]=e,n=o.toLowerCase(),t=e.length===1&&e[0]===""?0:e.length;return t<=1?om:t>2?[]:n==="mode"?nm:n==="trace"?tm:[]}a(ym,"getRepoIntelArgs");var vm=new Map([["mode",Bf],["thinking",lo],["think",lo],["t",lo],["reasoning",lo],["reason",lo],["effort",lo],["status",br],["info",br],["ctx",br],["mcp",Gf],["fallback",zf],["agent-mode",Ka],["am",Ka],["verifier-log",Ba],["stall-log",Ba],["memory",Xf],["goal",Jf],["paste",Qf],["review",Zf],["agents",em],["delete",$r],["rm",$r],["del",$r]]),km=new Set(["model","m","provider"]),bm=new Set(["repo-intel"]),$m=new Set(["repointel","ri"]),Sm=new Set(["workflow"]),xm=new Set(["learn"]);function xr(e,o,n=[]){let t=e.toLowerCase();return km.has(t)?qf(o):bm.has(t)?ym(n):$m.has(t)?n.length<=1?rm:[]:Sm.has(t)?hm(n):xm.has(t)?Yf(n):vm.get(t)??[]}a(xr,"getCommandArguments");var Ar=class{static{a(this,"ArgumentCompleter")}canComplete(o,n){let t=o.slice(0,n),r=ao(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=ao(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(),$=xr(c,p,u);if(!$||$.length===0)return[];let R=new Set(u.slice(0,-1).map(v=>v.toLowerCase()));return $.filter(v=>!R.has(v.name.toLowerCase())).filter(v=>!b||v.name.includes("/")?!0:v.name.toLowerCase().includes(b)).map(v=>({text:v.name,display:v.name,description:v.description,type:"argument"})).sort((v,k)=>{if(!b)return 0;let I=v.display.toLowerCase().startsWith(b),M=k.display.toLowerCase().startsWith(b);return I&&!M?-1:!I&&M?1:v.display.length-k.display.length})}};function Vv(){return new Ar}a(Vv,"createArgumentCompleter");export{kt as a,B as b,pg as c,ws as d,gg as e,tn as f,Ja as g,Qa as h,Ce as i,Za as j,Mi as k,Li as l,vo as m,bo as n,qe as o,Ge as p,Fi as q,Hi as r,Ki as s,Yi as t,Ji as u,ct as v,Zi as w,Wl as x,Ip as y,Kp as z,Nl as A,gt as B,Bp as C,qp as D,cs as E,xo as F,Qp as G,ht as H,Zp as I,eg as J,ig as K,sg as L,gs as M,le as N,vs as O,ks as P,bg as Q,oc as R,gc as S,$g as T,un as U,$t as V,Sg as W,Ps as X,xg as Y,Ag as Z,Rg as _,Zg as $,ew as aa,ow as ba,nw as ca,qs as da,It as ea,Gs as fa,ke as ga,bd as ha,lw as ia,Eo as ja,Wt as ka,Me as la,Jd as ma,Qd as na,ua as oa,_w as pa,Ww as qa,uu as ra,Th as sa,Mh as ta,Lh as ua,Qh as va,Zh as wa,ey as xa,oy as ya,ny as za,xa as Aa,ly as Ba,cy as Ca,Ra as Da,dy as Ea,Iy as Fa,Ca as Ga,io as Ha,kv as Ia,bv as Ja,$v as Ka,On as La,Ar as Ma,Vv as Na,ao as Oa,vr as Pa,kr as Qa,Nv as Ra};
674
+ `)){if(!c.trim())continue;let d=Ff(c);if(!d)continue;let u=so.resolve(r,d),f=so.relative(e,u).split(so.sep).join("/");if(!(!f||f.startsWith("..")||l.has(f))&&(l.add(f),s.push(f),s.length>=o))break}return s}catch{return[]}}a(Ha,"getRecentWorkingSetFiles");function ao(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(ao,"findCommandSlashIndex");var vr=class{static{a(this,"FileCompleter")}cwdSource;cache=new Map;cacheTimeout=5e3;recentCache=new Map;recentFilesProvider;constructor(o,n=Ha){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:jo.join(c,s.slice(0,d)),f=d===-1?s:s.slice(d+1);try{let b=(await this.readdir(u)).filter($=>$.toLowerCase().startsWith(f.toLowerCase()));for(let $ of b){let R=jo.join(u,$),A=await this.isDirectory(R),v=d===-1?$:s.slice(0,d+1)+$;l.push({text:"@"+v+(A?"/":""),display:$+(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)),$=f.toLowerCase(),R=[];for(let A of p){if(f&&!jo.basename(A).toLowerCase().startsWith($))continue;let v="@"+A;b.has(v)||(b.add(v),R.push({text:v,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 io().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=ao(t);return r===-1?!1:!t.slice(r).includes(" ")}async getCompletions(o,n){let t=o.slice(0,n),r=ao(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 Nv(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 Hf(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=>Kf(r,u)),r]}}a(Nv,"createCompleter");async function Hf(e,o){let{ArgumentCompleter:n}=await import("./argument-completer-NG4VLIRD.js"),t=new n;return t.canComplete(e,o)?t.getCompletions(e,o):[]}a(Hf,"getArgumentCompletions");function Kf(e,o){if(o.type!=="argument")return o.text;let n=ao(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(Kf,"formatReadlineCompletion");import{existsSync as jn,readdirSync as Ga,readFileSync as za}from"node:fs";import{join as Un}from"node:path";var Bf=[{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"}],lo=[{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 qf(e){if(e&&e.includes("/")){let o=e.indexOf("/"),n=e.slice(0,o),t=e.slice(o+1);if(De(n))try{return Ke(n).filter(s=>!t||s.toLowerCase().includes(t.toLowerCase())).map(s=>({name:`${n}/${s}`,description:s,type:"enum"}))}catch{}return[]}return je().map(o=>({name:o,description:`Switch to ${o} provider`,type:"enum"}))}a(qf,"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"}],$r=[{name:"all",description:"Delete ALL sessions",type:"enum"}],Gf=[{name:"status",description:"Show MCP server status",type:"enum"},{name:"refresh",description:"Refresh MCP server catalogs",type:"enum"}],zf=[{name:"status",description:"Show child-task fallback order",type:"enum"},{name:"off",description:"Disable child-task fallback providers",type:"enum"}],Ka=[{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"}],Ba=[{name:"on",description:"Enable logging",type:"enum"},{name:"off",description:"Disable logging",type:"enum"}],Xf=[{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"}],Vf=[{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 Yf(e){let[o=""]=e,n=o.toLowerCase(),t=e.length===1&&e[0]===""?0:e.length;return t<=1?Vf: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(Yf,"getLearnArgs");var Jf=[{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"}],Qf=[{name:"show",description:"Show a captured paste by id",type:"enum"},{name:"list",description:"List captured pastes",type:"enum"}],Zf=[{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"}],em=[{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"}],om=[{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"}],nm=[{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"}],tm=[{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"}],rm=[{name:"status",description:"Deprecated alias for /repo-intel status",type:"enum"}],im=[{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"}],sm=new Set(["show","pause","resume","stop","delete","rerun","save","rename","revise"]),am=new Set(["show","delete","rerun","save","rename","revise"]),lm=[{name:"--all",description:"Show all persisted workflow runs",type:"enum"},{name:"--limit",description:"Show at most N persisted workflow runs",type:"enum"}],cm=[{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"}],dm=[{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"}],um=[".workflow.json",".ts",".mjs",".js"];function fm(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(fm,"workflowRunMatchesSubcommand");function Fn(e){return/^[a-zA-Z0-9._-]{1,120}$/.test(e)&&!e.startsWith(".")&&!e.includes("..")}a(Fn,"isWorkflowRunEntryName");function mm(e,o){let n=Un(e,"workflow-metadata.json");if(jn(n))try{let r=JSON.parse(za(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(mm,"readWorkflowRunDisplayName");function pm(){let e=ke(process.cwd()).key,o=W("workflow-runs",e);if(!jn(o))return[];let n=[];for(let t of Ga(o)){if(!Fn(t))continue;let r=Un(o,t,"run.json");if(jn(r))try{let s=JSON.parse(za(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=mm(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(pm,"getPersistedWorkflowRunIdArgs");function Hn(e){let o=He().list().filter(r=>fm(e,r.status)).map(r=>({name:r.runId,description:`${r.workflow} - ${r.status}`,type:"string"})),n=am.has(e)?pm():[],t=new Set;return[...o,...n].filter(r=>t.has(r.name)?!1:(t.add(r.name),!0))}a(Hn,"getWorkflowRunIdArgs");function gm(e){for(let o of um)if(e.endsWith(o)){let n=e.slice(0,-o.length);return Fn(n)?n:void 0}}a(gm,"savedWorkflowNameFromFile");function Uo(e={}){let o=[{path:W("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 Ga(t.path)){if(e.generatedOnly===!0&&!r.endsWith(".workflow.json"))continue;let s=gm(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(Uo,"getSavedWorkflowNameArgs");function wm(){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 Uo()){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(wm,"getWorkflowRerunArgs");function Sr(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 Uo({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(Sr,"getWorkflowRunOrSavedNameArgs");function qa(e){let o=new Set(e.slice(1).filter(n=>n.startsWith("--")));return o.has("--saved")?Uo({generatedOnly:!0}):o.has("--run")?Hn("delete"):Sr("delete")}a(qa,"getWorkflowDeleteTargetArgs");function hm(e){let[o=""]=e,n=o.toLowerCase(),t=e.length===1&&e[0]===""?0:e.length;if(t<=1)return[...im,...Jo().map(r=>({name:r.name,description:r.description,type:"enum"})),...Uo()];if(n==="rerun"&&t<=2)return wm();if(n==="rename"&&t<=2)return Sr("rename");if(n==="delete"&&t<=2)return[...dm,...qa(e)];if(n==="delete"&&t<=3&&e.slice(1).some(r=>r.startsWith("--")))return qa(e);if(n==="revise"){if(t<=2)return[{name:"--replace",description:"Replace a saved workflow after confirmation",type:"enum"},...Sr("revise")];if(e[1]==="--replace"&&t<=3)return Uo()}return sm.has(n)&&t<=2?Hn(n):n==="runs"&&t<=2?lm:n==="prune"&&t<=2?cm:[]}a(hm,"getWorkflowArgs");function ym(e){let[o=""]=e,n=o.toLowerCase(),t=e.length===1&&e[0]===""?0:e.length;return t<=1?om:t>2?[]:n==="mode"?nm:n==="trace"?tm:[]}a(ym,"getRepoIntelArgs");var vm=new Map([["mode",Bf],["thinking",lo],["think",lo],["t",lo],["reasoning",lo],["reason",lo],["effort",lo],["status",br],["info",br],["ctx",br],["mcp",Gf],["fallback",zf],["agent-mode",Ka],["am",Ka],["verifier-log",Ba],["stall-log",Ba],["memory",Xf],["goal",Jf],["paste",Qf],["review",Zf],["agents",em],["delete",$r],["rm",$r],["del",$r]]),km=new Set(["model","m","provider"]),bm=new Set(["repo-intel"]),$m=new Set(["repointel","ri"]),Sm=new Set(["workflow"]),xm=new Set(["learn"]);function xr(e,o,n=[]){let t=e.toLowerCase();return km.has(t)?qf(o):bm.has(t)?ym(n):$m.has(t)?n.length<=1?rm:[]:Sm.has(t)?hm(n):xm.has(t)?Yf(n):vm.get(t)??[]}a(xr,"getCommandArguments");var Ar=class{static{a(this,"ArgumentCompleter")}canComplete(o,n){let t=o.slice(0,n),r=ao(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=ao(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(),$=xr(c,p,u);if(!$||$.length===0)return[];let R=new Set(u.slice(0,-1).map(v=>v.toLowerCase()));return $.filter(v=>!R.has(v.name.toLowerCase())).filter(v=>!b||v.name.includes("/")?!0:v.name.toLowerCase().includes(b)).map(v=>({text:v.name,display:v.name,description:v.description,type:"argument"})).sort((v,k)=>{if(!b)return 0;let I=v.display.toLowerCase().startsWith(b),M=k.display.toLowerCase().startsWith(b);return I&&!M?-1:!I&&M?1:v.display.length-k.display.length})}};function Vv(){return new Ar}a(Vv,"createArgumentCompleter");export{kt as a,B as b,pg as c,ws as d,gg as e,tn as f,Ja as g,Qa as h,Ce as i,Za as j,Mi as k,Li as l,vo as m,bo as n,qe as o,Ge as p,Fi as q,Hi as r,Ki as s,Yi as t,Ji as u,ct as v,Zi as w,Wl as x,Ip as y,Kp as z,Nl as A,gt as B,Bp as C,qp as D,cs as E,xo as F,Qp as G,ht as H,Zp as I,eg as J,ig as K,sg as L,gs as M,le as N,vs as O,ks as P,bg as Q,oc as R,gc as S,$g as T,un as U,$t as V,Sg as W,Ps as X,xg as Y,Ag as Z,Rg as _,Zg as $,ew as aa,ow as ba,nw as ca,qs as da,It as ea,Gs as fa,ke as ga,bd as ha,lw as ia,Eo as ja,Wt as ka,Me as la,Jd as ma,Qd as na,ua as oa,_w as pa,Ww as qa,uu as ra,Th as sa,Mh as ta,Lh as ua,Qh as va,Zh as wa,ey as xa,oy as ya,ny as za,xa as Aa,ly as Ba,cy as Ca,Ra as Da,dy as Ea,Iy as Fa,Ca as Ga,io as Ha,kv as Ia,bv as Ja,$v as Ka,On as La,Ar as Ma,Vv as Na,ao as Oa,vr as Pa,kr as Qa,Nv as Ra};
@@ -1,2 +1,2 @@
1
1
  // @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
2
- import{Ib as o,pb as r}from"./chunk-RNJPYIXJ.js";import{a as n}from"./chunk-BRZO5ZGS.js";import{a as e}from"./chunk-ONUPGMER.js";function u(t){return o(n(t))}e(u,"runInteractiveMode");function a(t){return r(n(t))}e(a,"runInkInteractiveMode");export{u as a,a as b};
2
+ import{Ib as o,pb as r}from"./chunk-N3ODBSEC.js";import{a as n}from"./chunk-LQ2TYOUF.js";import{a as e}from"./chunk-ONUPGMER.js";function u(t){return o(n(t))}e(u,"runInteractiveMode");function a(t){return r(n(t))}e(a,"runInkInteractiveMode");export{u as a,a as b};
@@ -1,2 +1,2 @@
1
1
  // @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
2
- import{La as c,lf as o}from"./chunk-S5USXWS2.js";import{a as n}from"./chunk-ONUPGMER.js";import{readFile as a}from"fs/promises";var i={enabled:!0,triggerPercent:75};async function s(r){let t=c("config.json");try{let e=await f(t);if(e?.compaction)return o({...i,...e.compaction})}catch{}return o(i)}n(s,"loadCompactionConfig");async function f(r){try{let t=await a(r,"utf-8");return JSON.parse(t)}catch{return null}}n(f,"readConfigFile");export{s as a};
2
+ import{La as c,lf as o}from"./chunk-JM6QBNUM.js";import{a as n}from"./chunk-ONUPGMER.js";import{readFile as a}from"fs/promises";var i={enabled:!0,triggerPercent:75};async function s(r){let t=c("config.json");try{let e=await f(t);if(e?.compaction)return o({...i,...e.compaction})}catch{}return o(i)}n(s,"loadCompactionConfig");async function f(r){try{let t=await a(r,"utf-8");return JSON.parse(t)}catch{return null}}n(f,"readConfigFile");export{s as a};
@@ -1,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-2O2HZCBH.js";import{c as u}from"./chunk-ZXNXMFXJ.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};
2
+ import{g as m,i as h,j as x}from"./chunk-3PIOVQVB.js";import{c as u}from"./chunk-TWXMMQ26.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,2 +1,2 @@
1
1
  // @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
2
- import{x as o}from"./chunk-TD2PU67Z.js";import{a as i}from"./chunk-ONUPGMER.js";function r(u){let e=o(u?.llm);if(!e)return;let t={};return e.requestTimeoutMs!==void 0&&(t.requestTimeoutMs=e.requestTimeoutMs),e.streamIdleTimeoutMs!==void 0&&(t.streamIdleTimeoutMs=e.streamIdleTimeoutMs),e.chunkTimeoutMs!==void 0&&(t.chunkTimeoutMs=e.chunkTimeoutMs),e.maxRetryDelayMs!==void 0&&(t.maxRetryDelayMs=e.maxRetryDelayMs),Object.keys(t).length>0?t:void 0}i(r,"providerResilienceConfigFromTimeouts");export{r as a};
2
+ import{y as o}from"./chunk-SHXBOMIB.js";import{a as i}from"./chunk-ONUPGMER.js";function r(u){let e=o(u?.llm);if(!e)return;let t={};return e.requestTimeoutMs!==void 0&&(t.requestTimeoutMs=e.requestTimeoutMs),e.streamIdleTimeoutMs!==void 0&&(t.streamIdleTimeoutMs=e.streamIdleTimeoutMs),e.chunkTimeoutMs!==void 0&&(t.chunkTimeoutMs=e.chunkTimeoutMs),e.maxRetryDelayMs!==void 0&&(t.maxRetryDelayMs=e.maxRetryDelayMs),Object.keys(t).length>0?t:void 0}i(r,"providerResilienceConfigFromTimeouts");export{r as a};