deepline 0.3.396 → 0.3.397

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 (117) hide show
  1. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  2. package/dist/bundling-sources/shared_libs/play-runtime/fixture-behavior.ts +2 -2
  3. package/dist/cli/{auth-3LTD62VL.mjs → auth-AZJFXGKP.mjs} +5 -4
  4. package/dist/cli/auth-CZJQU7B5.js +40 -0
  5. package/dist/cli/{billing-PA5OXEM5.js → billing-MQV5AGDJ.js} +76 -75
  6. package/dist/cli/{billing-DP7ZAJBO.mjs → billing-MZAAUHGH.mjs} +5 -4
  7. package/dist/cli/{chunk-VE3U3SQC.mjs → chunk-2LDADJNO.mjs} +7 -107
  8. package/dist/cli/{chunk-772W2SAU.js → chunk-3VP34TAU.js} +8 -8
  9. package/dist/cli/{chunk-QHGPA362.mjs → chunk-4D745XZO.mjs} +6 -108
  10. package/dist/cli/chunk-7DRPTGCK.js +930 -0
  11. package/dist/cli/{chunk-NSOTASOP.js → chunk-BQR6UN3C.js} +1 -83
  12. package/dist/cli/{chunk-RTO5QZWT.js → chunk-DQ65ZVHN.js} +6 -6
  13. package/dist/cli/{chunk-3T4MCB5R.mjs → chunk-F3BUFYKE.mjs} +89 -969
  14. package/dist/cli/chunk-FIVKWNMT.mjs +210 -0
  15. package/dist/cli/{describe-6O2ENKTP.mjs → chunk-HFYQBC2D.mjs} +22 -160
  16. package/dist/cli/chunk-HGFFYVXN.js +210 -0
  17. package/dist/cli/{chunk-5WNJF2T3.mjs → chunk-IHG7UAHD.mjs} +1 -83
  18. package/dist/cli/{chunk-GNN4MY5X.js → chunk-IZ74ABSX.js} +1 -1
  19. package/dist/cli/{chunk-MR6XCBQJ.mjs → chunk-J7ABTQQ7.mjs} +4 -2
  20. package/dist/cli/{chunk-2VOLOWYZ.js → chunk-K33MXVXQ.js} +293 -1173
  21. package/dist/cli/chunk-LJ5747UC.mjs +107 -0
  22. package/dist/cli/{chunk-NHB5YUCS.mjs → chunk-MRXMMERY.mjs} +1 -1
  23. package/dist/cli/{chunk-TLQ3FZOC.mjs → chunk-MV7QRALK.mjs} +3 -3
  24. package/dist/cli/{chunk-AUYXWELC.mjs → chunk-MYPH2LUU.mjs} +2 -2
  25. package/dist/cli/{chunk-LWERJUKN.js → chunk-NA4T3B62.js} +7 -215
  26. package/dist/cli/{chunk-23GAA3YO.mjs → chunk-NOX2TCBP.mjs} +1 -1
  27. package/dist/cli/chunk-OSDXE27V.mjs +88 -0
  28. package/dist/cli/{chunk-KAEZNPUM.js → chunk-PSGEDGLT.js} +13 -115
  29. package/dist/cli/chunk-Q2E4E4FJ.js +112 -0
  30. package/dist/cli/{describe-EFWNECHI.js → chunk-RFG3MRAC.js} +37 -175
  31. package/dist/cli/{chunk-XKZXO7D3.mjs → chunk-RNSWDKBM.mjs} +1 -1
  32. package/dist/cli/{chunk-V7UP2F4U.js → chunk-RYW4HPSM.js} +21 -121
  33. package/dist/cli/{chunk-7Z66NHUC.js → chunk-SO7RUVTY.js} +26 -26
  34. package/dist/cli/{chunk-H5KLUGY7.mjs → chunk-TXZVVBQZ.mjs} +1 -209
  35. package/dist/cli/{chunk-WQJJNIMQ.js → chunk-UVXBVUZQ.js} +11 -9
  36. package/dist/cli/{chunk-AVHLATII.js → chunk-VTF4RRWJ.js} +50 -50
  37. package/dist/cli/{chunk-LOGGNW4H.mjs → chunk-W3HMGKMI.mjs} +2 -2
  38. package/dist/cli/{chunk-JCN4DHF7.mjs → chunk-WM2QEHZL.mjs} +2 -2
  39. package/dist/cli/chunk-YHPYUZZX.mjs +112 -0
  40. package/dist/cli/chunk-YHZUZO3U.mjs +930 -0
  41. package/dist/cli/{chunk-ME6XRFLY.js → chunk-YLRME7MK.js} +15 -15
  42. package/dist/cli/{chunk-DC6LTULT.js → chunk-YSVORIEW.js} +2 -2
  43. package/dist/cli/{chunk-I4T4XAA2.mjs → chunk-YUDKBQUD.mjs} +4 -4
  44. package/dist/cli/chunk-ZAAKSJAS.js +88 -0
  45. package/dist/cli/{chunk-RMTASUAK.js → chunk-ZHUMDMOS.js} +65 -65
  46. package/dist/cli/chunk-ZM2YPJQJ.js +107 -0
  47. package/dist/cli/{csv-TF576S77.js → csv-AQBQ5O3I.js} +13 -12
  48. package/dist/cli/{csv-RLRR74RQ.mjs → csv-MB7PJMYQ.mjs} +4 -3
  49. package/dist/cli/{db-FDBJUTFO.js → db-JPUYC5RB.js} +30 -29
  50. package/dist/cli/{db-XORGNBIC.mjs → db-L5IEI2AU.mjs} +5 -4
  51. package/dist/cli/describe-6WT74AOR.js +164 -0
  52. package/dist/cli/describe-S6BFANVI.mjs +164 -0
  53. package/dist/cli/describe-core.d.mts +100 -0
  54. package/dist/cli/describe-core.d.ts +100 -0
  55. package/dist/cli/describe-core.js +18 -0
  56. package/dist/cli/describe-core.mjs +18 -0
  57. package/dist/cli/{executions-SFYAXPF4.js → executions-6TMQTFP4.js} +7 -6
  58. package/dist/cli/{executions-YPP7WR77.mjs → executions-L7I2ZW4Z.mjs} +5 -4
  59. package/dist/cli/{feedback-RBGA5ARU.mjs → feedback-DSJ63HK6.mjs} +4 -3
  60. package/dist/cli/{feedback-5UZFYMGB.js → feedback-XF7CQGMD.js} +8 -7
  61. package/dist/cli/{git-IRSAJEK2.mjs → git-C3ENM67D.mjs} +5 -4
  62. package/dist/cli/git-HYDZK2QR.js +24 -0
  63. package/dist/cli/index.js +93 -91
  64. package/dist/cli/index.mjs +35 -33
  65. package/dist/cli/{legacy-noops-CVAOQY2F.js → legacy-noops-B2NHWIVD.js} +8 -7
  66. package/dist/cli/{legacy-noops-NA7N6ZOU.mjs → legacy-noops-VFG2K6HK.mjs} +5 -4
  67. package/dist/cli/{monitors-4OMRXCXP.js → monitors-ORFWOVZB.js} +86 -85
  68. package/dist/cli/{monitors-ILZ2XHYG.mjs → monitors-TCEDBDGY.mjs} +5 -4
  69. package/dist/cli/{org-QDDXAE3J.mjs → org-45KREIKZ.mjs} +5 -4
  70. package/dist/cli/{org-YGNJDD2X.js → org-T74CJESN.js} +65 -64
  71. package/dist/cli/{play-VT6OHB2D.mjs → play-MU7MYBIM.mjs} +19 -15
  72. package/dist/cli/{play-L535H26U.js → play-XHK2LPON.js} +251 -247
  73. package/dist/cli/{providers-GPZ6PQAL.js → providers-4MGQKYFD.js} +8 -7
  74. package/dist/cli/{providers-KG4W5MPK.mjs → providers-VYCXIJT5.mjs} +5 -4
  75. package/dist/cli/{quickstart-UI27S5LO.js → quickstart-47G3VEOT.js} +6 -5
  76. package/dist/cli/{quickstart-2JDGTXIG.mjs → quickstart-H724EFM2.mjs} +4 -3
  77. package/dist/cli/search-3356ENLD.js +30 -0
  78. package/dist/cli/{search-PW3RAUX7.mjs → search-VQHXEFQ4.mjs} +7 -5
  79. package/dist/cli/{secrets-WFAXOUZE.js → secrets-ALLKCU35.js} +14 -13
  80. package/dist/cli/{secrets-HNOMK5A2.mjs → secrets-CPBNGA44.mjs} +5 -4
  81. package/dist/cli/{sessions-XLX3E5UO.mjs → sessions-7RSQB7IX.mjs} +5 -4
  82. package/dist/cli/sessions-FKGAY7WQ.js +16 -0
  83. package/dist/cli/{settings-YNZ4YKCH.mjs → settings-UYSGV4IC.mjs} +8 -7
  84. package/dist/cli/{settings-GADAG2UK.js → settings-Y5BI42P7.js} +75 -74
  85. package/dist/cli/{setup-PSEHIUXO.mjs → setup-L3ZBBTS4.mjs} +7 -6
  86. package/dist/cli/{setup-R5YO7GT6.js → setup-VXQPEU3E.js} +42 -41
  87. package/dist/cli/skills-DUZQTDTE.js +29 -0
  88. package/dist/cli/{skills-LTQBP6CZ.mjs → skills-QHVDLSFE.mjs} +5 -4
  89. package/dist/cli/{tools-UAXDWU63.mjs → tools-LSCEK4K2.mjs} +13 -8
  90. package/dist/cli/tools-YWU5QOQ5.js +39 -0
  91. package/dist/cli/update-5LYQAI55.js +29 -0
  92. package/dist/cli/{update-SMNIBIMS.mjs → update-CU22OTBM.mjs} +7 -6
  93. package/dist/cli/{workflow-AOQVZHMD.js → workflow-ERFLTRNX.js} +16 -15
  94. package/dist/cli/{workflow-IKGMBGF6.mjs → workflow-KQARK5BZ.mjs} +6 -5
  95. package/dist/{client-DiGl8ska.d.mts → client-D0j-_aaa.d.mts} +1 -1
  96. package/dist/{client-Bgis7F6-.d.ts → client-DflfVyj6.d.ts} +1 -1
  97. package/dist/index.d.mts +2 -2
  98. package/dist/index.d.ts +2 -2
  99. package/dist/index.js +14 -10
  100. package/dist/index.mjs +19 -15
  101. package/dist/install-integrity.json +92 -76
  102. package/dist/plays/play-description.d.mts +1 -1
  103. package/dist/plays/play-description.d.ts +1 -1
  104. package/dist/plays/run-request.d.mts +1 -1
  105. package/dist/plays/run-request.d.ts +1 -1
  106. package/dist/release.d.mts +1 -1
  107. package/dist/release.d.ts +1 -1
  108. package/dist/release.js +2 -2
  109. package/dist/release.mjs +1 -1
  110. package/package.json +6 -1
  111. package/dist/cli/auth-562JPKOM.js +0 -39
  112. package/dist/cli/git-5LDY5ZID.js +0 -23
  113. package/dist/cli/search-MGWROZ33.js +0 -28
  114. package/dist/cli/sessions-366KROUA.js +0 -15
  115. package/dist/cli/skills-JF2LPEGM.js +0 -28
  116. package/dist/cli/tools-CP2PEFRN.js +0 -34
  117. package/dist/cli/update-HZHZOU6C.js +0 -28
