@kodax-ai/kodax 0.7.97-alpha.10 → 0.7.97-alpha.11

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 (139) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/README.md +36 -7
  3. package/README_CN.md +26 -5
  4. package/config-templates/config.example.jsonc +2 -3
  5. package/dist/chunks/agent-C4QJRI2R.js +2 -0
  6. package/dist/chunks/agent-adapter-ZUBK5QZX.js +2 -0
  7. package/dist/chunks/argument-completer-VODW2G5C.js +2 -0
  8. package/dist/chunks/cell-JM7Z7IL4.js +2 -0
  9. package/dist/chunks/{chunk-VYBDXBXF.js → chunk-22UAAJCB.js} +4 -5
  10. package/dist/chunks/{chunk-INUCUPDB.js → chunk-4MZEUECQ.js} +1 -1
  11. package/dist/chunks/{chunk-LR6DYYBI.js → chunk-6Z63HHR2.js} +1 -1
  12. package/dist/chunks/{chunk-6YC6F7I5.js → chunk-76UPX4CI.js} +2 -2
  13. package/dist/chunks/{chunk-RHUYH367.js → chunk-7FQJ7PE6.js} +1 -1
  14. package/dist/chunks/chunk-7PBG4SST.js +137 -0
  15. package/dist/chunks/{chunk-C7XNYEK4.js → chunk-CFGJS457.js} +137 -139
  16. package/dist/chunks/{chunk-WMI7MAOL.js → chunk-CIIPF3TS.js} +1 -1
  17. package/dist/chunks/chunk-DOKPC4RS.js +5 -0
  18. package/dist/chunks/{chunk-CL26MA5E.js → chunk-DOO4VVA5.js} +1 -1
  19. package/dist/chunks/{chunk-CAYWOUYZ.js → chunk-E2ZROK4I.js} +1 -1
  20. package/dist/chunks/{chunk-X4RMCMA2.js → chunk-EXAZEV56.js} +1 -1
  21. package/dist/chunks/chunk-FPUEDGGU.js +500 -0
  22. package/dist/chunks/{chunk-QQEAMIKM.js → chunk-HAGF25HA.js} +11 -11
  23. package/dist/chunks/chunk-HFJ2KSHV.js +5 -0
  24. package/dist/chunks/chunk-HKN6ZIXI.js +408 -0
  25. package/dist/chunks/{chunk-LVJOKQZF.js → chunk-IL5AAIGK.js} +1 -1
  26. package/dist/chunks/{chunk-CJYBW5ZF.js → chunk-KI3TUCEE.js} +1 -1
  27. package/dist/chunks/chunk-LXSXL4DB.js +448 -0
  28. package/dist/chunks/chunk-MZ44IR3J.js +2 -0
  29. package/dist/chunks/chunk-N2MPJVHA.js +12 -0
  30. package/dist/chunks/chunk-NBKSCESR.js +29 -0
  31. package/dist/chunks/{chunk-Y5OQTXT7.js → chunk-NMRBY4TS.js} +1 -1
  32. package/dist/chunks/chunk-OXXWTARH.js +351 -0
  33. package/dist/chunks/{chunk-WIQQ57YO.js → chunk-QRIBGJLE.js} +1 -1
  34. package/dist/chunks/{chunk-JUK7W2GI.js → chunk-QVMFYZOS.js} +1 -1
  35. package/dist/chunks/{chunk-FSV2UNZK.js → chunk-UFWK2OOJ.js} +87 -86
  36. package/dist/chunks/chunk-ULA453FO.js +362 -0
  37. package/dist/chunks/{chunk-FROQFYUD.js → chunk-USAJGDW3.js} +20 -20
  38. package/dist/chunks/{chunk-U7XIL752.js → chunk-VA5GQNHW.js} +55 -55
  39. package/dist/chunks/chunk-W5LXBBFR.js +9 -0
  40. package/dist/chunks/{chunk-AM4NSREL.js → chunk-XYYFVN3S.js} +1 -1
  41. package/dist/chunks/{client-7WSN7BYP.js → client-IRMZJ3B5.js} +1 -1
  42. package/dist/chunks/compaction-config-WWWEV7KG.js +2 -0
  43. package/dist/chunks/{construction-bootstrap-7IOLANZJ.js → construction-bootstrap-SHGJLW3H.js} +1 -1
  44. package/dist/chunks/dist-OZQCZUII.js +2 -0
  45. package/dist/chunks/{dist-PRXAZ2CP.js → dist-YNYHK6HX.js} +1 -1
  46. package/dist/chunks/host-Q4CZDQFX.js +2 -0
  47. package/dist/chunks/model-6WXAASYQ.js +2 -0
  48. package/dist/chunks/readline-helpers-ACZ24UPE.js +2 -0
  49. package/dist/chunks/run-manager-2FHS7A5M.js +2 -0
  50. package/dist/chunks/running-session-JUSIVRWI.js +2 -0
  51. package/dist/chunks/{skills-BVDF6ICD.js → skills-I4D7CLUH.js} +1 -1
  52. package/dist/chunks/tool-dispatch-AJ7U2PQX.js +2 -0
  53. package/dist/chunks/utils-B4GWG4UV.js +2 -0
  54. package/dist/index.d.ts +20 -19
  55. package/dist/index.js +2 -2
  56. package/dist/kodax_bootstrap.js +2 -2
  57. package/dist/kodax_cli.js +1642 -1602
  58. package/dist/native/win32-x64/kodax-windows-sandbox.exe +0 -0
  59. package/dist/native/win32-x64/kodax-windows-text-transaction.node +0 -0
  60. package/dist/native/win32-x64/manifest.json +2 -2
  61. package/dist/provider-capabilities.json +337 -29
  62. package/dist/sandbox-network-broker.js +20 -20
  63. package/dist/script-cell.js +8 -0
  64. package/dist/script-worker.cjs +2166 -0
  65. package/dist/sdk-a2a.d.ts +15 -14
  66. package/dist/sdk-a2a.js +1 -1
  67. package/dist/sdk-agent.d.ts +15 -14
  68. package/dist/sdk-agent.js +1 -1
  69. package/dist/sdk-client.d.ts +8 -7
  70. package/dist/sdk-client.js +1 -1
  71. package/dist/sdk-coding.d.ts +29 -26
  72. package/dist/sdk-coding.js +1 -1
  73. package/dist/sdk-experimental-memory.d.ts +2 -2
  74. package/dist/sdk-experimental-memory.js +1 -1
  75. package/dist/sdk-llm.d.ts +1 -1
  76. package/dist/sdk-llm.js +1 -1
  77. package/dist/sdk-mcp.js +1 -1
  78. package/dist/sdk-media.js +1 -1
  79. package/dist/sdk-repl.d.ts +20 -29
  80. package/dist/sdk-repl.js +1 -1
  81. package/dist/sdk-runtime.d.ts +19 -16
  82. package/dist/sdk-runtime.js +1 -1
  83. package/dist/sdk-sandbox.js +1 -1
  84. package/dist/sdk-session.d.ts +10 -9
  85. package/dist/sdk-session.js +1 -1
  86. package/dist/sdk-skills.d.ts +2 -2
  87. package/dist/sdk-skills.js +1 -1
  88. package/dist/semantic-worker.js +62 -62
  89. package/dist/types-chunks/{bash-prefix-extractor.d-kPZTBP3w.d.ts → bash-prefix-extractor.d-BDunA1bO.d.ts} +36 -10
  90. package/dist/types-chunks/{capsule.d-C4BqofHf.d.ts → capsule.d-CWeFKL2e.d.ts} +4 -4
  91. package/dist/types-chunks/{client-contract-DxM_ECLG.d.ts → client-contract-CenyRbib.d.ts} +13 -4
  92. package/dist/types-chunks/{controller.d-Yz_UYWlp.d.ts → controller.d-BFi6Gc2Q.d.ts} +6 -2
  93. package/dist/types-chunks/{controller.d-Bcq7YlmN.d.ts → controller.d-Bs6MEu9T.d.ts} +1 -1
  94. package/dist/types-chunks/{history-retrieval.d-B08_0bke.d.ts → history-retrieval.d-nDle7ZMT.d.ts} +1 -1
  95. package/dist/types-chunks/{manifest.d-DnyVWNj9.d.ts → manifest.d-BM3wjQP3.d.ts} +1 -1
  96. package/dist/types-chunks/{provider-request-observation.d-B0F_IbaY.d.ts → provider-request-observation.d-DCimKZJv.d.ts} +2 -0
  97. package/dist/types-chunks/{public-api.d-Dd3WaHfO.d.ts → public-api.d-BqfXQREc.d.ts} +11 -6
  98. package/dist/types-chunks/{review-inbox.d-OHgSbiVU.d.ts → review-inbox.d-CBWZZaKk.d.ts} +2 -0
  99. package/dist/types-chunks/{review-packet.d-CgM1gO0P.d.ts → review-packet.d-DJ4cvofA.d.ts} +1 -1
  100. package/dist/types-chunks/{run-manager.d-DXcb6wIj.d.ts → run-manager.d-C7orI9Dw.d.ts} +5 -5
  101. package/dist/types-chunks/{runtime-client-info-DAYAaZ1K.d.ts → runtime-client-info-vWqPfxSv.d.ts} +2 -2
  102. package/dist/types-chunks/{sdk-session-Afj25p4w.d.ts → sdk-session-B-qxkrFY.d.ts} +13 -4
  103. package/dist/types-chunks/{sdk-skills-B4GGbMKo.d.ts → sdk-skills-C-UA1A6I.d.ts} +1 -1
  104. package/dist/types-chunks/{skill-invocation-error.d-BvYlTGif.d.ts → skill-invocation-error.d-Dr9SQHBj.d.ts} +5 -2
  105. package/dist/types-chunks/task-results.d-sGVm9DYX.d.ts +15 -0
  106. package/dist/types-chunks/{trusted-repl-entry-g5xfF23W.d.ts → trusted-repl-entry-CSO88d7v.d.ts} +7 -7
  107. package/dist/types-chunks/{types.d-mJVrC5yx.d.ts → types.d-C1Nptcqo.d.ts} +1 -1
  108. package/dist/types-chunks/{types.d-DqU20am8.d.ts → types.d-D8qQjMeo.d.ts} +2 -0
  109. package/dist/types-chunks/{utils.d-DSRo6pF4.d.ts → utils.d-hrtd99Wk.d.ts} +8 -6
  110. package/docs/CLIENT_CONTRACT.md +50 -2
  111. package/docs/SDK_MIGRATION.md +40 -1
  112. package/docs/SPACE_SDK_SEAMS.md +36 -1
  113. package/package.json +3 -2
  114. package/public_docs/README.md +9 -2
  115. package/public_docs/configuration/config-files.md +6 -0
  116. package/public_docs/configuration/providers.md +135 -3
  117. package/public_docs/configuration/sandbox.md +8 -0
  118. package/public_docs/getting-started/quickstart.md +10 -1
  119. package/public_docs/sdk/embedder-guide.md +125 -6
  120. package/dist/chunks/agent-2J37XQUU.js +0 -2
  121. package/dist/chunks/agent-adapter-ML7HCV4S.js +0 -2
  122. package/dist/chunks/argument-completer-T6NGMA6R.js +0 -2
  123. package/dist/chunks/chunk-BSOJXVSX.js +0 -498
  124. package/dist/chunks/chunk-BWXSYAUF.js +0 -12
  125. package/dist/chunks/chunk-CS2UXANP.js +0 -351
  126. package/dist/chunks/chunk-EV2DZBK6.js +0 -137
  127. package/dist/chunks/chunk-GBK65DAI.js +0 -350
  128. package/dist/chunks/chunk-IPOGKX27.js +0 -5
  129. package/dist/chunks/chunk-NIHDPG75.js +0 -433
  130. package/dist/chunks/chunk-QJHVTRAD.js +0 -29
  131. package/dist/chunks/chunk-VSXERQFQ.js +0 -403
  132. package/dist/chunks/compaction-config-FT7Q5JT6.js +0 -2
  133. package/dist/chunks/dist-JKLYAJPW.js +0 -2
  134. package/dist/chunks/host-COGFHKXD.js +0 -2
  135. package/dist/chunks/readline-helpers-G4UCRJHD.js +0 -2
  136. package/dist/chunks/run-manager-4YSPGN2D.js +0 -2
  137. package/dist/chunks/running-session-KBTXEY6Y.js +0 -2
  138. package/dist/chunks/tool-dispatch-D6RY2WRO.js +0 -2
  139. package/dist/chunks/utils-CIK3GTTG.js +0 -2
package/CHANGELOG.md CHANGED
@@ -8,6 +8,67 @@ All notable changes to this project will be documented in this file.
8
8
 
9
9
  ---
10
10
 
11
+ ## [0.7.97-alpha.11] - 2026-10-29
12
+
13
+ ### Added
14
+
15
+ - Add explicit Agent, Coding and experimental Script work modes through the
16
+ CLI, interactive `/work-mode` command and managed SDK/Session paths. Coding
17
+ remains the default. Script executes supported leaf tools through the existing
18
+ permission and receipt boundaries; SDK profiles and specialist agents retain
19
+ their declared capabilities.
20
+
21
+ - Refresh Ark, MiMo and MiniMax model catalogs and their reasoning/capacity
22
+ metadata. Provider-specific mappings and validation limits are documented in
23
+ the provider configuration guide.
24
+
25
+ ### Fixed
26
+
27
+ - Run release builds alongside full CI while retaining all publication gates;
28
+ move the complete serial Node 20 system suite to its own runner, validate
29
+ archives before lengthy Electron checks, and bound bundle/archive execution
30
+ with retained failure evidence. Ordinary branch pushes still do not trigger CI.
31
+ - Preserve the Windows PowerShell module search path in isolated archive tests,
32
+ avoiding stalled OS containment probes. Reject unverified supervised Hosts
33
+ before publishing incomplete capabilities and a misleading upgrade error.
34
+
35
+ - Align current SDK, Client, design and user documentation with post-alpha.10
36
+ work modes, question deadlines, saved tool originals, structured task reports
37
+ and streaming token estimates; retain historical release/validation limits.
38
+
39
+ - Preserve non-interactive question outcomes through the REPL client and reject
40
+ client-supplied timeout answers before daemon submission; the Host owns deadlines.
41
+ - Constrain Skill `Bash(pattern)` rules to a single parsed command, preventing
42
+ wildcard matches from admitting additional shell statements, pipelines,
43
+ redirects or command substitutions. Bare Bash and absent Skill restrictions
44
+ continue through normal Host authorization.
45
+ - Correct Windows stale-process recovery startup overhead and history browsing
46
+ cursor resynchronization; validate sandbox filesystem capabilities at startup.
47
+ Historical intermittent first-read latency remains under investigation.
48
+ - Display estimated tokens consistently across model streaming progress surfaces.
49
+
50
+ - Project existing task-result metadata into Product live views and recovered
51
+ history with explicit source, task identity, terminal/unknown status and
52
+ Markdown report bodies. Preserve multi-report order, literal report content,
53
+ existing full-body reads and raw canonical envelopes; decode only explicitly
54
+ sourced legacy deliveries and keep child failures separate from root Provider
55
+ errors. Deduplicate only identified task-message mirrors; preserve independent
56
+ same-text notices and ambiguous old UI records during history restoration.
57
+
58
+ - Keep Skill discovery rooted at the repository when the SDK runs from a
59
+ subdirectory, synchronize catalogs with loader availability in SA/AMA, and
60
+ invalidate stale bodies across rediscovery and in-flight reads. Model loads
61
+ now apply the existing Skill action policies, lifecycle hooks and model
62
+ preference, retaining Host authorization and safe multi-Skill composition.
63
+
64
+ - Preserve complete MCP tool output behind explicit SDK `part: 'original'`
65
+ reads, including daemon IPC and Host restart, while retaining existing preview
66
+ offsets. Keep results inline when recovery cannot be read, improve long JSON
67
+ previews, and stop Session-local automatic cleanup from deleting shared output
68
+ artifacts. Add simulated-provider/MCP E2E coverage against the built SDK.
69
+
70
+ ---
71
+
11
72
  ## [0.7.97-alpha.10] - 2026-10-27
12
73
 
13
74
  Tenth alpha of the v0.7.97 line: live context-capacity recovery reaches
@@ -58,6 +119,10 @@ remains a manual maintainer action.
58
119
  back a failed save acknowledgement before retrying, preserving newer metadata
59
120
  and avoiding duplicate history transactions; permission failures still surface.
60
121
 
122
+ - Keep the natural-eval fixture's `npm test` working on staged Node installs by
123
+ allowing reads of an npm CLI installed outside the binary directory, and
124
+ canonicalize the native test fixture root so hosted-runner 8.3 temp paths
125
+ (`RUNNER~1`) are not rejected by the native path policy.
61
126
  - Keep eval dump directories and unrelated `kodax-eval-*` directories out of orphan
62
127
  worktree cleanup. Require a worktree gitfile and successful Git-owned removal;
63
128
  isolate the cleanup regression from the shared system temporary directory.
package/README.md CHANGED
@@ -36,6 +36,18 @@
36
36
 
37
37
  ---
38
38
 
