@elie-laloum/outpost 5.0.0 → 7.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 +54 -0
- package/README.md +11 -11
- package/SECURITY.md +10 -0
- package/dist/adapters/agents/antigravity-adapter.d.ts +3 -0
- package/dist/adapters/agents/antigravity-adapter.js +41 -0
- package/dist/adapters/agents/antigravity-adapter.js.map +1 -0
- package/dist/adapters/agents/antigravity-authentication.d.ts +2 -0
- package/dist/adapters/agents/antigravity-authentication.js +27 -0
- package/dist/adapters/agents/antigravity-authentication.js.map +1 -0
- package/dist/adapters/agents/antigravity-diagnostics.d.ts +1 -0
- package/dist/adapters/agents/antigravity-diagnostics.js +6 -0
- package/dist/adapters/agents/antigravity-diagnostics.js.map +1 -0
- package/dist/adapters/agents/antigravity-events.d.ts +2 -0
- package/dist/adapters/agents/antigravity-events.js +75 -0
- package/dist/adapters/agents/antigravity-events.js.map +1 -0
- package/dist/adapters/agents/antigravity-request.d.ts +5 -0
- package/dist/adapters/agents/antigravity-request.js +37 -0
- package/dist/adapters/agents/antigravity-request.js.map +1 -0
- package/dist/adapters/agents/antigravity.constants.d.ts +3 -0
- package/dist/adapters/agents/antigravity.constants.js +4 -0
- package/dist/adapters/agents/antigravity.constants.js.map +1 -0
- package/dist/adapters/agents/{gemini.types.d.ts → antigravity.types.d.ts} +2 -2
- package/dist/adapters/agents/antigravity.types.js +2 -0
- package/dist/adapters/agents/antigravity.types.js.map +1 -0
- package/dist/adapters/agents/authentication.constants.d.ts +19 -9
- package/dist/adapters/agents/authentication.constants.js +12 -9
- package/dist/adapters/agents/authentication.constants.js.map +1 -1
- package/dist/adapters/agents/authentication.d.ts +11 -2
- package/dist/adapters/agents/authentication.js +70 -47
- package/dist/adapters/agents/authentication.js.map +1 -1
- package/dist/adapters/agents/authentication.types.d.ts +20 -0
- package/dist/adapters/agents/authentication.types.js +2 -0
- package/dist/adapters/agents/authentication.types.js.map +1 -0
- package/dist/adapters/agents/claude-adapter.js +4 -2
- package/dist/adapters/agents/claude-adapter.js.map +1 -1
- package/dist/adapters/agents/claude-authentication.d.ts +2 -0
- package/dist/adapters/agents/claude-authentication.js +34 -0
- package/dist/adapters/agents/claude-authentication.js.map +1 -0
- package/dist/adapters/agents/claude-events.js +52 -9
- package/dist/adapters/agents/claude-events.js.map +1 -1
- package/dist/adapters/agents/claude-request.js +2 -0
- package/dist/adapters/agents/claude-request.js.map +1 -1
- package/dist/adapters/agents/cli-diagnostics.constants.d.ts +6 -6
- package/dist/adapters/agents/cli-diagnostics.constants.js +6 -6
- package/dist/adapters/agents/cli-diagnostics.constants.js.map +1 -1
- package/dist/adapters/agents/cli-diagnostics.d.ts +1 -0
- package/dist/adapters/agents/cli-diagnostics.js +18 -0
- package/dist/adapters/agents/cli-diagnostics.js.map +1 -1
- package/dist/adapters/agents/codex-adapter.js +4 -2
- package/dist/adapters/agents/codex-adapter.js.map +1 -1
- package/dist/adapters/agents/codex-authentication.d.ts +3 -0
- package/dist/adapters/agents/codex-authentication.js +47 -0
- package/dist/adapters/agents/codex-authentication.js.map +1 -0
- package/dist/adapters/agents/codex-events.js +28 -2
- package/dist/adapters/agents/codex-events.js.map +1 -1
- package/dist/adapters/agents/copilot-adapter.d.ts +3 -0
- package/dist/adapters/agents/copilot-adapter.js +45 -0
- package/dist/adapters/agents/copilot-adapter.js.map +1 -0
- package/dist/adapters/agents/copilot-authentication.d.ts +2 -0
- package/dist/adapters/agents/copilot-authentication.js +46 -0
- package/dist/adapters/agents/copilot-authentication.js.map +1 -0
- package/dist/adapters/agents/copilot-diagnostics.d.ts +1 -0
- package/dist/adapters/agents/copilot-diagnostics.js +6 -0
- package/dist/adapters/agents/copilot-diagnostics.js.map +1 -0
- package/dist/adapters/agents/copilot-events.d.ts +2 -0
- package/dist/adapters/agents/copilot-events.js +66 -0
- package/dist/adapters/agents/copilot-events.js.map +1 -0
- package/dist/adapters/agents/copilot-request.d.ts +5 -0
- package/dist/adapters/agents/copilot-request.js +24 -0
- package/dist/adapters/agents/copilot-request.js.map +1 -0
- package/dist/adapters/agents/copilot-usage.d.ts +3 -0
- package/dist/adapters/agents/copilot-usage.js +19 -0
- package/dist/adapters/agents/copilot-usage.js.map +1 -0
- package/dist/adapters/agents/copilot.types.d.ts +6 -0
- package/dist/adapters/agents/copilot.types.js +2 -0
- package/dist/adapters/agents/copilot.types.js.map +1 -0
- package/dist/adapters/agents/event-decoder.d.ts +2 -2
- package/dist/adapters/agents/event-decoder.js +6 -5
- package/dist/adapters/agents/event-decoder.js.map +1 -1
- package/dist/adapters/agents/kimi-adapter.d.ts +3 -0
- package/dist/adapters/agents/kimi-adapter.js +51 -0
- package/dist/adapters/agents/kimi-adapter.js.map +1 -0
- package/dist/adapters/agents/kimi-authentication.d.ts +3 -0
- package/dist/adapters/agents/kimi-authentication.js +63 -0
- package/dist/adapters/agents/kimi-authentication.js.map +1 -0
- package/dist/adapters/agents/kimi-diagnostics.d.ts +2 -0
- package/dist/adapters/agents/kimi-diagnostics.js +14 -0
- package/dist/adapters/agents/kimi-diagnostics.js.map +1 -0
- package/dist/adapters/agents/kimi-events.d.ts +2 -0
- package/dist/adapters/agents/kimi-events.js +55 -0
- package/dist/adapters/agents/kimi-events.js.map +1 -0
- package/dist/adapters/agents/kimi-fork.d.ts +2 -0
- package/dist/adapters/agents/kimi-fork.js +11 -0
- package/dist/adapters/agents/kimi-fork.js.map +1 -0
- package/dist/adapters/agents/{gemini-request.d.ts → kimi-request.d.ts} +2 -2
- package/dist/adapters/agents/kimi-request.js +33 -0
- package/dist/adapters/agents/kimi-request.js.map +1 -0
- package/dist/adapters/agents/kimi-usage.d.ts +2 -0
- package/dist/adapters/agents/kimi-usage.js +7 -0
- package/dist/adapters/agents/kimi-usage.js.map +1 -0
- package/dist/adapters/agents/kimi.constants.d.ts +13 -0
- package/dist/adapters/agents/kimi.constants.js +14 -0
- package/dist/adapters/agents/kimi.constants.js.map +1 -0
- package/dist/adapters/agents/kimi.types.d.ts +7 -0
- package/dist/adapters/agents/kimi.types.js +2 -0
- package/dist/adapters/agents/kimi.types.js.map +1 -0
- package/dist/adapters/agents/model-support.constants.d.ts +3 -1
- package/dist/adapters/agents/model-support.constants.js +12 -2
- package/dist/adapters/agents/model-support.constants.js.map +1 -1
- package/dist/adapters/agents/protocol-fixtures.constants.d.ts +2 -2
- package/dist/adapters/agents/protocol-fixtures.constants.js +131 -9
- package/dist/adapters/agents/protocol-fixtures.constants.js.map +1 -1
- package/dist/adapters/agents/protocol-fixtures.types.d.ts +1 -0
- package/dist/adapters/agents/protocol-fixtures.types.js.map +1 -1
- package/dist/adapters/agents/protocol.d.ts +1 -0
- package/dist/adapters/agents/protocol.js +9 -0
- package/dist/adapters/agents/protocol.js.map +1 -1
- package/dist/adapters/agents/session-usage.constants.d.ts +10 -0
- package/dist/adapters/agents/session-usage.constants.js +110 -0
- package/dist/adapters/agents/session-usage.constants.js.map +1 -0
- package/dist/adapters/agents/session-usage.d.ts +5 -0
- package/dist/adapters/agents/session-usage.js +45 -0
- package/dist/adapters/agents/session-usage.js.map +1 -0
- package/dist/adapters/agents/settings.types.d.ts +1 -0
- package/dist/adapters/agents/settings.types.js.map +1 -1
- package/dist/adapters/agents/tool-result.d.ts +2 -0
- package/dist/adapters/agents/tool-result.js +17 -0
- package/dist/adapters/agents/tool-result.js.map +1 -0
- package/dist/adapters/models/anthropic-response.js +3 -0
- package/dist/adapters/models/anthropic-response.js.map +1 -1
- package/dist/adapters/models/http-provider.js +6 -1
- package/dist/adapters/models/http-provider.js.map +1 -1
- package/dist/adapters/models/openai-responses.js +10 -0
- package/dist/adapters/models/openai-responses.js.map +1 -1
- package/dist/adapters/models/retry-after.d.ts +1 -0
- package/dist/adapters/models/retry-after.js +16 -0
- package/dist/adapters/models/retry-after.js.map +1 -0
- package/dist/application/activity-watchdog.js +1 -2
- package/dist/application/activity-watchdog.js.map +1 -1
- package/dist/application/agent-authentication.d.ts +4 -0
- package/dist/application/agent-authentication.js +32 -0
- package/dist/application/agent-authentication.js.map +1 -0
- package/dist/application/agent-bootstrap.constants.d.ts +2 -5
- package/dist/application/agent-bootstrap.constants.js +27 -4
- package/dist/application/agent-bootstrap.constants.js.map +1 -1
- package/dist/application/agent-bootstrap.js +39 -12
- package/dist/application/agent-bootstrap.js.map +1 -1
- package/dist/application/agent-bootstrap.types.d.ts +19 -0
- package/dist/application/agent-bootstrap.types.js +2 -0
- package/dist/application/agent-bootstrap.types.js.map +1 -0
- package/dist/application/agent-output.js +74 -8
- package/dist/application/agent-output.js.map +1 -1
- package/dist/application/agent-request.d.ts +3 -0
- package/dist/application/agent-request.js +11 -0
- package/dist/application/agent-request.js.map +1 -0
- package/dist/application/agent-turn.js +74 -6
- package/dist/application/agent-turn.js.map +1 -1
- package/dist/application/agent-usage.d.ts +6 -0
- package/dist/application/agent-usage.js +57 -0
- package/dist/application/agent-usage.js.map +1 -0
- package/dist/application/attach.js +2 -0
- package/dist/application/attach.js.map +1 -1
- package/dist/application/credential-installer.constants.d.ts +1 -0
- package/dist/application/credential-installer.constants.js +22 -0
- package/dist/application/credential-installer.constants.js.map +1 -0
- package/dist/application/custom-turn.js +44 -49
- package/dist/application/custom-turn.js.map +1 -1
- package/dist/application/dispatch-observation.d.ts +1 -1
- package/dist/application/dispatch-observation.js +141 -21
- package/dist/application/dispatch-observation.js.map +1 -1
- package/dist/application/dispatch-observation.types.d.ts +2 -0
- package/dist/application/dispatch-observation.types.js.map +1 -1
- package/dist/application/dispatch-validation.js +2 -0
- package/dist/application/dispatch-validation.js.map +1 -1
- package/dist/application/dispatch.js +1 -1
- package/dist/application/dispatch.js.map +1 -1
- package/dist/application/doctor-agent.constants.d.ts +2 -8
- package/dist/application/doctor-agent.constants.js +43 -6
- package/dist/application/doctor-agent.constants.js.map +1 -1
- package/dist/application/doctor-agent.d.ts +2 -1
- package/dist/application/doctor-agent.js +15 -3
- package/dist/application/doctor-agent.js.map +1 -1
- package/dist/application/doctor-image.js +4 -6
- package/dist/application/doctor-image.js.map +1 -1
- package/dist/application/doctor-protocol.js +6 -11
- package/dist/application/doctor-protocol.js.map +1 -1
- package/dist/application/doctor-protocol.types.d.ts +1 -1
- package/dist/application/doctor-protocol.types.js.map +1 -1
- package/dist/application/doctor-sandbox.js +2 -5
- package/dist/application/doctor-sandbox.js.map +1 -1
- package/dist/application/doctor.js +28 -10
- package/dist/application/doctor.js.map +1 -1
- package/dist/application/doctor.types.d.ts +10 -1
- package/dist/application/doctor.types.js.map +1 -1
- package/dist/application/execution.constants.d.ts +2 -0
- package/dist/application/execution.constants.js +2 -0
- package/dist/application/execution.constants.js.map +1 -1
- package/dist/application/execution.types.d.ts +8 -0
- package/dist/application/execution.types.js.map +1 -1
- package/dist/application/harness-budget.d.ts +3 -0
- package/dist/application/harness-budget.js +42 -0
- package/dist/application/harness-budget.js.map +1 -0
- package/dist/application/harness-budget.types.d.ts +5 -0
- package/dist/application/harness-budget.types.js +2 -0
- package/dist/application/harness-budget.types.js.map +1 -0
- package/dist/application/harness-hooks.js +34 -3
- package/dist/application/harness-hooks.js.map +1 -1
- package/dist/application/harness-loop.js +52 -24
- package/dist/application/harness-loop.js.map +1 -1
- package/dist/application/harness-model-provider.d.ts +3 -0
- package/dist/application/harness-model-provider.js +49 -0
- package/dist/application/harness-model-provider.js.map +1 -0
- package/dist/application/harness-model-provider.types.d.ts +10 -0
- package/dist/application/harness-model-provider.types.js +2 -0
- package/dist/application/harness-model-provider.types.js.map +1 -0
- package/dist/application/harness-subagent.d.ts +4 -0
- package/dist/application/harness-subagent.js +110 -0
- package/dist/application/harness-subagent.js.map +1 -0
- package/dist/application/harness.types.d.ts +11 -0
- package/dist/application/harness.types.js.map +1 -1
- package/dist/application/lifecycle-hooks.d.ts +1 -1
- package/dist/application/lifecycle-hooks.js +5 -4
- package/dist/application/lifecycle-hooks.js.map +1 -1
- package/dist/application/observed-lease.d.ts +3 -0
- package/dist/application/observed-lease.js +26 -0
- package/dist/application/observed-lease.js.map +1 -0
- package/dist/application/outpost.types.d.ts +3 -1
- package/dist/application/outpost.types.js.map +1 -1
- package/dist/application/output-lines.d.ts +4 -0
- package/dist/application/output-lines.js +28 -0
- package/dist/application/output-lines.js.map +1 -0
- package/dist/application/queue-worker.js +1 -1
- package/dist/application/queue-worker.js.map +1 -1
- package/dist/application/queue-worker.types.d.ts +1 -0
- package/dist/application/queue-worker.types.js.map +1 -1
- package/dist/application/queued-task.js +24 -5
- package/dist/application/queued-task.js.map +1 -1
- package/dist/application/recovery-archive.d.ts +3 -2
- package/dist/application/recovery-archive.js +9 -2
- package/dist/application/recovery-archive.js.map +1 -1
- package/dist/application/recovery-restore.d.ts +3 -2
- package/dist/application/recovery-restore.js +9 -2
- package/dist/application/recovery-restore.js.map +1 -1
- package/dist/application/recovery-retention.d.ts +3 -2
- package/dist/application/recovery-retention.js +74 -26
- package/dist/application/recovery-retention.js.map +1 -1
- package/dist/application/remote-workspace.js +5 -4
- package/dist/application/remote-workspace.js.map +1 -1
- package/dist/application/remote-workspace.types.d.ts +1 -0
- package/dist/application/remote-workspace.types.js.map +1 -1
- package/dist/application/sandbox-agents.js +19 -19
- package/dist/application/sandbox-agents.js.map +1 -1
- package/dist/application/sandbox-attach.js +12 -3
- package/dist/application/sandbox-attach.js.map +1 -1
- package/dist/application/sandbox-dispatch.js +13 -27
- package/dist/application/sandbox-dispatch.js.map +1 -1
- package/dist/application/sandbox-provision.js +15 -9
- package/dist/application/sandbox-provision.js.map +1 -1
- package/dist/application/sandbox-session.types.d.ts +7 -2
- package/dist/application/sandbox-session.types.js.map +1 -1
- package/dist/application/sandbox.js +13 -6
- package/dist/application/sandbox.js.map +1 -1
- package/dist/application/speculation-checkpoint.d.ts +6 -0
- package/dist/application/speculation-checkpoint.js +206 -0
- package/dist/application/speculation-checkpoint.js.map +1 -0
- package/dist/application/speculation-checkpoint.types.d.ts +24 -0
- package/dist/application/speculation-checkpoint.types.js +2 -0
- package/dist/application/speculation-checkpoint.types.js.map +1 -0
- package/dist/application/speculation-integration.constants.d.ts +4 -0
- package/dist/application/speculation-integration.constants.js +5 -0
- package/dist/application/speculation-integration.constants.js.map +1 -0
- package/dist/application/speculation-integration.d.ts +2 -0
- package/dist/application/speculation-integration.js +67 -0
- package/dist/application/speculation-integration.js.map +1 -0
- package/dist/application/speculation-resume.d.ts +4 -0
- package/dist/application/speculation-resume.js +71 -0
- package/dist/application/speculation-resume.js.map +1 -0
- package/dist/application/speculation-run.d.ts +4 -0
- package/dist/application/speculation-run.js +320 -0
- package/dist/application/speculation-run.js.map +1 -0
- package/dist/application/speculation-timeout.d.ts +1 -0
- package/dist/application/speculation-timeout.js +15 -0
- package/dist/application/speculation-timeout.js.map +1 -0
- package/dist/application/speculation.constants.d.ts +1 -0
- package/dist/application/speculation.constants.js +5 -1
- package/dist/application/speculation.constants.js.map +1 -1
- package/dist/application/speculation.js +41 -149
- package/dist/application/speculation.js.map +1 -1
- package/dist/application/speculation.types.d.ts +23 -0
- package/dist/application/speculation.types.js.map +1 -1
- package/dist/application/startup-recovery.js +14 -1
- package/dist/application/startup-recovery.js.map +1 -1
- package/dist/application/startup-recovery.types.d.ts +1 -0
- package/dist/application/startup-recovery.types.js.map +1 -1
- package/dist/application/stop-reason.d.ts +2 -0
- package/dist/application/stop-reason.js +21 -0
- package/dist/application/stop-reason.js.map +1 -0
- package/dist/application/stop-reason.types.d.ts +4 -0
- package/dist/application/stop-reason.types.js +2 -0
- package/dist/application/stop-reason.types.js.map +1 -0
- package/dist/application/storage-reservation.js +9 -2
- package/dist/application/storage-reservation.js.map +1 -1
- package/dist/application/task-observation.d.ts +3 -0
- package/dist/application/task-observation.js +22 -0
- package/dist/application/task-observation.js.map +1 -0
- package/dist/application/task-usage.js +5 -12
- package/dist/application/task-usage.js.map +1 -1
- package/dist/application/tasks.js +41 -16
- package/dist/application/tasks.js.map +1 -1
- package/dist/application/tool-execution.js +42 -19
- package/dist/application/tool-execution.js.map +1 -1
- package/dist/application/workspace.js +6 -4
- package/dist/application/workspace.js.map +1 -1
- package/dist/cli/doctor-command.js +6 -2
- package/dist/cli/doctor-command.js.map +1 -1
- package/dist/cli/init-authentication.d.ts +4 -1
- package/dist/cli/init-authentication.js +28 -33
- package/dist/cli/init-authentication.js.map +1 -1
- package/dist/cli/init-command.js +3 -3
- package/dist/cli/init-command.js.map +1 -1
- package/dist/cli/main.constants.d.ts +50 -13
- package/dist/cli/main.constants.js +70 -8
- package/dist/cli/main.constants.js.map +1 -1
- package/dist/cli/main.js +2 -1
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/scaffold-files.js +1 -1
- package/dist/cli/scaffold-files.js.map +1 -1
- package/dist/cli/scaffold-validation.js +29 -22
- package/dist/cli/scaffold-validation.js.map +1 -1
- package/dist/cli/scaffold.constants.d.ts +0 -1
- package/dist/cli/scaffold.constants.js +6 -2
- package/dist/cli/scaffold.constants.js.map +1 -1
- package/dist/cli/scaffold.types.d.ts +8 -2
- package/dist/cli/scaffold.types.js.map +1 -1
- package/dist/cli/starters.js +1 -3
- package/dist/cli/starters.js.map +1 -1
- package/dist/domain/agent-observation.d.ts +4 -0
- package/dist/domain/agent-observation.js +27 -0
- package/dist/domain/agent-observation.js.map +1 -0
- package/dist/domain/agent.types.d.ts +122 -14
- package/dist/domain/agent.types.js.map +1 -1
- package/dist/domain/authentication.constants.d.ts +3 -0
- package/dist/domain/authentication.constants.js +11 -0
- package/dist/domain/authentication.constants.js.map +1 -0
- package/dist/domain/authentication.d.ts +3 -0
- package/dist/domain/authentication.js +22 -0
- package/dist/domain/authentication.js.map +1 -0
- package/dist/domain/authentication.types.d.ts +5 -0
- package/dist/domain/authentication.types.js +2 -0
- package/dist/domain/authentication.types.js.map +1 -0
- package/dist/domain/harness.d.ts +2 -2
- package/dist/domain/harness.js +6 -0
- package/dist/domain/harness.js.map +1 -1
- package/dist/domain/harness.types.d.ts +4 -3
- package/dist/domain/harness.types.js.map +1 -1
- package/dist/domain/model.types.d.ts +8 -0
- package/dist/domain/model.types.js.map +1 -1
- package/dist/domain/observation.constants.d.ts +8 -0
- package/dist/domain/observation.constants.js +9 -0
- package/dist/domain/observation.constants.js.map +1 -0
- package/dist/domain/observation.d.ts +2 -0
- package/dist/domain/observation.js +190 -0
- package/dist/domain/observation.js.map +1 -0
- package/dist/domain/observation.types.d.ts +84 -0
- package/dist/domain/observation.types.js +2 -0
- package/dist/domain/observation.types.js.map +1 -0
- package/dist/domain/observed-operation.d.ts +2 -0
- package/dist/domain/observed-operation.js +30 -0
- package/dist/domain/observed-operation.js.map +1 -0
- package/dist/domain/sandbox.types.d.ts +2 -0
- package/dist/domain/sandbox.types.js.map +1 -1
- package/dist/domain/subagent.constants.d.ts +13 -0
- package/dist/domain/subagent.constants.js +9 -0
- package/dist/domain/subagent.constants.js.map +1 -0
- package/dist/domain/subagent.d.ts +4 -0
- package/dist/domain/subagent.js +28 -0
- package/dist/domain/subagent.js.map +1 -0
- package/dist/domain/subagent.types.d.ts +13 -0
- package/dist/domain/subagent.types.js +2 -0
- package/dist/domain/subagent.types.js.map +1 -0
- package/dist/domain/transcript.types.d.ts +2 -0
- package/dist/domain/transcript.types.js.map +1 -1
- package/dist/domain/usage.d.ts +1 -0
- package/dist/domain/usage.js +16 -0
- package/dist/domain/usage.js.map +1 -1
- package/dist/domain/workflow/budget.d.ts +7 -3
- package/dist/domain/workflow/budget.js +26 -0
- package/dist/domain/workflow/budget.js.map +1 -1
- package/dist/domain/workflow/budget.types.d.ts +1 -1
- package/dist/domain/workflow/budget.types.js.map +1 -1
- package/dist/domain/workflow/checkpoint-validation.js +7 -1
- package/dist/domain/workflow/checkpoint-validation.js.map +1 -1
- package/dist/domain/workflow/checkpoint.js +3 -0
- package/dist/domain/workflow/checkpoint.js.map +1 -1
- package/dist/domain/workflow/gate-validation.js +14 -1
- package/dist/domain/workflow/gate-validation.js.map +1 -1
- package/dist/domain/workflow/gates.d.ts +1 -1
- package/dist/domain/workflow/gates.js +52 -4
- package/dist/domain/workflow/gates.js.map +1 -1
- package/dist/domain/workflow/gates.types.d.ts +15 -1
- package/dist/domain/workflow/gates.types.js.map +1 -1
- package/dist/domain/workflow/idempotency.d.ts +1 -0
- package/dist/domain/workflow/idempotency.js +7 -0
- package/dist/domain/workflow/idempotency.js.map +1 -0
- package/dist/domain/workflow/retry.constants.d.ts +2 -0
- package/dist/domain/workflow/retry.constants.js +3 -0
- package/dist/domain/workflow/retry.constants.js.map +1 -0
- package/dist/domain/workflow/retry.d.ts +4 -0
- package/dist/domain/workflow/retry.js +49 -0
- package/dist/domain/workflow/retry.js.map +1 -0
- package/dist/domain/workflow/task-runner.js +9 -5
- package/dist/domain/workflow/task-runner.js.map +1 -1
- package/dist/domain/workflow/task.js +6 -6
- package/dist/domain/workflow/task.js.map +1 -1
- package/dist/domain/workflow/workflow-scheduler.js +110 -72
- package/dist/domain/workflow/workflow-scheduler.js.map +1 -1
- package/dist/domain/workflow/workflow-state.js +28 -12
- package/dist/domain/workflow/workflow-state.js.map +1 -1
- package/dist/domain/workflow.d.ts +1 -1
- package/dist/domain/workflow.js +1 -1
- package/dist/domain/workflow.js.map +1 -1
- package/dist/domain/workflow.types.d.ts +13 -2
- package/dist/domain/workflow.types.js.map +1 -1
- package/dist/index.d.ts +16 -11
- package/dist/index.js +7 -4
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/conversations/capture.js +10 -0
- package/dist/infrastructure/conversations/capture.js.map +1 -1
- package/dist/infrastructure/conversations/harness-transcript.js +6 -0
- package/dist/infrastructure/conversations/harness-transcript.js.map +1 -1
- package/dist/infrastructure/conversations/harness-transcript.types.d.ts +2 -0
- package/dist/infrastructure/conversations/harness-transcript.types.js.map +1 -1
- package/dist/infrastructure/conversations/layout.js +2 -0
- package/dist/infrastructure/conversations/layout.js.map +1 -1
- package/dist/infrastructure/conversations/locate.js +7 -1
- package/dist/infrastructure/conversations/locate.js.map +1 -1
- package/dist/infrastructure/conversations/native-store.js +8 -1
- package/dist/infrastructure/conversations/native-store.js.map +1 -1
- package/dist/infrastructure/conversations/paths.js +3 -0
- package/dist/infrastructure/conversations/paths.js.map +1 -1
- package/dist/infrastructure/conversations/restore.js +7 -0
- package/dist/infrastructure/conversations/restore.js.map +1 -1
- package/dist/infrastructure/conversations/session-bundle.constants.d.ts +5 -0
- package/dist/infrastructure/conversations/session-bundle.constants.js +173 -0
- package/dist/infrastructure/conversations/session-bundle.constants.js.map +1 -0
- package/dist/infrastructure/conversations/session-bundle.d.ts +6 -0
- package/dist/infrastructure/conversations/session-bundle.js +98 -0
- package/dist/infrastructure/conversations/session-bundle.js.map +1 -0
- package/dist/infrastructure/conversations/session-bundle.types.d.ts +1 -0
- package/dist/infrastructure/conversations/session-bundle.types.js +2 -0
- package/dist/infrastructure/conversations/session-bundle.types.js.map +1 -0
- package/dist/infrastructure/conversations.js +4 -2
- package/dist/infrastructure/conversations.js.map +1 -1
- package/dist/infrastructure/conversations.types.d.ts +1 -1
- package/dist/infrastructure/conversations.types.js.map +1 -1
- package/dist/infrastructure/custom-reporter.js +32 -24
- package/dist/infrastructure/custom-reporter.js.map +1 -1
- package/dist/infrastructure/custom-reporter.types.d.ts +2 -0
- package/dist/infrastructure/custom-reporter.types.js.map +1 -1
- package/dist/infrastructure/git/git.constants.d.ts +1 -1
- package/dist/infrastructure/git/git.constants.js +1 -0
- package/dist/infrastructure/git/git.constants.js.map +1 -1
- package/dist/infrastructure/git/workspace-lease.js +4 -3
- package/dist/infrastructure/git/workspace-lease.js.map +1 -1
- package/dist/infrastructure/git/workspace.js +7 -6
- package/dist/infrastructure/git/workspace.js.map +1 -1
- package/dist/infrastructure/git/workspace.types.d.ts +1 -0
- package/dist/infrastructure/git/workspace.types.js.map +1 -1
- package/dist/infrastructure/host-credentials.constants.d.ts +1 -0
- package/dist/infrastructure/host-credentials.constants.js +2 -0
- package/dist/infrastructure/host-credentials.constants.js.map +1 -0
- package/dist/infrastructure/host-credentials.d.ts +4 -0
- package/dist/infrastructure/host-credentials.js +89 -0
- package/dist/infrastructure/host-credentials.js.map +1 -0
- package/dist/infrastructure/inspection-path.js +4 -3
- package/dist/infrastructure/inspection-path.js.map +1 -1
- package/dist/infrastructure/journal.constants.js +10 -1
- package/dist/infrastructure/journal.constants.js.map +1 -1
- package/dist/infrastructure/journal.d.ts +1 -1
- package/dist/infrastructure/journal.js +8 -75
- package/dist/infrastructure/journal.js.map +1 -1
- package/dist/infrastructure/journal.types.d.ts +2 -4
- package/dist/infrastructure/journal.types.js.map +1 -1
- package/dist/infrastructure/local-transport.js +9 -4
- package/dist/infrastructure/local-transport.js.map +1 -1
- package/dist/infrastructure/opentelemetry-dispatch.d.ts +3 -3
- package/dist/infrastructure/opentelemetry-dispatch.js +5 -4
- package/dist/infrastructure/opentelemetry-dispatch.js.map +1 -1
- package/dist/infrastructure/opentelemetry-observation.d.ts +5 -0
- package/dist/infrastructure/opentelemetry-observation.js +59 -0
- package/dist/infrastructure/opentelemetry-observation.js.map +1 -0
- package/dist/infrastructure/opentelemetry.js +15 -1
- package/dist/infrastructure/opentelemetry.js.map +1 -1
- package/dist/infrastructure/opentelemetry.types.d.ts +9 -1
- package/dist/infrastructure/opentelemetry.types.js.map +1 -1
- package/dist/infrastructure/reporter.d.ts +2 -2
- package/dist/infrastructure/reporter.js +5 -1
- package/dist/infrastructure/reporter.js.map +1 -1
- package/dist/infrastructure/repository-transport.constants.d.ts +1 -0
- package/dist/infrastructure/repository-transport.constants.js +2 -0
- package/dist/infrastructure/repository-transport.constants.js.map +1 -0
- package/dist/infrastructure/repository-transport.d.ts +2 -0
- package/dist/infrastructure/repository-transport.js +9 -0
- package/dist/infrastructure/repository-transport.js.map +1 -0
- package/dist/infrastructure/resource-activity-inspection.js +19 -24
- package/dist/infrastructure/resource-activity-inspection.js.map +1 -1
- package/dist/infrastructure/resource-activity.constants.d.ts +0 -1
- package/dist/infrastructure/resource-activity.constants.js +0 -1
- package/dist/infrastructure/resource-activity.constants.js.map +1 -1
- package/dist/infrastructure/resource-activity.js +20 -83
- package/dist/infrastructure/resource-activity.js.map +1 -1
- package/dist/infrastructure/s3-transport.constants.d.ts +2 -0
- package/dist/infrastructure/s3-transport.constants.js +3 -0
- package/dist/infrastructure/s3-transport.constants.js.map +1 -0
- package/dist/infrastructure/s3-transport.js +57 -3
- package/dist/infrastructure/s3-transport.js.map +1 -1
- package/dist/infrastructure/s3-transport.types.d.ts +1 -0
- package/dist/infrastructure/s3-transport.types.js.map +1 -1
- package/dist/infrastructure/speculation-store.constants.d.ts +3 -0
- package/dist/infrastructure/speculation-store.constants.js +2 -0
- package/dist/infrastructure/speculation-store.constants.js.map +1 -0
- package/dist/infrastructure/speculation-store.d.ts +4 -0
- package/dist/infrastructure/speculation-store.js +73 -0
- package/dist/infrastructure/speculation-store.js.map +1 -0
- package/dist/infrastructure/speculation-store.types.d.ts +12 -0
- package/dist/infrastructure/speculation-store.types.js +2 -0
- package/dist/infrastructure/speculation-store.types.js.map +1 -0
- package/dist/infrastructure/storage-inventory.constants.js +1 -0
- package/dist/infrastructure/storage-inventory.constants.js.map +1 -1
- package/dist/infrastructure/storage-inventory.types.d.ts +1 -1
- package/dist/infrastructure/storage-inventory.types.js.map +1 -1
- package/dist/infrastructure/storage-reservations.types.d.ts +0 -8
- package/dist/infrastructure/storage-reservations.types.js.map +1 -1
- package/dist/infrastructure/task-queue-bullmq-resources.js +3 -0
- package/dist/infrastructure/task-queue-bullmq-resources.js.map +1 -1
- package/dist/infrastructure/task-queue-http.js +29 -4
- package/dist/infrastructure/task-queue-http.js.map +1 -1
- package/dist/infrastructure/task-queue-http.types.d.ts +2 -2
- package/dist/infrastructure/task-queue-http.types.js.map +1 -1
- package/dist/infrastructure/transport-conversations.js +2 -0
- package/dist/infrastructure/transport-conversations.js.map +1 -1
- package/dist/infrastructure/transport-journal.d.ts +1 -1
- package/dist/infrastructure/transport-journal.js +8 -2
- package/dist/infrastructure/transport-journal.js.map +1 -1
- package/dist/infrastructure/transport-reservations.d.ts +1 -1
- package/dist/infrastructure/transport-reservations.js +14 -8
- package/dist/infrastructure/transport-reservations.js.map +1 -1
- package/dist/infrastructure/workflow-decision-signature.constants.d.ts +4 -0
- package/dist/infrastructure/workflow-decision-signature.constants.js +5 -0
- package/dist/infrastructure/workflow-decision-signature.constants.js.map +1 -0
- package/dist/infrastructure/workflow-decision-signature.d.ts +4 -0
- package/dist/infrastructure/workflow-decision-signature.js +83 -0
- package/dist/infrastructure/workflow-decision-signature.js.map +1 -0
- package/dist/infrastructure/workflow-decision-signature.types.d.ts +16 -0
- package/dist/infrastructure/workflow-decision-signature.types.js +2 -0
- package/dist/infrastructure/workflow-decision-signature.types.js.map +1 -0
- package/dist/providers/agents.d.ts +7 -2
- package/dist/providers/agents.js +4 -1
- package/dist/providers/agents.js.map +1 -1
- package/dist/providers/antigravity-install.constants.d.ts +2 -0
- package/dist/providers/antigravity-install.constants.js +28 -0
- package/dist/providers/antigravity-install.constants.js.map +1 -0
- package/dist/providers/antigravity-install.d.ts +2 -0
- package/dist/providers/antigravity-install.js +29 -0
- package/dist/providers/antigravity-install.js.map +1 -0
- package/dist/providers/antigravity-install.types.d.ts +4 -0
- package/dist/providers/antigravity-install.types.js +2 -0
- package/dist/providers/antigravity-install.types.js.map +1 -0
- package/dist/providers/container-recovery.d.ts +4 -0
- package/dist/providers/container-recovery.js +28 -0
- package/dist/providers/container-recovery.js.map +1 -0
- package/dist/providers/container.js +8 -0
- package/dist/providers/container.js.map +1 -1
- package/dist/providers/daytona-network.constants.d.ts +5 -0
- package/dist/providers/daytona-network.constants.js +8 -0
- package/dist/providers/daytona-network.constants.js.map +1 -0
- package/dist/providers/daytona-network.d.ts +4 -0
- package/dist/providers/daytona-network.js +33 -0
- package/dist/providers/daytona-network.js.map +1 -0
- package/dist/providers/daytona.d.ts +1 -0
- package/dist/providers/daytona.js +9 -3
- package/dist/providers/daytona.js.map +1 -1
- package/dist/providers/daytona.types.d.ts +2 -0
- package/dist/providers/daytona.types.js.map +1 -1
- package/dist/providers/firecracker-command.js +1 -1
- package/dist/providers/firecracker-command.js.map +1 -1
- package/dist/providers/firecracker-jailer.constants.d.ts +9 -0
- package/dist/providers/firecracker-jailer.constants.js +10 -0
- package/dist/providers/firecracker-jailer.constants.js.map +1 -0
- package/dist/providers/firecracker-jailer.d.ts +4 -0
- package/dist/providers/firecracker-jailer.js +171 -0
- package/dist/providers/firecracker-jailer.js.map +1 -0
- package/dist/providers/firecracker-machine.js +30 -8
- package/dist/providers/firecracker-machine.js.map +1 -1
- package/dist/providers/firecracker.types.d.ts +16 -0
- package/dist/providers/firecracker.types.js.map +1 -1
- package/dist/providers/vercel-network.js +1 -1
- package/dist/providers/vercel-network.js.map +1 -1
- package/dist/providers/vercel.js +6 -3
- package/dist/providers/vercel.js.map +1 -1
- package/dist/providers/versions.constants.d.ts +3 -1
- package/dist/providers/versions.constants.js +3 -1
- package/dist/providers/versions.constants.js.map +1 -1
- package/package.json +3 -3
- package/dist/adapters/agents/gemini-adapter.d.ts +0 -3
- package/dist/adapters/agents/gemini-adapter.js +0 -34
- package/dist/adapters/agents/gemini-adapter.js.map +0 -1
- package/dist/adapters/agents/gemini-diagnostics.d.ts +0 -2
- package/dist/adapters/agents/gemini-diagnostics.js +0 -15
- package/dist/adapters/agents/gemini-diagnostics.js.map +0 -1
- package/dist/adapters/agents/gemini-events.d.ts +0 -2
- package/dist/adapters/agents/gemini-events.js +0 -50
- package/dist/adapters/agents/gemini-events.js.map +0 -1
- package/dist/adapters/agents/gemini-request.js +0 -23
- package/dist/adapters/agents/gemini-request.js.map +0 -1
- package/dist/adapters/agents/gemini.types.js +0 -2
- package/dist/adapters/agents/gemini.types.js.map +0 -1
- package/dist/infrastructure/artifact-store.d.ts +0 -3
- package/dist/infrastructure/artifact-store.js +0 -110
- package/dist/infrastructure/artifact-store.js.map +0 -1
- package/dist/infrastructure/artifact-store.types.d.ts +0 -6
- package/dist/infrastructure/artifact-store.types.js +0 -2
- package/dist/infrastructure/artifact-store.types.js.map +0 -1
- package/dist/infrastructure/journal-retention.constants.d.ts +0 -4
- package/dist/infrastructure/journal-retention.constants.js +0 -5
- package/dist/infrastructure/journal-retention.constants.js.map +0 -1
- package/dist/infrastructure/journal-retention.d.ts +0 -2
- package/dist/infrastructure/journal-retention.js +0 -51
- package/dist/infrastructure/journal-retention.js.map +0 -1
- package/dist/infrastructure/storage-mutation-lock.constants.d.ts +0 -5
- package/dist/infrastructure/storage-mutation-lock.constants.js +0 -6
- package/dist/infrastructure/storage-mutation-lock.constants.js.map +0 -1
- package/dist/infrastructure/storage-mutation-lock.d.ts +0 -1
- package/dist/infrastructure/storage-mutation-lock.js +0 -21
- package/dist/infrastructure/storage-mutation-lock.js.map +0 -1
- package/dist/infrastructure/storage-reservations.constants.d.ts +0 -4
- package/dist/infrastructure/storage-reservations.constants.js +0 -5
- package/dist/infrastructure/storage-reservations.constants.js.map +0 -1
- package/dist/infrastructure/storage-reservations.d.ts +0 -2
- package/dist/infrastructure/storage-reservations.js +0 -150
- package/dist/infrastructure/storage-reservations.js.map +0 -1
- package/dist/infrastructure/workflow-checkpoint.d.ts +0 -3
- package/dist/infrastructure/workflow-checkpoint.js +0 -84
- package/dist/infrastructure/workflow-checkpoint.js.map +0 -1
- package/dist/infrastructure/workflow-checkpoint.types.d.ts +0 -6
- package/dist/infrastructure/workflow-checkpoint.types.js +0 -2
- package/dist/infrastructure/workflow-checkpoint.types.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"harness.types.js","sourceRoot":"","sources":["../../src/application/harness.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { AgentEvent, CustomAgent } from \"../domain/agent.types.ts\";\nimport type {\n ModelContentBlock,\n ModelMessage,\n ModelProvider,\n ModelResult,\n ModelToolCallBlock,\n} from \"../domain/model.types.ts\";\nimport type { SandboxLease } from \"../domain/sandbox.types.ts\";\nimport type { HarnessTool } from \"../domain/tool.types.ts\";\nimport type { DispatchOptions, TurnContext } from \"./execution.types.ts\";\n\nexport interface HarnessRuntime {\n readonly agent: CustomAgent;\n readonly tools: readonly HarnessTool[];\n readonly modelProvider: ModelProvider;\n readonly sandbox: SandboxLease;\n readonly signal: AbortSignal;\n emit(event: AgentEvent): void;\n hold(): () => void;\n}\n\nexport interface ToolCallBatch {\n readonly concurrent: boolean;\n readonly calls: readonly PreparedCall[];\n}\n\nexport type ValidatedInput =\n { readonly value: unknown } | { readonly outcome: ToolOutcome };\n\nexport interface ToolOutcome {\n readonly content: string;\n readonly isError: boolean;\n}\n\nexport interface HarnessHistory {\n readonly messages: readonly ModelMessage[];\n append(message: ModelMessage): Promise<void>;\n replace(messages: readonly ModelMessage[]): Promise<void>;\n}\n\nexport interface CustomTurnContext extends TurnContext {\n readonly continuation?: DispatchOptions[\"continuation\"];\n}\n\nexport interface LoopState {\n readonly history: HarnessHistory;\n readonly step: number;\n toolCalls: number;\n}\n\nexport type StopHandler = (\n runtime: HarnessRuntime,\n state: LoopState,\n result: ModelResult,\n content: readonly ModelContentBlock[],\n) => Promise<string | undefined>;\n\nexport interface PreparedCall {\n readonly call: ModelToolCallBlock;\n readonly tool?: HarnessTool;\n readonly input?: unknown;\n readonly outcome?: ToolOutcome;\n}\n\nexport interface ToolDenial {\n readonly deny: string;\n}\n\nexport type BlockRenderers = {\n readonly [Type in ModelContentBlock[\"type\"]]: (\n block: Extract<ModelContentBlock, { type: Type }>,\n ) => string;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"harness.types.js","sourceRoot":"","sources":["../../src/application/harness.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { HarnessBudget } from \"./harness-budget.types.ts\";\nimport type { HarnessPermissions } from \"../domain/permissions.types.ts\";\nimport type { HarnessModelScope } from \"./harness-model-provider.types.ts\";\nimport type { AgentEvent, CustomAgent } from \"../domain/agent.types.ts\";\nimport type {\n ModelContentBlock,\n ModelMessage,\n ModelProvider,\n ModelResult,\n ModelToolCallBlock,\n} from \"../domain/model.types.ts\";\nimport type { SandboxLease } from \"../domain/sandbox.types.ts\";\nimport type { HarnessTool } from \"../domain/tool.types.ts\";\nimport type { DispatchOptions, TurnContext } from \"./execution.types.ts\";\n\nexport interface HarnessRuntime {\n readonly verbose?: boolean;\n readonly repository: string;\n readonly conversation?: string | undefined;\n readonly budget: HarnessBudget;\n readonly permissions: readonly HarnessPermissions[];\n readonly depth: number;\n readonly maxDepth: number;\n readonly modelScope: Pick<HarnessModelScope, \"track\" | \"account\">;\n readonly agent: CustomAgent;\n readonly tools: readonly HarnessTool[];\n readonly modelProvider: ModelProvider;\n readonly sandbox: SandboxLease;\n readonly signal: AbortSignal;\n emit(event: AgentEvent): void;\n hold(): () => void;\n}\n\nexport interface ToolCallBatch {\n readonly concurrent: boolean;\n readonly calls: readonly PreparedCall[];\n}\n\nexport type ValidatedInput =\n { readonly value: unknown } | { readonly outcome: ToolOutcome };\n\nexport interface ToolOutcome {\n readonly content: string;\n readonly isError: boolean;\n}\n\nexport interface HarnessHistory {\n readonly messages: readonly ModelMessage[];\n append(message: ModelMessage): Promise<void>;\n replace(messages: readonly ModelMessage[]): Promise<void>;\n}\n\nexport interface CustomTurnContext extends TurnContext {\n readonly continuation?: DispatchOptions[\"continuation\"];\n}\n\nexport interface LoopState {\n readonly history: HarnessHistory;\n readonly step: number;\n toolCalls: number;\n}\n\nexport type StopHandler = (\n runtime: HarnessRuntime,\n state: LoopState,\n result: ModelResult,\n content: readonly ModelContentBlock[],\n) => Promise<string | undefined>;\n\nexport interface PreparedCall {\n readonly call: ModelToolCallBlock;\n readonly tool?: HarnessTool;\n readonly input?: unknown;\n readonly outcome?: ToolOutcome;\n}\n\nexport interface ToolDenial {\n readonly deny: string;\n}\n\nexport type BlockRenderers = {\n readonly [Type in ModelContentBlock[\"type\"]]: (\n block: Extract<ModelContentBlock, { type: Type }>,\n ) => string;\n};\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Command } from "../domain/command.types.ts";
|
|
2
2
|
import type { SandboxLease } from "../domain/sandbox.types.ts";
|
|
3
|
-
export declare function hooks(commands: readonly Command[], directory: string, invoke: SandboxLease["invoke"], signal?: AbortSignal, parallel?: boolean): Promise<void>;
|
|
3
|
+
export declare function hooks(commands: readonly Command[], directory: string, invoke: SandboxLease["invoke"], signal?: AbortSignal, parallel?: boolean, observation?: import("../domain/observation.types.ts").ObservationHub): Promise<void>;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { observedOperation } from "../domain/observed-operation.js";
|
|
1
2
|
import { requireSuccess } from "../infrastructure/process.js";
|
|
2
3
|
import { hookDeadlineMs } from "./lifecycle.constants.js";
|
|
3
|
-
export async function hooks(commands, directory, invoke, signal, parallel = false) {
|
|
4
|
+
export async function hooks(commands, directory, invoke, signal, parallel = false, observation) {
|
|
4
5
|
if (parallel) {
|
|
5
6
|
const controller = new AbortController();
|
|
6
7
|
const combined = signal
|
|
7
8
|
? AbortSignal.any([signal, controller.signal])
|
|
8
9
|
: controller.signal;
|
|
9
|
-
const outcomes = await Promise.allSettled(commands.map((command) => hooks([command], directory, invoke, combined).catch((cause) => {
|
|
10
|
+
const outcomes = await Promise.allSettled(commands.map((command) => hooks([command], directory, invoke, combined, false, observation).catch((cause) => {
|
|
10
11
|
controller.abort(cause);
|
|
11
12
|
throw cause;
|
|
12
13
|
})));
|
|
@@ -16,11 +17,11 @@ export async function hooks(commands, directory, invoke, signal, parallel = fals
|
|
|
16
17
|
return;
|
|
17
18
|
}
|
|
18
19
|
for (const command of commands)
|
|
19
|
-
await requireSuccess({
|
|
20
|
+
await observedOperation(observation, "hooks", "lifecycle.command", async () => requireSuccess({
|
|
20
21
|
...command,
|
|
21
22
|
directory: command.directory ?? directory,
|
|
22
23
|
deadlineMs: command.deadlineMs ?? hookDeadlineMs,
|
|
23
24
|
...(signal ? { signal } : {}),
|
|
24
|
-
}, invoke);
|
|
25
|
+
}, invoke));
|
|
25
26
|
}
|
|
26
27
|
//# sourceMappingURL=lifecycle-hooks.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle-hooks.js","sourceRoot":"","sources":["../../src/application/lifecycle-hooks.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lifecycle-hooks.js","sourceRoot":"","sources":["../../src/application/lifecycle-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAGpE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,MAAM,CAAC,KAAK,UAAU,KAAK,CACzB,QAA4B,EAC5B,SAAiB,EACjB,MAA8B,EAC9B,MAAoB,EACpB,QAAQ,GAAG,KAAK,EAChB,WAAqE;IAErE,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;QACzC,MAAM,QAAQ,GAAG,MAAM;YACrB,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;YAC9C,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC;QACtB,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,UAAU,CACvC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CACvB,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,KAAK,CACrE,CAAC,KAAK,EAAE,EAAE;YACR,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACxB,MAAM,KAAK,CAAC;QACd,CAAC,CACF,CACF,CACF,CAAC;QACF,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC;QAC1E,IAAI,OAAO,EAAE,MAAM,KAAK,UAAU;YAAE,MAAM,OAAO,CAAC,MAAM,CAAC;QACzD,OAAO;IACT,CAAC;IACD,KAAK,MAAM,OAAO,IAAI,QAAQ;QAC5B,MAAM,iBAAiB,CACrB,WAAW,EACX,OAAO,EACP,mBAAmB,EACnB,KAAK,IAAI,EAAE,CACT,cAAc,CACZ;YACE,GAAG,OAAO;YACV,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,SAAS;YACzC,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,cAAc;YAChD,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC9B,EACD,MAAM,CACP,CACJ,CAAC;AACN,CAAC","sourcesContent":["import { observedOperation } from \"../domain/observed-operation.ts\";\nimport type { Command } from \"../domain/command.types.ts\";\nimport type { SandboxLease } from \"../domain/sandbox.types.ts\";\nimport { requireSuccess } from \"../infrastructure/process.ts\";\nimport { hookDeadlineMs } from \"./lifecycle.constants.ts\";\n\nexport async function hooks(\n commands: readonly Command[],\n directory: string,\n invoke: SandboxLease[\"invoke\"],\n signal?: AbortSignal,\n parallel = false,\n observation?: import(\"../domain/observation.types.ts\").ObservationHub,\n): Promise<void> {\n if (parallel) {\n const controller = new AbortController();\n const combined = signal\n ? AbortSignal.any([signal, controller.signal])\n : controller.signal;\n const outcomes = await Promise.allSettled(\n commands.map((command) =>\n hooks([command], directory, invoke, combined, false, observation).catch(\n (cause) => {\n controller.abort(cause);\n throw cause;\n },\n ),\n ),\n );\n const failure = outcomes.find((outcome) => outcome.status === \"rejected\");\n if (failure?.status === \"rejected\") throw failure.reason;\n return;\n }\n for (const command of commands)\n await observedOperation(\n observation,\n \"hooks\",\n \"lifecycle.command\",\n async () =>\n requireSuccess(\n {\n ...command,\n directory: command.directory ?? directory,\n deadlineMs: command.deadlineMs ?? hookDeadlineMs,\n ...(signal ? { signal } : {}),\n },\n invoke,\n ),\n );\n}\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { observedOperation } from "../domain/observed-operation.js";
|
|
2
|
+
export function observedLease(lease, observation) {
|
|
3
|
+
if (!observation)
|
|
4
|
+
return lease;
|
|
5
|
+
return {
|
|
6
|
+
...lease,
|
|
7
|
+
invoke: lease.invoke.bind(lease),
|
|
8
|
+
...(lease.fileTransfers
|
|
9
|
+
? {
|
|
10
|
+
fileTransfers: {
|
|
11
|
+
manifest: (source, paths, options) => observedOperation(observation, "transfer", "files.manifest", () => lease.fileTransfers.manifest(source, paths, options)),
|
|
12
|
+
downloadBatch: (source, entries, destination, options) => observedOperation(observation, "transfer", "files.download", () => lease.fileTransfers.downloadBatch(source, entries, destination, options)),
|
|
13
|
+
...(lease.fileTransfers.uploadBatch
|
|
14
|
+
? {
|
|
15
|
+
uploadBatch: (source, entries, destination, options) => observedOperation(observation, "transfer", "files.upload", () => lease.fileTransfers.uploadBatch(source, entries, destination, options)),
|
|
16
|
+
}
|
|
17
|
+
: {}),
|
|
18
|
+
},
|
|
19
|
+
}
|
|
20
|
+
: {}),
|
|
21
|
+
upload: (source, destination, settings) => observedOperation(observation, "transfer", "file.upload", () => lease.upload(source, destination, settings)),
|
|
22
|
+
download: (source, destination, settings) => observedOperation(observation, "transfer", "file.download", () => lease.download(source, destination, settings)),
|
|
23
|
+
release: () => observedOperation(observation, "sandbox", "sandbox.release", () => lease.release()),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=observed-lease.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observed-lease.js","sourceRoot":"","sources":["../../src/application/observed-lease.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAEpE,MAAM,UAAU,aAAa,CAC3B,KAAmB,EACnB,WAA4B;IAE5B,IAAI,CAAC,WAAW;QAAE,OAAO,KAAK,CAAC;IAC/B,OAAO;QACL,GAAG,KAAK;QACR,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;QAChC,GAAG,CAAC,KAAK,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,EAAE,CAC/D,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,CAAC,CAC9C;QACH,OAAO,EAAE,GAAG,EAAE,CACZ,iBAAiB,CAAC,WAAW,EAAE,SAAS,EAAE,iBAAiB,EAAE,GAAG,EAAE,CAChE,KAAK,CAAC,OAAO,EAAE,CAChB;KACJ,CAAC;AACJ,CAAC","sourcesContent":["import type { ObservationHub } from \"../domain/observation.types.ts\";\nimport type { SandboxLease } from \"../domain/sandbox.types.ts\";\nimport { observedOperation } from \"../domain/observed-operation.ts\";\n\nexport function observedLease(\n lease: SandboxLease,\n observation?: ObservationHub,\n): SandboxLease {\n if (!observation) return lease;\n return {\n ...lease,\n invoke: lease.invoke.bind(lease),\n ...(lease.fileTransfers\n ? {\n fileTransfers: {\n manifest: (source, paths, options) =>\n observedOperation(observation, \"transfer\", \"files.manifest\", () =>\n lease.fileTransfers!.manifest(source, paths, options),\n ),\n downloadBatch: (source, entries, destination, options) =>\n observedOperation(observation, \"transfer\", \"files.download\", () =>\n lease.fileTransfers!.downloadBatch(\n source,\n entries,\n destination,\n options,\n ),\n ),\n ...(lease.fileTransfers.uploadBatch\n ? {\n uploadBatch: (\n source: string,\n entries: readonly import(\"../domain/sandbox.types.ts\").FileManifestEntry[],\n destination: string,\n options?: import(\"../domain/sandbox.types.ts\").TransferOptions,\n ) =>\n observedOperation(\n observation,\n \"transfer\",\n \"files.upload\",\n () =>\n lease.fileTransfers!.uploadBatch!(\n source,\n entries,\n destination,\n options,\n ),\n ),\n }\n : {}),\n },\n }\n : {}),\n upload: (source, destination, settings) =>\n observedOperation(observation, \"transfer\", \"file.upload\", () =>\n lease.upload(source, destination, settings),\n ),\n download: (source, destination, settings) =>\n observedOperation(observation, \"transfer\", \"file.download\", () =>\n lease.download(source, destination, settings),\n ),\n release: () =>\n observedOperation(observation, \"sandbox\", \"sandbox.release\", () =>\n lease.release(),\n ),\n };\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ObservationHub } from "../domain/observation.types.ts";
|
|
1
2
|
import type { Transport, TransportReference } from "../domain/transport.types.ts";
|
|
2
3
|
import type { Agent } from "../domain/agent.types.ts";
|
|
3
4
|
import type { Command, CommandResult } from "../domain/command.types.ts";
|
|
@@ -10,6 +11,7 @@ import type { SandboxDiagnosticOptions, SandboxDiagnosticReport } from "./doctor
|
|
|
10
11
|
import type { DispatchOptions, Execution } from "./execution.types.ts";
|
|
11
12
|
import type { VariableQuestion } from "./interactive-brief.types.ts";
|
|
12
13
|
export interface WorkspaceOptions {
|
|
14
|
+
readonly observation?: ObservationHub;
|
|
13
15
|
readonly storageQuota?: Omit<StorageReservationOptions, "signal">;
|
|
14
16
|
readonly signal?: AbortSignal;
|
|
15
17
|
readonly repository?: string;
|
|
@@ -63,13 +65,13 @@ export interface AttachResult extends CommandResult, Disposal {
|
|
|
63
65
|
readonly directory: string;
|
|
64
66
|
}
|
|
65
67
|
export interface DispatchResult<T> extends Execution<T> {
|
|
68
|
+
readonly observerErrors?: readonly unknown[];
|
|
66
69
|
readonly branch: string;
|
|
67
70
|
readonly directory: string;
|
|
68
71
|
readonly commits: readonly Commit[];
|
|
69
72
|
readonly transcript?: string;
|
|
70
73
|
readonly transcriptReference?: TransportReference;
|
|
71
74
|
readonly logReference?: TransportReference;
|
|
72
|
-
readonly log?: string;
|
|
73
75
|
readonly retainedDirectory?: string;
|
|
74
76
|
resume<U = undefined>(options: ContinuationOptions<U>): Promise<DispatchResult<U>>;
|
|
75
77
|
fork<U = undefined>(options: ContinuationOptions<U>): Promise<DispatchResult<U>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outpost.types.js","sourceRoot":"","sources":["../../src/application/outpost.types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n Transport,\n TransportReference,\n} from \"../domain/transport.types.ts\";\nimport type { Agent } from \"../domain/agent.types.ts\";\nimport type { Command, CommandResult } from \"../domain/command.types.ts\";\nimport type { Brief } from \"../domain/prompts.types.ts\";\nimport type { SandboxProvider } from \"../domain/sandbox.types.ts\";\nimport type {\n BranchPolicy,\n Commit,\n Disposal,\n LifecycleHooks,\n StageLimits,\n WorkspaceRecord,\n} from \"../domain/workspace.types.ts\";\nimport type { StorageReservationOptions } from \"../infrastructure/storage-reservations.types.ts\";\nimport type { Logging } from \"../infrastructure/journal.types.ts\";\nimport type {\n SandboxDiagnosticOptions,\n SandboxDiagnosticReport,\n} from \"./doctor-sandbox.types.ts\";\nimport type { DispatchOptions, Execution } from \"./execution.types.ts\";\nimport type { VariableQuestion } from \"./interactive-brief.types.ts\";\n\nexport interface WorkspaceOptions {\n readonly storageQuota?: Omit<StorageReservationOptions, \"signal\">;\n readonly signal?: AbortSignal;\n readonly repository?: string;\n readonly branch?: BranchPolicy;\n readonly copies?: readonly string[];\n readonly limits?: StageLimits;\n readonly label?: string;\n readonly hooks?: LifecycleHooks;\n}\n\nexport interface Workspace extends WorkspaceRecord {\n dispatch<T = undefined>(\n options: Omit<\n SandboxOptions,\n Exclude<keyof WorkspaceOptions, \"hooks\" | \"label\"> | \"workspace\"\n > &\n DispatchOptions<T> & { readonly agent: Agent },\n ): Promise<DispatchResult<T>>;\n sandbox(\n options?: Omit<\n SandboxOptions,\n Exclude<keyof WorkspaceOptions, \"hooks\" | \"label\"> | \"workspace\"\n >,\n ): Promise<Sandbox>;\n attach(\n options: Omit<\n SandboxOptions,\n Exclude<keyof WorkspaceOptions, \"hooks\" | \"label\"> | \"workspace\"\n > &\n AttachOptions & { readonly agent: Agent },\n ): Promise<AttachResult>;\n close(options?: { readonly preserve?: boolean }): Promise<Disposal>;\n integrate(): Promise<void>;\n [Symbol.asyncDispose](): Promise<void>;\n}\n\nexport interface SandboxOptions extends WorkspaceOptions {\n readonly includeUncommitted?: boolean;\n readonly agent?: Agent;\n readonly sandboxProvider?: SandboxProvider;\n readonly workspace?: Workspace;\n readonly hooks?: LifecycleHooks;\n readonly signal?: AbortSignal;\n readonly logging?: Logging;\n readonly bootstrap?: boolean;\n readonly conversationHome?: string;\n readonly recoveryTransport?: Transport;\n readonly activityTransport?: Transport;\n}\n\nexport interface AttachOptions {\n readonly ask?: VariableQuestion;\n readonly agent?: Agent;\n readonly brief?: Brief;\n readonly continuation?: { readonly id: string; readonly fork?: boolean };\n readonly signal?: AbortSignal;\n readonly terminal?: Command[\"terminal\"];\n}\n\nexport interface AttachResult extends CommandResult, Disposal {\n readonly commits: readonly Commit[];\n readonly branch: string;\n readonly directory: string;\n}\n\nexport interface DispatchResult<T> extends Execution<T> {\n readonly branch: string;\n readonly directory: string;\n readonly commits: readonly Commit[];\n readonly transcript?: string;\n readonly transcriptReference?: TransportReference;\n readonly logReference?: TransportReference;\n readonly
|
|
1
|
+
{"version":3,"file":"outpost.types.js","sourceRoot":"","sources":["../../src/application/outpost.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ObservationHub } from \"../domain/observation.types.ts\";\nimport type {\n Transport,\n TransportReference,\n} from \"../domain/transport.types.ts\";\nimport type { Agent } from \"../domain/agent.types.ts\";\nimport type { Command, CommandResult } from \"../domain/command.types.ts\";\nimport type { Brief } from \"../domain/prompts.types.ts\";\nimport type { SandboxProvider } from \"../domain/sandbox.types.ts\";\nimport type {\n BranchPolicy,\n Commit,\n Disposal,\n LifecycleHooks,\n StageLimits,\n WorkspaceRecord,\n} from \"../domain/workspace.types.ts\";\nimport type { StorageReservationOptions } from \"../infrastructure/storage-reservations.types.ts\";\nimport type { Logging } from \"../infrastructure/journal.types.ts\";\nimport type {\n SandboxDiagnosticOptions,\n SandboxDiagnosticReport,\n} from \"./doctor-sandbox.types.ts\";\nimport type { DispatchOptions, Execution } from \"./execution.types.ts\";\nimport type { VariableQuestion } from \"./interactive-brief.types.ts\";\n\nexport interface WorkspaceOptions {\n readonly observation?: ObservationHub;\n readonly storageQuota?: Omit<StorageReservationOptions, \"signal\">;\n readonly signal?: AbortSignal;\n readonly repository?: string;\n readonly branch?: BranchPolicy;\n readonly copies?: readonly string[];\n readonly limits?: StageLimits;\n readonly label?: string;\n readonly hooks?: LifecycleHooks;\n}\n\nexport interface Workspace extends WorkspaceRecord {\n dispatch<T = undefined>(\n options: Omit<\n SandboxOptions,\n Exclude<keyof WorkspaceOptions, \"hooks\" | \"label\"> | \"workspace\"\n > &\n DispatchOptions<T> & { readonly agent: Agent },\n ): Promise<DispatchResult<T>>;\n sandbox(\n options?: Omit<\n SandboxOptions,\n Exclude<keyof WorkspaceOptions, \"hooks\" | \"label\"> | \"workspace\"\n >,\n ): Promise<Sandbox>;\n attach(\n options: Omit<\n SandboxOptions,\n Exclude<keyof WorkspaceOptions, \"hooks\" | \"label\"> | \"workspace\"\n > &\n AttachOptions & { readonly agent: Agent },\n ): Promise<AttachResult>;\n close(options?: { readonly preserve?: boolean }): Promise<Disposal>;\n integrate(): Promise<void>;\n [Symbol.asyncDispose](): Promise<void>;\n}\n\nexport interface SandboxOptions extends WorkspaceOptions {\n readonly includeUncommitted?: boolean;\n readonly agent?: Agent;\n readonly sandboxProvider?: SandboxProvider;\n readonly workspace?: Workspace;\n readonly hooks?: LifecycleHooks;\n readonly signal?: AbortSignal;\n readonly logging?: Logging;\n readonly bootstrap?: boolean;\n readonly conversationHome?: string;\n readonly recoveryTransport?: Transport;\n readonly activityTransport?: Transport;\n}\n\nexport interface AttachOptions {\n readonly ask?: VariableQuestion;\n readonly agent?: Agent;\n readonly brief?: Brief;\n readonly continuation?: { readonly id: string; readonly fork?: boolean };\n readonly signal?: AbortSignal;\n readonly terminal?: Command[\"terminal\"];\n}\n\nexport interface AttachResult extends CommandResult, Disposal {\n readonly commits: readonly Commit[];\n readonly branch: string;\n readonly directory: string;\n}\n\nexport interface DispatchResult<T> extends Execution<T> {\n readonly observerErrors?: readonly unknown[];\n readonly branch: string;\n readonly directory: string;\n readonly commits: readonly Commit[];\n readonly transcript?: string;\n readonly transcriptReference?: TransportReference;\n readonly logReference?: TransportReference;\n readonly retainedDirectory?: string;\n resume<U = undefined>(\n options: ContinuationOptions<U>,\n ): Promise<DispatchResult<U>>;\n fork<U = undefined>(\n options: ContinuationOptions<U>,\n ): Promise<DispatchResult<U>>;\n}\n\nexport type ContinuationOptions<T = undefined> = DispatchOptions<T> &\n Omit<SandboxOptions, \"agent\">;\n\nexport interface WarmDispatchResult<T> extends Omit<\n DispatchResult<T>,\n \"resume\" | \"fork\"\n> {\n resume<U = undefined>(\n options: DispatchOptions<U>,\n ): Promise<WarmDispatchResult<U>>;\n fork<U = undefined>(\n options: DispatchOptions<U>,\n ): Promise<WarmDispatchResult<U>>;\n}\n\nexport interface Sandbox {\n diagnose(\n options?: SandboxDiagnosticOptions,\n ): Promise<SandboxDiagnosticReport>;\n readonly workspace: Workspace;\n readonly root: string;\n dispatch<T = undefined>(\n options: DispatchOptions<T>,\n ): Promise<WarmDispatchResult<T>>;\n resume<T = undefined>(\n id: string,\n options: DispatchOptions<T>,\n ): Promise<WarmDispatchResult<T>>;\n fork<T = undefined>(\n id: string,\n options: DispatchOptions<T>,\n ): Promise<WarmDispatchResult<T>>;\n attach(options?: AttachOptions): Promise<AttachResult>;\n command(command: Command): Promise<CommandResult>;\n close(options?: { readonly preserve?: boolean }): Promise<Disposal>;\n [Symbol.asyncDispose](): Promise<void>;\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { observationDefaults } from "../domain/observation.constants.js";
|
|
2
|
+
export function boundedLines(emit) {
|
|
3
|
+
let pending = "";
|
|
4
|
+
const limit = observationDefaults.outputCharacters;
|
|
5
|
+
return {
|
|
6
|
+
append(chunk) {
|
|
7
|
+
for (let offset = 0; offset < chunk.length; offset += limit) {
|
|
8
|
+
pending += chunk.slice(offset, offset + limit);
|
|
9
|
+
let end;
|
|
10
|
+
while ((end = pending.indexOf("\n")) >= 0) {
|
|
11
|
+
const line = pending.slice(0, end);
|
|
12
|
+
emit(line.slice(0, limit), line.length > limit);
|
|
13
|
+
pending = pending.slice(end + 1);
|
|
14
|
+
}
|
|
15
|
+
if (pending.length >= limit) {
|
|
16
|
+
emit(pending.slice(0, limit), true);
|
|
17
|
+
pending = pending.slice(limit);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
flush() {
|
|
22
|
+
if (pending)
|
|
23
|
+
emit(pending, false);
|
|
24
|
+
pending = "";
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=output-lines.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-lines.js","sourceRoot":"","sources":["../../src/application/output-lines.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAEzE,MAAM,UAAU,YAAY,CAAC,IAAgD;IAC3E,IAAI,OAAO,GAAG,EAAE,CAAC;IACjB,MAAM,KAAK,GAAG,mBAAmB,CAAC,gBAAgB,CAAC;IACnD,OAAO;QACL,MAAM,CAAC,KAAa;YAClB,KAAK,IAAI,MAAM,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,MAAM,IAAI,KAAK,EAAE,CAAC;gBAC5D,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC;gBAC/C,IAAI,GAAW,CAAC;gBAChB,OAAO,CAAC,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;oBAC1C,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;oBACnC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC;oBAChD,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;gBACnC,CAAC;gBACD,IAAI,OAAO,CAAC,MAAM,IAAI,KAAK,EAAE,CAAC;oBAC5B,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC;oBACpC,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;gBACjC,CAAC;YACH,CAAC;QACH,CAAC;QACD,KAAK;YACH,IAAI,OAAO;gBAAE,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAClC,OAAO,GAAG,EAAE,CAAC;QACf,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { observationDefaults } from \"../domain/observation.constants.ts\";\n\nexport function boundedLines(emit: (text: string, truncated: boolean) => void) {\n let pending = \"\";\n const limit = observationDefaults.outputCharacters;\n return {\n append(chunk: string) {\n for (let offset = 0; offset < chunk.length; offset += limit) {\n pending += chunk.slice(offset, offset + limit);\n let end: number;\n while ((end = pending.indexOf(\"\\n\")) >= 0) {\n const line = pending.slice(0, end);\n emit(line.slice(0, limit), line.length > limit);\n pending = pending.slice(end + 1);\n }\n if (pending.length >= limit) {\n emit(pending.slice(0, limit), true);\n pending = pending.slice(limit);\n }\n }\n },\n flush() {\n if (pending) emit(pending, false);\n pending = \"\";\n },\n };\n}\n"]}
|
|
@@ -37,7 +37,7 @@ export async function runQueueWorker(options) {
|
|
|
37
37
|
throw new Error("Worker handler unavailable");
|
|
38
38
|
let result;
|
|
39
39
|
try {
|
|
40
|
-
result = queueResult(await handler(job.input, { signal, job }));
|
|
40
|
+
result = queueResult(await handler(job.input, { signal, job, idempotencyKey: job.id }));
|
|
41
41
|
}
|
|
42
42
|
catch (error) {
|
|
43
43
|
result = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue-worker.js","sourceRoot":"","sources":["../../src/application/queue-worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,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,QAAQ,CAAC,IAAI,EAAE,CAAC;gBAC9B,OAAO;aACR,CAAC,CAAC;YACH,IAAI,GAAG,EAAE,CAAC;gBACR,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC;gBACnB,SAAS;YACX,CAAC;YACD,MAAM,KAAK,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO;YAAE,MAAM,KAAK,CAAC;IAC3C,CAAC;AACH,CAAC","sourcesContent":["import { setTimeout as delay } from \"node:timers/promises\";\nimport {\n queueMaxStringLength,\n queueDefaultLeaseMs,\n queueDefaultPollMs,\n} from \"../domain/task-queue.constants.ts\";\nimport {\n queueLeaseMs,\n queueNumber,\n queueString,\n queueResult,\n} from \"../domain/task-queue.ts\";\nimport type { QueueWorkerOptions } from \"./queue-worker.types.ts\";\nimport type { QueueJob, QueueResult } from \"../domain/task-queue.types.ts\";\n\nexport async function runQueueWorker(\n options: QueueWorkerOptions,\n): Promise<void> {\n const leaseMs = queueLeaseMs(options.leaseMs ?? queueDefaultLeaseMs);\n const pollMs = queueNumber(options.pollMs ?? queueDefaultPollMs);\n if (!pollMs) throw new Error(\"Worker poll interval must be positive\");\n const handlers = new Map(Object.entries(options.handlers));\n if (\n !handlers.size ||\n [...handlers.values()].some((handler) => typeof handler !== \"function\")\n )\n throw new Error(\"Worker requires trusted handlers\");\n const worker = queueString(options.worker);\n async function execute(job: QueueJob) {\n if (options.signal.aborted) return;\n const stop = new AbortController();\n const signal = AbortSignal.any([options.signal, stop.signal]);\n const lease = { id: job.id, worker, fence: job.fence };\n const heartbeat = (async () => {\n try {\n while (!signal.aborted) {\n await delay(Math.max(10, Math.floor(leaseMs / 3)), undefined, {\n signal,\n });\n await options.queue.renew(lease, leaseMs);\n }\n } catch (error) {\n if (!signal.aborted) stop.abort(error);\n }\n })();\n try {\n const handler = handlers.get(job.handler);\n if (!handler) throw new Error(\"Worker handler unavailable\");\n let result: QueueResult;\n try {\n result = queueResult(\n await handler(job.input, { signal, job, idempotencyKey: job.id }),\n );\n } catch (error) {\n result = {\n value: null,\n error:\n (error instanceof Error ? error.message : String(error)).slice(\n 0,\n queueMaxStringLength,\n ) || \"Queue handler failed\",\n };\n }\n if (!signal.aborted) await options.queue.complete(lease, result);\n } finally {\n stop.abort();\n await heartbeat;\n }\n }\n try {\n while (!options.signal.aborted) {\n const job = await options.queue.claim({\n worker,\n handlers: [...handlers.keys()],\n leaseMs,\n });\n if (job) {\n await execute(job);\n continue;\n }\n await delay(pollMs, undefined, { signal: options.signal });\n }\n } catch (error) {\n if (!options.signal.aborted) throw error;\n }\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { QueueJob, QueueResult, TaskQueue } from "../domain/task-queue.types.ts";
|
|
2
2
|
import type { WorkflowJson } from "../domain/workflow/checkpoint.types.ts";
|
|
3
3
|
export interface QueueHandlerContext {
|
|
4
|
+
readonly idempotencyKey: string;
|
|
4
5
|
readonly signal: AbortSignal;
|
|
5
6
|
readonly job: QueueJob;
|
|
6
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue-worker.types.js","sourceRoot":"","sources":["../../src/application/queue-worker.types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n QueueJob,\n QueueResult,\n TaskQueue,\n} from \"../domain/task-queue.types.ts\";\nimport type { WorkflowJson } from \"../domain/workflow/checkpoint.types.ts\";\nexport interface QueueHandlerContext {\n readonly signal: AbortSignal;\n readonly job: QueueJob;\n}\nexport type QueueHandler = (\n input: WorkflowJson,\n context: QueueHandlerContext,\n) => Promise<QueueResult> | QueueResult;\nexport interface QueueWorkerOptions {\n readonly queue: TaskQueue;\n readonly worker: string;\n readonly handlers: Readonly<Record<string, QueueHandler>>;\n readonly signal: AbortSignal;\n readonly leaseMs?: number;\n readonly pollMs?: number;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"queue-worker.types.js","sourceRoot":"","sources":["../../src/application/queue-worker.types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n QueueJob,\n QueueResult,\n TaskQueue,\n} from \"../domain/task-queue.types.ts\";\nimport type { WorkflowJson } from \"../domain/workflow/checkpoint.types.ts\";\nexport interface QueueHandlerContext {\n readonly idempotencyKey: string;\n readonly signal: AbortSignal;\n readonly job: QueueJob;\n}\nexport type QueueHandler = (\n input: WorkflowJson,\n context: QueueHandlerContext,\n) => Promise<QueueResult> | QueueResult;\nexport interface QueueWorkerOptions {\n readonly queue: TaskQueue;\n readonly worker: string;\n readonly handlers: Readonly<Record<string, QueueHandler>>;\n readonly signal: AbortSignal;\n readonly leaseMs?: number;\n readonly pollMs?: number;\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { taskIdempotencyKey } from "../domain/workflow/idempotency.js";
|
|
2
2
|
import { setTimeout as delay } from "node:timers/promises";
|
|
3
3
|
import { task } from "../domain/workflow.js";
|
|
4
4
|
import { queueDefaultPollMs } from "../domain/task-queue.constants.js";
|
|
@@ -14,15 +14,18 @@ export function queuedTask(options) {
|
|
|
14
14
|
...definition,
|
|
15
15
|
async perform(context) {
|
|
16
16
|
context.signal.throwIfAborted();
|
|
17
|
-
const id =
|
|
18
|
-
.update(JSON.stringify([context.executionId, definition.key]))
|
|
19
|
-
.digest("hex");
|
|
17
|
+
const id = taskIdempotencyKey(context.executionId, definition.key);
|
|
20
18
|
let job = await queue.enqueue({
|
|
21
19
|
id,
|
|
22
20
|
handler,
|
|
23
21
|
input: input(context),
|
|
24
22
|
...(deadline === undefined ? {} : { deadline }),
|
|
25
23
|
});
|
|
24
|
+
context.observation?.emit("workflow", {
|
|
25
|
+
kind: "queue",
|
|
26
|
+
id,
|
|
27
|
+
status: "enqueued",
|
|
28
|
+
});
|
|
26
29
|
try {
|
|
27
30
|
while (job.status === "pending" || job.status === "active") {
|
|
28
31
|
await delay(pollMs, undefined, { signal: context.signal });
|
|
@@ -30,6 +33,11 @@ export function queuedTask(options) {
|
|
|
30
33
|
if (!latest)
|
|
31
34
|
throw new Error("Queued workflow job disappeared");
|
|
32
35
|
job = latest;
|
|
36
|
+
context.observation?.emit("workflow", {
|
|
37
|
+
kind: "queue",
|
|
38
|
+
id,
|
|
39
|
+
status: "polled",
|
|
40
|
+
});
|
|
33
41
|
}
|
|
34
42
|
if (job.result?.usage) {
|
|
35
43
|
if (context.reportUsageOnce)
|
|
@@ -40,9 +48,20 @@ export function queuedTask(options) {
|
|
|
40
48
|
if (job.status !== "done" || !job.result)
|
|
41
49
|
throw new Error(job.result?.error ?? "Queued workflow job cancelled");
|
|
42
50
|
context.signal.throwIfAborted();
|
|
43
|
-
|
|
51
|
+
const value = decode(job.result.value);
|
|
52
|
+
context.observation?.emit("workflow", {
|
|
53
|
+
kind: "queue",
|
|
54
|
+
id,
|
|
55
|
+
status: "completed",
|
|
56
|
+
});
|
|
57
|
+
return value;
|
|
44
58
|
}
|
|
45
59
|
catch (error) {
|
|
60
|
+
context.observation?.emit("workflow", {
|
|
61
|
+
kind: "queue",
|
|
62
|
+
id,
|
|
63
|
+
status: "failed",
|
|
64
|
+
});
|
|
46
65
|
if (context.signal.aborted) {
|
|
47
66
|
const latest = await queue.get(id);
|
|
48
67
|
if (latest)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queued-task.js","sourceRoot":"","sources":["../../src/application/queued-task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"queued-task.js","sourceRoot":"","sources":["../../src/application/queued-task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAu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,EAAE,OAAO;oBACb,EAAE;oBACF,MAAM,EAAE,QAAQ;iBACjB,CAAC,CAAC;gBACH,IAAI,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;oBAC3B,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;oBACnC,IAAI,MAAM;wBAAE,MAAM,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;gBACnD,CAAC;gBACD,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { taskIdempotencyKey } from \"../domain/workflow/idempotency.ts\";\nimport { setTimeout as delay } from \"node:timers/promises\";\nimport { task } from \"../domain/workflow.ts\";\nimport { queueDefaultPollMs } from \"../domain/task-queue.constants.ts\";\nimport { queueNumber, queueString } from \"../domain/task-queue.ts\";\nimport type { Task } from \"../domain/workflow.types.ts\";\nimport type { QueuedTaskOptions } from \"./queued-task.types.ts\";\n\nexport function queuedTask<T>(options: QueuedTaskOptions<T>): Task<T> {\n const {\n queue,\n handler,\n input,\n decode,\n deadline,\n pollMs = queueDefaultPollMs,\n ...definition\n } = options;\n queueString(handler);\n if (!queueNumber(pollMs))\n throw new Error(\"Queue poll interval must be positive\");\n if (deadline !== undefined) queueNumber(deadline);\n return task({\n ...definition,\n async perform(context) {\n context.signal.throwIfAborted();\n const id = taskIdempotencyKey(context.executionId, definition.key);\n let job = await queue.enqueue({\n id,\n handler,\n input: input(context),\n ...(deadline === undefined ? {} : { deadline }),\n });\n context.observation?.emit(\"workflow\", {\n kind: \"queue\",\n id,\n status: \"enqueued\",\n });\n try {\n while (job.status === \"pending\" || job.status === \"active\") {\n await delay(pollMs, undefined, { signal: context.signal });\n const latest = await queue.get(id);\n if (!latest) throw new Error(\"Queued workflow job disappeared\");\n job = latest;\n context.observation?.emit(\"workflow\", {\n kind: \"queue\",\n id,\n status: \"polled\",\n });\n }\n if (job.result?.usage) {\n if (context.reportUsageOnce)\n context.reportUsageOnce(`queue:${id}`, job.result.usage);\n else context.reportUsage(job.result.usage);\n }\n if (job.status !== \"done\" || !job.result)\n throw new Error(job.result?.error ?? \"Queued workflow job cancelled\");\n context.signal.throwIfAborted();\n const value = decode(job.result.value);\n context.observation?.emit(\"workflow\", {\n kind: \"queue\",\n id,\n status: \"completed\",\n });\n return value;\n } catch (error) {\n context.observation?.emit(\"workflow\", {\n kind: \"queue\",\n id,\n status: \"failed\",\n });\n if (context.signal.aborted) {\n const latest = await queue.get(id);\n if (latest) await queue.cancel(id, latest.fence);\n }\n throw error;\n }\n },\n });\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import type { ObservationHub } from "../domain/observation.types.ts";
|
|
1
2
|
import type { TransportReference } from "../domain/transport.types.ts";
|
|
2
3
|
import type { RecoveryArchiveOptions, RecoveryArchiveRestoreOptions } from "./recovery-archive.types.ts";
|
|
3
|
-
export declare function archiveRecovery(options: RecoveryArchiveOptions): Promise<TransportReference>;
|
|
4
|
-
export declare function materializeRecoveryArchive(options: RecoveryArchiveRestoreOptions): Promise<string>;
|
|
4
|
+
export declare function archiveRecovery(options: RecoveryArchiveOptions, observation?: ObservationHub): Promise<TransportReference>;
|
|
5
|
+
export declare function materializeRecoveryArchive(options: RecoveryArchiveRestoreOptions, observation?: ObservationHub): Promise<string>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { observedOperation } from "../domain/observed-operation.js";
|
|
1
2
|
import { randomUUID } from "node:crypto";
|
|
2
3
|
import { archiveFiles, restoreArchiveFiles, } from "../infrastructure/transport-archive.js";
|
|
3
4
|
import { snapshotRecoveryTransfer } from "./recovery-restore-snapshot.js";
|
|
@@ -5,7 +6,7 @@ import { recoveryChecksumPaths } from "./recovery-checksum-paths.js";
|
|
|
5
6
|
import { recoveryChecksumDefaults } from "./recovery-checksums.constants.js";
|
|
6
7
|
import { verifyRecoveryTransfer } from "./recovery-verification.js";
|
|
7
8
|
import { invariant } from "../domain/errors.js";
|
|
8
|
-
|
|
9
|
+
async function archiveRecoveryOperation(options) {
|
|
9
10
|
const snapshot = await snapshotRecoveryTransfer(options.directory, options.maxBytes);
|
|
10
11
|
try {
|
|
11
12
|
return await archiveFiles(options.transporter, snapshot.directory, [
|
|
@@ -17,7 +18,7 @@ export async function archiveRecovery(options) {
|
|
|
17
18
|
await snapshot.dispose();
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
|
-
|
|
21
|
+
async function materializeRecoveryOperation(options) {
|
|
21
22
|
await restoreArchiveFiles(options.transporter, options.reference, options.destination, options.maxBytes);
|
|
22
23
|
const verified = await verifyRecoveryTransfer(options.destination, {
|
|
23
24
|
checksums: true,
|
|
@@ -26,4 +27,10 @@ export async function materializeRecoveryArchive(options) {
|
|
|
26
27
|
invariant(verified.complete && verified.integrity === "checksums-match", "Recovery archive integrity verification failed; destination retained");
|
|
27
28
|
return options.destination;
|
|
28
29
|
}
|
|
30
|
+
export function archiveRecovery(options, observation) {
|
|
31
|
+
return observedOperation(observation, "transfer", "recovery.archive", () => archiveRecoveryOperation(options));
|
|
32
|
+
}
|
|
33
|
+
export function materializeRecoveryArchive(options, observation) {
|
|
34
|
+
return observedOperation(observation, "transfer", "recovery.materialize", () => materializeRecoveryOperation(options));
|
|
35
|
+
}
|
|
29
36
|
//# sourceMappingURL=recovery-archive.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recovery-archive.js","sourceRoot":"","sources":["../../src/application/recovery-archive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EACL,YAAY,EACZ,mBAAmB,GACpB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,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,EACjB,OAAO,CAAC,WAAW,EACnB,OAAO,CAAC,QAAQ,CACjB,CAAC;IACF,MAAM,QAAQ,GAAG,MAAM,sBAAsB,CAAC,OAAO,CAAC,WAAW,EAAE;QACjE,SAAS,EAAE,IAAI;QACf,GAAG,CAAC,OAAO,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC;KAC1E,CAAC,CAAC;IACH,SAAS,CACP,QAAQ,CAAC,QAAQ,IAAI,QAAQ,CAAC,SAAS,KAAK,iBAAiB,EAC7D,sEAAsE,CACvE,CAAC;IACF,OAAO,OAAO,CAAC,WAAW,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,OAA+B,EAC/B,WAA4B;IAE5B,OAAO,iBAAiB,CAAC,WAAW,EAAE,UAAU,EAAE,kBAAkB,EAAE,GAAG,EAAE,CACzE,wBAAwB,CAAC,OAAO,CAAC,CAClC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,OAAsC,EACtC,WAA4B;IAE5B,OAAO,iBAAiB,CACtB,WAAW,EACX,UAAU,EACV,sBAAsB,EACtB,GAAG,EAAE,CAAC,4BAA4B,CAAC,OAAO,CAAC,CAC5C,CAAC;AACJ,CAAC","sourcesContent":["import { observedOperation } from \"../domain/observed-operation.ts\";\nimport type { ObservationHub } from \"../domain/observation.types.ts\";\nimport { randomUUID } from \"node:crypto\";\nimport type { TransportReference } from \"../domain/transport.types.ts\";\nimport {\n archiveFiles,\n restoreArchiveFiles,\n} from \"../infrastructure/transport-archive.ts\";\nimport { snapshotRecoveryTransfer } from \"./recovery-restore-snapshot.ts\";\nimport { recoveryChecksumPaths } from \"./recovery-checksum-paths.ts\";\nimport { recoveryChecksumDefaults } from \"./recovery-checksums.constants.ts\";\nimport { verifyRecoveryTransfer } from \"./recovery-verification.ts\";\nimport { invariant } from \"../domain/errors.ts\";\nimport type {\n RecoveryArchiveOptions,\n RecoveryArchiveRestoreOptions,\n} from \"./recovery-archive.types.ts\";\n\nasync function archiveRecoveryOperation(\n options: RecoveryArchiveOptions,\n): Promise<TransportReference> {\n const snapshot = await snapshotRecoveryTransfer(\n options.directory,\n options.maxBytes,\n );\n try {\n return await archiveFiles(\n options.transporter,\n snapshot.directory,\n [\n ...recoveryChecksumPaths(snapshot.state),\n recoveryChecksumDefaults.filename,\n ],\n `recovery/${randomUUID()}`,\n options.maxBytes,\n );\n } finally {\n await snapshot.dispose();\n }\n}\n\nasync function materializeRecoveryOperation(\n options: RecoveryArchiveRestoreOptions,\n): Promise<string> {\n await restoreArchiveFiles(\n options.transporter,\n options.reference,\n options.destination,\n options.maxBytes,\n );\n const verified = await verifyRecoveryTransfer(options.destination, {\n checksums: true,\n ...(options.maxBytes === undefined ? {} : { maxBytes: options.maxBytes }),\n });\n invariant(\n verified.complete && verified.integrity === \"checksums-match\",\n \"Recovery archive integrity verification failed; destination retained\",\n );\n return options.destination;\n}\n\nexport function archiveRecovery(\n options: RecoveryArchiveOptions,\n observation?: ObservationHub,\n): Promise<TransportReference> {\n return observedOperation(observation, \"transfer\", \"recovery.archive\", () =>\n archiveRecoveryOperation(options),\n );\n}\n\nexport function materializeRecoveryArchive(\n options: RecoveryArchiveRestoreOptions,\n observation?: ObservationHub,\n): Promise<string> {\n return observedOperation(\n observation,\n \"transfer\",\n \"recovery.materialize\",\n () => materializeRecoveryOperation(options),\n );\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ObservationHub } from "../domain/observation.types.ts";
|
|
1
2
|
import type { RecoveryRestoreOptions, RecoveryRestorePlan, RecoveryRestoreResult } from "./recovery-restore.types.ts";
|
|
2
|
-
export declare function planRecoveryRestore(options: RecoveryRestoreOptions): Promise<RecoveryRestorePlan>;
|
|
3
|
-
export declare function restoreRecoveryTransfer(plan: RecoveryRestorePlan): Promise<RecoveryRestoreResult>;
|
|
3
|
+
export declare function planRecoveryRestore(options: RecoveryRestoreOptions, observation?: ObservationHub): Promise<RecoveryRestorePlan>;
|
|
4
|
+
export declare function restoreRecoveryTransfer(plan: RecoveryRestorePlan, observation?: ObservationHub): Promise<RecoveryRestoreResult>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { observedOperation } from "../domain/observed-operation.js";
|
|
1
2
|
import { createHash } from "node:crypto";
|
|
2
3
|
import { cp, lstat, mkdir } from "node:fs/promises";
|
|
3
4
|
import { basename, dirname, join, resolve } from "node:path";
|
|
@@ -48,7 +49,7 @@ async function locations(options) {
|
|
|
48
49
|
await absent(destination);
|
|
49
50
|
return { repository, directory: transfer, destination };
|
|
50
51
|
}
|
|
51
|
-
|
|
52
|
+
async function planRecoveryRestoreOperation(options) {
|
|
52
53
|
const paths = await locations(options);
|
|
53
54
|
const snapshot = await snapshotRecoveryTransfer(paths.directory, options.maxBytes);
|
|
54
55
|
try {
|
|
@@ -84,7 +85,7 @@ async function applyPatch(checkout, patch, cached = false) {
|
|
|
84
85
|
patch,
|
|
85
86
|
]);
|
|
86
87
|
}
|
|
87
|
-
|
|
88
|
+
async function restoreRecoveryOperation(plan) {
|
|
88
89
|
invariant(plan.fingerprint === planFingerprint(plan), "Recovery plan changed after planning");
|
|
89
90
|
const paths = await locations(plan);
|
|
90
91
|
invariant(paths.repository === plan.repository &&
|
|
@@ -158,4 +159,10 @@ export async function restoreRecoveryTransfer(plan) {
|
|
|
158
159
|
await snapshot.dispose();
|
|
159
160
|
}
|
|
160
161
|
}
|
|
162
|
+
export function planRecoveryRestore(options, observation) {
|
|
163
|
+
return observedOperation(observation, "recovery", "restore.plan", () => planRecoveryRestoreOperation(options));
|
|
164
|
+
}
|
|
165
|
+
export function restoreRecoveryTransfer(plan, observation) {
|
|
166
|
+
return observedOperation(observation, "recovery", "restore.apply", () => restoreRecoveryOperation(plan));
|
|
167
|
+
}
|
|
161
168
|
//# sourceMappingURL=recovery-restore.js.map
|
|
@@ -1 +1 @@
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,KAAK,CAAC;QACxB,MAAM,IAAI,YAAY,CACpB,WAAW,EACX,sEAAsE,EACtE,EAAE,WAAW,EAAE,KAAK,CAAC,WAAW,EAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,EAAE,EAC7D,KAAK,CACN,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,MAAM,QAAQ,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;AACH,CAAC","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { cp, lstat, mkdir } from \"node:fs/promises\";\nimport { basename, dirname, join, resolve } from \"node:path\";\nimport { invariant, OutpostError } from \"../domain/errors.ts\";\nimport { directory, inside, safeDestination } from \"../infrastructure/files.ts\";\nimport { verificationGit as git } from \"../infrastructure/git/verification-command.ts\";\nimport { verifyRecoveryRestorability } from \"./recovery-restorability.ts\";\nimport { snapshotRecoveryTransfer } from \"./recovery-restore-snapshot.ts\";\nimport type {\n RecoveryRestoreOptions,\n RecoveryRestorePlan,\n RecoveryRestoreResult,\n} from \"./recovery-restore.types.ts\";\n\nfunction planFingerprint(\n plan: Omit<RecoveryRestorePlan, \"fingerprint\">,\n): string {\n return createHash(\"sha256\")\n .update(\n JSON.stringify([\n plan.directory,\n plan.repository,\n plan.destination,\n plan.side,\n plan.maxBytes ?? null,\n plan.manifestSha256,\n plan.commit,\n plan.payloads,\n plan.staging,\n ]),\n )\n .digest(\"hex\");\n}\n\nasync function absent(path: string): Promise<void> {\n const present = await lstat(path).then(\n () => true,\n (error: unknown) => {\n if (\n error &&\n typeof error === \"object\" &&\n \"code\" in error &&\n error.code === \"ENOENT\"\n )\n return false;\n throw error;\n },\n );\n invariant(!present, \"Recovery destination already exists\");\n}\n\nasync function locations(options: RecoveryRestoreOptions) {\n invariant(\n options.side === \"previous\" || options.side === \"incoming\",\n \"Recovery side must be previous or incoming\",\n );\n const repository = await directory(options.repository);\n const transfer = await directory(options.directory);\n const destination = join(\n await directory(dirname(resolve(options.destination))),\n basename(resolve(options.destination)),\n );\n const common = await directory(\n (\n await git(repository, [\n \"rev-parse\",\n \"--path-format=absolute\",\n \"--git-common-dir\",\n ])\n ).trim(),\n );\n invariant(\n !inside(repository, destination) &&\n !inside(transfer, destination) &&\n !inside(common, destination),\n \"Recovery destination must be outside the source repository, Git metadata and transfer\",\n );\n await absent(destination);\n return { repository, directory: transfer, destination };\n}\n\nexport async function planRecoveryRestore(\n options: RecoveryRestoreOptions,\n): Promise<RecoveryRestorePlan> {\n const paths = await locations(options);\n const snapshot = await snapshotRecoveryTransfer(\n paths.directory,\n options.maxBytes,\n );\n try {\n const checks = await verifyRecoveryRestorability(\n snapshot.directory,\n snapshot.state,\n paths.repository,\n );\n invariant(\n checks.every((check) => check.status === \"pass\"),\n \"Recovery Git restorability verification failed\",\n );\n const plan = {\n ...options,\n ...paths,\n manifestSha256: snapshot.manifestSha256,\n commit:\n options.side === \"previous\"\n ? snapshot.state.previous\n : snapshot.state.next,\n payloads:\n options.side === \"previous\"\n ? snapshot.state.previousExtras\n : snapshot.state.incoming,\n staging:\n options.side === \"previous\"\n ? (\"preserved\" as const)\n : (\"unavailable\" as const),\n };\n return { ...plan, fingerprint: planFingerprint(plan) };\n } finally {\n await snapshot.dispose();\n }\n}\n\nasync function applyPatch(\n checkout: string,\n patch: string,\n cached = false,\n): Promise<void> {\n if (!(await lstat(patch)).size) return;\n await git(checkout, [\n \"apply\",\n \"--binary\",\n ...(cached ? [\"--cached\"] : []),\n patch,\n ]);\n}\n\nexport async function restoreRecoveryTransfer(\n plan: RecoveryRestorePlan,\n): Promise<RecoveryRestoreResult> {\n invariant(\n plan.fingerprint === planFingerprint(plan),\n \"Recovery plan changed after planning\",\n );\n const paths = await locations(plan);\n invariant(\n paths.repository === plan.repository &&\n paths.directory === plan.directory &&\n paths.destination === plan.destination,\n \"Recovery plan paths changed after planning\",\n );\n const snapshot = await snapshotRecoveryTransfer(\n paths.directory,\n plan.maxBytes,\n );\n let owned = false;\n try {\n invariant(\n snapshot.manifestSha256 === plan.manifestSha256,\n \"Recovery transfer changed since planning\",\n );\n const commit =\n plan.side === \"previous\" ? snapshot.state.previous : snapshot.state.next;\n invariant(commit === plan.commit, \"Recovery plan commit changed\");\n const checks = await verifyRecoveryRestorability(\n snapshot.directory,\n snapshot.state,\n paths.repository,\n );\n invariant(\n checks.every((check) => check.status === \"pass\"),\n \"Recovery Git restorability verification failed\",\n );\n await mkdir(paths.destination, { mode: 0o700 });\n owned = true;\n await git(dirname(paths.destination), [\n \"clone\",\n \"--local\",\n \"--no-hardlinks\",\n \"--no-checkout\",\n \"--\",\n paths.repository,\n paths.destination,\n ]);\n await git(paths.destination, [\"remote\", \"remove\", \"origin\"]);\n if (snapshot.state.previous !== snapshot.state.next) {\n await git(paths.destination, [\n \"bundle\",\n \"verify\",\n join(snapshot.directory, \"commits.bundle\"),\n ]);\n await git(paths.destination, [\n \"bundle\",\n \"unbundle\",\n join(snapshot.directory, \"commits.bundle\"),\n ]);\n }\n await git(paths.destination, [\"checkout\", \"--detach\", commit]);\n await applyPatch(\n paths.destination,\n join(\n snapshot.directory,\n plan.side === \"previous\" ? \"previous.patch\" : \"remote.patch\",\n ),\n );\n if (plan.side === \"previous\")\n await applyPatch(\n paths.destination,\n join(snapshot.directory, \"previous-index.patch\"),\n true,\n );\n const entries =\n plan.side === \"previous\"\n ? snapshot.state.previousExtras\n : snapshot.state.incoming;\n const prefix = plan.side === \"previous\" ? \"previous-files\" : \"incoming\";\n for (const entry of entries) {\n const to = await safeDestination(paths.destination, entry);\n await absent(to);\n await mkdir(dirname(to), { recursive: true, mode: 0o700 });\n await cp(\n await safeDestination(snapshot.directory, `${prefix}/${entry}`),\n to,\n {\n dereference: false,\n verbatimSymlinks: true,\n force: false,\n errorOnExist: true,\n },\n );\n }\n return {\n directory: paths.destination,\n commit,\n side: plan.side,\n staging: plan.side === \"previous\" ? \"preserved\" : \"unavailable\",\n sourceRetained: true,\n };\n } catch (cause) {\n if (!owned) throw cause;\n throw new OutpostError(\n \"workspace\",\n \"Recovery restoration failed; source and partial destination retained\",\n { destination: paths.destination, transfer: paths.directory },\n cause,\n );\n } finally {\n await snapshot.dispose();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"recovery-restore.js","sourceRoot":"","sources":["../../src/application/recovery-restore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,eAAe,IAAI,GAAG,EAAE,MAAM,+CAA+C,CAAC;AACvF,OAAO,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAO1E,SAAS,eAAe,CACtB,IAA8C;IAE9C,OAAO,UAAU,CAAC,QAAQ,CAAC;SACxB,MAAM,CACL,IAAI,CAAC,SAAS,CAAC;QACb,IAAI,CAAC,SAAS;QACd,IAAI,CAAC,UAAU;QACf,IAAI,CAAC,WAAW;QAChB,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,QAAQ,IAAI,IAAI;QACrB,IAAI,CAAC,cAAc;QACnB,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,QAAQ;QACb,IAAI,CAAC,OAAO;KACb,CAAC,CACH;SACA,MAAM,CAAC,KAAK,CAAC,CAAC;AACnB,CAAC;AAED,KAAK,UAAU,MAAM,CAAC,IAAY;IAChC,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,IAAI,CA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aAAa;YAC/D,cAAc,EAAE,IAAI;SACrB,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,KAAK;YAAE,MAAM,KAAK,CAAC;QACxB,MAAM,IAAI,YAAY,CACpB,WAAW,EACX,sEAAsE,EACtE,EAAE,WAAW,EAAE,KAAK,CAAC,WAAW,EAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,EAAE,EAC7D,KAAK,CACN,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,MAAM,QAAQ,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;AACH,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,OAA+B,EAC/B,WAA4B;IAE5B,OAAO,iBAAiB,CAAC,WAAW,EAAE,UAAU,EAAE,cAAc,EAAE,GAAG,EAAE,CACrE,4BAA4B,CAAC,OAAO,CAAC,CACtC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,uBAAuB,CACrC,IAAyB,EACzB,WAA4B;IAE5B,OAAO,iBAAiB,CAAC,WAAW,EAAE,UAAU,EAAE,eAAe,EAAE,GAAG,EAAE,CACtE,wBAAwB,CAAC,IAAI,CAAC,CAC/B,CAAC;AACJ,CAAC","sourcesContent":["import { observedOperation } from \"../domain/observed-operation.ts\";\nimport type { ObservationHub } from \"../domain/observation.types.ts\";\nimport { createHash } from \"node:crypto\";\nimport { cp, lstat, mkdir } from \"node:fs/promises\";\nimport { basename, dirname, join, resolve } from \"node:path\";\nimport { invariant, OutpostError } from \"../domain/errors.ts\";\nimport { directory, inside, safeDestination } from \"../infrastructure/files.ts\";\nimport { verificationGit as git } from \"../infrastructure/git/verification-command.ts\";\nimport { verifyRecoveryRestorability } from \"./recovery-restorability.ts\";\nimport { snapshotRecoveryTransfer } from \"./recovery-restore-snapshot.ts\";\nimport type {\n RecoveryRestoreOptions,\n RecoveryRestorePlan,\n RecoveryRestoreResult,\n} from \"./recovery-restore.types.ts\";\n\nfunction planFingerprint(\n plan: Omit<RecoveryRestorePlan, \"fingerprint\">,\n): string {\n return createHash(\"sha256\")\n .update(\n JSON.stringify([\n plan.directory,\n plan.repository,\n plan.destination,\n plan.side,\n plan.maxBytes ?? null,\n plan.manifestSha256,\n plan.commit,\n plan.payloads,\n plan.staging,\n ]),\n )\n .digest(\"hex\");\n}\n\nasync function absent(path: string): Promise<void> {\n const present = await lstat(path).then(\n () => true,\n (error: unknown) => {\n if (\n error &&\n typeof error === \"object\" &&\n \"code\" in error &&\n error.code === \"ENOENT\"\n )\n return false;\n throw error;\n },\n );\n invariant(!present, \"Recovery destination already exists\");\n}\n\nasync function locations(options: RecoveryRestoreOptions) {\n invariant(\n options.side === \"previous\" || options.side === \"incoming\",\n \"Recovery side must be previous or incoming\",\n );\n const repository = await directory(options.repository);\n const transfer = await directory(options.directory);\n const destination = join(\n await directory(dirname(resolve(options.destination))),\n basename(resolve(options.destination)),\n );\n const common = await directory(\n (\n await git(repository, [\n \"rev-parse\",\n \"--path-format=absolute\",\n \"--git-common-dir\",\n ])\n ).trim(),\n );\n invariant(\n !inside(repository, destination) &&\n !inside(transfer, destination) &&\n !inside(common, destination),\n \"Recovery destination must be outside the source repository, Git metadata and transfer\",\n );\n await absent(destination);\n return { repository, directory: transfer, destination };\n}\n\nasync function planRecoveryRestoreOperation(\n options: RecoveryRestoreOptions,\n): Promise<RecoveryRestorePlan> {\n const paths = await locations(options);\n const snapshot = await snapshotRecoveryTransfer(\n paths.directory,\n options.maxBytes,\n );\n try {\n const checks = await verifyRecoveryRestorability(\n snapshot.directory,\n snapshot.state,\n paths.repository,\n );\n invariant(\n checks.every((check) => check.status === \"pass\"),\n \"Recovery Git restorability verification failed\",\n );\n const plan = {\n ...options,\n ...paths,\n manifestSha256: snapshot.manifestSha256,\n commit:\n options.side === \"previous\"\n ? snapshot.state.previous\n : snapshot.state.next,\n payloads:\n options.side === \"previous\"\n ? snapshot.state.previousExtras\n : snapshot.state.incoming,\n staging:\n options.side === \"previous\"\n ? (\"preserved\" as const)\n : (\"unavailable\" as const),\n };\n return { ...plan, fingerprint: planFingerprint(plan) };\n } finally {\n await snapshot.dispose();\n }\n}\n\nasync function applyPatch(\n checkout: string,\n patch: string,\n cached = false,\n): Promise<void> {\n if (!(await lstat(patch)).size) return;\n await git(checkout, [\n \"apply\",\n \"--binary\",\n ...(cached ? [\"--cached\"] : []),\n patch,\n ]);\n}\n\nasync function restoreRecoveryOperation(\n plan: RecoveryRestorePlan,\n): Promise<RecoveryRestoreResult> {\n invariant(\n plan.fingerprint === planFingerprint(plan),\n \"Recovery plan changed after planning\",\n );\n const paths = await locations(plan);\n invariant(\n paths.repository === plan.repository &&\n paths.directory === plan.directory &&\n paths.destination === plan.destination,\n \"Recovery plan paths changed after planning\",\n );\n const snapshot = await snapshotRecoveryTransfer(\n paths.directory,\n plan.maxBytes,\n );\n let owned = false;\n try {\n invariant(\n snapshot.manifestSha256 === plan.manifestSha256,\n \"Recovery transfer changed since planning\",\n );\n const commit =\n plan.side === \"previous\" ? snapshot.state.previous : snapshot.state.next;\n invariant(commit === plan.commit, \"Recovery plan commit changed\");\n const checks = await verifyRecoveryRestorability(\n snapshot.directory,\n snapshot.state,\n paths.repository,\n );\n invariant(\n checks.every((check) => check.status === \"pass\"),\n \"Recovery Git restorability verification failed\",\n );\n await mkdir(paths.destination, { mode: 0o700 });\n owned = true;\n await git(dirname(paths.destination), [\n \"clone\",\n \"--local\",\n \"--no-hardlinks\",\n \"--no-checkout\",\n \"--\",\n paths.repository,\n paths.destination,\n ]);\n await git(paths.destination, [\"remote\", \"remove\", \"origin\"]);\n if (snapshot.state.previous !== snapshot.state.next) {\n await git(paths.destination, [\n \"bundle\",\n \"verify\",\n join(snapshot.directory, \"commits.bundle\"),\n ]);\n await git(paths.destination, [\n \"bundle\",\n \"unbundle\",\n join(snapshot.directory, \"commits.bundle\"),\n ]);\n }\n await git(paths.destination, [\"checkout\", \"--detach\", commit]);\n await applyPatch(\n paths.destination,\n join(\n snapshot.directory,\n plan.side === \"previous\" ? \"previous.patch\" : \"remote.patch\",\n ),\n );\n if (plan.side === \"previous\")\n await applyPatch(\n paths.destination,\n join(snapshot.directory, \"previous-index.patch\"),\n true,\n );\n const entries =\n plan.side === \"previous\"\n ? snapshot.state.previousExtras\n : snapshot.state.incoming;\n const prefix = plan.side === \"previous\" ? \"previous-files\" : \"incoming\";\n for (const entry of entries) {\n const to = await safeDestination(paths.destination, entry);\n await absent(to);\n await mkdir(dirname(to), { recursive: true, mode: 0o700 });\n await cp(\n await safeDestination(snapshot.directory, `${prefix}/${entry}`),\n to,\n {\n dereference: false,\n verbatimSymlinks: true,\n force: false,\n errorOnExist: true,\n },\n );\n }\n return {\n directory: paths.destination,\n commit,\n side: plan.side,\n staging: plan.side === \"previous\" ? \"preserved\" : \"unavailable\",\n sourceRetained: true,\n };\n } catch (cause) {\n if (!owned) throw cause;\n throw new OutpostError(\n \"workspace\",\n \"Recovery restoration failed; source and partial destination retained\",\n { destination: paths.destination, transfer: paths.directory },\n cause,\n );\n } finally {\n await snapshot.dispose();\n }\n}\n\nexport function planRecoveryRestore(\n options: RecoveryRestoreOptions,\n observation?: ObservationHub,\n): Promise<RecoveryRestorePlan> {\n return observedOperation(observation, \"recovery\", \"restore.plan\", () =>\n planRecoveryRestoreOperation(options),\n );\n}\n\nexport function restoreRecoveryTransfer(\n plan: RecoveryRestorePlan,\n observation?: ObservationHub,\n): Promise<RecoveryRestoreResult> {\n return observedOperation(observation, \"recovery\", \"restore.apply\", () =>\n restoreRecoveryOperation(plan),\n );\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { ObservationHub } from "../domain/observation.types.ts";
|
|
1
2
|
import type { TransportStoreOptions } from "../domain/transport.types.ts";
|
|
2
3
|
import type { RecoveryPruneResult, RecoveryQuotaOptions, RecoveryRetentionOptions, RecoveryRetentionPlan } from "./recovery-retention.types.ts";
|
|
3
|
-
export declare function planRecoveryRetention(options: RecoveryRetentionOptions): Promise<RecoveryRetentionPlan>;
|
|
4
|
-
export declare function pruneRecoveryRetention(plan: RecoveryRetentionPlan, options?: TransportStoreOptions): Promise<RecoveryPruneResult>;
|
|
5
4
|
export declare function assertRecoveryQuota(options: RecoveryQuotaOptions): Promise<void>;
|
|
5
|
+
export declare function planRecoveryRetention(options: RecoveryRetentionOptions, observation?: ObservationHub): Promise<RecoveryRetentionPlan>;
|
|
6
|
+
export declare function pruneRecoveryRetention(plan: RecoveryRetentionPlan, options?: TransportStoreOptions, observation?: ObservationHub): Promise<RecoveryPruneResult>;
|