deepline 0.1.237 → 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 +6 -4
- 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 +387 -58
- package/dist/cli/index.mjs +387 -58
- package/dist/index.d.mts +107 -6
- package/dist/index.d.ts +107 -6
- package/dist/index.js +58 -12
- package/dist/index.mjs +58 -12
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -623,19 +623,21 @@ var SDK_RELEASE = {
|
|
|
623
623
|
// 0.1.154 removes the short-lived generated enrich StepOptions recompute
|
|
624
624
|
// fields shipped in 0.1.153.
|
|
625
625
|
// 0.1.175 ships loud `deepline enrich` empty-waterfall reporting.
|
|
626
|
+
// 0.1.230 propagates enrich extractor failures as failed rows rather than
|
|
627
|
+
// silently materializing them as unmatched results.
|
|
626
628
|
// 0.1.220 deprecates SDK CLI versions below 0.1.219 and updates them
|
|
627
629
|
// automatically without blocking their current command.
|
|
628
|
-
version: "0.1.
|
|
630
|
+
version: "0.1.239",
|
|
629
631
|
apiContract: "2026-06-dataset-handle-results-hard-cutover",
|
|
630
632
|
supportPolicy: {
|
|
631
|
-
latest: "0.1.
|
|
633
|
+
latest: "0.1.239",
|
|
632
634
|
minimumSupported: "0.1.53",
|
|
633
635
|
deprecatedBelow: "0.1.219",
|
|
634
636
|
commandMinimumSupported: [
|
|
635
637
|
{
|
|
636
638
|
command: "enrich",
|
|
637
|
-
minimumSupported: "0.1.
|
|
638
|
-
reason:
|
|
639
|
+
minimumSupported: "0.1.238",
|
|
640
|
+
reason: 'Older SDK CLI enrich generated stale play source; SDK CLI enrich 0.1.153 generated removed StepOptions fields in play source; SDK CLI enrich before 0.1.175 could silently succeed on the empty-waterfall bug when a requested waterfall returned no values for selected rows; SDK CLI enrich before 0.1.230 could convert extractor failures into successful unmatched results; SDK CLI enrich before 0.1.238 could drop a nested provider email match during generic pick("email") extraction and materialize it as NO_MATCH.'
|
|
639
641
|
},
|
|
640
642
|
{
|
|
641
643
|
command: "plays",
|
|
@@ -890,6 +892,7 @@ var HttpClient = class {
|
|
|
890
892
|
"X-Deepline-CLI-Version": SDK_VERSION,
|
|
891
893
|
"X-Deepline-SDK-Version": SDK_VERSION,
|
|
892
894
|
"X-Deepline-API-Contract": SDK_API_CONTRACT,
|
|
895
|
+
"X-Deepline-Run-Result-Shape": "canonical",
|
|
893
896
|
...extra
|
|
894
897
|
};
|
|
895
898
|
const skillsVersion = this.readSkillsVersionHeader();
|
|
@@ -2703,6 +2706,8 @@ var DeeplineClient = class {
|
|
|
2703
2706
|
config;
|
|
2704
2707
|
/** Canonical run lifecycle namespace backed by `/api/v2/runs`. */
|
|
2705
2708
|
runs;
|
|
2709
|
+
/** Current mutable customer database namespace backed by `/api/v2/db/query`. */
|
|
2710
|
+
db;
|
|
2706
2711
|
/** Billing namespace: subscription status/cancel and invoice history. */
|
|
2707
2712
|
billing;
|
|
2708
2713
|
/**
|
|
@@ -2726,6 +2731,9 @@ var DeeplineClient = class {
|
|
|
2726
2731
|
stop: (runId, options2) => this.stopRun(runId, options2),
|
|
2727
2732
|
stopAll: (options2) => this.stopAllRuns(options2)
|
|
2728
2733
|
};
|
|
2734
|
+
this.db = {
|
|
2735
|
+
query: (input2) => this.queryDb(input2)
|
|
2736
|
+
};
|
|
2729
2737
|
this.billing = {
|
|
2730
2738
|
topUp: (options2) => this.topUpBillingBalance(options2),
|
|
2731
2739
|
plans: () => this.getBillingPlans(),
|
|
@@ -2992,17 +3000,29 @@ var DeeplineClient = class {
|
|
|
2992
3000
|
async executeToolRaw(toolId, input2, options) {
|
|
2993
3001
|
return this.executeTool(toolId, input2, options);
|
|
2994
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
|
+
}
|
|
2995
3016
|
/**
|
|
2996
|
-
* Run a bounded SQL query against the customer
|
|
3017
|
+
* Run a bounded SQL query against the current mutable customer database.
|
|
2997
3018
|
*
|
|
2998
|
-
*
|
|
2999
|
-
*
|
|
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(...)`.
|
|
3000
3023
|
*/
|
|
3001
3024
|
async queryCustomerDb(input2) {
|
|
3002
|
-
return this.
|
|
3003
|
-
sql: input2.sql,
|
|
3004
|
-
...input2.maxRows ? { max_rows: input2.maxRows } : {}
|
|
3005
|
-
});
|
|
3025
|
+
return this.db.query(input2);
|
|
3006
3026
|
}
|
|
3007
3027
|
/**
|
|
3008
3028
|
* Re-establish this workspace's tenant storage contract: role/DB connect
|
|
@@ -4133,9 +4153,35 @@ var DeeplineClient = class {
|
|
|
4133
4153
|
if (input2.rowMode === "all") {
|
|
4134
4154
|
params.set("rowMode", "all");
|
|
4135
4155
|
}
|
|
4136
|
-
|
|
4156
|
+
const result = await this.http.get(
|
|
4137
4157
|
`/api/v2/plays/${encodeURIComponent(input2.playName)}/sheet?${params.toString()}`
|
|
4138
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;
|
|
4139
4185
|
}
|
|
4140
4186
|
/**
|
|
4141
4187
|
* Stop a run by id using the public runs resource model.
|
|
@@ -7384,6 +7430,33 @@ function formatDatasetExecutionStats(raw, _persistedRowTotal) {
|
|
|
7384
7430
|
}
|
|
7385
7431
|
|
|
7386
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
|
+
}
|
|
7387
7460
|
var CSV_PROJECTED_FIELDS_KEY = "__deeplineCsvProjectedFields";
|
|
7388
7461
|
function csvProjectedFields(row) {
|
|
7389
7462
|
const serialized = row[CSV_PROJECTED_FIELDS_KEY];
|
|
@@ -7531,7 +7604,13 @@ function canonicalRowsInfoFromCandidate(input2) {
|
|
|
7531
7604
|
source: candidate.source,
|
|
7532
7605
|
datasetId: typeof candidate.value.datasetId === "string" ? candidate.value.datasetId : null,
|
|
7533
7606
|
tableNamespace: typeof candidate.value.tableNamespace === "string" ? candidate.value.tableNamespace : null,
|
|
7534
|
-
...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
|
+
} : {}
|
|
7535
7614
|
};
|
|
7536
7615
|
}
|
|
7537
7616
|
if (candidate.serializedOnly) {
|
|
@@ -7706,6 +7785,23 @@ function collectPackagedDatasetCandidates(statusOrResult) {
|
|
|
7706
7785
|
}
|
|
7707
7786
|
return candidates;
|
|
7708
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
|
+
}
|
|
7709
7805
|
function collectSerializedDatasetRowsInfos(statusOrResult) {
|
|
7710
7806
|
const root = isRecord4(statusOrResult) ? statusOrResult : null;
|
|
7711
7807
|
const result = isRecord4(root?.result) ? root.result : root;
|
|
@@ -7724,8 +7820,9 @@ function collectSerializedDatasetRowsInfos(statusOrResult) {
|
|
|
7724
7820
|
});
|
|
7725
7821
|
}
|
|
7726
7822
|
}
|
|
7823
|
+
candidates.push(...collectPackagedStepDatasetCandidates(statusOrResult));
|
|
7727
7824
|
candidates.push(...collectPackagedDatasetCandidates(statusOrResult));
|
|
7728
|
-
const
|
|
7825
|
+
const sourceIndexes = /* @__PURE__ */ new Map();
|
|
7729
7826
|
const infos = [];
|
|
7730
7827
|
for (const candidate of candidates) {
|
|
7731
7828
|
const info = canonicalRowsInfoFromCandidate({
|
|
@@ -7734,10 +7831,15 @@ function collectSerializedDatasetRowsInfos(statusOrResult) {
|
|
|
7734
7831
|
});
|
|
7735
7832
|
if (info) {
|
|
7736
7833
|
if (info.source) {
|
|
7737
|
-
|
|
7834
|
+
const existingIndex = sourceIndexes.get(info.source);
|
|
7835
|
+
if (existingIndex !== void 0) {
|
|
7836
|
+
infos[existingIndex] = mergeCanonicalRowsInfo(
|
|
7837
|
+
infos[existingIndex],
|
|
7838
|
+
info
|
|
7839
|
+
);
|
|
7738
7840
|
continue;
|
|
7739
7841
|
}
|
|
7740
|
-
|
|
7842
|
+
sourceIndexes.set(info.source, infos.length);
|
|
7741
7843
|
}
|
|
7742
7844
|
infos.push(info);
|
|
7743
7845
|
}
|
|
@@ -8579,7 +8681,7 @@ async function handleDbQuery(args) {
|
|
|
8579
8681
|
const client2 = new DeeplineClient();
|
|
8580
8682
|
let result;
|
|
8581
8683
|
try {
|
|
8582
|
-
result = await client2.
|
|
8684
|
+
result = await client2.db.query({ sql, maxRows });
|
|
8583
8685
|
} catch (error) {
|
|
8584
8686
|
console.error(formatDbQueryError(sql, error));
|
|
8585
8687
|
return 1;
|
|
@@ -8791,7 +8893,13 @@ Examples:
|
|
|
8791
8893
|
deepline db repair
|
|
8792
8894
|
deepline db repair --json
|
|
8793
8895
|
`
|
|
8794
|
-
).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) => {
|
|
8795
8903
|
process.exitCode = await handleDbRepair([
|
|
8796
8904
|
...options.provider ? ["--provider", options.provider] : [],
|
|
8797
8905
|
...options.json ? ["--json"] : []
|
|
@@ -13729,9 +13837,15 @@ function actionToCommand(action) {
|
|
|
13729
13837
|
return null;
|
|
13730
13838
|
}
|
|
13731
13839
|
const record = action;
|
|
13840
|
+
if (typeof record.command === "string" && record.command.trim()) {
|
|
13841
|
+
return record.command.trim();
|
|
13842
|
+
}
|
|
13732
13843
|
if (record.kind === "deepline_run_inspect" && typeof record.runId === "string") {
|
|
13733
13844
|
return `deepline runs get ${record.runId} --json`;
|
|
13734
13845
|
}
|
|
13846
|
+
if (record.kind === "deepline_run_full" && typeof record.runId === "string") {
|
|
13847
|
+
return `deepline runs get ${record.runId} --full --json`;
|
|
13848
|
+
}
|
|
13735
13849
|
if (record.kind === "deepline_run_billing" && typeof record.runId === "string") {
|
|
13736
13850
|
return `deepline runs get ${record.runId} --full --json | jq '.billing'`;
|
|
13737
13851
|
}
|
|
@@ -13754,19 +13868,70 @@ function actionToCommand(action) {
|
|
|
13754
13868
|
}
|
|
13755
13869
|
return null;
|
|
13756
13870
|
}
|
|
13757
|
-
function
|
|
13758
|
-
|
|
13759
|
-
|
|
13760
|
-
|
|
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
|
+
}
|
|
13761
13894
|
}
|
|
13762
|
-
|
|
13763
|
-
|
|
13764
|
-
|
|
13765
|
-
|
|
13766
|
-
|
|
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
|
+
);
|
|
13767
13932
|
}
|
|
13768
13933
|
}
|
|
13769
|
-
return
|
|
13934
|
+
return lines;
|
|
13770
13935
|
}
|
|
13771
13936
|
function formatInlinePackageValue(value) {
|
|
13772
13937
|
const compacted = compactReturnValue(value);
|
|
@@ -13842,18 +14007,11 @@ function buildRunPackageTextLines(packaged) {
|
|
|
13842
14007
|
failedLogAssociation === "retained_before_truncation" ? ` retained logs: ${failedLogNext.logs}` : ` retry failed logs: ${failedLogNext.logs}`
|
|
13843
14008
|
);
|
|
13844
14009
|
}
|
|
13845
|
-
for (const output2 of readRecordArray(packaged.datasets)) {
|
|
13846
|
-
if (output2.recovered !== true) continue;
|
|
13847
|
-
const rowCount = typeof output2.rowCount === "number" ? formatInteger(output2.rowCount) : "persisted";
|
|
13848
|
-
const datasetPath = typeof output2.path === "string" ? output2.path : "dataset";
|
|
13849
|
-
lines.push(
|
|
13850
|
-
` dataset ${datasetPath}: available, ${rowCount} rows persisted; re-running reuses completed work`
|
|
13851
|
-
);
|
|
13852
|
-
}
|
|
13853
14010
|
if (playName) {
|
|
13854
14011
|
lines.push(` play: ${playName}`);
|
|
13855
14012
|
}
|
|
13856
14013
|
lines.push(...formatPackageValueOutputLines(packaged));
|
|
14014
|
+
lines.push(...formatPackageDatasetActionLines(packaged));
|
|
13857
14015
|
const next = packaged.next && typeof packaged.next === "object" && !Array.isArray(packaged.next) ? packaged.next : {};
|
|
13858
14016
|
const billingCommand = actionToCommand(next.billing);
|
|
13859
14017
|
const logsCommand = actionToCommand(next.logs);
|
|
@@ -13877,16 +14035,20 @@ function buildRunPackageTextLines(packaged) {
|
|
|
13877
14035
|
);
|
|
13878
14036
|
}
|
|
13879
14037
|
}
|
|
13880
|
-
const datasetActions = readFirstDatasetActions(packaged);
|
|
13881
14038
|
const inspectCommand = actionToCommand(next.inspect);
|
|
13882
|
-
const
|
|
13883
|
-
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);
|
|
13884
14044
|
const runAgainCommand = typeof next.run === "string" && next.run.trim() ? next.run.trim() : null;
|
|
13885
14045
|
if (inspectCommand) lines.push(` inspect: ${inspectCommand}`);
|
|
14046
|
+
if (fullResultCommand) lines.push(` full result: ${fullResultCommand}`);
|
|
13886
14047
|
if (logsCommand) lines.push(` logs: ${logsCommand}`);
|
|
13887
14048
|
if (billingCommand) lines.push(` billing: ${billingCommand}`);
|
|
13888
|
-
if (
|
|
13889
|
-
|
|
14049
|
+
if (legacyExportCommand) {
|
|
14050
|
+
lines.push(` export CSV: ${legacyExportCommand}`);
|
|
14051
|
+
}
|
|
13890
14052
|
if (runAgainCommand) {
|
|
13891
14053
|
lines.push(" run again (completed work is reused):");
|
|
13892
14054
|
lines.push(` ${runAgainCommand}`);
|
|
@@ -14186,6 +14348,102 @@ function resolveDatasetByName(available, datasetPath) {
|
|
|
14186
14348
|
}
|
|
14187
14349
|
return null;
|
|
14188
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
|
+
}
|
|
14189
14447
|
function assertDatasetHasExportableRows(input2) {
|
|
14190
14448
|
if (input2.rowsInfo.rows.length > 0) {
|
|
14191
14449
|
return input2.rowsInfo;
|
|
@@ -14206,28 +14464,93 @@ function assertDatasetHasExportableRows(input2) {
|
|
|
14206
14464
|
}
|
|
14207
14465
|
);
|
|
14208
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
|
+
}
|
|
14209
14484
|
async function exportPlayStatusRows(client2, status, outPath, options = {}) {
|
|
14210
14485
|
if (!outPath) {
|
|
14211
14486
|
return null;
|
|
14212
14487
|
}
|
|
14213
|
-
const availableRows =
|
|
14214
|
-
|
|
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;
|
|
14215
14497
|
if (!rowsInfo && options.datasetPath) {
|
|
14216
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
|
+
});
|
|
14217
14504
|
throw new DeeplineError(
|
|
14218
|
-
`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")}` : ""),
|
|
14219
14507
|
void 0,
|
|
14220
14508
|
"RUN_EXPORT_DATASET_NOT_FOUND",
|
|
14221
14509
|
{ runId: status.runId, dataset: options.datasetPath, available }
|
|
14222
14510
|
);
|
|
14223
14511
|
}
|
|
14224
|
-
if (!options.datasetPath &&
|
|
14225
|
-
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
|
+
});
|
|
14226
14519
|
throw new DeeplineError(
|
|
14227
|
-
`Run ${status.runId} returned multiple datasets. Choose one
|
|
14520
|
+
`Run ${status.runId} returned multiple datasets. Choose one:
|
|
14521
|
+
${commands.join("\n")}`,
|
|
14228
14522
|
void 0,
|
|
14229
14523
|
"RUN_EXPORT_DATASET_REQUIRED",
|
|
14230
|
-
{
|
|
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
|
+
}
|
|
14231
14554
|
);
|
|
14232
14555
|
}
|
|
14233
14556
|
if (!rowsInfo) {
|
|
@@ -14235,6 +14558,7 @@ async function exportPlayStatusRows(client2, status, outPath, options = {}) {
|
|
|
14235
14558
|
`Run ${status.runId} did not expose a row-shaped final output to export.`
|
|
14236
14559
|
);
|
|
14237
14560
|
}
|
|
14561
|
+
assertDatasetExportAvailable({ rowsInfo, status });
|
|
14238
14562
|
const attempts = Math.max(1, Math.trunc(options.attempts ?? 1));
|
|
14239
14563
|
const retryDelayMs = Math.max(0, Math.trunc(options.retryDelayMs ?? 0));
|
|
14240
14564
|
for (let attempt = 1; attempt <= attempts; attempt += 1) {
|
|
@@ -14246,6 +14570,9 @@ async function exportPlayStatusRows(client2, status, outPath, options = {}) {
|
|
|
14246
14570
|
rowsInfo
|
|
14247
14571
|
});
|
|
14248
14572
|
} catch (error) {
|
|
14573
|
+
if (error instanceof DeeplineError && error.code === "RUN_EXPORT_SCOPE_MISMATCH") {
|
|
14574
|
+
throw error;
|
|
14575
|
+
}
|
|
14249
14576
|
if (!rowsInfo.complete) {
|
|
14250
14577
|
throw error;
|
|
14251
14578
|
}
|
|
@@ -18749,7 +19076,7 @@ function helperSource() {
|
|
|
18749
19076
|
``,
|
|
18750
19077
|
`function __dlKeyPaths(key: string): string[] {`,
|
|
18751
19078
|
` const normalized = String(key || '').trim();`,
|
|
18752
|
-
` if (normalized === 'email') return ['email', 'email_address', 'person.email', 'contact.email', 'data.email', 'result.data.email'];`,
|
|
19079
|
+
` if (normalized === 'email') return ['email', 'email_address', 'person.email.email', 'data.person.email.email', 'result.person.email.email', 'result.data.person.email.email', 'person.email', 'contact.email', 'data.email', 'result.data.email'];`,
|
|
18753
19080
|
` if (normalized === 'personal_email') return ['personal_email', 'email', 'email_address', 'data.personal_email', 'data.email'];`,
|
|
18754
19081
|
` if (normalized === 'phone') return ['phone', 'phone_number', 'mobile_phone', 'mobile_phone_number', 'data.phone'];`,
|
|
18755
19082
|
` if (normalized === 'linkedin') return ['linkedin', 'linkedin_url', 'linkedin_profile', 'profile_url', 'person.linkedin', 'person.linkedin_url'];`,
|
|
@@ -18918,15 +19245,15 @@ function helperSource() {
|
|
|
18918
19245
|
` const raw = __dlRawToolOutput(result);`,
|
|
18919
19246
|
` if (!extractor) return raw;`,
|
|
18920
19247
|
` const pick = (paths: string[] | string) => {`,
|
|
18921
|
-
` const
|
|
18922
|
-
` for (const
|
|
18923
|
-
`
|
|
19248
|
+
` const requestedPaths = Array.isArray(paths) ? paths : [paths];`,
|
|
19249
|
+
` for (const requestedPath of requestedPaths) {`,
|
|
19250
|
+
` for (const path of __dlKeyPaths(String(requestedPath))) {`,
|
|
18924
19251
|
` const extractedValue = __dlExtractedValue(result, path);`,
|
|
18925
19252
|
` if (__dlMeaningful(extractedValue)) return extractedValue;`,
|
|
18926
|
-
`
|
|
18927
|
-
`
|
|
18928
|
-
`
|
|
18929
|
-
`
|
|
19253
|
+
` for (const candidate of __dlRawToolCandidates(raw)) {`,
|
|
19254
|
+
` const value = __dlGetByPath(candidate, path);`,
|
|
19255
|
+
` if (__dlMeaningful(value)) return value;`,
|
|
19256
|
+
` }`,
|
|
18930
19257
|
` }`,
|
|
18931
19258
|
` }`,
|
|
18932
19259
|
` return null;`,
|
|
@@ -20107,7 +20434,9 @@ function readFirstEnrichDatasetActions(value) {
|
|
|
20107
20434
|
}
|
|
20108
20435
|
const record = candidate;
|
|
20109
20436
|
const actions = isRecord7(record.actions) ? record.actions : null;
|
|
20110
|
-
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;
|
|
20111
20440
|
if (query?.kind === "deepline_db_query") {
|
|
20112
20441
|
return {
|
|
20113
20442
|
dataset: record,
|
|
@@ -20333,7 +20662,7 @@ async function collectCustomerDbFailureJobs(input2) {
|
|
|
20333
20662
|
for (let attempt = 0; attempt <= retryDelays.length; attempt += 1) {
|
|
20334
20663
|
try {
|
|
20335
20664
|
attempts = attempt + 1;
|
|
20336
|
-
result = await input2.client.
|
|
20665
|
+
result = await input2.client.db.query({
|
|
20337
20666
|
sql,
|
|
20338
20667
|
maxRows: 1e3
|
|
20339
20668
|
});
|