deepline 0.1.238 → 0.1.239
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/apps/play-runner-workers/src/entry.ts +3 -0
- package/dist/bundling-sources/sdk/src/client.ts +72 -8
- package/dist/bundling-sources/sdk/src/http.ts +1 -0
- package/dist/bundling-sources/sdk/src/index.ts +4 -0
- package/dist/bundling-sources/sdk/src/release.ts +2 -2
- package/dist/bundling-sources/sdk/src/types.ts +63 -2
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +16 -9
- package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +5 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-latency-trace.ts +3 -18
- package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +14 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-payload-transport.ts +42 -4
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-session-execution.ts +9 -5
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona.ts +5 -5
- package/dist/cli/index.js +375 -48
- package/dist/cli/index.mjs +375 -48
- package/dist/index.d.mts +107 -6
- package/dist/index.d.ts +107 -6
- package/dist/index.js +54 -10
- package/dist/index.mjs +54 -10
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -627,10 +627,10 @@ var SDK_RELEASE = {
|
|
|
627
627
|
// silently materializing them as unmatched results.
|
|
628
628
|
// 0.1.220 deprecates SDK CLI versions below 0.1.219 and updates them
|
|
629
629
|
// automatically without blocking their current command.
|
|
630
|
-
version: "0.1.
|
|
630
|
+
version: "0.1.239",
|
|
631
631
|
apiContract: "2026-06-dataset-handle-results-hard-cutover",
|
|
632
632
|
supportPolicy: {
|
|
633
|
-
latest: "0.1.
|
|
633
|
+
latest: "0.1.239",
|
|
634
634
|
minimumSupported: "0.1.53",
|
|
635
635
|
deprecatedBelow: "0.1.219",
|
|
636
636
|
commandMinimumSupported: [
|
|
@@ -892,6 +892,7 @@ var HttpClient = class {
|
|
|
892
892
|
"X-Deepline-CLI-Version": SDK_VERSION,
|
|
893
893
|
"X-Deepline-SDK-Version": SDK_VERSION,
|
|
894
894
|
"X-Deepline-API-Contract": SDK_API_CONTRACT,
|
|
895
|
+
"X-Deepline-Run-Result-Shape": "canonical",
|
|
895
896
|
...extra
|
|
896
897
|
};
|
|
897
898
|
const skillsVersion = this.readSkillsVersionHeader();
|
|
@@ -2705,6 +2706,8 @@ var DeeplineClient = class {
|
|
|
2705
2706
|
config;
|
|
2706
2707
|
/** Canonical run lifecycle namespace backed by `/api/v2/runs`. */
|
|
2707
2708
|
runs;
|
|
2709
|
+
/** Current mutable customer database namespace backed by `/api/v2/db/query`. */
|
|
2710
|
+
db;
|
|
2708
2711
|
/** Billing namespace: subscription status/cancel and invoice history. */
|
|
2709
2712
|
billing;
|
|
2710
2713
|
/**
|
|
@@ -2728,6 +2731,9 @@ var DeeplineClient = class {
|
|
|
2728
2731
|
stop: (runId, options2) => this.stopRun(runId, options2),
|
|
2729
2732
|
stopAll: (options2) => this.stopAllRuns(options2)
|
|
2730
2733
|
};
|
|
2734
|
+
this.db = {
|
|
2735
|
+
query: (input2) => this.queryDb(input2)
|
|
2736
|
+
};
|
|
2731
2737
|
this.billing = {
|
|
2732
2738
|
topUp: (options2) => this.topUpBillingBalance(options2),
|
|
2733
2739
|
plans: () => this.getBillingPlans(),
|
|
@@ -2994,17 +3000,29 @@ var DeeplineClient = class {
|
|
|
2994
3000
|
async executeToolRaw(toolId, input2, options) {
|
|
2995
3001
|
return this.executeTool(toolId, input2, options);
|
|
2996
3002
|
}
|
|
3003
|
+
async queryDb(input2) {
|
|
3004
|
+
const result = await this.http.post(
|
|
3005
|
+
"/api/v2/db/query",
|
|
3006
|
+
{
|
|
3007
|
+
sql: input2.sql,
|
|
3008
|
+
...input2.maxRows ? { max_rows: input2.maxRows } : {}
|
|
3009
|
+
}
|
|
3010
|
+
);
|
|
3011
|
+
return {
|
|
3012
|
+
...result,
|
|
3013
|
+
scope: { kind: "database", mutability: "current" }
|
|
3014
|
+
};
|
|
3015
|
+
}
|
|
2997
3016
|
/**
|
|
2998
|
-
* Run a bounded SQL query against the customer
|
|
3017
|
+
* Run a bounded SQL query against the current mutable customer database.
|
|
2999
3018
|
*
|
|
3000
|
-
*
|
|
3001
|
-
*
|
|
3019
|
+
* This query is not scoped to one play run. Use `client.runs` export actions
|
|
3020
|
+
* when the caller needs the rows produced by a specific run.
|
|
3021
|
+
*
|
|
3022
|
+
* @deprecated Use {@link DeeplineClient.db} `.query(...)`.
|
|
3002
3023
|
*/
|
|
3003
3024
|
async queryCustomerDb(input2) {
|
|
3004
|
-
return this.
|
|
3005
|
-
sql: input2.sql,
|
|
3006
|
-
...input2.maxRows ? { max_rows: input2.maxRows } : {}
|
|
3007
|
-
});
|
|
3025
|
+
return this.db.query(input2);
|
|
3008
3026
|
}
|
|
3009
3027
|
/**
|
|
3010
3028
|
* Re-establish this workspace's tenant storage contract: role/DB connect
|
|
@@ -4135,9 +4153,35 @@ var DeeplineClient = class {
|
|
|
4135
4153
|
if (input2.rowMode === "all") {
|
|
4136
4154
|
params.set("rowMode", "all");
|
|
4137
4155
|
}
|
|
4138
|
-
|
|
4156
|
+
const result = await this.http.get(
|
|
4139
4157
|
`/api/v2/plays/${encodeURIComponent(input2.playName)}/sheet?${params.toString()}`
|
|
4140
4158
|
);
|
|
4159
|
+
const requestedRunId = input2.runId?.trim() || "";
|
|
4160
|
+
if (requestedRunId) {
|
|
4161
|
+
const confirmedRunId = result.scope?.kind === "run" ? result.scope.runId.trim() : "";
|
|
4162
|
+
const foreignRowRunIds = [
|
|
4163
|
+
...new Set(
|
|
4164
|
+
result.rows.map(
|
|
4165
|
+
(row) => typeof row.runId === "string" ? row.runId.trim() : ""
|
|
4166
|
+
).filter((runId) => runId && runId !== requestedRunId)
|
|
4167
|
+
)
|
|
4168
|
+
];
|
|
4169
|
+
if (result.scope?.kind !== "run" || confirmedRunId !== requestedRunId || foreignRowRunIds.length > 0) {
|
|
4170
|
+
throw new DeeplineError(
|
|
4171
|
+
`Run-scoped dataset export was not confirmed for ${requestedRunId}; no rows were returned to the caller. Update Deepline, then retry the same export command. Do not rerun the play.`,
|
|
4172
|
+
void 0,
|
|
4173
|
+
"RUN_EXPORT_SCOPE_MISMATCH",
|
|
4174
|
+
{
|
|
4175
|
+
requestedRunId,
|
|
4176
|
+
confirmedScope: result.scope ?? null,
|
|
4177
|
+
foreignRowRunIds,
|
|
4178
|
+
playName: input2.playName,
|
|
4179
|
+
tableNamespace: input2.tableNamespace
|
|
4180
|
+
}
|
|
4181
|
+
);
|
|
4182
|
+
}
|
|
4183
|
+
}
|
|
4184
|
+
return result;
|
|
4141
4185
|
}
|
|
4142
4186
|
/**
|
|
4143
4187
|
* Stop a run by id using the public runs resource model.
|
|
@@ -7386,6 +7430,33 @@ function formatDatasetExecutionStats(raw, _persistedRowTotal) {
|
|
|
7386
7430
|
}
|
|
7387
7431
|
|
|
7388
7432
|
// src/cli/dataset-stats.ts
|
|
7433
|
+
function mergeCanonicalRowsInfo(left, right) {
|
|
7434
|
+
const preferred = right.rows.length > left.rows.length || right.complete && !left.complete && right.rows.length === left.rows.length ? right : left;
|
|
7435
|
+
const fallback = preferred === left ? right : left;
|
|
7436
|
+
const totalRows = Math.max(left.totalRows, right.totalRows);
|
|
7437
|
+
const exportUnavailableReason = left.exportUnavailableReason === "shared_table_namespace" || right.exportUnavailableReason === "shared_table_namespace" ? "shared_table_namespace" : left.exportUnavailableReason ?? right.exportUnavailableReason;
|
|
7438
|
+
const unavailableSource = left.exportUnavailableReason === exportUnavailableReason ? left : right.exportUnavailableReason === exportUnavailableReason ? right : null;
|
|
7439
|
+
const columns = preferred.columns.length > 0 ? preferred.columns : fallback.columns;
|
|
7440
|
+
return {
|
|
7441
|
+
...fallback,
|
|
7442
|
+
...preferred,
|
|
7443
|
+
rows: preferred.rows,
|
|
7444
|
+
totalRows,
|
|
7445
|
+
columns,
|
|
7446
|
+
columnsExplicit: columns === preferred.columns ? preferred.columnsExplicit : fallback.columnsExplicit,
|
|
7447
|
+
complete: preferred.rows.length === totalRows,
|
|
7448
|
+
source: preferred.source ?? fallback.source,
|
|
7449
|
+
datasetId: preferred.datasetId ?? fallback.datasetId,
|
|
7450
|
+
tableNamespace: preferred.tableNamespace ?? fallback.tableNamespace,
|
|
7451
|
+
...left.recovered || right.recovered ? { recovered: true } : {},
|
|
7452
|
+
...exportUnavailableReason ? {
|
|
7453
|
+
exportUnavailableReason,
|
|
7454
|
+
...unavailableSource?.exportUnavailableMessage ? {
|
|
7455
|
+
exportUnavailableMessage: unavailableSource.exportUnavailableMessage
|
|
7456
|
+
} : {}
|
|
7457
|
+
} : {}
|
|
7458
|
+
};
|
|
7459
|
+
}
|
|
7389
7460
|
var CSV_PROJECTED_FIELDS_KEY = "__deeplineCsvProjectedFields";
|
|
7390
7461
|
function csvProjectedFields(row) {
|
|
7391
7462
|
const serialized = row[CSV_PROJECTED_FIELDS_KEY];
|
|
@@ -7533,7 +7604,13 @@ function canonicalRowsInfoFromCandidate(input2) {
|
|
|
7533
7604
|
source: candidate.source,
|
|
7534
7605
|
datasetId: typeof candidate.value.datasetId === "string" ? candidate.value.datasetId : null,
|
|
7535
7606
|
tableNamespace: typeof candidate.value.tableNamespace === "string" ? candidate.value.tableNamespace : null,
|
|
7536
|
-
...candidate.value.recovered === true ? { recovered: true } : {}
|
|
7607
|
+
...candidate.value.recovered === true ? { recovered: true } : {},
|
|
7608
|
+
...isRecord4(candidate.value.exportUnavailable) && (candidate.value.exportUnavailable.reason === "empty_dataset" || candidate.value.exportUnavailable.reason === "shared_table_namespace") ? {
|
|
7609
|
+
exportUnavailableReason: candidate.value.exportUnavailable.reason,
|
|
7610
|
+
...typeof candidate.value.exportUnavailable.message === "string" ? {
|
|
7611
|
+
exportUnavailableMessage: candidate.value.exportUnavailable.message
|
|
7612
|
+
} : {}
|
|
7613
|
+
} : {}
|
|
7537
7614
|
};
|
|
7538
7615
|
}
|
|
7539
7616
|
if (candidate.serializedOnly) {
|
|
@@ -7708,6 +7785,23 @@ function collectPackagedDatasetCandidates(statusOrResult) {
|
|
|
7708
7785
|
}
|
|
7709
7786
|
return candidates;
|
|
7710
7787
|
}
|
|
7788
|
+
function collectPackagedStepDatasetCandidates(statusOrResult) {
|
|
7789
|
+
const root = isRecord4(statusOrResult) ? statusOrResult : null;
|
|
7790
|
+
if (!root) return [];
|
|
7791
|
+
const pkg = isRecord4(root.package) ? root.package : root;
|
|
7792
|
+
const steps = Array.isArray(pkg.steps) ? pkg.steps : [];
|
|
7793
|
+
return steps.flatMap((step) => {
|
|
7794
|
+
if (!isRecord4(step) || !isPackagedDatasetOutput(step.output)) return [];
|
|
7795
|
+
const source = typeof step.output.path === "string" && step.output.path.trim() ? step.output.path.trim() : null;
|
|
7796
|
+
return source ? [
|
|
7797
|
+
{
|
|
7798
|
+
source,
|
|
7799
|
+
value: step.output,
|
|
7800
|
+
total: step.output.rowCount ?? step.output.preview?.totalRows ?? void 0
|
|
7801
|
+
}
|
|
7802
|
+
] : [];
|
|
7803
|
+
});
|
|
7804
|
+
}
|
|
7711
7805
|
function collectSerializedDatasetRowsInfos(statusOrResult) {
|
|
7712
7806
|
const root = isRecord4(statusOrResult) ? statusOrResult : null;
|
|
7713
7807
|
const result = isRecord4(root?.result) ? root.result : root;
|
|
@@ -7726,8 +7820,9 @@ function collectSerializedDatasetRowsInfos(statusOrResult) {
|
|
|
7726
7820
|
});
|
|
7727
7821
|
}
|
|
7728
7822
|
}
|
|
7823
|
+
candidates.push(...collectPackagedStepDatasetCandidates(statusOrResult));
|
|
7729
7824
|
candidates.push(...collectPackagedDatasetCandidates(statusOrResult));
|
|
7730
|
-
const
|
|
7825
|
+
const sourceIndexes = /* @__PURE__ */ new Map();
|
|
7731
7826
|
const infos = [];
|
|
7732
7827
|
for (const candidate of candidates) {
|
|
7733
7828
|
const info = canonicalRowsInfoFromCandidate({
|
|
@@ -7736,10 +7831,15 @@ function collectSerializedDatasetRowsInfos(statusOrResult) {
|
|
|
7736
7831
|
});
|
|
7737
7832
|
if (info) {
|
|
7738
7833
|
if (info.source) {
|
|
7739
|
-
|
|
7834
|
+
const existingIndex = sourceIndexes.get(info.source);
|
|
7835
|
+
if (existingIndex !== void 0) {
|
|
7836
|
+
infos[existingIndex] = mergeCanonicalRowsInfo(
|
|
7837
|
+
infos[existingIndex],
|
|
7838
|
+
info
|
|
7839
|
+
);
|
|
7740
7840
|
continue;
|
|
7741
7841
|
}
|
|
7742
|
-
|
|
7842
|
+
sourceIndexes.set(info.source, infos.length);
|
|
7743
7843
|
}
|
|
7744
7844
|
infos.push(info);
|
|
7745
7845
|
}
|
|
@@ -8581,7 +8681,7 @@ async function handleDbQuery(args) {
|
|
|
8581
8681
|
const client2 = new DeeplineClient();
|
|
8582
8682
|
let result;
|
|
8583
8683
|
try {
|
|
8584
|
-
result = await client2.
|
|
8684
|
+
result = await client2.db.query({ sql, maxRows });
|
|
8585
8685
|
} catch (error) {
|
|
8586
8686
|
console.error(formatDbQueryError(sql, error));
|
|
8587
8687
|
return 1;
|
|
@@ -8793,7 +8893,13 @@ Examples:
|
|
|
8793
8893
|
deepline db repair
|
|
8794
8894
|
deepline db repair --json
|
|
8795
8895
|
`
|
|
8796
|
-
).option(
|
|
8896
|
+
).option(
|
|
8897
|
+
"--provider <provider>",
|
|
8898
|
+
"Limit materialized-table repair to one provider"
|
|
8899
|
+
).option(
|
|
8900
|
+
"--json",
|
|
8901
|
+
"Emit raw JSON response. Also automatic when stdout is piped"
|
|
8902
|
+
).action(async (options) => {
|
|
8797
8903
|
process.exitCode = await handleDbRepair([
|
|
8798
8904
|
...options.provider ? ["--provider", options.provider] : [],
|
|
8799
8905
|
...options.json ? ["--json"] : []
|
|
@@ -13731,9 +13837,15 @@ function actionToCommand(action) {
|
|
|
13731
13837
|
return null;
|
|
13732
13838
|
}
|
|
13733
13839
|
const record = action;
|
|
13840
|
+
if (typeof record.command === "string" && record.command.trim()) {
|
|
13841
|
+
return record.command.trim();
|
|
13842
|
+
}
|
|
13734
13843
|
if (record.kind === "deepline_run_inspect" && typeof record.runId === "string") {
|
|
13735
13844
|
return `deepline runs get ${record.runId} --json`;
|
|
13736
13845
|
}
|
|
13846
|
+
if (record.kind === "deepline_run_full" && typeof record.runId === "string") {
|
|
13847
|
+
return `deepline runs get ${record.runId} --full --json`;
|
|
13848
|
+
}
|
|
13737
13849
|
if (record.kind === "deepline_run_billing" && typeof record.runId === "string") {
|
|
13738
13850
|
return `deepline runs get ${record.runId} --full --json | jq '.billing'`;
|
|
13739
13851
|
}
|
|
@@ -13756,19 +13868,70 @@ function actionToCommand(action) {
|
|
|
13756
13868
|
}
|
|
13757
13869
|
return null;
|
|
13758
13870
|
}
|
|
13759
|
-
function
|
|
13760
|
-
|
|
13761
|
-
|
|
13762
|
-
|
|
13871
|
+
function packageDatasetRecords(packaged) {
|
|
13872
|
+
const catalog = readRecordArray(packaged.datasets);
|
|
13873
|
+
if (catalog.length > 0) return catalog;
|
|
13874
|
+
return readRecordArray(packaged.steps).flatMap((step) => {
|
|
13875
|
+
const output2 = readRecord(step.output);
|
|
13876
|
+
return output2?.kind === "dataset" ? [output2] : [];
|
|
13877
|
+
});
|
|
13878
|
+
}
|
|
13879
|
+
function packageReturnedDatasetIdentity(packaged) {
|
|
13880
|
+
const datasetIds = /* @__PURE__ */ new Set();
|
|
13881
|
+
const paths = /* @__PURE__ */ new Set();
|
|
13882
|
+
const outputs = readRecord(packaged.outputs) ?? {};
|
|
13883
|
+
for (const outputValue of Object.values(outputs)) {
|
|
13884
|
+
const output2 = readRecord(outputValue);
|
|
13885
|
+
if (output2?.kind !== "dataset") continue;
|
|
13886
|
+
if (typeof output2.datasetId === "string" && output2.datasetId.trim()) {
|
|
13887
|
+
datasetIds.add(output2.datasetId.trim());
|
|
13888
|
+
}
|
|
13889
|
+
for (const candidate of [output2.dataset, output2.path]) {
|
|
13890
|
+
if (typeof candidate === "string" && candidate.trim()) {
|
|
13891
|
+
paths.add(candidate.trim());
|
|
13892
|
+
}
|
|
13893
|
+
}
|
|
13763
13894
|
}
|
|
13764
|
-
|
|
13765
|
-
|
|
13766
|
-
|
|
13767
|
-
|
|
13768
|
-
|
|
13895
|
+
return { datasetIds, paths };
|
|
13896
|
+
}
|
|
13897
|
+
function formatPackageDatasetActionLines(packaged) {
|
|
13898
|
+
const returned = packageReturnedDatasetIdentity(packaged);
|
|
13899
|
+
const lines = [];
|
|
13900
|
+
for (const dataset of packageDatasetRecords(packaged)) {
|
|
13901
|
+
const path = typeof dataset.path === "string" && dataset.path.trim() ? dataset.path.trim() : "dataset";
|
|
13902
|
+
const datasetId = typeof dataset.datasetId === "string" ? dataset.datasetId.trim() : "";
|
|
13903
|
+
const isReturned = datasetId && returned.datasetIds.has(datasetId) || returned.paths.has(path);
|
|
13904
|
+
const category = isReturned ? "returned" : dataset.recovered === true ? "recovered" : "persisted";
|
|
13905
|
+
const rowCount = typeof dataset.rowCount === "number" && Number.isFinite(dataset.rowCount) ? Math.max(0, Math.trunc(dataset.rowCount)) : null;
|
|
13906
|
+
const actions = readRecord(dataset.actions) ?? {};
|
|
13907
|
+
if (category === "recovered" && Object.keys(actions).length === 0) {
|
|
13908
|
+
lines.push(
|
|
13909
|
+
` dataset ${path}: available, ${rowCount === null ? "persisted" : formatInteger(rowCount)} rows persisted; re-running reuses completed work`
|
|
13910
|
+
);
|
|
13911
|
+
} else {
|
|
13912
|
+
lines.push(
|
|
13913
|
+
` ${category} dataset ${path}: ${rowCount === null ? "unknown rows" : `${formatInteger(rowCount)} ${rowCount === 1 ? "row" : "rows"}`}`
|
|
13914
|
+
);
|
|
13915
|
+
}
|
|
13916
|
+
const exportCommand = actionToCommand(actions.exportCsv);
|
|
13917
|
+
const currentQueryCommand = actionToCommand(actions.queryCurrentTable);
|
|
13918
|
+
const legacyQueryCommand = actionToCommand(actions.query);
|
|
13919
|
+
if (exportCommand) {
|
|
13920
|
+
lines.push(` export this run: ${exportCommand}`);
|
|
13921
|
+
}
|
|
13922
|
+
if (currentQueryCommand) {
|
|
13923
|
+
lines.push(` query current table: ${currentQueryCommand}`);
|
|
13924
|
+
} else if (legacyQueryCommand) {
|
|
13925
|
+
lines.push(` query run rows (legacy): ${legacyQueryCommand}`);
|
|
13926
|
+
}
|
|
13927
|
+
const unavailable = readRecord(dataset.exportUnavailable);
|
|
13928
|
+
if (typeof unavailable?.reason === "string" && typeof unavailable.message === "string") {
|
|
13929
|
+
lines.push(
|
|
13930
|
+
` export unavailable (${unavailable.reason}): ${unavailable.message}`
|
|
13931
|
+
);
|
|
13769
13932
|
}
|
|
13770
13933
|
}
|
|
13771
|
-
return
|
|
13934
|
+
return lines;
|
|
13772
13935
|
}
|
|
13773
13936
|
function formatInlinePackageValue(value) {
|
|
13774
13937
|
const compacted = compactReturnValue(value);
|
|
@@ -13844,18 +14007,11 @@ function buildRunPackageTextLines(packaged) {
|
|
|
13844
14007
|
failedLogAssociation === "retained_before_truncation" ? ` retained logs: ${failedLogNext.logs}` : ` retry failed logs: ${failedLogNext.logs}`
|
|
13845
14008
|
);
|
|
13846
14009
|
}
|
|
13847
|
-
for (const output2 of readRecordArray(packaged.datasets)) {
|
|
13848
|
-
if (output2.recovered !== true) continue;
|
|
13849
|
-
const rowCount = typeof output2.rowCount === "number" ? formatInteger(output2.rowCount) : "persisted";
|
|
13850
|
-
const datasetPath = typeof output2.path === "string" ? output2.path : "dataset";
|
|
13851
|
-
lines.push(
|
|
13852
|
-
` dataset ${datasetPath}: available, ${rowCount} rows persisted; re-running reuses completed work`
|
|
13853
|
-
);
|
|
13854
|
-
}
|
|
13855
14010
|
if (playName) {
|
|
13856
14011
|
lines.push(` play: ${playName}`);
|
|
13857
14012
|
}
|
|
13858
14013
|
lines.push(...formatPackageValueOutputLines(packaged));
|
|
14014
|
+
lines.push(...formatPackageDatasetActionLines(packaged));
|
|
13859
14015
|
const next = packaged.next && typeof packaged.next === "object" && !Array.isArray(packaged.next) ? packaged.next : {};
|
|
13860
14016
|
const billingCommand = actionToCommand(next.billing);
|
|
13861
14017
|
const logsCommand = actionToCommand(next.logs);
|
|
@@ -13879,16 +14035,20 @@ function buildRunPackageTextLines(packaged) {
|
|
|
13879
14035
|
);
|
|
13880
14036
|
}
|
|
13881
14037
|
}
|
|
13882
|
-
const datasetActions = readFirstDatasetActions(packaged);
|
|
13883
14038
|
const inspectCommand = actionToCommand(next.inspect);
|
|
13884
|
-
const
|
|
13885
|
-
const
|
|
14039
|
+
const fullResultCommand = actionToCommand(next.full);
|
|
14040
|
+
const hasCatalogExportAction = packageDatasetRecords(packaged).some(
|
|
14041
|
+
(dataset) => Boolean(actionToCommand(readRecord(dataset.actions)?.exportCsv))
|
|
14042
|
+
);
|
|
14043
|
+
const legacyExportCommand = hasCatalogExportAction ? null : actionToCommand(next.export);
|
|
13886
14044
|
const runAgainCommand = typeof next.run === "string" && next.run.trim() ? next.run.trim() : null;
|
|
13887
14045
|
if (inspectCommand) lines.push(` inspect: ${inspectCommand}`);
|
|
14046
|
+
if (fullResultCommand) lines.push(` full result: ${fullResultCommand}`);
|
|
13888
14047
|
if (logsCommand) lines.push(` logs: ${logsCommand}`);
|
|
13889
14048
|
if (billingCommand) lines.push(` billing: ${billingCommand}`);
|
|
13890
|
-
if (
|
|
13891
|
-
|
|
14049
|
+
if (legacyExportCommand) {
|
|
14050
|
+
lines.push(` export CSV: ${legacyExportCommand}`);
|
|
14051
|
+
}
|
|
13892
14052
|
if (runAgainCommand) {
|
|
13893
14053
|
lines.push(" run again (completed work is reused):");
|
|
13894
14054
|
lines.push(` ${runAgainCommand}`);
|
|
@@ -14188,6 +14348,102 @@ function resolveDatasetByName(available, datasetPath) {
|
|
|
14188
14348
|
}
|
|
14189
14349
|
return null;
|
|
14190
14350
|
}
|
|
14351
|
+
function canonicalRowsIdentity(info) {
|
|
14352
|
+
return info.datasetId?.trim() ? `id:${info.datasetId.trim()}` : `path:${info.source ?? info.tableNamespace ?? "dataset"}`;
|
|
14353
|
+
}
|
|
14354
|
+
function distinctCanonicalRowsInfos(infos) {
|
|
14355
|
+
const byIdentity = /* @__PURE__ */ new Map();
|
|
14356
|
+
for (const info of infos) {
|
|
14357
|
+
const identity = canonicalRowsIdentity(info);
|
|
14358
|
+
const existing = byIdentity.get(identity);
|
|
14359
|
+
byIdentity.set(
|
|
14360
|
+
identity,
|
|
14361
|
+
existing ? mergeCanonicalRowsInfo(existing, info) : info
|
|
14362
|
+
);
|
|
14363
|
+
}
|
|
14364
|
+
return [...byIdentity.values()];
|
|
14365
|
+
}
|
|
14366
|
+
function packageForExportSelection(status) {
|
|
14367
|
+
const root = status;
|
|
14368
|
+
const nested = readRecord(root.package);
|
|
14369
|
+
if (nested?.kind === "play_run") return nested;
|
|
14370
|
+
return root.kind === "play_run" ? root : null;
|
|
14371
|
+
}
|
|
14372
|
+
function withReturnedDatasetAliases(status, available) {
|
|
14373
|
+
const packaged = packageForExportSelection(status);
|
|
14374
|
+
const outputs = readRecord(packaged?.outputs);
|
|
14375
|
+
if (!outputs) return available;
|
|
14376
|
+
const expanded = [...available];
|
|
14377
|
+
for (const outputValue of Object.values(outputs)) {
|
|
14378
|
+
const output2 = readRecord(outputValue);
|
|
14379
|
+
if (output2?.kind !== "dataset") continue;
|
|
14380
|
+
const alias = typeof output2.path === "string" && output2.path.trim() ? output2.path.trim() : null;
|
|
14381
|
+
if (!alias) continue;
|
|
14382
|
+
const datasetId = typeof output2.datasetId === "string" && output2.datasetId.trim() ? output2.datasetId.trim() : null;
|
|
14383
|
+
const canonicalPath2 = typeof output2.dataset === "string" && output2.dataset.trim() ? output2.dataset.trim() : null;
|
|
14384
|
+
const canonical = available.find(
|
|
14385
|
+
(info) => datasetId && info.datasetId === datasetId || canonicalPath2 && info.source === canonicalPath2
|
|
14386
|
+
);
|
|
14387
|
+
if (canonical) {
|
|
14388
|
+
const aliasIndex = expanded.findIndex((info) => info.source === alias);
|
|
14389
|
+
if (aliasIndex >= 0) {
|
|
14390
|
+
expanded[aliasIndex] = {
|
|
14391
|
+
...mergeCanonicalRowsInfo(expanded[aliasIndex], canonical),
|
|
14392
|
+
source: alias
|
|
14393
|
+
};
|
|
14394
|
+
} else {
|
|
14395
|
+
expanded.push({ ...canonical, source: alias });
|
|
14396
|
+
}
|
|
14397
|
+
}
|
|
14398
|
+
}
|
|
14399
|
+
return expanded;
|
|
14400
|
+
}
|
|
14401
|
+
function returnedRowsInfos(status, available) {
|
|
14402
|
+
const packaged = packageForExportSelection(status);
|
|
14403
|
+
const outputs = readRecord(packaged?.outputs);
|
|
14404
|
+
if (outputs) {
|
|
14405
|
+
const selected = /* @__PURE__ */ new Map();
|
|
14406
|
+
for (const outputValue of Object.values(outputs)) {
|
|
14407
|
+
const output2 = readRecord(outputValue);
|
|
14408
|
+
if (output2?.kind !== "dataset") continue;
|
|
14409
|
+
const datasetId = typeof output2.datasetId === "string" && output2.datasetId.trim() ? output2.datasetId.trim() : null;
|
|
14410
|
+
const alias = typeof output2.path === "string" && output2.path.trim() ? output2.path.trim() : null;
|
|
14411
|
+
const canonicalPath2 = typeof output2.dataset === "string" && output2.dataset.trim() ? output2.dataset.trim() : null;
|
|
14412
|
+
const info = (alias ? available.find((candidate) => candidate.source === alias) : null) ?? (datasetId ? available.find((candidate) => candidate.datasetId === datasetId) : null) ?? (canonicalPath2 ? available.find((candidate) => candidate.source === canonicalPath2) : null);
|
|
14413
|
+
if (!info) continue;
|
|
14414
|
+
const identity = datasetId ? `id:${datasetId}` : `path:${canonicalPath2 ?? alias ?? info.source ?? "dataset"}`;
|
|
14415
|
+
const aliased = { ...info, source: alias ?? info.source };
|
|
14416
|
+
const existing = selected.get(identity);
|
|
14417
|
+
selected.set(
|
|
14418
|
+
identity,
|
|
14419
|
+
existing ? mergeCanonicalRowsInfo(existing, aliased) : aliased
|
|
14420
|
+
);
|
|
14421
|
+
}
|
|
14422
|
+
if (selected.size > 0) return [...selected.values()];
|
|
14423
|
+
}
|
|
14424
|
+
return distinctCanonicalRowsInfos(
|
|
14425
|
+
available.filter(
|
|
14426
|
+
(info) => Boolean(info.source?.startsWith("result.")) && !info.recovered
|
|
14427
|
+
)
|
|
14428
|
+
);
|
|
14429
|
+
}
|
|
14430
|
+
function exportDatasetCommand(input2) {
|
|
14431
|
+
return `deepline runs export ${input2.runId} --dataset ${shellSingleQuote(
|
|
14432
|
+
input2.datasetPath
|
|
14433
|
+
)} --out ${shellSingleQuote((0, import_node_path11.resolve)(input2.outPath))}`;
|
|
14434
|
+
}
|
|
14435
|
+
function datasetChoiceLines(input2) {
|
|
14436
|
+
return input2.datasets.flatMap((dataset) => {
|
|
14437
|
+
const path = dataset.source ?? dataset.datasetId ?? dataset.tableNamespace;
|
|
14438
|
+
return path ? [
|
|
14439
|
+
exportDatasetCommand({
|
|
14440
|
+
runId: input2.runId,
|
|
14441
|
+
datasetPath: path,
|
|
14442
|
+
outPath: input2.outPath
|
|
14443
|
+
})
|
|
14444
|
+
] : [];
|
|
14445
|
+
});
|
|
14446
|
+
}
|
|
14191
14447
|
function assertDatasetHasExportableRows(input2) {
|
|
14192
14448
|
if (input2.rowsInfo.rows.length > 0) {
|
|
14193
14449
|
return input2.rowsInfo;
|
|
@@ -14208,28 +14464,93 @@ function assertDatasetHasExportableRows(input2) {
|
|
|
14208
14464
|
}
|
|
14209
14465
|
);
|
|
14210
14466
|
}
|
|
14467
|
+
function assertDatasetExportAvailable(input2) {
|
|
14468
|
+
if (input2.rowsInfo.exportUnavailableReason !== "shared_table_namespace") {
|
|
14469
|
+
return;
|
|
14470
|
+
}
|
|
14471
|
+
throw new DeeplineError(
|
|
14472
|
+
input2.rowsInfo.exportUnavailableMessage ?? "Run CSV export is unavailable because multiple Dataset Handles share one physical table.",
|
|
14473
|
+
void 0,
|
|
14474
|
+
"RUN_EXPORT_UNAVAILABLE",
|
|
14475
|
+
{
|
|
14476
|
+
runId: input2.status.runId,
|
|
14477
|
+
dataset: input2.rowsInfo.source,
|
|
14478
|
+
datasetId: input2.rowsInfo.datasetId ?? null,
|
|
14479
|
+
tableNamespace: input2.rowsInfo.tableNamespace ?? null,
|
|
14480
|
+
reason: input2.rowsInfo.exportUnavailableReason
|
|
14481
|
+
}
|
|
14482
|
+
);
|
|
14483
|
+
}
|
|
14211
14484
|
async function exportPlayStatusRows(client2, status, outPath, options = {}) {
|
|
14212
14485
|
if (!outPath) {
|
|
14213
14486
|
return null;
|
|
14214
14487
|
}
|
|
14215
|
-
const availableRows =
|
|
14216
|
-
|
|
14488
|
+
const availableRows = withReturnedDatasetAliases(
|
|
14489
|
+
status,
|
|
14490
|
+
distinctCanonicalRowsInfos(collectSerializedDatasetRowsInfos(status))
|
|
14491
|
+
);
|
|
14492
|
+
const returnedRows = returnedRowsInfos(status, availableRows);
|
|
14493
|
+
const recoveredRows = distinctCanonicalRowsInfos(
|
|
14494
|
+
availableRows.filter((info) => info.recovered)
|
|
14495
|
+
);
|
|
14496
|
+
const rowsInfo = options.datasetPath ? resolveDatasetByName(availableRows, options.datasetPath) ?? null : returnedRows.length === 1 ? returnedRows[0] : returnedRows.length === 0 && recoveredRows.length === 1 ? recoveredRows[0] : null;
|
|
14217
14497
|
if (!rowsInfo && options.datasetPath) {
|
|
14218
14498
|
const available = availableRows.map((info) => info.source).filter((source) => typeof source === "string");
|
|
14499
|
+
const commands = datasetChoiceLines({
|
|
14500
|
+
runId: status.runId,
|
|
14501
|
+
datasets: availableRows,
|
|
14502
|
+
outPath
|
|
14503
|
+
});
|
|
14219
14504
|
throw new DeeplineError(
|
|
14220
|
-
`Run ${status.runId} did not return a dataset at ${options.datasetPath}.` + (available.length > 0 ? ` Available datasets: ${available.join(", ")}
|
|
14505
|
+
`Run ${status.runId} did not return a dataset at ${options.datasetPath}.` + (available.length > 0 ? ` Available datasets: ${available.join(", ")}.
|
|
14506
|
+
${commands.join("\n")}` : ""),
|
|
14221
14507
|
void 0,
|
|
14222
14508
|
"RUN_EXPORT_DATASET_NOT_FOUND",
|
|
14223
14509
|
{ runId: status.runId, dataset: options.datasetPath, available }
|
|
14224
14510
|
);
|
|
14225
14511
|
}
|
|
14226
|
-
if (!options.datasetPath &&
|
|
14227
|
-
const available =
|
|
14512
|
+
if (!options.datasetPath && returnedRows.length > 1) {
|
|
14513
|
+
const available = returnedRows.map((info) => info.source).filter((source) => typeof source === "string");
|
|
14514
|
+
const commands = datasetChoiceLines({
|
|
14515
|
+
runId: status.runId,
|
|
14516
|
+
datasets: returnedRows,
|
|
14517
|
+
outPath
|
|
14518
|
+
});
|
|
14228
14519
|
throw new DeeplineError(
|
|
14229
|
-
`Run ${status.runId} returned multiple datasets. Choose one
|
|
14520
|
+
`Run ${status.runId} returned multiple datasets. Choose one:
|
|
14521
|
+
${commands.join("\n")}`,
|
|
14230
14522
|
void 0,
|
|
14231
14523
|
"RUN_EXPORT_DATASET_REQUIRED",
|
|
14232
|
-
{
|
|
14524
|
+
{
|
|
14525
|
+
runId: status.runId,
|
|
14526
|
+
available,
|
|
14527
|
+
datasets: returnedRows.map((info, index) => ({
|
|
14528
|
+
path: info.source,
|
|
14529
|
+
rowCount: info.totalRows,
|
|
14530
|
+
command: commands[index]
|
|
14531
|
+
}))
|
|
14532
|
+
}
|
|
14533
|
+
);
|
|
14534
|
+
}
|
|
14535
|
+
if (!options.datasetPath && returnedRows.length === 0 && recoveredRows.length > 1) {
|
|
14536
|
+
const commands = datasetChoiceLines({
|
|
14537
|
+
runId: status.runId,
|
|
14538
|
+
datasets: recoveredRows,
|
|
14539
|
+
outPath
|
|
14540
|
+
});
|
|
14541
|
+
throw new DeeplineError(
|
|
14542
|
+
`Run ${status.runId} has multiple recovered datasets. Choose one:
|
|
14543
|
+
${commands.join("\n")}`,
|
|
14544
|
+
void 0,
|
|
14545
|
+
"RUN_EXPORT_DATASET_REQUIRED",
|
|
14546
|
+
{
|
|
14547
|
+
runId: status.runId,
|
|
14548
|
+
datasets: recoveredRows.map((info, index) => ({
|
|
14549
|
+
path: info.source,
|
|
14550
|
+
rowCount: info.totalRows,
|
|
14551
|
+
command: commands[index]
|
|
14552
|
+
}))
|
|
14553
|
+
}
|
|
14233
14554
|
);
|
|
14234
14555
|
}
|
|
14235
14556
|
if (!rowsInfo) {
|
|
@@ -14237,6 +14558,7 @@ async function exportPlayStatusRows(client2, status, outPath, options = {}) {
|
|
|
14237
14558
|
`Run ${status.runId} did not expose a row-shaped final output to export.`
|
|
14238
14559
|
);
|
|
14239
14560
|
}
|
|
14561
|
+
assertDatasetExportAvailable({ rowsInfo, status });
|
|
14240
14562
|
const attempts = Math.max(1, Math.trunc(options.attempts ?? 1));
|
|
14241
14563
|
const retryDelayMs = Math.max(0, Math.trunc(options.retryDelayMs ?? 0));
|
|
14242
14564
|
for (let attempt = 1; attempt <= attempts; attempt += 1) {
|
|
@@ -14248,6 +14570,9 @@ async function exportPlayStatusRows(client2, status, outPath, options = {}) {
|
|
|
14248
14570
|
rowsInfo
|
|
14249
14571
|
});
|
|
14250
14572
|
} catch (error) {
|
|
14573
|
+
if (error instanceof DeeplineError && error.code === "RUN_EXPORT_SCOPE_MISMATCH") {
|
|
14574
|
+
throw error;
|
|
14575
|
+
}
|
|
14251
14576
|
if (!rowsInfo.complete) {
|
|
14252
14577
|
throw error;
|
|
14253
14578
|
}
|
|
@@ -20109,7 +20434,9 @@ function readFirstEnrichDatasetActions(value) {
|
|
|
20109
20434
|
}
|
|
20110
20435
|
const record = candidate;
|
|
20111
20436
|
const actions = isRecord7(record.actions) ? record.actions : null;
|
|
20112
|
-
const
|
|
20437
|
+
const currentQuery = isRecord7(actions?.queryCurrentTable) ? actions.queryCurrentTable : null;
|
|
20438
|
+
const legacyQuery = isRecord7(actions?.query) ? actions.query : null;
|
|
20439
|
+
const query = currentQuery?.kind === "deepline_db_query" ? currentQuery : legacyQuery?.kind === "deepline_db_query" ? legacyQuery : null;
|
|
20113
20440
|
if (query?.kind === "deepline_db_query") {
|
|
20114
20441
|
return {
|
|
20115
20442
|
dataset: record,
|
|
@@ -20335,7 +20662,7 @@ async function collectCustomerDbFailureJobs(input2) {
|
|
|
20335
20662
|
for (let attempt = 0; attempt <= retryDelays.length; attempt += 1) {
|
|
20336
20663
|
try {
|
|
20337
20664
|
attempts = attempt + 1;
|
|
20338
|
-
result = await input2.client.
|
|
20665
|
+
result = await input2.client.db.query({
|
|
20339
20666
|
sql,
|
|
20340
20667
|
maxRows: 1e3
|
|
20341
20668
|
});
|