deepline 0.3.89 → 0.3.90
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/contracts/install-commands.json +29 -0
- package/dist/bundling-sources/sdk/src/client.ts +120 -37
- package/dist/bundling-sources/sdk/src/index.ts +4 -0
- package/dist/bundling-sources/sdk/src/pagination.ts +25 -0
- package/dist/bundling-sources/sdk/src/plays/bundle-play-file.ts +1 -1
- package/dist/bundling-sources/sdk/src/release.ts +16 -9
- package/dist/bundling-sources/sdk/src/types.ts +23 -0
- package/dist/bundling-sources/shared_libs/monitors/analytics-public.ts +10 -0
- package/dist/bundling-sources/shared_libs/monitors/http-error-response.ts +3 -0
- package/dist/bundling-sources/shared_libs/monitors/inbound-queue.ts +4 -4
- package/dist/bundling-sources/shared_libs/monitors/inventory-reconciliation.ts +59 -0
- package/dist/bundling-sources/shared_libs/monitors/lifecycle-notifications.ts +7 -9
- package/dist/bundling-sources/shared_libs/monitors/package.json +7 -0
- package/dist/bundling-sources/shared_libs/monitors/provider-monitor-batch-operation.ts +44 -2
- package/dist/bundling-sources/shared_libs/monitors/provider-monitor-consumer-health.ts +2 -2
- package/dist/bundling-sources/shared_libs/monitors/provider-monitor-identity-claims.ts +2 -2
- package/dist/bundling-sources/shared_libs/monitors/provider-monitor-public-aliases.ts +1 -1
- package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-dead-letter.ts +245 -0
- package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-message.ts +38 -0
- package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-queue-ack-probe.ts +94 -0
- package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-queue-delivery.ts +60 -0
- package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-queue.ts +60 -0
- package/dist/bundling-sources/shared_libs/monitors/snitcher-install-validation.ts +1 -1
- package/dist/bundling-sources/shared_libs/monitors/snitcher-ip2company.ts +2 -2
- package/dist/bundling-sources/shared_libs/monitors/snitcher-radar.ts +1 -1
- package/dist/bundling-sources/shared_libs/monitors/tracking-provider-integrations.ts +1 -1
- package/dist/bundling-sources/shared_libs/observability/build-context.ts +13 -0
- package/dist/bundling-sources/shared_libs/observability/log-metadata.ts +160 -0
- package/dist/bundling-sources/shared_libs/observability/request-context.ts +68 -0
- package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +654 -0
- package/dist/bundling-sources/shared_libs/observability/scheduled-work-manual.ts +35 -0
- package/dist/bundling-sources/shared_libs/observability/scheduled-work.ts +5 -0
- package/dist/bundling-sources/shared_libs/play-data-plane/neon-constants.ts +9 -0
- package/dist/bundling-sources/shared_libs/play-data-plane/r2.ts +272 -0
- package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +45 -0
- package/dist/bundling-sources/shared_libs/play-runtime/async-operation.ts +66 -1
- package/dist/bundling-sources/shared_libs/play-runtime/async-play-invocation.ts +0 -1
- package/dist/bundling-sources/shared_libs/play-runtime/bounceban-batching.ts +137 -0
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +779 -140
- package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +46 -0
- package/dist/bundling-sources/shared_libs/play-runtime/daytona-payload-contract.ts +68 -0
- package/dist/bundling-sources/shared_libs/play-runtime/daytona-sandbox-janitor.ts +103 -0
- package/dist/bundling-sources/shared_libs/play-runtime/daytona-sandbox-reaper.ts +725 -0
- package/dist/bundling-sources/shared_libs/play-runtime/durable-call-cache.ts +29 -0
- package/dist/bundling-sources/shared_libs/play-runtime/execution-capabilities.ts +23 -0
- package/dist/bundling-sources/shared_libs/play-runtime/execution-gateway-invocation-fence.ts +442 -0
- package/dist/bundling-sources/shared_libs/play-runtime/execution-protocol.ts +3 -3
- package/dist/bundling-sources/shared_libs/play-runtime/fixture-behavior.ts +18 -0
- package/dist/bundling-sources/shared_libs/play-runtime/governor/app-runtime-rate-state-backend.ts +9 -0
- package/dist/bundling-sources/shared_libs/play-runtime/governor/policy.ts +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/governor/rate-state-backend.ts +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/integration-operation-reader-fence/contracts.ts +66 -0
- package/dist/bundling-sources/shared_libs/play-runtime/integration-operation-reader-fence/job.ts +145 -0
- package/dist/bundling-sources/shared_libs/play-runtime/integration-operation-reader-fence/ports.ts +21 -0
- package/dist/bundling-sources/shared_libs/play-runtime/integration-operation-reader-fence/postgres-store.ts +170 -0
- package/dist/bundling-sources/shared_libs/play-runtime/internal-bootstrap-token.ts +1322 -0
- package/dist/bundling-sources/shared_libs/play-runtime/internal-step-ids.ts +2 -2
- package/dist/bundling-sources/shared_libs/play-runtime/lane-retirement-gate.ts +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/launch-source-policy.ts +112 -0
- package/dist/bundling-sources/shared_libs/play-runtime/map-execution-frame.ts +8 -0
- package/dist/bundling-sources/shared_libs/play-runtime/perf-trace.ts +127 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-artifact-runtime-contract.ts +5 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-run-recovery-policy.ts +24 -1
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/admission/contracts.ts +56 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/admission/index.ts +13 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/admission/job.ts +41 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/admission/ports.ts +17 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/admission/postgres-adapter.ts +54 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/contracts.ts +114 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/engine-suspension.ts +108 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/index.ts +36 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/job.ts +97 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/ports.ts +104 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/postgres-fence-adapter.ts +263 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/worker-terminal-projection.ts +64 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/projection/contracts.ts +29 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/projection/gateway-adapter.ts +56 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/projection/index.ts +15 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/projection/job.ts +65 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/projection/ports.ts +17 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/contracts.ts +42 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/index.ts +17 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/job.ts +142 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/ports.ts +42 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/postgres-adapter.ts +102 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/contracts.ts +60 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/index.ts +16 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/job.ts +78 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/ports.ts +54 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/postgres-adapter.ts +71 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runtime-batching-registry.ts +4 -0
- package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +2 -0
- package/dist/bundling-sources/shared_libs/play-runtime/receipt-status.ts +5 -8
- package/dist/bundling-sources/shared_libs/play-runtime/run-failure.ts +3 -5
- package/dist/bundling-sources/shared_libs/play-runtime/run-identity.ts +168 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-lifecycle.ts +72 -9
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-payload-transport.ts +6 -12
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona.ts +19 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/bundle.ts +0 -1
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/runtime-sandbox-reconciliation.ts +14 -44
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +57 -205
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-authority.ts +201 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-env.ts +6 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-operation-contract.ts +67 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-release-environment.ts +2 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-sandbox-contract.ts +68 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-scheduler-topology.ts +14 -2
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-telemetry.ts +108 -0
- package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/contract.ts +4 -0
- package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/runner-backend-adapter.ts +3 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +7 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-deadline-reconciliation.ts +88 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-play-deploy-task.ts +124 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-play-run-task.ts +68 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-pool.ts +193 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-queue-lifecycle.ts +269 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-queue-suffix.ts +73 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +6642 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-shared.ts +897 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-worker-metrics.ts +120 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-worker-required-env.ts +76 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd.ts +476 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/gateway-heavy-request-admission.ts +47 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/gateway-progress-registry.ts +147 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/index.ts +27 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/lazy.ts +50 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/play-run-recovery.ts +98 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-budget-state.ts +260 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-pool.ts +1416 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +1255 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-state.ts +942 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +14636 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/receipt-gateway.ts +888 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/run-ledger-outbox-recovery.ts +355 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/run-terminal-transition.ts +46 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runner-push.ts +60 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-api-origin.ts +33 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-receipt-gateway-health.ts +64 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-capacity.ts +835 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-ledger-reconciliation.ts +1218 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-operation.ts +207 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-scheduler-schema.ts +10 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/scheduler-capacity.ts +123 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/scheduler-launch-read-observability.ts +78 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/submit-admission.ts +169 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/terminal-contract.ts +20 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/worker-queue-metrics.ts +34 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/worker-resource-metrics.ts +249 -0
- package/dist/bundling-sources/shared_libs/play-runtime/sheet-attempt-sql.ts +7 -0
- package/dist/bundling-sources/shared_libs/play-runtime/step-progress.ts +296 -0
- package/dist/bundling-sources/shared_libs/play-runtime/tool-call/native-batch.ts +3 -3
- package/dist/bundling-sources/shared_libs/play-runtime/tool-call/runtime-step-receipts-adapter.ts +20 -1
- package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +60 -15
- package/dist/bundling-sources/shared_libs/play-runtime/tool-execution-outcome.ts +20 -0
- package/dist/bundling-sources/shared_libs/play-runtime/transient-service-error.ts +12 -0
- package/dist/bundling-sources/shared_libs/play-runtime/vercel-protection.ts +14 -1
- package/dist/bundling-sources/shared_libs/play-runtime/work-receipt-storage-contract.ts +165 -0
- package/dist/bundling-sources/shared_libs/play-runtime/work-receipts.ts +15 -23
- package/dist/bundling-sources/shared_libs/play-runtime/workflow-executor-auth.ts +169 -0
- package/dist/bundling-sources/shared_libs/play-runtime/zerobounce-batching.ts +122 -0
- package/dist/bundling-sources/shared_libs/plays/artifact-types.ts +2 -0
- package/dist/bundling-sources/shared_libs/plays/contracts.ts +2 -0
- package/dist/bundling-sources/shared_libs/plays/deployment-status.ts +1 -1
- package/dist/bundling-sources/shared_libs/plays/docflow.ts +1 -1
- package/dist/bundling-sources/shared_libs/plays/play-grep-search.ts +39 -0
- package/dist/bundling-sources/shared_libs/plays/share/copy.ts +271 -0
- package/dist/bundling-sources/shared_libs/plays/share/metrics.ts +140 -0
- package/dist/bundling-sources/shared_libs/plays/share/public-read-model.ts +86 -0
- package/dist/bundling-sources/shared_libs/plays/share/seo-quality.ts +181 -0
- package/dist/bundling-sources/shared_libs/plays/share/static-pipeline-summary.ts +658 -0
- package/dist/bundling-sources/shared_libs/plays/share/types.ts +197 -0
- package/dist/bundling-sources/shared_libs/plays/slack-hitl-timeout-error.ts +37 -0
- package/dist/bundling-sources/shared_libs/plays/static-pipeline.ts +6 -1
- package/dist/bundling-sources/shared_libs/plays/tool-result-types.ts +1 -1
- package/dist/bundling-sources/shared_libs/product-notifications/configuration.ts +7 -1
- package/dist/bundling-sources/shared_libs/product-notifications/default-policy.ts +3 -2
- package/dist/bundling-sources/shared_libs/product-notifications/overflow.ts +18 -0
- package/dist/bundling-sources/shared_libs/product-notifications/rolling-limit.ts +24 -0
- package/dist/bundling-sources/shared_libs/product-notifications/slack-delivery.ts +624 -0
- package/dist/bundling-sources/shared_libs/product-notifications/slack-payload.ts +140 -0
- package/dist/bundling-sources/shared_libs/product-notifications/slack-transport.ts +75 -0
- package/dist/bundling-sources/shared_libs/runtime-env.ts +6 -0
- package/dist/bundling-sources/shared_libs/security/email-blacklist.ts +42 -0
- package/dist/bundling-sources/shared_libs/security/header-safe-env.ts +10 -3
- package/dist/bundling-sources/shared_libs/security/slack-sanitize.ts +133 -0
- package/dist/cli/getting-started.d.mts +52 -0
- package/dist/cli/getting-started.d.ts +52 -0
- package/dist/cli/getting-started.js +65 -0
- package/dist/cli/getting-started.mjs +36 -0
- package/dist/cli/index.d.mts +9 -0
- package/dist/cli/index.d.ts +9 -0
- package/dist/cli/index.js +545 -264
- package/dist/cli/index.mjs +543 -271
- package/dist/{compiler-manifest-DsLbQaew.d.mts → compiler-manifest-BaJfE-5H.d.mts} +5 -3
- package/dist/{compiler-manifest-DsLbQaew.d.ts → compiler-manifest-BaJfE-5H.d.ts} +5 -3
- package/dist/index.d.mts +81 -148
- package/dist/index.d.ts +81 -148
- package/dist/index.js +83 -26
- package/dist/index.mjs +83 -26
- package/dist/install-integrity.json +130 -2
- package/dist/monitor-fleet-contract.d.mts +138 -0
- package/dist/monitor-fleet-contract.d.ts +138 -0
- package/dist/monitor-fleet-contract.js +404 -0
- package/dist/monitor-fleet-contract.mjs +367 -0
- package/dist/plays/bundle-play-file.d.mts +2 -2
- package/dist/plays/bundle-play-file.d.ts +2 -2
- package/dist/release.d.mts +255 -0
- package/dist/release.d.ts +255 -0
- package/dist/release.js +215 -0
- package/dist/release.mjs +188 -0
- package/package.json +21 -4
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import {
|
|
2
|
+
resolvePlayRunTerminalAuthority,
|
|
3
|
+
type PlayRunTerminalInput,
|
|
4
|
+
type PlayRunTerminalJob,
|
|
5
|
+
type PlayRunTerminalOutcome,
|
|
6
|
+
} from '../../play-runs/terminal/contracts';
|
|
7
|
+
import type { PlayRunTerminalPorts } from '../../play-runs/terminal/ports';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Play Run Terminal Job.
|
|
11
|
+
*
|
|
12
|
+
* The job owns the terminal transition law:
|
|
13
|
+
*
|
|
14
|
+
* atomic direct transition → terminal outcome
|
|
15
|
+
* otherwise durable compatibility receipt → wake
|
|
16
|
+
*
|
|
17
|
+
* Infrastructure only supplies the three capabilities. In particular, no
|
|
18
|
+
* caller can accidentally publish a wake before the compatibility receipt is
|
|
19
|
+
* durable, or publish after a stale fence rejected its write.
|
|
20
|
+
*/
|
|
21
|
+
export function createPlayRunTerminalJob(
|
|
22
|
+
ports: PlayRunTerminalPorts,
|
|
23
|
+
): PlayRunTerminalJob {
|
|
24
|
+
return {
|
|
25
|
+
async accept(input: PlayRunTerminalInput): Promise<PlayRunTerminalOutcome> {
|
|
26
|
+
// The public compatibility facade historically accepted a manually
|
|
27
|
+
// constructed authority as well as the parsed ingress value. Normalize
|
|
28
|
+
// it again here so whitespace cannot turn an invalid lease into a direct
|
|
29
|
+
// terminal write when a caller bypasses the parser.
|
|
30
|
+
const authority = resolvePlayRunTerminalAuthority(input.authority ?? {});
|
|
31
|
+
const direct = authority
|
|
32
|
+
? await ports.directCommitter.commit({
|
|
33
|
+
runId: input.runId,
|
|
34
|
+
attempt: input.attempt,
|
|
35
|
+
authority,
|
|
36
|
+
result: input.result,
|
|
37
|
+
queueName: input.queueName,
|
|
38
|
+
// An authority exists only for the one terminal contract this
|
|
39
|
+
// build recognizes, and that contract is what proves the durable
|
|
40
|
+
// compute-billing controller. An absent or unrecognized contract
|
|
41
|
+
// never reaches here: it resolves to null above and wakes instead.
|
|
42
|
+
allowCappedCompletion: true,
|
|
43
|
+
})
|
|
44
|
+
: 'wake_required';
|
|
45
|
+
|
|
46
|
+
if (direct === 'not_found') {
|
|
47
|
+
return { kind: 'not_found_or_fence_rejected' };
|
|
48
|
+
}
|
|
49
|
+
if (direct === 'completed') {
|
|
50
|
+
return { kind: 'direct_completed' };
|
|
51
|
+
}
|
|
52
|
+
if (direct === 'stale_cleaned') {
|
|
53
|
+
return { kind: 'stale_attempt_cleaned' };
|
|
54
|
+
}
|
|
55
|
+
if (direct === 'already_terminal') {
|
|
56
|
+
// Mixed-version recovery is first-write-wins. Re-emitting can retire a
|
|
57
|
+
// historical parked invocation whose prior transition predates atomic
|
|
58
|
+
// retirement-event recording.
|
|
59
|
+
await ports.wakePublisher.publish(input);
|
|
60
|
+
return { kind: 'already_terminal' };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const recorded = await ports.compatibilityRecorder.record({
|
|
64
|
+
runId: input.runId,
|
|
65
|
+
attempt: input.attempt,
|
|
66
|
+
result: input.result,
|
|
67
|
+
});
|
|
68
|
+
if (!recorded) {
|
|
69
|
+
return { kind: 'not_found_or_fence_rejected' };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// The event carries no terminal payload. A resumed attempt reads truth
|
|
73
|
+
// from its durable store rather than trusting a message body.
|
|
74
|
+
await ports.wakePublisher.publish(input);
|
|
75
|
+
return { kind: 'compatibility_wake_queued' };
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
PlayRunTerminalAuthority,
|
|
3
|
+
PlayRunTerminalInput,
|
|
4
|
+
} from '../../play-runs/terminal/contracts';
|
|
5
|
+
|
|
6
|
+
/** The result of the atomic terminal-transition capability. */
|
|
7
|
+
export type DirectTerminalCommitOutcome =
|
|
8
|
+
| 'completed'
|
|
9
|
+
| 'stale_cleaned'
|
|
10
|
+
| 'already_terminal'
|
|
11
|
+
| 'not_found'
|
|
12
|
+
| 'wake_required';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Capability for the modern atomic terminal transition. An implementation
|
|
16
|
+
* commits run truth, cleanup/billing obligations, terminal log outbox, and
|
|
17
|
+
* retirement event as one transaction when it returns `completed`.
|
|
18
|
+
*/
|
|
19
|
+
export type DirectTerminalCommitter = {
|
|
20
|
+
commit(input: {
|
|
21
|
+
runId: string;
|
|
22
|
+
attempt: number;
|
|
23
|
+
authority: PlayRunTerminalAuthority;
|
|
24
|
+
result: unknown;
|
|
25
|
+
queueName: string;
|
|
26
|
+
allowCappedCompletion: boolean;
|
|
27
|
+
}): Promise<DirectTerminalCommitOutcome>;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Compatibility-only durable write. It persists a runner terminal before the
|
|
32
|
+
* wake is published; false means a stale/missing attempt won and no event may
|
|
33
|
+
* be emitted.
|
|
34
|
+
*/
|
|
35
|
+
export type CompatibilityTerminalRecorder = {
|
|
36
|
+
record(input: {
|
|
37
|
+
runId: string;
|
|
38
|
+
attempt: number;
|
|
39
|
+
result: unknown;
|
|
40
|
+
}): Promise<boolean>;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/** Publishes the wake only after terminal truth has become durable. */
|
|
44
|
+
export type RunnerTerminalWakePublisher = {
|
|
45
|
+
publish(
|
|
46
|
+
input: Pick<PlayRunTerminalInput, 'queueName' | 'runId' | 'attempt'>,
|
|
47
|
+
): Promise<void>;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export type PlayRunTerminalPorts = {
|
|
51
|
+
directCommitter: DirectTerminalCommitter;
|
|
52
|
+
compatibilityRecorder: CompatibilityTerminalRecorder;
|
|
53
|
+
wakePublisher: RunnerTerminalWakePublisher;
|
|
54
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { ABSURD_WAKE_CHANNEL } from '@deepline/absurd/sdk';
|
|
2
|
+
|
|
3
|
+
import { absurdRunnerTerminalEventName } from '../../scheduler-backends/absurd-shared';
|
|
4
|
+
import {
|
|
5
|
+
directCompletePostgresSchedulerRunnerTerminal,
|
|
6
|
+
recordPostgresSchedulerRunnerTerminal,
|
|
7
|
+
type PostgresSchedulerQueryClient,
|
|
8
|
+
} from '../../scheduler-backends/postgres';
|
|
9
|
+
import type { PlayRunTerminalPorts } from '../../play-runs/terminal/ports';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Postgres implementation of the Play Run Terminal capabilities.
|
|
13
|
+
*
|
|
14
|
+
* This adapter is intentionally the only place this module knows scheduler
|
|
15
|
+
* SQL, the Absurd event name, or PostgreSQL notification transport.
|
|
16
|
+
*/
|
|
17
|
+
export function createPostgresPlayRunTerminalPorts(input: {
|
|
18
|
+
client: PostgresSchedulerQueryClient;
|
|
19
|
+
schema?: string;
|
|
20
|
+
}): PlayRunTerminalPorts {
|
|
21
|
+
const options = input.schema ? { schema: input.schema } : undefined;
|
|
22
|
+
return {
|
|
23
|
+
directCommitter: {
|
|
24
|
+
async commit(terminal) {
|
|
25
|
+
return await directCompletePostgresSchedulerRunnerTerminal(
|
|
26
|
+
input.client,
|
|
27
|
+
{
|
|
28
|
+
runId: terminal.runId,
|
|
29
|
+
attempt: terminal.attempt,
|
|
30
|
+
leaseToken: terminal.authority.leaseToken,
|
|
31
|
+
result: terminal.result,
|
|
32
|
+
terminalLogOutbox: 'ctx_log_tail',
|
|
33
|
+
allowCappedCompletion: terminal.allowCappedCompletion,
|
|
34
|
+
engineWake: {
|
|
35
|
+
queueName: terminal.queueName,
|
|
36
|
+
eventName: absurdRunnerTerminalEventName(
|
|
37
|
+
terminal.runId,
|
|
38
|
+
terminal.attempt,
|
|
39
|
+
),
|
|
40
|
+
wakeChannel: ABSURD_WAKE_CHANNEL,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
options,
|
|
44
|
+
);
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
compatibilityRecorder: {
|
|
48
|
+
async record(terminal) {
|
|
49
|
+
return await recordPostgresSchedulerRunnerTerminal(
|
|
50
|
+
input.client,
|
|
51
|
+
terminal,
|
|
52
|
+
options,
|
|
53
|
+
);
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
wakePublisher: {
|
|
57
|
+
async publish(terminal) {
|
|
58
|
+
await input.client.query(
|
|
59
|
+
`WITH emitted AS (
|
|
60
|
+
SELECT absurd.emit_event($1, $2, 'null'::jsonb)
|
|
61
|
+
)
|
|
62
|
+
SELECT pg_notify('${ABSURD_WAKE_CHANNEL}', $1) FROM emitted`,
|
|
63
|
+
[
|
|
64
|
+
terminal.queueName,
|
|
65
|
+
absurdRunnerTerminalEventName(terminal.runId, terminal.attempt),
|
|
66
|
+
],
|
|
67
|
+
);
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { bouncebanBatchStrategies } from './/bounceban-batching';
|
|
1
2
|
import type { AnyBatchOperationStrategy } from './batching-types';
|
|
2
3
|
import { bettercontactBatchStrategies } from './bettercontact-batching';
|
|
3
4
|
import { DEFAULT_PLAY_RUNTIME_BATCH_STRATEGIES } from './default-batch-strategies';
|
|
4
5
|
import { fullenrichBatchStrategies } from './fullenrich-batching';
|
|
5
6
|
import { opensosdataBatchStrategies } from './opensosdata-batching';
|
|
7
|
+
import { zerobounceBatchStrategies } from './zerobounce-batching';
|
|
6
8
|
import { testAsyncBatchStrategies } from './test-async-batching';
|
|
7
9
|
|
|
8
10
|
export const PLAY_RUNTIME_BATCH_OPERATION_REGISTRY: Record<
|
|
@@ -11,9 +13,11 @@ export const PLAY_RUNTIME_BATCH_OPERATION_REGISTRY: Record<
|
|
|
11
13
|
> = {
|
|
12
14
|
...DEFAULT_PLAY_RUNTIME_BATCH_STRATEGIES,
|
|
13
15
|
...bettercontactBatchStrategies,
|
|
16
|
+
...bouncebanBatchStrategies,
|
|
14
17
|
...fullenrichBatchStrategies,
|
|
15
18
|
...opensosdataBatchStrategies,
|
|
16
19
|
...testAsyncBatchStrategies,
|
|
20
|
+
...zerobounceBatchStrategies,
|
|
17
21
|
};
|
|
18
22
|
|
|
19
23
|
export function getPlayRuntimeBatchStrategy(
|
|
@@ -152,6 +152,8 @@ export interface PlayRunnerContextConfig {
|
|
|
152
152
|
workflowId?: string;
|
|
153
153
|
playId?: string;
|
|
154
154
|
runId?: string;
|
|
155
|
+
/** Original run for an explicit user-requested replay. */
|
|
156
|
+
replayedFromRunId?: string | null;
|
|
155
157
|
/** Shared governance/billing root. Differs from runId for async children. */
|
|
156
158
|
rootRunId?: string;
|
|
157
159
|
runAttempt?: number | null;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import type { WorkReceiptStatus } from './work-receipts';
|
|
2
|
+
import { WORK_RECEIPT_STATUS_CODE } from './work-receipt-storage-contract';
|
|
2
3
|
|
|
3
|
-
export const RECEIPT_STATUS_CODE =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
completed: 2,
|
|
8
|
-
failed: 3,
|
|
9
|
-
skipped: 4,
|
|
10
|
-
} as const satisfies Record<WorkReceiptStatus, number>;
|
|
4
|
+
export const RECEIPT_STATUS_CODE = WORK_RECEIPT_STATUS_CODE satisfies Record<
|
|
5
|
+
WorkReceiptStatus,
|
|
6
|
+
number
|
|
7
|
+
>;
|
|
11
8
|
|
|
12
9
|
export type ReceiptStatusCode =
|
|
13
10
|
(typeof RECEIPT_STATUS_CODE)[keyof typeof RECEIPT_STATUS_CODE];
|
|
@@ -63,10 +63,10 @@ export const WORKSPACE_STORAGE_NOT_READY_CODE = 'WORKSPACE_STORAGE_NOT_READY';
|
|
|
63
63
|
// postgres-URI passwords). The raw pg error goes in the Error `cause` for server
|
|
64
64
|
// logs only, never into this message or the normalized public failure.
|
|
65
65
|
export const WORKSPACE_STORAGE_NOT_READY_MESSAGE =
|
|
66
|
-
'
|
|
66
|
+
'Deepline could not prepare your workspace storage in time, so this operation did not start. ' +
|
|
67
|
+
'Try again in a few moments. You do not need to run a database command. ' +
|
|
67
68
|
'This blocked operation did not use Deepline credits. ' +
|
|
68
69
|
'Earlier completed operations in the same run may already have used credits. ' +
|
|
69
|
-
'Re-run the command. If it fails again, ask an organization admin to run `deepline db repair` (POST /api/v2/ingestion/repair), then re-run. ' +
|
|
70
70
|
'If this keeps happening, contact Deepline support with the run ID.';
|
|
71
71
|
|
|
72
72
|
export class WorkspaceStorageNotReadyError extends Error {
|
|
@@ -177,9 +177,7 @@ export class ProviderExhaustedError extends Error {
|
|
|
177
177
|
* `ToolExecutionError` shape. Treat those two representations as the same
|
|
178
178
|
* typed exhaustion outcome; do not fall back based on a message substring.
|
|
179
179
|
*/
|
|
180
|
-
export function isProviderExhaustedFailure(
|
|
181
|
-
error: unknown,
|
|
182
|
-
): error is
|
|
180
|
+
export function isProviderExhaustedFailure(error: unknown): error is
|
|
183
181
|
| ProviderExhaustedError
|
|
184
182
|
| (ToolExecutionError & {
|
|
185
183
|
readonly origin: 'provider';
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { sha256Hex, stableStringify } from '../plays/row-identity';
|
|
2
|
+
function sanitizePlayNameForWorkflowSegment(value: string): string {
|
|
3
|
+
return value
|
|
4
|
+
.toLowerCase()
|
|
5
|
+
.replace(/[^a-z0-9-]/g, '-')
|
|
6
|
+
.replace(/-+/g, '-')
|
|
7
|
+
.replace(/^-+|-+$/g, '')
|
|
8
|
+
.slice(0, 64);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function buildPlayWorkflowFamilyKey(playName: string): string {
|
|
12
|
+
const normalized = playName
|
|
13
|
+
.split('/')
|
|
14
|
+
.map(sanitizePlayNameForWorkflowSegment)
|
|
15
|
+
.filter(Boolean)
|
|
16
|
+
.join('/');
|
|
17
|
+
return normalized || 'play';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function buildPlayWorkflowRunSuffix(now: Date): string {
|
|
21
|
+
const pad = (value: number, size = 2) => String(value).padStart(size, '0');
|
|
22
|
+
return [
|
|
23
|
+
now.getUTCFullYear(),
|
|
24
|
+
pad(now.getUTCMonth() + 1),
|
|
25
|
+
pad(now.getUTCDate()),
|
|
26
|
+
't',
|
|
27
|
+
pad(now.getUTCHours()),
|
|
28
|
+
pad(now.getUTCMinutes()),
|
|
29
|
+
pad(now.getUTCSeconds()),
|
|
30
|
+
'-',
|
|
31
|
+
pad(now.getUTCMilliseconds(), 3),
|
|
32
|
+
].join('');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const CANONICAL_PLAY_RUN_TIMESTAMP_RE =
|
|
36
|
+
/\/run\/(\d{4})(\d{2})(\d{2})t(\d{2})(\d{2})(\d{2})-(\d{3})(?:-|$)/;
|
|
37
|
+
|
|
38
|
+
/** Read the UTC creation time embedded in a canonical root play-run id. */
|
|
39
|
+
export function canonicalPlayRunStartedAtMs(runId: string): number | null {
|
|
40
|
+
const match = CANONICAL_PLAY_RUN_TIMESTAMP_RE.exec(runId);
|
|
41
|
+
if (!match) return null;
|
|
42
|
+
const [, year, month, day, hour, minute, second, millisecond] = match;
|
|
43
|
+
const value = Date.UTC(
|
|
44
|
+
Number(year),
|
|
45
|
+
Number(month) - 1,
|
|
46
|
+
Number(day),
|
|
47
|
+
Number(hour),
|
|
48
|
+
Number(minute),
|
|
49
|
+
Number(second),
|
|
50
|
+
Number(millisecond),
|
|
51
|
+
);
|
|
52
|
+
if (!Number.isFinite(value)) return null;
|
|
53
|
+
const roundTrip = new Date(value);
|
|
54
|
+
return roundTrip.getUTCFullYear() === Number(year) &&
|
|
55
|
+
roundTrip.getUTCMonth() === Number(month) - 1 &&
|
|
56
|
+
roundTrip.getUTCDate() === Number(day) &&
|
|
57
|
+
roundTrip.getUTCHours() === Number(hour) &&
|
|
58
|
+
roundTrip.getUTCMinutes() === Number(minute) &&
|
|
59
|
+
roundTrip.getUTCSeconds() === Number(second) &&
|
|
60
|
+
roundTrip.getUTCMilliseconds() === Number(millisecond)
|
|
61
|
+
? value
|
|
62
|
+
: null;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
type BuildPlayWorkflowIdOptions = {
|
|
66
|
+
/**
|
|
67
|
+
* Add entropy for new run creation. Keep false for tests and explicit
|
|
68
|
+
* externally-owned ids that need deterministic reconstruction.
|
|
69
|
+
*/
|
|
70
|
+
unique?: boolean;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
function buildRunEntropySuffix(): string {
|
|
74
|
+
const randomUuid = globalThis.crypto?.randomUUID?.();
|
|
75
|
+
if (randomUuid) {
|
|
76
|
+
return randomUuid.replace(/-/g, '').slice(0, 8);
|
|
77
|
+
}
|
|
78
|
+
return Math.random().toString(36).slice(2, 10).padEnd(8, '0');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function buildPlayWorkflowId(
|
|
82
|
+
playName: string,
|
|
83
|
+
now?: Date,
|
|
84
|
+
options: BuildPlayWorkflowIdOptions = {},
|
|
85
|
+
): string {
|
|
86
|
+
const familyKey = buildPlayWorkflowFamilyKey(playName);
|
|
87
|
+
const timestamp = now ?? new Date();
|
|
88
|
+
const unique = options.unique ?? now === undefined;
|
|
89
|
+
const entropy = unique ? `-${buildRunEntropySuffix()}` : '';
|
|
90
|
+
return `play/${familyKey}/run/${buildPlayWorkflowRunSuffix(timestamp)}${entropy}`;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export type PlayRunIdentity = {
|
|
94
|
+
workflowId: string;
|
|
95
|
+
runId: string;
|
|
96
|
+
workflowFamilyKey: string;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Convex and runtime schedulers share one run identity contract.
|
|
101
|
+
*
|
|
102
|
+
* - `workflowId` is the unique execution id.
|
|
103
|
+
* - `runId` is the same execution id surfaced in dashboard/API state.
|
|
104
|
+
* - `workflowFamilyKey` is the stable play-name-derived family/group key.
|
|
105
|
+
*
|
|
106
|
+
* Keeping these three values explicit removes the old ambiguity where one field
|
|
107
|
+
* pretended to mean both "this specific run" and "this play family".
|
|
108
|
+
*/
|
|
109
|
+
export function buildPlayRunIdentity(
|
|
110
|
+
playName: string,
|
|
111
|
+
now?: Date,
|
|
112
|
+
options: BuildPlayWorkflowIdOptions = {},
|
|
113
|
+
): PlayRunIdentity {
|
|
114
|
+
const workflowId = buildPlayWorkflowId(playName, now, {
|
|
115
|
+
unique: options.unique ?? now === undefined,
|
|
116
|
+
});
|
|
117
|
+
return {
|
|
118
|
+
workflowId,
|
|
119
|
+
runId: workflowId,
|
|
120
|
+
workflowFamilyKey: buildPlayWorkflowFamilyKey(playName),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Build the replay-stable identity for one ctx.runPlayAsync invocation.
|
|
126
|
+
*
|
|
127
|
+
* The parent's embedded timestamp keeps ordinary run ordering useful while
|
|
128
|
+
* the digest makes retries converge on exactly one independently scheduled
|
|
129
|
+
* child. Input is deliberately excluded: a changed request must conflict with
|
|
130
|
+
* the first immutable launch rather than silently minting another Run.
|
|
131
|
+
*/
|
|
132
|
+
export function buildAsyncPlayRunIdentity(input: {
|
|
133
|
+
playName: string;
|
|
134
|
+
parentRunId: string;
|
|
135
|
+
invocationKey: string;
|
|
136
|
+
}): PlayRunIdentity {
|
|
137
|
+
const digest = sha256Hex(
|
|
138
|
+
`${input.parentRunId}\0${input.invocationKey}`,
|
|
139
|
+
).slice(0, 20);
|
|
140
|
+
const parentStartedAt = canonicalPlayRunStartedAtMs(input.parentRunId) ?? 0;
|
|
141
|
+
// The run id is the durable identity of the authored invocation, so it must
|
|
142
|
+
// be reconstructible before resolving a mutable live Play reference. The
|
|
143
|
+
// workflow family remains the resolved child Play for grouping and display.
|
|
144
|
+
const base = buildPlayWorkflowId('async-child', new Date(parentStartedAt), {
|
|
145
|
+
unique: false,
|
|
146
|
+
});
|
|
147
|
+
const workflowId = `${base}-async-${digest}`;
|
|
148
|
+
return {
|
|
149
|
+
workflowId,
|
|
150
|
+
runId: workflowId,
|
|
151
|
+
workflowFamilyKey: buildPlayWorkflowFamilyKey(input.playName),
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** Immutable authored request identity, separate from the resolved revision. */
|
|
156
|
+
export function buildAsyncPlayRequestFingerprint(input: {
|
|
157
|
+
key: string;
|
|
158
|
+
playRef: string;
|
|
159
|
+
childInput: Record<string, unknown>;
|
|
160
|
+
}): string {
|
|
161
|
+
return sha256Hex(
|
|
162
|
+
stableStringify({
|
|
163
|
+
key: input.key,
|
|
164
|
+
playRef: input.playRef,
|
|
165
|
+
input: input.childInput,
|
|
166
|
+
}),
|
|
167
|
+
);
|
|
168
|
+
}
|
package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-lifecycle.ts
CHANGED
|
@@ -92,6 +92,20 @@ export class DaytonaSandboxAcquisitionUnavailableError extends Error {
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
/**
|
|
96
|
+
* A named Daytona create is still changing state after the client deadline.
|
|
97
|
+
* The scheduler must defer and resume this exact identity; falling back or
|
|
98
|
+
* creating another sandbox could execute the Play twice.
|
|
99
|
+
*/
|
|
100
|
+
export class DaytonaSandboxTransitionPendingError extends Error {
|
|
101
|
+
constructor(readonly sandboxName: string) {
|
|
102
|
+
super(
|
|
103
|
+
`Daytona sandbox ${sandboxName} is still transitioning after create timed out.`,
|
|
104
|
+
);
|
|
105
|
+
this.name = 'DaytonaSandboxTransitionPendingError';
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
95
109
|
export function resolveDaytonaSandboxAcquisitionUnavailableReason(
|
|
96
110
|
errors: readonly string[],
|
|
97
111
|
): DaytonaSandboxAcquisitionUnavailableReason | null {
|
|
@@ -326,7 +340,8 @@ async function createOneShotDaytonaSandbox(input: {
|
|
|
326
340
|
type TimedOutDaytonaSandboxReconciliation =
|
|
327
341
|
| { kind: 'started'; sandbox: DaytonaSandbox }
|
|
328
342
|
| { kind: 'deleted' }
|
|
329
|
-
| { kind: 'not_found' }
|
|
343
|
+
| { kind: 'not_found' }
|
|
344
|
+
| { kind: 'transition_pending' };
|
|
330
345
|
|
|
331
346
|
async function reconcileAndDeleteTimedOutDaytonaSandbox(input: {
|
|
332
347
|
daytona: DaytonaClient;
|
|
@@ -376,23 +391,28 @@ async function reconcileAndDeleteTimedOutDaytonaSandbox(input: {
|
|
|
376
391
|
return { kind: 'deleted' };
|
|
377
392
|
}
|
|
378
393
|
if (lastDeleteConflict) {
|
|
379
|
-
|
|
380
|
-
`Daytona timed-out sandbox ${input.sandboxName} remained in a state transition across the bounded cleanup window. Modal fallback suppressed.`,
|
|
381
|
-
{ cause: lastDeleteConflict },
|
|
382
|
-
);
|
|
394
|
+
return { kind: 'transition_pending' };
|
|
383
395
|
}
|
|
384
396
|
return { kind: 'not_found' };
|
|
385
397
|
}
|
|
386
398
|
|
|
399
|
+
function daytonaSandboxName(providerOperationToken?: string | null): string {
|
|
400
|
+
return providerOperationToken
|
|
401
|
+
? `dl-${providerOperationToken}`
|
|
402
|
+
: `dl-${crypto.randomUUID()}`;
|
|
403
|
+
}
|
|
404
|
+
|
|
387
405
|
async function createRetriedOneShotDaytonaSandbox(input: {
|
|
388
406
|
daytona: DaytonaClient;
|
|
389
407
|
orgId: string;
|
|
390
408
|
context: DaytonaExecutionContext;
|
|
391
409
|
emitStage: DaytonaStageEmitter;
|
|
392
410
|
observeCreateCall?: DaytonaCreateCallObserver;
|
|
393
|
-
reserveSandboxCapacity?: (
|
|
394
|
-
|
|
395
|
-
|
|
411
|
+
reserveSandboxCapacity?: (providerAttempt: number) => Promise<{
|
|
412
|
+
leaseId: string;
|
|
413
|
+
providerOperationToken: string | null;
|
|
414
|
+
resumeExistingProviderOperation?: boolean;
|
|
415
|
+
}>;
|
|
396
416
|
releaseSandboxCapacity?: (leaseId: string) => Promise<void>;
|
|
397
417
|
nextProviderAttempt: () => number;
|
|
398
418
|
startedAt: number;
|
|
@@ -400,7 +420,6 @@ async function createRetriedOneShotDaytonaSandbox(input: {
|
|
|
400
420
|
const errors: string[] = [];
|
|
401
421
|
for (const [index, delayMs] of DAYTONA_CREATE_RETRY_DELAYS_MS.entries()) {
|
|
402
422
|
const attempt = input.nextProviderAttempt();
|
|
403
|
-
const sandboxName = `dl-${crypto.randomUUID()}`;
|
|
404
423
|
if (delayMs > 0) {
|
|
405
424
|
input.emitStage('create:retry', {
|
|
406
425
|
attempt: index,
|
|
@@ -417,6 +436,40 @@ async function createRetriedOneShotDaytonaSandbox(input: {
|
|
|
417
436
|
providerAttempt: attempt,
|
|
418
437
|
});
|
|
419
438
|
const reservation = await input.reserveSandboxCapacity?.(attempt);
|
|
439
|
+
const sandboxName = daytonaSandboxName(reservation?.providerOperationToken);
|
|
440
|
+
if (reservation?.resumeExistingProviderOperation) {
|
|
441
|
+
if (!input.daytona.get) {
|
|
442
|
+
throw new DaytonaSandboxTransitionPendingError(sandboxName);
|
|
443
|
+
}
|
|
444
|
+
try {
|
|
445
|
+
const sandbox = await input.daytona.get(sandboxName);
|
|
446
|
+
if (sandbox.state !== 'started') {
|
|
447
|
+
throw new DaytonaSandboxTransitionPendingError(sandboxName);
|
|
448
|
+
}
|
|
449
|
+
const acquiredAt = Date.now();
|
|
450
|
+
input.emitStage('create:resumed', {
|
|
451
|
+
attempt,
|
|
452
|
+
elapsedMs: acquiredAt - input.startedAt,
|
|
453
|
+
sandboxId: sandbox.id,
|
|
454
|
+
});
|
|
455
|
+
return {
|
|
456
|
+
sandbox,
|
|
457
|
+
attempt,
|
|
458
|
+
attemptElapsedMs: acquiredAt - attemptStartedAt,
|
|
459
|
+
sandboxCapacityLeaseId: reservation.leaseId,
|
|
460
|
+
};
|
|
461
|
+
} catch (error) {
|
|
462
|
+
if (error instanceof DaytonaSandboxTransitionPendingError) throw error;
|
|
463
|
+
if (!isDaytonaSandboxNotFound(error)) {
|
|
464
|
+
throw new DaytonaSandboxTransitionPendingError(sandboxName);
|
|
465
|
+
}
|
|
466
|
+
await input.releaseSandboxCapacity?.(reservation.leaseId);
|
|
467
|
+
throw new DaytonaSandboxAcquisitionUnavailableError(
|
|
468
|
+
'daytona_sandbox_start_timeout',
|
|
469
|
+
`Timed-out Daytona sandbox ${sandboxName} was confirmed absent before resume.`,
|
|
470
|
+
);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
420
473
|
let sandbox: DaytonaSandbox;
|
|
421
474
|
try {
|
|
422
475
|
sandbox = await createOneShotDaytonaSandbox({
|
|
@@ -496,6 +549,15 @@ async function createRetriedOneShotDaytonaSandbox(input: {
|
|
|
496
549
|
};
|
|
497
550
|
}
|
|
498
551
|
await recordCreateFailure();
|
|
552
|
+
if (reconciliation.kind === 'transition_pending') {
|
|
553
|
+
if (reservation?.providerOperationToken) {
|
|
554
|
+
throw new DaytonaSandboxTransitionPendingError(sandboxName);
|
|
555
|
+
}
|
|
556
|
+
throw new Error(
|
|
557
|
+
`Daytona timed-out sandbox ${sandboxName} remained in a state transition across the bounded cleanup window. Modal fallback suppressed.`,
|
|
558
|
+
{ cause: error },
|
|
559
|
+
);
|
|
560
|
+
}
|
|
499
561
|
if (reconciliation.kind === 'deleted') {
|
|
500
562
|
// The provider-confirmed reconciliation means this reservation can
|
|
501
563
|
// no longer represent a live sandbox. Release before returning the
|
|
@@ -693,6 +755,7 @@ export function createOneShotDaytonaSandboxLifecycle(input: {
|
|
|
693
755
|
reserveSandboxCapacity?: (providerAttempt: number) => Promise<{
|
|
694
756
|
leaseId: string;
|
|
695
757
|
providerOperationToken: string | null;
|
|
758
|
+
resumeExistingProviderOperation?: boolean;
|
|
696
759
|
}>;
|
|
697
760
|
releaseSandboxCapacity?: (leaseId: string) => Promise<void>;
|
|
698
761
|
startAdmission?: DaytonaSandboxStartAdmission;
|
|
@@ -26,6 +26,11 @@ import {
|
|
|
26
26
|
RUNTIME_SANDBOX_KILLED_MESSAGE,
|
|
27
27
|
RUNTIME_SANDBOX_OOM_MESSAGE,
|
|
28
28
|
} from '../../run-failure';
|
|
29
|
+
import {
|
|
30
|
+
buildDaytonaPayloadMaterializerSource,
|
|
31
|
+
type DaytonaPayloadEnvelope,
|
|
32
|
+
} from '../../daytona-payload-contract';
|
|
33
|
+
export { buildDaytonaPayloadMaterializerSource } from '../../daytona-payload-contract';
|
|
29
34
|
import { compactPlayArtifactForRuntimeTransport } from '../../../plays/artifact-transport';
|
|
30
35
|
import type {
|
|
31
36
|
DaytonaExecutionContext,
|
|
@@ -36,16 +41,6 @@ import { buildDaytonaRuntimeWatchdogSource } from './daytona-runtime-watchdog';
|
|
|
36
41
|
|
|
37
42
|
type DaytonaRemoteRuntimeContext = PlayRunnerExecutionConfig['context'];
|
|
38
43
|
|
|
39
|
-
type DaytonaPayloadEnvelope = {
|
|
40
|
-
schemaVersion: 1;
|
|
41
|
-
runnerCode: string;
|
|
42
|
-
artifactBundledCode: string;
|
|
43
|
-
artifactSourceMap: string;
|
|
44
|
-
config: PlayRunnerExecutionConfig;
|
|
45
|
-
/** Crash-containment epilogue script (see buildDaytonaCrashTerminalPusherSource). */
|
|
46
|
-
crashPusherCode: string;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
44
|
/**
|
|
50
45
|
* The crash pusher must be able to recover one complete terminal event after
|
|
51
46
|
* a runner exits before its primary gateway push. A stdout `result` event is
|
|
@@ -116,8 +111,7 @@ function nodeMaterializePayloadCommand(input: {
|
|
|
116
111
|
artifactSourceMapPath: string;
|
|
117
112
|
crashPusherPath: string;
|
|
118
113
|
}): string {
|
|
119
|
-
const script =
|
|
120
|
-
"const fs=require('node:fs');const zlib=require('node:zlib');const p=JSON.parse(zlib.gunzipSync(fs.readFileSync(process.argv[1])));if(p.schemaVersion!==1)throw new Error('Unsupported Daytona payload envelope');fs.writeFileSync(process.argv[2],p.runnerCode);fs.writeFileSync(process.argv[3],JSON.stringify(p.config));fs.writeFileSync(process.argv[4],p.artifactBundledCode);fs.writeFileSync(process.argv[5],p.artifactSourceMap);fs.writeFileSync(process.argv[6],p.crashPusherCode);";
|
|
114
|
+
const script = buildDaytonaPayloadMaterializerSource();
|
|
121
115
|
return [
|
|
122
116
|
'node',
|
|
123
117
|
'-e',
|