deepline 0.1.213 → 0.1.214
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundling-sources/sdk/src/client.ts +2 -2
- package/dist/bundling-sources/sdk/src/release.ts +2 -2
- package/dist/bundling-sources/sdk/src/types.ts +3 -3
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +67 -22
- package/dist/bundling-sources/shared_libs/play-runtime/providers.ts +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +2 -2
- package/dist/cli/index.js +50 -436
- package/dist/cli/index.mjs +50 -436
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/plays/bundle-play-file.mjs +1 -1
- package/package.json +1 -1
package/dist/cli/index.mjs
CHANGED
|
@@ -608,10 +608,10 @@ var SDK_RELEASE = {
|
|
|
608
608
|
// 0.1.154 removes the short-lived generated enrich StepOptions recompute
|
|
609
609
|
// fields shipped in 0.1.153.
|
|
610
610
|
// 0.1.175 ships loud `deepline enrich` empty-waterfall reporting.
|
|
611
|
-
version: "0.1.
|
|
611
|
+
version: "0.1.214",
|
|
612
612
|
apiContract: "2026-06-dataset-handle-results-hard-cutover",
|
|
613
613
|
supportPolicy: {
|
|
614
|
-
latest: "0.1.
|
|
614
|
+
latest: "0.1.214",
|
|
615
615
|
minimumSupported: "0.1.53",
|
|
616
616
|
deprecatedBelow: "0.1.53",
|
|
617
617
|
commandMinimumSupported: [
|
|
@@ -3032,8 +3032,8 @@ var DeeplineClient = class {
|
|
|
3032
3032
|
...forceToolRefresh ? { forceToolRefresh: true } : {},
|
|
3033
3033
|
...typeof request.waitForCompletionMs === "number" ? { waitForCompletionMs: request.waitForCompletionMs } : {},
|
|
3034
3034
|
// Profile selection is the API's job, not the CLI's. The server
|
|
3035
|
-
// defaults to
|
|
3036
|
-
//
|
|
3035
|
+
// defaults to absurd; callers that need workers_edge pass
|
|
3036
|
+
// `request.profile` explicitly.
|
|
3037
3037
|
...request.profile ? { profile: request.profile } : {},
|
|
3038
3038
|
...integrationMode ? { integrationMode } : {},
|
|
3039
3039
|
...testPolicyOverrides ? { testPolicyOverrides } : {}
|
|
@@ -10814,7 +10814,7 @@ var PLAY_RUNTIME_PROVIDERS = {
|
|
|
10814
10814
|
}
|
|
10815
10815
|
};
|
|
10816
10816
|
function defaultPlayRuntimeProvider() {
|
|
10817
|
-
return PLAY_RUNTIME_PROVIDERS.
|
|
10817
|
+
return PLAY_RUNTIME_PROVIDERS.absurd;
|
|
10818
10818
|
}
|
|
10819
10819
|
function resolvePlayRuntimeProvider(override) {
|
|
10820
10820
|
if (override?.trim()) {
|
|
@@ -14502,7 +14502,7 @@ function writeStartedPlayRun(input2) {
|
|
|
14502
14502
|
);
|
|
14503
14503
|
}
|
|
14504
14504
|
function parsePlayRunOptions(args) {
|
|
14505
|
-
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 '{...}'] [--profile <id>] [--no-wait] [--tail-timeout-ms 30000] [--force] [--full] [--<input> value]\n deepline plays run --name <name> [--input '{...}'] [--profile <id>] [--live|--latest|--revision-id <id>] [--no-wait] [--tail-timeout-ms 30000] [--force] [--no-open] [--json] [--full] [--<input> value]\n Production defaults to
|
|
14505
|
+
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 '{...}'] [--profile <id>] [--no-wait] [--tail-timeout-ms 30000] [--force] [--full] [--<input> value]\n deepline plays run --name <name> [--input '{...}'] [--profile <id>] [--live|--latest|--revision-id <id>] [--no-wait] [--tail-timeout-ms 30000] [--force] [--no-open] [--json] [--full] [--<input> value]\n Production defaults to absurd. Use --profile workers_edge only for an explicit Cloudflare run.\n Unknown --<input> value flags, such as --limit 5, are passed into play input.\nRun `deepline plays run --help` for idempotent call caching and ctx.dataset guidance.";
|
|
14506
14506
|
let filePath = null;
|
|
14507
14507
|
let playName = null;
|
|
14508
14508
|
let input2 = null;
|
|
@@ -15017,7 +15017,7 @@ async function handlePlayCheck(args) {
|
|
|
15017
15017
|
}
|
|
15018
15018
|
return enrichedResult.valid ? 0 : 1;
|
|
15019
15019
|
}
|
|
15020
|
-
async function handleFileBackedRun(options) {
|
|
15020
|
+
async function handleFileBackedRun(options, hooks) {
|
|
15021
15021
|
if (options.target.kind !== "file") {
|
|
15022
15022
|
throw new Error("Expected a file-backed play run target.");
|
|
15023
15023
|
}
|
|
@@ -15157,6 +15157,7 @@ async function handleFileBackedRun(options) {
|
|
|
15157
15157
|
),
|
|
15158
15158
|
options
|
|
15159
15159
|
);
|
|
15160
|
+
hooks?.onTerminalStatus?.(outputStatus);
|
|
15160
15161
|
traceCliSync(
|
|
15161
15162
|
"cli.play_write_result",
|
|
15162
15163
|
{ targetKind: "file", playName },
|
|
@@ -15206,7 +15207,7 @@ async function resolveNamedRunRevisionId(input2) {
|
|
|
15206
15207
|
}
|
|
15207
15208
|
return null;
|
|
15208
15209
|
}
|
|
15209
|
-
async function handleNamedRun(options) {
|
|
15210
|
+
async function handleNamedRun(options, hooks) {
|
|
15210
15211
|
if (options.target.kind !== "name") {
|
|
15211
15212
|
throw new Error("Expected a named play run target.");
|
|
15212
15213
|
}
|
|
@@ -15325,6 +15326,7 @@ async function handleNamedRun(options) {
|
|
|
15325
15326
|
options,
|
|
15326
15327
|
finalStatus.revisionId ?? selectedRevisionId
|
|
15327
15328
|
);
|
|
15329
|
+
hooks?.onTerminalStatus?.(outputStatus);
|
|
15328
15330
|
traceCliSync(
|
|
15329
15331
|
"cli.play_write_result",
|
|
15330
15332
|
{ targetKind: "name", playName },
|
|
@@ -15362,11 +15364,11 @@ async function handleNamedRun(options) {
|
|
|
15362
15364
|
});
|
|
15363
15365
|
return 0;
|
|
15364
15366
|
}
|
|
15365
|
-
async function handlePlayRun(args) {
|
|
15367
|
+
async function handlePlayRun(args, hooks) {
|
|
15366
15368
|
const options = parsePlayRunOptions(args);
|
|
15367
15369
|
if (options.target.kind === "file") {
|
|
15368
15370
|
if (isFileTarget(options.target.path)) {
|
|
15369
|
-
return handleFileBackedRun(options);
|
|
15371
|
+
return handleFileBackedRun(options, hooks);
|
|
15370
15372
|
}
|
|
15371
15373
|
const resolved = resolve8(options.target.path);
|
|
15372
15374
|
console.error(`File not found: ${resolved}`);
|
|
@@ -15388,7 +15390,7 @@ async function handlePlayRun(args) {
|
|
|
15388
15390
|
}
|
|
15389
15391
|
return 1;
|
|
15390
15392
|
}
|
|
15391
|
-
return handleNamedRun(options);
|
|
15393
|
+
return handleNamedRun(options, hooks);
|
|
15392
15394
|
}
|
|
15393
15395
|
function parseRunIdPositional(args, usage) {
|
|
15394
15396
|
for (let index = 0; index < args.length; index += 1) {
|
|
@@ -18815,9 +18817,6 @@ function helperSource() {
|
|
|
18815
18817
|
|
|
18816
18818
|
// src/cli/commands/enrich.ts
|
|
18817
18819
|
var ENRICH_EXPORT_PAGE_SIZE = 5e3;
|
|
18818
|
-
var ENRICH_AUTO_BATCH_ROWS = 200;
|
|
18819
|
-
var ENRICH_HEAVY_PLAY_AUTO_BATCH_ROWS = 25;
|
|
18820
|
-
var ENRICH_NESTED_PROVIDER_AUTO_BATCH_ROWS = 50;
|
|
18821
18820
|
var ENRICH_EXPORT_BACKING_ROWS_WAIT_MS = 6e4;
|
|
18822
18821
|
var ENRICH_EXPORT_BACKING_ROWS_POLL_MS = 1e3;
|
|
18823
18822
|
var ENRICH_CUSTOMER_DB_FAILURE_LOOKUP_RETRY_DELAYS_MS = [1e3, 3e3, 7e3];
|
|
@@ -18830,12 +18829,7 @@ var ENRICH_DEBUG_T0 = Date.now();
|
|
|
18830
18829
|
var GENERATED_ENRICH_ROWS_TABLE_NAMESPACE = "deepline_enrich_rows";
|
|
18831
18830
|
var SDK_ENRICH_TELEMETRY_TIMEOUT_MS = 1e4;
|
|
18832
18831
|
var SDK_ENRICH_TELEMETRY_COMMAND_MAX_LENGTH = 2e4;
|
|
18833
|
-
var
|
|
18834
|
-
"company-to-contact",
|
|
18835
|
-
"company-to-contact-by-role-waterfall",
|
|
18836
|
-
"company_to_contact_by_role_waterfall"
|
|
18837
|
-
]);
|
|
18838
|
-
var HEAVY_ENRICH_AUTO_BATCH_TOOLS = /* @__PURE__ */ new Set([
|
|
18832
|
+
var ENRICH_AI_RUNTIME_COMPACT_TOOLS = /* @__PURE__ */ new Set([
|
|
18839
18833
|
"ai_inference",
|
|
18840
18834
|
"aiinference",
|
|
18841
18835
|
"deeplineagent",
|
|
@@ -19662,9 +19656,18 @@ async function stopGeneratedEnrichRunAfterWatchError(client2, error) {
|
|
|
19662
19656
|
async function runGeneratedEnrichPlay(client2, runArgs, options = {}) {
|
|
19663
19657
|
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
19664
19658
|
try {
|
|
19665
|
-
|
|
19666
|
-
|
|
19667
|
-
|
|
19659
|
+
let terminalStatus2 = null;
|
|
19660
|
+
const captured2 = await captureStdout(
|
|
19661
|
+
() => handlePlayRun(runArgs, {
|
|
19662
|
+
onTerminalStatus: (status) => {
|
|
19663
|
+
terminalStatus2 = status;
|
|
19664
|
+
}
|
|
19665
|
+
}),
|
|
19666
|
+
{
|
|
19667
|
+
passthrough: options.passthroughStdout
|
|
19668
|
+
}
|
|
19669
|
+
);
|
|
19670
|
+
return { ...captured2, terminalStatus: terminalStatus2 };
|
|
19668
19671
|
} catch (error) {
|
|
19669
19672
|
await stopGeneratedEnrichRunAfterWatchError(client2, error);
|
|
19670
19673
|
if (attempt === 0 && isPlayStartStreamEndedError(error)) {
|
|
@@ -19674,9 +19677,16 @@ async function runGeneratedEnrichPlay(client2, runArgs, options = {}) {
|
|
|
19674
19677
|
throw error;
|
|
19675
19678
|
}
|
|
19676
19679
|
}
|
|
19677
|
-
|
|
19678
|
-
|
|
19679
|
-
|
|
19680
|
+
let terminalStatus = null;
|
|
19681
|
+
const captured = await captureStdout(
|
|
19682
|
+
() => handlePlayRun(runArgs, {
|
|
19683
|
+
onTerminalStatus: (status) => {
|
|
19684
|
+
terminalStatus = status;
|
|
19685
|
+
}
|
|
19686
|
+
}),
|
|
19687
|
+
{ passthrough: options.passthroughStdout }
|
|
19688
|
+
);
|
|
19689
|
+
return { ...captured, terminalStatus };
|
|
19680
19690
|
}
|
|
19681
19691
|
async function writeOutputCsv(outputPath, status, options) {
|
|
19682
19692
|
let rowsInfo = extractCanonicalRowsInfo(status);
|
|
@@ -19759,71 +19769,6 @@ function normalizeEnrichPlayRef(value) {
|
|
|
19759
19769
|
const normalized = value.trim().toLowerCase().replace(/^prebuilt\//, "");
|
|
19760
19770
|
return normalized || null;
|
|
19761
19771
|
}
|
|
19762
|
-
function configContainsHeavyEnrichPlay(config) {
|
|
19763
|
-
const visit = (commands) => {
|
|
19764
|
-
for (const command of commands) {
|
|
19765
|
-
if ("with_waterfall" in command) {
|
|
19766
|
-
if (visit(command.commands)) {
|
|
19767
|
-
return true;
|
|
19768
|
-
}
|
|
19769
|
-
continue;
|
|
19770
|
-
}
|
|
19771
|
-
if (command.disabled) {
|
|
19772
|
-
continue;
|
|
19773
|
-
}
|
|
19774
|
-
const candidates = [
|
|
19775
|
-
command.tool,
|
|
19776
|
-
command.operation,
|
|
19777
|
-
command.play?.ref,
|
|
19778
|
-
command.play?.ref?.replace(/^prebuilt\//, "")
|
|
19779
|
-
];
|
|
19780
|
-
if (candidates.map(normalizeEnrichPlayRef).some(
|
|
19781
|
-
(candidate) => candidate !== null && HEAVY_ENRICH_AUTO_BATCH_PLAYS.has(candidate)
|
|
19782
|
-
)) {
|
|
19783
|
-
return true;
|
|
19784
|
-
}
|
|
19785
|
-
const normalizedTool = normalizeEnrichPlayRef(command.tool);
|
|
19786
|
-
const normalizedOperation = normalizeEnrichPlayRef(command.operation);
|
|
19787
|
-
if (isMarkedTestAiInferenceCommand(command) || normalizedTool && HEAVY_ENRICH_AUTO_BATCH_TOOLS.has(normalizedTool) || normalizedOperation && HEAVY_ENRICH_AUTO_BATCH_TOOLS.has(normalizedOperation)) {
|
|
19788
|
-
return true;
|
|
19789
|
-
}
|
|
19790
|
-
}
|
|
19791
|
-
return false;
|
|
19792
|
-
};
|
|
19793
|
-
return visit(config.commands);
|
|
19794
|
-
}
|
|
19795
|
-
function configContainsNestedProviderEnrichWorkload(config) {
|
|
19796
|
-
let hasNestedPlayStep = false;
|
|
19797
|
-
let hasSubrequestProviderStep = false;
|
|
19798
|
-
const visit = (commands) => {
|
|
19799
|
-
for (const command of commands) {
|
|
19800
|
-
if ("with_waterfall" in command) {
|
|
19801
|
-
visit(command.commands);
|
|
19802
|
-
continue;
|
|
19803
|
-
}
|
|
19804
|
-
if (command.disabled) {
|
|
19805
|
-
continue;
|
|
19806
|
-
}
|
|
19807
|
-
const normalizedTool = normalizeEnrichPlayRef(command.tool);
|
|
19808
|
-
if (command.play || normalizedTool === "test-play") {
|
|
19809
|
-
hasNestedPlayStep = true;
|
|
19810
|
-
} else if (normalizedTool !== null && normalizedTool !== "run_javascript") {
|
|
19811
|
-
hasSubrequestProviderStep = true;
|
|
19812
|
-
}
|
|
19813
|
-
}
|
|
19814
|
-
};
|
|
19815
|
-
visit(config.commands);
|
|
19816
|
-
return hasNestedPlayStep && hasSubrequestProviderStep;
|
|
19817
|
-
}
|
|
19818
|
-
function enrichAutoBatchRowsForConfig(config) {
|
|
19819
|
-
if (configContainsHeavyEnrichPlay(config)) {
|
|
19820
|
-
return ENRICH_HEAVY_PLAY_AUTO_BATCH_ROWS;
|
|
19821
|
-
}
|
|
19822
|
-
if (configContainsNestedProviderEnrichWorkload(config)) {
|
|
19823
|
-
return ENRICH_NESTED_PROVIDER_AUTO_BATCH_ROWS;
|
|
19824
|
-
}
|
|
19825
|
-
return ENRICH_AUTO_BATCH_ROWS;
|
|
19826
|
-
}
|
|
19827
19772
|
function enrichAiRuntimeCompactAliases(config) {
|
|
19828
19773
|
const aliases = /* @__PURE__ */ new Set();
|
|
19829
19774
|
const visit = (commands) => {
|
|
@@ -19837,7 +19782,7 @@ function enrichAiRuntimeCompactAliases(config) {
|
|
|
19837
19782
|
}
|
|
19838
19783
|
const normalizedTool = normalizeEnrichPlayRef(command.tool);
|
|
19839
19784
|
const normalizedOperation = normalizeEnrichPlayRef(command.operation);
|
|
19840
|
-
if (isMarkedTestAiInferenceCommand(command) || normalizedTool &&
|
|
19785
|
+
if (isMarkedTestAiInferenceCommand(command) || normalizedTool && ENRICH_AI_RUNTIME_COMPACT_TOOLS.has(normalizedTool) || normalizedOperation && ENRICH_AI_RUNTIME_COMPACT_TOOLS.has(normalizedOperation)) {
|
|
19841
19786
|
aliases.add(normalizeAlias2(command.alias));
|
|
19842
19787
|
}
|
|
19843
19788
|
}
|
|
@@ -19848,13 +19793,14 @@ function enrichAiRuntimeCompactAliases(config) {
|
|
|
19848
19793
|
async function maybeWriteOutputCsv(input2) {
|
|
19849
19794
|
if (!input2.outputPath) return null;
|
|
19850
19795
|
try {
|
|
19796
|
+
const terminalStatus = readEnrichRunStatus(input2.status);
|
|
19851
19797
|
return await writeOutputCsv(input2.outputPath, input2.status, {
|
|
19852
19798
|
client: input2.client,
|
|
19853
19799
|
config: input2.config,
|
|
19854
19800
|
sourceCsvPath: input2.sourceCsvPath,
|
|
19855
19801
|
rows: input2.rows,
|
|
19856
19802
|
inPlace: input2.inPlace,
|
|
19857
|
-
allowPartial: input2.capturedResult !== 0
|
|
19803
|
+
allowPartial: input2.capturedResult !== 0 || terminalStatus === "failed" || terminalStatus === "cancelled" || hasFailedRowSignal(input2.status)
|
|
19858
19804
|
});
|
|
19859
19805
|
} catch (error) {
|
|
19860
19806
|
if (input2.capturedResult !== 0 && isMissingRowsForCsvExportError(error)) {
|
|
@@ -20247,55 +20193,14 @@ function selectedSourceCsvRange(sourceCsvPath, rows) {
|
|
|
20247
20193
|
sourceRows
|
|
20248
20194
|
};
|
|
20249
20195
|
}
|
|
20250
|
-
function compactRuntimeCsvCell(value) {
|
|
20251
|
-
const parsed = parseMaybeJsonObject(value);
|
|
20252
|
-
const compacted = compactAiInferenceCellForCsv(parsed);
|
|
20253
|
-
return materializeCsvCellValue(compacted);
|
|
20254
|
-
}
|
|
20255
|
-
async function writeSlimBatchedRuntimeCsv(input2) {
|
|
20256
|
-
const cleanRows = readCsvRows(input2.cleanSourceCsvPath).map(
|
|
20257
|
-
(row) => ({ ...row })
|
|
20258
|
-
);
|
|
20259
|
-
const mergeRows = readCsvRows(input2.mergeSourceCsvPath);
|
|
20260
|
-
const preserveJsonStringColumns = /* @__PURE__ */ new Set([
|
|
20261
|
-
...cleanRows.flatMap((row) => Object.keys(row)),
|
|
20262
|
-
...mergeRows.flatMap((row) => Object.keys(row))
|
|
20263
|
-
]);
|
|
20264
|
-
const selectedRange = selectedSourceCsvRange(
|
|
20265
|
-
input2.mergeSourceCsvPath,
|
|
20266
|
-
input2.rows
|
|
20267
|
-
);
|
|
20268
|
-
for (let rowIndex = selectedRange.start; rowIndex <= selectedRange.end; rowIndex += 1) {
|
|
20269
|
-
const mergeRow = mergeRows[rowIndex];
|
|
20270
|
-
if (!mergeRow) {
|
|
20271
|
-
continue;
|
|
20272
|
-
}
|
|
20273
|
-
const baseRow = cleanRows[rowIndex] ?? {};
|
|
20274
|
-
const compactOverlayCell = ([key, value]) => {
|
|
20275
|
-
return [
|
|
20276
|
-
key,
|
|
20277
|
-
input2.compactAliases.has(normalizeAlias2(key)) ? compactRuntimeCsvCell(value) : value
|
|
20278
|
-
];
|
|
20279
|
-
};
|
|
20280
|
-
cleanRows[rowIndex] = {
|
|
20281
|
-
...baseRow,
|
|
20282
|
-
...Object.fromEntries(Object.entries(mergeRow).map(compactOverlayCell))
|
|
20283
|
-
};
|
|
20284
|
-
}
|
|
20285
|
-
const columns = dataExportColumns(
|
|
20286
|
-
dataExportRows(cleanRows, { preserveJsonStringColumns })
|
|
20287
|
-
);
|
|
20288
|
-
await writeFile3(
|
|
20289
|
-
input2.outputPath,
|
|
20290
|
-
csvStringFromRows(cleanRows, columns),
|
|
20291
|
-
"utf8"
|
|
20292
|
-
);
|
|
20293
|
-
}
|
|
20294
20196
|
function selectedSourceCsvRowCount(options) {
|
|
20295
20197
|
if (!options?.sourceCsvPath) {
|
|
20296
20198
|
return null;
|
|
20297
20199
|
}
|
|
20298
|
-
|
|
20200
|
+
const totalRows = readCsvRows(options.sourceCsvPath).length;
|
|
20201
|
+
const start = Math.max(0, options.rows?.rowStart ?? 0);
|
|
20202
|
+
const end = options.rows?.rowEnd === null || options.rows?.rowEnd === void 0 ? totalRows - 1 : Math.min(totalRows - 1, options.rows.rowEnd);
|
|
20203
|
+
return Math.max(0, end - start + 1);
|
|
20299
20204
|
}
|
|
20300
20205
|
function collectStringFields(value, key, output2, depth = 0) {
|
|
20301
20206
|
if (depth > 12 || !value || typeof value !== "object") {
|
|
@@ -20476,13 +20381,9 @@ function firstCollectedStringField(value, key) {
|
|
|
20476
20381
|
collectStringFields(value, key, fields);
|
|
20477
20382
|
return fields.values().next().value ?? null;
|
|
20478
20383
|
}
|
|
20479
|
-
function
|
|
20480
|
-
|
|
20481
|
-
|
|
20482
|
-
`
|
|
20483
|
-
);
|
|
20484
|
-
const runId = extractRunId(input2.status) ?? firstCollectedStringField(input2.status, "runId");
|
|
20485
|
-
const error = firstCollectedStringField(input2.status, "error") ?? firstCollectedStringField(input2.status, "message");
|
|
20384
|
+
function emitPlainRunFailure(status) {
|
|
20385
|
+
const runId = extractRunId(status) ?? firstCollectedStringField(status, "runId");
|
|
20386
|
+
const error = firstCollectedStringField(status, "error") ?? firstCollectedStringField(status, "message");
|
|
20486
20387
|
if (runId) {
|
|
20487
20388
|
process.stderr.write(`Run id: ${runId}
|
|
20488
20389
|
`);
|
|
@@ -20613,22 +20514,6 @@ function mergeExportedSheetRow(target, next) {
|
|
|
20613
20514
|
target._metadata = metadata;
|
|
20614
20515
|
}
|
|
20615
20516
|
}
|
|
20616
|
-
function countEnrichedRowsInSourceRange(exportResult, rows) {
|
|
20617
|
-
const start = Math.max(0, rows.rowStart ?? 0);
|
|
20618
|
-
const end = rows.rowEnd === null || rows.rowEnd === void 0 ? Number.MAX_SAFE_INTEGER : Math.max(start, rows.rowEnd);
|
|
20619
|
-
const rowIndexes = /* @__PURE__ */ new Set();
|
|
20620
|
-
for (const row of exportResult.enrichedDataRows) {
|
|
20621
|
-
const rowIndex = sourceRowIndexFromEnrichRow(row, start, end);
|
|
20622
|
-
if (rowIndex !== null) {
|
|
20623
|
-
rowIndexes.add(rowIndex);
|
|
20624
|
-
}
|
|
20625
|
-
}
|
|
20626
|
-
if (rowIndexes.size > 0) {
|
|
20627
|
-
return rowIndexes.size;
|
|
20628
|
-
}
|
|
20629
|
-
const selectedRows = end === Number.MAX_SAFE_INTEGER ? exportResult.enrichedRows : end - start + 1;
|
|
20630
|
-
return Math.min(exportResult.enrichedRows, Math.max(0, selectedRows));
|
|
20631
|
-
}
|
|
20632
20517
|
function coalesceExportableSheetRows(rows, sourceRowStart = 0) {
|
|
20633
20518
|
const mergedRows = [];
|
|
20634
20519
|
const bySourceRowIndex = /* @__PURE__ */ new Map();
|
|
@@ -21454,12 +21339,6 @@ function sidecarEnrichRowsExportPath(outputPath) {
|
|
|
21454
21339
|
const stem = basename2(resolved, ext);
|
|
21455
21340
|
return join7(dirname7(resolved), `${stem}.deepline-enrich-rows${ext}`);
|
|
21456
21341
|
}
|
|
21457
|
-
function sidecarEnrichBatchManifestPath(outputPath) {
|
|
21458
|
-
const resolved = resolve9(outputPath);
|
|
21459
|
-
const ext = extname(resolved) || ".csv";
|
|
21460
|
-
const stem = basename2(resolved, ext);
|
|
21461
|
-
return join7(dirname7(resolved), `${stem}.deepline-enrich-batches.json`);
|
|
21462
|
-
}
|
|
21463
21342
|
function collectDatasetFollowUpCommands(value, state) {
|
|
21464
21343
|
if (state.depth > 12 || !value || typeof value !== "object" || state.commands.length >= 8) {
|
|
21465
21344
|
return;
|
|
@@ -22516,7 +22395,7 @@ function registerEnrichCommand(program) {
|
|
|
22516
22395
|
const captured2 = await runGeneratedEnrichPlay(client2, runArgs, {
|
|
22517
22396
|
passthroughStdout: input2.passthroughStdout
|
|
22518
22397
|
});
|
|
22519
|
-
const generatedPlayStatus = input2.json ? parseJsonOutput(captured2.stdout) : await resolveWatchedGeneratedPlayStatus({
|
|
22398
|
+
const generatedPlayStatus = input2.json ? parseJsonOutput(captured2.stdout) : captured2.terminalStatus ?? await resolveWatchedGeneratedPlayStatus({
|
|
22520
22399
|
client: client2,
|
|
22521
22400
|
stdout: captured2.stdout,
|
|
22522
22401
|
exitCode: captured2.result
|
|
@@ -22537,274 +22416,6 @@ function registerEnrichCommand(program) {
|
|
|
22537
22416
|
});
|
|
22538
22417
|
return { captured: captured2, status: status2, exportResult: exportResult2 };
|
|
22539
22418
|
};
|
|
22540
|
-
const autoBatchRows = enrichAutoBatchRowsForConfig(config);
|
|
22541
|
-
if (outputPath && selectedRange.count > autoBatchRows) {
|
|
22542
|
-
const chunkCount = Math.ceil(selectedRange.count / autoBatchRows);
|
|
22543
|
-
const batchManifestPath = sidecarEnrichBatchManifestPath(
|
|
22544
|
-
inPlaceFinalOutputPath ?? resolve9(outputPath)
|
|
22545
|
-
);
|
|
22546
|
-
const batchManifest = {
|
|
22547
|
-
version: 1,
|
|
22548
|
-
kind: "deepline_enrich_batch_manifest",
|
|
22549
|
-
input: resolve9(inputCsv),
|
|
22550
|
-
output: inPlaceFinalOutputPath ?? resolve9(outputPath),
|
|
22551
|
-
selectedRows: selectedRange.count,
|
|
22552
|
-
sourceCsvRows: selectedRange.sourceRows,
|
|
22553
|
-
chunkRows: autoBatchRows,
|
|
22554
|
-
chunks: chunkCount,
|
|
22555
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
22556
|
-
batches: []
|
|
22557
|
-
};
|
|
22558
|
-
const writeBatchManifest = async () => {
|
|
22559
|
-
batchManifest.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
22560
|
-
await writeFile3(
|
|
22561
|
-
batchManifestPath,
|
|
22562
|
-
`${JSON.stringify(batchManifest, null, 2)}
|
|
22563
|
-
`,
|
|
22564
|
-
"utf8"
|
|
22565
|
-
);
|
|
22566
|
-
};
|
|
22567
|
-
const appendBatchManifestEntry = async (input2) => {
|
|
22568
|
-
const runId = extractRunId(input2.status) ?? firstCollectedStringField(input2.status, "runId");
|
|
22569
|
-
batchManifest.batches.push({
|
|
22570
|
-
chunk: input2.chunkIndex + 1,
|
|
22571
|
-
chunks: chunkCount,
|
|
22572
|
-
rows: {
|
|
22573
|
-
rowStart: input2.rows.rowStart,
|
|
22574
|
-
rowEnd: input2.rows.rowEnd
|
|
22575
|
-
},
|
|
22576
|
-
status: readEnrichRunStatus(input2.status),
|
|
22577
|
-
runId,
|
|
22578
|
-
customer_db: enrichCustomerDbJson({
|
|
22579
|
-
status: input2.status,
|
|
22580
|
-
client: client2,
|
|
22581
|
-
outputPath: enrichIssueFollowUpOutputPath ?? input2.exportResult?.path ?? outputPath
|
|
22582
|
-
}),
|
|
22583
|
-
output: enrichOutputJson(input2.exportResult),
|
|
22584
|
-
completedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
22585
|
-
});
|
|
22586
|
-
await writeBatchManifest();
|
|
22587
|
-
};
|
|
22588
|
-
await writeBatchManifest();
|
|
22589
|
-
if (!options.json) {
|
|
22590
|
-
process.stderr.write(
|
|
22591
|
-
`Large enrich input selected ${selectedRange.count.toLocaleString()} rows. Running ${chunkCount.toLocaleString()} sequential batch runs of up to ${autoBatchRows.toLocaleString()} rows and merging ${resolve9(outputPath)}.
|
|
22592
|
-
`
|
|
22593
|
-
);
|
|
22594
|
-
}
|
|
22595
|
-
process.stderr.write(
|
|
22596
|
-
`Batch recovery manifest: ${batchManifestPath}
|
|
22597
|
-
`
|
|
22598
|
-
);
|
|
22599
|
-
let workingMergeSourceCsvPath = sourceCsvPath;
|
|
22600
|
-
let lastStatus = null;
|
|
22601
|
-
const batchStatuses = [];
|
|
22602
|
-
let finalExportResult = null;
|
|
22603
|
-
let totalEnrichedRows = 0;
|
|
22604
|
-
const batchFailureRows = [];
|
|
22605
|
-
const runtimeCompactAliases = enrichAiRuntimeCompactAliases(config);
|
|
22606
|
-
for (let chunkStart = selectedRange.start, chunkIndex = 0; chunkStart <= selectedRange.end; chunkStart += autoBatchRows, chunkIndex += 1) {
|
|
22607
|
-
const chunkRows = {
|
|
22608
|
-
rowStart: chunkStart,
|
|
22609
|
-
rowEnd: Math.min(
|
|
22610
|
-
selectedRange.end,
|
|
22611
|
-
chunkStart + autoBatchRows - 1
|
|
22612
|
-
)
|
|
22613
|
-
};
|
|
22614
|
-
if (!options.json) {
|
|
22615
|
-
process.stderr.write(
|
|
22616
|
-
`Batch ${chunkIndex + 1}/${chunkCount}: rows ${chunkRows.rowStart}:${chunkRows.rowEnd}
|
|
22617
|
-
`
|
|
22618
|
-
);
|
|
22619
|
-
}
|
|
22620
|
-
const runtimeSourceCsvPath = options.inPlace ? sourceCsvPath : workingMergeSourceCsvPath === inputCsv ? inputCsv : join7(tempDir, `runtime-batch-${chunkIndex}.csv`);
|
|
22621
|
-
if (!options.inPlace && runtimeSourceCsvPath !== inputCsv) {
|
|
22622
|
-
await writeSlimBatchedRuntimeCsv({
|
|
22623
|
-
cleanSourceCsvPath: inputCsv,
|
|
22624
|
-
mergeSourceCsvPath: workingMergeSourceCsvPath,
|
|
22625
|
-
rows: chunkRows,
|
|
22626
|
-
compactAliases: runtimeCompactAliases,
|
|
22627
|
-
outputPath: runtimeSourceCsvPath
|
|
22628
|
-
});
|
|
22629
|
-
}
|
|
22630
|
-
const chunk = await runOne({
|
|
22631
|
-
sourceCsvPath: runtimeSourceCsvPath,
|
|
22632
|
-
mergeSourceCsvPath: workingMergeSourceCsvPath,
|
|
22633
|
-
rows: chunkRows,
|
|
22634
|
-
json: true,
|
|
22635
|
-
passthroughStdout: false,
|
|
22636
|
-
suppressOpen: true
|
|
22637
|
-
});
|
|
22638
|
-
lastStatus = chunk.status;
|
|
22639
|
-
batchStatuses.push(chunk.status);
|
|
22640
|
-
if (chunk.captured.result !== 0) {
|
|
22641
|
-
let currentChunkCommittedExportResult = null;
|
|
22642
|
-
if (chunk.exportResult) {
|
|
22643
|
-
finalExportResult = chunk.exportResult;
|
|
22644
|
-
totalEnrichedRows += countEnrichedRowsInSourceRange(
|
|
22645
|
-
chunk.exportResult,
|
|
22646
|
-
chunkRows
|
|
22647
|
-
);
|
|
22648
|
-
batchFailureRows.push(...chunk.exportResult.enrichedDataRows);
|
|
22649
|
-
}
|
|
22650
|
-
const failureReport3 = await maybeEmitEnrichFailureReport({
|
|
22651
|
-
config,
|
|
22652
|
-
rows: batchFailureRows,
|
|
22653
|
-
rowRange: {
|
|
22654
|
-
rowStart: selectedRange.start,
|
|
22655
|
-
rowEnd: selectedRange.end
|
|
22656
|
-
},
|
|
22657
|
-
statusRowRange: chunkRows,
|
|
22658
|
-
client: client2,
|
|
22659
|
-
outputPath: failureReportOutputPath ?? finalExportResult?.path ?? outputPath,
|
|
22660
|
-
followUpOutputPath: enrichIssueFollowUpOutputPath,
|
|
22661
|
-
status: chunk.status,
|
|
22662
|
-
waterfallStatus: batchStatuses,
|
|
22663
|
-
...finalExportResult ? { rowSetComplete: !finalExportResult.partial } : {}
|
|
22664
|
-
});
|
|
22665
|
-
if (chunk.exportResult) {
|
|
22666
|
-
currentChunkCommittedExportResult = await commitInPlaceOutput(
|
|
22667
|
-
chunk.exportResult
|
|
22668
|
-
);
|
|
22669
|
-
finalExportResult = currentChunkCommittedExportResult;
|
|
22670
|
-
}
|
|
22671
|
-
const reportedExportResult = currentChunkCommittedExportResult ?? finalExportResult;
|
|
22672
|
-
await appendBatchManifestEntry({
|
|
22673
|
-
chunkIndex,
|
|
22674
|
-
rows: chunkRows,
|
|
22675
|
-
status: chunk.status,
|
|
22676
|
-
exportResult: currentChunkCommittedExportResult
|
|
22677
|
-
});
|
|
22678
|
-
if (options.json) {
|
|
22679
|
-
printJson({
|
|
22680
|
-
ok: false,
|
|
22681
|
-
batch: {
|
|
22682
|
-
chunk: chunkIndex + 1,
|
|
22683
|
-
chunks: chunkCount,
|
|
22684
|
-
rows: chunkRows,
|
|
22685
|
-
manifest: batchManifestPath
|
|
22686
|
-
},
|
|
22687
|
-
result: chunk.status,
|
|
22688
|
-
output: reportedExportResult ? {
|
|
22689
|
-
sourceCsvRows: selectedRange.sourceRows,
|
|
22690
|
-
selectedRows: selectedRange.count,
|
|
22691
|
-
enrichedRows: totalEnrichedRows,
|
|
22692
|
-
path: reportedExportResult.path,
|
|
22693
|
-
...reportedExportResult.partial ? {
|
|
22694
|
-
rows: reportedExportResult.rows,
|
|
22695
|
-
partial: true
|
|
22696
|
-
} : {}
|
|
22697
|
-
} : null,
|
|
22698
|
-
customer_db: enrichCustomerDbJson({
|
|
22699
|
-
status: chunk.status,
|
|
22700
|
-
client: client2,
|
|
22701
|
-
outputPath: enrichIssueFollowUpOutputPath ?? reportedExportResult?.path ?? outputPath
|
|
22702
|
-
}),
|
|
22703
|
-
...enrichReportJson(failureReport3)
|
|
22704
|
-
});
|
|
22705
|
-
} else {
|
|
22706
|
-
if (reportedExportResult) {
|
|
22707
|
-
process.stderr.write(
|
|
22708
|
-
`Wrote ${reportedExportResult.rows} row(s) to ${reportedExportResult.path}${reportedExportResult.partial ? " (partial run output)" : ""}
|
|
22709
|
-
`
|
|
22710
|
-
);
|
|
22711
|
-
}
|
|
22712
|
-
emitPlainBatchRunFailure({
|
|
22713
|
-
chunkIndex,
|
|
22714
|
-
chunkCount,
|
|
22715
|
-
rows: chunkRows,
|
|
22716
|
-
status: chunk.status
|
|
22717
|
-
});
|
|
22718
|
-
}
|
|
22719
|
-
process.exitCode = failureReport3 ? EXIT_SERVER2 : chunk.captured.result;
|
|
22720
|
-
await completeTelemetry({
|
|
22721
|
-
status: "failed",
|
|
22722
|
-
failedJobs: failureReport3?.jobs.length ?? 1
|
|
22723
|
-
});
|
|
22724
|
-
return;
|
|
22725
|
-
}
|
|
22726
|
-
if (chunk.exportResult) {
|
|
22727
|
-
totalEnrichedRows += countEnrichedRowsInSourceRange(
|
|
22728
|
-
chunk.exportResult,
|
|
22729
|
-
chunkRows
|
|
22730
|
-
);
|
|
22731
|
-
batchFailureRows.push(...chunk.exportResult.enrichedDataRows);
|
|
22732
|
-
finalExportResult = options.inPlace ? await commitInPlaceOutput(chunk.exportResult) : chunk.exportResult;
|
|
22733
|
-
await appendBatchManifestEntry({
|
|
22734
|
-
chunkIndex,
|
|
22735
|
-
rows: chunkRows,
|
|
22736
|
-
status: chunk.status,
|
|
22737
|
-
exportResult: finalExportResult
|
|
22738
|
-
});
|
|
22739
|
-
workingMergeSourceCsvPath = outputPath;
|
|
22740
|
-
if (options.inPlace && (chunkRows.rowEnd ?? selectedRange.end) < selectedRange.end) {
|
|
22741
|
-
await prepareInPlaceOutput();
|
|
22742
|
-
}
|
|
22743
|
-
}
|
|
22744
|
-
}
|
|
22745
|
-
const outputRows = readCsvRows(outputPath);
|
|
22746
|
-
const failureReport2 = await maybeEmitEnrichFailureReport({
|
|
22747
|
-
config,
|
|
22748
|
-
rows: batchFailureRows,
|
|
22749
|
-
rowRange: {
|
|
22750
|
-
rowStart: selectedRange.start,
|
|
22751
|
-
rowEnd: selectedRange.end
|
|
22752
|
-
},
|
|
22753
|
-
client: client2,
|
|
22754
|
-
outputPath: failureReportOutputPath ?? finalExportResult?.path ?? outputPath,
|
|
22755
|
-
followUpOutputPath: enrichIssueFollowUpOutputPath,
|
|
22756
|
-
status: lastStatus,
|
|
22757
|
-
waterfallStatus: batchStatuses,
|
|
22758
|
-
...finalExportResult ? { rowSetComplete: !finalExportResult.partial } : {}
|
|
22759
|
-
});
|
|
22760
|
-
finalExportResult = await commitInPlaceOutput(finalExportResult);
|
|
22761
|
-
if (options.json) {
|
|
22762
|
-
const run = rewriteEnrichJsonStatus({
|
|
22763
|
-
status: lastStatus,
|
|
22764
|
-
config,
|
|
22765
|
-
forceAliases,
|
|
22766
|
-
output: finalExportResult ? {
|
|
22767
|
-
...finalExportResult,
|
|
22768
|
-
sourceCsvRows: selectedRange.sourceRows,
|
|
22769
|
-
selectedRows: selectedRange.count,
|
|
22770
|
-
enrichedRows: totalEnrichedRows,
|
|
22771
|
-
rows: outputRows.length,
|
|
22772
|
-
enrichedDataRows: outputRows
|
|
22773
|
-
} : null,
|
|
22774
|
-
failureReport: failureReport2
|
|
22775
|
-
});
|
|
22776
|
-
printJson({
|
|
22777
|
-
ok: !failureReport2,
|
|
22778
|
-
run,
|
|
22779
|
-
batch: {
|
|
22780
|
-
chunks: chunkCount,
|
|
22781
|
-
chunkRows: autoBatchRows,
|
|
22782
|
-
selectedRows: selectedRange.count,
|
|
22783
|
-
manifest: batchManifestPath
|
|
22784
|
-
},
|
|
22785
|
-
output: finalExportResult ? {
|
|
22786
|
-
sourceCsvRows: selectedRange.sourceRows,
|
|
22787
|
-
selectedRows: selectedRange.count,
|
|
22788
|
-
enrichedRows: totalEnrichedRows,
|
|
22789
|
-
path: finalExportResult.path
|
|
22790
|
-
} : null,
|
|
22791
|
-
customer_db: enrichCustomerDbJson({
|
|
22792
|
-
status: lastStatus,
|
|
22793
|
-
client: client2,
|
|
22794
|
-
outputPath: enrichIssueFollowUpOutputPath ?? finalExportResult?.path ?? outputPath
|
|
22795
|
-
}),
|
|
22796
|
-
...enrichReportJson(failureReport2)
|
|
22797
|
-
});
|
|
22798
|
-
}
|
|
22799
|
-
if (failureReport2) {
|
|
22800
|
-
process.exitCode = EXIT_SERVER2;
|
|
22801
|
-
}
|
|
22802
|
-
await completeTelemetry({
|
|
22803
|
-
status: failureReport2 ? "completed_with_failures" : "completed",
|
|
22804
|
-
failedJobs: failureReport2?.jobs.length ?? 0
|
|
22805
|
-
});
|
|
22806
|
-
return;
|
|
22807
|
-
}
|
|
22808
22419
|
const { captured, status, exportResult } = await runOne({
|
|
22809
22420
|
sourceCsvPath,
|
|
22810
22421
|
rows,
|
|
@@ -22820,6 +22431,9 @@ function registerEnrichCommand(program) {
|
|
|
22820
22431
|
`
|
|
22821
22432
|
);
|
|
22822
22433
|
}
|
|
22434
|
+
if (!options.json) {
|
|
22435
|
+
emitPlainRunFailure(status);
|
|
22436
|
+
}
|
|
22823
22437
|
const failureReport2 = await buildEnrichFailureReport({
|
|
22824
22438
|
config,
|
|
22825
22439
|
rows: rowsForFailureReport,
|
package/dist/index.d.mts
CHANGED
|
@@ -1085,9 +1085,9 @@ interface StartPlayRunRequest {
|
|
|
1085
1085
|
/** Optionally let the start request wait briefly and return a terminal result. */
|
|
1086
1086
|
waitForCompletionMs?: number;
|
|
1087
1087
|
/**
|
|
1088
|
-
* Per-run execution profile override. The server defaults to
|
|
1089
|
-
*
|
|
1090
|
-
*
|
|
1088
|
+
* Per-run execution profile override. The server defaults to absurd;
|
|
1089
|
+
* callers that need workers_edge can pass it here. Most callers should leave
|
|
1090
|
+
* this unset.
|
|
1091
1091
|
*/
|
|
1092
1092
|
profile?: string;
|
|
1093
1093
|
/** Optional per-run provider execution mode for eval/smoke runs. */
|