deepline 0.1.110 → 0.1.111

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.
@@ -159,7 +159,7 @@ configureProxyFromEnv();
159
159
 
160
160
  // src/cli/index.ts
161
161
  import { mkdtemp as mkdtemp2, rm as rm2, writeFile as writeFile6 } from "fs/promises";
162
- import { join as join16 } from "path";
162
+ import { join as join17 } from "path";
163
163
  import { tmpdir as tmpdir5 } from "os";
164
164
  import { Command as Command3 } from "commander";
165
165
 
@@ -380,10 +380,10 @@ var SDK_RELEASE = {
380
380
  // skill on the sdk sync surface, and the people-search-to-email prebuilt.
381
381
  // 0.1.108 ships explicit dataset column/tool recompute policy and removes
382
382
  // the SDK enrich generator's one-second stale policy.
383
- version: "0.1.110",
383
+ version: "0.1.111",
384
384
  apiContract: "2026-06-dataset-column-cell-stale-hard-cutover",
385
385
  supportPolicy: {
386
- latest: "0.1.110",
386
+ latest: "0.1.111",
387
387
  minimumSupported: "0.1.53",
388
388
  deprecatedBelow: "0.1.53",
389
389
  commandMinimumSupported: [
@@ -3439,11 +3439,57 @@ var DeeplineClient = class {
3439
3439
  };
3440
3440
 
3441
3441
  // src/compat.ts
3442
+ import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
3443
+ import { homedir as homedir3 } from "os";
3444
+ import { dirname as dirname2, join as join3 } from "path";
3442
3445
  var CHECK_TIMEOUT_MS = 2e3;
3446
+ var COMPAT_CACHE_TTL_MS = 5 * 60 * 1e3;
3443
3447
  function shouldSkipCompatibilityCheck() {
3444
3448
  const value = process.env.DEEPLINE_SKIP_SDK_COMPAT_CHECK?.trim().toLowerCase();
3445
3449
  return value === "1" || value === "true" || value === "yes";
3446
3450
  }
3451
+ function compatibilityCachePath() {
3452
+ return join3(homedir3(), ".cache", "deepline", "sdk-compat-cache.json");
3453
+ }
3454
+ function compatibilityCacheKey(baseUrl, command) {
3455
+ return JSON.stringify({
3456
+ baseUrl: baseUrl.replace(/\/$/, ""),
3457
+ version: SDK_VERSION,
3458
+ apiContract: SDK_API_CONTRACT,
3459
+ command: command?.trim() || null
3460
+ });
3461
+ }
3462
+ function readCachedCompatibility(baseUrl, command) {
3463
+ try {
3464
+ const path = compatibilityCachePath();
3465
+ if (!existsSync3(path)) {
3466
+ return null;
3467
+ }
3468
+ const parsed = JSON.parse(readFileSync3(path, "utf8"));
3469
+ const entry = parsed.entries?.[compatibilityCacheKey(baseUrl, command)];
3470
+ if (!entry || Date.now() - entry.savedAt > COMPAT_CACHE_TTL_MS) {
3471
+ return null;
3472
+ }
3473
+ return entry.response;
3474
+ } catch {
3475
+ return null;
3476
+ }
3477
+ }
3478
+ function writeCachedCompatibility(baseUrl, command, response) {
3479
+ try {
3480
+ const path = compatibilityCachePath();
3481
+ const existing = existsSync3(path) ? JSON.parse(readFileSync3(path, "utf8")) : {};
3482
+ const entries = existing.entries ?? {};
3483
+ entries[compatibilityCacheKey(baseUrl, command)] = {
3484
+ savedAt: Date.now(),
3485
+ response
3486
+ };
3487
+ mkdirSync2(dirname2(path), { recursive: true });
3488
+ writeFileSync2(path, `${JSON.stringify({ entries }, null, 2)}
3489
+ `);
3490
+ } catch {
3491
+ }
3492
+ }
3447
3493
  async function checkSdkCompatibility(baseUrl, options = {}) {
3448
3494
  if (shouldSkipCompatibilityCheck()) {
3449
3495
  return { response: null, error: null };
@@ -3466,8 +3512,15 @@ async function checkSdkCompatibility(baseUrl, options = {}) {
3466
3512
  signal: controller.signal
3467
3513
  });
3468
3514
  const data = await response.json().catch(() => null);
3515
+ if (data) {
3516
+ writeCachedCompatibility(baseUrl, options.command, data);
3517
+ }
3469
3518
  return { response: data, error: null };
3470
3519
  } catch (error) {
3520
+ const cached = readCachedCompatibility(baseUrl, options.command);
3521
+ if (cached?.ok === false || cached?.status === "unsupported") {
3522
+ return { response: cached, error: null };
3523
+ }
3471
3524
  return {
3472
3525
  response: null,
3473
3526
  error: error instanceof Error ? error : new Error(String(error))
@@ -3491,26 +3544,26 @@ function enforceSdkCompatibilityResponse(response) {
3491
3544
 
3492
3545
  // src/cli/commands/auth.ts
3493
3546
  import {
3494
- existsSync as existsSync4,
3495
- mkdirSync as mkdirSync3,
3496
- readFileSync as readFileSync4,
3547
+ existsSync as existsSync5,
3548
+ mkdirSync as mkdirSync4,
3549
+ readFileSync as readFileSync5,
3497
3550
  rmSync as rmSync2,
3498
- writeFileSync as writeFileSync3
3551
+ writeFileSync as writeFileSync4
3499
3552
  } from "fs";
3500
3553
  import { hostname } from "os";
3501
- import { dirname as dirname3 } from "path";
3554
+ import { dirname as dirname4 } from "path";
3502
3555
 
3503
3556
  // src/cli/utils.ts
3504
3557
  import {
3505
- existsSync as existsSync3,
3506
- mkdirSync as mkdirSync2,
3507
- readFileSync as readFileSync3,
3558
+ existsSync as existsSync4,
3559
+ mkdirSync as mkdirSync3,
3560
+ readFileSync as readFileSync4,
3508
3561
  rmSync,
3509
- writeFileSync as writeFileSync2
3562
+ writeFileSync as writeFileSync3
3510
3563
  } from "fs";
3511
3564
  import { mkdir, writeFile } from "fs/promises";
3512
- import { homedir as homedir3 } from "os";
3513
- import { dirname as dirname2, join as join3, resolve as resolve2 } from "path";
3565
+ import { homedir as homedir4 } from "os";
3566
+ import { dirname as dirname3, join as join4, resolve as resolve2 } from "path";
3514
3567
  import * as childProcess from "child_process";
3515
3568
  import { parse } from "csv-parse/sync";
3516
3569
  import { stringify } from "csv-stringify/sync";
@@ -3523,13 +3576,13 @@ function getAuthedHttpClient() {
3523
3576
  async function writeOutputFile(filename, content) {
3524
3577
  const outputDir = resolve2(process.cwd(), "deepline", "data");
3525
3578
  await mkdir(outputDir, { recursive: true });
3526
- const fullPath = join3(outputDir, filename);
3579
+ const fullPath = join4(outputDir, filename);
3527
3580
  await writeFile(fullPath, content, "utf-8");
3528
3581
  return fullPath;
3529
3582
  }
3530
3583
  function browserOpenStateFile() {
3531
- const homeDir2 = process.env.HOME || homedir3();
3532
- return join3(
3584
+ const homeDir2 = process.env.HOME || homedir4();
3585
+ return join4(
3533
3586
  homeDir2,
3534
3587
  ".local",
3535
3588
  "deepline",
@@ -3543,16 +3596,16 @@ function claimBrowserOpen(now = Date.now()) {
3543
3596
  const lockPath = `${statePath}.lock`;
3544
3597
  let locked = false;
3545
3598
  try {
3546
- mkdirSync2(dirname2(statePath), { recursive: true });
3599
+ mkdirSync3(dirname3(statePath), { recursive: true });
3547
3600
  try {
3548
- mkdirSync2(lockPath);
3601
+ mkdirSync3(lockPath);
3549
3602
  locked = true;
3550
3603
  } catch {
3551
3604
  return false;
3552
3605
  }
3553
3606
  let lastOpenedAt = 0;
3554
- if (existsSync3(statePath)) {
3555
- const payload = JSON.parse(readFileSync3(statePath, "utf-8"));
3607
+ if (existsSync4(statePath)) {
3608
+ const payload = JSON.parse(readFileSync4(statePath, "utf-8"));
3556
3609
  const value = payload.lastOpenedAt ?? payload.last_opened_at ?? payload.lastFocusedAt ?? payload.last_focused_at;
3557
3610
  if (typeof value === "number" && Number.isFinite(value)) {
3558
3611
  lastOpenedAt = value;
@@ -3564,7 +3617,7 @@ function claimBrowserOpen(now = Date.now()) {
3564
3617
  if (now - lastOpenedAt < BROWSER_OPEN_COOLDOWN_MS) {
3565
3618
  return false;
3566
3619
  }
3567
- writeFileSync2(statePath, JSON.stringify({ lastOpenedAt: now }), "utf-8");
3620
+ writeFileSync3(statePath, JSON.stringify({ lastOpenedAt: now }), "utf-8");
3568
3621
  return true;
3569
3622
  } catch {
3570
3623
  return true;
@@ -3605,7 +3658,7 @@ function readDefaultMacBrowserBundleId(runner = defaultBrowserCommandRunner) {
3605
3658
  "json",
3606
3659
  "-o",
3607
3660
  "-",
3608
- `${homedir3()}/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist`
3661
+ `${homedir4()}/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist`
3609
3662
  ],
3610
3663
  { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] }
3611
3664
  );
@@ -3776,7 +3829,7 @@ function collectLocalEnvInfo() {
3776
3829
  const info = {
3777
3830
  os: `${process.platform} ${process.arch}`,
3778
3831
  node_version: process.version,
3779
- home_dir: homedir3(),
3832
+ home_dir: homedir4(),
3780
3833
  agent_runtime: detectAgentRuntime2()
3781
3834
  };
3782
3835
  const env = process.env;
@@ -3805,7 +3858,7 @@ function detectAgentRuntime2() {
3805
3858
  if (process.env.CODEX_THREAD_ID?.trim()) return "codex";
3806
3859
  const pluginMode = process.env.DEEPLINE_PLUGIN_MODE?.trim().toLowerCase();
3807
3860
  const claudeRemote = process.env.CLAUDE_CODE_REMOTE?.trim().toLowerCase();
3808
- const sessionHome = (process.env.HOME?.trim() || homedir3()).startsWith(
3861
+ const sessionHome = (process.env.HOME?.trim() || homedir4()).startsWith(
3809
3862
  "/sessions/"
3810
3863
  );
3811
3864
  if (["1", "true", "yes", "on"].includes(pluginMode ?? "") && (["1", "true", "yes", "on"].includes(claudeRemote ?? "") || Boolean(process.env.CLAUDE_PROJECT_DIR?.trim()) || sessionHome)) {
@@ -3822,7 +3875,7 @@ function detectAgentRuntime2() {
3822
3875
  return "unknown";
3823
3876
  }
3824
3877
  function readCsvRows(csvPath) {
3825
- const raw = readFileSync3(resolve2(csvPath), "utf-8");
3878
+ const raw = readFileSync4(resolve2(csvPath), "utf-8");
3826
3879
  return parse(raw, {
3827
3880
  columns: true,
3828
3881
  skip_empty_lines: true
@@ -4056,18 +4109,18 @@ function pendingClaimTokenPath(baseUrl) {
4056
4109
  }
4057
4110
  function savePendingClaimToken(baseUrl, claimToken) {
4058
4111
  const filePath = pendingClaimTokenPath(baseUrl);
4059
- const dir = dirname3(filePath);
4060
- if (!existsSync4(dir)) {
4061
- mkdirSync3(dir, { recursive: true });
4112
+ const dir = dirname4(filePath);
4113
+ if (!existsSync5(dir)) {
4114
+ mkdirSync4(dir, { recursive: true });
4062
4115
  }
4063
- writeFileSync3(filePath, `${claimToken}
4116
+ writeFileSync4(filePath, `${claimToken}
4064
4117
  `, "utf-8");
4065
4118
  }
4066
4119
  function readPendingClaimToken(baseUrl) {
4067
4120
  const filePath = pendingClaimTokenPath(baseUrl);
4068
- if (!existsSync4(filePath)) return "";
4121
+ if (!existsSync5(filePath)) return "";
4069
4122
  try {
4070
- return readFileSync4(filePath, "utf-8").trim();
4123
+ return readFileSync5(filePath, "utf-8").trim();
4071
4124
  } catch {
4072
4125
  return "";
4073
4126
  }
@@ -4604,7 +4657,7 @@ Examples:
4604
4657
  // src/cli/commands/billing.ts
4605
4658
  import { Command } from "commander";
4606
4659
  import { appendFile, mkdir as mkdir2, writeFile as writeFile2 } from "fs/promises";
4607
- import { dirname as dirname4, resolve as resolve3 } from "path";
4660
+ import { dirname as dirname5, resolve as resolve3 } from "path";
4608
4661
  import { stringify as stringify2 } from "csv-stringify/sync";
4609
4662
  var SUBSCRIPTION_STATUS_NEXT_COMMAND = "deepline billing subscription status --json";
4610
4663
  var SUBSCRIPTION_CANCEL_PATH = "/api/v2/billing/subscription/cancel";
@@ -4893,7 +4946,7 @@ async function handleLedgerExportAll(options) {
4893
4946
  const entries = Array.isArray(payload.entries) ? payload.entries : [];
4894
4947
  const rows = entries.map(ledgerApiEntryToRow);
4895
4948
  if (!initializedOutput) {
4896
- await mkdir2(dirname4(outputPath), { recursive: true });
4949
+ await mkdir2(dirname5(outputPath), { recursive: true });
4897
4950
  await writeFile2(outputPath, ledgerRowsToCsv([], true), "utf-8");
4898
4951
  initializedOutput = true;
4899
4952
  }
@@ -5517,7 +5570,7 @@ Examples:
5517
5570
  }
5518
5571
 
5519
5572
  // src/cli/dataset-stats.ts
5520
- import { writeFileSync as writeFileSync4 } from "fs";
5573
+ import { writeFileSync as writeFileSync5 } from "fs";
5521
5574
  import { resolve as resolve4 } from "path";
5522
5575
 
5523
5576
  // ../shared_libs/plays/dataset-summary.ts
@@ -6126,7 +6179,7 @@ function writeCanonicalRowsCsv(rowsInfo, outPath) {
6126
6179
  const rows = dataExportRows(sanitized.rows);
6127
6180
  const columns = dataExportColumns(rows, sanitized.columns);
6128
6181
  const resolved = resolve4(outPath);
6129
- writeFileSync4(resolved, csvStringFromRows(rows, columns), "utf-8");
6182
+ writeFileSync5(resolved, csvStringFromRows(rows, columns), "utf-8");
6130
6183
  return resolved;
6131
6184
  }
6132
6185
 
@@ -6262,7 +6315,7 @@ Examples:
6262
6315
  }
6263
6316
 
6264
6317
  // src/cli/commands/db.ts
6265
- import { writeFileSync as writeFileSync5 } from "fs";
6318
+ import { writeFileSync as writeFileSync6 } from "fs";
6266
6319
  import { resolve as resolve5 } from "path";
6267
6320
  var CUSTOMER_DB_QUERY_FORMATS = /* @__PURE__ */ new Set(["table", "json", "csv", "markdown"]);
6268
6321
  function parsePositiveInteger(value, flagName) {
@@ -6377,7 +6430,7 @@ function formatDbQueryError(sql, error) {
6377
6430
  }
6378
6431
  function writeCustomerDbCsv(result, outPath) {
6379
6432
  const resolved = resolve5(outPath);
6380
- writeFileSync5(
6433
+ writeFileSync6(
6381
6434
  resolved,
6382
6435
  dataExportCsvString(customerDbRows(result), customerDbColumnNames(result)),
6383
6436
  "utf-8"
@@ -6490,7 +6543,7 @@ async function handleDbQuery(args) {
6490
6543
  );
6491
6544
  if (outPath) {
6492
6545
  const exportedPath = resolve5(outPath);
6493
- writeFileSync5(exportedPath, content, "utf-8");
6546
+ writeFileSync6(exportedPath, content, "utf-8");
6494
6547
  printCommandEnvelope(
6495
6548
  dbQueryExportEnvelope({
6496
6549
  result,
@@ -6599,39 +6652,40 @@ import {
6599
6652
  stat as stat3,
6600
6653
  writeFile as writeFile4
6601
6654
  } from "fs/promises";
6602
- import { homedir as homedir4, tmpdir as tmpdir3 } from "os";
6603
- import { join as join8, resolve as resolve11 } from "path";
6655
+ import { homedir as homedir5, tmpdir as tmpdir3 } from "os";
6656
+ import { join as join9, resolve as resolve11 } from "path";
6604
6657
 
6605
6658
  // src/cli/commands/play.ts
6606
6659
  import { createHash as createHash3 } from "crypto";
6607
6660
  import {
6608
- existsSync as existsSync7,
6609
- readFileSync as readFileSync6,
6661
+ existsSync as existsSync8,
6662
+ readFileSync as readFileSync7,
6610
6663
  readdirSync,
6611
6664
  realpathSync,
6612
6665
  statSync as statSync2,
6613
- writeFileSync as writeFileSync7
6666
+ writeFileSync as writeFileSync8
6614
6667
  } from "fs";
6615
- import { basename as basename3, dirname as dirname8, join as join7, resolve as resolve10 } from "path";
6668
+ import { basename as basename3, dirname as dirname9, join as join8, resolve as resolve10 } from "path";
6616
6669
  import { parse as parseCsvSync2 } from "csv-parse/sync";
6617
6670
 
6618
6671
  // src/plays/bundle-play-file.ts
6619
6672
  import { tmpdir as tmpdir2 } from "os";
6620
- import { dirname as dirname7, join as join6, resolve as resolve8 } from "path";
6673
+ import { dirname as dirname8, join as join7, resolve as resolve8 } from "path";
6621
6674
  import { fileURLToPath } from "url";
6622
- import { existsSync as existsSync6 } from "fs";
6675
+ import { existsSync as existsSync7 } from "fs";
6623
6676
 
6624
6677
  // ../shared_libs/plays/bundling/index.ts
6625
6678
  import { createHash } from "crypto";
6626
- import { existsSync as existsSync5, readFileSync as readFileSync5 } from "fs";
6679
+ import { existsSync as existsSync6, readFileSync as readFileSync6 } from "fs";
6627
6680
  import { mkdir as mkdir3, readFile, realpath, stat, writeFile as writeFile3 } from "fs/promises";
6628
6681
  import { tmpdir } from "os";
6629
6682
  import {
6630
6683
  basename,
6631
- dirname as dirname5,
6684
+ dirname as dirname6,
6632
6685
  extname,
6633
6686
  isAbsolute,
6634
- join as join4,
6687
+ join as join5,
6688
+ relative,
6635
6689
  resolve as resolve6
6636
6690
  } from "path";
6637
6691
  import { builtinModules } from "module";
@@ -6746,7 +6800,7 @@ var MAX_ESM_WORKERS_BUNDLE_BYTES = 115e4;
6746
6800
 
6747
6801
  // ../shared_libs/plays/bundling/index.ts
6748
6802
  var PLAY_BUNDLE_CACHE_VERSION = 24;
6749
- var PLAY_ARTIFACT_CACHE_DIR = join4(
6803
+ var PLAY_ARTIFACT_CACHE_DIR = join5(
6750
6804
  tmpdir(),
6751
6805
  `deepline-play-artifacts-v${PLAY_BUNDLE_CACHE_VERSION}`
6752
6806
  );
@@ -6797,7 +6851,7 @@ async function normalizeLocalPath(filePath) {
6797
6851
  function createPlayWorkspace(entryFile) {
6798
6852
  return {
6799
6853
  entryFile,
6800
- rootDir: dirname5(entryFile)
6854
+ rootDir: dirname6(entryFile)
6801
6855
  };
6802
6856
  }
6803
6857
  function isPathInsideDirectory(filePath, directory) {
@@ -6964,9 +7018,74 @@ function extractDefinedPlayName(sourceCode) {
6964
7018
  }
6965
7019
  return null;
6966
7020
  }
7021
+ function canonicalizeRootPlayNameForWorkersRuntimeHash(sourceCode) {
7022
+ const source = stripCommentsToSpaces(sourceCode);
7023
+ const callPattern = /(?:\b[A-Za-z_$][\w$]*\s*\.\s*)?\b(?:definePlay|defineWorkflow)\s*\(/g;
7024
+ const match = callPattern.exec(source);
7025
+ if (!match) return sourceCode;
7026
+ const openParen = match.index + match[0].length - 1;
7027
+ const firstArgStart = openParen + 1;
7028
+ const firstNonSpace = source.slice(firstArgStart).search(/\S/);
7029
+ if (firstNonSpace < 0) return sourceCode;
7030
+ const argIndex = firstArgStart + firstNonSpace;
7031
+ const quote = source[argIndex];
7032
+ if (quote === '"' || quote === "'") {
7033
+ const literalMatch = source.slice(argIndex).match(/^(['"])(?:\\.|(?!\1)[\s\S])*\1/);
7034
+ if (!literalMatch) return sourceCode;
7035
+ const replacement = `${quote}__deepline_runtime_play_name__${quote}`;
7036
+ return `${sourceCode.slice(0, argIndex)}${replacement}${sourceCode.slice(argIndex + literalMatch[0].length)}`;
7037
+ }
7038
+ if (quote !== "{") return sourceCode;
7039
+ const closeBrace = findMatchingBrace(source, argIndex);
7040
+ if (closeBrace < 0) return sourceCode;
7041
+ const objectSource = source.slice(argIndex + 1, closeBrace);
7042
+ const idMatch = objectSource.match(
7043
+ /(^|[,{\s])((?:id|['"]id['"])\s*:\s*)(['"])([\s\S]*?)\3/
7044
+ );
7045
+ if (!idMatch || idMatch.index === void 0) return sourceCode;
7046
+ const idValueStart = argIndex + 1 + idMatch.index + idMatch[1].length + idMatch[2].length + idMatch[3].length;
7047
+ return `${sourceCode.slice(0, idValueStart)}__deepline_runtime_play_name__${sourceCode.slice(idValueStart + idMatch[4].length)}`;
7048
+ }
7049
+ function workersRuntimeGraphFilePath(input2) {
7050
+ if (input2.filePath === input2.entryFile) return "<entry>";
7051
+ const entryRelative = relative(dirname6(input2.entryFile), input2.filePath);
7052
+ if (entryRelative && !entryRelative.startsWith("..")) {
7053
+ return entryRelative.replaceAll("\\", "/");
7054
+ }
7055
+ return `<project>/${relative(input2.adapter.projectRoot, input2.filePath).replaceAll("\\", "/")}`;
7056
+ }
7057
+ function buildWorkersRuntimeGraphHash(input2) {
7058
+ const sourceFiles = Object.entries(input2.analysis.sourceFiles).map(([filePath, contents]) => ({
7059
+ filePath: workersRuntimeGraphFilePath({
7060
+ entryFile: input2.entryFile,
7061
+ filePath,
7062
+ adapter: input2.adapter
7063
+ }),
7064
+ hash: sha256(
7065
+ filePath === input2.entryFile ? canonicalizeRootPlayNameForWorkersRuntimeHash(contents) : contents
7066
+ )
7067
+ })).sort((left, right) => left.filePath.localeCompare(right.filePath));
7068
+ return sha256(
7069
+ JSON.stringify({
7070
+ entryFile: "<entry>",
7071
+ entryExport: input2.exportName,
7072
+ localFiles: sourceFiles,
7073
+ nodeBuiltins: [...input2.analysis.importPolicy.nodeBuiltins].sort(),
7074
+ packages: input2.analysis.importPolicy.packages.map(({ name, version }) => ({ name, version })).sort((left, right) => left.name.localeCompare(right.name)),
7075
+ importedPlayDependencies: input2.analysis.importedPlayDependencies.map((dependency) => ({
7076
+ filePath: workersRuntimeGraphFilePath({
7077
+ entryFile: input2.entryFile,
7078
+ filePath: dependency.filePath,
7079
+ adapter: input2.adapter
7080
+ }),
7081
+ playName: dependency.playName
7082
+ })).sort((left, right) => left.filePath.localeCompare(right.filePath))
7083
+ })
7084
+ );
7085
+ }
6967
7086
  function readPackageVersionFromPackageJson(packageJsonPath, packageName) {
6968
7087
  try {
6969
- const packageJson = JSON.parse(readFileSync5(packageJsonPath, "utf-8"));
7088
+ const packageJson = JSON.parse(readFileSync6(packageJsonPath, "utf-8"));
6970
7089
  if (packageJson.name === packageName && typeof packageJson.version === "string") {
6971
7090
  return packageJson.version;
6972
7091
  }
@@ -6983,16 +7102,16 @@ function findPackageJsonPathFrom(startDir, packageName) {
6983
7102
  }
6984
7103
  let current = startDir;
6985
7104
  while (true) {
6986
- const packageJsonPath = join4(
7105
+ const packageJsonPath = join5(
6987
7106
  current,
6988
7107
  "node_modules",
6989
7108
  packageName,
6990
7109
  "package.json"
6991
7110
  );
6992
- if (existsSync5(packageJsonPath)) {
7111
+ if (existsSync6(packageJsonPath)) {
6993
7112
  return packageJsonPath;
6994
7113
  }
6995
- const parent = dirname5(current);
7114
+ const parent = dirname6(current);
6996
7115
  if (parent === current) {
6997
7116
  return null;
6998
7117
  }
@@ -7001,9 +7120,9 @@ function findPackageJsonPathFrom(startDir, packageName) {
7001
7120
  }
7002
7121
  function findPackageJsonPath(packageName, fromFile, adapter) {
7003
7122
  const startDirs = [
7004
- resolve6(dirname5(fromFile)),
7123
+ resolve6(dirname6(fromFile)),
7005
7124
  resolve6(adapter.projectRoot),
7006
- resolve6(dirname5(adapter.sdkPackageJson))
7125
+ resolve6(dirname6(adapter.sdkPackageJson))
7007
7126
  ];
7008
7127
  const seen = /* @__PURE__ */ new Set();
7009
7128
  for (const startDir of startDirs) {
@@ -7012,16 +7131,16 @@ function findPackageJsonPath(packageName, fromFile, adapter) {
7012
7131
  const packageJsonPath = findPackageJsonPathFrom(startDir, packageName);
7013
7132
  if (packageJsonPath) return packageJsonPath;
7014
7133
  }
7015
- const adapterNodeModulesPackageJson = join4(
7134
+ const adapterNodeModulesPackageJson = join5(
7016
7135
  adapter.nodeModulesDir,
7017
7136
  packageName,
7018
7137
  "package.json"
7019
7138
  );
7020
- return existsSync5(adapterNodeModulesPackageJson) ? adapterNodeModulesPackageJson : null;
7139
+ return existsSync6(adapterNodeModulesPackageJson) ? adapterNodeModulesPackageJson : null;
7021
7140
  }
7022
7141
  function localSdkAliasPlugin(adapter, options) {
7023
7142
  const entryFile = options?.workersRuntime ? adapter.sdkWorkersEntryFile : adapter.sdkEntryFile;
7024
- if (!existsSync5(entryFile)) {
7143
+ if (!existsSync6(entryFile)) {
7025
7144
  return null;
7026
7145
  }
7027
7146
  return {
@@ -7031,7 +7150,7 @@ function localSdkAliasPlugin(adapter, options) {
7031
7150
  path: entryFile
7032
7151
  }));
7033
7152
  buildContext.onResolve({ filter: /^deepline\/helpers$/ }, () => ({
7034
- path: join4(adapter.sdkSourceRoot, "helpers.ts")
7153
+ path: join5(adapter.sdkSourceRoot, "helpers.ts")
7035
7154
  }));
7036
7155
  }
7037
7156
  };
@@ -7064,7 +7183,7 @@ function workersNamedPlayEntryAliasPlugin(playFilePath, exportName) {
7064
7183
  contents: `export { ${exportName} as default } from ${JSON.stringify(playFilePath)};
7065
7184
  `,
7066
7185
  loader: "ts",
7067
- resolveDir: dirname5(playFilePath)
7186
+ resolveDir: dirname6(playFilePath)
7068
7187
  })
7069
7188
  );
7070
7189
  }
@@ -7235,7 +7354,7 @@ function importedPlayProxyPlugin(importedPlayDependencies) {
7235
7354
  return {
7236
7355
  contents: buildImportedPlayProxyModule(dependency.playName),
7237
7356
  loader: "ts",
7238
- resolveDir: dirname5(args.path)
7357
+ resolveDir: dirname6(args.path)
7239
7358
  };
7240
7359
  }
7241
7360
  );
@@ -7254,7 +7373,7 @@ async function resolveLocalImport(fromFile, specifier) {
7254
7373
  if (specifier.startsWith("file:")) {
7255
7374
  return normalizeLocalPath(new URL(specifier).pathname);
7256
7375
  }
7257
- const base = isAbsolute(specifier) ? resolve6(specifier) : resolve6(dirname5(fromFile), specifier);
7376
+ const base = isAbsolute(specifier) ? resolve6(specifier) : resolve6(dirname6(fromFile), specifier);
7258
7377
  const candidates = [base];
7259
7378
  const explicitExtension = extname(base).toLowerCase();
7260
7379
  if (!explicitExtension) {
@@ -7262,7 +7381,7 @@ async function resolveLocalImport(fromFile, specifier) {
7262
7381
  ...SOURCE_EXTENSIONS.map((extension) => `${base}${extension}`)
7263
7382
  );
7264
7383
  candidates.push(
7265
- ...SOURCE_EXTENSIONS.map((extension) => join4(base, `index${extension}`))
7384
+ ...SOURCE_EXTENSIONS.map((extension) => join5(base, `index${extension}`))
7266
7385
  );
7267
7386
  } else if ([".js", ".jsx", ".mjs", ".cjs"].includes(explicitExtension)) {
7268
7387
  const stem = base.slice(0, -explicitExtension.length);
@@ -7281,9 +7400,9 @@ async function resolveLocalImport(fromFile, specifier) {
7281
7400
  }
7282
7401
  function resolvePackageImport(specifier, fromFile, adapter) {
7283
7402
  const packageName = getPackageName(specifier);
7284
- if (packageName === "deepline" && existsSync5(adapter.sdkPackageJson)) {
7403
+ if (packageName === "deepline" && existsSync6(adapter.sdkPackageJson)) {
7285
7404
  const packageJson = JSON.parse(
7286
- readFileSync5(adapter.sdkPackageJson, "utf-8")
7405
+ readFileSync6(adapter.sdkPackageJson, "utf-8")
7287
7406
  );
7288
7407
  return {
7289
7408
  name: "deepline",
@@ -7435,7 +7554,7 @@ async function computeWorkersHarnessFingerprintWithAdapter(adapter) {
7435
7554
  const entries2 = await readdir(rootDir, { withFileTypes: true });
7436
7555
  const tsFiles2 = entries2.filter((entry) => entry.isFile() && /\.[cm]?ts$/.test(entry.name)).map((entry) => entry.name).sort();
7437
7556
  for (const name of tsFiles2) {
7438
- await addFilePart(parts2, rootDir, join4(rootDir, name));
7557
+ await addFilePart(parts2, rootDir, join5(rootDir, name));
7439
7558
  }
7440
7559
  };
7441
7560
  const collectIntegrationBatchingFiles = async (rootDir, parts2) => {
@@ -7444,10 +7563,10 @@ async function computeWorkersHarnessFingerprintWithAdapter(adapter) {
7444
7563
  const filePaths = [];
7445
7564
  for (const entry of entries2) {
7446
7565
  if (entry.isFile() && (entry.name === "play-runtime-batching-registry.ts" || /^batching.*\.ts$/.test(entry.name))) {
7447
- filePaths.push(join4(rootDir, entry.name));
7566
+ filePaths.push(join5(rootDir, entry.name));
7448
7567
  }
7449
7568
  if (entry.isDirectory()) {
7450
- const batchingFile = join4(rootDir, entry.name, "batching.ts");
7569
+ const batchingFile = join5(rootDir, entry.name, "batching.ts");
7451
7570
  if (await fileExists(batchingFile)) {
7452
7571
  filePaths.push(batchingFile);
7453
7572
  }
@@ -7466,7 +7585,7 @@ async function computeWorkersHarnessFingerprintWithAdapter(adapter) {
7466
7585
  await addFilePart(
7467
7586
  parts,
7468
7587
  adapter.workersHarnessFilesDir,
7469
- join4(adapter.workersHarnessFilesDir, name)
7588
+ join5(adapter.workersHarnessFilesDir, name)
7470
7589
  );
7471
7590
  }
7472
7591
  for (const dir of adapter.workersRuntimeFingerprintDirs ?? []) {
@@ -7479,7 +7598,7 @@ async function computeWorkersHarnessFingerprintWithAdapter(adapter) {
7479
7598
  return sha256(JSON.stringify(parts));
7480
7599
  }
7481
7600
  function artifactCachePath(graphHash, artifactKind, adapter) {
7482
- return join4(
7601
+ return join5(
7483
7602
  adapter.cacheDir ?? PLAY_ARTIFACT_CACHE_DIR,
7484
7603
  `${graphHash}.${artifactKind}.json`
7485
7604
  );
@@ -7514,7 +7633,7 @@ function normalizeSourceMapForRuntime(sourceMapText, projectRoot) {
7514
7633
  if (sourcePath.startsWith("data:") || sourcePath.startsWith("node:") || sourcePath.startsWith("/") || /^[a-zA-Z]+:\/\//.test(sourcePath)) {
7515
7634
  return sourcePath;
7516
7635
  }
7517
- return join4(projectRoot, sourcePath);
7636
+ return join5(projectRoot, sourcePath);
7518
7637
  });
7519
7638
  parsed.sourceRoot = void 0;
7520
7639
  return JSON.stringify(parsed);
@@ -7546,7 +7665,7 @@ async function runEsbuildForCjsNode(entryFile, importedPlayDependencies, adapter
7546
7665
  ...namedExportShim ? {
7547
7666
  stdin: {
7548
7667
  contents: namedExportShim,
7549
- resolveDir: dirname5(entryFile),
7668
+ resolveDir: dirname6(entryFile),
7550
7669
  sourcefile: `${basename(entryFile)}.${exportName}.entry.ts`,
7551
7670
  loader: "ts"
7552
7671
  }
@@ -7696,10 +7815,13 @@ async function bundlePlayFile(filePath, options) {
7696
7815
  adapter.warnAboutNonDevelopmentBundling?.(absolutePath);
7697
7816
  try {
7698
7817
  const analysis = await analyzeSourceGraph(absolutePath, adapter);
7699
- analysis.graphHash = sha256(
7700
- `${analysis.graphHash}
7701
- entry-export:${exportName}`
7702
- );
7818
+ analysis.graphHash = target === PLAY_ARTIFACT_KINDS.esmWorkers ? buildWorkersRuntimeGraphHash({
7819
+ analysis,
7820
+ entryFile: absolutePath,
7821
+ adapter,
7822
+ exportName
7823
+ }) : sha256(`${analysis.graphHash}
7824
+ entry-export:${exportName}`);
7703
7825
  if (targetAdapter.includeWorkersHarnessInGraphHash) {
7704
7826
  const harnessFingerprint = await computeWorkersHarnessFingerprintWithAdapter(adapter);
7705
7827
  analysis.graphHash = sha256(
@@ -7735,11 +7857,8 @@ workers-harness:${harnessFingerprint}`
7735
7857
  errors: typecheckErrors
7736
7858
  };
7737
7859
  }
7738
- const cachedArtifact = await readArtifactCache(
7739
- analysis.graphHash,
7740
- target,
7741
- adapter
7742
- );
7860
+ const canUseArtifactCache = target !== PLAY_ARTIFACT_KINDS.esmWorkers;
7861
+ const cachedArtifact = canUseArtifactCache ? await readArtifactCache(analysis.graphHash, target, adapter) : null;
7743
7862
  const discoveredFiles = await adapter.discoverPackagedLocalFiles(absolutePath);
7744
7863
  if (cachedArtifact) {
7745
7864
  const cachedArtifactSizeError = getBundleSizeError(
@@ -7756,7 +7875,13 @@ workers-harness:${harnessFingerprint}`
7756
7875
  }
7757
7876
  return {
7758
7877
  success: true,
7759
- artifact: { ...cachedArtifact, cacheHit: true },
7878
+ artifact: {
7879
+ ...cachedArtifact,
7880
+ entryFile: absolutePath,
7881
+ sourceHash: analysis.sourceHash,
7882
+ importPolicy: analysis.importPolicy,
7883
+ cacheHit: true
7884
+ },
7760
7885
  sourceCode: analysis.sourceCode,
7761
7886
  sourceFiles: analysis.sourceFiles,
7762
7887
  filePath: absolutePath,
@@ -7817,7 +7942,9 @@ workers-harness:${harnessFingerprint}`
7817
7942
  generatedAt: Date.now(),
7818
7943
  cacheHit: false
7819
7944
  };
7820
- await writeArtifactCache(artifact, adapter);
7945
+ if (canUseArtifactCache) {
7946
+ await writeArtifactCache(artifact, adapter);
7947
+ }
7821
7948
  return {
7822
7949
  success: true,
7823
7950
  artifact,
@@ -7941,11 +8068,11 @@ import { createHash as createHash2 } from "crypto";
7941
8068
  import { readFile as readFile2, stat as stat2 } from "fs/promises";
7942
8069
  import {
7943
8070
  basename as basename2,
7944
- dirname as dirname6,
8071
+ dirname as dirname7,
7945
8072
  extname as extname2,
7946
8073
  isAbsolute as isAbsolute2,
7947
- join as join5,
7948
- relative,
8074
+ join as join6,
8075
+ relative as relative2,
7949
8076
  resolve as resolve7
7950
8077
  } from "path";
7951
8078
  var SOURCE_EXTENSIONS2 = [
@@ -8162,11 +8289,11 @@ async function fileExists2(filePath) {
8162
8289
  }
8163
8290
  }
8164
8291
  function isPathInsideDirectory2(filePath, directory) {
8165
- const relativePath = relative(directory, filePath);
8292
+ const relativePath = relative2(directory, filePath);
8166
8293
  return relativePath === "" || !relativePath.startsWith("..") && !isAbsolute2(relativePath);
8167
8294
  }
8168
8295
  async function resolveLocalImport2(fromFile, specifier) {
8169
- const base = isAbsolute2(specifier) ? resolve7(specifier) : resolve7(dirname6(fromFile), specifier);
8296
+ const base = isAbsolute2(specifier) ? resolve7(specifier) : resolve7(dirname7(fromFile), specifier);
8170
8297
  const candidates = [base];
8171
8298
  const explicitExtension = extname2(base).toLowerCase();
8172
8299
  if (!explicitExtension) {
@@ -8174,7 +8301,7 @@ async function resolveLocalImport2(fromFile, specifier) {
8174
8301
  ...SOURCE_EXTENSIONS2.map((extension) => `${base}${extension}`)
8175
8302
  );
8176
8303
  candidates.push(
8177
- ...SOURCE_EXTENSIONS2.map((extension) => join5(base, `index${extension}`))
8304
+ ...SOURCE_EXTENSIONS2.map((extension) => join6(base, `index${extension}`))
8178
8305
  );
8179
8306
  } else if ([".js", ".jsx", ".mjs", ".cjs"].includes(explicitExtension)) {
8180
8307
  const stem = base.slice(0, -explicitExtension.length);
@@ -8193,7 +8320,7 @@ async function resolveLocalImport2(fromFile, specifier) {
8193
8320
  }
8194
8321
  async function discoverPackagedLocalFiles(entryFile) {
8195
8322
  const absoluteEntryFile = resolve7(entryFile);
8196
- const packagingRoot = dirname6(absoluteEntryFile);
8323
+ const packagingRoot = dirname7(absoluteEntryFile);
8197
8324
  const files = /* @__PURE__ */ new Map();
8198
8325
  const unresolved = [];
8199
8326
  const visitedFiles = /* @__PURE__ */ new Set();
@@ -8235,7 +8362,7 @@ async function discoverPackagedLocalFiles(entryFile) {
8235
8362
  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."
8236
8363
  });
8237
8364
  } else {
8238
- const absoluteCsvPath = resolve7(dirname6(absolutePath), resolvedPath);
8365
+ const absoluteCsvPath = resolve7(dirname7(absolutePath), resolvedPath);
8239
8366
  if (isAbsolute2(resolvedPath) || !isPathInsideDirectory2(absoluteCsvPath, packagingRoot)) {
8240
8367
  unresolved.push({
8241
8368
  sourceFragment: sourceCode.slice(argument.start, argument.end).trim(),
@@ -8274,14 +8401,14 @@ async function discoverPackagedLocalFiles(entryFile) {
8274
8401
 
8275
8402
  // src/plays/bundle-play-file.ts
8276
8403
  var PLAY_BUNDLE_CACHE_VERSION2 = 30;
8277
- var MODULE_DIR = dirname7(fileURLToPath(import.meta.url));
8404
+ var MODULE_DIR = dirname8(fileURLToPath(import.meta.url));
8278
8405
  var SDK_PACKAGE_ROOT = resolve8(MODULE_DIR, "..", "..");
8279
8406
  var SOURCE_REPO_ROOT = resolve8(SDK_PACKAGE_ROOT, "..");
8280
- var HAS_SOURCE_BUNDLING_SOURCES = existsSync6(
8407
+ var HAS_SOURCE_BUNDLING_SOURCES = existsSync7(
8281
8408
  resolve8(SOURCE_REPO_ROOT, "apps", "play-runner-workers", "src", "entry.ts")
8282
8409
  );
8283
8410
  var PACKAGED_REPO_ROOT = resolve8(SDK_PACKAGE_ROOT, "dist", "repo");
8284
- var HAS_PACKAGED_BUNDLING_SOURCES = existsSync6(
8411
+ var HAS_PACKAGED_BUNDLING_SOURCES = existsSync7(
8285
8412
  resolve8(PACKAGED_REPO_ROOT, "apps", "play-runner-workers", "src", "entry.ts")
8286
8413
  );
8287
8414
  var PROJECT_ROOT = HAS_SOURCE_BUNDLING_SOURCES ? SOURCE_REPO_ROOT : HAS_PACKAGED_BUNDLING_SOURCES ? PACKAGED_REPO_ROOT : resolve8(SDK_PACKAGE_ROOT, "..");
@@ -8327,14 +8454,14 @@ function createSdkPlayBundlingAdapter() {
8327
8454
  return {
8328
8455
  projectRoot: PROJECT_ROOT,
8329
8456
  nodeModulesDir: resolve8(PROJECT_ROOT, "node_modules"),
8330
- cacheDir: join6(
8457
+ cacheDir: join7(
8331
8458
  tmpdir2(),
8332
8459
  `deepline-play-artifacts-v${PLAY_BUNDLE_CACHE_VERSION2}`
8333
8460
  ),
8334
8461
  sdkSourceRoot: SDK_SOURCE_ROOT,
8335
8462
  sdkPackageJson: SDK_PACKAGE_JSON,
8336
8463
  sdkEntryFile: SDK_ENTRY_FILE,
8337
- sdkTypesEntryFile: HAS_SOURCE_BUNDLING_SOURCES || !existsSync6(SDK_TYPES_ENTRY_FILE) ? SDK_ENTRY_FILE : SDK_TYPES_ENTRY_FILE,
8464
+ sdkTypesEntryFile: HAS_SOURCE_BUNDLING_SOURCES || !existsSync7(SDK_TYPES_ENTRY_FILE) ? SDK_ENTRY_FILE : SDK_TYPES_ENTRY_FILE,
8338
8465
  sdkWorkersEntryFile: SDK_WORKERS_ENTRY_FILE,
8339
8466
  workersHarnessEntryFile: WORKERS_HARNESS_ENTRY_FILE,
8340
8467
  workersHarnessFilesDir: WORKERS_HARNESS_FILES_DIR,
@@ -8357,8 +8484,8 @@ async function bundlePlayFile2(filePath, options = {}) {
8357
8484
  }
8358
8485
 
8359
8486
  // src/cli/commands/plays/bootstrap.ts
8360
- import { closeSync, openSync, readSync, statSync, writeFileSync as writeFileSync6 } from "fs";
8361
- import { isAbsolute as isAbsolute3, relative as relative2, resolve as resolve9 } from "path";
8487
+ import { closeSync, openSync, readSync, statSync, writeFileSync as writeFileSync7 } from "fs";
8488
+ import { isAbsolute as isAbsolute3, relative as relative3, resolve as resolve9 } from "path";
8362
8489
  import { parse as parseCsvSync } from "csv-parse/sync";
8363
8490
 
8364
8491
  // ../shared_libs/plays/bootstrap-routes.ts
@@ -8863,7 +8990,7 @@ ${properties}
8863
8990
  function packagedCsvPathForPlay(csvPath) {
8864
8991
  const playDir = process.cwd();
8865
8992
  const absoluteCsvPath = resolve9(csvPath);
8866
- const relativePath = relative2(playDir, absoluteCsvPath);
8993
+ const relativePath = relative3(playDir, absoluteCsvPath);
8867
8994
  if (relativePath === "" || relativePath.startsWith("..") || isAbsolute3(relativePath)) {
8868
8995
  throw new PlayBootstrapUsageError(
8869
8996
  `--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.`
@@ -9783,7 +9910,7 @@ async function runPlayBootstrap(args) {
9783
9910
  ...csvContext
9784
9911
  });
9785
9912
  if (options.out) {
9786
- writeFileSync6(resolve9(options.out), source, "utf-8");
9913
+ writeFileSync7(resolve9(options.out), source, "utf-8");
9787
9914
  process.stdout.write(`Wrote ${resolve9(options.out)}
9788
9915
  `);
9789
9916
  return 0;
@@ -10258,15 +10385,15 @@ function materializeRemotePlaySource(input2) {
10258
10385
  return null;
10259
10386
  }
10260
10387
  const outputPath = input2.outPath ?? defaultMaterializedPlayPath(input2.playName);
10261
- if (existsSync7(outputPath)) {
10262
- const existingSource = readFileSync6(outputPath, "utf-8");
10388
+ if (existsSync8(outputPath)) {
10389
+ const existingSource = readFileSync7(outputPath, "utf-8");
10263
10390
  if (existingSource === input2.sourceCode) {
10264
10391
  return { path: outputPath, status: "unchanged", created: false };
10265
10392
  }
10266
- writeFileSync7(outputPath, input2.sourceCode, "utf-8");
10393
+ writeFileSync8(outputPath, input2.sourceCode, "utf-8");
10267
10394
  return { path: outputPath, status: "updated", created: false };
10268
10395
  }
10269
- writeFileSync7(outputPath, input2.sourceCode, "utf-8");
10396
+ writeFileSync8(outputPath, input2.sourceCode, "utf-8");
10270
10397
  return { path: outputPath, status: "created", created: true };
10271
10398
  }
10272
10399
  function formatLoadedPlayMessage(materializedFile) {
@@ -10311,7 +10438,7 @@ function extractPlayName(code, filePath) {
10311
10438
  throw buildMissingDefinePlayError(filePath);
10312
10439
  }
10313
10440
  function isFileTarget(target) {
10314
- return existsSync7(resolve10(target));
10441
+ return existsSync8(resolve10(target));
10315
10442
  }
10316
10443
  function looksLikeRunId(target) {
10317
10444
  return /^play\/[^/]+\/run\/[^/]+/.test(target.trim());
@@ -10340,7 +10467,7 @@ function parsePositiveInteger3(value, flagName) {
10340
10467
  return parsed;
10341
10468
  }
10342
10469
  function parseJsonInput(raw) {
10343
- const source = raw.startsWith("@") ? readFileSync6(resolve10(raw.slice(1)), "utf-8") : raw;
10470
+ const source = raw.startsWith("@") ? readFileSync7(resolve10(raw.slice(1)), "utf-8") : raw;
10344
10471
  const parsed = JSON.parse(source);
10345
10472
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
10346
10473
  throw new Error("--input must be a JSON object.");
@@ -10442,7 +10569,7 @@ function fileInputBindingsFromStaticPipeline(staticPipeline) {
10442
10569
  function isLocalFilePathValue(value) {
10443
10570
  if (typeof value !== "string" || !value.trim()) return false;
10444
10571
  if (/^[a-z][a-z0-9+.-]*:\/\//i.test(value.trim())) return false;
10445
- return existsSync7(resolve10(value));
10572
+ return existsSync8(resolve10(value));
10446
10573
  }
10447
10574
  function inputContainsLocalFilePath(value) {
10448
10575
  if (isLocalFilePathValue(value)) {
@@ -10458,6 +10585,15 @@ function inputContainsLocalFilePath(value) {
10458
10585
  }
10459
10586
  return false;
10460
10587
  }
10588
+ function sourceGraphMentionsRunPlay(node) {
10589
+ const runPlayCallPattern = /\brunPlay\b/;
10590
+ if (runPlayCallPattern.test(node.sourceCode)) {
10591
+ return true;
10592
+ }
10593
+ return Object.values(node.sourceFiles).some(
10594
+ (source) => runPlayCallPattern.test(source)
10595
+ );
10596
+ }
10461
10597
  function isUrlValue(value) {
10462
10598
  return /^[a-z][a-z0-9+.-]*:\/\//i.test(value.trim());
10463
10599
  }
@@ -10480,7 +10616,7 @@ function collectLocalFileInputRefs(value, inputPath, key, out) {
10480
10616
  const looksLikeFile = /\.[a-z0-9]{1,8}$/i.test(trimmed);
10481
10617
  if (keyIsCsvData) {
10482
10618
  out.push({ inputPath, value: trimmed, isCsvData: true });
10483
- } else if (endsWithCsv || looksLikeFile && existsSync7(resolve10(trimmed))) {
10619
+ } else if (endsWithCsv || looksLikeFile && existsSync8(resolve10(trimmed))) {
10484
10620
  out.push({ inputPath, value: trimmed, isCsvData: false });
10485
10621
  }
10486
10622
  return;
@@ -10523,7 +10659,7 @@ function preflightLocalFileInputs(runtimeInput) {
10523
10659
  }
10524
10660
  for (const ref of refs) {
10525
10661
  const absolutePath = resolve10(ref.value);
10526
- if (!existsSync7(absolutePath)) {
10662
+ if (!existsSync8(absolutePath)) {
10527
10663
  throw new DeeplineError(
10528
10664
  `Input ${ref.inputPath} references a local file that does not exist: ${ref.value} (resolved to ${absolutePath}). No run was created.`,
10529
10665
  void 0,
@@ -10559,7 +10695,7 @@ function preflightLocalFileInputs(runtimeInput) {
10559
10695
  function preflightCsvDataInput(ref, absolutePath) {
10560
10696
  let content;
10561
10697
  try {
10562
- content = readFileSync6(absolutePath, "utf-8");
10698
+ content = readFileSync7(absolutePath, "utf-8");
10563
10699
  } catch (error) {
10564
10700
  throw new DeeplineError(
10565
10701
  `Input ${ref.inputPath} CSV ${ref.value} is not readable: ${error instanceof Error ? error.message : String(error)}. No run was created.`,
@@ -10674,7 +10810,7 @@ async function stageFileInputArgs(input2) {
10674
10810
  };
10675
10811
  }
10676
10812
  function stageFile(logicalPath, absolutePath) {
10677
- const buffer = readFileSync6(absolutePath);
10813
+ const buffer = readFileSync7(absolutePath);
10678
10814
  return {
10679
10815
  logicalPath,
10680
10816
  contentBase64: buffer.toString("base64"),
@@ -13465,7 +13601,7 @@ async function handlePlayCheck(args) {
13465
13601
  }
13466
13602
  }
13467
13603
  const absolutePlayPath = resolve10(options.target);
13468
- const sourceCode = readFileSync6(absolutePlayPath, "utf-8");
13604
+ const sourceCode = readFileSync7(absolutePlayPath, "utf-8");
13469
13605
  let graph;
13470
13606
  try {
13471
13607
  graph = await collectBundledPlayGraph(absolutePlayPath);
@@ -13549,7 +13685,7 @@ async function handleFileBackedRun(options) {
13549
13685
  const sourceCode = traceCliSync(
13550
13686
  "cli.play_file_read_source",
13551
13687
  { targetKind: "file" },
13552
- () => readFileSync6(absolutePlayPath, "utf-8")
13688
+ () => readFileSync7(absolutePlayPath, "utf-8")
13553
13689
  );
13554
13690
  const runtimeInput = options.input ? { ...options.input } : {};
13555
13691
  try {
@@ -13565,11 +13701,23 @@ async function handleFileBackedRun(options) {
13565
13701
  { targetKind: "file" },
13566
13702
  () => collectBundledPlayGraph(absolutePlayPath, options.profile)
13567
13703
  );
13568
- await traceCliSpan(
13569
- "cli.play_file_compile_manifests",
13570
- { targetKind: "file" },
13571
- () => compileBundledPlayGraphManifests(client2, graph)
13572
- );
13704
+ const canDeferCompilerManifest = graph.root.importedPlayDependencies.length === 0 && !sourceGraphMentionsRunPlay(graph.root) && !inputContainsLocalFilePath(runtimeInput);
13705
+ if (canDeferCompilerManifest) {
13706
+ recordCliTrace({
13707
+ phase: "cli.play_file_compile_manifests",
13708
+ ms: 0,
13709
+ ok: true,
13710
+ targetKind: "file",
13711
+ skipped: true,
13712
+ reason: "validated_by_run_route"
13713
+ });
13714
+ } else {
13715
+ await traceCliSpan(
13716
+ "cli.play_file_compile_manifests",
13717
+ { targetKind: "file", skipped: false },
13718
+ () => compileBundledPlayGraphManifests(client2, graph)
13719
+ );
13720
+ }
13573
13721
  progress.phase("compiled play");
13574
13722
  } catch (error) {
13575
13723
  progress.fail();
@@ -13596,9 +13744,9 @@ async function handleFileBackedRun(options) {
13596
13744
  const packagedFileUploads = bundleResult.packagedFiles.map(
13597
13745
  (file) => stageFile(file.logicalPath, file.absolutePath)
13598
13746
  );
13599
- const compilerManifest = requireCompilerManifest(bundleResult);
13747
+ const compilerManifest = bundleResult.compilerManifest ?? null;
13600
13748
  const fileInputBindings = fileInputBindingsFromStaticPipeline(
13601
- compilerManifest.staticPipeline
13749
+ compilerManifest?.staticPipeline
13602
13750
  );
13603
13751
  const stagedFileInputs = await traceCliSpan(
13604
13752
  "cli.play_stage_inputs",
@@ -13618,7 +13766,7 @@ async function handleFileBackedRun(options) {
13618
13766
  sourceCode: bundleResult.sourceCode,
13619
13767
  sourceFiles: bundleResult.sourceFiles,
13620
13768
  runtimeArtifact: bundleResult.artifact,
13621
- compilerManifest,
13769
+ ...compilerManifest ? { compilerManifest } : {},
13622
13770
  packagedFileUploads,
13623
13771
  ...Object.keys(runtimeInput).length > 0 ? { input: runtimeInput } : {},
13624
13772
  ...stagedFileInputs.inputFile ? { inputFile: stagedFileInputs.inputFile } : {},
@@ -13858,8 +14006,8 @@ async function handlePlayRun(args) {
13858
14006
  }
13859
14007
  const resolved = resolve10(options.target.path);
13860
14008
  console.error(`File not found: ${resolved}`);
13861
- const dir = dirname8(resolved);
13862
- if (existsSync7(dir)) {
14009
+ const dir = dirname9(resolved);
14010
+ if (existsSync8(dir)) {
13863
14011
  const base = basename3(resolved);
13864
14012
  try {
13865
14013
  const siblings = readdirSync(dir).filter(
@@ -13868,7 +14016,7 @@ async function handlePlayRun(args) {
13868
14016
  if (siblings.length > 0) {
13869
14017
  console.error(`Did you mean one of these?`);
13870
14018
  for (const s of siblings.slice(0, 5)) {
13871
- console.error(` ${join7(dir, s)}`);
14019
+ console.error(` ${join8(dir, s)}`);
13872
14020
  }
13873
14021
  }
13874
14022
  } catch {
@@ -14030,7 +14178,7 @@ async function handleRunLogs(args) {
14030
14178
  if (outPath) {
14031
14179
  const result2 = await client2.runs.logs(runId, { all: true });
14032
14180
  const logs = result2.entries;
14033
- writeFileSync7(outPath, `${logs.join("\n")}${logs.length > 0 ? "\n" : ""}`);
14181
+ writeFileSync8(outPath, `${logs.join("\n")}${logs.length > 0 ? "\n" : ""}`);
14034
14182
  printCommandEnvelope(
14035
14183
  {
14036
14184
  runId: result2.runId,
@@ -14203,7 +14351,7 @@ async function handleRunExport(args) {
14203
14351
  }
14204
14352
  };
14205
14353
  if (metadataOutPath) {
14206
- writeFileSync7(
14354
+ writeFileSync8(
14207
14355
  metadataOutPath,
14208
14356
  `${JSON.stringify(payload, null, 2)}
14209
14357
  `,
@@ -14238,7 +14386,7 @@ async function handlePlayGet(args) {
14238
14386
  outPath = resolve10(args[++index]);
14239
14387
  }
14240
14388
  }
14241
- const playName = isFileTarget(target) ? extractPlayName(readFileSync6(resolve10(target), "utf-8"), resolve10(target)) : parseReferencedPlayTarget2(target).playName;
14389
+ const playName = isFileTarget(target) ? extractPlayName(readFileSync7(resolve10(target), "utf-8"), resolve10(target)) : parseReferencedPlayTarget2(target).playName;
14242
14390
  const detail = isFileTarget(target) ? await client2.getPlay(playName) : await assertCanonicalNamedPlayReference(client2, target);
14243
14391
  const resolvedSource = detail.play.workingRevision?.sourceCode ?? detail.play.liveRevision?.sourceCode ?? detail.play.currentRevision?.sourceCode ?? detail.play.sourceCode ?? "";
14244
14392
  const materializedFile = outPath ? materializeRemotePlaySource({
@@ -14681,7 +14829,7 @@ async function handlePlayDescribe(args) {
14681
14829
  const definedName = isFileTarget(playName) ? (() => {
14682
14830
  try {
14683
14831
  return extractPlayName(
14684
- readFileSync6(resolve10(playName), "utf-8"),
14832
+ readFileSync7(resolve10(playName), "utf-8"),
14685
14833
  playName
14686
14834
  );
14687
14835
  } catch {
@@ -17011,10 +17159,10 @@ function expandAtFilePath(rawPath) {
17011
17159
  (_match, bareName, bracedName) => process.env[bareName ?? bracedName ?? ""] ?? ""
17012
17160
  );
17013
17161
  if (expanded === "~") {
17014
- return homedir4();
17162
+ return homedir5();
17015
17163
  }
17016
17164
  if (expanded.startsWith("~/") || expanded.startsWith("~\\")) {
17017
- return join8(homedir4(), expanded.slice(2));
17165
+ return join9(homedir5(), expanded.slice(2));
17018
17166
  }
17019
17167
  return expanded;
17020
17168
  }
@@ -17875,9 +18023,9 @@ async function persistEnrichFailureReport(input2) {
17875
18023
  if (input2.jobs.length === 0) {
17876
18024
  return null;
17877
18025
  }
17878
- const stateDir = join8(homedir4(), ".local", "deepline", "runtime", "state");
18026
+ const stateDir = join9(homedir5(), ".local", "deepline", "runtime", "state");
17879
18027
  await mkdir4(stateDir, { recursive: true });
17880
- const reportPath = join8(
18028
+ const reportPath = join9(
17881
18029
  stateDir,
17882
18030
  `run-block-failures-${Math.floor(Date.now() / 1e3)}-${process.pid}.json`
17883
18031
  );
@@ -18339,8 +18487,8 @@ function registerEnrichCommand(program) {
18339
18487
  forceAliases,
18340
18488
  playName: options.name
18341
18489
  });
18342
- const tempDir = await mkdtemp(join8(tmpdir3(), "deepline-enrich-play-"));
18343
- const tempPlay = join8(tempDir, "deepline-enrich.play.ts");
18490
+ const tempDir = await mkdtemp(join9(tmpdir3(), "deepline-enrich-play-"));
18491
+ const tempPlay = join9(tempDir, "deepline-enrich.play.ts");
18344
18492
  try {
18345
18493
  await writeFile4(tempPlay, playSource, "utf8");
18346
18494
  const runtimeInput = {
@@ -18506,15 +18654,15 @@ Examples:
18506
18654
 
18507
18655
  // src/cli/commands/sessions.ts
18508
18656
  import {
18509
- existsSync as existsSync8,
18510
- mkdirSync as mkdirSync4,
18657
+ existsSync as existsSync9,
18658
+ mkdirSync as mkdirSync5,
18511
18659
  readdirSync as readdirSync2,
18512
- readFileSync as readFileSync7,
18660
+ readFileSync as readFileSync8,
18513
18661
  statSync as statSync3,
18514
- writeFileSync as writeFileSync8
18662
+ writeFileSync as writeFileSync9
18515
18663
  } from "fs";
18516
- import { homedir as homedir5, platform } from "os";
18517
- import { basename as basename4, dirname as dirname9, join as join9, resolve as resolve12 } from "path";
18664
+ import { homedir as homedir6, platform } from "os";
18665
+ import { basename as basename4, dirname as dirname10, join as join10, resolve as resolve12 } from "path";
18518
18666
  import { gzipSync } from "zlib";
18519
18667
  import { randomUUID } from "crypto";
18520
18668
  var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
@@ -18528,7 +18676,7 @@ var MAX_EVENT_OBJECT_KEYS = 80;
18528
18676
  var TRUNCATION_MARKER = "...[truncated]";
18529
18677
  var NOISE_EVENT_TYPES = /* @__PURE__ */ new Set(["progress", "file-history-snapshot"]);
18530
18678
  function homeDir() {
18531
- return process.env.HOME?.trim() || homedir5();
18679
+ return process.env.HOME?.trim() || homedir6();
18532
18680
  }
18533
18681
  function detectShellContext() {
18534
18682
  const shellPath = process.env.SHELL?.trim() || process.env.ComSpec?.trim() || process.env.COMSPEC?.trim() || "";
@@ -18540,21 +18688,21 @@ function detectShellContext() {
18540
18688
  };
18541
18689
  }
18542
18690
  function claudeProjectsRoot() {
18543
- return join9(homeDir(), ".claude", "projects");
18691
+ return join10(homeDir(), ".claude", "projects");
18544
18692
  }
18545
18693
  function codexSessionsRoot() {
18546
- return join9(homeDir(), ".codex", "sessions");
18694
+ return join10(homeDir(), ".codex", "sessions");
18547
18695
  }
18548
18696
  function listClaudeSessionFiles() {
18549
18697
  const root = claudeProjectsRoot();
18550
- if (!existsSync8(root)) return [];
18698
+ if (!existsSync9(root)) return [];
18551
18699
  const projectDirs = readDirectoryNames(root);
18552
18700
  const files = [];
18553
18701
  for (const projectDir of projectDirs) {
18554
- const fullProjectDir = join9(root, projectDir);
18702
+ const fullProjectDir = join10(root, projectDir);
18555
18703
  for (const fileName of readDirectoryNames(fullProjectDir)) {
18556
18704
  if (fileName.endsWith(".jsonl")) {
18557
- const filePath = join9(fullProjectDir, fileName);
18705
+ const filePath = join10(fullProjectDir, fileName);
18558
18706
  const sessionId = sessionIdFromClaudeFilePath(filePath);
18559
18707
  const stat4 = statIfReadable(filePath);
18560
18708
  if (sessionId && stat4) {
@@ -18572,7 +18720,7 @@ function listClaudeSessionFiles() {
18572
18720
  }
18573
18721
  function listCodexSessionFiles() {
18574
18722
  const root = codexSessionsRoot();
18575
- if (!existsSync8(root)) return [];
18723
+ if (!existsSync9(root)) return [];
18576
18724
  const files = [];
18577
18725
  for (const filePath of listJsonlFilesRecursive(root, 5)) {
18578
18726
  const stat4 = statIfReadable(filePath);
@@ -18611,7 +18759,7 @@ function listJsonlFilesRecursive(root, maxDepth) {
18611
18759
  return;
18612
18760
  }
18613
18761
  for (const entry of entries) {
18614
- const fullPath = join9(dir, entry.name);
18762
+ const fullPath = join10(dir, entry.name);
18615
18763
  if (entry.isDirectory()) {
18616
18764
  visit(fullPath, depth + 1);
18617
18765
  } else if (entry.isFile() && entry.name.endsWith(".jsonl")) {
@@ -18647,7 +18795,7 @@ function sessionIdFromCodexFilePath(filePath) {
18647
18795
  }
18648
18796
  function readCodexSessionId(filePath) {
18649
18797
  try {
18650
- for (const line of normalizedJsonLines(readFileSync7(filePath)).slice(
18798
+ for (const line of normalizedJsonLines(readFileSync8(filePath)).slice(
18651
18799
  0,
18652
18800
  20
18653
18801
  )) {
@@ -18925,11 +19073,11 @@ async function uploadChunkedSessions(sessions, options) {
18925
19073
  async function handleSessionsSend(options) {
18926
19074
  if (options.file) {
18927
19075
  const filePath = resolve12(options.file);
18928
- if (!existsSync8(filePath)) {
19076
+ if (!existsSync9(filePath)) {
18929
19077
  throw new Error(`File not found: ${options.file}`);
18930
19078
  }
18931
19079
  const response2 = await uploadPayload("/api/v2/cli/send-session", {
18932
- file: readFileSync7(filePath).toString("base64"),
19080
+ file: readFileSync8(filePath).toString("base64"),
18933
19081
  filename: basename4(filePath)
18934
19082
  });
18935
19083
  printCommandEnvelope(
@@ -18959,7 +19107,7 @@ async function handleSessionsSend(options) {
18959
19107
  agent: options.agent
18960
19108
  });
18961
19109
  const built = targets.map((target) => {
18962
- const upload = buildSessionUploadContent(readFileSync7(target.filePath));
19110
+ const upload = buildSessionUploadContent(readFileSync8(target.filePath));
18963
19111
  return { ...target, ...upload };
18964
19112
  });
18965
19113
  if (built.some((session) => session.needsChunking)) {
@@ -19026,25 +19174,25 @@ function loadViewerAssets() {
19026
19174
  const cliEntry = process.argv[1]?.trim() ? resolve12(process.argv[1]) : null;
19027
19175
  const candidateRoots2 = [
19028
19176
  ...cliEntry ? [
19029
- join9(dirname9(dirname9(cliEntry)), "viewer"),
19030
- join9(
19031
- dirname9(dirname9(dirname9(cliEntry))),
19177
+ join10(dirname10(dirname10(cliEntry)), "viewer"),
19178
+ join10(
19179
+ dirname10(dirname10(dirname10(cliEntry))),
19032
19180
  "src",
19033
19181
  "lib",
19034
19182
  "cli",
19035
19183
  "viewer"
19036
19184
  )
19037
19185
  ] : [],
19038
- join9(process.cwd(), "src", "lib", "cli", "viewer")
19186
+ join10(process.cwd(), "src", "lib", "cli", "viewer")
19039
19187
  ];
19040
19188
  for (const root of candidateRoots2) {
19041
19189
  try {
19042
- const cssPath = join9(root, "viewer.css");
19043
- const jsPath = join9(root, "viewer.js");
19044
- if (!existsSync8(cssPath) || !existsSync8(jsPath)) continue;
19190
+ const cssPath = join10(root, "viewer.css");
19191
+ const jsPath = join10(root, "viewer.js");
19192
+ if (!existsSync9(cssPath) || !existsSync9(jsPath)) continue;
19045
19193
  return {
19046
- css: readFileSync7(cssPath, "utf8"),
19047
- js: readFileSync7(jsPath, "utf8")
19194
+ css: readFileSync8(cssPath, "utf8"),
19195
+ js: readFileSync8(jsPath, "utf8")
19048
19196
  };
19049
19197
  } catch {
19050
19198
  continue;
@@ -19070,19 +19218,19 @@ async function handleSessionsRender(options) {
19070
19218
  });
19071
19219
  let outputPath = options.output ? resolve12(options.output) : "";
19072
19220
  if (!outputPath) {
19073
- const outputDir = join9(process.cwd(), "deepline", "data");
19074
- mkdirSync4(outputDir, { recursive: true });
19075
- outputPath = join9(
19221
+ const outputDir = join10(process.cwd(), "deepline", "data");
19222
+ mkdirSync5(outputDir, { recursive: true });
19223
+ outputPath = join10(
19076
19224
  outputDir,
19077
19225
  targets.length > 1 ? "session-viewer.html" : `session-${targets[0]?.sessionId}.html`
19078
19226
  );
19079
19227
  } else {
19080
- mkdirSync4(dirname9(outputPath), { recursive: true });
19228
+ mkdirSync5(dirname10(outputPath), { recursive: true });
19081
19229
  }
19082
19230
  const sessions = targets.map((target) => ({
19083
19231
  label: target.label,
19084
19232
  events: parsePreparedEvents(
19085
- prepareSessionBuffer(readFileSync7(target.filePath))
19233
+ prepareSessionBuffer(readFileSync8(target.filePath))
19086
19234
  )
19087
19235
  }));
19088
19236
  const { css, js } = loadViewerAssets();
@@ -19105,7 +19253,7 @@ ${refreshMeta}
19105
19253
  <script>${js}</script>
19106
19254
  </body>
19107
19255
  </html>`;
19108
- writeFileSync8(outputPath, html, "utf8");
19256
+ writeFileSync9(outputPath, html, "utf8");
19109
19257
  printCommandEnvelope(
19110
19258
  {
19111
19259
  ok: true,
@@ -19972,9 +20120,9 @@ Examples:
19972
20120
  }
19973
20121
 
19974
20122
  // src/cli/commands/switch.ts
19975
- import { existsSync as existsSync9, mkdirSync as mkdirSync5, readFileSync as readFileSync8, writeFileSync as writeFileSync9 } from "fs";
19976
- import { homedir as homedir6 } from "os";
19977
- import { dirname as dirname10, join as join10 } from "path";
20123
+ import { existsSync as existsSync10, mkdirSync as mkdirSync6, readFileSync as readFileSync9, writeFileSync as writeFileSync10 } from "fs";
20124
+ import { homedir as homedir7 } from "os";
20125
+ import { dirname as dirname11, join as join11 } from "path";
19978
20126
  function hostSlugFromBaseUrl(baseUrl) {
19979
20127
  try {
19980
20128
  const url = new URL(baseUrl);
@@ -19994,8 +20142,8 @@ function resolveConfigScope() {
19994
20142
  return hostSlugFromBaseUrl(autoDetectBaseUrl());
19995
20143
  }
19996
20144
  function activeFamilyPath() {
19997
- const home = process.env.HOME || process.env.USERPROFILE || homedir6();
19998
- return join10(
20145
+ const home = process.env.HOME || process.env.USERPROFILE || homedir7();
20146
+ return join11(
19999
20147
  home,
20000
20148
  ".local",
20001
20149
  "deepline",
@@ -20007,15 +20155,15 @@ function activeFamilyPath() {
20007
20155
  function readActiveFamily() {
20008
20156
  const path = activeFamilyPath();
20009
20157
  try {
20010
- return readFileSync8(path, "utf-8").trim() || "sdk";
20158
+ return readFileSync9(path, "utf-8").trim() || "sdk";
20011
20159
  } catch {
20012
20160
  return "sdk";
20013
20161
  }
20014
20162
  }
20015
20163
  function writeActiveFamily(family) {
20016
20164
  const path = activeFamilyPath();
20017
- mkdirSync5(dirname10(path), { recursive: true });
20018
- writeFileSync9(path, `${family}
20165
+ mkdirSync6(dirname11(path), { recursive: true });
20166
+ writeFileSync10(path, `${family}
20019
20167
  `, "utf-8");
20020
20168
  return path;
20021
20169
  }
@@ -20029,7 +20177,7 @@ function handleSwitch(action, options) {
20029
20177
  ok: true,
20030
20178
  active_family: activeFamily,
20031
20179
  active_family_path: path,
20032
- active_family_file_exists: existsSync9(path),
20180
+ active_family_file_exists: existsSync10(path),
20033
20181
  render: {
20034
20182
  sections: [
20035
20183
  {
@@ -20131,18 +20279,18 @@ Examples:
20131
20279
  import { Option } from "commander";
20132
20280
  import {
20133
20281
  chmodSync,
20134
- existsSync as existsSync10,
20282
+ existsSync as existsSync11,
20135
20283
  mkdtempSync,
20136
- readFileSync as readFileSync9,
20137
- writeFileSync as writeFileSync11
20284
+ readFileSync as readFileSync10,
20285
+ writeFileSync as writeFileSync12
20138
20286
  } from "fs";
20139
20287
  import { tmpdir as tmpdir4 } from "os";
20140
- import { join as join12, resolve as resolve13 } from "path";
20288
+ import { join as join13, resolve as resolve13 } from "path";
20141
20289
 
20142
20290
  // src/tool-output.ts
20143
- import { mkdirSync as mkdirSync6, writeFileSync as writeFileSync10 } from "fs";
20144
- import { homedir as homedir7 } from "os";
20145
- import { join as join11 } from "path";
20291
+ import { mkdirSync as mkdirSync7, writeFileSync as writeFileSync11 } from "fs";
20292
+ import { homedir as homedir8 } from "os";
20293
+ import { join as join12 } from "path";
20146
20294
  function isPlainObject(value) {
20147
20295
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
20148
20296
  }
@@ -20238,19 +20386,19 @@ function tryConvertToList(payload, options) {
20238
20386
  return null;
20239
20387
  }
20240
20388
  function ensureOutputDir() {
20241
- const outputDir = join11(homedir7(), ".local", "share", "deepline", "data");
20242
- mkdirSync6(outputDir, { recursive: true });
20389
+ const outputDir = join12(homedir8(), ".local", "share", "deepline", "data");
20390
+ mkdirSync7(outputDir, { recursive: true });
20243
20391
  return outputDir;
20244
20392
  }
20245
20393
  function writeJsonOutputFile(payload, stem) {
20246
20394
  const outputDir = ensureOutputDir();
20247
- const outputPath = join11(outputDir, `${stem}_${Date.now()}.json`);
20248
- writeFileSync10(outputPath, JSON.stringify(payload, null, 2), "utf-8");
20395
+ const outputPath = join12(outputDir, `${stem}_${Date.now()}.json`);
20396
+ writeFileSync11(outputPath, JSON.stringify(payload, null, 2), "utf-8");
20249
20397
  return outputPath;
20250
20398
  }
20251
20399
  function writeCsvOutputFile(rows, stem) {
20252
20400
  const outputDir = ensureOutputDir();
20253
- const outputPath = join11(outputDir, `${stem}_${Date.now()}.csv`);
20401
+ const outputPath = join12(outputDir, `${stem}_${Date.now()}.csv`);
20254
20402
  const seen = /* @__PURE__ */ new Set();
20255
20403
  const columns = [];
20256
20404
  for (const row of rows) {
@@ -20273,7 +20421,7 @@ function writeCsvOutputFile(rows, stem) {
20273
20421
  for (const row of rows) {
20274
20422
  lines.push(columns.map((column) => escapeCell(row[column])).join(","));
20275
20423
  }
20276
- writeFileSync10(outputPath, `${lines.join("\n")}
20424
+ writeFileSync11(outputPath, `${lines.join("\n")}
20277
20425
  `, "utf-8");
20278
20426
  const previewRows = rows.slice(0, 5);
20279
20427
  const previewColumns = columns.slice(0, 5);
@@ -21328,10 +21476,10 @@ function normalizeOutputFormat(raw) {
21328
21476
  function resolveAtFilePath(rawPath) {
21329
21477
  const trimmed = rawPath.trim();
21330
21478
  const resolved = resolve13(trimmed);
21331
- if (existsSync10(resolved)) return resolved;
21479
+ if (existsSync11(resolved)) return resolved;
21332
21480
  if (process.platform !== "win32" && trimmed.includes("\\")) {
21333
21481
  const normalized = resolve13(trimmed.replace(/\\/g, "/"));
21334
- if (existsSync10(normalized)) return normalized;
21482
+ if (existsSync11(normalized)) return normalized;
21335
21483
  }
21336
21484
  return resolved;
21337
21485
  }
@@ -21342,7 +21490,7 @@ function readJsonArgument(raw, flagName) {
21342
21490
  throw new Error(`Invalid ${flagName} value: empty @file path.`);
21343
21491
  }
21344
21492
  try {
21345
- return readFileSync9(resolveAtFilePath(filePath), "utf8").replace(
21493
+ return readFileSync10(resolveAtFilePath(filePath), "utf8").replace(
21346
21494
  /^\uFEFF/,
21347
21495
  ""
21348
21496
  );
@@ -21444,9 +21592,9 @@ function starterScriptJson(script) {
21444
21592
  function seedToolListScript(input2) {
21445
21593
  const stem = safeFileStem(input2.toolId);
21446
21594
  const fileName = `${stem}-workflow-seed-${Date.now()}.play.ts`;
21447
- const scriptDir = mkdtempSync(join12(tmpdir4(), "deepline-workflow-seed-"));
21595
+ const scriptDir = mkdtempSync(join13(tmpdir4(), "deepline-workflow-seed-"));
21448
21596
  chmodSync(scriptDir, 448);
21449
- const scriptPath = join12(scriptDir, fileName);
21597
+ const scriptPath = join13(scriptDir, fileName);
21450
21598
  const projectDir = `deepline/projects/${stem}-workflow`;
21451
21599
  const playName = `${stem}-workflow`;
21452
21600
  const sampleRows = input2.rows.length > 0 ? `${JSON.stringify(input2.rows.slice(0, 2)).replace(/\]$/, "")}, ...]` : "[]";
@@ -21482,7 +21630,7 @@ export default definePlay(${JSON.stringify(playName)}, async (ctx) => {
21482
21630
  };
21483
21631
  });
21484
21632
  `;
21485
- writeFileSync11(scriptPath, script, { encoding: "utf-8", mode: 384 });
21633
+ writeFileSync12(scriptPath, script, { encoding: "utf-8", mode: 384 });
21486
21634
  return {
21487
21635
  path: scriptPath,
21488
21636
  sourceCode: script,
@@ -21747,7 +21895,7 @@ async function executeTool(args) {
21747
21895
 
21748
21896
  // src/cli/commands/workflow.ts
21749
21897
  import { mkdir as mkdir5, readFile as readFile4, writeFile as writeFile5 } from "fs/promises";
21750
- import { dirname as dirname11, join as join13, resolve as resolve14 } from "path";
21898
+ import { dirname as dirname12, join as join14, resolve as resolve14 } from "path";
21751
21899
 
21752
21900
  // src/cli/workflow-to-play.ts
21753
21901
  import { createHash as createHash4 } from "crypto";
@@ -21988,8 +22136,8 @@ async function transformOne(api, workflowId, outDir, publish) {
21988
22136
  revision.config,
21989
22137
  { workflowName: workflow.name, version: revision.version }
21990
22138
  );
21991
- const file = join13(resolve14(outDir), `${compiled.playName}.play.ts`);
21992
- await mkdir5(dirname11(file), { recursive: true });
22139
+ const file = join14(resolve14(outDir), `${compiled.playName}.play.ts`);
22140
+ await mkdir5(dirname12(file), { recursive: true });
21993
22141
  await writeFile5(file, compiled.sourceCode, "utf8");
21994
22142
  let published = false;
21995
22143
  if (publish) {
@@ -22236,8 +22384,8 @@ Notes:
22236
22384
 
22237
22385
  // src/cli/commands/update.ts
22238
22386
  import { spawn as spawn2 } from "child_process";
22239
- import { existsSync as existsSync11 } from "fs";
22240
- import { dirname as dirname12, join as join14, resolve as resolve15 } from "path";
22387
+ import { existsSync as existsSync12 } from "fs";
22388
+ import { dirname as dirname13, join as join15, resolve as resolve15 } from "path";
22241
22389
  function posixShellQuote(value) {
22242
22390
  return `'${value.replace(/'/g, `'\\''`)}'`;
22243
22391
  }
@@ -22258,17 +22406,17 @@ function buildSourceUpdateCommand(sourceRoot) {
22258
22406
  function findRepoBackedSdkRoot(startPath) {
22259
22407
  let current = resolve15(startPath);
22260
22408
  while (true) {
22261
- if (existsSync11(join14(current, "sdk", "package.json")) && existsSync11(join14(current, "sdk", "bin", "deepline-dev.ts"))) {
22409
+ if (existsSync12(join15(current, "sdk", "package.json")) && existsSync12(join15(current, "sdk", "bin", "deepline-dev.ts"))) {
22262
22410
  return current;
22263
22411
  }
22264
- const parent = dirname12(current);
22412
+ const parent = dirname13(current);
22265
22413
  if (parent === current) return null;
22266
22414
  current = parent;
22267
22415
  }
22268
22416
  }
22269
22417
  function resolveUpdatePlan() {
22270
22418
  const entrypoint = process.argv[1] ? resolve15(process.argv[1]) : "";
22271
- const sourceRoot = entrypoint ? findRepoBackedSdkRoot(dirname12(entrypoint)) : null;
22419
+ const sourceRoot = entrypoint ? findRepoBackedSdkRoot(dirname13(entrypoint)) : null;
22272
22420
  if (sourceRoot) {
22273
22421
  return {
22274
22422
  kind: "source",
@@ -22621,9 +22769,9 @@ async function maybeAutoUpdateAndRelaunch(response) {
22621
22769
 
22622
22770
  // src/cli/skills-sync.ts
22623
22771
  import { spawn as spawn4, spawnSync as spawnSync2 } from "child_process";
22624
- import { existsSync as existsSync12, mkdirSync as mkdirSync7, readFileSync as readFileSync10, writeFileSync as writeFileSync12 } from "fs";
22625
- import { homedir as homedir8 } from "os";
22626
- import { dirname as dirname13, join as join15 } from "path";
22772
+ import { existsSync as existsSync13, mkdirSync as mkdirSync8, readFileSync as readFileSync11, writeFileSync as writeFileSync13 } from "fs";
22773
+ import { homedir as homedir9 } from "os";
22774
+ import { dirname as dirname14, join as join16 } from "path";
22627
22775
  var CHECK_TIMEOUT_MS2 = 3e3;
22628
22776
  var SDK_PLAY_SKILL_NAME = "deepline-plays";
22629
22777
  var attemptedSync = false;
@@ -22637,20 +22785,20 @@ function activePluginSkillsDir() {
22637
22785
  return "";
22638
22786
  }
22639
22787
  const dir = process.env.DEEPLINE_PLUGIN_SKILLS_DIR?.trim() ?? "";
22640
- return dir && existsSync12(dir) ? dir : "";
22788
+ return dir && existsSync13(dir) ? dir : "";
22641
22789
  }
22642
22790
  function readPluginSkillsVersion() {
22643
22791
  const dir = activePluginSkillsDir();
22644
22792
  if (!dir) return "";
22645
22793
  try {
22646
- return readFileSync10(join15(dir, ".version"), "utf-8").trim();
22794
+ return readFileSync11(join16(dir, ".version"), "utf-8").trim();
22647
22795
  } catch {
22648
22796
  return "";
22649
22797
  }
22650
22798
  }
22651
22799
  function sdkSkillsVersionPath(baseUrl) {
22652
- const home = process.env.HOME?.trim() || homedir8();
22653
- return join15(
22800
+ const home = process.env.HOME?.trim() || homedir9();
22801
+ return join16(
22654
22802
  home,
22655
22803
  ".local",
22656
22804
  "deepline",
@@ -22663,17 +22811,17 @@ function readLocalSkillsVersion(baseUrl) {
22663
22811
  const pluginVersion = readPluginSkillsVersion();
22664
22812
  if (pluginVersion) return pluginVersion;
22665
22813
  const path = sdkSkillsVersionPath(baseUrl);
22666
- if (!existsSync12(path)) return "";
22814
+ if (!existsSync13(path)) return "";
22667
22815
  try {
22668
- return readFileSync10(path, "utf-8").trim();
22816
+ return readFileSync11(path, "utf-8").trim();
22669
22817
  } catch {
22670
22818
  return "";
22671
22819
  }
22672
22820
  }
22673
22821
  function writeLocalSkillsVersion(baseUrl, version) {
22674
22822
  const path = sdkSkillsVersionPath(baseUrl);
22675
- mkdirSync7(dirname13(path), { recursive: true });
22676
- writeFileSync12(path, `${version}
22823
+ mkdirSync8(dirname14(path), { recursive: true });
22824
+ writeFileSync13(path, `${version}
22677
22825
  `, "utf-8");
22678
22826
  }
22679
22827
  function sortedUniqueSkillNames(names) {
@@ -23159,8 +23307,8 @@ function topLevelCommandKnown(program, commandName) {
23159
23307
  );
23160
23308
  }
23161
23309
  async function runPlayRunnerHealthCheck() {
23162
- const dir = await mkdtemp2(join16(tmpdir5(), "deepline-health-play-"));
23163
- const file = join16(dir, "health-check.play.ts");
23310
+ const dir = await mkdtemp2(join17(tmpdir5(), "deepline-health-play-"));
23311
+ const file = join17(dir, "health-check.play.ts");
23164
23312
  try {
23165
23313
  await writeFile6(
23166
23314
  file,