@cleocode/adapters 2026.11.4 → 2026.11.5-canary.1

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.
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "schema": 2,
3
- "sourceHash": "81fd86b2bcffe2d532b1f5064c53eca0d8826d7e249dc78964e0e00a2850c644"
3
+ "sourceHash": "dff0c9f07c3a2410ddeedaaf9118a168f418ff780d355c6b0376c6b93980cbb6"
4
4
  }
package/dist/index.js CHANGED
@@ -1216,8 +1216,12 @@ var init_orca_execution = __esm({
1216
1216
  /** Full receipts retain effects, residual resources and recovery advice. */
1217
1217
  lastReceipt: z4.string().nullable(),
1218
1218
  lastError: z4.string().nullable(),
1219
- /** Confirmed pre-dispatch refusal; never inferred from a process exit. */
1220
- startRefusal: z4.literal("agent_unconfigured").optional(),
1219
+ /**
1220
+ * Confirmed pre-dispatch refusal; never inferred from a process exit.
1221
+ * `agent_unconfigured` is Orca's own refusal; `not_launched` means a first
1222
+ * start failed before CLEO sent worker-start, so no Orca request exists.
1223
+ */
1224
+ startRefusal: z4.enum(["agent_unconfigured", "not_launched"]).optional(),
1221
1225
  observedAt: z4.string()
1222
1226
  });
