cloving 1.3.0 → 1.5.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/README.md +329 -215
- package/dist/src/agent-harness-shell.d.ts +2 -1
- package/dist/src/agent-harness-shell.js +8 -5
- package/dist/src/authority/command-wait-checks.d.ts +8 -0
- package/dist/src/authority/command-wait-checks.js +88 -0
- package/dist/src/authority/command-wait-results.d.ts +15 -0
- package/dist/src/authority/command-wait-results.js +73 -0
- package/dist/src/authority/command-wait-view.d.ts +21 -0
- package/dist/src/authority/command-wait-view.js +34 -0
- package/dist/src/authority/command-waits.d.ts +39 -0
- package/dist/src/authority/command-waits.js +97 -0
- package/dist/src/authority/commands.js +22 -1
- package/dist/src/authority/dispatch-decision.d.ts +8 -0
- package/dist/src/authority/dispatch-decision.js +26 -1
- package/dist/src/authority/effect-requests.js +6 -3
- package/dist/src/authority/effect-results.js +4 -2
- package/dist/src/authority/history-state.d.ts +2 -0
- package/dist/src/authority/history-state.js +13 -1
- package/dist/src/authority/instants.d.ts +1 -0
- package/dist/src/authority/instants.js +21 -0
- package/dist/src/authority/reduction-state.d.ts +2 -0
- package/dist/src/authority/reduction-state.js +5 -0
- package/dist/src/authority/reduction.js +24 -0
- package/dist/src/authority/status-input.d.ts +2 -0
- package/dist/src/authority/status.d.ts +2 -0
- package/dist/src/authority/status.js +1 -0
- package/dist/src/authority/stop-sequence.d.ts +1 -0
- package/dist/src/authority/stop-sequence.js +2 -1
- package/dist/src/authority/transitions.d.ts +6 -4
- package/dist/src/authority/transitions.js +7 -0
- package/dist/src/broker/actor/authority-health.d.ts +9 -0
- package/dist/src/broker/actor/authority-health.js +24 -0
- package/dist/src/broker/actor/authority-queries.d.ts +2 -1
- package/dist/src/broker/actor/authority-queries.js +14 -5
- package/dist/src/broker/actor/authority-receipts.js +1 -1
- package/dist/src/broker/actor/authority-runtime.d.ts +4 -2
- package/dist/src/broker/actor/authority-runtime.js +29 -20
- package/dist/src/broker/actor/authority-session.d.ts +6 -19
- package/dist/src/broker/actor/authority-session.js +66 -88
- package/dist/src/broker/actor/authority-settings.d.ts +2 -1
- package/dist/src/broker/actor/authority-settings.js +6 -3
- package/dist/src/broker/actor/authority-upgrades.d.ts +23 -2
- package/dist/src/broker/actor/authority-upgrades.js +8 -2
- package/dist/src/broker/actor/authority-watchdog.d.ts +6 -2
- package/dist/src/broker/actor/authority-watchdog.js +31 -9
- package/dist/src/broker/actor/authority.js +3 -1
- package/dist/src/broker/actor/delivery-intents.js +2 -0
- package/dist/src/broker/actor/effect-delivery.d.ts +1 -1
- package/dist/src/broker/actor/effect-delivery.js +15 -2
- package/dist/src/broker/actor/effect-plan.js +11 -2
- package/dist/src/broker/actor/effect-queries.d.ts +4 -0
- package/dist/src/broker/actor/effect-queries.js +9 -1
- package/dist/src/broker/actor/effect-turn.js +2 -0
- package/dist/src/broker/actor/projection-memory.d.ts +43 -0
- package/dist/src/broker/actor/projection-memory.js +207 -0
- package/dist/src/broker/actor/runtime-parts.d.ts +5 -0
- package/dist/src/broker/actor/runtime-parts.js +8 -3
- package/dist/src/broker/actor/stop-plan.js +9 -3
- package/dist/src/broker/actor/stop-turn.d.ts +2 -0
- package/dist/src/broker/actor/stop-turn.js +24 -11
- package/dist/src/broker/actor/turn-draft.d.ts +1 -0
- package/dist/src/broker/actor/turn-draft.js +4 -0
- package/dist/src/broker/actor/turn-state.js +5 -1
- package/dist/src/broker/authority-admission.js +60 -0
- package/dist/src/broker/authority-restore.d.ts +2 -0
- package/dist/src/broker/authority-restore.js +35 -1
- package/dist/src/broker/command-wait-restore.d.ts +31 -0
- package/dist/src/broker/command-wait-restore.js +86 -0
- package/dist/src/broker/decision-restore.d.ts +1 -1
- package/dist/src/broker/decision-restore.js +1 -0
- package/dist/src/broker/effect-upgrade.d.ts +3 -0
- package/dist/src/broker/effect-upgrade.js +11 -2
- package/dist/src/cli/arguments.d.ts +13 -0
- package/dist/src/cli/arguments.js +43 -3
- package/dist/src/cli/chat-stores.d.ts +2 -0
- package/dist/src/cli/chat-stores.js +113 -0
- package/dist/src/cli/client.d.ts +7 -2
- package/dist/src/cli/client.js +13 -7
- package/dist/src/cli/command-requests.d.ts +46 -0
- package/dist/src/cli/command-requests.js +84 -0
- package/dist/src/cli/command-waits.d.ts +9 -0
- package/dist/src/cli/command-waits.js +51 -0
- package/dist/src/cli/commands.js +70 -88
- package/dist/src/cli/config-file.d.ts +2 -2
- package/dist/src/cli/config-file.js +4 -2
- package/dist/src/cli/config-notice.js +5 -2
- package/dist/src/cli/doctor-retention.d.ts +2 -0
- package/dist/src/cli/doctor-retention.js +93 -0
- package/dist/src/cli/doctor-workflows.d.ts +5 -2
- package/dist/src/cli/doctor-workflows.js +12 -7
- package/dist/src/cli/doctor.js +11 -9
- package/dist/src/cli/harness-probes.d.ts +2 -0
- package/dist/src/cli/harness-probes.js +1 -1
- package/dist/src/cli/harness-processes.d.ts +6 -0
- package/dist/src/cli/harness-processes.js +36 -0
- package/dist/src/cli/init-command.d.ts +9 -0
- package/dist/src/cli/init-command.js +52 -0
- package/dist/src/cli/init-prompt-command.d.ts +10 -0
- package/dist/src/cli/init-prompt-command.js +145 -0
- package/dist/src/cli/init-prompt.d.ts +35 -0
- package/dist/src/cli/init-prompt.js +74 -0
- package/dist/src/cli/init-selection.d.ts +13 -0
- package/dist/src/cli/init-selection.js +75 -0
- package/dist/src/cli/main.d.ts +2 -0
- package/dist/src/cli/main.js +37 -7
- package/dist/src/cli/mcp-server.d.ts +1 -0
- package/dist/src/cli/mcp-server.js +156 -0
- package/dist/src/cli/mcp-tools.d.ts +15 -0
- package/dist/src/cli/mcp-tools.js +242 -0
- package/dist/src/cli/queue-arguments.d.ts +15 -0
- package/dist/src/cli/queue-arguments.js +31 -0
- package/dist/src/cli/queue-render.d.ts +3 -0
- package/dist/src/cli/queue-render.js +26 -0
- package/dist/src/cli/reload-render.d.ts +2 -0
- package/dist/src/cli/reload-render.js +12 -0
- package/dist/src/cli/render.d.ts +1 -1
- package/dist/src/cli/render.js +54 -38
- package/dist/src/cli/report-ci-jobs.d.ts +23 -0
- package/dist/src/cli/report-ci-jobs.js +103 -0
- package/dist/src/cli/report-ci-usage.d.ts +9 -0
- package/dist/src/cli/report-ci-usage.js +185 -0
- package/dist/src/cli/report-ci.d.ts +13 -0
- package/dist/src/cli/report-ci.js +74 -0
- package/dist/src/cli/report-closures.d.ts +6 -0
- package/dist/src/cli/report-closures.js +97 -0
- package/dist/src/cli/report-flow.d.ts +7 -0
- package/dist/src/cli/report-flow.js +122 -0
- package/dist/src/cli/report-github-reader.d.ts +29 -0
- package/dist/src/cli/report-github-reader.js +157 -0
- package/dist/src/cli/report-github.d.ts +15 -8
- package/dist/src/cli/report-github.js +131 -150
- package/dist/src/cli/report-operator.d.ts +3 -0
- package/dist/src/cli/report-operator.js +40 -0
- package/dist/src/cli/report-ready.d.ts +3 -0
- package/dist/src/cli/report-ready.js +96 -0
- package/dist/src/cli/report-text.d.ts +9 -0
- package/dist/src/cli/report-text.js +33 -0
- package/dist/src/cli/report.d.ts +1 -0
- package/dist/src/cli/report.js +104 -27
- package/dist/src/cli/runtime-arguments.d.ts +18 -3
- package/dist/src/cli/runtime-arguments.js +29 -20
- package/dist/src/cli/schedule-arguments.d.ts +14 -0
- package/dist/src/cli/schedule-arguments.js +26 -0
- package/dist/src/cli/schedule-render.d.ts +22 -0
- package/dist/src/cli/schedule-render.js +73 -0
- package/dist/src/cli/terminal-text.d.ts +3 -0
- package/dist/src/cli/terminal-text.js +28 -0
- package/dist/src/cli/toolchain.d.ts +1 -0
- package/dist/src/cli/toolchain.js +1 -0
- package/dist/src/cli/usage-render.d.ts +1 -0
- package/dist/src/cli/usage-render.js +28 -1
- package/dist/src/cli/usage.d.ts +2 -2
- package/dist/src/cli/usage.js +89 -11
- package/dist/src/cli/watch-actions.js +2 -2
- package/dist/src/cli/watch-api-document.d.ts +430 -0
- package/dist/src/cli/watch-api-document.js +291 -0
- package/dist/src/cli/watch-api-run.d.ts +56 -0
- package/dist/src/cli/watch-api-run.js +112 -0
- package/dist/src/cli/watch-api.d.ts +17 -0
- package/dist/src/cli/watch-api.js +230 -0
- package/dist/src/cli/watch-board-view.js +19 -2
- package/dist/src/cli/watch-board.d.ts +4 -2
- package/dist/src/cli/watch-board.js +53 -43
- package/dist/src/cli/watch-card-forms.d.ts +1 -1
- package/dist/src/cli/watch-card-forms.js +11 -10
- package/dist/src/cli/watch-client.d.ts +1 -1
- package/dist/src/cli/watch-client.js +2 -11
- package/dist/src/cli/watch-header-view.d.ts +1 -5
- package/dist/src/cli/watch-header-view.js +17 -21
- package/dist/src/cli/watch-model.d.ts +5 -1
- package/dist/src/cli/watch-model.js +20 -11
- package/dist/src/cli/watch-page.js +15 -15
- package/dist/src/cli/watch-phases.d.ts +12 -3
- package/dist/src/cli/watch-phases.js +68 -11
- package/dist/src/cli/watch-pr-board.js +1 -1
- package/dist/src/cli/watch-pr-command.d.ts +1 -0
- package/dist/src/cli/watch-pull-request.js +18 -8
- package/dist/src/cli/watch-reads.d.ts +3 -0
- package/dist/src/cli/watch-reads.js +22 -20
- package/dist/src/cli/watch-render.d.ts +15 -0
- package/dist/src/cli/watch-run-input.d.ts +0 -1
- package/dist/src/cli/watch-run-input.js +0 -13
- package/dist/src/cli/watch-server.js +24 -10
- package/dist/src/cli/watch-view.d.ts +0 -3
- package/dist/src/cli/watch-view.js +13 -13
- package/dist/src/cli.js +73 -12
- package/dist/src/command-wait.d.ts +4 -0
- package/dist/src/command-wait.js +45 -0
- package/dist/src/configuration-change.d.ts +7 -0
- package/dist/src/configuration-change.js +14 -0
- package/dist/src/configuration-display.js +2 -0
- package/dist/src/configuration-schema.d.ts +14 -0
- package/dist/src/configuration-schema.js +6 -2
- package/dist/src/daemon/attachment-file.d.ts +6 -0
- package/dist/src/daemon/attachment-file.js +86 -0
- package/dist/src/daemon/attachments.d.ts +14 -0
- package/dist/src/daemon/attachments.js +17 -0
- package/dist/src/daemon/claude-recovery.d.ts +50 -0
- package/dist/src/daemon/claude-recovery.js +208 -0
- package/dist/src/daemon/claude-stream.d.ts +27 -0
- package/dist/src/daemon/claude-stream.js +63 -0
- package/dist/src/daemon/claude-turn.d.ts +11 -25
- package/dist/src/daemon/claude-turn.js +64 -81
- package/dist/src/daemon/claude-worker.d.ts +5 -4
- package/dist/src/daemon/claude-worker.js +127 -126
- package/dist/src/daemon/daemon-adapters.d.ts +9 -0
- package/dist/src/daemon/daemon-adapters.js +33 -5
- package/dist/src/daemon/daemon-loops.d.ts +5 -1
- package/dist/src/daemon/daemon-loops.js +18 -10
- package/dist/src/daemon/daemon.js +80 -61
- package/dist/src/daemon/github-attach.d.ts +2 -0
- package/dist/src/daemon/github-attach.js +222 -0
- package/dist/src/daemon/github-calls.js +1 -1
- package/dist/src/daemon/github-ci-filters.d.ts +6 -0
- package/dist/src/daemon/github-ci-filters.js +138 -0
- package/dist/src/daemon/github-ci-workflows.d.ts +10 -0
- package/dist/src/daemon/github-ci-workflows.js +148 -0
- package/dist/src/daemon/github-ci.js +22 -4
- package/dist/src/daemon/github-issue-methods.d.ts +2 -0
- package/dist/src/daemon/github-issue-methods.js +37 -2
- package/dist/src/daemon/github-merge-call.d.ts +2 -1
- package/dist/src/daemon/github-merge-call.js +10 -3
- package/dist/src/daemon/github-merge.js +52 -24
- package/dist/src/daemon/github-methods.js +18 -4
- package/dist/src/daemon/github-operation.d.ts +4 -0
- package/dist/src/daemon/github-operation.js +6 -0
- package/dist/src/daemon/github-worker.d.ts +4 -0
- package/dist/src/daemon/github-worker.js +6 -0
- package/dist/src/daemon/issue-queue.d.ts +4 -1
- package/dist/src/daemon/issue-queue.js +76 -78
- package/dist/src/daemon/merge-turns.d.ts +10 -0
- package/dist/src/daemon/merge-turns.js +37 -0
- package/dist/src/daemon/notify-events.d.ts +6 -0
- package/dist/src/daemon/notify-events.js +84 -0
- package/dist/src/daemon/notify-journal.js +1 -1
- package/dist/src/daemon/notify-message.d.ts +4 -1
- package/dist/src/daemon/notify-message.js +36 -0
- package/dist/src/daemon/notify.d.ts +1 -1
- package/dist/src/daemon/notify.js +5 -77
- package/dist/src/daemon/operation-journal.d.ts +1 -0
- package/dist/src/daemon/queue-control.d.ts +13 -0
- package/dist/src/daemon/queue-control.js +86 -0
- package/dist/src/daemon/queue-journal.d.ts +20 -0
- package/dist/src/daemon/queue-journal.js +89 -0
- package/dist/src/daemon/queue-status.d.ts +9 -3
- package/dist/src/daemon/queue-status.js +17 -4
- package/dist/src/daemon/record-archive.d.ts +19 -0
- package/dist/src/daemon/record-archive.js +82 -0
- package/dist/src/daemon/record-sweep.d.ts +24 -0
- package/dist/src/daemon/record-sweep.js +147 -0
- package/dist/src/daemon/resume-index-lock.d.ts +13 -0
- package/dist/src/daemon/resume-index-lock.js +160 -0
- package/dist/src/daemon/resume-worktree.d.ts +7 -0
- package/dist/src/daemon/resume-worktree.js +29 -0
- package/dist/src/daemon/retrying-turn.d.ts +2 -12
- package/dist/src/daemon/retrying-turn.js +98 -172
- package/dist/src/daemon/schedule-control.d.ts +26 -0
- package/dist/src/daemon/schedule-control.js +110 -0
- package/dist/src/daemon/schedule-journal.d.ts +2 -15
- package/dist/src/daemon/schedule-journal.js +67 -4
- package/dist/src/daemon/settings-reload.d.ts +26 -0
- package/dist/src/daemon/settings-reload.js +82 -0
- package/dist/src/daemon/ticket-registration.d.ts +2 -7
- package/dist/src/daemon/ticket-registration.js +15 -81
- package/dist/src/daemon/turn-attempt-journal.d.ts +38 -0
- package/dist/src/daemon/turn-attempt-journal.js +136 -0
- package/dist/src/daemon/turn-attempts.d.ts +47 -0
- package/dist/src/daemon/turn-attempts.js +166 -0
- package/dist/src/daemon/turn-details.d.ts +4 -0
- package/dist/src/daemon/turn-details.js +33 -0
- package/dist/src/daemon/turn-report.d.ts +8 -1
- package/dist/src/daemon/turn-report.js +39 -0
- package/dist/src/daemon/work-tree.d.ts +9 -0
- package/dist/src/daemon/work-tree.js +20 -0
- package/dist/src/daemon/worker-profile.d.ts +9 -0
- package/dist/src/daemon/worker-profile.js +44 -0
- package/dist/src/daemon/workflow-generations.d.ts +7 -4
- package/dist/src/daemon/workflow-generations.js +22 -14
- package/dist/src/daemon/workflow-reload.d.ts +41 -0
- package/dist/src/daemon/workflow-reload.js +244 -0
- package/dist/src/daemon/workflow-replay.d.ts +2 -1
- package/dist/src/daemon/workflow-replay.js +7 -3
- package/dist/src/daemon/workflow-schedules.d.ts +3 -0
- package/dist/src/daemon/workflow-schedules.js +98 -45
- package/dist/src/daemon/worktree-processes.d.ts +9 -0
- package/dist/src/daemon/worktree-processes.js +151 -0
- package/dist/src/doctor-report.d.ts +4 -6
- package/dist/src/doctor-report.js +8 -13
- package/dist/src/harness-start.d.ts +15 -0
- package/dist/src/harness-start.js +37 -0
- package/dist/src/host/command-wait.d.ts +38 -0
- package/dist/src/host/command-wait.js +115 -0
- package/dist/src/host/start-delivery.d.ts +5 -7
- package/dist/src/host/start-delivery.js +3 -15
- package/dist/src/host/step-bridge-host.d.ts +2 -0
- package/dist/src/host/step-bridge-host.js +21 -0
- package/dist/src/operation-identity.d.ts +1 -0
- package/dist/src/operation-identity.js +4 -0
- package/dist/src/private-config.schema.json +71 -0
- package/dist/src/project-config.schema.json +40 -0
- package/dist/src/project-settings.d.ts +16 -2
- package/dist/src/project-settings.js +35 -1
- package/dist/src/queue-spend.d.ts +4 -0
- package/dist/src/queue-spend.js +21 -0
- package/dist/src/queue-state.d.ts +26 -0
- package/dist/src/queue-state.js +34 -0
- package/dist/src/record-retention.d.ts +46 -0
- package/dist/src/record-retention.js +81 -0
- package/dist/src/relay/relay-service.d.ts +3 -0
- package/dist/src/relay/relay-service.js +5 -3
- package/dist/src/report-ci.d.ts +164 -0
- package/dist/src/report-ci.js +32 -0
- package/dist/src/report-effects.d.ts +15 -0
- package/dist/src/report-effects.js +212 -0
- package/dist/src/report-flow-types.d.ts +38 -0
- package/dist/src/report-flow-types.js +7 -0
- package/dist/src/report-flow.d.ts +43 -0
- package/dist/src/report-flow.js +193 -0
- package/dist/src/report-operator.d.ts +67 -0
- package/dist/src/report-operator.js +25 -0
- package/dist/src/report-quality.d.ts +221 -0
- package/dist/src/report-quality.js +94 -0
- package/dist/src/report-ready.d.ts +23 -0
- package/dist/src/report-ready.js +117 -0
- package/dist/src/report-statistics.d.ts +2 -1
- package/dist/src/report-statistics.js +40 -4
- package/dist/src/report.d.ts +588 -47
- package/dist/src/report.js +156 -41
- package/dist/src/schedule-progress.d.ts +33 -0
- package/dist/src/schedule-progress.js +45 -0
- package/dist/src/service/active-tickets.js +11 -6
- package/dist/src/service/command-waits.d.ts +34 -0
- package/dist/src/service/command-waits.js +86 -0
- package/dist/src/service/dispatcher.d.ts +4 -0
- package/dist/src/service/dispatcher.js +33 -0
- package/dist/src/service/expiry.js +2 -0
- package/dist/src/service/gateway.js +3 -1
- package/dist/src/service/queue-handlers.d.ts +4 -0
- package/dist/src/service/queue-handlers.js +32 -0
- package/dist/src/service/queue-spend.d.ts +6 -0
- package/dist/src/service/queue-spend.js +68 -0
- package/dist/src/service/registry.d.ts +28 -2
- package/dist/src/service/registry.js +48 -0
- package/dist/src/service/replies.d.ts +22 -8
- package/dist/src/service/replies.js +16 -2
- package/dist/src/service/run-handlers.js +37 -12
- package/dist/src/service/run-metadata.d.ts +15 -1
- package/dist/src/service/run-metadata.js +93 -8
- package/dist/src/service/service.d.ts +11 -3
- package/dist/src/service/service.js +22 -37
- package/dist/src/service/submission-handler.js +18 -4
- package/dist/src/service/worker-port.js +9 -1
- package/dist/src/service/worker-totals.d.ts +6 -0
- package/dist/src/service/worker-totals.js +8 -1
- package/dist/src/service/workflow-reload.d.ts +35 -0
- package/dist/src/service/workflow-reload.js +52 -0
- package/dist/src/step-bridge.d.ts +20 -0
- package/dist/src/steps/command-wait.d.ts +12 -0
- package/dist/src/steps/command-wait.js +26 -0
- package/dist/src/steps/open-decision-wait.d.ts +2 -0
- package/dist/src/steps/{decision-gate.js → open-decision-wait.js} +0 -7
- package/dist/src/steps/review-by-person.js +4 -1
- package/dist/src/steps/wait-for-command.d.ts +3 -0
- package/dist/src/steps/wait-for-command.js +17 -0
- package/dist/src/steps/wait-for-decision.js +1 -1
- package/dist/src/storage/command-wait-rows.d.ts +30 -0
- package/dist/src/storage/command-wait-rows.js +96 -0
- package/dist/src/storage/decision-snapshots.d.ts +8 -2
- package/dist/src/storage/decision-snapshots.js +16 -8
- package/dist/src/storage/domain-changes.d.ts +3 -1
- package/dist/src/storage/domain-changes.js +4 -0
- package/dist/src/storage/domain-schema.d.ts +16 -1
- package/dist/src/storage/domain-schema.js +35 -4
- package/dist/src/storage/effect-schema.d.ts +2 -0
- package/dist/src/storage/effect-schema.js +9 -0
- package/dist/src/storage/projection-changes.d.ts +12 -0
- package/dist/src/storage/projection-changes.js +194 -0
- package/dist/src/storage/projection-lookups.d.ts +7 -0
- package/dist/src/storage/projection-lookups.js +30 -0
- package/dist/src/testing-requests.d.ts +15 -0
- package/dist/src/testing-requests.js +93 -0
- package/dist/src/testing.d.ts +4 -10
- package/dist/src/testing.js +33 -86
- package/dist/src/worker-usage.d.ts +1 -0
- package/dist/src/worker-usage.js +3 -0
- package/dist/src/workflow-candidate.d.ts +1 -0
- package/dist/src/workflow-candidate.js +12 -1
- package/dist/src/workflow-contracts.d.ts +1 -0
- package/dist/src/workflow-contracts.js +9 -2
- package/dist/src/workflow-declaration.d.ts +1 -0
- package/dist/src/workflow-declaration.js +3 -0
- package/dist/src/workflow-discovery.d.ts +2 -13
- package/dist/src/workflow-discovery.js +1 -13
- package/dist/src/workflow-refusals.js +0 -1
- package/dist/src/workflows.d.ts +1 -1
- package/dist/src/workflows.js +1 -1
- package/dist/tools/compile-workflows.js +3 -0
- package/dist/tools/project-configuration.d.ts +7 -2
- package/dist/tools/project-configuration.js +30 -1
- package/dist/tools/red-green-command.d.ts +1 -0
- package/dist/tools/red-green-command.js +174 -0
- package/dist/tools/red-green-process.d.ts +10 -0
- package/dist/tools/red-green-process.js +59 -0
- package/dist/tools/self-host-processes.d.ts +2 -0
- package/dist/tools/self-host-processes.js +69 -26
- package/dist/tools/self-host-project.d.ts +2 -0
- package/dist/tools/self-host-project.js +30 -77
- package/dist/tools/self-host-runtime.js +1 -1
- package/dist/tools/self-host.js +76 -34
- package/dist/tools/template-command.d.ts +1 -0
- package/dist/tools/template-command.js +160 -0
- package/dist/tools/template-copy.d.ts +11 -0
- package/dist/tools/template-copy.js +130 -0
- package/dist/tools/template-files.d.ts +17 -0
- package/dist/tools/template-files.js +74 -0
- package/dist/tools/workflow-bundles.js +1 -0
- package/dist/tools/workflow-candidate-counts.js +2 -2
- package/dist/tools/workflow-candidate-program.d.ts +4 -2
- package/dist/tools/workflow-candidate-program.js +30 -11
- package/dist/tools/workflow-candidate-shape.d.ts +3 -0
- package/dist/tools/workflow-candidate-shape.js +90 -0
- package/dist/tools/workflow-candidate-source.d.ts +1 -0
- package/dist/tools/workflow-candidate-source.js +26 -4
- package/dist/tools/workflow-candidate-syntax.d.ts +2 -2
- package/dist/tools/workflow-candidate-syntax.js +24 -94
- package/dist/tools/workflow-command.js +1 -2
- package/dist/tools/workflow-folders.d.ts +2 -3
- package/dist/tools/workflow-folders.js +1 -1
- package/package.json +17 -9
- package/templates/develop/README.md +93 -4
- package/templates/develop/develop/flow-tests.ts +38 -1
- package/templates/develop/develop/interruption-tests.ts +157 -0
- package/templates/develop/develop/local.ts +1 -0
- package/templates/develop/develop/option-tests.ts +138 -9
- package/templates/develop/develop/pull.ts +5 -1
- package/templates/develop/develop/red-green.ts +55 -0
- package/templates/develop/develop/refusal-tests.ts +77 -0
- package/templates/develop/develop/report.ts +31 -11
- package/templates/develop/develop/round.ts +1 -0
- package/templates/develop/develop/scenarios.ts +27 -0
- package/templates/develop/develop/turn.ts +28 -7
- package/templates/develop/develop.declaration.json +1 -1
- package/templates/develop/develop.test.ts +4 -0
- package/templates/develop/template.json +29 -2
- package/templates/idea-to-issue/README.md +27 -0
- package/templates/idea-to-issue/idea-to-issue/effects.ts +52 -0
- package/templates/idea-to-issue/idea-to-issue/leave.ts +10 -0
- package/templates/idea-to-issue/idea-to-issue/next.ts +29 -0
- package/templates/idea-to-issue/idea-to-issue/post-person.ts +18 -0
- package/templates/idea-to-issue/idea-to-issue/post.ts +50 -0
- package/templates/idea-to-issue/idea-to-issue/queue.ts +27 -0
- package/templates/idea-to-issue/idea-to-issue/review.ts +42 -0
- package/templates/idea-to-issue/idea-to-issue/scenarios.ts +50 -0
- package/templates/idea-to-issue/idea-to-issue/turn.ts +40 -0
- package/templates/idea-to-issue/idea-to-issue.declaration.json +16 -0
- package/templates/idea-to-issue/idea-to-issue.test.ts +79 -0
- package/templates/idea-to-issue/idea-to-issue.ts +49 -0
- package/templates/idea-to-issue/template.json +81 -0
- package/templates/review-day/README.md +97 -0
- package/templates/review-day/review-day/critique.ts +58 -0
- package/templates/review-day/review-day/decision.ts +29 -0
- package/templates/review-day/review-day/facts.ts +69 -0
- package/templates/review-day/review-day/label.ts +29 -0
- package/templates/review-day/review-day/next.ts +28 -0
- package/templates/review-day/review-day/post.ts +27 -0
- package/templates/review-day/review-day/report.ts +98 -0
- package/templates/review-day/review-day/rules.ts +12 -0
- package/templates/review-day/review-day/scenarios.ts +76 -0
- package/templates/review-day/review-day/turn.ts +73 -0
- package/templates/review-day/review-day.declaration.json +16 -0
- package/templates/review-day/review-day.test.ts +362 -0
- package/templates/review-day/review-day.ts +37 -0
- package/templates/review-day/template.json +56 -0
- package/dist/src/cli/watch-start-view.d.ts +0 -18
- package/dist/src/cli/watch-start-view.js +0 -77
- package/dist/src/steps/decision-gate.d.ts +0 -3
- package/dist/workflows/develop-prd.d.ts +0 -7
- package/dist/workflows/develop-prd.js +0 -165
- package/dist/workflows/develop-ticket.d.ts +0 -9
- package/dist/workflows/develop-ticket.js +0 -207
- package/dist/workflows/issue-labels.d.ts +0 -16
- package/dist/workflows/issue-labels.js +0 -70
- package/dist/workflows/ticket-prompts.d.ts +0 -35
- package/dist/workflows/ticket-prompts.js +0 -147
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { type TaggedRun } from "./world-runs.ts";
|
|
2
|
-
export type WorkflowFunction = (input: unknown
|
|
3
|
-
export interface
|
|
4
|
-
readonly gateId
|
|
5
|
-
readonly decision
|
|
6
|
-
readonly answer
|
|
7
|
-
}
|
|
8
|
-
export interface RunIntent extends Partial<Continuation> {
|
|
2
|
+
export type WorkflowFunction = (input: unknown) => Promise<unknown>;
|
|
3
|
+
export interface RunIntent {
|
|
4
|
+
readonly gateId?: string;
|
|
5
|
+
readonly decision?: string;
|
|
6
|
+
readonly answer?: string | null;
|
|
9
7
|
readonly kind: string;
|
|
10
8
|
readonly runId: string;
|
|
11
9
|
readonly operationId: string;
|
|
@@ -17,27 +17,15 @@ async function reconciled(parts, intent) {
|
|
|
17
17
|
evidence: found.map((run) => `world-run:${run.receipt}`).join(" "),
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
-
async function continuation(parts, intent) {
|
|
21
|
-
const { kind, gateId, decision, answer } = intent;
|
|
22
|
-
if (kind === "start-run")
|
|
23
|
-
return undefined;
|
|
24
|
-
if (kind !== "continue-run" || gateId === undefined || decision === undefined)
|
|
25
|
-
throw new Error(`unsupported-intent: ${kind}`);
|
|
26
|
-
if (answer === undefined || answer === null)
|
|
27
|
-
return { gateId, decision, answer: null };
|
|
28
|
-
const text = await parts.document(answer);
|
|
29
|
-
if (text === undefined)
|
|
30
|
-
throw new Error(`answer-not-available: ${gateId}`);
|
|
31
|
-
return { gateId, decision, answer: text };
|
|
32
|
-
}
|
|
33
20
|
async function delivered(parts, intent) {
|
|
34
|
-
|
|
21
|
+
if (intent.kind !== "start-run")
|
|
22
|
+
throw new Error(`unsupported-intent: ${intent.kind}`);
|
|
35
23
|
const workflow = await parts.workflow(intent);
|
|
36
24
|
const input = await parts.input(intent.runId);
|
|
37
25
|
if (workflow === undefined || input === undefined)
|
|
38
26
|
throw new Error(`start-not-available: ${intent.runId}`);
|
|
39
27
|
const argument = JSON.parse(input);
|
|
40
|
-
const started = await start(workflow, [argument
|
|
28
|
+
const started = await start(workflow, [argument], {
|
|
41
29
|
attributes: {
|
|
42
30
|
[runTag]: intent.runId,
|
|
43
31
|
[operationTag]: intent.operationId,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type CommandWaitPorts } from "./command-wait.ts";
|
|
1
2
|
import { type GateOpening, type GateReceipt, type WaitRegistration } from "./gate-bridge.ts";
|
|
2
3
|
export type { GateOpening, GateReceipt, WaitRegistration, } from "./gate-bridge.ts";
|
|
3
4
|
import { type RunWaitPorts } from "./run-wait.ts";
|
|
@@ -41,6 +42,7 @@ export interface BridgeTiming {
|
|
|
41
42
|
}
|
|
42
43
|
export declare const bridgeTiming: BridgeTiming;
|
|
43
44
|
export interface BridgePorts {
|
|
45
|
+
readonly commandWait?: CommandWaitPorts;
|
|
44
46
|
readonly decisionReceived?: (runId: string, gateId: string) => Promise<boolean>;
|
|
45
47
|
readonly runWait?: RunWaitPorts;
|
|
46
48
|
readonly call: () => StepCall;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { commandWaitBridge } from "./command-wait.js";
|
|
1
2
|
import { createHash } from "node:crypto";
|
|
2
3
|
import { setTimeout as delay } from "node:timers/promises";
|
|
3
4
|
import { getStepMetadata, getWorkflowMetadata } from "workflow";
|
|
@@ -155,9 +156,29 @@ async function gate(hold, request) {
|
|
|
155
156
|
return { kind: "unavailable", reason: "unknown-world-run" };
|
|
156
157
|
return await openBridgeGate(hold.ports, subject);
|
|
157
158
|
}
|
|
159
|
+
function hostCommandWait(hold) {
|
|
160
|
+
return commandWaitBridge({
|
|
161
|
+
...(hold.ports.commandWait === undefined
|
|
162
|
+
? {}
|
|
163
|
+
: { commandWait: hold.ports.commandWait }),
|
|
164
|
+
stopped: hold.ports.stopped,
|
|
165
|
+
pollMilliseconds: hold.timing.pollMilliseconds,
|
|
166
|
+
retryMilliseconds: hold.timing.retryMilliseconds,
|
|
167
|
+
runStatus: async (runId) => (await hold.ports.state()).runs[runId]?.status,
|
|
168
|
+
subject: async () => {
|
|
169
|
+
const call = hold.ports.call();
|
|
170
|
+
const world = await located(hold, call.worldRunId);
|
|
171
|
+
if (world === undefined)
|
|
172
|
+
return undefined;
|
|
173
|
+
await inWork(hold, world.runId);
|
|
174
|
+
return { runId: world.runId, commandId: transportOf(call) };
|
|
175
|
+
},
|
|
176
|
+
});
|
|
177
|
+
}
|
|
158
178
|
export function stepBridge(ports) {
|
|
159
179
|
const hold = { ports, timing: ports.timing ?? bridgeTiming };
|
|
160
180
|
return {
|
|
181
|
+
...hostCommandWait(hold),
|
|
161
182
|
effect: (request) => effect(hold, request),
|
|
162
183
|
gate: (request) => gate(hold, request),
|
|
163
184
|
waitForDecision: async (request) => {
|
|
@@ -48,6 +48,10 @@ export function operationScope(operationId) {
|
|
|
48
48
|
return null;
|
|
49
49
|
return { run, operation };
|
|
50
50
|
}
|
|
51
|
+
export function operationPhase(operationId) {
|
|
52
|
+
const [marker, , , phase] = parsedList(operationId);
|
|
53
|
+
return marker === "cloving-operation" && isComponent(phase) ? phase : null;
|
|
54
|
+
}
|
|
51
55
|
function parsedList(text) {
|
|
52
56
|
try {
|
|
53
57
|
const value = JSON.parse(text);
|
|
@@ -19,6 +19,42 @@
|
|
|
19
19
|
"type": "string",
|
|
20
20
|
"pattern": "\\S"
|
|
21
21
|
}
|
|
22
|
+
},
|
|
23
|
+
"redGreen": {
|
|
24
|
+
"type": "object",
|
|
25
|
+
"properties": {
|
|
26
|
+
"test": {
|
|
27
|
+
"type": "array",
|
|
28
|
+
"minItems": 1,
|
|
29
|
+
"items": {
|
|
30
|
+
"type": "string",
|
|
31
|
+
"pattern": "^[^\\u0000]+$"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"testFiles": {
|
|
35
|
+
"type": "array",
|
|
36
|
+
"items": {
|
|
37
|
+
"type": "string",
|
|
38
|
+
"pattern": "^[^\\u0000]+$"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"prepare": {
|
|
42
|
+
"type": "array",
|
|
43
|
+
"minItems": 1,
|
|
44
|
+
"items": {
|
|
45
|
+
"type": "string",
|
|
46
|
+
"pattern": "^[^\\u0000]+$"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"assertionPattern": {
|
|
50
|
+
"type": "string"
|
|
51
|
+
},
|
|
52
|
+
"skipPattern": {
|
|
53
|
+
"type": "string"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"required": ["test", "testFiles"],
|
|
57
|
+
"additionalProperties": false
|
|
22
58
|
}
|
|
23
59
|
},
|
|
24
60
|
"additionalProperties": false
|
|
@@ -49,6 +85,10 @@
|
|
|
49
85
|
"minimum": 10,
|
|
50
86
|
"maximum": 3600
|
|
51
87
|
},
|
|
88
|
+
"dailySpendLimitUsd": {
|
|
89
|
+
"type": "number",
|
|
90
|
+
"exclusiveMinimum": 0
|
|
91
|
+
},
|
|
52
92
|
"lanes": {
|
|
53
93
|
"type": "integer",
|
|
54
94
|
"minimum": 1,
|
|
@@ -254,6 +294,37 @@
|
|
|
254
294
|
}
|
|
255
295
|
},
|
|
256
296
|
"additionalProperties": false
|
|
297
|
+
},
|
|
298
|
+
"retention": {
|
|
299
|
+
"type": "object",
|
|
300
|
+
"properties": {
|
|
301
|
+
"days": {
|
|
302
|
+
"anyOf": [
|
|
303
|
+
{
|
|
304
|
+
"type": "integer",
|
|
305
|
+
"minimum": 1
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
"const": null
|
|
309
|
+
}
|
|
310
|
+
]
|
|
311
|
+
},
|
|
312
|
+
"action": {
|
|
313
|
+
"enum": ["archive", "delete"]
|
|
314
|
+
},
|
|
315
|
+
"archiveFolder": {
|
|
316
|
+
"anyOf": [
|
|
317
|
+
{
|
|
318
|
+
"type": "string",
|
|
319
|
+
"pattern": "^/"
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
"const": null
|
|
323
|
+
}
|
|
324
|
+
]
|
|
325
|
+
}
|
|
326
|
+
},
|
|
327
|
+
"additionalProperties": false
|
|
257
328
|
}
|
|
258
329
|
},
|
|
259
330
|
"additionalProperties": false,
|
|
@@ -19,6 +19,42 @@
|
|
|
19
19
|
"type": "string",
|
|
20
20
|
"pattern": "\\S"
|
|
21
21
|
}
|
|
22
|
+
},
|
|
23
|
+
"redGreen": {
|
|
24
|
+
"type": "object",
|
|
25
|
+
"properties": {
|
|
26
|
+
"test": {
|
|
27
|
+
"type": "array",
|
|
28
|
+
"minItems": 1,
|
|
29
|
+
"items": {
|
|
30
|
+
"type": "string",
|
|
31
|
+
"pattern": "^[^\\u0000]+$"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"testFiles": {
|
|
35
|
+
"type": "array",
|
|
36
|
+
"items": {
|
|
37
|
+
"type": "string",
|
|
38
|
+
"pattern": "^[^\\u0000]+$"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"prepare": {
|
|
42
|
+
"type": "array",
|
|
43
|
+
"minItems": 1,
|
|
44
|
+
"items": {
|
|
45
|
+
"type": "string",
|
|
46
|
+
"pattern": "^[^\\u0000]+$"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"assertionPattern": {
|
|
50
|
+
"type": "string"
|
|
51
|
+
},
|
|
52
|
+
"skipPattern": {
|
|
53
|
+
"type": "string"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"required": ["test", "testFiles"],
|
|
57
|
+
"additionalProperties": false
|
|
22
58
|
}
|
|
23
59
|
},
|
|
24
60
|
"additionalProperties": false
|
|
@@ -49,6 +85,10 @@
|
|
|
49
85
|
"minimum": 10,
|
|
50
86
|
"maximum": 3600
|
|
51
87
|
},
|
|
88
|
+
"dailySpendLimitUsd": {
|
|
89
|
+
"type": "number",
|
|
90
|
+
"exclusiveMinimum": 0
|
|
91
|
+
},
|
|
52
92
|
"lanes": {
|
|
53
93
|
"type": "integer",
|
|
54
94
|
"minimum": 1,
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import { type Configuration } from "./configuration-schema.ts";
|
|
1
|
+
import { type Configuration, type RedGreenSettings } from "./configuration-schema.ts";
|
|
2
2
|
import type { TurnProfiles } from "./turn-profile.ts";
|
|
3
3
|
import type { TokenPrices } from "./token-prices.ts";
|
|
4
4
|
export type SettingSource = "environment" | "private" | "project";
|
|
5
|
-
export
|
|
5
|
+
export declare const reloadedSettingFields: readonly string[];
|
|
6
|
+
export interface TurnSettings {
|
|
7
|
+
readonly profiles: TurnProfiles;
|
|
8
|
+
readonly fallbackModels: readonly string[];
|
|
9
|
+
readonly tokenPrices: TokenPrices;
|
|
10
|
+
}
|
|
11
|
+
export type SettingValue = null | string | number | readonly string[] | TurnProfiles | TokenPrices | RedGreenSettings;
|
|
6
12
|
export declare const settingVariables: Readonly<Record<string, string>>;
|
|
7
13
|
export declare function absoluteWorkflowFolder(folder: string | undefined): string | undefined;
|
|
8
14
|
export declare function configurationRoot(environment: Readonly<NodeJS.ProcessEnv>, home: string): string;
|
|
@@ -16,4 +22,12 @@ export declare function resolveSettings(environment: Readonly<NodeJS.ProcessEnv>
|
|
|
16
22
|
readonly profiles: TurnProfiles;
|
|
17
23
|
readonly harness?: Configuration["harness"];
|
|
18
24
|
readonly sources: Readonly<Record<string, SettingSource>>;
|
|
25
|
+
readonly values: Readonly<Record<string, SettingValue>>;
|
|
19
26
|
};
|
|
27
|
+
interface ResolvedFields {
|
|
28
|
+
readonly environment: Readonly<NodeJS.ProcessEnv>;
|
|
29
|
+
readonly values: Readonly<Record<string, SettingValue>>;
|
|
30
|
+
readonly profiles: TurnProfiles;
|
|
31
|
+
}
|
|
32
|
+
export declare function settingDigests(resolved: ResolvedFields, digest: (text: string) => string): Readonly<Record<string, string>>;
|
|
33
|
+
export {};
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
import { configuration } from "./configuration-schema.js";
|
|
1
|
+
import { configuration, settingFields, } from "./configuration-schema.js";
|
|
2
|
+
export const reloadedSettingFields = [
|
|
3
|
+
"fallbackModels",
|
|
4
|
+
"profiles",
|
|
5
|
+
"tokenPrices",
|
|
6
|
+
"workflows.folder",
|
|
7
|
+
];
|
|
2
8
|
export const settingVariables = {
|
|
3
9
|
"checks.beforeMerge": "CLOVING_CHECK_COMMAND",
|
|
4
10
|
"checks.required": "CLOVING_REQUIRED_CHECKS",
|
|
11
|
+
"checks.redGreen": "CLOVING_RED_GREEN",
|
|
5
12
|
"tickets.command": "CLOVING_TICKET_COMMAND",
|
|
6
13
|
"tickets.nextCommand": "CLOVING_NEXT_COMMAND",
|
|
7
14
|
"queue.everySeconds": "CLOVING_QUEUE_SECONDS",
|
|
8
15
|
"queue.lanes": "CLOVING_QUEUE_LANES",
|
|
16
|
+
"queue.dailySpendLimitUsd": "CLOVING_QUEUE_DAILY_SPEND_USD",
|
|
9
17
|
"harness.name": "CLOVING_WORKER",
|
|
10
18
|
fallbackModels: "CLOVING_FALLBACK_MODELS",
|
|
11
19
|
tokenPrices: "CLOVING_TOKEN_PRICES",
|
|
@@ -16,6 +24,9 @@ export const settingVariables = {
|
|
|
16
24
|
"selfUpdate.everySeconds": "CLOVING_SELF_UPDATE_SECONDS",
|
|
17
25
|
"github.command": "CLOVING_GH_COMMAND",
|
|
18
26
|
"workflows.folder": "CLOVING_WORKFLOW_FOLDER",
|
|
27
|
+
"retention.days": "CLOVING_RETENTION_DAYS",
|
|
28
|
+
"retention.action": "CLOVING_RETENTION_ACTION",
|
|
29
|
+
"retention.archiveFolder": "CLOVING_RETENTION_ARCHIVE_FOLDER",
|
|
19
30
|
};
|
|
20
31
|
const environmentOnly = [
|
|
21
32
|
"CLOVING_RUNTIME_DIR",
|
|
@@ -63,6 +74,7 @@ export function configurationValues(values) {
|
|
|
63
74
|
selfUpdate: values.selfUpdate,
|
|
64
75
|
github: values.github,
|
|
65
76
|
workflows: values.workflows,
|
|
77
|
+
retention: values.retention,
|
|
66
78
|
};
|
|
67
79
|
for (const [name, group] of Object.entries(groups)) {
|
|
68
80
|
if (group === undefined)
|
|
@@ -124,8 +136,30 @@ export function resolveSettings(environment, files) {
|
|
|
124
136
|
environment: resolved,
|
|
125
137
|
profiles,
|
|
126
138
|
sources,
|
|
139
|
+
values,
|
|
127
140
|
...(privateConfiguration.harness === undefined
|
|
128
141
|
? {}
|
|
129
142
|
: { harness: privateConfiguration.harness }),
|
|
130
143
|
};
|
|
131
144
|
}
|
|
145
|
+
function resolvedValue(resolved, field) {
|
|
146
|
+
if (field === "profiles")
|
|
147
|
+
return resolved.profiles;
|
|
148
|
+
const variable = resolved.variables[field];
|
|
149
|
+
return variable === undefined
|
|
150
|
+
? resolved.values[field]
|
|
151
|
+
: resolved.environment[variable];
|
|
152
|
+
}
|
|
153
|
+
export function settingDigests(resolved, digest) {
|
|
154
|
+
const fields = {
|
|
155
|
+
...resolved,
|
|
156
|
+
variables: {
|
|
157
|
+
...settingVariables,
|
|
158
|
+
...harnessCommandMapping(resolved.values["harness.name"]),
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
return Object.fromEntries(settingFields().map((field) => [
|
|
162
|
+
field,
|
|
163
|
+
digest(JSON.stringify(resolvedValue(fields, field) ?? null)),
|
|
164
|
+
]));
|
|
165
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
function decimal(value) {
|
|
2
|
+
const [mantissa = "0", exponent = "0"] = String(value).split("e");
|
|
3
|
+
const fraction = mantissa.split(".")[1]?.length ?? 0;
|
|
4
|
+
return {
|
|
5
|
+
units: BigInt(mantissa.replace(".", "")),
|
|
6
|
+
exponent: Number(exponent) - fraction,
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function scaled(value, exponent) {
|
|
10
|
+
return value.units * 10n ** BigInt(value.exponent - exponent);
|
|
11
|
+
}
|
|
12
|
+
export function queueSpending(costs, limitUsd) {
|
|
13
|
+
const prices = costs.map(decimal);
|
|
14
|
+
const limit = decimal(limitUsd);
|
|
15
|
+
const exponent = prices.reduce((smallest, price) => Math.min(smallest, price.exponent), limit.exponent);
|
|
16
|
+
const total = prices.reduce((sum, price) => sum + scaled(price, exponent), 0n);
|
|
17
|
+
return {
|
|
18
|
+
spentUsd: Number(`${String(total)}e${String(exponent)}`),
|
|
19
|
+
holding: total * 100n >= scaled(limit, exponent) * 85n,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Fields } from "./protocol.ts";
|
|
2
|
+
export declare const queueFailureLimit = 3;
|
|
3
|
+
export interface QueueDrain {
|
|
4
|
+
readonly startedAt: number;
|
|
5
|
+
readonly drainedAt: number | null;
|
|
6
|
+
}
|
|
7
|
+
export interface QueueControl {
|
|
8
|
+
readonly failedRunIds: readonly string[];
|
|
9
|
+
readonly drain: QueueDrain | undefined;
|
|
10
|
+
readonly error: string | undefined;
|
|
11
|
+
}
|
|
12
|
+
export type QueueCommand = "resume" | "drain";
|
|
13
|
+
export type QueueChange = {
|
|
14
|
+
readonly kind: "changed" | "replayed" | "conflicting-command";
|
|
15
|
+
} | {
|
|
16
|
+
readonly kind: "unavailable";
|
|
17
|
+
readonly detail: string;
|
|
18
|
+
};
|
|
19
|
+
export interface QueuePort {
|
|
20
|
+
readonly control: () => QueueControl | undefined;
|
|
21
|
+
readonly change: (request: {
|
|
22
|
+
readonly command: QueueCommand;
|
|
23
|
+
readonly commandId: string;
|
|
24
|
+
}) => Promise<QueueChange>;
|
|
25
|
+
}
|
|
26
|
+
export declare function queueStateFields(control: QueueControl, busy: number): Fields;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export const queueFailureLimit = 3;
|
|
2
|
+
function stopReason(control) {
|
|
3
|
+
if (control.error !== undefined)
|
|
4
|
+
return control.error;
|
|
5
|
+
if (control.failedRunIds.length >= queueFailureLimit)
|
|
6
|
+
return "failure-limit";
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
function drainState(drain, busy) {
|
|
10
|
+
return drain.drainedAt === null || busy > 0 ? "draining" : "drained";
|
|
11
|
+
}
|
|
12
|
+
function stateName(control, busy) {
|
|
13
|
+
if (control.error !== undefined)
|
|
14
|
+
return "stopped";
|
|
15
|
+
if (control.drain !== undefined)
|
|
16
|
+
return drainState(control.drain, busy);
|
|
17
|
+
if (stopReason(control) !== undefined)
|
|
18
|
+
return "stopped";
|
|
19
|
+
return "running";
|
|
20
|
+
}
|
|
21
|
+
export function queueStateFields(control, busy) {
|
|
22
|
+
const reason = stopReason(control);
|
|
23
|
+
return {
|
|
24
|
+
state: stateName(control, busy),
|
|
25
|
+
stop: reason === undefined ? null : { reason },
|
|
26
|
+
failedRunIds: [...control.failedRunIds],
|
|
27
|
+
drain: control.drain === undefined
|
|
28
|
+
? null
|
|
29
|
+
: {
|
|
30
|
+
startedAt: control.drain.startedAt,
|
|
31
|
+
drainedAt: control.drain.drainedAt,
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export interface StoredRun {
|
|
2
|
+
readonly status: string;
|
|
3
|
+
readonly endedAt: number | null;
|
|
4
|
+
}
|
|
5
|
+
export interface RecordFolder {
|
|
6
|
+
readonly started: unknown;
|
|
7
|
+
readonly changedAt: number;
|
|
8
|
+
}
|
|
9
|
+
export interface RetentionContext {
|
|
10
|
+
readonly runs: Readonly<Record<string, StoredRun>>;
|
|
11
|
+
readonly now: number;
|
|
12
|
+
readonly days: number;
|
|
13
|
+
}
|
|
14
|
+
export type RetentionVerdict = "due" | "kept" | "skipped" | "unreadable";
|
|
15
|
+
export interface RetentionSettings {
|
|
16
|
+
readonly days: number | null;
|
|
17
|
+
readonly action: "archive" | "delete";
|
|
18
|
+
readonly archiveFolder: string | null;
|
|
19
|
+
}
|
|
20
|
+
export interface RunTurns {
|
|
21
|
+
readonly runId: string;
|
|
22
|
+
readonly operationIds: readonly string[];
|
|
23
|
+
}
|
|
24
|
+
export type TurnDetails = {
|
|
25
|
+
readonly state: "archived";
|
|
26
|
+
readonly folder: string;
|
|
27
|
+
} | {
|
|
28
|
+
readonly state: "deleted";
|
|
29
|
+
};
|
|
30
|
+
export interface TurnFolders {
|
|
31
|
+
readonly turns: number;
|
|
32
|
+
readonly kept: number;
|
|
33
|
+
readonly archived: string | undefined;
|
|
34
|
+
}
|
|
35
|
+
export declare const sharedRecordFolders: readonly string[];
|
|
36
|
+
export declare const defaultRetention: RetentionSettings;
|
|
37
|
+
type Variables = Readonly<Record<string, string | undefined>>;
|
|
38
|
+
export declare function folderRunId(started: unknown): string | undefined;
|
|
39
|
+
export declare function retentionVerdict(folder: RecordFolder, context: RetentionContext): RetentionVerdict;
|
|
40
|
+
export declare function turnDetails(found: TurnFolders, context: {
|
|
41
|
+
readonly run: StoredRun | undefined;
|
|
42
|
+
readonly retention: RetentionSettings;
|
|
43
|
+
readonly now: number;
|
|
44
|
+
}): TurnDetails | undefined;
|
|
45
|
+
export declare function retentionSettings(variables: Variables): RetentionSettings;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { operationScope } from "./operation-identity.js";
|
|
2
|
+
export const sharedRecordFolders = [
|
|
3
|
+
"journal/runs",
|
|
4
|
+
"journal/targets",
|
|
5
|
+
];
|
|
6
|
+
export const defaultRetention = {
|
|
7
|
+
days: 30,
|
|
8
|
+
action: "archive",
|
|
9
|
+
archiveFolder: null,
|
|
10
|
+
};
|
|
11
|
+
const dayMilliseconds = 86_400_000;
|
|
12
|
+
const finished = ["completed", "failed", "cancelled"];
|
|
13
|
+
export function folderRunId(started) {
|
|
14
|
+
if (typeof started !== "object" || started === null)
|
|
15
|
+
return undefined;
|
|
16
|
+
if ("runId" in started && typeof started.runId === "string")
|
|
17
|
+
return started.runId;
|
|
18
|
+
if (!("operationId" in started) || typeof started.operationId !== "string")
|
|
19
|
+
return undefined;
|
|
20
|
+
return operationScope(started.operationId)?.run;
|
|
21
|
+
}
|
|
22
|
+
export function retentionVerdict(folder, context) {
|
|
23
|
+
const runId = folderRunId(folder.started);
|
|
24
|
+
const run = runId !== undefined && Object.hasOwn(context.runs, runId)
|
|
25
|
+
? context.runs[runId]
|
|
26
|
+
: undefined;
|
|
27
|
+
if (run === undefined)
|
|
28
|
+
return "unreadable";
|
|
29
|
+
if (!finished.includes(run.status))
|
|
30
|
+
return "skipped";
|
|
31
|
+
const limit = context.now - context.days * dayMilliseconds;
|
|
32
|
+
return endedBefore(run, limit) && folder.changedAt < limit ? "due" : "kept";
|
|
33
|
+
}
|
|
34
|
+
function endedBefore(run, limit) {
|
|
35
|
+
return finished.includes(run.status) && (run.endedAt ?? Number.NaN) < limit;
|
|
36
|
+
}
|
|
37
|
+
export function turnDetails(found, context) {
|
|
38
|
+
if (found.archived !== undefined)
|
|
39
|
+
return { state: "archived", folder: found.archived };
|
|
40
|
+
const { run, retention } = context;
|
|
41
|
+
if (found.turns === 0 || found.kept > 0 || run === undefined)
|
|
42
|
+
return undefined;
|
|
43
|
+
if (retention.action !== "delete" || retention.days === null)
|
|
44
|
+
return undefined;
|
|
45
|
+
const limit = context.now - retention.days * dayMilliseconds;
|
|
46
|
+
return endedBefore(run, limit) ? { state: "deleted" } : undefined;
|
|
47
|
+
}
|
|
48
|
+
function refused(variable, expected) {
|
|
49
|
+
throw new Error(`invalid-setting: ${variable} must be ${expected}`);
|
|
50
|
+
}
|
|
51
|
+
function retentionDays(value) {
|
|
52
|
+
if (value === undefined)
|
|
53
|
+
return defaultRetention.days;
|
|
54
|
+
if (value === "null")
|
|
55
|
+
return null;
|
|
56
|
+
const days = Number(value);
|
|
57
|
+
if (/^[1-9][0-9]*$/.test(value) && Number.isSafeInteger(days))
|
|
58
|
+
return days;
|
|
59
|
+
return refused("CLOVING_RETENTION_DAYS", "a whole number of at least 1 or null");
|
|
60
|
+
}
|
|
61
|
+
function retentionAction(value) {
|
|
62
|
+
if (value === undefined)
|
|
63
|
+
return defaultRetention.action;
|
|
64
|
+
if (value === "archive" || value === "delete")
|
|
65
|
+
return value;
|
|
66
|
+
return refused("CLOVING_RETENTION_ACTION", "archive or delete");
|
|
67
|
+
}
|
|
68
|
+
function archiveFolder(value) {
|
|
69
|
+
if (value === undefined || value === "null")
|
|
70
|
+
return null;
|
|
71
|
+
if (value.startsWith("/"))
|
|
72
|
+
return value;
|
|
73
|
+
return refused("CLOVING_RETENTION_ARCHIVE_FOLDER", "an absolute path or null");
|
|
74
|
+
}
|
|
75
|
+
export function retentionSettings(variables) {
|
|
76
|
+
return {
|
|
77
|
+
days: retentionDays(variables["CLOVING_RETENTION_DAYS"]),
|
|
78
|
+
action: retentionAction(variables["CLOVING_RETENTION_ACTION"]),
|
|
79
|
+
archiveFolder: archiveFolder(variables["CLOVING_RETENTION_ARCHIVE_FOLDER"]),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import type { Reply } from "../protocol.ts";
|
|
1
2
|
import { type InboxTiming } from "./answer-inbox.ts";
|
|
2
3
|
import { type WatchTiming } from "./decision-watch.ts";
|
|
4
|
+
import { type OperationState } from "./phone-operations.ts";
|
|
3
5
|
import { type HeartbeatTiming } from "./relay-heartbeat.ts";
|
|
4
6
|
export interface RelayPaths {
|
|
5
7
|
readonly runtimeDirectory: string;
|
|
@@ -16,6 +18,7 @@ export interface RelayOptions extends RelayPaths {
|
|
|
16
18
|
export interface Relay {
|
|
17
19
|
readonly close: () => Promise<void>;
|
|
18
20
|
}
|
|
21
|
+
export declare function phoneState(relay: OperationState): Promise<Reply>;
|
|
19
22
|
export declare function computerName(name: string): string;
|
|
20
23
|
export declare function startRelay(options: RelayOptions): Promise<Relay>;
|
|
21
24
|
export interface RelayProgram {
|
|
@@ -41,15 +41,17 @@ function pairingView(open) {
|
|
|
41
41
|
},
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
-
async function phoneState(relay) {
|
|
45
|
-
const
|
|
44
|
+
export async function phoneState(relay) {
|
|
45
|
+
const stored = await readLink(relay.context.phoneDirectory);
|
|
46
|
+
const lost = relay.registration.lost;
|
|
47
|
+
const link = lost ? undefined : stored;
|
|
46
48
|
return result({
|
|
47
49
|
registered: link !== undefined,
|
|
48
50
|
daemonId: link?.daemonId ?? null,
|
|
49
51
|
origin: link?.origin ?? null,
|
|
50
52
|
pairing: pairingView(relay.sessions.current()),
|
|
51
53
|
refusal: relay.sessions.refusal(),
|
|
52
|
-
reason:
|
|
54
|
+
reason: lost ? "registration-lost" : null,
|
|
53
55
|
devices: (await relay.store.devices()).map((device) => ({
|
|
54
56
|
deviceId: device.deviceId,
|
|
55
57
|
name: device.name,
|