@elie-laloum/outpost 2.0.0 → 4.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 +42 -0
- package/README.md +3 -1
- package/SECURITY.md +3 -1
- 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/gemini-adapter.d.ts +3 -0
- package/dist/adapters/agents/gemini-adapter.js +15 -0
- package/dist/adapters/agents/gemini-adapter.js.map +1 -0
- package/dist/adapters/agents/gemini-diagnostics.d.ts +2 -0
- package/dist/adapters/agents/gemini-diagnostics.js +15 -0
- package/dist/adapters/agents/gemini-diagnostics.js.map +1 -0
- package/dist/adapters/agents/gemini-events.d.ts +2 -0
- package/dist/adapters/agents/gemini-events.js +50 -0
- package/dist/adapters/agents/gemini-events.js.map +1 -0
- package/dist/adapters/agents/gemini-request.d.ts +4 -0
- package/dist/adapters/agents/gemini-request.js +21 -0
- package/dist/adapters/agents/gemini-request.js.map +1 -0
- package/dist/adapters/agents/gemini.types.d.ts +6 -0
- package/dist/adapters/agents/gemini.types.js +2 -0
- package/dist/adapters/agents/gemini.types.js.map +1 -0
- package/dist/adapters/agents/protocol-fixtures.constants.d.ts +2 -0
- package/dist/adapters/agents/protocol-fixtures.constants.js +105 -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/agent-bootstrap.constants.d.ts +1 -0
- package/dist/application/agent-bootstrap.constants.js +1 -0
- package/dist/application/agent-bootstrap.constants.js.map +1 -1
- package/dist/application/agent-bootstrap.js +6 -2
- package/dist/application/agent-bootstrap.js.map +1 -1
- package/dist/application/agent-output.js +9 -2
- package/dist/application/agent-output.js.map +1 -1
- package/dist/application/artifact-tasks.d.ts +5 -0
- package/dist/application/artifact-tasks.js +31 -0
- package/dist/application/artifact-tasks.js.map +1 -0
- package/dist/application/artifact-tasks.types.d.ts +8 -0
- package/dist/application/artifact-tasks.types.js +2 -0
- package/dist/application/artifact-tasks.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/dispatch-validation.js +2 -0
- package/dist/application/dispatch-validation.js.map +1 -1
- package/dist/application/doctor-agent.constants.d.ts +11 -0
- package/dist/application/doctor-agent.constants.js +10 -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 +30 -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 +4 -0
- package/dist/application/outpost.types.js.map +1 -1
- package/dist/application/queue-worker.d.ts +2 -0
- package/dist/application/queue-worker.js +75 -0
- package/dist/application/queue-worker.js.map +1 -0
- package/dist/application/queue-worker.types.d.ts +15 -0
- package/dist/application/queue-worker.types.js +2 -0
- package/dist/application/queue-worker.types.js.map +1 -0
- package/dist/application/queued-task.d.ts +3 -0
- package/dist/application/queued-task.js +56 -0
- package/dist/application/queued-task.js.map +1 -0
- package/dist/application/queued-task.types.d.ts +11 -0
- package/dist/application/queued-task.types.js +2 -0
- package/dist/application/queued-task.types.js.map +1 -0
- 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 +32 -0
- package/dist/application/recovery-inspection.js.map +1 -0
- package/dist/application/recovery-inspection.types.d.ts +18 -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-restore-snapshot.d.ts +2 -0
- package/dist/application/recovery-restore-snapshot.js +57 -0
- package/dist/application/recovery-restore-snapshot.js.map +1 -0
- package/dist/application/recovery-restore.d.ts +3 -0
- package/dist/application/recovery-restore.js +161 -0
- package/dist/application/recovery-restore.js.map +1 -0
- package/dist/application/recovery-restore.types.d.ts +28 -0
- package/dist/application/recovery-restore.types.js +2 -0
- package/dist/application/recovery-restore.types.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 +207 -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 +3 -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 +30 -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 +38 -6
- package/dist/application/remote-download.js.map +1 -1
- package/dist/application/remote-history.d.ts +6 -0
- package/dist/application/remote-history.js +114 -0
- package/dist/application/remote-history.js.map +1 -0
- package/dist/application/remote-upload.d.ts +2 -0
- package/dist/application/remote-upload.js +17 -0
- package/dist/application/remote-upload.js.map +1 -0
- package/dist/application/remote-validation.js +39 -28
- 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 +10 -10
- 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-activity.d.ts +3 -0
- package/dist/application/sandbox-activity.js +25 -0
- package/dist/application/sandbox-activity.js.map +1 -0
- package/dist/application/sandbox-provision.js +55 -10
- package/dist/application/sandbox-provision.js.map +1 -1
- package/dist/application/sandbox-session.types.d.ts +2 -0
- package/dist/application/sandbox-session.types.js.map +1 -1
- package/dist/application/sandbox.js +33 -10
- package/dist/application/sandbox.js.map +1 -1
- package/dist/application/speculation-host.d.ts +2 -0
- package/dist/application/speculation-host.js +30 -0
- package/dist/application/speculation-host.js.map +1 -0
- package/dist/application/speculation.constants.d.ts +4 -0
- package/dist/application/speculation.constants.js +2 -0
- package/dist/application/speculation.constants.js.map +1 -0
- package/dist/application/speculation.d.ts +2 -0
- package/dist/application/speculation.js +166 -0
- package/dist/application/speculation.js.map +1 -0
- package/dist/application/speculation.types.d.ts +56 -0
- package/dist/application/speculation.types.js +2 -0
- package/dist/application/speculation.types.js.map +1 -0
- package/dist/application/storage-reservation.d.ts +3 -0
- package/dist/application/storage-reservation.js +10 -0
- package/dist/application/storage-reservation.js.map +1 -0
- package/dist/application/storage-reservation.types.d.ts +4 -0
- package/dist/application/storage-reservation.types.js +2 -0
- package/dist/application/storage-reservation.types.js.map +1 -0
- 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/application/tasks.types.d.ts +4 -3
- package/dist/application/tasks.types.js.map +1 -1
- package/dist/application/workspace-allocation.d.ts +3 -0
- package/dist/application/workspace-allocation.js +34 -0
- package/dist/application/workspace-allocation.js.map +1 -0
- package/dist/application/workspace.js +2 -2
- package/dist/application/workspace.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/main.constants.d.ts +38 -2
- package/dist/cli/main.constants.js +21 -2
- package/dist/cli/main.constants.js.map +1 -1
- package/dist/cli/recovery-command.d.ts +2 -0
- package/dist/cli/recovery-command.js +93 -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-restore-command.d.ts +2 -0
- package/dist/cli/recovery-restore-command.js +34 -0
- package/dist/cli/recovery-restore-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.js +2 -2
- package/dist/cli/scaffold-files.js.map +1 -1
- package/dist/cli/scaffold-validation.js +1 -1
- package/dist/cli/scaffold-validation.js.map +1 -1
- package/dist/cli/scaffold.constants.d.ts +5 -0
- package/dist/cli/scaffold.constants.js +7 -2
- package/dist/cli/scaffold.constants.js.map +1 -1
- package/dist/cli/scaffold.types.d.ts +1 -1
- package/dist/cli/scaffold.types.js.map +1 -1
- package/dist/domain/agent.types.d.ts +2 -0
- package/dist/domain/agent.types.js.map +1 -1
- package/dist/domain/artifact-reference.d.ts +4 -0
- package/dist/domain/artifact-reference.js +90 -0
- package/dist/domain/artifact-reference.js.map +1 -0
- package/dist/domain/artifact.constants.d.ts +2 -0
- package/dist/domain/artifact.constants.js +3 -0
- package/dist/domain/artifact.constants.js.map +1 -0
- package/dist/domain/artifact.d.ts +7 -0
- package/dist/domain/artifact.js +104 -0
- package/dist/domain/artifact.js.map +1 -0
- package/dist/domain/artifact.types.d.ts +44 -0
- package/dist/domain/artifact.types.js +2 -0
- package/dist/domain/artifact.types.js.map +1 -0
- package/dist/domain/egress.constants.d.ts +1 -0
- package/dist/domain/egress.constants.js +7 -0
- package/dist/domain/egress.constants.js.map +1 -0
- package/dist/domain/egress.d.ts +2 -0
- package/dist/domain/egress.js +48 -0
- package/dist/domain/egress.js.map +1 -0
- package/dist/domain/egress.types.d.ts +8 -0
- package/dist/domain/egress.types.js +2 -0
- package/dist/domain/egress.types.js.map +1 -0
- package/dist/domain/ports.d.ts +1 -1
- package/dist/domain/ports.js.map +1 -1
- package/dist/domain/sandbox.types.d.ts +13 -0
- package/dist/domain/sandbox.types.js.map +1 -1
- package/dist/domain/task-queue.constants.d.ts +8 -0
- package/dist/domain/task-queue.constants.js +9 -0
- package/dist/domain/task-queue.constants.js.map +1 -0
- package/dist/domain/task-queue.d.ts +11 -0
- package/dist/domain/task-queue.js +105 -0
- package/dist/domain/task-queue.js.map +1 -0
- package/dist/domain/task-queue.types.d.ts +41 -0
- package/dist/domain/task-queue.types.js +2 -0
- package/dist/domain/task-queue.types.js.map +1 -0
- 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 +69 -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/checkpoint-validation.d.ts +3 -0
- package/dist/domain/workflow/checkpoint-validation.js +81 -0
- package/dist/domain/workflow/checkpoint-validation.js.map +1 -0
- package/dist/domain/workflow/checkpoint-value.d.ts +2 -0
- package/dist/domain/workflow/checkpoint-value.js +49 -0
- package/dist/domain/workflow/checkpoint-value.js.map +1 -0
- package/dist/domain/workflow/checkpoint.d.ts +3 -0
- package/dist/domain/workflow/checkpoint.js +70 -0
- package/dist/domain/workflow/checkpoint.js.map +1 -0
- package/dist/domain/workflow/checkpoint.types.d.ts +40 -0
- package/dist/domain/workflow/checkpoint.types.js +2 -0
- package/dist/domain/workflow/checkpoint.types.js.map +1 -0
- package/dist/domain/workflow/gate-validation.d.ts +4 -0
- package/dist/domain/workflow/gate-validation.js +71 -0
- package/dist/domain/workflow/gate-validation.js.map +1 -0
- package/dist/domain/workflow/gates.constants.d.ts +4 -0
- package/dist/domain/workflow/gates.constants.js +5 -0
- package/dist/domain/workflow/gates.constants.js.map +1 -0
- package/dist/domain/workflow/gates.d.ts +7 -0
- package/dist/domain/workflow/gates.js +85 -0
- package/dist/domain/workflow/gates.js.map +1 -0
- package/dist/domain/workflow/gates.types.d.ts +27 -0
- package/dist/domain/workflow/gates.types.js +2 -0
- package/dist/domain/workflow/gates.types.js.map +1 -0
- package/dist/domain/workflow/task-runner.js +22 -3
- package/dist/domain/workflow/task-runner.js.map +1 -1
- package/dist/domain/workflow/usage-receipt.constants.d.ts +2 -0
- package/dist/domain/workflow/usage-receipt.constants.js +3 -0
- package/dist/domain/workflow/usage-receipt.constants.js.map +1 -0
- package/dist/domain/workflow/usage-receipt.d.ts +2 -0
- package/dist/domain/workflow/usage-receipt.js +18 -0
- package/dist/domain/workflow/usage-receipt.js.map +1 -0
- package/dist/domain/workflow/validation.js +6 -0
- package/dist/domain/workflow/validation.js.map +1 -1
- package/dist/domain/workflow/workflow-scheduler.js +68 -33
- package/dist/domain/workflow/workflow-scheduler.js.map +1 -1
- package/dist/domain/workflow/workflow-state.d.ts +2 -1
- package/dist/domain/workflow/workflow-state.js +107 -3
- 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 +23 -3
- package/dist/domain/workflow.types.js.map +1 -1
- package/dist/index.d.ts +44 -5
- package/dist/index.js +19 -2
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/artifact-store.constants.d.ts +1 -0
- package/dist/infrastructure/artifact-store.constants.js +2 -0
- package/dist/infrastructure/artifact-store.constants.js.map +1 -0
- package/dist/infrastructure/artifact-store.d.ts +3 -0
- package/dist/infrastructure/artifact-store.js +100 -0
- package/dist/infrastructure/artifact-store.js.map +1 -0
- package/dist/infrastructure/artifact-store.types.d.ts +4 -0
- package/dist/infrastructure/artifact-store.types.js +2 -0
- package/dist/infrastructure/artifact-store.types.js.map +1 -0
- package/dist/infrastructure/file-manifest.d.ts +6 -0
- package/dist/infrastructure/file-manifest.js +92 -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 +37 -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/resource-activity-inspection.d.ts +2 -0
- package/dist/infrastructure/resource-activity-inspection.js +152 -0
- package/dist/infrastructure/resource-activity-inspection.js.map +1 -0
- package/dist/infrastructure/resource-activity.constants.d.ts +8 -0
- package/dist/infrastructure/resource-activity.constants.js +26 -0
- package/dist/infrastructure/resource-activity.constants.js.map +1 -0
- package/dist/infrastructure/resource-activity.d.ts +2 -0
- package/dist/infrastructure/resource-activity.js +166 -0
- package/dist/infrastructure/resource-activity.js.map +1 -0
- package/dist/infrastructure/resource-activity.types.d.ts +53 -0
- package/dist/infrastructure/resource-activity.types.js +2 -0
- package/dist/infrastructure/resource-activity.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/storage-mutation-lock.constants.d.ts +5 -0
- package/dist/infrastructure/storage-mutation-lock.constants.js +6 -0
- package/dist/infrastructure/storage-mutation-lock.constants.js.map +1 -0
- package/dist/infrastructure/storage-mutation-lock.d.ts +1 -0
- package/dist/infrastructure/storage-mutation-lock.js +21 -0
- package/dist/infrastructure/storage-mutation-lock.js.map +1 -0
- package/dist/infrastructure/storage-reservations.constants.d.ts +4 -0
- package/dist/infrastructure/storage-reservations.constants.js +5 -0
- package/dist/infrastructure/storage-reservations.constants.js.map +1 -0
- package/dist/infrastructure/storage-reservations.d.ts +2 -0
- package/dist/infrastructure/storage-reservations.js +150 -0
- package/dist/infrastructure/storage-reservations.js.map +1 -0
- package/dist/infrastructure/storage-reservations.types.d.ts +21 -0
- package/dist/infrastructure/storage-reservations.types.js +2 -0
- package/dist/infrastructure/storage-reservations.types.js.map +1 -0
- package/dist/infrastructure/task-queue-http.constants.d.ts +2 -0
- package/dist/infrastructure/task-queue-http.constants.js +3 -0
- package/dist/infrastructure/task-queue-http.constants.js.map +1 -0
- package/dist/infrastructure/task-queue-http.d.ts +4 -0
- package/dist/infrastructure/task-queue-http.js +158 -0
- package/dist/infrastructure/task-queue-http.js.map +1 -0
- package/dist/infrastructure/task-queue-http.types.d.ts +16 -0
- package/dist/infrastructure/task-queue-http.types.js +2 -0
- package/dist/infrastructure/task-queue-http.types.js.map +1 -0
- package/dist/infrastructure/task-queue.d.ts +2 -0
- package/dist/infrastructure/task-queue.js +134 -0
- package/dist/infrastructure/task-queue.js.map +1 -0
- package/dist/infrastructure/transfer.js +17 -0
- package/dist/infrastructure/transfer.js.map +1 -1
- package/dist/infrastructure/workflow-checkpoint.constants.d.ts +1 -0
- package/dist/infrastructure/workflow-checkpoint.constants.js +2 -0
- package/dist/infrastructure/workflow-checkpoint.constants.js.map +1 -0
- package/dist/infrastructure/workflow-checkpoint.d.ts +3 -0
- package/dist/infrastructure/workflow-checkpoint.js +77 -0
- package/dist/infrastructure/workflow-checkpoint.js.map +1 -0
- package/dist/infrastructure/workflow-checkpoint.types.d.ts +4 -0
- package/dist/infrastructure/workflow-checkpoint.types.js +2 -0
- package/dist/infrastructure/workflow-checkpoint.types.js.map +1 -0
- package/dist/providers/agents.d.ts +2 -0
- package/dist/providers/agents.js +1 -0
- package/dist/providers/agents.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-isolation.d.ts +2 -0
- package/dist/providers/container-isolation.js +29 -0
- package/dist/providers/container-isolation.js.map +1 -0
- package/dist/providers/container-mounts.js +7 -2
- package/dist/providers/container-mounts.js.map +1 -1
- package/dist/providers/container-network.d.ts +2 -0
- package/dist/providers/container-network.js +14 -0
- package/dist/providers/container-network.js.map +1 -0
- package/dist/providers/container-plan.js +6 -2
- package/dist/providers/container-plan.js.map +1 -1
- package/dist/providers/container.constants.d.ts +1 -0
- package/dist/providers/container.constants.js +1 -0
- package/dist/providers/container.constants.js.map +1 -1
- package/dist/providers/container.js +50 -3
- package/dist/providers/container.js.map +1 -1
- package/dist/providers/container.types.d.ts +5 -0
- package/dist/providers/container.types.js.map +1 -1
- package/dist/providers/daytona-command.js +10 -6
- package/dist/providers/daytona-command.js.map +1 -1
- package/dist/providers/daytona-terminal.d.ts +3 -0
- package/dist/providers/daytona-terminal.js +128 -0
- package/dist/providers/daytona-terminal.js.map +1 -0
- package/dist/providers/daytona.js +15 -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 +2 -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 +160 -0
- package/dist/providers/file-batches.js.map +1 -0
- package/dist/providers/file-upload.constants.d.ts +1 -0
- package/dist/providers/file-upload.constants.js +68 -0
- package/dist/providers/file-upload.constants.js.map +1 -0
- package/dist/providers/file-upload.d.ts +2 -0
- package/dist/providers/file-upload.js +146 -0
- package/dist/providers/file-upload.js.map +1 -0
- package/dist/providers/firecracker-command.d.ts +5 -0
- package/dist/providers/firecracker-command.js +114 -0
- package/dist/providers/firecracker-command.js.map +1 -0
- package/dist/providers/firecracker-files.constants.d.ts +1 -0
- package/dist/providers/firecracker-files.constants.js +21 -0
- package/dist/providers/firecracker-files.constants.js.map +1 -0
- package/dist/providers/firecracker-files.d.ts +3 -0
- package/dist/providers/firecracker-files.js +110 -0
- package/dist/providers/firecracker-files.js.map +1 -0
- package/dist/providers/firecracker-machine.d.ts +3 -0
- package/dist/providers/firecracker-machine.js +155 -0
- package/dist/providers/firecracker-machine.js.map +1 -0
- package/dist/providers/firecracker.constants.d.ts +10 -0
- package/dist/providers/firecracker.constants.js +11 -0
- package/dist/providers/firecracker.constants.js.map +1 -0
- package/dist/providers/firecracker.d.ts +4 -0
- package/dist/providers/firecracker.js +103 -0
- package/dist/providers/firecracker.js.map +1 -0
- package/dist/providers/firecracker.types.d.ts +36 -0
- package/dist/providers/firecracker.types.js +2 -0
- package/dist/providers/firecracker.types.js.map +1 -0
- package/dist/providers/local.js +2 -1
- package/dist/providers/local.js.map +1 -1
- package/dist/providers/podman.d.ts +2 -0
- package/dist/providers/podman.js.map +1 -1
- package/dist/providers/terminal-bridge.d.ts +14 -0
- package/dist/providers/terminal-bridge.js +100 -0
- package/dist/providers/terminal-bridge.js.map +1 -0
- package/dist/providers/vercel-directory.d.ts +2 -0
- package/dist/providers/vercel-directory.js +7 -0
- package/dist/providers/vercel-directory.js.map +1 -0
- package/dist/providers/vercel-files.js +3 -2
- package/dist/providers/vercel-files.js.map +1 -1
- package/dist/providers/vercel-network.d.ts +2 -0
- package/dist/providers/vercel-network.js +18 -0
- package/dist/providers/vercel-network.js.map +1 -0
- package/dist/providers/vercel.d.ts +1 -0
- package/dist/providers/vercel.js +8 -2
- package/dist/providers/vercel.js.map +1 -1
- package/dist/providers/vercel.types.d.ts +2 -0
- package/dist/providers/vercel.types.js.map +1 -1
- package/dist/providers/versions.constants.d.ts +1 -0
- package/dist/providers/versions.constants.js +1 -0
- package/dist/providers/versions.constants.js.map +1 -1
- package/package.json +16 -1
|
@@ -1 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AAC,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,14 @@
|
|
|
1
|
+
import type { WorkflowDecision, WorkflowDecisionRecord, WorkflowGate, WorkflowPauseRequest } from "./workflow/gates.types.ts";
|
|
2
|
+
import type { WorkflowCheckpointOptions } from "./workflow/checkpoint.types.ts";
|
|
3
|
+
import type { Usage } from "./agent.types.ts";
|
|
4
|
+
import type { WorkflowAccounting, WorkflowBudget, WorkflowUsage } from "./workflow/budget.types.ts";
|
|
1
5
|
export interface TaskContext {
|
|
2
6
|
readonly signal: AbortSignal;
|
|
3
7
|
readonly attempt: number;
|
|
4
8
|
readonly executionId: string;
|
|
9
|
+
reportUsage(usage: Usage): void;
|
|
10
|
+
reportUsageOnce?(receipt: string, usage: Usage): void;
|
|
11
|
+
checkpoint?(): Promise<void>;
|
|
5
12
|
value<T>(dependency: Task<T>): T;
|
|
6
13
|
}
|
|
7
14
|
export interface Retry {
|
|
@@ -11,6 +18,7 @@ export interface Retry {
|
|
|
11
18
|
}
|
|
12
19
|
export interface Task<T = unknown> {
|
|
13
20
|
readonly key: string;
|
|
21
|
+
readonly gate?: WorkflowGate;
|
|
14
22
|
readonly after: readonly Task[];
|
|
15
23
|
readonly perform: (context: TaskContext) => T | Promise<T>;
|
|
16
24
|
readonly condition?: (context: TaskContext) => boolean | Promise<boolean>;
|
|
@@ -20,8 +28,11 @@ export interface Task<T = unknown> {
|
|
|
20
28
|
export type TaskOptions<T> = Omit<Task<T>, "after"> & {
|
|
21
29
|
readonly after?: readonly Task[];
|
|
22
30
|
};
|
|
23
|
-
export type TaskStatus = "waiting" | "active" | "done" | "failed" | "skipped" | "cancelled";
|
|
31
|
+
export type TaskStatus = "waiting" | "active" | "done" | "failed" | "skipped" | "cancelled" | "paused" | "rejected";
|
|
24
32
|
export interface TaskRecord {
|
|
33
|
+
usageReceipts?: readonly string[];
|
|
34
|
+
pause?: WorkflowPauseRequest;
|
|
35
|
+
decision?: WorkflowDecisionRecord;
|
|
25
36
|
readonly key: string;
|
|
26
37
|
status: TaskStatus;
|
|
27
38
|
attempts: number;
|
|
@@ -33,24 +44,30 @@ export interface WorkflowEvent {
|
|
|
33
44
|
readonly executionId: string;
|
|
34
45
|
readonly workflow: string;
|
|
35
46
|
readonly timestamp: string;
|
|
36
|
-
readonly type: "start" | "task" | "retry" | "finish";
|
|
47
|
+
readonly type: "start" | "task" | "attempt" | "retry" | "usage" | "finish";
|
|
37
48
|
readonly key?: string;
|
|
38
49
|
readonly status?: TaskStatus;
|
|
39
50
|
readonly attempt?: number;
|
|
51
|
+
readonly usage?: Usage;
|
|
52
|
+
readonly durationMs?: number;
|
|
40
53
|
}
|
|
41
54
|
export interface WorkflowOptions {
|
|
55
|
+
readonly decisions?: readonly WorkflowDecision[];
|
|
56
|
+
readonly checkpoint?: WorkflowCheckpointOptions;
|
|
42
57
|
readonly signal?: AbortSignal;
|
|
43
58
|
readonly concurrency?: number;
|
|
59
|
+
readonly budget?: WorkflowBudget;
|
|
44
60
|
readonly stopOnError?: boolean;
|
|
45
61
|
readonly observe?: (event: WorkflowEvent) => void;
|
|
46
62
|
}
|
|
47
63
|
export interface WorkflowResult {
|
|
48
64
|
readonly executionId: string;
|
|
49
65
|
readonly name: string;
|
|
50
|
-
readonly status: "done" | "failed" | "cancelled";
|
|
66
|
+
readonly status: "done" | "failed" | "cancelled" | "paused";
|
|
51
67
|
readonly tasks: readonly Readonly<TaskRecord>[];
|
|
52
68
|
readonly errors: readonly unknown[];
|
|
53
69
|
readonly observerErrors: readonly unknown[];
|
|
70
|
+
readonly usage: WorkflowUsage;
|
|
54
71
|
value<T>(task: Task<T>): T;
|
|
55
72
|
unwrap(): void;
|
|
56
73
|
}
|
|
@@ -70,6 +87,9 @@ export interface WorkflowExecutionState {
|
|
|
70
87
|
readonly errors: unknown[];
|
|
71
88
|
readonly observerErrors: unknown[];
|
|
72
89
|
readonly options: WorkflowOptions;
|
|
90
|
+
readonly accounting: WorkflowAccounting;
|
|
91
|
+
persist(): Promise<void>;
|
|
92
|
+
closeAttempt(task: Task): void;
|
|
73
93
|
record(task: Task): TaskRecord;
|
|
74
94
|
emit(event: WorkflowNotification): void;
|
|
75
95
|
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 {\n WorkflowDecision,\n WorkflowDecisionRecord,\n WorkflowGate,\n WorkflowPauseRequest,\n} from \"./workflow/gates.types.ts\";\nimport type { WorkflowCheckpointOptions } from \"./workflow/checkpoint.types.ts\";\nimport 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 reportUsageOnce?(receipt: string, usage: Usage): void;\n checkpoint?(): Promise<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 gate?: WorkflowGate;\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\"\n | \"active\"\n | \"done\"\n | \"failed\"\n | \"skipped\"\n | \"cancelled\"\n | \"paused\"\n | \"rejected\";\n\nexport interface TaskRecord {\n usageReceipts?: readonly string[];\n pause?: WorkflowPauseRequest;\n decision?: WorkflowDecisionRecord;\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 decisions?: readonly WorkflowDecision[];\n readonly checkpoint?: WorkflowCheckpointOptions;\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\" | \"paused\";\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 persist(): Promise<void>;\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,22 +1,61 @@
|
|
|
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 { claude, codex } from "./providers/agents.ts";
|
|
7
|
+
export { claude, codex, gemini } from "./providers/agents.ts";
|
|
8
8
|
export { agentVersions } from "./providers/versions.ts";
|
|
9
9
|
export { conversations } from "./infrastructure/conversations.ts";
|
|
10
10
|
export type { ConversationFormat, ConversationLocation, } from "./infrastructure/conversations.ts";
|
|
11
|
-
export type { ClaudeSettings, CodexSettings } from "./providers/agents.ts";
|
|
11
|
+
export type { ClaudeSettings, CodexSettings, GeminiSettings, } from "./providers/agents.ts";
|
|
12
12
|
export { mountedProvider, remoteProvider } from "./providers/factories.ts";
|
|
13
13
|
export { ResponseError, response } from "./domain/response.ts";
|
|
14
14
|
export type { ResponseSpec, StandardValidator } from "./domain/response.ts";
|
|
15
15
|
export { OutpostError, recoveryDetails } from "./domain/errors.ts";
|
|
16
16
|
export type { FaultCode } from "./domain/errors.ts";
|
|
17
|
-
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";
|
|
18
18
|
export type { Brief, PromptVariables } from "./domain/prompts.ts";
|
|
19
19
|
export type { Logging } from "./infrastructure/journal.ts";
|
|
20
20
|
export { reporter } from "./infrastructure/reporter.ts";
|
|
21
21
|
export type { ReporterOptions } from "./infrastructure/reporter.ts";
|
|
22
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";
|
|
32
|
+
export { reserveRecoveryStorage } from "./application/storage-reservation.ts";
|
|
33
|
+
export type { RecoveryStorageReservationOptions } from "./application/storage-reservation.types.ts";
|
|
34
|
+
export type { StorageReservation, StorageReservationOptions, } from "./infrastructure/storage-reservations.types.ts";
|
|
35
|
+
export { planRecoveryRestore, restoreRecoveryTransfer, } from "./application/recovery-restore.ts";
|
|
36
|
+
export type { RecoveryRestoreOptions, RecoveryRestorePlan, RecoveryRestoreResult, } from "./application/recovery-restore.types.ts";
|
|
37
|
+
export { fileWorkflowCheckpointStore } from "./infrastructure/workflow-checkpoint.ts";
|
|
38
|
+
export type { FileWorkflowCheckpointOptions } from "./infrastructure/workflow-checkpoint.types.ts";
|
|
39
|
+
export type { WorkflowCheckpoint, WorkflowCheckpointOptions, WorkflowCheckpointStore, WorkflowCheckpointLease, WorkflowCheckpointValue, WorkflowJson, } from "./domain/workflow/checkpoint.types.ts";
|
|
40
|
+
export { approvalTask, pauseTask } from "./domain/workflow/gates.ts";
|
|
41
|
+
export type { WorkflowGate, WorkflowGateOptions, WorkflowPauseRequest, WorkflowDecision, WorkflowDecisionRecord, } from "./domain/workflow/gates.types.ts";
|
|
42
|
+
export { inspectRecovery } from "./application/recovery-inspection.ts";
|
|
43
|
+
export type { RecoveryInspection, RecoveryInspectionOptions, } from "./application/recovery-inspection.types.ts";
|
|
44
|
+
export type { ResourceActivityRecord, ResourceInspection, ResourceInspectionEntry, ResourceOperation, ResourceOperationKind, ResourceOperationResult, ResourcePhase, } from "./infrastructure/resource-activity.types.ts";
|
|
45
|
+
export { artifact, publishArtifact, readStoredArtifact, } from "./domain/artifact.ts";
|
|
46
|
+
export { artifactTask, readArtifact } from "./application/artifact-tasks.ts";
|
|
47
|
+
export { fileArtifactStore } from "./infrastructure/artifact-store.ts";
|
|
48
|
+
export type { ArtifactContract, ArtifactContractOptions, ArtifactIdentity, ArtifactProducer, ArtifactReference, ArtifactStore, JsonArtifactOptions, PublishArtifactOptions, ReadArtifactOptions, } from "./domain/artifact.types.ts";
|
|
49
|
+
export type { ArtifactTaskOptions } from "./application/artifact-tasks.types.ts";
|
|
50
|
+
export type { FileArtifactStoreOptions } from "./infrastructure/artifact-store.types.ts";
|
|
51
|
+
export { sqliteTaskQueue } from "./infrastructure/task-queue.ts";
|
|
52
|
+
export { serveTaskQueue, httpTaskQueue, } from "./infrastructure/task-queue-http.ts";
|
|
53
|
+
export { runQueueWorker } from "./application/queue-worker.ts";
|
|
54
|
+
export { queuedTask } from "./application/queued-task.ts";
|
|
55
|
+
export type { QueueRequest, QueueResult, QueueJob, QueueClaim, QueueLease, TaskQueue, DurableTaskQueue, } from "./domain/task-queue.types.ts";
|
|
56
|
+
export type { QueueServerOptions, QueueServer, QueueClientOptions, } from "./infrastructure/task-queue-http.types.ts";
|
|
57
|
+
export type { QueueHandlerContext, QueueHandler, QueueWorkerOptions, } from "./application/queue-worker.types.ts";
|
|
58
|
+
export type { QueuedTaskOptions } from "./application/queued-task.types.ts";
|
|
59
|
+
export type { EgressPolicy } from "./domain/egress.types.ts";
|
|
60
|
+
export { speculate } from "./application/speculation.ts";
|
|
61
|
+
export type { SpeculationOptions, SpeculationResult, SpeculativeCandidate, SpeculativeCandidateResult, SpeculativeOutput, SpeculativeHostSnapshot, SpeculativeValidation, } from "./application/speculation.types.ts";
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,28 @@
|
|
|
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 { claude, codex } from "./providers/agents.js";
|
|
4
|
+
export { claude, codex, gemini } from "./providers/agents.js";
|
|
5
5
|
export { agentVersions } from "./providers/versions.js";
|
|
6
6
|
export { conversations } from "./infrastructure/conversations.js";
|
|
7
7
|
export { mountedProvider, remoteProvider } from "./providers/factories.js";
|
|
8
8
|
export { ResponseError, response } from "./domain/response.js";
|
|
9
9
|
export { OutpostError, recoveryDetails } from "./domain/errors.js";
|
|
10
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";
|
|
15
|
+
export { reserveRecoveryStorage } from "./application/storage-reservation.js";
|
|
16
|
+
export { planRecoveryRestore, restoreRecoveryTransfer, } from "./application/recovery-restore.js";
|
|
17
|
+
export { fileWorkflowCheckpointStore } from "./infrastructure/workflow-checkpoint.js";
|
|
18
|
+
export { approvalTask, pauseTask } from "./domain/workflow/gates.js";
|
|
19
|
+
export { inspectRecovery } from "./application/recovery-inspection.js";
|
|
20
|
+
export { artifact, publishArtifact, readStoredArtifact, } from "./domain/artifact.js";
|
|
21
|
+
export { artifactTask, readArtifact } from "./application/artifact-tasks.js";
|
|
22
|
+
export { fileArtifactStore } from "./infrastructure/artifact-store.js";
|
|
23
|
+
export { sqliteTaskQueue } from "./infrastructure/task-queue.js";
|
|
24
|
+
export { serveTaskQueue, httpTaskQueue, } from "./infrastructure/task-queue-http.js";
|
|
25
|
+
export { runQueueWorker } from "./application/queue-worker.js";
|
|
26
|
+
export { queuedTask } from "./application/queued-task.js";
|
|
27
|
+
export { speculate } from "./application/speculation.js";
|
|
11
28
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,aAAa,EACb,QAAQ,EACR,aAAa,GACd,MAAM,0BAA0B,CAAC;AAoBlC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,aAAa,EACb,QAAQ,EACR,aAAa,GACd,MAAM,0BAA0B,CAAC;AAoBlC,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,IAAI,EACJ,QAAQ,GACT,MAAM,sBAAsB,CAAC;AAiB9B,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE9E,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAalE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE3E,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAI/D,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAoCnE,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAMxD,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,qCAAqC,CAAC;AAS7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAMhF,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAWlE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAGzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAO9E,OAAO,EACL,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,mCAAmC,CAAC;AAO3C,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AAWtF,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AASrE,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAevE,OAAO,EACL,QAAQ,EACR,eAAe,EACf,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAevE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EACL,cAAc,EACd,aAAa,GACd,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAwB1D,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC","sourcesContent":["export {\n attach,\n createSandbox,\n dispatch,\n openWorkspace,\n} from \"./application/outpost.ts\";\n\nexport type {\n AttachOptions,\n AttachResult,\n ContinuationOptions,\n DispatchResult,\n Sandbox,\n SandboxOptions,\n WarmDispatchResult,\n Workspace,\n WorkspaceOptions,\n} from \"./application/outpost.ts\";\n\nexport type {\n DispatchOptions,\n Execution,\n Turn,\n} from \"./application/execution.ts\";\n\nexport {\n WorkflowFailure,\n WorkflowBudgetExceeded,\n task,\n workflow,\n} from \"./domain/workflow.ts\";\n\nexport type {\n Retry,\n Task,\n TaskContext,\n TaskOptions,\n TaskRecord,\n TaskStatus,\n Workflow,\n WorkflowEvent,\n WorkflowOptions,\n WorkflowBudget,\n WorkflowUsage,\n WorkflowResult,\n} from \"./domain/workflow.ts\";\n\nexport { agentTask, commandTask, isolatedTask } from \"./application/tasks.ts\";\n\nexport { claude, codex, gemini } from \"./providers/agents.ts\";\n\nexport { agentVersions } from \"./providers/versions.ts\";\n\nexport { conversations } from \"./infrastructure/conversations.ts\";\n\nexport type {\n ConversationFormat,\n ConversationLocation,\n} from \"./infrastructure/conversations.ts\";\n\nexport type {\n ClaudeSettings,\n CodexSettings,\n GeminiSettings,\n} from \"./providers/agents.ts\";\n\nexport { mountedProvider, remoteProvider } from \"./providers/factories.ts\";\n\nexport { ResponseError, response } from \"./domain/response.ts\";\n\nexport type { ResponseSpec, StandardValidator } from \"./domain/response.ts\";\n\nexport { OutpostError, recoveryDetails } from \"./domain/errors.ts\";\n\nexport type { FaultCode } from \"./domain/errors.ts\";\n\nexport type {\n AgentAdapter,\n AgentEvent,\n AgentInput,\n AgentObservation,\n BranchPolicy,\n Channel,\n Command,\n CommandResult,\n Commit,\n ConversationContext,\n ConversationRecord,\n ConversationStore,\n Disposal,\n LifecycleHooks,\n FileManifestEntry,\n FileTransfers,\n SandboxContext,\n SandboxLease,\n SandboxProvider,\n StageLimits,\n TransferOptions,\n Usage,\n Variables,\n Volume,\n WorkspaceRecord,\n} from \"./domain/ports.ts\";\n\nexport type { Brief, PromptVariables } from \"./domain/prompts.ts\";\n\nexport type { Logging } from \"./infrastructure/journal.ts\";\n\nexport { reporter } from \"./infrastructure/reporter.ts\";\n\nexport type { ReporterOptions } from \"./infrastructure/reporter.ts\";\n\nexport type { VariableQuestion } from \"./application/interactive-brief.ts\";\n\nexport {\n planRecoveryRetention,\n pruneRecoveryRetention,\n assertRecoveryQuota,\n} from \"./application/recovery-retention.ts\";\nexport type {\n RecoveryRetentionPolicy,\n RecoveryRetentionOptions,\n RecoveryRetentionPlan,\n RecoveryRetentionEntry,\n RecoveryPruneResult,\n RecoveryQuotaOptions,\n} from \"./application/recovery-retention.types.ts\";\nexport { verifyRecoveryTransfer } from \"./application/recovery-verification.ts\";\nexport type {\n RecoveryVerification,\n RecoveryVerificationOptions,\n} from \"./application/recovery-verification.types.ts\";\n\nexport { diagnoseSandbox } from \"./application/doctor-sandbox.ts\";\nexport type {\n SandboxDiagnosticOptions,\n SandboxDiagnosticReport,\n DiagnosticCapability,\n} from \"./application/doctor-sandbox.types.ts\";\nexport type {\n DiagnosticCheck,\n DiagnosticStatus,\n DoctorAgent,\n} from \"./application/doctor.types.ts\";\nexport { diagnoseAgentProtocol } from \"./application/doctor-protocol.ts\";\nexport type { AgentProtocolReport } from \"./application/doctor-protocol.types.ts\";\n\nexport { reserveRecoveryStorage } from \"./application/storage-reservation.ts\";\nexport type { RecoveryStorageReservationOptions } from \"./application/storage-reservation.types.ts\";\nexport type {\n StorageReservation,\n StorageReservationOptions,\n} from \"./infrastructure/storage-reservations.types.ts\";\n\nexport {\n planRecoveryRestore,\n restoreRecoveryTransfer,\n} from \"./application/recovery-restore.ts\";\nexport type {\n RecoveryRestoreOptions,\n RecoveryRestorePlan,\n RecoveryRestoreResult,\n} from \"./application/recovery-restore.types.ts\";\n\nexport { fileWorkflowCheckpointStore } from \"./infrastructure/workflow-checkpoint.ts\";\nexport type { FileWorkflowCheckpointOptions } from \"./infrastructure/workflow-checkpoint.types.ts\";\nexport type {\n WorkflowCheckpoint,\n WorkflowCheckpointOptions,\n WorkflowCheckpointStore,\n WorkflowCheckpointLease,\n WorkflowCheckpointValue,\n WorkflowJson,\n} from \"./domain/workflow/checkpoint.types.ts\";\n\nexport { approvalTask, pauseTask } from \"./domain/workflow/gates.ts\";\nexport type {\n WorkflowGate,\n WorkflowGateOptions,\n WorkflowPauseRequest,\n WorkflowDecision,\n WorkflowDecisionRecord,\n} from \"./domain/workflow/gates.types.ts\";\n\nexport { inspectRecovery } from \"./application/recovery-inspection.ts\";\nexport type {\n RecoveryInspection,\n RecoveryInspectionOptions,\n} from \"./application/recovery-inspection.types.ts\";\nexport type {\n ResourceActivityRecord,\n ResourceInspection,\n ResourceInspectionEntry,\n ResourceOperation,\n ResourceOperationKind,\n ResourceOperationResult,\n ResourcePhase,\n} from \"./infrastructure/resource-activity.types.ts\";\n\nexport {\n artifact,\n publishArtifact,\n readStoredArtifact,\n} from \"./domain/artifact.ts\";\nexport { artifactTask, readArtifact } from \"./application/artifact-tasks.ts\";\nexport { fileArtifactStore } from \"./infrastructure/artifact-store.ts\";\nexport type {\n ArtifactContract,\n ArtifactContractOptions,\n ArtifactIdentity,\n ArtifactProducer,\n ArtifactReference,\n ArtifactStore,\n JsonArtifactOptions,\n PublishArtifactOptions,\n ReadArtifactOptions,\n} from \"./domain/artifact.types.ts\";\nexport type { ArtifactTaskOptions } from \"./application/artifact-tasks.types.ts\";\nexport type { FileArtifactStoreOptions } from \"./infrastructure/artifact-store.types.ts\";\n\nexport { sqliteTaskQueue } from \"./infrastructure/task-queue.ts\";\nexport {\n serveTaskQueue,\n httpTaskQueue,\n} from \"./infrastructure/task-queue-http.ts\";\nexport { runQueueWorker } from \"./application/queue-worker.ts\";\nexport { queuedTask } from \"./application/queued-task.ts\";\nexport type {\n QueueRequest,\n QueueResult,\n QueueJob,\n QueueClaim,\n QueueLease,\n TaskQueue,\n DurableTaskQueue,\n} from \"./domain/task-queue.types.ts\";\nexport type {\n QueueServerOptions,\n QueueServer,\n QueueClientOptions,\n} from \"./infrastructure/task-queue-http.types.ts\";\nexport type {\n QueueHandlerContext,\n QueueHandler,\n QueueWorkerOptions,\n} from \"./application/queue-worker.types.ts\";\nexport type { QueuedTaskOptions } from \"./application/queued-task.types.ts\";\n\nexport type { EgressPolicy } from \"./domain/egress.types.ts\";\n\nexport { speculate } from \"./application/speculation.ts\";\nexport type {\n SpeculationOptions,\n SpeculationResult,\n SpeculativeCandidate,\n SpeculativeCandidateResult,\n SpeculativeOutput,\n SpeculativeHostSnapshot,\n SpeculativeValidation,\n} from \"./application/speculation.types.ts\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const artifactMaxBytes: number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifact-store.constants.js","sourceRoot":"","sources":["../../src/infrastructure/artifact-store.constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC","sourcesContent":["export const artifactMaxBytes = 16 * 1024 * 1024;\n"]}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { artifactDigestPattern } from "../domain/artifact.constants.js";
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
import { link, lstat, mkdir, open, rm } from "node:fs/promises";
|
|
4
|
+
import { dirname, join, resolve } from "node:path";
|
|
5
|
+
import { readInspectionFile } from "./inspection-file.js";
|
|
6
|
+
import { artifactMaxBytes } from "./artifact-store.constants.js";
|
|
7
|
+
async function directory(path) {
|
|
8
|
+
const parent = dirname(path);
|
|
9
|
+
if (parent !== path) {
|
|
10
|
+
await directory(parent);
|
|
11
|
+
try {
|
|
12
|
+
await mkdir(path, { mode: 0o700 });
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
if (!code(error, "EEXIST"))
|
|
16
|
+
throw error;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
if (!(await lstat(path)).isDirectory())
|
|
20
|
+
throw new Error("Artifact directory must not contain symlinks");
|
|
21
|
+
}
|
|
22
|
+
function code(error, expected) {
|
|
23
|
+
return (!!error &&
|
|
24
|
+
typeof error === "object" &&
|
|
25
|
+
"code" in error &&
|
|
26
|
+
error.code === expected);
|
|
27
|
+
}
|
|
28
|
+
async function readArtifactFile(path, maxBytes) {
|
|
29
|
+
try {
|
|
30
|
+
return await readInspectionFile(path, maxBytes);
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
if (!(error instanceof Error) ||
|
|
34
|
+
error.message !== "Inspection file changed")
|
|
35
|
+
throw error;
|
|
36
|
+
// Removing the staging hard link can change ctime once after publication.
|
|
37
|
+
return readInspectionFile(path, maxBytes);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export function fileArtifactStore(options) {
|
|
41
|
+
const root = resolve(options.directory), maxBytes = options.maxBytes ?? artifactMaxBytes;
|
|
42
|
+
if (!Number.isSafeInteger(maxBytes) || maxBytes < 1)
|
|
43
|
+
throw new Error("Artifact maxBytes must be a positive safe integer");
|
|
44
|
+
const path = (id) => {
|
|
45
|
+
if (!artifactDigestPattern.test(id))
|
|
46
|
+
throw new Error("Invalid artifact storage ID");
|
|
47
|
+
return join(root, `${id}.blob`);
|
|
48
|
+
};
|
|
49
|
+
return {
|
|
50
|
+
async put(id, input, signal) {
|
|
51
|
+
signal?.throwIfAborted();
|
|
52
|
+
const target = path(id);
|
|
53
|
+
if (input.byteLength > maxBytes)
|
|
54
|
+
throw new Error("Artifact exceeds maxBytes");
|
|
55
|
+
const bytes = Buffer.from(input);
|
|
56
|
+
await directory(root);
|
|
57
|
+
const temporary = join(root, `.${randomUUID()}.tmp`);
|
|
58
|
+
try {
|
|
59
|
+
const file = await open(temporary, "wx", 0o600);
|
|
60
|
+
try {
|
|
61
|
+
await file.writeFile(bytes, signal ? { signal } : {});
|
|
62
|
+
await file.sync();
|
|
63
|
+
}
|
|
64
|
+
finally {
|
|
65
|
+
await file.close();
|
|
66
|
+
}
|
|
67
|
+
signal?.throwIfAborted();
|
|
68
|
+
try {
|
|
69
|
+
await link(temporary, target);
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
if (!code(error, "EEXIST"))
|
|
73
|
+
throw error;
|
|
74
|
+
if (!bytes.equals(await readArtifactFile(target, maxBytes)))
|
|
75
|
+
throw new Error("Existing artifact content integrity mismatch");
|
|
76
|
+
}
|
|
77
|
+
if (process.platform !== "win32") {
|
|
78
|
+
const parent = await open(root, "r");
|
|
79
|
+
try {
|
|
80
|
+
await parent.sync();
|
|
81
|
+
}
|
|
82
|
+
finally {
|
|
83
|
+
await parent.close();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
finally {
|
|
88
|
+
await rm(temporary, { force: true });
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
async get(id, signal) {
|
|
92
|
+
signal?.throwIfAborted();
|
|
93
|
+
const target = path(id);
|
|
94
|
+
const bytes = await readArtifactFile(target, maxBytes);
|
|
95
|
+
signal?.throwIfAborted();
|
|
96
|
+
return bytes;
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=artifact-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifact-store.js","sourceRoot":"","sources":["../../src/infrastructure/artifact-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGjE,KAAK,UAAU,SAAS,CAAC,IAAY;IACnC,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACpB,MAAM,SAAS,CA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O,KAAK,EAAE,CAAC;oBACf,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC;wBAAE,MAAM,KAAK,CAAC;oBACxC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,gBAAgB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;wBACzD,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;gBACpE,CAAC;gBACD,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;oBACjC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;oBACrC,IAAI,CAAC;wBACH,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;oBACtB,CAAC;4BAAS,CAAC;wBACT,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;oBACvB,CAAC;gBACH,CAAC;YACH,CAAC;oBAAS,CAAC;gBACT,MAAM,EAAE,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YACvC,CAAC;QACH,CAAC;QACD,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM;YAClB,MAAM,EAAE,cAAc,EAAE,CAAC;YACzB,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;YACxB,MAAM,KAAK,GAAG,MAAM,gBAAgB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YACvD,MAAM,EAAE,cAAc,EAAE,CAAC;YACzB,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { artifactDigestPattern } from \"../domain/artifact.constants.ts\";\nimport { randomUUID } from \"node:crypto\";\nimport { link, lstat, mkdir, open, rm } from \"node:fs/promises\";\nimport { dirname, join, resolve } from \"node:path\";\nimport type { ArtifactStore } from \"../domain/artifact.types.ts\";\nimport { readInspectionFile } from \"./inspection-file.ts\";\nimport { artifactMaxBytes } from \"./artifact-store.constants.ts\";\nimport type { FileArtifactStoreOptions } from \"./artifact-store.types.ts\";\n\nasync function directory(path: string): Promise<void> {\n const parent = dirname(path);\n if (parent !== path) {\n await directory(parent);\n try {\n await mkdir(path, { mode: 0o700 });\n } catch (error) {\n if (!code(error, \"EEXIST\")) throw error;\n }\n }\n if (!(await lstat(path)).isDirectory())\n throw new Error(\"Artifact directory must not contain symlinks\");\n}\n\nfunction code(error: unknown, expected: string): boolean {\n return (\n !!error &&\n typeof error === \"object\" &&\n \"code\" in error &&\n error.code === expected\n );\n}\n\nasync function readArtifactFile(\n path: string,\n maxBytes: number,\n): Promise<Buffer> {\n try {\n return await readInspectionFile(path, maxBytes);\n } catch (error) {\n if (\n !(error instanceof Error) ||\n error.message !== \"Inspection file changed\"\n )\n throw error;\n // Removing the staging hard link can change ctime once after publication.\n return readInspectionFile(path, maxBytes);\n }\n}\n\nexport function fileArtifactStore(\n options: FileArtifactStoreOptions,\n): ArtifactStore {\n const root = resolve(options.directory),\n maxBytes = options.maxBytes ?? artifactMaxBytes;\n if (!Number.isSafeInteger(maxBytes) || maxBytes < 1)\n throw new Error(\"Artifact maxBytes must be a positive safe integer\");\n const path = (id: string) => {\n if (!artifactDigestPattern.test(id))\n throw new Error(\"Invalid artifact storage ID\");\n return join(root, `${id}.blob`);\n };\n return {\n async put(id, input, signal) {\n signal?.throwIfAborted();\n const target = path(id);\n if (input.byteLength > maxBytes)\n throw new Error(\"Artifact exceeds maxBytes\");\n const bytes = Buffer.from(input);\n await directory(root);\n const temporary = join(root, `.${randomUUID()}.tmp`);\n try {\n const file = await open(temporary, \"wx\", 0o600);\n try {\n await file.writeFile(bytes, signal ? { signal } : {});\n await file.sync();\n } finally {\n await file.close();\n }\n signal?.throwIfAborted();\n try {\n await link(temporary, target);\n } catch (error) {\n if (!code(error, \"EEXIST\")) throw error;\n if (!bytes.equals(await readArtifactFile(target, maxBytes)))\n throw new Error(\"Existing artifact content integrity mismatch\");\n }\n if (process.platform !== \"win32\") {\n const parent = await open(root, \"r\");\n try {\n await parent.sync();\n } finally {\n await parent.close();\n }\n }\n } finally {\n await rm(temporary, { force: true });\n }\n },\n async get(id, signal) {\n signal?.throwIfAborted();\n const target = path(id);\n const bytes = await readArtifactFile(target, maxBytes);\n signal?.throwIfAborted();\n return bytes;\n },\n };\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifact-store.types.js","sourceRoot":"","sources":["../../src/infrastructure/artifact-store.types.ts"],"names":[],"mappings":"","sourcesContent":["export interface FileArtifactStoreOptions {\n readonly directory: string;\n readonly maxBytes?: number;\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { FileManifestEntry } from "../domain/sandbox.types.ts";
|
|
2
|
+
export declare function fileManifest(root: string, path: string, signal?: AbortSignal): Promise<FileManifestEntry>;
|
|
3
|
+
export declare function sameFile(left: FileManifestEntry, right: FileManifestEntry): boolean;
|
|
4
|
+
export declare function sameLocalFile(remote: FileManifestEntry, local: FileManifestEntry): boolean;
|
|
5
|
+
export declare function validateFilePaths(paths: readonly string[]): void;
|
|
6
|
+
export declare function parseManifest(value: unknown, paths: readonly string[]): FileManifestEntry[];
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { createReadStream } from "node:fs";
|
|
3
|
+
import { lstat, readlink } from "node:fs/promises";
|
|
4
|
+
import { OutpostError } from "../domain/errors.js";
|
|
5
|
+
import { safeDestination } from "./files.js";
|
|
6
|
+
export async function fileManifest(root, path, signal) {
|
|
7
|
+
signal?.throwIfAborted();
|
|
8
|
+
const target = await safeDestination(root, path);
|
|
9
|
+
const info = await lstat(target);
|
|
10
|
+
if (!info.isFile() && !info.isSymbolicLink())
|
|
11
|
+
throw new OutpostError("provider", "Unsupported manifest file type", {
|
|
12
|
+
path,
|
|
13
|
+
});
|
|
14
|
+
const hash = createHash("sha256");
|
|
15
|
+
let size = info.size;
|
|
16
|
+
if (info.isSymbolicLink()) {
|
|
17
|
+
const value = Buffer.from(await readlink(target));
|
|
18
|
+
size = value.length;
|
|
19
|
+
hash.update(value);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
for await (const chunk of createReadStream(target, { signal }))
|
|
23
|
+
hash.update(chunk);
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
path,
|
|
27
|
+
kind: info.isSymbolicLink() ? "link" : "file",
|
|
28
|
+
mode: info.mode & 0o777,
|
|
29
|
+
size,
|
|
30
|
+
sha256: hash.digest("hex"),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export function sameFile(left, right) {
|
|
34
|
+
return (left.path === right.path &&
|
|
35
|
+
left.kind === right.kind &&
|
|
36
|
+
left.mode === right.mode &&
|
|
37
|
+
left.size === right.size &&
|
|
38
|
+
left.sha256 === right.sha256);
|
|
39
|
+
}
|
|
40
|
+
export function sameLocalFile(remote, local) {
|
|
41
|
+
if (process.platform !== "win32")
|
|
42
|
+
return sameFile(remote, local);
|
|
43
|
+
return sameFile({ ...remote, mode: remote.mode & 0o200 }, { ...local, mode: local.mode & 0o200 });
|
|
44
|
+
}
|
|
45
|
+
export function validateFilePaths(paths) {
|
|
46
|
+
if (new Set(paths).size !== paths.length ||
|
|
47
|
+
paths.some((path) => !path ||
|
|
48
|
+
path.includes("\\") ||
|
|
49
|
+
path.includes("\0") ||
|
|
50
|
+
path
|
|
51
|
+
.split("/")
|
|
52
|
+
.some((part) => !part ||
|
|
53
|
+
part === "." ||
|
|
54
|
+
part === ".." ||
|
|
55
|
+
part.toLowerCase() === ".git")))
|
|
56
|
+
throw new OutpostError("provider", "Unsafe or duplicate manifest path");
|
|
57
|
+
}
|
|
58
|
+
export function parseManifest(value, paths) {
|
|
59
|
+
validateFilePaths(paths);
|
|
60
|
+
if (!Array.isArray(value) || value.length !== paths.length)
|
|
61
|
+
throw new OutpostError("provider", "Invalid file manifest");
|
|
62
|
+
return value.map((entry, index) => {
|
|
63
|
+
if (!entry ||
|
|
64
|
+
typeof entry !== "object" ||
|
|
65
|
+
!("path" in entry) ||
|
|
66
|
+
typeof entry.path !== "string" ||
|
|
67
|
+
entry.path !== paths[index] ||
|
|
68
|
+
!("kind" in entry) ||
|
|
69
|
+
(entry.kind !== "file" && entry.kind !== "link") ||
|
|
70
|
+
!("mode" in entry) ||
|
|
71
|
+
typeof entry.mode !== "number" ||
|
|
72
|
+
!Number.isInteger(entry.mode) ||
|
|
73
|
+
entry.mode < 0 ||
|
|
74
|
+
entry.mode > 0o777 ||
|
|
75
|
+
!("size" in entry) ||
|
|
76
|
+
typeof entry.size !== "number" ||
|
|
77
|
+
!Number.isSafeInteger(entry.size) ||
|
|
78
|
+
entry.size < 0 ||
|
|
79
|
+
!("sha256" in entry) ||
|
|
80
|
+
typeof entry.sha256 !== "string" ||
|
|
81
|
+
!/^[a-f0-9]{64}$/.test(entry.sha256))
|
|
82
|
+
throw new OutpostError("provider", "Invalid file manifest entry");
|
|
83
|
+
return {
|
|
84
|
+
path: entry.path,
|
|
85
|
+
kind: entry.kind,
|
|
86
|
+
mode: entry.mode,
|
|
87
|
+
size: entry.size,
|
|
88
|
+
sha256: entry.sha256,
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=file-manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-manifest.js","sourceRoot":"","sources":["../../src/infrastructure/file-manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,IAAY,EACZ,IAAY,EACZ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CAAC,IAAI;YAChB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,MAAM,EAAE,KAAK,CAAC,MAAM;SACrB,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { createReadStream } from \"node:fs\";\nimport { lstat, readlink } from \"node:fs/promises\";\nimport { OutpostError } from \"../domain/errors.ts\";\nimport type { FileManifestEntry } from \"../domain/sandbox.types.ts\";\nimport { safeDestination } from \"./files.ts\";\n\nexport async function fileManifest(\n root: string,\n path: string,\n signal?: AbortSignal,\n): Promise<FileManifestEntry> {\n signal?.throwIfAborted();\n const target = await safeDestination(root, path);\n const info = await lstat(target);\n if (!info.isFile() && !info.isSymbolicLink())\n throw new OutpostError(\"provider\", \"Unsupported manifest file type\", {\n path,\n });\n const hash = createHash(\"sha256\");\n let size = info.size;\n if (info.isSymbolicLink()) {\n const value = Buffer.from(await readlink(target));\n size = value.length;\n hash.update(value);\n } else {\n for await (const chunk of createReadStream(target, { signal }))\n hash.update(chunk);\n }\n return {\n path,\n kind: info.isSymbolicLink() ? \"link\" : \"file\",\n mode: info.mode & 0o777,\n size,\n sha256: hash.digest(\"hex\"),\n };\n}\n\nexport function sameFile(\n left: FileManifestEntry,\n right: FileManifestEntry,\n): boolean {\n return (\n left.path === right.path &&\n left.kind === right.kind &&\n left.mode === right.mode &&\n left.size === right.size &&\n left.sha256 === right.sha256\n );\n}\n\nexport function sameLocalFile(\n remote: FileManifestEntry,\n local: FileManifestEntry,\n): boolean {\n if (process.platform !== \"win32\") return sameFile(remote, local);\n return sameFile(\n { ...remote, mode: remote.mode & 0o200 },\n { ...local, mode: local.mode & 0o200 },\n );\n}\n\nexport function validateFilePaths(paths: readonly string[]): void {\n if (\n new Set(paths).size !== paths.length ||\n paths.some(\n (path) =>\n !path ||\n path.includes(\"\\\\\") ||\n path.includes(\"\\0\") ||\n path\n .split(\"/\")\n .some(\n (part) =>\n !part ||\n part === \".\" ||\n part === \"..\" ||\n part.toLowerCase() === \".git\",\n ),\n )\n )\n throw new OutpostError(\"provider\", \"Unsafe or duplicate manifest path\");\n}\n\nexport function parseManifest(\n value: unknown,\n paths: readonly string[],\n): FileManifestEntry[] {\n validateFilePaths(paths);\n if (!Array.isArray(value) || value.length !== paths.length)\n throw new OutpostError(\"provider\", \"Invalid file manifest\");\n return value.map((entry: unknown, index) => {\n if (\n !entry ||\n typeof entry !== \"object\" ||\n !(\"path\" in entry) ||\n typeof entry.path !== \"string\" ||\n entry.path !== paths[index] ||\n !(\"kind\" in entry) ||\n (entry.kind !== \"file\" && entry.kind !== \"link\") ||\n !(\"mode\" in entry) ||\n typeof entry.mode !== \"number\" ||\n !Number.isInteger(entry.mode) ||\n entry.mode < 0 ||\n entry.mode > 0o777 ||\n !(\"size\" in entry) ||\n typeof entry.size !== \"number\" ||\n !Number.isSafeInteger(entry.size) ||\n entry.size < 0 ||\n !(\"sha256\" in entry) ||\n typeof entry.sha256 !== \"string\" ||\n !/^[a-f0-9]{64}$/.test(entry.sha256)\n )\n throw new OutpostError(\"provider\", \"Invalid file manifest entry\");\n return {\n path: entry.path,\n kind: entry.kind,\n mode: entry.mode,\n size: entry.size,\n sha256: entry.sha256,\n };\n });\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lock-inspection.constants.js","sourceRoot":"","sources":["../../../src/infrastructure/git/lock-inspection.constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,QAAQ,EAAE,IAAI;IACd,MAAM,EAAE,aAAa;CACb,CAAC","sourcesContent":["export const lockInspectionDefaults = {\n maxBytes: 4096,\n maxPid: 2_147_483_647,\n} as const;\n"]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { observeOwnership } from "./process-identity.js";
|
|
2
|
+
import { readInspectionFile } from "../inspection-file.js";
|
|
3
|
+
import { lockInspectionDefaults } from "./lock-inspection.constants.js";
|
|
4
|
+
async function readPid(path) {
|
|
5
|
+
const record = JSON.parse((await readInspectionFile(path, lockInspectionDefaults.maxBytes)).toString("utf8"));
|
|
6
|
+
if (!record || typeof record !== "object" || !("pid" in record))
|
|
7
|
+
return undefined;
|
|
8
|
+
const pid = record.pid;
|
|
9
|
+
if (typeof pid !== "number" ||
|
|
10
|
+
!Number.isInteger(pid) ||
|
|
11
|
+
pid <= 0 ||
|
|
12
|
+
pid > lockInspectionDefaults.maxPid)
|
|
13
|
+
return undefined;
|
|
14
|
+
return {
|
|
15
|
+
pid,
|
|
16
|
+
...("identity" in record ? { identity: record.identity } : {}),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
async function inspectEntry(entry, probe) {
|
|
20
|
+
if (entry.kind !== "file")
|
|
21
|
+
return { state: "skipped", reason: "NOT_FILE" };
|
|
22
|
+
let record;
|
|
23
|
+
try {
|
|
24
|
+
record = await readPid(entry.path);
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return { state: "unknown", reason: "LOCK_READ_FAILED" };
|
|
28
|
+
}
|
|
29
|
+
if (record === undefined)
|
|
30
|
+
return { state: "unknown", reason: "INVALID_PID" };
|
|
31
|
+
const { pid, identity } = record;
|
|
32
|
+
const ownership = await observeOwnership(pid, identity);
|
|
33
|
+
try {
|
|
34
|
+
probe(pid);
|
|
35
|
+
return { state: "present", pid, ownership };
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
if (error &&
|
|
39
|
+
typeof error === "object" &&
|
|
40
|
+
"code" in error &&
|
|
41
|
+
error.code === "ESRCH")
|
|
42
|
+
return { state: "absent", pid, ownership };
|
|
43
|
+
return { state: "unknown", pid, reason: "PID_PROBE_FAILED", ownership };
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export async function inspectLocks(entries, probe = (pid) => {
|
|
47
|
+
process.kill(pid, 0);
|
|
48
|
+
}) {
|
|
49
|
+
const locks = [];
|
|
50
|
+
const issues = [];
|
|
51
|
+
for (const entry of entries) {
|
|
52
|
+
const state = await inspectEntry(entry, probe);
|
|
53
|
+
locks.push({ name: entry.name, path: entry.path, ...state });
|
|
54
|
+
if (state.state === "unknown")
|
|
55
|
+
issues.push({ path: entry.path, code: state.reason });
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
scope: "local-pid",
|
|
59
|
+
complete: issues.length === 0,
|
|
60
|
+
entries: locks,
|
|
61
|
+
issues,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=lock-inspection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lock-inspection.js","sourceRoot":"","sources":["../../../src/infrastructure/git/lock-inspection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AASxE,KAAK,UAAU,OAAO,CAAC,IAAY;IACjC,MAAM,MAAM,GAAY,IAAI,CAAC,KAAK,CAChC,CAAC,MAAM,kBAAkB,CAAC,IAAI,EAAE,sBAAsB,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CACxE,MAAM,CACP,CACF,CAAC;IACF,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,CAAC,KAAK,IAAI,MAAM,CAAC;QAC7D,OAAO,SAAS,CAAC;IACnB,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC;IACvB,IACE,OAAO,GAAG,KAAK,QAAQ;QACvB,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC;QACtB,GAAG,IAAI,CAAC;QACR,GAAG,GAAG,sBAAsB,CAAC,MAAM;QAEnC,OAAO,SAAS,CAAC;IACnB,OAAO;QACL,GAAG;QACH,GAAG,CAAC,UAAU,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE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EAChC,QAAsB,CAAC,GAAG,EAAE,EAAE;IAC5B,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;AACvB,CAAC;IAED,MAAM,KAAK,GAA0B,EAAE,CAAC;IACxC,MAAM,MAAM,GAAmB,EAAE,CAAC;IAClC,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,MAAM,KAAK,GAAG,MAAM,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC/C,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC;QAC7D,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS;YAC3B,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO;QACL,KAAK,EAAE,WAAW;QAClB,QAAQ,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;QAC7B,OAAO,EAAE,KAAK;QACd,MAAM;KACP,CAAC;AACJ,CAAC","sourcesContent":["import { observeOwnership } from \"./process-identity.ts\";\nimport { readInspectionFile } from \"../inspection-file.ts\";\nimport type { StorageEntry, StorageIssue } from \"../storage-inventory.types.ts\";\nimport { lockInspectionDefaults } from \"./lock-inspection.constants.ts\";\nimport type {\n LockIdentityRecord,\n LockInspection,\n LockInspectionEntry,\n LockInspectionState,\n LockPidProbe,\n} from \"./lock-inspection.types.ts\";\n\nasync function readPid(path: string): Promise<LockIdentityRecord | undefined> {\n const record: unknown = JSON.parse(\n (await readInspectionFile(path, lockInspectionDefaults.maxBytes)).toString(\n \"utf8\",\n ),\n );\n if (!record || typeof record !== \"object\" || !(\"pid\" in record))\n return undefined;\n const pid = record.pid;\n if (\n typeof pid !== \"number\" ||\n !Number.isInteger(pid) ||\n pid <= 0 ||\n pid > lockInspectionDefaults.maxPid\n )\n return undefined;\n return {\n pid,\n ...(\"identity\" in record ? { identity: record.identity } : {}),\n };\n}\n\nasync function inspectEntry(\n entry: StorageEntry,\n probe: LockPidProbe,\n): Promise<LockInspectionState> {\n if (entry.kind !== \"file\") return { state: \"skipped\", reason: \"NOT_FILE\" };\n let record: LockIdentityRecord | undefined;\n try {\n record = await readPid(entry.path);\n } catch {\n return { state: \"unknown\", reason: \"LOCK_READ_FAILED\" };\n }\n if (record === undefined) return { state: \"unknown\", reason: \"INVALID_PID\" };\n const { pid, identity } = record;\n const ownership = await observeOwnership(pid, identity);\n try {\n probe(pid);\n return { state: \"present\", pid, ownership };\n } catch (error) {\n if (\n error &&\n typeof error === \"object\" &&\n \"code\" in error &&\n error.code === \"ESRCH\"\n )\n return { state: \"absent\", pid, ownership };\n return { state: \"unknown\", pid, reason: \"PID_PROBE_FAILED\", ownership };\n }\n}\n\nexport async function inspectLocks(\n entries: readonly StorageEntry[],\n probe: LockPidProbe = (pid) => {\n process.kill(pid, 0);\n },\n): Promise<LockInspection> {\n const locks: LockInspectionEntry[] = [];\n const issues: StorageIssue[] = [];\n for (const entry of entries) {\n const state = await inspectEntry(entry, probe);\n locks.push({ name: entry.name, path: entry.path, ...state });\n if (state.state === \"unknown\")\n issues.push({ path: entry.path, code: state.reason });\n }\n return {\n scope: \"local-pid\",\n complete: issues.length === 0,\n entries: locks,\n issues,\n };\n}\n"]}
|