deepline 0.1.83 → 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,10 +81,12 @@ import type {
81
81
  ToolExecuteResult,
82
82
  ToolResultMetadataInput,
83
83
  } from '../../shared_libs/play-runtime/tool-result-types.js';
84
+ import type { PreviousCell } from '../../shared_libs/play-runtime/cell-staleness.js';
84
85
  import type {
85
86
  DeeplineClientOptions,
86
87
  PlayDetail,
87
88
  ClearPlayHistoryResult,
89
+ PlayListItem,
88
90
  PlayRevisionSummary,
89
91
  PlayRunListItem,
90
92
  PlayStatus,
@@ -121,6 +123,8 @@ import type { ToolExecution } from './client.js';
121
123
  * cron: { schedule: '0 2 * * *', timezone: 'UTC' },
122
124
  * });
123
125
  * ```
126
+ *
127
+ * @sdkReference runtime 030
124
128
  */
125
129
  export type PlayBindings = {
126
130
  /** Optional per-run billing controls enforced by the runtime. */
@@ -187,12 +191,30 @@ export type {
187
191
  ToolResultListAccessor,
188
192
  ToolResultTargetAccessor as ToolExtractedValue,
189
193
  } from '../../shared_libs/play-runtime/tool-result-types.js';
194
+ export {
195
+ DEEPLINE_EXTRACTOR_TARGETS,
196
+ DEEPLINE_EXTRACTOR_TARGET_DEFINITIONS,
197
+ JOB_CHANGE_STATUS_VALUES,
198
+ PHONE_STATUS_VALUES,
199
+ isDeeplineExtractorTarget,
200
+ } from '../../shared_libs/play-runtime/extractor-targets.js';
201
+ export type {
202
+ DeeplineEmailStatusGetterValue,
203
+ DeeplineExtractorTarget,
204
+ DeeplineGetterValue,
205
+ DeeplineGetterValueMap,
206
+ JobChangeStatus,
207
+ PhoneStatus,
208
+ } from '../../shared_libs/play-runtime/extractor-targets.js';
209
+ export type { PreviousCell } from '../../shared_libs/play-runtime/cell-staleness.js';
190
210
 
191
211
  /**
192
212
  * Keyword-style request object for `ctx.tools.execute(...)`.
193
213
  *
194
214
  * The `tool` value comes from live tool discovery. The `id` is the stable
195
215
  * logical call name inside this play and participates in replay/idempotency.
216
+ *
217
+ * @sdkReference runtime 160
196
218
  */
197
219
  export type ToolExecutionRequest = {
198
220
  /** Stable logical id for this tool call within the play. */
@@ -203,15 +225,73 @@ export type ToolExecutionRequest = {
203
225
  input: Record<string, unknown>;
204
226
  /** Human-readable description for logs and run inspection. */
205
227
  description?: string;
228
+ /** Numeric TTL in seconds for this tool checkpoint. */
206
229
  staleAfterSeconds?: number;
207
230
  };
208
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
+ */
246
+ export type StaleAfterSeconds<Value = unknown> =
247
+ | number
248
+ | ((value: Value) => number | null);
249
+
209
250
  export type StepResolver<Row, Value> = (
210
251
  row: Row,
211
252
  ctx: DeeplinePlayRuntimeContext,
212
253
  index: number,
254
+ previousCell?: PreviousCell<Value>,
213
255
  ) => Value | Promise<Value>;
214
256
 
257
+ /**
258
+ * Input object passed to an object-column `run` resolver.
259
+ *
260
+ * @sdkReference runtime 090
261
+ */
262
+ export type DatasetColumnRunInput<Row, Value> = {
263
+ /** Current row, including previously computed columns. */
264
+ row: Row;
265
+ /** Runtime context for tool/play/fetch/log calls. */
266
+ ctx: DeeplinePlayRuntimeContext;
267
+ /** Zero-based row index for this dataset run. */
268
+ index: number;
269
+ /**
270
+ * The prior stored value for this exact row+column when the runtime has
271
+ * decided the cell is due to run again. `previousCell.value` is the same type
272
+ * this column returns; metadata such as `completedAt` and `staleAt` lives
273
+ * beside it and is not mixed into the value.
274
+ */
275
+ previousCell?: PreviousCell<Value>;
276
+ };
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
+ */
286
+ export type DatasetColumnDefinition<Row, Value> = {
287
+ /** Compute one cell value. Receives the previous stored value when rerunning. */
288
+ run: (input: DatasetColumnRunInput<Row, Value>) => Value | Promise<Value>;
289
+ /** Optional row-level gate. Skipped rows produce `null` for this column. */
290
+ readonly runIf?: (row: Row, index: number) => boolean | Promise<boolean>;
291
+ /** Fixed or value-dependent freshness policy for this cell. */
292
+ readonly staleAfterSeconds?: StaleAfterSeconds<Value>;
293
+ };
294
+
215
295
  export type ConditionalStepResolver<Row, Value, Else = null> = {
216
296
  readonly kind: 'conditional';
217
297
  readonly when: (row: Row, index: number) => boolean | Promise<boolean>;
@@ -222,9 +302,16 @@ export type ConditionalStepResolver<Row, Value, Else = null> = {
222
302
  ): ConditionalStepResolver<Row, Value, ValueElse>;
223
303
  };
224
304
 
225
- export type StepOptions<Row> = {
305
+ /**
306
+ * Options for row-level `.withColumn(...)` and `steps().step(...)` entries.
307
+ *
308
+ * @sdkReference runtime 110
309
+ */
310
+ export type StepOptions<Row, Value = unknown> = {
311
+ /** Optional row-level gate. Skipped rows produce `null` for this column. */
226
312
  readonly runIf?: (row: Row, index: number) => boolean | Promise<boolean>;
227
- readonly staleAfterSeconds?: number;
313
+ /** Fixed or value-dependent freshness policy for this cell. */
314
+ readonly staleAfterSeconds?: StaleAfterSeconds<Value>;
228
315
  };
229
316
 
230
317
  export type StepProgram<Input, Output, Return = Output> = {
@@ -242,7 +329,7 @@ export type StepProgram<Input, Output, Return = Output> = {
242
329
  step<Name extends string, Value>(
243
330
  name: Name,
244
331
  resolver: StepResolver<Output, Value> | StepProgramResolver<Output, Value>,
245
- options: StepOptions<Output>,
332
+ options: StepOptions<Output, Value>,
246
333
  ): StepProgram<Input, Output & Record<Name, Value | null>, Return>;
247
334
  return<Value>(
248
335
  resolver: StepResolver<Output, Value>,
@@ -258,7 +345,7 @@ export type StepProgramResolver<Input, Return> = {
258
345
 
259
346
  export type PlayStepProgramStep = {
260
347
  readonly name: string;
261
- readonly staleAfterSeconds?: number;
348
+ readonly staleAfterSeconds?: StaleAfterSeconds;
262
349
  readonly resolver:
263
350
  | StepResolver<Record<string, unknown>, unknown>
264
351
  | ConditionalStepResolver<Record<string, unknown>, unknown>
@@ -273,6 +360,11 @@ export type ColumnResolver<Row, Value> =
273
360
  export type StepProgramOutput<TProgram> =
274
361
  TProgram extends StepProgram<any, infer Output, any> ? Output : never;
275
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
+ */
276
368
  export type DatasetBuilder<
277
369
  InputRow extends object,
278
370
  OutputRow extends object,
@@ -294,12 +386,50 @@ export type DatasetBuilder<
294
386
  name: Name,
295
387
  resolver: ColumnResolver<OutputRow, Value>,
296
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
+ */
396
+ withColumn<Name extends string, Value>(
397
+ name: Name,
398
+ definition: DatasetColumnDefinition<OutputRow, Value> & {
399
+ readonly runIf: (
400
+ row: OutputRow,
401
+ index: number,
402
+ ) => boolean | Promise<boolean>;
403
+ },
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
+ */
415
+ withColumn<Name extends string, Value>(
416
+ name: Name,
417
+ definition: DatasetColumnDefinition<OutputRow, Value>,
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
+ */
297
427
  withColumn<Name extends string, Value>(
298
428
  name: Name,
299
429
  resolver:
300
430
  | StepResolver<OutputRow, Value>
301
431
  | StepProgramResolver<OutputRow, Value>,
302
- options: StepOptions<OutputRow>,
432
+ options: StepOptions<OutputRow, Value>,
303
433
  ): DatasetBuilder<InputRow, OutputRow & Record<Name, Value | null>>;
304
434
  withColumns<Program extends StepProgram<OutputRow, object, unknown>>(
305
435
  program: Program,
@@ -357,7 +487,11 @@ export type ColumnMap<TRow extends object> = Partial<
357
487
  Record<Extract<keyof TRow, string>, string | readonly string[]>
358
488
  >;
359
489
 
360
- /** 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
+ */
361
495
  export type CsvOptions = {
362
496
  /** Human-readable description for runtime logs and inspection. */
363
497
  description?: string;
@@ -432,6 +566,8 @@ export interface DeeplinePlayRuntimeContext {
432
566
  * @param options - CSV load options.
433
567
  *
434
568
  * @returns A {@link PlayDataset} whose rows should usually flow directly into `ctx.dataset(...)`.
569
+ *
570
+ * @sdkReference runtime 040 ctx.csv(path, options)
435
571
  */
436
572
  csv<T = Record<string, unknown>>(
437
573
  path: string,
@@ -492,6 +628,8 @@ export interface DeeplinePlayRuntimeContext {
492
628
  * row.company?.employeeCount > 100 ? 'enterprise' : 'smb')
493
629
  * .run({ description: 'Enrich leads.' });
494
630
  * ```