1223
1227
  orcaWorkerDoneSchema = z4.object({
@@ -47254,12 +47258,13 @@ import {
47254
47258
  lstatSync,
47255
47259
  readdirSync as readdirSync4,
47256
47260
  readFileSync as readFileSync7,
47261
+ readlinkSync,
47257
47262
  realpathSync as realpathSync3,
47258
47263
  statSync as statSync3
47259
47264
  } from "node:fs";
47260
47265
  import { writeFile as writeFile2 } from "node:fs/promises";
47261
47266
  import { homedir as homedir5 } from "node:os";
47262
- import { basename as basename3, dirname as dirname7, isAbsolute as isAbsolute3, join as join10, relative as relative2, resolve as resolve5 } from "node:path";
47267
+ import { basename as basename3, dirname as dirname7, isAbsolute as isAbsolute3, join as join10, relative as relative2, resolve as resolve5, win32 } from "node:path";
47263
47268
  import {
47264
47269
  LEAD_MAILBOX_MCP_SERVER as LEAD_MAILBOX_MCP_SERVER2,
47265
47270
  LEAD_RUNNER_MCP_SERVER as LEAD_RUNNER_MCP_SERVER2,
@@ -47287,19 +47292,238 @@ function readJson(file2) {
47287
47292
  return null;
47288
47293
  }
47289
47294
  }
47290
- function linkedWorktreeTrustRoot(dir) {
47295
+ function isEnoent(err) {
47296
+ return err instanceof Error && "code" in err && err.code === "ENOENT";
47297
+ }
47298
+ function homeIsAutomount() {
47299
+ try {
47300
+ let mapped = false;
47301
+ try {
47302
+ mapped = readFileSync7("/etc/auto_master", "utf8").split("\n").some((line) => {
47303
+ const fields = line.replace(/#.*$/, "").trim().split(/\s+/);
47304
+ return fields.length >= 2 && fields[0]?.toLowerCase() === "/home";
47305
+ });
47306
+ } catch (err) {
47307
+ if (!isEnoent(err)) throw err;
47308
+ }
47309
+ if (mapped) return true;
47310
+ try {
47311
+ return statSync3("/home").dev !== statSync3("/Users").dev;
47312
+ } catch (err) {
47313
+ if (isEnoent(err)) return true;
47314
+ throw err;
47315
+ }
47316
+ } catch {
47317
+ return true;
47318
+ }
47319
+ }
47320
+ function claudePathHost(home = homedir5()) {
47321
+ const darwin = process.platform === "darwin";
47322
+ if (darwin) homeAutomountMemo ??= homeIsAutomount();
47323
+ return { darwin, homeAutomount: homeAutomountMemo ?? false, home };
47324
+ }
47325
+ function walkParts(path, visit2) {
47326
+ if (!path.startsWith("/")) return null;
47327
+ const parts = [];
47328
+ for (const part of path.split("/")) {
47329
+ if (part === "" || part === ".") continue;
47330
+ if (part === "..") {
47331
+ parts.pop();
47332
+ continue;
47333
+ }
47334
+ parts.push(part);
47335
+ visit2?.(parts);
47336
+ }
47337
+ return parts;
47338
+ }
47339
+ function isNetMount(parts) {
47340
+ const [first = "", second = ""] = parts;
47341
+ return parts.length === 2 && foldVisible(first) === "net" || parts.length === 3 && foldVisible(first) === "network" && foldVisible(second) === "servers";
47342
+ }
47343
+ function netHost(path) {
47344
+ let host = null;
47345
+ walkParts(path, (parts) => {
47346
+ if (host === null && isNetMount(parts)) host = lowerAscii(parts.at(-1) ?? "");
47347
+ });
47348
+ return host;
47349
+ }
47350
+ function firstPartIs(path, test) {
47351
+ let first;
47352
+ walkParts(path, (parts) => {
47353
+ if (parts.length === 1 && first === void 0 && test(parts[0] ?? "")) first = parts[0];
47354
+ });
47355
+ return first !== void 0;
47356
+ }
47357
+ function dataVolumeAlias(path) {
47358
+ const parts = path.split("/");
47359
+ const [root, system = "", volumes = "", data = ""] = parts;
47360
+ if (parts.length < 5 || root !== "" || foldCase(system) !== "system" || foldCase(volumes) !== "volumes" || foldCase(data) !== "data")
47361
+ return path;
47362
+ const rest = parts.slice(4);
47363
+ for (const link of FIRMLINKS) {
47364
+ const linkParts = link.split("/");
47365
+ if (rest.length >= linkParts.length && linkParts.every((part, i) => foldCase(rest[i] ?? "") === foldCase(part)))
47366
+ return `/${rest.join("/")}`;
47367
+ }
47368
+ return path;
47369
+ }
47370
+ function automountPrefixes(path, host) {
47371
+ const complete = [];
47372
+ const partial2 = [];
47373
+ walkParts(path, (parts) => {
47374
+ if (parts.length > 6) return;
47375
+ const spelled = `/${parts.join("/")}`;
47376
+ const at = (host.darwin ? dataVolumeAlias(spelled) : spelled).split("/").filter(Boolean);
47377
+ const [first = "", second = "", third = ""] = at;
47378
+ if (first.toLowerCase() === "network") {
47379
+ if (at.length === 1) partial2.push("/network/");
47380
+ else if (at.length === 2) partial2.push(`/network/${lowerAscii(second)}/`);
47381
+ else if (at.length === 3)
47382
+ complete.push(`/network/${lowerAscii(second)}/${lowerAscii(third)}`);
47383
+ } else if (host.homeAutomount && first.toLowerCase() === "home" && at.length === 2) {
47384
+ complete.push(`/home/${second}`);
47385
+ }
47386
+ });
47387
+ return { complete, partial: partial2 };
47388
+ }
47389
+ function reachesAutomount(path, host) {
47390
+ if (!host.darwin) return false;
47391
+ if (underNetwork(path) || underVolfs(path)) return true;
47392
+ if (!path.startsWith("/")) return false;
47393
+ const { complete, partial: partial2 } = automountPrefixes(path, host);
47394
+ if (partial2.length > 0 || complete.some((prefix) => prefix.startsWith("/network/"))) return true;
47395
+ const homes = complete.filter((prefix) => prefix.startsWith("/home/"));
47396
+ if (homes.length === 0) return false;
47397
+ const own = /^\/home\/([^/]+)/.exec(dataVolumeAlias(host.home));
47398
+ const ownHome = own ? `/home/${own[1]}` : null;
47399
+ return homes.some((prefix) => prefix !== ownHome);
47400
+ }
47401
+ function leavesAutomount(path, base, host) {
47402
+ if (!reachesAutomount(path, host)) return false;
47403
+ const own = automountPrefixes(base, host).complete[0] ?? null;
47404
+ const { complete, partial: partial2 } = automountPrefixes(path, host);
47405
+ if (complete.length === 0 && partial2.length === 0 || own === null) return true;
47406
+ return complete.some((prefix) => prefix !== own) || partial2.some((prefix) => !own.startsWith(prefix));
47407
+ }
47408
+ function uncServer(path) {
47409
+ if (/^[\\/]{2}[?.][\\/](?!unc[\\/])/i.test(path)) return null;
47410
+ const server = /^[\\/]{2}(?:[?.][\\/]unc[\\/])?([^\\/]+)/i.exec(path)?.[1];
47411
+ return server === void 0 ? null : lowerAscii(server);
47412
+ }
47413
+ function uncEscape(path, base) {
47414
+ if (!isUncLike(path)) return false;
47415
+ if (/^[\\/]{2}[?.][\\/]/.test(path) || isDosDevice(path)) return true;
47416
+ if (/(^|[\\/])\.{1,2}[. ]*([\\/]|$)/.test(path)) return true;
47417
+ const server = uncServer(path);
47418
+ return server === null || server !== uncServer(base);
47419
+ }
47420
+ function claudeUnsafePath(text, base, host = claudePathHost()) {
47421
+ const resolved = resolve5(base, text);
47422
+ if (uncEscape(text, base) || uncEscape(resolved, base)) return true;
47423
+ const baseHost = netHost(base);
47424
+ for (const path of [text, resolved]) {
47425
+ const pathHost = netHost(path);
47426
+ if (pathHost !== null && pathHost !== baseHost) return true;
47427
+ if (underNetwork(path) || isNetRoot(path) || underVolfs(path)) return true;
47428
+ if (leavesAutomount(path, base, host)) return true;
47429
+ }
47430
+ return false;
47431
+ }
47432
+ function componentEscapes(path, anchor, host) {
47433
+ if (underVolfs(path)) return true;
47434
+ const pathHost = netHost(path);
47435
+ if (pathHost !== null && pathHost !== netHost(anchor)) return true;
47436
+ return leavesAutomount(path, anchor, host);
47437
+ }
47438
+ function pathKind(path) {
47439
+ try {
47440
+ const stat2 = lstatSync(path);
47441
+ if (stat2.isSymbolicLink()) return "symlink";
47442
+ return stat2.isFile() ? "file" : stat2.isDirectory() ? "dir" : "special";
47443
+ } catch (err) {
47444
+ const code = err instanceof Error && "code" in err ? err.code : void 0;
47445
+ return code === "ENOENT" || code === "ENOTDIR" ? "absent" : "other";
47446
+ }
47447
+ }
47448
+ function linkText(path) {
47449
+ try {
47450
+ const raw = readlinkSync(path, { encoding: "buffer" });
47451
+ const text = raw.toString("utf8");
47452
+ return text.includes("\0") || !Buffer.from(text, "utf8").equals(raw) ? null : text;
47453
+ } catch {
47454
+ return null;
47455
+ }
47456
+ }
47457
+ function walksSafely(path, anchor, host, hops = 40) {
47458
+ if (hops <= 0) return false;
47459
+ const rooted = path.startsWith("/");
47460
+ const parts = path.slice(rooted ? 1 : 0).split(/\/+/);
47461
+ let at = rooted ? "/" : "";
47462
+ for (const [index, part] of parts.entries()) {
47463
+ if (part === "" || part === ".") continue;
47464
+ if (part === "..") {
47465
+ at = dirname7(at);
47466
+ continue;
47467
+ }
47468
+ at = join10(at, part);
47469
+ if (componentEscapes(at, anchor, host) || underNetwork(at)) return false;
47470
+ const kind = pathKind(at);
47471
+ if (kind === "other" || kind === "special") return false;
47472
+ if (kind === "symlink") {
47473
+ const target = linkText(at);
47474
+ if (target === null || claudeUnsafePath(target, dirname7(at), host)) return false;
47475
+ const base = target.startsWith("/") ? target : `${dirname7(at)}/${target}`;
47476
+ const rest = parts.slice(index + 1).join("/");
47477
+ const next = rest ? base.endsWith("/") ? base + rest : `${base}/${rest}` : base;
47478
+ return walksSafely(next, anchor, host, hops - 1);
47479
+ }
47480
+ }
47481
+ return true;
47482
+ }
47483
+ function textWalksSafely(text, base, host, anchor = base) {
47484
+ const written = text.startsWith("/") ? text : `${base}/${text}`;
47485
+ const resolved = resolve5(base, text);
47486
+ return walksSafely(written, anchor, host) && (resolved === written || walksSafely(resolved, anchor, host));
47487
+ }
47488
+ function readGitMetaFile(gitDir, name15, host) {
47489
+ const file2 = join10(gitDir, name15);
47490
+ if (!walksSafely(file2, gitDir, host) || ["symlink", "special", "other"].includes(pathKind(file2)))
47491
+ return null;
47492
+ return readFileSync7(file2, "utf8").trim();
47493
+ }
47494
+ function usableGitEntry(path, base, host) {
47495
+ try {
47496
+ const entry = lstatSync(path);
47497
+ if (!entry.isSymbolicLink()) return entry.isDirectory() || entry.isFile();
47498
+ const target = linkText(path);
47499
+ if (target === null || claudeUnsafePath(target, base, host) || !textWalksSafely(target, base, host))
47500
+ return false;
47501
+ const resolved = statSync3(path);
47502
+ return resolved.isDirectory() || resolved.isFile();
47503
+ } catch {
47504
+ return false;
47505
+ }
47506
+ }
47507
+ function linkedWorktreeTrustRoot(dir, home) {
47508
+ const host = claudePathHost(home);
47291
47509
  const link = readFileSync7(join10(dir, ".git"), "utf8").trim();
47292
47510
  if (!link.startsWith("gitdir:")) return null;
47293
- const gitDir = realpathSync3(resolve5(dir, link.slice(7).trim()));
47294
- const commonFile = join10(gitDir, "commondir");
47295
- const backFile = join10(gitDir, "gitdir");
47296
- if (![commonFile, backFile].every((file2) => lstatSync(file2, { throwIfNoEntry: false })?.isFile()))
47511
+ const gitText = link.slice(7).trim();
47512
+ if (claudeUnsafePath(gitText, dir, host) || !textWalksSafely(gitText, dir, host)) return null;
47513
+ const gitDir = resolve5(dir, gitText);
47514
+ const common = readGitMetaFile(gitDir, "commondir", host);
47515
+ if (common === null || claudeUnsafePath(common, gitDir, host) || !textWalksSafely(common, gitDir, host))
47516
+ return null;
47517
+ const commonDir = resolve5(gitDir, common);
47518
+ if (dirname7(gitDir) !== join10(commonDir, "worktrees")) return null;
47519
+ const back = readGitMetaFile(gitDir, "gitdir", host);
47520
+ if (back === null || claudeUnsafePath(back, dir, host) || !textWalksSafely(back, gitDir, host, dir))
47297
47521
  return null;
47298
- const commonDir = realpathSync3(resolve5(gitDir, readFileSync7(commonFile, "utf8").trim()));
47299
- if (dirname7(gitDir) !== join10(commonDir, "worktrees") || realpathSync3(resolve5(gitDir, readFileSync7(backFile, "utf8").trim())) !== join10(dir, ".git"))
47522
+ if ([dir, gitDir, back, commonDir].some((path) => path.includes("\\"))) return null;
47523
+ if (realpathSync3(resolve5(gitDir, back)) !== join10(realpathSync3(dir), ".git")) return null;
47524
+ if (basename3(commonDir) !== ".git" && usableGitEntry(join10(commonDir, ".git"), commonDir, host))
47300
47525
  return null;
47301
- if (basename3(commonDir) !== ".git" && existsSync8(join10(commonDir, ".git"))) return null;
47302
- return basename3(commonDir) === ".git" ? dirname7(commonDir) : commonDir;
47526
+ return (basename3(commonDir) === ".git" ? dirname7(commonDir) : commonDir).normalize("NFC");
47303
47527
  }
47304
47528
  function envTruthy(value) {
47305
47529
  return ["1", "true", "yes", "on"].includes((value ?? "").trim().toLowerCase());
@@ -47358,7 +47582,7 @@ function requireLeadProjectTrust(projectDir, env = process.env) {
47358
47582
  if (trusted(dir)) return configPath;
47359
47583
  const gitEntry = lstatSync(join10(dir, ".git"), { throwIfNoEntry: false });
47360
47584
  if (gitEntry || dirname7(dir) === dir) {
47361
- const mainRoot = gitEntry?.isFile() ? linkedWorktreeTrustRoot(dir) : null;
47585
+ const mainRoot = gitEntry?.isFile() ? linkedWorktreeTrustRoot(dir, home) : null;
47362
47586
  if (mainRoot && mainRoot !== realpathSync3(home) && trusted(mainRoot)) return configPath;
47363
47587
  break;
47364
47588
  }
@@ -47446,12 +47670,42 @@ async function prepareLeadMcp(dir, projectDir, opts = {}) {
47446
47670
  }
47447
47671
  };
47448
47672
  }
47449
- var RUNNER_IDENTITY_ENV, LEAD_TRUST_ENV_KEYS, LEAD_MCP_FILE;
47673
+ var RUNNER_IDENTITY_ENV, homeAutomountMemo, lowerAscii, foldCase, foldVisible, underNetwork, underVolfs, isNetRoot, FIRMLINKS, DOS_DEVICE, isDosDevice, isUncLike, LEAD_TRUST_ENV_KEYS, LEAD_MCP_FILE;
47450
47674
  var init_lead_mcp = __esm({
47451
47675
  "packages/adapters/src/providers/claude-code/lead-mcp.ts"() {
47452
47676
  "use strict";
47453
47677
  init_orca_execution2();
47454
47678
  RUNNER_IDENTITY_ENV = ["CLEO_SESSION_ID", "CLEO_AGENT_ID", "CLEO_AGENT_ROLE"];
47679
+ lowerAscii = (text) => text.replace(/[A-Z]/g, (c) => c.toLowerCase());
47680
+ foldCase = (text) => text.toUpperCase().toLowerCase();
47681
+ foldVisible = (text) => foldCase(text.replace(/[‌-‏‪-‮-]/g, ""));
47682
+ underNetwork = (path) => firstPartIs(path, (part) => part.toLowerCase() === "network");
47683
+ underVolfs = (path) => /\/\.(?:vol|file|nofollow|resolve)(?:\/|$)/i.test(path) && firstPartIs(path, (part) => /^\.(?:vol|file|nofollow|resolve)$/i.test(part));
47684
+ isNetRoot = (path) => {
47685
+ const parts = walkParts(path);
47686
+ return parts?.length === 1 && parts[0]?.toLowerCase() === "net";
47687
+ };
47688
+ FIRMLINKS = [
47689
+ "usr/local",
47690
+ "usr/libexec/cups",
47691
+ "usr/share/snmp",
47692
+ "AppleInternal",
47693
+ "Applications",
47694
+ "Library",
47695
+ "Users",
47696
+ "Volumes",
47697
+ "cores",
47698
+ "home",
47699
+ "media",
47700
+ "mnt",
47701
+ "opt",
47702
+ "pkg",
47703
+ "private",
47704
+ "sw"
47705
+ ];
47706
+ DOS_DEVICE = /^[\\/]\?\?[\\/]/;
47707
+ isDosDevice = (path) => DOS_DEVICE.test(path) || path.includes("??") && DOS_DEVICE.test(win32.normalize(path));
47708
+ isUncLike = (path) => /^[\\/]{2}/.test(path) || isDosDevice(path);
47455
47709
  LEAD_TRUST_ENV_KEYS = [
47456
47710
  "HOME",
47457
47711
  "USERPROFILE",