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.
@@ -81,14 +81,12 @@ import type {
81
81
  ToolExecuteResult,
82
82
  ToolResultMetadataInput,
83
83
  } from '../../shared_libs/play-runtime/tool-result-types.js';
84
- import type {
85
- AuthoredStaleAfterSeconds,
86
- PreviousCell,
87
- } from '../../shared_libs/play-runtime/cell-staleness.js';
84
+ import type { PreviousCell } from '../../shared_libs/play-runtime/cell-staleness.js';
88
85
  import type {
89
86
  DeeplineClientOptions,
90
87
  PlayDetail,
91
88
  ClearPlayHistoryResult,
89
+ PlayListItem,
92
90
  PlayRevisionSummary,
93
91
  PlayRunListItem,
94
92
  PlayStatus,
@@ -125,6 +123,8 @@ import type { ToolExecution } from './client.js';
125
123
  * cron: { schedule: '0 2 * * *', timezone: 'UTC' },
126
124
  * });
127
125
  * ```
126
+ *
127
+ * @sdkReference runtime 030
128
128
  */
129
129
  export type PlayBindings = {
130
130
  /** Optional per-run billing controls enforced by the runtime. */
@@ -213,6 +213,8 @@ export type { PreviousCell } from '../../shared_libs/play-runtime/cell-staleness
213
213
  *
214
214
  * The `tool` value comes from live tool discovery. The `id` is the stable
215
215
  * logical call name inside this play and participates in replay/idempotency.
216
+ *
217
+ * @sdkReference runtime 160
216
218
  */
217
219
  export type ToolExecutionRequest = {
218
220
  /** Stable logical id for this tool call within the play. */
@@ -223,11 +225,27 @@ export type ToolExecutionRequest = {
223
225
  input: Record<string, unknown>;
224
226
  /** Human-readable description for logs and run inspection. */
225
227
  description?: string;
228
+ /** Numeric TTL in seconds for this tool checkpoint. */
226
229
  staleAfterSeconds?: number;
227
230
  };
228
231
 
232
+ /**
233
+ * Freshness policy for dataset cells and step-program columns.
234
+ *
235
+ * Use a positive whole number of seconds for a fixed TTL. Use a function when
236
+ * the next expiry depends on the value that was just produced. The function
237
+ * receives the completed cell value; return a positive whole number of seconds
238
+ * to set the next expiry, or `null` to keep that value indefinitely.
239
+ *
240
+ * Result-based policies are evaluated only for dataset/step-program cells. The
241
+ * scalar `ctx.step`, `ctx.fetch`, `ctx.runPlay`, and `ctx.tools.execute` APIs
242
+ * accept numeric TTLs.
243
+ *
244
+ * @sdkReference runtime 080
245
+ */
229
246
  export type StaleAfterSeconds<Value = unknown> =
230
- AuthoredStaleAfterSeconds<Value>;
247
+ | number
248
+ | ((value: Value) => number | null);
231
249
 
232
250
  export type StepResolver<Row, Value> = (
233
251
  row: Row,
@@ -236,9 +254,17 @@ export type StepResolver<Row, Value> = (
236
254
  previousCell?: PreviousCell<Value>,
237
255
  ) => Value | Promise<Value>;
238
256
 
257
+ /**
258
+ * Input object passed to an object-column `run` resolver.
259
+ *
260
+ * @sdkReference runtime 090
261
+ */
239
262
  export type DatasetColumnRunInput<Row, Value> = {
263
+ /** Current row, including previously computed columns. */
240
264
  row: Row;
265
+ /** Runtime context for tool/play/fetch/log calls. */
241
266
  ctx: DeeplinePlayRuntimeContext;
267
+ /** Zero-based row index for this dataset run. */
242
268
  index: number;
243
269
  /**
244
270
  * The prior stored value for this exact row+column when the runtime has
@@ -249,9 +275,20 @@ export type DatasetColumnRunInput<Row, Value> = {
249
275
  previousCell?: PreviousCell<Value>;
250
276
  };
251
277
 
278
+ /**
279
+ * Object-column form for `.withColumn(...)`.
280
+ *
281
+ * Use this when a column needs `runIf`, typed `previousCell`, or a
282
+ * result-based `staleAfterSeconds(value)` policy.
283
+ *
284
+ * @sdkReference runtime 100
285
+ */
252
286
  export type DatasetColumnDefinition<Row, Value> = {
287
+ /** Compute one cell value. Receives the previous stored value when rerunning. */
253
288
  run: (input: DatasetColumnRunInput<Row, Value>) => Value | Promise<Value>;
289
+ /** Optional row-level gate. Skipped rows produce `null` for this column. */
254
290
  readonly runIf?: (row: Row, index: number) => boolean | Promise<boolean>;
291
+ /** Fixed or value-dependent freshness policy for this cell. */
255
292
  readonly staleAfterSeconds?: StaleAfterSeconds<Value>;
256
293
  };
257
294
 
@@ -265,8 +302,15 @@ export type ConditionalStepResolver<Row, Value, Else = null> = {
265
302
  ): ConditionalStepResolver<Row, Value, ValueElse>;
266
303
  };
267
304
 
305
+ /**
306
+ * Options for row-level `.withColumn(...)` and `steps().step(...)` entries.
307
+ *
308
+ * @sdkReference runtime 110
309
+ */
268
310
  export type StepOptions<Row, Value = unknown> = {
311
+ /** Optional row-level gate. Skipped rows produce `null` for this column. */
269
312
  readonly runIf?: (row: Row, index: number) => boolean | Promise<boolean>;
313
+ /** Fixed or value-dependent freshness policy for this cell. */
270
314
  readonly staleAfterSeconds?: StaleAfterSeconds<Value>;
271
315
  };
272
316
 
@@ -316,6 +360,11 @@ export type ColumnResolver<Row, Value> =
316
360
  export type StepProgramOutput<TProgram> =
317
361
  TProgram extends StepProgram<any, infer Output, any> ? Output : never;
318
362
 
363
+ /**
364
+ * Builder returned by `ctx.dataset(...)` for row-level durable columns.
365
+ *
366
+ * @sdkReference runtime 070 .dataset(...).withColumn(name, resolver).run(options)
367
+ */
319
368
  export type DatasetBuilder<
320
369
  InputRow extends object,
321
370
  OutputRow extends object,
@@ -337,6 +386,13 @@ export type DatasetBuilder<
337
386
  name: Name,
338
387
  resolver: ColumnResolver<OutputRow, Value>,
339
388
  ): DatasetBuilder<InputRow, OutputRow & Record<Name, Value>>;
389
+ /**
390
+ * Define one output column with object-column authoring and a row gate.
391
+ *
392
+ * @param name - Output column name.
393
+ * @param definition - Object-column definition with required `runIf`.
394
+ * @returns The same dataset builder with a nullable column type for skipped rows.
395
+ */
340
396
  withColumn<Name extends string, Value>(
341
397
  name: Name,
342
398
  definition: DatasetColumnDefinition<OutputRow, Value> & {
@@ -346,10 +402,28 @@ export type DatasetBuilder<
346
402
  ) => boolean | Promise<boolean>;
347
403
  },
348
404
  ): DatasetBuilder<InputRow, OutputRow & Record<Name, Value | null>>;
405
+ /**
406
+ * Define one output column with object-column authoring.
407
+ *
408
+ * Use this form for typed `previousCell` access or result-based
409
+ * `staleAfterSeconds(value)` policies.
410
+ *
411
+ * @param name - Output column name.
412
+ * @param definition - Object-column definition.
413
+ * @returns The same dataset builder with the new column type.
414
+ */
349
415
  withColumn<Name extends string, Value>(
350
416
  name: Name,
351
417
  definition: DatasetColumnDefinition<OutputRow, Value>,
352
418
  ): DatasetBuilder<InputRow, OutputRow & Record<Name, Value>>;
419
+ /**
420
+ * Define one output column with a resolver plus row-level options.
421
+ *
422
+ * @param name - Output column name.
423
+ * @param resolver - Computes the value for one row.
424
+ * @param options - Row gate and freshness options.
425
+ * @returns The same dataset builder with a nullable column type for skipped rows.
426
+ */
353
427
  withColumn<Name extends string, Value>(
354
428
  name: Name,
355
429
  resolver:
@@ -413,7 +487,11 @@ export type ColumnMap<TRow extends object> = Partial<
413
487
  Record<Extract<keyof TRow, string>, string | readonly string[]>
414
488
  >;
415
489
 
416
- /** Options for loading a staged CSV with `ctx.csv(...)`. */
490
+ /**
491
+ * Options for loading a staged CSV with `ctx.csv(...)`.
492
+ *
493
+ * @sdkReference runtime 050
494
+ */
417
495
  export type CsvOptions = {
418
496
  /** Human-readable description for runtime logs and inspection. */
419
497
  description?: string;
@@ -488,6 +566,8 @@ export interface DeeplinePlayRuntimeContext {
488
566
  * @param options - CSV load options.
489
567
  *
490
568
  * @returns A {@link PlayDataset} whose rows should usually flow directly into `ctx.dataset(...)`.
569
+ *
570
+ * @sdkReference runtime 040 ctx.csv(path, options)
491
571
  */
492
572
  csv<T = Record<string, unknown>>(
493
573
  path: string,
@@ -548,6 +628,8 @@ export interface DeeplinePlayRuntimeContext {
548
628
  * row.company?.employeeCount > 100 ? 'enterprise' : 'smb')
549
629
  * .run({ description: 'Enrich leads.' });
550
630
  * ```
