deepline 0.1.210 → 0.1.212

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 (40) hide show
  1. package/dist/bundling-sources/apps/play-runner-workers/src/entry.ts +203 -12
  2. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/customer-console.ts +23 -0
  3. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/map-chunk-plan.ts +15 -0
  4. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/map-latency-profile.ts +90 -0
  5. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/tool-dispatch.ts +162 -100
  6. package/dist/bundling-sources/sdk/src/client.ts +118 -3
  7. package/dist/bundling-sources/sdk/src/play.ts +2 -0
  8. package/dist/bundling-sources/sdk/src/plays/bundle-play-file.ts +1 -1
  9. package/dist/bundling-sources/sdk/src/release.ts +2 -2
  10. package/dist/bundling-sources/sdk/src/types.ts +47 -0
  11. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +253 -30
  12. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +365 -103
  13. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +12 -0
  14. package/dist/bundling-sources/shared_libs/play-runtime/dataset-id.ts +10 -4
  15. package/dist/bundling-sources/shared_libs/play-runtime/db-session.ts +9 -0
  16. package/dist/bundling-sources/shared_libs/play-runtime/durable-receipt-execution.ts +45 -8
  17. package/dist/bundling-sources/shared_libs/play-runtime/ledger-safe-payload.ts +14 -2
  18. package/dist/bundling-sources/shared_libs/play-runtime/output-size-limits.ts +4 -2
  19. package/dist/bundling-sources/shared_libs/play-runtime/receipt-sql.ts +21 -1
  20. package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +128 -6
  21. package/dist/bundling-sources/shared_libs/play-runtime/run-snapshot-stream.ts +7 -0
  22. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-payload-transport.ts +5 -1
  23. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona.ts +37 -5
  24. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/types.ts +19 -10
  25. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +63 -7
  26. package/dist/bundling-sources/shared_libs/play-runtime/secret-capability.ts +18 -4
  27. package/dist/bundling-sources/shared_libs/play-runtime/single-flight.ts +31 -0
  28. package/dist/bundling-sources/shared_libs/play-runtime/test-runtime-seams.ts +12 -1
  29. package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +29 -9
  30. package/dist/bundling-sources/shared_libs/play-runtime/work-receipt-state-machine.ts +22 -1
  31. package/dist/bundling-sources/shared_libs/plays/bundling/index.ts +79 -1
  32. package/dist/bundling-sources/shared_libs/plays/dataset.ts +41 -5
  33. package/dist/cli/index.js +728 -239
  34. package/dist/cli/index.mjs +728 -239
  35. package/dist/index.d.mts +93 -7
  36. package/dist/index.d.ts +93 -7
  37. package/dist/index.js +245 -46
  38. package/dist/index.mjs +245 -46
  39. package/dist/plays/bundle-play-file.mjs +65 -4
  40. package/package.json +1 -1
package/dist/index.d.mts CHANGED
@@ -431,6 +431,16 @@ type PlayRunActionPackage = {
431
431
  runId: string;
432
432
  datasetPath: string;
433
433
  format: 'csv';
434
+ } | {
435
+ kind: 'deepline_run_logs';
436
+ runId: string;
437
+ view: 'failed' | 'tail';
438
+ limit: number;
439
+ command: string;
440
+ api: {
441
+ method: 'GET';
442
+ path: string;
443
+ };
434
444
  };
435
445
  /**
436
446
  * Compact canonical package for an inspected play run.
@@ -460,11 +470,30 @@ interface PlayRunPackage {
460
470
  steps: Array<Record<string, unknown>>;
461
471
  /** Named output summaries, including dataset handles and scalar outputs. */
462
472
  outputs: Record<string, Record<string, unknown>>;
473
+ /** Every durable Dataset Handle explicitly registered by this run. */
474
+ datasets?: Array<{
475
+ kind: 'dataset';
476
+ datasetId?: string;
477
+ path: string;
478
+ tableNamespace?: string;
479
+ rowCount?: number;
480
+ recovered?: true;
481
+ preview?: Record<string, unknown>;
482
+ actions?: Record<string, PlayRunActionPackage>;
483
+ }>;
484
+ /** Small retained tail of customer and runtime logs; fetch the full stream through `runs.logs`. */
485
+ logs?: {
486
+ tail: string[];
487
+ totalCount: number;
488
+ returnedCount: number;
489
+ truncated?: boolean;
490
+ };
463
491
  /** Follow-up actions a caller can perform against the run. */
