@kontextmind/kxm 0.7.94 → 0.7.96
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.
- package/.claude-plugin/marketplace.json +1 -1
- package/.kxm/README.md +39 -9
- package/CHANGELOG.md +1 -1
- package/README.md +147 -257
- package/SECURITY.md +21 -12
- package/docs/README.md +133 -54
- package/docs/adr/ADR-0002-browser-automation-steel-doks.md +24 -18
- package/docs/adr/ADR-0003-sqlite-only-store.md +100 -0
- package/docs/adr/ADR-0004-edge-identity-authentik.md +99 -0
- package/docs/adr/README.md +33 -0
- package/docs/concepts/architecture.md +262 -0
- package/docs/concepts/data-and-storage.md +194 -0
- package/docs/concepts/trust-model.md +152 -0
- package/docs/contracts/README.md +22 -14
- package/docs/contracts/effects-and-recovery.md +3 -0
- package/docs/contracts/migration.md +2 -2
- package/docs/contracts/routing.md +6 -5
- package/docs/contributing/assignment-runner.md +388 -0
- package/docs/contributing/ci-and-release.md +231 -0
- package/docs/contributing/development.md +362 -0
- package/docs/contributing/harness-routing-internals.md +192 -0
- package/docs/{packages.md → contributing/packages.md} +13 -15
- package/docs/{skills → contributing}/repo-work-delivery.md +20 -21
- package/docs/contributing/test-matrix.md +208 -0
- package/docs/{tui-components.md → contributing/tui-components.md} +30 -22
- package/docs/contributing/writing-docs.md +340 -0
- package/docs/glossary.md +471 -0
- package/docs/guides/agent-skills.md +137 -0
- package/docs/guides/browser-automation.md +160 -0
- package/docs/guides/context-and-memory.md +352 -0
- package/docs/guides/continuous-improvement.md +228 -0
- package/docs/guides/governed-skills.md +173 -0
- package/docs/guides/nous-providers.md +186 -0
- package/docs/guides/peer-messaging.md +304 -0
- package/docs/guides/pi-workers.md +219 -0
- package/docs/guides/provenance-gates.md +313 -0
- package/docs/guides/webhook-workflows.md +364 -0
- package/docs/kb/how-credentials-retrieved-safely.md +38 -12
- package/docs/kb/how-to-capture-and-annotate-section.md +15 -13
- package/docs/kb/how-to-connect-playwright-to-steel.md +16 -11
- package/docs/kb/how-to-recover-expired-session-or-orphan.md +26 -16
- package/docs/kb/how-to-resume-after-mfa.md +19 -11
- package/docs/kb/how-to-take-over-session.md +17 -13
- package/docs/kb/why-authentication-disappeared.md +22 -14
- package/docs/kb/why-automation-opened-different-browser.md +23 -14
- package/docs/kb/why-session-viewer-cannot-control.md +13 -12
- package/docs/operations/backup-and-restore.md +248 -0
- package/docs/operations/deploy.md +307 -0
- package/docs/operations/monitoring.md +209 -0
- package/docs/operations/runtime-sync.md +192 -0
- package/docs/operations/troubleshooting.md +265 -0
- package/docs/operations/upgrade.md +124 -0
- package/docs/prompts/browser-annotate-feedback.md +7 -7
- package/docs/prompts/browser-diagnose-recover.md +11 -10
- package/docs/prompts/browser-explore.md +7 -7
- package/docs/prompts/browser-repro-fix.md +7 -7
- package/docs/prompts/browser-start.md +12 -11
- package/docs/prompts/browser-takeover.md +8 -8
- package/docs/{cli-reference.md → reference/cli-reference.md} +83 -41
- package/docs/{config-reference.md → reference/config-reference.md} +159 -148
- package/docs/reference/configuration.md +299 -0
- package/docs/reference/harness-routing.md +508 -0
- package/docs/reference/http-api.md +203 -0
- package/docs/reference/tools.md +370 -0
- package/docs/{workflow-guide.md → reference/workflow-catalog.md} +92 -153
- package/docs/reference/workflow-definitions.md +286 -0
- package/docs/start/first-workflow.md +287 -0
- package/docs/start/install.md +146 -0
- package/docs/start/quickstart-claude-code.md +405 -0
- package/docs/start/quickstart-pi.md +213 -0
- package/docs/templates/README.md +78 -73
- package/docs/templates/adr.md +13 -13
- package/docs/templates/architecture.md +55 -71
- package/docs/templates/bug-fix.md +13 -16
- package/docs/templates/feature.md +14 -19
- package/docs/templates/handoff.md +44 -46
- package/docs/templates/postmortem.md +30 -43
- package/docs/templates/research.md +15 -20
- package/docs/templates/review.md +49 -50
- package/docs/templates/runbook.md +38 -30
- package/docs/templates/test-plan.md +16 -23
- package/docs/templates/test-report.md +14 -17
- package/examples/README.md +9 -5
- package/examples/provenance-workflow.json +1 -1
- package/examples/webhook-workflows/jira-development.json +59 -0
- package/examples/webhook-workflows/jira-issue-updated.json +12 -0
- package/package.json +2 -2
- package/packages/core/tui/README.md +1 -1
- package/plugins/kxm/.claude-plugin/plugin.json +1 -1
- package/plugins/kxm/README.md +31 -32
- package/plugins/kxm/dist/cli.js +5 -5
- package/plugins/kxm/dist/mcp-server.js +1 -1
- package/plugins/kxm/dist/runtime.js +1 -1
- package/plugins/kxm/package.json +1 -1
- package/plugins/kxm/skills/kxm/references/protocol.md +3 -1
- package/plugins/kxm/skills/kxm-browser-auth/SKILL.md +1 -1
- package/plugins/kxm/skills/kxm-browser-diagnostics/SKILL.md +5 -5
- package/plugins/kxm/skills/kxm-browser-explore/SKILL.md +2 -2
- package/plugins/kxm/skills/kxm-browser-session/SKILL.md +10 -13
- package/plugins/kxm/skills/kxm-browser-takeover/SKILL.md +1 -1
- package/plugins/kxm/skills/kxm-browser-verify/SKILL.md +1 -1
- package/plugins/kxm/skills/kxm-context-memory/SKILL.md +13 -4
- package/plugins/kxm/skills/kxm-hub-ops/SKILL.md +3 -1
- package/plugins/kxm/skills/kxm-mind-setup/SKILL.md +2 -1
- package/plugins/kxm/skills/kxm-project-setup/SKILL.md +31 -54
- package/plugins/kxm/skills/kxm-projects/SKILL.md +1 -1
- package/plugins/kxm/skills/kxm-protocol/SKILL.md +1 -1
- package/plugins/kxm/skills/kxm-routing-improve/SKILL.md +15 -7
- package/plugins/kxm/skills/kxm-runs/SKILL.md +11 -5
- package/plugins/kxm/skills/kxm-session/SKILL.md +1 -1
- package/plugins/kxm/skills/kxm-tasks/SKILL.md +9 -7
- package/plugins/kxm/skills/kxm-workflow/SKILL.md +10 -2
- package/plugins/kxm/src/cli/system.ts +1 -1
- package/plugins/kxm/src/cli.ts +3 -3
- package/plugins/kxm/src/init-guide-setup.ts +1 -1
- package/plugins/kxm/src/mcp-server.ts +1 -1
- package/plugins/kxm/src/modes.ts +1 -1
- package/schemas/README.md +1 -1
- package/docs/agent-communication-envelopes-and-gates.md +0 -553
- package/docs/agent-skills.md +0 -198
- package/docs/architecture.md +0 -245
- package/docs/assignment-runner.md +0 -264
- package/docs/browser-automation.md +0 -139
- package/docs/configuration.md +0 -437
- package/docs/continuous-improvement.md +0 -226
- package/docs/getting-started.md +0 -277
- package/docs/harness-routing.md +0 -616
- package/docs/kb/qa-authentik-authentication.md +0 -97
- package/docs/kb/qa-extension-install-and-hub-bootstrap.md +0 -85
- package/docs/kb/qa-hub-on-a-public-host.md +0 -48
- package/docs/kb/qa-sqlite-vs-duckdb.md +0 -35
- package/docs/kb/qa-what-the-hub-stores.md +0 -64
- package/docs/kxm-handbook.md +0 -1181
- package/docs/operations.md +0 -510
- package/docs/operator-pi-packages.md +0 -67
- package/docs/provenance-gates.md +0 -295
- package/docs/skills.md +0 -47
- package/docs/test-matrix.md +0 -132
- package/docs/troubleshooting.md +0 -293
- package/docs/webhook-workflows.md +0 -240
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
# Hub HTTP API reference
|
|
2
|
+
|
|
3
|
+
This page lists every route the KXM [hub](../glossary.md#hub) serves: method, path, the credential it requires, what it does and the errors you are most likely to see. It also covers the Runtime supervisor's local API. KXM's own clients (the CLI, the Pi extension and the Claude Code plugin) are the supported way to use these routes; request and response shapes follow KXM releases and carry no separate compatibility promise beyond the `/v1` prefix.
|
|
4
|
+
|
|
5
|
+
## Conventions
|
|
6
|
+
|
|
7
|
+
| Topic | Rule |
|
|
8
|
+
|---|---|
|
|
9
|
+
| Base URL | `http://127.0.0.1:7331` by default (`KXM_HOST`, `KXM_PORT`) |
|
|
10
|
+
| Request bodies | JSON objects with `content-type: application/json` (`unsupported_media_type`, 415), at most 256 KiB (`payload_too_large`, 413) |
|
|
11
|
+
| Errors | `{ "error": "<message>", "code": "<code>", "requestId": "<id>" }`, sometimes with hints such as `nextAction` or `assignedCoordinatorName`. A 500 says only `internal server error` |
|
|
12
|
+
| Request IDs | Send `x-request-id` (letters, digits, `.`, `_`, `-`, up to 80) to have it echoed; otherwise the hub assigns one |
|
|
13
|
+
| Rate limit | All routes but `/health` and `/ready` count per agent ID, else per address. Headers `x-ratelimit-limit`, `x-ratelimit-remaining`; over the limit, 429 `rate_limited` with `retry-after` |
|
|
14
|
+
| Unknown routes | 404 `route_not_found` |
|
|
15
|
+
| Limits | Field lengths and ranges are in [Protocol limits](configuration.md#protocol-limits) |
|
|
16
|
+
|
|
17
|
+
## Authentication
|
|
18
|
+
|
|
19
|
+
Each route requires one of these credential classes. Send tokens as `Authorization: Bearer <token>`; never put a token in a URL.
|
|
20
|
+
|
|
21
|
+
| Class | What to send | Notes |
|
|
22
|
+
|---|---|---|
|
|
23
|
+
| None | Nothing | Public health probes only |
|
|
24
|
+
| Admin | The admin token (`KXM_AUTH_TOKEN` on the hub) | A loopback hub with no admin token at all accepts any caller |
|
|
25
|
+
| Admin, configured | The admin token | Answers 503 `admin_auth_not_configured` when the hub has no admin token, even on loopback |
|
|
26
|
+
| Project | The project's token, or the admin token for a project with no token of its own | Admission for agent registration and Runtime sync |
|
|
27
|
+
| Agent | The project token plus `x-kxm-agent-id` and `x-kxm-agent-key` from registration | The agent key rotates on every registration (401 `invalid_agent_identity` when stale) |
|
|
28
|
+
| Agent or admin | Agent headers for your own project, or the admin token with an explicit `project` | Admin calls may name a caller in `x-kxm-caller-id` |
|
|
29
|
+
| Signed | HMAC-SHA256 of the raw body in `x-hub-signature-256` (or `x-hub-signature`) as `sha256=<hex>`, plus a delivery ID | No bearer token; the secret is the workflow definition's |
|
|
30
|
+
|
|
31
|
+
A wrong or missing token is 401 `invalid_auth`. The [trust model](../concepts/trust-model.md) explains which person or process holds each credential.
|
|
32
|
+
|
|
33
|
+
## Health and operations
|
|
34
|
+
|
|
35
|
+
| Method | Path | Auth | Purpose |
|
|
36
|
+
|---|---|---|---|
|
|
37
|
+
| `GET` | `/health` | None | Liveness: `{ "ok": true, "agents": <online count> }` |
|
|
38
|
+
| `GET` | `/ready` | None | Storage readiness: `{ "ok", "storage": "sqlite" or "memory" }`; 503 when storage is unhealthy |
|
|
39
|
+
| `GET` | `/metrics` | Admin | Prometheus text: requests, errors, messages, workflows, leases, sync and Runtime heartbeat counters |
|
|
40
|
+
| `GET` | `/v1/ops/snapshot?project=<p>` | Admin, configured | Metadata for one project: agents, up to 16 open messages, up to 8 runs with stage progress, home Runtimes, recent plan summaries (120 characters) |
|
|
41
|
+
| `GET` | `/v1/ops/events?project=<p>` | Admin, configured | Server-sent events: an `ops` event naming the topic (`agents`, `messages`, `workflows`) whenever it changes; 15-second heartbeats |
|
|
42
|
+
|
|
43
|
+
Operations routes carry no message bodies. `kxm dash` and `kxm tenant status` use them. See [Monitoring](../operations/monitoring.md).
|
|
44
|
+
|
|
45
|
+
## Agents and presence
|
|
46
|
+
|
|
47
|
+
| Method | Path | Auth | Purpose |
|
|
48
|
+
|---|---|---|---|
|
|
49
|
+
| `POST` | `/v1/agents/register` | Project | Register or resume `name` in `project` with `purpose`, optional `model` and `host`. Returns the agent and a new `agentKey` (201 new, 200 resumed) |
|
|
50
|
+
| `GET` | `/v1/agents` | Agent | Agents in your project; `?includeOffline=true` adds registered offline agents |
|
|
51
|
+
| `POST` | `/v1/agents/<agentId>/heartbeat` | Agent | Renew your presence lease (clients send one every 10 seconds) |
|
|
52
|
+
| `DELETE` | `/v1/agents/<agentId>` | Agent | Mark yourself offline (204) |
|
|
53
|
+
|
|
54
|
+
Key errors: `duplicate_agent_name` (409, the name is online in the project), `invalid_agent_identity` (401). Presence (`online`, `stale`, `offline`) is computed from the hub's clock with a 30-second lease; agents never report their own presence.
|
|
55
|
+
|
|
56
|
+
## Messages and events
|
|
57
|
+
|
|
58
|
+
A message is a durable request between two agents in one project. The sequence below shows one agent session on the wire.
|
|
59
|
+
|
|
60
|
+
```mermaid
|
|
61
|
+
sequenceDiagram
|
|
62
|
+
participant A as Agent A
|
|
63
|
+
participant H as Hub
|
|
64
|
+
participant B as Agent B
|
|
65
|
+
A->>H: POST /v1/agents/register (project token)
|
|
66
|
+
H-->>A: agent record and agent key
|
|
67
|
+
A->>H: GET /v1/events?agentId=A (SSE stream)
|
|
68
|
+
B->>H: POST /v1/messages (target A)
|
|
69
|
+
H-->>A: event: message
|
|
70
|
+
A->>H: POST /v1/messages/:id/ack
|
|
71
|
+
A->>H: POST /v1/messages/:id/reply
|
|
72
|
+
H-->>B: event: reply
|
|
73
|
+
A->>H: POST /v1/agents/:id/heartbeat (every 10 s)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
| Method | Path | Auth | Purpose |
|
|
77
|
+
|---|---|---|---|
|
|
78
|
+
| `POST` | `/v1/messages` | Agent | Send a request: `target`, `content`, optional `delivery`, `correlationId`, `idempotencyKey`, `workflowContext`, `ttlMs`, `maxHops`, `allowOffline`. 202 new; 200 with `idempotent: true` for an exact retry |
|
|
79
|
+
| `GET` | `/v1/messages/<id>` | Agent | Read a message you sent or received |
|
|
80
|
+
| `POST` | `/v1/messages/<id>/ack` | Agent | Recipient marks a queued message `delivered` |
|
|
81
|
+
| `POST` | `/v1/messages/<id>/reply` | Agent | Recipient replies with `content`; the sender gets a `reply` event |
|
|
82
|
+
| `DELETE` | `/v1/messages/<id>` | Agent | Sender cancels a queued or delivered message |
|
|
83
|
+
| `GET` | `/v1/events?agentId=<id>` | Agent | Server-sent events for that agent: `ready`, then `message`, `reply`, `cancelled`, `expired` and `presence`. Pushes unacknowledged messages again on connect |
|
|
84
|
+
|
|
85
|
+
`GET /v1/events` with `presenceOnly=true` sends only `presence` events and is reserved for dashboard observers (`presence_stream_forbidden` otherwise).
|
|
86
|
+
|
|
87
|
+
Key errors: `target_not_found` (404), `self_target` and `hop_limit_reached` (400), `idempotency_conflict` (409), `message_not_found` (404), `message_forbidden` (403, not your message), `duplicate_reply` and `invalid_message_state` (409). A request with `workflowContext` adds the `workflow_context_*` and `workflow_evidence_*` codes listed under [`kxm_send`](tools.md#kxm_send).
|
|
88
|
+
|
|
89
|
+
> [!IMPORTANT]
|
|
90
|
+
> Delivery is at least once. A message stays `queued` or `delivered` until it is replied to, cancelled or expires. Whenever the recipient connects, including after a hub or agent restart, the hub pushes its `queued` messages again with the same message ID until the recipient acknowledges them. A `delivered` (acknowledged) message is not pushed again. Make side effects idempotent.
|
|
91
|
+
|
|
92
|
+
The hub tracks acknowledgement with a per-recipient cursor that moves to the highest acknowledged message, so a queued message older than one the recipient already acknowledged is not pushed again either.
|
|
93
|
+
|
|
94
|
+
## Workflows, journal and improvements
|
|
95
|
+
|
|
96
|
+
These routes serve the coordinator of a [webhook workflow run](workflow-definitions.md#webhook-workflow-definitions). Every agent route answers 403 `workflow_forbidden`, with `assignedCoordinatorName` and `nextAction: use_assigned_coordinator`, to any agent other than the run's coordinator.
|
|
97
|
+
|
|
98
|
+
| Method | Path | Auth | Purpose |
|
|
99
|
+
|---|---|---|---|
|
|
100
|
+
| `GET` | `/v1/workflows` | Agent | Runs in your project assigned to you |
|
|
101
|
+
| `GET` | `/v1/workflows/<runId>` | Agent | One run and its journal |
|
|
102
|
+
| `POST` | `/v1/workflows/<runId>/checkpoints` | Agent | Record the active stage's result: `stageId`, `status`, `summary`, `evidence`, `evidenceRefs`, optional `outcome` |
|
|
103
|
+
| `POST` | `/v1/workflows/<runId>/waits` | Agent | Park the active stage until a signed signal: `stageId`, `signalKey`, `summary`, optional evidence and `timeoutMs` (202) |
|
|
104
|
+
| `POST` | `/v1/workflows/<runId>/journal` | Agent | Add a journal entry: `category`, `area` or `stageId`, `summary`, optional `severity`, `details`, `evidence`, `relatedEntryIds` (201) |
|
|
105
|
+
| `POST` | `/v1/workflows/<runId>/degradations` | Admin, configured | Approve the policy's lower peer minimum for the current attempt: `stageId`, `requirementKey`, `reason` (201 new, 200 repeat) |
|
|
106
|
+
| `GET` | `/v1/improvements` | Agent | Improvement report for your project: `reports` by area and ranked cross-run `signals` |
|
|
107
|
+
| `POST` | `/v1/journal/<entryId>/promotion` | Admin | Move a promotable journal entry to `approved`, `rejected` or `quarantined` with `reason` and `evidenceRefs`; recorded as decided by `kxm-admin` |
|
|
108
|
+
|
|
109
|
+
Key errors: `workflow_not_found` (404), `workflow_stage_out_of_order`, `workflow_terminal`, `workflow_not_running` (409), `workflow_evidence_incomplete`, `workflow_provenance_invalid`, `invalid_workflow_evidence_refs`, `weakened_reproduction`, `plan_hash_required` (400), `invalid_journal_category`, `invalid_improvement_area`, `journal_evidence_required` (400), `workflow_degradation_forbidden` (400, the policy declares no degradation) and `workflow_degradation_conflict` (409, a different reason was already approved). The agent tools that call these routes are described in [Workflow tools](tools.md#workflow-tools).
|
|
110
|
+
|
|
111
|
+
## Webhooks and signals
|
|
112
|
+
|
|
113
|
+
| Method | Path | Auth | Purpose |
|
|
114
|
+
|---|---|---|---|
|
|
115
|
+
| `POST` | `/v1/webhooks/<definitionId>` | Signed with the definition's start secret | Start a run and prompt the coordinator (status codes below) |
|
|
116
|
+
| `POST` | `/v1/webhooks/<definitionId>/runs/<runId>/signals/<signalKey>` | Signed with the signal secret, else the start secret | Report an external result for a waiting stage: `status` (`passed`, `warning`, `failed`), `summary`, `evidence`. 202 when the coordinator is resumed, 200 otherwise |
|
|
117
|
+
|
|
118
|
+
A start answers 202 for a new run, 200 with `duplicate: true` for a known delivery ID, and 204 when the event or filter does not match.
|
|
119
|
+
|
|
120
|
+
The delivery ID comes from `x-atlassian-webhook-identifier`, `x-github-delivery` or `x-kxm-delivery-id`, in that order, and is required. The event comes from `x-github-event`, else the payload's `webhookEvent` or `event` field.
|
|
121
|
+
|
|
122
|
+
A start with a known delivery ID returns the existing run even if the body differs. A signal with a known delivery ID returns the original receipt when the body matches and 409 `workflow_signal_delivery_conflict` when it does not. Deduplication lasts as long as the run is retained.
|
|
123
|
+
|
|
124
|
+
Key errors: `webhook_not_found` (404), `webhook_signature_missing`, `webhook_signature_unsupported`, `webhook_signature_invalid` (401), `workflow_target_unavailable` (409, the coordinator never registered), `workflow_not_waiting`, `workflow_signal_mismatch` (409, the run waits for another key) and `workflow_signal_context_mismatch` (409, evidence names another run, stage or signal). See [Webhook workflows](../guides/webhook-workflows.md).
|
|
125
|
+
|
|
126
|
+
## Context and state
|
|
127
|
+
|
|
128
|
+
All context routes take a `project` in the body. An agent may name only its own project (`context_isolation_violation`, 403).
|
|
129
|
+
|
|
130
|
+
| Method | Path | Auth | Purpose |
|
|
131
|
+
|---|---|---|---|
|
|
132
|
+
| `POST` | `/v1/context/get` | Agent or admin | Assemble a context packet for `role` and `task`; returns `packet` and `audit` |
|
|
133
|
+
| `POST` | `/v1/context/recall` | Agent or admin | Search records by `query`, `kinds`, `limit`; returns metadata with `relevance` |
|
|
134
|
+
| `POST` | `/v1/context/state` | Agent or admin | Read one state `key`, optionally `asOf` a timestamp |
|
|
135
|
+
| `POST` | `/v1/context/state/propose` | Agent, or admin configured | Propose a state change (201 `proposalId`). An agent proposes as a peer, capped at `evidence` authority; the admin proposes as a human |
|
|
136
|
+
| `POST` | `/v1/context/state/promote` | Admin, configured | Promote `proposalId` with `evidence`; the promoter cannot be the proposer |
|
|
137
|
+
| `POST` | `/v1/context/episode` | Agent or admin | Error, lesson, observation and experiment entries, optionally for one `workflowRunId` |
|
|
138
|
+
| `POST` | `/v1/context/explain` | Agent or admin | Lineage, evidence references and sources behind one item `id` |
|
|
139
|
+
| `POST` | `/v1/context/wiki/compile` | Agent or admin | Compile the project's knowledge wiki pages with an audit and lint result |
|
|
140
|
+
|
|
141
|
+
Key errors: `invalid_context_request` (400), `state_proposer_mismatch` (403, `proposedBy` names someone else), `state_proposal_not_found` (404), `state_proposal_not_promotable` and `state_promotion_invalid` (400). The hub logs sizes, never the task or query text. See [Context and memory](../guides/context-and-memory.md).
|
|
142
|
+
|
|
143
|
+
## Leases
|
|
144
|
+
|
|
145
|
+
A lease gives one agent exclusive, fenced use of a named resource in its project, such as a branch. The hub prefixes the name with the caller's project, so two projects never contend.
|
|
146
|
+
|
|
147
|
+
| Method | Path | Auth | Purpose |
|
|
148
|
+
|---|---|---|---|
|
|
149
|
+
| `POST` | `/v1/leases/<name>/acquire` | Agent | Take or renew the lease; optional `ttlMs` (5 seconds to 10 minutes, default 5 minutes). Returns the lease and its `fencingToken` |
|
|
150
|
+
| `POST` | `/v1/leases/<name>/renew` | Agent | Extend it; requires your `fencingToken` |
|
|
151
|
+
| `POST` | `/v1/leases/<name>/release` | Agent | Release it; requires your `fencingToken` |
|
|
152
|
+
|
|
153
|
+
The fencing token increases only when a new holder takes over an expired lease. Refusals are `lease_held`, `lease_expired`, `lease_superseded` (409, with the current lease) and `lease_not_found` (404). Treat any refusal as "stop writing", not "retry". No bundled tool or command calls these routes yet.
|
|
154
|
+
|
|
155
|
+
## Runtime sync
|
|
156
|
+
|
|
157
|
+
A Runtime supervisor is a machine client, not an agent. It reports presence and pushes run summaries with the project token.
|
|
158
|
+
|
|
159
|
+
| Method | Path | Auth | Purpose |
|
|
160
|
+
|---|---|---|---|
|
|
161
|
+
| `POST` | `/v1/runtime/presence` | Project | Heartbeat a `runtimeId` and optional `host` for `project` (201 first time, 200 after) |
|
|
162
|
+
| `POST` | `/v1/sync/events` | Project | Push up to 100 `kxm.sync-event.v1` events for `project` from `runtimeId`. Returns a per-event outcome and each run's cursor |
|
|
163
|
+
|
|
164
|
+
Each event is accepted once per project, run and sequence. Identical bytes are a `duplicate`; different bytes under a used sequence are a `conflict` (`sync_<reason>`) and raise a security alert. An event from another Runtime is `rejected` with `sync_runtime_mismatch`, a malformed one with `sync_event_invalid`. A batch over 100 events is 413 `sync_batch_too_large`. See [Runtime sync](../operations/runtime-sync.md).
|
|
165
|
+
|
|
166
|
+
## Runtime supervisor local API
|
|
167
|
+
|
|
168
|
+
> [!NOTE]
|
|
169
|
+
> Internal. The supervisor serves this API on `127.0.0.1` at a port chosen at start, for the `kxm run`, `kxm runs` and `kxm runtime` commands on the same machine. Do not expose it.
|
|
170
|
+
|
|
171
|
+
Every route except `/healthz` requires `Authorization: Bearer` with the supervisor token from `supervisor.token` in the Runtime directory under the [user state root](config-reference.md#state-outside-the-project). Run routes take `projectRoot` (an absolute path) as a query parameter.
|
|
172
|
+
|
|
173
|
+
| Method | Path | Purpose |
|
|
174
|
+
|---|---|---|
|
|
175
|
+
| `GET` | `/healthz?nonce=<n>` | Liveness plus a keyed proof of the token, so a client can tell the real supervisor from a process on a reused port |
|
|
176
|
+
| `POST` | `/v1/shutdown` | Stop the supervisor |
|
|
177
|
+
| `GET` | `/v1/sync/status` | Outbox state per project: pending, acknowledged and refused rows, refusal codes, next attempt |
|
|
178
|
+
| `POST` | `/v1/sync/retry` | Re-queue durably refused outbox rows for `projectRoot` (`kxm runtime sync-retry`) |
|
|
179
|
+
| `POST` | `/v1/runs` | Create a run: `projectRoot`, `workflowId`, `prompt`, optional `commandId` |
|
|
180
|
+
| `GET` | `/v1/runs/<runId>` | The run projected from its events, with drive state |
|
|
181
|
+
| `GET` | `/v1/runs/<runId>/events?after=<n>` | Up to 500 run events after a sequence |
|
|
182
|
+
| `POST` | `/v1/runs/<runId>/drive` | Drive a run with `mode` `simulated` or `live`: 202 with a `driveId` to poll; 409 `run_busy` or `run_handoff_required` |
|
|
183
|
+
| `GET` | `/v1/runs/<runId>/drive` | The open drive session and up to 20 drive receipts |
|
|
184
|
+
| `POST` | `/v1/runs/<runId>/cancel` | Request cancellation; idempotent per `commandId` |
|
|
185
|
+
| `POST` | `/v1/runs/<runId>/signal` | Recovery for a blocked run: `action` `retry`, `unblock`, `fail` or `cancel` (default `unblock`) |
|
|
186
|
+
| `POST` | `/v1/runs/<runId>/wait` | Acknowledges only; it records nothing yet |
|
|
187
|
+
| `GET` | `/v1/drives/<driveId>` | One drive receipt, re-verified against the run's events |
|
|
188
|
+
| `GET` | `/v1/projects/<projectId>/runs` | Up to 50 runs of the bound project, each folded from its events |
|
|
189
|
+
|
|
190
|
+
A bad token is `runtime_auth_failed`; a missing parameter is `runtime_request_invalid`. The drive route accepts both modes. `kxm runs drive` drives live, with real harness calls, unless you pass `--simulated`.
|
|
191
|
+
|
|
192
|
+
## Web Studio server
|
|
193
|
+
|
|
194
|
+
`kxm studio serve` runs a separate local server, on `127.0.0.1:4242` by default, with `/`, `/health`, `GET /api/layout` and `POST /api/mutate`. It answers every route with `Access-Control-Allow-Origin: *`, so any web page in a local browser can read the layout. The mutate route requires a bearer session token only when one resolves; with none it accepts any caller. It accepts an allowlisted command name but executes nothing. See [`kxm studio serve`](cli-reference.md#kxm-studio-serve).
|
|
195
|
+
|
|
196
|
+
## Related
|
|
197
|
+
|
|
198
|
+
- [Agent tools](tools.md): the `kxm_*` tools built on these routes
|
|
199
|
+
- [Environment variables and limits](configuration.md): hub settings and protocol limits
|
|
200
|
+
- [Trust model](../concepts/trust-model.md): credentials and what each can reach
|
|
201
|
+
- [Webhook workflows](../guides/webhook-workflows.md): signing starts and signals
|
|
202
|
+
- [Monitoring](../operations/monitoring.md): health, readiness and metrics in practice
|
|
203
|
+
- [CLI reference](cli-reference.md): the commands that call these routes
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
# Agent tools reference
|
|
2
|
+
|
|
3
|
+
KXM gives every [agent](../glossary.md#agent) the same 19 `kxm_*` tools for peer messaging, durable workflows and project context. The Claude Code plugin publishes them over MCP, the Pi extension registers the same set, and the operator CLI offers many of the same operations. This page lists each tool's parameters, limits, results and errors, then the Pi slash commands and the Claude Code session hook.
|
|
4
|
+
|
|
5
|
+
## One catalog, three surfaces
|
|
6
|
+
|
|
7
|
+
One catalog in the plugin source defines every tool once: its name, JSON Schema parameters and implementation. The MCP server, the Pi extension and the CLI read that catalog, and KXM's tests fail if any of them drifts from it.
|
|
8
|
+
|
|
9
|
+
```mermaid
|
|
10
|
+
flowchart LR
|
|
11
|
+
CAT["Tool catalog<br/>19 kxm_* tools"] --> MCP["Claude Code plugin<br/>MCP server, stdio"]
|
|
12
|
+
CAT --> PI["Pi extension<br/>registered tools"]
|
|
13
|
+
CAT --> CLI["kxm peer and<br/>kxm workflow commands"]
|
|
14
|
+
MCP -- "HTTP as a registered agent" --> HUB[("KXM hub")]
|
|
15
|
+
PI -- "HTTP as a registered agent" --> HUB
|
|
16
|
+
CLI -- "HTTP as a short-lived agent" --> HUB
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
| Tool | Group | Changes state | CLI command |
|
|
20
|
+
|---|---|---|---|
|
|
21
|
+
| `kxm_list` | Peers | No | `kxm peer list` |
|
|
22
|
+
| `kxm_send` | Peers | Yes | `kxm peer send` |
|
|
23
|
+
| `kxm_get` | Peers | No | `kxm peer get` |
|
|
24
|
+
| `kxm_fanout` | Peers | Yes | `kxm peer fanout` |
|
|
25
|
+
| `kxm_await` | Peers | No | `kxm peer await` |
|
|
26
|
+
| `kxm_cancel` | Peers | Yes | `kxm peer cancel` |
|
|
27
|
+
| `kxm_inbox` | Peers | No | `kxm peer inbox` (always empty from the CLI) |
|
|
28
|
+
| `kxm_reply` | Peers | Yes | `kxm peer reply` |
|
|
29
|
+
| `kxm_workflow_list` | Workflows | No | None; `kxm workflow list` reads the local database instead |
|
|
30
|
+
| `kxm_workflow_get` | Workflows | No | None; `kxm workflow get` reads the local database instead |
|
|
31
|
+
| `kxm_workflow_checkpoint` | Workflows | Yes | `kxm workflow checkpoint` |
|
|
32
|
+
| `kxm_workflow_record` | Workflows | Yes | `kxm workflow record` |
|
|
33
|
+
| `kxm_workflow_wait` | Workflows | Yes | `kxm workflow wait` |
|
|
34
|
+
| `kxm_improvement_report` | Workflows | No | None |
|
|
35
|
+
| `kxm_context` | Context | No | `kxm context get` (admin token in `KXM_AUTH_TOKEN`) |
|
|
36
|
+
| `kxm_recall` | Context | No | `kxm context recall` (admin token) |
|
|
37
|
+
| `kxm_state` | Context | No | `kxm context state` (admin token) |
|
|
38
|
+
| `kxm_episode` | Context | No | `kxm context episode` (admin token) |
|
|
39
|
+
| `kxm_promote` | Context | Yes (proposal only) | None; `kxm context promote` applies a proposal |
|
|
40
|
+
|
|
41
|
+
The workflow tools act on hub [webhook workflow runs](workflow-definitions.md#webhook-workflow-definitions). Runs created by `kxm run` belong to the Runtime; inspect those with `kxm runs status`.
|
|
42
|
+
|
|
43
|
+
## Common behavior
|
|
44
|
+
|
|
45
|
+
### Identity and credentials
|
|
46
|
+
|
|
47
|
+
Each tool call acts as the calling session's registered agent in one hub project. The Claude Code MCP server authenticates with a project token only: `auth_token` from the plugin settings, else this project's token saved in `hub-env.json`, and never the admin token. The Pi extension uses `KXM_AUTH_TOKEN`, then the admin token that hub auto-start resolved or generated for the hub it started, then the saved admin token. See [Agent settings](configuration.md#agent-settings).
|
|
48
|
+
|
|
49
|
+
### Tool policy
|
|
50
|
+
|
|
51
|
+
A session token or Runtime attempt token can restrict which tools run. KXM checks `KXM_ATTEMPT_TOKEN` first, then `KXM_SESSION_TOKEN`, then the `session.token` file in the user configuration directory; with none of them, every tool is allowed. A denied call fails with `tool_policy_denied`, and an invalid or expired token blocks every tool.
|
|
52
|
+
|
|
53
|
+
| Policy field | Effect |
|
|
54
|
+
|---|---|
|
|
55
|
+
| `deny` | Names that never run. Wins over `allow` |
|
|
56
|
+
| `allow` | When non-empty, only these names run |
|
|
57
|
+
| `preset: read-only` | Blocks `kxm_send`, `kxm_fanout`, `kxm_cancel`, `kxm_reply`, `kxm_workflow_checkpoint`, `kxm_workflow_record`, `kxm_workflow_wait` and `kxm_promote` |
|
|
58
|
+
|
|
59
|
+
A name matches as the full tool name, the name without `kxm_`, `*`, or a trailing-`*` prefix such as `kxm_workflow_*`. Under an attempt token, `kxm_promote` also needs an explicit `allow` entry (`attempt_token_admin_denied`).
|
|
60
|
+
|
|
61
|
+
### Results and errors
|
|
62
|
+
|
|
63
|
+
Every tool returns its result as JSON text; Pi also attaches the same value as structured details. Errors reach the model as text that names the next step:
|
|
64
|
+
|
|
65
|
+
| Error text | Harness | Fix |
|
|
66
|
+
|---|---|---|
|
|
67
|
+
| `KXM has no project token for project <p> on this machine` | Claude Code | Set `auth_token` with `/plugin configure kxm@kxm`, or [give the project a token](../start/quickstart-claude-code.md#give-the-project-a-token-on-the-running-hub) on the hub |
|
|
68
|
+
| `KXM hub unreachable at <url> (<cause>)` | Claude Code | Start the hub with `kxm hub start`, or correct `server_url` |
|
|
69
|
+
| `KXM hub rejected the project token for project <p>` | Claude Code | Enter that project's token from the hub's `KXM_PROJECT_TOKENS` |
|
|
70
|
+
| `kxm hub is not connected; check KXM_SERVER_URL and /kxm hub` | Pi | Start the hub or fix `KXM_SERVER_URL`, then restart the session |
|
|
71
|
+
| `tool_policy_denied: …` | Both | Lift the policy; see [Troubleshooting](../operations/troubleshooting.md) |
|
|
72
|
+
| Hub refusal, for example `stage review is not currently active` | Both | Pi appends `[code=<code> …]`; Claude Code shows the message only |
|
|
73
|
+
|
|
74
|
+
The hub's error codes are listed with each tool below and in the [HTTP API reference](http-api.md).
|
|
75
|
+
|
|
76
|
+
## Peer tools
|
|
77
|
+
|
|
78
|
+
Peer tools send and answer [requests](../glossary.md#message) between agents in the same project. A request is durable: it survives restarts of the hub and of either agent, and delivery is at least once. See [Peer messaging](../guides/peer-messaging.md) for patterns.
|
|
79
|
+
|
|
80
|
+
### `kxm_list`
|
|
81
|
+
|
|
82
|
+
Lists agents in this project with presence computed from the hub's clock.
|
|
83
|
+
|
|
84
|
+
| Parameter | Type | Default | Notes |
|
|
85
|
+
|---|---|---|---|
|
|
86
|
+
| `includeOffline` | Boolean | `false` | Also list registered agents whose presence lease expired |
|
|
87
|
+
|
|
88
|
+
Returns `{ "agents": [...] }`. Each agent has `id`, `name`, `purpose`, `project`, `connectedAt`, `lastSeenAt`, `leaseExpiresAt` and `presence` (`online`, `stale` or `offline`), plus `model` and `host` when the agent declared them. The list includes the caller. Agent keys are never returned.
|
|
89
|
+
|
|
90
|
+
### `kxm_send`
|
|
91
|
+
|
|
92
|
+
Sends one focused request to one peer.
|
|
93
|
+
|
|
94
|
+
| Parameter | Type | Default or limit | Notes |
|
|
95
|
+
|---|---|---|---|
|
|
96
|
+
| `target` | String, required | 80 characters | Peer name (case-insensitive) or agent ID |
|
|
97
|
+
| `content` | String, required | 32,000 characters | The request and the expected response |
|
|
98
|
+
| `delivery` | `followUp`, `steer`, `nextTurn` | `followUp` | See [Delivery modes](configuration.md#delivery-modes) |
|
|
99
|
+
| `correlationId` | String | 128 characters | Groups related requests. With `workflowContext` it must equal the run ID, and defaults to it |
|
|
100
|
+
| `idempotencyKey` | String | 128 characters | An exact retry returns the original message |
|
|
101
|
+
| `workflowContext` | Object | None | `runId`, `stageId`, `requirementKey`, `attempt` (1 to 20); marks the reply as peer evidence |
|
|
102
|
+
| `ttlMs` | Number | 1,000 to 604,800,000; hub default 24 hours | How long the request stays valid |
|
|
103
|
+
| `allowOffline` | Boolean | `false` | Queue for a registered peer that is offline |
|
|
104
|
+
|
|
105
|
+
Returns `{ "messageId", "status", "target" }`.
|
|
106
|
+
|
|
107
|
+
Key errors: `target_not_found` (no online peer by that name or ID), `self_target`, `idempotency_conflict` (the key was used for a different request). With `workflowContext`: `workflow_context_forbidden` (you are not the run's coordinator), `workflow_context_inactive` (not the active stage), `workflow_context_attempt_mismatch`, `workflow_evidence_policy_missing` (the requirement takes no peer evidence), `workflow_evidence_producer_forbidden` (the target is not eligible), and `workflow_context_correlation_mismatch`.
|
|
108
|
+
|
|
109
|
+
### `kxm_get`
|
|
110
|
+
|
|
111
|
+
Reads a request's current state and reply without waiting.
|
|
112
|
+
|
|
113
|
+
| Parameter | Type | Notes |
|
|
114
|
+
|---|---|---|
|
|
115
|
+
| `messageId` | String, required | A request you sent or received |
|
|
116
|
+
|
|
117
|
+
Returns the message record: `id`, `from`, `fromName`, `to`, `toName`, `content`, `delivery`, `status`, `createdAt`, `expiresAt`, and when present `reply`, `deliveredAt`, `repliedAt`, `error`, `correlationId` and `workflowContext`. Status is `queued`, `delivered`, `replied`, `cancelled` or `expired`. Errors: `message_not_found`, `message_forbidden` (you are neither sender nor recipient).
|
|
118
|
+
|
|
119
|
+
### `kxm_fanout`
|
|
120
|
+
|
|
121
|
+
Sends the same request to one to three peers independently and waits for their replies.
|
|
122
|
+
|
|
123
|
+
| Parameter | Type | Default or limit | Notes |
|
|
124
|
+
|---|---|---|---|
|
|
125
|
+
| `targets` | Array of strings, required | 1 to 3 | Duplicates, compared case-insensitively, are merged |
|
|
126
|
+
| `content` | String, required | 32,000 characters | Sent unchanged to every target |
|
|
127
|
+
| `correlationId` | String | 128 characters | As for `kxm_send` |
|
|
128
|
+
| `idempotencyKeyPrefix` | String | None | Each target's key derives from the prefix, correlation ID and target |
|
|
129
|
+
| `workflowContext` | Object | None | Shared by every request; each target must be eligible |
|
|
130
|
+
| `ttlMs` | Number | 1,000 to 604,800,000 | Request lifetime |
|
|
131
|
+
| `timeoutMs` | Number | 100 to 1,800,000; default 30 minutes | Local wait only; never cancels a request |
|
|
132
|
+
|
|
133
|
+
Every request uses `followUp` delivery. Returns `{ "responses": [...] }` with one entry per target:
|
|
134
|
+
|
|
135
|
+
- Finished: `target`, `messageId`, `status` (`replied`, `cancelled` or `expired`), and `reply` or `error`.
|
|
136
|
+
- Still running when the wait ends: `status: "pending"`, `messageId`, `messageStatus`, `expiresAt` and `waitStatus` (`timed_out` or `aborted`). Check it later with `kxm_get`, or repeat the exact call.
|
|
137
|
+
- Failed to send: `status: "error"` and `error`. One failed target does not fail the others.
|
|
138
|
+
|
|
139
|
+
### `kxm_await`
|
|
140
|
+
|
|
141
|
+
Waits for a sent request to finish.
|
|
142
|
+
|
|
143
|
+
| Parameter | Type | Default or limit | Notes |
|
|
144
|
+
|---|---|---|---|
|
|
145
|
+
| `messageId` | String, required | None | A request you sent |
|
|
146
|
+
| `timeoutMs` | Number | 100 to 60,000; default 60,000 | Larger values are capped at 60 seconds |
|
|
147
|
+
|
|
148
|
+
Returns the message record once it is `replied`, `cancelled` or `expired`. When the wait ends first, the call fails with `timed out waiting for <messageId>`; the request is still pending, so check it later with `kxm_get`. For long external work, use `kxm_workflow_wait` instead.
|
|
149
|
+
|
|
150
|
+
### `kxm_cancel`
|
|
151
|
+
|
|
152
|
+
Cancels a request you sent that has not been answered.
|
|
153
|
+
|
|
154
|
+
| Parameter | Type | Notes |
|
|
155
|
+
|---|---|---|
|
|
156
|
+
| `messageId` | String, required | A queued or delivered request you sent |
|
|
157
|
+
|
|
158
|
+
Returns the message record with `status: "cancelled"`. Cancelling an already cancelled request returns it unchanged. Errors: `message_forbidden` (you did not send it), `invalid_message_state` (it already has a reply or expired). Cancelling stops KXM processing only; it cannot undo files or external effects the peer already changed.
|
|
159
|
+
|
|
160
|
+
### `kxm_inbox`
|
|
161
|
+
|
|
162
|
+
Lists inbound requests that still need a reply. It takes no parameters.
|
|
163
|
+
|
|
164
|
+
- **Claude Code:** returns `{ "messages": [...] }` from the session's inbox, which fills from the hub's event stream while the session is registered. Before returning, it re-reads each request and drops those already answered, cancelled or expired. This is pull mode; see [Pushed channel mode and pull mode](../../plugins/kxm/README.md#pushed-channel-mode-and-pull-mode).
|
|
165
|
+
- **Pi:** always returns an empty list. The extension turns each inbound request into a model turn instead.
|
|
166
|
+
- **CLI:** always returns an empty list, because a one-shot command holds no inbox.
|
|
167
|
+
|
|
168
|
+
### `kxm_reply`
|
|
169
|
+
|
|
170
|
+
Sends the final reply to an inbound request.
|
|
171
|
+
|
|
172
|
+
| Parameter | Type | Default or limit | Notes |
|
|
173
|
+
|---|---|---|---|
|
|
174
|
+
| `messageId` | String, required | None | A request addressed to you |
|
|
175
|
+
| `content` | String, required | 32,000 characters | The result, with evidence and remaining risks |
|
|
176
|
+
|
|
177
|
+
Returns `{ "messageId", "status": "replied", "recipient" }`. Errors: `message_forbidden` (not addressed to you), `duplicate_reply`, `invalid_message_state` (cancelled or expired).
|
|
178
|
+
|
|
179
|
+
> [!IMPORTANT]
|
|
180
|
+
> Replying to a workflow run's coordinator prompt while the run is still `running` fails the run. Pass every checkpoint, or call `kxm_workflow_wait`, before you reply.
|
|
181
|
+
|
|
182
|
+
In Pi you rarely call `kxm_reply`: the extension sends the settled final response as the reply automatically, truncated to 32,000 characters with a note if it is longer.
|
|
183
|
+
|
|
184
|
+
## Workflow tools
|
|
185
|
+
|
|
186
|
+
Workflow tools are for the coordinator a webhook workflow run is assigned to. Only that agent can read, checkpoint, wait on or journal the run; any other agent gets `workflow_forbidden`, with the assigned coordinator's name. See [Webhook workflows](../guides/webhook-workflows.md) for the coordinator procedure.
|
|
187
|
+
|
|
188
|
+
### `kxm_workflow_list`
|
|
189
|
+
|
|
190
|
+
Lists the webhook workflow runs in this project assigned to you, in any status, until the hub purges them. It takes no parameters and returns `{ "runs": [...] }`.
|
|
191
|
+
|
|
192
|
+
### `kxm_workflow_get`
|
|
193
|
+
|
|
194
|
+
Reads one run and its journal.
|
|
195
|
+
|
|
196
|
+
| Parameter | Type | Notes |
|
|
197
|
+
|---|---|---|
|
|
198
|
+
| `runId` | String, required | A run assigned to you |
|
|
199
|
+
|
|
200
|
+
Returns `{ "run", "journal" }`. The run holds `status` (`running`, `waiting`, `completed` or `failed`), `currentStage`, every stage's instructions, required evidence, attempts and evidence, any active `waiting` state, and typed transitions. Errors: `workflow_not_found`, `workflow_forbidden`.
|
|
201
|
+
|
|
202
|
+
### `kxm_workflow_checkpoint`
|
|
203
|
+
|
|
204
|
+
Records the result of the active stage.
|
|
205
|
+
|
|
206
|
+
| Parameter | Type | Default or limit | Notes |
|
|
207
|
+
|---|---|---|---|
|
|
208
|
+
| `runId` | String, required | None | The run |
|
|
209
|
+
| `stageId` | String, required | None | Must be the current stage |
|
|
210
|
+
| `status` | `passed`, `warning`, `failed`, required | None | The stage outcome |
|
|
211
|
+
| `summary` | String, required | 4,000 characters | Changes, verification and remaining risks |
|
|
212
|
+
| `evidence` | Object of strings | 64 keys; values 1,000 characters | Keyed by required evidence name |
|
|
213
|
+
| `evidenceRefs` | Object | 32 requirements; 1 to 16 message IDs each | `{ "<requirement>": { "messageIds": [...] } }` for peer-reply requirements; only on `passed` |
|
|
214
|
+
|
|
215
|
+
Evidence keys are compared after trimming, collapsing whitespace and lowercasing. A `passed` checkpoint must cover every required key; a key with a peer-reply policy is satisfied only by verified `evidenceRefs`, never by an evidence string. A `warning` or `failed` checkpoint consumes an attempt and asks you to fix and retry; when the attempts reach the stage's `maxAttempts`, the run fails. A stage can route outcomes or escalate instead; see [Transitions and outcome keys](workflow-definitions.md#transitions-and-outcome-keys).
|
|
216
|
+
|
|
217
|
+
Returns `{ "run", "retry", "completed", "instruction" }`. The instruction tells you to retry, continue with the next stage, or finish.
|
|
218
|
+
|
|
219
|
+
Key errors: `workflow_evidence_incomplete` (lists `missingRequirements`), `workflow_stage_out_of_order`, `workflow_terminal`, `workflow_provenance_invalid` (a cited message does not match the run, stage, requirement, attempt or eligible producer), `invalid_workflow_evidence_refs`, `weakened_reproduction`, `plan_hash_required`. The [provenance guide](../guides/provenance-gates.md) explains peer evidence.
|
|
220
|
+
|
|
221
|
+
### `kxm_workflow_record`
|
|
222
|
+
|
|
223
|
+
Adds an entry to the run's learning journal.
|
|
224
|
+
|
|
225
|
+
| Parameter | Type | Default or limit | Notes |
|
|
226
|
+
|---|---|---|---|
|
|
227
|
+
| `runId` | String, required | None | The run |
|
|
228
|
+
| `category` | String, required | None | `plan`, `decision`, `contradiction`, `error`, `lesson`, `observation`, `hypothesis`, `experiment`, `state-change` or `skill-candidate` |
|
|
229
|
+
| `area` | String | The stage's area | `harness`, `gates`, `implementation`, `workflow`, `documentation`, `security` or `other`; required unless `stageId` names a stage that declares one |
|
|
230
|
+
| `stageId` | String | None | Binds the entry to that stage; the hub derives the attempt |
|
|
231
|
+
| `severity` | `info`, `warning`, `error` | `info` | |
|
|
232
|
+
| `summary` | String, required | 1,000 characters | |
|
|
233
|
+
| `details` | String | 8,000 characters | |
|
|
234
|
+
| `evidence` | Array of strings | 32 items of 1,000 characters | Required for `lesson` and `skill-candidate` |
|
|
235
|
+
| `relatedEntryIds` | Array of strings | 16 | Entries in the same run |
|
|
236
|
+
|
|
237
|
+
Returns `{ "entry" }`. Errors: `invalid_journal_category`, `invalid_improvement_area`, `journal_evidence_required`, `invalid_journal_relation`, `invalid_journal_severity`. The journal covers hub webhook runs only; a Runtime run ID fails with `workflow_not_found`.
|
|
238
|
+
|
|
239
|
+
### `kxm_workflow_wait`
|
|
240
|
+
|
|
241
|
+
Parks the active stage until a signed external callback reports its result, so long work (CI, review, a merge) does not hold a model turn.
|
|
242
|
+
|
|
243
|
+
| Parameter | Type | Default or limit | Notes |
|
|
244
|
+
|---|---|---|---|
|
|
245
|
+
| `runId` | String, required | None | The run |
|
|
246
|
+
| `stageId` | String, required | None | Must be the current stage |
|
|
247
|
+
| `signalKey` | String, required | 128 characters | Letters, digits, `.`, `_`, `:` and `-`, starting with a letter or digit, for example `github-pr-42-checks` |
|
|
248
|
+
| `summary` | String, required | 4,000 characters | What is running and what result is expected |
|
|
249
|
+
| `evidence` | Object of strings | As for checkpoints | Saved now and merged with the callback's evidence |
|
|
250
|
+
| `evidenceRefs` | Object | As for checkpoints | Peer evidence verified now |
|
|
251
|
+
| `timeoutMs` | Number | 1,000 to 2,592,000,000; default 24 hours | When the wait expires, the run fails |
|
|
252
|
+
|
|
253
|
+
Returns `{ "run", "instruction" }` with the run in `waiting` status. Then reply to settle your turn: a reply while the run waits does not fail it. The callback (for example from `kxm gate github watch` or `kxm gate signal`) checkpoints the stage and, when work remains, sends you a fresh request. Errors: `invalid_signal_key`, `workflow_not_running`, `workflow_stage_out_of_order`, `workflow_wait_invalid`.
|
|
254
|
+
|
|
255
|
+
### `kxm_improvement_report`
|
|
256
|
+
|
|
257
|
+
Summarizes learning across this project's webhook workflow runs. It takes no parameters.
|
|
258
|
+
|
|
259
|
+
Returns `{ "reports", "signals", "entries" }`. Each report covers one improvement area with counts of errors, contradictions and lessons and up to 10 priority entries. `signals` holds up to 20 duplicates merged across runs, security signals first, then scored by frequency × severity × run-attempt cost × evidence confidence, with redacted text. The report proposes; it changes no workflow or policy. See [Continuous improvement](../guides/continuous-improvement.md).
|
|
260
|
+
|
|
261
|
+
## Context tools
|
|
262
|
+
|
|
263
|
+
Context tools read the project's durable context and propose state changes. `project` is optional on every context tool and must equal your own project (`context_isolation_violation` otherwise). See [Context and memory](../guides/context-and-memory.md) for what the packet contains.
|
|
264
|
+
|
|
265
|
+
### `kxm_context`
|
|
266
|
+
|
|
267
|
+
Builds a token-budgeted context packet for a role and task. Call it before planning.
|
|
268
|
+
|
|
269
|
+
| Parameter | Type | Default or limit | Notes |
|
|
270
|
+
|---|---|---|---|
|
|
271
|
+
| `role` | String, required | 64 characters | `repro`, `planner`, `critic`, `implementer`, `verifier`, or a custom role |
|
|
272
|
+
| `task` | String, required | 2,000 characters | What the role is trying to do; drives relevance ranking |
|
|
273
|
+
| `workflowRunId`, `stageId` | String | None | Recorded in the audit and hub log only; they do not filter the packet |
|
|
274
|
+
| `budgetTokens` | Integer | 512 to 200,000 | Defaults: `repro` and `verifier` 8,000, `critic` 12,000, `planner` and `implementer` 16,000, custom roles 32,000 |
|
|
275
|
+
| `includeKinds` | Array | All kinds | Any of `evidence`, `state`, `episode`, `knowledge`, `skill` |
|
|
276
|
+
|
|
277
|
+
Returns `{ "packet", "audit" }`. Superseded and rejected records are excluded. Selection draws on the whole project whether or not you pass `workflowRunId` and `stageId`. The audit echoes your request, including the `task` text, under `audit.request`, then selected IDs, provenance counts, token estimate and relevance numbers. Only the hub's log records sizes instead of the task text.
|
|
278
|
+
|
|
279
|
+
### `kxm_recall`
|
|
280
|
+
|
|
281
|
+
Searches durable context records.
|
|
282
|
+
|
|
283
|
+
| Parameter | Type | Default or limit | Notes |
|
|
284
|
+
|---|---|---|---|
|
|
285
|
+
| `query` | String | 500 characters | An empty query returns every record, ordered by ID |
|
|
286
|
+
| `kinds` | Array of strings | All | Item kinds to include |
|
|
287
|
+
| `limit` | Integer | 1 to 100; default 25 | |
|
|
288
|
+
|
|
289
|
+
Returns `{ "items", "unresolvedGaps" }`. Exact-phrase matches rank first, then token relevance, then ID. Each item is bounded metadata with a numeric `relevance`, never a summary.
|
|
290
|
+
|
|
291
|
+
### `kxm_state`
|
|
292
|
+
|
|
293
|
+
Reads one temporal state key.
|
|
294
|
+
|
|
295
|
+
| Parameter | Type | Notes |
|
|
296
|
+
|---|---|---|
|
|
297
|
+
| `key` | String, required | 200 characters |
|
|
298
|
+
| `asOf` | ISO-8601 timestamp | The value in force at that time |
|
|
299
|
+
|
|
300
|
+
Returns `{ "state", "key" }`, with `state` set to `null` when the key has no value.
|
|
301
|
+
|
|
302
|
+
### `kxm_episode`
|
|
303
|
+
|
|
304
|
+
Reads episodes (`error`, `lesson`, `observation` and `experiment` journal entries) from this project's workflow runs, oldest first, at most 50.
|
|
305
|
+
|
|
306
|
+
| Parameter | Type | Notes |
|
|
307
|
+
|---|---|---|
|
|
308
|
+
| `workflowRunId` | String | Limit to one run |
|
|
309
|
+
|
|
310
|
+
Returns `{ "episodes": [...] }`.
|
|
311
|
+
|
|
312
|
+
### `kxm_promote`
|
|
313
|
+
|
|
314
|
+
Proposes a change to one authoritative state key. Despite its name, it only proposes: nothing changes until an operator promotes the proposal with [`kxm context promote`](cli-reference.md#kxm-context-promote), which needs the admin token and a promoter other than the proposer.
|
|
315
|
+
|
|
316
|
+
| Parameter | Type | Default or limit | Notes |
|
|
317
|
+
|---|---|---|---|
|
|
318
|
+
| `key` | String, required | 200 characters | The state key |
|
|
319
|
+
| `summary` | String, required | 4,000 characters | The proposed value and why |
|
|
320
|
+
| `authority` | `evidence`, `hypothesis`, required | None | An agent's proposal is peer origin, so `evidence` at most |
|
|
321
|
+
| `confidence` | `verified`, `probable`, `uncertain`, required | None | |
|
|
322
|
+
| `evidenceRefs` | Array of strings, required | 1 to 32 | Context item or journal references backing it |
|
|
323
|
+
|
|
324
|
+
Returns `{ "proposalId" }`. Blocked by the `read-only` preset; under an attempt token it needs an explicit grant.
|
|
325
|
+
|
|
326
|
+
## Pi extension commands
|
|
327
|
+
|
|
328
|
+
The Pi extension connects the session to the hub at start, registers the 19 tools, and adds two slash commands. It also keeps a `kxm` status line and `kxm-work` and `kxm-progress` widgets, refreshed after every turn.
|
|
329
|
+
|
|
330
|
+
In Pi:
|
|
331
|
+
|
|
332
|
+
```text
|
|
333
|
+
/kxm
|
|
334
|
+
/kxm status
|
|
335
|
+
/kxm progress
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
| Command | Effect |
|
|
339
|
+
|---|---|
|
|
340
|
+
| `/kxm`, `/kxm brief` | Refreshes the status line and work widget; in the Pi TUI, also opens the task picker described below |
|
|
341
|
+
| `/kxm status` | Recomputes the session brief and shows its status line |
|
|
342
|
+
| `/kxm progress`, `/kxm workflow`, `/workflow` | Shows the active workflow run's stage progress, roles and model metrics from local state, or `kxm: no active workflow run found in state.` |
|
|
343
|
+
| `/kxm hub` | Probes the hub's `/health` at `KXM_SERVER_URL` and shows this agent's name and the online agent count |
|
|
344
|
+
| `/kxm memory` | Shows the project memory brief by running `kxm memory brief` (or `$KXM_BIN`) |
|
|
345
|
+
| `/kxm help` | Lists the subcommands. Any unknown subcommand shows the same help |
|
|
346
|
+
|
|
347
|
+
The task picker, `Continue KXM work?`, lists recent tasks and plans and puts the chosen prompt in the editor. It also appears when a Pi TUI session starts, begins a new session or forks, unless `KXM_SESSION_BRIEF=off`.
|
|
348
|
+
|
|
349
|
+
Inbound requests arrive as a displayed message that starts a model turn: `steer` at the next decision boundary, `followUp` (and `nextTurn`, which an unattended worker cannot wait on) after the current work. The final response is returned as the reply. If the model provider fails, the request stays `delivered` so a supervised worker can recover it. The extension also registers model providers; see [Harness routing](harness-routing.md) and [Nous providers](../guides/nous-providers.md).
|
|
350
|
+
|
|
351
|
+
## Claude Code plugin
|
|
352
|
+
|
|
353
|
+
The plugin's MCP server serves exactly the 19 tools above over stdio. When the project directory has `.kxm/`, a project token resolves and the tool policy allows `kxm_inbox` and `kxm_reply`, it registers with the hub at startup so peers can reach the session before its first tool call; otherwise it registers on the first call. Its instructions tell Claude to call `kxm_context` before planning and to answer peer requests with `kxm_reply`.
|
|
354
|
+
|
|
355
|
+
The plugin also adds:
|
|
356
|
+
|
|
357
|
+
- **A SessionStart hook**, `node ${CLAUDE_PLUGIN_ROOT}/dist/claude-hook.js session-start`, with a 5-second limit. Only in a directory with `.kxm/`, it adds the hub state, up to three active runs, the open request count, where to start, any fix hints, and the project memory brief. It is read-only, needs no `kxm` on `PATH`, and never fails the session.
|
|
358
|
+
- **Pushed channel delivery**, where peer requests arrive as `<channel source="kxm" message_id="…">` events, with pull mode through `kxm_inbox` as the fallback.
|
|
359
|
+
- **Five settings** (`server_url`, `auth_token`, `agent_name`, `agent_purpose`, `project`), described in [Claude Code plugin settings](config-reference.md#claude-code-plugin-settings).
|
|
360
|
+
|
|
361
|
+
The [plugin README](../../plugins/kxm/README.md) covers installation, the hook's exact output, channel mode and troubleshooting.
|
|
362
|
+
|
|
363
|
+
## Related
|
|
364
|
+
|
|
365
|
+
- [Peer messaging](../guides/peer-messaging.md): request patterns, fanout and pull mode
|
|
366
|
+
- [Webhook workflows](../guides/webhook-workflows.md): the coordinator procedure the workflow tools serve
|
|
367
|
+
- [Peer provenance and quorum gates](../guides/provenance-gates.md): `workflowContext` and `evidenceRefs`
|
|
368
|
+
- [Context and memory](../guides/context-and-memory.md): packets, recall, state and promotion
|
|
369
|
+
- [Hub HTTP API](http-api.md): the routes these tools call
|
|
370
|
+
- [Environment variables and limits](configuration.md): credentials, delivery modes and protocol limits
|