deepline 0.3.290 → 0.3.291
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/client.ts +8 -6
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/sdk/src/runs/overview.ts +16 -6
- package/dist/bundling-sources/sdk/src/types.ts +21 -2
- package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +11 -1
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +209 -51
- package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +10 -2
- package/dist/bundling-sources/shared_libs/play-runtime/log-context.ts +36 -0
- package/dist/bundling-sources/shared_libs/play-runtime/log-provenance.ts +2 -1
- package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +5 -1
- package/dist/bundling-sources/shared_libs/play-runtime/run-ledger-event-transport.ts +54 -41
- package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +50 -3
- package/dist/bundling-sources/shared_libs/play-runtime/run-log-buffer.ts +9 -2
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +35 -7
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-terminal-push.ts +55 -9
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +16 -4
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +140 -4
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +559 -313
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/run-ledger-outbox-recovery.ts +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-event-search.ts +116 -24
- package/dist/bundling-sources/shared_libs/play-runtime/step-progress.ts +6 -1
- package/dist/bundling-sources/shared_libs/play-runtime/tool-call/runtime-step-receipts-adapter.ts +22 -5
- package/dist/bundling-sources/shared_libs/play-runtime/tool-http-errors.ts +35 -0
- package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +68 -8
- package/dist/bundling-sources/shared_libs/play-runtime/worker-api-types.ts +2 -0
- package/dist/bundling-sources/shared_libs/plays/tool-result-types.ts +2 -0
- package/dist/cli/index.js +193 -582
- package/dist/cli/index.mjs +193 -582
- package/dist/{client-FR_u0dxT.d.ts → client-Ct4jmvAg.d.ts} +29 -8
- package/dist/{client-phK1Ixcl.d.mts → client-Ct9GKrwu.d.mts} +29 -8
- package/dist/{compiler-manifest-9SQtUuKb.d.mts → compiler-manifest-qtTNYvBl.d.mts} +2 -0
- package/dist/{compiler-manifest-9SQtUuKb.d.ts → compiler-manifest-qtTNYvBl.d.ts} +2 -0
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +12 -5
- package/dist/index.mjs +12 -5
- package/dist/install-integrity.json +4 -4
- package/dist/plays/bundle-play-file.d.mts +2 -2
- package/dist/plays/bundle-play-file.d.ts +2 -2
- package/dist/plays/run-request.d.mts +2 -2
- package/dist/plays/run-request.d.ts +2 -2
- package/dist/release.d.mts +1 -1
- package/dist/release.d.ts +1 -1
- package/dist/release.js +1 -1
- package/dist/release.mjs +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -3515,7 +3515,7 @@ var SDK_RELEASE = {
|
|
|
3515
3515
|
// getters keep their established compatibility behavior.
|
|
3516
3516
|
// 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
|
|
3517
3517
|
// 0.3.90 is the first deliberately versioned SDK release for API v3.
|
|
3518
|
-
version: "0.3.
|
|
3518
|
+
version: "0.3.291",
|
|
3519
3519
|
updateSummary: "Play grep now returns concise results with the matched fields and terms. Automatic CLI updates are enabled by default; use `deepline settings autoupdate off` to opt out, `deepline settings autoupdate on` to re-enable updates, or `deepline settings autoupdate pin <version>` to hold an exact release.",
|
|
3520
3520
|
packageCapabilities: {
|
|
3521
3521
|
updatePreferences: 1
|
|
@@ -5982,7 +5982,7 @@ function classifyLegacyLogLine(line) {
|
|
|
5982
5982
|
if (/^\[perf\] runtime receipt\b/i.test(message)) {
|
|
5983
5983
|
return "receipt";
|
|
5984
5984
|
}
|
|
5985
|
-
if (/^\[perf\] runtime
|
|
5985
|
+
if (/^\[perf\]/i.test(message) || /^\[runtime\.(?:phase_summary|logs|log_transport)\]/i.test(message) || /\[worker\] picked up run\b/.test(message) || /\[worker\] heartbeat\b/.test(message) || /\[worker\] progress completedRows=\d+ totalRows=\d+ rowUpdates=\d+/.test(
|
|
5986
5986
|
message
|
|
5987
5987
|
) || /\[worker\] step started\b/.test(message) || /\[worker\] Preparing run files\b/.test(message) || /\[worker\] Run files ready\b/.test(message) || /\[worker\] Runtime ready\b/.test(message) || /\[worker\] Sandbox (?:starting|create start|create done|workspace ready|upload start|runner uploaded)\b/.test(
|
|
5988
5988
|
message
|
|
@@ -7814,8 +7814,10 @@ var DeeplineClient = class _DeeplineClient {
|
|
|
7814
7814
|
/**
|
|
7815
7815
|
* Execute a tool and return the standard execution envelope.
|
|
7816
7816
|
*
|
|
7817
|
-
* The `toolResponse.rawV2` field contains the complete
|
|
7818
|
-
* `
|
|
7817
|
+
* The `toolResponse.rawV2` field contains the complete tool response,
|
|
7818
|
+
* preserving its original nesting. Inspect `getTool().examples` for a full
|
|
7819
|
+
* Deepline response example. Optional `toolResponse.responseMeta` contains
|
|
7820
|
+
* response metadata.
|
|
7819
7821
|
* Top-level fields such as `status`, `job_id`, and `billing` describe the
|
|
7820
7822
|
* Deepline execution envelope.
|
|
7821
7823
|
*/
|
|
@@ -8528,7 +8530,7 @@ var DeeplineClient = class _DeeplineClient {
|
|
|
8528
8530
|
});
|
|
8529
8531
|
} catch (error) {
|
|
8530
8532
|
failedLogsLoaded = false;
|
|
8531
|
-
const retryCommand = `deepline runs
|
|
8533
|
+
const retryCommand = `deepline runs logs ${runId} --failed --json`;
|
|
8532
8534
|
const reason = error instanceof Error && error.message.trim() ? ` (${error.message.trim().slice(0, 500)})` : "";
|
|
8533
8535
|
failedLogs = {
|
|
8534
8536
|
runId,
|
|
@@ -21734,7 +21736,7 @@ var KIND_DESCRIPTIONS = {
|
|
|
21734
21736
|
"dataset.lifecycle": "Dataset registered, available or failed.",
|
|
21735
21737
|
"activity.observed": "Provider or workflow activity.",
|
|
21736
21738
|
"work.counters": "Call, request and rate-limit totals.",
|
|
21737
|
-
"receipt.completed": "Saved
|
|
21739
|
+
"receipt.completed": "Saved result or call details.",
|
|
21738
21740
|
"receipt.failed": "Saved work result: failed.",
|
|
21739
21741
|
"receipt.skipped": "Saved work result: skipped.",
|
|
21740
21742
|
"runtime.event": "Other event."
|
|
@@ -21775,6 +21777,10 @@ var FILTER_EXAMPLES = [
|
|
|
21775
21777
|
{
|
|
21776
21778
|
label: "One run and step",
|
|
21777
21779
|
command: `deepline runs logs '<run-id>' --where '$.stepId == "company-lookup"' --json`
|
|
21780
|
+
},
|
|
21781
|
+
{
|
|
21782
|
+
label: "Error logs for one step",
|
|
21783
|
+
command: `deepline runs logs --kind log.appended --where '$.level == "error" && $.stepId == "company-lookup"' --payloads --json`
|
|
21778
21784
|
}
|
|
21779
21785
|
];
|
|
21780
21786
|
function wrapParagraph(text) {
|
|
@@ -21795,10 +21801,14 @@ function renderRunLogsHelp() {
|
|
|
21795
21801
|
"",
|
|
21796
21802
|
"Examples:",
|
|
21797
21803
|
` ${READ_EXAMPLES[0]}`,
|
|
21804
|
+
` deepline runs logs --where '$.eventId == "receipt:5a32ee1a-46cf-4853-b72b-5f1d782ffab4"' --payloads --json`,
|
|
21798
21805
|
" deepline runs logs --kind run.failed --json",
|
|
21799
|
-
...[
|
|
21800
|
-
|
|
21801
|
-
|
|
21806
|
+
...[
|
|
21807
|
+
FILTER_EXAMPLES[1],
|
|
21808
|
+
FILTER_EXAMPLES[2],
|
|
21809
|
+
FILTER_EXAMPLES[5],
|
|
21810
|
+
FILTER_EXAMPLES[7]
|
|
21811
|
+
].map(({ command }) => ` ${command}`),
|
|
21802
21812
|
"",
|
|
21803
21813
|
"Event kinds:",
|
|
21804
21814
|
...RUN_LOGS_KIND_HELP.map(
|
|
@@ -21817,6 +21827,7 @@ function renderRunLogsHelp() {
|
|
|
21817
21827
|
"A run ID alone reads text logs. Omit it or add a search flag to search events; a supplied run ID narrows the search.",
|
|
21818
21828
|
"Defaults to the last hour; maximum lookback is seven days. Follow next.logs for events; use nextCursor with --cursor for older text logs.",
|
|
21819
21829
|
"--payloads returns available details or saved results: up to 10 events and 16 MiB.",
|
|
21830
|
+
"To read one exact saved result, filter by its returned eventId and add --payloads.",
|
|
21820
21831
|
"--out, --failed and --log-level apply to text logs and cannot be combined with event search."
|
|
21821
21832
|
].map((note) => wrapParagraph(note)),
|
|
21822
21833
|
"",
|
|
@@ -22149,13 +22160,6 @@ var DATASET_EXECUTION_BUCKETS = [
|
|
|
22149
22160
|
"skipped:missed",
|
|
22150
22161
|
"failed"
|
|
22151
22162
|
];
|
|
22152
|
-
function formatDatasetRowCountsLine(counts) {
|
|
22153
|
-
const { persisted, succeeded, failed } = counts;
|
|
22154
|
-
if (succeeded === persisted && failed === 0) {
|
|
22155
|
-
return `${persisted} persisted`;
|
|
22156
|
-
}
|
|
22157
|
-
return `${persisted} persisted (${succeeded} succeeded, ${failed} failed)`;
|
|
22158
|
-
}
|
|
22159
22163
|
|
|
22160
22164
|
// src/runs/overview.ts
|
|
22161
22165
|
var record3 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
@@ -22174,7 +22178,7 @@ function lifecycleActions(status, id, state) {
|
|
|
22174
22178
|
return {
|
|
22175
22179
|
...["started", "queued", "running", "waiting"].includes(state ?? "") ? { stopRunCmd: `deepline runs stop ${id} --json` } : {},
|
|
22176
22180
|
...state === "failed" ? {
|
|
22177
|
-
getFailedLogsCmd: `deepline runs
|
|
22181
|
+
getFailedLogsCmd: `deepline runs logs ${id} --failed --json`,
|
|
22178
22182
|
...status.rerunCommand ? { rerunCmd: status.rerunCommand } : {}
|
|
22179
22183
|
} : {}
|
|
22180
22184
|
};
|
|
@@ -22377,7 +22381,7 @@ function buildRunOverview(status, fullStatus) {
|
|
|
22377
22381
|
);
|
|
22378
22382
|
return {
|
|
22379
22383
|
datasetId: dataset.datasetId,
|
|
22380
|
-
name: dataset.tableNamespace,
|
|
22384
|
+
name: dataset.tableNamespace ?? (typeof stepOutput?.tableNamespace === "string" ? stepOutput.tableNamespace : dataset.path),
|
|
22381
22385
|
stepId: step?.id ?? named[0]?.[1].stepId,
|
|
22382
22386
|
rowCount: dataset.rowCount ?? null,
|
|
22383
22387
|
...dataset.lifecycle ? { lifecycle: dataset.lifecycle } : {},
|
|
@@ -22471,7 +22475,7 @@ function buildRunOverview(status, fullStatus) {
|
|
|
22471
22475
|
function receiptAction(id) {
|
|
22472
22476
|
const quotedId = `'${id.replace(/'/g, "'\\''")}'`;
|
|
22473
22477
|
return {
|
|
22474
|
-
getReceiptCmd: `deepline runs
|
|
22478
|
+
getReceiptCmd: `deepline runs logs ${quotedId} --kind receipt.completed --payloads --json`
|
|
22475
22479
|
};
|
|
22476
22480
|
}
|
|
22477
22481
|
function buildRunNavigation(status) {
|
|
@@ -24330,7 +24334,7 @@ Examples:
|
|
|
24330
24334
|
// src/cli/commands/run-receipt.ts
|
|
24331
24335
|
var import_promises4 = require("fs/promises");
|
|
24332
24336
|
function registerRunReceiptCommand(runs) {
|
|
24333
|
-
runs.command("receipt <runId>").description(
|
|
24337
|
+
runs.command("receipt <runId>", { hidden: true }).description(
|
|
24334
24338
|
"Read retained tool responses by receipt key. Never executes tools."
|
|
24335
24339
|
).option(
|
|
24336
24340
|
"--key <key>",
|
|
@@ -24344,8 +24348,7 @@ function registerRunReceiptCommand(runs) {
|
|
|
24344
24348
|
"after",
|
|
24345
24349
|
`
|
|
24346
24350
|
Examples:
|
|
24347
|
-
deepline runs
|
|
24348
|
-
jq -r '.[].receipt_key' rows.json | deepline runs receipt <run-id> --keys - --out responses.json
|
|
24351
|
+
deepline runs logs <run-id> --kind receipt.completed --payloads --json
|
|
24349
24352
|
|
|
24350
24353
|
Returns one outcome per key, preserving order and duplicates. A missing or
|
|
24351
24354
|
unavailable result is explicit; other keys are still returned. Exit 4 means
|
|
@@ -31596,7 +31599,7 @@ async function traceCliSpan(phase, fields2, run) {
|
|
|
31596
31599
|
}
|
|
31597
31600
|
|
|
31598
31601
|
// src/cli/play-check-hints.ts
|
|
31599
|
-
var EXTRACTED_GETTER_ERROR_HINT = "Deepline hint: extractedValues/extractedLists .get() only works for declared Deepline getters listed by `deepline tools describe <tool> --json`.
|
|
31602
|
+
var EXTRACTED_GETTER_ERROR_HINT = "Deepline hint: extractedValues/extractedLists .get() only works for declared Deepline getters listed by `deepline tools describe <tool> --json`. Read tool-specific fields from `toolExecutionResult.toolResponse.rawV2` using the nesting shown in the response example, and use `toolExecutionResult.extractedLists.<name>.get()` for declared row/list outputs.";
|
|
31600
31603
|
var DATASET_API_HINT = "Deepline hint: PlayDataset is lazy, durable, and async-only. Use `.count()`, `.first()`, `.at(index)`, `.peek(n)`, `.materialize(limit)`, or async iteration; do not use `.length`, numeric indexing, spread, synchronous iteration, `.rows`, or `.toArray()`.";
|
|
31601
31604
|
var ROW_PROPERTY_HINT = "Deepline hint: this row type only contains fields produced by the CSV/schema and previous map steps. Check source column casing and the exact output field names from earlier steps before scaling.";
|
|
31602
31605
|
var TOOLS_EXECUTE_SIGNATURE_HINT = "Deepline hint: ctx.tools.execute requires a request object: `ctx.tools.execute({ id, tool, input, description })`. The stable `id` is required for logs, metadata, and result-cache identity; terminal cache reuse is based on play, tool, semantic input, auth scope, provider action version, and cache policy.";
|
|
@@ -36564,12 +36567,13 @@ function buildRunNextCommands(status) {
|
|
|
36564
36567
|
};
|
|
36565
36568
|
}
|
|
36566
36569
|
const actions2 = buildRunNavigation(status).actions;
|
|
36570
|
+
const exportDatasetCmds = Array.isArray(actions2.exportDatasetCmds) ? actions2.exportDatasetCmds : !status.package && extractCanonicalRowsInfo(status) ? [`deepline runs export ${runId} --out output.csv`] : [];
|
|
36567
36571
|
const commands = {
|
|
36568
36572
|
get: String(actions2.getRunCmd ?? `deepline runs get ${runId} --json`),
|
|
36569
36573
|
full: String(
|
|
36570
36574
|
actions2.getFullRunCmd ?? `deepline runs get ${runId} --full --json`
|
|
36571
36575
|
),
|
|
36572
|
-
...
|
|
36576
|
+
...exportDatasetCmds.length === 1 ? { export: String(exportDatasetCmds[0]) } : {},
|
|
36573
36577
|
logs: String(
|
|
36574
36578
|
!status.package ? `deepline runs logs ${runId} --out run.log --json` : actions2.getLogsCmd ?? `deepline runs logs ${runId} --limit 100 --json`
|
|
36575
36579
|
)
|
|
@@ -36578,7 +36582,7 @@ function buildRunNextCommands(status) {
|
|
|
36578
36582
|
commands.stop = `deepline runs stop ${runId} --json`;
|
|
36579
36583
|
}
|
|
36580
36584
|
if (status.status === "failed") {
|
|
36581
|
-
commands.failedLogs = `deepline runs
|
|
36585
|
+
commands.failedLogs = `deepline runs logs ${runId} --failed --json`;
|
|
36582
36586
|
if (status.rerunCommand) commands.run = status.rerunCommand;
|
|
36583
36587
|
}
|
|
36584
36588
|
if (status.dashboardUrl) {
|
|
@@ -37009,7 +37013,7 @@ function compactPlayStatus(status) {
|
|
|
37009
37013
|
next: {
|
|
37010
37014
|
...readRecord(packaged.next) ?? {},
|
|
37011
37015
|
...status.failedLogs ? {
|
|
37012
|
-
failedLogs: `deepline runs
|
|
37016
|
+
failedLogs: `deepline runs logs ${status.runId} --failed --json`
|
|
37013
37017
|
} : {},
|
|
37014
37018
|
...status.rerunCommand ? { run: status.rerunCommand } : {}
|
|
37015
37019
|
}
|
|
@@ -37022,14 +37026,14 @@ function compactPlayStatus(status) {
|
|
|
37022
37026
|
...status.failedLogs ? {
|
|
37023
37027
|
next: {
|
|
37024
37028
|
...readRecord(packaged.next) ?? {},
|
|
37025
|
-
failedLogs: `deepline runs
|
|
37029
|
+
failedLogs: `deepline runs logs ${status.runId} --failed --json`
|
|
37026
37030
|
}
|
|
37027
37031
|
} : {},
|
|
37028
37032
|
...status.rerunCommand ? {
|
|
37029
37033
|
next: {
|
|
37030
37034
|
...readRecord(packaged.next) ?? {},
|
|
37031
37035
|
...status.failedLogs ? {
|
|
37032
|
-
failedLogs: `deepline runs
|
|
37036
|
+
failedLogs: `deepline runs logs ${status.runId} --failed --json`
|
|
37033
37037
|
} : {},
|
|
37034
37038
|
run: status.rerunCommand
|
|
37035
37039
|
}
|
|
@@ -37078,9 +37082,6 @@ function compactRunErrorForEnvelope(message, runId) {
|
|
|
37078
37082
|
const headline = firstStackFrame >= 0 ? lines.slice(0, firstStackFrame).join("\n") : message;
|
|
37079
37083
|
return truncateErrorForDisplay(headline, runId, 1e3);
|
|
37080
37084
|
}
|
|
37081
|
-
function readRunPackageRun(packaged) {
|
|
37082
|
-
return packaged.run && typeof packaged.run === "object" && !Array.isArray(packaged.run) ? packaged.run : {};
|
|
37083
|
-
}
|
|
37084
37085
|
function readRecordArray(value) {
|
|
37085
37086
|
return Array.isArray(value) ? value.filter(
|
|
37086
37087
|
(item) => item !== null && typeof item === "object" && !Array.isArray(item)
|
|
@@ -37092,131 +37093,6 @@ function readRecord(value) {
|
|
|
37092
37093
|
function readNonNegativeInteger(value) {
|
|
37093
37094
|
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? Math.trunc(value) : null;
|
|
37094
37095
|
}
|
|
37095
|
-
function formatSummaryScalar(value) {
|
|
37096
|
-
if (typeof value === "number") {
|
|
37097
|
-
return Number.isFinite(value) ? formatInteger(Math.trunc(value)) : null;
|
|
37098
|
-
}
|
|
37099
|
-
if (typeof value === "string" || typeof value === "boolean") {
|
|
37100
|
-
return String(value);
|
|
37101
|
-
}
|
|
37102
|
-
if (value === null) {
|
|
37103
|
-
return "null";
|
|
37104
|
-
}
|
|
37105
|
-
return null;
|
|
37106
|
-
}
|
|
37107
|
-
function formatSummaryScalarParts(record5, skipKeys = /* @__PURE__ */ new Set()) {
|
|
37108
|
-
const parts = [];
|
|
37109
|
-
for (const [key, value] of Object.entries(record5)) {
|
|
37110
|
-
if (skipKeys.has(key)) {
|
|
37111
|
-
continue;
|
|
37112
|
-
}
|
|
37113
|
-
const formatted = formatSummaryScalar(value);
|
|
37114
|
-
if (formatted !== null) {
|
|
37115
|
-
parts.push(`${key}=${formatted}`);
|
|
37116
|
-
}
|
|
37117
|
-
}
|
|
37118
|
-
return parts;
|
|
37119
|
-
}
|
|
37120
|
-
var DATASET_SUMMARY_TOP_VALUES_DISPLAY_LIMIT = 10;
|
|
37121
|
-
function formatTopValuesPart(value) {
|
|
37122
|
-
const topValues = readRecord(value);
|
|
37123
|
-
if (!topValues) {
|
|
37124
|
-
return null;
|
|
37125
|
-
}
|
|
37126
|
-
const entries = Object.entries(topValues).slice(
|
|
37127
|
-
0,
|
|
37128
|
-
DATASET_SUMMARY_TOP_VALUES_DISPLAY_LIMIT
|
|
37129
|
-
);
|
|
37130
|
-
if (entries.length === 0) {
|
|
37131
|
-
return null;
|
|
37132
|
-
}
|
|
37133
|
-
return `top_values=${entries.map(([topValue, count2]) => `${topValue}=${String(count2)}`).join(", ")}`;
|
|
37134
|
-
}
|
|
37135
|
-
function formatPackageDatasetSummaryLines(summary, indent2 = " ") {
|
|
37136
|
-
const record5 = readRecord(summary);
|
|
37137
|
-
const columnStats = readRecord(record5?.columnStats);
|
|
37138
|
-
if (!record5 || !columnStats) {
|
|
37139
|
-
return [];
|
|
37140
|
-
}
|
|
37141
|
-
const lines = [];
|
|
37142
|
-
const rowCounts = readRecord(record5.rowCounts);
|
|
37143
|
-
if (rowCounts) {
|
|
37144
|
-
const persisted = readNonNegativeInteger(rowCounts.persisted);
|
|
37145
|
-
const succeeded = readNonNegativeInteger(rowCounts.succeeded);
|
|
37146
|
-
const failed = readNonNegativeInteger(rowCounts.failed);
|
|
37147
|
-
if (persisted !== null) {
|
|
37148
|
-
lines.push(
|
|
37149
|
-
`${indent2}rows: ${formatDatasetRowCountsLine({
|
|
37150
|
-
persisted,
|
|
37151
|
-
succeeded: succeeded ?? persisted,
|
|
37152
|
-
failed: failed ?? 0
|
|
37153
|
-
})}`
|
|
37154
|
-
);
|
|
37155
|
-
}
|
|
37156
|
-
}
|
|
37157
|
-
const parts = formatSummaryScalarParts(
|
|
37158
|
-
record5,
|
|
37159
|
-
/* @__PURE__ */ new Set(["columnStats", "rowCounts"])
|
|
37160
|
-
);
|
|
37161
|
-
if (parts.length > 0) {
|
|
37162
|
-
lines.push(`${indent2}summary: ${parts.join(" ")}`);
|
|
37163
|
-
}
|
|
37164
|
-
for (const [column, rawColumnSummary] of Object.entries(columnStats)) {
|
|
37165
|
-
const columnSummary = readRecord(rawColumnSummary);
|
|
37166
|
-
if (!columnSummary) continue;
|
|
37167
|
-
const execution = readRecord(columnSummary.execution);
|
|
37168
|
-
const executionText = execution ? Object.entries(execution).map(([bucket, value]) => `${bucket}=${String(value)}`).join(", ") : "";
|
|
37169
|
-
const topValuesText = formatTopValuesPart(columnSummary.top_values);
|
|
37170
|
-
const columnParts = [
|
|
37171
|
-
...formatSummaryScalarParts(
|
|
37172
|
-
columnSummary,
|
|
37173
|
-
/* @__PURE__ */ new Set(["execution", "top_values"])
|
|
37174
|
-
),
|
|
37175
|
-
topValuesText,
|
|
37176
|
-
executionText ? `execution=${executionText}` : null
|
|
37177
|
-
].filter(Boolean);
|
|
37178
|
-
if (columnParts.length > 0) {
|
|
37179
|
-
lines.push(`${indent2} ${column}: ${columnParts.join(" ")}`);
|
|
37180
|
-
}
|
|
37181
|
-
}
|
|
37182
|
-
return lines;
|
|
37183
|
-
}
|
|
37184
|
-
function actionToCommand(action) {
|
|
37185
|
-
if (!action || typeof action !== "object" || Array.isArray(action)) {
|
|
37186
|
-
return null;
|
|
37187
|
-
}
|
|
37188
|
-
const record5 = action;
|
|
37189
|
-
if (typeof record5.command === "string" && record5.command.trim()) {
|
|
37190
|
-
return record5.command.trim();
|
|
37191
|
-
}
|
|
37192
|
-
if (record5.kind === "deepline_run_inspect" && typeof record5.runId === "string") {
|
|
37193
|
-
return `deepline runs get ${record5.runId} --json`;
|
|
37194
|
-
}
|
|
37195
|
-
if (record5.kind === "deepline_run_full" && typeof record5.runId === "string") {
|
|
37196
|
-
return `deepline runs get ${record5.runId} --full --json`;
|
|
37197
|
-
}
|
|
37198
|
-
if (record5.kind === "deepline_run_billing" && typeof record5.runId === "string") {
|
|
37199
|
-
return `deepline runs get ${record5.runId} --full --json | jq '.billing'`;
|
|
37200
|
-
}
|
|
37201
|
-
if (record5.kind === "deepline_run_export" && typeof record5.runId === "string" && typeof record5.datasetPath === "string") {
|
|
37202
|
-
return `deepline runs export ${record5.runId} --dataset ${shellSingleQuote(
|
|
37203
|
-
record5.datasetPath
|
|
37204
|
-
)} --out ${shellSingleQuote(`${record5.datasetPath.split(".").pop() || "dataset"}.csv`)}`;
|
|
37205
|
-
}
|
|
37206
|
-
if (record5.kind === "deepline_run_logs") {
|
|
37207
|
-
if (typeof record5.command === "string" && record5.command.trim()) {
|
|
37208
|
-
return record5.command;
|
|
37209
|
-
}
|
|
37210
|
-
if (typeof record5.runId === "string") {
|
|
37211
|
-
return record5.view === "failed" ? `deepline runs get ${record5.runId} --log-failed --json` : `deepline runs logs ${record5.runId} --json`;
|
|
37212
|
-
}
|
|
37213
|
-
}
|
|
37214
|
-
if (record5.kind === "deepline_db_query" && typeof record5.sql === "string") {
|
|
37215
|
-
const maxRows = typeof record5.maxRows === "number" && Number.isFinite(record5.maxRows) ? Math.trunc(record5.maxRows) : 20;
|
|
37216
|
-
return `deepline db query --sql ${shellSingleQuote(record5.sql)} --max-rows ${maxRows} --json`;
|
|
37217
|
-
}
|
|
37218
|
-
return null;
|
|
37219
|
-
}
|
|
37220
37096
|
function packageDatasetRecords(packaged) {
|
|
37221
37097
|
const catalog = readRecordArray(packaged.datasets);
|
|
37222
37098
|
if (catalog.length > 0) return catalog;
|
|
@@ -37225,24 +37101,6 @@ function packageDatasetRecords(packaged) {
|
|
|
37225
37101
|
return output2?.kind === "dataset" ? [output2] : [];
|
|
37226
37102
|
});
|
|
37227
37103
|
}
|
|
37228
|
-
function packageReturnedDatasetIdentity(packaged) {
|
|
37229
|
-
const datasetIds = /* @__PURE__ */ new Set();
|
|
37230
|
-
const paths = /* @__PURE__ */ new Set();
|
|
37231
|
-
const outputs = readRecord(packaged.outputs) ?? {};
|
|
37232
|
-
for (const outputValue of Object.values(outputs)) {
|
|
37233
|
-
const output2 = readRecord(outputValue);
|
|
37234
|
-
if (output2?.kind !== "dataset") continue;
|
|
37235
|
-
if (typeof output2.datasetId === "string" && output2.datasetId.trim()) {
|
|
37236
|
-
datasetIds.add(output2.datasetId.trim());
|
|
37237
|
-
}
|
|
37238
|
-
for (const candidate of [output2.dataset, output2.path]) {
|
|
37239
|
-
if (typeof candidate === "string" && candidate.trim()) {
|
|
37240
|
-
paths.add(candidate.trim());
|
|
37241
|
-
}
|
|
37242
|
-
}
|
|
37243
|
-
}
|
|
37244
|
-
return { datasetIds, paths };
|
|
37245
|
-
}
|
|
37246
37104
|
function formatRunStepProgress(progress, includeRowOutcomes = false) {
|
|
37247
37105
|
const executed = readNonNegativeInteger(progress.executed);
|
|
37248
37106
|
const total = readNonNegativeInteger(progress.total);
|
|
@@ -37265,205 +37123,6 @@ function formatRunStepProgress(progress, includeRowOutcomes = false) {
|
|
|
37265
37123
|
}
|
|
37266
37124
|
return parts.join(" \xB7 ");
|
|
37267
37125
|
}
|
|
37268
|
-
function formatPackageDatasetActionLines(packaged, options) {
|
|
37269
|
-
const returned = packageReturnedDatasetIdentity(packaged);
|
|
37270
|
-
const includeSummary = options?.includeSummary ?? true;
|
|
37271
|
-
const lines = [];
|
|
37272
|
-
const steps = readRecordArray(packaged.steps);
|
|
37273
|
-
const stepsByDatasetId = /* @__PURE__ */ new Map();
|
|
37274
|
-
const stepsByPath = /* @__PURE__ */ new Map();
|
|
37275
|
-
const stepsByNamespace = /* @__PURE__ */ new Map();
|
|
37276
|
-
for (const step of steps) {
|
|
37277
|
-
if (step.kind !== "dataset") continue;
|
|
37278
|
-
const output2 = readRecord(step.output);
|
|
37279
|
-
if (typeof output2?.datasetId === "string") {
|
|
37280
|
-
stepsByDatasetId.set(output2.datasetId, step);
|
|
37281
|
-
}
|
|
37282
|
-
if (typeof output2?.path === "string") {
|
|
37283
|
-
stepsByPath.set(output2.path, step);
|
|
37284
|
-
}
|
|
37285
|
-
if (typeof step.id === "string") {
|
|
37286
|
-
stepsByNamespace.set(step.id, step);
|
|
37287
|
-
}
|
|
37288
|
-
}
|
|
37289
|
-
for (const dataset of packageDatasetRecords(packaged)) {
|
|
37290
|
-
const path = typeof dataset.path === "string" && dataset.path.trim() ? dataset.path.trim() : "dataset";
|
|
37291
|
-
const datasetId = typeof dataset.datasetId === "string" ? dataset.datasetId.trim() : "";
|
|
37292
|
-
const isReturned = datasetId && returned.datasetIds.has(datasetId) || returned.paths.has(path);
|
|
37293
|
-
const category = isReturned ? "returned" : dataset.recovered === true ? "recovered" : "persisted";
|
|
37294
|
-
const rowCount = typeof dataset.rowCount === "number" && Number.isFinite(dataset.rowCount) ? Math.max(0, Math.trunc(dataset.rowCount)) : null;
|
|
37295
|
-
const lifecycle = readRecord(dataset.lifecycle);
|
|
37296
|
-
const countUnconfirmed = lifecycle?.complete === false;
|
|
37297
|
-
const persistedLowerBound = typeof lifecycle?.persistedRowsAtLeast === "number" && Number.isFinite(lifecycle.persistedRowsAtLeast) ? Math.max(0, Math.trunc(lifecycle.persistedRowsAtLeast)) : 0;
|
|
37298
|
-
const actions2 = readRecord(dataset.actions) ?? {};
|
|
37299
|
-
if (countUnconfirmed) {
|
|
37300
|
-
lines.push(
|
|
37301
|
-
` dataset ${path}: row count unconfirmed (at least ${formatInteger(persistedLowerBound)} persisted)`
|
|
37302
|
-
);
|
|
37303
|
-
} else if (includeSummary) {
|
|
37304
|
-
if (category === "recovered" && Object.keys(actions2).length === 0) {
|
|
37305
|
-
lines.push(
|
|
37306
|
-
` dataset ${path}: available, ${rowCount === null ? "persisted" : formatInteger(rowCount)} rows persisted; re-running reuses completed work`
|
|
37307
|
-
);
|
|
37308
|
-
} else {
|
|
37309
|
-
lines.push(
|
|
37310
|
-
` ${category} dataset ${path}: ${rowCount === null ? "unknown rows" : `${formatInteger(rowCount)} ${rowCount === 1 ? "row" : "rows"}`}`
|
|
37311
|
-
);
|
|
37312
|
-
}
|
|
37313
|
-
}
|
|
37314
|
-
const step = (datasetId ? stepsByDatasetId.get(datasetId) : void 0) ?? stepsByPath.get(path) ?? (typeof dataset.tableNamespace === "string" ? stepsByNamespace.get(dataset.tableNamespace) : void 0);
|
|
37315
|
-
const progress = readRecord(step?.progress);
|
|
37316
|
-
if (progress) {
|
|
37317
|
-
lines.push(` progress: ${formatRunStepProgress(progress)}`);
|
|
37318
|
-
}
|
|
37319
|
-
if (lifecycle) {
|
|
37320
|
-
const succeeded = readNonNegativeInteger(lifecycle.succeededRowsAtLeast);
|
|
37321
|
-
const failed = readNonNegativeInteger(lifecycle.failedRowsAtLeast);
|
|
37322
|
-
const complete = lifecycle.complete === true;
|
|
37323
|
-
lines.push(
|
|
37324
|
-
` saved: ${complete ? "" : "at least "}${formatInteger(persistedLowerBound)} persisted${succeeded === null ? "" : ` \xB7 ${complete ? "" : "at least "}${formatInteger(succeeded)} succeeded`}${failed === null ? "" : ` \xB7 ${complete ? "" : "at least "}${formatInteger(failed)} failed`}`
|
|
37325
|
-
);
|
|
37326
|
-
}
|
|
37327
|
-
const exportAction = readRecord(actions2.exportCsv);
|
|
37328
|
-
const exportCommand = actionToCommand(exportAction);
|
|
37329
|
-
const exportScope = readRecord(exportAction?.scope);
|
|
37330
|
-
const queryAction = readRecord(actions2.query);
|
|
37331
|
-
const queryScope = readRecord(queryAction?.scope);
|
|
37332
|
-
const runQueryCommand = queryScope?.kind === "run" ? actionToCommand(queryAction) : null;
|
|
37333
|
-
const currentQueryCommand = actionToCommand(actions2.queryCurrentTable);
|
|
37334
|
-
const legacyQueryCommand = actionToCommand(actions2.query);
|
|
37335
|
-
if (runQueryCommand) {
|
|
37336
|
-
lines.push(` query rows from this run: ${runQueryCommand}`);
|
|
37337
|
-
} else if (currentQueryCommand) {
|
|
37338
|
-
lines.push(` query current table: ${currentQueryCommand}`);
|
|
37339
|
-
} else if (legacyQueryCommand) {
|
|
37340
|
-
lines.push(` query run rows (legacy): ${legacyQueryCommand}`);
|
|
37341
|
-
}
|
|
37342
|
-
if (exportCommand) {
|
|
37343
|
-
lines.push(
|
|
37344
|
-
exportScope?.kind === "database" ? ` export current table (may include other runs): ${exportCommand}` : ` export this run: ${exportCommand}`
|
|
37345
|
-
);
|
|
37346
|
-
}
|
|
37347
|
-
const unavailable = readRecord(dataset.exportUnavailable);
|
|
37348
|
-
if (typeof unavailable?.reason === "string" && typeof unavailable.message === "string") {
|
|
37349
|
-
lines.push(
|
|
37350
|
-
` export unavailable (${unavailable.reason}): ${unavailable.message}`
|
|
37351
|
-
);
|
|
37352
|
-
}
|
|
37353
|
-
}
|
|
37354
|
-
return lines;
|
|
37355
|
-
}
|
|
37356
|
-
function packageSavedRowCount(packaged) {
|
|
37357
|
-
const rowCounts = packageDatasetRecords(packaged).map((dataset) => dataset.rowCount).filter(
|
|
37358
|
-
(rowCount) => typeof rowCount === "number" && Number.isFinite(rowCount)
|
|
37359
|
-
).map((rowCount) => Math.max(0, Math.trunc(rowCount)));
|
|
37360
|
-
if (rowCounts.length === 0) return null;
|
|
37361
|
-
return rowCounts.reduce((total, rowCount) => total + rowCount, 0);
|
|
37362
|
-
}
|
|
37363
|
-
function runtimeLimitWindowLabel(runtimeLimitFailure) {
|
|
37364
|
-
const message = getStringField(runtimeLimitFailure, "message") ?? "";
|
|
37365
|
-
const configuredSeconds = /\bconfigured\s+(\d+)\s+second(?:s)?\s+runtime limit\b/i.exec(message)?.[1];
|
|
37366
|
-
if (configuredSeconds) {
|
|
37367
|
-
const seconds = Number(configuredSeconds);
|
|
37368
|
-
if (Number.isSafeInteger(seconds) && seconds > 0) {
|
|
37369
|
-
if (seconds % 3600 === 0) return `${seconds / 3600}-hour`;
|
|
37370
|
-
if (seconds % 60 === 0) return `${seconds / 60}-minute`;
|
|
37371
|
-
return `${seconds}-second`;
|
|
37372
|
-
}
|
|
37373
|
-
}
|
|
37374
|
-
const match = /\b(\d+)\s+(hour|hours|minute|minutes|second|seconds)\b/i.exec(
|
|
37375
|
-
message
|
|
37376
|
-
);
|
|
37377
|
-
if (!match) return "30-minute";
|
|
37378
|
-
const unit = match[2].toLowerCase().replace(/s$/, "");
|
|
37379
|
-
return `${match[1]}-${unit}`;
|
|
37380
|
-
}
|
|
37381
|
-
function runtimeLimitCheckpointLines(packaged, runId, runtimeLimitFailure) {
|
|
37382
|
-
const savedRows = packageSavedRowCount(packaged);
|
|
37383
|
-
const lines = [
|
|
37384
|
-
`\u2713 progress saved ${runId}`,
|
|
37385
|
-
"",
|
|
37386
|
-
`The Play reached its ${runtimeLimitWindowLabel(runtimeLimitFailure)} runtime window.`
|
|
37387
|
-
];
|
|
37388
|
-
if (savedRows === null) {
|
|
37389
|
-
lines.push("Progress completed before the runtime window closed.");
|
|
37390
|
-
} else {
|
|
37391
|
-
lines.push(
|
|
37392
|
-
`${formatInteger(savedRows)} ${savedRows === 1 ? "row was" : "rows were"} saved successfully.`
|
|
37393
|
-
);
|
|
37394
|
-
}
|
|
37395
|
-
lines.push(
|
|
37396
|
-
"",
|
|
37397
|
-
"Run the same Play again to continue where you left off.",
|
|
37398
|
-
"Completed work will be reused automatically."
|
|
37399
|
-
);
|
|
37400
|
-
return lines;
|
|
37401
|
-
}
|
|
37402
|
-
function formatInlinePackageValue(value) {
|
|
37403
|
-
const compacted = compactReturnValue(value);
|
|
37404
|
-
const json2 = JSON.stringify(compacted);
|
|
37405
|
-
return clampJsonPreviewText(json2 ?? String(compacted), 500);
|
|
37406
|
-
}
|
|
37407
|
-
function formatPackageValueOutputLines(packaged) {
|
|
37408
|
-
const outputs = packaged.outputs && typeof packaged.outputs === "object" && !Array.isArray(packaged.outputs) ? packaged.outputs : null;
|
|
37409
|
-
if (!outputs) return [];
|
|
37410
|
-
const returned = Object.entries(outputs).filter(([, output2]) => {
|
|
37411
|
-
const record5 = readRecord(output2);
|
|
37412
|
-
return record5?.kind === "dataset" || record5?.kind === "value" && Object.prototype.hasOwnProperty.call(record5, "value");
|
|
37413
|
-
});
|
|
37414
|
-
if (returned.length === 0) return [];
|
|
37415
|
-
const datasets = packageDatasetRecords(packaged);
|
|
37416
|
-
const datasetSteps = readRecordArray(packaged.steps).filter(
|
|
37417
|
-
(step) => step.kind === "dataset"
|
|
37418
|
-
);
|
|
37419
|
-
const lines = [" result:"];
|
|
37420
|
-
for (const [name, rawOutput] of returned.slice(0, 8)) {
|
|
37421
|
-
const output2 = readRecord(rawOutput);
|
|
37422
|
-
if (output2.kind === "dataset") {
|
|
37423
|
-
const path = typeof output2.dataset === "string" ? output2.dataset : name;
|
|
37424
|
-
const rowCount = readNonNegativeInteger(output2.rowCount);
|
|
37425
|
-
lines.push(
|
|
37426
|
-
` ${name}: dataset ${path}${rowCount === null ? "" : ` (${formatInteger(rowCount)} persisted rows)`}`
|
|
37427
|
-
);
|
|
37428
|
-
const dataset = datasets.find(
|
|
37429
|
-
(candidate) => typeof output2.datasetId === "string" && candidate.datasetId === output2.datasetId || candidate.path === path
|
|
37430
|
-
);
|
|
37431
|
-
const stepOutput = datasetSteps.map((step) => readRecord(step.output)).find(
|
|
37432
|
-
(candidate) => typeof output2.datasetId === "string" && candidate?.datasetId === output2.datasetId || candidate?.path === path
|
|
37433
|
-
);
|
|
37434
|
-
const preview = readRecord(stepOutput?.preview ?? dataset?.preview);
|
|
37435
|
-
const rows = Array.isArray(preview?.rows) ? preview.rows.slice(0, 2) : [];
|
|
37436
|
-
if (rows.length > 0) {
|
|
37437
|
-
lines.push(` sample rows (${rows.length}):`);
|
|
37438
|
-
lines.push(
|
|
37439
|
-
...rows.map(
|
|
37440
|
-
(row) => ` ${clampJsonPreviewText(JSON.stringify(row) ?? String(row), 350)}`
|
|
37441
|
-
)
|
|
37442
|
-
);
|
|
37443
|
-
}
|
|
37444
|
-
continue;
|
|
37445
|
-
}
|
|
37446
|
-
const value = output2.value;
|
|
37447
|
-
const compacted = compactReturnValue(value);
|
|
37448
|
-
if (compacted && typeof compacted === "object") {
|
|
37449
|
-
lines.push(` ${name}:`);
|
|
37450
|
-
lines.push(...formatJsonPreview(compacted).map((line) => ` ${line}`));
|
|
37451
|
-
} else {
|
|
37452
|
-
lines.push(` ${name}: ${formatInlinePackageValue(value)}`);
|
|
37453
|
-
}
|
|
37454
|
-
}
|
|
37455
|
-
if (returned.length > 8) {
|
|
37456
|
-
lines.push(` ... ${returned.length - 8} more output(s)`);
|
|
37457
|
-
}
|
|
37458
|
-
return lines;
|
|
37459
|
-
}
|
|
37460
|
-
function authoredPackageStackFrames(packaged) {
|
|
37461
|
-
const stack = readRecordArray(packaged.errors).map((entry) => typeof entry.stack === "string" ? entry.stack : null).find((candidate) => Boolean(candidate?.trim()));
|
|
37462
|
-
if (!stack) return [];
|
|
37463
|
-
return stack.split("\n").map((line) => line.trim()).filter((line) => line.startsWith("at ")).filter(
|
|
37464
|
-
(line) => !line.includes("/virtual/deepline-plays/") && !line.includes("/apps/play-runner/") && !line.includes("/shared_libs/play-runtime/") && !line.includes("node:internal")
|
|
37465
|
-
).slice(0, 5);
|
|
37466
|
-
}
|
|
37467
37126
|
function activityTargetLabel(target) {
|
|
37468
37127
|
const kind = typeof target.kind === "string" ? target.kind : "target";
|
|
37469
37128
|
const label = typeof target.label === "string" ? target.label.trim() : "";
|
|
@@ -37619,152 +37278,6 @@ function formatRunTimingTextLines(run) {
|
|
|
37619
37278
|
].join(" \xB7 ")}`
|
|
37620
37279
|
];
|
|
37621
37280
|
}
|
|
37622
|
-
function formatRecentRunLogLines(value) {
|
|
37623
|
-
const logs = readRecord(value);
|
|
37624
|
-
if (!logs || !Array.isArray(logs.tail)) return [];
|
|
37625
|
-
const tail = logs.tail.filter(
|
|
37626
|
-
(line) => typeof line === "string"
|
|
37627
|
-
);
|
|
37628
|
-
if (tail.length === 0) return [];
|
|
37629
|
-
const shown = tail.map((line) => classifyLogLine(line)).filter(
|
|
37630
|
-
(entry) => entry.level !== "debug" && !isProviderRowWaitLogLine(entry.line)
|
|
37631
|
-
).slice(-8);
|
|
37632
|
-
const total = readNonNegativeInteger(logs.totalCount);
|
|
37633
|
-
if (shown.length === 0) {
|
|
37634
|
-
return [
|
|
37635
|
-
` recent logs: no non-debug lines in the retained preview (${total === null ? "total unknown" : `${formatInteger(total)} total`})`,
|
|
37636
|
-
...logs.truncated === true ? [" [older log bodies lost to retention limit]"] : []
|
|
37637
|
-
];
|
|
37638
|
-
}
|
|
37639
|
-
const lines = [
|
|
37640
|
-
` recent logs (${total === null ? "count unknown" : `${formatInteger(total)} total`}; showing ${shown.length}):`,
|
|
37641
|
-
...shown.map(
|
|
37642
|
-
(entry) => ` ${clampJsonPreviewText(formatProviderCapacityWaitLogLine(entry.line) ?? formatMapProgressDiagnosticLogLine(entry.line) ?? entry.line, 350)}`
|
|
37643
|
-
)
|
|
37644
|
-
];
|
|
37645
|
-
if (logs.truncated === true) {
|
|
37646
|
-
lines.push(" [older log bodies lost to retention limit]");
|
|
37647
|
-
}
|
|
37648
|
-
return lines;
|
|
37649
|
-
}
|
|
37650
|
-
function buildRunPackageTextLines(packaged) {
|
|
37651
|
-
const run = readRunPackageRun(packaged);
|
|
37652
|
-
const runId = typeof run.id === "string" ? run.id : "unknown";
|
|
37653
|
-
const status = typeof run.status === "string" ? run.status : "unknown";
|
|
37654
|
-
const playName = typeof run.playName === "string" ? run.playName : null;
|
|
37655
|
-
const runtimeLimitFailure = readRecordArray(packaged.errors).find(
|
|
37656
|
-
(entry) => entry.code === "RUNTIME_LIMIT_EXCEEDED"
|
|
37657
|
-
);
|
|
37658
|
-
const isRuntimeTimeout = status === "failed" && (runtimeLimitFailure !== void 0 || typeof run.error === "string" && /RUNTIME_LIMIT_EXCEEDED/.test(run.error));
|
|
37659
|
-
const isRuntimeLimitCheckpoint = isRuntimeTimeout;
|
|
37660
|
-
const checkpointFailure = runtimeLimitFailure ?? (typeof run.error === "string" ? { message: run.error } : { message: "The Play reached its runtime limit and was stopped." });
|
|
37661
|
-
const lines = isRuntimeLimitCheckpoint ? runtimeLimitCheckpointLines(packaged, runId, checkpointFailure) : [
|
|
37662
|
-
`${status === "completed" ? "\u2713" : status === "failed" ? "\u2717" : "\u2022"} ${status} ${runId}`
|
|
37663
|
-
];
|
|
37664
|
-
const outcome = typeof run.outcome === "string" ? run.outcome : null;
|
|
37665
|
-
if (outcome) lines.push(` outcome: ${outcome}`);
|
|
37666
|
-
const recovery = readRecord(run.recovery);
|
|
37667
|
-
if (recovery) {
|
|
37668
|
-
const mode = typeof recovery.mode === "string" ? recovery.mode : "recovered";
|
|
37669
|
-
const sourceRunId = typeof recovery.sourceRunId === "string" ? ` from ${recovery.sourceRunId}` : "";
|
|
37670
|
-
lines.push(` recovery: ${mode}${sourceRunId}`);
|
|
37671
|
-
}
|
|
37672
|
-
const runError = typeof run.error === "string" && run.error.trim() ? run.error.trim() : null;
|
|
37673
|
-
const structuredRuntimeLimitMessage = typeof runtimeLimitFailure?.message === "string" && runtimeLimitFailure.message.trim() ? `${typeof runtimeLimitFailure.code === "string" ? runtimeLimitFailure.code : "RUNTIME_LIMIT_EXCEEDED"}: ${runtimeLimitFailure.message.trim()}` : null;
|
|
37674
|
-
const displayRunError = structuredRuntimeLimitMessage ?? runError;
|
|
37675
|
-
if (!isRuntimeLimitCheckpoint && displayRunError && (status === "failed" || status === "cancelled")) {
|
|
37676
|
-
lines.push(` error: ${truncateErrorForDisplay(displayRunError, runId)}`);
|
|
37677
|
-
const stackFrames = authoredPackageStackFrames(packaged);
|
|
37678
|
-
if (stackFrames.length > 0) {
|
|
37679
|
-
lines.push(" stack:");
|
|
37680
|
-
lines.push(...stackFrames.map((frame) => ` ${frame}`));
|
|
37681
|
-
}
|
|
37682
|
-
}
|
|
37683
|
-
const failedLogs = readRecord(packaged.failedLogs);
|
|
37684
|
-
const failedLogEntries = Array.isArray(failedLogs?.entries) ? failedLogs.entries.filter(
|
|
37685
|
-
(entry) => typeof entry === "string"
|
|
37686
|
-
) : [];
|
|
37687
|
-
const failedLogAssociation = typeof failedLogs?.association === "string" ? failedLogs.association : null;
|
|
37688
|
-
const failedLogWarning = typeof failedLogs?.warning === "string" && failedLogs.warning.trim() ? failedLogs.warning.trim() : null;
|
|
37689
|
-
if (failedLogEntries.length > 0) {
|
|
37690
|
-
lines.push(" failed logs:");
|
|
37691
|
-
lines.push(...failedLogEntries.map((entry) => ` ${entry}`));
|
|
37692
|
-
}
|
|
37693
|
-
if (failedLogAssociation === "retained_before_truncation") {
|
|
37694
|
-
lines.push(" failed log context: last retained lines before truncation");
|
|
37695
|
-
}
|
|
37696
|
-
if (failedLogWarning) {
|
|
37697
|
-
lines.push(` warning: ${failedLogWarning}`);
|
|
37698
|
-
}
|
|
37699
|
-
const packageWarnings = Array.isArray(packaged.warnings) ? Array.from(
|
|
37700
|
-
new Set(
|
|
37701
|
-
packaged.warnings.filter(
|
|
37702
|
-
(warning) => typeof warning === "string" && warning.trim().length > 0
|
|
37703
|
-
)
|
|
37704
|
-
)
|
|
37705
|
-
).slice(0, 16) : [];
|
|
37706
|
-
lines.push(...packageWarnings.map((warning) => ` warning: ${warning}`));
|
|
37707
|
-
const failedLogNext = readRecord(failedLogs?.next);
|
|
37708
|
-
if (failedLogWarning && typeof failedLogNext?.logs === "string") {
|
|
37709
|
-
lines.push(
|
|
37710
|
-
failedLogAssociation === "retained_before_truncation" ? ` retained logs: ${failedLogNext.logs}` : ` retry failed logs: ${failedLogNext.logs}`
|
|
37711
|
-
);
|
|
37712
|
-
}
|
|
37713
|
-
if (playName && !isRuntimeLimitCheckpoint) {
|
|
37714
|
-
lines.push(` play: ${playName}`);
|
|
37715
|
-
}
|
|
37716
|
-
lines.push(...formatRunTimingTextLines(run));
|
|
37717
|
-
if (!isRuntimeLimitCheckpoint) {
|
|
37718
|
-
lines.push(...buildRunActivityTextLines(run));
|
|
37719
|
-
}
|
|
37720
|
-
lines.push(...buildRunStatusEvidenceTextLines(packaged));
|
|
37721
|
-
lines.push(...formatPackageValueOutputLines(packaged));
|
|
37722
|
-
lines.push(
|
|
37723
|
-
...formatPackageDatasetActionLines(packaged, {
|
|
37724
|
-
includeSummary: !isRuntimeLimitCheckpoint
|
|
37725
|
-
})
|
|
37726
|
-
);
|
|
37727
|
-
lines.push(...formatRecentRunLogLines(packaged.logs));
|
|
37728
|
-
const next = packaged.next && typeof packaged.next === "object" && !Array.isArray(packaged.next) ? packaged.next : {};
|
|
37729
|
-
const logsCommand = actionToCommand(next.logs);
|
|
37730
|
-
for (const step of isRuntimeLimitCheckpoint ? [] : readRecordArray(packaged.steps).slice(0, 8)) {
|
|
37731
|
-
const id = typeof step.id === "string" ? step.id : "step";
|
|
37732
|
-
const kind = typeof step.kind === "string" ? step.kind : "step";
|
|
37733
|
-
const stepStatus = typeof step.status === "string" ? step.status : status;
|
|
37734
|
-
const output2 = step.output && typeof step.output === "object" && !Array.isArray(step.output) ? step.output : null;
|
|
37735
|
-
const rowCount = output2 && typeof output2.rowCount === "number" ? ` rows=${formatInteger(output2.rowCount)}` : "";
|
|
37736
|
-
const preview = output2?.preview && typeof output2.preview === "object" && !Array.isArray(output2.preview) ? output2.preview : null;
|
|
37737
|
-
const previewRows = Array.isArray(preview?.rows) ? preview.rows.length : null;
|
|
37738
|
-
lines.push(` ${kind} ${id}: ${stepStatus}${rowCount}`);
|
|
37739
|
-
lines.push(...formatPackageDatasetSummaryLines(output2?.summary));
|
|
37740
|
-
if (previewRows !== null) {
|
|
37741
|
-
lines.push(
|
|
37742
|
-
` preview=${previewRows}${preview?.truncated ? " truncated" : ""}`
|
|
37743
|
-
);
|
|
37744
|
-
}
|
|
37745
|
-
}
|
|
37746
|
-
const inspectCommand = actionToCommand(next.inspect);
|
|
37747
|
-
const fullResultCommand = actionToCommand(next.full);
|
|
37748
|
-
const hasCatalogExportAction = packageDatasetRecords(packaged).some(
|
|
37749
|
-
(dataset) => Boolean(actionToCommand(readRecord(dataset.actions)?.exportCsv))
|
|
37750
|
-
);
|
|
37751
|
-
const legacyExportCommand = hasCatalogExportAction ? null : actionToCommand(next.export);
|
|
37752
|
-
const runAgainCommand = typeof next.run === "string" && next.run.trim() ? next.run.trim() : null;
|
|
37753
|
-
if (inspectCommand) lines.push(` inspect: ${inspectCommand}`);
|
|
37754
|
-
if (fullResultCommand)
|
|
37755
|
-
lines.push(
|
|
37756
|
-
` ${isRuntimeTimeout ? "full run details" : "full result"}: ${fullResultCommand}`
|
|
37757
|
-
);
|
|
37758
|
-
if (logsCommand) lines.push(` logs: ${logsCommand}`);
|
|
37759
|
-
if (legacyExportCommand) {
|
|
37760
|
-
lines.push(` export CSV: ${legacyExportCommand}`);
|
|
37761
|
-
}
|
|
37762
|
-
if (runAgainCommand && !isRuntimeLimitCheckpoint) {
|
|
37763
|
-
lines.push(" run again (completed work is reused):");
|
|
37764
|
-
lines.push(` ${runAgainCommand}`);
|
|
37765
|
-
}
|
|
37766
|
-
return lines;
|
|
37767
|
-
}
|
|
37768
37281
|
function buildOrdinaryPlayRunCommand(options, resolvedRevisionId) {
|
|
37769
37282
|
const target = options.target.kind === "file" ? options.target.path : options.target.name;
|
|
37770
37283
|
const parts = ["deepline", "plays", "run", shellSingleQuote(target)];
|
|
@@ -37850,6 +37363,57 @@ function buildRunLaunch(status) {
|
|
|
37850
37363
|
)
|
|
37851
37364
|
};
|
|
37852
37365
|
}
|
|
37366
|
+
function buildPlayCompletionTextLines(status) {
|
|
37367
|
+
const overview = buildRunOverview(status);
|
|
37368
|
+
const { run } = overview;
|
|
37369
|
+
const failed = run.status === "failed";
|
|
37370
|
+
const label = run.status === "completed" ? overview.rowOutcomes?.hasRowFailures ? "Completed with row failures" : "Completed" : failed ? "Failed" : run.status;
|
|
37371
|
+
const lines = [
|
|
37372
|
+
`${label} ${run.playName ?? status.playName ?? "Play"}`,
|
|
37373
|
+
`Run: ${run.id}`
|
|
37374
|
+
];
|
|
37375
|
+
for (const failure of overview.failures.steps) {
|
|
37376
|
+
lines.push(
|
|
37377
|
+
`Failed step: ${failure.stepId}${failure.message ? ` \u2014 ${failure.message}` : ""}`
|
|
37378
|
+
);
|
|
37379
|
+
}
|
|
37380
|
+
if (overview.errorDetails.run)
|
|
37381
|
+
lines.push(
|
|
37382
|
+
`Error: ${truncateErrorForDisplay(overview.errorDetails.run, run.id)}`
|
|
37383
|
+
);
|
|
37384
|
+
if (Object.hasOwn(overview, "result")) {
|
|
37385
|
+
lines.push(
|
|
37386
|
+
"Result:",
|
|
37387
|
+
...formatJsonPreview(compactReturnValue(overview.result))
|
|
37388
|
+
);
|
|
37389
|
+
}
|
|
37390
|
+
if (overview.rowOutcomes?.hasRowFailures) {
|
|
37391
|
+
lines.push(
|
|
37392
|
+
`Rows: ${overview.rowOutcomes.completedRows} completed, ${overview.rowOutcomes.failedRows} failed`
|
|
37393
|
+
);
|
|
37394
|
+
}
|
|
37395
|
+
for (const dataset of overview.datasets) {
|
|
37396
|
+
lines.push(
|
|
37397
|
+
`Rows (${dataset.name ?? dataset.datasetId}): ${dataset.rowCount ?? "unknown"}`
|
|
37398
|
+
);
|
|
37399
|
+
if (dataset.exportUnavailable)
|
|
37400
|
+
lines.push(`Export unavailable: ${dataset.exportUnavailable.message}`);
|
|
37401
|
+
}
|
|
37402
|
+
for (const warning of overview.warnings) lines.push(`Warning: ${warning}`);
|
|
37403
|
+
const exports2 = overview.actions.exportDatasetCmds;
|
|
37404
|
+
if (Array.isArray(exports2))
|
|
37405
|
+
for (const command of exports2) lines.push(`Export CSV: ${command}`);
|
|
37406
|
+
lines.push(
|
|
37407
|
+
`Logs: ${failed ? String(
|
|
37408
|
+
overview.actions.getFailedLogsCmd ?? `deepline runs logs ${shellSingleQuote(run.id)} --failed`
|
|
37409
|
+
) : String(
|
|
37410
|
+
overview.actions.getLogsCmd ?? `deepline runs logs ${shellSingleQuote(run.id)}`
|
|
37411
|
+
)}`
|
|
37412
|
+
);
|
|
37413
|
+
if (failed && status.rerunCommand)
|
|
37414
|
+
lines.push(`Retry: ${status.rerunCommand}`);
|
|
37415
|
+
return lines;
|
|
37416
|
+
}
|
|
37853
37417
|
function writePlayResult(status, jsonOutput, options) {
|
|
37854
37418
|
const packaged = getPlayRunPackage(status);
|
|
37855
37419
|
const hits = options?.hits ?? null;
|
|
@@ -37868,10 +37432,7 @@ function writePlayResult(status, jsonOutput, options) {
|
|
|
37868
37432
|
...displayPackage
|
|
37869
37433
|
} = compactPlayStatus(status);
|
|
37870
37434
|
const lines2 = [
|
|
37871
|
-
...
|
|
37872
|
-
buildRunPackageTextLines(displayPackage),
|
|
37873
|
-
status
|
|
37874
|
-
),
|
|
37435
|
+
...buildPlayCompletionTextLines(status),
|
|
37875
37436
|
...formatRunHitsLines(hits)
|
|
37876
37437
|
];
|
|
37877
37438
|
printCommandEnvelope(displayPackage, {
|
|
@@ -37907,7 +37468,7 @@ function writePlayResult(status, jsonOutput, options) {
|
|
|
37907
37468
|
)
|
|
37908
37469
|
);
|
|
37909
37470
|
if (status.status === "failed") {
|
|
37910
|
-
lines.push(` failed logs: deepline runs
|
|
37471
|
+
lines.push(` failed logs: deepline runs logs ${runId} --failed --json`);
|
|
37911
37472
|
if (status.rerunCommand) {
|
|
37912
37473
|
lines.push(" run again (completed work is reused):");
|
|
37913
37474
|
lines.push(` ${status.rerunCommand}`);
|
|
@@ -37937,18 +37498,23 @@ function writePlayResult(status, jsonOutput, options) {
|
|
|
37937
37498
|
);
|
|
37938
37499
|
}
|
|
37939
37500
|
function withRunNavigationLines(lines, status, actionCommands = buildRunNavigation(status).actions) {
|
|
37940
|
-
const navigation = buildRunNavigation(status);
|
|
37941
37501
|
const existing = lines.join("\n");
|
|
37942
|
-
|
|
37943
|
-
|
|
37944
|
-
|
|
37945
|
-
|
|
37946
|
-
|
|
37947
|
-
|
|
37502
|
+
const labels = {
|
|
37503
|
+
getRunCmd: "Inspect",
|
|
37504
|
+
getFullRunCmd: "Full run",
|
|
37505
|
+
getBillingCmd: "Billing",
|
|
37506
|
+
getLogsCmd: "Logs",
|
|
37507
|
+
getFailedLogsCmd: "Failure logs",
|
|
37508
|
+
getReceiptCmd: "Saved responses",
|
|
37509
|
+
exportDatasetCmds: "Export rows",
|
|
37510
|
+
queryTableSqlCmds: "Query rows",
|
|
37511
|
+
stopRunCmd: "Stop run",
|
|
37512
|
+
rerunCmd: "Retry"
|
|
37513
|
+
};
|
|
37948
37514
|
for (const [name, value] of Object.entries(actionCommands)) {
|
|
37949
37515
|
for (const command of Array.isArray(value) ? value : [value]) {
|
|
37950
37516
|
if (typeof command === "string" && !existing.includes(command))
|
|
37951
|
-
lines.push(` ${name}: ${command}`);
|
|
37517
|
+
lines.push(` ${labels[name] ?? name}: ${command}`);
|
|
37952
37518
|
}
|
|
37953
37519
|
}
|
|
37954
37520
|
return lines;
|
|
@@ -38691,7 +38257,12 @@ function writeStartedPlayRun(input2) {
|
|
|
38691
38257
|
failedLogs: _failedLogs,
|
|
38692
38258
|
...displayPackage
|
|
38693
38259
|
} = input2.package;
|
|
38694
|
-
const lines2 =
|
|
38260
|
+
const lines2 = buildPlayCompletionTextLines({
|
|
38261
|
+
runId: input2.runId,
|
|
38262
|
+
playName: input2.playName,
|
|
38263
|
+
status: input2.status,
|
|
38264
|
+
package: displayPackage
|
|
38265
|
+
});
|
|
38695
38266
|
const output3 = lines2.join("\n");
|
|
38696
38267
|
if (input2.progress) {
|
|
38697
38268
|
input2.progress.writeLine(output3, process.stdout);
|
|
@@ -38719,17 +38290,11 @@ function writeStartedPlayRun(input2) {
|
|
|
38719
38290
|
};
|
|
38720
38291
|
const lines = [
|
|
38721
38292
|
`Started ${input2.playName}`,
|
|
38722
|
-
`
|
|
38723
|
-
`
|
|
38724
|
-
` input: ${input2.inputFieldCount ?? 0} top-level field(s) supplied`,
|
|
38725
|
-
` cache: ${input2.forceToolRefresh ? "completed provider receipts may be refreshed" : input2.force ? "fresh run graph; completed provider receipts may still be reused" : "completed provider receipts may be reused"}`,
|
|
38726
|
-
` inspect: deepline runs get ${input2.runId} --json`,
|
|
38727
|
-
` full debug: deepline runs get ${input2.runId} --full --json`,
|
|
38728
|
-
` logs: deepline runs logs ${input2.runId} --json`,
|
|
38729
|
-
` export after completion: deepline runs export ${input2.runId} --out output.csv`,
|
|
38293
|
+
`Run: ${input2.runId}`,
|
|
38294
|
+
`Logs: deepline runs logs ${shellSingleQuote(input2.runId)}`,
|
|
38730
38295
|
...["started", "queued", "running", "waiting"].includes(
|
|
38731
38296
|
input2.status ?? "started"
|
|
38732
|
-
) ? [`
|
|
38297
|
+
) ? [`Stop: deepline runs stop ${shellSingleQuote(input2.runId)} --json`] : []
|
|
38733
38298
|
];
|
|
38734
38299
|
if (input2.jsonOutput) {
|
|
38735
38300
|
printCommandEnvelope(payload, { json: true, fields: input2.jsonFields });
|
|
@@ -40151,7 +39716,7 @@ function renderRunOverviewText(overview, extras = {}) {
|
|
|
40151
39716
|
getBillingCmd: "Billing",
|
|
40152
39717
|
getLogsCmd: "Logs",
|
|
40153
39718
|
getFailedLogsCmd: "Failure logs",
|
|
40154
|
-
getReceiptCmd: "
|
|
39719
|
+
getReceiptCmd: "Saved responses",
|
|
40155
39720
|
exportDatasetCmds: "Export rows",
|
|
40156
39721
|
queryTableSqlCmds: "Query rows",
|
|
40157
39722
|
stopRunCmd: "Stop run",
|
|
@@ -40173,7 +39738,7 @@ async function handleRunGet(args) {
|
|
|
40173
39738
|
args.includes("--config") ? "config" : "get"
|
|
40174
39739
|
);
|
|
40175
39740
|
args = selection.args;
|
|
40176
|
-
const usage2 = "Usage: deepline runs get <run-id> [--json] [--full] [--input] [--config]
|
|
39741
|
+
const usage2 = "Usage: deepline runs get <run-id> [--json] [--full] [--input] [--config]";
|
|
40177
39742
|
let runId;
|
|
40178
39743
|
try {
|
|
40179
39744
|
runId = parseRunIdPositional(args, usage2);
|
|
@@ -43182,7 +42747,7 @@ Examples:
|
|
|
43182
42747
|
deepline runs get play/my-play/run/20260501t000000-000
|
|
43183
42748
|
deepline runs get play/my-play/run/20260501t000000-000 --json
|
|
43184
42749
|
deepline runs get play/my-play/run/20260501t000000-000 --json run.status,run.durationMs
|
|
43185
|
-
deepline runs
|
|
42750
|
+
deepline runs logs play/my-play/run/20260501t000000-000 --failed --json
|
|
43186
42751
|
deepline runs get play/my-play/run/20260501t000000-000 --full --json
|
|
43187
42752
|
deepline runs get play/my-play/run/20260501t000000-000 --input
|
|
43188
42753
|
deepline runs get play/my-play/run/20260501t000000-000 --config --json
|
|
@@ -43199,9 +42764,8 @@ Examples:
|
|
|
43199
42764
|
).option(
|
|
43200
42765
|
"--config",
|
|
43201
42766
|
"Explicitly print the recorded configuration, without full results"
|
|
43202
|
-
).
|
|
43203
|
-
"--log-failed",
|
|
43204
|
-
"Attach a bounded terminal-failure log window for failed runs"
|
|
42767
|
+
).addOption(
|
|
42768
|
+
new import_commander4.Option("--log-failed", "Attach terminal-failure logs").hideHelp()
|
|
43205
42769
|
).action(async (runId, options) => {
|
|
43206
42770
|
process.exitCode = await handleRunGet([
|
|
43207
42771
|
runId,
|
|
@@ -50587,7 +50151,10 @@ Examples:
|
|
|
50587
50151
|
`
|
|
50588
50152
|
Notes:
|
|
50589
50153
|
Shows the compact agent contract by default: what the tool does, cost,
|
|
50590
|
-
required inputs, play getters, and
|
|
50154
|
+
required inputs, play getters, input and full Deepline response examples,
|
|
50155
|
+
and a ctx.tools.execute snippet. Tool responses live at toolResponse.rawV2;
|
|
50156
|
+
preserve the nesting shown in the tool's example. Schemas and examples are
|
|
50157
|
+
separate describe fields.
|
|
50591
50158
|
get is accepted as a compatibility alias for describe.
|
|
50592
50159
|
|
|
50593
50160
|
Examples:
|
|
@@ -50610,7 +50177,7 @@ Examples:
|
|
|
50610
50177
|
"Quote an ai_evaluate, ai_inference, or deeplineagent JSON payload (inline or @file)"
|
|
50611
50178
|
).option("--pricing-only", "Only print pricing and billing semantics").option("--schema-only", "Only print input schema fields").option(
|
|
50612
50179
|
"--examples-only",
|
|
50613
|
-
"Only print
|
|
50180
|
+
"Only print input payload and full Deepline execution response examples"
|
|
50614
50181
|
).option("--getters-only", "Only print extracted list/value getters").addOption(
|
|
50615
50182
|
new import_commander5.Option(
|
|
50616
50183
|
"--compact",
|
|
@@ -50787,6 +50354,30 @@ async function getTool(toolId, options = {}) {
|
|
|
50787
50354
|
);
|
|
50788
50355
|
return 0;
|
|
50789
50356
|
}
|
|
50357
|
+
if ((options.schemaOnly || options.examplesOnly || options.gettersOnly) && !isMonitorTypeTool(tool) && !isPlayLikeTool(tool) && (options.json || options.contractJson)) {
|
|
50358
|
+
const contract = toolContractJsonForDescribe(tool, toolId);
|
|
50359
|
+
printCompactJson({
|
|
50360
|
+
toolId: contract.toolId,
|
|
50361
|
+
...options.schemaOnly ? {
|
|
50362
|
+
inputSchema: contract.inputSchema,
|
|
50363
|
+
inputFields: contract.inputFields,
|
|
50364
|
+
outputSchema: contract.outputSchema,
|
|
50365
|
+
outputFields: contract.outputFields,
|
|
50366
|
+
responseSchema: contract.responseSchema
|
|
50367
|
+
} : options.examplesOnly ? {
|
|
50368
|
+
examples: contract.examples ?? [],
|
|
50369
|
+
responseAccess: contract.responseAccess,
|
|
50370
|
+
getters: contract.getters,
|
|
50371
|
+
executeCommand: contract.executeCommand
|
|
50372
|
+
} : {
|
|
50373
|
+
getters: contract.getters,
|
|
50374
|
+
responseAccess: contract.responseAccess
|
|
50375
|
+
},
|
|
50376
|
+
...modelDescription ? { modelOptions: modelDescription } : {},
|
|
50377
|
+
...inferenceQuote ? { inferenceQuote } : {}
|
|
50378
|
+
});
|
|
50379
|
+
return 0;
|
|
50380
|
+
}
|
|
50790
50381
|
if (options.contractJson) {
|
|
50791
50382
|
printCompactJson({
|
|
50792
50383
|
...toolContractJsonForDescribe(tool, toolId),
|
|
@@ -50928,6 +50519,9 @@ function toolContractJsonForDescribe(tool, requestedToolId) {
|
|
|
50928
50519
|
} : {},
|
|
50929
50520
|
inputFields: inputFields.map(inputFieldJsonForDescribe),
|
|
50930
50521
|
inputSchema,
|
|
50522
|
+
...isRecord8(tool.responseSchema) ? { responseSchema: tool.responseSchema } : {},
|
|
50523
|
+
...Array.isArray(tool.examples) ? { examples: tool.examples } : {},
|
|
50524
|
+
responseAccess: "result.toolResponse.rawV2",
|
|
50931
50525
|
...Object.keys(outputSchemaRecord).length > 0 ? {
|
|
50932
50526
|
outputSchema: publicToolInputSchemaForDescribe(outputSchemaRecord),
|
|
50933
50527
|
outputFields: outputFields.map(inputFieldJsonForDescribe)
|
|
@@ -51149,15 +50743,13 @@ function printCompactToolContract(tool, requestedToolId) {
|
|
|
51149
50743
|
}
|
|
51150
50744
|
}
|
|
51151
50745
|
console.log("");
|
|
51152
|
-
printToolExamplesOnly(tool, requestedToolId
|
|
50746
|
+
printToolExamplesOnly(tool, requestedToolId);
|
|
51153
50747
|
const starterScript = isRecord8(contract.starterScript) ? contract.starterScript : {};
|
|
51154
50748
|
const starterPath = stringField2(starterScript, "path");
|
|
51155
50749
|
if (starterPath) {
|
|
51156
50750
|
console.log("");
|
|
51157
50751
|
console.log(`Starter script: ${starterPath}`);
|
|
51158
|
-
console.log(
|
|
51159
|
-
"Copy it into your project and replace the sample input with the proven probe payload."
|
|
51160
|
-
);
|
|
50752
|
+
console.log("Copy it into your project and adapt the example input.");
|
|
51161
50753
|
}
|
|
51162
50754
|
if (listGetters.length || valueGetters.length) {
|
|
51163
50755
|
console.log("");
|
|
@@ -51247,11 +50839,15 @@ function printToolSchemaOnly(tool, requestedToolId) {
|
|
|
51247
50839
|
recordField(contract, "inputSchema")
|
|
51248
50840
|
);
|
|
51249
50841
|
if (declaredSchema) {
|
|
51250
|
-
console.log("Declared JSON Schema:");
|
|
50842
|
+
console.log("Declared input JSON Schema:");
|
|
51251
50843
|
console.log(JSON.stringify(declaredSchema, null, 2));
|
|
51252
50844
|
}
|
|
50845
|
+
if (isRecord8(contract.responseSchema)) {
|
|
50846
|
+
console.log("Deepline execution response JSON Schema:");
|
|
50847
|
+
console.log(JSON.stringify(contract.responseSchema, null, 2));
|
|
50848
|
+
}
|
|
51253
50849
|
}
|
|
51254
|
-
function printToolExamplesOnly(tool, requestedToolId
|
|
50850
|
+
function printToolExamplesOnly(tool, requestedToolId) {
|
|
51255
50851
|
if (isMonitorTypeTool(tool)) {
|
|
51256
50852
|
printMonitorTypeDeploy(tool);
|
|
51257
50853
|
return;
|
|
@@ -51263,7 +50859,11 @@ function printToolExamplesOnly(tool, requestedToolId, options = {}) {
|
|
|
51263
50859
|
const contract = toolContractJsonForDescribe(tool, requestedToolId);
|
|
51264
50860
|
const toolId = String(contract.toolId);
|
|
51265
50861
|
const inputFields = Array.isArray(contract.inputFields) ? contract.inputFields : [];
|
|
51266
|
-
const
|
|
50862
|
+
const examples = arrayField2(tool, "examples").filter(isRecord8);
|
|
50863
|
+
const firstExample = examples[0];
|
|
50864
|
+
const sampleInput = firstExample && isRecord8(firstExample.input) ? firstExample.input : samplePayload(recordField(tool, "samples"), "request") ?? samplePayloadForInputFields(inputFields);
|
|
50865
|
+
console.log("Example input payload:");
|
|
50866
|
+
console.log(JSON.stringify(sampleInput, null, 2));
|
|
51267
50867
|
console.log(`Use in a play:`);
|
|
51268
50868
|
console.log("```ts");
|
|
51269
50869
|
console.log("const result = await ctx.tools.execute({");
|
|
@@ -51273,6 +50873,7 @@ function printToolExamplesOnly(tool, requestedToolId, options = {}) {
|
|
|
51273
50873
|
` input: ${JSON.stringify(sampleInput || {}, null, 2).replace(/\n/g, "\n ")},`
|
|
51274
50874
|
);
|
|
51275
50875
|
console.log("});");
|
|
50876
|
+
console.log("const response = result.toolResponse.rawV2;");
|
|
51276
50877
|
const getters = isRecord8(contract.getters) ? contract.getters : {};
|
|
51277
50878
|
const valueGetters = Array.isArray(getters.extractedValues) ? getters.extractedValues : [];
|
|
51278
50879
|
const listGetters = Array.isArray(getters.extractedLists) ? getters.extractedLists : [];
|
|
@@ -51286,10 +50887,19 @@ function printToolExamplesOnly(tool, requestedToolId, options = {}) {
|
|
|
51286
50887
|
);
|
|
51287
50888
|
}
|
|
51288
50889
|
console.log("```");
|
|
51289
|
-
|
|
51290
|
-
const
|
|
51291
|
-
|
|
50890
|
+
for (const example of examples) {
|
|
50891
|
+
const description = stringField2(example, "description");
|
|
50892
|
+
if (description) console.log(description);
|
|
50893
|
+
console.log("Example Deepline execution response:");
|
|
50894
|
+
console.log(JSON.stringify(example.response, null, 2));
|
|
51292
50895
|
}
|
|
50896
|
+
if (!examples.length)
|
|
50897
|
+
console.log(
|
|
50898
|
+
"No Deepline execution response example is published by this server."
|
|
50899
|
+
);
|
|
50900
|
+
console.log(
|
|
50901
|
+
"Read tool-specific fields from result.toolResponse.rawV2 using the nesting above. In a play, use the declared getters for extracted values and lists. Billing and execution metadata may also be returned."
|
|
50902
|
+
);
|
|
51293
50903
|
}
|
|
51294
50904
|
function printPlayLikeToolUsage(tool, requestedToolId) {
|
|
51295
50905
|
const toolId = String(tool.toolId || requestedToolId);
|
|
@@ -51434,9 +51044,9 @@ function toolMetadataJsonForDescribe(tool, requestedToolId) {
|
|
|
51434
51044
|
inputFields: inputFields.map(inputFieldJsonForDescribe),
|
|
51435
51045
|
usageGuidance,
|
|
51436
51046
|
runtimeOutputHelp: {
|
|
51437
|
-
contract: "
|
|
51047
|
+
contract: "Schemas declare field shapes. Examples illustrate input payloads and full Deepline execution responses; they are not observed responses from this call.",
|
|
51438
51048
|
getterScope: "extractedValues/extractedLists .get() only works for declared Deepline getters listed in usageGuidance.toolExecutionResult.",
|
|
51439
|
-
rawToolResponse: "Use toolExecutionResult.toolResponse.rawV2 for
|
|
51049
|
+
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.",
|
|
51440
51050
|
invalidGetterHint: "If TypeScript says an extractedValues/extractedLists property does not exist, that field is not a declared Deepline getter.",
|
|
51441
51051
|
observeActualShape: observedOutputCommand,
|
|
51442
51052
|
observedOutput: observedOutputCommand,
|
|
@@ -51451,7 +51061,25 @@ function usageGuidanceWithAccessDefaults(usageGuidance) {
|
|
|
51451
51061
|
const existingAccess = recordField(usageGuidance, "access");
|
|
51452
51062
|
return {
|
|
51453
51063
|
...usageGuidance,
|
|
51064
|
+
prefer: [
|
|
51065
|
+
"Use only the declared extractedLists and extractedValues getters listed below.",
|
|
51066
|
+
"Use toolExecutionResult.toolResponse.rawV2 for the complete tool response, preserving the nesting shown in the response example.",
|
|
51067
|
+
"Schemas declare field shapes; examples illustrate input values and full Deepline execution responses."
|
|
51068
|
+
],
|
|
51069
|
+
toolExecutionResult: {
|
|
51070
|
+
...recordField(
|
|
51071
|
+
usageGuidance,
|
|
51072
|
+
"toolExecutionResult",
|
|
51073
|
+
"tool_execution_result"
|
|
51074
|
+
),
|
|
51075
|
+
toolResponse: {
|
|
51076
|
+
rawV2: "toolResponse.rawV2",
|
|
51077
|
+
view: "toolResponse.view",
|
|
51078
|
+
responseMeta: "toolResponse.responseMeta"
|
|
51079
|
+
}
|
|
51080
|
+
},
|
|
51454
51081
|
access: {
|
|
51082
|
+
...existingAccess,
|
|
51455
51083
|
extractedLists: {
|
|
51456
51084
|
expression: "toolExecutionResult.extractedLists.<name>.get()",
|
|
51457
51085
|
meaning: "Declared Deepline list extractors only."
|
|
@@ -51463,13 +51091,13 @@ function usageGuidanceWithAccessDefaults(usageGuidance) {
|
|
|
51463
51091
|
...existingAccess,
|
|
51464
51092
|
rawToolResponse: {
|
|
51465
51093
|
expression: "toolExecutionResult.toolResponse.rawV2",
|
|
51466
|
-
meaning: "Complete
|
|
51094
|
+
meaning: "Complete tool response with its original nesting. Read tool-specific fields here; use declared getters for extracted values and lists."
|
|
51467
51095
|
},
|
|
51468
51096
|
canonicalToolResponse: {
|
|
51469
51097
|
expression: "toolExecutionResult.toolResponse.rawV2",
|
|
51470
|
-
meaning: "Complete
|
|
51098
|
+
meaning: "Complete tool response with its original nesting and sibling fields."
|
|
51471
51099
|
},
|
|
51472
|
-
invalidGetterHint: "If TypeScript says an extractedValues/extractedLists property does not exist, that field is not a declared Deepline getter;
|
|
51100
|
+
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."
|
|
51473
51101
|
}
|
|
51474
51102
|
};
|
|
51475
51103
|
}
|
|
@@ -51801,23 +51429,6 @@ function formatRateWindow(windowMs) {
|
|
|
51801
51429
|
if (windowMs === 36e5) return "hour";
|
|
51802
51430
|
return `${windowMs}ms`;
|
|
51803
51431
|
}
|
|
51804
|
-
function printSamples(samples) {
|
|
51805
|
-
const requestPayload = samplePayload(samples, "request");
|
|
51806
|
-
const responsePayload = samplePayload(samples, "response");
|
|
51807
|
-
if (requestPayload === void 0 && responsePayload === void 0) return;
|
|
51808
|
-
console.log(" Samples:");
|
|
51809
|
-
if (requestPayload !== void 0)
|
|
51810
|
-
printJsonPreview("Example payload", requestPayload);
|
|
51811
|
-
if (responsePayload !== void 0)
|
|
51812
|
-
printJsonPreview("Example response", responsePayload);
|
|
51813
|
-
}
|
|
51814
|
-
function printJsonPreview(label, payload) {
|
|
51815
|
-
console.log(` ${label}:`);
|
|
51816
|
-
const rendered = JSON.stringify(payload, null, 2);
|
|
51817
|
-
for (const line of rendered.split("\n")) {
|
|
51818
|
-
console.log(` ${line}`);
|
|
51819
|
-
}
|
|
51820
|
-
}
|
|
51821
51432
|
function samplePayload(samples, key) {
|
|
51822
51433
|
const entry = samples[key];
|
|
51823
51434
|
if (!isRecord8(entry)) return void 0;
|