deepline 0.1.198 → 0.1.200

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.
Files changed (72) hide show
  1. package/dist/bundling-sources/apps/play-runner-workers/src/coordinator-entry.ts +5 -1
  2. package/dist/bundling-sources/apps/play-runner-workers/src/entry.ts +51 -17
  3. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/README.md +1 -1
  4. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/harness-receipt-store.ts +16 -0
  5. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/receipts.ts +40 -9
  6. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/tool-dispatch.ts +108 -39
  7. package/dist/bundling-sources/sdk/src/http.ts +5 -2
  8. package/dist/bundling-sources/sdk/src/play.ts +1 -1
  9. package/dist/bundling-sources/sdk/src/plays/harness-stub.ts +7 -0
  10. package/dist/bundling-sources/sdk/src/release.ts +2 -2
  11. package/dist/bundling-sources/sdk/src/worker-play-entry.ts +11 -55
  12. package/dist/bundling-sources/shared_libs/play-runtime/adaptive-tool-dispatcher.ts +355 -0
  13. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +172 -73
  14. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +1794 -377
  15. package/dist/bundling-sources/shared_libs/play-runtime/ctx-contract.ts +3 -0
  16. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +67 -4
  17. package/dist/bundling-sources/shared_libs/play-runtime/durable-receipt-execution.ts +161 -39
  18. package/dist/bundling-sources/shared_libs/play-runtime/governor/adaptive-admission.ts +218 -0
  19. package/dist/bundling-sources/shared_libs/play-runtime/governor/app-runtime-rate-state-backend.ts +1 -1
  20. package/dist/bundling-sources/shared_libs/play-runtime/governor/governor.ts +115 -25
  21. package/dist/bundling-sources/shared_libs/play-runtime/governor/policy.ts +17 -17
  22. package/dist/bundling-sources/shared_libs/play-runtime/lease-policy.ts +22 -0
  23. package/dist/bundling-sources/shared_libs/play-runtime/ledger-safe-payload.ts +2 -1
  24. package/dist/bundling-sources/shared_libs/play-runtime/live-events.ts +0 -1
  25. package/dist/bundling-sources/shared_libs/play-runtime/map-memory-limits.ts +265 -0
  26. package/dist/bundling-sources/shared_libs/play-runtime/output-size-limits.ts +135 -0
  27. package/dist/bundling-sources/shared_libs/play-runtime/play-input.ts +17 -0
  28. package/dist/bundling-sources/shared_libs/play-runtime/play-latency-trace.ts +0 -3
  29. package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +10 -1
  30. package/dist/bundling-sources/shared_libs/play-runtime/providers.ts +9 -15
  31. package/dist/bundling-sources/shared_libs/play-runtime/receipt-completion-sink.ts +262 -0
  32. package/dist/bundling-sources/shared_libs/play-runtime/receipt-heartbeat-supervisor.ts +64 -0
  33. package/dist/bundling-sources/shared_libs/play-runtime/receipt-sql.ts +76 -8
  34. package/dist/bundling-sources/shared_libs/play-runtime/receipt-state-sink.ts +59 -0
  35. package/dist/bundling-sources/shared_libs/play-runtime/receipt-status.ts +3 -2
  36. package/dist/bundling-sources/shared_libs/play-runtime/resource-governor.ts +269 -0
  37. package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +2 -3
  38. package/dist/bundling-sources/shared_libs/play-runtime/run-terminal-source.ts +0 -1
  39. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-lifecycle.ts +433 -0
  40. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-payload-transport.ts +227 -0
  41. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona.ts +882 -0
  42. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/local-process.ts +573 -0
  43. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/bundle.ts +264 -0
  44. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/index.ts +33 -0
  45. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/runner-events.ts +35 -0
  46. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/types.ts +53 -0
  47. package/dist/bundling-sources/shared_libs/play-runtime/runtime-actions.ts +0 -1
  48. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +459 -103
  49. package/dist/bundling-sources/shared_libs/play-runtime/runtime-constants.ts +12 -0
  50. package/dist/bundling-sources/shared_libs/play-runtime/runtime-infra-mode.ts +23 -0
  51. package/dist/bundling-sources/shared_libs/play-runtime/runtime-sheet-attempt-state-machine.ts +23 -2
  52. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +16 -24
  53. package/dist/bundling-sources/shared_libs/play-runtime/serial-task-queue.ts +26 -0
  54. package/dist/bundling-sources/shared_libs/play-runtime/submit-limits.ts +1 -1
  55. package/dist/bundling-sources/shared_libs/play-runtime/vercel-protection.ts +81 -0
  56. package/dist/bundling-sources/shared_libs/play-runtime/work-receipt-state-machine.ts +54 -9
  57. package/dist/bundling-sources/shared_libs/play-runtime/work-receipts.ts +17 -3
  58. package/dist/bundling-sources/shared_libs/play-runtime/worker-api-types.ts +0 -20
  59. package/dist/bundling-sources/shared_libs/plays/dataset.ts +105 -4
  60. package/dist/bundling-sources/shared_libs/plays/row-identity.ts +4 -11
  61. package/dist/cli/index.js +441 -101
  62. package/dist/cli/index.mjs +441 -101
  63. package/dist/index.d.mts +1 -1
  64. package/dist/index.d.ts +1 -1
  65. package/dist/index.js +8 -8
  66. package/dist/index.mjs +8 -8
  67. package/dist/plays/bundle-play-file.mjs +15 -20
  68. package/package.json +1 -1
  69. package/dist/bundling-sources/shared_libs/play-runtime/hatchet-cold-execution-diagnosis.ts +0 -321
  70. package/dist/bundling-sources/shared_libs/play-runtime/hatchet-cold-execution-target.ts +0 -158
  71. package/dist/bundling-sources/shared_libs/temporal/constants.ts +0 -39
  72. package/dist/bundling-sources/shared_libs/temporal/preview-config.ts +0 -150
