deepline 0.1.153 → 0.1.155

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 (48) hide show
  1. package/dist/bundling-sources/apps/play-runner-workers/src/coordinator-entry.ts +15 -0
  2. package/dist/bundling-sources/apps/play-runner-workers/src/entry.ts +1180 -825
  3. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/batching.ts +34 -18
  4. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/harness-receipt-store.ts +41 -0
  5. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/receipts.ts +143 -8
  6. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/tool-receipts.ts +104 -0
  7. package/dist/bundling-sources/sdk/src/index.ts +0 -1
  8. package/dist/bundling-sources/sdk/src/play.ts +3 -48
  9. package/dist/bundling-sources/sdk/src/plays/harness-stub.ts +27 -2
  10. package/dist/bundling-sources/sdk/src/release.ts +6 -4
  11. package/dist/bundling-sources/sdk/src/worker-play-entry.ts +0 -10
  12. package/dist/bundling-sources/shared_libs/play-data-plane/index.ts +0 -1
  13. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +87 -0
  14. package/dist/bundling-sources/shared_libs/play-runtime/batch-runtime.ts +0 -59
  15. package/dist/bundling-sources/shared_libs/play-runtime/cell-staleness.ts +0 -253
  16. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +805 -1570
  17. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +47 -74
  18. package/dist/bundling-sources/shared_libs/play-runtime/default-batch-strategies.ts +36 -14
  19. package/dist/bundling-sources/shared_libs/play-runtime/durable-call-cache.ts +145 -0
  20. package/dist/bundling-sources/shared_libs/play-runtime/durable-receipt-execution.ts +284 -0
  21. package/dist/bundling-sources/shared_libs/play-runtime/postgres-json.ts +12 -5
  22. package/dist/bundling-sources/shared_libs/play-runtime/run-lifecycle-policy.ts +78 -0
  23. package/dist/bundling-sources/shared_libs/play-runtime/run-snapshot-stream.ts +10 -45
  24. package/dist/bundling-sources/shared_libs/play-runtime/runtime-actions.ts +1 -0
  25. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +923 -535
  26. package/dist/bundling-sources/shared_libs/play-runtime/runtime-pg-driver-neon-serverless.ts +45 -76
  27. package/dist/bundling-sources/shared_libs/play-runtime/runtime-pg-driver.ts +12 -1
  28. package/dist/bundling-sources/shared_libs/play-runtime/step-program-dataset-builder.ts +1 -14
  29. package/dist/bundling-sources/shared_libs/play-runtime/tool-execution-outcome.ts +159 -0
  30. package/dist/bundling-sources/shared_libs/play-runtime/tool-result-types.ts +4 -1
  31. package/dist/bundling-sources/shared_libs/play-runtime/work-receipts.ts +32 -0
  32. package/dist/bundling-sources/shared_libs/plays/definition.ts +4 -2
  33. package/dist/bundling-sources/shared_libs/plays/runtime-validation.ts +3 -14
  34. package/dist/bundling-sources/shared_libs/plays/static-pipeline.ts +1 -43
  35. package/dist/cli/index.js +1305 -401
  36. package/dist/cli/index.mjs +1273 -363
  37. package/dist/{compiler-manifest-BjoRENv9.d.ts → compiler-manifest-DW1flrHk.d.mts} +0 -9
  38. package/dist/{compiler-manifest-BjoRENv9.d.mts → compiler-manifest-DW1flrHk.d.ts} +0 -9
  39. package/dist/index.d.mts +9 -38
  40. package/dist/index.d.ts +9 -38
  41. package/dist/index.js +26 -13
  42. package/dist/index.mjs +26 -13
  43. package/dist/plays/bundle-play-file.d.mts +2 -2
  44. package/dist/plays/bundle-play-file.d.ts +2 -2
  45. package/package.json +1 -1
  46. package/dist/bundling-sources/shared_libs/play-data-plane/cell-policy.ts +0 -76
  47. package/dist/bundling-sources/shared_libs/play-runtime/progress-emitter.ts +0 -197
  48. package/dist/bundling-sources/shared_libs/play-runtime/waterfall-replay.ts +0 -79
@@ -1,9 +1,16 @@
1
1
  const POSTGRES_UNSUPPORTED_NUL_RE = /\u0000/g;
2
2
 
3
+ function postgresJsonReplacer(_key: string, value: unknown): unknown {
4
+ return typeof value === 'string'
5
+ ? value.replace(POSTGRES_UNSUPPORTED_NUL_RE, '')
6
+ : value;
7
+ }
8
+
9
+ export function sanitizePostgresJsonValue<T>(value: T): T {
10
+ const serialized = stringifyPostgresJson(value);
11
+ return serialized === undefined ? value : (JSON.parse(serialized) as T);
12
+ }
13
+
3
14
  export function stringifyPostgresJson(value: unknown): string | undefined {
4
- return JSON.stringify(value, (_key, nestedValue) =>
5
- typeof nestedValue === 'string'
6
- ? nestedValue.replace(POSTGRES_UNSUPPORTED_NUL_RE, '')
7
- : nestedValue,
8
- );
15
+ return JSON.stringify(value, postgresJsonReplacer);
9
16
  }
