deepline 0.1.38 → 0.1.40
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/cli/index.js +43 -237
- package/dist/cli/index.mjs +43 -237
- package/dist/index.d.mts +2 -18
- package/dist/index.d.ts +2 -18
- package/dist/index.js +17 -29
- package/dist/index.mjs +17 -29
- package/dist/repo/apps/play-runner-workers/src/entry.ts +17 -89
- package/dist/repo/sdk/src/client.ts +9 -22
- package/dist/repo/sdk/src/types.ts +0 -17
- package/dist/repo/sdk/src/version.ts +2 -2
- package/dist/repo/shared_libs/play-runtime/tool-result.ts +23 -79
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -216,8 +216,8 @@ function resolveConfig(options) {
|
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
// src/version.ts
|
|
219
|
-
var SDK_VERSION = "0.1.
|
|
220
|
-
var SDK_API_CONTRACT = "2026-05-
|
|
219
|
+
var SDK_VERSION = "0.1.40";
|
|
220
|
+
var SDK_API_CONTRACT = "2026-05-cloud-play-search";
|
|
221
221
|
|
|
222
222
|
// ../shared_libs/play-runtime/coordinator-headers.ts
|
|
223
223
|
var COORDINATOR_INTERNAL_TOKEN_HEADER = "x-deepline-internal-token";
|
|
@@ -1380,23 +1380,15 @@ var DeeplineClient = class {
|
|
|
1380
1380
|
return response.plays ?? [];
|
|
1381
1381
|
}
|
|
1382
1382
|
async searchPlays(options) {
|
|
1383
|
-
const
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
play.reference,
|
|
1393
|
-
play.displayName,
|
|
1394
|
-
play.origin,
|
|
1395
|
-
...play.aliases ?? [],
|
|
1396
|
-
play.inputSchema ? JSON.stringify(play.inputSchema) : ""
|
|
1397
|
-
].filter(Boolean).join(" ").toLowerCase();
|
|
1398
|
-
return terms.every((term) => haystack.includes(term));
|
|
1399
|
-
}).map((play) => this.summarizePlayListItem(play, options));
|
|
1383
|
+
const params = new URLSearchParams();
|
|
1384
|
+
params.set("search", options.query.trim());
|
|
1385
|
+
if (options.origin) params.set("origin", options.origin);
|
|
1386
|
+
const response = await this.http.get(
|
|
1387
|
+
`/api/v2/plays?${params.toString()}`
|
|
1388
|
+
);
|
|
1389
|
+
return (response.plays ?? []).map(
|
|
1390
|
+
(play) => this.summarizePlayListItem(play, options)
|
|
1391
|
+
);
|
|
1400
1392
|
}
|
|
1401
1393
|
/**
|
|
1402
1394
|
* Get the full definition and state of a named play.
|
|
@@ -7491,126 +7483,6 @@ function shouldUseLocalOnlyPlayCheck() {
|
|
|
7491
7483
|
const value = process.env.DEEPLINE_PLAY_CHECK_LOCAL_ONLY?.trim().toLowerCase();
|
|
7492
7484
|
return value === "1" || value === "true" || value === "yes" || value === "on";
|
|
7493
7485
|
}
|
|
7494
|
-
function isRecord3(value) {
|
|
7495
|
-
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
7496
|
-
}
|
|
7497
|
-
function stringValue(value) {
|
|
7498
|
-
return typeof value === "string" ? value.trim() : "";
|
|
7499
|
-
}
|
|
7500
|
-
function asArray(value) {
|
|
7501
|
-
return Array.isArray(value) ? value : [];
|
|
7502
|
-
}
|
|
7503
|
-
function extractionEntries(value) {
|
|
7504
|
-
if (Array.isArray(value)) return value.filter(isRecord3);
|
|
7505
|
-
if (!isRecord3(value)) return [];
|
|
7506
|
-
return Object.entries(value).map(
|
|
7507
|
-
([name, entry]) => isRecord3(entry) ? { name, ...entry } : { name }
|
|
7508
|
-
);
|
|
7509
|
-
}
|
|
7510
|
-
function firstRawPath(entry) {
|
|
7511
|
-
const details = isRecord3(entry.details) ? entry.details : {};
|
|
7512
|
-
const paths = [
|
|
7513
|
-
...asArray(details.rawToolOutputPaths),
|
|
7514
|
-
...asArray(details.raw_tool_output_paths),
|
|
7515
|
-
...asArray(details.candidatePaths),
|
|
7516
|
-
...asArray(details.candidate_paths)
|
|
7517
|
-
].map(stringValue).filter(Boolean);
|
|
7518
|
-
return paths[0];
|
|
7519
|
-
}
|
|
7520
|
-
function checkHintExpression(value) {
|
|
7521
|
-
return stringValue(value).replace(/^toolExecutionResult\./, "result.");
|
|
7522
|
-
}
|
|
7523
|
-
function checkHintRawPath(value) {
|
|
7524
|
-
return value?.replace(/^toolResponse\./, "result.toolResponse.");
|
|
7525
|
-
}
|
|
7526
|
-
function collectStaticPipelineToolIds(staticPipeline) {
|
|
7527
|
-
const seen = /* @__PURE__ */ new Set();
|
|
7528
|
-
const visitPipeline = (pipeline) => {
|
|
7529
|
-
if (!isRecord3(pipeline)) return;
|
|
7530
|
-
for (const step of [
|
|
7531
|
-
...asArray(pipeline.stages),
|
|
7532
|
-
...asArray(pipeline.substeps)
|
|
7533
|
-
]) {
|
|
7534
|
-
if (!isRecord3(step)) continue;
|
|
7535
|
-
if (step.type === "tool") {
|
|
7536
|
-
const toolId = stringValue(step.toolId) || stringValue(step.tool);
|
|
7537
|
-
if (toolId) seen.add(toolId);
|
|
7538
|
-
}
|
|
7539
|
-
if (step.type === "play_call") {
|
|
7540
|
-
visitPipeline(step.pipeline);
|
|
7541
|
-
}
|
|
7542
|
-
}
|
|
7543
|
-
};
|
|
7544
|
-
visitPipeline(staticPipeline);
|
|
7545
|
-
return [...seen].sort();
|
|
7546
|
-
}
|
|
7547
|
-
function toolGetterHintFromMetadata(toolId, tool) {
|
|
7548
|
-
const usageGuidance = isRecord3(tool.usageGuidance) ? tool.usageGuidance : {};
|
|
7549
|
-
const resultGuidance = isRecord3(usageGuidance.toolExecutionResult) ? usageGuidance.toolExecutionResult : isRecord3(usageGuidance.tool_execution_result) ? usageGuidance.tool_execution_result : {};
|
|
7550
|
-
const toolResponse = isRecord3(resultGuidance.toolResponse) ? resultGuidance.toolResponse : isRecord3(resultGuidance.tool_response) ? resultGuidance.tool_response : {};
|
|
7551
|
-
const lists = extractionEntries(
|
|
7552
|
-
resultGuidance.extractedLists ?? resultGuidance.extracted_lists
|
|
7553
|
-
).map((entry) => ({
|
|
7554
|
-
name: stringValue(entry.name),
|
|
7555
|
-
expression: checkHintExpression(entry.expression),
|
|
7556
|
-
raw: checkHintRawPath(firstRawPath(entry))
|
|
7557
|
-
})).filter((entry) => entry.name && entry.expression);
|
|
7558
|
-
const values = extractionEntries(
|
|
7559
|
-
resultGuidance.extractedValues ?? resultGuidance.extracted_values
|
|
7560
|
-
).map((entry) => ({
|
|
7561
|
-
name: stringValue(entry.name),
|
|
7562
|
-
expression: checkHintExpression(entry.expression),
|
|
7563
|
-
raw: checkHintRawPath(firstRawPath(entry))
|
|
7564
|
-
})).filter((entry) => entry.name && entry.expression);
|
|
7565
|
-
return {
|
|
7566
|
-
toolId,
|
|
7567
|
-
lists,
|
|
7568
|
-
values,
|
|
7569
|
-
raw: checkHintExpression(toolResponse.raw) || "result.toolResponse.raw"
|
|
7570
|
-
};
|
|
7571
|
-
}
|
|
7572
|
-
async function buildToolGetterHints(client, staticPipeline) {
|
|
7573
|
-
const toolIds = collectStaticPipelineToolIds(staticPipeline);
|
|
7574
|
-
return Promise.all(
|
|
7575
|
-
toolIds.map(async (toolId) => {
|
|
7576
|
-
try {
|
|
7577
|
-
const tool = await client.getTool(toolId);
|
|
7578
|
-
return toolGetterHintFromMetadata(toolId, tool);
|
|
7579
|
-
} catch (error) {
|
|
7580
|
-
return {
|
|
7581
|
-
toolId,
|
|
7582
|
-
lists: [],
|
|
7583
|
-
values: [],
|
|
7584
|
-
raw: "result.toolResponse.raw",
|
|
7585
|
-
unavailable: error instanceof Error ? error.message : String(error)
|
|
7586
|
-
};
|
|
7587
|
-
}
|
|
7588
|
-
})
|
|
7589
|
-
);
|
|
7590
|
-
}
|
|
7591
|
-
function printToolGetterHints(hints) {
|
|
7592
|
-
if (!hints?.length) return;
|
|
7593
|
-
console.log(" Tool result getter hints:");
|
|
7594
|
-
for (const hint of hints) {
|
|
7595
|
-
console.log(` ${hint.toolId} output:`);
|
|
7596
|
-
if (hint.lists.length) {
|
|
7597
|
-
for (const entry of hint.lists) {
|
|
7598
|
-
const raw = entry.raw ? ` (raw: ${entry.raw})` : "";
|
|
7599
|
-
console.log(` - list ${entry.name}: ${entry.expression}${raw}`);
|
|
7600
|
-
}
|
|
7601
|
-
}
|
|
7602
|
-
if (hint.values.length) {
|
|
7603
|
-
const valueNames = hint.values.map((entry) => entry.name).join(", ");
|
|
7604
|
-
console.log(` - values: ${valueNames}`);
|
|
7605
|
-
for (const entry of hint.values) {
|
|
7606
|
-
const raw = entry.raw ? ` (raw: ${entry.raw})` : "";
|
|
7607
|
-
console.log(` ${entry.name}: ${entry.expression}${raw}`);
|
|
7608
|
-
}
|
|
7609
|
-
}
|
|
7610
|
-
if (hint.raw) console.log(` - raw: ${hint.raw}`);
|
|
7611
|
-
if (hint.unavailable) console.log(` - warning: ${hint.unavailable}`);
|
|
7612
|
-
}
|
|
7613
|
-
}
|
|
7614
7486
|
async function handlePlayCheck(args) {
|
|
7615
7487
|
const options = parsePlayCheckOptions(args);
|
|
7616
7488
|
if (!isFileTarget(options.target)) {
|
|
@@ -7641,7 +7513,6 @@ async function handlePlayCheck(args) {
|
|
|
7641
7513
|
valid: true,
|
|
7642
7514
|
errors: [],
|
|
7643
7515
|
staticPipeline: graph.root.compilerManifest?.staticPipeline ?? null,
|
|
7644
|
-
toolGetterHints: [],
|
|
7645
7516
|
artifactHash: graph.root.artifact.artifactHash,
|
|
7646
7517
|
graphHash: graph.root.artifact.graphHash
|
|
7647
7518
|
};
|
|
@@ -7651,7 +7522,6 @@ async function handlePlayCheck(args) {
|
|
|
7651
7522
|
} else {
|
|
7652
7523
|
console.log(`\u2713 ${playName} passed local play check`);
|
|
7653
7524
|
console.log(` artifact: ${result2.artifactHash.slice(0, 12)}`);
|
|
7654
|
-
printToolGetterHints(result2.toolGetterHints);
|
|
7655
7525
|
}
|
|
7656
7526
|
return 0;
|
|
7657
7527
|
}
|
|
@@ -7662,27 +7532,21 @@ async function handlePlayCheck(args) {
|
|
|
7662
7532
|
sourceFiles: graph.root.sourceFiles,
|
|
7663
7533
|
artifact: graph.root.artifact
|
|
7664
7534
|
});
|
|
7665
|
-
const enrichedResult = {
|
|
7666
|
-
...result,
|
|
7667
|
-
toolGetterHints: result.toolGetterHints ?? await buildToolGetterHints(client, result.staticPipeline)
|
|
7668
|
-
};
|
|
7669
7535
|
if (options.jsonOutput) {
|
|
7670
|
-
process.stdout.write(`${JSON.stringify({ name: playName, ...
|
|
7536
|
+
process.stdout.write(`${JSON.stringify({ name: playName, ...result })}
|
|
7671
7537
|
`);
|
|
7672
|
-
} else if (
|
|
7538
|
+
} else if (result.valid) {
|
|
7673
7539
|
console.log(`\u2713 ${playName} passed cloud play check`);
|
|
7674
|
-
if (
|
|
7675
|
-
console.log(` artifact: ${
|
|
7540
|
+
if (result.artifactHash) {
|
|
7541
|
+
console.log(` artifact: ${result.artifactHash.slice(0, 12)}`);
|
|
7676
7542
|
}
|
|
7677
|
-
printToolGetterHints(enrichedResult.toolGetterHints);
|
|
7678
7543
|
} else {
|
|
7679
7544
|
console.error(`\u2717 ${playName} failed cloud play check`);
|
|
7680
|
-
for (const error of
|
|
7545
|
+
for (const error of result.errors) {
|
|
7681
7546
|
console.error(` ${error}`);
|
|
7682
7547
|
}
|
|
7683
|
-
printToolGetterHints(enrichedResult.toolGetterHints);
|
|
7684
7548
|
}
|
|
7685
|
-
return
|
|
7549
|
+
return result.valid ? 0 : 1;
|
|
7686
7550
|
}
|
|
7687
7551
|
async function handleFileBackedRun(options) {
|
|
7688
7552
|
if (options.target.kind !== "file") {
|
|
@@ -8785,7 +8649,7 @@ Pass-through input flags:
|
|
|
8785
8649
|
...options.logs ? ["--logs"] : [],
|
|
8786
8650
|
...options.tailTimeoutMs ? ["--tail-timeout-ms", options.tailTimeoutMs] : [],
|
|
8787
8651
|
...options.force ? ["--force"] : [],
|
|
8788
|
-
...options.
|
|
8652
|
+
...options.open === false ? ["--no-open"] : [],
|
|
8789
8653
|
...options.json ? ["--json"] : [],
|
|
8790
8654
|
...passthroughArgs
|
|
8791
8655
|
]);
|
|
@@ -9241,15 +9105,6 @@ function extractSummaryFields(payload) {
|
|
|
9241
9105
|
|
|
9242
9106
|
// src/cli/commands/tools.ts
|
|
9243
9107
|
function toListedTool(tool) {
|
|
9244
|
-
if (isPlayLikeTool(tool)) {
|
|
9245
|
-
const playReference = playReferenceForTool(tool);
|
|
9246
|
-
return {
|
|
9247
|
-
...tool,
|
|
9248
|
-
id: tool.toolId,
|
|
9249
|
-
type: "play",
|
|
9250
|
-
executeCommand: `deepline plays run ${playReference} --input '{...}' --watch`
|
|
9251
|
-
};
|
|
9252
|
-
}
|
|
9253
9108
|
return {
|
|
9254
9109
|
...tool,
|
|
9255
9110
|
id: tool.toolId,
|
|
@@ -9288,12 +9143,11 @@ async function searchTools(queryInput, options = {}) {
|
|
|
9288
9143
|
searchMode: options.searchMode,
|
|
9289
9144
|
includeSearchDebug: options.includeSearchDebug
|
|
9290
9145
|
});
|
|
9291
|
-
const items = result.tools.
|
|
9146
|
+
const items = result.tools.map(toListedTool);
|
|
9292
9147
|
const envelope = {
|
|
9293
9148
|
...result,
|
|
9294
9149
|
tools: items,
|
|
9295
9150
|
count: items.length,
|
|
9296
|
-
omitted_plays_hint: "Use `deepline plays search <query> --json` for prebuilt and org-owned plays.",
|
|
9297
9151
|
render: {
|
|
9298
9152
|
sections: [
|
|
9299
9153
|
{
|
|
@@ -9306,10 +9160,6 @@ async function searchTools(queryInput, options = {}) {
|
|
|
9306
9160
|
...item.inputSchema ? [" inputSchema: yes"] : []
|
|
9307
9161
|
];
|
|
9308
9162
|
})
|
|
9309
|
-
},
|
|
9310
|
-
{
|
|
9311
|
-
title: "plays",
|
|
9312
|
-
lines: ["For prebuilt or org-owned workflows, run: deepline plays search <query>"]
|
|
9313
9163
|
}
|
|
9314
9164
|
]
|
|
9315
9165
|
}
|
|
@@ -9328,36 +9178,13 @@ async function findPlayForToolId(client, toolId) {
|
|
|
9328
9178
|
const plays = await client.searchPlays({ query: requested, compact: true });
|
|
9329
9179
|
return plays.find((play) => playIdentifiers(play).includes(requested)) ?? null;
|
|
9330
9180
|
}
|
|
9331
|
-
function
|
|
9181
|
+
function printPlayAliasToolError(toolId, play) {
|
|
9332
9182
|
const playName = play.reference ?? play.name;
|
|
9333
|
-
|
|
9183
|
+
console.error(
|
|
9184
|
+
`${toolId} is a play, not a tool.
|
|
9334
9185
|
Use: deepline plays run ${playName} --input '{...}' --watch
|
|
9335
|
-
Inspect its schema with: deepline plays describe ${playName} --json
|
|
9336
|
-
|
|
9337
|
-
function printPlayAliasToolError(toolId, play) {
|
|
9338
|
-
console.error(playAliasToolErrorMessage(toolId, play));
|
|
9339
|
-
}
|
|
9340
|
-
function isPlayLikeTool(tool) {
|
|
9341
|
-
const record = tool;
|
|
9342
|
-
if (record.isPlay === true || record.is_play === true) return true;
|
|
9343
|
-
const playExpansion = recordField(record, "playExpansion", "play_expansion");
|
|
9344
|
-
if (Object.keys(playExpansion).length > 0) return true;
|
|
9345
|
-
const toolId = typeof record.toolId === "string" ? record.toolId : "";
|
|
9346
|
-
return toolId.endsWith("_waterfall");
|
|
9347
|
-
}
|
|
9348
|
-
function playReferenceForTool(tool) {
|
|
9349
|
-
const record = tool;
|
|
9350
|
-
const toolId = typeof record.toolId === "string" ? record.toolId : "play";
|
|
9351
|
-
return `prebuilt/${toolId.replace(/_/g, "-")}`;
|
|
9352
|
-
}
|
|
9353
|
-
function playLikeToolExecuteErrorMessage(toolId) {
|
|
9354
|
-
const playReference = `prebuilt/${toolId.replace(/_/g, "-")}`;
|
|
9355
|
-
return `${toolId} is a workflow/play entry, not an atomic provider tool.
|
|
9356
|
-
Use: deepline plays run ${playReference} --input '{...}' --watch
|
|
9357
|
-
Or search provider tools only with: deepline tools search "<query>" --json`;
|
|
9358
|
-
}
|
|
9359
|
-
function printPlayLikeToolExecuteError(toolId) {
|
|
9360
|
-
console.error(playLikeToolExecuteErrorMessage(toolId));
|
|
9186
|
+
Inspect its schema with: deepline plays describe ${playName} --json`
|
|
9187
|
+
);
|
|
9361
9188
|
}
|
|
9362
9189
|
function registerToolsCommands(program) {
|
|
9363
9190
|
const tools = program.command("tools").description("Search, describe, and execute atomic provider tools.").addHelpText(
|
|
@@ -9532,7 +9359,7 @@ function printToolDetails(tool, requestedToolId) {
|
|
|
9532
9359
|
const operation = typeof tool.operation === "string" ? tool.operation : "";
|
|
9533
9360
|
const displayBase = operation && operation.startsWith(`${tool.provider}_`) ? operation.slice(String(tool.provider).length + 1) : operation ? `${tool.provider} ${operation}`.trim() : toolId;
|
|
9534
9361
|
const displayName = titleCase(displayBase || String(tool.displayName || toolId));
|
|
9535
|
-
const cost =
|
|
9362
|
+
const cost = isRecord3(tool.cost) ? tool.cost : null;
|
|
9536
9363
|
const deeplineCredits = numberField(tool, "deeplineCreditsPerPricingUnit", "deepline_credits_per_pricing_unit");
|
|
9537
9364
|
const deeplineUsdPerPricingUnit = numberField(tool, "deeplineUsdPerPricingUnit", "deepline_usd_per_pricing_unit");
|
|
9538
9365
|
const deeplineUsdPerCredit = numberField(tool, "deeplineUsdPerCredit", "deepline_usd_per_credit");
|
|
@@ -9582,7 +9409,7 @@ function printToolDetails(tool, requestedToolId) {
|
|
|
9582
9409
|
if (stepContributions.length) {
|
|
9583
9410
|
console.log(" step contributions:");
|
|
9584
9411
|
for (const item of stepContributions) {
|
|
9585
|
-
if (!
|
|
9412
|
+
if (!isRecord3(item)) continue;
|
|
9586
9413
|
const stepTool = typeof item.tool === "string" ? item.tool.trim() : "";
|
|
9587
9414
|
const low = typeof item.lowCredits === "number" ? item.lowCredits : null;
|
|
9588
9415
|
const high = typeof item.highCredits === "number" ? item.highCredits : null;
|
|
@@ -9622,7 +9449,7 @@ function printToolDetails(tool, requestedToolId) {
|
|
|
9622
9449
|
}
|
|
9623
9450
|
const toolExecutionResult = recordField(usageGuidance, "toolExecutionResult");
|
|
9624
9451
|
const extractedValues = arrayField(toolExecutionResult, "extractedValues", "extracted_values");
|
|
9625
|
-
const targets = extractedValues.map((entry) =>
|
|
9452
|
+
const targets = extractedValues.map((entry) => isRecord3(entry) && typeof entry.name === "string" ? entry.name : "").filter(Boolean).sort();
|
|
9626
9453
|
if (targets.length) {
|
|
9627
9454
|
console.log(` - Built-in extract targets: ${targets.join(", ")}`);
|
|
9628
9455
|
}
|
|
@@ -9663,7 +9490,7 @@ function printExtractions(label, entries) {
|
|
|
9663
9490
|
if (!entries.length) return;
|
|
9664
9491
|
console.log(` ${label}:`);
|
|
9665
9492
|
for (const entry of entries) {
|
|
9666
|
-
if (!
|
|
9493
|
+
if (!isRecord3(entry)) continue;
|
|
9667
9494
|
const name = stringField(entry, "name");
|
|
9668
9495
|
const expression = stringField(entry, "expression");
|
|
9669
9496
|
const details = recordField(entry, "details");
|
|
@@ -9703,12 +9530,12 @@ function printToolCost(input) {
|
|
|
9703
9530
|
return false;
|
|
9704
9531
|
}
|
|
9705
9532
|
function toolInputFieldsForDisplay(inputSchema) {
|
|
9706
|
-
if (Array.isArray(inputSchema.fields)) return inputSchema.fields.filter(
|
|
9707
|
-
const jsonSchema =
|
|
9708
|
-
const properties =
|
|
9533
|
+
if (Array.isArray(inputSchema.fields)) return inputSchema.fields.filter(isRecord3);
|
|
9534
|
+
const jsonSchema = isRecord3(inputSchema.jsonSchema) ? inputSchema.jsonSchema : inputSchema;
|
|
9535
|
+
const properties = isRecord3(jsonSchema.properties) ? jsonSchema.properties : {};
|
|
9709
9536
|
const required = Array.isArray(jsonSchema.required) ? new Set(jsonSchema.required.map(String)) : /* @__PURE__ */ new Set();
|
|
9710
9537
|
return Object.entries(properties).map(([name, value]) => {
|
|
9711
|
-
const property =
|
|
9538
|
+
const property = isRecord3(value) ? value : {};
|
|
9712
9539
|
return {
|
|
9713
9540
|
name,
|
|
9714
9541
|
type: typeof property.type === "string" ? property.type : "unknown",
|
|
@@ -9735,15 +9562,15 @@ function printJsonPreview(label, payload) {
|
|
|
9735
9562
|
}
|
|
9736
9563
|
function samplePayload(samples, key) {
|
|
9737
9564
|
const entry = samples[key];
|
|
9738
|
-
if (!
|
|
9565
|
+
if (!isRecord3(entry)) return void 0;
|
|
9739
9566
|
return Object.prototype.hasOwnProperty.call(entry, "payload") ? entry.payload : entry;
|
|
9740
9567
|
}
|
|
9741
9568
|
function commandEnvelopeFromRawResponse(rawResponse) {
|
|
9742
|
-
return
|
|
9569
|
+
return isRecord3(rawResponse) ? { ...rawResponse } : { status: "completed", result: rawResponse };
|
|
9743
9570
|
}
|
|
9744
9571
|
function listExtractorPathsFromUsageGuidance(tool) {
|
|
9745
9572
|
const toolExecutionResult = tool.usageGuidance?.toolExecutionResult;
|
|
9746
|
-
const extractedLists = Array.isArray(toolExecutionResult?.extractedLists) ? toolExecutionResult.extractedLists :
|
|
9573
|
+
const extractedLists = Array.isArray(toolExecutionResult?.extractedLists) ? toolExecutionResult.extractedLists : isRecord3(toolExecutionResult?.extractedLists) ? Object.values(toolExecutionResult.extractedLists) : [];
|
|
9747
9574
|
return extractedLists.flatMap((entry) => {
|
|
9748
9575
|
const paths = entry.details?.candidatePaths ?? entry.details?.rawToolOutputPaths;
|
|
9749
9576
|
if (!Array.isArray(paths)) return [];
|
|
@@ -9770,7 +9597,7 @@ function formatDecimal(value) {
|
|
|
9770
9597
|
function formatUsd(value) {
|
|
9771
9598
|
return `$${formatDecimal(value)}`;
|
|
9772
9599
|
}
|
|
9773
|
-
function
|
|
9600
|
+
function isRecord3(value) {
|
|
9774
9601
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
9775
9602
|
}
|
|
9776
9603
|
function stringField(source, ...keys) {
|
|
@@ -9797,7 +9624,7 @@ function arrayField(source, ...keys) {
|
|
|
9797
9624
|
function recordField(source, ...keys) {
|
|
9798
9625
|
for (const key of keys) {
|
|
9799
9626
|
const value = source[key];
|
|
9800
|
-
if (
|
|
9627
|
+
if (isRecord3(value)) return value;
|
|
9801
9628
|
}
|
|
9802
9629
|
return {};
|
|
9803
9630
|
}
|
|
@@ -9895,11 +9722,8 @@ export default definePlay(${JSON.stringify(playName)}, async (ctx) => {
|
|
|
9895
9722
|
// .step('phone_waterfall', (row, rowCtx) => rowCtx.runPlay('contact_phone', 'contact-to-phone', { first_name: String(row.first_name ?? ''), last_name: String(row.last_name ?? ''), email: String(row.email ?? '') }, { description: 'Resolve phone.' }))
|
|
9896
9723
|
// ctx.map is idempotent by map key + row key; reruns reuse completed rows.
|
|
9897
9724
|
const enrichedData = await ctx
|
|
9898
|
-
.map('enriched_data', rows)
|
|
9899
|
-
.run({
|
|
9900
|
-
key: ${rowKey},
|
|
9901
|
-
description: 'Enrich seeded rows.',
|
|
9902
|
-
});
|
|
9725
|
+
.map('enriched_data', rows, { key: ${rowKey} })
|
|
9726
|
+
.run({ description: 'Enrich seeded rows.' });
|
|
9903
9727
|
|
|
9904
9728
|
return {
|
|
9905
9729
|
rows: enrichedData,
|
|
@@ -9929,7 +9753,7 @@ function buildToolExecuteBaseEnvelope(input) {
|
|
|
9929
9753
|
kind: summaryEntries.length > 0 ? "object" : "raw",
|
|
9930
9754
|
summary: input.summary
|
|
9931
9755
|
};
|
|
9932
|
-
const envelopeHasCanonicalOutput =
|
|
9756
|
+
const envelopeHasCanonicalOutput = isRecord3(envelope.toolResponse) && Object.prototype.hasOwnProperty.call(envelope.toolResponse, "raw");
|
|
9933
9757
|
const inspectCommand = `deepline tools execute ${input.toolId} --input ${shellQuote(JSON.stringify(input.params))} --json`;
|
|
9934
9758
|
const actions = input.listConversion ? [
|
|
9935
9759
|
{
|
|
@@ -9989,11 +9813,7 @@ async function executeTool(args) {
|
|
|
9989
9813
|
} catch (error) {
|
|
9990
9814
|
const play = await findPlayForToolId(client, parsed.toolId);
|
|
9991
9815
|
if (play) {
|
|
9992
|
-
|
|
9993
|
-
printJsonError(new Error(playAliasToolErrorMessage(parsed.toolId, play)));
|
|
9994
|
-
} else {
|
|
9995
|
-
printPlayAliasToolError(parsed.toolId, play);
|
|
9996
|
-
}
|
|
9816
|
+
printPlayAliasToolError(parsed.toolId, play);
|
|
9997
9817
|
return 2;
|
|
9998
9818
|
}
|
|
9999
9819
|
if (error instanceof DeeplineError) {
|
|
@@ -10001,14 +9821,6 @@ async function executeTool(args) {
|
|
|
10001
9821
|
}
|
|
10002
9822
|
throw error;
|
|
10003
9823
|
}
|
|
10004
|
-
if (isPlayLikeTool(metadata)) {
|
|
10005
|
-
if (argsWantJson(args)) {
|
|
10006
|
-
printJsonError(new Error(playLikeToolExecuteErrorMessage(parsed.toolId)));
|
|
10007
|
-
} else {
|
|
10008
|
-
printPlayLikeToolExecuteError(parsed.toolId);
|
|
10009
|
-
}
|
|
10010
|
-
return 2;
|
|
10011
|
-
}
|
|
10012
9824
|
const rawResponse = await client.executeTool(parsed.toolId, parsed.params);
|
|
10013
9825
|
const listConversion = tryConvertToList(rawResponse, {
|
|
10014
9826
|
listExtractorPaths: listExtractorPathsFromUsageGuidance(metadata)
|
|
@@ -10031,7 +9843,7 @@ async function executeTool(args) {
|
|
|
10031
9843
|
{
|
|
10032
9844
|
...baseEnvelope,
|
|
10033
9845
|
local: {
|
|
10034
|
-
...
|
|
9846
|
+
...isRecord3(baseEnvelope.local) ? baseEnvelope.local : {},
|
|
10035
9847
|
payload_file: jsonPath
|
|
10036
9848
|
}
|
|
10037
9849
|
},
|
|
@@ -10629,15 +10441,9 @@ Notes:
|
|
|
10629
10441
|
|
|
10630
10442
|
Examples:
|
|
10631
10443
|
deepline version
|
|
10632
|
-
deepline version --json
|
|
10633
10444
|
deepline --version
|
|
10634
10445
|
`
|
|
10635
|
-
).
|
|
10636
|
-
if (options.json) {
|
|
10637
|
-
process.stdout.write(`${JSON.stringify({ version: SDK_VERSION })}
|
|
10638
|
-
`);
|
|
10639
|
-
return;
|
|
10640
|
-
}
|
|
10446
|
+
).action(() => {
|
|
10641
10447
|
process.stdout.write(`deepline ${SDK_VERSION}
|
|
10642
10448
|
`);
|
|
10643
10449
|
});
|