deepline 0.3.290 → 0.3.292
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 +209 -588
- package/dist/cli/index.mjs +209 -588
- 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.292",
|
|
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,
|
|
@@ -11518,6 +11520,9 @@ function errorToJsonPayload(error) {
|
|
|
11518
11520
|
if (maybeRecord?.details && typeof maybeRecord.details === "object" && !Array.isArray(maybeRecord.details)) {
|
|
11519
11521
|
details.details = maybeRecord.details;
|
|
11520
11522
|
}
|
|
11523
|
+
if (maybeRecord?.guidance && typeof maybeRecord.guidance === "object" && !Array.isArray(maybeRecord.guidance)) {
|
|
11524
|
+
details.guidance = maybeRecord.guidance;
|
|
11525
|
+
}
|
|
11521
11526
|
const providerConcurrency = providerConcurrencyDiagnostic(maybeRecord);
|
|
11522
11527
|
if (providerConcurrency) {
|
|
11523
11528
|
details.providerConcurrency = providerConcurrency;
|
|
@@ -15086,7 +15091,9 @@ async function handleDbQuery(args) {
|
|
|
15086
15091
|
actions: [{ label: "Tool equivalent", command: toolCommand }]
|
|
15087
15092
|
}
|
|
15088
15093
|
},
|
|
15089
|
-
{
|
|
15094
|
+
{
|
|
15095
|
+
json: explicitJsonOutput || format === "json" || format !== "table" && jsonOutput
|
|
15096
|
+
}
|
|
15090
15097
|
);
|
|
15091
15098
|
return 0;
|
|
15092
15099
|
}
|
|
@@ -15162,8 +15169,9 @@ Examples:
|
|
|
15162
15169
|
"after",
|
|
15163
15170
|
`
|
|
15164
15171
|
Notes:
|
|
15165
|
-
Requires --sql (inline SQL or @file.sql). Output
|
|
15166
|
-
|
|
15172
|
+
Requires --sql (inline SQL or @file.sql). Output defaults to a compact table in a terminal
|
|
15173
|
+
and JSON when stdout is piped. --format table forces a table even in pipes.
|
|
15174
|
+
--json overrides --format for stdout. The active auth workspace determines scope.
|
|
15167
15175
|
Read permitted schemas with SELECT, EXPLAIN, or read-only WITH.
|
|
15168
15176
|
Write only to schema-qualified storage tables. For example, use
|
|
15169
15177
|
CREATE TABLE storage.blocked (...) instead of CREATE TABLE blocked (...).
|
|
@@ -21734,7 +21742,7 @@ var KIND_DESCRIPTIONS = {
|
|
|
21734
21742
|
"dataset.lifecycle": "Dataset registered, available or failed.",
|
|
21735
21743
|
"activity.observed": "Provider or workflow activity.",
|
|
21736
21744
|
"work.counters": "Call, request and rate-limit totals.",
|
|
21737
|
-
"receipt.completed": "Saved
|
|
21745
|
+
"receipt.completed": "Saved result or call details.",
|
|
21738
21746
|
"receipt.failed": "Saved work result: failed.",
|
|
21739
21747
|
"receipt.skipped": "Saved work result: skipped.",
|
|
21740
21748
|
"runtime.event": "Other event."
|
|
@@ -21775,6 +21783,10 @@ var FILTER_EXAMPLES = [
|
|
|
21775
21783
|
{
|
|
21776
21784
|
label: "One run and step",
|
|
21777
21785
|
command: `deepline runs logs '<run-id>' --where '$.stepId == "company-lookup"' --json`
|
|
21786
|
+
},
|
|
21787
|
+
{
|
|
21788
|
+
label: "Error logs for one step",
|
|
21789
|
+
command: `deepline runs logs --kind log.appended --where '$.level == "error" && $.stepId == "company-lookup"' --payloads --json`
|
|
21778
21790
|
}
|
|
21779
21791
|
];
|
|
21780
21792
|
function wrapParagraph(text) {
|
|
@@ -21795,10 +21807,14 @@ function renderRunLogsHelp() {
|
|
|
21795
21807
|
"",
|
|
21796
21808
|
"Examples:",
|
|
21797
21809
|
` ${READ_EXAMPLES[0]}`,
|
|
21810
|
+
` deepline runs logs --where '$.eventId == "receipt:5a32ee1a-46cf-4853-b72b-5f1d782ffab4"' --payloads --json`,
|
|
21798
21811
|
" deepline runs logs --kind run.failed --json",
|
|
21799
|
-
...[
|
|
21800
|
-
|
|
21801
|
-
|
|
21812
|
+
...[
|
|
21813
|
+
FILTER_EXAMPLES[1],
|
|
21814
|
+
FILTER_EXAMPLES[2],
|
|
21815
|
+
FILTER_EXAMPLES[5],
|
|
21816
|
+
FILTER_EXAMPLES[7]
|
|
21817
|
+
].map(({ command }) => ` ${command}`),
|
|
21802
21818
|
"",
|
|
21803
21819
|
"Event kinds:",
|
|
21804
21820
|
...RUN_LOGS_KIND_HELP.map(
|
|
@@ -21817,6 +21833,7 @@ function renderRunLogsHelp() {
|
|
|
21817
21833
|
"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
21834
|
"Defaults to the last hour; maximum lookback is seven days. Follow next.logs for events; use nextCursor with --cursor for older text logs.",
|
|
21819
21835
|
"--payloads returns available details or saved results: up to 10 events and 16 MiB.",
|
|
21836
|
+
"To read one exact saved result, filter by its returned eventId and add --payloads.",
|
|
21820
21837
|
"--out, --failed and --log-level apply to text logs and cannot be combined with event search."
|
|
21821
21838
|
].map((note) => wrapParagraph(note)),
|
|
21822
21839
|
"",
|
|
@@ -22149,13 +22166,6 @@ var DATASET_EXECUTION_BUCKETS = [
|
|
|
22149
22166
|
"skipped:missed",
|
|
22150
22167
|
"failed"
|
|
22151
22168
|
];
|
|
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
22169
|
|
|
22160
22170
|
// src/runs/overview.ts
|
|
22161
22171
|
var record3 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
@@ -22174,7 +22184,7 @@ function lifecycleActions(status, id, state) {
|
|
|
22174
22184
|
return {
|
|
22175
22185
|
...["started", "queued", "running", "waiting"].includes(state ?? "") ? { stopRunCmd: `deepline runs stop ${id} --json` } : {},
|
|
22176
22186
|
...state === "failed" ? {
|
|
22177
|
-
getFailedLogsCmd: `deepline runs
|
|
22187
|
+
getFailedLogsCmd: `deepline runs logs ${id} --failed --json`,
|
|
22178
22188
|
...status.rerunCommand ? { rerunCmd: status.rerunCommand } : {}
|
|
22179
22189
|
} : {}
|
|
22180
22190
|
};
|
|
@@ -22377,7 +22387,7 @@ function buildRunOverview(status, fullStatus) {
|
|
|
22377
22387
|
);
|
|
22378
22388
|
return {
|
|
22379
22389
|
datasetId: dataset.datasetId,
|
|
22380
|
-
name: dataset.tableNamespace,
|
|
22390
|
+
name: dataset.tableNamespace ?? (typeof stepOutput?.tableNamespace === "string" ? stepOutput.tableNamespace : dataset.path),
|
|
22381
22391
|
stepId: step?.id ?? named[0]?.[1].stepId,
|
|
22382
22392
|
rowCount: dataset.rowCount ?? null,
|
|
22383
22393
|
...dataset.lifecycle ? { lifecycle: dataset.lifecycle } : {},
|
|
@@ -22471,7 +22481,7 @@ function buildRunOverview(status, fullStatus) {
|
|
|
22471
22481
|
function receiptAction(id) {
|
|
22472
22482
|
const quotedId = `'${id.replace(/'/g, "'\\''")}'`;
|
|
22473
22483
|
return {
|
|
22474
|
-
getReceiptCmd: `deepline runs
|
|
22484
|
+
getReceiptCmd: `deepline runs logs ${quotedId} --kind receipt.completed --payloads --json`
|
|
22475
22485
|
};
|
|
22476
22486
|
}
|
|
22477
22487
|
function buildRunNavigation(status) {
|
|
@@ -24330,7 +24340,7 @@ Examples:
|
|
|
24330
24340
|
// src/cli/commands/run-receipt.ts
|
|
24331
24341
|
var import_promises4 = require("fs/promises");
|
|
24332
24342
|
function registerRunReceiptCommand(runs) {
|
|
24333
|
-
runs.command("receipt <runId>").description(
|
|
24343
|
+
runs.command("receipt <runId>", { hidden: true }).description(
|
|
24334
24344
|
"Read retained tool responses by receipt key. Never executes tools."
|
|
24335
24345
|
).option(
|
|
24336
24346
|
"--key <key>",
|
|
@@ -24344,8 +24354,7 @@ function registerRunReceiptCommand(runs) {
|
|
|
24344
24354
|
"after",
|
|
24345
24355
|
`
|
|
24346
24356
|
Examples:
|
|
24347
|
-
deepline runs
|
|
24348
|
-
jq -r '.[].receipt_key' rows.json | deepline runs receipt <run-id> --keys - --out responses.json
|
|
24357
|
+
deepline runs logs <run-id> --kind receipt.completed --payloads --json
|
|
24349
24358
|
|
|
24350
24359
|
Returns one outcome per key, preserving order and duplicates. A missing or
|
|
24351
24360
|
unavailable result is explicit; other keys are still returned. Exit 4 means
|
|
@@ -31596,7 +31605,7 @@ async function traceCliSpan(phase, fields2, run) {
|
|
|
31596
31605
|
}
|
|
31597
31606
|
|
|
31598
31607
|
// 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`.
|
|
31608
|
+
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
31609
|
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
31610
|
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
31611
|
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 +36573,13 @@ function buildRunNextCommands(status) {
|
|
|
36564
36573
|
};
|
|
36565
36574
|
}
|
|
36566
36575
|
const actions2 = buildRunNavigation(status).actions;
|
|
36576
|
+
const exportDatasetCmds = Array.isArray(actions2.exportDatasetCmds) ? actions2.exportDatasetCmds : !status.package && extractCanonicalRowsInfo(status) ? [`deepline runs export ${runId} --out output.csv`] : [];
|
|
36567
36577
|
const commands = {
|
|
36568
36578
|
get: String(actions2.getRunCmd ?? `deepline runs get ${runId} --json`),
|
|
36569
36579
|
full: String(
|
|
36570
36580
|
actions2.getFullRunCmd ?? `deepline runs get ${runId} --full --json`
|
|
36571
36581
|
),
|
|
36572
|
-
...
|
|
36582
|
+
...exportDatasetCmds.length === 1 ? { export: String(exportDatasetCmds[0]) } : {},
|
|
36573
36583
|
logs: String(
|
|
36574
36584
|
!status.package ? `deepline runs logs ${runId} --out run.log --json` : actions2.getLogsCmd ?? `deepline runs logs ${runId} --limit 100 --json`
|
|
36575
36585
|
)
|
|
@@ -36578,7 +36588,7 @@ function buildRunNextCommands(status) {
|
|
|
36578
36588
|
commands.stop = `deepline runs stop ${runId} --json`;
|
|
36579
36589
|
}
|
|
36580
36590
|
if (status.status === "failed") {
|
|
36581
|
-
commands.failedLogs = `deepline runs
|
|
36591
|
+
commands.failedLogs = `deepline runs logs ${runId} --failed --json`;
|
|
36582
36592
|
if (status.rerunCommand) commands.run = status.rerunCommand;
|
|
36583
36593
|
}
|
|
36584
36594
|
if (status.dashboardUrl) {
|
|
@@ -37009,7 +37019,7 @@ function compactPlayStatus(status) {
|
|
|
37009
37019
|
next: {
|
|
37010
37020
|
...readRecord(packaged.next) ?? {},
|
|
37011
37021
|
...status.failedLogs ? {
|
|
37012
|
-
failedLogs: `deepline runs
|
|
37022
|
+
failedLogs: `deepline runs logs ${status.runId} --failed --json`
|
|
37013
37023
|
} : {},
|
|
37014
37024
|
...status.rerunCommand ? { run: status.rerunCommand } : {}
|
|
37015
37025
|
}
|
|
@@ -37022,14 +37032,14 @@ function compactPlayStatus(status) {
|
|
|
37022
37032
|
...status.failedLogs ? {
|
|
37023
37033
|
next: {
|
|
37024
37034
|
...readRecord(packaged.next) ?? {},
|
|
37025
|
-
failedLogs: `deepline runs
|
|
37035
|
+
failedLogs: `deepline runs logs ${status.runId} --failed --json`
|
|
37026
37036
|
}
|
|
37027
37037
|
} : {},
|
|
37028
37038
|
...status.rerunCommand ? {
|
|
37029
37039
|
next: {
|
|
37030
37040
|
...readRecord(packaged.next) ?? {},
|
|
37031
37041
|
...status.failedLogs ? {
|
|
37032
|
-
failedLogs: `deepline runs
|
|
37042
|
+
failedLogs: `deepline runs logs ${status.runId} --failed --json`
|
|
37033
37043
|
} : {},
|
|
37034
37044
|
run: status.rerunCommand
|
|
37035
37045
|
}
|
|
@@ -37078,9 +37088,6 @@ function compactRunErrorForEnvelope(message, runId) {
|
|
|
37078
37088
|
const headline = firstStackFrame >= 0 ? lines.slice(0, firstStackFrame).join("\n") : message;
|
|
37079
37089
|
return truncateErrorForDisplay(headline, runId, 1e3);
|
|
37080
37090
|
}
|
|
37081
|
-
function readRunPackageRun(packaged) {
|
|
37082
|
-
return packaged.run && typeof packaged.run === "object" && !Array.isArray(packaged.run) ? packaged.run : {};
|
|
37083
|
-
}
|
|
37084
37091
|
function readRecordArray(value) {
|
|
37085
37092
|
return Array.isArray(value) ? value.filter(
|
|
37086
37093
|
(item) => item !== null && typeof item === "object" && !Array.isArray(item)
|
|
@@ -37092,131 +37099,6 @@ function readRecord(value) {
|
|
|
37092
37099
|
function readNonNegativeInteger(value) {
|
|
37093
37100
|
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? Math.trunc(value) : null;
|
|
37094
37101
|
}
|
|
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
37102
|
function packageDatasetRecords(packaged) {
|
|
37221
37103
|
const catalog = readRecordArray(packaged.datasets);
|
|
37222
37104
|
if (catalog.length > 0) return catalog;
|
|
@@ -37225,24 +37107,6 @@ function packageDatasetRecords(packaged) {
|
|
|
37225
37107
|
return output2?.kind === "dataset" ? [output2] : [];
|
|
37226
37108
|
});
|
|
37227
37109
|
}
|
|
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
37110
|
function formatRunStepProgress(progress, includeRowOutcomes = false) {
|
|
37247
37111
|
const executed = readNonNegativeInteger(progress.executed);
|
|
37248
37112
|
const total = readNonNegativeInteger(progress.total);
|
|
@@ -37265,205 +37129,6 @@ function formatRunStepProgress(progress, includeRowOutcomes = false) {
|
|
|
37265
37129
|
}
|
|
37266
37130
|
return parts.join(" \xB7 ");
|
|
37267
37131
|
}
|
|
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
37132
|
function activityTargetLabel(target) {
|
|
37468
37133
|
const kind = typeof target.kind === "string" ? target.kind : "target";
|
|
37469
37134
|
const label = typeof target.label === "string" ? target.label.trim() : "";
|
|
@@ -37619,152 +37284,6 @@ function formatRunTimingTextLines(run) {
|
|
|
37619
37284
|
].join(" \xB7 ")}`
|
|
37620
37285
|
];
|
|
37621
37286
|
}
|
|
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
37287
|
function buildOrdinaryPlayRunCommand(options, resolvedRevisionId) {
|
|
37769
37288
|
const target = options.target.kind === "file" ? options.target.path : options.target.name;
|
|
37770
37289
|
const parts = ["deepline", "plays", "run", shellSingleQuote(target)];
|
|
@@ -37850,6 +37369,57 @@ function buildRunLaunch(status) {
|
|
|
37850
37369
|
)
|
|
37851
37370
|
};
|
|
37852
37371
|
}
|
|
37372
|
+
function buildPlayCompletionTextLines(status) {
|
|
37373
|
+
const overview = buildRunOverview(status);
|
|
37374
|
+
const { run } = overview;
|
|
37375
|
+
const failed = run.status === "failed";
|
|
37376
|
+
const label = run.status === "completed" ? overview.rowOutcomes?.hasRowFailures ? "Completed with row failures" : "Completed" : failed ? "Failed" : run.status;
|
|
37377
|
+
const lines = [
|
|
37378
|
+
`${label} ${run.playName ?? status.playName ?? "Play"}`,
|
|
37379
|
+
`Run: ${run.id}`
|
|
37380
|
+
];
|
|
37381
|
+
for (const failure of overview.failures.steps) {
|
|
37382
|
+
lines.push(
|
|
37383
|
+
`Failed step: ${failure.stepId}${failure.message ? ` \u2014 ${failure.message}` : ""}`
|
|
37384
|
+
);
|
|
37385
|
+
}
|
|
37386
|
+
if (overview.errorDetails.run)
|
|
37387
|
+
lines.push(
|
|
37388
|
+
`Error: ${truncateErrorForDisplay(overview.errorDetails.run, run.id)}`
|
|
37389
|
+
);
|
|
37390
|
+
if (Object.hasOwn(overview, "result")) {
|
|
37391
|
+
lines.push(
|
|
37392
|
+
"Result:",
|
|
37393
|
+
...formatJsonPreview(compactReturnValue(overview.result))
|
|
37394
|
+
);
|
|
37395
|
+
}
|
|
37396
|
+
if (overview.rowOutcomes?.hasRowFailures) {
|
|
37397
|
+
lines.push(
|
|
37398
|
+
`Rows: ${overview.rowOutcomes.completedRows} completed, ${overview.rowOutcomes.failedRows} failed`
|
|
37399
|
+
);
|
|
37400
|
+
}
|
|
37401
|
+
for (const dataset of overview.datasets) {
|
|
37402
|
+
lines.push(
|
|
37403
|
+
`Rows (${dataset.name ?? dataset.datasetId}): ${dataset.rowCount ?? "unknown"}`
|
|
37404
|
+
);
|
|
37405
|
+
if (dataset.exportUnavailable)
|
|
37406
|
+
lines.push(`Export unavailable: ${dataset.exportUnavailable.message}`);
|
|
37407
|
+
}
|
|
37408
|
+
for (const warning of overview.warnings) lines.push(`Warning: ${warning}`);
|
|
37409
|
+
const exports2 = overview.actions.exportDatasetCmds;
|
|
37410
|
+
if (Array.isArray(exports2))
|
|
37411
|
+
for (const command of exports2) lines.push(`Export CSV: ${command}`);
|
|
37412
|
+
lines.push(
|
|
37413
|
+
`Logs: ${failed ? String(
|
|
37414
|
+
overview.actions.getFailedLogsCmd ?? `deepline runs logs ${shellSingleQuote(run.id)} --failed`
|
|
37415
|
+
) : String(
|
|
37416
|
+
overview.actions.getLogsCmd ?? `deepline runs logs ${shellSingleQuote(run.id)}`
|
|
37417
|
+
)}`
|
|
37418
|
+
);
|
|
37419
|
+
if (failed && status.rerunCommand)
|
|
37420
|
+
lines.push(`Retry: ${status.rerunCommand}`);
|
|
37421
|
+
return lines;
|
|
37422
|
+
}
|
|
37853
37423
|
function writePlayResult(status, jsonOutput, options) {
|
|
37854
37424
|
const packaged = getPlayRunPackage(status);
|
|
37855
37425
|
const hits = options?.hits ?? null;
|
|
@@ -37868,10 +37438,7 @@ function writePlayResult(status, jsonOutput, options) {
|
|
|
37868
37438
|
...displayPackage
|
|
37869
37439
|
} = compactPlayStatus(status);
|
|
37870
37440
|
const lines2 = [
|
|
37871
|
-
...
|
|
37872
|
-
buildRunPackageTextLines(displayPackage),
|
|
37873
|
-
status
|
|
37874
|
-
),
|
|
37441
|
+
...buildPlayCompletionTextLines(status),
|
|
37875
37442
|
...formatRunHitsLines(hits)
|
|
37876
37443
|
];
|
|
37877
37444
|
printCommandEnvelope(displayPackage, {
|
|
@@ -37907,7 +37474,7 @@ function writePlayResult(status, jsonOutput, options) {
|
|
|
37907
37474
|
)
|
|
37908
37475
|
);
|
|
37909
37476
|
if (status.status === "failed") {
|
|
37910
|
-
lines.push(` failed logs: deepline runs
|
|
37477
|
+
lines.push(` failed logs: deepline runs logs ${runId} --failed --json`);
|
|
37911
37478
|
if (status.rerunCommand) {
|
|
37912
37479
|
lines.push(" run again (completed work is reused):");
|
|
37913
37480
|
lines.push(` ${status.rerunCommand}`);
|
|
@@ -37937,18 +37504,23 @@ function writePlayResult(status, jsonOutput, options) {
|
|
|
37937
37504
|
);
|
|
37938
37505
|
}
|
|
37939
37506
|
function withRunNavigationLines(lines, status, actionCommands = buildRunNavigation(status).actions) {
|
|
37940
|
-
const navigation = buildRunNavigation(status);
|
|
37941
37507
|
const existing = lines.join("\n");
|
|
37942
|
-
|
|
37943
|
-
|
|
37944
|
-
|
|
37945
|
-
|
|
37946
|
-
|
|
37947
|
-
|
|
37508
|
+
const labels = {
|
|
37509
|
+
getRunCmd: "Inspect",
|
|
37510
|
+
getFullRunCmd: "Full run",
|
|
37511
|
+
getBillingCmd: "Billing",
|
|
37512
|
+
getLogsCmd: "Logs",
|
|
37513
|
+
getFailedLogsCmd: "Failure logs",
|
|
37514
|
+
getReceiptCmd: "Saved responses",
|
|
37515
|
+
exportDatasetCmds: "Export rows",
|
|
37516
|
+
queryTableSqlCmds: "Query rows",
|
|
37517
|
+
stopRunCmd: "Stop run",
|
|
37518
|
+
rerunCmd: "Retry"
|
|
37519
|
+
};
|
|
37948
37520
|
for (const [name, value] of Object.entries(actionCommands)) {
|
|
37949
37521
|
for (const command of Array.isArray(value) ? value : [value]) {
|
|
37950
37522
|
if (typeof command === "string" && !existing.includes(command))
|
|
37951
|
-
lines.push(` ${name}: ${command}`);
|
|
37523
|
+
lines.push(` ${labels[name] ?? name}: ${command}`);
|
|
37952
37524
|
}
|
|
37953
37525
|
}
|
|
37954
37526
|
return lines;
|
|
@@ -38691,7 +38263,12 @@ function writeStartedPlayRun(input2) {
|
|
|
38691
38263
|
failedLogs: _failedLogs,
|
|
38692
38264
|
...displayPackage
|
|
38693
38265
|
} = input2.package;
|
|
38694
|
-
const lines2 =
|
|
38266
|
+
const lines2 = buildPlayCompletionTextLines({
|
|
38267
|
+
runId: input2.runId,
|
|
38268
|
+
playName: input2.playName,
|
|
38269
|
+
status: input2.status,
|
|
38270
|
+
package: displayPackage
|
|
38271
|
+
});
|
|
38695
38272
|
const output3 = lines2.join("\n");
|
|
38696
38273
|
if (input2.progress) {
|
|
38697
38274
|
input2.progress.writeLine(output3, process.stdout);
|
|
@@ -38719,17 +38296,11 @@ function writeStartedPlayRun(input2) {
|
|
|
38719
38296
|
};
|
|
38720
38297
|
const lines = [
|
|
38721
38298
|
`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`,
|
|
38299
|
+
`Run: ${input2.runId}`,
|
|
38300
|
+
`Logs: deepline runs logs ${shellSingleQuote(input2.runId)}`,
|
|
38730
38301
|
...["started", "queued", "running", "waiting"].includes(
|
|
38731
38302
|
input2.status ?? "started"
|
|
38732
|
-
) ? [`
|
|
38303
|
+
) ? [`Stop: deepline runs stop ${shellSingleQuote(input2.runId)} --json`] : []
|
|
38733
38304
|
];
|
|
38734
38305
|
if (input2.jsonOutput) {
|
|
38735
38306
|
printCommandEnvelope(payload, { json: true, fields: input2.jsonFields });
|
|
@@ -40151,7 +39722,7 @@ function renderRunOverviewText(overview, extras = {}) {
|
|
|
40151
39722
|
getBillingCmd: "Billing",
|
|
40152
39723
|
getLogsCmd: "Logs",
|
|
40153
39724
|
getFailedLogsCmd: "Failure logs",
|
|
40154
|
-
getReceiptCmd: "
|
|
39725
|
+
getReceiptCmd: "Saved responses",
|
|
40155
39726
|
exportDatasetCmds: "Export rows",
|
|
40156
39727
|
queryTableSqlCmds: "Query rows",
|
|
40157
39728
|
stopRunCmd: "Stop run",
|
|
@@ -40173,7 +39744,7 @@ async function handleRunGet(args) {
|
|
|
40173
39744
|
args.includes("--config") ? "config" : "get"
|
|
40174
39745
|
);
|
|
40175
39746
|
args = selection.args;
|
|
40176
|
-
const usage2 = "Usage: deepline runs get <run-id> [--json] [--full] [--input] [--config]
|
|
39747
|
+
const usage2 = "Usage: deepline runs get <run-id> [--json] [--full] [--input] [--config]";
|
|
40177
39748
|
let runId;
|
|
40178
39749
|
try {
|
|
40179
39750
|
runId = parseRunIdPositional(args, usage2);
|
|
@@ -43182,7 +42753,7 @@ Examples:
|
|
|
43182
42753
|
deepline runs get play/my-play/run/20260501t000000-000
|
|
43183
42754
|
deepline runs get play/my-play/run/20260501t000000-000 --json
|
|
43184
42755
|
deepline runs get play/my-play/run/20260501t000000-000 --json run.status,run.durationMs
|
|
43185
|
-
deepline runs
|
|
42756
|
+
deepline runs logs play/my-play/run/20260501t000000-000 --failed --json
|
|
43186
42757
|
deepline runs get play/my-play/run/20260501t000000-000 --full --json
|
|
43187
42758
|
deepline runs get play/my-play/run/20260501t000000-000 --input
|
|
43188
42759
|
deepline runs get play/my-play/run/20260501t000000-000 --config --json
|
|
@@ -43199,9 +42770,8 @@ Examples:
|
|
|
43199
42770
|
).option(
|
|
43200
42771
|
"--config",
|
|
43201
42772
|
"Explicitly print the recorded configuration, without full results"
|
|
43202
|
-
).
|
|
43203
|
-
"--log-failed",
|
|
43204
|
-
"Attach a bounded terminal-failure log window for failed runs"
|
|
42773
|
+
).addOption(
|
|
42774
|
+
new import_commander4.Option("--log-failed", "Attach terminal-failure logs").hideHelp()
|
|
43205
42775
|
).action(async (runId, options) => {
|
|
43206
42776
|
process.exitCode = await handleRunGet([
|
|
43207
42777
|
runId,
|
|
@@ -50587,7 +50157,10 @@ Examples:
|
|
|
50587
50157
|
`
|
|
50588
50158
|
Notes:
|
|
50589
50159
|
Shows the compact agent contract by default: what the tool does, cost,
|
|
50590
|
-
required inputs, play getters, and
|
|
50160
|
+
required inputs, play getters, input and full Deepline response examples,
|
|
50161
|
+
and a ctx.tools.execute snippet. Tool responses live at toolResponse.rawV2;
|
|
50162
|
+
preserve the nesting shown in the tool's example. Schemas and examples are
|
|
50163
|
+
separate describe fields.
|
|
50591
50164
|
get is accepted as a compatibility alias for describe.
|
|
50592
50165
|
|
|
50593
50166
|
Examples:
|
|
@@ -50610,7 +50183,7 @@ Examples:
|
|
|
50610
50183
|
"Quote an ai_evaluate, ai_inference, or deeplineagent JSON payload (inline or @file)"
|
|
50611
50184
|
).option("--pricing-only", "Only print pricing and billing semantics").option("--schema-only", "Only print input schema fields").option(
|
|
50612
50185
|
"--examples-only",
|
|
50613
|
-
"Only print
|
|
50186
|
+
"Only print input payload and full Deepline execution response examples"
|
|
50614
50187
|
).option("--getters-only", "Only print extracted list/value getters").addOption(
|
|
50615
50188
|
new import_commander5.Option(
|
|
50616
50189
|
"--compact",
|
|
@@ -50787,6 +50360,30 @@ async function getTool(toolId, options = {}) {
|
|
|
50787
50360
|
);
|
|
50788
50361
|
return 0;
|
|
50789
50362
|
}
|
|
50363
|
+
if ((options.schemaOnly || options.examplesOnly || options.gettersOnly) && !isMonitorTypeTool(tool) && !isPlayLikeTool(tool) && (options.json || options.contractJson)) {
|
|
50364
|
+
const contract = toolContractJsonForDescribe(tool, toolId);
|
|
50365
|
+
printCompactJson({
|
|
50366
|
+
toolId: contract.toolId,
|
|
50367
|
+
...options.schemaOnly ? {
|
|
50368
|
+
inputSchema: contract.inputSchema,
|
|
50369
|
+
inputFields: contract.inputFields,
|
|
50370
|
+
outputSchema: contract.outputSchema,
|
|
50371
|
+
outputFields: contract.outputFields,
|
|
50372
|
+
responseSchema: contract.responseSchema
|
|
50373
|
+
} : options.examplesOnly ? {
|
|
50374
|
+
examples: contract.examples ?? [],
|
|
50375
|
+
responseAccess: contract.responseAccess,
|
|
50376
|
+
getters: contract.getters,
|
|
50377
|
+
executeCommand: contract.executeCommand
|
|
50378
|
+
} : {
|
|
50379
|
+
getters: contract.getters,
|
|
50380
|
+
responseAccess: contract.responseAccess
|
|
50381
|
+
},
|
|
50382
|
+
...modelDescription ? { modelOptions: modelDescription } : {},
|
|
50383
|
+
...inferenceQuote ? { inferenceQuote } : {}
|
|
50384
|
+
});
|
|
50385
|
+
return 0;
|
|
50386
|
+
}
|
|
50790
50387
|
if (options.contractJson) {
|
|
50791
50388
|
printCompactJson({
|
|
50792
50389
|
...toolContractJsonForDescribe(tool, toolId),
|
|
@@ -50928,6 +50525,9 @@ function toolContractJsonForDescribe(tool, requestedToolId) {
|
|
|
50928
50525
|
} : {},
|
|
50929
50526
|
inputFields: inputFields.map(inputFieldJsonForDescribe),
|
|
50930
50527
|
inputSchema,
|
|
50528
|
+
...isRecord8(tool.responseSchema) ? { responseSchema: tool.responseSchema } : {},
|
|
50529
|
+
...Array.isArray(tool.examples) ? { examples: tool.examples } : {},
|
|
50530
|
+
responseAccess: "result.toolResponse.rawV2",
|
|
50931
50531
|
...Object.keys(outputSchemaRecord).length > 0 ? {
|
|
50932
50532
|
outputSchema: publicToolInputSchemaForDescribe(outputSchemaRecord),
|
|
50933
50533
|
outputFields: outputFields.map(inputFieldJsonForDescribe)
|
|
@@ -51149,15 +50749,13 @@ function printCompactToolContract(tool, requestedToolId) {
|
|
|
51149
50749
|
}
|
|
51150
50750
|
}
|
|
51151
50751
|
console.log("");
|
|
51152
|
-
printToolExamplesOnly(tool, requestedToolId
|
|
50752
|
+
printToolExamplesOnly(tool, requestedToolId);
|
|
51153
50753
|
const starterScript = isRecord8(contract.starterScript) ? contract.starterScript : {};
|
|
51154
50754
|
const starterPath = stringField2(starterScript, "path");
|
|
51155
50755
|
if (starterPath) {
|
|
51156
50756
|
console.log("");
|
|
51157
50757
|
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
|
-
);
|
|
50758
|
+
console.log("Copy it into your project and adapt the example input.");
|
|
51161
50759
|
}
|
|
51162
50760
|
if (listGetters.length || valueGetters.length) {
|
|
51163
50761
|
console.log("");
|
|
@@ -51247,11 +50845,15 @@ function printToolSchemaOnly(tool, requestedToolId) {
|
|
|
51247
50845
|
recordField(contract, "inputSchema")
|
|
51248
50846
|
);
|
|
51249
50847
|
if (declaredSchema) {
|
|
51250
|
-
console.log("Declared JSON Schema:");
|
|
50848
|
+
console.log("Declared input JSON Schema:");
|
|
51251
50849
|
console.log(JSON.stringify(declaredSchema, null, 2));
|
|
51252
50850
|
}
|
|
50851
|
+
if (isRecord8(contract.responseSchema)) {
|
|
50852
|
+
console.log("Deepline execution response JSON Schema:");
|
|
50853
|
+
console.log(JSON.stringify(contract.responseSchema, null, 2));
|
|
50854
|
+
}
|
|
51253
50855
|
}
|
|
51254
|
-
function printToolExamplesOnly(tool, requestedToolId
|
|
50856
|
+
function printToolExamplesOnly(tool, requestedToolId) {
|
|
51255
50857
|
if (isMonitorTypeTool(tool)) {
|
|
51256
50858
|
printMonitorTypeDeploy(tool);
|
|
51257
50859
|
return;
|
|
@@ -51263,7 +50865,11 @@ function printToolExamplesOnly(tool, requestedToolId, options = {}) {
|
|
|
51263
50865
|
const contract = toolContractJsonForDescribe(tool, requestedToolId);
|
|
51264
50866
|
const toolId = String(contract.toolId);
|
|
51265
50867
|
const inputFields = Array.isArray(contract.inputFields) ? contract.inputFields : [];
|
|
51266
|
-
const
|
|
50868
|
+
const examples = arrayField2(tool, "examples").filter(isRecord8);
|
|
50869
|
+
const firstExample = examples[0];
|
|
50870
|
+
const sampleInput = firstExample && isRecord8(firstExample.input) ? firstExample.input : samplePayload(recordField(tool, "samples"), "request") ?? samplePayloadForInputFields(inputFields);
|
|
50871
|
+
console.log("Example input payload:");
|
|
50872
|
+
console.log(JSON.stringify(sampleInput, null, 2));
|
|
51267
50873
|
console.log(`Use in a play:`);
|
|
51268
50874
|
console.log("```ts");
|
|
51269
50875
|
console.log("const result = await ctx.tools.execute({");
|
|
@@ -51273,6 +50879,7 @@ function printToolExamplesOnly(tool, requestedToolId, options = {}) {
|
|
|
51273
50879
|
` input: ${JSON.stringify(sampleInput || {}, null, 2).replace(/\n/g, "\n ")},`
|
|
51274
50880
|
);
|
|
51275
50881
|
console.log("});");
|
|
50882
|
+
console.log("const response = result.toolResponse.rawV2;");
|
|
51276
50883
|
const getters = isRecord8(contract.getters) ? contract.getters : {};
|
|
51277
50884
|
const valueGetters = Array.isArray(getters.extractedValues) ? getters.extractedValues : [];
|
|
51278
50885
|
const listGetters = Array.isArray(getters.extractedLists) ? getters.extractedLists : [];
|
|
@@ -51286,10 +50893,19 @@ function printToolExamplesOnly(tool, requestedToolId, options = {}) {
|
|
|
51286
50893
|
);
|
|
51287
50894
|
}
|
|
51288
50895
|
console.log("```");
|
|
51289
|
-
|
|
51290
|
-
const
|
|
51291
|
-
|
|
50896
|
+
for (const example of examples) {
|
|
50897
|
+
const description = stringField2(example, "description");
|
|
50898
|
+
if (description) console.log(description);
|
|
50899
|
+
console.log("Example Deepline execution response:");
|
|
50900
|
+
console.log(JSON.stringify(example.response, null, 2));
|
|
51292
50901
|
}
|
|
50902
|
+
if (!examples.length)
|
|
50903
|
+
console.log(
|
|
50904
|
+
"No Deepline execution response example is published by this server."
|
|
50905
|
+
);
|
|
50906
|
+
console.log(
|
|
50907
|
+
"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."
|
|
50908
|
+
);
|
|
51293
50909
|
}
|
|
51294
50910
|
function printPlayLikeToolUsage(tool, requestedToolId) {
|
|
51295
50911
|
const toolId = String(tool.toolId || requestedToolId);
|
|
@@ -51434,9 +51050,9 @@ function toolMetadataJsonForDescribe(tool, requestedToolId) {
|
|
|
51434
51050
|
inputFields: inputFields.map(inputFieldJsonForDescribe),
|
|
51435
51051
|
usageGuidance,
|
|
51436
51052
|
runtimeOutputHelp: {
|
|
51437
|
-
contract: "
|
|
51053
|
+
contract: "Schemas declare field shapes. Examples illustrate input payloads and full Deepline execution responses; they are not observed responses from this call.",
|
|
51438
51054
|
getterScope: "extractedValues/extractedLists .get() only works for declared Deepline getters listed in usageGuidance.toolExecutionResult.",
|
|
51439
|
-
rawToolResponse: "Use toolExecutionResult.toolResponse.rawV2 for
|
|
51055
|
+
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
51056
|
invalidGetterHint: "If TypeScript says an extractedValues/extractedLists property does not exist, that field is not a declared Deepline getter.",
|
|
51441
51057
|
observeActualShape: observedOutputCommand,
|
|
51442
51058
|
observedOutput: observedOutputCommand,
|
|
@@ -51451,7 +51067,25 @@ function usageGuidanceWithAccessDefaults(usageGuidance) {
|
|
|
51451
51067
|
const existingAccess = recordField(usageGuidance, "access");
|
|
51452
51068
|
return {
|
|
51453
51069
|
...usageGuidance,
|
|
51070
|
+
prefer: [
|
|
51071
|
+
"Use only the declared extractedLists and extractedValues getters listed below.",
|
|
51072
|
+
"Use toolExecutionResult.toolResponse.rawV2 for the complete tool response, preserving the nesting shown in the response example.",
|
|
51073
|
+
"Schemas declare field shapes; examples illustrate input values and full Deepline execution responses."
|
|
51074
|
+
],
|
|
51075
|
+
toolExecutionResult: {
|
|
51076
|
+
...recordField(
|
|
51077
|
+
usageGuidance,
|
|
51078
|
+
"toolExecutionResult",
|
|
51079
|
+
"tool_execution_result"
|
|
51080
|
+
),
|
|
51081
|
+
toolResponse: {
|
|
51082
|
+
rawV2: "toolResponse.rawV2",
|
|
51083
|
+
view: "toolResponse.view",
|
|
51084
|
+
responseMeta: "toolResponse.responseMeta"
|
|
51085
|
+
}
|
|
51086
|
+
},
|
|
51454
51087
|
access: {
|
|
51088
|
+
...existingAccess,
|
|
51455
51089
|
extractedLists: {
|
|
51456
51090
|
expression: "toolExecutionResult.extractedLists.<name>.get()",
|
|
51457
51091
|
meaning: "Declared Deepline list extractors only."
|
|
@@ -51463,13 +51097,13 @@ function usageGuidanceWithAccessDefaults(usageGuidance) {
|
|
|
51463
51097
|
...existingAccess,
|
|
51464
51098
|
rawToolResponse: {
|
|
51465
51099
|
expression: "toolExecutionResult.toolResponse.rawV2",
|
|
51466
|
-
meaning: "Complete
|
|
51100
|
+
meaning: "Complete tool response with its original nesting. Read tool-specific fields here; use declared getters for extracted values and lists."
|
|
51467
51101
|
},
|
|
51468
51102
|
canonicalToolResponse: {
|
|
51469
51103
|
expression: "toolExecutionResult.toolResponse.rawV2",
|
|
51470
|
-
meaning: "Complete
|
|
51104
|
+
meaning: "Complete tool response with its original nesting and sibling fields."
|
|
51471
51105
|
},
|
|
51472
|
-
invalidGetterHint: "If TypeScript says an extractedValues/extractedLists property does not exist, that field is not a declared Deepline getter;
|
|
51106
|
+
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
51107
|
}
|
|
51474
51108
|
};
|
|
51475
51109
|
}
|
|
@@ -51801,23 +51435,6 @@ function formatRateWindow(windowMs) {
|
|
|
51801
51435
|
if (windowMs === 36e5) return "hour";
|
|
51802
51436
|
return `${windowMs}ms`;
|
|
51803
51437
|
}
|
|
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
51438
|
function samplePayload(samples, key) {
|
|
51822
51439
|
const entry = samples[key];
|
|
51823
51440
|
if (!isRecord8(entry)) return void 0;
|
|
@@ -52430,9 +52047,13 @@ async function executeTool(args) {
|
|
|
52430
52047
|
}).catch((error) => {
|
|
52431
52048
|
const guidanceLines = toolGuidanceLines(metadata.guidance);
|
|
52432
52049
|
if (guidanceLines.length > 0) {
|
|
52433
|
-
|
|
52434
|
-
|
|
52435
|
-
|
|
52050
|
+
if (args.includes("--json") && error instanceof Error) {
|
|
52051
|
+
Object.assign(error, { guidance: metadata.guidance });
|
|
52052
|
+
} else {
|
|
52053
|
+
console.error(
|
|
52054
|
+
[`Guidance for ${parsed.toolId}:`, ...guidanceLines].join("\n")
|
|
52055
|
+
);
|
|
52056
|
+
}
|
|
52436
52057
|
}
|
|
52437
52058
|
throw error;
|
|
52438
52059
|
});
|