deepline 0.3.294 → 0.3.296

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.ts +108 -35
  4. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-api-origin.ts +25 -0
  5. package/dist/bundling-sources/shared_libs/play-runtime/tool-http-errors.ts +14 -1
  6. package/dist/cli/auth-JCGIDVDF.mjs +31 -0
  7. package/dist/cli/auth-QDWV3TXX.js +31 -0
  8. package/dist/cli/billing-OQBSIXRG.mjs +1749 -0
  9. package/dist/cli/billing-YBK3J4WP.js +1749 -0
  10. package/dist/cli/chunk-2C3AVPTY.js +5688 -0
  11. package/dist/cli/chunk-2MZ5EQZE.mjs +499 -0
  12. package/dist/cli/chunk-3KC45UVF.js +150 -0
  13. package/dist/cli/chunk-3XX5TEA4.js +15 -0
  14. package/dist/cli/chunk-4MBOJQPL.mjs +0 -0
  15. package/dist/cli/chunk-4Y6CG4GE.js +2240 -0
  16. package/dist/cli/chunk-4ZB3CJRD.js +1269 -0
  17. package/dist/cli/chunk-5JLQPVNX.js +3056 -0
  18. package/dist/cli/chunk-6A3TJUWC.js +76 -0
  19. package/dist/cli/chunk-6HPEDBSJ.js +1995 -0
  20. package/dist/cli/chunk-7D6QG5KF.js +890 -0
  21. package/dist/cli/chunk-7P5AA3SN.js +344 -0
  22. package/dist/cli/chunk-7UAO5MWV.mjs +190 -0
  23. package/dist/cli/chunk-A7427JJH.js +190 -0
  24. package/dist/cli/chunk-AQRTLPHZ.js +735 -0
  25. package/dist/cli/chunk-AYHLUHE5.js +52 -0
  26. package/dist/cli/chunk-BZ77OTRF.mjs +923 -0
  27. package/dist/cli/chunk-CBVIJSHF.mjs +560 -0
  28. package/dist/cli/chunk-COGTRVWW.js +30 -0
  29. package/dist/cli/chunk-DLIRSHV6.mjs +28 -0
  30. package/dist/cli/chunk-DYWHXO7O.mjs +34 -0
  31. package/dist/cli/chunk-EDWJY6T4.mjs +3056 -0
  32. package/dist/cli/chunk-EXMLR72R.mjs +0 -0
  33. package/dist/cli/chunk-G46HHFNB.mjs +1269 -0
  34. package/dist/cli/chunk-GAMFK2ZP.mjs +148 -0
  35. package/dist/cli/chunk-GLKUGBTP.mjs +2240 -0
  36. package/dist/cli/chunk-GONRLVV3.js +3440 -0
  37. package/dist/cli/chunk-GVUJJJ5G.mjs +76 -0
  38. package/dist/cli/chunk-H7HIDGZ7.mjs +150 -0
  39. package/dist/cli/chunk-HUZXWOSK.mjs +503 -0
  40. package/dist/cli/chunk-I5YZLGMG.js +1 -0
  41. package/dist/cli/chunk-ITOFSXIU.mjs +15 -0
  42. package/dist/cli/chunk-J2D3VDOU.mjs +5688 -0
  43. package/dist/cli/chunk-J5NA2TTX.js +503 -0
  44. package/dist/cli/chunk-JCS5TPNY.mjs +3440 -0
  45. package/dist/cli/chunk-JNNOCMQY.js +47 -0
  46. package/dist/cli/chunk-KRD6H754.mjs +30 -0
  47. package/dist/cli/chunk-L4HBNHFW.js +34 -0
  48. package/dist/cli/chunk-LA46MMTL.js +560 -0
  49. package/dist/cli/chunk-LIKFCE7Z.js +190 -0
  50. package/dist/cli/chunk-MIMASXO4.mjs +389 -0
  51. package/dist/cli/chunk-NPPJX3BL.mjs +1995 -0
  52. package/dist/cli/chunk-NTEZFZLE.mjs +890 -0
  53. package/dist/cli/chunk-NXDRDJ4K.js +389 -0
  54. package/dist/cli/chunk-NXGCO4JB.mjs +344 -0
  55. package/dist/cli/chunk-OG64RBAC.js +6 -0
  56. package/dist/cli/chunk-OWJZUE3Y.mjs +103 -0
  57. package/dist/cli/chunk-QSIO4TX2.mjs +190 -0
  58. package/dist/cli/chunk-RCUE5C5C.mjs +735 -0
  59. package/dist/cli/chunk-SDK3ZA2C.js +103 -0
  60. package/dist/cli/chunk-SFLARO4Y.mjs +47 -0
  61. package/dist/cli/chunk-TAC3JIFE.mjs +354 -0
  62. package/dist/cli/chunk-UC6GHEL4.js +499 -0
  63. package/dist/cli/chunk-UFS752TU.mjs +52 -0
  64. package/dist/cli/chunk-UNEMDKXN.js +1 -0
  65. package/dist/cli/chunk-WB6Z2Q44.mjs +1622 -0
  66. package/dist/cli/chunk-WJYPBHTE.js +148 -0
  67. package/dist/cli/chunk-WOHBA5PV.js +354 -0
  68. package/dist/cli/chunk-WZYKRD7T.mjs +6 -0
  69. package/dist/cli/chunk-XNYIZMNQ.js +28 -0
  70. package/dist/cli/chunk-ZDO3TO3M.js +1622 -0
  71. package/dist/cli/chunk-ZDOC4HFL.js +923 -0
  72. package/dist/cli/client-CZDA4JKO.mjs +20 -0
  73. package/dist/cli/client-IZGIN2ZA.js +20 -0
  74. package/dist/cli/csv-6KOMZA2H.mjs +585 -0
  75. package/dist/cli/csv-UTEQY3NA.js +585 -0
  76. package/dist/cli/db-D5EP6TKO.mjs +486 -0
  77. package/dist/cli/db-SIBLPIKC.js +486 -0
  78. package/dist/cli/executions-2PHT57IO.js +28 -0
  79. package/dist/cli/executions-DFWM2YYY.mjs +28 -0
  80. package/dist/cli/feedback-GZW37JMI.mjs +107 -0
  81. package/dist/cli/feedback-IQVWIJZ4.js +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-563GYLMA.js +23 -0
  85. package/dist/cli/git-B72Y4FFQ.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-37F5MX2P.mjs +157 -0
  89. package/dist/cli/legacy-noops-IFGVDCOM.js +157 -0
  90. package/dist/cli/monitors-42H6LOVT.mjs +3251 -0
  91. package/dist/cli/monitors-GQCHXBXZ.js +3251 -0
  92. package/dist/cli/org-4GCPBTGR.js +849 -0
  93. package/dist/cli/org-JYZA3ZRJ.mjs +849 -0
  94. package/dist/cli/play-46ZJ4FMI.js +18439 -0
  95. package/dist/cli/play-Q2XV3FZZ.mjs +18439 -0
  96. package/dist/cli/providers-CTKQP45X.mjs +95 -0
  97. package/dist/cli/providers-PCNF5E3K.js +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-FTHWRVWN.js +69 -0
  101. package/dist/cli/quickstart-X7EVVWRG.mjs +69 -0
  102. package/dist/cli/search-73YPOFDO.mjs +18 -0
  103. package/dist/cli/search-XA5UVC3G.js +18 -0
  104. package/dist/cli/secrets-OUMPT4FX.mjs +400 -0
  105. package/dist/cli/secrets-UOEVR73Q.js +400 -0
  106. package/dist/cli/sessions-CMKXCN5Y.js +15 -0
  107. package/dist/cli/sessions-ZIFGDZE7.mjs +15 -0
  108. package/dist/cli/settings-OO5R3G52.mjs +846 -0
  109. package/dist/cli/settings-ULZT2NIC.js +846 -0
  110. package/dist/cli/setup-6GZH52OZ.mjs +1257 -0
  111. package/dist/cli/setup-DHGERXPZ.js +1257 -0
  112. package/dist/cli/skills-Q7NUCS2W.js +28 -0
  113. package/dist/cli/skills-T3EY2656.mjs +28 -0
  114. package/dist/cli/tools-BIMOAOTX.mjs +2955 -0
  115. package/dist/cli/tools-ODXVCKO7.js +2955 -0
  116. package/dist/cli/update-UMB3ULBR.js +28 -0
  117. package/dist/cli/update-X4HX7Z3M.mjs +28 -0
  118. package/dist/cli/workflow-EAUFVPIP.mjs +1936 -0
  119. package/dist/cli/workflow-IVLCPFTG.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,190 @@
