deepline 0.2.20 → 0.2.22

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.20",
1033
+ version: "0.2.22",
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") {
@@ -3761,6 +3761,8 @@ var DeeplineClient = class {
3761
3761
  list: (options2) => this.listRuns(options2),
3762
3762
  tail: (runId, options2) => this.tailRun(runId, options2),
3763
3763
  logs: (runId, options2) => this.getRunLogs(runId, options2),
3764
+ input: (runId) => this.getRunInput(runId),
3765
+ rerun: (runId) => this.rerun(runId),
3764
3766
  exportDatasetRows: (input2) => this.getPlaySheetRows(input2),
3765
3767
  stop: (runId, options2) => this.stopRun(runId, options2),
3766
3768
  stopAll: (options2) => this.stopAllRuns(options2)
@@ -5165,6 +5167,17 @@ var DeeplineClient = class {
5165
5167
  await sleep2(delayMs);
5166
5168
  }
5167
5169
  }
5170
+ /** Get the exact original input retained for a run. This is intentionally separate from status. */
5171
+ async getRunInput(runId) {
5172
+ return this.http.get(`/api/v2/runs/${encodeURIComponent(runId)}/input`);
5173
+ }
5174
+ /** Start a fresh run from a prior run's retained input and pinned revision. */
5175
+ async rerun(runId) {
5176
+ return this.http.post(
5177
+ `/api/v2/runs/${encodeURIComponent(runId)}/rerun`,
5178
+ {}
5179
+ );
5180
+ }
5168
5181
  /**
5169
5182
  * Fetch persisted logs for a run using the public runs resource model.
5170
5183
  *
@@ -6963,7 +6976,7 @@ function buildCandidateUrls2(url) {
6963
6976
  }
6964
6977
  }
6965
6978
  function sleep4(ms) {
6966
- return new Promise((resolve18) => setTimeout(resolve18, ms));
6979
+ return new Promise((resolve19) => setTimeout(resolve19, ms));
6967
6980
  }
6968
6981
  function printDeeplineLogo() {
6969
6982
  if (process.stdout.isTTY && (process.stdout.columns ?? 80) >= 70) {
@@ -17102,7 +17115,7 @@ function traceCliSync(phase, fields, run) {
17102
17115
  }
17103
17116
  }
17104
17117
  function sleep5(ms) {
17105
- return new Promise((resolve18) => setTimeout(resolve18, ms));
17118
+ return new Promise((resolve19) => setTimeout(resolve19, ms));
17106
17119
  }
17107
17120
  function parseReferencedPlayTarget2(target) {
17108
17121
  const trimmed = target.trim();
@@ -21886,7 +21899,7 @@ async function handlePlayRun(args, hooks) {
21886
21899
  function parseRunIdPositional(args, usage) {
21887
21900
  for (let index = 0; index < args.length; index += 1) {
21888
21901
  const arg = args[index];
21889
- if (arg === "--json" || arg === "--full" || arg === "--logs" || arg === "--compact" || arg === "--log-failed" || arg === "--failed" || arg === "--limit") {
21902
+ if (arg === "--json" || arg === "--full" || arg === "--input" || arg === "--logs" || arg === "--compact" || arg === "--log-failed" || arg === "--failed" || arg === "--limit") {
21890
21903
  if (arg === "--limit" && args[index + 1]) {
21891
21904
  index += 1;
21892
21905
  }
@@ -21903,7 +21916,7 @@ function parseRunIdPositional(args, usage) {
21903
21916
  throw new DeeplineError(usage);
21904
21917
  }
21905
21918
  async function handleRunGet(args) {
21906
- const usage = "Usage: deepline runs get <run-id> [--json] [--full] [--log-failed]";
21919
+ const usage = "Usage: deepline runs get <run-id> [--json] [--full] [--input] [--log-failed]";
21907
21920
  let runId;
21908
21921
  try {
21909
21922
  runId = parseRunIdPositional(args, usage);
@@ -21912,6 +21925,11 @@ async function handleRunGet(args) {
21912
21925
  return 1;
21913
21926
  }
21914
21927
  const client2 = new DeeplineClient();
21928
+ if (args.includes("--input")) {
21929
+ const input2 = await client2.getRunInput(runId);
21930
+ printCommandEnvelope(input2, { json: true });
21931
+ return 0;
21932
+ }
21915
21933
  const status = await client2.runs.get(runId, {
21916
21934
  full: args.includes("--full"),
21917
21935
  failedLogs: args.includes("--log-failed")
@@ -21921,6 +21939,29 @@ async function handleRunGet(args) {
21921
21939
  });
21922
21940
  return 0;
21923
21941
  }
21942
+ async function handleRunsRerun(args) {
21943
+ const usage = "Usage: deepline runs rerun <run-id> [--json]";
21944
+ let runId;
21945
+ try {
21946
+ runId = parseRunIdPositional(args, usage);
21947
+ } catch (error) {
21948
+ console.error(error instanceof Error ? error.message : usage);
21949
+ return 1;
21950
+ }
21951
+ const result = await new DeeplineClient().runs.rerun(runId);
21952
+ if (argsWantJson(args)) {
21953
+ printCommandEnvelope(result, { json: true });
21954
+ } else {
21955
+ console.log(`
21956
+ Rerun started from ${runId}.`);
21957
+ console.log(` inspect: deepline runs get ${result.runId} --json`);
21958
+ console.log(` original input: deepline runs get ${result.runId} --input`);
21959
+ console.log(
21960
+ " This is a fresh run using the original input and pinned revision. Normal tool receipt reuse still applies."
21961
+ );
21962
+ }
21963
+ return 0;
21964
+ }
21924
21965
  async function handleRunsList(args) {
21925
21966
  const usage = "Usage: deepline runs list [--play <play-name>] [--status <status>] [--limit <count>] [--offset <count>] [--json]";
21926
21967
  let playName = null;
@@ -23499,14 +23540,20 @@ Examples:
23499
23540
  `
23500
23541
  Notes:
23501
23542
  Full run status read. Use --full --json when debugging raw stream/status fields.
23543
+ Use --input only when you intentionally need the original payload; it can
23544
+ contain customer data and is never included in ordinary status output.
23502
23545
 
23503
23546
  Examples:
23504
23547
  deepline runs get play/my-play/run/20260501t000000-000
23505
23548
  deepline runs get play/my-play/run/20260501t000000-000 --json
23506
23549
  deepline runs get play/my-play/run/20260501t000000-000 --log-failed --json
23507
23550
  deepline runs get play/my-play/run/20260501t000000-000 --full --json
23551
+ deepline runs get play/my-play/run/20260501t000000-000 --input
23508
23552
  `
23509
23553
  ).option("--json", "Emit JSON output. Also automatic when stdout is piped").option("--full", "Debug only: with --json, emit the raw status payload").option(
23554
+ "--input",
23555
+ "Explicitly print the original retained input JSON (may contain customer data)"
23556
+ ).option(
23510
23557
  "--log-failed",
23511
23558
  "Attach a bounded terminal-failure log window for failed runs"
23512
23559
  ).action(async (runId, options) => {
@@ -23514,9 +23561,30 @@ Examples:
23514
23561
  runId,
23515
23562
  ...options.json ? ["--json"] : [],
23516
23563
  ...options.full ? ["--full"] : [],
23564
+ ...options.input ? ["--input"] : [],
23517
23565
  ...options.logFailed ? ["--log-failed"] : []
23518
23566
  ]);
23519
23567
  });
23568
+ runs.command("rerun <runId>").description(
23569
+ "Start a fresh run from a prior run's retained input and pinned revision."
23570
+ ).addHelpText(
23571
+ "after",
23572
+ `
23573
+ Notes:
23574
+ Creates a new run. It never mutates the original run.
23575
+ The rerun uses the original input and exact saved revision. Normal completed
23576
+ tool receipts may be reused; inspect the new run before forcing any external
23577
+ side effect.
23578
+
23579
+ Examples:
23580
+ deepline runs rerun play/my-play/webhook/abc --json
23581
+ `
23582
+ ).option("--json", "Emit JSON output. Also automatic when stdout is piped").action(async (runId, options) => {
23583
+ process.exitCode = await handleRunsRerun([
23584
+ runId,
23585
+ ...options.json ? ["--json"] : []
23586
+ ]);
23587
+ });
23520
23588
  runs.command("list").description("List play runs.").addHelpText(
23521
23589
  "after",
23522
23590
  `
@@ -25565,7 +25633,7 @@ function emitEnrichDebug(message) {
25565
25633
  );
25566
25634
  }
25567
25635
  function sleep6(ms) {
25568
- return new Promise((resolve18) => setTimeout(resolve18, ms));
25636
+ return new Promise((resolve19) => setTimeout(resolve19, ms));
25569
25637
  }
25570
25638
  function enrichExportBackingRowsWaitMs() {
25571
25639
  const raw = process.env.DEEPLINE_ENRICH_EXPORT_BACKING_ROWS_WAIT_MS?.trim();
@@ -31737,7 +31805,7 @@ async function readHiddenLine(prompt, streams = {}) {
31737
31805
  }
31738
31806
  let value = "";
31739
31807
  inputStream.resume();
31740
- return await new Promise((resolve18, reject) => {
31808
+ return await new Promise((resolve19, reject) => {
31741
31809
  let settled = false;
31742
31810
  const cleanup = () => {
31743
31811
  inputStream.off("data", onData);
@@ -31755,7 +31823,7 @@ async function readHiddenLine(prompt, streams = {}) {
31755
31823
  settled = true;
31756
31824
  outputStream.write("\n");
31757
31825
  cleanup();
31758
- resolve18(line);
31826
+ resolve19(line);
31759
31827
  };
31760
31828
  const fail = (error) => {
31761
31829
  if (settled) return;
@@ -35216,17 +35284,17 @@ Notes:
35216
35284
  // src/cli/commands/update.ts
35217
35285
  import { spawn as spawn3 } from "child_process";
35218
35286
  import {
35219
- existsSync as existsSync14,
35287
+ existsSync as existsSync15,
35220
35288
  mkdirSync as mkdirSync10,
35221
35289
  realpathSync as realpathSync3,
35222
- readFileSync as readFileSync14,
35290
+ readFileSync as readFileSync15,
35223
35291
  renameSync,
35224
35292
  rmSync as rmSync4,
35225
35293
  unlinkSync,
35226
35294
  writeFileSync as writeFileSync15
35227
35295
  } from "fs";
35228
35296
  import { homedir as homedir12 } from "os";
35229
- import { dirname as dirname16, isAbsolute as isAbsolute5, join as join18, relative as relative4, resolve as resolve16 } from "path";
35297
+ import { dirname as dirname16, isAbsolute as isAbsolute6, join as join19, relative as relative5, resolve as resolve17 } from "path";
35230
35298
 
35231
35299
  // src/cli/commands/skills.ts
35232
35300
  import { spawn as spawn2 } from "child_process";
@@ -35530,7 +35598,7 @@ function readSkillsInstallState(path) {
35530
35598
  }
35531
35599
  }
35532
35600
  function runProcess(command, args, cwd) {
35533
- return new Promise((resolve18, reject) => {
35601
+ return new Promise((resolve19, reject) => {
35534
35602
  const plan = resolveShellSpawn(command, args);
35535
35603
  const child = spawn2(plan.command, plan.args, {
35536
35604
  cwd,
@@ -35549,7 +35617,7 @@ function runProcess(command, args, cwd) {
35549
35617
  process.stderr.write(`skills@latest exited ${code}.
35550
35618
  `);
35551
35619
  }
35552
- resolve18(code ?? 1);
35620
+ resolve19(code ?? 1);
35553
35621
  });
35554
35622
  });
35555
35623
  }
@@ -35743,6 +35811,166 @@ Examples:
35743
35811
  });
35744
35812
  }
35745
35813
 
35814
+ // src/cli/install-integrity.ts
35815
+ import { createRequire } from "module";
35816
+ import { existsSync as existsSync14, readFileSync as readFileSync14, statSync as statSync5 } from "fs";
35817
+ import { isAbsolute as isAbsolute5, join as join18, relative as relative4, resolve as resolve16 } from "path";
35818
+ var SDK_SIDECAR_CRITICAL_PACKAGE_FILES = [
35819
+ "dist/cli/index.mjs",
35820
+ "dist/index.mjs",
35821
+ "dist/index.d.ts",
35822
+ "dist/plays/bundle-play-file.mjs",
35823
+ "dist/bundling-sources/shared_libs/observability/telemetry.ts",
35824
+ "dist/bundling-sources/shared_libs/play-runtime/backend.ts",
35825
+ "dist/bundling-sources/shared_libs/plays/bundling/index.ts",
35826
+ "dist/bundling-sources/shared_libs/tool-execution-error.ts"
35827
+ ];
35828
+ var SDK_SIDECAR_CRITICAL_DEPENDENCY_FILES = [
35829
+ "esbuild/package.json",
35830
+ "esbuild/lib/main.js"
35831
+ ];
35832
+ function safeRelativePath(value) {
35833
+ if (typeof value !== "string" || !value || isAbsolute5(value)) return false;
35834
+ const segments = value.split(/[\\/]+/);
35835
+ return segments.every(
35836
+ (segment) => Boolean(segment) && segment !== "." && segment !== ".."
35837
+ );
35838
+ }
35839
+ function resolveContainedPath(root, value) {
35840
+ if (!safeRelativePath(value)) return null;
35841
+ const target = resolve16(root, value);
35842
+ const relativeTarget = relative4(resolve16(root), target);
35843
+ if (!relativeTarget || relativeTarget.startsWith("..") || isAbsolute5(relativeTarget)) {
35844
+ return null;
35845
+ }
35846
+ return target;
35847
+ }
35848
+ function parseJson(path) {
35849
+ return JSON.parse(readFileSync14(path, "utf8"));
35850
+ }
35851
+ function isFile(path) {
35852
+ try {
35853
+ return statSync5(path).isFile();
35854
+ } catch {
35855
+ return false;
35856
+ }
35857
+ }
35858
+ function readManifest(packageRoot) {
35859
+ const packageJsonPath = join18(packageRoot, "package.json");
35860
+ let packageJson;
35861
+ try {
35862
+ packageJson = parseJson(packageJsonPath);
35863
+ } catch (error) {
35864
+ return {
35865
+ mode: "manifest",
35866
+ invalidReason: `invalid Deepline package metadata: ${error.message}`,
35867
+ missing: existsSync14(packageJsonPath) ? [] : ["deepline/package.json"]
35868
+ };
35869
+ }
35870
+ if (!packageJson || typeof packageJson !== "object" || Array.isArray(packageJson)) {
35871
+ return {
35872
+ mode: "manifest",
35873
+ invalidReason: "invalid Deepline package metadata: expected an object"
35874
+ };
35875
+ }
35876
+ const metadata = packageJson;
35877
+ if (metadata.deepline !== void 0 && (!metadata.deepline || typeof metadata.deepline !== "object" || Array.isArray(metadata.deepline))) {
35878
+ return {
35879
+ mode: "manifest",
35880
+ invalidReason: "invalid Deepline package metadata: deepline must be an object"
35881
+ };
35882
+ }
35883
+ const declaration = metadata.deepline?.installIntegrity;
35884
+ if (!declaration) {
35885
+ return {
35886
+ mode: "legacy",
35887
+ manifest: {
35888
+ schemaVersion: 1,
35889
+ packageFiles: [...SDK_SIDECAR_CRITICAL_PACKAGE_FILES],
35890
+ dependencyFiles: [...SDK_SIDECAR_CRITICAL_DEPENDENCY_FILES]
35891
+ }
35892
+ };
35893
+ }
35894
+ if (declaration.schemaVersion !== 1 || !safeRelativePath(declaration.manifest)) {
35895
+ return {
35896
+ mode: "manifest",
35897
+ invalidReason: "invalid Deepline install-integrity declaration"
35898
+ };
35899
+ }
35900
+ const manifestPath = resolveContainedPath(packageRoot, declaration.manifest);
35901
+ if (!manifestPath || !isFile(manifestPath)) {
35902
+ return {
35903
+ mode: "manifest",
35904
+ invalidReason: "declared Deepline install-integrity manifest is missing",
35905
+ missing: [String(declaration.manifest)]
35906
+ };
35907
+ }
35908
+ let raw;
35909
+ try {
35910
+ raw = parseJson(manifestPath);
35911
+ } catch (error) {
35912
+ return {
35913
+ mode: "manifest",
35914
+ invalidReason: `invalid Deepline install-integrity manifest: ${error.message}`
35915
+ };
35916
+ }
35917
+ if (!raw || typeof raw !== "object" || raw.schemaVersion !== 1 || !Array.isArray(raw.packageFiles) || !Array.isArray(raw.dependencyFiles)) {
35918
+ return {
35919
+ mode: "manifest",
35920
+ invalidReason: "invalid Deepline install-integrity manifest schema"
35921
+ };
35922
+ }
35923
+ const manifest = raw;
35924
+ if (manifest.packageFiles.length === 0 || manifest.dependencyFiles.length === 0 || !manifest.packageFiles.every(safeRelativePath) || !manifest.dependencyFiles.every(safeRelativePath)) {
35925
+ return {
35926
+ mode: "manifest",
35927
+ invalidReason: "unsafe path in Deepline install-integrity manifest"
35928
+ };
35929
+ }
35930
+ return { mode: "manifest", manifest };
35931
+ }
35932
+ function inspectSdkSidecarInstall(versionDir) {
35933
+ const nodeModulesRoot = join18(versionDir, "node_modules");
35934
+ const packageRoot = join18(nodeModulesRoot, "deepline");
35935
+ const manifestResult = readManifest(packageRoot);
35936
+ if ("invalidReason" in manifestResult) {
35937
+ return {
35938
+ ok: false,
35939
+ missing: manifestResult.missing ?? [],
35940
+ invalidReason: manifestResult.invalidReason,
35941
+ mode: manifestResult.mode
35942
+ };
35943
+ }
35944
+ const missing = [
35945
+ ...manifestResult.manifest.packageFiles.filter((path) => !isFile(join18(packageRoot, path))).map((path) => `deepline/${path}`),
35946
+ ...manifestResult.manifest.dependencyFiles.filter((path) => !isFile(join18(nodeModulesRoot, path))).map((path) => `node_modules/${path}`)
35947
+ ];
35948
+ return {
35949
+ ok: missing.length === 0,
35950
+ missing,
35951
+ invalidReason: null,
35952
+ mode: manifestResult.mode
35953
+ };
35954
+ }
35955
+ function probeSdkSidecarEsbuild(versionDir) {
35956
+ try {
35957
+ const requireFromInstall = createRequire(join18(versionDir, "package.json"));
35958
+ const esbuild = requireFromInstall("esbuild");
35959
+ if (typeof esbuild.transformSync !== "function") {
35960
+ return "esbuild does not export transformSync";
35961
+ }
35962
+ const result = esbuild.transformSync("const value: number = 1;", {
35963
+ loader: "ts"
35964
+ });
35965
+ if (typeof result?.code !== "string") {
35966
+ return "esbuild transform probe returned no code";
35967
+ }
35968
+ return null;
35969
+ } catch (error) {
35970
+ return error instanceof Error ? error.message : String(error);
35971
+ }
35972
+ }
35973
+
35746
35974
  // src/cli/commands/update.ts
35747
35975
  var NPM_SDK_INSTALL_COMMON_FLAGS = [
35748
35976
  "--no-audit",
@@ -35798,7 +36026,7 @@ function sidecarStateDir(input2) {
35798
36026
  if (!scope || scope.includes("/") || scope.includes("\\")) {
35799
36027
  return null;
35800
36028
  }
35801
- return join18(input2.homeDir, ".local", "deepline", scope, "sdk-cli");
36029
+ return join19(input2.homeDir, ".local", "deepline", scope, "sdk-cli");
35802
36030
  }
35803
36031
  function sidecarRegistryUrl(hostUrl) {
35804
36032
  let url;
@@ -35825,7 +36053,7 @@ function publicNpmFallbackRegistryUrl(hostUrl) {
35825
36053
  }
35826
36054
  function readOptionalText(path) {
35827
36055
  try {
35828
- return readFileSync14(path, "utf8").trim();
36056
+ return readFileSync15(path, "utf8").trim();
35829
36057
  } catch {
35830
36058
  return "";
35831
36059
  }
@@ -35833,19 +36061,19 @@ function readOptionalText(path) {
35833
36061
  function resolvePythonSidecarUpdatePlan(options) {
35834
36062
  const stateDir = sidecarStateDir(options);
35835
36063
  if (!stateDir) return null;
35836
- const relativeEntrypoint = relative4(
35837
- resolve16(stateDir),
35838
- resolve16(options.entrypoint)
36064
+ const relativeEntrypoint = relative5(
36065
+ resolve17(stateDir),
36066
+ resolve17(options.entrypoint)
35839
36067
  );
35840
- if (!relativeEntrypoint || relativeEntrypoint.startsWith("..") || isAbsolute5(relativeEntrypoint)) {
36068
+ if (!relativeEntrypoint || relativeEntrypoint.startsWith("..") || isAbsolute6(relativeEntrypoint)) {
35841
36069
  return null;
35842
36070
  }
35843
- const installMethod = readOptionalText(join18(stateDir, ".install-method"));
36071
+ const installMethod = readOptionalText(join19(stateDir, ".install-method"));
35844
36072
  if (installMethod !== "python-sidecar") return null;
35845
36073
  const scope = options.env.DEEPLINE_CONFIG_SCOPE?.trim() || "";
35846
36074
  const hostUrl = options.env.DEEPLINE_HOST_URL?.trim() || "";
35847
- const nodeBin = readOptionalText(join18(stateDir, ".node-bin")) || process.execPath;
35848
- const sidecarPath = readOptionalText(join18(stateDir, ".command-path")) || join18(
36075
+ const nodeBin = readOptionalText(join19(stateDir, ".node-bin")) || process.execPath;
36076
+ const sidecarPath = readOptionalText(join19(stateDir, ".command-path")) || join19(
35849
36077
  stateDir,
35850
36078
  "bin",
35851
36079
  process.platform === "win32" ? "deepline-sdk.cmd" : "deepline-sdk"
@@ -35853,7 +36081,7 @@ function resolvePythonSidecarUpdatePlan(options) {
35853
36081
  const packageSpec = options.packageSpec || "deepline@latest";
35854
36082
  const npmCommand = "npm";
35855
36083
  const registryUrl = sidecarRegistryUrl(hostUrl);
35856
- const versionDir = join18(stateDir, "versions", "<version>");
36084
+ const versionDir = join19(stateDir, "versions", "<version>");
35857
36085
  const manualCommand = `${buildSidecarProjectConfigCommand(versionDir, nodeBin)} && ${npmCommand} install --prefix ${shellQuote4(versionDir)} --registry ${shellQuote4(registryUrl)} ${NPM_SDK_INSTALL_COMMON_FLAGS.map(shellQuote4).join(" ")} ${shellQuote4(packageSpec)}`;
35858
36086
  return {
35859
36087
  kind: "python-sidecar",
@@ -35869,9 +36097,9 @@ function resolvePythonSidecarUpdatePlan(options) {
35869
36097
  };
35870
36098
  }
35871
36099
  function findRepoBackedSdkRoot(startPath) {
35872
- let current = resolve16(startPath);
36100
+ let current = resolve17(startPath);
35873
36101
  while (true) {
35874
- if (existsSync14(join18(current, "sdk", "package.json")) && existsSync14(join18(current, "sdk", "bin", "deepline-dev.ts"))) {
36102
+ if (existsSync15(join19(current, "sdk", "package.json")) && existsSync15(join19(current, "sdk", "bin", "deepline-dev.ts"))) {
35875
36103
  return current;
35876
36104
  }
35877
36105
  const parent = dirname16(current);
@@ -35884,7 +36112,7 @@ function inferNpmGlobalPrefixFromEntrypoint(entrypoint) {
35884
36112
  try {
35885
36113
  return realpathSync3(entrypoint);
35886
36114
  } catch {
35887
- return resolve16(entrypoint);
36115
+ return resolve17(entrypoint);
35888
36116
  }
35889
36117
  })();
35890
36118
  const parts = normalized.split(/[\\/]+/);
@@ -35905,7 +36133,7 @@ function isHomebrewFormulaEntrypoint(entrypoint) {
35905
36133
  try {
35906
36134
  return realpathSync3(entrypoint);
35907
36135
  } catch {
35908
- return resolve16(entrypoint);
36136
+ return resolve17(entrypoint);
35909
36137
  }
35910
36138
  })();
35911
36139
  const parts = normalized.split(/[\\/]+/);
@@ -35915,7 +36143,7 @@ function isHomebrewFormulaEntrypoint(entrypoint) {
35915
36143
  function resolveUpdatePlan(options = {}) {
35916
36144
  const env = options.env ?? process.env;
35917
36145
  const homeDir2 = options.homeDir ?? homedir12();
35918
- const entrypoint = options.entrypoint ?? (process.argv[1] ? resolve16(process.argv[1]) : "");
36146
+ const entrypoint = options.entrypoint ?? (process.argv[1] ? resolve17(process.argv[1]) : "");
35919
36147
  const sourceRoot = entrypoint ? findRepoBackedSdkRoot(dirname16(entrypoint)) : null;
35920
36148
  if (sourceRoot) {
35921
36149
  return {
@@ -35963,9 +36191,9 @@ var AUTO_UPDATE_FAILURE_FILE = ".auto-update-failure.json";
35963
36191
  function autoUpdateFailurePath(plan) {
35964
36192
  if (plan.kind === "source" || plan.kind === "homebrew") return null;
35965
36193
  if (plan.kind === "python-sidecar") {
35966
- return join18(plan.stateDir, AUTO_UPDATE_FAILURE_FILE);
36194
+ return join19(plan.stateDir, AUTO_UPDATE_FAILURE_FILE);
35967
36195
  }
35968
- return join18(
36196
+ return join19(
35969
36197
  homedir12(),
35970
36198
  ".local",
35971
36199
  "deepline",
@@ -35983,7 +36211,7 @@ function readAutoUpdateFailure(plan) {
35983
36211
  if (!path) return null;
35984
36212
  try {
35985
36213
  const parsed = JSON.parse(
35986
- readFileSync14(path, "utf8")
36214
+ readFileSync15(path, "utf8")
35987
36215
  );
35988
36216
  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") {
35989
36217
  return parsed;
@@ -36052,7 +36280,7 @@ function safeVersionSegment(value) {
36052
36280
  return /^[0-9A-Za-z._-]+$/.test(normalized) ? normalized : "";
36053
36281
  }
36054
36282
  function entryPathInVersionDir(versionDir) {
36055
- return join18(
36283
+ return join19(
36056
36284
  versionDir,
36057
36285
  "node_modules",
36058
36286
  "deepline",
@@ -36062,19 +36290,36 @@ function entryPathInVersionDir(versionDir) {
36062
36290
  );
36063
36291
  }
36064
36292
  function installedPackageVersion(versionDir) {
36065
- const packageJsonPath = join18(
36293
+ const packageJsonPath = join19(
36066
36294
  versionDir,
36067
36295
  "node_modules",
36068
36296
  "deepline",
36069
36297
  "package.json"
36070
36298
  );
36071
36299
  try {
36072
- const parsed = JSON.parse(readFileSync14(packageJsonPath, "utf8"));
36300
+ const parsed = JSON.parse(readFileSync15(packageJsonPath, "utf8"));
36073
36301
  return typeof parsed.version === "string" ? safeVersionSegment(parsed.version) : "";
36074
36302
  } catch {
36075
36303
  return "";
36076
36304
  }
36077
36305
  }
36306
+ function sidecarStructureFailure(versionDir) {
36307
+ const health = inspectSdkSidecarInstall(versionDir);
36308
+ if (!health.ok) {
36309
+ const details = [
36310
+ ...health.invalidReason ? [health.invalidReason] : [],
36311
+ ...health.missing.length > 0 ? [`missing ${health.missing.join(", ")}`] : []
36312
+ ].join("; ");
36313
+ return details || "required SDK CLI files are missing";
36314
+ }
36315
+ return null;
36316
+ }
36317
+ function sidecarInstallFailure(versionDir) {
36318
+ const structureFailure = sidecarStructureFailure(versionDir);
36319
+ if (structureFailure) return structureFailure;
36320
+ const esbuildFailure = probeSdkSidecarEsbuild(versionDir);
36321
+ return esbuildFailure ? `esbuild probe failed: ${esbuildFailure}` : null;
36322
+ }
36078
36323
  function runCommand(command, args, env = process.env) {
36079
36324
  return new Promise((resolveResult) => {
36080
36325
  let output2 = "";
@@ -36147,13 +36392,35 @@ async function runNpmInstallWithRegistryFallback(input2) {
36147
36392
  }
36148
36393
  function writeSidecarLauncher(input2) {
36149
36394
  mkdirSync10(dirname16(input2.path), { recursive: true });
36395
+ const packageRoot = dirname16(dirname16(dirname16(input2.entryPath)));
36396
+ const versionDir = dirname16(dirname16(packageRoot));
36397
+ 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);";
36398
+ const criticalPaths = [
36399
+ ...SDK_SIDECAR_CRITICAL_PACKAGE_FILES.map(
36400
+ (path) => join19(packageRoot, path)
36401
+ ),
36402
+ ...SDK_SIDECAR_CRITICAL_DEPENDENCY_FILES.map(
36403
+ (path) => join19(versionDir, "node_modules", path)
36404
+ )
36405
+ ];
36150
36406
  if (process.platform === "win32") {
36151
36407
  writeFileSync15(
36152
36408
  input2.path,
36153
36409
  [
36154
36410
  `@set DEEPLINE_HOST_URL=${input2.hostUrl.replace(/\r?\n/g, "")}`,
36155
36411
  `@set DEEPLINE_CONFIG_SCOPE=${input2.scope.replace(/\r?\n/g, "")}`,
36412
+ ...criticalPaths.map(
36413
+ (path) => `@if not exist "${path}" goto repair_sdk`
36414
+ ),
36415
+ `@"${input2.nodeBin}" -e "${esbuildProbe}" "${versionDir}" >NUL 2>&1`,
36416
+ "@if errorlevel 1 goto repair_sdk",
36156
36417
  `@"${input2.nodeBin}" "${input2.entryPath}" %*`,
36418
+ "@exit /b %ERRORLEVEL%",
36419
+ ":repair_sdk",
36420
+ '@if defined DEEPLINE_REAL_BINARY "%DEEPLINE_REAL_BINARY%" --version=v2 %*',
36421
+ "@if defined DEEPLINE_REAL_BINARY exit /b %ERRORLEVEL%",
36422
+ "@echo Deepline SDK CLI install is incomplete. Run `deepline update` to repair it. 1>&2",
36423
+ "@exit /b 1",
36157
36424
  ""
36158
36425
  ].join("\r\n"),
36159
36426
  "utf8"
@@ -36166,6 +36433,20 @@ function writeSidecarLauncher(input2) {
36166
36433
  "#!/usr/bin/env sh",
36167
36434
  `export DEEPLINE_HOST_URL=${shellQuote4(input2.hostUrl)}`,
36168
36435
  `export DEEPLINE_CONFIG_SCOPE=${shellQuote4(input2.scope)}`,
36436
+ `if ${criticalPaths.map((path) => `[ ! -f ${shellQuote4(path)} ]`).join(" || ")}; then`,
36437
+ ' if [ -n "${DEEPLINE_REAL_BINARY:-}" ] && [ -x "$DEEPLINE_REAL_BINARY" ]; then',
36438
+ ' exec "$DEEPLINE_REAL_BINARY" --version=v2 "$@"',
36439
+ " fi",
36440
+ ' printf "%s\\n" "Deepline SDK CLI install is incomplete. Run \\`deepline update\\` to repair it." >&2',
36441
+ " exit 1",
36442
+ "fi",
36443
+ `if ! ${shellQuote4(input2.nodeBin)} -e ${shellQuote4(esbuildProbe)} ${shellQuote4(versionDir)} >/dev/null 2>&1; then`,
36444
+ ' if [ -n "${DEEPLINE_REAL_BINARY:-}" ] && [ -x "$DEEPLINE_REAL_BINARY" ]; then',
36445
+ ' exec "$DEEPLINE_REAL_BINARY" --version=v2 "$@"',
36446
+ " fi",
36447
+ ' printf "%s\\n" "Deepline SDK CLI install is incomplete. Run \\`deepline update\\` to repair it." >&2',
36448
+ " exit 1",
36449
+ "fi",
36169
36450
  `exec ${shellQuote4(input2.nodeBin)} ${shellQuote4(input2.entryPath)} "$@"`,
36170
36451
  ""
36171
36452
  ].join("\n"),
@@ -36173,14 +36454,14 @@ function writeSidecarLauncher(input2) {
36173
36454
  );
36174
36455
  }
36175
36456
  async function runPythonSidecarUpdatePlan(plan) {
36176
- const versionsDir = join18(plan.stateDir, "versions");
36177
- const tempDir = join18(
36457
+ const versionsDir = join19(plan.stateDir, "versions");
36458
+ const tempDir = join19(
36178
36459
  versionsDir,
36179
36460
  `.tmp-sdk-update-${process.pid}-${Date.now()}`
36180
36461
  );
36181
36462
  rmSync4(tempDir, { recursive: true, force: true });
36182
36463
  mkdirSync10(tempDir, { recursive: true });
36183
- writeFileSync15(join18(tempDir, "package.json"), NPM_SDK_SIDECAR_PACKAGE_JSON);
36464
+ writeFileSync15(join19(tempDir, "package.json"), NPM_SDK_SIDECAR_PACKAGE_JSON);
36184
36465
  const env = {
36185
36466
  ...process.env,
36186
36467
  PATH: `${dirname16(plan.nodeBin)}${process.platform === "win32" ? ";" : ":"}${process.env.PATH ?? ""}`
@@ -36211,30 +36492,91 @@ async function runPythonSidecarUpdatePlan(plan) {
36211
36492
  rmSync4(tempDir, { recursive: true, force: true });
36212
36493
  return 1;
36213
36494
  }
36214
- const finalDir = join18(versionsDir, installedVersion);
36495
+ const stagedFailure = sidecarInstallFailure(tempDir);
36496
+ if (stagedFailure) {
36497
+ process.stderr.write(
36498
+ `Updated Deepline SDK package is incomplete: ${stagedFailure}.
36499
+ `
36500
+ );
36501
+ rmSync4(tempDir, { recursive: true, force: true });
36502
+ return 1;
36503
+ }
36504
+ const finalDir = join19(versionsDir, installedVersion);
36215
36505
  const finalEntryPath = entryPathInVersionDir(finalDir);
36216
- if (existsSync14(finalEntryPath)) {
36506
+ const finalFailure = sidecarInstallFailure(finalDir);
36507
+ let backupDir = null;
36508
+ if (!finalFailure) {
36217
36509
  rmSync4(tempDir, { recursive: true, force: true });
36218
36510
  } else {
36219
- rmSync4(finalDir, { recursive: true, force: true });
36220
- try {
36221
- renameSync(tempDir, finalDir);
36222
- } catch (error) {
36223
- rmSync4(tempDir, { recursive: true, force: true });
36224
- process.stderr.write(
36225
- `Failed to publish Deepline SDK sidecar update: ${error.message}
36226
- `
36511
+ let shouldPublishTemp = true;
36512
+ if (existsSync15(finalDir)) {
36513
+ backupDir = join19(
36514
+ versionsDir,
36515
+ `.backup-${installedVersion}-${process.pid}-${Date.now()}`
36227
36516
  );
36228
- return 1;
36517
+ try {
36518
+ renameSync(finalDir, backupDir);
36519
+ } catch (error) {
36520
+ const concurrentlyPublishedFailure = sidecarInstallFailure(finalDir);
36521
+ if (!concurrentlyPublishedFailure) {
36522
+ rmSync4(tempDir, { recursive: true, force: true });
36523
+ backupDir = null;
36524
+ shouldPublishTemp = false;
36525
+ } else {
36526
+ rmSync4(tempDir, { recursive: true, force: true });
36527
+ process.stderr.write(
36528
+ `Failed to preserve the incomplete Deepline SDK sidecar before repair: ${error.message}.
36529
+ `
36530
+ );
36531
+ return 1;
36532
+ }
36533
+ }
36534
+ }
36535
+ if (shouldPublishTemp) {
36536
+ try {
36537
+ renameSync(tempDir, finalDir);
36538
+ } catch (error) {
36539
+ rmSync4(tempDir, { recursive: true, force: true });
36540
+ const concurrentlyPublishedFailure = sidecarInstallFailure(finalDir);
36541
+ if (!concurrentlyPublishedFailure) {
36542
+ if (backupDir) rmSync4(backupDir, { recursive: true, force: true });
36543
+ backupDir = null;
36544
+ } else {
36545
+ let restoreFailure = "";
36546
+ if (backupDir && existsSync15(backupDir) && !existsSync15(finalDir)) {
36547
+ try {
36548
+ renameSync(backupDir, finalDir);
36549
+ backupDir = null;
36550
+ } catch (restoreError) {
36551
+ restoreFailure = `; failed to restore previous install: ${restoreError.message}`;
36552
+ }
36553
+ }
36554
+ process.stderr.write(
36555
+ `Failed to publish Deepline SDK sidecar update: ${error.message}; current install remains incomplete: ${concurrentlyPublishedFailure}${restoreFailure}.
36556
+ `
36557
+ );
36558
+ return 1;
36559
+ }
36560
+ }
36229
36561
  }
36230
36562
  }
36231
- if (!existsSync14(finalEntryPath)) {
36563
+ const publishedFailure = sidecarStructureFailure(finalDir);
36564
+ if (publishedFailure) {
36565
+ if (backupDir && existsSync15(backupDir)) {
36566
+ rmSync4(finalDir, { recursive: true, force: true });
36567
+ try {
36568
+ renameSync(backupDir, finalDir);
36569
+ backupDir = null;
36570
+ } catch {
36571
+ }
36572
+ }
36232
36573
  process.stderr.write(
36233
- `Updated Deepline SDK CLI entrypoint missing: ${finalEntryPath}
36574
+ `Updated Deepline SDK CLI install is incomplete: ${publishedFailure}.
36234
36575
  `
36235
36576
  );
36236
36577
  return 1;
36237
36578
  }
36579
+ if (backupDir) rmSync4(backupDir, { recursive: true, force: true });
36238
36580
  writeSidecarLauncher({
36239
36581
  path: plan.sidecarPath,
36240
36582
  hostUrl: plan.hostUrl,
@@ -36243,27 +36585,27 @@ async function runPythonSidecarUpdatePlan(plan) {
36243
36585
  entryPath: finalEntryPath
36244
36586
  });
36245
36587
  writeFileSync15(
36246
- join18(plan.stateDir, ".version"),
36588
+ join19(plan.stateDir, ".version"),
36247
36589
  `${installedVersion}
36248
36590
  `,
36249
36591
  "utf8"
36250
36592
  );
36251
36593
  writeFileSync15(
36252
- join18(plan.stateDir, ".install-method"),
36594
+ join19(plan.stateDir, ".install-method"),
36253
36595
  "python-sidecar\n",
36254
36596
  "utf8"
36255
36597
  );
36256
36598
  writeFileSync15(
36257
- join18(plan.stateDir, ".command-path"),
36599
+ join19(plan.stateDir, ".command-path"),
36258
36600
  `${plan.sidecarPath}
36259
36601
  `,
36260
36602
  "utf8"
36261
36603
  );
36262
- writeFileSync15(join18(plan.stateDir, ".runner"), "node\n", "utf8");
36263
- writeFileSync15(join18(plan.stateDir, ".node-bin"), `${plan.nodeBin}
36604
+ writeFileSync15(join19(plan.stateDir, ".runner"), "node\n", "utf8");
36605
+ writeFileSync15(join19(plan.stateDir, ".node-bin"), `${plan.nodeBin}
36264
36606
  `, "utf8");
36265
36607
  writeFileSync15(
36266
- join18(plan.stateDir, ".entry-path"),
36608
+ join19(plan.stateDir, ".entry-path"),
36267
36609
  `${finalEntryPath}
36268
36610
  `,
36269
36611
  "utf8"
@@ -36387,16 +36729,16 @@ Examples:
36387
36729
  // src/cli/commands/setup.ts
36388
36730
  import { spawnSync } from "child_process";
36389
36731
  import {
36390
- existsSync as existsSync15,
36732
+ existsSync as existsSync16,
36391
36733
  lstatSync,
36392
36734
  mkdirSync as mkdirSync11,
36393
- readFileSync as readFileSync15,
36735
+ readFileSync as readFileSync16,
36394
36736
  realpathSync as realpathSync4,
36395
36737
  rmSync as rmSync5,
36396
36738
  writeFileSync as writeFileSync16
36397
36739
  } from "fs";
36398
36740
  import { homedir as homedir13 } from "os";
36399
- import { dirname as dirname17, join as join19, resolve as resolve17 } from "path";
36741
+ import { dirname as dirname17, join as join20, resolve as resolve18 } from "path";
36400
36742
  var SETUP_PHASE_NAMES = [
36401
36743
  "cli",
36402
36744
  "cleanup",
@@ -36453,7 +36795,7 @@ function phasesFromLegacyStatus(status) {
36453
36795
  function readSetupState(input2) {
36454
36796
  try {
36455
36797
  const parsed = JSON.parse(
36456
- readFileSync15(
36798
+ readFileSync16(
36457
36799
  setupStatePath(input2.baseUrl, input2.scope, input2.root),
36458
36800
  "utf8"
36459
36801
  )
@@ -36529,7 +36871,7 @@ function buildPendingAuthorizationOutput(input2) {
36529
36871
  };
36530
36872
  }
36531
36873
  function setupStatePath(baseUrl, scope, root) {
36532
- return scope === "local" && root ? join19(root, ".deepline", "setup", "state.json") : join19(sdkCliStateDirPath(baseUrl), "setup.json");
36874
+ return scope === "local" && root ? join20(root, ".deepline", "setup", "state.json") : join20(sdkCliStateDirPath(baseUrl), "setup.json");
36533
36875
  }
36534
36876
  async function captureStdout2(run) {
36535
36877
  let stdout = "";
@@ -36558,14 +36900,14 @@ function asRecord3(value) {
36558
36900
  }
36559
36901
  function safeRead(path) {
36560
36902
  try {
36561
- return readFileSync15(path, "utf8");
36903
+ return readFileSync16(path, "utf8");
36562
36904
  } catch {
36563
36905
  return "";
36564
36906
  }
36565
36907
  }
36566
36908
  function isNpmManagedDeeplinePath(path) {
36567
36909
  try {
36568
- return realpathSync4(path).includes(`${join19("node_modules", "deepline")}`);
36910
+ return realpathSync4(path).includes(`${join20("node_modules", "deepline")}`);
36569
36911
  } catch {
36570
36912
  return false;
36571
36913
  }
@@ -36576,28 +36918,28 @@ function isInstallerManagedLegacyLauncher(path) {
36576
36918
  }
36577
36919
  function removeKnownLegacyPaths(baseUrl) {
36578
36920
  const home = homedir13();
36579
- const hostDir = join19(home, ".local", "deepline", baseUrlSlug(baseUrl));
36580
- const legacyLauncherPath = join19(home, ".local", "bin", "deepline");
36921
+ const hostDir = join20(home, ".local", "deepline", baseUrlSlug(baseUrl));
36922
+ const legacyLauncherPath = join20(home, ".local", "bin", "deepline");
36581
36923
  const installerCommandPath = safeRead(
36582
- join19(hostDir, "sdk", ".command-path")
36924
+ join20(hostDir, "sdk", ".command-path")
36583
36925
  ).trim();
36584
36926
  const candidates = [
36585
36927
  ...isInstallerManagedLegacyLauncher(legacyLauncherPath) ? [legacyLauncherPath] : [],
36586
- join19(home, ".local", "bin", "deepline-real"),
36587
- join19(hostDir, "bin", "deepline"),
36588
- join19(hostDir, "bin", "deepline-real"),
36589
- join19(hostDir, "cli", ".install-method"),
36590
- join19(hostDir, "cli", ".version"),
36591
- join19(hostDir, "sdk", ".install-method"),
36592
- join19(hostDir, "sdk", ".command-path"),
36928
+ join20(home, ".local", "bin", "deepline-real"),
36929
+ join20(hostDir, "bin", "deepline"),
36930
+ join20(hostDir, "bin", "deepline-real"),
36931
+ join20(hostDir, "cli", ".install-method"),
36932
+ join20(hostDir, "cli", ".version"),
36933
+ join20(hostDir, "sdk", ".install-method"),
36934
+ join20(hostDir, "sdk", ".command-path"),
36593
36935
  ...installerCommandPath ? [
36594
36936
  installerCommandPath,
36595
- join19(dirname17(installerCommandPath), "deepline-sdk")
36937
+ join20(dirname17(installerCommandPath), "deepline-sdk")
36596
36938
  ] : []
36597
36939
  ];
36598
36940
  const removed = [];
36599
36941
  for (const path of candidates) {
36600
- if (!existsSync15(path)) continue;
36942
+ if (!existsSync16(path)) continue;
36601
36943
  if (path === installerCommandPath && isNpmManagedDeeplinePath(path)) {
36602
36944
  continue;
36603
36945
  }
@@ -36614,7 +36956,7 @@ function resolvePathCommands(command) {
36614
36956
  );
36615
36957
  return [
36616
36958
  ...new Set(
36617
- String(lookup.stdout ?? "").split(/\r?\n/).map((line) => line.trim()).filter(Boolean).map((path) => resolve17(path))
36959
+ String(lookup.stdout ?? "").split(/\r?\n/).map((line) => line.trim()).filter(Boolean).map((path) => resolve18(path))
36618
36960
  )
36619
36961
  ];
36620
36962
  }
@@ -36635,7 +36977,7 @@ function isHomebrewFormulaCommand(path) {
36635
36977
  function resolvePersistentGlobalCommand(dependencies = {}) {
36636
36978
  const platform3 = dependencies.platform ?? process.platform;
36637
36979
  const run = dependencies.spawn ?? spawnSync;
36638
- const pathExists = dependencies.exists ?? existsSync15;
36980
+ const pathExists = dependencies.exists ?? existsSync16;
36639
36981
  const pathClis = dependencies.pathClis ?? resolvePathCommands("deepline");
36640
36982
  const homebrewCommand = pathClis.find(isHomebrewFormulaCommand);
36641
36983
  if (homebrewCommand) return homebrewCommand;
@@ -36647,7 +36989,7 @@ function resolvePersistentGlobalCommand(dependencies = {}) {
36647
36989
  if (prefix.status !== 0) return null;
36648
36990
  const root = String(prefix.stdout ?? "").trim();
36649
36991
  if (!root) return null;
36650
- const candidates = platform3 === "win32" ? [join19(root, "deepline.cmd"), join19(root, "deepline")] : [join19(root, "bin", "deepline")];
36992
+ const candidates = platform3 === "win32" ? [join20(root, "deepline.cmd"), join20(root, "deepline")] : [join20(root, "bin", "deepline")];
36651
36993
  return candidates.find((candidate) => pathExists(candidate)) ?? null;
36652
36994
  }
36653
36995
  function inspectGlobalCliAvailability(input2) {
@@ -36662,18 +37004,18 @@ function pathsResolveToSameFile(left, right) {
36662
37004
  try {
36663
37005
  return realpathSync4(left) === realpathSync4(right);
36664
37006
  } catch {
36665
- return resolve17(left) === resolve17(right);
37007
+ return resolve18(left) === resolve18(right);
36666
37008
  }
36667
37009
  }
36668
37010
  function isKnownDeeplineCommand(path) {
36669
- const entrypoint = process.argv[1] ? resolve17(process.argv[1]) : "";
37011
+ const entrypoint = process.argv[1] ? resolve18(process.argv[1]) : "";
36670
37012
  let resolvedPath = path;
36671
37013
  try {
36672
37014
  resolvedPath = realpathSync4(path);
36673
37015
  } catch {
36674
37016
  }
36675
37017
  if (entrypoint && resolvedPath === entrypoint) return true;
36676
- if (resolvedPath.includes(`${join19("node_modules", "deepline")}`)) return true;
37018
+ if (resolvedPath.includes(`${join20("node_modules", "deepline")}`)) return true;
36677
37019
  const content = safeRead(path);
36678
37020
  return content.includes("node_modules/deepline") || content.includes("node_modules\\deepline") || content.includes("DEEPLINE_CONFIG_SCOPE") || content.includes("deepline-real");
36679
37021
  }
@@ -36683,7 +37025,7 @@ function inspectPathConflict() {
36683
37025
  try {
36684
37026
  if (lstatSync(commandPath).isSymbolicLink()) {
36685
37027
  const target = realpathSync4(commandPath);
36686
- if (target.includes(`${join19("node_modules", "deepline")}`)) return null;
37028
+ if (target.includes(`${join20("node_modules", "deepline")}`)) return null;
36687
37029
  }
36688
37030
  } catch {
36689
37031
  }
@@ -36732,7 +37074,7 @@ function failSetupPhase(phases, phase, code) {
36732
37074
  phases[phase] = { status: "failed", code };
36733
37075
  }
36734
37076
  function rollbackCommand(scope, root) {
36735
- const prefix = scope === "local" && root ? ` --prefix ${JSON.stringify(join19(root, ".deepline", "runtime"))}` : "";
37077
+ const prefix = scope === "local" && root ? ` --prefix ${JSON.stringify(join20(root, ".deepline", "runtime"))}` : "";
36736
37078
  return `npm install -g${prefix} --no-audit --no-fund --include=optional --allow-scripts=esbuild deepline@${SDK_VERSION}`;
36737
37079
  }
36738
37080
  function setupResumeCommand(baseUrl, scope) {
@@ -36819,12 +37161,12 @@ function buildDoctorAssessment(input2) {
36819
37161
  const connected = input2.authStatus.payload?.connected === true;
36820
37162
  const authScopeOk = input2.scope === "local" ? Boolean(projectAuth) : Boolean(apiKey && !projectAuth);
36821
37163
  const skillsOk = skillsState?.scope === input2.scope && typeof skillsState.skillsVersion === "string" && Array.isArray(skillsState.agents) && skillsState.agents.length > 0;
36822
- const runningCliPath = process.argv[1] ? resolve17(process.argv[1]) : null;
37164
+ const runningCliPath = process.argv[1] ? resolve18(process.argv[1]) : null;
36823
37165
  const globalCli = input2.scope === "global" ? inspectGlobalCliAvailability() : null;
36824
37166
  const pathGlobalCli = globalCli?.path ?? null;
36825
37167
  const cliPath = input2.scope === "global" ? pathGlobalCli : runningCliPath;
36826
37168
  const cliScopeOk = input2.scope === "global" ? Boolean(pathGlobalCli) : Boolean(
36827
- input2.root && runningCliPath?.includes(join19(input2.root, ".deepline", "runtime"))
37169
+ input2.root && runningCliPath?.includes(join20(input2.root, ".deepline", "runtime"))
36828
37170
  );
36829
37171
  const checks = {
36830
37172
  cli: {
@@ -37470,7 +37812,7 @@ function isDowngradeAutoUpdateResponse(response) {
37470
37812
  return compareSemver(target, current) < 0;
37471
37813
  }
37472
37814
  function relaunchCurrentCommand(plan) {
37473
- return new Promise((resolve18) => {
37815
+ return new Promise((resolve19) => {
37474
37816
  const command = plan.kind === "python-sidecar" ? plan.sidecarPath : process.execPath;
37475
37817
  const args = plan.kind === "python-sidecar" ? process.argv.slice(2) : process.argv.slice(1);
37476
37818
  const child = spawn4(command, args, {
@@ -37486,9 +37828,9 @@ function relaunchCurrentCommand(plan) {
37486
37828
  `Deepline SDK/CLI updated, but relaunch failed: ${error.message}
37487
37829
  `
37488
37830
  );
37489
- resolve18(1);
37831
+ resolve19(1);
37490
37832
  });
37491
- child.on("close", (code) => resolve18(code ?? 1));
37833
+ child.on("close", (code) => resolve19(code ?? 1));
37492
37834
  });
37493
37835
  }
37494
37836
  async function maybeAutoUpdateAndRelaunch(response) {
@@ -37540,13 +37882,13 @@ async function maybeAutoUpdateAndRelaunch(response) {
37540
37882
  // src/cli/skills-sync.ts
37541
37883
  import { spawn as spawn5, spawnSync as spawnSync2 } from "child_process";
37542
37884
  import {
37543
- existsSync as existsSync16,
37885
+ existsSync as existsSync17,
37544
37886
  mkdirSync as mkdirSync12,
37545
- readFileSync as readFileSync16,
37887
+ readFileSync as readFileSync17,
37546
37888
  unlinkSync as unlinkSync2,
37547
37889
  writeFileSync as writeFileSync17
37548
37890
  } from "fs";
37549
- import { dirname as dirname18, join as join20 } from "path";
37891
+ import { dirname as dirname18, join as join21 } from "path";
37550
37892
  var CHECK_TIMEOUT_MS2 = 3e3;
37551
37893
  var attemptedSync = false;
37552
37894
  function shouldSkipSkillsSync() {
@@ -37562,33 +37904,33 @@ function activePluginSkillsDir() {
37562
37904
  return "";
37563
37905
  }
37564
37906
  const dir = process.env.DEEPLINE_PLUGIN_SKILLS_DIR?.trim() ?? "";
37565
- return dir && existsSync16(dir) ? dir : "";
37907
+ return dir && existsSync17(dir) ? dir : "";
37566
37908
  }
37567
37909
  function readPluginSkillsVersion() {
37568
37910
  const dir = activePluginSkillsDir();
37569
37911
  if (!dir) return "";
37570
37912
  try {
37571
- return readFileSync16(join20(dir, ".version"), "utf-8").trim();
37913
+ return readFileSync17(join21(dir, ".version"), "utf-8").trim();
37572
37914
  } catch {
37573
37915
  return "";
37574
37916
  }
37575
37917
  }
37576
37918
  function sdkSkillsVersionPath(baseUrl) {
37577
- return join20(sdkCliStateDirPath(baseUrl), "skills-version");
37919
+ return join21(sdkCliStateDirPath(baseUrl), "skills-version");
37578
37920
  }
37579
37921
  function legacySdkSkillsVersionPath(baseUrl) {
37580
- return join20(dirname18(sdkCliStateDirPath(baseUrl)), "sdk-skills", ".version");
37922
+ return join21(dirname18(sdkCliStateDirPath(baseUrl)), "sdk-skills", ".version");
37581
37923
  }
37582
37924
  function unavailableSkillsNoticePath(baseUrl) {
37583
- return join20(sdkCliStateDirPath(baseUrl), "skills-sync-unavailable-version");
37925
+ return join21(sdkCliStateDirPath(baseUrl), "skills-sync-unavailable-version");
37584
37926
  }
37585
37927
  function readSdkSkillsLocalVersion(baseUrl) {
37586
37928
  const pluginVersion = readPluginSkillsVersion();
37587
37929
  if (pluginVersion) return pluginVersion;
37588
- const path = existsSync16(sdkSkillsVersionPath(baseUrl)) ? sdkSkillsVersionPath(baseUrl) : legacySdkSkillsVersionPath(baseUrl);
37589
- if (!existsSync16(path)) return "";
37930
+ const path = existsSync17(sdkSkillsVersionPath(baseUrl)) ? sdkSkillsVersionPath(baseUrl) : legacySdkSkillsVersionPath(baseUrl);
37931
+ if (!existsSync17(path)) return "";
37590
37932
  try {
37591
- return readFileSync16(path, "utf-8").trim();
37933
+ return readFileSync17(path, "utf-8").trim();
37592
37934
  } catch {
37593
37935
  return "";
37594
37936
  }
@@ -37602,7 +37944,7 @@ function writeLocalSkillsVersion(baseUrl, version) {
37602
37944
  function writeUnavailableSkillsNotice(baseUrl, remoteVersion, skillNames) {
37603
37945
  const path = unavailableSkillsNoticePath(baseUrl);
37604
37946
  try {
37605
- if (existsSync16(path) && readFileSync16(path, "utf-8").trim() === remoteVersion) {
37947
+ if (existsSync17(path) && readFileSync17(path, "utf-8").trim() === remoteVersion) {
37606
37948
  return;
37607
37949
  }
37608
37950
  mkdirSync12(dirname18(path), { recursive: true });
@@ -37740,7 +38082,7 @@ function resolveSkillsInstallCommands(baseUrl, skillNames = DEFAULT_SDK_SKILL_NA
37740
38082
  return commands;
37741
38083
  }
37742
38084
  function runOneSkillsInstall(install) {
37743
- return new Promise((resolve18) => {
38085
+ return new Promise((resolve19) => {
37744
38086
  const plan = resolveSkillsInstallSpawn(install);
37745
38087
  const child = spawn5(plan.command, plan.args, {
37746
38088
  stdio: ["ignore", "ignore", "pipe"],
@@ -37752,7 +38094,7 @@ function runOneSkillsInstall(install) {
37752
38094
  stderr += chunk.toString("utf-8");
37753
38095
  });
37754
38096
  child.on("error", (error) => {
37755
- resolve18({
38097
+ resolve19({
37756
38098
  ok: false,
37757
38099
  detail: `failed to start ${install.command}: ${error.message}`,
37758
38100
  manualCommand: install.manualCommand
@@ -37760,11 +38102,11 @@ function runOneSkillsInstall(install) {
37760
38102
  });
37761
38103
  child.on("close", (code) => {
37762
38104
  if (code === 0) {
37763
- resolve18({ ok: true, detail: "", manualCommand: install.manualCommand });
38105
+ resolve19({ ok: true, detail: "", manualCommand: install.manualCommand });
37764
38106
  return;
37765
38107
  }
37766
38108
  const detail = stderr.trim();
37767
- resolve18({
38109
+ resolve19({
37768
38110
  ok: false,
37769
38111
  detail: detail ? `${install.command}: ${detail}` : `${install.command} exited ${code}`,
37770
38112
  manualCommand: install.manualCommand
@@ -38192,8 +38534,8 @@ function topLevelCommandKnown(program, commandName) {
38192
38534
  );
38193
38535
  }
38194
38536
  async function runPlayRunnerHealthCheck() {
38195
- const dir = await mkdtemp2(join21(tmpdir6(), "deepline-health-play-"));
38196
- const file = join21(dir, "health-check.play.ts");
38537
+ const dir = await mkdtemp2(join22(tmpdir6(), "deepline-health-play-"));
38538
+ const file = join22(dir, "health-check.play.ts");
38197
38539
  try {
38198
38540
  await writeFile6(
38199
38541
  file,