deepline 0.3.293 → 0.3.295

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.
Files changed (138) hide show
  1. package/dist/bundling-sources/sdk/src/compat.ts +35 -7
  2. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  3. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-pool.ts +269 -267
  4. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +3 -4
  5. package/dist/bundling-sources/shared_libs/play-runtime/tool-http-errors.ts +14 -1
  6. package/dist/cli/auth-EDTRERZP.mjs +31 -0
  7. package/dist/cli/auth-TDHKB277.js +31 -0
  8. package/dist/cli/billing-ELIDPILY.js +1749 -0
  9. package/dist/cli/billing-EXGXJVAU.mjs +1749 -0
  10. package/dist/cli/chunk-2S5Y3TZP.js +5688 -0
  11. package/dist/cli/chunk-3KC45UVF.js +150 -0
  12. package/dist/cli/chunk-3XX5TEA4.js +15 -0
  13. package/dist/cli/chunk-4MBOJQPL.mjs +0 -0
  14. package/dist/cli/chunk-4NEFYBF7.js +2240 -0
  15. package/dist/cli/chunk-5JLQPVNX.js +3056 -0
  16. package/dist/cli/chunk-5KDKFHZI.js +1269 -0
  17. package/dist/cli/chunk-6A3TJUWC.js +76 -0
  18. package/dist/cli/chunk-6O5YZOVN.mjs +890 -0
  19. package/dist/cli/chunk-7P5AA3SN.js +344 -0
  20. package/dist/cli/chunk-AYHLUHE5.js +52 -0
  21. package/dist/cli/chunk-CBVIJSHF.mjs +560 -0
  22. package/dist/cli/chunk-CFVVCN4A.js +735 -0
  23. package/dist/cli/chunk-COGTRVWW.js +30 -0
  24. package/dist/cli/chunk-D4AZUZO4.js +190 -0
  25. package/dist/cli/chunk-DLIRSHV6.mjs +28 -0
  26. package/dist/cli/chunk-EACVZI6N.mjs +1995 -0
  27. package/dist/cli/chunk-EDWJY6T4.mjs +3056 -0
  28. package/dist/cli/chunk-EXMLR72R.mjs +0 -0
  29. package/dist/cli/chunk-F35VOIQL.js +890 -0
  30. package/dist/cli/chunk-GAMFK2ZP.mjs +148 -0
  31. package/dist/cli/chunk-GHRQQPW2.mjs +2240 -0
  32. package/dist/cli/chunk-GONRLVV3.js +3440 -0
  33. package/dist/cli/chunk-GVUJJJ5G.mjs +76 -0
  34. package/dist/cli/chunk-H7HIDGZ7.mjs +150 -0
  35. package/dist/cli/chunk-HUZXWOSK.mjs +503 -0
  36. package/dist/cli/chunk-I5YZLGMG.js +1 -0
  37. package/dist/cli/chunk-ITOFSXIU.mjs +15 -0
  38. package/dist/cli/chunk-J5NA2TTX.js +503 -0
  39. package/dist/cli/chunk-JCS5TPNY.mjs +3440 -0
  40. package/dist/cli/chunk-JNNOCMQY.js +47 -0
  41. package/dist/cli/chunk-KRD6H754.mjs +30 -0
  42. package/dist/cli/chunk-LA46MMTL.js +560 -0
  43. package/dist/cli/chunk-LDWT7RJK.mjs +190 -0
  44. package/dist/cli/chunk-M2V26OR5.js +499 -0
  45. package/dist/cli/chunk-MIMASXO4.mjs +389 -0
  46. package/dist/cli/chunk-MROPCKW2.mjs +190 -0
  47. package/dist/cli/chunk-NXDRDJ4K.js +389 -0
  48. package/dist/cli/chunk-NXGCO4JB.mjs +344 -0
  49. package/dist/cli/chunk-OG64RBAC.js +6 -0
  50. package/dist/cli/chunk-OQYEC4GL.mjs +34 -0
  51. package/dist/cli/chunk-OWJZUE3Y.mjs +103 -0
  52. package/dist/cli/chunk-SDK3ZA2C.js +103 -0
  53. package/dist/cli/chunk-SFLARO4Y.mjs +47 -0
  54. package/dist/cli/chunk-SVIIIYIQ.js +923 -0
  55. package/dist/cli/chunk-TAC3JIFE.mjs +354 -0
  56. package/dist/cli/chunk-U3PI7HBM.js +34 -0
  57. package/dist/cli/chunk-UFS752TU.mjs +52 -0
  58. package/dist/cli/chunk-UI37DQE7.mjs +499 -0
  59. package/dist/cli/chunk-UNEMDKXN.js +1 -0
  60. package/dist/cli/chunk-WB6Z2Q44.mjs +1622 -0
  61. package/dist/cli/chunk-WJYPBHTE.js +148 -0
  62. package/dist/cli/chunk-WOHBA5PV.js +354 -0
  63. package/dist/cli/chunk-WQICC2B3.js +190 -0
  64. package/dist/cli/chunk-WZYKRD7T.mjs +6 -0
  65. package/dist/cli/chunk-XL2FO6CW.mjs +5688 -0
  66. package/dist/cli/chunk-XNYIZMNQ.js +28 -0
  67. package/dist/cli/chunk-XRK2TZT5.js +1995 -0
  68. package/dist/cli/chunk-YJYPL5OK.mjs +1269 -0
  69. package/dist/cli/chunk-YWNDYCXR.mjs +735 -0
  70. package/dist/cli/chunk-YWWAF7KZ.mjs +923 -0
  71. package/dist/cli/chunk-ZDO3TO3M.js +1622 -0
  72. package/dist/cli/client-4JVOYVC5.js +20 -0
  73. package/dist/cli/client-EEN2IJN2.mjs +20 -0
  74. package/dist/cli/csv-BOHBEP2I.mjs +585 -0
  75. package/dist/cli/csv-S5NYRUEX.js +585 -0
  76. package/dist/cli/db-CLODWCOB.mjs +486 -0
  77. package/dist/cli/db-F6PKFOOV.js +486 -0
  78. package/dist/cli/executions-5TQAKLJU.js +28 -0
  79. package/dist/cli/executions-MAKW6QOY.mjs +28 -0
  80. package/dist/cli/feedback-GV4QJFEN.js +107 -0
  81. package/dist/cli/feedback-XY24TW7H.mjs +107 -0
  82. package/dist/cli/getting-started.js +18 -76
  83. package/dist/cli/getting-started.mjs +10 -37
  84. package/dist/cli/git-6S2C22T5.js +23 -0
  85. package/dist/cli/git-OZLBD5HH.mjs +23 -0
  86. package/dist/cli/index.js +291 -54294
  87. package/dist/cli/index.mjs +209 -54352
  88. package/dist/cli/legacy-noops-LLCGDPQE.js +157 -0
  89. package/dist/cli/legacy-noops-TYH3TW2D.mjs +157 -0
  90. package/dist/cli/monitors-CABMB4DW.js +3251 -0
  91. package/dist/cli/monitors-TTD55HMK.mjs +3251 -0
  92. package/dist/cli/org-MSF3RG76.js +849 -0
  93. package/dist/cli/org-SFJ77MWY.mjs +849 -0
  94. package/dist/cli/play-NXHJSCKL.mjs +18439 -0
  95. package/dist/cli/play-OKSFNNO4.js +18439 -0
  96. package/dist/cli/providers-QC2ERERL.js +95 -0
  97. package/dist/cli/providers-TIIAZEUA.mjs +95 -0
  98. package/dist/cli/proxy-env-EBANZHPV.js +161 -0
  99. package/dist/cli/proxy-env-M4ZHXHRL.mjs +161 -0
  100. package/dist/cli/quickstart-ICANHLMI.js +69 -0
  101. package/dist/cli/quickstart-KWUOP3FI.mjs +69 -0
  102. package/dist/cli/search-U5H2FDOO.mjs +18 -0
  103. package/dist/cli/search-XQRQOLWS.js +18 -0
  104. package/dist/cli/secrets-3J6YTWFA.mjs +400 -0
  105. package/dist/cli/secrets-YNMNZNOM.js +400 -0
  106. package/dist/cli/sessions-CLEES4L6.mjs +15 -0
  107. package/dist/cli/sessions-J6VR47FG.js +15 -0
  108. package/dist/cli/settings-EEKZMTY4.js +846 -0
  109. package/dist/cli/settings-UVLOQZRH.mjs +846 -0
  110. package/dist/cli/setup-DLMDXPGJ.mjs +1257 -0
  111. package/dist/cli/setup-HC4Q7QM4.js +1257 -0
  112. package/dist/cli/skills-33PHFBSB.mjs +28 -0
  113. package/dist/cli/skills-LFRY3KPX.js +28 -0
  114. package/dist/cli/tools-3COEPKML.mjs +2955 -0
  115. package/dist/cli/tools-QXEVCN45.js +2955 -0
  116. package/dist/cli/update-LSAC4FF5.mjs +28 -0
  117. package/dist/cli/update-NXHSPYXA.js +28 -0
  118. package/dist/cli/workflow-7S44OECF.mjs +1936 -0
  119. package/dist/cli/workflow-QPZWYSZE.js +1936 -0
  120. package/dist/helpers.js +6 -32
  121. package/dist/helpers.mjs +2 -0
  122. package/dist/index.js +1972 -12825
  123. package/dist/index.mjs +1910 -12672
  124. package/dist/install-integrity.json +110 -0
  125. package/dist/monitor-fleet-contract.js +31 -730
  126. package/dist/monitor-fleet-contract.mjs +18 -667
  127. package/dist/monitor-input-contract.js +10 -390
  128. package/dist/monitor-input-contract.mjs +7 -348
  129. package/dist/plays/bundle-play-file.mjs +13 -5178
  130. package/dist/plays/csv-data-input.js +5 -3132
  131. package/dist/plays/csv-data-input.mjs +5 -3105
  132. package/dist/plays/run-request.js +56 -664
  133. package/dist/plays/run-request.mjs +30 -588
  134. package/dist/release.d.mts +1 -1
  135. package/dist/release.d.ts +1 -1
  136. package/dist/release.js +5 -212
  137. package/dist/release.mjs +5 -185
  138. package/package.json +1 -1