1
+ import {
2
+ DeeplineClient
3
+ } from "./chunk-J2D3VDOU.mjs";
4
+ import {
5
+ printCommandEnvelope
6
+ } from "./chunk-NTEZFZLE.mjs";
7
+ import {
8
+ resolveConfig,
9
+ sdkCliStateDirPath
10
+ } from "./chunk-NPPJX3BL.mjs";
11
+
12
+ // src/cli/search-ref.ts
13
+ import { mkdirSync, readFileSync, writeFileSync } from "fs";
14
+ import { dirname, join } from "path";
15
+ var SEARCH_REF_TTL_MS = 15 * 6e4;
16
+ function lastSearchPath() {
17
+ return join(sdkCliStateDirPath(resolveConfig().baseUrl), "last-search.json");
18
+ }
19
+ function rememberSearchRef(searchRef) {
20
+ try {
21
+ mkdirSync(dirname(lastSearchPath()), { recursive: true });
22
+ writeFileSync(
23
+ lastSearchPath(),
24
+ JSON.stringify({ searchRef, at: Date.now() }),
25
+ { mode: 384 }
26
+ );
27
+ } catch {
28
+ }
29
+ }
30
+ function recentSearchRef() {
31
+ try {
32
+ const saved = JSON.parse(readFileSync(lastSearchPath(), "utf8"));
33
+ return typeof saved.searchRef === "string" && typeof saved.at === "number" && Date.now() - saved.at < SEARCH_REF_TTL_MS ? saved.searchRef : void 0;
34
+ } catch {
35
+ return void 0;
36
+ }
37
+ }
38
+
39
+ // src/cli/commands/search.ts
40
+ var SEARCH_TYPES = [
41
+ "tools",
42
+ "plays",
43
+ "monitors",
44
+ "prebuilts",
45
+ "custom"
46
+ ];
47
+ var USAGE = "Usage: deepline search [query] [--type <types>] [--categories <categories>] [--search_terms <terms>] [--json]";
48
+ function parseTypes(flag, raw) {
49
+ const names = (raw ?? "").split(",").map((name) => name.trim().toLowerCase()).filter(Boolean);
50
+ const unknown = names.filter(
51
+ (name) => !SEARCH_TYPES.includes(name)
52
+ );
53
+ if (unknown.length > 0) {
54
+ throw new Error(
55
+ `Unknown ${flag} ${unknown.join(", ")}. Use any of: ${SEARCH_TYPES.join(", ")}.`
56
+ );
57
+ }
58
+ return names;
59
+ }
60
+ function optionalInteger(raw) {
61
+ return raw === void 0 ? void 0 : Number.parseInt(raw, 10);
62
+ }
63
+ function appendCsv(value, previous) {
64
+ return previous ? `${previous},${value}` : value;
65
+ }
66
+ function addSearchOptions(command) {
67
+ return command.option(
68
+ "--categories <categories>",
69
+ "Comma-separated tool categories; may be used without a query"
70
+ ).option(
71
+ "--search_terms <terms>",
72
+ "Comma-separated structured search terms; may be used without a query"
73
+ ).option("--search-terms <terms>", "Alias for --search_terms").option(
74
+ "--task <sentence>",
75
+ "What you are trying to accomplish: input you have -> result you need"
76
+ ).option("--limit <count>", "Maximum ranked results to return (1-50)").option("--offset <count>", "Zero-based ranked result offset").option("--search-mode <mode>", "Ranked search mode: v1 or v2").option("--include-search-debug", "Include ranked search debug metadata").option("--json", "Emit JSON output instead of the readable default");
77
+ }
78
+ async function runSearch(queryInput, options, types, exclude = []) {
79
+ const query = queryInput?.trim() ?? "";
80
+ const searchTerms = options.searchTerms ?? options.search_terms;
81
+ if (!query && !options.categories?.trim() && !searchTerms?.trim()) {
82
+ console.error(USAGE);
83
+ return 1;
84
+ }
85
+ const { search_ref: searchRef, ...result } = await new DeeplineClient().search({
86
+ query,
87
+ types,
88
+ exclude,
89
+ categories: options.categories,
90
+ searchTerms,
91
+ task: options.task,
92
+ limit: optionalInteger(options.limit),
93
+ offset: optionalInteger(options.offset),
94
+ searchMode: options.searchMode === "v1" || options.searchMode === "v2" ? options.searchMode : void 0,
95
+ includeSearchDebug: Boolean(options.includeSearchDebug)
96
+ });
97
+ if (searchRef) rememberSearchRef(searchRef);
98
+ printCommandEnvelope(result, {
99
+ json: options.json === true
100
+ });
101
+ return 0;
102
+ }
103
+ function registerDeprecatedSearchCommand(parent, typesFor) {
104
+ const name = `deepline ${parent.name()} search`;
105
+ addSearchOptions(
106
+ parent.command("search [query]").description(`Deprecated. Use deepline search --type <types>.`).addHelpText(
107
+ "after",
108
+ `
109
+ Notes:
110
+ Deprecated alias for the unified search. It runs deepline search with the
111
+ matching --type and returns the same results envelope.
112
+
113
+ Examples:
114
+ deepline search email --type ${typesFor({}).join(",")}
115
+ `
116
+ ).option("--all", "Include plays your workspace created").option("--compact", "Accepted for compatibility; results are compact")
117
+ ).action(async (query, options) => {
118
+ const types = typesFor(options);
119
+ console.error(
120
+ `${name} is deprecated. Use: deepline search${query ? ` ${JSON.stringify(query)}` : ""} --type ${types.join(",")}`
121
+ );
122
+ process.exitCode = await runSearch(query, options, types);
123
+ });
124
+ }
125
+ function registerSearchCommand(program) {
126
+ addSearchOptions(
127
+ program.command("search [query]").description(
128
+ "Search tools, monitors, and plays together, ranked by intent."
129
+ ).addHelpText(
130
+ "after",
131
+ `
132
+ Notes:
133
+ One ranked search across everything Deepline can run, deploy, or explain.
134
+ Every result carries a kind: tool, monitor_type, prebuilt_play, custom_play
135
+ (a play your workspace created), or doc. Narrow with --type, a
136
+ comma-separated list of:
137
+ tools atomic provider operations (deepline tools execute)
138
+ monitors monitor types you can deploy
139
+ prebuilts Deepline-maintained plays
140
+ custom plays your workspace created
141
+ plays prebuilts and custom together
142
+ --exclude takes the same names and leaves those kinds out instead.
143
+ Ranking uses a third-party AI relevance model. For plays your workspace
144
+ created it is sent only the play name and description, never play code.
145
+ Both flags may be repeated: --type tools --type prebuilts.
146
+ Provide a query, or omit it only when --categories and/or --search_terms is
147
+ supplied. Use --limit and --offset to page (limit 1-50, offset zero-based);
148
+ JSON includes next_offset. Pass --task with one sentence on what you are
149
+ trying to accomplish: the input you have and the result you need. It
150
+ materially improves ranking, especially for short queries.
151
+ Search prints a readable result list by default, piped or not, and that is
152
+ the recommended form. Pass --json only when a program parses the result.
153
+
154
+ Examples:
155
+ deepline search "find work email"
156
+ deepline search "find work email" --type tools --limit 10
157
+ deepline search "company to contacts" --type plays
158
+ deepline search "enrich a company" --exclude monitors,custom
159
+ deepline search linkedin --task "I have 200 LinkedIn profile URLs and need each person's current title and company"
160
+ deepline search --type tools --categories company_search --search_terms "investors,funding"
161
+ `
162
+ ).option(
163
+ "--type <types>",
164
+ `Kinds to search, comma-separated or repeated: ${SEARCH_TYPES.join(", ")}`,
165
+ appendCsv
166
+ ).option(
167
+ "--exclude <types>",
168
+ "Kinds to leave out, comma-separated or repeated; the opposite of --type",
169
+ appendCsv
170
+ )
171
+ ).action(async (query, options) => {
172
+ let types;
173
+ let exclude;
174
+ try {
175
+ types = parseTypes("--type", options.type);
176
+ exclude = parseTypes("--exclude", options.exclude);
177
+ } catch (error) {
178
+ console.error(error instanceof Error ? error.message : String(error));
179
+ process.exitCode = 1;
180
+ return;
181
+ }
182
+ process.exitCode = await runSearch(query, options, types, exclude);
183
+ });
184
+ }
185
+
186
+ export {
187
+ recentSearchRef,
188
+ registerDeprecatedSearchCommand,
189
+ registerSearchCommand
190
+ };