deepline 0.1.12 → 0.1.19

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 (80) hide show
  1. package/README.md +14 -6
  2. package/dist/cli/index.js +1298 -711
  3. package/dist/cli/index.mjs +1294 -707
  4. package/dist/index.d.mts +199 -23
  5. package/dist/index.d.ts +199 -23
  6. package/dist/index.js +219 -13
  7. package/dist/index.mjs +219 -13
  8. package/dist/repo/apps/play-runner-workers/src/coordinator-entry.ts +68 -12
  9. package/dist/repo/apps/play-runner-workers/src/entry.ts +241 -51
  10. package/dist/repo/sdk/src/client.ts +237 -0
  11. package/dist/repo/sdk/src/config.ts +125 -8
  12. package/dist/repo/sdk/src/http.ts +10 -2
  13. package/dist/repo/sdk/src/play.ts +19 -36
  14. package/dist/repo/sdk/src/plays/bundle-play-file.ts +22 -8
  15. package/dist/repo/sdk/src/plays/local-file-discovery.ts +207 -160
  16. package/dist/repo/sdk/src/types.ts +25 -0
  17. package/dist/repo/sdk/src/version.ts +2 -2
  18. package/dist/repo/shared_libs/play-runtime/tool-result.ts +237 -145
  19. package/dist/repo/shared_libs/plays/bundling/index.ts +206 -229
  20. package/dist/repo/shared_libs/plays/dataset.ts +28 -0
  21. package/package.json +5 -4
  22. package/dist/cli/index.js.map +0 -1
  23. package/dist/cli/index.mjs.map +0 -1
  24. package/dist/index.js.map +0 -1
  25. package/dist/index.mjs.map +0 -1
  26. package/dist/repo/apps/play-runner-workers/src/runtime/README.md +0 -21
  27. package/dist/repo/apps/play-runner-workers/src/runtime/batching.ts +0 -177
  28. package/dist/repo/apps/play-runner-workers/src/runtime/execution-plan.ts +0 -52
  29. package/dist/repo/apps/play-runner-workers/src/runtime/tool-batch.ts +0 -100
  30. package/dist/repo/sdk/src/cli/commands/auth.ts +0 -500
  31. package/dist/repo/sdk/src/cli/commands/billing.ts +0 -188
  32. package/dist/repo/sdk/src/cli/commands/csv.ts +0 -123
  33. package/dist/repo/sdk/src/cli/commands/db.ts +0 -119
  34. package/dist/repo/sdk/src/cli/commands/feedback.ts +0 -40
  35. package/dist/repo/sdk/src/cli/commands/org.ts +0 -117
  36. package/dist/repo/sdk/src/cli/commands/play.ts +0 -3441
  37. package/dist/repo/sdk/src/cli/commands/tools.ts +0 -687
  38. package/dist/repo/sdk/src/cli/dataset-stats.ts +0 -415
  39. package/dist/repo/sdk/src/cli/index.ts +0 -148
  40. package/dist/repo/sdk/src/cli/progress.ts +0 -149
  41. package/dist/repo/sdk/src/cli/skills-sync.ts +0 -141
  42. package/dist/repo/sdk/src/cli/trace.ts +0 -61
  43. package/dist/repo/sdk/src/cli/utils.ts +0 -145
  44. package/dist/repo/sdk/src/compat.ts +0 -77
  45. package/dist/repo/shared_libs/observability/node-tracing.ts +0 -129
  46. package/dist/repo/shared_libs/observability/tracing.ts +0 -98
  47. package/dist/repo/shared_libs/play-runtime/context.ts +0 -4242
  48. package/dist/repo/shared_libs/play-runtime/ctx-contract.ts +0 -250
  49. package/dist/repo/shared_libs/play-runtime/ctx-types.ts +0 -725
  50. package/dist/repo/shared_libs/play-runtime/dataset-id.ts +0 -10
  51. package/dist/repo/shared_libs/play-runtime/db-session-crypto.ts +0 -304
  52. package/dist/repo/shared_libs/play-runtime/db-session.ts +0 -462
  53. package/dist/repo/shared_libs/play-runtime/live-events.ts +0 -214
  54. package/dist/repo/shared_libs/play-runtime/live-state-contract.ts +0 -50
  55. package/dist/repo/shared_libs/play-runtime/map-execution-frame.ts +0 -114
  56. package/dist/repo/shared_libs/play-runtime/map-row-identity.ts +0 -158
  57. package/dist/repo/shared_libs/play-runtime/progress-emitter.ts +0 -172
  58. package/dist/repo/shared_libs/play-runtime/protocol.ts +0 -121
  59. package/dist/repo/shared_libs/play-runtime/public-play-contract.ts +0 -42
  60. package/dist/repo/shared_libs/play-runtime/result-normalization.ts +0 -33
  61. package/dist/repo/shared_libs/play-runtime/runtime-api.ts +0 -1873
  62. package/dist/repo/shared_libs/play-runtime/runtime-constraints.ts +0 -2
  63. package/dist/repo/shared_libs/play-runtime/runtime-pg-driver-neon-serverless.ts +0 -201
  64. package/dist/repo/shared_libs/play-runtime/runtime-pg-driver-pg.ts +0 -48
  65. package/dist/repo/shared_libs/play-runtime/runtime-pg-driver.ts +0 -84
  66. package/dist/repo/shared_libs/play-runtime/static-pipeline-types.ts +0 -147
  67. package/dist/repo/shared_libs/play-runtime/suspension.ts +0 -68
  68. package/dist/repo/shared_libs/play-runtime/tracing.ts +0 -31
  69. package/dist/repo/shared_libs/play-runtime/waterfall-replay.ts +0 -75
  70. package/dist/repo/shared_libs/play-runtime/worker-api-types.ts +0 -140
  71. package/dist/repo/shared_libs/plays/artifact-transport.ts +0 -14
  72. package/dist/repo/shared_libs/plays/artifact-types.ts +0 -49
  73. package/dist/repo/shared_libs/plays/compiler-manifest.ts +0 -186
  74. package/dist/repo/shared_libs/plays/definition.ts +0 -264
  75. package/dist/repo/shared_libs/plays/file-refs.ts +0 -11
  76. package/dist/repo/shared_libs/plays/rate-limit-scheduler.ts +0 -206
  77. package/dist/repo/shared_libs/plays/resolve-static-pipeline.ts +0 -164
  78. package/dist/repo/shared_libs/plays/runtime-validation.ts +0 -395
  79. package/dist/repo/shared_libs/temporal/constants.ts +0 -39
  80. package/dist/repo/shared_libs/temporal/preview-config.ts +0 -153