39
+ ## Current development after alpha.10
40
+
41
+ The unreleased source adds Agent / Coding / experimental Script work modes,
42
+ with Coding as the default. Select them with `--work-mode`, `/work-mode`, or
43
+ Product Client Session `workMode`; this is independent of permissions and model
44
+ choice. SDK/Host paths now share the corresponding settings, question outcomes,
45
+ saved original tool reads, structured task reports and estimated-token progress.
46
+ See the [SDK alignment and migration checklist](docs/SDK_MIGRATION.md#2026-10-29-未发布改动对齐)
47
+ and [English integration guide](public_docs/sdk/embedder-guide.md#post-alpha10-sdk-alignment).
48
+ These source additions shipped in the `v0.7.97-alpha.11` tag. Issue 371's
49
+ historical first-read latency and Script model-efficiency acceptance remain open.
50
+
39
51
  ## Install in 30 seconds
40
52
 
41
53
  ```bash
@@ -795,6 +807,23 @@ starts, upgrades, or waits. See
795
807
  Every v0.7.96 stable and v0.7.97-alpha.1/alpha.2/alpha.3 contract is
796
808
  retained.
797
809
 
810
+ **v0.7.97-alpha.11 release:** Explicit Agent, Coding and experimental Script
811
+ work modes land through the CLI, `/work-mode` and managed SDK/Session paths —
812
+ Coding stays the default and Script runs supported leaf tools through the
813
+ existing permission and receipt boundaries. Ark, MiMo and MiniMax catalogs
814
+ refresh their reasoning and capacity metadata; non-interactive question
815
+ outcomes are preserved with Host-owned deadlines; Skill `Bash(pattern)` rules
816
+ admit a single parsed command; MCP tool originals stay readable through
817
+ `part: 'original'` across daemon IPC and Host restart; structured task reports
818
+ project into Product live views and recovered history; streaming progress
819
+ shows consistent estimated tokens; Windows stale-process recovery and
820
+ history-browsing cursor resync are corrected and sandbox filesystem
821
+ capabilities are validated at startup. Tagging and publication remain
822
+ separate. See the
823
+ [v0.7.97-alpha.11 release notes](docs/release.md#v0797-alpha11-release-preparation).
824
+ Every v0.7.96 stable and v0.7.97-alpha.1 through alpha.10 contract is
825
+ retained.
826
+
798
827
  **v0.7.97-alpha.10 release:** Checkpointed Runs and task trees resume after
799
828
  Host restart with fresh scoped authority on top of durable context-capacity
800
829
  recovery boundaries; Kimi K3.1 provider routes join the registry with all
@@ -1544,7 +1573,7 @@ KodaX has two layers that consumers should understand separately:
1544
1573
 
1545
1574
  **Inline Workflow Authoring (FEATURE_246, v0.7.58; F270 update in v0.7.72)**: the Worker can author and run a workflow inline via the model-callable `run_workflow` tool when Workflow intent is explicit. It scouts the codebase first, bakes concrete findings into child prompts, and runs the script through the sandbox, static-validation, and postcondition-verification pipeline. F270 retires AMAW and complexity-driven activation; AMA keeps explicit `/workflow`, named/SDK, and natural-language Workflow requests. Workflow child Agents now run on the unified Actor control plane. See [docs/features/v0.7.58.md](docs/features/v0.7.58.md), [docs/features/v0.7.72.md](docs/features/v0.7.72.md), and ADR-044/046/047/048/049/055.
1546
1575
 
1547
- **Historical Workflow Activation Tiers (FEATURE_248 + FEATURE_249, v0.7.59; superseded by F270 in v0.7.72)**: v0.7.59 introduced AMAW and explicit-request AMA behavior. F270 retires AMAW and its complexity-driven directive. SA remains solo; AMA is the single adaptive multi-Agent mode and activates Workflow only from explicit Workflow intent. See [docs/features/v0.7.59.md](docs/features/v0.7.59.md) and [docs/features/v0.7.72.md](docs/features/v0.7.72.md).
1576
+ **Historical Workflow Activation Tiers (FEATURE_248 + FEATURE_249, v0.7.59; superseded by F270 in v0.7.72)**: v0.7.59 introduced AMAW and explicit-request AMA behavior. F270 retires AMAW and its complexity-driven directive. CLI and REPL tasks use AMA; explicit SDK SA selection and the internal solo executor remain compatible. AMA is the single adaptive multi-Agent mode and activates Workflow only from explicit Workflow intent. See [docs/features/v0.7.59.md](docs/features/v0.7.59.md) and [docs/features/v0.7.72.md](docs/features/v0.7.72.md).
1548
1577
 
1549
1578
  **Progressive Disclosure on the Managed Tool Path (FEATURE_250, v0.7.60; current policy corrected in v0.7.74)**: the deferred-tool mechanism applies to the managed AMA path as well as SA. The current deferred set contains exactly 11 tools: six repo-intelligence tools, four web/code discovery tools, and `run_workflow`. Their `input_schema` remains directly callable while `tool_search` provides the full description on demand. The five fixed `mcp_*` facades and the `get_goal` / `create_goal` / `update_goal` lifecycle tools stay resident with their complete contracts. The v0.7.74 goal correction adds only about 109 estimated schema tokens versus the former hints (`get_goal` is actually 12 tokens smaller when resident), removes a discovery round trip, and changes no tool schema, handler, permission, goal state, or compaction-protection behavior. See [docs/features/v0.7.60.md](docs/features/v0.7.60.md) and [docs/features/v0.7.74.md](docs/features/v0.7.74.md#feature_250-v0774-correction-resident-goal-lifecycle-tools).
1550
1579
 
@@ -2127,7 +2156,7 @@ This development tree exposes 17 SDK subpaths plus the root. Shared product
2127
2156
  applications use `@kodax-ai/kodax/client`; independent libraries and trusted Host
2128
2157
  APIs remain available through the other subpaths. See the [Client contract](docs/CLIENT_CONTRACT.md)
2129
2158
  and [SDK migration guide](docs/SDK_MIGRATION.md). This documentation was checked
2130
- against package version `0.7.97-alpha.10`; npm publication is separate from
2159
+ against package version `0.7.97-alpha.11`; npm publication is separate from
2131
2160
  the current development-tree contract.
2132
2161
 
2133
2162
  ```bash
@@ -2323,10 +2352,10 @@ await runInkInteractiveMode({ provider: 'zhipu-coding', effort: 'auto' });
2323
2352
  | zhipu | `ZHIPU_API_KEY` | Native | glm-5 (`glm-5.3` / `glm-5.2` 1M ctx, plus `glm-5.1` / `glm-5-turbo` via `/model`; GLM-5.3 is pre-registered while the public API remains marked upcoming) |
2324
2353
  | zhipu-coding | `ZHIPU_CODING_API_KEY` | Native | glm-5.3 (1M ctx, 128K output; `glm-5.2` rollback plus `glm-5-turbo` / `glm-4.7` via `/model`; raw upstream IDs) |
2325
2354
  | zai-coding | `ZAI_CODING_API_KEY` | Native | glm-5.3 (`glm-5.2` rollback; raw upstream IDs; switched from glm-5.2 default on 2026-08-15) |
2326
- | minimax-coding | `MINIMAX_CODING_API_KEY` | Native | MiniMax-M3 (Frontier Coding, native multimodal + 1M ctx; legacy `MiniMax-M2.7` / `MiniMax-M2.7-highspeed` remain selectable via `/model`) |
2327
- | mimo | `MIMO_API_KEY` | Native | mimo-v2.5-pro (Xiaomi MiMo pay-per-token, Anthropic-compat) |
2328
- | mimo-coding | `MIMO_CODING_API_KEY` | Native | mimo-v2.5-pro (Xiaomi Token Plan, Anthropic-compat) |
2329
- | ark-coding | `ARK_CODING_API_KEY` | Native | glm-5.3 (Volcengine Ark Coding Plan — GLM-5.3 (1M ctx, 128K out) · GLM-5.2 (alias: `glm-latest`) · Kimi K2.7 Code / K2.6 · MiniMax M3 / M2.7 · DeepSeek V4 Pro / V4 Flash · Doubao Seed 2.0 Code / Pro / Lite · Doubao Seed Code) |
2355
+ | minimax-coding | `MINIMAX_CODING_API_KEY` | Native | MiniMax-M3.1-Flash (M Plan, 1M ctx, five effort levels; always-on thinking) |
2356
+ | mimo | `MIMO_API_KEY` | Native | mimo-v2.6-pro (Xiaomi MiMo pay-per-token; V2.6 Flash also selectable) |
2357
+ | mimo-coding | `MIMO_CODING_API_KEY` | Native | mimo-v2.6-pro (Xiaomi Token Plan; V2.6 Flash also selectable, image input, thinking on/off) |
2358
+ | ark-coding | `ARK_CODING_API_KEY` | Native | glm-5.3 (Ark Coding Plan; new `deepseek-v4.1-flash` / `deepseek-v4.1-flash-economy`, `glm-5.3-flash`, `kimi-k3.1-pro` / `kimi-k3` / `kimi-k2.8-preview`; all six accept images; previous configured IDs retained) |
2330
2359
  | deepseek | `DEEPSEEK_API_KEY` | Native | deepseek-flash (Anthropic-compat; DeepSeek-V4.1-Flash, 1M ctx, native image input; legacy text-only `deepseek-v4-pro`, via `/model`) |
2331
2360
  | gemini-cli | Provider CLI authentication (no KodaX API-key variable) | Prompt-only / CLI bridge | (via gemini CLI) |
2332
2361
  | codex-cli | Provider CLI authentication (no KodaX API-key variable) | Prompt-only / CLI bridge | (via codex CLI) |
@@ -2353,7 +2382,7 @@ kodax --session list
2353
2382
  kodax --parallel "Read package.json and tsconfig.json"
2354
2383
 
2355
2384
  # Adaptive multi-agent (AMA) mode — V2 Worker single-loop with Actor collaboration
2356
- kodax --agent-mode ama "Analyze code structure, check test coverage, find bugs"
2385
+ kodax "Analyze code structure, check test coverage, find bugs"
2357
2386
  ```
2358
2387
 
2359
2388
  ---
package/README_CN.md CHANGED
@@ -36,6 +36,16 @@
36
36
 
37
37
  ---
38
38
 
39
+ ## alpha.10 之后的当前开发
40
+
41
+ 未发布源码新增 Agent / Coding / 实验性 Script 工作模式,默认 Coding。
42
+ CLI 使用 `--work-mode`,REPL 使用 `/work-mode`,Product Client 使用 Session
43
+ `workMode`;它与权限、模型选择独立。SDK/Host 的相关设置、问题结算、工具原文读取、
44
+ 结构化任务报告和 token 估算进度已接入对应契约,见
45
+ [SDK 一致性与迁移清单](docs/SDK_MIGRATION.md#2026-10-29-未发布改动对齐)。
46
+ 这些源码变更已随 `v0.7.97-alpha.11` 标签发布。
47
+ Issue 371 的历史首次读取延迟及 Script 模型效率验收仍未关闭。
48
+
39
49
  ## 30 秒上手
40
50
 
41
51
  ```bash
@@ -314,6 +324,17 @@ SDK 系统代码契约更新,但没有放宽 shell/sandbox 的 fail-closed 边
314
324
  [v0.7.97-alpha.4 发布清单](docs/release.md#v0797-alpha4-release-preparation)。
315
325
  所有 v0.7.96 稳定与 v0.7.97-alpha.1/alpha.2/alpha.3 契约全部保留。
316
326
 
327
+ **v0.7.97-alpha.11 发布**:显式 Agent、Coding 与实验性 Script 工作模式通过
328
+ CLI、`/work-mode` 与托管 SDK/Session 路径落地——Coding 保持默认,Script 在既有
329
+ 权限与回执边界内执行受支持的叶子工具。Ark、MiMo、MiniMax 目录刷新推理与容量
330
+ 元数据;非交互问题结算保留结果且截止期限由 Host 掌握;Skill `Bash(pattern)`
331
+ 规则仅放行单条解析命令;MCP 工具原文经 `part: 'original'` 跨 daemon IPC 与
332
+ Host 重启可读;结构化任务报告投影到 Product 视图与恢复历史;流式进度统一以
333
+ token 估算展示;修正 Windows 陈旧进程恢复与历史浏览游标重同步,启动时校验
334
+ 沙箱文件系统能力。代码提交、版本标签与实际发布分别判断。
335
+ 详见 [v0.7.97-alpha.11 发布清单](docs/release.md#v0797-alpha11-release-preparation)。
336
+ 所有 v0.7.96 稳定与 v0.7.97-alpha.1 至 alpha.10 契约全部保留。
337
+
317
338
  **v0.7.97-alpha.10 发布**:Host 重启后可恢复检查点 Run 与任务树(全新作用域
318
339
  授权);上下文容量恢复到达持久代边界;Kimi K3.1 供应商路由覆盖全部七档
319
340
  effort;AskUser 默认无限等待、支持显式跳过并返回带原因的 `unanswered` 结果。
@@ -1206,10 +1227,10 @@ dist/binary/linux-x64/
1206
1227
  | zhipu | `ZHIPU_API_KEY` | Native | glm-5(可 `/model` 切换 `glm-5.3` / `glm-5.2`,均为 1M ctx,另有 `glm-5.1` / `glm-5-turbo`;GLM-5.3 开放平台 API 仍标注为即将上线) |
1207
1228
  | zhipu-coding | `ZHIPU_CODING_API_KEY` | Native | glm-5.3(1M ctx、128K 最大输出;可回退到 `glm-5.2`,也可切换 `glm-5-turbo` / `glm-4.7`;原样发送上游 ID) |
1208
1229
  | zai-coding | `ZAI_CODING_API_KEY` | Native | glm-5.3(保留 `glm-5.2` 回退;原样发送上游 ID;2026-08-15 起默认从 glm-5.2 切换) |
1209
- | minimax-coding | `MINIMAX_CODING_API_KEY` | Native | MiniMax-M3(Frontier Coding,原生多模态 + 1M ctx;仍可通过 `/model` 显式选择兼容模型 `MiniMax-M2.7` / `MiniMax-M2.7-highspeed`) |
1210
- | mimo | `MIMO_API_KEY` | Native | mimo-v2.5-pro(小米 MiMo 按量计费,Anthropic 协议) |
1211
- | mimo-coding | `MIMO_CODING_API_KEY` | Native | mimo-v2.5-pro(小米 MiMo Token Plan,Anthropic 协议) |
1212
- | ark-coding | `ARK_CODING_API_KEY` | Native | glm-5.3(火山方舟 Coding Plan — GLM-5.3(1M ctx、128K out) · GLM-5.2(别名 `glm-latest`) · Kimi K2.7 Code / K2.6 · MiniMax M3 / M2.7 · DeepSeek V4 Pro / V4 Flash · Doubao Seed 2.0 Code / Pro / Lite · Doubao Seed Code) |
1230
+ | minimax-coding | `MINIMAX_CODING_API_KEY` | Native | MiniMax-M3.1-Flash(M Plan,1M 上下文,原生五档推理,思考始终开启) |
1231
+ | mimo | `MIMO_API_KEY` | Native | mimo-v2.6-pro(小米 MiMo 按量计费,也可选 V2.6 Flash) |
1232
+ | mimo-coding | `MIMO_CODING_API_KEY` | Native | mimo-v2.6-pro(小米 MiMo Token Plan,也可选 V2.6 Flash;支持图片、思考开关) |
1233
+ | ark-coding | `ARK_CODING_API_KEY` | Native | glm-5.3(方舟 Coding Plan;新增 `deepseek-v4.1-flash` / `deepseek-v4.1-flash-economy`、`glm-5.3-flash`、`kimi-k3.1-pro` / `kimi-k3` / `kimi-k2.8-preview`;六款均支持图片;保留历史配置 ID) |
1213
1234
  | deepseek | `DEEPSEEK_API_KEY` | Native | deepseek-flash(Anthropic 协议;DeepSeek-V4.1-Flash,1M ctx,原生图片理解;可 `/model` 切换纯文本兼容名 `deepseek-v4-pro`) |
1214
1235
  | gemini-cli | 由 Provider CLI 完成认证(无 KodaX API-key 环境变量) | Prompt-only / CLI bridge | (通过 gemini CLI) |
1215
1236
  | codex-cli | 由 Provider CLI 完成认证(无 KodaX API-key 环境变量) | Prompt-only / CLI bridge | (通过 codex CLI) |
@@ -1468,7 +1489,7 @@ REPL 显示、唤醒或消费。
1468
1489
 
1469
1490
  **Inline workflow authoring(FEATURE_246,v0.7.58;F270 于 v0.7.72 更新)**:Worker 在明确表达 Workflow 意图时,可通过 model-callable 的 `run_workflow` 工具在会话内编写并运行工作流。F270 退役 AMAW 与复杂度驱动激活;AMA 保留显式 `/workflow`、named/SDK 和自然语言 Workflow 请求。Workflow 子 Agent 统一运行在 Actor 控制面。详见 [docs/features/v0.7.58.md](docs/features/v0.7.58.md)、[docs/features/v0.7.72.md](docs/features/v0.7.72.md) 与 ADR-044/046/047/048/049/055。
1470
1491
 
1471
- **历史工作流激活分层(FEATURE_248 + FEATURE_249,v0.7.59;F270 于 v0.7.72 取代)**:v0.7.59 引入 AMAW 和 AMA 的显式请求行为。F270 退役 AMAW 及其复杂度驱动指令;SA 保持单独作业,AMA 成为唯一自适应多 Agent 模式,并且只在明确 Workflow 意图下激活 Workflow。详见 [docs/features/v0.7.59.md](docs/features/v0.7.59.md) 与 [docs/features/v0.7.72.md](docs/features/v0.7.72.md)。
1492
+ **历史工作流激活分层(FEATURE_248 + FEATURE_249,v0.7.59;F270 于 v0.7.72 取代)**:v0.7.59 引入 AMAW 和 AMA 的显式请求行为。F270 退役 AMAW 及其复杂度驱动指令;CLI/REPL 使用 AMA;SDK 显式 SA 和内部单 Agent 执行器继续兼容。AMA 是唯一自适应多 Agent 模式,并且只在明确 Workflow 意图下激活 Workflow。详见 [docs/features/v0.7.59.md](docs/features/v0.7.59.md) 与 [docs/features/v0.7.72.md](docs/features/v0.7.72.md)。
1472
1493
 
1473
1494
  **managed 工具路径的渐进披露(FEATURE_250,v0.7.60;当前策略于 v0.7.74 纠偏)**:deferred-tool 机制同时应用于 AMA managed path 与 SA。当前延迟集合精确包含 11 个工具:6 个 repo-intelligence、4 个 web/code discovery,以及 `run_workflow`;其 `input_schema` 仍可直接调用,完整描述按需由 `tool_search` 返回。5 个固定 `mcp_*` facade 与 `get_goal` / `create_goal` / `update_goal` 生命周期工具常驻完整契约。v0.7.74 的 Goal 纠偏相对旧 hint 仅增加约 109 个估算 schema token(其中常驻的 `get_goal` 反而少 12 token),消除一次发现往返,并且不改变工具 schema、handler、权限、Goal 状态或压缩保护。详见 [docs/features/v0.7.60.md](docs/features/v0.7.60.md) 与 [docs/features/v0.7.74.md](docs/features/v0.7.74.md#feature_250-v0774-correction-resident-goal-lifecycle-tools)。
1474
1495
 
@@ -22,14 +22,13 @@
22
22
  // "reasoningMode": "auto",
23
23
  // "thinking": true,
24
24
 
25
- // Agent harness: "ama" enables adaptive multi-agent use; "sa" forces one
26
- // agent. Permission profiles are "plan", "accept-edits", sandbox-first
25
+ // New product tasks use AMA with adaptive multi-agent use.
26
+ // Permission profiles are "plan", "accept-edits", sandbox-first
27
27
  // "auto", or direct-host "full-access". Full Access has no sandbox or
28
28
  // approval prompts; built-in dangerous-command fallbacks do not apply.
29
29
  // Explicit forbidden rules still block; explicit prompt rules cannot prompt.
30
30
  // Exec Policy is separate:
31
31
  // ~/.kodax/exec-policy.jsonc (and explicitly trusted project policy).
32
- // "agentMode": "ama",
33
32
  // "permissionMode": "accept-edits",
34
33
  // User-level Bash allow patterns. Project additions belong in
35
34
  // <project>/.kodax/config.local.json. Broad Bash(*) is rejected.
@@ -0,0 +1,2 @@
1
+ // @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
2
+ import{Ab as i,Bb as j,Ca as d,Da as e,Ea as f,Hb as k,cb as g,eb as h}from"./chunk-HKN6ZIXI.js";import"./chunk-NMRBY4TS.js";import{a as c}from"./chunk-N2MPJVHA.js";import"./chunk-NBKSCESR.js";import"./chunk-EGVAVI6U.js";import"./chunk-KI3TUCEE.js";import"./chunk-USAJGDW3.js";import"./chunk-ULA453FO.js";import"./chunk-DOO4VVA5.js";import"./chunk-HFJ2KSHV.js";import"./chunk-MZ44IR3J.js";import"./chunk-W5LXBBFR.js";import{Ab as a,Bb as b}from"./chunk-UFWK2OOJ.js";import"./chunk-VA5GQNHW.js";import"./chunk-DOKPC4RS.js";import"./chunk-7PBG4SST.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{a,b}from"./chunk-6Z63HHR2.js";import"./chunk-USAJGDW3.js";import"./chunk-ULA453FO.js";import"./chunk-DOO4VVA5.js";import"./chunk-MZ44IR3J.js";import"./chunk-UFWK2OOJ.js";import"./chunk-VA5GQNHW.js";import"./chunk-DOKPC4RS.js";import"./chunk-7PBG4SST.js";import"./chunk-ONUPGMER.js";export{b as createCodingWorkflowBackend,a as resumeWorkflowGenerationTurn};
@@ -0,0 +1,2 @@
1
+ // @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
2
+ import{Za as a,_a as b}from"./chunk-CFGJS457.js";import"./chunk-ZQYWDI4O.js";import"./chunk-22UAAJCB.js";import"./chunk-E2ZROK4I.js";import"./chunk-LXSXL4DB.js";import"./chunk-4MZEUECQ.js";import"./chunk-IL5AAIGK.js";import"./chunk-HKN6ZIXI.js";import"./chunk-NMRBY4TS.js";import"./chunk-N2MPJVHA.js";import"./chunk-76UPX4CI.js";import"./chunk-NBKSCESR.js";import"./chunk-EGVAVI6U.js";import"./chunk-KI3TUCEE.js";import"./chunk-6Z63HHR2.js";import"./chunk-USAJGDW3.js";import"./chunk-ULA453FO.js";import"./chunk-DOO4VVA5.js";import"./chunk-HFJ2KSHV.js";import"./chunk-MZ44IR3J.js";import"./chunk-W5LXBBFR.js";import"./chunk-UFWK2OOJ.js";import"./chunk-VA5GQNHW.js";import"./chunk-DOKPC4RS.js";import"./chunk-7PBG4SST.js";import"./chunk-ONUPGMER.js";export{a as ArgumentCompleter,b as createArgumentCompleter};
@@ -0,0 +1,2 @@
1
+ // @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
2
+ import{a,b,c}from"./chunk-W5LXBBFR.js";import"./chunk-ONUPGMER.js";export{c as resolveScriptWorkerUrl,b as runScriptCell,a as validateScriptCell};
@@ -1,5 +1,5 @@
1
1
  // @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
2
- import{ka as Me,ma as _e}from"./chunk-VSXERQFQ.js";import{Ka as Se}from"./chunk-FSV2UNZK.js";import{e as ke,j as Ce}from"./chunk-U7XIL752.js";import{H as me,Ma as ge,Na as ve,Oa as ye,Pa as we,Qa as xe,Ra as Y,T as z,W as B,X as he,Y as J,Ya as Ee,Za as R,bb as Q,mb as be,rb as Pe}from"./chunk-EV2DZBK6.js";import{a as r}from"./chunk-ONUPGMER.js";import m from"fs";import h from"path";import{exec as wt,spawnSync as xt}from"child_process";import{promisify as Et}from"util";import{fileURLToPath as bt}from"url";var Z="en";function Ye(){return(process.env.LC_ALL||process.env.LC_MESSAGES||process.env.LANG||"").toLowerCase().startsWith("zh")?"zh":"en"}r(Ye,"detectSystemLocale");function Oe(e){if(!e||e==="auto"){Z=Ye();return}Z=e.toLowerCase().replace(/[-_].*/,"")==="zh"?"zh":"en"}r(Oe,"setLocale");var Ae={en:{"dialog.confirm":"[Confirm]","dialog.select":"[Select]","dialog.input":"[Input]","confirm.instruction.basic":"Press (y) yes, (n) no","confirm.instruction.always":"Press (y) yes, (a) always yes for this tool, (n) no","confirm.instruction.runtime_session":"Press (y) allow once, (s) allow this Runtime scope for the session, (n) no","confirm.instruction.runtime_persistent":"Press (y) allow once, (s) allow this Runtime scope for the session, (a) always allow this Runtime scope, (n) no","confirm.instruction.protected":"Press (y) to confirm, (n) to cancel (protected path)","confirm.result.approved":"Approved","confirm.result.approved_always":"Approved (always)","confirm.result.approved_session":"Approved (this session)","confirm.result.denied":"Denied","tool.bash.title":"Execute bash command?","tool.shell.title":"Execute shell command?","tool.write.title":"Write to file?","tool.edit.title":"Edit file?","tool.generic.title":"Execute {tool}?","field.reason":"Reason","field.intent":"Intent","field.target":"Target","field.scope":"Scope","field.risk":"Risk","field.summary":"Summary","intent.read":"Read project files","intent.delete":"Delete files","intent.deps":"Modify dependencies or environment","intent.modify":"Modify files","intent.execute":"Execute command","intent.write_file":"Write file","intent.edit_file":"Edit file","intent.use_tool":"Use {tool}","risk.destructive":"Destructive change","risk.deps":"May change dependencies or local tools","risk.modify":"May modify files","risk.unknown":"Command effects depend on its arguments","risk.network":"May access network","scope.outside":"Outside project","scope.protected":"Protected path","waiting.confirm":"Waiting: approval required","waiting.select":"Waiting: choose an option","waiting.input":"Waiting: answer the prompt","placeholder.confirm":"Respond to the approval prompt above...","placeholder.select":"Choose an option above...","placeholder.input":"Answer the prompt above...","placeholder.busy":"Agent is busy...","placeholder.queue":"Queue a follow-up for the next round...","placeholder.idle":"Type a message...","select.choice":"Choice:","select.type_number":"(type a number)","select.more":"{count} more choices...","select.more_above":"\u2191 {count} more above","select.more_below":"\u2193 {count} more below","select.confirm_hint":"Press Enter to confirm, Esc to cancel","select.navigate_hint":"Use \u2191\u2193 to navigate, Enter to confirm, Esc to cancel","select.multiselect_hint":"Use \u2191\u2193 to navigate, Space to toggle, Enter to confirm, Esc to cancel","select.multiselect_empty":"Select at least one option with Space before confirming.","select.multiselect_min":"Select at least {min} option(s) with Space before confirming.","select.multiselect_max":"Select at most {max} option(s) with Space before confirming.","select.back_prev":"\u2190 Back to previous question","input.default":"Default:","input.value":"Value:","input.type_response":"(type your response)","managed.completed":"Task completed","managed.completed.blocked":"Task blocked","managed.completed.continuation":"Task needs continuation","todo.progress":"{completed}/{total} completed","todo.transcript.progress":"Plan {completed}/{total} completed","todo.summary.done":"{count} done","todo.summary.more":"+{count} more",cancelled:"[Cancelled] Operation cancelled by user",cancellationRequested:"[Cancelling] Stop requested for the current reply",cancellationAccepted:"Stop request accepted; waiting for execution to settle.",cancellationConfirmed:"Stop confirmed:",cancellationRejected:"Stop request failed:"},zh:{"dialog.confirm":"[\u786E\u8BA4]","dialog.select":"[\u9009\u62E9]","dialog.input":"[\u8F93\u5165]","confirm.instruction.basic":"\u6309 (y) \u786E\u8BA4, (n) \u62D2\u7EDD","confirm.instruction.always":"\u6309 (y) \u786E\u8BA4, (a) \u59CB\u7EC8\u5141\u8BB8\u6B64\u5DE5\u5177, (n) \u62D2\u7EDD","confirm.instruction.runtime_session":"\u6309 (y) \u4EC5\u5141\u8BB8\u4E00\u6B21, (s) \u672C\u4F1A\u8BDD\u59CB\u7EC8\u5141\u8BB8\u8FD9\u9879\u7CBE\u786E\u64CD\u4F5C, (n) \u62D2\u7EDD","confirm.instruction.runtime_persistent":"\u6309 (y) \u4EC5\u5141\u8BB8\u4E00\u6B21, (s) \u672C\u4F1A\u8BDD\u59CB\u7EC8\u5141\u8BB8\u8FD9\u9879\u7CBE\u786E\u64CD\u4F5C, (a) \u59CB\u7EC8\u5141\u8BB8\u8FD9\u9879\u7CBE\u786E\u64CD\u4F5C, (n) \u62D2\u7EDD","confirm.instruction.protected":"\u6309 (y) \u786E\u8BA4, (n) \u53D6\u6D88 (\u53D7\u4FDD\u62A4\u8DEF\u5F84)","confirm.result.approved":"\u5DF2\u6279\u51C6","confirm.result.approved_always":"\u5DF2\u6279\u51C6 (\u59CB\u7EC8\u5141\u8BB8)","confirm.result.approved_session":"\u5DF2\u6279\u51C6 (\u672C\u4F1A\u8BDD)","confirm.result.denied":"\u5DF2\u62D2\u7EDD","tool.bash.title":"\u6267\u884C bash \u547D\u4EE4\uFF1F","tool.shell.title":"\u6267\u884C shell \u547D\u4EE4\uFF1F","tool.write.title":"\u5199\u5165\u6587\u4EF6\uFF1F","tool.edit.title":"\u7F16\u8F91\u6587\u4EF6\uFF1F","tool.generic.title":"\u6267\u884C {tool}\uFF1F","field.reason":"\u539F\u56E0","field.intent":"\u610F\u56FE","field.target":"\u76EE\u6807","field.scope":"\u8303\u56F4","field.risk":"\u98CE\u9669","field.summary":"\u6458\u8981","intent.read":"\u8BFB\u53D6\u9879\u76EE\u6587\u4EF6","intent.delete":"\u5220\u9664\u6587\u4EF6","intent.deps":"\u4FEE\u6539\u4F9D\u8D56\u6216\u73AF\u5883","intent.modify":"\u4FEE\u6539\u6587\u4EF6","intent.execute":"\u6267\u884C\u547D\u4EE4","intent.write_file":"\u5199\u5165\u6587\u4EF6","intent.edit_file":"\u7F16\u8F91\u6587\u4EF6","intent.use_tool":"\u4F7F\u7528 {tool}","risk.destructive":"\u7834\u574F\u6027\u53D8\u66F4","risk.deps":"\u53EF\u80FD\u4FEE\u6539\u4F9D\u8D56\u6216\u672C\u5730\u5DE5\u5177","risk.modify":"\u53EF\u80FD\u4FEE\u6539\u6587\u4EF6","risk.unknown":"\u547D\u4EE4\u6548\u679C\u53D6\u51B3\u4E8E\u53C2\u6570","risk.network":"\u53EF\u80FD\u8BBF\u95EE\u7F51\u7EDC","scope.outside":"\u9879\u76EE\u5916\u90E8","scope.protected":"\u53D7\u4FDD\u62A4\u8DEF\u5F84","waiting.confirm":"\u7B49\u5F85\u4E2D\uFF1A\u9700\u8981\u5BA1\u6279","waiting.select":"\u7B49\u5F85\u4E2D\uFF1A\u8BF7\u9009\u62E9","waiting.input":"\u7B49\u5F85\u4E2D\uFF1A\u8BF7\u56DE\u7B54","placeholder.confirm":"\u8BF7\u56DE\u5E94\u4E0A\u65B9\u7684\u5BA1\u6279\u63D0\u793A...","placeholder.select":"\u8BF7\u5728\u4E0A\u65B9\u9009\u62E9\u4E00\u4E2A\u9009\u9879...","placeholder.input":"\u8BF7\u56DE\u7B54\u4E0A\u65B9\u7684\u63D0\u793A...","placeholder.busy":"\u667A\u80FD\u4F53\u6B63\u5728\u5DE5\u4F5C\u4E2D...","placeholder.queue":"\u6392\u961F\u7B49\u5F85\u4E0B\u4E00\u8F6E\u8DDF\u8FDB...","placeholder.idle":"\u8F93\u5165\u6D88\u606F...","select.choice":"\u9009\u9879\uFF1A","select.type_number":"(\u8F93\u5165\u7F16\u53F7)","select.more":"\u8FD8\u6709 {count} \u4E2A\u9009\u9879...","select.more_above":"\u2191 \u4E0A\u65B9\u8FD8\u6709 {count} \u4E2A","select.more_below":"\u2193 \u4E0B\u65B9\u8FD8\u6709 {count} \u4E2A","select.confirm_hint":"\u6309 Enter \u786E\u8BA4\uFF0CEsc \u53D6\u6D88","select.navigate_hint":"\u4F7F\u7528 \u2191\u2193 \u5BFC\u822A\uFF0CEnter \u786E\u8BA4\uFF0CEsc \u53D6\u6D88","select.multiselect_hint":"\u4F7F\u7528 \u2191\u2193 \u5BFC\u822A\uFF0C\u7A7A\u683C \u5207\u6362\u9009\u4E2D\uFF0CEnter \u786E\u8BA4\uFF0CEsc \u53D6\u6D88","select.multiselect_empty":"\u8BF7\u5148\u4F7F\u7528\u7A7A\u683C\u9009\u62E9\u81F3\u5C11\u4E00\u4E2A\u9009\u9879\u3002","select.multiselect_min":"\u8BF7\u5148\u4F7F\u7528\u7A7A\u683C\u81F3\u5C11\u9009\u62E9 {min} \u4E2A\u9009\u9879\u3002","select.multiselect_max":"\u6700\u591A\u53EA\u80FD\u9009\u62E9 {max} \u4E2A\u9009\u9879\u3002","select.back_prev":"\u2190 \u8FD4\u56DE\u4E0A\u4E00\u9898","input.default":"\u9ED8\u8BA4\u503C\uFF1A","input.value":"\u503C\uFF1A","input.type_response":"(\u8F93\u5165\u4F60\u7684\u56DE\u7B54)","managed.completed":"\u4EFB\u52A1\u5B8C\u6210","managed.completed.blocked":"\u4EFB\u52A1\u53D7\u963B","managed.completed.continuation":"\u4EFB\u52A1\u9700\u8981\u7EE7\u7EED","todo.progress":"{completed}/{total} \u5DF2\u5B8C\u6210","todo.transcript.progress":"\u8BA1\u5212 {completed}/{total} \u5DF2\u5B8C\u6210","todo.summary.done":"{count} \u9879\u5DF2\u5B8C\u6210","todo.summary.more":"\u53E6\u6709 {count} \u9879",cancelled:"[\u5DF2\u53D6\u6D88] \u64CD\u4F5C\u5DF2\u88AB\u7528\u6237\u53D6\u6D88",cancellationRequested:"[\u6B63\u5728\u53D6\u6D88] \u5DF2\u8BF7\u6C42\u505C\u6B62\u5F53\u524D\u56DE\u590D",cancellationAccepted:"\u505C\u6B62\u8BF7\u6C42\u5DF2\u63A5\u53D7\uFF0C\u6B63\u5728\u7B49\u5F85\u6267\u884C\u6536\u5C3E\u3002",cancellationConfirmed:"\u505C\u6B62\u5DF2\u786E\u8BA4\uFF1A",cancellationRejected:"\u505C\u6B62\u8BF7\u6C42\u5931\u8D25\uFF1A"}};function Bt(e,t){let o=Ae[Z][e]??Ae.en[e]??e;if(t)for(let[i,s]of Object.entries(t))o=o.replace(`{${i}}`,String(s));return o}r(Bt,"t");var Re={core:`// Split configs: ~/.kodax/integrations/mcp.json, extensions.json, and a2a.json.
2
+ import{ja as Me,la as _e}from"./chunk-HKN6ZIXI.js";import{Ka as Se}from"./chunk-UFWK2OOJ.js";import{e as ke,j as Ce}from"./chunk-VA5GQNHW.js";import{H as me,Ma as ge,Na as ve,Oa as ye,Pa as we,Qa as xe,Ra as Y,T as z,W as B,X as he,Y as J,Ya as Ee,Za as R,bb as Q,mb as be,rb as Pe}from"./chunk-7PBG4SST.js";import{a as r}from"./chunk-ONUPGMER.js";import m from"fs";import h from"path";import{exec as wt,spawnSync as xt}from"child_process";import{promisify as Et}from"util";import{fileURLToPath as bt}from"url";var Z="en";function Ye(){return(process.env.LC_ALL||process.env.LC_MESSAGES||process.env.LANG||"").toLowerCase().startsWith("zh")?"zh":"en"}r(Ye,"detectSystemLocale");function Oe(e){if(!e||e==="auto"){Z=Ye();return}Z=e.toLowerCase().replace(/[-_].*/,"")==="zh"?"zh":"en"}r(Oe,"setLocale");var Ae={en:{"dialog.confirm":"[Confirm]","dialog.select":"[Select]","dialog.input":"[Input]","confirm.instruction.basic":"Press (y) yes, (n) no","confirm.instruction.always":"Press (y) yes, (a) always yes for this tool, (n) no","confirm.instruction.runtime_session":"Press (y) allow once, (s) allow this Runtime scope for the session, (n) no","confirm.instruction.runtime_persistent":"Press (y) allow once, (s) allow this Runtime scope for the session, (a) always allow this Runtime scope, (n) no","confirm.instruction.protected":"Press (y) to confirm, (n) to cancel (protected path)","confirm.result.approved":"Approved","confirm.result.approved_always":"Approved (always)","confirm.result.approved_session":"Approved (this session)","confirm.result.denied":"Denied","tool.bash.title":"Execute bash command?","tool.shell.title":"Execute shell command?","tool.write.title":"Write to file?","tool.edit.title":"Edit file?","tool.generic.title":"Execute {tool}?","field.reason":"Reason","field.intent":"Intent","field.target":"Target","field.scope":"Scope","field.risk":"Risk","field.summary":"Summary","intent.read":"Read project files","intent.delete":"Delete files","intent.deps":"Modify dependencies or environment","intent.modify":"Modify files","intent.execute":"Execute command","intent.write_file":"Write file","intent.edit_file":"Edit file","intent.use_tool":"Use {tool}","risk.destructive":"Destructive change","risk.deps":"May change dependencies or local tools","risk.modify":"May modify files","risk.unknown":"Command effects depend on its arguments","risk.network":"May access network","scope.outside":"Outside project","scope.protected":"Protected path","waiting.confirm":"Waiting: approval required","waiting.select":"Waiting: choose an option","waiting.input":"Waiting: answer the prompt","placeholder.confirm":"Respond to the approval prompt above...","placeholder.select":"Choose an option above...","placeholder.input":"Answer the prompt above...","placeholder.busy":"Agent is busy...","placeholder.queue":"Queue a follow-up for the next round...","placeholder.idle":"Type a message...","select.choice":"Choice:","select.type_number":"(type a number)","select.more":"{count} more choices...","select.more_above":"\u2191 {count} more above","select.more_below":"\u2193 {count} more below","select.confirm_hint":"Press Enter to confirm, Esc to cancel","select.navigate_hint":"Use \u2191\u2193 to navigate, Enter to confirm, Esc to cancel","select.multiselect_hint":"Use \u2191\u2193 to navigate, Space to toggle, Enter to confirm, Esc to cancel","select.multiselect_empty":"Select at least one option with Space before confirming.","select.multiselect_min":"Select at least {min} option(s) with Space before confirming.","select.multiselect_max":"Select at most {max} option(s) with Space before confirming.","select.back_prev":"\u2190 Back to previous question","input.default":"Default:","input.value":"Value:","input.type_response":"(type your response)","managed.completed":"Task completed","managed.completed.blocked":"Task blocked","managed.completed.continuation":"Task needs continuation","todo.progress":"{completed}/{total} completed","todo.transcript.progress":"Plan {completed}/{total} completed","todo.summary.done":"{count} done","todo.summary.more":"+{count} more",cancelled:"[Cancelled] Operation cancelled by user",cancellationRequested:"[Cancelling] Stop requested for the current reply",cancellationAccepted:"Stop request accepted; waiting for execution to settle.",cancellationConfirmed:"Stop confirmed:",cancellationRejected:"Stop request failed:"},zh:{"dialog.confirm":"[\u786E\u8BA4]","dialog.select":"[\u9009\u62E9]","dialog.input":"[\u8F93\u5165]","confirm.instruction.basic":"\u6309 (y) \u786E\u8BA4, (n) \u62D2\u7EDD","confirm.instruction.always":"\u6309 (y) \u786E\u8BA4, (a) \u59CB\u7EC8\u5141\u8BB8\u6B64\u5DE5\u5177, (n) \u62D2\u7EDD","confirm.instruction.runtime_session":"\u6309 (y) \u4EC5\u5141\u8BB8\u4E00\u6B21, (s) \u672C\u4F1A\u8BDD\u59CB\u7EC8\u5141\u8BB8\u8FD9\u9879\u7CBE\u786E\u64CD\u4F5C, (n) \u62D2\u7EDD","confirm.instruction.runtime_persistent":"\u6309 (y) \u4EC5\u5141\u8BB8\u4E00\u6B21, (s) \u672C\u4F1A\u8BDD\u59CB\u7EC8\u5141\u8BB8\u8FD9\u9879\u7CBE\u786E\u64CD\u4F5C, (a) \u59CB\u7EC8\u5141\u8BB8\u8FD9\u9879\u7CBE\u786E\u64CD\u4F5C, (n) \u62D2\u7EDD","confirm.instruction.protected":"\u6309 (y) \u786E\u8BA4, (n) \u53D6\u6D88 (\u53D7\u4FDD\u62A4\u8DEF\u5F84)","confirm.result.approved":"\u5DF2\u6279\u51C6","confirm.result.approved_always":"\u5DF2\u6279\u51C6 (\u59CB\u7EC8\u5141\u8BB8)","confirm.result.approved_session":"\u5DF2\u6279\u51C6 (\u672C\u4F1A\u8BDD)","confirm.result.denied":"\u5DF2\u62D2\u7EDD","tool.bash.title":"\u6267\u884C bash \u547D\u4EE4\uFF1F","tool.shell.title":"\u6267\u884C shell \u547D\u4EE4\uFF1F","tool.write.title":"\u5199\u5165\u6587\u4EF6\uFF1F","tool.edit.title":"\u7F16\u8F91\u6587\u4EF6\uFF1F","tool.generic.title":"\u6267\u884C {tool}\uFF1F","field.reason":"\u539F\u56E0","field.intent":"\u610F\u56FE","field.target":"\u76EE\u6807","field.scope":"\u8303\u56F4","field.risk":"\u98CE\u9669","field.summary":"\u6458\u8981","intent.read":"\u8BFB\u53D6\u9879\u76EE\u6587\u4EF6","intent.delete":"\u5220\u9664\u6587\u4EF6","intent.deps":"\u4FEE\u6539\u4F9D\u8D56\u6216\u73AF\u5883","intent.modify":"\u4FEE\u6539\u6587\u4EF6","intent.execute":"\u6267\u884C\u547D\u4EE4","intent.write_file":"\u5199\u5165\u6587\u4EF6","intent.edit_file":"\u7F16\u8F91\u6587\u4EF6","intent.use_tool":"\u4F7F\u7528 {tool}","risk.destructive":"\u7834\u574F\u6027\u53D8\u66F4","risk.deps":"\u53EF\u80FD\u4FEE\u6539\u4F9D\u8D56\u6216\u672C\u5730\u5DE5\u5177","risk.modify":"\u53EF\u80FD\u4FEE\u6539\u6587\u4EF6","risk.unknown":"\u547D\u4EE4\u6548\u679C\u53D6\u51B3\u4E8E\u53C2\u6570","risk.network":"\u53EF\u80FD\u8BBF\u95EE\u7F51\u7EDC","scope.outside":"\u9879\u76EE\u5916\u90E8","scope.protected":"\u53D7\u4FDD\u62A4\u8DEF\u5F84","waiting.confirm":"\u7B49\u5F85\u4E2D\uFF1A\u9700\u8981\u5BA1\u6279","waiting.select":"\u7B49\u5F85\u4E2D\uFF1A\u8BF7\u9009\u62E9","waiting.input":"\u7B49\u5F85\u4E2D\uFF1A\u8BF7\u56DE\u7B54","placeholder.confirm":"\u8BF7\u56DE\u5E94\u4E0A\u65B9\u7684\u5BA1\u6279\u63D0\u793A...","placeholder.select":"\u8BF7\u5728\u4E0A\u65B9\u9009\u62E9\u4E00\u4E2A\u9009\u9879...","placeholder.input":"\u8BF7\u56DE\u7B54\u4E0A\u65B9\u7684\u63D0\u793A...","placeholder.busy":"\u667A\u80FD\u4F53\u6B63\u5728\u5DE5\u4F5C\u4E2D...","placeholder.queue":"\u6392\u961F\u7B49\u5F85\u4E0B\u4E00\u8F6E\u8DDF\u8FDB...","placeholder.idle":"\u8F93\u5165\u6D88\u606F...","select.choice":"\u9009\u9879\uFF1A","select.type_number":"(\u8F93\u5165\u7F16\u53F7)","select.more":"\u8FD8\u6709 {count} \u4E2A\u9009\u9879...","select.more_above":"\u2191 \u4E0A\u65B9\u8FD8\u6709 {count} \u4E2A","select.more_below":"\u2193 \u4E0B\u65B9\u8FD8\u6709 {count} \u4E2A","select.confirm_hint":"\u6309 Enter \u786E\u8BA4\uFF0CEsc \u53D6\u6D88","select.navigate_hint":"\u4F7F\u7528 \u2191\u2193 \u5BFC\u822A\uFF0CEnter \u786E\u8BA4\uFF0CEsc \u53D6\u6D88","select.multiselect_hint":"\u4F7F\u7528 \u2191\u2193 \u5BFC\u822A\uFF0C\u7A7A\u683C \u5207\u6362\u9009\u4E2D\uFF0CEnter \u786E\u8BA4\uFF0CEsc \u53D6\u6D88","select.multiselect_empty":"\u8BF7\u5148\u4F7F\u7528\u7A7A\u683C\u9009\u62E9\u81F3\u5C11\u4E00\u4E2A\u9009\u9879\u3002","select.multiselect_min":"\u8BF7\u5148\u4F7F\u7528\u7A7A\u683C\u81F3\u5C11\u9009\u62E9 {min} \u4E2A\u9009\u9879\u3002","select.multiselect_max":"\u6700\u591A\u53EA\u80FD\u9009\u62E9 {max} \u4E2A\u9009\u9879\u3002","select.back_prev":"\u2190 \u8FD4\u56DE\u4E0A\u4E00\u9898","input.default":"\u9ED8\u8BA4\u503C\uFF1A","input.value":"\u503C\uFF1A","input.type_response":"(\u8F93\u5165\u4F60\u7684\u56DE\u7B54)","managed.completed":"\u4EFB\u52A1\u5B8C\u6210","managed.completed.blocked":"\u4EFB\u52A1\u53D7\u963B","managed.completed.continuation":"\u4EFB\u52A1\u9700\u8981\u7EE7\u7EED","todo.progress":"{completed}/{total} \u5DF2\u5B8C\u6210","todo.transcript.progress":"\u8BA1\u5212 {completed}/{total} \u5DF2\u5B8C\u6210","todo.summary.done":"{count} \u9879\u5DF2\u5B8C\u6210","todo.summary.more":"\u53E6\u6709 {count} \u9879",cancelled:"[\u5DF2\u53D6\u6D88] \u64CD\u4F5C\u5DF2\u88AB\u7528\u6237\u53D6\u6D88",cancellationRequested:"[\u6B63\u5728\u53D6\u6D88] \u5DF2\u8BF7\u6C42\u505C\u6B62\u5F53\u524D\u56DE\u590D",cancellationAccepted:"\u505C\u6B62\u8BF7\u6C42\u5DF2\u63A5\u53D7\uFF0C\u6B63\u5728\u7B49\u5F85\u6267\u884C\u6536\u5C3E\u3002",cancellationConfirmed:"\u505C\u6B62\u5DF2\u786E\u8BA4\uFF1A",cancellationRejected:"\u505C\u6B62\u8BF7\u6C42\u5931\u8D25\uFF1A"}};function Bt(e,t){let o=Ae[Z][e]??Ae.en[e]??e;if(t)for(let[i,s]of Object.entries(t))o=o.replace(`{${i}}`,String(s));return o}r(Bt,"t");var Re={core:`// Split configs: ~/.kodax/integrations/mcp.json, extensions.json, and a2a.json.
3
3
  // KodaX core configuration template.
4
4
  // Copy only the fields you need to ~/.kodax/config.json (strict JSON).
5
5
  // MCP, A2A, and Extensions live in ~/.kodax/integrations/*.json; use
@@ -23,14 +23,13 @@ import{ka as Me,ma as _e}from"./chunk-VSXERQFQ.js";import{Ka as Se}from"./chunk-
23
23
  // "reasoningMode": "auto",
24
24
  // "thinking": true,
25
25
 
26
- // Agent harness: "ama" enables adaptive multi-agent use; "sa" forces one
27
- // agent. Permission profiles are "plan", "accept-edits", sandbox-first
26
+ // New product tasks use AMA with adaptive multi-agent use.
27
+ // Permission profiles are "plan", "accept-edits", sandbox-first
28
28
  // "auto", or direct-host "full-access". Full Access has no sandbox or
29
29
  // approval prompts; built-in dangerous-command fallbacks do not apply.
30
30
  // Explicit forbidden rules still block; explicit prompt rules cannot prompt.
31
31
  // Exec Policy is separate:
32
32
  // ~/.kodax/exec-policy.jsonc (and explicitly trusted project policy).
33
- // "agentMode": "ama",
34
33
  // "permissionMode": "accept-edits",
35
34
  // User-level Bash allow patterns. Project additions belong in
36
35
  // <project>/.kodax/config.local.json. Broad Bash(*) is rejected.
@@ -257,4 +256,4 @@ import{ka as Me,ma as _e}from"./chunk-VSXERQFQ.js";import{Ka as Se}from"./chunk-
257
256
  }
258
257
  `};function Ie(e){return Re[e]}r(Ie,"getConfigTemplate");import{closeSync as ne,existsSync as d,fsyncSync as $e,linkSync as it,mkdirSync as re,openSync as ie,readFileSync as je,renameSync as Ke,statSync as st,unlinkSync as K,watch as at,writeFileSync as Fe}from"node:fs";import{createHash as ct}from"node:crypto";import f from"node:path";import{closeSync as Qe,mkdirSync as Ze,openSync as et,rmSync as tt}from"node:fs";import nt from"node:path";var ee=class extends Error{static{r(this,"CoreConfigWriteConflictError")}constructor(t){super(`Core configuration is being changed by another KodaX writer: ${t}`),this.name="CoreConfigWriteConflictError"}};function ot(e){return`${e}.write.lock`}r(ot,"coreConfigWriteLockPath");function rt(e){if(!(!(e instanceof Error)||!("code"in e)))return typeof e.code=="string"?e.code:void 0}r(rt,"errorCode");function x(e,t){Ze(nt.dirname(e),{recursive:!0,mode:448});let n=ot(e),o;try{o=et(n,"wx",384)}catch(i){throw rt(i)==="EEXIST"?new ee(e):new Error(`Failed to acquire the core configuration write lock: ${e}`,{cause:i})}try{return t()}finally{Qe(o),tt(n,{force:!0})}}r(x,"withCoreConfigWriteLock");var k=class extends Error{static{r(this,"IntegrationConfigConflictError")}constructor(t,n,o){super(`Integration configuration revision changed for ${f.basename(t)} (expected ${n??"missing"}, actual ${o??"missing"}).`),this.name="IntegrationConfigConflictError"}},lt={mcp:"mcp.json",a2a:"a2a.json",extensions:"extensions.json"},dt=new Set(["type","command","args","cwd","env","url","headers","connect","startupTimeoutMs","requestTimeoutMs","auth"]);function P(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}r(P,"isRecord");function E(e,t){if(!P(e))throw new Error(`${t} must be an object.`);return e}r(E,"requireRecord");function F(e,t,n){let o=Object.keys(e).find(i=>!t.has(i));if(o!==void 0)throw new Error(`${n} has unknown field "${o}".`)}r(F,"assertNoUnknownKeys");function Xe(e,t){if(e.version!==1)throw new Error(`${t} version must be 1.`)}r(Xe,"requireVersionOne");function Te(e,t){let n=E(e,t);for(let[o,i]of Object.entries(n))if(o.trim().length===0||typeof i!="string")throw new Error(`${t} must contain non-empty string keys and string values.`);return structuredClone(n)}r(Te,"requireStringMap");function oe(e,t){if(!Array.isArray(e)||!e.every(n=>typeof n=="string"&&n.trim().length>0))throw new Error(`${t} must be an array of non-empty strings.`);return e.map(n=>n.trim())}r(oe,"requireStringArray");function te(e,t){if(e!==void 0&&(!Number.isFinite(e)||Number(e)<=0))throw new Error(`${t} must be a positive number.`)}r(te,"validatePositiveNumber");function ut(e,t){if(e.trim().length===0)throw new Error("MCP server names must not be empty.");let n=E(t,`MCP server "${e}"`);F(n,dt,`MCP server "${e}"`);let o=n.type??"stdio";if(!["stdio","sse","streamable-http","http"].includes(String(o)))throw new Error(`MCP server "${e}" has an unsupported transport type.`);if(o==="stdio"){if(typeof n.command!="string"||n.command.trim().length===0)throw new Error(`MCP server "${e}" stdio transport requires command.`)}else if(typeof n.url!="string"||n.url.trim().length===0)throw new Error(`MCP server "${e}" ${String(o)} transport requires url.`);if(n.args!==void 0&&oe(n.args,`MCP server "${e}" args`),n.cwd!==void 0&&typeof n.cwd!="string")throw new Error(`MCP server "${e}" cwd must be a string.`);if(n.env!==void 0&&Te(n.env,`MCP server "${e}" env`),n.headers!==void 0&&Te(n.headers,`MCP server "${e}" headers`),n.connect!==void 0&&!["lazy","prewarm","disabled"].includes(String(n.connect)))throw new Error(`MCP server "${e}" has an unsupported connect mode.`);if(te(n.startupTimeoutMs,`MCP server "${e}" startupTimeoutMs`),te(n.requestTimeoutMs,`MCP server "${e}" requestTimeoutMs`),n.auth!==void 0){let i=E(n.auth,`MCP server "${e}" auth`);if(F(i,new Set(["type","clientId","authorizationUrl","tokenUrl","scopes","redirectPort"]),`MCP server "${e}" auth`),i.type!=="oauth2")throw new Error(`MCP server "${e}" auth type must be oauth2.`);for(let a of["clientId","authorizationUrl","tokenUrl"])if(i[a]!==void 0&&typeof i[a]!="string")throw new Error(`MCP server "${e}" auth.${a} must be a string.`);i.scopes!==void 0&&oe(i.scopes,`MCP server "${e}" auth.scopes`),te(i.redirectPort,`MCP server "${e}" auth.redirectPort`)}return structuredClone(n)}r(ut,"parseMcpServer");function S(e){let t=E(e,"MCP integration config");F(t,new Set(["version","servers"]),"MCP integration config"),Xe(t,"MCP integration config");let n=E(t.servers,"MCP integration config servers"),o={};for(let[i,s]of Object.entries(n))o[i]=ut(i,s);return{version:1,servers:o}}r(S,"parseMcpIntegrationDocument");function C(e){let t=E(e,"Extensions integration config");F(t,new Set(["version","paths"]),"Extensions integration config"),Xe(t,"Extensions integration config");let n=oe(t.paths,"Extensions integration config paths");if(new Set(n).size!==n.length)throw new Error("Extensions integration config paths must not contain duplicates.");return{version:1,paths:n}}r(C,"parseExtensionsIntegrationDocument");function M(e,t){return f.join(f.resolve(t),"integrations",lt[e])}r(M,"resolveIntegrationConfigPath");function A(e){return f.join(f.resolve(e),"config.json")}r(A,"coreConfigPath");function Ue(e){return ct("sha256").update(e).digest("hex")}r(Ue,"hashText");function se(e){let t=je(e,"utf8");try{return{raw:t,value:JSON.parse(t)}}catch(n){let o=n instanceof Error?n.message:String(n);throw new Error(`Invalid JSON: ${o}`)}}r(se,"readJsonFile");function _(e){return{domain:e.domain,source:e.source,path:e.path,revision:Ue(e.raw),document:structuredClone(e.document),loadedAt:new Date().toISOString()}}r(_,"snapshot");function X(e){let t=A(e);return d(t)?E(se(t).value,"Core config"):{}}r(X,"readCoreConfig");function U(e){let t=M("mcp",e);if(d(t)){let s=se(t);return _({domain:"mcp",source:"user",path:t,raw:s.raw,document:S(s.value)})}let n=A(e),o=X(e).mcpServers,i=S({version:1,servers:o===void 0?{}:o});return _({domain:"mcp",source:o===void 0?"default":"legacy-user",path:o===void 0?t:n,raw:JSON.stringify(i),document:i})}r(U,"readMcpIntegration");function q(e){let t=M("extensions",e);if(d(t)){let s=se(t);return _({domain:"extensions",source:"user",path:t,raw:s.raw,document:C(s.value)})}let n=A(e),o=X(e).extensions,i=C({version:1,paths:o===void 0?[]:o});return _({domain:"extensions",source:o===void 0?"default":"legacy-user",path:o===void 0?t:n,raw:JSON.stringify(i),document:i})}r(q,"readExtensionsIntegration");function ft(e){if(!P(e))return[];let t=[],n=/(token|secret|password|api[_-]?key|authorization)/i;for(let[o,i]of Object.entries(e))if(P(i))for(let s of["env","headers"]){let a=i[s];if(P(a))for(let[c,l]of Object.entries(a))n.test(c)&&typeof l=="string"&&!l.startsWith("${env:")&&t.push(`MCP server "${o}" ${s}.${c} may contain a literal secret.`)}return t}r(ft,"likelySecretWarnings");function pt(e){let t=X(e),n=M("mcp",e),o=M("extensions",e),i=t.mcpServers,s=t.extensions,a=P(i)?Object.keys(i).length:0,c=Array.isArray(s)?s.length:0,l=r((g,N,$)=>d(g)?{action:"none",entries:N,destination:g,reason:"destination-exists"}:$?{action:"create",entries:N,destination:g}:{action:"none",entries:0,destination:g,reason:"legacy-absent"},"domainPlan");return{mcp:l(n,a,i!==void 0),extensions:l(o,c,s!==void 0),warnings:ft(i)}}r(pt,"planLegacyIntegrationMigration");function mt(e,t){let n=A(e);re(f.dirname(n),{recursive:!0,mode:448});let o=`${n}.${process.pid}.${Date.now()}.tmp`,i=ie(o,"wx",384);try{Fe(i,`${JSON.stringify(t,null,2)}
259
258
  `,"utf8"),$e(i)}finally{ne(i)}try{Ke(o,n)}catch(s){throw d(o)&&K(o),new Error("Failed to atomically clean legacy integration fields.",{cause:s})}}r(mt,"writeCoreConfigAtomically");function ln(e){return x(A(e.configHome),()=>ht(e))}r(ln,"migrateLegacyIntegrationConfig");function ht(e){let t=pt(e.configHome),n=X(e.configHome),o=t.mcp.action==="create"?S({version:1,servers:P(n.mcpServers)?n.mcpServers:{}}):void 0,i=t.extensions.action==="create"?C({version:1,paths:Array.isArray(n.extensions)?n.extensions:[]}):void 0,s=[];if(o)try{I({domain:"mcp",configHome:e.configHome,expectedRevision:null,document:o,validate:S}),s.push("mcp")}catch(c){if(!(c instanceof k))throw c}if(i)try{I({domain:"extensions",configHome:e.configHome,expectedRevision:null,document:i,validate:C}),s.push("extensions")}catch(c){if(!(c instanceof k))throw c}let a=!1;if(e.cleanupLegacy&&d(A(e.configHome))){let c={...n};d(t.mcp.destination)&&delete c.mcpServers,d(t.extensions.destination)&&delete c.extensions,gt(n,c)||(mt(e.configHome,c),a=!0)}return{...t,applied:s,cleanedLegacy:a}}r(ht,"migrateLegacyIntegrationConfigUnlocked");function gt(e,t){return JSON.stringify(e)===JSON.stringify(t)}r(gt,"isDeepStrictEqualForConfig");function De(e){return d(e)?Ue(je(e,"utf8")):void 0}r(De,"currentUserRevision");function vt(e){let t=`${e}.lock`;try{return{fd:ie(t,"wx",384),path:t}}catch(n){throw new Error(`Integration configuration is busy: ${f.basename(e)}`,{cause:n})}}r(vt,"acquireWriteLock");function I(e){let t=M(e.domain,e.configHome),n=e.validate(e.document);re(f.dirname(t),{recursive:!0,mode:448});let o=vt(t);try{let i=De(t),s=e.expectedRevision===null?void 0:e.expectedRevision;if(e.expectedRevision!==void 0&&i!==s)throw new k(t,s,i);let a=`${JSON.stringify(n,null,2)}
260
- `,c=`${t}.${process.pid}.${Date.now()}.tmp`,l=ie(c,"wx",384);try{Fe(l,a,"utf8"),$e(l)}finally{ne(l)}try{e.expectedRevision===null?(it(c,t),K(c)):Ke(c,t)}catch(g){throw d(c)&&K(c),e.expectedRevision===null&&d(t)?new k(t,void 0,De(t)):new Error(`Failed to atomically replace ${f.basename(t)}.`,{cause:g})}return _({domain:e.domain,source:"user",path:t,raw:a,document:n})}finally{ne(o.fd),d(o.path)&&K(o.path)}}r(I,"writeIntegrationDocument");function yt(e){if(!d(e))return"missing";let t=st(e);return`${t.dev}:${t.ino}:${t.size}:${t.mtimeMs}`}r(yt,"metadataSignature");function Le(e){return e.map(t=>`${t}:${yt(t)}`).join("|")}r(Le,"observationSignature");function j(e,t){return{code:e,message:t,time:new Date().toISOString()}}r(j,"safeDiagnostic");var Ne=class{static{r(this,"IntegrationConfigController")}#u;#n;#r;#a;#m;#f;#p;#e;#t;#c;#l;#h="";#s=[];#o;#i;#g=Promise.resolve();#d=new Set;constructor(t){this.#u=t.domain,this.#n=M(t.domain,t.configHome),this.#r=t.fallbackPath===void 0?void 0:f.resolve(t.fallbackPath),this.#a=this.#r===void 0?[this.#n]:[this.#n,this.#r],this.#f=t.validate,this.#m=t.read,this.#p=t.coldStartDefault===void 0?void 0:structuredClone(this.#f(t.coldStartDefault))}async initialize(){let t=await this.reload();if(!t.ok&&!this.#e&&this.#p!==void 0){let n=structuredClone(this.#p);this.#e=_({domain:this.#u,source:"default",path:this.#n,raw:JSON.stringify(n),document:n})}if(!this.#e)throw new Error(t.ok?"Integration configuration did not produce a snapshot.":t.error);return structuredClone(this.#e)}snapshot(){return this.#e?structuredClone(this.#e):void 0}status(){let t=this.#t?this.#c:void 0,n=this.#t?this.#l:void 0;return{domain:this.#u,path:t??this.#e?.path??this.#n,...this.#e?{revision:this.#e.revision,lastReloadAt:this.#e.loadedAt}:{},...n??this.#e?.source?{source:n??this.#e?.source}:{},...this.#t?{diagnostic:this.#t}:{},watching:this.#s.length>0}}subscribe(t){return this.#d.add(t),()=>{this.#d.delete(t)}}reload(){let t=this.#g.then(()=>this.#v());return this.#g=t.then(()=>{},()=>{}),t}async#v(){this.#h=Le(this.#a);let t;try{t=this.#m(),this.#f(t.document)}catch{let o=this.#y();return this.#c=o.path,this.#l=o.source,this.#t=j("invalid-config","Integration configuration is invalid; check the file against its versioned schema."),{ok:!1,error:this.#t.message}}let n=this.#e?structuredClone(this.#e):void 0;try{for(let o of this.#d)await o(structuredClone(t),n)}catch{return this.#c=t.path,this.#l=t.source,this.#t=j("activation-failed","Integration configuration could not be activated; the previous configuration remains active."),{ok:!1,error:this.#t.message}}return this.#e=t,this.#t=void 0,this.#c=void 0,this.#l=void 0,{ok:!0,snapshot:structuredClone(t)}}async ensureCurrent(){return Le(this.#a)===this.#h&&this.#e?{ok:!0,snapshot:structuredClone(this.#e)}:this.reload()}startWatching(t=100,n=2e3){if(this.#s.length>0||this.#i)return;re(f.dirname(this.#n),{recursive:!0,mode:448});let o=new Map;for(let i of this.#a){let s=f.dirname(i),a=o.get(s)??new Set;a.add(f.basename(i)),o.set(s,a)}for(let[i,s]of o)try{let a=at(i,(c,l)=>{l!==null&&!s.has(l.toString())||(this.#o&&clearTimeout(this.#o),this.#o=setTimeout(()=>{this.#o=void 0,this.reload()},t),this.#o.unref?.())});a.unref(),a.on("error",()=>{this.#t=j("watcher-degraded","Integration watcher is degraded; metadata polling remains active.")}),this.#s.push(a)}catch{this.#t=j("watcher-degraded","Integration watcher is degraded; metadata polling remains active.")}this.#i=setInterval(()=>{this.ensureCurrent()},n),this.#i.unref?.()}close(){this.#o&&clearTimeout(this.#o),this.#o=void 0,this.#i&&clearInterval(this.#i),this.#i=void 0;for(let t of this.#s)t.close();this.#s.length=0,this.#d.clear()}#y(){return d(this.#n)?{path:this.#n,source:"user"}:this.#r&&d(this.#r)?{path:this.#r,source:"legacy-user"}:{path:this.#n,source:"default"}}};var Pt=Et(wt),qe=2,We=!1,u=ke(),kn=h.join(u,"sessions"),p=h.join(u,"config.json"),Sn=60,v=null,ce=!1,kt="dumb";function St(e){let t=h.basename(e).toLowerCase(),n="__KODAX_SHELL_ENV_START__",o=`printf '%s\\0' '${n}'; env -0`;return t==="fish"?{args:["-i","-c",o],sentinel:n}:{args:t==="bash"||t==="zsh"?["-ic",o]:["-lc",o],sentinel:n}}r(St,"buildShellEnvCommand");function Ct(e,t){let n=`${t}\0`,o=e.lastIndexOf(n);if(o===-1)return{};let i=e.slice(o+n.length),s={};for(let a of i.split("\0")){if(!a)continue;let c=a.indexOf("=");c<=0||(s[a.slice(0,c)]=a.slice(c+1))}return s}r(Ct,"parseNullDelimitedShellEnv");function Mt(e={}){let t=e.env??process.env;if((e.platform??process.platform)==="win32"||t.KODAX_DISABLE_SHELL_ENV_HYDRATION==="1")return!1;let o=e.shell??t.SHELL;if(!o||!h.isAbsolute(o))return!1;let{args:i,sentinel:s}=St(o),a=e.run??xt,c={...t,TERM:kt},l=a(o,i,{encoding:"utf8",env:c,maxBuffer:1024*1024,timeout:5e3,windowsHide:!0,detached:!0,stdio:["ignore","pipe","pipe"]});if(l.status!==0||!l.stdout)return!1;let g=typeof l.stdout=="string"?l.stdout:l.stdout.toString("utf8"),N=Ct(g,s),$=!1;for(let[V,Je]of Object.entries(N))V!=="TERM"&&t[V]===void 0&&(t[V]=Je,$=!0);return $}r(Mt,"hydrateProcessEnvFromShell");function _t(){if(!ce){ce=!0;try{Mt()}catch{}}}r(_t,"ensureShellEnvironmentHydrated");function Cn(){ce=!1}r(Cn,"resetShellEnvironmentHydrationForTesting");function At(e){Ee(e.customProviders??[])}r(At,"registerConfiguredCustomProviders");function le(e){if(!Array.isArray(e))return;let t=e.filter(n=>typeof n=="string").map(n=>n.trim()).filter(n=>n.length>0);return t.length>0?t:[]}r(le,"normalizeConfiguredExtensions");function ue(){let e=m.readFileSync(p,"utf8"),t=JSON.parse(e);if(!(t===null||typeof t!="object"||Array.isArray(t)))return{raw:e,value:t}}r(ue,"readPersistedCoreConfig");function Ve(e){m.writeFileSync(p,JSON.stringify(e,null,2))}r(Ve,"writePersistedCoreConfig");function Ot(e){if(e.permissionMode!=="default")return e;let t={...e,permissionMode:"accept-edits"};try{x(p,()=>{let n=ue();n?.value.permissionMode==="default"&&Ve({...n.value,permissionMode:"accept-edits"})})}catch{}return t}r(Ot,"migrateLegacyPermissionModeInConfig");function Rt(e){if(e.permissionMode!=="auto-in-project")return e;try{x(p,()=>{let t=ue();if(t?.value.permissionMode!=="auto-in-project")return;let n=t.raw.replace(/("permissionMode"\s*:\s*)"auto-in-project"/,'$1"auto"');n!==t.raw&&m.writeFileSync(p,n)})}catch{}return{...e,permissionMode:"auto"}}r(Rt,"migrateAutoInProjectAliasInConfig");function It(){if(v)return v;let e="0.7.97-alpha.10";if(e)return v=e,v;let t=h.join(h.dirname(bt(import.meta.url)),"../../package.json");if(m.existsSync(t))try{return v=JSON.parse(m.readFileSync(t,"utf-8")).version??"0.0.0",v??"0.0.0"}catch{}return v="0.0.0",v}r(It,"getVersion");var Mn=It();function Tt(e){return ve(e)}r(Tt,"getProviderModel");function de(e,t){let n=new Set(e.map(i=>i.toLowerCase())),o=[...e];for(let i of t)n.has(i.toLowerCase())||o.push(i);return o}r(de,"mergeModels");function Dt(e,t){t||(t=fe().providerModels);let n=t?.[e];if(n&&n.length>0){try{let o=Y(e);if(o.length>0)return de(n,o)}catch{}try{let o=R(e);if(o)return de(n,o.getAvailableModels())}catch{}return n}try{let o=Y(e);if(o.length>0)return o}catch{}try{let o=R(e);if(o)return o.getAvailableModels()}catch{}return[]}r(Dt,"getProviderAvailableModels");function Lt(e,t){let n=ye(e,t);if(n!=="unknown")return n;try{let o=R(e);if(o)return o.getReasoningCapability(t)}catch{}return"unknown"}r(Lt,"getProviderReasoningCapability");function Nt(e){let t=we(e);if(t)return t;try{return Q().find(o=>o.name===e)?.capabilityProfile??null}catch{return null}}r(Nt,"getProviderCapabilityProfile");function ze(e,t){let n=Nt(e),o=Lt(e,t);if(n)return{capabilityProfile:n,reasoningCapability:o};try{let i=be(e);return{capabilityProfile:i.getCapabilityProfile(),reasoningCapability:i.getReasoningCapability(t)}}catch{return null}}r(ze,"getProviderCapabilityMetadata");function _n(e,t){let n=ze(e,t);return n?Me({providerName:e,model:t,capabilityProfile:n.capabilityProfile,reasoningCapability:n.reasoningCapability==="unknown"?void 0:n.reasoningCapability}):null}r(_n,"getProviderCapabilitySnapshot");function $t(e,t,n,o){let i=ze(e,t);return i?_e({providerName:e,model:t,capabilityProfile:i.capabilityProfile,reasoningCapability:i.reasoningCapability==="unknown"?void 0:i.reasoningCapability,reasoningMode:n,hints:o}):null}r($t,"getProviderPolicyDecision");function An(e){let t=e.transport==="cli-bridge"?"CLI bridge":"Native API",n=e.conversationSemantics==="last-user-message"?"forwards only the latest user message":"preserves full conversation history",o=e.mcpSupport==="native"?"MCP available":"MCP unavailable";return`${t}; ${n}; ${o}`}r(An,"describeProviderCapabilitySummary");function On(e){switch(e){case"native-budget":return"B";case"native-effort":return"E";case"native-toggle":return"T";case"native-adaptive":return"A";default:return"-"}}r(On,"formatReasoningCapabilityShort");function O(e){if(e)return e==="none"?"off":e}r(O,"formatReasoningEffortForDisplay");function W(e,t){let n=O(t);n&&!e.includes(n)&&e.push(n)}r(W,"pushUniqueEffortDisplay");function Rn(e,t,n){let o=["auto"],i=H(e,t,n),s=i?.supportedEfforts?.filter(a=>a.isUserVisible!==!1);if(!s||s.length===0){for(let a of["off","low","medium","high"])W(o,a);return o}for(let a of s)a.value==="none"&&i?.supportsDisabledThinking===!1||W(o,a.value);return o}r(Rn,"getProviderReasoningEffortOptions");function In(e,t){let n=H(e,t),o=new Set(n?.disabledEfforts??[]),i=n?.supportedEfforts?.filter(l=>l.isUserVisible!==!1),s=[],a=n?.supportsDisabledThinking===!0;if(!i||i.length===0){for(let l of["low","medium","high"])W(s,l);a=!0}else for(let l of i){if(l.value==="none"){n?.supportsDisabledThinking!==!1&&(a=!0);continue}if(o.has(l.value)){n?.supportsDisabledThinking!==!1&&(a=!0);continue}W(s,l.value)}let c=[];return a&&c.push("off"),c.push(...s),c.push("auto"),c}r(In,"getProviderReasoningEffortCycle");function jt(e,t){if(t===!1)return"off";switch(e){case"off":return"off";case"quick":return"low";case"balanced":return"medium";case"deep":return"high";default:return"auto"}}r(jt,"legacyReasoningModeToEffortDisplay");function H(e,t,n){let o=t??Tt(e);if(!o)return;let i=Pe(e,o)?.reasoningProfile;if(i)return me(i,Se(e,o,n))}r(H,"resolveReasoningProfileForDisplay");function Tn(e){let t=O(e.effort)??jt(e.reasoningMode,e.thinking),n=H(e.provider,e.model);if(!n)return t;try{let o=he({capability:n,explicitEffort:e.effortOverride?e.effort:void 0,sessionEffort:e.effortOverride?void 0:e.effort,legacyReasoningMode:e.reasoningMode,thinking:e.thinking}),i=O(o.configuredEffort)??t,a=o.configuredEffort!==void 0&&n.supportsDisabledThinking!==!1&&n.disabledEfforts?.includes(o.configuredEffort)===!0?"off":O(o.effectiveEffort);return a&&a!==i?`${i}->${a}`:i}catch{if(e.effort)try{let o=J({currentEffort:e.effort,capability:n}),i=O(e.effort)??t,s=O(o.effectiveEffort);return s&&s!==i?`${i}->${s}`:i}catch{return t}return t}}r(Tn,"formatReasoningEffortStatusLabel");function Dn(e){let t=Vt(e);if(!t)return{preserved:!0};let n=H(e.provider,e.model);if(!n)return{configuredEffort:t,runtimeEffort:t,preserved:!0};let o=J({currentEffort:t,capability:n});return{configuredEffort:t,runtimeEffort:o.effectiveEffort,preserved:o.preserved,diagnostic:o.diagnostic}}r(Dn,"resolveProviderReasoningRuntimeEffort");function Kt(e){switch(e){case"native-budget":return"budget";case"native-effort":return"effort";case"native-toggle":return"toggle";case"native-adaptive":return"adaptive";default:return"none"}}r(Kt,"describeReasoningCapabilityControl");function Ln(e,t){if(e==="off")return"Reasoning disabled";switch(t){case"native-budget":return"Uses native thinking budget control";case"native-effort":return"Uses native reasoning effort control";case"native-toggle":return"Uses provider-native thinking toggle only";case"native-adaptive":return"Model adaptively decides thinking depth (Opus 4.7+)";case"none":return"Runs without native reasoning parameters";case"prompt-only":return"Uses prompt overlays only; no native reasoning parameter";default:return"Runs without native reasoning parameters"}}r(Ln,"describeReasoningExecution");function Nn(e){let t=[];e||(e=fe().providerModels);for(let n of xe())t.push({name:n.name,model:n.model,models:Dt(n.name,e),configured:n.capabilityProfile.transport==="cli-bridge"?!0:n.configured,reasoningCapability:n.reasoningCapability,capabilityProfile:n.capabilityProfile});try{let n=Q().map(o=>({...o,models:(()=>{let i=e?.[o.name];return i&&i.length>0?de(i,o.models):o.models})()}));t.push(...n)}catch{}return t}r(Nn,"getProviderList");function $n(e){if(ge(e))return!0;try{return R(e)?.isConfigured()??!1}catch{return!1}}r($n,"isProviderConfigured");var G=class extends Error{static{r(this,"InvalidAgentModeConfigError")}};function Ft(e){let t=e.agentMode;if(t===void 0||t==="ama"||t==="sa")return e;if(t!=="amaw"&&t!=="ama-workflow")throw new G(`Invalid agentMode "${t}" in ${p}. Expected "ama" or "sa".`);let n={...e,agentMode:"ama",schemaVersion:Math.max(e.schemaVersion??0,qe)};try{x(p,()=>{let o=ue();if(!o)return;let i=o.value.agentMode;i!=="amaw"&&i!=="ama-workflow"||Ve({...o.value,agentMode:"ama",schemaVersion:Math.max(typeof o.value.schemaVersion=="number"?o.value.schemaVersion:0,qe)})})}catch{}return We||(process.emitWarning(`Migrated persisted agentMode "${t}" to "ama". Workflow use is now explicit intent.`,{code:"KODAX_AGENT_MODE_MIGRATED"}),We=!0),n}r(Ft,"migrateLegacyAgentModeConfig");function fe(){try{if(m.existsSync(p)){let n=JSON.parse(m.readFileSync(p,"utf-8")),o=Ft(n),i=o.reasoningCeiling??o.reasoningMode,s=[],a={};try{s=[...q(u).document.paths]}catch{}try{a=U(u).document.servers}catch{}let{sandbox:c,...l}=o;return Rt(Ot({...l,reasoningMode:i,extensions:le(s),mcpServers:a}))}}catch(n){if(n instanceof G)throw n}let e,t;try{let n=q(u);n.source!=="default"&&(e=le([...n.document.paths]))}catch{}try{let n=U(u);n.source!=="default"&&(t=n.document.servers)}catch{}return{...e===void 0?{}:{extensions:e},...t===void 0?{}:{mcpServers:t}}}r(fe,"loadConfig");var Xt=h.join(u,"config.example.jsonc"),ae={mcp:h.join(u,"integrations","mcp.example.jsonc"),a2a:h.join(u,"integrations","a2a.example.jsonc"),extensions:h.join(u,"integrations","extensions.example.jsonc")},Ut=[{name:"core",path:Xt},{name:"mcp",path:ae.mcp},{name:"a2a",path:ae.a2a},{name:"extensions",path:ae.extensions}];function qt(){let e=[];for(let t of Ut)try{if(m.existsSync(t.path))continue;m.mkdirSync(h.dirname(t.path),{recursive:!0}),m.writeFileSync(t.path,Ie(t.name),"utf8"),e.push(t.path)}catch{}return e}r(qt,"ensureExampleConfigFiles");function jn(){return qt()[0]}r(jn,"ensureExampleConfigFile");var L=new Map;function Kn(e){let t=process.env[e];return t===void 0?"unset":L.get(e)===t?"persisted":"environment"}r(Kn,"inspectConfigEnvironmentSource");function Be(e,t,n=!1){let o=process.env[e],i=L.get(e),s=i!==void 0&&o===i;if(o!==void 0&&!s&&!n){L.delete(e);return}if(t===void 0){(s||n)&&delete process.env[e],L.delete(e);return}process.env[e]=t,L.set(e,t)}r(Be,"projectConfigEnvironment");var pe=[{configPath:"streamIdleTimeoutMs",env:"KODAX_STREAM_IDLE_TIMEOUT_MS",value:r(e=>b(e.streamIdleTimeoutMs),"value")},{configPath:"repoIntelligenceMode",env:"KODAX_REPO_INTELLIGENCE",value:r(e=>e.repoIntelligenceMode,"value")},{configPath:"repoIntelligenceTrace",env:"KODAX_REPO_INTELLIGENCE_TRACE",value:r(e=>T(e.repoIntelligenceTrace),"value")},{configPath:"stallLog",env:"KODAX_STALL_LOG",value:r(e=>T(e.stallLog),"value")},{configPath:"fallbackProviders",env:"KODAX_FALLBACK_PROVIDERS",value:r(e=>Gt(e.fallbackProviders),"value")},{configPath:"fastProvider",env:"KODAX_FAST_PROVIDER",value:r(e=>y(e.fastProvider),"value")},{configPath:"fastModel",env:"KODAX_FAST_MODEL",value:r(e=>y(e.fastModel),"value")},{configPath:"deepProvider",env:"KODAX_DEEP_PROVIDER",value:r(e=>y(e.deepProvider),"value")},{configPath:"deepModel",env:"KODAX_DEEP_MODEL",value:r(e=>y(e.deepModel),"value")},{configPath:"provider",env:"KODAX_PROVIDER",value:r(e=>y(e.provider),"value")},{configPath:"effort",env:"KODAX_EFFORT",value:r(e=>y(e.effort),"value")},{configPath:"sessionRetentionDays",env:"KODAX_SESSION_RETENTION_DAYS",value:r(e=>b(e.sessionRetentionDays),"value")},{configPath:"maxOutputTokens",env:"KODAX_MAX_OUTPUT_TOKENS",value:r(e=>b(e.maxOutputTokens),"value")},{configPath:"disablePromptCache",env:"KODAX_DISABLE_PROMPT_CACHE",value:r(e=>T(e.disablePromptCache),"value")},{configPath:"lsp",env:"KODAX_LSP",value:r(e=>T(e.lsp),"value")},{configPath:"lspAutoDownload",env:"KODAX_LSP_DOWNLOAD",value:r(e=>T(e.lspAutoDownload),"value")},{configPath:"acpLogLevel",env:"KODAX_ACP_LOG",value:r(e=>y(e.acpLogLevel),"value")},{configPath:"repoIntelligence.toolWaitMs",env:"KODAX_REPO_INTELLIGENCE_TOOL_WAIT_MS",value:r(e=>b(e.repoIntelligence?.toolWaitMs),"value")},{configPath:"repoIntelligence.workerTimeoutMs",env:"KODAX_REPO_INTELLIGENCE_WORKER_TIMEOUT_MS",value:r(e=>b(e.repoIntelligence?.workerTimeoutMs),"value")},{configPath:"repoIntelligence.workerOldSpaceMb",env:"KODAX_REPO_INTELLIGENCE_WORKER_OLD_SPACE_MB",value:r(e=>b(e.repoIntelligence?.workerOldSpaceMb),"value")},{configPath:"repoIntelligence.storageDir",env:"KODAX_REPO_INTELLIGENCE_STORAGE_DIR",value:r(e=>y(e.repoIntelligence?.storageDir),"value")},{configPath:"workflow.maxConcurrency",env:"KODAX_WORKFLOW_MAX_CONCURRENCY",value:r(e=>b(e.workflow?.maxConcurrency),"value")}];function Wt(e){for(let t of pe)Be(t.env,t.value(e))}r(Wt,"applyConfigSurfaceBridges");function y(e){return e?.trim()||void 0}r(y,"normalizedConfigString");function b(e){return typeof e=="number"&&Number.isFinite(e)?String(e):void 0}r(b,"configNumberString");function T(e){return e===void 0?void 0:e?"1":"0"}r(T,"configBooleanString");function Gt(e){return e?.filter(t=>t.trim().length>0).join(",")}r(Gt,"configStringList");var Fn=[...pe.map(({configPath:e,env:t})=>({configPath:e,env:t}))];function Ht(e){Wt(e)}r(Ht,"applyConfigEnvironment");function Xn(e,t=!1){for(let n of pe)["fallbackProviders","stallLog"].includes(n.configPath)&&(t&&!Object.hasOwn(e,n.configPath)||Be(n.env,n.value(e),t))}r(Xn,"applyExecutionConfigEnvironment");function Un(){_t();let e=fe();return Ht(e),At(e),Oe(e.locale),e}r(Un,"prepareRuntimeConfig");function qn(e){let{extensions:t,mcpServers:n,...o}=e;if(x(p,()=>{let i={};if(m.existsSync(p))try{let a=JSON.parse(m.readFileSync(p,"utf8"));a&&typeof a=="object"&&!Array.isArray(a)&&(i=a)}catch{}let s={...i,...o};for(let a of Object.keys(o))o[a]===void 0&&delete s[a];m.writeFileSync(p,JSON.stringify(s,null,2))}),t!==void 0){let i=q(u);I({domain:"extensions",configHome:u,...i.source==="user"?{expectedRevision:i.revision}:{},document:{version:1,paths:le(t)??[]},validate:C})}if(n!==void 0){let i=U(u);I({domain:"mcp",configHome:u,...i.source==="user"?{expectedRevision:i.revision}:{},document:{version:1,servers:n},validate:S})}}r(qn,"saveConfig");function Wn(e,t,n){return e.effort!==void 0||B(n).kind==="value"||t.effort!==void 0}r(Wn,"resolveInitialEffortOverride");function w(e){return e?.trim()?e:void 0}r(w,"nonEmptySelection");function Gn(e){return w(e.explicitProvider)??w(e.environmentProvider)??w(e.configuredProvider)??e.defaultProvider}r(Gn,"resolveRuntimeProviderSelection");function Hn(e){let t=w(e.explicitModel);if(t)return t;let n=w(e.configuredModel);if(!n)return;let o=w(e.explicitProvider)??w(e.environmentProvider);return o?w(e.configuredProvider)===o?n:void 0:n}r(Hn,"resolveRuntimeModelSelection");function Vn(e){if(e.explicitEffort!==void 0)return z(e.explicitEffort);let t=B(e.environmentEffort);return t.kind==="value"?t.value:e.configuredEffort===void 0?void 0:z(e.configuredEffort)}r(Vn,"resolveRuntimeEffortSelection");function Vt(e){return e.permissionMode==="plan"&&e.effortOverride!==!0&&e.planModeEffort!==void 0?e.planModeEffort:e.effort}r(Vt,"resolvePermissionModeEffort");async function zn(e){try{await Ce({cwd:e});let{stdout:t}=await Pt("git rev-parse --show-toplevel",{cwd:e,windowsHide:!0});return t.trim()}catch{return null}}r(zn,"getGitRoot");function zt(e){switch(e){case"builtin":return"Built-in";case"runtime":return"Runtime extension";case"custom":return"Custom config";default:return"Unknown"}}r(zt,"formatProviderSourceKind");function Bn(e){let t=e.transport==="cli-bridge"?"CLI bridge":"Native API",n=e.conversationSemantics==="last-user-message"?"latest-user-message only":"full conversation history";return[`Source: ${zt(e.sourceKind)}`,`Transport: ${t}`,`Conversation semantics: ${n}`,`Context fidelity: ${e.contextFidelity}`,`Tool calling: ${e.toolCallingFidelity}`,`Session behavior: ${e.sessionSupport}`,`Long-running support: ${e.longRunningSupport}`,`Evidence-heavy flows: ${e.evidenceSupport}`,`Multimodal support: ${e.multimodalSupport}`,`MCP support: ${e.mcpSupport}`,`Reasoning control: ${Kt(e.reasoningCapability)}`]}r(Bn,"formatProviderCapabilityDetailLines");function Jn(e,t,n){return[{label:"General coding",hints:{}},{label:"Evidence-heavy review",hints:{evidenceHeavy:!0}},{label:"Long-running task",hints:{longRunning:!0}}].map(i=>({label:i.label,decision:$t(e,t,n,i.hints)})).filter(i=>i.decision!==null)}r(Jn,"getProviderCommonPolicyScenarios");var Ge=.5,He=0,D={locked:!1,queue:[]};async function Yn(e){for(;D.locked;)await new Promise(t=>D.queue.push(t));D.locked=!0;try{let t=(Date.now()-He)/1e3;t<Ge&&await new Promise(o=>setTimeout(o,(Ge-t)*1e3));let n=await e();return He=Date.now(),n}finally{D.locked=!1;let t=D.queue.shift();t&&t()}}r(Yn,"rateLimitedCall");export{Bt as a,Re as b,Ie as c,ee as d,ot as e,x as f,k as g,S as h,C as i,M as j,U as k,q as l,pt as m,ln as n,I as o,Ne as p,u as q,kn as r,p as s,Sn as t,Mt as u,Cn as v,At as w,It as x,Mn as y,Tt as z,Dt as A,Lt as B,Nt as C,_n as D,$t as E,An as F,On as G,O as H,Rn as I,In as J,Tn as K,Dn as L,Kt as M,Ln as N,Nn as O,$n as P,fe as Q,Xt as R,ae as S,qt as T,jn as U,Kn as V,Fn as W,Ht as X,Xn as Y,Un as Z,qn as _,Wn as $,Gn as aa,Hn as ba,Vn as ca,Vt as da,zn as ea,zt as fa,Bn as ga,Jn as ha,Yn as ia};
259
+ `,c=`${t}.${process.pid}.${Date.now()}.tmp`,l=ie(c,"wx",384);try{Fe(l,a,"utf8"),$e(l)}finally{ne(l)}try{e.expectedRevision===null?(it(c,t),K(c)):Ke(c,t)}catch(g){throw d(c)&&K(c),e.expectedRevision===null&&d(t)?new k(t,void 0,De(t)):new Error(`Failed to atomically replace ${f.basename(t)}.`,{cause:g})}return _({domain:e.domain,source:"user",path:t,raw:a,document:n})}finally{ne(o.fd),d(o.path)&&K(o.path)}}r(I,"writeIntegrationDocument");function yt(e){if(!d(e))return"missing";let t=st(e);return`${t.dev}:${t.ino}:${t.size}:${t.mtimeMs}`}r(yt,"metadataSignature");function Le(e){return e.map(t=>`${t}:${yt(t)}`).join("|")}r(Le,"observationSignature");function j(e,t){return{code:e,message:t,time:new Date().toISOString()}}r(j,"safeDiagnostic");var Ne=class{static{r(this,"IntegrationConfigController")}#u;#n;#r;#a;#m;#f;#p;#e;#t;#c;#l;#h="";#s=[];#o;#i;#g=Promise.resolve();#d=new Set;constructor(t){this.#u=t.domain,this.#n=M(t.domain,t.configHome),this.#r=t.fallbackPath===void 0?void 0:f.resolve(t.fallbackPath),this.#a=this.#r===void 0?[this.#n]:[this.#n,this.#r],this.#f=t.validate,this.#m=t.read,this.#p=t.coldStartDefault===void 0?void 0:structuredClone(this.#f(t.coldStartDefault))}async initialize(){let t=await this.reload();if(!t.ok&&!this.#e&&this.#p!==void 0){let n=structuredClone(this.#p);this.#e=_({domain:this.#u,source:"default",path:this.#n,raw:JSON.stringify(n),document:n})}if(!this.#e)throw new Error(t.ok?"Integration configuration did not produce a snapshot.":t.error);return structuredClone(this.#e)}snapshot(){return this.#e?structuredClone(this.#e):void 0}status(){let t=this.#t?this.#c:void 0,n=this.#t?this.#l:void 0;return{domain:this.#u,path:t??this.#e?.path??this.#n,...this.#e?{revision:this.#e.revision,lastReloadAt:this.#e.loadedAt}:{},...n??this.#e?.source?{source:n??this.#e?.source}:{},...this.#t?{diagnostic:this.#t}:{},watching:this.#s.length>0}}subscribe(t){return this.#d.add(t),()=>{this.#d.delete(t)}}reload(){let t=this.#g.then(()=>this.#v());return this.#g=t.then(()=>{},()=>{}),t}async#v(){this.#h=Le(this.#a);let t;try{t=this.#m(),this.#f(t.document)}catch{let o=this.#y();return this.#c=o.path,this.#l=o.source,this.#t=j("invalid-config","Integration configuration is invalid; check the file against its versioned schema."),{ok:!1,error:this.#t.message}}let n=this.#e?structuredClone(this.#e):void 0;try{for(let o of this.#d)await o(structuredClone(t),n)}catch{return this.#c=t.path,this.#l=t.source,this.#t=j("activation-failed","Integration configuration could not be activated; the previous configuration remains active."),{ok:!1,error:this.#t.message}}return this.#e=t,this.#t=void 0,this.#c=void 0,this.#l=void 0,{ok:!0,snapshot:structuredClone(t)}}async ensureCurrent(){return Le(this.#a)===this.#h&&this.#e?{ok:!0,snapshot:structuredClone(this.#e)}:this.reload()}startWatching(t=100,n=2e3){if(this.#s.length>0||this.#i)return;re(f.dirname(this.#n),{recursive:!0,mode:448});let o=new Map;for(let i of this.#a){let s=f.dirname(i),a=o.get(s)??new Set;a.add(f.basename(i)),o.set(s,a)}for(let[i,s]of o)try{let a=at(i,(c,l)=>{l!==null&&!s.has(l.toString())||(this.#o&&clearTimeout(this.#o),this.#o=setTimeout(()=>{this.#o=void 0,this.reload()},t),this.#o.unref?.())});a.unref(),a.on("error",()=>{this.#t=j("watcher-degraded","Integration watcher is degraded; metadata polling remains active.")}),this.#s.push(a)}catch{this.#t=j("watcher-degraded","Integration watcher is degraded; metadata polling remains active.")}this.#i=setInterval(()=>{this.ensureCurrent()},n),this.#i.unref?.()}close(){this.#o&&clearTimeout(this.#o),this.#o=void 0,this.#i&&clearInterval(this.#i),this.#i=void 0;for(let t of this.#s)t.close();this.#s.length=0,this.#d.clear()}#y(){return d(this.#n)?{path:this.#n,source:"user"}:this.#r&&d(this.#r)?{path:this.#r,source:"legacy-user"}:{path:this.#n,source:"default"}}};var Pt=Et(wt),qe=2,We=!1,u=ke(),kn=h.join(u,"sessions"),p=h.join(u,"config.json"),Sn=60,v=null,ce=!1,kt="dumb";function St(e){let t=h.basename(e).toLowerCase(),n="__KODAX_SHELL_ENV_START__",o=`printf '%s\\0' '${n}'; env -0`;return t==="fish"?{args:["-i","-c",o],sentinel:n}:{args:t==="bash"||t==="zsh"?["-ic",o]:["-lc",o],sentinel:n}}r(St,"buildShellEnvCommand");function Ct(e,t){let n=`${t}\0`,o=e.lastIndexOf(n);if(o===-1)return{};let i=e.slice(o+n.length),s={};for(let a of i.split("\0")){if(!a)continue;let c=a.indexOf("=");c<=0||(s[a.slice(0,c)]=a.slice(c+1))}return s}r(Ct,"parseNullDelimitedShellEnv");function Mt(e={}){let t=e.env??process.env;if((e.platform??process.platform)==="win32"||t.KODAX_DISABLE_SHELL_ENV_HYDRATION==="1")return!1;let o=e.shell??t.SHELL;if(!o||!h.isAbsolute(o))return!1;let{args:i,sentinel:s}=St(o),a=e.run??xt,c={...t,TERM:kt},l=a(o,i,{encoding:"utf8",env:c,maxBuffer:1024*1024,timeout:5e3,windowsHide:!0,detached:!0,stdio:["ignore","pipe","pipe"]});if(l.status!==0||!l.stdout)return!1;let g=typeof l.stdout=="string"?l.stdout:l.stdout.toString("utf8"),N=Ct(g,s),$=!1;for(let[V,Je]of Object.entries(N))V!=="TERM"&&t[V]===void 0&&(t[V]=Je,$=!0);return $}r(Mt,"hydrateProcessEnvFromShell");function _t(){if(!ce){ce=!0;try{Mt()}catch{}}}r(_t,"ensureShellEnvironmentHydrated");function Cn(){ce=!1}r(Cn,"resetShellEnvironmentHydrationForTesting");function At(e){Ee(e.customProviders??[])}r(At,"registerConfiguredCustomProviders");function le(e){if(!Array.isArray(e))return;let t=e.filter(n=>typeof n=="string").map(n=>n.trim()).filter(n=>n.length>0);return t.length>0?t:[]}r(le,"normalizeConfiguredExtensions");function ue(){let e=m.readFileSync(p,"utf8"),t=JSON.parse(e);if(!(t===null||typeof t!="object"||Array.isArray(t)))return{raw:e,value:t}}r(ue,"readPersistedCoreConfig");function Ve(e){m.writeFileSync(p,JSON.stringify(e,null,2))}r(Ve,"writePersistedCoreConfig");function Ot(e){if(e.permissionMode!=="default")return e;let t={...e,permissionMode:"accept-edits"};try{x(p,()=>{let n=ue();n?.value.permissionMode==="default"&&Ve({...n.value,permissionMode:"accept-edits"})})}catch{}return t}r(Ot,"migrateLegacyPermissionModeInConfig");function Rt(e){if(e.permissionMode!=="auto-in-project")return e;try{x(p,()=>{let t=ue();if(t?.value.permissionMode!=="auto-in-project")return;let n=t.raw.replace(/("permissionMode"\s*:\s*)"auto-in-project"/,'$1"auto"');n!==t.raw&&m.writeFileSync(p,n)})}catch{}return{...e,permissionMode:"auto"}}r(Rt,"migrateAutoInProjectAliasInConfig");function It(){if(v)return v;let e="0.7.97-alpha.11";if(e)return v=e,v;let t=h.join(h.dirname(bt(import.meta.url)),"../../package.json");if(m.existsSync(t))try{return v=JSON.parse(m.readFileSync(t,"utf-8")).version??"0.0.0",v??"0.0.0"}catch{}return v="0.0.0",v}r(It,"getVersion");var Mn=It();function Tt(e){return ve(e)}r(Tt,"getProviderModel");function de(e,t){let n=new Set(e.map(i=>i.toLowerCase())),o=[...e];for(let i of t)n.has(i.toLowerCase())||o.push(i);return o}r(de,"mergeModels");function Dt(e,t){t||(t=fe().providerModels);let n=t?.[e];if(n&&n.length>0){try{let o=Y(e);if(o.length>0)return de(n,o)}catch{}try{let o=R(e);if(o)return de(n,o.getAvailableModels())}catch{}return n}try{let o=Y(e);if(o.length>0)return o}catch{}try{let o=R(e);if(o)return o.getAvailableModels()}catch{}return[]}r(Dt,"getProviderAvailableModels");function Lt(e,t){let n=ye(e,t);if(n!=="unknown")return n;try{let o=R(e);if(o)return o.getReasoningCapability(t)}catch{}return"unknown"}r(Lt,"getProviderReasoningCapability");function Nt(e){let t=we(e);if(t)return t;try{return Q().find(o=>o.name===e)?.capabilityProfile??null}catch{return null}}r(Nt,"getProviderCapabilityProfile");function ze(e,t){let n=Nt(e),o=Lt(e,t);if(n)return{capabilityProfile:n,reasoningCapability:o};try{let i=be(e);return{capabilityProfile:i.getCapabilityProfile(),reasoningCapability:i.getReasoningCapability(t)}}catch{return null}}r(ze,"getProviderCapabilityMetadata");function _n(e,t){let n=ze(e,t);return n?Me({providerName:e,model:t,capabilityProfile:n.capabilityProfile,reasoningCapability:n.reasoningCapability==="unknown"?void 0:n.reasoningCapability}):null}r(_n,"getProviderCapabilitySnapshot");function $t(e,t,n,o){let i=ze(e,t);return i?_e({providerName:e,model:t,capabilityProfile:i.capabilityProfile,reasoningCapability:i.reasoningCapability==="unknown"?void 0:i.reasoningCapability,reasoningMode:n,hints:o}):null}r($t,"getProviderPolicyDecision");function An(e){let t=e.transport==="cli-bridge"?"CLI bridge":"Native API",n=e.conversationSemantics==="last-user-message"?"forwards only the latest user message":"preserves full conversation history",o=e.mcpSupport==="native"?"MCP available":"MCP unavailable";return`${t}; ${n}; ${o}`}r(An,"describeProviderCapabilitySummary");function On(e){switch(e){case"native-budget":return"B";case"native-effort":return"E";case"native-toggle":return"T";case"native-adaptive":return"A";default:return"-"}}r(On,"formatReasoningCapabilityShort");function O(e){if(e)return e==="none"?"off":e}r(O,"formatReasoningEffortForDisplay");function W(e,t){let n=O(t);n&&!e.includes(n)&&e.push(n)}r(W,"pushUniqueEffortDisplay");function Rn(e,t,n){let o=["auto"],i=H(e,t,n),s=i?.supportedEfforts?.filter(a=>a.isUserVisible!==!1);if(!s||s.length===0){for(let a of["off","low","medium","high"])W(o,a);return o}for(let a of s)a.value==="none"&&i?.supportsDisabledThinking===!1||W(o,a.value);return o}r(Rn,"getProviderReasoningEffortOptions");function In(e,t){let n=H(e,t),o=new Set(n?.disabledEfforts??[]),i=n?.supportedEfforts?.filter(l=>l.isUserVisible!==!1),s=[],a=n?.supportsDisabledThinking===!0;if(!i||i.length===0){for(let l of["low","medium","high"])W(s,l);a=!0}else for(let l of i){if(l.value==="none"){n?.supportsDisabledThinking!==!1&&(a=!0);continue}if(o.has(l.value)){n?.supportsDisabledThinking!==!1&&(a=!0);continue}W(s,l.value)}let c=[];return a&&c.push("off"),c.push(...s),c.push("auto"),c}r(In,"getProviderReasoningEffortCycle");function jt(e,t){if(t===!1)return"off";switch(e){case"off":return"off";case"quick":return"low";case"balanced":return"medium";case"deep":return"high";default:return"auto"}}r(jt,"legacyReasoningModeToEffortDisplay");function H(e,t,n){let o=t??Tt(e);if(!o)return;let i=Pe(e,o)?.reasoningProfile;if(i)return me(i,Se(e,o,n))}r(H,"resolveReasoningProfileForDisplay");function Tn(e){let t=O(e.effort)??jt(e.reasoningMode,e.thinking),n=H(e.provider,e.model);if(!n)return t;try{let o=he({capability:n,explicitEffort:e.effortOverride?e.effort:void 0,sessionEffort:e.effortOverride?void 0:e.effort,legacyReasoningMode:e.reasoningMode,thinking:e.thinking}),i=O(o.configuredEffort)??t,a=o.configuredEffort!==void 0&&n.supportsDisabledThinking!==!1&&n.disabledEfforts?.includes(o.configuredEffort)===!0?"off":O(o.effectiveEffort);return a&&a!==i?`${i}->${a}`:i}catch{if(e.effort)try{let o=J({currentEffort:e.effort,capability:n}),i=O(e.effort)??t,s=O(o.effectiveEffort);return s&&s!==i?`${i}->${s}`:i}catch{return t}return t}}r(Tn,"formatReasoningEffortStatusLabel");function Dn(e){let t=Vt(e);if(!t)return{preserved:!0};let n=H(e.provider,e.model);if(!n)return{configuredEffort:t,runtimeEffort:t,preserved:!0};let o=J({currentEffort:t,capability:n});return{configuredEffort:t,runtimeEffort:o.effectiveEffort,preserved:o.preserved,diagnostic:o.diagnostic}}r(Dn,"resolveProviderReasoningRuntimeEffort");function Kt(e){switch(e){case"native-budget":return"budget";case"native-effort":return"effort";case"native-toggle":return"toggle";case"native-adaptive":return"adaptive";default:return"none"}}r(Kt,"describeReasoningCapabilityControl");function Ln(e,t){if(e==="off")return"Reasoning disabled";switch(t){case"native-budget":return"Uses native thinking budget control";case"native-effort":return"Uses native reasoning effort control";case"native-toggle":return"Uses provider-native thinking toggle only";case"native-adaptive":return"Model adaptively decides thinking depth (Opus 4.7+)";case"none":return"Runs without native reasoning parameters";case"prompt-only":return"Uses prompt overlays only; no native reasoning parameter";default:return"Runs without native reasoning parameters"}}r(Ln,"describeReasoningExecution");function Nn(e){let t=[];e||(e=fe().providerModels);for(let n of xe())t.push({name:n.name,model:n.model,models:Dt(n.name,e),configured:n.capabilityProfile.transport==="cli-bridge"?!0:n.configured,reasoningCapability:n.reasoningCapability,capabilityProfile:n.capabilityProfile});try{let n=Q().map(o=>({...o,models:(()=>{let i=e?.[o.name];return i&&i.length>0?de(i,o.models):o.models})()}));t.push(...n)}catch{}return t}r(Nn,"getProviderList");function $n(e){if(ge(e))return!0;try{return R(e)?.isConfigured()??!1}catch{return!1}}r($n,"isProviderConfigured");var G=class extends Error{static{r(this,"InvalidAgentModeConfigError")}};function Ft(e){let t=e.agentMode;if(t===void 0||t==="ama"||t==="sa")return e;if(t!=="amaw"&&t!=="ama-workflow")throw new G(`Invalid agentMode "${t}" in ${p}. Expected "ama" or "sa".`);let n={...e,agentMode:"ama",schemaVersion:Math.max(e.schemaVersion??0,qe)};try{x(p,()=>{let o=ue();if(!o)return;let i=o.value.agentMode;i!=="amaw"&&i!=="ama-workflow"||Ve({...o.value,agentMode:"ama",schemaVersion:Math.max(typeof o.value.schemaVersion=="number"?o.value.schemaVersion:0,qe)})})}catch{}return We||(process.emitWarning(`Migrated persisted agentMode "${t}" to "ama". Workflow use is now explicit intent.`,{code:"KODAX_AGENT_MODE_MIGRATED"}),We=!0),n}r(Ft,"migrateLegacyAgentModeConfig");function fe(){try{if(m.existsSync(p)){let n=JSON.parse(m.readFileSync(p,"utf-8")),o=Ft(n),i=o.reasoningCeiling??o.reasoningMode,s=[],a={};try{s=[...q(u).document.paths]}catch{}try{a=U(u).document.servers}catch{}let{sandbox:c,...l}=o;return Rt(Ot({...l,reasoningMode:i,extensions:le(s),mcpServers:a}))}}catch(n){if(n instanceof G)throw n}let e,t;try{let n=q(u);n.source!=="default"&&(e=le([...n.document.paths]))}catch{}try{let n=U(u);n.source!=="default"&&(t=n.document.servers)}catch{}return{...e===void 0?{}:{extensions:e},...t===void 0?{}:{mcpServers:t}}}r(fe,"loadConfig");var Xt=h.join(u,"config.example.jsonc"),ae={mcp:h.join(u,"integrations","mcp.example.jsonc"),a2a:h.join(u,"integrations","a2a.example.jsonc"),extensions:h.join(u,"integrations","extensions.example.jsonc")},Ut=[{name:"core",path:Xt},{name:"mcp",path:ae.mcp},{name:"a2a",path:ae.a2a},{name:"extensions",path:ae.extensions}];function qt(){let e=[];for(let t of Ut)try{if(m.existsSync(t.path))continue;m.mkdirSync(h.dirname(t.path),{recursive:!0}),m.writeFileSync(t.path,Ie(t.name),"utf8"),e.push(t.path)}catch{}return e}r(qt,"ensureExampleConfigFiles");function jn(){return qt()[0]}r(jn,"ensureExampleConfigFile");var L=new Map;function Kn(e){let t=process.env[e];return t===void 0?"unset":L.get(e)===t?"persisted":"environment"}r(Kn,"inspectConfigEnvironmentSource");function Be(e,t,n=!1){let o=process.env[e],i=L.get(e),s=i!==void 0&&o===i;if(o!==void 0&&!s&&!n){L.delete(e);return}if(t===void 0){(s||n)&&delete process.env[e],L.delete(e);return}process.env[e]=t,L.set(e,t)}r(Be,"projectConfigEnvironment");var pe=[{configPath:"streamIdleTimeoutMs",env:"KODAX_STREAM_IDLE_TIMEOUT_MS",value:r(e=>b(e.streamIdleTimeoutMs),"value")},{configPath:"repoIntelligenceMode",env:"KODAX_REPO_INTELLIGENCE",value:r(e=>e.repoIntelligenceMode,"value")},{configPath:"repoIntelligenceTrace",env:"KODAX_REPO_INTELLIGENCE_TRACE",value:r(e=>T(e.repoIntelligenceTrace),"value")},{configPath:"stallLog",env:"KODAX_STALL_LOG",value:r(e=>T(e.stallLog),"value")},{configPath:"fallbackProviders",env:"KODAX_FALLBACK_PROVIDERS",value:r(e=>Gt(e.fallbackProviders),"value")},{configPath:"fastProvider",env:"KODAX_FAST_PROVIDER",value:r(e=>y(e.fastProvider),"value")},{configPath:"fastModel",env:"KODAX_FAST_MODEL",value:r(e=>y(e.fastModel),"value")},{configPath:"deepProvider",env:"KODAX_DEEP_PROVIDER",value:r(e=>y(e.deepProvider),"value")},{configPath:"deepModel",env:"KODAX_DEEP_MODEL",value:r(e=>y(e.deepModel),"value")},{configPath:"provider",env:"KODAX_PROVIDER",value:r(e=>y(e.provider),"value")},{configPath:"effort",env:"KODAX_EFFORT",value:r(e=>y(e.effort),"value")},{configPath:"sessionRetentionDays",env:"KODAX_SESSION_RETENTION_DAYS",value:r(e=>b(e.sessionRetentionDays),"value")},{configPath:"maxOutputTokens",env:"KODAX_MAX_OUTPUT_TOKENS",value:r(e=>b(e.maxOutputTokens),"value")},{configPath:"disablePromptCache",env:"KODAX_DISABLE_PROMPT_CACHE",value:r(e=>T(e.disablePromptCache),"value")},{configPath:"lsp",env:"KODAX_LSP",value:r(e=>T(e.lsp),"value")},{configPath:"lspAutoDownload",env:"KODAX_LSP_DOWNLOAD",value:r(e=>T(e.lspAutoDownload),"value")},{configPath:"acpLogLevel",env:"KODAX_ACP_LOG",value:r(e=>y(e.acpLogLevel),"value")},{configPath:"repoIntelligence.toolWaitMs",env:"KODAX_REPO_INTELLIGENCE_TOOL_WAIT_MS",value:r(e=>b(e.repoIntelligence?.toolWaitMs),"value")},{configPath:"repoIntelligence.workerTimeoutMs",env:"KODAX_REPO_INTELLIGENCE_WORKER_TIMEOUT_MS",value:r(e=>b(e.repoIntelligence?.workerTimeoutMs),"value")},{configPath:"repoIntelligence.workerOldSpaceMb",env:"KODAX_REPO_INTELLIGENCE_WORKER_OLD_SPACE_MB",value:r(e=>b(e.repoIntelligence?.workerOldSpaceMb),"value")},{configPath:"repoIntelligence.storageDir",env:"KODAX_REPO_INTELLIGENCE_STORAGE_DIR",value:r(e=>y(e.repoIntelligence?.storageDir),"value")},{configPath:"workflow.maxConcurrency",env:"KODAX_WORKFLOW_MAX_CONCURRENCY",value:r(e=>b(e.workflow?.maxConcurrency),"value")}];function Wt(e){for(let t of pe)Be(t.env,t.value(e))}r(Wt,"applyConfigSurfaceBridges");function y(e){return e?.trim()||void 0}r(y,"normalizedConfigString");function b(e){return typeof e=="number"&&Number.isFinite(e)?String(e):void 0}r(b,"configNumberString");function T(e){return e===void 0?void 0:e?"1":"0"}r(T,"configBooleanString");function Gt(e){return e?.filter(t=>t.trim().length>0).join(",")}r(Gt,"configStringList");var Fn=[...pe.map(({configPath:e,env:t})=>({configPath:e,env:t}))];function Ht(e){Wt(e)}r(Ht,"applyConfigEnvironment");function Xn(e,t=!1){for(let n of pe)["fallbackProviders","stallLog"].includes(n.configPath)&&(t&&!Object.hasOwn(e,n.configPath)||Be(n.env,n.value(e),t))}r(Xn,"applyExecutionConfigEnvironment");function Un(){_t();let e=fe();return Ht(e),At(e),Oe(e.locale),e}r(Un,"prepareRuntimeConfig");function qn(e){let{extensions:t,mcpServers:n,...o}=e;if(x(p,()=>{let i={};if(m.existsSync(p))try{let a=JSON.parse(m.readFileSync(p,"utf8"));a&&typeof a=="object"&&!Array.isArray(a)&&(i=a)}catch{}let s={...i,...o};for(let a of Object.keys(o))o[a]===void 0&&delete s[a];m.writeFileSync(p,JSON.stringify(s,null,2))}),t!==void 0){let i=q(u);I({domain:"extensions",configHome:u,...i.source==="user"?{expectedRevision:i.revision}:{},document:{version:1,paths:le(t)??[]},validate:C})}if(n!==void 0){let i=U(u);I({domain:"mcp",configHome:u,...i.source==="user"?{expectedRevision:i.revision}:{},document:{version:1,servers:n},validate:S})}}r(qn,"saveConfig");function Wn(e,t,n){return e.effort!==void 0||B(n).kind==="value"||t.effort!==void 0}r(Wn,"resolveInitialEffortOverride");function w(e){return e?.trim()?e:void 0}r(w,"nonEmptySelection");function Gn(e){return w(e.explicitProvider)??w(e.environmentProvider)??w(e.configuredProvider)??e.defaultProvider}r(Gn,"resolveRuntimeProviderSelection");function Hn(e){let t=w(e.explicitModel);if(t)return t;let n=w(e.configuredModel);if(!n)return;let o=w(e.explicitProvider)??w(e.environmentProvider);return o?w(e.configuredProvider)===o?n:void 0:n}r(Hn,"resolveRuntimeModelSelection");function Vn(e){if(e.explicitEffort!==void 0)return z(e.explicitEffort);let t=B(e.environmentEffort);return t.kind==="value"?t.value:e.configuredEffort===void 0?void 0:z(e.configuredEffort)}r(Vn,"resolveRuntimeEffortSelection");function Vt(e){return e.permissionMode==="plan"&&e.effortOverride!==!0&&e.planModeEffort!==void 0?e.planModeEffort:e.effort}r(Vt,"resolvePermissionModeEffort");async function zn(e){try{await Ce({cwd:e});let{stdout:t}=await Pt("git rev-parse --show-toplevel",{cwd:e,windowsHide:!0});return t.trim()}catch{return null}}r(zn,"getGitRoot");function zt(e){switch(e){case"builtin":return"Built-in";case"runtime":return"Runtime extension";case"custom":return"Custom config";default:return"Unknown"}}r(zt,"formatProviderSourceKind");function Bn(e){let t=e.transport==="cli-bridge"?"CLI bridge":"Native API",n=e.conversationSemantics==="last-user-message"?"latest-user-message only":"full conversation history";return[`Source: ${zt(e.sourceKind)}`,`Transport: ${t}`,`Conversation semantics: ${n}`,`Context fidelity: ${e.contextFidelity}`,`Tool calling: ${e.toolCallingFidelity}`,`Session behavior: ${e.sessionSupport}`,`Long-running support: ${e.longRunningSupport}`,`Evidence-heavy flows: ${e.evidenceSupport}`,`Multimodal support: ${e.multimodalSupport}`,`MCP support: ${e.mcpSupport}`,`Reasoning control: ${Kt(e.reasoningCapability)}`]}r(Bn,"formatProviderCapabilityDetailLines");function Jn(e,t,n){return[{label:"General coding",hints:{}},{label:"Evidence-heavy review",hints:{evidenceHeavy:!0}},{label:"Long-running task",hints:{longRunning:!0}}].map(i=>({label:i.label,decision:$t(e,t,n,i.hints)})).filter(i=>i.decision!==null)}r(Jn,"getProviderCommonPolicyScenarios");var Ge=.5,He=0,D={locked:!1,queue:[]};async function Yn(e){for(;D.locked;)await new Promise(t=>D.queue.push(t));D.locked=!0;try{let t=(Date.now()-He)/1e3;t<Ge&&await new Promise(o=>setTimeout(o,(Ge-t)*1e3));let n=await e();return He=Date.now(),n}finally{D.locked=!1;let t=D.queue.shift();t&&t()}}r(Yn,"rateLimitedCall");export{Bt as a,Re as b,Ie as c,ee as d,ot as e,x as f,k as g,S as h,C as i,M as j,U as k,q as l,pt as m,ln as n,I as o,Ne as p,u as q,kn as r,p as s,Sn as t,Mt as u,Cn as v,At as w,It as x,Mn as y,Tt as z,Dt as A,Lt as B,Nt as C,_n as D,$t as E,An as F,On as G,O as H,Rn as I,In as J,Tn as K,Dn as L,Kt as M,Ln as N,Nn as O,$n as P,fe as Q,Xt as R,ae as S,qt as T,jn as U,Kn as V,Fn as W,Ht as X,Xn as Y,Un as Z,qn as _,Wn as $,Gn as aa,Hn as ba,Vn as ca,Vt as da,zn as ea,zt as fa,Bn as ga,Jn as ha,Yn as ia};
@@ -1,5 +1,5 @@
1
1
  // @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
2
- import{C as D,I as F}from"./chunk-6YC6F7I5.js";import{c as q,d as j,e as N,f as P}from"./chunk-FROQFYUD.js";import{ua as C}from"./chunk-GBK65DAI.js";import{se as $,te as k,ue as y,xe as _,ye as b,ze as x}from"./chunk-FSV2UNZK.js";import{nb as W,ob as M,tb as I}from"./chunk-U7XIL752.js";import{D as v,E as T,Gb as O,mb as E}from"./chunk-EV2DZBK6.js";import{a as o}from"./chunk-ONUPGMER.js";import{join as Le}from"node:path";var ae=["You generate KodaX Dynamic Workflow scripts.","Return JSON only. Do not wrap the answer in prose.","For simple tasks that do not benefit from multiple agents, return:",'{"action":"decline","reason":"..."}',"For complex tasks, return:",'{"action":"generate","manifest":{...},"source":"async function run(wf, args) { ... }","approvalSummary":"..."}',"Generated source may only coordinate agents through wf and args.","Generated source must return displayable final text for the user.","Never use import, require, process, fs, child_process, network APIs, shell commands, or direct file access."].join(`
2
+ import{C as D,I as F}from"./chunk-76UPX4CI.js";import{c as q,d as j,e as N,f as P}from"./chunk-USAJGDW3.js";import{va as C}from"./chunk-ULA453FO.js";import{Ae as x,te as $,ue as k,ve as y,ye as _,ze as b}from"./chunk-UFWK2OOJ.js";import{nb as W,ob as M,tb as I}from"./chunk-VA5GQNHW.js";import{D as v,E as T,Gb as O,mb as E}from"./chunk-7PBG4SST.js";import{a as o}from"./chunk-ONUPGMER.js";import{join as Le}from"node:path";var ae=["You generate KodaX Dynamic Workflow scripts.","Return JSON only. Do not wrap the answer in prose.","For simple tasks that do not benefit from multiple agents, return:",'{"action":"decline","reason":"..."}',"For complex tasks, return:",'{"action":"generate","manifest":{...},"source":"async function run(wf, args) { ... }","approvalSummary":"..."}',"Generated source may only coordinate agents through wf and args.","Generated source must return displayable final text for the user.","Never use import, require, process, fs, child_process, network APIs, shell commands, or direct file access."].join(`
3
3
  `),G=12e4,le="KODAX_WORKFLOW_GENERATION_TIMEOUT_SEC",ce="KODAX_WORKFLOW_GENERATION_TIMEOUT_MS",ue=64,fe=2,de=2e3,pe=[{name:"default"},{name:"variant-results",finalText:o((e,n)=>`Variant smoke child report from ${e} (${n}).`,"finalText"),synthesizeText:"Variant smoke synthesis report."},{name:"unverified-success",status:o(()=>"completed_unverified","status"),finalText:o(e=>`Smoke result for ${e}: completed with verification warnings.`,"finalText"),synthesizeText:"Smoke synthesis: completed with verification warnings."},{name:"empty-args-rerun",args:o(()=>({}),"args")}],me=[{id:"import",pattern:/\bimport\s*(?:\(|['"*{]|\w+\s+from\b)/},{id:"require",pattern:/\brequire\s*\(/},{id:"process",pattern:/\bprocess\s*(?:\.|\[)/},{id:"fs",pattern:/\b(?:node:)?fs\b/},{id:"child_process",pattern:/\bchild_process\b/},{id:"shell",pattern:/\b(?:exec|spawn|execFile)\s*\(/},{id:"fetch",pattern:/\bfetch\s*\(/},{id:"Deno",pattern:/\bDeno\s*(?:\.|\[)/},{id:"Bun",pattern:/\bBun\s*(?:\.|\[)/},{id:"globalThis-index",pattern:/\bglobalThis\s*\[/}];function we(e=process.env,n){let t=v(n?.workflow?.generationTimeoutSec,"timeouts.workflow.generationTimeoutSec");if(t!==void 0)return t;let r=T(e[le]);if(r!==void 0)return r;let s=e[ce];if(s===void 0||s.trim().length===0)return G;let i=Number(s);return!Number.isFinite(i)||i<=0?G:Math.floor(i)}o(we,"resolveWorkflowGenerationTimeoutMs");function he(e,n){if(typeof e!="object"||e===null)throw new Error(`${n} must be an object`);return e}o(he,"readRecord");function K(e,n){let t=e[n];if(typeof t!="string"||t.trim().length===0)throw new Error(`workflow generation ${n} must be a non-empty string`);return t}o(K,"readNonEmptyString");function ge(e){let n=e.trim(),t=/^```(?:json)?\s*([\s\S]*?)\s*```$/i.exec(n);if(t?.[1])return t[1].trim();let r=n.indexOf("{"),s=n.lastIndexOf("}");if(r>=0&&s>r)return n.slice(r,s+1);throw new Error("workflow generation output did not contain a JSON object")}o(ge,"extractJsonText");function ke(e){let n=ge(e);return he(JSON.parse(n),"workflow generation output")}o(ke,"parseGenerationJson");function ye(e){if(typeof e=="string"){let t=e.trim();return t.length>0?t:void 0}if(typeof e!="object"||e===null)return;let n=e;for(let t of["name","id","title","phase"]){let r=n[t];if(typeof r=="string"&&r.trim().length>0)return r.trim()}}o(ye,"normalizePhaseEntry");function be(e){return e.split(/(?:->|\u2192|,|\n)/).map(n=>n.trim()).filter(n=>n.length>0)}o(be,"splitPhaseString");function xe(e){if(typeof e!="object"||e===null)return e;let n=e,t=n.phases,r;if(Array.isArray(t)){let s=t.map(ye);s.every(i=>i!==void 0)&&(r=s)}else if(typeof t=="string"){let s=be(t);s.length>0&&(r=s)}return r?{...n,phases:r}:e}o(xe,"normalizeGeneratedManifestCandidate");function ve(e){return e.match(/\bwf\.(?:runAgent|spawnAgent|synthesize)\s*\(/g)?.length??0}o(ve,"estimateDirectAgentCalls");function Se(e,n){let t=e.maxConcurrency*Math.max(1,e.phases.length)+2,r=ve(n)+2,s=Math.min(ue,Math.max(e.maxAgents,t,r));return s>e.maxAgents?{...e,maxAgents:s}:e}o(Se,"reserveGeneratedWorkflowAgentCapacity");function w(e){let n="",t=0,r=["code"],s=[0];for(;t<e.length;){let i=e[t],a=e[t+1];if(r[r.length-1]==="template"){if(i==="\\"){n+=" ",t+=2;continue}if(i==="`"){n+=" ",t+=1,r.pop(),s.pop();continue}if(i==="$"&&a==="{"){n+=" ",t+=2,r.push("code"),s.push(0);continue}n+=i===`
4
4
  `?`
5
5
  `:" ",t+=1;continue}if(i==="/"&&a==="/"){for(n+=" ",t+=2;t<e.length&&e[t]!==`
@@ -1,5 +1,5 @@
1
1
  // @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
2
- import{a as L,b as ne,m as de,p as X,q as ue,r as le}from"./chunk-FROQFYUD.js";import{Rb as ae,Sb as ie,Vb as se,Wb as ce}from"./chunk-GBK65DAI.js";import{b as J,j as oe}from"./chunk-U7XIL752.js";import{a as s}from"./chunk-ONUPGMER.js";import{execFile as Pe}from"node:child_process";import V from"node:path";import{promisify as Re}from"node:util";var be=Re(Pe),xe=1e4,ke=2,fe=new Set(["write","edit","multi_edit","insert_after_anchor"]),me=new Set(["read"]);function Ce(e,t){if(t.includes("*"))return e;if(e.includes("*"))return t;let r=new Set(t);return e.filter(c=>r.has(c))}s(Ce,"intersectWorkflowToolCeilings");var Se=/^\s*(?:let me|i will|i'll|i am going to)\b[\s\S]{0,120}\b(?:start|create|implement|write|build|plan)\b|^\s*(?:我将|让我|接下来)[\s\S]{0,80}(?:开始|创建|编写|实现|制定)/i;async function ot(e,t,r){let c=e.turn.checkpoint;if(!c||typeof c!="object"||Array.isArray(c)||!("workflow"in c))throw new Error("Workflow generation recovery instructions are missing.");let i=c.workflow;if(!i||i.customExecutor||!i.bundle||!i.input||!i.childOptions||!i.changedPathBaseline||!i.mutation)throw new Error("Workflow generation recovery requires its original executor binding.");let h=De({ctx:t,recovery:{execution:e,snapshot:i},runId:i.runId,childOptions:{...i.childOptions,historyStorage:r.session?.storage,guardrails:t.guardrails,planModeBlockCheck:t.planModeBlockCheck,parentOptions:{...r,extensionRuntime:t.extensionRuntime,events:t.parentEvents}}}),b=await h.spawn(i.input),x=await h.wait(b.taskId);if(x.status!=="completed"&&x.status!=="completed_unverified")throw new Error(x.finalText);return{output:x.finalText,structured:X(JSON.parse(JSON.stringify({workflowRunId:i.runId,taskId:b.taskId,actorPath:e.actor.path,turnId:e.turn.turnId,result:x}))),artifacts:x.artifacts}}s(ot,"resumeWorkflowGenerationTurn");function Ie(e){if(e?.timeoutMs!==void 0){if(!Number.isFinite(e.timeoutMs)||e.timeoutMs<=0)throw new Error("workflow wait timeoutMs must be a positive number");return Math.floor(e.timeoutMs)}}s(Ie,"normalizeWaitTimeoutMs");function Z(e){return e?.requiresMutation===!0||(e?.requiredChangedPaths?.length??0)>0}s(Z,"hasVerificationWork");function q(e){return e.replace(/\\/g,"/").replace(/^\.\//,"").trim()}s(q,"normalizeWorkspacePath");function Y(e,t){let r=t.gitRoot?V.resolve(t.gitRoot):void 0,c=V.isAbsolute(e)&&r?V.relative(r,V.resolve(e)):e;return q(c)}s(Y,"normalizeRequiredPath");function Fe(e){let t=(e.readOnly??!1)===!1?{enforcement:"warn",requiresMutation:!0,rejectPreparatoryFinalText:!0}:void 0;if(e.verification!==void 0){let r={...t??{},...e.verification,enforcement:e.verification.enforcement??"hard"},c=e.verification.requiredChangedPaths;return{verification:{...r,...c!==void 0&&c.length>0&&r.requiresMutation===void 0?{requiresMutation:!0}:{}}}}return{verification:t}}s(Fe,"resolveVerificationForInput");function Ee(e,t){if(t===!0&&e.readOnly===!1)throw new Error(`workflow manifest readOnly=true cannot spawn write-capable child "${e.name}"; set the workflow manifest readOnly=false or use child readOnly:true`);let r=e.readOnly??t??!1;return e.readOnly===r?e:{...e,readOnly:r}}s(Ee,"resolveSpawnAgentInput");function ye(e){let t=e.trim();return t.length>0&&Se.test(t)}s(ye,"isPreparatoryOnlyText");function Ae(e,t){let r=e.trim(),c=t?.trim();return c&&(r.length===0||ye(r))?c:e}s(Ae,"selectWorkflowFinalText");async function G(e,t){return await oe({cwd:t}),(await be("git",[...e],{cwd:t,timeout:xe,windowsHide:!0,maxBuffer:4*1024*1024})).stdout.toString()}s(G,"runGit");async function Me(e){let t=e.gitRoot??e.executionCwd??process.cwd(),r=(await G(["rev-parse","--show-toplevel"],t)).trim(),c=await Promise.all([G(["diff","--name-only","--"],r),G(["diff","--cached","--name-only","--"],r),G(["ls-files","--others","--exclude-standard"],r)]);return[...new Set(c.flatMap(i=>i.split(/\r?\n/)).map(q).filter(i=>i.length>0))]}s(Me,"listGitChangedFiles");async function Q(e,t){try{return{paths:(await t(e)).map(q).filter(c=>c.length>0)}}catch(r){return{paths:[],error:r instanceof Error?r.message:String(r)}}}s(Q,"captureChangedPaths");function Oe(){return{toolNameById:new Map,toolPathById:new Map,succeededToolCalls:[],succeededPaths:[],readPathById:new Map,succeededReadPaths:[]}}s(Oe,"createMutationRecorder");function he(e){if(e)for(let t of["path","file_path","target_path"]){let r=e[t];if(typeof r=="string"&&r.trim().length>0)return q(r)}}s(he,"readMutationPath");function Ue(e,t){return{...e??{},onToolUseStart:s((r,c)=>{if(fe.has(r.name)){t.toolNameById.set(r.id,r.name);let i=he(r.input);i!==void 0&&t.toolPathById.set(r.id,i)}if(me.has(r.name)){let i=he(r.input);i!==void 0&&t.readPathById.set(r.id,i)}e?.onToolUseStart?.(r,c)},"onToolUseStart"),onToolResult:s((r,c)=>{let i=t.toolNameById.get(r.id)??r.name;if(fe.has(i)&&!r.content.trimStart().startsWith("[Tool Error]")){t.succeededToolCalls.push(i);let h=t.toolPathById.get(r.id);h!==void 0&&t.succeededPaths.push(h)}if(me.has(i)&&!r.content.trimStart().startsWith("[Tool Error]")){let h=t.readPathById.get(r.id);h!==void 0&&t.succeededReadPaths.push(h)}e?.onToolResult?.(r,c)},"onToolResult")}}s(Ue,"wrapEventsForMutationRecording");function K(e){return[...new Set(e.filter(t=>t.trim().length>0))]}s(K,"uniqueItems");function pe(e){let t=e.verification;if(!t)return;let r=[],c=new Set(e.before.paths.map(q)),i=K(e.after.paths.map(q)),h=i.filter(y=>!c.has(y)),b=K(e.mutationRecorder.succeededToolCalls),x=e.acceptToolMutationEvidence?b:[],N=e.acceptToolMutationEvidence?K(e.mutationRecorder.succeededPaths.map(q)):[],M=h.length>0||x.length>0,S=t.enforcement??"hard",W=(t.requiredChangedPaths??[]).map(y=>Y(y,e.ctx)),_=K(e.mutationRecorder.succeededReadPaths.map(y=>Y(y,e.ctx))),z=(t.requiredReadPaths??[]).map(y=>Y(y,e.ctx));t.requiresMutation===!0&&(e.before.error!==void 0||e.after.error!==void 0?r.push(`workspace mutation verification could not read changed files: ${e.after.error??e.before.error}`):M||r.push(e.acceptToolMutationEvidence||b.length===0?"expected file mutations, but no new workspace changes or successful write tools were observed":"write tools ran in an isolated worktree, but no main workspace changes were present after cleanup")),e.term.limitReached===!0&&!M&&r.push("workflow child reached its iteration limit before satisfying the task");for(let y of W)!i.includes(y)&&!N.includes(y)&&r.push(`required changed path was not present in workspace changes: ${y}`);for(let y of z)_.includes(y)||r.push(`required review evidence was not read: ${y}`);let B=t.minFinalTextChars;return B!==void 0&&!M&&e.term.finalText.trim().length<B&&r.push(`finalText was shorter than the required ${B} characters`),t.rejectPreparatoryFinalText===!0&&!M&&ye(e.term.finalText)&&r.push("finalText looks preparatory instead of terminal"),{ok:r.length===0,enforcement:S,reasons:r,changedPaths:i,mutationToolCalls:b,mutationEvidence:M,..._.length>0?{readPaths:_}:{}}}s(pe,"evaluateVerification");function ee(e,t){if(t.ok)return e;let c=[t.enforcement==="warn"?"[Workflow task completed without verification]":"[Workflow task verification failed]",...t.reasons.map(i=>`- ${i}`)].join(`
2
+ import{a as L,b as ne,m as de,p as X,q as ue,r as le}from"./chunk-USAJGDW3.js";import{$b as se,Xb as ae,Yb as ie,ac as ce}from"./chunk-ULA453FO.js";import{b as J,j as oe}from"./chunk-VA5GQNHW.js";import{a as s}from"./chunk-ONUPGMER.js";import{execFile as Pe}from"node:child_process";import V from"node:path";import{promisify as Re}from"node:util";var be=Re(Pe),xe=1e4,ke=2,fe=new Set(["write","edit","multi_edit","insert_after_anchor"]),me=new Set(["read"]);function Ce(e,t){if(t.includes("*"))return e;if(e.includes("*"))return t;let r=new Set(t);return e.filter(c=>r.has(c))}s(Ce,"intersectWorkflowToolCeilings");var Se=/^\s*(?:let me|i will|i'll|i am going to)\b[\s\S]{0,120}\b(?:start|create|implement|write|build|plan)\b|^\s*(?:我将|让我|接下来)[\s\S]{0,80}(?:开始|创建|编写|实现|制定)/i;async function ot(e,t,r){let c=e.turn.checkpoint;if(!c||typeof c!="object"||Array.isArray(c)||!("workflow"in c))throw new Error("Workflow generation recovery instructions are missing.");let i=c.workflow;if(!i||i.customExecutor||!i.bundle||!i.input||!i.childOptions||!i.changedPathBaseline||!i.mutation)throw new Error("Workflow generation recovery requires its original executor binding.");let h=De({ctx:t,recovery:{execution:e,snapshot:i},runId:i.runId,childOptions:{...i.childOptions,historyStorage:r.session?.storage,guardrails:t.guardrails,planModeBlockCheck:t.planModeBlockCheck,parentOptions:{...r,extensionRuntime:t.extensionRuntime,events:t.parentEvents}}}),b=await h.spawn(i.input),x=await h.wait(b.taskId);if(x.status!=="completed"&&x.status!=="completed_unverified")throw new Error(x.finalText);return{output:x.finalText,structured:X(JSON.parse(JSON.stringify({workflowRunId:i.runId,taskId:b.taskId,actorPath:e.actor.path,turnId:e.turn.turnId,result:x}))),artifacts:x.artifacts}}s(ot,"resumeWorkflowGenerationTurn");function Ie(e){if(e?.timeoutMs!==void 0){if(!Number.isFinite(e.timeoutMs)||e.timeoutMs<=0)throw new Error("workflow wait timeoutMs must be a positive number");return Math.floor(e.timeoutMs)}}s(Ie,"normalizeWaitTimeoutMs");function Z(e){return e?.requiresMutation===!0||(e?.requiredChangedPaths?.length??0)>0}s(Z,"hasVerificationWork");function q(e){return e.replace(/\\/g,"/").replace(/^\.\//,"").trim()}s(q,"normalizeWorkspacePath");function Y(e,t){let r=t.gitRoot?V.resolve(t.gitRoot):void 0,c=V.isAbsolute(e)&&r?V.relative(r,V.resolve(e)):e;return q(c)}s(Y,"normalizeRequiredPath");function Fe(e){let t=(e.readOnly??!1)===!1?{enforcement:"warn",requiresMutation:!0,rejectPreparatoryFinalText:!0}:void 0;if(e.verification!==void 0){let r={...t??{},...e.verification,enforcement:e.verification.enforcement??"hard"},c=e.verification.requiredChangedPaths;return{verification:{...r,...c!==void 0&&c.length>0&&r.requiresMutation===void 0?{requiresMutation:!0}:{}}}}return{verification:t}}s(Fe,"resolveVerificationForInput");function Ee(e,t){if(t===!0&&e.readOnly===!1)throw new Error(`workflow manifest readOnly=true cannot spawn write-capable child "${e.name}"; set the workflow manifest readOnly=false or use child readOnly:true`);let r=e.readOnly??t??!1;return e.readOnly===r?e:{...e,readOnly:r}}s(Ee,"resolveSpawnAgentInput");function ye(e){let t=e.trim();return t.length>0&&Se.test(t)}s(ye,"isPreparatoryOnlyText");function Ae(e,t){let r=e.trim(),c=t?.trim();return c&&(r.length===0||ye(r))?c:e}s(Ae,"selectWorkflowFinalText");async function G(e,t){return await oe({cwd:t}),(await be("git",[...e],{cwd:t,timeout:xe,windowsHide:!0,maxBuffer:4*1024*1024})).stdout.toString()}s(G,"runGit");async function Me(e){let t=e.gitRoot??e.executionCwd??process.cwd(),r=(await G(["rev-parse","--show-toplevel"],t)).trim(),c=await Promise.all([G(["diff","--name-only","--"],r),G(["diff","--cached","--name-only","--"],r),G(["ls-files","--others","--exclude-standard"],r)]);return[...new Set(c.flatMap(i=>i.split(/\r?\n/)).map(q).filter(i=>i.length>0))]}s(Me,"listGitChangedFiles");async function Q(e,t){try{return{paths:(await t(e)).map(q).filter(c=>c.length>0)}}catch(r){return{paths:[],error:r instanceof Error?r.message:String(r)}}}s(Q,"captureChangedPaths");function Oe(){return{toolNameById:new Map,toolPathById:new Map,succeededToolCalls:[],succeededPaths:[],readPathById:new Map,succeededReadPaths:[]}}s(Oe,"createMutationRecorder");function he(e){if(e)for(let t of["path","file_path","target_path"]){let r=e[t];if(typeof r=="string"&&r.trim().length>0)return q(r)}}s(he,"readMutationPath");function Ue(e,t){return{...e??{},onToolUseStart:s((r,c)=>{if(fe.has(r.name)){t.toolNameById.set(r.id,r.name);let i=he(r.input);i!==void 0&&t.toolPathById.set(r.id,i)}if(me.has(r.name)){let i=he(r.input);i!==void 0&&t.readPathById.set(r.id,i)}e?.onToolUseStart?.(r,c)},"onToolUseStart"),onToolResult:s((r,c)=>{let i=t.toolNameById.get(r.id)??r.name;if(fe.has(i)&&!r.content.trimStart().startsWith("[Tool Error]")){t.succeededToolCalls.push(i);let h=t.toolPathById.get(r.id);h!==void 0&&t.succeededPaths.push(h)}if(me.has(i)&&!r.content.trimStart().startsWith("[Tool Error]")){let h=t.readPathById.get(r.id);h!==void 0&&t.succeededReadPaths.push(h)}e?.onToolResult?.(r,c)},"onToolResult")}}s(Ue,"wrapEventsForMutationRecording");function K(e){return[...new Set(e.filter(t=>t.trim().length>0))]}s(K,"uniqueItems");function pe(e){let t=e.verification;if(!t)return;let r=[],c=new Set(e.before.paths.map(q)),i=K(e.after.paths.map(q)),h=i.filter(y=>!c.has(y)),b=K(e.mutationRecorder.succeededToolCalls),x=e.acceptToolMutationEvidence?b:[],N=e.acceptToolMutationEvidence?K(e.mutationRecorder.succeededPaths.map(q)):[],M=h.length>0||x.length>0,S=t.enforcement??"hard",W=(t.requiredChangedPaths??[]).map(y=>Y(y,e.ctx)),_=K(e.mutationRecorder.succeededReadPaths.map(y=>Y(y,e.ctx))),z=(t.requiredReadPaths??[]).map(y=>Y(y,e.ctx));t.requiresMutation===!0&&(e.before.error!==void 0||e.after.error!==void 0?r.push(`workspace mutation verification could not read changed files: ${e.after.error??e.before.error}`):M||r.push(e.acceptToolMutationEvidence||b.length===0?"expected file mutations, but no new workspace changes or successful write tools were observed":"write tools ran in an isolated worktree, but no main workspace changes were present after cleanup")),e.term.limitReached===!0&&!M&&r.push("workflow child reached its iteration limit before satisfying the task");for(let y of W)!i.includes(y)&&!N.includes(y)&&r.push(`required changed path was not present in workspace changes: ${y}`);for(let y of z)_.includes(y)||r.push(`required review evidence was not read: ${y}`);let B=t.minFinalTextChars;return B!==void 0&&!M&&e.term.finalText.trim().length<B&&r.push(`finalText was shorter than the required ${B} characters`),t.rejectPreparatoryFinalText===!0&&!M&&ye(e.term.finalText)&&r.push("finalText looks preparatory instead of terminal"),{ok:r.length===0,enforcement:S,reasons:r,changedPaths:i,mutationToolCalls:b,mutationEvidence:M,..._.length>0?{readPaths:_}:{}}}s(pe,"evaluateVerification");function ee(e,t){if(t.ok)return e;let c=[t.enforcement==="warn"?"[Workflow task completed without verification]":"[Workflow task verification failed]",...t.reasons.map(i=>`- ${i}`)].join(`
3
3
  `);return e.trim().length>0?`${e}
4
4
 
5
5
  ${c}`:c}s(ee,"appendVerificationFailure");function ge(){return{ok:!1,enforcement:"warn",reasons:["workflow child reached its iteration limit before satisfying the task"],mutationEvidence:!1}}s(ge,"limitReachedWarningVerification");function $e(e){return e.entry.bundle.readOnly!==!0&&e.entry.repairAttempts<ke&&e.term.status==="completed"&&e.verification!==void 0&&e.verification.ok!==!0&&e.verification.enforcement!=="warn"}s($e,"shouldRepairVerificationFailure");function qe(e){let t=e.verification.reasons.map(c=>`- ${c}`).join(`