@kodax-ai/kodax 0.7.62 → 0.7.66

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 (81) hide show
  1. package/CHANGELOG.md +2300 -2145
  2. package/README.md +81 -9
  3. package/README_CN.md +54 -5
  4. package/dist/chunks/{agent-4ZMCIEGD.js → agent-KER4WDNO.js} +1 -1
  5. package/dist/chunks/argument-completer-HK3MHA3K.js +2 -0
  6. package/dist/chunks/{chunk-ARUWXX25.js → chunk-35P7QL2Q.js} +1 -1
  7. package/dist/chunks/chunk-3HKBBY74.js +339 -0
  8. package/dist/chunks/chunk-AKBH2EEE.js +8 -0
  9. package/dist/chunks/{chunk-OGRJQGKO.js → chunk-ALS32RNZ.js} +1 -1
  10. package/dist/chunks/chunk-MHRN2LQV.js +328 -0
  11. package/dist/chunks/{chunk-JILSZHCQ.js → chunk-NBQW7PNZ.js} +2 -2
  12. package/dist/chunks/{chunk-S4GVQO3W.js → chunk-O7N22GJ3.js} +1 -1
  13. package/dist/chunks/chunk-ONUPGMER.js +2 -0
  14. package/dist/chunks/{chunk-ZL5CEANW.js → chunk-PZTG2C33.js} +1 -1
  15. package/dist/chunks/{chunk-AY3BLB4Q.js → chunk-QAQ2HNXD.js} +112 -112
  16. package/dist/chunks/{chunk-6OZ5KWG3.js → chunk-QJJKMNZF.js} +1 -1
  17. package/dist/chunks/chunk-QJVZZSEO.js +56 -0
  18. package/dist/chunks/chunk-TLJGOKBT.js +729 -0
  19. package/dist/chunks/{chunk-6HTR3GHZ.js → chunk-VS4CDDEF.js} +245 -245
  20. package/dist/chunks/chunk-WBBEJIAY.js +306 -0
  21. package/dist/chunks/{chunk-HO6P6CPU.js → chunk-WMIZCY2J.js} +1 -1
  22. package/dist/chunks/{chunk-UA744TZM.js → chunk-YRBNXFHY.js} +1 -1
  23. package/dist/chunks/compaction-config-7GMUFNPB.js +2 -0
  24. package/dist/chunks/{construction-bootstrap-4ZNFZFX2.js → construction-bootstrap-3XDS2D5K.js} +1 -1
  25. package/dist/chunks/{devtools-4CRULTR2.js → devtools-CD6KSIHE.js} +1 -1
  26. package/dist/chunks/{devtools-YINBSZC7.js → devtools-XR5F2C6T.js} +1 -1
  27. package/dist/chunks/{dist-73L4OYPD.js → dist-4PXB7U22.js} +1 -1
  28. package/dist/chunks/dist-4YAYT2TO.js +2 -0
  29. package/dist/chunks/host-KG3456QP.js +2 -0
  30. package/dist/chunks/{paste-FDYM7SZX.js → paste-C33GZQV5.js} +1 -1
  31. package/dist/chunks/run-manager-6CAH3KTA.js +2 -0
  32. package/dist/chunks/utils-OT5ENFUL.js +2 -0
  33. package/dist/constructed-handler-worker.js +2 -0
  34. package/dist/index.d.ts +22 -11
  35. package/dist/index.js +6 -6
  36. package/dist/kodax_cli.js +1117 -1090
  37. package/dist/runtime-worker.js +2843 -0
  38. package/dist/sdk-agent.d.ts +29 -10
  39. package/dist/sdk-agent.js +1 -1
  40. package/dist/sdk-coding.d.ts +108 -1091
  41. package/dist/sdk-coding.js +1 -1
  42. package/dist/sdk-llm.js +1 -1
  43. package/dist/sdk-mcp.d.ts +2 -1
  44. package/dist/sdk-mcp.js +1 -1
  45. package/dist/sdk-media.js +1 -1
  46. package/dist/sdk-repl.d.ts +198 -184
  47. package/dist/sdk-repl.js +2 -2
  48. package/dist/sdk-runtime.d.ts +982 -0
  49. package/dist/sdk-runtime.js +2 -0
  50. package/dist/sdk-session.d.ts +4 -4
  51. package/dist/sdk-session.js +1 -1
  52. package/dist/sdk-skills.js +1 -1
  53. package/dist/semantic-worker.js +191 -10
  54. package/dist/types-chunks/{bash-prefix-extractor.d-Do_TCAmA.d.ts → bash-prefix-extractor.d-BjkITAva.d.ts} +266 -4
  55. package/dist/types-chunks/{run-manager.d-CYY3pZeJ.d.ts → capsule.d-hVhPNkHd.d.ts} +9 -107
  56. package/dist/types-chunks/commands.d-C3B1TdGM.d.ts +213 -0
  57. package/dist/types-chunks/{types.d-DFf4Sfys.d.ts → guardrail.d-C_Siraua.d.ts} +3 -128
  58. package/dist/types-chunks/{guardrail.d-DRp0Lqvx.d.ts → guardrail.d-wk-s0psS.d.ts} +3 -3
  59. package/dist/types-chunks/{manager.d-DBD7SOTT.d.ts → manager.d-Zum9cGHU.d.ts} +3 -173
  60. package/dist/types-chunks/oauth-login.d-Bgb4rdLN.d.ts +174 -0
  61. package/dist/types-chunks/{process.d-DXkRD7hj.d.ts → process.d-CY2g03Mb.d.ts} +11 -4
  62. package/dist/types-chunks/public-api.d-jtREVfEq.d.ts +596 -0
  63. package/dist/types-chunks/run-manager.d-CFknOfo1.d.ts +91 -0
  64. package/dist/types-chunks/{sdk-session-BGGOC0cT.d.ts → sdk-session-CLqyfAmf.d.ts} +8 -304
  65. package/dist/types-chunks/types.d-BMLxKV69.d.ts +128 -0
  66. package/dist/types-chunks/types.d-CUN_bZU7.d.ts +975 -0
  67. package/dist/types-chunks/{utils.d-ChOEH3NF.d.ts → utils.d-C1rpoeDh.d.ts} +84 -72
  68. package/package.json +7 -1
  69. package/dist/chunks/argument-completer-5PWSKFKI.js +0 -2
  70. package/dist/chunks/chunk-2F4R7WM7.js +0 -52
  71. package/dist/chunks/chunk-3KD26NCI.js +0 -310
  72. package/dist/chunks/chunk-E2Q4RIOD.js +0 -731
  73. package/dist/chunks/chunk-S4ISEA6F.js +0 -341
  74. package/dist/chunks/chunk-V4WSBIXB.js +0 -2
  75. package/dist/chunks/chunk-WFE6FBQ2.js +0 -326
  76. package/dist/chunks/compaction-config-SP3REMFR.js +0 -2
  77. package/dist/chunks/dist-IKWRJW6J.js +0 -2
  78. package/dist/chunks/host-XL5CH7QP.js +0 -2
  79. package/dist/chunks/run-manager-UXIPDVVF.js +0 -2
  80. package/dist/chunks/utils-XKWEVPE3.js +0 -2
  81. package/dist/types-chunks/storage.d-C3umBC4g.d.ts +0 -280
