@elie-laloum/outpost 1.1.4 → 3.0.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/CHANGELOG.md +35 -0
- package/README.md +12 -6
- package/dist/adapters/agents/claude-diagnostics.d.ts +1 -0
- package/dist/adapters/agents/claude-diagnostics.js +7 -0
- package/dist/adapters/agents/claude-diagnostics.js.map +1 -0
- package/dist/adapters/agents/cli-diagnostics.constants.d.ts +12 -0
- package/dist/adapters/agents/cli-diagnostics.constants.js +24 -0
- package/dist/adapters/agents/cli-diagnostics.constants.js.map +1 -0
- package/dist/adapters/agents/cli-diagnostics.d.ts +4 -0
- package/dist/adapters/agents/cli-diagnostics.js +14 -0
- package/dist/adapters/agents/cli-diagnostics.js.map +1 -0
- package/dist/adapters/agents/cli-diagnostics.types.d.ts +13 -0
- package/dist/adapters/agents/cli-diagnostics.types.js +2 -0
- package/dist/adapters/agents/cli-diagnostics.types.js.map +1 -0
- package/dist/adapters/agents/codex-diagnostics.d.ts +1 -0
- package/dist/adapters/agents/codex-diagnostics.js +7 -0
- package/dist/adapters/agents/codex-diagnostics.js.map +1 -0
- package/dist/adapters/agents/protocol-fixtures.constants.d.ts +2 -0
- package/dist/adapters/agents/protocol-fixtures.constants.js +68 -0
- package/dist/adapters/agents/protocol-fixtures.constants.js.map +1 -0
- package/dist/adapters/agents/protocol-fixtures.types.d.ts +6 -0
- package/dist/adapters/agents/protocol-fixtures.types.js +2 -0
- package/dist/adapters/agents/protocol-fixtures.types.js.map +1 -0
- package/dist/application/diagnostic-probe.d.ts +3 -0
- package/dist/application/diagnostic-probe.js +55 -0
- package/dist/application/diagnostic-probe.js.map +1 -0
- package/dist/application/doctor-agent.constants.d.ts +9 -0
- package/dist/application/doctor-agent.constants.js +8 -0
- package/dist/application/doctor-agent.constants.js.map +1 -0
- package/dist/application/doctor-agent.d.ts +3 -0
- package/dist/application/doctor-agent.js +53 -0
- package/dist/application/doctor-agent.js.map +1 -0
- package/dist/application/doctor-image.d.ts +3 -0
- package/dist/application/doctor-image.js +133 -0
- package/dist/application/doctor-image.js.map +1 -0
- package/dist/application/doctor-protocol.d.ts +3 -0
- package/dist/application/doctor-protocol.js +29 -0
- package/dist/application/doctor-protocol.js.map +1 -0
- package/dist/application/doctor-protocol.types.d.ts +10 -0
- package/dist/application/doctor-protocol.types.js +2 -0
- package/dist/application/doctor-protocol.types.js.map +1 -0
- package/dist/application/doctor-sandbox.constants.d.ts +5 -0
- package/dist/application/doctor-sandbox.constants.js +6 -0
- package/dist/application/doctor-sandbox.constants.js.map +1 -0
- package/dist/application/doctor-sandbox.d.ts +4 -0
- package/dist/application/doctor-sandbox.js +133 -0
- package/dist/application/doctor-sandbox.js.map +1 -0
- package/dist/application/doctor-sandbox.types.d.ts +23 -0
- package/dist/application/doctor-sandbox.types.js +2 -0
- package/dist/application/doctor-sandbox.types.js.map +1 -0
- package/dist/application/doctor-transfers.constants.d.ts +6 -0
- package/dist/application/doctor-transfers.constants.js +7 -0
- package/dist/application/doctor-transfers.constants.js.map +1 -0
- package/dist/application/doctor-transfers.d.ts +4 -0
- package/dist/application/doctor-transfers.js +88 -0
- package/dist/application/doctor-transfers.js.map +1 -0
- package/dist/application/doctor.constants.d.ts +9 -0
- package/dist/application/doctor.constants.js +15 -0
- package/dist/application/doctor.constants.js.map +1 -0
- package/dist/application/doctor.d.ts +3 -0
- package/dist/application/doctor.js +106 -0
- package/dist/application/doctor.js.map +1 -0
- package/dist/application/doctor.types.d.ts +39 -0
- package/dist/application/doctor.types.js +2 -0
- package/dist/application/doctor.types.js.map +1 -0
- package/dist/application/execution.js +1 -0
- package/dist/application/execution.js.map +1 -1
- package/dist/application/outpost.types.d.ts +2 -0
- package/dist/application/outpost.types.js.map +1 -1
- package/dist/application/recovery-checksum-capture.d.ts +2 -0
- package/dist/application/recovery-checksum-capture.js +32 -0
- package/dist/application/recovery-checksum-capture.js.map +1 -0
- package/dist/application/recovery-checksum-paths.d.ts +2 -0
- package/dist/application/recovery-checksum-paths.js +11 -0
- package/dist/application/recovery-checksum-paths.js.map +1 -0
- package/dist/application/recovery-checksums.constants.d.ts +5 -0
- package/dist/application/recovery-checksums.constants.js +6 -0
- package/dist/application/recovery-checksums.constants.js.map +1 -0
- package/dist/application/recovery-checksums.d.ts +3 -0
- package/dist/application/recovery-checksums.js +94 -0
- package/dist/application/recovery-checksums.js.map +1 -0
- package/dist/application/recovery-checksums.types.d.ts +17 -0
- package/dist/application/recovery-checksums.types.js +2 -0
- package/dist/application/recovery-checksums.types.js.map +1 -0
- package/dist/application/recovery-inspection.d.ts +2 -0
- package/dist/application/recovery-inspection.js +27 -0
- package/dist/application/recovery-inspection.js.map +1 -0
- package/dist/application/recovery-inspection.types.d.ts +15 -0
- package/dist/application/recovery-inspection.types.js +2 -0
- package/dist/application/recovery-inspection.types.js.map +1 -0
- package/dist/application/recovery-restorability.d.ts +2 -0
- package/dist/application/recovery-restorability.js +137 -0
- package/dist/application/recovery-restorability.js.map +1 -0
- package/dist/application/recovery-retention-policy.d.ts +2 -0
- package/dist/application/recovery-retention-policy.js +21 -0
- package/dist/application/recovery-retention-policy.js.map +1 -0
- package/dist/application/recovery-retention.constants.d.ts +3 -0
- package/dist/application/recovery-retention.constants.js +2 -0
- package/dist/application/recovery-retention.constants.js.map +1 -0
- package/dist/application/recovery-retention.d.ts +4 -0
- package/dist/application/recovery-retention.js +202 -0
- package/dist/application/recovery-retention.js.map +1 -0
- package/dist/application/recovery-retention.types.d.ts +52 -0
- package/dist/application/recovery-retention.types.js +2 -0
- package/dist/application/recovery-retention.types.js.map +1 -0
- package/dist/application/recovery-verification.constants.d.ts +5 -0
- package/dist/application/recovery-verification.constants.js +10 -0
- package/dist/application/recovery-verification.constants.js.map +1 -0
- package/dist/application/recovery-verification.d.ts +2 -0
- package/dist/application/recovery-verification.js +107 -0
- package/dist/application/recovery-verification.js.map +1 -0
- package/dist/application/recovery-verification.types.d.ts +26 -0
- package/dist/application/recovery-verification.types.js +2 -0
- package/dist/application/recovery-verification.types.js.map +1 -0
- package/dist/application/remote-apply.js +24 -6
- package/dist/application/remote-apply.js.map +1 -1
- package/dist/application/remote-backup.js +6 -2
- package/dist/application/remote-backup.js.map +1 -1
- package/dist/application/remote-download.js +36 -4
- package/dist/application/remote-download.js.map +1 -1
- package/dist/application/remote-validation.js +19 -0
- package/dist/application/remote-validation.js.map +1 -1
- package/dist/application/remote-workspace.constants.d.ts +3 -0
- package/dist/application/remote-workspace.constants.js +2 -0
- package/dist/application/remote-workspace.constants.js.map +1 -0
- package/dist/application/remote-workspace.js +6 -0
- package/dist/application/remote-workspace.js.map +1 -1
- package/dist/application/remote-workspace.types.d.ts +3 -1
- package/dist/application/remote-workspace.types.js.map +1 -1
- package/dist/application/sandbox.js +11 -0
- package/dist/application/sandbox.js.map +1 -1
- package/dist/application/task-usage.d.ts +4 -0
- package/dist/application/task-usage.js +41 -0
- package/dist/application/task-usage.js.map +1 -0
- package/dist/application/task-usage.types.d.ts +5 -0
- package/dist/application/task-usage.types.js +2 -0
- package/dist/application/task-usage.types.js.map +1 -0
- package/dist/application/tasks.js +23 -2
- package/dist/application/tasks.js.map +1 -1
- package/dist/cli/commands.js +4 -0
- package/dist/cli/commands.js.map +1 -1
- package/dist/cli/doctor-command.d.ts +3 -0
- package/dist/cli/doctor-command.js +38 -0
- package/dist/cli/doctor-command.js.map +1 -0
- package/dist/cli/image.js +1 -1
- package/dist/cli/image.js.map +1 -1
- package/dist/cli/init-command.js +4 -3
- package/dist/cli/init-command.js.map +1 -1
- package/dist/cli/main.constants.d.ts +29 -8
- package/dist/cli/main.constants.js +19 -7
- package/dist/cli/main.constants.js.map +1 -1
- package/dist/cli/project-settings.js +8 -2
- package/dist/cli/project-settings.js.map +1 -1
- package/dist/cli/recovery-command.d.ts +2 -0
- package/dist/cli/recovery-command.js +69 -0
- package/dist/cli/recovery-command.js.map +1 -0
- package/dist/cli/recovery-prune-command.d.ts +2 -0
- package/dist/cli/recovery-prune-command.js +34 -0
- package/dist/cli/recovery-prune-command.js.map +1 -0
- package/dist/cli/recovery-verify-command.d.ts +2 -0
- package/dist/cli/recovery-verify-command.js +43 -0
- package/dist/cli/recovery-verify-command.js.map +1 -0
- package/dist/cli/scaffold-files.d.ts +1 -1
- package/dist/cli/scaffold-files.js +26 -20
- package/dist/cli/scaffold-files.js.map +1 -1
- package/dist/cli/scaffold-validation.js +2 -5
- package/dist/cli/scaffold-validation.js.map +1 -1
- package/dist/cli/scaffold.constants.d.ts +0 -2
- package/dist/cli/scaffold.constants.js +1 -13
- package/dist/cli/scaffold.constants.js.map +1 -1
- package/dist/cli/scaffold.d.ts +1 -1
- package/dist/cli/scaffold.js +37 -29
- package/dist/cli/scaffold.js.map +1 -1
- package/dist/cli/scaffold.types.d.ts +3 -5
- package/dist/cli/scaffold.types.js.map +1 -1
- package/dist/cli/starters.d.ts +1 -2
- package/dist/cli/starters.js +42 -30
- package/dist/cli/starters.js.map +1 -1
- package/dist/domain/ports.d.ts +1 -1
- package/dist/domain/ports.js.map +1 -1
- package/dist/domain/sandbox.types.d.ts +12 -0
- package/dist/domain/sandbox.types.js.map +1 -1
- package/dist/domain/workflow/budget.constants.d.ts +1 -0
- package/dist/domain/workflow/budget.constants.js +7 -0
- package/dist/domain/workflow/budget.constants.js.map +1 -0
- package/dist/domain/workflow/budget.d.ts +9 -0
- package/dist/domain/workflow/budget.js +67 -0
- package/dist/domain/workflow/budget.js.map +1 -0
- package/dist/domain/workflow/budget.types.d.ts +15 -0
- package/dist/domain/workflow/budget.types.js +2 -0
- package/dist/domain/workflow/budget.types.js.map +1 -0
- package/dist/domain/workflow/task-runner.js +8 -1
- package/dist/domain/workflow/task-runner.js.map +1 -1
- package/dist/domain/workflow/workflow-scheduler.js +4 -2
- package/dist/domain/workflow/workflow-scheduler.js.map +1 -1
- package/dist/domain/workflow/workflow-state.js +29 -0
- package/dist/domain/workflow/workflow-state.js.map +1 -1
- package/dist/domain/workflow.d.ts +2 -0
- package/dist/domain/workflow.js +1 -0
- package/dist/domain/workflow.js.map +1 -1
- package/dist/domain/workflow.types.d.ts +10 -1
- package/dist/domain/workflow.types.js.map +1 -1
- package/dist/index.d.ts +12 -8
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/file-manifest.d.ts +6 -0
- package/dist/infrastructure/file-manifest.js +91 -0
- package/dist/infrastructure/file-manifest.js.map +1 -0
- package/dist/infrastructure/git/lock-inspection.constants.d.ts +4 -0
- package/dist/infrastructure/git/lock-inspection.constants.js +5 -0
- package/dist/infrastructure/git/lock-inspection.constants.js.map +1 -0
- package/dist/infrastructure/git/lock-inspection.d.ts +3 -0
- package/dist/infrastructure/git/lock-inspection.js +64 -0
- package/dist/infrastructure/git/lock-inspection.js.map +1 -0
- package/dist/infrastructure/git/lock-inspection.types.d.ts +27 -0
- package/dist/infrastructure/git/lock-inspection.types.js +2 -0
- package/dist/infrastructure/git/lock-inspection.types.js.map +1 -0
- package/dist/infrastructure/git/lock.d.ts +1 -0
- package/dist/infrastructure/git/lock.js +70 -29
- package/dist/infrastructure/git/lock.js.map +1 -1
- package/dist/infrastructure/git/process-identity.d.ts +3 -0
- package/dist/infrastructure/git/process-identity.js +73 -0
- package/dist/infrastructure/git/process-identity.js.map +1 -0
- package/dist/infrastructure/git/process-identity.types.d.ts +10 -0
- package/dist/infrastructure/git/process-identity.types.js +2 -0
- package/dist/infrastructure/git/process-identity.types.js.map +1 -0
- package/dist/infrastructure/git/verification-command.d.ts +1 -0
- package/dist/infrastructure/git/verification-command.js +36 -0
- package/dist/infrastructure/git/verification-command.js.map +1 -0
- package/dist/infrastructure/git/workspace-lease.js +1 -0
- package/dist/infrastructure/git/workspace-lease.js.map +1 -1
- package/dist/infrastructure/git/workspace.js +5 -1
- package/dist/infrastructure/git/workspace.js.map +1 -1
- package/dist/infrastructure/git/worktree-inspection.constants.d.ts +5 -0
- package/dist/infrastructure/git/worktree-inspection.constants.js +16 -0
- package/dist/infrastructure/git/worktree-inspection.constants.js.map +1 -0
- package/dist/infrastructure/git/worktree-inspection.d.ts +3 -0
- package/dist/infrastructure/git/worktree-inspection.js +120 -0
- package/dist/infrastructure/git/worktree-inspection.js.map +1 -0
- package/dist/infrastructure/git/worktree-inspection.types.d.ts +19 -0
- package/dist/infrastructure/git/worktree-inspection.types.js +2 -0
- package/dist/infrastructure/git/worktree-inspection.types.js.map +1 -0
- package/dist/infrastructure/inspection-file.constants.d.ts +1 -0
- package/dist/infrastructure/inspection-file.constants.js +5 -0
- package/dist/infrastructure/inspection-file.constants.js.map +1 -0
- package/dist/infrastructure/inspection-file.d.ts +1 -0
- package/dist/infrastructure/inspection-file.js +43 -0
- package/dist/infrastructure/inspection-file.js.map +1 -0
- package/dist/infrastructure/inspection-hash.constants.d.ts +1 -0
- package/dist/infrastructure/inspection-hash.constants.js +2 -0
- package/dist/infrastructure/inspection-hash.constants.js.map +1 -0
- package/dist/infrastructure/inspection-hash.d.ts +2 -0
- package/dist/infrastructure/inspection-hash.js +62 -0
- package/dist/infrastructure/inspection-hash.js.map +1 -0
- package/dist/infrastructure/inspection-hash.types.d.ts +5 -0
- package/dist/infrastructure/inspection-hash.types.js +2 -0
- package/dist/infrastructure/inspection-hash.types.js.map +1 -0
- package/dist/infrastructure/journal-retention.constants.d.ts +4 -0
- package/dist/infrastructure/journal-retention.constants.js +5 -0
- package/dist/infrastructure/journal-retention.constants.js.map +1 -0
- package/dist/infrastructure/journal-retention.d.ts +2 -0
- package/dist/infrastructure/journal-retention.js +51 -0
- package/dist/infrastructure/journal-retention.js.map +1 -0
- package/dist/infrastructure/journal.js +37 -13
- package/dist/infrastructure/journal.js.map +1 -1
- package/dist/infrastructure/opentelemetry.constants.d.ts +10 -0
- package/dist/infrastructure/opentelemetry.constants.js +11 -0
- package/dist/infrastructure/opentelemetry.constants.js.map +1 -0
- package/dist/infrastructure/opentelemetry.d.ts +3 -0
- package/dist/infrastructure/opentelemetry.js +131 -0
- package/dist/infrastructure/opentelemetry.js.map +1 -0
- package/dist/infrastructure/opentelemetry.types.d.ts +21 -0
- package/dist/infrastructure/opentelemetry.types.js +2 -0
- package/dist/infrastructure/opentelemetry.types.js.map +1 -0
- package/dist/infrastructure/storage-inventory.constants.d.ts +6 -0
- package/dist/infrastructure/storage-inventory.constants.js +11 -0
- package/dist/infrastructure/storage-inventory.constants.js.map +1 -0
- package/dist/infrastructure/storage-inventory.d.ts +2 -0
- package/dist/infrastructure/storage-inventory.js +123 -0
- package/dist/infrastructure/storage-inventory.js.map +1 -0
- package/dist/infrastructure/storage-inventory.types.d.ts +38 -0
- package/dist/infrastructure/storage-inventory.types.js +2 -0
- package/dist/infrastructure/storage-inventory.types.js.map +1 -0
- package/dist/infrastructure/transfer.js +12 -0
- package/dist/infrastructure/transfer.js.map +1 -1
- package/dist/providers/cloud.constants.d.ts +1 -0
- package/dist/providers/cloud.constants.js +1 -0
- package/dist/providers/cloud.constants.js.map +1 -1
- package/dist/providers/container-cache.constants.d.ts +11 -0
- package/dist/providers/container-cache.constants.js +9 -0
- package/dist/providers/container-cache.constants.js.map +1 -0
- package/dist/providers/container-cache.d.ts +4 -0
- package/dist/providers/container-cache.js +48 -0
- package/dist/providers/container-cache.js.map +1 -0
- package/dist/providers/container-cache.types.d.ts +8 -0
- package/dist/providers/container-cache.types.js +2 -0
- package/dist/providers/container-cache.types.js.map +1 -0
- package/dist/providers/container-plan.js +3 -1
- package/dist/providers/container-plan.js.map +1 -1
- package/dist/providers/container.js +31 -1
- package/dist/providers/container.js.map +1 -1
- package/dist/providers/container.types.d.ts +2 -0
- package/dist/providers/container.types.js.map +1 -1
- package/dist/providers/daytona-command.js +7 -4
- package/dist/providers/daytona-command.js.map +1 -1
- package/dist/providers/daytona.js +13 -4
- package/dist/providers/daytona.js.map +1 -1
- package/dist/providers/diagnostic-container.d.ts +4 -0
- package/dist/providers/diagnostic-container.js +15 -0
- package/dist/providers/diagnostic-container.js.map +1 -0
- package/dist/providers/docker.d.ts +1 -0
- package/dist/providers/docker.js.map +1 -1
- package/dist/providers/file-batches.constants.d.ts +10 -0
- package/dist/providers/file-batches.constants.js +57 -0
- package/dist/providers/file-batches.constants.js.map +1 -0
- package/dist/providers/file-batches.d.ts +2 -0
- package/dist/providers/file-batches.js +151 -0
- package/dist/providers/file-batches.js.map +1 -0
- package/dist/providers/podman.d.ts +1 -0
- package/dist/providers/podman.js.map +1 -1
- package/dist/providers/vercel.js +3 -1
- package/dist/providers/vercel.js.map +1 -1
- package/package.json +12 -1
- package/dist/adapters/backlogs/backlog.constants.d.ts +0 -4
- package/dist/adapters/backlogs/backlog.constants.js +0 -5
- package/dist/adapters/backlogs/backlog.constants.js.map +0 -1
- package/dist/adapters/backlogs/beads-adapter.d.ts +0 -4
- package/dist/adapters/backlogs/beads-adapter.js +0 -31
- package/dist/adapters/backlogs/beads-adapter.js.map +0 -1
- package/dist/adapters/backlogs/cli.d.ts +0 -3
- package/dist/adapters/backlogs/cli.js +0 -20
- package/dist/adapters/backlogs/cli.js.map +0 -1
- package/dist/adapters/backlogs/github-adapter.d.ts +0 -4
- package/dist/adapters/backlogs/github-adapter.js +0 -28
- package/dist/adapters/backlogs/github-adapter.js.map +0 -1
- package/dist/adapters/backlogs/issue.d.ts +0 -2
- package/dist/adapters/backlogs/issue.js +0 -13
- package/dist/adapters/backlogs/issue.js.map +0 -1
- package/dist/adapters/backlogs/settings.types.d.ts +0 -5
- package/dist/adapters/backlogs/settings.types.js +0 -2
- package/dist/adapters/backlogs/settings.types.js.map +0 -1
- package/dist/application/campaign-integration.d.ts +0 -2
- package/dist/application/campaign-integration.js +0 -44
- package/dist/application/campaign-integration.js.map +0 -1
- package/dist/application/campaign-planner.d.ts +0 -3
- package/dist/application/campaign-planner.js +0 -35
- package/dist/application/campaign-planner.js.map +0 -1
- package/dist/application/campaign-worker.d.ts +0 -3
- package/dist/application/campaign-worker.js +0 -54
- package/dist/application/campaign-worker.js.map +0 -1
- package/dist/application/campaign.constants.d.ts +0 -7
- package/dist/application/campaign.constants.js +0 -8
- package/dist/application/campaign.constants.js.map +0 -1
- package/dist/application/campaign.d.ts +0 -3
- package/dist/application/campaign.js +0 -96
- package/dist/application/campaign.js.map +0 -1
- package/dist/application/campaign.types.d.ts +0 -43
- package/dist/application/campaign.types.js +0 -2
- package/dist/application/campaign.types.js.map +0 -1
- package/dist/domain/backlog.d.ts +0 -3
- package/dist/domain/backlog.js +0 -23
- package/dist/domain/backlog.js.map +0 -1
- package/dist/domain/backlog.types.d.ts +0 -15
- package/dist/domain/backlog.types.js +0 -2
- package/dist/domain/backlog.types.js.map +0 -1
- package/dist/providers/backlogs.d.ts +0 -3
- package/dist/providers/backlogs.js +0 -3
- package/dist/providers/backlogs.js.map +0 -1
package/dist/cli/starters.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"starters.js","sourceRoot":"","sources":["../../src/cli/starters.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,OAAO,CAAC,OAAoB
|
|
1
|
+
{"version":3,"file":"starters.js","sourceRoot":"","sources":["../../src/cli/starters.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,OAAO,CAAC,OAAoB;IAC1C,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,OAAO,EACpC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,QAAQ,CAAC;IAC1C,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC7E,MAAM,KAAK,GACT,OAAO,CAAC,KAAK,IAAI,CAAC,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,QAAQ,CAAC;QAC/D,CAAC,CAAC,UAAU,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI;QAC7C,CAAC,CAAC,EAAE,CAAC;IACT,OAAO;;;qBAGY,KAAK;WACf,QAAQ,2CAA2C,QAAQ;;;kDAGpB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,UAAU,IAAI,GAAG,CAAC;;;;;;;;;WAShF,KAAK,MAAM,KAAK;cACb,QAAQ,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;CAoBhC,CAAC;AACF,CAAC","sourcesContent":["import type { InitOptions } from \"./scaffold.types.ts\";\n\nexport function starter(options: InitOptions): string {\n const agent = options.agent ?? \"codex\",\n provider = options.provider ?? \"docker\";\n const model = options.model ? `model: ${JSON.stringify(options.model)}` : \"\";\n const image =\n options.image && (provider === \"docker\" || provider === \"podman\")\n ? `image: ${JSON.stringify(options.image)}, `\n : \"\";\n return `import { readFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\nimport { parseEnv } from \"node:util\";\nimport { dispatch, ${agent}, OutpostError, reporter } from \"@elie-laloum/outpost\";\nimport { ${provider} } from \"@elie-laloum/outpost/providers/${provider}\";\n\n// Paths are relative to this workflow, regardless of where Node is launched.\nconst repository = resolve(import.meta.dirname, ${JSON.stringify(options.repository ?? \".\")});\nconst environment = await readFile(new URL(\".env\", import.meta.url), \"utf8\").catch((error) => {\n if (error.code === \"ENOENT\") return \"\";\n throw error;\n});\nconst variables = Object.fromEntries(\n Object.entries(parseEnv(environment)).map(([key, value]) => [key, value || process.env[key] || \"\"]),\n);\nconst runtime = {\n agent: ${agent}({ ${model} }),\n provider: ${provider}({ ${image}variables }),\n};\nconst objective = process.argv.slice(2).join(\" \") || \"Inspect this repository and implement one useful improvement.\";\n\nconsole.error(\"[outpost] Preparing sandbox...\");\ntry {\n const result = await dispatch({\n ...runtime,\n repository,\n branch: { mode: \"integrate\" },\n brief: { file: resolve(import.meta.dirname, \"brief.md\"), values: { OBJECTIVE: objective } },\n observe: reporter(),\n warn: (message) => console.error(message),\n });\n console.log({ branch: result.branch, commits: result.commits, conversation: result.conversation });\n} catch (error) {\n if (!(error instanceof OutpostError) || error.code !== \"aborted\") throw error;\n process.exitCode ||= 130;\n console.error(\"[outpost] Cancelled. Recovery details:\", error.recovery);\n}\n`;\n}\n"]}
|
package/dist/domain/ports.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type { AgentAdapter, AgentEvent, AgentInput, AgentObservation, Usage, } from "./agent.types.ts";
|
|
2
2
|
export type { Channel, Command, CommandResult, Variables, } from "./command.types.ts";
|
|
3
3
|
export type { ConversationContext, ConversationRecord, ConversationStore, } from "./conversation.types.ts";
|
|
4
|
-
export type { SandboxContext, SandboxLease, SandboxProvider, TransferOptions, Volume, } from "./sandbox.types.ts";
|
|
4
|
+
export type { FileManifestEntry, FileTransfers, SandboxContext, SandboxLease, SandboxProvider, TransferOptions, Volume, } from "./sandbox.types.ts";
|
|
5
5
|
export type { BranchPolicy, Commit, Disposal, LifecycleHooks, StageLimits, WorkspaceRecord, } from "./workspace.types.ts";
|
package/dist/domain/ports.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ports.js","sourceRoot":"","sources":["../../src/domain/ports.ts"],"names":[],"mappings":"","sourcesContent":["export type {\n AgentAdapter,\n AgentEvent,\n AgentInput,\n AgentObservation,\n Usage,\n} from \"./agent.types.ts\";\nexport type {\n Channel,\n Command,\n CommandResult,\n Variables,\n} from \"./command.types.ts\";\nexport type {\n ConversationContext,\n ConversationRecord,\n ConversationStore,\n} from \"./conversation.types.ts\";\nexport type {\n SandboxContext,\n SandboxLease,\n SandboxProvider,\n TransferOptions,\n Volume,\n} from \"./sandbox.types.ts\";\nexport type {\n BranchPolicy,\n Commit,\n Disposal,\n LifecycleHooks,\n StageLimits,\n WorkspaceRecord,\n} from \"./workspace.types.ts\";\n"]}
|
|
1
|
+
{"version":3,"file":"ports.js","sourceRoot":"","sources":["../../src/domain/ports.ts"],"names":[],"mappings":"","sourcesContent":["export type {\n AgentAdapter,\n AgentEvent,\n AgentInput,\n AgentObservation,\n Usage,\n} from \"./agent.types.ts\";\nexport type {\n Channel,\n Command,\n CommandResult,\n Variables,\n} from \"./command.types.ts\";\nexport type {\n ConversationContext,\n ConversationRecord,\n ConversationStore,\n} from \"./conversation.types.ts\";\nexport type {\n FileManifestEntry,\n FileTransfers,\n SandboxContext,\n SandboxLease,\n SandboxProvider,\n TransferOptions,\n Volume,\n} from \"./sandbox.types.ts\";\nexport type {\n BranchPolicy,\n Commit,\n Disposal,\n LifecycleHooks,\n StageLimits,\n WorkspaceRecord,\n} from \"./workspace.types.ts\";\n"]}
|
|
@@ -15,7 +15,19 @@ export interface TransferOptions {
|
|
|
15
15
|
readonly signal?: AbortSignal;
|
|
16
16
|
readonly deadlineMs?: number;
|
|
17
17
|
}
|
|
18
|
+
export interface FileManifestEntry {
|
|
19
|
+
readonly path: string;
|
|
20
|
+
readonly kind: "file" | "link";
|
|
21
|
+
readonly mode: number;
|
|
22
|
+
readonly size: number;
|
|
23
|
+
readonly sha256: string;
|
|
24
|
+
}
|
|
25
|
+
export interface FileTransfers {
|
|
26
|
+
manifest(source: string, paths: readonly string[], options?: TransferOptions): Promise<readonly FileManifestEntry[]>;
|
|
27
|
+
downloadBatch(source: string, entries: readonly FileManifestEntry[], destination: string, options?: TransferOptions): Promise<void>;
|
|
28
|
+
}
|
|
18
29
|
export interface SandboxLease {
|
|
30
|
+
readonly fileTransfers?: FileTransfers;
|
|
19
31
|
readonly root: string;
|
|
20
32
|
readonly home: string;
|
|
21
33
|
invoke(command: Command): Promise<CommandResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox.types.js","sourceRoot":"","sources":["../../src/domain/sandbox.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Command, CommandResult, Variables } from \"./command.types.ts\";\n\nexport interface Volume {\n readonly source: string;\n readonly target: string;\n readonly readOnly?: boolean;\n}\n\nexport interface SandboxContext {\n readonly repository: string;\n readonly directory: string;\n readonly gitDirectories: readonly string[];\n readonly variables: Variables;\n readonly signal?: AbortSignal;\n}\n\nexport interface TransferOptions {\n readonly signal?: AbortSignal;\n readonly deadlineMs?: number;\n}\n\nexport interface SandboxLease {\n readonly root: string;\n readonly home: string;\n invoke(command: Command): Promise<CommandResult>;\n upload(\n source: string,\n destination: string,\n options?: TransferOptions,\n ): Promise<void>;\n download(\n source: string,\n destination: string,\n options?: TransferOptions,\n ): Promise<void>;\n release(): Promise<void>;\n}\n\nexport interface SandboxProvider {\n readonly name: string;\n readonly placement: \"mounted\" | \"remote\" | \"host\";\n readonly variables?: Variables;\n acquire(context: SandboxContext): Promise<SandboxLease>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sandbox.types.js","sourceRoot":"","sources":["../../src/domain/sandbox.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Command, CommandResult, Variables } from \"./command.types.ts\";\n\nexport interface Volume {\n readonly source: string;\n readonly target: string;\n readonly readOnly?: boolean;\n}\n\nexport interface SandboxContext {\n readonly repository: string;\n readonly directory: string;\n readonly gitDirectories: readonly string[];\n readonly variables: Variables;\n readonly signal?: AbortSignal;\n}\n\nexport interface TransferOptions {\n readonly signal?: AbortSignal;\n readonly deadlineMs?: number;\n}\n\nexport interface FileManifestEntry {\n readonly path: string;\n readonly kind: \"file\" | \"link\";\n readonly mode: number;\n readonly size: number;\n readonly sha256: string;\n}\n\nexport interface FileTransfers {\n manifest(\n source: string,\n paths: readonly string[],\n options?: TransferOptions,\n ): Promise<readonly FileManifestEntry[]>;\n downloadBatch(\n source: string,\n entries: readonly FileManifestEntry[],\n destination: string,\n options?: TransferOptions,\n ): Promise<void>;\n}\n\nexport interface SandboxLease {\n readonly fileTransfers?: FileTransfers;\n readonly root: string;\n readonly home: string;\n invoke(command: Command): Promise<CommandResult>;\n upload(\n source: string,\n destination: string,\n options?: TransferOptions,\n ): Promise<void>;\n download(\n source: string,\n destination: string,\n options?: TransferOptions,\n ): Promise<void>;\n release(): Promise<void>;\n}\n\nexport interface SandboxProvider {\n readonly name: string;\n readonly placement: \"mounted\" | \"remote\" | \"host\";\n readonly variables?: Variables;\n acquire(context: SandboxContext): Promise<SandboxLease>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const usageDimensions: readonly ["input", "cached", "cacheCreated", "output"];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"budget.constants.js","sourceRoot":"","sources":["../../../src/domain/workflow/budget.constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,OAAO;IACP,QAAQ;IACR,cAAc;IACd,QAAQ;CACA,CAAC","sourcesContent":["export const usageDimensions = [\n \"input\",\n \"cached\",\n \"cacheCreated\",\n \"output\",\n] as const;\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Usage } from "../agent.types.ts";
|
|
2
|
+
import type { WorkflowAccounting, WorkflowBudget } from "./budget.types.ts";
|
|
3
|
+
export declare class WorkflowBudgetExceeded extends Error {
|
|
4
|
+
readonly dimension: "attempts" | keyof Usage;
|
|
5
|
+
readonly limit: number;
|
|
6
|
+
readonly observed: number;
|
|
7
|
+
constructor(dimension: "attempts" | keyof Usage, limit: number, observed: number);
|
|
8
|
+
}
|
|
9
|
+
export declare function workflowAccounting(budget: WorkflowBudget | undefined, exhaust: (error: WorkflowBudgetExceeded) => void): WorkflowAccounting;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { addUsage } from "../usage.js";
|
|
2
|
+
import { usageDimensions } from "./budget.constants.js";
|
|
3
|
+
export class WorkflowBudgetExceeded extends Error {
|
|
4
|
+
dimension;
|
|
5
|
+
limit;
|
|
6
|
+
observed;
|
|
7
|
+
constructor(dimension, limit, observed) {
|
|
8
|
+
super(`Workflow budget exhausted: ${dimension} limit ${limit}, observed ${observed}`);
|
|
9
|
+
this.name = "WorkflowBudgetExceeded";
|
|
10
|
+
this.dimension = dimension;
|
|
11
|
+
this.limit = limit;
|
|
12
|
+
this.observed = observed;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export function workflowAccounting(budget, exhaust) {
|
|
16
|
+
for (const [key, value] of Object.entries({
|
|
17
|
+
attempts: budget?.attempts,
|
|
18
|
+
...budget?.usage,
|
|
19
|
+
})) {
|
|
20
|
+
if (value !== undefined && (!Number.isSafeInteger(value) || value < 0))
|
|
21
|
+
throw new Error(`Workflow budget ${key} must be a nonnegative safe integer`);
|
|
22
|
+
}
|
|
23
|
+
let attempts = 0;
|
|
24
|
+
let tokens = { input: 0, cached: 0, output: 0 };
|
|
25
|
+
let exhausted = false;
|
|
26
|
+
let usageExhausted = false;
|
|
27
|
+
function fail(dimension, limit, observed) {
|
|
28
|
+
const error = new WorkflowBudgetExceeded(dimension, limit, observed);
|
|
29
|
+
if (!exhausted || (dimension !== "attempts" && !usageExhausted)) {
|
|
30
|
+
exhausted = true;
|
|
31
|
+
if (dimension !== "attempts")
|
|
32
|
+
usageExhausted = true;
|
|
33
|
+
exhaust(error);
|
|
34
|
+
}
|
|
35
|
+
return error;
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
get exhausted() {
|
|
39
|
+
return exhausted;
|
|
40
|
+
},
|
|
41
|
+
admit() {
|
|
42
|
+
if (budget?.attempts !== undefined && attempts >= budget.attempts)
|
|
43
|
+
throw fail("attempts", budget.attempts, attempts);
|
|
44
|
+
for (const dimension of usageDimensions) {
|
|
45
|
+
const limit = budget?.usage?.[dimension];
|
|
46
|
+
if (limit !== undefined && (tokens[dimension] ?? 0) >= limit)
|
|
47
|
+
throw fail(dimension, limit, tokens[dimension] ?? 0);
|
|
48
|
+
}
|
|
49
|
+
attempts++;
|
|
50
|
+
},
|
|
51
|
+
report(usage) {
|
|
52
|
+
for (const dimension of usageDimensions) {
|
|
53
|
+
const value = usage[dimension] ?? 0;
|
|
54
|
+
if (!Number.isSafeInteger(value) || value < 0)
|
|
55
|
+
throw new Error(`Reported usage ${dimension} must be a nonnegative safe integer`);
|
|
56
|
+
}
|
|
57
|
+
tokens = addUsage(tokens, usage);
|
|
58
|
+
for (const dimension of usageDimensions) {
|
|
59
|
+
const limit = budget?.usage?.[dimension];
|
|
60
|
+
if (limit !== undefined && (tokens[dimension] ?? 0) >= limit)
|
|
61
|
+
fail(dimension, limit, tokens[dimension] ?? 0);
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
snapshot: () => Object.freeze({ attempts, tokens: Object.freeze({ ...tokens }) }),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=budget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"budget.js","sourceRoot":"","sources":["../../../src/domain/workflow/budget.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAGxD,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IACtC,SAAS,CAA2B;IACpC,KAAK,CAAS;IACd,QAAQ,CAAS;IAC1B,YACE,SAAmC,EACnC,KAAa,EACb,QAAgB;QAEhB,KAAK,CACH,8BAA8B,SAAS,UAAU,KAAK,cAAc,QAAQ,EAAE,CAC/E,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;QACrC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AAED,MAAM,UAAU,kBAAkB,CAChC,MAAkC,EAClC,OAAgD;IAEhD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC;QACxC,QAAQ,EAAE,MAAM,EAAE,QAAQ;QAC1B,GAAG,MAAM,EAAE,KAAK;KACjB,CAAC,EAAE,CAAC;QACH,IAAI,KAAK,KAAK,SAAS,IAAI,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC;YACpE,MAAM,I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AC,CAAC;YACzD,CAAC;YACD,QAAQ,EAAE,CAAC;QACb,CAAC;QACD,MAAM,CAAC,KAAK;YACV,KAAK,MAAM,SAAS,IAAI,eAAe,EAAE,CAAC;gBACxC,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;gBACpC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC;oBAC3C,MAAM,IAAI,KAAK,CACb,kBAAkB,SAAS,qCAAqC,CACjE,CAAC;YACN,CAAC;YACD,MAAM,GAAG,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;YACjC,KAAK,MAAM,SAAS,IAAI,eAAe,EAAE,CAAC;gBACxC,MAAM,KAAK,GAAG,MAAM,EAAE,KAAK,EAAE,CAAC,SAAS,CAAC,CAAC;gBACzC,IAAI,KAAK,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK;oBAC1D,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;QACD,QAAQ,EAAE,GAAG,EAAE,CACb,MAAM,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC,EAAE,CAAC;KACpE,CAAC;AACJ,CAAC","sourcesContent":["import type { Usage } from \"../agent.types.ts\";\nimport { addUsage } from \"../usage.ts\";\nimport { usageDimensions } from \"./budget.constants.ts\";\nimport type { WorkflowAccounting, WorkflowBudget } from \"./budget.types.ts\";\n\nexport class WorkflowBudgetExceeded extends Error {\n readonly dimension: \"attempts\" | keyof Usage;\n readonly limit: number;\n readonly observed: number;\n constructor(\n dimension: \"attempts\" | keyof Usage,\n limit: number,\n observed: number,\n ) {\n super(\n `Workflow budget exhausted: ${dimension} limit ${limit}, observed ${observed}`,\n );\n this.name = \"WorkflowBudgetExceeded\";\n this.dimension = dimension;\n this.limit = limit;\n this.observed = observed;\n }\n}\n\nexport function workflowAccounting(\n budget: WorkflowBudget | undefined,\n exhaust: (error: WorkflowBudgetExceeded) => void,\n): WorkflowAccounting {\n for (const [key, value] of Object.entries({\n attempts: budget?.attempts,\n ...budget?.usage,\n })) {\n if (value !== undefined && (!Number.isSafeInteger(value) || value < 0))\n throw new Error(\n `Workflow budget ${key} must be a nonnegative safe integer`,\n );\n }\n let attempts = 0;\n let tokens: Usage = { input: 0, cached: 0, output: 0 };\n let exhausted = false;\n let usageExhausted = false;\n function fail(\n dimension: \"attempts\" | keyof Usage,\n limit: number,\n observed: number,\n ): WorkflowBudgetExceeded {\n const error = new WorkflowBudgetExceeded(dimension, limit, observed);\n if (!exhausted || (dimension !== \"attempts\" && !usageExhausted)) {\n exhausted = true;\n if (dimension !== \"attempts\") usageExhausted = true;\n exhaust(error);\n }\n return error;\n }\n return {\n get exhausted() {\n return exhausted;\n },\n admit() {\n if (budget?.attempts !== undefined && attempts >= budget.attempts)\n throw fail(\"attempts\", budget.attempts, attempts);\n for (const dimension of usageDimensions) {\n const limit = budget?.usage?.[dimension];\n if (limit !== undefined && (tokens[dimension] ?? 0) >= limit)\n throw fail(dimension, limit, tokens[dimension] ?? 0);\n }\n attempts++;\n },\n report(usage) {\n for (const dimension of usageDimensions) {\n const value = usage[dimension] ?? 0;\n if (!Number.isSafeInteger(value) || value < 0)\n throw new Error(\n `Reported usage ${dimension} must be a nonnegative safe integer`,\n );\n }\n tokens = addUsage(tokens, usage);\n for (const dimension of usageDimensions) {\n const limit = budget?.usage?.[dimension];\n if (limit !== undefined && (tokens[dimension] ?? 0) >= limit)\n fail(dimension, limit, tokens[dimension] ?? 0);\n }\n },\n snapshot: () =>\n Object.freeze({ attempts, tokens: Object.freeze({ ...tokens }) }),\n };\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Usage } from "../agent.types.ts";
|
|
2
|
+
export interface WorkflowBudget {
|
|
3
|
+
readonly attempts?: number;
|
|
4
|
+
readonly usage?: Partial<Usage>;
|
|
5
|
+
}
|
|
6
|
+
export interface WorkflowUsage {
|
|
7
|
+
readonly attempts: number;
|
|
8
|
+
readonly tokens: Usage;
|
|
9
|
+
}
|
|
10
|
+
export interface WorkflowAccounting {
|
|
11
|
+
readonly exhausted: boolean;
|
|
12
|
+
admit(): void;
|
|
13
|
+
report(usage: Usage): void;
|
|
14
|
+
snapshot(): WorkflowUsage;
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"budget.types.js","sourceRoot":"","sources":["../../../src/domain/workflow/budget.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Usage } from \"../agent.types.ts\";\n\nexport interface WorkflowBudget {\n readonly attempts?: number;\n readonly usage?: Partial<Usage>;\n}\n\nexport interface WorkflowUsage {\n readonly attempts: number;\n readonly tokens: Usage;\n}\n\nexport interface WorkflowAccounting {\n readonly exhausted: boolean;\n admit(): void;\n report(usage: Usage): void;\n snapshot(): WorkflowUsage;\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { WorkflowBudgetExceeded } from "./budget.js";
|
|
1
2
|
import { setTimeout as delay } from "node:timers/promises";
|
|
2
3
|
export async function runTask(item, runtime) {
|
|
3
4
|
const { record, signal, context, emit, finish, values, errors, options, stop, } = runtime;
|
|
@@ -15,13 +16,16 @@ export async function runTask(item, runtime) {
|
|
|
15
16
|
const limit = item.retry?.attempts ?? 1;
|
|
16
17
|
for (let attempt = 1; attempt <= limit; attempt++) {
|
|
17
18
|
signal.throwIfAborted();
|
|
19
|
+
runtime.accounting.admit();
|
|
18
20
|
state.attempts = attempt;
|
|
21
|
+
emit({ type: "attempt", key: item.key, attempt });
|
|
19
22
|
const deadline = new AbortController();
|
|
20
23
|
const timer = item.timeoutMs === undefined
|
|
21
24
|
? undefined
|
|
22
25
|
: setTimeout(() => deadline.abort(new Error(`${item.key} timed out`)), item.timeoutMs);
|
|
23
26
|
const taskSignal = AbortSignal.any([signal, deadline.signal]);
|
|
24
27
|
try {
|
|
28
|
+
taskSignal.throwIfAborted();
|
|
25
29
|
const value = await item.perform(context(item, attempt, taskSignal));
|
|
26
30
|
taskSignal.throwIfAborted();
|
|
27
31
|
values.set(item, value);
|
|
@@ -29,6 +33,7 @@ export async function runTask(item, runtime) {
|
|
|
29
33
|
return;
|
|
30
34
|
}
|
|
31
35
|
catch (error) {
|
|
36
|
+
runtime.closeAttempt(item);
|
|
32
37
|
if (signal.aborted ||
|
|
33
38
|
attempt === limit ||
|
|
34
39
|
item.retry?.accepts?.(error, attempt) === false)
|
|
@@ -36,6 +41,7 @@ export async function runTask(item, runtime) {
|
|
|
36
41
|
emit({ type: "retry", key: item.key, attempt });
|
|
37
42
|
}
|
|
38
43
|
finally {
|
|
44
|
+
runtime.closeAttempt(item);
|
|
39
45
|
clearTimeout(timer);
|
|
40
46
|
}
|
|
41
47
|
await delay(item.retry?.delayMs ?? 0, undefined, { signal });
|
|
@@ -43,7 +49,8 @@ export async function runTask(item, runtime) {
|
|
|
43
49
|
}
|
|
44
50
|
catch (error) {
|
|
45
51
|
state.error = error instanceof Error ? error.message : String(error);
|
|
46
|
-
if (signal.aborted
|
|
52
|
+
if (signal.aborted ||
|
|
53
|
+
(error instanceof WorkflowBudgetExceeded && runtime.accounting.exhausted))
|
|
47
54
|
finish(item, "cancelled");
|
|
48
55
|
else {
|
|
49
56
|
errors.push(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-runner.js","sourceRoot":"","sources":["../../../src/domain/workflow/task-runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAG3D,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,IAAU,EACV,OAA+B;IAE/B,MAAM,EACJ,MAAM,EACN,MAAM,EACN,OAAO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AI,CAAC,CAAC;gBAC3B,YAAY,CAAC,KAAK,CAAC,CAAC;YACtB,CAAC;YACD,MAAM,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,IAAI,CAAC,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,KAAK,CAAC,KAAK,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACrE,IACE,MAAM,CAAC,OAAO;YACd,CAAC,KAAK,YAAY,sBAAsB,IAAI,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC;YAEzE,MAAM,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;aACvB,CAAC;YACJ,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACnB,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YACvB,IAAI,OAAO,CAAC,WAAW,KAAK,KAAK;gBAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { WorkflowBudgetExceeded } from \"./budget.ts\";\nimport { setTimeout as delay } from \"node:timers/promises\";\nimport type { Task, WorkflowExecutionState } from \"../workflow.types.ts\";\n\nexport async function runTask(\n item: Task,\n runtime: WorkflowExecutionState,\n): Promise<void> {\n const {\n record,\n signal,\n context,\n emit,\n finish,\n values,\n errors,\n options,\n stop,\n } = runtime;\n const state = record(item);\n state.status = \"active\";\n state.startedAt = new Date().toISOString();\n emit({ type: \"task\", key: item.key, status: \"active\", attempt: 0 });\n try {\n signal.throwIfAborted();\n if (item.condition && !(await item.condition(context(item, 0, signal)))) {\n signal.throwIfAborted();\n finish(item, \"skipped\");\n return;\n }\n const limit = item.retry?.attempts ?? 1;\n for (let attempt = 1; attempt <= limit; attempt++) {\n signal.throwIfAborted();\n runtime.accounting.admit();\n state.attempts = attempt;\n emit({ type: \"attempt\", key: item.key, attempt });\n const deadline = new AbortController();\n const timer =\n item.timeoutMs === undefined\n ? undefined\n : setTimeout(\n () => deadline.abort(new Error(`${item.key} timed out`)),\n item.timeoutMs,\n );\n const taskSignal = AbortSignal.any([signal, deadline.signal]);\n try {\n taskSignal.throwIfAborted();\n const value = await item.perform(context(item, attempt, taskSignal));\n taskSignal.throwIfAborted();\n values.set(item, value);\n finish(item, \"done\");\n return;\n } catch (error) {\n runtime.closeAttempt(item);\n if (\n signal.aborted ||\n attempt === limit ||\n item.retry?.accepts?.(error, attempt) === false\n )\n throw error;\n emit({ type: \"retry\", key: item.key, attempt });\n } finally {\n runtime.closeAttempt(item);\n clearTimeout(timer);\n }\n await delay(item.retry?.delayMs ?? 0, undefined, { signal });\n }\n } catch (error) {\n state.error = error instanceof Error ? error.message : String(error);\n if (\n signal.aborted ||\n (error instanceof WorkflowBudgetExceeded && runtime.accounting.exhausted)\n )\n finish(item, \"cancelled\");\n else {\n errors.push(error);\n finish(item, \"failed\");\n if (options.stopOnError !== false) stop.abort(error);\n }\n }\n}\n"]}
|
|
@@ -8,13 +8,14 @@ export async function schedule(name, tasks, options) {
|
|
|
8
8
|
const state = workflowState(name, tasks, options);
|
|
9
9
|
const { executionId, signal, values, records, errors, observerErrors, record, emit, finish, } = state;
|
|
10
10
|
const active = new Map();
|
|
11
|
+
const started = Date.now();
|
|
11
12
|
emit({ type: "start" });
|
|
12
13
|
while (true) {
|
|
13
14
|
let changed = false;
|
|
14
15
|
for (const item of tasks) {
|
|
15
16
|
if (record(item).status !== "waiting")
|
|
16
17
|
continue;
|
|
17
|
-
if (signal.aborted) {
|
|
18
|
+
if (signal.aborted || state.accounting.exhausted) {
|
|
18
19
|
finish(item, "cancelled");
|
|
19
20
|
changed = true;
|
|
20
21
|
continue;
|
|
@@ -48,11 +49,12 @@ export async function schedule(name, tasks, options) {
|
|
|
48
49
|
: errors.length
|
|
49
50
|
? "failed"
|
|
50
51
|
: "done";
|
|
51
|
-
emit({ type: "finish" });
|
|
52
|
+
emit({ type: "finish", status, durationMs: Date.now() - started });
|
|
52
53
|
const result = Object.freeze({
|
|
53
54
|
executionId,
|
|
54
55
|
name,
|
|
55
56
|
status,
|
|
57
|
+
usage: state.accounting.snapshot(),
|
|
56
58
|
tasks: Object.freeze([...records.values()].map((value) => Object.freeze({ ...value }))),
|
|
57
59
|
errors: Object.freeze(errors),
|
|
58
60
|
observerErrors: Object.freeze(observerErrors),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-scheduler.js","sourceRoot":"","sources":["../../../src/domain/workflow/workflow-scheduler.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,IAAY,EACZ,KAAsB,EACtB,OAAwB;IAExB,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,CAAC,CAAC;IAC7C,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;IACrC,MAAM,KAAK,GAAG,aAAa,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAClD,MAAM,EACJ,WAAW,EACX,MAAM,EACN,MAAM,EACN,OAAO,EACP,MAAM,EACN,cAAc,EACd,MAAM,EACN,IAAI,EACJ,MAAM,GACP,GAAG,KAAK,CAAC;IACV,MAAM,MAAM,GAAG,IAAI,GAAG,EAAuB,CAAC;IAC9C,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IACxB,OAAO,IAAI,EAAE,CAAC;QACZ,IAAI,OAAO,GAAG,KAAK,CAAC;QAC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Failure } from \"./failure.ts\";\nimport { runTask } from \"./task-runner.ts\";\nimport { positive } from \"./validation.ts\";\nimport { workflowState } from \"./workflow-state.ts\";\n\nexport async function schedule(\n name: string,\n tasks: readonly Task[],\n options: WorkflowOptions,\n): Promise<WorkflowResult> {\n const concurrency = options.concurrency ?? 1;\n positive(concurrency, \"concurrency\");\n const state = workflowState(name, tasks, options);\n const {\n executionId,\n signal,\n values,\n records,\n errors,\n observerErrors,\n record,\n emit,\n finish,\n } = state;\n const active = new Map<Task, Promise<void>>();\n const started = Date.now();\n emit({ type: \"start\" });\n while (true) {\n let changed = false;\n for (const item of tasks) {\n if (record(item).status !== \"waiting\") continue;\n if (signal.aborted || state.accounting.exhausted) {\n finish(item, \"cancelled\");\n changed = true;\n continue;\n }\n const dependencies = item.after.map(\n (dependency) => record(dependency).status,\n );\n if (\n dependencies.some((status) =>\n [\"failed\", \"skipped\", \"cancelled\"].includes(status),\n )\n ) {\n finish(item, \"skipped\");\n changed = true;\n continue;\n }\n if (\n active.size >= concurrency ||\n !dependencies.every((status) => status === \"done\")\n )\n continue;\n const running = runTask(item, state).finally(() => {\n active.delete(item);\n });\n active.set(item, running);\n changed = true;\n }\n if (active.size) {\n await Promise.race(active.values());\n continue;\n }\n if (!changed) break;\n }\n if (options.signal?.aborted) errors.push(options.signal.reason);\n const status = options.signal?.aborted\n ? \"cancelled\"\n : errors.length\n ? \"failed\"\n : \"done\";\n emit({ type: \"finish\", status, durationMs: Date.now() - started });\n const result: WorkflowResult = Object.freeze({\n executionId,\n name,\n status,\n usage: state.accounting.snapshot(),\n tasks: Object.freeze(\n [...records.values()].map((value) => Object.freeze({ ...value })),\n ),\n errors: Object.freeze(errors),\n observerErrors: Object.freeze(observerErrors),\n value<T>(item: Task<T>): T {\n if (!values.has(item))\n throw new Error(\n `${item.key} has no successful value in this execution`,\n );\n return values.get(item) as T;\n },\n unwrap() {\n if (status !== \"done\") throw new WorkflowFailure(result);\n },\n });\n return result;\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { workflowAccounting } from "./budget.js";
|
|
1
2
|
import { randomUUID } from "node:crypto";
|
|
2
3
|
export function workflowState(name, tasks, options) {
|
|
3
4
|
const executionId = randomUUID();
|
|
@@ -6,11 +7,17 @@ export function workflowState(name, tasks, options) {
|
|
|
6
7
|
? AbortSignal.any([options.signal, stop.signal])
|
|
7
8
|
: stop.signal;
|
|
8
9
|
const values = new Map();
|
|
10
|
+
const activeAttempts = new Map();
|
|
9
11
|
const records = new Map(tasks.map((item) => [
|
|
10
12
|
item,
|
|
11
13
|
{ key: item.key, status: "waiting", attempts: 0 },
|
|
12
14
|
]));
|
|
13
15
|
const errors = [], observerErrors = [];
|
|
16
|
+
const accounting = workflowAccounting(options.budget, (error) => {
|
|
17
|
+
errors.push(error);
|
|
18
|
+
if (error.dimension !== "attempts")
|
|
19
|
+
stop.abort(error);
|
|
20
|
+
});
|
|
14
21
|
const record = (item) => records.get(item);
|
|
15
22
|
function emit(event) {
|
|
16
23
|
try {
|
|
@@ -35,13 +42,31 @@ export function workflowState(name, tasks, options) {
|
|
|
35
42
|
key: item.key,
|
|
36
43
|
status,
|
|
37
44
|
attempt: record(item).attempts,
|
|
45
|
+
...(record(item).startedAt
|
|
46
|
+
? { durationMs: Date.now() - Date.parse(record(item).startedAt) }
|
|
47
|
+
: {}),
|
|
38
48
|
});
|
|
39
49
|
}
|
|
40
50
|
function context(item, attempt, taskSignal) {
|
|
51
|
+
if (attempt > 0)
|
|
52
|
+
activeAttempts.set(item, attempt);
|
|
41
53
|
return {
|
|
42
54
|
signal: taskSignal,
|
|
43
55
|
attempt,
|
|
44
56
|
executionId,
|
|
57
|
+
reportUsage(usage) {
|
|
58
|
+
if (attempt === 0 ||
|
|
59
|
+
record(item).status !== "active" ||
|
|
60
|
+
activeAttempts.get(item) !== attempt)
|
|
61
|
+
throw new Error("Usage must be reported during its active task attempt");
|
|
62
|
+
accounting.report(usage);
|
|
63
|
+
emit({
|
|
64
|
+
type: "usage",
|
|
65
|
+
key: item.key,
|
|
66
|
+
attempt,
|
|
67
|
+
usage: Object.freeze({ ...usage }),
|
|
68
|
+
});
|
|
69
|
+
},
|
|
45
70
|
value(dependency) {
|
|
46
71
|
if (!item.after.includes(dependency))
|
|
47
72
|
throw new Error(`${item.key}: undeclared dependency ${dependency.key}`);
|
|
@@ -53,6 +78,10 @@ export function workflowState(name, tasks, options) {
|
|
|
53
78
|
}
|
|
54
79
|
return {
|
|
55
80
|
executionId,
|
|
81
|
+
accounting,
|
|
82
|
+
closeAttempt(item) {
|
|
83
|
+
activeAttempts.delete(item);
|
|
84
|
+
},
|
|
56
85
|
stop,
|
|
57
86
|
signal,
|
|
58
87
|
values,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-state.js","sourceRoot":"","sources":["../../../src/domain/workflow/workflow-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAWzC,MAAM,UAAU,aAAa,CAC3B,IAAY,EACZ,KAAsB,EACtB,OAAwB;IAExB,MAAM,WAAW,GAAG,UAAU,EAAE,CAAC;IACjC,MAAM,IAAI,GAAG,IAAI,eAAe,EAAE,CAAC;IACnC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM;QAC3B,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAChD,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;IAChB,MAAM,MAAM,GAAG,IAAI,GAAG,EAAiB,CAAC;IACxC,MAAM,OAAO,GAAG,IAAI,GAAG,CACrB,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;QAClB,IAAI;QACJ,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,EAAE;KAClD,CAAC,CACH,CAAC;IACF,MAAM,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,QAAQ,CAAC,UAAU,CAAC;oBAClC,MAAM,IAAI,KAAK,CACb,GAAG,IAAI,CAAC,GAAG,2BAA2B,UAAU,CAAC,GAAG,EAAE,CACvD,CAAC;gBACJ,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC;oBACzB,MAAM,IAAI,KAAK,CAAC,GAAG,UAAU,CAAC,GAAG,0BAA0B,CAAC,CAAC;gBAC/D,OAAO,MAAM,CAAC,GAAG,CAAC,UAAU,CAAM,CAAC;YACrC,CAAC;SACF,CAAC;IACJ,CAAC;IAED,OAAO;QACL,WAAW;QACX,UAAU;QACV,YAAY,CAAC,IAAI;YACf,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC9B,CAAC;QACD,IAAI;QACJ,MAAM;QACN,MAAM;QACN,OAAO;QACP,MAAM;QACN,cAAc;QACd,MAAM;QACN,IAAI;QACJ,MAAM;QACN,OAAO;QACP,OAAO;KACR,CAAC;AACJ,CAAC","sourcesContent":["import { workflowAccounting } from \"./budget.ts\";\nimport { randomUUID } from \"node:crypto\";\nimport type {\n Task,\n TaskContext,\n TaskRecord,\n TaskStatus,\n WorkflowEvent,\n WorkflowExecutionState,\n WorkflowOptions,\n} from \"../workflow.types.ts\";\n\nexport function workflowState(\n name: string,\n tasks: readonly Task[],\n options: WorkflowOptions,\n): WorkflowExecutionState {\n const executionId = randomUUID();\n const stop = new AbortController();\n const signal = options.signal\n ? AbortSignal.any([options.signal, stop.signal])\n : stop.signal;\n const values = new Map<Task, unknown>();\n const activeAttempts = new Map<Task, number>();\n const records = new Map<Task, TaskRecord>(\n tasks.map((item) => [\n item,\n { key: item.key, status: \"waiting\", attempts: 0 },\n ]),\n );\n const errors: unknown[] = [],\n observerErrors: unknown[] = [];\n const accounting = workflowAccounting(options.budget, (error) => {\n errors.push(error);\n if (error.dimension !== \"attempts\") stop.abort(error);\n });\n const record = (item: Task) => records.get(item)!;\n function emit(\n event: Omit<WorkflowEvent, \"executionId\" | \"workflow\" | \"timestamp\">,\n ): void {\n try {\n options.observe?.({\n ...event,\n executionId,\n workflow: name,\n timestamp: new Date().toISOString(),\n });\n } catch (error) {\n observerErrors.push(error);\n }\n }\n function finish(item: Task, status: TaskStatus): void {\n Object.assign(record(item), {\n status,\n finishedAt: new Date().toISOString(),\n });\n emit({\n type: \"task\",\n key: item.key,\n status,\n attempt: record(item).attempts,\n ...(record(item).startedAt\n ? { durationMs: Date.now() - Date.parse(record(item).startedAt!) }\n : {}),\n });\n }\n function context(\n item: Task,\n attempt: number,\n taskSignal: AbortSignal,\n ): TaskContext {\n if (attempt > 0) activeAttempts.set(item, attempt);\n return {\n signal: taskSignal,\n attempt,\n executionId,\n reportUsage(usage) {\n if (\n attempt === 0 ||\n record(item).status !== \"active\" ||\n activeAttempts.get(item) !== attempt\n )\n throw new Error(\n \"Usage must be reported during its active task attempt\",\n );\n accounting.report(usage);\n emit({\n type: \"usage\",\n key: item.key,\n attempt,\n usage: Object.freeze({ ...usage }),\n });\n },\n value<T>(dependency: Task<T>): T {\n if (!item.after.includes(dependency))\n throw new Error(\n `${item.key}: undeclared dependency ${dependency.key}`,\n );\n if (!values.has(dependency))\n throw new Error(`${dependency.key} has no successful value`);\n return values.get(dependency) as T;\n },\n };\n }\n\n return {\n executionId,\n accounting,\n closeAttempt(item) {\n activeAttempts.delete(item);\n },\n stop,\n signal,\n values,\n records,\n errors,\n observerErrors,\n record,\n emit,\n finish,\n context,\n options,\n };\n}\n"]}
|
|
@@ -3,3 +3,5 @@ export type { Retry, Task, TaskContext, TaskOptions, TaskRecord, TaskStatus, Wor
|
|
|
3
3
|
export { WorkflowFailure } from "./workflow/failure.ts";
|
|
4
4
|
export { task } from "./workflow/task.ts";
|
|
5
5
|
export declare function workflow(name: string, tasks: readonly Task[]): Workflow;
|
|
6
|
+
export { WorkflowBudgetExceeded } from "./workflow/budget.ts";
|
|
7
|
+
export type { WorkflowBudget, WorkflowUsage } from "./workflow/budget.types.ts";
|
package/dist/domain/workflow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,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAChE;iBACF,CAAC;aACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACf,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Task, Workflow, WorkflowOptions } from \"./workflow.types.ts\";\nimport { validate } from \"./workflow/validation.ts\";\nimport { schedule } from \"./workflow/workflow-scheduler.ts\";\n\nexport type {\n Retry,\n Task,\n TaskContext,\n TaskOptions,\n TaskRecord,\n TaskStatus,\n Workflow,\n WorkflowEvent,\n WorkflowOptions,\n WorkflowResult,\n} from \"./workflow.types.ts\";\nexport { WorkflowFailure } from \"./workflow/failure.ts\";\nexport { task } from \"./workflow/task.ts\";\n\nexport function workflow(name: string, tasks: readonly Task[]): Workflow {\n if (!name.trim()) throw new Error(\"Workflow name cannot be empty\");\n const graph = Object.freeze([...tasks]);\n validate(graph);\n return Object.freeze({\n name,\n tasks: graph,\n start: (options: WorkflowOptions = {}) => schedule(name, graph, options),\n diagram() {\n const ids = new Map(graph.map((item, index) => [item, `n${index}`]));\n return [\n \"flowchart LR\",\n ...graph.flatMap((item) => [\n ` ${ids.get(item)}[\"${item.key}\"]`,\n ...item.after.map(\n (dependency) => ` ${ids.get(dependency)} --> ${ids.get(item)}`,\n ),\n ]),\n ].join(\"\\n\");\n },\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"workflow.js","sourceRoot":"","sources":["../../src/domain/workflow.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAc5D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE1C,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,KAAsB;IAC3D,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACnE,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;IACxC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAChB,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,IAAI;QACJ,KAAK,EAAE,KAAK;QACZ,KAAK,EAAE,CAAC,UAA2B,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC;QACxE,OAAO;YACL,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;YACrE,OAAO;gBACL,cAAc;gBACd,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;oBACzB,KAAK,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,GAAG,IAAI;oBACnC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CACf,CAAC,UAAU,EAAE,EAAE,CAAC,KAAK,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,QAAQ,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAChE;iBACF,CAAC;aACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACf,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAED,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC","sourcesContent":["import type { Task, Workflow, WorkflowOptions } from \"./workflow.types.ts\";\nimport { validate } from \"./workflow/validation.ts\";\nimport { schedule } from \"./workflow/workflow-scheduler.ts\";\n\nexport type {\n Retry,\n Task,\n TaskContext,\n TaskOptions,\n TaskRecord,\n TaskStatus,\n Workflow,\n WorkflowEvent,\n WorkflowOptions,\n WorkflowResult,\n} from \"./workflow.types.ts\";\nexport { WorkflowFailure } from \"./workflow/failure.ts\";\nexport { task } from \"./workflow/task.ts\";\n\nexport function workflow(name: string, tasks: readonly Task[]): Workflow {\n if (!name.trim()) throw new Error(\"Workflow name cannot be empty\");\n const graph = Object.freeze([...tasks]);\n validate(graph);\n return Object.freeze({\n name,\n tasks: graph,\n start: (options: WorkflowOptions = {}) => schedule(name, graph, options),\n diagram() {\n const ids = new Map(graph.map((item, index) => [item, `n${index}`]));\n return [\n \"flowchart LR\",\n ...graph.flatMap((item) => [\n ` ${ids.get(item)}[\"${item.key}\"]`,\n ...item.after.map(\n (dependency) => ` ${ids.get(dependency)} --> ${ids.get(item)}`,\n ),\n ]),\n ].join(\"\\n\");\n },\n });\n}\n\nexport { WorkflowBudgetExceeded } from \"./workflow/budget.ts\";\nexport type { WorkflowBudget, WorkflowUsage } from \"./workflow/budget.types.ts\";\n"]}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import type { Usage } from "./agent.types.ts";
|
|
2
|
+
import type { WorkflowAccounting, WorkflowBudget, WorkflowUsage } from "./workflow/budget.types.ts";
|
|
1
3
|
export interface TaskContext {
|
|
2
4
|
readonly signal: AbortSignal;
|
|
3
5
|
readonly attempt: number;
|
|
4
6
|
readonly executionId: string;
|
|
7
|
+
reportUsage(usage: Usage): void;
|
|
5
8
|
value<T>(dependency: Task<T>): T;
|
|
6
9
|
}
|
|
7
10
|
export interface Retry {
|
|
@@ -33,14 +36,17 @@ export interface WorkflowEvent {
|
|
|
33
36
|
readonly executionId: string;
|
|
34
37
|
readonly workflow: string;
|
|
35
38
|
readonly timestamp: string;
|
|
36
|
-
readonly type: "start" | "task" | "retry" | "finish";
|
|
39
|
+
readonly type: "start" | "task" | "attempt" | "retry" | "usage" | "finish";
|
|
37
40
|
readonly key?: string;
|
|
38
41
|
readonly status?: TaskStatus;
|
|
39
42
|
readonly attempt?: number;
|
|
43
|
+
readonly usage?: Usage;
|
|
44
|
+
readonly durationMs?: number;
|
|
40
45
|
}
|
|
41
46
|
export interface WorkflowOptions {
|
|
42
47
|
readonly signal?: AbortSignal;
|
|
43
48
|
readonly concurrency?: number;
|
|
49
|
+
readonly budget?: WorkflowBudget;
|
|
44
50
|
readonly stopOnError?: boolean;
|
|
45
51
|
readonly observe?: (event: WorkflowEvent) => void;
|
|
46
52
|
}
|
|
@@ -51,6 +57,7 @@ export interface WorkflowResult {
|
|
|
51
57
|
readonly tasks: readonly Readonly<TaskRecord>[];
|
|
52
58
|
readonly errors: readonly unknown[];
|
|
53
59
|
readonly observerErrors: readonly unknown[];
|
|
60
|
+
readonly usage: WorkflowUsage;
|
|
54
61
|
value<T>(task: Task<T>): T;
|
|
55
62
|
unwrap(): void;
|
|
56
63
|
}
|
|
@@ -70,6 +77,8 @@ export interface WorkflowExecutionState {
|
|
|
70
77
|
readonly errors: unknown[];
|
|
71
78
|
readonly observerErrors: unknown[];
|
|
72
79
|
readonly options: WorkflowOptions;
|
|
80
|
+
readonly accounting: WorkflowAccounting;
|
|
81
|
+
closeAttempt(task: Task): void;
|
|
73
82
|
record(task: Task): TaskRecord;
|
|
74
83
|
emit(event: WorkflowNotification): void;
|
|
75
84
|
finish(task: Task, status: TaskStatus): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow.types.js","sourceRoot":"","sources":["../../src/domain/workflow.types.ts"],"names":[],"mappings":"","sourcesContent":["
|
|
1
|
+
{"version":3,"file":"workflow.types.js","sourceRoot":"","sources":["../../src/domain/workflow.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Usage } from \"./agent.types.ts\";\nimport type {\n WorkflowAccounting,\n WorkflowBudget,\n WorkflowUsage,\n} from \"./workflow/budget.types.ts\";\n\nexport interface TaskContext {\n readonly signal: AbortSignal;\n readonly attempt: number;\n readonly executionId: string;\n reportUsage(usage: Usage): void;\n value<T>(dependency: Task<T>): T;\n}\n\nexport interface Retry {\n readonly attempts: number;\n readonly delayMs?: number;\n readonly accepts?: (error: unknown, attempt: number) => boolean;\n}\n\nexport interface Task<T = unknown> {\n readonly key: string;\n readonly after: readonly Task[];\n readonly perform: (context: TaskContext) => T | Promise<T>;\n readonly condition?: (context: TaskContext) => boolean | Promise<boolean>;\n readonly retry?: Retry;\n readonly timeoutMs?: number;\n}\n\nexport type TaskOptions<T> = Omit<Task<T>, \"after\"> & {\n readonly after?: readonly Task[];\n};\n\nexport type TaskStatus =\n \"waiting\" | \"active\" | \"done\" | \"failed\" | \"skipped\" | \"cancelled\";\n\nexport interface TaskRecord {\n readonly key: string;\n status: TaskStatus;\n attempts: number;\n startedAt?: string;\n finishedAt?: string;\n error?: string;\n}\n\nexport interface WorkflowEvent {\n readonly executionId: string;\n readonly workflow: string;\n readonly timestamp: string;\n readonly type: \"start\" | \"task\" | \"attempt\" | \"retry\" | \"usage\" | \"finish\";\n readonly key?: string;\n readonly status?: TaskStatus;\n readonly attempt?: number;\n readonly usage?: Usage;\n readonly durationMs?: number;\n}\n\nexport interface WorkflowOptions {\n readonly signal?: AbortSignal;\n readonly concurrency?: number;\n readonly budget?: WorkflowBudget;\n readonly stopOnError?: boolean;\n readonly observe?: (event: WorkflowEvent) => void;\n}\n\nexport interface WorkflowResult {\n readonly executionId: string;\n readonly name: string;\n readonly status: \"done\" | \"failed\" | \"cancelled\";\n readonly tasks: readonly Readonly<TaskRecord>[];\n readonly errors: readonly unknown[];\n readonly observerErrors: readonly unknown[];\n readonly usage: WorkflowUsage;\n value<T>(task: Task<T>): T;\n unwrap(): void;\n}\n\nexport interface Workflow {\n readonly name: string;\n readonly tasks: readonly Task[];\n start(options?: WorkflowOptions): Promise<WorkflowResult>;\n diagram(): string;\n}\n\nexport type WorkflowNotification = Omit<\n WorkflowEvent,\n \"executionId\" | \"workflow\" | \"timestamp\"\n>;\nexport interface WorkflowExecutionState {\n readonly executionId: string;\n readonly stop: AbortController;\n readonly signal: AbortSignal;\n readonly values: Map<Task, unknown>;\n readonly records: Map<Task, TaskRecord>;\n readonly errors: unknown[];\n readonly observerErrors: unknown[];\n readonly options: WorkflowOptions;\n readonly accounting: WorkflowAccounting;\n closeAttempt(task: Task): void;\n record(task: Task): TaskRecord;\n emit(event: WorkflowNotification): void;\n finish(task: Task, status: TaskStatus): void;\n context(task: Task, attempt: number, signal: AbortSignal): TaskContext;\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
export { attach, createSandbox, dispatch, openWorkspace, } from "./application/outpost.ts";
|
|
2
2
|
export type { AttachOptions, AttachResult, ContinuationOptions, DispatchResult, Sandbox, SandboxOptions, WarmDispatchResult, Workspace, WorkspaceOptions, } from "./application/outpost.ts";
|
|
3
3
|
export type { DispatchOptions, Execution, Turn, } from "./application/execution.ts";
|
|
4
|
-
export { WorkflowFailure, task, workflow } from "./domain/workflow.ts";
|
|
5
|
-
export type { Retry, Task, TaskContext, TaskOptions, TaskRecord, TaskStatus, Workflow, WorkflowEvent, WorkflowOptions, WorkflowResult, } from "./domain/workflow.ts";
|
|
4
|
+
export { WorkflowFailure, WorkflowBudgetExceeded, task, workflow, } from "./domain/workflow.ts";
|
|
5
|
+
export type { Retry, Task, TaskContext, TaskOptions, TaskRecord, TaskStatus, Workflow, WorkflowEvent, WorkflowOptions, WorkflowBudget, WorkflowUsage, WorkflowResult, } from "./domain/workflow.ts";
|
|
6
6
|
export { agentTask, commandTask, isolatedTask } from "./application/tasks.ts";
|
|
7
|
-
export { campaign } from "./application/campaign.ts";
|
|
8
|
-
export type { CampaignEvent, CampaignOptions, CampaignResult, IssueOutcome, } from "./application/campaign.ts";
|
|
9
|
-
export type { Assignment, Backlog, Issue } from "./domain/backlog.ts";
|
|
10
|
-
export { beadsBacklog, githubBacklog } from "./providers/backlogs.ts";
|
|
11
|
-
export type { BacklogSettings } from "./providers/backlogs.ts";
|
|
12
7
|
export { claude, codex } from "./providers/agents.ts";
|
|
13
8
|
export { agentVersions } from "./providers/versions.ts";
|
|
14
9
|
export { conversations } from "./infrastructure/conversations.ts";
|
|
@@ -19,9 +14,18 @@ export { ResponseError, response } from "./domain/response.ts";
|
|
|
19
14
|
export type { ResponseSpec, StandardValidator } from "./domain/response.ts";
|
|
20
15
|
export { OutpostError, recoveryDetails } from "./domain/errors.ts";
|
|
21
16
|
export type { FaultCode } from "./domain/errors.ts";
|
|
22
|
-
export type { AgentAdapter, AgentEvent, AgentInput, AgentObservation, BranchPolicy, Channel, Command, CommandResult, Commit, ConversationContext, ConversationRecord, ConversationStore, Disposal, LifecycleHooks, SandboxContext, SandboxLease, SandboxProvider, StageLimits, TransferOptions, Usage, Variables, Volume, WorkspaceRecord, } from "./domain/ports.ts";
|
|
17
|
+
export type { AgentAdapter, AgentEvent, AgentInput, AgentObservation, BranchPolicy, Channel, Command, CommandResult, Commit, ConversationContext, ConversationRecord, ConversationStore, Disposal, LifecycleHooks, FileManifestEntry, FileTransfers, SandboxContext, SandboxLease, SandboxProvider, StageLimits, TransferOptions, Usage, Variables, Volume, WorkspaceRecord, } from "./domain/ports.ts";
|
|
23
18
|
export type { Brief, PromptVariables } from "./domain/prompts.ts";
|
|
24
19
|
export type { Logging } from "./infrastructure/journal.ts";
|
|
25
20
|
export { reporter } from "./infrastructure/reporter.ts";
|
|
26
21
|
export type { ReporterOptions } from "./infrastructure/reporter.ts";
|
|
27
22
|
export type { VariableQuestion } from "./application/interactive-brief.ts";
|
|
23
|
+
export { planRecoveryRetention, pruneRecoveryRetention, assertRecoveryQuota, } from "./application/recovery-retention.ts";
|
|
24
|
+
export type { RecoveryRetentionPolicy, RecoveryRetentionOptions, RecoveryRetentionPlan, RecoveryRetentionEntry, RecoveryPruneResult, RecoveryQuotaOptions, } from "./application/recovery-retention.types.ts";
|
|
25
|
+
export { verifyRecoveryTransfer } from "./application/recovery-verification.ts";
|
|
26
|
+
export type { RecoveryVerification, RecoveryVerificationOptions, } from "./application/recovery-verification.types.ts";
|
|
27
|
+
export { diagnoseSandbox } from "./application/doctor-sandbox.ts";
|
|
28
|
+
export type { SandboxDiagnosticOptions, SandboxDiagnosticReport, DiagnosticCapability, } from "./application/doctor-sandbox.types.ts";
|
|
29
|
+
export type { DiagnosticCheck, DiagnosticStatus, DoctorAgent, } from "./application/doctor.types.ts";
|
|
30
|
+
export { diagnoseAgentProtocol } from "./application/doctor-protocol.ts";
|
|
31
|
+
export type { AgentProtocolReport } from "./application/doctor-protocol.types.ts";
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export { attach, createSandbox, dispatch, openWorkspace, } from "./application/outpost.js";
|
|
2
|
-
export { WorkflowFailure, task, workflow } from "./domain/workflow.js";
|
|
2
|
+
export { WorkflowFailure, WorkflowBudgetExceeded, task, workflow, } from "./domain/workflow.js";
|
|
3
3
|
export { agentTask, commandTask, isolatedTask } from "./application/tasks.js";
|
|
4
|
-
export { campaign } from "./application/campaign.js";
|
|
5
|
-
export { beadsBacklog, githubBacklog } from "./providers/backlogs.js";
|
|
6
4
|
export { claude, codex } from "./providers/agents.js";
|
|
7
5
|
export { agentVersions } from "./providers/versions.js";
|
|
8
6
|
export { conversations } from "./infrastructure/conversations.js";
|
|
@@ -10,4 +8,8 @@ export { mountedProvider, remoteProvider } from "./providers/factories.js";
|
|
|
10
8
|
export { ResponseError, response } from "./domain/response.js";
|
|
11
9
|
export { OutpostError, recoveryDetails } from "./domain/errors.js";
|
|
12
10
|
export { reporter } from "./infrastructure/reporter.js";
|
|
11
|
+
export { planRecoveryRetention, pruneRecoveryRetention, assertRecoveryQuota, } from "./application/recovery-retention.js";
|
|
12
|
+
export { verifyRecoveryTransfer } from "./application/recovery-verification.js";
|
|
13
|
+
export { diagnoseSandbox } from "./application/doctor-sandbox.js";
|
|
14
|
+
export { diagnoseAgentProtocol } from "./application/doctor-protocol.js";
|
|
13
15
|
//# sourceMappingURL=index.js.map
|