@humwick/server 0.0.0-stage → 0.130.0
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/CLA.md +66 -0
- package/CONTRIBUTING.md +144 -0
- package/LICENSE +167 -0
- package/README.md +511 -2
- package/SECURITY.md +67 -0
- package/THIRD_PARTY_NOTICES.md +144 -0
- package/bundled/prompts/README.md +10 -0
- package/bundled/prompts/context.advisory.compact.md +1 -0
- package/bundled/prompts/context.advisory.warn.md +1 -0
- package/bundled/prompts/continuation.envelope.md +18 -0
- package/bundled/prompts/manifest.json +838 -0
- package/bundled/prompts/memory.capture.boundary.post.md +1 -0
- package/bundled/prompts/memory.capture.boundary.pre.md +1 -0
- package/bundled/prompts/memory.charter.md +3 -0
- package/bundled/prompts/memory.native-off.md +0 -0
- package/bundled/prompts/notify.agent.exited.md +1 -0
- package/bundled/prompts/notify.agent.never-ready.md +1 -0
- package/bundled/prompts/notify.agent.ready.md +1 -0
- package/bundled/prompts/notify.automation.budget-warning.md +1 -0
- package/bundled/prompts/notify.land.failure.md +1 -0
- package/bundled/prompts/notify.land.steward-taken.coordinator.md +1 -0
- package/bundled/prompts/notify.land.steward-taken.md +1 -0
- package/bundled/prompts/notify.land.success.md +1 -0
- package/bundled/prompts/notify.routing.policy-changed.md +2 -0
- package/bundled/prompts/notify.spawn.failed.md +1 -0
- package/bundled/prompts/notify.spawn.queued.md +1 -0
- package/bundled/prompts/notify.spawn.recovered.md +1 -0
- package/bundled/prompts/notify.spawn.unconfirmed.md +1 -0
- package/bundled/prompts/profile.coordinator.charter.md +17 -0
- package/bundled/prompts/profile.debugger.system.md +12 -0
- package/bundled/prompts/profile.device-qa.system.md +10 -0
- package/bundled/prompts/profile.image-gen.append.0.md +2 -0
- package/bundled/prompts/profile.image-gen.system.md +4 -0
- package/bundled/prompts/profile.ops-assistant.brief.md +4 -0
- package/bundled/prompts/profile.probe.system.md +5 -0
- package/bundled/prompts/profile.qa.system.md +10 -0
- package/bundled/prompts/profile.sec-ops.system.md +14 -0
- package/bundled/prompts/profile.social-media.system.md +7 -0
- package/bundled/prompts/profile.software-design.system.md +26 -0
- package/bundled/prompts/profile.sub-coordinator.charter.md +2 -0
- package/bundled/prompts/profile.worker-gui.system.md +7 -0
- package/bundled/prompts/profile.worker.system.md +2 -0
- package/bundled/prompts/relay.agent-core.delivery.md +13 -0
- package/bundled/prompts/relay.agent-core.engineering.md +13 -0
- package/bundled/prompts/relay.agent-core.md +22 -0
- package/bundled/prompts/relay.context.claude.md +1 -0
- package/bundled/prompts/relay.context.claude.readonly.md +3 -0
- package/bundled/prompts/relay.context.codex.md +1 -0
- package/bundled/prompts/relay.context.opencode.md +1 -0
- package/bundled/prompts/relay.manual.claude.md +8 -0
- package/bundled/prompts/relay.search.fff.md +1 -0
- package/bundled/prompts/relay.temp-dir.md +1 -0
- package/bundled/prompts/relay.web.brave.md +1 -0
- package/bundled/prompts/relay.web.fetch.md +1 -0
- package/bundled/prompts/skill.device-lane.md +20 -0
- package/bundled/prompts/skill.security-code-review.md +10 -0
- package/bundled/prompts/skill.security-hardening.md +10 -0
- package/bundled/prompts/skill.security-host-audit.md +11 -0
- package/bundled/prompts/spawn.primer.md +6 -0
- package/bundled/prompts/spawn.reportup.child.md +3 -0
- package/bundled/prompts/spawn.reportup.coordinator.md +2 -0
- package/bundled/prompts/spawn.reportup.workflow-step.md +4 -0
- package/bundled/prompts/spawn.validation.delivery.md +1 -0
- package/bundled/prompts/spawn.validation.iterate.generic.md +1 -0
- package/bundled/prompts/spawn.validation.iterate.imperative.md +1 -0
- package/bundled/prompts/spawn.validation.landgates.header.md +1 -0
- package/bundled/prompts/steward.merge-stall.md +1 -0
- package/bundled/prompts/steward.prompt.md +20 -0
- package/bundled/prompts/steward.wake.md +1 -0
- package/bundled/prompts/task.claim.instruction.md +1 -0
- package/bundled/prompts/task.hydration.md +23 -0
- package/bundled/prompts/user.response.brief.md +1 -0
- package/bundled/prompts/user.response.normal.md +1 -0
- package/bundled/prompts/user.style.neutral.md +1 -0
- package/bundled/prompts/user.style.warm.md +1 -0
- package/bundled/prompts/workspace.deps.command.md +1 -0
- package/bundled/prompts/workspace.deps.none.md +1 -0
- package/bundled/prompts/workspace.deps.symlink.md +1 -0
- package/bundled/prompts/workspace.lifecycle.md +4 -0
- package/bundled/prompts/workspace.mcp.instructions.md +7 -0
- package/bundled/prompts/workspace.phase.abandoned.headline.md +1 -0
- package/bundled/prompts/workspace.phase.abandoned.hint.md +1 -0
- package/bundled/prompts/workspace.phase.active.headline.md +1 -0
- package/bundled/prompts/workspace.phase.active.hint.md +1 -0
- package/bundled/prompts/workspace.phase.conflict.headline.md +1 -0
- package/bundled/prompts/workspace.phase.conflict.hint.md +1 -0
- package/bundled/prompts/workspace.phase.merge-planned.headline.md +1 -0
- package/bundled/prompts/workspace.phase.merge-planned.hint.md +1 -0
- package/bundled/prompts/workspace.phase.merged.headline.md +1 -0
- package/bundled/prompts/workspace.phase.merged.hint.md +1 -0
- package/bundled/prompts/workspace.phase.ready.headline.md +1 -0
- package/bundled/prompts/workspace.phase.ready.hint.md +1 -0
- package/bundled/prompts/workspace.ready.contract.md +6 -0
- package/bundled/prompts/workspace.symlinks.md +1 -0
- package/bundled/roles/builder.md +18 -0
- package/bundled/roles/design-reviewer.md +13 -0
- package/bundled/roles/designer.md +11 -0
- package/bundled/roles/plan-auditor.md +29 -0
- package/bundled/roles/reviewer.md +36 -0
- package/bundled/roles/slice-qa.md +13 -0
- package/bundled/roles/verifier.md +13 -0
- package/bundled/skills/agent-browser/SKILL.md +72 -0
- package/bundled/skills/test-audit/SKILL.md +75 -0
- package/bundled/workflows/build-review.yaml +8 -0
- package/bundled/workflows/design-review.yaml +60 -0
- package/bundled/workflows/plan-conformance.yaml +5 -0
- package/bundled/workflows/slice-proof.yaml +85 -0
- package/bundled/workflows/verify-deployed.yaml +140 -0
- package/docs/guides/sub-coordinators.md +114 -0
- package/docs/guides/tools-administration.md +83 -0
- package/docs/guides/tools-agents.md +137 -0
- package/docs/guides/tools-coordination.md +228 -0
- package/docs/guides/tools-execution.md +48 -0
- package/docs/guides/tools-issues.md +69 -0
- package/docs/guides/tools-memory.md +150 -0
- package/docs/guides/tools-messages.md +192 -0
- package/docs/guides/tools-operations.md +133 -0
- package/docs/guides/tools-tasks.md +235 -0
- package/docs/guides/workflows.md +324 -0
- package/docs/license-faq.md +37 -0
- package/docs/openapi.json +18531 -0
- package/examples/integrations/github-issue.ts +48 -0
- package/examples/integrations/ops-alert.sh +27 -0
- package/examples/integrations/prometheus-alertmanager.ts +55 -0
- package/examples/integrations/support-ticket.sh +28 -0
- package/node_modules/@humwick/kernel/LICENSE +167 -0
- package/node_modules/@humwick/kernel/async-entity-persistence.ts +344 -0
- package/node_modules/@humwick/kernel/async-event-log.ts +107 -0
- package/node_modules/@humwick/kernel/automations.pilot.ts +147 -0
- package/node_modules/@humwick/kernel/config.ts +111 -0
- package/node_modules/@humwick/kernel/contract.ts +572 -0
- package/node_modules/@humwick/kernel/control-authz.ts +281 -0
- package/node_modules/@humwick/kernel/control.ts +645 -0
- package/node_modules/@humwick/kernel/effects.ts +493 -0
- package/node_modules/@humwick/kernel/event-log.ts +319 -0
- package/node_modules/@humwick/kernel/http-transport.ts +384 -0
- package/node_modules/@humwick/kernel/identity-grammar.ts +20 -0
- package/node_modules/@humwick/kernel/identity.ts +248 -0
- package/node_modules/@humwick/kernel/index.ts +28 -0
- package/node_modules/@humwick/kernel/kernel-persistence.ts +181 -0
- package/node_modules/@humwick/kernel/landing-incident.ts +306 -0
- package/node_modules/@humwick/kernel/landing.ts +953 -0
- package/node_modules/@humwick/kernel/manifest-validation.ts +460 -0
- package/node_modules/@humwick/kernel/mcp-transport.ts +109 -0
- package/node_modules/@humwick/kernel/message-authority-chaos-worker.ts +200 -0
- package/node_modules/@humwick/kernel/message-authority.ts +281 -0
- package/node_modules/@humwick/kernel/module-host.ts +722 -0
- package/node_modules/@humwick/kernel/openapi-init.ts +14 -0
- package/node_modules/@humwick/kernel/package.json +47 -0
- package/node_modules/@humwick/kernel/persistence-schema.ts +248 -0
- package/node_modules/@humwick/kernel/persistence.ts +510 -0
- package/node_modules/@humwick/kernel/registry.ts +60 -0
- package/node_modules/@humwick/kernel/sqlite-kernel-persistence.ts +499 -0
- package/node_modules/@humwick/kernel/sqlite-module-host.ts +87 -0
- package/node_modules/@humwick/kernel/timers-chaos-worker.ts +186 -0
- package/node_modules/@humwick/kernel/timers.pilot.ts +1411 -0
- package/node_modules/@humwick/kernel/workflow-activation.ts +25 -0
- package/node_modules/@humwick/kernel/workflow-backstop.ts +40 -0
- package/node_modules/@humwick/kernel/workflow-cancel-tree.ts +20 -0
- package/node_modules/@humwick/kernel/workflow-chaos-worker.ts +213 -0
- package/node_modules/@humwick/kernel/workflow-composition.ts +231 -0
- package/node_modules/@humwick/kernel/workflow-container.ts +72 -0
- package/node_modules/@humwick/kernel/workflow-control.test-fixture.ts +42 -0
- package/node_modules/@humwick/kernel/workflow-control.ts +178 -0
- package/node_modules/@humwick/kernel/workflow-definition.ts +507 -0
- package/node_modules/@humwick/kernel/workflow-dispatch.ts +60 -0
- package/node_modules/@humwick/kernel/workflow-foreach.ts +167 -0
- package/node_modules/@humwick/kernel/workflow-journal-codec.ts +339 -0
- package/node_modules/@humwick/kernel/workflow-journal.ts +922 -0
- package/node_modules/@humwick/kernel/workflow-lane.ts +48 -0
- package/node_modules/@humwick/kernel/workflow-lease-owner.ts +60 -0
- package/node_modules/@humwick/kernel/workflow-recovery.test-fixture.ts +19 -0
- package/node_modules/@humwick/kernel/workflow-runtime.ts +938 -0
- package/node_modules/@humwick/kernel/workflow-script.ts +11 -0
- package/node_modules/@humwick/kernel/workflow-state.ts +299 -0
- package/node_modules/@humwick/kernel/workflow-step-commit.ts +195 -0
- package/node_modules/@humwick/kernel/workflow-transitions.ts +317 -0
- package/node_modules/@humwick/kernel/workflow-values.ts +153 -0
- package/node_modules/@humwick/kernel/workflow.pilot.ts +376 -0
- package/node_modules/@humwick/offload/LICENSE +167 -0
- package/node_modules/@humwick/offload/README.md +57 -0
- package/node_modules/@humwick/offload/dist/async-runner.d.ts +18 -0
- package/node_modules/@humwick/offload/dist/async-runner.d.ts.map +1 -0
- package/node_modules/@humwick/offload/dist/async-runner.js +158 -0
- package/node_modules/@humwick/offload/dist/async-runner.js.map +1 -0
- package/node_modules/@humwick/offload/dist/envelope.d.ts +25 -0
- package/node_modules/@humwick/offload/dist/envelope.d.ts.map +1 -0
- package/node_modules/@humwick/offload/dist/envelope.js +80 -0
- package/node_modules/@humwick/offload/dist/envelope.js.map +1 -0
- package/node_modules/@humwick/offload/dist/fixtures/worker-task.d.ts +10 -0
- package/node_modules/@humwick/offload/dist/fixtures/worker-task.d.ts.map +1 -0
- package/node_modules/@humwick/offload/dist/fixtures/worker-task.js +59 -0
- package/node_modules/@humwick/offload/dist/fixtures/worker-task.js.map +1 -0
- package/node_modules/@humwick/offload/dist/index.d.ts +5 -0
- package/node_modules/@humwick/offload/dist/index.d.ts.map +1 -0
- package/node_modules/@humwick/offload/dist/index.js +5 -0
- package/node_modules/@humwick/offload/dist/index.js.map +1 -0
- package/node_modules/@humwick/offload/dist/subprocess-runner.d.ts +62 -0
- package/node_modules/@humwick/offload/dist/subprocess-runner.d.ts.map +1 -0
- package/node_modules/@humwick/offload/dist/subprocess-runner.js +295 -0
- package/node_modules/@humwick/offload/dist/subprocess-runner.js.map +1 -0
- package/node_modules/@humwick/offload/dist/types.d.ts +111 -0
- package/node_modules/@humwick/offload/dist/types.d.ts.map +1 -0
- package/node_modules/@humwick/offload/dist/types.js +176 -0
- package/node_modules/@humwick/offload/dist/types.js.map +1 -0
- package/node_modules/@humwick/offload/dist/worker-pool.d.ts +23 -0
- package/node_modules/@humwick/offload/dist/worker-pool.d.ts.map +1 -0
- package/node_modules/@humwick/offload/dist/worker-pool.js +435 -0
- package/node_modules/@humwick/offload/dist/worker-pool.js.map +1 -0
- package/node_modules/@humwick/offload/dist/worker-runtime.d.ts +2 -0
- package/node_modules/@humwick/offload/dist/worker-runtime.d.ts.map +1 -0
- package/node_modules/@humwick/offload/dist/worker-runtime.js +27 -0
- package/node_modules/@humwick/offload/dist/worker-runtime.js.map +1 -0
- package/node_modules/@humwick/offload/dist/worker.d.ts +5 -0
- package/node_modules/@humwick/offload/dist/worker.d.ts.map +1 -0
- package/node_modules/@humwick/offload/dist/worker.js +1 -0
- package/node_modules/@humwick/offload/dist/worker.js.map +1 -0
- package/node_modules/@humwick/offload/package.json +46 -0
- package/node_modules/@humwick/offload/src/async-runner.ts +170 -0
- package/node_modules/@humwick/offload/src/envelope.ts +92 -0
- package/node_modules/@humwick/offload/src/fixtures/worker-task.ts +49 -0
- package/node_modules/@humwick/offload/src/index.ts +4 -0
- package/node_modules/@humwick/offload/src/subprocess-runner.ts +334 -0
- package/node_modules/@humwick/offload/src/types.ts +235 -0
- package/node_modules/@humwick/offload/src/worker-pool.ts +463 -0
- package/node_modules/@humwick/offload/src/worker-runtime.ts +32 -0
- package/node_modules/@humwick/offload/src/worker.ts +5 -0
- package/package.json +229 -4
- package/public/assets/MessageBubble-BWpoBjl4.js +4 -0
- package/public/assets/PlanGraphPanel-C0auck3n.js +2 -0
- package/public/assets/TraceView-DBnOx7AQ.js +5 -0
- package/public/assets/VaultDecisionCard-0kp2oNBC.js +2 -0
- package/public/assets/activity-TMzFOdh2.js +2 -0
- package/public/assets/activity-yLztXEBt.js +2 -0
- package/public/assets/agent-lineage-BbJDR1dW.js +2 -0
- package/public/assets/agent-liveness-DyqxfB-t.js +2 -0
- package/public/assets/agent-name-CTZBrSD9.js +2 -0
- package/public/assets/agent-profiles-BpI_jTxq.js +2 -0
- package/public/assets/agent-project-badge-9TqzUUYE.js +2 -0
- package/public/assets/agent-tools-D4n40pn8.js +2 -0
- package/public/assets/agent-type-icon-D6FUarOf.js +2 -0
- package/public/assets/agents-BYDslkJc.js +2 -0
- package/public/assets/analytics-B-XSbEMC.js +910 -0
- package/public/assets/andromeeda-vGVdxbeo.js +2 -0
- package/public/assets/angular-html-BVBpGdXr.js +2 -0
- package/public/assets/angular-ts-BfdufMKP.js +2 -0
- package/public/assets/api-CIIVBtAV.js +10 -0
- package/public/assets/archive-CIuPSvmx.js +2 -0
- package/public/assets/arrow-right-vFsRqG8V.js +2 -0
- package/public/assets/arrow-up-a-z-CKC2RCjD.js +2 -0
- package/public/assets/artifact-viewer-DdWIfV6M.js +2 -0
- package/public/assets/artifacts-DPN1q4pA.js +2 -0
- package/public/assets/artifacts-oBOqks-2.js +2 -0
- package/public/assets/astro-JKRPP03v.js +2 -0
- package/public/assets/aurora-x-CDeNXAV0.js +2 -0
- package/public/assets/automation-4KcRFXEu.js +2 -0
- package/public/assets/ayu-dark-DluEY0Gj.js +2 -0
- package/public/assets/ayu-light-C3h-C4tm.js +2 -0
- package/public/assets/ayu-mirage-Bqwy1Gya.js +2 -0
- package/public/assets/backlog-Cw9xPTCF.js +2 -0
- package/public/assets/badge-DqJRtj_p.js +2 -0
- package/public/assets/bell-_Yzbxxrt.js +2 -0
- package/public/assets/blade-DA8yMPsw.js +2 -0
- package/public/assets/bot-B0NpDNhr.js +2 -0
- package/public/assets/boxes-Cv7Wq3h4.js +2 -0
- package/public/assets/braces-BOks9SsY.js +2 -0
- package/public/assets/brain-CagXMEKE.js +2 -0
- package/public/assets/brain-circuit-CpQeSmp3.js +2 -0
- package/public/assets/bundle-web-ifbJd0t-.js +14 -0
- package/public/assets/busy-health-CTu32MZt.js +2 -0
- package/public/assets/button-Do6Z3vvn.js +2 -0
- package/public/assets/c-Wt1voDr2.js +2 -0
- package/public/assets/calendar-QJjoZ1JU.js +2 -0
- package/public/assets/calendar-clock-CDG_KBhx.js +2 -0
- package/public/assets/card-C4QJ4hCW.js +2 -0
- package/public/assets/catppuccin-frappe-3VR1Za6u.js +2 -0
- package/public/assets/catppuccin-latte-DwIHMF0Q.js +2 -0
- package/public/assets/catppuccin-macchiato-DYnBP6_5.js +2 -0
- package/public/assets/catppuccin-mocha-DYhrFGRu.js +2 -0
- package/public/assets/channels-BiXzg1G9.js +2 -0
- package/public/assets/chart-column-S02ZGfTR.js +2 -0
- package/public/assets/chat-Ctk2qwvA.js +6 -0
- package/public/assets/check-B3M9Ug1P.js +2 -0
- package/public/assets/chevron-down-BoG3JCZn.js +2 -0
- package/public/assets/chevron-right-iljytE0x.js +2 -0
- package/public/assets/chevron-up-Bv3yC5ma.js +2 -0
- package/public/assets/circle-UESLMi2-.js +2 -0
- package/public/assets/circle-alert-CryagaZd.js +2 -0
- package/public/assets/circle-arrow-up-B432r0Kk.js +2 -0
- package/public/assets/circle-check-CkUkN96J.js +2 -0
- package/public/assets/circle-x-CZ0erS7Q.js +2 -0
- package/public/assets/clipboard-list-W2YeUsxT.js +2 -0
- package/public/assets/clock-3-BH47318N.js +2 -0
- package/public/assets/clock-BWPPBh1_.js +2 -0
- package/public/assets/code-preview-Bm1wWqAp.js +3 -0
- package/public/assets/coffee-CThvmt4R.js +2 -0
- package/public/assets/connectors-C36ax4Vw.js +2 -0
- package/public/assets/copy-DFxhHRtV.js +2 -0
- package/public/assets/copy-button-CjOj4HEf.js +2 -0
- package/public/assets/cosmos-Dn8XrlnS.css +1 -0
- package/public/assets/cosmos-Jj9LK2Wf.js +3993 -0
- package/public/assets/cpp-C5WNSHb9.js +2 -0
- package/public/assets/cpu-Dndy84IU.js +2 -0
- package/public/assets/crate-agent-H6S7-B9T.js +2 -0
- package/public/assets/css-DJp_X0uY.js +2 -0
- package/public/assets/csv-Dx-8-gkx.js +2 -0
- package/public/assets/dark-plus-Cs2F2srj.js +2 -0
- package/public/assets/dependency-graph-Cd1E23wa.js +2 -0
- package/public/assets/deploys-Bwfq146q.js +2 -0
- package/public/assets/dialog-uuJ9_geR.js +6 -0
- package/public/assets/display-CfO7rTuF.js +3 -0
- package/public/assets/dist-B2h2GeWt.js +2 -0
- package/public/assets/dist-BeVYU67E.js +2 -0
- package/public/assets/dist-Bmm-RKub.js +2 -0
- package/public/assets/dist-C1xmD7qJ.js +2 -0
- package/public/assets/dist-C2J943E6.js +2 -0
- package/public/assets/dist-C6lpJDoA.js +2 -0
- package/public/assets/dist-CoWL6B0c.js +2 -0
- package/public/assets/dist-D93SmTNC.js +2 -0
- package/public/assets/dist-Da7HrHNA.js +2 -0
- package/public/assets/dist-DeW2Y1R5.js +2 -0
- package/public/assets/dist-DwBdqQ6H.js +2 -0
- package/public/assets/dist-Dz182zaW.js +2 -0
- package/public/assets/dist-H3DLHJ0C.js +2 -0
- package/public/assets/dist-RrY9C4SI.js +2 -0
- package/public/assets/download-KgtpDbt5.js +2 -0
- package/public/assets/dracula-BHWKrbxM.js +2 -0
- package/public/assets/dracula-soft-5eyTD99u.js +2 -0
- package/public/assets/dropdown-menu-BXiNephE.js +2 -0
- package/public/assets/es2015-DMmZ8vbD.js +42 -0
- package/public/assets/esm-ZSuD7QuY.js +2 -0
- package/public/assets/everforest-dark-sB-x3p7T.js +2 -0
- package/public/assets/everforest-light-Df2xbC6M.js +2 -0
- package/public/assets/external-link-BRfu-fHG.js +2 -0
- package/public/assets/eye-BAP6fHrX.js +2 -0
- package/public/assets/file-code-corner-CXhIR1vB.js +2 -0
- package/public/assets/file-pen-Crunre5f.js +2 -0
- package/public/assets/file-text-CKuoMR2U.js +2 -0
- package/public/assets/files-DhhZI2Ih.js +3 -0
- package/public/assets/flag-CnEG9PH-.js +2 -0
- package/public/assets/flame-CxBuz46L.js +2 -0
- package/public/assets/fleet-BL4UXS_k.js +2 -0
- package/public/assets/fleet-metrics-BkHP-P3R.js +2 -0
- package/public/assets/folder-git-2-CJOmTT06.js +2 -0
- package/public/assets/folder-open-CBUCMSlu.js +2 -0
- package/public/assets/folder-tree-BG3Y9nqH.js +2 -0
- package/public/assets/formatted-body-Cm1RrzmN.js +3 -0
- package/public/assets/formatted-body-impl-DQiOuOD1.js +3 -0
- package/public/assets/gauge-BIODY-BQ.js +2 -0
- package/public/assets/geist-cyrillic-wght-normal-CHSlOQsW.woff2 +0 -0
- package/public/assets/geist-latin-ext-wght-normal-DMtmJ5ZE.woff2 +0 -0
- package/public/assets/geist-latin-wght-normal-Dm3htQBi.woff2 +0 -0
- package/public/assets/git-branch-yxhV0m8E.js +2 -0
- package/public/assets/git-commit-horizontal-DS1pJ_SS.js +2 -0
- package/public/assets/git-merge-C7eIG425.js +2 -0
- package/public/assets/github-dark-C-LZuMrd.js +2 -0
- package/public/assets/github-dark-default-DXG-b-1a.js +2 -0
- package/public/assets/github-dark-dimmed-Bx1FflLF.js +2 -0
- package/public/assets/github-dark-high-contrast-B_tTalzw.js +2 -0
- package/public/assets/github-light-EUqPIrTm.js +2 -0
- package/public/assets/github-light-default-BXViO-2h.js +2 -0
- package/public/assets/github-light-high-contrast-B68TUdTA.js +2 -0
- package/public/assets/globe-Cl5fXtqs.js +2 -0
- package/public/assets/glsl-Dv5r7kPw.js +2 -0
- package/public/assets/graphql-CcFwQwm0.js +2 -0
- package/public/assets/gruvbox-dark-hard-C820rvS2.js +2 -0
- package/public/assets/gruvbox-dark-medium-BPjhmG05.js +2 -0
- package/public/assets/gruvbox-dark-soft-MrdJrrXF.js +2 -0
- package/public/assets/gruvbox-light-hard-BC_s9l72.js +2 -0
- package/public/assets/gruvbox-light-medium-BAWPOn9u.js +2 -0
- package/public/assets/gruvbox-light-soft-BSMLrYjP.js +2 -0
- package/public/assets/haml-Bg4I2hiD.js +2 -0
- package/public/assets/handlebars-DnwbnL5R.js +2 -0
- package/public/assets/hash-CbtKih3g.js +2 -0
- package/public/assets/horizon-CE9ld1lL.js +2 -0
- package/public/assets/horizon-bright-DSNQnXHK.js +2 -0
- package/public/assets/host-mTgRw7xh.js +2 -0
- package/public/assets/host-providers-dialog-CHqwXTov.js +2 -0
- package/public/assets/hourglass-txu4ax6n.js +2 -0
- package/public/assets/houston-CsvMBhTu.js +2 -0
- package/public/assets/html-C8UlPnhE.js +2 -0
- package/public/assets/html-derivative-CY6NRz-J.js +2 -0
- package/public/assets/http-CoW620Fi.js +2 -0
- package/public/assets/humwick-lockup-on-dark-Ds44Y7BK.svg +19 -0
- package/public/assets/humwick-lockup-on-light-ClALZAHt.svg +19 -0
- package/public/assets/hurl-CSSETujw.js +2 -0
- package/public/assets/imba-DsUTQ-LC.js +2 -0
- package/public/assets/inbox-Dfwk3Gt8.js +2 -0
- package/public/assets/index-B7ZerHLY.css +2 -0
- package/public/assets/index-BK0WV6hF.js +15 -0
- package/public/assets/input-CsTB6jIx.js +2 -0
- package/public/assets/insights-fH1EL-qZ.js +2 -0
- package/public/assets/integrations-C5Oix6ng.js +2 -0
- package/public/assets/issue-ref-chip-ODyondIa.js +3 -0
- package/public/assets/java-CGc3VwQr.js +2 -0
- package/public/assets/javascript-CUt1pgmJ.js +2 -0
- package/public/assets/jinja-CD-Z-FLd.js +2 -0
- package/public/assets/jison-imPNup1l.js +2 -0
- package/public/assets/json-qhed-kSA.js +2 -0
- package/public/assets/json5-BR5RXkoi.js +2 -0
- package/public/assets/jsonc-CYpm1nAK.js +2 -0
- package/public/assets/jsonl-CmCQp5Yx.js +2 -0
- package/public/assets/jsx-CY6oMTks.js +2 -0
- package/public/assets/julia-CjffhBEM.js +2 -0
- package/public/assets/kanagawa-dragon-CXtmUGW6.js +2 -0
- package/public/assets/kanagawa-lotus-BN08jTvb.js +2 -0
- package/public/assets/kanagawa-wave-CTweb8Dz.js +2 -0
- package/public/assets/kernel-Bqr0CZGv.js +2 -0
- package/public/assets/key-round-CcSxl5qr.js +2 -0
- package/public/assets/keyboard-DcmEulph.js +2 -0
- package/public/assets/label-BPBzm9FJ.js +2 -0
- package/public/assets/laserwave-C_8bwKvT.js +2 -0
- package/public/assets/layers-DEfClY-v.js +2 -0
- package/public/assets/legacy-storage-carry-C-tBSxRA.js +2 -0
- package/public/assets/less-DVTAwKKz.js +2 -0
- package/public/assets/lib-D7DTGM1F.js +2 -0
- package/public/assets/lib-G-25QXXf.js +30 -0
- package/public/assets/light-plus-DVQuIRkW.js +2 -0
- package/public/assets/lightbulb-RDhZ4p-D.js +2 -0
- package/public/assets/link-2-off-DfRF9Hwb.js +2 -0
- package/public/assets/link-6RR7Hy3-.js +2 -0
- package/public/assets/list-checks-CwnS3hly.js +2 -0
- package/public/assets/list-ordered-D8nCM7rT.js +2 -0
- package/public/assets/list-todo-9qT0fgxZ.js +2 -0
- package/public/assets/loader-circle-BfPd4kOD.js +2 -0
- package/public/assets/lock-BW8MPKw_.js +2 -0
- package/public/assets/log-viewer-Cvfy6PW7.js +4 -0
- package/public/assets/mail-DyaDmwfY.js +2 -0
- package/public/assets/maintenance-D8CDH5wZ.js +2 -0
- package/public/assets/managed-agents-egllbpij.js +4 -0
- package/public/assets/markdown-BYOwaDjH.js +2 -0
- package/public/assets/markdown-preview-CYSFgVgK.js +3 -0
- package/public/assets/markdown-preview-impl-BteVIjX4.js +2 -0
- package/public/assets/marko-DvhNOisQ.js +2 -0
- package/public/assets/material-theme-Bm3Qr25_.js +2 -0
- package/public/assets/material-theme-darker-2IIEA8gg.js +2 -0
- package/public/assets/material-theme-lighter-uhdI0v04.js +2 -0
- package/public/assets/material-theme-ocean-CHQ94UKr.js +2 -0
- package/public/assets/material-theme-palenight-B5W6OYN7.js +2 -0
- package/public/assets/mdc-CazklSAj.js +2 -0
- package/public/assets/mdx-DQZ5AkYe.js +2 -0
- package/public/assets/memory-C8WmXsyr.js +2 -0
- package/public/assets/message-circle-wjztgHBe.js +2 -0
- package/public/assets/message-square-C-1G8dMM.js +2 -0
- package/public/assets/message-square-reply-B9Z4cbQx.js +2 -0
- package/public/assets/messages-BzQdqlO6.js +2 -0
- package/public/assets/messages-square-DVM1ZtcI.js +2 -0
- package/public/assets/min-dark-BSWPekZh.js +2 -0
- package/public/assets/min-light-DDpmG2fV.js +2 -0
- package/public/assets/minimize-2-BkK6XoMP.js +2 -0
- package/public/assets/monokai-CdkpiU2Y.js +2 -0
- package/public/assets/night-owl-DhmEMT88.js +2 -0
- package/public/assets/night-owl-light-eJ-hLW7d.js +2 -0
- package/public/assets/nord-Cb4Vim4T.js +2 -0
- package/public/assets/octagon-x-B5lnUY-8.js +2 -0
- package/public/assets/one-dark-pro-CLwyXe_n.js +2 -0
- package/public/assets/one-light-D7Lr4KcI.js +2 -0
- package/public/assets/orchestrators-B1HxzkNw.js +2 -0
- package/public/assets/overview-DCUnI4Z7.js +2 -0
- package/public/assets/package-open-ckPgcjpv.js +2 -0
- package/public/assets/package-plus-C1AKMjsl.js +2 -0
- package/public/assets/pairs-ftCd2XcD.js +2 -0
- package/public/assets/paperclip-CNpKZKum.js +2 -0
- package/public/assets/pause-DttnHD4c.js +2 -0
- package/public/assets/pencil-B1Hf2V_J.js +2 -0
- package/public/assets/php-CBqsN0ai.js +2 -0
- package/public/assets/pin-DcsKeXxr.js +2 -0
- package/public/assets/plastic-DQwYfKfQ.js +2 -0
- package/public/assets/play-BbT8m7A0.js +2 -0
- package/public/assets/plug-vIyO9_P8.js +2 -0
- package/public/assets/plug-zap-V0wMDJ-G.js +2 -0
- package/public/assets/plus-D5Ek4e2S.js +2 -0
- package/public/assets/poimandres-DRFjx7u4.js +2 -0
- package/public/assets/popover-8w1TWKMG.js +2 -0
- package/public/assets/postcss-BXeXVLqQ.js +2 -0
- package/public/assets/power-6tZOhYPg.js +2 -0
- package/public/assets/preload-helper-HclGiUj8.js +1 -0
- package/public/assets/profile-icon-B2zH8DMH.js +2 -0
- package/public/assets/projects-B_lmcqfO.js +2 -0
- package/public/assets/prompt-settings-Bftq9czX.js +2 -0
- package/public/assets/provider-brand-icon-_67JR7Zh.js +2 -0
- package/public/assets/provider-display-DbLWpP3j.js +2 -0
- package/public/assets/pug-C5hz5LQ7.js +2 -0
- package/public/assets/python-gzcpVVnB.js +2 -0
- package/public/assets/r-Dzep-lPg.js +2 -0
- package/public/assets/radio-Bn0_qc0G.js +2 -0
- package/public/assets/react-dom-DSFxiC7T.js +2 -0
- package/public/assets/red-CJ3rzSJv.js +2 -0
- package/public/assets/refresh-cw-CfpvQcUn.js +2 -0
- package/public/assets/regexp-Omp9DhTb.js +2 -0
- package/public/assets/registry-DWCU5c8q.js +4 -0
- package/public/assets/repeat-hl4p_Klo.js +2 -0
- package/public/assets/rocket-BmO1qSu-.js +2 -0
- package/public/assets/rolldown-runtime-QTnfLwEv.js +1 -0
- package/public/assets/rose-pine-BthvhNj6.js +2 -0
- package/public/assets/rose-pine-dawn-Dg85fqjY.js +2 -0
- package/public/assets/rose-pine-moon-hon4tzzS.js +2 -0
- package/public/assets/rotate-ccw-CtD77qkX.js +2 -0
- package/public/assets/rotate-cw-FPtkDewA.js +2 -0
- package/public/assets/run-card-CO_bguQf.js +2 -0
- package/public/assets/sass-DXrisJhu.js +2 -0
- package/public/assets/save-B_PGqSm4.js +2 -0
- package/public/assets/scroll-area-CIN4KQse.js +2 -0
- package/public/assets/scss-DdSxiZKl.js +2 -0
- package/public/assets/search-DjzbnTbf.js +2 -0
- package/public/assets/secrets-C7GIUATz.js +2 -0
- package/public/assets/security-BUFau5-N.js +3 -0
- package/public/assets/select-DTQMP4Dk.js +2 -0
- package/public/assets/separator-t1cLZErD.js +2 -0
- package/public/assets/server-CZIRjFyY.js +2 -0
- package/public/assets/service-access-settings-C3aujqTG.js +2 -0
- package/public/assets/settings-C6sZ9eBa.js +6 -0
- package/public/assets/shellscript-CLZ0U2zV.js +2 -0
- package/public/assets/shield-CtXNUA0i.js +2 -0
- package/public/assets/shield-alert-B9jCWcKW.js +2 -0
- package/public/assets/shipping-Bu8p1gEw.js +2 -0
- package/public/assets/shipping-stats-BiMTsA4A.js +2 -0
- package/public/assets/slack-dark-DnToyrRv.js +2 -0
- package/public/assets/slack-ochin-B2OO5cIa.js +2 -0
- package/public/assets/smile-plus-q6EQBXHZ.js +2 -0
- package/public/assets/snazzy-light-4G7pJPwS.js +2 -0
- package/public/assets/solarized-dark-DV17i1UV.js +2 -0
- package/public/assets/solarized-light-DSh2HLQt.js +2 -0
- package/public/assets/sparkles-CzwR10ZU.js +2 -0
- package/public/assets/sql-DNssxck8.js +2 -0
- package/public/assets/square-Bqly37YM.js +2 -0
- package/public/assets/stats-V9Z-GxUd.js +2 -0
- package/public/assets/status-dot-CVv0iGHL.js +2 -0
- package/public/assets/stethoscope-SCBrnQQ8.js +2 -0
- package/public/assets/store-BvtFdlGX.js +9 -0
- package/public/assets/stylus-B6D30XZt.js +2 -0
- package/public/assets/svelte-DOdLCIlh.js +2 -0
- package/public/assets/switch-DuCA7mrB.js +2 -0
- package/public/assets/synthwave-84-nFMaYfgc.js +2 -0
- package/public/assets/tabs-jZgNvNHr.js +2 -0
- package/public/assets/task-chip-CYj0mpoL.js +2 -0
- package/public/assets/tasks-BIyeAaPC.js +2 -0
- package/public/assets/tasks-CXU75HRF.js +11 -0
- package/public/assets/teams-BPf976zb.js +2 -0
- package/public/assets/terminal-Bl2u7KxT.js +2 -0
- package/public/assets/terminal-viewer-DE9BOe-8.js +3 -0
- package/public/assets/terminal-viewer-impl-BrP-ENHg.css +1 -0
- package/public/assets/terminal-viewer-impl-D04pjmGh.js +143 -0
- package/public/assets/textarea-hs6Mpyfl.js +2 -0
- package/public/assets/themes-G5j9m1Ji.js +2 -0
- package/public/assets/tokyo-night-oM2G3aXe.js +2 -0
- package/public/assets/trash-2-FbcSq927.js +2 -0
- package/public/assets/triangle-alert-BBNhfgMi.js +2 -0
- package/public/assets/ts-tags-Ca73dJJY.js +2 -0
- package/public/assets/tsx-5Eka4NBX.js +2 -0
- package/public/assets/typescript-DOu2WMV5.js +2 -0
- package/public/assets/use-agent-terminal-B1yR456R.js +2 -0
- package/public/assets/use-decisions-D-S4tpDf.js +2 -0
- package/public/assets/use-project-list-B-T2Bnnn.js +2 -0
- package/public/assets/use-selectors-CnrAk2YP.js +6 -0
- package/public/assets/user-avatar-nBFIcR4M.js +2 -0
- package/public/assets/user-cog-CKcouW1J.js +2 -0
- package/public/assets/user-plus-D9749q73.js +2 -0
- package/public/assets/users-C7B3u9jv.js +2 -0
- package/public/assets/versioned-prompt-editor-Diu8BIaM.js +8 -0
- package/public/assets/vesper-DdrHHSXu.js +2 -0
- package/public/assets/vitesse-black-fwtXNY1n.js +2 -0
- package/public/assets/vitesse-dark-BZCL-v6S.js +2 -0
- package/public/assets/vitesse-light-VbXTXTou.js +2 -0
- package/public/assets/volume-2-XrcRKD9Z.js +2 -0
- package/public/assets/vue-Bfx0ffIq.js +2 -0
- package/public/assets/vue-html-BeluIYX0.js +2 -0
- package/public/assets/vue-vine-DGUAbOCX.js +2 -0
- package/public/assets/warehouse-BanzOanY.js +2 -0
- package/public/assets/wasm-BnjxR4X6.js +2 -0
- package/public/assets/wasm-ByWQv1Qj.js +2 -0
- package/public/assets/waypoints-CIzINtLT.js +2 -0
- package/public/assets/wgsl-BsKzXJz4.js +2 -0
- package/public/assets/wit-DdvCle-K.js +2 -0
- package/public/assets/work-queue-TCjJxeT-.js +2 -0
- package/public/assets/workflow-marker-Cf3Hf2fN.js +2 -0
- package/public/assets/workflows-CXQX20Qj.js +6 -0
- package/public/assets/workspaces-qSYzKYMA.js +3 -0
- package/public/assets/wrench-C7-4CgnY.js +2 -0
- package/public/assets/x-Bge17hWJ.js +2 -0
- package/public/assets/xml-DIqSwXR3.js +2 -0
- package/public/assets/yaml-rwi0_p6S.js +2 -0
- package/public/assets/zap-DGuDTw4w.js +2 -0
- package/public/assets/zoom-in-Bs8Qv8VL.js +2 -0
- package/public/assets/zoomable-image-B3Og53nj.js +2 -0
- package/public/cosmos/audio/README.md +50 -0
- package/public/cosmos/audio/alert.mp3 +0 -0
- package/public/cosmos/audio/ambient-bed.mp3 +0 -0
- package/public/cosmos/audio/comet.mp3 +0 -0
- package/public/cosmos/audio/cross-galaxy.mp3 +0 -0
- package/public/cosmos/audio/deploy.mp3 +0 -0
- package/public/cosmos/audio/galaxy-dissipate.mp3 +0 -0
- package/public/cosmos/audio/galaxy-form.mp3 +0 -0
- package/public/cosmos/audio/land.mp3 +0 -0
- package/public/cosmos/audio/reap.mp3 +0 -0
- package/public/cosmos/audio/spawn.mp3 +0 -0
- package/public/cosmos.html +34 -0
- package/public/favicon.ico +0 -0
- package/public/favicon.svg +10 -0
- package/public/icons/apple-touch-icon.png +0 -0
- package/public/icons/humwick-192.png +0 -0
- package/public/icons/humwick-512.png +0 -0
- package/public/icons/humwick.svg +19 -0
- package/public/index.html +188 -0
- package/public/manifest.webmanifest +45 -0
- package/public/sw.js +160 -0
- package/recipes/code-review.yaml +26 -0
- package/recipes/debug.yaml +20 -0
- package/recipes/feature.yaml +26 -0
- package/recipes/refactor.yaml +20 -0
- package/recipes/test.yaml +20 -0
- package/runner/LICENSE +167 -0
- package/runner/agent-bin/agent-relay-browser +10 -0
- package/runner/agent-bin/humwick +10 -0
- package/runner/hooks/fff-search-redirect/fff-search-redirect.cjs +161 -0
- package/runner/hooks/fff-search-redirect/hooks.json +13 -0
- package/runner/hooks/rg-r-guard/hooks.json +18 -0
- package/runner/hooks/rg-r-guard/rg-r-guard.cjs +144 -0
- package/runner/hooks/web-tools-redirect/hooks.json +13 -0
- package/runner/hooks/web-tools-redirect/web-tools-redirect.cjs +84 -0
- package/runner/plugins/browser/skills/playwright-cli/SKILL.md +53 -0
- package/runner/plugins/claude/.claude-plugin/plugin.json +8 -0
- package/runner/plugins/claude/claude-statusline-probe.cjs +144 -0
- package/runner/plugins/claude/hooks/gate-run-guard.provisioned.mjs +914 -0
- package/runner/plugins/claude/hooks/gate-run-guard.sh +9 -0
- package/runner/plugins/claude/hooks/gate-run-guard.ts +237 -0
- package/runner/plugins/claude/hooks/hooks.json +158 -0
- package/runner/plugins/claude/hooks/kill-guard.provisioned.mjs +7027 -0
- package/runner/plugins/claude/hooks/kill-guard.sh +341 -0
- package/runner/plugins/claude/hooks/kill-guard.ts +337 -0
- package/runner/plugins/claude/hooks/permission-request.sh +22 -0
- package/runner/plugins/claude/hooks/post-compact.sh +10 -0
- package/runner/plugins/claude/hooks/post-tool-use.sh +8 -0
- package/runner/plugins/claude/hooks/pre-compact.sh +12 -0
- package/runner/plugins/claude/hooks/read-only-bash-guard.sh +587 -0
- package/runner/plugins/claude/hooks/relay-status.sh +373 -0
- package/runner/plugins/claude/hooks/session-end.sh +26 -0
- package/runner/plugins/claude/hooks/session-start.sh +31 -0
- package/runner/plugins/claude/hooks/shell-trust.ts +28 -0
- package/runner/plugins/claude/hooks/stop-failure.sh +47 -0
- package/runner/plugins/claude/hooks/stop.sh +48 -0
- package/runner/plugins/claude/hooks/subagent-guard.cjs +26 -0
- package/runner/plugins/claude/hooks/subagent-skill-policy.cjs +160 -0
- package/runner/plugins/claude/hooks/subagent-start.sh +13 -0
- package/runner/plugins/claude/hooks/subagent-stop.sh +19 -0
- package/runner/plugins/claude/hooks/user-prompt-submit.sh +18 -0
- package/runner/plugins/claude/hooks/wait-loop-guard.ts +120 -0
- package/runner/plugins/claude/monitors/monitors.json +7 -0
- package/runner/plugins/claude/monitors/relay-monitor.provisioned.mjs +786 -0
- package/runner/plugins/claude/monitors/relay-monitor.ts +58 -0
- package/runner/plugins/claude/skills/disconnect/SKILL.md +16 -0
- package/runner/plugins/claude/skills/label/SKILL.md +23 -0
- package/runner/plugins/claude/skills/message/SKILL.md +40 -0
- package/runner/plugins/claude/skills/pair/SKILL.md +30 -0
- package/runner/plugins/claude/skills/react/SKILL.md +18 -0
- package/runner/plugins/claude/skills/read-message/SKILL.md +24 -0
- package/runner/plugins/claude/skills/reply/SKILL.md +44 -0
- package/runner/plugins/claude/skills/send-claimable/SKILL.md +39 -0
- package/runner/plugins/claude/skills/slice-first/SKILL.md +32 -0
- package/runner/plugins/claude/skills/slice-first/references/plan-recipe.md +46 -0
- package/runner/plugins/claude/skills/status/SKILL.md +16 -0
- package/runner/plugins/claude/skills/tags/SKILL.md +25 -0
- package/runner/plugins/claude/skills/task/SKILL.md +28 -0
- package/runner/plugins/claude-output-style/.claude-plugin/plugin.json +5 -0
- package/runner/plugins/claude-output-style/output-styles/agent-relay.md +5 -0
- package/runner/plugins/codex/skills/disconnect/SKILL.md +15 -0
- package/runner/plugins/codex/skills/guide/SKILL.md +15 -0
- package/runner/plugins/codex/skills/label/SKILL.md +22 -0
- package/runner/plugins/codex/skills/message/SKILL.md +40 -0
- package/runner/plugins/codex/skills/pair/SKILL.md +29 -0
- package/runner/plugins/codex/skills/react/SKILL.md +17 -0
- package/runner/plugins/codex/skills/read-message/SKILL.md +23 -0
- package/runner/plugins/codex/skills/reply/SKILL.md +44 -0
- package/runner/plugins/codex/skills/send-claimable/SKILL.md +39 -0
- package/runner/plugins/codex/skills/slice-first/SKILL.md +32 -0
- package/runner/plugins/codex/skills/slice-first/references/plan-recipe.md +46 -0
- package/runner/plugins/codex/skills/status/SKILL.md +15 -0
- package/runner/plugins/codex/skills/tags/SKILL.md +24 -0
- package/runner/plugins/codex/skills/task/SKILL.md +28 -0
- package/runner/src/adapter.ts +1061 -0
- package/runner/src/adapters/__fixtures__/codex-app-server.ts +47 -0
- package/runner/src/adapters/claude-api.ts +243 -0
- package/runner/src/adapters/claude-context-command.ts +16 -0
- package/runner/src/adapters/claude-credentials.ts +22 -0
- package/runner/src/adapters/claude-delivery-lanes.ts +28 -0
- package/runner/src/adapters/claude-delivery.ts +166 -0
- package/runner/src/adapters/claude-effort.ts +94 -0
- package/runner/src/adapters/claude-exit.ts +290 -0
- package/runner/src/adapters/claude-headless-mirror.ts +88 -0
- package/runner/src/adapters/claude-headless-refusal.ts +51 -0
- package/runner/src/adapters/claude-headless.ts +617 -0
- package/runner/src/adapters/claude-monitor-delivery-plan.ts +317 -0
- package/runner/src/adapters/claude-permission.ts +243 -0
- package/runner/src/adapters/claude-prompt-gates.ts +269 -0
- package/runner/src/adapters/claude-prompt-hook.ts +145 -0
- package/runner/src/adapters/claude-session-capture.ts +293 -0
- package/runner/src/adapters/claude-session-probe.ts +414 -0
- package/runner/src/adapters/claude-shutdown.ts +190 -0
- package/runner/src/adapters/claude-status-detectors.ts +426 -0
- package/runner/src/adapters/claude-subagents.ts +93 -0
- package/runner/src/adapters/claude-submit-confirmation.ts +287 -0
- package/runner/src/adapters/claude-tmux.ts +548 -0
- package/runner/src/adapters/claude-token-usage-capture.ts +253 -0
- package/runner/src/adapters/claude-tool-policy.ts +165 -0
- package/runner/src/adapters/claude-transcript-tail.ts +193 -0
- package/runner/src/adapters/claude-transcript.ts +812 -0
- package/runner/src/adapters/claude.ts +1097 -0
- package/runner/src/adapters/codex-agent-message-capture.ts +189 -0
- package/runner/src/adapters/codex-app-server.ts +70 -0
- package/runner/src/adapters/codex-client.ts +362 -0
- package/runner/src/adapters/codex-effective-config.ts +87 -0
- package/runner/src/adapters/codex-launch-config.ts +153 -0
- package/runner/src/adapters/codex-rollout-context.ts +272 -0
- package/runner/src/adapters/codex-skill-discovery.ts +18 -0
- package/runner/src/adapters/codex-token-usage-capture.ts +163 -0
- package/runner/src/adapters/codex-tool-output.ts +53 -0
- package/runner/src/adapters/codex-turn-outcome.ts +27 -0
- package/runner/src/adapters/codex-version.ts +64 -0
- package/runner/src/adapters/codex.ts +1442 -0
- package/runner/src/adapters/incremental-file.ts +110 -0
- package/runner/src/adapters/opencode-api.ts +71 -0
- package/runner/src/adapters/opencode-context.ts +277 -0
- package/runner/src/adapters/opencode-model-registry.ts +126 -0
- package/runner/src/adapters/opencode-provider.ts +169 -0
- package/runner/src/adapters/opencode-server-retry.ts +50 -0
- package/runner/src/adapters/opencode-soft-steer.ts +302 -0
- package/runner/src/adapters/opencode-spawn.ts +145 -0
- package/runner/src/adapters/opencode-subscribe.ts +62 -0
- package/runner/src/adapters/opencode-token-usage-capture.ts +187 -0
- package/runner/src/adapters/opencode-tool-events.ts +302 -0
- package/runner/src/adapters/opencode-tools-config.ts +17 -0
- package/runner/src/adapters/opencode.ts +2264 -0
- package/runner/src/adapters/project-shell.ts +80 -0
- package/runner/src/adapters/provider-launch-config.ts +21 -0
- package/runner/src/adapters/provider-quota-harvest.ts +127 -0
- package/runner/src/adapters/service-access.ts +153 -0
- package/runner/src/adapters/tmux-offload.ts +207 -0
- package/runner/src/adapters/tool-summary.ts +214 -0
- package/runner/src/agent-redact.ts +75 -0
- package/runner/src/agent-runner/commands/dispatch.ts +185 -0
- package/runner/src/agent-runner/commands/lifecycle.ts +84 -0
- package/runner/src/agent-runner/commands/prompt.ts +284 -0
- package/runner/src/agent-runner/credentials.ts +208 -0
- package/runner/src/agent-runner/http-liveness.ts +85 -0
- package/runner/src/agent-runner/lifecycle-milestones.ts +207 -0
- package/runner/src/agent-runner/lifecycle-phase.ts +80 -0
- package/runner/src/agent-runner/registration.ts +163 -0
- package/runner/src/agent-runner/runner-context.ts +158 -0
- package/runner/src/agent-runner/session-mirror.ts +278 -0
- package/runner/src/agent-runner/task-claims.ts +116 -0
- package/runner/src/agent-runner/token-usage-coverage.ts +54 -0
- package/runner/src/agent-runner/turn-report.ts +269 -0
- package/runner/src/api-budget-accounting.ts +91 -0
- package/runner/src/area-memory.ts +255 -0
- package/runner/src/artifact-path-materialize.ts +52 -0
- package/runner/src/async-guard.ts +35 -0
- package/runner/src/attachment-cache-sweep.ts +31 -0
- package/runner/src/attachment-cache.ts +195 -0
- package/runner/src/background-script-reconcile.ts +106 -0
- package/runner/src/bounded-log.ts +59 -0
- package/runner/src/bounded-spawn-sync.ts +18 -0
- package/runner/src/busy-reconciler.ts +282 -0
- package/runner/src/claim-tracker.ts +140 -0
- package/runner/src/claude-settings.ts +167 -0
- package/runner/src/claude-workspace-trust.ts +289 -0
- package/runner/src/config.ts +547 -0
- package/runner/src/context-boundary.ts +101 -0
- package/runner/src/context-command.ts +151 -0
- package/runner/src/context-probe-state.ts +6 -0
- package/runner/src/continuation-archive.ts +179 -0
- package/runner/src/control-server.ts +730 -0
- package/runner/src/delivery-policy.ts +9 -0
- package/runner/src/delivery-result.ts +24 -0
- package/runner/src/effort-command.ts +125 -0
- package/runner/src/empty-turn.ts +816 -0
- package/runner/src/free-port.ts +25 -0
- package/runner/src/fs-offload.ts +26 -0
- package/runner/src/gate-run-config.ts +35 -0
- package/runner/src/gate-run-lease-probe.ts +38 -0
- package/runner/src/host-asset-plan.ts +450 -0
- package/runner/src/host-claude-config-worker.ts +34 -0
- package/runner/src/host-sources.ts +40 -0
- package/runner/src/inbox-carrier.ts +7 -0
- package/runner/src/index.ts +386 -0
- package/runner/src/launch-assembly.ts +955 -0
- package/runner/src/liveness.ts +105 -0
- package/runner/src/logger.ts +108 -0
- package/runner/src/mcp-outbox.ts +204 -0
- package/runner/src/mcp-preflight.ts +86 -0
- package/runner/src/mcp-source-selection.ts +54 -0
- package/runner/src/mcp-tool-deferral.ts +35 -0
- package/runner/src/mcp-vault-env.ts +25 -0
- package/runner/src/message-body-config/config.ts +16 -0
- package/runner/src/message-body-config.ts +1 -0
- package/runner/src/mid-turn-delivery.ts +43 -0
- package/runner/src/native-memory-lever.ts +329 -0
- package/runner/src/native-self-resume.ts +244 -0
- package/runner/src/outbox.ts +453 -0
- package/runner/src/park-post.ts +17 -0
- package/runner/src/pending-permission-store.ts +148 -0
- package/runner/src/process-meta.ts +9 -0
- package/runner/src/profile-home.ts +419 -0
- package/runner/src/profile-projection.ts +411 -0
- package/runner/src/project-hooks.ts +65 -0
- package/runner/src/project-instructions.ts +119 -0
- package/runner/src/provider-double.ts +59 -0
- package/runner/src/provider-hold.ts +228 -0
- package/runner/src/provider-home-marker.ts +3 -0
- package/runner/src/provider-home-tombstone.ts +4 -0
- package/runner/src/provider-input-queue.ts +134 -0
- package/runner/src/provider-integration.ts +93 -0
- package/runner/src/provider-processes.ts +17 -0
- package/runner/src/provider-submit-failure.ts +15 -0
- package/runner/src/providers.ts +35 -0
- package/runner/src/provisioning.ts +703 -0
- package/runner/src/question-decision.ts +18 -0
- package/runner/src/quota.ts +22 -0
- package/runner/src/rate-limit.ts +351 -0
- package/runner/src/refused-prompt-store.ts +36 -0
- package/runner/src/relay-injection-events.ts +161 -0
- package/runner/src/relay-instructions.ts +107 -0
- package/runner/src/relay-mcp-proxy.long-turn-e2e.ts +183 -0
- package/runner/src/relay-mcp-proxy.ts +704 -0
- package/runner/src/relay-mcp.ts +583 -0
- package/runner/src/reply-obligation-cache.ts +211 -0
- package/runner/src/response-capture-report.ts +111 -0
- package/runner/src/response-routing.ts +6 -0
- package/runner/src/runner-core.ts +2955 -0
- package/runner/src/runner-exit.ts +12 -0
- package/runner/src/runner-helpers.ts +582 -0
- package/runner/src/runner-insights.ts +105 -0
- package/runner/src/runner-mcp-proxy.ts +46 -0
- package/runner/src/runner-spawn-config.ts +68 -0
- package/runner/src/runner-stale-scratch-sweep.ts +21 -0
- package/runner/src/runner.ts +9 -0
- package/runner/src/runtime-token-file.ts +45 -0
- package/runner/src/runtime-token-remint.ts +56 -0
- package/runner/src/service-access.ts +88 -0
- package/runner/src/session-destroy.ts +27 -0
- package/runner/src/session-insights.ts +118 -0
- package/runner/src/session-scratch.ts +296 -0
- package/runner/src/spawn-input.ts +147 -0
- package/runner/src/startup-config-fetch.ts +48 -0
- package/runner/src/subreaper.ts +113 -0
- package/runner/src/template-resolver.ts +29 -0
- package/runner/src/test-run-dedup.ts +435 -0
- package/runner/src/transcript-context.ts +99 -0
- package/runner/src/transport-errors.ts +48 -0
- package/runner/src/turn-opener.ts +55 -0
- package/runner/src/turn-reconcile-event.ts +88 -0
- package/runner/src/vault-proxy-hop.ts +99 -0
- package/runner/src/version.ts +44 -0
- package/runner/src/web-tool-call-proxy.ts +128 -0
- package/runner/src/web-tools.ts +59 -0
- package/runner/test-support/codex-web-config-proof.ts +149 -0
- package/runner/test-support/effective-launch.ts +189 -0
- package/runner/test-support/native-context-sources.ts +77 -0
- package/runner/test-support/provisioning-context.ts +55 -0
- package/runner/test-support/recorder-double.ts +130 -0
- package/runner/test-support/recording-provider.ts +242 -0
- package/runner/test-support/runner-harness.ts +249 -0
- package/runner/test-support/service-access-fixture.ts +12 -0
- package/scripts/agent-vault/bootstrap.py +87 -0
- package/scripts/agent-vault/install.py +200 -0
- package/scripts/agent-vault/install_refresh.py +98 -0
- package/scripts/agent-vault/refresh.py +116 -0
- package/scripts/agent-vault/refresh_provision.py +109 -0
- package/scripts/agent-vault/refresh_store.py +54 -0
- package/scripts/agent-vault/runtime.py +253 -0
- package/scripts/agent-vault/sec-ops-activation.json +23 -0
- package/scripts/artifact-checkout-gc.ts +51 -0
- package/scripts/cd-config.ts +224 -0
- package/scripts/cd-deploy-debounce.ts +94 -0
- package/scripts/cd-deploy-worktree-gc.ts +235 -0
- package/scripts/cd-fleet-membership.ts +48 -0
- package/scripts/cd-host-epochs.ts +101 -0
- package/scripts/cd-hub-wake.ts +40 -0
- package/scripts/cd-land-boundary.ts +49 -0
- package/scripts/cd-watcher.ts +985 -0
- package/scripts/dashboard-build-marker.ts +71 -0
- package/scripts/fleet-sha-coverage.ts +66 -0
- package/scripts/gate-run-lease.ts +329 -0
- package/scripts/gate-slot +9 -0
- package/scripts/gate-slot-fleet-health.ts +60 -0
- package/scripts/gate.sh +6 -0
- package/scripts/install-bin-shim.cjs +149 -0
- package/scripts/orchestrator-spawn-smoke.ts +398 -0
- package/scripts/provisioning-matrix.ts +72 -0
- package/scripts/release-cd-stamp.ts +146 -0
- package/scripts/release-health.ts +133 -0
- package/scripts/release-report.ts +102 -0
- package/scripts/release-upgrade.ts +1296 -0
- package/scripts/steward-policy-cleanup.ts +73 -0
- package/scripts/wait-for-deploy.ts +43 -0
- package/src/agent-authz.ts +219 -0
- package/src/agent-branch-state.ts +45 -0
- package/src/agent-busy-health.ts +158 -0
- package/src/agent-card-projection.ts +86 -0
- package/src/agent-channel-binding.ts +49 -0
- package/src/agent-command-activity.ts +39 -0
- package/src/agent-core.ts +29 -0
- package/src/agent-death-diagnosis.ts +314 -0
- package/src/agent-drive-arbiter.ts +112 -0
- package/src/agent-exit-alarm.ts +10 -0
- package/src/agent-exit-cleanup-async.ts +69 -0
- package/src/agent-exit-cleanup.ts +99 -0
- package/src/agent-exit-report.ts +28 -0
- package/src/agent-issue-repo.ts +53 -0
- package/src/agent-launch-shape-redaction.ts +72 -0
- package/src/agent-lifecycle-events.ts +428 -0
- package/src/agent-principal.ts +14 -0
- package/src/agent-profile-catalog.ts +188 -0
- package/src/agent-ref.ts +340 -0
- package/src/agent-spawn.ts +45 -0
- package/src/agent-status-events.ts +41 -0
- package/src/agent-system-tags.ts +38 -0
- package/src/artifact-media.ts +34 -0
- package/src/artifact-storage.ts +245 -0
- package/src/artifact-text.ts +31 -0
- package/src/async-deadline.ts +59 -0
- package/src/auth/admin-routes.ts +36 -0
- package/src/auth/index.ts +23 -0
- package/src/auth/login-rate-limiter.ts +153 -0
- package/src/auth/password.ts +142 -0
- package/src/auth/provider.ts +60 -0
- package/src/auth/role-scopes.ts +15 -0
- package/src/auth/session-cookie.ts +35 -0
- package/src/auth/session-refresh.ts +61 -0
- package/src/auth/session.test-fixture.ts +10 -0
- package/src/auth/session.ts +107 -0
- package/src/authority-audit.ts +56 -0
- package/src/authz-meta-keys.ts +64 -0
- package/src/auto-spawn-dispatch.ts +154 -0
- package/src/automations/constants.ts +14 -0
- package/src/automations/cron.ts +129 -0
- package/src/automations/crud.ts +129 -0
- package/src/automations/dispatch.ts +299 -0
- package/src/automations/index.ts +5 -0
- package/src/automations/precheck.ts +124 -0
- package/src/automations/reconcile.ts +314 -0
- package/src/automations/storage.ts +200 -0
- package/src/automations/types.ts +16 -0
- package/src/automations/validation.ts +216 -0
- package/src/automations.ts +1 -0
- package/src/branch-landed.ts +761 -0
- package/src/browser-authz.ts +18 -0
- package/src/browser-config.ts +31 -0
- package/src/bundled-workflows.ts +48 -0
- package/src/bus-outbox-async.ts +16 -0
- package/src/bus-outbox.ts +265 -0
- package/src/bus-resume-commands.ts +18 -0
- package/src/bus.ts +792 -0
- package/src/canonical-repo-root.ts +131 -0
- package/src/cd-deploy-notify.ts +59 -0
- package/src/cd-host-deferrals.ts +23 -0
- package/src/cd-host-lag-notify.ts +36 -0
- package/src/cd-repository.ts +49 -0
- package/src/channel-output-control.ts +43 -0
- package/src/channel-output-validation.ts +11 -0
- package/src/channel-policy-health.ts +20 -0
- package/src/channel-target.ts +40 -0
- package/src/channels-host-service.ts +219 -0
- package/src/ci/bun-test-log.ts +41 -0
- package/src/ci/failed-test-files.ts +52 -0
- package/src/ci/gate-history.ts +66 -0
- package/src/ci/github-actions.ts +145 -0
- package/src/ci/incidents.ts +175 -0
- package/src/ci/index.ts +6 -0
- package/src/ci/job-verdict.ts +27 -0
- package/src/ci/land-boundary-ci.ts +104 -0
- package/src/ci/monitor.ts +528 -0
- package/src/ci/not-triggered.ts +116 -0
- package/src/ci/notifications.ts +234 -0
- package/src/ci/provider.ts +87 -0
- package/src/ci/root-missing.ts +35 -0
- package/src/ci/transition-notify.ts +279 -0
- package/src/ci-monitor.ts +7 -0
- package/src/claude-api-budget-async.ts +11 -0
- package/src/claude-api-budget-config.ts +23 -0
- package/src/claude-api-expiry.ts +70 -0
- package/src/claude-api-overflow.ts +146 -0
- package/src/claude-app/config.ts +13 -0
- package/src/claude-app/oauth-http.ts +127 -0
- package/src/claude-app/oauth-provider.ts +136 -0
- package/src/claude-app/passphrase.ts +14 -0
- package/src/claude-app-auth.ts +65 -0
- package/src/claude-app-gateway.ts +68 -0
- package/src/cli/_shared.ts +136 -0
- package/src/cli/agent-detect.ts +175 -0
- package/src/cli/agent-guide.ts +152 -0
- package/src/cli/agent-keep.ts +37 -0
- package/src/cli/agent-meta.ts +111 -0
- package/src/cli/artifact.ts +154 -0
- package/src/cli/browser.ts +56 -0
- package/src/cli/channel-output.ts +17 -0
- package/src/cli/channels-host.ts +13 -0
- package/src/cli/channels.ts +16 -0
- package/src/cli/claude-api-budget.ts +41 -0
- package/src/cli/context-probe.ts +90 -0
- package/src/cli/credentials.ts +1 -0
- package/src/cli/daemon.ts +125 -0
- package/src/cli/dev.ts +185 -0
- package/src/cli/ephemeral.ts +159 -0
- package/src/cli/hosts.ts +41 -0
- package/src/cli/index.ts +442 -0
- package/src/cli/introspect.ts +74 -0
- package/src/cli/maintenance.ts +24 -0
- package/src/cli/merges.ts +78 -0
- package/src/cli/message.ts +229 -0
- package/src/cli/orchestrator.ts +384 -0
- package/src/cli/pair.ts +135 -0
- package/src/cli/profile.ts +35 -0
- package/src/cli/project.ts +52 -0
- package/src/cli/prompts.ts +23 -0
- package/src/cli/provider-enablement.ts +42 -0
- package/src/cli/provider.ts +230 -0
- package/src/cli/recipe.ts +110 -0
- package/src/cli/reply.ts +130 -0
- package/src/cli/roles.ts +60 -0
- package/src/cli/routing-policy.ts +20 -0
- package/src/cli/run.ts +96 -0
- package/src/cli/secrets-backup.ts +85 -0
- package/src/cli/secrets.ts +55 -0
- package/src/cli/service-access.ts +23 -0
- package/src/cli/setup.ts +57 -0
- package/src/cli/shutdown.ts +16 -0
- package/src/cli/spawn.ts +31 -0
- package/src/cli/state.ts +73 -0
- package/src/cli/steward.ts +58 -0
- package/src/cli/task.ts +151 -0
- package/src/cli/team.ts +18 -0
- package/src/cli/timers.ts +53 -0
- package/src/cli/token.ts +72 -0
- package/src/cli/upgrade.ts +200 -0
- package/src/cli/web-tool-calls.ts +17 -0
- package/src/cli/workflow.ts +46 -0
- package/src/cli/workspace.ts +544 -0
- package/src/cli.ts +4 -0
- package/src/codex-reset-consume.ts +274 -0
- package/src/codex-wham-quota.ts +177 -0
- package/src/command-events.ts +69 -0
- package/src/command-secrets.ts +198 -0
- package/src/command-ttl.ts +63 -0
- package/src/commands-db.ts +1196 -0
- package/src/commands-landing-async.ts +166 -0
- package/src/commands-write.ts +160 -0
- package/src/comment-blocks.ts +84 -0
- package/src/compaction-watch.ts +259 -0
- package/src/config-model-selection.ts +14 -0
- package/src/config-store-write.ts +39 -0
- package/src/config-store.ts +1253 -0
- package/src/config.ts +939 -0
- package/src/connector-boot-health.ts +27 -0
- package/src/connector-paths.ts +47 -0
- package/src/connectors.ts +547 -0
- package/src/content-security.ts +12 -0
- package/src/context-advisory.ts +279 -0
- package/src/context-block-rendered-at.ts +33 -0
- package/src/context-injection-channel.ts +49 -0
- package/src/context-router.ts +121 -0
- package/src/context-threshold-config.ts +52 -0
- package/src/continuation-replay-edge.ts +30 -0
- package/src/continuity-working-state.ts +107 -0
- package/src/contracts.ts +109 -0
- package/src/coordinator-authority.ts +100 -0
- package/src/coordinator-digest-config.ts +20 -0
- package/src/cosmos-events.ts +164 -0
- package/src/daemon.ts +570 -0
- package/src/dashboard-notifications.ts +169 -0
- package/src/dashboard-presence.ts +86 -0
- package/src/db/activity-async.ts +58 -0
- package/src/db/activity-read-ops.ts +42 -0
- package/src/db/activity-write-ops.ts +43 -0
- package/src/db/activity.ts +454 -0
- package/src/db/agent-card-read.ts +98 -0
- package/src/db/agent-effort-state.ts +146 -0
- package/src/db/agent-exit-cleanup.ts +94 -0
- package/src/db/agent-exit-report.ts +33 -0
- package/src/db/agent-gate-runs-write-ops.ts +7 -0
- package/src/db/agent-gate-runs.ts +96 -0
- package/src/db/agent-identity-archive.test-fixture.ts +12 -0
- package/src/db/agent-identity-archive.ts +75 -0
- package/src/db/agent-keep.ts +21 -0
- package/src/db/agent-lifecycle-write-ops.ts +92 -0
- package/src/db/agent-meta.ts +74 -0
- package/src/db/agent-outstanding-work.ts +154 -0
- package/src/db/agent-ownership-async.ts +45 -0
- package/src/db/agent-ownership-read-ops.ts +12 -0
- package/src/db/agent-ownership-write-ops.ts +50 -0
- package/src/db/agent-ownership.ts +200 -0
- package/src/db/agent-predicates.ts +64 -0
- package/src/db/agent-read.ts +39 -0
- package/src/db/agent-search-async.ts +21 -0
- package/src/db/agent-search-read-ops.ts +8 -0
- package/src/db/agent-search.ts +162 -0
- package/src/db/agent-shutdown-in-flight.ts +21 -0
- package/src/db/agents-async.ts +333 -0
- package/src/db/agents-prune-write-op.ts +37 -0
- package/src/db/agents-read-ops.ts +33 -0
- package/src/db/agents-write-ops.ts +174 -0
- package/src/db/agents.ts +1284 -0
- package/src/db/api-budget-schema.ts +144 -0
- package/src/db/api-budget-usage-migration.ts +31 -0
- package/src/db/api-budget-usage.ts +40 -0
- package/src/db/artifact-browse.ts +145 -0
- package/src/db/artifact-retention.ts +115 -0
- package/src/db/artifacts-async.ts +81 -0
- package/src/db/artifacts-read-ops.ts +24 -0
- package/src/db/artifacts-write-ops.ts +46 -0
- package/src/db/artifacts.ts +307 -0
- package/src/db/auth-identities.ts +128 -0
- package/src/db/backlog.ts +172 -0
- package/src/db/blackboard.ts +171 -0
- package/src/db/broadcast-scope.ts +63 -0
- package/src/db/broker-memory-migration.ts +71 -0
- package/src/db/browser-sessions.ts +89 -0
- package/src/db/budget-lineage.ts +26 -0
- package/src/db/bus-outbox-read-ops.ts +29 -0
- package/src/db/bus-outbox-write-ops.ts +57 -0
- package/src/db/bus-prune-async.ts +16 -0
- package/src/db/busy-regression.worker.ts +48 -0
- package/src/db/caller-lifecycle.ts +24 -0
- package/src/db/carry-pending-marker.ts +129 -0
- package/src/db/carry-pending.ts +145 -0
- package/src/db/channel-binding-delete.ts +15 -0
- package/src/db/channel-egress-allowlist.ts +200 -0
- package/src/db/channel-identity.ts +38 -0
- package/src/db/channel-runtime.ts +19 -0
- package/src/db/channels-async.ts +55 -0
- package/src/db/channels-read-ops.ts +13 -0
- package/src/db/channels-session-fence.ts +18 -0
- package/src/db/channels-write-ops.ts +42 -0
- package/src/db/channels.ts +654 -0
- package/src/db/checkout-refresh.ts +36 -0
- package/src/db/ci-gate-runs.ts +92 -0
- package/src/db/ci-incidents-async.ts +76 -0
- package/src/db/ci-incidents-read-ops.ts +15 -0
- package/src/db/ci-incidents-write-ops.ts +57 -0
- package/src/db/ci-incidents.ts +667 -0
- package/src/db/ci-sha-observations-schema.ts +33 -0
- package/src/db/claim-sql.ts +44 -0
- package/src/db/claude-api-budget-ops.ts +15 -0
- package/src/db/claude-api-budget-reconcile.ts +39 -0
- package/src/db/claude-api-budget.ts +198 -0
- package/src/db/claude-app-oauth.ts +74 -0
- package/src/db/claude-catalog-reconcile.ts +27 -0
- package/src/db/codex-reset-consumes-async.ts +9 -0
- package/src/db/codex-reset-consumes-read-ops.ts +5 -0
- package/src/db/codex-reset-consumes-write-ops.ts +19 -0
- package/src/db/codex-reset-consumes.ts +122 -0
- package/src/db/command-agent-profiles.ts +58 -0
- package/src/db/command-row.ts +88 -0
- package/src/db/command-terminal-status.ts +33 -0
- package/src/db/command-vault-pruning.ts +30 -0
- package/src/db/commands-cancel-write.ts +45 -0
- package/src/db/commands-claim-admission.ts +144 -0
- package/src/db/commands-effort-read.ts +58 -0
- package/src/db/commands-host-land-admission.ts +106 -0
- package/src/db/commands-kernel-landing.ts +268 -0
- package/src/db/commands-land-occupancy.ts +40 -0
- package/src/db/commands-land-wait.ts +38 -0
- package/src/db/commands-landing-completeness.ts +66 -0
- package/src/db/commands-landing-tuples.ts +22 -0
- package/src/db/commands-landing.ts +1046 -0
- package/src/db/commands-leaseless-sweep.ts +72 -0
- package/src/db/commands-list-query.ts +47 -0
- package/src/db/commands-planner-stats.test-fixture.ts +97 -0
- package/src/db/commands-read-ops.ts +49 -0
- package/src/db/commands-scheduler-recovery.ts +71 -0
- package/src/db/commands-spawn-read.ts +33 -0
- package/src/db/commands-write-ops.ts +286 -0
- package/src/db/config-store-write-ops.ts +58 -0
- package/src/db/connection-instrumentation.ts +76 -0
- package/src/db/connection.ts +532 -0
- package/src/db/context-reset-carry.ts +144 -0
- package/src/db/continuation-archive-purge.ts +48 -0
- package/src/db/continuation-archive-search.ts +249 -0
- package/src/db/continuation-archives-async.ts +59 -0
- package/src/db/continuation-archives-read-ops.ts +10 -0
- package/src/db/continuation-archives-write-ops.ts +15 -0
- package/src/db/continuation-archives.ts +158 -0
- package/src/db/continuations.ts +201 -0
- package/src/db/coordinator-delivery.ts +10 -0
- package/src/db/coordinator-digest-async.ts +13 -0
- package/src/db/coordinator-digest-flush.ts +6 -0
- package/src/db/coordinator-digest.ts +145 -0
- package/src/db/coordinator-seat.ts +130 -0
- package/src/db/crash-reports.ts +115 -0
- package/src/db/db-error-registry.ts +290 -0
- package/src/db/db-reader-worker.ts +91 -0
- package/src/db/db-writer-worker.ts +66 -0
- package/src/db/deferred-lineage-report-queries.ts +28 -0
- package/src/db/deferred-lineage-reports.ts +44 -0
- package/src/db/delivery-async.ts +102 -0
- package/src/db/delivery-expiration-health.ts +97 -0
- package/src/db/delivery-expiration.ts +52 -0
- package/src/db/delivery-quality-async.ts +23 -0
- package/src/db/delivery-quality.ts +116 -0
- package/src/db/delivery-read-ops.ts +26 -0
- package/src/db/delivery-report-echo.ts +53 -0
- package/src/db/delivery-write-ops.ts +72 -0
- package/src/db/delivery.ts +545 -0
- package/src/db/deploy-events-async.ts +66 -0
- package/src/db/deploy-events-read-ops.ts +25 -0
- package/src/db/deploy-events-write-ops.ts +81 -0
- package/src/db/deploy-events.ts +554 -0
- package/src/db/deploy-task-completion.ts +48 -0
- package/src/db/drive-leases.ts +165 -0
- package/src/db/durable-payloads.ts +92 -0
- package/src/db/fixtures/writer-shutdown.ts +28 -0
- package/src/db/fts-query.ts +8 -0
- package/src/db/gate-policy.ts +27 -0
- package/src/db/gate-runs.ts +181 -0
- package/src/db/gateway.ts +513 -0
- package/src/db/generation-launch.ts +82 -0
- package/src/db/guides-search.ts +18 -0
- package/src/db/history-delivery-settle.ts +57 -0
- package/src/db/hosts-async.ts +150 -0
- package/src/db/hosts-backfill.ts +91 -0
- package/src/db/hosts-read-ops.ts +21 -0
- package/src/db/hosts-registration.ts +452 -0
- package/src/db/hosts-views.ts +259 -0
- package/src/db/hosts-write-ops.ts +94 -0
- package/src/db/hosts.ts +251 -0
- package/src/db/human-address.ts +6 -0
- package/src/db/idle-digest.ts +54 -0
- package/src/db/idle-self-care.ts +100 -0
- package/src/db/inbox-async.ts +29 -0
- package/src/db/inbox-read-ops.ts +8 -0
- package/src/db/inbox-write-ops.ts +25 -0
- package/src/db/inbox.ts +197 -0
- package/src/db/index.ts +147 -0
- package/src/db/injection-attempts.ts +41 -0
- package/src/db/insights-read-ops.ts +12 -0
- package/src/db/insights-write-ops.ts +15 -0
- package/src/db/integrations.ts +297 -0
- package/src/db/issue-associations.ts +136 -0
- package/src/db/issue-lifecycle.ts +199 -0
- package/src/db/issue-refs.ts +312 -0
- package/src/db/kernel-event-log-schema.ts +14 -0
- package/src/db/kernel-landing-admission.ts +15 -0
- package/src/db/kernel-landing-command-authority.ts +222 -0
- package/src/db/kernel-persistence-async.ts +48 -0
- package/src/db/kernel-persistence-read-ops.ts +24 -0
- package/src/db/kernel-persistence-write-ops.ts +43 -0
- package/src/db/land-boundaries.ts +138 -0
- package/src/db/land-executing.ts +147 -0
- package/src/db/land-gate-attestations.ts +161 -0
- package/src/db/land-incident-eligibility.ts +44 -0
- package/src/db/land-queue-trace.ts +28 -0
- package/src/db/land-stack.ts +80 -0
- package/src/db/land-telemetry-schema.ts +50 -0
- package/src/db/land-telemetry-write-ops.ts +16 -0
- package/src/db/land-telemetry.ts +114 -0
- package/src/db/land-withdrawal-state.ts +26 -0
- package/src/db/landed-merge-evidence.ts +72 -0
- package/src/db/landed-task-attribution.ts +23 -0
- package/src/db/landing-audit.ts +18 -0
- package/src/db/landing-controllers.ts +67 -0
- package/src/db/landing-ingress-async.ts +102 -0
- package/src/db/landing-ingress-read-ops.ts +8 -0
- package/src/db/landing-ingress-write-ops.ts +42 -0
- package/src/db/landing-ingress.ts +380 -0
- package/src/db/landing-read-ops.ts +18 -0
- package/src/db/landing-receipts.ts +206 -0
- package/src/db/landing-schema.ts +479 -0
- package/src/db/launch-facts.ts +60 -0
- package/src/db/legacy-landing-publication.ts +103 -0
- package/src/db/legacy-message-backfill.ts +90 -0
- package/src/db/lifecycle-seq.ts +127 -0
- package/src/db/lifecycle-write-window.ts +216 -0
- package/src/db/lineage-pair-dedupe-sql.ts +80 -0
- package/src/db/lineage-startup-captures.ts +43 -0
- package/src/db/long-running-work-async.ts +12 -0
- package/src/db/long-running-work-write-ops.ts +8 -0
- package/src/db/long-running-work.ts +78 -0
- package/src/db/macos-privacy.ts +72 -0
- package/src/db/main-connection-writes.ts +44 -0
- package/src/db/main-thread-state.ts +38 -0
- package/src/db/maintenance-health.ts +560 -0
- package/src/db/maintenance-indexes.ts +37 -0
- package/src/db/maintenance-job-runs-async.ts +15 -0
- package/src/db/maintenance-job-runs.ts +62 -0
- package/src/db/maintenance-job-write-ops.ts +10 -0
- package/src/db/maintenance-pauses.ts +224 -0
- package/src/db/maintenance-worker.ts +111 -0
- package/src/db/mappers.ts +422 -0
- package/src/db/memory-preamble-read.ts +13 -0
- package/src/db/memory-resolve.ts +209 -0
- package/src/db/memory-retirement-plan.ts +31 -0
- package/src/db/memory-retirement.ts +15 -0
- package/src/db/merge-drain-async.ts +8 -0
- package/src/db/merge-lease.ts +225 -0
- package/src/db/message-claims.ts +16 -0
- package/src/db/message-queries.ts +16 -0
- package/src/db/message-read-mark.ts +32 -0
- package/src/db/message-reads-async.ts +46 -0
- package/src/db/message-reads-read-ops.ts +35 -0
- package/src/db/message-reads-write-ops.ts +24 -0
- package/src/db/message-reads.ts +553 -0
- package/src/db/message-send-suppression.ts +58 -0
- package/src/db/message-send.ts +76 -0
- package/src/db/message-thread.ts +15 -0
- package/src/db/message-write-ops.ts +96 -0
- package/src/db/messages-async.ts +31 -0
- package/src/db/messages-read-ops.ts +14 -0
- package/src/db/messages.ts +1201 -0
- package/src/db/migration-marker.ts +13 -0
- package/src/db/migrations.ts +1761 -0
- package/src/db/notification-subscriptions.ts +282 -0
- package/src/db/on-loop-write-transaction.ts +34 -0
- package/src/db/operator-actions-schema.ts +10 -0
- package/src/db/operator-decisions.ts +180 -0
- package/src/db/orchestrators-async.ts +57 -0
- package/src/db/orchestrators-read-ops.ts +7 -0
- package/src/db/orchestrators-write-ops.ts +52 -0
- package/src/db/orchestrators.ts +485 -0
- package/src/db/outbox-codec.ts +16 -0
- package/src/db/pair-maintenance.ts +9 -0
- package/src/db/pairs-async.ts +10 -0
- package/src/db/pairs-write-ops.ts +8 -0
- package/src/db/pairs.ts +264 -0
- package/src/db/pending-relay-runs.ts +73 -0
- package/src/db/plan-blurb-migration.ts +158 -0
- package/src/db/plan-ci-blocks.ts +28 -0
- package/src/db/plan-completion.ts +55 -0
- package/src/db/plan-conformance.ts +104 -0
- package/src/db/plan-dispatch-schema.ts +17 -0
- package/src/db/plan-dispatch-store.ts +112 -0
- package/src/db/plan-external.ts +79 -0
- package/src/db/plan-graph-async.ts +23 -0
- package/src/db/plan-graph-read-ops.ts +16 -0
- package/src/db/plan-graph-write-ops.ts +37 -0
- package/src/db/plan-graph.ts +403 -0
- package/src/db/plan-import-schema.ts +19 -0
- package/src/db/plan-import.ts +211 -0
- package/src/db/plan-task-create.ts +44 -0
- package/src/db/planner-stats.ts +123 -0
- package/src/db/plans-async.ts +22 -0
- package/src/db/plans-read-ops.ts +11 -0
- package/src/db/plans-write-ops.ts +9 -0
- package/src/db/plans.ts +385 -0
- package/src/db/policy-runtime.ts +14 -0
- package/src/db/presence-buffer.ts +111 -0
- package/src/db/presence-loop.ts +58 -0
- package/src/db/presence-write-ops.ts +28 -0
- package/src/db/presence-write.ts +38 -0
- package/src/db/profile-artifact-backfill-migration.ts +32 -0
- package/src/db/profile-host-sources-migration.ts +150 -0
- package/src/db/profile-legacy-project-instructions-migration.ts +41 -0
- package/src/db/profile-name-case-migration.ts +46 -0
- package/src/db/profile-override-migration.ts +200 -0
- package/src/db/profile-project-ack-migration.ts +55 -0
- package/src/db/profile-slim-migration.ts +125 -0
- package/src/db/profile-slim-plan.ts +190 -0
- package/src/db/project-entries-async.ts +18 -0
- package/src/db/project-entries-read-ops.ts +28 -0
- package/src/db/project-entries.ts +514 -0
- package/src/db/project-entry-search.ts +63 -0
- package/src/db/project-identity.ts +16 -0
- package/src/db/project-journal.ts +256 -0
- package/src/db/project-lifecycle.ts +80 -0
- package/src/db/project-memory-group-migration.ts +76 -0
- package/src/db/project-phantom-merge.ts +228 -0
- package/src/db/project-root-schema.ts +30 -0
- package/src/db/project-trust-approvals.ts +98 -0
- package/src/db/projects-async.ts +50 -0
- package/src/db/projects-read-ops.ts +59 -0
- package/src/db/projects-write-ops.ts +74 -0
- package/src/db/projects.ts +629 -0
- package/src/db/prompt-templates-schema.ts +23 -0
- package/src/db/prompt-templates.ts +138 -0
- package/src/db/prompt-version-migration.ts +115 -0
- package/src/db/prompt-versions-ops.ts +16 -0
- package/src/db/prompt-versions.ts +167 -0
- package/src/db/provider-catalog-async.ts +31 -0
- package/src/db/provider-catalog-read-ops.ts +8 -0
- package/src/db/provider-catalog-write-ops.ts +16 -0
- package/src/db/provider-config-history.ts +49 -0
- package/src/db/provider-config-secrets.ts +117 -0
- package/src/db/provider-flap-messages-async.ts +6 -0
- package/src/db/provider-flap-messages-write-ops.ts +12 -0
- package/src/db/provider-flap-messages.ts +19 -0
- package/src/db/provider-quota-advisory-types.ts +39 -0
- package/src/db/provider-quota-burn.ts +322 -0
- package/src/db/provider-quota-effect-occurrences.ts +13 -0
- package/src/db/provider-quota-lease-write-ops.ts +23 -0
- package/src/db/provider-quota-leases-async.ts +35 -0
- package/src/db/provider-quota-leases.ts +174 -0
- package/src/db/provider-quota-matrix-cache.ts +85 -0
- package/src/db/provider-quota-matrix-fetch.ts +85 -0
- package/src/db/provider-quota-merge.ts +90 -0
- package/src/db/provider-quota-notification-write.ts +98 -0
- package/src/db/provider-quota-prune.ts +35 -0
- package/src/db/provider-quota-read-async.ts +77 -0
- package/src/db/provider-quota-read-ops.ts +56 -0
- package/src/db/provider-quota-recipients.ts +38 -0
- package/src/db/provider-quota-state.ts +139 -0
- package/src/db/provider-quota-visibility.ts +22 -0
- package/src/db/provider-quota-write-ops.ts +69 -0
- package/src/db/provider-quotas.ts +726 -0
- package/src/db/provider-secret-scrub.ts +64 -0
- package/src/db/provisioning-assets-migration.ts +85 -0
- package/src/db/provisioning-async.ts +116 -0
- package/src/db/provisioning-callmux.ts +184 -0
- package/src/db/provisioning-github-api.ts +16 -0
- package/src/db/provisioning-github-import-target.ts +29 -0
- package/src/db/provisioning-mcp-validation.ts +103 -0
- package/src/db/provisioning-read-ops.ts +23 -0
- package/src/db/provisioning-registry.ts +1122 -0
- package/src/db/provisioning-resolve.ts +321 -0
- package/src/db/provisioning-write-ops.ts +43 -0
- package/src/db/qa-skill-seed.ts +27 -0
- package/src/db/quota-lease-busy.worker.ts +62 -0
- package/src/db/read-op-marshaling-fixtures.ts +724 -0
- package/src/db/read-ops.ts +266 -0
- package/src/db/reader-pool.ts +252 -0
- package/src/db/recipe-read-ops.ts +15 -0
- package/src/db/recipe-write-ops.ts +68 -0
- package/src/db/reply-obligations.ts +265 -0
- package/src/db/report-suppression.ts +126 -0
- package/src/db/restart-epoch-admin-async.ts +14 -0
- package/src/db/restart-epoch-admin.ts +67 -0
- package/src/db/restart-epoch-admission.ts +114 -0
- package/src/db/restart-epoch-async.ts +80 -0
- package/src/db/restart-epoch-begin.ts +177 -0
- package/src/db/restart-epoch-read-ops.ts +40 -0
- package/src/db/restart-epoch-release.ts +248 -0
- package/src/db/restart-epoch-write-ops.ts +117 -0
- package/src/db/restart-epoch.test-fixture.ts +37 -0
- package/src/db/restart-epoch.ts +623 -0
- package/src/db/restart-sensitive.ts +81 -0
- package/src/db/retention.ts +423 -0
- package/src/db/review-ref-cleanups.ts +306 -0
- package/src/db/routing-policy.ts +64 -0
- package/src/db/scheduled-timer-projection.ts +123 -0
- package/src/db/scheduled-timer-quota-chaos-worker.ts +84 -0
- package/src/db/scheduled-timers.ts +521 -0
- package/src/db/schema.ts +1472 -0
- package/src/db/scoped-message-reads.ts +31 -0
- package/src/db/secrets-broker-async.ts +31 -0
- package/src/db/secrets-broker-read-ops.ts +8 -0
- package/src/db/secrets-broker-write-ops.ts +23 -0
- package/src/db/secrets-broker.ts +221 -0
- package/src/db/secrets-vault-import.ts +37 -0
- package/src/db/secrets-vault-key-lifecycle.ts +64 -0
- package/src/db/secrets-vault-metadata.ts +37 -0
- package/src/db/secrets-vault-migration.ts +53 -0
- package/src/db/secrets-vault-write.ts +97 -0
- package/src/db/secrets-vault.ts +69 -0
- package/src/db/self-effort-permissions.ts +50 -0
- package/src/db/service-access-read-ops.ts +10 -0
- package/src/db/services-async.ts +29 -0
- package/src/db/services-read-ops.ts +134 -0
- package/src/db/services-write-ops.ts +71 -0
- package/src/db/shared.ts +7 -0
- package/src/db/shipping-board-async.ts +6 -0
- package/src/db/shipping-board.ts +319 -0
- package/src/db/shipping-stats-async.ts +24 -0
- package/src/db/shipping-stats-histogram.ts +45 -0
- package/src/db/shipping-stats-schema.ts +8 -0
- package/src/db/shipping-stats.ts +265 -0
- package/src/db/snapshot-ledger-prune.ts +53 -0
- package/src/db/spawn-budget.ts +145 -0
- package/src/db/spawn-command-busy.worker.ts +71 -0
- package/src/db/spawn-delegation-state.ts +124 -0
- package/src/db/spawn-delegation.ts +114 -0
- package/src/db/spawn-host-cap.ts +29 -0
- package/src/db/spawn-in-flight-count.ts +37 -0
- package/src/db/spawn-in-flight.ts +15 -0
- package/src/db/spawn-process-evidence.ts +68 -0
- package/src/db/spawn-project-target.ts +57 -0
- package/src/db/spawn-registration-confirmed-backfill.ts +71 -0
- package/src/db/spawn-request-id-migration.ts +36 -0
- package/src/db/spawn-request-id.ts +35 -0
- package/src/db/spawn-request-reuse.ts +28 -0
- package/src/db/spawn-tree-cleanup.ts +89 -0
- package/src/db/spawn-tree.ts +29 -0
- package/src/db/sql-audit-indexes.ts +77 -0
- package/src/db/stalled-message-delivery.ts +52 -0
- package/src/db/startup-write-lock.ts +36 -0
- package/src/db/stats-async.ts +235 -0
- package/src/db/stats-health-read-model.ts +225 -0
- package/src/db/stats-read-ops.ts +25 -0
- package/src/db/stats.ts +633 -0
- package/src/db/target-host.ts +25 -0
- package/src/db/task-async.ts +165 -0
- package/src/db/task-comment-through-async.ts +14 -0
- package/src/db/task-comment-through-read-ops.ts +4 -0
- package/src/db/task-comment-through-write-ops.ts +7 -0
- package/src/db/task-comment-through.ts +123 -0
- package/src/db/task-core.ts +44 -0
- package/src/db/task-deliverables-async.ts +60 -0
- package/src/db/task-deliverables-read-ops.ts +4 -0
- package/src/db/task-deliverables-write-ops.ts +37 -0
- package/src/db/task-deliverables.ts +387 -0
- package/src/db/task-dependency-cycle.worker.ts +43 -0
- package/src/db/task-detail-projection.ts +91 -0
- package/src/db/task-entity-async.ts +252 -0
- package/src/db/task-entity-read-ops.ts +51 -0
- package/src/db/task-entity-write-ops.ts +197 -0
- package/src/db/task-entity.ts +1143 -0
- package/src/db/task-execution.ts +20 -0
- package/src/db/task-issue-relation.ts +23 -0
- package/src/db/task-issue-source.ts +46 -0
- package/src/db/task-land-withdraw-async.ts +10 -0
- package/src/db/task-land-withdraw-read-ops.ts +13 -0
- package/src/db/task-land-withdraw-read.ts +47 -0
- package/src/db/task-land-withdraw-write-ops.ts +31 -0
- package/src/db/task-land-withdraw.ts +423 -0
- package/src/db/task-list.ts +113 -0
- package/src/db/task-maintenance.ts +25 -0
- package/src/db/task-memory-async.ts +19 -0
- package/src/db/task-memory-read-ops.ts +9 -0
- package/src/db/task-memory-write-ops.ts +23 -0
- package/src/db/task-memory.ts +170 -0
- package/src/db/task-owner.ts +126 -0
- package/src/db/task-read-ops.ts +44 -0
- package/src/db/task-review-hold-async.ts +20 -0
- package/src/db/task-review-hold-delivery.ts +58 -0
- package/src/db/task-review-hold-write-ops.ts +26 -0
- package/src/db/task-review-hold.ts +615 -0
- package/src/db/task-state-reconcile-async.ts +12 -0
- package/src/db/task-state-reconcile.ts +163 -0
- package/src/db/task-validation.ts +71 -0
- package/src/db/task-write-ops.ts +145 -0
- package/src/db/tasks.ts +528 -0
- package/src/db/team-epics.ts +37 -0
- package/src/db/team-idle.ts +35 -0
- package/src/db/team-project.ts +69 -0
- package/src/db/team-spawn-delegation-read.ts +36 -0
- package/src/db/team-spawn-delegation.ts +49 -0
- package/src/db/teams-async.ts +58 -0
- package/src/db/teams-read-ops.ts +27 -0
- package/src/db/teams-write-ops.ts +17 -0
- package/src/db/teams.ts +504 -0
- package/src/db/terminal-events.ts +113 -0
- package/src/db/timer-async.ts +523 -0
- package/src/db/timer-cutover-core.ts +545 -0
- package/src/db/timer-cutover-report-read-ops.ts +211 -0
- package/src/db/timer-cutover-write-ops.ts +275 -0
- package/src/db/timer-ingress-payload.ts +160 -0
- package/src/db/timer-ingress-read-ops.ts +39 -0
- package/src/db/timer-ingress-request-keys.ts +282 -0
- package/src/db/timer-ingress-write-ops.ts +145 -0
- package/src/db/timer-ingress.ts +515 -0
- package/src/db/timer-message-cutover.ts +322 -0
- package/src/db/timer-message-fire-deadletter.ts +136 -0
- package/src/db/timer-message-fire.ts +209 -0
- package/src/db/timer-message-flip-chaos-worker.ts +89 -0
- package/src/db/timer-message-flip-consistency.ts +147 -0
- package/src/db/timer-message-flip.ts +676 -0
- package/src/db/timer-message-participant.ts +138 -0
- package/src/db/timer-migrate-input.ts +92 -0
- package/src/db/timer-operator-async.ts +177 -0
- package/src/db/timer-operator-read-ops.ts +21 -0
- package/src/db/timer-operator-stage10.ts +119 -0
- package/src/db/timer-operator-write-ops.ts +102 -0
- package/src/db/timer-operator.ts +393 -0
- package/src/db/timer-read-ops.ts +147 -0
- package/src/db/timer-transfer-errors.ts +10 -0
- package/src/db/timer-transfer-write-ops.ts +39 -0
- package/src/db/timer-verifier-schema.ts +29 -0
- package/src/db/timer-verifier.ts +379 -0
- package/src/db/timer-write-ops.ts +277 -0
- package/src/db/token-db-write-ops.ts +92 -0
- package/src/db/token-standing.ts +84 -0
- package/src/db/token-usage-read-ops.ts +8 -0
- package/src/db/token-usage-write-ops.ts +35 -0
- package/src/db/token-usage.ts +338 -0
- package/src/db/tool-groups-empty-migration.ts +59 -0
- package/src/db/urgent-intake.ts +30 -0
- package/src/db/user-invites.ts +107 -0
- package/src/db/user-settings-read-ops.ts +19 -0
- package/src/db/user-settings-write-ops.ts +42 -0
- package/src/db/users.ts +173 -0
- package/src/db/vault-backup.ts +59 -0
- package/src/db/vault-expiry.ts +71 -0
- package/src/db/vault-health.ts +99 -0
- package/src/db/vault-token-launch.ts +77 -0
- package/src/db/vault-token-ops.ts +14 -0
- package/src/db/vault-tokens.ts +101 -0
- package/src/db/viewer-scope.ts +117 -0
- package/src/db/wal-checkpointer-worker.ts +48 -0
- package/src/db/wal-checkpointer.ts +107 -0
- package/src/db/wal-index.ts +53 -0
- package/src/db/wal-live-log.ts +68 -0
- package/src/db/wal-reclaim-async.ts +45 -0
- package/src/db/wal-reclaim.ts +140 -0
- package/src/db/web-tool-call-ops.ts +15 -0
- package/src/db/web-tool-calls.ts +87 -0
- package/src/db/withdraw-land-error.ts +18 -0
- package/src/db/work-evidence.ts +43 -0
- package/src/db/workflow-budget.ts +44 -0
- package/src/db/workflow-contact.ts +173 -0
- package/src/db/workflow-execution.ts +10 -0
- package/src/db/workflow-journal-async.ts +64 -0
- package/src/db/workflow-journal-prune.ts +71 -0
- package/src/db/workflow-journal-read-ops.ts +21 -0
- package/src/db/workflow-journal-schema.ts +9 -0
- package/src/db/workflow-journal-write-ops.ts +33 -0
- package/src/db/workflow-journal.ts +324 -0
- package/src/db/workflow-spawn-quota.ts +57 -0
- package/src/db/workflow-stats-read-ops.ts +177 -0
- package/src/db/workflow-step-tasks.ts +74 -0
- package/src/db/workflow-task-read-ops.ts +187 -0
- package/src/db/workspace-land-state.ts +65 -0
- package/src/db/workspace-merge-hold.ts +28 -0
- package/src/db/workspace-persistence.ts +77 -0
- package/src/db/workspace-rekey-write-ops.ts +11 -0
- package/src/db/workspace-rekey.ts +148 -0
- package/src/db/workspace-steward-cancel.ts +85 -0
- package/src/db/workspace-steward-fence.ts +30 -0
- package/src/db/workspace-write-ops.ts +26 -0
- package/src/db/workspace-writes-async.ts +46 -0
- package/src/db/workspace-writes.ts +196 -0
- package/src/db/workspaces.ts +617 -0
- package/src/db/write-ops.ts +594 -0
- package/src/db/writer-drain.ts +27 -0
- package/src/db/writer-fault-seam.ts +101 -0
- package/src/db/writer-gateway.ts +840 -0
- package/src/db/writer-ledger.ts +56 -0
- package/src/db.ts +4 -0
- package/src/deploy-executor.ts +139 -0
- package/src/dev.ts +541 -0
- package/src/dispatch-availability.ts +55 -0
- package/src/dispatch-match.ts +21 -0
- package/src/ephemeral/host-landing-slots-proof-worker.ts +45 -0
- package/src/ephemeral/index.ts +58 -0
- package/src/ephemeral/instance.ts +832 -0
- package/src/ephemeral/landing-ingress-proof-worker.ts +30 -0
- package/src/ephemeral/ports.ts +40 -0
- package/src/ephemeral/profile.ts +323 -0
- package/src/ephemeral/rehearsal-stamps.ts +149 -0
- package/src/ephemeral/rehearsal.ts +213 -0
- package/src/ephemeral/snapshot-kernel.ts +41 -0
- package/src/ephemeral/snapshot.ts +753 -0
- package/src/ephemeral/sweep.ts +40 -0
- package/src/event-loop-lag.ts +584 -0
- package/src/event-loop-yield.ts +27 -0
- package/src/events.ts +140 -0
- package/src/execution-mode.ts +63 -0
- package/src/fleet-convergence.ts +123 -0
- package/src/gate-resolver.ts +151 -0
- package/src/gate-run-capture.ts +71 -0
- package/src/git-sha.ts +58 -0
- package/src/guides.ts +73 -0
- package/src/host/capacity.ts +79 -0
- package/src/host/gate-capacity-alert.ts +90 -0
- package/src/host/identity.ts +128 -0
- package/src/host/presentation.ts +234 -0
- package/src/host/pressure-details.ts +89 -0
- package/src/host/pressure.ts +216 -0
- package/src/host/state.ts +132 -0
- package/src/host/utilization-buffer.ts +71 -0
- package/src/host-awareness.ts +57 -0
- package/src/host-identity.ts +39 -0
- package/src/host-provider-enablement.ts +75 -0
- package/src/host-provider-store.ts +102 -0
- package/src/host-tools.ts +39 -0
- package/src/http-body.ts +49 -0
- package/src/http-compression.ts +16 -0
- package/src/hub-metrics-report.ts +67 -0
- package/src/hub-metrics.ts +166 -0
- package/src/idle-digest-config.ts +40 -0
- package/src/idle-self-care.ts +58 -0
- package/src/index.ts +35 -0
- package/src/injection-sweep-pacing.ts +24 -0
- package/src/insights-async.ts +16 -0
- package/src/insights-db.ts +188 -0
- package/src/internal-spawn-model.ts +18 -0
- package/src/invite-link.ts +11 -0
- package/src/issue-tracker/adapter.ts +58 -0
- package/src/issue-tracker/github.ts +342 -0
- package/src/issue-tracker/index.ts +12 -0
- package/src/issue-tracker/registry.ts +26 -0
- package/src/journal-preamble.ts +350 -0
- package/src/kernel-correlation.ts +28 -0
- package/src/land-authorization.ts +73 -0
- package/src/land-block.ts +59 -0
- package/src/land-failure-event-key.ts +8 -0
- package/src/land-gate-failure-routing.ts +69 -0
- package/src/land-gate-notifications.ts +173 -0
- package/src/land-gate-queue-progress.ts +54 -0
- package/src/land-gates-source.ts +126 -0
- package/src/land-gates.ts +29 -0
- package/src/land-lifecycle-drives.ts +15 -0
- package/src/land-settle-dispatch.ts +134 -0
- package/src/land-stack-depth.ts +11 -0
- package/src/land-telemetry.ts +40 -0
- package/src/landing-base-ref.ts +3 -0
- package/src/landing-host-safety.ts +38 -0
- package/src/landing-lane-key.ts +74 -0
- package/src/launch-mode-support.ts +11 -0
- package/src/launch-mode.ts +58 -0
- package/src/legacy-landing.test-fixture.ts +56 -0
- package/src/lifecycle-context-pressure.ts +134 -0
- package/src/lifecycle-manager.ts +831 -0
- package/src/lifecycle-signal-registry.ts +87 -0
- package/src/live-runs-section.ts +38 -0
- package/src/loop-block-attribution.ts +442 -0
- package/src/loop-block-regression-alarm.ts +156 -0
- package/src/loop-task-stamps.ts +62 -0
- package/src/main-thread-clock.ts +95 -0
- package/src/maintenance/agent-identity-archive-job.ts +15 -0
- package/src/maintenance/artifact-checkout-gc-job.ts +14 -0
- package/src/maintenance/artifact-checkout-gc.ts +33 -0
- package/src/maintenance/artifact-sweep.ts +23 -0
- package/src/maintenance/breaker.ts +200 -0
- package/src/maintenance/cd-watcher.ts +176 -0
- package/src/maintenance/checkout-refresh.ts +83 -0
- package/src/maintenance/ci-monitor.ts +14 -0
- package/src/maintenance/claude-api-budget-job.ts +16 -0
- package/src/maintenance/constants.ts +134 -0
- package/src/maintenance/continuation-archive-search-job.ts +27 -0
- package/src/maintenance/critical-job-watchdog.ts +252 -0
- package/src/maintenance/db-planner-stats-job.ts +19 -0
- package/src/maintenance/db-wal-reclaim-job.ts +82 -0
- package/src/maintenance/events.ts +28 -0
- package/src/maintenance/gate-capacity-sample-job.ts +16 -0
- package/src/maintenance/index.ts +10 -0
- package/src/maintenance/jobs.ts +857 -0
- package/src/maintenance/long-running-work.ts +41 -0
- package/src/maintenance/orphaned-sessions.ts +126 -0
- package/src/maintenance/pauses.ts +174 -0
- package/src/maintenance/provider-secret-scrub-job.ts +16 -0
- package/src/maintenance/queued-message-expiration.ts +23 -0
- package/src/maintenance/red-main-controller-job.ts +22 -0
- package/src/maintenance/reply-obligation-parity-job.ts +27 -0
- package/src/maintenance/restart-epoch-hold-health.ts +62 -0
- package/src/maintenance/run-registry.ts +194 -0
- package/src/maintenance/scheduler.ts +778 -0
- package/src/maintenance/service-access-job.ts +31 -0
- package/src/maintenance/shipping-stats-rollup-job.ts +23 -0
- package/src/maintenance/snapshot-ledger-prune-job.ts +17 -0
- package/src/maintenance/stalled-delivery-pager.ts +125 -0
- package/src/maintenance/steward-handback.ts +11 -0
- package/src/maintenance/task-state-reconcile-job.ts +22 -0
- package/src/maintenance/teams.ts +426 -0
- package/src/maintenance/types.ts +124 -0
- package/src/maintenance/vault-backup-job.ts +34 -0
- package/src/maintenance/vault-expiry-job.ts +29 -0
- package/src/maintenance/web-tool-call-prune-job.ts +13 -0
- package/src/maintenance/workflow-backstop-job.ts +12 -0
- package/src/maintenance/workflow-journal-prune-job.ts +29 -0
- package/src/maintenance/workspaces.ts +784 -0
- package/src/maintenance.ts +1 -0
- package/src/managed-policy-escalation.ts +123 -0
- package/src/managed-policy.ts +236 -0
- package/src/managed-provider-gate.ts +27 -0
- package/src/managed-spawn-reservation.ts +23 -0
- package/src/markdown-frontmatter.ts +14 -0
- package/src/mcp/activity-output.ts +57 -0
- package/src/mcp/artifact-upload.ts +53 -0
- package/src/mcp/context-output.ts +73 -0
- package/src/mcp/dispatch-shape-schema.ts +13 -0
- package/src/mcp/guides.ts +33 -0
- package/src/mcp/http.ts +27 -0
- package/src/mcp/identity-projection.ts +121 -0
- package/src/mcp/identity.ts +235 -0
- package/src/mcp/index.ts +355 -0
- package/src/mcp/issue-selector-schema.ts +12 -0
- package/src/mcp/message-read.ts +87 -0
- package/src/mcp/output-descriptions.ts +72 -0
- package/src/mcp/output-levels.ts +71 -0
- package/src/mcp/output-projection.ts +88 -0
- package/src/mcp/plan-presentation.ts +166 -0
- package/src/mcp/presentation-values.ts +11 -0
- package/src/mcp/presentation.ts +653 -0
- package/src/mcp/project-entry-search-schema.ts +7 -0
- package/src/mcp/prompts.ts +36 -0
- package/src/mcp/runtime-output.ts +84 -0
- package/src/mcp/schema-budget.ts +28 -0
- package/src/mcp/self-care-visibility.ts +23 -0
- package/src/mcp/service-access.ts +18 -0
- package/src/mcp/spawn-targets-matrix.ts +68 -0
- package/src/mcp/spawn-targets.test-fixture.ts +21 -0
- package/src/mcp/task-validation-presentation.ts +19 -0
- package/src/mcp/tool-generation.ts +8 -0
- package/src/mcp/tool-groups.ts +136 -0
- package/src/mcp/tools-artifacts.ts +82 -0
- package/src/mcp/tools-messaging.ts +541 -0
- package/src/mcp/tools-permission.ts +88 -0
- package/src/mcp/tools-run.ts +73 -0
- package/src/mcp/tools-scheduler.ts +156 -0
- package/src/mcp/tools-spawn.ts +418 -0
- package/src/mcp/tools-web-tool-calls.ts +28 -0
- package/src/mcp/tools-workspace.ts +260 -0
- package/src/mcp/types.ts +68 -0
- package/src/mcp/validation.ts +66 -0
- package/src/mcp-agent-action.ts +96 -0
- package/src/mcp-agent-keep.ts +37 -0
- package/src/mcp-backlog-tools.ts +137 -0
- package/src/mcp-blackboard-tools.ts +131 -0
- package/src/mcp-channel-binding-tools.ts +27 -0
- package/src/mcp-claude-api-budget.ts +35 -0
- package/src/mcp-codex-reset.ts +43 -0
- package/src/mcp-decision-tools.ts +96 -0
- package/src/mcp-dispatch-tools.ts +142 -0
- package/src/mcp-egress-tools.ts +168 -0
- package/src/mcp-errors.ts +7 -0
- package/src/mcp-host-tools.ts +61 -0
- package/src/mcp-interrupt-agent.ts +47 -0
- package/src/mcp-issue-activity-tools.ts +114 -0
- package/src/mcp-issue-association-tools.ts +103 -0
- package/src/mcp-issue-lifecycle-tools.ts +49 -0
- package/src/mcp-issue-ref-tools.ts +214 -0
- package/src/mcp-maintenance-tools.ts +113 -0
- package/src/mcp-merge-tools.ts +66 -0
- package/src/mcp-notification-subscription-tools.ts +297 -0
- package/src/mcp-output-levels.test-fixture.ts +95 -0
- package/src/mcp-plan-tools.ts +347 -0
- package/src/mcp-profile-trust-tools.ts +47 -0
- package/src/mcp-project-journal-tools.ts +160 -0
- package/src/mcp-project-tools.ts +420 -0
- package/src/mcp-provider-catalog.ts +9 -0
- package/src/mcp-release-tools.ts +33 -0
- package/src/mcp-routing-policy-tools.ts +35 -0
- package/src/mcp-secrets-tools.ts +87 -0
- package/src/mcp-task-deliver-tools.ts +166 -0
- package/src/mcp-task-land-withdraw-tools.ts +49 -0
- package/src/mcp-task-memory-tools.ts +119 -0
- package/src/mcp-task-review-hold-tools.ts +57 -0
- package/src/mcp-task-tools.ts +342 -0
- package/src/mcp-task-validation-tools.ts +30 -0
- package/src/mcp-task-weave-tools.ts +63 -0
- package/src/mcp-team-template-tools.ts +141 -0
- package/src/mcp-team-tools.ts +197 -0
- package/src/mcp-tool-allowlist.ts +88 -0
- package/src/mcp-workflow-tools.ts +158 -0
- package/src/mcp.ts +1 -0
- package/src/memory-admission-rank.ts +55 -0
- package/src/memory-area-injection.ts +216 -0
- package/src/memory-boundary-capture.ts +206 -0
- package/src/memory-entry-safety.ts +28 -0
- package/src/memory-inject-filter.ts +190 -0
- package/src/memory-injection.ts +954 -0
- package/src/memory-preamble-admission.ts +158 -0
- package/src/memory-preamble-async.ts +13 -0
- package/src/memory-preamble.ts +1142 -0
- package/src/memory-retirement.ts +11 -0
- package/src/memory-seam.ts +273 -0
- package/src/memory-tokens.ts +91 -0
- package/src/merge-drain.ts +101 -0
- package/src/merge-pause-maintenance.ts +19 -0
- package/src/message-visibility.ts +50 -0
- package/src/messaging-policy.ts +94 -0
- package/src/native-memory.ts +59 -0
- package/src/notification-prefs.ts +25 -0
- package/src/notification-role-policy.ts +14 -0
- package/src/notification-router.ts +329 -0
- package/src/notification-rules.ts +390 -0
- package/src/notification-settings-store.ts +47 -0
- package/src/notification-settings.ts +166 -0
- package/src/notification-subscription-rules.ts +11 -0
- package/src/notification-types.ts +312 -0
- package/src/notify.ts +55 -0
- package/src/observed-reset-boundary.ts +23 -0
- package/src/observed-reset-refresh.ts +21 -0
- package/src/operator-alarm.ts +41 -0
- package/src/operator-decisions-section.ts +29 -0
- package/src/orchestrator-lookup.ts +29 -0
- package/src/orchestrator-self-report-authz.ts +34 -0
- package/src/package-pack.ts +246 -0
- package/src/post-bind-startup.ts +58 -0
- package/src/process-guard.ts +31 -0
- package/src/profile-cells.ts +305 -0
- package/src/profile-effective-survey.ts +121 -0
- package/src/profile-host-sources.ts +73 -0
- package/src/profile-instruction-blocks.ts +11 -0
- package/src/profile-project-validation.ts +23 -0
- package/src/profile-provider-options.ts +59 -0
- package/src/profile-role-templates.ts +26 -0
- package/src/profile-workflow-policy.ts +14 -0
- package/src/project-claudemd-sweep.ts +176 -0
- package/src/project-file-source.ts +54 -0
- package/src/project-ingest.ts +195 -0
- package/src/project-instructions.ts +700 -0
- package/src/project-mcp.ts +18 -0
- package/src/project-role-assets.ts +109 -0
- package/src/project-roles-validate.ts +53 -0
- package/src/project-roles.ts +364 -0
- package/src/project-settings.ts +5 -0
- package/src/project-skills.ts +5 -0
- package/src/project-toolchain.ts +58 -0
- package/src/project-trust-fingerprint.ts +174 -0
- package/src/project-trust.ts +262 -0
- package/src/project-workflows.ts +185 -0
- package/src/prompt-resolver.ts +697 -0
- package/src/prompt-template-fallback.ts +15 -0
- package/src/prompt-version-errors.ts +13 -0
- package/src/provider-catalog-store.ts +393 -0
- package/src/provider-config-store.ts +308 -0
- package/src/provider-enablement.ts +36 -0
- package/src/provider-home-gc.ts +58 -0
- package/src/provider-model-seed.ts +18 -0
- package/src/provider-quota-async.ts +152 -0
- package/src/provider-quota-config-store.ts +60 -0
- package/src/provider-secrets.test-fixture.ts +34 -0
- package/src/provider-state.ts +93 -0
- package/src/provider-timeline-event.ts +76 -0
- package/src/quota-advisory.ts +359 -0
- package/src/quota-band-delivery.ts +13 -0
- package/src/quota-band-projection.ts +149 -0
- package/src/quota-band-transition.ts +316 -0
- package/src/quota-pacing.ts +46 -0
- package/src/quota-threshold-config.ts +46 -0
- package/src/quota.ts +61 -0
- package/src/ratchet-files.ts +202 -0
- package/src/recipe-async.ts +50 -0
- package/src/recipe-db.ts +260 -0
- package/src/recipe-loader.ts +132 -0
- package/src/recipe-runner.ts +259 -0
- package/src/recipe-validator.ts +107 -0
- package/src/relay-event-drain.ts +39 -0
- package/src/relay-host-locality.ts +20 -0
- package/src/relay-run-lease.ts +17 -0
- package/src/repo-config-source.ts +209 -0
- package/src/report-verbosity.ts +5 -0
- package/src/restart-epoch-deploy-hold.ts +221 -0
- package/src/retention-config-store.ts +32 -0
- package/src/retention-config.ts +70 -0
- package/src/reviewer-pipeline.ts +238 -0
- package/src/routes/_route.ts +70 -0
- package/src/routes/_shared.ts +513 -0
- package/src/routes/activity.ts +70 -0
- package/src/routes/agent-effort.ts +69 -0
- package/src/routes/agent-keep.ts +27 -0
- package/src/routes/agent-profiles.ts +169 -0
- package/src/routes/agent-reporting.ts +19 -0
- package/src/routes/agent-self-effort.ts +51 -0
- package/src/routes/agent-sessions.ts +650 -0
- package/src/routes/agent-sharing.ts +23 -0
- package/src/routes/agents-spawn.ts +258 -0
- package/src/routes/agents.ts +452 -0
- package/src/routes/artifacts.ts +340 -0
- package/src/routes/auth.ts +123 -0
- package/src/routes/authority-audit.ts +14 -0
- package/src/routes/automations.ts +83 -0
- package/src/routes/backlog.ts +112 -0
- package/src/routes/blackboard.ts +54 -0
- package/src/routes/browser.ts +73 -0
- package/src/routes/channel-binding-delete.ts +21 -0
- package/src/routes/channel-output.ts +17 -0
- package/src/routes/claude-api-budget.ts +65 -0
- package/src/routes/commands-listing.ts +50 -0
- package/src/routes/commands.ts +586 -0
- package/src/routes/config.ts +75 -0
- package/src/routes/connectors.ts +108 -0
- package/src/routes/context-resets.ts +35 -0
- package/src/routes/continuation-archives.ts +37 -0
- package/src/routes/coordinator-teams.ts +14 -0
- package/src/routes/decisions.ts +82 -0
- package/src/routes/deploys.ts +15 -0
- package/src/routes/fleet-convergence.ts +5 -0
- package/src/routes/guides.ts +13 -0
- package/src/routes/host-providers.ts +73 -0
- package/src/routes/host-resource-control.ts +45 -0
- package/src/routes/host-secret-files.ts +38 -0
- package/src/routes/hosts.ts +240 -0
- package/src/routes/inbox.ts +151 -0
- package/src/routes/index.ts +614 -0
- package/src/routes/insights.ts +86 -0
- package/src/routes/integrations.ts +636 -0
- package/src/routes/issue-activity.ts +78 -0
- package/src/routes/issue-associations.ts +76 -0
- package/src/routes/issue-lifecycle.ts +34 -0
- package/src/routes/issue-refs.ts +163 -0
- package/src/routes/kernel-timers-operator.ts +57 -0
- package/src/routes/memory.ts +25 -0
- package/src/routes/merges.ts +109 -0
- package/src/routes/message-viewer.ts +4 -0
- package/src/routes/messages.ts +621 -0
- package/src/routes/notifications.ts +36 -0
- package/src/routes/orchestrator-bootstrap.ts +101 -0
- package/src/routes/orchestrator-host-registration.ts +125 -0
- package/src/routes/orchestrator-host-utilization.ts +255 -0
- package/src/routes/orchestrator-proxy.ts +174 -0
- package/src/routes/orchestrator.ts +699 -0
- package/src/routes/pairs.ts +214 -0
- package/src/routes/plans.ts +98 -0
- package/src/routes/project-onboarding.ts +56 -0
- package/src/routes/project-trust.ts +73 -0
- package/src/routes/projects.ts +296 -0
- package/src/routes/prompt-templates.ts +106 -0
- package/src/routes/provider-config.ts +232 -0
- package/src/routes/provider-quota-config.ts +48 -0
- package/src/routes/provider-quotas.ts +312 -0
- package/src/routes/provisioning-registry.ts +192 -0
- package/src/routes/recipes.ts +129 -0
- package/src/routes/restart-epochs.ts +98 -0
- package/src/routes/routing-policy.ts +30 -0
- package/src/routes/run-command.ts +25 -0
- package/src/routes/secrets-backup.ts +53 -0
- package/src/routes/secrets-import.ts +32 -0
- package/src/routes/secrets-page.ts +98 -0
- package/src/routes/secrets-vault.ts +121 -0
- package/src/routes/secrets.ts +165 -0
- package/src/routes/service-access.ts +57 -0
- package/src/routes/settings.ts +191 -0
- package/src/routes/shipping.ts +56 -0
- package/src/routes/spawn-policy.ts +299 -0
- package/src/routes/spec.ts +58 -0
- package/src/routes/sse.ts +18 -0
- package/src/routes/stats.ts +159 -0
- package/src/routes/steward.ts +49 -0
- package/src/routes/task-graph.ts +30 -0
- package/src/routes/task-http.ts +27 -0
- package/src/routes/task-issues.ts +81 -0
- package/src/routes/task-reads.ts +139 -0
- package/src/routes/task-validation.ts +22 -0
- package/src/routes/tasks.ts +553 -0
- package/src/routes/team-templates.ts +65 -0
- package/src/routes/teams-config.ts +15 -0
- package/src/routes/teams.ts +141 -0
- package/src/routes/token-usage.ts +167 -0
- package/src/routes/tokens.ts +393 -0
- package/src/routes/users.ts +248 -0
- package/src/routes/viewer-read.ts +27 -0
- package/src/routes/web-tool-calls.ts +38 -0
- package/src/routes/workflows.ts +142 -0
- package/src/routes/workspaces.ts +642 -0
- package/src/routes.ts +3 -0
- package/src/routing-eligibility.ts +42 -0
- package/src/routing-model-aliases.ts +21 -0
- package/src/routing-policy-normalize.ts +412 -0
- package/src/routing-policy-push.ts +154 -0
- package/src/routing-policy-service.ts +19 -0
- package/src/routing-policy-store.ts +16 -0
- package/src/routing-preferences.ts +82 -0
- package/src/routing-step-defaults.ts +31 -0
- package/src/runtime-grant.ts +164 -0
- package/src/runtime-prefix.ts +8 -0
- package/src/runtime-tokens.ts +395 -0
- package/src/search-query.ts +10 -0
- package/src/secret-keys.ts +24 -0
- package/src/secrets-broker/config.ts +53 -0
- package/src/secrets-broker/error.ts +8 -0
- package/src/secrets-broker/infisical.ts +259 -0
- package/src/secrets-broker/reader-infisical.ts +41 -0
- package/src/secrets-broker/reader.ts +101 -0
- package/src/secrets-broker/service.ts +242 -0
- package/src/secrets-broker/tool-credentials.ts +9 -0
- package/src/secrets-vault/backend-conformance.ts +26 -0
- package/src/secrets-vault/backend.ts +102 -0
- package/src/secrets-vault/backup.ts +103 -0
- package/src/secrets-vault/config.ts +7 -0
- package/src/secrets-vault/expiry.ts +10 -0
- package/src/secrets-vault/identity.ts +27 -0
- package/src/secrets-vault/import.ts +90 -0
- package/src/secrets-vault/key-files.ts +91 -0
- package/src/secrets-vault/keys.ts +79 -0
- package/src/secrets-vault/metadata.ts +51 -0
- package/src/secrets-vault/provider-env.ts +25 -0
- package/src/secrets-vault/resolve.ts +101 -0
- package/src/secrets-vault/restore.ts +57 -0
- package/src/secrets-vault/scope.ts +25 -0
- package/src/secrets-vault/service.ts +192 -0
- package/src/secrets-vault/shared.ts +10 -0
- package/src/security.ts +772 -0
- package/src/self-effort-rule.ts +36 -0
- package/src/self-resume-carry.ts +131 -0
- package/src/self-resume-command.ts +24 -0
- package/src/self-resume-config.ts +54 -0
- package/src/self-resume-identity.ts +40 -0
- package/src/self-resume-supersede.ts +19 -0
- package/src/self-resume.ts +884 -0
- package/src/server-background.ts +24 -0
- package/src/server.ts +726 -0
- package/src/service-access/config.ts +3 -0
- package/src/service-access/health.ts +151 -0
- package/src/service-access/host-health.ts +62 -0
- package/src/service-access/host.ts +63 -0
- package/src/service-access/operations.ts +21 -0
- package/src/service-access/policy.ts +30 -0
- package/src/service-access/probe.ts +62 -0
- package/src/service-access/request-logs.ts +93 -0
- package/src/service-access/scope.ts +7 -0
- package/src/service-access/service.ts +185 -0
- package/src/service-access/tokens.ts +174 -0
- package/src/service-access/validation.ts +75 -0
- package/src/service-access/vault.ts +59 -0
- package/src/services/agent-action.ts +238 -0
- package/src/services/agent-control-host.ts +74 -0
- package/src/services/agent-effort.ts +60 -0
- package/src/services/agent-hang-watchdog-job.ts +513 -0
- package/src/services/agent-hang-watchdog-wiring.ts +487 -0
- package/src/services/agent-hang-watchdog.ts +395 -0
- package/src/services/agent-keep.ts +72 -0
- package/src/services/agent-message-fanout.ts +91 -0
- package/src/services/agent-outstanding-work.ts +66 -0
- package/src/services/agent-reporting.ts +27 -0
- package/src/services/artifact-access.ts +39 -0
- package/src/services/artifact-multipart.ts +70 -0
- package/src/services/artifact-path-host.ts +55 -0
- package/src/services/artifact-read.ts +88 -0
- package/src/services/artifact-write.ts +25 -0
- package/src/services/auth-context.ts +117 -0
- package/src/services/automatic-disposal.ts +33 -0
- package/src/services/backlog.ts +149 -0
- package/src/services/browser-inventory.ts +52 -0
- package/src/services/browser-session-state.ts +41 -0
- package/src/services/browser-session.ts +167 -0
- package/src/services/bus-command-update.ts +84 -0
- package/src/services/bus-expiration-death.ts +57 -0
- package/src/services/canonical-root.ts +284 -0
- package/src/services/captured-delivery-gate.ts +12 -0
- package/src/services/carry-pending.ts +5 -0
- package/src/services/channel-binding-delete.ts +20 -0
- package/src/services/channel-suppression-receipt.ts +28 -0
- package/src/services/checkout-refresh-state.ts +18 -0
- package/src/services/checkout-refresh.test-fixture.ts +12 -0
- package/src/services/child-work-evidence.ts +77 -0
- package/src/services/claude-app.ts +91 -0
- package/src/services/command-claim-rejection.ts +23 -0
- package/src/services/command-host.ts +42 -0
- package/src/services/coordinator-digest.ts +30 -0
- package/src/services/decision-audience.ts +26 -0
- package/src/services/delivery-gate-policy.ts +98 -0
- package/src/services/delivery-tip.test-fixture.ts +25 -0
- package/src/services/diff-gate.ts +110 -0
- package/src/services/dispatch-command.ts +388 -0
- package/src/services/effective-launch-driver.ts +240 -0
- package/src/services/effective-launch-harness.ts +257 -0
- package/src/services/errors.ts +31 -0
- package/src/services/git-process.ts +176 -0
- package/src/services/git-remote.ts +100 -0
- package/src/services/harness-subagents.ts +12 -0
- package/src/services/host-changed-paths.test-fixture.ts +134 -0
- package/src/services/host-landing-placement.ts +65 -0
- package/src/services/host-project-readiness.ts +49 -0
- package/src/services/host-providers.ts +114 -0
- package/src/services/host-utilization.ts +70 -0
- package/src/services/idle-agent-digest.ts +318 -0
- package/src/services/idle-epics.ts +105 -0
- package/src/services/idle-self-care.ts +47 -0
- package/src/services/interrupt-agent.ts +146 -0
- package/src/services/isolated-workspace-placement.ts +258 -0
- package/src/services/issue-activity.ts +23 -0
- package/src/services/issue-associations.ts +72 -0
- package/src/services/issue-completion-drain.ts +24 -0
- package/src/services/issue-completion.ts +24 -0
- package/src/services/issue-lifecycle-comments.ts +12 -0
- package/src/services/issue-lifecycle.ts +620 -0
- package/src/services/issue-refs.ts +65 -0
- package/src/services/kernel-command-bridge.ts +219 -0
- package/src/services/kernel-control-host.ts +78 -0
- package/src/services/kernel-control-http.ts +119 -0
- package/src/services/kernel-control-mcp.ts +193 -0
- package/src/services/kernel-landing-command.ts +28 -0
- package/src/services/kernel-landing-ingress.ts +65 -0
- package/src/services/kernel-timers-authoritative-ingress.ts +48 -0
- package/src/services/kernel-timers-authz.ts +229 -0
- package/src/services/kernel-timers-command.ts +182 -0
- package/src/services/kernel-timers-cutover-chaos-worker.ts +209 -0
- package/src/services/kernel-timers-cutover.ts +39 -0
- package/src/services/kernel-timers-ingress-apply.ts +39 -0
- package/src/services/kernel-timers-ingress-chaos-worker.ts +312 -0
- package/src/services/kernel-timers-ingress.ts +702 -0
- package/src/services/kernel-timers-message-authority-chaos-worker.ts +97 -0
- package/src/services/kernel-timers-migrate.ts +158 -0
- package/src/services/kernel-timers-operator-chaos-worker.ts +259 -0
- package/src/services/kernel-timers-operator-preflight.ts +18 -0
- package/src/services/kernel-timers-operator.ts +424 -0
- package/src/services/kernel-timers-outbox.ts +138 -0
- package/src/services/kernel-timers-request-key-migration-chaos-worker.ts +77 -0
- package/src/services/kernel-timers-stage10-operator.ts +210 -0
- package/src/services/kernel-timers-stage10.ts +85 -0
- package/src/services/kernel-timers-stage9.ts +57 -0
- package/src/services/kernel-timers-transfer-chaos-worker.ts +118 -0
- package/src/services/kernel-timers-transfer.ts +525 -0
- package/src/services/kernel-timers-verifier.ts +39 -0
- package/src/services/kernel-timers.ts +247 -0
- package/src/services/land-boundary-settle.ts +32 -0
- package/src/services/land-gate-placement.ts +60 -0
- package/src/services/land-issue-relations.ts +46 -0
- package/src/services/land-restart-retry.ts +77 -0
- package/src/services/landed-ancestry.ts +417 -0
- package/src/services/landed-task-attribution.ts +14 -0
- package/src/services/landing-terminal-report.ts +119 -0
- package/src/services/legacy-landing-backfill.ts +159 -0
- package/src/services/legacy-landing-host.ts +291 -0
- package/src/services/legacy-landing-publication.ts +35 -0
- package/src/services/legacy-landing-recovery.ts +111 -0
- package/src/services/macos-privacy.ts +34 -0
- package/src/services/managed-running.ts +189 -0
- package/src/services/memory-areas.ts +172 -0
- package/src/services/memory-identity.ts +162 -0
- package/src/services/merge-pause.ts +37 -0
- package/src/services/message-delivery-actions.ts +11 -0
- package/src/services/operator-decisions.ts +260 -0
- package/src/services/orchestrator-landing-recovery.ts +55 -0
- package/src/services/orchestrator-registration-recovery.ts +12 -0
- package/src/services/orchestrator-upgrade.ts +83 -0
- package/src/services/parity-harness.ts +141 -0
- package/src/services/permission-decision.ts +129 -0
- package/src/services/plan-ci-recovery.ts +76 -0
- package/src/services/plan-conformance.ts +105 -0
- package/src/services/plan-dispatch-policy.ts +79 -0
- package/src/services/plan-dispatch.ts +372 -0
- package/src/services/plan-external-view.ts +7 -0
- package/src/services/plan-frontier.ts +34 -0
- package/src/services/plan-graph.ts +703 -0
- package/src/services/plan-import.ts +66 -0
- package/src/services/plan-live-bindings.ts +139 -0
- package/src/services/plan-task-create.ts +80 -0
- package/src/services/plan-terminal-refs.ts +83 -0
- package/src/services/plan-wake-digest.ts +88 -0
- package/src/services/plan-wake-policy.ts +12 -0
- package/src/services/profile-trust.ts +54 -0
- package/src/services/project-checkout-binding.ts +65 -0
- package/src/services/project-checkout-enrollment.ts +27 -0
- package/src/services/project-cwd.ts +41 -0
- package/src/services/project-onboarding.ts +165 -0
- package/src/services/project-repo-create.ts +27 -0
- package/src/services/project-role.test-fixture.ts +74 -0
- package/src/services/project.ts +191 -0
- package/src/services/prompt-templates.ts +46 -0
- package/src/services/prompt-version-writer.ts +42 -0
- package/src/services/provider-catalog.ts +7 -0
- package/src/services/provider-hold-flap.ts +130 -0
- package/src/services/provider-hold-nudge.ts +191 -0
- package/src/services/provider-hold-record.ts +137 -0
- package/src/services/provider-state-audit.ts +214 -0
- package/src/services/provisioning-harness/analyze.ts +285 -0
- package/src/services/provisioning-harness/budget-baseline.json +391 -0
- package/src/services/provisioning-harness/capture.ts +197 -0
- package/src/services/provisioning-harness/config.ts +55 -0
- package/src/services/provisioning-harness/context-sources.ts +85 -0
- package/src/services/provisioning-harness/driver.ts +156 -0
- package/src/services/provisioning-harness/expect.ts +81 -0
- package/src/services/provisioning-harness/fixture-matrix.ts +38 -0
- package/src/services/provisioning-harness/fixtures/project/.agent-relay/land-gates.json +1 -0
- package/src/services/provisioning-harness/fixtures/project/.claude/skills/harness-skill/SKILL.md +6 -0
- package/src/services/provisioning-harness/fixtures/project/.mcp.json +1 -0
- package/src/services/provisioning-harness/fixtures/project/AGENTS.md +1 -0
- package/src/services/provisioning-harness/fixtures/project/CLAUDE.md +1 -0
- package/src/services/provisioning-harness/fixtures/project/mcp-server.ts +33 -0
- package/src/services/provisioning-harness/fixtures/provider-home/AGENTS.md +1 -0
- package/src/services/provisioning-harness/fixtures/provider-home/CLAUDE.md +1 -0
- package/src/services/provisioning-harness/host-fixtures.ts +25 -0
- package/src/services/provisioning-harness/index.ts +4 -0
- package/src/services/provisioning-harness/inventory-types.ts +8 -0
- package/src/services/provisioning-harness/inventory.ts +33 -0
- package/src/services/provisioning-harness/lifecycle.ts +193 -0
- package/src/services/provisioning-harness/live.ts +61 -0
- package/src/services/provisioning-harness/manifests.ts +118 -0
- package/src/services/provisioning-harness/prepare.ts +113 -0
- package/src/services/provisioning-harness/redundancy-report.ts +32 -0
- package/src/services/provisioning-harness/redundancy.ts +137 -0
- package/src/services/provisioning-harness/report.ts +129 -0
- package/src/services/provisioning-harness/types.ts +174 -0
- package/src/services/provisioning-registry.ts +15 -0
- package/src/services/rate-limit-resume.ts +220 -0
- package/src/services/reap-verdict.ts +52 -0
- package/src/services/red-main-auto-revert.ts +103 -0
- package/src/services/red-main-controller-deps.ts +80 -0
- package/src/services/red-main-controller.ts +262 -0
- package/src/services/red-main-incident.ts +44 -0
- package/src/services/red-main-quarantine.ts +92 -0
- package/src/services/register-agent.ts +447 -0
- package/src/services/release-readiness.ts +219 -0
- package/src/services/reported-exit-death.ts +29 -0
- package/src/services/response-report-admission.ts +17 -0
- package/src/services/restart-epoch-driver.ts +290 -0
- package/src/services/restart-epoch-reconciler.ts +326 -0
- package/src/services/restart-epoch-stale-command-recovery.ts +133 -0
- package/src/services/restart-instructions.ts +86 -0
- package/src/services/restart-project-role.ts +74 -0
- package/src/services/restart-secret-refs.ts +14 -0
- package/src/services/restart-spawn.ts +510 -0
- package/src/services/review-publish.ts +76 -0
- package/src/services/review-ref-reconcile.ts +337 -0
- package/src/services/run-command-input.ts +22 -0
- package/src/services/run-command.ts +510 -0
- package/src/services/run-completion-message.ts +70 -0
- package/src/services/run-log.ts +212 -0
- package/src/services/run-queue.ts +63 -0
- package/src/services/scheduler-command-cancel.ts +49 -0
- package/src/services/scheduler-command.ts +590 -0
- package/src/services/scheduler-create.ts +25 -0
- package/src/services/scheduler-plan.ts +202 -0
- package/src/services/scheduler-recovery.ts +31 -0
- package/src/services/scheduler.ts +406 -0
- package/src/services/self-care-state.ts +10 -0
- package/src/services/self-effort-grant.ts +93 -0
- package/src/services/self-effort.ts +152 -0
- package/src/services/send-message.ts +548 -0
- package/src/services/server-credentials.ts +53 -0
- package/src/services/shipping-board.ts +111 -0
- package/src/services/shipping-project-config.ts +86 -0
- package/src/services/shipping-stats.ts +86 -0
- package/src/services/shutdown-agent.ts +463 -0
- package/src/services/shutdown-watchdog.ts +119 -0
- package/src/services/spawn-agent.ts +967 -0
- package/src/services/spawn-approval.ts +26 -0
- package/src/services/spawn-brief.ts +39 -0
- package/src/services/spawn-chain-inspector.ts +286 -0
- package/src/services/spawn-cwd-placement.ts +250 -0
- package/src/services/spawn-identity.ts +127 -0
- package/src/services/spawn-instruction-inputs.ts +114 -0
- package/src/services/spawn-issue-activity.ts +102 -0
- package/src/services/spawn-launch-decision.ts +32 -0
- package/src/services/spawn-launch.ts +116 -0
- package/src/services/spawn-loss-escalation.ts +253 -0
- package/src/services/spawn-placement.test-fixture.ts +30 -0
- package/src/services/spawn-project-role.ts +133 -0
- package/src/services/spawn-registration-watchdog.ts +352 -0
- package/src/services/spawn-replay.ts +61 -0
- package/src/services/spawn-repo-probe.ts +118 -0
- package/src/services/spawn-tree-cleanup.ts +37 -0
- package/src/services/spawn-warnings.ts +13 -0
- package/src/services/steward-reaper.ts +244 -0
- package/src/services/task-context-hydration.ts +413 -0
- package/src/services/task-delivery-close.ts +26 -0
- package/src/services/task-delivery-event.ts +11 -0
- package/src/services/task-delivery-land-policy.ts +35 -0
- package/src/services/task-delivery-summary.ts +38 -0
- package/src/services/task-delivery.ts +762 -0
- package/src/services/task-dependency-graph.ts +116 -0
- package/src/services/task-dispatch.ts +178 -0
- package/src/services/task-done-when.ts +45 -0
- package/src/services/task-entity.ts +758 -0
- package/src/services/task-from-issue.ts +80 -0
- package/src/services/task-issue-digest.ts +45 -0
- package/src/services/task-issue-link.ts +158 -0
- package/src/services/task-issue-weave.ts +570 -0
- package/src/services/task-land-withdraw.ts +462 -0
- package/src/services/task-lifecycle.ts +668 -0
- package/src/services/task-nothing-to-land.ts +37 -0
- package/src/services/task-plan-view.ts +172 -0
- package/src/services/task-review-hold.ts +244 -0
- package/src/services/task-semantic-events.ts +396 -0
- package/src/services/task-stage-wake.ts +15 -0
- package/src/services/task-state-reconcile.ts +169 -0
- package/src/services/task-validation.ts +42 -0
- package/src/services/team-claim-race.worker.ts +72 -0
- package/src/services/team-spawn-delegation.ts +30 -0
- package/src/services/team-templates.ts +172 -0
- package/src/services/team.ts +320 -0
- package/src/services/terminal-provider-exit.ts +57 -0
- package/src/services/timer-message-fire-chaos-worker.ts +29 -0
- package/src/services/timer-message-fire-outbox.ts +184 -0
- package/src/services/transient-agent-reaper.ts +412 -0
- package/src/services/turn-reconcile-audit.ts +236 -0
- package/src/services/user-onboarding.ts +98 -0
- package/src/services/user-profile.ts +57 -0
- package/src/services/web-search.ts +83 -0
- package/src/services/web-tool-calls.ts +65 -0
- package/src/services/withdraw-steward.ts +57 -0
- package/src/services/work-finality.ts +34 -0
- package/src/services/workflow-agent-obligation.ts +35 -0
- package/src/services/workflow-auto-start.ts +126 -0
- package/src/services/workflow-backstop.ts +38 -0
- package/src/services/workflow-budget.test-fixture.ts +10 -0
- package/src/services/workflow-caller.ts +32 -0
- package/src/services/workflow-catalog.ts +43 -0
- package/src/services/workflow-child-proof-worker.ts +76 -0
- package/src/services/workflow-child.test-fixture.ts +51 -0
- package/src/services/workflow-ci-main.ts +93 -0
- package/src/services/workflow-control-proof-worker.ts +149 -0
- package/src/services/workflow-coordinator-decision-proof-worker.ts +123 -0
- package/src/services/workflow-coordinator.ts +8 -0
- package/src/services/workflow-decision-answer.ts +18 -0
- package/src/services/workflow-decision-proof-worker.ts +92 -0
- package/src/services/workflow-decision.test-fixture.ts +58 -0
- package/src/services/workflow-decisions.ts +107 -0
- package/src/services/workflow-deferred-cleanup.ts +40 -0
- package/src/services/workflow-dispatch-result.ts +20 -0
- package/src/services/workflow-effect-driver.ts +165 -0
- package/src/services/workflow-effects.ts +544 -0
- package/src/services/workflow-foreach-proof-worker.ts +209 -0
- package/src/services/workflow-land-notice.ts +18 -0
- package/src/services/workflow-land.ts +105 -0
- package/src/services/workflow-notice.ts +32 -0
- package/src/services/workflow-overdue-notice.ts +19 -0
- package/src/services/workflow-pins.ts +162 -0
- package/src/services/workflow-reconcile.ts +210 -0
- package/src/services/workflow-resume-pins.ts +30 -0
- package/src/services/workflow-run-chaos-worker.ts +67 -0
- package/src/services/workflow-run-view.ts +71 -0
- package/src/services/workflow-run.test-fixture.ts +165 -0
- package/src/services/workflow-runs.ts +370 -0
- package/src/services/workflow-scripts.ts +100 -0
- package/src/services/workflow-slice-proof.ts +14 -0
- package/src/services/workflow-stats.ts +208 -0
- package/src/services/workflow-supervisor-state.ts +117 -0
- package/src/services/workflow-supervisor.ts +122 -0
- package/src/services/workflow-verification.ts +68 -0
- package/src/services/workspace-recovery.ts +168 -0
- package/src/services/workspace-task-binding.ts +22 -0
- package/src/settings/modules.ts +149 -0
- package/src/settings/registry.ts +629 -0
- package/src/settings/user-settings.ts +81 -0
- package/src/setup.ts +199 -0
- package/src/shared-mcp.ts +87 -0
- package/src/shutdown.ts +33 -0
- package/src/spawn-admission.ts +48 -0
- package/src/spawn-budget.ts +18 -0
- package/src/spawn-command.ts +373 -0
- package/src/spawn-env.ts +27 -0
- package/src/spawn-intent.ts +17 -0
- package/src/spawn-lease.ts +41 -0
- package/src/spawn-models.ts +22 -0
- package/src/spawn-placement.ts +348 -0
- package/src/spawn-profile-errors.ts +9 -0
- package/src/spawn-quota.ts +15 -0
- package/src/spawn-targets.ts +679 -0
- package/src/sse-agent-status.ts +35 -0
- package/src/sse-outbox-cursor.ts +28 -0
- package/src/sse-visibility.ts +36 -0
- package/src/sse.ts +684 -0
- package/src/startup-context-injection.ts +518 -0
- package/src/startup-timing.ts +30 -0
- package/src/state-adoption/artifacts.ts +27 -0
- package/src/state-adoption/cd-cutover.ts +125 -0
- package/src/state-adoption/files.ts +31 -0
- package/src/state-adoption/index.ts +166 -0
- package/src/state-adoption/linux-plan.ts +67 -0
- package/src/state-adoption/linux.ts +104 -0
- package/src/state-adoption/macos-plan.ts +58 -0
- package/src/state-adoption/macos.ts +112 -0
- package/src/steward-claim-release.ts +38 -0
- package/src/steward-handoff.ts +28 -0
- package/src/steward-identity.ts +54 -0
- package/src/steward-policy-cleanup.ts +222 -0
- package/src/steward-policy-model-reconcile.ts +33 -0
- package/src/steward-policy-name.ts +13 -0
- package/src/steward-provenance.ts +59 -0
- package/src/steward-queue.ts +85 -0
- package/src/steward-slot-recovery.ts +34 -0
- package/src/steward-spawn-guard.ts +344 -0
- package/src/steward.test-fixture.ts +11 -0
- package/src/steward.ts +199 -0
- package/src/stream-proxy.ts +84 -0
- package/src/task-authz.ts +40 -0
- package/src/task-completion.ts +39 -0
- package/src/task-dispatch-live.ts +70 -0
- package/src/task-dispatcher-ranking.ts +136 -0
- package/src/task-dispatcher.ts +841 -0
- package/src/task-owner-notices.ts +35 -0
- package/src/task-owner.ts +63 -0
- package/src/task-plan-status.ts +21 -0
- package/src/task-verification.ts +35 -0
- package/src/team-idle-tracker.ts +39 -0
- package/src/team-template-config.ts +100 -0
- package/src/teams-config-store.ts +22 -0
- package/src/terminal-authz.ts +49 -0
- package/src/token-db-write.ts +44 -0
- package/src/token-db.ts +487 -0
- package/src/token-usage-async.ts +40 -0
- package/src/transport-subscriptions.ts +57 -0
- package/src/types.ts +1 -0
- package/src/upgrade-install-verify.ts +179 -0
- package/src/upgrade-local-id.ts +3 -0
- package/src/upgrade-services.ts +125 -0
- package/src/upgrade.ts +1006 -0
- package/src/user-awaiting-reply.ts +42 -0
- package/src/user-path.ts +246 -0
- package/src/user-settings-async.ts +33 -0
- package/src/user-settings-store.ts +106 -0
- package/src/user-style.ts +83 -0
- package/src/utils.ts +42 -0
- package/src/validation.ts +324 -0
- package/src/vault-backup-config.ts +28 -0
- package/src/vault-expiry-config.ts +12 -0
- package/src/versioned-prompts.ts +57 -0
- package/src/workflow-capabilities.ts +10 -0
- package/src/workflow-prompt-templates.ts +20 -0
- package/src/workspace-action-audit.ts +42 -0
- package/src/workspace-actions.ts +689 -0
- package/src/workspace-auto-merge.ts +1055 -0
- package/src/workspace-changed-paths-client.ts +97 -0
- package/src/workspace-claim.ts +45 -0
- package/src/workspace-cleanup-settle.ts +51 -0
- package/src/workspace-cleanup-stale.ts +231 -0
- package/src/workspace-command-settle.ts +589 -0
- package/src/workspace-config.ts +7 -0
- package/src/workspace-conflict-resolver.ts +182 -0
- package/src/workspace-dead-owner-recovery.ts +19 -0
- package/src/workspace-delivery-tip.ts +51 -0
- package/src/workspace-escalation.ts +107 -0
- package/src/workspace-git-state-client.ts +42 -0
- package/src/workspace-host-client.ts +86 -0
- package/src/workspace-host-target.ts +5 -0
- package/src/workspace-host.ts +61 -0
- package/src/workspace-human-escalation.ts +70 -0
- package/src/workspace-land-gate-watchdog.ts +76 -0
- package/src/workspace-land-gate.ts +99 -0
- package/src/workspace-land-result.ts +12 -0
- package/src/workspace-land-retry.ts +82 -0
- package/src/workspace-land-stopped.ts +57 -0
- package/src/workspace-merge-dispatch.ts +27 -0
- package/src/workspace-merge-progress.ts +369 -0
- package/src/workspace-merge-retry-policy.ts +59 -0
- package/src/workspace-merge.ts +614 -0
- package/src/workspace-nothing-to-land-notice.ts +27 -0
- package/src/workspace-orphans.ts +927 -0
- package/src/workspace-phase.ts +507 -0
- package/src/workspace-pr-completion.ts +285 -0
- package/src/workspace-probe.ts +212 -0
- package/src/workspace-recorded-land.ts +47 -0
- package/src/workspace-recovery-authz.ts +88 -0
- package/src/workspace-rekey.ts +106 -0
- package/src/workspace-steward-authority.ts +16 -0
- package/src/workspace-steward-failure.ts +42 -0
- package/src/workspace-steward-wake.ts +150 -0
- package/src/workspace-steward-watchdog.ts +240 -0
package/src/db/agents.ts
ADDED
|
@@ -0,0 +1,1284 @@
|
|
|
1
|
+
import { mainThreadRegistry } from "./main-thread-state";
|
|
2
|
+
import { spawnTreeParentIds } from "./spawn-tree";
|
|
3
|
+
import { recordSpawnProcessExit } from "./spawn-process-evidence";
|
|
4
|
+
import { revokeVaultTokens, terminalProviderLaunchId } from "./vault-tokens";
|
|
5
|
+
import { isRecord, stringValue, isReservedAgentId, isHumanAgentId } from "@humwick/sdk";
|
|
6
|
+
import { parseJson } from "../utils";
|
|
7
|
+
import { STALE_TTL_MS, DAY_MS } from "../config";
|
|
8
|
+
import { withoutAuthzMetaKeys } from "../authz-meta-keys";
|
|
9
|
+
import {
|
|
10
|
+
jsonBytes,
|
|
11
|
+
splitAgentMetaForStorage,
|
|
12
|
+
splitAgentMetaPatchForStorage,
|
|
13
|
+
topLevelJsonPath,
|
|
14
|
+
warnIfAgentMetaOversized,
|
|
15
|
+
} from "./agent-meta.ts";
|
|
16
|
+
import { agentSessionGuardResult, reservedAgentIdSql } from "./agent-predicates.ts";
|
|
17
|
+
import { ROSTER_AGENT_COLUMNS, getPersistedAgentCard, getPersistedAgentRuntimeCard, listPersistedAgentCards, type AgentCardFilter } from "./agent-card-read.ts";
|
|
18
|
+
import { expectedChannelAgentId } from "./channel-identity.ts";
|
|
19
|
+
import { evaluatePoolBindings, upsertChannelForAgent } from "./channels.ts";
|
|
20
|
+
import { seedContinuationObjectiveFromSpawnPrompt } from "./continuations.ts";
|
|
21
|
+
import { messageTaskClosed } from "./claim-sql.ts";
|
|
22
|
+
import { ValidationError, getDb, inWriteTransaction, writeTransaction } from "./connection.ts";
|
|
23
|
+
import { fencedColumnSql, lifecycleWriteOutcome, nextLifecycleSeq, type LifecycleWriteOutcome } from "./lifecycle-seq.ts";
|
|
24
|
+
import { pendingPresence, evictPendingPresence, withBufferedPresence, snapshotPendingPresenceFlush, settlePendingPresenceFlush, type PresenceFlushPayload } from "./presence-buffer.ts";
|
|
25
|
+
import { rowToAgent, rowToContextSnapshot, rowToQuotaSnapshot } from "./mappers.ts";
|
|
26
|
+
import { closeOpenPairsForAgent } from "./pair-maintenance.ts";
|
|
27
|
+
import { parseStringArray } from "./shared.ts";
|
|
28
|
+
import { removeSubscriptionsForAgent } from "./notification-subscriptions.ts";
|
|
29
|
+
import { clearAgentNotices } from "./terminal-events.ts";
|
|
30
|
+
import { listAgentQuotaSnapshotsFromProviderStore } from "./provider-quotas.ts";
|
|
31
|
+
import { settleSingleTargetOnDemandTasks } from "./task-maintenance.ts";
|
|
32
|
+
import { claimTaskWhere } from "./task-core.ts";
|
|
33
|
+
import { withCanonicalSpawnRequestId } from "./spawn-request-id.ts";
|
|
34
|
+
import { assertSpawnIntentActive } from "../spawn-intent";
|
|
35
|
+
import { electWorkspaceStewards, electWorkspaceStewardsForAgent } from "./workspaces.ts";
|
|
36
|
+
import { releaseWorkspaceClaimsForAgent } from "../steward-claim-release.ts";
|
|
37
|
+
import { revokeTokenLineage, type LineageRevokeReason } from "./token-standing.ts";
|
|
38
|
+
import type {
|
|
39
|
+
AgentCard,
|
|
40
|
+
AgentKind,
|
|
41
|
+
AgentSessionGuard,
|
|
42
|
+
ManagedSessionExitDiagnostics,
|
|
43
|
+
RegisterAgentInput,
|
|
44
|
+
ContextSnapshot,
|
|
45
|
+
ContextState,
|
|
46
|
+
ProviderCapabilities,
|
|
47
|
+
QuotaSnapshot,
|
|
48
|
+
QuotaState,
|
|
49
|
+
} from "../types";
|
|
50
|
+
|
|
51
|
+
type BeforeAgentStatusTransition = (agent: AgentCard, nextStatus: AgentCard["status"]) => void;
|
|
52
|
+
const beforeAgentStatusTransitionHandlers = mainThreadRegistry("agents.ts:beforeAgentStatusTransitionHandlers", new Set<BeforeAgentStatusTransition>());
|
|
53
|
+
|
|
54
|
+
/** Register synchronous work that must finish before a status transition is persisted. */
|
|
55
|
+
export function onBeforeAgentStatusTransition(handler: BeforeAgentStatusTransition): () => void {
|
|
56
|
+
beforeAgentStatusTransitionHandlers.add(handler);
|
|
57
|
+
return () => beforeAgentStatusTransitionHandlers.delete(handler);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Fire the registered pre-transition handlers — the module-level Set only the MAIN thread's
|
|
61
|
+
* `agents.ts` instance ever populates (registrations like `transient-agent-reaper.ts`'s never reach
|
|
62
|
+
* a writer-worker's own instance), so this must only ever be invoked main-thread-side: from
|
|
63
|
+
* `setStatus` directly, or from `setStatusAsync`'s pre-write orchestration. Never from the
|
|
64
|
+
* `agents.setStatus` op body. */
|
|
65
|
+
export function runBeforeAgentStatusTransitionHandlers(before: AgentCard, next: AgentCard["status"]): void {
|
|
66
|
+
for (const handler of beforeAgentStatusTransitionHandlers) handler(before, next);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const CONTEXT_SNAPSHOT_DEBOUNCE_MS = 60_000;
|
|
70
|
+
|
|
71
|
+
export { parseStringArray } from "./shared.ts";
|
|
72
|
+
|
|
73
|
+
export function normalizeTags(tags: string[] | undefined): string[] {
|
|
74
|
+
return [...new Set((tags ?? []).map((tag) => tag.trim()).filter(Boolean))];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function inferAgentKind(input: Pick<RegisterAgentInput, "id" | "kind" | "tags" | "capabilities" | "meta">): AgentKind {
|
|
78
|
+
if (input.kind) return input.kind;
|
|
79
|
+
if (isHumanAgentId(input.id)) return "user";
|
|
80
|
+
if (input.id === "system") return "system";
|
|
81
|
+
const metaKind = stringValue(input.meta?.kind);
|
|
82
|
+
if (metaKind === "channel" || metaKind === "communication-channel") return "channel";
|
|
83
|
+
if (metaKind === "orchestrator") return "orchestrator";
|
|
84
|
+
if ((input.tags ?? []).includes("channel") || (input.capabilities ?? []).includes("channel")) return "channel";
|
|
85
|
+
return "provider";
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function inferProviderTag(input: RegisterAgentInput): "claude" | "codex" | undefined {
|
|
89
|
+
if (inferAgentKind(input) !== "provider") return undefined;
|
|
90
|
+
const meta = input.meta ?? {};
|
|
91
|
+
const values = [
|
|
92
|
+
input.id,
|
|
93
|
+
input.name,
|
|
94
|
+
input.rig,
|
|
95
|
+
...(input.tags ?? []),
|
|
96
|
+
stringValue(meta.provider),
|
|
97
|
+
stringValue(meta.client),
|
|
98
|
+
stringValue(meta.runtime),
|
|
99
|
+
stringValue(meta.agentType),
|
|
100
|
+
].filter((value): value is string => typeof value === "string");
|
|
101
|
+
|
|
102
|
+
if (values.some((value) => value.toLowerCase().includes("codex"))) return "codex";
|
|
103
|
+
if (values.some((value) => value.toLowerCase().includes("claude"))) return "claude";
|
|
104
|
+
|
|
105
|
+
// Older Claude hooks did not always send an explicit provider tag, but did
|
|
106
|
+
// send Claude-style approval metadata. Codex also sends approvalMode, so this
|
|
107
|
+
// fallback only runs after Codex signals have been ruled out.
|
|
108
|
+
if (Object.prototype.hasOwnProperty.call(meta, "approvalMode")) return "claude";
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function tagsWithProvider(input: RegisterAgentInput): string[] {
|
|
113
|
+
const tags = normalizeTags(input.tags);
|
|
114
|
+
const provider = inferProviderTag(input);
|
|
115
|
+
if (!provider || tags.includes(provider)) return tags;
|
|
116
|
+
return [provider, ...tags];
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
export interface UpsertAgentTxResult {
|
|
121
|
+
agent: AgentCard;
|
|
122
|
+
contextState: ContextState | undefined;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export interface UpsertAgentOptions {
|
|
126
|
+
verifiedKeepJtis?: string[];
|
|
127
|
+
systemTags?: string[];
|
|
128
|
+
verifiedSpawnRequestId?: string;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* The atomic op body for `agents.upsert` (S3 L10 #1895): the pre-#1057 comment below still applies
|
|
133
|
+
* unchanged, just relocated out of a `writeTransaction` closure so it can run either wrapped by the
|
|
134
|
+
* sync caller (`upsertAgent`) or by the writer executor when reached via the gateway. Folding
|
|
135
|
+
* `mergeRelayContextMarkers` (a read) in here — rather than leaving it computed before the
|
|
136
|
+
* transaction, as the pre-migration code did — closes a TOCTOU window that a real thread hop would
|
|
137
|
+
* otherwise open (ADR §3.4): the read and the write are now one atomic unit either way.
|
|
138
|
+
*/
|
|
139
|
+
export function upsertAgentInternal(
|
|
140
|
+
input: RegisterAgentInput,
|
|
141
|
+
opts: UpsertAgentOptions | undefined,
|
|
142
|
+
now: number,
|
|
143
|
+
/** #2111 — the registration's lifecycle ordinal, taken on the MAIN thread at submission.
|
|
144
|
+
* Never defaulted inside this body: under a worker writer the module-global counter is a
|
|
145
|
+
* different instance, and two counters could hand out the same ordinal. */
|
|
146
|
+
lifecycleSeq: number,
|
|
147
|
+
): UpsertAgentTxResult {
|
|
148
|
+
const kind = inferAgentKind(input);
|
|
149
|
+
if (kind === "channel") {
|
|
150
|
+
const expectedId = expectedChannelAgentId(input);
|
|
151
|
+
if (input.id !== expectedId) {
|
|
152
|
+
throw new ValidationError(`channel agent id must be canonical: ${expectedId}`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
const tags = tagsWithProvider(input); const labelProvided = Object.prototype.hasOwnProperty.call(input, "label");
|
|
156
|
+
// Preserve the existing label across re-registrations unless the caller
|
|
157
|
+
// explicitly sends one (including null to clear).
|
|
158
|
+
const readyProvided = Object.prototype.hasOwnProperty.call(input, "ready");
|
|
159
|
+
const lifecycleProvided = Object.prototype.hasOwnProperty.call(input, "lifecycle");
|
|
160
|
+
const instanceProvided = Boolean(input.instanceId);
|
|
161
|
+
const contextState = mergeRelayContextMarkers(input.id, input.context);
|
|
162
|
+
const storedMeta = splitAgentMetaForStorage(withCanonicalSpawnRequestId(input.meta));
|
|
163
|
+
const metaJson = JSON.stringify(storedMeta.meta);
|
|
164
|
+
const profileProjectionJson = storedMeta.profileProjection == null ? null : JSON.stringify(storedMeta.profileProjection);
|
|
165
|
+
warnIfAgentMetaOversized(input.id, metaJson, "stored meta");
|
|
166
|
+
const stmt = getDb().query(`
|
|
167
|
+
INSERT INTO agents (id, name, kind, label, tags, system_tags, machine, rig, capabilities, ready, status, instance_id, epoch, provider_capabilities, context_state, quota_state, profile_projection, meta, lifecycle, spawned_by, team_id, status_seq, ready_seq, last_seen, created_at)
|
|
168
|
+
VALUES ($id, $name, $kind, $label, $tags, $systemTags, $machine, $rig, $capabilities, $ready, $status, $instanceId, $initialEpoch, $providerCapabilities, $contextState, $quotaState, $profileProjection, $meta, $lifecycle, $spawnedBy, $teamId, $lifecycleSeq, $lifecycleSeq, $now, $now)
|
|
169
|
+
ON CONFLICT(id) DO UPDATE SET
|
|
170
|
+
name = $name,
|
|
171
|
+
kind = $kind,
|
|
172
|
+
label = CASE WHEN $labelProvided = 1 THEN $label ELSE agents.label END,
|
|
173
|
+
tags = $tags, system_tags = CASE WHEN $systemTagsProvided = 1 THEN $systemTags ELSE agents.system_tags END,
|
|
174
|
+
machine = coalesce($machine, agents.machine),
|
|
175
|
+
rig = coalesce($rig, agents.rig),
|
|
176
|
+
capabilities = $capabilities,
|
|
177
|
+
${fencedColumnSql("ready", "CASE WHEN $readyProvided = 1 THEN $ready ELSE agents.ready END", "$lifecycleSeq", { qualifier: "agents." })},
|
|
178
|
+
${fencedColumnSql("status", "$status", "$lifecycleSeq", { qualifier: "agents." })},
|
|
179
|
+
instance_id = CASE WHEN $instanceProvided = 1 THEN $instanceId ELSE agents.instance_id END,
|
|
180
|
+
epoch = CASE
|
|
181
|
+
WHEN $instanceProvided = 1 AND (agents.instance_id IS NULL OR agents.instance_id <> $instanceId) THEN agents.epoch + 1
|
|
182
|
+
ELSE agents.epoch
|
|
183
|
+
END,
|
|
184
|
+
provider_capabilities = coalesce($providerCapabilities, agents.provider_capabilities),
|
|
185
|
+
context_state = coalesce($contextState, agents.context_state),
|
|
186
|
+
quota_state = coalesce($quotaState, agents.quota_state),
|
|
187
|
+
profile_projection = CASE WHEN $profileProjectionProvided = 1 THEN $profileProjection ELSE agents.profile_projection END,
|
|
188
|
+
-- Re-registration replaces provider meta, but readiness is a server-owned lifetime stamp.
|
|
189
|
+
-- Keep it through a deploy restart even when the replacement has not become ready yet.
|
|
190
|
+
-- The server's idle self-care latch survives only within the same epoch.
|
|
191
|
+
meta = json_patch(CASE
|
|
192
|
+
WHEN json_type(agents.meta, '$.readyNotifiedAt') IN ('integer', 'real')
|
|
193
|
+
THEN json_set($meta, '$.readyNotifiedAt', json_extract(agents.meta, '$.readyNotifiedAt'))
|
|
194
|
+
ELSE $meta
|
|
195
|
+
END, json_object('idleSelfCare', CASE
|
|
196
|
+
WHEN ($instanceProvided = 0 OR agents.instance_id = $instanceId)
|
|
197
|
+
AND json_type(agents.meta, '$.idleSelfCare') = 'object'
|
|
198
|
+
AND json_extract(agents.meta, '$.idleSelfCare.epoch') = agents.epoch
|
|
199
|
+
THEN json_extract(agents.meta, '$.idleSelfCare')
|
|
200
|
+
ELSE NULL
|
|
201
|
+
END)),
|
|
202
|
+
lifecycle = CASE WHEN $lifecycleProvided = 1 THEN $lifecycle ELSE agents.lifecycle END,
|
|
203
|
+
spawned_by = coalesce($spawnedBy, agents.spawned_by),
|
|
204
|
+
team_id = coalesce($teamId, agents.team_id),
|
|
205
|
+
last_seen = $now
|
|
206
|
+
`);
|
|
207
|
+
|
|
208
|
+
// #1057(2) — the takeover revoke fires on the SAME predicate as the epoch bump, by observing
|
|
209
|
+
// the bump itself (prior.epoch !== next.epoch) rather than re-deriving the SQL's instance-
|
|
210
|
+
// transition condition. The old guard in registerAgent required a truthy prior instanceId, so a
|
|
211
|
+
// NULL→instanceId takeover bumped the epoch yet skipped the revoke, stranding the prior token
|
|
212
|
+
// until the 24h prune. Read→upsert upgrade (SELECT prior agent → INSERT…ON CONFLICT DO UPDATE) on
|
|
213
|
+
// the hot registration/re-registration path. #1057(4) — the write + superseded-token revoke share
|
|
214
|
+
// this op body: a revoke failure rolls the epoch bump back with it, atomically either way.
|
|
215
|
+
const prior = getAgent(input.id);
|
|
216
|
+
// Check under the same writer transaction as registration so cancellation cannot slip between.
|
|
217
|
+
assertSpawnIntentActive(storedMeta.meta.spawnRequestId ?? prior?.meta?.spawnRequestId);
|
|
218
|
+
assertSpawnIntentActive(opts?.verifiedSpawnRequestId);
|
|
219
|
+
stmt.run({
|
|
220
|
+
$lifecycleSeq: lifecycleSeq,
|
|
221
|
+
$id: input.id,
|
|
222
|
+
$name: input.name,
|
|
223
|
+
$kind: kind,
|
|
224
|
+
$label: input.label ?? null,
|
|
225
|
+
$labelProvided: labelProvided ? 1 : 0,
|
|
226
|
+
$tags: JSON.stringify(tags), $systemTags: JSON.stringify(normalizeTags(opts?.systemTags)),
|
|
227
|
+
$systemTagsProvided: opts?.systemTags !== undefined ? 1 : 0,
|
|
228
|
+
$machine: input.machine ?? null,
|
|
229
|
+
$rig: input.rig ?? null,
|
|
230
|
+
$capabilities: JSON.stringify(input.capabilities ?? []),
|
|
231
|
+
$ready: input.ready ? 1 : 0,
|
|
232
|
+
$readyProvided: readyProvided ? 1 : 0,
|
|
233
|
+
$status: input.status ?? "idle",
|
|
234
|
+
$instanceId: input.instanceId ?? null,
|
|
235
|
+
$instanceProvided: instanceProvided ? 1 : 0,
|
|
236
|
+
$initialEpoch: instanceProvided ? 1 : 0,
|
|
237
|
+
$providerCapabilities: input.providerCapabilities ? JSON.stringify(input.providerCapabilities) : null,
|
|
238
|
+
$contextState: contextState ? JSON.stringify(contextState) : null,
|
|
239
|
+
$quotaState: input.quota ? JSON.stringify(input.quota) : null,
|
|
240
|
+
$profileProjection: profileProjectionJson,
|
|
241
|
+
$profileProjectionProvided: storedMeta.profileProjectionProvided ? 1 : 0,
|
|
242
|
+
$meta: metaJson, // #1456 round-10 — canonical spawnRequestId at ingress
|
|
243
|
+
$lifecycle: input.lifecycle ?? "persistent",
|
|
244
|
+
$lifecycleProvided: lifecycleProvided ? 1 : 0,
|
|
245
|
+
$spawnedBy: input.spawnedBy ?? null,
|
|
246
|
+
$teamId: input.teamId ?? null,
|
|
247
|
+
$now: now,
|
|
248
|
+
});
|
|
249
|
+
const next = getAgent(input.id)!;
|
|
250
|
+
if (prior && next.epoch !== prior.epoch) {
|
|
251
|
+
revokeSupersededRuntimeTokens(prior, opts?.verifiedKeepJtis ?? [], now);
|
|
252
|
+
}
|
|
253
|
+
return { agent: next, contextState };
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* BEGIN IMMEDIATE (#1428/#1431) so a concurrent writer waits on busy_timeout instead of an instant
|
|
258
|
+
* SQLITE_BUSY on the deferred upgrade. Orchestrates `upsertAgentInternal` (the atomic DB op, also
|
|
259
|
+
* reachable async via the `agents.upsert` writer op) with the cross-domain side effects that were
|
|
260
|
+
* already outside its transaction pre-migration (channel/pool/steward wiring, in-memory presence
|
|
261
|
+
* eviction) — kept outside here too, since several of them (workspaces.ts's steward election,
|
|
262
|
+
* presence-buffer.ts's `pendingPresence` map) rely on MAIN-THREAD-only state a writer-worker op body
|
|
263
|
+
* cannot see (the same class of bug the S3.1 L4 stale-read-on-async landmine surfaced).
|
|
264
|
+
*/
|
|
265
|
+
export function upsertAgent(input: RegisterAgentInput, opts?: UpsertAgentOptions): AgentCard {
|
|
266
|
+
const now = Date.now();
|
|
267
|
+
const lifecycleSeq = nextLifecycleSeq();
|
|
268
|
+
const { agent, contextState } = writeTransaction(() => upsertAgentInternal(input, opts, now, lifecycleSeq));
|
|
269
|
+
if (contextState) recordContextSnapshot(input.id, contextState, now);
|
|
270
|
+
|
|
271
|
+
// #1468 — a (re)registration writes the row authoritatively (fresh last_seen + a possibly bumped
|
|
272
|
+
// epoch on instance takeover), so any beat buffered against the PRIOR instance is stale and must
|
|
273
|
+
// not be flushed onto this successor. The flush's epoch guard also catches it; this evicts eagerly.
|
|
274
|
+
evictPendingPresence(agent.id);
|
|
275
|
+
|
|
276
|
+
seedContinuationObjectiveFromSpawnPrompt(agent.id, stringValue(agent.meta?.spawnRequestId), now);
|
|
277
|
+
if (agent.kind === "channel") upsertChannelForAgent(agent);
|
|
278
|
+
evaluatePoolBindings();
|
|
279
|
+
// A (re)joining agent may revive a dormant repo steward — re-elect for the
|
|
280
|
+
// repos it owns live workspaces in (issue #157, steward survives offline gap).
|
|
281
|
+
if (agent.status !== "offline") electWorkspaceStewardsForAgent(agent.id);
|
|
282
|
+
return agent;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export function validateAgentSession(id: string, guard?: AgentSessionGuard): { ok: boolean; error?: string } {
|
|
286
|
+
if (!guard || (!guard.instanceId && guard.epoch === undefined)) return { ok: true };
|
|
287
|
+
return agentSessionGuardResult(getAgent(id), guard);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export function setLabel(id: string, label: string | null): boolean {
|
|
291
|
+
const normalized = label && label.trim() ? label.trim() : null;
|
|
292
|
+
return (
|
|
293
|
+
getDb().query("UPDATE agents SET label = ? WHERE id = ?").run(normalized, id).changes > 0
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export function setAgentTeam(agentId: string, teamId: string, now: number = Date.now()): AgentCard | null {
|
|
298
|
+
const result = getDb()
|
|
299
|
+
.query("UPDATE agents SET team_id = ?, last_seen = ? WHERE id = ?")
|
|
300
|
+
.run(teamId, now, agentId);
|
|
301
|
+
return result.changes > 0 ? getAgent(agentId) : null;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
export function setTags(id: string, tags: string[], now: number = Date.now()): AgentCard | null {
|
|
305
|
+
const normalized = [...new Set(tags.map((tag) => tag.trim()).filter(Boolean))];
|
|
306
|
+
const result = getDb().query("UPDATE agents SET tags = ?, last_seen = ? WHERE id = ?").run(JSON.stringify(normalized), now, id);
|
|
307
|
+
return result.changes > 0 ? getAgent(id) : null;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
export function getAgent(id: string): AgentCard | null {
|
|
311
|
+
// #1468 — fold in any epoch-matched buffered beat so liveness/routing reads (isAgentOnline,
|
|
312
|
+
// resolveAgentRef, channel routing) never see a coalesced-but-live agent as gone.
|
|
313
|
+
const card = getPersistedAgentCard(id);
|
|
314
|
+
return card ? withBufferedPresence(card) : null;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export function listAgents(filter?: AgentCardFilter): AgentCard[] {
|
|
318
|
+
// #1468 — roster routing must include coalesced heartbeat advances.
|
|
319
|
+
return listPersistedAgentCards(filter).map(withBufferedPresence);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Raw (unbuffered) persisted rows for a parent's ready, non-terminal descendants — the reader-pool op
|
|
325
|
+
* body for `agents.spawnedChildren`. Deliberately does NOT fold `pendingPresence` (mirrors
|
|
326
|
+
* `agent-card-read.ts`'s split): a reader-pool worker has its own empty presence-buffer module
|
|
327
|
+
* instance, so folding here would silently make a coalesced-but-live child invisible to the
|
|
328
|
+
* caller (the same stale-read-on-async class the S3.1 L4 landmine warned about). Buffer folding
|
|
329
|
+
* belongs to the main-thread caller — see `countLiveSpawnedAgents` / `countLiveSpawnedAgentsAsync`.
|
|
330
|
+
*/
|
|
331
|
+
export function spawnedChildrenRows(parentId: string): AgentCard[] {
|
|
332
|
+
const rows = getDb().query(
|
|
333
|
+
// #2392 — roster columns only; a spawn-quota scan has no use for the cold launch projection.
|
|
334
|
+
`SELECT ${ROSTER_AGENT_COLUMNS} FROM agents WHERE spawned_by IN (SELECT value FROM json_each(?)) AND status NOT IN ('offline', 'stale') AND ready = 1`,
|
|
335
|
+
).all(JSON.stringify(spawnTreeParentIds(parentId))) as any[];
|
|
336
|
+
return rows.map(rowToAgent);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
export function countLiveSpawnedAgents(parentId: string, now: number = Date.now()): number {
|
|
340
|
+
// #1468 — buffer-aware liveness: load the (few) ready children and fold in any epoch-matched
|
|
341
|
+
// buffered beat before the recency test, so a coalesced-but-live child near the TTL boundary is
|
|
342
|
+
// not undercounted (which would wrongly free a spawn-quota slot).
|
|
343
|
+
const cutoff = now - STALE_TTL_MS;
|
|
344
|
+
return spawnedChildrenRows(parentId).map(withBufferedPresence).filter((agent) => agent.lastSeen > cutoff).length;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* The bare `agents.setStatus` op body (S3 L10 #1895) — just the UPDATE, threaded on `now`. Handler
|
|
349
|
+
* firing (`beforeAgentStatusTransitionHandlers`, a main-thread-only module Set — registrations like
|
|
350
|
+
* `transient-agent-reaper.ts`'s never reach a writer-worker's own module instance) and the
|
|
351
|
+
* presence-buffer eviction stay OUT of the op body for the same reason the S3.1 L4 landmine did:
|
|
352
|
+
* calling them from a worker thread would silently no-op against empty worker-local state.
|
|
353
|
+
*
|
|
354
|
+
* `expectedEpoch` (review fix, #1895 cross-host review finding 2 — CONFIRMED HIGH): the sync
|
|
355
|
+
* `setStatus` reads `before` and writes back-to-back with no event-loop yield, so the row can never
|
|
356
|
+
* move out from under it. `setStatusAsync` has a REAL await gap between that read and this write
|
|
357
|
+
* landing, during which a fresh instance registration can bump the row's epoch (an instance
|
|
358
|
+
* takeover) — without a CAS guard, a stale connection's setStatus could then offline the SUCCESSOR
|
|
359
|
+
* it was supposed to be fenced from. When provided, the UPDATE only applies if the row's epoch still
|
|
360
|
+
* matches what the caller observed; a mismatch is a silent no-op (`changes = 0`), exactly like "agent
|
|
361
|
+
* not found" today. Always `undefined` for the sync path (no gap to fence against).
|
|
362
|
+
*
|
|
363
|
+
* `seq` (#2111 review BLOCKER 1) is the ORDERING fence `expectedEpoch` cannot be: the epoch only
|
|
364
|
+
* moves on an instance takeover, so it lets a same-instance write that the coalescing window deferred
|
|
365
|
+
* commit AFTER — and silently undo — a newer synchronous transition. See lifecycle-seq.ts.
|
|
366
|
+
*/
|
|
367
|
+
export function setStatusInternal(
|
|
368
|
+
id: string,
|
|
369
|
+
status: AgentCard["status"],
|
|
370
|
+
now: number,
|
|
371
|
+
expectedEpoch?: number,
|
|
372
|
+
seq: number = nextLifecycleSeq(),
|
|
373
|
+
): LifecycleWriteOutcome {
|
|
374
|
+
const epochGuard = expectedEpoch !== undefined ? " AND epoch = ?" : "";
|
|
375
|
+
// `offline` also clears readiness, but through the READY fence rather than as part of this one:
|
|
376
|
+
// an independently newer markReady must survive, and losing that half must not make the status
|
|
377
|
+
// transition itself report superseded. `status` is this write's primary column.
|
|
378
|
+
const readySet = status === "offline" ? `, ${fencedColumnSql("ready", "0", "$seq")}` : "";
|
|
379
|
+
const sql = `UPDATE agents SET ${fencedColumnSql("status", "$status", "$seq")}${readySet}, last_seen = $now`
|
|
380
|
+
+ ` WHERE id = $id${epochGuard.replace("?", "$epoch")} RETURNING status_seq AS seq`;
|
|
381
|
+
const params: Record<string, unknown> = { $status: status, $seq: seq, $now: now, $id: id };
|
|
382
|
+
if (expectedEpoch !== undefined) params.$epoch = expectedEpoch;
|
|
383
|
+
const row = getDb().query(sql).get(params as never) as { seq: number } | null;
|
|
384
|
+
return lifecycleWriteOutcome(row?.seq, seq);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
export function setStatus(id: string, status: AgentCard["status"], guard?: AgentSessionGuard): boolean {
|
|
388
|
+
if (!validateAgentSession(id, guard).ok) return false;
|
|
389
|
+
const before = getAgent(id);
|
|
390
|
+
if (!before) return false;
|
|
391
|
+
if (before.status !== status) {
|
|
392
|
+
runBeforeAgentStatusTransitionHandlers(before, status);
|
|
393
|
+
}
|
|
394
|
+
// #1468 — a terminal transition (offline/stale) evicts any buffered beat, so a coalesced advance
|
|
395
|
+
// can't later resurrect a gone agent at flush. Covers busHandleClose / expireStaleBusAgents, which
|
|
396
|
+
// reach terminal via this one choke point.
|
|
397
|
+
if (status === "offline" || status === "stale") evictPendingPresence(id);
|
|
398
|
+
const now = Date.now();
|
|
399
|
+
// BEGIN IMMEDIATE (#1428/#1431), same pattern as the registration path above (#1549): this write
|
|
400
|
+
// is hit by every agent on a post-restart reconnect storm, so it needs busy_timeout to govern
|
|
401
|
+
// contention instead of an unwrapped statement risking SQLITE_BUSY under concurrent writers.
|
|
402
|
+
// #2111 — the ordinal is taken HERE, at the caller's intent, and inside the transaction the write
|
|
403
|
+
// applies only if no later-submitted lifecycle write already landed (see lifecycle-seq.ts).
|
|
404
|
+
const seq = nextLifecycleSeq();
|
|
405
|
+
const changed = writeTransaction(() => setStatusInternal(id, status, now, undefined, seq)) === "applied";
|
|
406
|
+
// NOTE: `offline` here is a LIVENESS observation (bus-grace expiry / heartbeat lapse — the process may
|
|
407
|
+
// still be alive after a relay stall or partition), NOT a confirmed death. So it re-elects stewards and
|
|
408
|
+
// closes pairs, but it must NOT release a steward's workspace claim (#1789 part 2, review F2): that
|
|
409
|
+
// fires only on a CONFIRMED process exit, in recordAgentExitDiagnostics below.
|
|
410
|
+
if (changed && status === "offline") { closeOpenPairsForAgent(id, now); electWorkspaceStewards(); }
|
|
411
|
+
return changed;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* #2111 review BLOCKER 1 — readiness is fenced by `seq` for the same reason `setStatusInternal` is,
|
|
416
|
+
* and it needed it MORE: markReady's only guard was session identity, so a buffered `markReady(true)`
|
|
417
|
+
* committing after a synchronous `offline` (which clears `ready`) resurrected readiness on a dead
|
|
418
|
+
* agent. The ordinal makes the last SUBMITTED writer win regardless of who commits last.
|
|
419
|
+
*/
|
|
420
|
+
export function markReady(
|
|
421
|
+
id: string,
|
|
422
|
+
ready: boolean,
|
|
423
|
+
guard?: AgentSessionGuard,
|
|
424
|
+
now: number = Date.now(),
|
|
425
|
+
seq: number = nextLifecycleSeq(),
|
|
426
|
+
): LifecycleWriteOutcome {
|
|
427
|
+
if (!validateAgentSession(id, guard).ok) return "missing";
|
|
428
|
+
const row = getDb()
|
|
429
|
+
.query(`UPDATE agents SET ${fencedColumnSql("ready", "$ready", "$seq")}, last_seen = $now`
|
|
430
|
+
+ " WHERE id = $id RETURNING ready_seq AS seq")
|
|
431
|
+
.get({ $ready: ready ? 1 : 0, $seq: seq, $now: now, $id: id } as never) as { seq: number } | null;
|
|
432
|
+
return lifecycleWriteOutcome(row?.seq, seq);
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/** One agent row's whole lifecycle delta for `applyAgentLifecycleUpdate`. Every field is optional;
|
|
436
|
+
* only what is supplied reaches the SET list. */
|
|
437
|
+
export interface AgentLifecycleUpdate {
|
|
438
|
+
status?: AgentCard["status"];
|
|
439
|
+
ready?: boolean;
|
|
440
|
+
/** Shallow-patched onto stored meta (authz keys stripped); null/undefined deletes a top-level key. */
|
|
441
|
+
meta?: Record<string, unknown>;
|
|
442
|
+
runtime?: { providerCapabilities?: ProviderCapabilities; context?: ContextState; quota?: QuotaState };
|
|
443
|
+
/** Apply `heartbeat()`'s offline/stale → idle resurrection CASE. Ignored when `status` is supplied
|
|
444
|
+
* (an explicit status always wins, matching the old heartbeat()-then-setStatus() ordering). */
|
|
445
|
+
resurrectOnBeat?: boolean;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
export interface AgentLifecycleUpdateResult {
|
|
449
|
+
/** The session guard passed AND the row exists. False maps to the callers' old "agent not found". */
|
|
450
|
+
ok: boolean;
|
|
451
|
+
/** The UPDATE touched a row — the boolean the superseded setStatus/markReady/mergeMeta returned. */
|
|
452
|
+
changed: boolean;
|
|
453
|
+
/** Bytes bound for the JSON meta update (zero when this lifecycle delta has no meta patch). */
|
|
454
|
+
metaWriteBytes: number;
|
|
455
|
+
before: AgentCard | null;
|
|
456
|
+
after: AgentCard | null;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* #2111 — ONE read + ONE UPDATE + ONE transaction for a whole agent lifecycle delta.
|
|
461
|
+
*
|
|
462
|
+
* The hot bus seams used to spend a per-frame storm of on-loop DB work on a SINGLE row: the `status`
|
|
463
|
+
* frame ran `getAgent(before)` → `setStatus` (its own `validateAgentSession`+`getAgent`+`getAgent`, an
|
|
464
|
+
* UPDATE inside its own BEGIN IMMEDIATE) → `markReady` (another guard read + UPDATE) → `mergeAgentMeta`
|
|
465
|
+
* (two more reads + UPDATE) → `getAgent(after)`: ~7 row reads and 3 separate UPDATEs of the same row.
|
|
466
|
+
* `recordHeartbeat`'s presence-critical bypass did the same on a smaller scale (`heartbeat()` UPDATE
|
|
467
|
+
* then `setStatus()` UPDATE). Under a fleet reconnection storm that per-row multiplier is what
|
|
468
|
+
* saturated the loop (agents.setStatus 121 / agents.markReady 75 on-loop blocks in the bad window).
|
|
469
|
+
*
|
|
470
|
+
* This collapses the whole delta into one statement inside one transaction, so a storm costs one row
|
|
471
|
+
* write per event instead of three, and the guard/before/after reads are shared rather than repeated.
|
|
472
|
+
* Observable semantics are deliberately UNCHANGED — same guard rejection, same pre-transition handlers,
|
|
473
|
+
* same presence eviction, same offline post-commit (pair close + steward re-election), same
|
|
474
|
+
* `changed` boolean — so nothing here relaxes a terminal transition.
|
|
475
|
+
*/
|
|
476
|
+
export function applyAgentLifecycleUpdate(
|
|
477
|
+
id: string,
|
|
478
|
+
update: AgentLifecycleUpdate,
|
|
479
|
+
guard?: AgentSessionGuard,
|
|
480
|
+
now: number = Date.now(),
|
|
481
|
+
): AgentLifecycleUpdateResult {
|
|
482
|
+
const miss: AgentLifecycleUpdateResult = { ok: false, changed: false, metaWriteBytes: 0, before: null, after: null };
|
|
483
|
+
const before = getPersistedAgentRuntimeCard(id);
|
|
484
|
+
if (!before) return miss;
|
|
485
|
+
if (!agentSessionGuardResult(before, guard).ok) return miss;
|
|
486
|
+
|
|
487
|
+
const nextStatus = update.status;
|
|
488
|
+
// Pre-transition handlers are main-thread-only state (see runBeforeAgentStatusTransitionHandlers)
|
|
489
|
+
// and must run BEFORE the write lands, exactly as `setStatus` does.
|
|
490
|
+
if (nextStatus !== undefined && nextStatus !== before.status) runBeforeAgentStatusTransitionHandlers(before, nextStatus);
|
|
491
|
+
// #1468 — a terminal transition evicts any buffered beat so a coalesced advance cannot later
|
|
492
|
+
// resurrect a gone agent at flush.
|
|
493
|
+
if (nextStatus === "offline" || nextStatus === "stale") evictPendingPresence(id);
|
|
494
|
+
|
|
495
|
+
// #2111 review BLOCKER 1 — raise each written column's ordinal so a lifecycle write the coalescing
|
|
496
|
+
// window deferred cannot commit afterwards and undo it. This path only ever WINS its own races (it
|
|
497
|
+
// commits synchronously, and any submission carrying a higher ordinal has not been allocated yet),
|
|
498
|
+
// but it is fenced anyway so every writer of these columns obeys one rule.
|
|
499
|
+
const seq = nextLifecycleSeq();
|
|
500
|
+
// Named params throughout: the fenced-column fragments repeat `$seq`, which positional `?` could
|
|
501
|
+
// only express by counting placeholders across a dynamically-built SET list.
|
|
502
|
+
const sets: string[] = ["last_seen = $now"];
|
|
503
|
+
const params: Record<string, unknown> = { $now: now, $seq: seq, $id: id };
|
|
504
|
+
let metaWriteBytes = 0;
|
|
505
|
+
if (nextStatus !== undefined) {
|
|
506
|
+
sets.push(fencedColumnSql("status", "$status", "$seq"));
|
|
507
|
+
params.$status = nextStatus;
|
|
508
|
+
} else if (update.resurrectOnBeat) {
|
|
509
|
+
// A beat that does not actually resurrect makes no status claim, so `when` keeps it from raising
|
|
510
|
+
// the fence — otherwise it would suppress an earlier-submitted, later-flushed real transition.
|
|
511
|
+
sets.push(fencedColumnSql("status", "'idle'", "$seq", { when: "status IN ('offline', 'stale')" }));
|
|
512
|
+
}
|
|
513
|
+
// An explicit `ready` wins over the offline-forced clear, preserving the old setStatus-then-markReady
|
|
514
|
+
// ordering (setStatus zeroed `ready` on offline; a following markReady overwrote it).
|
|
515
|
+
if (update.ready !== undefined) {
|
|
516
|
+
sets.push(fencedColumnSql("ready", "$ready", "$seq"));
|
|
517
|
+
params.$ready = update.ready ? 1 : 0;
|
|
518
|
+
} else if (nextStatus === "offline") {
|
|
519
|
+
sets.push(fencedColumnSql("ready", "0", "$seq"));
|
|
520
|
+
}
|
|
521
|
+
if (update.meta) {
|
|
522
|
+
// #2367 — bind only the incoming top-level patch. Removing its keys before json_patch preserves
|
|
523
|
+
// the old SHALLOW replacement contract for nested objects; null (and local undefined) deletes a
|
|
524
|
+
// key, which lets one-shot runner markers be consumed instead of latching forever. The static
|
|
525
|
+
// launch projection is split into its cold column and never rides this hot write.
|
|
526
|
+
const patch = splitAgentMetaPatchForStorage(withoutAuthzMetaKeys(update.meta));
|
|
527
|
+
const metaJson = JSON.stringify(patch.meta);
|
|
528
|
+
let base = "meta";
|
|
529
|
+
const keys = Object.keys(patch.meta);
|
|
530
|
+
metaWriteBytes = keys.length ? jsonBytes(metaJson) : 0;
|
|
531
|
+
if (keys.length) warnIfAgentMetaOversized(id, metaJson, "status meta patch");
|
|
532
|
+
for (let offset = 0; offset < keys.length; offset += 50) {
|
|
533
|
+
const pathParams = keys.slice(offset, offset + 50).map((key, index) => {
|
|
534
|
+
const name = `$metaPath${offset + index}`;
|
|
535
|
+
params[name] = topLevelJsonPath(key);
|
|
536
|
+
return name;
|
|
537
|
+
});
|
|
538
|
+
base = `json_remove(${base}, ${pathParams.join(", ")})`;
|
|
539
|
+
}
|
|
540
|
+
if (keys.length) {
|
|
541
|
+
sets.push(`meta = json_patch(${base}, $meta)`);
|
|
542
|
+
params.$meta = metaJson;
|
|
543
|
+
}
|
|
544
|
+
if (patch.profileProjectionProvided) {
|
|
545
|
+
sets.push("profile_projection = $profileProjection");
|
|
546
|
+
params.$profileProjection = patch.profileProjection == null ? null : JSON.stringify(patch.profileProjection);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
const runtime = update.runtime;
|
|
550
|
+
const hasRuntime = Boolean(runtime?.providerCapabilities || runtime?.context || runtime?.quota);
|
|
551
|
+
const contextState = hasRuntime ? mergeRelayContextMarkers(id, runtime?.context) : undefined;
|
|
552
|
+
if (hasRuntime) {
|
|
553
|
+
sets.push("provider_capabilities = coalesce($pc, provider_capabilities)");
|
|
554
|
+
params.$pc = runtime?.providerCapabilities ? JSON.stringify(runtime.providerCapabilities) : null;
|
|
555
|
+
sets.push("context_state = coalesce($cx, context_state)");
|
|
556
|
+
params.$cx = contextState ? JSON.stringify(contextState) : null;
|
|
557
|
+
sets.push("quota_state = coalesce($qs, quota_state)");
|
|
558
|
+
params.$qs = runtime?.quota ? JSON.stringify(runtime.quota) : null;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
// BEGIN IMMEDIATE (#1428/#1431) so busy_timeout governs contention, joining an ambient writer-op
|
|
562
|
+
// transaction rather than nesting when this body is reached through the gateway.
|
|
563
|
+
const changed = inWriteTransaction(() => {
|
|
564
|
+
const applied = getDb().query(`UPDATE agents SET ${sets.join(", ")} WHERE id = $id`).run(params as never).changes > 0;
|
|
565
|
+
const terminalLaunch = terminalProviderLaunchId(update.meta?.terminalProviderExit ?? before.meta?.terminalProviderExit);
|
|
566
|
+
if (applied && nextStatus === "offline" && terminalLaunch) revokeVaultTokens(id, now, "provider_terminal_exit", before.instanceId, String(before.meta?.spawnRequestId ?? ""), terminalLaunch);
|
|
567
|
+
if (applied && contextState) recordContextSnapshot(id, contextState, now);
|
|
568
|
+
return applied;
|
|
569
|
+
});
|
|
570
|
+
|
|
571
|
+
// NOTE (from setStatus): `offline` is a LIVENESS observation, not a confirmed death — it re-elects
|
|
572
|
+
// stewards and closes pairs but must NOT release a steward's workspace claim (#1789 part 2, F2).
|
|
573
|
+
// Gated on the requested status, not on a status CHANGE, matching setStatus's own condition.
|
|
574
|
+
if (changed && nextStatus === "offline") {
|
|
575
|
+
closeOpenPairsForAgent(id, now);
|
|
576
|
+
electWorkspaceStewards();
|
|
577
|
+
}
|
|
578
|
+
return { ok: true, changed, metaWriteBytes, before, after: getPersistedAgentRuntimeCard(id) };
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
export function mergeAgentMeta(id: string, meta: Record<string, unknown>, guard?: AgentSessionGuard, now: number = Date.now()): boolean {
|
|
582
|
+
if (!validateAgentSession(id, guard).ok) return false;
|
|
583
|
+
const agent = getAgent(id);
|
|
584
|
+
if (!agent) return false;
|
|
585
|
+
// #1797 (N1) — THE SECOND caller-controlled meta ingress. `bus.ts` merges an agent-supplied blob
|
|
586
|
+
// from a `status` frame straight through here, so this path bypassed the registration sanitizer
|
|
587
|
+
// completely: an agent with a bus socket could stamp another agent's `spawnRequestId` on its own
|
|
588
|
+
// row and inherit that Task's read + DISPATCH authority (`agentBoundTaskIds` in task-authz.ts;
|
|
589
|
+
// dispatch is spawn-class), and claim an unowned Task on its next ready flip. `policyName` /
|
|
590
|
+
// `spawnRequestId` are authorization ADDRESSING established once at registration from the signed
|
|
591
|
+
// grant — no relay-internal caller of this function writes either — so refuse them outright here
|
|
592
|
+
// and let the invariant hold on BOTH ingresses. See authz-meta-keys.ts.
|
|
593
|
+
// #1456 round-10 — canonicalize spawnRequestId here too, so a value already on the row (written by
|
|
594
|
+
// registration, from signed constraints) stays canonical through an unrelated merge.
|
|
595
|
+
const merged = withCanonicalSpawnRequestId({ ...(agent.meta ?? {}), ...withoutAuthzMetaKeys(meta) });
|
|
596
|
+
const stored = splitAgentMetaForStorage(merged);
|
|
597
|
+
const metaJson = JSON.stringify(stored.meta);
|
|
598
|
+
warnIfAgentMetaOversized(id, metaJson, "stored meta");
|
|
599
|
+
const result = getDb()
|
|
600
|
+
.query("UPDATE agents SET meta = ?, profile_projection = ?, last_seen = ? WHERE id = ?")
|
|
601
|
+
.run(metaJson, stored.profileProjection == null ? null : JSON.stringify(stored.profileProjection), now, id);
|
|
602
|
+
return result.changes > 0;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
/** #633/#634 — persist a durable "this child became ready" marker. Death classification
|
|
606
|
+
* (`notifyAgentOffline`) keys `agent.exited` vs `agent.spawn_failed` off readiness, but the live
|
|
607
|
+
* signal is an in-memory set that a relay restart wipes — so a long-ready child's later clean exit
|
|
608
|
+
* would mis-fire `spawn_failed`. This stamp survives the restart in SQLite, so the offline edge
|
|
609
|
+
* still classifies as `agent.exited`. Idempotent: only stamped once (first ready). */
|
|
610
|
+
export function markAgentReadyNotified(id: string, at: number = Date.now()): boolean {
|
|
611
|
+
const agent = getAgent(id);
|
|
612
|
+
if (!agent) return false;
|
|
613
|
+
if (typeof agent.meta?.readyNotifiedAt === "number") return false;
|
|
614
|
+
const merged = { ...(agent.meta ?? {}), readyNotifiedAt: at };
|
|
615
|
+
const stored = splitAgentMetaForStorage(merged);
|
|
616
|
+
return getDb().query("UPDATE agents SET meta = ?, profile_projection = ? WHERE id = ?")
|
|
617
|
+
.run(JSON.stringify(stored.meta), stored.profileProjection == null ? null : JSON.stringify(stored.profileProjection), id).changes > 0;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
/** Delete specific keys from an agent's meta blob. Returns true if anything changed. Used to clear
|
|
621
|
+
* the #633 `terminalProviderExit` hold when a dead provider genuinely resumes. */
|
|
622
|
+
export function clearAgentMetaKeys(id: string, keys: string[]): boolean {
|
|
623
|
+
const agent = getAgent(id);
|
|
624
|
+
if (!agent?.meta) return false;
|
|
625
|
+
const meta = { ...agent.meta };
|
|
626
|
+
let changed = false;
|
|
627
|
+
for (const key of keys) {
|
|
628
|
+
if (key in meta) {
|
|
629
|
+
delete meta[key];
|
|
630
|
+
changed = true;
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
if (!changed) return false;
|
|
634
|
+
const stored = splitAgentMetaForStorage(meta);
|
|
635
|
+
return getDb().query("UPDATE agents SET meta = ?, profile_projection = ? WHERE id = ?")
|
|
636
|
+
.run(JSON.stringify(stored.meta), stored.profileProjection == null ? null : JSON.stringify(stored.profileProjection), id).changes > 0;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* #1059 — decide whether a process-exit certificate belongs to an agent row's CURRENT
|
|
641
|
+
* instance. A late/duplicate orchestrator exit report for a SUPERSEDED session (the agent id
|
|
642
|
+
* re-registered as a fresh instance after the report was generated) carries the prior session's
|
|
643
|
+
* `spawnRequestId`; the live successor's meta carries the new one. When both are known and
|
|
644
|
+
* differ, the certificate is for a dead predecessor and must never mark the successor gone.
|
|
645
|
+
* Unknown on either side (legacy / unmanaged sessions that never carried a spawnRequestId) can't
|
|
646
|
+
* be disproven, so it is treated as matching — preserving the pre-#1059 fast-exit path.
|
|
647
|
+
*
|
|
648
|
+
* The single home for the death-certificate/instance identity check, shared by the stamp site
|
|
649
|
+
* (recordAgentExitDiagnostics, below) and the reaper's death predicate (isOwnerProcessConfirmedGone
|
|
650
|
+
* in workspace-merge.ts) so the two can't drift.
|
|
651
|
+
*/
|
|
652
|
+
export function exitCertificateMatchesInstance(
|
|
653
|
+
currentMeta: Record<string, unknown> | undefined,
|
|
654
|
+
certificate: { spawnRequestId?: unknown } | undefined,
|
|
655
|
+
): boolean {
|
|
656
|
+
const current = currentMeta ? stringValue(currentMeta.spawnRequestId) : undefined;
|
|
657
|
+
const cert = certificate ? stringValue(certificate.spawnRequestId) : undefined;
|
|
658
|
+
if (current && cert && current !== cert) return false;
|
|
659
|
+
return true;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
/**
|
|
663
|
+
* The `agents.recordExitDiagnostics` op body (S3 L10 #1895): agent lookup + cert-match check + the
|
|
664
|
+
* merged-meta UPDATE, folded into one unit (the read decides whether the write applies at all, so
|
|
665
|
+
* splitting it across a real thread hop would reopen the #1059 TOCTOU the pre-migration code closed
|
|
666
|
+
* by keeping them in one synchronous call). Returns the EPOCH the exit write stamped (or `null` when
|
|
667
|
+
* no row changed), so the async facade's separate post-commit cleanup jobs can fence on the exact
|
|
668
|
+
* instance identity this write validated — a same-id replacement that registers in the await gap
|
|
669
|
+
* bumps the epoch and its pairs/claims must never be clobbered (#1869 W0.2 race fix). The cross-domain
|
|
670
|
+
* post-write side effects (pair/steward cleanup, presence eviction) stay in the orchestration below —
|
|
671
|
+
* `evictPendingPresence` in particular MUST run main-thread (see `setStatusInternal`'s note).
|
|
672
|
+
*/
|
|
673
|
+
export function recordAgentExitDiagnosticsInternal(
|
|
674
|
+
id: string,
|
|
675
|
+
diagnostics: ManagedSessionExitDiagnostics,
|
|
676
|
+
now: number,
|
|
677
|
+
/** #2111 — taken on the MAIN thread at submission, for the same cross-thread reason as
|
|
678
|
+
* `upsertAgentInternal`'s. */
|
|
679
|
+
lifecycleSeq: number,
|
|
680
|
+
): number | null {
|
|
681
|
+
recordSpawnProcessExit(id, stringValue(diagnostics.spawnRequestId), now);
|
|
682
|
+
const agent = getAgent(id);
|
|
683
|
+
if (!agent) return null;
|
|
684
|
+
// #1059 — drop a stale/duplicate exit report for a SUPERSEDED instance. The agent id
|
|
685
|
+
// re-registered as a fresh session (new spawnRequestId) after this report was generated;
|
|
686
|
+
// stamping its predecessor's certificate here would poison the LIVE successor's row (false
|
|
687
|
+
// offline flip + false death notification via the caller + a certificate the dead-owner reaper
|
|
688
|
+
// would later act on — the #1054 reopener). Returning false makes the caller skip both the status
|
|
689
|
+
// emit and notifyAgentOffline, exactly as for an absent row.
|
|
690
|
+
if (!exitCertificateMatchesInstance(isRecord(agent.meta) ? agent.meta : undefined, diagnostics)) return null;
|
|
691
|
+
revokeVaultTokens(id, now, "confirmed_exit", agent.instanceId, String(agent.meta?.spawnRequestId ?? ""));
|
|
692
|
+
const merged: Record<string, unknown> = {
|
|
693
|
+
...(agent.meta ?? {}),
|
|
694
|
+
lastError: diagnostics.lastError,
|
|
695
|
+
lastExit: diagnostics,
|
|
696
|
+
lastExitAt: diagnostics.detectedAt || now,
|
|
697
|
+
// #1057(1) — RELAY-clock receipt of the process-confirmed death. The orphan-token sweep
|
|
698
|
+
// (revokeOrphanedRuntimeTokens) compares this against last_seen (also relay clock); the
|
|
699
|
+
// orchestrator-clock detectedAt in lastExitAt is not comparable across hosts.
|
|
700
|
+
lastExitReceivedAt: now,
|
|
701
|
+
};
|
|
702
|
+
// #1746 RC-2 — a process-confirmed exit is terminal: drop any in-flight lifecycle pill
|
|
703
|
+
// (shutting-down / killing / kill-failed / restarting) so relay_my_agents and the dashboard don't
|
|
704
|
+
// show a dead agent stuck "shutting down" forever. The MCP surface now checks offline first too, but
|
|
705
|
+
// clearing the underlying meta keeps every consumer of agent.meta in agreement.
|
|
706
|
+
delete merged.lifecycleAction;
|
|
707
|
+
delete merged.lifecycleActionAt;
|
|
708
|
+
delete merged.lifecycleCommandId;
|
|
709
|
+
// #1746 fwd BLOCKER — also drop the watchdog's one-shot escalation marker on the confirmed exit, so
|
|
710
|
+
// a re-registered/reused agent row starts its next shutdown with a fresh shot instead of inheriting a
|
|
711
|
+
// stale stamp that would fast-path it to kill-failed.
|
|
712
|
+
delete merged.shutdownWatchdogEscalatedAt;
|
|
713
|
+
delete merged.lifecycleShutdownTimeoutMs;
|
|
714
|
+
const stored = splitAgentMetaForStorage(merged);
|
|
715
|
+
// #636 — do NOT clobber last_seen with `now`: it is the agent's genuine last heartbeat, and the
|
|
716
|
+
// death diagnosis derives the real heartbeat gap from it (the orchestrator exit path diagnoses
|
|
717
|
+
// off the row returned here). "When we detected the exit" lives in meta.lastExitAt instead.
|
|
718
|
+
// #2111 review BLOCKER 1 — this is the CONFIRMED-death certificate, the transition that must never
|
|
719
|
+
// be undone. Advancing the lifecycle fence here is what stops a `setStatus`/`markReady` still
|
|
720
|
+
// sitting in the coalescing window from committing afterwards and reviving the dead row.
|
|
721
|
+
const result = getDb()
|
|
722
|
+
.query(`UPDATE agents SET ${fencedColumnSql("status", "'offline'", "$seq")}, ${fencedColumnSql("ready", "0", "$seq")}`
|
|
723
|
+
+ ", meta = $meta, profile_projection = $profileProjection WHERE id = $id")
|
|
724
|
+
.run({
|
|
725
|
+
$seq: lifecycleSeq,
|
|
726
|
+
$meta: JSON.stringify(stored.meta),
|
|
727
|
+
$profileProjection: stored.profileProjection == null ? null : JSON.stringify(stored.profileProjection),
|
|
728
|
+
$id: id,
|
|
729
|
+
} as never);
|
|
730
|
+
return result.changes > 0 ? agent.epoch : null;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
export function recordAgentExitDiagnostics(id: string, diagnostics: ManagedSessionExitDiagnostics, now: number = Date.now()): AgentCard | null {
|
|
734
|
+
const lifecycleSeq = nextLifecycleSeq();
|
|
735
|
+
const stampedEpoch = writeTransaction(() => recordAgentExitDiagnosticsInternal(id, diagnostics, now, lifecycleSeq));
|
|
736
|
+
// Sync path has no event-loop yield between this write and the cleanup below, so no replacement can
|
|
737
|
+
// interleave — the epoch is threaded only for the async facade's fencing (#1869 W0.2). `=== null` not
|
|
738
|
+
// truthiness: epoch 0 is a valid instance (instance-less agents), see setStatusInternal.
|
|
739
|
+
if (stampedEpoch === null) return null;
|
|
740
|
+
// #1468 — this terminal write bypasses setStatus, so evict any buffered beat here too.
|
|
741
|
+
evictPendingPresence(id);
|
|
742
|
+
// #1789 part 2 (review F2) — THIS is the confirmed process-exit certificate (matched to the current
|
|
743
|
+
// instance above, so a superseded/re-registered id's stale report can never fire it). Release the
|
|
744
|
+
// gone steward's workspace claim here — not on setStatus(offline) — so a live-but-partitioned steward
|
|
745
|
+
// mid-land keeps its lease while a genuinely-dead one's stale lease no longer wedges its replacement.
|
|
746
|
+
closeOpenPairsForAgent(id, now); releaseWorkspaceClaimsForAgent(id, now);
|
|
747
|
+
return getAgent(id);
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
/**
|
|
751
|
+
* `seq` (#2111 review BLOCKER 1) fences the RESURRECTION CASE below. A beat that the coalescing window
|
|
752
|
+
* deferred would otherwise flip an `offline`/`stale` row back to `idle` after a newer synchronous
|
|
753
|
+
* transition put it there — the orchestrator-heartbeat variant of the lost-terminal-transition bug.
|
|
754
|
+
* Only the deferred caller (`orchestrators.heartbeat`) passes one; the immediate paths leave it
|
|
755
|
+
* undefined and the write behaves exactly as before, since a beat that is not deferred cannot lose an
|
|
756
|
+
* ordering race it never entered.
|
|
757
|
+
*/
|
|
758
|
+
export function heartbeat(
|
|
759
|
+
id: string,
|
|
760
|
+
guard?: AgentSessionGuard,
|
|
761
|
+
runtime?: { providerCapabilities?: ProviderCapabilities; context?: ContextState; quota?: QuotaState },
|
|
762
|
+
now: number = Date.now(),
|
|
763
|
+
seq?: number,
|
|
764
|
+
): boolean {
|
|
765
|
+
if (!validateAgentSession(id, guard).ok) return false;
|
|
766
|
+
// The resurrection is the only lifecycle CLAIM a beat makes, so that is all the fence covers: with
|
|
767
|
+
// `seq` supplied it flips offline/stale → idle only while no later-submitted status write has landed,
|
|
768
|
+
// and raises `status_seq` ONLY in that case (a beat that resurrects nothing must not consume an
|
|
769
|
+
// ordinal other writers are ordered against). Without `seq` the write is exactly as it was — a beat
|
|
770
|
+
// that is not deferred cannot lose an ordering race it never entered.
|
|
771
|
+
const RESURRECT_WHEN = "status IN ('offline', 'stale')";
|
|
772
|
+
const statusSet = seq !== undefined
|
|
773
|
+
? fencedColumnSql("status", "'idle'", "$seq", { when: RESURRECT_WHEN })
|
|
774
|
+
: `status = CASE WHEN ${RESURRECT_WHEN} THEN 'idle' ELSE status END`;
|
|
775
|
+
if (runtime?.providerCapabilities || runtime?.context || runtime?.quota) {
|
|
776
|
+
const contextState = mergeRelayContextMarkers(id, runtime.context);
|
|
777
|
+
const params: Record<string, unknown> = {
|
|
778
|
+
$now: now,
|
|
779
|
+
$pc: runtime.providerCapabilities ? JSON.stringify(runtime.providerCapabilities) : null,
|
|
780
|
+
$cx: contextState ? JSON.stringify(contextState) : null,
|
|
781
|
+
$qs: runtime.quota ? JSON.stringify(runtime.quota) : null,
|
|
782
|
+
$id: id,
|
|
783
|
+
};
|
|
784
|
+
if (seq !== undefined) params.$seq = seq;
|
|
785
|
+
const result = getDb()
|
|
786
|
+
.query(`
|
|
787
|
+
UPDATE agents SET
|
|
788
|
+
last_seen = $now,
|
|
789
|
+
${statusSet},
|
|
790
|
+
provider_capabilities = coalesce($pc, provider_capabilities),
|
|
791
|
+
context_state = coalesce($cx, context_state),
|
|
792
|
+
quota_state = coalesce($qs, quota_state)
|
|
793
|
+
WHERE id = $id
|
|
794
|
+
`)
|
|
795
|
+
.run(params as never);
|
|
796
|
+
if (result.changes > 0 && contextState) recordContextSnapshot(id, contextState, now);
|
|
797
|
+
return result.changes > 0;
|
|
798
|
+
}
|
|
799
|
+
const params: Record<string, unknown> = { $now: now, $id: id };
|
|
800
|
+
if (seq !== undefined) params.$seq = seq;
|
|
801
|
+
const result = getDb()
|
|
802
|
+
.query(`UPDATE agents SET last_seen = $now, ${statusSet} WHERE id = $id`)
|
|
803
|
+
.run(params as never);
|
|
804
|
+
return result.changes > 0;
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
// #1468 — heartbeat presence write-coalescing buffer.
|
|
808
|
+
//
|
|
809
|
+
// PROBLEM: the SDK sends a heartbeat every ~30s per agent (bus.ts) carrying `status` (always) and
|
|
810
|
+
// usually `context`/`providerCapabilities`. The bus path used to persist that with TWO synchronous
|
|
811
|
+
// row writes per beat — `heartbeat()` (last_seen + runtime cols) AND `setStatus()` (which rewrites
|
|
812
|
+
// the row even when status is unchanged). bun:sqlite is synchronous, so at fleet scale on the 2012
|
|
813
|
+
// macmini2 that scattered write frequency is the top CONSTANT event-loop-lag source.
|
|
814
|
+
//
|
|
815
|
+
// FIX: hold each agent's latest presence in memory and persist the whole DIRTY set in ONE batched
|
|
816
|
+
// `UPDATE ... FROM json_each` per flush (PRESENCE_FLUSH_MS, default 5s) — N scattered writes/period
|
|
817
|
+
// collapse to a single statement. `recordHeartbeat` is the entry point for the hot bus/API heartbeat
|
|
818
|
+
// paths; it BYPASSES the buffer and writes synchronously only for presence-critical transitions
|
|
819
|
+
// (status change — e.g. busy→idle for #1465/#1466 — and offline/stale resurrection), so a genuinely
|
|
820
|
+
// changed presence still flips promptly. Steady-state no-change beats are coalesced.
|
|
821
|
+
//
|
|
822
|
+
// SAFETY: `last_seen` advances monotonically on flush (MAX), so the #1465 transportLiveAt floor and
|
|
823
|
+
// the isLive/routing reads never regress; the persisted value is at most PRESENCE_FLUSH_MS stale,
|
|
824
|
+
// 24× under the 120s STALE_TTL. The stale reaper flushes the buffer synchronously first
|
|
825
|
+
// (`reapStaleAgents`), so a coalesced-but-live agent is never mis-reaped. A crash loses ≤ one flush
|
|
826
|
+
// interval of last_seen advance — harmless (the agent looks ≤5s staler, still ≪ 120s).
|
|
827
|
+
// PendingPresence, the buffer Map, and the read-side accessors (evictPendingPresence /
|
|
828
|
+
// withBufferedPresence / bufferedLiveAgentIds) live in the leaf module ./presence-buffer.ts so every
|
|
829
|
+
// liveness reader can fold in the buffer without an import cycle (agents.ts imports channels.ts).
|
|
830
|
+
|
|
831
|
+
/**
|
|
832
|
+
* Hot-path heartbeat entry point for the bus/API transports. Coalesces the steady-state liveness
|
|
833
|
+
* advance into the in-memory buffer (flushed by `flushPresence`), but writes synchronously for
|
|
834
|
+
* presence-critical transitions. Returns false if the session guard rejects or the agent is gone.
|
|
835
|
+
*/
|
|
836
|
+
export function recordHeartbeat(
|
|
837
|
+
id: string,
|
|
838
|
+
opts: {
|
|
839
|
+
guard?: AgentSessionGuard;
|
|
840
|
+
/** Semantic status reported by the beat (bus path); undefined for the runtime-less API path. */
|
|
841
|
+
status?: AgentCard["status"];
|
|
842
|
+
runtime?: { providerCapabilities?: ProviderCapabilities; context?: ContextState; quota?: QuotaState };
|
|
843
|
+
now?: number;
|
|
844
|
+
} = {},
|
|
845
|
+
): boolean {
|
|
846
|
+
if (!validateAgentSession(id, opts.guard).ok) return false;
|
|
847
|
+
const current = getAgent(id);
|
|
848
|
+
if (!current) return false;
|
|
849
|
+
const now = opts.now ?? Date.now();
|
|
850
|
+
|
|
851
|
+
// Presence-critical transitions must persist NOW, not at the next flush: a status change
|
|
852
|
+
// (busy→idle etc. — the #1465/#1466 surface) and a resurrection of an offline/stale row both
|
|
853
|
+
// flip liveness/availability that downstream readers and message-flush logic act on immediately.
|
|
854
|
+
// A context lifecycleState transition is equally critical — isAgentUnavailable() (message-queue
|
|
855
|
+
// gating, #416) keys off lifecycleState (compacting / clearing-context) — so a CHANGE in it also
|
|
856
|
+
// bypasses the buffer; only benign same-lifecycle utilization drift is coalesced.
|
|
857
|
+
const resurrection = current.status === "offline" || current.status === "stale";
|
|
858
|
+
const statusChanged = opts.status !== undefined && opts.status !== current.status;
|
|
859
|
+
const lifecycleTransition =
|
|
860
|
+
opts.runtime?.context !== undefined &&
|
|
861
|
+
opts.runtime.context.lifecycleState !== current.context?.lifecycleState;
|
|
862
|
+
const prev = pendingPresence.get(id);
|
|
863
|
+
if (resurrection || statusChanged || lifecycleTransition) {
|
|
864
|
+
// Merge any buffered-but-unflushed runtime cols into this synchronous write so the bypass never
|
|
865
|
+
// DISCARDS a coalesced advance (a beat that carried context but was buffered, then a status
|
|
866
|
+
// change arrives carrying none). Per column: this beat wins, else the pending value.
|
|
867
|
+
const runtime = prev
|
|
868
|
+
? {
|
|
869
|
+
providerCapabilities: opts.runtime?.providerCapabilities ?? prev.providerCapabilities,
|
|
870
|
+
context: opts.runtime?.context ?? prev.context,
|
|
871
|
+
quota: opts.runtime?.quota ?? prev.quota,
|
|
872
|
+
}
|
|
873
|
+
: opts.runtime;
|
|
874
|
+
pendingPresence.delete(id); // this synchronous write supersedes any buffered advance
|
|
875
|
+
// #2111 — was `heartbeat()` (one UPDATE) followed by `setStatus()` (a second UPDATE of the SAME
|
|
876
|
+
// row inside its own BEGIN IMMEDIATE). One consolidated update now carries both; the explicit
|
|
877
|
+
// status overrides the resurrection CASE exactly as the second write used to.
|
|
878
|
+
return applyAgentLifecycleUpdate(
|
|
879
|
+
id,
|
|
880
|
+
{ status: statusChanged ? opts.status : undefined, resurrectOnBeat: true, runtime },
|
|
881
|
+
opts.guard,
|
|
882
|
+
now,
|
|
883
|
+
).changed;
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
// Steady state: buffer. Merge context advisory markers now (matches heartbeat()'s per-beat merge),
|
|
887
|
+
// carrying forward the freshest of {this beat, an earlier un-flushed beat} for each column. The
|
|
888
|
+
// entry is epoch-bound so a flush can't apply it to a successor instance after a takeover.
|
|
889
|
+
const merged = opts.runtime?.context ? mergeRelayContextMarkers(id, opts.runtime.context) : undefined;
|
|
890
|
+
pendingPresence.set(id, {
|
|
891
|
+
epoch: current.epoch,
|
|
892
|
+
lastSeen: Math.max(now, prev?.lastSeen ?? current.lastSeen),
|
|
893
|
+
providerCapabilities: opts.runtime?.providerCapabilities ?? prev?.providerCapabilities,
|
|
894
|
+
context: merged ?? prev?.context,
|
|
895
|
+
quota: opts.runtime?.quota ?? prev?.quota,
|
|
896
|
+
});
|
|
897
|
+
return true;
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
/**
|
|
901
|
+
* Persist every buffered heartbeat in ONE batched statement (the #1468 win: N scattered per-agent
|
|
902
|
+
* writes/period → a single UPDATE). `last_seen` advances via MAX (monotonic — never regresses a
|
|
903
|
+
* concurrent fresher write); the resurrection CASE mirrors `heartbeat()` as a backstop; runtime
|
|
904
|
+
* columns COALESCE so an absent value keeps the stored one. Context snapshots are recorded (with
|
|
905
|
+
* their existing 60s debounce) only for agents the UPDATE actually touched, so a row pruned between
|
|
906
|
+
* buffering and flush can't trip the context_snapshots FK. Called on the flush loop, before the
|
|
907
|
+
* stale reaper, and on shutdown.
|
|
908
|
+
*/
|
|
909
|
+
/**
|
|
910
|
+
* Writer-op body for `presence.flush`. The executor already owns the transaction/savepoint, so this
|
|
911
|
+
* deliberately does not call writeTransaction. `now` was captured at gateway submission (H6).
|
|
912
|
+
*/
|
|
913
|
+
export function flushPresencePayloadInternal(payload: PresenceFlushPayload, now: number): string[] {
|
|
914
|
+
if (payload.length === 0) return [];
|
|
915
|
+
// NEVER resurrect: the flush leaves `status` untouched and only touches rows that are still live
|
|
916
|
+
// and still on the buffered beat's epoch. A row that went offline/stale (BLOCKER) or was taken
|
|
917
|
+
// over by a new instance (HIGH) after the beat was buffered is skipped — no reanimation, no
|
|
918
|
+
// predecessor-instance clobber. A genuinely live beat that needs resurrection took the synchronous
|
|
919
|
+
// bypass in recordHeartbeat, so the flush never has to flip status.
|
|
920
|
+
const updated = getDb()
|
|
921
|
+
.query(`
|
|
922
|
+
UPDATE agents AS a SET
|
|
923
|
+
last_seen = MAX(a.last_seen, CAST(j.value ->> 'ls' AS INTEGER)),
|
|
924
|
+
provider_capabilities = COALESCE(j.value ->> 'pc', a.provider_capabilities),
|
|
925
|
+
context_state = COALESCE(j.value ->> 'cx', a.context_state),
|
|
926
|
+
quota_state = COALESCE(j.value ->> 'qs', a.quota_state)
|
|
927
|
+
FROM json_each(?) AS j
|
|
928
|
+
WHERE a.id = j.value ->> 'id'
|
|
929
|
+
AND a.epoch = CAST(j.value ->> 'ep' AS INTEGER)
|
|
930
|
+
AND a.status NOT IN ('offline', 'stale')
|
|
931
|
+
RETURNING id
|
|
932
|
+
`)
|
|
933
|
+
.all(JSON.stringify(payload)) as Array<{ id: string }>;
|
|
934
|
+
const updatedIds = new Set(updated.map((row) => row.id));
|
|
935
|
+
for (const row of payload) {
|
|
936
|
+
const p = row.cx ? JSON.parse(row.cx) as ContextState : undefined;
|
|
937
|
+
if (p && updatedIds.has(row.id)) recordContextSnapshot(row.id, p, now);
|
|
938
|
+
}
|
|
939
|
+
return [...updatedIds];
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
/** Synchronous compatibility path for stale reaping and process teardown. Normal timer ticks use
|
|
943
|
+
* `flushPresenceAsync` from presence-write.ts, which routes this same body through the writer gateway. */
|
|
944
|
+
export function flushPresence(now: number = Date.now()): { flushed: number } {
|
|
945
|
+
const flush = snapshotPendingPresenceFlush();
|
|
946
|
+
if (!flush) return { flushed: 0 };
|
|
947
|
+
const ids = writeTransaction(() => flushPresencePayloadInternal(flush.payload, now));
|
|
948
|
+
// Clear only after commit. `settle` is identity-aware so a future async caller cannot erase a beat
|
|
949
|
+
// that arrived while its earlier snapshot was in flight.
|
|
950
|
+
settlePendingPresenceFlush(flush);
|
|
951
|
+
return { flushed: ids.length };
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
export function listContextSnapshots(agentId: string, options: { since?: number; limit?: number } = {}): ContextSnapshot[] {
|
|
955
|
+
const limit = Math.max(1, Math.min(options.limit ?? 288, 1000));
|
|
956
|
+
const params: any[] = [agentId];
|
|
957
|
+
let sql = "SELECT * FROM context_snapshots WHERE agent_id = ?";
|
|
958
|
+
if (options.since !== undefined) {
|
|
959
|
+
sql += " AND captured_at >= ?";
|
|
960
|
+
params.push(options.since);
|
|
961
|
+
}
|
|
962
|
+
sql += " ORDER BY captured_at ASC, id ASC LIMIT ?";
|
|
963
|
+
params.push(limit);
|
|
964
|
+
return (getDb().query(sql).all(...params) as any[]).map(rowToContextSnapshot);
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
export function listQuotaSnapshots(agentId: string, options: { since?: number; limit?: number } = {}): QuotaSnapshot[] {
|
|
968
|
+
const agent = getAgent(agentId);
|
|
969
|
+
if (!agent) return [];
|
|
970
|
+
return listAgentQuotaSnapshotsFromProviderStore(agent, options);
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
/** Debounced snapshot insert; retention runs separately in snapshot-ledger-prune. */
|
|
974
|
+
export function recordContextSnapshot(agentId: string, context: ContextState, now: number): void {
|
|
975
|
+
const latest = getDb()
|
|
976
|
+
.query("SELECT captured_at FROM context_snapshots WHERE agent_id = ? ORDER BY captured_at DESC LIMIT 1")
|
|
977
|
+
.get(agentId) as { captured_at: number } | undefined;
|
|
978
|
+
if (latest && latest.captured_at > now - CONTEXT_SNAPSHOT_DEBOUNCE_MS) return;
|
|
979
|
+
|
|
980
|
+
getDb().query(`
|
|
981
|
+
INSERT INTO context_snapshots (
|
|
982
|
+
agent_id,
|
|
983
|
+
utilization,
|
|
984
|
+
lifecycle_state,
|
|
985
|
+
tokens_used,
|
|
986
|
+
tokens_max,
|
|
987
|
+
source,
|
|
988
|
+
confidence,
|
|
989
|
+
context_state,
|
|
990
|
+
captured_at
|
|
991
|
+
)
|
|
992
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
993
|
+
`).run(
|
|
994
|
+
agentId,
|
|
995
|
+
context.utilization,
|
|
996
|
+
context.lifecycleState,
|
|
997
|
+
context.tokensUsed ?? null,
|
|
998
|
+
context.tokensMax ?? null,
|
|
999
|
+
context.source,
|
|
1000
|
+
context.confidence,
|
|
1001
|
+
JSON.stringify(context),
|
|
1002
|
+
now,
|
|
1003
|
+
);
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
function mergeRelayContextMarkers(agentId: string, next: ContextState | undefined): ContextState | undefined {
|
|
1007
|
+
if (!next) return undefined;
|
|
1008
|
+
const row = getDb().query("SELECT context_state FROM agents WHERE id = ?").get(agentId) as { context_state?: string | null } | undefined;
|
|
1009
|
+
const previous = row?.context_state ? parseJson<ContextState | undefined>(row.context_state, undefined) : undefined;
|
|
1010
|
+
if (!previous) return next;
|
|
1011
|
+
return {
|
|
1012
|
+
...next,
|
|
1013
|
+
lastContextAdvisoryBand: next.lastContextAdvisoryBand ?? previous.lastContextAdvisoryBand,
|
|
1014
|
+
lastContextAdvisoryAt: next.lastContextAdvisoryAt ?? previous.lastContextAdvisoryAt,
|
|
1015
|
+
};
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
|
|
1019
|
+
/**
|
|
1020
|
+
* The `agents.reapStale` op body (S3 L10 #1895): the stale-marking sweep only — deliberately
|
|
1021
|
+
* EXCLUDES the `flushPresence` pre-flush (see `reapStaleAgents`), which reads the main-thread-only
|
|
1022
|
+
* `pendingPresence` buffer and would silently no-op on a writer-worker thread (the exact
|
|
1023
|
+
* stale-read-on-async class the S3.1 L4 landmine warned about; caught during this migration).
|
|
1024
|
+
*
|
|
1025
|
+
* `protectedIds` (review fix, finding 1 — CONFIRMED HIGH): ids the ASYNC caller observed with a
|
|
1026
|
+
* still-fresh buffered beat at submission time — see `reapStaleAgentsAsync`'s doc comment for the
|
|
1027
|
+
* race this closes. Always `[]` for the sync `reapStaleAgents` path (no gap to close there).
|
|
1028
|
+
*/
|
|
1029
|
+
export function reapStaleAgentsInternal(
|
|
1030
|
+
ttlMs: number,
|
|
1031
|
+
lagGraceMs: number,
|
|
1032
|
+
now: number,
|
|
1033
|
+
protectedIds: string[] = [],
|
|
1034
|
+
/** #2111 round-3 review — the ordering fence. This is a TERMINAL transition, so a lifecycle write
|
|
1035
|
+
* still sitting in the coalescing window (submitted before this sweep) must not commit afterwards
|
|
1036
|
+
* and revive a reaped agent. Allocated at the caller's synchronous submission point. */
|
|
1037
|
+
seq: number = nextLifecycleSeq(),
|
|
1038
|
+
): string[] {
|
|
1039
|
+
// #1048 — extend the stale cutoff by the relay's own recently-observed event-loop
|
|
1040
|
+
// lag. A missed heartbeat while THIS process was stalled means "the relay couldn't
|
|
1041
|
+
// read it", not "the agent died"; the caller passes the grace in (this module stays
|
|
1042
|
+
// health-agnostic). lagGraceMs of 0 is the pre-#1048 behavior.
|
|
1043
|
+
const cutoff = now - ttlMs - Math.max(0, lagGraceMs);
|
|
1044
|
+
getDb().query(`UPDATE agents SET last_seen = ? WHERE ${reservedAgentIdSql()}`).run(now);
|
|
1045
|
+
const guard = protectedIds.length > 0
|
|
1046
|
+
? ` AND id NOT IN (${protectedIds.map((_, i) => `$p${i}`).join(",")})`
|
|
1047
|
+
: "";
|
|
1048
|
+
const params: Record<string, unknown> = { $seq: seq, $cutoff: cutoff };
|
|
1049
|
+
protectedIds.forEach((protectedId, i) => { params[`$p${i}`] = protectedId; });
|
|
1050
|
+
// The status fence is a WHERE clause rather than a CASE because this sweep RETURNS the rows it
|
|
1051
|
+
// reaped: a row a later-submitted write already claimed must not be reaped at all, and must not be
|
|
1052
|
+
// announced as stale. `ready` is fenced separately (an independently newer markReady survives).
|
|
1053
|
+
const rows = getDb()
|
|
1054
|
+
.query(
|
|
1055
|
+
`UPDATE agents SET status = 'stale', status_seq = $seq, ${fencedColumnSql("ready", "0", "$seq")}`
|
|
1056
|
+
+ ` WHERE status NOT IN ('offline', 'stale') AND last_seen < $cutoff AND NOT ${reservedAgentIdSql()}`
|
|
1057
|
+
+ ` AND status_seq < $seq${guard} RETURNING id`,
|
|
1058
|
+
)
|
|
1059
|
+
.all(params as never) as any[];
|
|
1060
|
+
for (const row of rows) {
|
|
1061
|
+
// #1051 — liveness ≠ credential validity. A lapsed heartbeat is a transient,
|
|
1062
|
+
// recoverable observation (the relay may have stalled, or the network blipped);
|
|
1063
|
+
// it marks status only and must NOT void a still-unexpired token. On reconnect the
|
|
1064
|
+
// relay accepts the agent's EXISTING token and re-marks it live. The #484 restart-
|
|
1065
|
+
// strand invariant (an orphaned prior-instance token must not stay usable) is now
|
|
1066
|
+
// enforced on instance takeover instead — see revokeSupersededRuntimeTokens, fired
|
|
1067
|
+
// from registerAgent when a fresh process re-registers under a new instanceId.
|
|
1068
|
+
closeOpenPairsForAgent(row.id, now);
|
|
1069
|
+
}
|
|
1070
|
+
return rows.map((r: any) => r.id);
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
export function reapStaleAgents(ttlMs: number = STALE_TTL_MS, lagGraceMs = 0): string[] {
|
|
1074
|
+
const now = Date.now();
|
|
1075
|
+
// #1468 — persist buffered heartbeats BEFORE evaluating staleness, so a live agent whose
|
|
1076
|
+
// last_seen advance was only coalesced in memory is never mis-reaped as stale. This is the one
|
|
1077
|
+
// read path that needs a synchronous flush-before; the isLive/routing reads tolerate a ≤5s-stale
|
|
1078
|
+
// persisted value (far under the 120s TTL) and stay lock-free.
|
|
1079
|
+
flushPresence(now);
|
|
1080
|
+
const seq = nextLifecycleSeq();
|
|
1081
|
+
return writeTransaction(() => reapStaleAgentsInternal(ttlMs, lagGraceMs, now, [], seq));
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
export { settleSingleTargetOnDemandTasks } from "./task-maintenance.ts";
|
|
1085
|
+
|
|
1086
|
+
/**
|
|
1087
|
+
* The `agents.pruneOffline` op body (S3 L10 #1895): everything the pre-migration `writeTransaction`
|
|
1088
|
+
* closure did, MINUS `evictPendingPresence` (main-thread-only buffer, see `setStatusInternal`) and
|
|
1089
|
+
* the `beforeDelete` callback (a JS closure — not structured-clone-safe across a real thread hop, so
|
|
1090
|
+
* it cannot ride in op args; see `pruneOfflineAgents`). `revokeRuntimeTokensForAgent` /
|
|
1091
|
+
* `closeOpenPairsForAgent` / `removeSubscriptionsForAgent` / `settleSingleTargetOnDemandTasks` are
|
|
1092
|
+
* plain `getDb()`-based helpers with no main-thread state, so they run correctly on any thread.
|
|
1093
|
+
*/
|
|
1094
|
+
export function pruneOfflineAgentsInternal(cutoff: number, now: number, beforeDelete?: (agentId: string) => void): string[] {
|
|
1095
|
+
const rows = getDb()
|
|
1096
|
+
.query(
|
|
1097
|
+
`SELECT id FROM agents WHERE status = 'offline' AND last_seen < ? AND NOT ${reservedAgentIdSql()}`
|
|
1098
|
+
)
|
|
1099
|
+
.all(cutoff) as any[];
|
|
1100
|
+
if (rows.length === 0) return [];
|
|
1101
|
+
|
|
1102
|
+
// Release claims held by pruned agents so unfinished work becomes claimable again — but
|
|
1103
|
+
// never for a message whose task is already closed: nulling that claim resurrects completed
|
|
1104
|
+
// work on the next restart (the task release below is already guarded the same way).
|
|
1105
|
+
getDb()
|
|
1106
|
+
.query(
|
|
1107
|
+
`UPDATE messages SET claimed_by = NULL, claimed_at = NULL, claim_expires_at = NULL WHERE claimed_by IN (SELECT id FROM agents WHERE status = 'offline' AND last_seen < ? AND NOT ${reservedAgentIdSql()}) AND NOT ${messageTaskClosed("messages.id")}`
|
|
1108
|
+
)
|
|
1109
|
+
.run(cutoff);
|
|
1110
|
+
|
|
1111
|
+
const offlineClaimCondition = `claimed_by IN (SELECT id FROM agents WHERE status = 'offline' AND last_seen < ? AND NOT ${reservedAgentIdSql()})`;
|
|
1112
|
+
settleSingleTargetOnDemandTasks(offlineClaimCondition, [cutoff], now, "agent-pruned");
|
|
1113
|
+
|
|
1114
|
+
getDb()
|
|
1115
|
+
.query(
|
|
1116
|
+
`UPDATE tasks SET status = 'open', claimed_by = NULL, claimed_at = NULL, claim_expires_at = NULL, updated_at = ? WHERE ${claimTaskWhere()} AND ${offlineClaimCondition} AND status IN ('claimed', 'in_progress', 'blocked')`
|
|
1117
|
+
)
|
|
1118
|
+
.run(now, cutoff);
|
|
1119
|
+
|
|
1120
|
+
for (const row of rows) {
|
|
1121
|
+
// Offline past the prune horizon and being deleted — a hard kill, not recoverable.
|
|
1122
|
+
beforeDelete?.(row.id);
|
|
1123
|
+
revokeRuntimeTokensForAgent(row.id, now, "pruned");
|
|
1124
|
+
closeOpenPairsForAgent(row.id, now);
|
|
1125
|
+
removeSubscriptionsForAgent(row.id);
|
|
1126
|
+
clearAgentNotices(row.id);
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
getDb()
|
|
1130
|
+
.query(
|
|
1131
|
+
`DELETE FROM agents WHERE status = 'offline' AND last_seen < ? AND NOT ${reservedAgentIdSql()}`
|
|
1132
|
+
)
|
|
1133
|
+
.run(cutoff);
|
|
1134
|
+
|
|
1135
|
+
return rows.map((r: any) => r.id);
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
export function pruneOfflineAgents(
|
|
1139
|
+
maxOfflineMs: number = DAY_MS,
|
|
1140
|
+
opts?: {
|
|
1141
|
+
/**
|
|
1142
|
+
* #1084 crash-final-loss fix-forward — defense-in-depth for a held work-final ring that
|
|
1143
|
+
* somehow survived to prune time (the primary flush is `notifyAgentOffline`, fired when the
|
|
1144
|
+
* agent first goes offline). Called per pruned agent id BEFORE its row is deleted, so a
|
|
1145
|
+
* caller can flush any still-held final report while `getAgent(id)` can still resolve it —
|
|
1146
|
+
* kept a plain callback (not a direct import) so this db-layer module stays free of
|
|
1147
|
+
* service/SSE-layer dependencies.
|
|
1148
|
+
*/
|
|
1149
|
+
beforeDelete?: (agentId: string) => void;
|
|
1150
|
+
},
|
|
1151
|
+
): string[] {
|
|
1152
|
+
const cutoff = Date.now() - maxOfflineMs;
|
|
1153
|
+
// Lock-free candidate pre-check (#1432 review R2 — the releaseExpiredClaims pattern). This offline
|
|
1154
|
+
// reaper runs periodically and almost always has nothing to prune. Entering BEGIN IMMEDIATE
|
|
1155
|
+
// unconditionally would make that no-op path BLOCK on busy_timeout (~1s stall, then throw) whenever an
|
|
1156
|
+
// unrelated writer holds the lock — strictly worse than the old deferred read's ~0ms. This EXISTS is a
|
|
1157
|
+
// plain deferred read that takes NO write lock; only a real candidate pays for BEGIN IMMEDIATE below,
|
|
1158
|
+
// which re-reads under the lock (TOCTOU-safe).
|
|
1159
|
+
const hasCandidate = getDb()
|
|
1160
|
+
.query(`SELECT EXISTS(SELECT 1 FROM agents WHERE status = 'offline' AND last_seen < ? AND NOT ${reservedAgentIdSql()}) AS n`)
|
|
1161
|
+
.get(cutoff) as { n: number };
|
|
1162
|
+
if (!hasCandidate.n) return [];
|
|
1163
|
+
const now = Date.now();
|
|
1164
|
+
const prunedIds = writeTransaction(() => pruneOfflineAgentsInternal(cutoff, now, opts?.beforeDelete));
|
|
1165
|
+
for (const id of prunedIds) evictPendingPresence(id); // #1468 — no buffered beat should outlive a pruned row
|
|
1166
|
+
return prunedIds;
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
/** The `agents.delete` op body (S3 L10 #1895): the pre-migration transaction closure minus
|
|
1170
|
+
* `evictPendingPresence` (main-thread-only buffer — see `setStatusInternal`'s note). */
|
|
1171
|
+
export function deleteAgentInternal(id: string, now: number): boolean {
|
|
1172
|
+
// Release any claims held by this agent so the tasks become claimable again — except for
|
|
1173
|
+
// messages whose task is already closed (releasing those resurrects finished work).
|
|
1174
|
+
// from_agent is left intact as historical record.
|
|
1175
|
+
getDb().query(`UPDATE messages SET claimed_by = NULL, claimed_at = NULL, claim_expires_at = NULL WHERE claimed_by = ? AND NOT ${messageTaskClosed("messages.id")}`).run(id);
|
|
1176
|
+
settleSingleTargetOnDemandTasks("claimed_by = ?", [id], now, "agent-removed");
|
|
1177
|
+
getDb().query(`UPDATE tasks SET status = 'open', claimed_by = NULL, claimed_at = NULL, claim_expires_at = NULL, updated_at = ? WHERE ${claimTaskWhere()} AND claimed_by = ? AND status IN ('claimed', 'in_progress', 'blocked')`).run(now, id);
|
|
1178
|
+
revokeRuntimeTokensForAgent(id, now);
|
|
1179
|
+
closeOpenPairsForAgent(id, now);
|
|
1180
|
+
removeSubscriptionsForAgent(id);
|
|
1181
|
+
clearAgentNotices(id);
|
|
1182
|
+
return getDb().query("DELETE FROM agents WHERE id = ?").run(id).changes > 0;
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
export function deleteAgent(id: string): { ok: boolean; error?: string } {
|
|
1186
|
+
if (isReservedAgentId(id)) {
|
|
1187
|
+
return { ok: false, error: "built-in agent cannot be deleted" };
|
|
1188
|
+
}
|
|
1189
|
+
const now = Date.now();
|
|
1190
|
+
const deleted = writeTransaction(() => deleteAgentInternal(id, now));
|
|
1191
|
+
evictPendingPresence(id); // #1468 — no buffered beat should outlive the deleted row
|
|
1192
|
+
return deleted ? { ok: true } : { ok: false, error: "agent not found" };
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
// #1057(1) — close the orphan-token window #1051 left open. A dead runner with no replacement
|
|
1196
|
+
// used to keep its token valid until the 24h offline prune (~720× the pre-#1051 ~2min horizon).
|
|
1197
|
+
// This sweep revokes ("stale", re-mintable — #484) the runtime tokens of agents whose process the
|
|
1198
|
+
// orchestrator CONFIRMED dead (meta.lastExit, the #1054 signal — never a liveness inference, so
|
|
1199
|
+
// the #1051 decouple holds) once a full grace has passed with no heartbeat since the relay
|
|
1200
|
+
// received the report. The two guards make a late exit report harmless to a live replacement:
|
|
1201
|
+
// - a replacement registration replaces meta wholesale (no lastExitReceivedAt) → excluded;
|
|
1202
|
+
// - a replacement that got the late report stamped ONTO its row keeps heartbeating, pushing
|
|
1203
|
+
// last_seen past the receipt (heartbeat also flips it off 'offline') → excluded.
|
|
1204
|
+
// `lagGraceMs` mirrors the stale reaper's #1048/#1055 discipline: while the relay's own event
|
|
1205
|
+
// loop was stalled, a live claimant's heartbeats may not have been processed yet, so the window
|
|
1206
|
+
// widens by the observed lag rather than misreading the backlog as post-mortem silence.
|
|
1207
|
+
export function revokeOrphanedRuntimeTokens(graceMs: number = STALE_TTL_MS, lagGraceMs = 0, now = Date.now()): Array<{ agentId: string; jtis: string[] }> {
|
|
1208
|
+
const cutoff = now - graceMs - Math.max(0, lagGraceMs);
|
|
1209
|
+
const rows = getDb()
|
|
1210
|
+
.query(`SELECT id, meta, last_seen FROM agents WHERE status = 'offline' AND meta LIKE '%lastExitReceivedAt%' AND NOT ${reservedAgentIdSql()}`)
|
|
1211
|
+
.all() as Array<{ id: string; meta: string | null; last_seen: number }>;
|
|
1212
|
+
const revoked: Array<{ agentId: string; jtis: string[] }> = [];
|
|
1213
|
+
for (const row of rows) {
|
|
1214
|
+
const meta = parseJson<Record<string, unknown>>(row.meta ?? "{}", {});
|
|
1215
|
+
const receivedAt = typeof meta.lastExitReceivedAt === "number" ? meta.lastExitReceivedAt : undefined;
|
|
1216
|
+
if (receivedAt === undefined || receivedAt > cutoff) continue;
|
|
1217
|
+
if (row.last_seen > receivedAt) continue;
|
|
1218
|
+
const jtis = revokeProviderRuntimeTokensByJti(runtimeTokenJtisFromMeta(meta), "stale", now);
|
|
1219
|
+
if (jtis.length > 0) revoked.push({ agentId: row.id, jtis });
|
|
1220
|
+
}
|
|
1221
|
+
return revoked;
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
// #484: `reason` is stamped on each revocation so a stale-on-restart revocation
|
|
1225
|
+
// (recoverable via orchestrator re-mint for a still-live process) is distinguishable
|
|
1226
|
+
// from a hard kill. Default "agent-removed" (hard) — callers that revoke a possibly-
|
|
1227
|
+
// live process across a restart MUST pass "stale".
|
|
1228
|
+
export function revokeRuntimeTokensForAgent(agentId: string, now = Date.now(), reason: LineageRevokeReason = "agent-removed"): string[] {
|
|
1229
|
+
revokeVaultTokens(agentId, now, reason);
|
|
1230
|
+
const row = getDb().query("SELECT meta FROM agents WHERE id = ?").get(agentId) as { meta?: string } | undefined;
|
|
1231
|
+
const jtis = runtimeTokenJtisFromMeta(parseJson(row?.meta ?? "{}", {}));
|
|
1232
|
+
return revokeProviderRuntimeTokensByJti(jtis, reason, now);
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
// #1051 — the #484 restart-strand invariant, re-homed from heartbeat-lapse to instance
|
|
1236
|
+
// takeover. Staleness (a missed heartbeat) no longer revokes anything; instead, when a
|
|
1237
|
+
// FRESH runner process re-registers under an existing agent id — a new instanceId, which
|
|
1238
|
+
// bumps the agent epoch — the PRIOR instance's runtime tokens are revoked "stale" here,
|
|
1239
|
+
// atomically with the bump (fired from inside upsertAgent). "stale" (not a hard kill)
|
|
1240
|
+
// keeps them re-mintable via the orchestrator (#484), so a live process that merely
|
|
1241
|
+
// rotated instances still self-heals, while an orphaned prior-instance token can no
|
|
1242
|
+
// longer authenticate a request directly. A same-instance reconnect (relay-restart / lag
|
|
1243
|
+
// recovery) keeps its instanceId, does not bump the epoch, and so never reaches this
|
|
1244
|
+
// path — its token stays valid untouched.
|
|
1245
|
+
// #1057(3) — `keepJtis` must be SERVER-verified (the jti of the token that authenticated the
|
|
1246
|
+
// registration, resolved to this very agent — see registerAgent). It is never derived from the
|
|
1247
|
+
// incoming client meta: a takeover caller could otherwise list the prior jti in meta.auth.jtis
|
|
1248
|
+
// and spare it from revocation. The incoming instance's own token needs no keep entry — only
|
|
1249
|
+
// PRIOR jtis are ever revoked, so a fresh token is structurally never collateral.
|
|
1250
|
+
export function revokeSupersededRuntimeTokens(prior: AgentCard, keepJtis: string[] = [], now = Date.now()): string[] {
|
|
1251
|
+
revokeVaultTokens(prior.id, now, "instance_replaced", prior.instanceId);
|
|
1252
|
+
const priorJtis = runtimeTokenJtisFromMeta((prior.meta ?? {}) as Record<string, unknown>);
|
|
1253
|
+
if (priorJtis.length === 0) return [];
|
|
1254
|
+
const keep = new Set(keepJtis);
|
|
1255
|
+
const superseded = priorJtis.filter((jti) => !keep.has(jti));
|
|
1256
|
+
return revokeProviderRuntimeTokensByJti(superseded, "stale", now, keepJtis);
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
// #1245 — each listed provider token, retired or not, seeds its whole handoff lineage.
|
|
1260
|
+
function revokeProviderRuntimeTokensByJti(jtis: string[], reason: LineageRevokeReason, now: number, keep: string[] = []): string[] {
|
|
1261
|
+
if (jtis.length === 0) return [];
|
|
1262
|
+
const placeholders = jtis.map(() => "?").join(",");
|
|
1263
|
+
const seeds = getDb().query(`
|
|
1264
|
+
SELECT jti FROM tokens
|
|
1265
|
+
WHERE role = 'provider'
|
|
1266
|
+
AND profile_id IN ('provider-agent', 'provider-interactive', 'provider-child')
|
|
1267
|
+
AND jti IN (${placeholders})
|
|
1268
|
+
`).all(...jtis) as Array<{ jti: string }>;
|
|
1269
|
+
return revokeTokenLineage(seeds.map((row) => row.jti), reason, Math.floor(now / 1000), keep);
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
function runtimeTokenJtisFromMeta(meta: Record<string, unknown>): string[] {
|
|
1273
|
+
const jtis = new Set<string>();
|
|
1274
|
+
const auth = isRecord(meta.auth) ? meta.auth : undefined;
|
|
1275
|
+
const direct = typeof auth?.jti === "string" ? auth.jti : typeof meta.runtimeTokenJti === "string" ? meta.runtimeTokenJti : undefined;
|
|
1276
|
+
if (direct) jtis.add(direct);
|
|
1277
|
+
const extra = Array.isArray(auth?.jtis) ? auth.jtis : Array.isArray(meta.runtimeTokenJtis) ? meta.runtimeTokenJtis : [];
|
|
1278
|
+
for (const item of extra) {
|
|
1279
|
+
if (typeof item === "string") jtis.add(item);
|
|
1280
|
+
}
|
|
1281
|
+
return [...jtis];
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
// --- Tasks ---
|