package/dist/index.d.mts CHANGED
@@ -264,6 +264,25 @@ interface ToolDefinition {
264
264
  resultIdentityGetters?: Record<string, string[]>;
265
265
  /** Whether the output is a direct object or wrapped in a `result` envelope. */
266
266
  rowContextShape?: 'direct' | 'result_envelope';
267
+ /** Search relevance score returned by ranked tool search. */
268
+ search_score?: number;
269
+ /** Search match snippets returned by ranked tool search. */
270
+ search_matches?: Array<{
271
+ field: string;
272
+ value: string;
273
+ term?: string;
274
+ }>;
275
+ }
276
+ interface ToolSearchOptions {
277
+ query?: string;
278
+ categories?: string;
279
+ searchTerms?: string;
280
+ searchMode?: 'v1' | 'v2';
281
+ includeSearchDebug?: boolean;
282
+ }
283
+ interface ToolSearchResult {
284
+ tools: ToolDefinition[];
285
+ search_fallback_to_category?: boolean;
267
286
  }
268
287
  /**
269
288
  * Extended tool metadata including pricing, samples, and failure modes.
@@ -344,6 +363,8 @@ interface PlayProgressStatus {
344
363
  totalRows?: number;
345
364
  /** Accumulated log lines from `ctx.log()`. Grows monotonically. */
