deepline 0.1.51 → 0.1.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +254 -79
- package/dist/cli/index.mjs +254 -79
- package/dist/index.d.mts +68 -7
- package/dist/index.d.ts +68 -7
- package/dist/index.js +68 -15
- package/dist/index.mjs +68 -15
- package/dist/repo/sdk/src/client.ts +92 -19
- package/dist/repo/sdk/src/play.ts +3 -0
- package/dist/repo/sdk/src/release.ts +60 -0
- package/dist/repo/sdk/src/types.ts +60 -2
- package/dist/repo/sdk/src/version.ts +6 -2
- package/package.json +6 -5
package/dist/cli/index.mjs
CHANGED
|
@@ -195,9 +195,20 @@ function resolveConfig(options) {
|
|
|
195
195
|
};
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
+
// src/release.ts
|
|
199
|
+
var SDK_RELEASE = {
|
|
200
|
+
version: "0.1.53",
|
|
201
|
+
apiContract: "2026-05-run-response-package",
|
|
202
|
+
supportPolicy: {
|
|
203
|
+
latest: "0.1.53",
|
|
204
|
+
minimumSupported: "0.1.53",
|
|
205
|
+
deprecatedBelow: "0.1.53"
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
|
|
198
209
|
// src/version.ts
|
|
199
|
-
var SDK_VERSION =
|
|
200
|
-
var SDK_API_CONTRACT =
|
|
210
|
+
var SDK_VERSION = SDK_RELEASE.version;
|
|
211
|
+
var SDK_API_CONTRACT = SDK_RELEASE.apiContract;
|
|
201
212
|
|
|
202
213
|
// ../shared_libs/play-runtime/coordinator-headers.ts
|
|
203
214
|
var COORDINATOR_INTERNAL_TOKEN_HEADER = "x-deepline-internal-token";
|
|
@@ -525,15 +536,38 @@ function isTransientCompileManifestError(error) {
|
|
|
525
536
|
function isRecord(value) {
|
|
526
537
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
527
538
|
}
|
|
539
|
+
function isPlayRunPackage(value) {
|
|
540
|
+
return Boolean(
|
|
541
|
+
value && typeof value === "object" && !Array.isArray(value) && value.kind === "play_run" && value.run && typeof value.run?.id === "string"
|
|
542
|
+
);
|
|
543
|
+
}
|
|
528
544
|
function normalizePlayStatus(raw) {
|
|
529
|
-
const
|
|
530
|
-
const
|
|
545
|
+
const runPackage = isPlayRunPackage(raw) ? raw : isPlayRunPackage(raw.package) ? raw.package : null;
|
|
546
|
+
const packageRun = runPackage?.run;
|
|
547
|
+
const status = typeof raw.status === "string" ? raw.status : typeof packageRun?.status === "string" ? packageRun.status : "running";
|
|
548
|
+
const runId = typeof raw.runId === "string" ? raw.runId : typeof raw.workflowId === "string" ? raw.workflowId : packageRun?.id ?? "";
|
|
531
549
|
return {
|
|
532
550
|
...raw,
|
|
533
551
|
runId,
|
|
552
|
+
...runPackage ? { package: runPackage, outputs: runPackage.outputs } : {},
|
|
534
553
|
status
|
|
535
554
|
};
|
|
536
555
|
}
|
|
556
|
+
function normalizePlayRunStart(raw) {
|
|
557
|
+
const runPackage = isPlayRunPackage(raw) ? raw : isPlayRunPackage(raw.package) ? raw.package : null;
|
|
558
|
+
if (!runPackage) {
|
|
559
|
+
return raw;
|
|
560
|
+
}
|
|
561
|
+
const status = typeof runPackage.run.status === "string" ? runPackage.run.status : "running";
|
|
562
|
+
return {
|
|
563
|
+
workflowId: runPackage.run.id,
|
|
564
|
+
name: runPackage.run.playName,
|
|
565
|
+
status,
|
|
566
|
+
...runPackage.run.dashboardUrl ? { dashboardUrl: runPackage.run.dashboardUrl } : {},
|
|
567
|
+
...TERMINAL_PLAY_STATUSES.has(status) ? { finalStatus: runPackage } : {},
|
|
568
|
+
package: runPackage
|
|
569
|
+
};
|
|
570
|
+
}
|
|
537
571
|
function decodeBase64Bytes(value) {
|
|
538
572
|
const binary = atob(value);
|
|
539
573
|
const bytes = new Uint8Array(binary.length);
|
|
@@ -563,25 +597,31 @@ function updatePlayLiveStatusState(state, event) {
|
|
|
563
597
|
if (event.type !== "play.run.snapshot" && event.type !== "play.run.status" && event.type !== "play.run.final_status") {
|
|
564
598
|
return null;
|
|
565
599
|
}
|
|
566
|
-
const runId = typeof payload.runId === "string" && payload.runId ? payload.runId : state.runId;
|
|
567
|
-
const status = normalizeLiveStatus(payload.status) ?? state.status;
|
|
568
|
-
const
|
|
569
|
-
|
|
600
|
+
const runId = typeof payload.runId === "string" && payload.runId ? payload.runId : isPlayRunPackage(payload) ? payload.run.id : state.runId;
|
|
601
|
+
const status = normalizeLiveStatus(payload.status) ?? (isPlayRunPackage(payload) ? normalizeLiveStatus(payload.run.status) : null) ?? state.status;
|
|
602
|
+
const progressPayload = isRecord(payload.progress) ? payload.progress : {};
|
|
603
|
+
const payloadLogs = readStringArray(payload.logs);
|
|
604
|
+
const progressLogs = readStringArray(progressPayload.logs);
|
|
605
|
+
const logs = payloadLogs.length > 0 ? payloadLogs : progressLogs;
|
|
606
|
+
if (logs.length > 0 || event.type === "play.run.snapshot" || event.type === "play.run.final_status" && !isPlayRunPackage(payload)) {
|
|
570
607
|
state.logs = logs;
|
|
571
608
|
}
|
|
572
609
|
if ("result" in payload) {
|
|
573
610
|
state.result = payload.result;
|
|
611
|
+
} else if (isPlayRunPackage(payload)) {
|
|
612
|
+
state.result = payload;
|
|
574
613
|
}
|
|
575
614
|
if (typeof payload.error === "string" && payload.error.trim()) {
|
|
576
615
|
state.error = payload.error;
|
|
577
616
|
}
|
|
578
617
|
state.runId = runId;
|
|
579
618
|
state.status = status;
|
|
580
|
-
const progressRecord =
|
|
619
|
+
const progressRecord = progressPayload;
|
|
581
620
|
const next = {
|
|
582
621
|
...payload,
|
|
583
622
|
runId,
|
|
584
623
|
status,
|
|
624
|
+
...isPlayRunPackage(payload) ? { package: payload, outputs: payload.outputs } : {},
|
|
585
625
|
progress: {
|
|
586
626
|
...progressRecord,
|
|
587
627
|
status: typeof progressRecord.status === "string" ? progressRecord.status : status,
|
|
@@ -597,7 +637,8 @@ function playRunResultFromStatus(status, startedAt, fallbackRunId) {
|
|
|
597
637
|
return {
|
|
598
638
|
success: status.status === "completed",
|
|
599
639
|
runId: status.runId || fallbackRunId,
|
|
600
|
-
result: status.result,
|
|
640
|
+
result: status.package ?? status.result,
|
|
641
|
+
...status.package ? { package: status.package } : {},
|
|
601
642
|
logs: status.progress?.logs ?? [],
|
|
602
643
|
durationMs: Date.now() - startedAt,
|
|
603
644
|
error: status.progress?.error ?? (status.status !== "completed" ? status.status : void 0)
|
|
@@ -627,7 +668,7 @@ var DeeplineClient = class {
|
|
|
627
668
|
this.config = resolveConfig(options);
|
|
628
669
|
this.http = new HttpClient(this.config);
|
|
629
670
|
this.runs = {
|
|
630
|
-
get: (runId) => this.getRunStatus(runId),
|
|
671
|
+
get: (runId, options2) => this.getRunStatus(runId, options2),
|
|
631
672
|
list: (options2) => this.listRuns(options2),
|
|
632
673
|
tail: (runId, options2) => this.tailRun(runId, options2),
|
|
633
674
|
logs: (runId, options2) => this.getRunLogs(runId, options2),
|
|
@@ -846,9 +887,9 @@ var DeeplineClient = class {
|
|
|
846
887
|
* artifactStorageKey: 'plays/v1/orgs/acme/plays/my-play/artifacts/playgraph_abc123.json',
|
|
847
888
|
* });
|
|
848
889
|
* ```
|
|
849
|
-
|
|
890
|
+
*/
|
|
850
891
|
async startPlayRun(request) {
|
|
851
|
-
|
|
892
|
+
const response = await this.http.post("/api/v2/plays/run", {
|
|
852
893
|
...request.name ? { name: request.name } : {},
|
|
853
894
|
...request.revisionId ? { revisionId: request.revisionId } : {},
|
|
854
895
|
...request.artifactStorageKey ? { artifactStorageKey: request.artifactStorageKey } : {},
|
|
@@ -871,6 +912,7 @@ var DeeplineClient = class {
|
|
|
871
912
|
// different profile pass `request.profile` explicitly.
|
|
872
913
|
...request.profile ? { profile: request.profile } : {}
|
|
873
914
|
});
|
|
915
|
+
return normalizePlayRunStart(response);
|
|
874
916
|
}
|
|
875
917
|
async *startPlayRunStream(request, options) {
|
|
876
918
|
const body = {
|
|
@@ -1154,6 +1196,9 @@ var DeeplineClient = class {
|
|
|
1154
1196
|
if (options?.billing === false) {
|
|
1155
1197
|
params.set("billing", "false");
|
|
1156
1198
|
}
|
|
1199
|
+
if (options?.full === true) {
|
|
1200
|
+
params.set("full", "true");
|
|
1201
|
+
}
|
|
1157
1202
|
const query = params.size > 0 ? `?${params.toString()}` : "";
|
|
1158
1203
|
const response = await this.http.get(
|
|
1159
1204
|
`/api/v2/plays/run/${encodeURIComponent(workflowId)}${query}`
|
|
@@ -1242,9 +1287,14 @@ var DeeplineClient = class {
|
|
|
1242
1287
|
* deepline runs get <run-id> --json
|
|
1243
1288
|
* ```
|
|
1244
1289
|
*/
|
|
1245
|
-
async getRunStatus(runId) {
|
|
1290
|
+
async getRunStatus(runId, options) {
|
|
1291
|
+
const params = new URLSearchParams();
|
|
1292
|
+
if (options?.full === true) {
|
|
1293
|
+
params.set("full", "true");
|
|
1294
|
+
}
|
|
1295
|
+
const query = params.size > 0 ? `?${params.toString()}` : "";
|
|
1246
1296
|
const response = await this.http.get(
|
|
1247
|
-
`/api/v2/runs/${encodeURIComponent(runId)}`
|
|
1297
|
+
`/api/v2/runs/${encodeURIComponent(runId)}${query}`
|
|
1248
1298
|
);
|
|
1249
1299
|
return normalizePlayStatus(response);
|
|
1250
1300
|
}
|
|
@@ -5556,6 +5606,17 @@ async function traceCliSpan(phase, fields, run) {
|
|
|
5556
5606
|
}
|
|
5557
5607
|
|
|
5558
5608
|
// src/cli/commands/play.ts
|
|
5609
|
+
var PLAY_RUN_RESERVED_BOOLEAN_FLAGS = /* @__PURE__ */ new Set([
|
|
5610
|
+
"--json",
|
|
5611
|
+
"--wait",
|
|
5612
|
+
"--tail",
|
|
5613
|
+
"--watch",
|
|
5614
|
+
"--no-wait",
|
|
5615
|
+
"--logs",
|
|
5616
|
+
"--full",
|
|
5617
|
+
"--force",
|
|
5618
|
+
"--no-open"
|
|
5619
|
+
]);
|
|
5559
5620
|
function traceCliSync(phase, fields, run) {
|
|
5560
5621
|
const startedAt = Date.now();
|
|
5561
5622
|
try {
|
|
@@ -6074,25 +6135,46 @@ var PLAY_START_TRANSIENT_RETRY_DELAYS_MS = [500, 1500];
|
|
|
6074
6135
|
function getEventPayload(event) {
|
|
6075
6136
|
return event.payload && typeof event.payload === "object" ? event.payload : {};
|
|
6076
6137
|
}
|
|
6138
|
+
function playStatusValue(value) {
|
|
6139
|
+
return value === "queued" || value === "running" || value === "waiting" || value === "completed" || value === "failed" || value === "cancelled" ? value : null;
|
|
6140
|
+
}
|
|
6141
|
+
function getRunRecordFromPackage(value) {
|
|
6142
|
+
if (!isPlayRunPackageValue(value)) {
|
|
6143
|
+
return null;
|
|
6144
|
+
}
|
|
6145
|
+
const run = value.run;
|
|
6146
|
+
return run && typeof run === "object" && !Array.isArray(run) ? run : null;
|
|
6147
|
+
}
|
|
6148
|
+
function getRunIdFromLiveEvent(event) {
|
|
6149
|
+
const payload = getEventPayload(event);
|
|
6150
|
+
const directRunId = payload.runId;
|
|
6151
|
+
if (typeof directRunId === "string" && directRunId.trim()) {
|
|
6152
|
+
return directRunId;
|
|
6153
|
+
}
|
|
6154
|
+
const packageRunId = getRunRecordFromPackage(payload)?.id;
|
|
6155
|
+
return typeof packageRunId === "string" && packageRunId.trim() ? packageRunId : null;
|
|
6156
|
+
}
|
|
6077
6157
|
function getStatusFromLiveEvent(event) {
|
|
6078
6158
|
if (event.type !== "play.run.status" && event.type !== "play.run.snapshot" && event.type !== "play.run.final_status") {
|
|
6079
6159
|
return null;
|
|
6080
6160
|
}
|
|
6081
|
-
const
|
|
6082
|
-
return status
|
|
6161
|
+
const payload = getEventPayload(event);
|
|
6162
|
+
return playStatusValue(payload.status) ?? playStatusValue(getRunRecordFromPackage(payload)?.status);
|
|
6083
6163
|
}
|
|
6084
6164
|
function getFinalStatusFromLiveEvent(event) {
|
|
6085
6165
|
if (event.type !== "play.run.snapshot" && event.type !== "play.run.status" && event.type !== "play.run.final_status") {
|
|
6086
6166
|
return null;
|
|
6087
6167
|
}
|
|
6088
6168
|
const payload = getEventPayload(event);
|
|
6089
|
-
const
|
|
6169
|
+
const packageRun = getRunRecordFromPackage(payload);
|
|
6170
|
+
const status = playStatusValue(payload.status) ?? playStatusValue(packageRun?.status);
|
|
6090
6171
|
if (status !== "completed" && status !== "failed" && status !== "cancelled") {
|
|
6091
6172
|
return null;
|
|
6092
6173
|
}
|
|
6174
|
+
const runId = typeof payload.runId === "string" ? payload.runId : typeof packageRun?.id === "string" ? packageRun.id : "";
|
|
6093
6175
|
return {
|
|
6094
6176
|
...payload,
|
|
6095
|
-
runId
|
|
6177
|
+
runId,
|
|
6096
6178
|
status
|
|
6097
6179
|
};
|
|
6098
6180
|
}
|
|
@@ -6110,7 +6192,8 @@ function describeLiveEventPhase(event) {
|
|
|
6110
6192
|
if (status === "running") {
|
|
6111
6193
|
return null;
|
|
6112
6194
|
}
|
|
6113
|
-
const
|
|
6195
|
+
const eventRunId = getRunIdFromLiveEvent(event);
|
|
6196
|
+
const runId = eventRunId ? ` ${eventRunId}` : "";
|
|
6114
6197
|
return status ? `${status}${runId}` : null;
|
|
6115
6198
|
}
|
|
6116
6199
|
if (event.type === "play.step.status" || event.type === "play.step.progress") {
|
|
@@ -6359,7 +6442,7 @@ async function startAndWaitForPlayCompletionByStreamOnce(input) {
|
|
|
6359
6442
|
signal: controller.signal
|
|
6360
6443
|
})) {
|
|
6361
6444
|
eventCount += 1;
|
|
6362
|
-
const eventRunId =
|
|
6445
|
+
const eventRunId = getRunIdFromLiveEvent(event);
|
|
6363
6446
|
if (typeof eventRunId === "string" && eventRunId && eventRunId !== "pending") {
|
|
6364
6447
|
lastKnownWorkflowId = eventRunId;
|
|
6365
6448
|
firstRunIdMs ??= Date.now() - startedAt;
|
|
@@ -6956,16 +7039,27 @@ function stripProviderSpendFromBilling(value) {
|
|
|
6956
7039
|
}
|
|
6957
7040
|
return next;
|
|
6958
7041
|
}
|
|
7042
|
+
function isPlayRunPackageValue(value) {
|
|
7043
|
+
return Boolean(
|
|
7044
|
+
value && typeof value === "object" && !Array.isArray(value) && value.kind === "play_run" && value.run && typeof value.run.id === "string"
|
|
7045
|
+
);
|
|
7046
|
+
}
|
|
7047
|
+
function getPlayRunPackage(status) {
|
|
7048
|
+
const direct = status;
|
|
7049
|
+
if (isPlayRunPackageValue(direct)) {
|
|
7050
|
+
return direct;
|
|
7051
|
+
}
|
|
7052
|
+
const packaged = status.package;
|
|
7053
|
+
return isPlayRunPackageValue(packaged) ? packaged : null;
|
|
7054
|
+
}
|
|
6959
7055
|
function compactPlayStatus(status) {
|
|
7056
|
+
const packaged = getPlayRunPackage(status);
|
|
7057
|
+
if (packaged) {
|
|
7058
|
+
return packaged;
|
|
7059
|
+
}
|
|
6960
7060
|
const rowsInfo = extractCanonicalRowsInfo(status);
|
|
6961
7061
|
const result = status && typeof status === "object" ? status.result : null;
|
|
6962
7062
|
const warnings = buildRunWarnings(status, rowsInfo);
|
|
6963
|
-
const datasetStats = rowsInfo && rowsInfo.complete ? buildDatasetStats(
|
|
6964
|
-
rowsInfo.rows,
|
|
6965
|
-
rowsInfo.totalRows,
|
|
6966
|
-
rowsInfo.columns,
|
|
6967
|
-
extractDatasetExecutionStats(status)
|
|
6968
|
-
) : null;
|
|
6969
7063
|
const billing = status && typeof status === "object" ? stripProviderSpendFromBilling(
|
|
6970
7064
|
status.billing
|
|
6971
7065
|
) : null;
|
|
@@ -6987,8 +7081,6 @@ function compactPlayStatus(status) {
|
|
|
6987
7081
|
...displayError ? { error: displayError } : {},
|
|
6988
7082
|
...warnings.length > 0 ? { warnings } : {},
|
|
6989
7083
|
...result !== void 0 ? { result } : {},
|
|
6990
|
-
...status.resultView ? { resultView: status.resultView } : {},
|
|
6991
|
-
...datasetStats ? { dataset_stats: datasetStats } : {},
|
|
6992
7084
|
...billing ? { billing } : {},
|
|
6993
7085
|
next: buildRunNextCommands(status)
|
|
6994
7086
|
};
|
|
@@ -7008,51 +7100,87 @@ function enrichPlayStatusWithDatasetStats(status) {
|
|
|
7008
7100
|
)
|
|
7009
7101
|
};
|
|
7010
7102
|
}
|
|
7011
|
-
function
|
|
7012
|
-
|
|
7013
|
-
|
|
7103
|
+
function readRunPackageRun(packaged) {
|
|
7104
|
+
return packaged.run && typeof packaged.run === "object" && !Array.isArray(packaged.run) ? packaged.run : {};
|
|
7105
|
+
}
|
|
7106
|
+
function readRecordArray(value) {
|
|
7107
|
+
return Array.isArray(value) ? value.filter(
|
|
7108
|
+
(item) => item !== null && typeof item === "object" && !Array.isArray(item)
|
|
7109
|
+
) : [];
|
|
7110
|
+
}
|
|
7111
|
+
function actionToCommand(action) {
|
|
7112
|
+
if (!action || typeof action !== "object" || Array.isArray(action)) {
|
|
7113
|
+
return null;
|
|
7014
7114
|
}
|
|
7015
|
-
const
|
|
7016
|
-
|
|
7017
|
-
|
|
7018
|
-
12
|
|
7019
|
-
)) {
|
|
7020
|
-
const topValues = stat3.top_values ? `, top_values=${Object.entries(stat3.top_values).slice(0, 3).map(([value, count]) => `${value}=${count}`).join(", ")}` : "";
|
|
7021
|
-
const sample = stat3.sample_value !== void 0 ? `, sample_value=${JSON.stringify(stat3.sample_value)}` : "";
|
|
7022
|
-
const execution = stat3.execution ? `, execution=${Object.entries(stat3.execution).map(([bucket, count]) => `${bucket}=${count}`).join(", ")}` : "";
|
|
7023
|
-
lines.push(
|
|
7024
|
-
` ${column}: non_empty=${stat3.non_empty}, unique=${stat3.unique}${topValues}${sample}${execution}`
|
|
7025
|
-
);
|
|
7115
|
+
const record = action;
|
|
7116
|
+
if (record.kind === "deepline_run_inspect" && typeof record.runId === "string") {
|
|
7117
|
+
return `deepline runs get ${record.runId} --json`;
|
|
7026
7118
|
}
|
|
7027
|
-
|
|
7119
|
+
if (record.kind === "deepline_run_export" && typeof record.runId === "string" && typeof record.datasetPath === "string") {
|
|
7120
|
+
return `deepline runs export ${record.runId} --dataset ${shellSingleQuote(
|
|
7121
|
+
record.datasetPath
|
|
7122
|
+
)} --out ${shellSingleQuote(`${record.datasetPath.split(".").pop() || "dataset"}.csv`)}`;
|
|
7123
|
+
}
|
|
7124
|
+
if (record.kind === "deepline_db_query" && typeof record.sql === "string") {
|
|
7125
|
+
const maxRows = typeof record.maxRows === "number" && Number.isFinite(record.maxRows) ? Math.trunc(record.maxRows) : 20;
|
|
7126
|
+
return `deepline db query --sql ${shellSingleQuote(record.sql)} --max-rows ${maxRows} --json`;
|
|
7127
|
+
}
|
|
7128
|
+
return null;
|
|
7028
7129
|
}
|
|
7029
|
-
function
|
|
7030
|
-
const
|
|
7031
|
-
|
|
7032
|
-
|
|
7033
|
-
|
|
7034
|
-
|
|
7035
|
-
const billing = extractBillingForStatus(status, progressError);
|
|
7036
|
-
if (isInsufficientCreditsBilling(billing)) {
|
|
7037
|
-
lines.push(...buildInsufficientCreditsSummaryLines({ status, billing }));
|
|
7130
|
+
function readFirstDatasetActions(packaged) {
|
|
7131
|
+
for (const step of readRecordArray(packaged.steps)) {
|
|
7132
|
+
const output = step.output && typeof step.output === "object" && !Array.isArray(step.output) ? step.output : null;
|
|
7133
|
+
const actions = output?.actions && typeof output.actions === "object" && !Array.isArray(output.actions) ? output.actions : null;
|
|
7134
|
+
if (actions) {
|
|
7135
|
+
return actions;
|
|
7038
7136
|
}
|
|
7039
7137
|
}
|
|
7138
|
+
return {};
|
|
7139
|
+
}
|
|
7140
|
+
function buildRunPackageTextLines(packaged) {
|
|
7141
|
+
const run = readRunPackageRun(packaged);
|
|
7142
|
+
const runId = typeof run.id === "string" ? run.id : "unknown";
|
|
7143
|
+
const status = typeof run.status === "string" ? run.status : "unknown";
|
|
7144
|
+
const playName = typeof run.playName === "string" ? run.playName : null;
|
|
7145
|
+
const lines = [`${status === "completed" ? "\u2713" : status === "failed" ? "\u2717" : "\u2022"} ${status} ${runId}`];
|
|
7146
|
+
if (playName) {
|
|
7147
|
+
lines.push(` play: ${playName}`);
|
|
7148
|
+
}
|
|
7149
|
+
for (const step of readRecordArray(packaged.steps).slice(0, 8)) {
|
|
7150
|
+
const id = typeof step.id === "string" ? step.id : "step";
|
|
7151
|
+
const kind = typeof step.kind === "string" ? step.kind : "step";
|
|
7152
|
+
const stepStatus = typeof step.status === "string" ? step.status : status;
|
|
7153
|
+
const output = step.output && typeof step.output === "object" && !Array.isArray(step.output) ? step.output : null;
|
|
7154
|
+
const rowCount = output && typeof output.rowCount === "number" ? ` rows=${formatInteger(output.rowCount)}` : "";
|
|
7155
|
+
const preview = output?.preview && typeof output.preview === "object" && !Array.isArray(output.preview) ? output.preview : null;
|
|
7156
|
+
const previewRows = Array.isArray(preview?.rows) ? preview.rows.length : null;
|
|
7157
|
+
const previewLabel = previewRows !== null ? ` preview=${previewRows}${preview?.truncated ? " truncated" : ""}` : "";
|
|
7158
|
+
lines.push(` ${kind} ${id}: ${stepStatus}${rowCount}${previewLabel}`);
|
|
7159
|
+
}
|
|
7160
|
+
const next = packaged.next && typeof packaged.next === "object" && !Array.isArray(packaged.next) ? packaged.next : {};
|
|
7161
|
+
const datasetActions = readFirstDatasetActions(packaged);
|
|
7162
|
+
const inspectCommand = actionToCommand(next.inspect);
|
|
7163
|
+
const queryCommand = actionToCommand(next.query) ?? actionToCommand(datasetActions.query);
|
|
7164
|
+
const exportCommand = actionToCommand(next.export) ?? actionToCommand(datasetActions.exportCsv);
|
|
7165
|
+
if (inspectCommand) lines.push(` inspect: ${inspectCommand}`);
|
|
7166
|
+
if (queryCommand) lines.push(` query: ${queryCommand}`);
|
|
7167
|
+
if (exportCommand) lines.push(` export CSV: ${exportCommand}`);
|
|
7040
7168
|
return lines;
|
|
7041
7169
|
}
|
|
7042
7170
|
function writePlayResult(status, jsonOutput, options) {
|
|
7171
|
+
const packaged = getPlayRunPackage(status);
|
|
7043
7172
|
if (jsonOutput) {
|
|
7044
|
-
const payload2 = options?.fullJson ?
|
|
7045
|
-
printCommandEnvelope({
|
|
7046
|
-
|
|
7047
|
-
|
|
7048
|
-
|
|
7049
|
-
|
|
7050
|
-
|
|
7051
|
-
|
|
7052
|
-
|
|
7053
|
-
|
|
7054
|
-
|
|
7055
|
-
}, { json: true });
|
|
7173
|
+
const payload2 = options?.fullJson ? status : compactPlayStatus(status);
|
|
7174
|
+
printCommandEnvelope(payload2, { json: true });
|
|
7175
|
+
return;
|
|
7176
|
+
}
|
|
7177
|
+
if (packaged && !options?.fullJson) {
|
|
7178
|
+
const lines2 = buildRunPackageTextLines(packaged);
|
|
7179
|
+
printCommandEnvelope(packaged, {
|
|
7180
|
+
json: false,
|
|
7181
|
+
text: `${lines2.join("\n")}
|
|
7182
|
+
`
|
|
7183
|
+
});
|
|
7056
7184
|
return;
|
|
7057
7185
|
}
|
|
7058
7186
|
const result = status.result;
|
|
@@ -7063,16 +7191,9 @@ function writePlayResult(status, jsonOutput, options) {
|
|
|
7063
7191
|
lines.push(`${success ? "\u2713" : "\u2717"} ${publicStatus} ${runId}`);
|
|
7064
7192
|
const rowsInfo = extractCanonicalRowsInfo(status);
|
|
7065
7193
|
const warnings = buildRunWarnings(status, rowsInfo);
|
|
7066
|
-
const datasetStats = rowsInfo && rowsInfo.complete ? buildDatasetStats(
|
|
7067
|
-
rowsInfo.rows,
|
|
7068
|
-
rowsInfo.totalRows,
|
|
7069
|
-
rowsInfo.columns,
|
|
7070
|
-
extractDatasetExecutionStats(status)
|
|
7071
|
-
) : null;
|
|
7072
7194
|
for (const warning of warnings) {
|
|
7073
7195
|
lines.push(` warning: ${warning}`);
|
|
7074
7196
|
}
|
|
7075
|
-
lines.push(...formatDatasetStatsLines(datasetStats));
|
|
7076
7197
|
const progressError = status.progress?.error;
|
|
7077
7198
|
if (progressError && typeof progressError === "string") {
|
|
7078
7199
|
const billing = extractBillingForStatus(status, progressError);
|
|
@@ -7100,6 +7221,21 @@ function writePlayResult(status, jsonOutput, options) {
|
|
|
7100
7221
|
}, { json: jsonOutput, text: `${lines.join("\n")}
|
|
7101
7222
|
` });
|
|
7102
7223
|
}
|
|
7224
|
+
async function resolvePlayRunOutputStatus(input) {
|
|
7225
|
+
if (!input.fullJson || !getPlayRunPackage(input.status)) {
|
|
7226
|
+
return input.status;
|
|
7227
|
+
}
|
|
7228
|
+
const runId = input.status.runId;
|
|
7229
|
+
if (!runId) {
|
|
7230
|
+
return input.status;
|
|
7231
|
+
}
|
|
7232
|
+
const fullStatus = await input.client.getPlayStatus(runId, {
|
|
7233
|
+
billing: false,
|
|
7234
|
+
full: true
|
|
7235
|
+
});
|
|
7236
|
+
const dashboardUrl = input.status.dashboardUrl;
|
|
7237
|
+
return typeof dashboardUrl === "string" ? { ...fullStatus, dashboardUrl } : fullStatus;
|
|
7238
|
+
}
|
|
7103
7239
|
var RUN_EXPORT_PAGE_SIZE = 5e3;
|
|
7104
7240
|
function shellSingleQuote(value) {
|
|
7105
7241
|
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
@@ -7453,6 +7589,24 @@ function renderServerResultView(value) {
|
|
|
7453
7589
|
return { lines: lines.length > 1 ? lines : [], actions: [] };
|
|
7454
7590
|
}
|
|
7455
7591
|
function writeStartedPlayRun(input) {
|
|
7592
|
+
if (input.package && isPlayRunPackageValue(input.package)) {
|
|
7593
|
+
if (input.jsonOutput) {
|
|
7594
|
+
printCommandEnvelope(input.package, { json: true });
|
|
7595
|
+
return;
|
|
7596
|
+
}
|
|
7597
|
+
const lines2 = buildRunPackageTextLines(input.package);
|
|
7598
|
+
const output2 = lines2.join("\n");
|
|
7599
|
+
if (input.progress) {
|
|
7600
|
+
input.progress.writeLine(output2, process.stdout);
|
|
7601
|
+
return;
|
|
7602
|
+
}
|
|
7603
|
+
printCommandEnvelope(input.package, {
|
|
7604
|
+
json: false,
|
|
7605
|
+
text: `${output2}
|
|
7606
|
+
`
|
|
7607
|
+
});
|
|
7608
|
+
return;
|
|
7609
|
+
}
|
|
7456
7610
|
const payload = {
|
|
7457
7611
|
runId: input.runId,
|
|
7458
7612
|
workflowId: input.runId,
|
|
@@ -7498,7 +7652,7 @@ function writeStartedPlayRun(input) {
|
|
|
7498
7652
|
` });
|
|
7499
7653
|
}
|
|
7500
7654
|
function parsePlayRunOptions(args) {
|
|
7501
|
-
const usage = "Usage: deepline plays run <play-name> [--input '{...}'] [--no-wait] [--tail-timeout-ms 30000] [--force] [--<input> value]\n deepline plays run <play-file.ts> [--input '{...}'] [--no-wait] [--tail-timeout-ms 30000] [--force] [--<input> value]\n deepline plays run --file <play-file.ts> [--input '{...}'] [--no-wait] [--tail-timeout-ms 30000] [--force] [--<input> value]\n deepline plays run --name <name> [--input '{...}'] [--live|--latest|--revision-id <id>] [--no-wait] [--tail-timeout-ms 30000] [--force] [--no-open] [--json] [--<input> value]\n Unknown --<input> value flags, such as --limit 5, are passed into play input.\nRun `deepline plays run --help` for idempotency, tool call id, and ctx.map guidance.";
|
|
7655
|
+
const usage = "Usage: deepline plays run <play-name> [--input '{...}'] [--no-wait] [--tail-timeout-ms 30000] [--force] [--full] [--<input> value]\n deepline plays run <play-file.ts> [--input '{...}'] [--no-wait] [--tail-timeout-ms 30000] [--force] [--full] [--<input> value]\n deepline plays run --file <play-file.ts> [--input '{...}'] [--no-wait] [--tail-timeout-ms 30000] [--force] [--full] [--<input> value]\n deepline plays run --name <name> [--input '{...}'] [--live|--latest|--revision-id <id>] [--no-wait] [--tail-timeout-ms 30000] [--force] [--no-open] [--json] [--full] [--<input> value]\n Unknown --<input> value flags, such as --limit 5, are passed into play input.\nRun `deepline plays run --help` for idempotency, tool call id, and ctx.map guidance.";
|
|
7502
7656
|
let filePath = null;
|
|
7503
7657
|
let playName = null;
|
|
7504
7658
|
let input = null;
|
|
@@ -7506,6 +7660,7 @@ function parsePlayRunOptions(args) {
|
|
|
7506
7660
|
let revisionSelector = null;
|
|
7507
7661
|
const watch = !args.includes("--no-wait");
|
|
7508
7662
|
let jsonOutput = watch ? args.includes("--json") : argsWantJson(args);
|
|
7663
|
+
const fullJson = args.includes("--full");
|
|
7509
7664
|
const emitLogs = !jsonOutput || args.includes("--logs");
|
|
7510
7665
|
const force = args.includes("--force");
|
|
7511
7666
|
const noOpen = args.includes("--no-open");
|
|
@@ -7550,7 +7705,7 @@ function parsePlayRunOptions(args) {
|
|
|
7550
7705
|
waitTimeoutMs = parsePositiveInteger2(args[++index], arg);
|
|
7551
7706
|
continue;
|
|
7552
7707
|
}
|
|
7553
|
-
if (arg
|
|
7708
|
+
if (PLAY_RUN_RESERVED_BOOLEAN_FLAGS.has(arg)) {
|
|
7554
7709
|
if (arg === "--watch") {
|
|
7555
7710
|
continue;
|
|
7556
7711
|
}
|
|
@@ -7612,6 +7767,7 @@ function parsePlayRunOptions(args) {
|
|
|
7612
7767
|
watch,
|
|
7613
7768
|
emitLogs,
|
|
7614
7769
|
jsonOutput,
|
|
7770
|
+
fullJson,
|
|
7615
7771
|
waitTimeoutMs,
|
|
7616
7772
|
force,
|
|
7617
7773
|
noOpen
|
|
@@ -7923,10 +8079,17 @@ async function handleFileBackedRun(options) {
|
|
|
7923
8079
|
} else {
|
|
7924
8080
|
progress.fail();
|
|
7925
8081
|
}
|
|
8082
|
+
const outputStatus = await resolvePlayRunOutputStatus({
|
|
8083
|
+
client,
|
|
8084
|
+
status: finalStatus,
|
|
8085
|
+
fullJson: options.fullJson
|
|
8086
|
+
});
|
|
7926
8087
|
traceCliSync(
|
|
7927
8088
|
"cli.play_write_result",
|
|
7928
8089
|
{ targetKind: "file", playName },
|
|
7929
|
-
() => writePlayResult(
|
|
8090
|
+
() => writePlayResult(outputStatus, options.jsonOutput, {
|
|
8091
|
+
fullJson: options.fullJson
|
|
8092
|
+
})
|
|
7930
8093
|
);
|
|
7931
8094
|
return finalStatus.status === "completed" ? 0 : 1;
|
|
7932
8095
|
}
|
|
@@ -7951,6 +8114,7 @@ async function handleFileBackedRun(options) {
|
|
|
7951
8114
|
playName,
|
|
7952
8115
|
status: started.status,
|
|
7953
8116
|
dashboardUrl: resolvedDashboardUrl,
|
|
8117
|
+
package: options.fullJson ? void 0 : started.package,
|
|
7954
8118
|
jsonOutput: options.jsonOutput,
|
|
7955
8119
|
progress
|
|
7956
8120
|
});
|
|
@@ -8062,10 +8226,17 @@ async function handleNamedRun(options) {
|
|
|
8062
8226
|
} else {
|
|
8063
8227
|
progress.fail();
|
|
8064
8228
|
}
|
|
8229
|
+
const outputStatus = await resolvePlayRunOutputStatus({
|
|
8230
|
+
client,
|
|
8231
|
+
status: finalStatus,
|
|
8232
|
+
fullJson: options.fullJson
|
|
8233
|
+
});
|
|
8065
8234
|
traceCliSync(
|
|
8066
8235
|
"cli.play_write_result",
|
|
8067
8236
|
{ targetKind: "name", playName },
|
|
8068
|
-
() => writePlayResult(
|
|
8237
|
+
() => writePlayResult(outputStatus, options.jsonOutput, {
|
|
8238
|
+
fullJson: options.fullJson
|
|
8239
|
+
})
|
|
8069
8240
|
);
|
|
8070
8241
|
return finalStatus.status === "completed" ? 0 : 1;
|
|
8071
8242
|
}
|
|
@@ -8090,6 +8261,7 @@ async function handleNamedRun(options) {
|
|
|
8090
8261
|
playName: started.name ?? playName,
|
|
8091
8262
|
status: started.status,
|
|
8092
8263
|
dashboardUrl: resolvedDashboardUrl,
|
|
8264
|
+
package: options.fullJson ? void 0 : started.package,
|
|
8093
8265
|
jsonOutput: options.jsonOutput,
|
|
8094
8266
|
progress
|
|
8095
8267
|
});
|
|
@@ -8152,7 +8324,9 @@ async function handleRunGet(args) {
|
|
|
8152
8324
|
return 1;
|
|
8153
8325
|
}
|
|
8154
8326
|
const client = new DeeplineClient();
|
|
8155
|
-
const status = await client.runs.get(runId
|
|
8327
|
+
const status = await client.runs.get(runId, {
|
|
8328
|
+
full: args.includes("--full")
|
|
8329
|
+
});
|
|
8156
8330
|
writePlayResult(status, argsWantJson(args), {
|
|
8157
8331
|
fullJson: args.includes("--full")
|
|
8158
8332
|
});
|
|
@@ -8341,7 +8515,7 @@ async function handleRunExport(args) {
|
|
|
8341
8515
|
return 1;
|
|
8342
8516
|
}
|
|
8343
8517
|
const client = new DeeplineClient();
|
|
8344
|
-
const status = await client.getPlayStatus(runId);
|
|
8518
|
+
const status = await client.getPlayStatus(runId, { full: true });
|
|
8345
8519
|
const exportResult = await exportPlayStatusRows(client, status, outPath, {
|
|
8346
8520
|
datasetPath
|
|
8347
8521
|
});
|
|
@@ -9061,7 +9235,7 @@ Examples:
|
|
|
9061
9235
|
).option("--watch", "Compatibility alias; run waits by default").option("--wait", "Compatibility alias; run waits by default").option("--no-wait", "Start the run and return immediately").option(
|
|
9062
9236
|
"--logs",
|
|
9063
9237
|
"When output is non-interactive, stream play logs to stderr while waiting"
|
|
9064
|
-
).option("--tail-timeout-ms <ms>", "Timeout while watching the run stream").option("--force", "Supersede any active runs for this play").option("--no-open", "Print the play page URL without opening a browser").option("--json", "Emit JSON output").addHelpText(
|
|
9238
|
+
).option("--tail-timeout-ms <ms>", "Timeout while watching the run stream").option("--force", "Supersede any active runs for this play").option("--no-open", "Print the play page URL without opening a browser").option("--json", "Emit JSON output").option("--full", "Debug only: with --json, emit the raw status payload").addHelpText(
|
|
9065
9239
|
"afterAll",
|
|
9066
9240
|
`
|
|
9067
9241
|
Pass-through input flags:
|
|
@@ -9098,6 +9272,7 @@ Pass-through input flags:
|
|
|
9098
9272
|
...options.force ? ["--force"] : [],
|
|
9099
9273
|
...options.noOpen || options.open === false ? ["--no-open"] : [],
|
|
9100
9274
|
...options.json ? ["--json"] : [],
|
|
9275
|
+
...options.full ? ["--full"] : [],
|
|
9101
9276
|
...passthroughArgs
|
|
9102
9277
|
]);
|
|
9103
9278
|
});
|