deepline 0.2.60 → 0.2.62

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.
@@ -4,7 +4,10 @@ import {
4
4
  ToolExecutionError,
5
5
  brandAsProviderTransientError,
6
6
  brandAsToolExecutionError,
7
+ getProviderUnavailableReason,
8
+ isProviderUnavailable,
7
9
  isProviderTransientFailure,
10
+ isProviderWaterfallUnavailableError,
8
11
  type ProviderTransientErrorCategory,
9
12
  type ToolExecutionErrorCategory,
10
13
  type ToolExecutionFailureV1,
@@ -18,7 +21,12 @@ export {
18
21
  DeeplineError,
19
22
  ProviderTransientError,
20
23
  ToolExecutionError,
24
+ getProviderUnavailableReason,
25
+ isProviderUnavailable,
26
+ isProviderWaterfallUnavailableError,
21
27
  type ProviderTransientErrorCategory,
28
+ type ProviderUnavailableError,
29
+ type ProviderUnavailableReason,
22
30
  type ToolExecutionErrorCategory,
23
31
  type ToolExecutionFailureV1,
24
32
  type ToolExecutionErrorOrigin,
@@ -126,6 +126,9 @@ export {
126
126
  DeeplineError,
127
127
  ProviderTransientError,
128
128
  ToolExecutionError,
129
+ getProviderUnavailableReason,
130
+ isProviderUnavailable,
131
+ isProviderWaterfallUnavailableError,
129
132
  AuthError,
130
133
  RateLimitError,
131
134
  ToolRateLimitError,
@@ -133,6 +136,8 @@ export {
133
136
  } from './errors.js';
134
137
  export type {
135
138
  ProviderTransientErrorCategory,
139
+ ProviderUnavailableError,
140
+ ProviderUnavailableReason,
136
141
  ToolExecutionErrorCategory,
137
142
  ToolExecutionFailureV1,
138
143
  ToolExecutionErrorOrigin,
@@ -140,6 +140,7 @@ import type {
140
140
  PlayAuthoringRuntimeContext,
141
141
  PlayAuthoringRuntimeStepOptions,
142
142
  PlayAuthoringStepOptions,
143
+ PlayAuthoringStepProgramOptions,
143
144
  PlayAuthoringStepProgram,
144
145
  PlayAuthoringStepProgramOutput,
145
146
  PlayAuthoringStepProgramResolver,
@@ -333,6 +334,9 @@ export type StepOptions<Row, Value = unknown> = PlayAuthoringStepOptions<
333
334
  Value
334
335
  >;
335
336
 
337
+ /** Explicitly mark a step program as a provider fallback waterfall. */
338
+ export type StepProgramOptions = PlayAuthoringStepProgramOptions;
339
+
336
340
  export type StepProgram<
337
341
  Input,
338
342
  Output,
@@ -720,6 +724,7 @@ class DeeplineStepProgram<Input, Output, ReturnValue> implements StepProgram<
720
724
  constructor(
721
725
  readonly steps: readonly PlayStepProgramStep[],
722
726
  readonly returnResolver?: StepResolver<Output, ReturnValue>,
727
+ readonly continueOnProviderUnavailable = false,
723
728
  ) {}
724
729
 
725
730
  step<Name extends string, Value>(
@@ -774,13 +779,18 @@ class DeeplineStepProgram<Input, Output, ReturnValue> implements StepProgram<
774
779
  Output & Record<Name, Value | null>,
775
780
  ReturnValue
776
781
  >,
782
+ this.continueOnProviderUnavailable,
777
783
  );
778
784
  }
779
785
 
780
786
  return<Value>(
781
787
  resolver: StepResolver<Output, Value>,
782
788
  ): StepProgram<Input, Output, Value> {
783
- return new DeeplineStepProgram(this.steps, resolver);
789
+ return new DeeplineStepProgram(
790
+ this.steps,
791
+ resolver,
792
+ this.continueOnProviderUnavailable,
793
+ );
784
794
  }
785
795
  }
786
796
 
@@ -794,8 +804,14 @@ function isConditionalStepResolver(
794
804
  );
795
805
  }
796
806
 
797
- export function steps<TInput>(): StepProgram<TInput, TInput, TInput> {
798
- return new DeeplineStepProgram<TInput, TInput, TInput>([]);
807
+ export function steps<TInput>(
808
+ options: StepProgramOptions = {},
809
+ ): StepProgram<TInput, TInput, TInput> {
810
+ return new DeeplineStepProgram<TInput, TInput, TInput>(
811
+ [],
812
+ undefined,
813
+ options.continueOnProviderUnavailable === true,
814
+ );
799
815
  }
800
816
 
801
817
  export function runIf<Row, Value>(
@@ -160,7 +160,7 @@ export const SDK_RELEASE = {
160
160
  // 0.2.0 makes Dataset Handles uniformly async-only after 0.1.320 briefly
161
161
  // exposed storage-dependent synchronous access. This deliberate minor
162
162
  // release keeps lazy paging semantics independent of row residency.
163
- version: '0.2.60',
163
+ version: '0.2.62',
164
164
  contracts: {
165
165
  api: {
166
166
  name: 'sdk-http-api',
@@ -100,6 +100,7 @@ import {
100
100
  normalizePlayContractCompatibility,
101
101
  } from '@shared_libs/plays/contracts';
102
102
  import {
103
+ isProviderUnavailable,
103
104
  serializeToolExecutionFailure,
104
105
  TOOL_EXECUTION_ERROR_SCHEMA_VERSION,
105
106
  TOOL_EXECUTION_ERROR_SCHEMA_HEADER,
@@ -1666,6 +1667,23 @@ function isRuntimeConditionalStepResolver(
1666
1667
  );
1667
1668
  }
1668
1669
 
1670
+ /**
1671
+ * Prebuilt source is also typechecked by the deployed SDK, which can lag the
1672
+ * runtime. A tagged `runIf` keeps that source compatible with older `steps()`
1673
+ * declarations while retaining the explicit per-program waterfall opt-in.
1674
+ */
1675
+ function continuesOnProviderUnavailable(program: RuntimeStepProgram): boolean {
1676
+ return (
1677
+ program.continueOnProviderUnavailable === true ||
1678
+ program.steps.some(
1679
+ (step) =>
1680
+ isRuntimeConditionalStepResolver(step.resolver) &&
1681
+ (step.resolver.when as { __deeplineProviderWaterfall?: unknown })
1682
+ .__deeplineProviderWaterfall === true,
1683
+ )
1684
+ );
1685
+ }
1686
+
1669
1687
  const CTX_MAP_MIGRATION_MESSAGE =
1670
1688
  'ctx.map(...) has been replaced by ctx.dataset(...). Use ctx.dataset("rows", rows).withColumn("field", resolver).run().';
1671
1689
  const DATASET_STEP_MIGRATION_MESSAGE =
@@ -7810,6 +7828,8 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
7810
7828
  program: RuntimeStepProgram,
7811
7829
  ): MapFieldDefinition<Record<string, unknown>> {
7812
7830
  const definition: MapFieldDefinition<Record<string, unknown>> = {};
7831
+ const continueOnProviderUnavailable =
7832
+ continuesOnProviderUnavailable(program);
7813
7833
  for (const step of program.steps) {
7814
7834
  const resolver: MapFieldResolver<
7815
7835
  Record<string, unknown>,
@@ -7820,14 +7840,27 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
7820
7840
  currentRow: Record<string, unknown>,
7821
7841
  index: number,
7822
7842
  previousCell?: PreviousCell,
7823
- ) =>
7824
- await this.executeStepProgramStep(
7825
- step,
7826
- currentRow,
7827
- index,
7828
- [step.name],
7829
- previousCell,
7830
- );
7843
+ ) => {
7844
+ try {
7845
+ return await this.executeStepProgramStep(
7846
+ step,
7847
+ currentRow,
7848
+ index,
7849
+ [step.name],
7850
+ previousCell,
7851
+ );
7852
+ } catch (error) {
7853
+ if (
7854
+ (!continueOnProviderUnavailable &&
7855
+ step.continueOnProviderUnavailable !== true) ||
7856
+ (!(error instanceof ProviderExhaustedError) &&
7857
+ !isProviderUnavailable(error))
7858
+ ) {
7859
+ throw error;
7860
+ }
7861
+ return null;
7862
+ }
7863
+ };
7831
7864
  definition[step.name] = resolver;
7832
7865
  }
7833
7866
  Object.defineProperty(definition, STEP_PROGRAM_MAP_DEFINITION, {
@@ -7849,8 +7882,12 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
7849
7882
  // Steps this program has not run yet. Hoisted per program, not rebuilt per
7850
7883
  // step, and shrunk as each step produces.
7851
7884
  const pendingStepNames = new Set(program.steps.map((step) => step.name));
7885
+ const waterfallAttempts: Record<string, Record<string, unknown>> = {};
7886
+ const continueOnProviderUnavailable =
7887
+ continuesOnProviderUnavailable(program);
7852
7888
  for (const step of program.steps) {
7853
7889
  const stepPath = [...path, step.name];
7890
+ const stageExecution = { skipped: false };
7854
7891
  // ADR 0019: a step's read-set is the row as it stands *now*, which
7855
7892
  // includes every earlier step's output. Sibling steps are not part of the
7856
7893
  // row's column order, so a step cell keeps an explicit array where a
@@ -7878,6 +7915,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
7878
7915
  index,
7879
7916
  stepPath,
7880
7917
  undefined,
7918
+ stageExecution,
7881
7919
  ),
7882
7920
  {
7883
7921
  semanticKey: stableDigest(
@@ -7895,30 +7933,63 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
7895
7933
  index,
7896
7934
  stepPath,
7897
7935
  undefined,
7936
+ stageExecution,
7898
7937
  );
7899
7938
  let value: unknown;
7900
7939
  try {
7901
7940
  value = await runStep();
7902
7941
  } catch (error) {
7903
- // PROVIDER_EXHAUSTED is a step MISS, not a program abort. The pacer
7904
- // skipped this provider (no spend, no dispatch); resolve the step as an
7905
- // empty result so the row falls through to the next step's `runIf` chain
7906
- // exactly as it would for a provider miss. Any OTHER error keeps its
7907
- // existing propagation (row-isolation / abort semantics unchanged).
7908
- if (!(error instanceof ProviderExhaustedError)) throw error;
7942
+ // A provider admission, transient upstream failure, or exhausted
7943
+ // managed provider account is a visible unavailable leg, not a row
7944
+ // abort. Persist the failure on this stage, then make its value a
7945
+ // normal miss so existing `runIf` waterfalls advance without every
7946
+ // author hand-writing error handling.
7947
+ if (
7948
+ !continueOnProviderUnavailable ||
7949
+ (!(error instanceof ProviderExhaustedError) &&
7950
+ !isProviderUnavailable(error))
7951
+ ) {
7952
+ throw error;
7953
+ }
7954
+ const unavailableAttempt =
7955
+ error instanceof ProviderExhaustedError
7956
+ ? {
7957
+ provider: error.provider,
7958
+ operation: null,
7959
+ code: error.code,
7960
+ category: 'rate_limit',
7961
+ retryable: true,
7962
+ statusCode: null,
7963
+ requestId: null,
7964
+ retryAfterMs: null,
7965
+ }
7966
+ : {
7967
+ provider: error.provider ?? null,
7968
+ operation: error.operation ?? null,
7969
+ code: error.code ?? null,
7970
+ category: error.category ?? null,
7971
+ retryable: error.retryable === true,
7972
+ statusCode: error.statusCode ?? null,
7973
+ requestId: error.requestId ?? null,
7974
+ retryAfterMs: error.retryAfterMs ?? null,
7975
+ };
7909
7976
  value = null;
7977
+ waterfallAttempts[step.name] = {
7978
+ status: 'unavailable',
7979
+ ...unavailableAttempt,
7980
+ error: this.formatRuntimeError(error),
7981
+ };
7910
7982
  const rowStore = rowContext.getStore();
7911
- const fieldName = stepPath.join('.');
7912
7983
  if (rowStore) {
7913
7984
  this.emitScopedFieldMetaUpdate({
7914
7985
  rowId: rowStore.rowId,
7915
7986
  key: rowStore.rowKey ?? null,
7916
7987
  tableNamespace: rowStore.tableNamespace ?? null,
7917
- fieldName,
7988
+ fieldName: stepPath.join('.'),
7918
7989
  status: 'failed',
7919
7990
  rowStatus: 'running',
7920
7991
  stage: 'failed',
7921
- provider: null,
7992
+ provider: error.provider,
7922
7993
  error: this.formatRuntimeError(error),
7923
7994
  dataPatch: {},
7924
7995
  });
@@ -7928,6 +7999,11 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
7928
7999
  currentRow = cloneCsvAliasedRow(currentRow, { [step.name]: value });
7929
8000
  continue;
7930
8001
  }
8002
+ waterfallAttempts[step.name] = stageExecution.skipped
8003
+ ? { status: 'skipped' }
8004
+ : value === null
8005
+ ? { status: 'no_result' }
8006
+ : { status: 'completed', result: value };
7931
8007
  produced[step.name] = value;
7932
8008
  pendingStepNames.delete(step.name);
7933
8009
  const rowStore = rowContext.getStore();
@@ -7952,9 +8028,32 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
7952
8028
  currentRow = cloneCsvAliasedRow(currentRow, { [step.name]: value });
7953
8029
  }
7954
8030
  if (typeof program.returnResolver === 'function') {
7955
- return await program.returnResolver(currentRow, this, index);
8031
+ const result = await program.returnResolver(currentRow, this, index);
8032
+ return continueOnProviderUnavailable
8033
+ ? this.appendWaterfallAttempts(result, waterfallAttempts)
8034
+ : result;
7956
8035
  }
7957
- return produced;
8036
+ return continueOnProviderUnavailable
8037
+ ? this.appendWaterfallAttempts(produced, waterfallAttempts)
8038
+ : produced;
8039
+ }
8040
+
8041
+ private appendWaterfallAttempts(
8042
+ result: unknown,
8043
+ waterfallAttempts: Record<string, Record<string, unknown>>,
8044
+ ): unknown {
8045
+ if (
8046
+ result === null ||
8047
+ typeof result !== 'object' ||
8048
+ Array.isArray(result) ||
8049
+ Object.prototype.hasOwnProperty.call(result, 'waterfall_attempts')
8050
+ ) {
8051
+ return result;
8052
+ }
8053
+ return {
8054
+ ...(result as Record<string, unknown>),
8055
+ waterfall_attempts: waterfallAttempts,
8056
+ };
7958
8057
  }
7959
8058
 
7960
8059
  private async executeStepProgramStep(
@@ -7963,6 +8062,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
7963
8062
  index: number,
7964
8063
  path: string[],
7965
8064
  previousCell?: PreviousCell,
8065
+ stageExecution?: { skipped: boolean },
7966
8066
  ): Promise<unknown> {
7967
8067
  const resolver = step.resolver;
7968
8068
  const store = rowContext.getStore();
@@ -8024,6 +8124,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
8024
8124
  dataPatch: {},
8025
8125
  });
8026
8126
  }
8127
+ if (stageExecution) stageExecution.skipped = true;
8027
8128
  return elseValue;
8028
8129
  }
8029
8130
  return await runWithStepScope(
@@ -1041,6 +1041,8 @@ export type RuntimeConditionalStepResolver<
1041
1041
 
1042
1042
  export type RuntimeStepProgramStep = {
1043
1043
  name: string;
1044
+ /** Copied from a `withColumns()` waterfall program for per-leg fallback. */
1045
+ continueOnProviderUnavailable?: boolean;
1044
1046
  recompute?: boolean;
1045
1047
  recomputeOnError?: boolean;
1046
1048
  staleAfterSeconds?: number;
@@ -1054,6 +1056,8 @@ export type RuntimeStepProgram = {
1054
1056
  kind: 'steps';
1055
1057
  steps: readonly RuntimeStepProgramStep[];
1056
1058
  returnResolver?: RuntimeStepResolver;
1059
+ /** Opt in to treating provider unavailability as a miss and advancing. */
1060
+ continueOnProviderUnavailable?: boolean;
1057
1061
  };
1058
1062
 
1059
1063
  export type { PlayDataset, PlayDatasetInput, PlayDatasetRow };
@@ -56,6 +56,7 @@ export type StepProgramDatasetStep<TResolver> = {
56
56
  export type StepProgramDatasetProgram<TStep> = {
57
57
  kind: 'steps';
58
58
  steps: readonly TStep[];
59
+ continueOnProviderUnavailable?: boolean;
59
60
  };
60
61
 
61
62
  export type StepProgramDatasetConditionalResolver<TResolver> = {
@@ -91,6 +92,29 @@ export function isStepProgramDatasetConditionalResolver<TResolver>(
91
92
  );
92
93
  }
93
94
 
95
+ function continuesOnProviderUnavailable<TStep>(
96
+ program: StepProgramDatasetProgram<TStep>,
97
+ ): boolean {
98
+ return (
99
+ program.continueOnProviderUnavailable === true ||
100
+ program.steps.some(
101
+ (step) =>
102
+ isStepProgramDatasetConditionalResolver(
103
+ (step as StepProgramDatasetStep<unknown>).resolver,
104
+ ) &&
105
+ (
106
+ (
107
+ step as StepProgramDatasetStep<
108
+ StepProgramDatasetConditionalResolver<unknown>
109
+ >
110
+ ).resolver.when as {
111
+ __deeplineProviderWaterfall?: unknown;
112
+ }
113
+ ).__deeplineProviderWaterfall === true,
114
+ )
115
+ );
116
+ }
117
+
94
118
  export class StepProgramDatasetBuilder<
95
119
  TStep extends StepProgramDatasetStep<TResolver>,
96
120
  TResolver,
@@ -147,7 +171,16 @@ export class StepProgramDatasetBuilder<
147
171
  if (!isStepProgramDatasetProgram<TStep>(program)) {
148
172
  throw new Error(this.messages.invalidColumnsProgram);
149
173
  }
150
- this.program.steps = [...this.program.steps, ...program.steps];
174
+ const continueOnProviderUnavailable =
175
+ continuesOnProviderUnavailable(program);
176
+ this.program.steps = [
177
+ ...this.program.steps,
178
+ ...program.steps.map((step) =>
179
+ continueOnProviderUnavailable
180
+ ? ({ ...step, continueOnProviderUnavailable: true } as TStep)
181
+ : step,
182
+ ),
183
+ ];
151
184
  return this;
152
185
  }
153
186
 
@@ -495,6 +495,11 @@ export type PlayAuthoringStepOptions<Row, Value = unknown> = {
495
495
  readonly staleAfterSeconds?: number;
496
496
  };
497
497
 
498
+ /** Explicitly mark a step program as a provider fallback waterfall. */
499
+ export type PlayAuthoringStepProgramOptions = {
500
+ readonly continueOnProviderUnavailable?: boolean;
501
+ };
502
+
498
503
  export type PlayAuthoringStepProgram<
499
504
  Input,
500
505
  Output,
@@ -504,6 +509,7 @@ export type PlayAuthoringStepProgram<
504
509
  readonly kind: 'steps';
505
510
  readonly steps: readonly PlayAuthoringStepProgramStep<TContext>[];
506
511
  readonly returnResolver?: PlayAuthoringStepResolver<Output, Return, TContext>;
512
+ readonly continueOnProviderUnavailable?: boolean;
507
513
  readonly __inputType?: (input: Input) => void;
508
514
  step<Name extends string, Value>(
509
515
  name: Name,
@@ -2378,7 +2384,8 @@ export const PLAY_AUTHORING_CLOUD_TYPE_DECLARATIONS = [
2378
2384
  'export type DatasetColumnDefinition<Row, Value> = { readonly run: (input: DatasetColumnRunInput<Row, Value>) => Value | Promise<Value>; readonly runIf?: (row: Row, index: number) => boolean | Promise<boolean> };',
2379
2385
  "export type ConditionalStepResolver<Row, Value, Else = null> = { readonly kind: 'conditional'; readonly when: (row: Row, index: number) => boolean | Promise<boolean>; readonly run: StepResolver<Row, Value>; readonly elseValue: Else; else<ValueElse>(value: ValueElse): ConditionalStepResolver<Row, Value, ValueElse>; };",
2380
2386
  'export type StepOptions<Row, Value = unknown> = { readonly runIf?: (row: Row, index: number) => boolean | Promise<boolean>; readonly recompute?: boolean; readonly recomputeOnError?: boolean; readonly staleAfterSeconds?: number };',
2381
- "export type StepProgram<Input, Output, Return = Output> = { readonly kind: 'steps'; readonly steps: readonly PlayStepProgramStep[]; readonly returnResolver?: StepResolver<Output, Return>; readonly __inputType?: (input: Input) => void; step<Name extends string, Value>(name: Name, resolver: StepResolver<Output, Value> | ConditionalStepResolver<Output, Value> | StepProgramResolver<Output, Value>): StepProgram<Input, Output & Record<Name, Value>, Return>; step<Name extends string, Value>(name: Name, resolver: StepResolver<Output, Value> | StepProgramResolver<Output, Value>, options: StepOptions<Output, Value>): StepProgram<Input, Output & Record<Name, Value | null>, Return>; return<Value>(resolver: StepResolver<Output, Value>): StepProgram<Input, Output, Value>; };",
2387
+ 'export type StepProgramOptions = { readonly continueOnProviderUnavailable?: boolean };',
2388
+ "export type StepProgram<Input, Output, Return = Output> = { readonly kind: 'steps'; readonly steps: readonly PlayStepProgramStep[]; readonly returnResolver?: StepResolver<Output, Return>; readonly continueOnProviderUnavailable?: boolean; readonly __inputType?: (input: Input) => void; step<Name extends string, Value>(name: Name, resolver: StepResolver<Output, Value> | ConditionalStepResolver<Output, Value> | StepProgramResolver<Output, Value>): StepProgram<Input, Output & Record<Name, Value>, Return>; step<Name extends string, Value>(name: Name, resolver: StepResolver<Output, Value> | StepProgramResolver<Output, Value>, options: StepOptions<Output, Value>): StepProgram<Input, Output & Record<Name, Value | null>, Return>; return<Value>(resolver: StepResolver<Output, Value>): StepProgram<Input, Output, Value>; };",
2382
2389
  "export type StepProgramResolver<Input, Return> = { readonly kind: 'steps'; readonly steps: readonly PlayStepProgramStep[]; readonly returnResolver?: StepResolver<never, Return>; readonly __inputType?: (input: Input) => void };",
2383
2390
  "export type RunnableStepProgram<Input, Return> = Pick<StepProgram<Input, never, Return>, 'kind' | 'steps' | 'returnResolver' | '__inputType'>;",
2384
2391
  "export type RunnableColumnStepProgram<Return> = Pick<StepProgramResolver<unknown, Return>, 'kind' | 'steps' | 'returnResolver'>;",
@@ -367,6 +367,58 @@ export class ProviderTransientError extends ToolExecutionError {
367
367
  }
368
368
  }
369
369
 
370
+ /** Why a provider cannot serve the current read request. */
371
+ export type ProviderUnavailableReason =
372
+ | ProviderTransientErrorCategory
373
+ | 'account_capacity';
374
+
375
+ /**
376
+ * A provider-owned failure that permits a read waterfall to try its next
377
+ * provider. This does not include invalid credentials, caller input, or
378
+ * Deepline billing failures.
379
+ */
380
+ export type ProviderUnavailableError =
381
+ | ProviderTransientError
382
+ | (ToolExecutionError & {
383
+ readonly origin: 'provider';
384
+ readonly code: 'PROVIDER_ACCOUNT_CAPACITY';
385
+ });
386
+
387
+ /**
388
+ * Return the provider-specific reason a read cannot run right now.
389
+ *
390
+ * `null` means this error must stay loud: it is caller input, an invalid
391
+ * customer credential, Deepline billing, or an internal failure.
392
+ */
393
+ export function getProviderUnavailableReason(
394
+ error: unknown,
395
+ ): ProviderUnavailableReason | null {
396
+ if (error instanceof ProviderTransientError) return error.category;
397
+ if (
398
+ error instanceof ToolExecutionError &&
399
+ error.origin === 'provider' &&
400
+ error.code === 'PROVIDER_ACCOUNT_CAPACITY'
401
+ ) {
402
+ return 'account_capacity';
403
+ }
404
+ return null;
405
+ }
406
+
407
+ /**
408
+ * Whether a provider cannot serve this read right now.
409
+ *
410
+ * Use this in an explicit `catch` to advance a read-only waterfall. For
411
+ * diagnostics, use `getProviderUnavailableReason(error)`.
412
+ */
413
+ export function isProviderUnavailable(
414
+ error: unknown,
415
+ ): error is ProviderUnavailableError {
416
+ return getProviderUnavailableReason(error) !== null;
417
+ }
418
+
419
+ /** @deprecated Use isProviderUnavailable. */
420
+ export const isProviderWaterfallUnavailableError = isProviderUnavailable;
421
+
370
422
  /** Brand an internal compatibility error after its normalized fields exist. */
371
423
  export function brandAsProviderTransientError(value: object): void {
372
424
  applyBrand(value, PROVIDER_TRANSIENT_ERROR_BRAND);
package/dist/cli/index.js CHANGED
@@ -1044,7 +1044,7 @@ var SDK_RELEASE = {
1044
1044
  // 0.2.0 makes Dataset Handles uniformly async-only after 0.1.320 briefly
1045
1045
  // exposed storage-dependent synchronous access. This deliberate minor
1046
1046
  // release keeps lazy paging semantics independent of row residency.
1047
- version: "0.2.60",
1047
+ version: "0.2.62",
1048
1048
  contracts: {
1049
1049
  api: {
1050
1050
  name: "sdk-http-api",
@@ -16550,7 +16550,8 @@ var PLAY_AUTHORING_CLOUD_TYPE_DECLARATIONS = [
16550
16550
  "export type DatasetColumnDefinition<Row, Value> = { readonly run: (input: DatasetColumnRunInput<Row, Value>) => Value | Promise<Value>; readonly runIf?: (row: Row, index: number) => boolean | Promise<boolean> };",
16551
16551
  "export type ConditionalStepResolver<Row, Value, Else = null> = { readonly kind: 'conditional'; readonly when: (row: Row, index: number) => boolean | Promise<boolean>; readonly run: StepResolver<Row, Value>; readonly elseValue: Else; else<ValueElse>(value: ValueElse): ConditionalStepResolver<Row, Value, ValueElse>; };",
16552
16552
  "export type StepOptions<Row, Value = unknown> = { readonly runIf?: (row: Row, index: number) => boolean | Promise<boolean>; readonly recompute?: boolean; readonly recomputeOnError?: boolean; readonly staleAfterSeconds?: number };",
16553
- "export type StepProgram<Input, Output, Return = Output> = { readonly kind: 'steps'; readonly steps: readonly PlayStepProgramStep[]; readonly returnResolver?: StepResolver<Output, Return>; readonly __inputType?: (input: Input) => void; step<Name extends string, Value>(name: Name, resolver: StepResolver<Output, Value> | ConditionalStepResolver<Output, Value> | StepProgramResolver<Output, Value>): StepProgram<Input, Output & Record<Name, Value>, Return>; step<Name extends string, Value>(name: Name, resolver: StepResolver<Output, Value> | StepProgramResolver<Output, Value>, options: StepOptions<Output, Value>): StepProgram<Input, Output & Record<Name, Value | null>, Return>; return<Value>(resolver: StepResolver<Output, Value>): StepProgram<Input, Output, Value>; };",
16553
+ "export type StepProgramOptions = { readonly continueOnProviderUnavailable?: boolean };",
16554
+ "export type StepProgram<Input, Output, Return = Output> = { readonly kind: 'steps'; readonly steps: readonly PlayStepProgramStep[]; readonly returnResolver?: StepResolver<Output, Return>; readonly continueOnProviderUnavailable?: boolean; readonly __inputType?: (input: Input) => void; step<Name extends string, Value>(name: Name, resolver: StepResolver<Output, Value> | ConditionalStepResolver<Output, Value> | StepProgramResolver<Output, Value>): StepProgram<Input, Output & Record<Name, Value>, Return>; step<Name extends string, Value>(name: Name, resolver: StepResolver<Output, Value> | StepProgramResolver<Output, Value>, options: StepOptions<Output, Value>): StepProgram<Input, Output & Record<Name, Value | null>, Return>; return<Value>(resolver: StepResolver<Output, Value>): StepProgram<Input, Output, Value>; };",
16554
16555
  "export type StepProgramResolver<Input, Return> = { readonly kind: 'steps'; readonly steps: readonly PlayStepProgramStep[]; readonly returnResolver?: StepResolver<never, Return>; readonly __inputType?: (input: Input) => void };",
16555
16556
  "export type RunnableStepProgram<Input, Return> = Pick<StepProgram<Input, never, Return>, 'kind' | 'steps' | 'returnResolver' | '__inputType'>;",
16556
16557
  "export type RunnableColumnStepProgram<Return> = Pick<StepProgramResolver<unknown, Return>, 'kind' | 'steps' | 'returnResolver'>;",
@@ -36728,6 +36729,14 @@ function emitPassThrough(command, payload, options) {
36728
36729
  function client() {
36729
36730
  return new DeeplineClient();
36730
36731
  }
36732
+ function clientWithTimeout(timeoutSeconds) {
36733
+ if (!timeoutSeconds) return client();
36734
+ const seconds = Number(timeoutSeconds);
36735
+ if (!Number.isFinite(seconds) || seconds <= 0) {
36736
+ throw new Error("--timeout must be a positive number of seconds.");
36737
+ }
36738
+ return new DeeplineClient({ timeout: seconds * 1e3 });
36739
+ }
36731
36740
  function readStatus(payload) {
36732
36741
  if (!payload || typeof payload !== "object") return null;
36733
36742
  const record = payload;
@@ -36906,7 +36915,11 @@ async function handleCall(options) {
36906
36915
  const input2 = options.payload ? JSON.parse(options.payload) : {};
36907
36916
  if (options.mode) input2.__execution_mode = options.mode;
36908
36917
  body.input = input2;
36909
- emitPassThrough("call", await client().callWorkflow(body), options);
36918
+ emitPassThrough(
36919
+ "call",
36920
+ await clientWithTimeout(options.timeout).callWorkflow(body),
36921
+ options
36922
+ );
36910
36923
  }
36911
36924
  async function handleRuns(id, options) {
36912
36925
  const limit = options.limit ? Number(options.limit) : void 0;
@@ -37009,7 +37022,7 @@ Notes:
37009
37022
  )
37010
37023
  ).action(handleSchema);
37011
37024
  withJsonOption2(
37012
- workflows.command("call").description("Queue a workflow run.").option("--workflow-id <id>", "Workflow id").option("--workflow-name <name>", "Workflow name").option("--payload <json>", "Run input JSON").option("--mode <mode>", "live | dry_run | smoke_test")
37025
+ workflows.command("call").description("Queue a workflow run.").option("--workflow-id <id>", "Workflow id").option("--workflow-name <name>", "Workflow name").option("--payload <json>", "Run input JSON").option("--mode <mode>", "live | dry_run | smoke_test").option("--timeout <seconds>", "API read timeout in seconds.")
37013
37026
  ).action(handleCall);
37014
37027
  withJsonOption2(
37015
37028
  workflows.command("runs <id>").description("List a workflow\u2019s runs.").option("--limit <n>", "Max runs to return")
@@ -37247,25 +37260,6 @@ function detectSkillsAgents(input2) {
37247
37260
  ).map((marker) => marker.agent);
37248
37261
  return detected.length > 0 ? detected : ["*"];
37249
37262
  }
37250
- async function fetchSkillCatalog(baseUrl) {
37251
- const response = await fetch(skillsIndexUrl(baseUrl));
37252
- if (!response.ok) {
37253
- throw new Error(
37254
- `Skill catalog request failed (status ${response.status}).`
37255
- );
37256
- }
37257
- const index = await response.json();
37258
- const skillNames = (index.skills ?? []).filter((skill) => skill.install_surface === "v1").map((skill) => skill.name).filter((name) => typeof name === "string" && Boolean(name)).sort((a, b) => a.localeCompare(b));
37259
- if (skillNames.length === 0) {
37260
- throw new Error(
37261
- "The Deepline skill catalog contains no installable skills."
37262
- );
37263
- }
37264
- return {
37265
- skillNames,
37266
- version: typeof index.version === "string" && index.version.trim() ? index.version.trim() : "unversioned"
37267
- };
37268
- }
37269
37263
  function skillsStatePathForScope(baseUrl, scope, root) {
37270
37264
  return scope === "local" && root ? (0, import_node_path21.join)(root, ".deepline", "setup", "skills.json") : (0, import_node_path21.join)(sdkCliStateDirPath(baseUrl), "skills-install.json");
37271
37265
  }
@@ -37384,23 +37378,10 @@ async function runSkillsCommand(options, dependencies = {}) {
37384
37378
  return 2;
37385
37379
  }
37386
37380
  const baseUrl = autoDetectBaseUrl().replace(/\/$/, "");
37387
- let catalog;
37388
- try {
37389
- catalog = options.dryRun ? { skillNames: [...DEFAULT_SDK_SKILL_NAMES], version: "latest" } : await (dependencies.fetchCatalog ?? fetchSkillCatalog)(baseUrl);
37390
- } catch (error) {
37391
- printCommandEnvelope(
37392
- {
37393
- ok: false,
37394
- status: "failed",
37395
- code: "SKILLS_CATALOG_UNAVAILABLE",
37396
- exitCode: 5,
37397
- message: error instanceof Error ? error.message : String(error),
37398
- next: "Retry: deepline skills"
37399
- },
37400
- { json: options.json }
37401
- );
37402
- return 5;
37403
- }
37381
+ const catalog = {
37382
+ skillNames: [...DEFAULT_SDK_SKILL_NAMES],
37383
+ version: SDK_VERSION
37384
+ };
37404
37385
  const agents = options.agent ? [options.agent] : detectSkillsAgents({ scope, root });
37405
37386
  const plan = buildSkillsPlan({ baseUrl, scope, root, agents, ...catalog });
37406
37387
  if (options.dryRun) {
@@ -1030,7 +1030,7 @@ var SDK_RELEASE = {
1030
1030
  // 0.2.0 makes Dataset Handles uniformly async-only after 0.1.320 briefly
1031
1031
  // exposed storage-dependent synchronous access. This deliberate minor
1032
1032
  // release keeps lazy paging semantics independent of row residency.
1033
- version: "0.2.60",
1033
+ version: "0.2.62",
1034
1034
  contracts: {
1035
1035
  api: {
1036
1036
  name: "sdk-http-api",
@@ -16595,7 +16595,8 @@ var PLAY_AUTHORING_CLOUD_TYPE_DECLARATIONS = [
16595
16595
  "export type DatasetColumnDefinition<Row, Value> = { readonly run: (input: DatasetColumnRunInput<Row, Value>) => Value | Promise<Value>; readonly runIf?: (row: Row, index: number) => boolean | Promise<boolean> };",
16596
16596
  "export type ConditionalStepResolver<Row, Value, Else = null> = { readonly kind: 'conditional'; readonly when: (row: Row, index: number) => boolean | Promise<boolean>; readonly run: StepResolver<Row, Value>; readonly elseValue: Else; else<ValueElse>(value: ValueElse): ConditionalStepResolver<Row, Value, ValueElse>; };",
16597
16597
  "export type StepOptions<Row, Value = unknown> = { readonly runIf?: (row: Row, index: number) => boolean | Promise<boolean>; readonly recompute?: boolean; readonly recomputeOnError?: boolean; readonly staleAfterSeconds?: number };",
16598
- "export type StepProgram<Input, Output, Return = Output> = { readonly kind: 'steps'; readonly steps: readonly PlayStepProgramStep[]; readonly returnResolver?: StepResolver<Output, Return>; readonly __inputType?: (input: Input) => void; step<Name extends string, Value>(name: Name, resolver: StepResolver<Output, Value> | ConditionalStepResolver<Output, Value> | StepProgramResolver<Output, Value>): StepProgram<Input, Output & Record<Name, Value>, Return>; step<Name extends string, Value>(name: Name, resolver: StepResolver<Output, Value> | StepProgramResolver<Output, Value>, options: StepOptions<Output, Value>): StepProgram<Input, Output & Record<Name, Value | null>, Return>; return<Value>(resolver: StepResolver<Output, Value>): StepProgram<Input, Output, Value>; };",
16598
+ "export type StepProgramOptions = { readonly continueOnProviderUnavailable?: boolean };",
16599
+ "export type StepProgram<Input, Output, Return = Output> = { readonly kind: 'steps'; readonly steps: readonly PlayStepProgramStep[]; readonly returnResolver?: StepResolver<Output, Return>; readonly continueOnProviderUnavailable?: boolean; readonly __inputType?: (input: Input) => void; step<Name extends string, Value>(name: Name, resolver: StepResolver<Output, Value> | ConditionalStepResolver<Output, Value> | StepProgramResolver<Output, Value>): StepProgram<Input, Output & Record<Name, Value>, Return>; step<Name extends string, Value>(name: Name, resolver: StepResolver<Output, Value> | StepProgramResolver<Output, Value>, options: StepOptions<Output, Value>): StepProgram<Input, Output & Record<Name, Value | null>, Return>; return<Value>(resolver: StepResolver<Output, Value>): StepProgram<Input, Output, Value>; };",
16599
16600
  "export type StepProgramResolver<Input, Return> = { readonly kind: 'steps'; readonly steps: readonly PlayStepProgramStep[]; readonly returnResolver?: StepResolver<never, Return>; readonly __inputType?: (input: Input) => void };",
16600
16601
  "export type RunnableStepProgram<Input, Return> = Pick<StepProgram<Input, never, Return>, 'kind' | 'steps' | 'returnResolver' | '__inputType'>;",
16601
16602
  "export type RunnableColumnStepProgram<Return> = Pick<StepProgramResolver<unknown, Return>, 'kind' | 'steps' | 'returnResolver'>;",
@@ -36799,6 +36800,14 @@ function emitPassThrough(command, payload, options) {
36799
36800
  function client() {
36800
36801
  return new DeeplineClient();
36801
36802
  }
36803
+ function clientWithTimeout(timeoutSeconds) {
36804
+ if (!timeoutSeconds) return client();
36805
+ const seconds = Number(timeoutSeconds);
36806
+ if (!Number.isFinite(seconds) || seconds <= 0) {
36807
+ throw new Error("--timeout must be a positive number of seconds.");
36808
+ }
36809
+ return new DeeplineClient({ timeout: seconds * 1e3 });
36810
+ }
36802
36811
  function readStatus(payload) {
36803
36812
  if (!payload || typeof payload !== "object") return null;
36804
36813
  const record = payload;
@@ -36977,7 +36986,11 @@ async function handleCall(options) {
36977
36986
  const input2 = options.payload ? JSON.parse(options.payload) : {};
36978
36987
  if (options.mode) input2.__execution_mode = options.mode;
36979
36988
  body.input = input2;
36980
- emitPassThrough("call", await client().callWorkflow(body), options);
36989
+ emitPassThrough(
36990
+ "call",
36991
+ await clientWithTimeout(options.timeout).callWorkflow(body),
36992
+ options
36993
+ );
36981
36994
  }
36982
36995
  async function handleRuns(id, options) {
36983
36996
  const limit = options.limit ? Number(options.limit) : void 0;
@@ -37080,7 +37093,7 @@ Notes:
37080
37093
  )
37081
37094
  ).action(handleSchema);
37082
37095
  withJsonOption2(
37083
- workflows.command("call").description("Queue a workflow run.").option("--workflow-id <id>", "Workflow id").option("--workflow-name <name>", "Workflow name").option("--payload <json>", "Run input JSON").option("--mode <mode>", "live | dry_run | smoke_test")
37096
+ workflows.command("call").description("Queue a workflow run.").option("--workflow-id <id>", "Workflow id").option("--workflow-name <name>", "Workflow name").option("--payload <json>", "Run input JSON").option("--mode <mode>", "live | dry_run | smoke_test").option("--timeout <seconds>", "API read timeout in seconds.")
37084
37097
  ).action(handleCall);
37085
37098
  withJsonOption2(
37086
37099
  workflows.command("runs <id>").description("List a workflow\u2019s runs.").option("--limit <n>", "Max runs to return")
@@ -37327,25 +37340,6 @@ function detectSkillsAgents(input2) {
37327
37340
  ).map((marker) => marker.agent);
37328
37341
  return detected.length > 0 ? detected : ["*"];
37329
37342
  }
37330
- async function fetchSkillCatalog(baseUrl) {
37331
- const response = await fetch(skillsIndexUrl(baseUrl));
37332
- if (!response.ok) {
37333
- throw new Error(
37334
- `Skill catalog request failed (status ${response.status}).`
37335
- );
37336
- }
37337
- const index = await response.json();
37338
- const skillNames = (index.skills ?? []).filter((skill) => skill.install_surface === "v1").map((skill) => skill.name).filter((name) => typeof name === "string" && Boolean(name)).sort((a, b) => a.localeCompare(b));
37339
- if (skillNames.length === 0) {
37340
- throw new Error(
37341
- "The Deepline skill catalog contains no installable skills."
37342
- );
37343
- }
37344
- return {
37345
- skillNames,
37346
- version: typeof index.version === "string" && index.version.trim() ? index.version.trim() : "unversioned"
37347
- };
37348
- }
37349
37343
  function skillsStatePathForScope(baseUrl, scope, root) {
37350
37344
  return scope === "local" && root ? join17(root, ".deepline", "setup", "skills.json") : join17(sdkCliStateDirPath(baseUrl), "skills-install.json");
37351
37345
  }
@@ -37464,23 +37458,10 @@ async function runSkillsCommand(options, dependencies = {}) {
37464
37458
  return 2;
37465
37459
  }
37466
37460
  const baseUrl = autoDetectBaseUrl().replace(/\/$/, "");
37467
- let catalog;
37468
- try {
37469
- catalog = options.dryRun ? { skillNames: [...DEFAULT_SDK_SKILL_NAMES], version: "latest" } : await (dependencies.fetchCatalog ?? fetchSkillCatalog)(baseUrl);
37470
- } catch (error) {
37471
- printCommandEnvelope(
37472
- {
37473
- ok: false,
37474
- status: "failed",
37475
- code: "SKILLS_CATALOG_UNAVAILABLE",
37476
- exitCode: 5,
37477
- message: error instanceof Error ? error.message : String(error),
37478
- next: "Retry: deepline skills"
37479
- },
37480
- { json: options.json }
37481
- );
37482
- return 5;
37483
- }
37461
+ const catalog = {
37462
+ skillNames: [...DEFAULT_SDK_SKILL_NAMES],
37463
+ version: SDK_VERSION
37464
+ };
37484
37465
  const agents = options.agent ? [options.agent] : detectSkillsAgents({ scope, root });
37485
37466
  const plan = buildSkillsPlan({ baseUrl, scope, root, agents, ...catalog });
37486
37467
  if (options.dryRun) {
@@ -978,6 +978,33 @@ declare class ProviderTransientError extends ToolExecutionError {
978
978
  });
979
979
  static [Symbol.hasInstance](value: unknown): boolean;
980
980
  }
981
+ /** Why a provider cannot serve the current read request. */
982
+ type ProviderUnavailableReason = ProviderTransientErrorCategory | 'account_capacity';
983
+ /**
984
+ * A provider-owned failure that permits a read waterfall to try its next
985
+ * provider. This does not include invalid credentials, caller input, or
986
+ * Deepline billing failures.
987
+ */
988
+ type ProviderUnavailableError = ProviderTransientError | (ToolExecutionError & {
989
+ readonly origin: 'provider';
990
+ readonly code: 'PROVIDER_ACCOUNT_CAPACITY';
991
+ });
992
+ /**
993
+ * Return the provider-specific reason a read cannot run right now.
994
+ *
995
+ * `null` means this error must stay loud: it is caller input, an invalid
996
+ * customer credential, Deepline billing, or an internal failure.
997
+ */
998
+ declare function getProviderUnavailableReason(error: unknown): ProviderUnavailableReason | null;
999
+ /**
1000
+ * Whether a provider cannot serve this read right now.
1001
+ *
1002
+ * Use this in an explicit `catch` to advance a read-only waterfall. For
1003
+ * diagnostics, use `getProviderUnavailableReason(error)`.
1004
+ */
1005
+ declare function isProviderUnavailable(error: unknown): error is ProviderUnavailableError;
1006
+ /** @deprecated Use isProviderUnavailable. */
1007
+ declare const isProviderWaterfallUnavailableError: typeof isProviderUnavailable;
981
1008
 
982
1009
  declare const SUPPORTED_PLAY_AUTHORING_CONTRACT_EDITIONS: readonly [1, 2, 3];
983
1010
  type PlayAuthoringContractEdition = (typeof SUPPORTED_PLAY_AUTHORING_CONTRACT_EDITIONS)[number];
@@ -1182,10 +1209,15 @@ type PlayAuthoringStepOptions<Row, Value = unknown> = {
1182
1209
  /** Legacy cell staleness metadata accepted for older authored Plays. */
1183
1210
  readonly staleAfterSeconds?: number;
1184
1211
  };
1212
+ /** Explicitly mark a step program as a provider fallback waterfall. */
1213
+ type PlayAuthoringStepProgramOptions = {
1214
+ readonly continueOnProviderUnavailable?: boolean;
1215
+ };
1185
1216
  type PlayAuthoringStepProgram<Input, Output, TContext, Return = Output> = {
1186
1217
  readonly kind: 'steps';
1187
1218
  readonly steps: readonly PlayAuthoringStepProgramStep<TContext>[];
1188
1219
  readonly returnResolver?: PlayAuthoringStepResolver<Output, Return, TContext>;
1220
+ readonly continueOnProviderUnavailable?: boolean;
1189
1221
  readonly __inputType?: (input: Input) => void;
1190
1222
  step<Name extends string, Value>(name: Name, resolver: PlayAuthoringStepResolver<Output, Value, TContext> | PlayAuthoringConditionalStepResolver<Output, Value, TContext> | PlayAuthoringStepProgramResolver<Output, Value, TContext>): PlayAuthoringStepProgram<Input, Output & Record<Name, Value>, TContext, Return>;
1191
1223
  step<Name extends string, Value>(name: Name, resolver: PlayAuthoringStepResolver<Output, Value, TContext> | PlayAuthoringStepProgramResolver<Output, Value, TContext>, options: PlayAuthoringStepOptions<Output, Value>): PlayAuthoringStepProgram<Input, Output & Record<Name, Value | null>, TContext, Return>;
@@ -2743,4 +2775,4 @@ type PlayCompilerManifest = {
2743
2775
  authoringContract?: AdmittedPlayAuthoringContract;
2744
2776
  };
2745
2777
 
2746
- export { type PlayDatasetInput as $, type PlayAuthoringFetchResponse as A, type PlayAuthoringInputContract as B, type PlayAuthoringStepProgramStep as C, DeeplineError as D, type PlayAuthoringRuntimeStepOptions as E, type PlaySqlListenerDeclaration as F, type PlaySqlListenerEvent as G, type PlaySqlListenerOperation as H, type PlaySqlQuery as I, type PlayAuthoringStepOptions as J, type PlayAuthoringStepProgram as K, type PlayAuthoringStepProgramResolver as L, type PlayAuthoringStepResolver as M, type PlayToolExecutionRequest as N, DEEPLINE_EXTRACTOR_TARGETS as O, type PlayAuthoringContractEdition as P, DEEPLINE_EXTRACTOR_TARGET_DEFINITIONS as Q, type DeeplineEmailStatusGetterValue as R, type DeeplineExtractorTarget as S, type ToolExecutionErrorSchemaVersion as T, type DeeplineGetterValue as U, type DeeplineGetterValueMap as V, JOB_CHANGE_STATUS_VALUES as W, type JobChangeStatus as X, PHONE_STATUS_VALUES as Y, type PhoneStatus as Z, type PlayDataset as _, type PlayArtifactKind as a, type PreviousCell as a0, ProviderTransientError as a1, type ProviderTransientErrorCategory as a2, type ToolExecutionErrorCategory as a3, type ToolExecutionErrorOrigin as a4, type ToolExecutionFailureV1 as a5, type ToolExecutionNetworkKind as a6, type ToolExecutionNetworkScope as a7, isDeeplineExtractorTarget as a8, type PlaySandboxRuntimeDeclaration as b, type PlayCompilerManifest as c, PLAY_ARTIFACT_KINDS as d, type PlayRuntimeBackendId as e, ToolExecutionError as f, type ToolExecutionErrorOptions as g, type PlayAuthoringColumnMap as h, type PlayAuthoringColumnResolver as i, type PlayAuthoringRuntimeContext as j, type PlayAuthoringConditionalStepResolver as k, type PlayAuthoringCsvInput as l, type PlayAuthoringCsvOptions as m, type PlayAuthoringDatasetBuilder as n, type PlayAuthoringDatasetColumnDefinition as o, type PlayAuthoringDatasetColumnRunInput as p, type ToolExecuteResult as q, type PlayAuthoringReferenceLike as r, type PlayReturnObject as s, type PlayAuthoringDefineConfig as t, type PlayAuthoringDefinedPlay as u, type PlayAuthoringFetchOptions as v, type PlayAuthoringFileInput as w, type PlayAuthoringBindings as x, type PlayAuthoringCallExecution as y, type PlayAuthoringCallOptions as z };
2778
+ export { type PlayDataset as $, type PlayAuthoringFetchResponse as A, type PlayAuthoringInputContract as B, type PlayAuthoringStepProgramStep as C, DeeplineError as D, type PlayAuthoringRuntimeStepOptions as E, type PlaySqlListenerDeclaration as F, type PlaySqlListenerEvent as G, type PlaySqlListenerOperation as H, type PlaySqlQuery as I, type PlayAuthoringStepOptions as J, type PlayAuthoringStepProgram as K, type PlayAuthoringStepProgramResolver as L, type PlayAuthoringStepResolver as M, type PlayToolExecutionRequest as N, type PlayAuthoringStepProgramOptions as O, type PlayAuthoringContractEdition as P, DEEPLINE_EXTRACTOR_TARGETS as Q, DEEPLINE_EXTRACTOR_TARGET_DEFINITIONS as R, type DeeplineEmailStatusGetterValue as S, type ToolExecutionErrorSchemaVersion as T, type DeeplineExtractorTarget as U, type DeeplineGetterValue as V, type DeeplineGetterValueMap as W, JOB_CHANGE_STATUS_VALUES as X, type JobChangeStatus as Y, PHONE_STATUS_VALUES as Z, type PhoneStatus as _, type PlayArtifactKind as a, type PlayDatasetInput as a0, type PreviousCell as a1, ProviderTransientError as a2, type ProviderTransientErrorCategory as a3, type ProviderUnavailableError as a4, type ProviderUnavailableReason as a5, type ToolExecutionErrorCategory as a6, type ToolExecutionErrorOrigin as a7, type ToolExecutionFailureV1 as a8, type ToolExecutionNetworkKind as a9, type ToolExecutionNetworkScope as aa, getProviderUnavailableReason as ab, isDeeplineExtractorTarget as ac, isProviderUnavailable as ad, isProviderWaterfallUnavailableError as ae, type PlaySandboxRuntimeDeclaration as b, type PlayCompilerManifest as c, PLAY_ARTIFACT_KINDS as d, type PlayRuntimeBackendId as e, ToolExecutionError as f, type ToolExecutionErrorOptions as g, type PlayAuthoringColumnMap as h, type PlayAuthoringColumnResolver as i, type PlayAuthoringRuntimeContext as j, type PlayAuthoringConditionalStepResolver as k, type PlayAuthoringCsvInput as l, type PlayAuthoringCsvOptions as m, type PlayAuthoringDatasetBuilder as n, type PlayAuthoringDatasetColumnDefinition as o, type PlayAuthoringDatasetColumnRunInput as p, type ToolExecuteResult as q, type PlayAuthoringReferenceLike as r, type PlayReturnObject as s, type PlayAuthoringDefineConfig as t, type PlayAuthoringDefinedPlay as u, type PlayAuthoringFetchOptions as v, type PlayAuthoringFileInput as w, type PlayAuthoringBindings as x, type PlayAuthoringCallExecution as y, type PlayAuthoringCallOptions as z };
@@ -978,6 +978,33 @@ declare class ProviderTransientError extends ToolExecutionError {
978
978
  });
979
979
  static [Symbol.hasInstance](value: unknown): boolean;
980
980
  }
981
+ /** Why a provider cannot serve the current read request. */
982
+ type ProviderUnavailableReason = ProviderTransientErrorCategory | 'account_capacity';
983
+ /**
984
+ * A provider-owned failure that permits a read waterfall to try its next
985
+ * provider. This does not include invalid credentials, caller input, or
986
+ * Deepline billing failures.
987
+ */
988
+ type ProviderUnavailableError = ProviderTransientError | (ToolExecutionError & {
989
+ readonly origin: 'provider';
990
+ readonly code: 'PROVIDER_ACCOUNT_CAPACITY';
991
+ });
992
+ /**
993
+ * Return the provider-specific reason a read cannot run right now.
994
+ *
995
+ * `null` means this error must stay loud: it is caller input, an invalid
996
+ * customer credential, Deepline billing, or an internal failure.
997
+ */
998
+ declare function getProviderUnavailableReason(error: unknown): ProviderUnavailableReason | null;
999
+ /**
1000
+ * Whether a provider cannot serve this read right now.
1001
+ *
1002
+ * Use this in an explicit `catch` to advance a read-only waterfall. For
1003
+ * diagnostics, use `getProviderUnavailableReason(error)`.
1004
+ */
1005
+ declare function isProviderUnavailable(error: unknown): error is ProviderUnavailableError;
1006
+ /** @deprecated Use isProviderUnavailable. */
1007
+ declare const isProviderWaterfallUnavailableError: typeof isProviderUnavailable;
981
1008
 
982
1009
  declare const SUPPORTED_PLAY_AUTHORING_CONTRACT_EDITIONS: readonly [1, 2, 3];
983
1010
  type PlayAuthoringContractEdition = (typeof SUPPORTED_PLAY_AUTHORING_CONTRACT_EDITIONS)[number];
@@ -1182,10 +1209,15 @@ type PlayAuthoringStepOptions<Row, Value = unknown> = {
1182
1209
  /** Legacy cell staleness metadata accepted for older authored Plays. */
1183
1210
  readonly staleAfterSeconds?: number;
1184
1211
  };
1212
+ /** Explicitly mark a step program as a provider fallback waterfall. */
1213
+ type PlayAuthoringStepProgramOptions = {
1214
+ readonly continueOnProviderUnavailable?: boolean;
1215
+ };
1185
1216
  type PlayAuthoringStepProgram<Input, Output, TContext, Return = Output> = {
1186
1217
  readonly kind: 'steps';
1187
1218
  readonly steps: readonly PlayAuthoringStepProgramStep<TContext>[];
1188
1219
  readonly returnResolver?: PlayAuthoringStepResolver<Output, Return, TContext>;
1220
+ readonly continueOnProviderUnavailable?: boolean;
1189
1221
  readonly __inputType?: (input: Input) => void;
1190
1222
  step<Name extends string, Value>(name: Name, resolver: PlayAuthoringStepResolver<Output, Value, TContext> | PlayAuthoringConditionalStepResolver<Output, Value, TContext> | PlayAuthoringStepProgramResolver<Output, Value, TContext>): PlayAuthoringStepProgram<Input, Output & Record<Name, Value>, TContext, Return>;
1191
1223
  step<Name extends string, Value>(name: Name, resolver: PlayAuthoringStepResolver<Output, Value, TContext> | PlayAuthoringStepProgramResolver<Output, Value, TContext>, options: PlayAuthoringStepOptions<Output, Value>): PlayAuthoringStepProgram<Input, Output & Record<Name, Value | null>, TContext, Return>;
@@ -2743,4 +2775,4 @@ type PlayCompilerManifest = {
2743
2775
  authoringContract?: AdmittedPlayAuthoringContract;
2744
2776
  };
2745
2777
 
2746
- export { type PlayDatasetInput as $, type PlayAuthoringFetchResponse as A, type PlayAuthoringInputContract as B, type PlayAuthoringStepProgramStep as C, DeeplineError as D, type PlayAuthoringRuntimeStepOptions as E, type PlaySqlListenerDeclaration as F, type PlaySqlListenerEvent as G, type PlaySqlListenerOperation as H, type PlaySqlQuery as I, type PlayAuthoringStepOptions as J, type PlayAuthoringStepProgram as K, type PlayAuthoringStepProgramResolver as L, type PlayAuthoringStepResolver as M, type PlayToolExecutionRequest as N, DEEPLINE_EXTRACTOR_TARGETS as O, type PlayAuthoringContractEdition as P, DEEPLINE_EXTRACTOR_TARGET_DEFINITIONS as Q, type DeeplineEmailStatusGetterValue as R, type DeeplineExtractorTarget as S, type ToolExecutionErrorSchemaVersion as T, type DeeplineGetterValue as U, type DeeplineGetterValueMap as V, JOB_CHANGE_STATUS_VALUES as W, type JobChangeStatus as X, PHONE_STATUS_VALUES as Y, type PhoneStatus as Z, type PlayDataset as _, type PlayArtifactKind as a, type PreviousCell as a0, ProviderTransientError as a1, type ProviderTransientErrorCategory as a2, type ToolExecutionErrorCategory as a3, type ToolExecutionErrorOrigin as a4, type ToolExecutionFailureV1 as a5, type ToolExecutionNetworkKind as a6, type ToolExecutionNetworkScope as a7, isDeeplineExtractorTarget as a8, type PlaySandboxRuntimeDeclaration as b, type PlayCompilerManifest as c, PLAY_ARTIFACT_KINDS as d, type PlayRuntimeBackendId as e, ToolExecutionError as f, type ToolExecutionErrorOptions as g, type PlayAuthoringColumnMap as h, type PlayAuthoringColumnResolver as i, type PlayAuthoringRuntimeContext as j, type PlayAuthoringConditionalStepResolver as k, type PlayAuthoringCsvInput as l, type PlayAuthoringCsvOptions as m, type PlayAuthoringDatasetBuilder as n, type PlayAuthoringDatasetColumnDefinition as o, type PlayAuthoringDatasetColumnRunInput as p, type ToolExecuteResult as q, type PlayAuthoringReferenceLike as r, type PlayReturnObject as s, type PlayAuthoringDefineConfig as t, type PlayAuthoringDefinedPlay as u, type PlayAuthoringFetchOptions as v, type PlayAuthoringFileInput as w, type PlayAuthoringBindings as x, type PlayAuthoringCallExecution as y, type PlayAuthoringCallOptions as z };
2778
+ export { type PlayDataset as $, type PlayAuthoringFetchResponse as A, type PlayAuthoringInputContract as B, type PlayAuthoringStepProgramStep as C, DeeplineError as D, type PlayAuthoringRuntimeStepOptions as E, type PlaySqlListenerDeclaration as F, type PlaySqlListenerEvent as G, type PlaySqlListenerOperation as H, type PlaySqlQuery as I, type PlayAuthoringStepOptions as J, type PlayAuthoringStepProgram as K, type PlayAuthoringStepProgramResolver as L, type PlayAuthoringStepResolver as M, type PlayToolExecutionRequest as N, type PlayAuthoringStepProgramOptions as O, type PlayAuthoringContractEdition as P, DEEPLINE_EXTRACTOR_TARGETS as Q, DEEPLINE_EXTRACTOR_TARGET_DEFINITIONS as R, type DeeplineEmailStatusGetterValue as S, type ToolExecutionErrorSchemaVersion as T, type DeeplineExtractorTarget as U, type DeeplineGetterValue as V, type DeeplineGetterValueMap as W, JOB_CHANGE_STATUS_VALUES as X, type JobChangeStatus as Y, PHONE_STATUS_VALUES as Z, type PhoneStatus as _, type PlayArtifactKind as a, type PlayDatasetInput as a0, type PreviousCell as a1, ProviderTransientError as a2, type ProviderTransientErrorCategory as a3, type ProviderUnavailableError as a4, type ProviderUnavailableReason as a5, type ToolExecutionErrorCategory as a6, type ToolExecutionErrorOrigin as a7, type ToolExecutionFailureV1 as a8, type ToolExecutionNetworkKind as a9, type ToolExecutionNetworkScope as aa, getProviderUnavailableReason as ab, isDeeplineExtractorTarget as ac, isProviderUnavailable as ad, isProviderWaterfallUnavailableError as ae, type PlaySandboxRuntimeDeclaration as b, type PlayCompilerManifest as c, PLAY_ARTIFACT_KINDS as d, type PlayRuntimeBackendId as e, ToolExecutionError as f, type ToolExecutionErrorOptions as g, type PlayAuthoringColumnMap as h, type PlayAuthoringColumnResolver as i, type PlayAuthoringRuntimeContext as j, type PlayAuthoringConditionalStepResolver as k, type PlayAuthoringCsvInput as l, type PlayAuthoringCsvOptions as m, type PlayAuthoringDatasetBuilder as n, type PlayAuthoringDatasetColumnDefinition as o, type PlayAuthoringDatasetColumnRunInput as p, type ToolExecuteResult as q, type PlayAuthoringReferenceLike as r, type PlayReturnObject as s, type PlayAuthoringDefineConfig as t, type PlayAuthoringDefinedPlay as u, type PlayAuthoringFetchOptions as v, type PlayAuthoringFileInput as w, type PlayAuthoringBindings as x, type PlayAuthoringCallExecution as y, type PlayAuthoringCallOptions as z };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { e as PlayRuntimeBackendId, c as PlayCompilerManifest, D as DeeplineError, f as ToolExecutionError, g as ToolExecutionErrorOptions, h as PlayAuthoringColumnMap, i as PlayAuthoringColumnResolver, j as PlayAuthoringRuntimeContext, k as PlayAuthoringConditionalStepResolver, l as PlayAuthoringCsvInput, m as PlayAuthoringCsvOptions, n as PlayAuthoringDatasetBuilder, o as PlayAuthoringDatasetColumnDefinition, p as PlayAuthoringDatasetColumnRunInput, q as ToolExecuteResult, r as PlayAuthoringReferenceLike, s as PlayReturnObject$1, t as PlayAuthoringDefineConfig, u as PlayAuthoringDefinedPlay, v as PlayAuthoringFetchOptions, w as PlayAuthoringFileInput, x as PlayAuthoringBindings, y as PlayAuthoringCallExecution, z as PlayAuthoringCallOptions, A as PlayAuthoringFetchResponse, B as PlayAuthoringInputContract, C as PlayAuthoringStepProgramStep, E as PlayAuthoringRuntimeStepOptions, F as PlaySqlListenerDeclaration, G as PlaySqlListenerEvent, H as PlaySqlListenerOperation, I as PlaySqlQuery, J as PlayAuthoringStepOptions, K as PlayAuthoringStepProgram, L as PlayAuthoringStepProgramResolver, M as PlayAuthoringStepResolver, N as PlayToolExecutionRequest } from './compiler-manifest-TgaC4DeD.mjs';
2
- export { O as DEEPLINE_EXTRACTOR_TARGETS, Q as DEEPLINE_EXTRACTOR_TARGET_DEFINITIONS, R as DeeplineEmailStatusGetterValue, S as DeeplineExtractorTarget, U as DeeplineGetterValue, V as DeeplineGetterValueMap, W as JOB_CHANGE_STATUS_VALUES, X as JobChangeStatus, Y as PHONE_STATUS_VALUES, Z as PhoneStatus, _ as PlayDataset, $ as PlayDatasetInput, a0 as PreviousCell, a1 as ProviderTransientError, a2 as ProviderTransientErrorCategory, a3 as ToolExecutionErrorCategory, a4 as ToolExecutionErrorOrigin, a5 as ToolExecutionFailureV1, a6 as ToolExecutionNetworkKind, a7 as ToolExecutionNetworkScope, a8 as isDeeplineExtractorTarget } from './compiler-manifest-TgaC4DeD.mjs';
1
+ import { e as PlayRuntimeBackendId, c as PlayCompilerManifest, D as DeeplineError, f as ToolExecutionError, g as ToolExecutionErrorOptions, h as PlayAuthoringColumnMap, i as PlayAuthoringColumnResolver, j as PlayAuthoringRuntimeContext, k as PlayAuthoringConditionalStepResolver, l as PlayAuthoringCsvInput, m as PlayAuthoringCsvOptions, n as PlayAuthoringDatasetBuilder, o as PlayAuthoringDatasetColumnDefinition, p as PlayAuthoringDatasetColumnRunInput, q as ToolExecuteResult, r as PlayAuthoringReferenceLike, s as PlayReturnObject$1, t as PlayAuthoringDefineConfig, u as PlayAuthoringDefinedPlay, v as PlayAuthoringFetchOptions, w as PlayAuthoringFileInput, x as PlayAuthoringBindings, y as PlayAuthoringCallExecution, z as PlayAuthoringCallOptions, A as PlayAuthoringFetchResponse, B as PlayAuthoringInputContract, C as PlayAuthoringStepProgramStep, E as PlayAuthoringRuntimeStepOptions, F as PlaySqlListenerDeclaration, G as PlaySqlListenerEvent, H as PlaySqlListenerOperation, I as PlaySqlQuery, J as PlayAuthoringStepOptions, K as PlayAuthoringStepProgram, L as PlayAuthoringStepProgramResolver, M as PlayAuthoringStepResolver, N as PlayToolExecutionRequest, O as PlayAuthoringStepProgramOptions } from './compiler-manifest-DTbs7i9a.mjs';
2
+ export { Q as DEEPLINE_EXTRACTOR_TARGETS, R as DEEPLINE_EXTRACTOR_TARGET_DEFINITIONS, S as DeeplineEmailStatusGetterValue, U as DeeplineExtractorTarget, V as DeeplineGetterValue, W as DeeplineGetterValueMap, X as JOB_CHANGE_STATUS_VALUES, Y as JobChangeStatus, Z as PHONE_STATUS_VALUES, _ as PhoneStatus, $ as PlayDataset, a0 as PlayDatasetInput, a1 as PreviousCell, a2 as ProviderTransientError, a3 as ProviderTransientErrorCategory, a4 as ProviderUnavailableError, a5 as ProviderUnavailableReason, a6 as ToolExecutionErrorCategory, a7 as ToolExecutionErrorOrigin, a8 as ToolExecutionFailureV1, a9 as ToolExecutionNetworkKind, aa as ToolExecutionNetworkScope, ab as getProviderUnavailableReason, ac as isDeeplineExtractorTarget, ad as isProviderUnavailable, ae as isProviderWaterfallUnavailableError } from './compiler-manifest-DTbs7i9a.mjs';
3
3
  import '@sinclair/typebox';
4
4
 
5
5
  declare const FIXTURE_BEHAVIOR_VERSION: 1;
@@ -3908,6 +3908,8 @@ type ConditionalStepResolver<Row, Value, Else = null> = PlayAuthoringConditional
3908
3908
  * @sdkReference runtime 110
3909
3909
  */
3910
3910
  type StepOptions<Row, Value = unknown> = PlayAuthoringStepOptions<Row, Value>;
3911
+ /** Explicitly mark a step program as a provider fallback waterfall. */
3912
+ type StepProgramOptions = PlayAuthoringStepProgramOptions;
3911
3913
  type StepProgram<Input, Output, Return = Output> = PlayAuthoringStepProgram<Input, Output, DeeplinePlayRuntimeContext, Return>;
3912
3914
  type StepProgramResolver<Input, Return> = PlayAuthoringStepProgramResolver<Input, Return, DeeplinePlayRuntimeContext>;
3913
3915
  type PlayStepProgramStep = PlayAuthoringStepProgramStep<DeeplinePlayRuntimeContext>;
@@ -4189,7 +4191,7 @@ type PlayInputContract<TInput> = PlayAuthoringInputContract<TInput>;
4189
4191
  * @sdkReference runtime 020
4190
4192
  */
4191
4193
  type DefinePlayConfig<TInput, TOutput extends PlayReturnObject> = PlayAuthoringDefineConfig<TInput, TOutput, DeeplinePlayRuntimeContext>;
4192
- declare function steps<TInput>(): StepProgram<TInput, TInput, TInput>;
4194
+ declare function steps<TInput>(options?: StepProgramOptions): StepProgram<TInput, TInput, TInput>;
4193
4195
  declare function runIf<Row, Value>(predicate: (row: Row, index: number) => boolean | Promise<boolean>, resolver: StepResolver<Row, Value>): ConditionalStepResolver<Row, Value, null>;
4194
4196
  /**
4195
4197
  * A defined play: both a callable function and a named play handle.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { e as PlayRuntimeBackendId, c as PlayCompilerManifest, D as DeeplineError, f as ToolExecutionError, g as ToolExecutionErrorOptions, h as PlayAuthoringColumnMap, i as PlayAuthoringColumnResolver, j as PlayAuthoringRuntimeContext, k as PlayAuthoringConditionalStepResolver, l as PlayAuthoringCsvInput, m as PlayAuthoringCsvOptions, n as PlayAuthoringDatasetBuilder, o as PlayAuthoringDatasetColumnDefinition, p as PlayAuthoringDatasetColumnRunInput, q as ToolExecuteResult, r as PlayAuthoringReferenceLike, s as PlayReturnObject$1, t as PlayAuthoringDefineConfig, u as PlayAuthoringDefinedPlay, v as PlayAuthoringFetchOptions, w as PlayAuthoringFileInput, x as PlayAuthoringBindings, y as PlayAuthoringCallExecution, z as PlayAuthoringCallOptions, A as PlayAuthoringFetchResponse, B as PlayAuthoringInputContract, C as PlayAuthoringStepProgramStep, E as PlayAuthoringRuntimeStepOptions, F as PlaySqlListenerDeclaration, G as PlaySqlListenerEvent, H as PlaySqlListenerOperation, I as PlaySqlQuery, J as PlayAuthoringStepOptions, K as PlayAuthoringStepProgram, L as PlayAuthoringStepProgramResolver, M as PlayAuthoringStepResolver, N as PlayToolExecutionRequest } from './compiler-manifest-TgaC4DeD.js';
2
- export { O as DEEPLINE_EXTRACTOR_TARGETS, Q as DEEPLINE_EXTRACTOR_TARGET_DEFINITIONS, R as DeeplineEmailStatusGetterValue, S as DeeplineExtractorTarget, U as DeeplineGetterValue, V as DeeplineGetterValueMap, W as JOB_CHANGE_STATUS_VALUES, X as JobChangeStatus, Y as PHONE_STATUS_VALUES, Z as PhoneStatus, _ as PlayDataset, $ as PlayDatasetInput, a0 as PreviousCell, a1 as ProviderTransientError, a2 as ProviderTransientErrorCategory, a3 as ToolExecutionErrorCategory, a4 as ToolExecutionErrorOrigin, a5 as ToolExecutionFailureV1, a6 as ToolExecutionNetworkKind, a7 as ToolExecutionNetworkScope, a8 as isDeeplineExtractorTarget } from './compiler-manifest-TgaC4DeD.js';
1
+ import { e as PlayRuntimeBackendId, c as PlayCompilerManifest, D as DeeplineError, f as ToolExecutionError, g as ToolExecutionErrorOptions, h as PlayAuthoringColumnMap, i as PlayAuthoringColumnResolver, j as PlayAuthoringRuntimeContext, k as PlayAuthoringConditionalStepResolver, l as PlayAuthoringCsvInput, m as PlayAuthoringCsvOptions, n as PlayAuthoringDatasetBuilder, o as PlayAuthoringDatasetColumnDefinition, p as PlayAuthoringDatasetColumnRunInput, q as ToolExecuteResult, r as PlayAuthoringReferenceLike, s as PlayReturnObject$1, t as PlayAuthoringDefineConfig, u as PlayAuthoringDefinedPlay, v as PlayAuthoringFetchOptions, w as PlayAuthoringFileInput, x as PlayAuthoringBindings, y as PlayAuthoringCallExecution, z as PlayAuthoringCallOptions, A as PlayAuthoringFetchResponse, B as PlayAuthoringInputContract, C as PlayAuthoringStepProgramStep, E as PlayAuthoringRuntimeStepOptions, F as PlaySqlListenerDeclaration, G as PlaySqlListenerEvent, H as PlaySqlListenerOperation, I as PlaySqlQuery, J as PlayAuthoringStepOptions, K as PlayAuthoringStepProgram, L as PlayAuthoringStepProgramResolver, M as PlayAuthoringStepResolver, N as PlayToolExecutionRequest, O as PlayAuthoringStepProgramOptions } from './compiler-manifest-DTbs7i9a.js';
2
+ export { Q as DEEPLINE_EXTRACTOR_TARGETS, R as DEEPLINE_EXTRACTOR_TARGET_DEFINITIONS, S as DeeplineEmailStatusGetterValue, U as DeeplineExtractorTarget, V as DeeplineGetterValue, W as DeeplineGetterValueMap, X as JOB_CHANGE_STATUS_VALUES, Y as JobChangeStatus, Z as PHONE_STATUS_VALUES, _ as PhoneStatus, $ as PlayDataset, a0 as PlayDatasetInput, a1 as PreviousCell, a2 as ProviderTransientError, a3 as ProviderTransientErrorCategory, a4 as ProviderUnavailableError, a5 as ProviderUnavailableReason, a6 as ToolExecutionErrorCategory, a7 as ToolExecutionErrorOrigin, a8 as ToolExecutionFailureV1, a9 as ToolExecutionNetworkKind, aa as ToolExecutionNetworkScope, ab as getProviderUnavailableReason, ac as isDeeplineExtractorTarget, ad as isProviderUnavailable, ae as isProviderWaterfallUnavailableError } from './compiler-manifest-DTbs7i9a.js';
3
3
  import '@sinclair/typebox';
4
4
 
5
5
  declare const FIXTURE_BEHAVIOR_VERSION: 1;
@@ -3908,6 +3908,8 @@ type ConditionalStepResolver<Row, Value, Else = null> = PlayAuthoringConditional
3908
3908
  * @sdkReference runtime 110
3909
3909
  */
3910
3910
  type StepOptions<Row, Value = unknown> = PlayAuthoringStepOptions<Row, Value>;
3911
+ /** Explicitly mark a step program as a provider fallback waterfall. */
3912
+ type StepProgramOptions = PlayAuthoringStepProgramOptions;
3911
3913
  type StepProgram<Input, Output, Return = Output> = PlayAuthoringStepProgram<Input, Output, DeeplinePlayRuntimeContext, Return>;
3912
3914
  type StepProgramResolver<Input, Return> = PlayAuthoringStepProgramResolver<Input, Return, DeeplinePlayRuntimeContext>;
3913
3915
  type PlayStepProgramStep = PlayAuthoringStepProgramStep<DeeplinePlayRuntimeContext>;
@@ -4189,7 +4191,7 @@ type PlayInputContract<TInput> = PlayAuthoringInputContract<TInput>;
4189
4191
  * @sdkReference runtime 020
4190
4192
  */
4191
4193
  type DefinePlayConfig<TInput, TOutput extends PlayReturnObject> = PlayAuthoringDefineConfig<TInput, TOutput, DeeplinePlayRuntimeContext>;
4192
- declare function steps<TInput>(): StepProgram<TInput, TInput, TInput>;
4194
+ declare function steps<TInput>(options?: StepProgramOptions): StepProgram<TInput, TInput, TInput>;
4193
4195
  declare function runIf<Row, Value>(predicate: (row: Row, index: number) => boolean | Promise<boolean>, resolver: StepResolver<Row, Value>): ConditionalStepResolver<Row, Value, null>;
4194
4196
  /**
4195
4197
  * A defined play: both a callable function and a named play handle.
package/dist/index.js CHANGED
@@ -68,9 +68,12 @@ __export(src_exports, {
68
68
  formatPlayBootstrapFinderKindsForSentence: () => formatPlayBootstrapFinderKindsForSentence,
69
69
  formatPlayBootstrapTemplates: () => formatPlayBootstrapTemplates,
70
70
  getDefinedPlayMetadata: () => getDefinedPlayMetadata,
71
+ getProviderUnavailableReason: () => getProviderUnavailableReason,
71
72
  isDeeplineExtractorTarget: () => isDeeplineExtractorTarget,
72
73
  isPlayBootstrapFinderKind: () => isPlayBootstrapFinderKind,
73
74
  isPlayBootstrapTemplate: () => isPlayBootstrapTemplate,
75
+ isProviderUnavailable: () => isProviderUnavailable,
76
+ isProviderWaterfallUnavailableError: () => isProviderWaterfallUnavailableError,
74
77
  resolveConfig: () => resolveConfig,
75
78
  runIf: () => runIf,
76
79
  steps: () => steps,
@@ -231,6 +234,17 @@ var ProviderTransientError = class _ProviderTransientError extends ToolExecution
231
234
  return hasBrand(value, PROVIDER_TRANSIENT_ERROR_BRAND);
232
235
  }
233
236
  };
237
+ function getProviderUnavailableReason(error) {
238
+ if (error instanceof ProviderTransientError) return error.category;
239
+ if (error instanceof ToolExecutionError && error.origin === "provider" && error.code === "PROVIDER_ACCOUNT_CAPACITY") {
240
+ return "account_capacity";
241
+ }
242
+ return null;
243
+ }
244
+ function isProviderUnavailable(error) {
245
+ return getProviderUnavailableReason(error) !== null;
246
+ }
247
+ var isProviderWaterfallUnavailableError = isProviderUnavailable;
234
248
  function brandAsProviderTransientError(value) {
235
249
  applyBrand(value, PROVIDER_TRANSIENT_ERROR_BRAND);
236
250
  }
@@ -763,7 +777,7 @@ var SDK_RELEASE = {
763
777
  // 0.2.0 makes Dataset Handles uniformly async-only after 0.1.320 briefly
764
778
  // exposed storage-dependent synchronous access. This deliberate minor
765
779
  // release keeps lazy paging semantics independent of row residency.
766
- version: "0.2.60",
780
+ version: "0.2.62",
767
781
  contracts: {
768
782
  api: {
769
783
  name: "sdk-http-api",
@@ -7804,12 +7818,14 @@ var DeeplineConditionalStepResolver = class _DeeplineConditionalStepResolver {
7804
7818
  }
7805
7819
  };
7806
7820
  var DeeplineStepProgram = class _DeeplineStepProgram {
7807
- constructor(steps2, returnResolver) {
7821
+ constructor(steps2, returnResolver, continueOnProviderUnavailable = false) {
7808
7822
  this.steps = steps2;
7809
7823
  this.returnResolver = returnResolver;
7824
+ this.continueOnProviderUnavailable = continueOnProviderUnavailable;
7810
7825
  }
7811
7826
  steps;
7812
7827
  returnResolver;
7828
+ continueOnProviderUnavailable;
7813
7829
  kind = "steps";
7814
7830
  step(name, resolver, options) {
7815
7831
  if (!name.trim()) {
@@ -7833,18 +7849,27 @@ var DeeplineStepProgram = class _DeeplineStepProgram {
7833
7849
  resolver: stepResolver
7834
7850
  }
7835
7851
  ],
7836
- this.returnResolver
7852
+ this.returnResolver,
7853
+ this.continueOnProviderUnavailable
7837
7854
  );
7838
7855
  }
7839
7856
  return(resolver) {
7840
- return new _DeeplineStepProgram(this.steps, resolver);
7857
+ return new _DeeplineStepProgram(
7858
+ this.steps,
7859
+ resolver,
7860
+ this.continueOnProviderUnavailable
7861
+ );
7841
7862
  }
7842
7863
  };
7843
7864
  function isConditionalStepResolver(value) {
7844
7865
  return value !== null && typeof value === "object" && value.kind === "conditional";
7845
7866
  }
7846
- function steps() {
7847
- return new DeeplineStepProgram([]);
7867
+ function steps(options = {}) {
7868
+ return new DeeplineStepProgram(
7869
+ [],
7870
+ void 0,
7871
+ options.continueOnProviderUnavailable === true
7872
+ );
7848
7873
  }
7849
7874
  function runIf(predicate, resolver) {
7850
7875
  return new DeeplineConditionalStepResolver(predicate, resolver, null);
@@ -8657,9 +8682,12 @@ function extractSummaryFields(payload) {
8657
8682
  formatPlayBootstrapFinderKindsForSentence,
8658
8683
  formatPlayBootstrapTemplates,
8659
8684
  getDefinedPlayMetadata,
8685
+ getProviderUnavailableReason,
8660
8686
  isDeeplineExtractorTarget,
8661
8687
  isPlayBootstrapFinderKind,
8662
8688
  isPlayBootstrapTemplate,
8689
+ isProviderUnavailable,
8690
+ isProviderWaterfallUnavailableError,
8663
8691
  resolveConfig,
8664
8692
  runIf,
8665
8693
  steps,
package/dist/index.mjs CHANGED
@@ -157,6 +157,17 @@ var ProviderTransientError = class _ProviderTransientError extends ToolExecution
157
157
  return hasBrand(value, PROVIDER_TRANSIENT_ERROR_BRAND);
158
158
  }
159
159
  };
160
+ function getProviderUnavailableReason(error) {
161
+ if (error instanceof ProviderTransientError) return error.category;
162
+ if (error instanceof ToolExecutionError && error.origin === "provider" && error.code === "PROVIDER_ACCOUNT_CAPACITY") {
163
+ return "account_capacity";
164
+ }
165
+ return null;
166
+ }
167
+ function isProviderUnavailable(error) {
168
+ return getProviderUnavailableReason(error) !== null;
169
+ }
170
+ var isProviderWaterfallUnavailableError = isProviderUnavailable;
160
171
  function brandAsProviderTransientError(value) {
161
172
  applyBrand(value, PROVIDER_TRANSIENT_ERROR_BRAND);
162
173
  }
@@ -689,7 +700,7 @@ var SDK_RELEASE = {
689
700
  // 0.2.0 makes Dataset Handles uniformly async-only after 0.1.320 briefly
690
701
  // exposed storage-dependent synchronous access. This deliberate minor
691
702
  // release keeps lazy paging semantics independent of row residency.
692
- version: "0.2.60",
703
+ version: "0.2.62",
693
704
  contracts: {
694
705
  api: {
695
706
  name: "sdk-http-api",
@@ -7730,12 +7741,14 @@ var DeeplineConditionalStepResolver = class _DeeplineConditionalStepResolver {
7730
7741
  }
7731
7742
  };
7732
7743
  var DeeplineStepProgram = class _DeeplineStepProgram {
7733
- constructor(steps2, returnResolver) {
7744
+ constructor(steps2, returnResolver, continueOnProviderUnavailable = false) {
7734
7745
  this.steps = steps2;
7735
7746
  this.returnResolver = returnResolver;
7747
+ this.continueOnProviderUnavailable = continueOnProviderUnavailable;
7736
7748
  }
7737
7749
  steps;
7738
7750
  returnResolver;
7751
+ continueOnProviderUnavailable;
7739
7752
  kind = "steps";
7740
7753
  step(name, resolver, options) {
7741
7754
  if (!name.trim()) {
@@ -7759,18 +7772,27 @@ var DeeplineStepProgram = class _DeeplineStepProgram {
7759
7772
  resolver: stepResolver
7760
7773
  }
7761
7774
  ],
7762
- this.returnResolver
7775
+ this.returnResolver,
7776
+ this.continueOnProviderUnavailable
7763
7777
  );
7764
7778
  }
7765
7779
  return(resolver) {
7766
- return new _DeeplineStepProgram(this.steps, resolver);
7780
+ return new _DeeplineStepProgram(
7781
+ this.steps,
7782
+ resolver,
7783
+ this.continueOnProviderUnavailable
7784
+ );
7767
7785
  }
7768
7786
  };
7769
7787
  function isConditionalStepResolver(value) {
7770
7788
  return value !== null && typeof value === "object" && value.kind === "conditional";
7771
7789
  }
7772
- function steps() {
7773
- return new DeeplineStepProgram([]);
7790
+ function steps(options = {}) {
7791
+ return new DeeplineStepProgram(
7792
+ [],
7793
+ void 0,
7794
+ options.continueOnProviderUnavailable === true
7795
+ );
7774
7796
  }
7775
7797
  function runIf(predicate, resolver) {
7776
7798
  return new DeeplineConditionalStepResolver(predicate, resolver, null);
@@ -8588,9 +8610,12 @@ export {
8588
8610
  formatPlayBootstrapFinderKindsForSentence,
8589
8611
  formatPlayBootstrapTemplates,
8590
8612
  getDefinedPlayMetadata,
8613
+ getProviderUnavailableReason,
8591
8614
  isDeeplineExtractorTarget,
8592
8615
  isPlayBootstrapFinderKind,
8593
8616
  isPlayBootstrapTemplate,
8617
+ isProviderUnavailable,
8618
+ isProviderWaterfallUnavailableError,
8594
8619
  resolveConfig,
8595
8620
  runIf,
8596
8621
  steps,
@@ -225,8 +225,8 @@
225
225
  "dist/cli/index.d.ts",
226
226
  "dist/cli/index.js",
227
227
  "dist/cli/index.mjs",
228
- "dist/compiler-manifest-TgaC4DeD.d.mts",
229
- "dist/compiler-manifest-TgaC4DeD.d.ts",
228
+ "dist/compiler-manifest-DTbs7i9a.d.mts",
229
+ "dist/compiler-manifest-DTbs7i9a.d.ts",
230
230
  "dist/helpers.d.mts",
231
231
  "dist/helpers.d.ts",
232
232
  "dist/helpers.js",
@@ -1,5 +1,5 @@
1
- import { T as ToolExecutionErrorSchemaVersion, P as PlayAuthoringContractEdition, a as PlayArtifactKind$1, b as PlaySandboxRuntimeDeclaration, c as PlayCompilerManifest } from '../compiler-manifest-TgaC4DeD.mjs';
2
- export { d as PLAY_ARTIFACT_KINDS } from '../compiler-manifest-TgaC4DeD.mjs';
1
+ import { T as ToolExecutionErrorSchemaVersion, P as PlayAuthoringContractEdition, a as PlayArtifactKind$1, b as PlaySandboxRuntimeDeclaration, c as PlayCompilerManifest } from '../compiler-manifest-DTbs7i9a.mjs';
2
+ export { d as PLAY_ARTIFACT_KINDS } from '../compiler-manifest-DTbs7i9a.mjs';
3
3
  import '@sinclair/typebox';
4
4
 
5
5
  type PlayPackageImport = {
@@ -1,5 +1,5 @@
1
- import { T as ToolExecutionErrorSchemaVersion, P as PlayAuthoringContractEdition, a as PlayArtifactKind$1, b as PlaySandboxRuntimeDeclaration, c as PlayCompilerManifest } from '../compiler-manifest-TgaC4DeD.js';
2
- export { d as PLAY_ARTIFACT_KINDS } from '../compiler-manifest-TgaC4DeD.js';
1
+ import { T as ToolExecutionErrorSchemaVersion, P as PlayAuthoringContractEdition, a as PlayArtifactKind$1, b as PlaySandboxRuntimeDeclaration, c as PlayCompilerManifest } from '../compiler-manifest-DTbs7i9a.js';
2
+ export { d as PLAY_ARTIFACT_KINDS } from '../compiler-manifest-DTbs7i9a.js';
3
3
  import '@sinclair/typebox';
4
4
 
5
5
  type PlayPackageImport = {
@@ -3942,7 +3942,8 @@ var PLAY_AUTHORING_CLOUD_TYPE_DECLARATIONS = [
3942
3942
  "export type DatasetColumnDefinition<Row, Value> = { readonly run: (input: DatasetColumnRunInput<Row, Value>) => Value | Promise<Value>; readonly runIf?: (row: Row, index: number) => boolean | Promise<boolean> };",
3943
3943
  "export type ConditionalStepResolver<Row, Value, Else = null> = { readonly kind: 'conditional'; readonly when: (row: Row, index: number) => boolean | Promise<boolean>; readonly run: StepResolver<Row, Value>; readonly elseValue: Else; else<ValueElse>(value: ValueElse): ConditionalStepResolver<Row, Value, ValueElse>; };",
3944
3944
  "export type StepOptions<Row, Value = unknown> = { readonly runIf?: (row: Row, index: number) => boolean | Promise<boolean>; readonly recompute?: boolean; readonly recomputeOnError?: boolean; readonly staleAfterSeconds?: number };",
3945
- "export type StepProgram<Input, Output, Return = Output> = { readonly kind: 'steps'; readonly steps: readonly PlayStepProgramStep[]; readonly returnResolver?: StepResolver<Output, Return>; readonly __inputType?: (input: Input) => void; step<Name extends string, Value>(name: Name, resolver: StepResolver<Output, Value> | ConditionalStepResolver<Output, Value> | StepProgramResolver<Output, Value>): StepProgram<Input, Output & Record<Name, Value>, Return>; step<Name extends string, Value>(name: Name, resolver: StepResolver<Output, Value> | StepProgramResolver<Output, Value>, options: StepOptions<Output, Value>): StepProgram<Input, Output & Record<Name, Value | null>, Return>; return<Value>(resolver: StepResolver<Output, Value>): StepProgram<Input, Output, Value>; };",
3945
+ "export type StepProgramOptions = { readonly continueOnProviderUnavailable?: boolean };",
3946
+ "export type StepProgram<Input, Output, Return = Output> = { readonly kind: 'steps'; readonly steps: readonly PlayStepProgramStep[]; readonly returnResolver?: StepResolver<Output, Return>; readonly continueOnProviderUnavailable?: boolean; readonly __inputType?: (input: Input) => void; step<Name extends string, Value>(name: Name, resolver: StepResolver<Output, Value> | ConditionalStepResolver<Output, Value> | StepProgramResolver<Output, Value>): StepProgram<Input, Output & Record<Name, Value>, Return>; step<Name extends string, Value>(name: Name, resolver: StepResolver<Output, Value> | StepProgramResolver<Output, Value>, options: StepOptions<Output, Value>): StepProgram<Input, Output & Record<Name, Value | null>, Return>; return<Value>(resolver: StepResolver<Output, Value>): StepProgram<Input, Output, Value>; };",
3946
3947
  "export type StepProgramResolver<Input, Return> = { readonly kind: 'steps'; readonly steps: readonly PlayStepProgramStep[]; readonly returnResolver?: StepResolver<never, Return>; readonly __inputType?: (input: Input) => void };",
3947
3948
  "export type RunnableStepProgram<Input, Return> = Pick<StepProgram<Input, never, Return>, 'kind' | 'steps' | 'returnResolver' | '__inputType'>;",
3948
3949
  "export type RunnableColumnStepProgram<Return> = Pick<StepProgramResolver<unknown, Return>, 'kind' | 'steps' | 'returnResolver'>;",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepline",
3
- "version": "0.2.60",
3
+ "version": "0.2.62",
4
4
  "description": "GTM data CLI and TypeScript SDK for coding agents",
5
5
  "license": "MIT",
6
6
  "homepage": "https://code.deepline.com",