@kontextmind/kxm 0.7.95 → 0.7.97

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 (158) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.kxm/README.md +39 -9
  3. package/CHANGELOG.md +23 -1
  4. package/README.md +147 -257
  5. package/SECURITY.md +21 -12
  6. package/docs/README.md +133 -54
  7. package/docs/adr/ADR-0002-browser-automation-steel-doks.md +24 -18
  8. package/docs/adr/ADR-0003-sqlite-only-store.md +100 -0
  9. package/docs/adr/ADR-0004-edge-identity-authentik.md +99 -0
  10. package/docs/adr/README.md +33 -0
  11. package/docs/concepts/architecture.md +262 -0
  12. package/docs/concepts/data-and-storage.md +194 -0
  13. package/docs/concepts/trust-model.md +153 -0
  14. package/docs/contracts/README.md +22 -14
  15. package/docs/contracts/effects-and-recovery.md +3 -0
  16. package/docs/contracts/migration.md +2 -2
  17. package/docs/contracts/routing.md +6 -5
  18. package/docs/contributing/assignment-runner.md +388 -0
  19. package/docs/contributing/ci-and-release.md +231 -0
  20. package/docs/contributing/development.md +362 -0
  21. package/docs/contributing/harness-routing-internals.md +192 -0
  22. package/docs/{packages.md → contributing/packages.md} +13 -15
  23. package/docs/{skills → contributing}/repo-work-delivery.md +20 -21
  24. package/docs/contributing/test-matrix.md +208 -0
  25. package/docs/{tui-components.md → contributing/tui-components.md} +30 -22
  26. package/docs/contributing/writing-docs.md +340 -0
  27. package/docs/glossary.md +471 -0
  28. package/docs/guides/agent-skills.md +137 -0
  29. package/docs/guides/browser-automation.md +160 -0
  30. package/docs/guides/context-and-memory.md +352 -0
  31. package/docs/guides/continuous-improvement.md +228 -0
  32. package/docs/guides/governed-skills.md +173 -0
  33. package/docs/guides/nous-providers.md +186 -0
  34. package/docs/guides/peer-messaging.md +304 -0
  35. package/docs/guides/pi-workers.md +219 -0
  36. package/docs/guides/provenance-gates.md +313 -0
  37. package/docs/guides/webhook-workflows.md +399 -0
  38. package/docs/kb/how-credentials-retrieved-safely.md +38 -12
  39. package/docs/kb/how-to-capture-and-annotate-section.md +15 -13
  40. package/docs/kb/how-to-connect-playwright-to-steel.md +16 -11
  41. package/docs/kb/how-to-recover-expired-session-or-orphan.md +26 -16
  42. package/docs/kb/how-to-resume-after-mfa.md +19 -11
  43. package/docs/kb/how-to-take-over-session.md +17 -13
  44. package/docs/kb/why-authentication-disappeared.md +22 -14
  45. package/docs/kb/why-automation-opened-different-browser.md +23 -14
  46. package/docs/kb/why-session-viewer-cannot-control.md +13 -12
  47. package/docs/operations/backup-and-restore.md +248 -0
  48. package/docs/operations/deploy.md +307 -0
  49. package/docs/operations/monitoring.md +209 -0
  50. package/docs/operations/runtime-sync.md +192 -0
  51. package/docs/operations/troubleshooting.md +266 -0
  52. package/docs/operations/upgrade.md +124 -0
  53. package/docs/prompts/browser-annotate-feedback.md +7 -7
  54. package/docs/prompts/browser-diagnose-recover.md +11 -10
  55. package/docs/prompts/browser-explore.md +7 -7
  56. package/docs/prompts/browser-repro-fix.md +7 -7
  57. package/docs/prompts/browser-start.md +12 -11
  58. package/docs/prompts/browser-takeover.md +8 -8
  59. package/docs/{cli-reference.md → reference/cli-reference.md} +88 -46
  60. package/docs/{config-reference.md → reference/config-reference.md} +159 -148
  61. package/docs/reference/configuration.md +299 -0
  62. package/docs/reference/harness-routing.md +508 -0
  63. package/docs/reference/http-api.md +203 -0
  64. package/docs/reference/tools.md +370 -0
  65. package/docs/{workflow-guide.md → reference/workflow-catalog.md} +92 -153
  66. package/docs/reference/workflow-definitions.md +286 -0
  67. package/docs/start/first-workflow.md +287 -0
  68. package/docs/start/install.md +146 -0
  69. package/docs/start/quickstart-claude-code.md +405 -0
  70. package/docs/start/quickstart-pi.md +213 -0
  71. package/docs/templates/README.md +78 -73
  72. package/docs/templates/adr.md +13 -13
  73. package/docs/templates/architecture.md +55 -71
  74. package/docs/templates/bug-fix.md +13 -16
  75. package/docs/templates/feature.md +14 -19
  76. package/docs/templates/handoff.md +44 -46
  77. package/docs/templates/postmortem.md +30 -43
  78. package/docs/templates/research.md +15 -20
  79. package/docs/templates/review.md +49 -50
  80. package/docs/templates/runbook.md +38 -30
  81. package/docs/templates/test-plan.md +16 -23
  82. package/docs/templates/test-report.md +14 -17
  83. package/examples/README.md +9 -5
  84. package/examples/provenance-workflow.json +1 -1
  85. package/examples/webhook-workflows/jira-development.json +59 -0
  86. package/examples/webhook-workflows/jira-issue-updated.json +12 -0
  87. package/examples/workflow-signal.ts +4 -5
  88. package/package.json +1 -1
  89. package/packages/core/tui/README.md +1 -1
  90. package/plugins/kxm/.claude-plugin/plugin.json +1 -1
  91. package/plugins/kxm/README.md +31 -32
  92. package/plugins/kxm/dist/claude-hook.js +11 -1
  93. package/plugins/kxm/dist/cli.js +164 -79
  94. package/plugins/kxm/dist/client.js +3 -1
  95. package/plugins/kxm/dist/core.js +11 -1
  96. package/plugins/kxm/dist/extension.js +45 -13
  97. package/plugins/kxm/dist/mcp-server.js +20 -4
  98. package/plugins/kxm/dist/runtime-supervisor.js +1 -3
  99. package/plugins/kxm/dist/runtime.js +18 -4
  100. package/plugins/kxm/dist/server.js +115 -20
  101. package/plugins/kxm/package.json +1 -1
  102. package/plugins/kxm/skills/kxm/references/protocol.md +3 -1
  103. package/plugins/kxm/skills/kxm-browser-auth/SKILL.md +1 -1
  104. package/plugins/kxm/skills/kxm-browser-diagnostics/SKILL.md +5 -5
  105. package/plugins/kxm/skills/kxm-browser-explore/SKILL.md +2 -2
  106. package/plugins/kxm/skills/kxm-browser-session/SKILL.md +10 -13
  107. package/plugins/kxm/skills/kxm-browser-takeover/SKILL.md +1 -1
  108. package/plugins/kxm/skills/kxm-browser-verify/SKILL.md +1 -1
  109. package/plugins/kxm/skills/kxm-context-memory/SKILL.md +13 -4
  110. package/plugins/kxm/skills/kxm-hub-ops/SKILL.md +3 -1
  111. package/plugins/kxm/skills/kxm-mind-setup/SKILL.md +2 -1
  112. package/plugins/kxm/skills/kxm-project-setup/SKILL.md +31 -54
  113. package/plugins/kxm/skills/kxm-projects/SKILL.md +1 -1
  114. package/plugins/kxm/skills/kxm-protocol/SKILL.md +1 -1
  115. package/plugins/kxm/skills/kxm-routing-improve/SKILL.md +15 -7
  116. package/plugins/kxm/skills/kxm-runs/SKILL.md +11 -5
  117. package/plugins/kxm/skills/kxm-session/SKILL.md +1 -1
  118. package/plugins/kxm/skills/kxm-tasks/SKILL.md +9 -7
  119. package/plugins/kxm/skills/kxm-workflow/SKILL.md +10 -2
  120. package/plugins/kxm/src/cli/system.ts +1 -1
  121. package/plugins/kxm/src/cli/workflows.ts +12 -7
  122. package/plugins/kxm/src/cli.ts +22 -8
  123. package/plugins/kxm/src/client.ts +4 -0
  124. package/plugins/kxm/src/commands.ts +23 -1
  125. package/plugins/kxm/src/extension.ts +20 -14
  126. package/plugins/kxm/src/github-watch.ts +8 -5
  127. package/plugins/kxm/src/hub-env.ts +19 -1
  128. package/plugins/kxm/src/hub.ts +105 -21
  129. package/plugins/kxm/src/improve-sources.ts +2 -7
  130. package/plugins/kxm/src/init-guide-setup.ts +1 -1
  131. package/plugins/kxm/src/mcp-server.ts +9 -2
  132. package/plugins/kxm/src/modes.ts +1 -1
  133. package/plugins/kxm/src/runtime-store.ts +23 -0
  134. package/plugins/kxm/src/workflow.ts +70 -1
  135. package/schemas/README.md +1 -1
  136. package/scripts/smoke-multi-pi.mjs +5 -1
  137. package/docs/agent-communication-envelopes-and-gates.md +0 -553
  138. package/docs/agent-skills.md +0 -198
  139. package/docs/architecture.md +0 -245
  140. package/docs/assignment-runner.md +0 -264
  141. package/docs/browser-automation.md +0 -139
  142. package/docs/configuration.md +0 -437
  143. package/docs/continuous-improvement.md +0 -226
  144. package/docs/getting-started.md +0 -277
  145. package/docs/harness-routing.md +0 -616
  146. package/docs/kb/qa-authentik-authentication.md +0 -97
  147. package/docs/kb/qa-extension-install-and-hub-bootstrap.md +0 -85
  148. package/docs/kb/qa-hub-on-a-public-host.md +0 -48
  149. package/docs/kb/qa-sqlite-vs-duckdb.md +0 -35
  150. package/docs/kb/qa-what-the-hub-stores.md +0 -64
  151. package/docs/kxm-handbook.md +0 -1181
  152. package/docs/operations.md +0 -510
  153. package/docs/operator-pi-packages.md +0 -67
  154. package/docs/provenance-gates.md +0 -295
  155. package/docs/skills.md +0 -47
  156. package/docs/test-matrix.md +0 -132
  157. package/docs/troubleshooting.md +0 -322
  158. package/docs/webhook-workflows.md +0 -240