@@ -1,39 +0,0 @@
1
- /**
2
- * Shared Temporal execution constants.
3
- *
4
- * Keep values that both the API/auth surface and the worker need here so the
5
- * API never imports from worker-only modules.
6
- */
7
-
8
- /**
9
- * Local Temporal dev defaults.
10
- *
11
- * These match the host ports exposed by docker-compose.yml and the env files
12
- * used by the local dev flows (`.env.local`, `.env.worktree`).
13
- */
14
- export const LOCAL_TEMPORAL_FRONTEND_PORT = 17233;
15
- export const LOCAL_TEMPORAL_UI_PORT = 18233;
16
- export const LOCAL_TEMPORAL_NAMESPACE = 'default';
17
- export const LOCAL_TEMPORAL_ADDRESS = `127.0.0.1:${LOCAL_TEMPORAL_FRONTEND_PORT}`;
18
- export const LOCAL_TEMPORAL_UI_URL = `http://127.0.0.1:${LOCAL_TEMPORAL_UI_PORT}`;
19
-
20
- /** Maximum active user-code runtime for a standard play, in seconds. */
21
- export const STANDARD_PLAY_RUNTIME_LIMIT_SECONDS = 20 * 60; // 20 minutes
22
- export const STANDARD_PLAY_RUNTIME_LIMIT_LABEL = '20 minutes';
23
-
24
- /**
25
- * Activity timeout includes setup, cleanup, and billing headroom after the 20 minute
26
- * user-code runtime cap. Keep this higher than STANDARD_PLAY_RUNTIME_LIMIT_SECONDS.
27
- */
28
- export const PLAY_ACTIVITY_TIMEOUT_SECONDS = 30 * 60; // 30 minutes
29
-
30
- /** Heartbeat cadence for the long-running play execution activity. */
31
- export const PLAY_EXECUTE_ACTIVITY_HEARTBEAT_INTERVAL_SECONDS = 15;
32
-
33
- /**
34
- * TTL for workflow executor tokens, in seconds.
35
- * Matches the activity timeout so tokens expire when the activity would
36
- * time out anyway.
37
- */
38
- export const WORKFLOW_EXECUTOR_TOKEN_TTL_SECONDS =
39
- PLAY_ACTIVITY_TIMEOUT_SECONDS;
@@ -1,150 +0,0 @@
1
- import { existsSync } from 'node:fs';
2
- import * as path from 'node:path';
3
- import * as dotenv from 'dotenv';
4
- import { LOCAL_TEMPORAL_ADDRESS, LOCAL_TEMPORAL_NAMESPACE } from './constants';
5
-
6
- export const PLAY_TASK_QUEUE = 'deepline-plays';
7
- // Internal process flag set by `bun run dev:v2 --preview`. Do not put this in
8
- // .env.local; the dev command owns the mode selection so local/preview runs are
9
- // obvious at the call site.
10
- export const DEEPLINE_V2_INFRA_MODE_ENV = 'DEEPLINE_V2_INFRA_MODE';
11
- export const PREVIEW_PLAYS_ENV_FILE = '.env.plays.preview';
12
-
13
- type TemporalTlsConfig = {
14
- clientCertPair: {
15
- crt: Uint8Array;
16
- key: Uint8Array;
17
- };
18
- };
19
-
20
- export type DeeplineTemporalConfig = {
21
- address: string;
22
- namespace: string;
23
- taskQueue: string;
24
- tls?: TemporalTlsConfig;
25
- deployment: 'local' | 'preview';
26
- };
27
-
28
- let loadedPreviewEnv = false;
29
-
30
- function decodePemEnv(value: string): Uint8Array {
31
- return Buffer.from(value.replace(/\\n/g, '\n'), 'utf-8');
32
- }
33
-
34
- export function isPreviewPlaysDeployment(): boolean {
35
- const mode = process.env[DEEPLINE_V2_INFRA_MODE_ENV]?.trim().toLowerCase();
36
- return mode === 'external' || mode === 'preview';
37
- }
38
-
39
- export function isCloudflarePlaysDeployment(): boolean {
40
- const mode = process.env[DEEPLINE_V2_INFRA_MODE_ENV]?.trim().toLowerCase();
41
- return mode === 'cloudflare';
42
- }
43
-
44
- /**
45
- * True when the play runtime callback baseUrl must be a public URL — i.e. when
46
- * the plays runner runs outside the local app process and can't reach
47
- * 127.0.0.1. Both `external` (Daytona) and `cloudflare` (Workers/DOs) need
48
- * this; only fully-local mode can keep baseUrl on localhost.
49
- */
50
- export function requiresPublicCallbackBaseUrl(): boolean {
51
- return isPreviewPlaysDeployment() || isCloudflarePlaysDeployment();
52
- }
53
-
54
- export function loadPreviewPlaysEnv(cwd = process.cwd()): void {
55
- if (loadedPreviewEnv || !isPreviewPlaysDeployment()) {
56
- return;
57
- }
58
-
59
- const envPath = path.join(cwd, PREVIEW_PLAYS_ENV_FILE);
60
- if (existsSync(envPath)) {
61
- dotenv.config({ path: envPath, override: true });
62
- }
63
-
64
- loadedPreviewEnv = true;
65
- }
66
-
67
- function temporalTlsFromEnv(): TemporalTlsConfig | undefined {
68
- const cert =
69
- process.env.TEMPORAL_TLS_CERT_DATA ?? process.env.FAS_TEMPORAL_CERT_DATA;
70
- const key =
71
- process.env.TEMPORAL_TLS_KEY_DATA ?? process.env.FAS_TEMPORAL_KEY_DATA;
72
-
73
- if (!cert && !key) {
74
- return undefined;
75
- }
76
- if (!cert || !key) {
77
- throw new Error(
78
- 'Temporal Cloud mTLS requires both TEMPORAL_TLS_CERT_DATA and TEMPORAL_TLS_KEY_DATA.',
79
- );
80
- }
81
-
82
- return {
83
- clientCertPair: {
84
- crt: decodePemEnv(cert),
85
- key: decodePemEnv(key),
86
- },
87
- };
88
- }
89
-
90
- function temporalAddressFromEnv(): string | undefined {
91
- return (
92
- process.env.TEMPORAL_ADDRESS?.trim() ||
93
- process.env.FAS_TEMPORAL_ADDRESS?.trim() ||
94
- undefined
95
- );
96
- }
97
-
98
- function temporalNamespaceFromEnv(address: string): string | undefined {
99
- const previewConfigured = process.env.FAS_TEMPORAL_NAMESPACE?.trim();
100
- if (previewConfigured) {
101
- return previewConfigured;
102
- }
103
-
104
- const host = address.split(':')[0] ?? '';
105
- const temporalCloudNamespace = /^([^.]+\.[^.]+)\.tmprl\.cloud$/i.exec(host);
106
- if (temporalCloudNamespace?.[1]) {
107
- return temporalCloudNamespace[1];
108
- }
109
-
110
- const configured = process.env.TEMPORAL_NAMESPACE?.trim();
111
- return configured || undefined;
112
- }
113
-
114
- export function getDeeplineTemporalConfig(options?: {
115
- loadPreviewEnv?: boolean;
116
- }): DeeplineTemporalConfig {
117
- if (options?.loadPreviewEnv !== false) {
118
- loadPreviewPlaysEnv();
119
- }
120
-
121
- if (isPreviewPlaysDeployment()) {
122
- const address = temporalAddressFromEnv();
123
- const namespace = address ? temporalNamespaceFromEnv(address) : undefined;
124
- if (!address) {
125
- throw new Error(
126
- 'dev:v2 preview mode requires TEMPORAL_ADDRESS or FAS_TEMPORAL_ADDRESS.',
127
- );
128
- }
129
- if (!namespace) {
130
- throw new Error(
131
- 'dev:v2 preview mode requires TEMPORAL_NAMESPACE or FAS_TEMPORAL_NAMESPACE.',
132
- );
133
- }
134
- return {
135
- address,
136
- namespace,
137
- taskQueue: process.env.TEMPORAL_TASK_QUEUE?.trim() || PLAY_TASK_QUEUE,
138
- tls: temporalTlsFromEnv(),
139
- deployment: 'preview',
140
- };
141
- }
142
-
143
- return {
144
- address: process.env.TEMPORAL_ADDRESS ?? LOCAL_TEMPORAL_ADDRESS,
145
- namespace: process.env.TEMPORAL_NAMESPACE ?? LOCAL_TEMPORAL_NAMESPACE,
146
- taskQueue: process.env.TEMPORAL_TASK_QUEUE?.trim() || PLAY_TASK_QUEUE,
147
- tls: temporalTlsFromEnv(),
148
- deployment: 'local',
149
- };
150
- }