cloving 0.3.20 → 1.1.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/{LICENSE.md → LICENSE} +1 -1
- package/README.md +606 -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 +271 -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 +29 -0
- package/dist/src/authority/reconciliation.js +156 -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 +124 -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 +67 -0
- package/dist/src/broker/actor/authority-session.js +251 -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/analysis-batches.d.ts +24 -0
- package/dist/src/chats/analysis-batches.js +83 -0
- package/dist/src/chats/analysis-contract.d.ts +80 -0
- package/dist/src/chats/analysis-contract.js +16 -0
- package/dist/src/chats/analysis-data.d.ts +3 -0
- package/dist/src/chats/analysis-data.js +85 -0
- package/dist/src/chats/analysis-input.d.ts +12 -0
- package/dist/src/chats/analysis-input.js +83 -0
- package/dist/src/chats/analysis-links.d.ts +2 -0
- package/dist/src/chats/analysis-links.js +25 -0
- package/dist/src/chats/analysis-prompt.d.ts +10 -0
- package/dist/src/chats/analysis-prompt.js +16 -0
- package/dist/src/chats/analysis-proposal.d.ts +2 -0
- package/dist/src/chats/analysis-proposal.js +32 -0
- package/dist/src/chats/analysis-provenance.d.ts +4 -0
- package/dist/src/chats/analysis-provenance.js +99 -0
- package/dist/src/chats/analysis-shape.d.ts +3 -0
- package/dist/src/chats/analysis-shape.js +228 -0
- package/dist/src/chats/analysis.d.ts +3 -0
- package/dist/src/chats/analysis.js +42 -0
- package/dist/src/chats/corpus-input.d.ts +5 -0
- package/dist/src/chats/corpus-input.js +288 -0
- package/dist/src/chats/destination.d.ts +4 -0
- package/dist/src/chats/destination.js +96 -0
- package/dist/src/chats/import.d.ts +15 -0
- package/dist/src/chats/import.js +243 -0
- package/dist/src/chats/input-file.d.ts +3 -0
- package/dist/src/chats/input-file.js +32 -0
- package/dist/src/chats/normalize.d.ts +29 -0
- package/dist/src/chats/normalize.js +155 -0
- package/dist/src/chats/previous-import.d.ts +5 -0
- package/dist/src/chats/previous-import.js +34 -0
- package/dist/src/chats/reader.d.ts +21 -0
- package/dist/src/chats/reader.js +118 -0
- package/dist/src/chats/redact-import.d.ts +14 -0
- package/dist/src/chats/redact-import.js +141 -0
- package/dist/src/chats/redaction.d.ts +41 -0
- package/dist/src/chats/redaction.js +161 -0
- package/dist/src/chats/revision-input.d.ts +3 -0
- package/dist/src/chats/revision-input.js +180 -0
- package/dist/src/chats/revision.d.ts +48 -0
- package/dist/src/chats/revision.js +94 -0
- package/dist/src/chats/selection.d.ts +25 -0
- package/dist/src/chats/selection.js +109 -0
- package/dist/src/chats/source.d.ts +23 -0
- package/dist/src/chats/source.js +135 -0
- package/dist/src/chats/structure.d.ts +57 -0
- package/dist/src/chats/structure.js +216 -0
- package/dist/src/cli/arguments.d.ts +31 -0
- package/dist/src/cli/arguments.js +235 -0
- package/dist/src/cli/client.d.ts +16 -0
- package/dist/src/cli/client.js +159 -0
- package/dist/src/cli/commands.d.ts +17 -0
- package/dist/src/cli/commands.js +271 -0
- package/dist/src/cli/main.d.ts +2 -0
- package/dist/src/cli/main.js +127 -0
- package/dist/src/cli/render.d.ts +10 -0
- package/dist/src/cli/render.js +254 -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-render.d.ts +3 -0
- package/dist/src/cli/usage-render.js +28 -0
- package/dist/src/cli/usage.d.ts +5 -0
- package/dist/src/cli/usage.js +156 -0
- package/dist/src/cli/validate.d.ts +38 -0
- package/dist/src/cli/validate.js +116 -0
- package/dist/src/cli/watch-actions.d.ts +10 -0
- package/dist/src/cli/watch-actions.js +58 -0
- package/dist/src/cli/watch-board-view.d.ts +54 -0
- package/dist/src/cli/watch-board-view.js +201 -0
- package/dist/src/cli/watch-board.d.ts +15 -0
- package/dist/src/cli/watch-board.js +179 -0
- package/dist/src/cli/watch-card-client.d.ts +1 -0
- package/dist/src/cli/watch-card-client.js +44 -0
- package/dist/src/cli/watch-card-forms.d.ts +2 -0
- package/dist/src/cli/watch-card-forms.js +33 -0
- package/dist/src/cli/watch-card-reply.d.ts +5 -0
- package/dist/src/cli/watch-card-reply.js +34 -0
- package/dist/src/cli/watch-card-view.d.ts +40 -0
- package/dist/src/cli/watch-card-view.js +86 -0
- package/dist/src/cli/watch-client.d.ts +1 -0
- package/dist/src/cli/watch-client.js +118 -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 +278 -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 +258 -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-pr-board.d.ts +3 -0
- package/dist/src/cli/watch-pr-board.js +26 -0
- package/dist/src/cli/watch-pr-command.d.ts +15 -0
- package/dist/src/cli/watch-pr-command.js +37 -0
- package/dist/src/cli/watch-pr-identity.d.ts +20 -0
- package/dist/src/cli/watch-pr-identity.js +62 -0
- package/dist/src/cli/watch-pr-observer.d.ts +19 -0
- package/dist/src/cli/watch-pr-observer.js +108 -0
- package/dist/src/cli/watch-pr-settings.d.ts +8 -0
- package/dist/src/cli/watch-pr-settings.js +47 -0
- package/dist/src/cli/watch-reads.d.ts +28 -0
- package/dist/src/cli/watch-reads.js +248 -0
- package/dist/src/cli/watch-render.d.ts +153 -0
- package/dist/src/cli/watch-render.js +102 -0
- package/dist/src/cli/watch-run-input.d.ts +14 -0
- package/dist/src/cli/watch-run-input.js +49 -0
- package/dist/src/cli/watch-server.d.ts +13 -0
- package/dist/src/cli/watch-server.js +214 -0
- package/dist/src/cli/watch-start-view.d.ts +18 -0
- package/dist/src/cli/watch-start-view.js +77 -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 +30 -0
- package/dist/src/cli/watch-turn.js +135 -0
- package/dist/src/cli/watch-usage.d.ts +6 -0
- package/dist/src/cli/watch-usage.js +65 -0
- package/dist/src/cli/watch-view.d.ts +54 -0
- package/dist/src/cli/watch-view.js +267 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.js +104 -0
- package/dist/src/daemon/analysis-launch.d.ts +5 -0
- package/dist/src/daemon/analysis-launch.js +81 -0
- package/dist/src/daemon/analysis-token.d.ts +6 -0
- package/dist/src/daemon/analysis-token.js +88 -0
- package/dist/src/daemon/analysis-worker.d.ts +22 -0
- package/dist/src/daemon/analysis-worker.js +219 -0
- package/dist/src/daemon/chats-files.d.ts +15 -0
- package/dist/src/daemon/chats-files.js +113 -0
- package/dist/src/daemon/chats-worker.d.ts +12 -0
- package/dist/src/daemon/chats-worker.js +200 -0
- package/dist/src/daemon/claude-turn.d.ts +38 -0
- package/dist/src/daemon/claude-turn.js +216 -0
- package/dist/src/daemon/claude-worker.d.ts +29 -0
- package/dist/src/daemon/claude-worker.js +276 -0
- package/dist/src/daemon/codex-stream.d.ts +4 -0
- package/dist/src/daemon/codex-stream.js +129 -0
- package/dist/src/daemon/daemon.d.ts +49 -0
- package/dist/src/daemon/daemon.js +195 -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 +202 -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-ticket-status.d.ts +3 -0
- package/dist/src/daemon/github-ticket-status.js +268 -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 +10 -0
- package/dist/src/daemon/issue-queue.js +254 -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 +43 -0
- package/dist/src/daemon/operation-journal.js +55 -0
- package/dist/src/daemon/retrying-turn.d.ts +9 -0
- package/dist/src/daemon/retrying-turn.js +185 -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 +39 -0
- package/dist/src/host/world-reconciliation.js +81 -0
- package/dist/src/host/world-runs.d.ts +14 -0
- package/dist/src/host/world-runs.js +69 -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 +263 -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/service/worker-totals.d.ts +3 -0
- package/dist/src/service/worker-totals.js +28 -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/ticket-status.d.ts +8 -0
- package/dist/src/ticket-status.js +45 -0
- package/dist/src/token-prices.d.ts +19 -0
- package/dist/src/token-prices.js +76 -0
- package/dist/src/turn-profile.d.ts +13 -0
- package/dist/src/turn-profile.js +100 -0
- package/dist/src/worker-usage.d.ts +22 -0
- package/dist/src/worker-usage.js +44 -0
- package/dist/src/workflow-admission.d.ts +45 -0
- package/dist/src/workflow-admission.js +151 -0
- package/dist/src/workflow-candidate.d.ts +29 -0
- package/dist/src/workflow-candidate.js +59 -0
- package/dist/src/workflow-contracts.d.ts +29 -0
- package/dist/src/workflow-contracts.js +110 -0
- package/dist/src/workflow-declaration.d.ts +11 -0
- package/dist/src/workflow-declaration.js +59 -0
- package/dist/src/workflow-resources.d.ts +8 -0
- package/dist/src/workflow-resources.js +14 -0
- package/dist/src/workflows.d.ts +6 -0
- package/dist/src/workflows.js +4 -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 +156 -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 +13 -0
- package/dist/tools/self-update-host.js +88 -0
- package/dist/tools/self-update.d.ts +11 -0
- package/dist/tools/self-update.js +177 -0
- package/dist/tools/workflow-manifest.d.ts +3 -0
- package/dist/tools/workflow-manifest.js +34 -0
- package/dist/workflows/analyze-chats.d.ts +10 -0
- package/dist/workflows/analyze-chats.declaration.json +9 -0
- package/dist/workflows/analyze-chats.js +73 -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 +9 -0
- package/dist/workflows/develop-ticket.js +202 -0
- package/dist/workflows/issue-labels.d.ts +16 -0
- package/dist/workflows/issue-labels.js +70 -0
- package/dist/workflows/ticket-prompts.d.ts +35 -0
- package/dist/workflows/ticket-prompts.js +133 -0
- package/package.json +84 -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,263 @@
|
|
|
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 { usageTotals } from "./worker-totals.js";
|
|
5
|
+
import { feedbackOf } from "./decision-handler.js";
|
|
6
|
+
async function snapshot(context) {
|
|
7
|
+
const { authority } = context;
|
|
8
|
+
const state = await authority.state();
|
|
9
|
+
const sequences = await authority.queries.sequences();
|
|
10
|
+
return {
|
|
11
|
+
state,
|
|
12
|
+
operations: await authority.operations(),
|
|
13
|
+
sequences: sequences.runs,
|
|
14
|
+
times: sequences.times,
|
|
15
|
+
workflowIds: await authority.queries.workflowIds(),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function silent(context, signs) {
|
|
19
|
+
const times = signs
|
|
20
|
+
.filter((sign) => sign !== undefined)
|
|
21
|
+
.map((sign) => Date.parse(sign));
|
|
22
|
+
if (times.length === 0)
|
|
23
|
+
return false;
|
|
24
|
+
const elapsed = Date.parse(context.clock()) - Math.max(...times);
|
|
25
|
+
return elapsed > context.livenessMilliseconds;
|
|
26
|
+
}
|
|
27
|
+
function summaries(snapshot, runId) {
|
|
28
|
+
return snapshot.operations
|
|
29
|
+
.filter((operation) => operation.runId === runId)
|
|
30
|
+
.map((operation) => ({
|
|
31
|
+
operationId: operation.operationId,
|
|
32
|
+
kind: operation.kind,
|
|
33
|
+
releasedSequence: operation.releasedSequence,
|
|
34
|
+
outcomes: operation.deliveries.map((delivery) => delivery.outcome),
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
async function effectInput(context, runId) {
|
|
38
|
+
const { effects } = context.authority;
|
|
39
|
+
const budget = await effects.budget(runId);
|
|
40
|
+
const stored = await effects.operations(runId);
|
|
41
|
+
return {
|
|
42
|
+
budget: budget === undefined
|
|
43
|
+
? null
|
|
44
|
+
: { limit: budget.limit, spent: budget.spent },
|
|
45
|
+
effects: stored.map((operation) => ({
|
|
46
|
+
operationId: operation.operationId,
|
|
47
|
+
status: operation.status,
|
|
48
|
+
reason: operation.waitCause ?? operation.reason,
|
|
49
|
+
leaseGeneration: operation.leaseGeneration,
|
|
50
|
+
attempts: operation.attempts,
|
|
51
|
+
limit: operation.recoveryLimit,
|
|
52
|
+
})),
|
|
53
|
+
effectEvidence: await effects.evidence(runId),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
async function viewOf(context, scope) {
|
|
57
|
+
const { state, sequences, times } = scope.snapshot;
|
|
58
|
+
const run = isIdentifier(scope.runId) ? state.runs[scope.runId] : undefined;
|
|
59
|
+
if (run === undefined)
|
|
60
|
+
return undefined;
|
|
61
|
+
const details = state.details[run.runId];
|
|
62
|
+
const input = {
|
|
63
|
+
...(await effectInput(context, run.runId)),
|
|
64
|
+
closure: run.status === "cancelled"
|
|
65
|
+
? await context.authority.effects.closure(run.runId)
|
|
66
|
+
: null,
|
|
67
|
+
run,
|
|
68
|
+
details,
|
|
69
|
+
gates: Object.values(state.gates)
|
|
70
|
+
.filter((gate) => gate.runId === run.runId)
|
|
71
|
+
.sort((left, right) => left.openedSequence - right.openedSequence),
|
|
72
|
+
operations: summaries(scope.snapshot, run.runId),
|
|
73
|
+
latestSequence: sequences[run.runId] ?? 0,
|
|
74
|
+
silent: silent(context, [
|
|
75
|
+
details?.observation?.recordedAt,
|
|
76
|
+
times[run.runId],
|
|
77
|
+
]),
|
|
78
|
+
};
|
|
79
|
+
return {
|
|
80
|
+
...runView(input),
|
|
81
|
+
workflowId: scope.snapshot.workflowIds[run.runId] ?? run.workflow,
|
|
82
|
+
latestAt: times[run.runId] ?? null,
|
|
83
|
+
unresolvedEffects: unresolvedEffects(input),
|
|
84
|
+
feedback: await feedbackOf(context, { state, runId: run.runId }),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function summary(view) {
|
|
88
|
+
return {
|
|
89
|
+
runId: view.runId,
|
|
90
|
+
workflowId: view.workflowId,
|
|
91
|
+
state: view.state,
|
|
92
|
+
condition: view.condition,
|
|
93
|
+
revision: view.revision,
|
|
94
|
+
latestSequence: view.latestSequence,
|
|
95
|
+
latestAt: view.latestAt,
|
|
96
|
+
pendingDecisions: view.pendingDecisions,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function full(view) {
|
|
100
|
+
return {
|
|
101
|
+
...summary(view),
|
|
102
|
+
reason: view.reason,
|
|
103
|
+
evidence: view.evidence,
|
|
104
|
+
lastConfirmedObservation: view.lastConfirmedObservation,
|
|
105
|
+
recovery: view.recovery,
|
|
106
|
+
claudeCostUsd: view.claudeCostUsd,
|
|
107
|
+
estimatedCostUsd: view.estimatedCostUsd,
|
|
108
|
+
usage: view.usage,
|
|
109
|
+
workerTurns: view.workerTurns,
|
|
110
|
+
budget: view.budget,
|
|
111
|
+
effects: view.effects,
|
|
112
|
+
nextAction: view.nextAction,
|
|
113
|
+
nextActionAt: view.nextActionAt,
|
|
114
|
+
humanInputCanHelp: view.humanInputCanHelp,
|
|
115
|
+
feedback: view.feedback,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
async function outcomeOf(context, view) {
|
|
119
|
+
if (view.state !== "completed")
|
|
120
|
+
return null;
|
|
121
|
+
const event = await context.authority.queries.latestCompletion({
|
|
122
|
+
runId: view.runId,
|
|
123
|
+
atOrBefore: view.latestSequence,
|
|
124
|
+
});
|
|
125
|
+
const kind = event?.payload["outcome"];
|
|
126
|
+
if (kind === undefined)
|
|
127
|
+
return null;
|
|
128
|
+
const ticketStatus = event?.payload["ticketStatus"];
|
|
129
|
+
return {
|
|
130
|
+
kind,
|
|
131
|
+
reason: event?.payload["outcomeReason"] ?? null,
|
|
132
|
+
...(ticketStatus === undefined ? {} : { ticketStatus }),
|
|
133
|
+
...(event?.payload["issueUpdate"] === "failed"
|
|
134
|
+
? { issueUpdate: "failed" }
|
|
135
|
+
: {}),
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function titleOf(input, workflowId) {
|
|
139
|
+
const ticket = input?.["ticket"];
|
|
140
|
+
if (typeof ticket !== "string")
|
|
141
|
+
return null;
|
|
142
|
+
const fallback = `Cloving task ${String(input?.["cycleId"])}`;
|
|
143
|
+
const lines = ticket.split("\n");
|
|
144
|
+
if (workflowId === "develop-prompt") {
|
|
145
|
+
const first = lines.find((line) => /\S/.test(line));
|
|
146
|
+
return first === undefined
|
|
147
|
+
? fallback
|
|
148
|
+
: first.replace(/^# /, "").trim().slice(0, 200);
|
|
149
|
+
}
|
|
150
|
+
const first = lines[0] ?? "";
|
|
151
|
+
return first.startsWith("# ")
|
|
152
|
+
? first.slice(2).trim().slice(0, 200)
|
|
153
|
+
: fallback;
|
|
154
|
+
}
|
|
155
|
+
async function metadataOf(context, source) {
|
|
156
|
+
const document = source.digest
|
|
157
|
+
? await context.authority.queries.document(source.digest)
|
|
158
|
+
: undefined;
|
|
159
|
+
const input = record(JSON.parse(document ?? "null"));
|
|
160
|
+
const ticketId = input?.["ticketId"];
|
|
161
|
+
return {
|
|
162
|
+
ticketId: typeof ticketId === "string" && ticketId !== "" ? ticketId : null,
|
|
163
|
+
title: titleOf(input, source.workflowId),
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
async function listed(context, page) {
|
|
167
|
+
const identifiers = Object.keys(page.snapshot.state.runs)
|
|
168
|
+
.sort()
|
|
169
|
+
.filter((runId) => runId > page.after);
|
|
170
|
+
const shown = identifiers.slice(0, page.limit);
|
|
171
|
+
const views = [];
|
|
172
|
+
for (const runId of shown)
|
|
173
|
+
views.push(await viewOf(context, { snapshot: page.snapshot, runId }));
|
|
174
|
+
const runs = views.filter((view) => view !== undefined).map(summary);
|
|
175
|
+
return result("run-list", {
|
|
176
|
+
workflows: context.registry.workflowIds,
|
|
177
|
+
runs,
|
|
178
|
+
next: identifiers.length > shown.length ? (shown.at(-1) ?? null) : null,
|
|
179
|
+
worldReports: context.worldReports?.() ?? [],
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
export async function status(context, parameters) {
|
|
183
|
+
const { runId } = parameters;
|
|
184
|
+
const after = parameters["after"] ?? "";
|
|
185
|
+
const limit = parameters["limit"] ?? 50;
|
|
186
|
+
if (typeof after !== "string" || !wholeNumber(limit, 1) || limit > 500)
|
|
187
|
+
return invalidRequest("The status request is not valid.");
|
|
188
|
+
const current = await snapshot(context);
|
|
189
|
+
if (runId === undefined)
|
|
190
|
+
return listed(context, { snapshot: current, after, limit });
|
|
191
|
+
const named = typeof runId === "string" ? runId : "";
|
|
192
|
+
const view = await viewOf(context, { snapshot: current, runId: named });
|
|
193
|
+
if (view === undefined)
|
|
194
|
+
return failed("unknown-run", { detail: `No run has the ID ${named}.` });
|
|
195
|
+
const totals = await usageTotals(context, view.runId);
|
|
196
|
+
return result("run-status", {
|
|
197
|
+
run: {
|
|
198
|
+
...full({ ...view, ...totals }),
|
|
199
|
+
outcome: await outcomeOf(context, view),
|
|
200
|
+
...(await metadataOf(context, {
|
|
201
|
+
workflowId: view.workflowId,
|
|
202
|
+
digest: current.state.details[view.runId]?.input,
|
|
203
|
+
})),
|
|
204
|
+
},
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
const kinds = {
|
|
208
|
+
pause: "pause-run",
|
|
209
|
+
resume: "resume-run",
|
|
210
|
+
drop: "cancel-run",
|
|
211
|
+
};
|
|
212
|
+
async function reported(context, outcome) {
|
|
213
|
+
const { command, commandId, runId } = outcome;
|
|
214
|
+
const stored = await context.authority.queries.receipt(commandId);
|
|
215
|
+
const current = await snapshot(context);
|
|
216
|
+
const view = await viewOf(context, { snapshot: current, runId });
|
|
217
|
+
if (stored === undefined || view === undefined)
|
|
218
|
+
return failed("authority-unavailable", { commandId, runId });
|
|
219
|
+
const operations = current.operations.filter((operation) => operation.runId === runId);
|
|
220
|
+
return result("run-command", {
|
|
221
|
+
command,
|
|
222
|
+
runId,
|
|
223
|
+
commandId,
|
|
224
|
+
replayed: outcome.replayed,
|
|
225
|
+
receipt: publicReceipt(stored),
|
|
226
|
+
committed: {
|
|
227
|
+
state: view.state,
|
|
228
|
+
revision: view.revision,
|
|
229
|
+
revokedIntents: operations.filter((operation) => operation.releasedSequence === stored.sequence).length,
|
|
230
|
+
},
|
|
231
|
+
observed: {
|
|
232
|
+
condition: view.condition,
|
|
233
|
+
unresolvedEffects: view.unresolvedEffects,
|
|
234
|
+
},
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
export async function runCommand(context, parameters) {
|
|
238
|
+
const { command, runId, expectedRevision, commandId } = parameters;
|
|
239
|
+
if (typeof command !== "string" ||
|
|
240
|
+
!Object.hasOwn(kinds, command) ||
|
|
241
|
+
!isIdentifier(runId) ||
|
|
242
|
+
!isIdentifier(commandId) ||
|
|
243
|
+
!wholeNumber(expectedRevision, 1))
|
|
244
|
+
return invalidRequest("The run command request is not valid.");
|
|
245
|
+
const receipt = await context.gateway.execute({
|
|
246
|
+
principal: "operator",
|
|
247
|
+
command: { kind: kinds[command], commandId, runId, expectedRevision },
|
|
248
|
+
});
|
|
249
|
+
if (!committed(receipt)) {
|
|
250
|
+
const run = (await context.authority.state()).runs[runId];
|
|
251
|
+
return rejection(receipt, {
|
|
252
|
+
commandId,
|
|
253
|
+
runId,
|
|
254
|
+
currentRevision: run?.revision ?? null,
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
return reported(context, {
|
|
258
|
+
command,
|
|
259
|
+
commandId,
|
|
260
|
+
runId,
|
|
261
|
+
replayed: receipt.kind === "duplicate",
|
|
262
|
+
});
|
|
263
|
+
}
|
|
@@ -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>;
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { lstat, rm } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { authorityTiming, openAuthority, } from "../broker/actor/authority.js";
|
|
4
|
+
import { socketAddress } from "../broker/socket-address.js";
|
|
5
|
+
import { changeSignal } from "./changes.js";
|
|
6
|
+
import { decision, questions } from "./decision-handler.js";
|
|
7
|
+
import { events } from "./event-handler.js";
|
|
8
|
+
import { expiryScan } from "./expiry.js";
|
|
9
|
+
import { commandGateway, workerCommandBound } from "./gateway.js";
|
|
10
|
+
import { workflowRegistry, } from "./registry.js";
|
|
11
|
+
import { failed } from "./replies.js";
|
|
12
|
+
import { runCommand, status } from "./run-handlers.js";
|
|
13
|
+
import { submissionHandler } from "./submission-handler.js";
|
|
14
|
+
import { connectionLimits, listen, reachable } from "./transport.js";
|
|
15
|
+
import { workerPort } from "./worker-port.js";
|
|
16
|
+
export const serviceTiming = {
|
|
17
|
+
authority: authorityTiming,
|
|
18
|
+
expiryScanMilliseconds: 1_000,
|
|
19
|
+
livenessMilliseconds: 600_000,
|
|
20
|
+
followMilliseconds: 250,
|
|
21
|
+
resolverMilliseconds: 30_000,
|
|
22
|
+
idleMilliseconds: connectionLimits.idleMilliseconds,
|
|
23
|
+
};
|
|
24
|
+
export const serviceLimits = {
|
|
25
|
+
textBytes: 65_536,
|
|
26
|
+
documentBytes: 262_144,
|
|
27
|
+
pendingWorkerCommands: workerCommandBound,
|
|
28
|
+
};
|
|
29
|
+
function refused(reason, detail) {
|
|
30
|
+
return { kind: "refused", reason, detail };
|
|
31
|
+
}
|
|
32
|
+
async function privateDirectory(directory) {
|
|
33
|
+
const entry = await lstat(directory).catch(() => undefined);
|
|
34
|
+
if (entry === undefined || !entry.isDirectory())
|
|
35
|
+
return refused("insecure-runtime-directory", "not a directory");
|
|
36
|
+
const owned = entry.uid === process.getuid?.();
|
|
37
|
+
const mode = entry.mode & 0o777;
|
|
38
|
+
if (owned && (mode & 0o077) === 0)
|
|
39
|
+
return undefined;
|
|
40
|
+
return refused("insecure-runtime-directory", owned ? `mode ${mode.toString(8)}` : "owned by a different user");
|
|
41
|
+
}
|
|
42
|
+
async function endpoint(directory) {
|
|
43
|
+
const insecure = await privateDirectory(directory);
|
|
44
|
+
if (insecure !== undefined)
|
|
45
|
+
return insecure;
|
|
46
|
+
const address = socketAddress(join(directory, "control.sock"));
|
|
47
|
+
if (address.kind === "refused")
|
|
48
|
+
return address;
|
|
49
|
+
if (await reachable(address.path))
|
|
50
|
+
return refused("service-already-running", directory);
|
|
51
|
+
return address.path;
|
|
52
|
+
}
|
|
53
|
+
function wallClock() {
|
|
54
|
+
return new Date().toISOString();
|
|
55
|
+
}
|
|
56
|
+
function dispatcher(context) {
|
|
57
|
+
const run = submissionHandler(context);
|
|
58
|
+
const operations = new Map([
|
|
59
|
+
["run", (request) => run(request.parameters)],
|
|
60
|
+
["status", (request) => status(context, request.parameters)],
|
|
61
|
+
["questions", (request) => questions(context, request.parameters)],
|
|
62
|
+
["decision", (request) => decision(context, request.parameters)],
|
|
63
|
+
["run-command", (request) => runCommand(context, request.parameters)],
|
|
64
|
+
[
|
|
65
|
+
"events",
|
|
66
|
+
(request, connection) => events(context, { parameters: request.parameters, connection }),
|
|
67
|
+
],
|
|
68
|
+
]);
|
|
69
|
+
return (request, connection) => {
|
|
70
|
+
const operation = operations.get(request.operation);
|
|
71
|
+
if (operation === undefined)
|
|
72
|
+
return Promise.resolve(failed("unknown-operation", {
|
|
73
|
+
detail: `The service has no operation ${request.operation}.`,
|
|
74
|
+
}));
|
|
75
|
+
return operation(request, connection);
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
async function started(authority, setup) {
|
|
79
|
+
const { options, path, timing, registry, gateway, host } = setup;
|
|
80
|
+
const clock = options.clock ?? wallClock;
|
|
81
|
+
const { textBytes, documentBytes } = options.limits ?? serviceLimits;
|
|
82
|
+
await rm(path, { force: true });
|
|
83
|
+
const changes = changeSignal(authority.changes.subscribe);
|
|
84
|
+
const listener = await listen({
|
|
85
|
+
path,
|
|
86
|
+
limits: { idleMilliseconds: timing.idleMilliseconds },
|
|
87
|
+
handle: dispatcher({
|
|
88
|
+
authority,
|
|
89
|
+
registry,
|
|
90
|
+
gateway,
|
|
91
|
+
clock,
|
|
92
|
+
changed: changes.next,
|
|
93
|
+
livenessMilliseconds: timing.livenessMilliseconds,
|
|
94
|
+
followMilliseconds: timing.followMilliseconds,
|
|
95
|
+
resolverMilliseconds: timing.resolverMilliseconds,
|
|
96
|
+
textBytes,
|
|
97
|
+
documentBytes,
|
|
98
|
+
worldReports: () => host?.reports?.() ?? [],
|
|
99
|
+
}),
|
|
100
|
+
});
|
|
101
|
+
const stopping = new AbortController();
|
|
102
|
+
const delivering = Promise.allSettled([authority.deliver(stopping.signal)]);
|
|
103
|
+
const expiry = expiryScan({
|
|
104
|
+
authority,
|
|
105
|
+
gateway,
|
|
106
|
+
clock,
|
|
107
|
+
intervalMilliseconds: timing.expiryScanMilliseconds,
|
|
108
|
+
});
|
|
109
|
+
return {
|
|
110
|
+
socket: path,
|
|
111
|
+
epoch: authority.epoch,
|
|
112
|
+
worker: setup.worker,
|
|
113
|
+
close: async () => {
|
|
114
|
+
changes.close();
|
|
115
|
+
await expiry.stop();
|
|
116
|
+
await listener.close();
|
|
117
|
+
stopping.abort();
|
|
118
|
+
await delivering;
|
|
119
|
+
await released(authority, host);
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
async function released(authority, host) {
|
|
124
|
+
try {
|
|
125
|
+
await host?.close();
|
|
126
|
+
}
|
|
127
|
+
finally {
|
|
128
|
+
await authority.close();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
export async function startService(options) {
|
|
132
|
+
const path = await endpoint(options.runtimeDirectory);
|
|
133
|
+
if (typeof path !== "string")
|
|
134
|
+
return path;
|
|
135
|
+
const timing = options.timing ?? serviceTiming;
|
|
136
|
+
const registry = workflowRegistry(options.workflows);
|
|
137
|
+
const opening = await openAuthority(options.stateDirectory, {
|
|
138
|
+
delivery: options.delivery,
|
|
139
|
+
timing: timing.authority,
|
|
140
|
+
available: registry.available,
|
|
141
|
+
...(options.effects === undefined ? {} : { effects: options.effects }),
|
|
142
|
+
...(options.clock === undefined ? {} : { clock: options.clock }),
|
|
143
|
+
});
|
|
144
|
+
if (opening.kind === "refused")
|
|
145
|
+
return opening;
|
|
146
|
+
const { authority } = opening;
|
|
147
|
+
const gateway = serviceGateway(authority, { options, registry });
|
|
148
|
+
const worker = workerPort({ gateway, authority });
|
|
149
|
+
const host = await hosted(options, hostPorts(authority, worker));
|
|
150
|
+
if (host.kind === "refused") {
|
|
151
|
+
await authority.close();
|
|
152
|
+
return host;
|
|
153
|
+
}
|
|
154
|
+
try {
|
|
155
|
+
return {
|
|
156
|
+
kind: "started",
|
|
157
|
+
service: await started(authority, {
|
|
158
|
+
options,
|
|
159
|
+
path,
|
|
160
|
+
timing,
|
|
161
|
+
registry,
|
|
162
|
+
gateway,
|
|
163
|
+
worker,
|
|
164
|
+
host: host.host,
|
|
165
|
+
}),
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
const unclosed = await released(authority, host.host).then(() => "", (failure) => `; the close failed: ${message(failure)}`);
|
|
170
|
+
return refused("transport-failure", `${message(error)}${unclosed}`);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
function serviceGateway(authority, parts) {
|
|
174
|
+
const limits = parts.options.limits ?? serviceLimits;
|
|
175
|
+
return commandGateway({
|
|
176
|
+
authority,
|
|
177
|
+
registry: parts.registry,
|
|
178
|
+
clock: parts.options.clock ?? wallClock,
|
|
179
|
+
textBytes: limits.textBytes,
|
|
180
|
+
pendingWorkerCommands: limits.pendingWorkerCommands,
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
function hostPorts(authority, worker) {
|
|
184
|
+
return {
|
|
185
|
+
state: authority.state,
|
|
186
|
+
submit: worker.submit,
|
|
187
|
+
input: async (runId) => {
|
|
188
|
+
const digest = (await authority.state()).details[runId]?.input;
|
|
189
|
+
return typeof digest === "string"
|
|
190
|
+
? await authority.queries.document(digest)
|
|
191
|
+
: undefined;
|
|
192
|
+
},
|
|
193
|
+
document: authority.queries.document,
|
|
194
|
+
requestEffect: worker.requestEffect,
|
|
195
|
+
reportEffect: worker.reportEffect,
|
|
196
|
+
openGate: worker.openGate,
|
|
197
|
+
registerWait: worker.registerWait,
|
|
198
|
+
operation: authority.effects.operation,
|
|
199
|
+
workflowId: async (runId) => (await authority.queries.workflowIds())[runId],
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
function message(error) {
|
|
203
|
+
return String(Reflect.get(Object(error), "message"));
|
|
204
|
+
}
|
|
205
|
+
async function hosted(options, ports) {
|
|
206
|
+
try {
|
|
207
|
+
return { kind: "started", host: await options.host?.(ports) };
|
|
208
|
+
}
|
|
209
|
+
catch (error) {
|
|
210
|
+
return refused("host-unavailable", message(error));
|
|
211
|
+
}
|
|
212
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type Fields, type Reply } from "../protocol.ts";
|
|
2
|
+
import { type ServiceContext } from "./replies.ts";
|
|
3
|
+
export declare function runIdentity(commandId: string): string;
|
|
4
|
+
export declare function submissionHandler(context: ServiceContext): (parameters: Fields) => Promise<Reply>;
|