@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":"attach.js","sourceRoot":"","sources":["../../src/application/attach.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,GAAG,EAAE,MAAM,kCAAkC,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAMvD,O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3B,OAAO,CAAC,SAAS,CAAC,SAAS,EAC3B,QAAQ,EACR,OAAO,CAAC,MAAM,EAAE,SAAS,CAC1B,CAAC;QACF,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;YAAE,MAAM,OAAO,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC;QAC7D,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC,CAAC;QACxE,UAAU,GAAG,IAAI,CAAC;QAClB,OAAO;YACL,GAAG,MAAM;YACT,GAAG,QAAQ;YACX,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,MAAM;YAChC,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,SAAS;YACtC,OAAO,EAAE,OAAO;SACjB,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,IAAI,CAAC,UAAU;YAAE,MAAM,OAAO,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3D,CAAC;AACH,CAAC","sourcesContent":["import type { RequiredAgent } from \"../domain/agent.types.ts\";\nimport { invariant } from \"../domain/errors.ts\";\nimport { validateBrief } from \"../domain/prompts.ts\";\nimport { git } from \"../infrastructure/git/command.ts\";\nimport { commits } from \"../infrastructure/git/history.ts\";\nimport { storageFor } from \"./agent-storage.ts\";\nimport { completeBrief } from \"./interactive-brief.ts\";\nimport type {\n AttachOptions,\n AttachResult,\n SandboxOptions,\n} from \"./outpost.types.ts\";\nimport { createSandbox } from \"./sandbox.ts\";\n\nexport async function attach(\n options: SandboxOptions & AttachOptions & RequiredAgent,\n): Promise<AttachResult> {\n options.signal?.throwIfAborted();\n invariant(\n options.agent.kind === \"cli\",\n \"This harness does not support interactive attachment\",\n );\n validateBrief(options.brief, true);\n const brief = await completeBrief(options.brief, options.signal, options.ask);\n if (brief) options = { ...options, brief };\n if (options.continuation) {\n const storage = storageFor(options.agent);\n invariant(storage, \"This adapter does not support native conversations\");\n await storage.locate(\n options.continuation.id,\n options.workspace?.repository ?? options.repository ?? process.cwd(),\n options.conversationHome,\n );\n }\n const sandbox = await createSandbox(options);\n let successful = false;\n try {\n const baseline = (\n await git(sandbox.workspace.directory, [\"rev-parse\", \"HEAD\"])\n ).trim();\n const result = await sandbox.attach(options);\n const changes = await commits(\n sandbox.workspace.directory,\n baseline,\n options.limits?.collectMs,\n );\n if (result.status === 0) await sandbox.workspace.integrate();\n const disposal = await sandbox.close({ preserve: result.status !== 0 });\n successful = true;\n return {\n ...result,\n ...disposal,\n branch: sandbox.workspace.branch,\n directory: sandbox.workspace.directory,\n commits: changes,\n };\n } finally {\n if (!successful) await sandbox.close({ preserve: true });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"attach.js","sourceRoot":"","sources":["../../src/application/attach.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,GAAG,EAAE,MAAM,kCAAkC,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAMvD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,OAAuD;IAEvD,OAAO,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC;IACjC,SAAS,CACP,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,KAAK,EAC5B,sDAAsD,CACvD,CAAC;IACF,SAAS,CACP,CAAC,OAAO,CAAC,YAAY,IAAI,OAAO,CAAC,KAAK,CAAC,SAAS,KAAK,KAAK,EAC1D,4CAA4C,CAC7C,CAAC;IACF,SAAS,CACP,CAAC,OAAO,CAAC,Y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AC;YAAE,MAAM,OAAO,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC;QAC7D,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC,CAAC;QACxE,UAAU,GAAG,IAAI,CAAC;QAClB,OAAO;YACL,GAAG,MAAM;YACT,GAAG,QAAQ;YACX,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,MAAM;YAChC,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,SAAS;YACtC,OAAO,EAAE,OAAO;SACjB,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,IAAI,CAAC,UAAU;YAAE,MAAM,OAAO,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3D,CAAC;AACH,CAAC","sourcesContent":["import type { RequiredAgent } from \"../domain/agent.types.ts\";\nimport { invariant } from \"../domain/errors.ts\";\nimport { validateBrief } from \"../domain/prompts.ts\";\nimport { git } from \"../infrastructure/git/command.ts\";\nimport { commits } from \"../infrastructure/git/history.ts\";\nimport { storageFor } from \"./agent-storage.ts\";\nimport { completeBrief } from \"./interactive-brief.ts\";\nimport type {\n AttachOptions,\n AttachResult,\n SandboxOptions,\n} from \"./outpost.types.ts\";\nimport { createSandbox } from \"./sandbox.ts\";\n\nexport async function attach(\n options: SandboxOptions & AttachOptions & RequiredAgent,\n): Promise<AttachResult> {\n options.signal?.throwIfAborted();\n invariant(\n options.agent.kind === \"cli\",\n \"This harness does not support interactive attachment\",\n );\n invariant(\n !options.continuation || options.agent.resumable !== false,\n \"This adapter does not support continuation\",\n );\n invariant(\n !options.continuation?.fork || options.agent.forkable !== false,\n \"This adapter does not support automated fork\",\n );\n validateBrief(options.brief, true);\n const brief = await completeBrief(options.brief, options.signal, options.ask);\n if (brief) options = { ...options, brief };\n if (options.continuation) {\n const storage = storageFor(options.agent);\n invariant(storage, \"This adapter does not support native conversations\");\n await storage.locate(\n options.continuation.id,\n options.workspace?.repository ?? options.repository ?? process.cwd(),\n options.conversationHome,\n );\n }\n const sandbox = await createSandbox(options);\n let successful = false;\n try {\n const baseline = (\n await git(sandbox.workspace.directory, [\"rev-parse\", \"HEAD\"])\n ).trim();\n const result = await sandbox.attach(options);\n const changes = await commits(\n sandbox.workspace.directory,\n baseline,\n options.limits?.collectMs,\n );\n if (result.status === 0) await sandbox.workspace.integrate();\n const disposal = await sandbox.close({ preserve: result.status !== 0 });\n successful = true;\n return {\n ...result,\n ...disposal,\n branch: sandbox.workspace.branch,\n directory: sandbox.workspace.directory,\n commits: changes,\n };\n } finally {\n if (!successful) await sandbox.close({ preserve: true });\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const credentialInstaller = "\nconst fs = require(\"node:fs\");\nconst path = require(\"node:path\");\nconst { randomUUID } = require(\"node:crypto\");\nconst input = JSON.parse(fs.readFileSync(0, \"utf8\"));\nfor (const file of input.files) {\n const parts = String(file.path).split(/[\\\\/]/);\n if (!path.isAbsolute(input.home) || path.isAbsolute(file.path) || parts.some((part) => part === \"\" || part === \".\" || part === \"..\"))\n throw new Error(\"Unsafe credential path: \" + file.path);\n const target = path.join(input.home, ...parts);\n fs.mkdirSync(path.dirname(target), { recursive: true, mode: 0o700 });\n const temporary = path.join(path.dirname(target), \".outpost-\" + randomUUID());\n try {\n fs.writeFileSync(temporary, file.content, { mode: 0o600, flag: \"wx\" });\n fs.chmodSync(temporary, 0o600);\n fs.renameSync(temporary, target);\n } finally {\n fs.rmSync(temporary, { force: true });\n }\n}\n";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export const credentialInstaller = `
|
|
2
|
+
const fs = require("node:fs");
|
|
3
|
+
const path = require("node:path");
|
|
4
|
+
const { randomUUID } = require("node:crypto");
|
|
5
|
+
const input = JSON.parse(fs.readFileSync(0, "utf8"));
|
|
6
|
+
for (const file of input.files) {
|
|
7
|
+
const parts = String(file.path).split(/[\\\\/]/);
|
|
8
|
+
if (!path.isAbsolute(input.home) || path.isAbsolute(file.path) || parts.some((part) => part === "" || part === "." || part === ".."))
|
|
9
|
+
throw new Error("Unsafe credential path: " + file.path);
|
|
10
|
+
const target = path.join(input.home, ...parts);
|
|
11
|
+
fs.mkdirSync(path.dirname(target), { recursive: true, mode: 0o700 });
|
|
12
|
+
const temporary = path.join(path.dirname(target), ".outpost-" + randomUUID());
|
|
13
|
+
try {
|
|
14
|
+
fs.writeFileSync(temporary, file.content, { mode: 0o600, flag: "wx" });
|
|
15
|
+
fs.chmodSync(temporary, 0o600);
|
|
16
|
+
fs.renameSync(temporary, target);
|
|
17
|
+
} finally {
|
|
18
|
+
fs.rmSync(temporary, { force: true });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
`;
|
|
22
|
+
//# sourceMappingURL=credential-installer.constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential-installer.constants.js","sourceRoot":"","sources":["../../src/application/credential-installer.constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;CAoBlC,CAAC","sourcesContent":["export const credentialInstaller = `\nconst fs = require(\"node:fs\");\nconst path = require(\"node:path\");\nconst { randomUUID } = require(\"node:crypto\");\nconst input = JSON.parse(fs.readFileSync(0, \"utf8\"));\nfor (const file of input.files) {\n const parts = String(file.path).split(/[\\\\\\\\/]/);\n if (!path.isAbsolute(input.home) || path.isAbsolute(file.path) || parts.some((part) => part === \"\" || part === \".\" || part === \"..\"))\n throw new Error(\"Unsafe credential path: \" + file.path);\n const target = path.join(input.home, ...parts);\n fs.mkdirSync(path.dirname(target), { recursive: true, mode: 0o700 });\n const temporary = path.join(path.dirname(target), \".outpost-\" + randomUUID());\n try {\n fs.writeFileSync(temporary, file.content, { mode: 0o600, flag: \"wx\" });\n fs.chmodSync(temporary, 0o600);\n fs.renameSync(temporary, target);\n } finally {\n fs.rmSync(temporary, { force: true });\n }\n}\n`;\n"]}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { invariant, OutpostError } from "../domain/errors.js";
|
|
2
|
+
import { harnessBudget } from "./harness-budget.js";
|
|
3
|
+
import { harnessModelProvider } from "./harness-model-provider.js";
|
|
4
|
+
import { MAX_DELEGATION_DEPTH } from "../domain/subagent.constants.js";
|
|
2
5
|
import { addUsage } from "../domain/usage.js";
|
|
3
6
|
import { activityWatchdog } from "./activity-watchdog.js";
|
|
4
7
|
import { executionDefaults } from "./execution.constants.js";
|
|
@@ -6,6 +9,7 @@ import { openTranscript } from "../infrastructure/conversations/harness-transcri
|
|
|
6
9
|
import { storageFor } from "./agent-storage.js";
|
|
7
10
|
import { harnessHistory } from "./harness-history.js";
|
|
8
11
|
import { harnessLoop } from "./harness-loop.js";
|
|
12
|
+
import { stopReason } from "./stop-reason.js";
|
|
9
13
|
import { notify } from "./observation.js";
|
|
10
14
|
export async function customTurn(lease, agent, prompt, options, pass, context) {
|
|
11
15
|
const start = Date.now();
|
|
@@ -29,58 +33,31 @@ export async function customTurn(lease, agent, prompt, options, pass, context) {
|
|
|
29
33
|
watchdog.refresh(false);
|
|
30
34
|
notify(options.observe, { ...event, pass, at: new Date().toISOString() });
|
|
31
35
|
};
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
signal,
|
|
36
|
+
const budget = harnessBudget(agent.harness.limits);
|
|
37
|
+
const account = (result, subagentId) => {
|
|
38
|
+
const tokens = result.usage ?? {
|
|
39
|
+
input: 0,
|
|
40
|
+
cached: 0,
|
|
41
|
+
output: 0,
|
|
42
|
+
complete: false,
|
|
40
43
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
tokens: result.usage,
|
|
50
|
-
pass,
|
|
51
|
-
at: new Date().toISOString(),
|
|
52
|
-
});
|
|
53
|
-
}
|
|
44
|
+
usage = addUsage(usage, tokens);
|
|
45
|
+
notify(options.observe, {
|
|
46
|
+
kind: "usage",
|
|
47
|
+
tokens,
|
|
48
|
+
...(subagentId ? { subagentId } : {}),
|
|
49
|
+
pass,
|
|
50
|
+
at: new Date().toISOString(),
|
|
51
|
+
});
|
|
54
52
|
watchdog.refresh(false);
|
|
55
|
-
return result;
|
|
56
|
-
};
|
|
57
|
-
async function* stream(request) {
|
|
58
|
-
signal.throwIfAborted();
|
|
59
|
-
let finish;
|
|
60
|
-
track(new Promise((resolve) => (finish = resolve)));
|
|
61
|
-
try {
|
|
62
|
-
for await (const event of provider.stream(scoped(request))) {
|
|
63
|
-
signal.throwIfAborted();
|
|
64
|
-
watchdog.refresh(false);
|
|
65
|
-
yield event.type === "result"
|
|
66
|
-
? { type: "result", result: account(event.result) }
|
|
67
|
-
: event;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
finally {
|
|
71
|
-
finish();
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
const modelProvider = {
|
|
75
|
-
name: provider.name,
|
|
76
|
-
...(provider.stream ? { stream } : {}),
|
|
77
|
-
request(request) {
|
|
78
|
-
return track((async () => {
|
|
79
|
-
signal.throwIfAborted();
|
|
80
|
-
return account(await provider.request(scoped(request)));
|
|
81
|
-
})());
|
|
82
|
-
},
|
|
83
53
|
};
|
|
54
|
+
const modelScope = { track, account };
|
|
55
|
+
const modelProvider = harnessModelProvider({
|
|
56
|
+
agent,
|
|
57
|
+
signal,
|
|
58
|
+
budget,
|
|
59
|
+
...modelScope,
|
|
60
|
+
});
|
|
84
61
|
const sandbox = {
|
|
85
62
|
root: lease.root,
|
|
86
63
|
home: lease.home,
|
|
@@ -138,6 +115,16 @@ export async function customTurn(lease, agent, prompt, options, pass, context) {
|
|
|
138
115
|
emit({ kind: "conversation", id: transcript.id });
|
|
139
116
|
const text = await harnessLoop({
|
|
140
117
|
agent,
|
|
118
|
+
repository: context.repository,
|
|
119
|
+
...(transcript ? { conversation: transcript.id } : {}),
|
|
120
|
+
budget,
|
|
121
|
+
modelScope,
|
|
122
|
+
permissions: agent.harness.permissions
|
|
123
|
+
? [agent.harness.permissions]
|
|
124
|
+
: [],
|
|
125
|
+
depth: 0,
|
|
126
|
+
maxDepth: agent.harness.limits.maxDelegationDepth ?? MAX_DELEGATION_DEPTH,
|
|
127
|
+
verbose: options.observation?.verbose ?? false,
|
|
141
128
|
tools: context.repair
|
|
142
129
|
? agent.harness.tools.filter((tool) => tool.readOnly)
|
|
143
130
|
: agent.harness.tools,
|
|
@@ -176,6 +163,14 @@ export async function customTurn(lease, agent, prompt, options, pass, context) {
|
|
|
176
163
|
};
|
|
177
164
|
}
|
|
178
165
|
catch (error) {
|
|
166
|
+
const reason = stopReason(options.signal, controller.signal.reason, error);
|
|
167
|
+
if (reason)
|
|
168
|
+
notify(options.observe, {
|
|
169
|
+
kind: "stopped",
|
|
170
|
+
reason,
|
|
171
|
+
pass,
|
|
172
|
+
at: new Date().toISOString(),
|
|
173
|
+
});
|
|
179
174
|
signal.throwIfAborted();
|
|
180
175
|
throw error;
|
|
181
176
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-turn.js","sourceRoot":"","sources":["../../src/application/custom-turn.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,EAAE,cAAc,EAAE,MAAM,uDAAuD,CAAC;AAEvF,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAA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AAK,CAAC;IACd,CAAC;YAAS,CAAC;QACT,MAAM,UAAU,EAAE,KAAK,EAAE,CAAC;QAC1B,UAAU,CAAC,KAAK,CAAC,IAAI,YAAY,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC,CAAC;QACpE,YAAY,CAAC,KAAK,CAAC,CAAC;QACpB,QAAQ,CAAC,KAAK,EAAE,CAAC;QACjB,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IACzC,CAAC;AACH,CAAC","sourcesContent":["import type { AgentEvent, CustomAgent, Usage } from \"../domain/agent.types.ts\";\nimport type {\n ModelProvider,\n ModelRequest,\n ModelResult,\n ModelStreamEvent,\n} from \"../domain/model.types.ts\";\nimport type { SandboxLease } from \"../domain/sandbox.types.ts\";\nimport { invariant, OutpostError } from \"../domain/errors.ts\";\nimport { addUsage } from \"../domain/usage.ts\";\nimport { activityWatchdog } from \"./activity-watchdog.ts\";\nimport { executionDefaults } from \"./execution.constants.ts\";\nimport type { DispatchOptions, Turn } from \"./execution.types.ts\";\nimport { openTranscript } from \"../infrastructure/conversations/harness-transcript.ts\";\nimport type { TranscriptHandle } from \"../infrastructure/conversations/harness-transcript.types.ts\";\nimport { storageFor } from \"./agent-storage.ts\";\nimport { harnessHistory } from \"./harness-history.ts\";\nimport { harnessLoop } from \"./harness-loop.ts\";\nimport type { CustomTurnContext } from \"./harness.types.ts\";\nimport { notify } from \"./observation.ts\";\n\nexport async function customTurn(\n lease: SandboxLease,\n agent: CustomAgent,\n prompt: string,\n options: DispatchOptions<unknown>,\n pass: number,\n context: CustomTurnContext,\n): Promise<Turn> {\n const start = Date.now();\n const controller = new AbortController();\n const signal = options.signal\n ? AbortSignal.any([options.signal, controller.signal])\n : controller.signal;\n const watchdog = activityWatchdog(controller, options, pass);\n const timer = setTimeout(\n () =>\n controller.abort(\n new OutpostError(\"timeout\", \"Harness execution timed out\"),\n ),\n options.deadlineMs ?? executionDefaults.deadlineMs,\n );\n let usage: Usage = { input: 0, cached: 0, output: 0 };\n const pending = new Set<Promise<unknown>>();\n const track = <T>(operation: Promise<T>): Promise<T> => {\n pending.add(operation);\n void operation\n .finally(() => pending.delete(operation))\n .catch(() => undefined);\n return operation;\n };\n const emit = (event: AgentEvent) => {\n signal.throwIfAborted();\n watchdog.refresh(false);\n notify(options.observe, { ...event, pass, at: new Date().toISOString() });\n };\n const provider = agent.harness.modelProvider;\n const scoped = (request: ModelRequest): ModelRequest => {\n const { reasoning, maxOutputTokens } = agent.model;\n return {\n ...(reasoning === undefined ? {} : { reasoning }),\n ...(maxOutputTokens === undefined ? {} : { maxOutputTokens }),\n ...request,\n signal,\n };\n };\n const account = (result: ModelResult): ModelResult => {\n signal.throwIfAborted();\n invariant(\n result && typeof result.text === \"string\",\n \"Model provider must return text\",\n );\n if (result.usage) {\n usage = addUsage(usage, result.usage);\n notify(options.observe, {\n kind: \"usage\",\n tokens: result.usage,\n pass,\n at: new Date().toISOString(),\n });\n }\n watchdog.refresh(false);\n return result;\n };\n async function* stream(\n request: ModelRequest,\n ): AsyncGenerator<ModelStreamEvent> {\n signal.throwIfAborted();\n let finish!: () => void;\n track(new Promise<void>((resolve) => (finish = resolve)));\n try {\n for await (const event of provider.stream!(scoped(request))) {\n signal.throwIfAborted();\n watchdog.refresh(false);\n yield event.type === \"result\"\n ? { type: \"result\", result: account(event.result) }\n : event;\n }\n } finally {\n finish();\n }\n }\n const modelProvider: ModelProvider = {\n name: provider.name,\n ...(provider.stream ? { stream } : {}),\n request(request) {\n return track(\n (async () => {\n signal.throwIfAborted();\n return account(await provider.request(scoped(request)));\n })(),\n );\n },\n };\n const sandbox: SandboxLease = {\n root: lease.root,\n home: lease.home,\n invoke: (command) => {\n signal.throwIfAborted();\n return track(\n lease.invoke({\n ...command,\n observe(channel, chunk) {\n watchdog.refresh(false);\n notify((value) => command.observe?.(channel, value), chunk);\n },\n signal: command.signal\n ? AbortSignal.any([command.signal, signal])\n : signal,\n }),\n );\n },\n upload: (source, destination, settings = {}) => {\n signal.throwIfAborted();\n return track(\n lease.upload(source, destination, {\n ...settings,\n signal: settings.signal\n ? AbortSignal.any([settings.signal, signal])\n : signal,\n }),\n );\n },\n download: (source, destination, settings = {}) => {\n signal.throwIfAborted();\n return track(\n lease.download(source, destination, {\n ...settings,\n signal: settings.signal\n ? AbortSignal.any([settings.signal, signal])\n : signal,\n }),\n );\n },\n release: async () => {\n throw new OutpostError(\n \"configuration\",\n \"The harness does not own its sandbox lease\",\n );\n },\n };\n let transcript: TranscriptHandle | undefined;\n try {\n signal.throwIfAborted();\n watchdog.refresh(false);\n const storage = storageFor(agent);\n transcript = storage\n ? await openTranscript({\n repository: context.repository,\n store: storage,\n model: agent.model.name,\n ...(context.continuation\n ? { continuation: context.continuation }\n : {}),\n })\n : undefined;\n if (transcript) emit({ kind: \"conversation\", id: transcript.id });\n const text = await harnessLoop(\n {\n agent,\n tools: context.repair\n ? agent.harness.tools.filter((tool) => tool.readOnly)\n : agent.harness.tools,\n modelProvider,\n sandbox,\n signal,\n emit,\n hold: () => watchdog.hold(),\n },\n prompt,\n harnessHistory(transcript),\n );\n signal.throwIfAborted();\n for (const value of [\n usage.input,\n usage.cached,\n usage.output,\n usage.cacheCreated ?? 0,\n ])\n invariant(\n Number.isSafeInteger(value) && value >= 0,\n \"Harness usage must contain nonnegative token counts\",\n );\n invariant(\n usage.cached + (usage.cacheCreated ?? 0) <= usage.input,\n \"Cached tokens must be included in input usage\",\n );\n notify(options.observe, {\n kind: \"result\",\n text,\n pass,\n at: new Date().toISOString(),\n });\n notify(options.observe, {\n kind: \"finished\",\n pass,\n at: new Date().toISOString(),\n });\n return {\n text,\n usage,\n status: 0,\n durationMs: Date.now() - start,\n ...(transcript ? { conversation: transcript.id } : {}),\n };\n } catch (error) {\n signal.throwIfAborted();\n throw error;\n } finally {\n await transcript?.close();\n controller.abort(new OutpostError(\"aborted\", \"Harness turn ended\"));\n clearTimeout(timer);\n watchdog.close();\n await Promise.allSettled([...p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,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;aAC7B,CAAC,CAAC;QACL,MAAM,CAAC,cAAc,EAAE,CAAC;QACxB,MAAM,KAAK,CAAC;IACd,CAAC;YAAS,CAAC;QACT,MAAM,UAAU,EAAE,KAAK,EAAE,CAAC;QAC1B,UAAU,CAAC,KAAK,CAAC,IAAI,YAAY,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC,CAAC;QACpE,YAAY,CAAC,KAAK,CAAC,CAAC;QACpB,QAAQ,CAAC,KAAK,EAAE,CAAC;QACjB,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IACzC,CAAC;AACH,CAAC","sourcesContent":["import type { AgentEvent, CustomAgent, Usage } from \"../domain/agent.types.ts\";\nimport type { ModelResult } from \"../domain/model.types.ts\";\nimport type { SandboxLease } from \"../domain/sandbox.types.ts\";\nimport { invariant, OutpostError } from \"../domain/errors.ts\";\nimport { harnessBudget } from \"./harness-budget.ts\";\nimport { harnessModelProvider } from \"./harness-model-provider.ts\";\nimport { MAX_DELEGATION_DEPTH } from \"../domain/subagent.constants.ts\";\nimport { addUsage } from \"../domain/usage.ts\";\nimport { activityWatchdog } from \"./activity-watchdog.ts\";\nimport { executionDefaults } from \"./execution.constants.ts\";\nimport type { DispatchOptions, Turn } from \"./execution.types.ts\";\nimport { openTranscript } from \"../infrastructure/conversations/harness-transcript.ts\";\nimport type { TranscriptHandle } from \"../infrastructure/conversations/harness-transcript.types.ts\";\nimport { storageFor } from \"./agent-storage.ts\";\nimport { harnessHistory } from \"./harness-history.ts\";\nimport { harnessLoop } from \"./harness-loop.ts\";\nimport type { CustomTurnContext } from \"./harness.types.ts\";\nimport { stopReason } from \"./stop-reason.ts\";\nimport { notify } from \"./observation.ts\";\n\nexport async function customTurn(\n lease: SandboxLease,\n agent: CustomAgent,\n prompt: string,\n options: DispatchOptions<unknown>,\n pass: number,\n context: CustomTurnContext,\n): Promise<Turn> {\n const start = Date.now();\n const controller = new AbortController();\n const signal = options.signal\n ? AbortSignal.any([options.signal, controller.signal])\n : controller.signal;\n const watchdog = activityWatchdog(controller, options, pass);\n const timer = setTimeout(\n () =>\n controller.abort(\n new OutpostError(\"timeout\", \"Harness execution timed out\"),\n ),\n options.deadlineMs ?? executionDefaults.deadlineMs,\n );\n let usage: Usage = { input: 0, cached: 0, output: 0 };\n const pending = new Set<Promise<unknown>>();\n const track = <T>(operation: Promise<T>): Promise<T> => {\n pending.add(operation);\n void operation\n .finally(() => pending.delete(operation))\n .catch(() => undefined);\n return operation;\n };\n const emit = (event: AgentEvent) => {\n signal.throwIfAborted();\n watchdog.refresh(false);\n notify(options.observe, { ...event, pass, at: new Date().toISOString() });\n };\n const budget = harnessBudget(agent.harness.limits);\n const account = (result: ModelResult, subagentId?: string): void => {\n const tokens = result.usage ?? {\n input: 0,\n cached: 0,\n output: 0,\n complete: false,\n };\n usage = addUsage(usage, tokens);\n notify(options.observe, {\n kind: \"usage\",\n tokens,\n ...(subagentId ? { subagentId } : {}),\n pass,\n at: new Date().toISOString(),\n });\n watchdog.refresh(false);\n };\n const modelScope = { track, account };\n const modelProvider = harnessModelProvider({\n agent,\n signal,\n budget,\n ...modelScope,\n });\n const sandbox: SandboxLease = {\n root: lease.root,\n home: lease.home,\n invoke: (command) => {\n signal.throwIfAborted();\n return track(\n lease.invoke({\n ...command,\n observe(channel, chunk) {\n watchdog.refresh(false);\n notify((value) => command.observe?.(channel, value), chunk);\n },\n signal: command.signal\n ? AbortSignal.any([command.signal, signal])\n : signal,\n }),\n );\n },\n upload: (source, destination, settings = {}) => {\n signal.throwIfAborted();\n return track(\n lease.upload(source, destination, {\n ...settings,\n signal: settings.signal\n ? AbortSignal.any([settings.signal, signal])\n : signal,\n }),\n );\n },\n download: (source, destination, settings = {}) => {\n signal.throwIfAborted();\n return track(\n lease.download(source, destination, {\n ...settings,\n signal: settings.signal\n ? AbortSignal.any([settings.signal, signal])\n : signal,\n }),\n );\n },\n release: async () => {\n throw new OutpostError(\n \"configuration\",\n \"The harness does not own its sandbox lease\",\n );\n },\n };\n let transcript: TranscriptHandle | undefined;\n try {\n signal.throwIfAborted();\n watchdog.refresh(false);\n const storage = storageFor(agent);\n transcript = storage\n ? await openTranscript({\n repository: context.repository,\n store: storage,\n model: agent.model.name,\n ...(context.continuation\n ? { continuation: context.continuation }\n : {}),\n })\n : undefined;\n if (transcript) emit({ kind: \"conversation\", id: transcript.id });\n const text = await harnessLoop(\n {\n agent,\n repository: context.repository,\n ...(transcript ? { conversation: transcript.id } : {}),\n budget,\n modelScope,\n permissions: agent.harness.permissions\n ? [agent.harness.permissions]\n : [],\n depth: 0,\n maxDepth:\n agent.harness.limits.maxDelegationDepth ?? MAX_DELEGATION_DEPTH,\n verbose: options.observation?.verbose ?? false,\n tools: context.repair\n ? agent.harness.tools.filter((tool) => tool.readOnly)\n : agent.harness.tools,\n modelProvider,\n sandbox,\n signal,\n emit,\n hold: () => watchdog.hold(),\n },\n prompt,\n harnessHistory(transcript),\n );\n signal.throwIfAborted();\n for (const value of [\n usage.input,\n usage.cached,\n usage.output,\n usage.cacheCreated ?? 0,\n ])\n invariant(\n Number.isSafeInteger(value) && value >= 0,\n \"Harness usage must contain nonnegative token counts\",\n );\n invariant(\n usage.cached + (usage.cacheCreated ?? 0) <= usage.input,\n \"Cached tokens must be included in input usage\",\n );\n notify(options.observe, {\n kind: \"result\",\n text,\n pass,\n at: new Date().toISOString(),\n });\n notify(options.observe, {\n kind: \"finished\",\n pass,\n at: new Date().toISOString(),\n });\n return {\n text,\n usage,\n status: 0,\n durationMs: Date.now() - start,\n ...(transcript ? { conversation: transcript.id } : {}),\n };\n } catch (error) {\n const reason = stopReason(options.signal, controller.signal.reason, error);\n if (reason)\n notify(options.observe, {\n kind: \"stopped\",\n reason,\n pass,\n at: new Date().toISOString(),\n });\n signal.throwIfAborted();\n throw error;\n } finally {\n await transcript?.close();\n controller.abort(new OutpostError(\"aborted\", \"Harness turn ended\"));\n clearTimeout(timer);\n watchdog.close();\n await Promise.allSettled([...pending]);\n }\n}\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ObservedDispatchResult } from "./dispatch-observation.types.ts";
|
|
2
2
|
import type { DispatchOptions } from "./execution.types.ts";
|
|
3
|
-
export declare function observeDispatch<T, R extends ObservedDispatchResult>(options: DispatchOptions<T>, action: (options: DispatchOptions<T>) => Promise<R
|
|
3
|
+
export declare function observeDispatch<T, R extends ObservedDispatchResult>(options: DispatchOptions<T>, action: (options: DispatchOptions<T>) => Promise<R>, repository?: string): Promise<R>;
|
|
@@ -1,18 +1,84 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { access } from "node:fs/promises";
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
import { agentObservation } from "../domain/agent-observation.js";
|
|
4
|
+
import { createObservationHub } from "../domain/observation.js";
|
|
5
|
+
import { recordRecovery, recoveryDetails, OutpostError, } from "../domain/errors.js";
|
|
2
6
|
import { addUsage } from "../domain/usage.js";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
7
|
+
import { journal } from "../infrastructure/journal.js";
|
|
8
|
+
const active = new WeakSet();
|
|
9
|
+
export async function observeDispatch(options, action, repository = process.cwd()) {
|
|
10
|
+
if (options.observation && active.has(options.observation))
|
|
6
11
|
return action(options);
|
|
12
|
+
const root = options.observation ?? createObservationHub();
|
|
13
|
+
const failures = [];
|
|
14
|
+
let log;
|
|
7
15
|
let session;
|
|
8
|
-
|
|
16
|
+
const initialized = (async () => {
|
|
17
|
+
try {
|
|
18
|
+
await access(repository);
|
|
19
|
+
log = await journal(repository, options.logging, options.label, false);
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
failures.push(error);
|
|
23
|
+
}
|
|
24
|
+
})();
|
|
25
|
+
try {
|
|
9
26
|
session = options.telemetry?.startDispatch();
|
|
10
|
-
}
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
failures.push(error);
|
|
30
|
+
}
|
|
31
|
+
const observation = root.child({ dispatchId: randomUUID() }, [
|
|
32
|
+
{
|
|
33
|
+
async observe(value) {
|
|
34
|
+
await initialized;
|
|
35
|
+
await log?.record({
|
|
36
|
+
...value.event,
|
|
37
|
+
seq: value.seq,
|
|
38
|
+
at: value.at,
|
|
39
|
+
source: value.source,
|
|
40
|
+
scope: value.scope,
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
async flush() {
|
|
44
|
+
await initialized;
|
|
45
|
+
await log?.close();
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
observe(value) {
|
|
50
|
+
if (value.event.kind === "warning")
|
|
51
|
+
return options.warn?.(value.event.message);
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
observe(value) {
|
|
56
|
+
if (value.source !== "agent" && value.source !== "harness")
|
|
57
|
+
return;
|
|
58
|
+
const event = agentObservation(value);
|
|
59
|
+
if (event)
|
|
60
|
+
return options.observe?.(event);
|
|
61
|
+
},
|
|
62
|
+
async flush() {
|
|
63
|
+
const observer = options.observe;
|
|
64
|
+
if (observer &&
|
|
65
|
+
"flush" in observer &&
|
|
66
|
+
typeof observer.flush === "function")
|
|
67
|
+
await observer.flush();
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
]);
|
|
71
|
+
active.add(observation);
|
|
72
|
+
observation.emit("sandbox", { kind: "dispatch-start" });
|
|
11
73
|
const empty = () => ({ input: 0, cached: 0, output: 0 });
|
|
12
74
|
let previous = empty(), current = empty();
|
|
13
75
|
const { telemetry: _telemetry, ...settings } = options;
|
|
14
76
|
const observed = {
|
|
15
77
|
...settings,
|
|
78
|
+
observation,
|
|
79
|
+
warn(message) {
|
|
80
|
+
observation.emit("agent", { kind: "warning", message });
|
|
81
|
+
},
|
|
16
82
|
observe(event) {
|
|
17
83
|
if (event.kind === "phase" && event.name === "preparing prompt") {
|
|
18
84
|
previous = addUsage(previous, current);
|
|
@@ -22,30 +88,84 @@ export function observeDispatch(options, action) {
|
|
|
22
88
|
current = addUsage(current, event.tokens);
|
|
23
89
|
if (event.kind === "summary")
|
|
24
90
|
current = event.tokens;
|
|
25
|
-
|
|
91
|
+
observation
|
|
92
|
+
.child({
|
|
93
|
+
pass: event.pass,
|
|
94
|
+
...(event.subagentId ? { subagentId: event.subagentId } : {}),
|
|
95
|
+
})
|
|
96
|
+
.emit(options.agent?.kind === "custom" ? "harness" : "agent", event);
|
|
26
97
|
},
|
|
27
98
|
};
|
|
28
|
-
|
|
29
|
-
|
|
99
|
+
try {
|
|
100
|
+
const result = await action(observed);
|
|
101
|
+
observation.emit("sandbox", {
|
|
102
|
+
kind: "dispatch-finished",
|
|
103
|
+
status: "done",
|
|
104
|
+
completed: result.completed,
|
|
105
|
+
usage: result.usage,
|
|
106
|
+
...(result.branch ? { branch: result.branch } : {}),
|
|
107
|
+
...(result.commits ? { commits: result.commits } : {}),
|
|
108
|
+
});
|
|
30
109
|
try {
|
|
31
|
-
|
|
32
|
-
notify(() => session?.finish({
|
|
110
|
+
session?.finish({
|
|
33
111
|
status: "done",
|
|
34
112
|
usage: result.usage,
|
|
35
113
|
completed: result.completed,
|
|
36
|
-
})
|
|
37
|
-
return result;
|
|
114
|
+
});
|
|
38
115
|
}
|
|
39
116
|
catch (error) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
117
|
+
failures.push(error);
|
|
118
|
+
}
|
|
119
|
+
await finish();
|
|
120
|
+
return {
|
|
121
|
+
...result,
|
|
122
|
+
...(log?.reference ? { logReference: log.reference } : {}),
|
|
123
|
+
observerErrors: [...failures, ...observation.errors],
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
const cancelled = options.signal?.aborted ||
|
|
128
|
+
(error instanceof OutpostError && error.code === "aborted") ||
|
|
129
|
+
(error instanceof Error && error.name === "AbortError");
|
|
130
|
+
const status = cancelled ? "cancelled" : "failed";
|
|
131
|
+
const usage = addUsage(previous, current);
|
|
132
|
+
const recovery = recoveryDetails(error);
|
|
133
|
+
observation.emit("sandbox", {
|
|
134
|
+
kind: "dispatch-finished",
|
|
135
|
+
status,
|
|
136
|
+
completed: false,
|
|
137
|
+
...(typeof recovery?.branch === "string"
|
|
138
|
+
? { branch: recovery.branch }
|
|
139
|
+
: {}),
|
|
140
|
+
...(Array.isArray(recovery?.commits) && recovery.commits.every(isCommit)
|
|
141
|
+
? { commits: recovery.commits }
|
|
142
|
+
: {}),
|
|
143
|
+
usage,
|
|
144
|
+
});
|
|
145
|
+
try {
|
|
146
|
+
session?.finish({ status, usage });
|
|
147
|
+
}
|
|
148
|
+
catch (failure) {
|
|
149
|
+
failures.push(failure);
|
|
48
150
|
}
|
|
151
|
+
await finish();
|
|
152
|
+
recordRecovery(error, {
|
|
153
|
+
observerErrors: [...failures, ...observation.errors],
|
|
154
|
+
...(log?.reference ? { logReference: log.reference } : {}),
|
|
155
|
+
});
|
|
156
|
+
throw error;
|
|
49
157
|
}
|
|
158
|
+
async function finish() {
|
|
159
|
+
await observation.close();
|
|
160
|
+
active.delete(observation);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
function isCommit(value) {
|
|
164
|
+
return (typeof value === "object" &&
|
|
165
|
+
value !== null &&
|
|
166
|
+
"oid" in value &&
|
|
167
|
+
typeof value.oid === "string" &&
|
|
168
|
+
"subject" in value &&
|
|
169
|
+
typeof value.subject === "string");
|
|
50
170
|
}
|
|
51
171
|
//# sourceMappingURL=dispatch-observation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch-observation.js","sourceRoot":"","sources":["../../src/application/dispatch-observation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,C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,UAAU,MAAM;QACnB,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC;YACtC,MAAM,CACJ,GAAG,EAAE,CACH,OAAO,EAAE,MAAM,CAAC;gBACd,MAAM,EAAE,MAAM;gBACd,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,SAAS,EAAE,MAAM,CAAC,SAAS;aAC5B,CAAC,EACJ,SAAS,CACV,CAAC;YACF,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,SAAS,GACb,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,IAAI,KAAK,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC;gBAC5D,CAAC,KAAK,YAAY,YAAY,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC;gBAC3D,CAAC,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC;YAC1D,MAAM,CACJ,GAAG,EAAE,CACH,OAAO,EAAE,MAAM,CAAC;gBACd,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ;gBAC1C,KAAK,EAAE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;aACnC,CAAC,EACJ,SAAS,CACV,CAAC;YACF,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import type { Usage } from \"../domain/agent.types.ts\";\nimport type { DispatchTelemetrySession } from \"../domain/dispatch-telemetry.types.ts\";\nimport { OutpostError } from \"../domain/errors.ts\";\nimport { addUsage } from \"../domain/usage.ts\";\nimport type { ObservedDispatchResult } from \"./dispatch-observation.types.ts\";\nimport type { DispatchOptions } from \"./execution.types.ts\";\nimport { notify } from \"./observation.ts\";\n\nexport function observeDispatch<T, R extends ObservedDispatchResult>(\n options: DispatchOptions<T>,\n action: (options: DispatchOptions<T>) => Promise<R>,\n): Promise<R> {\n if (!options.telemetry) return action(options);\n let session: DispatchTelemetrySession | undefined;\n notify(() => {\n session = options.telemetry?.startDispatch();\n }, undefined);\n const empty = (): Usage => ({ input: 0, cached: 0, output: 0 });\n let previous = empty(),\n current = empty();\n const { telemetry: _telemetry, ...settings } = options;\n const observed: DispatchOptions<T> = {\n ...settings,\n observe(event) {\n if (event.kind === \"phase\" && event.name === \"preparing prompt\") {\n previous = addUsage(previous, current);\n current = empty();\n }\n if (event.kind === \"usage\") current = addUsage(current, event.tokens);\n if (event.kind === \"summary\") current = event.tokens;\n notify(options.observe, event);\n },\n };\n return settle();\n\n async function settle(): Promise<R> {\n try {\n const result = await action(observed);\n notify(\n () =>\n session?.finish({\n status: \"done\",\n usage: result.usage,\n completed: result.completed,\n }),\n undefined,\n );\n return result;\n } catch (error) {\n const cancelled =\n (options.signal?.aborted && error === options.signal.reason) ||\n (error instanceof OutpostError && error.code === \"aborted\") ||\n (error instanceof Error && error.name === \"AbortError\");\n notify(\n () =>\n session?.finish({\n status: cancelled ? \"cancelled\" : \"failed\",\n usage: addUsage(previous, current),\n }),\n undefined,\n );\n throw error;\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dispatch-observation.js","sourceRoot":"","sources":["../../src/application/dispatch-observation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAIlE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EACL,cAAc,EACd,eAAe,EACf,YAAY,GACb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAKvD,MAAM,MAAM,GAAG,IAAI,OAAO,EAAkB,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CAAC;IAC7B,CAAC;AACH,CAAC;AAED,SAAS,QAAQ,CACf,KAAc;IAEd,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,KAAK,IAAI,KAAK;QACd,OAAO,KAAK,CAAC,GAAG,KAAK,QAAQ;QAC7B,SAAS,IAAI,KAAK;QAClB,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,CAClC,CAAC;AACJ,CAAC","sourcesContent":["import { access } from \"node:fs/promises\";\nimport { randomUUID } from \"node:crypto\";\nimport { agentObservation } from \"../domain/agent-observation.ts\";\nimport type { Usage } from \"../domain/agent.types.ts\";\nimport type { DispatchTelemetrySession } from \"../domain/dispatch-telemetry.types.ts\";\nimport type { ObservationHub } from \"../domain/observation.types.ts\";\nimport { createObservationHub } from \"../domain/observation.ts\";\nimport {\n recordRecovery,\n recoveryDetails,\n OutpostError,\n} from \"../domain/errors.ts\";\nimport { addUsage } from \"../domain/usage.ts\";\nimport { journal } from \"../infrastructure/journal.ts\";\nimport type { Journal } from \"../infrastructure/journal.types.ts\";\nimport type { ObservedDispatchResult } from \"./dispatch-observation.types.ts\";\nimport type { DispatchOptions } from \"./execution.types.ts\";\n\nconst active = new WeakSet<ObservationHub>();\n\nexport async function observeDispatch<T, R extends ObservedDispatchResult>(\n options: DispatchOptions<T>,\n action: (options: DispatchOptions<T>) => Promise<R>,\n repository = process.cwd(),\n): Promise<R> {\n if (options.observation && active.has(options.observation))\n return action(options);\n const root = options.observation ?? createObservationHub();\n const failures: unknown[] = [];\n let log: Journal | undefined;\n let session: DispatchTelemetrySession | undefined;\n const initialized = (async () => {\n try {\n await access(repository);\n log = await journal(repository, options.logging, options.label, false);\n } catch (error) {\n failures.push(error);\n }\n })();\n try {\n session = options.telemetry?.startDispatch();\n } catch (error) {\n failures.push(error);\n }\n const observation = root.child({ dispatchId: randomUUID() }, [\n {\n async observe(value) {\n await initialized;\n await log?.record({\n ...value.event,\n seq: value.seq,\n at: value.at,\n source: value.source,\n scope: value.scope,\n });\n },\n async flush() {\n await initialized;\n await log?.close();\n },\n },\n {\n observe(value) {\n if (value.event.kind === \"warning\")\n return options.warn?.(value.event.message);\n },\n },\n {\n observe(value) {\n if (value.source !== \"agent\" && value.source !== \"harness\") return;\n const event = agentObservation(value);\n if (event) return options.observe?.(event);\n },\n async flush() {\n const observer = options.observe;\n if (\n observer &&\n \"flush\" in observer &&\n typeof observer.flush === \"function\"\n )\n await observer.flush();\n },\n },\n ]);\n active.add(observation);\n observation.emit(\"sandbox\", { kind: \"dispatch-start\" });\n const empty = (): Usage => ({ input: 0, cached: 0, output: 0 });\n let previous = empty(),\n current = empty();\n const { telemetry: _telemetry, ...settings } = options;\n const observed: DispatchOptions<T> = {\n ...settings,\n observation,\n warn(message) {\n observation.emit(\"agent\", { kind: \"warning\", message });\n },\n observe(event) {\n if (event.kind === \"phase\" && event.name === \"preparing prompt\") {\n previous = addUsage(previous, current);\n current = empty();\n }\n if (event.kind === \"usage\") current = addUsage(current, event.tokens);\n if (event.kind === \"summary\") current = event.tokens;\n observation\n .child({\n pass: event.pass,\n ...(event.subagentId ? { subagentId: event.subagentId } : {}),\n })\n .emit(options.agent?.kind === \"custom\" ? \"harness\" : \"agent\", event);\n },\n };\n try {\n const result = await action(observed);\n observation.emit(\"sandbox\", {\n kind: \"dispatch-finished\",\n status: \"done\",\n completed: result.completed,\n usage: result.usage,\n ...(result.branch ? { branch: result.branch } : {}),\n ...(result.commits ? { commits: result.commits } : {}),\n });\n try {\n session?.finish({\n status: \"done\",\n usage: result.usage,\n completed: result.completed,\n });\n } catch (error) {\n failures.push(error);\n }\n await finish();\n return {\n ...result,\n ...(log?.reference ? { logReference: log.reference } : {}),\n observerErrors: [...failures, ...observation.errors],\n };\n } catch (error) {\n const cancelled =\n options.signal?.aborted ||\n (error instanceof OutpostError && error.code === \"aborted\") ||\n (error instanceof Error && error.name === \"AbortError\");\n const status = cancelled ? \"cancelled\" : \"failed\";\n const usage = addUsage(previous, current);\n const recovery = recoveryDetails(error);\n observation.emit(\"sandbox\", {\n kind: \"dispatch-finished\",\n status,\n completed: false,\n ...(typeof recovery?.branch === \"string\"\n ? { branch: recovery.branch }\n : {}),\n ...(Array.isArray(recovery?.commits) && recovery.commits.every(isCommit)\n ? { commits: recovery.commits }\n : {}),\n usage,\n });\n try {\n session?.finish({ status, usage });\n } catch (failure) {\n failures.push(failure);\n }\n await finish();\n recordRecovery(error, {\n observerErrors: [...failures, ...observation.errors],\n ...(log?.reference ? { logReference: log.reference } : {}),\n });\n throw error;\n }\n async function finish(): Promise<void> {\n await observation.close();\n active.delete(observation);\n }\n}\n\nfunction isCommit(\n value: unknown,\n): value is import(\"../domain/workspace.types.ts\").Commit {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"oid\" in value &&\n typeof value.oid === \"string\" &&\n \"subject\" in value &&\n typeof value.subject === \"string\"\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch-observation.types.js","sourceRoot":"","sources":["../../src/application/dispatch-observation.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Usage } from \"../domain/agent.types.ts\";\n\nexport interface ObservedDispatchResult {\n readonly usage: Usage;\n readonly completed: boolean;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dispatch-observation.types.js","sourceRoot":"","sources":["../../src/application/dispatch-observation.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Usage } from \"../domain/agent.types.ts\";\n\nexport interface ObservedDispatchResult {\n readonly branch?: string;\n readonly commits?: readonly import(\"../domain/workspace.types.ts\").Commit[];\n readonly usage: Usage;\n readonly completed: boolean;\n}\n"]}
|
|
@@ -24,6 +24,8 @@ export async function preflightDispatch(options, _repository, agent) {
|
|
|
24
24
|
validateDispatch(options);
|
|
25
25
|
if (options.continuation)
|
|
26
26
|
invariant(agent?.resumable !== false, `${agent?.name} does not support continuation or fork in Outpost`);
|
|
27
|
+
if (options.continuation?.fork)
|
|
28
|
+
invariant(agent?.forkable !== false, `${agent?.name} does not support automated fork in Outpost`);
|
|
27
29
|
if (!options.response)
|
|
28
30
|
return;
|
|
29
31
|
if (options.response.repairs > 0)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch-validation.js","sourceRoot":"","sources":["../../src/application/dispatch-validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAGhF,MAAM,UAAU,gBAAgB,CAAC,OAAiC;IAChE,OAAO,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC;IACjC,aAAa,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC7B,QAAQ,CAAC,OAAO,CAAC,MAAM,IAAI,iBAAiB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC/D,SAAS,CACP,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,IAAI,iBAAiB,CAAC,MAAM,CAAC,EAChE,2BAA2B,CAC5B,CAAC;IACF,KAAK,MAAM,GAAG,IAAI,iBAAiB;QACjC,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,SAAS;YAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IAC9D,IAAI,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,YAAY;QAC1C,SAAS,CACP,CAAC,OAAO,CAAC,MAAM,IAAI,iBAAiB,CAAC,MAAM,CAAC,KAAK,CAAC,EAClD,yDAAyD,CAC1D,CAAC;IACJ,MAAM,OAAO,GACX,OAAO,CAAC,KAAK,KAAK,SAAS;QACzB,CAAC,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CAAC,CACtE,CAAC;IACF,SAAS,CACP,QAAQ,CAAC,QAAQ,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC,EAC9C,kCAAkC,OAAO,CAAC,QAAQ,CAAC,GAAG,OAAO,CAC9D,CAAC;AACJ,CAAC","sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\nimport type { Agent } from \"../domain/agent.types.ts\";\nimport { invariant, positive } from \"../domain/errors.ts\";\nimport { validateBrief } from \"../domain/prompts.ts\";\nimport { dispatchDeadlines, executionDefaults } from \"./execution.constants.ts\";\nimport type { DispatchOptions } from \"./execution.types.ts\";\n\nexport function validateDispatch(options: DispatchOptions<unknown>): void {\n options.signal?.throwIfAborted();\n validateBrief(options.brief);\n positive(options.passes ?? executionDefaults.passes, \"passes\");\n invariant(\n Number.isSafeInteger(options.passes ?? executionDefaults.passes),\n \"passes must be an integer\",\n );\n for (const key of dispatchDeadlines)\n if (options[key] !== undefined) positive(options[key], key);\n if (options.response || options.continuation)\n invariant(\n (options.passes ?? executionDefaults.passes) === 1,\n \"Structured responses and continuations require one pass\",\n );\n const markers =\n options.until === undefined\n ? []\n : typeof options.until === \"string\"\n ? [options.until]\n : options.until;\n invariant(\n markers.every((marker) => marker.length > 0),\n \"Completion markers cannot be empty\",\n );\n}\n\nexport async function preflightDispatch(\n options: DispatchOptions<unknown>,\n _repository: string,\n agent?: Agent,\n): Promise<void> {\n validateDispatch(options);\n if (options.continuation)\n invariant(\n agent?.resumable !== false,\n `${agent?.name} does not support continuation or fork in Outpost`,\n );\n if (!options.response) return;\n if (options.response.repairs > 0)\n invariant(\n agent?.resumable ?? !!(agent?.conversations || agent?.storage),\n \"Response repair requires an adapter that supports continuation\",\n );\n const brief = options.brief;\n const text = brief.text ?? (await readFile(resolve(brief.file!), \"utf8\"));\n const resolved = text.replace(/\\{\\{\\s*(\\w+)\\s*\\}\\}/g, (token, key: string) =>\n brief.values?.[key] === undefined ? token : String(brief.values[key]),\n );\n invariant(\n resolved.includes(`<${options.response.tag}>`),\n `Brief must request an opening <${options.response.tag}> tag`,\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dispatch-validation.js","sourceRoot":"","sources":["../../src/application/dispatch-validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAGhF,MAAM,UAAU,gBAAgB,CAAC,OAAiC;IAChE,OAAO,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC;IACjC,aAAa,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC7B,QAAQ,CAAC,OAAO,CAAC,MAAM,IAAI,iBAAiB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC/D,SAAS,CACP,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,IAAI,iBAAiB,CAAC,MAAM,CAAC,EAChE,2BAA2B,CAC5B,CAAC;IACF,KAAK,MAAM,GAAG,IAAI,iBAAiB;QACjC,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,SAAS;YAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IAC9D,IAAI,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,YAAY;QAC1C,SAAS,CACP,CAAC,OAAO,CAAC,MAAM,IAAI,iBAAiB,CAAC,MAAM,CAAC,KAAK,CAAC,EAClD,yDAAyD,CAC1D,CAAC;IACJ,MAAM,OAAO,GACX,OAAO,CAAC,KAAK,KAAK,SAAS;QACzB,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,OAAO,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AAC,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CACtE,CAAC;IACF,SAAS,CACP,QAAQ,CAAC,QAAQ,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC,EAC9C,kCAAkC,OAAO,CAAC,QAAQ,CAAC,GAAG,OAAO,CAC9D,CAAC;AACJ,CAAC","sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\nimport type { Agent } from \"../domain/agent.types.ts\";\nimport { invariant, positive } from \"../domain/errors.ts\";\nimport { validateBrief } from \"../domain/prompts.ts\";\nimport { dispatchDeadlines, executionDefaults } from \"./execution.constants.ts\";\nimport type { DispatchOptions } from \"./execution.types.ts\";\n\nexport function validateDispatch(options: DispatchOptions<unknown>): void {\n options.signal?.throwIfAborted();\n validateBrief(options.brief);\n positive(options.passes ?? executionDefaults.passes, \"passes\");\n invariant(\n Number.isSafeInteger(options.passes ?? executionDefaults.passes),\n \"passes must be an integer\",\n );\n for (const key of dispatchDeadlines)\n if (options[key] !== undefined) positive(options[key], key);\n if (options.response || options.continuation)\n invariant(\n (options.passes ?? executionDefaults.passes) === 1,\n \"Structured responses and continuations require one pass\",\n );\n const markers =\n options.until === undefined\n ? []\n : typeof options.until === \"string\"\n ? [options.until]\n : options.until;\n invariant(\n markers.every((marker) => marker.length > 0),\n \"Completion markers cannot be empty\",\n );\n}\n\nexport async function preflightDispatch(\n options: DispatchOptions<unknown>,\n _repository: string,\n agent?: Agent,\n): Promise<void> {\n validateDispatch(options);\n if (options.continuation)\n invariant(\n agent?.resumable !== false,\n `${agent?.name} does not support continuation or fork in Outpost`,\n );\n if (options.continuation?.fork)\n invariant(\n agent?.forkable !== false,\n `${agent?.name} does not support automated fork in Outpost`,\n );\n if (!options.response) return;\n if (options.response.repairs > 0)\n invariant(\n agent?.resumable ?? !!(agent?.conversations || agent?.storage),\n \"Response repair requires an adapter that supports continuation\",\n );\n const brief = options.brief;\n const text = brief.text ?? (await readFile(resolve(brief.file!), \"utf8\"));\n const resolved = text.replace(/\\{\\{\\s*(\\w+)\\s*\\}\\}/g, (token, key: string) =>\n brief.values?.[key] === undefined ? token : String(brief.values[key]),\n );\n invariant(\n resolved.includes(`<${options.response.tag}>`),\n `Brief must request an opening <${options.response.tag}> tag`,\n );\n}\n"]}
|
|
@@ -9,7 +9,7 @@ import { observeDispatch } from "./dispatch-observation.js";
|
|
|
9
9
|
import { createSandbox } from "./sandbox.js";
|
|
10
10
|
export async function dispatch(options) {
|
|
11
11
|
const { telemetry: _telemetry, ...configuration } = options;
|
|
12
|
-
return observeDispatch(options, (observed) => dispatchOperation({ ...configuration, ...observed }, options));
|
|
12
|
+
return observeDispatch(options, (observed) => dispatchOperation({ ...configuration, ...observed }, options), options.workspace?.repository ?? options.repository ?? process.cwd());
|
|
13
13
|
}
|
|
14
14
|
async function dispatchOperation(options, original) {
|
|
15
15
|
options.signal?.throwIfAborted();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch.js","sourceRoot":"","sources":["../../src/application/dispatch.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAM1C,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C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D,OAAO,QAAQ,CAAC;oBACd,GAAG,yBAAyB,CAAC,aAAa,EAAE,IAAI,CAAC;oBACjD,GAAG,IAAI;oBACP,YAAY,EAAE,EAAE,EAAE,EAAE,YAAY,EAAE;iBACnC,CAAC,CAAC;YACL,CAAC;YACD,IAAI,CAAI,IAA4B;gBAClC,SAAS,CAAC,YAAY,EAAE,6BAA6B,CAAC,CAAC;gBACvD,OAAO,QAAQ,CAAC;oBACd,GAAG,yBAAyB,CAAC,aAAa,EAAE,IAAI,CAAC;oBACjD,GAAG,IAAI;oBACP,YAAY,EAAE,EAAE,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE;iBAC/C,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,cAAc,CAAC,KAAK,EAAE;YACpB,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,MAAM;YAChC,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,SAAS;SACvC,CAAC,CAAC;QACH,MAAM,KAAK,CAAC;IACd,CAAC;YAAS,CAAC;QACT,IAAI,CAAC,UAAU;YAAE,MAAM,OAAO,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3D,CAAC;AACH,CAAC","sourcesContent":["import type { RequiredAgent, Usage } from \"../domain/agent.types.ts\";\nimport { invariant, recordRecovery } from \"../domain/errors.ts\";\nimport { addUsage } from \"../domain/usage.ts\";\nimport { storageFor } from \"./agent-storage.ts\";\nimport { continuationConfiguration } from \"./continuation.ts\";\nimport { preflightDispatch } from \"./dispatch-validation.ts\";\nimport { executionDefaults } from \"./execution.constants.ts\";\nimport type { DispatchOptions } from \"./execution.types.ts\";\nimport { notify } from \"./observation.ts\";\nimport type {\n ContinuationOptions,\n DispatchResult,\n SandboxOptions,\n} from \"./outpost.types.ts\";\nimport { observeDispatch } from \"./dispatch-observation.ts\";\nimport { createSandbox } from \"./sandbox.ts\";\n\nexport async function dispatch<T = undefined>(\n options: SandboxOptions & DispatchOptions<T> & RequiredAgent,\n): Promise<DispatchResult<T>> {\n const { telemetry: _telemetry, ...configuration } = options;\n return observeDispatch(\n options,\n (observed) => dispatchOperation({ ...configuration, ...observed }, options),\n options.workspace?.repository ?? options.repository ?? process.cwd(),\n );\n}\n\nasync function dispatchOperation<T>(\n options: SandboxOptions & DispatchOptions<T> & RequiredAgent,\n original: SandboxOptions & DispatchOptions<T> & RequiredAgent,\n): Promise<DispatchResult<T>> {\n options.signal?.throwIfAborted();\n await preflightDispatch(\n options,\n options.workspace?.repository ?? options.repository ?? process.cwd(),\n options.agent,\n );\n if ((options.passes ?? executionDefaults.passes) > 1) {\n const outputs: DispatchResult<T>[] = [];\n for (let index = 0; index < options.passes!; index++) {\n options.signal?.throwIfAborted();\n const output = await dispatchOperation(\n {\n ...options,\n passes: 1,\n observe: (event) =>\n notify(options.observe, { ...event, pass: index + 1 }),\n },\n original,\n );\n outputs.push(output);\n if (output.completed) break;\n }\n const last = outputs.at(-1)!;\n return {\n ...last,\n text: outputs.map((output) => output.text).join(\"\\n\"),\n turns: outputs.flatMap((output) => output.turns),\n commits: outputs.flatMap((output) => output.commits),\n usage: outputs.reduce((sum, output) => addUsage(sum, output.usage), {\n input: 0,\n cached: 0,\n output: 0,\n } as Usage),\n };\n }\n if (options.continuation) {\n const storage = storageFor(options.agent);\n invariant(storage, \"This adapter does not support native conversations\");\n await storage.locate(\n options.continuation.id,\n options.workspace?.repository ?? options.repository ?? process.cwd(),\n options.conversationHome,\n );\n }\n const sandbox = await createSandbox(options);\n const {\n brief: _brief,\n response: _response,\n continuation: _continuation,\n passes: _passes,\n ...configuration\n } = original;\n let successful = false;\n try {\n const output = await sandbox.dispatch(options);\n await sandbox.workspace.integrate();\n successful = true;\n const disposed = await sandbox.close();\n const continuation = output.conversation;\n return {\n ...output,\n ...disposed,\n resume<U>(next: ContinuationOptions<U>) {\n invariant(continuation, \"No conversation was emitted\");\n return dispatch({\n ...continuationConfiguration(configuration, next),\n ...next,\n continuation: { id: continuation },\n });\n },\n fork<U>(next: ContinuationOptions<U>) {\n invariant(continuation, \"No conversation was emitted\");\n return dispatch({\n ...continuationConfiguration(configuration, next),\n ...next,\n continuation: { id: continuation, fork: true },\n });\n },\n };\n } catch (cause) {\n recordRecovery(cause, {\n branch: sandbox.workspace.branch,\n directory: sandbox.workspace.directory,\n });\n throw cause;\n } finally {\n if (!successful) await sandbox.close({ preserve: true });\n }\n}\n"]}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { geminiDiagnostics } from "../adapters/agents/gemini-diagnostics.ts";
|
|
4
|
-
export declare const agentDiagnosticPlans: {
|
|
5
|
-
readonly gemini: typeof geminiDiagnostics;
|
|
6
|
-
readonly claude: typeof claudeDiagnostics;
|
|
7
|
-
readonly codex: typeof codexDiagnostics;
|
|
8
|
-
};
|
|
1
|
+
import type { DoctorAgent, DoctorAgentProfile } from "./doctor.types.ts";
|
|
2
|
+
export declare const doctorAgents: Readonly<Record<DoctorAgent, DoctorAgentProfile>>;
|
|
9
3
|
export declare const agentDiagnosticDefaults: Readonly<{
|
|
10
4
|
retain: 65536;
|
|
11
5
|
}>;
|