631
+ *
632
+ * @sdkReference runtime 060 ctx.dataset(key, items)
551
633
  */
552
634
  dataset<TItem extends object>(
553
635
  key: string,
@@ -565,6 +647,8 @@ export interface DeeplinePlayRuntimeContext {
565
647
  *
566
648
  * @param request - Tool call request.
567
649
  * @returns Tool execution result.
650
+ *
651
+ * @sdkReference runtime 150 ctx.tools.execute(request)
568
652
  */
569
653
  execute<TOutput = LoosePlayObject>(
570
654
  request: ToolExecutionRequest & { staleAfterSeconds?: number },
@@ -594,6 +678,8 @@ export interface DeeplinePlayRuntimeContext {
594
678
  * @param input - Program input.
595
679
  * @param options - Run options.
596
680
  * @returns Program output.
681
+ *
682
+ * @sdkReference runtime 180 ctx.runSteps(program, input, options)
597
683
  */
598
684
  runSteps<TInput extends Record<string, unknown>, TOutput>(
599
685
  program: StepProgram<TInput, any, TOutput>,
@@ -616,6 +702,8 @@ export interface DeeplinePlayRuntimeContext {
616
702
  * @param run - Computes the value once.
617
703
  * @param options - Checkpoint options.
618
704
  * @returns Checkpoint value.
705
+ *
706
+ * @sdkReference runtime 130 ctx.step(id, fn)
619
707
  */
620
708
  step<T>(
621
709
  id: string,
@@ -634,6 +722,8 @@ export interface DeeplinePlayRuntimeContext {
634
722
  * @param url - URL to fetch.
635
723
  * @param init - Fetch options.
636
724
  * @returns Recorded response.
725
+ *
726
+ * @sdkReference runtime 170 ctx.fetch(key, url, init)
637
727
  */
638
728
  fetch(
639
729
  key: string,
@@ -649,6 +739,11 @@ export interface DeeplinePlayRuntimeContext {
649
739
  bodyText: string;
650
740
  json: unknown | null;
651
741
  }>;
742
+ secrets: {
743
+ get(name: string): SecretHandle;
744
+ bearer(secret: SecretHandle): SecretAuth;
745
+ header(header: string, secret: SecretHandle): SecretAuth;
746
+ };
652
747
  /**
653
748
  * Invoke another registered or file-backed play as a child workflow.
654
749
  *
@@ -664,12 +759,9 @@ export interface DeeplinePlayRuntimeContext {
664
759
  * @param input - Input object passed to the child play.
665
760
  * @param options - Child play options.
666
761
  * @returns Child play output.
762
+ *
763
+ * @sdkReference runtime 140 ctx.runPlay(key, playRef, input, options)
667
764
  */
668
- secrets: {
669
- get(name: string): SecretHandle;
670
- bearer(secret: SecretHandle): SecretAuth;
671
- header(header: string, secret: SecretHandle): SecretAuth;
672
- };
673
765
  runPlay<TOutput = unknown>(
674
766
  key: string,
675
767
  playRef: string | PlayReferenceLike,
@@ -730,6 +822,8 @@ export interface DeeplinePlayRuntimeContext {
730
822
  * // Cancel if needed
731
823
  * await job.cancel();
732
824
  * ```
825
+ *
826
+ * @sdkReference plays 030
733
827
  */
734
828
  export interface PlayJob<TOutput = unknown> {
735
829
  /** Temporal workflow ID for this execution. */
@@ -805,6 +899,8 @@ export interface PlayJob<TOutput = unknown> {
805
899
  * // Publish the current draft
806
900
  * await play.publish();
807
901
  * ```
902
+ *
903
+ * @sdkReference plays 020
808
904
  */
809
905
  export interface DeeplineNamedPlay<
810
906
  TInput = Record<string, unknown>,
@@ -854,6 +950,46 @@ export interface DeeplineNamedPlay<
854
950
  runSync(input: TInput, options?: { revisionId?: string }): Promise<TOutput>;
855
951
  }
856
952
 
953
+ /**
954
+ * Tool/provider operations available from a connected {@link DeeplineContext}.
955
+ *
956
+ * This namespace is for regular SDK callers outside a play runtime. Inside a
957
+ * `definePlay(...)` body, use `ctx.tools.execute({ id, tool, input, ... })`
958
+ * so provider calls become durable runtime checkpoints.
959
+ *
960
+ * @sdkReference tools 010 DeeplineContext.tools
961
+ */
962
+ export type DeeplineToolsNamespace = {
963
+ /** List all available provider-backed tools. */
964
+ list(): Promise<ToolDefinition[]>;
965
+ /** Get detailed metadata for one provider-backed tool. */
966
+ get(toolId: string): Promise<ToolMetadata>;
967
+ /**
968
+ * Execute a provider-backed tool from a regular SDK process.
969
+ *
970
+ * For durable play code, prefer `ctx.tools.execute(...)` because the play
971
+ * runtime records the call under a stable id.
972
+ */
973
+ execute(
974
+ toolId: string,
975
+ input: Record<string, unknown>,
976
+ ): Promise<ToolExecuteResult>;
977
+ };
978
+
979
+ /**
980
+ * Named-play discovery and handle operations from a connected {@link DeeplineContext}.
981
+ *
982
+ * @sdkReference plays 010 DeeplineContext.plays
983
+ */
984
+ export type DeeplinePlaysNamespace = {
985
+ /** List saved and callable plays visible to the current workspace. */
986
+ list(): Promise<PlayListItem[]>;
987
+ /** Return a typed handle for a named, saved, shared, or prebuilt play. */
988
+ get<TInput = Record<string, unknown>, TOutput = unknown>(
989
+ name: string,
990
+ ): DeeplineNamedPlay<TInput, TOutput>;
991
+ };
992
+
857
993
  export type PrebuiltPlayRef = {
858
994
  readonly playName: string;
859
995
  readonly name: string;
@@ -885,6 +1021,8 @@ export type PlayInputContract<TInput> = {
885
1021
  * through `defineInput<T>(schema)`, or when configuration reads clearer as one
886
1022
  * object. The shorthand `definePlay(name, fn, bindings?)` is equivalent for
887
1023
  * simple file-backed plays.
1024
+ *
1025
+ * @sdkReference runtime 020
888
1026
  */
889
1027
  export type DefinePlayConfig<TInput, TOutput extends PlayReturnObject> = {
890
1028
  /** Play id/name. */
@@ -942,7 +1080,7 @@ class DeeplineStepProgram<Input, Output, ReturnValue> implements StepProgram<
942
1080
  step<Name extends string, Value>(
943
1081
  name: Name,
944
1082
  resolver: StepResolver<Output, Value> | StepProgramResolver<Output, Value>,
945
- options: StepOptions<Output>,
1083
+ options: StepOptions<Output, Value>,
946
1084
  ): StepProgram<Input, Output & Record<Name, Value | null>, ReturnValue>;
947
1085
  step<Name extends string, Value>(
948
1086
  name: Name,
@@ -950,7 +1088,7 @@ class DeeplineStepProgram<Input, Output, ReturnValue> implements StepProgram<
950
1088
  | StepResolver<Output, Value>
951
1089
  | ConditionalStepResolver<Output, Value>
952
1090
  | StepProgramResolver<Output, Value>,
953
- options?: StepOptions<Output>,
1091
+ options?: StepOptions<Output, Value>,
954
1092
  ): StepProgram<Input, Output & Record<Name, Value | null>, ReturnValue> {
955
1093
  if (!name.trim()) {
956
1094
  throw new Error(
@@ -971,6 +1109,12 @@ class DeeplineStepProgram<Input, Output, ReturnValue> implements StepProgram<
971
1109
  {
972
1110
  name,
973
1111
  resolver: stepResolver as PlayStepProgramStep['resolver'],
1112
+ ...(options?.staleAfterSeconds !== undefined
1113
+ ? {
1114
+ staleAfterSeconds:
1115
+ options.staleAfterSeconds as PlayStepProgramStep['staleAfterSeconds'],
1116
+ }
1117
+ : {}),
974
1118
  },
975
1119
  ],
976
1120
  this.returnResolver as StepResolver<
@@ -1189,10 +1333,20 @@ function createNamedPlayHandle<
1189
1333
  * const job = await deepline.play('email-waterfall').run({ domain: 'stripe.com' });
1190
1334
  * const output = await job.get();
1191
1335
  * ```
1336
+ *
1337
+ * @sdkReference entrypoints 020
1192
1338
  */
1193
1339
  export class DeeplineContext {
1194
1340
  private readonly client: DeeplineClient;
1195
1341
 
1342
+ /**
1343
+ * Create a high-level SDK context.
1344
+ *
1345
+ * Most callers should use {@link Deepline.connect}; direct construction is
1346
+ * equivalent when you already have explicit client options.
1347
+ *
1348
+ * @param options - Optional SDK client configuration.
1349
+ */
1196
1350
  constructor(options?: DeeplineClientOptions) {
1197
1351
  this.client = new DeeplineClient(options);
1198
1352
  }
@@ -1208,7 +1362,7 @@ export class DeeplineContext {
1208
1362
  * const company = companyLookup.toolResponse.raw;
1209
1363
  * ```
1210
1364
  */
1211
- get tools() {
1365
+ get tools(): DeeplineToolsNamespace {
1212
1366
  return {
1213
1367
  /** List all available tools. */
1214
1368
  list: (): Promise<ToolDefinition[]> => this.client.listTools(),
@@ -1228,7 +1382,13 @@ export class DeeplineContext {
1228
1382
  };
1229
1383
  }
1230
1384
 
1231
- get plays() {
1385
+ /**
1386
+ * Play discovery and named-play handles.
1387
+ *
1388
+ * Use `plays.list()` for discovery and `plays.get(name)` when you prefer a
1389
+ * namespace spelling over `ctx.play(name)`.
1390
+ */
1391
+ get plays(): DeeplinePlaysNamespace {
1232
1392
  return {
1233
1393
  list: () => this.client.listPlays(),
1234
1394
  get: <TInput = Record<string, unknown>, TOutput = unknown>(
@@ -1237,6 +1397,13 @@ export class DeeplineContext {
1237
1397
  };
1238
1398
  }
1239
1399
 
1400
+ /**
1401
+ * Convenience references for Deepline-managed prebuilt plays.
1402
+ *
1403
+ * Known prebuilts are exposed by camel-cased aliases. Any other property is
1404
+ * converted into `prebuilt/<property>` so callers can pass the reference to
1405
+ * `ctx.runPlay(...)`.
1406
+ */
1240
1407
  get prebuilt(): Record<string, PrebuiltPlayRef> {
1241
1408
  const explicit = {
1242
1409
  companyToContact: {
@@ -1297,6 +1464,17 @@ export class DeeplineContext {
1297
1464
  return createNamedPlayHandle<TInput, TOutput>(() => this.client, name);
1298
1465
  }
1299
1466
 
1467
+ /**
1468
+ * Run a named or prebuilt play and wait for its output.
1469
+ *
1470
+ * This is the high-level SDK equivalent of `ctx.play(name).runSync(input)`.
1471
+ * Inside a play runtime, prefer the in-play `ctx.runPlay(key, playRef, input,
1472
+ * options)` form so the child run is checkpointed under a stable key.
1473
+ *
1474
+ * @param playOrRef - Play name or prebuilt/reference object.
1475
+ * @param input - JSON input passed to the play.
1476
+ * @returns Completed play output.
1477
+ */
1300
1478
  async runPlay<TInput = Record<string, unknown>, TOutput = unknown>(
1301
1479
  playOrRef: string | PlayReferenceLike,
1302
1480
  input: TInput,
@@ -1320,6 +1498,8 @@ export class DeeplineContext {
1320
1498
  * const tools = await deepline.tools.list();
1321
1499
  * const result = await deepline.tools.execute('test_company_search', { domain: 'stripe.com' });
1322
1500
  * ```
1501
+ *
1502
+ * @sdkReference entrypoints 010
1323
1503
  */
1324
1504
  export class Deepline {
1325
1505
  /**
@@ -1546,6 +1726,9 @@ export function definePlay<TInput, TOutput extends PlayReturnObject>(
1546
1726
  fn: (ctx: DeeplinePlayRuntimeContext, input: TInput) => Promise<TOutput>,
1547
1727
  bindings?: PlayBindings,
1548
1728
  ): DefinedPlay<TInput, TOutput>;
1729
+ /**
1730
+ * @sdkReference runtime 010
1731
+ */
1549
1732
  export function definePlay<TInput, TOutput extends PlayReturnObject>(
1550
1733
  nameOrConfig: string | DefinePlayConfig<TInput, TOutput>,
1551
1734
  maybeFn?: (
@@ -50,10 +50,10 @@ export type SdkRelease = {
50
50
  };
51
51
 
52
52
  export const SDK_RELEASE = {
53
- version: '0.1.85',
53
+ version: '0.1.88',
54
54
  apiContract: '2026-06-dataset-column-cell-stale-hard-cutover',
55
55
  supportPolicy: {
56
- latest: '0.1.85',
56
+ latest: '0.1.88',
57
57
  minimumSupported: '0.1.53',
58
58
  deprecatedBelow: '0.1.53',
59
59
  },
@@ -61,18 +61,34 @@ export interface ResolvedConfig {
61
61
  maxRetries: number;
62
62
  }
63
63
 
64
+ /** Column metadata returned by a customer data query. */
64
65
  export interface CustomerDbColumn {
66
+ /** Column name as returned by the database. */
65
67
  name: string;
68
+ /** Internal table identifier when available. */
66
69
  table_id: number | null;
70
+ /** Internal data-type identifier when available. */
67
71
  data_type_id: number | null;
68
72
  }
69
73
 
74
+ /**
75
+ * Result returned by {@link DeeplineClient.queryCustomerDb}.
76
+ *
77
+ * Rows are intentionally untyped because the schema depends on the caller's SQL
78
+ * query and selected customer tables.
79
+ */
70
80
  export interface CustomerDbQueryResult {
81
+ /** Database command executed by the query endpoint. */
71
82
  command: string;
83
+ /** Total affected row count when reported by the database. */
72
84
  row_count: number | null;
85
+ /** Number of rows included in this response. */
73
86
  row_count_returned: number;
87
+ /** Whether server-side row limits truncated the result. */
74
88
  truncated: boolean;
89
+ /** Column metadata for the returned rows. */
75
90
  columns: CustomerDbColumn[];
91
+ /** Result rows. */
76
92
  rows: unknown[];
77
93
  }
78
94
 
@@ -114,6 +130,13 @@ export type {
114
130
  PlayBootstrapTemplate,
115
131
  };
116
132
 
133
+ /**
134
+ * Summary definition of a callable provider-backed tool.
135
+ *
136
+ * Returned by {@link DeeplineClient.listTools} and ranked tool search. Use
137
+ * `getTool(toolId)` or the matching HTTP describe route for provider-specific
138
+ * schema, examples, pricing, and extraction guidance before executing.
139
+ */
117
140
  export interface ToolDefinition {
118
141
  /** Unique tool identifier used in API calls (e.g. `"apollo_people_search"`). */
119
142
  toolId: string;
@@ -222,29 +245,54 @@ export interface ToolDefinition {
222
245
  }>;
223
246
  }
224
247
 
248
+ /**
249
+ * Query options for ranked tool/provider discovery.
250
+ */
225
251
  export interface ToolSearchOptions {
252
+ /** Free-text search query. */
226
253
  query?: string;
254
+ /** Comma-separated category filter such as `company_search` or `email_finder`. */
227
255
  categories?: string;
256
+ /** Optional explicit search terms used by agent/CLI callers. */
228
257
  searchTerms?: string;
258
+ /** Search algorithm/version. Defaults to the current ranked mode. */
229
259
  searchMode?: 'v1' | 'v2';
260
+ /** Include backend debug metadata in the search response. */
230
261
  includeSearchDebug?: boolean;
231
262
  }
232
263
 
264
+ /**
265
+ * Ranked tool/provider discovery response.
266
+ *
267
+ * Includes matching tools plus render/action hints used by the CLI and agents.
268
+ */
233
269
  export interface ToolSearchResult {
270
+ /** Ranked matching tools. */
234
271
  tools: ToolDefinition[];
272
+ /** Count included in this response when available. */
235
273
  count?: number;
274
+ /** Total available count when the backend reports it. */
236
275
  total?: number;
276
+ /** Whether results were truncated by server-side limits. */
237
277
  truncated?: boolean;
278
+ /** Echoed query. */
238
279
  query?: string;
280
+ /** Parsed category filters. */
239
281
  categories?: string[];
282
+ /** Parsed search terms. */
240
283
  search_terms?: string[];
284
+ /** Search mode used. */
241
285
  search_mode?: 'v1' | 'v2';
286
+ /** Whether search fell back to category matching. */
242
287
  search_fallback_to_category?: boolean;
288
+ /** Hint explaining omitted play results when searching tools only. */
243
289
  omitted_plays_hint?: string;
290
+ /** Copyable CLI command templates for follow-up discovery/execution. */
244
291
  commandTemplates?: {
245
292
  describe?: string;
246
293
  execute?: string;
247
294
  };
295
+ /** Pre-rendered sections and actions for CLI/agent display. */
248
296
  render?: {
249
297
  sections?: Array<{
250
298
  title: string;
@@ -372,9 +420,19 @@ export type PlayRunActionPackage =
372
420
  format: 'csv';
373
421
  };
374
422
 
423
+ /**
424
+ * Compact canonical package for an inspected play run.
425
+ *
426
+ * This object is designed for SDK/CLI/API consumers that need stable run
427
+ * metadata, output handles, and follow-up actions without reading dashboard
428
+ * internals.
429
+ */
375
430
  export interface PlayRunPackage {
431
+ /** Package schema version. */
376
432
  schemaVersion: 1;
433
+ /** Package discriminator. */
377
434
  kind: 'play_run';
435
+ /** Run identity, status, timing, and dashboard metadata. */
378
436
  run: {
379
437
  id: string;
380
438
  playName: string;
@@ -386,8 +444,11 @@ export interface PlayRunPackage {
386
444
  durationMs?: number | null;
387
445
  error?: string;
388
446
  };
447
+ /** Step-level summaries emitted by the runtime. */
389
448
  steps: Array<Record<string, unknown>>;
449
+ /** Named output summaries, including dataset handles and scalar outputs. */
390
450
  outputs: Record<string, Record<string, unknown>>;
451
+ /** Follow-up actions a caller can perform against the run. */
391
452
  next?: {
392
453
  inspect?: PlayRunActionPackage;
393
454
  export?: PlayRunActionPackage;
@@ -101,7 +101,7 @@ class WorkerStepProgram<Input, Output, ReturnValue> implements StepProgram<
101
101
  step<Name extends string, Value>(
102
102
  name: Name,
103
103
  resolver: StepResolver<Output, Value> | StepProgramResolver<Output, Value>,
104
- options: StepOptions<Output>,
104
+ options: StepOptions<Output, Value>,
105
105
  ): StepProgram<Input, Output & Record<Name, Value | null>, ReturnValue>;
106
106
  step<Name extends string, Value>(
107
107
  name: Name,
@@ -109,7 +109,7 @@ class WorkerStepProgram<Input, Output, ReturnValue> implements StepProgram<
109
109
  | StepResolver<Output, Value>
110
110
  | ConditionalStepResolver<Output, Value>
111
111
  | StepProgramResolver<Output, Value>,
112
- options?: StepOptions<Output>,
112
+ options?: StepOptions<Output, Value>,
113
113
  ): StepProgram<Input, Output & Record<Name, Value | null>, ReturnValue> {
114
114
  if (!name.trim()) {
115
115
  throw new Error('Step name required.');
@@ -129,7 +129,10 @@ class WorkerStepProgram<Input, Output, ReturnValue> implements StepProgram<
129
129
  name,
130
130
  resolver: stepResolver as PlayStepProgramStep['resolver'],
131
131
  ...(options?.staleAfterSeconds !== undefined
132
- ? { staleAfterSeconds: options.staleAfterSeconds }
132
+ ? {
133
+ staleAfterSeconds:
134
+ options.staleAfterSeconds as PlayStepProgramStep['staleAfterSeconds'],
135
+ }
133
136
  : {}),
134
137
  },
135
138
  ],
@@ -1,20 +1,30 @@
1
+ /**
2
+ * Resolve the next expiry window from a completed cell value.
3
+ *
4
+ * Return a positive whole number of seconds to set the next `staleAt`, or
5
+ * `null` when this particular value should not expire.
6
+ */
1
7
  export type StaleAfterSecondsResolver<Value = unknown> = (
2
8
  value: Value,
3
9
  ) => number | null;
4
10
 
11
+ /** Authored freshness policy: fixed TTL seconds or a value-based resolver. */
5
12
  export type AuthoredStaleAfterSeconds<Value = unknown> =
6
13
  | number
7
14
  | StaleAfterSecondsResolver<Value>;
8
15
 
16
+ /** Freshness policy as written by play authors before runtime normalization. */
9
17
  export type AuthoredCellStalenessPolicy<Value = unknown> = {
10
18
  staleAfterSeconds?: AuthoredStaleAfterSeconds<Value>;
11
19
  };
12
20
 
21
+ /** Runtime-normalized freshness policy stored in execution plans. */
13
22
  export type CellStalenessPolicy = {
14
23
  staleAfterSeconds?: number;
15
24
  dynamicStaleAfterSeconds?: boolean;
16
25
  };
17
26
 
27
+ /** Stored per-cell freshness and completion metadata. */
18
28
  export type CellStalenessMeta = {
19
29
  status?: string | null;
20
30
  completedAt?: number | null;
@@ -22,10 +32,23 @@ export type CellStalenessMeta = {
22
32
  staleAfterSeconds?: number | null;
23
33
  };
24
34
 
35
+ /**
36
+ * Previous durable cell value passed to object-column resolvers.
37
+ *
38
+ * The runtime supplies this when a row+column is being recomputed after a
39
+ * previous value existed. `value` has the same type that the column returns;
40
+ * freshness metadata lives beside it.
41
+ *
42
+ * @sdkReference runtime 120
43
+ */
25
44
  export type PreviousCell<Value = unknown> = {
45
+ /** Previous completed value for this row+column. */
26
46
  value: Value;
47
+ /** Millisecond timestamp when the previous value completed. */
27
48
  completedAt?: number;
49
+ /** Millisecond timestamp when the previous value becomes stale; `null` means no expiry. */
28
50
  staleAt?: number | null;
51
+ /** Resolved numeric TTL in seconds for the previous value, when present. */
29
52
  staleAfterSeconds?: number;
30
53
  };
31
54