deepline 0.1.126 → 0.1.128

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