deepline 0.1.85 → 0.1.88

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/index.d.ts CHANGED
@@ -267,17 +267,33 @@ interface ResolvedConfig {
267
267
  /** Max retry count for transient failures. */
268
268
  maxRetries: number;
269
269
  }
270
+ /** Column metadata returned by a customer data query. */
270
271
  interface CustomerDbColumn {
272
+ /** Column name as returned by the database. */
271
273
  name: string;
274
+ /** Internal table identifier when available. */
272
275
  table_id: number | null;
276
+ /** Internal data-type identifier when available. */
273
277
  data_type_id: number | null;
274
278
  }
279
+ /**
280
+ * Result returned by {@link DeeplineClient.queryCustomerDb}.
281
+ *
282
+ * Rows are intentionally untyped because the schema depends on the caller's SQL
283
+ * query and selected customer tables.
284
+ */
275
285
  interface CustomerDbQueryResult {
286
+ /** Database command executed by the query endpoint. */
276
287
  command: string;
288
+ /** Total affected row count when reported by the database. */
277
289
  row_count: number | null;
290
+ /** Number of rows included in this response. */
278
291
  row_count_returned: number;
292
+ /** Whether server-side row limits truncated the result. */
279
293
  truncated: boolean;
294
+ /** Column metadata for the returned rows. */
280
295
  columns: CustomerDbColumn[];
296
+ /** Result rows. */
281
297
  rows: unknown[];
282
298
  }
