deepline 0.1.119 → 0.1.121
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/README.md +4 -0
- package/dist/bundling-sources/apps/play-runner-workers/src/runtime/README.md +21 -0
- package/dist/bundling-sources/apps/play-runner-workers/src/runtime/batching.ts +185 -0
- package/dist/bundling-sources/apps/play-runner-workers/src/runtime/tool-batch.ts +107 -0
- package/dist/{repo → bundling-sources}/sdk/src/client.ts +116 -12
- package/dist/bundling-sources/sdk/src/compat.ts +191 -0
- package/dist/bundling-sources/sdk/src/gtm.ts +146 -0
- package/dist/bundling-sources/sdk/src/helpers.ts +12 -0
- package/dist/{repo → bundling-sources}/sdk/src/index.ts +2 -1
- package/dist/{repo → bundling-sources}/sdk/src/play.ts +3 -1
- package/dist/{repo → bundling-sources}/sdk/src/plays/bundle-play-file.ts +17 -5
- package/dist/{repo → bundling-sources}/sdk/src/release.ts +2 -2
- package/dist/{repo → bundling-sources}/sdk/src/runs/observe-transport.ts +2 -3
- package/dist/bundling-sources/shared_libs/play-data-plane/index.ts +3 -0
- package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +838 -0
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +5510 -0
- package/dist/bundling-sources/shared_libs/play-runtime/ctx-contract.ts +261 -0
- package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +828 -0
- package/dist/bundling-sources/shared_libs/play-runtime/dataset-id.ts +10 -0
- package/dist/bundling-sources/shared_libs/play-runtime/daytona-runtime-config.ts +50 -0
- package/dist/bundling-sources/shared_libs/play-runtime/durability-store.ts +20 -0
- package/dist/bundling-sources/shared_libs/play-runtime/event-wait-tools.ts +9 -0
- package/dist/bundling-sources/shared_libs/play-runtime/governor/in-memory-rate-state-backend.ts +171 -0
- package/dist/bundling-sources/shared_libs/play-runtime/hatchet-cold-execution-diagnosis.ts +321 -0
- package/dist/bundling-sources/shared_libs/play-runtime/hatchet-cold-execution-target.ts +158 -0
- package/dist/bundling-sources/shared_libs/play-runtime/internal-step-ids.ts +34 -0
- package/dist/bundling-sources/shared_libs/play-runtime/ledger-safe-payload.ts +34 -0
- package/dist/bundling-sources/shared_libs/play-runtime/live-state-contract.ts +50 -0
- package/dist/bundling-sources/shared_libs/play-runtime/map-execution-frame.ts +119 -0
- package/dist/{repo → bundling-sources}/shared_libs/play-runtime/map-row-identity.ts +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/play-latency-trace.ts +636 -0
- package/dist/bundling-sources/shared_libs/play-runtime/postgres-json.ts +9 -0
- package/dist/bundling-sources/shared_libs/play-runtime/progress-emitter.ts +197 -0
- package/dist/bundling-sources/shared_libs/play-runtime/projection.ts +262 -0
- package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +143 -0
- package/dist/bundling-sources/shared_libs/play-runtime/public-play-contract.ts +42 -0
- package/dist/bundling-sources/shared_libs/play-runtime/receipt-status.ts +40 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-actions.ts +178 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +4015 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-constraints.ts +2 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-pg-driver-neon-serverless.ts +238 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-pg-driver-pg.ts +53 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-pg-driver.ts +149 -0
- package/dist/bundling-sources/shared_libs/play-runtime/suspension.ts +68 -0
- package/dist/bundling-sources/shared_libs/play-runtime/tool-batch-executor.ts +149 -0
- package/dist/bundling-sources/shared_libs/play-runtime/tool-result-types.ts +159 -0
- package/dist/bundling-sources/shared_libs/play-runtime/tracing.ts +33 -0
- package/dist/bundling-sources/shared_libs/play-runtime/waterfall-replay.ts +79 -0
- package/dist/bundling-sources/shared_libs/play-runtime/worker-api-types.ts +139 -0
- package/dist/bundling-sources/shared_libs/plays/artifact-transport.ts +14 -0
- package/dist/bundling-sources/shared_libs/plays/artifact-types.ts +49 -0
- package/dist/bundling-sources/shared_libs/plays/compiler-manifest.ts +41 -0
- package/dist/bundling-sources/shared_libs/plays/dataset-summary.ts +163 -0
- package/dist/bundling-sources/shared_libs/plays/definition.ts +267 -0
- package/dist/bundling-sources/shared_libs/plays/file-refs.ts +11 -0
- package/dist/bundling-sources/shared_libs/plays/input-contract.ts +146 -0
- package/dist/bundling-sources/shared_libs/plays/resolve-static-pipeline.ts +190 -0
- package/dist/bundling-sources/shared_libs/plays/runtime-validation.ts +417 -0
- package/dist/bundling-sources/shared_libs/plays/tool-codegen.ts +142 -0
- package/dist/bundling-sources/shared_libs/security/safe-outbound-fetch.ts +274 -0
- package/dist/bundling-sources/shared_libs/temporal/preview-config.ts +150 -0
- package/dist/cli/index.js +811 -2207
- package/dist/cli/index.mjs +847 -2258
- package/dist/compiler-manifest-BjoRENv9.d.mts +227 -0
- package/dist/compiler-manifest-BjoRENv9.d.ts +227 -0
- package/dist/index.d.mts +8 -231
- package/dist/index.d.ts +8 -231
- package/dist/index.js +101 -15
- package/dist/index.mjs +101 -15
- package/dist/plays/bundle-play-file.d.mts +120 -0
- package/dist/plays/bundle-play-file.d.ts +120 -0
- package/dist/plays/bundle-play-file.mjs +1830 -0
- package/package.json +4 -9
- /package/dist/{repo → bundling-sources}/apps/play-runner-workers/src/child-play-await.ts +0 -0
- /package/dist/{repo → bundling-sources}/apps/play-runner-workers/src/child-play-submit.ts +0 -0
- /package/dist/{repo → bundling-sources}/apps/play-runner-workers/src/coordinator-entry.ts +0 -0
- /package/dist/{repo → bundling-sources}/apps/play-runner-workers/src/dedup-do.ts +0 -0
- /package/dist/{repo → bundling-sources}/apps/play-runner-workers/src/entry.ts +0 -0
- /package/dist/{repo → bundling-sources}/apps/play-runner-workers/src/runtime/csv-rows.ts +0 -0
- /package/dist/{repo → bundling-sources}/apps/play-runner-workers/src/runtime/dataset-handles.ts +0 -0
- /package/dist/{repo → bundling-sources}/apps/play-runner-workers/src/runtime/harness-receipt-store.ts +0 -0
- /package/dist/{repo → bundling-sources}/apps/play-runner-workers/src/runtime/live-progress.ts +0 -0
- /package/dist/{repo → bundling-sources}/apps/play-runner-workers/src/runtime/map-chunk-plan.ts +0 -0
- /package/dist/{repo → bundling-sources}/apps/play-runner-workers/src/runtime/receipts.ts +0 -0
- /package/dist/{repo → bundling-sources}/apps/play-runner-workers/src/runtime/row-isolation.ts +0 -0
- /package/dist/{repo → bundling-sources}/apps/play-runner-workers/src/runtime/tool-http-errors.ts +0 -0
- /package/dist/{repo → bundling-sources}/apps/play-runner-workers/src/workflow-instance-create.ts +0 -0
- /package/dist/{repo → bundling-sources}/apps/play-runner-workers/src/workflow-retry-state.ts +0 -0
- /package/dist/{repo → bundling-sources}/apps/play-runner-workers/src/workflow-retry.ts +0 -0
- /package/dist/{repo → bundling-sources}/sdk/src/agent-runtime.ts +0 -0
- /package/dist/{repo → bundling-sources}/sdk/src/config.ts +0 -0
- /package/dist/{repo → bundling-sources}/sdk/src/errors.ts +0 -0
- /package/dist/{repo → bundling-sources}/sdk/src/http.ts +0 -0
- /package/dist/{repo → bundling-sources}/sdk/src/plays/harness-stub.ts +0 -0
- /package/dist/{repo → bundling-sources}/sdk/src/plays/local-file-discovery.ts +0 -0
- /package/dist/{repo → bundling-sources}/sdk/src/stream-reconnect.ts +0 -0
- /package/dist/{repo → bundling-sources}/sdk/src/tool-output.ts +0 -0
- /package/dist/{repo → bundling-sources}/sdk/src/types.ts +0 -0
- /package/dist/{repo → bundling-sources}/sdk/src/version.ts +0 -0
- /package/dist/{repo → bundling-sources}/sdk/src/worker-play-entry.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-data-plane/cell-policy.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-data-plane/column-names.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-data-plane/sheet-contract.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/backend.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/batch-runtime.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/batching-types.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/cell-staleness.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/coordinator-headers.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/csv-rename.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/db-session-crypto.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/db-session-plan.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/db-session.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/dedup-backend.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/default-batch-strategies.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/email-status.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/execution-plan.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/extractor-targets.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/fullenrich-batching.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/governor/coordinator-rate-state-backend.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/governor/governor.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/governor/policy.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/governor/rate-state-backend.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/live-events.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/play-runtime-batching-registry.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/profiles.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/providers.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/run-failure.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/run-ledger.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/run-snapshot-stream.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/scheduler-backend.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/secret-capability.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/secret-redaction.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/step-lifecycle-tracker.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/step-program-dataset-builder.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/submit-limits.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/tool-result.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/work-receipts.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/plays/bootstrap-routes.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/plays/bundling/index.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/plays/bundling/limits.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/plays/contracts.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/plays/dataset.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/plays/row-identity.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/plays/secret-guardrails.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/plays/static-pipeline.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/security/outbound-url-policy.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/security/safe-fetch.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/temporal/constants.ts +0 -0
|
@@ -0,0 +1,828 @@
|
|
|
1
|
+
// Core types for PlayContext — cloud-only execution via Temporal
|
|
2
|
+
import type { PlayBundleArtifact } from '../plays/artifact-types';
|
|
3
|
+
import type { PlayRunContractSnapshot } from '../plays/contracts';
|
|
4
|
+
import type { PlayStructuredDefinition } from '../plays/definition';
|
|
5
|
+
import type { PlayStaticPipeline } from '../plays/static-pipeline';
|
|
6
|
+
import type {
|
|
7
|
+
PlayDataset,
|
|
8
|
+
PlayDatasetInput,
|
|
9
|
+
PlayDatasetRow,
|
|
10
|
+
} from '../plays/dataset';
|
|
11
|
+
import type { PlayQueueHint } from './governor/rate-state-backend';
|
|
12
|
+
import type { GovernanceSnapshot } from './governor/governor';
|
|
13
|
+
import type { AnyBatchOperationStrategy } from './batching-types';
|
|
14
|
+
import type { ToolResultMetadataInput } from './tool-result';
|
|
15
|
+
import type {
|
|
16
|
+
AuthoredStaleAfterSeconds,
|
|
17
|
+
CellStalenessPolicy,
|
|
18
|
+
PreviousCell,
|
|
19
|
+
} from './cell-staleness';
|
|
20
|
+
import type { MapRowOutcome } from './durability-store';
|
|
21
|
+
|
|
22
|
+
export interface RowState {
|
|
23
|
+
waterfalls: Map<string, WaterfallState>;
|
|
24
|
+
results: Map<string, unknown>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface WaterfallState {
|
|
28
|
+
status: 'pending' | 'complete' | 'failed';
|
|
29
|
+
providerIndex: number;
|
|
30
|
+
result?: unknown;
|
|
31
|
+
error?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface WaterfallRequest {
|
|
35
|
+
rowId: number;
|
|
36
|
+
fieldName?: string;
|
|
37
|
+
tableNamespace?: string;
|
|
38
|
+
rowKey?: string | null;
|
|
39
|
+
key: string;
|
|
40
|
+
toolName: string;
|
|
41
|
+
input: Record<string, unknown>;
|
|
42
|
+
providerIndex: number;
|
|
43
|
+
opts?: WaterfallOptions;
|
|
44
|
+
spec?: InlineWaterfallSpec;
|
|
45
|
+
description?: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface ToolCallRequest {
|
|
49
|
+
callId: string;
|
|
50
|
+
rowId: number;
|
|
51
|
+
fieldName?: string;
|
|
52
|
+
toolId: string;
|
|
53
|
+
input: Record<string, unknown>;
|
|
54
|
+
tableNamespace?: string;
|
|
55
|
+
rowKey?: string | null;
|
|
56
|
+
description?: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface ToolBatchResult {
|
|
60
|
+
done: true;
|
|
61
|
+
result: unknown | null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface RuntimeStepReceipt {
|
|
65
|
+
key: string;
|
|
66
|
+
status: 'pending' | 'running' | 'completed' | 'failed' | 'skipped';
|
|
67
|
+
output?: unknown;
|
|
68
|
+
error?: string;
|
|
69
|
+
runId?: string | null;
|
|
70
|
+
claimState?: 'claimed' | 'existing';
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface GetRuntimeStepReceiptInput {
|
|
74
|
+
key: string;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface ClaimRuntimeStepReceiptInput {
|
|
78
|
+
key: string;
|
|
79
|
+
runId: string;
|
|
80
|
+
reclaimRunning?: boolean;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface CompleteRuntimeStepReceiptInput {
|
|
84
|
+
key: string;
|
|
85
|
+
runId: string;
|
|
86
|
+
output: unknown | null;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface FailRuntimeStepReceiptInput {
|
|
90
|
+
key: string;
|
|
91
|
+
runId: string;
|
|
92
|
+
error: string;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface SkipRuntimeStepReceiptInput {
|
|
96
|
+
key: string;
|
|
97
|
+
runId: string;
|
|
98
|
+
output?: unknown | null;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface WaterfallOptions {
|
|
102
|
+
providers?: string[];
|
|
103
|
+
timeout?: number;
|
|
104
|
+
description?: string;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface CsvOptions {
|
|
108
|
+
description?: string;
|
|
109
|
+
columns?: Record<string, string | readonly string[]>;
|
|
110
|
+
rename?: Record<string, string | readonly string[]>;
|
|
111
|
+
required?: readonly string[];
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export interface DatasetOptions<TItem = Record<string, unknown>> {
|
|
115
|
+
description?: string;
|
|
116
|
+
/**
|
|
117
|
+
* Optional relative cache window for intentional reruns.
|
|
118
|
+
*
|
|
119
|
+
* By default, ctx.dataset is durable by play + dataset key + row identity forever.
|
|
120
|
+
* Set staleAfterSeconds to rerun after that many seconds while retries/replays
|
|
121
|
+
* inside the same window still hit the cache. Daily refreshes use 86400.
|
|
122
|
+
*/
|
|
123
|
+
staleAfterSeconds?: number;
|
|
124
|
+
/**
|
|
125
|
+
* Optional stable key per row. When provided, row identity is derived from
|
|
126
|
+
* the selected input field(s) or returned value instead of hashing the full
|
|
127
|
+
* row. Use this to pin identity to primary columns (e.g. `{ key: "email" }`
|
|
128
|
+
* or `{ key: ["first_name", "last_name", "domain"] }`) so harmless
|
|
129
|
+
* mutations to other columns don't invalidate the cache.
|
|
130
|
+
*
|
|
131
|
+
* Must return a non-empty string (numbers are coerced). Empty keys throw
|
|
132
|
+
* loudly before any provider work runs. Rows whose keys duplicate an earlier
|
|
133
|
+
* row are silently deduped (first occurrence wins) and logged, never failing
|
|
134
|
+
* the run. The key function should reference *input*
|
|
135
|
+
* columns only — values produced by this dataset's field resolvers are stripped
|
|
136
|
+
* before identity is computed.
|
|
137
|
+
*/
|
|
138
|
+
key?:
|
|
139
|
+
| (keyof TItem & string)
|
|
140
|
+
| readonly (keyof TItem & string)[]
|
|
141
|
+
| ((row: TItem, index: number) => string | number | readonly unknown[]);
|
|
142
|
+
/**
|
|
143
|
+
* Row failure policy for this dataset run.
|
|
144
|
+
*
|
|
145
|
+
* Default 'isolate': a row whose column resolver or tool call throws is
|
|
146
|
+
* recorded as a failed row (its error is persisted on the row and the
|
|
147
|
+
* failing cell), sibling rows continue, and the run completes with a
|
|
148
|
+
* partial-failure summary (N succeeded / M failed). Failed rows re-execute
|
|
149
|
+
* on the next run; succeeded rows replay free from receipts. If every
|
|
150
|
+
* executed row fails, the run still fails loudly.
|
|
151
|
+
*
|
|
152
|
+
* 'fail' opts into fail-fast: the first row error aborts the dataset run
|
|
153
|
+
* and fails the play run. Rows persisted before the error stay recoverable
|
|
154
|
+
* and are reused on re-run.
|
|
155
|
+
*/
|
|
156
|
+
onRowError?: 'isolate' | 'fail';
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export type DatasetDefinitionOptions<TItem = Record<string, unknown>> = Omit<
|
|
160
|
+
DatasetOptions<TItem>,
|
|
161
|
+
'description'
|
|
162
|
+
>;
|
|
163
|
+
|
|
164
|
+
export type DatasetRunOptions<TItem = Record<string, unknown>> = Pick<
|
|
165
|
+
DatasetOptions<TItem>,
|
|
166
|
+
'description' | 'key' | 'onRowError'
|
|
167
|
+
>;
|
|
168
|
+
|
|
169
|
+
export interface ToolCallOptions {
|
|
170
|
+
description?: string;
|
|
171
|
+
force?: boolean;
|
|
172
|
+
staleAfterSeconds?: number;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export interface ToolExecutionRequest {
|
|
176
|
+
id: string;
|
|
177
|
+
tool: string;
|
|
178
|
+
input: Record<string, unknown>;
|
|
179
|
+
description?: string;
|
|
180
|
+
force?: boolean;
|
|
181
|
+
staleAfterSeconds?: number;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export type SqlQuery = {
|
|
185
|
+
readonly kind: 'sql.query';
|
|
186
|
+
readonly text: string;
|
|
187
|
+
readonly values: readonly unknown[];
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
export type CustomerDbQueryOptions = {
|
|
191
|
+
maxRows?: number;
|
|
192
|
+
timeoutMs?: number;
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
export type CustomerDbQueryHandler = (
|
|
196
|
+
statement: SqlQuery | string,
|
|
197
|
+
options?: CustomerDbQueryOptions,
|
|
198
|
+
) => Promise<readonly Record<string, unknown>[]>;
|
|
199
|
+
|
|
200
|
+
export interface PlayCallOptions {
|
|
201
|
+
description?: string;
|
|
202
|
+
staleAfterSeconds?: number;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export interface StepOptions {
|
|
206
|
+
recompute?: boolean;
|
|
207
|
+
recomputeOnError?: boolean;
|
|
208
|
+
semanticKey?: string;
|
|
209
|
+
staleAfterSeconds?: number;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export interface FetchOptions {
|
|
213
|
+
staleAfterSeconds?: number;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export interface InlineWaterfallToolStep {
|
|
217
|
+
id: string;
|
|
218
|
+
kind?: 'tool';
|
|
219
|
+
toolId: string;
|
|
220
|
+
mapInput: (input: Record<string, unknown>) => Record<string, unknown>;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export interface InlineWaterfallCodeStepContext {
|
|
224
|
+
tools: {
|
|
225
|
+
execute(request: ToolExecutionRequest): Promise<unknown>;
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export interface InlineWaterfallCodeStep {
|
|
230
|
+
id: string;
|
|
231
|
+
kind: 'code';
|
|
232
|
+
run: (
|
|
233
|
+
input: Record<string, unknown>,
|
|
234
|
+
ctx: InlineWaterfallCodeStepContext,
|
|
235
|
+
) => unknown | Promise<unknown>;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export type InlineWaterfallStep =
|
|
239
|
+
| InlineWaterfallToolStep
|
|
240
|
+
| InlineWaterfallCodeStep;
|
|
241
|
+
|
|
242
|
+
export interface InlineWaterfallSpec {
|
|
243
|
+
id: string;
|
|
244
|
+
output: string;
|
|
245
|
+
minResults: number;
|
|
246
|
+
steps: InlineWaterfallStep[];
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export interface ResolvedPlayExecution {
|
|
250
|
+
playId: string;
|
|
251
|
+
code?: string | null;
|
|
252
|
+
sourceCode?: string | null;
|
|
253
|
+
codeFormat?: 'function' | 'cjs_module' | 'esm_module';
|
|
254
|
+
artifact?: PlayBundleArtifact | null;
|
|
255
|
+
compressedArtifact?: string | null;
|
|
256
|
+
definition?: PlayStructuredDefinition | null;
|
|
257
|
+
staticPipeline?: PlayStaticPipeline | null;
|
|
258
|
+
contractSnapshot?: PlayRunContractSnapshot | null;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export interface PlayExecutionGovernanceLimits {
|
|
262
|
+
maxPlayCallDepth: number;
|
|
263
|
+
maxPlayCallCount: number;
|
|
264
|
+
maxToolCallCount: number;
|
|
265
|
+
maxWaterfallStepExecutions: number | null;
|
|
266
|
+
maxRetryCount: number;
|
|
267
|
+
maxDescendants: number;
|
|
268
|
+
maxChildPlayCallsPerParent: number;
|
|
269
|
+
maxConcurrentPlayCalls: number;
|
|
270
|
+
maxConcurrentToolCalls: number;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export interface PlayExecutionGovernanceState {
|
|
274
|
+
rootPlayId: string;
|
|
275
|
+
rootRunId: string;
|
|
276
|
+
currentPlayId: string;
|
|
277
|
+
currentRunId: string;
|
|
278
|
+
ancestryPlayIds: string[];
|
|
279
|
+
ancestryRunIds: string[];
|
|
280
|
+
callDepth: number;
|
|
281
|
+
playCallCount: number;
|
|
282
|
+
toolCallCount: number;
|
|
283
|
+
waterfallStepExecutions: number;
|
|
284
|
+
retryCount: number;
|
|
285
|
+
descendantCount: number;
|
|
286
|
+
parentChildCalls: Record<string, number>;
|
|
287
|
+
inFlightPlayCalls: number;
|
|
288
|
+
inFlightPlayCallsByPlayId?: Record<string, number>;
|
|
289
|
+
inFlightToolCalls: number;
|
|
290
|
+
limits: PlayExecutionGovernanceLimits;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export interface BatchRequest {
|
|
294
|
+
provider: string;
|
|
295
|
+
toolName: string;
|
|
296
|
+
inputs: Record<string, unknown>[];
|
|
297
|
+
rowIds: number[];
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
export interface MapStartResult {
|
|
301
|
+
/** Rows that need processing (not yet completed in a prior run). */
|
|
302
|
+
pendingRows: Record<string, unknown>[];
|
|
303
|
+
/** Rows already completed in a prior run (cached results). */
|
|
304
|
+
completedRows: Record<string, unknown>[];
|
|
305
|
+
/** Resolved table namespace. */
|
|
306
|
+
tableNamespace: string;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
export interface MapExecutionFrame {
|
|
310
|
+
mapInvocationId: string;
|
|
311
|
+
mapNodeId?: string | null;
|
|
312
|
+
logicalNamespace: string;
|
|
313
|
+
artifactTableNamespace: string;
|
|
314
|
+
status: 'running' | 'suspended' | 'completed' | 'failed';
|
|
315
|
+
totalRows: number;
|
|
316
|
+
completedRowKeys: string[];
|
|
317
|
+
pendingRowKeys: string[];
|
|
318
|
+
activeBoundaryId?: string | null;
|
|
319
|
+
startedAt: number;
|
|
320
|
+
updatedAt: number;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export interface MapExecutionScope {
|
|
324
|
+
mapInvocationId: string;
|
|
325
|
+
mapNodeId?: string | null;
|
|
326
|
+
logicalNamespace: string;
|
|
327
|
+
artifactTableNamespace: string;
|
|
328
|
+
rowIdentity: (row: Record<string, unknown>, index?: number) => string;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
export type PlayExecutionEvent =
|
|
332
|
+
| {
|
|
333
|
+
type: 'map.preparing';
|
|
334
|
+
mapInvocationId: string;
|
|
335
|
+
mapNodeId?: string | null;
|
|
336
|
+
logicalNamespace: string;
|
|
337
|
+
artifactTableNamespace: string;
|
|
338
|
+
totalRows: number;
|
|
339
|
+
completedRows: number;
|
|
340
|
+
pendingRows: number;
|
|
341
|
+
at: number;
|
|
342
|
+
}
|
|
343
|
+
| {
|
|
344
|
+
type: 'map.started';
|
|
345
|
+
mapInvocationId: string;
|
|
346
|
+
mapNodeId?: string | null;
|
|
347
|
+
logicalNamespace: string;
|
|
348
|
+
artifactTableNamespace: string;
|
|
349
|
+
totalRows: number;
|
|
350
|
+
completedRows: number;
|
|
351
|
+
pendingRows: number;
|
|
352
|
+
at: number;
|
|
353
|
+
}
|
|
354
|
+
| {
|
|
355
|
+
type: 'map.progress';
|
|
356
|
+
mapInvocationId: string;
|
|
357
|
+
mapNodeId?: string | null;
|
|
358
|
+
logicalNamespace: string;
|
|
359
|
+
artifactTableNamespace: string;
|
|
360
|
+
completedRows: number;
|
|
361
|
+
failedRows: number;
|
|
362
|
+
totalRows?: number;
|
|
363
|
+
at: number;
|
|
364
|
+
}
|
|
365
|
+
| {
|
|
366
|
+
type: 'map.row.updated';
|
|
367
|
+
mapInvocationId: string;
|
|
368
|
+
mapNodeId?: string | null;
|
|
369
|
+
logicalNamespace: string;
|
|
370
|
+
artifactTableNamespace: string;
|
|
371
|
+
rowKey: string;
|
|
372
|
+
rowStatus?: PlayRowUpdate['status'];
|
|
373
|
+
fieldName?: string | null;
|
|
374
|
+
stage?: string | null;
|
|
375
|
+
provider?: string | null;
|
|
376
|
+
at: number;
|
|
377
|
+
}
|
|
378
|
+
| {
|
|
379
|
+
type: 'map.completed' | 'map.suspended' | 'map.resumed' | 'map.failed';
|
|
380
|
+
mapInvocationId: string;
|
|
381
|
+
mapNodeId?: string | null;
|
|
382
|
+
logicalNamespace: string;
|
|
383
|
+
artifactTableNamespace: string;
|
|
384
|
+
completedRows: number;
|
|
385
|
+
failedRows: number;
|
|
386
|
+
totalRows?: number;
|
|
387
|
+
at: number;
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
export type IntegrationEventWaitRuntimeContext = {
|
|
391
|
+
playId?: string;
|
|
392
|
+
runId?: string;
|
|
393
|
+
workflowId?: string;
|
|
394
|
+
orgId?: string;
|
|
395
|
+
executorToken?: string;
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
export type IntegrationEventWaitBoundary = {
|
|
399
|
+
boundaryId: string;
|
|
400
|
+
eventKey: string;
|
|
401
|
+
timeoutMs: number;
|
|
402
|
+
provider: string;
|
|
403
|
+
toolId: string;
|
|
404
|
+
messageRef?: {
|
|
405
|
+
channel: string;
|
|
406
|
+
ts: string;
|
|
407
|
+
};
|
|
408
|
+
};
|
|
409
|
+
|
|
410
|
+
export type IntegrationEventWaitHandler = {
|
|
411
|
+
provider: string;
|
|
412
|
+
toolId: string;
|
|
413
|
+
prepare: (input: {
|
|
414
|
+
payload: Record<string, unknown>;
|
|
415
|
+
context: IntegrationEventWaitRuntimeContext;
|
|
416
|
+
}) => IntegrationEventWaitBoundary | Promise<IntegrationEventWaitBoundary>;
|
|
417
|
+
arm: (input: {
|
|
418
|
+
payload: Record<string, unknown>;
|
|
419
|
+
context: IntegrationEventWaitRuntimeContext;
|
|
420
|
+
boundary: IntegrationEventWaitBoundary;
|
|
421
|
+
}) => Promise<IntegrationEventWaitBoundary>;
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
export interface ContextOptions {
|
|
425
|
+
/** Short-lived HMAC-signed internal token for tool callbacks. Required for cloud execution. */
|
|
426
|
+
executorToken?: string;
|
|
427
|
+
baseUrl?: string;
|
|
428
|
+
vercelProtectionBypassToken?: string | null;
|
|
429
|
+
orgId?: string;
|
|
430
|
+
userEmail?: string;
|
|
431
|
+
playName?: string;
|
|
432
|
+
graphHash?: string | null;
|
|
433
|
+
artifactHash?: string | null;
|
|
434
|
+
convexUrl?: string;
|
|
435
|
+
staticPipeline?: PlayStaticPipeline | null;
|
|
436
|
+
workflowId?: string;
|
|
437
|
+
sessionId?: string;
|
|
438
|
+
verbose?: boolean;
|
|
439
|
+
/** Heartbeat checkpoint from a previous Temporal activity attempt. */
|
|
440
|
+
checkpoint?: PlayCheckpoint;
|
|
441
|
+
/** Enables durable boundary replay such as ctx.sleep() resumptions. */
|
|
442
|
+
durableBoundaries?: boolean;
|
|
443
|
+
/** Called after each durable batch completes — for Temporal heartbeating. */
|
|
444
|
+
onBatchComplete?: (checkpoint: PlayCheckpoint) => void;
|
|
445
|
+
/** Called when the runtime emits a new execution log line. */
|
|
446
|
+
onLog?: (line: string) => void;
|
|
447
|
+
/**
|
|
448
|
+
* Runtime-provided HTTP transport for ctx.fetch. Node runtimes should provide
|
|
449
|
+
* a transport that validates resolved IP addresses at connect time.
|
|
450
|
+
*/
|
|
451
|
+
fetchImpl?: (input: string | URL, init?: RequestInit) => Promise<Response>;
|
|
452
|
+
/** Called when a row gains new partial data or stage info. */
|
|
453
|
+
onRowUpdate?: (update: PlayRowUpdate) => void | Promise<void>;
|
|
454
|
+
/** Structured execution events emitted from explicit dataset scopes. */
|
|
455
|
+
onExecutionEvent?: (event: PlayExecutionEvent) => void | Promise<void>;
|
|
456
|
+
/**
|
|
457
|
+
* Called when ctx.dataset() starts — inserts items into the sheet and returns
|
|
458
|
+
* the pending/completed split. If not provided, all items are processed.
|
|
459
|
+
*/
|
|
460
|
+
onMapStart?: (
|
|
461
|
+
items: Record<string, unknown>[],
|
|
462
|
+
tableNamespace: string,
|
|
463
|
+
context: {
|
|
464
|
+
playName?: string;
|
|
465
|
+
playId?: string;
|
|
466
|
+
runId?: string;
|
|
467
|
+
staticPipeline?: PlayStaticPipeline | null;
|
|
468
|
+
cellPolicies?: Record<string, CellStalenessPolicy>;
|
|
469
|
+
},
|
|
470
|
+
) => Promise<MapStartResult>;
|
|
471
|
+
/**
|
|
472
|
+
* Called as ctx.dataset() rows complete — persists executed rows (data +
|
|
473
|
+
* cell meta) into the tenant runtime sheet so the sheet, not an in-memory
|
|
474
|
+
* preview, is the source of truth. Invoked in bounded chunks; rows carry
|
|
475
|
+
* deterministic keys, so the write is idempotent across retries and runs.
|
|
476
|
+
*/
|
|
477
|
+
onMapRowsCompleted?: (input: {
|
|
478
|
+
playName?: string;
|
|
479
|
+
playId?: string;
|
|
480
|
+
runId?: string;
|
|
481
|
+
tableNamespace: string;
|
|
482
|
+
rows: MapRowOutcome[];
|
|
483
|
+
outputFields: string[];
|
|
484
|
+
staticPipeline?: PlayStaticPipeline | null;
|
|
485
|
+
}) => Promise<void>;
|
|
486
|
+
playId?: string;
|
|
487
|
+
runId?: string;
|
|
488
|
+
resolvePlay?: (playRef: string) => Promise<ResolvedPlayExecution | null>;
|
|
489
|
+
getToolQueueHints?: (toolId: string) => Promise<readonly PlayQueueHint[]>;
|
|
490
|
+
getToolTargetGetters?: (
|
|
491
|
+
toolId: string,
|
|
492
|
+
output: string,
|
|
493
|
+
) => Promise<readonly string[]>;
|
|
494
|
+
resolveSecret?: (input: {
|
|
495
|
+
name: string;
|
|
496
|
+
playName?: string;
|
|
497
|
+
orgId?: string;
|
|
498
|
+
workflowId?: string;
|
|
499
|
+
runId?: string;
|
|
500
|
+
executorToken?: string;
|
|
501
|
+
}) => Promise<string | null>;
|
|
502
|
+
getToolResultMetadata?: (
|
|
503
|
+
toolId: string,
|
|
504
|
+
) => Promise<ToolResultMetadataInput | null> | ToolResultMetadataInput | null;
|
|
505
|
+
getIntegrationEventWaitHandler?: (
|
|
506
|
+
toolId: string,
|
|
507
|
+
) =>
|
|
508
|
+
| IntegrationEventWaitHandler
|
|
509
|
+
| null
|
|
510
|
+
| Promise<IntegrationEventWaitHandler | null>;
|
|
511
|
+
getBatchOperationStrategy?: (
|
|
512
|
+
operation: string,
|
|
513
|
+
) => AnyBatchOperationStrategy | null;
|
|
514
|
+
queryCustomerDb?: CustomerDbQueryHandler;
|
|
515
|
+
executeStructuredPlayDefinition?: (input: {
|
|
516
|
+
definition: PlayStructuredDefinition;
|
|
517
|
+
ctx: unknown;
|
|
518
|
+
rows: Record<string, unknown>[];
|
|
519
|
+
playInput: Record<string, unknown>;
|
|
520
|
+
}) => Promise<unknown>;
|
|
521
|
+
getRuntimeStepReceipt?: (
|
|
522
|
+
input: GetRuntimeStepReceiptInput,
|
|
523
|
+
) => Promise<RuntimeStepReceipt | null> | RuntimeStepReceipt | null;
|
|
524
|
+
claimRuntimeStepReceipt?: (
|
|
525
|
+
input: ClaimRuntimeStepReceiptInput,
|
|
526
|
+
) => Promise<RuntimeStepReceipt | null> | RuntimeStepReceipt | null;
|
|
527
|
+
completeRuntimeStepReceipt?: (
|
|
528
|
+
input: CompleteRuntimeStepReceiptInput,
|
|
529
|
+
) => Promise<RuntimeStepReceipt | null> | RuntimeStepReceipt | null;
|
|
530
|
+
failRuntimeStepReceipt?: (
|
|
531
|
+
input: FailRuntimeStepReceiptInput,
|
|
532
|
+
) => Promise<RuntimeStepReceipt | null> | RuntimeStepReceipt | null;
|
|
533
|
+
skipRuntimeStepReceipt?: (
|
|
534
|
+
input: SkipRuntimeStepReceiptInput,
|
|
535
|
+
) => Promise<RuntimeStepReceipt | null> | RuntimeStepReceipt | null;
|
|
536
|
+
/**
|
|
537
|
+
* Lineage governance snapshot to resume a child play run from. Produced by the
|
|
538
|
+
* parent's Play Execution Governor `forkChild(...)` so budgets/depth/cycle
|
|
539
|
+
* guards accumulate across the nested-play tree. Only set on child contexts.
|
|
540
|
+
*/
|
|
541
|
+
governance?: GovernanceSnapshot;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
export interface PlayCheckpoint {
|
|
545
|
+
/** Waterfall batches that have completed: key = `${toolName}:${provider}`, value = results array. */
|
|
546
|
+
completedBatches: Record<string, BatchResult[]>;
|
|
547
|
+
/** Tool call batches that have completed: key = toolId, value = sparse row-cache-key -> result map. */
|
|
548
|
+
completedToolBatches: Record<string, Record<string, ToolBatchResult>>;
|
|
549
|
+
/** Row states resolved from completed batches. */
|
|
550
|
+
resolvedWaterfalls: Record<string, Record<string, unknown>>;
|
|
551
|
+
/** Durable boundary completions keyed by boundary id. */
|
|
552
|
+
resolvedBoundaries?: Record<
|
|
553
|
+
string,
|
|
554
|
+
| {
|
|
555
|
+
kind: 'sleep';
|
|
556
|
+
delayMs: number;
|
|
557
|
+
completedAt?: number;
|
|
558
|
+
scope?: {
|
|
559
|
+
type: 'workflow' | 'map_row';
|
|
560
|
+
tableNamespace?: string;
|
|
561
|
+
rowKey?: string;
|
|
562
|
+
rowIndex?: number;
|
|
563
|
+
fieldName?: string;
|
|
564
|
+
};
|
|
565
|
+
}
|
|
566
|
+
| {
|
|
567
|
+
kind: 'integration_event';
|
|
568
|
+
eventKey: string;
|
|
569
|
+
timeoutMs: number;
|
|
570
|
+
provider?: string;
|
|
571
|
+
toolId?: string;
|
|
572
|
+
messageRef?: {
|
|
573
|
+
channel: string;
|
|
574
|
+
ts: string;
|
|
575
|
+
};
|
|
576
|
+
output?: unknown;
|
|
577
|
+
completedAt?: number;
|
|
578
|
+
}
|
|
579
|
+
| {
|
|
580
|
+
kind: 'fetch';
|
|
581
|
+
url: string;
|
|
582
|
+
method: string;
|
|
583
|
+
output?: unknown;
|
|
584
|
+
completedAt?: number;
|
|
585
|
+
}
|
|
586
|
+
| {
|
|
587
|
+
kind: 'step';
|
|
588
|
+
stepId: string;
|
|
589
|
+
output?: unknown;
|
|
590
|
+
completedAt?: number;
|
|
591
|
+
}
|
|
592
|
+
>;
|
|
593
|
+
/** Per-map execution frames keyed by invocation id. */
|
|
594
|
+
mapFrames?: Record<string, MapExecutionFrame>;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
export type PlayFetchResponse = {
|
|
598
|
+
ok: boolean;
|
|
599
|
+
status: number;
|
|
600
|
+
statusText: string;
|
|
601
|
+
url: string;
|
|
602
|
+
headers: Record<string, string>;
|
|
603
|
+
bodyText: string;
|
|
604
|
+
json: unknown | null;
|
|
605
|
+
};
|
|
606
|
+
|
|
607
|
+
export interface BatchResult {
|
|
608
|
+
rowId: number;
|
|
609
|
+
rowKey?: string | null;
|
|
610
|
+
result: unknown | null;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
export interface ToolDefinition {
|
|
614
|
+
toolId: string;
|
|
615
|
+
provider: string;
|
|
616
|
+
providers?: string[]; // For waterfalls
|
|
617
|
+
supportsBatch?: boolean;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
type AwaitedMapValue<T> = T extends Promise<infer U> ? AwaitedMapValue<U> : T;
|
|
621
|
+
|
|
622
|
+
export type MapResolvedFields<TColumns extends Record<string, unknown>> = {
|
|
623
|
+
[K in keyof TColumns]: AwaitedMapValue<TColumns[K]>;
|
|
624
|
+
};
|
|
625
|
+
|
|
626
|
+
export type MapAvailableFields<
|
|
627
|
+
TItem,
|
|
628
|
+
TColumns extends Record<string, unknown>,
|
|
629
|
+
> = TItem & Partial<MapResolvedFields<NoInfer<TColumns>>>;
|
|
630
|
+
|
|
631
|
+
export type MapFieldResolver<
|
|
632
|
+
TItem,
|
|
633
|
+
TFields = Record<string, unknown>,
|
|
634
|
+
TValue = unknown,
|
|
635
|
+
> =
|
|
636
|
+
| TValue
|
|
637
|
+
| ((
|
|
638
|
+
row: TItem,
|
|
639
|
+
ctx: unknown,
|
|
640
|
+
fields: TFields,
|
|
641
|
+
index: number,
|
|
642
|
+
previousCell?: PreviousCell<TValue>,
|
|
643
|
+
) => TValue | Promise<TValue>);
|
|
644
|
+
|
|
645
|
+
export type MapFieldDefinition<
|
|
646
|
+
TItem,
|
|
647
|
+
TColumns extends Record<string, unknown> = Record<string, unknown>,
|
|
648
|
+
> = {
|
|
649
|
+
[K in keyof TColumns]: MapFieldResolver<
|
|
650
|
+
TItem,
|
|
651
|
+
MapAvailableFields<TItem, TColumns>,
|
|
652
|
+
TColumns[K]
|
|
653
|
+
>;
|
|
654
|
+
};
|
|
655
|
+
|
|
656
|
+
export type RuntimeStepResolver<
|
|
657
|
+
Row = Record<string, unknown>,
|
|
658
|
+
Value = unknown,
|
|
659
|
+
> = (
|
|
660
|
+
row: Row,
|
|
661
|
+
ctx: unknown,
|
|
662
|
+
index: number,
|
|
663
|
+
previousCell?: PreviousCell<Value>,
|
|
664
|
+
) => Value | Promise<Value>;
|
|
665
|
+
|
|
666
|
+
export type RuntimeConditionalStepResolver<
|
|
667
|
+
Row = Record<string, unknown>,
|
|
668
|
+
Value = unknown,
|
|
669
|
+
> = {
|
|
670
|
+
kind: 'conditional';
|
|
671
|
+
when: (row: Row, index: number) => boolean | Promise<boolean>;
|
|
672
|
+
run: RuntimeStepResolver<Row, Value>;
|
|
673
|
+
elseValue?: unknown;
|
|
674
|
+
};
|
|
675
|
+
|
|
676
|
+
export type RuntimeStepProgramStep = {
|
|
677
|
+
name: string;
|
|
678
|
+
recompute?: boolean;
|
|
679
|
+
recomputeOnError?: boolean;
|
|
680
|
+
staleAfterSeconds?: AuthoredStaleAfterSeconds;
|
|
681
|
+
resolver:
|
|
682
|
+
| RuntimeStepResolver
|
|
683
|
+
| RuntimeConditionalStepResolver
|
|
684
|
+
| RuntimeStepProgram;
|
|
685
|
+
};
|
|
686
|
+
|
|
687
|
+
export type RuntimeStepProgram = {
|
|
688
|
+
kind: 'steps';
|
|
689
|
+
steps: readonly RuntimeStepProgramStep[];
|
|
690
|
+
returnResolver?: RuntimeStepResolver;
|
|
691
|
+
};
|
|
692
|
+
|
|
693
|
+
export type { PlayDataset, PlayDatasetInput, PlayDatasetRow };
|
|
694
|
+
|
|
695
|
+
// Structured step data for UI visualization
|
|
696
|
+
// csv_load is NOT a step — it's part of the run metadata, not the pipeline
|
|
697
|
+
export type PlayStep =
|
|
698
|
+
| { type: 'start'; trigger?: string; description?: string }
|
|
699
|
+
| { type: 'csv_load'; arg?: string; rows?: number; description?: string }
|
|
700
|
+
| {
|
|
701
|
+
type: 'dataset';
|
|
702
|
+
items: number;
|
|
703
|
+
fields?: string[];
|
|
704
|
+
substeps: PlayDatasetSubstep[];
|
|
705
|
+
description?: string;
|
|
706
|
+
}
|
|
707
|
+
| {
|
|
708
|
+
type: 'waterfall';
|
|
709
|
+
tool?: string;
|
|
710
|
+
providers?: string[];
|
|
711
|
+
id?: string;
|
|
712
|
+
output?: string;
|
|
713
|
+
minResults?: number;
|
|
714
|
+
steps?: Array<{
|
|
715
|
+
id: string;
|
|
716
|
+
kind?: 'tool' | 'code';
|
|
717
|
+
toolId?: string;
|
|
718
|
+
results: PlayStepRowResult[];
|
|
719
|
+
}>;
|
|
720
|
+
results: PlayStepRowResult[];
|
|
721
|
+
description?: string;
|
|
722
|
+
}
|
|
723
|
+
| {
|
|
724
|
+
type: 'tool';
|
|
725
|
+
toolId: string;
|
|
726
|
+
results: PlayStepRowResult[];
|
|
727
|
+
description?: string;
|
|
728
|
+
}
|
|
729
|
+
| {
|
|
730
|
+
type: 'play_call';
|
|
731
|
+
playId: string;
|
|
732
|
+
results?: PlayStepRowResult[];
|
|
733
|
+
nestedSteps: PlayStep[];
|
|
734
|
+
description?: string;
|
|
735
|
+
}
|
|
736
|
+
| {
|
|
737
|
+
type: 'run_javascript';
|
|
738
|
+
alias: string;
|
|
739
|
+
results: PlayStepRowResult[];
|
|
740
|
+
description?: string;
|
|
741
|
+
}
|
|
742
|
+
| { type: 'return'; outputRows: number; description?: string };
|
|
743
|
+
|
|
744
|
+
/** Steps that happen inside ctx.dataset() — tool/waterfall calls from column resolvers. */
|
|
745
|
+
export type PlayDatasetSubstep =
|
|
746
|
+
| {
|
|
747
|
+
type: 'waterfall';
|
|
748
|
+
tool?: string;
|
|
749
|
+
providers?: string[];
|
|
750
|
+
id?: string;
|
|
751
|
+
output?: string;
|
|
752
|
+
minResults?: number;
|
|
753
|
+
steps?: Array<{
|
|
754
|
+
id: string;
|
|
755
|
+
kind?: 'tool' | 'code';
|
|
756
|
+
toolId?: string;
|
|
757
|
+
results: PlayStepRowResult[];
|
|
758
|
+
}>;
|
|
759
|
+
results: PlayStepRowResult[];
|
|
760
|
+
description?: string;
|
|
761
|
+
}
|
|
762
|
+
| {
|
|
763
|
+
type: 'tool';
|
|
764
|
+
toolId: string;
|
|
765
|
+
results: PlayStepRowResult[];
|
|
766
|
+
description?: string;
|
|
767
|
+
}
|
|
768
|
+
| {
|
|
769
|
+
type: 'play_call';
|
|
770
|
+
playId: string;
|
|
771
|
+
results?: PlayStepRowResult[];
|
|
772
|
+
nestedSteps: PlayStep[];
|
|
773
|
+
description?: string;
|
|
774
|
+
}
|
|
775
|
+
| {
|
|
776
|
+
type: 'run_javascript';
|
|
777
|
+
alias: string;
|
|
778
|
+
results: PlayStepRowResult[];
|
|
779
|
+
description?: string;
|
|
780
|
+
};
|
|
781
|
+
|
|
782
|
+
export interface PlayStepRowResult {
|
|
783
|
+
rowId: number;
|
|
784
|
+
status: 'completed' | 'failed' | 'missed' | 'skipped';
|
|
785
|
+
success: boolean;
|
|
786
|
+
provider?: string;
|
|
787
|
+
value?: unknown;
|
|
788
|
+
error?: string | null;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
export interface PlayRowUpdate {
|
|
792
|
+
key: string;
|
|
793
|
+
rowId: number;
|
|
794
|
+
tableNamespace?: string | null;
|
|
795
|
+
status?: 'running' | 'completed' | 'failed';
|
|
796
|
+
stage?: string | null;
|
|
797
|
+
provider?: string | null;
|
|
798
|
+
error?: string | null;
|
|
799
|
+
dataPatch?: Record<string, unknown>;
|
|
800
|
+
cellMetaPatch?: Record<
|
|
801
|
+
string,
|
|
802
|
+
{
|
|
803
|
+
status:
|
|
804
|
+
| 'queued'
|
|
805
|
+
| 'running'
|
|
806
|
+
| 'completed'
|
|
807
|
+
| 'failed'
|
|
808
|
+
| 'cached'
|
|
809
|
+
| 'missed'
|
|
810
|
+
| 'skipped';
|
|
811
|
+
stage?: string | null;
|
|
812
|
+
provider?: string | null;
|
|
813
|
+
error?: string | null;
|
|
814
|
+
producer?: {
|
|
815
|
+
kind: 'play' | 'tool' | 'code';
|
|
816
|
+
id?: string | null;
|
|
817
|
+
displayName?: string | null;
|
|
818
|
+
playId?: string | null;
|
|
819
|
+
toolId?: string | null;
|
|
820
|
+
runId?: string | null;
|
|
821
|
+
} | null;
|
|
822
|
+
reused?: boolean;
|
|
823
|
+
completedAt?: number;
|
|
824
|
+
staleAt?: number | null;
|
|
825
|
+
staleAfterSeconds?: number | null;
|
|
826
|
+
}
|
|
827
|
+
>;
|
|
828
|
+
}
|