deepline 0.1.126 → 0.1.127

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.
@@ -381,10 +381,10 @@ var SDK_RELEASE = {
381
381
  // 0.1.108 ships explicit dataset column/tool recompute policy and removes
382
382
  // the SDK enrich generator's one-second stale policy.
383
383
  // 0.1.110 ships authored V2 prebuilts and required top-level play descriptions.
384
- version: "0.1.126",
384
+ version: "0.1.127",
385
385
  apiContract: "2026-06-dataset-column-cell-stale-hard-cutover",
386
386
  supportPolicy: {
387
- latest: "0.1.126",
387
+ latest: "0.1.127",
388
388
  minimumSupported: "0.1.53",
389
389
  deprecatedBelow: "0.1.53",
390
390
  commandMinimumSupported: [
@@ -21270,33 +21270,371 @@ Notes:
21270
21270
  }
21271
21271
 
21272
21272
  // src/cli/commands/update.ts
21273
- import { spawn as spawn2 } from "child_process";
21273
+ import { spawn as spawn3 } from "child_process";
21274
21274
  import {
21275
- existsSync as existsSync10,
21276
- mkdirSync as mkdirSync8,
21275
+ existsSync as existsSync11,
21276
+ mkdirSync as mkdirSync9,
21277
21277
  realpathSync as realpathSync2,
21278
- readFileSync as readFileSync10,
21278
+ readFileSync as readFileSync11,
21279
21279
  renameSync,
21280
21280
  rmSync as rmSync3,
21281
21281
  unlinkSync,
21282
- writeFileSync as writeFileSync13
21282
+ writeFileSync as writeFileSync14
21283
21283
  } from "fs";
21284
+ import { homedir as homedir11 } from "os";
21285
+ import { dirname as dirname11, isAbsolute as isAbsolute2, join as join13, relative as relative2, resolve as resolve12 } from "path";
21286
+
21287
+ // src/cli/skills-sync.ts
21288
+ import { spawn as spawn2, spawnSync as spawnSync2 } from "child_process";
21289
+ import { existsSync as existsSync10, mkdirSync as mkdirSync8, readFileSync as readFileSync10, writeFileSync as writeFileSync13 } from "fs";
21284
21290
  import { homedir as homedir10 } from "os";
21285
- import { dirname as dirname10, isAbsolute as isAbsolute2, join as join12, relative as relative2, resolve as resolve12 } from "path";
21291
+ import { dirname as dirname10, join as join12 } from "path";
21292
+
21293
+ // ../shared_libs/cli/install-commands.json
21294
+ var install_commands_default = {
21295
+ skills: {
21296
+ index_path: "/.well-known/skills/index.json",
21297
+ default_agents: [
21298
+ "codex",
21299
+ "claude-code",
21300
+ "cursor",
21301
+ "gemini-cli",
21302
+ "antigravity"
21303
+ ],
21304
+ npx_binary: "npx",
21305
+ npx_add_args_template: [
21306
+ "--yes",
21307
+ "skills",
21308
+ "add",
21309
+ "{skills_index_url}",
21310
+ "--agent",
21311
+ "{agents}",
21312
+ "--global",
21313
+ "--yes",
21314
+ "--skill",
21315
+ "{skill_name}",
21316
+ "--full-depth"
21317
+ ]
21318
+ },
21319
+ cli: {
21320
+ legacy_python_shell_template: "curl -s {base_url}/api/v2/cli/install | bash",
21321
+ sdk_npm_global: "npm install -g deepline@latest"
21322
+ }
21323
+ };
21324
+
21325
+ // src/cli/install-commands.ts
21326
+ var INSTALL_COMMANDS = install_commands_default;
21327
+ var DEFAULT_V1_SKILL_NAMES = [
21328
+ "build-tam",
21329
+ "clay-to-deepline",
21330
+ "deepline-analytics",
21331
+ "deepline-feedback",
21332
+ "deepline-gtm",
21333
+ "deepline-quickstart",
21334
+ "find-qualified-titles",
21335
+ "linkedin-url-lookup",
21336
+ "niche-signal-discovery",
21337
+ "portfolio-prospecting",
21338
+ "workflow-hello-world"
21339
+ ];
21340
+ var DEFAULT_SDK_SKILL_NAMES = [
21341
+ ...DEFAULT_V1_SKILL_NAMES,
21342
+ "deepline-plays"
21343
+ ];
21344
+ function normalizeBaseUrl2(baseUrl) {
21345
+ return baseUrl.replace(/\/$/, "");
21346
+ }
21347
+ function renderTemplate(template, values) {
21348
+ return template.replace(/\{([a-z_]+)\}/g, (match, key) => {
21349
+ return values[key] ?? match;
21350
+ });
21351
+ }
21352
+ function shellJoin(args) {
21353
+ return args.join(" ");
21354
+ }
21355
+ function skillsIndexUrl(baseUrl) {
21356
+ return `${normalizeBaseUrl2(baseUrl)}${INSTALL_COMMANDS.skills.index_path}`;
21357
+ }
21358
+ function buildSkillsAddArgs(baseUrl, skillName, options = {}) {
21359
+ const skillNames = Array.isArray(skillName) ? skillName : [skillName];
21360
+ const [firstSkillName, ...extraSkillNames] = skillNames;
21361
+ const values = {
21362
+ skills_index_url: skillsIndexUrl(baseUrl),
21363
+ agents: INSTALL_COMMANDS.skills.default_agents.join(" "),
21364
+ skill_name: firstSkillName ?? ""
21365
+ };
21366
+ const rendered = INSTALL_COMMANDS.skills.npx_add_args_template.flatMap(
21367
+ (arg, index) => {
21368
+ const next = index === 0 && options.firstArg ? options.firstArg : arg;
21369
+ const value = renderTemplate(next, values);
21370
+ if (arg === "{agents}") {
21371
+ return INSTALL_COMMANDS.skills.default_agents;
21372
+ }
21373
+ if (arg === "{skill_name}") {
21374
+ return [value, ...extraSkillNames.flatMap((name) => ["--skill", name])];
21375
+ }
21376
+ return value;
21377
+ }
21378
+ );
21379
+ return rendered;
21380
+ }
21381
+ function skillsInstallCommand(baseUrl, skillName) {
21382
+ return `${INSTALL_COMMANDS.skills.npx_binary} ${shellJoin(
21383
+ buildSkillsAddArgs(baseUrl, skillName)
21384
+ )}`;
21385
+ }
21386
+ function legacyPythonInstallCommand(baseUrl) {
21387
+ return renderTemplate(INSTALL_COMMANDS.cli.legacy_python_shell_template, {
21388
+ base_url: normalizeBaseUrl2(baseUrl)
21389
+ });
21390
+ }
21391
+ function sdkNpmGlobalInstallCommand() {
21392
+ return INSTALL_COMMANDS.cli.sdk_npm_global;
21393
+ }
21394
+
21395
+ // src/cli/skills-sync.ts
21396
+ var CHECK_TIMEOUT_MS2 = 3e3;
21397
+ var SDK_PLAY_SKILL_NAME = "deepline-plays";
21398
+ var attemptedSync = false;
21399
+ function shouldSkipSkillsSync() {
21400
+ const value = process.env.DEEPLINE_SKIP_SKILLS_SYNC?.trim().toLowerCase();
21401
+ return value === "1" || value === "true" || value === "yes" || value === "on";
21402
+ }
21403
+ function activePluginSkillsDir() {
21404
+ const pluginMode = process.env.DEEPLINE_PLUGIN_MODE?.trim().toLowerCase();
21405
+ if (pluginMode !== "true" && pluginMode !== "1" && pluginMode !== "yes" && pluginMode !== "on") {
21406
+ return "";
21407
+ }
21408
+ const dir = process.env.DEEPLINE_PLUGIN_SKILLS_DIR?.trim() ?? "";
21409
+ return dir && existsSync10(dir) ? dir : "";
21410
+ }
21411
+ function readPluginSkillsVersion() {
21412
+ const dir = activePluginSkillsDir();
21413
+ if (!dir) return "";
21414
+ try {
21415
+ return readFileSync10(join12(dir, ".version"), "utf-8").trim();
21416
+ } catch {
21417
+ return "";
21418
+ }
21419
+ }
21420
+ function sdkSkillsVersionPath(baseUrl) {
21421
+ const home = process.env.HOME?.trim() || homedir10();
21422
+ return join12(
21423
+ home,
21424
+ ".local",
21425
+ "deepline",
21426
+ baseUrlSlug(baseUrl),
21427
+ "sdk-skills",
21428
+ ".version"
21429
+ );
21430
+ }
21431
+ function readLocalSkillsVersion(baseUrl) {
21432
+ const pluginVersion = readPluginSkillsVersion();
21433
+ if (pluginVersion) return pluginVersion;
21434
+ const path = sdkSkillsVersionPath(baseUrl);
21435
+ if (!existsSync10(path)) return "";
21436
+ try {
21437
+ return readFileSync10(path, "utf-8").trim();
21438
+ } catch {
21439
+ return "";
21440
+ }
21441
+ }
21442
+ function writeLocalSkillsVersion(baseUrl, version) {
21443
+ const path = sdkSkillsVersionPath(baseUrl);
21444
+ mkdirSync8(dirname10(path), { recursive: true });
21445
+ writeFileSync13(path, `${version}
21446
+ `, "utf-8");
21447
+ }
21448
+ function sortedUniqueSkillNames(names) {
21449
+ return [...new Set(names.map((name) => name.trim()).filter(Boolean))].sort(
21450
+ (a, b) => a.localeCompare(b)
21451
+ );
21452
+ }
21453
+ async function fetchV1SkillNames(baseUrl) {
21454
+ const controller = new AbortController();
21455
+ const timeout = setTimeout(() => controller.abort(), CHECK_TIMEOUT_MS2);
21456
+ try {
21457
+ const response = await fetch(
21458
+ new URL("/.well-known/skills/index.json", baseUrl),
21459
+ { signal: controller.signal }
21460
+ );
21461
+ if (!response.ok) return [];
21462
+ const data = await response.json().catch(() => null);
21463
+ const names = (data?.skills ?? []).filter((skill) => skill.install_surface === "v1").map((skill) => skill.name).filter(
21464
+ (name) => typeof name === "string" && name.length > 0
21465
+ );
21466
+ return sortedUniqueSkillNames(names);
21467
+ } catch {
21468
+ return [];
21469
+ } finally {
21470
+ clearTimeout(timeout);
21471
+ }
21472
+ }
21473
+ function buildSdkSkillNames(v1SkillNames) {
21474
+ return sortedUniqueSkillNames([...v1SkillNames, SDK_PLAY_SKILL_NAME]);
21475
+ }
21476
+ async function fetchSkillsUpdate(baseUrl, localVersion) {
21477
+ const controller = new AbortController();
21478
+ const timeout = setTimeout(() => controller.abort(), CHECK_TIMEOUT_MS2);
21479
+ try {
21480
+ const response = await fetch(new URL("/api/v2/cli/update-check", baseUrl), {
21481
+ method: "POST",
21482
+ headers: { "Content-Type": "application/json" },
21483
+ body: JSON.stringify({
21484
+ skills: {
21485
+ version: localVersion
21486
+ }
21487
+ }),
21488
+ signal: controller.signal
21489
+ });
21490
+ if (!response.ok) return null;
21491
+ const data = await response.json().catch(() => null);
21492
+ const skills = data?.skills;
21493
+ if (!skills) return null;
21494
+ return {
21495
+ needsUpdate: skills.needs_update === true,
21496
+ remoteVersion: typeof skills.remote?.version === "string" ? skills.remote.version.trim() : ""
21497
+ };
21498
+ } catch {
21499
+ return null;
21500
+ } finally {
21501
+ clearTimeout(timeout);
21502
+ }
21503
+ }
21504
+ function buildSkillsInstallArgs(baseUrl, skillNames = DEFAULT_SDK_SKILL_NAMES) {
21505
+ return buildSkillsAddArgs(baseUrl, sortedUniqueSkillNames(skillNames));
21506
+ }
21507
+ function buildBunxSkillsInstallArgs(baseUrl, skillNames) {
21508
+ return buildSkillsAddArgs(baseUrl, sortedUniqueSkillNames(skillNames), {
21509
+ firstArg: "--bun"
21510
+ });
21511
+ }
21512
+ function hasCommand(command) {
21513
+ const result = spawnSync2(command, ["--version"], {
21514
+ stdio: "ignore",
21515
+ shell: process.platform === "win32"
21516
+ });
21517
+ return result.status === 0;
21518
+ }
21519
+ function shellQuote3(arg) {
21520
+ return `'${arg.replace(/'/g, `'\\''`)}'`;
21521
+ }
21522
+ function resolveSkillsInstallCommands(baseUrl, skillNames = DEFAULT_SDK_SKILL_NAMES) {
21523
+ const npxArgs = buildSkillsInstallArgs(baseUrl, skillNames);
21524
+ const npxInstall = {
21525
+ command: "npx",
21526
+ args: npxArgs,
21527
+ manualCommand: `npx ${npxArgs.map(shellQuote3).join(" ")}`
21528
+ };
21529
+ if (hasCommand("bunx")) {
21530
+ const bunxArgs = buildBunxSkillsInstallArgs(baseUrl, skillNames);
21531
+ return [
21532
+ {
21533
+ command: "bunx",
21534
+ args: bunxArgs,
21535
+ manualCommand: `bunx ${bunxArgs.map(shellQuote3).join(" ")}`
21536
+ },
21537
+ npxInstall
21538
+ ];
21539
+ }
21540
+ return [npxInstall];
21541
+ }
21542
+ function runOneSkillsInstall(install) {
21543
+ return new Promise((resolve13) => {
21544
+ const child = spawn2(install.command, install.args, {
21545
+ stdio: ["ignore", "ignore", "pipe"],
21546
+ env: process.env
21547
+ });
21548
+ let stderr = "";
21549
+ child.stderr.on("data", (chunk) => {
21550
+ stderr += chunk.toString("utf-8");
21551
+ });
21552
+ child.on("error", (error) => {
21553
+ resolve13({
21554
+ ok: false,
21555
+ detail: `failed to start ${install.command}: ${error.message}`,
21556
+ manualCommand: install.manualCommand
21557
+ });
21558
+ });
21559
+ child.on("close", (code) => {
21560
+ if (code === 0) {
21561
+ resolve13({ ok: true, detail: "", manualCommand: install.manualCommand });
21562
+ return;
21563
+ }
21564
+ const detail = stderr.trim();
21565
+ resolve13({
21566
+ ok: false,
21567
+ detail: detail ? `${install.command}: ${detail}` : `${install.command} exited ${code}`,
21568
+ manualCommand: install.manualCommand
21569
+ });
21570
+ });
21571
+ });
21572
+ }
21573
+ async function runSkillsInstall(baseUrl, skillNames) {
21574
+ const failures = [];
21575
+ for (const install of resolveSkillsInstallCommands(baseUrl, skillNames)) {
21576
+ const result = await runOneSkillsInstall(install);
21577
+ if (result.ok) return true;
21578
+ failures.push(result);
21579
+ }
21580
+ const details = failures.map((failure) => failure.detail).filter(Boolean).join("\n");
21581
+ const manualCommand = failures.at(-1)?.manualCommand;
21582
+ process.stderr.write(
21583
+ `SDK skills sync failed${details ? `:
21584
+ ${details}` : ""}
21585
+ ` + (manualCommand ? `Run manually: ${manualCommand}
21586
+ ` : "")
21587
+ );
21588
+ return false;
21589
+ }
21590
+ function writeSdkSkillsStatusLine(line) {
21591
+ const progress = getActiveCliProgress();
21592
+ if (progress) {
21593
+ progress.writeLine(line);
21594
+ return;
21595
+ }
21596
+ process.stderr.write(`${line}
21597
+ `);
21598
+ }
21599
+ async function syncSdkSkillsIfNeeded(baseUrl) {
21600
+ if (attemptedSync || shouldSkipSkillsSync()) return;
21601
+ attemptedSync = true;
21602
+ const usingPluginSkills = Boolean(activePluginSkillsDir());
21603
+ const localVersion = readLocalSkillsVersion(baseUrl);
21604
+ const update = await fetchSkillsUpdate(baseUrl, localVersion);
21605
+ if (usingPluginSkills) {
21606
+ return;
21607
+ }
21608
+ if (!update?.needsUpdate || !update.remoteVersion) {
21609
+ return;
21610
+ }
21611
+ const remoteSkillNames = await fetchV1SkillNames(baseUrl);
21612
+ const skillNames = buildSdkSkillNames(
21613
+ remoteSkillNames.length > 0 ? remoteSkillNames : DEFAULT_SDK_SKILL_NAMES
21614
+ );
21615
+ if (skillNames.length === 0) return;
21616
+ writeSdkSkillsStatusLine("Deepline skills changed; syncing agent skills...");
21617
+ const installed = await runSkillsInstall(baseUrl, skillNames);
21618
+ if (!installed) return;
21619
+ writeLocalSkillsVersion(baseUrl, update.remoteVersion);
21620
+ writeSdkSkillsStatusLine("Deepline agent skills are up to date.");
21621
+ }
21622
+
21623
+ // src/cli/commands/update.ts
21286
21624
  function posixShellQuote(value) {
21287
21625
  return `'${value.replace(/'/g, `'\\''`)}'`;
21288
21626
  }