631
+ *
632
+ * @sdkReference runtime 060 ctx.dataset(key, items)
495
633
  */
496
634
  dataset<TItem extends object>(
497
635
  key: string,
@@ -509,6 +647,8 @@ export interface DeeplinePlayRuntimeContext {
509
647
  *
510
648
  * @param request - Tool call request.
511
649
  * @returns Tool execution result.
650
+ *
651
+ * @sdkReference runtime 150 ctx.tools.execute(request)
512
652
  */
513
653
  execute<TOutput = LoosePlayObject>(
514
654
  request: ToolExecutionRequest & { staleAfterSeconds?: number },
@@ -538,6 +678,8 @@ export interface DeeplinePlayRuntimeContext {
538
678
  * @param input - Program input.
539
679
  * @param options - Run options.
540
680
  * @returns Program output.
681
+ *
682
+ * @sdkReference runtime 180 ctx.runSteps(program, input, options)
541
683
  */
542
684
  runSteps<TInput extends Record<string, unknown>, TOutput>(
543
685
  program: StepProgram<TInput, any, TOutput>,
@@ -560,6 +702,8 @@ export interface DeeplinePlayRuntimeContext {
560
702
  * @param run - Computes the value once.
561
703
  * @param options - Checkpoint options.
562
704
  * @returns Checkpoint value.
705
+ *
706
+ * @sdkReference runtime 130 ctx.step(id, fn)
563
707
  */
564
708
  step<T>(
565
709
  id: string,
@@ -578,6 +722,8 @@ export interface DeeplinePlayRuntimeContext {
578
722
  * @param url - URL to fetch.
579
723
  * @param init - Fetch options.
580
724
  * @returns Recorded response.
725
+ *
726
+ * @sdkReference runtime 170 ctx.fetch(key, url, init)
581
727
  */
582
728
  fetch(
583
729
  key: string,
@@ -593,6 +739,11 @@ export interface DeeplinePlayRuntimeContext {
593
739
  bodyText: string;
594
740
  json: unknown | null;
595
741
  }>;
742
+ secrets: {
743
+ get(name: string): SecretHandle;
744
+ bearer(secret: SecretHandle): SecretAuth;
745
+ header(header: string, secret: SecretHandle): SecretAuth;
746
+ };
596
747
  /**
597
748
  * Invoke another registered or file-backed play as a child workflow.
598
749
  *
@@ -608,12 +759,9 @@ export interface DeeplinePlayRuntimeContext {
608
759
  * @param input - Input object passed to the child play.
609
760
  * @param options - Child play options.
610
761
  * @returns Child play output.
762
+ *
763
+ * @sdkReference runtime 140 ctx.runPlay(key, playRef, input, options)
611
764
  */
612
- secrets: {
613
- get(name: string): SecretHandle;
614
- bearer(secret: SecretHandle): SecretAuth;
615
- header(header: string, secret: SecretHandle): SecretAuth;
616
- };
617
765
  runPlay<TOutput = unknown>(
618
766
  key: string,
619
767
  playRef: string | PlayReferenceLike,
@@ -674,6 +822,8 @@ export interface DeeplinePlayRuntimeContext {
674
822
  * // Cancel if needed
675
823
  * await job.cancel();
676
824
  * ```
825
+ *
826
+ * @sdkReference plays 030
677
827
  */
678
828
  export interface PlayJob<TOutput = unknown> {
679
829
  /** Temporal workflow ID for this execution. */
@@ -749,6 +899,8 @@ export interface PlayJob<TOutput = unknown> {
749
899
  * // Publish the current draft
750
900
  * await play.publish();
751
901
  * ```
902
+ *
903
+ * @sdkReference plays 020
752
904
  */
753
905
  export interface DeeplineNamedPlay<
754
906
  TInput = Record<string, unknown>,
@@ -798,6 +950,46 @@ export interface DeeplineNamedPlay<
798
950
  runSync(input: TInput, options?: { revisionId?: string }): Promise<TOutput>;
799
951
  }
800
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
+
801
993
  export type PrebuiltPlayRef = {
802
994
  readonly playName: string;
803
995
  readonly name: string;
@@ -829,6 +1021,8 @@ export type PlayInputContract<TInput> = {
829
1021
  * through `defineInput<T>(schema)`, or when configuration reads clearer as one
830
1022
  * object. The shorthand `definePlay(name, fn, bindings?)` is equivalent for
831
1023
  * simple file-backed plays.
1024
+ *
1025
+ * @sdkReference runtime 020
832
1026
  */
833
1027
  export type DefinePlayConfig<TInput, TOutput extends PlayReturnObject> = {
834
1028
  /** Play id/name. */
@@ -886,7 +1080,7 @@ class DeeplineStepProgram<Input, Output, ReturnValue> implements StepProgram<
886
1080
  step<Name extends string, Value>(
887
1081
  name: Name,
888
1082
  resolver: StepResolver<Output, Value> | StepProgramResolver<Output, Value>,
889
- options: StepOptions<Output>,
1083
+ options: StepOptions<Output, Value>,
890
1084
  ): StepProgram<Input, Output & Record<Name, Value | null>, ReturnValue>;
891
1085
  step<Name extends string, Value>(
892
1086
  name: Name,
@@ -894,7 +1088,7 @@ class DeeplineStepProgram<Input, Output, ReturnValue> implements StepProgram<
894
1088
  | StepResolver<Output, Value>
895
1089
  | ConditionalStepResolver<Output, Value>
896
1090
  | StepProgramResolver<Output, Value>,
897
- options?: StepOptions<Output>,
1091
+ options?: StepOptions<Output, Value>,
898
1092
  ): StepProgram<Input, Output & Record<Name, Value | null>, ReturnValue> {
899
1093
  if (!name.trim()) {
900
1094
  throw new Error(
@@ -915,6 +1109,12 @@ class DeeplineStepProgram<Input, Output, ReturnValue> implements StepProgram<
915
1109
  {
916
1110
  name,
917
1111
  resolver: stepResolver as PlayStepProgramStep['resolver'],
1112
+ ...(options?.staleAfterSeconds !== undefined
1113
+ ? {
1114
+ staleAfterSeconds:
1115
+ options.staleAfterSeconds as PlayStepProgramStep['staleAfterSeconds'],
1116
+ }
1117
+ : {}),
918
1118
  },
919
1119
  ],
920
1120
  this.returnResolver as StepResolver<
@@ -1133,10 +1333,20 @@ function createNamedPlayHandle<
1133
1333
  * const job = await deepline.play('email-waterfall').run({ domain: 'stripe.com' });
1134
1334
  * const output = await job.get();
1135
1335
  * ```
1336
+ *
1337
+ * @sdkReference entrypoints 020
1136
1338
  */
1137
1339
  export class DeeplineContext {
1138
1340
  private readonly client: DeeplineClient;
1139
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
+ */
1140
1350
  constructor(options?: DeeplineClientOptions) {
1141
1351
  this.client = new DeeplineClient(options);
1142
1352
  }
@@ -1152,7 +1362,7 @@ export class DeeplineContext {
1152
1362
  * const company = companyLookup.toolResponse.raw;
1153
1363
  * ```
1154
1364
  */
1155
- get tools() {
1365
+ get tools(): DeeplineToolsNamespace {
1156
1366
  return {
1157
1367
  /** List all available tools. */
1158
1368
  list: (): Promise<ToolDefinition[]> => this.client.listTools(),
@@ -1172,7 +1382,13 @@ export class DeeplineContext {
1172
1382
  };
1173
1383
  }
1174
1384
 
1175
- 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 {
1176
1392
  return {
1177
1393
  list: () => this.client.listPlays(),
1178
1394
  get: <TInput = Record<string, unknown>, TOutput = unknown>(
@@ -1181,6 +1397,13 @@ export class DeeplineContext {
1181
1397
  };
1182
1398
  }
1183
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
+ */
1184
1407
  get prebuilt(): Record<string, PrebuiltPlayRef> {
1185
1408
  const explicit = {
1186
1409
  companyToContact: {
@@ -1241,6 +1464,17 @@ export class DeeplineContext {
1241
1464
  return createNamedPlayHandle<TInput, TOutput>(() => this.client, name);
1242
1465
  }
1243
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
+ */
1244
1478
  async runPlay<TInput = Record<string, unknown>, TOutput = unknown>(
1245
1479
  playOrRef: string | PlayReferenceLike,
1246
1480
  input: TInput,
@@ -1264,6 +1498,8 @@ export class DeeplineContext {
1264
1498
  * const tools = await deepline.tools.list();
1265
1499
  * const result = await deepline.tools.execute('test_company_search', { domain: 'stripe.com' });
1266
1500
  * ```
1501
+ *
1502
+ * @sdkReference entrypoints 010
1267
1503
  */
1268
1504
  export class Deepline {
1269
1505
  /**
@@ -1490,6 +1726,9 @@ export function definePlay<TInput, TOutput extends PlayReturnObject>(
1490
1726
  fn: (ctx: DeeplinePlayRuntimeContext, input: TInput) => Promise<TOutput>,
1491
1727
  bindings?: PlayBindings,
1492
1728
  ): DefinedPlay<TInput, TOutput>;
1729
+ /**
1730
+ * @sdkReference runtime 010
1731
+ */
1493
1732
  export function definePlay<TInput, TOutput extends PlayReturnObject>(
1494
1733
  nameOrConfig: string | DefinePlayConfig<TInput, TOutput>,
1495
1734
  maybeFn?: (
@@ -46,6 +46,7 @@ import type {
46
46
  WorkReceipt,
47
47
  WorkReceiptClaim,
48
48
  } from '../../../shared_libs/play-runtime/work-receipts';
49
+ import type { CellStalenessPolicy } from '../../../shared_libs/play-runtime/cell-staleness';
49
50
 
50
51
  /**
51
52
  * Service-binding RPC stub shape — what `env.HARNESS` looks like inside
@@ -191,7 +192,7 @@ export async function harnessStartSheetDataset(input: {
191
192
  runId: string;
192
193
  inputOffset?: number;
193
194
  userEmail?: string | null;
194
- cellPolicies?: Record<string, { staleAfterSeconds?: number }>;
195
+ cellPolicies?: Record<string, CellStalenessPolicy>;
195
196
  }): Promise<{
196
197
  inserted: number;
197
198
  skipped: number;
@@ -50,10 +50,10 @@ export type SdkRelease = {
50
50
  };
51
51
 
52
52
  export const SDK_RELEASE = {
53
- version: '0.1.83',
53
+ version: '0.1.88',
54
54
  apiContract: '2026-06-dataset-column-cell-stale-hard-cutover',
55
55
  supportPolicy: {
56
- latest: '0.1.83',
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;
@@ -505,6 +566,10 @@ export interface PlayRunListItem {
505
566
  closeTime: string | null;
506
567
  /** Duration string (e.g. `'2.5s'`). */
507
568
  executionTime: string | null;
569
+ /** Total Deepline credits charged for the run, when available. */
570
+ billingTotalCredits?: number;
571
+ /** Configured per-run Deepline credit cap, when available. */
572
+ billingMaxCreditsPerRun?: number | null;
508
573
  /** Metadata attached to the workflow. */
509
574
  memo: {
510
575
  /** Organization that owns this run. */