deepline 0.0.1 → 0.1.1
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 +324 -0
- package/dist/cli/index.js +6750 -503
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +6735 -512
- package/dist/cli/index.mjs.map +1 -1
- package/dist/index.d.mts +2349 -32
- package/dist/index.d.ts +2349 -32
- package/dist/index.js +1631 -82
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1617 -83
- package/dist/index.mjs.map +1 -1
- package/dist/repo/apps/play-runner-workers/src/coordinator-entry.ts +3256 -0
- package/dist/repo/apps/play-runner-workers/src/dedup-do.ts +710 -0
- package/dist/repo/apps/play-runner-workers/src/entry.ts +5070 -0
- package/dist/repo/apps/play-runner-workers/src/runtime/README.md +21 -0
- package/dist/repo/apps/play-runner-workers/src/runtime/batching.ts +177 -0
- package/dist/repo/apps/play-runner-workers/src/runtime/execution-plan.ts +52 -0
- package/dist/repo/apps/play-runner-workers/src/runtime/tool-batch.ts +100 -0
- package/dist/repo/apps/play-runner-workers/src/runtime/tool-result.ts +184 -0
- package/dist/repo/sdk/src/cli/commands/auth.ts +482 -0
- package/dist/repo/sdk/src/cli/commands/billing.ts +188 -0
- package/dist/repo/sdk/src/cli/commands/csv.ts +123 -0
- package/dist/repo/sdk/src/cli/commands/db.ts +119 -0
- package/dist/repo/sdk/src/cli/commands/feedback.ts +40 -0
- package/dist/repo/sdk/src/cli/commands/org.ts +117 -0
- package/dist/repo/sdk/src/cli/commands/play.ts +3200 -0
- package/dist/repo/sdk/src/cli/commands/tools.ts +687 -0
- package/dist/repo/sdk/src/cli/dataset-stats.ts +341 -0
- package/dist/repo/sdk/src/cli/index.ts +138 -0
- package/dist/repo/sdk/src/cli/progress.ts +135 -0
- package/dist/repo/sdk/src/cli/trace.ts +61 -0
- package/dist/repo/sdk/src/cli/utils.ts +145 -0
- package/dist/repo/sdk/src/client.ts +1188 -0
- package/dist/repo/sdk/src/compat.ts +77 -0
- package/dist/repo/sdk/src/config.ts +285 -0
- package/dist/repo/sdk/src/errors.ts +125 -0
- package/dist/repo/sdk/src/http.ts +391 -0
- package/dist/repo/sdk/src/index.ts +139 -0
- package/dist/repo/sdk/src/play.ts +1330 -0
- package/dist/repo/sdk/src/plays/bundle-play-file.ts +133 -0
- package/dist/repo/sdk/src/plays/harness-stub.ts +210 -0
- package/dist/repo/sdk/src/plays/local-file-discovery.ts +326 -0
- package/dist/repo/sdk/src/tool-output.ts +489 -0
- package/dist/repo/sdk/src/types.ts +669 -0
- package/dist/repo/sdk/src/version.ts +2 -0
- package/dist/repo/sdk/src/worker-play-entry.ts +286 -0
- package/dist/repo/shared_libs/observability/node-tracing.ts +129 -0
- package/dist/repo/shared_libs/observability/tracing.ts +98 -0
- package/dist/repo/shared_libs/play-runtime/backend.ts +139 -0
- package/dist/repo/shared_libs/play-runtime/batch-runtime.ts +182 -0
- package/dist/repo/shared_libs/play-runtime/batching-types.ts +91 -0
- package/dist/repo/shared_libs/play-runtime/context.ts +3999 -0
- package/dist/repo/shared_libs/play-runtime/coordinator-headers.ts +78 -0
- package/dist/repo/shared_libs/play-runtime/ctx-contract.ts +250 -0
- package/dist/repo/shared_libs/play-runtime/ctx-types.ts +713 -0
- package/dist/repo/shared_libs/play-runtime/dataset-id.ts +10 -0
- package/dist/repo/shared_libs/play-runtime/db-session-crypto.ts +304 -0
- package/dist/repo/shared_libs/play-runtime/db-session.ts +462 -0
- package/dist/repo/shared_libs/play-runtime/dedup-backend.ts +0 -0
- package/dist/repo/shared_libs/play-runtime/default-batch-strategies.ts +124 -0
- package/dist/repo/shared_libs/play-runtime/execution-plan.ts +262 -0
- package/dist/repo/shared_libs/play-runtime/live-events.ts +214 -0
- package/dist/repo/shared_libs/play-runtime/live-state-contract.ts +50 -0
- package/dist/repo/shared_libs/play-runtime/map-execution-frame.ts +114 -0
- package/dist/repo/shared_libs/play-runtime/map-row-identity.ts +158 -0
- package/dist/repo/shared_libs/play-runtime/profiles.ts +90 -0
- package/dist/repo/shared_libs/play-runtime/progress-emitter.ts +172 -0
- package/dist/repo/shared_libs/play-runtime/protocol.ts +121 -0
- package/dist/repo/shared_libs/play-runtime/public-play-contract.ts +42 -0
- package/dist/repo/shared_libs/play-runtime/result-normalization.ts +33 -0
- package/dist/repo/shared_libs/play-runtime/runtime-actions.ts +208 -0
- package/dist/repo/shared_libs/play-runtime/runtime-api.ts +1873 -0
- package/dist/repo/shared_libs/play-runtime/runtime-constraints.ts +2 -0
- package/dist/repo/shared_libs/play-runtime/runtime-pg-driver-neon-serverless.ts +201 -0
- package/dist/repo/shared_libs/play-runtime/runtime-pg-driver-pg.ts +48 -0
- package/dist/repo/shared_libs/play-runtime/runtime-pg-driver.ts +84 -0
- package/dist/repo/shared_libs/play-runtime/scheduler-backend.ts +174 -0
- package/dist/repo/shared_libs/play-runtime/static-pipeline-types.ts +147 -0
- package/dist/repo/shared_libs/play-runtime/suspension.ts +68 -0
- package/dist/repo/shared_libs/play-runtime/tool-batch-executor.ts +146 -0
- package/dist/repo/shared_libs/play-runtime/tool-result.ts +387 -0
- package/dist/repo/shared_libs/play-runtime/tracing.ts +31 -0
- package/dist/repo/shared_libs/play-runtime/waterfall-replay.ts +75 -0
- package/dist/repo/shared_libs/play-runtime/worker-api-types.ts +140 -0
- package/dist/repo/shared_libs/plays/artifact-transport.ts +14 -0
- package/dist/repo/shared_libs/plays/artifact-types.ts +49 -0
- package/dist/repo/shared_libs/plays/bundling/index.ts +1346 -0
- package/dist/repo/shared_libs/plays/compiler-manifest.ts +186 -0
- package/dist/repo/shared_libs/plays/contracts.ts +51 -0
- package/dist/repo/shared_libs/plays/dataset.ts +308 -0
- package/dist/repo/shared_libs/plays/definition.ts +264 -0
- package/dist/repo/shared_libs/plays/file-refs.ts +11 -0
- package/dist/repo/shared_libs/plays/rate-limit-scheduler.ts +206 -0
- package/dist/repo/shared_libs/plays/resolve-static-pipeline.ts +164 -0
- package/dist/repo/shared_libs/plays/row-identity.ts +302 -0
- package/dist/repo/shared_libs/plays/runtime-validation.ts +415 -0
- package/dist/repo/shared_libs/plays/static-pipeline.ts +560 -0
- package/dist/repo/shared_libs/temporal/constants.ts +39 -0
- package/dist/repo/shared_libs/temporal/preview-config.ts +153 -0
- package/package.json +14 -12
package/dist/index.d.ts
CHANGED
|
@@ -1,105 +1,2422 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The runtime shape of a built play artifact. Different runner backends need
|
|
3
|
+
* different bundle outputs:
|
|
4
|
+
* - cjs_node20: Daytona + local-process (full Node.js sandbox).
|
|
5
|
+
* - esm_workers: Cloudflare Workers (V8 isolate, no `fs`/`child_process`).
|
|
6
|
+
*
|
|
7
|
+
* The CLI selects which kind to build based on the target backend; the worker
|
|
8
|
+
* validates the kind matches the backend it's about to dispatch to.
|
|
9
|
+
*/
|
|
10
|
+
declare const PLAY_ARTIFACT_KINDS: {
|
|
11
|
+
readonly cjsNode20: "cjs_node20";
|
|
12
|
+
readonly esmWorkers: "esm_workers";
|
|
13
|
+
};
|
|
14
|
+
type PlayArtifactKind = (typeof PLAY_ARTIFACT_KINDS)[keyof typeof PLAY_ARTIFACT_KINDS];
|
|
15
|
+
|
|
16
|
+
interface PlayStaticPipelineSnapshot {
|
|
17
|
+
tableNamespace?: string;
|
|
18
|
+
inputFields?: string[];
|
|
19
|
+
csvArg?: string;
|
|
20
|
+
hasInlineData?: boolean;
|
|
21
|
+
csvDescription?: string;
|
|
22
|
+
mapDescription?: string;
|
|
23
|
+
fields: string[];
|
|
24
|
+
stages?: PlayStaticSubstepSnapshot[];
|
|
25
|
+
substeps: PlayStaticSubstepSnapshot[];
|
|
26
|
+
sheetContract?: PlaySheetContractSnapshot | null;
|
|
27
|
+
sheetContractErrors?: string[];
|
|
28
|
+
}
|
|
29
|
+
type PlaySheetColumnSourceSnapshot = 'input' | 'mapField' | 'waterfallStep' | 'childPlayColumn';
|
|
30
|
+
interface PlaySheetColumnContractSnapshot {
|
|
31
|
+
id: string;
|
|
32
|
+
sqlName: string;
|
|
33
|
+
source: PlaySheetColumnSourceSnapshot;
|
|
34
|
+
field?: string;
|
|
35
|
+
parentField?: string;
|
|
36
|
+
playId?: string;
|
|
37
|
+
waterfallId?: string;
|
|
38
|
+
outputField?: string;
|
|
39
|
+
outputSqlName?: string;
|
|
40
|
+
stepId?: string;
|
|
41
|
+
toolId?: string;
|
|
42
|
+
}
|
|
43
|
+
interface PlaySheetContractSnapshot {
|
|
44
|
+
tableNamespace: string;
|
|
45
|
+
columns: PlaySheetColumnContractSnapshot[];
|
|
46
|
+
}
|
|
47
|
+
interface PlayStaticSourceRangeSnapshot {
|
|
48
|
+
sourcePath?: string;
|
|
49
|
+
startLine: number;
|
|
50
|
+
endLine: number;
|
|
51
|
+
startColumn: number;
|
|
52
|
+
endColumn: number;
|
|
53
|
+
}
|
|
54
|
+
type PlayStaticSubstepMetadataSnapshot = {
|
|
55
|
+
conditional?: boolean;
|
|
56
|
+
};
|
|
57
|
+
type PlayStaticSubstepSnapshot = PlayStaticSubstepMetadataSnapshot & ({
|
|
58
|
+
type: 'csv';
|
|
59
|
+
field: string;
|
|
60
|
+
path?: string;
|
|
61
|
+
description?: string;
|
|
62
|
+
sourceRange?: PlayStaticSourceRangeSnapshot;
|
|
63
|
+
callDepth?: number;
|
|
64
|
+
callPath?: string[];
|
|
65
|
+
} | {
|
|
66
|
+
type: 'map';
|
|
67
|
+
field: string;
|
|
68
|
+
name?: string;
|
|
69
|
+
tableNamespace?: string;
|
|
70
|
+
inputFields?: string[];
|
|
71
|
+
outputFields?: string[];
|
|
72
|
+
waterfallIds?: string[];
|
|
73
|
+
sheetContract?: PlaySheetContractSnapshot | null;
|
|
74
|
+
description?: string;
|
|
75
|
+
sourceRange?: PlayStaticSourceRangeSnapshot;
|
|
76
|
+
callDepth?: number;
|
|
77
|
+
callPath?: string[];
|
|
78
|
+
} | {
|
|
79
|
+
type: 'tool';
|
|
80
|
+
toolId: string;
|
|
81
|
+
field: string;
|
|
82
|
+
description?: string;
|
|
83
|
+
inLoop?: boolean;
|
|
84
|
+
isEventWait?: boolean;
|
|
85
|
+
sourceRange?: PlayStaticSourceRangeSnapshot;
|
|
86
|
+
callDepth?: number;
|
|
87
|
+
callPath?: string[];
|
|
88
|
+
} | {
|
|
89
|
+
type: 'waterfall';
|
|
90
|
+
tool?: string;
|
|
91
|
+
field: string;
|
|
92
|
+
inLoop?: boolean;
|
|
93
|
+
id?: string;
|
|
94
|
+
output?: string;
|
|
95
|
+
minResults?: number;
|
|
96
|
+
sourceText?: string;
|
|
97
|
+
steps?: Array<{
|
|
98
|
+
id: string;
|
|
99
|
+
kind?: 'tool' | 'code';
|
|
100
|
+
toolId?: string;
|
|
101
|
+
paramsSource?: string;
|
|
102
|
+
}>;
|
|
103
|
+
description?: string;
|
|
104
|
+
sourceRange?: PlayStaticSourceRangeSnapshot;
|
|
105
|
+
callDepth?: number;
|
|
106
|
+
callPath?: string[];
|
|
107
|
+
} | {
|
|
108
|
+
type: 'step_suite';
|
|
109
|
+
field: string;
|
|
110
|
+
steps: PlayStaticSubstepSnapshot[];
|
|
111
|
+
returnSource?: string;
|
|
112
|
+
description?: string;
|
|
113
|
+
sourceRange?: PlayStaticSourceRangeSnapshot;
|
|
114
|
+
callDepth?: number;
|
|
115
|
+
callPath?: string[];
|
|
116
|
+
} | {
|
|
117
|
+
type: 'play_call';
|
|
118
|
+
playId: string;
|
|
119
|
+
field: string;
|
|
120
|
+
inLoop?: boolean;
|
|
121
|
+
pipeline?: PlayStaticPipelineSnapshot | null;
|
|
122
|
+
cycleDetected?: boolean;
|
|
123
|
+
resolutionError?: string;
|
|
124
|
+
description?: string;
|
|
125
|
+
sourceRange?: PlayStaticSourceRangeSnapshot;
|
|
126
|
+
callDepth?: number;
|
|
127
|
+
callPath?: string[];
|
|
128
|
+
} | {
|
|
129
|
+
type: 'run_javascript';
|
|
130
|
+
alias: string;
|
|
131
|
+
description?: string;
|
|
132
|
+
sourceRange?: PlayStaticSourceRangeSnapshot;
|
|
133
|
+
callDepth?: number;
|
|
134
|
+
callPath?: string[];
|
|
135
|
+
} | {
|
|
136
|
+
type: 'code';
|
|
137
|
+
field: string;
|
|
138
|
+
description?: string;
|
|
139
|
+
sourceRange?: PlayStaticSourceRangeSnapshot;
|
|
140
|
+
callDepth?: number;
|
|
141
|
+
callPath?: string[];
|
|
142
|
+
});
|
|
143
|
+
type PlayCompilerDependencyManifest = {
|
|
144
|
+
playName: string;
|
|
145
|
+
sourceHash: string;
|
|
146
|
+
graphHash: string;
|
|
147
|
+
artifactHash: string;
|
|
148
|
+
staticPipeline: PlayStaticPipelineSnapshot;
|
|
149
|
+
};
|
|
150
|
+
type PlayCompilerManifest = {
|
|
151
|
+
compilerVersion: number;
|
|
152
|
+
playName: string;
|
|
153
|
+
sourceHash: string;
|
|
154
|
+
graphHash: string;
|
|
155
|
+
artifactHash: string;
|
|
156
|
+
artifactKind?: PlayArtifactKind;
|
|
157
|
+
staticPipeline: PlayStaticPipelineSnapshot;
|
|
158
|
+
importedPlayDependencies: PlayCompilerDependencyManifest[];
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Options for constructing a {@link DeeplineClient} or connecting via {@link Deepline.connect}.
|
|
163
|
+
*
|
|
164
|
+
* All fields are optional — the SDK resolves missing values from environment
|
|
165
|
+
* variables and CLI-managed config files. See {@link resolveConfig} for the
|
|
166
|
+
* full resolution order.
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```typescript
|
|
170
|
+
* import { DeeplineClient } from 'deepline';
|
|
171
|
+
*
|
|
172
|
+
* // Minimal — uses env vars / CLI config automatically:
|
|
173
|
+
* const client = new DeeplineClient();
|
|
174
|
+
*
|
|
175
|
+
* // Explicit overrides:
|
|
176
|
+
* const client2 = new DeeplineClient({
|
|
177
|
+
* apiKey: 'dl_test_...',
|
|
178
|
+
* baseUrl: 'http://localhost:3000',
|
|
179
|
+
* timeout: 30_000,
|
|
180
|
+
* maxRetries: 5,
|
|
181
|
+
* });
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
1
184
|
interface DeeplineClientOptions {
|
|
185
|
+
/** API key. Overrides `DEEPLINE_API_KEY` env var and CLI-stored keys. */
|
|
2
186
|
apiKey?: string;
|
|
187
|
+
/** Base URL of the Deepline API. Overrides `DEEPLINE_ORIGIN_URL` / `DEEPLINE_API_BASE_URL`. */
|
|
3
188
|
baseUrl?: string;
|
|
189
|
+
/** Per-request timeout in milliseconds. Default: `60_000` (60 seconds). */
|
|
4
190
|
timeout?: number;
|
|
191
|
+
/** Maximum retry attempts for transient failures (network errors, 429s). Default: `3`. */
|
|
5
192
|
maxRetries?: number;
|
|
6
193
|
}
|
|
194
|
+
/**
|
|
195
|
+
* Fully resolved configuration used internally by the SDK.
|
|
196
|
+
*
|
|
197
|
+
* Produced by {@link resolveConfig} — all fields are guaranteed non-empty.
|
|
198
|
+
*/
|
|
7
199
|
interface ResolvedConfig {
|
|
200
|
+
/** Validated API key (non-empty string). */
|
|
8
201
|
apiKey: string;
|
|
202
|
+
/** Normalized base URL (trailing slash stripped). */
|
|
9
203
|
baseUrl: string;
|
|
204
|
+
/** Request timeout in milliseconds. */
|
|
10
205
|
timeout: number;
|
|
206
|
+
/** Max retry count for transient failures. */
|
|
11
207
|
maxRetries: number;
|
|
12
208
|
}
|
|
13
|
-
interface
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
error?: string;
|
|
18
|
-
credits?: number | null;
|
|
209
|
+
interface CustomerDbColumn {
|
|
210
|
+
name: string;
|
|
211
|
+
table_id: number | null;
|
|
212
|
+
data_type_id: number | null;
|
|
19
213
|
}
|
|
214
|
+
interface CustomerDbQueryResult {
|
|
215
|
+
command: string;
|
|
216
|
+
row_count: number | null;
|
|
217
|
+
row_count_returned: number;
|
|
218
|
+
truncated: boolean;
|
|
219
|
+
columns: CustomerDbColumn[];
|
|
220
|
+
rows: unknown[];
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Summary definition of a tool, returned by {@link DeeplineClient.listTools}.
|
|
224
|
+
*
|
|
225
|
+
* Contains everything needed to discover, describe, and call a tool.
|
|
226
|
+
*
|
|
227
|
+
* @example
|
|
228
|
+
* ```typescript
|
|
229
|
+
* const tools = await client.listTools();
|
|
230
|
+
* for (const tool of tools) {
|
|
231
|
+
* console.log(`${tool.toolId} (${tool.provider}): ${tool.description}`);
|
|
232
|
+
* }
|
|
233
|
+
* ```
|
|
234
|
+
*/
|
|
20
235
|
interface ToolDefinition {
|
|
236
|
+
/** Unique tool identifier used in API calls (e.g. `"apollo_people_search"`). */
|
|
21
237
|
toolId: string;
|
|
238
|
+
/** Provider that backs this tool (e.g. `"apollo"`, `"hunter"`, `"test"`). */
|
|
22
239
|
provider: string;
|
|
240
|
+
/** Human-readable name for display. */
|
|
23
241
|
displayName: string;
|
|
242
|
+
/** What this tool does — suitable for LLM tool descriptions. */
|
|
24
243
|
description: string;
|
|
244
|
+
/** Categorization tags (e.g. `["people", "enrichment"]`). */
|
|
25
245
|
categories: string[];
|
|
246
|
+
/** Operation slug within the provider. */
|
|
247
|
+
operation?: string;
|
|
248
|
+
/** Normalized operation identifier. */
|
|
249
|
+
operationId?: string;
|
|
250
|
+
/** Alternative names that resolve to this tool. */
|
|
251
|
+
operationAliases?: string[];
|
|
252
|
+
/** JSON Schema describing the tool's input parameters. */
|
|
26
253
|
inputSchema?: Record<string, unknown>;
|
|
254
|
+
/** JSON Schema describing the tool's output shape. */
|
|
27
255
|
outputSchema?: Record<string, unknown>;
|
|
256
|
+
/**
|
|
257
|
+
* Dotted paths for extracting list data from the tool's response.
|
|
258
|
+
*
|
|
259
|
+
* Used by {@link tryConvertToList} to automatically find the array of results
|
|
260
|
+
* in a nested response. Example: `["people", "result.data"]`.
|
|
261
|
+
*/
|
|
262
|
+
listExtractorPaths?: string[];
|
|
263
|
+
/** Field mappings for extracting identity fields (email, phone, etc.) from results. */
|
|
264
|
+
resultIdentityGetters?: Record<string, string[]>;
|
|
265
|
+
/** Whether the output is a direct object or wrapped in a `result` envelope. */
|
|
266
|
+
rowContextShape?: 'direct' | 'result_envelope';
|
|
28
267
|
}
|
|
268
|
+
/**
|
|
269
|
+
* Extended tool metadata including pricing, samples, and failure modes.
|
|
270
|
+
*
|
|
271
|
+
* Returned by {@link DeeplineClient.getTool}. Extends {@link ToolDefinition}
|
|
272
|
+
* with operational details needed for cost estimation and debugging.
|
|
273
|
+
*
|
|
274
|
+
* @example
|
|
275
|
+
* ```typescript
|
|
276
|
+
* const meta = await client.getTool('apollo_people_search');
|
|
277
|
+
* console.log(meta.displayName); // "Apollo People Search"
|
|
278
|
+
* console.log(meta.estimatedCreditsRange); // "1-5"
|
|
279
|
+
* console.log(meta.samples); // { input: {...}, output: {...} }
|
|
280
|
+
* ```
|
|
281
|
+
*/
|
|
282
|
+
interface ToolMetadata extends ToolDefinition {
|
|
283
|
+
/** Related async polling action, if this tool supports async execution. */
|
|
284
|
+
asyncGetAction?: string | null;
|
|
285
|
+
/** Known failure scenarios and their expected handling. */
|
|
286
|
+
failureMode?: Record<string, unknown> | null;
|
|
287
|
+
/** Provider-side pricing structure. */
|
|
288
|
+
cost?: Record<string, unknown> | null;
|
|
289
|
+
/** How many Deepline credits map to one provider pricing unit. */
|
|
290
|
+
deeplineCreditsPerPricingUnit?: number | null;
|
|
291
|
+
/** Whether cost is billed by the provider or by Deepline. */
|
|
292
|
+
billingSource?: string;
|
|
293
|
+
/** Display label for the billing source. */
|
|
294
|
+
billingSourceLabel?: string;
|
|
295
|
+
/** Play expansion config if this tool auto-expands in plays. */
|
|
296
|
+
playExpansion?: Record<string, unknown>;
|
|
297
|
+
/** Estimated credit range for a single call (e.g. `"1-5"`). */
|
|
298
|
+
estimatedCreditsRange?: string;
|
|
299
|
+
/** Version of the cost estimation model used. */
|
|
300
|
+
estimateModelVersion?: string;
|
|
301
|
+
/** Tools whose costs were used to build this estimate. */
|
|
302
|
+
estimateBasedOnTools?: string[];
|
|
303
|
+
/** Individual step cost contributions (for composite tools). */
|
|
304
|
+
stepContributions?: unknown[];
|
|
305
|
+
/** Example input/output pairs for documentation and testing. */
|
|
306
|
+
samples?: Record<string, unknown>;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Final result of a play execution, returned by {@link DeeplineClient.runPlay}.
|
|
310
|
+
*
|
|
311
|
+
* @example
|
|
312
|
+
* ```typescript
|
|
313
|
+
* const result = await client.runPlay(code, null, 'my-play');
|
|
314
|
+
* if (result.success) {
|
|
315
|
+
* console.log('Output:', result.result);
|
|
316
|
+
* console.log(`Completed in ${result.durationMs}ms`);
|
|
317
|
+
* } else {
|
|
318
|
+
* console.error('Failed:', result.error);
|
|
319
|
+
* console.log('Logs:', result.logs.join('\n'));
|
|
320
|
+
* }
|
|
321
|
+
* ```
|
|
322
|
+
*/
|
|
29
323
|
interface PlayRunResult {
|
|
324
|
+
/** `true` if the play completed successfully (`status === 'completed'`). */
|
|
30
325
|
success: boolean;
|
|
31
|
-
|
|
326
|
+
/** Public play-run identifier — use for `play tail` or status polling. */
|
|
327
|
+
runId: string;
|
|
328
|
+
/** The play's return value. Only present on success. */
|
|
32
329
|
result?: unknown;
|
|
330
|
+
/** All log lines emitted via `ctx.log()` during execution. */
|
|
33
331
|
logs: string[];
|
|
332
|
+
/** Wall-clock duration from submission to completion, in milliseconds. */
|
|
34
333
|
durationMs: number;
|
|
334
|
+
/** Error message if the play failed, was cancelled, or timed out. */
|
|
35
335
|
error?: string;
|
|
36
336
|
}
|
|
337
|
+
/**
|
|
338
|
+
* Progress snapshot from a running play, nested inside {@link PlayStatus}.
|
|
339
|
+
*/
|
|
340
|
+
interface PlayProgressStatus {
|
|
341
|
+
/** Human-readable description of the current step. */
|
|
342
|
+
status: string;
|
|
343
|
+
/** Total row count for row-based processing (e.g. CSV enrichment). */
|
|
344
|
+
totalRows?: number;
|
|
345
|
+
/** Accumulated log lines from `ctx.log()`. Grows monotonically. */
|
|
346
|
+
logs: string[];
|
|
347
|
+
/** Error message if the play has failed. */
|
|
348
|
+
error?: string;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Current status of a play execution, returned by {@link DeeplineClient.getPlayStatus}.
|
|
352
|
+
*
|
|
353
|
+
* Poll this until `status` reaches a terminal state:
|
|
354
|
+
* `'completed'` | `'failed'` | `'cancelled'`.
|
|
355
|
+
*
|
|
356
|
+
* @example
|
|
357
|
+
* ```typescript
|
|
358
|
+
* const status = await client.getPlayStatus(runId);
|
|
359
|
+
* if (status.status === 'completed') {
|
|
360
|
+
* console.log('Done:', status.result);
|
|
361
|
+
* } else if (status.status === 'running' || status.status === 'waiting') {
|
|
362
|
+
* console.log('Logs so far:', status.progress?.logs);
|
|
363
|
+
* }
|
|
364
|
+
* ```
|
|
365
|
+
*/
|
|
366
|
+
interface PlayStatus {
|
|
367
|
+
/** Public play-run identifier. */
|
|
368
|
+
runId: string;
|
|
369
|
+
/** Public Deepline play-run API version. */
|
|
370
|
+
apiVersion?: number;
|
|
371
|
+
/** Saved play name for this run, when available. */
|
|
372
|
+
name?: string;
|
|
373
|
+
/** Alias for `name` used by run/result APIs. */
|
|
374
|
+
playName?: string;
|
|
375
|
+
/** Product-level play-run state. */
|
|
376
|
+
status: 'queued' | 'running' | 'waiting' | 'completed' | 'failed' | 'cancelled';
|
|
377
|
+
/** Execution progress with logs and error details. */
|
|
378
|
+
progress?: PlayProgressStatus;
|
|
379
|
+
/** Partial or final result. Available once the play returns. */
|
|
380
|
+
result?: unknown;
|
|
381
|
+
/** Temporal-backed run metadata when returned by the status endpoint. */
|
|
382
|
+
run?: {
|
|
383
|
+
startTime?: string | null;
|
|
384
|
+
closeTime?: string | null;
|
|
385
|
+
[key: string]: unknown;
|
|
386
|
+
} | null;
|
|
387
|
+
/** Server-rendered result view metadata for CLI/UI summaries. */
|
|
388
|
+
resultView?: unknown;
|
|
389
|
+
/** Canonical run contract snapshot metadata, when available. */
|
|
390
|
+
contract?: Record<string, unknown> | null;
|
|
391
|
+
/** If the run is blocked on a durable boundary, expose the public wait state. */
|
|
392
|
+
wait?: {
|
|
393
|
+
kind: 'integration_event' | 'sleep';
|
|
394
|
+
boundaryId?: string;
|
|
395
|
+
eventKey?: string;
|
|
396
|
+
until?: number;
|
|
397
|
+
} | null;
|
|
398
|
+
}
|
|
399
|
+
type LiveEventScope = 'play' | 'agent';
|
|
400
|
+
interface LiveEventEnvelope<TPayload = unknown> {
|
|
401
|
+
cursor: string;
|
|
402
|
+
streamId: string;
|
|
403
|
+
scope: LiveEventScope;
|
|
404
|
+
type: string;
|
|
405
|
+
at: string;
|
|
406
|
+
payload: TPayload;
|
|
407
|
+
}
|
|
408
|
+
type PlayLiveEvent = LiveEventEnvelope<unknown> & {
|
|
409
|
+
scope: 'play';
|
|
410
|
+
};
|
|
411
|
+
/**
|
|
412
|
+
* Result returned by {@link DeeplineClient.stopPlay}.
|
|
413
|
+
*/
|
|
414
|
+
interface StopPlayRunResult {
|
|
415
|
+
/** Public play-run identifier that was stopped. */
|
|
416
|
+
runId: string;
|
|
417
|
+
/** Stop request acknowledgement. */
|
|
418
|
+
stopped: true;
|
|
419
|
+
/** Number of open HITL interactions marked cancelled. */
|
|
420
|
+
hitlCancelledCount: number;
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Summary of a single play run, returned by {@link DeeplineClient.listPlayRuns}.
|
|
424
|
+
*/
|
|
425
|
+
interface PlayRunListItem {
|
|
426
|
+
/** Temporal workflow ID. */
|
|
427
|
+
workflowId: string;
|
|
428
|
+
/** Temporal run ID (unique per retry of the same workflow). */
|
|
429
|
+
runId: string;
|
|
430
|
+
/** Workflow type (typically `'Workflow'`). */
|
|
431
|
+
type: string;
|
|
432
|
+
/** Human-readable status (e.g. `'Completed'`, `'Failed'`). */
|
|
433
|
+
status: string;
|
|
434
|
+
/** ISO 8601 timestamp when the run started. */
|
|
435
|
+
startTime: string | null;
|
|
436
|
+
/** ISO 8601 timestamp when the run finished. */
|
|
437
|
+
closeTime: string | null;
|
|
438
|
+
/** Duration string (e.g. `'2.5s'`). */
|
|
439
|
+
executionTime: string | null;
|
|
440
|
+
/** Metadata attached to the workflow. */
|
|
441
|
+
memo: {
|
|
442
|
+
/** Organization that owns this run. */
|
|
443
|
+
orgId: string;
|
|
444
|
+
/** Play name. */
|
|
445
|
+
playName: string;
|
|
446
|
+
/** User who triggered the run, if known. */
|
|
447
|
+
userId: string | null;
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* A single revision (version) of a play's code and configuration.
|
|
452
|
+
*/
|
|
453
|
+
interface PlayRevisionSummary {
|
|
454
|
+
/** Convex revision document ID used for exact-version runs and live promotion. */
|
|
455
|
+
_id?: string;
|
|
456
|
+
/** Monotonically increasing version number. */
|
|
457
|
+
version: number;
|
|
458
|
+
/** R2 storage reference for the bundled code artifact. */
|
|
459
|
+
artifactStorageKey?: string | null;
|
|
460
|
+
/** Immutable artifact hash for the revision. */
|
|
461
|
+
artifactHash?: string | null;
|
|
462
|
+
/** Static dependency graph hash for the revision. */
|
|
463
|
+
graphHash?: string | null;
|
|
464
|
+
/** Hash of the original source file. */
|
|
465
|
+
sourceHash?: string | null;
|
|
466
|
+
/** Original TypeScript source code. */
|
|
467
|
+
sourceCode?: string | null;
|
|
468
|
+
/** Primary key column for CSV-based plays. */
|
|
469
|
+
tableNamespace?: string | null;
|
|
470
|
+
/** Static pipeline definition (for declarative plays). */
|
|
471
|
+
staticPipeline?: unknown;
|
|
472
|
+
/** Extracted binding metadata. */
|
|
473
|
+
bindings?: unknown;
|
|
474
|
+
/** Human-readable description of this revision. */
|
|
475
|
+
description?: string | null;
|
|
476
|
+
/** Unix timestamp (ms) when this revision was created. */
|
|
477
|
+
createdAt?: number;
|
|
478
|
+
/** Unix timestamp (ms) of last update. */
|
|
479
|
+
updatedAt?: number;
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Aggregate row-processing stats for a play's sheet.
|
|
483
|
+
*/
|
|
484
|
+
interface PlaySheetStats {
|
|
485
|
+
total: number;
|
|
486
|
+
queued: number;
|
|
487
|
+
running: number;
|
|
488
|
+
completed: number;
|
|
489
|
+
failed: number;
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Per-column processing stats within a play's sheet.
|
|
493
|
+
*/
|
|
494
|
+
interface PlaySheetColumnStats {
|
|
495
|
+
queued: number;
|
|
496
|
+
running: number;
|
|
497
|
+
completed: number;
|
|
498
|
+
failed: number;
|
|
499
|
+
cached: number;
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* Summary of a play's data sheet state.
|
|
503
|
+
*/
|
|
504
|
+
interface PlaySheetSummary {
|
|
505
|
+
/** Aggregate stats across all rows. */
|
|
506
|
+
stats: PlaySheetStats;
|
|
507
|
+
/** Per-column breakdown of processing state. */
|
|
508
|
+
columns: Record<string, PlaySheetColumnStats>;
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* Full play definition with revision history and run stats.
|
|
512
|
+
*
|
|
513
|
+
* Returned by {@link DeeplineClient.getPlay}.
|
|
514
|
+
*/
|
|
515
|
+
interface PlayDefinitionDetail {
|
|
516
|
+
/** Convex document ID. */
|
|
517
|
+
_id: string;
|
|
518
|
+
/** Stable registry key. */
|
|
519
|
+
playKey?: string;
|
|
520
|
+
/** Canonical owner-qualified play reference. */
|
|
521
|
+
reference?: string;
|
|
522
|
+
/** Play name (unique within an org). */
|
|
523
|
+
name: string;
|
|
524
|
+
/** Human-friendly display name for UI surfaces. */
|
|
525
|
+
displayName?: string;
|
|
526
|
+
/** Whether this entry comes from the Deepline prebuilt registry or the org-owned catalog. */
|
|
527
|
+
origin?: 'prebuilt' | 'owned';
|
|
528
|
+
/** Ownership class used for permissions and badges. */
|
|
529
|
+
ownerType?: 'deepline' | 'org';
|
|
530
|
+
/** Slug of the owning workspace, or `deepline` for system plays. */
|
|
531
|
+
ownerSlug?: string;
|
|
532
|
+
/** Scope in the control plane. */
|
|
533
|
+
scope?: 'org' | 'system';
|
|
534
|
+
/** Whether the current actor can edit this play in place. */
|
|
535
|
+
canEdit?: boolean;
|
|
536
|
+
/** Whether the current actor can clone this play into their org. */
|
|
537
|
+
canClone?: boolean;
|
|
538
|
+
/** Organization ID that owns this play. */
|
|
539
|
+
orgId: string;
|
|
540
|
+
/** User ID that created the play. */
|
|
541
|
+
userId: string;
|
|
542
|
+
/** Total number of times this play has been executed. */
|
|
543
|
+
runCount: number;
|
|
544
|
+
/** Primary key column for CSV-based plays. */
|
|
545
|
+
tableNamespace?: string | null;
|
|
546
|
+
/** Temporal workflow ID of the latest run. */
|
|
547
|
+
latestRunId?: string | null;
|
|
548
|
+
/** Unix timestamp (ms). */
|
|
549
|
+
createdAt: number;
|
|
550
|
+
/** Unix timestamp (ms). */
|
|
551
|
+
updatedAt: number;
|
|
552
|
+
/** Source code of the current revision. */
|
|
553
|
+
sourceCode?: string | null;
|
|
554
|
+
/** Static pipeline, if applicable. */
|
|
555
|
+
staticPipeline?: unknown;
|
|
556
|
+
/** Serialized input schema contract for rendering / validation help. */
|
|
557
|
+
inputSchema?: Record<string, unknown> | null;
|
|
558
|
+
/** Serialized output schema contract for rendering / validation help. */
|
|
559
|
+
outputSchema?: Record<string, unknown> | null;
|
|
560
|
+
/** Alternate names that resolve to this play. */
|
|
561
|
+
aliases?: string[];
|
|
562
|
+
/** The revision that run-by-name resolves to. */
|
|
563
|
+
currentRevision?: PlayRevisionSummary | null;
|
|
564
|
+
/** The current working revision (may differ from live). */
|
|
565
|
+
workingRevision?: PlayRevisionSummary | null;
|
|
566
|
+
/** The live revision that executes for named runs. */
|
|
567
|
+
liveRevision?: PlayRevisionSummary | null;
|
|
568
|
+
/** `true` if the working revision differs from the live revision. */
|
|
569
|
+
isDraftDirty?: boolean;
|
|
570
|
+
/** Compatibility field for older readers. */
|
|
571
|
+
currentPublishedVersion?: number | null;
|
|
572
|
+
}
|
|
573
|
+
interface PlayListItem {
|
|
574
|
+
playKey?: string;
|
|
575
|
+
reference?: string;
|
|
576
|
+
name: string;
|
|
577
|
+
displayName?: string;
|
|
578
|
+
origin?: 'prebuilt' | 'owned';
|
|
579
|
+
ownerType?: 'deepline' | 'org';
|
|
580
|
+
ownerSlug?: string;
|
|
581
|
+
canEdit?: boolean;
|
|
582
|
+
canClone?: boolean;
|
|
583
|
+
orgId: string;
|
|
584
|
+
userId: string;
|
|
585
|
+
runCount: number;
|
|
586
|
+
updatedAt: number;
|
|
587
|
+
createdAt: number;
|
|
588
|
+
currentPublishedVersion?: number | null;
|
|
589
|
+
tableNamespace?: string | null;
|
|
590
|
+
isDraftDirty?: boolean;
|
|
591
|
+
inputSchema?: Record<string, unknown> | null;
|
|
592
|
+
outputSchema?: Record<string, unknown> | null;
|
|
593
|
+
aliases?: string[];
|
|
594
|
+
}
|
|
595
|
+
interface PlayDescription {
|
|
596
|
+
name: string;
|
|
597
|
+
reference?: string;
|
|
598
|
+
displayName?: string;
|
|
599
|
+
origin?: 'prebuilt' | 'owned';
|
|
600
|
+
ownerType?: 'deepline' | 'org';
|
|
601
|
+
canEdit?: boolean;
|
|
602
|
+
canClone?: boolean;
|
|
603
|
+
aliases: string[];
|
|
604
|
+
inputSchema?: Record<string, unknown> | null;
|
|
605
|
+
outputSchema?: Record<string, unknown> | null;
|
|
606
|
+
runCommand: string;
|
|
607
|
+
examples: string[];
|
|
608
|
+
currentPublishedVersion?: number | null;
|
|
609
|
+
isDraftDirty?: boolean;
|
|
610
|
+
latestRunId?: string | null;
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* Complete play detail including definition, recent runs, and sheet state.
|
|
614
|
+
*
|
|
615
|
+
* Returned by {@link DeeplineClient.getPlay}.
|
|
616
|
+
*
|
|
617
|
+
* @example
|
|
618
|
+
* ```typescript
|
|
619
|
+
* const detail = await client.getPlay('email-waterfall');
|
|
620
|
+
* console.log(`${detail.play.name} — ${detail.play.runCount} runs`);
|
|
621
|
+
* console.log(`Live: v${detail.play.liveRevision?.version}`);
|
|
622
|
+
* console.log(`Latest runs:`, detail.latestRuns.map(r => r.status));
|
|
623
|
+
* ```
|
|
624
|
+
*/
|
|
625
|
+
interface PlayDetail {
|
|
626
|
+
/** Full play definition with revisions. */
|
|
627
|
+
play: PlayDefinitionDetail;
|
|
628
|
+
/** Most recent runs (newest first). */
|
|
629
|
+
latestRuns: PlayRunListItem[];
|
|
630
|
+
/** Sheet processing summary. */
|
|
631
|
+
sheetSummary: PlaySheetSummary;
|
|
632
|
+
/** Neon database URL for this play's customer data. */
|
|
633
|
+
customerDbUrl: string;
|
|
634
|
+
/** Change cursor for incremental sync. */
|
|
635
|
+
deltaCursor: number;
|
|
636
|
+
}
|
|
637
|
+
interface ClearPlayHistoryRequest {
|
|
638
|
+
/** Optional explicit ctx.map keys to clear. Omit to clear all discovered sheets for the play. */
|
|
639
|
+
tableNamespaces?: string[];
|
|
640
|
+
}
|
|
641
|
+
interface ClearPlayHistoryResult {
|
|
642
|
+
playName: string;
|
|
643
|
+
deletedRuns: number;
|
|
644
|
+
droppedTables: string[];
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* Response from starting a play run.
|
|
648
|
+
*
|
|
649
|
+
* Internal/advanced payload returned by low-level play submission primitives.
|
|
650
|
+
* Most callers should prefer `deepline play run`, {@link DeeplineClient.runPlay},
|
|
651
|
+
* or {@link PlayJob.get}.
|
|
652
|
+
*
|
|
653
|
+
* @example
|
|
654
|
+
* ```typescript
|
|
655
|
+
* const started = await client.startPlayRun({ name: 'my-play', input: { domain: 'stripe.com' } });
|
|
656
|
+
* console.log(`Started: ${started.workflowId}`);
|
|
657
|
+
* console.log(`Status URL: ${started.statusUrl}`);
|
|
658
|
+
* console.log(`Dashboard: ${started.dashboardUrl}`);
|
|
659
|
+
* ```
|
|
660
|
+
*/
|
|
661
|
+
interface PlayRunStart {
|
|
662
|
+
/** Temporal workflow ID for tracking this execution. */
|
|
663
|
+
workflowId: string;
|
|
664
|
+
/** Public Deepline play-run API version. */
|
|
665
|
+
apiVersion?: number;
|
|
666
|
+
/** Play name (echoed back from the request). */
|
|
667
|
+
name?: string;
|
|
668
|
+
/** Initial status (typically `'RUNNING'`). */
|
|
669
|
+
status?: string;
|
|
670
|
+
/** Resolved runtime backend used for this run. */
|
|
671
|
+
runtimeBackend?: string;
|
|
672
|
+
/** Canonical run contract compatibility metadata. */
|
|
673
|
+
contract?: Record<string, unknown> | null;
|
|
674
|
+
/** URL to poll for status updates. */
|
|
675
|
+
statusUrl?: string;
|
|
676
|
+
/** Dashboard URL for the named play. */
|
|
677
|
+
dashboardUrl?: string;
|
|
678
|
+
/** Terminal status returned when the start request used a short completion wait. */
|
|
679
|
+
finalStatus?: unknown;
|
|
680
|
+
}
|
|
681
|
+
/**
|
|
682
|
+
* Result returned by {@link DeeplineClient.checkPlayArtifact}.
|
|
683
|
+
*
|
|
684
|
+
* This is the check-only version of play artifact registration: the server runs
|
|
685
|
+
* the same preflight compiler and static-analysis pass without storing,
|
|
686
|
+
* publishing, or starting a Temporal run.
|
|
687
|
+
*/
|
|
688
|
+
interface PlayCheckResult {
|
|
689
|
+
valid: boolean;
|
|
690
|
+
errors: string[];
|
|
691
|
+
staticPipeline?: Record<string, unknown> | null;
|
|
692
|
+
artifactHash?: string | null;
|
|
693
|
+
graphHash?: string | null;
|
|
694
|
+
}
|
|
695
|
+
/**
|
|
696
|
+
* Request body for starting a play run via {@link DeeplineClient.startPlayRun}.
|
|
697
|
+
*
|
|
698
|
+
* Internal/advanced request shape for low-level submission primitives.
|
|
699
|
+
* Most callers should prefer `deepline play run`, {@link DeeplineClient.runPlay},
|
|
700
|
+
* or {@link Deepline.connect}.
|
|
701
|
+
*
|
|
702
|
+
* Either `name` (for live plays) or `artifactStorageKey` (for packaged ad hoc runs) is required.
|
|
703
|
+
*
|
|
704
|
+
* @example
|
|
705
|
+
* ```typescript
|
|
706
|
+
* // Run a live play by name:
|
|
707
|
+
* await client.startPlayRun({ name: 'email-waterfall', input: { domain: 'stripe.com' } });
|
|
708
|
+
*
|
|
709
|
+
* // Run a packaged ad hoc play by registered artifact:
|
|
710
|
+
* await client.startPlayRun({
|
|
711
|
+
* artifactStorageKey: 'plays/artifacts/org/acme/my-play/playgraph_abc123.json',
|
|
712
|
+
* input: { domain: 'stripe.com' },
|
|
713
|
+
* });
|
|
714
|
+
* ```
|
|
715
|
+
*/
|
|
716
|
+
interface StartPlayRunRequest {
|
|
717
|
+
/** Play name for registered revisions. */
|
|
718
|
+
name?: string;
|
|
719
|
+
/** Explicit revision ID when the caller wants a specific saved version. */
|
|
720
|
+
revisionId?: string;
|
|
721
|
+
/** R2 artifact key for ad hoc artifact-backed runs. */
|
|
722
|
+
artifactStorageKey?: string;
|
|
723
|
+
/** Source snapshot already validated while registering this artifact. */
|
|
724
|
+
sourceCode?: string;
|
|
725
|
+
/** Static pipeline already produced while registering this artifact. */
|
|
726
|
+
staticPipeline?: unknown;
|
|
727
|
+
/** Artifact content hash already validated while registering this artifact. */
|
|
728
|
+
artifactHash?: string;
|
|
729
|
+
/** Static graph hash already validated while registering this artifact. */
|
|
730
|
+
graphHash?: string;
|
|
731
|
+
/** Optional preloaded artifact snapshot for immediate ad hoc execution. */
|
|
732
|
+
runtimeArtifact?: Record<string, unknown>;
|
|
733
|
+
/** Compiler manifest for ad hoc graph runs, including imported play dependencies. */
|
|
734
|
+
compilerManifest?: PlayCompilerManifest;
|
|
735
|
+
/** Primary input file bytes for one-shot server-side staging. */
|
|
736
|
+
inputFileUpload?: unknown;
|
|
737
|
+
/** Packaged file bytes for one-shot server-side staging. */
|
|
738
|
+
packagedFileUploads?: unknown[];
|
|
739
|
+
/** Runtime input passed to the play function as its second argument. */
|
|
740
|
+
input?: Record<string, unknown>;
|
|
741
|
+
/** Staged file reference for the primary input file (e.g. CSV). */
|
|
742
|
+
inputFile?: unknown;
|
|
743
|
+
/** Additional staged file references (dependencies, data files). */
|
|
744
|
+
packagedFiles?: unknown[];
|
|
745
|
+
/** Force-supersede any active runs for this play before starting. */
|
|
746
|
+
force?: boolean;
|
|
747
|
+
/** Optionally let the start request wait briefly and return a terminal result. */
|
|
748
|
+
waitForCompletionMs?: number;
|
|
749
|
+
/**
|
|
750
|
+
* Per-run execution profile override. The server defaults to `workers_edge`;
|
|
751
|
+
* tests/benchmarks pass `legacy` or `local` here. Most callers should leave
|
|
752
|
+
* this unset.
|
|
753
|
+
*/
|
|
754
|
+
profile?: string;
|
|
755
|
+
}
|
|
756
|
+
/**
|
|
757
|
+
* Request body for making a play revision live.
|
|
758
|
+
*
|
|
759
|
+
* If omitted, the server promotes the current working revision.
|
|
760
|
+
*/
|
|
761
|
+
interface PublishPlayVersionRequest {
|
|
762
|
+
/** Explicit revision ID to make live. */
|
|
763
|
+
revisionId?: string;
|
|
764
|
+
}
|
|
765
|
+
/**
|
|
766
|
+
* Result returned after making a play revision live.
|
|
767
|
+
*/
|
|
768
|
+
interface PublishPlayVersionResult {
|
|
769
|
+
success: boolean;
|
|
770
|
+
name: string;
|
|
771
|
+
liveVersion?: number;
|
|
772
|
+
triggerMetadata?: unknown;
|
|
773
|
+
triggerBindings?: unknown;
|
|
774
|
+
}
|
|
775
|
+
/**
|
|
776
|
+
* Result returned after deleting an org-owned play.
|
|
777
|
+
*/
|
|
778
|
+
interface DeletePlayResult {
|
|
779
|
+
deleted: boolean;
|
|
780
|
+
name: string;
|
|
781
|
+
deletedRevisionCount: number;
|
|
782
|
+
deletedBindingCount: number;
|
|
783
|
+
deletedRunCount: number;
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
interface PlayStagedFileRef {
|
|
787
|
+
storageKind: 'r2';
|
|
788
|
+
storageKey: string;
|
|
789
|
+
logicalPath: string;
|
|
790
|
+
fileName: string;
|
|
791
|
+
contentHash: string;
|
|
792
|
+
contentType: string;
|
|
793
|
+
bytes: number;
|
|
794
|
+
}
|
|
37
795
|
|
|
796
|
+
/**
|
|
797
|
+
* Low-level client for the Deepline REST API.
|
|
798
|
+
*
|
|
799
|
+
* Provides typed methods for every API endpoint: tools, plays, auth, and health.
|
|
800
|
+
* Handles authentication, retries, and localhost failover automatically.
|
|
801
|
+
*
|
|
802
|
+
* @example
|
|
803
|
+
* ```typescript
|
|
804
|
+
* import { DeeplineClient } from 'deepline';
|
|
805
|
+
*
|
|
806
|
+
* // Zero-config (uses env vars / CLI auth):
|
|
807
|
+
* const client = new DeeplineClient();
|
|
808
|
+
*
|
|
809
|
+
* // Explicit config:
|
|
810
|
+
* const client2 = new DeeplineClient({
|
|
811
|
+
* apiKey: 'dl_test_...',
|
|
812
|
+
* baseUrl: 'http://localhost:3000',
|
|
813
|
+
* });
|
|
814
|
+
* ```
|
|
815
|
+
*/
|
|
38
816
|
declare class DeeplineClient {
|
|
39
817
|
private readonly http;
|
|
40
818
|
private readonly config;
|
|
819
|
+
/**
|
|
820
|
+
* @param options - Optional overrides for API key, base URL, timeout, and retries.
|
|
821
|
+
* @throws {@link ConfigError} if no API key can be resolved from any source.
|
|
822
|
+
*/
|
|
41
823
|
constructor(options?: DeeplineClientOptions);
|
|
824
|
+
/** The resolved base URL this client is targeting (e.g. `"http://localhost:3000"`). */
|
|
42
825
|
get baseUrl(): string;
|
|
43
|
-
|
|
826
|
+
private compactSchema;
|
|
827
|
+
private playRunCommand;
|
|
828
|
+
private summarizePlayListItem;
|
|
829
|
+
private summarizePlayDetail;
|
|
830
|
+
/**
|
|
831
|
+
* List all available tools.
|
|
832
|
+
*
|
|
833
|
+
* Returns tool definitions including ID, provider, description, input/output schemas,
|
|
834
|
+
* and list extractor paths for automatic CSV conversion.
|
|
835
|
+
*
|
|
836
|
+
* @returns Array of tool definitions
|
|
837
|
+
*
|
|
838
|
+
* @example
|
|
839
|
+
* ```typescript
|
|
840
|
+
* const tools = await client.listTools();
|
|
841
|
+
* const searchTools = tools.filter(t => t.categories.includes('search'));
|
|
842
|
+
* console.log(`Found ${searchTools.length} search tools`);
|
|
843
|
+
* ```
|
|
844
|
+
*/
|
|
44
845
|
listTools(): Promise<ToolDefinition[]>;
|
|
45
|
-
/**
|
|
846
|
+
/**
|
|
847
|
+
* Get detailed metadata for a single tool.
|
|
848
|
+
*
|
|
849
|
+
* Returns everything from {@link ToolDefinition} plus pricing info, sample
|
|
850
|
+
* inputs/outputs, failure modes, and cost estimates.
|
|
851
|
+
*
|
|
852
|
+
* @param toolId - Tool identifier (e.g. `"apollo_people_search"`)
|
|
853
|
+
* @returns Full tool metadata
|
|
854
|
+
*
|
|
855
|
+
* @example
|
|
856
|
+
* ```typescript
|
|
857
|
+
* const meta = await client.getTool('apollo_people_search');
|
|
858
|
+
* console.log(`Cost: ${meta.estimatedCreditsRange} credits`);
|
|
859
|
+
* console.log(`Input schema:`, meta.inputSchema);
|
|
860
|
+
* ```
|
|
861
|
+
*/
|
|
862
|
+
getTool(toolId: string): Promise<ToolMetadata>;
|
|
863
|
+
/**
|
|
864
|
+
* Execute a tool and return the extracted result.
|
|
865
|
+
*
|
|
866
|
+
* Sends the input payload to the tool and returns the `.result` field from the
|
|
867
|
+
* response. For the full response envelope (including job_id, credits, etc.),
|
|
868
|
+
* use {@link executeToolRaw}.
|
|
869
|
+
*
|
|
870
|
+
* @param toolId - Tool identifier (e.g. `"test_company_search"`)
|
|
871
|
+
* @param input - Tool-specific input parameters
|
|
872
|
+
* @returns The tool's output (shape varies by tool)
|
|
873
|
+
* @throws {@link DeeplineError} if the tool execution fails
|
|
874
|
+
*
|
|
875
|
+
* @example
|
|
876
|
+
* ```typescript
|
|
877
|
+
* const company = await client.executeTool('test_company_search', {
|
|
878
|
+
* domain: 'stripe.com',
|
|
879
|
+
* });
|
|
880
|
+
* console.log(company); // { name: "Stripe", industry: "Financial Services", ... }
|
|
881
|
+
* ```
|
|
882
|
+
*/
|
|
46
883
|
executeTool(toolId: string, input: Record<string, unknown>): Promise<unknown>;
|
|
47
884
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
885
|
+
* Execute a tool and return the full response envelope.
|
|
886
|
+
*
|
|
887
|
+
* Unlike {@link executeTool}, this returns the complete API response including
|
|
888
|
+
* `job_id`, `status`, `credits`, and the raw `result` object.
|
|
889
|
+
*
|
|
890
|
+
* @param toolId - Tool identifier
|
|
891
|
+
* @param input - Tool-specific input parameters
|
|
892
|
+
* @returns Full response with job metadata and result
|
|
893
|
+
*
|
|
894
|
+
* @example
|
|
895
|
+
* ```typescript
|
|
896
|
+
* const raw = await client.executeToolRaw('test_company_search', { domain: 'stripe.com' });
|
|
897
|
+
* console.log(`Job: ${raw.job_id}, Credits: ${raw.credits}`);
|
|
898
|
+
* console.log(`Result:`, raw.result);
|
|
899
|
+
* ```
|
|
900
|
+
*/
|
|
901
|
+
executeToolRaw(toolId: string, input: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
902
|
+
queryCustomerDb(input: {
|
|
903
|
+
sql: string;
|
|
904
|
+
maxRows?: number;
|
|
905
|
+
}): Promise<CustomerDbQueryResult>;
|
|
906
|
+
/**
|
|
907
|
+
* Start a play run.
|
|
908
|
+
*
|
|
909
|
+
* Internal/advanced primitive. For normal callers, prefer the public
|
|
910
|
+
* entrypoints: the CLI, {@link Deepline.connect}, {@link submitPlay},
|
|
911
|
+
* or {@link runPlay}.
|
|
912
|
+
*
|
|
913
|
+
* Supported invocation surfaces intentionally share this same run contract:
|
|
914
|
+
* `deepline play run`, repo scripts such as `bun run deepline -- play run`,
|
|
915
|
+
* SDK context calls like `Deepline.connect().play(name).run()`, and direct
|
|
916
|
+
* `POST /api/v2/plays/run` calls all return a workflow/run id. The completed
|
|
917
|
+
* output is always retrievable from `getPlayStatus(runId).result` (or from
|
|
918
|
+
* `PlayJob.get()` for SDK context calls). Execution logs live under
|
|
919
|
+
* `progress.logs`; they are not part of the user output object.
|
|
920
|
+
*
|
|
921
|
+
* @param request - Play run configuration (name, code, input, etc.)
|
|
922
|
+
* @returns Workflow metadata including the `workflowId` for status polling
|
|
923
|
+
*
|
|
924
|
+
* @example
|
|
925
|
+
* ```typescript
|
|
926
|
+
* // Run a live play by name:
|
|
927
|
+
* const started = await client.startPlayRun({
|
|
928
|
+
* name: 'email-waterfall',
|
|
929
|
+
* input: { linkedin_url: 'https://linkedin.com/in/jdoe', domain: 'acme.com' },
|
|
930
|
+
* });
|
|
931
|
+
* console.log(`Workflow: ${started.workflowId}`);
|
|
932
|
+
*
|
|
933
|
+
* // Run an ad hoc artifact-backed play:
|
|
934
|
+
* const started2 = await client.startPlayRun({
|
|
935
|
+
* artifactStorageKey: 'plays/v1/orgs/acme/plays/my-play/artifacts/playgraph_abc123.json',
|
|
936
|
+
* });
|
|
937
|
+
* ```
|
|
50
938
|
*/
|
|
51
|
-
|
|
52
|
-
|
|
939
|
+
startPlayRun(request: StartPlayRunRequest): Promise<PlayRunStart>;
|
|
940
|
+
startPlayRunStream(request: StartPlayRunRequest, options?: {
|
|
941
|
+
signal?: AbortSignal;
|
|
942
|
+
}): AsyncGenerator<PlayLiveEvent>;
|
|
943
|
+
/**
|
|
944
|
+
* Register a bundled play artifact.
|
|
945
|
+
*
|
|
946
|
+
* Internal/advanced primitive used by packaging flows. Public callers should
|
|
947
|
+
* prefer the CLI, {@link submitPlay}, or {@link runPlay}.
|
|
948
|
+
*/
|
|
949
|
+
registerPlayArtifact(input: {
|
|
950
|
+
name: string;
|
|
951
|
+
sourceCode: string;
|
|
952
|
+
artifact: Record<string, unknown>;
|
|
953
|
+
compilerManifest?: PlayCompilerManifest;
|
|
954
|
+
publish?: boolean;
|
|
955
|
+
ownerType?: 'org' | 'deepline';
|
|
956
|
+
scope?: 'org' | 'system';
|
|
957
|
+
userId?: string;
|
|
958
|
+
}): Promise<{
|
|
959
|
+
success?: boolean;
|
|
960
|
+
name?: string;
|
|
961
|
+
artifactStorageKey: string;
|
|
962
|
+
artifactMetadata?: Record<string, unknown> | null;
|
|
963
|
+
staticPipeline?: unknown;
|
|
964
|
+
definitionId?: string | null;
|
|
965
|
+
revisionId?: string | null;
|
|
966
|
+
version?: number | null;
|
|
967
|
+
liveVersion?: number | null;
|
|
968
|
+
triggerMetadata?: unknown;
|
|
969
|
+
triggerBindings?: unknown;
|
|
53
970
|
}>;
|
|
54
|
-
|
|
971
|
+
registerPlayArtifacts(artifacts: Array<{
|
|
972
|
+
name: string;
|
|
973
|
+
sourceCode: string;
|
|
974
|
+
artifact: Record<string, unknown>;
|
|
975
|
+
compilerManifest?: PlayCompilerManifest;
|
|
976
|
+
publish?: boolean;
|
|
977
|
+
ownerType?: 'org' | 'deepline';
|
|
978
|
+
scope?: 'org' | 'system';
|
|
979
|
+
userId?: string;
|
|
980
|
+
}>): Promise<{
|
|
981
|
+
success: boolean;
|
|
982
|
+
artifacts: Array<{
|
|
983
|
+
success?: boolean;
|
|
984
|
+
name?: string;
|
|
985
|
+
artifactStorageKey: string;
|
|
986
|
+
artifactMetadata?: Record<string, unknown> | null;
|
|
987
|
+
staticPipeline?: unknown;
|
|
988
|
+
definitionId?: string | null;
|
|
989
|
+
revisionId?: string | null;
|
|
990
|
+
version?: number | null;
|
|
991
|
+
liveVersion?: number | null;
|
|
992
|
+
triggerMetadata?: unknown;
|
|
993
|
+
triggerBindings?: unknown;
|
|
994
|
+
}>;
|
|
995
|
+
}>;
|
|
996
|
+
compilePlayManifest(input: {
|
|
997
|
+
name: string;
|
|
998
|
+
sourceCode: string;
|
|
999
|
+
artifact: Record<string, unknown>;
|
|
1000
|
+
importedPlayDependencies?: PlayCompilerManifest[];
|
|
1001
|
+
}): Promise<PlayCompilerManifest>;
|
|
1002
|
+
/**
|
|
1003
|
+
* Check a bundled play artifact against the server's current play compiler.
|
|
1004
|
+
*
|
|
1005
|
+
* Unlike {@link registerPlayArtifact}, this does not store the artifact,
|
|
1006
|
+
* publish a revision, or start a run. It is the authoritative cloud validation
|
|
1007
|
+
* path used by `deepline play check`.
|
|
1008
|
+
*/
|
|
1009
|
+
checkPlayArtifact(input: {
|
|
1010
|
+
name?: string;
|
|
1011
|
+
sourceCode: string;
|
|
1012
|
+
artifact: Record<string, unknown>;
|
|
1013
|
+
}): Promise<PlayCheckResult>;
|
|
1014
|
+
startPlayRunFromBundle(input: {
|
|
1015
|
+
name: string;
|
|
1016
|
+
sourceCode: string;
|
|
1017
|
+
artifact: Record<string, unknown>;
|
|
1018
|
+
compilerManifest?: PlayCompilerManifest;
|
|
1019
|
+
input?: Record<string, unknown>;
|
|
1020
|
+
inputFile?: PlayStagedFileRef | null;
|
|
1021
|
+
packagedFiles?: PlayStagedFileRef[];
|
|
1022
|
+
force?: boolean;
|
|
1023
|
+
}): Promise<PlayRunStart>;
|
|
1024
|
+
/**
|
|
1025
|
+
* Register a bundled play artifact and start a run from the live revision.
|
|
1026
|
+
*
|
|
1027
|
+
* Convenience wrapper around {@link registerPlayArtifact} plus
|
|
1028
|
+
* {@link startPlayRun}. This is the canonical file-backed path used by wrappers.
|
|
1029
|
+
* The returned id can be passed to {@link getPlayStatus} to retrieve the same
|
|
1030
|
+
* durable `{ result }` object that the CLI prints after `--watch` completes.
|
|
1031
|
+
*
|
|
1032
|
+
* @param code - Source string fallback; the bundled artifact should be passed in `options.artifact`
|
|
1033
|
+
* @param csvPath - Path to input CSV file, or `null`
|
|
1034
|
+
* @param name - Play name (extracted from source if omitted)
|
|
1035
|
+
* @param options - Additional submission options
|
|
1036
|
+
* @returns Workflow metadata with `workflowId`
|
|
1037
|
+
*
|
|
1038
|
+
* @example
|
|
1039
|
+
* ```typescript
|
|
1040
|
+
* const started = await client.submitPlay(
|
|
1041
|
+
* originalSource,
|
|
1042
|
+
* './leads.csv',
|
|
1043
|
+
* 'bulk-enrich',
|
|
1044
|
+
* { artifact: bundledArtifact, input: { limit: 100 } },
|
|
1045
|
+
* );
|
|
1046
|
+
* ```
|
|
1047
|
+
*/
|
|
1048
|
+
submitPlay(code: string, csvPath: string | null, name?: string, options?: {
|
|
1049
|
+
sourceCode?: string;
|
|
1050
|
+
artifact?: Record<string, unknown>;
|
|
1051
|
+
compilerManifest?: PlayCompilerManifest;
|
|
1052
|
+
input?: Record<string, unknown>;
|
|
1053
|
+
inputFile?: PlayStagedFileRef | null;
|
|
1054
|
+
packagedFiles?: PlayStagedFileRef[];
|
|
1055
|
+
force?: boolean;
|
|
1056
|
+
}): Promise<PlayRunStart>;
|
|
1057
|
+
/**
|
|
1058
|
+
* Upload files to the staging area for use in play runs.
|
|
1059
|
+
*
|
|
1060
|
+
* Internal/advanced primitive used by packaging flows. Public callers should
|
|
1061
|
+
* prefer the CLI, {@link submitPlay}, or {@link runPlay}.
|
|
1062
|
+
*
|
|
1063
|
+
* Staged files are referenced by their returned {@link PlayStagedFileRef}
|
|
1064
|
+
* in subsequent {@link startPlayRun} calls via `inputFile` or `packagedFiles`.
|
|
1065
|
+
*
|
|
1066
|
+
* @param files - Array of files to stage (base64-encoded content)
|
|
1067
|
+
* @returns Array of staged file references
|
|
1068
|
+
*
|
|
1069
|
+
* @example
|
|
1070
|
+
* ```typescript
|
|
1071
|
+
* const staged = await client.stagePlayFiles([{
|
|
1072
|
+
* logicalPath: 'data/leads.csv',
|
|
1073
|
+
* contentBase64: Buffer.from(csvContent).toString('base64'),
|
|
1074
|
+
* contentHash: sha256(csvContent),
|
|
1075
|
+
* contentType: 'text/csv',
|
|
1076
|
+
* bytes: csvContent.length,
|
|
1077
|
+
* }]);
|
|
1078
|
+
* // Use staged[0] as inputFile in startPlayRun
|
|
1079
|
+
* ```
|
|
1080
|
+
*/
|
|
1081
|
+
stagePlayFiles(files: Array<{
|
|
1082
|
+
logicalPath: string;
|
|
1083
|
+
contentBase64: string;
|
|
1084
|
+
contentHash: string;
|
|
1085
|
+
contentType: string;
|
|
1086
|
+
bytes: number;
|
|
1087
|
+
}>): Promise<PlayStagedFileRef[]>;
|
|
1088
|
+
resolveStagedPlayFiles(files: Array<{
|
|
1089
|
+
logicalPath: string;
|
|
1090
|
+
contentHash: string;
|
|
1091
|
+
contentType: string;
|
|
1092
|
+
bytes: number;
|
|
1093
|
+
}>): Promise<{
|
|
1094
|
+
files: PlayStagedFileRef[];
|
|
1095
|
+
missing: Array<{
|
|
1096
|
+
logicalPath: string;
|
|
1097
|
+
contentHash: string;
|
|
1098
|
+
}>;
|
|
1099
|
+
}>;
|
|
1100
|
+
/**
|
|
1101
|
+
* Get the current status of a play execution.
|
|
1102
|
+
*
|
|
1103
|
+
* Internal/advanced primitive. Public callers should usually prefer
|
|
1104
|
+
* {@link runPlay}, {@link PlayJob.get}, or `deepline play run --watch`.
|
|
1105
|
+
*
|
|
1106
|
+
* Poll this method until `status` reaches a terminal state:
|
|
1107
|
+
* `'completed'`, `'failed'`, or `'cancelled'`.
|
|
1108
|
+
*
|
|
1109
|
+
* @param workflowId - Play-run id from {@link startPlayRun}
|
|
1110
|
+
* @returns Current status with progress logs and partial results
|
|
1111
|
+
*
|
|
1112
|
+
* @example
|
|
1113
|
+
* ```typescript
|
|
1114
|
+
* const status = await client.getPlayStatus('play-abc123');
|
|
1115
|
+
* console.log(`Status: ${status.status}`);
|
|
1116
|
+
* console.log(`Logs: ${status.progress?.logs.length ?? 0} lines`);
|
|
1117
|
+
* ```
|
|
1118
|
+
*/
|
|
55
1119
|
getPlayStatus(workflowId: string): Promise<PlayStatus>;
|
|
56
|
-
/**
|
|
1120
|
+
/**
|
|
1121
|
+
* Get the lightweight tail-polling status for a play execution.
|
|
1122
|
+
*
|
|
1123
|
+
* This is intentionally smaller than {@link getPlayStatus}: it returns the
|
|
1124
|
+
* fields needed for CLI log tailing while the run is in flight, without
|
|
1125
|
+
* forcing the API to rebuild final result views on every poll. Call
|
|
1126
|
+
* {@link getPlayStatus} once after a terminal state for the full result.
|
|
1127
|
+
*/
|
|
1128
|
+
getPlayTailStatus(workflowId: string, options?: {
|
|
1129
|
+
afterLogIndex?: number;
|
|
1130
|
+
waitMs?: number;
|
|
1131
|
+
terminalOnly?: boolean;
|
|
1132
|
+
}): Promise<PlayStatus>;
|
|
1133
|
+
/**
|
|
1134
|
+
* Stream semantic play-run events using the same SSE feed as the dashboard.
|
|
1135
|
+
*
|
|
1136
|
+
* Consumers should still keep a polling fallback: SSE is the fast live-update
|
|
1137
|
+
* transport, while the status endpoints remain the authoritative recovery path.
|
|
1138
|
+
*/
|
|
1139
|
+
streamPlayRunEvents(workflowId: string, options?: {
|
|
1140
|
+
signal?: AbortSignal;
|
|
1141
|
+
lastEventId?: string;
|
|
1142
|
+
mode?: 'cli' | 'ui';
|
|
1143
|
+
}): AsyncGenerator<PlayLiveEvent>;
|
|
1144
|
+
/**
|
|
1145
|
+
* Cancel a running play execution.
|
|
1146
|
+
*
|
|
1147
|
+
* Sends a stop request for the run.
|
|
1148
|
+
*
|
|
1149
|
+
* @param workflowId - Temporal workflow ID to cancel
|
|
1150
|
+
*
|
|
1151
|
+
* @example
|
|
1152
|
+
* ```typescript
|
|
1153
|
+
* await client.cancelPlay('play-abc123');
|
|
1154
|
+
* ```
|
|
1155
|
+
*/
|
|
57
1156
|
cancelPlay(workflowId: string): Promise<void>;
|
|
58
1157
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
1158
|
+
* Stop a running play execution, including open HITL waits.
|
|
1159
|
+
*
|
|
1160
|
+
* @param workflowId - Temporal workflow ID to stop
|
|
1161
|
+
* @param options.reason - Optional audit/debug reason
|
|
1162
|
+
*/
|
|
1163
|
+
stopPlay(workflowId: string, options?: {
|
|
1164
|
+
reason?: string;
|
|
1165
|
+
}): Promise<StopPlayRunResult>;
|
|
1166
|
+
/**
|
|
1167
|
+
* List recent runs for a named play.
|
|
1168
|
+
*
|
|
1169
|
+
* Returns runs sorted by start time (newest first), including workflow IDs,
|
|
1170
|
+
* status, timestamps, and metadata.
|
|
1171
|
+
*
|
|
1172
|
+
* @param playName - The play name to query
|
|
1173
|
+
* @returns Array of run summaries (empty array if no runs exist)
|
|
1174
|
+
*
|
|
1175
|
+
* @example
|
|
1176
|
+
* ```typescript
|
|
1177
|
+
* const runs = await client.listPlayRuns('email-waterfall');
|
|
1178
|
+
* for (const run of runs) {
|
|
1179
|
+
* console.log(`${run.workflowId}: ${run.status} (${run.executionTime})`);
|
|
1180
|
+
* }
|
|
1181
|
+
* ```
|
|
1182
|
+
*/
|
|
1183
|
+
listPlayRuns(playName: string): Promise<PlayRunListItem[]>;
|
|
1184
|
+
listPlays(): Promise<PlayListItem[]>;
|
|
1185
|
+
searchPlays(options: {
|
|
1186
|
+
query: string;
|
|
1187
|
+
origin?: 'prebuilt' | 'owned';
|
|
1188
|
+
compact?: boolean;
|
|
1189
|
+
}): Promise<PlayDescription[]>;
|
|
1190
|
+
/**
|
|
1191
|
+
* Get the full definition and state of a named play.
|
|
1192
|
+
*
|
|
1193
|
+
* Returns the play's revision state (draft, live), recent runs,
|
|
1194
|
+
* sheet processing summary, and database URL.
|
|
1195
|
+
*
|
|
1196
|
+
* @param name - Play name
|
|
1197
|
+
* @returns Complete play detail
|
|
1198
|
+
*
|
|
1199
|
+
* @example
|
|
1200
|
+
* ```typescript
|
|
1201
|
+
* const detail = await client.getPlay('email-waterfall');
|
|
1202
|
+
* console.log(`Live: v${detail.play.currentPublishedVersion}`);
|
|
1203
|
+
* console.log(`Draft dirty: ${detail.play.isDraftDirty}`);
|
|
1204
|
+
* console.log(`Total runs: ${detail.play.runCount}`);
|
|
1205
|
+
* ```
|
|
1206
|
+
*/
|
|
1207
|
+
getPlay(name: string): Promise<PlayDetail>;
|
|
1208
|
+
describePlay(name: string, options?: {
|
|
1209
|
+
compact?: boolean;
|
|
1210
|
+
}): Promise<PlayDescription>;
|
|
1211
|
+
/**
|
|
1212
|
+
* Clear run history and durable sheet/result data for a play without deleting
|
|
1213
|
+
* the play definition or revisions.
|
|
1214
|
+
*/
|
|
1215
|
+
clearPlayHistory(name: string, request?: ClearPlayHistoryRequest): Promise<ClearPlayHistoryResult>;
|
|
1216
|
+
/**
|
|
1217
|
+
* List saved versions for a named play.
|
|
1218
|
+
*
|
|
1219
|
+
* Returns immutable revision snapshots newest-first, including the revision
|
|
1220
|
+
* id needed for exact-version runs and live-version switching.
|
|
1221
|
+
*
|
|
1222
|
+
* @param name - Play name
|
|
1223
|
+
* @returns Version list (newest first)
|
|
1224
|
+
*/
|
|
1225
|
+
listPlayVersions(name: string): Promise<PlayRevisionSummary[]>;
|
|
1226
|
+
/**
|
|
1227
|
+
* Make a play revision live.
|
|
1228
|
+
*
|
|
1229
|
+
* When `revisionId` is omitted, the current working revision becomes live.
|
|
1230
|
+
* The live version is what executes when the play is run by name without
|
|
1231
|
+
* specifying an explicit revision.
|
|
1232
|
+
*
|
|
1233
|
+
* @param name - Play name
|
|
1234
|
+
* @param request - Optional explicit revision to make live
|
|
1235
|
+
* @returns Result with the new live version number
|
|
1236
|
+
*
|
|
1237
|
+
* @example
|
|
1238
|
+
* ```typescript
|
|
1239
|
+
* const result = await client.publishPlayVersion('email-waterfall');
|
|
1240
|
+
* if (result.success) {
|
|
1241
|
+
* console.log(`Live v${result.liveVersion}`);
|
|
1242
|
+
* }
|
|
1243
|
+
* ```
|
|
1244
|
+
*/
|
|
1245
|
+
publishPlayVersion(name: string, request?: PublishPlayVersionRequest): Promise<PublishPlayVersionResult>;
|
|
1246
|
+
/**
|
|
1247
|
+
* Delete an org-owned play definition, including its revisions, trigger
|
|
1248
|
+
* bindings, and local run records. Deepline prebuilt plays are read-only.
|
|
1249
|
+
*/
|
|
1250
|
+
deletePlay(name: string): Promise<DeletePlayResult>;
|
|
1251
|
+
/**
|
|
1252
|
+
* Run a play end-to-end: submit, poll until terminal, return result.
|
|
1253
|
+
*
|
|
1254
|
+
* This is the highest-level play execution method. It submits the play,
|
|
1255
|
+
* polls for status updates, and returns a structured result with logs
|
|
1256
|
+
* and timing. Supports cancellation via `AbortSignal`.
|
|
1257
|
+
*
|
|
1258
|
+
* @param code - Source string fallback; pass the bundled artifact in `options.artifact`
|
|
1259
|
+
* @param csvPath - Input CSV path, or `null`
|
|
1260
|
+
* @param name - Play name
|
|
1261
|
+
* @param options - Execution options
|
|
1262
|
+
* @returns Final execution result with success/failure, output, logs, and duration
|
|
1263
|
+
*
|
|
1264
|
+
* @example
|
|
1265
|
+
* ```typescript
|
|
1266
|
+
* const result = await client.runPlay(bundledCode, null, 'my-play', {
|
|
1267
|
+
* input: { domain: 'stripe.com' },
|
|
1268
|
+
* onProgress: (status) => {
|
|
1269
|
+
* const logs = status.progress?.logs ?? [];
|
|
1270
|
+
* console.log(`[${status.status}] ${logs.length} log lines`);
|
|
1271
|
+
* },
|
|
1272
|
+
* pollIntervalMs: 1000,
|
|
1273
|
+
* });
|
|
1274
|
+
*
|
|
1275
|
+
* if (result.success) {
|
|
1276
|
+
* console.log('Output:', result.result);
|
|
1277
|
+
* } else {
|
|
1278
|
+
* console.error(`Failed after ${result.durationMs}ms:`, result.error);
|
|
1279
|
+
* }
|
|
1280
|
+
* ```
|
|
1281
|
+
*
|
|
1282
|
+
* @example Cancellation
|
|
1283
|
+
* ```typescript
|
|
1284
|
+
* const controller = new AbortController();
|
|
1285
|
+
* setTimeout(() => controller.abort(), 30_000); // 30s timeout
|
|
1286
|
+
*
|
|
1287
|
+
* const result = await client.runPlay(code, null, 'slow-play', {
|
|
1288
|
+
* signal: controller.signal,
|
|
1289
|
+
* });
|
|
1290
|
+
* // result.success === false, result.error === 'Cancelled by user'
|
|
1291
|
+
* ```
|
|
61
1292
|
*/
|
|
62
|
-
runPlay(code: string, csvPath: string, name?: string, options?: {
|
|
1293
|
+
runPlay(code: string, csvPath: string | null, name?: string, options?: {
|
|
1294
|
+
/** Called on each poll iteration with the current status. */
|
|
63
1295
|
onProgress?: (status: PlayStatus) => void;
|
|
1296
|
+
/** Milliseconds between status polls. Default: `500`. */
|
|
64
1297
|
pollIntervalMs?: number;
|
|
1298
|
+
/** Abort signal — triggers cancellation and immediate return. */
|
|
65
1299
|
signal?: AbortSignal;
|
|
1300
|
+
/** Runtime input for the play function. */
|
|
1301
|
+
input?: Record<string, unknown>;
|
|
1302
|
+
sourceCode?: string;
|
|
1303
|
+
artifact?: Record<string, unknown>;
|
|
1304
|
+
compilerManifest?: PlayCompilerManifest;
|
|
1305
|
+
inputFile?: PlayStagedFileRef | null;
|
|
1306
|
+
packagedFiles?: PlayStagedFileRef[];
|
|
1307
|
+
/** Force-supersede any active runs for this play before starting. */
|
|
1308
|
+
force?: boolean;
|
|
66
1309
|
}): Promise<PlayRunResult>;
|
|
67
|
-
/**
|
|
1310
|
+
/**
|
|
1311
|
+
* Check API connectivity and server health.
|
|
1312
|
+
*
|
|
1313
|
+
* @returns Health status with API version
|
|
1314
|
+
*
|
|
1315
|
+
* @example
|
|
1316
|
+
* ```typescript
|
|
1317
|
+
* const health = await client.health();
|
|
1318
|
+
* console.log(`API: ${health.status} (${health.version})`);
|
|
1319
|
+
* // { status: "ok", version: "v2" }
|
|
1320
|
+
* ```
|
|
1321
|
+
*/
|
|
68
1322
|
health(): Promise<{
|
|
69
1323
|
status: string;
|
|
70
1324
|
version?: string;
|
|
71
1325
|
}>;
|
|
72
1326
|
}
|
|
73
|
-
interface PlayStatus {
|
|
74
|
-
workflowId: string;
|
|
75
|
-
temporalStatus: string;
|
|
76
|
-
progress?: {
|
|
77
|
-
status: string;
|
|
78
|
-
totalRows?: number;
|
|
79
|
-
logs: string[];
|
|
80
|
-
error?: string;
|
|
81
|
-
};
|
|
82
|
-
result?: unknown;
|
|
83
|
-
}
|
|
84
1327
|
|
|
1328
|
+
declare const SDK_VERSION = "0.1.1";
|
|
1329
|
+
declare const SDK_API_CONTRACT = "2026-04-plays-v1";
|
|
1330
|
+
|
|
1331
|
+
/**
|
|
1332
|
+
* Base error class for all Deepline SDK errors.
|
|
1333
|
+
*
|
|
1334
|
+
* Every error thrown by the SDK extends this class, so you can catch all
|
|
1335
|
+
* Deepline-specific errors with a single `catch (e) { if (e instanceof DeeplineError) }`.
|
|
1336
|
+
*
|
|
1337
|
+
* @example
|
|
1338
|
+
* ```typescript
|
|
1339
|
+
* import { DeeplineClient, DeeplineError, AuthError } from 'deepline';
|
|
1340
|
+
*
|
|
1341
|
+
* const client = new DeeplineClient();
|
|
1342
|
+
* try {
|
|
1343
|
+
* await client.executeTool('apollo_people_search', { query: 'cto' });
|
|
1344
|
+
* } catch (err) {
|
|
1345
|
+
* if (err instanceof AuthError) {
|
|
1346
|
+
* console.error('Bad API key — run: deepline auth register');
|
|
1347
|
+
* } else if (err instanceof DeeplineError) {
|
|
1348
|
+
* console.error(`API error ${err.statusCode}: ${err.message}`);
|
|
1349
|
+
* }
|
|
1350
|
+
* }
|
|
1351
|
+
* ```
|
|
1352
|
+
*/
|
|
85
1353
|
declare class DeeplineError extends Error {
|
|
1354
|
+
/** HTTP status code from the API response, if applicable. */
|
|
86
1355
|
statusCode?: number | undefined;
|
|
1356
|
+
/** Machine-readable error code (e.g. `'AUTH_ERROR'`, `'RATE_LIMIT'`, `'CONFIG_ERROR'`). */
|
|
87
1357
|
code?: string | undefined;
|
|
1358
|
+
/** Additional context from the API response body. */
|
|
88
1359
|
details?: Record<string, unknown> | undefined;
|
|
89
|
-
constructor(message: string,
|
|
1360
|
+
constructor(message: string,
|
|
1361
|
+
/** HTTP status code from the API response, if applicable. */
|
|
1362
|
+
statusCode?: number | undefined,
|
|
1363
|
+
/** Machine-readable error code (e.g. `'AUTH_ERROR'`, `'RATE_LIMIT'`, `'CONFIG_ERROR'`). */
|
|
1364
|
+
code?: string | undefined,
|
|
1365
|
+
/** Additional context from the API response body. */
|
|
1366
|
+
details?: Record<string, unknown> | undefined);
|
|
90
1367
|
}
|
|
1368
|
+
/**
|
|
1369
|
+
* Thrown when the API rejects the request due to an invalid or missing API key.
|
|
1370
|
+
*
|
|
1371
|
+
* This maps to HTTP 401/403 responses. The SDK never retries auth errors —
|
|
1372
|
+
* they fail immediately.
|
|
1373
|
+
*
|
|
1374
|
+
* Fix: run `deepline auth register` to obtain a valid key, or pass one via
|
|
1375
|
+
* the `apiKey` option or `DEEPLINE_API_KEY` environment variable.
|
|
1376
|
+
*
|
|
1377
|
+
* @example
|
|
1378
|
+
* ```typescript
|
|
1379
|
+
* import { AuthError } from 'deepline';
|
|
1380
|
+
*
|
|
1381
|
+
* try {
|
|
1382
|
+
* await client.listTools();
|
|
1383
|
+
* } catch (err) {
|
|
1384
|
+
* if (err instanceof AuthError) {
|
|
1385
|
+
* // Redirect user to auth flow
|
|
1386
|
+
* }
|
|
1387
|
+
* }
|
|
1388
|
+
* ```
|
|
1389
|
+
*/
|
|
91
1390
|
declare class AuthError extends DeeplineError {
|
|
92
1391
|
constructor(message?: string);
|
|
93
1392
|
}
|
|
1393
|
+
/**
|
|
1394
|
+
* Thrown when the API returns HTTP 429 (Too Many Requests).
|
|
1395
|
+
*
|
|
1396
|
+
* The SDK retries rate-limited requests automatically up to `maxRetries` times
|
|
1397
|
+
* with exponential backoff. This error is only thrown when all retries are exhausted.
|
|
1398
|
+
*
|
|
1399
|
+
* Use {@link RateLimitError.retryAfterMs} to implement your own backoff if needed.
|
|
1400
|
+
*
|
|
1401
|
+
* @example
|
|
1402
|
+
* ```typescript
|
|
1403
|
+
* import { RateLimitError } from 'deepline';
|
|
1404
|
+
*
|
|
1405
|
+
* try {
|
|
1406
|
+
* await client.executeTool('apollo_people_search', { query: 'cto' });
|
|
1407
|
+
* } catch (err) {
|
|
1408
|
+
* if (err instanceof RateLimitError) {
|
|
1409
|
+
* console.log(`Retry after ${err.retryAfterMs}ms`);
|
|
1410
|
+
* await sleep(err.retryAfterMs);
|
|
1411
|
+
* // retry...
|
|
1412
|
+
* }
|
|
1413
|
+
* }
|
|
1414
|
+
* ```
|
|
1415
|
+
*/
|
|
94
1416
|
declare class RateLimitError extends DeeplineError {
|
|
1417
|
+
/** Milliseconds to wait before retrying, from the `Retry-After` response header. Defaults to 5000. */
|
|
95
1418
|
retryAfterMs: number;
|
|
96
1419
|
constructor(retryAfterMs?: number, message?: string);
|
|
97
1420
|
}
|
|
1421
|
+
/**
|
|
1422
|
+
* Thrown when the SDK cannot resolve a valid configuration.
|
|
1423
|
+
*
|
|
1424
|
+
* Most commonly: no API key found in any of the resolution sources
|
|
1425
|
+
* (explicit option, environment variable, CLI env files).
|
|
1426
|
+
*
|
|
1427
|
+
* @example
|
|
1428
|
+
* ```typescript
|
|
1429
|
+
* import { ConfigError } from 'deepline';
|
|
1430
|
+
*
|
|
1431
|
+
* try {
|
|
1432
|
+
* const client = new DeeplineClient();
|
|
1433
|
+
* } catch (err) {
|
|
1434
|
+
* if (err instanceof ConfigError) {
|
|
1435
|
+
* console.error('Run: deepline auth register');
|
|
1436
|
+
* }
|
|
1437
|
+
* }
|
|
1438
|
+
* ```
|
|
1439
|
+
*/
|
|
98
1440
|
declare class ConfigError extends DeeplineError {
|
|
99
1441
|
constructor(message: string);
|
|
100
1442
|
}
|
|
101
1443
|
|
|
1444
|
+
/** Production API base URL. */
|
|
102
1445
|
declare const PROD_URL = "https://code.deepline.com";
|
|
1446
|
+
/**
|
|
1447
|
+
* Resolve SDK configuration from all available sources.
|
|
1448
|
+
*
|
|
1449
|
+
* Merges explicit options, environment variables, and CLI-managed config files
|
|
1450
|
+
* into a fully validated {@link ResolvedConfig}. See the module-level docs for
|
|
1451
|
+
* the complete resolution order.
|
|
1452
|
+
*
|
|
1453
|
+
* @param options - Optional overrides (highest priority)
|
|
1454
|
+
* @returns Fully resolved configuration with all fields populated
|
|
1455
|
+
* @throws {@link ConfigError} if no API key can be found from any source
|
|
1456
|
+
*
|
|
1457
|
+
* @example
|
|
1458
|
+
* ```typescript
|
|
1459
|
+
* import { resolveConfig } from 'deepline';
|
|
1460
|
+
*
|
|
1461
|
+
* // Auto-resolve everything:
|
|
1462
|
+
* const config = resolveConfig();
|
|
1463
|
+
* console.log(config.baseUrl); // "http://localhost:3000" or "https://code.deepline.com"
|
|
1464
|
+
*
|
|
1465
|
+
* // Override specific values:
|
|
1466
|
+
* const config2 = resolveConfig({ baseUrl: 'http://localhost:4000', timeout: 10_000 });
|
|
1467
|
+
* ```
|
|
1468
|
+
*/
|
|
103
1469
|
declare function resolveConfig(options?: DeeplineClientOptions): ResolvedConfig;
|
|
104
1470
|
|
|
105
|
-
|
|
1471
|
+
/**
|
|
1472
|
+
* Result of converting a tool response to a list of records.
|
|
1473
|
+
*
|
|
1474
|
+
* @example
|
|
1475
|
+
* ```typescript
|
|
1476
|
+
* const conversion = tryConvertToList(toolResponse, {
|
|
1477
|
+
* listExtractorPaths: ['people', 'result.data'],
|
|
1478
|
+
* });
|
|
1479
|
+
* if (conversion) {
|
|
1480
|
+
* console.log(`Found ${conversion.rows.length} rows via ${conversion.strategy}`);
|
|
1481
|
+
* console.log(`Source path: ${conversion.sourcePath}`);
|
|
1482
|
+
* }
|
|
1483
|
+
* ```
|
|
1484
|
+
*/
|
|
1485
|
+
type ListConversionResult = {
|
|
1486
|
+
/** Normalized array of record objects. Scalars are wrapped as `{ value: <scalar> }`. */
|
|
1487
|
+
rows: Array<Record<string, unknown>>;
|
|
1488
|
+
/**
|
|
1489
|
+
* How the list was found:
|
|
1490
|
+
* - `'configured_paths'` — matched one of the `listExtractorPaths`
|
|
1491
|
+
* - `'auto_detected'` — found via recursive DFS (longest array wins)
|
|
1492
|
+
*/
|
|
1493
|
+
strategy: 'configured_paths' | 'auto_detected';
|
|
1494
|
+
/** Dotted path to where the list was found (e.g. `"result.data"`, `"people"`). */
|
|
1495
|
+
sourcePath: string | null;
|
|
1496
|
+
};
|
|
1497
|
+
type Scalar = string | number | boolean | null;
|
|
1498
|
+
/** Ergonomic wrapper returned by high-level SDK tool execution. */
|
|
1499
|
+
type ToolCallResult = {
|
|
1500
|
+
/** Raw tool response. Use this when a provider-specific shape matters. */
|
|
1501
|
+
readonly value: unknown;
|
|
1502
|
+
/** Best-effort email extraction from common response shapes. */
|
|
1503
|
+
getEmail(): string | null;
|
|
1504
|
+
/** Best-effort phone extraction from common response shapes. */
|
|
1505
|
+
getPhone(): string | null;
|
|
1506
|
+
/** Best-effort list extraction. Returns rows only; use `tryConvertToList` for metadata. */
|
|
1507
|
+
tryList(options?: {
|
|
1508
|
+
listExtractorPaths?: string[];
|
|
1509
|
+
}): Array<Record<string, unknown>> | null;
|
|
1510
|
+
};
|
|
1511
|
+
/** Wrap a raw tool response with the high-level SDK result API. */
|
|
1512
|
+
declare function createToolCallResult(value: unknown): ToolCallResult;
|
|
1513
|
+
/**
|
|
1514
|
+
* Extract a list of records from a tool response.
|
|
1515
|
+
*
|
|
1516
|
+
* Handles the common problem of tools returning data in varied shapes.
|
|
1517
|
+
* First tries configured `listExtractorPaths` (from tool metadata), then
|
|
1518
|
+
* falls back to automatic detection via recursive DFS.
|
|
1519
|
+
*
|
|
1520
|
+
* ## Extraction strategy
|
|
1521
|
+
*
|
|
1522
|
+
* 1. **Configured paths** — If `listExtractorPaths` is provided, each path is
|
|
1523
|
+
* tried against multiple candidate roots (raw payload, `.result`, `.result.data`).
|
|
1524
|
+
* First match wins.
|
|
1525
|
+
*
|
|
1526
|
+
* 2. **Auto-detection** — If no configured path matches, recursively searches
|
|
1527
|
+
* the response for the largest array of objects (up to depth 5).
|
|
1528
|
+
*
|
|
1529
|
+
* @param payload - Raw tool response
|
|
1530
|
+
* @param options - Optional extraction configuration
|
|
1531
|
+
* @returns Extracted list with metadata, or `null` if no list found
|
|
1532
|
+
*
|
|
1533
|
+
* @example Using configured paths (from tool metadata)
|
|
1534
|
+
* ```typescript
|
|
1535
|
+
* const meta = await client.getTool('apollo_people_search');
|
|
1536
|
+
* const result = await client.executeTool('apollo_people_search', { query: 'cto' });
|
|
1537
|
+
*
|
|
1538
|
+
* const list = tryConvertToList(result, {
|
|
1539
|
+
* listExtractorPaths: meta.listExtractorPaths,
|
|
1540
|
+
* });
|
|
1541
|
+
* if (list) {
|
|
1542
|
+
* console.log(`${list.rows.length} people found via ${list.strategy}`);
|
|
1543
|
+
* // Write to CSV
|
|
1544
|
+
* const csv = writeCsvOutputFile(list.rows, 'apollo-people');
|
|
1545
|
+
* console.log(`Saved to ${csv.path}`);
|
|
1546
|
+
* }
|
|
1547
|
+
* ```
|
|
1548
|
+
*
|
|
1549
|
+
* @example Auto-detection (no configured paths)
|
|
1550
|
+
* ```typescript
|
|
1551
|
+
* const result = await client.executeTool('some_tool', { query: 'test' });
|
|
1552
|
+
* const list = tryConvertToList(result);
|
|
1553
|
+
* // Finds the largest array of objects anywhere in the response
|
|
1554
|
+
* ```
|
|
1555
|
+
*/
|
|
1556
|
+
declare function tryConvertToList(payload: unknown, options?: {
|
|
1557
|
+
listExtractorPaths?: string[];
|
|
1558
|
+
}): ListConversionResult | null;
|
|
1559
|
+
/**
|
|
1560
|
+
* Write a JSON payload to a timestamped file.
|
|
1561
|
+
*
|
|
1562
|
+
* Output location: `~/.local/share/deepline/data/{stem}_{timestamp}.json`
|
|
1563
|
+
*
|
|
1564
|
+
* @param payload - Any JSON-serializable value
|
|
1565
|
+
* @param stem - Filename prefix (e.g. tool ID or play name)
|
|
1566
|
+
* @returns Absolute path to the written file
|
|
1567
|
+
*
|
|
1568
|
+
* @example
|
|
1569
|
+
* ```typescript
|
|
1570
|
+
* const result = await client.executeTool('test_company_search', { domain: 'stripe.com' });
|
|
1571
|
+
* const path = writeJsonOutputFile(result, 'test_company_search');
|
|
1572
|
+
* console.log(`Saved to ${path}`);
|
|
1573
|
+
* // ~/.local/share/deepline/data/test_company_search_1713456789000.json
|
|
1574
|
+
* ```
|
|
1575
|
+
*/
|
|
1576
|
+
declare function writeJsonOutputFile(payload: unknown, stem: string): string;
|
|
1577
|
+
/**
|
|
1578
|
+
* Write an array of records to a CSV file.
|
|
1579
|
+
*
|
|
1580
|
+
* Columns are ordered by first appearance across all rows. Cells containing
|
|
1581
|
+
* commas, quotes, or newlines are properly escaped. Objects and arrays are
|
|
1582
|
+
* JSON-serialized.
|
|
1583
|
+
*
|
|
1584
|
+
* Output location: `~/.local/share/deepline/data/{stem}_{timestamp}.csv`
|
|
1585
|
+
*
|
|
1586
|
+
* @param rows - Array of record objects
|
|
1587
|
+
* @param stem - Filename prefix
|
|
1588
|
+
* @returns File metadata including path, row count, columns, and a 5×5 preview
|
|
1589
|
+
*
|
|
1590
|
+
* @example
|
|
1591
|
+
* ```typescript
|
|
1592
|
+
* const list = tryConvertToList(toolResponse);
|
|
1593
|
+
* if (list) {
|
|
1594
|
+
* const csv = writeCsvOutputFile(list.rows, 'search-results');
|
|
1595
|
+
* console.log(`Wrote ${csv.rowCount} rows, ${csv.columns.length} columns`);
|
|
1596
|
+
* console.log(`File: ${csv.path}`);
|
|
1597
|
+
* console.log(`Preview:\n${csv.preview}`);
|
|
1598
|
+
* }
|
|
1599
|
+
* ```
|
|
1600
|
+
*/
|
|
1601
|
+
declare function writeCsvOutputFile(rows: Array<Record<string, unknown>>, stem: string): {
|
|
1602
|
+
path: string;
|
|
1603
|
+
rowCount: number;
|
|
1604
|
+
columns: string[];
|
|
1605
|
+
preview: string;
|
|
1606
|
+
};
|
|
1607
|
+
/**
|
|
1608
|
+
* Extract scalar (non-nested) fields from a tool response for summary display.
|
|
1609
|
+
*
|
|
1610
|
+
* Searches through candidate roots (raw → `.result` → `.result.data`) and
|
|
1611
|
+
* returns the first set of scalar fields found. Useful for displaying a
|
|
1612
|
+
* quick summary of single-record responses.
|
|
1613
|
+
*
|
|
1614
|
+
* @param payload - Raw tool response
|
|
1615
|
+
* @returns Object containing only scalar fields (string, number, boolean, null)
|
|
1616
|
+
*
|
|
1617
|
+
* @example
|
|
1618
|
+
* ```typescript
|
|
1619
|
+
* const result = await client.executeTool('test_company_search', { domain: 'stripe.com' });
|
|
1620
|
+
* const summary = extractSummaryFields(result);
|
|
1621
|
+
* // { name: "Stripe", industry: "Financial Services", employeeCount: 8000 }
|
|
1622
|
+
* // (nested objects and arrays are excluded)
|
|
1623
|
+
* ```
|
|
1624
|
+
*/
|
|
1625
|
+
declare function extractSummaryFields(payload: unknown): Record<string, Scalar>;
|
|
1626
|
+
|
|
1627
|
+
interface PlayR2FileRef {
|
|
1628
|
+
storageKind: 'r2';
|
|
1629
|
+
storageKey: string;
|
|
1630
|
+
logicalPath: string;
|
|
1631
|
+
fileName: string;
|
|
1632
|
+
contentHash: string;
|
|
1633
|
+
contentType: string;
|
|
1634
|
+
bytes: number;
|
|
1635
|
+
}
|
|
1636
|
+
type PlayExecutionFileRef = PlayR2FileRef;
|
|
1637
|
+
|
|
1638
|
+
declare const PLAY_DATASET_BRAND: unique symbol;
|
|
1639
|
+
type PlayDatasetKind = 'csv' | 'map';
|
|
1640
|
+
type PlayDatasetBacking = {
|
|
1641
|
+
storage: 'neon_sheet';
|
|
1642
|
+
sheet: {
|
|
1643
|
+
playName: string;
|
|
1644
|
+
tableNamespace: string;
|
|
1645
|
+
};
|
|
1646
|
+
} | {
|
|
1647
|
+
storage: 'r2_file';
|
|
1648
|
+
file: PlayExecutionFileRef;
|
|
1649
|
+
};
|
|
1650
|
+
type PlayDatasetInput<T> = ReadonlyArray<T> | Iterable<T> | AsyncIterable<T> | PlayDataset<T>;
|
|
1651
|
+
interface PlayDataset<T> extends AsyncIterable<T> {
|
|
1652
|
+
readonly [PLAY_DATASET_BRAND]: true;
|
|
1653
|
+
readonly datasetKind: PlayDatasetKind;
|
|
1654
|
+
readonly datasetId: string;
|
|
1655
|
+
readonly backing?: PlayDatasetBacking;
|
|
1656
|
+
readonly sourceLabel?: string | null;
|
|
1657
|
+
readonly tableNamespace?: string | null;
|
|
1658
|
+
count(): Promise<number>;
|
|
1659
|
+
peek(limit?: number): Promise<T[]>;
|
|
1660
|
+
/**
|
|
1661
|
+
* Explicit escape hatch for bounded result sets.
|
|
1662
|
+
* Large datasets should flow by handle through Neon-backed storage, not
|
|
1663
|
+
* through worker memory as giant arrays.
|
|
1664
|
+
*/
|
|
1665
|
+
materialize(limit?: number): Promise<T[]>;
|
|
1666
|
+
toJSON(): {
|
|
1667
|
+
kind: 'dataset';
|
|
1668
|
+
datasetKind: PlayDatasetKind;
|
|
1669
|
+
datasetId: string;
|
|
1670
|
+
count: number;
|
|
1671
|
+
backing?: PlayDatasetBacking;
|
|
1672
|
+
sourceLabel?: string | null;
|
|
1673
|
+
tableNamespace?: string | null;
|
|
1674
|
+
columns?: string[];
|
|
1675
|
+
preview: T[];
|
|
1676
|
+
};
|
|
1677
|
+
}
|
|
1678
|
+
|
|
1679
|
+
/**
|
|
1680
|
+
* Optional trigger bindings for a play.
|
|
1681
|
+
*
|
|
1682
|
+
* Plays can be triggered by webhooks (with HMAC signature verification)
|
|
1683
|
+
* or cron schedules. Bindings are declared as the third argument to
|
|
1684
|
+
* {@link definePlay}.
|
|
1685
|
+
*
|
|
1686
|
+
* @example Webhook with HMAC verification
|
|
1687
|
+
* ```typescript
|
|
1688
|
+
* definePlay('webhook-handler', handler, {
|
|
1689
|
+
* webhook: {
|
|
1690
|
+
* hmac: {
|
|
1691
|
+
* algorithm: 'sha256',
|
|
1692
|
+
* header: 'X-Hub-Signature-256',
|
|
1693
|
+
* secretEnv: 'WEBHOOK_SECRET',
|
|
1694
|
+
* },
|
|
1695
|
+
* },
|
|
1696
|
+
* });
|
|
1697
|
+
* ```
|
|
1698
|
+
*
|
|
1699
|
+
* @example Cron schedule
|
|
1700
|
+
* ```typescript
|
|
1701
|
+
* definePlay('nightly-sync', handler, {
|
|
1702
|
+
* cron: { schedule: '0 2 * * *', timezone: 'UTC' },
|
|
1703
|
+
* });
|
|
1704
|
+
* ```
|
|
1705
|
+
*/
|
|
1706
|
+
type PlayBindings = {
|
|
1707
|
+
/** Optional per-run billing controls enforced by the runtime. */
|
|
1708
|
+
billing?: {
|
|
1709
|
+
/** Stop the run before a billed action would push total run credits above this cap. */
|
|
1710
|
+
maxCreditsPerRun?: number;
|
|
1711
|
+
};
|
|
1712
|
+
/** Webhook trigger with optional HMAC signature verification. */
|
|
1713
|
+
webhook?: {
|
|
1714
|
+
hmac?: {
|
|
1715
|
+
/** Hash algorithm. Currently only `'sha256'` is supported. */
|
|
1716
|
+
algorithm?: 'sha256';
|
|
1717
|
+
/** HTTP header containing the signature (e.g. `'X-Hub-Signature-256'`). */
|
|
1718
|
+
header?: string;
|
|
1719
|
+
/** Environment variable name holding the HMAC secret. */
|
|
1720
|
+
secretEnv: string;
|
|
1721
|
+
};
|
|
1722
|
+
};
|
|
1723
|
+
/** Cron schedule trigger. */
|
|
1724
|
+
cron?: {
|
|
1725
|
+
/** Cron expression (e.g. `'0 9 * * *'` for daily at 9am). */
|
|
1726
|
+
schedule: string;
|
|
1727
|
+
/** IANA timezone (e.g. `'America/New_York'`). Defaults to UTC. */
|
|
1728
|
+
timezone?: string;
|
|
1729
|
+
};
|
|
1730
|
+
};
|
|
1731
|
+
type LoosePlayObject = {
|
|
1732
|
+
[key: string]: LoosePlayObject;
|
|
1733
|
+
};
|
|
1734
|
+
type ToolExecutionRequest = {
|
|
1735
|
+
id: string;
|
|
1736
|
+
tool: string;
|
|
1737
|
+
input: Record<string, unknown>;
|
|
1738
|
+
description?: string;
|
|
1739
|
+
};
|
|
1740
|
+
type SdkToolExecutionRequest = {
|
|
1741
|
+
tool: string;
|
|
1742
|
+
input: Record<string, unknown>;
|
|
1743
|
+
};
|
|
1744
|
+
type ToolExecuteResult<TResult = unknown> = {
|
|
1745
|
+
status: string;
|
|
1746
|
+
result: TResult;
|
|
1747
|
+
_metadata: {
|
|
1748
|
+
toolId: string;
|
|
1749
|
+
execution: {
|
|
1750
|
+
idempotent: true;
|
|
1751
|
+
cached: boolean;
|
|
1752
|
+
source: 'live' | 'checkpoint' | 'cache';
|
|
1753
|
+
cacheKey?: string;
|
|
1754
|
+
};
|
|
1755
|
+
targets: Record<string, {
|
|
1756
|
+
value: unknown;
|
|
1757
|
+
path: string;
|
|
1758
|
+
}>;
|
|
1759
|
+
lists: Record<string, {
|
|
1760
|
+
path: string;
|
|
1761
|
+
count: number | null;
|
|
1762
|
+
keys: Record<string, string>;
|
|
1763
|
+
}>;
|
|
1764
|
+
};
|
|
1765
|
+
get<T = unknown>(target: string): T | null;
|
|
1766
|
+
getEmail(): string | null;
|
|
1767
|
+
getPhone(): string | null;
|
|
1768
|
+
getLinkedin(): string | null;
|
|
1769
|
+
list<T = Record<string, unknown>>(name?: string): T[] | null;
|
|
1770
|
+
listPick<const TKeys extends readonly string[]>(keys: TKeys, name?: string): Array<Record<TKeys[number], unknown>> | null;
|
|
1771
|
+
listKeys(name?: string): Record<string, string>;
|
|
1772
|
+
};
|
|
1773
|
+
type StepResolver<Row, Value> = (row: Row, ctx: DeeplinePlayRuntimeContext, index: number) => Value | Promise<Value>;
|
|
1774
|
+
type ConditionalStepResolver<Row, Value, Else = null> = {
|
|
1775
|
+
readonly kind: 'conditional';
|
|
1776
|
+
readonly when: (row: Row, index: number) => boolean | Promise<boolean>;
|
|
1777
|
+
readonly run: StepResolver<Row, Value>;
|
|
1778
|
+
readonly elseValue: Else;
|
|
1779
|
+
else<ValueElse>(value: ValueElse): ConditionalStepResolver<Row, Value, ValueElse>;
|
|
1780
|
+
};
|
|
1781
|
+
type StepProgram<Input, Output, Return = Output> = {
|
|
1782
|
+
readonly kind: 'steps';
|
|
1783
|
+
readonly steps: readonly PlayStepProgramStep[];
|
|
1784
|
+
readonly returnResolver?: StepResolver<Output, Return>;
|
|
1785
|
+
readonly __inputType?: (input: Input) => void;
|
|
1786
|
+
step<Name extends string, Value>(name: Name, resolver: StepResolver<Output, Value> | ConditionalStepResolver<Output, Value> | StepProgramResolver<Output, Value>): StepProgram<Input, Output & Record<Name, Value>, Return>;
|
|
1787
|
+
return<Value>(resolver: StepResolver<Output, Value>): StepProgram<Input, Output, Value>;
|
|
1788
|
+
};
|
|
1789
|
+
type StepProgramResolver<Input, Return> = {
|
|
1790
|
+
readonly kind: 'steps';
|
|
1791
|
+
readonly steps: readonly PlayStepProgramStep[];
|
|
1792
|
+
readonly returnResolver?: StepResolver<never, Return>;
|
|
1793
|
+
readonly __inputType?: (input: Input) => void;
|
|
1794
|
+
};
|
|
1795
|
+
type PlayStepProgramStep = {
|
|
1796
|
+
readonly name: string;
|
|
1797
|
+
readonly resolver: StepResolver<Record<string, unknown>, unknown> | ConditionalStepResolver<Record<string, unknown>, unknown> | StepProgramResolver<Record<string, unknown>, unknown>;
|
|
1798
|
+
};
|
|
1799
|
+
type MapStepResolver<Row, Value> = StepResolver<Row, Value> | ConditionalStepResolver<Row, Value> | StepProgramResolver<Row, Value>;
|
|
1800
|
+
type MapRowKey<InputRow extends object> = (keyof InputRow & string) | readonly (keyof InputRow & string)[] | ((row: InputRow, index: number) => string | number | readonly unknown[]);
|
|
1801
|
+
type MapDefinitionOptions<InputRow extends object> = {
|
|
1802
|
+
staleAfterSeconds?: number;
|
|
1803
|
+
key?: MapRowKey<InputRow>;
|
|
1804
|
+
};
|
|
1805
|
+
type MapRunOptions = {
|
|
1806
|
+
description?: string;
|
|
1807
|
+
};
|
|
1808
|
+
type MapStepBuilder<InputRow extends object, OutputRow extends object> = {
|
|
1809
|
+
step<Name extends string, Value>(name: Name, resolver: MapStepResolver<OutputRow, Value>): MapStepBuilder<InputRow, OutputRow & Record<Name, Value>>;
|
|
1810
|
+
run(options?: MapRunOptions): Promise<PlayDataset<OutputRow>>;
|
|
1811
|
+
};
|
|
1812
|
+
/**
|
|
1813
|
+
* Runtime context available inside a play function.
|
|
1814
|
+
*
|
|
1815
|
+
* Provides methods for calling tools, processing data, and emitting logs.
|
|
1816
|
+
* This context is injected by the Temporal worker — you never construct it directly.
|
|
1817
|
+
*
|
|
1818
|
+
* @example
|
|
1819
|
+
* ```typescript
|
|
1820
|
+
* definePlay('example', async (ctx, input: { domain: string }) => {
|
|
1821
|
+
* // Call a tool
|
|
1822
|
+
* const company = await ctx.tools.execute({
|
|
1823
|
+
* id: 'company_search',
|
|
1824
|
+
* tool: 'test_company_search',
|
|
1825
|
+
* input: { domain: input.domain },
|
|
1826
|
+
* description: 'Look up company details by domain.',
|
|
1827
|
+
* });
|
|
1828
|
+
*
|
|
1829
|
+
* // Fan-out: process items with named steps
|
|
1830
|
+
* const enriched = await ctx
|
|
1831
|
+
* .map('companies', [{ domain: 'a.com' }, { domain: 'b.com' }], { key: 'domain' })
|
|
1832
|
+
* .step('company', (row, rowCtx) =>
|
|
1833
|
+
* rowCtx.tool({
|
|
1834
|
+
* id: 'company_search',
|
|
1835
|
+
* tool: 'test_company_search',
|
|
1836
|
+
* input: { domain: row.domain },
|
|
1837
|
+
* description: 'Look up company details by domain.',
|
|
1838
|
+
* }))
|
|
1839
|
+
* .run({ description: 'Look up company details.' });
|
|
1840
|
+
*
|
|
1841
|
+
* // Load CSV data
|
|
1842
|
+
* const leads = await ctx.csv('leads.csv');
|
|
1843
|
+
*
|
|
1844
|
+
* // Emit a log line (visible in `play tail`)
|
|
1845
|
+
* ctx.log(`Loaded ${await leads.count()} leads`);
|
|
1846
|
+
*
|
|
1847
|
+
* // Pause execution
|
|
1848
|
+
* await ctx.sleep(1000);
|
|
1849
|
+
*
|
|
1850
|
+
* // Access the raw input object
|
|
1851
|
+
* console.log(ctx.input);
|
|
1852
|
+
*
|
|
1853
|
+
* return { company, enriched };
|
|
1854
|
+
* });
|
|
1855
|
+
* ```
|
|
1856
|
+
*/
|
|
1857
|
+
interface DeeplinePlayRuntimeContext {
|
|
1858
|
+
/**
|
|
1859
|
+
* Load a CSV file as a dataset handle.
|
|
1860
|
+
*
|
|
1861
|
+
* The CSV must be staged or available at the given path. Each row becomes
|
|
1862
|
+
* an object keyed by column headers.
|
|
1863
|
+
*
|
|
1864
|
+
* @typeParam T - Row type (defaults to `Record<string, unknown>`)
|
|
1865
|
+
* @param path - Relative path to the CSV file
|
|
1866
|
+
* The returned dataset supports `for await`, `peek()`, `count()`, and
|
|
1867
|
+
* explicit `materialize()` for small result sets.
|
|
1868
|
+
*
|
|
1869
|
+
* @returns Parsed dataset rows
|
|
1870
|
+
*/
|
|
1871
|
+
csv<T = Record<string, unknown>>(path: string, options?: {
|
|
1872
|
+
description?: string;
|
|
1873
|
+
}): Promise<PlayDataset<T>>;
|
|
1874
|
+
/**
|
|
1875
|
+
* Fan-out: process each item through one or more named columns.
|
|
1876
|
+
*
|
|
1877
|
+
* Each key in `columns` becomes an output column. Each value is an async
|
|
1878
|
+
* callback `(row, ctx) => result` that receives the current row and the
|
|
1879
|
+
* play context — call tools, run waterfalls, do arbitrary logic.
|
|
1880
|
+
*
|
|
1881
|
+
* Items are processed in parallel (paced by the rate-limit scheduler).
|
|
1882
|
+
* The first argument identifies the logical map/table namespace. Use
|
|
1883
|
+
* `options.key` to pin durable row identity to stable input fields instead of
|
|
1884
|
+
* hashing the full input row.
|
|
1885
|
+
* `options.staleAfterSeconds` intentionally partitions the durable cache on a
|
|
1886
|
+
* relative time window. Use `86400` for daily reruns; retries inside the same
|
|
1887
|
+
* window still replay safely.
|
|
1888
|
+
*
|
|
1889
|
+
* Returns a dataset handle containing the original rows merged with the new
|
|
1890
|
+
* columns. Input may be a normal array, iterable, async iterable, or another
|
|
1891
|
+
* play dataset handle.
|
|
1892
|
+
*
|
|
1893
|
+
* @typeParam T - Row type
|
|
1894
|
+
* @param key - Logical map key used to isolate row identities (e.g. `'main_table'`, `'email_lookup'`)
|
|
1895
|
+
* @param items - Input rows or dataset handle
|
|
1896
|
+
* @returns Dataset of rows merged with the computed column values
|
|
1897
|
+
*
|
|
1898
|
+
* @example Single tool per row
|
|
1899
|
+
* ```typescript
|
|
1900
|
+
* const results = await ctx
|
|
1901
|
+
* .map('leads', leads, { key: 'domain' })
|
|
1902
|
+
* .step('company', (row, ctx) =>
|
|
1903
|
+
* ctx.tools.execute({
|
|
1904
|
+
* id: 'company_search',
|
|
1905
|
+
* tool: 'test_company_search',
|
|
1906
|
+
* input: { domain: row.domain },
|
|
1907
|
+
* description: 'Look up company details by domain.',
|
|
1908
|
+
* }))
|
|
1909
|
+
* .run({ description: 'Look up companies.' });
|
|
1910
|
+
* // [{ domain: 'stripe.com', company: { name: 'Stripe', ... } }, ...]
|
|
1911
|
+
* ```
|
|
1912
|
+
*
|
|
1913
|
+
* @example Multiple columns with pre/post logic
|
|
1914
|
+
* ```typescript
|
|
1915
|
+
* const results = await ctx
|
|
1916
|
+
* .map('leads', leads, { key: 'lead_id' })
|
|
1917
|
+
* .step('company', (row, ctx) =>
|
|
1918
|
+
* ctx.tools.execute({
|
|
1919
|
+
* id: 'company_search',
|
|
1920
|
+
* tool: 'test_company_search',
|
|
1921
|
+
* input: { domain: row.domain },
|
|
1922
|
+
* description: 'Look up company details by domain.',
|
|
1923
|
+
* }))
|
|
1924
|
+
* .step('score', (row) =>
|
|
1925
|
+
* row.company?.employeeCount > 100 ? 'enterprise' : 'smb')
|
|
1926
|
+
* .run({ description: 'Enrich leads.' });
|
|
1927
|
+
* ```
|
|
1928
|
+
*/
|
|
1929
|
+
map<TItem extends object>(key: string, items: PlayDatasetInput<TItem>, options?: MapDefinitionOptions<TItem>): MapStepBuilder<TItem, TItem>;
|
|
1930
|
+
/** Tool execution namespace. */
|
|
1931
|
+
tools: {
|
|
1932
|
+
/**
|
|
1933
|
+
* Execute a single tool by stable durable execution id and tool ID.
|
|
1934
|
+
*
|
|
1935
|
+
* @param request - Tool execution request. `id` is the durable execution id;
|
|
1936
|
+
* omit it in row/map steps when the surrounding step id is the execution id.
|
|
1937
|
+
* @returns The tool's output
|
|
1938
|
+
*/
|
|
1939
|
+
execute<TOutput = LoosePlayObject>(request: ToolExecutionRequest): Promise<ToolExecuteResult<TOutput>>;
|
|
1940
|
+
};
|
|
1941
|
+
/**
|
|
1942
|
+
* Execute a single tool by stable durable execution id and tool ID.
|
|
1943
|
+
*
|
|
1944
|
+
* Shorthand for `ctx.tools.execute({ id, tool, input })`; this is the
|
|
1945
|
+
* preferred spelling in row-level step programs.
|
|
1946
|
+
*/
|
|
1947
|
+
tool<TOutput = LoosePlayObject>(request: ToolExecutionRequest): Promise<ToolExecuteResult<TOutput>>;
|
|
1948
|
+
step<T>(id: string, run: () => T | Promise<T>): Promise<T>;
|
|
1949
|
+
fetch(key: string, url: string | URL, init?: RequestInit): Promise<{
|
|
1950
|
+
ok: boolean;
|
|
1951
|
+
status: number;
|
|
1952
|
+
statusText: string;
|
|
1953
|
+
url: string;
|
|
1954
|
+
headers: Record<string, string>;
|
|
1955
|
+
bodyText: string;
|
|
1956
|
+
json: unknown | null;
|
|
1957
|
+
}>;
|
|
1958
|
+
runPlay(key: string, playRef: string | PlayReferenceLike, input: Record<string, unknown>, options: {
|
|
1959
|
+
description?: string;
|
|
1960
|
+
}): Promise<Record<string, unknown>>;
|
|
1961
|
+
/**
|
|
1962
|
+
* Emit a log line visible in `play tail` and the play's progress logs.
|
|
1963
|
+
*
|
|
1964
|
+
* @param message - Log message (plain text)
|
|
1965
|
+
*/
|
|
1966
|
+
log(message: string): void;
|
|
1967
|
+
/**
|
|
1968
|
+
* Pause play execution for the specified duration.
|
|
1969
|
+
*
|
|
1970
|
+
* Uses Temporal's durable timer — safe across worker restarts.
|
|
1971
|
+
*
|
|
1972
|
+
* @param ms - Duration in milliseconds
|
|
1973
|
+
*/
|
|
1974
|
+
sleep(ms: number): Promise<void>;
|
|
1975
|
+
/** The raw input object passed when the play was started. */
|
|
1976
|
+
readonly input: Record<string, unknown>;
|
|
1977
|
+
}
|
|
1978
|
+
/**
|
|
1979
|
+
* Handle to a running play execution.
|
|
1980
|
+
*
|
|
1981
|
+
* Provides methods to check status, stream logs, wait for completion,
|
|
1982
|
+
* or cancel the execution.
|
|
1983
|
+
*
|
|
1984
|
+
* This handle is the SDK-context equivalent of `deepline play run --watch` and
|
|
1985
|
+
* `POST /api/v2/plays/run`: every surface returns a run id first, then exposes
|
|
1986
|
+
* the completed user output through `PlayJob.get()` or the status endpoint's
|
|
1987
|
+
* `result` field. Runtime logs are available from `status().progress.logs` and
|
|
1988
|
+
* are intentionally separate from the returned output object.
|
|
1989
|
+
*
|
|
1990
|
+
* @typeParam TOutput - The play's return type
|
|
1991
|
+
*
|
|
1992
|
+
* @example
|
|
1993
|
+
* ```typescript
|
|
1994
|
+
* const job: PlayJob = await ctx.play('my-play').run({ domain: 'stripe.com' });
|
|
1995
|
+
*
|
|
1996
|
+
* // Poll status
|
|
1997
|
+
* const status = await job.status();
|
|
1998
|
+
* console.log(status.temporalStatus); // 'RUNNING'
|
|
1999
|
+
*
|
|
2000
|
+
* // Stream logs until completion
|
|
2001
|
+
* const finalStatus = await job.tail({
|
|
2002
|
+
* onLog: (line) => console.log(`[play] ${line}`),
|
|
2003
|
+
* });
|
|
2004
|
+
*
|
|
2005
|
+
* // Or just wait for the result
|
|
2006
|
+
* const output = await job.get();
|
|
2007
|
+
*
|
|
2008
|
+
* // Cancel if needed
|
|
2009
|
+
* await job.cancel();
|
|
2010
|
+
* ```
|
|
2011
|
+
*/
|
|
2012
|
+
interface PlayJob<TOutput = unknown> {
|
|
2013
|
+
/** Temporal workflow ID for this execution. */
|
|
2014
|
+
id: string;
|
|
2015
|
+
/** Get the current execution status (single poll). */
|
|
2016
|
+
status(): Promise<PlayStatus>;
|
|
2017
|
+
/**
|
|
2018
|
+
* Stream logs and wait for completion.
|
|
2019
|
+
*
|
|
2020
|
+
* Polls until the play reaches a terminal state, invoking `onLog` for
|
|
2021
|
+
* each new log line. Returns the final status.
|
|
2022
|
+
*
|
|
2023
|
+
* @param options.intervalMs - Poll interval in ms. Default: `500`.
|
|
2024
|
+
* @param options.onLog - Callback for each log line. Default: `console.log`.
|
|
2025
|
+
*/
|
|
2026
|
+
tail(options?: {
|
|
2027
|
+
intervalMs?: number;
|
|
2028
|
+
onLog?: (line: string) => void;
|
|
2029
|
+
}): Promise<PlayStatus>;
|
|
2030
|
+
/**
|
|
2031
|
+
* Wait for the play to complete and return its output.
|
|
2032
|
+
*
|
|
2033
|
+
* Polls until terminal state. Throws {@link DeeplineError} if the play
|
|
2034
|
+
* fails, is cancelled, or times out.
|
|
2035
|
+
*
|
|
2036
|
+
* @param options.intervalMs - Poll interval in ms. Default: `500`.
|
|
2037
|
+
* @returns The play's return value
|
|
2038
|
+
* @throws {@link DeeplineError} if the play did not complete successfully
|
|
2039
|
+
*/
|
|
2040
|
+
get(options?: {
|
|
2041
|
+
intervalMs?: number;
|
|
2042
|
+
}): Promise<TOutput>;
|
|
2043
|
+
/** Cancel this play execution. */
|
|
2044
|
+
cancel(): Promise<void>;
|
|
2045
|
+
/** Deep-stop this play execution, including open HITL waits. */
|
|
2046
|
+
stop(options?: {
|
|
2047
|
+
reason?: string;
|
|
2048
|
+
}): Promise<StopPlayRunResult>;
|
|
2049
|
+
}
|
|
2050
|
+
/**
|
|
2051
|
+
* Handle to a named play for remote lifecycle operations.
|
|
2052
|
+
*
|
|
2053
|
+
* Returned by {@link DeeplineContext.play} and attached to {@link DefinedPlay}.
|
|
2054
|
+
* Provides methods to run, inspect, list runs, and publish a play by name.
|
|
2055
|
+
*
|
|
2056
|
+
* @typeParam TInput - The play's input type
|
|
2057
|
+
* @typeParam TOutput - The play's return type
|
|
2058
|
+
*
|
|
2059
|
+
* @example
|
|
2060
|
+
* ```typescript
|
|
2061
|
+
* const ctx = await Deepline.connect();
|
|
2062
|
+
* const play = ctx.play<{ domain: string }, Company>('company-lookup');
|
|
2063
|
+
*
|
|
2064
|
+
* // Get play definition
|
|
2065
|
+
* const detail = await play.get();
|
|
2066
|
+
* console.log(`Live: v${detail.play.currentPublishedVersion}`);
|
|
2067
|
+
*
|
|
2068
|
+
* // Run and wait
|
|
2069
|
+
* const result = await play.runSync({ domain: 'stripe.com' });
|
|
2070
|
+
*
|
|
2071
|
+
* // Run async
|
|
2072
|
+
* const job = await play.run({ domain: 'stripe.com' });
|
|
2073
|
+
* const output = await job.get();
|
|
2074
|
+
*
|
|
2075
|
+
* // List recent runs
|
|
2076
|
+
* const runs = await play.runs();
|
|
2077
|
+
*
|
|
2078
|
+
* // List saved versions
|
|
2079
|
+
* const versions = await play.versions();
|
|
2080
|
+
*
|
|
2081
|
+
* // Publish the current draft
|
|
2082
|
+
* await play.publish();
|
|
2083
|
+
* ```
|
|
2084
|
+
*/
|
|
2085
|
+
interface DeeplineNamedPlay<TInput = Record<string, unknown>, TOutput = unknown> {
|
|
2086
|
+
/** The play's name. */
|
|
2087
|
+
readonly name: string;
|
|
2088
|
+
/** Fetch the full play definition with revision history and run stats. */
|
|
2089
|
+
get(): Promise<PlayDetail>;
|
|
2090
|
+
/** List recent runs for this play. */
|
|
2091
|
+
runs(): Promise<PlayRunListItem[]>;
|
|
2092
|
+
/** List saved versions for this play (newest first). */
|
|
2093
|
+
versions(): Promise<PlayRevisionSummary[]>;
|
|
2094
|
+
/** Publish a play revision. Defaults to the current working revision. */
|
|
2095
|
+
publish(options?: {
|
|
2096
|
+
revisionId?: string;
|
|
2097
|
+
}): Promise<PublishPlayVersionResult>;
|
|
2098
|
+
/**
|
|
2099
|
+
* Clear run history and durable sheet/result data for this play while keeping
|
|
2100
|
+
* the play definition and revisions.
|
|
2101
|
+
*/
|
|
2102
|
+
clearHistory(options?: {
|
|
2103
|
+
tableNamespaces?: string[];
|
|
2104
|
+
}): Promise<ClearPlayHistoryResult>;
|
|
2105
|
+
/**
|
|
2106
|
+
* Start a new run of this play. Returns a {@link PlayJob} for monitoring.
|
|
2107
|
+
*
|
|
2108
|
+
* @param input - Runtime input passed to the play function
|
|
2109
|
+
*/
|
|
2110
|
+
run(input: TInput, options?: {
|
|
2111
|
+
revisionId?: string;
|
|
2112
|
+
}): Promise<PlayJob<TOutput>>;
|
|
2113
|
+
/**
|
|
2114
|
+
* Run this play and wait for completion.
|
|
2115
|
+
*
|
|
2116
|
+
* Equivalent to `play.run(input).then(job => job.get())`.
|
|
2117
|
+
*
|
|
2118
|
+
* @param input - Runtime input
|
|
2119
|
+
* @returns The play's return value
|
|
2120
|
+
*/
|
|
2121
|
+
runSync(input: TInput, options?: {
|
|
2122
|
+
revisionId?: string;
|
|
2123
|
+
}): Promise<TOutput>;
|
|
2124
|
+
}
|
|
2125
|
+
type PrebuiltPlayRef = {
|
|
2126
|
+
readonly playName: string;
|
|
2127
|
+
readonly name: string;
|
|
2128
|
+
};
|
|
2129
|
+
type PlayReferenceLike = {
|
|
2130
|
+
readonly playName?: string;
|
|
2131
|
+
readonly name?: string;
|
|
2132
|
+
};
|
|
2133
|
+
|
|
2134
|
+
type PlayReturnObject = Record<string, unknown> & {
|
|
2135
|
+
readonly _metadata?: never;
|
|
2136
|
+
};
|
|
2137
|
+
type PlayInputContract<TInput> = {
|
|
2138
|
+
readonly schema: Record<string, unknown>;
|
|
2139
|
+
readonly __inputType?: TInput;
|
|
2140
|
+
};
|
|
2141
|
+
type DefinePlayConfig<TInput, TOutput extends PlayReturnObject> = {
|
|
2142
|
+
id: string;
|
|
2143
|
+
input: PlayInputContract<TInput>;
|
|
2144
|
+
run: (ctx: DeeplinePlayRuntimeContext, input: TInput) => Promise<TOutput>;
|
|
2145
|
+
bindings?: PlayBindings;
|
|
2146
|
+
billing?: PlayBindings['billing'];
|
|
2147
|
+
};
|
|
2148
|
+
declare function steps<TInput>(): StepProgram<TInput, TInput, TInput>;
|
|
2149
|
+
declare function when<Row, Value>(predicate: (row: Row, index: number) => boolean | Promise<boolean>, resolver: StepResolver<Row, Value>): ConditionalStepResolver<Row, Value, null>;
|
|
2150
|
+
/**
|
|
2151
|
+
* A defined play: both a callable function and a named play handle.
|
|
2152
|
+
*
|
|
2153
|
+
* Created by {@link definePlay}. Can be:
|
|
2154
|
+
* 1. Called directly as a function (for server-side Temporal execution)
|
|
2155
|
+
* 2. Used as a {@link DeeplineNamedPlay} for remote lifecycle operations
|
|
2156
|
+
*
|
|
2157
|
+
* @typeParam TInput - The play's input type
|
|
2158
|
+
* @typeParam TOutput - The play's return type
|
|
2159
|
+
*
|
|
2160
|
+
* @example
|
|
2161
|
+
* ```typescript
|
|
2162
|
+
* import { definePlay } from 'deepline';
|
|
2163
|
+
*
|
|
2164
|
+
* const myPlay = definePlay('my-play', async (ctx, input: { domain: string }) => {
|
|
2165
|
+
* const company = await ctx.tools.execute({
|
|
2166
|
+
* id: 'company_search',
|
|
2167
|
+
* tool: 'test_company_search',
|
|
2168
|
+
* input: { domain: input.domain },
|
|
2169
|
+
* description: 'Look up company details by domain.',
|
|
2170
|
+
* });
|
|
2171
|
+
* return { company: company.result };
|
|
2172
|
+
* });
|
|
2173
|
+
*
|
|
2174
|
+
* // Type is: DefinedPlay<{ domain: string }, unknown>
|
|
2175
|
+
*
|
|
2176
|
+
* // Use as named play handle:
|
|
2177
|
+
* const detail = await myPlay.get();
|
|
2178
|
+
* const result = await myPlay.runSync({ domain: 'stripe.com' });
|
|
2179
|
+
*
|
|
2180
|
+
* // Access metadata:
|
|
2181
|
+
* console.log(myPlay.playName); // "my-play"
|
|
2182
|
+
* console.log(myPlay.bindings); // undefined (no cron/webhook)
|
|
2183
|
+
* ```
|
|
2184
|
+
*/
|
|
2185
|
+
type DefinedPlay<TInput, TOutput extends PlayReturnObject> = ((ctx: DeeplinePlayRuntimeContext, input: TInput) => Promise<TOutput>) & DeeplineNamedPlay<TInput, TOutput> & {
|
|
2186
|
+
/** Optional trigger bindings (cron, webhook). */
|
|
2187
|
+
readonly bindings?: PlayBindings;
|
|
2188
|
+
/** The play's name (same as `.name`). */
|
|
2189
|
+
readonly playName: string;
|
|
2190
|
+
};
|
|
2191
|
+
type PlayMetadata = {
|
|
2192
|
+
name: string;
|
|
2193
|
+
bindings?: PlayBindings;
|
|
2194
|
+
inputSchema?: Record<string, unknown>;
|
|
2195
|
+
billing?: PlayBindings['billing'];
|
|
2196
|
+
};
|
|
2197
|
+
/**
|
|
2198
|
+
* High-level SDK context with tool shortcuts and play handles.
|
|
2199
|
+
*
|
|
2200
|
+
* Created by {@link Deepline.connect}. Wraps a {@link DeeplineClient} with
|
|
2201
|
+
* a friendlier API for common operations.
|
|
2202
|
+
*
|
|
2203
|
+
* @example
|
|
2204
|
+
* ```typescript
|
|
2205
|
+
* const ctx = await Deepline.connect();
|
|
2206
|
+
*
|
|
2207
|
+
* // Tools
|
|
2208
|
+
* const tools = await ctx.tools.list();
|
|
2209
|
+
* const result = await ctx.tools.execute({
|
|
2210
|
+
* tool: 'test_company_search',
|
|
2211
|
+
* input: { domain: 'stripe.com' },
|
|
2212
|
+
* });
|
|
2213
|
+
*
|
|
2214
|
+
* // Plays
|
|
2215
|
+
* const job = await ctx.play('email-waterfall').run({ domain: 'stripe.com' });
|
|
2216
|
+
* const output = await job.get();
|
|
2217
|
+
* ```
|
|
2218
|
+
*/
|
|
2219
|
+
declare class DeeplineContext {
|
|
2220
|
+
private readonly client;
|
|
2221
|
+
constructor(options?: DeeplineClientOptions);
|
|
2222
|
+
/**
|
|
2223
|
+
* Tool operations namespace.
|
|
2224
|
+
*
|
|
2225
|
+
* @example
|
|
2226
|
+
* ```typescript
|
|
2227
|
+
* const tools = await ctx.tools.list();
|
|
2228
|
+
* const meta = await ctx.tools.get('apollo_people_search');
|
|
2229
|
+
* const result = await ctx.tools.execute({
|
|
2230
|
+
* tool: 'test_company_search',
|
|
2231
|
+
* input: { domain: 'stripe.com' },
|
|
2232
|
+
* });
|
|
2233
|
+
* const rows = result.tryList({ listExtractorPaths: ['people'] });
|
|
2234
|
+
* const email = result.getEmail();
|
|
2235
|
+
* ```
|
|
2236
|
+
*/
|
|
2237
|
+
get tools(): {
|
|
2238
|
+
/** List all available tools. */
|
|
2239
|
+
list: () => Promise<ToolDefinition[]>;
|
|
2240
|
+
/** Get detailed metadata for a tool. */
|
|
2241
|
+
get: (toolId: string) => Promise<ToolMetadata>;
|
|
2242
|
+
/** Execute a tool and return an ergonomic result wrapper. */
|
|
2243
|
+
execute: (request: SdkToolExecutionRequest) => Promise<ToolCallResult>;
|
|
2244
|
+
};
|
|
2245
|
+
get plays(): {
|
|
2246
|
+
list: () => Promise<PlayListItem[]>;
|
|
2247
|
+
get: <TInput = Record<string, unknown>, TOutput = unknown>(name: string) => DeeplineNamedPlay<TInput, TOutput>;
|
|
2248
|
+
};
|
|
2249
|
+
get prebuilt(): Record<string, PrebuiltPlayRef>;
|
|
2250
|
+
/**
|
|
2251
|
+
* Get a named play handle for remote lifecycle operations.
|
|
2252
|
+
*
|
|
2253
|
+
* @typeParam TInput - Expected input type
|
|
2254
|
+
* @typeParam TOutput - Expected output type
|
|
2255
|
+
* @param name - Play name (as registered on the server)
|
|
2256
|
+
* @returns Named play handle with run, versions, get, publish, etc.
|
|
2257
|
+
*
|
|
2258
|
+
* @example
|
|
2259
|
+
* ```typescript
|
|
2260
|
+
* const play = ctx.play<{ domain: string }>('email-waterfall');
|
|
2261
|
+
* const job = await play.run({ domain: 'stripe.com' });
|
|
2262
|
+
* const result = await job.get();
|
|
2263
|
+
* ```
|
|
2264
|
+
*/
|
|
2265
|
+
play<TInput = Record<string, unknown>, TOutput = unknown>(name: string): DeeplineNamedPlay<TInput, TOutput>;
|
|
2266
|
+
runPlay<TInput = Record<string, unknown>, TOutput = unknown>(playOrRef: string | PlayReferenceLike, input: TInput): Promise<TOutput>;
|
|
2267
|
+
}
|
|
2268
|
+
/**
|
|
2269
|
+
* Static entry point for the Deepline SDK.
|
|
2270
|
+
*
|
|
2271
|
+
* @example
|
|
2272
|
+
* ```typescript
|
|
2273
|
+
* import { Deepline } from 'deepline';
|
|
2274
|
+
*
|
|
2275
|
+
* const ctx = await Deepline.connect();
|
|
2276
|
+
* const tools = await ctx.tools.list();
|
|
2277
|
+
* const result = await ctx.tools.execute({
|
|
2278
|
+
* tool: 'test_company_search',
|
|
2279
|
+
* input: { domain: 'stripe.com' },
|
|
2280
|
+
* });
|
|
2281
|
+
* ```
|
|
2282
|
+
*/
|
|
2283
|
+
declare class Deepline {
|
|
2284
|
+
/**
|
|
2285
|
+
* Create a connected SDK context.
|
|
2286
|
+
*
|
|
2287
|
+
* Resolves configuration from options, environment variables, and CLI config
|
|
2288
|
+
* files. See {@link resolveConfig} for the resolution order.
|
|
2289
|
+
*
|
|
2290
|
+
* @param options - Optional overrides for API key, base URL, etc.
|
|
2291
|
+
* @returns Ready-to-use SDK context
|
|
2292
|
+
* @throws {@link ConfigError} if no API key can be resolved
|
|
2293
|
+
*
|
|
2294
|
+
* @example
|
|
2295
|
+
* ```typescript
|
|
2296
|
+
* // Auto-config (uses env vars / CLI auth):
|
|
2297
|
+
* const ctx = await Deepline.connect();
|
|
2298
|
+
*
|
|
2299
|
+
* // Explicit config:
|
|
2300
|
+
* const ctx2 = await Deepline.connect({
|
|
2301
|
+
* apiKey: 'dl_test_...',
|
|
2302
|
+
* baseUrl: 'http://localhost:3000',
|
|
2303
|
+
* });
|
|
2304
|
+
* ```
|
|
2305
|
+
*/
|
|
2306
|
+
static connect(options?: DeeplineClientOptions): Promise<DeeplineContext>;
|
|
2307
|
+
}
|
|
2308
|
+
declare function defineInput<TInput>(schema: Record<string, unknown>): PlayInputContract<TInput>;
|
|
2309
|
+
/**
|
|
2310
|
+
* Define a play — a composable TypeScript workflow for the Deepline platform.
|
|
2311
|
+
*
|
|
2312
|
+
* The returned value is both:
|
|
2313
|
+
* 1. **A callable function** — invoked by the Temporal worker with a runtime context
|
|
2314
|
+
* 2. **A named play handle** — with `.run()`, `.versions()`, `.get()`, `.publish()`, etc. for remote lifecycle management
|
|
2315
|
+
*
|
|
2316
|
+
* Plays are the primary abstraction for building repeatable data pipelines.
|
|
2317
|
+
* They run on Temporal for durable execution with automatic retries and timeouts.
|
|
2318
|
+
*
|
|
2319
|
+
* @typeParam TInput - The input type accepted by the play
|
|
2320
|
+
* @typeParam TOutput - The return type of the play
|
|
2321
|
+
* @param name - Unique play name (used for publishing, running by name, and CLI reference)
|
|
2322
|
+
* @param fn - Async function that receives a {@link DeeplinePlayRuntimeContext} and typed input
|
|
2323
|
+
* @param bindings - Optional trigger bindings (cron schedule, webhook with HMAC)
|
|
2324
|
+
* @returns A {@link DefinedPlay} that is both callable and has lifecycle methods
|
|
2325
|
+
*
|
|
2326
|
+
* @example Basic play
|
|
2327
|
+
* ```typescript
|
|
2328
|
+
* import { definePlay } from 'deepline';
|
|
2329
|
+
*
|
|
2330
|
+
* export default definePlay('company-lookup', async (ctx, input: { domain: string }) => {
|
|
2331
|
+
* ctx.log(`Searching for ${input.domain}`);
|
|
2332
|
+
* const company = await ctx.tools.execute({
|
|
2333
|
+
* id: 'company_search',
|
|
2334
|
+
* tool: 'test_company_search',
|
|
2335
|
+
* input: { domain: input.domain },
|
|
2336
|
+
* description: 'Look up company details by domain.',
|
|
2337
|
+
* });
|
|
2338
|
+
* return { company: company.result };
|
|
2339
|
+
* });
|
|
2340
|
+
* ```
|
|
2341
|
+
*
|
|
2342
|
+
* @example CSV processing play
|
|
2343
|
+
* ```typescript
|
|
2344
|
+
* export default definePlay('bulk-enrich', async (ctx) => {
|
|
2345
|
+
* const leads = await ctx.csv('leads.csv');
|
|
2346
|
+
* ctx.log(`Processing ${leads.length} rows`);
|
|
2347
|
+
* const results = await ctx
|
|
2348
|
+
* .map('domain', leads)
|
|
2349
|
+
* .step('company', (row, ctx) =>
|
|
2350
|
+
* ctx.tools.execute({
|
|
2351
|
+
* id: 'company_search',
|
|
2352
|
+
* tool: 'test_company_search',
|
|
2353
|
+
* input: { domain: row.domain },
|
|
2354
|
+
* description: 'Look up company details by domain.',
|
|
2355
|
+
* }))
|
|
2356
|
+
* .run({ description: 'Enrich lead companies.' });
|
|
2357
|
+
* return results;
|
|
2358
|
+
* });
|
|
2359
|
+
* ```
|
|
2360
|
+
*
|
|
2361
|
+
* @example With cron binding
|
|
2362
|
+
* ```typescript
|
|
2363
|
+
* export default definePlay('daily-report', async (ctx) => {
|
|
2364
|
+
* const data = await ctx.tools.execute({
|
|
2365
|
+
* id: 'crm_export',
|
|
2366
|
+
* tool: 'crm_export',
|
|
2367
|
+
* input: { since: 'yesterday' },
|
|
2368
|
+
* description: 'Export yesterday CRM records.',
|
|
2369
|
+
* });
|
|
2370
|
+
* return data;
|
|
2371
|
+
* }, {
|
|
2372
|
+
* cron: { schedule: '0 9 * * *', timezone: 'America/New_York' },
|
|
2373
|
+
* });
|
|
2374
|
+
* ```
|
|
2375
|
+
*
|
|
2376
|
+
* @example Programmatic lifecycle
|
|
2377
|
+
* ```typescript
|
|
2378
|
+
* const myPlay = definePlay('my-play', handler);
|
|
2379
|
+
*
|
|
2380
|
+
* // Get play definition:
|
|
2381
|
+
* const detail = await myPlay.get();
|
|
2382
|
+
*
|
|
2383
|
+
* // Run remotely:
|
|
2384
|
+
* const result = await myPlay.runSync({ domain: 'stripe.com' });
|
|
2385
|
+
*
|
|
2386
|
+
* // Make the current draft live:
|
|
2387
|
+
* await myPlay.publish();
|
|
2388
|
+
* ```
|
|
2389
|
+
*/
|
|
2390
|
+
declare function definePlay<TInput, TOutput extends PlayReturnObject>(config: DefinePlayConfig<TInput, TOutput>): DefinedPlay<TInput, TOutput>;
|
|
2391
|
+
declare function definePlay<TInput, TOutput extends PlayReturnObject>(name: string, fn: (ctx: DeeplinePlayRuntimeContext, input: TInput) => Promise<TOutput>, bindings?: PlayBindings): DefinedPlay<TInput, TOutput>;
|
|
2392
|
+
/**
|
|
2393
|
+
* Alias for {@link definePlay}. Workflows and plays share the same public
|
|
2394
|
+
* Deepline SDK contract; the selected execution profile decides whether the
|
|
2395
|
+
* run is backed by local Node, Temporal/Daytona, or Cloudflare Dynamic
|
|
2396
|
+
* Workflows.
|
|
2397
|
+
*/
|
|
2398
|
+
declare const defineWorkflow: typeof definePlay;
|
|
2399
|
+
/**
|
|
2400
|
+
* Extract play metadata from a value that may be a defined play.
|
|
2401
|
+
*
|
|
2402
|
+
* Used internally by the CLI and bundler to detect `definePlay()` exports
|
|
2403
|
+
* and extract the play name and bindings.
|
|
2404
|
+
*
|
|
2405
|
+
* @param value - Any value (typically a module's default export)
|
|
2406
|
+
* @returns Play metadata if the value is a defined play, `null` otherwise
|
|
2407
|
+
*
|
|
2408
|
+
* @example
|
|
2409
|
+
* ```typescript
|
|
2410
|
+
* import { getDefinedPlayMetadata } from 'deepline';
|
|
2411
|
+
*
|
|
2412
|
+
* const mod = await import('./my-play.play.ts');
|
|
2413
|
+
* const meta = getDefinedPlayMetadata(mod.default);
|
|
2414
|
+
* if (meta) {
|
|
2415
|
+
* console.log(`Play name: ${meta.name}`);
|
|
2416
|
+
* console.log(`Bindings:`, meta.bindings);
|
|
2417
|
+
* }
|
|
2418
|
+
* ```
|
|
2419
|
+
*/
|
|
2420
|
+
declare function getDefinedPlayMetadata(value: unknown): PlayMetadata | null;
|
|
2421
|
+
|
|
2422
|
+
export { AuthError, type ClearPlayHistoryRequest, type ClearPlayHistoryResult, type ConditionalStepResolver, ConfigError, Deepline, DeeplineClient, type DeeplineClientOptions, DeeplineContext, DeeplineError, type DeeplineNamedPlay, type DeeplinePlayRuntimeContext, type DefinePlayConfig, type DefinedPlay, type LiveEventEnvelope, type MapDefinitionOptions, type MapRowKey, type MapRunOptions, type MapStepBuilder, type MapStepResolver, PROD_URL, type PlayBindings, type PlayDataset, type PlayDatasetInput, type PlayInputContract, type PlayJob, type PlayListItem, type PlayLiveEvent, type PlayRevisionSummary, type PlayRunResult, type PlayRunStart, type PlayStatus, type PlayStepProgramStep, type PrebuiltPlayRef, type PublishPlayVersionRequest, type PublishPlayVersionResult, RateLimitError, type ResolvedConfig, SDK_API_CONTRACT, SDK_VERSION, type StartPlayRunRequest, type StepProgram, type StepProgramResolver, type StepResolver, type ToolCallResult, type ToolDefinition, type ToolExecuteResult, type ToolMetadata, createToolCallResult, defineInput, definePlay, defineWorkflow, extractSummaryFields, getDefinedPlayMetadata, resolveConfig, steps, tryConvertToList, when, writeCsvOutputFile, writeJsonOutputFile };
|