deepline 0.1.110 → 0.1.112
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +476 -314
- package/dist/cli/index.mjs +383 -220
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/dist/repo/apps/play-runner-workers/src/coordinator-entry.ts +179 -130
- package/dist/repo/apps/play-runner-workers/src/entry.ts +119 -20
- package/dist/repo/sdk/src/release.ts +2 -2
- package/dist/repo/shared_libs/play-runtime/run-ledger.ts +40 -14
- package/dist/repo/shared_libs/play-runtime/scheduler-backend.ts +2 -0
- package/dist/repo/shared_libs/plays/bundling/index.ts +124 -10
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -182,8 +182,8 @@ configureProxyFromEnv();
|
|
|
182
182
|
|
|
183
183
|
// src/cli/index.ts
|
|
184
184
|
var import_promises7 = require("fs/promises");
|
|
185
|
-
var
|
|
186
|
-
var
|
|
185
|
+
var import_node_path22 = require("path");
|
|
186
|
+
var import_node_os15 = require("os");
|
|
187
187
|
var import_commander3 = require("commander");
|
|
188
188
|
|
|
189
189
|
// src/config.ts
|
|
@@ -403,10 +403,10 @@ var SDK_RELEASE = {
|
|
|
403
403
|
// skill on the sdk sync surface, and the people-search-to-email prebuilt.
|
|
404
404
|
// 0.1.108 ships explicit dataset column/tool recompute policy and removes
|
|
405
405
|
// the SDK enrich generator's one-second stale policy.
|
|
406
|
-
version: "0.1.
|
|
406
|
+
version: "0.1.112",
|
|
407
407
|
apiContract: "2026-06-dataset-column-cell-stale-hard-cutover",
|
|
408
408
|
supportPolicy: {
|
|
409
|
-
latest: "0.1.
|
|
409
|
+
latest: "0.1.112",
|
|
410
410
|
minimumSupported: "0.1.53",
|
|
411
411
|
deprecatedBelow: "0.1.53",
|
|
412
412
|
commandMinimumSupported: [
|
|
@@ -3462,11 +3462,57 @@ var DeeplineClient = class {
|
|
|
3462
3462
|
};
|
|
3463
3463
|
|
|
3464
3464
|
// src/compat.ts
|
|
3465
|
+
var import_node_fs3 = require("fs");
|
|
3466
|
+
var import_node_os3 = require("os");
|
|
3467
|
+
var import_node_path3 = require("path");
|
|
3465
3468
|
var CHECK_TIMEOUT_MS = 2e3;
|
|
3469
|
+
var COMPAT_CACHE_TTL_MS = 5 * 60 * 1e3;
|
|
3466
3470
|
function shouldSkipCompatibilityCheck() {
|
|
3467
3471
|
const value = process.env.DEEPLINE_SKIP_SDK_COMPAT_CHECK?.trim().toLowerCase();
|
|
3468
3472
|
return value === "1" || value === "true" || value === "yes";
|
|
3469
3473
|
}
|
|
3474
|
+
function compatibilityCachePath() {
|
|
3475
|
+
return (0, import_node_path3.join)((0, import_node_os3.homedir)(), ".cache", "deepline", "sdk-compat-cache.json");
|
|
3476
|
+
}
|
|
3477
|
+
function compatibilityCacheKey(baseUrl, command) {
|
|
3478
|
+
return JSON.stringify({
|
|
3479
|
+
baseUrl: baseUrl.replace(/\/$/, ""),
|
|
3480
|
+
version: SDK_VERSION,
|
|
3481
|
+
apiContract: SDK_API_CONTRACT,
|
|
3482
|
+
command: command?.trim() || null
|
|
3483
|
+
});
|
|
3484
|
+
}
|
|
3485
|
+
function readCachedCompatibility(baseUrl, command) {
|
|
3486
|
+
try {
|
|
3487
|
+
const path = compatibilityCachePath();
|
|
3488
|
+
if (!(0, import_node_fs3.existsSync)(path)) {
|
|
3489
|
+
return null;
|
|
3490
|
+
}
|
|
3491
|
+
const parsed = JSON.parse((0, import_node_fs3.readFileSync)(path, "utf8"));
|
|
3492
|
+
const entry = parsed.entries?.[compatibilityCacheKey(baseUrl, command)];
|
|
3493
|
+
if (!entry || Date.now() - entry.savedAt > COMPAT_CACHE_TTL_MS) {
|
|
3494
|
+
return null;
|
|
3495
|
+
}
|
|
3496
|
+
return entry.response;
|
|
3497
|
+
} catch {
|
|
3498
|
+
return null;
|
|
3499
|
+
}
|
|
3500
|
+
}
|
|
3501
|
+
function writeCachedCompatibility(baseUrl, command, response) {
|
|
3502
|
+
try {
|
|
3503
|
+
const path = compatibilityCachePath();
|
|
3504
|
+
const existing = (0, import_node_fs3.existsSync)(path) ? JSON.parse((0, import_node_fs3.readFileSync)(path, "utf8")) : {};
|
|
3505
|
+
const entries = existing.entries ?? {};
|
|
3506
|
+
entries[compatibilityCacheKey(baseUrl, command)] = {
|
|
3507
|
+
savedAt: Date.now(),
|
|
3508
|
+
response
|
|
3509
|
+
};
|
|
3510
|
+
(0, import_node_fs3.mkdirSync)((0, import_node_path3.dirname)(path), { recursive: true });
|
|
3511
|
+
(0, import_node_fs3.writeFileSync)(path, `${JSON.stringify({ entries }, null, 2)}
|
|
3512
|
+
`);
|
|
3513
|
+
} catch {
|
|
3514
|
+
}
|
|
3515
|
+
}
|
|
3470
3516
|
async function checkSdkCompatibility(baseUrl, options = {}) {
|
|
3471
3517
|
if (shouldSkipCompatibilityCheck()) {
|
|
3472
3518
|
return { response: null, error: null };
|
|
@@ -3489,8 +3535,15 @@ async function checkSdkCompatibility(baseUrl, options = {}) {
|
|
|
3489
3535
|
signal: controller.signal
|
|
3490
3536
|
});
|
|
3491
3537
|
const data = await response.json().catch(() => null);
|
|
3538
|
+
if (data) {
|
|
3539
|
+
writeCachedCompatibility(baseUrl, options.command, data);
|
|
3540
|
+
}
|
|
3492
3541
|
return { response: data, error: null };
|
|
3493
3542
|
} catch (error) {
|
|
3543
|
+
const cached = readCachedCompatibility(baseUrl, options.command);
|
|
3544
|
+
if (cached?.ok === false || cached?.status === "unsupported") {
|
|
3545
|
+
return { response: cached, error: null };
|
|
3546
|
+
}
|
|
3494
3547
|
return {
|
|
3495
3548
|
response: null,
|
|
3496
3549
|
error: error instanceof Error ? error : new Error(String(error))
|
|
@@ -3513,15 +3566,15 @@ function enforceSdkCompatibilityResponse(response) {
|
|
|
3513
3566
|
}
|
|
3514
3567
|
|
|
3515
3568
|
// src/cli/commands/auth.ts
|
|
3516
|
-
var
|
|
3517
|
-
var
|
|
3518
|
-
var
|
|
3569
|
+
var import_node_fs5 = require("fs");
|
|
3570
|
+
var import_node_os5 = require("os");
|
|
3571
|
+
var import_node_path5 = require("path");
|
|
3519
3572
|
|
|
3520
3573
|
// src/cli/utils.ts
|
|
3521
|
-
var
|
|
3574
|
+
var import_node_fs4 = require("fs");
|
|
3522
3575
|
var import_promises = require("fs/promises");
|
|
3523
|
-
var
|
|
3524
|
-
var
|
|
3576
|
+
var import_node_os4 = require("os");
|
|
3577
|
+
var import_node_path4 = require("path");
|
|
3525
3578
|
var childProcess = __toESM(require("child_process"));
|
|
3526
3579
|
var import_sync = require("csv-parse/sync");
|
|
3527
3580
|
var import_sync2 = require("csv-stringify/sync");
|
|
@@ -3532,15 +3585,15 @@ function getAuthedHttpClient() {
|
|
|
3532
3585
|
return { config, http: new HttpClient(config) };
|
|
3533
3586
|
}
|
|
3534
3587
|
async function writeOutputFile(filename, content) {
|
|
3535
|
-
const outputDir = (0,
|
|
3588
|
+
const outputDir = (0, import_node_path4.resolve)(process.cwd(), "deepline", "data");
|
|
3536
3589
|
await (0, import_promises.mkdir)(outputDir, { recursive: true });
|
|
3537
|
-
const fullPath = (0,
|
|
3590
|
+
const fullPath = (0, import_node_path4.join)(outputDir, filename);
|
|
3538
3591
|
await (0, import_promises.writeFile)(fullPath, content, "utf-8");
|
|
3539
3592
|
return fullPath;
|
|
3540
3593
|
}
|
|
3541
3594
|
function browserOpenStateFile() {
|
|
3542
|
-
const homeDir2 = process.env.HOME || (0,
|
|
3543
|
-
return (0,
|
|
3595
|
+
const homeDir2 = process.env.HOME || (0, import_node_os4.homedir)();
|
|
3596
|
+
return (0, import_node_path4.join)(
|
|
3544
3597
|
homeDir2,
|
|
3545
3598
|
".local",
|
|
3546
3599
|
"deepline",
|
|
@@ -3554,16 +3607,16 @@ function claimBrowserOpen(now = Date.now()) {
|
|
|
3554
3607
|
const lockPath = `${statePath}.lock`;
|
|
3555
3608
|
let locked = false;
|
|
3556
3609
|
try {
|
|
3557
|
-
(0,
|
|
3610
|
+
(0, import_node_fs4.mkdirSync)((0, import_node_path4.dirname)(statePath), { recursive: true });
|
|
3558
3611
|
try {
|
|
3559
|
-
(0,
|
|
3612
|
+
(0, import_node_fs4.mkdirSync)(lockPath);
|
|
3560
3613
|
locked = true;
|
|
3561
3614
|
} catch {
|
|
3562
3615
|
return false;
|
|
3563
3616
|
}
|
|
3564
3617
|
let lastOpenedAt = 0;
|
|
3565
|
-
if ((0,
|
|
3566
|
-
const payload = JSON.parse((0,
|
|
3618
|
+
if ((0, import_node_fs4.existsSync)(statePath)) {
|
|
3619
|
+
const payload = JSON.parse((0, import_node_fs4.readFileSync)(statePath, "utf-8"));
|
|
3567
3620
|
const value = payload.lastOpenedAt ?? payload.last_opened_at ?? payload.lastFocusedAt ?? payload.last_focused_at;
|
|
3568
3621
|
if (typeof value === "number" && Number.isFinite(value)) {
|
|
3569
3622
|
lastOpenedAt = value;
|
|
@@ -3575,13 +3628,13 @@ function claimBrowserOpen(now = Date.now()) {
|
|
|
3575
3628
|
if (now - lastOpenedAt < BROWSER_OPEN_COOLDOWN_MS) {
|
|
3576
3629
|
return false;
|
|
3577
3630
|
}
|
|
3578
|
-
(0,
|
|
3631
|
+
(0, import_node_fs4.writeFileSync)(statePath, JSON.stringify({ lastOpenedAt: now }), "utf-8");
|
|
3579
3632
|
return true;
|
|
3580
3633
|
} catch {
|
|
3581
3634
|
return true;
|
|
3582
3635
|
} finally {
|
|
3583
3636
|
if (locked) {
|
|
3584
|
-
(0,
|
|
3637
|
+
(0, import_node_fs4.rmSync)(lockPath, { recursive: true, force: true });
|
|
3585
3638
|
}
|
|
3586
3639
|
}
|
|
3587
3640
|
}
|
|
@@ -3616,7 +3669,7 @@ function readDefaultMacBrowserBundleId(runner = defaultBrowserCommandRunner) {
|
|
|
3616
3669
|
"json",
|
|
3617
3670
|
"-o",
|
|
3618
3671
|
"-",
|
|
3619
|
-
`${(0,
|
|
3672
|
+
`${(0, import_node_os4.homedir)()}/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist`
|
|
3620
3673
|
],
|
|
3621
3674
|
{ encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] }
|
|
3622
3675
|
);
|
|
@@ -3787,7 +3840,7 @@ function collectLocalEnvInfo() {
|
|
|
3787
3840
|
const info = {
|
|
3788
3841
|
os: `${process.platform} ${process.arch}`,
|
|
3789
3842
|
node_version: process.version,
|
|
3790
|
-
home_dir: (0,
|
|
3843
|
+
home_dir: (0, import_node_os4.homedir)(),
|
|
3791
3844
|
agent_runtime: detectAgentRuntime2()
|
|
3792
3845
|
};
|
|
3793
3846
|
const env = process.env;
|
|
@@ -3816,7 +3869,7 @@ function detectAgentRuntime2() {
|
|
|
3816
3869
|
if (process.env.CODEX_THREAD_ID?.trim()) return "codex";
|
|
3817
3870
|
const pluginMode = process.env.DEEPLINE_PLUGIN_MODE?.trim().toLowerCase();
|
|
3818
3871
|
const claudeRemote = process.env.CLAUDE_CODE_REMOTE?.trim().toLowerCase();
|
|
3819
|
-
const sessionHome = (process.env.HOME?.trim() || (0,
|
|
3872
|
+
const sessionHome = (process.env.HOME?.trim() || (0, import_node_os4.homedir)()).startsWith(
|
|
3820
3873
|
"/sessions/"
|
|
3821
3874
|
);
|
|
3822
3875
|
if (["1", "true", "yes", "on"].includes(pluginMode ?? "") && (["1", "true", "yes", "on"].includes(claudeRemote ?? "") || Boolean(process.env.CLAUDE_PROJECT_DIR?.trim()) || sessionHome)) {
|
|
@@ -3833,7 +3886,7 @@ function detectAgentRuntime2() {
|
|
|
3833
3886
|
return "unknown";
|
|
3834
3887
|
}
|
|
3835
3888
|
function readCsvRows(csvPath) {
|
|
3836
|
-
const raw = (0,
|
|
3889
|
+
const raw = (0, import_node_fs4.readFileSync)((0, import_node_path4.resolve)(csvPath), "utf-8");
|
|
3837
3890
|
return (0, import_sync.parse)(raw, {
|
|
3838
3891
|
columns: true,
|
|
3839
3892
|
skip_empty_lines: true
|
|
@@ -4067,25 +4120,25 @@ function pendingClaimTokenPath(baseUrl) {
|
|
|
4067
4120
|
}
|
|
4068
4121
|
function savePendingClaimToken(baseUrl, claimToken) {
|
|
4069
4122
|
const filePath = pendingClaimTokenPath(baseUrl);
|
|
4070
|
-
const dir = (0,
|
|
4071
|
-
if (!(0,
|
|
4072
|
-
(0,
|
|
4123
|
+
const dir = (0, import_node_path5.dirname)(filePath);
|
|
4124
|
+
if (!(0, import_node_fs5.existsSync)(dir)) {
|
|
4125
|
+
(0, import_node_fs5.mkdirSync)(dir, { recursive: true });
|
|
4073
4126
|
}
|
|
4074
|
-
(0,
|
|
4127
|
+
(0, import_node_fs5.writeFileSync)(filePath, `${claimToken}
|
|
4075
4128
|
`, "utf-8");
|
|
4076
4129
|
}
|
|
4077
4130
|
function readPendingClaimToken(baseUrl) {
|
|
4078
4131
|
const filePath = pendingClaimTokenPath(baseUrl);
|
|
4079
|
-
if (!(0,
|
|
4132
|
+
if (!(0, import_node_fs5.existsSync)(filePath)) return "";
|
|
4080
4133
|
try {
|
|
4081
|
-
return (0,
|
|
4134
|
+
return (0, import_node_fs5.readFileSync)(filePath, "utf-8").trim();
|
|
4082
4135
|
} catch {
|
|
4083
4136
|
return "";
|
|
4084
4137
|
}
|
|
4085
4138
|
}
|
|
4086
4139
|
function clearPendingClaimToken(baseUrl) {
|
|
4087
4140
|
try {
|
|
4088
|
-
(0,
|
|
4141
|
+
(0, import_node_fs5.rmSync)(pendingClaimTokenPath(baseUrl), { force: true });
|
|
4089
4142
|
} catch {
|
|
4090
4143
|
}
|
|
4091
4144
|
}
|
|
@@ -4204,7 +4257,7 @@ async function handleRegister(args) {
|
|
|
4204
4257
|
}
|
|
4205
4258
|
if (!agentName) {
|
|
4206
4259
|
try {
|
|
4207
|
-
agentName = (0,
|
|
4260
|
+
agentName = (0, import_node_os5.hostname)() || "Deepline CLI (TS)";
|
|
4208
4261
|
} catch {
|
|
4209
4262
|
agentName = "Deepline CLI (TS)";
|
|
4210
4263
|
}
|
|
@@ -4615,7 +4668,7 @@ Examples:
|
|
|
4615
4668
|
// src/cli/commands/billing.ts
|
|
4616
4669
|
var import_commander = require("commander");
|
|
4617
4670
|
var import_promises2 = require("fs/promises");
|
|
4618
|
-
var
|
|
4671
|
+
var import_node_path6 = require("path");
|
|
4619
4672
|
var import_sync3 = require("csv-stringify/sync");
|
|
4620
4673
|
var SUBSCRIPTION_STATUS_NEXT_COMMAND = "deepline billing subscription status --json";
|
|
4621
4674
|
var SUBSCRIPTION_CANCEL_PATH = "/api/v2/billing/subscription/cancel";
|
|
@@ -4726,7 +4779,7 @@ function ledgerRowsToCsv(rows, header) {
|
|
|
4726
4779
|
});
|
|
4727
4780
|
}
|
|
4728
4781
|
function defaultLedgerExportPath() {
|
|
4729
|
-
return (0,
|
|
4782
|
+
return (0, import_node_path6.resolve)(
|
|
4730
4783
|
process.cwd(),
|
|
4731
4784
|
"deepline",
|
|
4732
4785
|
"data",
|
|
@@ -4891,7 +4944,7 @@ async function handleHistory(options) {
|
|
|
4891
4944
|
}
|
|
4892
4945
|
async function handleLedgerExportAll(options) {
|
|
4893
4946
|
const { http } = getAuthedHttpClient();
|
|
4894
|
-
const outputPath = options.output ? (0,
|
|
4947
|
+
const outputPath = options.output ? (0, import_node_path6.resolve)(String(options.output)) : defaultLedgerExportPath();
|
|
4895
4948
|
let summary = { row_count: 0, net_delta_credits: 0 };
|
|
4896
4949
|
let cursor = null;
|
|
4897
4950
|
let initializedOutput = false;
|
|
@@ -4904,7 +4957,7 @@ async function handleLedgerExportAll(options) {
|
|
|
4904
4957
|
const entries = Array.isArray(payload.entries) ? payload.entries : [];
|
|
4905
4958
|
const rows = entries.map(ledgerApiEntryToRow);
|
|
4906
4959
|
if (!initializedOutput) {
|
|
4907
|
-
await (0, import_promises2.mkdir)((0,
|
|
4960
|
+
await (0, import_promises2.mkdir)((0, import_node_path6.dirname)(outputPath), { recursive: true });
|
|
4908
4961
|
await (0, import_promises2.writeFile)(outputPath, ledgerRowsToCsv([], true), "utf-8");
|
|
4909
4962
|
initializedOutput = true;
|
|
4910
4963
|
}
|
|
@@ -5528,8 +5581,8 @@ Examples:
|
|
|
5528
5581
|
}
|
|
5529
5582
|
|
|
5530
5583
|
// src/cli/dataset-stats.ts
|
|
5531
|
-
var
|
|
5532
|
-
var
|
|
5584
|
+
var import_node_fs6 = require("fs");
|
|
5585
|
+
var import_node_path7 = require("path");
|
|
5533
5586
|
|
|
5534
5587
|
// ../shared_libs/plays/dataset-summary.ts
|
|
5535
5588
|
function formatDatasetRowCountsLine(counts) {
|
|
@@ -6136,8 +6189,8 @@ function writeCanonicalRowsCsv(rowsInfo, outPath) {
|
|
|
6136
6189
|
});
|
|
6137
6190
|
const rows = dataExportRows(sanitized.rows);
|
|
6138
6191
|
const columns = dataExportColumns(rows, sanitized.columns);
|
|
6139
|
-
const resolved = (0,
|
|
6140
|
-
(0,
|
|
6192
|
+
const resolved = (0, import_node_path7.resolve)(outPath);
|
|
6193
|
+
(0, import_node_fs6.writeFileSync)(resolved, csvStringFromRows(rows, columns), "utf-8");
|
|
6141
6194
|
return resolved;
|
|
6142
6195
|
}
|
|
6143
6196
|
|
|
@@ -6273,8 +6326,8 @@ Examples:
|
|
|
6273
6326
|
}
|
|
6274
6327
|
|
|
6275
6328
|
// src/cli/commands/db.ts
|
|
6276
|
-
var
|
|
6277
|
-
var
|
|
6329
|
+
var import_node_fs7 = require("fs");
|
|
6330
|
+
var import_node_path8 = require("path");
|
|
6278
6331
|
var CUSTOMER_DB_QUERY_FORMATS = /* @__PURE__ */ new Set(["table", "json", "csv", "markdown"]);
|
|
6279
6332
|
function parsePositiveInteger(value, flagName) {
|
|
6280
6333
|
const parsed = Number.parseInt(value, 10);
|
|
@@ -6387,8 +6440,8 @@ function formatDbQueryError(sql, error) {
|
|
|
6387
6440
|
return errorMessage(error);
|
|
6388
6441
|
}
|
|
6389
6442
|
function writeCustomerDbCsv(result, outPath) {
|
|
6390
|
-
const resolved = (0,
|
|
6391
|
-
(0,
|
|
6443
|
+
const resolved = (0, import_node_path8.resolve)(outPath);
|
|
6444
|
+
(0, import_node_fs7.writeFileSync)(
|
|
6392
6445
|
resolved,
|
|
6393
6446
|
dataExportCsvString(customerDbRows(result), customerDbColumnNames(result)),
|
|
6394
6447
|
"utf-8"
|
|
@@ -6500,8 +6553,8 @@ async function handleDbQuery(args) {
|
|
|
6500
6553
|
customerDbColumnNames(result)
|
|
6501
6554
|
);
|
|
6502
6555
|
if (outPath) {
|
|
6503
|
-
const exportedPath = (0,
|
|
6504
|
-
(0,
|
|
6556
|
+
const exportedPath = (0, import_node_path8.resolve)(outPath);
|
|
6557
|
+
(0, import_node_fs7.writeFileSync)(exportedPath, content, "utf-8");
|
|
6505
6558
|
printCommandEnvelope(
|
|
6506
6559
|
dbQueryExportEnvelope({
|
|
6507
6560
|
result,
|
|
@@ -6603,27 +6656,27 @@ Examples:
|
|
|
6603
6656
|
|
|
6604
6657
|
// src/cli/commands/enrich.ts
|
|
6605
6658
|
var import_promises5 = require("fs/promises");
|
|
6606
|
-
var
|
|
6607
|
-
var
|
|
6659
|
+
var import_node_os8 = require("os");
|
|
6660
|
+
var import_node_path14 = require("path");
|
|
6608
6661
|
|
|
6609
6662
|
// src/cli/commands/play.ts
|
|
6610
6663
|
var import_node_crypto3 = require("crypto");
|
|
6611
|
-
var
|
|
6612
|
-
var
|
|
6664
|
+
var import_node_fs11 = require("fs");
|
|
6665
|
+
var import_node_path13 = require("path");
|
|
6613
6666
|
var import_sync5 = require("csv-parse/sync");
|
|
6614
6667
|
|
|
6615
6668
|
// src/plays/bundle-play-file.ts
|
|
6616
|
-
var
|
|
6617
|
-
var
|
|
6669
|
+
var import_node_os7 = require("os");
|
|
6670
|
+
var import_node_path11 = require("path");
|
|
6618
6671
|
var import_node_url = require("url");
|
|
6619
|
-
var
|
|
6672
|
+
var import_node_fs9 = require("fs");
|
|
6620
6673
|
|
|
6621
6674
|
// ../shared_libs/plays/bundling/index.ts
|
|
6622
6675
|
var import_node_crypto = require("crypto");
|
|
6623
|
-
var
|
|
6676
|
+
var import_node_fs8 = require("fs");
|
|
6624
6677
|
var import_promises3 = require("fs/promises");
|
|
6625
|
-
var
|
|
6626
|
-
var
|
|
6678
|
+
var import_node_os6 = require("os");
|
|
6679
|
+
var import_node_path9 = require("path");
|
|
6627
6680
|
var import_node_module = require("module");
|
|
6628
6681
|
var import_esbuild = require("esbuild");
|
|
6629
6682
|
|
|
@@ -6736,8 +6789,8 @@ var MAX_ESM_WORKERS_BUNDLE_BYTES = 115e4;
|
|
|
6736
6789
|
|
|
6737
6790
|
// ../shared_libs/plays/bundling/index.ts
|
|
6738
6791
|
var PLAY_BUNDLE_CACHE_VERSION = 24;
|
|
6739
|
-
var PLAY_ARTIFACT_CACHE_DIR = (0,
|
|
6740
|
-
(0,
|
|
6792
|
+
var PLAY_ARTIFACT_CACHE_DIR = (0, import_node_path9.join)(
|
|
6793
|
+
(0, import_node_os6.tmpdir)(),
|
|
6741
6794
|
`deepline-play-artifacts-v${PLAY_BUNDLE_CACHE_VERSION}`
|
|
6742
6795
|
);
|
|
6743
6796
|
var PLAY_PROXY_NAMESPACE = "deepline-play-runtime-ref";
|
|
@@ -6781,13 +6834,13 @@ async function normalizeLocalPath(filePath) {
|
|
|
6781
6834
|
try {
|
|
6782
6835
|
return await (0, import_promises3.realpath)(filePath);
|
|
6783
6836
|
} catch {
|
|
6784
|
-
return (0,
|
|
6837
|
+
return (0, import_node_path9.resolve)(filePath);
|
|
6785
6838
|
}
|
|
6786
6839
|
}
|
|
6787
6840
|
function createPlayWorkspace(entryFile) {
|
|
6788
6841
|
return {
|
|
6789
6842
|
entryFile,
|
|
6790
|
-
rootDir: (0,
|
|
6843
|
+
rootDir: (0, import_node_path9.dirname)(entryFile)
|
|
6791
6844
|
};
|
|
6792
6845
|
}
|
|
6793
6846
|
function isPathInsideDirectory(filePath, directory) {
|
|
@@ -6954,9 +7007,74 @@ function extractDefinedPlayName(sourceCode) {
|
|
|
6954
7007
|
}
|
|
6955
7008
|
return null;
|
|
6956
7009
|
}
|
|
7010
|
+
function canonicalizeRootPlayNameForWorkersRuntimeHash(sourceCode) {
|
|
7011
|
+
const source = stripCommentsToSpaces(sourceCode);
|
|
7012
|
+
const callPattern = /(?:\b[A-Za-z_$][\w$]*\s*\.\s*)?\b(?:definePlay|defineWorkflow)\s*\(/g;
|
|
7013
|
+
const match = callPattern.exec(source);
|
|
7014
|
+
if (!match) return sourceCode;
|
|
7015
|
+
const openParen = match.index + match[0].length - 1;
|
|
7016
|
+
const firstArgStart = openParen + 1;
|
|
7017
|
+
const firstNonSpace = source.slice(firstArgStart).search(/\S/);
|
|
7018
|
+
if (firstNonSpace < 0) return sourceCode;
|
|
7019
|
+
const argIndex = firstArgStart + firstNonSpace;
|
|
7020
|
+
const quote = source[argIndex];
|
|
7021
|
+
if (quote === '"' || quote === "'") {
|
|
7022
|
+
const literalMatch = source.slice(argIndex).match(/^(['"])(?:\\.|(?!\1)[\s\S])*\1/);
|
|
7023
|
+
if (!literalMatch) return sourceCode;
|
|
7024
|
+
const replacement = `${quote}__deepline_runtime_play_name__${quote}`;
|
|
7025
|
+
return `${sourceCode.slice(0, argIndex)}${replacement}${sourceCode.slice(argIndex + literalMatch[0].length)}`;
|
|
7026
|
+
}
|
|
7027
|
+
if (quote !== "{") return sourceCode;
|
|
7028
|
+
const closeBrace = findMatchingBrace(source, argIndex);
|
|
7029
|
+
if (closeBrace < 0) return sourceCode;
|
|
7030
|
+
const objectSource = source.slice(argIndex + 1, closeBrace);
|
|
7031
|
+
const idMatch = objectSource.match(
|
|
7032
|
+
/(^|[,{\s])((?:id|['"]id['"])\s*:\s*)(['"])([\s\S]*?)\3/
|
|
7033
|
+
);
|
|
7034
|
+
if (!idMatch || idMatch.index === void 0) return sourceCode;
|
|
7035
|
+
const idValueStart = argIndex + 1 + idMatch.index + idMatch[1].length + idMatch[2].length + idMatch[3].length;
|
|
7036
|
+
return `${sourceCode.slice(0, idValueStart)}__deepline_runtime_play_name__${sourceCode.slice(idValueStart + idMatch[4].length)}`;
|
|
7037
|
+
}
|
|
7038
|
+
function workersRuntimeGraphFilePath(input2) {
|
|
7039
|
+
if (input2.filePath === input2.entryFile) return "<entry>";
|
|
7040
|
+
const entryRelative = (0, import_node_path9.relative)((0, import_node_path9.dirname)(input2.entryFile), input2.filePath);
|
|
7041
|
+
if (entryRelative && !entryRelative.startsWith("..")) {
|
|
7042
|
+
return entryRelative.replaceAll("\\", "/");
|
|
7043
|
+
}
|
|
7044
|
+
return `<project>/${(0, import_node_path9.relative)(input2.adapter.projectRoot, input2.filePath).replaceAll("\\", "/")}`;
|
|
7045
|
+
}
|
|
7046
|
+
function buildWorkersRuntimeGraphHash(input2) {
|
|
7047
|
+
const sourceFiles = Object.entries(input2.analysis.sourceFiles).map(([filePath, contents]) => ({
|
|
7048
|
+
filePath: workersRuntimeGraphFilePath({
|
|
7049
|
+
entryFile: input2.entryFile,
|
|
7050
|
+
filePath,
|
|
7051
|
+
adapter: input2.adapter
|
|
7052
|
+
}),
|
|
7053
|
+
hash: sha256(
|
|
7054
|
+
filePath === input2.entryFile ? canonicalizeRootPlayNameForWorkersRuntimeHash(contents) : contents
|
|
7055
|
+
)
|
|
7056
|
+
})).sort((left, right) => left.filePath.localeCompare(right.filePath));
|
|
7057
|
+
return sha256(
|
|
7058
|
+
JSON.stringify({
|
|
7059
|
+
entryFile: "<entry>",
|
|
7060
|
+
entryExport: input2.exportName,
|
|
7061
|
+
localFiles: sourceFiles,
|
|
7062
|
+
nodeBuiltins: [...input2.analysis.importPolicy.nodeBuiltins].sort(),
|
|
7063
|
+
packages: input2.analysis.importPolicy.packages.map(({ name, version }) => ({ name, version })).sort((left, right) => left.name.localeCompare(right.name)),
|
|
7064
|
+
importedPlayDependencies: input2.analysis.importedPlayDependencies.map((dependency) => ({
|
|
7065
|
+
filePath: workersRuntimeGraphFilePath({
|
|
7066
|
+
entryFile: input2.entryFile,
|
|
7067
|
+
filePath: dependency.filePath,
|
|
7068
|
+
adapter: input2.adapter
|
|
7069
|
+
}),
|
|
7070
|
+
playName: dependency.playName
|
|
7071
|
+
})).sort((left, right) => left.filePath.localeCompare(right.filePath))
|
|
7072
|
+
})
|
|
7073
|
+
);
|
|
7074
|
+
}
|
|
6957
7075
|
function readPackageVersionFromPackageJson(packageJsonPath, packageName) {
|
|
6958
7076
|
try {
|
|
6959
|
-
const packageJson = JSON.parse((0,
|
|
7077
|
+
const packageJson = JSON.parse((0, import_node_fs8.readFileSync)(packageJsonPath, "utf-8"));
|
|
6960
7078
|
if (packageJson.name === packageName && typeof packageJson.version === "string") {
|
|
6961
7079
|
return packageJson.version;
|
|
6962
7080
|
}
|
|
@@ -6966,23 +7084,23 @@ function readPackageVersionFromPackageJson(packageJsonPath, packageName) {
|
|
|
6966
7084
|
return null;
|
|
6967
7085
|
}
|
|
6968
7086
|
function findPackageJsonPathFrom(startDir, packageName) {
|
|
6969
|
-
if (!(0,
|
|
7087
|
+
if (!(0, import_node_path9.isAbsolute)(startDir)) {
|
|
6970
7088
|
throw new Error(
|
|
6971
7089
|
`Package resolution requires an absolute start directory, got ${startDir}`
|
|
6972
7090
|
);
|
|
6973
7091
|
}
|
|
6974
7092
|
let current = startDir;
|
|
6975
7093
|
while (true) {
|
|
6976
|
-
const packageJsonPath = (0,
|
|
7094
|
+
const packageJsonPath = (0, import_node_path9.join)(
|
|
6977
7095
|
current,
|
|
6978
7096
|
"node_modules",
|
|
6979
7097
|
packageName,
|
|
6980
7098
|
"package.json"
|
|
6981
7099
|
);
|
|
6982
|
-
if ((0,
|
|
7100
|
+
if ((0, import_node_fs8.existsSync)(packageJsonPath)) {
|
|
6983
7101
|
return packageJsonPath;
|
|
6984
7102
|
}
|
|
6985
|
-
const parent = (0,
|
|
7103
|
+
const parent = (0, import_node_path9.dirname)(current);
|
|
6986
7104
|
if (parent === current) {
|
|
6987
7105
|
return null;
|
|
6988
7106
|
}
|
|
@@ -6991,9 +7109,9 @@ function findPackageJsonPathFrom(startDir, packageName) {
|
|
|
6991
7109
|
}
|
|
6992
7110
|
function findPackageJsonPath(packageName, fromFile, adapter) {
|
|
6993
7111
|
const startDirs = [
|
|
6994
|
-
(0,
|
|
6995
|
-
(0,
|
|
6996
|
-
(0,
|
|
7112
|
+
(0, import_node_path9.resolve)((0, import_node_path9.dirname)(fromFile)),
|
|
7113
|
+
(0, import_node_path9.resolve)(adapter.projectRoot),
|
|
7114
|
+
(0, import_node_path9.resolve)((0, import_node_path9.dirname)(adapter.sdkPackageJson))
|
|
6997
7115
|
];
|
|
6998
7116
|
const seen = /* @__PURE__ */ new Set();
|
|
6999
7117
|
for (const startDir of startDirs) {
|
|
@@ -7002,16 +7120,16 @@ function findPackageJsonPath(packageName, fromFile, adapter) {
|
|
|
7002
7120
|
const packageJsonPath = findPackageJsonPathFrom(startDir, packageName);
|
|
7003
7121
|
if (packageJsonPath) return packageJsonPath;
|
|
7004
7122
|
}
|
|
7005
|
-
const adapterNodeModulesPackageJson = (0,
|
|
7123
|
+
const adapterNodeModulesPackageJson = (0, import_node_path9.join)(
|
|
7006
7124
|
adapter.nodeModulesDir,
|
|
7007
7125
|
packageName,
|
|
7008
7126
|
"package.json"
|
|
7009
7127
|
);
|
|
7010
|
-
return (0,
|
|
7128
|
+
return (0, import_node_fs8.existsSync)(adapterNodeModulesPackageJson) ? adapterNodeModulesPackageJson : null;
|
|
7011
7129
|
}
|
|
7012
7130
|
function localSdkAliasPlugin(adapter, options) {
|
|
7013
7131
|
const entryFile = options?.workersRuntime ? adapter.sdkWorkersEntryFile : adapter.sdkEntryFile;
|
|
7014
|
-
if (!(0,
|
|
7132
|
+
if (!(0, import_node_fs8.existsSync)(entryFile)) {
|
|
7015
7133
|
return null;
|
|
7016
7134
|
}
|
|
7017
7135
|
return {
|
|
@@ -7021,7 +7139,7 @@ function localSdkAliasPlugin(adapter, options) {
|
|
|
7021
7139
|
path: entryFile
|
|
7022
7140
|
}));
|
|
7023
7141
|
buildContext.onResolve({ filter: /^deepline\/helpers$/ }, () => ({
|
|
7024
|
-
path: (0,
|
|
7142
|
+
path: (0, import_node_path9.join)(adapter.sdkSourceRoot, "helpers.ts")
|
|
7025
7143
|
}));
|
|
7026
7144
|
}
|
|
7027
7145
|
};
|
|
@@ -7054,7 +7172,7 @@ function workersNamedPlayEntryAliasPlugin(playFilePath, exportName) {
|
|
|
7054
7172
|
contents: `export { ${exportName} as default } from ${JSON.stringify(playFilePath)};
|
|
7055
7173
|
`,
|
|
7056
7174
|
loader: "ts",
|
|
7057
|
-
resolveDir: (0,
|
|
7175
|
+
resolveDir: (0, import_node_path9.dirname)(playFilePath)
|
|
7058
7176
|
})
|
|
7059
7177
|
);
|
|
7060
7178
|
}
|
|
@@ -7225,7 +7343,7 @@ function importedPlayProxyPlugin(importedPlayDependencies) {
|
|
|
7225
7343
|
return {
|
|
7226
7344
|
contents: buildImportedPlayProxyModule(dependency.playName),
|
|
7227
7345
|
loader: "ts",
|
|
7228
|
-
resolveDir: (0,
|
|
7346
|
+
resolveDir: (0, import_node_path9.dirname)(args.path)
|
|
7229
7347
|
};
|
|
7230
7348
|
}
|
|
7231
7349
|
);
|
|
@@ -7244,15 +7362,15 @@ async function resolveLocalImport(fromFile, specifier) {
|
|
|
7244
7362
|
if (specifier.startsWith("file:")) {
|
|
7245
7363
|
return normalizeLocalPath(new URL(specifier).pathname);
|
|
7246
7364
|
}
|
|
7247
|
-
const base = (0,
|
|
7365
|
+
const base = (0, import_node_path9.isAbsolute)(specifier) ? (0, import_node_path9.resolve)(specifier) : (0, import_node_path9.resolve)((0, import_node_path9.dirname)(fromFile), specifier);
|
|
7248
7366
|
const candidates = [base];
|
|
7249
|
-
const explicitExtension = (0,
|
|
7367
|
+
const explicitExtension = (0, import_node_path9.extname)(base).toLowerCase();
|
|
7250
7368
|
if (!explicitExtension) {
|
|
7251
7369
|
candidates.push(
|
|
7252
7370
|
...SOURCE_EXTENSIONS.map((extension) => `${base}${extension}`)
|
|
7253
7371
|
);
|
|
7254
7372
|
candidates.push(
|
|
7255
|
-
...SOURCE_EXTENSIONS.map((extension) => (0,
|
|
7373
|
+
...SOURCE_EXTENSIONS.map((extension) => (0, import_node_path9.join)(base, `index${extension}`))
|
|
7256
7374
|
);
|
|
7257
7375
|
} else if ([".js", ".jsx", ".mjs", ".cjs"].includes(explicitExtension)) {
|
|
7258
7376
|
const stem = base.slice(0, -explicitExtension.length);
|
|
@@ -7271,9 +7389,9 @@ async function resolveLocalImport(fromFile, specifier) {
|
|
|
7271
7389
|
}
|
|
7272
7390
|
function resolvePackageImport(specifier, fromFile, adapter) {
|
|
7273
7391
|
const packageName = getPackageName(specifier);
|
|
7274
|
-
if (packageName === "deepline" && (0,
|
|
7392
|
+
if (packageName === "deepline" && (0, import_node_fs8.existsSync)(adapter.sdkPackageJson)) {
|
|
7275
7393
|
const packageJson = JSON.parse(
|
|
7276
|
-
(0,
|
|
7394
|
+
(0, import_node_fs8.readFileSync)(adapter.sdkPackageJson, "utf-8")
|
|
7277
7395
|
);
|
|
7278
7396
|
return {
|
|
7279
7397
|
name: "deepline",
|
|
@@ -7305,7 +7423,7 @@ async function analyzeSourceGraph(entryFile, adapter) {
|
|
|
7305
7423
|
visited.add(absolutePath);
|
|
7306
7424
|
const sourceCode2 = await (0, import_promises3.readFile)(absolutePath, "utf-8");
|
|
7307
7425
|
localFiles.set(absolutePath, sourceCode2);
|
|
7308
|
-
if ((0,
|
|
7426
|
+
if ((0, import_node_path9.extname)(absolutePath).toLowerCase() === ".json") {
|
|
7309
7427
|
return;
|
|
7310
7428
|
}
|
|
7311
7429
|
const handleSpecifier = async (specifier, line, column, kind) => {
|
|
@@ -7416,7 +7534,7 @@ async function computeWorkersHarnessFingerprintWithAdapter(adapter) {
|
|
|
7416
7534
|
const addFilePart = async (parts2, rootDir, filePath) => {
|
|
7417
7535
|
const contents = await (0, import_promises3.readFile)(filePath, "utf-8");
|
|
7418
7536
|
parts2.push({
|
|
7419
|
-
name: `${(0,
|
|
7537
|
+
name: `${(0, import_node_path9.basename)(rootDir)}:${filePath.slice(rootDir.length + 1)}`,
|
|
7420
7538
|
hash: sha256(contents)
|
|
7421
7539
|
});
|
|
7422
7540
|
};
|
|
@@ -7425,7 +7543,7 @@ async function computeWorkersHarnessFingerprintWithAdapter(adapter) {
|
|
|
7425
7543
|
const entries2 = await readdir(rootDir, { withFileTypes: true });
|
|
7426
7544
|
const tsFiles2 = entries2.filter((entry) => entry.isFile() && /\.[cm]?ts$/.test(entry.name)).map((entry) => entry.name).sort();
|
|
7427
7545
|
for (const name of tsFiles2) {
|
|
7428
|
-
await addFilePart(parts2, rootDir, (0,
|
|
7546
|
+
await addFilePart(parts2, rootDir, (0, import_node_path9.join)(rootDir, name));
|
|
7429
7547
|
}
|
|
7430
7548
|
};
|
|
7431
7549
|
const collectIntegrationBatchingFiles = async (rootDir, parts2) => {
|
|
@@ -7434,10 +7552,10 @@ async function computeWorkersHarnessFingerprintWithAdapter(adapter) {
|
|
|
7434
7552
|
const filePaths = [];
|
|
7435
7553
|
for (const entry of entries2) {
|
|
7436
7554
|
if (entry.isFile() && (entry.name === "play-runtime-batching-registry.ts" || /^batching.*\.ts$/.test(entry.name))) {
|
|
7437
|
-
filePaths.push((0,
|
|
7555
|
+
filePaths.push((0, import_node_path9.join)(rootDir, entry.name));
|
|
7438
7556
|
}
|
|
7439
7557
|
if (entry.isDirectory()) {
|
|
7440
|
-
const batchingFile = (0,
|
|
7558
|
+
const batchingFile = (0, import_node_path9.join)(rootDir, entry.name, "batching.ts");
|
|
7441
7559
|
if (await fileExists(batchingFile)) {
|
|
7442
7560
|
filePaths.push(batchingFile);
|
|
7443
7561
|
}
|
|
@@ -7456,11 +7574,11 @@ async function computeWorkersHarnessFingerprintWithAdapter(adapter) {
|
|
|
7456
7574
|
await addFilePart(
|
|
7457
7575
|
parts,
|
|
7458
7576
|
adapter.workersHarnessFilesDir,
|
|
7459
|
-
(0,
|
|
7577
|
+
(0, import_node_path9.join)(adapter.workersHarnessFilesDir, name)
|
|
7460
7578
|
);
|
|
7461
7579
|
}
|
|
7462
7580
|
for (const dir of adapter.workersRuntimeFingerprintDirs ?? []) {
|
|
7463
|
-
if ((0,
|
|
7581
|
+
if ((0, import_node_path9.basename)(dir) === "integrations") {
|
|
7464
7582
|
await collectIntegrationBatchingFiles(dir, parts);
|
|
7465
7583
|
} else {
|
|
7466
7584
|
await collectTopLevelTsFiles(dir, parts);
|
|
@@ -7469,7 +7587,7 @@ async function computeWorkersHarnessFingerprintWithAdapter(adapter) {
|
|
|
7469
7587
|
return sha256(JSON.stringify(parts));
|
|
7470
7588
|
}
|
|
7471
7589
|
function artifactCachePath(graphHash, artifactKind, adapter) {
|
|
7472
|
-
return (0,
|
|
7590
|
+
return (0, import_node_path9.join)(
|
|
7473
7591
|
adapter.cacheDir ?? PLAY_ARTIFACT_CACHE_DIR,
|
|
7474
7592
|
`${graphHash}.${artifactKind}.json`
|
|
7475
7593
|
);
|
|
@@ -7504,7 +7622,7 @@ function normalizeSourceMapForRuntime(sourceMapText, projectRoot) {
|
|
|
7504
7622
|
if (sourcePath.startsWith("data:") || sourcePath.startsWith("node:") || sourcePath.startsWith("/") || /^[a-zA-Z]+:\/\//.test(sourcePath)) {
|
|
7505
7623
|
return sourcePath;
|
|
7506
7624
|
}
|
|
7507
|
-
return (0,
|
|
7625
|
+
return (0, import_node_path9.join)(projectRoot, sourcePath);
|
|
7508
7626
|
});
|
|
7509
7627
|
parsed.sourceRoot = void 0;
|
|
7510
7628
|
return JSON.stringify(parsed);
|
|
@@ -7536,8 +7654,8 @@ async function runEsbuildForCjsNode(entryFile, importedPlayDependencies, adapter
|
|
|
7536
7654
|
...namedExportShim ? {
|
|
7537
7655
|
stdin: {
|
|
7538
7656
|
contents: namedExportShim,
|
|
7539
|
-
resolveDir: (0,
|
|
7540
|
-
sourcefile: `${(0,
|
|
7657
|
+
resolveDir: (0, import_node_path9.dirname)(entryFile),
|
|
7658
|
+
sourcefile: `${(0, import_node_path9.basename)(entryFile)}.${exportName}.entry.ts`,
|
|
7541
7659
|
loader: "ts"
|
|
7542
7660
|
}
|
|
7543
7661
|
} : { entryPoints: [entryFile] },
|
|
@@ -7686,10 +7804,13 @@ async function bundlePlayFile(filePath, options) {
|
|
|
7686
7804
|
adapter.warnAboutNonDevelopmentBundling?.(absolutePath);
|
|
7687
7805
|
try {
|
|
7688
7806
|
const analysis = await analyzeSourceGraph(absolutePath, adapter);
|
|
7689
|
-
analysis.graphHash =
|
|
7690
|
-
|
|
7691
|
-
|
|
7692
|
-
|
|
7807
|
+
analysis.graphHash = target === PLAY_ARTIFACT_KINDS.esmWorkers ? buildWorkersRuntimeGraphHash({
|
|
7808
|
+
analysis,
|
|
7809
|
+
entryFile: absolutePath,
|
|
7810
|
+
adapter,
|
|
7811
|
+
exportName
|
|
7812
|
+
}) : sha256(`${analysis.graphHash}
|
|
7813
|
+
entry-export:${exportName}`);
|
|
7693
7814
|
if (targetAdapter.includeWorkersHarnessInGraphHash) {
|
|
7694
7815
|
const harnessFingerprint = await computeWorkersHarnessFingerprintWithAdapter(adapter);
|
|
7695
7816
|
analysis.graphHash = sha256(
|
|
@@ -7725,11 +7846,8 @@ workers-harness:${harnessFingerprint}`
|
|
|
7725
7846
|
errors: typecheckErrors
|
|
7726
7847
|
};
|
|
7727
7848
|
}
|
|
7728
|
-
const
|
|
7729
|
-
|
|
7730
|
-
target,
|
|
7731
|
-
adapter
|
|
7732
|
-
);
|
|
7849
|
+
const canUseArtifactCache = target !== PLAY_ARTIFACT_KINDS.esmWorkers;
|
|
7850
|
+
const cachedArtifact = canUseArtifactCache ? await readArtifactCache(analysis.graphHash, target, adapter) : null;
|
|
7733
7851
|
const discoveredFiles = await adapter.discoverPackagedLocalFiles(absolutePath);
|
|
7734
7852
|
if (cachedArtifact) {
|
|
7735
7853
|
const cachedArtifactSizeError = getBundleSizeError(
|
|
@@ -7746,7 +7864,13 @@ workers-harness:${harnessFingerprint}`
|
|
|
7746
7864
|
}
|
|
7747
7865
|
return {
|
|
7748
7866
|
success: true,
|
|
7749
|
-
artifact: {
|
|
7867
|
+
artifact: {
|
|
7868
|
+
...cachedArtifact,
|
|
7869
|
+
entryFile: absolutePath,
|
|
7870
|
+
sourceHash: analysis.sourceHash,
|
|
7871
|
+
importPolicy: analysis.importPolicy,
|
|
7872
|
+
cacheHit: true
|
|
7873
|
+
},
|
|
7750
7874
|
sourceCode: analysis.sourceCode,
|
|
7751
7875
|
sourceFiles: analysis.sourceFiles,
|
|
7752
7876
|
filePath: absolutePath,
|
|
@@ -7772,12 +7896,12 @@ workers-harness:${harnessFingerprint}`
|
|
|
7772
7896
|
const { bundledCode, sourceMapText, outputExtension } = buildOutcome;
|
|
7773
7897
|
const normalizedSourceMap = normalizeSourceMapForRuntime(
|
|
7774
7898
|
sourceMapText,
|
|
7775
|
-
(0,
|
|
7899
|
+
(0, import_node_path9.resolve)(adapter.projectRoot)
|
|
7776
7900
|
);
|
|
7777
|
-
const virtualBaseName = exportName === "default" ? (0,
|
|
7901
|
+
const virtualBaseName = exportName === "default" ? (0, import_node_path9.basename)(absolutePath).replace(/\.[^.]+$/, "") : `${(0, import_node_path9.basename)(absolutePath).replace(/\.[^.]+$/, "")}.${exportName}`;
|
|
7778
7902
|
const virtualFilename = `/virtual/deepline-plays/${analysis.graphHash}/${virtualBaseName}.${outputExtension}`;
|
|
7779
7903
|
const executableCode = `${bundledCode}
|
|
7780
|
-
//# sourceMappingURL=${(0,
|
|
7904
|
+
//# sourceMappingURL=${(0, import_node_path9.basename)(virtualFilename)}.map
|
|
7781
7905
|
`;
|
|
7782
7906
|
const bundleSizeError = getBundleSizeError(
|
|
7783
7907
|
absolutePath,
|
|
@@ -7807,7 +7931,9 @@ workers-harness:${harnessFingerprint}`
|
|
|
7807
7931
|
generatedAt: Date.now(),
|
|
7808
7932
|
cacheHit: false
|
|
7809
7933
|
};
|
|
7810
|
-
|
|
7934
|
+
if (canUseArtifactCache) {
|
|
7935
|
+
await writeArtifactCache(artifact, adapter);
|
|
7936
|
+
}
|
|
7811
7937
|
return {
|
|
7812
7938
|
success: true,
|
|
7813
7939
|
artifact,
|
|
@@ -7929,7 +8055,7 @@ function resolveExecutionProfile(override) {
|
|
|
7929
8055
|
// src/plays/local-file-discovery.ts
|
|
7930
8056
|
var import_node_crypto2 = require("crypto");
|
|
7931
8057
|
var import_promises4 = require("fs/promises");
|
|
7932
|
-
var
|
|
8058
|
+
var import_node_path10 = require("path");
|
|
7933
8059
|
var SOURCE_EXTENSIONS2 = [
|
|
7934
8060
|
".ts",
|
|
7935
8061
|
".tsx",
|
|
@@ -7945,7 +8071,7 @@ function sha2562(buffer) {
|
|
|
7945
8071
|
return (0, import_node_crypto2.createHash)("sha256").update(buffer).digest("hex");
|
|
7946
8072
|
}
|
|
7947
8073
|
function contentTypeForFile(filePath) {
|
|
7948
|
-
const extension = (0,
|
|
8074
|
+
const extension = (0, import_node_path10.extname)(filePath).toLowerCase();
|
|
7949
8075
|
if (extension === ".csv") return "text/csv";
|
|
7950
8076
|
if (extension === ".json") return "application/json";
|
|
7951
8077
|
if (extension === ".txt") return "text/plain";
|
|
@@ -8144,19 +8270,19 @@ async function fileExists2(filePath) {
|
|
|
8144
8270
|
}
|
|
8145
8271
|
}
|
|
8146
8272
|
function isPathInsideDirectory2(filePath, directory) {
|
|
8147
|
-
const relativePath = (0,
|
|
8148
|
-
return relativePath === "" || !relativePath.startsWith("..") && !(0,
|
|
8273
|
+
const relativePath = (0, import_node_path10.relative)(directory, filePath);
|
|
8274
|
+
return relativePath === "" || !relativePath.startsWith("..") && !(0, import_node_path10.isAbsolute)(relativePath);
|
|
8149
8275
|
}
|
|
8150
8276
|
async function resolveLocalImport2(fromFile, specifier) {
|
|
8151
|
-
const base = (0,
|
|
8277
|
+
const base = (0, import_node_path10.isAbsolute)(specifier) ? (0, import_node_path10.resolve)(specifier) : (0, import_node_path10.resolve)((0, import_node_path10.dirname)(fromFile), specifier);
|
|
8152
8278
|
const candidates = [base];
|
|
8153
|
-
const explicitExtension = (0,
|
|
8279
|
+
const explicitExtension = (0, import_node_path10.extname)(base).toLowerCase();
|
|
8154
8280
|
if (!explicitExtension) {
|
|
8155
8281
|
candidates.push(
|
|
8156
8282
|
...SOURCE_EXTENSIONS2.map((extension) => `${base}${extension}`)
|
|
8157
8283
|
);
|
|
8158
8284
|
candidates.push(
|
|
8159
|
-
...SOURCE_EXTENSIONS2.map((extension) => (0,
|
|
8285
|
+
...SOURCE_EXTENSIONS2.map((extension) => (0, import_node_path10.join)(base, `index${extension}`))
|
|
8160
8286
|
);
|
|
8161
8287
|
} else if ([".js", ".jsx", ".mjs", ".cjs"].includes(explicitExtension)) {
|
|
8162
8288
|
const stem = base.slice(0, -explicitExtension.length);
|
|
@@ -8174,13 +8300,13 @@ async function resolveLocalImport2(fromFile, specifier) {
|
|
|
8174
8300
|
);
|
|
8175
8301
|
}
|
|
8176
8302
|
async function discoverPackagedLocalFiles(entryFile) {
|
|
8177
|
-
const absoluteEntryFile = (0,
|
|
8178
|
-
const packagingRoot = (0,
|
|
8303
|
+
const absoluteEntryFile = (0, import_node_path10.resolve)(entryFile);
|
|
8304
|
+
const packagingRoot = (0, import_node_path10.dirname)(absoluteEntryFile);
|
|
8179
8305
|
const files = /* @__PURE__ */ new Map();
|
|
8180
8306
|
const unresolved = [];
|
|
8181
8307
|
const visitedFiles = /* @__PURE__ */ new Set();
|
|
8182
8308
|
const visitSourceFile = async (filePath) => {
|
|
8183
|
-
const absolutePath = (0,
|
|
8309
|
+
const absolutePath = (0, import_node_path10.resolve)(filePath);
|
|
8184
8310
|
if (visitedFiles.has(absolutePath)) {
|
|
8185
8311
|
return;
|
|
8186
8312
|
}
|
|
@@ -8217,8 +8343,8 @@ async function discoverPackagedLocalFiles(entryFile) {
|
|
|
8217
8343
|
message: "Could not resolve this ctx.csv(...) path at submit time. Use a string literal, a top-level const string, or pass a runtime input like input.file."
|
|
8218
8344
|
});
|
|
8219
8345
|
} else {
|
|
8220
|
-
const absoluteCsvPath = (0,
|
|
8221
|
-
if ((0,
|
|
8346
|
+
const absoluteCsvPath = (0, import_node_path10.resolve)((0, import_node_path10.dirname)(absolutePath), resolvedPath);
|
|
8347
|
+
if ((0, import_node_path10.isAbsolute)(resolvedPath) || !isPathInsideDirectory2(absoluteCsvPath, packagingRoot)) {
|
|
8222
8348
|
unresolved.push({
|
|
8223
8349
|
sourceFragment: sourceCode.slice(argument.start, argument.end).trim(),
|
|
8224
8350
|
message: "ctx.csv(...) packaged file paths must be relative paths inside the play directory. Pass external files at runtime with input.file instead."
|
|
@@ -8257,30 +8383,30 @@ async function discoverPackagedLocalFiles(entryFile) {
|
|
|
8257
8383
|
// src/plays/bundle-play-file.ts
|
|
8258
8384
|
var import_meta = {};
|
|
8259
8385
|
var PLAY_BUNDLE_CACHE_VERSION2 = 30;
|
|
8260
|
-
var MODULE_DIR = (0,
|
|
8261
|
-
var SDK_PACKAGE_ROOT = (0,
|
|
8262
|
-
var SOURCE_REPO_ROOT = (0,
|
|
8263
|
-
var HAS_SOURCE_BUNDLING_SOURCES = (0,
|
|
8264
|
-
(0,
|
|
8386
|
+
var MODULE_DIR = (0, import_node_path11.dirname)((0, import_node_url.fileURLToPath)(import_meta.url));
|
|
8387
|
+
var SDK_PACKAGE_ROOT = (0, import_node_path11.resolve)(MODULE_DIR, "..", "..");
|
|
8388
|
+
var SOURCE_REPO_ROOT = (0, import_node_path11.resolve)(SDK_PACKAGE_ROOT, "..");
|
|
8389
|
+
var HAS_SOURCE_BUNDLING_SOURCES = (0, import_node_fs9.existsSync)(
|
|
8390
|
+
(0, import_node_path11.resolve)(SOURCE_REPO_ROOT, "apps", "play-runner-workers", "src", "entry.ts")
|
|
8265
8391
|
);
|
|
8266
|
-
var PACKAGED_REPO_ROOT = (0,
|
|
8267
|
-
var HAS_PACKAGED_BUNDLING_SOURCES = (0,
|
|
8268
|
-
(0,
|
|
8392
|
+
var PACKAGED_REPO_ROOT = (0, import_node_path11.resolve)(SDK_PACKAGE_ROOT, "dist", "repo");
|
|
8393
|
+
var HAS_PACKAGED_BUNDLING_SOURCES = (0, import_node_fs9.existsSync)(
|
|
8394
|
+
(0, import_node_path11.resolve)(PACKAGED_REPO_ROOT, "apps", "play-runner-workers", "src", "entry.ts")
|
|
8269
8395
|
);
|
|
8270
|
-
var PROJECT_ROOT = HAS_SOURCE_BUNDLING_SOURCES ? SOURCE_REPO_ROOT : HAS_PACKAGED_BUNDLING_SOURCES ? PACKAGED_REPO_ROOT : (0,
|
|
8271
|
-
var SDK_SOURCE_ROOT = HAS_SOURCE_BUNDLING_SOURCES ? (0,
|
|
8272
|
-
var SDK_PACKAGE_JSON = (0,
|
|
8273
|
-
var SDK_ENTRY_FILE = (0,
|
|
8274
|
-
var SDK_TYPES_ENTRY_FILE = HAS_SOURCE_BUNDLING_SOURCES ? SDK_ENTRY_FILE : (0,
|
|
8275
|
-
var SDK_WORKERS_ENTRY_FILE = (0,
|
|
8276
|
-
var WORKERS_HARNESS_ENTRY_FILE = (0,
|
|
8396
|
+
var PROJECT_ROOT = HAS_SOURCE_BUNDLING_SOURCES ? SOURCE_REPO_ROOT : HAS_PACKAGED_BUNDLING_SOURCES ? PACKAGED_REPO_ROOT : (0, import_node_path11.resolve)(SDK_PACKAGE_ROOT, "..");
|
|
8397
|
+
var SDK_SOURCE_ROOT = HAS_SOURCE_BUNDLING_SOURCES ? (0, import_node_path11.resolve)(SOURCE_REPO_ROOT, "sdk", "src") : HAS_PACKAGED_BUNDLING_SOURCES ? (0, import_node_path11.resolve)(PACKAGED_REPO_ROOT, "sdk", "src") : (0, import_node_path11.resolve)(SDK_PACKAGE_ROOT, "src");
|
|
8398
|
+
var SDK_PACKAGE_JSON = (0, import_node_path11.resolve)(SDK_PACKAGE_ROOT, "package.json");
|
|
8399
|
+
var SDK_ENTRY_FILE = (0, import_node_path11.resolve)(SDK_SOURCE_ROOT, "index.ts");
|
|
8400
|
+
var SDK_TYPES_ENTRY_FILE = HAS_SOURCE_BUNDLING_SOURCES ? SDK_ENTRY_FILE : (0, import_node_path11.resolve)(SDK_PACKAGE_ROOT, "dist", "index.d.ts");
|
|
8401
|
+
var SDK_WORKERS_ENTRY_FILE = (0, import_node_path11.resolve)(SDK_SOURCE_ROOT, "worker-play-entry.ts");
|
|
8402
|
+
var WORKERS_HARNESS_ENTRY_FILE = (0, import_node_path11.resolve)(
|
|
8277
8403
|
PROJECT_ROOT,
|
|
8278
8404
|
"apps",
|
|
8279
8405
|
"play-runner-workers",
|
|
8280
8406
|
"src",
|
|
8281
8407
|
"entry.ts"
|
|
8282
8408
|
);
|
|
8283
|
-
var WORKERS_HARNESS_FILES_DIR = (0,
|
|
8409
|
+
var WORKERS_HARNESS_FILES_DIR = (0, import_node_path11.resolve)(
|
|
8284
8410
|
PROJECT_ROOT,
|
|
8285
8411
|
"apps",
|
|
8286
8412
|
"play-runner-workers",
|
|
@@ -8309,20 +8435,20 @@ function defaultPlayBundleTarget() {
|
|
|
8309
8435
|
function createSdkPlayBundlingAdapter() {
|
|
8310
8436
|
return {
|
|
8311
8437
|
projectRoot: PROJECT_ROOT,
|
|
8312
|
-
nodeModulesDir: (0,
|
|
8313
|
-
cacheDir: (0,
|
|
8314
|
-
(0,
|
|
8438
|
+
nodeModulesDir: (0, import_node_path11.resolve)(PROJECT_ROOT, "node_modules"),
|
|
8439
|
+
cacheDir: (0, import_node_path11.join)(
|
|
8440
|
+
(0, import_node_os7.tmpdir)(),
|
|
8315
8441
|
`deepline-play-artifacts-v${PLAY_BUNDLE_CACHE_VERSION2}`
|
|
8316
8442
|
),
|
|
8317
8443
|
sdkSourceRoot: SDK_SOURCE_ROOT,
|
|
8318
8444
|
sdkPackageJson: SDK_PACKAGE_JSON,
|
|
8319
8445
|
sdkEntryFile: SDK_ENTRY_FILE,
|
|
8320
|
-
sdkTypesEntryFile: HAS_SOURCE_BUNDLING_SOURCES || !(0,
|
|
8446
|
+
sdkTypesEntryFile: HAS_SOURCE_BUNDLING_SOURCES || !(0, import_node_fs9.existsSync)(SDK_TYPES_ENTRY_FILE) ? SDK_ENTRY_FILE : SDK_TYPES_ENTRY_FILE,
|
|
8321
8447
|
sdkWorkersEntryFile: SDK_WORKERS_ENTRY_FILE,
|
|
8322
8448
|
workersHarnessEntryFile: WORKERS_HARNESS_ENTRY_FILE,
|
|
8323
8449
|
workersHarnessFilesDir: WORKERS_HARNESS_FILES_DIR,
|
|
8324
8450
|
workersRuntimeFingerprintDirs: [
|
|
8325
|
-
(0,
|
|
8451
|
+
(0, import_node_path11.resolve)(PROJECT_ROOT, "shared_libs", "play-runtime")
|
|
8326
8452
|
],
|
|
8327
8453
|
discoverPackagedLocalFiles,
|
|
8328
8454
|
warnAboutNonDevelopmentBundling
|
|
@@ -8340,8 +8466,8 @@ async function bundlePlayFile2(filePath, options = {}) {
|
|
|
8340
8466
|
}
|
|
8341
8467
|
|
|
8342
8468
|
// src/cli/commands/plays/bootstrap.ts
|
|
8343
|
-
var
|
|
8344
|
-
var
|
|
8469
|
+
var import_node_fs10 = require("fs");
|
|
8470
|
+
var import_node_path12 = require("path");
|
|
8345
8471
|
var import_sync4 = require("csv-parse/sync");
|
|
8346
8472
|
|
|
8347
8473
|
// ../shared_libs/plays/bootstrap-routes.ts
|
|
@@ -8770,13 +8896,13 @@ function inferCsvColumnSpecs(headers, rows) {
|
|
|
8770
8896
|
}));
|
|
8771
8897
|
}
|
|
8772
8898
|
function readCsvSample(csvPath) {
|
|
8773
|
-
const resolvedPath = (0,
|
|
8774
|
-
const size = (0,
|
|
8775
|
-
const fd = (0,
|
|
8899
|
+
const resolvedPath = (0, import_node_path12.resolve)(csvPath);
|
|
8900
|
+
const size = (0, import_node_fs10.statSync)(resolvedPath).size;
|
|
8901
|
+
const fd = (0, import_node_fs10.openSync)(resolvedPath, "r");
|
|
8776
8902
|
const byteLength = Math.min(size, CSV_HEADER_SAMPLE_BYTES);
|
|
8777
8903
|
const buffer = Buffer.alloc(byteLength);
|
|
8778
|
-
const bytesRead = (0,
|
|
8779
|
-
(0,
|
|
8904
|
+
const bytesRead = (0, import_node_fs10.readSync)(fd, buffer, 0, byteLength, 0);
|
|
8905
|
+
(0, import_node_fs10.closeSync)(fd);
|
|
8780
8906
|
if (bytesRead === 0) {
|
|
8781
8907
|
throw new PlayBootstrapUsageError(`--from csv:${csvPath} is empty.`);
|
|
8782
8908
|
}
|
|
@@ -8845,9 +8971,9 @@ ${properties}
|
|
|
8845
8971
|
}
|
|
8846
8972
|
function packagedCsvPathForPlay(csvPath) {
|
|
8847
8973
|
const playDir = process.cwd();
|
|
8848
|
-
const absoluteCsvPath = (0,
|
|
8849
|
-
const relativePath = (0,
|
|
8850
|
-
if (relativePath === "" || relativePath.startsWith("..") || (0,
|
|
8974
|
+
const absoluteCsvPath = (0, import_node_path12.resolve)(csvPath);
|
|
8975
|
+
const relativePath = (0, import_node_path12.relative)(playDir, absoluteCsvPath);
|
|
8976
|
+
if (relativePath === "" || relativePath.startsWith("..") || (0, import_node_path12.isAbsolute)(relativePath)) {
|
|
8851
8977
|
throw new PlayBootstrapUsageError(
|
|
8852
8978
|
`--from csv:${csvPath} must point to a file inside the directory where you run plays bootstrap. Run bootstrap from the intended play directory and write the play with --out there.`
|
|
8853
8979
|
);
|
|
@@ -9766,8 +9892,8 @@ async function runPlayBootstrap(args) {
|
|
|
9766
9892
|
...csvContext
|
|
9767
9893
|
});
|
|
9768
9894
|
if (options.out) {
|
|
9769
|
-
(0,
|
|
9770
|
-
process.stdout.write(`Wrote ${(0,
|
|
9895
|
+
(0, import_node_fs10.writeFileSync)((0, import_node_path12.resolve)(options.out), source, "utf-8");
|
|
9896
|
+
process.stdout.write(`Wrote ${(0, import_node_path12.resolve)(options.out)}
|
|
9771
9897
|
`);
|
|
9772
9898
|
return 0;
|
|
9773
9899
|
}
|
|
@@ -10215,7 +10341,7 @@ function formatPlayListReference(play) {
|
|
|
10215
10341
|
return play.reference || play.name;
|
|
10216
10342
|
}
|
|
10217
10343
|
function defaultMaterializedPlayPath(reference) {
|
|
10218
|
-
return (0,
|
|
10344
|
+
return (0, import_node_path13.resolve)(defaultStarterPlayPath(reference));
|
|
10219
10345
|
}
|
|
10220
10346
|
function defaultStarterPlayPath(reference) {
|
|
10221
10347
|
const playName = parseReferencedPlayTarget2(reference).unqualifiedPlayName;
|
|
@@ -10241,15 +10367,15 @@ function materializeRemotePlaySource(input2) {
|
|
|
10241
10367
|
return null;
|
|
10242
10368
|
}
|
|
10243
10369
|
const outputPath = input2.outPath ?? defaultMaterializedPlayPath(input2.playName);
|
|
10244
|
-
if ((0,
|
|
10245
|
-
const existingSource = (0,
|
|
10370
|
+
if ((0, import_node_fs11.existsSync)(outputPath)) {
|
|
10371
|
+
const existingSource = (0, import_node_fs11.readFileSync)(outputPath, "utf-8");
|
|
10246
10372
|
if (existingSource === input2.sourceCode) {
|
|
10247
10373
|
return { path: outputPath, status: "unchanged", created: false };
|
|
10248
10374
|
}
|
|
10249
|
-
(0,
|
|
10375
|
+
(0, import_node_fs11.writeFileSync)(outputPath, input2.sourceCode, "utf-8");
|
|
10250
10376
|
return { path: outputPath, status: "updated", created: false };
|
|
10251
10377
|
}
|
|
10252
|
-
(0,
|
|
10378
|
+
(0, import_node_fs11.writeFileSync)(outputPath, input2.sourceCode, "utf-8");
|
|
10253
10379
|
return { path: outputPath, status: "created", created: true };
|
|
10254
10380
|
}
|
|
10255
10381
|
function formatLoadedPlayMessage(materializedFile) {
|
|
@@ -10294,7 +10420,7 @@ function extractPlayName(code, filePath) {
|
|
|
10294
10420
|
throw buildMissingDefinePlayError(filePath);
|
|
10295
10421
|
}
|
|
10296
10422
|
function isFileTarget(target) {
|
|
10297
|
-
return (0,
|
|
10423
|
+
return (0, import_node_fs11.existsSync)((0, import_node_path13.resolve)(target));
|
|
10298
10424
|
}
|
|
10299
10425
|
function looksLikeRunId(target) {
|
|
10300
10426
|
return /^play\/[^/]+\/run\/[^/]+/.test(target.trim());
|
|
@@ -10323,7 +10449,7 @@ function parsePositiveInteger3(value, flagName) {
|
|
|
10323
10449
|
return parsed;
|
|
10324
10450
|
}
|
|
10325
10451
|
function parseJsonInput(raw) {
|
|
10326
|
-
const source = raw.startsWith("@") ? (0,
|
|
10452
|
+
const source = raw.startsWith("@") ? (0, import_node_fs11.readFileSync)((0, import_node_path13.resolve)(raw.slice(1)), "utf-8") : raw;
|
|
10327
10453
|
const parsed = JSON.parse(source);
|
|
10328
10454
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
10329
10455
|
throw new Error("--input must be a JSON object.");
|
|
@@ -10425,7 +10551,7 @@ function fileInputBindingsFromStaticPipeline(staticPipeline) {
|
|
|
10425
10551
|
function isLocalFilePathValue(value) {
|
|
10426
10552
|
if (typeof value !== "string" || !value.trim()) return false;
|
|
10427
10553
|
if (/^[a-z][a-z0-9+.-]*:\/\//i.test(value.trim())) return false;
|
|
10428
|
-
return (0,
|
|
10554
|
+
return (0, import_node_fs11.existsSync)((0, import_node_path13.resolve)(value));
|
|
10429
10555
|
}
|
|
10430
10556
|
function inputContainsLocalFilePath(value) {
|
|
10431
10557
|
if (isLocalFilePathValue(value)) {
|
|
@@ -10441,6 +10567,15 @@ function inputContainsLocalFilePath(value) {
|
|
|
10441
10567
|
}
|
|
10442
10568
|
return false;
|
|
10443
10569
|
}
|
|
10570
|
+
function sourceGraphMentionsRunPlay(node) {
|
|
10571
|
+
const runPlayCallPattern = /\brunPlay\b/;
|
|
10572
|
+
if (runPlayCallPattern.test(node.sourceCode)) {
|
|
10573
|
+
return true;
|
|
10574
|
+
}
|
|
10575
|
+
return Object.values(node.sourceFiles).some(
|
|
10576
|
+
(source) => runPlayCallPattern.test(source)
|
|
10577
|
+
);
|
|
10578
|
+
}
|
|
10444
10579
|
function isUrlValue(value) {
|
|
10445
10580
|
return /^[a-z][a-z0-9+.-]*:\/\//i.test(value.trim());
|
|
10446
10581
|
}
|
|
@@ -10463,7 +10598,7 @@ function collectLocalFileInputRefs(value, inputPath, key, out) {
|
|
|
10463
10598
|
const looksLikeFile = /\.[a-z0-9]{1,8}$/i.test(trimmed);
|
|
10464
10599
|
if (keyIsCsvData) {
|
|
10465
10600
|
out.push({ inputPath, value: trimmed, isCsvData: true });
|
|
10466
|
-
} else if (endsWithCsv || looksLikeFile && (0,
|
|
10601
|
+
} else if (endsWithCsv || looksLikeFile && (0, import_node_fs11.existsSync)((0, import_node_path13.resolve)(trimmed))) {
|
|
10467
10602
|
out.push({ inputPath, value: trimmed, isCsvData: false });
|
|
10468
10603
|
}
|
|
10469
10604
|
return;
|
|
@@ -10505,8 +10640,8 @@ function preflightLocalFileInputs(runtimeInput) {
|
|
|
10505
10640
|
collectLocalFileInputRefs(value, key, key, refs);
|
|
10506
10641
|
}
|
|
10507
10642
|
for (const ref of refs) {
|
|
10508
|
-
const absolutePath = (0,
|
|
10509
|
-
if (!(0,
|
|
10643
|
+
const absolutePath = (0, import_node_path13.resolve)(ref.value);
|
|
10644
|
+
if (!(0, import_node_fs11.existsSync)(absolutePath)) {
|
|
10510
10645
|
throw new DeeplineError(
|
|
10511
10646
|
`Input ${ref.inputPath} references a local file that does not exist: ${ref.value} (resolved to ${absolutePath}). No run was created.`,
|
|
10512
10647
|
void 0,
|
|
@@ -10516,7 +10651,7 @@ function preflightLocalFileInputs(runtimeInput) {
|
|
|
10516
10651
|
}
|
|
10517
10652
|
let stat4;
|
|
10518
10653
|
try {
|
|
10519
|
-
stat4 = (0,
|
|
10654
|
+
stat4 = (0, import_node_fs11.statSync)(absolutePath);
|
|
10520
10655
|
} catch (error) {
|
|
10521
10656
|
throw new DeeplineError(
|
|
10522
10657
|
`Input ${ref.inputPath} references a local file that is not readable: ${ref.value} (${error instanceof Error ? error.message : String(error)}). No run was created.`,
|
|
@@ -10542,7 +10677,7 @@ function preflightLocalFileInputs(runtimeInput) {
|
|
|
10542
10677
|
function preflightCsvDataInput(ref, absolutePath) {
|
|
10543
10678
|
let content;
|
|
10544
10679
|
try {
|
|
10545
|
-
content = (0,
|
|
10680
|
+
content = (0, import_node_fs11.readFileSync)(absolutePath, "utf-8");
|
|
10546
10681
|
} catch (error) {
|
|
10547
10682
|
throw new DeeplineError(
|
|
10548
10683
|
`Input ${ref.inputPath} CSV ${ref.value} is not readable: ${error instanceof Error ? error.message : String(error)}. No run was created.`,
|
|
@@ -10624,8 +10759,8 @@ async function stageFileInputArgs(input2) {
|
|
|
10624
10759
|
const localFiles = uniqueBindings.flatMap((binding) => {
|
|
10625
10760
|
const value = getDottedInputValue(input2.runtimeInput, binding.inputPath);
|
|
10626
10761
|
if (!isLocalFilePathValue(value)) return [];
|
|
10627
|
-
const absolutePath = (0,
|
|
10628
|
-
return [{ binding, absolutePath, logicalPath: (0,
|
|
10762
|
+
const absolutePath = (0, import_node_path13.resolve)(value);
|
|
10763
|
+
return [{ binding, absolutePath, logicalPath: (0, import_node_path13.basename)(absolutePath) }];
|
|
10629
10764
|
});
|
|
10630
10765
|
if (localFiles.length === 0) {
|
|
10631
10766
|
return { inputFile: null, packagedFiles: [] };
|
|
@@ -10657,7 +10792,7 @@ async function stageFileInputArgs(input2) {
|
|
|
10657
10792
|
};
|
|
10658
10793
|
}
|
|
10659
10794
|
function stageFile(logicalPath, absolutePath) {
|
|
10660
|
-
const buffer = (0,
|
|
10795
|
+
const buffer = (0, import_node_fs11.readFileSync)(absolutePath);
|
|
10661
10796
|
return {
|
|
10662
10797
|
logicalPath,
|
|
10663
10798
|
contentBase64: buffer.toString("base64"),
|
|
@@ -10668,9 +10803,9 @@ function stageFile(logicalPath, absolutePath) {
|
|
|
10668
10803
|
}
|
|
10669
10804
|
function normalizePlayPath(filePath) {
|
|
10670
10805
|
try {
|
|
10671
|
-
return
|
|
10806
|
+
return import_node_fs11.realpathSync.native((0, import_node_path13.resolve)(filePath));
|
|
10672
10807
|
} catch {
|
|
10673
|
-
return (0,
|
|
10808
|
+
return (0, import_node_path13.resolve)(filePath);
|
|
10674
10809
|
}
|
|
10675
10810
|
}
|
|
10676
10811
|
function formatBundlingErrors(filePath, errors) {
|
|
@@ -12626,7 +12761,7 @@ function shellSingleQuote(value) {
|
|
|
12626
12761
|
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
12627
12762
|
}
|
|
12628
12763
|
function runExportRetryCommand(runId, outPath, datasetPath) {
|
|
12629
|
-
return `deepline runs export ${runId}${datasetPath ? ` --dataset ${shellSingleQuote(datasetPath)}` : ""} --out ${shellSingleQuote((0,
|
|
12764
|
+
return `deepline runs export ${runId}${datasetPath ? ` --dataset ${shellSingleQuote(datasetPath)}` : ""} --out ${shellSingleQuote((0, import_node_path13.resolve)(outPath))}`;
|
|
12630
12765
|
}
|
|
12631
12766
|
function extractRunPlayName(status) {
|
|
12632
12767
|
const run = status.run;
|
|
@@ -13430,7 +13565,7 @@ async function handlePlayCheck(args) {
|
|
|
13430
13565
|
}
|
|
13431
13566
|
return 0;
|
|
13432
13567
|
} catch (error) {
|
|
13433
|
-
const resolved = (0,
|
|
13568
|
+
const resolved = (0, import_node_path13.resolve)(options.target);
|
|
13434
13569
|
const message = error instanceof Error && error.message ? error.message : `File not found: ${resolved}`;
|
|
13435
13570
|
if (options.jsonOutput) {
|
|
13436
13571
|
process.stdout.write(
|
|
@@ -13447,8 +13582,8 @@ async function handlePlayCheck(args) {
|
|
|
13447
13582
|
return 1;
|
|
13448
13583
|
}
|
|
13449
13584
|
}
|
|
13450
|
-
const absolutePlayPath = (0,
|
|
13451
|
-
const sourceCode = (0,
|
|
13585
|
+
const absolutePlayPath = (0, import_node_path13.resolve)(options.target);
|
|
13586
|
+
const sourceCode = (0, import_node_fs11.readFileSync)(absolutePlayPath, "utf-8");
|
|
13452
13587
|
let graph;
|
|
13453
13588
|
try {
|
|
13454
13589
|
graph = await collectBundledPlayGraph(absolutePlayPath);
|
|
@@ -13527,12 +13662,12 @@ async function handleFileBackedRun(options) {
|
|
|
13527
13662
|
}
|
|
13528
13663
|
const client2 = new DeeplineClient();
|
|
13529
13664
|
const progress = getActiveCliProgress() ?? createCliProgress(!options.jsonOutput);
|
|
13530
|
-
const absolutePlayPath = (0,
|
|
13665
|
+
const absolutePlayPath = (0, import_node_path13.resolve)(options.target.path);
|
|
13531
13666
|
progress.phase("compiling play");
|
|
13532
13667
|
const sourceCode = traceCliSync(
|
|
13533
13668
|
"cli.play_file_read_source",
|
|
13534
13669
|
{ targetKind: "file" },
|
|
13535
|
-
() => (0,
|
|
13670
|
+
() => (0, import_node_fs11.readFileSync)(absolutePlayPath, "utf-8")
|
|
13536
13671
|
);
|
|
13537
13672
|
const runtimeInput = options.input ? { ...options.input } : {};
|
|
13538
13673
|
try {
|
|
@@ -13548,11 +13683,23 @@ async function handleFileBackedRun(options) {
|
|
|
13548
13683
|
{ targetKind: "file" },
|
|
13549
13684
|
() => collectBundledPlayGraph(absolutePlayPath, options.profile)
|
|
13550
13685
|
);
|
|
13551
|
-
|
|
13552
|
-
|
|
13553
|
-
{
|
|
13554
|
-
|
|
13555
|
-
|
|
13686
|
+
const canDeferCompilerManifest = graph.root.importedPlayDependencies.length === 0 && !sourceGraphMentionsRunPlay(graph.root) && !inputContainsLocalFilePath(runtimeInput);
|
|
13687
|
+
if (canDeferCompilerManifest) {
|
|
13688
|
+
recordCliTrace({
|
|
13689
|
+
phase: "cli.play_file_compile_manifests",
|
|
13690
|
+
ms: 0,
|
|
13691
|
+
ok: true,
|
|
13692
|
+
targetKind: "file",
|
|
13693
|
+
skipped: true,
|
|
13694
|
+
reason: "validated_by_run_route"
|
|
13695
|
+
});
|
|
13696
|
+
} else {
|
|
13697
|
+
await traceCliSpan(
|
|
13698
|
+
"cli.play_file_compile_manifests",
|
|
13699
|
+
{ targetKind: "file", skipped: false },
|
|
13700
|
+
() => compileBundledPlayGraphManifests(client2, graph)
|
|
13701
|
+
);
|
|
13702
|
+
}
|
|
13556
13703
|
progress.phase("compiled play");
|
|
13557
13704
|
} catch (error) {
|
|
13558
13705
|
progress.fail();
|
|
@@ -13579,9 +13726,9 @@ async function handleFileBackedRun(options) {
|
|
|
13579
13726
|
const packagedFileUploads = bundleResult.packagedFiles.map(
|
|
13580
13727
|
(file) => stageFile(file.logicalPath, file.absolutePath)
|
|
13581
13728
|
);
|
|
13582
|
-
const compilerManifest =
|
|
13729
|
+
const compilerManifest = bundleResult.compilerManifest ?? null;
|
|
13583
13730
|
const fileInputBindings = fileInputBindingsFromStaticPipeline(
|
|
13584
|
-
compilerManifest
|
|
13731
|
+
compilerManifest?.staticPipeline
|
|
13585
13732
|
);
|
|
13586
13733
|
const stagedFileInputs = await traceCliSpan(
|
|
13587
13734
|
"cli.play_stage_inputs",
|
|
@@ -13601,7 +13748,7 @@ async function handleFileBackedRun(options) {
|
|
|
13601
13748
|
sourceCode: bundleResult.sourceCode,
|
|
13602
13749
|
sourceFiles: bundleResult.sourceFiles,
|
|
13603
13750
|
runtimeArtifact: bundleResult.artifact,
|
|
13604
|
-
compilerManifest,
|
|
13751
|
+
...compilerManifest ? { compilerManifest } : {},
|
|
13605
13752
|
packagedFileUploads,
|
|
13606
13753
|
...Object.keys(runtimeInput).length > 0 ? { input: runtimeInput } : {},
|
|
13607
13754
|
...stagedFileInputs.inputFile ? { inputFile: stagedFileInputs.inputFile } : {},
|
|
@@ -13839,19 +13986,19 @@ async function handlePlayRun(args) {
|
|
|
13839
13986
|
if (isFileTarget(options.target.path)) {
|
|
13840
13987
|
return handleFileBackedRun(options);
|
|
13841
13988
|
}
|
|
13842
|
-
const resolved = (0,
|
|
13989
|
+
const resolved = (0, import_node_path13.resolve)(options.target.path);
|
|
13843
13990
|
console.error(`File not found: ${resolved}`);
|
|
13844
|
-
const dir = (0,
|
|
13845
|
-
if ((0,
|
|
13846
|
-
const base = (0,
|
|
13991
|
+
const dir = (0, import_node_path13.dirname)(resolved);
|
|
13992
|
+
if ((0, import_node_fs11.existsSync)(dir)) {
|
|
13993
|
+
const base = (0, import_node_path13.basename)(resolved);
|
|
13847
13994
|
try {
|
|
13848
|
-
const siblings = (0,
|
|
13995
|
+
const siblings = (0, import_node_fs11.readdirSync)(dir).filter(
|
|
13849
13996
|
(f) => f.includes(base.replace(/\.(play\.)?ts$/, "")) || f.endsWith(".play.ts")
|
|
13850
13997
|
);
|
|
13851
13998
|
if (siblings.length > 0) {
|
|
13852
13999
|
console.error(`Did you mean one of these?`);
|
|
13853
14000
|
for (const s of siblings.slice(0, 5)) {
|
|
13854
|
-
console.error(` ${(0,
|
|
14001
|
+
console.error(` ${(0, import_node_path13.join)(dir, s)}`);
|
|
13855
14002
|
}
|
|
13856
14003
|
}
|
|
13857
14004
|
} catch {
|
|
@@ -14006,14 +14153,14 @@ async function handleRunLogs(args) {
|
|
|
14006
14153
|
continue;
|
|
14007
14154
|
}
|
|
14008
14155
|
if (arg === "--out" && args[index + 1]) {
|
|
14009
|
-
outPath = (0,
|
|
14156
|
+
outPath = (0, import_node_path13.resolve)(args[++index]);
|
|
14010
14157
|
}
|
|
14011
14158
|
}
|
|
14012
14159
|
const client2 = new DeeplineClient();
|
|
14013
14160
|
if (outPath) {
|
|
14014
14161
|
const result2 = await client2.runs.logs(runId, { all: true });
|
|
14015
14162
|
const logs = result2.entries;
|
|
14016
|
-
(0,
|
|
14163
|
+
(0, import_node_fs11.writeFileSync)(outPath, `${logs.join("\n")}${logs.length > 0 ? "\n" : ""}`);
|
|
14017
14164
|
printCommandEnvelope(
|
|
14018
14165
|
{
|
|
14019
14166
|
runId: result2.runId,
|
|
@@ -14138,7 +14285,7 @@ async function handleRunExport(args) {
|
|
|
14138
14285
|
for (let index = 0; index < args.length; index += 1) {
|
|
14139
14286
|
const arg = args[index];
|
|
14140
14287
|
if (arg === "--out" && args[index + 1]) {
|
|
14141
|
-
outPath = (0,
|
|
14288
|
+
outPath = (0, import_node_path13.resolve)(args[++index]);
|
|
14142
14289
|
continue;
|
|
14143
14290
|
}
|
|
14144
14291
|
if (arg === "--dataset" && args[index + 1]) {
|
|
@@ -14146,7 +14293,7 @@ async function handleRunExport(args) {
|
|
|
14146
14293
|
continue;
|
|
14147
14294
|
}
|
|
14148
14295
|
if (arg === "--metadata-out" && args[index + 1]) {
|
|
14149
|
-
metadataOutPath = (0,
|
|
14296
|
+
metadataOutPath = (0, import_node_path13.resolve)(args[++index]);
|
|
14150
14297
|
}
|
|
14151
14298
|
}
|
|
14152
14299
|
if (!outPath) {
|
|
@@ -14186,7 +14333,7 @@ async function handleRunExport(args) {
|
|
|
14186
14333
|
}
|
|
14187
14334
|
};
|
|
14188
14335
|
if (metadataOutPath) {
|
|
14189
|
-
(0,
|
|
14336
|
+
(0, import_node_fs11.writeFileSync)(
|
|
14190
14337
|
metadataOutPath,
|
|
14191
14338
|
`${JSON.stringify(payload, null, 2)}
|
|
14192
14339
|
`,
|
|
@@ -14218,10 +14365,10 @@ async function handlePlayGet(args) {
|
|
|
14218
14365
|
for (let index = 1; index < args.length; index += 1) {
|
|
14219
14366
|
const arg = args[index];
|
|
14220
14367
|
if (arg === "--out" && args[index + 1]) {
|
|
14221
|
-
outPath = (0,
|
|
14368
|
+
outPath = (0, import_node_path13.resolve)(args[++index]);
|
|
14222
14369
|
}
|
|
14223
14370
|
}
|
|
14224
|
-
const playName = isFileTarget(target) ? extractPlayName((0,
|
|
14371
|
+
const playName = isFileTarget(target) ? extractPlayName((0, import_node_fs11.readFileSync)((0, import_node_path13.resolve)(target), "utf-8"), (0, import_node_path13.resolve)(target)) : parseReferencedPlayTarget2(target).playName;
|
|
14225
14372
|
const detail = isFileTarget(target) ? await client2.getPlay(playName) : await assertCanonicalNamedPlayReference(client2, target);
|
|
14226
14373
|
const resolvedSource = detail.play.workingRevision?.sourceCode ?? detail.play.liveRevision?.sourceCode ?? detail.play.currentRevision?.sourceCode ?? detail.play.sourceCode ?? "";
|
|
14227
14374
|
const materializedFile = outPath ? materializeRemotePlaySource({
|
|
@@ -14664,7 +14811,7 @@ async function handlePlayDescribe(args) {
|
|
|
14664
14811
|
const definedName = isFileTarget(playName) ? (() => {
|
|
14665
14812
|
try {
|
|
14666
14813
|
return extractPlayName(
|
|
14667
|
-
(0,
|
|
14814
|
+
(0, import_node_fs11.readFileSync)((0, import_node_path13.resolve)(playName), "utf-8"),
|
|
14668
14815
|
playName
|
|
14669
14816
|
);
|
|
14670
14817
|
} catch {
|
|
@@ -14745,7 +14892,7 @@ async function handlePlayPublish(args) {
|
|
|
14745
14892
|
graph = await traceCliSpan(
|
|
14746
14893
|
"cli.play_publish_bundle_graph",
|
|
14747
14894
|
{ targetKind: "file" },
|
|
14748
|
-
() => collectBundledPlayGraph((0,
|
|
14895
|
+
() => collectBundledPlayGraph((0, import_node_path13.resolve)(playName))
|
|
14749
14896
|
);
|
|
14750
14897
|
await traceCliSpan(
|
|
14751
14898
|
"cli.play_publish_compile_manifests",
|
|
@@ -16994,10 +17141,10 @@ function expandAtFilePath(rawPath) {
|
|
|
16994
17141
|
(_match, bareName, bracedName) => process.env[bareName ?? bracedName ?? ""] ?? ""
|
|
16995
17142
|
);
|
|
16996
17143
|
if (expanded === "~") {
|
|
16997
|
-
return (0,
|
|
17144
|
+
return (0, import_node_os8.homedir)();
|
|
16998
17145
|
}
|
|
16999
17146
|
if (expanded.startsWith("~/") || expanded.startsWith("~\\")) {
|
|
17000
|
-
return (0,
|
|
17147
|
+
return (0, import_node_path14.join)((0, import_node_os8.homedir)(), expanded.slice(2));
|
|
17001
17148
|
}
|
|
17002
17149
|
return expanded;
|
|
17003
17150
|
}
|
|
@@ -17181,7 +17328,7 @@ async function buildPlanArgs(args) {
|
|
|
17181
17328
|
return planArgs;
|
|
17182
17329
|
}
|
|
17183
17330
|
async function assertInputCsvExists(inputCsv) {
|
|
17184
|
-
const path = (0,
|
|
17331
|
+
const path = (0, import_node_path14.resolve)(inputCsv);
|
|
17185
17332
|
try {
|
|
17186
17333
|
const info = await (0, import_promises5.stat)(path);
|
|
17187
17334
|
if (info.isFile()) {
|
|
@@ -17195,8 +17342,8 @@ async function assertInputCsvExists(inputCsv) {
|
|
|
17195
17342
|
}
|
|
17196
17343
|
}
|
|
17197
17344
|
async function assertSafeOutputPath(inputCsv, outputPath) {
|
|
17198
|
-
const input2 = (0,
|
|
17199
|
-
const output2 = (0,
|
|
17345
|
+
const input2 = (0, import_node_path14.resolve)(inputCsv);
|
|
17346
|
+
const output2 = (0, import_node_path14.resolve)(outputPath);
|
|
17200
17347
|
if (input2 === output2) {
|
|
17201
17348
|
throw new Error(
|
|
17202
17349
|
"--input and --output must be different files when not using --in-place."
|
|
@@ -17225,7 +17372,7 @@ async function assertSafeOutputPath(inputCsv, outputPath) {
|
|
|
17225
17372
|
}
|
|
17226
17373
|
async function regularFileExists(path) {
|
|
17227
17374
|
try {
|
|
17228
|
-
const info = await (0, import_promises5.stat)((0,
|
|
17375
|
+
const info = await (0, import_promises5.stat)((0, import_node_path14.resolve)(path));
|
|
17229
17376
|
return info.isFile();
|
|
17230
17377
|
} catch (error) {
|
|
17231
17378
|
const code = error && typeof error === "object" ? error.code : void 0;
|
|
@@ -17236,7 +17383,7 @@ async function regularFileExists(path) {
|
|
|
17236
17383
|
}
|
|
17237
17384
|
}
|
|
17238
17385
|
async function readConfig(path) {
|
|
17239
|
-
const source = await (0, import_promises5.readFile)((0,
|
|
17386
|
+
const source = await (0, import_promises5.readFile)((0, import_node_path14.resolve)(path), "utf8");
|
|
17240
17387
|
let parsed;
|
|
17241
17388
|
try {
|
|
17242
17389
|
parsed = JSON.parse(source);
|
|
@@ -17553,7 +17700,7 @@ async function writeOutputCsv(outputPath, status, options) {
|
|
|
17553
17700
|
options?.config
|
|
17554
17701
|
);
|
|
17555
17702
|
await (0, import_promises5.writeFile)(
|
|
17556
|
-
(0,
|
|
17703
|
+
(0, import_node_path14.resolve)(outputPath),
|
|
17557
17704
|
csvStringFromRows(merged.rows, columns),
|
|
17558
17705
|
"utf8"
|
|
17559
17706
|
);
|
|
@@ -17563,7 +17710,7 @@ async function writeOutputCsv(outputPath, status, options) {
|
|
|
17563
17710
|
selectedRows: rowsInfo.totalRows,
|
|
17564
17711
|
enrichedRows: rowsInfo.rows.length,
|
|
17565
17712
|
rows: merged.rows.length,
|
|
17566
|
-
path: (0,
|
|
17713
|
+
path: (0, import_node_path14.resolve)(outputPath),
|
|
17567
17714
|
enrichedDataRows: rowsInfo.rows
|
|
17568
17715
|
};
|
|
17569
17716
|
}
|
|
@@ -17858,9 +18005,9 @@ async function persistEnrichFailureReport(input2) {
|
|
|
17858
18005
|
if (input2.jobs.length === 0) {
|
|
17859
18006
|
return null;
|
|
17860
18007
|
}
|
|
17861
|
-
const stateDir = (0,
|
|
18008
|
+
const stateDir = (0, import_node_path14.join)((0, import_node_os8.homedir)(), ".local", "deepline", "runtime", "state");
|
|
17862
18009
|
await (0, import_promises5.mkdir)(stateDir, { recursive: true });
|
|
17863
|
-
const reportPath = (0,
|
|
18010
|
+
const reportPath = (0, import_node_path14.join)(
|
|
17864
18011
|
stateDir,
|
|
17865
18012
|
`run-block-failures-${Math.floor(Date.now() / 1e3)}-${process.pid}.json`
|
|
17866
18013
|
);
|
|
@@ -18297,8 +18444,8 @@ function registerEnrichCommand(program) {
|
|
|
18297
18444
|
if (options.json) {
|
|
18298
18445
|
printJson({
|
|
18299
18446
|
dryRun: true,
|
|
18300
|
-
input: (0,
|
|
18301
|
-
output: options.output ? (0,
|
|
18447
|
+
input: (0, import_node_path14.resolve)(inputCsv),
|
|
18448
|
+
output: options.output ? (0, import_node_path14.resolve)(options.output) : null,
|
|
18302
18449
|
plan: summary
|
|
18303
18450
|
});
|
|
18304
18451
|
return;
|
|
@@ -18322,12 +18469,12 @@ function registerEnrichCommand(program) {
|
|
|
18322
18469
|
forceAliases,
|
|
18323
18470
|
playName: options.name
|
|
18324
18471
|
});
|
|
18325
|
-
const tempDir = await (0, import_promises5.mkdtemp)((0,
|
|
18326
|
-
const tempPlay = (0,
|
|
18472
|
+
const tempDir = await (0, import_promises5.mkdtemp)((0, import_node_path14.join)((0, import_node_os8.tmpdir)(), "deepline-enrich-play-"));
|
|
18473
|
+
const tempPlay = (0, import_node_path14.join)(tempDir, "deepline-enrich.play.ts");
|
|
18327
18474
|
try {
|
|
18328
18475
|
await (0, import_promises5.writeFile)(tempPlay, playSource, "utf8");
|
|
18329
18476
|
const runtimeInput = {
|
|
18330
|
-
file: (0,
|
|
18477
|
+
file: (0, import_node_path14.resolve)(sourceCsvPath),
|
|
18331
18478
|
...rows.rowStart !== null ? { rowStart: rows.rowStart } : {},
|
|
18332
18479
|
...rows.rowEnd !== null ? { rowEnd: rows.rowEnd } : {}
|
|
18333
18480
|
};
|
|
@@ -18488,9 +18635,9 @@ Examples:
|
|
|
18488
18635
|
}
|
|
18489
18636
|
|
|
18490
18637
|
// src/cli/commands/sessions.ts
|
|
18491
|
-
var
|
|
18492
|
-
var
|
|
18493
|
-
var
|
|
18638
|
+
var import_node_fs12 = require("fs");
|
|
18639
|
+
var import_node_os9 = require("os");
|
|
18640
|
+
var import_node_path15 = require("path");
|
|
18494
18641
|
var import_node_zlib = require("zlib");
|
|
18495
18642
|
var import_node_crypto4 = require("crypto");
|
|
18496
18643
|
var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
@@ -18504,33 +18651,33 @@ var MAX_EVENT_OBJECT_KEYS = 80;
|
|
|
18504
18651
|
var TRUNCATION_MARKER = "...[truncated]";
|
|
18505
18652
|
var NOISE_EVENT_TYPES = /* @__PURE__ */ new Set(["progress", "file-history-snapshot"]);
|
|
18506
18653
|
function homeDir() {
|
|
18507
|
-
return process.env.HOME?.trim() || (0,
|
|
18654
|
+
return process.env.HOME?.trim() || (0, import_node_os9.homedir)();
|
|
18508
18655
|
}
|
|
18509
18656
|
function detectShellContext() {
|
|
18510
18657
|
const shellPath = process.env.SHELL?.trim() || process.env.ComSpec?.trim() || process.env.COMSPEC?.trim() || "";
|
|
18511
18658
|
return {
|
|
18512
|
-
shell: shellPath ? (0,
|
|
18659
|
+
shell: shellPath ? (0, import_node_path15.basename)(shellPath).replace(/\.exe$/i, "") : "unknown",
|
|
18513
18660
|
shell_path: shellPath || null,
|
|
18514
|
-
os: (0,
|
|
18661
|
+
os: (0, import_node_os9.platform)(),
|
|
18515
18662
|
cwd: process.cwd()
|
|
18516
18663
|
};
|
|
18517
18664
|
}
|
|
18518
18665
|
function claudeProjectsRoot() {
|
|
18519
|
-
return (0,
|
|
18666
|
+
return (0, import_node_path15.join)(homeDir(), ".claude", "projects");
|
|
18520
18667
|
}
|
|
18521
18668
|
function codexSessionsRoot() {
|
|
18522
|
-
return (0,
|
|
18669
|
+
return (0, import_node_path15.join)(homeDir(), ".codex", "sessions");
|
|
18523
18670
|
}
|
|
18524
18671
|
function listClaudeSessionFiles() {
|
|
18525
18672
|
const root = claudeProjectsRoot();
|
|
18526
|
-
if (!(0,
|
|
18673
|
+
if (!(0, import_node_fs12.existsSync)(root)) return [];
|
|
18527
18674
|
const projectDirs = readDirectoryNames(root);
|
|
18528
18675
|
const files = [];
|
|
18529
18676
|
for (const projectDir of projectDirs) {
|
|
18530
|
-
const fullProjectDir = (0,
|
|
18677
|
+
const fullProjectDir = (0, import_node_path15.join)(root, projectDir);
|
|
18531
18678
|
for (const fileName of readDirectoryNames(fullProjectDir)) {
|
|
18532
18679
|
if (fileName.endsWith(".jsonl")) {
|
|
18533
|
-
const filePath = (0,
|
|
18680
|
+
const filePath = (0, import_node_path15.join)(fullProjectDir, fileName);
|
|
18534
18681
|
const sessionId = sessionIdFromClaudeFilePath(filePath);
|
|
18535
18682
|
const stat4 = statIfReadable(filePath);
|
|
18536
18683
|
if (sessionId && stat4) {
|
|
@@ -18548,7 +18695,7 @@ function listClaudeSessionFiles() {
|
|
|
18548
18695
|
}
|
|
18549
18696
|
function listCodexSessionFiles() {
|
|
18550
18697
|
const root = codexSessionsRoot();
|
|
18551
|
-
if (!(0,
|
|
18698
|
+
if (!(0, import_node_fs12.existsSync)(root)) return [];
|
|
18552
18699
|
const files = [];
|
|
18553
18700
|
for (const filePath of listJsonlFilesRecursive(root, 5)) {
|
|
18554
18701
|
const stat4 = statIfReadable(filePath);
|
|
@@ -18571,7 +18718,7 @@ function listSessionFiles(agent) {
|
|
|
18571
18718
|
}
|
|
18572
18719
|
function readDirectoryNames(dir) {
|
|
18573
18720
|
try {
|
|
18574
|
-
return (0,
|
|
18721
|
+
return (0, import_node_fs12.readdirSync)(dir);
|
|
18575
18722
|
} catch {
|
|
18576
18723
|
return [];
|
|
18577
18724
|
}
|
|
@@ -18582,12 +18729,12 @@ function listJsonlFilesRecursive(root, maxDepth) {
|
|
|
18582
18729
|
if (depth > maxDepth) return;
|
|
18583
18730
|
let entries;
|
|
18584
18731
|
try {
|
|
18585
|
-
entries = (0,
|
|
18732
|
+
entries = (0, import_node_fs12.readdirSync)(dir, { withFileTypes: true });
|
|
18586
18733
|
} catch {
|
|
18587
18734
|
return;
|
|
18588
18735
|
}
|
|
18589
18736
|
for (const entry of entries) {
|
|
18590
|
-
const fullPath = (0,
|
|
18737
|
+
const fullPath = (0, import_node_path15.join)(dir, entry.name);
|
|
18591
18738
|
if (entry.isDirectory()) {
|
|
18592
18739
|
visit(fullPath, depth + 1);
|
|
18593
18740
|
} else if (entry.isFile() && entry.name.endsWith(".jsonl")) {
|
|
@@ -18600,7 +18747,7 @@ function listJsonlFilesRecursive(root, maxDepth) {
|
|
|
18600
18747
|
}
|
|
18601
18748
|
function statIfReadable(filePath) {
|
|
18602
18749
|
try {
|
|
18603
|
-
return (0,
|
|
18750
|
+
return (0, import_node_fs12.statSync)(filePath);
|
|
18604
18751
|
} catch {
|
|
18605
18752
|
return null;
|
|
18606
18753
|
}
|
|
@@ -18615,15 +18762,15 @@ function newestSessionFile(agent) {
|
|
|
18615
18762
|
return newest;
|
|
18616
18763
|
}
|
|
18617
18764
|
function sessionIdFromClaudeFilePath(filePath) {
|
|
18618
|
-
return (0,
|
|
18765
|
+
return (0, import_node_path15.basename)(filePath, ".jsonl");
|
|
18619
18766
|
}
|
|
18620
18767
|
function sessionIdFromCodexFilePath(filePath) {
|
|
18621
|
-
const match = (0,
|
|
18768
|
+
const match = (0, import_node_path15.basename)(filePath, ".jsonl").match(UUID_IN_TEXT_RE);
|
|
18622
18769
|
return match?.[0] ?? null;
|
|
18623
18770
|
}
|
|
18624
18771
|
function readCodexSessionId(filePath) {
|
|
18625
18772
|
try {
|
|
18626
|
-
for (const line of normalizedJsonLines((0,
|
|
18773
|
+
for (const line of normalizedJsonLines((0, import_node_fs12.readFileSync)(filePath)).slice(
|
|
18627
18774
|
0,
|
|
18628
18775
|
20
|
|
18629
18776
|
)) {
|
|
@@ -18900,25 +19047,25 @@ async function uploadChunkedSessions(sessions, options) {
|
|
|
18900
19047
|
}
|
|
18901
19048
|
async function handleSessionsSend(options) {
|
|
18902
19049
|
if (options.file) {
|
|
18903
|
-
const filePath = (0,
|
|
18904
|
-
if (!(0,
|
|
19050
|
+
const filePath = (0, import_node_path15.resolve)(options.file);
|
|
19051
|
+
if (!(0, import_node_fs12.existsSync)(filePath)) {
|
|
18905
19052
|
throw new Error(`File not found: ${options.file}`);
|
|
18906
19053
|
}
|
|
18907
19054
|
const response2 = await uploadPayload("/api/v2/cli/send-session", {
|
|
18908
|
-
file: (0,
|
|
18909
|
-
filename: (0,
|
|
19055
|
+
file: (0, import_node_fs12.readFileSync)(filePath).toString("base64"),
|
|
19056
|
+
filename: (0, import_node_path15.basename)(filePath)
|
|
18910
19057
|
});
|
|
18911
19058
|
printCommandEnvelope(
|
|
18912
19059
|
{
|
|
18913
19060
|
...response2,
|
|
18914
19061
|
ok: true,
|
|
18915
|
-
filename: (0,
|
|
19062
|
+
filename: (0, import_node_path15.basename)(filePath),
|
|
18916
19063
|
render: {
|
|
18917
19064
|
sections: [
|
|
18918
19065
|
{
|
|
18919
19066
|
title: "sessions send",
|
|
18920
19067
|
lines: [
|
|
18921
|
-
`File '${(0,
|
|
19068
|
+
`File '${(0, import_node_path15.basename)(filePath)}' uploaded to #internal-reports.`
|
|
18922
19069
|
]
|
|
18923
19070
|
}
|
|
18924
19071
|
]
|
|
@@ -18935,7 +19082,7 @@ async function handleSessionsSend(options) {
|
|
|
18935
19082
|
agent: options.agent
|
|
18936
19083
|
});
|
|
18937
19084
|
const built = targets.map((target) => {
|
|
18938
|
-
const upload = buildSessionUploadContent((0,
|
|
19085
|
+
const upload = buildSessionUploadContent((0, import_node_fs12.readFileSync)(target.filePath));
|
|
18939
19086
|
return { ...target, ...upload };
|
|
18940
19087
|
});
|
|
18941
19088
|
if (built.some((session) => session.needsChunking)) {
|
|
@@ -18999,28 +19146,28 @@ function fallbackViewerAssets() {
|
|
|
18999
19146
|
};
|
|
19000
19147
|
}
|
|
19001
19148
|
function loadViewerAssets() {
|
|
19002
|
-
const cliEntry = process.argv[1]?.trim() ? (0,
|
|
19149
|
+
const cliEntry = process.argv[1]?.trim() ? (0, import_node_path15.resolve)(process.argv[1]) : null;
|
|
19003
19150
|
const candidateRoots2 = [
|
|
19004
19151
|
...cliEntry ? [
|
|
19005
|
-
(0,
|
|
19006
|
-
(0,
|
|
19007
|
-
(0,
|
|
19152
|
+
(0, import_node_path15.join)((0, import_node_path15.dirname)((0, import_node_path15.dirname)(cliEntry)), "viewer"),
|
|
19153
|
+
(0, import_node_path15.join)(
|
|
19154
|
+
(0, import_node_path15.dirname)((0, import_node_path15.dirname)((0, import_node_path15.dirname)(cliEntry))),
|
|
19008
19155
|
"src",
|
|
19009
19156
|
"lib",
|
|
19010
19157
|
"cli",
|
|
19011
19158
|
"viewer"
|
|
19012
19159
|
)
|
|
19013
19160
|
] : [],
|
|
19014
|
-
(0,
|
|
19161
|
+
(0, import_node_path15.join)(process.cwd(), "src", "lib", "cli", "viewer")
|
|
19015
19162
|
];
|
|
19016
19163
|
for (const root of candidateRoots2) {
|
|
19017
19164
|
try {
|
|
19018
|
-
const cssPath = (0,
|
|
19019
|
-
const jsPath = (0,
|
|
19020
|
-
if (!(0,
|
|
19165
|
+
const cssPath = (0, import_node_path15.join)(root, "viewer.css");
|
|
19166
|
+
const jsPath = (0, import_node_path15.join)(root, "viewer.js");
|
|
19167
|
+
if (!(0, import_node_fs12.existsSync)(cssPath) || !(0, import_node_fs12.existsSync)(jsPath)) continue;
|
|
19021
19168
|
return {
|
|
19022
|
-
css: (0,
|
|
19023
|
-
js: (0,
|
|
19169
|
+
css: (0, import_node_fs12.readFileSync)(cssPath, "utf8"),
|
|
19170
|
+
js: (0, import_node_fs12.readFileSync)(jsPath, "utf8")
|
|
19024
19171
|
};
|
|
19025
19172
|
} catch {
|
|
19026
19173
|
continue;
|
|
@@ -19044,21 +19191,21 @@ async function handleSessionsRender(options) {
|
|
|
19044
19191
|
currentSession: options.currentSession,
|
|
19045
19192
|
agent: options.agent
|
|
19046
19193
|
});
|
|
19047
|
-
let outputPath = options.output ? (0,
|
|
19194
|
+
let outputPath = options.output ? (0, import_node_path15.resolve)(options.output) : "";
|
|
19048
19195
|
if (!outputPath) {
|
|
19049
|
-
const outputDir = (0,
|
|
19050
|
-
(0,
|
|
19051
|
-
outputPath = (0,
|
|
19196
|
+
const outputDir = (0, import_node_path15.join)(process.cwd(), "deepline", "data");
|
|
19197
|
+
(0, import_node_fs12.mkdirSync)(outputDir, { recursive: true });
|
|
19198
|
+
outputPath = (0, import_node_path15.join)(
|
|
19052
19199
|
outputDir,
|
|
19053
19200
|
targets.length > 1 ? "session-viewer.html" : `session-${targets[0]?.sessionId}.html`
|
|
19054
19201
|
);
|
|
19055
19202
|
} else {
|
|
19056
|
-
(0,
|
|
19203
|
+
(0, import_node_fs12.mkdirSync)((0, import_node_path15.dirname)(outputPath), { recursive: true });
|
|
19057
19204
|
}
|
|
19058
19205
|
const sessions = targets.map((target) => ({
|
|
19059
19206
|
label: target.label,
|
|
19060
19207
|
events: parsePreparedEvents(
|
|
19061
|
-
prepareSessionBuffer((0,
|
|
19208
|
+
prepareSessionBuffer((0, import_node_fs12.readFileSync)(target.filePath))
|
|
19062
19209
|
)
|
|
19063
19210
|
}));
|
|
19064
19211
|
const { css, js } = loadViewerAssets();
|
|
@@ -19081,7 +19228,7 @@ ${refreshMeta}
|
|
|
19081
19228
|
<script>${js}</script>
|
|
19082
19229
|
</body>
|
|
19083
19230
|
</html>`;
|
|
19084
|
-
(0,
|
|
19231
|
+
(0, import_node_fs12.writeFileSync)(outputPath, html, "utf8");
|
|
19085
19232
|
printCommandEnvelope(
|
|
19086
19233
|
{
|
|
19087
19234
|
ok: true,
|
|
@@ -19948,9 +20095,9 @@ Examples:
|
|
|
19948
20095
|
}
|
|
19949
20096
|
|
|
19950
20097
|
// src/cli/commands/switch.ts
|
|
19951
|
-
var
|
|
19952
|
-
var
|
|
19953
|
-
var
|
|
20098
|
+
var import_node_fs13 = require("fs");
|
|
20099
|
+
var import_node_os10 = require("os");
|
|
20100
|
+
var import_node_path16 = require("path");
|
|
19954
20101
|
function hostSlugFromBaseUrl(baseUrl) {
|
|
19955
20102
|
try {
|
|
19956
20103
|
const url = new URL(baseUrl);
|
|
@@ -19970,8 +20117,8 @@ function resolveConfigScope() {
|
|
|
19970
20117
|
return hostSlugFromBaseUrl(autoDetectBaseUrl());
|
|
19971
20118
|
}
|
|
19972
20119
|
function activeFamilyPath() {
|
|
19973
|
-
const home = process.env.HOME || process.env.USERPROFILE || (0,
|
|
19974
|
-
return (0,
|
|
20120
|
+
const home = process.env.HOME || process.env.USERPROFILE || (0, import_node_os10.homedir)();
|
|
20121
|
+
return (0, import_node_path16.join)(
|
|
19975
20122
|
home,
|
|
19976
20123
|
".local",
|
|
19977
20124
|
"deepline",
|
|
@@ -19983,18 +20130,21 @@ function activeFamilyPath() {
|
|
|
19983
20130
|
function readActiveFamily() {
|
|
19984
20131
|
const path = activeFamilyPath();
|
|
19985
20132
|
try {
|
|
19986
|
-
return (0,
|
|
20133
|
+
return (0, import_node_fs13.readFileSync)(path, "utf-8").trim() || "sdk";
|
|
19987
20134
|
} catch {
|
|
19988
20135
|
return "sdk";
|
|
19989
20136
|
}
|
|
19990
20137
|
}
|
|
19991
20138
|
function writeActiveFamily(family) {
|
|
19992
20139
|
const path = activeFamilyPath();
|
|
19993
|
-
(0,
|
|
19994
|
-
(0,
|
|
20140
|
+
(0, import_node_fs13.mkdirSync)((0, import_node_path16.dirname)(path), { recursive: true });
|
|
20141
|
+
(0, import_node_fs13.writeFileSync)(path, `${family}
|
|
19995
20142
|
`, "utf-8");
|
|
19996
20143
|
return path;
|
|
19997
20144
|
}
|
|
20145
|
+
function forcePythonCliFamily() {
|
|
20146
|
+
return writeActiveFamily("python");
|
|
20147
|
+
}
|
|
19998
20148
|
function handleSwitch(action, options) {
|
|
19999
20149
|
const normalized = (action || "status").trim().toLowerCase();
|
|
20000
20150
|
if (normalized === "status") {
|
|
@@ -20005,7 +20155,7 @@ function handleSwitch(action, options) {
|
|
|
20005
20155
|
ok: true,
|
|
20006
20156
|
active_family: activeFamily,
|
|
20007
20157
|
active_family_path: path,
|
|
20008
|
-
active_family_file_exists: (0,
|
|
20158
|
+
active_family_file_exists: (0, import_node_fs13.existsSync)(path),
|
|
20009
20159
|
render: {
|
|
20010
20160
|
sections: [
|
|
20011
20161
|
{
|
|
@@ -20105,14 +20255,14 @@ Examples:
|
|
|
20105
20255
|
|
|
20106
20256
|
// src/cli/commands/tools.ts
|
|
20107
20257
|
var import_commander2 = require("commander");
|
|
20258
|
+
var import_node_fs15 = require("fs");
|
|
20259
|
+
var import_node_os12 = require("os");
|
|
20260
|
+
var import_node_path18 = require("path");
|
|
20261
|
+
|
|
20262
|
+
// src/tool-output.ts
|
|
20108
20263
|
var import_node_fs14 = require("fs");
|
|
20109
20264
|
var import_node_os11 = require("os");
|
|
20110
20265
|
var import_node_path17 = require("path");
|
|
20111
|
-
|
|
20112
|
-
// src/tool-output.ts
|
|
20113
|
-
var import_node_fs13 = require("fs");
|
|
20114
|
-
var import_node_os10 = require("os");
|
|
20115
|
-
var import_node_path16 = require("path");
|
|
20116
20266
|
function isPlainObject(value) {
|
|
20117
20267
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
20118
20268
|
}
|
|
@@ -20208,19 +20358,19 @@ function tryConvertToList(payload, options) {
|
|
|
20208
20358
|
return null;
|
|
20209
20359
|
}
|
|
20210
20360
|
function ensureOutputDir() {
|
|
20211
|
-
const outputDir = (0,
|
|
20212
|
-
(0,
|
|
20361
|
+
const outputDir = (0, import_node_path17.join)((0, import_node_os11.homedir)(), ".local", "share", "deepline", "data");
|
|
20362
|
+
(0, import_node_fs14.mkdirSync)(outputDir, { recursive: true });
|
|
20213
20363
|
return outputDir;
|
|
20214
20364
|
}
|
|
20215
20365
|
function writeJsonOutputFile(payload, stem) {
|
|
20216
20366
|
const outputDir = ensureOutputDir();
|
|
20217
|
-
const outputPath = (0,
|
|
20218
|
-
(0,
|
|
20367
|
+
const outputPath = (0, import_node_path17.join)(outputDir, `${stem}_${Date.now()}.json`);
|
|
20368
|
+
(0, import_node_fs14.writeFileSync)(outputPath, JSON.stringify(payload, null, 2), "utf-8");
|
|
20219
20369
|
return outputPath;
|
|
20220
20370
|
}
|
|
20221
20371
|
function writeCsvOutputFile(rows, stem) {
|
|
20222
20372
|
const outputDir = ensureOutputDir();
|
|
20223
|
-
const outputPath = (0,
|
|
20373
|
+
const outputPath = (0, import_node_path17.join)(outputDir, `${stem}_${Date.now()}.csv`);
|
|
20224
20374
|
const seen = /* @__PURE__ */ new Set();
|
|
20225
20375
|
const columns = [];
|
|
20226
20376
|
for (const row of rows) {
|
|
@@ -20243,7 +20393,7 @@ function writeCsvOutputFile(rows, stem) {
|
|
|
20243
20393
|
for (const row of rows) {
|
|
20244
20394
|
lines.push(columns.map((column) => escapeCell(row[column])).join(","));
|
|
20245
20395
|
}
|
|
20246
|
-
(0,
|
|
20396
|
+
(0, import_node_fs14.writeFileSync)(outputPath, `${lines.join("\n")}
|
|
20247
20397
|
`, "utf-8");
|
|
20248
20398
|
const previewRows = rows.slice(0, 5);
|
|
20249
20399
|
const previewColumns = columns.slice(0, 5);
|
|
@@ -21297,11 +21447,11 @@ function normalizeOutputFormat(raw) {
|
|
|
21297
21447
|
}
|
|
21298
21448
|
function resolveAtFilePath(rawPath) {
|
|
21299
21449
|
const trimmed = rawPath.trim();
|
|
21300
|
-
const resolved = (0,
|
|
21301
|
-
if ((0,
|
|
21450
|
+
const resolved = (0, import_node_path18.resolve)(trimmed);
|
|
21451
|
+
if ((0, import_node_fs15.existsSync)(resolved)) return resolved;
|
|
21302
21452
|
if (process.platform !== "win32" && trimmed.includes("\\")) {
|
|
21303
|
-
const normalized = (0,
|
|
21304
|
-
if ((0,
|
|
21453
|
+
const normalized = (0, import_node_path18.resolve)(trimmed.replace(/\\/g, "/"));
|
|
21454
|
+
if ((0, import_node_fs15.existsSync)(normalized)) return normalized;
|
|
21305
21455
|
}
|
|
21306
21456
|
return resolved;
|
|
21307
21457
|
}
|
|
@@ -21312,7 +21462,7 @@ function readJsonArgument(raw, flagName) {
|
|
|
21312
21462
|
throw new Error(`Invalid ${flagName} value: empty @file path.`);
|
|
21313
21463
|
}
|
|
21314
21464
|
try {
|
|
21315
|
-
return (0,
|
|
21465
|
+
return (0, import_node_fs15.readFileSync)(resolveAtFilePath(filePath), "utf8").replace(
|
|
21316
21466
|
/^\uFEFF/,
|
|
21317
21467
|
""
|
|
21318
21468
|
);
|
|
@@ -21414,9 +21564,9 @@ function starterScriptJson(script) {
|
|
|
21414
21564
|
function seedToolListScript(input2) {
|
|
21415
21565
|
const stem = safeFileStem(input2.toolId);
|
|
21416
21566
|
const fileName = `${stem}-workflow-seed-${Date.now()}.play.ts`;
|
|
21417
|
-
const scriptDir = (0,
|
|
21418
|
-
(0,
|
|
21419
|
-
const scriptPath = (0,
|
|
21567
|
+
const scriptDir = (0, import_node_fs15.mkdtempSync)((0, import_node_path18.join)((0, import_node_os12.tmpdir)(), "deepline-workflow-seed-"));
|
|
21568
|
+
(0, import_node_fs15.chmodSync)(scriptDir, 448);
|
|
21569
|
+
const scriptPath = (0, import_node_path18.join)(scriptDir, fileName);
|
|
21420
21570
|
const projectDir = `deepline/projects/${stem}-workflow`;
|
|
21421
21571
|
const playName = `${stem}-workflow`;
|
|
21422
21572
|
const sampleRows = input2.rows.length > 0 ? `${JSON.stringify(input2.rows.slice(0, 2)).replace(/\]$/, "")}, ...]` : "[]";
|
|
@@ -21452,7 +21602,7 @@ export default definePlay(${JSON.stringify(playName)}, async (ctx) => {
|
|
|
21452
21602
|
};
|
|
21453
21603
|
});
|
|
21454
21604
|
`;
|
|
21455
|
-
(0,
|
|
21605
|
+
(0, import_node_fs15.writeFileSync)(scriptPath, script, { encoding: "utf-8", mode: 384 });
|
|
21456
21606
|
return {
|
|
21457
21607
|
path: scriptPath,
|
|
21458
21608
|
sourceCode: script,
|
|
@@ -21717,7 +21867,7 @@ async function executeTool(args) {
|
|
|
21717
21867
|
|
|
21718
21868
|
// src/cli/commands/workflow.ts
|
|
21719
21869
|
var import_promises6 = require("fs/promises");
|
|
21720
|
-
var
|
|
21870
|
+
var import_node_path19 = require("path");
|
|
21721
21871
|
|
|
21722
21872
|
// src/cli/workflow-to-play.ts
|
|
21723
21873
|
var import_node_crypto6 = require("crypto");
|
|
@@ -21924,7 +22074,7 @@ function readStatus(payload) {
|
|
|
21924
22074
|
}
|
|
21925
22075
|
async function readJsonOption(payload, file) {
|
|
21926
22076
|
if (file) {
|
|
21927
|
-
const raw = await (0, import_promises6.readFile)((0,
|
|
22077
|
+
const raw = await (0, import_promises6.readFile)((0, import_node_path19.resolve)(file), "utf8");
|
|
21928
22078
|
return JSON.parse(raw);
|
|
21929
22079
|
}
|
|
21930
22080
|
if (payload) {
|
|
@@ -21958,8 +22108,8 @@ async function transformOne(api, workflowId, outDir, publish) {
|
|
|
21958
22108
|
revision.config,
|
|
21959
22109
|
{ workflowName: workflow.name, version: revision.version }
|
|
21960
22110
|
);
|
|
21961
|
-
const file = (0,
|
|
21962
|
-
await (0, import_promises6.mkdir)((0,
|
|
22111
|
+
const file = (0, import_node_path19.join)((0, import_node_path19.resolve)(outDir), `${compiled.playName}.play.ts`);
|
|
22112
|
+
await (0, import_promises6.mkdir)((0, import_node_path19.dirname)(file), { recursive: true });
|
|
21963
22113
|
await (0, import_promises6.writeFile)(file, compiled.sourceCode, "utf8");
|
|
21964
22114
|
let published = false;
|
|
21965
22115
|
if (publish) {
|
|
@@ -22206,8 +22356,8 @@ Notes:
|
|
|
22206
22356
|
|
|
22207
22357
|
// src/cli/commands/update.ts
|
|
22208
22358
|
var import_node_child_process2 = require("child_process");
|
|
22209
|
-
var
|
|
22210
|
-
var
|
|
22359
|
+
var import_node_fs16 = require("fs");
|
|
22360
|
+
var import_node_path20 = require("path");
|
|
22211
22361
|
function posixShellQuote(value) {
|
|
22212
22362
|
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
22213
22363
|
}
|
|
@@ -22226,19 +22376,19 @@ function buildSourceUpdateCommand(sourceRoot) {
|
|
|
22226
22376
|
return `${cdCommand} && git fetch origin main --tags && git merge --ff-only origin/main`;
|
|
22227
22377
|
}
|
|
22228
22378
|
function findRepoBackedSdkRoot(startPath) {
|
|
22229
|
-
let current = (0,
|
|
22379
|
+
let current = (0, import_node_path20.resolve)(startPath);
|
|
22230
22380
|
while (true) {
|
|
22231
|
-
if ((0,
|
|
22381
|
+
if ((0, import_node_fs16.existsSync)((0, import_node_path20.join)(current, "sdk", "package.json")) && (0, import_node_fs16.existsSync)((0, import_node_path20.join)(current, "sdk", "bin", "deepline-dev.ts"))) {
|
|
22232
22382
|
return current;
|
|
22233
22383
|
}
|
|
22234
|
-
const parent = (0,
|
|
22384
|
+
const parent = (0, import_node_path20.dirname)(current);
|
|
22235
22385
|
if (parent === current) return null;
|
|
22236
22386
|
current = parent;
|
|
22237
22387
|
}
|
|
22238
22388
|
}
|
|
22239
22389
|
function resolveUpdatePlan() {
|
|
22240
|
-
const entrypoint = process.argv[1] ? (0,
|
|
22241
|
-
const sourceRoot = entrypoint ? findRepoBackedSdkRoot((0,
|
|
22390
|
+
const entrypoint = process.argv[1] ? (0, import_node_path20.resolve)(process.argv[1]) : "";
|
|
22391
|
+
const sourceRoot = entrypoint ? findRepoBackedSdkRoot((0, import_node_path20.dirname)(entrypoint)) : null;
|
|
22242
22392
|
if (sourceRoot) {
|
|
22243
22393
|
return {
|
|
22244
22394
|
kind: "source",
|
|
@@ -22565,7 +22715,7 @@ async function maybeAutoUpdateAndRelaunch(response) {
|
|
|
22565
22715
|
if (plan.kind !== "npm-global") {
|
|
22566
22716
|
return false;
|
|
22567
22717
|
}
|
|
22568
|
-
const label = autoUpdate.required ? "requires an update" : "is more than the supported auto-update lag behind";
|
|
22718
|
+
const label = autoUpdate.reason === "rollback_forced" ? "has a server rollback pending and needs the latest rollback-aware CLI" : autoUpdate.required ? "requires an update" : "is more than the supported auto-update lag behind";
|
|
22569
22719
|
process.stderr.write(
|
|
22570
22720
|
`Deepline SDK/CLI ${label}; running ${plan.manualCommand}
|
|
22571
22721
|
`
|
|
@@ -22591,9 +22741,9 @@ async function maybeAutoUpdateAndRelaunch(response) {
|
|
|
22591
22741
|
|
|
22592
22742
|
// src/cli/skills-sync.ts
|
|
22593
22743
|
var import_node_child_process4 = require("child_process");
|
|
22594
|
-
var
|
|
22595
|
-
var
|
|
22596
|
-
var
|
|
22744
|
+
var import_node_fs17 = require("fs");
|
|
22745
|
+
var import_node_os13 = require("os");
|
|
22746
|
+
var import_node_path21 = require("path");
|
|
22597
22747
|
var CHECK_TIMEOUT_MS2 = 3e3;
|
|
22598
22748
|
var SDK_PLAY_SKILL_NAME = "deepline-plays";
|
|
22599
22749
|
var attemptedSync = false;
|
|
@@ -22607,20 +22757,20 @@ function activePluginSkillsDir() {
|
|
|
22607
22757
|
return "";
|
|
22608
22758
|
}
|
|
22609
22759
|
const dir = process.env.DEEPLINE_PLUGIN_SKILLS_DIR?.trim() ?? "";
|
|
22610
|
-
return dir && (0,
|
|
22760
|
+
return dir && (0, import_node_fs17.existsSync)(dir) ? dir : "";
|
|
22611
22761
|
}
|
|
22612
22762
|
function readPluginSkillsVersion() {
|
|
22613
22763
|
const dir = activePluginSkillsDir();
|
|
22614
22764
|
if (!dir) return "";
|
|
22615
22765
|
try {
|
|
22616
|
-
return (0,
|
|
22766
|
+
return (0, import_node_fs17.readFileSync)((0, import_node_path21.join)(dir, ".version"), "utf-8").trim();
|
|
22617
22767
|
} catch {
|
|
22618
22768
|
return "";
|
|
22619
22769
|
}
|
|
22620
22770
|
}
|
|
22621
22771
|
function sdkSkillsVersionPath(baseUrl) {
|
|
22622
|
-
const home = process.env.HOME?.trim() || (0,
|
|
22623
|
-
return (0,
|
|
22772
|
+
const home = process.env.HOME?.trim() || (0, import_node_os13.homedir)();
|
|
22773
|
+
return (0, import_node_path21.join)(
|
|
22624
22774
|
home,
|
|
22625
22775
|
".local",
|
|
22626
22776
|
"deepline",
|
|
@@ -22633,17 +22783,17 @@ function readLocalSkillsVersion(baseUrl) {
|
|
|
22633
22783
|
const pluginVersion = readPluginSkillsVersion();
|
|
22634
22784
|
if (pluginVersion) return pluginVersion;
|
|
22635
22785
|
const path = sdkSkillsVersionPath(baseUrl);
|
|
22636
|
-
if (!(0,
|
|
22786
|
+
if (!(0, import_node_fs17.existsSync)(path)) return "";
|
|
22637
22787
|
try {
|
|
22638
|
-
return (0,
|
|
22788
|
+
return (0, import_node_fs17.readFileSync)(path, "utf-8").trim();
|
|
22639
22789
|
} catch {
|
|
22640
22790
|
return "";
|
|
22641
22791
|
}
|
|
22642
22792
|
}
|
|
22643
22793
|
function writeLocalSkillsVersion(baseUrl, version) {
|
|
22644
22794
|
const path = sdkSkillsVersionPath(baseUrl);
|
|
22645
|
-
(0,
|
|
22646
|
-
(0,
|
|
22795
|
+
(0, import_node_fs17.mkdirSync)((0, import_node_path21.dirname)(path), { recursive: true });
|
|
22796
|
+
(0, import_node_fs17.writeFileSync)(path, `${version}
|
|
22647
22797
|
`, "utf-8");
|
|
22648
22798
|
}
|
|
22649
22799
|
function sortedUniqueSkillNames(names) {
|
|
@@ -22822,7 +22972,7 @@ async function syncSdkSkillsIfNeeded(baseUrl) {
|
|
|
22822
22972
|
}
|
|
22823
22973
|
|
|
22824
22974
|
// src/cli/failure-reporting.ts
|
|
22825
|
-
var
|
|
22975
|
+
var import_node_os14 = require("os");
|
|
22826
22976
|
var FAILURE_REPORT_DISABLE_ENV = "DEEPLINE_DISABLE_FAILURE_REPORTING";
|
|
22827
22977
|
var REPORT_FAILURE_TIMEOUT_MS = 1e4;
|
|
22828
22978
|
var MAX_FAILURE_TEXT_CHARS = 4e3;
|
|
@@ -22944,12 +23094,12 @@ function detectAgentRuntime3() {
|
|
|
22944
23094
|
}
|
|
22945
23095
|
function buildEnvironmentContext() {
|
|
22946
23096
|
const context = {
|
|
22947
|
-
os: (0,
|
|
22948
|
-
os_release: (0,
|
|
22949
|
-
platform: `${(0,
|
|
23097
|
+
os: (0, import_node_os14.platform)(),
|
|
23098
|
+
os_release: (0, import_node_os14.release)(),
|
|
23099
|
+
platform: `${(0, import_node_os14.platform)()}-${(0, import_node_os14.release)()}-${process.arch}`,
|
|
22950
23100
|
node_version: process.version,
|
|
22951
23101
|
runtime: "Node.js",
|
|
22952
|
-
hostname: (0,
|
|
23102
|
+
hostname: (0, import_node_os14.hostname)(),
|
|
22953
23103
|
agent_runtime: detectAgentRuntime3()
|
|
22954
23104
|
};
|
|
22955
23105
|
for (const key of ["CLAUDE_CODE_REMOTE", "DEEPLINE_PLUGIN_MODE"]) {
|
|
@@ -23129,8 +23279,8 @@ function topLevelCommandKnown(program, commandName) {
|
|
|
23129
23279
|
);
|
|
23130
23280
|
}
|
|
23131
23281
|
async function runPlayRunnerHealthCheck() {
|
|
23132
|
-
const dir = await (0, import_promises7.mkdtemp)((0,
|
|
23133
|
-
const file = (0,
|
|
23282
|
+
const dir = await (0, import_promises7.mkdtemp)((0, import_node_path22.join)((0, import_node_os15.tmpdir)(), "deepline-health-play-"));
|
|
23283
|
+
const file = (0, import_node_path22.join)(dir, "health-check.play.ts");
|
|
23134
23284
|
try {
|
|
23135
23285
|
await (0, import_promises7.writeFile)(
|
|
23136
23286
|
file,
|
|
@@ -23368,6 +23518,18 @@ Exit codes:
|
|
|
23368
23518
|
if (relaunched) {
|
|
23369
23519
|
return;
|
|
23370
23520
|
}
|
|
23521
|
+
if (compatibility.response?.cli_family?.action === "force_python") {
|
|
23522
|
+
forcePythonCliFamily();
|
|
23523
|
+
process.stderr.write(
|
|
23524
|
+
"Deepline SDK CLI rollback is active; switched installer-managed `deepline` back to the Python CLI. Re-run your command.\n"
|
|
23525
|
+
);
|
|
23526
|
+
const error = new Error(
|
|
23527
|
+
"SDK CLI rollback is active"
|
|
23528
|
+
);
|
|
23529
|
+
error.code = "deepline.sdk_cli_rollback";
|
|
23530
|
+
error.exitCode = 7;
|
|
23531
|
+
throw error;
|
|
23532
|
+
}
|
|
23371
23533
|
enforceSdkCompatibilityResponse(compatibility.response);
|
|
23372
23534
|
if (printStartupPhase) {
|
|
23373
23535
|
progress?.phase("checking sdk skills");
|