346
365
  logs: string[];
366
+ /** Zero-based offset of the first returned log line when a tail cursor is used. */
367
+ logOffset?: number;
347
368
  /** Error message if the play has failed. */
348
369
  error?: string;
349
370
  }
@@ -724,6 +745,8 @@ interface StartPlayRunRequest {
724
745
  artifactStorageKey?: string;
725
746
  /** Source snapshot already validated while registering this artifact. */
726
747
  sourceCode?: string;
748
+ /** Source graph snapshots for local helper files included in cloud preflight. */
749
+ sourceFiles?: Record<string, string>;
727
750
  /** Static pipeline already produced while registering this artifact. */
728
751
  staticPipeline?: unknown;
729
752
  /** Artifact content hash already validated while registering this artifact. */
@@ -795,6 +818,9 @@ interface PlayStagedFileRef {
795
818
  bytes: number;
796
819
  }
797
820
 
821
+ type ExecuteToolRawOptions = {
822
+ includeToolMetadata?: boolean;
823
+ };
798
824
  type ToolExecution<TData = unknown, TMeta = Record<string, unknown>> = {
799
825
  status: string;
800
826
  job_id?: string;
@@ -805,6 +831,39 @@ type ToolExecution<TData = unknown, TMeta = Record<string, unknown>> = {
805
831
  billing?: Record<string, unknown>;
806
832
  [key: string]: unknown;
807
833
  };
834
+ type RunsListOptions = {
835
+ play: string;
836
+ status?: string;
837
+ };
838
+ type RunsTailOptions = {
839
+ cursor?: string | number;
840
+ afterLogIndex?: number;
841
+ waitMs?: number;
842
+ terminalOnly?: boolean;
843
+ compact?: boolean;
844
+ };
845
+ type RunsLogsOptions = {
846
+ limit?: number;
847
+ };
848
+ type RunsLogsResult = {
849
+ runId: string;
850
+ totalCount: number;
851
+ returnedCount: number;
852
+ firstSequence: number | null;
853
+ lastSequence: number | null;
854
+ truncated: boolean;
855
+ hasMore: boolean;
856
+ entries: string[];
857
+ };
858
+ type RunsNamespace = {
859
+ get: (runId: string) => Promise<PlayStatus>;
860
+ list: (options: RunsListOptions) => Promise<PlayRunListItem[]>;
861
+ tail: (runId: string, options?: RunsTailOptions) => Promise<PlayStatus>;
862
+ logs: (runId: string, options?: RunsLogsOptions) => Promise<RunsLogsResult>;
863
+ stop: (runId: string, options?: {
864
+ reason?: string;
865
+ }) => Promise<StopPlayRunResult>;
866
+ };
808
867
  /**
809
868
  * Low-level client for the Deepline REST API.
810
869
  *
@@ -828,6 +887,7 @@ type ToolExecution<TData = unknown, TMeta = Record<string, unknown>> = {
828
887
  declare class DeeplineClient {
829
888
  private readonly http;
830
889
  private readonly config;
890
+ readonly runs: RunsNamespace;
831
891
  /**
832
892
  * @param options - Optional overrides for API key, base URL, timeout, and retries.
833
893
  * @throws {@link ConfigError} if no API key can be resolved from any source.
@@ -856,6 +916,13 @@ declare class DeeplineClient {
856
916
  * ```
857
917
  */
858
918
  listTools(): Promise<ToolDefinition[]>;
919
+ /**
920
+ * Search available tools using Deepline's ranked backend search.
921
+ *
922
+ * This is the same discovery surface used by the legacy CLI: it ranks across
923
+ * tool metadata, categories, agent guidance, and input schema fields.
924
+ */
925
+ searchTools(options?: ToolSearchOptions): Promise<ToolSearchResult>;
859
926
  /**
860
927
  * Get detailed metadata for a single tool.
861
928
  *
@@ -881,7 +948,8 @@ declare class DeeplineClient {
881
948
  * Top-level fields such as `status`, `job_id`, and `billing` describe the
882
949
  * Deepline execution.
883
950
  */
884
- executeTool<TData = unknown, TMeta = Record<string, unknown>>(toolId: string, input: Record<string, unknown>): Promise<ToolExecution<TData, TMeta>>;
951
+ executeTool<TData = unknown, TMeta = Record<string, unknown>>(toolId: string, input: Record<string, unknown>, options?: ExecuteToolRawOptions): Promise<ToolExecution<TData, TMeta>>;
952
+ executeToolRaw<TData = unknown, TMeta = Record<string, unknown>>(toolId: string, input: Record<string, unknown>, options?: ExecuteToolRawOptions): Promise<ToolExecution<TData, TMeta>>;
885
953
  queryCustomerDb(input: {
886
954
  sql: string;
887
955
  maxRows?: number;
@@ -932,6 +1000,7 @@ declare class DeeplineClient {
932
1000
  registerPlayArtifact(input: {
933
1001
  name: string;
934
1002
  sourceCode: string;
1003
+ sourceFiles?: Record<string, string>;
935
1004
  artifact: Record<string, unknown>;
936
1005
  compilerManifest?: PlayCompilerManifest;
937
1006
  publish?: boolean;
@@ -954,6 +1023,7 @@ declare class DeeplineClient {
954
1023
  registerPlayArtifacts(artifacts: Array<{
955
1024
  name: string;
956
1025
  sourceCode: string;
1026
+ sourceFiles?: Record<string, string>;
957
1027
  artifact: Record<string, unknown>;
958
1028
  compilerManifest?: PlayCompilerManifest;
959
1029
  publish?: boolean;
@@ -979,6 +1049,7 @@ declare class DeeplineClient {
979
1049
  compilePlayManifest(input: {
980
1050
  name: string;
981
1051
  sourceCode: string;
1052
+ sourceFiles?: Record<string, string>;
982
1053
  artifact: Record<string, unknown>;
983
1054
  importedPlayDependencies?: PlayCompilerManifest[];
984
1055
  }): Promise<PlayCompilerManifest>;
@@ -992,11 +1063,13 @@ declare class DeeplineClient {
992
1063
  checkPlayArtifact(input: {
993
1064
  name?: string;
994
1065
  sourceCode: string;
1066
+ sourceFiles?: Record<string, string>;
995
1067
  artifact: Record<string, unknown>;
996
1068
  }): Promise<PlayCheckResult>;
997
1069
  startPlayRunFromBundle(input: {
998
1070
  name: string;
999
1071
  sourceCode: string;
1072
+ sourceFiles?: Record<string, string>;
1000
1073
  artifact: Record<string, unknown>;
1001
1074
  compilerManifest?: PlayCompilerManifest;
1002
1075
  input?: Record<string, unknown>;
@@ -1030,6 +1103,7 @@ declare class DeeplineClient {
1030
1103
  */
1031
1104
  submitPlay(code: string, csvPath: string | null, name?: string, options?: {
1032
1105
  sourceCode?: string;
1106
+ sourceFiles?: Record<string, string>;
1033
1107
  artifact?: Record<string, unknown>;
1034
1108
  compilerManifest?: PlayCompilerManifest;
1035
1109
  input?: Record<string, unknown>;
@@ -1164,6 +1238,58 @@ declare class DeeplineClient {
1164
1238
  * ```
1165
1239
  */
1166
1240
  listPlayRuns(playName: string): Promise<PlayRunListItem[]>;
1241
+ /**
1242
+ * Get a run by id using the public runs resource model.
1243
+ *
1244
+ * This is the SDK equivalent of:
1245
+ *
1246
+ * ```bash
1247
+ * deepline runs get <run-id> --json
1248
+ * ```
1249
+ */
1250
+ getRunStatus(runId: string): Promise<PlayStatus>;
1251
+ /**
1252
+ * List play runs using the public runs resource model.
1253
+ *
1254
+ * This is the SDK equivalent of:
1255
+ *
1256
+ * ```bash
1257
+ * deepline runs list --play <play-name> --status failed --json
1258
+ * ```
1259
+ */
1260
+ listRuns(options: RunsListOptions): Promise<PlayRunListItem[]>;
1261
+ /**
1262
+ * Fetch the lightweight tail status for a run using the public runs resource model.
1263
+ *
1264
+ * This is the SDK equivalent of:
1265
+ *
1266
+ * ```bash
1267
+ * deepline runs tail <run-id> --json
1268
+ * ```
1269
+ */
1270
+ tailRun(runId: string, options?: RunsTailOptions): Promise<PlayStatus>;
1271
+ /**
1272
+ * Fetch persisted logs for a run using the public runs resource model.
1273
+ *
1274
+ * This is the SDK equivalent of:
1275
+ *
1276
+ * ```bash
1277
+ * deepline runs logs <run-id> --limit 200 --json
1278
+ * ```
1279
+ */
1280
+ getRunLogs(runId: string, options?: RunsLogsOptions): Promise<RunsLogsResult>;
1281
+ /**
1282
+ * Stop a run by id using the public runs resource model.
1283
+ *
1284
+ * This is the SDK equivalent of:
1285
+ *
1286
+ * ```bash
1287
+ * deepline runs stop <run-id> --reason "stale lock" --json
1288
+ * ```
1289
+ */
1290
+ stopRun(runId: string, options?: {
1291
+ reason?: string;
1292
+ }): Promise<StopPlayRunResult>;
1167
1293
  listPlays(): Promise<PlayListItem[]>;
1168
1294
  searchPlays(options: {
1169
1295
  query: string;
@@ -1308,8 +1434,8 @@ declare class DeeplineClient {
1308
1434
  }>;
1309
1435
  }
1310
1436
 
1311
- declare const SDK_VERSION = "0.1.12";
1312
- declare const SDK_API_CONTRACT = "2026-04-plays-v1";
1437
+ declare const SDK_VERSION = "0.1.19";
1438
+ declare const SDK_API_CONTRACT = "2026-05-runs-v2";
1313
1439
 
1314
1440
  /**
1315
1441
  * Base error class for all Deepline SDK errors.
@@ -1474,6 +1600,20 @@ type PlayDatasetBacking = {
1474
1600
  storage: 'r2_file';
1475
1601
  file: PlayExecutionFileRef;
1476
1602
  };
1603
+ type PlayDatasetWorkProgressSummary = {
1604
+ total: number;
1605
+ executed: number;
1606
+ reused: number;
1607
+ skipped: number;
1608
+ pending: number;
1609
+ failed: number;
1610
+ degraded?: boolean;
1611
+ duplicates?: {
1612
+ exact?: number;
1613
+ semantic?: number;
1614
+ rejected?: number;
1615
+ };
1616
+ };
1477
1617
  type PlayDatasetInput<T> = ReadonlyArray<T> | Iterable<T> | AsyncIterable<T> | PlayDataset<T>;
1478
1618
  interface PlayDataset<T> extends AsyncIterable<T> {
1479
1619
  readonly [PLAY_DATASET_BRAND]: true;
@@ -1499,10 +1639,65 @@ interface PlayDataset<T> extends AsyncIterable<T> {
1499
1639
  sourceLabel?: string | null;
1500
1640
  tableNamespace?: string | null;
1501
1641
  columns?: string[];
1642
+ _metadata?: {
1643
+ workProgress?: PlayDatasetWorkProgressSummary;
1644
+ };
1502
1645
  preview: T[];
1503
1646
  };
1504
1647
  }
1505
1648
 
1649
+ type ToolResultExecutionMetadata = {
1650
+ idempotent: true;
1651
+ cached: boolean;
1652
+ source: 'live' | 'checkpoint' | 'cache';
1653
+ cacheKey?: string;
1654
+ };
1655
+ type ToolResultTargetMetadata = {
1656
+ value: unknown;
1657
+ path: string;
1658
+ };
1659
+ type ToolResultListMetadata = {
1660
+ path: string;
1661
+ count: number | null;
1662
+ keys: Record<string, string>;
1663
+ };
1664
+ type ToolResultTargetAccessor<T = unknown> = ToolResultTargetMetadata & {
1665
+ get(): T | null;
1666
+ };
1667
+ type ToolResultListAccessor<T = Record<string, unknown>> = ToolResultListMetadata & {
1668
+ get(): T[];
1669
+ };
1670
+ type ToolResultEnvelope<TData = unknown, TMeta = Record<string, unknown>> = {
1671
+ data: TData;
1672
+ meta?: TMeta;
1673
+ };
1674
+ type ToolExecuteResultBase<TResult = unknown, TMeta = Record<string, unknown>> = {
1675
+ status: string;
1676
+ result: ToolResultEnvelope<TResult, TMeta>;
1677
+ _metadata: {
1678
+ toolId: string;
1679
+ execution: ToolResultExecutionMetadata;
1680
+ targets: Record<string, {
1681
+ value: unknown;
1682
+ path: string;
1683
+ }>;
1684
+ lists: Record<string, {
1685
+ path: string;
1686
+ count: number | null;
1687
+ keys: Record<string, string>;
1688
+ }>;
1689
+ };
1690
+ };
1691
+ type ToolExecuteResultAccessors<TExtracted extends Record<string, unknown> = Record<string, unknown>, TLists extends Record<string, Record<string, unknown>> = Record<string, Record<string, unknown>>> = {
1692
+ extracted: {
1693
+ [K in keyof TExtracted]: ToolResultTargetAccessor<TExtracted[K]>;
1694
+ };
1695
+ lists: {
1696
+ [K in keyof TLists]: ToolResultListAccessor<TLists[K]>;
1697
+ };
1698
+ };
1699
+ type ToolExecuteResult<TResult = unknown, TMeta = Record<string, unknown>, TExtracted extends Record<string, unknown> = Record<string, unknown>, TLists extends Record<string, Record<string, unknown>> = Record<string, Record<string, unknown>>> = ToolExecuteResultBase<TResult, TMeta> & ToolExecuteResultAccessors<TExtracted, TLists>;
1700
+
1506
1701
  /**
1507
1702
  * Optional trigger bindings for a play.
1508
1703
  *
@@ -1558,25 +1753,7 @@ type PlayBindings = {
1558
1753
  type LoosePlayObject = {
1559
1754
  [key: string]: LoosePlayObject;
1560
1755
  };
1561
- type ToolExtractedValue<T = unknown> = {
1562
- path: string;
1563
- get(): T | null;
1564
- };
1565
- type ToolResultEnvelope<TData = unknown, TMeta = Record<string, unknown>> = {
1566
- data: TData;
1567
- meta?: TMeta;
1568
- };
1569
- type ToolExecuteResult<TData = unknown, TMeta = Record<string, unknown>> = {
1570
- status: string;
1571
- result: ToolResultEnvelope<TData, TMeta>;
1572
- extracted: Record<string, ToolExtractedValue>;
1573
- lists: Record<string, {
1574
- path: string;
1575
- count: number | null;
1576
- keys: Record<string, string>;
1577
- get(): Record<string, unknown>[];
1578
- }>;
1579
- };
1756
+
1580
1757
  type ToolExecutionRequest = {
1581
1758
  id: string;
1582
1759
  tool: string;
@@ -1615,7 +1792,6 @@ type MapStepBuilder<InputRow extends object, OutputRow extends object> = {
1615
1792
  run(options?: {
1616
1793
  description?: string;
1617
1794
  staleAfterSeconds?: number;
1618
- concurrency?: number;
1619
1795
  key?: (keyof InputRow & string) | readonly (keyof InputRow & string)[] | ((row: InputRow, index: number) => string | number | readonly unknown[]);
1620
1796
  }): Promise<PlayDataset<OutputRow>>;
1621
1797
  };