deepline 0.3.395 → 0.3.396
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/cli/{auth-NMQXZRS7.mjs → auth-3LTD62VL.mjs} +4 -4
- package/dist/cli/auth-562JPKOM.js +39 -0
- package/dist/cli/{billing-5MVXZRS6.mjs → billing-DP7ZAJBO.mjs} +5 -5
- package/dist/cli/{billing-Z4JTGUU3.js → billing-PA5OXEM5.js} +76 -76
- package/dist/cli/{chunk-BLYL3KOC.mjs → chunk-23GAA3YO.mjs} +1 -1
- package/dist/cli/{chunk-LZLBR2SF.js → chunk-2VOLOWYZ.js} +1087 -1056
- package/dist/cli/{chunk-EFLQHJZ6.mjs → chunk-3T4MCB5R.mjs} +1026 -995
- package/dist/cli/{chunk-VB6KECLU.mjs → chunk-5WNJF2T3.mjs} +102 -36
- package/dist/cli/{chunk-UKU6JM3S.js → chunk-772W2SAU.js} +8 -8
- package/dist/cli/{chunk-K5T3EN6D.js → chunk-7Z66NHUC.js} +26 -26
- package/dist/cli/{chunk-WCCKMLHL.mjs → chunk-AUYXWELC.mjs} +2 -2
- package/dist/cli/{chunk-PZ5BZ76S.js → chunk-AVHLATII.js} +50 -50
- package/dist/cli/{chunk-MYIBHORT.js → chunk-DC6LTULT.js} +2 -2
- package/dist/cli/{chunk-5VCZ3WRH.mjs → chunk-EIMG75BT.mjs} +1 -0
- package/dist/cli/{chunk-TO2MWPGR.js → chunk-GNN4MY5X.js} +1 -1
- package/dist/cli/{chunk-OCSG6X67.mjs → chunk-I4T4XAA2.mjs} +4 -4
- package/dist/cli/{chunk-ZWH2TFA7.mjs → chunk-JCN4DHF7.mjs} +2 -2
- package/dist/cli/{chunk-R4XZO6Z5.js → chunk-KAEZNPUM.js} +23 -8
- package/dist/cli/{chunk-DRM3CMHL.js → chunk-KXMNM4AQ.js} +2 -1
- package/dist/cli/{chunk-3TRY7KAC.mjs → chunk-LOGGNW4H.mjs} +2 -2
- package/dist/cli/{chunk-RDXFGPJU.js → chunk-LWERJUKN.js} +218 -218
- package/dist/cli/{chunk-UCXK2DS4.js → chunk-ME6XRFLY.js} +15 -15
- package/dist/cli/{chunk-G4IWGRMK.mjs → chunk-MR6XCBQJ.mjs} +2 -2
- package/dist/cli/{chunk-BON3DRC6.mjs → chunk-NHB5YUCS.mjs} +1 -1
- package/dist/cli/{chunk-ZMVJSS6N.js → chunk-NSOTASOP.js} +101 -35
- package/dist/cli/{chunk-7XAM7KDW.mjs → chunk-QHGPA362.mjs} +18 -3
- package/dist/cli/{chunk-VYLJJQ7Y.js → chunk-RMTASUAK.js} +65 -65
- package/dist/cli/{chunk-HRWUQJ4K.js → chunk-RTO5QZWT.js} +6 -6
- package/dist/cli/{chunk-7MVWUXOD.mjs → chunk-TLQ3FZOC.mjs} +3 -3
- package/dist/cli/{chunk-56IFFVIB.js → chunk-V7UP2F4U.js} +4 -4
- package/dist/cli/{chunk-6D7A2FSL.mjs → chunk-VE3U3SQC.mjs} +1 -1
- package/dist/cli/{chunk-36ML3YKA.js → chunk-WQJJNIMQ.js} +13 -13
- package/dist/cli/{chunk-47M6HPGP.mjs → chunk-XKZXO7D3.mjs} +1 -1
- package/dist/cli/{csv-SVOD5UBH.mjs → csv-RLRR74RQ.mjs} +3 -3
- package/dist/cli/{csv-HTS5ZYQ4.js → csv-TF576S77.js} +12 -12
- package/dist/cli/{db-7AP4P52N.js → db-FDBJUTFO.js} +30 -30
- package/dist/cli/{db-7QLNI3Q4.mjs → db-XORGNBIC.mjs} +5 -5
- package/dist/cli/{describe-DBRY5BNK.mjs → describe-6O2ENKTP.mjs} +86 -68
- package/dist/cli/{describe-YKOE54ZO.js → describe-EFWNECHI.js} +100 -82
- package/dist/cli/{executions-GRQXTB2P.js → executions-SFYAXPF4.js} +7 -7
- package/dist/cli/{executions-QNZTPNG4.mjs → executions-YPP7WR77.mjs} +5 -5
- package/dist/cli/{feedback-ZOLA2KY7.js → feedback-5UZFYMGB.js} +7 -7
- package/dist/cli/{feedback-JMCSR624.mjs → feedback-RBGA5ARU.mjs} +3 -3
- package/dist/cli/git-5LDY5ZID.js +23 -0
- package/dist/cli/{git-LJGL2IHS.mjs → git-IRSAJEK2.mjs} +4 -4
- package/dist/cli/index.js +94 -94
- package/dist/cli/index.mjs +38 -38
- package/dist/cli/{legacy-noops-YSCIR2SD.js → legacy-noops-CVAOQY2F.js} +7 -7
- package/dist/cli/{legacy-noops-F23PKVBN.mjs → legacy-noops-NA7N6ZOU.mjs} +4 -4
- package/dist/cli/{monitors-WMZ6HJZX.js → monitors-4OMRXCXP.js} +86 -86
- package/dist/cli/{monitors-S4LOEL7W.mjs → monitors-ILZ2XHYG.mjs} +5 -5
- package/dist/cli/{org-U3WA2NQM.mjs → org-QDDXAE3J.mjs} +5 -5
- package/dist/cli/{org-PFHM5ZLY.js → org-YGNJDD2X.js} +65 -65
- package/dist/cli/{chunk-4KLCLLTO.js → play-L535H26U.js} +266 -323
- package/dist/cli/{chunk-XMAPE2KH.mjs → play-VT6OHB2D.mjs} +72 -129
- package/dist/cli/{providers-XYMHLKCA.js → providers-GPZ6PQAL.js} +8 -8
- package/dist/cli/{providers-QBBRFBOH.mjs → providers-KG4W5MPK.mjs} +5 -5
- package/dist/cli/{quickstart-5JTDGISY.mjs → quickstart-2JDGTXIG.mjs} +3 -3
- package/dist/cli/{quickstart-IYGD6ZY3.js → quickstart-UI27S5LO.js} +5 -5
- package/dist/cli/search-MGWROZ33.js +28 -0
- package/dist/cli/{search-X6W6GRHS.mjs → search-PW3RAUX7.mjs} +6 -6
- package/dist/cli/{secrets-N55B67H6.mjs → secrets-HNOMK5A2.mjs} +5 -5
- package/dist/cli/{secrets-UHG6OQFD.js → secrets-WFAXOUZE.js} +14 -14
- package/dist/cli/{sessions-57L5MGHN.js → sessions-366KROUA.js} +5 -5
- package/dist/cli/{sessions-JTRSTDSS.mjs → sessions-XLX3E5UO.mjs} +4 -4
- package/dist/cli/{settings-ATX4U5AS.js → settings-GADAG2UK.js} +75 -75
- package/dist/cli/{settings-Q24HRAQI.mjs → settings-YNZ4YKCH.mjs} +8 -8
- package/dist/cli/{setup-77ZWLVHT.mjs → setup-PSEHIUXO.mjs} +6 -6
- package/dist/cli/{setup-EJCNOUCE.js → setup-R5YO7GT6.js} +41 -41
- package/dist/cli/skills-JF2LPEGM.js +28 -0
- package/dist/cli/{skills-XIS5AWQI.mjs → skills-LTQBP6CZ.mjs} +4 -4
- package/dist/cli/tools-CP2PEFRN.js +34 -0
- package/dist/cli/{tools-WCKLYEGQ.mjs → tools-UAXDWU63.mjs} +11 -19
- package/dist/cli/update-HZHZOU6C.js +28 -0
- package/dist/cli/{update-UT5WANMV.mjs → update-SMNIBIMS.mjs} +6 -6
- package/dist/cli/{workflow-226QYUN2.js → workflow-AOQVZHMD.js} +16 -16
- package/dist/cli/{workflow-ZMX3L4ML.mjs → workflow-IKGMBGF6.mjs} +6 -6
- package/dist/{client-CivP-PAI.d.ts → client-Bgis7F6-.d.ts} +2 -1
- package/dist/{client-hdFtwhTm.d.mts → client-DiGl8ska.d.mts} +2 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +11 -11
- package/dist/index.mjs +9 -9
- package/dist/install-integrity.json +78 -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 +1 -1
- package/dist/cli/auth-UYCOBAL5.js +0 -39
- 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/skills-SPXUBLII.js +0 -28
- package/dist/cli/tools-DBHUUZJX.js +0 -42
- package/dist/cli/update-VSNFXRHJ.js +0 -28
- package/dist/cli/{chunk-KZZC33PY.mjs → chunk-H5KLUGY7.mjs} +214 -214
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkNSOTASOPjs = require('./chunk-NSOTASOP.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
var _chunkAID3OYVJjs = require('./chunk-AID3OYVJ.js');
|
|
@@ -13,7 +13,7 @@ var _chunkAID3OYVJjs = require('./chunk-AID3OYVJ.js');
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _chunkKAEZNPUMjs = require('./chunk-KAEZNPUM.js');
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
@@ -24,14 +24,14 @@ var _chunkR4XZO6Z5js = require('./chunk-R4XZO6Z5.js');
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
var
|
|
27
|
+
var _chunkLWERJUKNjs = require('./chunk-LWERJUKN.js');
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
var _chunkKB4SDX5Sjs = require('./chunk-KB4SDX5S.js');
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
var
|
|
34
|
+
var _chunkWQJJNIMQjs = require('./chunk-WQJJNIMQ.js');
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
var _chunkXDVT3GOMjs = require('./chunk-XDVT3GOM.js');
|
|
@@ -48,11 +48,11 @@ var _chunkQJBJZVG6js = require('./chunk-QJBJZVG6.js');
|
|
|
48
48
|
|
|
49
49
|
|
|
50
50
|
|
|
51
|
-
var
|
|
51
|
+
var _chunkRTO5QZWTjs = require('./chunk-RTO5QZWT.js');
|
|
52
52
|
|
|
53
53
|
|
|
54
54
|
|
|
55
|
-
var
|
|
55
|
+
var _chunkV7UP2F4Ujs = require('./chunk-V7UP2F4U.js');
|
|
56
56
|
|
|
57
57
|
|
|
58
58
|
var _chunk7P5AA3SNjs = require('./chunk-7P5AA3SN.js');
|
|
@@ -131,10 +131,10 @@ var ToolCallRecovery = class _ToolCallRecovery {
|
|
|
131
131
|
}
|
|
132
132
|
};
|
|
133
133
|
function pendingToolExecutionPath(input) {
|
|
134
|
-
const config =
|
|
134
|
+
const config = _chunkV7UP2F4Ujs.resolveConfig.call(void 0, );
|
|
135
135
|
const fingerprint = _crypto.createHash.call(void 0, "sha256").update(config.baseUrl).update("\0").update(_crypto.createHash.call(void 0, "sha256").update(config.apiKey).digest("hex")).update("\0").update(input.toolId).update("\0").update(_chunkXDVT3GOMjs.stableStringify.call(void 0, input.params)).update("\0").update(input.responseIntent).digest("hex");
|
|
136
136
|
return _path.join.call(void 0,
|
|
137
|
-
|
|
137
|
+
_chunkV7UP2F4Ujs.sdkCliStateDirPath.call(void 0, config.baseUrl),
|
|
138
138
|
`pending-tool-execution-${fingerprint}.json`
|
|
139
139
|
);
|
|
140
140
|
}
|
|
@@ -195,36 +195,6 @@ async function completePendingToolExecution(path, idempotencyKey) {
|
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
-
// ../plays/tool-category-descriptions.ts
|
|
199
|
-
var TOOL_CATEGORY_DESCRIPTIONS = {
|
|
200
|
-
company_search: "Find companies matching firmographic, ad, or web criteria.",
|
|
201
|
-
people_search: "Find people matching role, company, or persona criteria.",
|
|
202
|
-
people_enrich: "Enrich a known person with contact, social, and profile data.",
|
|
203
|
-
company_enrich: "Enrich a known company with firmographic and account data.",
|
|
204
|
-
email_finder: "Find work or personal email addresses for a person.",
|
|
205
|
-
email_verify: "Validate email deliverability and catch-all status.",
|
|
206
|
-
phone_finder: "Find mobile or direct phone numbers for a person.",
|
|
207
|
-
phone_verify: "Validate phone-number reachability and line type.",
|
|
208
|
-
research: "Research accounts, people, news, and signals for context and scoring.",
|
|
209
|
-
autocomplete: "Resolve names and entities to canonical catalog records.",
|
|
210
|
-
automation: "Kick off provider-side jobs, exports, and asynchronous workflows.",
|
|
211
|
-
outbound_tools: "Run outbound sequencing, deliverability, and campaign operations.",
|
|
212
|
-
admin: "Provider-side status, metadata, and account operations behind other tools.",
|
|
213
|
-
smb: "Look up small-business listings, local records, and public filings.",
|
|
214
|
-
identity_resolution: "Match a partial identity to a single resolved person or company.",
|
|
215
|
-
reverse_lookup: "Resolve an email, phone, or profile back to a person.",
|
|
216
|
-
enrichment: "General-purpose record enrichment across people and companies.",
|
|
217
|
-
batch: "Run an enrichment or search operation over many rows at once.",
|
|
218
|
-
premium: "Higher-cost tools with premium provider coverage.",
|
|
219
|
-
free: "Free tools that do not spend Deepline credits."
|
|
220
|
-
};
|
|
221
|
-
var WELL_KNOWN_TOOL_CATEGORIES = Object.freeze(
|
|
222
|
-
Object.keys(TOOL_CATEGORY_DESCRIPTIONS)
|
|
223
|
-
);
|
|
224
|
-
function describeToolCategory(category) {
|
|
225
|
-
return _nullishCoalesce(TOOL_CATEGORY_DESCRIPTIONS[category], () => ( null));
|
|
226
|
-
}
|
|
227
|
-
|
|
228
198
|
// ../plays/field-catalog.ts
|
|
229
199
|
var value = (description) => ({ type: "string", description });
|
|
230
200
|
var SOURCE = {
|
|
@@ -398,106 +368,793 @@ function fieldOfName(name, declared) {
|
|
|
398
368
|
return meanings.some((meaning) => fieldSatisfies(declared, meaning)) ? declared : void 0;
|
|
399
369
|
}
|
|
400
370
|
|
|
401
|
-
// src/cli/
|
|
402
|
-
function
|
|
403
|
-
const
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
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
|
-
`;
|
|
371
|
+
// src/cli/described-tool.ts
|
|
372
|
+
function isPlayLikeTool(tool) {
|
|
373
|
+
const record = tool;
|
|
374
|
+
if (record.isPlay === true || record.is_play === true) return true;
|
|
375
|
+
const playExpansion = recordField(record, "playExpansion", "play_expansion");
|
|
376
|
+
if (Object.keys(playExpansion).length > 0) return true;
|
|
377
|
+
const toolId = typeof record.toolId === "string" ? record.toolId : "";
|
|
378
|
+
return toolId.endsWith("_waterfall");
|
|
435
379
|
}
|
|
436
|
-
function
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
380
|
+
function isMonitorTypeTool(tool) {
|
|
381
|
+
return stringField(tool, "kind") === "monitor_type";
|
|
382
|
+
}
|
|
383
|
+
function playReferenceForTool(tool) {
|
|
384
|
+
const record = tool;
|
|
385
|
+
const declared = stringField(record, "playReference", "play_reference");
|
|
386
|
+
if (declared.startsWith("prebuilt/")) {
|
|
387
|
+
return declared;
|
|
443
388
|
}
|
|
389
|
+
return null;
|
|
444
390
|
}
|
|
445
|
-
function
|
|
446
|
-
|
|
447
|
-
const candidate = value2[key];
|
|
448
|
-
return typeof candidate === "string" && candidate.trim() ? candidate.trim() : null;
|
|
391
|
+
function playSearchCommandForToolId(toolId) {
|
|
392
|
+
return `deepline search --type prebuilts ${JSON.stringify(toolId.replace(/_/g, " "))}`;
|
|
449
393
|
}
|
|
450
|
-
function
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
394
|
+
function playRunCommandForTool(tool, toolId, input) {
|
|
395
|
+
const playReference = playReferenceForTool(tool);
|
|
396
|
+
if (!playReference) return playSearchCommandForToolId(toolId);
|
|
397
|
+
const inputArg = input === void 0 ? "'{...}'" : `'${JSON.stringify(input)}'`;
|
|
398
|
+
return `deepline plays run ${playReference} --input ${inputArg}`;
|
|
454
399
|
}
|
|
455
|
-
function
|
|
456
|
-
|
|
457
|
-
const
|
|
458
|
-
|
|
400
|
+
function toolContractJsonForDescribe(tool, requestedToolId, authoringContractEdition, seedStarterScript) {
|
|
401
|
+
const toolId = String(tool.toolId || requestedToolId);
|
|
402
|
+
const inputFields = toolInputFieldsForDisplay(
|
|
403
|
+
recordField(tool, "inputSchema", "input_schema")
|
|
404
|
+
);
|
|
405
|
+
const inputSchema = publicToolInputSchemaForDescribe(
|
|
406
|
+
recordField(tool, "inputSchema", "input_schema")
|
|
407
|
+
);
|
|
408
|
+
const outputSchemaRecord = recordField(tool, "outputSchema", "output_schema");
|
|
409
|
+
const outputFields = toolOutputFieldsForDisplay(outputSchemaRecord);
|
|
410
|
+
const usageGuidance = recordField(tool, "usageGuidance", "usage_guidance");
|
|
411
|
+
const guidance = recordField(tool, "guidance");
|
|
412
|
+
const toolExecutionResult = recordField(
|
|
413
|
+
usageGuidance,
|
|
414
|
+
"toolExecutionResult",
|
|
415
|
+
"tool_execution_result"
|
|
416
|
+
);
|
|
417
|
+
const extractedLists = extractionContractEntries(
|
|
418
|
+
arrayField(toolExecutionResult, "extractedLists", "extracted_lists")
|
|
419
|
+
).map((entry) => ({
|
|
420
|
+
...entry,
|
|
421
|
+
returnType: _chunkKB4SDX5Sjs.playToolListGetterMode.call(void 0, authoringContractEdition) === "array" ? "Array" : "PlayDataset",
|
|
422
|
+
rowsExpression: _chunkKB4SDX5Sjs.playToolListGetterMode.call(void 0, authoringContractEdition) === "array" ? entry.expression : `await ${entry.expression}.materialize()`
|
|
423
|
+
}));
|
|
424
|
+
const extractedValues = extractionContractEntries(
|
|
425
|
+
arrayField(toolExecutionResult, "extractedValues", "extracted_values")
|
|
426
|
+
);
|
|
427
|
+
const pricing = _chunkKAEZNPUMjs.Capability.fromCatalogEntry(tool).describe().customerCost();
|
|
428
|
+
const executionMetadataRecord = recordField(
|
|
429
|
+
tool,
|
|
430
|
+
"executionMetadata",
|
|
431
|
+
"execution_metadata"
|
|
432
|
+
);
|
|
433
|
+
const executionMetadata = Object.keys(executionMetadataRecord).length > 0 ? executionMetadataRecord : null;
|
|
434
|
+
const batchCapabilityRecord = recordField(
|
|
435
|
+
tool,
|
|
436
|
+
"batchCapability",
|
|
437
|
+
"batch_capability"
|
|
438
|
+
);
|
|
439
|
+
const batchCapability = Object.keys(batchCapabilityRecord).length > 0 ? batchCapabilityRecord : null;
|
|
440
|
+
const deprecation = recordField(tool, "deprecation");
|
|
441
|
+
const replacementToolId = stringField(
|
|
442
|
+
deprecation,
|
|
443
|
+
"replacementToolId",
|
|
444
|
+
"replacement_tool_id"
|
|
445
|
+
);
|
|
446
|
+
const deprecationMessage = stringField(deprecation, "message");
|
|
447
|
+
const deprecationExecution = stringField(deprecation, "execution");
|
|
448
|
+
const deprecated = tool.deprecated === true || stringField(tool, "credentialStatus", "credential_status") === "deprecated";
|
|
449
|
+
const starterScript = seedStarterScript && !deprecated && !isPlayLikeTool(tool) && extractedLists.length > 0 ? starterScriptJson(
|
|
450
|
+
seedStarterScript({
|
|
451
|
+
toolId,
|
|
452
|
+
payload: samplePayloadForInputFields(inputFields),
|
|
453
|
+
rows: []
|
|
454
|
+
})
|
|
455
|
+
) : null;
|
|
456
|
+
const executeCommand = deprecated && replacementToolId ? `deepline tools execute ${replacementToolId} --input '{...}'` : isPlayLikeTool(tool) ? playRunCommandForTool(tool, toolId) : `deepline tools execute ${toolId} --input '{...}'`;
|
|
457
|
+
return {
|
|
458
|
+
schemaVersion: 1,
|
|
459
|
+
toolId,
|
|
460
|
+
provider: tool.provider,
|
|
461
|
+
displayName: tool.displayName,
|
|
462
|
+
cost: pricing,
|
|
463
|
+
description: tool.description,
|
|
464
|
+
...Object.keys(guidance).length > 0 ? { guidance } : {},
|
|
465
|
+
categories: tool.categories,
|
|
466
|
+
...Array.isArray(tool.requestWarnings) ? { requestWarnings: tool.requestWarnings } : {},
|
|
467
|
+
...deprecated ? {
|
|
468
|
+
deprecated: true,
|
|
469
|
+
callable: tool.callable !== false,
|
|
470
|
+
deprecation: {
|
|
471
|
+
replacementToolId,
|
|
472
|
+
message: deprecationMessage,
|
|
473
|
+
...deprecationExecution ? { execution: deprecationExecution } : {}
|
|
474
|
+
}
|
|
475
|
+
} : {},
|
|
476
|
+
inputFields: inputFields.map(inputFieldJsonForDescribe),
|
|
477
|
+
inputSchema,
|
|
478
|
+
...isRecord(tool.responseSchema) ? { responseSchema: tool.responseSchema } : {},
|
|
479
|
+
...Array.isArray(tool.examples) ? { examples: tool.examples } : {},
|
|
480
|
+
responseAccess: "result.toolResponse.rawV2",
|
|
481
|
+
...Object.keys(outputSchemaRecord).length > 0 ? {
|
|
482
|
+
outputSchema: publicToolInputSchemaForDescribe(outputSchemaRecord),
|
|
483
|
+
outputFields: outputFields.map(inputFieldJsonForDescribe)
|
|
484
|
+
} : {},
|
|
485
|
+
...executionMetadata ? { executionMetadata } : {},
|
|
486
|
+
...batchCapability ? { batchCapability } : {},
|
|
487
|
+
getters: {
|
|
488
|
+
extractedLists,
|
|
489
|
+
extractedValues
|
|
490
|
+
},
|
|
491
|
+
executeCommand,
|
|
492
|
+
...starterScript ? { starterScript } : {}
|
|
493
|
+
};
|
|
459
494
|
}
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
495
|
+
function extractionContractEntries(entries) {
|
|
496
|
+
return entries.flatMap((entry) => {
|
|
497
|
+
if (!isRecord(entry)) return [];
|
|
498
|
+
const name = stringField(entry, "name");
|
|
499
|
+
const expression = stringField(entry, "expression");
|
|
500
|
+
return name && expression ? [{ name, expression }] : [];
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
function schemaNodeAt(schema, path) {
|
|
504
|
+
let node = schema;
|
|
505
|
+
for (const part of path.split(".").filter(Boolean)) {
|
|
506
|
+
const [key, ...indexes] = part.split("[");
|
|
507
|
+
node = recordField(isRecord(node) ? node : {}, "properties")[key];
|
|
508
|
+
for (const _index of indexes)
|
|
509
|
+
node = isRecord(node) ? node.items : void 0;
|
|
468
510
|
}
|
|
469
|
-
return
|
|
511
|
+
return node;
|
|
470
512
|
}
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
describe: "deepline describe <toolId>",
|
|
475
|
-
execute: "deepline tools execute <toolId> --input '{...}'"
|
|
513
|
+
var NAMED_VALUE_SHAPES = {
|
|
514
|
+
email_status: { shape: "EmailStatus", schema: _chunkLWERJUKNjs.EMAIL_STATUS_JSON_SCHEMA },
|
|
515
|
+
job_change: { shape: "JobChange", schema: _chunkLWERJUKNjs.JOB_CHANGE_JSON_SCHEMA }
|
|
476
516
|
};
|
|
477
|
-
function
|
|
478
|
-
if (
|
|
517
|
+
function extractorValueType(name) {
|
|
518
|
+
if (!_chunkLWERJUKNjs.isDeeplineExtractorTarget.call(void 0, name)) return void 0;
|
|
519
|
+
const definition = _chunkLWERJUKNjs.DEEPLINE_EXTRACTOR_TARGET_DEFINITIONS[name];
|
|
520
|
+
if (definition.enum) {
|
|
479
521
|
return {
|
|
480
|
-
|
|
481
|
-
description: listedToolDescription(tool),
|
|
482
|
-
id: tool.toolId,
|
|
483
|
-
type: "play",
|
|
484
|
-
executeCommand: playRunCommandForTool(tool, tool.toolId)
|
|
522
|
+
type: definition.enum.map((value2) => JSON.stringify(value2)).join(" | ")
|
|
485
523
|
};
|
|
486
524
|
}
|
|
525
|
+
const named = NAMED_VALUE_SHAPES[definition.valueKind];
|
|
526
|
+
if (!named) return { type: "string" };
|
|
527
|
+
const { type, fields } = _chunkNSOTASOPjs.schemaField.call(void 0, name, named.schema, true);
|
|
528
|
+
return { type, ...fields ? { fields } : {}, shape: named.shape };
|
|
529
|
+
}
|
|
530
|
+
function jsonSchemaOf(wrapper) {
|
|
531
|
+
return isRecord(wrapper.jsonSchema) ? wrapper.jsonSchema : wrapper;
|
|
532
|
+
}
|
|
533
|
+
function publicToolSchemas(tool) {
|
|
534
|
+
const scrubbed = (...keys) => {
|
|
535
|
+
const schema = recordField(tool, ...keys);
|
|
536
|
+
if (Object.keys(schema).length === 0) return null;
|
|
537
|
+
const cleaned = publicToolInputSchemaForDescribe(schema);
|
|
538
|
+
return isRecord(cleaned.jsonSchema) ? cleaned.jsonSchema : cleaned;
|
|
539
|
+
};
|
|
540
|
+
const responseSchema = scrubbed("responseSchema", "response_schema");
|
|
487
541
|
return {
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
542
|
+
inputSchema: scrubbed(
|
|
543
|
+
"inputSchema",
|
|
544
|
+
"input_schema",
|
|
545
|
+
"payload_schema",
|
|
546
|
+
"payloadSchema"
|
|
547
|
+
),
|
|
548
|
+
outputSchema: scrubbed("outputSchema", "output_schema"),
|
|
549
|
+
...responseSchema ? { responseSchema } : {}
|
|
493
550
|
};
|
|
494
551
|
}
|
|
495
|
-
function
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
552
|
+
function describedTool(tool, requestedToolId) {
|
|
553
|
+
const id = stringField(tool, "toolId") || requestedToolId;
|
|
554
|
+
const displayName = stringField(tool, "displayName") || void 0;
|
|
555
|
+
const description = stringField(tool, "bestFor", "best_for") || stringField(tool, "description") || void 0;
|
|
556
|
+
if (isMonitorTypeTool(tool)) {
|
|
557
|
+
return {
|
|
558
|
+
kind: "monitor_type",
|
|
559
|
+
id,
|
|
560
|
+
displayName,
|
|
561
|
+
description,
|
|
562
|
+
cost: stringField(recordField(tool, "pricing"), "displayText") || void 0,
|
|
563
|
+
guidance: [],
|
|
564
|
+
inputs: _chunkNSOTASOPjs.schemaFields.call(void 0,
|
|
565
|
+
recordField(tool, "payload_schema", "payloadSchema")
|
|
566
|
+
),
|
|
567
|
+
outputs: [],
|
|
568
|
+
runner: {
|
|
569
|
+
via: "monitor",
|
|
570
|
+
deploy: stringField(recordField(tool, "deploy"), "example") || `deepline monitors deploy '{"key":"...","tool":"${id}","payload":{...}}'`
|
|
571
|
+
}
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
const contract = toolContractJsonForDescribe(tool, requestedToolId);
|
|
575
|
+
const cost = recordField(contract, "cost");
|
|
576
|
+
const billing = stringField(cost, "billingSourceLabel");
|
|
577
|
+
const deprecation = recordField(contract, "deprecation");
|
|
578
|
+
const getters = recordField(contract, "getters");
|
|
579
|
+
const outputSchema = jsonSchemaOf(recordField(contract, "outputSchema"));
|
|
580
|
+
const toolResult = recordField(tool, "toolResult", "tool_result");
|
|
581
|
+
const getterDetails = (kind) => new Map(
|
|
582
|
+
arrayField(toolResult, kind).filter(isRecord).map((item) => [
|
|
583
|
+
stringField(item, "name"),
|
|
584
|
+
recordField(item, "details")
|
|
585
|
+
])
|
|
586
|
+
);
|
|
587
|
+
const declared = recordField(tool, "extractors");
|
|
588
|
+
const getterOutputs = (kind, roots) => {
|
|
589
|
+
const details = getterDetails(kind);
|
|
590
|
+
return arrayField(getters, kind).filter(isRecord).map((entry) => {
|
|
591
|
+
const name = stringField(entry, "name");
|
|
592
|
+
const rawPaths = arrayField(
|
|
593
|
+
_nullishCoalesce(details.get(name), () => ( {})),
|
|
594
|
+
"rawToolOutputPaths"
|
|
595
|
+
).map(String);
|
|
596
|
+
const paths = rawPaths.map(
|
|
597
|
+
(path) => path.replace(/^toolResponse\.raw\./, "")
|
|
598
|
+
);
|
|
599
|
+
const node = roots.flatMap((root) => paths.map((path) => schemaNodeAt(root, path))).find(isRecord);
|
|
600
|
+
const { fields, ...typed } = _chunkNSOTASOPjs.schemaField.call(void 0, name, node, true);
|
|
601
|
+
const valueType = stringField(_nullishCoalesce(details.get(name), () => ( {})), "valueType");
|
|
602
|
+
const deepline = kind === "extractedValues" ? extractorValueType(name) : void 0;
|
|
603
|
+
const known = typed.type !== "unknown" ? void 0 : kind === "extractedLists" ? { type: "object[]" } : deepline;
|
|
604
|
+
const means = kind === "extractedValues" ? fieldOfName(
|
|
605
|
+
name,
|
|
606
|
+
stringField(_nullishCoalesce(declared[name], () => ( {})), "means") || void 0
|
|
607
|
+
) : void 0;
|
|
608
|
+
const field = {
|
|
609
|
+
...typed,
|
|
610
|
+
...means ? { means } : {},
|
|
611
|
+
// A normalized value has a named type instead of the response's
|
|
612
|
+
// shape; a normalized object is spelled out once under Types.
|
|
613
|
+
..._optionalChain([deepline, 'optionalAccess', _5 => _5.shape]) ? deepline : valueType ? { type: valueType } : known ? known : fields ? { fields } : {},
|
|
614
|
+
// A list's row columns that matter are value getters of their own.
|
|
615
|
+
...kind === "extractedLists" && fields ? { summarized: true } : {},
|
|
616
|
+
read: playResultExpression(entry),
|
|
617
|
+
...rawPaths.length ? { paths: rawPaths } : {}
|
|
618
|
+
};
|
|
619
|
+
return { field, node };
|
|
620
|
+
});
|
|
621
|
+
};
|
|
622
|
+
const declaredLists = getterOutputs("extractedLists", [outputSchema]);
|
|
623
|
+
const lists = declaredLists.some(({ node }) => node) ? declaredLists.filter(({ node }) => node) : declaredLists;
|
|
624
|
+
const values = getterOutputs("extractedValues", [
|
|
625
|
+
outputSchema,
|
|
626
|
+
...lists.map(({ node }) => _optionalChain([node, 'optionalAccess', _6 => _6.items]))
|
|
627
|
+
]).map((value2) => {
|
|
628
|
+
if (!lists.length || !value2.field.paths) return value2;
|
|
629
|
+
const within = value2.field.paths.map(
|
|
630
|
+
(path) => path.replace(/^toolResponse\.raw\./, "")
|
|
631
|
+
);
|
|
632
|
+
const list = _nullishCoalesce(lists.find(
|
|
633
|
+
({ node }) => within.some((path) => isRecord(schemaNodeAt(_optionalChain([node, 'optionalAccess', _7 => _7.items]), path)))
|
|
634
|
+
), () => ( lists[0]));
|
|
635
|
+
return {
|
|
636
|
+
...value2,
|
|
637
|
+
field: { ...value2.field, in: list.field.name, paths: within }
|
|
638
|
+
};
|
|
639
|
+
});
|
|
640
|
+
const playReference = isPlayLikeTool(tool) ? playReferenceForTool(tool) : null;
|
|
641
|
+
return {
|
|
642
|
+
kind: "tool",
|
|
643
|
+
id: String(contract.toolId),
|
|
644
|
+
displayName,
|
|
645
|
+
description,
|
|
646
|
+
cost: [
|
|
647
|
+
stringField(cost, "displayText"),
|
|
648
|
+
// "Free (free)" says the same thing twice.
|
|
649
|
+
billing.toLowerCase() === stringField(cost, "displayText").toLowerCase() ? "" : billing && `(${billing})`,
|
|
650
|
+
_chunkKAEZNPUMjs.observedMaxText.call(void 0, cost) && `\u2014 ${_chunkKAEZNPUMjs.observedMaxText.call(void 0, cost)}`
|
|
651
|
+
].filter(Boolean).join(" ") || void 0,
|
|
652
|
+
guidance: [
|
|
653
|
+
...contract.deprecated === true ? [`Deprecated. ${stringField(deprecation, "message")}`.trim()] : [],
|
|
654
|
+
...Object.values(recordField(contract, "guidance")).filter(
|
|
655
|
+
(line) => typeof line === "string" && /[a-z0-9]/i.test(line)
|
|
656
|
+
)
|
|
657
|
+
],
|
|
658
|
+
rateLimit: _chunkNSOTASOPjs.rateLimitSummary.call(void 0,
|
|
659
|
+
recordField(contract, "executionMetadata").configuredRateLimits
|
|
660
|
+
),
|
|
661
|
+
inputs: _chunkNSOTASOPjs.schemaFields.call(void 0, jsonSchemaOf(recordField(contract, "inputSchema"))),
|
|
662
|
+
outputs: [...lists, ...values].map(({ field }) => field),
|
|
663
|
+
rawResponse: _chunkNSOTASOPjs.schemaFields.call(void 0, outputSchema),
|
|
664
|
+
runner: playReference ? { via: "play", reference: playReference } : { via: "tool", toolId: String(contract.toolId) }
|
|
665
|
+
};
|
|
666
|
+
}
|
|
667
|
+
function sampleValueForField(field) {
|
|
668
|
+
const name = stringField(field, "name").toLowerCase();
|
|
669
|
+
const type = stringField(field, "type").toLowerCase();
|
|
670
|
+
if (Object.prototype.hasOwnProperty.call(field, "default"))
|
|
671
|
+
return field.default;
|
|
672
|
+
if (name.includes("email")) return "ada@example.com";
|
|
673
|
+
if (name.includes("domain") || name.includes("website")) return "example.com";
|
|
674
|
+
if (name.includes("first")) return "Ada";
|
|
675
|
+
if (name.includes("last")) return "Lovelace";
|
|
676
|
+
if (name.includes("name")) return "Ada Lovelace";
|
|
677
|
+
if (type === "integer" || type === "number") return 1;
|
|
678
|
+
if (type === "boolean") return true;
|
|
679
|
+
if (type === "array") return [];
|
|
680
|
+
if (type === "object") return {};
|
|
681
|
+
return "...";
|
|
682
|
+
}
|
|
683
|
+
function samplePayloadForInputFields(fields) {
|
|
684
|
+
return Object.fromEntries(
|
|
685
|
+
fields.slice(0, 4).flatMap((field) => {
|
|
686
|
+
if (!isRecord(field)) return [];
|
|
687
|
+
const name = stringField(field, "name");
|
|
688
|
+
if (!name) return [];
|
|
689
|
+
return [[name, sampleValueForField(field)]];
|
|
690
|
+
})
|
|
691
|
+
);
|
|
692
|
+
}
|
|
693
|
+
function playResultExpression(entry) {
|
|
694
|
+
return stringField(entry, "expression").replace(
|
|
695
|
+
/^toolExecutionResult\./,
|
|
696
|
+
"result."
|
|
697
|
+
);
|
|
698
|
+
}
|
|
699
|
+
function toolMetadataJsonForDescribe(tool, requestedToolId, seedStarterScript) {
|
|
700
|
+
const toolId = String(tool.toolId || requestedToolId);
|
|
701
|
+
const inputFields = toolInputFieldsForDisplay(
|
|
702
|
+
recordField(tool, "inputSchema", "input_schema")
|
|
703
|
+
);
|
|
704
|
+
const usageGuidance = usageGuidanceWithAccessDefaults(
|
|
705
|
+
recordField(tool, "usageGuidance", "usage_guidance")
|
|
706
|
+
);
|
|
707
|
+
const toolExecutionResult = recordField(
|
|
708
|
+
usageGuidance,
|
|
709
|
+
"toolExecutionResult",
|
|
710
|
+
"tool_execution_result"
|
|
711
|
+
);
|
|
712
|
+
const extractedLists = extractionContractEntries(
|
|
713
|
+
arrayField(toolExecutionResult, "extractedLists", "extracted_lists")
|
|
714
|
+
);
|
|
715
|
+
const starterScript = seedStarterScript && !isPlayLikeTool(tool) && extractedLists.length > 0 ? starterScriptJson(
|
|
716
|
+
seedStarterScript({
|
|
717
|
+
toolId,
|
|
718
|
+
payload: samplePayloadForInputFields(inputFields),
|
|
719
|
+
rows: []
|
|
720
|
+
})
|
|
721
|
+
) : null;
|
|
722
|
+
const observedOutputCommand = isPlayLikeTool(tool) ? playRunCommandForTool(tool, toolId) : `deepline tools execute ${toolId} --input '{...}'`;
|
|
723
|
+
const {
|
|
724
|
+
cost: _cost,
|
|
725
|
+
deeplineCreditsPerPricingUnit: _deeplineCreditsPerPricingUnit,
|
|
726
|
+
deeplineUsdPerPricingUnit: _deeplineUsdPerPricingUnit,
|
|
727
|
+
deeplineUsdPerCredit: _deeplineUsdPerCredit,
|
|
728
|
+
deeplinePricingSummary: _deeplinePricingSummary,
|
|
729
|
+
deeplinePricingDetails: _deeplinePricingDetails,
|
|
730
|
+
deepline_credits_per_pricing_unit: _snakeDeeplineCreditsPerPricingUnit,
|
|
731
|
+
deepline_usd_per_pricing_unit: _snakeDeeplineUsdPerPricingUnit,
|
|
732
|
+
deepline_usd_per_credit: _snakeDeeplineUsdPerCredit,
|
|
733
|
+
deepline_pricing_summary: _snakeDeeplinePricingSummary,
|
|
734
|
+
deepline_pricing_details: _snakeDeeplinePricingDetails,
|
|
735
|
+
// BYOK is shown only on request, via describe --feature byok.
|
|
736
|
+
byok: _byok,
|
|
737
|
+
...publicTool
|
|
738
|
+
} = tool;
|
|
739
|
+
const outputSchemaRecord = recordField(tool, "outputSchema", "output_schema");
|
|
740
|
+
return {
|
|
741
|
+
cost: _chunkKAEZNPUMjs.Capability.fromCatalogEntry(tool).describe().customerCost(),
|
|
742
|
+
...publicTool,
|
|
743
|
+
toolId,
|
|
744
|
+
provider: tool.provider,
|
|
745
|
+
displayName: tool.displayName,
|
|
746
|
+
...Object.keys(outputSchemaRecord).length > 0 ? {
|
|
747
|
+
outputSchema: publicToolInputSchemaForDescribe(outputSchemaRecord),
|
|
748
|
+
outputFields: toolOutputFieldsForDisplay(outputSchemaRecord).map(
|
|
749
|
+
inputFieldJsonForDescribe
|
|
750
|
+
)
|
|
751
|
+
} : {},
|
|
752
|
+
inputFields: inputFields.map(inputFieldJsonForDescribe),
|
|
753
|
+
usageGuidance,
|
|
754
|
+
runtimeOutputHelp: {
|
|
755
|
+
contract: "Schemas declare field shapes. Examples illustrate input payloads and full Deepline execution responses; they are not observed responses from this call.",
|
|
756
|
+
getterScope: "extractedValues/extractedLists .get() only works for declared Deepline getters listed in usageGuidance.toolExecutionResult.",
|
|
757
|
+
rawToolResponse: "Use toolExecutionResult.toolResponse.rawV2 for the complete tool response. Preserve its nesting and sibling fields as shown in examples; use declared getters for extracted values and lists.",
|
|
758
|
+
invalidGetterHint: "If TypeScript says an extractedValues/extractedLists property does not exist, that field is not a declared Deepline getter.",
|
|
759
|
+
observeActualShape: observedOutputCommand,
|
|
760
|
+
observedOutput: observedOutputCommand,
|
|
761
|
+
forPlayGetterBugs: "Run a tiny play, inspect returned handles with `deepline runs get <run-id> --full`, then export row datasets with `deepline runs export`.",
|
|
762
|
+
executeOutputFields: "tools execute JSON may include output_preview for this direct probe only; play debugging uses run output and returned dataset handles."
|
|
763
|
+
},
|
|
764
|
+
...starterScript ? { starterScript } : {}
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
function usageGuidanceWithAccessDefaults(usageGuidance) {
|
|
768
|
+
if (Object.keys(usageGuidance).length === 0) return usageGuidance;
|
|
769
|
+
const existingAccess = recordField(usageGuidance, "access");
|
|
770
|
+
return {
|
|
771
|
+
...usageGuidance,
|
|
772
|
+
prefer: [
|
|
773
|
+
"Use only the declared extractedLists and extractedValues getters listed below.",
|
|
774
|
+
"Use toolExecutionResult.toolResponse.rawV2 for the complete tool response, preserving the nesting shown in the response example.",
|
|
775
|
+
"Schemas declare field shapes; examples illustrate input values and full Deepline execution responses."
|
|
776
|
+
],
|
|
777
|
+
toolExecutionResult: {
|
|
778
|
+
...recordField(
|
|
779
|
+
usageGuidance,
|
|
780
|
+
"toolExecutionResult",
|
|
781
|
+
"tool_execution_result"
|
|
782
|
+
),
|
|
783
|
+
toolResponse: {
|
|
784
|
+
rawV2: "toolResponse.rawV2",
|
|
785
|
+
view: "toolResponse.view",
|
|
786
|
+
responseMeta: "toolResponse.responseMeta"
|
|
787
|
+
}
|
|
788
|
+
},
|
|
789
|
+
access: {
|
|
790
|
+
...existingAccess,
|
|
791
|
+
extractedValues: {
|
|
792
|
+
expression: "toolExecutionResult.extractedValues.<name>.get()",
|
|
793
|
+
meaning: "Declared Deepline scalar or normalized object extractors only."
|
|
794
|
+
},
|
|
795
|
+
...existingAccess,
|
|
796
|
+
extractedLists: {
|
|
797
|
+
...recordField(existingAccess, "extractedLists"),
|
|
798
|
+
expression: "toolExecutionResult.extractedLists.<name>.get()",
|
|
799
|
+
meaning: _chunkKB4SDX5Sjs.playToolListGetterMode.call(void 0, ) === "array" ? "Returns an ordinary array from this response. Use array methods directly or pass it to ctx.dataset to persist row work. Lazy or incomplete lists throw; use readList for an explicit dataset read. It does not fetch provider pages." : "Returns a PlayDataset, not a JavaScript array. Pass the handle to ctx.dataset, use first(), async iteration, or await handle.materialize() for the complete current list within the memory cap. materialize(n) and peek(n) return a prefix; none fetch additional provider pages. A missing getter is not an empty list."
|
|
800
|
+
},
|
|
801
|
+
rawToolResponse: {
|
|
802
|
+
expression: "toolExecutionResult.toolResponse.rawV2",
|
|
803
|
+
meaning: "Complete tool response with its original nesting. Read tool-specific fields here; use declared getters for extracted values and lists."
|
|
804
|
+
},
|
|
805
|
+
canonicalToolResponse: {
|
|
806
|
+
expression: "toolExecutionResult.toolResponse.rawV2",
|
|
807
|
+
meaning: "Complete tool response with its original nesting and sibling fields."
|
|
808
|
+
},
|
|
809
|
+
invalidGetterHint: "If TypeScript says an extractedValues/extractedLists property does not exist, that field is not a declared Deepline getter; read it from toolResponse.rawV2 using the nesting shown in the response example."
|
|
810
|
+
}
|
|
811
|
+
};
|
|
812
|
+
}
|
|
813
|
+
function toolInputFieldsForDisplay(inputSchema) {
|
|
814
|
+
if (Array.isArray(inputSchema.fields)) {
|
|
815
|
+
const fields = inputSchema.fields.filter(isRecord);
|
|
816
|
+
if (!isRecord(inputSchema.jsonSchema)) return fields;
|
|
817
|
+
const jsonSchemaFields = new Map(
|
|
818
|
+
recursiveToolInputFieldsForDisplay({
|
|
819
|
+
jsonSchema: inputSchema.jsonSchema
|
|
820
|
+
}).flatMap(
|
|
821
|
+
(field) => typeof field.name === "string" ? [[field.name, field]] : []
|
|
822
|
+
)
|
|
823
|
+
);
|
|
824
|
+
return fields.map((field) => {
|
|
825
|
+
const jsonSchemaField = typeof field.name === "string" ? jsonSchemaFields.get(field.name) : void 0;
|
|
826
|
+
const minItems = typeof field.minItems === "number" ? field.minItems : _optionalChain([jsonSchemaField, 'optionalAccess', _8 => _8.minItems]);
|
|
827
|
+
const maxItems = typeof field.maxItems === "number" ? field.maxItems : _optionalChain([jsonSchemaField, 'optionalAccess', _9 => _9.maxItems]);
|
|
828
|
+
const items = isRecord(field.items) ? field.items : _optionalChain([jsonSchemaField, 'optionalAccess', _10 => _10.items]);
|
|
829
|
+
return {
|
|
830
|
+
...field,
|
|
831
|
+
...isRecord(items) ? { items } : {},
|
|
832
|
+
...typeof minItems === "number" ? { minItems } : {},
|
|
833
|
+
...typeof maxItems === "number" ? { maxItems } : {}
|
|
834
|
+
};
|
|
835
|
+
});
|
|
836
|
+
}
|
|
837
|
+
const jsonSchema = isRecord(inputSchema.jsonSchema) ? inputSchema.jsonSchema : inputSchema;
|
|
838
|
+
const properties = isRecord(jsonSchema.properties) ? jsonSchema.properties : {};
|
|
839
|
+
const required = Array.isArray(jsonSchema.required) ? new Set(jsonSchema.required.map(String)) : /* @__PURE__ */ new Set();
|
|
840
|
+
return Object.entries(properties).map(([name, value2]) => {
|
|
841
|
+
const property = isRecord(value2) ? value2 : {};
|
|
842
|
+
return {
|
|
843
|
+
name,
|
|
844
|
+
type: typeof property.type === "string" ? property.type : "unknown",
|
|
845
|
+
required: required.has(name),
|
|
846
|
+
description: property.description,
|
|
847
|
+
...isRecord(property.items) ? { items: property.items } : {},
|
|
848
|
+
...typeof property.minItems === "number" ? { minItems: property.minItems } : {},
|
|
849
|
+
...typeof property.maxItems === "number" ? { maxItems: property.maxItems } : {},
|
|
850
|
+
...Object.prototype.hasOwnProperty.call(property, "default") ? { default: property.default } : {}
|
|
851
|
+
};
|
|
852
|
+
});
|
|
853
|
+
}
|
|
854
|
+
function toolOutputFieldsForDisplay(outputSchema) {
|
|
855
|
+
if (Object.keys(outputSchema).length === 0) return [];
|
|
856
|
+
return recursiveToolInputFieldsForDisplay({
|
|
857
|
+
jsonSchema: outputSchema
|
|
858
|
+
}).filter(
|
|
859
|
+
(field) => typeof field.name === "string" && field.name.includes("[]")
|
|
860
|
+
);
|
|
861
|
+
}
|
|
862
|
+
function canonicalToolJsonSchema(inputSchema) {
|
|
863
|
+
return isRecord(inputSchema.jsonSchema) ? inputSchema.jsonSchema : inputSchema;
|
|
864
|
+
}
|
|
865
|
+
function publicToolInputSchemaForDescribe(inputSchema) {
|
|
866
|
+
const exposesProviderSpend = (description) => {
|
|
867
|
+
const withoutDeeplineCredits = description.replace(
|
|
868
|
+
/\bdeepline(?:-facing)?\s+credits?\b/gi,
|
|
869
|
+
""
|
|
870
|
+
);
|
|
871
|
+
return /\bcredits?\b/i.test(withoutDeeplineCredits) || /\bprovider\s+(?:cost|spend|price|pricing|usage)\b/i.test(
|
|
872
|
+
withoutDeeplineCredits
|
|
873
|
+
) || /\b(?:costs?|charges?|priced at)\s+[$€£]\s*\d/i.test(
|
|
874
|
+
withoutDeeplineCredits
|
|
875
|
+
) || /\b(?:costs?|charges?|priced at)\s+\d+(?:\.\d+)?\s*(?:usd|eur|gbp)\b/i.test(
|
|
876
|
+
withoutDeeplineCredits
|
|
877
|
+
) || /\battribute-priced\b/i.test(withoutDeeplineCredits) || /\b(?:cost|price|pricing)\s+(?:grows?|increases?|scales?|varies?)\b/i.test(
|
|
878
|
+
withoutDeeplineCredits
|
|
879
|
+
) || /\b(?:will be|are|is|be)\s+(?:billed|charged)\b/i.test(
|
|
880
|
+
withoutDeeplineCredits
|
|
881
|
+
) || /\b(?:additional|extra)\s+charges?\b/i.test(withoutDeeplineCredits) || /\bcharg(?:e|ed)\s+(?:double|per)\b/i.test(withoutDeeplineCredits) || /\bpricing page\b/i.test(withoutDeeplineCredits);
|
|
882
|
+
};
|
|
883
|
+
const stripDescriptions = (value2) => {
|
|
884
|
+
if (Array.isArray(value2)) return value2.map(stripDescriptions);
|
|
885
|
+
if (!isRecord(value2)) return value2;
|
|
886
|
+
return Object.fromEntries(
|
|
887
|
+
Object.entries(value2).flatMap(([key, nested]) => {
|
|
888
|
+
if (key === "description" && typeof nested === "string" && exposesProviderSpend(nested)) {
|
|
889
|
+
return [];
|
|
890
|
+
}
|
|
891
|
+
return [[key, stripDescriptions(nested)]];
|
|
892
|
+
})
|
|
893
|
+
);
|
|
894
|
+
};
|
|
895
|
+
return stripDescriptions(inputSchema);
|
|
896
|
+
}
|
|
897
|
+
function recursiveToolInputFieldsForDisplay(inputSchema) {
|
|
898
|
+
const root = canonicalToolJsonSchema(inputSchema);
|
|
899
|
+
const fields = /* @__PURE__ */ new Map();
|
|
900
|
+
const schemasById = /* @__PURE__ */ new Map();
|
|
901
|
+
const collectSchemaIds = (value2) => {
|
|
902
|
+
if (Array.isArray(value2)) {
|
|
903
|
+
for (const item of value2) collectSchemaIds(item);
|
|
904
|
+
return;
|
|
905
|
+
}
|
|
906
|
+
if (!isRecord(value2)) return;
|
|
907
|
+
if (typeof value2.$id === "string" && value2.$id.trim()) {
|
|
908
|
+
schemasById.set(value2.$id.trim(), value2);
|
|
909
|
+
}
|
|
910
|
+
for (const nested of Object.values(value2)) collectSchemaIds(nested);
|
|
911
|
+
};
|
|
912
|
+
collectSchemaIds(root);
|
|
913
|
+
const resolveRef = (schema) => {
|
|
914
|
+
const ref = typeof schema.$ref === "string" ? schema.$ref : "";
|
|
915
|
+
if (!ref.startsWith("#/")) return _nullishCoalesce(schemasById.get(ref), () => ( schema));
|
|
916
|
+
let current = root;
|
|
917
|
+
for (const rawSegment of ref.slice(2).split("/")) {
|
|
918
|
+
const segment = rawSegment.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
919
|
+
if (!isRecord(current)) return schema;
|
|
920
|
+
current = current[segment];
|
|
921
|
+
}
|
|
922
|
+
return isRecord(current) ? current : schema;
|
|
923
|
+
};
|
|
924
|
+
const addField = (field) => {
|
|
925
|
+
const name = typeof field.name === "string" ? field.name : "";
|
|
926
|
+
if (!name) return;
|
|
927
|
+
const existing = fields.get(name);
|
|
928
|
+
if (!existing || existing.type === "unknown") {
|
|
929
|
+
fields.set(name, field);
|
|
930
|
+
}
|
|
931
|
+
};
|
|
932
|
+
const visit = (unresolvedSchema, path, required, activeRefs = /* @__PURE__ */ new Set()) => {
|
|
933
|
+
const ref = typeof unresolvedSchema.$ref === "string" ? unresolvedSchema.$ref : "";
|
|
934
|
+
if (ref && activeRefs.has(ref)) return;
|
|
935
|
+
const schema = resolveRef(unresolvedSchema);
|
|
936
|
+
const nextActiveRefs = ref ? /* @__PURE__ */ new Set([...activeRefs, ref]) : activeRefs;
|
|
937
|
+
const type = Array.isArray(schema.type) ? schema.type.map(String).join("|") : typeof schema.type === "string" ? schema.type : isRecord(schema.properties) ? "object" : schema.items ? "array" : "unknown";
|
|
938
|
+
if (path) {
|
|
939
|
+
addField({
|
|
940
|
+
name: path,
|
|
941
|
+
type,
|
|
942
|
+
required,
|
|
943
|
+
description: schema.description,
|
|
944
|
+
...Array.isArray(schema.enum) ? { enum: schema.enum } : {},
|
|
945
|
+
...isRecord(schema.items) ? { items: schema.items } : {},
|
|
946
|
+
...typeof schema.minItems === "number" ? { minItems: schema.minItems } : {},
|
|
947
|
+
...typeof schema.maxItems === "number" ? { maxItems: schema.maxItems } : {},
|
|
948
|
+
...Object.prototype.hasOwnProperty.call(schema, "default") ? { default: schema.default } : {}
|
|
949
|
+
});
|
|
950
|
+
}
|
|
951
|
+
const properties = isRecord(schema.properties) ? schema.properties : {};
|
|
952
|
+
const requiredNames = new Set(
|
|
953
|
+
Array.isArray(schema.required) ? schema.required.map(String) : []
|
|
954
|
+
);
|
|
955
|
+
for (const [name, value2] of Object.entries(properties)) {
|
|
956
|
+
if (!isRecord(value2)) continue;
|
|
957
|
+
visit(
|
|
958
|
+
value2,
|
|
959
|
+
path ? `${path}.${name}` : name,
|
|
960
|
+
requiredNames.has(name),
|
|
961
|
+
nextActiveRefs
|
|
962
|
+
);
|
|
963
|
+
}
|
|
964
|
+
if (isRecord(schema.items)) {
|
|
965
|
+
visit(schema.items, `${path}[]`, false, nextActiveRefs);
|
|
966
|
+
}
|
|
967
|
+
for (const keyword of ["anyOf", "oneOf", "allOf"]) {
|
|
968
|
+
const branches = Array.isArray(schema[keyword]) ? schema[keyword] : [];
|
|
969
|
+
for (const branch of branches) {
|
|
970
|
+
if (isRecord(branch)) {
|
|
971
|
+
visit(branch, path, required, nextActiveRefs);
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
};
|
|
976
|
+
visit(root, "", false);
|
|
977
|
+
return fields.size ? [...fields.values()] : toolInputFieldsForDisplay(inputSchema);
|
|
978
|
+
}
|
|
979
|
+
function inputFieldJsonForDescribe(field) {
|
|
980
|
+
const publicItems = isRecord(field.items) ? publicToolInputSchemaForDescribe({ items: field.items }).items : void 0;
|
|
981
|
+
return {
|
|
982
|
+
name: field.name,
|
|
983
|
+
type: _nullishCoalesce(field.type, () => ( "unknown")),
|
|
984
|
+
required: Boolean(field.required),
|
|
985
|
+
...field.description ? { description: field.description } : {},
|
|
986
|
+
...isRecord(publicItems) ? { items: publicItems } : {},
|
|
987
|
+
...typeof field.minItems === "number" ? { minItems: field.minItems } : {},
|
|
988
|
+
...typeof field.maxItems === "number" ? { maxItems: field.maxItems } : {},
|
|
989
|
+
...Object.prototype.hasOwnProperty.call(field, "default") ? { default: field.default } : {}
|
|
990
|
+
};
|
|
991
|
+
}
|
|
992
|
+
function isRecord(value2) {
|
|
993
|
+
return Boolean(value2 && typeof value2 === "object" && !Array.isArray(value2));
|
|
994
|
+
}
|
|
995
|
+
function stringField(source, ...keys) {
|
|
996
|
+
for (const key of keys) {
|
|
997
|
+
const value2 = source[key];
|
|
998
|
+
if (typeof value2 === "string" && value2.trim()) return value2.trim();
|
|
999
|
+
}
|
|
1000
|
+
return "";
|
|
1001
|
+
}
|
|
1002
|
+
function arrayField(source, ...keys) {
|
|
1003
|
+
for (const key of keys) {
|
|
1004
|
+
const value2 = source[key];
|
|
1005
|
+
if (Array.isArray(value2)) return value2;
|
|
1006
|
+
}
|
|
1007
|
+
return [];
|
|
1008
|
+
}
|
|
1009
|
+
function recordField(source, ...keys) {
|
|
1010
|
+
for (const key of keys) {
|
|
1011
|
+
const value2 = source[key];
|
|
1012
|
+
if (isRecord(value2)) return value2;
|
|
1013
|
+
}
|
|
1014
|
+
return {};
|
|
1015
|
+
}
|
|
1016
|
+
function starterScriptJson(script) {
|
|
1017
|
+
return {
|
|
1018
|
+
path: script.path,
|
|
1019
|
+
sourceCode: script.sourceCode,
|
|
1020
|
+
projectDir: script.projectDir,
|
|
1021
|
+
copyToProject: {
|
|
1022
|
+
macosLinux: script.macCopyCommand,
|
|
1023
|
+
windowsPowerShell: script.windowsCopyCommand
|
|
1024
|
+
}
|
|
1025
|
+
};
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
// ../plays/tool-category-descriptions.ts
|
|
1029
|
+
var TOOL_CATEGORY_DESCRIPTIONS = {
|
|
1030
|
+
company_search: "Find companies matching firmographic, ad, or web criteria.",
|
|
1031
|
+
people_search: "Find people matching role, company, or persona criteria.",
|
|
1032
|
+
people_enrich: "Enrich a known person with contact, social, and profile data.",
|
|
1033
|
+
company_enrich: "Enrich a known company with firmographic and account data.",
|
|
1034
|
+
email_finder: "Find work or personal email addresses for a person.",
|
|
1035
|
+
email_verify: "Validate email deliverability and catch-all status.",
|
|
1036
|
+
phone_finder: "Find mobile or direct phone numbers for a person.",
|
|
1037
|
+
phone_verify: "Validate phone-number reachability and line type.",
|
|
1038
|
+
research: "Research accounts, people, news, and signals for context and scoring.",
|
|
1039
|
+
autocomplete: "Resolve names and entities to canonical catalog records.",
|
|
1040
|
+
automation: "Kick off provider-side jobs, exports, and asynchronous workflows.",
|
|
1041
|
+
outbound_tools: "Run outbound sequencing, deliverability, and campaign operations.",
|
|
1042
|
+
admin: "Provider-side status, metadata, and account operations behind other tools.",
|
|
1043
|
+
smb: "Look up small-business listings, local records, and public filings.",
|
|
1044
|
+
identity_resolution: "Match a partial identity to a single resolved person or company.",
|
|
1045
|
+
reverse_lookup: "Resolve an email, phone, or profile back to a person.",
|
|
1046
|
+
enrichment: "General-purpose record enrichment across people and companies.",
|
|
1047
|
+
batch: "Run an enrichment or search operation over many rows at once.",
|
|
1048
|
+
premium: "Higher-cost tools with premium provider coverage.",
|
|
1049
|
+
free: "Free tools that do not spend Deepline credits."
|
|
1050
|
+
};
|
|
1051
|
+
var WELL_KNOWN_TOOL_CATEGORIES = Object.freeze(
|
|
1052
|
+
Object.keys(TOOL_CATEGORY_DESCRIPTIONS)
|
|
1053
|
+
);
|
|
1054
|
+
function describeToolCategory(category) {
|
|
1055
|
+
return _nullishCoalesce(TOOL_CATEGORY_DESCRIPTIONS[category], () => ( null));
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
// src/cli/commands/model-description.ts
|
|
1059
|
+
function formatModelDescription(description) {
|
|
1060
|
+
const lines = [];
|
|
1061
|
+
lines.push(description.model);
|
|
1062
|
+
lines.push(`Provider: ${description.provider}`);
|
|
1063
|
+
const name = stringField2(description.modelMetadata, "name");
|
|
1064
|
+
if (name) lines.push(`Name: ${name}`);
|
|
1065
|
+
const contextWindow = numberField(
|
|
1066
|
+
description.modelMetadata,
|
|
1067
|
+
"context_window"
|
|
1068
|
+
);
|
|
1069
|
+
if (contextWindow !== null) lines.push(`Context: ${contextWindow}`);
|
|
1070
|
+
const tags = arrayField2(description.modelMetadata, "tags").filter(
|
|
1071
|
+
(value2) => typeof value2 === "string"
|
|
1072
|
+
);
|
|
1073
|
+
if (tags.length) lines.push(`Tags: ${tags.join(", ")}`);
|
|
1074
|
+
lines.push("");
|
|
1075
|
+
lines.push("Provider options:");
|
|
1076
|
+
appendNamespace(lines, description.providerOptions.gateway);
|
|
1077
|
+
if (description.providerOptions.selectedProvider) {
|
|
1078
|
+
appendNamespace(lines, description.providerOptions.selectedProvider);
|
|
1079
|
+
}
|
|
1080
|
+
lines.push("");
|
|
1081
|
+
lines.push("Example input:");
|
|
1082
|
+
lines.push(JSON.stringify(description.exampleInput, null, 2));
|
|
1083
|
+
if (description.caveats.length) {
|
|
1084
|
+
lines.push("");
|
|
1085
|
+
lines.push("Caveats:");
|
|
1086
|
+
for (const caveat of description.caveats) {
|
|
1087
|
+
lines.push(`- ${caveat}`);
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
return `${lines.join("\n")}
|
|
1091
|
+
`;
|
|
1092
|
+
}
|
|
1093
|
+
function appendNamespace(lines, namespace) {
|
|
1094
|
+
lines.push(`- ${namespace.provider} (${namespace.sourceSymbol})`);
|
|
1095
|
+
for (const field of namespace.fields) {
|
|
1096
|
+
const values = _optionalChain([field, 'access', _11 => _11.enumValues, 'optionalAccess', _12 => _12.length]) ? ` (${field.enumValues.map((value2) => JSON.stringify(value2)).join(" | ")})` : "";
|
|
1097
|
+
lines.push(
|
|
1098
|
+
` - ${field.name}: ${field.type}${values} - ${field.description}`
|
|
1099
|
+
);
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
function stringField2(value2, key) {
|
|
1103
|
+
if (!value2 || typeof value2 !== "object" || Array.isArray(value2)) return null;
|
|
1104
|
+
const candidate = value2[key];
|
|
1105
|
+
return typeof candidate === "string" && candidate.trim() ? candidate.trim() : null;
|
|
1106
|
+
}
|
|
1107
|
+
function numberField(value2, key) {
|
|
1108
|
+
if (!value2 || typeof value2 !== "object" || Array.isArray(value2)) return null;
|
|
1109
|
+
const candidate = value2[key];
|
|
1110
|
+
return typeof candidate === "number" ? candidate : null;
|
|
1111
|
+
}
|
|
1112
|
+
function arrayField2(value2, key) {
|
|
1113
|
+
if (!value2 || typeof value2 !== "object" || Array.isArray(value2)) return [];
|
|
1114
|
+
const candidate = value2[key];
|
|
1115
|
+
return Array.isArray(candidate) ? candidate : [];
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
// src/cli/tool-connection-status.ts
|
|
1119
|
+
function toolConnectionStatusMessage(input) {
|
|
1120
|
+
if (input.credentialStatus === "requires_connection") {
|
|
1121
|
+
return "requires your credentials \u2014 not connected (connect to use)";
|
|
1122
|
+
}
|
|
1123
|
+
if (input.connected === false && input.credentialStatus === "managed") {
|
|
1124
|
+
return "temporarily unavailable";
|
|
1125
|
+
}
|
|
1126
|
+
return null;
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
// src/cli/commands/tools.ts
|
|
1130
|
+
var TOOL_COMMAND_TEMPLATES = {
|
|
1131
|
+
describe: "deepline describe <toolId>",
|
|
1132
|
+
execute: "deepline tools execute <toolId> --input '{...}'"
|
|
1133
|
+
};
|
|
1134
|
+
function toListedTool(tool) {
|
|
1135
|
+
if (isPlayLikeTool(tool)) {
|
|
1136
|
+
return {
|
|
1137
|
+
...tool,
|
|
1138
|
+
description: listedToolDescription(tool),
|
|
1139
|
+
id: tool.toolId,
|
|
1140
|
+
type: "play",
|
|
1141
|
+
executeCommand: playRunCommandForTool(tool, tool.toolId)
|
|
1142
|
+
};
|
|
1143
|
+
}
|
|
1144
|
+
return {
|
|
1145
|
+
...tool,
|
|
1146
|
+
description: listedToolDescription(tool),
|
|
1147
|
+
id: tool.toolId,
|
|
1148
|
+
type: "tool",
|
|
1149
|
+
executeCommand: `deepline tools execute ${tool.toolId}`
|
|
1150
|
+
};
|
|
1151
|
+
}
|
|
1152
|
+
function normalizeGrepText(value2) {
|
|
1153
|
+
if (value2 === null || value2 === void 0) return "";
|
|
1154
|
+
if (typeof value2 === "string") return value2.toLowerCase();
|
|
1155
|
+
if (typeof value2 === "number" || typeof value2 === "boolean") {
|
|
1156
|
+
return String(value2).toLowerCase();
|
|
1157
|
+
}
|
|
501
1158
|
if (Array.isArray(value2)) return value2.map(normalizeGrepText).join(" ");
|
|
502
1159
|
if (typeof value2 === "object") {
|
|
503
1160
|
return Object.values(value2).map(normalizeGrepText).join(" ");
|
|
@@ -523,7 +1180,7 @@ function shellCommandArg(value2) {
|
|
|
523
1180
|
}
|
|
524
1181
|
function zeroMatchToolGuidance(options) {
|
|
525
1182
|
const categories = _nullishCoalesce(options.categories, () => ( []));
|
|
526
|
-
const query = _nullishCoalesce(_optionalChain([options, 'access',
|
|
1183
|
+
const query = _nullishCoalesce(_optionalChain([options, 'access', _13 => _13.query, 'optionalAccess', _14 => _14.trim, 'call', _15 => _15()]), () => ( ""));
|
|
527
1184
|
const filterText = [
|
|
528
1185
|
categories.length ? `categories=${categories.join(",")}` : null,
|
|
529
1186
|
query ? `grep=${query}` : null,
|
|
@@ -591,7 +1248,7 @@ function requiredInputIds(tool) {
|
|
|
591
1248
|
}
|
|
592
1249
|
function notConnectedSuffix(tool) {
|
|
593
1250
|
const record = tool;
|
|
594
|
-
const status =
|
|
1251
|
+
const status = stringField(record, "credentialStatus", "credential_status");
|
|
595
1252
|
const connected = record.connected;
|
|
596
1253
|
const message = toolConnectionStatusMessage({
|
|
597
1254
|
connected: connected === false ? false : void 0,
|
|
@@ -605,13 +1262,13 @@ function shortPricingHint(tool) {
|
|
|
605
1262
|
"pricing"
|
|
606
1263
|
);
|
|
607
1264
|
const credits = numberField2(pricing, "creditsPerUnit", "credits_per_unit");
|
|
608
|
-
const unit =
|
|
1265
|
+
const unit = stringField(pricing, "unit");
|
|
609
1266
|
if (credits !== null) {
|
|
610
1267
|
return `${formatDecimal(credits)} cr/${unit || "unit"}`;
|
|
611
1268
|
}
|
|
612
|
-
const summary =
|
|
1269
|
+
const summary = stringField(pricing, "summary");
|
|
613
1270
|
if (summary) return summary;
|
|
614
|
-
const displayText =
|
|
1271
|
+
const displayText = stringField(pricing, "displayText", "display_text");
|
|
615
1272
|
return displayText || null;
|
|
616
1273
|
}
|
|
617
1274
|
function aggregateCategorySummaries(tools) {
|
|
@@ -655,12 +1312,12 @@ function categoryEnumerationRender(summaries) {
|
|
|
655
1312
|
};
|
|
656
1313
|
}
|
|
657
1314
|
async function listToolCategories(emitJson, compact) {
|
|
658
|
-
const client = new (0,
|
|
1315
|
+
const client = new (0, _chunkWQJJNIMQjs.DeeplineClient)();
|
|
659
1316
|
const rawTools = await client.listTools({ compact });
|
|
660
1317
|
const items = rawTools.map(toListedTool);
|
|
661
1318
|
const summaries = aggregateCategorySummaries(rawTools);
|
|
662
1319
|
const outputItems = compact ? items.map(compactTool) : items;
|
|
663
|
-
|
|
1320
|
+
_chunkRTO5QZWTjs.printCommandEnvelope.call(void 0,
|
|
664
1321
|
{
|
|
665
1322
|
tools: outputItems,
|
|
666
1323
|
count: outputItems.length,
|
|
@@ -679,7 +1336,7 @@ function unknownCategoryError(category, summaries, emitJson) {
|
|
|
679
1336
|
const known = summaries.map((item) => item.name);
|
|
680
1337
|
const message = `Unknown tool category "${category}". Run \`deepline tools list\` to browse categories.`;
|
|
681
1338
|
if (emitJson) {
|
|
682
|
-
|
|
1339
|
+
_chunkRTO5QZWTjs.printJson.call(void 0, {
|
|
683
1340
|
ok: false,
|
|
684
1341
|
exitCode: 4,
|
|
685
1342
|
code: "TOOL_CATEGORY_NOT_FOUND",
|
|
@@ -693,13 +1350,13 @@ function unknownCategoryError(category, summaries, emitJson) {
|
|
|
693
1350
|
const render = categoryEnumerationRender(summaries);
|
|
694
1351
|
console.error(message);
|
|
695
1352
|
console.error("");
|
|
696
|
-
console.error(
|
|
1353
|
+
console.error(_chunkRTO5QZWTjs.renderCommandEnvelopeText.call(void 0, { render }).trimEnd());
|
|
697
1354
|
console.error("");
|
|
698
1355
|
console.error(`Valid categories: ${known.join(", ")}`);
|
|
699
1356
|
return 4;
|
|
700
1357
|
}
|
|
701
1358
|
async function listToolsInCategory(category, emitJson) {
|
|
702
|
-
const client = new (0,
|
|
1359
|
+
const client = new (0, _chunkWQJJNIMQjs.DeeplineClient)();
|
|
703
1360
|
const rawTools = await client.listTools({
|
|
704
1361
|
categories: category,
|
|
705
1362
|
compact: false
|
|
@@ -709,7 +1366,7 @@ async function listToolsInCategory(category, emitJson) {
|
|
|
709
1366
|
if (!summaries.some((item) => item.name === category)) {
|
|
710
1367
|
return unknownCategoryError(category, summaries, emitJson);
|
|
711
1368
|
}
|
|
712
|
-
const rows = rawTools.filter((tool) => _optionalChain([tool, 'access',
|
|
1369
|
+
const rows = rawTools.filter((tool) => _optionalChain([tool, 'access', _16 => _16.categories, 'optionalAccess', _17 => _17.includes, 'call', _18 => _18(category)])).map((tool) => ({
|
|
713
1370
|
id: tool.toolId,
|
|
714
1371
|
provider: tool.provider,
|
|
715
1372
|
required: requiredInputIds(tool),
|
|
@@ -736,7 +1393,7 @@ async function listToolsInCategory(category, emitJson) {
|
|
|
736
1393
|
}
|
|
737
1394
|
]
|
|
738
1395
|
};
|
|
739
|
-
|
|
1396
|
+
_chunkRTO5QZWTjs.printCommandEnvelope.call(void 0,
|
|
740
1397
|
{
|
|
741
1398
|
category,
|
|
742
1399
|
total: rows.length,
|
|
@@ -749,7 +1406,7 @@ async function listToolsInCategory(category, emitJson) {
|
|
|
749
1406
|
return 0;
|
|
750
1407
|
}
|
|
751
1408
|
async function listToolsForCategoryFilter(requestedCategories, emitJson, compact) {
|
|
752
|
-
const client = new (0,
|
|
1409
|
+
const client = new (0, _chunkWQJJNIMQjs.DeeplineClient)();
|
|
753
1410
|
const items = (await client.listTools({
|
|
754
1411
|
categories: requestedCategories.join(","),
|
|
755
1412
|
compact
|
|
@@ -778,7 +1435,7 @@ async function listToolsForCategoryFilter(requestedCategories, emitJson, compact
|
|
|
778
1435
|
]
|
|
779
1436
|
};
|
|
780
1437
|
const outputItems = compact ? items.map(compactTool) : items;
|
|
781
|
-
|
|
1438
|
+
_chunkRTO5QZWTjs.printCommandEnvelope.call(void 0,
|
|
782
1439
|
{
|
|
783
1440
|
tools: outputItems,
|
|
784
1441
|
count: outputItems.length,
|
|
@@ -794,16 +1451,16 @@ async function listToolsForCategoryFilter(requestedCategories, emitJson, compact
|
|
|
794
1451
|
return 0;
|
|
795
1452
|
}
|
|
796
1453
|
async function listTools(category, options = {}) {
|
|
797
|
-
const positional = _nullishCoalesce(_optionalChain([category, 'optionalAccess',
|
|
1454
|
+
const positional = _nullishCoalesce(_optionalChain([category, 'optionalAccess', _19 => _19.trim, 'call', _20 => _20()]), () => ( ""));
|
|
798
1455
|
const flagCategories = (_nullishCoalesce(options.categories, () => ( ""))).split(",").map((item) => item.trim()).filter(Boolean);
|
|
799
1456
|
const compact = options.compact !== false;
|
|
800
|
-
const emitJson = options.json === true ||
|
|
1457
|
+
const emitJson = options.json === true || _chunkRTO5QZWTjs.shouldEmitJson.call(void 0, );
|
|
801
1458
|
if (positional && flagCategories.length > 0) {
|
|
802
1459
|
const flagIsSameSingle = flagCategories.length === 1 && flagCategories[0] === positional;
|
|
803
1460
|
if (!flagIsSameSingle) {
|
|
804
1461
|
const message = `Category "${positional}" and --categories ${flagCategories.join(",")} disagree. Pass one: deepline tools list ${positional}`;
|
|
805
1462
|
if (emitJson) {
|
|
806
|
-
|
|
1463
|
+
_chunkRTO5QZWTjs.printJson.call(void 0, {
|
|
807
1464
|
ok: false,
|
|
808
1465
|
exitCode: 2,
|
|
809
1466
|
code: "TOOL_LIST_CATEGORY_CONFLICT",
|
|
@@ -830,7 +1487,7 @@ async function grepTools(queryInput, options = {}) {
|
|
|
830
1487
|
console.error("Usage: deepline tools grep <query> [--json]");
|
|
831
1488
|
return 1;
|
|
832
1489
|
}
|
|
833
|
-
const client = new (0,
|
|
1490
|
+
const client = new (0, _chunkWQJJNIMQjs.DeeplineClient)();
|
|
834
1491
|
const requestedCategories = options.categories ? options.categories.split(",").map((item) => item.trim()).filter(Boolean) : [];
|
|
835
1492
|
const mode = _nullishCoalesce(options.mode, () => ( "all"));
|
|
836
1493
|
const jsonOutput = options.json === true;
|
|
@@ -873,7 +1530,7 @@ async function grepTools(queryInput, options = {}) {
|
|
|
873
1530
|
query,
|
|
874
1531
|
mode
|
|
875
1532
|
}) : null;
|
|
876
|
-
|
|
1533
|
+
_chunkRTO5QZWTjs.printCommandEnvelope.call(void 0,
|
|
877
1534
|
{
|
|
878
1535
|
tools: outputTools,
|
|
879
1536
|
count: outputTools.length,
|
|
@@ -891,7 +1548,7 @@ async function grepTools(queryInput, options = {}) {
|
|
|
891
1548
|
} : {},
|
|
892
1549
|
commandTemplates: TOOL_COMMAND_TEMPLATES
|
|
893
1550
|
},
|
|
894
|
-
{ json: options.json ||
|
|
1551
|
+
{ json: options.json || _chunkRTO5QZWTjs.shouldEmitJson.call(void 0, ) }
|
|
895
1552
|
);
|
|
896
1553
|
return 0;
|
|
897
1554
|
}
|
|
@@ -917,7 +1574,7 @@ function compactTool(tool) {
|
|
|
917
1574
|
};
|
|
918
1575
|
}
|
|
919
1576
|
function playIdentifiers(play) {
|
|
920
|
-
return [play.name, play.reference, ..._nullishCoalesce(play.aliases, () => ( []))].filter((value2) => Boolean(_optionalChain([value2, 'optionalAccess',
|
|
1577
|
+
return [play.name, play.reference, ..._nullishCoalesce(play.aliases, () => ( []))].filter((value2) => Boolean(_optionalChain([value2, 'optionalAccess', _21 => _21.trim, 'call', _22 => _22()]))).map((value2) => value2.trim());
|
|
921
1578
|
}
|
|
922
1579
|
async function findPlayForToolId(client, toolId, cliInvocationId) {
|
|
923
1580
|
const requested = toolId.trim();
|
|
@@ -943,34 +1600,6 @@ Inspect its schema with: deepline describe ${playName}`;
|
|
|
943
1600
|
function printPlayAliasToolError(toolId, play) {
|
|
944
1601
|
console.error(playAliasToolErrorMessage(toolId, play));
|
|
945
1602
|
}
|
|
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
1603
|
function playLikeToolExecuteErrorMessage(toolId, tool) {
|
|
975
1604
|
const playReference = tool ? playReferenceForTool(tool) : null;
|
|
976
1605
|
const nextStep = playReference ? `Use: deepline plays run ${playReference} --input '{...}'` : `Find the maintained workflow with: ${playSearchCommandForToolId(toolId)}`;
|
|
@@ -1037,7 +1666,7 @@ Output:
|
|
|
1037
1666
|
"--credentials-file must contain a nonempty JSON object of string credential values."
|
|
1038
1667
|
);
|
|
1039
1668
|
}
|
|
1040
|
-
const result = await new (0,
|
|
1669
|
+
const result = await new (0, _chunkWQJJNIMQjs.DeeplineClient)().setIntegrationCredentials(
|
|
1041
1670
|
provider,
|
|
1042
1671
|
credentials
|
|
1043
1672
|
);
|
|
@@ -1047,7 +1676,7 @@ Output:
|
|
|
1047
1676
|
);
|
|
1048
1677
|
}
|
|
1049
1678
|
const confirmation = { provider, credential_saved: true };
|
|
1050
|
-
if (
|
|
1679
|
+
if (_chunkRTO5QZWTjs.shouldEmitJson.call(void 0, options.json))
|
|
1051
1680
|
console.log(JSON.stringify(confirmation));
|
|
1052
1681
|
else
|
|
1053
1682
|
console.log(
|
|
@@ -1087,7 +1716,7 @@ Examples:
|
|
|
1087
1716
|
json: Boolean(options.json)
|
|
1088
1717
|
});
|
|
1089
1718
|
});
|
|
1090
|
-
|
|
1719
|
+
_chunkKAEZNPUMjs.registerDeprecatedSearchCommand.call(void 0, tools, () => ["tools", "monitors"]);
|
|
1091
1720
|
tools.command("grep <query>").description(
|
|
1092
1721
|
"Literal grep over tool ids, descriptions, categories, and input fields."
|
|
1093
1722
|
).addHelpText(
|
|
@@ -1188,7 +1817,7 @@ Examples:
|
|
|
1188
1817
|
process.exitCode = await narrowView();
|
|
1189
1818
|
return;
|
|
1190
1819
|
}
|
|
1191
|
-
const { describeAnything } = await Promise.resolve().then(() => _interopRequireWildcard(require("./describe-
|
|
1820
|
+
const { describeAnything } = await Promise.resolve().then(() => _interopRequireWildcard(require("./describe-EFWNECHI.js")));
|
|
1192
1821
|
process.exitCode = await describeAnything(
|
|
1193
1822
|
toolId,
|
|
1194
1823
|
{
|
|
@@ -1203,7 +1832,7 @@ Examples:
|
|
|
1203
1832
|
});
|
|
1204
1833
|
};
|
|
1205
1834
|
addToolMetadataCommand(
|
|
1206
|
-
|
|
1835
|
+
_chunkNSOTASOPjs.addDescribeOptions.call(void 0,
|
|
1207
1836
|
tools.command("describe <toolId>", { hidden: true }).alias("get"),
|
|
1208
1837
|
{ json: false }
|
|
1209
1838
|
)
|
|
@@ -1274,7 +1903,7 @@ async function getTool(toolId, options = {}, compatibilityMetadata) {
|
|
|
1274
1903
|
console.error("Usage: deepline tools describe <toolId> [--json]");
|
|
1275
1904
|
return 1;
|
|
1276
1905
|
}
|
|
1277
|
-
const client = new (0,
|
|
1906
|
+
const client = new (0, _chunkWQJJNIMQjs.DeeplineClient)();
|
|
1278
1907
|
let tool;
|
|
1279
1908
|
try {
|
|
1280
1909
|
tool = await _asyncNullishCoalesce(compatibilityMetadata, async () => ( await client.getTool(toolId)));
|
|
@@ -1328,10 +1957,10 @@ async function getTool(toolId, options = {}, compatibilityMetadata) {
|
|
|
1328
1957
|
const lines = toolPricingOnlyLines(tool, toolId);
|
|
1329
1958
|
if (inferenceQuote)
|
|
1330
1959
|
lines.push(...inferenceQuoteSummaryLines(inferenceQuote));
|
|
1331
|
-
|
|
1960
|
+
_chunkRTO5QZWTjs.printCommandEnvelope.call(void 0,
|
|
1332
1961
|
{
|
|
1333
1962
|
toolId: String(tool.toolId || toolId),
|
|
1334
|
-
cost:
|
|
1963
|
+
cost: _chunkKAEZNPUMjs.Capability.fromCatalogEntry(tool).describe().customerCost(),
|
|
1335
1964
|
...modelDescription ? { modelOptions: modelDescription } : {},
|
|
1336
1965
|
...isMonitorTypeTool(tool) ? { pricing: recordField(tool, "pricing") } : {},
|
|
1337
1966
|
...inferenceQuote ? { inferenceQuote } : {}
|
|
@@ -1345,8 +1974,13 @@ async function getTool(toolId, options = {}, compatibilityMetadata) {
|
|
|
1345
1974
|
return 0;
|
|
1346
1975
|
}
|
|
1347
1976
|
if ((options.schemaOnly || options.examplesOnly || options.gettersOnly) && !isMonitorTypeTool(tool) && !isPlayLikeTool(tool) && (options.json || options.contractJson)) {
|
|
1348
|
-
const contract = toolContractJsonForDescribe(
|
|
1349
|
-
|
|
1977
|
+
const contract = toolContractJsonForDescribe(
|
|
1978
|
+
tool,
|
|
1979
|
+
toolId,
|
|
1980
|
+
void 0,
|
|
1981
|
+
seedToolListScript
|
|
1982
|
+
);
|
|
1983
|
+
_chunkRTO5QZWTjs.printCompactJson.call(void 0, {
|
|
1350
1984
|
toolId: contract.toolId,
|
|
1351
1985
|
...options.schemaOnly ? {
|
|
1352
1986
|
inputSchema: contract.inputSchema,
|
|
@@ -1369,173 +2003,75 @@ async function getTool(toolId, options = {}, compatibilityMetadata) {
|
|
|
1369
2003
|
return 0;
|
|
1370
2004
|
}
|
|
1371
2005
|
if (options.contractJson) {
|
|
1372
|
-
|
|
1373
|
-
...toolContractJsonForDescribe(
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
const emitJson = options.json === true;
|
|
1380
|
-
if (emitJson) {
|
|
1381
|
-
_chunkHRWUQJ4Kjs.printCompactJson.call(void 0, {
|
|
1382
|
-
...toolMetadataJsonForDescribe(tool, toolId),
|
|
2006
|
+
_chunkRTO5QZWTjs.printCompactJson.call(void 0, {
|
|
2007
|
+
...toolContractJsonForDescribe(
|
|
2008
|
+
tool,
|
|
2009
|
+
toolId,
|
|
2010
|
+
void 0,
|
|
2011
|
+
seedToolListScript
|
|
2012
|
+
),
|
|
1383
2013
|
...modelDescription ? { modelOptions: modelDescription } : {},
|
|
1384
|
-
...inferenceQuote ? { inferenceQuote } : {}
|
|
1385
|
-
});
|
|
1386
|
-
return 0;
|
|
1387
|
-
}
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
if (inferenceQuote) printInferenceQuoteSummary(inferenceQuote);
|
|
1410
|
-
return 0;
|
|
1411
|
-
}
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
function printInferenceQuoteSummary(quote) {
|
|
1429
|
-
for (const line of inferenceQuoteSummaryLines(quote)) console.log(line);
|
|
1430
|
-
}
|
|
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: _chunkKB4SDX5Sjs.playToolListGetterMode.call(void 0, authoringContractEdition) === "array" ? "Array" : "PlayDataset",
|
|
1453
|
-
rowsExpression: _chunkKB4SDX5Sjs.playToolListGetterMode.call(void 0, authoringContractEdition) === "array" ? entry.expression : `await ${entry.expression}.materialize()`
|
|
1454
|
-
}));
|
|
1455
|
-
const extractedValues = extractionContractEntries(
|
|
1456
|
-
arrayField2(toolExecutionResult, "extractedValues", "extracted_values")
|
|
1457
|
-
);
|
|
1458
|
-
const pricing = _chunkR4XZO6Z5js.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
|
-
};
|
|
2014
|
+
...inferenceQuote ? { inferenceQuote } : {}
|
|
2015
|
+
});
|
|
2016
|
+
return 0;
|
|
2017
|
+
}
|
|
2018
|
+
const emitJson = options.json === true;
|
|
2019
|
+
if (emitJson) {
|
|
2020
|
+
_chunkRTO5QZWTjs.printCompactJson.call(void 0, {
|
|
2021
|
+
...toolMetadataJsonForDescribe(tool, toolId, seedToolListScript),
|
|
2022
|
+
...modelDescription ? { modelOptions: modelDescription } : {},
|
|
2023
|
+
...inferenceQuote ? { inferenceQuote } : {}
|
|
2024
|
+
});
|
|
2025
|
+
return 0;
|
|
2026
|
+
}
|
|
2027
|
+
if (options.schemaOnly) {
|
|
2028
|
+
printToolSchemaOnly(tool, toolId);
|
|
2029
|
+
if (inferenceQuote) printInferenceQuoteSummary(inferenceQuote);
|
|
2030
|
+
return 0;
|
|
2031
|
+
}
|
|
2032
|
+
if (options.examplesOnly) {
|
|
2033
|
+
printToolExamplesOnly(tool, toolId);
|
|
2034
|
+
if (inferenceQuote) printInferenceQuoteSummary(inferenceQuote);
|
|
2035
|
+
return 0;
|
|
2036
|
+
}
|
|
2037
|
+
if (options.gettersOnly) {
|
|
2038
|
+
printToolGettersOnly(tool, toolId);
|
|
2039
|
+
if (inferenceQuote) printInferenceQuoteSummary(inferenceQuote);
|
|
2040
|
+
return 0;
|
|
2041
|
+
}
|
|
2042
|
+
if (options.compact) {
|
|
2043
|
+
printCompactToolContract(tool, toolId);
|
|
2044
|
+
if (modelDescription) {
|
|
2045
|
+
process.stdout.write(`
|
|
2046
|
+
${formatModelDescription(modelDescription)}`);
|
|
2047
|
+
}
|
|
2048
|
+
if (inferenceQuote) printInferenceQuoteSummary(inferenceQuote);
|
|
2049
|
+
return 0;
|
|
2050
|
+
}
|
|
2051
|
+
printCompactToolContract(tool, toolId);
|
|
2052
|
+
if (modelDescription) {
|
|
2053
|
+
process.stdout.write(`
|
|
2054
|
+
${formatModelDescription(modelDescription)}`);
|
|
2055
|
+
}
|
|
2056
|
+
if (inferenceQuote) printInferenceQuoteSummary(inferenceQuote);
|
|
2057
|
+
return 0;
|
|
1525
2058
|
}
|
|
1526
|
-
function
|
|
1527
|
-
return
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
2059
|
+
function inferenceQuoteSummaryLines(_quote) {
|
|
2060
|
+
return [
|
|
2061
|
+
"",
|
|
2062
|
+
"Inference quote:",
|
|
2063
|
+
"- Temporary hold: priced estimate (minimum 0.02 credits)",
|
|
2064
|
+
"- Final charge: actual usage"
|
|
2065
|
+
];
|
|
2066
|
+
}
|
|
2067
|
+
function printInferenceQuoteSummary(quote) {
|
|
2068
|
+
for (const line of inferenceQuoteSummaryLines(quote)) console.log(line);
|
|
1533
2069
|
}
|
|
1534
2070
|
function printMonitorTypeFilters(tool) {
|
|
1535
2071
|
const schema = recordField(tool, "payload_schema", "payloadSchema");
|
|
1536
2072
|
const properties = recordField(schema, "properties");
|
|
1537
2073
|
const required = new Set(
|
|
1538
|
-
|
|
2074
|
+
arrayField(schema, "required").filter(
|
|
1539
2075
|
(v) => typeof v === "string"
|
|
1540
2076
|
)
|
|
1541
2077
|
);
|
|
@@ -1548,11 +2084,11 @@ function printMonitorTypeFilters(tool) {
|
|
|
1548
2084
|
for (const name of names) {
|
|
1549
2085
|
const field = isRecord(properties[name]) ? properties[name] : {};
|
|
1550
2086
|
const star = required.has(name) ? "*" : "";
|
|
1551
|
-
const enumVals =
|
|
2087
|
+
const enumVals = arrayField(field, "enum").filter(
|
|
1552
2088
|
(v) => typeof v === "string"
|
|
1553
2089
|
);
|
|
1554
|
-
const type = enumVals.length ? `one of [${enumVals.join(", ")}]` :
|
|
1555
|
-
const desc =
|
|
2090
|
+
const type = enumVals.length ? `one of [${enumVals.join(", ")}]` : stringField(field, "type") || "string";
|
|
2091
|
+
const desc = stringField(field, "description");
|
|
1556
2092
|
console.log(`- ${name}${star}: ${type}${desc ? ` - ${desc}` : ""}`);
|
|
1557
2093
|
}
|
|
1558
2094
|
}
|
|
@@ -1561,9 +2097,9 @@ function printMonitorTypeFilterExamples(tool) {
|
|
|
1561
2097
|
const fields = recordField(documentation, "fields");
|
|
1562
2098
|
const examples = Object.entries(fields).flatMap(([name, rawField]) => {
|
|
1563
2099
|
const grammar = recordField(isRecord(rawField) ? rawField : {}, "grammar");
|
|
1564
|
-
const example =
|
|
2100
|
+
const example = stringField(grammar, "example");
|
|
1565
2101
|
const values = [
|
|
1566
|
-
...
|
|
2102
|
+
...arrayField(grammar, "examples").filter(
|
|
1567
2103
|
(value2) => typeof value2 === "string" && Boolean(value2)
|
|
1568
2104
|
),
|
|
1569
2105
|
...example ? [example] : []
|
|
@@ -1571,250 +2107,86 @@ function printMonitorTypeFilterExamples(tool) {
|
|
|
1571
2107
|
return [...new Set(values)].map((example2) => ({ name, example: example2 }));
|
|
1572
2108
|
});
|
|
1573
2109
|
if (examples.length === 0) return;
|
|
1574
|
-
console.log("");
|
|
1575
|
-
console.log("Filter examples:");
|
|
1576
|
-
for (const { name, example } of examples) {
|
|
1577
|
-
console.log(`- ${name}: ${example}`);
|
|
1578
|
-
}
|
|
1579
|
-
}
|
|
1580
|
-
function printMonitorTypeStreams(tool) {
|
|
1581
|
-
const streams =
|
|
1582
|
-
isRecord
|
|
1583
|
-
);
|
|
1584
|
-
if (!streams.length) return;
|
|
1585
|
-
console.log("");
|
|
1586
|
-
console.log("Filter columns (a play's sqlListeners.where, per stream):");
|
|
1587
|
-
for (const stream of streams) {
|
|
1588
|
-
const name =
|
|
1589
|
-
const cols =
|
|
1590
|
-
console.log(`- ${name}: ${cols.join(", ")}`);
|
|
1591
|
-
}
|
|
1592
|
-
}
|
|
1593
|
-
function monitorTypePricingLines(tool) {
|
|
1594
|
-
const pricing = recordField(tool, "pricing");
|
|
1595
|
-
const byType = recordField(
|
|
1596
|
-
pricing,
|
|
1597
|
-
"pricing_by_radar_type",
|
|
1598
|
-
"pricingByRadarType"
|
|
1599
|
-
);
|
|
1600
|
-
const keys = Object.keys(byType);
|
|
1601
|
-
if (!keys.length) {
|
|
1602
|
-
return ["Pricing: Deepline credits per accepted event"];
|
|
1603
|
-
}
|
|
1604
|
-
const lines = ["Pricing (Deepline credits per accepted event):"];
|
|
1605
|
-
for (const key of keys) {
|
|
1606
|
-
const entry = isRecord(byType[key]) ? byType[key] : {};
|
|
1607
|
-
const credits = numberField2(entry, "deepline_credits", "deeplineCredits");
|
|
1608
|
-
const display =
|
|
1609
|
-
const shown = display || (credits !== null ? `${formatDecimal(credits)} credits/event` : "not listed");
|
|
1610
|
-
lines.push(`- ${key}: ${shown}`);
|
|
1611
|
-
}
|
|
1612
|
-
return lines;
|
|
1613
|
-
}
|
|
1614
|
-
function printMonitorTypePricing(tool) {
|
|
1615
|
-
for (const line of monitorTypePricingLines(tool)) console.log(line);
|
|
1616
|
-
}
|
|
1617
|
-
function printMonitorTypeDeploy(tool) {
|
|
1618
|
-
const deploy = recordField(tool, "deploy");
|
|
1619
|
-
const toolId =
|
|
1620
|
-
const example =
|
|
1621
|
-
console.log("Deploy (a monitor type is deployed, not executed):");
|
|
1622
|
-
console.log(` ${example}`);
|
|
1623
|
-
}
|
|
1624
|
-
function printMonitorTypeContract(tool, requestedToolId) {
|
|
1625
|
-
const toolId =
|
|
1626
|
-
console.log(toolId);
|
|
1627
|
-
const displayName =
|
|
1628
|
-
if (displayName) console.log(`Best for: ${displayName}`);
|
|
1629
|
-
const description =
|
|
1630
|
-
if (description) console.log(`Description: ${description}`);
|
|
1631
|
-
const categories =
|
|
1632
|
-
(v) => typeof v === "string"
|
|
1633
|
-
);
|
|
1634
|
-
if (categories.length) console.log(`Tags: ${categories.join(", ")}`);
|
|
1635
|
-
console.log("");
|
|
1636
|
-
console.log(
|
|
1637
|
-
"Monitor type \u2014 streams a provider's events into your warehouse. Deploy it, don't execute it."
|
|
1638
|
-
);
|
|
1639
|
-
console.log("");
|
|
1640
|
-
printMonitorTypeFilters(tool);
|
|
1641
|
-
printMonitorTypeFilterExamples(tool);
|
|
1642
|
-
printMonitorTypeStreams(tool);
|
|
1643
|
-
console.log("");
|
|
1644
|
-
printMonitorTypePricing(tool);
|
|
1645
|
-
console.log("");
|
|
1646
|
-
printMonitorTypeDeploy(tool);
|
|
1647
|
-
console.log("");
|
|
1648
|
-
console.log(`More: deepline describe ${toolId}`);
|
|
1649
|
-
}
|
|
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: _chunkRDXFGPJUjs.EMAIL_STATUS_JSON_SCHEMA },
|
|
1662
|
-
job_change: { shape: "JobChange", schema: _chunkRDXFGPJUjs.JOB_CHANGE_JSON_SCHEMA }
|
|
1663
|
-
};
|
|
1664
|
-
function extractorValueType(name) {
|
|
1665
|
-
if (!_chunkRDXFGPJUjs.isDeeplineExtractorTarget.call(void 0, name)) return void 0;
|
|
1666
|
-
const definition = _chunkRDXFGPJUjs.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 } = _chunkZMVJSS6Njs.schemaField.call(void 0, 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: _chunkZMVJSS6Njs.schemaFields.call(void 0,
|
|
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
|
-
_nullishCoalesce(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 } = _chunkZMVJSS6Njs.schemaField.call(void 0, name, node, true);
|
|
1748
|
-
const valueType = stringField2(_nullishCoalesce(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(_nullishCoalesce(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
|
-
..._optionalChain([deepline, 'optionalAccess', _17 => _17.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 }) => _optionalChain([node, 'optionalAccess', _18 => _18.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 = _nullishCoalesce(lists.find(
|
|
1780
|
-
({ node }) => within.some((path) => isRecord(schemaNodeAt(_optionalChain([node, 'optionalAccess', _19 => _19.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
|
-
_chunkR4XZO6Z5js.observedMaxText.call(void 0, cost) && `\u2014 ${_chunkR4XZO6Z5js.observedMaxText.call(void 0, 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: _chunkZMVJSS6Njs.rateLimitSummary.call(void 0,
|
|
1806
|
-
recordField(contract, "executionMetadata").configuredRateLimits
|
|
1807
|
-
),
|
|
1808
|
-
inputs: _chunkZMVJSS6Njs.schemaFields.call(void 0, jsonSchemaOf(recordField(contract, "inputSchema"))),
|
|
1809
|
-
outputs: [...lists, ...values].map(({ field }) => field),
|
|
1810
|
-
rawResponse: _chunkZMVJSS6Njs.schemaFields.call(void 0, outputSchema),
|
|
1811
|
-
runner: playReference ? { via: "play", reference: playReference } : { via: "tool", toolId: String(contract.toolId) }
|
|
1812
|
-
};
|
|
2110
|
+
console.log("");
|
|
2111
|
+
console.log("Filter examples:");
|
|
2112
|
+
for (const { name, example } of examples) {
|
|
2113
|
+
console.log(`- ${name}: ${example}`);
|
|
2114
|
+
}
|
|
2115
|
+
}
|
|
2116
|
+
function printMonitorTypeStreams(tool) {
|
|
2117
|
+
const streams = arrayField(tool, "streams", "output_streams").filter(
|
|
2118
|
+
isRecord
|
|
2119
|
+
);
|
|
2120
|
+
if (!streams.length) return;
|
|
2121
|
+
console.log("");
|
|
2122
|
+
console.log("Filter columns (a play's sqlListeners.where, per stream):");
|
|
2123
|
+
for (const stream of streams) {
|
|
2124
|
+
const name = stringField(stream, "stream");
|
|
2125
|
+
const cols = arrayField(stream, "columns").filter(isRecord).map((col) => stringField(col, "name")).filter(Boolean);
|
|
2126
|
+
console.log(`- ${name}: ${cols.join(", ")}`);
|
|
2127
|
+
}
|
|
2128
|
+
}
|
|
2129
|
+
function monitorTypePricingLines(tool) {
|
|
2130
|
+
const pricing = recordField(tool, "pricing");
|
|
2131
|
+
const byType = recordField(
|
|
2132
|
+
pricing,
|
|
2133
|
+
"pricing_by_radar_type",
|
|
2134
|
+
"pricingByRadarType"
|
|
2135
|
+
);
|
|
2136
|
+
const keys = Object.keys(byType);
|
|
2137
|
+
if (!keys.length) {
|
|
2138
|
+
return ["Pricing: Deepline credits per accepted event"];
|
|
2139
|
+
}
|
|
2140
|
+
const lines = ["Pricing (Deepline credits per accepted event):"];
|
|
2141
|
+
for (const key of keys) {
|
|
2142
|
+
const entry = isRecord(byType[key]) ? byType[key] : {};
|
|
2143
|
+
const credits = numberField2(entry, "deepline_credits", "deeplineCredits");
|
|
2144
|
+
const display = stringField(entry, "display");
|
|
2145
|
+
const shown = display || (credits !== null ? `${formatDecimal(credits)} credits/event` : "not listed");
|
|
2146
|
+
lines.push(`- ${key}: ${shown}`);
|
|
2147
|
+
}
|
|
2148
|
+
return lines;
|
|
2149
|
+
}
|
|
2150
|
+
function printMonitorTypePricing(tool) {
|
|
2151
|
+
for (const line of monitorTypePricingLines(tool)) console.log(line);
|
|
2152
|
+
}
|
|
2153
|
+
function printMonitorTypeDeploy(tool) {
|
|
2154
|
+
const deploy = recordField(tool, "deploy");
|
|
2155
|
+
const toolId = stringField(tool, "toolId");
|
|
2156
|
+
const example = stringField(deploy, "example") || `deepline monitors deploy '{"key":"...","tool":"${toolId}","payload":{...}}'`;
|
|
2157
|
+
console.log("Deploy (a monitor type is deployed, not executed):");
|
|
2158
|
+
console.log(` ${example}`);
|
|
2159
|
+
}
|
|
2160
|
+
function printMonitorTypeContract(tool, requestedToolId) {
|
|
2161
|
+
const toolId = stringField(tool, "toolId") || requestedToolId;
|
|
2162
|
+
console.log(toolId);
|
|
2163
|
+
const displayName = stringField(tool, "displayName");
|
|
2164
|
+
if (displayName) console.log(`Best for: ${displayName}`);
|
|
2165
|
+
const description = stringField(tool, "description");
|
|
2166
|
+
if (description) console.log(`Description: ${description}`);
|
|
2167
|
+
const categories = arrayField(tool, "categories").filter(
|
|
2168
|
+
(v) => typeof v === "string"
|
|
2169
|
+
);
|
|
2170
|
+
if (categories.length) console.log(`Tags: ${categories.join(", ")}`);
|
|
2171
|
+
console.log("");
|
|
2172
|
+
console.log(
|
|
2173
|
+
"Monitor type \u2014 streams a provider's events into your warehouse. Deploy it, don't execute it."
|
|
2174
|
+
);
|
|
2175
|
+
console.log("");
|
|
2176
|
+
printMonitorTypeFilters(tool);
|
|
2177
|
+
printMonitorTypeFilterExamples(tool);
|
|
2178
|
+
printMonitorTypeStreams(tool);
|
|
2179
|
+
console.log("");
|
|
2180
|
+
printMonitorTypePricing(tool);
|
|
2181
|
+
console.log("");
|
|
2182
|
+
printMonitorTypeDeploy(tool);
|
|
2183
|
+
console.log("");
|
|
2184
|
+
console.log(`More: deepline describe ${toolId}`);
|
|
1813
2185
|
}
|
|
1814
2186
|
function toolGuidanceLines(guidance) {
|
|
1815
2187
|
const record = isRecord(guidance) ? guidance : {};
|
|
1816
|
-
const toolGuidance =
|
|
1817
|
-
const providerGuidance =
|
|
2188
|
+
const toolGuidance = stringField(record, "tool");
|
|
2189
|
+
const providerGuidance = stringField(record, "provider");
|
|
1818
2190
|
return [
|
|
1819
2191
|
...toolGuidance ? [`- This tool: ${toolGuidance}`] : [],
|
|
1820
2192
|
...providerGuidance ? [`- Provider: ${providerGuidance}`] : []
|
|
@@ -1825,7 +2197,12 @@ function printCompactToolContract(tool, requestedToolId) {
|
|
|
1825
2197
|
printMonitorTypeContract(tool, requestedToolId);
|
|
1826
2198
|
return;
|
|
1827
2199
|
}
|
|
1828
|
-
const contract = toolContractJsonForDescribe(
|
|
2200
|
+
const contract = toolContractJsonForDescribe(
|
|
2201
|
+
tool,
|
|
2202
|
+
requestedToolId,
|
|
2203
|
+
void 0,
|
|
2204
|
+
seedToolListScript
|
|
2205
|
+
);
|
|
1829
2206
|
const cost = isRecord(contract.cost) ? contract.cost : {};
|
|
1830
2207
|
const getters = isRecord(contract.getters) ? contract.getters : {};
|
|
1831
2208
|
const listGetters = Array.isArray(getters.extractedLists) ? getters.extractedLists : [];
|
|
@@ -1849,8 +2226,8 @@ function printCompactToolContract(tool, requestedToolId) {
|
|
|
1849
2226
|
printToolExecutionHints(contract);
|
|
1850
2227
|
if (contract.deprecated === true) {
|
|
1851
2228
|
const deprecation = isRecord(contract.deprecation) ? contract.deprecation : {};
|
|
1852
|
-
const message =
|
|
1853
|
-
const replacementToolId =
|
|
2229
|
+
const message = stringField(deprecation, "message");
|
|
2230
|
+
const replacementToolId = stringField(
|
|
1854
2231
|
deprecation,
|
|
1855
2232
|
"replacementToolId",
|
|
1856
2233
|
"replacement_tool_id"
|
|
@@ -1876,11 +2253,11 @@ function printCompactToolContract(tool, requestedToolId) {
|
|
|
1876
2253
|
console.log("Inputs:");
|
|
1877
2254
|
for (const field of inputFields) {
|
|
1878
2255
|
if (!isRecord(field)) continue;
|
|
1879
|
-
const name =
|
|
2256
|
+
const name = stringField(field, "name");
|
|
1880
2257
|
if (!name) continue;
|
|
1881
2258
|
const required = field.required ? "*" : "";
|
|
1882
|
-
const type =
|
|
1883
|
-
const description =
|
|
2259
|
+
const type = stringField(field, "type") || "unknown";
|
|
2260
|
+
const description = stringField(field, "description");
|
|
1884
2261
|
const enumValues = Array.isArray(field.enum) ? field.enum : [];
|
|
1885
2262
|
const enumSuffix = enumValues.length ? ` enum=${enumValues.map(String).join("|")}` : "";
|
|
1886
2263
|
const itemBoundsSuffix = arrayItemBoundsSuffix(field);
|
|
@@ -1896,7 +2273,7 @@ function printCompactToolContract(tool, requestedToolId) {
|
|
|
1896
2273
|
console.log("");
|
|
1897
2274
|
printToolExamplesOnly(tool, requestedToolId);
|
|
1898
2275
|
const starterScript = isRecord(contract.starterScript) ? contract.starterScript : {};
|
|
1899
|
-
const starterPath =
|
|
2276
|
+
const starterPath = stringField(starterScript, "path");
|
|
1900
2277
|
if (starterPath) {
|
|
1901
2278
|
console.log("");
|
|
1902
2279
|
console.log(`Starter script: ${starterPath}`);
|
|
@@ -1909,14 +2286,14 @@ function printCompactToolContract(tool, requestedToolId) {
|
|
|
1909
2286
|
for (const entry of listGetters) {
|
|
1910
2287
|
if (isRecord(entry))
|
|
1911
2288
|
console.log(
|
|
1912
|
-
`- ${
|
|
2289
|
+
`- ${stringField(entry, "name")}: ${playResultExpression(entry)}`
|
|
1913
2290
|
);
|
|
1914
2291
|
}
|
|
1915
2292
|
if (valueGetters.length) console.log("Values:");
|
|
1916
2293
|
for (const entry of valueGetters) {
|
|
1917
2294
|
if (isRecord(entry))
|
|
1918
2295
|
console.log(
|
|
1919
|
-
`- ${
|
|
2296
|
+
`- ${stringField(entry, "name")}: ${playResultExpression(entry)}`
|
|
1920
2297
|
);
|
|
1921
2298
|
}
|
|
1922
2299
|
}
|
|
@@ -1931,19 +2308,19 @@ function toolPricingOnlyLines(tool, requestedToolId, options = {}) {
|
|
|
1931
2308
|
return monitorTypePricingLines(tool);
|
|
1932
2309
|
}
|
|
1933
2310
|
const toolId = String(tool.toolId || requestedToolId);
|
|
1934
|
-
const cost =
|
|
1935
|
-
const pricingModel =
|
|
1936
|
-
const billing =
|
|
1937
|
-
const explicitUnit =
|
|
2311
|
+
const cost = _chunkKAEZNPUMjs.Capability.fromCatalogEntry(tool).describe().customerCost();
|
|
2312
|
+
const pricingModel = stringField(cost, "pricingModel") || "unknown";
|
|
2313
|
+
const billing = stringField(cost, "billingSourceLabel") || stringField(cost, "billingSource") || stringField(cost, "billingMode") || "unknown";
|
|
2314
|
+
const explicitUnit = stringField(cost, "unit");
|
|
1938
2315
|
const unit = explicitUnit || (pricingModel === "per_page" ? "page" : pricingModel === "per_result" ? "result" : pricingModel === "fixed" ? "call" : pricingModel.replace(/^per_/, "") || "unit");
|
|
1939
2316
|
const credits = numberField2(cost, "deeplineCreditsPerPricingUnit");
|
|
1940
2317
|
const usd = numberField2(cost, "deeplineUsdPerPricingUnit");
|
|
1941
|
-
const displayText =
|
|
1942
|
-
const summary =
|
|
2318
|
+
const displayText = stringField(cost, "displayText");
|
|
2319
|
+
const summary = stringField(cost, "summary");
|
|
1943
2320
|
const price = displayText || summary || (credits !== null ? `${formatDecimal(credits)} Deepline credits${usd !== null ? ` / ${formatUsd(usd)}` : ""} per ${unit}` : "pricing unavailable");
|
|
1944
2321
|
return [
|
|
1945
2322
|
`${_nullishCoalesce(options.heading, () => ( `Pricing: ${toolId}`))}: ${price}`,
|
|
1946
|
-
...
|
|
2323
|
+
..._chunkKAEZNPUMjs.observedMaxText.call(void 0, cost) ? [` ${_chunkKAEZNPUMjs.observedMaxText.call(void 0, cost)}`] : [],
|
|
1947
2324
|
...cost.observedReference || cost.estimatedRange ? [
|
|
1948
2325
|
...summary ? [` ${summary}`] : [],
|
|
1949
2326
|
...(_nullishCoalesce(cost.details, () => ( []))).map((detail) => ` ${detail}`)
|
|
@@ -1961,7 +2338,12 @@ function printToolSchemaOnly(tool, requestedToolId) {
|
|
|
1961
2338
|
printMonitorTypeStreams(tool);
|
|
1962
2339
|
return;
|
|
1963
2340
|
}
|
|
1964
|
-
const contract = toolContractJsonForDescribe(
|
|
2341
|
+
const contract = toolContractJsonForDescribe(
|
|
2342
|
+
tool,
|
|
2343
|
+
requestedToolId,
|
|
2344
|
+
void 0,
|
|
2345
|
+
seedToolListScript
|
|
2346
|
+
);
|
|
1965
2347
|
const inputFields = recursiveToolInputFieldsForDisplay(
|
|
1966
2348
|
recordField(contract, "inputSchema")
|
|
1967
2349
|
);
|
|
@@ -2010,10 +2392,15 @@ function printToolExamplesOnly(tool, requestedToolId) {
|
|
|
2010
2392
|
printPlayLikeToolUsage(tool, requestedToolId);
|
|
2011
2393
|
return;
|
|
2012
2394
|
}
|
|
2013
|
-
const contract = toolContractJsonForDescribe(
|
|
2395
|
+
const contract = toolContractJsonForDescribe(
|
|
2396
|
+
tool,
|
|
2397
|
+
requestedToolId,
|
|
2398
|
+
void 0,
|
|
2399
|
+
seedToolListScript
|
|
2400
|
+
);
|
|
2014
2401
|
const toolId = String(contract.toolId);
|
|
2015
2402
|
const inputFields = Array.isArray(contract.inputFields) ? contract.inputFields : [];
|
|
2016
|
-
const examples =
|
|
2403
|
+
const examples = arrayField(tool, "examples").filter(isRecord);
|
|
2017
2404
|
const firstExample = examples[0];
|
|
2018
2405
|
const sampleInput = firstExample && isRecord(firstExample.input) ? firstExample.input : _nullishCoalesce(samplePayload(recordField(tool, "samples"), "request"), () => ( samplePayloadForInputFields(inputFields)));
|
|
2019
2406
|
console.log("Example input payload:");
|
|
@@ -2034,8 +2421,8 @@ function printToolExamplesOnly(tool, requestedToolId) {
|
|
|
2034
2421
|
const listGetters = Array.isArray(getters.extractedLists) ? getters.extractedLists : [];
|
|
2035
2422
|
const firstGetter = valueGetters.find(isRecord);
|
|
2036
2423
|
if (firstGetter) {
|
|
2037
|
-
const name =
|
|
2038
|
-
const expression =
|
|
2424
|
+
const name = stringField(firstGetter, "name") || "value";
|
|
2425
|
+
const expression = stringField(firstGetter, "expression");
|
|
2039
2426
|
if (expression)
|
|
2040
2427
|
console.log(
|
|
2041
2428
|
`const ${safeIdentifier(name)} = ${expression.replace(/^toolExecutionResult\./, "result.")};`
|
|
@@ -2047,10 +2434,10 @@ function printToolExamplesOnly(tool, requestedToolId) {
|
|
|
2047
2434
|
).filter((field) => String(field.type).split("|").includes("array")).map((field) => String(field.name).split(".").at(-1))
|
|
2048
2435
|
);
|
|
2049
2436
|
const firstList = _nullishCoalesce(listGetters.find(
|
|
2050
|
-
(entry) => isRecord(entry) && arrayNames.has(
|
|
2437
|
+
(entry) => isRecord(entry) && arrayNames.has(stringField(entry, "name"))
|
|
2051
2438
|
), () => ( listGetters.find(isRecord)));
|
|
2052
2439
|
if (isRecord(firstList)) {
|
|
2053
|
-
const name = safeIdentifier(
|
|
2440
|
+
const name = safeIdentifier(stringField(firstList, "name") || "list");
|
|
2054
2441
|
if (_chunkKB4SDX5Sjs.playToolListGetterMode.call(void 0, ) === "array") {
|
|
2055
2442
|
console.log(`const ${name}_rows = ${playResultExpression(firstList)};`);
|
|
2056
2443
|
} else {
|
|
@@ -2064,7 +2451,7 @@ function printToolExamplesOnly(tool, requestedToolId) {
|
|
|
2064
2451
|
console.log("```");
|
|
2065
2452
|
if (firstList) printListGetterConsumption();
|
|
2066
2453
|
for (const example of examples) {
|
|
2067
|
-
const description =
|
|
2454
|
+
const description = stringField(example, "description");
|
|
2068
2455
|
if (description) console.log(description);
|
|
2069
2456
|
console.log("Example Deepline execution response:");
|
|
2070
2457
|
console.log(JSON.stringify(example.response, null, 2));
|
|
@@ -2097,201 +2484,60 @@ function printPlayLikeToolUsage(tool, requestedToolId) {
|
|
|
2097
2484
|
}
|
|
2098
2485
|
}
|
|
2099
2486
|
function printToolGettersOnly(tool, requestedToolId) {
|
|
2100
|
-
const contract = toolContractJsonForDescribe(
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
if (!listGetters.length && !valueGetters.length) {
|
|
2106
|
-
console.log("No generated getters declared.");
|
|
2107
|
-
return;
|
|
2108
|
-
}
|
|
2109
|
-
if (listGetters.length) {
|
|
2110
|
-
console.log(listGetterHeading());
|
|
2111
|
-
for (const entry of listGetters) {
|
|
2112
|
-
if (isRecord(entry))
|
|
2113
|
-
console.log(
|
|
2114
|
-
`- ${stringField2(entry, "name")}: ${playResultExpression(entry)}`
|
|
2115
|
-
);
|
|
2116
|
-
}
|
|
2117
|
-
printListGetterConsumption();
|
|
2118
|
-
}
|
|
2119
|
-
if (valueGetters.length) {
|
|
2120
|
-
console.log("Values:");
|
|
2121
|
-
for (const entry of valueGetters) {
|
|
2122
|
-
if (isRecord(entry))
|
|
2123
|
-
console.log(
|
|
2124
|
-
`- ${stringField2(entry, "name")}: ${playResultExpression(entry)}`
|
|
2125
|
-
);
|
|
2126
|
-
}
|
|
2127
|
-
}
|
|
2128
|
-
}
|
|
2129
|
-
function printListGetterConsumption() {
|
|
2130
|
-
if (_chunkKB4SDX5Sjs.playToolListGetterMode.call(void 0, ) === "array") {
|
|
2131
|
-
console.log(
|
|
2132
|
-
"Use the ordinary array directly, or pass it to ctx.dataset to persist row work. No provider pagination is fetched. Lazy or incomplete lists throw; use readList for an explicit dataset read. A missing getter is not an empty list."
|
|
2133
|
-
);
|
|
2134
|
-
return;
|
|
2135
|
-
}
|
|
2136
|
-
console.log(
|
|
2137
|
-
"Pass the handle to ctx.dataset, use first() for one row, or for await...of to stream rows. materialize() loads the complete current list within the memory cap; materialize(n) and peek(n) return only a prefix. None fetch additional provider pagination. A missing getter is not an empty list."
|
|
2138
|
-
);
|
|
2139
|
-
}
|
|
2140
|
-
function listGetterHeading() {
|
|
2141
|
-
return _chunkKB4SDX5Sjs.playToolListGetterMode.call(void 0, ) === "array" ? "Lists (ordinary JavaScript arrays):" : "Lists (PlayDataset, not a JavaScript array):";
|
|
2142
|
-
}
|
|
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
|
-
function stableStepIdForTool(toolId) {
|
|
2170
|
-
return toolId.replace(/^[a-z0-9]+_/, "").replace(/[^a-z0-9_]+/gi, "_") || "tool_call";
|
|
2171
|
-
}
|
|
2172
|
-
function safeIdentifier(name) {
|
|
2173
|
-
const cleaned = name.replace(/[^a-zA-Z0-9_$]+/g, "_").replace(/^[^a-zA-Z_$]+/, "");
|
|
2174
|
-
return cleaned || "value";
|
|
2175
|
-
}
|
|
2176
|
-
function playResultExpression(entry) {
|
|
2177
|
-
return stringField2(entry, "expression").replace(
|
|
2178
|
-
/^toolExecutionResult\./,
|
|
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")
|
|
2487
|
+
const contract = toolContractJsonForDescribe(
|
|
2488
|
+
tool,
|
|
2489
|
+
requestedToolId,
|
|
2490
|
+
void 0,
|
|
2491
|
+
seedToolListScript
|
|
2197
2492
|
);
|
|
2198
|
-
const
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
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: _chunkR4XZO6Z5js.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: _chunkKB4SDX5Sjs.playToolListGetterMode.call(void 0, ) === "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."
|
|
2493
|
+
const getters = isRecord(contract.getters) ? contract.getters : {};
|
|
2494
|
+
const listGetters = Array.isArray(getters.extractedLists) ? getters.extractedLists : [];
|
|
2495
|
+
const valueGetters = Array.isArray(getters.extractedValues) ? getters.extractedValues : [];
|
|
2496
|
+
console.log(`Getters: ${contract.toolId}`);
|
|
2497
|
+
if (!listGetters.length && !valueGetters.length) {
|
|
2498
|
+
console.log("No generated getters declared.");
|
|
2499
|
+
return;
|
|
2500
|
+
}
|
|
2501
|
+
if (listGetters.length) {
|
|
2502
|
+
console.log(listGetterHeading());
|
|
2503
|
+
for (const entry of listGetters) {
|
|
2504
|
+
if (isRecord(entry))
|
|
2505
|
+
console.log(
|
|
2506
|
+
`- ${stringField(entry, "name")}: ${playResultExpression(entry)}`
|
|
2507
|
+
);
|
|
2293
2508
|
}
|
|
2294
|
-
|
|
2509
|
+
printListGetterConsumption();
|
|
2510
|
+
}
|
|
2511
|
+
if (valueGetters.length) {
|
|
2512
|
+
console.log("Values:");
|
|
2513
|
+
for (const entry of valueGetters) {
|
|
2514
|
+
if (isRecord(entry))
|
|
2515
|
+
console.log(
|
|
2516
|
+
`- ${stringField(entry, "name")}: ${playResultExpression(entry)}`
|
|
2517
|
+
);
|
|
2518
|
+
}
|
|
2519
|
+
}
|
|
2520
|
+
}
|
|
2521
|
+
function printListGetterConsumption() {
|
|
2522
|
+
if (_chunkKB4SDX5Sjs.playToolListGetterMode.call(void 0, ) === "array") {
|
|
2523
|
+
console.log(
|
|
2524
|
+
"Use the ordinary array directly, or pass it to ctx.dataset to persist row work. No provider pagination is fetched. Lazy or incomplete lists throw; use readList for an explicit dataset read. A missing getter is not an empty list."
|
|
2525
|
+
);
|
|
2526
|
+
return;
|
|
2527
|
+
}
|
|
2528
|
+
console.log(
|
|
2529
|
+
"Pass the handle to ctx.dataset, use first() for one row, or for await...of to stream rows. materialize() loads the complete current list within the memory cap; materialize(n) and peek(n) return only a prefix. None fetch additional provider pagination. A missing getter is not an empty list."
|
|
2530
|
+
);
|
|
2531
|
+
}
|
|
2532
|
+
function listGetterHeading() {
|
|
2533
|
+
return _chunkKB4SDX5Sjs.playToolListGetterMode.call(void 0, ) === "array" ? "Lists (ordinary JavaScript arrays):" : "Lists (PlayDataset, not a JavaScript array):";
|
|
2534
|
+
}
|
|
2535
|
+
function stableStepIdForTool(toolId) {
|
|
2536
|
+
return toolId.replace(/^[a-z0-9]+_/, "").replace(/[^a-z0-9_]+/gi, "_") || "tool_call";
|
|
2537
|
+
}
|
|
2538
|
+
function safeIdentifier(name) {
|
|
2539
|
+
const cleaned = name.replace(/[^a-zA-Z0-9_$]+/g, "_").replace(/^[^a-zA-Z_$]+/, "");
|
|
2540
|
+
return cleaned || "value";
|
|
2295
2541
|
}
|
|
2296
2542
|
function singleLineText(value2, maxLength = 260) {
|
|
2297
2543
|
if (typeof value2 !== "string") return "";
|
|
@@ -2305,62 +2551,13 @@ function listedToolDescription(tool) {
|
|
|
2305
2551
|
}
|
|
2306
2552
|
function formatListedToolCost(tool) {
|
|
2307
2553
|
const record = tool;
|
|
2308
|
-
if (
|
|
2554
|
+
if (stringField(record, "billingSource", "billing_source") === "free") {
|
|
2309
2555
|
return "Cost: Free";
|
|
2310
2556
|
}
|
|
2311
2557
|
const pricing = recordField(record, "pricing");
|
|
2312
|
-
const displayText =
|
|
2558
|
+
const displayText = stringField(pricing, "displayText", "display_text");
|
|
2313
2559
|
return displayText ? `Cost: ${displayText}` : "";
|
|
2314
2560
|
}
|
|
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 : _optionalChain([jsonSchemaField, 'optionalAccess', _20 => _20.minItems]);
|
|
2329
|
-
const maxItems = typeof field.maxItems === "number" ? field.maxItems : _optionalChain([jsonSchemaField, 'optionalAccess', _21 => _21.maxItems]);
|
|
2330
|
-
const items = isRecord(field.items) ? field.items : _optionalChain([jsonSchemaField, 'optionalAccess', _22 => _22.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
2561
|
function printToolOutputArrayShape(tool) {
|
|
2365
2562
|
const outputFields = toolOutputFieldsForDisplay(
|
|
2366
2563
|
recordField(isRecord(tool) ? tool : {}, "outputSchema", "output_schema")
|
|
@@ -2369,7 +2566,7 @@ function printToolOutputArrayShape(tool) {
|
|
|
2369
2566
|
console.log(" Output array shape (declared schema):");
|
|
2370
2567
|
for (const field of outputFields.slice(0, 60)) {
|
|
2371
2568
|
const name = String(field.name);
|
|
2372
|
-
const type =
|
|
2569
|
+
const type = stringField(field, "type") || "unknown";
|
|
2373
2570
|
const itemBounds = arrayItemBoundsSuffix(field);
|
|
2374
2571
|
console.log(` - ${name}: ${type}${itemBounds}`);
|
|
2375
2572
|
}
|
|
@@ -2377,142 +2574,12 @@ function printToolOutputArrayShape(tool) {
|
|
|
2377
2574
|
console.log(` - \u2026 ${outputFields.length - 60} more schema fields`);
|
|
2378
2575
|
}
|
|
2379
2576
|
}
|
|
2380
|
-
function canonicalToolJsonSchema(inputSchema) {
|
|
2381
|
-
return isRecord(inputSchema.jsonSchema) ? inputSchema.jsonSchema : inputSchema;
|
|
2382
|
-
}
|
|
2383
2577
|
function declaredToolJsonSchema(inputSchema) {
|
|
2384
2578
|
if (isRecord(inputSchema.jsonSchema)) {
|
|
2385
2579
|
return inputSchema.jsonSchema;
|
|
2386
2580
|
}
|
|
2387
2581
|
return Array.isArray(inputSchema.fields) ? null : inputSchema;
|
|
2388
2582
|
}
|
|
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 _nullishCoalesce(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: _nullishCoalesce(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
2583
|
function arrayItemBoundsSuffix(field) {
|
|
2517
2584
|
const itemSchema = isRecord(field.items) ? field.items : null;
|
|
2518
2585
|
const itemType = itemSchema ? typeof itemSchema.type === "string" ? itemSchema.type : isRecord(itemSchema.properties) ? "object" : "unknown" : null;
|
|
@@ -2540,9 +2607,9 @@ function printToolExecutionHints(value2) {
|
|
|
2540
2607
|
"execution_metadata"
|
|
2541
2608
|
);
|
|
2542
2609
|
if (batchCapability) {
|
|
2543
|
-
const status =
|
|
2544
|
-
const surface =
|
|
2545
|
-
const operation =
|
|
2610
|
+
const status = stringField(batchCapability, "status") || "unknown";
|
|
2611
|
+
const surface = stringField(batchCapability, "surface");
|
|
2612
|
+
const operation = stringField(
|
|
2546
2613
|
batchCapability,
|
|
2547
2614
|
"batchOperation",
|
|
2548
2615
|
"batch_operation"
|
|
@@ -2552,7 +2619,7 @@ function printToolExecutionHints(value2) {
|
|
|
2552
2619
|
"maxBatchSize",
|
|
2553
2620
|
"max_batch_size"
|
|
2554
2621
|
);
|
|
2555
|
-
const notes =
|
|
2622
|
+
const notes = stringField(batchCapability, "notes");
|
|
2556
2623
|
console.log("");
|
|
2557
2624
|
console.log("Batching:");
|
|
2558
2625
|
console.log(`- Catalog status: ${status}${surface ? ` (${surface})` : ""}`);
|
|
@@ -2571,7 +2638,7 @@ function printToolExecutionHints(value2) {
|
|
|
2571
2638
|
}
|
|
2572
2639
|
if (notes) console.log(`- Details: ${notes}`);
|
|
2573
2640
|
}
|
|
2574
|
-
const configuredRateLimits =
|
|
2641
|
+
const configuredRateLimits = arrayField(
|
|
2575
2642
|
executionMetadata,
|
|
2576
2643
|
"configuredRateLimits",
|
|
2577
2644
|
"configured_rate_limits"
|
|
@@ -2585,7 +2652,7 @@ function printToolExecutionHints(value2) {
|
|
|
2585
2652
|
const requests = numberField2(limit, "requestsPerWindow");
|
|
2586
2653
|
const windowMs = numberField2(limit, "windowMs");
|
|
2587
2654
|
if (requests === null || windowMs === null) continue;
|
|
2588
|
-
const usage =
|
|
2655
|
+
const usage = stringField(limit, "usage") || "unknown";
|
|
2589
2656
|
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
2657
|
const explicitMaxConcurrency = numberField2(
|
|
2591
2658
|
limit,
|
|
@@ -2651,7 +2718,7 @@ function extractToolExecutionWarningMessages(rawResponse) {
|
|
|
2651
2718
|
if (typeof warning === "string" && warning.trim()) {
|
|
2652
2719
|
messages.push(warning.trim());
|
|
2653
2720
|
} else if (isRecord(warning)) {
|
|
2654
|
-
const message =
|
|
2721
|
+
const message = stringField(warning, "message");
|
|
2655
2722
|
if (message) messages.push(message);
|
|
2656
2723
|
}
|
|
2657
2724
|
}
|
|
@@ -2665,13 +2732,13 @@ function apifySyncRecoveryNext(rawResponse) {
|
|
|
2665
2732
|
if (raw.state !== "awaiting_apify") return null;
|
|
2666
2733
|
const next = recordField(raw, "next");
|
|
2667
2734
|
const getActorRun = recordField(next, "getActorRun");
|
|
2668
|
-
const getActorRunTool =
|
|
2735
|
+
const getActorRunTool = stringField(getActorRun, "tool");
|
|
2669
2736
|
const getActorRunPayload = recordField(getActorRun, "payload");
|
|
2670
2737
|
if (!getActorRunTool || Object.keys(getActorRunPayload).length === 0) {
|
|
2671
2738
|
return null;
|
|
2672
2739
|
}
|
|
2673
2740
|
const getDatasetItems = recordField(next, "getDatasetItems");
|
|
2674
|
-
const getDatasetItemsTool =
|
|
2741
|
+
const getDatasetItemsTool = stringField(getDatasetItems, "tool");
|
|
2675
2742
|
const getDatasetItemsPayload = recordField(getDatasetItems, "payload");
|
|
2676
2743
|
return {
|
|
2677
2744
|
getActorRun: `deepline tools execute ${getActorRunTool} --input ${_chunkAID3OYVJjs.shellQuote.call(void 0, JSON.stringify(getActorRunPayload))}`,
|
|
@@ -2698,16 +2765,6 @@ function formatDecimal(value2) {
|
|
|
2698
2765
|
function formatUsd(value2) {
|
|
2699
2766
|
return `$${formatDecimal(value2)}`;
|
|
2700
2767
|
}
|
|
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 "";
|
|
2710
|
-
}
|
|
2711
2768
|
function numberField2(source, ...keys) {
|
|
2712
2769
|
for (const key of keys) {
|
|
2713
2770
|
const value2 = source[key];
|
|
@@ -2715,20 +2772,6 @@ function numberField2(source, ...keys) {
|
|
|
2715
2772
|
}
|
|
2716
2773
|
return null;
|
|
2717
2774
|
}
|
|
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
2775
|
function normalizeOutputFormat(raw) {
|
|
2733
2776
|
switch ((raw || "auto").trim().toLowerCase()) {
|
|
2734
2777
|
case "auto":
|
|
@@ -2835,7 +2878,7 @@ function parseExecuteOptions(toolId, options, output) {
|
|
|
2835
2878
|
outputFormat = normalizeOutputFormat(options.outputFormat);
|
|
2836
2879
|
}
|
|
2837
2880
|
if (options.idempotencyKey !== void 0) {
|
|
2838
|
-
|
|
2881
|
+
_chunkWQJJNIMQjs.validateExecutionIdempotencyKey.call(void 0, options.idempotencyKey);
|
|
2839
2882
|
}
|
|
2840
2883
|
if (options.recoveryTimeoutMs !== void 0) {
|
|
2841
2884
|
const parsed = Number(options.recoveryTimeoutMs);
|
|
@@ -2880,17 +2923,6 @@ function safeFileStem(value2) {
|
|
|
2880
2923
|
function powerShellQuote(value2) {
|
|
2881
2924
|
return `'${value2.replace(/'/g, "''")}'`;
|
|
2882
2925
|
}
|
|
2883
|
-
function starterScriptJson(script) {
|
|
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
|
-
};
|
|
2893
|
-
}
|
|
2894
2926
|
function seedToolListScript(input) {
|
|
2895
2927
|
const stem = safeFileStem(input.toolId);
|
|
2896
2928
|
const fileName = `${stem}-workflow-seed-${Date.now()}.play.ts`;
|
|
@@ -3146,20 +3178,20 @@ function buildToolExecuteRowArtifactEnvelope(input) {
|
|
|
3146
3178
|
}
|
|
3147
3179
|
async function executeTool(toolId, options) {
|
|
3148
3180
|
const output = toolExecuteJsonOption(options.json);
|
|
3149
|
-
const wantsJson =
|
|
3181
|
+
const wantsJson = _chunkRTO5QZWTjs.shouldEmitJson.call(void 0, output.requested) || (_nullishCoalesce(options.outputFormat, () => ( "auto"))).trim().toLowerCase() !== "csv";
|
|
3150
3182
|
let parsed;
|
|
3151
3183
|
try {
|
|
3152
3184
|
parsed = parseExecuteOptions(toolId, options, output);
|
|
3153
3185
|
} catch (error) {
|
|
3154
3186
|
if (wantsJson) {
|
|
3155
|
-
|
|
3187
|
+
_chunkRTO5QZWTjs.printJsonError.call(void 0, error);
|
|
3156
3188
|
} else {
|
|
3157
3189
|
console.error(error instanceof Error ? error.message : String(error));
|
|
3158
3190
|
}
|
|
3159
3191
|
return error instanceof _chunk7P5AA3SNjs.DeeplineError && error.code === "IDEMPOTENCY_KEY_INVALID" ? 2 : 1;
|
|
3160
3192
|
}
|
|
3161
3193
|
const cliInvocationId = _nullishCoalesce(_chunkQJBJZVG6js.getToolExecuteInvocationId.call(void 0, ), () => ( _chunkQJBJZVG6js.beginToolExecuteCommand.call(void 0, )));
|
|
3162
|
-
const client = new (0,
|
|
3194
|
+
const client = new (0, _chunkWQJJNIMQjs.DeeplineClient)();
|
|
3163
3195
|
let metadata;
|
|
3164
3196
|
try {
|
|
3165
3197
|
metadata = await _chunkQJBJZVG6js.runToolExecuteStage.call(void 0,
|
|
@@ -3174,7 +3206,7 @@ async function executeTool(toolId, options) {
|
|
|
3174
3206
|
);
|
|
3175
3207
|
if (play) {
|
|
3176
3208
|
if (wantsJson) {
|
|
3177
|
-
|
|
3209
|
+
_chunkRTO5QZWTjs.printJsonError.call(void 0,
|
|
3178
3210
|
new Error(playAliasToolErrorMessage(parsed.toolId, play))
|
|
3179
3211
|
);
|
|
3180
3212
|
} else {
|
|
@@ -3187,7 +3219,7 @@ async function executeTool(toolId, options) {
|
|
|
3187
3219
|
}
|
|
3188
3220
|
if (isPlayLikeTool(metadata)) {
|
|
3189
3221
|
if (wantsJson) {
|
|
3190
|
-
|
|
3222
|
+
_chunkRTO5QZWTjs.printJsonError.call(void 0,
|
|
3191
3223
|
new Error(
|
|
3192
3224
|
playLikeToolExecuteErrorMessage(
|
|
3193
3225
|
parsed.toolId,
|
|
@@ -3235,9 +3267,9 @@ async function executeTool(toolId, options) {
|
|
|
3235
3267
|
responseIntent,
|
|
3236
3268
|
...idempotencyKey ? { idempotencyKey } : {},
|
|
3237
3269
|
...parsed.recoveryTimeoutMs !== void 0 ? { recoveryTimeoutMs: parsed.recoveryTimeoutMs } : {},
|
|
3238
|
-
searchRef:
|
|
3270
|
+
searchRef: _chunkKAEZNPUMjs.recentSearchRef.call(void 0, ),
|
|
3239
3271
|
cliInvocationId,
|
|
3240
|
-
onResponseReceived:
|
|
3272
|
+
onResponseReceived: _chunkNSOTASOPjs.recordApiResponse
|
|
3241
3273
|
}).catch((error) => {
|
|
3242
3274
|
const guidanceLines = toolGuidanceLines(metadata.guidance);
|
|
3243
3275
|
if (guidanceLines.length > 0) {
|
|
@@ -3256,10 +3288,10 @@ async function executeTool(toolId, options) {
|
|
|
3256
3288
|
"result formatting",
|
|
3257
3289
|
() => {
|
|
3258
3290
|
const listExtractorPaths = listExtractorPathsFromUsageGuidance(metadata);
|
|
3259
|
-
const listConversion2 =
|
|
3291
|
+
const listConversion2 = _chunkLWERJUKNjs.tryConvertToList.call(void 0, rawResponse, {
|
|
3260
3292
|
listExtractorPaths
|
|
3261
3293
|
});
|
|
3262
|
-
const summary2 =
|
|
3294
|
+
const summary2 = _chunkLWERJUKNjs.extractSummaryFields.call(void 0, rawResponse);
|
|
3263
3295
|
const baseEnvelope2 = buildToolExecuteBaseEnvelope({
|
|
3264
3296
|
toolId: parsed.toolId,
|
|
3265
3297
|
params: parsed.params,
|
|
@@ -3276,15 +3308,15 @@ async function executeTool(toolId, options) {
|
|
|
3276
3308
|
const executeExitCode = toolExecuteExitCode(baseEnvelope);
|
|
3277
3309
|
const delivered = await _chunkQJBJZVG6js.runToolExecuteStage.call(void 0, "output delivery", () => {
|
|
3278
3310
|
if (!parsed.outPath && (parsed.outputFormat === "json" || parsed.outputFormat === "auto" && wantsJson)) {
|
|
3279
|
-
|
|
3311
|
+
_chunkRTO5QZWTjs.printCommandEnvelope.call(void 0, baseEnvelope, { json: true });
|
|
3280
3312
|
return true;
|
|
3281
3313
|
}
|
|
3282
3314
|
if (parsed.outputFormat === "json_file") {
|
|
3283
|
-
const jsonPath =
|
|
3315
|
+
const jsonPath = _chunkLWERJUKNjs.writeJsonOutputFile.call(void 0,
|
|
3284
3316
|
rawResponse,
|
|
3285
3317
|
`payload_${parsed.toolId}`
|
|
3286
3318
|
);
|
|
3287
|
-
|
|
3319
|
+
_chunkRTO5QZWTjs.printCommandEnvelope.call(void 0,
|
|
3288
3320
|
{
|
|
3289
3321
|
...baseEnvelope,
|
|
3290
3322
|
local: {
|
|
@@ -3306,18 +3338,18 @@ async function executeTool(toolId, options) {
|
|
|
3306
3338
|
`${parsed.toolId} did not expose row-shaped output to write as CSV. ${inspection.inspectDescription} Run: ${inspection.inspect}`
|
|
3307
3339
|
);
|
|
3308
3340
|
if (wantsJson) {
|
|
3309
|
-
|
|
3341
|
+
_chunkRTO5QZWTjs.printJsonError.call(void 0, error);
|
|
3310
3342
|
} else {
|
|
3311
3343
|
console.error(error.message);
|
|
3312
3344
|
}
|
|
3313
3345
|
return false;
|
|
3314
3346
|
}
|
|
3315
3347
|
if (parsed.outputFormat === "csv" || parsed.outputFormat === "csv_file") {
|
|
3316
|
-
const jsonPath =
|
|
3348
|
+
const jsonPath = _chunkLWERJUKNjs.writeJsonOutputFile.call(void 0,
|
|
3317
3349
|
rawResponse,
|
|
3318
3350
|
`payload_${parsed.toolId}`
|
|
3319
3351
|
);
|
|
3320
|
-
|
|
3352
|
+
_chunkRTO5QZWTjs.printCommandEnvelope.call(void 0,
|
|
3321
3353
|
{
|
|
3322
3354
|
...baseEnvelope,
|
|
3323
3355
|
local: {
|
|
@@ -3328,11 +3360,11 @@ async function executeTool(toolId, options) {
|
|
|
3328
3360
|
);
|
|
3329
3361
|
return true;
|
|
3330
3362
|
}
|
|
3331
|
-
|
|
3363
|
+
_chunkRTO5QZWTjs.printCommandEnvelope.call(void 0, baseEnvelope, { json: false });
|
|
3332
3364
|
return true;
|
|
3333
3365
|
}
|
|
3334
|
-
const rowOutput =
|
|
3335
|
-
const csv =
|
|
3366
|
+
const rowOutput = _chunkLWERJUKNjs.projectRowOutput.call(void 0, listConversion);
|
|
3367
|
+
const csv = _chunkLWERJUKNjs.writeCsvOutputFile.call(void 0,
|
|
3336
3368
|
listConversion.rows,
|
|
3337
3369
|
`${parsed.toolId}_output`,
|
|
3338
3370
|
parsed.outPath ? { outPath: parsed.outPath } : void 0
|
|
@@ -3352,7 +3384,7 @@ async function executeTool(toolId, options) {
|
|
|
3352
3384
|
seededScript
|
|
3353
3385
|
});
|
|
3354
3386
|
if (parsed.outputFormat === "csv_file") {
|
|
3355
|
-
|
|
3387
|
+
_chunkRTO5QZWTjs.printCommandEnvelope.call(void 0, materializedEnvelope, { json: true });
|
|
3356
3388
|
return true;
|
|
3357
3389
|
}
|
|
3358
3390
|
if (parsed.outPath) {
|
|
@@ -3360,7 +3392,7 @@ async function executeTool(toolId, options) {
|
|
|
3360
3392
|
toolId: parsed.toolId,
|
|
3361
3393
|
idempotencyKey
|
|
3362
3394
|
});
|
|
3363
|
-
|
|
3395
|
+
_chunkRTO5QZWTjs.printCommandEnvelope.call(void 0, materializedEnvelope, {
|
|
3364
3396
|
json: wantsJson,
|
|
3365
3397
|
text: `Wrote ${csv.rowCount} row(s) to ${csv.path}
|
|
3366
3398
|
inspect: ${inspection.inspect}
|
|
@@ -3369,7 +3401,7 @@ inspect: ${inspection.inspect}
|
|
|
3369
3401
|
return true;
|
|
3370
3402
|
}
|
|
3371
3403
|
if (parsed.noPreview) {
|
|
3372
|
-
|
|
3404
|
+
_chunkRTO5QZWTjs.printCommandEnvelope.call(void 0,
|
|
3373
3405
|
{
|
|
3374
3406
|
...materializedEnvelope,
|
|
3375
3407
|
local: {
|
|
@@ -3382,7 +3414,7 @@ inspect: ${inspection.inspect}
|
|
|
3382
3414
|
);
|
|
3383
3415
|
return true;
|
|
3384
3416
|
}
|
|
3385
|
-
|
|
3417
|
+
_chunkRTO5QZWTjs.printCommandEnvelope.call(void 0, materializedEnvelope, {
|
|
3386
3418
|
json: wantsJson && parsed.outputFormat !== "csv"
|
|
3387
3419
|
});
|
|
3388
3420
|
return true;
|
|
@@ -3407,5 +3439,4 @@ inspect: ${inspection.inspect}
|
|
|
3407
3439
|
|
|
3408
3440
|
|
|
3409
3441
|
|
|
3410
|
-
|
|
3411
|
-
exports.formatModelDescription = formatModelDescription; exports.isMonitorTypeTool = isMonitorTypeTool; exports.registerToolsCommands = registerToolsCommands; exports.toolContractJsonForDescribe = toolContractJsonForDescribe; exports.printMonitorTypeContract = printMonitorTypeContract; exports.publicToolSchemas = publicToolSchemas; exports.describedTool = describedTool; exports.printCompactToolContract = printCompactToolContract; exports.toolMetadataJsonForDescribe = toolMetadataJsonForDescribe; exports.extractToolExecutionWarningMessages = extractToolExecutionWarningMessages; exports.buildToolExecuteBaseEnvelope = buildToolExecuteBaseEnvelope;
|
|
3442
|
+
exports.publicToolSchemas = publicToolSchemas; exports.describedTool = describedTool; exports.toolMetadataJsonForDescribe = toolMetadataJsonForDescribe; exports.formatModelDescription = formatModelDescription; exports.registerToolsCommands = registerToolsCommands; exports.printMonitorTypeContract = printMonitorTypeContract; exports.printCompactToolContract = printCompactToolContract; exports.extractToolExecutionWarningMessages = extractToolExecutionWarningMessages; exports.seedToolListScript = seedToolListScript; exports.buildToolExecuteBaseEnvelope = buildToolExecuteBaseEnvelope;
|