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.
@@ -164,7 +164,7 @@ configureProxyFromEnv();
164
164
 
165
165
  // src/cli/index.ts
166
166
  import { mkdtemp as mkdtemp2, rm as rm2, writeFile as writeFile6 } from "fs/promises";
167
- import { join as join21 } from "path";
167
+ import { join as join22 } from "path";
168
168
  import { tmpdir as tmpdir6 } from "os";
169
169
  import { Command as Command4 } from "commander";
170
170
 
@@ -1030,7 +1030,7 @@ var SDK_RELEASE = {
1030
1030
  // 0.2.0 makes Dataset Handles uniformly async-only after 0.1.320 briefly
1031
1031
  // exposed storage-dependent synchronous access. This deliberate minor
1032
1032
  // release keeps lazy paging semantics independent of row residency.
1033
- version: "0.2.19",
1033
+ version: "0.2.21",
1034
1034
  contracts: {
1035
1035
  api: {
1036
1036
  name: "sdk-http-api",
@@ -1798,7 +1798,7 @@ function decodeSseFrame(frame) {
1798
1798
  return parsed;
1799
1799
  }
1800
1800
  function sleep(ms) {
1801
- return new Promise((resolve18) => setTimeout(resolve18, ms));
1801
+ return new Promise((resolve19) => setTimeout(resolve19, ms));
1802
1802
  }
1803
1803
  function withCoworkNetworkHint(message) {
1804
1804
  if (!isCoworkLikeSandbox2() || message.includes(COWORK_NETWORK_HINT)) {
@@ -3100,14 +3100,14 @@ async function* observeRunEvents(options) {
3100
3100
  try {
3101
3101
  for (; ; ) {
3102
3102
  if (queue.length === 0) {
3103
- const waitForItem = new Promise((resolve18) => {
3104
- wake = resolve18;
3103
+ const waitForItem = new Promise((resolve19) => {
3104
+ wake = resolve19;
3105
3105
  });
3106
3106
  if (!sawFirstSnapshot) {
3107
3107
  const timedOut = await Promise.race([
3108
3108
  waitForItem.then(() => false),
3109
3109
  new Promise(
3110
- (resolve18) => setTimeout(() => resolve18(true), OBSERVE_BOOTSTRAP_TIMEOUT_MS)
3110
+ (resolve19) => setTimeout(() => resolve19(true), OBSERVE_BOOTSTRAP_TIMEOUT_MS)
3111
3111
  )
3112
3112
  ]);
3113
3113
  if (timedOut && queue.length === 0) {
@@ -3417,7 +3417,7 @@ function parseEnvTestPolicyOverrides() {
3417
3417
  return normalizeTestPolicyOverrides(parsed, "DEEPLINE_TEST_POLICY_OVERRIDES");
3418
3418
  }
3419
3419
  function sleep2(ms) {
3420
- return new Promise((resolve18) => setTimeout(resolve18, ms));
3420
+ return new Promise((resolve19) => setTimeout(resolve19, ms));
3421
3421
  }
3422
3422
  function isTransientCompileManifestError(error) {
3423
3423
  if (error instanceof DeeplineError && typeof error.statusCode === "number") {
@@ -6477,6 +6477,10 @@ function collectLocalEnvInfo() {
6477
6477
  function readCsvRows(csvPath) {
6478
6478
  const raw = readFileSync4(resolve2(csvPath), "utf-8");
6479
6479
  return parse(raw, {
6480
+ // `csv-parse` otherwise treats a BOM before an opening quote as a field
6481
+ // value, then rejects the quote as invalid. A UTF-8 BOM is a valid file
6482
+ // prefix and must not become part of the first column name either.
6483
+ bom: true,
6480
6484
  columns: true,
6481
6485
  skip_empty_lines: true
6482
6486
  });
@@ -6959,7 +6963,7 @@ function buildCandidateUrls2(url) {
6959
6963
  }
6960
6964
  }
6961
6965
  function sleep4(ms) {
6962
- return new Promise((resolve18) => setTimeout(resolve18, ms));
6966
+ return new Promise((resolve19) => setTimeout(resolve19, ms));
6963
6967
  }
6964
6968
  function printDeeplineLogo() {
6965
6969
  if (process.stdout.isTTY && (process.stdout.columns ?? 80) >= 70) {
@@ -15960,27 +15964,6 @@ var SECRET_ENV_PATTERN = /\bprocess(?:\.env|\[['"]env['"]\])(?:\.|\[['"])([A-Z0-
15960
15964
  var PRIVATE_KEY_PATTERN = /-----BEGIN (?:RSA |EC |OPENSSH |PGP )?PRIVATE KEY-----/;
15961
15965
  var BEARER_LITERAL_PATTERN = /\bBearer\s+[A-Za-z0-9._~+/=-]{16,}/i;
15962
15966
  var ASSIGNMENT_SECRET_LITERAL_PATTERN = /\b(?:api[_-]?key|token|secret|password)\b\s*[:=]\s*['"][^'"]{12,}['"]/i;
15963
- var HIGH_ENTROPY_LITERAL_PATTERN = /['"]([A-Za-z0-9+/=_-]{32,})['"]/g;
15964
- 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;
15965
- var BOOTSTRAP_RESOURCE_IDENTIFIER_PATTERN = /^bootstrap-[0-9a-f]{32}(?:\/[a-z0-9][a-z0-9_-]{0,127})?$/i;
15966
- var SECRET_LABEL_PATTERN = /(?:^|[-_])(?:api|auth|access|secret|token|key|password|credential|bearer|sk|pk|live)(?:[-_]|$)/i;
15967
- function shannonEntropy(value) {
15968
- const counts = /* @__PURE__ */ new Map();
15969
- for (const char of value) counts.set(char, (counts.get(char) ?? 0) + 1);
15970
- return [...counts.values()].reduce((entropy, count) => {
15971
- const p = count / value.length;
15972
- return entropy - p * Math.log2(p);
15973
- }, 0);
15974
- }
15975
- function isNonSecretUuidIdentifier(value) {
15976
- const match = UUID_IDENTIFIER_PATTERN.exec(value);
15977
- if (!match) return false;
15978
- const label = match[1] ?? "";
15979
- return !SECRET_LABEL_PATTERN.test(label);
15980
- }
15981
- function isNonSecretBootstrapResourceIdentifier(value) {
15982
- return BOOTSTRAP_RESOURCE_IDENTIFIER_PATTERN.test(value);
15983
- }
15984
15967
  function collectInlineSecretFindings(sourceCode) {
15985
15968
  const findings = [];
15986
15969
  for (const match of sourceCode.matchAll(SECRET_ENV_PATTERN)) {
@@ -15992,15 +15975,6 @@ function collectInlineSecretFindings(sourceCode) {
15992
15975
  if (ASSIGNMENT_SECRET_LITERAL_PATTERN.test(sourceCode)) {
15993
15976
  findings.push("secret-looking assignment literal");
15994
15977
  }
15995
- for (const match of sourceCode.matchAll(HIGH_ENTROPY_LITERAL_PATTERN)) {
15996
- const literal = match[1] ?? "";
15997
- if (isNonSecretUuidIdentifier(literal)) continue;
15998
- if (isNonSecretBootstrapResourceIdentifier(literal)) continue;
15999
- if (literal.length >= 40 && shannonEntropy(literal) >= 4.2) {
16000
- findings.push("high-entropy string literal");
16001
- break;
16002
- }
16003
- }
16004
15978
  return [...new Set(findings)];
16005
15979
  }
16006
15980
 
@@ -17128,7 +17102,7 @@ function traceCliSync(phase, fields, run) {
17128
17102
  }
17129
17103
  }
17130
17104
  function sleep5(ms) {
17131
- return new Promise((resolve18) => setTimeout(resolve18, ms));
17105
+ return new Promise((resolve19) => setTimeout(resolve19, ms));
17132
17106
  }
17133
17107
  function parseReferencedPlayTarget2(target) {
17134
17108
  const trimmed = target.trim();
@@ -25591,7 +25565,7 @@ function emitEnrichDebug(message) {
25591
25565
  );
25592
25566
  }
25593
25567
  function sleep6(ms) {
25594
- return new Promise((resolve18) => setTimeout(resolve18, ms));
25568
+ return new Promise((resolve19) => setTimeout(resolve19, ms));
25595
25569
  }
25596
25570
  function enrichExportBackingRowsWaitMs() {
25597
25571
  const raw = process.env.DEEPLINE_ENRICH_EXPORT_BACKING_ROWS_WAIT_MS?.trim();
@@ -31763,7 +31737,7 @@ async function readHiddenLine(prompt, streams = {}) {
31763
31737
  }
31764
31738
  let value = "";
31765
31739
  inputStream.resume();
31766
- return await new Promise((resolve18, reject) => {
31740
+ return await new Promise((resolve19, reject) => {
31767
31741
  let settled = false;
31768
31742
  const cleanup = () => {
31769
31743
  inputStream.off("data", onData);
@@ -31781,7 +31755,7 @@ async function readHiddenLine(prompt, streams = {}) {
31781
31755
  settled = true;
31782
31756
  outputStream.write("\n");
31783
31757
  cleanup();
31784
- resolve18(line);
31758
+ resolve19(line);
31785
31759
  };
31786
31760
  const fail = (error) => {
31787
31761
  if (settled) return;
@@ -35242,17 +35216,17 @@ Notes:
35242
35216
  // src/cli/commands/update.ts
35243
35217
  import { spawn as spawn3 } from "child_process";
35244
35218
  import {
35245
- existsSync as existsSync14,
35219
+ existsSync as existsSync15,
35246
35220
  mkdirSync as mkdirSync10,
35247
35221
  realpathSync as realpathSync3,
35248
- readFileSync as readFileSync14,
35222
+ readFileSync as readFileSync15,
35249
35223
  renameSync,
35250
35224
  rmSync as rmSync4,
35251
35225
  unlinkSync,
35252
35226
  writeFileSync as writeFileSync15
35253
35227
  } from "fs";
35254
35228
  import { homedir as homedir12 } from "os";
35255
- import { dirname as dirname16, isAbsolute as isAbsolute5, join as join18, relative as relative4, resolve as resolve16 } from "path";
35229
+ import { dirname as dirname16, isAbsolute as isAbsolute6, join as join19, relative as relative5, resolve as resolve17 } from "path";
35256
35230
 
35257
35231
  // src/cli/commands/skills.ts
35258
35232
  import { spawn as spawn2 } from "child_process";
@@ -35556,7 +35530,7 @@ function readSkillsInstallState(path) {
35556
35530
  }
35557
35531
  }
35558
35532
  function runProcess(command, args, cwd) {
35559
- return new Promise((resolve18, reject) => {
35533
+ return new Promise((resolve19, reject) => {
35560
35534
  const plan = resolveShellSpawn(command, args);
35561
35535
  const child = spawn2(plan.command, plan.args, {
35562
35536
  cwd,
@@ -35575,7 +35549,7 @@ function runProcess(command, args, cwd) {
35575
35549
  process.stderr.write(`skills@latest exited ${code}.
35576
35550
  `);
35577
35551
  }
35578
- resolve18(code ?? 1);
35552
+ resolve19(code ?? 1);
35579
35553
  });
35580
35554
  });
35581
35555
  }
@@ -35769,6 +35743,166 @@ Examples:
35769
35743
  });
35770
35744
  }
35771
35745
 
35746
+ // src/cli/install-integrity.ts
35747
+ import { createRequire } from "module";
35748
+ import { existsSync as existsSync14, readFileSync as readFileSync14, statSync as statSync5 } from "fs";
35749
+ import { isAbsolute as isAbsolute5, join as join18, relative as relative4, resolve as resolve16 } from "path";
35750
+ var SDK_SIDECAR_CRITICAL_PACKAGE_FILES = [
35751
+ "dist/cli/index.mjs",
35752
+ "dist/index.mjs",
35753
+ "dist/index.d.ts",
35754
+ "dist/plays/bundle-play-file.mjs",
35755
+ "dist/bundling-sources/shared_libs/observability/telemetry.ts",
35756
+ "dist/bundling-sources/shared_libs/play-runtime/backend.ts",
35757
+ "dist/bundling-sources/shared_libs/plays/bundling/index.ts",
35758
+ "dist/bundling-sources/shared_libs/tool-execution-error.ts"
35759
+ ];
35760
+ var SDK_SIDECAR_CRITICAL_DEPENDENCY_FILES = [
35761
+ "esbuild/package.json",
35762
+ "esbuild/lib/main.js"
35763
+ ];
35764
+ function safeRelativePath(value) {
35765
+ if (typeof value !== "string" || !value || isAbsolute5(value)) return false;
35766
+ const segments = value.split(/[\\/]+/);
35767
+ return segments.every(
35768
+ (segment) => Boolean(segment) && segment !== "." && segment !== ".."
35769
+ );
35770
+ }
35771
+ function resolveContainedPath(root, value) {
35772
+ if (!safeRelativePath(value)) return null;
35773
+ const target = resolve16(root, value);
35774
+ const relativeTarget = relative4(resolve16(root), target);
35775
+ if (!relativeTarget || relativeTarget.startsWith("..") || isAbsolute5(relativeTarget)) {
35776
+ return null;
35777
+ }
35778
+ return target;
35779
+ }
35780
+ function parseJson(path) {
35781
+ return JSON.parse(readFileSync14(path, "utf8"));
35782
+ }
35783
+ function isFile(path) {
35784
+ try {
35785
+ return statSync5(path).isFile();
35786
+ } catch {
35787
+ return false;
35788
+ }
35789
+ }
35790
+ function readManifest(packageRoot) {
35791
+ const packageJsonPath = join18(packageRoot, "package.json");
35792
+ let packageJson;
35793
+ try {
35794
+ packageJson = parseJson(packageJsonPath);
35795
+ } catch (error) {
35796
+ return {
35797
+ mode: "manifest",
35798
+ invalidReason: `invalid Deepline package metadata: ${error.message}`,
35799
+ missing: existsSync14(packageJsonPath) ? [] : ["deepline/package.json"]
35800
+ };
35801
+ }
35802
+ if (!packageJson || typeof packageJson !== "object" || Array.isArray(packageJson)) {
35803
+ return {
35804
+ mode: "manifest",
35805
+ invalidReason: "invalid Deepline package metadata: expected an object"
35806
+ };
35807
+ }
35808
+ const metadata = packageJson;
35809
+ if (metadata.deepline !== void 0 && (!metadata.deepline || typeof metadata.deepline !== "object" || Array.isArray(metadata.deepline))) {
35810
+ return {
35811
+ mode: "manifest",
35812
+ invalidReason: "invalid Deepline package metadata: deepline must be an object"
35813
+ };
35814
+ }
35815
+ const declaration = metadata.deepline?.installIntegrity;
35816
+ if (!declaration) {
35817
+ return {
35818
+ mode: "legacy",
35819
+ manifest: {
35820
+ schemaVersion: 1,
35821
+ packageFiles: [...SDK_SIDECAR_CRITICAL_PACKAGE_FILES],
35822
+ dependencyFiles: [...SDK_SIDECAR_CRITICAL_DEPENDENCY_FILES]
35823
+ }
35824
+ };
35825
+ }
35826
+ if (declaration.schemaVersion !== 1 || !safeRelativePath(declaration.manifest)) {
35827
+ return {
35828
+ mode: "manifest",
35829
+ invalidReason: "invalid Deepline install-integrity declaration"
35830
+ };
35831
+ }
35832
+ const manifestPath = resolveContainedPath(packageRoot, declaration.manifest);
35833
+ if (!manifestPath || !isFile(manifestPath)) {
35834
+ return {
35835
+ mode: "manifest",
35836
+ invalidReason: "declared Deepline install-integrity manifest is missing",
35837
+ missing: [String(declaration.manifest)]
35838
+ };
35839
+ }
35840
+ let raw;
35841
+ try {
35842
+ raw = parseJson(manifestPath);
35843
+ } catch (error) {
35844
+ return {
35845
+ mode: "manifest",
35846
+ invalidReason: `invalid Deepline install-integrity manifest: ${error.message}`
35847
+ };
35848
+ }
35849
+ if (!raw || typeof raw !== "object" || raw.schemaVersion !== 1 || !Array.isArray(raw.packageFiles) || !Array.isArray(raw.dependencyFiles)) {
35850
+ return {
35851
+ mode: "manifest",
35852
+ invalidReason: "invalid Deepline install-integrity manifest schema"
35853
+ };
35854
+ }
35855
+ const manifest = raw;
35856
+ if (manifest.packageFiles.length === 0 || manifest.dependencyFiles.length === 0 || !manifest.packageFiles.every(safeRelativePath) || !manifest.dependencyFiles.every(safeRelativePath)) {
35857
+ return {
35858
+ mode: "manifest",
35859
+ invalidReason: "unsafe path in Deepline install-integrity manifest"
35860
+ };
35861
+ }
35862
+ return { mode: "manifest", manifest };
35863
+ }
35864
+ function inspectSdkSidecarInstall(versionDir) {
35865
+ const nodeModulesRoot = join18(versionDir, "node_modules");
35866
+ const packageRoot = join18(nodeModulesRoot, "deepline");
35867
+ const manifestResult = readManifest(packageRoot);
35868
+ if ("invalidReason" in manifestResult) {
35869
+ return {
35870
+ ok: false,
35871
+ missing: manifestResult.missing ?? [],
35872
+ invalidReason: manifestResult.invalidReason,
35873
+ mode: manifestResult.mode
35874
+ };
35875
+ }
35876
+ const missing = [
35877
+ ...manifestResult.manifest.packageFiles.filter((path) => !isFile(join18(packageRoot, path))).map((path) => `deepline/${path}`),
35878
+ ...manifestResult.manifest.dependencyFiles.filter((path) => !isFile(join18(nodeModulesRoot, path))).map((path) => `node_modules/${path}`)
35879
+ ];
35880
+ return {
35881
+ ok: missing.length === 0,
35882
+ missing,
35883
+ invalidReason: null,
35884
+ mode: manifestResult.mode
35885
+ };
35886
+ }
35887
+ function probeSdkSidecarEsbuild(versionDir) {
35888
+ try {
35889
+ const requireFromInstall = createRequire(join18(versionDir, "package.json"));
35890
+ const esbuild = requireFromInstall("esbuild");
35891
+ if (typeof esbuild.transformSync !== "function") {
35892
+ return "esbuild does not export transformSync";
35893
+ }
35894
+ const result = esbuild.transformSync("const value: number = 1;", {
35895
+ loader: "ts"
35896
+ });
35897
+ if (typeof result?.code !== "string") {
35898
+ return "esbuild transform probe returned no code";
35899
+ }
35900
+ return null;
35901
+ } catch (error) {
35902
+ return error instanceof Error ? error.message : String(error);
35903
+ }
35904
+ }
35905
+
35772
35906
  // src/cli/commands/update.ts
35773
35907
  var NPM_SDK_INSTALL_COMMON_FLAGS = [
35774
35908
  "--no-audit",
@@ -35824,7 +35958,7 @@ function sidecarStateDir(input2) {
35824
35958
  if (!scope || scope.includes("/") || scope.includes("\\")) {
35825
35959
  return null;
35826
35960
  }
35827
- return join18(input2.homeDir, ".local", "deepline", scope, "sdk-cli");
35961
+ return join19(input2.homeDir, ".local", "deepline", scope, "sdk-cli");
35828
35962
  }
35829
35963
  function sidecarRegistryUrl(hostUrl) {
35830
35964
  let url;
@@ -35851,7 +35985,7 @@ function publicNpmFallbackRegistryUrl(hostUrl) {
35851
35985
  }
35852
35986
  function readOptionalText(path) {
35853
35987
  try {
35854
- return readFileSync14(path, "utf8").trim();
35988
+ return readFileSync15(path, "utf8").trim();
35855
35989
  } catch {
35856
35990
  return "";
35857
35991
  }
@@ -35859,19 +35993,19 @@ function readOptionalText(path) {
35859
35993
  function resolvePythonSidecarUpdatePlan(options) {
35860
35994
  const stateDir = sidecarStateDir(options);
35861
35995
  if (!stateDir) return null;
35862
- const relativeEntrypoint = relative4(
35863
- resolve16(stateDir),
35864
- resolve16(options.entrypoint)
35996
+ const relativeEntrypoint = relative5(
35997
+ resolve17(stateDir),
35998
+ resolve17(options.entrypoint)
35865
35999
  );
35866
- if (!relativeEntrypoint || relativeEntrypoint.startsWith("..") || isAbsolute5(relativeEntrypoint)) {
36000
+ if (!relativeEntrypoint || relativeEntrypoint.startsWith("..") || isAbsolute6(relativeEntrypoint)) {
35867
36001
  return null;
35868
36002
  }
35869
- const installMethod = readOptionalText(join18(stateDir, ".install-method"));
36003
+ const installMethod = readOptionalText(join19(stateDir, ".install-method"));
35870
36004
  if (installMethod !== "python-sidecar") return null;
35871
36005
  const scope = options.env.DEEPLINE_CONFIG_SCOPE?.trim() || "";
35872
36006
  const hostUrl = options.env.DEEPLINE_HOST_URL?.trim() || "";
35873
- const nodeBin = readOptionalText(join18(stateDir, ".node-bin")) || process.execPath;
35874
- const sidecarPath = readOptionalText(join18(stateDir, ".command-path")) || join18(
36007
+ const nodeBin = readOptionalText(join19(stateDir, ".node-bin")) || process.execPath;
36008
+ const sidecarPath = readOptionalText(join19(stateDir, ".command-path")) || join19(
35875
36009
  stateDir,
35876
36010
  "bin",
35877
36011
  process.platform === "win32" ? "deepline-sdk.cmd" : "deepline-sdk"
@@ -35879,7 +36013,7 @@ function resolvePythonSidecarUpdatePlan(options) {
35879
36013
  const packageSpec = options.packageSpec || "deepline@latest";
35880
36014
  const npmCommand = "npm";
35881
36015
  const registryUrl = sidecarRegistryUrl(hostUrl);
35882
- const versionDir = join18(stateDir, "versions", "<version>");
36016
+ const versionDir = join19(stateDir, "versions", "<version>");
35883
36017
  const manualCommand = `${buildSidecarProjectConfigCommand(versionDir, nodeBin)} && ${npmCommand} install --prefix ${shellQuote4(versionDir)} --registry ${shellQuote4(registryUrl)} ${NPM_SDK_INSTALL_COMMON_FLAGS.map(shellQuote4).join(" ")} ${shellQuote4(packageSpec)}`;
35884
36018
  return {
35885
36019
  kind: "python-sidecar",
@@ -35895,9 +36029,9 @@ function resolvePythonSidecarUpdatePlan(options) {
35895
36029
  };
35896
36030
  }
35897
36031
  function findRepoBackedSdkRoot(startPath) {
35898
- let current = resolve16(startPath);
36032
+ let current = resolve17(startPath);
35899
36033
  while (true) {
35900
- if (existsSync14(join18(current, "sdk", "package.json")) && existsSync14(join18(current, "sdk", "bin", "deepline-dev.ts"))) {
36034
+ if (existsSync15(join19(current, "sdk", "package.json")) && existsSync15(join19(current, "sdk", "bin", "deepline-dev.ts"))) {
35901
36035
  return current;
35902
36036
  }
35903
36037
  const parent = dirname16(current);
@@ -35910,7 +36044,7 @@ function inferNpmGlobalPrefixFromEntrypoint(entrypoint) {
35910
36044
  try {
35911
36045
  return realpathSync3(entrypoint);
35912
36046
  } catch {
35913
- return resolve16(entrypoint);
36047
+ return resolve17(entrypoint);
35914
36048
  }
35915
36049
  })();
35916
36050
  const parts = normalized.split(/[\\/]+/);
@@ -35931,7 +36065,7 @@ function isHomebrewFormulaEntrypoint(entrypoint) {
35931
36065
  try {
35932
36066
  return realpathSync3(entrypoint);
35933
36067
  } catch {
35934
- return resolve16(entrypoint);
36068
+ return resolve17(entrypoint);
35935
36069
  }
35936
36070
  })();
35937
36071
  const parts = normalized.split(/[\\/]+/);
@@ -35941,7 +36075,7 @@ function isHomebrewFormulaEntrypoint(entrypoint) {
35941
36075
  function resolveUpdatePlan(options = {}) {
35942
36076
  const env = options.env ?? process.env;
35943
36077
  const homeDir2 = options.homeDir ?? homedir12();
35944
- const entrypoint = options.entrypoint ?? (process.argv[1] ? resolve16(process.argv[1]) : "");
36078
+ const entrypoint = options.entrypoint ?? (process.argv[1] ? resolve17(process.argv[1]) : "");
35945
36079
  const sourceRoot = entrypoint ? findRepoBackedSdkRoot(dirname16(entrypoint)) : null;
35946
36080
  if (sourceRoot) {
35947
36081
  return {
@@ -35989,9 +36123,9 @@ var AUTO_UPDATE_FAILURE_FILE = ".auto-update-failure.json";
35989
36123
  function autoUpdateFailurePath(plan) {
35990
36124
  if (plan.kind === "source" || plan.kind === "homebrew") return null;
35991
36125
  if (plan.kind === "python-sidecar") {
35992
- return join18(plan.stateDir, AUTO_UPDATE_FAILURE_FILE);
36126
+ return join19(plan.stateDir, AUTO_UPDATE_FAILURE_FILE);
35993
36127
  }
35994
- return join18(
36128
+ return join19(
35995
36129
  homedir12(),
35996
36130
  ".local",
35997
36131
  "deepline",
@@ -36009,7 +36143,7 @@ function readAutoUpdateFailure(plan) {
36009
36143
  if (!path) return null;
36010
36144
  try {
36011
36145
  const parsed = JSON.parse(
36012
- readFileSync14(path, "utf8")
36146
+ readFileSync15(path, "utf8")
36013
36147
  );
36014
36148
  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") {
36015
36149
  return parsed;
@@ -36078,7 +36212,7 @@ function safeVersionSegment(value) {
36078
36212
  return /^[0-9A-Za-z._-]+$/.test(normalized) ? normalized : "";
36079
36213
  }
36080
36214
  function entryPathInVersionDir(versionDir) {
36081
- return join18(
36215
+ return join19(
36082
36216
  versionDir,
36083
36217
  "node_modules",
36084
36218
  "deepline",
@@ -36088,19 +36222,36 @@ function entryPathInVersionDir(versionDir) {
36088
36222
  );
36089
36223
  }
36090
36224
  function installedPackageVersion(versionDir) {
36091
- const packageJsonPath = join18(
36225
+ const packageJsonPath = join19(
36092
36226
  versionDir,
36093
36227
  "node_modules",
36094
36228
  "deepline",
36095
36229
  "package.json"
36096
36230
  );
36097
36231
  try {
36098
- const parsed = JSON.parse(readFileSync14(packageJsonPath, "utf8"));
36232
+ const parsed = JSON.parse(readFileSync15(packageJsonPath, "utf8"));
36099
36233
  return typeof parsed.version === "string" ? safeVersionSegment(parsed.version) : "";
36100
36234
  } catch {
36101
36235
  return "";
36102
36236
  }
36103
36237
  }
36238
+ function sidecarStructureFailure(versionDir) {
36239
+ const health = inspectSdkSidecarInstall(versionDir);
36240
+ if (!health.ok) {
36241
+ const details = [
36242
+ ...health.invalidReason ? [health.invalidReason] : [],
36243
+ ...health.missing.length > 0 ? [`missing ${health.missing.join(", ")}`] : []
36244
+ ].join("; ");
36245
+ return details || "required SDK CLI files are missing";
36246
+ }
36247
+ return null;
36248
+ }
36249
+ function sidecarInstallFailure(versionDir) {
36250
+ const structureFailure = sidecarStructureFailure(versionDir);
36251
+ if (structureFailure) return structureFailure;
36252
+ const esbuildFailure = probeSdkSidecarEsbuild(versionDir);
36253
+ return esbuildFailure ? `esbuild probe failed: ${esbuildFailure}` : null;
36254
+ }
36104
36255
  function runCommand(command, args, env = process.env) {
36105
36256
  return new Promise((resolveResult) => {
36106
36257
  let output2 = "";
@@ -36173,13 +36324,35 @@ async function runNpmInstallWithRegistryFallback(input2) {
36173
36324
  }
36174
36325
  function writeSidecarLauncher(input2) {
36175
36326
  mkdirSync10(dirname16(input2.path), { recursive: true });
36327
+ const packageRoot = dirname16(dirname16(dirname16(input2.entryPath)));
36328
+ const versionDir = dirname16(dirname16(packageRoot));
36329
+ 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);";
36330
+ const criticalPaths = [
36331
+ ...SDK_SIDECAR_CRITICAL_PACKAGE_FILES.map(
36332
+ (path) => join19(packageRoot, path)
36333
+ ),
36334
+ ...SDK_SIDECAR_CRITICAL_DEPENDENCY_FILES.map(
36335
+ (path) => join19(versionDir, "node_modules", path)
36336
+ )
36337
+ ];
36176
36338
  if (process.platform === "win32") {
36177
36339
  writeFileSync15(
36178
36340
  input2.path,
36179
36341
  [
36180
36342
  `@set DEEPLINE_HOST_URL=${input2.hostUrl.replace(/\r?\n/g, "")}`,
36181
36343
  `@set DEEPLINE_CONFIG_SCOPE=${input2.scope.replace(/\r?\n/g, "")}`,
36344
+ ...criticalPaths.map(
36345
+ (path) => `@if not exist "${path}" goto repair_sdk`
36346
+ ),
36347
+ `@"${input2.nodeBin}" -e "${esbuildProbe}" "${versionDir}" >NUL 2>&1`,
36348
+ "@if errorlevel 1 goto repair_sdk",
36182
36349
  `@"${input2.nodeBin}" "${input2.entryPath}" %*`,
36350
+ "@exit /b %ERRORLEVEL%",
36351
+ ":repair_sdk",
36352
+ '@if defined DEEPLINE_REAL_BINARY "%DEEPLINE_REAL_BINARY%" --version=v2 %*',
36353
+ "@if defined DEEPLINE_REAL_BINARY exit /b %ERRORLEVEL%",
36354
+ "@echo Deepline SDK CLI install is incomplete. Run `deepline update` to repair it. 1>&2",
36355
+ "@exit /b 1",
36183
36356
  ""
36184
36357
  ].join("\r\n"),
36185
36358
  "utf8"
@@ -36192,6 +36365,20 @@ function writeSidecarLauncher(input2) {
36192
36365
  "#!/usr/bin/env sh",
36193
36366
  `export DEEPLINE_HOST_URL=${shellQuote4(input2.hostUrl)}`,
36194
36367
  `export DEEPLINE_CONFIG_SCOPE=${shellQuote4(input2.scope)}`,
36368
+ `if ${criticalPaths.map((path) => `[ ! -f ${shellQuote4(path)} ]`).join(" || ")}; then`,
36369
+ ' if [ -n "${DEEPLINE_REAL_BINARY:-}" ] && [ -x "$DEEPLINE_REAL_BINARY" ]; then',
36370
+ ' exec "$DEEPLINE_REAL_BINARY" --version=v2 "$@"',
36371
+ " fi",
36372
+ ' printf "%s\\n" "Deepline SDK CLI install is incomplete. Run \\`deepline update\\` to repair it." >&2',
36373
+ " exit 1",
36374
+ "fi",
36375
+ `if ! ${shellQuote4(input2.nodeBin)} -e ${shellQuote4(esbuildProbe)} ${shellQuote4(versionDir)} >/dev/null 2>&1; then`,
36376
+ ' if [ -n "${DEEPLINE_REAL_BINARY:-}" ] && [ -x "$DEEPLINE_REAL_BINARY" ]; then',
36377
+ ' exec "$DEEPLINE_REAL_BINARY" --version=v2 "$@"',
36378
+ " fi",
36379
+ ' printf "%s\\n" "Deepline SDK CLI install is incomplete. Run \\`deepline update\\` to repair it." >&2',
36380
+ " exit 1",
36381
+ "fi",
36195
36382
  `exec ${shellQuote4(input2.nodeBin)} ${shellQuote4(input2.entryPath)} "$@"`,
36196
36383
  ""
36197
36384
  ].join("\n"),
@@ -36199,14 +36386,14 @@ function writeSidecarLauncher(input2) {
36199
36386
  );
36200
36387
  }
36201
36388
  async function runPythonSidecarUpdatePlan(plan) {
36202
- const versionsDir = join18(plan.stateDir, "versions");
36203
- const tempDir = join18(
36389
+ const versionsDir = join19(plan.stateDir, "versions");
36390
+ const tempDir = join19(
36204
36391
  versionsDir,
36205
36392
  `.tmp-sdk-update-${process.pid}-${Date.now()}`
36206
36393
  );
36207
36394
  rmSync4(tempDir, { recursive: true, force: true });
36208
36395
  mkdirSync10(tempDir, { recursive: true });
36209
- writeFileSync15(join18(tempDir, "package.json"), NPM_SDK_SIDECAR_PACKAGE_JSON);
36396
+ writeFileSync15(join19(tempDir, "package.json"), NPM_SDK_SIDECAR_PACKAGE_JSON);
36210
36397
  const env = {
36211
36398
  ...process.env,
36212
36399
  PATH: `${dirname16(plan.nodeBin)}${process.platform === "win32" ? ";" : ":"}${process.env.PATH ?? ""}`
@@ -36237,30 +36424,91 @@ async function runPythonSidecarUpdatePlan(plan) {
36237
36424
  rmSync4(tempDir, { recursive: true, force: true });
36238
36425
  return 1;
36239
36426
  }
36240
- const finalDir = join18(versionsDir, installedVersion);
36427
+ const stagedFailure = sidecarInstallFailure(tempDir);
36428
+ if (stagedFailure) {
36429
+ process.stderr.write(
36430
+ `Updated Deepline SDK package is incomplete: ${stagedFailure}.
36431
+ `
36432
+ );
36433
+ rmSync4(tempDir, { recursive: true, force: true });
36434
+ return 1;
36435
+ }
36436
+ const finalDir = join19(versionsDir, installedVersion);
36241
36437
  const finalEntryPath = entryPathInVersionDir(finalDir);
36242
- if (existsSync14(finalEntryPath)) {
36438
+ const finalFailure = sidecarInstallFailure(finalDir);
36439
+ let backupDir = null;
36440
+ if (!finalFailure) {
36243
36441
  rmSync4(tempDir, { recursive: true, force: true });
36244
36442
  } else {
36245
- rmSync4(finalDir, { recursive: true, force: true });
36246
- try {
36247
- renameSync(tempDir, finalDir);
36248
- } catch (error) {
36249
- rmSync4(tempDir, { recursive: true, force: true });
36250
- process.stderr.write(
36251
- `Failed to publish Deepline SDK sidecar update: ${error.message}
36252
- `
36443
+ let shouldPublishTemp = true;
36444
+ if (existsSync15(finalDir)) {
36445
+ backupDir = join19(
36446
+ versionsDir,
36447
+ `.backup-${installedVersion}-${process.pid}-${Date.now()}`
36253
36448
  );
36254
- return 1;
36449
+ try {
36450
+ renameSync(finalDir, backupDir);
36451
+ } catch (error) {
36452
+ const concurrentlyPublishedFailure = sidecarInstallFailure(finalDir);
36453
+ if (!concurrentlyPublishedFailure) {
36454
+ rmSync4(tempDir, { recursive: true, force: true });
36455
+ backupDir = null;
36456
+ shouldPublishTemp = false;
36457
+ } else {
36458
+ rmSync4(tempDir, { recursive: true, force: true });
36459
+ process.stderr.write(
36460
+ `Failed to preserve the incomplete Deepline SDK sidecar before repair: ${error.message}.
36461
+ `
36462
+ );
36463
+ return 1;
36464
+ }
36465
+ }
36466
+ }
36467
+ if (shouldPublishTemp) {
36468
+ try {
36469
+ renameSync(tempDir, finalDir);
36470
+ } catch (error) {
36471
+ rmSync4(tempDir, { recursive: true, force: true });
36472
+ const concurrentlyPublishedFailure = sidecarInstallFailure(finalDir);
36473
+ if (!concurrentlyPublishedFailure) {
36474
+ if (backupDir) rmSync4(backupDir, { recursive: true, force: true });
36475
+ backupDir = null;
36476
+ } else {
36477
+ let restoreFailure = "";
36478
+ if (backupDir && existsSync15(backupDir) && !existsSync15(finalDir)) {
36479
+ try {
36480
+ renameSync(backupDir, finalDir);
36481
+ backupDir = null;
36482
+ } catch (restoreError) {
36483
+ restoreFailure = `; failed to restore previous install: ${restoreError.message}`;
36484
+ }
36485
+ }
36486
+ process.stderr.write(
36487
+ `Failed to publish Deepline SDK sidecar update: ${error.message}; current install remains incomplete: ${concurrentlyPublishedFailure}${restoreFailure}.
36488
+ `
36489
+ );
36490
+ return 1;
36491
+ }
36492
+ }
36255
36493
  }
36256
36494
  }
36257
- if (!existsSync14(finalEntryPath)) {
36495
+ const publishedFailure = sidecarStructureFailure(finalDir);
36496
+ if (publishedFailure) {
36497
+ if (backupDir && existsSync15(backupDir)) {
36498
+ rmSync4(finalDir, { recursive: true, force: true });
36499
+ try {
36500
+ renameSync(backupDir, finalDir);
36501
+ backupDir = null;
36502
+ } catch {
36503
+ }
36504
+ }
36258
36505
  process.stderr.write(
36259
- `Updated Deepline SDK CLI entrypoint missing: ${finalEntryPath}
36506
+ `Updated Deepline SDK CLI install is incomplete: ${publishedFailure}.
36260
36507
  `
36261
36508
  );
36262
36509
  return 1;
36263
36510
  }
36511
+ if (backupDir) rmSync4(backupDir, { recursive: true, force: true });
36264
36512
  writeSidecarLauncher({
36265
36513
  path: plan.sidecarPath,
36266
36514
  hostUrl: plan.hostUrl,
@@ -36269,27 +36517,27 @@ async function runPythonSidecarUpdatePlan(plan) {
36269
36517
  entryPath: finalEntryPath
36270
36518
  });
36271
36519
  writeFileSync15(
36272
- join18(plan.stateDir, ".version"),
36520
+ join19(plan.stateDir, ".version"),
36273
36521
  `${installedVersion}
36274
36522
  `,
36275
36523
  "utf8"
36276
36524
  );
36277
36525
  writeFileSync15(
36278
- join18(plan.stateDir, ".install-method"),
36526
+ join19(plan.stateDir, ".install-method"),
36279
36527
  "python-sidecar\n",
36280
36528
  "utf8"
36281
36529
  );
36282
36530
  writeFileSync15(
36283
- join18(plan.stateDir, ".command-path"),
36531
+ join19(plan.stateDir, ".command-path"),
36284
36532
  `${plan.sidecarPath}
36285
36533
  `,
36286
36534
  "utf8"
36287
36535
  );
36288
- writeFileSync15(join18(plan.stateDir, ".runner"), "node\n", "utf8");
36289
- writeFileSync15(join18(plan.stateDir, ".node-bin"), `${plan.nodeBin}
36536
+ writeFileSync15(join19(plan.stateDir, ".runner"), "node\n", "utf8");
36537
+ writeFileSync15(join19(plan.stateDir, ".node-bin"), `${plan.nodeBin}
36290
36538
  `, "utf8");
36291
36539
  writeFileSync15(
36292
- join18(plan.stateDir, ".entry-path"),
36540
+ join19(plan.stateDir, ".entry-path"),
36293
36541
  `${finalEntryPath}
36294
36542
  `,
36295
36543
  "utf8"
@@ -36413,16 +36661,16 @@ Examples:
36413
36661
  // src/cli/commands/setup.ts
36414
36662
  import { spawnSync } from "child_process";
36415
36663
  import {
36416
- existsSync as existsSync15,
36664
+ existsSync as existsSync16,
36417
36665
  lstatSync,
36418
36666
  mkdirSync as mkdirSync11,
36419
- readFileSync as readFileSync15,
36667
+ readFileSync as readFileSync16,
36420
36668
  realpathSync as realpathSync4,
36421
36669
  rmSync as rmSync5,
36422
36670
  writeFileSync as writeFileSync16
36423
36671
  } from "fs";
36424
36672
  import { homedir as homedir13 } from "os";
36425
- import { dirname as dirname17, join as join19, resolve as resolve17 } from "path";
36673
+ import { dirname as dirname17, join as join20, resolve as resolve18 } from "path";
36426
36674
  var SETUP_PHASE_NAMES = [
36427
36675
  "cli",
36428
36676
  "cleanup",
@@ -36479,7 +36727,7 @@ function phasesFromLegacyStatus(status) {
36479
36727
  function readSetupState(input2) {
36480
36728
  try {
36481
36729
  const parsed = JSON.parse(
36482
- readFileSync15(
36730
+ readFileSync16(
36483
36731
  setupStatePath(input2.baseUrl, input2.scope, input2.root),
36484
36732
  "utf8"
36485
36733
  )
@@ -36555,7 +36803,7 @@ function buildPendingAuthorizationOutput(input2) {
36555
36803
  };
36556
36804
  }
36557
36805
  function setupStatePath(baseUrl, scope, root) {
36558
- return scope === "local" && root ? join19(root, ".deepline", "setup", "state.json") : join19(sdkCliStateDirPath(baseUrl), "setup.json");
36806
+ return scope === "local" && root ? join20(root, ".deepline", "setup", "state.json") : join20(sdkCliStateDirPath(baseUrl), "setup.json");
36559
36807
  }
36560
36808
  async function captureStdout2(run) {
36561
36809
  let stdout = "";
@@ -36584,14 +36832,14 @@ function asRecord3(value) {
36584
36832
  }
36585
36833
  function safeRead(path) {
36586
36834
  try {
36587
- return readFileSync15(path, "utf8");
36835
+ return readFileSync16(path, "utf8");
36588
36836
  } catch {
36589
36837
  return "";
36590
36838
  }
36591
36839
  }
36592
36840
  function isNpmManagedDeeplinePath(path) {
36593
36841
  try {
36594
- return realpathSync4(path).includes(`${join19("node_modules", "deepline")}`);
36842
+ return realpathSync4(path).includes(`${join20("node_modules", "deepline")}`);
36595
36843
  } catch {
36596
36844
  return false;
36597
36845
  }
@@ -36602,28 +36850,28 @@ function isInstallerManagedLegacyLauncher(path) {
36602
36850
  }
36603
36851
  function removeKnownLegacyPaths(baseUrl) {
36604
36852
  const home = homedir13();
36605
- const hostDir = join19(home, ".local", "deepline", baseUrlSlug(baseUrl));
36606
- const legacyLauncherPath = join19(home, ".local", "bin", "deepline");
36853
+ const hostDir = join20(home, ".local", "deepline", baseUrlSlug(baseUrl));
36854
+ const legacyLauncherPath = join20(home, ".local", "bin", "deepline");
36607
36855
  const installerCommandPath = safeRead(
36608
- join19(hostDir, "sdk", ".command-path")
36856
+ join20(hostDir, "sdk", ".command-path")
36609
36857
  ).trim();
36610
36858
  const candidates = [
36611
36859
  ...isInstallerManagedLegacyLauncher(legacyLauncherPath) ? [legacyLauncherPath] : [],
36612
- join19(home, ".local", "bin", "deepline-real"),
36613
- join19(hostDir, "bin", "deepline"),
36614
- join19(hostDir, "bin", "deepline-real"),
36615
- join19(hostDir, "cli", ".install-method"),
36616
- join19(hostDir, "cli", ".version"),
36617
- join19(hostDir, "sdk", ".install-method"),
36618
- join19(hostDir, "sdk", ".command-path"),
36860
+ join20(home, ".local", "bin", "deepline-real"),
36861
+ join20(hostDir, "bin", "deepline"),
36862
+ join20(hostDir, "bin", "deepline-real"),
36863
+ join20(hostDir, "cli", ".install-method"),
36864
+ join20(hostDir, "cli", ".version"),
36865
+ join20(hostDir, "sdk", ".install-method"),
36866
+ join20(hostDir, "sdk", ".command-path"),
36619
36867
  ...installerCommandPath ? [
36620
36868
  installerCommandPath,
36621
- join19(dirname17(installerCommandPath), "deepline-sdk")
36869
+ join20(dirname17(installerCommandPath), "deepline-sdk")
36622
36870
  ] : []
36623
36871
  ];
36624
36872
  const removed = [];
36625
36873
  for (const path of candidates) {
36626
- if (!existsSync15(path)) continue;
36874
+ if (!existsSync16(path)) continue;
36627
36875
  if (path === installerCommandPath && isNpmManagedDeeplinePath(path)) {
36628
36876
  continue;
36629
36877
  }
@@ -36640,7 +36888,7 @@ function resolvePathCommands(command) {
36640
36888
  );
36641
36889
  return [
36642
36890
  ...new Set(
36643
- String(lookup.stdout ?? "").split(/\r?\n/).map((line) => line.trim()).filter(Boolean).map((path) => resolve17(path))
36891
+ String(lookup.stdout ?? "").split(/\r?\n/).map((line) => line.trim()).filter(Boolean).map((path) => resolve18(path))
36644
36892
  )
36645
36893
  ];
36646
36894
  }
@@ -36661,7 +36909,7 @@ function isHomebrewFormulaCommand(path) {
36661
36909
  function resolvePersistentGlobalCommand(dependencies = {}) {
36662
36910
  const platform3 = dependencies.platform ?? process.platform;
36663
36911
  const run = dependencies.spawn ?? spawnSync;
36664
- const pathExists = dependencies.exists ?? existsSync15;
36912
+ const pathExists = dependencies.exists ?? existsSync16;
36665
36913
  const pathClis = dependencies.pathClis ?? resolvePathCommands("deepline");
36666
36914
  const homebrewCommand = pathClis.find(isHomebrewFormulaCommand);
36667
36915
  if (homebrewCommand) return homebrewCommand;
@@ -36673,7 +36921,7 @@ function resolvePersistentGlobalCommand(dependencies = {}) {
36673
36921
  if (prefix.status !== 0) return null;
36674
36922
  const root = String(prefix.stdout ?? "").trim();
36675
36923
  if (!root) return null;
36676
- const candidates = platform3 === "win32" ? [join19(root, "deepline.cmd"), join19(root, "deepline")] : [join19(root, "bin", "deepline")];
36924
+ const candidates = platform3 === "win32" ? [join20(root, "deepline.cmd"), join20(root, "deepline")] : [join20(root, "bin", "deepline")];
36677
36925
  return candidates.find((candidate) => pathExists(candidate)) ?? null;
36678
36926
  }
36679
36927
  function inspectGlobalCliAvailability(input2) {
@@ -36688,18 +36936,18 @@ function pathsResolveToSameFile(left, right) {
36688
36936
  try {
36689
36937
  return realpathSync4(left) === realpathSync4(right);
36690
36938
  } catch {
36691
- return resolve17(left) === resolve17(right);
36939
+ return resolve18(left) === resolve18(right);
36692
36940
  }
36693
36941
  }
36694
36942
  function isKnownDeeplineCommand(path) {
36695
- const entrypoint = process.argv[1] ? resolve17(process.argv[1]) : "";
36943
+ const entrypoint = process.argv[1] ? resolve18(process.argv[1]) : "";
36696
36944
  let resolvedPath = path;
36697
36945
  try {
36698
36946
  resolvedPath = realpathSync4(path);
36699
36947
  } catch {
36700
36948
  }
36701
36949
  if (entrypoint && resolvedPath === entrypoint) return true;
36702
- if (resolvedPath.includes(`${join19("node_modules", "deepline")}`)) return true;
36950
+ if (resolvedPath.includes(`${join20("node_modules", "deepline")}`)) return true;
36703
36951
  const content = safeRead(path);
36704
36952
  return content.includes("node_modules/deepline") || content.includes("node_modules\\deepline") || content.includes("DEEPLINE_CONFIG_SCOPE") || content.includes("deepline-real");
36705
36953
  }
@@ -36709,7 +36957,7 @@ function inspectPathConflict() {
36709
36957
  try {
36710
36958
  if (lstatSync(commandPath).isSymbolicLink()) {
36711
36959
  const target = realpathSync4(commandPath);
36712
- if (target.includes(`${join19("node_modules", "deepline")}`)) return null;
36960
+ if (target.includes(`${join20("node_modules", "deepline")}`)) return null;
36713
36961
  }
36714
36962
  } catch {
36715
36963
  }
@@ -36758,7 +37006,7 @@ function failSetupPhase(phases, phase, code) {
36758
37006
  phases[phase] = { status: "failed", code };
36759
37007
  }
36760
37008
  function rollbackCommand(scope, root) {
36761
- const prefix = scope === "local" && root ? ` --prefix ${JSON.stringify(join19(root, ".deepline", "runtime"))}` : "";
37009
+ const prefix = scope === "local" && root ? ` --prefix ${JSON.stringify(join20(root, ".deepline", "runtime"))}` : "";
36762
37010
  return `npm install -g${prefix} --no-audit --no-fund --include=optional --allow-scripts=esbuild deepline@${SDK_VERSION}`;
36763
37011
  }
36764
37012
  function setupResumeCommand(baseUrl, scope) {
@@ -36845,12 +37093,12 @@ function buildDoctorAssessment(input2) {
36845
37093
  const connected = input2.authStatus.payload?.connected === true;
36846
37094
  const authScopeOk = input2.scope === "local" ? Boolean(projectAuth) : Boolean(apiKey && !projectAuth);
36847
37095
  const skillsOk = skillsState?.scope === input2.scope && typeof skillsState.skillsVersion === "string" && Array.isArray(skillsState.agents) && skillsState.agents.length > 0;
36848
- const runningCliPath = process.argv[1] ? resolve17(process.argv[1]) : null;
37096
+ const runningCliPath = process.argv[1] ? resolve18(process.argv[1]) : null;
36849
37097
  const globalCli = input2.scope === "global" ? inspectGlobalCliAvailability() : null;
36850
37098
  const pathGlobalCli = globalCli?.path ?? null;
36851
37099
  const cliPath = input2.scope === "global" ? pathGlobalCli : runningCliPath;
36852
37100
  const cliScopeOk = input2.scope === "global" ? Boolean(pathGlobalCli) : Boolean(
36853
- input2.root && runningCliPath?.includes(join19(input2.root, ".deepline", "runtime"))
37101
+ input2.root && runningCliPath?.includes(join20(input2.root, ".deepline", "runtime"))
36854
37102
  );
36855
37103
  const checks = {
36856
37104
  cli: {
@@ -37496,7 +37744,7 @@ function isDowngradeAutoUpdateResponse(response) {
37496
37744
  return compareSemver(target, current) < 0;
37497
37745
  }
37498
37746
  function relaunchCurrentCommand(plan) {
37499
- return new Promise((resolve18) => {
37747
+ return new Promise((resolve19) => {
37500
37748
  const command = plan.kind === "python-sidecar" ? plan.sidecarPath : process.execPath;
37501
37749
  const args = plan.kind === "python-sidecar" ? process.argv.slice(2) : process.argv.slice(1);
37502
37750
  const child = spawn4(command, args, {
@@ -37512,9 +37760,9 @@ function relaunchCurrentCommand(plan) {
37512
37760
  `Deepline SDK/CLI updated, but relaunch failed: ${error.message}
37513
37761
  `
37514
37762
  );
37515
- resolve18(1);
37763
+ resolve19(1);
37516
37764
  });
37517
- child.on("close", (code) => resolve18(code ?? 1));
37765
+ child.on("close", (code) => resolve19(code ?? 1));
37518
37766
  });
37519
37767
  }
37520
37768
  async function maybeAutoUpdateAndRelaunch(response) {
@@ -37566,13 +37814,13 @@ async function maybeAutoUpdateAndRelaunch(response) {
37566
37814
  // src/cli/skills-sync.ts
37567
37815
  import { spawn as spawn5, spawnSync as spawnSync2 } from "child_process";
37568
37816
  import {
37569
- existsSync as existsSync16,
37817
+ existsSync as existsSync17,
37570
37818
  mkdirSync as mkdirSync12,
37571
- readFileSync as readFileSync16,
37819
+ readFileSync as readFileSync17,
37572
37820
  unlinkSync as unlinkSync2,
37573
37821
  writeFileSync as writeFileSync17
37574
37822
  } from "fs";
37575
- import { dirname as dirname18, join as join20 } from "path";
37823
+ import { dirname as dirname18, join as join21 } from "path";
37576
37824
  var CHECK_TIMEOUT_MS2 = 3e3;
37577
37825
  var attemptedSync = false;
37578
37826
  function shouldSkipSkillsSync() {
@@ -37588,33 +37836,33 @@ function activePluginSkillsDir() {
37588
37836
  return "";
37589
37837
  }
37590
37838
  const dir = process.env.DEEPLINE_PLUGIN_SKILLS_DIR?.trim() ?? "";
37591
- return dir && existsSync16(dir) ? dir : "";
37839
+ return dir && existsSync17(dir) ? dir : "";
37592
37840
  }
37593
37841
  function readPluginSkillsVersion() {
37594
37842
  const dir = activePluginSkillsDir();
37595
37843
  if (!dir) return "";
37596
37844
  try {
37597
- return readFileSync16(join20(dir, ".version"), "utf-8").trim();
37845
+ return readFileSync17(join21(dir, ".version"), "utf-8").trim();
37598
37846
  } catch {
37599
37847
  return "";
37600
37848
  }
37601
37849
  }
37602
37850
  function sdkSkillsVersionPath(baseUrl) {
37603
- return join20(sdkCliStateDirPath(baseUrl), "skills-version");
37851
+ return join21(sdkCliStateDirPath(baseUrl), "skills-version");
37604
37852
  }
37605
37853
  function legacySdkSkillsVersionPath(baseUrl) {
37606
- return join20(dirname18(sdkCliStateDirPath(baseUrl)), "sdk-skills", ".version");
37854
+ return join21(dirname18(sdkCliStateDirPath(baseUrl)), "sdk-skills", ".version");
37607
37855
  }
37608
37856
  function unavailableSkillsNoticePath(baseUrl) {
37609
- return join20(sdkCliStateDirPath(baseUrl), "skills-sync-unavailable-version");
37857
+ return join21(sdkCliStateDirPath(baseUrl), "skills-sync-unavailable-version");
37610
37858
  }
37611
37859
  function readSdkSkillsLocalVersion(baseUrl) {
37612
37860
  const pluginVersion = readPluginSkillsVersion();
37613
37861
  if (pluginVersion) return pluginVersion;
37614
- const path = existsSync16(sdkSkillsVersionPath(baseUrl)) ? sdkSkillsVersionPath(baseUrl) : legacySdkSkillsVersionPath(baseUrl);
37615
- if (!existsSync16(path)) return "";
37862
+ const path = existsSync17(sdkSkillsVersionPath(baseUrl)) ? sdkSkillsVersionPath(baseUrl) : legacySdkSkillsVersionPath(baseUrl);
37863
+ if (!existsSync17(path)) return "";
37616
37864
  try {
37617
- return readFileSync16(path, "utf-8").trim();
37865
+ return readFileSync17(path, "utf-8").trim();
37618
37866
  } catch {
37619
37867
  return "";
37620
37868
  }
@@ -37628,7 +37876,7 @@ function writeLocalSkillsVersion(baseUrl, version) {
37628
37876
  function writeUnavailableSkillsNotice(baseUrl, remoteVersion, skillNames) {
37629
37877
  const path = unavailableSkillsNoticePath(baseUrl);
37630
37878
  try {
37631
- if (existsSync16(path) && readFileSync16(path, "utf-8").trim() === remoteVersion) {
37879
+ if (existsSync17(path) && readFileSync17(path, "utf-8").trim() === remoteVersion) {
37632
37880
  return;
37633
37881
  }
37634
37882
  mkdirSync12(dirname18(path), { recursive: true });
@@ -37766,7 +38014,7 @@ function resolveSkillsInstallCommands(baseUrl, skillNames = DEFAULT_SDK_SKILL_NA
37766
38014
  return commands;
37767
38015
  }
37768
38016
  function runOneSkillsInstall(install) {
37769
- return new Promise((resolve18) => {
38017
+ return new Promise((resolve19) => {
37770
38018
  const plan = resolveSkillsInstallSpawn(install);
37771
38019
  const child = spawn5(plan.command, plan.args, {
37772
38020
  stdio: ["ignore", "ignore", "pipe"],
@@ -37778,7 +38026,7 @@ function runOneSkillsInstall(install) {
37778
38026
  stderr += chunk.toString("utf-8");
37779
38027
  });
37780
38028
  child.on("error", (error) => {
37781
- resolve18({
38029
+ resolve19({
37782
38030
  ok: false,
37783
38031
  detail: `failed to start ${install.command}: ${error.message}`,
37784
38032
  manualCommand: install.manualCommand
@@ -37786,11 +38034,11 @@ function runOneSkillsInstall(install) {
37786
38034
  });
37787
38035
  child.on("close", (code) => {
37788
38036
  if (code === 0) {
37789
- resolve18({ ok: true, detail: "", manualCommand: install.manualCommand });
38037
+ resolve19({ ok: true, detail: "", manualCommand: install.manualCommand });
37790
38038
  return;
37791
38039
  }
37792
38040
  const detail = stderr.trim();
37793
- resolve18({
38041
+ resolve19({
37794
38042
  ok: false,
37795
38043
  detail: detail ? `${install.command}: ${detail}` : `${install.command} exited ${code}`,
37796
38044
  manualCommand: install.manualCommand
@@ -38218,8 +38466,8 @@ function topLevelCommandKnown(program, commandName) {
38218
38466
  );
38219
38467
  }
38220
38468
  async function runPlayRunnerHealthCheck() {
38221
- const dir = await mkdtemp2(join21(tmpdir6(), "deepline-health-play-"));
38222
- const file = join21(dir, "health-check.play.ts");
38469
+ const dir = await mkdtemp2(join22(tmpdir6(), "deepline-health-play-"));
38470
+ const file = join22(dir, "health-check.play.ts");
38223
38471
  try {
38224
38472
  await writeFile6(
38225
38473
  file,