deepline 0.1.12 → 0.1.19

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 (80) hide show
  1. package/README.md +14 -6
  2. package/dist/cli/index.js +1298 -711
  3. package/dist/cli/index.mjs +1294 -707
  4. package/dist/index.d.mts +199 -23
  5. package/dist/index.d.ts +199 -23
  6. package/dist/index.js +219 -13
  7. package/dist/index.mjs +219 -13
  8. package/dist/repo/apps/play-runner-workers/src/coordinator-entry.ts +68 -12
  9. package/dist/repo/apps/play-runner-workers/src/entry.ts +241 -51
  10. package/dist/repo/sdk/src/client.ts +237 -0
  11. package/dist/repo/sdk/src/config.ts +125 -8
  12. package/dist/repo/sdk/src/http.ts +10 -2
  13. package/dist/repo/sdk/src/play.ts +19 -36
  14. package/dist/repo/sdk/src/plays/bundle-play-file.ts +22 -8
  15. package/dist/repo/sdk/src/plays/local-file-discovery.ts +207 -160
  16. package/dist/repo/sdk/src/types.ts +25 -0
  17. package/dist/repo/sdk/src/version.ts +2 -2
  18. package/dist/repo/shared_libs/play-runtime/tool-result.ts +237 -145
  19. package/dist/repo/shared_libs/plays/bundling/index.ts +206 -229
  20. package/dist/repo/shared_libs/plays/dataset.ts +28 -0
  21. package/package.json +5 -4
  22. package/dist/cli/index.js.map +0 -1
  23. package/dist/cli/index.mjs.map +0 -1
  24. package/dist/index.js.map +0 -1
  25. package/dist/index.mjs.map +0 -1
  26. package/dist/repo/apps/play-runner-workers/src/runtime/README.md +0 -21
  27. package/dist/repo/apps/play-runner-workers/src/runtime/batching.ts +0 -177
  28. package/dist/repo/apps/play-runner-workers/src/runtime/execution-plan.ts +0 -52
  29. package/dist/repo/apps/play-runner-workers/src/runtime/tool-batch.ts +0 -100
  30. package/dist/repo/sdk/src/cli/commands/auth.ts +0 -500
  31. package/dist/repo/sdk/src/cli/commands/billing.ts +0 -188
  32. package/dist/repo/sdk/src/cli/commands/csv.ts +0 -123
  33. package/dist/repo/sdk/src/cli/commands/db.ts +0 -119
  34. package/dist/repo/sdk/src/cli/commands/feedback.ts +0 -40
  35. package/dist/repo/sdk/src/cli/commands/org.ts +0 -117
  36. package/dist/repo/sdk/src/cli/commands/play.ts +0 -3441
  37. package/dist/repo/sdk/src/cli/commands/tools.ts +0 -687
  38. package/dist/repo/sdk/src/cli/dataset-stats.ts +0 -415
  39. package/dist/repo/sdk/src/cli/index.ts +0 -148
  40. package/dist/repo/sdk/src/cli/progress.ts +0 -149
  41. package/dist/repo/sdk/src/cli/skills-sync.ts +0 -141
  42. package/dist/repo/sdk/src/cli/trace.ts +0 -61
  43. package/dist/repo/sdk/src/cli/utils.ts +0 -145
  44. package/dist/repo/sdk/src/compat.ts +0 -77
  45. package/dist/repo/shared_libs/observability/node-tracing.ts +0 -129
  46. package/dist/repo/shared_libs/observability/tracing.ts +0 -98
  47. package/dist/repo/shared_libs/play-runtime/context.ts +0 -4242
  48. package/dist/repo/shared_libs/play-runtime/ctx-contract.ts +0 -250
  49. package/dist/repo/shared_libs/play-runtime/ctx-types.ts +0 -725
  50. package/dist/repo/shared_libs/play-runtime/dataset-id.ts +0 -10
  51. package/dist/repo/shared_libs/play-runtime/db-session-crypto.ts +0 -304
  52. package/dist/repo/shared_libs/play-runtime/db-session.ts +0 -462
  53. package/dist/repo/shared_libs/play-runtime/live-events.ts +0 -214
  54. package/dist/repo/shared_libs/play-runtime/live-state-contract.ts +0 -50
  55. package/dist/repo/shared_libs/play-runtime/map-execution-frame.ts +0 -114
  56. package/dist/repo/shared_libs/play-runtime/map-row-identity.ts +0 -158
  57. package/dist/repo/shared_libs/play-runtime/progress-emitter.ts +0 -172
  58. package/dist/repo/shared_libs/play-runtime/protocol.ts +0 -121
  59. package/dist/repo/shared_libs/play-runtime/public-play-contract.ts +0 -42
  60. package/dist/repo/shared_libs/play-runtime/result-normalization.ts +0 -33
  61. package/dist/repo/shared_libs/play-runtime/runtime-api.ts +0 -1873
  62. package/dist/repo/shared_libs/play-runtime/runtime-constraints.ts +0 -2
  63. package/dist/repo/shared_libs/play-runtime/runtime-pg-driver-neon-serverless.ts +0 -201
  64. package/dist/repo/shared_libs/play-runtime/runtime-pg-driver-pg.ts +0 -48
  65. package/dist/repo/shared_libs/play-runtime/runtime-pg-driver.ts +0 -84
  66. package/dist/repo/shared_libs/play-runtime/static-pipeline-types.ts +0 -147
  67. package/dist/repo/shared_libs/play-runtime/suspension.ts +0 -68
  68. package/dist/repo/shared_libs/play-runtime/tracing.ts +0 -31
  69. package/dist/repo/shared_libs/play-runtime/waterfall-replay.ts +0 -75
  70. package/dist/repo/shared_libs/play-runtime/worker-api-types.ts +0 -140
  71. package/dist/repo/shared_libs/plays/artifact-transport.ts +0 -14
  72. package/dist/repo/shared_libs/plays/artifact-types.ts +0 -49
  73. package/dist/repo/shared_libs/plays/compiler-manifest.ts +0 -186
  74. package/dist/repo/shared_libs/plays/definition.ts +0 -264
  75. package/dist/repo/shared_libs/plays/file-refs.ts +0 -11
  76. package/dist/repo/shared_libs/plays/rate-limit-scheduler.ts +0 -206
  77. package/dist/repo/shared_libs/plays/resolve-static-pipeline.ts +0 -164
  78. package/dist/repo/shared_libs/plays/runtime-validation.ts +0 -395
  79. package/dist/repo/shared_libs/temporal/constants.ts +0 -39
  80. package/dist/repo/shared_libs/temporal/preview-config.ts +0 -153
