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,114 +0,0 @@
1
- import type {
2
- MapExecutionFrame,
3
- MapExecutionScope,
4
- PlayCheckpoint,
5
- PlayExecutionEvent,
6
- } from './ctx-types';
7
-
8
- export function cloneMapFrame(frame: MapExecutionFrame): MapExecutionFrame {
9
- return {
10
- ...frame,
11
- completedRowKeys: [...frame.completedRowKeys],
12
- pendingRowKeys: [...frame.pendingRowKeys],
13
- };
14
- }
15
-
16
- export class MapExecutionFrameStore {
17
- constructor(
18
- private readonly checkpoint: PlayCheckpoint,
19
- private readonly emitExecutionEvent: (event: PlayExecutionEvent) => void,
20
- ) {}
21
-
22
- set(frame: MapExecutionFrame): void {
23
- this.checkpoint.mapFrames = {
24
- ...(this.checkpoint.mapFrames ?? {}),
25
- [frame.mapInvocationId]: cloneMapFrame(frame),
26
- };
27
- }
28
-
29
- start(input: {
30
- scope: MapExecutionScope;
31
- totalRows: number;
32
- completedRowKeys: readonly string[];
33
- pendingRowKeys: readonly string[];
34
- }): void {
35
- const now = Date.now();
36
- this.set({
37
- mapInvocationId: input.scope.mapInvocationId,
38
- mapNodeId: input.scope.mapNodeId ?? null,
39
- logicalNamespace: input.scope.logicalNamespace,
40
- artifactTableNamespace: input.scope.artifactTableNamespace,
41
- status: 'running',
42
- totalRows: input.totalRows,
43
- completedRowKeys: [...input.completedRowKeys],
44
- pendingRowKeys: [...input.pendingRowKeys],
45
- startedAt: now,
46
- updatedAt: now,
47
- });
48
- this.emitExecutionEvent({
49
- type: 'map.started',
50
- mapInvocationId: input.scope.mapInvocationId,
51
- mapNodeId: input.scope.mapNodeId ?? null,
52
- logicalNamespace: input.scope.logicalNamespace,
53
- artifactTableNamespace: input.scope.artifactTableNamespace,
54
- totalRows: input.totalRows,
55
- completedRows: input.completedRowKeys.length,
56
- pendingRows: input.pendingRowKeys.length,
57
- at: Date.now(),
58
- });
59
- }
60
-
61
- updateProgress(input: {
62
- scope: MapExecutionScope;
63
- totalRows: number;
64
- status?: MapExecutionFrame['status'];
65
- completedRowKey?: string | null;
66
- pendingRowKey?: string | null;
67
- activeBoundaryId?: string | null;
68
- emitEventType?: PlayExecutionEvent['type'];
69
- }): void {
70
- const existing =
71
- this.checkpoint.mapFrames?.[input.scope.mapInvocationId] ?? null;
72
- if (!existing) {
73
- return;
74
- }
75
- const completedRowKeys = new Set(existing.completedRowKeys);
76
- const pendingRowKeys = new Set(existing.pendingRowKeys);
77
- if (input.completedRowKey?.trim()) {
78
- completedRowKeys.add(input.completedRowKey.trim());
79
- pendingRowKeys.delete(input.completedRowKey.trim());
80
- }
81
- if (input.pendingRowKey?.trim()) {
82
- pendingRowKeys.add(input.pendingRowKey.trim());
83
- }
84
- const nextFrame: MapExecutionFrame = {
85
- ...existing,
86
- status: input.status ?? existing.status,
87
- completedRowKeys: [...completedRowKeys],
88
- pendingRowKeys: [...pendingRowKeys],
89
- ...(input.activeBoundaryId !== undefined
90
- ? { activeBoundaryId: input.activeBoundaryId }
91
- : {}),
92
- updatedAt: Date.now(),
93
- };
94
- this.set(nextFrame);
95
- if (input.emitEventType) {
96
- this.emitExecutionEvent({
97
- type: input.emitEventType,
98
- mapInvocationId: input.scope.mapInvocationId,
99
- mapNodeId: input.scope.mapNodeId ?? null,
100
- logicalNamespace: input.scope.logicalNamespace,
101
- artifactTableNamespace: input.scope.artifactTableNamespace,
102
- completedRows: nextFrame.completedRowKeys.length,
103
- failedRows: Math.max(
104
- 0,
105
- input.totalRows -
106
- nextFrame.completedRowKeys.length -
107
- nextFrame.pendingRowKeys.length,
108
- ),
109
- totalRows: input.totalRows,
110
- at: Date.now(),
111
- } as PlayExecutionEvent);
112
- }
113
- }
114
- }
@@ -1,158 +0,0 @@
1
- import {
2
- derivePlayRowIdentity,
3
- derivePlayRowIdentityFromKey,
4
- } from '@shared_libs/plays/row-identity';
5
- import type { MapExecutionScope } from './ctx-types';
6
-
7
- export type ExplicitMapKeyResolver = (
8
- row: Record<string, unknown>,
9
- index: number,
10
- ) => string;
11
-
12
- export type ExplicitMapKeyInput =
13
- | string
14
- | readonly string[]
15
- | ((row: Record<string, unknown>, index: number) => unknown);
16
-
17
- export function stripMapFieldOutputs(
18
- row: Record<string, unknown>,
19
- fieldNames: readonly string[],
20
- ): Record<string, unknown> {
21
- return Object.fromEntries(
22
- Object.entries(row).filter(
23
- ([fieldName]) => !fieldNames.includes(fieldName),
24
- ),
25
- );
26
- }
27
-
28
- export function createExplicitMapKeyResolver(input: {
29
- mapNamespace: string;
30
- fieldNames: readonly string[];
31
- key: ExplicitMapKeyInput | null | undefined;
32
- }): ExplicitMapKeyResolver | null {
33
- if (!input.key) {
34
- return null;
35
- }
36
- const key = input.key;
37
- return (row, index) => {
38
- const stableRow = stripMapFieldOutputs(row, input.fieldNames);
39
- let raw: unknown;
40
- if (typeof key === 'function') {
41
- raw = key(stableRow, index);
42
- } else if (typeof key === 'string') {
43
- raw = stableRow[key];
44
- } else {
45
- raw = key.map((fieldName) => stableRow[fieldName]);
46
- }
47
- if (raw === null || raw === undefined) {
48
- throw new Error(
49
- `ctx.map("${input.mapNamespace}") key function returned ${raw === null ? 'null' : 'undefined'} for row ${index}. ` +
50
- 'Use a non-empty stable input column (e.g. { key: "email" }) or return a non-empty string, number, or tuple.',
51
- );
52
- }
53
- const asString = normalizeExplicitMapKey(raw);
54
- if (!asString) {
55
- throw new Error(
56
- `ctx.map("${input.mapNamespace}") key function returned an empty value for row ${index}. ` +
57
- 'Use non-empty stable input columns or return a non-empty string, number, or tuple.',
58
- );
59
- }
60
- return asString;
61
- };
62
- }
63
-
64
- function normalizeExplicitMapKey(value: unknown): string {
65
- if (Array.isArray(value)) {
66
- const parts = value.map((entry) => normalizeExplicitMapKeyPart(entry));
67
- return parts.every(Boolean) ? JSON.stringify(parts) : '';
68
- }
69
- return normalizeExplicitMapKeyPart(value);
70
- }
71
-
72
- function normalizeExplicitMapKeyPart(value: unknown): string {
73
- if (typeof value === 'number') {
74
- return Number.isFinite(value) ? String(value) : '';
75
- }
76
- return String(value ?? '').trim();
77
- }
78
-
79
- export function assertUniqueExplicitMapKeys(input: {
80
- mapNamespace: string;
81
- rows: readonly Record<string, unknown>[];
82
- resolver: ExplicitMapKeyResolver | null;
83
- }): void {
84
- if (!input.resolver) {
85
- return;
86
- }
87
- const seenKeys = new Map<string, number>();
88
- for (let index = 0; index < input.rows.length; index += 1) {
89
- const keyValue = input.resolver(input.rows[index]!, index);
90
- const previousIndex = seenKeys.get(keyValue);
91
- if (previousIndex !== undefined) {
92
- throw new Error(
93
- `ctx.map("${input.mapNamespace}") key function produced duplicate value "${keyValue}" for rows ${previousIndex} and ${index}. ` +
94
- 'Each row must produce a unique key. Combine columns (e.g. `${row.email}|${row.company}`) or pick a column that is unique per row.',
95
- );
96
- }
97
- seenKeys.set(keyValue, index);
98
- }
99
- }
100
-
101
- export function deriveMapRowIdentity(input: {
102
- row: Record<string, unknown>;
103
- index?: number;
104
- artifactTableNamespace: string;
105
- fieldNames?: readonly string[];
106
- explicitKey?: ExplicitMapKeyResolver | null;
107
- }): string {
108
- const stableRow = stripMapFieldOutputs(input.row, input.fieldNames ?? []);
109
- return input.explicitKey
110
- ? derivePlayRowIdentityFromKey(
111
- input.explicitKey(stableRow, input.index ?? 0),
112
- input.artifactTableNamespace,
113
- )
114
- : derivePlayRowIdentity(stableRow, input.artifactTableNamespace);
115
- }
116
-
117
- export class MapRowIdentity {
118
- private nextInvocationIndex: number;
119
-
120
- constructor(startInvocationIndex = 0) {
121
- this.nextInvocationIndex = startInvocationIndex;
122
- }
123
-
124
- get invocationIndex(): number {
125
- return this.nextInvocationIndex;
126
- }
127
-
128
- set invocationIndex(value: number) {
129
- this.nextInvocationIndex = value;
130
- }
131
-
132
- createScope(input: {
133
- logicalNamespace: string;
134
- artifactTableNamespace: string;
135
- mapNodeId?: string | null;
136
- fieldNames?: readonly string[];
137
- explicitKey?: ExplicitMapKeyResolver | null;
138
- }): MapExecutionScope {
139
- const mapInvocationId = `${input.logicalNamespace}:${this.nextInvocationIndex}`;
140
- this.nextInvocationIndex += 1;
141
- const explicitKey = input.explicitKey ?? null;
142
- const fieldNames = input.fieldNames ?? [];
143
- return {
144
- mapInvocationId,
145
- mapNodeId: input.mapNodeId ?? null,
146
- logicalNamespace: input.logicalNamespace,
147
- artifactTableNamespace: input.artifactTableNamespace,
148
- rowIdentity: (row, index) =>
149
- deriveMapRowIdentity({
150
- row,
151
- index,
152
- artifactTableNamespace: input.artifactTableNamespace,
153
- fieldNames,
154
- explicitKey,
155
- }),
156
- };
157
- }
158
- }
@@ -1,172 +0,0 @@
1
- import { sqlSafePlayColumnName } from '@shared_libs/plays/static-pipeline';
2
- import type {
3
- InlineWaterfallSpec,
4
- MapExecutionScope,
5
- PlayExecutionEvent,
6
- PlayRowUpdate,
7
- } from './ctx-types';
8
-
9
- type RowContextSnapshot = {
10
- fieldName?: string;
11
- mapScope?: MapExecutionScope;
12
- } | null;
13
-
14
- type CellStatus =
15
- | 'queued'
16
- | 'running'
17
- | 'completed'
18
- | 'failed'
19
- | 'cached'
20
- | 'missed'
21
- | 'skipped';
22
-
23
- export class PlayProgressEmitter {
24
- constructor(
25
- private readonly onRowUpdate:
26
- | ((update: PlayRowUpdate) => void | Promise<void>)
27
- | undefined,
28
- private readonly onExecutionEvent:
29
- | ((event: PlayExecutionEvent) => void | Promise<void>)
30
- | undefined,
31
- private readonly getRowContext: () => RowContextSnapshot,
32
- private readonly isInlineWaterfallToolStep: (
33
- step: InlineWaterfallSpec['steps'][number],
34
- ) => boolean,
35
- ) {}
36
-
37
- executionEvent(event: PlayExecutionEvent): void {
38
- if (!this.onExecutionEvent) {
39
- return;
40
- }
41
- void this.onExecutionEvent(event);
42
- }
43
-
44
- rowUpdate(
45
- key: string | null,
46
- tableNamespace: string | null,
47
- update: Omit<PlayRowUpdate, 'key'>,
48
- ): void {
49
- const rowContext = this.getRowContext();
50
- const rowScope = rowContext?.mapScope;
51
- if (rowScope && key) {
52
- this.executionEvent({
53
- type: 'map.row.updated',
54
- mapInvocationId: rowScope.mapInvocationId,
55
- mapNodeId: rowScope.mapNodeId ?? null,
56
- logicalNamespace: rowScope.logicalNamespace,
57
- artifactTableNamespace: rowScope.artifactTableNamespace,
58
- rowKey: key,
59
- rowStatus: update.status,
60
- fieldName: rowContext?.fieldName ?? null,
61
- stage: update.stage ?? null,
62
- provider: update.provider ?? null,
63
- at: Date.now(),
64
- });
65
- }
66
- if (!key || !this.onRowUpdate) {
67
- return;
68
- }
69
- void this.onRowUpdate({
70
- ...update,
71
- key,
72
- tableNamespace,
73
- });
74
- }
75
-
76
- fieldMetaUpdate(input: {
77
- rowId: number;
78
- key: string | null;
79
- tableNamespace: string | null;
80
- fieldName?: string | null;
81
- status: CellStatus;
82
- rowStatus?: PlayRowUpdate['status'];
83
- stage?: string | null;
84
- provider?: string | null;
85
- error?: string | null;
86
- reused?: boolean;
87
- dataPatch?: Record<string, unknown>;
88
- }): void {
89
- if (!input.fieldName) {
90
- this.rowUpdate(input.key, input.tableNamespace, {
91
- rowId: input.rowId,
92
- status: input.rowStatus,
93
- stage: input.stage ?? null,
94
- provider: input.provider ?? null,
95
- error: input.error ?? null,
96
- dataPatch: input.dataPatch ?? {},
97
- });
98
- return;
99
- }
100
-
101
- this.rowUpdate(input.key, input.tableNamespace, {
102
- rowId: input.rowId,
103
- status: input.rowStatus,
104
- stage: input.stage ?? null,
105
- provider: input.provider ?? null,
106
- error: input.error ?? null,
107
- dataPatch: input.dataPatch ?? {},
108
- cellMetaPatch: {
109
- [input.fieldName]: {
110
- status: input.status,
111
- stage: input.stage ?? null,
112
- provider: input.provider ?? null,
113
- error: input.error ?? null,
114
- ...(input.reused !== undefined ? { reused: input.reused } : {}),
115
- },
116
- },
117
- });
118
- }
119
-
120
- cellUpdate(input: {
121
- rowId: number;
122
- key: string | null;
123
- tableNamespace: string | null;
124
- columnName: string;
125
- status: CellStatus;
126
- rowStatus?: PlayRowUpdate['status'];
127
- stage?: string | null;
128
- provider?: string | null;
129
- error?: string | null;
130
- value?: unknown;
131
- }): void {
132
- this.rowUpdate(input.key, input.tableNamespace, {
133
- rowId: input.rowId,
134
- status: input.rowStatus,
135
- stage: input.stage ?? null,
136
- provider: input.provider ?? null,
137
- error: input.error ?? null,
138
- dataPatch:
139
- input.value === undefined ? {} : { [input.columnName]: input.value },
140
- cellMetaPatch: {
141
- [input.columnName]: {
142
- status: input.status,
143
- stage: input.stage ?? null,
144
- provider: input.provider ?? null,
145
- error: input.error ?? null,
146
- },
147
- },
148
- });
149
- }
150
-
151
- queuedInlineWaterfallSteps(input: {
152
- rowId: number;
153
- key: string | null;
154
- tableNamespace: string | null;
155
- spec: InlineWaterfallSpec;
156
- }): void {
157
- for (const step of input.spec.steps) {
158
- this.cellUpdate({
159
- rowId: input.rowId,
160
- key: input.key,
161
- tableNamespace: input.tableNamespace,
162
- columnName: sqlSafePlayColumnName(`${input.spec.id}.${step.id}`),
163
- status: 'queued',
164
- stage: step.id,
165
- provider: this.isInlineWaterfallToolStep(step)
166
- ? (step as Extract<InlineWaterfallSpec['steps'][number], { toolId: string }>).toolId
167
- : 'code',
168
- value: null,
169
- });
170
- }
171
- }
172
- }
@@ -1,121 +0,0 @@
1
- import type { PlayBundleArtifact } from '../plays/artifact-types';
2
- import type {
3
- PlayCheckpoint,
4
- PlayExecutionEvent,
5
- PlayRowUpdate,
6
- PlayStep,
7
- } from './ctx-types';
8
- import type { PlayExecutionSuspension } from './suspension';
9
- import type { PlayStaticPipeline } from '../plays/static-pipeline';
10
- import type { PlayLiveEventSource } from './live-events';
11
- import type { PreloadedRuntimeDbSession } from './db-session';
12
-
13
- export interface PlayRunnerContextConfig {
14
- executorToken?: string;
15
- baseUrl?: string;
16
- orgId?: string;
17
- workflowId?: string;
18
- playId?: string;
19
- runId?: string;
20
- playName?: string;
21
- userEmail?: string;
22
- convexUrl?: string;
23
- staticPipeline?: PlayStaticPipeline | null;
24
- /**
25
- * Short-lived scoped Postgres sessions minted by the worker before the runner
26
- * starts. They are only an initial fast path: the runner still renews through
27
- * the app runtime API when a session is absent, too close to expiry, or not an
28
- * exact-enough match for the requested play/table/operation scope.
29
- */
30
- preloadedDbSessions?: PreloadedRuntimeDbSession[];
31
- }
32
-
33
- export interface PlayRunnerExecutionConfig {
34
- artifact: PlayBundleArtifact;
35
- input: Record<string, unknown>;
36
- checkpoint?: PlayCheckpoint | null;
37
- csvSourcePath?: string | null;
38
- csvSourceUrl?: string | null;
39
- csvSourceContentBase64?: string | null;
40
- runtimeInputAlias?: string | null;
41
- materializedFiles: Record<string, string>;
42
- workspaceRoot: string;
43
- context: PlayRunnerContextConfig;
44
- }
45
-
46
- export type PlayRunnerLogEvent = {
47
- type: 'log';
48
- at: string;
49
- source: PlayLiveEventSource;
50
- line: string;
51
- };
52
-
53
- export type PlayRunnerEvent =
54
- | PlayRunnerLogEvent
55
- | {
56
- type: 'checkpoint';
57
- checkpoint: PlayCheckpoint;
58
- }
59
- | {
60
- type: 'row_update';
61
- update: PlayRowUpdate;
62
- }
63
- | {
64
- type: 'execution_event';
65
- event: PlayExecutionEvent;
66
- }
67
- | {
68
- type: 'result';
69
- result: PlayRunnerResult;
70
- };
71
-
72
- export type PlayRunnerDeferredRuntimeTask = {
73
- kind: 'daytona_sandbox_cleanup';
74
- sandboxId: string;
75
- billingStartedAt: number;
76
- cpu: number;
77
- memoryGiB: number;
78
- diskGiB: number;
79
- };
80
-
81
- export type PlayRunnerResult =
82
- | {
83
- status: 'completed';
84
- output: unknown;
85
- outputRowCount?: number;
86
- logs: string[];
87
- stats: Record<string, unknown>;
88
- steps: PlayStep[];
89
- checkpoint: PlayCheckpoint;
90
- tableNamespace?: string | null;
91
- totalRows?: number;
92
- inserted?: number;
93
- skipped?: number;
94
- deferredRuntimeTasks?: PlayRunnerDeferredRuntimeTask[];
95
- }
96
- | {
97
- status: 'suspended';
98
- suspension: PlayExecutionSuspension;
99
- logs: string[];
100
- stats: Record<string, unknown>;
101
- steps: PlayStep[];
102
- checkpoint: PlayCheckpoint;
103
- tableNamespace?: string | null;
104
- totalRows?: number;
105
- inserted?: number;
106
- skipped?: number;
107
- deferredRuntimeTasks?: PlayRunnerDeferredRuntimeTask[];
108
- }
109
- | {
110
- status: 'failed';
111
- error: string;
112
- logs: string[];
113
- stats: Record<string, unknown>;
114
- steps: PlayStep[];
115
- checkpoint?: PlayCheckpoint | null;
116
- tableNamespace?: string | null;
117
- totalRows?: number;
118
- inserted?: number;
119
- skipped?: number;
120
- deferredRuntimeTasks?: PlayRunnerDeferredRuntimeTask[];
121
- };
@@ -1,42 +0,0 @@
1
- export type PublicPlayRunStatus =
2
- | 'queued'
3
- | 'running'
4
- | 'waiting'
5
- | 'completed'
6
- | 'failed'
7
- | 'cancelled';
8
-
9
- export interface PublicPlayRunResult {
10
- success: boolean;
11
- runId: string;
12
- result?: unknown;
13
- logs: string[];
14
- durationMs: number;
15
- error?: string;
16
- }
17
-
18
- export interface PublicPlayProgressStatus {
19
- status: string;
20
- totalRows?: number;
21
- logs: string[];
22
- error?: string;
23
- }
24
-
25
- export interface PublicPlayWaitState {
26
- kind: 'integration_event' | 'sleep';
27
- boundaryId?: string;
28
- eventKey?: string;
29
- until?: number;
30
- }
31
-
32
- export interface PublicPlayStatus {
33
- runId: string;
34
- apiVersion?: number;
35
- status: PublicPlayRunStatus;
36
- error?: string;
37
- progress?: PublicPlayProgressStatus;
38
- result?: unknown;
39
- resultView?: unknown;
40
- contract?: Record<string, unknown> | null;
41
- wait?: PublicPlayWaitState | null;
42
- }
@@ -1,33 +0,0 @@
1
- function isRecord(value: unknown): value is Record<string, unknown> {
2
- return value != null && typeof value === 'object' && !Array.isArray(value);
3
- }
4
-
5
- /**
6
- * Normalize integration responses into the higher-level SDK/play shape.
7
- *
8
- * Examples:
9
- * - `{ data: {...} }` => `{...}`
10
- * - `{ provider, operation, result: { data: {...}, meta } }`
11
- * => `{ provider, operation, result: {...} }`
12
- */
13
- export function normalizePlayToolResult(value: unknown): unknown {
14
- if (!isRecord(value)) {
15
- return value;
16
- }
17
-
18
- if ('data' in value) {
19
- return normalizePlayToolResult(value.data);
20
- }
21
-
22
- if ('result' in value) {
23
- const normalizedResult = normalizePlayToolResult(value.result);
24
- if (normalizedResult !== value.result) {
25
- return {
26
- ...value,
27
- result: normalizedResult,
28
- };
29
- }
30
- }
31
-
32
- return value;
33
- }