package/README.md CHANGED
@@ -296,6 +296,70 @@ const result = await runKodaX(
296
296
  > surface (`startKodaX` + `RunningSession`), MCP popout manager API (`McpManager`),
297
297
  > Skill `` !`cmd` `` host hook, and per-app data dir namespacing (`getAppDataDir`).
298
298
 
299
+ ## Runtime SDK and daemon
300
+
301
+ SDK hosts can use `@kodax-ai/kodax/runtime` in three forms: inline embedded for
302
+ lowest latency, Worker-hosted embedded for private state plus hard V8 disposal,
303
+ or a local daemon shared by REPL, Space, IDE adapters, and custom SDK clients.
304
+ All three expose the same `KodaXRuntime` services.
305
+
306
+ ```ts
307
+ import { createKodaXRuntime } from '@kodax-ai/kodax/runtime';
308
+
309
+ const isolated = await createKodaXRuntime({
310
+ mode: 'embedded',
311
+ isolation: 'worker',
312
+ requirements: { hardDispose: true },
313
+ });
314
+ ```
315
+
316
+ Inline is private and lowest-overhead; Worker is private and hard-disposable;
317
+ daemon is process-isolated and shared. `runtime.close()` closes private
318
+ inline/Worker ownership, but only detaches one daemon client. Contradictory
319
+ isolation options fail instead of silently selecting a weaker mode. Worker
320
+ isolation is a V8 fault boundary, not a security sandbox.
321
+
322
+ ```bash
323
+ kodax daemon start
324
+ kodax --runtime-mode daemon
325
+ kodax -p "Review this repository" --runtime-mode daemon
326
+ ```
327
+
328
+ All CLI task forms now use the same Runtime path: interactive REPL, positional
329
+ prompts, slash-command prompts, and `kodax -p`. Select the persistent default in
330
+ `~/.kodax/config.json`:
331
+
332
+ ```json
333
+ {
334
+ "runtimeMode": "daemon"
335
+ }
336
+ ```
337
+
338
+ Resolution order is explicit CLI/SDK option > environment variable >
339
+ `config.json` > built-in default (`embedded`). `KODAX_RUNTIME_MODE=daemon` is a
340
+ temporary environment override. The same rule applies to other paired settings,
341
+ for example `provider` ↔ `KODAX_PROVIDER` and `effort` ↔ `KODAX_EFFORT`.
342
+ JSON names stay camelCase while environment names use `KODAX_UPPER_SNAKE_CASE`.
343
+
344
+ By default, daemon state, config, and runtime session storage are scoped under
345
+ the OS user home directory, so `kodax --runtime-mode daemon` and SDK clients
346
+ using `createKodaXRuntime({ mode: 'daemon' })` converge on the same local daemon
347
+ profile. The high-level `createKodaXRuntime({ mode: 'daemon' })` API starts or
348
+ reuses that daemon unless you pass an explicit endpoint/transport or
349
+ `autoStartDaemon: false`. Pass `--home <dir>` or `homeDir` only when you
350
+ intentionally want an isolated daemon namespace for tests, CI, or project-local
351
+ experiments.
352
+
353
+ One daemon owns many sessions. Different sessions may run concurrently; starts
354
+ within the same session are queued so that only one run is active for that
355
+ session. Multiple `kodax` processes can attach to the same daemon and open or
356
+ observe different sessions.
357
+
358
+ For the full host-integration contract, including inline/Worker/daemon selection,
359
+ multi-client permission handling, config/catalog/MCP admin APIs, artifacts,
360
+ context diagnostics, and daemon protocol schemas, see
361
+ [docs/SDK_EMBEDDER_GUIDE.md §17](docs/SDK_EMBEDDER_GUIDE.md#17-runtime-sdk-worker-isolation-and-local-daemon-feature_253-feature_257).
362
+
299
363
  ## Repo Intelligence
300
364
 
301
365
  KodaX ships with built-in repo intelligence (`repo_overview`, `module_context`, `symbol_context`, `process_context`, `impact_estimate`, and related tools) that helps the coding agent understand large codebases without ad-hoc grep/glob exploration.
@@ -309,7 +373,7 @@ kodax --repo-intelligence full --repo-intelligence-trace
309
373
 
310
374
  ## Architecture
311
375
 
312
- KodaX uses a **monorepo architecture** with npm workspaces. Source layout currently has 4 workspace packages; published as a single bundled npm package `@kodax-ai/kodax` with 8 SDK subpath exports (`/agent`, `/llm`, `/coding`, `/media`, `/repl`, `/skills`, `/mcp`, `/session`; ADR-024 + ADR-032 + ADR-038, with ADR-036 consolidation):
376
+ KodaX uses a **monorepo architecture** with npm workspaces. Source layout currently has 4 workspace packages; published as a single bundled npm package `@kodax-ai/kodax` with 9 SDK subpath exports (`/agent`, `/llm`, `/coding`, `/media`, `/repl`, `/skills`, `/mcp`, `/session`, `/runtime`; ADR-024 + ADR-032 + ADR-038, with ADR-036 consolidation):
313
377
 
314
378
  ```
315
379
  KodaX/
@@ -335,7 +399,7 @@ KodaX/
335
399
 
336
400
  ├── src/ # CLI entry + SDK subpath entries
337
401
  │ ├── kodax_cli.ts # Main CLI entry point (bin: `kodax`)
338
- │ └── sdk-*.ts # SDK subpath re-exports → @kodax-ai/kodax/{agent,llm,coding,media,repl,skills,mcp,session}
402
+ │ └── sdk-*.ts # SDK subpath re-exports → @kodax-ai/kodax/{agent,llm,coding,media,repl,skills,mcp,session,runtime}
339
403
 
340
404
  └── package.json # Root workspace config; release.mjs rewrites name + injects subpath exports
341
405
  ```
@@ -384,7 +448,7 @@ Source-side workspace package names (`@kodax-ai/*`). npm consumers install the s
384
448
  KodaX has two layers that consumers should understand separately:
385
449
 
386
450
  - **Source-side**: 4 workspace packages above (what developers see when reading the repo).
387
- - **npm-published**: a single bundled package `@kodax-ai/kodax` with 8 SDK subpaths (what SDK consumers `import` from). The subpaths are split into two roles:
451
+ - **npm-published**: a single bundled package `@kodax-ai/kodax` with 9 SDK subpaths (what SDK consumers `import` from). The subpaths are split into two roles:
388
452
  - **Full-package subpaths** (`/agent`, `/llm`, `/coding`, `/repl`) — each one maps 1:1 to a source workspace and exposes its complete public API.
389
453
  - **Narrow-subset subpaths** (`/media`, `/skills`, `/mcp`, `/session`) — each one exposes only a focused capability slice carved out of `/agent` or `/repl`. This lets consumers who only need (say) the Skills system import a much smaller surface without pulling in the full agent framework.
390
454
 
@@ -396,7 +460,8 @@ KodaX has two layers that consumers should understand separately:
396
460
  | `packages/agent` | `@kodax-ai/kodax/mcp` | **Narrow subset** | MCP only — `McpCapabilityProvider` / `createMcpTransport` / `searchMcpCatalog` / ... (11 exports = pre-v0.7.43 `@kodax-ai/mcp` complete API) | MCP server hosts |
397
461
  | `packages/coding` | `@kodax-ai/kodax/coding` | Full package | Coding agent + 50+ tools + repo-intelligence (342 exports) | Build a Claude Code-shape product |
398
462
  | `packages/repl` | `@kodax-ai/kodax/repl` | Full package | Ink TUI + permission modes + commands (193 exports) | Terminal-UI consumers |
399
- | `packages/repl` | `@kodax-ai/kodax/session` | **Narrow subset** | Session management only — `listSessions` / `loadFullTranscript` / `appendClientNotice` / `forkSession` / `watchSessions` / ... | IDE plugins and desktop hosts reading session history |
463
+ | `packages/repl` | `@kodax-ai/kodax/session` | **Narrow subset** | Session management only — `listSessions` / `loadFullTranscript` / `appendClientNotice` / `forkSession` / `compactSession` / `watchSessions` / ... | IDE plugins and desktop hosts reading session history |
464
+ | `src` | `@kodax-ai/kodax/runtime` | Host API | Embedded/daemon runtime facade, sessions/runs/events/permissions/catalog/MCP/artifacts/diagnostics, daemon protocol schema | SDK hosts, Space/IDE clients, daemon clients |
400
465
 
401
466
  **Rule of thumb**: if you need Runner / Agent / fan-out, import from `/agent`. If you only need skills or mcp APIs, import from `/skills` or `/mcp` to get a smaller bundle. The narrow subsets are subsets of the full packages — they do **not** expose extra symbols.
402
467
 
@@ -404,7 +469,7 @@ KodaX has two layers that consumers should understand separately:
404
469
 
405
470
  **Workflow Process Surface (FEATURE_229, v0.7.50)**: workflow progress is now a reusable Agent-layer process contract rather than private REPL text. SDK hosts can subscribe to `WorkflowProcessEvent`/poll `WorkflowProcessSnapshot`, use `createWorkflowRunManager` and `createWorkflowLifecycleController` for stop/pause/resume/result/artifact/delete/prune/identity/preflight controls, and receive ANSI-free provenance fields (`source`, `sourceRunId`, `sourceWorkflowName`, `savedWorkflowName`, `revisionOf`) plus `resultSummary`. `/coding` owns the coding workflow backend and run graph, `/repl` renders the same snapshots, and the terminal UI is not the hidden source of truth. `KodaXEvents` callbacks also take an optional metadata arg (`KodaXToolEventMeta` / `KodaXActivityEventMeta` / `KodaXWorkflowEventMeta`) so a host can attribute every child-agent tool/thinking/progress event to its workflow run and child id without a second event protocol, and generated/saved workflow scripts pass `validateRestrictedWorkflowSource` (compile + source-policy check) plus a generator repair/smoke loop before they run. See [docs/ADR.md ADR-040](docs/ADR.md) for the layering rationale.
406
471
 
407
- **Host Reads Persisted History (FEATURE_230 + FEATURE_234, v0.7.51)**: additive closures for hosts that read persisted state. **Durable tool transcript replay** — a resumed session now replays the tool cards the assistant used instead of degrading to text-only. `messages` / `lineage` stay canonical; `SessionData.uiHistory` becomes a bounded, sanitized, terminal-only replay cache. The SDK transcript contract is explicit: `loadSession()` = active model context, `loadFullTranscript()` = append-order host scrollback with typed entries (`message` / `compaction` / `branch_summary` / `client_notice` / `task_result`) plus clone provenance (`logicalId` / `sourceEntryId`), `uiHistory` = optional replay cache, and tool cards can always be reconstructed from canonical messages. Hosts can persist local slash output with `appendClientNotice()` without entering model context, and workflow/child completions expose structured `taskResults[]` instead of requiring `<task-completed>` parsing. **Workflow run host attribution** — `WorkflowProcessTrackerOptions` / `WorkflowProcessSnapshot` gain a host-owned opaque `hostMetadata?: Record<string, string>` that the SDK stores, persists to `run.json`, and echoes back (including after a restart) without interpreting it, so a host can map a run to the session/surface that launched it with zero side table. Unstamped/legacy runs honestly echo `hostMetadata === undefined`. See [docs/features/v0.7.51.md](docs/features/v0.7.51.md).
472
+ **Host Reads Persisted History (FEATURE_230 + FEATURE_234, v0.7.51; v0.7.63 hardening)**: additive closures for hosts that read persisted state. **Durable tool transcript replay** — a resumed session now replays the tool cards the assistant used instead of degrading to text-only. `messages` / `lineage` stay canonical; `SessionData.uiHistory` becomes a bounded, sanitized, terminal-only replay cache. The SDK transcript contract is explicit: `loadSession()` = active model context, `loadFullTranscript()` = append-order host scrollback with typed entries (`message` / `compaction` / `branch_summary` / `rewind_marker` / `client_notice` / `task_result`) plus clone provenance (`logicalId` / `sourceEntryId`), `uiHistory` = optional replay cache, and tool cards can always be reconstructed from canonical messages. Hosts can persist local slash output with `appendClientNotice()` without entering model context, and workflow/child completions expose structured `taskResults[]` instead of requiring `<task-completed>` parsing. `rewind_marker` is an audit entry for host scrollback only and is excluded from model-context messages. **Workflow run host attribution** — `WorkflowProcessTrackerOptions` / `WorkflowProcessSnapshot` gain a host-owned opaque `hostMetadata?: Record<string, string>` that the SDK stores, persists to `run.json`, and echoes back (including after a restart) without interpreting it, so a host can map a run to the session/surface that launched it with zero side table. Unstamped/legacy runs honestly echo `hostMetadata === undefined`. See [docs/features/v0.7.51.md](docs/features/v0.7.51.md).
408
473
 
409
474
  **Inline Workflow Authoring (FEATURE_246, v0.7.58)**: in AMA/AMAW the Worker can now author and run a workflow inline via a model-callable `run_workflow` tool — it scouts the codebase with its own tools first, then bakes concrete findings into each child prompt, and runs the script through the **unchanged** sandbox + static-validation + postcondition-verification pipeline. This replaces the context-blind `sideQuery` generator as the primary interactive path (the generator survives only as a fallback for the explicit `/workflow create` command and non-interactive / CI hosts that have no investigating Worker). It adds structured child output (`outputSchema`), the no-barrier `wf.pipeline` staged primitive, same-session resume (`resumeFromRunId`), nested `wf.workflow(...)`, and a `/workflow create` redirect to Worker-authored scouting; `run_workflow` is async / idle-yield so the turn is not blocked. The neutral run-lifecycle manager (`createWorkflowRunManager` / `getDefaultWorkflowRunManager`) now lives in `@kodax-ai/kodax/agent` for non-coding SDK hosts. See [docs/features/v0.7.58.md](docs/features/v0.7.58.md) and [docs/ADR.md](docs/ADR.md) ADR-044/046/047/048/049.
410
475
 
@@ -478,8 +543,12 @@ Output lives under `dist/binary/<target>/`:
478
543
 
479
544
  ```
480
545
  dist/binary/linux-x64/
481
- ├── kodax # ~60 MB Bun-compiled executable
482
- └── builtin/ # Sidecar built-in skills
546
+ ├── kodax # ~60 MB Bun-compiled executable
547
+ ├── builtin/ # Sidecar built-in skills
548
+ ├── provider-capabilities.json
549
+ ├── semantic-worker.js # Repo-intelligence Worker
550
+ ├── runtime-worker.js # SDK Runtime Worker
551
+ └── constructed-handler-worker.js # Constructed-tool Worker
483
552
  ```
484
553
 
485
554
  Smoke-test: `dist/binary/<host>/kodax --version`.
@@ -523,9 +592,10 @@ import { SkillRegistry } from '@kodax-ai/kodax/skills'; // zero-dep skil
523
592
  import { loadConfig } from '@kodax-ai/kodax/repl'; // REPL config / session helpers
524
593
  import { createMcpManager } from '@kodax-ai/kodax/mcp'; // MCP popout manager (v0.7.42)
525
594
  import { listSessions } from '@kodax-ai/kodax/session'; // session history helpers
595
+ import { createKodaXRuntime } from '@kodax-ai/kodax/runtime'; // embedded/daemon runtime API
526
596
  ```
527
597
 
528
- All 9 SDK entries (root + 8 subpaths) share internal code via ESM chunk splitting — importing from `/agent` does not pull in `/repl`'s Ink + React surface.
598
+ All 10 SDK entries (root + 9 subpaths) share internal code via ESM chunk splitting — importing from `/agent` does not pull in `/repl`'s Ink + React surface.
529
599
 
530
600
  > **ESM-only.** The SDK is published as ES Modules. In a CommonJS context (Electron main process, legacy Webpack CJS bundles, `require()`-based code) you must use `await import(...)` instead of `require()`. See [docs/SDK_EMBEDDER_GUIDE.md §5](docs/SDK_EMBEDDER_GUIDE.md#5-consuming-from-a-commonjs-context-electron-main-cjs-bundles) for the canonical recipe + the technical reason most subpaths cannot ship a dual ESM/CJS build.
531
601
 
@@ -812,7 +882,7 @@ await runKodaX({
812
882
 
813
883
  ## SDK Usage
814
884
 
815
- KodaX ships as a single npm package `@kodax-ai/kodax` with 8 SDK subpath exports (ADR-024 v0.7.39 + ADR-032 v0.7.42 + ADR-038 v0.7.49 + v0.7.56 `/media`). Each subpath is tree-shake-friendly so consumers pull only what they need:
885
+ KodaX ships as a single npm package `@kodax-ai/kodax` with 9 SDK subpath exports (ADR-024 v0.7.39 + ADR-032 v0.7.42 + ADR-038 v0.7.49 + v0.7.56 `/media` + v0.7.64 `/runtime`). Each subpath is tree-shake-friendly so consumers pull only what they need:
816
886
 
817
887
  ```bash
818
888
  npm install @kodax-ai/kodax
@@ -828,6 +898,7 @@ import { runInkInteractiveMode } from '@kodax-ai/kodax/repl'; // Ink TUI ent
828
898
  import { SkillRegistry } from '@kodax-ai/kodax/skills'; // zero-dep skill loader
829
899
  import { createMcpManager } from '@kodax-ai/kodax/mcp'; // MCP popout manager (v0.7.42)
830
900
  import { listSessions } from '@kodax-ai/kodax/session'; // session history helpers
901
+ import { createKodaXRuntime } from '@kodax-ai/kodax/runtime'; // embedded/daemon runtime API
831
902
  ```
832
903
 
833
904
  > The SDK is **ESM-only**. CommonJS consumers (Electron main / Webpack CJS / `require()` callers) must use `await import('@kodax-ai/kodax/...')` — see [docs/SDK_EMBEDDER_GUIDE.md §5](docs/SDK_EMBEDDER_GUIDE.md#5-consuming-from-a-commonjs-context-electron-main-cjs-bundles).
@@ -976,6 +1047,7 @@ await runInkInteractiveMode({ provider: 'zhipu-coding', effort: 'auto' });
976
1047
  | Building custom agent | `@kodax-ai/kodax/agent` | Runner + fan-out + idle-yield + session-lineage + capabilities |
977
1048
  | Coding tasks | `@kodax-ai/kodax/coding` | Complete coding agent + tools |
978
1049
  | Terminal app | `@kodax-ai/kodax/repl` | Full interactive experience |
1050
+ | Runtime host / daemon client | `@kodax-ai/kodax/runtime` | Sessions, runs, events, permissions, catalog, MCP, artifacts, diagnostics |
979
1051
 
980
1052
  ---
981
1053
 
package/README_CN.md CHANGED
@@ -344,7 +344,52 @@ registerCustomProviders([
344
344
  await runKodaX({ provider: 'my-openai-compatible' }, '解释这个仓库');
345
345
  ```
346
346
 
347
- ### 6. 打包成单文件二进制(无需 Node)
347
+ ### 6. Runtime 与本机 daemon
348
+
349
+ 交互 REPL、位置参数、slash-command 生成的任务和 `kodax -p` 现在都走统一的
350
+ `KodaXRuntime` 入口。默认使用最低延迟的进程内 `embedded`;单一 SDK 宿主需要
351
+ 独立 V8 与硬销毁时,可选择 Worker-hosted embedded;需要后台持续运行、断线后
352
+ 查询或多个本机客户端共享时,可切到 `daemon`:
353
+
354
+ ```ts
355
+ import { createKodaXRuntime } from '@kodax-ai/kodax/runtime';
356
+
357
+ const isolated = await createKodaXRuntime({
358
+ mode: 'embedded',
359
+ isolation: 'worker',
360
+ requirements: { hardDispose: true },
361
+ });
362
+ ```
363
+
364
+ inline 形态由调用方私有且开销最低;Worker 形态仍然私有,但可硬销毁;
365
+ daemon 形态使用独立进程并允许多个客户端共享。`runtime.close()` 会关闭
366
+ 私有 inline/Worker Runtime,但对 daemon 只断开当前客户端。矛盾的隔离参数
367
+ 会直接报错,不会静默降级。Worker 是 V8 故障隔离边界,不是安全沙箱。
368
+
369
+ ```bash
370
+ kodax daemon start
371
+ kodax --runtime-mode daemon
372
+ kodax -p "检查这个仓库" --runtime-mode daemon
373
+ ```
374
+
375
+ 持久设置写入 `~/.kodax/config.json`:
376
+
377
+ ```json
378
+ {
379
+ "runtimeMode": "daemon"
380
+ }
381
+ ```
382
+
383
+ 统一优先级是:显式 CLI/SDK 参数 > 环境变量 > `config.json` > 内置默认值。
384
+ `KODAX_RUNTIME_MODE=daemon` 适合临时覆盖。其他成对配置也遵循相同规则,例如
385
+ `provider` ↔ `KODAX_PROVIDER`、`effort` ↔ `KODAX_EFFORT`。JSON 保持 camelCase,
386
+ 环境变量保持 `KODAX_UPPER_SNAKE_CASE`,两者按语义一一对应。
387
+
388
+ 一个 daemon 可以承载多个 session。不同 session 可以并发运行;同一个 session
389
+ 内部仍保持一次只运行一个任务,后续任务按队列执行。多个 `kodax` 进程可以连接
390
+ 同一个 daemon,并分别打开或观察不同 session。
391
+
392
+ ### 7. 打包成单文件二进制(无需 Node)
348
393
 
349
394
  KodaX 可以用 `bun --compile` 打包成单可执行文件 + 一个 `builtin/` sidecar 目录,目标机器**不需要安装 Node.js 或任何运行时**。
350
395
 
@@ -365,8 +410,12 @@ node scripts/build-binary.mjs --target=linux-arm64 # 指定平台
365
410
 
366
411
  ```
367
412
  dist/binary/linux-x64/
368
- ├── kodax # ~60 MB Bun 编译的二进制
369
- └── builtin/ # 内置 skills sidecar
413
+ ├── kodax # ~60 MB Bun 编译的二进制
414
+ ├── builtin/ # 内置 skills sidecar
415
+ ├── provider-capabilities.json
416
+ ├── semantic-worker.js # Repo intelligence Worker
417
+ ├── runtime-worker.js # SDK Runtime Worker
418
+ └── constructed-handler-worker.js # Constructed tool Worker
370
419
  ```
371
420
 
372
421
  冒烟验证:`dist/binary/<host>/kodax --version`。
@@ -500,13 +549,13 @@ KodaX 有两层结构,SDK 用户需要分开理解:
500
549
  | `packages/agent` | `@kodax-ai/kodax/mcp` | **窄子集** | 仅 MCP —— `McpCapabilityProvider` / `createMcpTransport` / `searchMcpCatalog` 等 (11 exports = v0.7.43 之前 `@kodax-ai/mcp` 完整 API) | MCP server 宿主 |
501
550
  | `packages/coding` | `@kodax-ai/kodax/coding` | 完整包 | Coding agent + 50+ 工具 + repo-intelligence (342 exports) | 构建 Claude Code 形态产品 |
502
551
  | `packages/repl` | `@kodax-ai/kodax/repl` | 完整包 | Ink TUI + 权限模式 + 命令系统 (193 exports) | 终端 UI 消费者 |
503
- | `packages/repl` | `@kodax-ai/kodax/session` | **窄子集** | 仅会话管理 —— `listSessions` / `loadFullTranscript` / `appendClientNotice` / `forkSession` / `watchSessions` 等 | 读取 session 历史的 IDE 插件和桌面宿主 |
552
+ | `packages/repl` | `@kodax-ai/kodax/session` | **窄子集** | 仅会话管理 —— `listSessions` / `loadFullTranscript` / `appendClientNotice` / `forkSession` / `compactSession` / `watchSessions` 等 | 读取 session 历史的 IDE 插件和桌面宿主 |
504
553
 
505
554
  **经验法则**:需要 Runner / Agent / fan-out 时从 `/agent` 引入;只需要 skills 或 mcp API 时从 `/skills` 或 `/mcp` 引入,bundle 更小。窄子集是完整包的真子集 —— **不会**有额外符号。
506
555
 
507
556
  **Workflow process surface(FEATURE_229,v0.7.50)**:动态工作流不再只是 REPL 私有文本,而是 Agent 层可复用的 process/event/snapshot 契约。SDK 宿主可以订阅 `WorkflowProcessEvent`、轮询 `WorkflowProcessSnapshot`,并通过 `createWorkflowRunManager` / `createWorkflowLifecycleController` 做 stop/pause/resume、读取 final result/artifact、删除/清理 terminal runs、管理 workflow identity/preflight。`/coding` 负责 coding workflow backend 与 run graph,`/repl` 只是消费同一份 snapshot 渲染 UI;SDK 不需要解析 slash-command 输出或 Ink view-model。`KodaXEvents` 回调新增可选 meta 尾参(`KodaXToolEventMeta` / `KodaXActivityEventMeta` / `KodaXWorkflowEventMeta`),宿主据此把每个子 Agent 的 tool/thinking/progress 事件归因到对应 workflow run 与 child id,无需第二套事件协议;生成/保存的工作流脚本在运行前过 `validateRestrictedWorkflowSource`(编译 + 源策略检查)与 generator 的 repair/smoke 循环。分层取舍见 [docs/ADR.md ADR-040](docs/ADR.md)。
508
557
 
509
- **宿主读持久化历史(FEATURE_230 + FEATURE_234,v0.7.51)**:面向「宿主读持久化状态」的 additive 闭环。**持久化工具记录回放**——resume 的会话现在会回放助手用过的工具卡片,而不是退化成纯文本。`messages` / `lineage` 仍是 canonical;`SessionData.uiHistory` 成为有界、脱敏、仅 terminal 状态的回放缓存。SDK transcript 契约明确化:`loadSession()` = 活动 model context,`loadFullTranscript()` = 带结构化条目的追加序 host scrollback(`message` / `compaction` / `branch_summary` / `client_notice` / `task_result`)并带 clone provenance(`logicalId` / `sourceEntryId`),`uiHistory` = 可选回放缓存,工具卡片始终可从 canonical messages 重建。宿主可用 `appendClientNotice()` 持久化本地 slash 输出且不进入模型上下文;workflow/child 完成结果通过结构化 `taskResults[]` 暴露,不再要求解析 `<task-completed>` 文本。**Workflow run 宿主归属**——`WorkflowProcessTrackerOptions` / `WorkflowProcessSnapshot` 新增 host-owned 不透明 `hostMetadata?: Record<string, string>`,SDK 存储、持久化进 `run.json`、回读回显(含进程重启后)但不解释其含义,让宿主零侧表把 run 归回发起它的 session/surface。未 stamp 的旧 run 诚实回显 `hostMetadata === undefined`。详见 [docs/features/v0.7.51.md](docs/features/v0.7.51.md)。
558
+ **宿主读持久化历史(FEATURE_230 + FEATURE_234,v0.7.51;v0.7.63 hardening)**:面向「宿主读持久化状态」的 additive 闭环。**持久化工具记录回放**——resume 的会话现在会回放助手用过的工具卡片,而不是退化成纯文本。`messages` / `lineage` 仍是 canonical;`SessionData.uiHistory` 成为有界、脱敏、仅 terminal 状态的回放缓存。SDK transcript 契约明确化:`loadSession()` = 活动 model context,`loadFullTranscript()` = 带结构化条目的追加序 host scrollback(`message` / `compaction` / `branch_summary` / `rewind_marker` / `client_notice` / `task_result`)并带 clone provenance(`logicalId` / `sourceEntryId`),`uiHistory` = 可选回放缓存,工具卡片始终可从 canonical messages 重建。宿主可用 `appendClientNotice()` 持久化本地 slash 输出且不进入模型上下文;workflow/child 完成结果通过结构化 `taskResults[]` 暴露,不再要求解析 `<task-completed>` 文本。`rewind_marker` 只用于 host scrollback 审计,不进入 model-context messages。**Workflow run 宿主归属**——`WorkflowProcessTrackerOptions` / `WorkflowProcessSnapshot` 新增 host-owned 不透明 `hostMetadata?: Record<string, string>`,SDK 存储、持久化进 `run.json`、回读回显(含进程重启后)但不解释其含义,让宿主零侧表把 run 归回发起它的 session/surface。未 stamp 的旧 run 诚实回显 `hostMetadata === undefined`。详见 [docs/features/v0.7.51.md](docs/features/v0.7.51.md)。
510
559
 
511
560
  **Inline workflow authoring(FEATURE_246,v0.7.58)**:AMA/AMAW 下 Worker 现在可通过 model-callable 的 `run_workflow` 工具在会话内直接编写并运行工作流——先用自己的工具 scout 代码库,再把具体发现烤进每个 child prompt,然后走**不变的** sandbox + 静态校验 + postcondition 验证流水线。它取代 context-blind 的 `sideQuery` generator 成为主交互路径(generator 仅作为显式 `/workflow create` 命令与无 investigating Worker 的 non-interactive/CI 主机的 fallback 保留);新增结构化 child 输出(`outputSchema`)、无 barrier 的 `wf.pipeline` 分阶段原语、同会话 resume(`resumeFromRunId`)、嵌套 `wf.workflow(...)`,`/workflow create` 重定向到 Worker 的 scout-then-author;`run_workflow` 为 async / idle-yield,不阻塞当前轮。中立的 run-lifecycle manager(`createWorkflowRunManager`)已移入 `@kodax-ai/kodax/agent` 供非 coding SDK 宿主使用。详见 [docs/features/v0.7.58.md](docs/features/v0.7.58.md) 与 [docs/ADR.md](docs/ADR.md) ADR-044/046/047/048/049。
512
561
 
@@ -1,2 +1,2 @@
1
1
  // @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
2
- import{I as c,J as d,K as e,L as f,Z as g,_ as h,ia as i,qa as j}from"./chunk-WFE6FBQ2.js";import"./chunk-D6QVXQNI.js";import"./chunk-UA744TZM.js";import"./chunk-S4ISEA6F.js";import"./chunk-S4GVQO3W.js";import{ob as a,pb as b}from"./chunk-E2Q4RIOD.js";import"./chunk-ZL5CEANW.js";import"./chunk-V4WSBIXB.js";export{d as bucketProviderPayloadSize,g as buildAutoRepoIntelligenceContext,e as checkPromiseSignal,b as cleanupIncompleteToolCalls,h as describeTransientProviderRetry,f as emitResilienceDebug,c as estimateProviderPayloadBytes,j as runKodaX,i as saveSessionSnapshot,a as validateAndFixToolHistory};
2
+ import{I as c,J as d,K as e,L as f,Z as g,_ as h,ra as i,za as j}from"./chunk-MHRN2LQV.js";import"./chunk-D6QVXQNI.js";import"./chunk-YRBNXFHY.js";import"./chunk-3HKBBY74.js";import"./chunk-O7N22GJ3.js";import{rb as a,sb as b}from"./chunk-TLJGOKBT.js";import"./chunk-PZTG2C33.js";import"./chunk-ONUPGMER.js";export{d as bucketProviderPayloadSize,g as buildAutoRepoIntelligenceContext,e as checkPromiseSignal,b as cleanupIncompleteToolCalls,h as describeTransientProviderRetry,f as emitResilienceDebug,c as estimateProviderPayloadBytes,j as runKodaX,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{Ba as a,Ca as b}from"./chunk-VS4CDDEF.js";import"./chunk-QJVZZSEO.js";import"./chunk-WMIZCY2J.js";import"./chunk-QAQ2HNXD.js";import"./chunk-ALS32RNZ.js";import"./chunk-NBQW7PNZ.js";import"./chunk-MHRN2LQV.js";import"./chunk-D6QVXQNI.js";import"./chunk-YRBNXFHY.js";import"./chunk-3HKBBY74.js";import"./chunk-O7N22GJ3.js";import"./chunk-TLJGOKBT.js";import"./chunk-PZTG2C33.js";import"./chunk-ONUPGMER.js";export{a as ArgumentCompleter,b as createArgumentCompleter};
@@ -1,2 +1,2 @@
1
1
  // @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
2
- import{a as o}from"./chunk-V4WSBIXB.js";var t=o(()=>{},"noop"),c={initialize:t,connectToDevTools:t};var e=class{static{o(this,"WebSocketStub")}},l=e;export{l as a,c as b};
2
+ import{a as o}from"./chunk-ONUPGMER.js";var t=o(()=>{},"noop"),c={initialize:t,connectToDevTools:t};var e=class{static{o(this,"WebSocketStub")}},l=e;export{l as a,c as b};