deepline 0.3.395 → 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.
- package/dist/bundling-sources/sdk/src/plays/play-description.ts +1 -1
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/fixture-behavior.ts +2 -2
- package/dist/cli/{auth-NMQXZRS7.mjs → auth-AZJFXGKP.mjs} +5 -4
- package/dist/cli/auth-CZJQU7B5.js +40 -0
- package/dist/cli/{billing-Z4JTGUU3.js → billing-MQV5AGDJ.js} +77 -76
- package/dist/cli/{billing-5MVXZRS6.mjs → billing-MZAAUHGH.mjs} +6 -5
- package/dist/cli/{chunk-6D7A2FSL.mjs → chunk-2LDADJNO.mjs} +7 -107
- package/dist/cli/{chunk-UKU6JM3S.js → chunk-3VP34TAU.js} +8 -8
- package/dist/cli/{chunk-7XAM7KDW.mjs → chunk-4D745XZO.mjs} +21 -108
- package/dist/cli/chunk-7DRPTGCK.js +930 -0
- package/dist/cli/{chunk-ZMVJSS6N.js → chunk-BQR6UN3C.js} +62 -78
- package/dist/cli/{chunk-HRWUQJ4K.js → chunk-DQ65ZVHN.js} +6 -6
- package/dist/cli/{chunk-5VCZ3WRH.mjs → chunk-EIMG75BT.mjs} +1 -0
- package/dist/cli/{chunk-EFLQHJZ6.mjs → chunk-F3BUFYKE.mjs} +182 -1031
- package/dist/cli/chunk-FIVKWNMT.mjs +210 -0
- package/dist/cli/{describe-DBRY5BNK.mjs → chunk-HFYQBC2D.mjs} +51 -171
- package/dist/cli/chunk-HGFFYVXN.js +210 -0
- package/dist/cli/{chunk-VB6KECLU.mjs → chunk-IHG7UAHD.mjs} +63 -79
- package/dist/cli/{chunk-TO2MWPGR.js → chunk-IZ74ABSX.js} +1 -1
- package/dist/cli/{chunk-G4IWGRMK.mjs → chunk-J7ABTQQ7.mjs} +5 -3
- package/dist/cli/{chunk-LZLBR2SF.js → chunk-K33MXVXQ.js} +323 -1172
- package/dist/cli/{chunk-DRM3CMHL.js → chunk-KXMNM4AQ.js} +2 -1
- package/dist/cli/chunk-LJ5747UC.mjs +107 -0
- package/dist/cli/{chunk-BON3DRC6.mjs → chunk-MRXMMERY.mjs} +1 -1
- package/dist/cli/{chunk-7MVWUXOD.mjs → chunk-MV7QRALK.mjs} +3 -3
- package/dist/cli/{chunk-WCCKMLHL.mjs → chunk-MYPH2LUU.mjs} +2 -2
- package/dist/cli/{chunk-RDXFGPJU.js → chunk-NA4T3B62.js} +64 -272
- package/dist/cli/{chunk-BLYL3KOC.mjs → chunk-NOX2TCBP.mjs} +1 -1
- package/dist/cli/chunk-OSDXE27V.mjs +88 -0
- package/dist/cli/{chunk-R4XZO6Z5.js → chunk-PSGEDGLT.js} +28 -115
- package/dist/cli/chunk-Q2E4E4FJ.js +112 -0
- package/dist/cli/chunk-RFG3MRAC.js +286 -0
- package/dist/cli/{chunk-47M6HPGP.mjs → chunk-RNSWDKBM.mjs} +1 -1
- package/dist/cli/{chunk-56IFFVIB.js → chunk-RYW4HPSM.js} +21 -121
- package/dist/cli/{chunk-K5T3EN6D.js → chunk-SO7RUVTY.js} +26 -26
- package/dist/cli/{chunk-KZZC33PY.mjs → chunk-TXZVVBQZ.mjs} +63 -271
- package/dist/cli/{chunk-36ML3YKA.js → chunk-UVXBVUZQ.js} +15 -13
- package/dist/cli/{chunk-PZ5BZ76S.js → chunk-VTF4RRWJ.js} +50 -50
- package/dist/cli/{chunk-3TRY7KAC.mjs → chunk-W3HMGKMI.mjs} +2 -2
- package/dist/cli/{chunk-ZWH2TFA7.mjs → chunk-WM2QEHZL.mjs} +2 -2
- package/dist/cli/chunk-YHPYUZZX.mjs +112 -0
- package/dist/cli/chunk-YHZUZO3U.mjs +930 -0
- package/dist/cli/{chunk-UCXK2DS4.js → chunk-YLRME7MK.js} +15 -15
- package/dist/cli/{chunk-MYIBHORT.js → chunk-YSVORIEW.js} +2 -2
- package/dist/cli/{chunk-OCSG6X67.mjs → chunk-YUDKBQUD.mjs} +4 -4
- package/dist/cli/chunk-ZAAKSJAS.js +88 -0
- package/dist/cli/{chunk-VYLJJQ7Y.js → chunk-ZHUMDMOS.js} +65 -65
- package/dist/cli/chunk-ZM2YPJQJ.js +107 -0
- package/dist/cli/{csv-HTS5ZYQ4.js → csv-AQBQ5O3I.js} +13 -12
- package/dist/cli/{csv-SVOD5UBH.mjs → csv-MB7PJMYQ.mjs} +4 -3
- package/dist/cli/{db-7AP4P52N.js → db-JPUYC5RB.js} +31 -30
- package/dist/cli/{db-7QLNI3Q4.mjs → db-L5IEI2AU.mjs} +6 -5
- package/dist/cli/describe-6WT74AOR.js +164 -0
- package/dist/cli/describe-S6BFANVI.mjs +164 -0
- package/dist/cli/describe-core.d.mts +100 -0
- package/dist/cli/describe-core.d.ts +100 -0
- package/dist/cli/describe-core.js +18 -0
- package/dist/cli/describe-core.mjs +18 -0
- package/dist/cli/{executions-GRQXTB2P.js → executions-6TMQTFP4.js} +8 -7
- package/dist/cli/{executions-QNZTPNG4.mjs → executions-L7I2ZW4Z.mjs} +6 -5
- package/dist/cli/{feedback-JMCSR624.mjs → feedback-DSJ63HK6.mjs} +4 -3
- package/dist/cli/{feedback-ZOLA2KY7.js → feedback-XF7CQGMD.js} +8 -7
- package/dist/cli/{git-LJGL2IHS.mjs → git-C3ENM67D.mjs} +5 -4
- package/dist/cli/git-HYDZK2QR.js +24 -0
- package/dist/cli/index.js +96 -94
- package/dist/cli/index.mjs +41 -39
- package/dist/cli/{legacy-noops-YSCIR2SD.js → legacy-noops-B2NHWIVD.js} +8 -7
- package/dist/cli/{legacy-noops-F23PKVBN.mjs → legacy-noops-VFG2K6HK.mjs} +5 -4
- package/dist/cli/{monitors-WMZ6HJZX.js → monitors-ORFWOVZB.js} +87 -86
- package/dist/cli/{monitors-S4LOEL7W.mjs → monitors-TCEDBDGY.mjs} +6 -5
- package/dist/cli/{org-U3WA2NQM.mjs → org-45KREIKZ.mjs} +6 -5
- package/dist/cli/{org-PFHM5ZLY.js → org-T74CJESN.js} +66 -65
- package/dist/cli/{chunk-XMAPE2KH.mjs → play-MU7MYBIM.mjs} +78 -131
- package/dist/cli/{chunk-4KLCLLTO.js → play-XHK2LPON.js} +273 -326
- package/dist/cli/{providers-XYMHLKCA.js → providers-4MGQKYFD.js} +9 -8
- package/dist/cli/{providers-QBBRFBOH.mjs → providers-VYCXIJT5.mjs} +6 -5
- package/dist/cli/{quickstart-IYGD6ZY3.js → quickstart-47G3VEOT.js} +6 -5
- package/dist/cli/{quickstart-5JTDGISY.mjs → quickstart-H724EFM2.mjs} +4 -3
- package/dist/cli/search-3356ENLD.js +30 -0
- package/dist/cli/{search-X6W6GRHS.mjs → search-VQHXEFQ4.mjs} +8 -6
- package/dist/cli/{secrets-UHG6OQFD.js → secrets-ALLKCU35.js} +15 -14
- package/dist/cli/{secrets-N55B67H6.mjs → secrets-CPBNGA44.mjs} +6 -5
- package/dist/cli/{sessions-JTRSTDSS.mjs → sessions-7RSQB7IX.mjs} +5 -4
- package/dist/cli/sessions-FKGAY7WQ.js +16 -0
- package/dist/cli/{settings-Q24HRAQI.mjs → settings-UYSGV4IC.mjs} +9 -8
- package/dist/cli/{settings-ATX4U5AS.js → settings-Y5BI42P7.js} +76 -75
- package/dist/cli/{setup-77ZWLVHT.mjs → setup-L3ZBBTS4.mjs} +7 -6
- package/dist/cli/{setup-EJCNOUCE.js → setup-VXQPEU3E.js} +42 -41
- package/dist/cli/skills-DUZQTDTE.js +29 -0
- package/dist/cli/{skills-XIS5AWQI.mjs → skills-QHVDLSFE.mjs} +5 -4
- package/dist/cli/{tools-WCKLYEGQ.mjs → tools-LSCEK4K2.mjs} +16 -19
- package/dist/cli/tools-YWU5QOQ5.js +39 -0
- package/dist/cli/update-5LYQAI55.js +29 -0
- package/dist/cli/{update-UT5WANMV.mjs → update-CU22OTBM.mjs} +7 -6
- package/dist/cli/{workflow-226QYUN2.js → workflow-ERFLTRNX.js} +17 -16
- package/dist/cli/{workflow-ZMX3L4ML.mjs → workflow-KQARK5BZ.mjs} +7 -6
- package/dist/{client-hdFtwhTm.d.mts → client-D0j-_aaa.d.mts} +2 -1
- package/dist/{client-CivP-PAI.d.ts → client-DflfVyj6.d.ts} +2 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +15 -11
- package/dist/index.mjs +19 -15
- package/dist/install-integrity.json +94 -80
- package/dist/plays/play-description.d.mts +1 -1
- package/dist/plays/play-description.d.ts +1 -1
- package/dist/plays/play-description.js +4 -2
- package/dist/plays/play-description.mjs +3 -1
- package/dist/plays/run-request.d.mts +1 -1
- package/dist/plays/run-request.d.ts +1 -1
- package/dist/release.d.mts +1 -1
- package/dist/release.d.ts +1 -1
- package/dist/release.js +2 -2
- package/dist/release.mjs +1 -1
- package/package.json +6 -1
- package/dist/cli/auth-UYCOBAL5.js +0 -39
- package/dist/cli/describe-YKOE54ZO.js +0 -406
- package/dist/cli/git-EJQLRK27.js +0 -23
- package/dist/cli/play-AGSECQFN.mjs +0 -159
- package/dist/cli/play-BR2LWGXK.js +0 -159
- package/dist/cli/search-ZVSYH5GY.js +0 -28
- package/dist/cli/sessions-57L5MGHN.js +0 -15
- package/dist/cli/skills-SPXUBLII.js +0 -28
- package/dist/cli/tools-DBHUUZJX.js +0 -42
- package/dist/cli/update-VSNFXRHJ.js +0 -28
|
@@ -1,37 +1,51 @@
|
|
|
1
1
|
import {
|
|
2
2
|
addDescribeOptions,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
15
|
-
registerDeprecatedSearchCommand
|
|
16
|
-
} from "./chunk-7XAM7KDW.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-
|
|
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-
|
|
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-
|
|
65
|
+
} from "./chunk-RNSWDKBM.mjs";
|
|
52
66
|
import {
|
|
53
67
|
resolveConfig,
|
|
54
68
|
sdkCliStateDirPath
|
|
55
|
-
} from "./chunk-
|
|
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
|
|
89
|
+
const value = payload?.[condition.field];
|
|
76
90
|
switch (condition.operator) {
|
|
77
91
|
case "equals":
|
|
78
|
-
return
|
|
92
|
+
return value === condition.value;
|
|
79
93
|
case "number_equals":
|
|
80
94
|
try {
|
|
81
|
-
return Number(
|
|
95
|
+
return Number(value) === condition.value;
|
|
82
96
|
} catch {
|
|
83
97
|
return false;
|
|
84
98
|
}
|
|
85
99
|
case "present_nonblank":
|
|
86
|
-
return typeof
|
|
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
|
}
|
|
@@ -225,239 +239,6 @@ function describeToolCategory(category) {
|
|
|
225
239
|
return TOOL_CATEGORY_DESCRIPTIONS[category] ?? null;
|
|
226
240
|
}
|
|
227
241
|
|
|
228
|
-
// ../plays/field-catalog.ts
|
|
229
|
-
var value = (description) => ({ type: "string", description });
|
|
230
|
-
var SOURCE = {
|
|
231
|
-
type: "string",
|
|
232
|
-
description: "The provider or step that found it."
|
|
233
|
-
};
|
|
234
|
-
var FIELD_CATALOG = {
|
|
235
|
-
person: {
|
|
236
|
-
name: {
|
|
237
|
-
description: "The person's name.",
|
|
238
|
-
leaves: {
|
|
239
|
-
value: value("Full name."),
|
|
240
|
-
first: value("First (given) name."),
|
|
241
|
-
last: value("Last (family) name.")
|
|
242
|
-
}
|
|
243
|
-
},
|
|
244
|
-
email: {
|
|
245
|
-
description: "An email address for the person.",
|
|
246
|
-
leaves: {
|
|
247
|
-
value: value("The address."),
|
|
248
|
-
validated: {
|
|
249
|
-
type: "boolean",
|
|
250
|
-
description: "Whether the address passed validation."
|
|
251
|
-
},
|
|
252
|
-
status: {
|
|
253
|
-
type: "EmailStatus",
|
|
254
|
-
description: "The validation verdict and its signals."
|
|
255
|
-
},
|
|
256
|
-
source: SOURCE
|
|
257
|
-
},
|
|
258
|
-
kinds: {
|
|
259
|
-
work: "At their employer.",
|
|
260
|
-
personal: "Their own, not tied to an employer."
|
|
261
|
-
}
|
|
262
|
-
},
|
|
263
|
-
phone: {
|
|
264
|
-
description: "A phone number for the person.",
|
|
265
|
-
leaves: {
|
|
266
|
-
value: value("The number."),
|
|
267
|
-
validated: {
|
|
268
|
-
type: "boolean",
|
|
269
|
-
description: "Whether the number passed validation."
|
|
270
|
-
},
|
|
271
|
-
status: {
|
|
272
|
-
type: '"valid" | "invalid" | "unknown"',
|
|
273
|
-
description: "The validation verdict."
|
|
274
|
-
},
|
|
275
|
-
line_type: value("Mobile, landline, VoIP and so on."),
|
|
276
|
-
carrier: value("The carrier serving the number."),
|
|
277
|
-
source: SOURCE
|
|
278
|
-
},
|
|
279
|
-
kinds: {
|
|
280
|
-
mobile: "Their mobile.",
|
|
281
|
-
work: "A direct line at their employer."
|
|
282
|
-
}
|
|
283
|
-
},
|
|
284
|
-
linkedin: {
|
|
285
|
-
description: "The person's LinkedIn profile.",
|
|
286
|
-
leaves: { url: value("The profile URL.") }
|
|
287
|
-
},
|
|
288
|
-
job: {
|
|
289
|
-
description: "The person's current role.",
|
|
290
|
-
leaves: {
|
|
291
|
-
title: value("Job title."),
|
|
292
|
-
change: {
|
|
293
|
-
type: "JobChange",
|
|
294
|
-
description: "Whether they changed jobs, and to what."
|
|
295
|
-
},
|
|
296
|
-
change_status: {
|
|
297
|
-
type: "JobChangeStatus",
|
|
298
|
-
description: "The job-change verdict alone."
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
},
|
|
302
|
-
record: {
|
|
303
|
-
description: "A provider's own record of the person.",
|
|
304
|
-
leaves: { id: value("The provider's id for the person.") }
|
|
305
|
-
}
|
|
306
|
-
},
|
|
307
|
-
company: {
|
|
308
|
-
name: {
|
|
309
|
-
description: "The company's name.",
|
|
310
|
-
leaves: { value: value("The name.") },
|
|
311
|
-
kinds: { legal: "As registered with a government." }
|
|
312
|
-
},
|
|
313
|
-
domain: {
|
|
314
|
-
description: "The company's web domain.",
|
|
315
|
-
leaves: { value: value("The bare domain, such as example.com.") }
|
|
316
|
-
},
|
|
317
|
-
website: {
|
|
318
|
-
description: "The company's website.",
|
|
319
|
-
leaves: { url: value("The site URL.") }
|
|
320
|
-
},
|
|
321
|
-
linkedin: {
|
|
322
|
-
description: "The company's LinkedIn page.",
|
|
323
|
-
leaves: { url: value("The page URL.") }
|
|
324
|
-
},
|
|
325
|
-
phone: {
|
|
326
|
-
description: "A phone number for the company.",
|
|
327
|
-
leaves: { value: value("The number.") }
|
|
328
|
-
},
|
|
329
|
-
industry: {
|
|
330
|
-
description: "The industry the company is in.",
|
|
331
|
-
leaves: { value: value("The industry.") }
|
|
332
|
-
},
|
|
333
|
-
record: {
|
|
334
|
-
description: "A provider's own record of the company.",
|
|
335
|
-
leaves: { id: value("The provider's id for the company.") }
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
};
|
|
339
|
-
function catalogFields() {
|
|
340
|
-
return Object.entries(FIELD_CATALOG).flatMap(
|
|
341
|
-
([entity, groups]) => Object.entries(groups).flatMap(
|
|
342
|
-
([group, definition]) => [void 0, ...Object.keys(definition.kinds ?? {})].flatMap(
|
|
343
|
-
(kind) => Object.entries(definition.leaves).map(([leaf, described]) => ({
|
|
344
|
-
...described,
|
|
345
|
-
id: [entity, group, kind, leaf].filter(Boolean).join("."),
|
|
346
|
-
entity,
|
|
347
|
-
group,
|
|
348
|
-
...kind ? { kind } : {},
|
|
349
|
-
leaf
|
|
350
|
-
}))
|
|
351
|
-
)
|
|
352
|
-
)
|
|
353
|
-
);
|
|
354
|
-
}
|
|
355
|
-
var FIELDS_BY_ID = new Map(catalogFields().map((field) => [field.id, field]));
|
|
356
|
-
function generalField(id) {
|
|
357
|
-
const field = FIELDS_BY_ID.get(id);
|
|
358
|
-
return field?.kind ? [field.entity, field.group, field.leaf].join(".") : null;
|
|
359
|
-
}
|
|
360
|
-
function fieldSatisfies(offered, wanted) {
|
|
361
|
-
return offered === wanted || generalField(offered) === wanted;
|
|
362
|
-
}
|
|
363
|
-
var EXTRACTOR_TARGET_FIELDS = {
|
|
364
|
-
email: ["person.email.value"],
|
|
365
|
-
personal_email: ["person.email.personal.value"],
|
|
366
|
-
email_status: ["person.email.status"],
|
|
367
|
-
phone: ["person.phone.value", "company.phone.value"],
|
|
368
|
-
phone_status: ["person.phone.status"],
|
|
369
|
-
first_name: ["person.name.first"],
|
|
370
|
-
last_name: ["person.name.last"],
|
|
371
|
-
full_name: ["person.name.value"],
|
|
372
|
-
// Also used for a list name, a channel title and a search suggestion.
|
|
373
|
-
name: ["person.name.value", "company.name.value"],
|
|
374
|
-
linkedin: ["person.linkedin.url", "company.linkedin.url"],
|
|
375
|
-
linkedin_url: ["person.linkedin.url"],
|
|
376
|
-
title: ["person.job.title"],
|
|
377
|
-
job_change: ["person.job.change"],
|
|
378
|
-
job_change_status: ["person.job.change_status"],
|
|
379
|
-
company: ["company.name.value"],
|
|
380
|
-
company_name: ["company.name.value"],
|
|
381
|
-
organization_name: ["company.name.value"],
|
|
382
|
-
company_domain: ["company.domain.value"],
|
|
383
|
-
domain: ["company.domain.value"],
|
|
384
|
-
company_website: ["company.website.url"],
|
|
385
|
-
// Also used for a podcast URL.
|
|
386
|
-
website: ["company.website.url"],
|
|
387
|
-
company_linkedin_url: ["company.linkedin.url"],
|
|
388
|
-
industry: ["company.industry.value"],
|
|
389
|
-
id: ["person.record.id", "company.record.id"],
|
|
390
|
-
// Used for unrelated provider statuses; none is a catalog field.
|
|
391
|
-
status: []
|
|
392
|
-
};
|
|
393
|
-
function fieldOfName(name, declared) {
|
|
394
|
-
const meanings = EXTRACTOR_TARGET_FIELDS[name] ?? [];
|
|
395
|
-
if (declared === void 0) {
|
|
396
|
-
return meanings.length === 1 ? meanings[0] : void 0;
|
|
397
|
-
}
|
|
398
|
-
return meanings.some((meaning) => fieldSatisfies(declared, meaning)) ? declared : void 0;
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
// src/cli/commands/model-description.ts
|
|
402
|
-
function formatModelDescription(description) {
|
|
403
|
-
const lines = [];
|
|
404
|
-
lines.push(description.model);
|
|
405
|
-
lines.push(`Provider: ${description.provider}`);
|
|
406
|
-
const name = stringField(description.modelMetadata, "name");
|
|
407
|
-
if (name) lines.push(`Name: ${name}`);
|
|
408
|
-
const contextWindow = numberField(
|
|
409
|
-
description.modelMetadata,
|
|
410
|
-
"context_window"
|
|
411
|
-
);
|
|
412
|
-
if (contextWindow !== null) lines.push(`Context: ${contextWindow}`);
|
|
413
|
-
const tags = arrayField(description.modelMetadata, "tags").filter(
|
|
414
|
-
(value2) => typeof value2 === "string"
|
|
415
|
-
);
|
|
416
|
-
if (tags.length) lines.push(`Tags: ${tags.join(", ")}`);
|
|
417
|
-
lines.push("");
|
|
418
|
-
lines.push("Provider options:");
|
|
419
|
-
appendNamespace(lines, description.providerOptions.gateway);
|
|
420
|
-
if (description.providerOptions.selectedProvider) {
|
|
421
|
-
appendNamespace(lines, description.providerOptions.selectedProvider);
|
|
422
|
-
}
|
|
423
|
-
lines.push("");
|
|
424
|
-
lines.push("Example input:");
|
|
425
|
-
lines.push(JSON.stringify(description.exampleInput, null, 2));
|
|
426
|
-
if (description.caveats.length) {
|
|
427
|
-
lines.push("");
|
|
428
|
-
lines.push("Caveats:");
|
|
429
|
-
for (const caveat of description.caveats) {
|
|
430
|
-
lines.push(`- ${caveat}`);
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
return `${lines.join("\n")}
|
|
434
|
-
`;
|
|
435
|
-
}
|
|
436
|
-
function appendNamespace(lines, namespace) {
|
|
437
|
-
lines.push(`- ${namespace.provider} (${namespace.sourceSymbol})`);
|
|
438
|
-
for (const field of namespace.fields) {
|
|
439
|
-
const values = field.enumValues?.length ? ` (${field.enumValues.map((value2) => JSON.stringify(value2)).join(" | ")})` : "";
|
|
440
|
-
lines.push(
|
|
441
|
-
` - ${field.name}: ${field.type}${values} - ${field.description}`
|
|
442
|
-
);
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
function stringField(value2, key) {
|
|
446
|
-
if (!value2 || typeof value2 !== "object" || Array.isArray(value2)) return null;
|
|
447
|
-
const candidate = value2[key];
|
|
448
|
-
return typeof candidate === "string" && candidate.trim() ? candidate.trim() : null;
|
|
449
|
-
}
|
|
450
|
-
function numberField(value2, key) {
|
|
451
|
-
if (!value2 || typeof value2 !== "object" || Array.isArray(value2)) return null;
|
|
452
|
-
const candidate = value2[key];
|
|
453
|
-
return typeof candidate === "number" ? candidate : null;
|
|
454
|
-
}
|
|
455
|
-
function arrayField(value2, key) {
|
|
456
|
-
if (!value2 || typeof value2 !== "object" || Array.isArray(value2)) return [];
|
|
457
|
-
const candidate = value2[key];
|
|
458
|
-
return Array.isArray(candidate) ? candidate : [];
|
|
459
|
-
}
|
|
460
|
-
|
|
461
242
|
// src/cli/tool-connection-status.ts
|
|
462
243
|
function toolConnectionStatusMessage(input) {
|
|
463
244
|
if (input.credentialStatus === "requires_connection") {
|
|
@@ -492,15 +273,15 @@ function toListedTool(tool) {
|
|
|
492
273
|
executeCommand: `deepline tools execute ${tool.toolId}`
|
|
493
274
|
};
|
|
494
275
|
}
|
|
495
|
-
function normalizeGrepText(
|
|
496
|
-
if (
|
|
497
|
-
if (typeof
|
|
498
|
-
if (typeof
|
|
499
|
-
return String(
|
|
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();
|
|
500
281
|
}
|
|
501
|
-
if (Array.isArray(
|
|
502
|
-
if (typeof
|
|
503
|
-
return Object.values(
|
|
282
|
+
if (Array.isArray(value)) return value.map(normalizeGrepText).join(" ");
|
|
283
|
+
if (typeof value === "object") {
|
|
284
|
+
return Object.values(value).map(normalizeGrepText).join(" ");
|
|
504
285
|
}
|
|
505
286
|
return "";
|
|
506
287
|
}
|
|
@@ -511,15 +292,15 @@ function parseGrepTerms(query, mode) {
|
|
|
511
292
|
const matches = trimmed.match(/"([^"]+)"|'([^']+)'|\S+/g) ?? [];
|
|
512
293
|
return matches.map((term) => term.replace(/^["']|["']$/g, "").trim()).filter(Boolean);
|
|
513
294
|
}
|
|
514
|
-
function matchesGrepQuery(
|
|
295
|
+
function matchesGrepQuery(value, query, mode) {
|
|
515
296
|
const terms = parseGrepTerms(query, mode);
|
|
516
297
|
if (terms.length === 0) return true;
|
|
517
|
-
const haystack = normalizeGrepText(
|
|
298
|
+
const haystack = normalizeGrepText(value);
|
|
518
299
|
if (mode === "any") return terms.some((term) => haystack.includes(term));
|
|
519
300
|
return terms.every((term) => haystack.includes(term));
|
|
520
301
|
}
|
|
521
|
-
function shellCommandArg(
|
|
522
|
-
return `'${
|
|
302
|
+
function shellCommandArg(value) {
|
|
303
|
+
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
523
304
|
}
|
|
524
305
|
function zeroMatchToolGuidance(options) {
|
|
525
306
|
const categories = options.categories ?? [];
|
|
@@ -591,7 +372,7 @@ function requiredInputIds(tool) {
|
|
|
591
372
|
}
|
|
592
373
|
function notConnectedSuffix(tool) {
|
|
593
374
|
const record = tool;
|
|
594
|
-
const status =
|
|
375
|
+
const status = stringField(record, "credentialStatus", "credential_status");
|
|
595
376
|
const connected = record.connected;
|
|
596
377
|
const message = toolConnectionStatusMessage({
|
|
597
378
|
connected: connected === false ? false : void 0,
|
|
@@ -604,14 +385,14 @@ function shortPricingHint(tool) {
|
|
|
604
385
|
tool,
|
|
605
386
|
"pricing"
|
|
606
387
|
);
|
|
607
|
-
const credits =
|
|
608
|
-
const unit =
|
|
388
|
+
const credits = numberField(pricing, "creditsPerUnit", "credits_per_unit");
|
|
389
|
+
const unit = stringField(pricing, "unit");
|
|
609
390
|
if (credits !== null) {
|
|
610
391
|
return `${formatDecimal(credits)} cr/${unit || "unit"}`;
|
|
611
392
|
}
|
|
612
|
-
const summary =
|
|
393
|
+
const summary = stringField(pricing, "summary");
|
|
613
394
|
if (summary) return summary;
|
|
614
|
-
const displayText =
|
|
395
|
+
const displayText = stringField(pricing, "displayText", "display_text");
|
|
615
396
|
return displayText || null;
|
|
616
397
|
}
|
|
617
398
|
function aggregateCategorySummaries(tools) {
|
|
@@ -896,8 +677,8 @@ async function grepTools(queryInput, options = {}) {
|
|
|
896
677
|
return 0;
|
|
897
678
|
}
|
|
898
679
|
function numericToolField(tool, field) {
|
|
899
|
-
const
|
|
900
|
-
return typeof
|
|
680
|
+
const value = tool[field];
|
|
681
|
+
return typeof value === "number" ? value : void 0;
|
|
901
682
|
}
|
|
902
683
|
function compactTool(tool) {
|
|
903
684
|
const listed = toListedTool(tool);
|
|
@@ -917,7 +698,7 @@ function compactTool(tool) {
|
|
|
917
698
|
};
|
|
918
699
|
}
|
|
919
700
|
function playIdentifiers(play) {
|
|
920
|
-
return [play.name, play.reference, ...play.aliases ?? []].filter((
|
|
701
|
+
return [play.name, play.reference, ...play.aliases ?? []].filter((value) => Boolean(value?.trim())).map((value) => value.trim());
|
|
921
702
|
}
|
|
922
703
|
async function findPlayForToolId(client, toolId, cliInvocationId) {
|
|
923
704
|
const requested = toolId.trim();
|
|
@@ -943,34 +724,6 @@ Inspect its schema with: deepline describe ${playName}`;
|
|
|
943
724
|
function printPlayAliasToolError(toolId, play) {
|
|
944
725
|
console.error(playAliasToolErrorMessage(toolId, play));
|
|
945
726
|
}
|
|
946
|
-
function isPlayLikeTool(tool) {
|
|
947
|
-
const record = tool;
|
|
948
|
-
if (record.isPlay === true || record.is_play === true) return true;
|
|
949
|
-
const playExpansion = recordField(record, "playExpansion", "play_expansion");
|
|
950
|
-
if (Object.keys(playExpansion).length > 0) return true;
|
|
951
|
-
const toolId = typeof record.toolId === "string" ? record.toolId : "";
|
|
952
|
-
return toolId.endsWith("_waterfall");
|
|
953
|
-
}
|
|
954
|
-
function isMonitorTypeTool(tool) {
|
|
955
|
-
return stringField2(tool, "kind") === "monitor_type";
|
|
956
|
-
}
|
|
957
|
-
function playReferenceForTool(tool) {
|
|
958
|
-
const record = tool;
|
|
959
|
-
const declared = stringField2(record, "playReference", "play_reference");
|
|
960
|
-
if (declared.startsWith("prebuilt/")) {
|
|
961
|
-
return declared;
|
|
962
|
-
}
|
|
963
|
-
return null;
|
|
964
|
-
}
|
|
965
|
-
function playSearchCommandForToolId(toolId) {
|
|
966
|
-
return `deepline search --type prebuilts ${JSON.stringify(toolId.replace(/_/g, " "))}`;
|
|
967
|
-
}
|
|
968
|
-
function playRunCommandForTool(tool, toolId, input) {
|
|
969
|
-
const playReference = playReferenceForTool(tool);
|
|
970
|
-
if (!playReference) return playSearchCommandForToolId(toolId);
|
|
971
|
-
const inputArg = input === void 0 ? "'{...}'" : `'${JSON.stringify(input)}'`;
|
|
972
|
-
return `deepline plays run ${playReference} --input ${inputArg}`;
|
|
973
|
-
}
|
|
974
727
|
function playLikeToolExecuteErrorMessage(toolId, tool) {
|
|
975
728
|
const playReference = tool ? playReferenceForTool(tool) : null;
|
|
976
729
|
const nextStep = playReference ? `Use: deepline plays run ${playReference} --input '{...}'` : `Find the maintained workflow with: ${playSearchCommandForToolId(toolId)}`;
|
|
@@ -1032,7 +785,7 @@ Output:
|
|
|
1032
785
|
"Unable to read --credentials-file as a JSON object."
|
|
1033
786
|
);
|
|
1034
787
|
}
|
|
1035
|
-
if (!credentials || typeof credentials !== "object" || Array.isArray(credentials) || Object.keys(credentials).length === 0 || Object.values(credentials).some((
|
|
788
|
+
if (!credentials || typeof credentials !== "object" || Array.isArray(credentials) || Object.keys(credentials).length === 0 || Object.values(credentials).some((value) => typeof value !== "string")) {
|
|
1036
789
|
throw new Error(
|
|
1037
790
|
"--credentials-file must contain a nonempty JSON object of string credential values."
|
|
1038
791
|
);
|
|
@@ -1188,7 +941,7 @@ Examples:
|
|
|
1188
941
|
process.exitCode = await narrowView();
|
|
1189
942
|
return;
|
|
1190
943
|
}
|
|
1191
|
-
const { describeAnything } = await import("./describe-
|
|
944
|
+
const { describeAnything } = await import("./describe-S6BFANVI.mjs");
|
|
1192
945
|
process.exitCode = await describeAnything(
|
|
1193
946
|
toolId,
|
|
1194
947
|
{
|
|
@@ -1233,8 +986,8 @@ Examples:
|
|
|
1233
986
|
).option(
|
|
1234
987
|
"-p, --param <key=value>",
|
|
1235
988
|
"Pass one parameter. Repeat for multiple values.",
|
|
1236
|
-
(
|
|
1237
|
-
acc.push(
|
|
989
|
+
(value, acc) => {
|
|
990
|
+
acc.push(value);
|
|
1238
991
|
return acc;
|
|
1239
992
|
},
|
|
1240
993
|
[]
|
|
@@ -1345,7 +1098,12 @@ async function getTool(toolId, options = {}, compatibilityMetadata) {
|
|
|
1345
1098
|
return 0;
|
|
1346
1099
|
}
|
|
1347
1100
|
if ((options.schemaOnly || options.examplesOnly || options.gettersOnly) && !isMonitorTypeTool(tool) && !isPlayLikeTool(tool) && (options.json || options.contractJson)) {
|
|
1348
|
-
const contract = toolContractJsonForDescribe(
|
|
1101
|
+
const contract = toolContractJsonForDescribe(
|
|
1102
|
+
tool,
|
|
1103
|
+
toolId,
|
|
1104
|
+
void 0,
|
|
1105
|
+
seedToolListScript
|
|
1106
|
+
);
|
|
1349
1107
|
printCompactJson({
|
|
1350
1108
|
toolId: contract.toolId,
|
|
1351
1109
|
...options.schemaOnly ? {
|
|
@@ -1370,7 +1128,12 @@ async function getTool(toolId, options = {}, compatibilityMetadata) {
|
|
|
1370
1128
|
}
|
|
1371
1129
|
if (options.contractJson) {
|
|
1372
1130
|
printCompactJson({
|
|
1373
|
-
...toolContractJsonForDescribe(
|
|
1131
|
+
...toolContractJsonForDescribe(
|
|
1132
|
+
tool,
|
|
1133
|
+
toolId,
|
|
1134
|
+
void 0,
|
|
1135
|
+
seedToolListScript
|
|
1136
|
+
),
|
|
1374
1137
|
...modelDescription ? { modelOptions: modelDescription } : {},
|
|
1375
1138
|
...inferenceQuote ? { inferenceQuote } : {}
|
|
1376
1139
|
});
|
|
@@ -1379,7 +1142,7 @@ async function getTool(toolId, options = {}, compatibilityMetadata) {
|
|
|
1379
1142
|
const emitJson = options.json === true;
|
|
1380
1143
|
if (emitJson) {
|
|
1381
1144
|
printCompactJson({
|
|
1382
|
-
...toolMetadataJsonForDescribe(tool, toolId),
|
|
1145
|
+
...toolMetadataJsonForDescribe(tool, toolId, seedToolListScript),
|
|
1383
1146
|
...modelDescription ? { modelOptions: modelDescription } : {},
|
|
1384
1147
|
...inferenceQuote ? { inferenceQuote } : {}
|
|
1385
1148
|
});
|
|
@@ -1428,114 +1191,11 @@ function inferenceQuoteSummaryLines(_quote) {
|
|
|
1428
1191
|
function printInferenceQuoteSummary(quote) {
|
|
1429
1192
|
for (const line of inferenceQuoteSummaryLines(quote)) console.log(line);
|
|
1430
1193
|
}
|
|
1431
|
-
function toolContractJsonForDescribe(tool, requestedToolId, authoringContractEdition) {
|
|
1432
|
-
const toolId = String(tool.toolId || requestedToolId);
|
|
1433
|
-
const inputFields = toolInputFieldsForDisplay(
|
|
1434
|
-
recordField(tool, "inputSchema", "input_schema")
|
|
1435
|
-
);
|
|
1436
|
-
const inputSchema = publicToolInputSchemaForDescribe(
|
|
1437
|
-
recordField(tool, "inputSchema", "input_schema")
|
|
1438
|
-
);
|
|
1439
|
-
const outputSchemaRecord = recordField(tool, "outputSchema", "output_schema");
|
|
1440
|
-
const outputFields = toolOutputFieldsForDisplay(outputSchemaRecord);
|
|
1441
|
-
const usageGuidance = recordField(tool, "usageGuidance", "usage_guidance");
|
|
1442
|
-
const guidance = recordField(tool, "guidance");
|
|
1443
|
-
const toolExecutionResult = recordField(
|
|
1444
|
-
usageGuidance,
|
|
1445
|
-
"toolExecutionResult",
|
|
1446
|
-
"tool_execution_result"
|
|
1447
|
-
);
|
|
1448
|
-
const extractedLists = extractionContractEntries(
|
|
1449
|
-
arrayField2(toolExecutionResult, "extractedLists", "extracted_lists")
|
|
1450
|
-
).map((entry) => ({
|
|
1451
|
-
...entry,
|
|
1452
|
-
returnType: playToolListGetterMode(authoringContractEdition) === "array" ? "Array" : "PlayDataset",
|
|
1453
|
-
rowsExpression: playToolListGetterMode(authoringContractEdition) === "array" ? entry.expression : `await ${entry.expression}.materialize()`
|
|
1454
|
-
}));
|
|
1455
|
-
const extractedValues = extractionContractEntries(
|
|
1456
|
-
arrayField2(toolExecutionResult, "extractedValues", "extracted_values")
|
|
1457
|
-
);
|
|
1458
|
-
const pricing = Capability.fromCatalogEntry(tool).describe().customerCost();
|
|
1459
|
-
const executionMetadataRecord = recordField(
|
|
1460
|
-
tool,
|
|
1461
|
-
"executionMetadata",
|
|
1462
|
-
"execution_metadata"
|
|
1463
|
-
);
|
|
1464
|
-
const executionMetadata = Object.keys(executionMetadataRecord).length > 0 ? executionMetadataRecord : null;
|
|
1465
|
-
const batchCapabilityRecord = recordField(
|
|
1466
|
-
tool,
|
|
1467
|
-
"batchCapability",
|
|
1468
|
-
"batch_capability"
|
|
1469
|
-
);
|
|
1470
|
-
const batchCapability = Object.keys(batchCapabilityRecord).length > 0 ? batchCapabilityRecord : null;
|
|
1471
|
-
const deprecation = recordField(tool, "deprecation");
|
|
1472
|
-
const replacementToolId = stringField2(
|
|
1473
|
-
deprecation,
|
|
1474
|
-
"replacementToolId",
|
|
1475
|
-
"replacement_tool_id"
|
|
1476
|
-
);
|
|
1477
|
-
const deprecationMessage = stringField2(deprecation, "message");
|
|
1478
|
-
const deprecationExecution = stringField2(deprecation, "execution");
|
|
1479
|
-
const deprecated = tool.deprecated === true || stringField2(tool, "credentialStatus", "credential_status") === "deprecated";
|
|
1480
|
-
const starterScript = !deprecated && !isPlayLikeTool(tool) && extractedLists.length > 0 ? starterScriptJson(
|
|
1481
|
-
seedToolListScript({
|
|
1482
|
-
toolId,
|
|
1483
|
-
payload: samplePayloadForInputFields(inputFields),
|
|
1484
|
-
rows: []
|
|
1485
|
-
})
|
|
1486
|
-
) : null;
|
|
1487
|
-
const executeCommand = deprecated && replacementToolId ? `deepline tools execute ${replacementToolId} --input '{...}'` : isPlayLikeTool(tool) ? playRunCommandForTool(tool, toolId) : `deepline tools execute ${toolId} --input '{...}'`;
|
|
1488
|
-
return {
|
|
1489
|
-
schemaVersion: 1,
|
|
1490
|
-
toolId,
|
|
1491
|
-
provider: tool.provider,
|
|
1492
|
-
displayName: tool.displayName,
|
|
1493
|
-
cost: pricing,
|
|
1494
|
-
description: tool.description,
|
|
1495
|
-
...Object.keys(guidance).length > 0 ? { guidance } : {},
|
|
1496
|
-
categories: tool.categories,
|
|
1497
|
-
...Array.isArray(tool.requestWarnings) ? { requestWarnings: tool.requestWarnings } : {},
|
|
1498
|
-
...deprecated ? {
|
|
1499
|
-
deprecated: true,
|
|
1500
|
-
callable: tool.callable !== false,
|
|
1501
|
-
deprecation: {
|
|
1502
|
-
replacementToolId,
|
|
1503
|
-
message: deprecationMessage,
|
|
1504
|
-
...deprecationExecution ? { execution: deprecationExecution } : {}
|
|
1505
|
-
}
|
|
1506
|
-
} : {},
|
|
1507
|
-
inputFields: inputFields.map(inputFieldJsonForDescribe),
|
|
1508
|
-
inputSchema,
|
|
1509
|
-
...isRecord(tool.responseSchema) ? { responseSchema: tool.responseSchema } : {},
|
|
1510
|
-
...Array.isArray(tool.examples) ? { examples: tool.examples } : {},
|
|
1511
|
-
responseAccess: "result.toolResponse.rawV2",
|
|
1512
|
-
...Object.keys(outputSchemaRecord).length > 0 ? {
|
|
1513
|
-
outputSchema: publicToolInputSchemaForDescribe(outputSchemaRecord),
|
|
1514
|
-
outputFields: outputFields.map(inputFieldJsonForDescribe)
|
|
1515
|
-
} : {},
|
|
1516
|
-
...executionMetadata ? { executionMetadata } : {},
|
|
1517
|
-
...batchCapability ? { batchCapability } : {},
|
|
1518
|
-
getters: {
|
|
1519
|
-
extractedLists,
|
|
1520
|
-
extractedValues
|
|
1521
|
-
},
|
|
1522
|
-
executeCommand,
|
|
1523
|
-
...starterScript ? { starterScript } : {}
|
|
1524
|
-
};
|
|
1525
|
-
}
|
|
1526
|
-
function extractionContractEntries(entries) {
|
|
1527
|
-
return entries.flatMap((entry) => {
|
|
1528
|
-
if (!isRecord(entry)) return [];
|
|
1529
|
-
const name = stringField2(entry, "name");
|
|
1530
|
-
const expression = stringField2(entry, "expression");
|
|
1531
|
-
return name && expression ? [{ name, expression }] : [];
|
|
1532
|
-
});
|
|
1533
|
-
}
|
|
1534
1194
|
function printMonitorTypeFilters(tool) {
|
|
1535
1195
|
const schema = recordField(tool, "payload_schema", "payloadSchema");
|
|
1536
1196
|
const properties = recordField(schema, "properties");
|
|
1537
1197
|
const required = new Set(
|
|
1538
|
-
|
|
1198
|
+
arrayField(schema, "required").filter(
|
|
1539
1199
|
(v) => typeof v === "string"
|
|
1540
1200
|
)
|
|
1541
1201
|
);
|
|
@@ -1548,11 +1208,11 @@ function printMonitorTypeFilters(tool) {
|
|
|
1548
1208
|
for (const name of names) {
|
|
1549
1209
|
const field = isRecord(properties[name]) ? properties[name] : {};
|
|
1550
1210
|
const star = required.has(name) ? "*" : "";
|
|
1551
|
-
const enumVals =
|
|
1211
|
+
const enumVals = arrayField(field, "enum").filter(
|
|
1552
1212
|
(v) => typeof v === "string"
|
|
1553
1213
|
);
|
|
1554
|
-
const type = enumVals.length ? `one of [${enumVals.join(", ")}]` :
|
|
1555
|
-
const desc =
|
|
1214
|
+
const type = enumVals.length ? `one of [${enumVals.join(", ")}]` : stringField(field, "type") || "string";
|
|
1215
|
+
const desc = stringField(field, "description");
|
|
1556
1216
|
console.log(`- ${name}${star}: ${type}${desc ? ` - ${desc}` : ""}`);
|
|
1557
1217
|
}
|
|
1558
1218
|
}
|
|
@@ -1561,10 +1221,10 @@ function printMonitorTypeFilterExamples(tool) {
|
|
|
1561
1221
|
const fields = recordField(documentation, "fields");
|
|
1562
1222
|
const examples = Object.entries(fields).flatMap(([name, rawField]) => {
|
|
1563
1223
|
const grammar = recordField(isRecord(rawField) ? rawField : {}, "grammar");
|
|
1564
|
-
const example =
|
|
1224
|
+
const example = stringField(grammar, "example");
|
|
1565
1225
|
const values = [
|
|
1566
|
-
...
|
|
1567
|
-
(
|
|
1226
|
+
...arrayField(grammar, "examples").filter(
|
|
1227
|
+
(value) => typeof value === "string" && Boolean(value)
|
|
1568
1228
|
),
|
|
1569
1229
|
...example ? [example] : []
|
|
1570
1230
|
];
|
|
@@ -1578,15 +1238,15 @@ function printMonitorTypeFilterExamples(tool) {
|
|
|
1578
1238
|
}
|
|
1579
1239
|
}
|
|
1580
1240
|
function printMonitorTypeStreams(tool) {
|
|
1581
|
-
const streams =
|
|
1241
|
+
const streams = arrayField(tool, "streams", "output_streams").filter(
|
|
1582
1242
|
isRecord
|
|
1583
1243
|
);
|
|
1584
1244
|
if (!streams.length) return;
|
|
1585
1245
|
console.log("");
|
|
1586
1246
|
console.log("Filter columns (a play's sqlListeners.where, per stream):");
|
|
1587
1247
|
for (const stream of streams) {
|
|
1588
|
-
const name =
|
|
1589
|
-
const cols =
|
|
1248
|
+
const name = stringField(stream, "stream");
|
|
1249
|
+
const cols = arrayField(stream, "columns").filter(isRecord).map((col) => stringField(col, "name")).filter(Boolean);
|
|
1590
1250
|
console.log(`- ${name}: ${cols.join(", ")}`);
|
|
1591
1251
|
}
|
|
1592
1252
|
}
|
|
@@ -1604,8 +1264,8 @@ function monitorTypePricingLines(tool) {
|
|
|
1604
1264
|
const lines = ["Pricing (Deepline credits per accepted event):"];
|
|
1605
1265
|
for (const key of keys) {
|
|
1606
1266
|
const entry = isRecord(byType[key]) ? byType[key] : {};
|
|
1607
|
-
const credits =
|
|
1608
|
-
const display =
|
|
1267
|
+
const credits = numberField(entry, "deepline_credits", "deeplineCredits");
|
|
1268
|
+
const display = stringField(entry, "display");
|
|
1609
1269
|
const shown = display || (credits !== null ? `${formatDecimal(credits)} credits/event` : "not listed");
|
|
1610
1270
|
lines.push(`- ${key}: ${shown}`);
|
|
1611
1271
|
}
|
|
@@ -1616,19 +1276,19 @@ function printMonitorTypePricing(tool) {
|
|
|
1616
1276
|
}
|
|
1617
1277
|
function printMonitorTypeDeploy(tool) {
|
|
1618
1278
|
const deploy = recordField(tool, "deploy");
|
|
1619
|
-
const toolId =
|
|
1620
|
-
const example =
|
|
1279
|
+
const toolId = stringField(tool, "toolId");
|
|
1280
|
+
const example = stringField(deploy, "example") || `deepline monitors deploy '{"key":"...","tool":"${toolId}","payload":{...}}'`;
|
|
1621
1281
|
console.log("Deploy (a monitor type is deployed, not executed):");
|
|
1622
1282
|
console.log(` ${example}`);
|
|
1623
1283
|
}
|
|
1624
1284
|
function printMonitorTypeContract(tool, requestedToolId) {
|
|
1625
|
-
const toolId =
|
|
1285
|
+
const toolId = stringField(tool, "toolId") || requestedToolId;
|
|
1626
1286
|
console.log(toolId);
|
|
1627
|
-
const displayName =
|
|
1287
|
+
const displayName = stringField(tool, "displayName");
|
|
1628
1288
|
if (displayName) console.log(`Best for: ${displayName}`);
|
|
1629
|
-
const description =
|
|
1289
|
+
const description = stringField(tool, "description");
|
|
1630
1290
|
if (description) console.log(`Description: ${description}`);
|
|
1631
|
-
const categories =
|
|
1291
|
+
const categories = arrayField(tool, "categories").filter(
|
|
1632
1292
|
(v) => typeof v === "string"
|
|
1633
1293
|
);
|
|
1634
1294
|
if (categories.length) console.log(`Tags: ${categories.join(", ")}`);
|
|
@@ -1647,174 +1307,10 @@ function printMonitorTypeContract(tool, requestedToolId) {
|
|
|
1647
1307
|
console.log("");
|
|
1648
1308
|
console.log(`More: deepline describe ${toolId}`);
|
|
1649
1309
|
}
|
|
1650
|
-
function schemaNodeAt(schema, path) {
|
|
1651
|
-
let node = schema;
|
|
1652
|
-
for (const part of path.split(".").filter(Boolean)) {
|
|
1653
|
-
const [key, ...indexes] = part.split("[");
|
|
1654
|
-
node = recordField(isRecord(node) ? node : {}, "properties")[key];
|
|
1655
|
-
for (const _index of indexes)
|
|
1656
|
-
node = isRecord(node) ? node.items : void 0;
|
|
1657
|
-
}
|
|
1658
|
-
return node;
|
|
1659
|
-
}
|
|
1660
|
-
var NAMED_VALUE_SHAPES = {
|
|
1661
|
-
email_status: { shape: "EmailStatus", schema: EMAIL_STATUS_JSON_SCHEMA },
|
|
1662
|
-
job_change: { shape: "JobChange", schema: JOB_CHANGE_JSON_SCHEMA }
|
|
1663
|
-
};
|
|
1664
|
-
function extractorValueType(name) {
|
|
1665
|
-
if (!isDeeplineExtractorTarget(name)) return void 0;
|
|
1666
|
-
const definition = DEEPLINE_EXTRACTOR_TARGET_DEFINITIONS[name];
|
|
1667
|
-
if (definition.enum) {
|
|
1668
|
-
return {
|
|
1669
|
-
type: definition.enum.map((value2) => JSON.stringify(value2)).join(" | ")
|
|
1670
|
-
};
|
|
1671
|
-
}
|
|
1672
|
-
const named = NAMED_VALUE_SHAPES[definition.valueKind];
|
|
1673
|
-
if (!named) return { type: "string" };
|
|
1674
|
-
const { type, fields } = schemaField(name, named.schema, true);
|
|
1675
|
-
return { type, ...fields ? { fields } : {}, shape: named.shape };
|
|
1676
|
-
}
|
|
1677
|
-
function jsonSchemaOf(wrapper) {
|
|
1678
|
-
return isRecord(wrapper.jsonSchema) ? wrapper.jsonSchema : wrapper;
|
|
1679
|
-
}
|
|
1680
|
-
function publicToolSchemas(tool) {
|
|
1681
|
-
const scrubbed = (...keys) => {
|
|
1682
|
-
const schema = recordField(tool, ...keys);
|
|
1683
|
-
if (Object.keys(schema).length === 0) return null;
|
|
1684
|
-
const cleaned = publicToolInputSchemaForDescribe(schema);
|
|
1685
|
-
return isRecord(cleaned.jsonSchema) ? cleaned.jsonSchema : cleaned;
|
|
1686
|
-
};
|
|
1687
|
-
const responseSchema = scrubbed("responseSchema", "response_schema");
|
|
1688
|
-
return {
|
|
1689
|
-
inputSchema: scrubbed(
|
|
1690
|
-
"inputSchema",
|
|
1691
|
-
"input_schema",
|
|
1692
|
-
"payload_schema",
|
|
1693
|
-
"payloadSchema"
|
|
1694
|
-
),
|
|
1695
|
-
outputSchema: scrubbed("outputSchema", "output_schema"),
|
|
1696
|
-
...responseSchema ? { responseSchema } : {}
|
|
1697
|
-
};
|
|
1698
|
-
}
|
|
1699
|
-
function describedTool(tool, requestedToolId) {
|
|
1700
|
-
const id = stringField2(tool, "toolId") || requestedToolId;
|
|
1701
|
-
const displayName = stringField2(tool, "displayName") || void 0;
|
|
1702
|
-
const description = stringField2(tool, "bestFor", "best_for") || stringField2(tool, "description") || void 0;
|
|
1703
|
-
if (isMonitorTypeTool(tool)) {
|
|
1704
|
-
return {
|
|
1705
|
-
kind: "monitor_type",
|
|
1706
|
-
id,
|
|
1707
|
-
displayName,
|
|
1708
|
-
description,
|
|
1709
|
-
cost: stringField2(recordField(tool, "pricing"), "displayText") || void 0,
|
|
1710
|
-
guidance: [],
|
|
1711
|
-
inputs: schemaFields(
|
|
1712
|
-
recordField(tool, "payload_schema", "payloadSchema")
|
|
1713
|
-
),
|
|
1714
|
-
outputs: [],
|
|
1715
|
-
runner: {
|
|
1716
|
-
via: "monitor",
|
|
1717
|
-
deploy: stringField2(recordField(tool, "deploy"), "example") || `deepline monitors deploy '{"key":"...","tool":"${id}","payload":{...}}'`
|
|
1718
|
-
}
|
|
1719
|
-
};
|
|
1720
|
-
}
|
|
1721
|
-
const contract = toolContractJsonForDescribe(tool, requestedToolId);
|
|
1722
|
-
const cost = recordField(contract, "cost");
|
|
1723
|
-
const billing = stringField2(cost, "billingSourceLabel");
|
|
1724
|
-
const deprecation = recordField(contract, "deprecation");
|
|
1725
|
-
const getters = recordField(contract, "getters");
|
|
1726
|
-
const outputSchema = jsonSchemaOf(recordField(contract, "outputSchema"));
|
|
1727
|
-
const toolResult = recordField(tool, "toolResult", "tool_result");
|
|
1728
|
-
const getterDetails = (kind) => new Map(
|
|
1729
|
-
arrayField2(toolResult, kind).filter(isRecord).map((item) => [
|
|
1730
|
-
stringField2(item, "name"),
|
|
1731
|
-
recordField(item, "details")
|
|
1732
|
-
])
|
|
1733
|
-
);
|
|
1734
|
-
const declared = recordField(tool, "extractors");
|
|
1735
|
-
const getterOutputs = (kind, roots) => {
|
|
1736
|
-
const details = getterDetails(kind);
|
|
1737
|
-
return arrayField2(getters, kind).filter(isRecord).map((entry) => {
|
|
1738
|
-
const name = stringField2(entry, "name");
|
|
1739
|
-
const rawPaths = arrayField2(
|
|
1740
|
-
details.get(name) ?? {},
|
|
1741
|
-
"rawToolOutputPaths"
|
|
1742
|
-
).map(String);
|
|
1743
|
-
const paths = rawPaths.map(
|
|
1744
|
-
(path) => path.replace(/^toolResponse\.raw\./, "")
|
|
1745
|
-
);
|
|
1746
|
-
const node = roots.flatMap((root) => paths.map((path) => schemaNodeAt(root, path))).find(isRecord);
|
|
1747
|
-
const { fields, ...typed } = schemaField(name, node, true);
|
|
1748
|
-
const valueType = stringField2(details.get(name) ?? {}, "valueType");
|
|
1749
|
-
const deepline = kind === "extractedValues" ? extractorValueType(name) : void 0;
|
|
1750
|
-
const known = typed.type !== "unknown" ? void 0 : kind === "extractedLists" ? { type: "object[]" } : deepline;
|
|
1751
|
-
const means = kind === "extractedValues" ? fieldOfName(
|
|
1752
|
-
name,
|
|
1753
|
-
stringField2(declared[name] ?? {}, "means") || void 0
|
|
1754
|
-
) : void 0;
|
|
1755
|
-
const field = {
|
|
1756
|
-
...typed,
|
|
1757
|
-
...means ? { means } : {},
|
|
1758
|
-
// A normalized value has a named type instead of the response's
|
|
1759
|
-
// shape; a normalized object is spelled out once under Types.
|
|
1760
|
-
...deepline?.shape ? deepline : valueType ? { type: valueType } : known ? known : fields ? { fields } : {},
|
|
1761
|
-
// A list's row columns that matter are value getters of their own.
|
|
1762
|
-
...kind === "extractedLists" && fields ? { summarized: true } : {},
|
|
1763
|
-
read: playResultExpression(entry),
|
|
1764
|
-
...rawPaths.length ? { paths: rawPaths } : {}
|
|
1765
|
-
};
|
|
1766
|
-
return { field, node };
|
|
1767
|
-
});
|
|
1768
|
-
};
|
|
1769
|
-
const declaredLists = getterOutputs("extractedLists", [outputSchema]);
|
|
1770
|
-
const lists = declaredLists.some(({ node }) => node) ? declaredLists.filter(({ node }) => node) : declaredLists;
|
|
1771
|
-
const values = getterOutputs("extractedValues", [
|
|
1772
|
-
outputSchema,
|
|
1773
|
-
...lists.map(({ node }) => node?.items)
|
|
1774
|
-
]).map((value2) => {
|
|
1775
|
-
if (!lists.length || !value2.field.paths) return value2;
|
|
1776
|
-
const within = value2.field.paths.map(
|
|
1777
|
-
(path) => path.replace(/^toolResponse\.raw\./, "")
|
|
1778
|
-
);
|
|
1779
|
-
const list = lists.find(
|
|
1780
|
-
({ node }) => within.some((path) => isRecord(schemaNodeAt(node?.items, path)))
|
|
1781
|
-
) ?? lists[0];
|
|
1782
|
-
return {
|
|
1783
|
-
...value2,
|
|
1784
|
-
field: { ...value2.field, in: list.field.name, paths: within }
|
|
1785
|
-
};
|
|
1786
|
-
});
|
|
1787
|
-
const playReference = isPlayLikeTool(tool) ? playReferenceForTool(tool) : null;
|
|
1788
|
-
return {
|
|
1789
|
-
kind: "tool",
|
|
1790
|
-
id: String(contract.toolId),
|
|
1791
|
-
displayName,
|
|
1792
|
-
description,
|
|
1793
|
-
cost: [
|
|
1794
|
-
stringField2(cost, "displayText"),
|
|
1795
|
-
// "Free (free)" says the same thing twice.
|
|
1796
|
-
billing.toLowerCase() === stringField2(cost, "displayText").toLowerCase() ? "" : billing && `(${billing})`,
|
|
1797
|
-
observedMaxText(cost) && `\u2014 ${observedMaxText(cost)}`
|
|
1798
|
-
].filter(Boolean).join(" ") || void 0,
|
|
1799
|
-
guidance: [
|
|
1800
|
-
...contract.deprecated === true ? [`Deprecated. ${stringField2(deprecation, "message")}`.trim()] : [],
|
|
1801
|
-
...Object.values(recordField(contract, "guidance")).filter(
|
|
1802
|
-
(line) => typeof line === "string" && /[a-z0-9]/i.test(line)
|
|
1803
|
-
)
|
|
1804
|
-
],
|
|
1805
|
-
rateLimit: rateLimitSummary(
|
|
1806
|
-
recordField(contract, "executionMetadata").configuredRateLimits
|
|
1807
|
-
),
|
|
1808
|
-
inputs: schemaFields(jsonSchemaOf(recordField(contract, "inputSchema"))),
|
|
1809
|
-
outputs: [...lists, ...values].map(({ field }) => field),
|
|
1810
|
-
rawResponse: schemaFields(outputSchema),
|
|
1811
|
-
runner: playReference ? { via: "play", reference: playReference } : { via: "tool", toolId: String(contract.toolId) }
|
|
1812
|
-
};
|
|
1813
|
-
}
|
|
1814
1310
|
function toolGuidanceLines(guidance) {
|
|
1815
1311
|
const record = isRecord(guidance) ? guidance : {};
|
|
1816
|
-
const toolGuidance =
|
|
1817
|
-
const providerGuidance =
|
|
1312
|
+
const toolGuidance = stringField(record, "tool");
|
|
1313
|
+
const providerGuidance = stringField(record, "provider");
|
|
1818
1314
|
return [
|
|
1819
1315
|
...toolGuidance ? [`- This tool: ${toolGuidance}`] : [],
|
|
1820
1316
|
...providerGuidance ? [`- Provider: ${providerGuidance}`] : []
|
|
@@ -1825,7 +1321,12 @@ function printCompactToolContract(tool, requestedToolId) {
|
|
|
1825
1321
|
printMonitorTypeContract(tool, requestedToolId);
|
|
1826
1322
|
return;
|
|
1827
1323
|
}
|
|
1828
|
-
const contract = toolContractJsonForDescribe(
|
|
1324
|
+
const contract = toolContractJsonForDescribe(
|
|
1325
|
+
tool,
|
|
1326
|
+
requestedToolId,
|
|
1327
|
+
void 0,
|
|
1328
|
+
seedToolListScript
|
|
1329
|
+
);
|
|
1829
1330
|
const cost = isRecord(contract.cost) ? contract.cost : {};
|
|
1830
1331
|
const getters = isRecord(contract.getters) ? contract.getters : {};
|
|
1831
1332
|
const listGetters = Array.isArray(getters.extractedLists) ? getters.extractedLists : [];
|
|
@@ -1849,8 +1350,8 @@ function printCompactToolContract(tool, requestedToolId) {
|
|
|
1849
1350
|
printToolExecutionHints(contract);
|
|
1850
1351
|
if (contract.deprecated === true) {
|
|
1851
1352
|
const deprecation = isRecord(contract.deprecation) ? contract.deprecation : {};
|
|
1852
|
-
const message =
|
|
1853
|
-
const replacementToolId =
|
|
1353
|
+
const message = stringField(deprecation, "message");
|
|
1354
|
+
const replacementToolId = stringField(
|
|
1854
1355
|
deprecation,
|
|
1855
1356
|
"replacementToolId",
|
|
1856
1357
|
"replacement_tool_id"
|
|
@@ -1876,11 +1377,11 @@ function printCompactToolContract(tool, requestedToolId) {
|
|
|
1876
1377
|
console.log("Inputs:");
|
|
1877
1378
|
for (const field of inputFields) {
|
|
1878
1379
|
if (!isRecord(field)) continue;
|
|
1879
|
-
const name =
|
|
1380
|
+
const name = stringField(field, "name");
|
|
1880
1381
|
if (!name) continue;
|
|
1881
1382
|
const required = field.required ? "*" : "";
|
|
1882
|
-
const type =
|
|
1883
|
-
const description =
|
|
1383
|
+
const type = stringField(field, "type") || "unknown";
|
|
1384
|
+
const description = stringField(field, "description");
|
|
1884
1385
|
const enumValues = Array.isArray(field.enum) ? field.enum : [];
|
|
1885
1386
|
const enumSuffix = enumValues.length ? ` enum=${enumValues.map(String).join("|")}` : "";
|
|
1886
1387
|
const itemBoundsSuffix = arrayItemBoundsSuffix(field);
|
|
@@ -1896,7 +1397,7 @@ function printCompactToolContract(tool, requestedToolId) {
|
|
|
1896
1397
|
console.log("");
|
|
1897
1398
|
printToolExamplesOnly(tool, requestedToolId);
|
|
1898
1399
|
const starterScript = isRecord(contract.starterScript) ? contract.starterScript : {};
|
|
1899
|
-
const starterPath =
|
|
1400
|
+
const starterPath = stringField(starterScript, "path");
|
|
1900
1401
|
if (starterPath) {
|
|
1901
1402
|
console.log("");
|
|
1902
1403
|
console.log(`Starter script: ${starterPath}`);
|
|
@@ -1909,14 +1410,14 @@ function printCompactToolContract(tool, requestedToolId) {
|
|
|
1909
1410
|
for (const entry of listGetters) {
|
|
1910
1411
|
if (isRecord(entry))
|
|
1911
1412
|
console.log(
|
|
1912
|
-
`- ${
|
|
1413
|
+
`- ${stringField(entry, "name")}: ${playResultExpression(entry)}`
|
|
1913
1414
|
);
|
|
1914
1415
|
}
|
|
1915
1416
|
if (valueGetters.length) console.log("Values:");
|
|
1916
1417
|
for (const entry of valueGetters) {
|
|
1917
1418
|
if (isRecord(entry))
|
|
1918
1419
|
console.log(
|
|
1919
|
-
`- ${
|
|
1420
|
+
`- ${stringField(entry, "name")}: ${playResultExpression(entry)}`
|
|
1920
1421
|
);
|
|
1921
1422
|
}
|
|
1922
1423
|
}
|
|
@@ -1932,14 +1433,14 @@ function toolPricingOnlyLines(tool, requestedToolId, options = {}) {
|
|
|
1932
1433
|
}
|
|
1933
1434
|
const toolId = String(tool.toolId || requestedToolId);
|
|
1934
1435
|
const cost = Capability.fromCatalogEntry(tool).describe().customerCost();
|
|
1935
|
-
const pricingModel =
|
|
1936
|
-
const billing =
|
|
1937
|
-
const explicitUnit =
|
|
1436
|
+
const pricingModel = stringField(cost, "pricingModel") || "unknown";
|
|
1437
|
+
const billing = stringField(cost, "billingSourceLabel") || stringField(cost, "billingSource") || stringField(cost, "billingMode") || "unknown";
|
|
1438
|
+
const explicitUnit = stringField(cost, "unit");
|
|
1938
1439
|
const unit = explicitUnit || (pricingModel === "per_page" ? "page" : pricingModel === "per_result" ? "result" : pricingModel === "fixed" ? "call" : pricingModel.replace(/^per_/, "") || "unit");
|
|
1939
|
-
const credits =
|
|
1940
|
-
const usd =
|
|
1941
|
-
const displayText =
|
|
1942
|
-
const summary =
|
|
1440
|
+
const credits = numberField(cost, "deeplineCreditsPerPricingUnit");
|
|
1441
|
+
const usd = numberField(cost, "deeplineUsdPerPricingUnit");
|
|
1442
|
+
const displayText = stringField(cost, "displayText");
|
|
1443
|
+
const summary = stringField(cost, "summary");
|
|
1943
1444
|
const price = displayText || summary || (credits !== null ? `${formatDecimal(credits)} Deepline credits${usd !== null ? ` / ${formatUsd(usd)}` : ""} per ${unit}` : "pricing unavailable");
|
|
1944
1445
|
return [
|
|
1945
1446
|
`${options.heading ?? `Pricing: ${toolId}`}: ${price}`,
|
|
@@ -1961,7 +1462,12 @@ function printToolSchemaOnly(tool, requestedToolId) {
|
|
|
1961
1462
|
printMonitorTypeStreams(tool);
|
|
1962
1463
|
return;
|
|
1963
1464
|
}
|
|
1964
|
-
const contract = toolContractJsonForDescribe(
|
|
1465
|
+
const contract = toolContractJsonForDescribe(
|
|
1466
|
+
tool,
|
|
1467
|
+
requestedToolId,
|
|
1468
|
+
void 0,
|
|
1469
|
+
seedToolListScript
|
|
1470
|
+
);
|
|
1965
1471
|
const inputFields = recursiveToolInputFieldsForDisplay(
|
|
1966
1472
|
recordField(contract, "inputSchema")
|
|
1967
1473
|
);
|
|
@@ -2010,10 +1516,15 @@ function printToolExamplesOnly(tool, requestedToolId) {
|
|
|
2010
1516
|
printPlayLikeToolUsage(tool, requestedToolId);
|
|
2011
1517
|
return;
|
|
2012
1518
|
}
|
|
2013
|
-
const contract = toolContractJsonForDescribe(
|
|
1519
|
+
const contract = toolContractJsonForDescribe(
|
|
1520
|
+
tool,
|
|
1521
|
+
requestedToolId,
|
|
1522
|
+
void 0,
|
|
1523
|
+
seedToolListScript
|
|
1524
|
+
);
|
|
2014
1525
|
const toolId = String(contract.toolId);
|
|
2015
1526
|
const inputFields = Array.isArray(contract.inputFields) ? contract.inputFields : [];
|
|
2016
|
-
const examples =
|
|
1527
|
+
const examples = arrayField(tool, "examples").filter(isRecord);
|
|
2017
1528
|
const firstExample = examples[0];
|
|
2018
1529
|
const sampleInput = firstExample && isRecord(firstExample.input) ? firstExample.input : samplePayload(recordField(tool, "samples"), "request") ?? samplePayloadForInputFields(inputFields);
|
|
2019
1530
|
console.log("Example input payload:");
|
|
@@ -2034,8 +1545,8 @@ function printToolExamplesOnly(tool, requestedToolId) {
|
|
|
2034
1545
|
const listGetters = Array.isArray(getters.extractedLists) ? getters.extractedLists : [];
|
|
2035
1546
|
const firstGetter = valueGetters.find(isRecord);
|
|
2036
1547
|
if (firstGetter) {
|
|
2037
|
-
const name =
|
|
2038
|
-
const expression =
|
|
1548
|
+
const name = stringField(firstGetter, "name") || "value";
|
|
1549
|
+
const expression = stringField(firstGetter, "expression");
|
|
2039
1550
|
if (expression)
|
|
2040
1551
|
console.log(
|
|
2041
1552
|
`const ${safeIdentifier(name)} = ${expression.replace(/^toolExecutionResult\./, "result.")};`
|
|
@@ -2047,10 +1558,10 @@ function printToolExamplesOnly(tool, requestedToolId) {
|
|
|
2047
1558
|
).filter((field) => String(field.type).split("|").includes("array")).map((field) => String(field.name).split(".").at(-1))
|
|
2048
1559
|
);
|
|
2049
1560
|
const firstList = listGetters.find(
|
|
2050
|
-
(entry) => isRecord(entry) && arrayNames.has(
|
|
1561
|
+
(entry) => isRecord(entry) && arrayNames.has(stringField(entry, "name"))
|
|
2051
1562
|
) ?? listGetters.find(isRecord);
|
|
2052
1563
|
if (isRecord(firstList)) {
|
|
2053
|
-
const name = safeIdentifier(
|
|
1564
|
+
const name = safeIdentifier(stringField(firstList, "name") || "list");
|
|
2054
1565
|
if (playToolListGetterMode() === "array") {
|
|
2055
1566
|
console.log(`const ${name}_rows = ${playResultExpression(firstList)};`);
|
|
2056
1567
|
} else {
|
|
@@ -2064,7 +1575,7 @@ function printToolExamplesOnly(tool, requestedToolId) {
|
|
|
2064
1575
|
console.log("```");
|
|
2065
1576
|
if (firstList) printListGetterConsumption();
|
|
2066
1577
|
for (const example of examples) {
|
|
2067
|
-
const description =
|
|
1578
|
+
const description = stringField(example, "description");
|
|
2068
1579
|
if (description) console.log(description);
|
|
2069
1580
|
console.log("Example Deepline execution response:");
|
|
2070
1581
|
console.log(JSON.stringify(example.response, null, 2));
|
|
@@ -2097,7 +1608,12 @@ function printPlayLikeToolUsage(tool, requestedToolId) {
|
|
|
2097
1608
|
}
|
|
2098
1609
|
}
|
|
2099
1610
|
function printToolGettersOnly(tool, requestedToolId) {
|
|
2100
|
-
const contract = toolContractJsonForDescribe(
|
|
1611
|
+
const contract = toolContractJsonForDescribe(
|
|
1612
|
+
tool,
|
|
1613
|
+
requestedToolId,
|
|
1614
|
+
void 0,
|
|
1615
|
+
seedToolListScript
|
|
1616
|
+
);
|
|
2101
1617
|
const getters = isRecord(contract.getters) ? contract.getters : {};
|
|
2102
1618
|
const listGetters = Array.isArray(getters.extractedLists) ? getters.extractedLists : [];
|
|
2103
1619
|
const valueGetters = Array.isArray(getters.extractedValues) ? getters.extractedValues : [];
|
|
@@ -2111,7 +1627,7 @@ function printToolGettersOnly(tool, requestedToolId) {
|
|
|
2111
1627
|
for (const entry of listGetters) {
|
|
2112
1628
|
if (isRecord(entry))
|
|
2113
1629
|
console.log(
|
|
2114
|
-
`- ${
|
|
1630
|
+
`- ${stringField(entry, "name")}: ${playResultExpression(entry)}`
|
|
2115
1631
|
);
|
|
2116
1632
|
}
|
|
2117
1633
|
printListGetterConsumption();
|
|
@@ -2121,7 +1637,7 @@ function printToolGettersOnly(tool, requestedToolId) {
|
|
|
2121
1637
|
for (const entry of valueGetters) {
|
|
2122
1638
|
if (isRecord(entry))
|
|
2123
1639
|
console.log(
|
|
2124
|
-
`- ${
|
|
1640
|
+
`- ${stringField(entry, "name")}: ${playResultExpression(entry)}`
|
|
2125
1641
|
);
|
|
2126
1642
|
}
|
|
2127
1643
|
}
|
|
@@ -2140,32 +1656,6 @@ function printListGetterConsumption() {
|
|
|
2140
1656
|
function listGetterHeading() {
|
|
2141
1657
|
return playToolListGetterMode() === "array" ? "Lists (ordinary JavaScript arrays):" : "Lists (PlayDataset, not a JavaScript array):";
|
|
2142
1658
|
}
|
|
2143
|
-
function sampleValueForField(field) {
|
|
2144
|
-
const name = stringField2(field, "name").toLowerCase();
|
|
2145
|
-
const type = stringField2(field, "type").toLowerCase();
|
|
2146
|
-
if (Object.prototype.hasOwnProperty.call(field, "default"))
|
|
2147
|
-
return field.default;
|
|
2148
|
-
if (name.includes("email")) return "ada@example.com";
|
|
2149
|
-
if (name.includes("domain") || name.includes("website")) return "example.com";
|
|
2150
|
-
if (name.includes("first")) return "Ada";
|
|
2151
|
-
if (name.includes("last")) return "Lovelace";
|
|
2152
|
-
if (name.includes("name")) return "Ada Lovelace";
|
|
2153
|
-
if (type === "integer" || type === "number") return 1;
|
|
2154
|
-
if (type === "boolean") return true;
|
|
2155
|
-
if (type === "array") return [];
|
|
2156
|
-
if (type === "object") return {};
|
|
2157
|
-
return "...";
|
|
2158
|
-
}
|
|
2159
|
-
function samplePayloadForInputFields(fields) {
|
|
2160
|
-
return Object.fromEntries(
|
|
2161
|
-
fields.slice(0, 4).flatMap((field) => {
|
|
2162
|
-
if (!isRecord(field)) return [];
|
|
2163
|
-
const name = stringField2(field, "name");
|
|
2164
|
-
if (!name) return [];
|
|
2165
|
-
return [[name, sampleValueForField(field)]];
|
|
2166
|
-
})
|
|
2167
|
-
);
|
|
2168
|
-
}
|
|
2169
1659
|
function stableStepIdForTool(toolId) {
|
|
2170
1660
|
return toolId.replace(/^[a-z0-9]+_/, "").replace(/[^a-z0-9_]+/gi, "_") || "tool_call";
|
|
2171
1661
|
}
|
|
@@ -2173,129 +1663,9 @@ function safeIdentifier(name) {
|
|
|
2173
1663
|
const cleaned = name.replace(/[^a-zA-Z0-9_$]+/g, "_").replace(/^[^a-zA-Z_$]+/, "");
|
|
2174
1664
|
return cleaned || "value";
|
|
2175
1665
|
}
|
|
2176
|
-
function
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
"result."
|
|
2180
|
-
);
|
|
2181
|
-
}
|
|
2182
|
-
function toolMetadataJsonForDescribe(tool, requestedToolId) {
|
|
2183
|
-
const toolId = String(tool.toolId || requestedToolId);
|
|
2184
|
-
const inputFields = toolInputFieldsForDisplay(
|
|
2185
|
-
recordField(tool, "inputSchema", "input_schema")
|
|
2186
|
-
);
|
|
2187
|
-
const usageGuidance = usageGuidanceWithAccessDefaults(
|
|
2188
|
-
recordField(tool, "usageGuidance", "usage_guidance")
|
|
2189
|
-
);
|
|
2190
|
-
const toolExecutionResult = recordField(
|
|
2191
|
-
usageGuidance,
|
|
2192
|
-
"toolExecutionResult",
|
|
2193
|
-
"tool_execution_result"
|
|
2194
|
-
);
|
|
2195
|
-
const extractedLists = extractionContractEntries(
|
|
2196
|
-
arrayField2(toolExecutionResult, "extractedLists", "extracted_lists")
|
|
2197
|
-
);
|
|
2198
|
-
const starterScript = !isPlayLikeTool(tool) && extractedLists.length > 0 ? starterScriptJson(
|
|
2199
|
-
seedToolListScript({
|
|
2200
|
-
toolId,
|
|
2201
|
-
payload: samplePayloadForInputFields(inputFields),
|
|
2202
|
-
rows: []
|
|
2203
|
-
})
|
|
2204
|
-
) : null;
|
|
2205
|
-
const observedOutputCommand = isPlayLikeTool(tool) ? playRunCommandForTool(tool, toolId) : `deepline tools execute ${toolId} --input '{...}'`;
|
|
2206
|
-
const {
|
|
2207
|
-
cost: _cost,
|
|
2208
|
-
deeplineCreditsPerPricingUnit: _deeplineCreditsPerPricingUnit,
|
|
2209
|
-
deeplineUsdPerPricingUnit: _deeplineUsdPerPricingUnit,
|
|
2210
|
-
deeplineUsdPerCredit: _deeplineUsdPerCredit,
|
|
2211
|
-
deeplinePricingSummary: _deeplinePricingSummary,
|
|
2212
|
-
deeplinePricingDetails: _deeplinePricingDetails,
|
|
2213
|
-
deepline_credits_per_pricing_unit: _snakeDeeplineCreditsPerPricingUnit,
|
|
2214
|
-
deepline_usd_per_pricing_unit: _snakeDeeplineUsdPerPricingUnit,
|
|
2215
|
-
deepline_usd_per_credit: _snakeDeeplineUsdPerCredit,
|
|
2216
|
-
deepline_pricing_summary: _snakeDeeplinePricingSummary,
|
|
2217
|
-
deepline_pricing_details: _snakeDeeplinePricingDetails,
|
|
2218
|
-
// BYOK is shown only on request, via describe --feature byok.
|
|
2219
|
-
byok: _byok,
|
|
2220
|
-
...publicTool
|
|
2221
|
-
} = tool;
|
|
2222
|
-
const outputSchemaRecord = recordField(tool, "outputSchema", "output_schema");
|
|
2223
|
-
return {
|
|
2224
|
-
cost: Capability.fromCatalogEntry(tool).describe().customerCost(),
|
|
2225
|
-
...publicTool,
|
|
2226
|
-
toolId,
|
|
2227
|
-
provider: tool.provider,
|
|
2228
|
-
displayName: tool.displayName,
|
|
2229
|
-
...Object.keys(outputSchemaRecord).length > 0 ? {
|
|
2230
|
-
outputSchema: publicToolInputSchemaForDescribe(outputSchemaRecord),
|
|
2231
|
-
outputFields: toolOutputFieldsForDisplay(outputSchemaRecord).map(
|
|
2232
|
-
inputFieldJsonForDescribe
|
|
2233
|
-
)
|
|
2234
|
-
} : {},
|
|
2235
|
-
inputFields: inputFields.map(inputFieldJsonForDescribe),
|
|
2236
|
-
usageGuidance,
|
|
2237
|
-
runtimeOutputHelp: {
|
|
2238
|
-
contract: "Schemas declare field shapes. Examples illustrate input payloads and full Deepline execution responses; they are not observed responses from this call.",
|
|
2239
|
-
getterScope: "extractedValues/extractedLists .get() only works for declared Deepline getters listed in usageGuidance.toolExecutionResult.",
|
|
2240
|
-
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.",
|
|
2241
|
-
invalidGetterHint: "If TypeScript says an extractedValues/extractedLists property does not exist, that field is not a declared Deepline getter.",
|
|
2242
|
-
observeActualShape: observedOutputCommand,
|
|
2243
|
-
observedOutput: observedOutputCommand,
|
|
2244
|
-
forPlayGetterBugs: "Run a tiny play, inspect returned handles with `deepline runs get <run-id> --full`, then export row datasets with `deepline runs export`.",
|
|
2245
|
-
executeOutputFields: "tools execute JSON may include output_preview for this direct probe only; play debugging uses run output and returned dataset handles."
|
|
2246
|
-
},
|
|
2247
|
-
...starterScript ? { starterScript } : {}
|
|
2248
|
-
};
|
|
2249
|
-
}
|
|
2250
|
-
function usageGuidanceWithAccessDefaults(usageGuidance) {
|
|
2251
|
-
if (Object.keys(usageGuidance).length === 0) return usageGuidance;
|
|
2252
|
-
const existingAccess = recordField(usageGuidance, "access");
|
|
2253
|
-
return {
|
|
2254
|
-
...usageGuidance,
|
|
2255
|
-
prefer: [
|
|
2256
|
-
"Use only the declared extractedLists and extractedValues getters listed below.",
|
|
2257
|
-
"Use toolExecutionResult.toolResponse.rawV2 for the complete tool response, preserving the nesting shown in the response example.",
|
|
2258
|
-
"Schemas declare field shapes; examples illustrate input values and full Deepline execution responses."
|
|
2259
|
-
],
|
|
2260
|
-
toolExecutionResult: {
|
|
2261
|
-
...recordField(
|
|
2262
|
-
usageGuidance,
|
|
2263
|
-
"toolExecutionResult",
|
|
2264
|
-
"tool_execution_result"
|
|
2265
|
-
),
|
|
2266
|
-
toolResponse: {
|
|
2267
|
-
rawV2: "toolResponse.rawV2",
|
|
2268
|
-
view: "toolResponse.view",
|
|
2269
|
-
responseMeta: "toolResponse.responseMeta"
|
|
2270
|
-
}
|
|
2271
|
-
},
|
|
2272
|
-
access: {
|
|
2273
|
-
...existingAccess,
|
|
2274
|
-
extractedValues: {
|
|
2275
|
-
expression: "toolExecutionResult.extractedValues.<name>.get()",
|
|
2276
|
-
meaning: "Declared Deepline scalar or normalized object extractors only."
|
|
2277
|
-
},
|
|
2278
|
-
...existingAccess,
|
|
2279
|
-
extractedLists: {
|
|
2280
|
-
...recordField(existingAccess, "extractedLists"),
|
|
2281
|
-
expression: "toolExecutionResult.extractedLists.<name>.get()",
|
|
2282
|
-
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."
|
|
2283
|
-
},
|
|
2284
|
-
rawToolResponse: {
|
|
2285
|
-
expression: "toolExecutionResult.toolResponse.rawV2",
|
|
2286
|
-
meaning: "Complete tool response with its original nesting. Read tool-specific fields here; use declared getters for extracted values and lists."
|
|
2287
|
-
},
|
|
2288
|
-
canonicalToolResponse: {
|
|
2289
|
-
expression: "toolExecutionResult.toolResponse.rawV2",
|
|
2290
|
-
meaning: "Complete tool response with its original nesting and sibling fields."
|
|
2291
|
-
},
|
|
2292
|
-
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."
|
|
2293
|
-
}
|
|
2294
|
-
};
|
|
2295
|
-
}
|
|
2296
|
-
function singleLineText(value2, maxLength = 260) {
|
|
2297
|
-
if (typeof value2 !== "string") return "";
|
|
2298
|
-
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();
|
|
2299
1669
|
if (text.length <= maxLength) return text;
|
|
2300
1670
|
return `${text.slice(0, maxLength - 3).trimEnd()}...`;
|
|
2301
1671
|
}
|
|
@@ -2305,62 +1675,13 @@ function listedToolDescription(tool) {
|
|
|
2305
1675
|
}
|
|
2306
1676
|
function formatListedToolCost(tool) {
|
|
2307
1677
|
const record = tool;
|
|
2308
|
-
if (
|
|
1678
|
+
if (stringField(record, "billingSource", "billing_source") === "free") {
|
|
2309
1679
|
return "Cost: Free";
|
|
2310
1680
|
}
|
|
2311
1681
|
const pricing = recordField(record, "pricing");
|
|
2312
|
-
const displayText =
|
|
1682
|
+
const displayText = stringField(pricing, "displayText", "display_text");
|
|
2313
1683
|
return displayText ? `Cost: ${displayText}` : "";
|
|
2314
1684
|
}
|
|
2315
|
-
function toolInputFieldsForDisplay(inputSchema) {
|
|
2316
|
-
if (Array.isArray(inputSchema.fields)) {
|
|
2317
|
-
const fields = inputSchema.fields.filter(isRecord);
|
|
2318
|
-
if (!isRecord(inputSchema.jsonSchema)) return fields;
|
|
2319
|
-
const jsonSchemaFields = new Map(
|
|
2320
|
-
recursiveToolInputFieldsForDisplay({
|
|
2321
|
-
jsonSchema: inputSchema.jsonSchema
|
|
2322
|
-
}).flatMap(
|
|
2323
|
-
(field) => typeof field.name === "string" ? [[field.name, field]] : []
|
|
2324
|
-
)
|
|
2325
|
-
);
|
|
2326
|
-
return fields.map((field) => {
|
|
2327
|
-
const jsonSchemaField = typeof field.name === "string" ? jsonSchemaFields.get(field.name) : void 0;
|
|
2328
|
-
const minItems = typeof field.minItems === "number" ? field.minItems : jsonSchemaField?.minItems;
|
|
2329
|
-
const maxItems = typeof field.maxItems === "number" ? field.maxItems : jsonSchemaField?.maxItems;
|
|
2330
|
-
const items = isRecord(field.items) ? field.items : jsonSchemaField?.items;
|
|
2331
|
-
return {
|
|
2332
|
-
...field,
|
|
2333
|
-
...isRecord(items) ? { items } : {},
|
|
2334
|
-
...typeof minItems === "number" ? { minItems } : {},
|
|
2335
|
-
...typeof maxItems === "number" ? { maxItems } : {}
|
|
2336
|
-
};
|
|
2337
|
-
});
|
|
2338
|
-
}
|
|
2339
|
-
const jsonSchema = isRecord(inputSchema.jsonSchema) ? inputSchema.jsonSchema : inputSchema;
|
|
2340
|
-
const properties = isRecord(jsonSchema.properties) ? jsonSchema.properties : {};
|
|
2341
|
-
const required = Array.isArray(jsonSchema.required) ? new Set(jsonSchema.required.map(String)) : /* @__PURE__ */ new Set();
|
|
2342
|
-
return Object.entries(properties).map(([name, value2]) => {
|
|
2343
|
-
const property = isRecord(value2) ? value2 : {};
|
|
2344
|
-
return {
|
|
2345
|
-
name,
|
|
2346
|
-
type: typeof property.type === "string" ? property.type : "unknown",
|
|
2347
|
-
required: required.has(name),
|
|
2348
|
-
description: property.description,
|
|
2349
|
-
...isRecord(property.items) ? { items: property.items } : {},
|
|
2350
|
-
...typeof property.minItems === "number" ? { minItems: property.minItems } : {},
|
|
2351
|
-
...typeof property.maxItems === "number" ? { maxItems: property.maxItems } : {},
|
|
2352
|
-
...Object.prototype.hasOwnProperty.call(property, "default") ? { default: property.default } : {}
|
|
2353
|
-
};
|
|
2354
|
-
});
|
|
2355
|
-
}
|
|
2356
|
-
function toolOutputFieldsForDisplay(outputSchema) {
|
|
2357
|
-
if (Object.keys(outputSchema).length === 0) return [];
|
|
2358
|
-
return recursiveToolInputFieldsForDisplay({
|
|
2359
|
-
jsonSchema: outputSchema
|
|
2360
|
-
}).filter(
|
|
2361
|
-
(field) => typeof field.name === "string" && field.name.includes("[]")
|
|
2362
|
-
);
|
|
2363
|
-
}
|
|
2364
1685
|
function printToolOutputArrayShape(tool) {
|
|
2365
1686
|
const outputFields = toolOutputFieldsForDisplay(
|
|
2366
1687
|
recordField(isRecord(tool) ? tool : {}, "outputSchema", "output_schema")
|
|
@@ -2369,7 +1690,7 @@ function printToolOutputArrayShape(tool) {
|
|
|
2369
1690
|
console.log(" Output array shape (declared schema):");
|
|
2370
1691
|
for (const field of outputFields.slice(0, 60)) {
|
|
2371
1692
|
const name = String(field.name);
|
|
2372
|
-
const type =
|
|
1693
|
+
const type = stringField(field, "type") || "unknown";
|
|
2373
1694
|
const itemBounds = arrayItemBoundsSuffix(field);
|
|
2374
1695
|
console.log(` - ${name}: ${type}${itemBounds}`);
|
|
2375
1696
|
}
|
|
@@ -2377,142 +1698,12 @@ function printToolOutputArrayShape(tool) {
|
|
|
2377
1698
|
console.log(` - \u2026 ${outputFields.length - 60} more schema fields`);
|
|
2378
1699
|
}
|
|
2379
1700
|
}
|
|
2380
|
-
function canonicalToolJsonSchema(inputSchema) {
|
|
2381
|
-
return isRecord(inputSchema.jsonSchema) ? inputSchema.jsonSchema : inputSchema;
|
|
2382
|
-
}
|
|
2383
1701
|
function declaredToolJsonSchema(inputSchema) {
|
|
2384
1702
|
if (isRecord(inputSchema.jsonSchema)) {
|
|
2385
1703
|
return inputSchema.jsonSchema;
|
|
2386
1704
|
}
|
|
2387
1705
|
return Array.isArray(inputSchema.fields) ? null : inputSchema;
|
|
2388
1706
|
}
|
|
2389
|
-
function publicToolInputSchemaForDescribe(inputSchema) {
|
|
2390
|
-
const exposesProviderSpend = (description) => {
|
|
2391
|
-
const withoutDeeplineCredits = description.replace(
|
|
2392
|
-
/\bdeepline(?:-facing)?\s+credits?\b/gi,
|
|
2393
|
-
""
|
|
2394
|
-
);
|
|
2395
|
-
return /\bcredits?\b/i.test(withoutDeeplineCredits) || /\bprovider\s+(?:cost|spend|price|pricing|usage)\b/i.test(
|
|
2396
|
-
withoutDeeplineCredits
|
|
2397
|
-
) || /\b(?:costs?|charges?|priced at)\s+[$€£]\s*\d/i.test(
|
|
2398
|
-
withoutDeeplineCredits
|
|
2399
|
-
) || /\b(?:costs?|charges?|priced at)\s+\d+(?:\.\d+)?\s*(?:usd|eur|gbp)\b/i.test(
|
|
2400
|
-
withoutDeeplineCredits
|
|
2401
|
-
) || /\battribute-priced\b/i.test(withoutDeeplineCredits) || /\b(?:cost|price|pricing)\s+(?:grows?|increases?|scales?|varies?)\b/i.test(
|
|
2402
|
-
withoutDeeplineCredits
|
|
2403
|
-
) || /\b(?:will be|are|is|be)\s+(?:billed|charged)\b/i.test(
|
|
2404
|
-
withoutDeeplineCredits
|
|
2405
|
-
) || /\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);
|
|
2406
|
-
};
|
|
2407
|
-
const stripDescriptions = (value2) => {
|
|
2408
|
-
if (Array.isArray(value2)) return value2.map(stripDescriptions);
|
|
2409
|
-
if (!isRecord(value2)) return value2;
|
|
2410
|
-
return Object.fromEntries(
|
|
2411
|
-
Object.entries(value2).flatMap(([key, nested]) => {
|
|
2412
|
-
if (key === "description" && typeof nested === "string" && exposesProviderSpend(nested)) {
|
|
2413
|
-
return [];
|
|
2414
|
-
}
|
|
2415
|
-
return [[key, stripDescriptions(nested)]];
|
|
2416
|
-
})
|
|
2417
|
-
);
|
|
2418
|
-
};
|
|
2419
|
-
return stripDescriptions(inputSchema);
|
|
2420
|
-
}
|
|
2421
|
-
function recursiveToolInputFieldsForDisplay(inputSchema) {
|
|
2422
|
-
const root = canonicalToolJsonSchema(inputSchema);
|
|
2423
|
-
const fields = /* @__PURE__ */ new Map();
|
|
2424
|
-
const schemasById = /* @__PURE__ */ new Map();
|
|
2425
|
-
const collectSchemaIds = (value2) => {
|
|
2426
|
-
if (Array.isArray(value2)) {
|
|
2427
|
-
for (const item of value2) collectSchemaIds(item);
|
|
2428
|
-
return;
|
|
2429
|
-
}
|
|
2430
|
-
if (!isRecord(value2)) return;
|
|
2431
|
-
if (typeof value2.$id === "string" && value2.$id.trim()) {
|
|
2432
|
-
schemasById.set(value2.$id.trim(), value2);
|
|
2433
|
-
}
|
|
2434
|
-
for (const nested of Object.values(value2)) collectSchemaIds(nested);
|
|
2435
|
-
};
|
|
2436
|
-
collectSchemaIds(root);
|
|
2437
|
-
const resolveRef = (schema) => {
|
|
2438
|
-
const ref = typeof schema.$ref === "string" ? schema.$ref : "";
|
|
2439
|
-
if (!ref.startsWith("#/")) return schemasById.get(ref) ?? schema;
|
|
2440
|
-
let current = root;
|
|
2441
|
-
for (const rawSegment of ref.slice(2).split("/")) {
|
|
2442
|
-
const segment = rawSegment.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
2443
|
-
if (!isRecord(current)) return schema;
|
|
2444
|
-
current = current[segment];
|
|
2445
|
-
}
|
|
2446
|
-
return isRecord(current) ? current : schema;
|
|
2447
|
-
};
|
|
2448
|
-
const addField = (field) => {
|
|
2449
|
-
const name = typeof field.name === "string" ? field.name : "";
|
|
2450
|
-
if (!name) return;
|
|
2451
|
-
const existing = fields.get(name);
|
|
2452
|
-
if (!existing || existing.type === "unknown") {
|
|
2453
|
-
fields.set(name, field);
|
|
2454
|
-
}
|
|
2455
|
-
};
|
|
2456
|
-
const visit = (unresolvedSchema, path, required, activeRefs = /* @__PURE__ */ new Set()) => {
|
|
2457
|
-
const ref = typeof unresolvedSchema.$ref === "string" ? unresolvedSchema.$ref : "";
|
|
2458
|
-
if (ref && activeRefs.has(ref)) return;
|
|
2459
|
-
const schema = resolveRef(unresolvedSchema);
|
|
2460
|
-
const nextActiveRefs = ref ? /* @__PURE__ */ new Set([...activeRefs, ref]) : activeRefs;
|
|
2461
|
-
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";
|
|
2462
|
-
if (path) {
|
|
2463
|
-
addField({
|
|
2464
|
-
name: path,
|
|
2465
|
-
type,
|
|
2466
|
-
required,
|
|
2467
|
-
description: schema.description,
|
|
2468
|
-
...Array.isArray(schema.enum) ? { enum: schema.enum } : {},
|
|
2469
|
-
...isRecord(schema.items) ? { items: schema.items } : {},
|
|
2470
|
-
...typeof schema.minItems === "number" ? { minItems: schema.minItems } : {},
|
|
2471
|
-
...typeof schema.maxItems === "number" ? { maxItems: schema.maxItems } : {},
|
|
2472
|
-
...Object.prototype.hasOwnProperty.call(schema, "default") ? { default: schema.default } : {}
|
|
2473
|
-
});
|
|
2474
|
-
}
|
|
2475
|
-
const properties = isRecord(schema.properties) ? schema.properties : {};
|
|
2476
|
-
const requiredNames = new Set(
|
|
2477
|
-
Array.isArray(schema.required) ? schema.required.map(String) : []
|
|
2478
|
-
);
|
|
2479
|
-
for (const [name, value2] of Object.entries(properties)) {
|
|
2480
|
-
if (!isRecord(value2)) continue;
|
|
2481
|
-
visit(
|
|
2482
|
-
value2,
|
|
2483
|
-
path ? `${path}.${name}` : name,
|
|
2484
|
-
requiredNames.has(name),
|
|
2485
|
-
nextActiveRefs
|
|
2486
|
-
);
|
|
2487
|
-
}
|
|
2488
|
-
if (isRecord(schema.items)) {
|
|
2489
|
-
visit(schema.items, `${path}[]`, false, nextActiveRefs);
|
|
2490
|
-
}
|
|
2491
|
-
for (const keyword of ["anyOf", "oneOf", "allOf"]) {
|
|
2492
|
-
const branches = Array.isArray(schema[keyword]) ? schema[keyword] : [];
|
|
2493
|
-
for (const branch of branches) {
|
|
2494
|
-
if (isRecord(branch)) {
|
|
2495
|
-
visit(branch, path, required, nextActiveRefs);
|
|
2496
|
-
}
|
|
2497
|
-
}
|
|
2498
|
-
}
|
|
2499
|
-
};
|
|
2500
|
-
visit(root, "", false);
|
|
2501
|
-
return fields.size ? [...fields.values()] : toolInputFieldsForDisplay(inputSchema);
|
|
2502
|
-
}
|
|
2503
|
-
function inputFieldJsonForDescribe(field) {
|
|
2504
|
-
const publicItems = isRecord(field.items) ? publicToolInputSchemaForDescribe({ items: field.items }).items : void 0;
|
|
2505
|
-
return {
|
|
2506
|
-
name: field.name,
|
|
2507
|
-
type: field.type ?? "unknown",
|
|
2508
|
-
required: Boolean(field.required),
|
|
2509
|
-
...field.description ? { description: field.description } : {},
|
|
2510
|
-
...isRecord(publicItems) ? { items: publicItems } : {},
|
|
2511
|
-
...typeof field.minItems === "number" ? { minItems: field.minItems } : {},
|
|
2512
|
-
...typeof field.maxItems === "number" ? { maxItems: field.maxItems } : {},
|
|
2513
|
-
...Object.prototype.hasOwnProperty.call(field, "default") ? { default: field.default } : {}
|
|
2514
|
-
};
|
|
2515
|
-
}
|
|
2516
1707
|
function arrayItemBoundsSuffix(field) {
|
|
2517
1708
|
const itemSchema = isRecord(field.items) ? field.items : null;
|
|
2518
1709
|
const itemType = itemSchema ? typeof itemSchema.type === "string" ? itemSchema.type : isRecord(itemSchema.properties) ? "object" : "unknown" : null;
|
|
@@ -2527,32 +1718,32 @@ function arrayItemBoundsSuffix(field) {
|
|
|
2527
1718
|
if (maxItems !== null) return `${itemTypeSuffix} maxItems=${maxItems}`;
|
|
2528
1719
|
return itemTypeSuffix;
|
|
2529
1720
|
}
|
|
2530
|
-
function printToolExecutionHints(
|
|
1721
|
+
function printToolExecutionHints(value) {
|
|
2531
1722
|
const batchCapabilityRecord = recordField(
|
|
2532
|
-
isRecord(
|
|
1723
|
+
isRecord(value) ? value : {},
|
|
2533
1724
|
"batchCapability",
|
|
2534
1725
|
"batch_capability"
|
|
2535
1726
|
);
|
|
2536
1727
|
const batchCapability = Object.keys(batchCapabilityRecord).length > 0 ? batchCapabilityRecord : null;
|
|
2537
1728
|
const executionMetadata = recordField(
|
|
2538
|
-
isRecord(
|
|
1729
|
+
isRecord(value) ? value : {},
|
|
2539
1730
|
"executionMetadata",
|
|
2540
1731
|
"execution_metadata"
|
|
2541
1732
|
);
|
|
2542
1733
|
if (batchCapability) {
|
|
2543
|
-
const status =
|
|
2544
|
-
const surface =
|
|
2545
|
-
const operation =
|
|
1734
|
+
const status = stringField(batchCapability, "status") || "unknown";
|
|
1735
|
+
const surface = stringField(batchCapability, "surface");
|
|
1736
|
+
const operation = stringField(
|
|
2546
1737
|
batchCapability,
|
|
2547
1738
|
"batchOperation",
|
|
2548
1739
|
"batch_operation"
|
|
2549
1740
|
);
|
|
2550
|
-
const maxBatchSize =
|
|
1741
|
+
const maxBatchSize = numberField(
|
|
2551
1742
|
batchCapability,
|
|
2552
1743
|
"maxBatchSize",
|
|
2553
1744
|
"max_batch_size"
|
|
2554
1745
|
);
|
|
2555
|
-
const notes =
|
|
1746
|
+
const notes = stringField(batchCapability, "notes");
|
|
2556
1747
|
console.log("");
|
|
2557
1748
|
console.log("Batching:");
|
|
2558
1749
|
console.log(`- Catalog status: ${status}${surface ? ` (${surface})` : ""}`);
|
|
@@ -2571,7 +1762,7 @@ function printToolExecutionHints(value2) {
|
|
|
2571
1762
|
}
|
|
2572
1763
|
if (notes) console.log(`- Details: ${notes}`);
|
|
2573
1764
|
}
|
|
2574
|
-
const configuredRateLimits =
|
|
1765
|
+
const configuredRateLimits = arrayField(
|
|
2575
1766
|
executionMetadata,
|
|
2576
1767
|
"configuredRateLimits",
|
|
2577
1768
|
"configured_rate_limits"
|
|
@@ -2582,12 +1773,12 @@ function printToolExecutionHints(value2) {
|
|
|
2582
1773
|
"Configured Deepline pacing (guidance, not a guaranteed provider quota):"
|
|
2583
1774
|
);
|
|
2584
1775
|
for (const limit of configuredRateLimits) {
|
|
2585
|
-
const requests =
|
|
2586
|
-
const windowMs =
|
|
1776
|
+
const requests = numberField(limit, "requestsPerWindow");
|
|
1777
|
+
const windowMs = numberField(limit, "windowMs");
|
|
2587
1778
|
if (requests === null || windowMs === null) continue;
|
|
2588
|
-
const usage =
|
|
1779
|
+
const usage = stringField(limit, "usage") || "unknown";
|
|
2589
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;
|
|
2590
|
-
const explicitMaxConcurrency =
|
|
1781
|
+
const explicitMaxConcurrency = numberField(
|
|
2591
1782
|
limit,
|
|
2592
1783
|
"explicitMaxConcurrency",
|
|
2593
1784
|
"explicit_max_concurrency"
|
|
@@ -2599,12 +1790,12 @@ function printToolExecutionHints(value2) {
|
|
|
2599
1790
|
}
|
|
2600
1791
|
}
|
|
2601
1792
|
const queueHint = recordField(executionMetadata, "queueHint", "queue_hint");
|
|
2602
|
-
const requestsPerSecondHint =
|
|
1793
|
+
const requestsPerSecondHint = numberField(
|
|
2603
1794
|
queueHint,
|
|
2604
1795
|
"requestsPerSecondHint",
|
|
2605
1796
|
"requests_per_second_hint"
|
|
2606
1797
|
);
|
|
2607
|
-
const derivedConcurrency =
|
|
1798
|
+
const derivedConcurrency = numberField(
|
|
2608
1799
|
queueHint,
|
|
2609
1800
|
"derivedConcurrency",
|
|
2610
1801
|
"derived_concurrency"
|
|
@@ -2651,7 +1842,7 @@ function extractToolExecutionWarningMessages(rawResponse) {
|
|
|
2651
1842
|
if (typeof warning === "string" && warning.trim()) {
|
|
2652
1843
|
messages.push(warning.trim());
|
|
2653
1844
|
} else if (isRecord(warning)) {
|
|
2654
|
-
const message =
|
|
1845
|
+
const message = stringField(warning, "message");
|
|
2655
1846
|
if (message) messages.push(message);
|
|
2656
1847
|
}
|
|
2657
1848
|
}
|
|
@@ -2665,13 +1856,13 @@ function apifySyncRecoveryNext(rawResponse) {
|
|
|
2665
1856
|
if (raw.state !== "awaiting_apify") return null;
|
|
2666
1857
|
const next = recordField(raw, "next");
|
|
2667
1858
|
const getActorRun = recordField(next, "getActorRun");
|
|
2668
|
-
const getActorRunTool =
|
|
1859
|
+
const getActorRunTool = stringField(getActorRun, "tool");
|
|
2669
1860
|
const getActorRunPayload = recordField(getActorRun, "payload");
|
|
2670
1861
|
if (!getActorRunTool || Object.keys(getActorRunPayload).length === 0) {
|
|
2671
1862
|
return null;
|
|
2672
1863
|
}
|
|
2673
1864
|
const getDatasetItems = recordField(next, "getDatasetItems");
|
|
2674
|
-
const getDatasetItemsTool =
|
|
1865
|
+
const getDatasetItemsTool = stringField(getDatasetItems, "tool");
|
|
2675
1866
|
const getDatasetItemsPayload = recordField(getDatasetItems, "payload");
|
|
2676
1867
|
return {
|
|
2677
1868
|
getActorRun: `deepline tools execute ${getActorRunTool} --input ${shellQuote(JSON.stringify(getActorRunPayload))}`,
|
|
@@ -2691,44 +1882,20 @@ function listExtractorPathsFromUsageGuidance(tool) {
|
|
|
2691
1882
|
).filter(Boolean);
|
|
2692
1883
|
});
|
|
2693
1884
|
}
|
|
2694
|
-
function formatDecimal(
|
|
2695
|
-
const text =
|
|
1885
|
+
function formatDecimal(value) {
|
|
1886
|
+
const text = value.toFixed(12).replace(/0+$/, "").replace(/\.$/, "");
|
|
2696
1887
|
return text || "0";
|
|
2697
1888
|
}
|
|
2698
|
-
function formatUsd(
|
|
2699
|
-
return `$${formatDecimal(
|
|
2700
|
-
}
|
|
2701
|
-
function isRecord(value2) {
|
|
2702
|
-
return Boolean(value2 && typeof value2 === "object" && !Array.isArray(value2));
|
|
2703
|
-
}
|
|
2704
|
-
function stringField2(source, ...keys) {
|
|
2705
|
-
for (const key of keys) {
|
|
2706
|
-
const value2 = source[key];
|
|
2707
|
-
if (typeof value2 === "string" && value2.trim()) return value2.trim();
|
|
2708
|
-
}
|
|
2709
|
-
return "";
|
|
1889
|
+
function formatUsd(value) {
|
|
1890
|
+
return `$${formatDecimal(value)}`;
|
|
2710
1891
|
}
|
|
2711
|
-
function
|
|
1892
|
+
function numberField(source, ...keys) {
|
|
2712
1893
|
for (const key of keys) {
|
|
2713
|
-
const
|
|
2714
|
-
if (typeof
|
|
1894
|
+
const value = source[key];
|
|
1895
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
2715
1896
|
}
|
|
2716
1897
|
return null;
|
|
2717
1898
|
}
|
|
2718
|
-
function arrayField2(source, ...keys) {
|
|
2719
|
-
for (const key of keys) {
|
|
2720
|
-
const value2 = source[key];
|
|
2721
|
-
if (Array.isArray(value2)) return value2;
|
|
2722
|
-
}
|
|
2723
|
-
return [];
|
|
2724
|
-
}
|
|
2725
|
-
function recordField(source, ...keys) {
|
|
2726
|
-
for (const key of keys) {
|
|
2727
|
-
const value2 = source[key];
|
|
2728
|
-
if (isRecord(value2)) return value2;
|
|
2729
|
-
}
|
|
2730
|
-
return {};
|
|
2731
|
-
}
|
|
2732
1899
|
function normalizeOutputFormat(raw) {
|
|
2733
1900
|
switch ((raw || "auto").trim().toLowerCase()) {
|
|
2734
1901
|
case "auto":
|
|
@@ -2796,10 +1963,10 @@ function parseJsonObjectArgument(raw, flagName) {
|
|
|
2796
1963
|
}
|
|
2797
1964
|
return parsed;
|
|
2798
1965
|
}
|
|
2799
|
-
function toolExecuteJsonOption(
|
|
2800
|
-
const legacyInput = typeof
|
|
1966
|
+
function toolExecuteJsonOption(value) {
|
|
1967
|
+
const legacyInput = typeof value === "string" ? value : void 0;
|
|
2801
1968
|
return {
|
|
2802
|
-
requested:
|
|
1969
|
+
requested: value === true || legacyInput !== void 0,
|
|
2803
1970
|
legacyInput
|
|
2804
1971
|
};
|
|
2805
1972
|
}
|
|
@@ -2863,10 +2030,10 @@ function parseToolExecuteTimeout(raw) {
|
|
|
2863
2030
|
"--timeout must be a duration like 500ms, 90s, 10m, or 1h (a bare number is seconds)."
|
|
2864
2031
|
);
|
|
2865
2032
|
}
|
|
2866
|
-
const
|
|
2033
|
+
const value = Number(match[1]);
|
|
2867
2034
|
const unit = (match[2] ?? "s").toLowerCase();
|
|
2868
2035
|
const factor = unit === "ms" ? 1 : unit === "s" ? 1e3 : unit === "m" ? 6e4 : 36e5;
|
|
2869
|
-
const timeoutMs =
|
|
2036
|
+
const timeoutMs = value * factor;
|
|
2870
2037
|
if (!Number.isSafeInteger(timeoutMs) || timeoutMs < 1 || timeoutMs > 2147483647) {
|
|
2871
2038
|
throw new Error(
|
|
2872
2039
|
"--timeout must be between 1ms and 2147483647ms (24d 20h 31m 23s)."
|
|
@@ -2874,22 +2041,11 @@ function parseToolExecuteTimeout(raw) {
|
|
|
2874
2041
|
}
|
|
2875
2042
|
return timeoutMs;
|
|
2876
2043
|
}
|
|
2877
|
-
function safeFileStem(
|
|
2878
|
-
return
|
|
2879
|
-
}
|
|
2880
|
-
function powerShellQuote(value2) {
|
|
2881
|
-
return `'${value2.replace(/'/g, "''")}'`;
|
|
2044
|
+
function safeFileStem(value) {
|
|
2045
|
+
return value.trim().replace(/[^a-zA-Z0-9_-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 64) || "tool";
|
|
2882
2046
|
}
|
|
2883
|
-
function
|
|
2884
|
-
return {
|
|
2885
|
-
path: script.path,
|
|
2886
|
-
sourceCode: script.sourceCode,
|
|
2887
|
-
projectDir: script.projectDir,
|
|
2888
|
-
copyToProject: {
|
|
2889
|
-
macosLinux: script.macCopyCommand,
|
|
2890
|
-
windowsPowerShell: script.windowsCopyCommand
|
|
2891
|
-
}
|
|
2892
|
-
};
|
|
2047
|
+
function powerShellQuote(value) {
|
|
2048
|
+
return `'${value.replace(/'/g, "''")}'`;
|
|
2893
2049
|
}
|
|
2894
2050
|
function seedToolListScript(input) {
|
|
2895
2051
|
const stem = safeFileStem(input.toolId);
|
|
@@ -3036,7 +2192,7 @@ function buildToolExecuteBaseEnvelope(input) {
|
|
|
3036
2192
|
lines: apifyRecovery ? [
|
|
3037
2193
|
"Apify is still running. Run the follow-up command(s) below."
|
|
3038
2194
|
] : summaryEntries.length > 0 ? summaryEntries.map(
|
|
3039
|
-
([key,
|
|
2195
|
+
([key, value]) => `${key}=${String(value)}`
|
|
3040
2196
|
) : [JSON.stringify(input.rawResponse, null, 2)]
|
|
3041
2197
|
},
|
|
3042
2198
|
...guidanceLines.length > 0 ? [{ title: "guidance", lines: guidanceLines }] : []
|
|
@@ -3118,7 +2274,7 @@ function buildToolExecuteRowArtifactEnvelope(input) {
|
|
|
3118
2274
|
lines: [
|
|
3119
2275
|
...input.csv.columns.length > 0 ? [`columns: ${JSON.stringify(input.csv.columns)}`] : [],
|
|
3120
2276
|
...Object.keys(input.summary).length > 0 ? [
|
|
3121
|
-
`summary: ${Object.entries(input.summary).map(([key,
|
|
2277
|
+
`summary: ${Object.entries(input.summary).map(([key, value]) => `${key}=${String(value)}`).join(", ")}`
|
|
3122
2278
|
] : [],
|
|
3123
2279
|
`preview: ${JSON.stringify(input.rowOutput.previewRows)}`,
|
|
3124
2280
|
`starter script: ${input.seededScript.path}`
|
|
@@ -3397,15 +2553,10 @@ inspect: ${inspection.inspect}
|
|
|
3397
2553
|
}
|
|
3398
2554
|
|
|
3399
2555
|
export {
|
|
3400
|
-
formatModelDescription,
|
|
3401
|
-
isMonitorTypeTool,
|
|
3402
2556
|
registerToolsCommands,
|
|
3403
|
-
toolContractJsonForDescribe,
|
|
3404
2557
|
printMonitorTypeContract,
|
|
3405
|
-
publicToolSchemas,
|
|
3406
|
-
describedTool,
|
|
3407
2558
|
printCompactToolContract,
|
|
3408
|
-
toolMetadataJsonForDescribe,
|
|
3409
2559
|
extractToolExecutionWarningMessages,
|
|
2560
|
+
seedToolListScript,
|
|
3410
2561
|
buildToolExecuteBaseEnvelope
|
|
3411
2562
|
};
|