deepline 0.1.229 → 0.1.231

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.
@@ -108,10 +108,10 @@ export const SDK_RELEASE = {
108
108
  // 0.1.175 ships loud `deepline enrich` empty-waterfall reporting.
109
109
  // 0.1.220 deprecates SDK CLI versions below 0.1.219 and updates them
110
110
  // automatically without blocking their current command.
111
- version: '0.1.229',
111
+ version: '0.1.231',
112
112
  apiContract: '2026-06-dataset-handle-results-hard-cutover',
113
113
  supportPolicy: {
114
- latest: '0.1.229',
114
+ latest: '0.1.231',
115
115
  minimumSupported: '0.1.53',
116
116
  deprecatedBelow: '0.1.219',
117
117
  commandMinimumSupported: [
package/dist/cli/index.js CHANGED
@@ -625,10 +625,10 @@ var SDK_RELEASE = {
625
625
  // 0.1.175 ships loud `deepline enrich` empty-waterfall reporting.
626
626
  // 0.1.220 deprecates SDK CLI versions below 0.1.219 and updates them
627
627
  // automatically without blocking their current command.
628
- version: "0.1.229",
628
+ version: "0.1.231",
629
629
  apiContract: "2026-06-dataset-handle-results-hard-cutover",
630
630
  supportPolicy: {
631
- latest: "0.1.229",
631
+ latest: "0.1.231",
632
632
  minimumSupported: "0.1.53",
633
633
  deprecatedBelow: "0.1.219",
634
634
  commandMinimumSupported: [
@@ -17886,8 +17886,6 @@ function renderExecuteStep(command, options = {
17886
17886
  force: true` : "";
17887
17887
  const legacyEnvelope = options.legacyEnvelope ? `,
17888
17888
  legacyEnvelope: true` : "";
17889
- const waterfallSoftFail = options.waterfallSoftFail ? `,
17890
- waterfallSoftFail: true` : "";
17891
17889
  return [
17892
17890
  `async (row, stepCtx) => {`,
17893
17891
  ...options.precheck ? [` if (${options.precheck}) return null;`] : [],
@@ -17899,7 +17897,7 @@ function renderExecuteStep(command, options = {
17899
17897
  ` extract: ${extractJs},`,
17900
17898
  ` runIf: ${runIfJs},`,
17901
17899
  ` row,`,
17902
- ` stepCtx${description}${force}${legacyEnvelope}${waterfallSoftFail}`,
17900
+ ` stepCtx${description}${force}${legacyEnvelope}`,
17903
17901
  ` });`,
17904
17902
  `}`
17905
17903
  ].join("\n");
@@ -17959,18 +17957,14 @@ function renderIdiomaticExecuteStep(command, options) {
17959
17957
  `async (row, ctx) => {`,
17960
17958
  ...options.precheck ? [` if (${options.precheck}) return null;`] : [],
17961
17959
  ...runIfLines,
17962
- ` let result: any;`,
17963
- ` try {`,
17964
- ` result = await ctx.tools.execute({`,
17965
- ` id: ${callId},`,
17966
- ` tool: ${tool},`,
17967
- ` input: ${input2} as any,`,
17968
- ` description: ${stringLiteral((command.description ?? "").trim() || `Run ${command.alias} via ${command.tool}.`)},`,
17960
+ ` const result: any = await ctx.tools.execute({`,
17961
+ ` id: ${callId},`,
17962
+ ` tool: ${tool},`,
17963
+ ` input: ${input2} as any,`,
17964
+ ` description: ${stringLiteral((command.description ?? "").trim() || `Run ${command.alias} via ${command.tool}.`)},`,
17969
17965
  ...options.force ? [` force: true,`] : [],
17970
- ` });`,
17971
- ` } catch (error) {`,
17972
- ...options.waterfallSoftFail ? [` return __dlWaterfallToolFailure(error);`] : [` throw error;`],
17973
- ` }`,
17966
+ ` });`,
17967
+ ` __dlAssertSuccessfulToolResult(result);`,
17974
17968
  ` return ${extraction};`,
17975
17969
  `}`
17976
17970
  ].join("\n");
@@ -17994,21 +17988,19 @@ function renderPlayStep(command, options) {
17994
17988
  ...runIfLines,
17995
17989
  ` const payload = __dlTemplate(${payload}, templateRow) as Record<string, unknown>;`,
17996
17990
  ` if (__dlShouldSkipBlankPlayPayload(payload)) return null;`,
17997
- ` let result: unknown;`,
17998
- ` try {`,
17991
+ ` const result: unknown = `,
17999
17992
  ...inlineHandler ? [
18000
17993
  // Enrich validates and normalizes this payload against the certified
18001
17994
  // prebuilt contract before code generation. The attachment retains
18002
17995
  // its concrete input type, while generated payloads are records.
18003
- ` result = await __dlRunInlinePlay(${inlineHandler}, stepCtx, payload as never, ${options.force});`
17996
+ ` await __dlRunInlinePlay(${inlineHandler}, stepCtx, payload as never, ${options.force});`
18004
17997
  ] : [
18005
- ` result = await stepCtx.runPlay(${callId}, ${playRef}, payload, {`,
18006
- ` description: ${stringLiteral(command.description ?? command.alias)}`,
17998
+ ` await stepCtx.runPlay(${callId}, ${playRef}, payload, {`,
17999
+ ` description: ${stringLiteral(command.description ?? command.alias)}`,
18007
18000
  ` });`
18008
18001
  ],
18009
- ` } catch (error) {`,
18010
- ...options.waterfallSoftFail ? [` return __dlWaterfallToolFailure(error);`] : [` throw error;`],
18011
- ` }`,
18002
+ ``,
18003
+ ` __dlAssertSuccessfulToolResult(result);`,
18012
18004
  ` return __dlPlayResultValue(${alias}, result);`,
18013
18005
  `}`
18014
18006
  ].join("\n");
@@ -18042,23 +18034,17 @@ function renderInlineJavascriptStep(command, options) {
18042
18034
  `async (row) => {`,
18043
18035
  ...options.precheck ? [` if (${options.precheck}) return null;`] : [],
18044
18036
  ...runIfLines,
18045
- ...options.waterfallSoftFail ? [` try {`] : [],
18046
- `${options.waterfallSoftFail ? " " : " "}const __dlPayload = __dlRuntimePayload('run_javascript', __dlTemplate(${payload}, row as Record<string, unknown>) as Record<string, unknown>, row as Record<string, unknown>);`,
18047
- `${options.waterfallSoftFail ? " " : " "}const rawResult = ((row: Record<string, any>, input: Record<string, any>, context: Record<string, any>) => {`,
18048
- `${options.waterfallSoftFail ? " " : " "} const payload = __dlPayload as Record<string, any>;`,
18049
- `${options.waterfallSoftFail ? " " : " "} const extract = __dlInlineExtract;`,
18050
- `${options.waterfallSoftFail ? " " : " "} const extractList = __dlInlineExtractList;`,
18051
- `${options.waterfallSoftFail ? " " : " "} return (() => {`,
18037
+ ` const __dlPayload = __dlRuntimePayload('run_javascript', __dlTemplate(${payload}, row as Record<string, unknown>) as Record<string, unknown>, row as Record<string, unknown>);`,
18038
+ ` const rawResult = ((row: Record<string, any>, input: Record<string, any>, context: Record<string, any>) => {`,
18039
+ ` const payload = __dlPayload as Record<string, any>;`,
18040
+ ` const extract = __dlInlineExtract;`,
18041
+ ` const extractList = __dlInlineExtractList;`,
18042
+ ` return (() => {`,
18052
18043
  indent(renderJavascriptBody(code), 4),
18053
- `${options.waterfallSoftFail ? " " : " "} })();`,
18054
- `${options.waterfallSoftFail ? " " : " "}})(row as Record<string, any>, row as Record<string, any>, row as Record<string, any>);`,
18055
- `${options.waterfallSoftFail ? " " : " "}const result = await Promise.resolve(rawResult);`,
18056
- `${options.waterfallSoftFail ? " " : " "}return ${resultExpression};`,
18057
- ...options.waterfallSoftFail ? [
18058
- ` } catch (error) {`,
18059
- ` return __dlExtractorFailure(error);`,
18060
- ` }`
18061
- ] : [],
18044
+ ` })();`,
18045
+ ` })(row as Record<string, any>, row as Record<string, any>, row as Record<string, any>);`,
18046
+ ` const result = await Promise.resolve(rawResult);`,
18047
+ ` return ${resultExpression};`,
18062
18048
  `}`
18063
18049
  ].join("\n");
18064
18050
  }
@@ -18192,7 +18178,6 @@ function renderWaterfallColumns(command, forceAliases, inlineRunJavascript, idio
18192
18178
  legacyEnvelope: Boolean(nested.extract_js),
18193
18179
  inlineRunJavascript,
18194
18180
  idiomaticGetters,
18195
- waterfallSoftFail: true,
18196
18181
  nativeRunIf: Boolean(runIfSource)
18197
18182
  }),
18198
18183
  {
@@ -18526,6 +18511,14 @@ function helperSource() {
18526
18511
  ` return status === 'error' || status === 'failed' || (typeof record.error === 'string' && record.error.trim() !== '') || (typeof resultError === 'string' && resultError.trim() !== '');`,
18527
18512
  `}`,
18528
18513
  ``,
18514
+ `function __dlAssertSuccessfulToolResult(value: unknown): void {`,
18515
+ ` if (!__dlErrorPayload(value)) return;`,
18516
+ ` const record = value as Record<string, unknown>;`,
18517
+ ` const result = record.result && typeof record.result === 'object' && !Array.isArray(record.result) ? record.result as Record<string, unknown> : null;`,
18518
+ ` const message = typeof record.error === 'string' ? record.error : typeof result?.error === 'string' ? result.error : typeof result?.message === 'string' ? result.message : 'Tool returned an error-shaped result.';`,
18519
+ ` throw new Error(message);`,
18520
+ `}`,
18521
+ ``,
18529
18522
  `function __dlGeneratedCellError(value: unknown): boolean {`,
18530
18523
  ` if (typeof value === 'string') {`,
18531
18524
  ` const lower = value.trim().toLowerCase();`,
@@ -18916,37 +18909,6 @@ function helperSource() {
18916
18909
  ` return keys ? __dlProjectListRows(rows, keys, payload) : rows;`,
18917
18910
  `}`,
18918
18911
  ``,
18919
- `function __dlErrorMessage(error: unknown): string {`,
18920
- ` if (error instanceof Error && error.message) return error.message;`,
18921
- ` if (typeof error === 'string' && error.trim()) return error.trim();`,
18922
- ` return 'Extractor failed';`,
18923
- `}`,
18924
- ``,
18925
- `function __dlErrorDetail(error: unknown): string {`,
18926
- ` const message = __dlErrorMessage(error);`,
18927
- ` if (!__dlRecord(error)) return message;`,
18928
- ` try {`,
18929
- ` return message + ' ' + JSON.stringify(error);`,
18930
- ` } catch {`,
18931
- ` return message;`,
18932
- ` }`,
18933
- `}`,
18934
- ``,
18935
- `function __dlRecoverableWaterfallToolError(error: unknown): boolean {`,
18936
- ` const detail = __dlErrorDetail(error).toLowerCase();`,
18937
- ` return /\\b5\\d\\d\\b/.test(detail) || detail.includes('upstream_failure') || detail.includes('"error_category":"upstream"') || (detail.includes('"failure_origin":"provider"') && detail.includes('"status":5')) || detail.includes('bad gateway') || detail.includes('gateway time-out') || detail.includes('gateway timeout') || detail.includes('service unavailable');`,
18938
- `}`,
18939
- ``,
18940
- `function __dlWaterfallToolFailure(error: unknown, tool?: string): unknown {`,
18941
- ` if (tool === 'run_javascript' || __dlRecoverableWaterfallToolError(error)) return __dlExtractorFailure(error);`,
18942
- ` throw error;`,
18943
- `}`,
18944
- ``,
18945
- `function __dlExtractorFailure(error: unknown): unknown {`,
18946
- ` const message = __dlErrorMessage(error);`,
18947
- ` return { matched_result: null, result: { error: message, message } };`,
18948
- `}`,
18949
- ``,
18950
18912
  `function __dlExtract(alias: string, result: unknown, row: Record<string, unknown>, extractor: ((args: __DlExtractorHelpers) => unknown) | null, legacyEnvelope = false): unknown {`,
18951
18913
  ` const raw = __dlRawToolOutput(result);`,
18952
18914
  ` if (!extractor) return raw;`,
@@ -18987,12 +18949,8 @@ function helperSource() {
18987
18949
  ` };`,
18988
18950
  ` const get = (path: string): unknown => __dlExtractedValue(result, path) ?? __dlFirstByPaths(raw, path);`,
18989
18951
  ` let resolved: unknown;`,
18990
- ` try {`,
18991
- ` const extracted = extractor({ row, result, data: raw, raw, pick, extract, extractList, target: pick, get });`,
18992
- ` resolved = typeof extracted === 'function' ? (extracted as (outputData: unknown) => unknown)(__dlLegacyOutputData(result, raw)) : extracted;`,
18993
- ` } catch (error) {`,
18994
- ` return __dlExtractorFailure(error);`,
18995
- ` }`,
18952
+ ` const extracted = extractor({ row, result, data: raw, raw, pick, extract, extractList, target: pick, get });`,
18953
+ ` resolved = typeof extracted === 'function' ? (extracted as (outputData: unknown) => unknown)(__dlLegacyOutputData(result, raw)) : extracted;`,
18996
18954
  ` if (resolved && typeof resolved === 'object' && !Array.isArray(resolved) && alias in (resolved as Record<string, unknown>)) {`,
18997
18955
  ` const aliasValue = (resolved as Record<string, unknown>)[alias];`,
18998
18956
  ` return legacyEnvelope && __dlMeaningful(aliasValue) ? __dlLegacyMatchedEnvelope(aliasValue, raw) : aliasValue;`,
@@ -19082,26 +19040,21 @@ function helperSource() {
19082
19040
  ` return result;`,
19083
19041
  `}`,
19084
19042
  ``,
19085
- `async function __dlRunCommand(input: { alias: string; callId: string; tool: string; payload: Record<string, unknown>; extract: ((args: __DlExtractorHelpers) => unknown) | null; runIf: ((row: Record<string, unknown>) => unknown) | null; row: Record<string, unknown>; stepCtx: { tools: { execute: (request: Record<string, unknown>) => Promise<unknown> } }; description?: string; force?: boolean; legacyEnvelope?: boolean; waterfallSoftFail?: boolean }): Promise<unknown> {`,
19043
+ `async function __dlRunCommand(input: { alias: string; callId: string; tool: string; payload: Record<string, unknown>; extract: ((args: __DlExtractorHelpers) => unknown) | null; runIf: ((row: Record<string, unknown>) => unknown) | null; row: Record<string, unknown>; stepCtx: { tools: { execute: (request: Record<string, unknown>) => Promise<unknown> } }; description?: string; force?: boolean; legacyEnvelope?: boolean }): Promise<unknown> {`,
19086
19044
  ` if (input.runIf) {`,
19087
19045
  ` const shouldRun = input.runIf(input.row);`,
19088
19046
  ` if (!shouldRun) return null;`,
19089
19047
  ` }`,
19090
19048
  ` const payload = __dlRuntimePayload(input.tool, __dlTemplate(input.payload, input.row) as Record<string, unknown>, input.row);`,
19091
19049
  ` if (__dlShouldSkipEmptyPayload(input.tool, payload)) return null;`,
19092
- ` let result: unknown;`,
19093
- ` try {`,
19094
- ` result = await input.stepCtx.tools.execute({`,
19095
- ` id: input.callId,`,
19096
- ` tool: input.tool,`,
19097
- ` input: payload,`,
19098
- ` ...(input.description ? { description: input.description } : {}),`,
19099
- ` ...(input.force ? { force: true } : {}),`,
19100
- ` });`,
19101
- ` } catch (error) {`,
19102
- ` if (input.waterfallSoftFail) return __dlWaterfallToolFailure(error, input.tool);`,
19103
- ` throw error;`,
19104
- ` }`,
19050
+ ` const result = await input.stepCtx.tools.execute({`,
19051
+ ` id: input.callId,`,
19052
+ ` tool: input.tool,`,
19053
+ ` input: payload,`,
19054
+ ` ...(input.description ? { description: input.description } : {}),`,
19055
+ ` ...(input.force ? { force: true } : {}),`,
19056
+ ` });`,
19057
+ ` __dlAssertSuccessfulToolResult(result);`,
19105
19058
  ` return __dlExtract(input.alias, result, input.row, input.extract, Boolean(input.legacyEnvelope));`,
19106
19059
  `}`
19107
19060
  ].join("\n");
@@ -23769,9 +23722,17 @@ function monitorsErrorExitCode(error) {
23769
23722
  return 5;
23770
23723
  }
23771
23724
  function monitorsFailureNextCommand(error, exitCode) {
23725
+ if (error instanceof DeeplineError) {
23726
+ const response = asRecord(asRecord(error.details)?.response);
23727
+ const serverNextAction = asString(response?.next_action);
23728
+ if (serverNextAction) return serverNextAction;
23729
+ }
23772
23730
  if (error instanceof DeeplineError && error.code === "monitor_access_required") {
23773
23731
  return "deepline monitors status";
23774
23732
  }
23733
+ if (error instanceof DeeplineError && error.code === "monitor_tool_not_found") {
23734
+ return "deepline monitors available --json";
23735
+ }
23775
23736
  if (exitCode === 3) return "deepline auth status --json";
23776
23737
  if (exitCode === 4) return "deepline monitors list --status all --json";
23777
23738
  return void 0;
@@ -23886,6 +23847,16 @@ function asString(value) {
23886
23847
  function asFiniteNumber(value) {
23887
23848
  return typeof value === "number" && Number.isFinite(value) ? value : void 0;
23888
23849
  }
23850
+ function monitorPricingLine(rawPricing) {
23851
+ const pricing = asRecord(rawPricing);
23852
+ if (!pricing) return void 0;
23853
+ const display = asString(pricing.display);
23854
+ if (display) return display;
23855
+ const credits = asFiniteNumber(pricing.deepline_credits);
23856
+ const basis = asString(pricing.billing_basis);
23857
+ if (credits === void 0 || !basis) return void 0;
23858
+ return `${credits} Deepline credits (${basis.replaceAll("_", " ")})`;
23859
+ }
23889
23860
  function yesNo(value) {
23890
23861
  if (value === true) return "yes";
23891
23862
  if (value === false) return "no";
@@ -23925,6 +23896,7 @@ function renderMonitorDeployCompletion(payload) {
23925
23896
  const toolId = tool ?? (monitor ? asString(monitor.tool) : void 0) ?? "<tool>";
23926
23897
  const name = monitor ? asString(monitor.name) : void 0;
23927
23898
  const status = monitor ? asString(monitor.status) : void 0;
23899
+ const pricingLine = monitorPricingLine(monitor?.pricing ?? payload.pricing);
23928
23900
  const eventStreams = streams.filter((stream) => stream.isEvent);
23929
23901
  const matched = eventStreams.filter((stream) => stream.matchesPayload);
23930
23902
  const shown = matched.length ? matched : eventStreams.length ? eventStreams : streams;
@@ -23940,6 +23912,9 @@ function renderMonitorDeployCompletion(payload) {
23940
23912
  ` columns: ${stream.columns.length ? stream.columns.join(", ") : "(promoted dynamically as events arrive)"}`
23941
23913
  );
23942
23914
  }
23915
+ if (pricingLine) {
23916
+ lines.push("", `Pricing: ${pricingLine}`);
23917
+ }
23943
23918
  lines.push(
23944
23919
  "",
23945
23920
  "This monitor streams new rows into your Customer DB \u2014 there is no manual run.",
@@ -23983,6 +23958,10 @@ function renderMonitorDeployPlan(payload) {
23983
23958
  "Deploy cost: estimate unavailable from this server (validation only)."
23984
23959
  );
23985
23960
  }
23961
+ const pricingLine = monitorPricingLine(payload.pricing);
23962
+ if (pricingLine) {
23963
+ lines.push(`Selected pricing: ${pricingLine}`);
23964
+ }
23986
23965
  const candidates = Array.isArray(payload.reuse_candidates) ? payload.reuse_candidates : [];
23987
23966
  const candidateLines = candidates.flatMap((raw) => {
23988
23967
  const candidate = asRecord(raw);
@@ -24218,13 +24197,63 @@ async function handleMonitorsDeploy(definition, options) {
24218
24197
  text: renderMonitorDeployCompletion(payload)
24219
24198
  });
24220
24199
  }
24200
+ function renderMonitorGet(payload) {
24201
+ const key = asString(payload.key);
24202
+ const tool = asString(payload.tool);
24203
+ if (!key || !tool) return void 0;
24204
+ const status = asString(payload.status);
24205
+ const definition = asRecord(payload.definition);
24206
+ const pricingLine = monitorPricingLine(payload.pricing);
24207
+ const billing = asRecord(payload.billing);
24208
+ const nextRenewalAt = billing ? asString(billing.next_renewal_at) : void 0;
24209
+ const dependents = asRecord(payload.dependents);
24210
+ const plays = dependents && Array.isArray(dependents.plays) ? dependents.plays : [];
24211
+ const lines = [
24212
+ `Monitor: ${key}`,
24213
+ `Tool: ${tool}`,
24214
+ ...status ? [`Status: ${status}`] : [],
24215
+ ...pricingLine ? [`Pricing: ${pricingLine}`] : [],
24216
+ ...nextRenewalAt ? [`Next renewal: ${nextRenewalAt}`] : []
24217
+ ];
24218
+ if (definition) {
24219
+ lines.push("", "Current definition:", ` ${JSON.stringify(definition)}`);
24220
+ }
24221
+ lines.push("", `Dependent published plays (${plays.length}):`);
24222
+ if (plays.length === 0) {
24223
+ lines.push(" none");
24224
+ } else {
24225
+ for (const raw of plays) {
24226
+ const play = asRecord(raw);
24227
+ const name = play ? asString(play.name) : void 0;
24228
+ if (!play || !name) continue;
24229
+ const listener = asString(play.listener_key);
24230
+ const output2 = asString(play.output_key);
24231
+ lines.push(
24232
+ ` ${name}${listener ? ` (listener: ${listener})` : ""}${output2 ? ` \u2014 stream: ${output2}` : ""}`
24233
+ );
24234
+ }
24235
+ }
24236
+ if (dependents?.truncated === true) {
24237
+ lines.push(" Results are truncated; use --json for the returned detail.");
24238
+ }
24239
+ return `${lines.join("\n")}
24240
+ `;
24241
+ }
24221
24242
  async function handleMonitorsGet(key, options) {
24222
24243
  const http2 = buildHttpClient();
24223
24244
  const payload = await http2.request(
24224
24245
  `/api/v2/monitors/deployed/${encodeKey(key)}`,
24225
24246
  { method: "GET", ...FORBIDDEN_AS_API_ERROR }
24226
24247
  );
24227
- printCommandEnvelope(payload, { json: options.json });
24248
+ const dependents = await http2.request(
24249
+ `/api/v2/monitors/deployed/${encodeKey(key)}/dependents`,
24250
+ { method: "GET", ...FORBIDDEN_AS_API_ERROR }
24251
+ );
24252
+ const detail = { ...payload, dependents };
24253
+ printCommandEnvelope(detail, {
24254
+ json: options.json,
24255
+ text: renderMonitorGet(detail)
24256
+ });
24228
24257
  }
24229
24258
  async function confirmMonitorDelete(key, options) {
24230
24259
  const rl = (0, import_promises4.createInterface)({
@@ -24423,7 +24452,9 @@ Examples:
24423
24452
  "after",
24424
24453
  `
24425
24454
  Notes:
24426
- Read-only.
24455
+ Read-only. Returns the exact editable definition, selected Deepline pricing,
24456
+ billing state, output streams, and dependent published plays. Inspect this
24457
+ before proposing an update so scope and downstream effects are visible.
24427
24458
 
24428
24459
  Examples:
24429
24460
  deepline monitors get my-monitor --json
@@ -610,10 +610,10 @@ var SDK_RELEASE = {
610
610
  // 0.1.175 ships loud `deepline enrich` empty-waterfall reporting.
611
611
  // 0.1.220 deprecates SDK CLI versions below 0.1.219 and updates them
612
612
  // automatically without blocking their current command.
613
- version: "0.1.229",
613
+ version: "0.1.231",
614
614
  apiContract: "2026-06-dataset-handle-results-hard-cutover",
615
615
  supportPolicy: {
616
- latest: "0.1.229",
616
+ latest: "0.1.231",
617
617
  minimumSupported: "0.1.53",
618
618
  deprecatedBelow: "0.1.219",
619
619
  commandMinimumSupported: [
@@ -17915,8 +17915,6 @@ function renderExecuteStep(command, options = {
17915
17915
  force: true` : "";
17916
17916
  const legacyEnvelope = options.legacyEnvelope ? `,
17917
17917
  legacyEnvelope: true` : "";
17918
- const waterfallSoftFail = options.waterfallSoftFail ? `,
17919
- waterfallSoftFail: true` : "";
17920
17918
  return [
17921
17919
  `async (row, stepCtx) => {`,
17922
17920
  ...options.precheck ? [` if (${options.precheck}) return null;`] : [],
@@ -17928,7 +17926,7 @@ function renderExecuteStep(command, options = {
17928
17926
  ` extract: ${extractJs},`,
17929
17927
  ` runIf: ${runIfJs},`,
17930
17928
  ` row,`,
17931
- ` stepCtx${description}${force}${legacyEnvelope}${waterfallSoftFail}`,
17929
+ ` stepCtx${description}${force}${legacyEnvelope}`,
17932
17930
  ` });`,
17933
17931
  `}`
17934
17932
  ].join("\n");
@@ -17988,18 +17986,14 @@ function renderIdiomaticExecuteStep(command, options) {
17988
17986
  `async (row, ctx) => {`,
17989
17987
  ...options.precheck ? [` if (${options.precheck}) return null;`] : [],
17990
17988
  ...runIfLines,
17991
- ` let result: any;`,
17992
- ` try {`,
17993
- ` result = await ctx.tools.execute({`,
17994
- ` id: ${callId},`,
17995
- ` tool: ${tool},`,
17996
- ` input: ${input2} as any,`,
17997
- ` description: ${stringLiteral((command.description ?? "").trim() || `Run ${command.alias} via ${command.tool}.`)},`,
17989
+ ` const result: any = await ctx.tools.execute({`,
17990
+ ` id: ${callId},`,
17991
+ ` tool: ${tool},`,
17992
+ ` input: ${input2} as any,`,
17993
+ ` description: ${stringLiteral((command.description ?? "").trim() || `Run ${command.alias} via ${command.tool}.`)},`,
17998
17994
  ...options.force ? [` force: true,`] : [],
17999
- ` });`,
18000
- ` } catch (error) {`,
18001
- ...options.waterfallSoftFail ? [` return __dlWaterfallToolFailure(error);`] : [` throw error;`],
18002
- ` }`,
17995
+ ` });`,
17996
+ ` __dlAssertSuccessfulToolResult(result);`,
18003
17997
  ` return ${extraction};`,
18004
17998
  `}`
18005
17999
  ].join("\n");
@@ -18023,21 +18017,19 @@ function renderPlayStep(command, options) {
18023
18017
  ...runIfLines,
18024
18018
  ` const payload = __dlTemplate(${payload}, templateRow) as Record<string, unknown>;`,
18025
18019
  ` if (__dlShouldSkipBlankPlayPayload(payload)) return null;`,
18026
- ` let result: unknown;`,
18027
- ` try {`,
18020
+ ` const result: unknown = `,
18028
18021
  ...inlineHandler ? [
18029
18022
  // Enrich validates and normalizes this payload against the certified
18030
18023
  // prebuilt contract before code generation. The attachment retains
18031
18024
  // its concrete input type, while generated payloads are records.
18032
- ` result = await __dlRunInlinePlay(${inlineHandler}, stepCtx, payload as never, ${options.force});`
18025
+ ` await __dlRunInlinePlay(${inlineHandler}, stepCtx, payload as never, ${options.force});`
18033
18026
  ] : [
18034
- ` result = await stepCtx.runPlay(${callId}, ${playRef}, payload, {`,
18035
- ` description: ${stringLiteral(command.description ?? command.alias)}`,
18027
+ ` await stepCtx.runPlay(${callId}, ${playRef}, payload, {`,
18028
+ ` description: ${stringLiteral(command.description ?? command.alias)}`,
18036
18029
  ` });`
18037
18030
  ],
18038
- ` } catch (error) {`,
18039
- ...options.waterfallSoftFail ? [` return __dlWaterfallToolFailure(error);`] : [` throw error;`],
18040
- ` }`,
18031
+ ``,
18032
+ ` __dlAssertSuccessfulToolResult(result);`,
18041
18033
  ` return __dlPlayResultValue(${alias}, result);`,
18042
18034
  `}`
18043
18035
  ].join("\n");
@@ -18071,23 +18063,17 @@ function renderInlineJavascriptStep(command, options) {
18071
18063
  `async (row) => {`,
18072
18064
  ...options.precheck ? [` if (${options.precheck}) return null;`] : [],
18073
18065
  ...runIfLines,
18074
- ...options.waterfallSoftFail ? [` try {`] : [],
18075
- `${options.waterfallSoftFail ? " " : " "}const __dlPayload = __dlRuntimePayload('run_javascript', __dlTemplate(${payload}, row as Record<string, unknown>) as Record<string, unknown>, row as Record<string, unknown>);`,
18076
- `${options.waterfallSoftFail ? " " : " "}const rawResult = ((row: Record<string, any>, input: Record<string, any>, context: Record<string, any>) => {`,
18077
- `${options.waterfallSoftFail ? " " : " "} const payload = __dlPayload as Record<string, any>;`,
18078
- `${options.waterfallSoftFail ? " " : " "} const extract = __dlInlineExtract;`,
18079
- `${options.waterfallSoftFail ? " " : " "} const extractList = __dlInlineExtractList;`,
18080
- `${options.waterfallSoftFail ? " " : " "} return (() => {`,
18066
+ ` const __dlPayload = __dlRuntimePayload('run_javascript', __dlTemplate(${payload}, row as Record<string, unknown>) as Record<string, unknown>, row as Record<string, unknown>);`,
18067
+ ` const rawResult = ((row: Record<string, any>, input: Record<string, any>, context: Record<string, any>) => {`,
18068
+ ` const payload = __dlPayload as Record<string, any>;`,
18069
+ ` const extract = __dlInlineExtract;`,
18070
+ ` const extractList = __dlInlineExtractList;`,
18071
+ ` return (() => {`,
18081
18072
  indent(renderJavascriptBody(code), 4),
18082
- `${options.waterfallSoftFail ? " " : " "} })();`,
18083
- `${options.waterfallSoftFail ? " " : " "}})(row as Record<string, any>, row as Record<string, any>, row as Record<string, any>);`,
18084
- `${options.waterfallSoftFail ? " " : " "}const result = await Promise.resolve(rawResult);`,
18085
- `${options.waterfallSoftFail ? " " : " "}return ${resultExpression};`,
18086
- ...options.waterfallSoftFail ? [
18087
- ` } catch (error) {`,
18088
- ` return __dlExtractorFailure(error);`,
18089
- ` }`
18090
- ] : [],
18073
+ ` })();`,
18074
+ ` })(row as Record<string, any>, row as Record<string, any>, row as Record<string, any>);`,
18075
+ ` const result = await Promise.resolve(rawResult);`,
18076
+ ` return ${resultExpression};`,
18091
18077
  `}`
18092
18078
  ].join("\n");
18093
18079
  }
@@ -18221,7 +18207,6 @@ function renderWaterfallColumns(command, forceAliases, inlineRunJavascript, idio
18221
18207
  legacyEnvelope: Boolean(nested.extract_js),
18222
18208
  inlineRunJavascript,
18223
18209
  idiomaticGetters,
18224
- waterfallSoftFail: true,
18225
18210
  nativeRunIf: Boolean(runIfSource)
18226
18211
  }),
18227
18212
  {
@@ -18555,6 +18540,14 @@ function helperSource() {
18555
18540
  ` return status === 'error' || status === 'failed' || (typeof record.error === 'string' && record.error.trim() !== '') || (typeof resultError === 'string' && resultError.trim() !== '');`,
18556
18541
  `}`,
18557
18542
  ``,
18543
+ `function __dlAssertSuccessfulToolResult(value: unknown): void {`,
18544
+ ` if (!__dlErrorPayload(value)) return;`,
18545
+ ` const record = value as Record<string, unknown>;`,
18546
+ ` const result = record.result && typeof record.result === 'object' && !Array.isArray(record.result) ? record.result as Record<string, unknown> : null;`,
18547
+ ` const message = typeof record.error === 'string' ? record.error : typeof result?.error === 'string' ? result.error : typeof result?.message === 'string' ? result.message : 'Tool returned an error-shaped result.';`,
18548
+ ` throw new Error(message);`,
18549
+ `}`,
18550
+ ``,
18558
18551
  `function __dlGeneratedCellError(value: unknown): boolean {`,
18559
18552
  ` if (typeof value === 'string') {`,
18560
18553
  ` const lower = value.trim().toLowerCase();`,
@@ -18945,37 +18938,6 @@ function helperSource() {
18945
18938
  ` return keys ? __dlProjectListRows(rows, keys, payload) : rows;`,
18946
18939
  `}`,
18947
18940
  ``,
18948
- `function __dlErrorMessage(error: unknown): string {`,
18949
- ` if (error instanceof Error && error.message) return error.message;`,
18950
- ` if (typeof error === 'string' && error.trim()) return error.trim();`,
18951
- ` return 'Extractor failed';`,
18952
- `}`,
18953
- ``,
18954
- `function __dlErrorDetail(error: unknown): string {`,
18955
- ` const message = __dlErrorMessage(error);`,
18956
- ` if (!__dlRecord(error)) return message;`,
18957
- ` try {`,
18958
- ` return message + ' ' + JSON.stringify(error);`,
18959
- ` } catch {`,
18960
- ` return message;`,
18961
- ` }`,
18962
- `}`,
18963
- ``,
18964
- `function __dlRecoverableWaterfallToolError(error: unknown): boolean {`,
18965
- ` const detail = __dlErrorDetail(error).toLowerCase();`,
18966
- ` return /\\b5\\d\\d\\b/.test(detail) || detail.includes('upstream_failure') || detail.includes('"error_category":"upstream"') || (detail.includes('"failure_origin":"provider"') && detail.includes('"status":5')) || detail.includes('bad gateway') || detail.includes('gateway time-out') || detail.includes('gateway timeout') || detail.includes('service unavailable');`,
18967
- `}`,
18968
- ``,
18969
- `function __dlWaterfallToolFailure(error: unknown, tool?: string): unknown {`,
18970
- ` if (tool === 'run_javascript' || __dlRecoverableWaterfallToolError(error)) return __dlExtractorFailure(error);`,
18971
- ` throw error;`,
18972
- `}`,
18973
- ``,
18974
- `function __dlExtractorFailure(error: unknown): unknown {`,
18975
- ` const message = __dlErrorMessage(error);`,
18976
- ` return { matched_result: null, result: { error: message, message } };`,
18977
- `}`,
18978
- ``,
18979
18941
  `function __dlExtract(alias: string, result: unknown, row: Record<string, unknown>, extractor: ((args: __DlExtractorHelpers) => unknown) | null, legacyEnvelope = false): unknown {`,
18980
18942
  ` const raw = __dlRawToolOutput(result);`,
18981
18943
  ` if (!extractor) return raw;`,
@@ -19016,12 +18978,8 @@ function helperSource() {
19016
18978
  ` };`,
19017
18979
  ` const get = (path: string): unknown => __dlExtractedValue(result, path) ?? __dlFirstByPaths(raw, path);`,
19018
18980
  ` let resolved: unknown;`,
19019
- ` try {`,
19020
- ` const extracted = extractor({ row, result, data: raw, raw, pick, extract, extractList, target: pick, get });`,
19021
- ` resolved = typeof extracted === 'function' ? (extracted as (outputData: unknown) => unknown)(__dlLegacyOutputData(result, raw)) : extracted;`,
19022
- ` } catch (error) {`,
19023
- ` return __dlExtractorFailure(error);`,
19024
- ` }`,
18981
+ ` const extracted = extractor({ row, result, data: raw, raw, pick, extract, extractList, target: pick, get });`,
18982
+ ` resolved = typeof extracted === 'function' ? (extracted as (outputData: unknown) => unknown)(__dlLegacyOutputData(result, raw)) : extracted;`,
19025
18983
  ` if (resolved && typeof resolved === 'object' && !Array.isArray(resolved) && alias in (resolved as Record<string, unknown>)) {`,
19026
18984
  ` const aliasValue = (resolved as Record<string, unknown>)[alias];`,
19027
18985
  ` return legacyEnvelope && __dlMeaningful(aliasValue) ? __dlLegacyMatchedEnvelope(aliasValue, raw) : aliasValue;`,
@@ -19111,26 +19069,21 @@ function helperSource() {
19111
19069
  ` return result;`,
19112
19070
  `}`,
19113
19071
  ``,
19114
- `async function __dlRunCommand(input: { alias: string; callId: string; tool: string; payload: Record<string, unknown>; extract: ((args: __DlExtractorHelpers) => unknown) | null; runIf: ((row: Record<string, unknown>) => unknown) | null; row: Record<string, unknown>; stepCtx: { tools: { execute: (request: Record<string, unknown>) => Promise<unknown> } }; description?: string; force?: boolean; legacyEnvelope?: boolean; waterfallSoftFail?: boolean }): Promise<unknown> {`,
19072
+ `async function __dlRunCommand(input: { alias: string; callId: string; tool: string; payload: Record<string, unknown>; extract: ((args: __DlExtractorHelpers) => unknown) | null; runIf: ((row: Record<string, unknown>) => unknown) | null; row: Record<string, unknown>; stepCtx: { tools: { execute: (request: Record<string, unknown>) => Promise<unknown> } }; description?: string; force?: boolean; legacyEnvelope?: boolean }): Promise<unknown> {`,
19115
19073
  ` if (input.runIf) {`,
19116
19074
  ` const shouldRun = input.runIf(input.row);`,
19117
19075
  ` if (!shouldRun) return null;`,
19118
19076
  ` }`,
19119
19077
  ` const payload = __dlRuntimePayload(input.tool, __dlTemplate(input.payload, input.row) as Record<string, unknown>, input.row);`,
19120
19078
  ` if (__dlShouldSkipEmptyPayload(input.tool, payload)) return null;`,
19121
- ` let result: unknown;`,
19122
- ` try {`,
19123
- ` result = await input.stepCtx.tools.execute({`,
19124
- ` id: input.callId,`,
19125
- ` tool: input.tool,`,
19126
- ` input: payload,`,
19127
- ` ...(input.description ? { description: input.description } : {}),`,
19128
- ` ...(input.force ? { force: true } : {}),`,
19129
- ` });`,
19130
- ` } catch (error) {`,
19131
- ` if (input.waterfallSoftFail) return __dlWaterfallToolFailure(error, input.tool);`,
19132
- ` throw error;`,
19133
- ` }`,
19079
+ ` const result = await input.stepCtx.tools.execute({`,
19080
+ ` id: input.callId,`,
19081
+ ` tool: input.tool,`,
19082
+ ` input: payload,`,
19083
+ ` ...(input.description ? { description: input.description } : {}),`,
19084
+ ` ...(input.force ? { force: true } : {}),`,
19085
+ ` });`,
19086
+ ` __dlAssertSuccessfulToolResult(result);`,
19134
19087
  ` return __dlExtract(input.alias, result, input.row, input.extract, Boolean(input.legacyEnvelope));`,
19135
19088
  `}`
19136
19089
  ].join("\n");
@@ -23805,9 +23758,17 @@ function monitorsErrorExitCode(error) {
23805
23758
  return 5;
23806
23759
  }
23807
23760
  function monitorsFailureNextCommand(error, exitCode) {
23761
+ if (error instanceof DeeplineError) {
23762
+ const response = asRecord(asRecord(error.details)?.response);
23763
+ const serverNextAction = asString(response?.next_action);
23764
+ if (serverNextAction) return serverNextAction;
23765
+ }
23808
23766
  if (error instanceof DeeplineError && error.code === "monitor_access_required") {
23809
23767
  return "deepline monitors status";
23810
23768
  }
23769
+ if (error instanceof DeeplineError && error.code === "monitor_tool_not_found") {
23770
+ return "deepline monitors available --json";
23771
+ }
23811
23772
  if (exitCode === 3) return "deepline auth status --json";
23812
23773
  if (exitCode === 4) return "deepline monitors list --status all --json";
23813
23774
  return void 0;
@@ -23922,6 +23883,16 @@ function asString(value) {
23922
23883
  function asFiniteNumber(value) {
23923
23884
  return typeof value === "number" && Number.isFinite(value) ? value : void 0;
23924
23885
  }
23886
+ function monitorPricingLine(rawPricing) {
23887
+ const pricing = asRecord(rawPricing);
23888
+ if (!pricing) return void 0;
23889
+ const display = asString(pricing.display);
23890
+ if (display) return display;
23891
+ const credits = asFiniteNumber(pricing.deepline_credits);
23892
+ const basis = asString(pricing.billing_basis);
23893
+ if (credits === void 0 || !basis) return void 0;
23894
+ return `${credits} Deepline credits (${basis.replaceAll("_", " ")})`;
23895
+ }
23925
23896
  function yesNo(value) {
23926
23897
  if (value === true) return "yes";
23927
23898
  if (value === false) return "no";
@@ -23961,6 +23932,7 @@ function renderMonitorDeployCompletion(payload) {
23961
23932
  const toolId = tool ?? (monitor ? asString(monitor.tool) : void 0) ?? "<tool>";
23962
23933
  const name = monitor ? asString(monitor.name) : void 0;
23963
23934
  const status = monitor ? asString(monitor.status) : void 0;
23935
+ const pricingLine = monitorPricingLine(monitor?.pricing ?? payload.pricing);
23964
23936
  const eventStreams = streams.filter((stream) => stream.isEvent);
23965
23937
  const matched = eventStreams.filter((stream) => stream.matchesPayload);
23966
23938
  const shown = matched.length ? matched : eventStreams.length ? eventStreams : streams;
@@ -23976,6 +23948,9 @@ function renderMonitorDeployCompletion(payload) {
23976
23948
  ` columns: ${stream.columns.length ? stream.columns.join(", ") : "(promoted dynamically as events arrive)"}`
23977
23949
  );
23978
23950
  }
23951
+ if (pricingLine) {
23952
+ lines.push("", `Pricing: ${pricingLine}`);
23953
+ }
23979
23954
  lines.push(
23980
23955
  "",
23981
23956
  "This monitor streams new rows into your Customer DB \u2014 there is no manual run.",
@@ -24019,6 +23994,10 @@ function renderMonitorDeployPlan(payload) {
24019
23994
  "Deploy cost: estimate unavailable from this server (validation only)."
24020
23995
  );
24021
23996
  }
23997
+ const pricingLine = monitorPricingLine(payload.pricing);
23998
+ if (pricingLine) {
23999
+ lines.push(`Selected pricing: ${pricingLine}`);
24000
+ }
24022
24001
  const candidates = Array.isArray(payload.reuse_candidates) ? payload.reuse_candidates : [];
24023
24002
  const candidateLines = candidates.flatMap((raw) => {
24024
24003
  const candidate = asRecord(raw);
@@ -24254,13 +24233,63 @@ async function handleMonitorsDeploy(definition, options) {
24254
24233
  text: renderMonitorDeployCompletion(payload)
24255
24234
  });
24256
24235
  }
24236
+ function renderMonitorGet(payload) {
24237
+ const key = asString(payload.key);
24238
+ const tool = asString(payload.tool);
24239
+ if (!key || !tool) return void 0;
24240
+ const status = asString(payload.status);
24241
+ const definition = asRecord(payload.definition);
24242
+ const pricingLine = monitorPricingLine(payload.pricing);
24243
+ const billing = asRecord(payload.billing);
24244
+ const nextRenewalAt = billing ? asString(billing.next_renewal_at) : void 0;
24245
+ const dependents = asRecord(payload.dependents);
24246
+ const plays = dependents && Array.isArray(dependents.plays) ? dependents.plays : [];
24247
+ const lines = [
24248
+ `Monitor: ${key}`,
24249
+ `Tool: ${tool}`,
24250
+ ...status ? [`Status: ${status}`] : [],
24251
+ ...pricingLine ? [`Pricing: ${pricingLine}`] : [],
24252
+ ...nextRenewalAt ? [`Next renewal: ${nextRenewalAt}`] : []
24253
+ ];
24254
+ if (definition) {
24255
+ lines.push("", "Current definition:", ` ${JSON.stringify(definition)}`);
24256
+ }
24257
+ lines.push("", `Dependent published plays (${plays.length}):`);
24258
+ if (plays.length === 0) {
24259
+ lines.push(" none");
24260
+ } else {
24261
+ for (const raw of plays) {
24262
+ const play = asRecord(raw);
24263
+ const name = play ? asString(play.name) : void 0;
24264
+ if (!play || !name) continue;
24265
+ const listener = asString(play.listener_key);
24266
+ const output2 = asString(play.output_key);
24267
+ lines.push(
24268
+ ` ${name}${listener ? ` (listener: ${listener})` : ""}${output2 ? ` \u2014 stream: ${output2}` : ""}`
24269
+ );
24270
+ }
24271
+ }
24272
+ if (dependents?.truncated === true) {
24273
+ lines.push(" Results are truncated; use --json for the returned detail.");
24274
+ }
24275
+ return `${lines.join("\n")}
24276
+ `;
24277
+ }
24257
24278
  async function handleMonitorsGet(key, options) {
24258
24279
  const http2 = buildHttpClient();
24259
24280
  const payload = await http2.request(
24260
24281
  `/api/v2/monitors/deployed/${encodeKey(key)}`,
24261
24282
  { method: "GET", ...FORBIDDEN_AS_API_ERROR }
24262
24283
  );
24263
- printCommandEnvelope(payload, { json: options.json });
24284
+ const dependents = await http2.request(
24285
+ `/api/v2/monitors/deployed/${encodeKey(key)}/dependents`,
24286
+ { method: "GET", ...FORBIDDEN_AS_API_ERROR }
24287
+ );
24288
+ const detail = { ...payload, dependents };
24289
+ printCommandEnvelope(detail, {
24290
+ json: options.json,
24291
+ text: renderMonitorGet(detail)
24292
+ });
24264
24293
  }
24265
24294
  async function confirmMonitorDelete(key, options) {
24266
24295
  const rl = createInterface({
@@ -24459,7 +24488,9 @@ Examples:
24459
24488
  "after",
24460
24489
  `
24461
24490
  Notes:
24462
- Read-only.
24491
+ Read-only. Returns the exact editable definition, selected Deepline pricing,
24492
+ billing state, output streams, and dependent published plays. Inspect this
24493
+ before proposing an update so scope and downstream effects are visible.
24463
24494
 
24464
24495
  Examples:
24465
24496
  deepline monitors get my-monitor --json
package/dist/index.js CHANGED
@@ -424,10 +424,10 @@ var SDK_RELEASE = {
424
424
  // 0.1.175 ships loud `deepline enrich` empty-waterfall reporting.
425
425
  // 0.1.220 deprecates SDK CLI versions below 0.1.219 and updates them
426
426
  // automatically without blocking their current command.
427
- version: "0.1.229",
427
+ version: "0.1.231",
428
428
  apiContract: "2026-06-dataset-handle-results-hard-cutover",
429
429
  supportPolicy: {
430
- latest: "0.1.229",
430
+ latest: "0.1.231",
431
431
  minimumSupported: "0.1.53",
432
432
  deprecatedBelow: "0.1.219",
433
433
  commandMinimumSupported: [
package/dist/index.mjs CHANGED
@@ -354,10 +354,10 @@ var SDK_RELEASE = {
354
354
  // 0.1.175 ships loud `deepline enrich` empty-waterfall reporting.
355
355
  // 0.1.220 deprecates SDK CLI versions below 0.1.219 and updates them
356
356
  // automatically without blocking their current command.
357
- version: "0.1.229",
357
+ version: "0.1.231",
358
358
  apiContract: "2026-06-dataset-handle-results-hard-cutover",
359
359
  supportPolicy: {
360
- latest: "0.1.229",
360
+ latest: "0.1.231",
361
361
  minimumSupported: "0.1.53",
362
362
  deprecatedBelow: "0.1.219",
363
363
  commandMinimumSupported: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepline",
3
- "version": "0.1.229",
3
+ "version": "0.1.231",
4
4
  "description": "Deepline SDK + CLI — B2B data enrichment powered by durable cloud execution",
5
5
  "license": "MIT",
6
6
  "repository": {