deepline 0.2.13 → 0.2.14
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/bundling-sources/sdk/src/index.ts +3 -0
- package/dist/bundling-sources/sdk/src/play.ts +150 -691
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/child-execution-strategy.ts +7 -1
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +249 -51
- package/dist/bundling-sources/shared_libs/play-runtime/csv-rename.ts +10 -6
- package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +32 -51
- package/dist/bundling-sources/shared_libs/play-runtime/durable-call-cache.ts +11 -22
- package/dist/bundling-sources/shared_libs/play-runtime/durable-call-policy.ts +34 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-call-execution.ts +2 -1
- package/dist/bundling-sources/shared_libs/play-runtime/run-ledger-projection-contract.ts +95 -0
- package/dist/bundling-sources/shared_libs/play-runtime/secret-capability.ts +23 -15
- package/dist/bundling-sources/shared_libs/plays/artifact-types.ts +3 -0
- package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +2222 -0
- package/dist/bundling-sources/shared_libs/plays/bundling/index.ts +3 -2
- package/dist/bundling-sources/shared_libs/plays/compiler-manifest.ts +2 -0
- package/dist/bundling-sources/shared_libs/plays/contracts.ts +16 -0
- package/dist/bundling-sources/shared_libs/plays/input-contract-definition.ts +28 -0
- package/dist/bundling-sources/shared_libs/plays/input-contract.ts +3 -3
- package/dist/cli/index.js +5074 -829
- package/dist/cli/index.mjs +5019 -759
- package/dist/compiler-manifest-xFkbJX2B.d.mts +2517 -0
- package/dist/compiler-manifest-xFkbJX2B.d.ts +2517 -0
- package/dist/index.d.mts +36 -1011
- package/dist/index.d.ts +36 -1011
- package/dist/index.js +25 -7
- package/dist/index.mjs +25 -7
- package/dist/plays/bundle-play-file.d.mts +5 -8
- package/dist/plays/bundle-play-file.d.ts +5 -8
- package/dist/plays/bundle-play-file.mjs +3844 -3
- package/package.json +1 -1
- package/dist/bundling-sources/shared_libs/plays/source-metadata.ts +0 -240
- package/dist/tool-execution-error-4-rhemLQ.d.mts +0 -446
- package/dist/tool-execution-error-4-rhemLQ.d.ts +0 -446
|
@@ -98,7 +98,6 @@ import type {
|
|
|
98
98
|
ToolResultMetadataInput,
|
|
99
99
|
} from '../../shared_libs/play-runtime/tool-result-types.js';
|
|
100
100
|
import type { EmailStatusExtractorConfig } from '../../shared_libs/play-runtime/email-status.js';
|
|
101
|
-
import type { PreviousCell } from '../../shared_libs/play-runtime/cell-staleness.js';
|
|
102
101
|
import type {
|
|
103
102
|
DeeplineClientOptions,
|
|
104
103
|
PlayDetail,
|
|
@@ -113,14 +112,64 @@ import type {
|
|
|
113
112
|
ToolMetadata,
|
|
114
113
|
} from './types.js';
|
|
115
114
|
import type { ToolExecution } from './client.js';
|
|
116
|
-
import type {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
115
|
+
import type {
|
|
116
|
+
DurableCallStaleAfterSeconds,
|
|
117
|
+
PlayAuthoringBindings,
|
|
118
|
+
PlayAuthoringCallExecution,
|
|
119
|
+
PlayAuthoringCallOptions,
|
|
120
|
+
PlayAuthoringColumnResolver,
|
|
121
|
+
PlayAuthoringColumnMap,
|
|
122
|
+
PlayAuthoringConditionalStepResolver,
|
|
123
|
+
PlayAuthoringCsvInput,
|
|
124
|
+
PlayAuthoringCsvOptions,
|
|
125
|
+
PlayAuthoringCsvRenameMap,
|
|
126
|
+
PlayAuthoringDatasetBuilder,
|
|
127
|
+
PlayAuthoringDatasetColumnDefinition,
|
|
128
|
+
PlayAuthoringDatasetColumnRunInput,
|
|
129
|
+
PlayAuthoringDatasetDefinitionOptions,
|
|
130
|
+
PlayAuthoringDatasetRowKey,
|
|
131
|
+
PlayAuthoringDatasetRunOptions,
|
|
132
|
+
PlayAuthoringDefineConfig,
|
|
133
|
+
PlayAuthoringDefinedPlay,
|
|
134
|
+
PlayAuthoringInputContract,
|
|
135
|
+
PlayAuthoringFileInput,
|
|
136
|
+
PlayAuthoringFetchOptions,
|
|
137
|
+
PlayAuthoringFetchResponse,
|
|
138
|
+
PlayAuthoringReferenceLike,
|
|
139
|
+
PlayAuthoringRunnableStepProgram,
|
|
140
|
+
PlayAuthoringRuntimeContext,
|
|
141
|
+
PlayAuthoringRuntimeStepOptions,
|
|
142
|
+
PlayAuthoringStepOptions,
|
|
143
|
+
PlayAuthoringStepProgram,
|
|
144
|
+
PlayAuthoringStepProgramOutput,
|
|
145
|
+
PlayAuthoringStepProgramResolver,
|
|
146
|
+
PlayAuthoringStepProgramStep,
|
|
147
|
+
PlayAuthoringStepResolver,
|
|
148
|
+
PlayLooseObject,
|
|
149
|
+
PlayReturnObject as PlayAuthoringReturnObject,
|
|
150
|
+
PlaySecretAuth,
|
|
151
|
+
PlaySecretAwareRequestInit,
|
|
152
|
+
PlaySecretHandle,
|
|
153
|
+
PlaySqlQuery,
|
|
154
|
+
PlayReceiptWaitMs,
|
|
155
|
+
PlayRuntimeTimeoutMs,
|
|
156
|
+
PlaySqlListenerDeclaration,
|
|
157
|
+
PlaySqlListenerEvent,
|
|
158
|
+
PlaySqlListenerFilterOperator,
|
|
159
|
+
PlaySqlListenerFilterScalar,
|
|
160
|
+
PlaySqlListenerOperation,
|
|
161
|
+
PlaySqlListenerWhere,
|
|
162
|
+
PlayToolExecutionRequest,
|
|
163
|
+
} from '../../shared_libs/plays/authoring-contract.js';
|
|
164
|
+
import { createPlayInputContract } from '../../shared_libs/plays/input-contract-definition.js';
|
|
165
|
+
|
|
166
|
+
export type PlayCallExecution = PlayAuthoringCallExecution;
|
|
167
|
+
|
|
168
|
+
export type PlayCallOptions = PlayAuthoringCallOptions;
|
|
169
|
+
|
|
170
|
+
export type RuntimeStepOptions = PlayAuthoringRuntimeStepOptions;
|
|
171
|
+
export type FetchOptions = PlayAuthoringFetchOptions;
|
|
172
|
+
export type PlayFetchResponse = PlayAuthoringFetchResponse;
|
|
124
173
|
|
|
125
174
|
/**
|
|
126
175
|
* Optional trigger bindings for a play.
|
|
@@ -172,142 +221,21 @@ export interface PlayCallOptions {
|
|
|
172
221
|
*
|
|
173
222
|
* @sdkReference runtime 030
|
|
174
223
|
*/
|
|
175
|
-
export type PlayBindings =
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
*/
|
|
191
|
-
compatibility?: {
|
|
192
|
-
toolErrorSchemaVersion: ToolExecutionErrorSchemaVersion;
|
|
193
|
-
};
|
|
194
|
-
/** Allow compilers to bundle this named handler directly without a child run. */
|
|
195
|
-
inline?: boolean;
|
|
196
|
-
/** Optional per-run billing controls enforced by the runtime. */
|
|
197
|
-
billing?: {
|
|
198
|
-
/** Stop the run before a billed action would push total run credits above this cap. */
|
|
199
|
-
maxCreditsPerRun?: number;
|
|
200
|
-
};
|
|
201
|
-
/** Requested prebuilt sandbox and runtime deadline. */
|
|
202
|
-
runtime?: {
|
|
203
|
-
/** Duration such as `"90m"` or `"2h"`. */
|
|
204
|
-
timeout?: string;
|
|
205
|
-
/** Deepline-managed prebuilt sandbox size. */
|
|
206
|
-
size?: 'standard';
|
|
207
|
-
};
|
|
208
|
-
/** Webhook trigger with optional HMAC signature verification. */
|
|
209
|
-
webhook?: {
|
|
210
|
-
hmac?: {
|
|
211
|
-
/** Hash algorithm. Currently only `'sha256'` is supported. */
|
|
212
|
-
algorithm?: 'sha256';
|
|
213
|
-
/** HTTP header containing the signature (e.g. `'X-Hub-Signature-256'`). */
|
|
214
|
-
header?: string;
|
|
215
|
-
/** Environment variable name holding the HMAC secret. */
|
|
216
|
-
secretEnv: string;
|
|
217
|
-
};
|
|
218
|
-
};
|
|
219
|
-
/** Cron schedule trigger. */
|
|
220
|
-
cron?: {
|
|
221
|
-
/** Cron expression (e.g. `'0 9 * * *'` for daily at 9am). */
|
|
222
|
-
schedule: string;
|
|
223
|
-
/** IANA timezone (e.g. `'America/New_York'`). Defaults to UTC. */
|
|
224
|
-
timezone?: string;
|
|
225
|
-
};
|
|
226
|
-
/** Customer DB row-change listeners that wake this play when published. */
|
|
227
|
-
sqlListeners?: SqlListenerDeclaration[];
|
|
228
|
-
/**
|
|
229
|
-
* Customer-authored play secrets this play is allowed to use at runtime.
|
|
230
|
-
* Values are never bundled or exposed by the SDK; access them with
|
|
231
|
-
* `ctx.secrets.get("NAME")` and approved helpers such as
|
|
232
|
-
* `ctx.secrets.bearer(handle)`. Secret-authenticated `ctx.fetch` calls
|
|
233
|
-
* require an https:// URL so customer secrets never leave Deepline over
|
|
234
|
-
* plaintext HTTP.
|
|
235
|
-
*/
|
|
236
|
-
secrets?: readonly string[];
|
|
237
|
-
};
|
|
238
|
-
|
|
239
|
-
export type SqlListenerOperation = 'INSERT' | 'UPDATE' | 'DELETE';
|
|
240
|
-
export type SqlListenerFilterScalar = string | number | boolean | null;
|
|
241
|
-
export type SqlListenerFilterOperator = {
|
|
242
|
-
eq?: SqlListenerFilterScalar;
|
|
243
|
-
neq?: SqlListenerFilterScalar;
|
|
244
|
-
in?: SqlListenerFilterScalar[];
|
|
245
|
-
notIn?: SqlListenerFilterScalar[];
|
|
246
|
-
isNull?: true;
|
|
247
|
-
isNotNull?: true;
|
|
248
|
-
ilike?: string;
|
|
249
|
-
};
|
|
250
|
-
export type SqlListenerWhere = {
|
|
251
|
-
before?: Record<string, SqlListenerFilterOperator>;
|
|
252
|
-
after?: Record<string, SqlListenerFilterOperator>;
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
export type SqlListenerDeclaration = {
|
|
256
|
-
/** Short id unique inside this play. Deepline stores it as playName.id. */
|
|
257
|
-
id: string;
|
|
258
|
-
/** Modeled monitor tool id, for example "deepline_native.company_radar". */
|
|
259
|
-
tool: string;
|
|
260
|
-
/** Stream key exposed by the modeled monitor tool, for example "company_job_openings". */
|
|
261
|
-
stream: string;
|
|
262
|
-
/** Row operations that should wake this play. Defaults to INSERT and UPDATE. */
|
|
263
|
-
operations?: SqlListenerOperation[];
|
|
264
|
-
/** Optional DB-side row filter over top-level before/after fields. */
|
|
265
|
-
where?: SqlListenerWhere;
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
export type SqlListenerEvent<T extends object = Record<string, unknown>> = {
|
|
269
|
-
tool: string;
|
|
270
|
-
stream: string;
|
|
271
|
-
operation: SqlListenerOperation;
|
|
272
|
-
before: T | null;
|
|
273
|
-
after: T | null;
|
|
274
|
-
changedAt: string;
|
|
275
|
-
metadata: {
|
|
276
|
-
outboxId: string;
|
|
277
|
-
listenerId: string;
|
|
278
|
-
table: string;
|
|
279
|
-
};
|
|
280
|
-
};
|
|
281
|
-
|
|
282
|
-
export type SqlQuery = {
|
|
283
|
-
readonly kind: 'sql.query';
|
|
284
|
-
readonly text: string;
|
|
285
|
-
readonly values: readonly unknown[];
|
|
286
|
-
};
|
|
287
|
-
|
|
288
|
-
declare const SECRET_HANDLE_BRAND: unique symbol;
|
|
289
|
-
|
|
290
|
-
export type SecretHandle = {
|
|
291
|
-
readonly [SECRET_HANDLE_BRAND]: never;
|
|
292
|
-
readonly name: string;
|
|
293
|
-
toString(): string;
|
|
294
|
-
toJSON(): never;
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
export type SecretAuth = {
|
|
298
|
-
readonly kind: 'bearer' | 'header';
|
|
299
|
-
readonly secret: SecretHandle;
|
|
300
|
-
readonly header?: string;
|
|
301
|
-
};
|
|
302
|
-
|
|
303
|
-
export type SecretAwareRequestInit = Omit<RequestInit, 'headers'> & {
|
|
304
|
-
headers?: HeadersInit;
|
|
305
|
-
auth?: SecretAuth;
|
|
306
|
-
};
|
|
307
|
-
|
|
308
|
-
export type LoosePlayObject = {
|
|
309
|
-
[key: string]: LoosePlayObject;
|
|
310
|
-
};
|
|
224
|
+
export type PlayBindings = PlayAuthoringBindings;
|
|
225
|
+
export type SqlListenerOperation = PlaySqlListenerOperation;
|
|
226
|
+
export type SqlListenerFilterScalar = PlaySqlListenerFilterScalar;
|
|
227
|
+
export type SqlListenerFilterOperator = PlaySqlListenerFilterOperator;
|
|
228
|
+
export type SqlListenerWhere = PlaySqlListenerWhere;
|
|
229
|
+
export type SqlListenerDeclaration = PlaySqlListenerDeclaration;
|
|
230
|
+
export type SqlListenerEvent<T extends object = Record<string, unknown>> =
|
|
231
|
+
PlaySqlListenerEvent<T>;
|
|
232
|
+
|
|
233
|
+
/** @deprecated Pass a SQL string directly to ctx.customerDb.query. */
|
|
234
|
+
export type SqlQuery = PlaySqlQuery;
|
|
235
|
+
export type SecretHandle = PlaySecretHandle;
|
|
236
|
+
export type SecretAuth = PlaySecretAuth;
|
|
237
|
+
export type SecretAwareRequestInit = PlaySecretAwareRequestInit;
|
|
238
|
+
export type LoosePlayObject = PlayLooseObject;
|
|
311
239
|
|
|
312
240
|
export type {
|
|
313
241
|
ToolExecuteResult,
|
|
@@ -344,52 +272,21 @@ export type { PreviousCell } from '../../shared_libs/play-runtime/cell-staleness
|
|
|
344
272
|
*
|
|
345
273
|
* @sdkReference runtime 160
|
|
346
274
|
*/
|
|
347
|
-
export type ToolExecutionRequest =
|
|
348
|
-
/** Stable logical id for logs, metadata, and receipt attachment. */
|
|
349
|
-
id: string;
|
|
350
|
-
/** Current tool id from `deepline tools search` / `deepline tools describe`. */
|
|
351
|
-
tool: string;
|
|
352
|
-
/** JSON-serializable provider/tool input object. */
|
|
353
|
-
input: Record<string, unknown>;
|
|
354
|
-
/** Human-readable description for logs and run inspection. */
|
|
355
|
-
description?: string;
|
|
356
|
-
/** Recompute this tool call instead of reusing a durable receipt/checkpoint. */
|
|
357
|
-
force?: boolean;
|
|
358
|
-
/** Numeric TTL in seconds for this tool checkpoint. */
|
|
359
|
-
staleAfterSeconds?: number;
|
|
360
|
-
/** Runtime transport timeout in milliseconds. This is not sent to the provider. */
|
|
361
|
-
timeoutMs?: number;
|
|
362
|
-
/** Follower wait budget in milliseconds before a running receipt is reclaimable. */
|
|
363
|
-
receiptWaitMs?: number;
|
|
364
|
-
};
|
|
275
|
+
export type ToolExecutionRequest = PlayToolExecutionRequest;
|
|
365
276
|
|
|
366
|
-
export type StepResolver<Row, Value> =
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
) => Value | Promise<Value>;
|
|
277
|
+
export type StepResolver<Row, Value> = PlayAuthoringStepResolver<
|
|
278
|
+
Row,
|
|
279
|
+
Value,
|
|
280
|
+
DeeplinePlayRuntimeContext
|
|
281
|
+
>;
|
|
372
282
|
|
|
373
283
|
/**
|
|
374
284
|
* Input object passed to an object-column `run` resolver.
|
|
375
285
|
*
|
|
376
286
|
* @sdkReference runtime 090
|
|
377
287
|
*/
|
|
378
|
-
export type DatasetColumnRunInput<Row, Value> =
|
|
379
|
-
|
|
380
|
-
row: Row;
|
|
381
|
-
/** Runtime context for tool/play/fetch/log calls. */
|
|
382
|
-
ctx: DeeplinePlayRuntimeContext;
|
|
383
|
-
/** Zero-based row index for this dataset run. */
|
|
384
|
-
index: number;
|
|
385
|
-
/**
|
|
386
|
-
* The prior stored value for this exact row+column when the runtime has
|
|
387
|
-
* decided the cell is due to run again. `previousCell.value` is the same type
|
|
388
|
-
* this column returns; metadata such as `completedAt` and `staleAt` lives
|
|
389
|
-
* beside it and is not mixed into the value.
|
|
390
|
-
*/
|
|
391
|
-
previousCell?: PreviousCell<Value>;
|
|
392
|
-
};
|
|
288
|
+
export type DatasetColumnRunInput<Row, Value> =
|
|
289
|
+
PlayAuthoringDatasetColumnRunInput<Row, Value, DeeplinePlayRuntimeContext>;
|
|
393
290
|
|
|
394
291
|
/**
|
|
395
292
|
* Object-column form for `.withColumn(...)`.
|
|
@@ -398,96 +295,55 @@ export type DatasetColumnRunInput<Row, Value> = {
|
|
|
398
295
|
*
|
|
399
296
|
* @sdkReference runtime 100
|
|
400
297
|
*/
|
|
401
|
-
export type DatasetColumnDefinition<Row, Value> =
|
|
402
|
-
|
|
403
|
-
run: (input: DatasetColumnRunInput<Row, Value>) => Value | Promise<Value>;
|
|
404
|
-
/** Optional row-level gate. Skipped rows produce `null` for this column. */
|
|
405
|
-
readonly runIf?: (row: Row, index: number) => boolean | Promise<boolean>;
|
|
406
|
-
};
|
|
298
|
+
export type DatasetColumnDefinition<Row, Value> =
|
|
299
|
+
PlayAuthoringDatasetColumnDefinition<Row, Value, DeeplinePlayRuntimeContext>;
|
|
407
300
|
|
|
408
|
-
export type ConditionalStepResolver<
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
301
|
+
export type ConditionalStepResolver<
|
|
302
|
+
Row,
|
|
303
|
+
Value,
|
|
304
|
+
Else = null,
|
|
305
|
+
> = PlayAuthoringConditionalStepResolver<
|
|
306
|
+
Row,
|
|
307
|
+
Value,
|
|
308
|
+
DeeplinePlayRuntimeContext,
|
|
309
|
+
Else
|
|
310
|
+
>;
|
|
417
311
|
|
|
418
312
|
/**
|
|
419
313
|
* Options for row-level `.withColumn(...)` and `steps().step(...)` entries.
|
|
420
314
|
*
|
|
421
315
|
* @sdkReference runtime 110
|
|
422
316
|
*/
|
|
423
|
-
export type StepOptions<Row, Value = unknown> =
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
* Legacy dataset-column recompute flag accepted for older authored plays.
|
|
428
|
-
*
|
|
429
|
-
* Prefer putting freshness on the actual reusable call
|
|
430
|
-
* (`ctx.tools.execute`, `ctx.step`, or `ctx.fetch`).
|
|
431
|
-
*/
|
|
432
|
-
readonly recompute?: boolean;
|
|
433
|
-
/** Legacy error-recompute flag accepted for older authored plays. */
|
|
434
|
-
readonly recomputeOnError?: boolean;
|
|
435
|
-
/** Legacy cell staleness metadata accepted for older authored plays. */
|
|
436
|
-
readonly staleAfterSeconds?: number;
|
|
437
|
-
};
|
|
317
|
+
export type StepOptions<Row, Value = unknown> = PlayAuthoringStepOptions<
|
|
318
|
+
Row,
|
|
319
|
+
Value
|
|
320
|
+
>;
|
|
438
321
|
|
|
439
|
-
export type StepProgram<
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
step<Name extends string, Value>(
|
|
445
|
-
name: Name,
|
|
446
|
-
resolver:
|
|
447
|
-
| StepResolver<Output, Value>
|
|
448
|
-
| ConditionalStepResolver<Output, Value>
|
|
449
|
-
| StepProgramResolver<Output, Value>,
|
|
450
|
-
): StepProgram<Input, Output & Record<Name, Value>, Return>;
|
|
451
|
-
step<Name extends string, Value>(
|
|
452
|
-
name: Name,
|
|
453
|
-
resolver: StepResolver<Output, Value> | StepProgramResolver<Output, Value>,
|
|
454
|
-
options: StepOptions<Output, Value>,
|
|
455
|
-
): StepProgram<Input, Output & Record<Name, Value | null>, Return>;
|
|
456
|
-
return<Value>(
|
|
457
|
-
resolver: StepResolver<Output, Value>,
|
|
458
|
-
): StepProgram<Input, Output, Value>;
|
|
459
|
-
};
|
|
322
|
+
export type StepProgram<
|
|
323
|
+
Input,
|
|
324
|
+
Output,
|
|
325
|
+
Return = Output,
|
|
326
|
+
> = PlayAuthoringStepProgram<Input, Output, DeeplinePlayRuntimeContext, Return>;
|
|
460
327
|
|
|
461
|
-
export type StepProgramResolver<Input, Return> =
|
|
462
|
-
|
|
463
|
-
readonly steps: readonly PlayStepProgramStep[];
|
|
464
|
-
readonly returnResolver?: StepResolver<never, Return>;
|
|
465
|
-
readonly __inputType?: (input: Input) => void;
|
|
466
|
-
};
|
|
328
|
+
export type StepProgramResolver<Input, Return> =
|
|
329
|
+
PlayAuthoringStepProgramResolver<Input, Return, DeeplinePlayRuntimeContext>;
|
|
467
330
|
|
|
468
|
-
export type PlayStepProgramStep =
|
|
469
|
-
|
|
470
|
-
readonly recompute?: boolean;
|
|
471
|
-
readonly recomputeOnError?: boolean;
|
|
472
|
-
readonly staleAfterSeconds?: number;
|
|
473
|
-
readonly resolver:
|
|
474
|
-
| StepResolver<Record<string, unknown>, unknown>
|
|
475
|
-
| ConditionalStepResolver<Record<string, unknown>, unknown>
|
|
476
|
-
| StepProgramResolver<Record<string, unknown>, unknown>;
|
|
477
|
-
};
|
|
331
|
+
export type PlayStepProgramStep =
|
|
332
|
+
PlayAuthoringStepProgramStep<DeeplinePlayRuntimeContext>;
|
|
478
333
|
|
|
479
|
-
export type ColumnResolver<Row, Value> =
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
334
|
+
export type ColumnResolver<Row, Value> = PlayAuthoringColumnResolver<
|
|
335
|
+
Row,
|
|
336
|
+
Value,
|
|
337
|
+
DeeplinePlayRuntimeContext
|
|
338
|
+
>;
|
|
483
339
|
|
|
484
340
|
export type StepProgramOutput<TProgram> =
|
|
485
|
-
TProgram
|
|
341
|
+
PlayAuthoringStepProgramOutput<TProgram>;
|
|
486
342
|
|
|
487
343
|
export type RunnableStepProgram<TInput, TOutput> = Pick<
|
|
488
|
-
|
|
489
|
-
'kind' | 'steps' | 'returnResolver'
|
|
490
|
-
|
|
344
|
+
PlayAuthoringRunnableStepProgram<TOutput, DeeplinePlayRuntimeContext>,
|
|
345
|
+
'kind' | 'steps' | 'returnResolver'
|
|
346
|
+
> & { readonly __inputType?: (input: TInput) => void };
|
|
491
347
|
|
|
492
348
|
/**
|
|
493
349
|
* Builder returned by `ctx.dataset(...)` for row-level durable columns.
|
|
@@ -497,111 +353,26 @@ export type RunnableStepProgram<TInput, TOutput> = Pick<
|
|
|
497
353
|
export type DatasetBuilder<
|
|
498
354
|
InputRow extends object,
|
|
499
355
|
OutputRow extends object,
|
|
500
|
-
> =
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
* @returns The same dataset builder with the new column type.
|
|
513
|
-
*/
|
|
514
|
-
withColumn<Name extends string, Value>(
|
|
515
|
-
name: Name,
|
|
516
|
-
resolver: ColumnResolver<OutputRow, Value>,
|
|
517
|
-
): DatasetBuilder<InputRow, OutputRow & Record<Name, Value>>;
|
|
518
|
-
/**
|
|
519
|
-
* Define one output column with object-column authoring and a row gate.
|
|
520
|
-
*
|
|
521
|
-
* @param name - Output column name.
|
|
522
|
-
* @param definition - Object-column definition with required `runIf`.
|
|
523
|
-
* @returns The same dataset builder with a nullable column type for skipped rows.
|
|
524
|
-
*/
|
|
525
|
-
withColumn<Name extends string, Value>(
|
|
526
|
-
name: Name,
|
|
527
|
-
definition: DatasetColumnDefinition<OutputRow, Value> & {
|
|
528
|
-
readonly runIf: (
|
|
529
|
-
row: OutputRow,
|
|
530
|
-
index: number,
|
|
531
|
-
) => boolean | Promise<boolean>;
|
|
532
|
-
},
|
|
533
|
-
): DatasetBuilder<InputRow, OutputRow & Record<Name, Value | null>>;
|
|
534
|
-
/**
|
|
535
|
-
* Define one output column with object-column authoring.
|
|
536
|
-
*
|
|
537
|
-
* Use this form for typed `previousCell` access.
|
|
538
|
-
*
|
|
539
|
-
* @param name - Output column name.
|
|
540
|
-
* @param definition - Object-column definition.
|
|
541
|
-
* @returns The same dataset builder with the new column type.
|
|
542
|
-
*/
|
|
543
|
-
withColumn<Name extends string, Value>(
|
|
544
|
-
name: Name,
|
|
545
|
-
definition: DatasetColumnDefinition<OutputRow, Value>,
|
|
546
|
-
): DatasetBuilder<InputRow, OutputRow & Record<Name, Value>>;
|
|
547
|
-
/**
|
|
548
|
-
* Define one output column with a resolver plus row-level options.
|
|
549
|
-
*
|
|
550
|
-
* @param name - Output column name.
|
|
551
|
-
* @param resolver - Computes the value for one row.
|
|
552
|
-
* @param options - Row gate options.
|
|
553
|
-
* @returns The same dataset builder with a nullable column type for skipped rows.
|
|
554
|
-
*/
|
|
555
|
-
withColumn<Name extends string, Value>(
|
|
556
|
-
name: Name,
|
|
557
|
-
resolver:
|
|
558
|
-
| StepResolver<OutputRow, Value>
|
|
559
|
-
| StepProgramResolver<OutputRow, Value>,
|
|
560
|
-
options: StepOptions<OutputRow, Value>,
|
|
561
|
-
): DatasetBuilder<InputRow, OutputRow & Record<Name, Value | null>>;
|
|
562
|
-
withColumns<Program extends StepProgram<OutputRow, object, unknown>>(
|
|
563
|
-
program: Program,
|
|
564
|
-
): DatasetBuilder<InputRow, StepProgramOutput<Program>>;
|
|
565
|
-
/** @deprecated Dataset `.step(...)` was replaced by `.withColumn(...)`. */
|
|
566
|
-
step<Name extends string, Value>(
|
|
567
|
-
name: Name,
|
|
568
|
-
resolver: ColumnResolver<OutputRow, Value>,
|
|
569
|
-
): never;
|
|
570
|
-
/**
|
|
571
|
-
* Execute the row-column program and return a durable dataset handle.
|
|
572
|
-
*
|
|
573
|
-
* The returned {@link PlayDataset} preserves one output row per input row,
|
|
574
|
-
* with original fields merged with the columns produced by `.withColumn(...)`.
|
|
575
|
-
*
|
|
576
|
-
* @param options - Run options.
|
|
577
|
-
* @returns Output rows as a dataset handle.
|
|
578
|
-
*/
|
|
579
|
-
run(options?: {
|
|
580
|
-
description?: string;
|
|
581
|
-
/**
|
|
582
|
-
* `upsert` (default) returns every input row, reusing persisted work for
|
|
583
|
-
* existing keys. `net_new` atomically inserts and returns only unseen keys.
|
|
584
|
-
*/
|
|
585
|
-
mode?: 'upsert' | 'net_new';
|
|
586
|
-
key?:
|
|
587
|
-
| (keyof InputRow & string)
|
|
588
|
-
| readonly (keyof InputRow & string)[]
|
|
589
|
-
| ((
|
|
590
|
-
row: InputRow,
|
|
591
|
-
index: number,
|
|
592
|
-
) => string | number | readonly unknown[]);
|
|
593
|
-
}): Promise<PlayDataset<OutputRow>>;
|
|
594
|
-
};
|
|
356
|
+
> = PlayAuthoringDatasetBuilder<
|
|
357
|
+
InputRow,
|
|
358
|
+
OutputRow,
|
|
359
|
+
DeeplinePlayRuntimeContext
|
|
360
|
+
>;
|
|
361
|
+
|
|
362
|
+
export type DatasetRowKey<InputRow extends object> =
|
|
363
|
+
PlayAuthoringDatasetRowKey<InputRow>;
|
|
364
|
+
export type DatasetDefinitionOptions<InputRow extends object> =
|
|
365
|
+
PlayAuthoringDatasetDefinitionOptions<InputRow>;
|
|
366
|
+
export type DatasetRunOptions<InputRow extends object> =
|
|
367
|
+
PlayAuthoringDatasetRunOptions<InputRow>;
|
|
595
368
|
|
|
596
|
-
export type CsvRenameMap =
|
|
369
|
+
export type CsvRenameMap = PlayAuthoringCsvRenameMap;
|
|
597
370
|
|
|
598
371
|
/**
|
|
599
372
|
* Runtime file-like input. At runtime this is the staged file path/reference
|
|
600
373
|
* string. The type parameter carries static metadata for describe/CLI tooling.
|
|
601
374
|
*/
|
|
602
|
-
export type FileInput<TMetadata = unknown> =
|
|
603
|
-
readonly __deeplineFileInputMetadata?: TMetadata;
|
|
604
|
-
};
|
|
375
|
+
export type FileInput<TMetadata = unknown> = PlayAuthoringFileInput<TMetadata>;
|
|
605
376
|
|
|
606
377
|
/**
|
|
607
378
|
* CSV file input whose rows are described by `TRow`.
|
|
@@ -611,30 +382,16 @@ export type FileInput<TMetadata = unknown> = string & {
|
|
|
611
382
|
* discovery.
|
|
612
383
|
*/
|
|
613
384
|
export type CsvInput<TRow extends object = Record<string, unknown>> =
|
|
614
|
-
|
|
615
|
-
readonly kind: 'csv';
|
|
616
|
-
readonly row: TRow;
|
|
617
|
-
}>;
|
|
385
|
+
PlayAuthoringCsvInput<TRow>;
|
|
618
386
|
|
|
619
|
-
export type ColumnMap<TRow extends object> =
|
|
620
|
-
Record<Extract<keyof TRow, string>, string | readonly string[]>
|
|
621
|
-
>;
|
|
387
|
+
export type ColumnMap<TRow extends object> = PlayAuthoringColumnMap<TRow>;
|
|
622
388
|
|
|
623
389
|
/**
|
|
624
390
|
* Options for loading a staged CSV with `ctx.csv(...)`.
|
|
625
391
|
*
|
|
626
392
|
* @sdkReference runtime 050
|
|
627
393
|
*/
|
|
628
|
-
export type CsvOptions =
|
|
629
|
-
/** Human-readable description for runtime logs and inspection. */
|
|
630
|
-
description?: string;
|
|
631
|
-
/** Canonical field-to-header aliases, e.g. `{ domain: ['domain', 'Company Domain'] }`. */
|
|
632
|
-
columns?: CsvRenameMap;
|
|
633
|
-
/** Header rename map; use `columns` for new code. */
|
|
634
|
-
rename?: CsvRenameMap;
|
|
635
|
-
/** Canonical fields that must be present after header normalization. */
|
|
636
|
-
required?: readonly string[];
|
|
637
|
-
};
|
|
394
|
+
export type CsvOptions = PlayAuthoringCsvOptions;
|
|
638
395
|
|
|
639
396
|
/**
|
|
640
397
|
* Runtime context available inside a play function.
|
|
@@ -681,272 +438,7 @@ export type CsvOptions = {
|
|
|
681
438
|
* });
|
|
682
439
|
* ```
|
|
683
440
|
*/
|
|
684
|
-
export
|
|
685
|
-
/**
|
|
686
|
-
* Load a staged CSV file as a durable dataset handle.
|
|
687
|
-
*
|
|
688
|
-
* Use this when a play receives a CSV path from the CLI or API and row work
|
|
689
|
-
* should continue through {@link DeeplinePlayRuntimeContext.dataset}. The path is
|
|
690
|
-
* normally an input field such as `input.csv`, populated by
|
|
691
|
-
* `deepline plays run my.play.ts --csv rows.csv`. Prefer `input.csv` for row
|
|
692
|
-
* data so the CLI can run strict CSV preflight before starting a run.
|
|
693
|
-
* Pass-through flags can also target non-reserved field names. If a play
|
|
694
|
-
* intentionally calls `ctx.csv(input.file)`, use `--input
|
|
695
|
-
* '{"file":"rows.csv"}'` because `--file` is reserved for the play source
|
|
696
|
-
* path.
|
|
697
|
-
*
|
|
698
|
-
* Each CSV row becomes an object keyed by canonical column names. Use
|
|
699
|
-
* `options.columns` / `options.rename` to map user headers such as
|
|
700
|
-
* `"Company Domain"` to stable code fields such as `domain`.
|
|
701
|
-
*
|
|
702
|
-
* @typeParam T - Row type (defaults to `Record<string, unknown>`)
|
|
703
|
-
* @param path - Staged CSV path.
|
|
704
|
-
* @param options - CSV load options.
|
|
705
|
-
*
|
|
706
|
-
* @returns A {@link PlayDataset} whose rows should usually flow directly into `ctx.dataset(...)`.
|
|
707
|
-
*
|
|
708
|
-
* @sdkReference runtime 040 ctx.csv(path, options)
|
|
709
|
-
*/
|
|
710
|
-
csv<T = Record<string, unknown>>(
|
|
711
|
-
path: string,
|
|
712
|
-
options?: CsvOptions,
|
|
713
|
-
): Promise<PlayDataset<T>>;
|
|
714
|
-
|
|
715
|
-
/**
|
|
716
|
-
* Create a persisted row dataset/table from input rows.
|
|
717
|
-
*
|
|
718
|
-
* `ctx.dataset` is Deepline's row-work primitive. It records row identity,
|
|
719
|
-
* progress, retries, table output, and idempotency for a collection of rows.
|
|
720
|
-
* Use `.withColumn(name, resolver)` on the returned builder to define output
|
|
721
|
-
* columns, then `.run(...)` to execute the row program.
|
|
722
|
-
*
|
|
723
|
-
* The `key` identifies the logical dataset/table. Renaming it is a persistence
|
|
724
|
-
* migration: existing rows may no longer be reused. Row identity is derived
|
|
725
|
-
* automatically from input row content unless `.run({ key: ... })` overrides
|
|
726
|
-
* it with stable business fields such as `domain`, `email`, or `linkedin_url`.
|
|
727
|
-
*
|
|
728
|
-
* By default, `ctx.dataset` is row-preserving: one input row produces one output
|
|
729
|
-
* row, with original fields merged with the columns produced by
|
|
730
|
-
* `.withColumn(...)`. If one input entity must become many output rows, use the
|
|
731
|
-
* documented expand/flatten recipe instead of assuming `ctx.dataset` changes
|
|
732
|
-
* row cardinality.
|
|
733
|
-
*
|
|
734
|
-
* @typeParam T - Row type
|
|
735
|
-
* @param key - Dataset/table name.
|
|
736
|
-
* @param items - Input rows.
|
|
737
|
-
* @returns A builder. Calling `.run()` returns a `PlayDataset` of rows plus computed columns.
|
|
738
|
-
*
|
|
739
|
-
* @example Single tool per row
|
|
740
|
-
* ```typescript
|
|
741
|
-
* const results = await ctx
|
|
742
|
-
* .dataset('companies', leads)
|
|
743
|
-
* .withColumn('company', (row, ctx) =>
|
|
744
|
-
* ctx.tools.execute({
|
|
745
|
-
* id: 'company_search',
|
|
746
|
-
* tool: 'test_company_search',
|
|
747
|
-
* input: { domain: row.domain },
|
|
748
|
-
* description: 'Look up company details by domain.',
|
|
749
|
-
* }))
|
|
750
|
-
* .run({ description: 'Look up companies.' });
|
|
751
|
-
* // [{ domain: 'stripe.com', company: { name: 'Stripe', ... } }, ...]
|
|
752
|
-
* ```
|
|
753
|
-
*
|
|
754
|
-
* @example Multiple columns with pre/post logic
|
|
755
|
-
* ```typescript
|
|
756
|
-
* const results = await ctx
|
|
757
|
-
* .dataset('leads', leads)
|
|
758
|
-
* .withColumn('company', (row, ctx) =>
|
|
759
|
-
* ctx.tools.execute({
|
|
760
|
-
* id: 'company_search',
|
|
761
|
-
* tool: 'test_company_search',
|
|
762
|
-
* input: { domain: row.domain },
|
|
763
|
-
* description: 'Look up company details by domain.',
|
|
764
|
-
* }))
|
|
765
|
-
* .withColumn('score', (row) =>
|
|
766
|
-
* row.company?.employeeCount > 100 ? 'enterprise' : 'smb')
|
|
767
|
-
* .run({ description: 'Enrich leads.' });
|
|
768
|
-
* ```
|
|
769
|
-
*
|
|
770
|
-
* @sdkReference runtime 060 ctx.dataset(key, items)
|
|
771
|
-
*/
|
|
772
|
-
dataset<TSource extends PlayDatasetInput<object>>(
|
|
773
|
-
key: string,
|
|
774
|
-
items: TSource,
|
|
775
|
-
): DatasetBuilder<
|
|
776
|
-
PlayDatasetRow<TSource> & object,
|
|
777
|
-
PlayDatasetRow<TSource> & object
|
|
778
|
-
>;
|
|
779
|
-
/**
|
|
780
|
-
* @deprecated `ctx.map(...)` was replaced by `ctx.dataset(...)`.
|
|
781
|
-
*/
|
|
782
|
-
map<TSource extends PlayDatasetInput<object>>(
|
|
783
|
-
key: string,
|
|
784
|
-
items: TSource,
|
|
785
|
-
): never;
|
|
786
|
-
|
|
787
|
-
/** Tool execution namespace. */
|
|
788
|
-
tools: {
|
|
789
|
-
/**
|
|
790
|
-
* Execute a single tool with a keyword-style request object.
|
|
791
|
-
*
|
|
792
|
-
* @param request - Tool call request.
|
|
793
|
-
* @returns Tool execution result.
|
|
794
|
-
*
|
|
795
|
-
* @sdkReference runtime 150 ctx.tools.execute(request)
|
|
796
|
-
*/
|
|
797
|
-
execute<TOutput = LoosePlayObject>(
|
|
798
|
-
request: ToolExecutionRequest,
|
|
799
|
-
): Promise<ToolExecuteResult<TOutput>>;
|
|
800
|
-
};
|
|
801
|
-
/** Customer DB query namespace for play handlers. */
|
|
802
|
-
customerDb: {
|
|
803
|
-
query<TRow extends object = Record<string, unknown>>(
|
|
804
|
-
statement: SqlQuery | string,
|
|
805
|
-
options?: {
|
|
806
|
-
maxRows?: number;
|
|
807
|
-
timeoutMs?: number;
|
|
808
|
-
},
|
|
809
|
-
): Promise<TRow[]>;
|
|
810
|
-
};
|
|
811
|
-
/**
|
|
812
|
-
* Execute a single tool by stable step key and tool ID.
|
|
813
|
-
*
|
|
814
|
-
* Shorthand for `ctx.tools.execute(...)`; this is the preferred spelling in
|
|
815
|
-
* row-level step programs.
|
|
816
|
-
*/
|
|
817
|
-
tool<TOutput = LoosePlayObject>(
|
|
818
|
-
key: string,
|
|
819
|
-
toolId: string,
|
|
820
|
-
input: Record<string, unknown>,
|
|
821
|
-
options?: { description?: string },
|
|
822
|
-
): Promise<ToolExecuteResult<TOutput>>;
|
|
823
|
-
/**
|
|
824
|
-
* Run a reusable step program against one scalar input object.
|
|
825
|
-
*
|
|
826
|
-
* `steps().step(...)` is a composable mini-pipeline. Use `ctx.runSteps(...)`
|
|
827
|
-
* when that mini-pipeline should execute outside a row dataset. Inside a
|
|
828
|
-
* `ctx.dataset` column resolver, pass the step program directly to
|
|
829
|
-
* `.withColumn(name, program)` instead.
|
|
830
|
-
*
|
|
831
|
-
* @param program - Step program.
|
|
832
|
-
* @param input - Program input.
|
|
833
|
-
* @param options - Run options.
|
|
834
|
-
* @returns Program output.
|
|
835
|
-
*
|
|
836
|
-
* @sdkReference runtime 180 ctx.runSteps(program, input, options)
|
|
837
|
-
*/
|
|
838
|
-
runSteps<TInput extends Record<string, unknown>, TOutput>(
|
|
839
|
-
program: RunnableStepProgram<TInput, TOutput>,
|
|
840
|
-
input: TInput,
|
|
841
|
-
options?: { description?: string },
|
|
842
|
-
): Promise<TOutput>;
|
|
843
|
-
/**
|
|
844
|
-
* Create one scalar checkpoint for the whole play run.
|
|
845
|
-
*
|
|
846
|
-
* Use `ctx.step` when a value is nondeterministic, expensive, external, or
|
|
847
|
-
* useful to inspect as a named boundary. The first execution stores the
|
|
848
|
-
* JSON-serializable output under `id`; replay and retries return the stored
|
|
849
|
-
* value instead of running `run` again.
|
|
850
|
-
*
|
|
851
|
-
* Plain deterministic assignment does not need `ctx.step`. Use
|
|
852
|
-
* `ctx.dataset(...).withColumn(...)`, not `ctx.step`, when the value should become a
|
|
853
|
-
* field on each exported row.
|
|
854
|
-
*
|
|
855
|
-
* @param id - Checkpoint id.
|
|
856
|
-
* @param run - Computes the value once.
|
|
857
|
-
* @param options - Checkpoint options.
|
|
858
|
-
* @returns Checkpoint value.
|
|
859
|
-
*
|
|
860
|
-
* @sdkReference runtime 130 ctx.step(id, fn)
|
|
861
|
-
*/
|
|
862
|
-
step<T>(
|
|
863
|
-
id: string,
|
|
864
|
-
run: () => T | Promise<T>,
|
|
865
|
-
options?: { staleAfterSeconds?: number },
|
|
866
|
-
): Promise<T>;
|
|
867
|
-
/**
|
|
868
|
-
* Durable HTTP fetch.
|
|
869
|
-
*
|
|
870
|
-
* Use this for non-provider HTTP calls that must replay safely. The response
|
|
871
|
-
* is recorded under `key` so workflow replay sees the same value. Prefer
|
|
872
|
-
* `ctx.tools.execute(...)` for Deepline-managed provider APIs because tools
|
|
873
|
-
* handle auth, retries, rate limits, extraction metadata, and spend tracking.
|
|
874
|
-
* If `init.auth` comes from `ctx.secrets`, `url` must be https://.
|
|
875
|
-
*
|
|
876
|
-
* @param key - Checkpoint id.
|
|
877
|
-
* @param url - URL to fetch.
|
|
878
|
-
* @param init - Fetch options.
|
|
879
|
-
* @returns Recorded response.
|
|
880
|
-
*
|
|
881
|
-
* @sdkReference runtime 170 ctx.fetch(key, url, init)
|
|
882
|
-
*/
|
|
883
|
-
fetch(
|
|
884
|
-
key: string,
|
|
885
|
-
url: string | URL,
|
|
886
|
-
init?: SecretAwareRequestInit,
|
|
887
|
-
options?: { staleAfterSeconds?: number },
|
|
888
|
-
): Promise<{
|
|
889
|
-
ok: boolean;
|
|
890
|
-
status: number;
|
|
891
|
-
statusText: string;
|
|
892
|
-
url: string;
|
|
893
|
-
headers: Record<string, string>;
|
|
894
|
-
bodyText: string;
|
|
895
|
-
json: unknown | null;
|
|
896
|
-
}>;
|
|
897
|
-
secrets: {
|
|
898
|
-
get(name: string): SecretHandle;
|
|
899
|
-
bearer(secret: SecretHandle): SecretAuth;
|
|
900
|
-
header(header: string, secret: SecretHandle): SecretAuth;
|
|
901
|
-
};
|
|
902
|
-
/**
|
|
903
|
-
* Invoke another registered or file-backed play as a child workflow.
|
|
904
|
-
*
|
|
905
|
-
* Use this for real composition boundaries, especially when a fitting
|
|
906
|
-
* scalar prebuilt play already encodes provider order, fallbacks,
|
|
907
|
-
* normalization, and no-result behavior. Do not invoke plays through
|
|
908
|
-
* `ctx.tools.execute`; tools and plays are separate namespaces.
|
|
909
|
-
*
|
|
910
|
-
* `key` is the stable child-call identity for idempotency and traceability.
|
|
911
|
-
*
|
|
912
|
-
* @param key - Stable child-call key.
|
|
913
|
-
* @param playRef - Registered play name, play handle, or file-backed play reference.
|
|
914
|
-
* @param input - Input object passed to the child play.
|
|
915
|
-
* @param options - Child play options.
|
|
916
|
-
* @returns Child play output.
|
|
917
|
-
*
|
|
918
|
-
* @sdkReference runtime 140 ctx.runPlay(key, playRef, input, options)
|
|
919
|
-
*/
|
|
920
|
-
runPlay<TOutput = unknown>(
|
|
921
|
-
key: string,
|
|
922
|
-
playRef: string | PlayReferenceLike,
|
|
923
|
-
input: Record<string, unknown>,
|
|
924
|
-
options?: PlayCallOptions,
|
|
925
|
-
): Promise<TOutput>;
|
|
926
|
-
|
|
927
|
-
/**
|
|
928
|
-
* Emit a log line visible in `play tail` and the play's progress logs.
|
|
929
|
-
*
|
|
930
|
-
* @param message - Log message (plain text)
|
|
931
|
-
*/
|
|
932
|
-
log(message: string): void;
|
|
933
|
-
|
|
934
|
-
/**
|
|
935
|
-
* Pause play execution for the specified duration.
|
|
936
|
-
*
|
|
937
|
-
* Uses Temporal's durable timer — safe across worker restarts.
|
|
938
|
-
*
|
|
939
|
-
* @param ms - Duration in milliseconds
|
|
940
|
-
*/
|
|
941
|
-
sleep(ms: number): Promise<void>;
|
|
942
|
-
|
|
943
|
-
/**
|
|
944
|
-
* @deprecated Read submitted play input from the handler's second argument:
|
|
945
|
-
* `definePlay('example', async (ctx, input) => ...)`. This legacy field is
|
|
946
|
-
* not the supported V2 play input API.
|
|
947
|
-
*/
|
|
948
|
-
readonly input: Record<string, unknown>;
|
|
949
|
-
}
|
|
441
|
+
export type DeeplinePlayRuntimeContext = PlayAuthoringRuntimeContext;
|
|
950
442
|
|
|
951
443
|
/**
|
|
952
444
|
* Handle to a running play execution.
|
|
@@ -1157,10 +649,7 @@ export type PrebuiltPlayRef = {
|
|
|
1157
649
|
readonly name: string;
|
|
1158
650
|
};
|
|
1159
651
|
|
|
1160
|
-
export type PlayReferenceLike =
|
|
1161
|
-
readonly playName?: string;
|
|
1162
|
-
readonly name?: string;
|
|
1163
|
-
};
|
|
652
|
+
export type PlayReferenceLike = PlayAuthoringReferenceLike;
|
|
1164
653
|
|
|
1165
654
|
export type {
|
|
1166
655
|
PlayDataset,
|
|
@@ -1168,14 +657,8 @@ export type {
|
|
|
1168
657
|
PlayDatasetRow,
|
|
1169
658
|
} from '../../shared_libs/plays/dataset.js';
|
|
1170
659
|
|
|
1171
|
-
export type PlayReturnObject =
|
|
1172
|
-
|
|
1173
|
-
};
|
|
1174
|
-
|
|
1175
|
-
export type PlayInputContract<TInput> = {
|
|
1176
|
-
readonly schema: Record<string, unknown>;
|
|
1177
|
-
readonly __inputType?: TInput;
|
|
1178
|
-
};
|
|
660
|
+
export type PlayReturnObject = PlayAuthoringReturnObject;
|
|
661
|
+
export type PlayInputContract<TInput> = PlayAuthoringInputContract<TInput>;
|
|
1179
662
|
|
|
1180
663
|
/**
|
|
1181
664
|
* Object-form play definition accepted by `definePlay(config)`.
|
|
@@ -1187,24 +670,10 @@ export type PlayInputContract<TInput> = {
|
|
|
1187
670
|
*
|
|
1188
671
|
* @sdkReference runtime 020
|
|
1189
672
|
*/
|
|
1190
|
-
export type DefinePlayConfig<
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
description?: string;
|
|
1195
|
-
/** Input schema. */
|
|
1196
|
-
input: PlayInputContract<TInput>;
|
|
1197
|
-
/** Play function. */
|
|
1198
|
-
run: (ctx: DeeplinePlayRuntimeContext, input: TInput) => Promise<TOutput>;
|
|
1199
|
-
/** Trigger bindings. */
|
|
1200
|
-
bindings?: PlayBindings;
|
|
1201
|
-
/** Billing options. */
|
|
1202
|
-
billing?: PlayBindings['billing'];
|
|
1203
|
-
/** Requested prebuilt sandbox and runtime deadline. */
|
|
1204
|
-
runtime?: PlayBindings['runtime'];
|
|
1205
|
-
/** Runtime compatibility override. Omit for the current typed contract. */
|
|
1206
|
-
compatibility?: PlayBindings['compatibility'];
|
|
1207
|
-
};
|
|
673
|
+
export type DefinePlayConfig<
|
|
674
|
+
TInput,
|
|
675
|
+
TOutput extends PlayReturnObject,
|
|
676
|
+
> = PlayAuthoringDefineConfig<TInput, TOutput, DeeplinePlayRuntimeContext>;
|
|
1208
677
|
|
|
1209
678
|
class DeeplineConditionalStepResolver<
|
|
1210
679
|
Row,
|
|
@@ -1356,20 +825,15 @@ export function runIf<Row, Value>(
|
|
|
1356
825
|
* console.log(myPlay.bindings); // undefined (no cron/webhook)
|
|
1357
826
|
* ```
|
|
1358
827
|
*/
|
|
1359
|
-
export type DefinedPlay<
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
/** Runtime compatibility explicitly selected by the author. */
|
|
1369
|
-
readonly compatibility?: PlayBindings['compatibility'];
|
|
1370
|
-
/** The play's name (same as `.name`). */
|
|
1371
|
-
readonly playName: string;
|
|
1372
|
-
};
|
|
828
|
+
export type DefinedPlay<
|
|
829
|
+
TInput,
|
|
830
|
+
TOutput extends PlayReturnObject,
|
|
831
|
+
> = PlayAuthoringDefinedPlay<
|
|
832
|
+
TInput,
|
|
833
|
+
TOutput,
|
|
834
|
+
DeeplinePlayRuntimeContext,
|
|
835
|
+
DeeplineNamedPlay<TInput, TOutput>
|
|
836
|
+
>;
|
|
1373
837
|
|
|
1374
838
|
type PlayMetadata = {
|
|
1375
839
|
name: string;
|
|
@@ -2017,12 +1481,7 @@ function toolExecutionEnvelopeToResult(
|
|
|
2017
1481
|
export function defineInput<TInput>(
|
|
2018
1482
|
schema: Record<string, unknown>,
|
|
2019
1483
|
): PlayInputContract<TInput> {
|
|
2020
|
-
|
|
2021
|
-
throw new Error(
|
|
2022
|
-
'defineInput<T>(schema) requires a JSON-schema-like object.',
|
|
2023
|
-
);
|
|
2024
|
-
}
|
|
2025
|
-
return { schema };
|
|
1484
|
+
return createPlayInputContract<TInput>(schema);
|
|
2026
1485
|
}
|
|
2027
1486
|
|
|
2028
1487
|
/**
|