@@ -1,37 +1,51 @@
1
1
  import {
2
2
  addDescribeOptions,
3
- rateLimitSummary,
4
- recordApiResponse,
5
- schemaField,
6
- schemaFields
7
- } from "./chunk-5WNJF2T3.mjs";
3
+ recordApiResponse
4
+ } from "./chunk-OSDXE27V.mjs";
5
+ import {
6
+ recentSearchRef,
7
+ registerDeprecatedSearchCommand
8
+ } from "./chunk-4D745XZO.mjs";
9
+ import {
10
+ arrayField,
11
+ formatModelDescription,
12
+ isMonitorTypeTool,
13
+ isPlayLikeTool,
14
+ isRecord,
15
+ playReferenceForTool,
16
+ playResultExpression,
17
+ playRunCommandForTool,
18
+ playSearchCommandForToolId,
19
+ recordField,
20
+ recursiveToolInputFieldsForDisplay,
21
+ samplePayloadForInputFields,
22
+ stringField,
23
+ toolContractJsonForDescribe,
24
+ toolInputFieldsForDisplay,
25
+ toolMetadataJsonForDescribe,
26
+ toolOutputFieldsForDisplay
27
+ } from "./chunk-YHZUZO3U.mjs";
8
28
  import {
9
29
  shellQuote
10
30
  } from "./chunk-OVDNJAJN.mjs";
11
31
  import {
12
32
  Capability,
13
- observedMaxText,
14
- recentSearchRef,
15
- registerDeprecatedSearchCommand
16
- } from "./chunk-QHGPA362.mjs";
33
+ observedMaxText
34
+ } from "./chunk-LJ5747UC.mjs";
17
35
  import {
18
- DEEPLINE_EXTRACTOR_TARGET_DEFINITIONS,
19
- EMAIL_STATUS_JSON_SCHEMA,
20
- JOB_CHANGE_JSON_SCHEMA,
21
36
  extractSummaryFields,
22
- isDeeplineExtractorTarget,
23
37
  projectRowOutput,
24
38
  tryConvertToList,
25
39
  writeCsvOutputFile,
26
40
  writeJsonOutputFile
27
- } from "./chunk-H5KLUGY7.mjs";
41
+ } from "./chunk-FIVKWNMT.mjs";
28
42
  import {
29
43
  playToolListGetterMode
30
44
  } from "./chunk-3HU47EGZ.mjs";
31
45
  import {
32
46
  DeeplineClient,
33
47
  validateExecutionIdempotencyKey
34
- } from "./chunk-MR6XCBQJ.mjs";
48
+ } from "./chunk-J7ABTQQ7.mjs";
35
49
  import {
36
50
  stableStringify
37
51
  } from "./chunk-UBKA33KY.mjs";
@@ -48,11 +62,11 @@ import {
48
62
  printJsonError,
49
63
  renderCommandEnvelopeText,
50
64
  shouldEmitJson
51
- } from "./chunk-XKZXO7D3.mjs";
65
+ } from "./chunk-RNSWDKBM.mjs";
52
66
  import {
53
67
  resolveConfig,
54
68
  sdkCliStateDirPath
55
- } from "./chunk-VE3U3SQC.mjs";
69
+ } from "./chunk-2LDADJNO.mjs";
56
70
  import {
57
71
  DeeplineError
58
72
  } from "./chunk-NXGCO4JB.mjs";
@@ -72,18 +86,18 @@ function matchesToolRequestCondition(condition, payload) {
72
86
  (entry) => matchesToolRequestCondition(entry, payload)
73
87
  );
74
88
  }
75
- const value2 = payload?.[condition.field];
89
+ const value = payload?.[condition.field];
76
90
  switch (condition.operator) {
77
91
  case "equals":
78
- return value2 === condition.value;
92
+ return value === condition.value;
79
93
  case "number_equals":
80
94
  try {
81
- return Number(value2) === condition.value;
95
+ return Number(value) === condition.value;
82
96
  } catch {
83
97
  return false;
84
98
  }
85
99
  case "present_nonblank":
86
- return typeof value2 === "string" ? value2.trim().length > 0 : value2 !== void 0 && value2 !== null;
100
+ return typeof value === "string" ? value.trim().length > 0 : value !== void 0 && value !== null;
87
101
  default:
88
102
  throw new Error("Unsupported tool request warning condition.");
89
103
  }
@@ -195,836 +209,6 @@ async function completePendingToolExecution(path, idempotencyKey) {
195
209
  }
196
210
  }
197
211
 