21289
21627
  function windowsCmdQuote(value) {
21290
21628
  return `"${value.replace(/"/g, '""')}"`;
21291
21629
  }
21292
- function shellQuote3(value) {
21630
+ function shellQuote4(value) {
21293
21631
  if (process.platform === "win32") {
21294
21632
  return /^[A-Za-z0-9_./:@%+=,-]+$/.test(value) ? value : windowsCmdQuote(value);
21295
21633
  }
21296
21634
  return posixShellQuote(value);
21297
21635
  }
21298
21636
  function buildSourceUpdateCommand(sourceRoot) {
21299
- const quotedRoot = shellQuote3(sourceRoot);
21637
+ const quotedRoot = shellQuote4(sourceRoot);
21300
21638
  const cdCommand = process.platform === "win32" ? `cd /d ${quotedRoot}` : `cd ${quotedRoot}`;
21301
21639
  return `${cdCommand} && git fetch origin main --tags && git merge --ff-only origin/main`;
21302
21640
  }
@@ -21305,11 +21643,11 @@ function sidecarStateDir(input2) {
21305
21643
  if (!scope || scope.includes("/") || scope.includes("\\")) {
21306
21644
  return null;
21307
21645
  }
21308
- return join12(input2.homeDir, ".local", "deepline", scope, "sdk-cli");
21646
+ return join13(input2.homeDir, ".local", "deepline", scope, "sdk-cli");
21309
21647
  }
21310
21648
  function readOptionalText(path) {
21311
21649
  try {
21312
- return readFileSync10(path, "utf8").trim();
21650
+ return readFileSync11(path, "utf8").trim();
21313
21651
  } catch {
21314
21652
  return "";
21315
21653
  }
@@ -21324,19 +21662,19 @@ function resolvePythonSidecarUpdatePlan(options) {
21324
21662
  if (!relativeEntrypoint || relativeEntrypoint.startsWith("..") || isAbsolute2(relativeEntrypoint)) {
21325
21663
  return null;
21326
21664
  }
21327
- const installMethod = readOptionalText(join12(stateDir, ".install-method"));
21665
+ const installMethod = readOptionalText(join13(stateDir, ".install-method"));
21328
21666
  if (installMethod !== "python-sidecar") return null;
21329
21667
  const scope = options.env.DEEPLINE_CONFIG_SCOPE?.trim() || "";
21330
21668
  const hostUrl = options.env.DEEPLINE_HOST_URL?.trim() || "";
21331
- const nodeBin = readOptionalText(join12(stateDir, ".node-bin")) || process.execPath;
21332
- const sidecarPath = readOptionalText(join12(stateDir, ".command-path")) || join12(
21669
+ const nodeBin = readOptionalText(join13(stateDir, ".node-bin")) || process.execPath;
21670
+ const sidecarPath = readOptionalText(join13(stateDir, ".command-path")) || join13(
21333
21671
  stateDir,
21334
21672
  "bin",
21335
21673
  process.platform === "win32" ? "deepline-sdk.cmd" : "deepline-sdk"
21336
21674
  );
21337
21675
  const packageSpec = options.packageSpec || "deepline@latest";
21338
21676
  const npmCommand = "npm";
21339
- const manualCommand = `${npmCommand} install --prefix ${shellQuote3(join12(stateDir, "versions", "<version>"))} --no-audit --no-fund ${shellQuote3(packageSpec)}`;
21677
+ const manualCommand = `${npmCommand} install --prefix ${shellQuote4(join13(stateDir, "versions", "<version>"))} --no-audit --no-fund ${shellQuote4(packageSpec)}`;
21340
21678
  return {
21341
21679
  kind: "python-sidecar",
21342
21680
  stateDir,
@@ -21352,10 +21690,10 @@ function resolvePythonSidecarUpdatePlan(options) {
21352
21690
  function findRepoBackedSdkRoot(startPath) {
21353
21691
  let current = resolve12(startPath);
21354
21692
  while (true) {
21355
- if (existsSync10(join12(current, "sdk", "package.json")) && existsSync10(join12(current, "sdk", "bin", "deepline-dev.ts"))) {
21693
+ if (existsSync11(join13(current, "sdk", "package.json")) && existsSync11(join13(current, "sdk", "bin", "deepline-dev.ts"))) {
21356
21694
  return current;
21357
21695
  }
21358
- const parent = dirname10(current);
21696
+ const parent = dirname11(current);
21359
21697
  if (parent === current) return null;
21360
21698
  current = parent;
21361
21699
  }
@@ -21383,9 +21721,9 @@ function inferNpmGlobalPrefixFromEntrypoint(entrypoint) {
21383
21721
  }
21384
21722
  function resolveUpdatePlan(options = {}) {
21385
21723
  const env = options.env ?? process.env;
21386
- const homeDir2 = options.homeDir ?? homedir10();
21724
+ const homeDir2 = options.homeDir ?? homedir11();
21387
21725
  const entrypoint = options.entrypoint ?? (process.argv[1] ? resolve12(process.argv[1]) : "");
21388
- const sourceRoot = entrypoint ? findRepoBackedSdkRoot(dirname10(entrypoint)) : null;
21726
+ const sourceRoot = entrypoint ? findRepoBackedSdkRoot(dirname11(entrypoint)) : null;
21389
21727
  if (sourceRoot) {
21390
21728
  return {
21391
21729
  kind: "source",
@@ -21409,17 +21747,17 @@ function resolveUpdatePlan(options = {}) {
21409
21747
  command,
21410
21748
  args,
21411
21749
  ...installPrefix ? { installPrefix } : {},
21412
- manualCommand: `${command} ${args.map(shellQuote3).join(" ")}`
21750
+ manualCommand: `${command} ${args.map(shellQuote4).join(" ")}`
21413
21751
  };
21414
21752
  }
21415
21753
  var AUTO_UPDATE_FAILURE_FILE = ".auto-update-failure.json";
21416
21754
  function autoUpdateFailurePath(plan) {
21417
21755
  if (plan.kind === "source") return null;
21418
21756
  if (plan.kind === "python-sidecar") {
21419
- return join12(plan.stateDir, AUTO_UPDATE_FAILURE_FILE);
21757
+ return join13(plan.stateDir, AUTO_UPDATE_FAILURE_FILE);
21420
21758
  }
21421
- return join12(
21422
- homedir10(),
21759
+ return join13(
21760
+ homedir11(),
21423
21761
  ".local",
21424
21762
  "deepline",
21425
21763
  "sdk-cli",
@@ -21436,7 +21774,7 @@ function readAutoUpdateFailure(plan) {
21436
21774
  if (!path) return null;
21437
21775
  try {
21438
21776
  const parsed = JSON.parse(
21439
- readFileSync10(path, "utf8")
21777
+ readFileSync11(path, "utf8")
21440
21778
  );
21441
21779
  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") {
21442
21780
  return parsed;
@@ -21457,8 +21795,8 @@ function writeAutoUpdateFailure(plan, exitCode) {
21457
21795
  manualCommand: plan.manualCommand
21458
21796
  };
21459
21797
  try {
21460
- mkdirSync8(dirname10(path), { recursive: true });
21461
- writeFileSync13(path, `${JSON.stringify(marker, null, 2)}
21798
+ mkdirSync9(dirname11(path), { recursive: true });
21799
+ writeFileSync14(path, `${JSON.stringify(marker, null, 2)}
21462
21800
  `, "utf8");
21463
21801
  } catch {
21464
21802
  }
@@ -21503,7 +21841,7 @@ function safeVersionSegment(value) {
21503
21841
  return /^[0-9A-Za-z._-]+$/.test(normalized) ? normalized : "";
21504
21842
  }
21505
21843
  function entryPathInVersionDir(versionDir) {
21506
- return join12(
21844
+ return join13(
21507
21845
  versionDir,
21508
21846
  "node_modules",
21509
21847
  "deepline",
@@ -21513,14 +21851,14 @@ function entryPathInVersionDir(versionDir) {
21513
21851
  );
21514
21852
  }
21515
21853
  function installedPackageVersion(versionDir) {
21516
- const packageJsonPath = join12(
21854
+ const packageJsonPath = join13(
21517
21855
  versionDir,
21518
21856
  "node_modules",
21519
21857
  "deepline",
21520
21858
  "package.json"
21521
21859
  );
21522
21860
  try {
21523
- const parsed = JSON.parse(readFileSync10(packageJsonPath, "utf8"));
21861
+ const parsed = JSON.parse(readFileSync11(packageJsonPath, "utf8"));
21524
21862
  return typeof parsed.version === "string" ? safeVersionSegment(parsed.version) : "";
21525
21863
  } catch {
21526
21864
  return "";
@@ -21528,7 +21866,7 @@ function installedPackageVersion(versionDir) {
21528
21866
  }
21529
21867
  function runCommand(command, args, env = process.env) {
21530
21868
  return new Promise((resolveExitCode) => {
21531
- const child = spawn2(command, args, {
21869
+ const child = spawn3(command, args, {
21532
21870
  stdio: "inherit",
21533
21871
  shell: process.platform === "win32",
21534
21872
  env
@@ -21544,9 +21882,9 @@ function runCommand(command, args, env = process.env) {
21544
21882
  });
21545
21883
  }
21546
21884
  function writeSidecarLauncher(input2) {
21547
- mkdirSync8(dirname10(input2.path), { recursive: true });
21885
+ mkdirSync9(dirname11(input2.path), { recursive: true });
21548
21886
  if (process.platform === "win32") {
21549
- writeFileSync13(
21887
+ writeFileSync14(
21550
21888
  input2.path,
21551
21889
  [
21552
21890
  `@set DEEPLINE_HOST_URL=${input2.hostUrl.replace(/\r?\n/g, "")}`,
@@ -21558,30 +21896,30 @@ function writeSidecarLauncher(input2) {
21558
21896
  );
21559
21897
  return;
21560
21898
  }
21561
- writeFileSync13(
21899
+ writeFileSync14(
21562
21900
  input2.path,
21563
21901
  [
21564
21902
  "#!/usr/bin/env sh",
21565
- `export DEEPLINE_HOST_URL=${shellQuote3(input2.hostUrl)}`,
21566
- `export DEEPLINE_CONFIG_SCOPE=${shellQuote3(input2.scope)}`,
21567
- `exec ${shellQuote3(input2.nodeBin)} ${shellQuote3(input2.entryPath)} "$@"`,
21903
+ `export DEEPLINE_HOST_URL=${shellQuote4(input2.hostUrl)}`,
21904
+ `export DEEPLINE_CONFIG_SCOPE=${shellQuote4(input2.scope)}`,
21905
+ `exec ${shellQuote4(input2.nodeBin)} ${shellQuote4(input2.entryPath)} "$@"`,
21568
21906
  ""
21569
21907
  ].join("\n"),
21570
21908
  { encoding: "utf8", mode: 493 }
21571
21909
  );
21572
21910
  }
21573
21911
  async function runPythonSidecarUpdatePlan(plan) {
21574
- const versionsDir = join12(plan.stateDir, "versions");
21575
- const tempDir = join12(
21912
+ const versionsDir = join13(plan.stateDir, "versions");
21913
+ const tempDir = join13(
21576
21914
  versionsDir,
21577
21915
  `.tmp-sdk-update-${process.pid}-${Date.now()}`
21578
21916
  );
21579
21917
  rmSync3(tempDir, { recursive: true, force: true });
21580
- mkdirSync8(tempDir, { recursive: true });
21581
- writeFileSync13(join12(tempDir, "package.json"), '{"private":true}\n', "utf8");
21918
+ mkdirSync9(tempDir, { recursive: true });
21919
+ writeFileSync14(join13(tempDir, "package.json"), '{"private":true}\n', "utf8");
21582
21920
  const env = {
21583
21921
  ...process.env,
21584
- PATH: `${dirname10(plan.nodeBin)}${process.platform === "win32" ? ";" : ":"}${process.env.PATH ?? ""}`
21922
+ PATH: `${dirname11(plan.nodeBin)}${process.platform === "win32" ? ";" : ":"}${process.env.PATH ?? ""}`
21585
21923
  };
21586
21924
  const installExitCode = await runCommand(
21587
21925
  plan.npmCommand,
@@ -21607,9 +21945,9 @@ async function runPythonSidecarUpdatePlan(plan) {
21607
21945
  rmSync3(tempDir, { recursive: true, force: true });
21608
21946
  return 1;
21609
21947
  }
21610
- const finalDir = join12(versionsDir, installedVersion);
21948
+ const finalDir = join13(versionsDir, installedVersion);
21611
21949
  const finalEntryPath = entryPathInVersionDir(finalDir);
21612
- if (existsSync10(finalEntryPath)) {
21950
+ if (existsSync11(finalEntryPath)) {
21613
21951
  rmSync3(tempDir, { recursive: true, force: true });
21614
21952
  } else {
21615
21953
  rmSync3(finalDir, { recursive: true, force: true });
@@ -21624,7 +21962,7 @@ async function runPythonSidecarUpdatePlan(plan) {
21624
21962
  return 1;
21625
21963
  }
21626
21964
  }
21627
- if (!existsSync10(finalEntryPath)) {
21965
+ if (!existsSync11(finalEntryPath)) {
21628
21966
  process.stderr.write(
21629
21967
  `Updated Deepline SDK CLI entrypoint missing: ${finalEntryPath}
21630
21968
  `
@@ -21638,28 +21976,28 @@ async function runPythonSidecarUpdatePlan(plan) {
21638
21976
  nodeBin: plan.nodeBin,
21639
21977
  entryPath: finalEntryPath
21640
21978
  });
21641
- writeFileSync13(
21642
- join12(plan.stateDir, ".version"),
21979
+ writeFileSync14(
21980
+ join13(plan.stateDir, ".version"),
21643
21981
  `${installedVersion}
21644
21982
  `,
21645
21983
  "utf8"
21646
21984
  );
21647
- writeFileSync13(
21648
- join12(plan.stateDir, ".install-method"),
21985
+ writeFileSync14(
21986
+ join13(plan.stateDir, ".install-method"),
21649
21987
  "python-sidecar\n",
21650
21988
  "utf8"
21651
21989
  );
21652
- writeFileSync13(
21653
- join12(plan.stateDir, ".command-path"),
21990
+ writeFileSync14(
21991
+ join13(plan.stateDir, ".command-path"),
21654
21992
  `${plan.sidecarPath}
21655
21993
  `,
21656
21994
  "utf8"
21657
21995
  );
21658
- writeFileSync13(join12(plan.stateDir, ".runner"), "node\n", "utf8");
21659
- writeFileSync13(join12(plan.stateDir, ".node-bin"), `${plan.nodeBin}
21996
+ writeFileSync14(join13(plan.stateDir, ".runner"), "node\n", "utf8");
21997
+ writeFileSync14(join13(plan.stateDir, ".node-bin"), `${plan.nodeBin}
21660
21998
  `, "utf8");
21661
- writeFileSync13(
21662
- join12(plan.stateDir, ".entry-path"),
21999
+ writeFileSync14(
22000
+ join13(plan.stateDir, ".entry-path"),
21663
22001
  `${finalEntryPath}
21664
22002
  `,
21665
22003
  "utf8"
@@ -21680,8 +22018,16 @@ async function runUpdatePlan(plan) {
21680
22018
  }
21681
22019
  return exitCode;
21682
22020
  }
21683
- async function handleUpdate(options) {
21684
- const plan = resolveUpdatePlan();
22021
+ function normalizeBaseUrl3(value) {
22022
+ return value.replace(/\/$/, "");
22023
+ }
22024
+ async function runUpdateCommand(options, dependencies = {}) {
22025
+ const detectBaseUrl = dependencies.detectBaseUrl ?? autoDetectBaseUrl;
22026
+ const resolvePlan = dependencies.resolvePlan ?? resolveUpdatePlan;
22027
+ const runPlan = dependencies.runPlan ?? runUpdatePlan;
22028
+ const syncSkills = dependencies.syncSkillsIfNeeded ?? syncSdkSkillsIfNeeded;
22029
+ const stderr = dependencies.stderr ?? process.stderr;
22030
+ const plan = resolvePlan();
21685
22031
  const render = {
21686
22032
  sections: [
21687
22033
  {
@@ -21717,11 +22063,14 @@ async function handleUpdate(options) {
21717
22063
  printCommandEnvelope({ ...plan, render }, { json: false });
21718
22064
  return 0;
21719
22065
  }
21720
- process.stderr.write(
21721
- `Updating Deepline SDK/CLI with: ${plan.manualCommand}
21722
- `
21723
- );
21724
- return runUpdatePlan(plan);
22066
+ stderr.write(`Updating Deepline SDK/CLI with: ${plan.manualCommand}
22067
+ `);
22068
+ const updateExitCode = await runPlan(plan);
22069
+ if (updateExitCode !== 0) {
22070
+ return updateExitCode;
22071
+ }
22072
+ await syncSkills(normalizeBaseUrl3(detectBaseUrl()));
22073
+ return 0;
21725
22074
  }
21726
22075
  function registerUpdateCommand(program) {
21727
22076
  program.command("update").description("Update the Deepline SDK/CLI.").addHelpText(
@@ -21740,151 +22089,49 @@ Examples:
21740
22089
  deepline update --json
21741
22090
  `
21742
22091
  ).option("--print-command", "Print the update command without running it").option("--json", "Emit the resolved update plan as JSON").action(async (options) => {
21743
- process.exitCode = await handleUpdate(options);
22092
+ process.exitCode = await runUpdateCommand(options);
21744
22093
  });
21745
22094
  }
21746
22095
 
21747
22096
  // ../shared_libs/cli/command-compatibility.json
21748
22097
  var command_compatibility_default = {
21749
22098
  enrich: {
21750
- family: "python",
21751
- label: "a legacy Python CLI enrichment command",
21752
- sdk_alternative: "Use `deepline plays ...` for durable workflows or `deepline tools execute ...` for one tool call."
21753
- },
21754
- session: {
21755
- family: "python",
21756
- label: "a legacy Python CLI session/playground command",
21757
- sdk_alternative: "Use `deepline sessions send ...` or `deepline sessions render ...` for transcript workflows."
21758
- },
21759
- workflows: {
21760
- family: "python",
21761
- label: "a legacy Python CLI workflow command",
21762
- sdk_alternative: "Use `deepline plays ...` in the SDK CLI."
21763
- },
21764
- events: {
21765
- family: "python",
21766
- label: "a legacy Python CLI event command"
21767
- },
21768
- plays: {
21769
- family: "sdk",
21770
- label: "an SDK CLI play command",
21771
- python_alternative: "Use `deepline workflows ...` only for legacy workflows."
21772
- },
21773
- runs: {
21774
- family: "sdk",
21775
- label: "an SDK CLI run inspection command"
21776
- },
21777
- sessions: {
21778
- family: "sdk",
21779
- label: "an SDK CLI session transcript command"
21780
- },
21781
- health: {
21782
- family: "sdk",
21783
- label: "an SDK CLI health command"
21784
- }
21785
- };
21786
-
21787
- // ../shared_libs/cli/install-commands.json
21788
- var install_commands_default = {
21789
- skills: {
21790
- index_path: "/.well-known/skills/index.json",
21791
- default_agents: [
21792
- "codex",
21793
- "claude-code",
21794
- "cursor",
21795
- "gemini-cli",
21796
- "antigravity"
21797
- ],
21798
- npx_binary: "npx",
21799
- npx_add_args_template: [
21800
- "--yes",
21801
- "skills",
21802
- "add",
21803
- "{skills_index_url}",
21804
- "--agent",
21805
- "{agents}",
21806
- "--global",
21807
- "--yes",
21808
- "--skill",
21809
- "{skill_name}",
21810
- "--full-depth"
21811
- ]
21812
- },
21813
- cli: {
21814
- legacy_python_shell_template: "curl -s {base_url}/api/v2/cli/install | bash",
21815
- sdk_npm_global: "npm install -g deepline@latest"
21816
- }
21817
- };
21818
-
21819
- // src/cli/install-commands.ts
21820
- var INSTALL_COMMANDS = install_commands_default;
21821
- var DEFAULT_V1_SKILL_NAMES = [
21822
- "build-tam",
21823
- "clay-to-deepline",
21824
- "deepline-analytics",
21825
- "deepline-feedback",
21826
- "deepline-gtm",
21827
- "deepline-quickstart",
21828
- "find-qualified-titles",
21829
- "linkedin-url-lookup",
21830
- "niche-signal-discovery",
21831
- "portfolio-prospecting",
21832
- "workflow-hello-world"
21833
- ];
21834
- var DEFAULT_SDK_SKILL_NAMES = [
21835
- ...DEFAULT_V1_SKILL_NAMES,
21836
- "deepline-plays"
21837
- ];
21838
- function normalizeBaseUrl2(baseUrl) {
21839
- return baseUrl.replace(/\/$/, "");
21840
- }
21841
- function renderTemplate(template, values) {
21842
- return template.replace(/\{([a-z_]+)\}/g, (match, key) => {
21843
- return values[key] ?? match;
21844
- });
21845
- }
21846
- function shellJoin(args) {
21847
- return args.join(" ");
21848
- }
21849
- function skillsIndexUrl(baseUrl) {
21850
- return `${normalizeBaseUrl2(baseUrl)}${INSTALL_COMMANDS.skills.index_path}`;
21851
- }
21852
- function buildSkillsAddArgs(baseUrl, skillName, options = {}) {
21853
- const skillNames = Array.isArray(skillName) ? skillName : [skillName];
21854
- const [firstSkillName, ...extraSkillNames] = skillNames;
21855
- const values = {
21856
- skills_index_url: skillsIndexUrl(baseUrl),
21857
- agents: INSTALL_COMMANDS.skills.default_agents.join(" "),
21858
- skill_name: firstSkillName ?? ""
21859
- };
21860
- const rendered = INSTALL_COMMANDS.skills.npx_add_args_template.flatMap(
21861
- (arg, index) => {
21862
- const next = index === 0 && options.firstArg ? options.firstArg : arg;
21863
- const value = renderTemplate(next, values);
21864
- if (arg === "{agents}") {
21865
- return INSTALL_COMMANDS.skills.default_agents;
21866
- }
21867
- if (arg === "{skill_name}") {
21868
- return [value, ...extraSkillNames.flatMap((name) => ["--skill", name])];
21869
- }
21870
- return value;
21871
- }
21872
- );
21873
- return rendered;
21874
- }
21875
- function skillsInstallCommand(baseUrl, skillName) {
21876
- return `${INSTALL_COMMANDS.skills.npx_binary} ${shellJoin(
21877
- buildSkillsAddArgs(baseUrl, skillName)
21878
- )}`;
21879
- }
21880
- function legacyPythonInstallCommand(baseUrl) {
21881
- return renderTemplate(INSTALL_COMMANDS.cli.legacy_python_shell_template, {
21882
- base_url: normalizeBaseUrl2(baseUrl)
21883
- });
21884
- }
21885
- function sdkNpmGlobalInstallCommand() {
21886
- return INSTALL_COMMANDS.cli.sdk_npm_global;
21887
- }
22099
+ family: "python",
22100
+ label: "a legacy Python CLI enrichment command",
22101
+ sdk_alternative: "Use `deepline plays ...` for durable workflows or `deepline tools execute ...` for one tool call."
22102
+ },
22103
+ session: {
22104
+ family: "python",
22105
+ label: "a legacy Python CLI session/playground command",
22106
+ sdk_alternative: "Use `deepline sessions send ...` or `deepline sessions render ...` for transcript workflows."
22107
+ },
22108
+ workflows: {
22109
+ family: "python",
22110
+ label: "a legacy Python CLI workflow command",
22111
+ sdk_alternative: "Use `deepline plays ...` in the SDK CLI."
22112
+ },
22113
+ events: {
22114
+ family: "python",
22115
+ label: "a legacy Python CLI event command"
22116
+ },
22117
+ plays: {
22118
+ family: "sdk",
22119
+ label: "an SDK CLI play command",
22120
+ python_alternative: "Use `deepline workflows ...` only for legacy workflows."
22121
+ },
22122
+ runs: {
22123
+ family: "sdk",
22124
+ label: "an SDK CLI run inspection command"
22125
+ },
22126
+ sessions: {
22127
+ family: "sdk",
22128
+ label: "an SDK CLI session transcript command"
22129
+ },
22130
+ health: {
22131
+ family: "sdk",
22132
+ label: "an SDK CLI health command"
22133
+ }
22134
+ };
21888
22135
 
21889
22136
  // src/cli/command-compatibility.ts
21890
22137
  var COMMAND_COMPATIBILITY = command_compatibility_default;
@@ -21939,7 +22186,7 @@ function unknownCommandNameFromMessage(message) {
21939
22186
  }
21940
22187
 
21941
22188
  // src/cli/self-update.ts
21942
- import { spawn as spawn3 } from "child_process";
22189
+ import { spawn as spawn4 } from "child_process";
21943
22190
  function envTruthy(name) {
21944
22191
  const value = process.env[name]?.trim().toLowerCase();
21945
22192
  return value === "1" || value === "true" || value === "yes";
@@ -21954,7 +22201,7 @@ function relaunchCurrentCommand(plan) {
21954
22201
  return new Promise((resolve13) => {
21955
22202
  const command = plan.kind === "python-sidecar" ? plan.sidecarPath : process.execPath;
21956
22203
  const args = plan.kind === "python-sidecar" ? process.argv.slice(2) : process.argv.slice(1);
21957
- const child = spawn3(command, args, {
22204
+ const child = spawn4(command, args, {
21958
22205
  stdio: "inherit",
21959
22206
  shell: process.platform === "win32",
21960
22207
  env: {
@@ -22009,238 +22256,6 @@ async function maybeAutoUpdateAndRelaunch(response) {
22009
22256
  return true;
22010
22257
  }
22011
22258
 
22012
- // src/cli/skills-sync.ts
22013
- import { spawn as spawn4, spawnSync as spawnSync2 } from "child_process";
22014
- import { existsSync as existsSync11, mkdirSync as mkdirSync9, readFileSync as readFileSync11, writeFileSync as writeFileSync14 } from "fs";
22015
- import { homedir as homedir11 } from "os";
22016
- import { dirname as dirname11, join as join13 } from "path";
22017
- var CHECK_TIMEOUT_MS2 = 3e3;
22018
- var SDK_PLAY_SKILL_NAME = "deepline-plays";
22019
- var attemptedSync = false;
22020
- function shouldSkipSkillsSync() {
22021
- const value = process.env.DEEPLINE_SKIP_SKILLS_SYNC?.trim().toLowerCase();
22022
- return value === "1" || value === "true" || value === "yes" || value === "on";
22023
- }
22024
- function activePluginSkillsDir() {
22025
- const pluginMode = process.env.DEEPLINE_PLUGIN_MODE?.trim().toLowerCase();
22026
- if (pluginMode !== "true" && pluginMode !== "1" && pluginMode !== "yes" && pluginMode !== "on") {
22027
- return "";
22028
- }
22029
- const dir = process.env.DEEPLINE_PLUGIN_SKILLS_DIR?.trim() ?? "";
22030
- return dir && existsSync11(dir) ? dir : "";
22031
- }
22032
- function readPluginSkillsVersion() {
22033
- const dir = activePluginSkillsDir();
22034
- if (!dir) return "";
22035
- try {
22036
- return readFileSync11(join13(dir, ".version"), "utf-8").trim();
22037
- } catch {
22038
- return "";
22039
- }
22040
- }
22041
- function sdkSkillsVersionPath(baseUrl) {
22042
- const home = process.env.HOME?.trim() || homedir11();
22043
- return join13(
22044
- home,
22045
- ".local",
22046
- "deepline",
22047
- baseUrlSlug(baseUrl),
22048
- "sdk-skills",
22049
- ".version"
22050
- );
22051
- }
22052
- function readLocalSkillsVersion(baseUrl) {
22053
- const pluginVersion = readPluginSkillsVersion();
22054
- if (pluginVersion) return pluginVersion;
22055
- const path = sdkSkillsVersionPath(baseUrl);
22056
- if (!existsSync11(path)) return "";
22057
- try {
22058
- return readFileSync11(path, "utf-8").trim();
22059
- } catch {
22060
- return "";
22061
- }
22062
- }
22063
- function writeLocalSkillsVersion(baseUrl, version) {
22064
- const path = sdkSkillsVersionPath(baseUrl);
22065
- mkdirSync9(dirname11(path), { recursive: true });
22066
- writeFileSync14(path, `${version}
22067
- `, "utf-8");
22068
- }
22069
- function sortedUniqueSkillNames(names) {
22070
- return [...new Set(names.map((name) => name.trim()).filter(Boolean))].sort(
22071
- (a, b) => a.localeCompare(b)
22072
- );
22073
- }
22074
- async function fetchV1SkillNames(baseUrl) {
22075
- const controller = new AbortController();
22076
- const timeout = setTimeout(() => controller.abort(), CHECK_TIMEOUT_MS2);
22077
- try {
22078
- const response = await fetch(
22079
- new URL("/.well-known/skills/index.json", baseUrl),
22080
- { signal: controller.signal }
22081
- );
22082
- if (!response.ok) return [];
22083
- const data = await response.json().catch(() => null);
22084
- const names = (data?.skills ?? []).filter((skill) => skill.install_surface === "v1").map((skill) => skill.name).filter(
22085
- (name) => typeof name === "string" && name.length > 0
22086
- );
22087
- return sortedUniqueSkillNames(names);
22088
- } catch {
22089
- return [];
22090
- } finally {
22091
- clearTimeout(timeout);
22092
- }
22093
- }
22094
- function buildSdkSkillNames(v1SkillNames) {
22095
- return sortedUniqueSkillNames([...v1SkillNames, SDK_PLAY_SKILL_NAME]);
22096
- }
22097
- async function fetchSkillsUpdate(baseUrl, localVersion) {
22098
- const controller = new AbortController();
22099
- const timeout = setTimeout(() => controller.abort(), CHECK_TIMEOUT_MS2);
22100
- try {
22101
- const response = await fetch(new URL("/api/v2/cli/update-check", baseUrl), {
22102
- method: "POST",
22103
- headers: { "Content-Type": "application/json" },
22104
- body: JSON.stringify({
22105
- skills: {
22106
- version: localVersion
22107
- }
22108
- }),
22109
- signal: controller.signal
22110
- });
22111
- if (!response.ok) return null;
22112
- const data = await response.json().catch(() => null);
22113
- const skills = data?.skills;
22114
- if (!skills) return null;
22115
- return {
22116
- needsUpdate: skills.needs_update === true,
22117
- remoteVersion: typeof skills.remote?.version === "string" ? skills.remote.version.trim() : ""
22118
- };
22119
- } catch {
22120
- return null;
22121
- } finally {
22122
- clearTimeout(timeout);
22123
- }
22124
- }
22125
- function buildSkillsInstallArgs(baseUrl, skillNames = DEFAULT_SDK_SKILL_NAMES) {
22126
- return buildSkillsAddArgs(baseUrl, sortedUniqueSkillNames(skillNames));
22127
- }
22128
- function buildBunxSkillsInstallArgs(baseUrl, skillNames) {
22129
- return buildSkillsAddArgs(baseUrl, sortedUniqueSkillNames(skillNames), {
22130
- firstArg: "--bun"
22131
- });
22132
- }
22133
- function hasCommand(command) {
22134
- const result = spawnSync2(command, ["--version"], {
22135
- stdio: "ignore",
22136
- shell: process.platform === "win32"
22137
- });
22138
- return result.status === 0;
22139
- }
22140
- function shellQuote4(arg) {
22141
- return `'${arg.replace(/'/g, `'\\''`)}'`;
22142
- }
22143
- function resolveSkillsInstallCommands(baseUrl, skillNames = DEFAULT_SDK_SKILL_NAMES) {
22144
- const npxArgs = buildSkillsInstallArgs(baseUrl, skillNames);
22145
- const npxInstall = {
22146
- command: "npx",
22147
- args: npxArgs,
22148
- manualCommand: `npx ${npxArgs.map(shellQuote4).join(" ")}`
22149
- };
22150
- if (hasCommand("bunx")) {
22151
- const bunxArgs = buildBunxSkillsInstallArgs(baseUrl, skillNames);
22152
- return [
22153
- {
22154
- command: "bunx",
22155
- args: bunxArgs,
22156
- manualCommand: `bunx ${bunxArgs.map(shellQuote4).join(" ")}`
22157
- },
22158
- npxInstall
22159
- ];
22160
- }
22161
- return [npxInstall];
22162
- }
22163
- function runOneSkillsInstall(install) {
22164
- return new Promise((resolve13) => {
22165
- const child = spawn4(install.command, install.args, {
22166
- stdio: ["ignore", "ignore", "pipe"],
22167
- env: process.env
22168
- });
22169
- let stderr = "";
22170
- child.stderr.on("data", (chunk) => {
22171
- stderr += chunk.toString("utf-8");
22172
- });
22173
- child.on("error", (error) => {
22174
- resolve13({
22175
- ok: false,
22176
- detail: `failed to start ${install.command}: ${error.message}`,
22177
- manualCommand: install.manualCommand
22178
- });
22179
- });
22180
- child.on("close", (code) => {
22181
- if (code === 0) {
22182
- resolve13({ ok: true, detail: "", manualCommand: install.manualCommand });
22183
- return;
22184
- }
22185
- const detail = stderr.trim();
22186
- resolve13({
22187
- ok: false,
22188
- detail: detail ? `${install.command}: ${detail}` : `${install.command} exited ${code}`,
22189
- manualCommand: install.manualCommand
22190
- });
22191
- });
22192
- });
22193
- }
22194
- async function runSkillsInstall(baseUrl, skillNames) {
22195
- const failures = [];
22196
- for (const install of resolveSkillsInstallCommands(baseUrl, skillNames)) {
22197
- const result = await runOneSkillsInstall(install);
22198
- if (result.ok) return true;
22199
- failures.push(result);
22200
- }
22201
- const details = failures.map((failure) => failure.detail).filter(Boolean).join("\n");
22202
- const manualCommand = failures.at(-1)?.manualCommand;
22203
- process.stderr.write(
22204
- `SDK skills sync failed${details ? `:
22205
- ${details}` : ""}
22206
- ` + (manualCommand ? `Run manually: ${manualCommand}
22207
- ` : "")
22208
- );
22209
- return false;
22210
- }
22211
- function writeSdkSkillsStatusLine(line) {
22212
- const progress = getActiveCliProgress();
22213
- if (progress) {
22214
- progress.writeLine(line);
22215
- return;
22216
- }
22217
- process.stderr.write(`${line}
22218
- `);
22219
- }
22220
- async function syncSdkSkillsIfNeeded(baseUrl) {
22221
- if (attemptedSync || shouldSkipSkillsSync()) return;
22222
- attemptedSync = true;
22223
- const usingPluginSkills = Boolean(activePluginSkillsDir());
22224
- const localVersion = readLocalSkillsVersion(baseUrl);
22225
- const update = await fetchSkillsUpdate(baseUrl, localVersion);
22226
- if (usingPluginSkills) {
22227
- return;
22228
- }
22229
- if (!update?.needsUpdate || !update.remoteVersion) {
22230
- return;
22231
- }
22232
- const remoteSkillNames = await fetchV1SkillNames(baseUrl);
22233
- const skillNames = buildSdkSkillNames(
22234
- remoteSkillNames.length > 0 ? remoteSkillNames : DEFAULT_SDK_SKILL_NAMES
22235
- );
22236
- if (skillNames.length === 0) return;
22237
- writeSdkSkillsStatusLine("Deepline skills changed; syncing agent skills...");
22238
- const installed = await runSkillsInstall(baseUrl, skillNames);
22239
- if (!installed) return;
22240
- writeLocalSkillsVersion(baseUrl, update.remoteVersion);
22241
- writeSdkSkillsStatusLine("Deepline agent skills are up to date.");
22242
- }
22243
-
22244
22259
  // src/cli/failure-reporting.ts
22245
22260
  import { hostname as hostname2, platform as platform2, release } from "os";
22246
22261
  var FAILURE_REPORT_DISABLE_ENV = "DEEPLINE_DISABLE_FAILURE_REPORTING";