cloving 0.3.20 → 1.0.1
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/{LICENSE.md → LICENSE} +1 -1
- package/README.md +475 -182
- package/dist/src/authority/budgets.d.ts +12 -0
- package/dist/src/authority/budgets.js +42 -0
- package/dist/src/authority/commands.d.ts +7 -0
- package/dist/src/authority/commands.js +263 -0
- package/dist/src/authority/details.d.ts +28 -0
- package/dist/src/authority/details.js +33 -0
- package/dist/src/authority/dispatch-decision.d.ts +40 -0
- package/dist/src/authority/dispatch-decision.js +47 -0
- package/dist/src/authority/effect-requests.d.ts +2 -0
- package/dist/src/authority/effect-requests.js +139 -0
- package/dist/src/authority/effect-results.d.ts +4 -0
- package/dist/src/authority/effect-results.js +236 -0
- package/dist/src/authority/events.d.ts +2 -0
- package/dist/src/authority/events.js +45 -0
- package/dist/src/authority/gate-reduction.d.ts +8 -0
- package/dist/src/authority/gate-reduction.js +109 -0
- package/dist/src/authority/gates.d.ts +48 -0
- package/dist/src/authority/gates.js +77 -0
- package/dist/src/authority/history-state.d.ts +15 -0
- package/dist/src/authority/history-state.js +61 -0
- package/dist/src/authority/history.d.ts +13 -0
- package/dist/src/authority/history.js +37 -0
- package/dist/src/authority/instants.d.ts +3 -0
- package/dist/src/authority/instants.js +38 -0
- package/dist/src/authority/leases.d.ts +15 -0
- package/dist/src/authority/leases.js +113 -0
- package/dist/src/authority/operations.d.ts +101 -0
- package/dist/src/authority/operations.js +75 -0
- package/dist/src/authority/reconciliation.d.ts +27 -0
- package/dist/src/authority/reconciliation.js +147 -0
- package/dist/src/authority/reducer.d.ts +41 -0
- package/dist/src/authority/reducer.js +139 -0
- package/dist/src/authority/reduction-state.d.ts +36 -0
- package/dist/src/authority/reduction-state.js +68 -0
- package/dist/src/authority/reduction.d.ts +6 -0
- package/dist/src/authority/reduction.js +160 -0
- package/dist/src/authority/status-closure.d.ts +4 -0
- package/dist/src/authority/status-closure.js +57 -0
- package/dist/src/authority/status-effects.d.ts +17 -0
- package/dist/src/authority/status-effects.js +43 -0
- package/dist/src/authority/status-input.d.ts +45 -0
- package/dist/src/authority/status-input.js +9 -0
- package/dist/src/authority/status.d.ts +32 -0
- package/dist/src/authority/status.js +256 -0
- package/dist/src/authority/stop-sequence.d.ts +37 -0
- package/dist/src/authority/stop-sequence.js +91 -0
- package/dist/src/authority/transitions.d.ts +63 -0
- package/dist/src/authority/transitions.js +122 -0
- package/dist/src/broker/actor/adapter-calls.d.ts +13 -0
- package/dist/src/broker/actor/adapter-calls.js +34 -0
- package/dist/src/broker/actor/adapter-outcomes.d.ts +28 -0
- package/dist/src/broker/actor/adapter-outcomes.js +80 -0
- package/dist/src/broker/actor/authority-actor.d.ts +25 -0
- package/dist/src/broker/actor/authority-actor.js +169 -0
- package/dist/src/broker/actor/authority-changes.d.ts +31 -0
- package/dist/src/broker/actor/authority-changes.js +46 -0
- package/dist/src/broker/actor/authority-connection.d.ts +15 -0
- package/dist/src/broker/actor/authority-connection.js +44 -0
- package/dist/src/broker/actor/authority-conversion.d.ts +10 -0
- package/dist/src/broker/actor/authority-conversion.js +72 -0
- package/dist/src/broker/actor/authority-delivery.d.ts +13 -0
- package/dist/src/broker/actor/authority-delivery.js +162 -0
- package/dist/src/broker/actor/authority-logger.d.ts +2 -0
- package/dist/src/broker/actor/authority-logger.js +19 -0
- package/dist/src/broker/actor/authority-policy.d.ts +9 -0
- package/dist/src/broker/actor/authority-policy.js +11 -0
- package/dist/src/broker/actor/authority-queries.d.ts +45 -0
- package/dist/src/broker/actor/authority-queries.js +85 -0
- package/dist/src/broker/actor/authority-receipts.d.ts +28 -0
- package/dist/src/broker/actor/authority-receipts.js +84 -0
- package/dist/src/broker/actor/authority-release.d.ts +13 -0
- package/dist/src/broker/actor/authority-release.js +69 -0
- package/dist/src/broker/actor/authority-runtime.d.ts +60 -0
- package/dist/src/broker/actor/authority-runtime.js +204 -0
- package/dist/src/broker/actor/authority-session.d.ts +65 -0
- package/dist/src/broker/actor/authority-session.js +252 -0
- package/dist/src/broker/actor/authority-settings.d.ts +33 -0
- package/dist/src/broker/actor/authority-settings.js +63 -0
- package/dist/src/broker/actor/authority-upgrades.d.ts +16 -0
- package/dist/src/broker/actor/authority-upgrades.js +12 -0
- package/dist/src/broker/actor/authority-watchdog.d.ts +14 -0
- package/dist/src/broker/actor/authority-watchdog.js +41 -0
- package/dist/src/broker/actor/authority.d.ts +14 -0
- package/dist/src/broker/actor/authority.js +115 -0
- package/dist/src/broker/actor/delivery-intents.d.ts +68 -0
- package/dist/src/broker/actor/delivery-intents.js +77 -0
- package/dist/src/broker/actor/delivery-plan.d.ts +2 -0
- package/dist/src/broker/actor/delivery-plan.js +109 -0
- package/dist/src/broker/actor/delivery-results.d.ts +11 -0
- package/dist/src/broker/actor/delivery-results.js +63 -0
- package/dist/src/broker/actor/effect-delivery.d.ts +19 -0
- package/dist/src/broker/actor/effect-delivery.js +118 -0
- package/dist/src/broker/actor/effect-plan.d.ts +41 -0
- package/dist/src/broker/actor/effect-plan.js +173 -0
- package/dist/src/broker/actor/effect-queries.d.ts +27 -0
- package/dist/src/broker/actor/effect-queries.js +80 -0
- package/dist/src/broker/actor/effect-turn.d.ts +25 -0
- package/dist/src/broker/actor/effect-turn.js +84 -0
- package/dist/src/broker/actor/pin-check.d.ts +6 -0
- package/dist/src/broker/actor/pin-check.js +12 -0
- package/dist/src/broker/actor/runtime-parts.d.ts +23 -0
- package/dist/src/broker/actor/runtime-parts.js +34 -0
- package/dist/src/broker/actor/stop-plan.d.ts +20 -0
- package/dist/src/broker/actor/stop-plan.js +46 -0
- package/dist/src/broker/actor/stop-turn.d.ts +17 -0
- package/dist/src/broker/actor/stop-turn.js +42 -0
- package/dist/src/broker/actor/turn-draft.d.ts +31 -0
- package/dist/src/broker/actor/turn-draft.js +138 -0
- package/dist/src/broker/actor/turn-plan.d.ts +17 -0
- package/dist/src/broker/actor/turn-plan.js +136 -0
- package/dist/src/broker/actor/turn-refusals.d.ts +8 -0
- package/dist/src/broker/actor/turn-refusals.js +35 -0
- package/dist/src/broker/actor/turn-staging.d.ts +78 -0
- package/dist/src/broker/actor/turn-staging.js +34 -0
- package/dist/src/broker/actor/turn-state.d.ts +34 -0
- package/dist/src/broker/actor/turn-state.js +208 -0
- package/dist/src/broker/authority-admission.d.ts +21 -0
- package/dist/src/broker/authority-admission.js +70 -0
- package/dist/src/broker/authority-restore.d.ts +30 -0
- package/dist/src/broker/authority-restore.js +165 -0
- package/dist/src/broker/decision-restore.d.ts +16 -0
- package/dist/src/broker/decision-restore.js +158 -0
- package/dist/src/broker/decision-upgrade.d.ts +3 -0
- package/dist/src/broker/decision-upgrade.js +12 -0
- package/dist/src/broker/effect-restore.d.ts +20 -0
- package/dist/src/broker/effect-restore.js +111 -0
- package/dist/src/broker/effect-upgrade.d.ts +3 -0
- package/dist/src/broker/effect-upgrade.js +9 -0
- package/dist/src/broker/operation-digest.d.ts +1 -0
- package/dist/src/broker/operation-digest.js +4 -0
- package/dist/src/broker/socket-address.d.ts +9 -0
- package/dist/src/broker/socket-address.js +14 -0
- package/dist/src/broker/workflow-pin.d.ts +2 -0
- package/dist/src/broker/workflow-pin.js +5 -0
- package/dist/src/chats/destination.d.ts +4 -0
- package/dist/src/chats/destination.js +94 -0
- package/dist/src/chats/import.d.ts +13 -0
- package/dist/src/chats/import.js +71 -0
- package/dist/src/chats/normalize.d.ts +20 -0
- package/dist/src/chats/normalize.js +139 -0
- package/dist/src/chats/reader.d.ts +15 -0
- package/dist/src/chats/reader.js +87 -0
- package/dist/src/cli/arguments.d.ts +23 -0
- package/dist/src/cli/arguments.js +154 -0
- package/dist/src/cli/client.d.ts +15 -0
- package/dist/src/cli/client.js +122 -0
- package/dist/src/cli/commands.d.ts +14 -0
- package/dist/src/cli/commands.js +253 -0
- package/dist/src/cli/main.d.ts +1 -0
- package/dist/src/cli/main.js +80 -0
- package/dist/src/cli/render.d.ts +8 -0
- package/dist/src/cli/render.js +186 -0
- package/dist/src/cli/runtime-arguments.d.ts +73 -0
- package/dist/src/cli/runtime-arguments.js +248 -0
- package/dist/src/cli/runtime-directory.d.ts +4 -0
- package/dist/src/cli/runtime-directory.js +25 -0
- package/dist/src/cli/toolchain.d.ts +3 -0
- package/dist/src/cli/toolchain.js +74 -0
- package/dist/src/cli/usage.d.ts +4 -0
- package/dist/src/cli/usage.js +124 -0
- package/dist/src/cli/validate.d.ts +38 -0
- package/dist/src/cli/validate.js +116 -0
- package/dist/src/cli/watch-board-view.d.ts +22 -0
- package/dist/src/cli/watch-board-view.js +128 -0
- package/dist/src/cli/watch-board.d.ts +15 -0
- package/dist/src/cli/watch-board.js +174 -0
- package/dist/src/cli/watch-element.d.ts +11 -0
- package/dist/src/cli/watch-element.js +6 -0
- package/dist/src/cli/watch-model.d.ts +29 -0
- package/dist/src/cli/watch-model.js +261 -0
- package/dist/src/cli/watch-navigation.d.ts +9 -0
- package/dist/src/cli/watch-navigation.js +40 -0
- package/dist/src/cli/watch-page.d.ts +1 -0
- package/dist/src/cli/watch-page.js +272 -0
- package/dist/src/cli/watch-paths.d.ts +2 -0
- package/dist/src/cli/watch-paths.js +52 -0
- package/dist/src/cli/watch-phases.d.ts +7 -0
- package/dist/src/cli/watch-phases.js +148 -0
- package/dist/src/cli/watch-reads.d.ts +28 -0
- package/dist/src/cli/watch-reads.js +244 -0
- package/dist/src/cli/watch-render.d.ts +139 -0
- package/dist/src/cli/watch-render.js +95 -0
- package/dist/src/cli/watch-server.d.ts +10 -0
- package/dist/src/cli/watch-server.js +176 -0
- package/dist/src/cli/watch-stream.d.ts +11 -0
- package/dist/src/cli/watch-stream.js +128 -0
- package/dist/src/cli/watch-turn.d.ts +29 -0
- package/dist/src/cli/watch-turn.js +130 -0
- package/dist/src/cli/watch-view.d.ts +39 -0
- package/dist/src/cli/watch-view.js +223 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.js +62 -0
- package/dist/src/daemon/claude-turn.d.ts +28 -0
- package/dist/src/daemon/claude-turn.js +135 -0
- package/dist/src/daemon/claude-worker.d.ts +26 -0
- package/dist/src/daemon/claude-worker.js +224 -0
- package/dist/src/daemon/codex-stream.d.ts +4 -0
- package/dist/src/daemon/codex-stream.js +113 -0
- package/dist/src/daemon/daemon.d.ts +46 -0
- package/dist/src/daemon/daemon.js +186 -0
- package/dist/src/daemon/delivery-router.d.ts +10 -0
- package/dist/src/daemon/delivery-router.js +34 -0
- package/dist/src/daemon/github-calls.d.ts +29 -0
- package/dist/src/daemon/github-calls.js +127 -0
- package/dist/src/daemon/github-issue-methods.d.ts +3 -0
- package/dist/src/daemon/github-issue-methods.js +99 -0
- package/dist/src/daemon/github-issue-privacy.d.ts +6 -0
- package/dist/src/daemon/github-issue-privacy.js +131 -0
- package/dist/src/daemon/github-merge.d.ts +18 -0
- package/dist/src/daemon/github-merge.js +259 -0
- package/dist/src/daemon/github-methods.d.ts +5 -0
- package/dist/src/daemon/github-methods.js +198 -0
- package/dist/src/daemon/github-operation.d.ts +38 -0
- package/dist/src/daemon/github-operation.js +57 -0
- package/dist/src/daemon/github-worker.d.ts +17 -0
- package/dist/src/daemon/github-worker.js +281 -0
- package/dist/src/daemon/host-environment.d.ts +8 -0
- package/dist/src/daemon/host-environment.js +14 -0
- package/dist/src/daemon/issue-queue.d.ts +9 -0
- package/dist/src/daemon/issue-queue.js +163 -0
- package/dist/src/daemon/notify-message.d.ts +14 -0
- package/dist/src/daemon/notify-message.js +48 -0
- package/dist/src/daemon/notify.d.ts +12 -0
- package/dist/src/daemon/notify.js +161 -0
- package/dist/src/daemon/operation-journal.d.ts +42 -0
- package/dist/src/daemon/operation-journal.js +53 -0
- package/dist/src/daemon/ticket-registration.d.ts +33 -0
- package/dist/src/daemon/ticket-registration.js +177 -0
- package/dist/src/daemon/ticket-source.d.ts +17 -0
- package/dist/src/daemon/ticket-source.js +36 -0
- package/dist/src/daemon/work-tree.d.ts +26 -0
- package/dist/src/daemon/work-tree.js +206 -0
- package/dist/src/effect-authorization.d.ts +21 -0
- package/dist/src/effect-authorization.js +14 -0
- package/dist/src/execution-pin.d.ts +4 -0
- package/dist/src/execution-pin.js +68 -0
- package/dist/src/host/start-delivery.d.ts +41 -0
- package/dist/src/host/start-delivery.js +68 -0
- package/dist/src/host/step-bridge-host.d.ts +79 -0
- package/dist/src/host/step-bridge-host.js +205 -0
- package/dist/src/host/step-claims.d.ts +31 -0
- package/dist/src/host/step-claims.js +85 -0
- package/dist/src/host/world-host.d.ts +21 -0
- package/dist/src/host/world-host.js +51 -0
- package/dist/src/host/world-reconciliation.d.ts +37 -0
- package/dist/src/host/world-reconciliation.js +75 -0
- package/dist/src/host/world-runs.d.ts +14 -0
- package/dist/src/host/world-runs.js +61 -0
- package/dist/src/operation-identity.d.ts +7 -0
- package/dist/src/operation-identity.js +59 -0
- package/dist/src/protocol.d.ts +35 -0
- package/dist/src/protocol.js +64 -0
- package/dist/src/resource-files.d.ts +1 -0
- package/dist/src/resource-files.js +29 -0
- package/dist/src/service/changes.d.ts +11 -0
- package/dist/src/service/changes.js +32 -0
- package/dist/src/service/decision-handler.d.ts +9 -0
- package/dist/src/service/decision-handler.js +233 -0
- package/dist/src/service/event-handler.d.ts +10 -0
- package/dist/src/service/event-handler.js +70 -0
- package/dist/src/service/expiry.d.ts +13 -0
- package/dist/src/service/expiry.js +53 -0
- package/dist/src/service/gateway.d.ts +21 -0
- package/dist/src/service/gateway.js +120 -0
- package/dist/src/service/registry.d.ts +40 -0
- package/dist/src/service/registry.js +13 -0
- package/dist/src/service/replies.d.ts +26 -0
- package/dist/src/service/replies.js +56 -0
- package/dist/src/service/run-handlers.d.ts +4 -0
- package/dist/src/service/run-handlers.js +271 -0
- package/dist/src/service/service.d.ts +58 -0
- package/dist/src/service/service.js +212 -0
- package/dist/src/service/submission-handler.d.ts +4 -0
- package/dist/src/service/submission-handler.js +206 -0
- package/dist/src/service/transport.d.ts +16 -0
- package/dist/src/service/transport.js +141 -0
- package/dist/src/service/worker-port.d.ts +85 -0
- package/dist/src/service/worker-port.js +126 -0
- package/dist/src/step-bridge.d.ts +57 -0
- package/dist/src/step-bridge.js +4 -0
- package/dist/src/steps/decision-gate.d.ts +2 -0
- package/dist/src/steps/decision-gate.js +8 -0
- package/dist/src/steps/load-cycle.d.ts +10 -0
- package/dist/src/steps/load-cycle.js +11 -0
- package/dist/src/steps/protected-effect.d.ts +2 -0
- package/dist/src/steps/protected-effect.js +8 -0
- package/dist/src/storage/decision-rows.d.ts +54 -0
- package/dist/src/storage/decision-rows.js +72 -0
- package/dist/src/storage/decision-snapshots.d.ts +17 -0
- package/dist/src/storage/decision-snapshots.js +25 -0
- package/dist/src/storage/domain-changes.d.ts +48 -0
- package/dist/src/storage/domain-changes.js +213 -0
- package/dist/src/storage/domain-rows.d.ts +85 -0
- package/dist/src/storage/domain-rows.js +129 -0
- package/dist/src/storage/domain-schema.d.ts +32 -0
- package/dist/src/storage/domain-schema.js +193 -0
- package/dist/src/storage/effect-changes.d.ts +5 -0
- package/dist/src/storage/effect-changes.js +105 -0
- package/dist/src/storage/effect-rows.d.ts +67 -0
- package/dist/src/storage/effect-rows.js +74 -0
- package/dist/src/storage/effect-schema.d.ts +1 -0
- package/dist/src/storage/effect-schema.js +59 -0
- package/dist/src/storage/statements.d.ts +9 -0
- package/dist/src/storage/statements.js +8 -0
- package/dist/src/submission.d.ts +42 -0
- package/dist/src/submission.js +71 -0
- package/dist/src/turn-profile.d.ts +13 -0
- package/dist/src/turn-profile.js +100 -0
- package/dist/src/workflow-admission.d.ts +45 -0
- package/dist/src/workflow-admission.js +151 -0
- package/dist/src/workflow-contracts.d.ts +27 -0
- package/dist/src/workflow-contracts.js +88 -0
- package/dist/src/workflow-declaration.d.ts +11 -0
- package/dist/src/workflow-declaration.js +57 -0
- package/dist/src/workflow-resources.d.ts +8 -0
- package/dist/src/workflow-resources.js +14 -0
- package/dist/src/workflows.d.ts +5 -0
- package/dist/src/workflows.js +3 -0
- package/dist/tools/compile-workflows.d.ts +1 -0
- package/dist/tools/compile-workflows.js +33 -0
- package/dist/tools/self-host-processes.d.ts +10 -0
- package/dist/tools/self-host-processes.js +151 -0
- package/dist/tools/self-host-workflows.d.ts +15 -0
- package/dist/tools/self-host-workflows.js +78 -0
- package/dist/tools/self-host.d.ts +1 -0
- package/dist/tools/self-host.js +261 -0
- package/dist/tools/self-update-host.d.ts +6 -0
- package/dist/tools/self-update-host.js +41 -0
- package/dist/tools/self-update.d.ts +10 -0
- package/dist/tools/self-update.js +105 -0
- package/dist/tools/workflow-manifest.d.ts +3 -0
- package/dist/tools/workflow-manifest.js +34 -0
- package/dist/workflows/develop-prd.d.ts +7 -0
- package/dist/workflows/develop-prd.js +97 -0
- package/dist/workflows/develop-ticket.d.ts +15 -0
- package/dist/workflows/develop-ticket.js +301 -0
- package/dist/workflows/issue-labels.d.ts +14 -0
- package/dist/workflows/issue-labels.js +36 -0
- package/package.json +82 -75
- package/dist/abstract_gpt/index.js +0 -55
- package/dist/cloving_gpt/adapters/Adapter.js +0 -2
- package/dist/cloving_gpt/adapters/azureopenai.js +0 -69
- package/dist/cloving_gpt/adapters/claude.js +0 -128
- package/dist/cloving_gpt/adapters/gemini.js +0 -135
- package/dist/cloving_gpt/adapters/gpt4all.js +0 -29
- package/dist/cloving_gpt/adapters/index.js +0 -2
- package/dist/cloving_gpt/adapters/mistral.js +0 -128
- package/dist/cloving_gpt/adapters/ollama.js +0 -128
- package/dist/cloving_gpt/adapters/openai.js +0 -100
- package/dist/cloving_gpt/index.js +0 -192
- package/dist/commands/analyze.js +0 -47
- package/dist/commands/chat.js +0 -14
- package/dist/commands/check.js +0 -7
- package/dist/commands/commit.js +0 -44
- package/dist/commands/config.js +0 -167
- package/dist/commands/describe.js +0 -235
- package/dist/commands/generate/code.js +0 -21
- package/dist/commands/generate/commit.js +0 -11
- package/dist/commands/generate/context.js +0 -82
- package/dist/commands/generate/docs.js +0 -11
- package/dist/commands/generate/documentation.js +0 -11
- package/dist/commands/generate/fizzbuzz.js +0 -35
- package/dist/commands/generate/init.js +0 -15
- package/dist/commands/generate/review.js +0 -11
- package/dist/commands/generate/sh.js +0 -95
- package/dist/commands/generate/shell.js +0 -11
- package/dist/commands/generate/unit_tests.js +0 -11
- package/dist/commands/init.js +0 -13
- package/dist/commands/models.js +0 -22
- package/dist/commands/project/build.js +0 -88
- package/dist/commands/project/complete.js +0 -12
- package/dist/commands/project/init.js +0 -82
- package/dist/commands/project/plan.js +0 -108
- package/dist/commands/proxy.js +0 -11
- package/dist/commands/review.js +0 -50
- package/dist/commands/tokens.js +0 -75
- package/dist/commands/unit_tests.js +0 -150
- package/dist/commands/update.js +0 -7
- package/dist/file2.js +0 -4
- package/dist/index.js +0 -136
- package/dist/managers/BlockManager.js +0 -120
- package/dist/managers/ChatManager.js +0 -653
- package/dist/managers/ChunkManager.js +0 -32
- package/dist/managers/CodeManager.js +0 -185
- package/dist/managers/CommitManager.js +0 -78
- package/dist/managers/DocsManager.js +0 -88
- package/dist/managers/DocumentationManager.js +0 -114
- package/dist/managers/InitManager.js +0 -230
- package/dist/managers/ProxyManager.js +0 -210
- package/dist/managers/ReviewManager.js +0 -131
- package/dist/managers/ShellManager.js +0 -163
- package/dist/managers/StreamManager.js +0 -308
- package/dist/managers/UnitTestManager.js +0 -243
- package/dist/managers/src/managers/ProxyManager.js +0 -1
- package/dist/newfile.js +0 -2
- package/dist/package.json +0 -86
- package/dist/utils/command_utils.js +0 -384
- package/dist/utils/config_utils.js +0 -249
- package/dist/utils/gitUtils.js +0 -42
- package/dist/utils/git_utils.js +0 -217
- package/dist/utils/modelUtils.js +0 -7
- package/dist/utils/model_utils.js +0 -7
- package/dist/utils/prompt_utils.js +0 -333
- package/dist/utils/prompts/CODEGEN_COULDNT_APPLY.md +0 -5
- package/dist/utils/prompts/CODEGEN_EXAMPLES.md +0 -82
- package/dist/utils/prompts/CODEGEN_INSTRUCTIONS.md +0 -43
- package/dist/utils/prompts/DOCS_INSTRUCTIONS.md +0 -9
- package/dist/utils/prompts/INIT_INSTRUCTIONS.md +0 -132
- package/dist/utils/prompts/REVIEW_INSTRUCTIONS.md +0 -49
- package/dist/utils/prompts/SHELL_INSTRUCTIONS.md +0 -15
- package/dist/utils/prompts/SPECIAL_FILES.md +0 -66
- package/dist/utils/prompts/index.js +0 -27
- package/dist/utils/string_utils.js +0 -505
- package/dist/utils/types.js +0 -2
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { invalidCommand, serializable, textList, unserializable, } from "../broker/actor/authority-receipts.js";
|
|
2
|
+
import { record } from "../protocol.js";
|
|
3
|
+
export const workerCommandBound = 1_000;
|
|
4
|
+
const permitted = {
|
|
5
|
+
operator: [
|
|
6
|
+
"admit-run",
|
|
7
|
+
"decide-gate",
|
|
8
|
+
"pause-run",
|
|
9
|
+
"resume-run",
|
|
10
|
+
"cancel-run",
|
|
11
|
+
],
|
|
12
|
+
worker: [
|
|
13
|
+
"mark-started",
|
|
14
|
+
"open-gate",
|
|
15
|
+
"register-wait",
|
|
16
|
+
"report-observation",
|
|
17
|
+
"complete-run",
|
|
18
|
+
"fail-run",
|
|
19
|
+
"request-effect",
|
|
20
|
+
"report-effect",
|
|
21
|
+
],
|
|
22
|
+
controller: ["expire-gate", "expire-lease"],
|
|
23
|
+
};
|
|
24
|
+
const pinned = ["decide-gate", "resume-run"];
|
|
25
|
+
function denied(principal, subject) {
|
|
26
|
+
return {
|
|
27
|
+
kind: "rejected",
|
|
28
|
+
reason: "permission-denied",
|
|
29
|
+
detail: `${principal} cannot send ${subject}`,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function checked(principal, copy) {
|
|
33
|
+
const command = record(copy["command"]);
|
|
34
|
+
const documents = textList(copy["documents"]);
|
|
35
|
+
const epoch = copy["epoch"];
|
|
36
|
+
if (command === undefined || documents === undefined)
|
|
37
|
+
return undefined;
|
|
38
|
+
if (epoch === undefined)
|
|
39
|
+
return { principal, command, documents };
|
|
40
|
+
if (typeof epoch !== "number")
|
|
41
|
+
return undefined;
|
|
42
|
+
return { principal, command, documents, epoch };
|
|
43
|
+
}
|
|
44
|
+
function busy(bound) {
|
|
45
|
+
return {
|
|
46
|
+
kind: "rejected",
|
|
47
|
+
reason: "service-busy",
|
|
48
|
+
detail: `The service has ${String(bound)} worker commands in work. Send the command again with the same command ID.`,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function refusal(submission, textBytes) {
|
|
52
|
+
const { principal, command } = submission;
|
|
53
|
+
const kind = String(command["kind"]);
|
|
54
|
+
if (!permitted[principal].includes(kind))
|
|
55
|
+
return denied(principal, kind);
|
|
56
|
+
if (kind === "open-gate" && command["gateKind"] === undefined)
|
|
57
|
+
return denied(principal, "an untyped gate");
|
|
58
|
+
const long = submission.documents.some((document) => Buffer.byteLength(document) > textBytes);
|
|
59
|
+
if (principal === "worker" && long)
|
|
60
|
+
return {
|
|
61
|
+
kind: "rejected",
|
|
62
|
+
reason: "input-too-large",
|
|
63
|
+
detail: `A text of a worker has at most ${String(textBytes)} bytes.`,
|
|
64
|
+
};
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
export function commandGateway(parts) {
|
|
68
|
+
const { authority, registry, clock, textBytes } = parts;
|
|
69
|
+
const bound = parts.pendingWorkerCommands ?? workerCommandBound;
|
|
70
|
+
let pending = 0;
|
|
71
|
+
async function manifest(command) {
|
|
72
|
+
const kind = String(command["kind"]);
|
|
73
|
+
if (kind === "admit-run")
|
|
74
|
+
return registry.byPin(String(command["workflow"]))?.manifest;
|
|
75
|
+
if (!pinned.includes(kind))
|
|
76
|
+
return undefined;
|
|
77
|
+
const run = (await authority.state()).runs[String(command["runId"])];
|
|
78
|
+
return registry.byPin(run?.workflow ?? "")?.manifest;
|
|
79
|
+
}
|
|
80
|
+
async function forwarded(submission) {
|
|
81
|
+
const available = await manifest(submission.command);
|
|
82
|
+
return authority.execute(submission.command, {
|
|
83
|
+
recordedAt: clock(),
|
|
84
|
+
...(available === undefined ? {} : { manifest: available }),
|
|
85
|
+
...(submission.epoch === undefined ? {} : { epoch: submission.epoch }),
|
|
86
|
+
documents: submission.documents,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
async function counted(submission) {
|
|
90
|
+
if (pending >= bound)
|
|
91
|
+
return busy(bound);
|
|
92
|
+
pending += 1;
|
|
93
|
+
try {
|
|
94
|
+
return await forwarded(submission);
|
|
95
|
+
}
|
|
96
|
+
finally {
|
|
97
|
+
pending -= 1;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
execute: async (given) => {
|
|
102
|
+
const copy = serializable({
|
|
103
|
+
command: given.command,
|
|
104
|
+
documents: given.documents ?? [],
|
|
105
|
+
...(given.epoch === undefined ? {} : { epoch: given.epoch }),
|
|
106
|
+
});
|
|
107
|
+
if (copy === undefined)
|
|
108
|
+
return unserializable;
|
|
109
|
+
const submission = checked(given.principal, copy);
|
|
110
|
+
if (submission === undefined)
|
|
111
|
+
return invalidCommand;
|
|
112
|
+
const refused = refusal(submission, textBytes);
|
|
113
|
+
if (refused !== undefined)
|
|
114
|
+
return refused;
|
|
115
|
+
return submission.principal === "worker"
|
|
116
|
+
? counted(submission)
|
|
117
|
+
: forwarded(submission);
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { SubmissionContract } from "../submission.ts";
|
|
2
|
+
import type { ExecutionManifest } from "../workflow-admission.ts";
|
|
3
|
+
export type Resolution = {
|
|
4
|
+
readonly kind: "resolved";
|
|
5
|
+
readonly input: unknown;
|
|
6
|
+
} | {
|
|
7
|
+
readonly kind: "rejected";
|
|
8
|
+
readonly code: string;
|
|
9
|
+
readonly detail: string;
|
|
10
|
+
};
|
|
11
|
+
export interface ResolutionRequest {
|
|
12
|
+
readonly workflowId: string;
|
|
13
|
+
readonly submission: Readonly<Record<string, unknown>>;
|
|
14
|
+
readonly commandId: string;
|
|
15
|
+
readonly signal: AbortSignal;
|
|
16
|
+
}
|
|
17
|
+
export interface Resolver {
|
|
18
|
+
readonly id: string;
|
|
19
|
+
readonly version: string;
|
|
20
|
+
readonly resolve: (request: ResolutionRequest) => Promise<Resolution>;
|
|
21
|
+
}
|
|
22
|
+
export interface WorkflowRegistration {
|
|
23
|
+
readonly workflowId: string;
|
|
24
|
+
readonly manifest: ExecutionManifest;
|
|
25
|
+
readonly availability: "available" | "unavailable";
|
|
26
|
+
readonly submission: SubmissionContract;
|
|
27
|
+
readonly resolver: Resolver;
|
|
28
|
+
readonly effectLimit?: number;
|
|
29
|
+
readonly admission?: "when-idle";
|
|
30
|
+
}
|
|
31
|
+
export interface Registered extends WorkflowRegistration {
|
|
32
|
+
readonly pin: string;
|
|
33
|
+
}
|
|
34
|
+
export interface Registry {
|
|
35
|
+
readonly workflowIds: readonly string[];
|
|
36
|
+
readonly byId: (workflowId: string) => Registered | undefined;
|
|
37
|
+
readonly byPin: (pin: string) => Registered | undefined;
|
|
38
|
+
readonly available: (pinned: ExecutionManifest) => ExecutionManifest | undefined;
|
|
39
|
+
}
|
|
40
|
+
export declare function workflowRegistry(workflows: readonly WorkflowRegistration[]): Registry;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { workflowPin } from "../broker/workflow-pin.js";
|
|
2
|
+
export function workflowRegistry(workflows) {
|
|
3
|
+
const registered = workflows.map((workflow) => ({
|
|
4
|
+
...workflow,
|
|
5
|
+
pin: workflowPin(workflow.manifest),
|
|
6
|
+
}));
|
|
7
|
+
return {
|
|
8
|
+
workflowIds: registered.map((workflow) => workflow.workflowId),
|
|
9
|
+
byId: (workflowId) => registered.find((workflow) => workflow.workflowId === workflowId),
|
|
10
|
+
byPin: (pin) => registered.find((workflow) => workflow.pin === pin),
|
|
11
|
+
available: (pinned) => registered.find((workflow) => workflow.manifest.workflowId === pinned.workflowId)?.manifest,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Authority, CommandRecord, StoreReceipt } from "../broker/actor/authority.ts";
|
|
2
|
+
import type { Fields, Reply } from "../protocol.ts";
|
|
3
|
+
import type { ChangeSignal } from "./changes.ts";
|
|
4
|
+
import type { Gateway } from "./gateway.ts";
|
|
5
|
+
import type { Registry } from "./registry.ts";
|
|
6
|
+
export interface ServiceContext {
|
|
7
|
+
readonly authority: Authority;
|
|
8
|
+
readonly registry: Registry;
|
|
9
|
+
readonly gateway: Gateway;
|
|
10
|
+
readonly clock: () => string;
|
|
11
|
+
readonly livenessMilliseconds: number;
|
|
12
|
+
readonly followMilliseconds: number;
|
|
13
|
+
readonly resolverMilliseconds: number;
|
|
14
|
+
readonly textBytes: number;
|
|
15
|
+
readonly documentBytes: number;
|
|
16
|
+
readonly worldReports?: () => readonly unknown[];
|
|
17
|
+
readonly changed?: ChangeSignal["next"];
|
|
18
|
+
}
|
|
19
|
+
export declare function result(kind: string, fields: Fields): Reply;
|
|
20
|
+
export declare function failed(code: string, extra: Fields): Reply;
|
|
21
|
+
export declare function invalidRequest(detail: string): Reply;
|
|
22
|
+
export declare function rejection(receipt: StoreReceipt, identity: Fields): Reply;
|
|
23
|
+
export declare function committed(receipt: StoreReceipt): boolean;
|
|
24
|
+
export declare function isIdentifier(value: unknown): value is string;
|
|
25
|
+
export declare function wholeNumber(value: unknown, minimum: number): value is number;
|
|
26
|
+
export declare function publicReceipt(record: CommandRecord): Fields;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { isRecordKey } from "../authority/commands.js";
|
|
2
|
+
const codes = {
|
|
3
|
+
"invalid-command": "invalid-request",
|
|
4
|
+
"request-too-large": "input-too-large",
|
|
5
|
+
"missing-document": "invalid-request",
|
|
6
|
+
"unknown-gate": "unknown-decision",
|
|
7
|
+
"missing-manifest": "workflow-unavailable",
|
|
8
|
+
};
|
|
9
|
+
export function result(kind, fields) {
|
|
10
|
+
return { kind: "result", result: { schemaVersion: 1, kind, ...fields } };
|
|
11
|
+
}
|
|
12
|
+
export function failed(code, extra) {
|
|
13
|
+
const detail = extra["detail"];
|
|
14
|
+
return {
|
|
15
|
+
kind: "error",
|
|
16
|
+
error: {
|
|
17
|
+
...extra,
|
|
18
|
+
code,
|
|
19
|
+
detail: typeof detail === "string" ? detail : code,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export function invalidRequest(detail) {
|
|
24
|
+
return failed("invalid-request", { detail });
|
|
25
|
+
}
|
|
26
|
+
export function rejection(receipt, identity) {
|
|
27
|
+
if (receipt.kind === "failed")
|
|
28
|
+
return failed("authority-unavailable", {
|
|
29
|
+
...identity,
|
|
30
|
+
detail: `${receipt.reason}: ${receipt.detail}`,
|
|
31
|
+
});
|
|
32
|
+
if (receipt.kind !== "rejected")
|
|
33
|
+
return failed("invalid-request", identity);
|
|
34
|
+
return failed(codes[receipt.reason] ?? receipt.reason, {
|
|
35
|
+
...identity,
|
|
36
|
+
detail: receipt.detail ?? receipt.reason,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
export function committed(receipt) {
|
|
40
|
+
return receipt.kind === "accepted" || receipt.kind === "duplicate";
|
|
41
|
+
}
|
|
42
|
+
export function isIdentifier(value) {
|
|
43
|
+
return isRecordKey(value);
|
|
44
|
+
}
|
|
45
|
+
export function wholeNumber(value, minimum) {
|
|
46
|
+
return (typeof value === "number" && Number.isSafeInteger(value) && value >= minimum);
|
|
47
|
+
}
|
|
48
|
+
export function publicReceipt(record) {
|
|
49
|
+
return {
|
|
50
|
+
commandId: record.commandId,
|
|
51
|
+
sequence: record.sequence,
|
|
52
|
+
runId: record.runId,
|
|
53
|
+
recordedAt: record.recordedAt,
|
|
54
|
+
commandDigest: record.commandDigest,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type Fields, type Reply } from "../protocol.ts";
|
|
2
|
+
import { type ServiceContext } from "./replies.ts";
|
|
3
|
+
export declare function status(context: ServiceContext, parameters: Fields): Promise<Reply>;
|
|
4
|
+
export declare function runCommand(context: ServiceContext, parameters: Fields): Promise<Reply>;
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { runView, unresolvedEffects, } from "../authority/status.js";
|
|
2
|
+
import { record } from "../protocol.js";
|
|
3
|
+
import { committed, failed, invalidRequest, isIdentifier, publicReceipt, rejection, result, wholeNumber, } from "./replies.js";
|
|
4
|
+
import { feedbackOf } from "./decision-handler.js";
|
|
5
|
+
async function snapshot(context) {
|
|
6
|
+
const { authority } = context;
|
|
7
|
+
const state = await authority.state();
|
|
8
|
+
const sequences = await authority.queries.sequences();
|
|
9
|
+
return {
|
|
10
|
+
state,
|
|
11
|
+
operations: await authority.operations(),
|
|
12
|
+
sequences: sequences.runs,
|
|
13
|
+
times: sequences.times,
|
|
14
|
+
workflowIds: await authority.queries.workflowIds(),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function silent(context, signs) {
|
|
18
|
+
const times = signs
|
|
19
|
+
.filter((sign) => sign !== undefined)
|
|
20
|
+
.map((sign) => Date.parse(sign));
|
|
21
|
+
if (times.length === 0)
|
|
22
|
+
return false;
|
|
23
|
+
const elapsed = Date.parse(context.clock()) - Math.max(...times);
|
|
24
|
+
return elapsed > context.livenessMilliseconds;
|
|
25
|
+
}
|
|
26
|
+
function summaries(snapshot, runId) {
|
|
27
|
+
return snapshot.operations
|
|
28
|
+
.filter((operation) => operation.runId === runId)
|
|
29
|
+
.map((operation) => ({
|
|
30
|
+
operationId: operation.operationId,
|
|
31
|
+
kind: operation.kind,
|
|
32
|
+
releasedSequence: operation.releasedSequence,
|
|
33
|
+
outcomes: operation.deliveries.map((delivery) => delivery.outcome),
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
36
|
+
async function effectInput(context, runId) {
|
|
37
|
+
const { effects } = context.authority;
|
|
38
|
+
const budget = await effects.budget(runId);
|
|
39
|
+
const stored = await effects.operations(runId);
|
|
40
|
+
return {
|
|
41
|
+
budget: budget === undefined
|
|
42
|
+
? null
|
|
43
|
+
: { limit: budget.limit, spent: budget.spent },
|
|
44
|
+
effects: stored.map((operation) => ({
|
|
45
|
+
operationId: operation.operationId,
|
|
46
|
+
status: operation.status,
|
|
47
|
+
reason: operation.waitCause ?? operation.reason,
|
|
48
|
+
leaseGeneration: operation.leaseGeneration,
|
|
49
|
+
attempts: operation.attempts,
|
|
50
|
+
limit: operation.recoveryLimit,
|
|
51
|
+
})),
|
|
52
|
+
effectEvidence: await effects.evidence(runId),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
async function viewOf(context, scope) {
|
|
56
|
+
const { state, sequences, times } = scope.snapshot;
|
|
57
|
+
const run = isIdentifier(scope.runId) ? state.runs[scope.runId] : undefined;
|
|
58
|
+
if (run === undefined)
|
|
59
|
+
return undefined;
|
|
60
|
+
const details = state.details[run.runId];
|
|
61
|
+
const input = {
|
|
62
|
+
...(await effectInput(context, run.runId)),
|
|
63
|
+
closure: run.status === "cancelled"
|
|
64
|
+
? await context.authority.effects.closure(run.runId)
|
|
65
|
+
: null,
|
|
66
|
+
run,
|
|
67
|
+
details,
|
|
68
|
+
gates: Object.values(state.gates)
|
|
69
|
+
.filter((gate) => gate.runId === run.runId)
|
|
70
|
+
.sort((left, right) => left.openedSequence - right.openedSequence),
|
|
71
|
+
operations: summaries(scope.snapshot, run.runId),
|
|
72
|
+
latestSequence: sequences[run.runId] ?? 0,
|
|
73
|
+
silent: silent(context, [
|
|
74
|
+
details?.observation?.recordedAt,
|
|
75
|
+
times[run.runId],
|
|
76
|
+
]),
|
|
77
|
+
};
|
|
78
|
+
return {
|
|
79
|
+
...runView(input),
|
|
80
|
+
workflowId: scope.snapshot.workflowIds[run.runId] ?? run.workflow,
|
|
81
|
+
latestAt: times[run.runId] ?? null,
|
|
82
|
+
unresolvedEffects: unresolvedEffects(input),
|
|
83
|
+
feedback: await feedbackOf(context, { state, runId: run.runId }),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function summary(view) {
|
|
87
|
+
return {
|
|
88
|
+
runId: view.runId,
|
|
89
|
+
workflowId: view.workflowId,
|
|
90
|
+
state: view.state,
|
|
91
|
+
condition: view.condition,
|
|
92
|
+
revision: view.revision,
|
|
93
|
+
latestSequence: view.latestSequence,
|
|
94
|
+
latestAt: view.latestAt,
|
|
95
|
+
pendingDecisions: view.pendingDecisions,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function costOf(text) {
|
|
99
|
+
try {
|
|
100
|
+
const cost = record(JSON.parse(text ?? "null"))?.["costUsd"];
|
|
101
|
+
return typeof cost === "number" ? cost : 0;
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
return 0;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
async function claudeCost(context, runId) {
|
|
108
|
+
const { effects, queries } = context.authority;
|
|
109
|
+
const digests = (await effects.operations(runId))
|
|
110
|
+
.filter((operation) => operation.capability === "claude")
|
|
111
|
+
.map((operation) => operation.result)
|
|
112
|
+
.filter((digest) => digest !== null);
|
|
113
|
+
let total = 0;
|
|
114
|
+
for (const digest of digests)
|
|
115
|
+
total += costOf(await queries.document(digest));
|
|
116
|
+
return Math.round(total * 100) / 100;
|
|
117
|
+
}
|
|
118
|
+
function full(view) {
|
|
119
|
+
return {
|
|
120
|
+
...summary(view),
|
|
121
|
+
reason: view.reason,
|
|
122
|
+
evidence: view.evidence,
|
|
123
|
+
lastConfirmedObservation: view.lastConfirmedObservation,
|
|
124
|
+
recovery: view.recovery,
|
|
125
|
+
claudeCostUsd: view.claudeCostUsd,
|
|
126
|
+
budget: view.budget,
|
|
127
|
+
effects: view.effects,
|
|
128
|
+
nextAction: view.nextAction,
|
|
129
|
+
nextActionAt: view.nextActionAt,
|
|
130
|
+
humanInputCanHelp: view.humanInputCanHelp,
|
|
131
|
+
feedback: view.feedback,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
async function outcomeOf(context, view) {
|
|
135
|
+
if (view.state !== "completed")
|
|
136
|
+
return null;
|
|
137
|
+
const event = await context.authority.queries.latestCompletion({
|
|
138
|
+
runId: view.runId,
|
|
139
|
+
atOrBefore: view.latestSequence,
|
|
140
|
+
});
|
|
141
|
+
const kind = event?.payload["outcome"];
|
|
142
|
+
if (kind === undefined)
|
|
143
|
+
return null;
|
|
144
|
+
return { kind, reason: event?.payload["outcomeReason"] ?? null };
|
|
145
|
+
}
|
|
146
|
+
function titleOf(input, workflowId) {
|
|
147
|
+
const ticket = input?.["ticket"];
|
|
148
|
+
if (typeof ticket !== "string")
|
|
149
|
+
return null;
|
|
150
|
+
const fallback = `Cloving task ${String(input?.["cycleId"])}`;
|
|
151
|
+
const lines = ticket.split("\n");
|
|
152
|
+
if (workflowId === "develop-prompt") {
|
|
153
|
+
const first = lines.find((line) => /\S/.test(line));
|
|
154
|
+
return first === undefined
|
|
155
|
+
? fallback
|
|
156
|
+
: first.replace(/^# /, "").trim().slice(0, 200);
|
|
157
|
+
}
|
|
158
|
+
const first = lines[0] ?? "";
|
|
159
|
+
return first.startsWith("# ")
|
|
160
|
+
? first.slice(2).trim().slice(0, 200)
|
|
161
|
+
: fallback;
|
|
162
|
+
}
|
|
163
|
+
async function metadataOf(context, source) {
|
|
164
|
+
const document = source.digest
|
|
165
|
+
? await context.authority.queries.document(source.digest)
|
|
166
|
+
: undefined;
|
|
167
|
+
const input = record(JSON.parse(document ?? "null"));
|
|
168
|
+
const ticketId = input?.["ticketId"];
|
|
169
|
+
return {
|
|
170
|
+
ticketId: typeof ticketId === "string" && ticketId !== "" ? ticketId : null,
|
|
171
|
+
title: titleOf(input, source.workflowId),
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
async function listed(context, page) {
|
|
175
|
+
const identifiers = Object.keys(page.snapshot.state.runs)
|
|
176
|
+
.sort()
|
|
177
|
+
.filter((runId) => runId > page.after);
|
|
178
|
+
const shown = identifiers.slice(0, page.limit);
|
|
179
|
+
const views = [];
|
|
180
|
+
for (const runId of shown)
|
|
181
|
+
views.push(await viewOf(context, { snapshot: page.snapshot, runId }));
|
|
182
|
+
const runs = views.filter((view) => view !== undefined).map(summary);
|
|
183
|
+
return result("run-list", {
|
|
184
|
+
workflows: context.registry.workflowIds,
|
|
185
|
+
runs,
|
|
186
|
+
next: identifiers.length > shown.length ? (shown.at(-1) ?? null) : null,
|
|
187
|
+
worldReports: context.worldReports?.() ?? [],
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
export async function status(context, parameters) {
|
|
191
|
+
const { runId } = parameters;
|
|
192
|
+
const after = parameters["after"] ?? "";
|
|
193
|
+
const limit = parameters["limit"] ?? 50;
|
|
194
|
+
if (typeof after !== "string" || !wholeNumber(limit, 1) || limit > 500)
|
|
195
|
+
return invalidRequest("The status request is not valid.");
|
|
196
|
+
const current = await snapshot(context);
|
|
197
|
+
if (runId === undefined)
|
|
198
|
+
return listed(context, { snapshot: current, after, limit });
|
|
199
|
+
const named = typeof runId === "string" ? runId : "";
|
|
200
|
+
const view = await viewOf(context, { snapshot: current, runId: named });
|
|
201
|
+
if (view === undefined)
|
|
202
|
+
return failed("unknown-run", { detail: `No run has the ID ${named}.` });
|
|
203
|
+
const claudeCostUsd = await claudeCost(context, view.runId);
|
|
204
|
+
return result("run-status", {
|
|
205
|
+
run: {
|
|
206
|
+
...full({ ...view, claudeCostUsd }),
|
|
207
|
+
outcome: await outcomeOf(context, view),
|
|
208
|
+
...(await metadataOf(context, {
|
|
209
|
+
workflowId: view.workflowId,
|
|
210
|
+
digest: current.state.details[view.runId]?.input,
|
|
211
|
+
})),
|
|
212
|
+
},
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
const kinds = {
|
|
216
|
+
pause: "pause-run",
|
|
217
|
+
resume: "resume-run",
|
|
218
|
+
drop: "cancel-run",
|
|
219
|
+
};
|
|
220
|
+
async function reported(context, outcome) {
|
|
221
|
+
const { command, commandId, runId } = outcome;
|
|
222
|
+
const stored = await context.authority.queries.receipt(commandId);
|
|
223
|
+
const current = await snapshot(context);
|
|
224
|
+
const view = await viewOf(context, { snapshot: current, runId });
|
|
225
|
+
if (stored === undefined || view === undefined)
|
|
226
|
+
return failed("authority-unavailable", { commandId, runId });
|
|
227
|
+
const operations = current.operations.filter((operation) => operation.runId === runId);
|
|
228
|
+
return result("run-command", {
|
|
229
|
+
command,
|
|
230
|
+
runId,
|
|
231
|
+
commandId,
|
|
232
|
+
replayed: outcome.replayed,
|
|
233
|
+
receipt: publicReceipt(stored),
|
|
234
|
+
committed: {
|
|
235
|
+
state: view.state,
|
|
236
|
+
revision: view.revision,
|
|
237
|
+
revokedIntents: operations.filter((operation) => operation.releasedSequence === stored.sequence).length,
|
|
238
|
+
},
|
|
239
|
+
observed: {
|
|
240
|
+
condition: view.condition,
|
|
241
|
+
unresolvedEffects: view.unresolvedEffects,
|
|
242
|
+
},
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
export async function runCommand(context, parameters) {
|
|
246
|
+
const { command, runId, expectedRevision, commandId } = parameters;
|
|
247
|
+
if (typeof command !== "string" ||
|
|
248
|
+
!Object.hasOwn(kinds, command) ||
|
|
249
|
+
!isIdentifier(runId) ||
|
|
250
|
+
!isIdentifier(commandId) ||
|
|
251
|
+
!wholeNumber(expectedRevision, 1))
|
|
252
|
+
return invalidRequest("The run command request is not valid.");
|
|
253
|
+
const receipt = await context.gateway.execute({
|
|
254
|
+
principal: "operator",
|
|
255
|
+
command: { kind: kinds[command], commandId, runId, expectedRevision },
|
|
256
|
+
});
|
|
257
|
+
if (!committed(receipt)) {
|
|
258
|
+
const run = (await context.authority.state()).runs[runId];
|
|
259
|
+
return rejection(receipt, {
|
|
260
|
+
commandId,
|
|
261
|
+
runId,
|
|
262
|
+
currentRevision: run?.revision ?? null,
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
return reported(context, {
|
|
266
|
+
command,
|
|
267
|
+
commandId,
|
|
268
|
+
runId,
|
|
269
|
+
replayed: receipt.kind === "duplicate",
|
|
270
|
+
});
|
|
271
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { type Authority, type AuthorityTiming, type Delivery, type EffectSettings, type Refusal } from "../broker/actor/authority.ts";
|
|
2
|
+
import { type WorkflowRegistration } from "./registry.ts";
|
|
3
|
+
import { type WorkerPort } from "./worker-port.ts";
|
|
4
|
+
export type { WorkflowRegistration } from "./registry.ts";
|
|
5
|
+
export type { EffectReply, EffectReport, EffectRequest, WorkerPort, } from "./worker-port.ts";
|
|
6
|
+
export interface ServiceTiming {
|
|
7
|
+
readonly authority: AuthorityTiming;
|
|
8
|
+
readonly expiryScanMilliseconds: number;
|
|
9
|
+
readonly livenessMilliseconds: number;
|
|
10
|
+
readonly followMilliseconds: number;
|
|
11
|
+
readonly resolverMilliseconds: number;
|
|
12
|
+
readonly idleMilliseconds: number;
|
|
13
|
+
}
|
|
14
|
+
export declare const serviceTiming: ServiceTiming;
|
|
15
|
+
export interface ServiceLimits {
|
|
16
|
+
readonly textBytes: number;
|
|
17
|
+
readonly documentBytes: number;
|
|
18
|
+
readonly pendingWorkerCommands: number;
|
|
19
|
+
}
|
|
20
|
+
export declare const serviceLimits: ServiceLimits;
|
|
21
|
+
export interface ServiceHost {
|
|
22
|
+
readonly close: () => Promise<void>;
|
|
23
|
+
readonly reports?: () => readonly unknown[];
|
|
24
|
+
}
|
|
25
|
+
export interface HostPorts {
|
|
26
|
+
readonly state: Authority["state"];
|
|
27
|
+
readonly submit: WorkerPort["submit"];
|
|
28
|
+
readonly input: (runId: string) => Promise<string | undefined>;
|
|
29
|
+
readonly document: (digest: string) => Promise<string | undefined>;
|
|
30
|
+
readonly workflowId: (runId: string) => Promise<string | undefined>;
|
|
31
|
+
readonly requestEffect: WorkerPort["requestEffect"];
|
|
32
|
+
readonly operation: Authority["effects"]["operation"];
|
|
33
|
+
readonly reportEffect: WorkerPort["reportEffect"];
|
|
34
|
+
readonly openGate: WorkerPort["openGate"];
|
|
35
|
+
readonly registerWait: WorkerPort["registerWait"];
|
|
36
|
+
}
|
|
37
|
+
export interface ServiceOptions {
|
|
38
|
+
readonly stateDirectory: string;
|
|
39
|
+
readonly runtimeDirectory: string;
|
|
40
|
+
readonly workflows: readonly WorkflowRegistration[];
|
|
41
|
+
readonly delivery: Delivery;
|
|
42
|
+
readonly host?: (ports: HostPorts) => Promise<ServiceHost>;
|
|
43
|
+
readonly timing?: ServiceTiming;
|
|
44
|
+
readonly limits?: ServiceLimits;
|
|
45
|
+
readonly effects?: Partial<EffectSettings>;
|
|
46
|
+
readonly clock?: () => string;
|
|
47
|
+
}
|
|
48
|
+
export interface Service {
|
|
49
|
+
readonly socket: string;
|
|
50
|
+
readonly epoch: number;
|
|
51
|
+
readonly worker: WorkerPort;
|
|
52
|
+
readonly close: () => Promise<void>;
|
|
53
|
+
}
|
|
54
|
+
export type ServiceOpening = {
|
|
55
|
+
readonly kind: "started";
|
|
56
|
+
readonly service: Service;
|
|
57
|
+
} | Refusal;
|
|
58
|
+
export declare function startService(options: ServiceOptions): Promise<ServiceOpening>;
|