464
492
  next?: {
465
493
  inspect?: PlayRunActionPackage;
466
494
  export?: PlayRunActionPackage;
467
495
  query?: PlayRunActionPackage;
496
+ logs?: PlayRunActionPackage;
468
497
  };
469
498
  }
470
499
  /**
@@ -490,6 +519,8 @@ interface PlayStatus {
490
519
  apiVersion?: number;
491
520
  /** Saved play name for this run, when available. */
492
521
  name?: string;
522
+ /** Exact saved revision launched for this run, when applicable. */
523
+ revisionId?: string;
493
524
  /** Alias for `name` used by run/result APIs. */
494
525
  playName?: string;
495
526
  /** Dashboard URL for inspecting the play and its run output in the app. */
@@ -524,6 +555,26 @@ interface PlayStatus {
524
555
  } | null;
525
556
  /** Structured follow-up actions for inspect/query/export. */
526
557
  next?: PlayRunPackage['next'] | Record<string, unknown>;
558
+ /** Bounded terminal-failure log window requested by `runs.get`. */
559
+ failedLogs?: {
560
+ runId: string;
561
+ totalCount: number;
562
+ returnedCount: number;
563
+ firstSequence: number | null;
564
+ lastSequence: number | null;
565
+ truncated: boolean;
566
+ hasMore: boolean;
567
+ entries: string[];
568
+ view?: 'failed';
569
+ association?: 'terminal_failure_window' | 'retained_before_truncation';
570
+ warning?: string;
571
+ next?: {
572
+ logs: string;
573
+ };
574
+ logsTruncated?: boolean;
575
+ };
576
+ /** Exact ordinary `plays run` command that can rerun a failed execution. */
577
+ rerunCommand?: string;
527
578
  }
528
579
  type LiveEventScope = 'play' | 'agent';