@@ -0,0 +1,78 @@
1
+ export type PlayRunLifecycleStatus =
2
+ | 'queued'
3
+ | 'running'
4
+ | 'completed'
5
+ | 'failed'
6
+ | 'cancelled'
7
+ | 'terminated'
8
+ | 'timed_out'
9
+ | 'unknown';
10
+
11
+ const TERMINAL_PLAY_RUN_STATUSES = new Set<PlayRunLifecycleStatus>([
12
+ 'completed',
13
+ 'failed',
14
+ 'cancelled',
15
+ 'terminated',
16
+ 'timed_out',
17
+ ]);
18
+
19
+ const RECOVERABLE_DATASET_ROW_STATUSES = new Set<PlayRunLifecycleStatus>([
20
+ 'failed',
21
+ 'cancelled',
22
+ 'terminated',
23
+ 'timed_out',
24
+ ]);
25
+
26
+ export function normalizePlayRunLifecycleStatus(
27
+ value: unknown,
28
+ ): PlayRunLifecycleStatus {
29
+ const normalized = String(value ?? '')
30
+ .trim()
31
+ .toLowerCase();
32
+ switch (normalized) {
33
+ case 'queued':
34
+ case 'pending':
35
+ return 'running';
36
+ case 'running':
37
+ case 'started':
38
+ case 'waiting':
39
+ return 'running';
40
+ case 'completed':
41
+ case 'complete':
42
+ case 'succeeded':
43
+ return 'completed';
44
+ case 'failed':
45
+ case 'error':
46
+ return 'failed';
47
+ case 'cancelled':
48
+ case 'canceled':
49
+ return 'cancelled';
50
+ case 'terminated':
51
+ return 'terminated';
52
+ case 'timed_out':
53
+ case 'timeout':
54
+ return 'timed_out';
55
+ default:
56
+ return 'unknown';
57
+ }
58
+ }
59
+
60
+ export function isTerminalPlayRunLifecycleStatus(status: unknown): boolean {
61
+ return TERMINAL_PLAY_RUN_STATUSES.has(normalizePlayRunLifecycleStatus(status));
62
+ }
63
+
64
+ export function isActivePlayRunLifecycleStatus(status: unknown): boolean {
65
+ return normalizePlayRunLifecycleStatus(status) === 'running';
66
+ }
67
+
68
+ export function isRecoverableDatasetRowStatus(status: unknown): boolean {
69
+ return RECOVERABLE_DATASET_ROW_STATUSES.has(
70
+ normalizePlayRunLifecycleStatus(status),
71
+ );
72
+ }
73
+
74
+ export function datasetSummaryRowModeForRunStatus(
75
+ status: unknown,
76
+ ): 'output' | 'all' {
77
+ return isRecoverableDatasetRowStatus(status) ? 'all' : 'output';
78
+ }
@@ -5,6 +5,12 @@ import {
5
5
  type PlayRunLedgerSnapshot,
6
6
  type PlayRunLedgerStepSnapshot,
7
7
  } from './run-ledger';
8
+ import {
9
+ isActivePlayRunLifecycleStatus,
10
+ isTerminalPlayRunLifecycleStatus,
11
+ normalizePlayRunLifecycleStatus,
12
+ type PlayRunLifecycleStatus,
13
+ } from './run-lifecycle-policy';
8
14
 
9
15
  /**
10
16
  * Run Snapshot Stream.
@@ -17,15 +23,7 @@ import {
17
23
  * event streams from the same Convex Run Snapshot. See ADR-0008.
18
24
  */
19
25
 
20
- export type PlayRunLiveStatus =
21
- | 'queued'
22
- | 'running'
23
- | 'completed'
24
- | 'failed'
25
- | 'cancelled'
26
- | 'terminated'
27
- | 'timed_out'
28
- | 'unknown';
26
+ export type PlayRunLiveStatus = PlayRunLifecycleStatus;
29
27
 
30
28
  export type PlayRunStreamNodeProgress = {
31
29
  completed?: number;
@@ -81,50 +79,17 @@ export type PlayRunLiveSnapshot = {
81
79
  };
82
80
 
83
81
  export function normalizePlayRunLiveStatus(value: unknown): PlayRunLiveStatus {
84
- const normalized = String(value ?? '')
85
- .trim()
86
- .toLowerCase();
87
- switch (normalized) {
88
- case 'queued':
89
- case 'pending':
90
- return 'running';
91
- case 'running':
92
- case 'started':
93
- return 'running';
94
- case 'completed':
95
- case 'complete':
96
- case 'succeeded':
97
- return 'completed';
98
- case 'failed':
99
- case 'error':
100
- return 'failed';
101
- case 'cancelled':
102
- case 'canceled':
103
- return 'cancelled';
104
- case 'terminated':
105
- return 'terminated';
106
- case 'timed_out':
107
- case 'timeout':
108
- return 'timed_out';
109
- default:
110
- return 'unknown';
111
- }
82
+ return normalizePlayRunLifecycleStatus(value);
112
83
  }
113
84
 
114
85
  export function isTerminalPlayRunLiveStatus(
115
86
  status: PlayRunLiveStatus,
116
87
  ): boolean {
117
- return (
118
- status === 'completed' ||
119
- status === 'failed' ||
120
- status === 'cancelled' ||
121
- status === 'terminated' ||
122
- status === 'timed_out'
123
- );
88
+ return isTerminalPlayRunLifecycleStatus(status);
124
89
  }
125
90
 
126
91
  export function isActivePlayRunStatus(status: unknown): boolean {
127
- return normalizePlayRunLiveStatus(status) === 'running';
92
+ return isActivePlayRunLifecycleStatus(status);
128
93
  }
129
94
 
130
95
  /**
@@ -100,6 +100,7 @@ export type RuntimeReceiptAction =
100
100
  runId: string;
101
101
  key: string;
102
102
  reclaimRunning?: boolean;
103
+ forceRefresh?: boolean;
103
104
  }
104
105
  | {
105
106
  action: 'complete_runtime_step_receipt';