@kya-os/cli 1.8.1 → 1.8.3
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/dist/commands/agent.d.ts +35 -0
- package/dist/commands/agent.d.ts.map +1 -0
- package/dist/commands/agent.js +321 -0
- package/dist/commands/agent.js.map +1 -0
- package/dist/commands/build.js +2 -2
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/check.js +3 -3
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/checkpoint-init.d.ts +1 -1
- package/dist/commands/checkpoint-init.d.ts.map +1 -1
- package/dist/commands/checkpoint-init.js +8 -41
- package/dist/commands/checkpoint-init.js.map +1 -1
- package/dist/commands/claim.js +2 -2
- package/dist/commands/claim.js.map +1 -1
- package/dist/commands/dco.d.ts +59 -0
- package/dist/commands/dco.d.ts.map +1 -1
- package/dist/commands/dco.js +280 -5
- package/dist/commands/dco.js.map +1 -1
- package/dist/commands/dev.js +1 -1
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +18 -24
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/env.js +6 -6
- package/dist/commands/env.js.map +1 -1
- package/dist/commands/identity.js +3 -3
- package/dist/commands/identity.js.map +1 -1
- package/dist/commands/init-stages.d.ts +141 -0
- package/dist/commands/init-stages.d.ts.map +1 -0
- package/dist/commands/init-stages.js +684 -0
- package/dist/commands/init-stages.js.map +1 -0
- package/dist/commands/init.d.ts +46 -16
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +229 -279
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/orchestrator.d.ts +18 -0
- package/dist/commands/orchestrator.d.ts.map +1 -0
- package/dist/commands/orchestrator.js +251 -0
- package/dist/commands/orchestrator.js.map +1 -0
- package/dist/commands/register.d.ts +1 -1
- package/dist/commands/register.d.ts.map +1 -1
- package/dist/commands/register.js +35 -7
- package/dist/commands/register.js.map +1 -1
- package/dist/commands/review.d.ts +48 -0
- package/dist/commands/review.d.ts.map +1 -0
- package/dist/commands/review.js +220 -0
- package/dist/commands/review.js.map +1 -0
- package/dist/commands/rotate.js +4 -4
- package/dist/commands/rotate.js.map +1 -1
- package/dist/commands/score.d.ts +15 -0
- package/dist/commands/score.d.ts.map +1 -0
- package/dist/commands/score.js +471 -0
- package/dist/commands/score.js.map +1 -0
- package/dist/commands/start.js +3 -3
- package/dist/commands/start.js.map +1 -1
- package/dist/commands/status.js +1 -1
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/verify.js +6 -6
- package/dist/commands/verify.js.map +1 -1
- package/dist/dco.d.ts +4 -0
- package/dist/dco.d.ts.map +1 -0
- package/dist/dco.js +23 -0
- package/dist/dco.js.map +1 -0
- package/dist/index.js +52 -9
- package/dist/orchestrator/daemon.d.ts +137 -0
- package/dist/orchestrator/daemon.d.ts.map +1 -0
- package/dist/orchestrator/daemon.js +242 -0
- package/dist/orchestrator/daemon.js.map +1 -0
- package/dist/orchestrator/db/dispatches.d.ts +108 -0
- package/dist/orchestrator/db/dispatches.d.ts.map +1 -0
- package/dist/orchestrator/db/dispatches.js +122 -0
- package/dist/orchestrator/db/dispatches.js.map +1 -0
- package/dist/orchestrator/db/index.d.ts +50 -0
- package/dist/orchestrator/db/index.d.ts.map +1 -0
- package/dist/orchestrator/db/index.js +116 -0
- package/dist/orchestrator/db/index.js.map +1 -0
- package/dist/orchestrator/db/journal.d.ts +93 -0
- package/dist/orchestrator/db/journal.d.ts.map +1 -0
- package/dist/orchestrator/db/journal.js +91 -0
- package/dist/orchestrator/db/journal.js.map +1 -0
- package/dist/orchestrator/db/liveness.d.ts +97 -0
- package/dist/orchestrator/db/liveness.d.ts.map +1 -0
- package/dist/orchestrator/db/liveness.js +105 -0
- package/dist/orchestrator/db/liveness.js.map +1 -0
- package/dist/orchestrator/db/mission.d.ts +78 -0
- package/dist/orchestrator/db/mission.d.ts.map +1 -0
- package/dist/orchestrator/db/mission.js +99 -0
- package/dist/orchestrator/db/mission.js.map +1 -0
- package/dist/orchestrator/db/schema.d.ts +14 -0
- package/dist/orchestrator/db/schema.d.ts.map +1 -0
- package/dist/orchestrator/db/schema.js +169 -0
- package/dist/orchestrator/db/schema.js.map +1 -0
- package/dist/orchestrator/db/tickets.d.ts +147 -0
- package/dist/orchestrator/db/tickets.d.ts.map +1 -0
- package/dist/orchestrator/db/tickets.js +238 -0
- package/dist/orchestrator/db/tickets.js.map +1 -0
- package/dist/orchestrator/db/verdicts.d.ts +187 -0
- package/dist/orchestrator/db/verdicts.d.ts.map +1 -0
- package/dist/orchestrator/db/verdicts.js +197 -0
- package/dist/orchestrator/db/verdicts.js.map +1 -0
- package/dist/orchestrator/events.d.ts +69 -0
- package/dist/orchestrator/events.d.ts.map +1 -0
- package/dist/orchestrator/events.js +20 -0
- package/dist/orchestrator/events.js.map +1 -0
- package/dist/orchestrator/github-credential-anchor-sender.d.ts +159 -0
- package/dist/orchestrator/github-credential-anchor-sender.d.ts.map +1 -0
- package/dist/orchestrator/github-credential-anchor-sender.js +313 -0
- package/dist/orchestrator/github-credential-anchor-sender.js.map +1 -0
- package/dist/orchestrator/hub-dispatch.d.ts +120 -0
- package/dist/orchestrator/hub-dispatch.d.ts.map +1 -0
- package/dist/orchestrator/hub-dispatch.js +257 -0
- package/dist/orchestrator/hub-dispatch.js.map +1 -0
- package/dist/orchestrator/hub-observer.d.ts +201 -0
- package/dist/orchestrator/hub-observer.d.ts.map +1 -0
- package/dist/orchestrator/hub-observer.js +474 -0
- package/dist/orchestrator/hub-observer.js.map +1 -0
- package/dist/orchestrator/journal-writer.d.ts +80 -0
- package/dist/orchestrator/journal-writer.d.ts.map +1 -0
- package/dist/orchestrator/journal-writer.js +113 -0
- package/dist/orchestrator/journal-writer.js.map +1 -0
- package/dist/orchestrator/mcp/server.d.ts +136 -0
- package/dist/orchestrator/mcp/server.d.ts.map +1 -0
- package/dist/orchestrator/mcp/server.js +582 -0
- package/dist/orchestrator/mcp/server.js.map +1 -0
- package/dist/orchestrator/mcp/stdio.d.ts +22 -0
- package/dist/orchestrator/mcp/stdio.d.ts.map +1 -0
- package/dist/orchestrator/mcp/stdio.js +51 -0
- package/dist/orchestrator/mcp/stdio.js.map +1 -0
- package/dist/orchestrator/review.d.ts +131 -0
- package/dist/orchestrator/review.d.ts.map +1 -0
- package/dist/orchestrator/review.js +322 -0
- package/dist/orchestrator/review.js.map +1 -0
- package/dist/tui/app.d.ts +33 -0
- package/dist/tui/app.d.ts.map +1 -0
- package/dist/tui/app.js +71 -0
- package/dist/tui/app.js.map +1 -0
- package/dist/tui/components.d.ts +110 -0
- package/dist/tui/components.d.ts.map +1 -0
- package/dist/tui/components.js +118 -0
- package/dist/tui/components.js.map +1 -0
- package/dist/tui/index.d.ts +30 -0
- package/dist/tui/index.d.ts.map +1 -0
- package/dist/tui/index.js +95 -0
- package/dist/tui/index.js.map +1 -0
- package/dist/tui/keymap.d.ts +33 -0
- package/dist/tui/keymap.d.ts.map +1 -0
- package/dist/tui/keymap.js +49 -0
- package/dist/tui/keymap.js.map +1 -0
- package/dist/tui/nav.d.ts +29 -0
- package/dist/tui/nav.d.ts.map +1 -0
- package/dist/tui/nav.js +39 -0
- package/dist/tui/nav.js.map +1 -0
- package/dist/tui/sanitize.d.ts +25 -0
- package/dist/tui/sanitize.d.ts.map +1 -0
- package/dist/tui/sanitize.js +36 -0
- package/dist/tui/sanitize.js.map +1 -0
- package/dist/tui/theme.d.ts +32 -0
- package/dist/tui/theme.d.ts.map +1 -0
- package/dist/tui/theme.js +63 -0
- package/dist/tui/theme.js.map +1 -0
- package/dist/tui/views/agents.d.ts +67 -0
- package/dist/tui/views/agents.d.ts.map +1 -0
- package/dist/tui/views/agents.js +231 -0
- package/dist/tui/views/agents.js.map +1 -0
- package/dist/tui/views/index.d.ts +93 -0
- package/dist/tui/views/index.d.ts.map +1 -0
- package/dist/tui/views/index.js +150 -0
- package/dist/tui/views/index.js.map +1 -0
- package/dist/tui/views/registry.d.ts +22 -0
- package/dist/tui/views/registry.d.ts.map +1 -0
- package/dist/tui/views/registry.js +110 -0
- package/dist/tui/views/registry.js.map +1 -0
- package/dist/utils/agent/backoff.d.ts +31 -0
- package/dist/utils/agent/backoff.d.ts.map +1 -0
- package/dist/utils/agent/backoff.js +51 -0
- package/dist/utils/agent/backoff.js.map +1 -0
- package/dist/utils/agent/markers.d.ts +87 -0
- package/dist/utils/agent/markers.d.ts.map +1 -0
- package/dist/utils/agent/markers.js +147 -0
- package/dist/utils/agent/markers.js.map +1 -0
- package/dist/utils/agent/review.d.ts +67 -0
- package/dist/utils/agent/review.d.ts.map +1 -0
- package/dist/utils/agent/review.js +305 -0
- package/dist/utils/agent/review.js.map +1 -0
- package/dist/utils/agent/spawn-agent.d.ts +117 -0
- package/dist/utils/agent/spawn-agent.d.ts.map +1 -0
- package/dist/utils/agent/spawn-agent.js +177 -0
- package/dist/utils/agent/spawn-agent.js.map +1 -0
- package/dist/utils/agent/task.d.ts +101 -0
- package/dist/utils/agent/task.d.ts.map +1 -0
- package/dist/utils/agent/task.js +357 -0
- package/dist/utils/agent/task.js.map +1 -0
- package/dist/utils/agent/verify.d.ts +47 -0
- package/dist/utils/agent/verify.d.ts.map +1 -0
- package/dist/utils/agent/verify.js +144 -0
- package/dist/utils/agent/verify.js.map +1 -0
- package/dist/utils/agent-detector.d.ts +48 -0
- package/dist/utils/agent-detector.d.ts.map +1 -0
- package/dist/utils/agent-detector.js +74 -0
- package/dist/utils/agent-detector.js.map +1 -0
- package/dist/utils/agent-profile-stage.d.ts +70 -0
- package/dist/utils/agent-profile-stage.d.ts.map +1 -0
- package/dist/utils/agent-profile-stage.js +153 -0
- package/dist/utils/agent-profile-stage.js.map +1 -0
- package/dist/utils/agent-profiles.d.ts +27 -0
- package/dist/utils/agent-profiles.d.ts.map +1 -0
- package/dist/utils/agent-profiles.js +61 -0
- package/dist/utils/agent-profiles.js.map +1 -0
- package/dist/utils/checkpoint-api.d.ts +1 -1
- package/dist/utils/checkpoint-api.js +1 -1
- package/dist/utils/checkpoint-env.d.ts +1 -1
- package/dist/utils/checkpoint-env.js +2 -2
- package/dist/utils/checkpoint-env.js.map +1 -1
- package/dist/utils/checkpoint-scaffold.d.ts +1 -1
- package/dist/utils/checkpoint-scaffold.js +1 -1
- package/dist/utils/cli-kit/browser.d.ts +24 -0
- package/dist/utils/cli-kit/browser.d.ts.map +1 -0
- package/dist/utils/cli-kit/browser.js +58 -0
- package/dist/utils/cli-kit/browser.js.map +1 -0
- package/dist/utils/cli-kit/claim-polling.d.ts +18 -0
- package/dist/utils/cli-kit/claim-polling.d.ts.map +1 -0
- package/dist/utils/{claim-polling.js → cli-kit/claim-polling.js} +19 -26
- package/dist/utils/cli-kit/claim-polling.js.map +1 -0
- package/dist/utils/cli-kit/diagnostics.d.ts +9 -0
- package/dist/utils/cli-kit/diagnostics.d.ts.map +1 -0
- package/dist/utils/cli-kit/diagnostics.js +11 -0
- package/dist/utils/cli-kit/diagnostics.js.map +1 -0
- package/dist/utils/cli-kit/fs-safe.d.ts +14 -0
- package/dist/utils/cli-kit/fs-safe.d.ts.map +1 -0
- package/dist/utils/cli-kit/fs-safe.js +20 -0
- package/dist/utils/cli-kit/fs-safe.js.map +1 -0
- package/dist/utils/cli-kit/index.d.ts +15 -0
- package/dist/utils/cli-kit/index.d.ts.map +1 -0
- package/dist/utils/cli-kit/index.js +10 -0
- package/dist/utils/cli-kit/index.js.map +1 -0
- package/dist/utils/cli-kit/json-file.d.ts +21 -0
- package/dist/utils/cli-kit/json-file.d.ts.map +1 -0
- package/dist/utils/cli-kit/json-file.js +51 -0
- package/dist/utils/cli-kit/json-file.js.map +1 -0
- package/dist/utils/cli-kit/marker-block.d.ts +26 -0
- package/dist/utils/cli-kit/marker-block.d.ts.map +1 -0
- package/dist/utils/cli-kit/marker-block.js +61 -0
- package/dist/utils/cli-kit/marker-block.js.map +1 -0
- package/dist/utils/cli-kit/paths.d.ts +15 -0
- package/dist/utils/cli-kit/paths.d.ts.map +1 -0
- package/dist/utils/cli-kit/paths.js +21 -0
- package/dist/utils/cli-kit/paths.js.map +1 -0
- package/dist/utils/cli-kit/secure-storage.d.ts +14 -0
- package/dist/utils/cli-kit/secure-storage.d.ts.map +1 -0
- package/dist/utils/cli-kit/secure-storage.js +20 -0
- package/dist/utils/cli-kit/secure-storage.js.map +1 -0
- package/dist/utils/cli-kit/step-report.d.ts +16 -0
- package/dist/utils/cli-kit/step-report.d.ts.map +1 -0
- package/dist/utils/cli-kit/step-report.js +36 -0
- package/dist/utils/cli-kit/step-report.js.map +1 -0
- package/dist/utils/dco/agent-metadata.d.ts +1 -1
- package/dist/utils/dco/agent-metadata.js +1 -1
- package/dist/utils/dco/agent-metadata.js.map +1 -1
- package/dist/utils/dco/claude-config.d.ts +18 -14
- package/dist/utils/dco/claude-config.d.ts.map +1 -1
- package/dist/utils/dco/claude-config.js +31 -97
- package/dist/utils/dco/claude-config.js.map +1 -1
- package/dist/utils/dco/dispatch.d.ts +134 -0
- package/dist/utils/dco/dispatch.d.ts.map +1 -0
- package/dist/utils/dco/dispatch.js +399 -0
- package/dist/utils/dco/dispatch.js.map +1 -0
- package/dist/utils/dco/fix.d.ts +122 -0
- package/dist/utils/dco/fix.d.ts.map +1 -0
- package/dist/utils/dco/fix.js +560 -0
- package/dist/utils/dco/fix.js.map +1 -0
- package/dist/utils/dco/git-config.d.ts.map +1 -1
- package/dist/utils/dco/git-config.js +5 -3
- package/dist/utils/dco/git-config.js.map +1 -1
- package/dist/utils/dco/github.d.ts +101 -0
- package/dist/utils/dco/github.d.ts.map +1 -1
- package/dist/utils/dco/github.js +133 -0
- package/dist/utils/dco/github.js.map +1 -1
- package/dist/utils/dco/paths.d.ts +1 -8
- package/dist/utils/dco/paths.d.ts.map +1 -1
- package/dist/utils/dco/paths.js +3 -12
- package/dist/utils/dco/paths.js.map +1 -1
- package/dist/utils/dco/render.d.ts +1 -1
- package/dist/utils/dco/render.d.ts.map +1 -1
- package/dist/utils/dco/render.js +4 -21
- package/dist/utils/dco/render.js.map +1 -1
- package/dist/utils/dco/resolve-agent.d.ts +54 -0
- package/dist/utils/dco/resolve-agent.d.ts.map +1 -0
- package/dist/utils/dco/resolve-agent.js +164 -0
- package/dist/utils/dco/resolve-agent.js.map +1 -0
- package/dist/utils/dco/setup.d.ts +10 -7
- package/dist/utils/dco/setup.d.ts.map +1 -1
- package/dist/utils/dco/setup.js +264 -200
- package/dist/utils/dco/setup.js.map +1 -1
- package/dist/utils/dco/signing-key-writer.d.ts +40 -0
- package/dist/utils/dco/signing-key-writer.d.ts.map +1 -0
- package/dist/utils/dco/signing-key-writer.js +76 -0
- package/dist/utils/dco/signing-key-writer.js.map +1 -0
- package/dist/utils/dco/ssh-key.d.ts +50 -0
- package/dist/utils/dco/ssh-key.d.ts.map +1 -1
- package/dist/utils/dco/ssh-key.js +129 -8
- package/dist/utils/dco/ssh-key.js.map +1 -1
- package/dist/utils/dco/status.d.ts +1 -1
- package/dist/utils/dco/status.d.ts.map +1 -1
- package/dist/utils/dco/status.js +3 -3
- package/dist/utils/dco/status.js.map +1 -1
- package/dist/utils/dco/verify.d.ts +170 -0
- package/dist/utils/dco/verify.d.ts.map +1 -0
- package/dist/utils/dco/verify.js +550 -0
- package/dist/utils/dco/verify.js.map +1 -0
- package/dist/utils/dependency-installer.d.ts +37 -0
- package/dist/utils/dependency-installer.d.ts.map +1 -0
- package/dist/utils/dependency-installer.js +32 -0
- package/dist/utils/dependency-installer.js.map +1 -0
- package/dist/utils/github-credential-stage.d.ts +87 -0
- package/dist/utils/github-credential-stage.d.ts.map +1 -0
- package/dist/utils/github-credential-stage.js +168 -0
- package/dist/utils/github-credential-stage.js.map +1 -0
- package/dist/utils/github-credential.d.ts +160 -0
- package/dist/utils/github-credential.d.ts.map +1 -0
- package/dist/utils/github-credential.js +308 -0
- package/dist/utils/github-credential.js.map +1 -0
- package/dist/utils/gitignore.d.ts +17 -0
- package/dist/utils/gitignore.d.ts.map +1 -0
- package/dist/utils/gitignore.js +40 -0
- package/dist/utils/gitignore.js.map +1 -0
- package/dist/utils/hub-config.d.ts +21 -0
- package/dist/utils/hub-config.d.ts.map +1 -0
- package/dist/utils/hub-config.js +28 -0
- package/dist/utils/hub-config.js.map +1 -0
- package/dist/utils/identity-heal.d.ts +16 -0
- package/dist/utils/identity-heal.d.ts.map +1 -0
- package/dist/utils/identity-heal.js +37 -0
- package/dist/utils/identity-heal.js.map +1 -0
- package/dist/utils/init/pipeline.d.ts +74 -0
- package/dist/utils/init/pipeline.d.ts.map +1 -0
- package/dist/utils/init/pipeline.js +96 -0
- package/dist/utils/init/pipeline.js.map +1 -0
- package/dist/utils/poll.d.ts +15 -1
- package/dist/utils/poll.d.ts.map +1 -1
- package/dist/utils/poll.js +6 -3
- package/dist/utils/poll.js.map +1 -1
- package/dist/utils/register-agent-identity.d.ts +67 -0
- package/dist/utils/register-agent-identity.d.ts.map +1 -0
- package/dist/utils/register-agent-identity.js +34 -0
- package/dist/utils/register-agent-identity.js.map +1 -0
- package/dist/utils/review/did-web-key.d.ts +34 -0
- package/dist/utils/review/did-web-key.d.ts.map +1 -0
- package/dist/utils/review/did-web-key.js +104 -0
- package/dist/utils/review/did-web-key.js.map +1 -0
- package/dist/utils/review/load-registry.d.ts +33 -0
- package/dist/utils/review/load-registry.d.ts.map +1 -0
- package/dist/utils/review/load-registry.js +62 -0
- package/dist/utils/review/load-registry.js.map +1 -0
- package/dist/utils/review/verdict-verify.d.ts +43 -0
- package/dist/utils/review/verdict-verify.d.ts.map +1 -0
- package/dist/utils/review/verdict-verify.js +53 -0
- package/dist/utils/review/verdict-verify.js.map +1 -0
- package/dist/utils/review-registry-writer.d.ts +52 -0
- package/dist/utils/review-registry-writer.d.ts.map +1 -0
- package/dist/utils/review-registry-writer.js +79 -0
- package/dist/utils/review-registry-writer.js.map +1 -0
- package/dist/utils/should-install-dependency.d.ts +17 -0
- package/dist/utils/should-install-dependency.d.ts.map +1 -0
- package/dist/utils/should-install-dependency.js +25 -0
- package/dist/utils/should-install-dependency.js.map +1 -0
- package/dist/utils/tool-readiness.d.ts +57 -0
- package/dist/utils/tool-readiness.d.ts.map +1 -0
- package/dist/utils/tool-readiness.js +114 -0
- package/dist/utils/tool-readiness.js.map +1 -0
- package/dist/utils/which.d.ts +2 -0
- package/dist/utils/which.d.ts.map +1 -0
- package/dist/utils/which.js +22 -0
- package/dist/utils/which.js.map +1 -0
- package/dist/version.d.ts +15 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +29 -0
- package/dist/version.js.map +1 -0
- package/package.json +19 -6
- package/dist/utils/claim-polling.d.ts +0 -21
- package/dist/utils/claim-polling.d.ts.map +0 -1
- package/dist/utils/claim-polling.js.map +0 -1
- package/dist/utils/dco/fs-safe.d.ts +0 -14
- package/dist/utils/dco/fs-safe.d.ts.map +0 -1
- package/dist/utils/dco/fs-safe.js +0 -20
- package/dist/utils/dco/fs-safe.js.map +0 -1
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Journal writer (ORC-W1 PR-2).
|
|
3
|
+
*
|
|
4
|
+
* Turns hub events into ledger rows. This is the piece that makes the journal
|
|
5
|
+
* evidence rather than narration: rows land because a verified protocol event
|
|
6
|
+
* arrived, not because a model chose to record one.
|
|
7
|
+
*
|
|
8
|
+
* @module orchestrator/journal-writer
|
|
9
|
+
*/
|
|
10
|
+
import { appendJournal } from "./db/journal.js";
|
|
11
|
+
import { findTicketIdByTaskId, findTicketIdByPr } from "./db/dispatches.js";
|
|
12
|
+
/**
|
|
13
|
+
* Pull a task id out of an event's untyped `data` bag.
|
|
14
|
+
*
|
|
15
|
+
* `data` is `Record<string, unknown>` on the wire, so this narrows rather than
|
|
16
|
+
* casting. Anything that is not a non-empty string is treated as absent, which
|
|
17
|
+
* is the honest reading: a malformed taskId must not be used to look up a
|
|
18
|
+
* ticket and silently attach an observation to the wrong one.
|
|
19
|
+
*/
|
|
20
|
+
export function taskIdOf(event) {
|
|
21
|
+
const raw = (event.data ?? {})["taskId"];
|
|
22
|
+
return typeof raw === "string" && raw.length > 0 ? raw : null;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Persist one event.
|
|
26
|
+
*
|
|
27
|
+
* Correlates to a ticket through `dispatches` when the event names a task this
|
|
28
|
+
* orchestrator dispatched. When it does not, the row is still written with a
|
|
29
|
+
* null ticket, because an uncorrelated observation is worth more than no
|
|
30
|
+
* observation and guessing at a ticket would be worse than either.
|
|
31
|
+
*
|
|
32
|
+
* Returns true when the row was new (false means it was a replay).
|
|
33
|
+
*/
|
|
34
|
+
export function writeEvent(db, event) {
|
|
35
|
+
return appendJournal(db, { event, ticketId: ticketIdForEvent(db, event) });
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Read a review event's subject out of its untyped `data` bag.
|
|
39
|
+
*
|
|
40
|
+
* All three fields or nothing. A verdict missing part of its subject cannot be
|
|
41
|
+
* attributed, and attributing it to the wrong ticket is worse than leaving the
|
|
42
|
+
* row uncorrelated.
|
|
43
|
+
*/
|
|
44
|
+
export function reviewSubjectOf(event) {
|
|
45
|
+
const data = event.data ?? {};
|
|
46
|
+
const repo = data["repo"];
|
|
47
|
+
const prNumber = data["prNumber"];
|
|
48
|
+
const headSha = data["headSha"];
|
|
49
|
+
if (typeof repo !== "string" || repo.length === 0)
|
|
50
|
+
return null;
|
|
51
|
+
// Number.isInteger rejects NaN, Infinity and floats. A bad PR number would
|
|
52
|
+
// match no dispatch, which reads as "not ours" rather than as bad input.
|
|
53
|
+
if (typeof prNumber !== "number" || !Number.isInteger(prNumber) || prNumber <= 0)
|
|
54
|
+
return null;
|
|
55
|
+
if (typeof headSha !== "string" || headSha.length === 0)
|
|
56
|
+
return null;
|
|
57
|
+
return { repo, prNumber, headSha };
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Resolve the ticket an event concerns: task id first, pull request second.
|
|
61
|
+
*
|
|
62
|
+
* Task id is exact where present. PR correlation is the fallback and the ONLY
|
|
63
|
+
* option for `pr_quorum_reached`, which carries no task id -- so before this
|
|
64
|
+
* existed every quorum event journalled with a null ticket, and the Review lens
|
|
65
|
+
* could show that something reached quorum but never which ticket it was for.
|
|
66
|
+
*/
|
|
67
|
+
export function ticketIdForEvent(db, event) {
|
|
68
|
+
const taskId = taskIdOf(event);
|
|
69
|
+
if (taskId) {
|
|
70
|
+
const byTask = findTicketIdByTaskId(db, taskId);
|
|
71
|
+
if (byTask)
|
|
72
|
+
return byTask;
|
|
73
|
+
}
|
|
74
|
+
const subject = reviewSubjectOf(event);
|
|
75
|
+
return subject ? findTicketIdByPr(db, subject.repo, subject.prNumber) : null;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Subscribe to the hub and journal everything it emits.
|
|
79
|
+
*
|
|
80
|
+
* Returns the unsubscribe, matching the hub's own `onEvent` contract, so the
|
|
81
|
+
* daemon can detach cleanly on shutdown instead of leaking a handler that
|
|
82
|
+
* writes to a closed database.
|
|
83
|
+
*
|
|
84
|
+
* Deliberately does NOT catch a write failure here. Every real dispatcher
|
|
85
|
+
* this attaches to -- the hub's own emit loop, `HubObserver.dispatch()` --
|
|
86
|
+
* already isolates one handler's failure from its siblings and from itself,
|
|
87
|
+
* so catching AGAIN in here just hides the failure from that dispatcher: a
|
|
88
|
+
* reconnect's replay retries a write only if it can tell the write failed,
|
|
89
|
+
* and a handler that always reports success by swallowing its own errors
|
|
90
|
+
* makes that retry permanently dead code (review finding on #686).
|
|
91
|
+
*/
|
|
92
|
+
export function registerJournalWriter(db, hub) {
|
|
93
|
+
return hub.onEvent((event) => {
|
|
94
|
+
writeEvent(db, event);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Replay the hub's recent-event window into the journal.
|
|
99
|
+
*
|
|
100
|
+
* Called once on boot so a daemon restart recovers what it slept through.
|
|
101
|
+
* Idempotent by construction: journal ids are derived from event content, so
|
|
102
|
+
* an event already recorded live is ignored rather than duplicated. Returns
|
|
103
|
+
* how many rows were genuinely new.
|
|
104
|
+
*/
|
|
105
|
+
export function reconcileRecentEvents(db, hub, limit = 50) {
|
|
106
|
+
let added = 0;
|
|
107
|
+
for (const event of hub.getRecentEvents(limit)) {
|
|
108
|
+
if (writeEvent(db, event))
|
|
109
|
+
added += 1;
|
|
110
|
+
}
|
|
111
|
+
return added;
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=journal-writer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"journal-writer.js","sourceRoot":"","sources":["../../src/orchestrator/journal-writer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAG5E;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAmB;IAC1C,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC;IACzC,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;AAChE,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,UAAU,CAAC,EAAU,EAAE,KAAmB;IACxD,OAAO,aAAa,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,gBAAgB,CAAC,EAAE,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;AAC7E,CAAC;AASD;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,KAAmB;IACjD,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC;IAC9B,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;IAC1B,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,CAA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UAAU,qBAAqB,CAAC,EAAU,EAAE,GAAgB,EAAE,KAAK,GAAG,EAAE;IAC5E,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,KAAK,IAAI,GAAG,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/C,IAAI,UAAU,CAAC,EAAE,EAAE,KAAK,CAAC;YAAE,KAAK,IAAI,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ledger MCP server.
|
|
3
|
+
*
|
|
4
|
+
* The orchestrator session's tool surface. This is the boundary that makes
|
|
5
|
+
* approach C work: the daemon owns anything whose correctness a test can
|
|
6
|
+
* check, and the session owns anything whose correctness requires an opinion.
|
|
7
|
+
* Every tool here enforces its invariant in SQL, so a model cannot reason its
|
|
8
|
+
* way past one.
|
|
9
|
+
*
|
|
10
|
+
* Two absences are load-bearing:
|
|
11
|
+
*
|
|
12
|
+
* - There is NO tool that creates a Linear issue, and none by which the
|
|
13
|
+
* SESSION can create a ticket. That is about the session specifically: the
|
|
14
|
+
* ledger does hold agent-native tickets (linear_id NULL), and the daemon
|
|
15
|
+
* writes those deterministically from protocol events. What must not exist
|
|
16
|
+
* is a path by which a model decides, on its own reading of a situation,
|
|
17
|
+
* that some new work exists. A finding it wants to raise goes in the
|
|
18
|
+
* journal, and a human promotes it. Without this absence that policy would
|
|
19
|
+
* be a sentence in a prompt instead of a property of the surface.
|
|
20
|
+
* - There is NO tool that sets the mission note. Reading it is the point;
|
|
21
|
+
* writing it is the operator's. A session that can rewrite its own standing
|
|
22
|
+
* objective is not following one, and would drift toward whatever it last
|
|
23
|
+
* found interesting.
|
|
24
|
+
* - There is NO delete tool, for the same reason the store has no delete
|
|
25
|
+
* path: a bad autonomous close and a clean backlog are indistinguishable
|
|
26
|
+
* once the row is gone.
|
|
27
|
+
*
|
|
28
|
+
* JSON-RPC 2.0 is hand-rolled rather than pulled from the MCP SDK, matching
|
|
29
|
+
* `fleet-mcp.ts` in @kya-os/compute. It keeps a dependency out of a published
|
|
30
|
+
* CLI for what amounts to a switch statement.
|
|
31
|
+
*
|
|
32
|
+
* @module cli/orchestrator/mcp/server
|
|
33
|
+
*/
|
|
34
|
+
import type { Ledger } from "../db/index.js";
|
|
35
|
+
import { SettableTicketStatusSchema, SETTABLE_TICKET_STATUSES, type SettableTicketStatus } from "../db/tickets.js";
|
|
36
|
+
export interface JsonRpcRequest {
|
|
37
|
+
jsonrpc: "2.0";
|
|
38
|
+
id?: string | number | null;
|
|
39
|
+
method: string;
|
|
40
|
+
params?: Record<string, unknown>;
|
|
41
|
+
}
|
|
42
|
+
export interface JsonRpcResponse {
|
|
43
|
+
jsonrpc: "2.0";
|
|
44
|
+
id?: string | number | null;
|
|
45
|
+
result?: unknown;
|
|
46
|
+
error?: {
|
|
47
|
+
code: number;
|
|
48
|
+
message: string;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
interface ToolDefinition {
|
|
52
|
+
name: string;
|
|
53
|
+
description: string;
|
|
54
|
+
inputSchema: Record<string, unknown>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The MCP revision this server speaks.
|
|
58
|
+
*
|
|
59
|
+
* Named rather than inlined in the handshake response, so the version this
|
|
60
|
+
* server actually implements is greppable and changes in one place. Deliberately
|
|
61
|
+
* NOT echoed back from the client's request: the handshake exists for the client
|
|
62
|
+
* to discover what the server supports, and reflecting whatever it asked for
|
|
63
|
+
* would claim support for revisions this code has never been tested against,
|
|
64
|
+
* turning the one honest signal in the exchange into a mirror.
|
|
65
|
+
*/
|
|
66
|
+
export declare const MCP_PROTOCOL_VERSION = "2025-03-26";
|
|
67
|
+
/**
|
|
68
|
+
* Row cap shared by every list tool.
|
|
69
|
+
*
|
|
70
|
+
* journal.list capped and the others did not, which contradicted this file's own
|
|
71
|
+
* reason for capping: a model must not be able to ask for the whole table. The
|
|
72
|
+
* cap is uniform so the reason applies uniformly.
|
|
73
|
+
*/
|
|
74
|
+
export declare const MAX_ROWS = 500;
|
|
75
|
+
/** Serialised size limit for a session-written journal payload. */
|
|
76
|
+
export declare const MAX_EVENT_DATA_BYTES = 8000;
|
|
77
|
+
/** Size limit for a session-written event type. */
|
|
78
|
+
export declare const MAX_EVENT_TYPE_BYTES = 120;
|
|
79
|
+
/**
|
|
80
|
+
* Length limit for a ticket id arriving from the session.
|
|
81
|
+
*
|
|
82
|
+
* Generous next to the ids this ledger mints (a UUID is 36 characters), because
|
|
83
|
+
* its job is to refuse the absurd, not to second-guess the id format.
|
|
84
|
+
*/
|
|
85
|
+
export declare const MAX_TICKET_ID_LENGTH = 200;
|
|
86
|
+
/**
|
|
87
|
+
* Force a session-authored event into its own namespace.
|
|
88
|
+
*
|
|
89
|
+
* Idempotent, so a caller that already prefixes does not end up with
|
|
90
|
+
* `session.session.x`.
|
|
91
|
+
*/
|
|
92
|
+
export declare function sessionEventType(raw: string): string;
|
|
93
|
+
/**
|
|
94
|
+
* The statuses this surface may SET.
|
|
95
|
+
*
|
|
96
|
+
* `claimed` and `closed` each have a dedicated tool that carries something a
|
|
97
|
+
* bare status write cannot: an atomic claim, and a recorded close reason.
|
|
98
|
+
*
|
|
99
|
+
* The definition itself now lives in the store, which is the layer that has to
|
|
100
|
+
* hold the line for callers that never pass through this file. Re-exported here
|
|
101
|
+
* so the advertised JSON Schema, the Zod enforcement and the store's own guard
|
|
102
|
+
* are provably the same list -- they used to be written twice, with Zod holding
|
|
103
|
+
* the real enum while the advertised schema said `{ type: "string" }`, so the
|
|
104
|
+
* model learned the actual constraint only by guessing and reading the error
|
|
105
|
+
* back.
|
|
106
|
+
*/
|
|
107
|
+
export { SettableTicketStatusSchema, SETTABLE_TICKET_STATUSES, type SettableTicketStatus };
|
|
108
|
+
export declare const TICKET_STATUSES: ["open", "claimed", "in-progress", "in-review", "blocked", "ready", "closed"];
|
|
109
|
+
/** Namespace for anything the orchestrator session writes to the journal. */
|
|
110
|
+
export declare const SESSION_EVENT_PREFIX = "session.";
|
|
111
|
+
/**
|
|
112
|
+
* The payload a session-authored journal row actually stores.
|
|
113
|
+
*
|
|
114
|
+
* One definition, shared by the schema that bounds it and the handler that
|
|
115
|
+
* writes it. Two copies of this composition is precisely how the size limit
|
|
116
|
+
* came to guard a value that was not the one being written.
|
|
117
|
+
*/
|
|
118
|
+
export declare function sessionEventPayload(data: Record<string, unknown>, note?: string): Record<string, unknown>;
|
|
119
|
+
export declare const LEDGER_TOOLS: ToolDefinition[];
|
|
120
|
+
/**
|
|
121
|
+
* Run one tool against the ledger.
|
|
122
|
+
*
|
|
123
|
+
* Exported separately from the RPC plumbing so tests exercise the tool
|
|
124
|
+
* semantics without speaking JSON-RPC, and so the invariants are testable in
|
|
125
|
+
* isolation from the transport.
|
|
126
|
+
*/
|
|
127
|
+
export declare function callLedgerTool(db: Ledger, name: string, rawArgs: unknown): unknown;
|
|
128
|
+
/**
|
|
129
|
+
* Handle one JSON-RPC request.
|
|
130
|
+
*
|
|
131
|
+
* Errors become JSON-RPC errors rather than thrown exceptions, because a
|
|
132
|
+
* thrown error here kills the stdio loop and takes every subsequent tool call
|
|
133
|
+
* with it. A tool that fails should fail one call.
|
|
134
|
+
*/
|
|
135
|
+
export declare function handleLedgerRpc(db: Ledger, req: JsonRpcRequest): JsonRpcResponse | null;
|
|
136
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/orchestrator/mcp/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAOL,0BAA0B,EAC1B,wBAAwB,EACxB,KAAK,oBAAoB,EAG1B,MAAM,kBAAkB,CAAC;AAM1B,MAAM,WAAW,cAAc;IAC7B,OAA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