198
- // ../plays/field-catalog.ts
199
- var value = (description) => ({ type: "string", description });
200
- var SOURCE = {
201
- type: "string",
202
- description: "The provider or step that found it."
203
- };
204
- var FIELD_CATALOG = {
205
- person: {
206
- name: {
207
- description: "The person's name.",
208
- leaves: {
209
- value: value("Full name."),
210
- first: value("First (given) name."),
211
- last: value("Last (family) name.")
212
- }
213
- },
214
- email: {
215
- description: "An email address for the person.",
216
- leaves: {
217
- value: value("The address."),
218
- validated: {
219
- type: "boolean",
220
- description: "Whether the address passed validation."
221
- },
222
- status: {
223
- type: "EmailStatus",
224
- description: "The validation verdict and its signals."
225
- },
226
- source: SOURCE
227
- },
228
- kinds: {
229
- work: "At their employer.",
230
- personal: "Their own, not tied to an employer."
231
- }
232
- },
233
- phone: {
234
- description: "A phone number for the person.",
235
- leaves: {
236
- value: value("The number."),
237
- validated: {
238
- type: "boolean",
239
- description: "Whether the number passed validation."
240
- },
241
- status: {
242
- type: '"valid" | "invalid" | "unknown"',
243
- description: "The validation verdict."
244
- },
245
- line_type: value("Mobile, landline, VoIP and so on."),
246
- carrier: value("The carrier serving the number."),
247
- source: SOURCE
248
- },
249
- kinds: {
250
- mobile: "Their mobile.",
251
- work: "A direct line at their employer."
252
- }
253
- },
254
- linkedin: {
255
- description: "The person's LinkedIn profile.",
256
- leaves: { url: value("The profile URL.") }
257
- },
258
- job: {
259
- description: "The person's current role.",
260
- leaves: {
261
- title: value("Job title."),
262
- change: {
263
- type: "JobChange",
264
- description: "Whether they changed jobs, and to what."
265
- },
266
- change_status: {
267
- type: "JobChangeStatus",
268
- description: "The job-change verdict alone."
269
- }
270
- }
271
- },
272
- record: {
273
- description: "A provider's own record of the person.",
274
- leaves: { id: value("The provider's id for the person.") }
275
- }
276
- },
277
- company: {
278
- name: {
279
- description: "The company's name.",
280
- leaves: { value: value("The name.") },
281
- kinds: { legal: "As registered with a government." }
282
- },
283
- domain: {
284
- description: "The company's web domain.",
285
- leaves: { value: value("The bare domain, such as example.com.") }
286
- },
287
- website: {
288
- description: "The company's website.",
289
- leaves: { url: value("The site URL.") }
290
- },
291
- linkedin: {
292
- description: "The company's LinkedIn page.",
293
- leaves: { url: value("The page URL.") }
294
- },
295
- phone: {
296
- description: "A phone number for the company.",
297
- leaves: { value: value("The number.") }
298
- },
299
- industry: {
300
- description: "The industry the company is in.",
301
- leaves: { value: value("The industry.") }
302
- },
303
- record: {
304
- description: "A provider's own record of the company.",
305
- leaves: { id: value("The provider's id for the company.") }
306
- }
307
- }
308
- };
309
- function catalogFields() {
310
- return Object.entries(FIELD_CATALOG).flatMap(
311
- ([entity, groups]) => Object.entries(groups).flatMap(
312
- ([group, definition]) => [void 0, ...Object.keys(definition.kinds ?? {})].flatMap(
313
- (kind) => Object.entries(definition.leaves).map(([leaf, described]) => ({
314
- ...described,
315
- id: [entity, group, kind, leaf].filter(Boolean).join("."),
316
- entity,
317
- group,
318
- ...kind ? { kind } : {},
319
- leaf
320
- }))
321
- )
322
- )
323
- );
324
- }
325
- var FIELDS_BY_ID = new Map(catalogFields().map((field) => [field.id, field]));
326
- function generalField(id) {
327
- const field = FIELDS_BY_ID.get(id);
328
- return field?.kind ? [field.entity, field.group, field.leaf].join(".") : null;
329
- }
330
- function fieldSatisfies(offered, wanted) {
331
- return offered === wanted || generalField(offered) === wanted;
332
- }
333
- var EXTRACTOR_TARGET_FIELDS = {
334
- email: ["person.email.value"],
335
- personal_email: ["person.email.personal.value"],
336
- email_status: ["person.email.status"],
337
- phone: ["person.phone.value", "company.phone.value"],
338
- phone_status: ["person.phone.status"],
339
- first_name: ["person.name.first"],
340
- last_name: ["person.name.last"],
341
- full_name: ["person.name.value"],
342
- // Also used for a list name, a channel title and a search suggestion.
343
- name: ["person.name.value", "company.name.value"],
344
- linkedin: ["person.linkedin.url", "company.linkedin.url"],
345
- linkedin_url: ["person.linkedin.url"],
346
- title: ["person.job.title"],
347
- job_change: ["person.job.change"],
348
- job_change_status: ["person.job.change_status"],
349
- company: ["company.name.value"],
350
- company_name: ["company.name.value"],
351
- organization_name: ["company.name.value"],
352
- company_domain: ["company.domain.value"],
353
- domain: ["company.domain.value"],
354
- company_website: ["company.website.url"],
355
- // Also used for a podcast URL.
356
- website: ["company.website.url"],
357
- company_linkedin_url: ["company.linkedin.url"],
358
- industry: ["company.industry.value"],
359
- id: ["person.record.id", "company.record.id"],
360
- // Used for unrelated provider statuses; none is a catalog field.
361
- status: []
362
- };
363
- function fieldOfName(name, declared) {
364
- const meanings = EXTRACTOR_TARGET_FIELDS[name] ?? [];
365
- if (declared === void 0) {
366
- return meanings.length === 1 ? meanings[0] : void 0;
367
- }
368
- return meanings.some((meaning) => fieldSatisfies(declared, meaning)) ? declared : void 0;
369
- }
370
-
371
- // src/cli/described-tool.ts
372
- function isPlayLikeTool(tool) {
373
- const record = tool;
374
- if (record.isPlay === true || record.is_play === true) return true;
375
- const playExpansion = recordField(record, "playExpansion", "play_expansion");
376
- if (Object.keys(playExpansion).length > 0) return true;
377
- const toolId = typeof record.toolId === "string" ? record.toolId : "";
378
- return toolId.endsWith("_waterfall");
379
- }
380
- function isMonitorTypeTool(tool) {
381
- return stringField(tool, "kind") === "monitor_type";
382
- }
383
- function playReferenceForTool(tool) {
384
- const record = tool;
385
- const declared = stringField(record, "playReference", "play_reference");
386
- if (declared.startsWith("prebuilt/")) {
387
- return declared;
388
- }
389
- return null;
390
- }
391
- function playSearchCommandForToolId(toolId) {
392
- return `deepline search --type prebuilts ${JSON.stringify(toolId.replace(/_/g, " "))}`;
393
- }
394
- function playRunCommandForTool(tool, toolId, input) {
395
- const playReference = playReferenceForTool(tool);
396
- if (!playReference) return playSearchCommandForToolId(toolId);
397
- const inputArg = input === void 0 ? "'{...}'" : `'${JSON.stringify(input)}'`;
398
- return `deepline plays run ${playReference} --input ${inputArg}`;
399
- }
400
- function toolContractJsonForDescribe(tool, requestedToolId, authoringContractEdition, seedStarterScript) {
401
- const toolId = String(tool.toolId || requestedToolId);
402
- const inputFields = toolInputFieldsForDisplay(
403
- recordField(tool, "inputSchema", "input_schema")
404
- );
405
- const inputSchema = publicToolInputSchemaForDescribe(
406
- recordField(tool, "inputSchema", "input_schema")
407
- );
408
- const outputSchemaRecord = recordField(tool, "outputSchema", "output_schema");
409
- const outputFields = toolOutputFieldsForDisplay(outputSchemaRecord);
410
- const usageGuidance = recordField(tool, "usageGuidance", "usage_guidance");
411
- const guidance = recordField(tool, "guidance");
412
- const toolExecutionResult = recordField(
413
- usageGuidance,
414
- "toolExecutionResult",
415
- "tool_execution_result"
416
- );
417
- const extractedLists = extractionContractEntries(
418
- arrayField(toolExecutionResult, "extractedLists", "extracted_lists")
419
- ).map((entry) => ({
420
- ...entry,
421
- returnType: playToolListGetterMode(authoringContractEdition) === "array" ? "Array" : "PlayDataset",
422
- rowsExpression: playToolListGetterMode(authoringContractEdition) === "array" ? entry.expression : `await ${entry.expression}.materialize()`
423
- }));
424
- const extractedValues = extractionContractEntries(
425
- arrayField(toolExecutionResult, "extractedValues", "extracted_values")
426
- );
427
- const pricing = Capability.fromCatalogEntry(tool).describe().customerCost();
428
- const executionMetadataRecord = recordField(
429
- tool,
430
- "executionMetadata",
431
- "execution_metadata"
432
- );
433
- const executionMetadata = Object.keys(executionMetadataRecord).length > 0 ? executionMetadataRecord : null;
434
- const batchCapabilityRecord = recordField(
435
- tool,
436
- "batchCapability",
437
- "batch_capability"
438
- );
439
- const batchCapability = Object.keys(batchCapabilityRecord).length > 0 ? batchCapabilityRecord : null;
440
- const deprecation = recordField(tool, "deprecation");
441
- const replacementToolId = stringField(
442
- deprecation,
443
- "replacementToolId",
444
- "replacement_tool_id"
445
- );
446
- const deprecationMessage = stringField(deprecation, "message");
447
- const deprecationExecution = stringField(deprecation, "execution");
448
- const deprecated = tool.deprecated === true || stringField(tool, "credentialStatus", "credential_status") === "deprecated";
449
- const starterScript = seedStarterScript && !deprecated && !isPlayLikeTool(tool) && extractedLists.length > 0 ? starterScriptJson(
450
- seedStarterScript({
451
- toolId,
452
- payload: samplePayloadForInputFields(inputFields),
453
- rows: []
454
- })
455
- ) : null;
456
- const executeCommand = deprecated && replacementToolId ? `deepline tools execute ${replacementToolId} --input '{...}'` : isPlayLikeTool(tool) ? playRunCommandForTool(tool, toolId) : `deepline tools execute ${toolId} --input '{...}'`;
457
- return {
458
- schemaVersion: 1,
459
- toolId,
460
- provider: tool.provider,
461
- displayName: tool.displayName,
462
- cost: pricing,
463
- description: tool.description,
464
- ...Object.keys(guidance).length > 0 ? { guidance } : {},
465
- categories: tool.categories,
466
- ...Array.isArray(tool.requestWarnings) ? { requestWarnings: tool.requestWarnings } : {},
467
- ...deprecated ? {
468
- deprecated: true,
469
- callable: tool.callable !== false,
470
- deprecation: {
471
- replacementToolId,
472
- message: deprecationMessage,
473
- ...deprecationExecution ? { execution: deprecationExecution } : {}
474
- }
475
- } : {},
476
- inputFields: inputFields.map(inputFieldJsonForDescribe),
477
- inputSchema,
478
- ...isRecord(tool.responseSchema) ? { responseSchema: tool.responseSchema } : {},
479
- ...Array.isArray(tool.examples) ? { examples: tool.examples } : {},
480
- responseAccess: "result.toolResponse.rawV2",
481
- ...Object.keys(outputSchemaRecord).length > 0 ? {
482
- outputSchema: publicToolInputSchemaForDescribe(outputSchemaRecord),
483
- outputFields: outputFields.map(inputFieldJsonForDescribe)
484
- } : {},
485
- ...executionMetadata ? { executionMetadata } : {},
486
- ...batchCapability ? { batchCapability } : {},
487
- getters: {
488
- extractedLists,
489
- extractedValues
490
- },
491
- executeCommand,
492
- ...starterScript ? { starterScript } : {}
493
- };
494
- }
495
- function extractionContractEntries(entries) {
496
- return entries.flatMap((entry) => {
497
- if (!isRecord(entry)) return [];
498
- const name = stringField(entry, "name");
499
- const expression = stringField(entry, "expression");
500
- return name && expression ? [{ name, expression }] : [];
501
- });
502
- }
503
- function schemaNodeAt(schema, path) {
504
- let node = schema;
505
- for (const part of path.split(".").filter(Boolean)) {
506
- const [key, ...indexes] = part.split("[");
507
- node = recordField(isRecord(node) ? node : {}, "properties")[key];
508
- for (const _index of indexes)
509
- node = isRecord(node) ? node.items : void 0;
510
- }
511
- return node;
512
- }
513
- var NAMED_VALUE_SHAPES = {
514
- email_status: { shape: "EmailStatus", schema: EMAIL_STATUS_JSON_SCHEMA },
515
- job_change: { shape: "JobChange", schema: JOB_CHANGE_JSON_SCHEMA }
516
- };
517
- function extractorValueType(name) {
518
- if (!isDeeplineExtractorTarget(name)) return void 0;
519
- const definition = DEEPLINE_EXTRACTOR_TARGET_DEFINITIONS[name];
520
- if (definition.enum) {
521
- return {
522
- type: definition.enum.map((value2) => JSON.stringify(value2)).join(" | ")
523
- };
524
- }
525
- const named = NAMED_VALUE_SHAPES[definition.valueKind];
526
- if (!named) return { type: "string" };
527
- const { type, fields } = schemaField(name, named.schema, true);
528
- return { type, ...fields ? { fields } : {}, shape: named.shape };
529
- }
530
- function jsonSchemaOf(wrapper) {
531
- return isRecord(wrapper.jsonSchema) ? wrapper.jsonSchema : wrapper;
532
- }
533
- function publicToolSchemas(tool) {
534
- const scrubbed = (...keys) => {
535
- const schema = recordField(tool, ...keys);
536
- if (Object.keys(schema).length === 0) return null;
537
- const cleaned = publicToolInputSchemaForDescribe(schema);
538
- return isRecord(cleaned.jsonSchema) ? cleaned.jsonSchema : cleaned;
539
- };
540
- const responseSchema = scrubbed("responseSchema", "response_schema");
541
- return {
542
- inputSchema: scrubbed(
543
- "inputSchema",
544
- "input_schema",
545
- "payload_schema",
546
- "payloadSchema"
547
- ),
548
- outputSchema: scrubbed("outputSchema", "output_schema"),
549
- ...responseSchema ? { responseSchema } : {}
550
- };
551
- }
552
- function describedTool(tool, requestedToolId) {
553
- const id = stringField(tool, "toolId") || requestedToolId;
554
- const displayName = stringField(tool, "displayName") || void 0;
555
- const description = stringField(tool, "bestFor", "best_for") || stringField(tool, "description") || void 0;
556
- if (isMonitorTypeTool(tool)) {
557
- return {
558
- kind: "monitor_type",
559
- id,
560
- displayName,
561
- description,
562
- cost: stringField(recordField(tool, "pricing"), "displayText") || void 0,
563
- guidance: [],
564
- inputs: schemaFields(
565
- recordField(tool, "payload_schema", "payloadSchema")
566
- ),
567
- outputs: [],
568
- runner: {
569
- via: "monitor",
570
- deploy: stringField(recordField(tool, "deploy"), "example") || `deepline monitors deploy '{"key":"...","tool":"${id}","payload":{...}}'`
571
- }
572
- };
573
- }
574
- const contract = toolContractJsonForDescribe(tool, requestedToolId);
575
- const cost = recordField(contract, "cost");
576
- const billing = stringField(cost, "billingSourceLabel");
577
- const deprecation = recordField(contract, "deprecation");
578
- const getters = recordField(contract, "getters");
579
- const outputSchema = jsonSchemaOf(recordField(contract, "outputSchema"));
580
- const toolResult = recordField(tool, "toolResult", "tool_result");
581
- const getterDetails = (kind) => new Map(
582
- arrayField(toolResult, kind).filter(isRecord).map((item) => [
583
- stringField(item, "name"),
584
- recordField(item, "details")
585
- ])
586
- );
587
- const declared = recordField(tool, "extractors");
588
- const getterOutputs = (kind, roots) => {
589
- const details = getterDetails(kind);
590
- return arrayField(getters, kind).filter(isRecord).map((entry) => {
591
- const name = stringField(entry, "name");
592
- const rawPaths = arrayField(
593
- details.get(name) ?? {},
594
- "rawToolOutputPaths"
595
- ).map(String);
596
- const paths = rawPaths.map(
597
- (path) => path.replace(/^toolResponse\.raw\./, "")
598
- );
599
- const node = roots.flatMap((root) => paths.map((path) => schemaNodeAt(root, path))).find(isRecord);
600
- const { fields, ...typed } = schemaField(name, node, true);
601
- const valueType = stringField(details.get(name) ?? {}, "valueType");
602
- const deepline = kind === "extractedValues" ? extractorValueType(name) : void 0;
603
- const known = typed.type !== "unknown" ? void 0 : kind === "extractedLists" ? { type: "object[]" } : deepline;
604
- const means = kind === "extractedValues" ? fieldOfName(
605
- name,
606
- stringField(declared[name] ?? {}, "means") || void 0
607
- ) : void 0;
608
- const field = {
609
- ...typed,
610
- ...means ? { means } : {},
611
- // A normalized value has a named type instead of the response's
612
- // shape; a normalized object is spelled out once under Types.
613
- ...deepline?.shape ? deepline : valueType ? { type: valueType } : known ? known : fields ? { fields } : {},
614
- // A list's row columns that matter are value getters of their own.
615
- ...kind === "extractedLists" && fields ? { summarized: true } : {},
616
- read: playResultExpression(entry),
617
- ...rawPaths.length ? { paths: rawPaths } : {}
618
- };
619
- return { field, node };
620
- });
621
- };
622
- const declaredLists = getterOutputs("extractedLists", [outputSchema]);
623
- const lists = declaredLists.some(({ node }) => node) ? declaredLists.filter(({ node }) => node) : declaredLists;
624
- const values = getterOutputs("extractedValues", [
625
- outputSchema,
626
- ...lists.map(({ node }) => node?.items)
627
- ]).map((value2) => {
628
- if (!lists.length || !value2.field.paths) return value2;
629
- const within = value2.field.paths.map(
630
- (path) => path.replace(/^toolResponse\.raw\./, "")
631
- );
632
- const list = lists.find(
633
- ({ node }) => within.some((path) => isRecord(schemaNodeAt(node?.items, path)))
634
- ) ?? lists[0];
635
- return {
636
- ...value2,
637
- field: { ...value2.field, in: list.field.name, paths: within }
638
- };
639
- });
640
- const playReference = isPlayLikeTool(tool) ? playReferenceForTool(tool) : null;
641
- return {
642
- kind: "tool",
643
- id: String(contract.toolId),
644
- displayName,
645
- description,
646
- cost: [
647
- stringField(cost, "displayText"),
648
- // "Free (free)" says the same thing twice.
649
- billing.toLowerCase() === stringField(cost, "displayText").toLowerCase() ? "" : billing && `(${billing})`,
650
- observedMaxText(cost) && `\u2014 ${observedMaxText(cost)}`
651
- ].filter(Boolean).join(" ") || void 0,
652
- guidance: [
653
- ...contract.deprecated === true ? [`Deprecated. ${stringField(deprecation, "message")}`.trim()] : [],
654
- ...Object.values(recordField(contract, "guidance")).filter(
655
- (line) => typeof line === "string" && /[a-z0-9]/i.test(line)
656
- )
657
- ],
658
- rateLimit: rateLimitSummary(
659
- recordField(contract, "executionMetadata").configuredRateLimits
660
- ),
661
- inputs: schemaFields(jsonSchemaOf(recordField(contract, "inputSchema"))),
662
- outputs: [...lists, ...values].map(({ field }) => field),
663
- rawResponse: schemaFields(outputSchema),
664
- runner: playReference ? { via: "play", reference: playReference } : { via: "tool", toolId: String(contract.toolId) }
665
- };
666
- }
667
- function sampleValueForField(field) {
668
- const name = stringField(field, "name").toLowerCase();
669
- const type = stringField(field, "type").toLowerCase();
670
- if (Object.prototype.hasOwnProperty.call(field, "default"))
671
- return field.default;
672
- if (name.includes("email")) return "ada@example.com";
673
- if (name.includes("domain") || name.includes("website")) return "example.com";
674
- if (name.includes("first")) return "Ada";
675
- if (name.includes("last")) return "Lovelace";
676
- if (name.includes("name")) return "Ada Lovelace";
677
- if (type === "integer" || type === "number") return 1;
678
- if (type === "boolean") return true;
679
- if (type === "array") return [];
680
- if (type === "object") return {};
681
- return "...";
682
- }
683
- function samplePayloadForInputFields(fields) {
684
- return Object.fromEntries(
685
- fields.slice(0, 4).flatMap((field) => {
686
- if (!isRecord(field)) return [];
687
- const name = stringField(field, "name");
688
- if (!name) return [];
689
- return [[name, sampleValueForField(field)]];
690
- })
691
- );
692
- }
693
- function playResultExpression(entry) {
694
- return stringField(entry, "expression").replace(
695
- /^toolExecutionResult\./,
696
- "result."
697
- );
698
- }
699
- function toolMetadataJsonForDescribe(tool, requestedToolId, seedStarterScript) {
700
- const toolId = String(tool.toolId || requestedToolId);
701
- const inputFields = toolInputFieldsForDisplay(
702
- recordField(tool, "inputSchema", "input_schema")
703
- );
704
- const usageGuidance = usageGuidanceWithAccessDefaults(
705
- recordField(tool, "usageGuidance", "usage_guidance")
706
- );
707
- const toolExecutionResult = recordField(
708
- usageGuidance,
709
- "toolExecutionResult",
710
- "tool_execution_result"
711
- );
712
- const extractedLists = extractionContractEntries(
713
- arrayField(toolExecutionResult, "extractedLists", "extracted_lists")
714
- );
715
- const starterScript = seedStarterScript && !isPlayLikeTool(tool) && extractedLists.length > 0 ? starterScriptJson(
716
- seedStarterScript({
717
- toolId,
718
- payload: samplePayloadForInputFields(inputFields),
719
- rows: []
720
- })
721
- ) : null;
722
- const observedOutputCommand = isPlayLikeTool(tool) ? playRunCommandForTool(tool, toolId) : `deepline tools execute ${toolId} --input '{...}'`;
723
- const {
724
- cost: _cost,
725
- deeplineCreditsPerPricingUnit: _deeplineCreditsPerPricingUnit,
726
- deeplineUsdPerPricingUnit: _deeplineUsdPerPricingUnit,
727
- deeplineUsdPerCredit: _deeplineUsdPerCredit,
728
- deeplinePricingSummary: _deeplinePricingSummary,
729
- deeplinePricingDetails: _deeplinePricingDetails,
730
- deepline_credits_per_pricing_unit: _snakeDeeplineCreditsPerPricingUnit,
731
- deepline_usd_per_pricing_unit: _snakeDeeplineUsdPerPricingUnit,
732
- deepline_usd_per_credit: _snakeDeeplineUsdPerCredit,
733
- deepline_pricing_summary: _snakeDeeplinePricingSummary,
734
- deepline_pricing_details: _snakeDeeplinePricingDetails,
735
- // BYOK is shown only on request, via describe --feature byok.
736
- byok: _byok,
737
- ...publicTool
738
- } = tool;
739
- const outputSchemaRecord = recordField(tool, "outputSchema", "output_schema");
740
- return {
741
- cost: Capability.fromCatalogEntry(tool).describe().customerCost(),
742
- ...publicTool,
743
- toolId,
744
- provider: tool.provider,
745
- displayName: tool.displayName,
746
- ...Object.keys(outputSchemaRecord).length > 0 ? {
747
- outputSchema: publicToolInputSchemaForDescribe(outputSchemaRecord),
748
- outputFields: toolOutputFieldsForDisplay(outputSchemaRecord).map(
749
- inputFieldJsonForDescribe
750
- )
751
- } : {},
752
- inputFields: inputFields.map(inputFieldJsonForDescribe),
753
- usageGuidance,
754
- runtimeOutputHelp: {
755
- contract: "Schemas declare field shapes. Examples illustrate input payloads and full Deepline execution responses; they are not observed responses from this call.",
756
- getterScope: "extractedValues/extractedLists .get() only works for declared Deepline getters listed in usageGuidance.toolExecutionResult.",
757
- rawToolResponse: "Use toolExecutionResult.toolResponse.rawV2 for the complete tool response. Preserve its nesting and sibling fields as shown in examples; use declared getters for extracted values and lists.",
758
- invalidGetterHint: "If TypeScript says an extractedValues/extractedLists property does not exist, that field is not a declared Deepline getter.",
759
- observeActualShape: observedOutputCommand,
760
- observedOutput: observedOutputCommand,
761
- forPlayGetterBugs: "Run a tiny play, inspect returned handles with `deepline runs get <run-id> --full`, then export row datasets with `deepline runs export`.",
762
- executeOutputFields: "tools execute JSON may include output_preview for this direct probe only; play debugging uses run output and returned dataset handles."
763
- },
764
- ...starterScript ? { starterScript } : {}
765
- };
766
- }
767
- function usageGuidanceWithAccessDefaults(usageGuidance) {
768
- if (Object.keys(usageGuidance).length === 0) return usageGuidance;
769
- const existingAccess = recordField(usageGuidance, "access");
770
- return {
771
- ...usageGuidance,
772
- prefer: [
773
- "Use only the declared extractedLists and extractedValues getters listed below.",
774
- "Use toolExecutionResult.toolResponse.rawV2 for the complete tool response, preserving the nesting shown in the response example.",
775
- "Schemas declare field shapes; examples illustrate input values and full Deepline execution responses."
776
- ],
777
- toolExecutionResult: {
778
- ...recordField(
779
- usageGuidance,
780
- "toolExecutionResult",
781
- "tool_execution_result"
782
- ),
783
- toolResponse: {
784
- rawV2: "toolResponse.rawV2",
785
- view: "toolResponse.view",
786
- responseMeta: "toolResponse.responseMeta"
787
- }
788
- },
789
- access: {
790
- ...existingAccess,
791
- extractedValues: {
792
- expression: "toolExecutionResult.extractedValues.<name>.get()",
793
- meaning: "Declared Deepline scalar or normalized object extractors only."
794
- },
795
- ...existingAccess,
796
- extractedLists: {
797
- ...recordField(existingAccess, "extractedLists"),
798
- expression: "toolExecutionResult.extractedLists.<name>.get()",
799
- meaning: playToolListGetterMode() === "array" ? "Returns an ordinary array from this response. Use array methods directly or pass it to ctx.dataset to persist row work. Lazy or incomplete lists throw; use readList for an explicit dataset read. It does not fetch provider pages." : "Returns a PlayDataset, not a JavaScript array. Pass the handle to ctx.dataset, use first(), async iteration, or await handle.materialize() for the complete current list within the memory cap. materialize(n) and peek(n) return a prefix; none fetch additional provider pages. A missing getter is not an empty list."
800
- },
801
- rawToolResponse: {
802
- expression: "toolExecutionResult.toolResponse.rawV2",
803
- meaning: "Complete tool response with its original nesting. Read tool-specific fields here; use declared getters for extracted values and lists."
804
- },
805
- canonicalToolResponse: {
806
- expression: "toolExecutionResult.toolResponse.rawV2",
807
- meaning: "Complete tool response with its original nesting and sibling fields."
808
- },
809
- invalidGetterHint: "If TypeScript says an extractedValues/extractedLists property does not exist, that field is not a declared Deepline getter; read it from toolResponse.rawV2 using the nesting shown in the response example."
810
- }
811
- };
812
- }
813
- function toolInputFieldsForDisplay(inputSchema) {
814
- if (Array.isArray(inputSchema.fields)) {
815
- const fields = inputSchema.fields.filter(isRecord);
816
- if (!isRecord(inputSchema.jsonSchema)) return fields;
817
- const jsonSchemaFields = new Map(
818
- recursiveToolInputFieldsForDisplay({
819
- jsonSchema: inputSchema.jsonSchema
820
- }).flatMap(
821
- (field) => typeof field.name === "string" ? [[field.name, field]] : []
822
- )
823
- );
824
- return fields.map((field) => {
825
- const jsonSchemaField = typeof field.name === "string" ? jsonSchemaFields.get(field.name) : void 0;
826
- const minItems = typeof field.minItems === "number" ? field.minItems : jsonSchemaField?.minItems;
827
- const maxItems = typeof field.maxItems === "number" ? field.maxItems : jsonSchemaField?.maxItems;
828
- const items = isRecord(field.items) ? field.items : jsonSchemaField?.items;
829
- return {
830
- ...field,
831
- ...isRecord(items) ? { items } : {},
832
- ...typeof minItems === "number" ? { minItems } : {},
833
- ...typeof maxItems === "number" ? { maxItems } : {}
834
- };
835
- });
836
- }
837
- const jsonSchema = isRecord(inputSchema.jsonSchema) ? inputSchema.jsonSchema : inputSchema;
838
- const properties = isRecord(jsonSchema.properties) ? jsonSchema.properties : {};
839
- const required = Array.isArray(jsonSchema.required) ? new Set(jsonSchema.required.map(String)) : /* @__PURE__ */ new Set();
840
- return Object.entries(properties).map(([name, value2]) => {
841
- const property = isRecord(value2) ? value2 : {};
842
- return {
843
- name,
844
- type: typeof property.type === "string" ? property.type : "unknown",
845
- required: required.has(name),
846
- description: property.description,
847
- ...isRecord(property.items) ? { items: property.items } : {},
848
- ...typeof property.minItems === "number" ? { minItems: property.minItems } : {},
849
- ...typeof property.maxItems === "number" ? { maxItems: property.maxItems } : {},
850
- ...Object.prototype.hasOwnProperty.call(property, "default") ? { default: property.default } : {}
851
- };
852
- });
853
- }
854
- function toolOutputFieldsForDisplay(outputSchema) {
855
- if (Object.keys(outputSchema).length === 0) return [];
856
- return recursiveToolInputFieldsForDisplay({
857
- jsonSchema: outputSchema
858
- }).filter(
859
- (field) => typeof field.name === "string" && field.name.includes("[]")
860
- );
861
- }
862
- function canonicalToolJsonSchema(inputSchema) {
863
- return isRecord(inputSchema.jsonSchema) ? inputSchema.jsonSchema : inputSchema;
864
- }
865
- function publicToolInputSchemaForDescribe(inputSchema) {
866
- const exposesProviderSpend = (description) => {
867
- const withoutDeeplineCredits = description.replace(
868
- /\bdeepline(?:-facing)?\s+credits?\b/gi,
869
- ""
870
- );
871
- return /\bcredits?\b/i.test(withoutDeeplineCredits) || /\bprovider\s+(?:cost|spend|price|pricing|usage)\b/i.test(
872
- withoutDeeplineCredits
873
- ) || /\b(?:costs?|charges?|priced at)\s+[$€£]\s*\d/i.test(
874
- withoutDeeplineCredits
875
- ) || /\b(?:costs?|charges?|priced at)\s+\d+(?:\.\d+)?\s*(?:usd|eur|gbp)\b/i.test(
876
- withoutDeeplineCredits
877
- ) || /\battribute-priced\b/i.test(withoutDeeplineCredits) || /\b(?:cost|price|pricing)\s+(?:grows?|increases?|scales?|varies?)\b/i.test(
878
- withoutDeeplineCredits
879
- ) || /\b(?:will be|are|is|be)\s+(?:billed|charged)\b/i.test(
880
- withoutDeeplineCredits
881
- ) || /\b(?:additional|extra)\s+charges?\b/i.test(withoutDeeplineCredits) || /\bcharg(?:e|ed)\s+(?:double|per)\b/i.test(withoutDeeplineCredits) || /\bpricing page\b/i.test(withoutDeeplineCredits);
882
- };
883
- const stripDescriptions = (value2) => {
884
- if (Array.isArray(value2)) return value2.map(stripDescriptions);
885
- if (!isRecord(value2)) return value2;
886
- return Object.fromEntries(
887
- Object.entries(value2).flatMap(([key, nested]) => {
888
- if (key === "description" && typeof nested === "string" && exposesProviderSpend(nested)) {
889
- return [];
890
- }
891
- return [[key, stripDescriptions(nested)]];
892
- })
893
- );
894
- };
895
- return stripDescriptions(inputSchema);
896
- }
897
- function recursiveToolInputFieldsForDisplay(inputSchema) {
898
- const root = canonicalToolJsonSchema(inputSchema);
899
- const fields = /* @__PURE__ */ new Map();
900
- const schemasById = /* @__PURE__ */ new Map();
901
- const collectSchemaIds = (value2) => {
902
- if (Array.isArray(value2)) {
903
- for (const item of value2) collectSchemaIds(item);
904
- return;
905
- }
906
- if (!isRecord(value2)) return;
907
- if (typeof value2.$id === "string" && value2.$id.trim()) {
908
- schemasById.set(value2.$id.trim(), value2);
909
- }
910
- for (const nested of Object.values(value2)) collectSchemaIds(nested);
911
- };
912
- collectSchemaIds(root);
913
- const resolveRef = (schema) => {
914
- const ref = typeof schema.$ref === "string" ? schema.$ref : "";
915
- if (!ref.startsWith("#/")) return schemasById.get(ref) ?? schema;
916
- let current = root;
917
- for (const rawSegment of ref.slice(2).split("/")) {
918
- const segment = rawSegment.replace(/~1/g, "/").replace(/~0/g, "~");
919
- if (!isRecord(current)) return schema;
920
- current = current[segment];
921
- }
922
- return isRecord(current) ? current : schema;
923
- };
924
- const addField = (field) => {
925
- const name = typeof field.name === "string" ? field.name : "";
926
- if (!name) return;
927
- const existing = fields.get(name);
928
- if (!existing || existing.type === "unknown") {
929
- fields.set(name, field);
930
- }
931
- };
932
- const visit = (unresolvedSchema, path, required, activeRefs = /* @__PURE__ */ new Set()) => {
933
- const ref = typeof unresolvedSchema.$ref === "string" ? unresolvedSchema.$ref : "";
934
- if (ref && activeRefs.has(ref)) return;
935
- const schema = resolveRef(unresolvedSchema);
936
- const nextActiveRefs = ref ? /* @__PURE__ */ new Set([...activeRefs, ref]) : activeRefs;
937
- const type = Array.isArray(schema.type) ? schema.type.map(String).join("|") : typeof schema.type === "string" ? schema.type : isRecord(schema.properties) ? "object" : schema.items ? "array" : "unknown";
938
- if (path) {
939
- addField({
940
- name: path,
941
- type,
942
- required,
943
- description: schema.description,
944
- ...Array.isArray(schema.enum) ? { enum: schema.enum } : {},
945
- ...isRecord(schema.items) ? { items: schema.items } : {},
946
- ...typeof schema.minItems === "number" ? { minItems: schema.minItems } : {},
947
- ...typeof schema.maxItems === "number" ? { maxItems: schema.maxItems } : {},
948
- ...Object.prototype.hasOwnProperty.call(schema, "default") ? { default: schema.default } : {}
949
- });
950
- }
951
- const properties = isRecord(schema.properties) ? schema.properties : {};
952
- const requiredNames = new Set(
953
- Array.isArray(schema.required) ? schema.required.map(String) : []
954
- );
955
- for (const [name, value2] of Object.entries(properties)) {
956
- if (!isRecord(value2)) continue;
957
- visit(
958
- value2,
959
- path ? `${path}.${name}` : name,
960
- requiredNames.has(name),
961
- nextActiveRefs
962
- );
963
- }
964
- if (isRecord(schema.items)) {
965
- visit(schema.items, `${path}[]`, false, nextActiveRefs);
966
- }
967
- for (const keyword of ["anyOf", "oneOf", "allOf"]) {
968
- const branches = Array.isArray(schema[keyword]) ? schema[keyword] : [];
969
- for (const branch of branches) {
970
- if (isRecord(branch)) {
971
- visit(branch, path, required, nextActiveRefs);
972
- }
973
- }
974
- }
975
- };
976
- visit(root, "", false);
977
- return fields.size ? [...fields.values()] : toolInputFieldsForDisplay(inputSchema);
978
- }
979
- function inputFieldJsonForDescribe(field) {
980
- const publicItems = isRecord(field.items) ? publicToolInputSchemaForDescribe({ items: field.items }).items : void 0;
981
- return {
982
- name: field.name,
983
- type: field.type ?? "unknown",
984
- required: Boolean(field.required),
985
- ...field.description ? { description: field.description } : {},
986
- ...isRecord(publicItems) ? { items: publicItems } : {},
987
- ...typeof field.minItems === "number" ? { minItems: field.minItems } : {},
988
- ...typeof field.maxItems === "number" ? { maxItems: field.maxItems } : {},
989
- ...Object.prototype.hasOwnProperty.call(field, "default") ? { default: field.default } : {}
990
- };
991
- }
992
- function isRecord(value2) {
993
- return Boolean(value2 && typeof value2 === "object" && !Array.isArray(value2));
994
- }
995
- function stringField(source, ...keys) {
996
- for (const key of keys) {
997
- const value2 = source[key];
998
- if (typeof value2 === "string" && value2.trim()) return value2.trim();
999
- }
1000
- return "";
1001
- }
1002
- function arrayField(source, ...keys) {
1003
- for (const key of keys) {
1004
- const value2 = source[key];
1005
- if (Array.isArray(value2)) return value2;
1006
- }
1007
- return [];
1008
- }
1009
- function recordField(source, ...keys) {
1010
- for (const key of keys) {
1011
- const value2 = source[key];
1012
- if (isRecord(value2)) return value2;
1013
- }
1014
- return {};
1015
- }
1016
- function starterScriptJson(script) {
1017
- return {
1018
- path: script.path,
1019
- sourceCode: script.sourceCode,
1020
- projectDir: script.projectDir,
1021
- copyToProject: {
1022
- macosLinux: script.macCopyCommand,
1023
- windowsPowerShell: script.windowsCopyCommand
1024
- }
1025
- };
1026
- }
1027
-
1028
212
  // ../plays/tool-category-descriptions.ts
