deepline 0.2.19 → 0.2.21

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 CHANGED
@@ -186,7 +186,7 @@ configureProxyFromEnv();
186
186
 
187
187
  // src/cli/index.ts
188
188
  var import_promises8 = require("fs/promises");
189
- var import_node_path25 = require("path");
189
+ var import_node_path26 = require("path");
190
190
  var import_node_os19 = require("os");
191
191
  var import_commander4 = require("commander");
192
192
 
@@ -1044,7 +1044,7 @@ var SDK_RELEASE = {
1044
1044
  // 0.2.0 makes Dataset Handles uniformly async-only after 0.1.320 briefly
1045
1045
  // exposed storage-dependent synchronous access. This deliberate minor
1046
1046
  // release keeps lazy paging semantics independent of row residency.
1047
- version: "0.2.19",
1047
+ version: "0.2.21",
1048
1048
  contracts: {
1049
1049
  api: {
1050
1050
  name: "sdk-http-api",
@@ -1812,7 +1812,7 @@ function decodeSseFrame(frame) {
1812
1812
  return parsed;
1813
1813
  }
1814
1814
  function sleep(ms) {
1815
- return new Promise((resolve18) => setTimeout(resolve18, ms));
1815
+ return new Promise((resolve19) => setTimeout(resolve19, ms));
1816
1816
  }
1817
1817
  function withCoworkNetworkHint(message) {
1818
1818
  if (!isCoworkLikeSandbox2() || message.includes(COWORK_NETWORK_HINT)) {
@@ -3114,14 +3114,14 @@ async function* observeRunEvents(options) {
3114
3114
  try {
3115
3115
  for (; ; ) {
3116
3116
  if (queue.length === 0) {
3117
- const waitForItem = new Promise((resolve18) => {
3118
- wake = resolve18;
3117
+ const waitForItem = new Promise((resolve19) => {
3118
+ wake = resolve19;
3119
3119
  });
3120
3120
  if (!sawFirstSnapshot) {
3121
3121
  const timedOut = await Promise.race([
3122
3122
  waitForItem.then(() => false),
3123
3123
  new Promise(
3124
- (resolve18) => setTimeout(() => resolve18(true), OBSERVE_BOOTSTRAP_TIMEOUT_MS)
3124
+ (resolve19) => setTimeout(() => resolve19(true), OBSERVE_BOOTSTRAP_TIMEOUT_MS)
3125
3125
  )
3126
3126
  ]);
3127
3127
  if (timedOut && queue.length === 0) {
@@ -3431,7 +3431,7 @@ function parseEnvTestPolicyOverrides() {
3431
3431
  return normalizeTestPolicyOverrides(parsed, "DEEPLINE_TEST_POLICY_OVERRIDES");
3432
3432
  }
3433
3433
  function sleep2(ms) {
3434
- return new Promise((resolve18) => setTimeout(resolve18, ms));
3434
+ return new Promise((resolve19) => setTimeout(resolve19, ms));
3435
3435
  }
3436
3436
  function isTransientCompileManifestError(error) {
3437
3437
  if (error instanceof DeeplineError && typeof error.statusCode === "number") {
@@ -6479,6 +6479,10 @@ function collectLocalEnvInfo() {
6479
6479
  function readCsvRows(csvPath) {
6480
6480
  const raw = (0, import_node_fs4.readFileSync)((0, import_node_path4.resolve)(csvPath), "utf-8");
6481
6481
  return (0, import_sync.parse)(raw, {
6482
+ // `csv-parse` otherwise treats a BOM before an opening quote as a field
6483
+ // value, then rejects the quote as invalid. A UTF-8 BOM is a valid file
6484
+ // prefix and must not become part of the first column name either.
6485
+ bom: true,
6482
6486
  columns: true,
6483
6487
  skip_empty_lines: true
6484
6488
  });
@@ -6961,7 +6965,7 @@ function buildCandidateUrls2(url) {
6961
6965
  }
6962
6966
  }
6963
6967
  function sleep4(ms) {
6964
- return new Promise((resolve18) => setTimeout(resolve18, ms));
6968
+ return new Promise((resolve19) => setTimeout(resolve19, ms));
6965
6969
  }
6966
6970
  function printDeeplineLogo() {
6967
6971
  if (process.stdout.isTTY && (process.stdout.columns ?? 80) >= 70) {
@@ -15923,27 +15927,6 @@ var SECRET_ENV_PATTERN = /\bprocess(?:\.env|\[['"]env['"]\])(?:\.|\[['"])([A-Z0-
15923
15927
  var PRIVATE_KEY_PATTERN = /-----BEGIN (?:RSA |EC |OPENSSH |PGP )?PRIVATE KEY-----/;
15924
15928
  var BEARER_LITERAL_PATTERN = /\bBearer\s+[A-Za-z0-9._~+/=-]{16,}/i;
15925
15929
  var ASSIGNMENT_SECRET_LITERAL_PATTERN = /\b(?:api[_-]?key|token|secret|password)\b\s*[:=]\s*['"][^'"]{12,}['"]/i;
15926
- var HIGH_ENTROPY_LITERAL_PATTERN = /['"]([A-Za-z0-9+/=_-]{32,})['"]/g;
15927
- var UUID_IDENTIFIER_PATTERN = /^((?:[A-Za-z0-9]+[-_])*)?([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/i;
15928
- var BOOTSTRAP_RESOURCE_IDENTIFIER_PATTERN = /^bootstrap-[0-9a-f]{32}(?:\/[a-z0-9][a-z0-9_-]{0,127})?$/i;
15929
- var SECRET_LABEL_PATTERN = /(?:^|[-_])(?:api|auth|access|secret|token|key|password|credential|bearer|sk|pk|live)(?:[-_]|$)/i;
15930
- function shannonEntropy(value) {
15931
- const counts = /* @__PURE__ */ new Map();
15932
- for (const char of value) counts.set(char, (counts.get(char) ?? 0) + 1);
15933
- return [...counts.values()].reduce((entropy, count) => {
15934
- const p = count / value.length;
15935
- return entropy - p * Math.log2(p);
15936
- }, 0);
15937
- }
15938
- function isNonSecretUuidIdentifier(value) {
15939
- const match = UUID_IDENTIFIER_PATTERN.exec(value);
15940
- if (!match) return false;
15941
- const label = match[1] ?? "";
15942
- return !SECRET_LABEL_PATTERN.test(label);
15943
- }
15944
- function isNonSecretBootstrapResourceIdentifier(value) {
15945
- return BOOTSTRAP_RESOURCE_IDENTIFIER_PATTERN.test(value);
15946
- }
15947
15930
  function collectInlineSecretFindings(sourceCode) {
15948
15931
  const findings = [];
15949
15932
  for (const match of sourceCode.matchAll(SECRET_ENV_PATTERN)) {
@@ -15955,15 +15938,6 @@ function collectInlineSecretFindings(sourceCode) {
15955
15938
  if (ASSIGNMENT_SECRET_LITERAL_PATTERN.test(sourceCode)) {
15956
15939
  findings.push("secret-looking assignment literal");
15957
15940
  }
15958
- for (const match of sourceCode.matchAll(HIGH_ENTROPY_LITERAL_PATTERN)) {
15959
- const literal = match[1] ?? "";
15960
- if (isNonSecretUuidIdentifier(literal)) continue;
15961
- if (isNonSecretBootstrapResourceIdentifier(literal)) continue;
15962
- if (literal.length >= 40 && shannonEntropy(literal) >= 4.2) {
15963
- findings.push("high-entropy string literal");
15964
- break;
15965
- }
15966
- }
15967
15941
  return [...new Set(findings)];
15968
15942
  }
15969
15943
 
@@ -17084,7 +17058,7 @@ function traceCliSync(phase, fields, run) {
17084
17058
  }
17085
17059
  }
17086
17060
  function sleep5(ms) {
17087
- return new Promise((resolve18) => setTimeout(resolve18, ms));
17061
+ return new Promise((resolve19) => setTimeout(resolve19, ms));
17088
17062
  }
17089
17063
  function parseReferencedPlayTarget2(target) {
17090
17064
  const trimmed = target.trim();
@@ -25547,7 +25521,7 @@ function emitEnrichDebug(message) {
25547
25521
  );
25548
25522
  }
25549
25523
  function sleep6(ms) {
25550
- return new Promise((resolve18) => setTimeout(resolve18, ms));
25524
+ return new Promise((resolve19) => setTimeout(resolve19, ms));
25551
25525
  }
25552
25526
  function enrichExportBackingRowsWaitMs() {
25553
25527
  const raw = process.env.DEEPLINE_ENRICH_EXPORT_BACKING_ROWS_WAIT_MS?.trim();
@@ -31712,7 +31686,7 @@ async function readHiddenLine(prompt, streams = {}) {
31712
31686
  }
31713
31687
  let value = "";
31714
31688
  inputStream.resume();
31715
- return await new Promise((resolve18, reject) => {
31689
+ return await new Promise((resolve19, reject) => {
31716
31690
  let settled = false;
31717
31691
  const cleanup = () => {
31718
31692
  inputStream.off("data", onData);
@@ -31730,7 +31704,7 @@ async function readHiddenLine(prompt, streams = {}) {
31730
31704
  settled = true;
31731
31705
  outputStream.write("\n");
31732
31706
  cleanup();
31733
- resolve18(line);
31707
+ resolve19(line);
31734
31708
  };
31735
31709
  const fail = (error) => {
31736
31710
  if (settled) return;
@@ -35178,9 +35152,9 @@ Notes:
35178
35152
 
35179
35153
  // src/cli/commands/update.ts
35180
35154
  var import_node_child_process3 = require("child_process");
35181
- var import_node_fs19 = require("fs");
35155
+ var import_node_fs20 = require("fs");
35182
35156
  var import_node_os16 = require("os");
35183
- var import_node_path22 = require("path");
35157
+ var import_node_path23 = require("path");
35184
35158
 
35185
35159
  // src/cli/commands/skills.ts
35186
35160
  var import_node_child_process2 = require("child_process");
@@ -35484,7 +35458,7 @@ function readSkillsInstallState(path) {
35484
35458
  }
35485
35459
  }
35486
35460
  function runProcess(command, args, cwd) {
35487
- return new Promise((resolve18, reject) => {
35461
+ return new Promise((resolve19, reject) => {
35488
35462
  const plan = resolveShellSpawn(command, args);
35489
35463
  const child = (0, import_node_child_process2.spawn)(plan.command, plan.args, {
35490
35464
  cwd,
@@ -35503,7 +35477,7 @@ function runProcess(command, args, cwd) {
35503
35477
  process.stderr.write(`skills@latest exited ${code}.
35504
35478
  `);
35505
35479
  }
35506
- resolve18(code ?? 1);
35480
+ resolve19(code ?? 1);
35507
35481
  });
35508
35482
  });
35509
35483
  }
@@ -35697,6 +35671,166 @@ Examples:
35697
35671
  });
35698
35672
  }
35699
35673
 
35674
+ // src/cli/install-integrity.ts
35675
+ var import_node_module2 = require("module");
35676
+ var import_node_fs19 = require("fs");
35677
+ var import_node_path22 = require("path");
35678
+ var SDK_SIDECAR_CRITICAL_PACKAGE_FILES = [
35679
+ "dist/cli/index.mjs",
35680
+ "dist/index.mjs",
35681
+ "dist/index.d.ts",
35682
+ "dist/plays/bundle-play-file.mjs",
35683
+ "dist/bundling-sources/shared_libs/observability/telemetry.ts",
35684
+ "dist/bundling-sources/shared_libs/play-runtime/backend.ts",
35685
+ "dist/bundling-sources/shared_libs/plays/bundling/index.ts",
35686
+ "dist/bundling-sources/shared_libs/tool-execution-error.ts"
35687
+ ];
35688
+ var SDK_SIDECAR_CRITICAL_DEPENDENCY_FILES = [
35689
+ "esbuild/package.json",
35690
+ "esbuild/lib/main.js"
35691
+ ];
35692
+ function safeRelativePath(value) {
35693
+ if (typeof value !== "string" || !value || (0, import_node_path22.isAbsolute)(value)) return false;
35694
+ const segments = value.split(/[\\/]+/);
35695
+ return segments.every(
35696
+ (segment) => Boolean(segment) && segment !== "." && segment !== ".."
35697
+ );
35698
+ }
35699
+ function resolveContainedPath(root, value) {
35700
+ if (!safeRelativePath(value)) return null;
35701
+ const target = (0, import_node_path22.resolve)(root, value);
35702
+ const relativeTarget = (0, import_node_path22.relative)((0, import_node_path22.resolve)(root), target);
35703
+ if (!relativeTarget || relativeTarget.startsWith("..") || (0, import_node_path22.isAbsolute)(relativeTarget)) {
35704
+ return null;
35705
+ }
35706
+ return target;
35707
+ }
35708
+ function parseJson(path) {
35709
+ return JSON.parse((0, import_node_fs19.readFileSync)(path, "utf8"));
35710
+ }
35711
+ function isFile(path) {
35712
+ try {
35713
+ return (0, import_node_fs19.statSync)(path).isFile();
35714
+ } catch {
35715
+ return false;
35716
+ }
35717
+ }
35718
+ function readManifest(packageRoot) {
35719
+ const packageJsonPath = (0, import_node_path22.join)(packageRoot, "package.json");
35720
+ let packageJson;
35721
+ try {
35722
+ packageJson = parseJson(packageJsonPath);
35723
+ } catch (error) {
35724
+ return {
35725
+ mode: "manifest",
35726
+ invalidReason: `invalid Deepline package metadata: ${error.message}`,
35727
+ missing: (0, import_node_fs19.existsSync)(packageJsonPath) ? [] : ["deepline/package.json"]
35728
+ };
35729
+ }
35730
+ if (!packageJson || typeof packageJson !== "object" || Array.isArray(packageJson)) {
35731
+ return {
35732
+ mode: "manifest",
35733
+ invalidReason: "invalid Deepline package metadata: expected an object"
35734
+ };
35735
+ }
35736
+ const metadata = packageJson;
35737
+ if (metadata.deepline !== void 0 && (!metadata.deepline || typeof metadata.deepline !== "object" || Array.isArray(metadata.deepline))) {
35738
+ return {
35739
+ mode: "manifest",
35740
+ invalidReason: "invalid Deepline package metadata: deepline must be an object"
35741
+ };
35742
+ }
35743
+ const declaration = metadata.deepline?.installIntegrity;
35744
+ if (!declaration) {
35745
+ return {
35746
+ mode: "legacy",
35747
+ manifest: {
35748
+ schemaVersion: 1,
35749
+ packageFiles: [...SDK_SIDECAR_CRITICAL_PACKAGE_FILES],
35750
+ dependencyFiles: [...SDK_SIDECAR_CRITICAL_DEPENDENCY_FILES]
35751
+ }
35752
+ };
35753
+ }
35754
+ if (declaration.schemaVersion !== 1 || !safeRelativePath(declaration.manifest)) {
35755
+ return {
35756
+ mode: "manifest",
35757
+ invalidReason: "invalid Deepline install-integrity declaration"
35758
+ };
35759
+ }
35760
+ const manifestPath = resolveContainedPath(packageRoot, declaration.manifest);
35761
+ if (!manifestPath || !isFile(manifestPath)) {
35762
+ return {
35763
+ mode: "manifest",
35764
+ invalidReason: "declared Deepline install-integrity manifest is missing",
35765
+ missing: [String(declaration.manifest)]
35766
+ };
35767
+ }
35768
+ let raw;
35769
+ try {
35770
+ raw = parseJson(manifestPath);
35771
+ } catch (error) {
35772
+ return {
35773
+ mode: "manifest",
35774
+ invalidReason: `invalid Deepline install-integrity manifest: ${error.message}`
35775
+ };
35776
+ }
35777
+ if (!raw || typeof raw !== "object" || raw.schemaVersion !== 1 || !Array.isArray(raw.packageFiles) || !Array.isArray(raw.dependencyFiles)) {
35778
+ return {
35779
+ mode: "manifest",
35780
+ invalidReason: "invalid Deepline install-integrity manifest schema"
35781
+ };
35782
+ }
35783
+ const manifest = raw;
35784
+ if (manifest.packageFiles.length === 0 || manifest.dependencyFiles.length === 0 || !manifest.packageFiles.every(safeRelativePath) || !manifest.dependencyFiles.every(safeRelativePath)) {
35785
+ return {
35786
+ mode: "manifest",
35787
+ invalidReason: "unsafe path in Deepline install-integrity manifest"
35788
+ };
35789
+ }
35790
+ return { mode: "manifest", manifest };
35791
+ }
35792
+ function inspectSdkSidecarInstall(versionDir) {
35793
+ const nodeModulesRoot = (0, import_node_path22.join)(versionDir, "node_modules");
35794
+ const packageRoot = (0, import_node_path22.join)(nodeModulesRoot, "deepline");
35795
+ const manifestResult = readManifest(packageRoot);
35796
+ if ("invalidReason" in manifestResult) {
35797
+ return {
35798
+ ok: false,
35799
+ missing: manifestResult.missing ?? [],
35800
+ invalidReason: manifestResult.invalidReason,
35801
+ mode: manifestResult.mode
35802
+ };
35803
+ }
35804
+ const missing = [
35805
+ ...manifestResult.manifest.packageFiles.filter((path) => !isFile((0, import_node_path22.join)(packageRoot, path))).map((path) => `deepline/${path}`),
35806
+ ...manifestResult.manifest.dependencyFiles.filter((path) => !isFile((0, import_node_path22.join)(nodeModulesRoot, path))).map((path) => `node_modules/${path}`)
35807
+ ];
35808
+ return {
35809
+ ok: missing.length === 0,
35810
+ missing,
35811
+ invalidReason: null,
35812
+ mode: manifestResult.mode
35813
+ };
35814
+ }
35815
+ function probeSdkSidecarEsbuild(versionDir) {
35816
+ try {
35817
+ const requireFromInstall = (0, import_node_module2.createRequire)((0, import_node_path22.join)(versionDir, "package.json"));
35818
+ const esbuild = requireFromInstall("esbuild");
35819
+ if (typeof esbuild.transformSync !== "function") {
35820
+ return "esbuild does not export transformSync";
35821
+ }
35822
+ const result = esbuild.transformSync("const value: number = 1;", {
35823
+ loader: "ts"
35824
+ });
35825
+ if (typeof result?.code !== "string") {
35826
+ return "esbuild transform probe returned no code";
35827
+ }
35828
+ return null;
35829
+ } catch (error) {
35830
+ return error instanceof Error ? error.message : String(error);
35831
+ }
35832
+ }
35833
+
35700
35834
  // src/cli/commands/update.ts
35701
35835
  var NPM_SDK_INSTALL_COMMON_FLAGS = [
35702
35836
  "--no-audit",
@@ -35752,7 +35886,7 @@ function sidecarStateDir(input2) {
35752
35886
  if (!scope || scope.includes("/") || scope.includes("\\")) {
35753
35887
  return null;
35754
35888
  }
35755
- return (0, import_node_path22.join)(input2.homeDir, ".local", "deepline", scope, "sdk-cli");
35889
+ return (0, import_node_path23.join)(input2.homeDir, ".local", "deepline", scope, "sdk-cli");
35756
35890
  }
35757
35891
  function sidecarRegistryUrl(hostUrl) {
35758
35892
  let url;
@@ -35779,7 +35913,7 @@ function publicNpmFallbackRegistryUrl(hostUrl) {
35779
35913
  }
35780
35914
  function readOptionalText(path) {
35781
35915
  try {
35782
- return (0, import_node_fs19.readFileSync)(path, "utf8").trim();
35916
+ return (0, import_node_fs20.readFileSync)(path, "utf8").trim();
35783
35917
  } catch {
35784
35918
  return "";
35785
35919
  }
@@ -35787,19 +35921,19 @@ function readOptionalText(path) {
35787
35921
  function resolvePythonSidecarUpdatePlan(options) {
35788
35922
  const stateDir = sidecarStateDir(options);
35789
35923
  if (!stateDir) return null;
35790
- const relativeEntrypoint = (0, import_node_path22.relative)(
35791
- (0, import_node_path22.resolve)(stateDir),
35792
- (0, import_node_path22.resolve)(options.entrypoint)
35924
+ const relativeEntrypoint = (0, import_node_path23.relative)(
35925
+ (0, import_node_path23.resolve)(stateDir),
35926
+ (0, import_node_path23.resolve)(options.entrypoint)
35793
35927
  );
35794
- if (!relativeEntrypoint || relativeEntrypoint.startsWith("..") || (0, import_node_path22.isAbsolute)(relativeEntrypoint)) {
35928
+ if (!relativeEntrypoint || relativeEntrypoint.startsWith("..") || (0, import_node_path23.isAbsolute)(relativeEntrypoint)) {
35795
35929
  return null;
35796
35930
  }
35797
- const installMethod = readOptionalText((0, import_node_path22.join)(stateDir, ".install-method"));
35931
+ const installMethod = readOptionalText((0, import_node_path23.join)(stateDir, ".install-method"));
35798
35932
  if (installMethod !== "python-sidecar") return null;
35799
35933
  const scope = options.env.DEEPLINE_CONFIG_SCOPE?.trim() || "";
35800
35934
  const hostUrl = options.env.DEEPLINE_HOST_URL?.trim() || "";
35801
- const nodeBin = readOptionalText((0, import_node_path22.join)(stateDir, ".node-bin")) || process.execPath;
35802
- const sidecarPath = readOptionalText((0, import_node_path22.join)(stateDir, ".command-path")) || (0, import_node_path22.join)(
35935
+ const nodeBin = readOptionalText((0, import_node_path23.join)(stateDir, ".node-bin")) || process.execPath;
35936
+ const sidecarPath = readOptionalText((0, import_node_path23.join)(stateDir, ".command-path")) || (0, import_node_path23.join)(
35803
35937
  stateDir,
35804
35938
  "bin",
35805
35939
  process.platform === "win32" ? "deepline-sdk.cmd" : "deepline-sdk"
@@ -35807,7 +35941,7 @@ function resolvePythonSidecarUpdatePlan(options) {
35807
35941
  const packageSpec = options.packageSpec || "deepline@latest";
35808
35942
  const npmCommand = "npm";
35809
35943
  const registryUrl = sidecarRegistryUrl(hostUrl);
35810
- const versionDir = (0, import_node_path22.join)(stateDir, "versions", "<version>");
35944
+ const versionDir = (0, import_node_path23.join)(stateDir, "versions", "<version>");
35811
35945
  const manualCommand = `${buildSidecarProjectConfigCommand(versionDir, nodeBin)} && ${npmCommand} install --prefix ${shellQuote4(versionDir)} --registry ${shellQuote4(registryUrl)} ${NPM_SDK_INSTALL_COMMON_FLAGS.map(shellQuote4).join(" ")} ${shellQuote4(packageSpec)}`;
35812
35946
  return {
35813
35947
  kind: "python-sidecar",
@@ -35823,12 +35957,12 @@ function resolvePythonSidecarUpdatePlan(options) {
35823
35957
  };
35824
35958
  }
35825
35959
  function findRepoBackedSdkRoot(startPath) {
35826
- let current = (0, import_node_path22.resolve)(startPath);
35960
+ let current = (0, import_node_path23.resolve)(startPath);
35827
35961
  while (true) {
35828
- if ((0, import_node_fs19.existsSync)((0, import_node_path22.join)(current, "sdk", "package.json")) && (0, import_node_fs19.existsSync)((0, import_node_path22.join)(current, "sdk", "bin", "deepline-dev.ts"))) {
35962
+ if ((0, import_node_fs20.existsSync)((0, import_node_path23.join)(current, "sdk", "package.json")) && (0, import_node_fs20.existsSync)((0, import_node_path23.join)(current, "sdk", "bin", "deepline-dev.ts"))) {
35829
35963
  return current;
35830
35964
  }
35831
- const parent = (0, import_node_path22.dirname)(current);
35965
+ const parent = (0, import_node_path23.dirname)(current);
35832
35966
  if (parent === current) return null;
35833
35967
  current = parent;
35834
35968
  }
@@ -35836,9 +35970,9 @@ function findRepoBackedSdkRoot(startPath) {
35836
35970
  function inferNpmGlobalPrefixFromEntrypoint(entrypoint) {
35837
35971
  const normalized = (() => {
35838
35972
  try {
35839
- return (0, import_node_fs19.realpathSync)(entrypoint);
35973
+ return (0, import_node_fs20.realpathSync)(entrypoint);
35840
35974
  } catch {
35841
- return (0, import_node_path22.resolve)(entrypoint);
35975
+ return (0, import_node_path23.resolve)(entrypoint);
35842
35976
  }
35843
35977
  })();
35844
35978
  const parts = normalized.split(/[\\/]+/);
@@ -35857,9 +35991,9 @@ function inferNpmGlobalPrefixFromEntrypoint(entrypoint) {
35857
35991
  function isHomebrewFormulaEntrypoint(entrypoint) {
35858
35992
  const normalized = (() => {
35859
35993
  try {
35860
- return (0, import_node_fs19.realpathSync)(entrypoint);
35994
+ return (0, import_node_fs20.realpathSync)(entrypoint);
35861
35995
  } catch {
35862
- return (0, import_node_path22.resolve)(entrypoint);
35996
+ return (0, import_node_path23.resolve)(entrypoint);
35863
35997
  }
35864
35998
  })();
35865
35999
  const parts = normalized.split(/[\\/]+/);
@@ -35869,8 +36003,8 @@ function isHomebrewFormulaEntrypoint(entrypoint) {
35869
36003
  function resolveUpdatePlan(options = {}) {
35870
36004
  const env = options.env ?? process.env;
35871
36005
  const homeDir2 = options.homeDir ?? (0, import_node_os16.homedir)();
35872
- const entrypoint = options.entrypoint ?? (process.argv[1] ? (0, import_node_path22.resolve)(process.argv[1]) : "");
35873
- const sourceRoot = entrypoint ? findRepoBackedSdkRoot((0, import_node_path22.dirname)(entrypoint)) : null;
36006
+ const entrypoint = options.entrypoint ?? (process.argv[1] ? (0, import_node_path23.resolve)(process.argv[1]) : "");
36007
+ const sourceRoot = entrypoint ? findRepoBackedSdkRoot((0, import_node_path23.dirname)(entrypoint)) : null;
35874
36008
  if (sourceRoot) {
35875
36009
  return {
35876
36010
  kind: "source",
@@ -35917,9 +36051,9 @@ var AUTO_UPDATE_FAILURE_FILE = ".auto-update-failure.json";
35917
36051
  function autoUpdateFailurePath(plan) {
35918
36052
  if (plan.kind === "source" || plan.kind === "homebrew") return null;
35919
36053
  if (plan.kind === "python-sidecar") {
35920
- return (0, import_node_path22.join)(plan.stateDir, AUTO_UPDATE_FAILURE_FILE);
36054
+ return (0, import_node_path23.join)(plan.stateDir, AUTO_UPDATE_FAILURE_FILE);
35921
36055
  }
35922
- return (0, import_node_path22.join)(
36056
+ return (0, import_node_path23.join)(
35923
36057
  (0, import_node_os16.homedir)(),
35924
36058
  ".local",
35925
36059
  "deepline",
@@ -35937,7 +36071,7 @@ function readAutoUpdateFailure(plan) {
35937
36071
  if (!path) return null;
35938
36072
  try {
35939
36073
  const parsed = JSON.parse(
35940
- (0, import_node_fs19.readFileSync)(path, "utf8")
36074
+ (0, import_node_fs20.readFileSync)(path, "utf8")
35941
36075
  );
35942
36076
  if ((parsed.kind === "npm-global" || parsed.kind === "python-sidecar") && typeof parsed.packageSpec === "string" && typeof parsed.failedAt === "string" && typeof parsed.exitCode === "number" && typeof parsed.manualCommand === "string") {
35943
36077
  return parsed;
@@ -35958,8 +36092,8 @@ function writeAutoUpdateFailure(plan, exitCode) {
35958
36092
  manualCommand: plan.manualCommand
35959
36093
  };
35960
36094
  try {
35961
- (0, import_node_fs19.mkdirSync)((0, import_node_path22.dirname)(path), { recursive: true });
35962
- (0, import_node_fs19.writeFileSync)(path, `${JSON.stringify(marker, null, 2)}
36095
+ (0, import_node_fs20.mkdirSync)((0, import_node_path23.dirname)(path), { recursive: true });
36096
+ (0, import_node_fs20.writeFileSync)(path, `${JSON.stringify(marker, null, 2)}
35963
36097
  `, "utf8");
35964
36098
  } catch {
35965
36099
  }
@@ -35968,7 +36102,7 @@ function clearAutoUpdateFailure(plan) {
35968
36102
  const path = autoUpdateFailurePath(plan);
35969
36103
  if (!path) return;
35970
36104
  try {
35971
- (0, import_node_fs19.unlinkSync)(path);
36105
+ (0, import_node_fs20.unlinkSync)(path);
35972
36106
  } catch {
35973
36107
  }
35974
36108
  }
@@ -36006,7 +36140,7 @@ function safeVersionSegment(value) {
36006
36140
  return /^[0-9A-Za-z._-]+$/.test(normalized) ? normalized : "";
36007
36141
  }
36008
36142
  function entryPathInVersionDir(versionDir) {
36009
- return (0, import_node_path22.join)(
36143
+ return (0, import_node_path23.join)(
36010
36144
  versionDir,
36011
36145
  "node_modules",
36012
36146
  "deepline",
@@ -36016,19 +36150,36 @@ function entryPathInVersionDir(versionDir) {
36016
36150
  );
36017
36151
  }
36018
36152
  function installedPackageVersion(versionDir) {
36019
- const packageJsonPath = (0, import_node_path22.join)(
36153
+ const packageJsonPath = (0, import_node_path23.join)(
36020
36154
  versionDir,
36021
36155
  "node_modules",
36022
36156
  "deepline",
36023
36157
  "package.json"
36024
36158
  );
36025
36159
  try {
36026
- const parsed = JSON.parse((0, import_node_fs19.readFileSync)(packageJsonPath, "utf8"));
36160
+ const parsed = JSON.parse((0, import_node_fs20.readFileSync)(packageJsonPath, "utf8"));
36027
36161
  return typeof parsed.version === "string" ? safeVersionSegment(parsed.version) : "";
36028
36162
  } catch {
36029
36163
  return "";
36030
36164
  }
36031
36165
  }
36166
+ function sidecarStructureFailure(versionDir) {
36167
+ const health = inspectSdkSidecarInstall(versionDir);
36168
+ if (!health.ok) {
36169
+ const details = [
36170
+ ...health.invalidReason ? [health.invalidReason] : [],
36171
+ ...health.missing.length > 0 ? [`missing ${health.missing.join(", ")}`] : []
36172
+ ].join("; ");
36173
+ return details || "required SDK CLI files are missing";
36174
+ }
36175
+ return null;
36176
+ }
36177
+ function sidecarInstallFailure(versionDir) {
36178
+ const structureFailure = sidecarStructureFailure(versionDir);
36179
+ if (structureFailure) return structureFailure;
36180
+ const esbuildFailure = probeSdkSidecarEsbuild(versionDir);
36181
+ return esbuildFailure ? `esbuild probe failed: ${esbuildFailure}` : null;
36182
+ }
36032
36183
  function runCommand(command, args, env = process.env) {
36033
36184
  return new Promise((resolveResult) => {
36034
36185
  let output2 = "";
@@ -36100,26 +36251,62 @@ async function runNpmInstallWithRegistryFallback(input2) {
36100
36251
  return fallback.exitCode;
36101
36252
  }
36102
36253
  function writeSidecarLauncher(input2) {
36103
- (0, import_node_fs19.mkdirSync)((0, import_node_path22.dirname)(input2.path), { recursive: true });
36254
+ (0, import_node_fs20.mkdirSync)((0, import_node_path23.dirname)(input2.path), { recursive: true });
36255
+ const packageRoot = (0, import_node_path23.dirname)((0, import_node_path23.dirname)((0, import_node_path23.dirname)(input2.entryPath)));
36256
+ const versionDir = (0, import_node_path23.dirname)((0, import_node_path23.dirname)(packageRoot));
36257
+ const esbuildProbe = "const {createRequire}=require('node:module');const path=require('node:path');const req=createRequire(path.join(process.argv[1],'package.json'));const result=req('esbuild').transformSync('const value: number = 1;',{loader:'ts'});if(!result||typeof result.code!=='string')process.exit(3);";
36258
+ const criticalPaths = [
36259
+ ...SDK_SIDECAR_CRITICAL_PACKAGE_FILES.map(
36260
+ (path) => (0, import_node_path23.join)(packageRoot, path)
36261
+ ),
36262
+ ...SDK_SIDECAR_CRITICAL_DEPENDENCY_FILES.map(
36263
+ (path) => (0, import_node_path23.join)(versionDir, "node_modules", path)
36264
+ )
36265
+ ];
36104
36266
  if (process.platform === "win32") {
36105
- (0, import_node_fs19.writeFileSync)(
36267
+ (0, import_node_fs20.writeFileSync)(
36106
36268
  input2.path,
36107
36269
  [
36108
36270
  `@set DEEPLINE_HOST_URL=${input2.hostUrl.replace(/\r?\n/g, "")}`,
36109
36271
  `@set DEEPLINE_CONFIG_SCOPE=${input2.scope.replace(/\r?\n/g, "")}`,
36272
+ ...criticalPaths.map(
36273
+ (path) => `@if not exist "${path}" goto repair_sdk`
36274
+ ),
36275
+ `@"${input2.nodeBin}" -e "${esbuildProbe}" "${versionDir}" >NUL 2>&1`,
36276
+ "@if errorlevel 1 goto repair_sdk",
36110
36277
  `@"${input2.nodeBin}" "${input2.entryPath}" %*`,
36278
+ "@exit /b %ERRORLEVEL%",
36279
+ ":repair_sdk",
36280
+ '@if defined DEEPLINE_REAL_BINARY "%DEEPLINE_REAL_BINARY%" --version=v2 %*',
36281
+ "@if defined DEEPLINE_REAL_BINARY exit /b %ERRORLEVEL%",
36282
+ "@echo Deepline SDK CLI install is incomplete. Run `deepline update` to repair it. 1>&2",
36283
+ "@exit /b 1",
36111
36284
  ""
36112
36285
  ].join("\r\n"),
36113
36286
  "utf8"
36114
36287
  );
36115
36288
  return;
36116
36289
  }
36117
- (0, import_node_fs19.writeFileSync)(
36290
+ (0, import_node_fs20.writeFileSync)(
36118
36291
  input2.path,
36119
36292
  [
36120
36293
  "#!/usr/bin/env sh",
36121
36294
  `export DEEPLINE_HOST_URL=${shellQuote4(input2.hostUrl)}`,
36122
36295
  `export DEEPLINE_CONFIG_SCOPE=${shellQuote4(input2.scope)}`,
36296
+ `if ${criticalPaths.map((path) => `[ ! -f ${shellQuote4(path)} ]`).join(" || ")}; then`,
36297
+ ' if [ -n "${DEEPLINE_REAL_BINARY:-}" ] && [ -x "$DEEPLINE_REAL_BINARY" ]; then',
36298
+ ' exec "$DEEPLINE_REAL_BINARY" --version=v2 "$@"',
36299
+ " fi",
36300
+ ' printf "%s\\n" "Deepline SDK CLI install is incomplete. Run \\`deepline update\\` to repair it." >&2',
36301
+ " exit 1",
36302
+ "fi",
36303
+ `if ! ${shellQuote4(input2.nodeBin)} -e ${shellQuote4(esbuildProbe)} ${shellQuote4(versionDir)} >/dev/null 2>&1; then`,
36304
+ ' if [ -n "${DEEPLINE_REAL_BINARY:-}" ] && [ -x "$DEEPLINE_REAL_BINARY" ]; then',
36305
+ ' exec "$DEEPLINE_REAL_BINARY" --version=v2 "$@"',
36306
+ " fi",
36307
+ ' printf "%s\\n" "Deepline SDK CLI install is incomplete. Run \\`deepline update\\` to repair it." >&2',
36308
+ " exit 1",
36309
+ "fi",
36123
36310
  `exec ${shellQuote4(input2.nodeBin)} ${shellQuote4(input2.entryPath)} "$@"`,
36124
36311
  ""
36125
36312
  ].join("\n"),
@@ -36127,17 +36314,17 @@ function writeSidecarLauncher(input2) {
36127
36314
  );
36128
36315
  }
36129
36316
  async function runPythonSidecarUpdatePlan(plan) {
36130
- const versionsDir = (0, import_node_path22.join)(plan.stateDir, "versions");
36131
- const tempDir = (0, import_node_path22.join)(
36317
+ const versionsDir = (0, import_node_path23.join)(plan.stateDir, "versions");
36318
+ const tempDir = (0, import_node_path23.join)(
36132
36319
  versionsDir,
36133
36320
  `.tmp-sdk-update-${process.pid}-${Date.now()}`
36134
36321
  );
36135
- (0, import_node_fs19.rmSync)(tempDir, { recursive: true, force: true });
36136
- (0, import_node_fs19.mkdirSync)(tempDir, { recursive: true });
36137
- (0, import_node_fs19.writeFileSync)((0, import_node_path22.join)(tempDir, "package.json"), NPM_SDK_SIDECAR_PACKAGE_JSON);
36322
+ (0, import_node_fs20.rmSync)(tempDir, { recursive: true, force: true });
36323
+ (0, import_node_fs20.mkdirSync)(tempDir, { recursive: true });
36324
+ (0, import_node_fs20.writeFileSync)((0, import_node_path23.join)(tempDir, "package.json"), NPM_SDK_SIDECAR_PACKAGE_JSON);
36138
36325
  const env = {
36139
36326
  ...process.env,
36140
- PATH: `${(0, import_node_path22.dirname)(plan.nodeBin)}${process.platform === "win32" ? ";" : ":"}${process.env.PATH ?? ""}`
36327
+ PATH: `${(0, import_node_path23.dirname)(plan.nodeBin)}${process.platform === "win32" ? ";" : ":"}${process.env.PATH ?? ""}`
36141
36328
  };
36142
36329
  const installResult = await runCommand(
36143
36330
  plan.npmCommand,
@@ -36154,7 +36341,7 @@ async function runPythonSidecarUpdatePlan(plan) {
36154
36341
  );
36155
36342
  const installExitCode = installResult.exitCode;
36156
36343
  if (installExitCode !== 0) {
36157
- (0, import_node_fs19.rmSync)(tempDir, { recursive: true, force: true });
36344
+ (0, import_node_fs20.rmSync)(tempDir, { recursive: true, force: true });
36158
36345
  return installExitCode;
36159
36346
  }
36160
36347
  const installedVersion = installedPackageVersion(tempDir);
@@ -36162,33 +36349,94 @@ async function runPythonSidecarUpdatePlan(plan) {
36162
36349
  process.stderr.write(
36163
36350
  "Updated Deepline SDK package did not report a version.\n"
36164
36351
  );
36165
- (0, import_node_fs19.rmSync)(tempDir, { recursive: true, force: true });
36352
+ (0, import_node_fs20.rmSync)(tempDir, { recursive: true, force: true });
36166
36353
  return 1;
36167
36354
  }
36168
- const finalDir = (0, import_node_path22.join)(versionsDir, installedVersion);
36355
+ const stagedFailure = sidecarInstallFailure(tempDir);
36356
+ if (stagedFailure) {
36357
+ process.stderr.write(
36358
+ `Updated Deepline SDK package is incomplete: ${stagedFailure}.
36359
+ `
36360
+ );
36361
+ (0, import_node_fs20.rmSync)(tempDir, { recursive: true, force: true });
36362
+ return 1;
36363
+ }
36364
+ const finalDir = (0, import_node_path23.join)(versionsDir, installedVersion);
36169
36365
  const finalEntryPath = entryPathInVersionDir(finalDir);
36170
- if ((0, import_node_fs19.existsSync)(finalEntryPath)) {
36171
- (0, import_node_fs19.rmSync)(tempDir, { recursive: true, force: true });
36366
+ const finalFailure = sidecarInstallFailure(finalDir);
36367
+ let backupDir = null;
36368
+ if (!finalFailure) {
36369
+ (0, import_node_fs20.rmSync)(tempDir, { recursive: true, force: true });
36172
36370
  } else {
36173
- (0, import_node_fs19.rmSync)(finalDir, { recursive: true, force: true });
36174
- try {
36175
- (0, import_node_fs19.renameSync)(tempDir, finalDir);
36176
- } catch (error) {
36177
- (0, import_node_fs19.rmSync)(tempDir, { recursive: true, force: true });
36178
- process.stderr.write(
36179
- `Failed to publish Deepline SDK sidecar update: ${error.message}
36180
- `
36371
+ let shouldPublishTemp = true;
36372
+ if ((0, import_node_fs20.existsSync)(finalDir)) {
36373
+ backupDir = (0, import_node_path23.join)(
36374
+ versionsDir,
36375
+ `.backup-${installedVersion}-${process.pid}-${Date.now()}`
36181
36376
  );
36182
- return 1;
36377
+ try {
36378
+ (0, import_node_fs20.renameSync)(finalDir, backupDir);
36379
+ } catch (error) {
36380
+ const concurrentlyPublishedFailure = sidecarInstallFailure(finalDir);
36381
+ if (!concurrentlyPublishedFailure) {
36382
+ (0, import_node_fs20.rmSync)(tempDir, { recursive: true, force: true });
36383
+ backupDir = null;
36384
+ shouldPublishTemp = false;
36385
+ } else {
36386
+ (0, import_node_fs20.rmSync)(tempDir, { recursive: true, force: true });
36387
+ process.stderr.write(
36388
+ `Failed to preserve the incomplete Deepline SDK sidecar before repair: ${error.message}.
36389
+ `
36390
+ );
36391
+ return 1;
36392
+ }
36393
+ }
36394
+ }
36395
+ if (shouldPublishTemp) {
36396
+ try {
36397
+ (0, import_node_fs20.renameSync)(tempDir, finalDir);
36398
+ } catch (error) {
36399
+ (0, import_node_fs20.rmSync)(tempDir, { recursive: true, force: true });
36400
+ const concurrentlyPublishedFailure = sidecarInstallFailure(finalDir);
36401
+ if (!concurrentlyPublishedFailure) {
36402
+ if (backupDir) (0, import_node_fs20.rmSync)(backupDir, { recursive: true, force: true });
36403
+ backupDir = null;
36404
+ } else {
36405
+ let restoreFailure = "";
36406
+ if (backupDir && (0, import_node_fs20.existsSync)(backupDir) && !(0, import_node_fs20.existsSync)(finalDir)) {
36407
+ try {
36408
+ (0, import_node_fs20.renameSync)(backupDir, finalDir);
36409
+ backupDir = null;
36410
+ } catch (restoreError) {
36411
+ restoreFailure = `; failed to restore previous install: ${restoreError.message}`;
36412
+ }
36413
+ }
36414
+ process.stderr.write(
36415
+ `Failed to publish Deepline SDK sidecar update: ${error.message}; current install remains incomplete: ${concurrentlyPublishedFailure}${restoreFailure}.
36416
+ `
36417
+ );
36418
+ return 1;
36419
+ }
36420
+ }
36183
36421
  }
36184
36422
  }
36185
- if (!(0, import_node_fs19.existsSync)(finalEntryPath)) {
36423
+ const publishedFailure = sidecarStructureFailure(finalDir);
36424
+ if (publishedFailure) {
36425
+ if (backupDir && (0, import_node_fs20.existsSync)(backupDir)) {
36426
+ (0, import_node_fs20.rmSync)(finalDir, { recursive: true, force: true });
36427
+ try {
36428
+ (0, import_node_fs20.renameSync)(backupDir, finalDir);
36429
+ backupDir = null;
36430
+ } catch {
36431
+ }
36432
+ }
36186
36433
  process.stderr.write(
36187
- `Updated Deepline SDK CLI entrypoint missing: ${finalEntryPath}
36434
+ `Updated Deepline SDK CLI install is incomplete: ${publishedFailure}.
36188
36435
  `
36189
36436
  );
36190
36437
  return 1;
36191
36438
  }
36439
+ if (backupDir) (0, import_node_fs20.rmSync)(backupDir, { recursive: true, force: true });
36192
36440
  writeSidecarLauncher({
36193
36441
  path: plan.sidecarPath,
36194
36442
  hostUrl: plan.hostUrl,
@@ -36196,28 +36444,28 @@ async function runPythonSidecarUpdatePlan(plan) {
36196
36444
  nodeBin: plan.nodeBin,
36197
36445
  entryPath: finalEntryPath
36198
36446
  });
36199
- (0, import_node_fs19.writeFileSync)(
36200
- (0, import_node_path22.join)(plan.stateDir, ".version"),
36447
+ (0, import_node_fs20.writeFileSync)(
36448
+ (0, import_node_path23.join)(plan.stateDir, ".version"),
36201
36449
  `${installedVersion}
36202
36450
  `,
36203
36451
  "utf8"
36204
36452
  );
36205
- (0, import_node_fs19.writeFileSync)(
36206
- (0, import_node_path22.join)(plan.stateDir, ".install-method"),
36453
+ (0, import_node_fs20.writeFileSync)(
36454
+ (0, import_node_path23.join)(plan.stateDir, ".install-method"),
36207
36455
  "python-sidecar\n",
36208
36456
  "utf8"
36209
36457
  );
36210
- (0, import_node_fs19.writeFileSync)(
36211
- (0, import_node_path22.join)(plan.stateDir, ".command-path"),
36458
+ (0, import_node_fs20.writeFileSync)(
36459
+ (0, import_node_path23.join)(plan.stateDir, ".command-path"),
36212
36460
  `${plan.sidecarPath}
36213
36461
  `,
36214
36462
  "utf8"
36215
36463
  );
36216
- (0, import_node_fs19.writeFileSync)((0, import_node_path22.join)(plan.stateDir, ".runner"), "node\n", "utf8");
36217
- (0, import_node_fs19.writeFileSync)((0, import_node_path22.join)(plan.stateDir, ".node-bin"), `${plan.nodeBin}
36464
+ (0, import_node_fs20.writeFileSync)((0, import_node_path23.join)(plan.stateDir, ".runner"), "node\n", "utf8");
36465
+ (0, import_node_fs20.writeFileSync)((0, import_node_path23.join)(plan.stateDir, ".node-bin"), `${plan.nodeBin}
36218
36466
  `, "utf8");
36219
- (0, import_node_fs19.writeFileSync)(
36220
- (0, import_node_path22.join)(plan.stateDir, ".entry-path"),
36467
+ (0, import_node_fs20.writeFileSync)(
36468
+ (0, import_node_path23.join)(plan.stateDir, ".entry-path"),
36221
36469
  `${finalEntryPath}
36222
36470
  `,
36223
36471
  "utf8"
@@ -36340,9 +36588,9 @@ Examples:
36340
36588
 
36341
36589
  // src/cli/commands/setup.ts
36342
36590
  var import_node_child_process4 = require("child_process");
36343
- var import_node_fs20 = require("fs");
36591
+ var import_node_fs21 = require("fs");
36344
36592
  var import_node_os17 = require("os");
36345
- var import_node_path23 = require("path");
36593
+ var import_node_path24 = require("path");
36346
36594
  var SETUP_PHASE_NAMES = [
36347
36595
  "cli",
36348
36596
  "cleanup",
@@ -36399,7 +36647,7 @@ function phasesFromLegacyStatus(status) {
36399
36647
  function readSetupState(input2) {
36400
36648
  try {
36401
36649
  const parsed = JSON.parse(
36402
- (0, import_node_fs20.readFileSync)(
36650
+ (0, import_node_fs21.readFileSync)(
36403
36651
  setupStatePath(input2.baseUrl, input2.scope, input2.root),
36404
36652
  "utf8"
36405
36653
  )
@@ -36475,7 +36723,7 @@ function buildPendingAuthorizationOutput(input2) {
36475
36723
  };
36476
36724
  }
36477
36725
  function setupStatePath(baseUrl, scope, root) {
36478
- return scope === "local" && root ? (0, import_node_path23.join)(root, ".deepline", "setup", "state.json") : (0, import_node_path23.join)(sdkCliStateDirPath(baseUrl), "setup.json");
36726
+ return scope === "local" && root ? (0, import_node_path24.join)(root, ".deepline", "setup", "state.json") : (0, import_node_path24.join)(sdkCliStateDirPath(baseUrl), "setup.json");
36479
36727
  }
36480
36728
  async function captureStdout2(run) {
36481
36729
  let stdout = "";
@@ -36504,14 +36752,14 @@ function asRecord3(value) {
36504
36752
  }
36505
36753
  function safeRead(path) {
36506
36754
  try {
36507
- return (0, import_node_fs20.readFileSync)(path, "utf8");
36755
+ return (0, import_node_fs21.readFileSync)(path, "utf8");
36508
36756
  } catch {
36509
36757
  return "";
36510
36758
  }
36511
36759
  }
36512
36760
  function isNpmManagedDeeplinePath(path) {
36513
36761
  try {
36514
- return (0, import_node_fs20.realpathSync)(path).includes(`${(0, import_node_path23.join)("node_modules", "deepline")}`);
36762
+ return (0, import_node_fs21.realpathSync)(path).includes(`${(0, import_node_path24.join)("node_modules", "deepline")}`);
36515
36763
  } catch {
36516
36764
  return false;
36517
36765
  }
@@ -36522,32 +36770,32 @@ function isInstallerManagedLegacyLauncher(path) {
36522
36770
  }
36523
36771
  function removeKnownLegacyPaths(baseUrl) {
36524
36772
  const home = (0, import_node_os17.homedir)();
36525
- const hostDir = (0, import_node_path23.join)(home, ".local", "deepline", baseUrlSlug(baseUrl));
36526
- const legacyLauncherPath = (0, import_node_path23.join)(home, ".local", "bin", "deepline");
36773
+ const hostDir = (0, import_node_path24.join)(home, ".local", "deepline", baseUrlSlug(baseUrl));
36774
+ const legacyLauncherPath = (0, import_node_path24.join)(home, ".local", "bin", "deepline");
36527
36775
  const installerCommandPath = safeRead(
36528
- (0, import_node_path23.join)(hostDir, "sdk", ".command-path")
36776
+ (0, import_node_path24.join)(hostDir, "sdk", ".command-path")
36529
36777
  ).trim();
36530
36778
  const candidates = [
36531
36779
  ...isInstallerManagedLegacyLauncher(legacyLauncherPath) ? [legacyLauncherPath] : [],
36532
- (0, import_node_path23.join)(home, ".local", "bin", "deepline-real"),
36533
- (0, import_node_path23.join)(hostDir, "bin", "deepline"),
36534
- (0, import_node_path23.join)(hostDir, "bin", "deepline-real"),
36535
- (0, import_node_path23.join)(hostDir, "cli", ".install-method"),
36536
- (0, import_node_path23.join)(hostDir, "cli", ".version"),
36537
- (0, import_node_path23.join)(hostDir, "sdk", ".install-method"),
36538
- (0, import_node_path23.join)(hostDir, "sdk", ".command-path"),
36780
+ (0, import_node_path24.join)(home, ".local", "bin", "deepline-real"),
36781
+ (0, import_node_path24.join)(hostDir, "bin", "deepline"),
36782
+ (0, import_node_path24.join)(hostDir, "bin", "deepline-real"),
36783
+ (0, import_node_path24.join)(hostDir, "cli", ".install-method"),
36784
+ (0, import_node_path24.join)(hostDir, "cli", ".version"),
36785
+ (0, import_node_path24.join)(hostDir, "sdk", ".install-method"),
36786
+ (0, import_node_path24.join)(hostDir, "sdk", ".command-path"),
36539
36787
  ...installerCommandPath ? [
36540
36788
  installerCommandPath,
36541
- (0, import_node_path23.join)((0, import_node_path23.dirname)(installerCommandPath), "deepline-sdk")
36789
+ (0, import_node_path24.join)((0, import_node_path24.dirname)(installerCommandPath), "deepline-sdk")
36542
36790
  ] : []
36543
36791
  ];
36544
36792
  const removed = [];
36545
36793
  for (const path of candidates) {
36546
- if (!(0, import_node_fs20.existsSync)(path)) continue;
36794
+ if (!(0, import_node_fs21.existsSync)(path)) continue;
36547
36795
  if (path === installerCommandPath && isNpmManagedDeeplinePath(path)) {
36548
36796
  continue;
36549
36797
  }
36550
- (0, import_node_fs20.rmSync)(path, { force: true });
36798
+ (0, import_node_fs21.rmSync)(path, { force: true });
36551
36799
  removed.push(path);
36552
36800
  }
36553
36801
  return removed;
@@ -36560,7 +36808,7 @@ function resolvePathCommands(command) {
36560
36808
  );
36561
36809
  return [
36562
36810
  ...new Set(
36563
- String(lookup.stdout ?? "").split(/\r?\n/).map((line) => line.trim()).filter(Boolean).map((path) => (0, import_node_path23.resolve)(path))
36811
+ String(lookup.stdout ?? "").split(/\r?\n/).map((line) => line.trim()).filter(Boolean).map((path) => (0, import_node_path24.resolve)(path))
36564
36812
  )
36565
36813
  ];
36566
36814
  }
@@ -36570,7 +36818,7 @@ function resolvePathCommand(command) {
36570
36818
  function isHomebrewFormulaCommand(path) {
36571
36819
  let resolvedPath = path;
36572
36820
  try {
36573
- resolvedPath = (0, import_node_fs20.realpathSync)(path);
36821
+ resolvedPath = (0, import_node_fs21.realpathSync)(path);
36574
36822
  } catch {
36575
36823
  return false;
36576
36824
  }
@@ -36581,7 +36829,7 @@ function isHomebrewFormulaCommand(path) {
36581
36829
  function resolvePersistentGlobalCommand(dependencies = {}) {
36582
36830
  const platform3 = dependencies.platform ?? process.platform;
36583
36831
  const run = dependencies.spawn ?? import_node_child_process4.spawnSync;
36584
- const pathExists = dependencies.exists ?? import_node_fs20.existsSync;
36832
+ const pathExists = dependencies.exists ?? import_node_fs21.existsSync;
36585
36833
  const pathClis = dependencies.pathClis ?? resolvePathCommands("deepline");
36586
36834
  const homebrewCommand = pathClis.find(isHomebrewFormulaCommand);
36587
36835
  if (homebrewCommand) return homebrewCommand;
@@ -36593,7 +36841,7 @@ function resolvePersistentGlobalCommand(dependencies = {}) {
36593
36841
  if (prefix.status !== 0) return null;
36594
36842
  const root = String(prefix.stdout ?? "").trim();
36595
36843
  if (!root) return null;
36596
- const candidates = platform3 === "win32" ? [(0, import_node_path23.join)(root, "deepline.cmd"), (0, import_node_path23.join)(root, "deepline")] : [(0, import_node_path23.join)(root, "bin", "deepline")];
36844
+ const candidates = platform3 === "win32" ? [(0, import_node_path24.join)(root, "deepline.cmd"), (0, import_node_path24.join)(root, "deepline")] : [(0, import_node_path24.join)(root, "bin", "deepline")];
36597
36845
  return candidates.find((candidate) => pathExists(candidate)) ?? null;
36598
36846
  }
36599
36847
  function inspectGlobalCliAvailability(input2) {
@@ -36606,20 +36854,20 @@ function inspectGlobalCliAvailability(input2) {
36606
36854
  }
36607
36855
  function pathsResolveToSameFile(left, right) {
36608
36856
  try {
36609
- return (0, import_node_fs20.realpathSync)(left) === (0, import_node_fs20.realpathSync)(right);
36857
+ return (0, import_node_fs21.realpathSync)(left) === (0, import_node_fs21.realpathSync)(right);
36610
36858
  } catch {
36611
- return (0, import_node_path23.resolve)(left) === (0, import_node_path23.resolve)(right);
36859
+ return (0, import_node_path24.resolve)(left) === (0, import_node_path24.resolve)(right);
36612
36860
  }
36613
36861
  }
36614
36862
  function isKnownDeeplineCommand(path) {
36615
- const entrypoint = process.argv[1] ? (0, import_node_path23.resolve)(process.argv[1]) : "";
36863
+ const entrypoint = process.argv[1] ? (0, import_node_path24.resolve)(process.argv[1]) : "";
36616
36864
  let resolvedPath = path;
36617
36865
  try {
36618
- resolvedPath = (0, import_node_fs20.realpathSync)(path);
36866
+ resolvedPath = (0, import_node_fs21.realpathSync)(path);
36619
36867
  } catch {
36620
36868
  }
36621
36869
  if (entrypoint && resolvedPath === entrypoint) return true;
36622
- if (resolvedPath.includes(`${(0, import_node_path23.join)("node_modules", "deepline")}`)) return true;
36870
+ if (resolvedPath.includes(`${(0, import_node_path24.join)("node_modules", "deepline")}`)) return true;
36623
36871
  const content = safeRead(path);
36624
36872
  return content.includes("node_modules/deepline") || content.includes("node_modules\\deepline") || content.includes("DEEPLINE_CONFIG_SCOPE") || content.includes("deepline-real");
36625
36873
  }
@@ -36627,9 +36875,9 @@ function inspectPathConflict() {
36627
36875
  const commandPath = resolvePathCommand("deepline");
36628
36876
  if (!commandPath || isKnownDeeplineCommand(commandPath)) return null;
36629
36877
  try {
36630
- if ((0, import_node_fs20.lstatSync)(commandPath).isSymbolicLink()) {
36631
- const target = (0, import_node_fs20.realpathSync)(commandPath);
36632
- if (target.includes(`${(0, import_node_path23.join)("node_modules", "deepline")}`)) return null;
36878
+ if ((0, import_node_fs21.lstatSync)(commandPath).isSymbolicLink()) {
36879
+ const target = (0, import_node_fs21.realpathSync)(commandPath);
36880
+ if (target.includes(`${(0, import_node_path24.join)("node_modules", "deepline")}`)) return null;
36633
36881
  }
36634
36882
  } catch {
36635
36883
  }
@@ -36637,8 +36885,8 @@ function inspectPathConflict() {
36637
36885
  }
36638
36886
  function writeSetupState(input2) {
36639
36887
  const path = setupStatePath(input2.baseUrl, input2.scope, input2.root);
36640
- (0, import_node_fs20.mkdirSync)((0, import_node_path23.dirname)(path), { recursive: true });
36641
- (0, import_node_fs20.writeFileSync)(
36888
+ (0, import_node_fs21.mkdirSync)((0, import_node_path24.dirname)(path), { recursive: true });
36889
+ (0, import_node_fs21.writeFileSync)(
36642
36890
  path,
36643
36891
  `${JSON.stringify(
36644
36892
  {
@@ -36678,7 +36926,7 @@ function failSetupPhase(phases, phase, code) {
36678
36926
  phases[phase] = { status: "failed", code };
36679
36927
  }
36680
36928
  function rollbackCommand(scope, root) {
36681
- const prefix = scope === "local" && root ? ` --prefix ${JSON.stringify((0, import_node_path23.join)(root, ".deepline", "runtime"))}` : "";
36929
+ const prefix = scope === "local" && root ? ` --prefix ${JSON.stringify((0, import_node_path24.join)(root, ".deepline", "runtime"))}` : "";
36682
36930
  return `npm install -g${prefix} --no-audit --no-fund --include=optional --allow-scripts=esbuild deepline@${SDK_VERSION}`;
36683
36931
  }
36684
36932
  function setupResumeCommand(baseUrl, scope) {
@@ -36765,12 +37013,12 @@ function buildDoctorAssessment(input2) {
36765
37013
  const connected = input2.authStatus.payload?.connected === true;
36766
37014
  const authScopeOk = input2.scope === "local" ? Boolean(projectAuth) : Boolean(apiKey && !projectAuth);
36767
37015
  const skillsOk = skillsState?.scope === input2.scope && typeof skillsState.skillsVersion === "string" && Array.isArray(skillsState.agents) && skillsState.agents.length > 0;
36768
- const runningCliPath = process.argv[1] ? (0, import_node_path23.resolve)(process.argv[1]) : null;
37016
+ const runningCliPath = process.argv[1] ? (0, import_node_path24.resolve)(process.argv[1]) : null;
36769
37017
  const globalCli = input2.scope === "global" ? inspectGlobalCliAvailability() : null;
36770
37018
  const pathGlobalCli = globalCli?.path ?? null;
36771
37019
  const cliPath = input2.scope === "global" ? pathGlobalCli : runningCliPath;
36772
37020
  const cliScopeOk = input2.scope === "global" ? Boolean(pathGlobalCli) : Boolean(
36773
- input2.root && runningCliPath?.includes((0, import_node_path23.join)(input2.root, ".deepline", "runtime"))
37021
+ input2.root && runningCliPath?.includes((0, import_node_path24.join)(input2.root, ".deepline", "runtime"))
36774
37022
  );
36775
37023
  const checks = {
36776
37024
  cli: {
@@ -37416,7 +37664,7 @@ function isDowngradeAutoUpdateResponse(response) {
37416
37664
  return compareSemver(target, current) < 0;
37417
37665
  }
37418
37666
  function relaunchCurrentCommand(plan) {
37419
- return new Promise((resolve18) => {
37667
+ return new Promise((resolve19) => {
37420
37668
  const command = plan.kind === "python-sidecar" ? plan.sidecarPath : process.execPath;
37421
37669
  const args = plan.kind === "python-sidecar" ? process.argv.slice(2) : process.argv.slice(1);
37422
37670
  const child = (0, import_node_child_process5.spawn)(command, args, {
@@ -37432,9 +37680,9 @@ function relaunchCurrentCommand(plan) {
37432
37680
  `Deepline SDK/CLI updated, but relaunch failed: ${error.message}
37433
37681
  `
37434
37682
  );
37435
- resolve18(1);
37683
+ resolve19(1);
37436
37684
  });
37437
- child.on("close", (code) => resolve18(code ?? 1));
37685
+ child.on("close", (code) => resolve19(code ?? 1));
37438
37686
  });
37439
37687
  }
37440
37688
  async function maybeAutoUpdateAndRelaunch(response) {
@@ -37485,8 +37733,8 @@ async function maybeAutoUpdateAndRelaunch(response) {
37485
37733
 
37486
37734
  // src/cli/skills-sync.ts
37487
37735
  var import_node_child_process6 = require("child_process");
37488
- var import_node_fs21 = require("fs");
37489
- var import_node_path24 = require("path");
37736
+ var import_node_fs22 = require("fs");
37737
+ var import_node_path25 = require("path");
37490
37738
  var CHECK_TIMEOUT_MS2 = 3e3;
37491
37739
  var attemptedSync = false;
37492
37740
  function shouldSkipSkillsSync() {
@@ -37502,51 +37750,51 @@ function activePluginSkillsDir() {
37502
37750
  return "";
37503
37751
  }
37504
37752
  const dir = process.env.DEEPLINE_PLUGIN_SKILLS_DIR?.trim() ?? "";
37505
- return dir && (0, import_node_fs21.existsSync)(dir) ? dir : "";
37753
+ return dir && (0, import_node_fs22.existsSync)(dir) ? dir : "";
37506
37754
  }
37507
37755
  function readPluginSkillsVersion() {
37508
37756
  const dir = activePluginSkillsDir();
37509
37757
  if (!dir) return "";
37510
37758
  try {
37511
- return (0, import_node_fs21.readFileSync)((0, import_node_path24.join)(dir, ".version"), "utf-8").trim();
37759
+ return (0, import_node_fs22.readFileSync)((0, import_node_path25.join)(dir, ".version"), "utf-8").trim();
37512
37760
  } catch {
37513
37761
  return "";
37514
37762
  }
37515
37763
  }
37516
37764
  function sdkSkillsVersionPath(baseUrl) {
37517
- return (0, import_node_path24.join)(sdkCliStateDirPath(baseUrl), "skills-version");
37765
+ return (0, import_node_path25.join)(sdkCliStateDirPath(baseUrl), "skills-version");
37518
37766
  }
37519
37767
  function legacySdkSkillsVersionPath(baseUrl) {
37520
- return (0, import_node_path24.join)((0, import_node_path24.dirname)(sdkCliStateDirPath(baseUrl)), "sdk-skills", ".version");
37768
+ return (0, import_node_path25.join)((0, import_node_path25.dirname)(sdkCliStateDirPath(baseUrl)), "sdk-skills", ".version");
37521
37769
  }
37522
37770
  function unavailableSkillsNoticePath(baseUrl) {
37523
- return (0, import_node_path24.join)(sdkCliStateDirPath(baseUrl), "skills-sync-unavailable-version");
37771
+ return (0, import_node_path25.join)(sdkCliStateDirPath(baseUrl), "skills-sync-unavailable-version");
37524
37772
  }
37525
37773
  function readSdkSkillsLocalVersion(baseUrl) {
37526
37774
  const pluginVersion = readPluginSkillsVersion();
37527
37775
  if (pluginVersion) return pluginVersion;
37528
- const path = (0, import_node_fs21.existsSync)(sdkSkillsVersionPath(baseUrl)) ? sdkSkillsVersionPath(baseUrl) : legacySdkSkillsVersionPath(baseUrl);
37529
- if (!(0, import_node_fs21.existsSync)(path)) return "";
37776
+ const path = (0, import_node_fs22.existsSync)(sdkSkillsVersionPath(baseUrl)) ? sdkSkillsVersionPath(baseUrl) : legacySdkSkillsVersionPath(baseUrl);
37777
+ if (!(0, import_node_fs22.existsSync)(path)) return "";
37530
37778
  try {
37531
- return (0, import_node_fs21.readFileSync)(path, "utf-8").trim();
37779
+ return (0, import_node_fs22.readFileSync)(path, "utf-8").trim();
37532
37780
  } catch {
37533
37781
  return "";
37534
37782
  }
37535
37783
  }
37536
37784
  function writeLocalSkillsVersion(baseUrl, version) {
37537
37785
  const path = sdkSkillsVersionPath(baseUrl);
37538
- (0, import_node_fs21.mkdirSync)((0, import_node_path24.dirname)(path), { recursive: true });
37539
- (0, import_node_fs21.writeFileSync)(path, `${version}
37786
+ (0, import_node_fs22.mkdirSync)((0, import_node_path25.dirname)(path), { recursive: true });
37787
+ (0, import_node_fs22.writeFileSync)(path, `${version}
37540
37788
  `, "utf-8");
37541
37789
  }
37542
37790
  function writeUnavailableSkillsNotice(baseUrl, remoteVersion, skillNames) {
37543
37791
  const path = unavailableSkillsNoticePath(baseUrl);
37544
37792
  try {
37545
- if ((0, import_node_fs21.existsSync)(path) && (0, import_node_fs21.readFileSync)(path, "utf-8").trim() === remoteVersion) {
37793
+ if ((0, import_node_fs22.existsSync)(path) && (0, import_node_fs22.readFileSync)(path, "utf-8").trim() === remoteVersion) {
37546
37794
  return;
37547
37795
  }
37548
- (0, import_node_fs21.mkdirSync)((0, import_node_path24.dirname)(path), { recursive: true });
37549
- (0, import_node_fs21.writeFileSync)(path, `${remoteVersion}
37796
+ (0, import_node_fs22.mkdirSync)((0, import_node_path25.dirname)(path), { recursive: true });
37797
+ (0, import_node_fs22.writeFileSync)(path, `${remoteVersion}
37550
37798
  `, "utf-8");
37551
37799
  } catch {
37552
37800
  }
@@ -37558,7 +37806,7 @@ ${manualCommand}`
37558
37806
  }
37559
37807
  function clearUnavailableSkillsNotice(baseUrl) {
37560
37808
  try {
37561
- (0, import_node_fs21.unlinkSync)(unavailableSkillsNoticePath(baseUrl));
37809
+ (0, import_node_fs22.unlinkSync)(unavailableSkillsNoticePath(baseUrl));
37562
37810
  } catch {
37563
37811
  }
37564
37812
  }
@@ -37680,7 +37928,7 @@ function resolveSkillsInstallCommands(baseUrl, skillNames = DEFAULT_SDK_SKILL_NA
37680
37928
  return commands;
37681
37929
  }
37682
37930
  function runOneSkillsInstall(install) {
37683
- return new Promise((resolve18) => {
37931
+ return new Promise((resolve19) => {
37684
37932
  const plan = resolveSkillsInstallSpawn(install);
37685
37933
  const child = (0, import_node_child_process6.spawn)(plan.command, plan.args, {
37686
37934
  stdio: ["ignore", "ignore", "pipe"],
@@ -37692,7 +37940,7 @@ function runOneSkillsInstall(install) {
37692
37940
  stderr += chunk.toString("utf-8");
37693
37941
  });
37694
37942
  child.on("error", (error) => {
37695
- resolve18({
37943
+ resolve19({
37696
37944
  ok: false,
37697
37945
  detail: `failed to start ${install.command}: ${error.message}`,
37698
37946
  manualCommand: install.manualCommand
@@ -37700,11 +37948,11 @@ function runOneSkillsInstall(install) {
37700
37948
  });
37701
37949
  child.on("close", (code) => {
37702
37950
  if (code === 0) {
37703
- resolve18({ ok: true, detail: "", manualCommand: install.manualCommand });
37951
+ resolve19({ ok: true, detail: "", manualCommand: install.manualCommand });
37704
37952
  return;
37705
37953
  }
37706
37954
  const detail = stderr.trim();
37707
- resolve18({
37955
+ resolve19({
37708
37956
  ok: false,
37709
37957
  detail: detail ? `${install.command}: ${detail}` : `${install.command} exited ${code}`,
37710
37958
  manualCommand: install.manualCommand
@@ -38132,8 +38380,8 @@ function topLevelCommandKnown(program, commandName) {
38132
38380
  );
38133
38381
  }
38134
38382
  async function runPlayRunnerHealthCheck() {
38135
- const dir = await (0, import_promises8.mkdtemp)((0, import_node_path25.join)((0, import_node_os19.tmpdir)(), "deepline-health-play-"));
38136
- const file = (0, import_node_path25.join)(dir, "health-check.play.ts");
38383
+ const dir = await (0, import_promises8.mkdtemp)((0, import_node_path26.join)((0, import_node_os19.tmpdir)(), "deepline-health-play-"));
38384
+ const file = (0, import_node_path26.join)(dir, "health-check.play.ts");
38137
38385
  try {
38138
38386
  await (0, import_promises8.writeFile)(
38139
38387
  file,