deepline 0.3.34 → 0.3.35

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.
@@ -199,7 +199,7 @@ export const SDK_RELEASE = {
199
199
  // available at toolResponse.rawV2 while toolResponse.raw and all declared
200
200
  // getters keep their established compatibility behavior.
201
201
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
202
- version: '0.3.34',
202
+ version: '0.3.35',
203
203
  updateSummary:
204
204
  'Automatic CLI updates are now enabled by default. To opt out, run `deepline settings autoupdate off`; use `deepline settings autoupdate on` to re-enable updates or `deepline settings autoupdate pin <version>` to hold an exact release. This release also adds raw-v2 tool responses at toolResponse.rawV2 while preserving existing toolResponse.raw and declared getters.',
205
205
  packageCapabilities: {
@@ -1,3 +1,8 @@
1
+ import type {
2
+ ToolExecutionErrorCategory,
3
+ ToolExecutionErrorOrigin,
4
+ } from '../tool-execution-error';
5
+
1
6
  /**
2
7
  * The durable terminal envelope carries the complete 5 MiB authored return
3
8
  * plus bounded scheduler-owned metadata (progress, warnings, and a log tail).
@@ -301,6 +306,14 @@ const LEDGER_STRIPPED_TERMINAL_RESULT_KEYS = [
301
306
  'suspension',
302
307
  ] as const;
303
308
 
309
+ export type LedgerTerminalFailureSummary = {
310
+ code: string;
311
+ phase: string;
312
+ retryable: boolean | null;
313
+ origin?: ToolExecutionErrorOrigin;
314
+ category?: ToolExecutionErrorCategory;
315
+ };
316
+
304
317
  /** A tiny reference descriptor left in place of a dropped over-limit result. */
305
318
  export type LedgerTerminalResultRef = {
306
319
  __kind: 'deepline.ledger_terminal_result_ref.v1';
@@ -323,6 +336,8 @@ export type LedgerTerminalResultRef = {
323
336
  * fetching the complete scheduler result.
324
337
  */
325
338
  preview?: BoundedRunListOutputPreview;
339
+ /** Failure ownership retained when the full failed result is out of line. */
340
+ failure?: LedgerTerminalFailureSummary;
326
341
  };
327
342
 
328
343
  export const LEDGER_TERMINAL_RESULT_STORED_WARNING =
@@ -682,6 +697,7 @@ function ledgerTerminalResultRef(
682
697
  content?: 'full';
683
698
  bytes?: number;
684
699
  preview?: BoundedRunListOutputPreview;
700
+ failure?: LedgerTerminalFailureSummary;
685
701
  } = {},
686
702
  ): LedgerTerminalResultRef {
687
703
  return {
@@ -693,12 +709,83 @@ function ledgerTerminalResultRef(
693
709
  projection: 'out_of_line',
694
710
  ...(options.content ? { content: options.content } : {}),
695
711
  ...(options.preview ? { preview: options.preview } : {}),
712
+ ...(options.failure ? { failure: options.failure } : {}),
696
713
  warning: options.content
697
714
  ? LEDGER_TERMINAL_RESULT_STORED_WARNING
698
715
  : LEDGER_TERMINAL_RESULT_OMITTED_WARNING,
699
716
  };
700
717
  }
701
718
 
719
+ const TOOL_ERROR_ORIGINS = new Set<ToolExecutionErrorOrigin>([
720
+ 'caller',
721
+ 'provider',
722
+ 'deepline',
723
+ 'unknown',
724
+ ]);
725
+
726
+ const TOOL_ERROR_CATEGORIES = new Set<ToolExecutionErrorCategory>([
727
+ 'validation',
728
+ 'authentication',
729
+ 'authorization',
730
+ 'rate_limit',
731
+ 'network',
732
+ 'upstream',
733
+ 'billing',
734
+ 'conflict',
735
+ 'internal',
736
+ 'unknown',
737
+ ]);
738
+
739
+ const LEDGER_FAILURE_CODE_MAX_LENGTH = 160;
740
+ const LEDGER_FAILURE_PHASE_MAX_LENGTH = 80;
741
+
742
+ function terminalFailureSummary(
743
+ value: unknown,
744
+ ): LedgerTerminalFailureSummary | undefined {
745
+ if (!isPlainObject(value) || !Array.isArray(value.errors)) return undefined;
746
+ const first = value.errors.find(isPlainObject);
747
+ if (!first) return undefined;
748
+ const rawRetryable = first.retryable;
749
+ let retryable: boolean | null;
750
+ if (typeof rawRetryable === 'boolean') {
751
+ retryable = rawRetryable;
752
+ } else if (rawRetryable === null) {
753
+ retryable = null;
754
+ } else {
755
+ return undefined;
756
+ }
757
+ if (typeof first.code !== 'string' || typeof first.phase !== 'string') {
758
+ return undefined;
759
+ }
760
+ const code = first.code.trim();
761
+ const phase = first.phase.trim();
762
+ if (
763
+ !code ||
764
+ code.length > LEDGER_FAILURE_CODE_MAX_LENGTH ||
765
+ !phase ||
766
+ phase.length > LEDGER_FAILURE_PHASE_MAX_LENGTH
767
+ ) {
768
+ return undefined;
769
+ }
770
+ const origin = TOOL_ERROR_ORIGINS.has(
771
+ first.origin as ToolExecutionErrorOrigin,
772
+ )
773
+ ? (first.origin as ToolExecutionErrorOrigin)
774
+ : undefined;
775
+ const category = TOOL_ERROR_CATEGORIES.has(
776
+ first.category as ToolExecutionErrorCategory,
777
+ )
778
+ ? (first.category as ToolExecutionErrorCategory)
779
+ : undefined;
780
+ return {
781
+ code,
782
+ phase,
783
+ retryable,
784
+ ...(origin ? { origin } : {}),
785
+ ...(category ? { category } : {}),
786
+ };
787
+ }
788
+
702
789
  export function ledgerTerminalResultRefForValue(
703
790
  value: unknown,
704
791
  reason: LedgerTerminalResultRefReason,
@@ -721,7 +808,12 @@ export function ledgerTerminalResultRefForValue(
721
808
  // persistence failure.
722
809
  }
723
810
  }
724
- return ledgerTerminalResultRef(reason, { ...options, bytes, preview });
811
+ return ledgerTerminalResultRef(reason, {
812
+ ...options,
813
+ bytes,
814
+ preview,
815
+ failure: terminalFailureSummary(value),
816
+ });
725
817
  }
726
818
 
727
819
  /** Optional derived summaries must never block the terminal lifecycle event. */
@@ -1,4 +1,8 @@
1
- import { ToolExecutionError } from '../tool-execution-error';
1
+ import {
2
+ ToolExecutionError,
3
+ type ToolExecutionErrorCategory,
4
+ type ToolExecutionErrorOrigin,
5
+ } from '../tool-execution-error';
2
6
 
3
7
  const CLOUDFLARE_DURABLE_OBJECT_RESET_RE =
4
8
  /Durable Object.*(?:code (?:was|has been) updated|storage caused object)/;
@@ -186,6 +190,10 @@ export type PlayRunFailureDetails = {
186
190
  phase: string;
187
191
  message: string;
188
192
  retryable: boolean | null;
193
+ /** Original ownership boundary when the failure came from a typed tool call. */
194
+ origin?: ToolExecutionErrorOrigin;
195
+ /** Original reason family when the failure came from a typed tool call. */
196
+ category?: ToolExecutionErrorCategory;
189
197
  cause?: string;
190
198
  name?: string;
191
199
  stack?: string;
@@ -305,6 +313,8 @@ export function normalizePlayRunFailure(error: unknown): PlayRunFailureDetails {
305
313
  phase: 'billing',
306
314
  message: cause,
307
315
  retryable: false,
316
+ origin: error.origin,
317
+ category: error.category,
308
318
  cause,
309
319
  };
310
320
  }
@@ -534,7 +544,10 @@ export function normalizePlayRunFailure(error: unknown): PlayRunFailureDetails {
534
544
  code: 'RUN_FAILED',
535
545
  phase: 'runtime',
536
546
  message: cause,
537
- retryable: null,
547
+ retryable: error instanceof ToolExecutionError ? error.retryable : null,
548
+ ...(error instanceof ToolExecutionError
549
+ ? { origin: error.origin, category: error.category }
550
+ : {}),
538
551
  ...(diagnostics
539
552
  ? {
540
553
  name: diagnostics.name,
package/dist/cli/index.js CHANGED
@@ -1043,7 +1043,7 @@ var SDK_RELEASE = {
1043
1043
  // available at toolResponse.rawV2 while toolResponse.raw and all declared
1044
1044
  // getters keep their established compatibility behavior.
1045
1045
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
1046
- version: "0.3.34",
1046
+ version: "0.3.35",
1047
1047
  updateSummary: "Automatic CLI updates are now enabled by default. To opt out, run `deepline settings autoupdate off`; use `deepline settings autoupdate on` to re-enable updates or `deepline settings autoupdate pin <version>` to hold an exact release. This release also adds raw-v2 tool responses at toolResponse.rawV2 while preserving existing toolResponse.raw and declared getters.",
1048
1048
  packageCapabilities: {
1049
1049
  updatePreferences: 1
@@ -1029,7 +1029,7 @@ var SDK_RELEASE = {
1029
1029
  // available at toolResponse.rawV2 while toolResponse.raw and all declared
1030
1030
  // getters keep their established compatibility behavior.
1031
1031
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
1032
- version: "0.3.34",
1032
+ version: "0.3.35",
1033
1033
  updateSummary: "Automatic CLI updates are now enabled by default. To opt out, run `deepline settings autoupdate off`; use `deepline settings autoupdate on` to re-enable updates or `deepline settings autoupdate pin <version>` to hold an exact release. This release also adds raw-v2 tool responses at toolResponse.rawV2 while preserving existing toolResponse.raw and declared getters.",
1034
1034
  packageCapabilities: {
1035
1035
  updatePreferences: 1
package/dist/index.js CHANGED
@@ -779,7 +779,7 @@ var SDK_RELEASE = {
779
779
  // available at toolResponse.rawV2 while toolResponse.raw and all declared
780
780
  // getters keep their established compatibility behavior.
781
781
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
782
- version: "0.3.34",
782
+ version: "0.3.35",
783
783
  updateSummary: "Automatic CLI updates are now enabled by default. To opt out, run `deepline settings autoupdate off`; use `deepline settings autoupdate on` to re-enable updates or `deepline settings autoupdate pin <version>` to hold an exact release. This release also adds raw-v2 tool responses at toolResponse.rawV2 while preserving existing toolResponse.raw and declared getters.",
784
784
  packageCapabilities: {
785
785
  updatePreferences: 1
package/dist/index.mjs CHANGED
@@ -702,7 +702,7 @@ var SDK_RELEASE = {
702
702
  // available at toolResponse.rawV2 while toolResponse.raw and all declared
703
703
  // getters keep their established compatibility behavior.
704
704
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
705
- version: "0.3.34",
705
+ version: "0.3.35",
706
706
  updateSummary: "Automatic CLI updates are now enabled by default. To opt out, run `deepline settings autoupdate off`; use `deepline settings autoupdate on` to re-enable updates or `deepline settings autoupdate pin <version>` to hold an exact release. This release also adds raw-v2 tool responses at toolResponse.rawV2 while preserving existing toolResponse.raw and declared getters.",
707
707
  packageCapabilities: {
708
708
  updatePreferences: 1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepline",
3
- "version": "0.3.34",
3
+ "version": "0.3.35",
4
4
  "description": "GTM data CLI and TypeScript SDK for coding agents",
5
5
  "license": "MIT",
6
6
  "homepage": "https://code.deepline.com",