1029
213
  var TOOL_CATEGORY_DESCRIPTIONS = {
1030
214
  company_search: "Find companies matching firmographic, ad, or web criteria.",
@@ -1055,66 +239,6 @@ function describeToolCategory(category) {
1055
239
  return TOOL_CATEGORY_DESCRIPTIONS[category] ?? null;
1056
240
  }
1057
241
 
1058
- // src/cli/commands/model-description.ts
1059
- function formatModelDescription(description) {
1060
- const lines = [];
1061
- lines.push(description.model);
1062
- lines.push(`Provider: ${description.provider}`);
1063
- const name = stringField2(description.modelMetadata, "name");
1064
- if (name) lines.push(`Name: ${name}`);
1065
- const contextWindow = numberField(
1066
- description.modelMetadata,
1067
- "context_window"
1068
- );
1069
- if (contextWindow !== null) lines.push(`Context: ${contextWindow}`);
1070
- const tags = arrayField2(description.modelMetadata, "tags").filter(
1071
- (value2) => typeof value2 === "string"
1072
- );
1073
- if (tags.length) lines.push(`Tags: ${tags.join(", ")}`);
1074
- lines.push("");
1075
- lines.push("Provider options:");
1076
- appendNamespace(lines, description.providerOptions.gateway);
1077
- if (description.providerOptions.selectedProvider) {
1078
- appendNamespace(lines, description.providerOptions.selectedProvider);
1079
- }
1080
- lines.push("");
1081
- lines.push("Example input:");
1082
- lines.push(JSON.stringify(description.exampleInput, null, 2));
1083
- if (description.caveats.length) {
1084
- lines.push("");
1085
- lines.push("Caveats:");
1086
- for (const caveat of description.caveats) {
1087
- lines.push(`- ${caveat}`);
1088
- }
1089
- }
1090
- return `${lines.join("\n")}
1091
- `;
1092
- }
1093
- function appendNamespace(lines, namespace) {
1094
- lines.push(`- ${namespace.provider} (${namespace.sourceSymbol})`);
1095
- for (const field of namespace.fields) {
1096
- const values = field.enumValues?.length ? ` (${field.enumValues.map((value2) => JSON.stringify(value2)).join(" | ")})` : "";
1097
- lines.push(
1098
- ` - ${field.name}: ${field.type}${values} - ${field.description}`
1099
- );
1100
- }
1101
- }
1102
- function stringField2(value2, key) {
1103
- if (!value2 || typeof value2 !== "object" || Array.isArray(value2)) return null;
1104
- const candidate = value2[key];
1105
- return typeof candidate === "string" && candidate.trim() ? candidate.trim() : null;
1106
- }
1107
- function numberField(value2, key) {
1108
- if (!value2 || typeof value2 !== "object" || Array.isArray(value2)) return null;
1109
- const candidate = value2[key];
1110
- return typeof candidate === "number" ? candidate : null;
1111
- }
1112
- function arrayField2(value2, key) {
1113
- if (!value2 || typeof value2 !== "object" || Array.isArray(value2)) return [];
1114
- const candidate = value2[key];
1115
- return Array.isArray(candidate) ? candidate : [];
1116
- }
1117
-
1118
242
  // src/cli/tool-connection-status.ts
1119
243
  function toolConnectionStatusMessage(input) {
1120
244
  if (input.credentialStatus === "requires_connection") {
@@ -1149,15 +273,15 @@ function toListedTool(tool) {
1149
273
  executeCommand: `deepline tools execute ${tool.toolId}`
1150
274
  };
1151
275
  }
1152
- function normalizeGrepText(value2) {
1153
- if (value2 === null || value2 === void 0) return "";
1154
- if (typeof value2 === "string") return value2.toLowerCase();
1155
- if (typeof value2 === "number" || typeof value2 === "boolean") {
1156
- return String(value2).toLowerCase();
276
+ function normalizeGrepText(value) {
277
+ if (value === null || value === void 0) return "";
278
+ if (typeof value === "string") return value.toLowerCase();
279
+ if (typeof value === "number" || typeof value === "boolean") {
280
+ return String(value).toLowerCase();
1157
281
  }
1158
- if (Array.isArray(value2)) return value2.map(normalizeGrepText).join(" ");
1159
- if (typeof value2 === "object") {
1160
- return Object.values(value2).map(normalizeGrepText).join(" ");
282
+ if (Array.isArray(value)) return value.map(normalizeGrepText).join(" ");
283
+ if (typeof value === "object") {
284
+ return Object.values(value).map(normalizeGrepText).join(" ");
1161
285
  }
1162
286
  return "";
1163
287
  }
@@ -1168,15 +292,15 @@ function parseGrepTerms(query, mode) {
1168
292
  const matches = trimmed.match(/"([^"]+)"|'([^']+)'|\S+/g) ?? [];
1169
293
  return matches.map((term) => term.replace(/^["']|["']$/g, "").trim()).filter(Boolean);
1170
294
  }
1171
- function matchesGrepQuery(value2, query, mode) {
295
+ function matchesGrepQuery(value, query, mode) {
1172
296
  const terms = parseGrepTerms(query, mode);
1173
297
  if (terms.length === 0) return true;
1174
- const haystack = normalizeGrepText(value2);
298
+ const haystack = normalizeGrepText(value);
1175
299
  if (mode === "any") return terms.some((term) => haystack.includes(term));
1176
300
  return terms.every((term) => haystack.includes(term));
1177
301
  }
1178
- function shellCommandArg(value2) {
1179
- return `'${value2.replace(/'/g, `'\\''`)}'`;
302
+ function shellCommandArg(value) {
303
+ return `'${value.replace(/'/g, `'\\''`)}'`;
1180
304
  }
1181
305
  function zeroMatchToolGuidance(options) {
1182
306
  const categories = options.categories ?? [];
@@ -1261,7 +385,7 @@ function shortPricingHint(tool) {
1261
385
  tool,
1262
386
  "pricing"
1263
387
  );
1264
- const credits = numberField2(pricing, "creditsPerUnit", "credits_per_unit");
388
+ const credits = numberField(pricing, "creditsPerUnit", "credits_per_unit");
1265
389
  const unit = stringField(pricing, "unit");
1266
390
  if (credits !== null) {
1267
391
  return `${formatDecimal(credits)} cr/${unit || "unit"}`;
@@ -1553,8 +677,8 @@ async function grepTools(queryInput, options = {}) {
1553
677
  return 0;
1554
678
  }
1555
679
  function numericToolField(tool, field) {
1556
- const value2 = tool[field];
1557
- return typeof value2 === "number" ? value2 : void 0;
680
+ const value = tool[field];
681
+ return typeof value === "number" ? value : void 0;
1558
682
  }
1559
683
  function compactTool(tool) {
1560
684
  const listed = toListedTool(tool);
@@ -1574,7 +698,7 @@ function compactTool(tool) {
1574
698
  };
1575
699
  }
1576
700
  function playIdentifiers(play) {
1577
- return [play.name, play.reference, ...play.aliases ?? []].filter((value2) => Boolean(value2?.trim())).map((value2) => value2.trim());
701
+ return [play.name, play.reference, ...play.aliases ?? []].filter((value) => Boolean(value?.trim())).map((value) => value.trim());
1578
702
  }
1579
703
  async function findPlayForToolId(client, toolId, cliInvocationId) {
1580
704
  const requested = toolId.trim();
@@ -1661,7 +785,7 @@ Output:
1661
785
  "Unable to read --credentials-file as a JSON object."
1662
786
  );
1663
787
  }
1664
- if (!credentials || typeof credentials !== "object" || Array.isArray(credentials) || Object.keys(credentials).length === 0 || Object.values(credentials).some((value2) => typeof value2 !== "string")) {
788
+ if (!credentials || typeof credentials !== "object" || Array.isArray(credentials) || Object.keys(credentials).length === 0 || Object.values(credentials).some((value) => typeof value !== "string")) {
1665
789
  throw new Error(
1666
790
  "--credentials-file must contain a nonempty JSON object of string credential values."
1667
791
  );
@@ -1817,7 +941,7 @@ Examples:
1817
941
  process.exitCode = await narrowView();
1818
942
  return;
1819
943
  }
1820
- const { describeAnything } = await import("./describe-6O2ENKTP.mjs");
944
+ const { describeAnything } = await import("./describe-S6BFANVI.mjs");
1821
945
  process.exitCode = await describeAnything(
1822
946
  toolId,
1823
947
  {
@@ -1862,8 +986,8 @@ Examples:
1862
986
  ).option(
1863
987
  "-p, --param <key=value>",
1864
988
  "Pass one parameter. Repeat for multiple values.",
1865
- (value2, acc) => {
1866
- acc.push(value2);
989
+ (value, acc) => {
990
+ acc.push(value);
1867
991
  return acc;
1868
992
  },
1869
993
  []
@@ -2100,7 +1224,7 @@ function printMonitorTypeFilterExamples(tool) {
2100
1224
  const example = stringField(grammar, "example");
2101
1225
  const values = [
2102
1226
  ...arrayField(grammar, "examples").filter(
2103
- (value2) => typeof value2 === "string" && Boolean(value2)
1227
+ (value) => typeof value === "string" && Boolean(value)
2104
1228
  ),
2105
1229
  ...example ? [example] : []
2106
1230
  ];
@@ -2140,7 +1264,7 @@ function monitorTypePricingLines(tool) {
2140
1264
  const lines = ["Pricing (Deepline credits per accepted event):"];
2141
1265
  for (const key of keys) {
2142
1266
  const entry = isRecord(byType[key]) ? byType[key] : {};
2143
- const credits = numberField2(entry, "deepline_credits", "deeplineCredits");
1267
+ const credits = numberField(entry, "deepline_credits", "deeplineCredits");
2144
1268
  const display = stringField(entry, "display");
2145
1269
  const shown = display || (credits !== null ? `${formatDecimal(credits)} credits/event` : "not listed");
2146
1270
  lines.push(`- ${key}: ${shown}`);
@@ -2313,8 +1437,8 @@ function toolPricingOnlyLines(tool, requestedToolId, options = {}) {
2313
1437
  const billing = stringField(cost, "billingSourceLabel") || stringField(cost, "billingSource") || stringField(cost, "billingMode") || "unknown";
2314
1438
  const explicitUnit = stringField(cost, "unit");
2315
1439
  const unit = explicitUnit || (pricingModel === "per_page" ? "page" : pricingModel === "per_result" ? "result" : pricingModel === "fixed" ? "call" : pricingModel.replace(/^per_/, "") || "unit");
2316
- const credits = numberField2(cost, "deeplineCreditsPerPricingUnit");
2317
- const usd = numberField2(cost, "deeplineUsdPerPricingUnit");
1440
+ const credits = numberField(cost, "deeplineCreditsPerPricingUnit");
1441
+ const usd = numberField(cost, "deeplineUsdPerPricingUnit");
2318
1442
  const displayText = stringField(cost, "displayText");
2319
1443
  const summary = stringField(cost, "summary");
2320
1444
  const price = displayText || summary || (credits !== null ? `${formatDecimal(credits)} Deepline credits${usd !== null ? ` / ${formatUsd(usd)}` : ""} per ${unit}` : "pricing unavailable");
@@ -2539,9 +1663,9 @@ function safeIdentifier(name) {
2539
1663
  const cleaned = name.replace(/[^a-zA-Z0-9_$]+/g, "_").replace(/^[^a-zA-Z_$]+/, "");
2540
1664
  return cleaned || "value";
2541
1665
  }
2542
- function singleLineText(value2, maxLength = 260) {
2543
- if (typeof value2 !== "string") return "";
2544
- const text = value2.replace(/\s+/g, " ").trim();
1666
+ function singleLineText(value, maxLength = 260) {
1667
+ if (typeof value !== "string") return "";
1668
+ const text = value.replace(/\s+/g, " ").trim();
2545
1669
  if (text.length <= maxLength) return text;
2546
1670
  return `${text.slice(0, maxLength - 3).trimEnd()}...`;
2547
1671
  }
@@ -2594,15 +1718,15 @@ function arrayItemBoundsSuffix(field) {
2594
1718
  if (maxItems !== null) return `${itemTypeSuffix} maxItems=${maxItems}`;
2595
1719
  return itemTypeSuffix;
2596
1720
  }
2597
- function printToolExecutionHints(value2) {
1721
+ function printToolExecutionHints(value) {
2598
1722
  const batchCapabilityRecord = recordField(
2599
- isRecord(value2) ? value2 : {},
1723
+ isRecord(value) ? value : {},
2600
1724
  "batchCapability",
2601
1725
  "batch_capability"
2602
1726
  );
2603
1727
  const batchCapability = Object.keys(batchCapabilityRecord).length > 0 ? batchCapabilityRecord : null;
2604
1728
  const executionMetadata = recordField(
2605
- isRecord(value2) ? value2 : {},
1729
+ isRecord(value) ? value : {},
2606
1730
  "executionMetadata",
2607
1731
  "execution_metadata"
2608
1732
  );
@@ -2614,7 +1738,7 @@ function printToolExecutionHints(value2) {
2614
1738
  "batchOperation",
2615
1739
  "batch_operation"
2616
1740
  );
2617
- const maxBatchSize = numberField2(
1741
+ const maxBatchSize = numberField(
2618
1742
  batchCapability,
2619
1743
  "maxBatchSize",
2620
1744
  "max_batch_size"
@@ -2649,12 +1773,12 @@ function printToolExecutionHints(value2) {
2649
1773
  "Configured Deepline pacing (guidance, not a guaranteed provider quota):"
2650
1774
  );
2651
1775
  for (const limit of configuredRateLimits) {
2652
- const requests = numberField2(limit, "requestsPerWindow");
2653
- const windowMs = numberField2(limit, "windowMs");
1776
+ const requests = numberField(limit, "requestsPerWindow");
1777
+ const windowMs = numberField(limit, "windowMs");
2654
1778
  if (requests === null || windowMs === null) continue;
2655
1779
  const usage = stringField(limit, "usage") || "unknown";
2656
1780
  const usageText = usage === "queue_hint" ? "queue hint" : usage === "enforced" ? "Deepline enforced" : usage === "queue_hint_and_enforced" ? "queue hint and Deepline enforced" : usage === "disabled" ? "disabled" : usage;
2657
- const explicitMaxConcurrency = numberField2(
1781
+ const explicitMaxConcurrency = numberField(
2658
1782
  limit,
2659
1783
  "explicitMaxConcurrency",
2660
1784
  "explicit_max_concurrency"
@@ -2666,12 +1790,12 @@ function printToolExecutionHints(value2) {
2666
1790
  }
2667
1791
  }
2668
1792
  const queueHint = recordField(executionMetadata, "queueHint", "queue_hint");
2669
- const requestsPerSecondHint = numberField2(
1793
+ const requestsPerSecondHint = numberField(
2670
1794
  queueHint,
2671
1795
  "requestsPerSecondHint",
2672
1796
  "requests_per_second_hint"
2673
1797
  );
2674
- const derivedConcurrency = numberField2(
1798
+ const derivedConcurrency = numberField(
2675
1799
  queueHint,
2676
1800
  "derivedConcurrency",
2677
1801
  "derived_concurrency"
@@ -2758,17 +1882,17 @@ function listExtractorPathsFromUsageGuidance(tool) {
2758
1882
  ).filter(Boolean);
2759
1883
  });
2760
1884
  }
2761
- function formatDecimal(value2) {
2762
- const text = value2.toFixed(12).replace(/0+$/, "").replace(/\.$/, "");
1885
+ function formatDecimal(value) {
1886
+ const text = value.toFixed(12).replace(/0+$/, "").replace(/\.$/, "");
2763
1887
  return text || "0";
2764
1888
  }
2765
- function formatUsd(value2) {
2766
- return `$${formatDecimal(value2)}`;
1889
+ function formatUsd(value) {
1890
+ return `$${formatDecimal(value)}`;
2767
1891
  }
2768
- function numberField2(source, ...keys) {
1892
+ function numberField(source, ...keys) {
2769
1893
  for (const key of keys) {
2770
- const value2 = source[key];
2771
- if (typeof value2 === "number" && Number.isFinite(value2)) return value2;
1894
+ const value = source[key];
1895
+ if (typeof value === "number" && Number.isFinite(value)) return value;
2772
1896
  }
2773
1897
  return null;
2774
1898
  }
@@ -2839,10 +1963,10 @@ function parseJsonObjectArgument(raw, flagName) {
2839
1963
  }
2840
1964
  return parsed;
2841
1965
  }
2842
- function toolExecuteJsonOption(value2) {
2843
- const legacyInput = typeof value2 === "string" ? value2 : void 0;
1966
+ function toolExecuteJsonOption(value) {
1967
+ const legacyInput = typeof value === "string" ? value : void 0;
2844
1968
  return {
2845
- requested: value2 === true || legacyInput !== void 0,
1969
+ requested: value === true || legacyInput !== void 0,
2846
1970
  legacyInput
2847
1971
  };
2848
1972
  }
@@ -2906,10 +2030,10 @@ function parseToolExecuteTimeout(raw) {
2906
2030
  "--timeout must be a duration like 500ms, 90s, 10m, or 1h (a bare number is seconds)."
2907
2031
  );
2908
2032
  }
2909
- const value2 = Number(match[1]);
2033
+ const value = Number(match[1]);
2910
2034
  const unit = (match[2] ?? "s").toLowerCase();
2911
2035
  const factor = unit === "ms" ? 1 : unit === "s" ? 1e3 : unit === "m" ? 6e4 : 36e5;
2912
- const timeoutMs = value2 * factor;
2036
+ const timeoutMs = value * factor;
2913
2037
  if (!Number.isSafeInteger(timeoutMs) || timeoutMs < 1 || timeoutMs > 2147483647) {
2914
2038
  throw new Error(
2915
2039
  "--timeout must be between 1ms and 2147483647ms (24d 20h 31m 23s)."
@@ -2917,11 +2041,11 @@ function parseToolExecuteTimeout(raw) {
2917
2041
  }
2918
2042
  return timeoutMs;
2919
2043
  }
2920
- function safeFileStem(value2) {
2921
- return value2.trim().replace(/[^a-zA-Z0-9_-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 64) || "tool";
2044
+ function safeFileStem(value) {
2045
+ return value.trim().replace(/[^a-zA-Z0-9_-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 64) || "tool";
2922
2046
  }
2923
- function powerShellQuote(value2) {
2924
- return `'${value2.replace(/'/g, "''")}'`;
2047
+ function powerShellQuote(value) {
2048
+ return `'${value.replace(/'/g, "''")}'`;
2925
2049
  }
2926
2050
  function seedToolListScript(input) {
2927
2051
  const stem = safeFileStem(input.toolId);
@@ -3068,7 +2192,7 @@ function buildToolExecuteBaseEnvelope(input) {
3068
2192
  lines: apifyRecovery ? [
3069
2193
  "Apify is still running. Run the follow-up command(s) below."
3070
2194
  ] : summaryEntries.length > 0 ? summaryEntries.map(
3071
- ([key, value2]) => `${key}=${String(value2)}`
2195
+ ([key, value]) => `${key}=${String(value)}`
3072
2196
  ) : [JSON.stringify(input.rawResponse, null, 2)]
3073
2197
  },
3074
2198
  ...guidanceLines.length > 0 ? [{ title: "guidance", lines: guidanceLines }] : []
@@ -3150,7 +2274,7 @@ function buildToolExecuteRowArtifactEnvelope(input) {
3150
2274
  lines: [
3151
2275
  ...input.csv.columns.length > 0 ? [`columns: ${JSON.stringify(input.csv.columns)}`] : [],
3152
2276
  ...Object.keys(input.summary).length > 0 ? [
3153
- `summary: ${Object.entries(input.summary).map(([key, value2]) => `${key}=${String(value2)}`).join(", ")}`
2277
+ `summary: ${Object.entries(input.summary).map(([key, value]) => `${key}=${String(value)}`).join(", ")}`
3154
2278
  ] : [],
3155
2279
  `preview: ${JSON.stringify(input.rowOutput.previewRows)}`,
3156
2280
  `starter script: ${input.seededScript.path}`
@@ -3429,10 +2553,6 @@ inspect: ${inspection.inspect}
3429
2553
  }
3430
2554
 
3431
2555
  export {
3432
- publicToolSchemas,
3433
- describedTool,
3434
- toolMetadataJsonForDescribe,
3435
- formatModelDescription,
3436
2556
  registerToolsCommands,
3437
2557
  printMonitorTypeContract,
3438
2558
  printCompactToolContract,