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.mjs
CHANGED
|
@@ -3510,7 +3510,7 @@ var SDK_RELEASE = {
|
|
|
3510
3510
|
// getters keep their established compatibility behavior.
|
|
3511
3511
|
// 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
|
|
3512
3512
|
// 0.3.90 is the first deliberately versioned SDK release for API v3.
|
|
3513
|
-
version: "0.3.
|
|
3513
|
+
version: "0.3.292",
|
|
3514
3514
|
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.",
|
|
3515
3515
|
packageCapabilities: {
|
|
3516
3516
|
updatePreferences: 1
|
|
@@ -5977,7 +5977,7 @@ function classifyLegacyLogLine(line) {
|
|
|
5977
5977
|
if (/^\[perf\] runtime receipt\b/i.test(message)) {
|
|
5978
5978
|
return "receipt";
|
|
5979
5979
|
}
|
|
5980
|
-
if (/^\[perf\] runtime
|
|
5980
|
+
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(
|
|
5981
5981
|
message
|
|
5982
5982
|
) || /\[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(
|
|
5983
5983
|
message
|
|
@@ -7809,8 +7809,10 @@ var DeeplineClient = class _DeeplineClient {
|
|
|
7809
7809
|
/**
|
|
7810
7810
|
* Execute a tool and return the standard execution envelope.
|
|
7811
7811
|
*
|
|
7812
|
-
* The `toolResponse.rawV2` field contains the complete
|
|
7813
|
-
* `
|
|
7812
|
+
* The `toolResponse.rawV2` field contains the complete tool response,
|
|
7813
|
+
* preserving its original nesting. Inspect `getTool().examples` for a full
|
|
7814
|
+
* Deepline response example. Optional `toolResponse.responseMeta` contains
|
|
7815
|
+
* response metadata.
|
|
7814
7816
|
* Top-level fields such as `status`, `job_id`, and `billing` describe the
|
|
7815
7817
|
* Deepline execution envelope.
|
|
7816
7818
|
*/
|
|
@@ -8523,7 +8525,7 @@ var DeeplineClient = class _DeeplineClient {
|
|
|
8523
8525
|
});
|
|
8524
8526
|
} catch (error) {
|
|
8525
8527
|
failedLogsLoaded = false;
|
|
8526
|
-
const retryCommand = `deepline runs
|
|
8528
|
+
const retryCommand = `deepline runs logs ${runId} --failed --json`;
|
|
8527
8529
|
const reason = error instanceof Error && error.message.trim() ? ` (${error.message.trim().slice(0, 500)})` : "";
|
|
8528
8530
|
failedLogs = {
|
|
8529
8531
|
runId,
|
|
@@ -11525,6 +11527,9 @@ function errorToJsonPayload(error) {
|
|
|
11525
11527
|
if (maybeRecord?.details && typeof maybeRecord.details === "object" && !Array.isArray(maybeRecord.details)) {
|
|
11526
11528
|
details.details = maybeRecord.details;
|
|
11527
11529
|
}
|
|
11530
|
+
if (maybeRecord?.guidance && typeof maybeRecord.guidance === "object" && !Array.isArray(maybeRecord.guidance)) {
|
|
11531
|
+
details.guidance = maybeRecord.guidance;
|
|
11532
|
+
}
|
|
11528
11533
|
const providerConcurrency = providerConcurrencyDiagnostic(maybeRecord);
|
|
11529
11534
|
if (providerConcurrency) {
|
|
11530
11535
|
details.providerConcurrency = providerConcurrency;
|
|
@@ -15101,7 +15106,9 @@ async function handleDbQuery(args) {
|
|
|
15101
15106
|
actions: [{ label: "Tool equivalent", command: toolCommand }]
|
|
15102
15107
|
}
|
|
15103
15108
|
},
|
|
15104
|
-
{
|
|
15109
|
+
{
|
|
15110
|
+
json: explicitJsonOutput || format === "json" || format !== "table" && jsonOutput
|
|
15111
|
+
}
|
|
15105
15112
|
);
|
|
15106
15113
|
return 0;
|
|
15107
15114
|
}
|
|
@@ -15177,8 +15184,9 @@ Examples:
|
|
|
15177
15184
|
"after",
|
|
15178
15185
|
`
|
|
15179
15186
|
Notes:
|
|
15180
|
-
Requires --sql (inline SQL or @file.sql). Output
|
|
15181
|
-
|
|
15187
|
+
Requires --sql (inline SQL or @file.sql). Output defaults to a compact table in a terminal
|
|
15188
|
+
and JSON when stdout is piped. --format table forces a table even in pipes.
|
|
15189
|
+
--json overrides --format for stdout. The active auth workspace determines scope.
|
|
15182
15190
|
Read permitted schemas with SELECT, EXPLAIN, or read-only WITH.
|
|
15183
15191
|
Write only to schema-qualified storage tables. For example, use
|
|
15184
15192
|
CREATE TABLE storage.blocked (...) instead of CREATE TABLE blocked (...).
|
|
@@ -21763,7 +21771,7 @@ var KIND_DESCRIPTIONS = {
|
|
|
21763
21771
|
"dataset.lifecycle": "Dataset registered, available or failed.",
|
|
21764
21772
|
"activity.observed": "Provider or workflow activity.",
|
|
21765
21773
|
"work.counters": "Call, request and rate-limit totals.",
|
|
21766
|
-
"receipt.completed": "Saved
|
|
21774
|
+
"receipt.completed": "Saved result or call details.",
|
|
21767
21775
|
"receipt.failed": "Saved work result: failed.",
|
|
21768
21776
|
"receipt.skipped": "Saved work result: skipped.",
|
|
21769
21777
|
"runtime.event": "Other event."
|
|
@@ -21804,6 +21812,10 @@ var FILTER_EXAMPLES = [
|
|
|
21804
21812
|
{
|
|
21805
21813
|
label: "One run and step",
|
|
21806
21814
|
command: `deepline runs logs '<run-id>' --where '$.stepId == "company-lookup"' --json`
|
|
21815
|
+
},
|
|
21816
|
+
{
|
|
21817
|
+
label: "Error logs for one step",
|
|
21818
|
+
command: `deepline runs logs --kind log.appended --where '$.level == "error" && $.stepId == "company-lookup"' --payloads --json`
|
|
21807
21819
|
}
|
|
21808
21820
|
];
|
|
21809
21821
|
function wrapParagraph(text) {
|
|
@@ -21824,10 +21836,14 @@ function renderRunLogsHelp() {
|
|
|
21824
21836
|
"",
|
|
21825
21837
|
"Examples:",
|
|
21826
21838
|
` ${READ_EXAMPLES[0]}`,
|
|
21839
|
+
` deepline runs logs --where '$.eventId == "receipt:5a32ee1a-46cf-4853-b72b-5f1d782ffab4"' --payloads --json`,
|
|
21827
21840
|
" deepline runs logs --kind run.failed --json",
|
|
21828
|
-
...[
|
|
21829
|
-
|
|
21830
|
-
|
|
21841
|
+
...[
|
|
21842
|
+
FILTER_EXAMPLES[1],
|
|
21843
|
+
FILTER_EXAMPLES[2],
|
|
21844
|
+
FILTER_EXAMPLES[5],
|
|
21845
|
+
FILTER_EXAMPLES[7]
|
|
21846
|
+
].map(({ command }) => ` ${command}`),
|
|
21831
21847
|
"",
|
|
21832
21848
|
"Event kinds:",
|
|
21833
21849
|
...RUN_LOGS_KIND_HELP.map(
|
|
@@ -21846,6 +21862,7 @@ function renderRunLogsHelp() {
|
|
|
21846
21862
|
"A run ID alone reads text logs. Omit it or add a search flag to search events; a supplied run ID narrows the search.",
|
|
21847
21863
|
"Defaults to the last hour; maximum lookback is seven days. Follow next.logs for events; use nextCursor with --cursor for older text logs.",
|
|
21848
21864
|
"--payloads returns available details or saved results: up to 10 events and 16 MiB.",
|
|
21865
|
+
"To read one exact saved result, filter by its returned eventId and add --payloads.",
|
|
21849
21866
|
"--out, --failed and --log-level apply to text logs and cannot be combined with event search."
|
|
21850
21867
|
].map((note) => wrapParagraph(note)),
|
|
21851
21868
|
"",
|
|
@@ -22178,13 +22195,6 @@ var DATASET_EXECUTION_BUCKETS = [
|
|
|
22178
22195
|
"skipped:missed",
|
|
22179
22196
|
"failed"
|
|
22180
22197
|
];
|
|
22181
|
-
function formatDatasetRowCountsLine(counts) {
|
|
22182
|
-
const { persisted, succeeded, failed } = counts;
|
|
22183
|
-
if (succeeded === persisted && failed === 0) {
|
|
22184
|
-
return `${persisted} persisted`;
|
|
22185
|
-
}
|
|
22186
|
-
return `${persisted} persisted (${succeeded} succeeded, ${failed} failed)`;
|
|
22187
|
-
}
|
|
22188
22198
|
|
|
22189
22199
|
// src/runs/overview.ts
|
|
22190
22200
|
var record3 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
@@ -22203,7 +22213,7 @@ function lifecycleActions(status, id, state) {
|
|
|
22203
22213
|
return {
|
|
22204
22214
|
...["started", "queued", "running", "waiting"].includes(state ?? "") ? { stopRunCmd: `deepline runs stop ${id} --json` } : {},
|
|
22205
22215
|
...state === "failed" ? {
|
|
22206
|
-
getFailedLogsCmd: `deepline runs
|
|
22216
|
+
getFailedLogsCmd: `deepline runs logs ${id} --failed --json`,
|
|
22207
22217
|
...status.rerunCommand ? { rerunCmd: status.rerunCommand } : {}
|
|
22208
22218
|
} : {}
|
|
22209
22219
|
};
|
|
@@ -22406,7 +22416,7 @@ function buildRunOverview(status, fullStatus) {
|
|
|
22406
22416
|
);
|
|
22407
22417
|
return {
|
|
22408
22418
|
datasetId: dataset.datasetId,
|
|
22409
|
-
name: dataset.tableNamespace,
|
|
22419
|
+
name: dataset.tableNamespace ?? (typeof stepOutput?.tableNamespace === "string" ? stepOutput.tableNamespace : dataset.path),
|
|
22410
22420
|
stepId: step?.id ?? named[0]?.[1].stepId,
|
|
22411
22421
|
rowCount: dataset.rowCount ?? null,
|
|
22412
22422
|
...dataset.lifecycle ? { lifecycle: dataset.lifecycle } : {},
|
|
@@ -22500,7 +22510,7 @@ function buildRunOverview(status, fullStatus) {
|
|
|
22500
22510
|
function receiptAction(id) {
|
|
22501
22511
|
const quotedId = `'${id.replace(/'/g, "'\\''")}'`;
|
|
22502
22512
|
return {
|
|
22503
|
-
getReceiptCmd: `deepline runs
|
|
22513
|
+
getReceiptCmd: `deepline runs logs ${quotedId} --kind receipt.completed --payloads --json`
|
|
22504
22514
|
};
|
|
22505
22515
|
}
|
|
22506
22516
|
function buildRunNavigation(status) {
|
|
@@ -24387,7 +24397,7 @@ Examples:
|
|
|
24387
24397
|
// src/cli/commands/run-receipt.ts
|
|
24388
24398
|
import { readFile, writeFile as writeFile3 } from "fs/promises";
|
|
24389
24399
|
function registerRunReceiptCommand(runs) {
|
|
24390
|
-
runs.command("receipt <runId>").description(
|
|
24400
|
+
runs.command("receipt <runId>", { hidden: true }).description(
|
|
24391
24401
|
"Read retained tool responses by receipt key. Never executes tools."
|
|
24392
24402
|
).option(
|
|
24393
24403
|
"--key <key>",
|
|
@@ -24401,8 +24411,7 @@ function registerRunReceiptCommand(runs) {
|
|
|
24401
24411
|
"after",
|
|
24402
24412
|
`
|
|
24403
24413
|
Examples:
|
|
24404
|
-
deepline runs
|
|
24405
|
-
jq -r '.[].receipt_key' rows.json | deepline runs receipt <run-id> --keys - --out responses.json
|
|
24414
|
+
deepline runs logs <run-id> --kind receipt.completed --payloads --json
|
|
24406
24415
|
|
|
24407
24416
|
Returns one outcome per key, preserving order and duplicates. A missing or
|
|
24408
24417
|
unavailable result is explicit; other keys are still returned. Exit 4 means
|
|
@@ -31672,7 +31681,7 @@ async function traceCliSpan(phase, fields2, run) {
|
|
|
31672
31681
|
}
|
|
31673
31682
|
|
|
31674
31683
|
// src/cli/play-check-hints.ts
|
|
31675
|
-
var EXTRACTED_GETTER_ERROR_HINT = "Deepline hint: extractedValues/extractedLists .get() only works for declared Deepline getters listed by `deepline tools describe <tool> --json`.
|
|
31684
|
+
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.";
|
|
31676
31685
|
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()`.";
|
|
31677
31686
|
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.";
|
|
31678
31687
|
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.";
|
|
@@ -36640,12 +36649,13 @@ function buildRunNextCommands(status) {
|
|
|
36640
36649
|
};
|
|
36641
36650
|
}
|
|
36642
36651
|
const actions2 = buildRunNavigation(status).actions;
|
|
36652
|
+
const exportDatasetCmds = Array.isArray(actions2.exportDatasetCmds) ? actions2.exportDatasetCmds : !status.package && extractCanonicalRowsInfo(status) ? [`deepline runs export ${runId} --out output.csv`] : [];
|
|
36643
36653
|
const commands = {
|
|
36644
36654
|
get: String(actions2.getRunCmd ?? `deepline runs get ${runId} --json`),
|
|
36645
36655
|
full: String(
|
|
36646
36656
|
actions2.getFullRunCmd ?? `deepline runs get ${runId} --full --json`
|
|
36647
36657
|
),
|
|
36648
|
-
...
|
|
36658
|
+
...exportDatasetCmds.length === 1 ? { export: String(exportDatasetCmds[0]) } : {},
|
|
36649
36659
|
logs: String(
|
|
36650
36660
|
!status.package ? `deepline runs logs ${runId} --out run.log --json` : actions2.getLogsCmd ?? `deepline runs logs ${runId} --limit 100 --json`
|
|
36651
36661
|
)
|
|
@@ -36654,7 +36664,7 @@ function buildRunNextCommands(status) {
|
|
|
36654
36664
|
commands.stop = `deepline runs stop ${runId} --json`;
|
|
36655
36665
|
}
|
|
36656
36666
|
if (status.status === "failed") {
|
|
36657
|
-
commands.failedLogs = `deepline runs
|
|
36667
|
+
commands.failedLogs = `deepline runs logs ${runId} --failed --json`;
|
|
36658
36668
|
if (status.rerunCommand) commands.run = status.rerunCommand;
|
|
36659
36669
|
}
|
|
36660
36670
|
if (status.dashboardUrl) {
|
|
@@ -37085,7 +37095,7 @@ function compactPlayStatus(status) {
|
|
|
37085
37095
|
next: {
|
|
37086
37096
|
...readRecord(packaged.next) ?? {},
|
|
37087
37097
|
...status.failedLogs ? {
|
|
37088
|
-
failedLogs: `deepline runs
|
|
37098
|
+
failedLogs: `deepline runs logs ${status.runId} --failed --json`
|
|
37089
37099
|
} : {},
|
|
37090
37100
|
...status.rerunCommand ? { run: status.rerunCommand } : {}
|
|
37091
37101
|
}
|
|
@@ -37098,14 +37108,14 @@ function compactPlayStatus(status) {
|
|
|
37098
37108
|
...status.failedLogs ? {
|
|
37099
37109
|
next: {
|
|
37100
37110
|
...readRecord(packaged.next) ?? {},
|
|
37101
|
-
failedLogs: `deepline runs
|
|
37111
|
+
failedLogs: `deepline runs logs ${status.runId} --failed --json`
|
|
37102
37112
|
}
|
|
37103
37113
|
} : {},
|
|
37104
37114
|
...status.rerunCommand ? {
|
|
37105
37115
|
next: {
|
|
37106
37116
|
...readRecord(packaged.next) ?? {},
|
|
37107
37117
|
...status.failedLogs ? {
|
|
37108
|
-
failedLogs: `deepline runs
|
|
37118
|
+
failedLogs: `deepline runs logs ${status.runId} --failed --json`
|
|
37109
37119
|
} : {},
|
|
37110
37120
|
run: status.rerunCommand
|
|
37111
37121
|
}
|
|
@@ -37154,9 +37164,6 @@ function compactRunErrorForEnvelope(message, runId) {
|
|
|
37154
37164
|
const headline = firstStackFrame >= 0 ? lines.slice(0, firstStackFrame).join("\n") : message;
|
|
37155
37165
|
return truncateErrorForDisplay(headline, runId, 1e3);
|
|
37156
37166
|
}
|
|
37157
|
-
function readRunPackageRun(packaged) {
|
|
37158
|
-
return packaged.run && typeof packaged.run === "object" && !Array.isArray(packaged.run) ? packaged.run : {};
|
|
37159
|
-
}
|
|
37160
37167
|
function readRecordArray(value) {
|
|
37161
37168
|
return Array.isArray(value) ? value.filter(
|
|
37162
37169
|
(item) => item !== null && typeof item === "object" && !Array.isArray(item)
|
|
@@ -37168,131 +37175,6 @@ function readRecord(value) {
|
|
|
37168
37175
|
function readNonNegativeInteger(value) {
|
|
37169
37176
|
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? Math.trunc(value) : null;
|
|
37170
37177
|
}
|
|
37171
|
-
function formatSummaryScalar(value) {
|
|
37172
|
-
if (typeof value === "number") {
|
|
37173
|
-
return Number.isFinite(value) ? formatInteger(Math.trunc(value)) : null;
|
|
37174
|
-
}
|
|
37175
|
-
if (typeof value === "string" || typeof value === "boolean") {
|
|
37176
|
-
return String(value);
|
|
37177
|
-
}
|
|
37178
|
-
if (value === null) {
|
|
37179
|
-
return "null";
|
|
37180
|
-
}
|
|
37181
|
-
return null;
|
|
37182
|
-
}
|
|
37183
|
-
function formatSummaryScalarParts(record5, skipKeys = /* @__PURE__ */ new Set()) {
|
|
37184
|
-
const parts = [];
|
|
37185
|
-
for (const [key, value] of Object.entries(record5)) {
|
|
37186
|
-
if (skipKeys.has(key)) {
|
|
37187
|
-
continue;
|
|
37188
|
-
}
|
|
37189
|
-
const formatted = formatSummaryScalar(value);
|
|
37190
|
-
if (formatted !== null) {
|
|
37191
|
-
parts.push(`${key}=${formatted}`);
|
|
37192
|
-
}
|
|
37193
|
-
}
|
|
37194
|
-
return parts;
|
|
37195
|
-
}
|
|
37196
|
-
var DATASET_SUMMARY_TOP_VALUES_DISPLAY_LIMIT = 10;
|
|
37197
|
-
function formatTopValuesPart(value) {
|
|
37198
|
-
const topValues = readRecord(value);
|
|
37199
|
-
if (!topValues) {
|
|
37200
|
-
return null;
|
|
37201
|
-
}
|
|
37202
|
-
const entries = Object.entries(topValues).slice(
|
|
37203
|
-
0,
|
|
37204
|
-
DATASET_SUMMARY_TOP_VALUES_DISPLAY_LIMIT
|
|
37205
|
-
);
|
|
37206
|
-
if (entries.length === 0) {
|
|
37207
|
-
return null;
|
|
37208
|
-
}
|
|
37209
|
-
return `top_values=${entries.map(([topValue, count2]) => `${topValue}=${String(count2)}`).join(", ")}`;
|
|
37210
|
-
}
|
|
37211
|
-
function formatPackageDatasetSummaryLines(summary, indent2 = " ") {
|
|
37212
|
-
const record5 = readRecord(summary);
|
|
37213
|
-
const columnStats = readRecord(record5?.columnStats);
|
|
37214
|
-
if (!record5 || !columnStats) {
|
|
37215
|
-
return [];
|
|
37216
|
-
}
|
|
37217
|
-
const lines = [];
|
|
37218
|
-
const rowCounts = readRecord(record5.rowCounts);
|
|
37219
|
-
if (rowCounts) {
|
|
37220
|
-
const persisted = readNonNegativeInteger(rowCounts.persisted);
|
|
37221
|
-
const succeeded = readNonNegativeInteger(rowCounts.succeeded);
|
|
37222
|
-
const failed = readNonNegativeInteger(rowCounts.failed);
|
|
37223
|
-
if (persisted !== null) {
|
|
37224
|
-
lines.push(
|
|
37225
|
-
`${indent2}rows: ${formatDatasetRowCountsLine({
|
|
37226
|
-
persisted,
|
|
37227
|
-
succeeded: succeeded ?? persisted,
|
|
37228
|
-
failed: failed ?? 0
|
|
37229
|
-
})}`
|
|
37230
|
-
);
|
|
37231
|
-
}
|
|
37232
|
-
}
|
|
37233
|
-
const parts = formatSummaryScalarParts(
|
|
37234
|
-
record5,
|
|
37235
|
-
/* @__PURE__ */ new Set(["columnStats", "rowCounts"])
|
|
37236
|
-
);
|
|
37237
|
-
if (parts.length > 0) {
|
|
37238
|
-
lines.push(`${indent2}summary: ${parts.join(" ")}`);
|
|
37239
|
-
}
|
|
37240
|
-
for (const [column, rawColumnSummary] of Object.entries(columnStats)) {
|
|
37241
|
-
const columnSummary = readRecord(rawColumnSummary);
|
|
37242
|
-
if (!columnSummary) continue;
|
|
37243
|
-
const execution = readRecord(columnSummary.execution);
|
|
37244
|
-
const executionText = execution ? Object.entries(execution).map(([bucket, value]) => `${bucket}=${String(value)}`).join(", ") : "";
|
|
37245
|
-
const topValuesText = formatTopValuesPart(columnSummary.top_values);
|
|
37246
|
-
const columnParts = [
|
|
37247
|
-
...formatSummaryScalarParts(
|
|
37248
|
-
columnSummary,
|
|
37249
|
-
/* @__PURE__ */ new Set(["execution", "top_values"])
|
|
37250
|
-
),
|
|
37251
|
-
topValuesText,
|
|
37252
|
-
executionText ? `execution=${executionText}` : null
|
|
37253
|
-
].filter(Boolean);
|
|
37254
|
-
if (columnParts.length > 0) {
|
|
37255
|
-
lines.push(`${indent2} ${column}: ${columnParts.join(" ")}`);
|
|
37256
|
-
}
|
|
37257
|
-
}
|
|
37258
|
-
return lines;
|
|
37259
|
-
}
|
|
37260
|
-
function actionToCommand(action) {
|
|
37261
|
-
if (!action || typeof action !== "object" || Array.isArray(action)) {
|
|
37262
|
-
return null;
|
|
37263
|
-
}
|
|
37264
|
-
const record5 = action;
|
|
37265
|
-
if (typeof record5.command === "string" && record5.command.trim()) {
|
|
37266
|
-
return record5.command.trim();
|
|
37267
|
-
}
|
|
37268
|
-
if (record5.kind === "deepline_run_inspect" && typeof record5.runId === "string") {
|
|
37269
|
-
return `deepline runs get ${record5.runId} --json`;
|
|
37270
|
-
}
|
|
37271
|
-
if (record5.kind === "deepline_run_full" && typeof record5.runId === "string") {
|
|
37272
|
-
return `deepline runs get ${record5.runId} --full --json`;
|
|
37273
|
-
}
|
|
37274
|
-
if (record5.kind === "deepline_run_billing" && typeof record5.runId === "string") {
|
|
37275
|
-
return `deepline runs get ${record5.runId} --full --json | jq '.billing'`;
|
|
37276
|
-
}
|
|
37277
|
-
if (record5.kind === "deepline_run_export" && typeof record5.runId === "string" && typeof record5.datasetPath === "string") {
|
|
37278
|
-
return `deepline runs export ${record5.runId} --dataset ${shellSingleQuote(
|
|
37279
|
-
record5.datasetPath
|
|
37280
|
-
)} --out ${shellSingleQuote(`${record5.datasetPath.split(".").pop() || "dataset"}.csv`)}`;
|
|
37281
|
-
}
|
|
37282
|
-
if (record5.kind === "deepline_run_logs") {
|
|
37283
|
-
if (typeof record5.command === "string" && record5.command.trim()) {
|
|
37284
|
-
return record5.command;
|
|
37285
|
-
}
|
|
37286
|
-
if (typeof record5.runId === "string") {
|
|
37287
|
-
return record5.view === "failed" ? `deepline runs get ${record5.runId} --log-failed --json` : `deepline runs logs ${record5.runId} --json`;
|
|
37288
|
-
}
|
|
37289
|
-
}
|
|
37290
|
-
if (record5.kind === "deepline_db_query" && typeof record5.sql === "string") {
|
|
37291
|
-
const maxRows = typeof record5.maxRows === "number" && Number.isFinite(record5.maxRows) ? Math.trunc(record5.maxRows) : 20;
|
|
37292
|
-
return `deepline db query --sql ${shellSingleQuote(record5.sql)} --max-rows ${maxRows} --json`;
|
|
37293
|
-
}
|
|
37294
|
-
return null;
|
|
37295
|
-
}
|
|
37296
37178
|
function packageDatasetRecords(packaged) {
|
|
37297
37179
|
const catalog = readRecordArray(packaged.datasets);
|
|
37298
37180
|
if (catalog.length > 0) return catalog;
|
|
@@ -37301,24 +37183,6 @@ function packageDatasetRecords(packaged) {
|
|
|
37301
37183
|
return output2?.kind === "dataset" ? [output2] : [];
|
|
37302
37184
|
});
|
|
37303
37185
|
}
|
|
37304
|
-
function packageReturnedDatasetIdentity(packaged) {
|
|
37305
|
-
const datasetIds = /* @__PURE__ */ new Set();
|
|
37306
|
-
const paths = /* @__PURE__ */ new Set();
|
|
37307
|
-
const outputs = readRecord(packaged.outputs) ?? {};
|
|
37308
|
-
for (const outputValue of Object.values(outputs)) {
|
|
37309
|
-
const output2 = readRecord(outputValue);
|
|
37310
|
-
if (output2?.kind !== "dataset") continue;
|
|
37311
|
-
if (typeof output2.datasetId === "string" && output2.datasetId.trim()) {
|
|
37312
|
-
datasetIds.add(output2.datasetId.trim());
|
|
37313
|
-
}
|
|
37314
|
-
for (const candidate of [output2.dataset, output2.path]) {
|
|
37315
|
-
if (typeof candidate === "string" && candidate.trim()) {
|
|
37316
|
-
paths.add(candidate.trim());
|
|
37317
|
-
}
|
|
37318
|
-
}
|
|
37319
|
-
}
|
|
37320
|
-
return { datasetIds, paths };
|
|
37321
|
-
}
|
|
37322
37186
|
function formatRunStepProgress(progress, includeRowOutcomes = false) {
|
|
37323
37187
|
const executed = readNonNegativeInteger(progress.executed);
|
|
37324
37188
|
const total = readNonNegativeInteger(progress.total);
|
|
@@ -37341,205 +37205,6 @@ function formatRunStepProgress(progress, includeRowOutcomes = false) {
|
|
|
37341
37205
|
}
|
|
37342
37206
|
return parts.join(" \xB7 ");
|
|
37343
37207
|
}
|
|
37344
|
-
function formatPackageDatasetActionLines(packaged, options) {
|
|
37345
|
-
const returned = packageReturnedDatasetIdentity(packaged);
|
|
37346
|
-
const includeSummary = options?.includeSummary ?? true;
|
|
37347
|
-
const lines = [];
|
|
37348
|
-
const steps = readRecordArray(packaged.steps);
|
|
37349
|
-
const stepsByDatasetId = /* @__PURE__ */ new Map();
|
|
37350
|
-
const stepsByPath = /* @__PURE__ */ new Map();
|
|
37351
|
-
const stepsByNamespace = /* @__PURE__ */ new Map();
|
|
37352
|
-
for (const step of steps) {
|
|
37353
|
-
if (step.kind !== "dataset") continue;
|
|
37354
|
-
const output2 = readRecord(step.output);
|
|
37355
|
-
if (typeof output2?.datasetId === "string") {
|
|
37356
|
-
stepsByDatasetId.set(output2.datasetId, step);
|
|
37357
|
-
}
|
|
37358
|
-
if (typeof output2?.path === "string") {
|
|
37359
|
-
stepsByPath.set(output2.path, step);
|
|
37360
|
-
}
|
|
37361
|
-
if (typeof step.id === "string") {
|
|
37362
|
-
stepsByNamespace.set(step.id, step);
|
|
37363
|
-
}
|
|
37364
|
-
}
|
|
37365
|
-
for (const dataset of packageDatasetRecords(packaged)) {
|
|
37366
|
-
const path = typeof dataset.path === "string" && dataset.path.trim() ? dataset.path.trim() : "dataset";
|
|
37367
|
-
const datasetId = typeof dataset.datasetId === "string" ? dataset.datasetId.trim() : "";
|
|
37368
|
-
const isReturned = datasetId && returned.datasetIds.has(datasetId) || returned.paths.has(path);
|
|
37369
|
-
const category = isReturned ? "returned" : dataset.recovered === true ? "recovered" : "persisted";
|
|
37370
|
-
const rowCount = typeof dataset.rowCount === "number" && Number.isFinite(dataset.rowCount) ? Math.max(0, Math.trunc(dataset.rowCount)) : null;
|
|
37371
|
-
const lifecycle = readRecord(dataset.lifecycle);
|
|
37372
|
-
const countUnconfirmed = lifecycle?.complete === false;
|
|
37373
|
-
const persistedLowerBound = typeof lifecycle?.persistedRowsAtLeast === "number" && Number.isFinite(lifecycle.persistedRowsAtLeast) ? Math.max(0, Math.trunc(lifecycle.persistedRowsAtLeast)) : 0;
|
|
37374
|
-
const actions2 = readRecord(dataset.actions) ?? {};
|
|
37375
|
-
if (countUnconfirmed) {
|
|
37376
|
-
lines.push(
|
|
37377
|
-
` dataset ${path}: row count unconfirmed (at least ${formatInteger(persistedLowerBound)} persisted)`
|
|
37378
|
-
);
|
|
37379
|
-
} else if (includeSummary) {
|
|
37380
|
-
if (category === "recovered" && Object.keys(actions2).length === 0) {
|
|
37381
|
-
lines.push(
|
|
37382
|
-
` dataset ${path}: available, ${rowCount === null ? "persisted" : formatInteger(rowCount)} rows persisted; re-running reuses completed work`
|
|
37383
|
-
);
|
|
37384
|
-
} else {
|
|
37385
|
-
lines.push(
|
|
37386
|
-
` ${category} dataset ${path}: ${rowCount === null ? "unknown rows" : `${formatInteger(rowCount)} ${rowCount === 1 ? "row" : "rows"}`}`
|
|
37387
|
-
);
|
|
37388
|
-
}
|
|
37389
|
-
}
|
|
37390
|
-
const step = (datasetId ? stepsByDatasetId.get(datasetId) : void 0) ?? stepsByPath.get(path) ?? (typeof dataset.tableNamespace === "string" ? stepsByNamespace.get(dataset.tableNamespace) : void 0);
|
|
37391
|
-
const progress = readRecord(step?.progress);
|
|
37392
|
-
if (progress) {
|
|
37393
|
-
lines.push(` progress: ${formatRunStepProgress(progress)}`);
|
|
37394
|
-
}
|
|
37395
|
-
if (lifecycle) {
|
|
37396
|
-
const succeeded = readNonNegativeInteger(lifecycle.succeededRowsAtLeast);
|
|
37397
|
-
const failed = readNonNegativeInteger(lifecycle.failedRowsAtLeast);
|
|
37398
|
-
const complete = lifecycle.complete === true;
|
|
37399
|
-
lines.push(
|
|
37400
|
-
` 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`}`
|
|
37401
|
-
);
|
|
37402
|
-
}
|
|
37403
|
-
const exportAction = readRecord(actions2.exportCsv);
|
|
37404
|
-
const exportCommand = actionToCommand(exportAction);
|
|
37405
|
-
const exportScope = readRecord(exportAction?.scope);
|
|
37406
|
-
const queryAction = readRecord(actions2.query);
|
|
37407
|
-
const queryScope = readRecord(queryAction?.scope);
|
|
37408
|
-
const runQueryCommand = queryScope?.kind === "run" ? actionToCommand(queryAction) : null;
|
|
37409
|
-
const currentQueryCommand = actionToCommand(actions2.queryCurrentTable);
|
|
37410
|
-
const legacyQueryCommand = actionToCommand(actions2.query);
|
|
37411
|
-
if (runQueryCommand) {
|
|
37412
|
-
lines.push(` query rows from this run: ${runQueryCommand}`);
|
|
37413
|
-
} else if (currentQueryCommand) {
|
|
37414
|
-
lines.push(` query current table: ${currentQueryCommand}`);
|
|
37415
|
-
} else if (legacyQueryCommand) {
|
|
37416
|
-
lines.push(` query run rows (legacy): ${legacyQueryCommand}`);
|
|
37417
|
-
}
|
|
37418
|
-
if (exportCommand) {
|
|
37419
|
-
lines.push(
|
|
37420
|
-
exportScope?.kind === "database" ? ` export current table (may include other runs): ${exportCommand}` : ` export this run: ${exportCommand}`
|
|
37421
|
-
);
|
|
37422
|
-
}
|
|
37423
|
-
const unavailable = readRecord(dataset.exportUnavailable);
|
|
37424
|
-
if (typeof unavailable?.reason === "string" && typeof unavailable.message === "string") {
|
|
37425
|
-
lines.push(
|
|
37426
|
-
` export unavailable (${unavailable.reason}): ${unavailable.message}`
|
|
37427
|
-
);
|
|
37428
|
-
}
|
|
37429
|
-
}
|
|
37430
|
-
return lines;
|
|
37431
|
-
}
|
|
37432
|
-
function packageSavedRowCount(packaged) {
|
|
37433
|
-
const rowCounts = packageDatasetRecords(packaged).map((dataset) => dataset.rowCount).filter(
|
|
37434
|
-
(rowCount) => typeof rowCount === "number" && Number.isFinite(rowCount)
|
|
37435
|
-
).map((rowCount) => Math.max(0, Math.trunc(rowCount)));
|
|
37436
|
-
if (rowCounts.length === 0) return null;
|
|
37437
|
-
return rowCounts.reduce((total, rowCount) => total + rowCount, 0);
|
|
37438
|
-
}
|
|
37439
|
-
function runtimeLimitWindowLabel(runtimeLimitFailure) {
|
|
37440
|
-
const message = getStringField(runtimeLimitFailure, "message") ?? "";
|
|
37441
|
-
const configuredSeconds = /\bconfigured\s+(\d+)\s+second(?:s)?\s+runtime limit\b/i.exec(message)?.[1];
|
|
37442
|
-
if (configuredSeconds) {
|
|
37443
|
-
const seconds = Number(configuredSeconds);
|
|
37444
|
-
if (Number.isSafeInteger(seconds) && seconds > 0) {
|
|
37445
|
-
if (seconds % 3600 === 0) return `${seconds / 3600}-hour`;
|
|
37446
|
-
if (seconds % 60 === 0) return `${seconds / 60}-minute`;
|
|
37447
|
-
return `${seconds}-second`;
|
|
37448
|
-
}
|
|
37449
|
-
}
|
|
37450
|
-
const match = /\b(\d+)\s+(hour|hours|minute|minutes|second|seconds)\b/i.exec(
|
|
37451
|
-
message
|
|
37452
|
-
);
|
|
37453
|
-
if (!match) return "30-minute";
|
|
37454
|
-
const unit = match[2].toLowerCase().replace(/s$/, "");
|
|
37455
|
-
return `${match[1]}-${unit}`;
|
|
37456
|
-
}
|
|
37457
|
-
function runtimeLimitCheckpointLines(packaged, runId, runtimeLimitFailure) {
|
|
37458
|
-
const savedRows = packageSavedRowCount(packaged);
|
|
37459
|
-
const lines = [
|
|
37460
|
-
`\u2713 progress saved ${runId}`,
|
|
37461
|
-
"",
|
|
37462
|
-
`The Play reached its ${runtimeLimitWindowLabel(runtimeLimitFailure)} runtime window.`
|
|
37463
|
-
];
|
|
37464
|
-
if (savedRows === null) {
|
|
37465
|
-
lines.push("Progress completed before the runtime window closed.");
|
|
37466
|
-
} else {
|
|
37467
|
-
lines.push(
|
|
37468
|
-
`${formatInteger(savedRows)} ${savedRows === 1 ? "row was" : "rows were"} saved successfully.`
|
|
37469
|
-
);
|
|
37470
|
-
}
|
|
37471
|
-
lines.push(
|
|
37472
|
-
"",
|
|
37473
|
-
"Run the same Play again to continue where you left off.",
|
|
37474
|
-
"Completed work will be reused automatically."
|
|
37475
|
-
);
|
|
37476
|
-
return lines;
|
|
37477
|
-
}
|
|
37478
|
-
function formatInlinePackageValue(value) {
|
|
37479
|
-
const compacted = compactReturnValue(value);
|
|
37480
|
-
const json2 = JSON.stringify(compacted);
|
|
37481
|
-
return clampJsonPreviewText(json2 ?? String(compacted), 500);
|
|
37482
|
-
}
|
|
37483
|
-
function formatPackageValueOutputLines(packaged) {
|
|
37484
|
-
const outputs = packaged.outputs && typeof packaged.outputs === "object" && !Array.isArray(packaged.outputs) ? packaged.outputs : null;
|
|
37485
|
-
if (!outputs) return [];
|
|
37486
|
-
const returned = Object.entries(outputs).filter(([, output2]) => {
|
|
37487
|
-
const record5 = readRecord(output2);
|
|
37488
|
-
return record5?.kind === "dataset" || record5?.kind === "value" && Object.prototype.hasOwnProperty.call(record5, "value");
|
|
37489
|
-
});
|
|
37490
|
-
if (returned.length === 0) return [];
|
|
37491
|
-
const datasets = packageDatasetRecords(packaged);
|
|
37492
|
-
const datasetSteps = readRecordArray(packaged.steps).filter(
|
|
37493
|
-
(step) => step.kind === "dataset"
|
|
37494
|
-
);
|
|
37495
|
-
const lines = [" result:"];
|
|
37496
|
-
for (const [name, rawOutput] of returned.slice(0, 8)) {
|
|
37497
|
-
const output2 = readRecord(rawOutput);
|
|
37498
|
-
if (output2.kind === "dataset") {
|
|
37499
|
-
const path = typeof output2.dataset === "string" ? output2.dataset : name;
|
|
37500
|
-
const rowCount = readNonNegativeInteger(output2.rowCount);
|
|
37501
|
-
lines.push(
|
|
37502
|
-
` ${name}: dataset ${path}${rowCount === null ? "" : ` (${formatInteger(rowCount)} persisted rows)`}`
|
|
37503
|
-
);
|
|
37504
|
-
const dataset = datasets.find(
|
|
37505
|
-
(candidate) => typeof output2.datasetId === "string" && candidate.datasetId === output2.datasetId || candidate.path === path
|
|
37506
|
-
);
|
|
37507
|
-
const stepOutput = datasetSteps.map((step) => readRecord(step.output)).find(
|
|
37508
|
-
(candidate) => typeof output2.datasetId === "string" && candidate?.datasetId === output2.datasetId || candidate?.path === path
|
|
37509
|
-
);
|
|
37510
|
-
const preview = readRecord(stepOutput?.preview ?? dataset?.preview);
|
|
37511
|
-
const rows = Array.isArray(preview?.rows) ? preview.rows.slice(0, 2) : [];
|
|
37512
|
-
if (rows.length > 0) {
|
|
37513
|
-
lines.push(` sample rows (${rows.length}):`);
|
|
37514
|
-
lines.push(
|
|
37515
|
-
...rows.map(
|
|
37516
|
-
(row) => ` ${clampJsonPreviewText(JSON.stringify(row) ?? String(row), 350)}`
|
|
37517
|
-
)
|
|
37518
|
-
);
|
|
37519
|
-
}
|
|
37520
|
-
continue;
|
|
37521
|
-
}
|
|
37522
|
-
const value = output2.value;
|
|
37523
|
-
const compacted = compactReturnValue(value);
|
|
37524
|
-
if (compacted && typeof compacted === "object") {
|
|
37525
|
-
lines.push(` ${name}:`);
|
|
37526
|
-
lines.push(...formatJsonPreview(compacted).map((line) => ` ${line}`));
|
|
37527
|
-
} else {
|
|
37528
|
-
lines.push(` ${name}: ${formatInlinePackageValue(value)}`);
|
|
37529
|
-
}
|
|
37530
|
-
}
|
|
37531
|
-
if (returned.length > 8) {
|
|
37532
|
-
lines.push(` ... ${returned.length - 8} more output(s)`);
|
|
37533
|
-
}
|
|
37534
|
-
return lines;
|
|
37535
|
-
}
|
|
37536
|
-
function authoredPackageStackFrames(packaged) {
|
|
37537
|
-
const stack = readRecordArray(packaged.errors).map((entry) => typeof entry.stack === "string" ? entry.stack : null).find((candidate) => Boolean(candidate?.trim()));
|
|
37538
|
-
if (!stack) return [];
|
|
37539
|
-
return stack.split("\n").map((line) => line.trim()).filter((line) => line.startsWith("at ")).filter(
|
|
37540
|
-
(line) => !line.includes("/virtual/deepline-plays/") && !line.includes("/apps/play-runner/") && !line.includes("/shared_libs/play-runtime/") && !line.includes("node:internal")
|
|
37541
|
-
).slice(0, 5);
|
|
37542
|
-
}
|
|
37543
37208
|
function activityTargetLabel(target) {
|
|
37544
37209
|
const kind = typeof target.kind === "string" ? target.kind : "target";
|
|
37545
37210
|
const label = typeof target.label === "string" ? target.label.trim() : "";
|
|
@@ -37695,152 +37360,6 @@ function formatRunTimingTextLines(run) {
|
|
|
37695
37360
|
].join(" \xB7 ")}`
|
|
37696
37361
|
];
|
|
37697
37362
|
}
|
|
37698
|
-
function formatRecentRunLogLines(value) {
|
|
37699
|
-
const logs = readRecord(value);
|
|
37700
|
-
if (!logs || !Array.isArray(logs.tail)) return [];
|
|
37701
|
-
const tail = logs.tail.filter(
|
|
37702
|
-
(line) => typeof line === "string"
|
|
37703
|
-
);
|
|
37704
|
-
if (tail.length === 0) return [];
|
|
37705
|
-
const shown = tail.map((line) => classifyLogLine(line)).filter(
|
|
37706
|
-
(entry) => entry.level !== "debug" && !isProviderRowWaitLogLine(entry.line)
|
|
37707
|
-
).slice(-8);
|
|
37708
|
-
const total = readNonNegativeInteger(logs.totalCount);
|
|
37709
|
-
if (shown.length === 0) {
|
|
37710
|
-
return [
|
|
37711
|
-
` recent logs: no non-debug lines in the retained preview (${total === null ? "total unknown" : `${formatInteger(total)} total`})`,
|
|
37712
|
-
...logs.truncated === true ? [" [older log bodies lost to retention limit]"] : []
|
|
37713
|
-
];
|
|
37714
|
-
}
|
|
37715
|
-
const lines = [
|
|
37716
|
-
` recent logs (${total === null ? "count unknown" : `${formatInteger(total)} total`}; showing ${shown.length}):`,
|
|
37717
|
-
...shown.map(
|
|
37718
|
-
(entry) => ` ${clampJsonPreviewText(formatProviderCapacityWaitLogLine(entry.line) ?? formatMapProgressDiagnosticLogLine(entry.line) ?? entry.line, 350)}`
|
|
37719
|
-
)
|
|
37720
|
-
];
|
|
37721
|
-
if (logs.truncated === true) {
|
|
37722
|
-
lines.push(" [older log bodies lost to retention limit]");
|
|
37723
|
-
}
|
|
37724
|
-
return lines;
|
|
37725
|
-
}
|
|
37726
|
-
function buildRunPackageTextLines(packaged) {
|
|
37727
|
-
const run = readRunPackageRun(packaged);
|
|
37728
|
-
const runId = typeof run.id === "string" ? run.id : "unknown";
|
|
37729
|
-
const status = typeof run.status === "string" ? run.status : "unknown";
|
|
37730
|
-
const playName = typeof run.playName === "string" ? run.playName : null;
|
|
37731
|
-
const runtimeLimitFailure = readRecordArray(packaged.errors).find(
|
|
37732
|
-
(entry) => entry.code === "RUNTIME_LIMIT_EXCEEDED"
|
|
37733
|
-
);
|
|
37734
|
-
const isRuntimeTimeout = status === "failed" && (runtimeLimitFailure !== void 0 || typeof run.error === "string" && /RUNTIME_LIMIT_EXCEEDED/.test(run.error));
|
|
37735
|
-
const isRuntimeLimitCheckpoint = isRuntimeTimeout;
|
|
37736
|
-
const checkpointFailure = runtimeLimitFailure ?? (typeof run.error === "string" ? { message: run.error } : { message: "The Play reached its runtime limit and was stopped." });
|
|
37737
|
-
const lines = isRuntimeLimitCheckpoint ? runtimeLimitCheckpointLines(packaged, runId, checkpointFailure) : [
|
|
37738
|
-
`${status === "completed" ? "\u2713" : status === "failed" ? "\u2717" : "\u2022"} ${status} ${runId}`
|
|
37739
|
-
];
|
|
37740
|
-
const outcome = typeof run.outcome === "string" ? run.outcome : null;
|
|
37741
|
-
if (outcome) lines.push(` outcome: ${outcome}`);
|
|
37742
|
-
const recovery = readRecord(run.recovery);
|
|
37743
|
-
if (recovery) {
|
|
37744
|
-
const mode = typeof recovery.mode === "string" ? recovery.mode : "recovered";
|
|
37745
|
-
const sourceRunId = typeof recovery.sourceRunId === "string" ? ` from ${recovery.sourceRunId}` : "";
|
|
37746
|
-
lines.push(` recovery: ${mode}${sourceRunId}`);
|
|
37747
|
-
}
|
|
37748
|
-
const runError = typeof run.error === "string" && run.error.trim() ? run.error.trim() : null;
|
|
37749
|
-
const structuredRuntimeLimitMessage = typeof runtimeLimitFailure?.message === "string" && runtimeLimitFailure.message.trim() ? `${typeof runtimeLimitFailure.code === "string" ? runtimeLimitFailure.code : "RUNTIME_LIMIT_EXCEEDED"}: ${runtimeLimitFailure.message.trim()}` : null;
|
|
37750
|
-
const displayRunError = structuredRuntimeLimitMessage ?? runError;
|
|
37751
|
-
if (!isRuntimeLimitCheckpoint && displayRunError && (status === "failed" || status === "cancelled")) {
|
|
37752
|
-
lines.push(` error: ${truncateErrorForDisplay(displayRunError, runId)}`);
|
|
37753
|
-
const stackFrames = authoredPackageStackFrames(packaged);
|
|
37754
|
-
if (stackFrames.length > 0) {
|
|
37755
|
-
lines.push(" stack:");
|
|
37756
|
-
lines.push(...stackFrames.map((frame) => ` ${frame}`));
|
|
37757
|
-
}
|
|
37758
|
-
}
|
|
37759
|
-
const failedLogs = readRecord(packaged.failedLogs);
|
|
37760
|
-
const failedLogEntries = Array.isArray(failedLogs?.entries) ? failedLogs.entries.filter(
|
|
37761
|
-
(entry) => typeof entry === "string"
|
|
37762
|
-
) : [];
|
|
37763
|
-
const failedLogAssociation = typeof failedLogs?.association === "string" ? failedLogs.association : null;
|
|
37764
|
-
const failedLogWarning = typeof failedLogs?.warning === "string" && failedLogs.warning.trim() ? failedLogs.warning.trim() : null;
|
|
37765
|
-
if (failedLogEntries.length > 0) {
|
|
37766
|
-
lines.push(" failed logs:");
|
|
37767
|
-
lines.push(...failedLogEntries.map((entry) => ` ${entry}`));
|
|
37768
|
-
}
|
|
37769
|
-
if (failedLogAssociation === "retained_before_truncation") {
|
|
37770
|
-
lines.push(" failed log context: last retained lines before truncation");
|
|
37771
|
-
}
|
|
37772
|
-
if (failedLogWarning) {
|
|
37773
|
-
lines.push(` warning: ${failedLogWarning}`);
|
|
37774
|
-
}
|
|
37775
|
-
const packageWarnings = Array.isArray(packaged.warnings) ? Array.from(
|
|
37776
|
-
new Set(
|
|
37777
|
-
packaged.warnings.filter(
|
|
37778
|
-
(warning) => typeof warning === "string" && warning.trim().length > 0
|
|
37779
|
-
)
|
|
37780
|
-
)
|
|
37781
|
-
).slice(0, 16) : [];
|
|
37782
|
-
lines.push(...packageWarnings.map((warning) => ` warning: ${warning}`));
|
|
37783
|
-
const failedLogNext = readRecord(failedLogs?.next);
|
|
37784
|
-
if (failedLogWarning && typeof failedLogNext?.logs === "string") {
|
|
37785
|
-
lines.push(
|
|
37786
|
-
failedLogAssociation === "retained_before_truncation" ? ` retained logs: ${failedLogNext.logs}` : ` retry failed logs: ${failedLogNext.logs}`
|
|
37787
|
-
);
|
|
37788
|
-
}
|
|
37789
|
-
if (playName && !isRuntimeLimitCheckpoint) {
|
|
37790
|
-
lines.push(` play: ${playName}`);
|
|
37791
|
-
}
|
|
37792
|
-
lines.push(...formatRunTimingTextLines(run));
|
|
37793
|
-
if (!isRuntimeLimitCheckpoint) {
|
|
37794
|
-
lines.push(...buildRunActivityTextLines(run));
|
|
37795
|
-
}
|
|
37796
|
-
lines.push(...buildRunStatusEvidenceTextLines(packaged));
|
|
37797
|
-
lines.push(...formatPackageValueOutputLines(packaged));
|
|
37798
|
-
lines.push(
|
|
37799
|
-
...formatPackageDatasetActionLines(packaged, {
|
|
37800
|
-
includeSummary: !isRuntimeLimitCheckpoint
|
|
37801
|
-
})
|
|
37802
|
-
);
|
|
37803
|
-
lines.push(...formatRecentRunLogLines(packaged.logs));
|
|
37804
|
-
const next = packaged.next && typeof packaged.next === "object" && !Array.isArray(packaged.next) ? packaged.next : {};
|
|
37805
|
-
const logsCommand = actionToCommand(next.logs);
|
|
37806
|
-
for (const step of isRuntimeLimitCheckpoint ? [] : readRecordArray(packaged.steps).slice(0, 8)) {
|
|
37807
|
-
const id = typeof step.id === "string" ? step.id : "step";
|
|
37808
|
-
const kind = typeof step.kind === "string" ? step.kind : "step";
|
|
37809
|
-
const stepStatus = typeof step.status === "string" ? step.status : status;
|
|
37810
|
-
const output2 = step.output && typeof step.output === "object" && !Array.isArray(step.output) ? step.output : null;
|
|
37811
|
-
const rowCount = output2 && typeof output2.rowCount === "number" ? ` rows=${formatInteger(output2.rowCount)}` : "";
|
|
37812
|
-
const preview = output2?.preview && typeof output2.preview === "object" && !Array.isArray(output2.preview) ? output2.preview : null;
|
|
37813
|
-
const previewRows = Array.isArray(preview?.rows) ? preview.rows.length : null;
|
|
37814
|
-
lines.push(` ${kind} ${id}: ${stepStatus}${rowCount}`);
|
|
37815
|
-
lines.push(...formatPackageDatasetSummaryLines(output2?.summary));
|
|
37816
|
-
if (previewRows !== null) {
|
|
37817
|
-
lines.push(
|
|
37818
|
-
` preview=${previewRows}${preview?.truncated ? " truncated" : ""}`
|
|
37819
|
-
);
|
|
37820
|
-
}
|
|
37821
|
-
}
|
|
37822
|
-
const inspectCommand = actionToCommand(next.inspect);
|
|
37823
|
-
const fullResultCommand = actionToCommand(next.full);
|
|
37824
|
-
const hasCatalogExportAction = packageDatasetRecords(packaged).some(
|
|
37825
|
-
(dataset) => Boolean(actionToCommand(readRecord(dataset.actions)?.exportCsv))
|
|
37826
|
-
);
|
|
37827
|
-
const legacyExportCommand = hasCatalogExportAction ? null : actionToCommand(next.export);
|
|
37828
|
-
const runAgainCommand = typeof next.run === "string" && next.run.trim() ? next.run.trim() : null;
|
|
37829
|
-
if (inspectCommand) lines.push(` inspect: ${inspectCommand}`);
|
|
37830
|
-
if (fullResultCommand)
|
|
37831
|
-
lines.push(
|
|
37832
|
-
` ${isRuntimeTimeout ? "full run details" : "full result"}: ${fullResultCommand}`
|
|
37833
|
-
);
|
|
37834
|
-
if (logsCommand) lines.push(` logs: ${logsCommand}`);
|
|
37835
|
-
if (legacyExportCommand) {
|
|
37836
|
-
lines.push(` export CSV: ${legacyExportCommand}`);
|
|
37837
|
-
}
|
|
37838
|
-
if (runAgainCommand && !isRuntimeLimitCheckpoint) {
|
|
37839
|
-
lines.push(" run again (completed work is reused):");
|
|
37840
|
-
lines.push(` ${runAgainCommand}`);
|
|
37841
|
-
}
|
|
37842
|
-
return lines;
|
|
37843
|
-
}
|
|
37844
37363
|
function buildOrdinaryPlayRunCommand(options, resolvedRevisionId) {
|
|
37845
37364
|
const target = options.target.kind === "file" ? options.target.path : options.target.name;
|
|
37846
37365
|
const parts = ["deepline", "plays", "run", shellSingleQuote(target)];
|
|
@@ -37926,6 +37445,57 @@ function buildRunLaunch(status) {
|
|
|
37926
37445
|
)
|
|
37927
37446
|
};
|
|
37928
37447
|
}
|
|
37448
|
+
function buildPlayCompletionTextLines(status) {
|
|
37449
|
+
const overview = buildRunOverview(status);
|
|
37450
|
+
const { run } = overview;
|
|
37451
|
+
const failed = run.status === "failed";
|
|
37452
|
+
const label = run.status === "completed" ? overview.rowOutcomes?.hasRowFailures ? "Completed with row failures" : "Completed" : failed ? "Failed" : run.status;
|
|
37453
|
+
const lines = [
|
|
37454
|
+
`${label} ${run.playName ?? status.playName ?? "Play"}`,
|
|
37455
|
+
`Run: ${run.id}`
|
|
37456
|
+
];
|
|
37457
|
+
for (const failure of overview.failures.steps) {
|
|
37458
|
+
lines.push(
|
|
37459
|
+
`Failed step: ${failure.stepId}${failure.message ? ` \u2014 ${failure.message}` : ""}`
|
|
37460
|
+
);
|
|
37461
|
+
}
|
|
37462
|
+
if (overview.errorDetails.run)
|
|
37463
|
+
lines.push(
|
|
37464
|
+
`Error: ${truncateErrorForDisplay(overview.errorDetails.run, run.id)}`
|
|
37465
|
+
);
|
|
37466
|
+
if (Object.hasOwn(overview, "result")) {
|
|
37467
|
+
lines.push(
|
|
37468
|
+
"Result:",
|
|
37469
|
+
...formatJsonPreview(compactReturnValue(overview.result))
|
|
37470
|
+
);
|
|
37471
|
+
}
|
|
37472
|
+
if (overview.rowOutcomes?.hasRowFailures) {
|
|
37473
|
+
lines.push(
|
|
37474
|
+
`Rows: ${overview.rowOutcomes.completedRows} completed, ${overview.rowOutcomes.failedRows} failed`
|
|
37475
|
+
);
|
|
37476
|
+
}
|
|
37477
|
+
for (const dataset of overview.datasets) {
|
|
37478
|
+
lines.push(
|
|
37479
|
+
`Rows (${dataset.name ?? dataset.datasetId}): ${dataset.rowCount ?? "unknown"}`
|
|
37480
|
+
);
|
|
37481
|
+
if (dataset.exportUnavailable)
|
|
37482
|
+
lines.push(`Export unavailable: ${dataset.exportUnavailable.message}`);
|
|
37483
|
+
}
|
|
37484
|
+
for (const warning of overview.warnings) lines.push(`Warning: ${warning}`);
|
|
37485
|
+
const exports = overview.actions.exportDatasetCmds;
|
|
37486
|
+
if (Array.isArray(exports))
|
|
37487
|
+
for (const command of exports) lines.push(`Export CSV: ${command}`);
|
|
37488
|
+
lines.push(
|
|
37489
|
+
`Logs: ${failed ? String(
|
|
37490
|
+
overview.actions.getFailedLogsCmd ?? `deepline runs logs ${shellSingleQuote(run.id)} --failed`
|
|
37491
|
+
) : String(
|
|
37492
|
+
overview.actions.getLogsCmd ?? `deepline runs logs ${shellSingleQuote(run.id)}`
|
|
37493
|
+
)}`
|
|
37494
|
+
);
|
|
37495
|
+
if (failed && status.rerunCommand)
|
|
37496
|
+
lines.push(`Retry: ${status.rerunCommand}`);
|
|
37497
|
+
return lines;
|
|
37498
|
+
}
|
|
37929
37499
|
function writePlayResult(status, jsonOutput, options) {
|
|
37930
37500
|
const packaged = getPlayRunPackage(status);
|
|
37931
37501
|
const hits = options?.hits ?? null;
|
|
@@ -37944,10 +37514,7 @@ function writePlayResult(status, jsonOutput, options) {
|
|
|
37944
37514
|
...displayPackage
|
|
37945
37515
|
} = compactPlayStatus(status);
|
|
37946
37516
|
const lines2 = [
|
|
37947
|
-
...
|
|
37948
|
-
buildRunPackageTextLines(displayPackage),
|
|
37949
|
-
status
|
|
37950
|
-
),
|
|
37517
|
+
...buildPlayCompletionTextLines(status),
|
|
37951
37518
|
...formatRunHitsLines(hits)
|
|
37952
37519
|
];
|
|
37953
37520
|
printCommandEnvelope(displayPackage, {
|
|
@@ -37983,7 +37550,7 @@ function writePlayResult(status, jsonOutput, options) {
|
|
|
37983
37550
|
)
|
|
37984
37551
|
);
|
|
37985
37552
|
if (status.status === "failed") {
|
|
37986
|
-
lines.push(` failed logs: deepline runs
|
|
37553
|
+
lines.push(` failed logs: deepline runs logs ${runId} --failed --json`);
|
|
37987
37554
|
if (status.rerunCommand) {
|
|
37988
37555
|
lines.push(" run again (completed work is reused):");
|
|
37989
37556
|
lines.push(` ${status.rerunCommand}`);
|
|
@@ -38013,18 +37580,23 @@ function writePlayResult(status, jsonOutput, options) {
|
|
|
38013
37580
|
);
|
|
38014
37581
|
}
|
|
38015
37582
|
function withRunNavigationLines(lines, status, actionCommands = buildRunNavigation(status).actions) {
|
|
38016
|
-
const navigation = buildRunNavigation(status);
|
|
38017
37583
|
const existing = lines.join("\n");
|
|
38018
|
-
|
|
38019
|
-
|
|
38020
|
-
|
|
38021
|
-
|
|
38022
|
-
|
|
38023
|
-
|
|
37584
|
+
const labels = {
|
|
37585
|
+
getRunCmd: "Inspect",
|
|
37586
|
+
getFullRunCmd: "Full run",
|
|
37587
|
+
getBillingCmd: "Billing",
|
|
37588
|
+
getLogsCmd: "Logs",
|
|
37589
|
+
getFailedLogsCmd: "Failure logs",
|
|
37590
|
+
getReceiptCmd: "Saved responses",
|
|
37591
|
+
exportDatasetCmds: "Export rows",
|
|
37592
|
+
queryTableSqlCmds: "Query rows",
|
|
37593
|
+
stopRunCmd: "Stop run",
|
|
37594
|
+
rerunCmd: "Retry"
|
|
37595
|
+
};
|
|
38024
37596
|
for (const [name, value] of Object.entries(actionCommands)) {
|
|
38025
37597
|
for (const command of Array.isArray(value) ? value : [value]) {
|
|
38026
37598
|
if (typeof command === "string" && !existing.includes(command))
|
|
38027
|
-
lines.push(` ${name}: ${command}`);
|
|
37599
|
+
lines.push(` ${labels[name] ?? name}: ${command}`);
|
|
38028
37600
|
}
|
|
38029
37601
|
}
|
|
38030
37602
|
return lines;
|
|
@@ -38767,7 +38339,12 @@ function writeStartedPlayRun(input2) {
|
|
|
38767
38339
|
failedLogs: _failedLogs,
|
|
38768
38340
|
...displayPackage
|
|
38769
38341
|
} = input2.package;
|
|
38770
|
-
const lines2 =
|
|
38342
|
+
const lines2 = buildPlayCompletionTextLines({
|
|
38343
|
+
runId: input2.runId,
|
|
38344
|
+
playName: input2.playName,
|
|
38345
|
+
status: input2.status,
|
|
38346
|
+
package: displayPackage
|
|
38347
|
+
});
|
|
38771
38348
|
const output3 = lines2.join("\n");
|
|
38772
38349
|
if (input2.progress) {
|
|
38773
38350
|
input2.progress.writeLine(output3, process.stdout);
|
|
@@ -38795,17 +38372,11 @@ function writeStartedPlayRun(input2) {
|
|
|
38795
38372
|
};
|
|
38796
38373
|
const lines = [
|
|
38797
38374
|
`Started ${input2.playName}`,
|
|
38798
|
-
`
|
|
38799
|
-
`
|
|
38800
|
-
` input: ${input2.inputFieldCount ?? 0} top-level field(s) supplied`,
|
|
38801
|
-
` 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"}`,
|
|
38802
|
-
` inspect: deepline runs get ${input2.runId} --json`,
|
|
38803
|
-
` full debug: deepline runs get ${input2.runId} --full --json`,
|
|
38804
|
-
` logs: deepline runs logs ${input2.runId} --json`,
|
|
38805
|
-
` export after completion: deepline runs export ${input2.runId} --out output.csv`,
|
|
38375
|
+
`Run: ${input2.runId}`,
|
|
38376
|
+
`Logs: deepline runs logs ${shellSingleQuote(input2.runId)}`,
|
|
38806
38377
|
...["started", "queued", "running", "waiting"].includes(
|
|
38807
38378
|
input2.status ?? "started"
|
|
38808
|
-
) ? [`
|
|
38379
|
+
) ? [`Stop: deepline runs stop ${shellSingleQuote(input2.runId)} --json`] : []
|
|
38809
38380
|
];
|
|
38810
38381
|
if (input2.jsonOutput) {
|
|
38811
38382
|
printCommandEnvelope(payload, { json: true, fields: input2.jsonFields });
|
|
@@ -40227,7 +39798,7 @@ function renderRunOverviewText(overview, extras = {}) {
|
|
|
40227
39798
|
getBillingCmd: "Billing",
|
|
40228
39799
|
getLogsCmd: "Logs",
|
|
40229
39800
|
getFailedLogsCmd: "Failure logs",
|
|
40230
|
-
getReceiptCmd: "
|
|
39801
|
+
getReceiptCmd: "Saved responses",
|
|
40231
39802
|
exportDatasetCmds: "Export rows",
|
|
40232
39803
|
queryTableSqlCmds: "Query rows",
|
|
40233
39804
|
stopRunCmd: "Stop run",
|
|
@@ -40249,7 +39820,7 @@ async function handleRunGet(args) {
|
|
|
40249
39820
|
args.includes("--config") ? "config" : "get"
|
|
40250
39821
|
);
|
|
40251
39822
|
args = selection.args;
|
|
40252
|
-
const usage2 = "Usage: deepline runs get <run-id> [--json] [--full] [--input] [--config]
|
|
39823
|
+
const usage2 = "Usage: deepline runs get <run-id> [--json] [--full] [--input] [--config]";
|
|
40253
39824
|
let runId;
|
|
40254
39825
|
try {
|
|
40255
39826
|
runId = parseRunIdPositional(args, usage2);
|
|
@@ -43258,7 +42829,7 @@ Examples:
|
|
|
43258
42829
|
deepline runs get play/my-play/run/20260501t000000-000
|
|
43259
42830
|
deepline runs get play/my-play/run/20260501t000000-000 --json
|
|
43260
42831
|
deepline runs get play/my-play/run/20260501t000000-000 --json run.status,run.durationMs
|
|
43261
|
-
deepline runs
|
|
42832
|
+
deepline runs logs play/my-play/run/20260501t000000-000 --failed --json
|
|
43262
42833
|
deepline runs get play/my-play/run/20260501t000000-000 --full --json
|
|
43263
42834
|
deepline runs get play/my-play/run/20260501t000000-000 --input
|
|
43264
42835
|
deepline runs get play/my-play/run/20260501t000000-000 --config --json
|
|
@@ -43275,9 +42846,8 @@ Examples:
|
|
|
43275
42846
|
).option(
|
|
43276
42847
|
"--config",
|
|
43277
42848
|
"Explicitly print the recorded configuration, without full results"
|
|
43278
|
-
).
|
|
43279
|
-
"--log-failed",
|
|
43280
|
-
"Attach a bounded terminal-failure log window for failed runs"
|
|
42849
|
+
).addOption(
|
|
42850
|
+
new Option4("--log-failed", "Attach terminal-failure logs").hideHelp()
|
|
43281
42851
|
).action(async (runId, options) => {
|
|
43282
42852
|
process.exitCode = await handleRunGet([
|
|
43283
42853
|
runId,
|
|
@@ -50728,7 +50298,10 @@ Examples:
|
|
|
50728
50298
|
`
|
|
50729
50299
|
Notes:
|
|
50730
50300
|
Shows the compact agent contract by default: what the tool does, cost,
|
|
50731
|
-
required inputs, play getters, and
|
|
50301
|
+
required inputs, play getters, input and full Deepline response examples,
|
|
50302
|
+
and a ctx.tools.execute snippet. Tool responses live at toolResponse.rawV2;
|
|
50303
|
+
preserve the nesting shown in the tool's example. Schemas and examples are
|
|
50304
|
+
separate describe fields.
|
|
50732
50305
|
get is accepted as a compatibility alias for describe.
|
|
50733
50306
|
|
|
50734
50307
|
Examples:
|
|
@@ -50751,7 +50324,7 @@ Examples:
|
|
|
50751
50324
|
"Quote an ai_evaluate, ai_inference, or deeplineagent JSON payload (inline or @file)"
|
|
50752
50325
|
).option("--pricing-only", "Only print pricing and billing semantics").option("--schema-only", "Only print input schema fields").option(
|
|
50753
50326
|
"--examples-only",
|
|
50754
|
-
"Only print
|
|
50327
|
+
"Only print input payload and full Deepline execution response examples"
|
|
50755
50328
|
).option("--getters-only", "Only print extracted list/value getters").addOption(
|
|
50756
50329
|
new Option5(
|
|
50757
50330
|
"--compact",
|
|
@@ -50928,6 +50501,30 @@ async function getTool(toolId, options = {}) {
|
|
|
50928
50501
|
);
|
|
50929
50502
|
return 0;
|
|
50930
50503
|
}
|
|
50504
|
+
if ((options.schemaOnly || options.examplesOnly || options.gettersOnly) && !isMonitorTypeTool(tool) && !isPlayLikeTool(tool) && (options.json || options.contractJson)) {
|
|
50505
|
+
const contract = toolContractJsonForDescribe(tool, toolId);
|
|
50506
|
+
printCompactJson({
|
|
50507
|
+
toolId: contract.toolId,
|
|
50508
|
+
...options.schemaOnly ? {
|
|
50509
|
+
inputSchema: contract.inputSchema,
|
|
50510
|
+
inputFields: contract.inputFields,
|
|
50511
|
+
outputSchema: contract.outputSchema,
|
|
50512
|
+
outputFields: contract.outputFields,
|
|
50513
|
+
responseSchema: contract.responseSchema
|
|
50514
|
+
} : options.examplesOnly ? {
|
|
50515
|
+
examples: contract.examples ?? [],
|
|
50516
|
+
responseAccess: contract.responseAccess,
|
|
50517
|
+
getters: contract.getters,
|
|
50518
|
+
executeCommand: contract.executeCommand
|
|
50519
|
+
} : {
|
|
50520
|
+
getters: contract.getters,
|
|
50521
|
+
responseAccess: contract.responseAccess
|
|
50522
|
+
},
|
|
50523
|
+
...modelDescription ? { modelOptions: modelDescription } : {},
|
|
50524
|
+
...inferenceQuote ? { inferenceQuote } : {}
|
|
50525
|
+
});
|
|
50526
|
+
return 0;
|
|
50527
|
+
}
|
|
50931
50528
|
if (options.contractJson) {
|
|
50932
50529
|
printCompactJson({
|
|
50933
50530
|
...toolContractJsonForDescribe(tool, toolId),
|
|
@@ -51069,6 +50666,9 @@ function toolContractJsonForDescribe(tool, requestedToolId) {
|
|
|
51069
50666
|
} : {},
|
|
51070
50667
|
inputFields: inputFields.map(inputFieldJsonForDescribe),
|
|
51071
50668
|
inputSchema,
|
|
50669
|
+
...isRecord8(tool.responseSchema) ? { responseSchema: tool.responseSchema } : {},
|
|
50670
|
+
...Array.isArray(tool.examples) ? { examples: tool.examples } : {},
|
|
50671
|
+
responseAccess: "result.toolResponse.rawV2",
|
|
51072
50672
|
...Object.keys(outputSchemaRecord).length > 0 ? {
|
|
51073
50673
|
outputSchema: publicToolInputSchemaForDescribe(outputSchemaRecord),
|
|
51074
50674
|
outputFields: outputFields.map(inputFieldJsonForDescribe)
|
|
@@ -51290,15 +50890,13 @@ function printCompactToolContract(tool, requestedToolId) {
|
|
|
51290
50890
|
}
|
|
51291
50891
|
}
|
|
51292
50892
|
console.log("");
|
|
51293
|
-
printToolExamplesOnly(tool, requestedToolId
|
|
50893
|
+
printToolExamplesOnly(tool, requestedToolId);
|
|
51294
50894
|
const starterScript = isRecord8(contract.starterScript) ? contract.starterScript : {};
|
|
51295
50895
|
const starterPath = stringField2(starterScript, "path");
|
|
51296
50896
|
if (starterPath) {
|
|
51297
50897
|
console.log("");
|
|
51298
50898
|
console.log(`Starter script: ${starterPath}`);
|
|
51299
|
-
console.log(
|
|
51300
|
-
"Copy it into your project and replace the sample input with the proven probe payload."
|
|
51301
|
-
);
|
|
50899
|
+
console.log("Copy it into your project and adapt the example input.");
|
|
51302
50900
|
}
|
|
51303
50901
|
if (listGetters.length || valueGetters.length) {
|
|
51304
50902
|
console.log("");
|
|
@@ -51388,11 +50986,15 @@ function printToolSchemaOnly(tool, requestedToolId) {
|
|
|
51388
50986
|
recordField(contract, "inputSchema")
|
|
51389
50987
|
);
|
|
51390
50988
|
if (declaredSchema) {
|
|
51391
|
-
console.log("Declared JSON Schema:");
|
|
50989
|
+
console.log("Declared input JSON Schema:");
|
|
51392
50990
|
console.log(JSON.stringify(declaredSchema, null, 2));
|
|
51393
50991
|
}
|
|
50992
|
+
if (isRecord8(contract.responseSchema)) {
|
|
50993
|
+
console.log("Deepline execution response JSON Schema:");
|
|
50994
|
+
console.log(JSON.stringify(contract.responseSchema, null, 2));
|
|
50995
|
+
}
|
|
51394
50996
|
}
|
|
51395
|
-
function printToolExamplesOnly(tool, requestedToolId
|
|
50997
|
+
function printToolExamplesOnly(tool, requestedToolId) {
|
|
51396
50998
|
if (isMonitorTypeTool(tool)) {
|
|
51397
50999
|
printMonitorTypeDeploy(tool);
|
|
51398
51000
|
return;
|
|
@@ -51404,7 +51006,11 @@ function printToolExamplesOnly(tool, requestedToolId, options = {}) {
|
|
|
51404
51006
|
const contract = toolContractJsonForDescribe(tool, requestedToolId);
|
|
51405
51007
|
const toolId = String(contract.toolId);
|
|
51406
51008
|
const inputFields = Array.isArray(contract.inputFields) ? contract.inputFields : [];
|
|
51407
|
-
const
|
|
51009
|
+
const examples = arrayField2(tool, "examples").filter(isRecord8);
|
|
51010
|
+
const firstExample = examples[0];
|
|
51011
|
+
const sampleInput = firstExample && isRecord8(firstExample.input) ? firstExample.input : samplePayload(recordField(tool, "samples"), "request") ?? samplePayloadForInputFields(inputFields);
|
|
51012
|
+
console.log("Example input payload:");
|
|
51013
|
+
console.log(JSON.stringify(sampleInput, null, 2));
|
|
51408
51014
|
console.log(`Use in a play:`);
|
|
51409
51015
|
console.log("```ts");
|
|
51410
51016
|
console.log("const result = await ctx.tools.execute({");
|
|
@@ -51414,6 +51020,7 @@ function printToolExamplesOnly(tool, requestedToolId, options = {}) {
|
|
|
51414
51020
|
` input: ${JSON.stringify(sampleInput || {}, null, 2).replace(/\n/g, "\n ")},`
|
|
51415
51021
|
);
|
|
51416
51022
|
console.log("});");
|
|
51023
|
+
console.log("const response = result.toolResponse.rawV2;");
|
|
51417
51024
|
const getters = isRecord8(contract.getters) ? contract.getters : {};
|
|
51418
51025
|
const valueGetters = Array.isArray(getters.extractedValues) ? getters.extractedValues : [];
|
|
51419
51026
|
const listGetters = Array.isArray(getters.extractedLists) ? getters.extractedLists : [];
|
|
@@ -51427,10 +51034,19 @@ function printToolExamplesOnly(tool, requestedToolId, options = {}) {
|
|
|
51427
51034
|
);
|
|
51428
51035
|
}
|
|
51429
51036
|
console.log("```");
|
|
51430
|
-
|
|
51431
|
-
const
|
|
51432
|
-
|
|
51037
|
+
for (const example of examples) {
|
|
51038
|
+
const description = stringField2(example, "description");
|
|
51039
|
+
if (description) console.log(description);
|
|
51040
|
+
console.log("Example Deepline execution response:");
|
|
51041
|
+
console.log(JSON.stringify(example.response, null, 2));
|
|
51433
51042
|
}
|
|
51043
|
+
if (!examples.length)
|
|
51044
|
+
console.log(
|
|
51045
|
+
"No Deepline execution response example is published by this server."
|
|
51046
|
+
);
|
|
51047
|
+
console.log(
|
|
51048
|
+
"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."
|
|
51049
|
+
);
|
|
51434
51050
|
}
|
|
51435
51051
|
function printPlayLikeToolUsage(tool, requestedToolId) {
|
|
51436
51052
|
const toolId = String(tool.toolId || requestedToolId);
|
|
@@ -51575,9 +51191,9 @@ function toolMetadataJsonForDescribe(tool, requestedToolId) {
|
|
|
51575
51191
|
inputFields: inputFields.map(inputFieldJsonForDescribe),
|
|
51576
51192
|
usageGuidance,
|
|
51577
51193
|
runtimeOutputHelp: {
|
|
51578
|
-
contract: "
|
|
51194
|
+
contract: "Schemas declare field shapes. Examples illustrate input payloads and full Deepline execution responses; they are not observed responses from this call.",
|
|
51579
51195
|
getterScope: "extractedValues/extractedLists .get() only works for declared Deepline getters listed in usageGuidance.toolExecutionResult.",
|
|
51580
|
-
rawToolResponse: "Use toolExecutionResult.toolResponse.rawV2 for
|
|
51196
|
+
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.",
|
|
51581
51197
|
invalidGetterHint: "If TypeScript says an extractedValues/extractedLists property does not exist, that field is not a declared Deepline getter.",
|
|
51582
51198
|
observeActualShape: observedOutputCommand,
|
|
51583
51199
|
observedOutput: observedOutputCommand,
|
|
@@ -51592,7 +51208,25 @@ function usageGuidanceWithAccessDefaults(usageGuidance) {
|
|
|
51592
51208
|
const existingAccess = recordField(usageGuidance, "access");
|
|
51593
51209
|
return {
|
|
51594
51210
|
...usageGuidance,
|
|
51211
|
+
prefer: [
|
|
51212
|
+
"Use only the declared extractedLists and extractedValues getters listed below.",
|
|
51213
|
+
"Use toolExecutionResult.toolResponse.rawV2 for the complete tool response, preserving the nesting shown in the response example.",
|
|
51214
|
+
"Schemas declare field shapes; examples illustrate input values and full Deepline execution responses."
|
|
51215
|
+
],
|
|
51216
|
+
toolExecutionResult: {
|
|
51217
|
+
...recordField(
|
|
51218
|
+
usageGuidance,
|
|
51219
|
+
"toolExecutionResult",
|
|
51220
|
+
"tool_execution_result"
|
|
51221
|
+
),
|
|
51222
|
+
toolResponse: {
|
|
51223
|
+
rawV2: "toolResponse.rawV2",
|
|
51224
|
+
view: "toolResponse.view",
|
|
51225
|
+
responseMeta: "toolResponse.responseMeta"
|
|
51226
|
+
}
|
|
51227
|
+
},
|
|
51595
51228
|
access: {
|
|
51229
|
+
...existingAccess,
|
|
51596
51230
|
extractedLists: {
|
|
51597
51231
|
expression: "toolExecutionResult.extractedLists.<name>.get()",
|
|
51598
51232
|
meaning: "Declared Deepline list extractors only."
|
|
@@ -51604,13 +51238,13 @@ function usageGuidanceWithAccessDefaults(usageGuidance) {
|
|
|
51604
51238
|
...existingAccess,
|
|
51605
51239
|
rawToolResponse: {
|
|
51606
51240
|
expression: "toolExecutionResult.toolResponse.rawV2",
|
|
51607
|
-
meaning: "Complete
|
|
51241
|
+
meaning: "Complete tool response with its original nesting. Read tool-specific fields here; use declared getters for extracted values and lists."
|
|
51608
51242
|
},
|
|
51609
51243
|
canonicalToolResponse: {
|
|
51610
51244
|
expression: "toolExecutionResult.toolResponse.rawV2",
|
|
51611
|
-
meaning: "Complete
|
|
51245
|
+
meaning: "Complete tool response with its original nesting and sibling fields."
|
|
51612
51246
|
},
|
|
51613
|
-
invalidGetterHint: "If TypeScript says an extractedValues/extractedLists property does not exist, that field is not a declared Deepline getter;
|
|
51247
|
+
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."
|
|
51614
51248
|
}
|
|
51615
51249
|
};
|
|
51616
51250
|
}
|
|
@@ -51942,23 +51576,6 @@ function formatRateWindow(windowMs) {
|
|
|
51942
51576
|
if (windowMs === 36e5) return "hour";
|
|
51943
51577
|
return `${windowMs}ms`;
|
|
51944
51578
|
}
|
|
51945
|
-
function printSamples(samples) {
|
|
51946
|
-
const requestPayload = samplePayload(samples, "request");
|
|
51947
|
-
const responsePayload = samplePayload(samples, "response");
|
|
51948
|
-
if (requestPayload === void 0 && responsePayload === void 0) return;
|
|
51949
|
-
console.log(" Samples:");
|
|
51950
|
-
if (requestPayload !== void 0)
|
|
51951
|
-
printJsonPreview("Example payload", requestPayload);
|
|
51952
|
-
if (responsePayload !== void 0)
|
|
51953
|
-
printJsonPreview("Example response", responsePayload);
|
|
51954
|
-
}
|
|
51955
|
-
function printJsonPreview(label, payload) {
|
|
51956
|
-
console.log(` ${label}:`);
|
|
51957
|
-
const rendered = JSON.stringify(payload, null, 2);
|
|
51958
|
-
for (const line of rendered.split("\n")) {
|
|
51959
|
-
console.log(` ${line}`);
|
|
51960
|
-
}
|
|
51961
|
-
}
|
|
51962
51579
|
function samplePayload(samples, key) {
|
|
51963
51580
|
const entry = samples[key];
|
|
51964
51581
|
if (!isRecord8(entry)) return void 0;
|
|
@@ -52571,9 +52188,13 @@ async function executeTool(args) {
|
|
|
52571
52188
|
}).catch((error) => {
|
|
52572
52189
|
const guidanceLines = toolGuidanceLines(metadata.guidance);
|
|
52573
52190
|
if (guidanceLines.length > 0) {
|
|
52574
|
-
|
|
52575
|
-
|
|
52576
|
-
|
|
52191
|
+
if (args.includes("--json") && error instanceof Error) {
|
|
52192
|
+
Object.assign(error, { guidance: metadata.guidance });
|
|
52193
|
+
} else {
|
|
52194
|
+
console.error(
|
|
52195
|
+
[`Guidance for ${parsed.toolId}:`, ...guidanceLines].join("\n")
|
|
52196
|
+
);
|
|
52197
|
+
}
|
|
52577
52198
|
}
|
|
52578
52199
|
throw error;
|
|
52579
52200
|
});
|