@@ -1,462 +0,0 @@
1
- import type {
2
- EncryptedPostgresUrl,
3
- PostgresUrlEncryptionRequest,
4
- } from './db-session-crypto';
5
-
6
- export const DB_SESSION_DEFAULT_TTL_SECONDS = 10 * 60;
7
- export const DB_SESSION_MAX_TTL_SECONDS = 30 * 60;
8
-
9
- export const DB_SESSION_OPERATIONS = [
10
- 'rows.read',
11
- 'rows.append',
12
- 'rows.upsert',
13
- 'rows.replace',
14
- ] as const;
15
- export type DbSessionOperation = (typeof DB_SESSION_OPERATIONS)[number];
16
-
17
- export const DB_LOGICAL_TABLES = [
18
- 'sheet_rows',
19
- 'dataset_rows',
20
- 'play_output',
21
- ] as const;
22
- export type DbLogicalTable = (typeof DB_LOGICAL_TABLES)[number];
23
-
24
- export type DbSessionTarget = {
25
- orgId: string;
26
- tableNamespace: string;
27
- logicalTable: DbLogicalTable;
28
- };
29
-
30
- export type DbSessionLimits = {
31
- maxRows?: number;
32
- maxBytes?: number;
33
- maxRequests?: number;
34
- };
35
-
36
- export type CreateDbSessionRequest = {
37
- playName: string;
38
- target: Omit<DbSessionTarget, 'orgId'>;
39
- operations: DbSessionOperation[];
40
- limits?: DbSessionLimits;
41
- sheetContract?: unknown | null;
42
- ttlSeconds?: number;
43
- userEmail?: string | null;
44
- postgresUrlEncryption?: PostgresUrlEncryptionRequest | null;
45
- };
46
-
47
- export type CreateDbSessionResponse = {
48
- sessionId: string;
49
- postgresUrl?: string;
50
- encryptedPostgresUrl?: EncryptedPostgresUrl;
51
- postgres?: {
52
- schema: string;
53
- sheetTable: string;
54
- eventTable: string;
55
- summaryTable: string;
56
- columnSummaryTable: string;
57
- };
58
- expiresAt: string;
59
- playName: string;
60
- target: DbSessionTarget;
61
- operations: DbSessionOperation[];
62
- limits: DbSessionLimits;
63
- };
64
-
65
- export type PreloadedRuntimeDbSession = {
66
- tableNamespace: string;
67
- logicalTable: DbLogicalTable;
68
- operations: DbSessionOperation[];
69
- limits?: DbSessionLimits;
70
- session: CreateDbSessionResponse;
71
- };
72
-
73
- export type RowsWriteDisposition = 'completed' | 'accepted';
74
-
75
- export type RowsWriteResponse = {
76
- disposition: RowsWriteDisposition;
77
- writtenRows?: number;
78
- jobId?: string;
79
- };
80
-
81
- type SafeParseSuccess<T> = { success: true; data: T };
82
- type SafeParseFailure = { success: false; error: Error };
83
- type SafeParseResult<T> = SafeParseSuccess<T> | SafeParseFailure;
84
-
85
- type RuntimeSchema<T> = {
86
- parse(value: unknown): T;
87
- safeParse(value: unknown): SafeParseResult<T>;
88
- };
89
-
90
- function createSchema<T>(parse: (value: unknown) => T): RuntimeSchema<T> {
91
- return {
92
- parse,
93
- safeParse(value) {
94
- try {
95
- return { success: true, data: parse(value) };
96
- } catch (error) {
97
- return {
98
- success: false,
99
- error: error instanceof Error ? error : new Error(String(error)),
100
- };
101
- }
102
- },
103
- };
104
- }
105
-
106
- function isRecord(value: unknown): value is Record<string, unknown> {
107
- return value !== null && typeof value === 'object' && !Array.isArray(value);
108
- }
109
-
110
- function parseString(value: unknown, path: string): string {
111
- if (typeof value !== 'string' || value.length === 0) {
112
- throw new Error(`${path} must be a non-empty string.`);
113
- }
114
- return value;
115
- }
116
-
117
- function parseOptionalString(value: unknown, path: string): string | undefined {
118
- if (value === undefined) return undefined;
119
- return parseString(value, path);
120
- }
121
-
122
- function parseLiteral<T extends string>(
123
- value: unknown,
124
- expected: T,
125
- path: string,
126
- ): T {
127
- if (value !== expected) {
128
- throw new Error(`${path} must be ${expected}.`);
129
- }
130
- return expected;
131
- }
132
-
133
- function parseNullableString(
134
- value: unknown,
135
- path: string,
136
- ): string | null | undefined {
137
- if (value === undefined) return undefined;
138
- if (value === null) return null;
139
- return parseString(value, path);
140
- }
141
-
142
- function parsePositiveInteger(value: unknown, path: string): number {
143
- if (
144
- typeof value !== 'number' ||
145
- !Number.isInteger(value) ||
146
- value <= 0
147
- ) {
148
- throw new Error(`${path} must be a positive integer.`);
149
- }
150
- return value;
151
- }
152
-
153
- function parseNonnegativeInteger(
154
- value: unknown,
155
- path: string,
156
- ): number {
157
- if (
158
- typeof value !== 'number' ||
159
- !Number.isInteger(value) ||
160
- value < 0
161
- ) {
162
- throw new Error(`${path} must be a nonnegative integer.`);
163
- }
164
- return value;
165
- }
166
-
167
- function parseEnum<T extends readonly string[]>(
168
- value: unknown,
169
- allowed: T,
170
- path: string,
171
- ): T[number] {
172
- if (
173
- typeof value === 'string' &&
174
- (allowed as readonly string[]).includes(value)
175
- ) {
176
- return value as T[number];
177
- }
178
- throw new Error(`${path} must be one of: ${allowed.join(', ')}.`);
179
- }
180
-
181
- function parseArray<T>(
182
- value: unknown,
183
- path: string,
184
- parseItem: (item: unknown, itemPath: string) => T,
185
- ): T[] {
186
- if (!Array.isArray(value) || value.length === 0) {
187
- throw new Error(`${path} must be a non-empty array.`);
188
- }
189
- return value.map((item, index) => parseItem(item, `${path}[${index}]`));
190
- }
191
-
192
- function parseLimits(value: unknown, path: string): DbSessionLimits {
193
- if (!isRecord(value)) {
194
- throw new Error(`${path} must be an object.`);
195
- }
196
- return {
197
- ...(value.maxRows !== undefined
198
- ? { maxRows: parsePositiveInteger(value.maxRows, `${path}.maxRows`) }
199
- : {}),
200
- ...(value.maxBytes !== undefined
201
- ? { maxBytes: parsePositiveInteger(value.maxBytes, `${path}.maxBytes`) }
202
- : {}),
203
- ...(value.maxRequests !== undefined
204
- ? {
205
- maxRequests: parsePositiveInteger(
206
- value.maxRequests,
207
- `${path}.maxRequests`,
208
- ),
209
- }
210
- : {}),
211
- };
212
- }
213
-
214
- function parseOperation(value: unknown, path: string): DbSessionOperation {
215
- return parseEnum(value, DB_SESSION_OPERATIONS, path);
216
- }
217
-
218
- function parseLogicalTable(value: unknown, path: string): DbLogicalTable {
219
- return parseEnum(value, DB_LOGICAL_TABLES, path);
220
- }
221
-
222
- function parseTarget(value: unknown, path: string): DbSessionTarget {
223
- if (!isRecord(value)) {
224
- throw new Error(`${path} must be an object.`);
225
- }
226
- return {
227
- orgId: parseString(value.orgId, `${path}.orgId`),
228
- tableNamespace: parseString(value.tableNamespace, `${path}.tableNamespace`),
229
- logicalTable: parseLogicalTable(value.logicalTable, `${path}.logicalTable`),
230
- };
231
- }
232
-
233
- function parseRequestTarget(
234
- value: unknown,
235
- path: string,
236
- ): Omit<DbSessionTarget, 'orgId'> {
237
- if (!isRecord(value)) {
238
- throw new Error(`${path} must be an object.`);
239
- }
240
- return {
241
- tableNamespace: parseString(value.tableNamespace, `${path}.tableNamespace`),
242
- logicalTable: parseLogicalTable(value.logicalTable, `${path}.logicalTable`),
243
- };
244
- }
245
-
246
- function parsePostgresMetadata(
247
- value: unknown,
248
- path: string,
249
- ): CreateDbSessionResponse['postgres'] {
250
- if (value === undefined) return undefined;
251
- if (!isRecord(value)) {
252
- throw new Error(`${path} must be an object.`);
253
- }
254
- return {
255
- schema: parseString(value.schema, `${path}.schema`),
256
- sheetTable: parseString(value.sheetTable, `${path}.sheetTable`),
257
- eventTable: parseString(value.eventTable, `${path}.eventTable`),
258
- summaryTable: parseString(value.summaryTable, `${path}.summaryTable`),
259
- columnSummaryTable: parseString(
260
- value.columnSummaryTable,
261
- `${path}.columnSummaryTable`,
262
- ),
263
- };
264
- }
265
-
266
- function parseEncryptedPostgresUrl(
267
- value: unknown,
268
- path: string,
269
- ): EncryptedPostgresUrl {
270
- if (!isRecord(value)) {
271
- throw new Error(`${path} must be an object.`);
272
- }
273
- const alg = parseString(value.alg, `${path}.alg`);
274
- if (alg === 'A256GCM') {
275
- return {
276
- alg,
277
- kid: parseLiteral(
278
- value.kid,
279
- 'deepline-runtime-db-session-url:v1',
280
- `${path}.kid`,
281
- ),
282
- iv: parseString(value.iv, `${path}.iv`),
283
- ciphertext: parseString(value.ciphertext, `${path}.ciphertext`),
284
- tag: parseString(value.tag, `${path}.tag`),
285
- };
286
- }
287
- if (alg === 'RSA-OAEP-256+A256GCM') {
288
- return {
289
- alg,
290
- kid: parseLiteral(
291
- value.kid,
292
- 'deepline-runtime-db-session-url:v2',
293
- `${path}.kid`,
294
- ),
295
- wrappedKey: parseString(value.wrappedKey, `${path}.wrappedKey`),
296
- iv: parseString(value.iv, `${path}.iv`),
297
- ciphertext: parseString(value.ciphertext, `${path}.ciphertext`),
298
- tag: parseString(value.tag, `${path}.tag`),
299
- };
300
- }
301
- throw new Error(`${path}.alg must be a supported encryption algorithm.`);
302
- }
303
-
304
- function parsePostgresUrlEncryptionRequest(
305
- value: unknown,
306
- path: string,
307
- ): PostgresUrlEncryptionRequest {
308
- if (!isRecord(value)) {
309
- throw new Error(`${path} must be an object.`);
310
- }
311
- const alg = parseLiteral(
312
- value.alg,
313
- 'RSA-OAEP-256+A256GCM',
314
- `${path}.alg`,
315
- );
316
- const publicKeyJwkValue = value.publicKeyJwk;
317
- if (!isRecord(publicKeyJwkValue)) {
318
- throw new Error(`${path}.publicKeyJwk must be an object.`);
319
- }
320
- const publicKeyJwk = { ...publicKeyJwkValue } as unknown as JsonWebKey;
321
- if (publicKeyJwk.kty !== 'RSA') {
322
- throw new Error(`${path}.publicKeyJwk.kty must be RSA.`);
323
- }
324
- if (
325
- typeof publicKeyJwk.n !== 'string' ||
326
- typeof publicKeyJwk.e !== 'string'
327
- ) {
328
- throw new Error(`${path}.publicKeyJwk must include RSA n and e values.`);
329
- }
330
- return {
331
- alg,
332
- publicKeyJwk,
333
- };
334
- }
335
-
336
- export const dbSessionOperationSchema = createSchema<DbSessionOperation>(
337
- (value) => parseOperation(value, 'operation'),
338
- );
339
-
340
- export const dbLogicalTableSchema = createSchema<DbLogicalTable>(
341
- (value) => parseLogicalTable(value, 'logicalTable'),
342
- );
343
-
344
- export const dbSessionTargetSchema = createSchema<DbSessionTarget>(
345
- (value) => parseTarget(value, 'target'),
346
- );
347
-
348
- export const dbSessionLimitsSchema = createSchema<DbSessionLimits>(
349
- (value) => parseLimits(value, 'limits'),
350
- );
351
-
352
- export const createDbSessionRequestSchema = createSchema<CreateDbSessionRequest>(
353
- (value) => {
354
- if (!isRecord(value)) {
355
- throw new Error('Create DB session request must be an object.');
356
- }
357
- const ttlSeconds =
358
- value.ttlSeconds === undefined
359
- ? undefined
360
- : parsePositiveInteger(value.ttlSeconds, 'ttlSeconds');
361
- if (
362
- ttlSeconds !== undefined &&
363
- ttlSeconds > DB_SESSION_MAX_TTL_SECONDS
364
- ) {
365
- throw new Error(
366
- `ttlSeconds must be <= ${DB_SESSION_MAX_TTL_SECONDS}.`,
367
- );
368
- }
369
- return {
370
- playName: parseString(value.playName, 'playName'),
371
- target: parseRequestTarget(value.target, 'target'),
372
- operations: parseArray(
373
- value.operations,
374
- 'operations',
375
- parseOperation,
376
- ),
377
- ...(value.limits !== undefined
378
- ? { limits: parseLimits(value.limits, 'limits') }
379
- : {}),
380
- ...(value.sheetContract !== undefined
381
- ? { sheetContract: value.sheetContract }
382
- : {}),
383
- ...(ttlSeconds !== undefined ? { ttlSeconds } : {}),
384
- ...(value.userEmail !== undefined
385
- ? { userEmail: parseNullableString(value.userEmail, 'userEmail') }
386
- : {}),
387
- ...(value.postgresUrlEncryption !== undefined
388
- ? {
389
- postgresUrlEncryption:
390
- value.postgresUrlEncryption === null
391
- ? null
392
- : parsePostgresUrlEncryptionRequest(
393
- value.postgresUrlEncryption,
394
- 'postgresUrlEncryption',
395
- ),
396
- }
397
- : {}),
398
- };
399
- },
400
- );
401
-
402
- export const createDbSessionResponseSchema =
403
- createSchema<CreateDbSessionResponse>((value) => {
404
- if (!isRecord(value)) {
405
- throw new Error('Create DB session response must be an object.');
406
- }
407
- return {
408
- sessionId: parseString(value.sessionId, 'sessionId'),
409
- ...(value.postgresUrl !== undefined
410
- ? { postgresUrl: parseOptionalString(value.postgresUrl, 'postgresUrl') }
411
- : {}),
412
- ...(value.encryptedPostgresUrl !== undefined
413
- ? {
414
- encryptedPostgresUrl: parseEncryptedPostgresUrl(
415
- value.encryptedPostgresUrl,
416
- 'encryptedPostgresUrl',
417
- ),
418
- }
419
- : {}),
420
- ...(value.postgres !== undefined
421
- ? { postgres: parsePostgresMetadata(value.postgres, 'postgres') }
422
- : {}),
423
- expiresAt: parseString(value.expiresAt, 'expiresAt'),
424
- playName: parseString(value.playName, 'playName'),
425
- target: parseTarget(value.target, 'target'),
426
- operations: parseArray(
427
- value.operations,
428
- 'operations',
429
- parseOperation,
430
- ),
431
- limits:
432
- value.limits === undefined
433
- ? {}
434
- : parseLimits(value.limits, 'limits'),
435
- };
436
- });
437
-
438
- export const rowsWriteResponseSchema = createSchema<RowsWriteResponse>(
439
- (value) => {
440
- if (!isRecord(value)) {
441
- throw new Error('Rows write response must be an object.');
442
- }
443
- return {
444
- disposition: parseEnum(
445
- value.disposition,
446
- ['completed', 'accepted'] as const,
447
- 'disposition',
448
- ),
449
- ...(value.writtenRows !== undefined
450
- ? {
451
- writtenRows: parseNonnegativeInteger(
452
- value.writtenRows,
453
- 'writtenRows',
454
- ),
455
- }
456
- : {}),
457
- ...(value.jobId !== undefined
458
- ? { jobId: parseOptionalString(value.jobId, 'jobId') }
459
- : {}),
460
- };
461
- },
462
- );
@@ -1,214 +0,0 @@
1
- export type PlayLiveEventSource =
2
- | 'worker'
3
- | 'temporal'
4
- | 'convex'
5
- | 'play'
6
- | 'system';
7
- export type PlayRunTimelineEventType =
8
- | 'play.run.status'
9
- | 'play.run.snapshot'
10
- | 'play.step.status'
11
- | 'play.step.progress'
12
- | 'play.run.health'
13
- | 'play.run.log'
14
- | 'play.sheet.summary'
15
- | 'play.sheet.delta';
16
-
17
- export type PlayRunTimelineLogEntry = {
18
- kind: 'log';
19
- at: string;
20
- source: PlayLiveEventSource;
21
- message: string;
22
- };
23
-
24
- export type PlayRunTimelineEventEntry = {
25
- kind: 'event';
26
- at: string;
27
- eventType: PlayRunTimelineEventType;
28
- summary: string;
29
- };
30
-
31
- export type PlayRunTimelineEntry =
32
- | PlayRunTimelineLogEntry
33
- | PlayRunTimelineEventEntry;
34
-
35
- export function makePlayRunTimelineLogEntry(input: {
36
- at?: string;
37
- source: PlayLiveEventSource;
38
- message: string;
39
- }): PlayRunTimelineLogEntry {
40
- return {
41
- kind: 'log',
42
- at: input.at ?? new Date().toISOString(),
43
- source: input.source,
44
- message: input.message,
45
- };
46
- }
47
-
48
- export function makePlayRunTimelineEventEntry(input: {
49
- at?: string;
50
- eventType: PlayRunTimelineEventType;
51
- summary: string;
52
- }): PlayRunTimelineEventEntry {
53
- return {
54
- kind: 'event',
55
- at: input.at ?? new Date().toISOString(),
56
- eventType: input.eventType,
57
- summary: input.summary,
58
- };
59
- }
60
-
61
- export type PlayRuntimeTimingWindow = {
62
- startedAt?: number | null;
63
- completedAt?: number | null;
64
- updatedAt?: number | null;
65
- };
66
-
67
- export type PlayStepStatusEventPayload = {
68
- runId: string;
69
- stepId: string;
70
- status: 'running' | 'completed' | 'failed' | 'skipped';
71
- label?: string;
72
- artifactTableNamespace?: string | null;
73
- } & PlayRuntimeTimingWindow;
74
-
75
- export type PlayStepProgressEventPayload = {
76
- runId: string;
77
- stepId: string;
78
- completed?: number;
79
- total?: number;
80
- failed?: number;
81
- message?: string;
82
- artifactTableNamespace?: string | null;
83
- } & PlayRuntimeTimingWindow;
84
-
85
- export type PlayRunHealthEventPayload = {
86
- runId: string;
87
- state: 'healthy' | 'degraded';
88
- reasons: string[];
89
- message: string;
90
- taskQueue: string | null;
91
- workflowPollerCount?: number;
92
- activityPollerCount?: number;
93
- lastHeartbeatAgeMs?: number | null;
94
- };
95
-
96
- export type PlayRunLogEventPayload = {
97
- runId: string;
98
- lines: string[];
99
- source: PlayLiveEventSource;
100
- };
101
-
102
- export type PlaySheetStats = {
103
- total: number;
104
- queued: number;
105
- running: number;
106
- completed: number;
107
- failed: number;
108
- };
109
-
110
- export type PlaySheetColumnStats = {
111
- queued: number;
112
- running: number;
113
- completed: number;
114
- failed: number;
115
- cached: number;
116
- };
117
-
118
- export type PlaySheetSummaryPayload = {
119
- runId: string;
120
- tableNamespace: string;
121
- deltaCursor: number;
122
- summary: {
123
- stats: PlaySheetStats;
124
- columns: Record<string, PlaySheetColumnStats>;
125
- } | null;
126
- previewRows: Array<{
127
- key: string;
128
- status: string;
129
- data: Record<string, unknown>;
130
- cellMeta: Record<string, unknown>;
131
- }>;
132
- };
133
-
134
- export type PlaySheetDeltaEventPayload = {
135
- runId: string;
136
- tableNamespace: string;
137
- nextCursor: number;
138
- updates: Array<{
139
- key: string;
140
- status: string;
141
- data: Record<string, unknown>;
142
- cellMeta: Record<string, unknown>;
143
- inputIndex?: number;
144
- runId?: string;
145
- error?: string;
146
- stage?: string;
147
- provider?: string;
148
- seq?: number;
149
- createdAt: string;
150
- updatedAt: string;
151
- }>;
152
- };
153
-
154
- export function resolveTimingWindow(input: {
155
- startedAt?: number | null;
156
- completedAt?: number | null;
157
- updatedAt?: number | null;
158
- }): PlayRuntimeTimingWindow {
159
- const startedAt =
160
- typeof input.startedAt === 'number' && Number.isFinite(input.startedAt)
161
- ? input.startedAt
162
- : null;
163
- const completedAt =
164
- typeof input.completedAt === 'number' && Number.isFinite(input.completedAt)
165
- ? input.completedAt
166
- : null;
167
- const updatedAt =
168
- typeof input.updatedAt === 'number' && Number.isFinite(input.updatedAt)
169
- ? input.updatedAt
170
- : null;
171
-
172
- return {
173
- startedAt,
174
- completedAt,
175
- updatedAt,
176
- };
177
- }
178
-
179
- export function getTimingDurationMs(input: {
180
- startedAt?: number | null;
181
- completedAt?: number | null;
182
- }): number | null {
183
- return typeof input.startedAt === 'number' &&
184
- Number.isFinite(input.startedAt) &&
185
- typeof input.completedAt === 'number' &&
186
- Number.isFinite(input.completedAt)
187
- ? Math.max(0, input.completedAt - input.startedAt)
188
- : null;
189
- }
190
-
191
- export function getTimingActiveDurationMs(input: {
192
- startedAt?: number | null;
193
- completedAt?: number | null;
194
- updatedAt?: number | null;
195
- now?: number;
196
- }): number | null {
197
- if (
198
- typeof input.startedAt !== 'number' ||
199
- !Number.isFinite(input.startedAt)
200
- ) {
201
- return null;
202
- }
203
- if (
204
- typeof input.completedAt === 'number' &&
205
- Number.isFinite(input.completedAt)
206
- ) {
207
- return Math.max(0, input.completedAt - input.startedAt);
208
- }
209
- const referenceAt =
210
- typeof input.updatedAt === 'number' && Number.isFinite(input.updatedAt)
211
- ? input.updatedAt
212
- : input.now ?? Date.now();
213
- return Math.max(0, referenceAt - input.startedAt);
214
- }
@@ -1,50 +0,0 @@
1
- export type PlayRunLiveStatus =
2
- | 'queued'
3
- | 'running'
4
- | 'completed'
5
- | 'failed'
6
- | 'cancelled'
7
- | 'terminated'
8
- | 'timed_out'
9
- | 'unknown';
10
-
11
- export type PlayVisualNodeStatus =
12
- | 'idle'
13
- | 'running'
14
- | 'completed'
15
- | 'failed'
16
- | 'skipped';
17
-
18
- export type PlayStepLiveStatus = Exclude<PlayVisualNodeStatus, 'idle'>;
19
-
20
- export type PlayVisualNodeProgressSnapshot = {
21
- completed?: number;
22
- total?: number;
23
- failed?: number;
24
- message?: string;
25
- updatedAt?: number | null;
26
- startedAt?: number | null;
27
- completedAt?: number | null;
28
- artifactTableNamespace?: string | null;
29
- };
30
-
31
- export type PlayVisualNodeStateSnapshot = {
32
- nodeId: string;
33
- status: PlayVisualNodeStatus;
34
- artifactTableNamespace?: string | null;
35
- progress?: PlayVisualNodeProgressSnapshot | null;
36
- startedAt?: number | null;
37
- completedAt?: number | null;
38
- updatedAt?: number | null;
39
- };
40
-
41
- export type PlayRunLiveSnapshot = {
42
- runId: string;
43
- status: PlayRunLiveStatus;
44
- updatedAt: number | null;
45
- logs: string[];
46
- activeArtifactTableNamespace: string | null;
47
- resultTableNamespace: string | null;
48
- nodeStates: PlayVisualNodeStateSnapshot[];
49
- activeNodeId: string | null;
50
- };