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.
Files changed (34) hide show
  1. package/dist/bundling-sources/sdk/src/index.ts +3 -0
  2. package/dist/bundling-sources/sdk/src/play.ts +150 -691
  3. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  4. package/dist/bundling-sources/shared_libs/play-runtime/child-execution-strategy.ts +7 -1
  5. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +249 -51
  6. package/dist/bundling-sources/shared_libs/play-runtime/csv-rename.ts +10 -6
  7. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +32 -51
  8. package/dist/bundling-sources/shared_libs/play-runtime/durable-call-cache.ts +11 -22
  9. package/dist/bundling-sources/shared_libs/play-runtime/durable-call-policy.ts +34 -0
  10. package/dist/bundling-sources/shared_libs/play-runtime/play-call-execution.ts +2 -1
  11. package/dist/bundling-sources/shared_libs/play-runtime/run-ledger-projection-contract.ts +95 -0
  12. package/dist/bundling-sources/shared_libs/play-runtime/secret-capability.ts +23 -15
  13. package/dist/bundling-sources/shared_libs/plays/artifact-types.ts +3 -0
  14. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +2222 -0
  15. package/dist/bundling-sources/shared_libs/plays/bundling/index.ts +3 -2
  16. package/dist/bundling-sources/shared_libs/plays/compiler-manifest.ts +2 -0
  17. package/dist/bundling-sources/shared_libs/plays/contracts.ts +16 -0
  18. package/dist/bundling-sources/shared_libs/plays/input-contract-definition.ts +28 -0
  19. package/dist/bundling-sources/shared_libs/plays/input-contract.ts +3 -3
  20. package/dist/cli/index.js +5074 -829
  21. package/dist/cli/index.mjs +5019 -759
  22. package/dist/compiler-manifest-xFkbJX2B.d.mts +2517 -0
  23. package/dist/compiler-manifest-xFkbJX2B.d.ts +2517 -0
  24. package/dist/index.d.mts +36 -1011
  25. package/dist/index.d.ts +36 -1011
  26. package/dist/index.js +25 -7
  27. package/dist/index.mjs +25 -7
  28. package/dist/plays/bundle-play-file.d.mts +5 -8
  29. package/dist/plays/bundle-play-file.d.ts +5 -8
  30. package/dist/plays/bundle-play-file.mjs +3844 -3
  31. package/package.json +1 -1
  32. package/dist/bundling-sources/shared_libs/plays/source-metadata.ts +0 -240
  33. package/dist/tool-execution-error-4-rhemLQ.d.mts +0 -446
  34. package/dist/tool-execution-error-4-rhemLQ.d.ts +0 -446