@@ -0,0 +1,344 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;// ../plays/tool-execution-error.ts
2
+ var DEEPLINE_ERROR_BRAND = Symbol.for("deepline.error.v1");
3
+ var TOOL_EXECUTION_ERROR_BRAND = Symbol.for(
4
+ "deepline.tool-execution-error.v1"
5
+ );
6
+ var PROVIDER_TRANSIENT_ERROR_BRAND = Symbol.for(
7
+ "deepline.provider-transient-error.v1"
8
+ );
9
+ var LEGACY_TOOL_EXECUTION_ERROR_SCHEMA_VERSION = 0;
10
+ var TOOL_EXECUTION_ERROR_SCHEMA_VERSION = 1;
11
+ var TOOL_EXECUTION_ERROR_SCHEMA_HEADER = "x-deepline-tool-error-schema";
12
+ var MAX_IDENTIFIER_LENGTH = 200;
13
+ var MAX_CODE_LENGTH = 160;
14
+ function nativeInstanceOf(constructor, value) {
15
+ return Reflect.apply(Function.prototype[Symbol.hasInstance], constructor, [
16
+ value
17
+ ]);
18
+ }
19
+ function hasBrand(value, brand) {
20
+ return typeof value === "object" && value !== null && value[brand] === true;
21
+ }
22
+ function applyBrand(value, brand) {
23
+ if (hasBrand(value, brand)) return;
24
+ Object.defineProperty(value, brand, {
25
+ configurable: false,
26
+ enumerable: false,
27
+ writable: false,
28
+ value: true
29
+ });
30
+ }
31
+ var DeeplineError = class _DeeplineError extends Error {
32
+ /** HTTP status when the failure crossed an HTTP boundary. */
33
+
34
+ /** Stable machine-readable error code when one exists. */
35
+
36
+ /** Local diagnostic context; not a portable error contract. */
37
+
38
+ /**
39
+ * Construct a Deepline error.
40
+ *
41
+ * SDK and runtime code construct these errors. Application and Play code
42
+ * normally catches the public subclasses instead.
43
+ *
44
+ * @param message Human-readable failure summary.
45
+ * @param statusCode HTTP status when one exists.
46
+ * @param code Stable machine-readable code when one exists.
47
+ * @param details Local diagnostic context; never a portable error contract.
48
+ */
49
+ constructor(message, statusCode, code, details) {
50
+ super(message);
51
+ this.name = "DeeplineError";
52
+ this.statusCode = statusCode;
53
+ this.code = code;
54
+ this.details = details;
55
+ applyBrand(this, DEEPLINE_ERROR_BRAND);
56
+ }
57
+ static [Symbol.hasInstance](value) {
58
+ if (this !== _DeeplineError) return nativeInstanceOf(this, value);
59
+ return hasBrand(value, DEEPLINE_ERROR_BRAND);
60
+ }
61
+ };
62
+ var ToolExecutionError = class _ToolExecutionError extends DeeplineError {
63
+ /** Public tool id passed to `tools.execute`. */
64
+
65
+ /** Provider responsible for the operation, or `null` when unattributed. */
66
+
67
+ /** Provider operation name, or `null` when unavailable. */
68
+
69
+ /** Boundary responsible for the failure. */
70
+
71
+ /** Stable reason family for policy and diagnostics. */
72
+
73
+ /**
74
+ * Whether repeating the same semantic call is delivery-safe.
75
+ *
76
+ * This does not mean the error may be ignored. Waterfall fallthrough is
77
+ * represented by `ProviderTransientError`.
78
+ */
79
+
80
+ /** Provider or Deepline request id, or `null` when unavailable. */
81
+
82
+ /** Suggested same-call retry delay in milliseconds, or `null`. */
83
+
84
+ /** Network failure kind, or `null` for non-network failures. */
85
+
86
+ /** Network boundary that failed, or `null` for non-network failures. */
87
+
88
+ /** Explicitly allowlisted diagnostics safe for SDK and Play callers. */
89
+
90
+ /**
91
+ * Construct a structured tool error.
92
+ *
93
+ * Deepline constructs this from the versioned `tool_error` payload.
94
+ * Application and Play code should catch it rather than create it.
95
+ */
96
+ constructor(message, options) {
97
+ super(
98
+ message,
99
+ _nullishCoalesce(options.statusCode, () => ( void 0)),
100
+ _nullishCoalesce(options.code, () => ( void 0)),
101
+ options.details
102
+ );
103
+ this.name = "ToolExecutionError";
104
+ this.toolId = options.toolId;
105
+ this.provider = options.provider;
106
+ this.operation = options.operation;
107
+ this.origin = options.origin;
108
+ this.category = options.category;
109
+ this.retryable = options.retryable;
110
+ this.requestId = options.requestId;
111
+ this.retryAfterMs = options.retryAfterMs;
112
+ this.networkKind = options.networkKind;
113
+ this.networkScope = options.networkScope;
114
+ this.publicDetails = _nullishCoalesce(options.publicDetails, () => ( null));
115
+ applyBrand(this, TOOL_EXECUTION_ERROR_BRAND);
116
+ if (isProviderTransientFailure(options)) {
117
+ applyBrand(this, PROVIDER_TRANSIENT_ERROR_BRAND);
118
+ }
119
+ }
120
+ static [Symbol.hasInstance](value) {
121
+ if (this !== _ToolExecutionError) return nativeInstanceOf(this, value);
122
+ return hasBrand(value, TOOL_EXECUTION_ERROR_BRAND);
123
+ }
124
+ };
125
+ function brandAsToolExecutionError(value) {
126
+ applyBrand(value, TOOL_EXECUTION_ERROR_BRAND);
127
+ }
128
+ function isProviderTransientFailure(input) {
129
+ return input.origin === "provider" && (input.category === "rate_limit" || input.category === "network" || input.category === "upstream");
130
+ }
131
+ var ProviderTransientError = (_class = class _ProviderTransientError extends ToolExecutionError {
132
+ /** Provider attribution is guaranteed for this subtype. */
133
+ __init() {this.origin = "provider"}
134
+ /** Constructed by Deepline when a provider-owned transient failure arrives. */
135
+ constructor(message, options) {
136
+ super(message, {
137
+ ...options,
138
+ origin: "provider",
139
+ category: options.category
140
+ });_class.prototype.__init.call(this);;
141
+ this.name = "ProviderTransientError";
142
+ this.category = options.category;
143
+ applyBrand(this, PROVIDER_TRANSIENT_ERROR_BRAND);
144
+ }
145
+ static [Symbol.hasInstance](value) {
146
+ if (this !== _ProviderTransientError) return nativeInstanceOf(this, value);
147
+ return hasBrand(value, PROVIDER_TRANSIENT_ERROR_BRAND);
148
+ }
149
+ }, _class);
150
+ function getProviderUnavailableReason(error) {
151
+ if (error instanceof ProviderTransientError) return error.category;
152
+ if (error instanceof ToolExecutionError && error.origin === "provider" && error.code === "PROVIDER_ACCOUNT_CAPACITY") {
153
+ return "account_capacity";
154
+ }
155
+ if (error instanceof ToolExecutionError && error.origin === "caller" && error.code === "INTEGRATION_CREDENTIALS_MISSING") {
156
+ return "credentials_missing";
157
+ }
158
+ return null;
159
+ }
160
+ function isProviderUnavailable(error) {
161
+ return getProviderUnavailableReason(error) !== null;
162
+ }
163
+ var isProviderWaterfallUnavailableError = isProviderUnavailable;
164
+ function brandAsProviderTransientError(value) {
165
+ applyBrand(value, PROVIDER_TRANSIENT_ERROR_BRAND);
166
+ }
167
+ function boundedString(value, maxLength = MAX_IDENTIFIER_LENGTH) {
168
+ if (typeof value !== "string") return null;
169
+ const normalized = value.trim();
170
+ return normalized ? normalized.slice(0, maxLength) : null;
171
+ }
172
+ function finiteNonNegativeInteger(value) {
173
+ return typeof value === "number" && Number.isFinite(value) && value >= 0 && Number.isInteger(value) ? value : null;
174
+ }
175
+ function normalizeToolExecutionOrigin(value, input) {
176
+ const normalized = _optionalChain([boundedString, 'call', _ => _(value), 'optionalAccess', _2 => _2.toLowerCase, 'call', _3 => _3()]);
177
+ if (normalized === "caller") return "caller";
178
+ if (normalized === "provider" || normalized === "provider_network") {
179
+ return "provider";
180
+ }
181
+ if (normalized === "upstream" && boundedString(_optionalChain([input, 'optionalAccess', _4 => _4.provider])) && boundedString(_optionalChain([input, 'optionalAccess', _5 => _5.operation]))) {
182
+ return "provider";
183
+ }
184
+ if (normalized === "deepline" || normalized === "deepline_billing" || normalized === "deepline_rate_limit" || normalized === "internal" || normalized === "server") {
185
+ return "deepline";
186
+ }
187
+ if (normalized === "provider_account") return "provider";
188
+ return "unknown";
189
+ }
190
+ function normalizeToolExecutionCategory(value) {
191
+ switch (_optionalChain([boundedString, 'call', _6 => _6(value), 'optionalAccess', _7 => _7.toLowerCase, 'call', _8 => _8()])) {
192
+ case "validation":
193
+ case "authorization":
194
+ case "rate_limit":
195
+ case "network":
196
+ case "upstream":
197
+ case "billing":
198
+ case "conflict":
199
+ case "internal":
200
+ return boundedString(value).toLowerCase();
201
+ case "authentication":
202
+ case "provider_auth":
203
+ case "provider_account":
204
+ return "authentication";
205
+ case "execution":
206
+ case "parse":
207
+ case "stub":
208
+ case "internal_native_search_performance":
209
+ return "internal";
210
+ default:
211
+ return "unknown";
212
+ }
213
+ }
214
+ function normalizeNetworkKind(value) {
215
+ switch (_optionalChain([boundedString, 'call', _9 => _9(value), 'optionalAccess', _10 => _10.toLowerCase, 'call', _11 => _11()])) {
216
+ case "timeout":
217
+ case "dns":
218
+ case "connect":
219
+ case "reset":
220
+ case "unavailable":
221
+ case "unknown":
222
+ return boundedString(value).toLowerCase();
223
+ default:
224
+ return null;
225
+ }
226
+ }
227
+ function normalizeNetworkScope(value) {
228
+ switch (_optionalChain([boundedString, 'call', _12 => _12(value), 'optionalAccess', _13 => _13.toLowerCase, 'call', _14 => _14()])) {
229
+ case "client_to_deepline":
230
+ case "runtime_to_deepline":
231
+ case "deepline_to_provider":
232
+ return boundedString(value).toLowerCase();
233
+ default:
234
+ return null;
235
+ }
236
+ }
237
+ function isRecord(value) {
238
+ return value !== null && typeof value === "object" && !Array.isArray(value);
239
+ }
240
+ var MAX_PUBLIC_DETAIL_ENTRIES = 20;
241
+ var MAX_PUBLIC_DETAIL_KEY_LENGTH = 80;
242
+ var MAX_PUBLIC_DETAIL_STRING_LENGTH = 512;
243
+ function normalizeToolExecutionPublicDetails(value) {
244
+ if (!isRecord(value)) return null;
245
+ const details = {};
246
+ for (const [key, entry] of Object.entries(value)) {
247
+ if (Object.keys(details).length >= MAX_PUBLIC_DETAIL_ENTRIES) break;
248
+ if (key.length === 0 || key.length > MAX_PUBLIC_DETAIL_KEY_LENGTH || !/^[a-z][a-zA-Z0-9_]*$/.test(key)) {
249
+ continue;
250
+ }
251
+ if (typeof entry === "string") {
252
+ if (entry.length <= MAX_PUBLIC_DETAIL_STRING_LENGTH) details[key] = entry;
253
+ continue;
254
+ }
255
+ if (typeof entry === "number") {
256
+ if (Number.isFinite(entry)) details[key] = entry;
257
+ continue;
258
+ }
259
+ if (typeof entry === "boolean") {
260
+ details[key] = entry;
261
+ continue;
262
+ }
263
+ if (entry === null) details[key] = null;
264
+ }
265
+ return Object.keys(details).length > 0 ? details : null;
266
+ }
267
+ function normalizeToolExecutionFailure(value) {
268
+ if (!isRecord(value) || value.schemaVersion !== TOOL_EXECUTION_ERROR_SCHEMA_VERSION) {
269
+ return null;
270
+ }
271
+ const toolId = boundedString(value.toolId);
272
+ if (!toolId) return null;
273
+ const provider = boundedString(value.provider);
274
+ const operation = boundedString(value.operation);
275
+ const origin = normalizeToolExecutionOrigin(value.origin, {
276
+ provider,
277
+ operation
278
+ });
279
+ const category = normalizeToolExecutionCategory(value.category);
280
+ const publicDetails = normalizeToolExecutionPublicDetails(value.publicDetails);
281
+ const trustworthy = origin !== "unknown" && category !== "unknown" && typeof value.retryable === "boolean";
282
+ return {
283
+ schemaVersion: TOOL_EXECUTION_ERROR_SCHEMA_VERSION,
284
+ toolId,
285
+ provider,
286
+ operation,
287
+ code: boundedString(value.code, MAX_CODE_LENGTH),
288
+ origin,
289
+ category,
290
+ retryable: trustworthy ? value.retryable === true : false,
291
+ statusCode: finiteNonNegativeInteger(value.statusCode),
292
+ requestId: boundedString(value.requestId),
293
+ retryAfterMs: finiteNonNegativeInteger(value.retryAfterMs),
294
+ networkKind: normalizeNetworkKind(value.networkKind),
295
+ networkScope: normalizeNetworkScope(value.networkScope),
296
+ ...publicDetails ? { publicDetails } : {}
297
+ };
298
+ }
299
+ function serializeToolExecutionFailure(error) {
300
+ if (!(error instanceof ToolExecutionError)) return null;
301
+ return normalizeToolExecutionFailure({
302
+ schemaVersion: TOOL_EXECUTION_ERROR_SCHEMA_VERSION,
303
+ toolId: error.toolId,
304
+ provider: error.provider,
305
+ operation: error.operation,
306
+ code: _nullishCoalesce(error.code, () => ( null)),
307
+ origin: error.origin,
308
+ category: error.category,
309
+ retryable: error.retryable,
310
+ statusCode: _nullishCoalesce(error.statusCode, () => ( null)),
311
+ requestId: error.requestId,
312
+ retryAfterMs: error.retryAfterMs,
313
+ networkKind: error.networkKind,
314
+ networkScope: error.networkScope,
315
+ publicDetails: error.publicDetails
316
+ });
317
+ }
318
+ function deserializeToolExecutionFailure(message, value, acceptedSchemaVersion) {
319
+ if (acceptedSchemaVersion === LEGACY_TOOL_EXECUTION_ERROR_SCHEMA_VERSION) {
320
+ return null;
321
+ }
322
+ const failure = normalizeToolExecutionFailure(value);
323
+ if (!failure) return null;
324
+ if (isProviderTransientFailure(failure)) {
325
+ return new ProviderTransientError(message, failure);
326
+ }
327
+ return new ToolExecutionError(message, failure);
328
+ }
329
+
330
+
331
+
332
+
333
+
334
+
335
+
336
+
337
+
338
+
339
+
340
+
341
+
342
+
343
+
344
+ exports.TOOL_EXECUTION_ERROR_SCHEMA_VERSION = TOOL_EXECUTION_ERROR_SCHEMA_VERSION; exports.TOOL_EXECUTION_ERROR_SCHEMA_HEADER = TOOL_EXECUTION_ERROR_SCHEMA_HEADER; exports.DeeplineError = DeeplineError; exports.ToolExecutionError = ToolExecutionError; exports.brandAsToolExecutionError = brandAsToolExecutionError; exports.isProviderTransientFailure = isProviderTransientFailure; exports.ProviderTransientError = ProviderTransientError; exports.getProviderUnavailableReason = getProviderUnavailableReason; exports.isProviderUnavailable = isProviderUnavailable; exports.isProviderWaterfallUnavailableError = isProviderWaterfallUnavailableError; exports.brandAsProviderTransientError = brandAsProviderTransientError; exports.serializeToolExecutionFailure = serializeToolExecutionFailure; exports.deserializeToolExecutionFailure = deserializeToolExecutionFailure;
@@ -0,0 +1,52 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/cli/trace.ts
2
+ var cliTraceStartedAt = Date.now();
3
+ function isTruthyEnv(value) {
4
+ return value === "1" || value === "true" || value === "yes";
5
+ }
6
+ function isCliTraceEnabled() {
7
+ return isTruthyEnv(process.env.DEEPLINE_CLI_TRACE);
8
+ }
9
+ function recordCliTrace(event) {
10
+ if (!isCliTraceEnabled()) {
11
+ return;
12
+ }
13
+ const now = Date.now();
14
+ const payload = {
15
+ ts: now,
16
+ source: "cli",
17
+ sinceStartMs: now - cliTraceStartedAt,
18
+ ...event
19
+ };
20
+ process.stderr.write(`[cli-trace] ${JSON.stringify(payload)}
21
+ `);
22
+ }
23
+ async function traceCliSpan(phase, fields, run) {
24
+ if (!isCliTraceEnabled()) {
25
+ return run();
26
+ }
27
+ const startedAt = Date.now();
28
+ try {
29
+ const result = await run();
30
+ recordCliTrace({
31
+ phase,
32
+ ms: Date.now() - startedAt,
33
+ ok: true,
34
+ ...fields
35
+ });
36
+ return result;
37
+ } catch (error) {
38
+ recordCliTrace({
39
+ phase,
40
+ ms: Date.now() - startedAt,
41
+ ok: false,
42
+ error: error instanceof Error ? error.message : String(error),
43
+ ...fields
44
+ });
45
+ throw error;
46
+ }
47
+ }
48
+
49
+
50
+
51
+
52
+ exports.recordCliTrace = recordCliTrace; exports.traceCliSpan = traceCliSpan;