283
299
  interface ToolPricingSummary {
@@ -297,6 +313,13 @@ interface ToolPricingSummary {
297
313
  details: string[];
298
314
  }
299
315
 
316
+ /**
317
+ * Summary definition of a callable provider-backed tool.
318
+ *
319
+ * Returned by {@link DeeplineClient.listTools} and ranked tool search. Use
320
+ * `getTool(toolId)` or the matching HTTP describe route for provider-specific
321
+ * schema, examples, pricing, and extraction guidance before executing.
322
+ */
300
323
  interface ToolDefinition {
301
324
  /** Unique tool identifier used in API calls (e.g. `"apollo_people_search"`). */
302
325
  toolId: string;
@@ -394,28 +417,53 @@ interface ToolDefinition {
394
417
  term?: string;
395
418
  }>;
396
419
  }
420
+ /**
421
+ * Query options for ranked tool/provider discovery.
422
+ */
397
423
  interface ToolSearchOptions {
424
+ /** Free-text search query. */
398
425
  query?: string;
426
+ /** Comma-separated category filter such as `company_search` or `email_finder`. */
399
427
  categories?: string;
428
+ /** Optional explicit search terms used by agent/CLI callers. */
400
429
  searchTerms?: string;
430
+ /** Search algorithm/version. Defaults to the current ranked mode. */
401
431
  searchMode?: 'v1' | 'v2';
432
+ /** Include backend debug metadata in the search response. */
402
433
  includeSearchDebug?: boolean;
403
434
  }
435
+ /**
436
+ * Ranked tool/provider discovery response.
437
+ *
438
+ * Includes matching tools plus render/action hints used by the CLI and agents.
439
+ */
404
440
  interface ToolSearchResult {
441
+ /** Ranked matching tools. */
405
442
  tools: ToolDefinition[];
443
+ /** Count included in this response when available. */
406
444
  count?: number;
445
+ /** Total available count when the backend reports it. */
407
446
  total?: number;
447
+ /** Whether results were truncated by server-side limits. */
408
448
  truncated?: boolean;
449
+ /** Echoed query. */
409
450
  query?: string;
451
+ /** Parsed category filters. */
410
452
  categories?: string[];
453
+ /** Parsed search terms. */
411
454
  search_terms?: string[];
455
+ /** Search mode used. */
412
456
  search_mode?: 'v1' | 'v2';
457
+ /** Whether search fell back to category matching. */
413
458
  search_fallback_to_category?: boolean;
459
+ /** Hint explaining omitted play results when searching tools only. */
414
460
  omitted_plays_hint?: string;
461
+ /** Copyable CLI command templates for follow-up discovery/execution. */
415
462
  commandTemplates?: {
416
463
  describe?: string;
417
464
  execute?: string;
418
465
  };
466
+ /** Pre-rendered sections and actions for CLI/agent display. */
419
467
  render?: {
420
468
  sections?: Array<{
421
469
  title: string;
@@ -534,9 +582,19 @@ type PlayRunActionPackage = {
534
582
  datasetPath: string;
535
583
  format: 'csv';
536
584
  };
585
+ /**
586
+ * Compact canonical package for an inspected play run.
587
+ *
588
+ * This object is designed for SDK/CLI/API consumers that need stable run
589
+ * metadata, output handles, and follow-up actions without reading dashboard
590
+ * internals.
591
+ */
537
592
  interface PlayRunPackage {
593
+ /** Package schema version. */
538
594
  schemaVersion: 1;
595
+ /** Package discriminator. */
539
596
  kind: 'play_run';
597
+ /** Run identity, status, timing, and dashboard metadata. */
540
598
  run: {
541
599
  id: string;
542
600
  playName: string;
@@ -548,8 +606,11 @@ interface PlayRunPackage {
548
606
  durationMs?: number | null;
549
607
  error?: string;
550
608
  };
609
+ /** Step-level summaries emitted by the runtime. */
551
610
  steps: Array<Record<string, unknown>>;
611
+ /** Named output summaries, including dataset handles and scalar outputs. */
552
612
  outputs: Record<string, Record<string, unknown>>;
613
+ /** Follow-up actions a caller can perform against the run. */
553
614
  next?: {
554
615
  inspect?: PlayRunActionPackage;
555
616
  export?: PlayRunActionPackage;
@@ -1136,6 +1197,13 @@ type EnrichCompiledConfig = {
1136
1197
  type ExecuteToolRawOptions = {
1137
1198
  includeToolMetadata?: boolean;
1138
1199
  };
1200
+ /**
1201
+ * Standard provider/tool execution envelope returned by low-level SDK calls.
1202
+ *
1203
+ * `toolResponse.raw` contains the provider result. `extractedValues` and
1204
+ * `extractedLists` contain Deepline-normalized getters when the tool exposes
1205
+ * them. Billing fields are Deepline-facing and must not expose provider spend.
1206
+ */
1139
1207
  type ToolExecution<TData = unknown, TMeta = Record<string, unknown>> = {
1140
1208
  status: string;
1141
1209
  job_id?: string;
@@ -1149,16 +1217,20 @@ type ToolExecution<TData = unknown, TMeta = Record<string, unknown>> = {
1149
1217
  billing?: Record<string, unknown>;
1150
1218
  [key: string]: unknown;
1151
1219
  };
1220
+ /** Filters for `client.runs.list(...)`. */
1152
1221
  type RunsListOptions = {
1153
1222
  play: string;
1154
1223
  status?: string;
1155
1224
  };
1225
+ /** Streaming options for `client.runs.tail(...)`. */
1156
1226
  type RunsTailOptions = {
1157
1227
  signal?: AbortSignal;
1158
1228
  };
1229
+ /** Log fetch options for `client.runs.logs(...)`. */
1159
1230
  type RunsLogsOptions = {
1160
1231
  limit?: number;
1161
1232
  };
1233
+ /** Persisted log response for one play run. */
1162
1234
  type RunsLogsResult = {
1163
1235
  runId: string;
1164
1236
  totalCount: number;
@@ -1169,12 +1241,14 @@ type RunsLogsResult = {
1169
1241
  hasMore: boolean;
1170
1242
  entries: string[];
1171
1243
  };
1244
+ /** One persisted runtime-sheet row returned by `client.runs.exportDatasetRows(...)`. */
1172
1245
  type PlaySheetRow = {
1173
1246
  key?: string;
1174
1247
  status?: string;
1175
1248
  data?: Record<string, unknown>;
1176
1249
  [key: string]: unknown;
1177
1250
  };
1251
+ /** Runtime-sheet rows and aggregate progress for one dataset/table namespace. */
1178
1252
  type PlaySheetRowsResult = {
1179
1253
  rows: PlaySheetRow[];
1180
1254
  summary?: {
@@ -1204,13 +1278,27 @@ type PlaySecretMetadata = {
1204
1278
  updatedAt: number;
1205
1279
  lastUsedAt?: number;
1206
1280
  };
1281
+ /**
1282
+ * Public runs namespace exposed as `client.runs`.
1283
+ *
1284
+ * This namespace mirrors the canonical `/api/v2/runs` resource family and is
1285
+ * the preferred low-level surface for polling, streaming, stopping, reading
1286
+ * logs, and exporting durable dataset rows.
1287
+ *
1288
+ * @sdkReference client 020 client.runs
1289
+ */
1207
1290
  type RunsNamespace = {
1291
+ /** Get current run status by public run id. */
1208
1292
  get: (runId: string, options?: {
1209
1293
  full?: boolean;
1210
1294
  }) => Promise<PlayStatus>;
1295
+ /** List runs for one play, optionally filtered by status. */
1211
1296
  list: (options: RunsListOptions) => Promise<PlayRunListItem[]>;
1297
+ /** Stream run events and return the latest/terminal run status. */
1212
1298
  tail: (runId: string, options?: RunsTailOptions) => Promise<PlayStatus>;
1299
+ /** Fetch persisted log lines for a run. */
1213
1300
  logs: (runId: string, options?: RunsLogsOptions) => Promise<RunsLogsResult>;
1301
+ /** Export persisted rows for a runtime-sheet dataset/table namespace. */
1214
1302
  exportDatasetRows: (input: {
1215
1303
  playName: string;
1216
1304
  tableNamespace: string;
@@ -1218,6 +1306,7 @@ type RunsNamespace = {
1218
1306
  limit?: number;
1219
1307
  offset?: number;
1220
1308
  }) => Promise<PlaySheetRowsResult>;
1309
+ /** Stop a running/waiting run. */
1221
1310
  stop: (runId: string, options?: {
1222
1311
  reason?: string;
1223
1312
  }) => Promise<StopPlayRunResult>;
@@ -1241,12 +1330,20 @@ type RunsNamespace = {
1241
1330
  * baseUrl: 'http://localhost:3000',
1242
1331
  * });
1243
1332
  * ```
1333
+ *
1334
+ * @sdkReference client 010
1244
1335
  */
1245
1336
  declare class DeeplineClient {
1246
1337
  private readonly http;
1247
1338
  private readonly config;
1339
+ /** Canonical run lifecycle namespace backed by `/api/v2/runs`. */
1248
1340
  readonly runs: RunsNamespace;
1249
1341
  /**
1342
+ * Create a low-level SDK client.
1343
+ *
1344
+ * Most callers can omit options and let the SDK resolve auth/config from
1345
+ * environment variables and CLI-managed credentials.
1346
+ *
1250
1347
  * @param options - Optional overrides for API key, base URL, timeout, and retries.
1251
1348
  * @throws {@link ConfigError} if no API key can be resolved from any source.
1252
1349
  */
@@ -1260,7 +1357,14 @@ declare class DeeplineClient {
1260
1357
  private playCloneEditStarter;
1261
1358
  private summarizePlayListItem;
1262
1359
  private summarizePlayDetail;
1360
+ /** List secret metadata visible to the current workspace. */
1263
1361
  listSecrets(): Promise<PlaySecretMetadata[]>;
1362
+ /**
1363
+ * Check whether a named secret exists, is active, and has a stored value.
1364
+ *
1365
+ * @param name - Secret name. It is normalized to uppercase before lookup.
1366
+ * @returns Matching active secret metadata, or `null`.
1367
+ */
1264
1368
  checkSecret(name: string): Promise<PlaySecretMetadata | null>;
1265
1369
  /**
1266
1370
  * List all available tools.
@@ -1316,7 +1420,19 @@ declare class DeeplineClient {
1316
1420
  * Deepline execution envelope.
1317
1421
  */
1318
1422
  executeTool<TData = unknown, TMeta = Record<string, unknown>>(toolId: string, input: Record<string, unknown>, options?: ExecuteToolRawOptions): Promise<ToolExecution<TData, TMeta>>;
1423
+ /**
1424
+ * Back-compatible alias for {@link executeTool}.
1425
+ *
1426
+ * Retained for callers that still use the older raw naming while the response
1427
+ * envelope remains the same.
1428
+ */
1319
1429
  executeToolRaw<TData = unknown, TMeta = Record<string, unknown>>(toolId: string, input: Record<string, unknown>, options?: ExecuteToolRawOptions): Promise<ToolExecution<TData, TMeta>>;
1430
+ /**
1431
+ * Run a bounded SQL query against the customer data plane.
1432
+ *
1433
+ * Use this from trusted backend or agent contexts only. The API enforces
1434
+ * workspace scoping and row limits.
1435
+ */
1320
1436
  queryCustomerDb(input: {
1321
1437
  sql: string;
1322
1438
  maxRows?: number;
@@ -1355,6 +1471,17 @@ declare class DeeplineClient {
1355
1471
  * ```
1356
1472
  */
1357
1473
  startPlayRun(request: StartPlayRunRequest): Promise<PlayRunStart>;
1474
+ /**
1475
+ * Start a play run and stream live runtime events from the same request.
1476
+ *
1477
+ * Use this when a caller wants low-level event handling instead of submitting
1478
+ * first and then connecting to `streamPlayRunEvents(runId)`.
1479
+ *
1480
+ * @param request - Play run configuration.
1481
+ * @param options - Optional streaming options.
1482
+ * @param options.signal - Optional abort signal for the streaming request.
1483
+ * @returns Async stream of play-scoped live events.
1484
+ */
1358
1485
  startPlayRunStream(request: StartPlayRunRequest, options?: {
1359
1486
  signal?: AbortSignal;
1360
1487
  }): AsyncGenerator<PlayLiveEvent>;
@@ -1387,6 +1514,12 @@ declare class DeeplineClient {
1387
1514
  triggerMetadata?: unknown;
1388
1515
  triggerBindings?: unknown;
1389
1516
  }>;
1517
+ /**
1518
+ * Register multiple bundled play artifacts in one request.
1519
+ *
1520
+ * Used by packaging and prebuilt publication flows. Each artifact is compiled
1521
+ * first when a compiler manifest is not already supplied.
1522
+ */
1390
1523
  registerPlayArtifacts(artifacts: Array<{
1391
1524
  name: string;
1392
1525
  sourceCode: string;
@@ -1413,6 +1546,13 @@ declare class DeeplineClient {
1413
1546
  triggerBindings?: unknown;
1414
1547
  }>;
1415
1548
  }>;
1549
+ /**
1550
+ * Compile a bundled play artifact into the server-side compiler manifest.
1551
+ *
1552
+ * The manifest records imports, trigger bindings, static pipeline shape, and
1553
+ * runtime metadata needed before a play artifact can be checked, registered,
1554
+ * or run.
1555
+ */
1416
1556
  compilePlayManifest(input: {
1417
1557
  name: string;
1418
1558
  sourceCode: string;
@@ -1433,12 +1573,24 @@ declare class DeeplineClient {
1433
1573
  sourceFiles?: Record<string, string>;
1434
1574
  artifact: Record<string, unknown>;
1435
1575
  }): Promise<PlayCheckResult>;
1576
+ /**
1577
+ * Compile legacy enrich command arguments into a runtime plan.
1578
+ *
1579
+ * This is primarily used by CLI compatibility paths that translate older
1580
+ * enrichment commands onto the play runtime.
1581
+ */
1436
1582
  compileEnrichPlan(input: {
1437
1583
  plan_args?: string[];
1438
1584
  config?: unknown;
1439
1585
  }): Promise<{
1440
1586
  config: EnrichCompiledConfig;
1441
1587
  }>;
1588
+ /**
1589
+ * Register an already-bundled play artifact and start a run from it.
1590
+ *
1591
+ * This is the low-level file-backed run path used by SDK/CLI packaging
1592
+ * wrappers after local bundling has produced the runtime artifact.
1593
+ */
1442
1594
  startPlayRunFromBundle(input: {
1443
1595
  name: string;
1444
1596
  sourceCode: string;
@@ -1515,6 +1667,12 @@ declare class DeeplineClient {
1515
1667
  contentType: string;
1516
1668
  bytes: number;
1517
1669
  }>): Promise<PlayStagedFileRef[]>;
1670
+ /**
1671
+ * Resolve staged play files by content hash without uploading bytes.
1672
+ *
1673
+ * Missing files are returned so callers can upload only the files the server
1674
+ * does not already have.
1675
+ */
1518
1676
  resolveStagedPlayFiles(files: Array<{
1519
1677
  logicalPath: string;
1520
1678
  contentHash: string;
@@ -1632,6 +1790,12 @@ declare class DeeplineClient {
1632
1790
  * ```
1633
1791
  */
1634
1792
  getRunLogs(runId: string, options?: RunsLogsOptions): Promise<RunsLogsResult>;
1793
+ /**
1794
+ * Export persisted runtime-sheet rows for a play dataset/table namespace.
1795
+ *
1796
+ * This is the SDK form of exporting `ctx.dataset(...).run()` output for a
1797
+ * specific play and optional run id.
1798
+ */
1635
1799
  getPlaySheetRows(input: {
1636
1800
  playName: string;
1637
1801
  tableNamespace: string;
@@ -1651,14 +1815,27 @@ declare class DeeplineClient {
1651
1815
  stopRun(runId: string, options?: {
1652
1816
  reason?: string;
1653
1817
  }): Promise<StopPlayRunResult>;
1818
+ /**
1819
+ * List callable plays visible to the workspace.
1820
+ *
1821
+ * Pass `origin: "prebuilt"` for Deepline-managed prebuilts or
1822
+ * `origin: "owned"` for org-owned plays.
1823
+ */
1654
1824
  listPlays(options?: {
1655
1825
  origin?: 'prebuilt' | 'owned';
1656
1826
  grep?: string;
1657
1827
  grepMode?: 'all' | 'any' | 'phrase';
1658
1828
  }): Promise<PlayListItem[]>;
1829
+ /**
1830
+ * Search callable plays and return compact play descriptions.
1831
+ *
1832
+ * Prebuilt plays are preferred by default because they have maintained
1833
+ * contracts and stable run behavior.
1834
+ */
1659
1835
  searchPlays(options: {
1660
1836
  query: string;
1661
1837
  compact?: boolean;
1838
+ scope?: 'prebuilt' | 'owned' | 'all';
1662
1839
  }): Promise<PlayDescription[]>;
1663
1840
  /**
1664
1841
  * Get the full definition and state of a named play.
@@ -1678,6 +1855,12 @@ declare class DeeplineClient {
1678
1855
  * ```
1679
1856
  */
1680
1857
  getPlay(name: string): Promise<PlayDetail>;
1858
+ /**
1859
+ * Get a normalized play description suitable for agents and CLIs.
1860
+ *
1861
+ * The description includes runnable examples, input/output summaries, clone
1862
+ * guidance, revision state, and latest run metadata when available.
1863
+ */
1681
1864
  describePlay(name: string, options?: {
1682
1865
  compact?: boolean;
1683
1866
  }): Promise<PlayDescription>;
@@ -2004,6 +2187,8 @@ type PlayDatasetTransformOptions = {
2004
2187
  * small and bounded. `PlayDataset` intentionally does not expose `.rows`,
2005
2188
  * `.toArray()`, or other array aliases; those hide the runtime cost of loading
2006
2189
  * persisted rows into memory.
2190
+ *
2191
+ * @sdkReference runtime 190
2007
2192
  */
2008
2193
  interface PlayDataset<T> extends AsyncIterable<T> {
2009
2194
  readonly [PLAY_DATASET_BRAND]: true;
@@ -2337,15 +2522,28 @@ type ToolExecuteResultAccessors<TExtracted extends Record<string, unknown> = Par
2337
2522
  * Use extractors first when a tool contract exposes them. Drop to
2338
2523
  * `toolResponse.raw` when you need provider-specific fields or when debugging
2339
2524
  * from persisted run rows.
2525
+ *
2526
+ * @sdkReference runtime 200
2340
2527
  */
2341
2528
  type ToolExecuteResult<TResult = unknown, TMeta = Record<string, unknown>, TExtracted extends Record<string, unknown> = Partial<DeeplineGetterValueMap>, TLists extends Record<string, Record<string, unknown>> = Record<string, Record<string, unknown>>> = ToolExecuteResultBase<TResult, TMeta> & ToolExecuteResultAccessors<TExtracted, TLists>;
2342
2529
 
2343
- type StaleAfterSecondsResolver<Value = unknown> = (value: Value) => number | null;
2344
- type AuthoredStaleAfterSeconds<Value = unknown> = number | StaleAfterSecondsResolver<Value>;
2530
+ /**
2531
+ * Previous durable cell value passed to object-column resolvers.
2532
+ *
2533
+ * The runtime supplies this when a row+column is being recomputed after a
2534
+ * previous value existed. `value` has the same type that the column returns;
2535
+ * freshness metadata lives beside it.
2536
+ *
2537
+ * @sdkReference runtime 120
2538
+ */
2345
2539
  type PreviousCell<Value = unknown> = {
2540
+ /** Previous completed value for this row+column. */
2346
2541
  value: Value;
2542
+ /** Millisecond timestamp when the previous value completed. */
2347
2543
  completedAt?: number;
2544
+ /** Millisecond timestamp when the previous value becomes stale; `null` means no expiry. */
2348
2545
  staleAt?: number | null;
2546
+ /** Resolved numeric TTL in seconds for the previous value, when present. */
2349
2547
  staleAfterSeconds?: number;
2350
2548
  };
2351
2549
 
@@ -2375,6 +2573,8 @@ type PreviousCell<Value = unknown> = {
2375
2573
  * cron: { schedule: '0 2 * * *', timezone: 'UTC' },
2376
2574
  * });
2377
2575
  * ```
2576
+ *
2577
+ * @sdkReference runtime 030
2378
2578
  */
2379
2579
  type PlayBindings = {
2380
2580
  /** Optional per-run billing controls enforced by the runtime. */
@@ -2433,6 +2633,8 @@ type LoosePlayObject = {
2433
2633
  *
2434
2634
  * The `tool` value comes from live tool discovery. The `id` is the stable
2435
2635
  * logical call name inside this play and participates in replay/idempotency.
2636
+ *
2637
+ * @sdkReference runtime 160
2436
2638
  */
2437
2639
  type ToolExecutionRequest = {
2438
2640
  /** Stable logical id for this tool call within the play. */
@@ -2443,13 +2645,36 @@ type ToolExecutionRequest = {
2443
2645
  input: Record<string, unknown>;
2444
2646
  /** Human-readable description for logs and run inspection. */
2445
2647
  description?: string;
2648
+ /** Numeric TTL in seconds for this tool checkpoint. */
2446
2649
  staleAfterSeconds?: number;
2447
2650
  };
2448
- type StaleAfterSeconds<Value = unknown> = AuthoredStaleAfterSeconds<Value>;
2651
+ /**
2652
+ * Freshness policy for dataset cells and step-program columns.
2653
+ *
2654
+ * Use a positive whole number of seconds for a fixed TTL. Use a function when
2655
+ * the next expiry depends on the value that was just produced. The function
2656
+ * receives the completed cell value; return a positive whole number of seconds
2657
+ * to set the next expiry, or `null` to keep that value indefinitely.
2658
+ *
2659
+ * Result-based policies are evaluated only for dataset/step-program cells. The
2660
+ * scalar `ctx.step`, `ctx.fetch`, `ctx.runPlay`, and `ctx.tools.execute` APIs
2661
+ * accept numeric TTLs.
2662
+ *
2663
+ * @sdkReference runtime 080
2664
+ */
2665
+ type StaleAfterSeconds<Value = unknown> = number | ((value: Value) => number | null);
2449
2666
  type StepResolver<Row, Value> = (row: Row, ctx: DeeplinePlayRuntimeContext, index: number, previousCell?: PreviousCell<Value>) => Value | Promise<Value>;
2667
+ /**
2668
+ * Input object passed to an object-column `run` resolver.
2669
+ *
2670
+ * @sdkReference runtime 090
2671
+ */
2450
2672
  type DatasetColumnRunInput<Row, Value> = {
2673
+ /** Current row, including previously computed columns. */
2451
2674
  row: Row;
2675
+ /** Runtime context for tool/play/fetch/log calls. */
2452
2676
  ctx: DeeplinePlayRuntimeContext;
2677
+ /** Zero-based row index for this dataset run. */
2453
2678
  index: number;
2454
2679
  /**
2455
2680
  * The prior stored value for this exact row+column when the runtime has
@@ -2459,9 +2684,20 @@ type DatasetColumnRunInput<Row, Value> = {
2459
2684
  */
2460
2685
  previousCell?: PreviousCell<Value>;
2461
2686
  };
2687
+ /**
2688
+ * Object-column form for `.withColumn(...)`.
2689
+ *
2690
+ * Use this when a column needs `runIf`, typed `previousCell`, or a
2691
+ * result-based `staleAfterSeconds(value)` policy.
2692
+ *
2693
+ * @sdkReference runtime 100
2694
+ */
2462
2695
  type DatasetColumnDefinition<Row, Value> = {
2696
+ /** Compute one cell value. Receives the previous stored value when rerunning. */
2463
2697
  run: (input: DatasetColumnRunInput<Row, Value>) => Value | Promise<Value>;
2698
+ /** Optional row-level gate. Skipped rows produce `null` for this column. */
2464
2699
  readonly runIf?: (row: Row, index: number) => boolean | Promise<boolean>;
2700
+ /** Fixed or value-dependent freshness policy for this cell. */
2465
2701
  readonly staleAfterSeconds?: StaleAfterSeconds<Value>;
2466
2702
  };
2467
2703
  type ConditionalStepResolver<Row, Value, Else = null> = {
@@ -2471,8 +2707,15 @@ type ConditionalStepResolver<Row, Value, Else = null> = {
2471
2707
  readonly elseValue: Else;
2472
2708
  else<ValueElse>(value: ValueElse): ConditionalStepResolver<Row, Value, ValueElse>;
2473
2709
  };
2710
+ /**
2711
+ * Options for row-level `.withColumn(...)` and `steps().step(...)` entries.
2712
+ *
2713
+ * @sdkReference runtime 110
2714
+ */
2474
2715
  type StepOptions<Row, Value = unknown> = {
2716
+ /** Optional row-level gate. Skipped rows produce `null` for this column. */
2475
2717
  readonly runIf?: (row: Row, index: number) => boolean | Promise<boolean>;
2718
+ /** Fixed or value-dependent freshness policy for this cell. */
2476
2719
  readonly staleAfterSeconds?: StaleAfterSeconds<Value>;
2477
2720
  };
2478
2721
  type StepProgram<Input, Output, Return = Output> = {
@@ -2497,6 +2740,11 @@ type PlayStepProgramStep = {
2497
2740
  };
2498
2741
  type ColumnResolver<Row, Value> = StepResolver<Row, Value> | ConditionalStepResolver<Row, Value> | StepProgramResolver<Row, Value>;
2499
2742
  type StepProgramOutput<TProgram> = TProgram extends StepProgram<any, infer Output, any> ? Output : never;
2743
+ /**
2744
+ * Builder returned by `ctx.dataset(...)` for row-level durable columns.
2745
+ *
2746
+ * @sdkReference runtime 070 .dataset(...).withColumn(name, resolver).run(options)
2747
+ */
2500
2748
  type DatasetBuilder<InputRow extends object, OutputRow extends object> = {
2501
2749
  /**
2502
2750
  * Define one output column for every row in this dataset.
@@ -2512,10 +2760,35 @@ type DatasetBuilder<InputRow extends object, OutputRow extends object> = {
2512
2760
  * @returns The same dataset builder with the new column type.
2513
2761
  */
2514
2762
  withColumn<Name extends string, Value>(name: Name, resolver: ColumnResolver<OutputRow, Value>): DatasetBuilder<InputRow, OutputRow & Record<Name, Value>>;
2763
+ /**
2764
+ * Define one output column with object-column authoring and a row gate.
2765
+ *
2766
+ * @param name - Output column name.
2767
+ * @param definition - Object-column definition with required `runIf`.
2768
+ * @returns The same dataset builder with a nullable column type for skipped rows.
2769
+ */
2515
2770
  withColumn<Name extends string, Value>(name: Name, definition: DatasetColumnDefinition<OutputRow, Value> & {
2516
2771
  readonly runIf: (row: OutputRow, index: number) => boolean | Promise<boolean>;
2517
2772
  }): DatasetBuilder<InputRow, OutputRow & Record<Name, Value | null>>;
2773
+ /**
2774
+ * Define one output column with object-column authoring.
2775
+ *
2776
+ * Use this form for typed `previousCell` access or result-based
2777
+ * `staleAfterSeconds(value)` policies.
2778
+ *
2779
+ * @param name - Output column name.
2780
+ * @param definition - Object-column definition.
2781
+ * @returns The same dataset builder with the new column type.
2782
+ */
2518
2783
  withColumn<Name extends string, Value>(name: Name, definition: DatasetColumnDefinition<OutputRow, Value>): DatasetBuilder<InputRow, OutputRow & Record<Name, Value>>;
2784
+ /**
2785
+ * Define one output column with a resolver plus row-level options.
2786
+ *
2787
+ * @param name - Output column name.
2788
+ * @param resolver - Computes the value for one row.
2789
+ * @param options - Row gate and freshness options.
2790
+ * @returns The same dataset builder with a nullable column type for skipped rows.
2791
+ */
2519
2792
  withColumn<Name extends string, Value>(name: Name, resolver: StepResolver<OutputRow, Value> | StepProgramResolver<OutputRow, Value>, options: StepOptions<OutputRow, Value>): DatasetBuilder<InputRow, OutputRow & Record<Name, Value | null>>;
2520
2793
  withColumns<Program extends StepProgram<OutputRow, object, unknown>>(program: Program): DatasetBuilder<InputRow, StepProgramOutput<Program>>;
2521
2794
  /** @deprecated Dataset `.step(...)` was replaced by `.withColumn(...)`. */
@@ -2554,7 +2827,11 @@ type CsvInput<TRow extends object = Record<string, unknown>> = FileInput<{
2554
2827
  readonly row: TRow;
2555
2828
  }>;
2556
2829
  type ColumnMap<TRow extends object> = Partial<Record<Extract<keyof TRow, string>, string | readonly string[]>>;
2557
- /** Options for loading a staged CSV with `ctx.csv(...)`. */
2830
+ /**
2831
+ * Options for loading a staged CSV with `ctx.csv(...)`.
2832
+ *
2833
+ * @sdkReference runtime 050
2834
+ */
2558
2835
  type CsvOptions = {
2559
2836
  /** Human-readable description for runtime logs and inspection. */
2560
2837
  description?: string;
@@ -2628,6 +2905,8 @@ interface DeeplinePlayRuntimeContext {
2628
2905
  * @param options - CSV load options.
2629
2906
  *
2630
2907
  * @returns A {@link PlayDataset} whose rows should usually flow directly into `ctx.dataset(...)`.
2908
+ *
2909
+ * @sdkReference runtime 040 ctx.csv(path, options)
2631
2910
  */
2632
2911
  csv<T = Record<string, unknown>>(path: string, options?: CsvOptions): Promise<PlayDataset<T>>;
2633
2912
  /**
@@ -2684,6 +2963,8 @@ interface DeeplinePlayRuntimeContext {
2684
2963
  * row.company?.employeeCount > 100 ? 'enterprise' : 'smb')
2685
2964
  * .run({ description: 'Enrich leads.' });
2686
2965
  * ```
2966
+ *
2967
+ * @sdkReference runtime 060 ctx.dataset(key, items)
2687
2968
  */
2688
2969
  dataset<TItem extends object>(key: string, items: PlayDatasetInput<TItem>): DatasetBuilder<TItem, TItem>;
2689
2970
  /**
@@ -2697,6 +2978,8 @@ interface DeeplinePlayRuntimeContext {
2697
2978
  *
2698
2979
  * @param request - Tool call request.
2699
2980
  * @returns Tool execution result.
2981
+ *
2982
+ * @sdkReference runtime 150 ctx.tools.execute(request)
2700
2983
  */
2701
2984
  execute<TOutput = LoosePlayObject>(request: ToolExecutionRequest & {
2702
2985
  staleAfterSeconds?: number;
@@ -2723,6 +3006,8 @@ interface DeeplinePlayRuntimeContext {
2723
3006
  * @param input - Program input.
2724
3007
  * @param options - Run options.
2725
3008
  * @returns Program output.
3009
+ *
3010
+ * @sdkReference runtime 180 ctx.runSteps(program, input, options)
2726
3011
  */
2727
3012
  runSteps<TInput extends Record<string, unknown>, TOutput>(program: StepProgram<TInput, any, TOutput>, input: TInput, options?: {
2728
3013
  description?: string;
@@ -2743,6 +3028,8 @@ interface DeeplinePlayRuntimeContext {
2743
3028
  * @param run - Computes the value once.
2744
3029
  * @param options - Checkpoint options.
2745
3030
  * @returns Checkpoint value.
3031
+ *
3032
+ * @sdkReference runtime 130 ctx.step(id, fn)
2746
3033
  */
2747
3034
  step<T>(id: string, run: () => T | Promise<T>, options?: {
2748
3035
  staleAfterSeconds?: number;
@@ -2759,6 +3046,8 @@ interface DeeplinePlayRuntimeContext {
2759
3046
  * @param url - URL to fetch.
2760
3047
  * @param init - Fetch options.
2761
3048
  * @returns Recorded response.
3049
+ *
3050
+ * @sdkReference runtime 170 ctx.fetch(key, url, init)
2762
3051
  */
2763
3052
  fetch(key: string, url: string | URL, init?: SecretAwareRequestInit, options?: {
2764
3053
  staleAfterSeconds?: number;
@@ -2771,6 +3060,11 @@ interface DeeplinePlayRuntimeContext {
2771
3060
  bodyText: string;
2772
3061
  json: unknown | null;
2773
3062
  }>;
3063
+ secrets: {
3064
+ get(name: string): SecretHandle;
3065
+ bearer(secret: SecretHandle): SecretAuth;
3066
+ header(header: string, secret: SecretHandle): SecretAuth;
3067
+ };
2774
3068
  /**
2775
3069
  * Invoke another registered or file-backed play as a child workflow.
2776
3070
  *
@@ -2786,12 +3080,9 @@ interface DeeplinePlayRuntimeContext {
2786
3080
  * @param input - Input object passed to the child play.
2787
3081
  * @param options - Child play options.
2788
3082
  * @returns Child play output.
3083
+ *
3084
+ * @sdkReference runtime 140 ctx.runPlay(key, playRef, input, options)
2789
3085
  */
2790
- secrets: {
2791
- get(name: string): SecretHandle;
2792
- bearer(secret: SecretHandle): SecretAuth;
2793
- header(header: string, secret: SecretHandle): SecretAuth;
2794
- };
2795
3086
  runPlay<TOutput = unknown>(key: string, playRef: string | PlayReferenceLike, input: Record<string, unknown>, options: {
2796
3087
  description?: string;
2797
3088
  staleAfterSeconds?: number;
@@ -2846,6 +3137,8 @@ interface DeeplinePlayRuntimeContext {
2846
3137
  * // Cancel if needed
2847
3138
  * await job.cancel();
2848
3139
  * ```
3140
+ *
3141
+ * @sdkReference plays 030
2849
3142
  */
2850
3143
  interface PlayJob<TOutput = unknown> {
2851
3144
  /** Temporal workflow ID for this execution. */
@@ -2919,6 +3212,8 @@ interface PlayJob<TOutput = unknown> {
2919
3212
  * // Publish the current draft
2920
3213
  * await play.publish();
2921
3214
  * ```
3215
+ *
3216
+ * @sdkReference plays 020
2922
3217
  */
2923
3218
  interface DeeplineNamedPlay<TInput = Record<string, unknown>, TOutput = unknown> {
2924
3219
  /** The play's name. */
@@ -2960,6 +3255,39 @@ interface DeeplineNamedPlay<TInput = Record<string, unknown>, TOutput = unknown>
2960
3255
  revisionId?: string;
2961
3256
  }): Promise<TOutput>;
2962
3257
  }
3258
+ /**
3259
+ * Tool/provider operations available from a connected {@link DeeplineContext}.
3260
+ *
3261
+ * This namespace is for regular SDK callers outside a play runtime. Inside a
3262
+ * `definePlay(...)` body, use `ctx.tools.execute({ id, tool, input, ... })`
3263
+ * so provider calls become durable runtime checkpoints.
3264
+ *
3265
+ * @sdkReference tools 010 DeeplineContext.tools
3266
+ */
3267
+ type DeeplineToolsNamespace = {
3268
+ /** List all available provider-backed tools. */
3269
+ list(): Promise<ToolDefinition[]>;
3270
+ /** Get detailed metadata for one provider-backed tool. */
3271
+ get(toolId: string): Promise<ToolMetadata>;
3272
+ /**
3273
+ * Execute a provider-backed tool from a regular SDK process.
3274
+ *
3275
+ * For durable play code, prefer `ctx.tools.execute(...)` because the play
3276
+ * runtime records the call under a stable id.
3277
+ */
3278
+ execute(toolId: string, input: Record<string, unknown>): Promise<ToolExecuteResult>;
3279
+ };
3280
+ /**
3281
+ * Named-play discovery and handle operations from a connected {@link DeeplineContext}.
3282
+ *
3283
+ * @sdkReference plays 010 DeeplineContext.plays
3284
+ */
3285
+ type DeeplinePlaysNamespace = {
3286
+ /** List saved and callable plays visible to the current workspace. */
3287
+ list(): Promise<PlayListItem[]>;
3288
+ /** Return a typed handle for a named, saved, shared, or prebuilt play. */
3289
+ get<TInput = Record<string, unknown>, TOutput = unknown>(name: string): DeeplineNamedPlay<TInput, TOutput>;
3290
+ };
2963
3291
  type PrebuiltPlayRef = {
2964
3292
  readonly playName: string;
2965
3293
  readonly name: string;
@@ -2983,6 +3311,8 @@ type PlayInputContract<TInput> = {
2983
3311
  * through `defineInput<T>(schema)`, or when configuration reads clearer as one
2984
3312
  * object. The shorthand `definePlay(name, fn, bindings?)` is equivalent for
2985
3313
  * simple file-backed plays.
3314
+ *
3315
+ * @sdkReference runtime 020
2986
3316
  */
2987
3317
  type DefinePlayConfig<TInput, TOutput extends PlayReturnObject> = {
2988
3318
  /** Play id/name. */
@@ -3062,9 +3392,19 @@ type PlayMetadata = {
3062
3392
  * const job = await deepline.play('email-waterfall').run({ domain: 'stripe.com' });
3063
3393
  * const output = await job.get();
3064
3394
  * ```
3395
+ *
3396
+ * @sdkReference entrypoints 020
3065
3397
  */
3066
3398
  declare class DeeplineContext {
3067
3399
  private readonly client;
3400
+ /**
3401
+ * Create a high-level SDK context.
3402
+ *
3403
+ * Most callers should use {@link Deepline.connect}; direct construction is
3404
+ * equivalent when you already have explicit client options.
3405
+ *
3406
+ * @param options - Optional SDK client configuration.
3407
+ */
3068
3408
  constructor(options?: DeeplineClientOptions);
3069
3409
  /**
3070
3410
  * Tool operations namespace.
@@ -3077,18 +3417,21 @@ declare class DeeplineContext {
3077
3417
  * const company = companyLookup.toolResponse.raw;
3078
3418
  * ```
3079
3419
  */
3080
- get tools(): {
3081
- /** List all available tools. */
3082
- list: () => Promise<ToolDefinition[]>;
3083
- /** Get detailed metadata for a tool. */
3084
- get: (toolId: string) => Promise<ToolMetadata>;
3085
- /** Execute a tool and return the standard execution envelope. */
3086
- execute: (toolId: string, input: Record<string, unknown>) => Promise<ToolExecuteResult>;
3087
- };
3088
- get plays(): {
3089
- list: () => Promise<PlayListItem[]>;
3090
- get: <TInput = Record<string, unknown>, TOutput = unknown>(name: string) => DeeplineNamedPlay<TInput, TOutput>;
3091
- };
3420
+ get tools(): DeeplineToolsNamespace;
3421
+ /**
3422
+ * Play discovery and named-play handles.
3423
+ *
3424
+ * Use `plays.list()` for discovery and `plays.get(name)` when you prefer a
3425
+ * namespace spelling over `ctx.play(name)`.
3426
+ */
3427
+ get plays(): DeeplinePlaysNamespace;
3428
+ /**
3429
+ * Convenience references for Deepline-managed prebuilt plays.
3430
+ *
3431
+ * Known prebuilts are exposed by camel-cased aliases. Any other property is
3432
+ * converted into `prebuilt/<property>` so callers can pass the reference to
3433
+ * `ctx.runPlay(...)`.
3434
+ */
3092
3435
  get prebuilt(): Record<string, PrebuiltPlayRef>;
3093
3436
  /**
3094
3437
  * Get a named play handle for remote lifecycle operations.
@@ -3106,6 +3449,17 @@ declare class DeeplineContext {
3106
3449
  * ```
3107
3450
  */
3108
3451
  play<TInput = Record<string, unknown>, TOutput = unknown>(name: string): DeeplineNamedPlay<TInput, TOutput>;
3452
+ /**
3453
+ * Run a named or prebuilt play and wait for its output.
3454
+ *
3455
+ * This is the high-level SDK equivalent of `ctx.play(name).runSync(input)`.
3456
+ * Inside a play runtime, prefer the in-play `ctx.runPlay(key, playRef, input,
3457
+ * options)` form so the child run is checkpointed under a stable key.
3458
+ *
3459
+ * @param playOrRef - Play name or prebuilt/reference object.
3460
+ * @param input - JSON input passed to the play.
3461
+ * @returns Completed play output.
3462
+ */
3109
3463
  runPlay<TInput = Record<string, unknown>, TOutput = unknown>(playOrRef: string | PlayReferenceLike, input: TInput): Promise<TOutput>;
3110
3464
  }
3111
3465
  /**
@@ -3119,6 +3473,8 @@ declare class DeeplineContext {
3119
3473
  * const tools = await deepline.tools.list();
3120
3474
  * const result = await deepline.tools.execute('test_company_search', { domain: 'stripe.com' });
3121
3475
  * ```
3476
+ *
3477
+ * @sdkReference entrypoints 010
3122
3478
  */
3123
3479
  declare class Deepline {
3124
3480
  /**
@@ -3409,4 +3765,4 @@ declare function writeCsvOutputFile(rows: Array<Record<string, unknown>>, stem:
3409
3765
  */
3410
3766
  declare function extractSummaryFields(payload: unknown): Record<string, Scalar>;
3411
3767
 
3412
- export { AuthError, type ClearPlayHistoryRequest, type ClearPlayHistoryResult, type ColumnMap, type ColumnResolver, type ConditionalStepResolver, ConfigError, type CsvInput, DEEPLINE_EXTRACTOR_TARGETS, DEEPLINE_EXTRACTOR_TARGET_DEFINITIONS, DEEPLINE_TOOL_CATEGORIES, type DatasetBuilder, Deepline, DeeplineClient, type DeeplineClientOptions, DeeplineContext, type DeeplineEmailStatusGetterValue, DeeplineError, type DeeplineExtractorTarget, type DeeplineGetterValue, type DeeplineGetterValueMap, type DeeplineNamedPlay, type DeeplinePlayRuntimeContext, type DeeplineToolCategory, type DefinePlayConfig, type DefinedPlay, type FileInput, JOB_CHANGE_STATUS_VALUES, type JobChangeStatus, type LiveEventEnvelope, PHONE_STATUS_VALUES, PLAY_BOOTSTRAP_COMPANY_FIELDS, PLAY_BOOTSTRAP_COMPANY_PROVIDER_CATEGORY, PLAY_BOOTSTRAP_CONTACT_FIELDS, PLAY_BOOTSTRAP_FINDER_KINDS, PLAY_BOOTSTRAP_OUTPUT_FIELD_BY_FINDER, PLAY_BOOTSTRAP_PEOPLE_PROVIDER_CATEGORY, PLAY_BOOTSTRAP_PROVIDER_CATEGORY_BY_FINDER, PLAY_BOOTSTRAP_SOURCE_KINDS, PLAY_BOOTSTRAP_STAGE_KINDS, PLAY_BOOTSTRAP_TEMPLATES, PROD_URL, type PhoneStatus, type PlayBindings, type PlayBootstrapEntityKind, type PlayBootstrapFinderKind, type PlayDataset, type PlayDatasetInput, type PlayInputContract, type PlayJob, type PlayListItem, type PlayLiveEvent, type PlayRevisionSummary, type PlayRunResult, type PlayRunStart, type PlayStatus, type PlayStepProgramStep, type PrebuiltPlayRef, type PublishPlayVersionRequest, type PublishPlayVersionResult, RateLimitError, type ResolvedConfig, SDK_API_CONTRACT, SDK_VERSION, type StartPlayRunRequest, type StepProgram, type StepProgramResolver, type StepResolver, type ToolDefinition, type ToolExecuteResult, type ToolExecution, type ToolMetadata, defineInput, definePlay, defineWorkflow, extractSummaryFields, formatPlayBootstrapFinderKinds, formatPlayBootstrapFinderKindsForSentence, formatPlayBootstrapTemplates, getDefinedPlayMetadata, isDeeplineExtractorTarget, isPlayBootstrapFinderKind, isPlayBootstrapTemplate, resolveConfig, runIf, steps, tryConvertToList, writeCsvOutputFile, writeJsonOutputFile };
3768
+ export { AuthError, type ClearPlayHistoryRequest, type ClearPlayHistoryResult, type ColumnMap, type ColumnResolver, type ConditionalStepResolver, ConfigError, type CsvInput, type CsvOptions, type CustomerDbQueryResult, DEEPLINE_EXTRACTOR_TARGETS, DEEPLINE_EXTRACTOR_TARGET_DEFINITIONS, DEEPLINE_TOOL_CATEGORIES, type DatasetBuilder, type DatasetColumnDefinition, type DatasetColumnRunInput, Deepline, DeeplineClient, type DeeplineClientOptions, DeeplineContext, type DeeplineEmailStatusGetterValue, DeeplineError, type DeeplineExtractorTarget, type DeeplineGetterValue, type DeeplineGetterValueMap, type DeeplineNamedPlay, type DeeplinePlayRuntimeContext, type DeeplinePlaysNamespace, type DeeplineToolCategory, type DeeplineToolsNamespace, type DefinePlayConfig, type DefinedPlay, type FileInput, JOB_CHANGE_STATUS_VALUES, type JobChangeStatus, type LiveEventEnvelope, PHONE_STATUS_VALUES, PLAY_BOOTSTRAP_COMPANY_FIELDS, PLAY_BOOTSTRAP_COMPANY_PROVIDER_CATEGORY, PLAY_BOOTSTRAP_CONTACT_FIELDS, PLAY_BOOTSTRAP_FINDER_KINDS, PLAY_BOOTSTRAP_OUTPUT_FIELD_BY_FINDER, PLAY_BOOTSTRAP_PEOPLE_PROVIDER_CATEGORY, PLAY_BOOTSTRAP_PROVIDER_CATEGORY_BY_FINDER, PLAY_BOOTSTRAP_SOURCE_KINDS, PLAY_BOOTSTRAP_STAGE_KINDS, PLAY_BOOTSTRAP_TEMPLATES, PROD_URL, type PhoneStatus, type PlayBindings, type PlayBootstrapEntityKind, type PlayBootstrapFinderKind, type PlayDataset, type PlayDatasetInput, type PlayInputContract, type PlayJob, type PlayListItem, type PlayLiveEvent, type PlayRevisionSummary, type PlayRunResult, type PlayRunStart, type PlaySheetRow, type PlaySheetRowsResult, type PlayStatus, type PlayStepProgramStep, type PrebuiltPlayRef, type PreviousCell, type PublishPlayVersionRequest, type PublishPlayVersionResult, RateLimitError, type ResolvedConfig, type RunsListOptions, type RunsLogsOptions, type RunsLogsResult, type RunsNamespace, type RunsTailOptions, SDK_API_CONTRACT, SDK_VERSION, type StaleAfterSeconds, type StartPlayRunRequest, type StepOptions, type StepProgram, type StepProgramResolver, type StepResolver, type StopPlayRunResult, type ToolDefinition, type ToolExecuteResult, type ToolExecution, type ToolExecutionRequest, type ToolMetadata, type ToolSearchOptions, type ToolSearchResult, defineInput, definePlay, defineWorkflow, extractSummaryFields, formatPlayBootstrapFinderKinds, formatPlayBootstrapFinderKindsForSentence, formatPlayBootstrapTemplates, getDefinedPlayMetadata, isDeeplineExtractorTarget, isPlayBootstrapFinderKind, isPlayBootstrapTemplate, resolveConfig, runIf, steps, tryConvertToList, writeCsvOutputFile, writeJsonOutputFile };