deepline 0.1.0 → 0.1.2
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/dist/cli/index.js +212 -54
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +198 -40
- package/dist/cli/index.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +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 +4 -4
|
@@ -0,0 +1,669 @@
|
|
|
1
|
+
import type { PlayCompilerManifest } from '../../shared_libs/plays/compiler-manifest';
|
|
2
|
+
|
|
3
|
+
// ——————————————————————————————————————————————————————————
|
|
4
|
+
// Config
|
|
5
|
+
// ——————————————————————————————————————————————————————————
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Options for constructing a {@link DeeplineClient} or connecting via {@link Deepline.connect}.
|
|
9
|
+
*
|
|
10
|
+
* All fields are optional — the SDK resolves missing values from environment
|
|
11
|
+
* variables and CLI-managed config files. See {@link resolveConfig} for the
|
|
12
|
+
* full resolution order.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import { DeeplineClient } from 'deepline';
|
|
17
|
+
*
|
|
18
|
+
* // Minimal — uses env vars / CLI config automatically:
|
|
19
|
+
* const client = new DeeplineClient();
|
|
20
|
+
*
|
|
21
|
+
* // Explicit overrides:
|
|
22
|
+
* const client2 = new DeeplineClient({
|
|
23
|
+
* apiKey: 'dl_test_...',
|
|
24
|
+
* baseUrl: 'http://localhost:3000',
|
|
25
|
+
* timeout: 30_000,
|
|
26
|
+
* maxRetries: 5,
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export interface DeeplineClientOptions {
|
|
31
|
+
/** API key. Overrides `DEEPLINE_API_KEY` env var and CLI-stored keys. */
|
|
32
|
+
apiKey?: string;
|
|
33
|
+
/** Base URL of the Deepline API. Overrides `DEEPLINE_ORIGIN_URL` / `DEEPLINE_API_BASE_URL`. */
|
|
34
|
+
baseUrl?: string;
|
|
35
|
+
/** Per-request timeout in milliseconds. Default: `60_000` (60 seconds). */
|
|
36
|
+
timeout?: number;
|
|
37
|
+
/** Maximum retry attempts for transient failures (network errors, 429s). Default: `3`. */
|
|
38
|
+
maxRetries?: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Fully resolved configuration used internally by the SDK.
|
|
43
|
+
*
|
|
44
|
+
* Produced by {@link resolveConfig} — all fields are guaranteed non-empty.
|
|
45
|
+
*/
|
|
46
|
+
export interface ResolvedConfig {
|
|
47
|
+
/** Validated API key (non-empty string). */
|
|
48
|
+
apiKey: string;
|
|
49
|
+
/** Normalized base URL (trailing slash stripped). */
|
|
50
|
+
baseUrl: string;
|
|
51
|
+
/** Request timeout in milliseconds. */
|
|
52
|
+
timeout: number;
|
|
53
|
+
/** Max retry count for transient failures. */
|
|
54
|
+
maxRetries: number;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface CustomerDbColumn {
|
|
58
|
+
name: string;
|
|
59
|
+
table_id: number | null;
|
|
60
|
+
data_type_id: number | null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface CustomerDbQueryResult {
|
|
64
|
+
command: string;
|
|
65
|
+
row_count: number | null;
|
|
66
|
+
row_count_returned: number;
|
|
67
|
+
truncated: boolean;
|
|
68
|
+
columns: CustomerDbColumn[];
|
|
69
|
+
rows: unknown[];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Summary definition of a tool, returned by {@link DeeplineClient.listTools}.
|
|
74
|
+
*
|
|
75
|
+
* Contains everything needed to discover, describe, and call a tool.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* const tools = await client.listTools();
|
|
80
|
+
* for (const tool of tools) {
|
|
81
|
+
* console.log(`${tool.toolId} (${tool.provider}): ${tool.description}`);
|
|
82
|
+
* }
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
export interface ToolDefinition {
|
|
86
|
+
/** Unique tool identifier used in API calls (e.g. `"apollo_people_search"`). */
|
|
87
|
+
toolId: string;
|
|
88
|
+
/** Provider that backs this tool (e.g. `"apollo"`, `"hunter"`, `"test"`). */
|
|
89
|
+
provider: string;
|
|
90
|
+
/** Human-readable name for display. */
|
|
91
|
+
displayName: string;
|
|
92
|
+
/** What this tool does — suitable for LLM tool descriptions. */
|
|
93
|
+
description: string;
|
|
94
|
+
/** Categorization tags (e.g. `["people", "enrichment"]`). */
|
|
95
|
+
categories: string[];
|
|
96
|
+
/** Operation slug within the provider. */
|
|
97
|
+
operation?: string;
|
|
98
|
+
/** Normalized operation identifier. */
|
|
99
|
+
operationId?: string;
|
|
100
|
+
/** Alternative names that resolve to this tool. */
|
|
101
|
+
operationAliases?: string[];
|
|
102
|
+
/** JSON Schema describing the tool's input parameters. */
|
|
103
|
+
inputSchema?: Record<string, unknown>;
|
|
104
|
+
/** JSON Schema describing the tool's output shape. */
|
|
105
|
+
outputSchema?: Record<string, unknown>;
|
|
106
|
+
/**
|
|
107
|
+
* Dotted paths for extracting list data from the tool's response.
|
|
108
|
+
*
|
|
109
|
+
* Used by {@link tryConvertToList} to automatically find the array of results
|
|
110
|
+
* in a nested response. Example: `["people", "result.data"]`.
|
|
111
|
+
*/
|
|
112
|
+
listExtractorPaths?: string[];
|
|
113
|
+
/** Field mappings for extracting identity fields (email, phone, etc.) from results. */
|
|
114
|
+
resultIdentityGetters?: Record<string, string[]>;
|
|
115
|
+
/** Whether the output is a direct object or wrapped in a `result` envelope. */
|
|
116
|
+
rowContextShape?: 'direct' | 'result_envelope';
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Extended tool metadata including pricing, samples, and failure modes.
|
|
121
|
+
*
|
|
122
|
+
* Returned by {@link DeeplineClient.getTool}. Extends {@link ToolDefinition}
|
|
123
|
+
* with operational details needed for cost estimation and debugging.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```typescript
|
|
127
|
+
* const meta = await client.getTool('apollo_people_search');
|
|
128
|
+
* console.log(meta.displayName); // "Apollo People Search"
|
|
129
|
+
* console.log(meta.estimatedCreditsRange); // "1-5"
|
|
130
|
+
* console.log(meta.samples); // { input: {...}, output: {...} }
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
export interface ToolMetadata extends ToolDefinition {
|
|
134
|
+
/** Related async polling action, if this tool supports async execution. */
|
|
135
|
+
asyncGetAction?: string | null;
|
|
136
|
+
/** Known failure scenarios and their expected handling. */
|
|
137
|
+
failureMode?: Record<string, unknown> | null;
|
|
138
|
+
/** Provider-side pricing structure. */
|
|
139
|
+
cost?: Record<string, unknown> | null;
|
|
140
|
+
/** How many Deepline credits map to one provider pricing unit. */
|
|
141
|
+
deeplineCreditsPerPricingUnit?: number | null;
|
|
142
|
+
/** Whether cost is billed by the provider or by Deepline. */
|
|
143
|
+
billingSource?: string;
|
|
144
|
+
/** Display label for the billing source. */
|
|
145
|
+
billingSourceLabel?: string;
|
|
146
|
+
/** Play expansion config if this tool auto-expands in plays. */
|
|
147
|
+
playExpansion?: Record<string, unknown>;
|
|
148
|
+
/** Estimated credit range for a single call (e.g. `"1-5"`). */
|
|
149
|
+
estimatedCreditsRange?: string;
|
|
150
|
+
/** Version of the cost estimation model used. */
|
|
151
|
+
estimateModelVersion?: string;
|
|
152
|
+
/** Tools whose costs were used to build this estimate. */
|
|
153
|
+
estimateBasedOnTools?: string[];
|
|
154
|
+
/** Individual step cost contributions (for composite tools). */
|
|
155
|
+
stepContributions?: unknown[];
|
|
156
|
+
/** Example input/output pairs for documentation and testing. */
|
|
157
|
+
samples?: Record<string, unknown>;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// ——————————————————————————————————————————————————————————
|
|
161
|
+
// Play results
|
|
162
|
+
// ——————————————————————————————————————————————————————————
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Final result of a play execution, returned by {@link DeeplineClient.runPlay}.
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```typescript
|
|
169
|
+
* const result = await client.runPlay(code, null, 'my-play');
|
|
170
|
+
* if (result.success) {
|
|
171
|
+
* console.log('Output:', result.result);
|
|
172
|
+
* console.log(`Completed in ${result.durationMs}ms`);
|
|
173
|
+
* } else {
|
|
174
|
+
* console.error('Failed:', result.error);
|
|
175
|
+
* console.log('Logs:', result.logs.join('\n'));
|
|
176
|
+
* }
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
export interface PlayRunResult {
|
|
180
|
+
/** `true` if the play completed successfully (`status === 'completed'`). */
|
|
181
|
+
success: boolean;
|
|
182
|
+
/** Public play-run identifier — use for `play tail` or status polling. */
|
|
183
|
+
runId: string;
|
|
184
|
+
/** The play's return value. Only present on success. */
|
|
185
|
+
result?: unknown;
|
|
186
|
+
/** All log lines emitted via `ctx.log()` during execution. */
|
|
187
|
+
logs: string[];
|
|
188
|
+
/** Wall-clock duration from submission to completion, in milliseconds. */
|
|
189
|
+
durationMs: number;
|
|
190
|
+
/** Error message if the play failed, was cancelled, or timed out. */
|
|
191
|
+
error?: string;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Progress snapshot from a running play, nested inside {@link PlayStatus}.
|
|
196
|
+
*/
|
|
197
|
+
export interface PlayProgressStatus {
|
|
198
|
+
/** Human-readable description of the current step. */
|
|
199
|
+
status: string;
|
|
200
|
+
/** Total row count for row-based processing (e.g. CSV enrichment). */
|
|
201
|
+
totalRows?: number;
|
|
202
|
+
/** Accumulated log lines from `ctx.log()`. Grows monotonically. */
|
|
203
|
+
logs: string[];
|
|
204
|
+
/** Error message if the play has failed. */
|
|
205
|
+
error?: string;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Current status of a play execution, returned by {@link DeeplineClient.getPlayStatus}.
|
|
210
|
+
*
|
|
211
|
+
* Poll this until `status` reaches a terminal state:
|
|
212
|
+
* `'completed'` | `'failed'` | `'cancelled'`.
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* ```typescript
|
|
216
|
+
* const status = await client.getPlayStatus(runId);
|
|
217
|
+
* if (status.status === 'completed') {
|
|
218
|
+
* console.log('Done:', status.result);
|
|
219
|
+
* } else if (status.status === 'running' || status.status === 'waiting') {
|
|
220
|
+
* console.log('Logs so far:', status.progress?.logs);
|
|
221
|
+
* }
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
224
|
+
export interface PlayStatus {
|
|
225
|
+
/** Public play-run identifier. */
|
|
226
|
+
runId: string;
|
|
227
|
+
/** Public Deepline play-run API version. */
|
|
228
|
+
apiVersion?: number;
|
|
229
|
+
/** Saved play name for this run, when available. */
|
|
230
|
+
name?: string;
|
|
231
|
+
/** Alias for `name` used by run/result APIs. */
|
|
232
|
+
playName?: string;
|
|
233
|
+
/** Product-level play-run state. */
|
|
234
|
+
status:
|
|
235
|
+
| 'queued'
|
|
236
|
+
| 'running'
|
|
237
|
+
| 'waiting'
|
|
238
|
+
| 'completed'
|
|
239
|
+
| 'failed'
|
|
240
|
+
| 'cancelled';
|
|
241
|
+
/** Execution progress with logs and error details. */
|
|
242
|
+
progress?: PlayProgressStatus;
|
|
243
|
+
/** Partial or final result. Available once the play returns. */
|
|
244
|
+
result?: unknown;
|
|
245
|
+
/** Temporal-backed run metadata when returned by the status endpoint. */
|
|
246
|
+
run?: {
|
|
247
|
+
startTime?: string | null;
|
|
248
|
+
closeTime?: string | null;
|
|
249
|
+
[key: string]: unknown;
|
|
250
|
+
} | null;
|
|
251
|
+
/** Server-rendered result view metadata for CLI/UI summaries. */
|
|
252
|
+
resultView?: unknown;
|
|
253
|
+
/** Canonical run contract snapshot metadata, when available. */
|
|
254
|
+
contract?: Record<string, unknown> | null;
|
|
255
|
+
/** If the run is blocked on a durable boundary, expose the public wait state. */
|
|
256
|
+
wait?: {
|
|
257
|
+
kind: 'integration_event' | 'sleep';
|
|
258
|
+
boundaryId?: string;
|
|
259
|
+
eventKey?: string;
|
|
260
|
+
until?: number;
|
|
261
|
+
} | null;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export type LiveEventScope = 'play' | 'agent';
|
|
265
|
+
|
|
266
|
+
export interface LiveEventEnvelope<TPayload = unknown> {
|
|
267
|
+
cursor: string;
|
|
268
|
+
streamId: string;
|
|
269
|
+
scope: LiveEventScope;
|
|
270
|
+
type: string;
|
|
271
|
+
at: string;
|
|
272
|
+
payload: TPayload;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
export type PlayLiveEvent = LiveEventEnvelope<unknown> & {
|
|
276
|
+
scope: 'play';
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Result returned by {@link DeeplineClient.stopPlay}.
|
|
281
|
+
*/
|
|
282
|
+
export interface StopPlayRunResult {
|
|
283
|
+
/** Public play-run identifier that was stopped. */
|
|
284
|
+
runId: string;
|
|
285
|
+
/** Stop request acknowledgement. */
|
|
286
|
+
stopped: true;
|
|
287
|
+
/** Number of open HITL interactions marked cancelled. */
|
|
288
|
+
hitlCancelledCount: number;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Summary of a single play run, returned by {@link DeeplineClient.listPlayRuns}.
|
|
293
|
+
*/
|
|
294
|
+
export interface PlayRunListItem {
|
|
295
|
+
/** Temporal workflow ID. */
|
|
296
|
+
workflowId: string;
|
|
297
|
+
/** Temporal run ID (unique per retry of the same workflow). */
|
|
298
|
+
runId: string;
|
|
299
|
+
/** Workflow type (typically `'Workflow'`). */
|
|
300
|
+
type: string;
|
|
301
|
+
/** Human-readable status (e.g. `'Completed'`, `'Failed'`). */
|
|
302
|
+
status: string;
|
|
303
|
+
/** ISO 8601 timestamp when the run started. */
|
|
304
|
+
startTime: string | null;
|
|
305
|
+
/** ISO 8601 timestamp when the run finished. */
|
|
306
|
+
closeTime: string | null;
|
|
307
|
+
/** Duration string (e.g. `'2.5s'`). */
|
|
308
|
+
executionTime: string | null;
|
|
309
|
+
/** Metadata attached to the workflow. */
|
|
310
|
+
memo: {
|
|
311
|
+
/** Organization that owns this run. */
|
|
312
|
+
orgId: string;
|
|
313
|
+
/** Play name. */
|
|
314
|
+
playName: string;
|
|
315
|
+
/** User who triggered the run, if known. */
|
|
316
|
+
userId: string | null;
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* A single revision (version) of a play's code and configuration.
|
|
322
|
+
*/
|
|
323
|
+
export interface PlayRevisionSummary {
|
|
324
|
+
/** Convex revision document ID used for exact-version runs and live promotion. */
|
|
325
|
+
_id?: string;
|
|
326
|
+
/** Monotonically increasing version number. */
|
|
327
|
+
version: number;
|
|
328
|
+
/** R2 storage reference for the bundled code artifact. */
|
|
329
|
+
artifactStorageKey?: string | null;
|
|
330
|
+
/** Immutable artifact hash for the revision. */
|
|
331
|
+
artifactHash?: string | null;
|
|
332
|
+
/** Static dependency graph hash for the revision. */
|
|
333
|
+
graphHash?: string | null;
|
|
334
|
+
/** Hash of the original source file. */
|
|
335
|
+
sourceHash?: string | null;
|
|
336
|
+
/** Original TypeScript source code. */
|
|
337
|
+
sourceCode?: string | null;
|
|
338
|
+
/** Primary key column for CSV-based plays. */
|
|
339
|
+
tableNamespace?: string | null;
|
|
340
|
+
/** Static pipeline definition (for declarative plays). */
|
|
341
|
+
staticPipeline?: unknown;
|
|
342
|
+
/** Extracted binding metadata. */
|
|
343
|
+
bindings?: unknown;
|
|
344
|
+
/** Human-readable description of this revision. */
|
|
345
|
+
description?: string | null;
|
|
346
|
+
/** Unix timestamp (ms) when this revision was created. */
|
|
347
|
+
createdAt?: number;
|
|
348
|
+
/** Unix timestamp (ms) of last update. */
|
|
349
|
+
updatedAt?: number;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Aggregate row-processing stats for a play's sheet.
|
|
354
|
+
*/
|
|
355
|
+
export interface PlaySheetStats {
|
|
356
|
+
total: number;
|
|
357
|
+
queued: number;
|
|
358
|
+
running: number;
|
|
359
|
+
completed: number;
|
|
360
|
+
failed: number;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Per-column processing stats within a play's sheet.
|
|
365
|
+
*/
|
|
366
|
+
export interface PlaySheetColumnStats {
|
|
367
|
+
queued: number;
|
|
368
|
+
running: number;
|
|
369
|
+
completed: number;
|
|
370
|
+
failed: number;
|
|
371
|
+
cached: number;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Summary of a play's data sheet state.
|
|
376
|
+
*/
|
|
377
|
+
export interface PlaySheetSummary {
|
|
378
|
+
/** Aggregate stats across all rows. */
|
|
379
|
+
stats: PlaySheetStats;
|
|
380
|
+
/** Per-column breakdown of processing state. */
|
|
381
|
+
columns: Record<string, PlaySheetColumnStats>;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Full play definition with revision history and run stats.
|
|
386
|
+
*
|
|
387
|
+
* Returned by {@link DeeplineClient.getPlay}.
|
|
388
|
+
*/
|
|
389
|
+
export interface PlayDefinitionDetail {
|
|
390
|
+
/** Convex document ID. */
|
|
391
|
+
_id: string;
|
|
392
|
+
/** Stable registry key. */
|
|
393
|
+
playKey?: string;
|
|
394
|
+
/** Canonical owner-qualified play reference. */
|
|
395
|
+
reference?: string;
|
|
396
|
+
/** Play name (unique within an org). */
|
|
397
|
+
name: string;
|
|
398
|
+
/** Human-friendly display name for UI surfaces. */
|
|
399
|
+
displayName?: string;
|
|
400
|
+
/** Whether this entry comes from the Deepline prebuilt registry or the org-owned catalog. */
|
|
401
|
+
origin?: 'prebuilt' | 'owned';
|
|
402
|
+
/** Ownership class used for permissions and badges. */
|
|
403
|
+
ownerType?: 'deepline' | 'org';
|
|
404
|
+
/** Slug of the owning workspace, or `deepline` for system plays. */
|
|
405
|
+
ownerSlug?: string;
|
|
406
|
+
/** Scope in the control plane. */
|
|
407
|
+
scope?: 'org' | 'system';
|
|
408
|
+
/** Whether the current actor can edit this play in place. */
|
|
409
|
+
canEdit?: boolean;
|
|
410
|
+
/** Whether the current actor can clone this play into their org. */
|
|
411
|
+
canClone?: boolean;
|
|
412
|
+
/** Organization ID that owns this play. */
|
|
413
|
+
orgId: string;
|
|
414
|
+
/** User ID that created the play. */
|
|
415
|
+
userId: string;
|
|
416
|
+
/** Total number of times this play has been executed. */
|
|
417
|
+
runCount: number;
|
|
418
|
+
/** Primary key column for CSV-based plays. */
|
|
419
|
+
tableNamespace?: string | null;
|
|
420
|
+
/** Temporal workflow ID of the latest run. */
|
|
421
|
+
latestRunId?: string | null;
|
|
422
|
+
/** Unix timestamp (ms). */
|
|
423
|
+
createdAt: number;
|
|
424
|
+
/** Unix timestamp (ms). */
|
|
425
|
+
updatedAt: number;
|
|
426
|
+
/** Source code of the current revision. */
|
|
427
|
+
sourceCode?: string | null;
|
|
428
|
+
/** Static pipeline, if applicable. */
|
|
429
|
+
staticPipeline?: unknown;
|
|
430
|
+
/** Serialized input schema contract for rendering / validation help. */
|
|
431
|
+
inputSchema?: Record<string, unknown> | null;
|
|
432
|
+
/** Serialized output schema contract for rendering / validation help. */
|
|
433
|
+
outputSchema?: Record<string, unknown> | null;
|
|
434
|
+
/** Alternate names that resolve to this play. */
|
|
435
|
+
aliases?: string[];
|
|
436
|
+
/** The revision that run-by-name resolves to. */
|
|
437
|
+
currentRevision?: PlayRevisionSummary | null;
|
|
438
|
+
/** The current working revision (may differ from live). */
|
|
439
|
+
workingRevision?: PlayRevisionSummary | null;
|
|
440
|
+
/** The live revision that executes for named runs. */
|
|
441
|
+
liveRevision?: PlayRevisionSummary | null;
|
|
442
|
+
/** `true` if the working revision differs from the live revision. */
|
|
443
|
+
isDraftDirty?: boolean;
|
|
444
|
+
/** Compatibility field for older readers. */
|
|
445
|
+
currentPublishedVersion?: number | null;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
export interface PlayListItem {
|
|
449
|
+
playKey?: string;
|
|
450
|
+
reference?: string;
|
|
451
|
+
name: string;
|
|
452
|
+
displayName?: string;
|
|
453
|
+
origin?: 'prebuilt' | 'owned';
|
|
454
|
+
ownerType?: 'deepline' | 'org';
|
|
455
|
+
ownerSlug?: string;
|
|
456
|
+
canEdit?: boolean;
|
|
457
|
+
canClone?: boolean;
|
|
458
|
+
orgId: string;
|
|
459
|
+
userId: string;
|
|
460
|
+
runCount: number;
|
|
461
|
+
updatedAt: number;
|
|
462
|
+
createdAt: number;
|
|
463
|
+
currentPublishedVersion?: number | null;
|
|
464
|
+
tableNamespace?: string | null;
|
|
465
|
+
isDraftDirty?: boolean;
|
|
466
|
+
inputSchema?: Record<string, unknown> | null;
|
|
467
|
+
outputSchema?: Record<string, unknown> | null;
|
|
468
|
+
aliases?: string[];
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
export interface PlayDescription {
|
|
472
|
+
name: string;
|
|
473
|
+
reference?: string;
|
|
474
|
+
displayName?: string;
|
|
475
|
+
origin?: 'prebuilt' | 'owned';
|
|
476
|
+
ownerType?: 'deepline' | 'org';
|
|
477
|
+
canEdit?: boolean;
|
|
478
|
+
canClone?: boolean;
|
|
479
|
+
aliases: string[];
|
|
480
|
+
inputSchema?: Record<string, unknown> | null;
|
|
481
|
+
outputSchema?: Record<string, unknown> | null;
|
|
482
|
+
runCommand: string;
|
|
483
|
+
examples: string[];
|
|
484
|
+
currentPublishedVersion?: number | null;
|
|
485
|
+
isDraftDirty?: boolean;
|
|
486
|
+
latestRunId?: string | null;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* Complete play detail including definition, recent runs, and sheet state.
|
|
491
|
+
*
|
|
492
|
+
* Returned by {@link DeeplineClient.getPlay}.
|
|
493
|
+
*
|
|
494
|
+
* @example
|
|
495
|
+
* ```typescript
|
|
496
|
+
* const detail = await client.getPlay('email-waterfall');
|
|
497
|
+
* console.log(`${detail.play.name} — ${detail.play.runCount} runs`);
|
|
498
|
+
* console.log(`Live: v${detail.play.liveRevision?.version}`);
|
|
499
|
+
* console.log(`Latest runs:`, detail.latestRuns.map(r => r.status));
|
|
500
|
+
* ```
|
|
501
|
+
*/
|
|
502
|
+
export interface PlayDetail {
|
|
503
|
+
/** Full play definition with revisions. */
|
|
504
|
+
play: PlayDefinitionDetail;
|
|
505
|
+
/** Most recent runs (newest first). */
|
|
506
|
+
latestRuns: PlayRunListItem[];
|
|
507
|
+
/** Sheet processing summary. */
|
|
508
|
+
sheetSummary: PlaySheetSummary;
|
|
509
|
+
/** Neon database URL for this play's customer data. */
|
|
510
|
+
customerDbUrl: string;
|
|
511
|
+
/** Change cursor for incremental sync. */
|
|
512
|
+
deltaCursor: number;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
export interface ClearPlayHistoryRequest {
|
|
516
|
+
/** Optional explicit ctx.map keys to clear. Omit to clear all discovered sheets for the play. */
|
|
517
|
+
tableNamespaces?: string[];
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
export interface ClearPlayHistoryResult {
|
|
521
|
+
playName: string;
|
|
522
|
+
deletedRuns: number;
|
|
523
|
+
droppedTables: string[];
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Response from starting a play run.
|
|
528
|
+
*
|
|
529
|
+
* Internal/advanced payload returned by low-level play submission primitives.
|
|
530
|
+
* Most callers should prefer `deepline play run`, {@link DeeplineClient.runPlay},
|
|
531
|
+
* or {@link PlayJob.get}.
|
|
532
|
+
*
|
|
533
|
+
* @example
|
|
534
|
+
* ```typescript
|
|
535
|
+
* const started = await client.startPlayRun({ name: 'my-play', input: { domain: 'stripe.com' } });
|
|
536
|
+
* console.log(`Started: ${started.workflowId}`);
|
|
537
|
+
* console.log(`Status URL: ${started.statusUrl}`);
|
|
538
|
+
* console.log(`Dashboard: ${started.dashboardUrl}`);
|
|
539
|
+
* ```
|
|
540
|
+
*/
|
|
541
|
+
export interface PlayRunStart {
|
|
542
|
+
/** Temporal workflow ID for tracking this execution. */
|
|
543
|
+
workflowId: string;
|
|
544
|
+
/** Public Deepline play-run API version. */
|
|
545
|
+
apiVersion?: number;
|
|
546
|
+
/** Play name (echoed back from the request). */
|
|
547
|
+
name?: string;
|
|
548
|
+
/** Initial status (typically `'RUNNING'`). */
|
|
549
|
+
status?: string;
|
|
550
|
+
/** Resolved runtime backend used for this run. */
|
|
551
|
+
runtimeBackend?: string;
|
|
552
|
+
/** Canonical run contract compatibility metadata. */
|
|
553
|
+
contract?: Record<string, unknown> | null;
|
|
554
|
+
/** URL to poll for status updates. */
|
|
555
|
+
statusUrl?: string;
|
|
556
|
+
/** Dashboard URL for the named play. */
|
|
557
|
+
dashboardUrl?: string;
|
|
558
|
+
/** Terminal status returned when the start request used a short completion wait. */
|
|
559
|
+
finalStatus?: unknown;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* Result returned by {@link DeeplineClient.checkPlayArtifact}.
|
|
564
|
+
*
|
|
565
|
+
* This is the check-only version of play artifact registration: the server runs
|
|
566
|
+
* the same preflight compiler and static-analysis pass without storing,
|
|
567
|
+
* publishing, or starting a Temporal run.
|
|
568
|
+
*/
|
|
569
|
+
export interface PlayCheckResult {
|
|
570
|
+
valid: boolean;
|
|
571
|
+
errors: string[];
|
|
572
|
+
staticPipeline?: Record<string, unknown> | null;
|
|
573
|
+
artifactHash?: string | null;
|
|
574
|
+
graphHash?: string | null;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* Request body for starting a play run via {@link DeeplineClient.startPlayRun}.
|
|
579
|
+
*
|
|
580
|
+
* Internal/advanced request shape for low-level submission primitives.
|
|
581
|
+
* Most callers should prefer `deepline play run`, {@link DeeplineClient.runPlay},
|
|
582
|
+
* or {@link Deepline.connect}.
|
|
583
|
+
*
|
|
584
|
+
* Either `name` (for live plays) or `artifactStorageKey` (for packaged ad hoc runs) is required.
|
|
585
|
+
*
|
|
586
|
+
* @example
|
|
587
|
+
* ```typescript
|
|
588
|
+
* // Run a live play by name:
|
|
589
|
+
* await client.startPlayRun({ name: 'email-waterfall', input: { domain: 'stripe.com' } });
|
|
590
|
+
*
|
|
591
|
+
* // Run a packaged ad hoc play by registered artifact:
|
|
592
|
+
* await client.startPlayRun({
|
|
593
|
+
* artifactStorageKey: 'plays/artifacts/org/acme/my-play/playgraph_abc123.json',
|
|
594
|
+
* input: { domain: 'stripe.com' },
|
|
595
|
+
* });
|
|
596
|
+
* ```
|
|
597
|
+
*/
|
|
598
|
+
export interface StartPlayRunRequest {
|
|
599
|
+
/** Play name for registered revisions. */
|
|
600
|
+
name?: string;
|
|
601
|
+
/** Explicit revision ID when the caller wants a specific saved version. */
|
|
602
|
+
revisionId?: string;
|
|
603
|
+
/** R2 artifact key for ad hoc artifact-backed runs. */
|
|
604
|
+
artifactStorageKey?: string;
|
|
605
|
+
/** Source snapshot already validated while registering this artifact. */
|
|
606
|
+
sourceCode?: string;
|
|
607
|
+
/** Static pipeline already produced while registering this artifact. */
|
|
608
|
+
staticPipeline?: unknown;
|
|
609
|
+
/** Artifact content hash already validated while registering this artifact. */
|
|
610
|
+
artifactHash?: string;
|
|
611
|
+
/** Static graph hash already validated while registering this artifact. */
|
|
612
|
+
graphHash?: string;
|
|
613
|
+
/** Optional preloaded artifact snapshot for immediate ad hoc execution. */
|
|
614
|
+
runtimeArtifact?: Record<string, unknown>;
|
|
615
|
+
/** Compiler manifest for ad hoc graph runs, including imported play dependencies. */
|
|
616
|
+
compilerManifest?: PlayCompilerManifest;
|
|
617
|
+
/** Primary input file bytes for one-shot server-side staging. */
|
|
618
|
+
inputFileUpload?: unknown;
|
|
619
|
+
/** Packaged file bytes for one-shot server-side staging. */
|
|
620
|
+
packagedFileUploads?: unknown[];
|
|
621
|
+
/** Runtime input passed to the play function as its second argument. */
|
|
622
|
+
input?: Record<string, unknown>;
|
|
623
|
+
/** Staged file reference for the primary input file (e.g. CSV). */
|
|
624
|
+
inputFile?: unknown;
|
|
625
|
+
/** Additional staged file references (dependencies, data files). */
|
|
626
|
+
packagedFiles?: unknown[];
|
|
627
|
+
/** Force-supersede any active runs for this play before starting. */
|
|
628
|
+
force?: boolean;
|
|
629
|
+
/** Optionally let the start request wait briefly and return a terminal result. */
|
|
630
|
+
waitForCompletionMs?: number;
|
|
631
|
+
/**
|
|
632
|
+
* Per-run execution profile override. The server defaults to `workers_edge`;
|
|
633
|
+
* tests/benchmarks pass `legacy` or `local` here. Most callers should leave
|
|
634
|
+
* this unset.
|
|
635
|
+
*/
|
|
636
|
+
profile?: string;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* Request body for making a play revision live.
|
|
641
|
+
*
|
|
642
|
+
* If omitted, the server promotes the current working revision.
|
|
643
|
+
*/
|
|
644
|
+
export interface PublishPlayVersionRequest {
|
|
645
|
+
/** Explicit revision ID to make live. */
|
|
646
|
+
revisionId?: string;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
/**
|
|
650
|
+
* Result returned after making a play revision live.
|
|
651
|
+
*/
|
|
652
|
+
export interface PublishPlayVersionResult {
|
|
653
|
+
success: boolean;
|
|
654
|
+
name: string;
|
|
655
|
+
liveVersion?: number;
|
|
656
|
+
triggerMetadata?: unknown;
|
|
657
|
+
triggerBindings?: unknown;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* Result returned after deleting an org-owned play.
|
|
662
|
+
*/
|
|
663
|
+
export interface DeletePlayResult {
|
|
664
|
+
deleted: boolean;
|
|
665
|
+
name: string;
|
|
666
|
+
deletedRevisionCount: number;
|
|
667
|
+
deletedBindingCount: number;
|
|
668
|
+
deletedRunCount: number;
|
|
669
|
+
}
|