@@ -1,446 +0,0 @@
1
- declare const PLAY_RUNTIME_BACKENDS: {
2
- readonly localProcess: "local_process";
3
- readonly daytona: "daytona";
4
- readonly modal: "modal";
5
- };
6
- type PlayRuntimeBackendId = (typeof PLAY_RUNTIME_BACKENDS)[keyof typeof PLAY_RUNTIME_BACKENDS];
7
- /**
8
- * The one executable Play artifact contract. Daytona and local-process both
9
- * load CommonJS under Node 20.
10
- */
11
- declare const PLAY_ARTIFACT_KINDS: {
12
- readonly cjsNode20: "cjs_node20";
13
- };
14
- type PlayArtifactKind = (typeof PLAY_ARTIFACT_KINDS)[keyof typeof PLAY_ARTIFACT_KINDS];
15
-
16
- /**
17
- * A top-level key the play's function literally `return`s. Derived from the
18
- * `return { ... }` object literal — NOT from dataset `.withColumn(...)` names —
19
- * so the "Returns" graph node mirrors the function's real output shape.
20
- * `isDataset` is true when the key's value is a `PlayDataset` handle (a table).
21
- */
22
- interface PlayStaticReturnField {
23
- name: string;
24
- isDataset: boolean;
25
- /**
26
- * For a dataset-valued field, the `ctx.dataset(KEY, ...)` key backing it
27
- * (e.g. `job_change_checks`) — so the UI can label the return by the dataset
28
- * it actually produces instead of the bland object key (`rows`). Undefined
29
- * for non-dataset fields, `ctx.csv(...)` (no durable name), or when the key
30
- * isn't a static string literal.
31
- */
32
- datasetName?: string;
33
- }
34
- interface PlayStaticPipeline {
35
- tableNamespace?: string;
36
- inputFields?: string[];
37
- rowKeyFields?: string[];
38
- csvArg?: string;
39
- hasInlineData?: boolean;
40
- csvDescription?: string;
41
- datasetDescription?: string;
42
- fields: string[];
43
- /**
44
- * Top-level keys of the play's `return { ... }` object literal, in source
45
- * order. Undefined when the terminal return isn't a statically-known object
46
- * literal (bare value, dataset handle, conditional returns, etc.).
47
- */
48
- returnFields?: PlayStaticReturnField[];
49
- stages?: PlayStaticSubstep[];
50
- substeps: PlayStaticSubstep[];
51
- sheetContract?: PlaySheetContract | null;
52
- sheetContractErrors?: string[];
53
- }
54
- type PlaySheetColumnSource = 'input' | 'datasetColumn' | 'waterfallStep' | 'childPlayColumn';
55
- interface PlaySheetColumnContract {
56
- id: string;
57
- sqlName: string;
58
- source: PlaySheetColumnSource;
59
- field?: string;
60
- parentField?: string;
61
- playId?: string;
62
- waterfallId?: string;
63
- outputField?: string;
64
- outputSqlName?: string;
65
- stepId?: string;
66
- toolId?: string;
67
- isRowKey?: boolean;
68
- }
69
- interface PlaySheetContract {
70
- tableNamespace: string;
71
- columns: PlaySheetColumnContract[];
72
- }
73
- type PlayStaticColumnProducerKind = 'tool' | 'waterfall' | 'stepProgram' | 'playCall' | 'controlFlow' | 'transform';
74
- interface PlayStaticColumnProducer {
75
- id: string;
76
- kind: PlayStaticColumnProducerKind;
77
- field: string;
78
- toolId?: string;
79
- playId?: string;
80
- conditional?: boolean;
81
- sourceRange?: PlayStaticSourceRange;
82
- steps?: PlayStaticColumnProducer[];
83
- substep: PlayStaticSubstep;
84
- }
85
- interface PlayStaticDatasetColumn {
86
- id: string;
87
- source: PlaySheetColumnSource;
88
- sqlName?: string;
89
- producers: PlayStaticColumnProducer[];
90
- }
91
- interface PlayStaticSourceRange {
92
- sourcePath?: string;
93
- startLine: number;
94
- endLine: number;
95
- startColumn: number;
96
- endColumn: number;
97
- }
98
- type PlayStaticSubstepMetadata = {
99
- conditional?: boolean;
100
- disabled?: boolean;
101
- };
102
- /**
103
- * One arm of a conditional `control_flow` substep — an `if`/`else if`/`else`
104
- * leg, a `switch` case, or a ternary branch. Carries its own steps so the graph
105
- * can render the conditional as a real fork instead of a flat strip.
106
- */
107
- type PlayStaticControlFlowBranch = {
108
- /** Short arm label, e.g. `if`, `else if`, `else`, `case 'x'`, `default`. */
109
- label: string;
110
- /** The arm's condition source text, when it has one (omitted for `else`). */
111
- condition?: string;
112
- /** Static work in this arm. Empty for log/throw/return-only arms. */
113
- steps: PlayStaticSubstep[];
114
- };
115
- type PlayStaticSubstep = PlayStaticSubstepMetadata & ({
116
- type: 'csv';
117
- field: string;
118
- path?: string;
119
- description?: string;
120
- sourceRange?: PlayStaticSourceRange;
121
- callDepth?: number;
122
- callPath?: string[];
123
- } | {
124
- type: 'dataset';
125
- field: string;
126
- name?: string;
127
- tableNamespace?: string;
128
- inputFields?: string[];
129
- rowKeyFields?: string[];
130
- outputFields?: string[];
131
- columns?: PlayStaticDatasetColumn[];
132
- waterfallIds?: string[];
133
- steps?: PlayStaticSubstep[];
134
- sheetContract?: PlaySheetContract | null;
135
- description?: string;
136
- sourceRange?: PlayStaticSourceRange;
137
- callDepth?: number;
138
- callPath?: string[];
139
- } | {
140
- type: 'tool';
141
- toolId: string;
142
- field: string;
143
- paramsSource?: string;
144
- sourceText?: string;
145
- description?: string;
146
- inLoop?: boolean;
147
- isEventWait?: boolean;
148
- sourceRange?: PlayStaticSourceRange;
149
- callDepth?: number;
150
- callPath?: string[];
151
- } | {
152
- type: 'waterfall';
153
- tool?: string;
154
- field: string;
155
- inLoop?: boolean;
156
- id?: string;
157
- output?: string;
158
- minResults?: number;
159
- sourceText?: string;
160
- steps?: Array<{
161
- id: string;
162
- kind?: 'tool' | 'code';
163
- toolId?: string;
164
- paramsSource?: string;
165
- }>;
166
- description?: string;
167
- sourceRange?: PlayStaticSourceRange;
168
- callDepth?: number;
169
- callPath?: string[];
170
- } | {
171
- type: 'step_suite';
172
- field: string;
173
- steps: PlayStaticSubstep[];
174
- returnSource?: string;
175
- description?: string;
176
- sourceRange?: PlayStaticSourceRange;
177
- callDepth?: number;
178
- callPath?: string[];
179
- } | {
180
- type: 'play_call';
181
- playId: string;
182
- execution?: 'inline' | 'child-workflow';
183
- timeoutMs?: number;
184
- hasExplicitTimeout?: boolean;
185
- field: string;
186
- inLoop?: boolean;
187
- pipeline?: PlayStaticPipeline | null;
188
- cycleDetected?: boolean;
189
- resolutionError?: string;
190
- description?: string;
191
- sourceRange?: PlayStaticSourceRange;
192
- callDepth?: number;
193
- callPath?: string[];
194
- } | {
195
- type: 'control_flow';
196
- kind: 'conditional' | 'loop';
197
- field: string;
198
- /** Flattened steps across every arm, in source order (back-compat). */
199
- steps: PlayStaticSubstep[];
200
- /** Discriminant source text (the `if`/ternary test, `switch` subject). */
201
- condition?: string;
202
- /** Per-arm breakdown for conditionals; omitted for loops. */
203
- branches?: PlayStaticControlFlowBranch[];
204
- description?: string;
205
- sourceRange?: PlayStaticSourceRange;
206
- callDepth?: number;
207
- callPath?: string[];
208
- } | {
209
- type: 'run_javascript';
210
- alias: string;
211
- sourceText?: string;
212
- description?: string;
213
- sourceRange?: PlayStaticSourceRange;
214
- callDepth?: number;
215
- callPath?: string[];
216
- } | {
217
- type: 'code';
218
- field: string;
219
- sourceText?: string;
220
- description?: string;
221
- sourceRange?: PlayStaticSourceRange;
222
- callDepth?: number;
223
- callPath?: string[];
224
- });
225
-
226
- type PlayCompilerDependencyManifest = {
227
- playName: string;
228
- /** Original source path for direct imported definePlay dependencies. */
229
- filePath?: string;
230
- sourceHash: string;
231
- graphHash: string;
232
- artifactHash: string;
233
- staticPipeline: PlayStaticPipeline;
234
- };
235
- type PlayCompilerManifest = {
236
- compilerVersion: number;
237
- playName: string;
238
- sourceHash: string;
239
- graphHash: string;
240
- artifactHash: string;
241
- artifactKind?: PlayArtifactKind;
242
- staticPipeline: PlayStaticPipeline;
243
- importedPlayDependencies: PlayCompilerDependencyManifest[];
244
- };
245
-
246
- declare const TOOL_EXECUTION_ERROR_SCHEMA_VERSION: 1;
247
- declare const SUPPORTED_TOOL_EXECUTION_ERROR_SCHEMA_VERSIONS: readonly [0, 1];
248
- type ToolExecutionErrorSchemaVersion = (typeof SUPPORTED_TOOL_EXECUTION_ERROR_SCHEMA_VERSIONS)[number];
249
- /**
250
- * The boundary responsible for a failed tool call.
251
- *
252
- * Use `provider` to distinguish a provider answer from caller input and
253
- * Deepline infrastructure. `unknown` fails closed and must not trigger a
254
- * waterfall fallback.
255
- *
256
- * @sdkReference errors 020
257
- */
258
- type ToolExecutionErrorOrigin = 'caller' | 'provider' | 'deepline' | 'unknown';
259
- /**
260
- * The stable reason family for a failed tool call.
261
- *
262
- * Branch on this field only after narrowing to `ToolExecutionError`. Catch
263
- * `ProviderTransientError` when the policy is simply “try the next read
264
- * provider”; it is the safer and shorter waterfall contract.
265
- *
266
- * @sdkReference errors 030
267
- */
268
- type ToolExecutionErrorCategory = 'validation' | 'authentication' | 'authorization' | 'rate_limit' | 'network' | 'upstream' | 'billing' | 'conflict' | 'internal' | 'unknown';
269
- /**
270
- * The transport failure observed when `category` is `network`.
271
- *
272
- * This is `null` for failures that are not network failures.
273
- *
274
- * @sdkReference errors 040
275
- */
276
- type ToolExecutionNetworkKind = 'timeout' | 'dns' | 'connect' | 'reset' | 'unavailable' | 'unknown';
277
- /**
278
- * The request boundary on which a network failure occurred.
279
- *
280
- * `deepline_to_provider` is provider-side. Client and runtime scopes are
281
- * Deepline transport failures and never qualify as provider fallthrough.
282
- *
283
- * @sdkReference errors 050
284
- */
285
- type ToolExecutionNetworkScope = 'client_to_deepline' | 'runtime_to_deepline' | 'deepline_to_provider';
286
- /**
287
- * Portable version-1 `tool_error` payload.
288
- *
289
- * This allowlisted shape crosses the API, runtime, and SDK boundaries.
290
- * `message` remains on the Error object and is deliberately not a policy
291
- * field.
292
- *
293
- * @sdkReference errors 064
294
- */
295
- type ToolExecutionFailureV1 = {
296
- /** Payload version. */
297
- schemaVersion: typeof TOOL_EXECUTION_ERROR_SCHEMA_VERSION;
298
- /** Public tool id passed to `tools.execute`. */
299
- toolId: string;
300
- /** Provider responsible for the operation, or `null`. */
301
- provider: string | null;
302
- /** Provider operation name, or `null`. */
303
- operation: string | null;
304
- /** Stable machine-readable failure code, or `null`. */
305
- code: string | null;
306
- /** Boundary responsible for the failure. */
307
- origin: ToolExecutionErrorOrigin;
308
- /** Stable reason family. */
309
- category: ToolExecutionErrorCategory;
310
- /** Whether repeating the same semantic call is delivery-safe. */
311
- retryable: boolean;
312
- /** HTTP status when one exists, or `null`. */
313
- statusCode: number | null;
314
- /** Provider or Deepline request id, or `null`. */
315
- requestId: string | null;
316
- /** Suggested same-call retry delay in milliseconds, or `null`. */
317
- retryAfterMs: number | null;
318
- /** Network failure kind, or `null`. */
319
- networkKind: ToolExecutionNetworkKind | null;
320
- /** Network boundary that failed, or `null`. */
321
- networkScope: ToolExecutionNetworkScope | null;
322
- };
323
- /**
324
- * Constructor input for a structured tool failure.
325
- *
326
- * Deepline creates these values while decoding the versioned wire payload.
327
- * Customer code normally reads `ToolExecutionError` fields instead of
328
- * constructing an error.
329
- *
330
- * @sdkReference errors 065
331
- */
332
- type ToolExecutionErrorOptions = Omit<ToolExecutionFailureV1, 'schemaVersion'> & {
333
- /**
334
- * Local diagnostic context inherited from DeeplineError. This is not part of
335
- * the portable failure payload and is intentionally omitted by serialization.
336
- */
337
- details?: Record<string, unknown>;
338
- };
339
- /**
340
- * Provider-owned failure categories that may fall through to another read
341
- * provider.
342
- *
343
- * @sdkReference errors 060
344
- */
345
- type ProviderTransientErrorCategory = 'rate_limit' | 'network' | 'upstream';
346
- /**
347
- * Base error class shared by the SDK and play runtime.
348
- *
349
- * The global brand preserves `instanceof DeeplineError` when a bundled play
350
- * and the runtime load separate physical copies of this module.
351
- *
352
- * @sdkReference errors 010
353
- */
354
- declare class DeeplineError extends Error {
355
- /** HTTP status when the failure crossed an HTTP boundary. */
356
- statusCode?: number;
357
- /** Stable machine-readable error code when one exists. */
358
- code?: string;
359
- /** Local diagnostic context; not a portable error contract. */
360
- details?: Record<string, unknown>;
361
- /**
362
- * Construct a Deepline error.
363
- *
364
- * SDK and runtime code construct these errors. Application and Play code
365
- * normally catches the public subclasses instead.
366
- *
367
- * @param message Human-readable failure summary.
368
- * @param statusCode HTTP status when one exists.
369
- * @param code Stable machine-readable code when one exists.
370
- * @param details Local diagnostic context; never a portable error contract.
371
- */
372
- constructor(message: string, statusCode?: number, code?: string, details?: Record<string, unknown>);
373
- static [Symbol.hasInstance](value: unknown): boolean;
374
- }
375
- /**
376
- * A failed `tools.execute` call with stable, allowlisted provenance.
377
- *
378
- * `retryable` means Deepline's delivery/idempotency contract says it is safe
379
- * to repeat the same semantic call. It does not describe durable receipt
380
- * repairability and does not make arbitrary side-effecting fallbacks safe.
381
- *
382
- * In a Play, catch `ProviderTransientError` to continue a read waterfall and
383
- * let every other `ToolExecutionError` remain loud. In an SDK client, catch
384
- * this base class when you need structured diagnostics for every tool failure.
385
- *
386
- * @sdkReference errors 070
387
- */
388
- declare class ToolExecutionError extends DeeplineError {
389
- /** Public tool id passed to `tools.execute`. */
390
- readonly toolId: string;
391
- /** Provider responsible for the operation, or `null` when unattributed. */
392
- readonly provider: string | null;
393
- /** Provider operation name, or `null` when unavailable. */
394
- readonly operation: string | null;
395
- /** Boundary responsible for the failure. */
396
- readonly origin: ToolExecutionErrorOrigin;
397
- /** Stable reason family for policy and diagnostics. */
398
- readonly category: ToolExecutionErrorCategory;
399
- /**
400
- * Whether repeating the same semantic call is delivery-safe.
401
- *
402
- * This does not mean the error may be ignored. Waterfall fallthrough is
403
- * represented by `ProviderTransientError`.
404
- */
405
- readonly retryable: boolean;
406
- /** Provider or Deepline request id, or `null` when unavailable. */
407
- readonly requestId: string | null;
408
- /** Suggested same-call retry delay in milliseconds, or `null`. */
409
- readonly retryAfterMs: number | null;
410
- /** Network failure kind, or `null` for non-network failures. */
411
- readonly networkKind: ToolExecutionNetworkKind | null;
412
- /** Network boundary that failed, or `null` for non-network failures. */
413
- readonly networkScope: ToolExecutionNetworkScope | null;
414
- /**
415
- * Construct a structured tool error.
416
- *
417
- * Deepline constructs this from the versioned `tool_error` payload.
418
- * Application and Play code should catch it rather than create it.
419
- */
420
- constructor(message: string, options: ToolExecutionErrorOptions);
421
- static [Symbol.hasInstance](value: unknown): boolean;
422
- }
423
- /**
424
- * A provider-owned transient failure that is safe to handle as an empty
425
- * waterfall leg. Validation, auth, billing, Deepline, and unknown failures
426
- * never satisfy this type.
427
- *
428
- * `retryable` remains independent: it says whether the same semantic call may
429
- * be repeated safely. Falling through to a different read provider depends on
430
- * this class, not on `retryable`.
431
- *
432
- * @sdkReference errors 080
433
- */
434
- declare class ProviderTransientError extends ToolExecutionError {
435
- /** Provider attribution is guaranteed for this subtype. */
436
- readonly origin: "provider";
437
- /** Provider failure category that made this error eligible for fallthrough. */
438
- readonly category: ProviderTransientErrorCategory;
439
- /** Constructed by Deepline when a provider-owned transient failure arrives. */
440
- constructor(message: string, options: Omit<ToolExecutionErrorOptions, 'origin' | 'category'> & {
441
- category: ProviderTransientErrorCategory;
442
- });
443
- static [Symbol.hasInstance](value: unknown): boolean;
444
- }
445
-
446
- export { DeeplineError as D, type PlayArtifactKind as P, type ToolExecutionErrorSchemaVersion as T, type PlayCompilerManifest as a, PLAY_ARTIFACT_KINDS as b, type PlayRuntimeBackendId as c, ToolExecutionError as d, type ToolExecutionErrorOptions as e, ProviderTransientError as f, type ProviderTransientErrorCategory as g, type ToolExecutionErrorCategory as h, type ToolExecutionErrorOrigin as i, type ToolExecutionFailureV1 as j, type ToolExecutionNetworkKind as k, type ToolExecutionNetworkScope as l };