@@ -0,0 +1,299 @@
1
+ # Environment variables and limits
2
+
3
+ This page lists every environment variable KXM reads, what it controls and its default, and the fixed limits the [hub](../glossary.md#hub) and its clients enforce. Use it when you run a hub, a long-lived Pi worker, or an agent against a hub. The files under `.kxm/` and the `kxm.config.v1` preference keys are in the [configuration file reference](config-reference.md); commands are in the [CLI reference](cli-reference.md).
4
+
5
+ ## Where settings come from
6
+
7
+ KXM reads settings from four places. The first three merge key by key into one `kxm.config.v1` view; environment variables configure processes and never override a `kxm.config.v1` key. The [configuration layering diagram](config-reference.md#configuration-layers) shows the same order.
8
+
9
+ | Layer | Location | Written by | Wins over |
10
+ |---|---|---|---|
11
+ | Built-in defaults | `plugins/kxm/src/config.ts` | Nobody; ships with KXM | Nothing |
12
+ | User preferences | `~/.config/kxm/config.yaml`, or `$KXM_USER_CONFIG_DIR/config.yaml` | `kxm config set <key> <value> --scope user` | Built-in defaults |
13
+ | Project preferences | `<project root>/.kxm/config.yaml` | `kxm config set <key> <value>` (project is the default scope) | User preferences |
14
+ | Environment variables | The shell, service manager, container, or secret manager that starts the process | You | Values persisted on this machine by `kxm hub start` and `kxm hub bind` |
15
+
16
+ Only `hub.autoStart` and the `improvement.*` keys change behavior today. The reviewed project files (`project.yaml`, `agents/`, `workflows/`, `gates.yaml` and the rest) are a separate, Git-tracked bundle that no environment variable overrides.
17
+
18
+ > [!WARNING]
19
+ > Keep tokens and secrets in environment variables or a secret manager. Never commit them, put them in a `.kxm/*.yaml` file, or pass them as command-line arguments.
20
+
21
+ ## Environment-variable classification
22
+
23
+ Names that start with `KXM_` are not all operator settings. This map covers every name the KXM source reads from the environment.
24
+
25
+ | Group | Variables | Documented in |
26
+ |---|---|---|
27
+ | Hub process | `KXM_HOST`, `KXM_PORT`, `KXM_AUTH_TOKEN`, `KXM_PROJECT_TOKENS`, `KXM_DATA_PATH`, `KXM_LOG_PATH`, `KXM_MESSAGE_*`, `KXM_RATE_LIMIT_*` | [Hub settings](#hub-settings) |
28
+ | Workspace directories | `KXM_WORKDIR`, `KXM_WORKSPACE_DIR`, `KXM_CONFIG_DIR`, `KXM_LOGS_DIR`, `KXM_ASSETS_DIR`, `KXM_STATE_DIR` | [Workspace directories](#workspace-directories) |
29
+ | Webhook workflows | `KXM_WEBHOOK_WORKFLOWS`, `KXM_WEBHOOK_WORKFLOWS_FILE`, plus each definition's `secretEnv` and `signalSecretEnv` | [Webhook workflow settings](#webhook-workflow-settings) |
30
+ | Agents | `KXM_SERVER_URL`, `KXM_AUTH_TOKEN`, `KXM_PROJECT`, `KXM_AGENT_NAME`, `KXM_AGENT_PURPOSE` | [Agent settings](#agent-settings) |
31
+ | Long-lived Pi workers | `KXM_PI_COMMAND`, `KXM_WORKER_*` (operator settings), `KXM_AGENT_LOG_PATH` | [Long-lived worker settings](#long-lived-worker-settings) |
32
+ | Runtime supervisor | `KXM_STATE_HOME`, `KXM_RUNTIME_SYNC_INTERVAL_MS`, `KXM_RUNTIME_STOP_GRACE_MS` | [Runtime supervisor settings](#runtime-supervisor-settings) |
33
+ | Operator CLI and sessions | `KXM_USER_CONFIG_DIR`, `KXM_USER_TELEMETRY_DIR`, `KXM_SESSION_TOKEN`, `KXM_SESSION_BRIEF`, `KXM_WORKFLOW_*`, `GITHUB_TOKEN`, and others | [CLI and session settings](#cli-and-session-settings) |
34
+ | Nous model providers | `KXM_NOUS_PROVIDERS`, `KXM_NOUS_PROXY_URL`, `KXM_NOUS_DISCOVERY_TIMEOUT_MS`, `KXM_NOUS_CATALOG_FILE`, `NOUS_API_KEY` | [Nous providers](../guides/nous-providers.md) |
35
+ | Browser automation | `STEEL_API_URL`, `STEEL_API_KEY`, `STEEL_UI_URL`, `USE_PASS_CLI` | [Browser automation](../guides/browser-automation.md) |
36
+ | Set by a harness, not by you | `KXM_PROJECT_DIR` (Claude Code plugin), `KXM_ATTEMPT_TOKEN` (Runtime attempts), `KXM_WORKER_IDENTITY_KEY`, `KXM_WORKER_GENERATION`, `KXM_WORKER_CHILD_INCARCATION`, `KXM_WORKER_SESSION_SCOPE` (worker supervisor to its Pi child) | [Internal variables](#internal-variables) |
37
+ | Maintainer and test only | `KXM_SMOKE*`, `KXM_ASSET*`, `KXM_RELEASE_TAG`, `KXM_PUBLISH_WAIT_MS`, `KXM_DETERMINISTIC_TEST_CLOCK`, `KXM_WORKER_STOP_AFTER_MS`, `KXM_STUDIO_ONCE` | [Development](../contributing/development.md) |
38
+ | Maintainer critic script | `KXM_CRITIC_DIR`, `KXM_REVIEW_TARGET` | [Maintainer critic script](#maintainer-critic-script) |
39
+ | Not environment variables | `KXM_SLASH_SUBCOMMANDS`, `KXM_UPDATE_CACHE`, `KXM_UPDATE_SCHEMA`, and other `KXM_*_SCHEMA` constants | Source constants; do not set them |
40
+
41
+ ## Hub settings
42
+
43
+ `kxm hub start` reads these when it starts the hub. Restart the hub after you change one.
44
+
45
+ | Variable | Default | Effect |
46
+ |---|---|---|
47
+ | `KXM_HOST` | `127.0.0.1` | Listening interface. Any non-loopback value requires `KXM_AUTH_TOKEN`, or the hub refuses to start |
48
+ | `KXM_PORT` | `7331` | TCP port, an integer from 0 to 65535; `0` picks a free port |
49
+ | `KXM_AUTH_TOKEN` | Persisted or generated (see below) | Administrative bearer token. Also accepted as the project token for any project without its own entry |
50
+ | `KXM_PROJECT_TOKENS` | Persisted value, else none | JSON object mapping project names to project tokens, for example `{"web":"replace-with-a-web-token"}`. Replaces the whole saved map |
51
+ | `KXM_DATA_PATH` | `$KXM_STATE_DIR/kxm.db` | SQLite database. `:memory:` keeps nothing across a restart; use it only for disposable runs |
52
+ | `KXM_LOG_PATH` | `$KXM_LOGS_DIR/kxm-hub.jsonl` | Structured JSON Lines hub log |
53
+ | `KXM_MESSAGE_TTL_MS` | `86400000` (24 hours) | Default request lifetime, at least `1000` |
54
+ | `KXM_MESSAGE_RETENTION_MS` | `604800000` (7 days) | How long replied, cancelled and expired messages are kept, at least `1000` |
55
+ | `KXM_RATE_LIMIT_MAX` | `600` | Requests accepted per client and window, at least `1` |
56
+ | `KXM_RATE_LIMIT_WINDOW_MS` | `60000` | Rate-limit window, at least `100` |
57
+
58
+ ### Hub credentials
59
+
60
+ When `KXM_AUTH_TOKEN` is unset, `kxm hub start` reuses the admin token saved in `hub-env.json` under the [user state root](config-reference.md#state-outside-the-project). On first start it generates one, saves it with `0600` permissions, and reuses it on every restart, so workers and dashboards on the same machine share one credential. Delete the file and restart the hub to rotate a generated token.
61
+
62
+ Explicit `KXM_AUTH_TOKEN` and `KXM_PROJECT_TOKENS` values win and are saved for later restarts. `KXM_PROJECT_TOKENS` replaces the saved map rather than merging with it: a value that omits a project drops that project's token. List every project each time you set it; [Start the hub](../start/quickstart-claude-code.md#3-start-the-hub) shows a command that merges a new project into the saved map.
63
+
64
+ A project token is an authorization boundary: it registers agents only in its project and sees only that project's agents, messages and runs. Give agents project tokens and keep the admin token for operators. The [trust model](../concepts/trust-model.md) shows which credential reaches which endpoint.
65
+
66
+ > [!IMPORTANT]
67
+ > A hub on loopback with no admin token trusts every local caller and prints `auth=none`. `kxm hub start` always resolves or generates a token, so this happens only when you run the hub entry point directly.
68
+
69
+ ### Hub auto-start from the Pi extension
70
+
71
+ The `hub.autoStart` preference controls whether the Pi extension starts a hub itself. The default is `background`: on load the extension reuses a healthy bound hub, a live local hub claim, or a hub already answering at `KXM_SERVER_URL`, and only otherwise starts one in the background, logging to `.kxm/logs/hub-autostart.log`. Set `hub.autoStart: off` with `kxm config set hub.autoStart off` to disable it. The Claude Code plugin never starts a hub.
72
+
73
+ ### Hub log contents
74
+
75
+ The hub log records metadata, not message bodies. A context request is logged by size only: `context_packet_assembled` carries `taskChars`, `taskTokens` and `matchedCandidates`, and `context_recall` carries `queryChars`, `queryTokens`, `limit` and `results`. The task and query text appear only in the caller's own response. The SQLite database stores message bodies as sent and is not encrypted by KXM, so protect `.kxm/state/`.
76
+
77
+ ## Workspace directories
78
+
79
+ The hub, the CLI and the worker supervisor keep runtime files under one workspace directory. Set only `KXM_WORKSPACE_DIR` and the four derived directories move with it.
80
+
81
+ | Variable | Default | Effect |
82
+ |---|---|---|
83
+ | `KXM_WORKDIR` | The current directory | Base for relative paths; the repository a Pi worker runs in |
84
+ | `KXM_WORKSPACE_DIR` | `.kxm` | Root of the derived directories below |
85
+ | `KXM_LOGS_DIR` | `$KXM_WORKSPACE_DIR/logs` | Hub, worker and Pi logs |
86
+ | `KXM_ASSETS_DIR` | `$KXM_WORKSPACE_DIR/assets` | Durable workflow assets and exported retrospectives |
87
+ | `KXM_STATE_DIR` | `$KXM_WORKSPACE_DIR/state` | Hub database, Pi sessions, worker manifests and recovery files |
88
+ | `KXM_CONFIG_DIR` | `$KXM_WORKSPACE_DIR/config` | Legacy. Created on start; read only by `kxm session start`. JSON files there make a project unloadable (`legacy_state_unsupported`) |
89
+
90
+ These variables never move the project configuration files, which always live in `<project root>/.kxm/`. The CLI's `--workspace <dir>` flag overrides all of them for one command. See [Workspace layout](config-reference.md#workspace-layout-tracked-ignored-and-state) for what to commit and what to ignore.
91
+
92
+ ## Webhook workflow settings
93
+
94
+ Configure exactly one of these on the hub. With both set, the hub refuses to start.
95
+
96
+ | Variable | Default | Effect |
97
+ |---|---|---|
98
+ | `KXM_WEBHOOK_WORKFLOWS_FILE` | None | Path to a JSON file holding an array of [webhook workflow definitions](workflow-definitions.md#webhook-workflow-definitions) |
99
+ | `KXM_WEBHOOK_WORKFLOWS` | None | The same JSON array, inline |
100
+
101
+ Each definition names the variables that hold its secrets (`secretEnv`, `signalSecretEnv`); those variables must be set in the hub's environment when it starts, and in the environment of `kxm workflow start`, `kxm gate signal` and `kxm gate github watch`. Check a file with `kxm gate validate --file <path>` before you restart the hub.
102
+
103
+ ## Agent settings
104
+
105
+ Every agent client (the Pi extension, the Claude Code MCP server, and the `kxm peer` commands) reads these.
106
+
107
+ | Variable | Default | Effect |
108
+ |---|---|---|
109
+ | `KXM_SERVER_URL` | `http://127.0.0.1:7331` | Hub base URL. For the CLI, the machine's `kxm hub bind` URL is used when this is unset |
110
+ | `KXM_AUTH_TOKEN` | See below | The project token for this agent's project |
111
+ | `KXM_PROJECT` | `name` in `package.json` in the working directory, else the directory name | Project for discovery and authentication |
112
+ | `KXM_AGENT_NAME` | Harness-specific (see below) | Name peers see; unique among online agents in the project, compared case-insensitively |
113
+ | `KXM_AGENT_PURPOSE` | Harness-specific (see below) | One line peers use to decide what to send this agent |
114
+
115
+ | Harness | Default name | Default purpose | Token when `KXM_AUTH_TOKEN` is unset |
116
+ |---|---|---|---|
117
+ | Pi extension | The Pi session name, else `pi-<pid>` | `General-purpose coding agent` | This project's saved project token only; never the admin token |
118
+ | Claude Code MCP server | `claude` from the plugin settings, else `claude-<pid>` | `Claude Code implementation and review agent` | This project's saved project token only; never the admin token |
119
+ | `kxm peer` and `kxm workflow` agent commands | `cli-<pid>` | `CLI agent client` | This project's saved project token only; never the admin token (`project_token_missing`, exit 2) |
120
+
121
+ A clean shutdown marks an identity offline. Reconnecting with the same project and name resumes its durable agent ID and rotates its agent key. If the Claude Code name is already online in the project, the MCP server registers once more as `<name>-<pid>`.
122
+
123
+ ## Claude Code plugin settings
124
+
125
+ The plugin asks for `server_url`, `auth_token`, `agent_name`, `agent_purpose` and `project` when you install it, and passes them to its MCP server as `KXM_SERVER_URL`, `KXM_AUTH_TOKEN`, `KXM_AGENT_NAME`, `KXM_AGENT_PURPOSE` and `KXM_PROJECT`. It also sets `KXM_PROJECT_DIR` to the directory Claude Code started in. Change them with `/plugin configure kxm@kxm`. Every field, default and token rule is in [Claude Code plugin settings](config-reference.md#claude-code-plugin-settings) and the [plugin README](../../plugins/kxm/README.md).
126
+
127
+ ## Long-lived worker settings
128
+
129
+ `kxm agent worker` starts a supervised headless Pi process and passes these to it. The command's flags (`--model`, `--tools`, `--session-isolation` and the rest) set the same values; see [`kxm agent worker`](cli-reference.md#kxm-agent). How to run workers safely is in [Pi workers](../guides/pi-workers.md).
130
+
131
+ | Variable | Default | Effect |
132
+ |---|---|---|
133
+ | `KXM_AGENT_NAME`, `KXM_PROJECT` | None; required | The worker's identity in the hub |
134
+ | `KXM_PI_COMMAND` | `pi`, or `pi.cmd` on Windows | Pi executable when it is not on `PATH` |
135
+ | `KXM_WORKER_MODEL` | Pi's default | Primary model selector. Must pass the Pi native-vendor brake, or the worker exits with `pi_native_impersonation_blocked` before Pi starts |
136
+ | `KXM_WORKER_FALLBACK_MODELS` | None | Up to eight comma-separated selectors, tried in order after a final provider failure. Requires `KXM_WORKER_MODEL`. Each must pass the same brake |
137
+ | `KXM_WORKER_PROVIDER_RETRY_MS` | `60000` | Retry delay after a final provider failure with no unused fallback, `1000` to `3600000` |
138
+ | `KXM_WORKER_TOOLS` | Pi's defaults | Allowlist of 1 to 64 comma-separated Pi tool names |
139
+ | `KXM_WORKER_EXTENSION_PATHS` | Discovery | 1 to 16 extension files, separated by `:` (`;` on Windows); relative paths resolve inside `KXM_WORKDIR` |
140
+ | `KXM_WORKER_SKILL_PATHS` | Discovery | 1 to 16 skill files or directories, same separator and base |
141
+ | `KXM_WORKER_CONTINUE` | `true` | Resume the active Pi session after a restart; `false` never resumes |
142
+ | `KXM_WORKER_INITIAL_CONTINUE` | Same as `KXM_WORKER_CONTINUE` | `false` starts this supervisor's first child fresh and still resumes later restarts |
143
+ | `KXM_WORKER_SESSION_ISOLATION` | `off` | `workflow` gives each workflow run its own Pi session beside a stable default session |
144
+ | `KXM_WORKER_MAX_RUN_SESSIONS` | `128` | Workflow-specific sessions kept per worker, `1` to `1024`; least recently used inactive ones are evicted |
145
+ | `KXM_WORKER_TOOL_TIMEOUT_MS` | `1860000` (31 minutes) | Watchdog for one Pi tool call, `1000` to `86400000`; `0` disables it |
146
+ | `KXM_WORKER_ACTIVATION_TIMEOUT_MS` | `60000` | Deadline for a delivered request to start a model turn, `1000` to `600000`; expiry restarts the child and keeps the request |
147
+ | `KXM_WORKER_DRAIN_MS` | `15000` | Graceful shutdown wait before the child is killed |
148
+ | `KXM_WORKER_MAX_RESTARTS` | Unlimited | Non-negative restart limit |
149
+ | `KXM_WORKER_LOG_PATH` | `$KXM_LOGS_DIR/kxm-worker-<project>-<agent>-<id>.jsonl` | Structured supervisor lifecycle log |
150
+ | `KXM_AGENT_LOG_PATH` | `$KXM_LOGS_DIR/pi-agent-<project>-<agent>-<id>.log` | Captured Pi stdout and stderr. May contain model output; protect it |
151
+
152
+ Two rules matter for safety. Setting either resource-path variable turns off discovery for that category only, and the listed extensions and skills run with the worker's repository, network and model credentials, so review them like executable dependencies and never derive them from a webhook payload. The tool allowlist bounds tool names, not file paths: a worker that keeps `write`, `edit` or a shell tool can change any file its OS user can reach.
153
+
154
+ For example, a review-only worker that cannot edit the checkout:
155
+
156
+ ```bash
157
+ export KXM_WORKER_TOOLS="read,grep,find,ls,kxm_list,kxm_get,kxm_reply"
158
+ kxm agent worker --name reviewer --project <project> --model openrouter/qwen/qwen3-coder-plus
159
+ ```
160
+
161
+ <details><summary>PowerShell</summary>
162
+
163
+ ```powershell
164
+ $env:KXM_WORKER_TOOLS = "read,grep,find,ls,kxm_list,kxm_get,kxm_reply"
165
+ kxm agent worker --name reviewer --project <project> --model openrouter/qwen/qwen3-coder-plus
166
+ ```
167
+
168
+ </details>
169
+
170
+ ## Runtime supervisor settings
171
+
172
+ The Runtime supervisor runs `kxm run` workflows and syncs their summaries to the hub. See [Runtime sync](../operations/runtime-sync.md).
173
+
174
+ | Variable | Default | Effect |
175
+ |---|---|---|
176
+ | `KXM_STATE_HOME` | macOS `~/Library/Application Support/KXM`; Windows `%LOCALAPPDATA%\KXM`; Linux `$XDG_STATE_HOME/kxm`, else `~/.local/state/kxm` | User state root: Runtime event stores, supervisor token, `hub-env.json`, `hub-binding.json`, `update.yaml`. Must be absolute (`local_state_root_not_absolute`) |
177
+ | `KXM_RUNTIME_SYNC_INTERVAL_MS` | `10000` | How often the supervisor heartbeats and pushes its outbox, clamped to `250` through `60000` |
178
+ | `KXM_RUNTIME_STOP_GRACE_MS` | `30000` | How long a stopping supervisor waits for open drives, `0` to `600000`; an invalid value warns and uses the default |
179
+
180
+ ## CLI and session settings
181
+
182
+ | Variable | Default | Effect |
183
+ |---|---|---|
184
+ | `KXM_USER_CONFIG_DIR` | `~/.config/kxm` | User preferences, global roles and workflows, `session.token`, shell completions |
185
+ | `KXM_USER_TELEMETRY_DIR` | `~/.config/kxm/telemetry` | User telemetry directory |
186
+ | `KXM_SESSION_TOKEN` | None | Session token whose tool policy limits the `kxm_*` tools. When unset, the `session.token` file applies if present. An invalid or expired token blocks every tool |
187
+ | `KXM_SESSION_BRIEF` | Picker on | `off` disables the Pi task and plan picker at session start; the status line still shows |
188
+ | `KXM_WORKFLOW_ID` | None | Default definition for `kxm workflow start`; required by `kxm gate signal` and `kxm gate github watch` for a hub run |
189
+ | `KXM_WORKFLOW_SECRET`, `KXM_WORKFLOW_SIGNAL_SECRET` | None | Start and callback secrets, used only when no active definition source is configured |
190
+ | `GITHUB_TOKEN`, `GH_TOKEN` | None | GitHub API token for `kxm gate github watch` and `kxm update` |
191
+ | `KXM_IMPROVE_TARGET` | Inferred | `cli` or `project`; overrides the `target` label written on telemetry events. Nothing reads the label yet |
192
+ | `KXM_SKIP_COMPLETION_PROMPT`, `KXM_SKIP_GUIDE_SETUP_PROMPT` | Unset | Any value skips the interactive `kxm init` prompts for shell completion and workflow-catalog setup |
193
+ | `KXM_OPENROUTER_MODELS_URL` | OpenRouter's public model list | Catalog URL for `kxm models inventory-refresh`; `OPENROUTER_API_KEY` is sent when set |
194
+ | `KXM_BIN` | `kxm` | CLI the Pi `/kxm memory` command runs |
195
+ | `NO_COLOR`, `KXM_TUI_NO_COLOR` | Unset | Any value turns off color in `kxm dash` and the terminal panels |
196
+ | `KXM_PICK_SELECT` | Unset | Answers an interactive role picker with an index or ID, for scripts |
197
+ | `KXM_DAEMON` | Unset | `1` or `true` stops structured loggers from echoing to stdout |
198
+ | `KXM_ENTRY` | The running script | Entry point `kxm completion install` resolves the CLI directory from |
199
+ | `KXM_SESSION_ID` | Unset | Session ID stamped on gate command result envelopes |
200
+
201
+ ## Internal variables
202
+
203
+ KXM sets these for its own child processes. Do not set them yourself.
204
+
205
+ | Variable | Set by | Purpose |
206
+ |---|---|---|
207
+ | `KXM_PROJECT_DIR` | Claude Code plugin (`.mcp.json`) | Directory Claude Code started in; decides the default project and whether this is a KXM project |
208
+ | `KXM_ATTEMPT_TOKEN` | Runtime attempt dispatch | Attempt-scoped tool policy; `kxm_promote` needs an explicit grant in it |
209
+ | `KXM_WORKER_IDENTITY_KEY`, `KXM_WORKER_GENERATION`, `KXM_WORKER_CHILD_INCARCATION` | Worker supervisor | Binds the Pi child to its supervisor generation and incarnation |
210
+ | `KXM_WORKER_SESSION_SCOPE` | Worker supervisor | `default`, `legacy` or `workflow:<run-id>`: the session scope the child may serve |
211
+ | `KXM_USER_STATE_DIR`, `KXM_STATE_ROOT` | None (legacy aliases) | Read only by the local snapshot reader when `KXM_STATE_HOME` is unset; use `KXM_STATE_HOME` |
212
+
213
+ ## Maintainer critic script
214
+
215
+ `scripts/native-critic.mjs`, a maintainer tool in the KXM repository, runs a read-only Claude or Codex review, saves the result as a JSON artifact, and posts a notice through the hub. It reads two variables of its own. Neither is part of the shipped CLI.
216
+
217
+ | Variable | Default | Effect |
218
+ |---|---|---|
219
+ | `KXM_CRITIC_DIR` | `.kxm/assets/critic-reviews` in the current directory | Where the review artifact is written, with `0600` permissions |
220
+ | `KXM_REVIEW_TARGET` | The critic's own agent ID | Online agent, by name or ID, that receives the `review completed` notice |
221
+
222
+ The notice is transport only: it is not approval or hub peer-reply evidence.
223
+
224
+ ## Protocol limits
225
+
226
+ The hub and its clients enforce these fixed values. None of them is configurable except where the table names a variable.
227
+
228
+ ### Messages and transport
229
+
230
+ | Limit | Value |
231
+ |---|---|
232
+ | Message content | 32,000 characters |
233
+ | HTTP request body | 256 KiB (`payload_too_large`) |
234
+ | Request lifetime (`ttlMs`) | 1 second to 7 days; default 24 hours (`KXM_MESSAGE_TTL_MS`) |
235
+ | Terminal message retention | 7 days (`KXM_MESSAGE_RETENTION_MS`) |
236
+ | Hop limit (`maxHops`) | Default 5, at most 20 |
237
+ | Idempotency key, correlation ID | 128 characters each |
238
+ | Agent name, purpose, project, host label | 64, 256, 128 and 64 characters |
239
+ | Rate limit | 600 requests per 60 seconds per agent or address (`KXM_RATE_LIMIT_*`) |
240
+
241
+ ### Presence, waits and timeouts
242
+
243
+ | Limit | Value |
244
+ |---|---|
245
+ | Agent heartbeat interval | 10 seconds |
246
+ | Agent stale threshold (presence lease) | 30 seconds |
247
+ | SSE heartbeat | 15 seconds |
248
+ | Client request timeout | 15 seconds |
249
+ | `kxm_await` wait | 60 seconds, default and maximum |
250
+ | `kxm_fanout` local wait (`timeoutMs`) | 100 ms to 30 minutes; default 30 minutes |
251
+ | Workflow signal wait | 1 second to 30 days; default 24 hours |
252
+ | Fenced lease TTL | 5 seconds to 10 minutes; default 5 minutes |
253
+ | Runtime sync batch | 100 events |
254
+
255
+ ### Workflows and context
256
+
257
+ | Limit | Value |
258
+ |---|---|
259
+ | Evidence per checkpoint or wait | 64 keys; each key 128 characters, each value 1,000 characters |
260
+ | Evidence references | 32 requirements; 1 to 16 message IDs each |
261
+ | Checkpoint or wait summary | 4,000 characters |
262
+ | Journal entry | Summary 1,000 characters, details 8,000, 32 evidence strings, 16 related entries |
263
+ | Context task, role | 2,000 and 64 characters |
264
+ | Context budget (`budgetTokens`) | 512 to 200,000; default by role, 32,000 for an unknown role |
265
+ | Recall results | 1 to 100; default 25 |
266
+ | Finished hub workflow runs and their journal | Purged 7 days after they finish; not configurable. Exported retrospectives remain |
267
+
268
+ Limits on webhook workflow definitions are in [Workflow definitions](workflow-definitions.md#limits).
269
+
270
+ ### Timeouts, retries and idempotency
271
+
272
+ `ttlMs` bounds how long a request stays valid, including time queued behind other work. `kxm_fanout.timeoutMs` bounds only how long the caller waits. A local wait that ends first returns `status: pending` with the durable `messageId`; it does not cancel the request. Normally omit `ttlMs` for model work.
273
+
274
+ An automated sender should set a stable `idempotencyKey`, so an exact retry returns the original message instead of a duplicate. Reusing a key with different content fails with `idempotency_conflict`. While a request is pending, check it with `kxm_get` or repeat the exact call; do not mint a new key. `kxm_fanout` derives each target's key from `idempotencyKeyPrefix`, the correlation ID and the target name.
275
+
276
+ Correlation IDs and idempotency keys never prove where evidence came from. For a peer-reply requirement, pass `workflowContext` and cite the replies in `evidenceRefs`; see [Peer provenance and quorum gates](../guides/provenance-gates.md).
277
+
278
+ When a Pi peer's final response exceeds 32,000 characters, the extension replies with a truncated response and a note instead of leaving the request pending. The full output may remain in that peer's Pi session or `pi-agent-*.log`.
279
+
280
+ ## Delivery modes
281
+
282
+ A request's `delivery` tells the receiving harness when to handle it.
283
+
284
+ | Mode | Use it when | Effect |
285
+ |---|---|---|
286
+ | `followUp` | Normal delegation; the default | Handled after the receiver's current work settles |
287
+ | `steer` | An active blocker needs a course change | Delivered at the receiver's next decision boundary |
288
+ | `nextTurn` | Context that should not interrupt | Stored with the message. The Pi extension handles it like `followUp`; the Claude MCP server passes it on as `delivery` metadata |
289
+
290
+ Webhook workflow definitions accept only `followUp` and `steer`, and `kxm_fanout` always sends `followUp`.
291
+
292
+ ## Related
293
+
294
+ - [Configuration file reference](config-reference.md): every `.kxm` file and `kxm.config.v1` key
295
+ - [CLI reference](cli-reference.md): every command and flag
296
+ - [Agent tools](tools.md): the `kxm_*` tools and their parameters
297
+ - [Hub HTTP API](http-api.md): routes, credentials and error codes
298
+ - [Trust model](../concepts/trust-model.md): which credential reaches what
299
+ - [Nous providers](../guides/nous-providers.md): opt-in Nous model providers for Pi