529
580
  interface LiveEventEnvelope<TPayload = unknown> {
@@ -1143,6 +1194,13 @@ type EnrichStepCommand = {
1143
1194
  play?: {
1144
1195
  ref: string;
1145
1196
  mode?: 'scalar';
1197
+ execution?: 'child' | 'inline';
1198
+ inline?: {
1199
+ exportName: string;
1200
+ functionExpressionSource: string;
1201
+ sourceHash: string;
1202
+ typeImports: string[];
1203
+ };
1146
1204
  };
1147
1205
  payload: Record<string, unknown>;
1148
1206
  extract_js?: string;
@@ -1210,9 +1268,20 @@ type RunsListOptions = {
1210
1268
  status?: string;
1211
1269
  limit?: number;
1212
1270
  };
1271
+ /** Options for `client.runs.get(...)`. */
1272
+ type RunsGetOptions = {
1273
+ /** Return the raw status payload instead of the compact package. */
1274
+ full?: boolean;
1275
+ /** Attach a bounded end-of-stream window for a failed run. */
1276
+ failedLogs?: boolean;
1277
+ /** Requested failed-log lines to attach (default 20, hard-capped at 20). */
1278
+ failedLogLimit?: number;
1279
+ };
1213
1280
  /** Streaming options for `client.runs.tail(...)`. */
1214
1281
  type RunsTailOptions = {
1215
1282
  signal?: AbortSignal;
1283
+ /** Observe each canonical live event while `tail` waits for terminal state. */
1284
+ onEvent?: (event: PlayLiveEvent) => void;
1216
1285
  /**
1217
1286
  * Called before each stream reconnect. Server stream windows are finite, so
1218
1287
  * long runs reconnect with backoff until a terminal status is observed.
@@ -1235,6 +1304,8 @@ type RunsLogsOptions = {
1235
1304
  limit?: number;
1236
1305
  /** Fetch every stored log line, paginating to the full totalCount. */
1237
1306
  all?: boolean;
1307
+ /** Select the bounded failure view; truncated runs degrade explicitly. */
1308
+ failed?: boolean;
1238
1309
  };
1239
1310
  /** Persisted log response for one play run. */
1240
1311
  type RunsLogsResult = {
@@ -1246,6 +1317,16 @@ type RunsLogsResult = {
1246
1317
  truncated: boolean;
1247
1318
  hasMore: boolean;
1248
1319
  entries: string[];
1320
+ /** Selected public log view. */
1321
+ view?: 'tail' | 'failed' | 'all';
1322
+ /** Whether entries are terminal context or the last pre-truncation lines. */
1323
+ association?: 'terminal_failure_window' | 'retained_before_truncation';
1324
+ /** Loud explanation when the terminal failure window was not retained. */
1325
+ warning?: string;
1326
+ /** Exact follow-up command when the selected view is degraded. */
1327
+ next?: {
1328
+ logs: string;
1329
+ };
1249
1330
  /**
1250
1331
  * True when the run crossed the Run Log Stream retention cap: `totalCount`
1251
1332
  * keeps counting, but stored line bodies end at a loud truncation marker.
@@ -1300,9 +1381,7 @@ type PlaySecretMetadata = {
1300
1381
  */
1301
1382
  type RunsNamespace = {
1302
1383
  /** Get current run status by public run id. */
1303
- get: (runId: string, options?: {
1304
- full?: boolean;
1305
- }) => Promise<PlayStatus>;
1384
+ get: (runId: string, options?: RunsGetOptions) => Promise<PlayStatus>;
1306
1385
  /** List runs for one play, optionally filtered by status. */
1307
1386
  list: (options: RunsListOptions) => Promise<PlayRunListItem[]>;
1308
1387
  /** Stream run events and return the latest/terminal run status. */
@@ -2083,9 +2162,7 @@ declare class DeeplineClient {
2083
2162
  * deepline runs get <run-id> --json
2084
2163
  * ```
2085
2164
  */
2086
- getRunStatus(runId: string, options?: {
2087
- full?: boolean;
2088
- }): Promise<PlayStatus>;
2165
+ getRunStatus(runId: string, options?: RunsGetOptions): Promise<PlayStatus>;
2089
2166
  /**
2090
2167
  * List play runs using the public runs resource model.
2091
2168
  *
@@ -2850,7 +2927,7 @@ interface PlayDataset<T> extends AsyncIterable<T> {
2850
2927
  * Large datasets should flow by handle through Neon-backed storage, not
2851
2928
  * through worker memory as giant arrays.
2852
2929
  */
2853
- materialize(limit?: number): Promise<T[]>;
2930
+ materialize(options?: number | PlayDatasetMaterializeOptions): Promise<T[]>;
2854
2931
  toJSON(): {
2855
2932
  kind: 'dataset';
2856
2933
  datasetKind: PlayDatasetKind;
@@ -2866,6 +2943,13 @@ interface PlayDataset<T> extends AsyncIterable<T> {
2866
2943
  preview: T[];
2867
2944
  };
2868
2945
  }
2946
+ type PlayDatasetMaterializeScope = 'result' | 'full_persisted_dataset';
2947
+ type PlayDatasetMaterializeOptions = {
2948
+ /** Rows returned by this operation, or every current row in its persisted dataset. */
2949
+ scope?: PlayDatasetMaterializeScope;
2950
+ /** Maximum number of rows to load into memory. */
2951
+ limit?: number;
2952
+ };
2869
2953
 
2870
2954
  type ToolResultExecutionMetadata = {
2871
2955
  idempotent: true;
@@ -3038,6 +3122,8 @@ type PlayBindings = {
3038
3122
  * older clients can continue to register revisions during the migration.
3039
3123
  */
3040
3124
  description?: string;
3125
+ /** Allow compilers to bundle this named handler directly without a child run. */
3126
+ inline?: boolean;
3041
3127
  /** Optional per-run billing controls enforced by the runtime. */
3042
3128
  billing?: {
3043
3129
  /** Stop the run before a billed action would push total run credits above this cap. */
package/dist/index.d.ts CHANGED
@@ -431,6 +431,16 @@ type PlayRunActionPackage = {
431
431
  runId: string;
432
432
  datasetPath: string;
433
433
  format: 'csv';
434
+ } | {
435
+ kind: 'deepline_run_logs';
436
+ runId: string;
437
+ view: 'failed' | 'tail';
438
+ limit: number;
439
+ command: string;
440
+ api: {
441
+ method: 'GET';
442
+ path: string;
443
+ };
434
444
  };
435
445
  /**
436
446
  * Compact canonical package for an inspected play run.
@@ -460,11 +470,30 @@ interface PlayRunPackage {
460
470
  steps: Array<Record<string, unknown>>;
461
471
  /** Named output summaries, including dataset handles and scalar outputs. */
462
472
  outputs: Record<string, Record<string, unknown>>;
473
+ /** Every durable Dataset Handle explicitly registered by this run. */
474
+ datasets?: Array<{
475
+ kind: 'dataset';
476
+ datasetId?: string;
477
+ path: string;
478
+ tableNamespace?: string;
479
+ rowCount?: number;
480
+ recovered?: true;
481
+ preview?: Record<string, unknown>;
482
+ actions?: Record<string, PlayRunActionPackage>;
483
+ }>;
484
+ /** Small retained tail of customer and runtime logs; fetch the full stream through `runs.logs`. */
485
+ logs?: {
486
+ tail: string[];
487
+ totalCount: number;
488
+ returnedCount: number;
489
+ truncated?: boolean;
490
+ };
463
491
  /** Follow-up actions a caller can perform against the run. */
464
492
  next?: {
465
493
  inspect?: PlayRunActionPackage;
466
494
  export?: PlayRunActionPackage;
467
495
  query?: PlayRunActionPackage;
496
+ logs?: PlayRunActionPackage;
468
497
  };
469
498
  }
470
499
  /**
@@ -490,6 +519,8 @@ interface PlayStatus {
490
519
  apiVersion?: number;
491
520
  /** Saved play name for this run, when available. */
492
521
  name?: string;
522
+ /** Exact saved revision launched for this run, when applicable. */
523
+ revisionId?: string;
493
524
  /** Alias for `name` used by run/result APIs. */
494
525
  playName?: string;
495
526
  /** Dashboard URL for inspecting the play and its run output in the app. */
@@ -524,6 +555,26 @@ interface PlayStatus {
524
555
  } | null;
525
556
  /** Structured follow-up actions for inspect/query/export. */
526
557
  next?: PlayRunPackage['next'] | Record<string, unknown>;
558
+ /** Bounded terminal-failure log window requested by `runs.get`. */
559
+ failedLogs?: {
560
+ runId: string;
561
+ totalCount: number;
562
+ returnedCount: number;
563
+ firstSequence: number | null;
564
+ lastSequence: number | null;
565
+ truncated: boolean;
566
+ hasMore: boolean;
567
+ entries: string[];
568
+ view?: 'failed';
569
+ association?: 'terminal_failure_window' | 'retained_before_truncation';
570
+ warning?: string;
571
+ next?: {
572
+ logs: string;
573
+ };
574
+ logsTruncated?: boolean;
575
+ };
576
+ /** Exact ordinary `plays run` command that can rerun a failed execution. */
577
+ rerunCommand?: string;
527
578
  }
528
579
  type LiveEventScope = 'play' | 'agent';
529
580
  interface LiveEventEnvelope<TPayload = unknown> {
@@ -1143,6 +1194,13 @@ type EnrichStepCommand = {
1143
1194
  play?: {
1144
1195
  ref: string;
1145
1196
  mode?: 'scalar';
1197
+ execution?: 'child' | 'inline';
1198
+ inline?: {
1199
+ exportName: string;
1200
+ functionExpressionSource: string;
1201
+ sourceHash: string;
1202
+ typeImports: string[];
1203
+ };
1146
1204
  };
1147
1205
  payload: Record<string, unknown>;
1148
1206
  extract_js?: string;
@@ -1210,9 +1268,20 @@ type RunsListOptions = {
1210
1268
  status?: string;
1211
1269
  limit?: number;
1212
1270
  };
1271
+ /** Options for `client.runs.get(...)`. */
1272
+ type RunsGetOptions = {
1273
+ /** Return the raw status payload instead of the compact package. */
1274
+ full?: boolean;
1275
+ /** Attach a bounded end-of-stream window for a failed run. */
1276
+ failedLogs?: boolean;
1277
+ /** Requested failed-log lines to attach (default 20, hard-capped at 20). */
1278
+ failedLogLimit?: number;
1279
+ };
1213
1280
  /** Streaming options for `client.runs.tail(...)`. */
1214
1281
  type RunsTailOptions = {
1215
1282
  signal?: AbortSignal;
1283
+ /** Observe each canonical live event while `tail` waits for terminal state. */
1284
+ onEvent?: (event: PlayLiveEvent) => void;
1216
1285
  /**
1217
1286
  * Called before each stream reconnect. Server stream windows are finite, so
1218
1287
  * long runs reconnect with backoff until a terminal status is observed.
@@ -1235,6 +1304,8 @@ type RunsLogsOptions = {
1235
1304
  limit?: number;
1236
1305
  /** Fetch every stored log line, paginating to the full totalCount. */
1237
1306
  all?: boolean;
1307
+ /** Select the bounded failure view; truncated runs degrade explicitly. */
1308
+ failed?: boolean;
1238
1309
  };
1239
1310
  /** Persisted log response for one play run. */
1240
1311
  type RunsLogsResult = {
@@ -1246,6 +1317,16 @@ type RunsLogsResult = {
1246
1317
  truncated: boolean;
1247
1318
  hasMore: boolean;
1248
1319
  entries: string[];
1320
+ /** Selected public log view. */
1321
+ view?: 'tail' | 'failed' | 'all';
1322
+ /** Whether entries are terminal context or the last pre-truncation lines. */
1323
+ association?: 'terminal_failure_window' | 'retained_before_truncation';
1324
+ /** Loud explanation when the terminal failure window was not retained. */
1325
+ warning?: string;
1326
+ /** Exact follow-up command when the selected view is degraded. */
1327
+ next?: {
1328
+ logs: string;
1329
+ };
1249
1330
  /**
1250
1331
  * True when the run crossed the Run Log Stream retention cap: `totalCount`
1251
1332
  * keeps counting, but stored line bodies end at a loud truncation marker.
@@ -1300,9 +1381,7 @@ type PlaySecretMetadata = {
1300
1381
  */
1301
1382
  type RunsNamespace = {
1302
1383
  /** Get current run status by public run id. */
1303
- get: (runId: string, options?: {
1304
- full?: boolean;
1305
- }) => Promise<PlayStatus>;
1384
+ get: (runId: string, options?: RunsGetOptions) => Promise<PlayStatus>;
1306
1385
  /** List runs for one play, optionally filtered by status. */
1307
1386
  list: (options: RunsListOptions) => Promise<PlayRunListItem[]>;
1308
1387
  /** Stream run events and return the latest/terminal run status. */
@@ -2083,9 +2162,7 @@ declare class DeeplineClient {
2083
2162
  * deepline runs get <run-id> --json
2084
2163
  * ```
2085
2164
  */
2086
- getRunStatus(runId: string, options?: {
2087
- full?: boolean;
2088
- }): Promise<PlayStatus>;
2165
+ getRunStatus(runId: string, options?: RunsGetOptions): Promise<PlayStatus>;
2089
2166
  /**
2090
2167
  * List play runs using the public runs resource model.
2091
2168
  *
@@ -2850,7 +2927,7 @@ interface PlayDataset<T> extends AsyncIterable<T> {
2850
2927
  * Large datasets should flow by handle through Neon-backed storage, not
2851
2928
  * through worker memory as giant arrays.
2852
2929
  */
2853
- materialize(limit?: number): Promise<T[]>;
2930
+ materialize(options?: number | PlayDatasetMaterializeOptions): Promise<T[]>;
2854
2931
  toJSON(): {
2855
2932
  kind: 'dataset';
2856
2933
  datasetKind: PlayDatasetKind;
@@ -2866,6 +2943,13 @@ interface PlayDataset<T> extends AsyncIterable<T> {
2866
2943
  preview: T[];
2867
2944
  };
2868
2945
  }
2946
+ type PlayDatasetMaterializeScope = 'result' | 'full_persisted_dataset';
2947
+ type PlayDatasetMaterializeOptions = {
2948
+ /** Rows returned by this operation, or every current row in its persisted dataset. */
2949
+ scope?: PlayDatasetMaterializeScope;
2950
+ /** Maximum number of rows to load into memory. */
2951
+ limit?: number;
2952
+ };
2869
2953
 
2870
2954
  type ToolResultExecutionMetadata = {
2871
2955
  idempotent: true;
@@ -3038,6 +3122,8 @@ type PlayBindings = {
3038
3122
  * older clients can continue to register revisions during the migration.
3039
3123
  */
3040
3124
  description?: string;
3125
+ /** Allow compilers to bundle this named handler directly without a child run. */
3126
+ inline?: boolean;
3041
3127
  /** Optional per-run billing controls enforced by the runtime. */
3042
3128
  billing?: {
3043
3129
  /** Stop the run before a billed action would push total run credits above this cap. */