@cleocode/adapters 2026.11.3 → 2026.11.4-rc.ci.719

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": "e1f97297a2acfe976f0157621b8e42f200ccb848ab44cd1a280ac7bfbf119226"
3
+ "sourceHash": "81fd86b2bcffe2d532b1f5064c53eca0d8826d7e249dc78964e0e00a2850c644"
4
4
  }
package/dist/index.js CHANGED
@@ -47249,15 +47249,23 @@ var init_prompt_file = __esm({
47249
47249
  });
47250
47250
 
47251
47251
  // packages/adapters/src/providers/claude-code/lead-mcp.ts
47252
- import { existsSync as existsSync8, readFileSync as readFileSync7, realpathSync as realpathSync3 } from "node:fs";
47252
+ import {
47253
+ existsSync as existsSync8,
47254
+ lstatSync,
47255
+ readdirSync as readdirSync4,
47256
+ readFileSync as readFileSync7,
47257
+ realpathSync as realpathSync3,
47258
+ statSync as statSync3
47259
+ } from "node:fs";
47253
47260
  import { writeFile as writeFile2 } from "node:fs/promises";
47254
47261
  import { homedir as homedir5 } from "node:os";
47255
- import { basename as basename3, isAbsolute as isAbsolute3, join as join10, relative as relative2, resolve as resolve5 } from "node:path";
47262
+ import { basename as basename3, dirname as dirname7, isAbsolute as isAbsolute3, join as join10, relative as relative2, resolve as resolve5 } from "node:path";
47256
47263
  import {
47257
47264
  LEAD_MAILBOX_MCP_SERVER as LEAD_MAILBOX_MCP_SERVER2,
47258
47265
  LEAD_RUNNER_MCP_SERVER as LEAD_RUNNER_MCP_SERVER2,
47259
47266
  LEAD_RUNNER_TOOL as LEAD_RUNNER_TOOL2
47260
47267
  } from "@cleocode/contracts/operations/orchestrate.js";
47268
+ import { claudeCodeTrustConfigSchema } from "@cleocode/contracts/provider-paths.js";
47261
47269
  function runnerEntry(identityEnv, cleoBin) {
47262
47270
  const env = {};
47263
47271
  for (const key of RUNNER_IDENTITY_ENV) {
@@ -47279,6 +47287,92 @@ function readJson(file2) {
47279
47287
  return null;
47280
47288
  }
47281
47289
  }
47290
+ function linkedWorktreeTrustRoot(dir) {
47291
+ const link = readFileSync7(join10(dir, ".git"), "utf8").trim();
47292
+ 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()))
47297
+ 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"))
47300
+ return null;
47301
+ if (basename3(commonDir) !== ".git" && existsSync8(join10(commonDir, ".git"))) return null;
47302
+ return basename3(commonDir) === ".git" ? dirname7(commonDir) : commonDir;
47303
+ }
47304
+ function envTruthy(value) {
47305
+ return ["1", "true", "yes", "on"].includes((value ?? "").trim().toLowerCase());
47306
+ }
47307
+ function claudeUserConfigPath(projectDir, home, env) {
47308
+ const dirVar = env.CLAUDE_CONFIG_DIR;
47309
+ const configDir = dirVar !== void 0 ? resolve5(projectDir, dirVar) : join10(home, ".claude");
47310
+ const migrated = join10(configDir.normalize("NFC"), ".config.json");
47311
+ const suffix = env.CLAUDE_CODE_CUSTOM_OAUTH_URL ? "-custom-oauth" : "";
47312
+ const legacy = join10(dirVar ? resolve5(projectDir, dirVar) : home, `.claude${suffix}.json`);
47313
+ const enoent = (err) => err instanceof Error && "code" in err && err.code === "ENOENT";
47314
+ try {
47315
+ const stat2 = statSync3(migrated);
47316
+ if (!stat2.isFile() || stat2.size === 0 && (stat2.mode & 146) === 0) return legacy;
47317
+ let legacyStat;
47318
+ try {
47319
+ legacyStat = statSync3(legacy);
47320
+ } catch (err) {
47321
+ if (enoent(err) || stat2.size === 0) return migrated;
47322
+ }
47323
+ if (stat2.size === 0) return legacy;
47324
+ if (legacyStat && (!legacyStat.isFile() || legacyStat.size === 0)) return migrated;
47325
+ try {
47326
+ if (!readdirSync4(dirname7(migrated)).includes(basename3(migrated))) return legacy;
47327
+ } catch (err) {
47328
+ if (enoent(err)) return legacy;
47329
+ }
47330
+ return migrated;
47331
+ } catch {
47332
+ return legacy;
47333
+ }
47334
+ }
47335
+ function orcaLeadEnv(spawnEnv, base = process.env) {
47336
+ const env = { HOME: base.HOME || homedir5(), ...spawnEnv };
47337
+ return { env, unset: LEAD_TRUST_ENV_KEYS.filter((key) => !(key in env)) };
47338
+ }
47339
+ function requireLeadProjectTrust(projectDir, env = process.env) {
47340
+ const home = resolve5(projectDir, env.HOME || env.USERPROFILE || homedir5());
47341
+ const configPath = claudeUserConfigPath(projectDir, home, env);
47342
+ let fixPrefix = "";
47343
+ try {
47344
+ const config2 = claudeCodeTrustConfigSchema.safeParse(readJson(configPath));
47345
+ let dir = realpathSync3(projectDir);
47346
+ if (env.CLAUDE_CODE_IGNORE_PERSISTED_TRUST) {
47347
+ fixPrefix = "Unset CLAUDE_CODE_IGNORE_PERSISTED_TRUST in the lead environment. ";
47348
+ } else if (envTruthy(env.CLAUDE_CODE_SANDBOXED)) {
47349
+ return configPath;
47350
+ } else if (dir === realpathSync3(home)) {
47351
+ fixPrefix = "Choose a project subdirectory: Claude Code never persists home-folder trust. ";
47352
+ } else if (config2.success) {
47353
+ const trusted = (folder) => {
47354
+ const key = (process.platform === "win32" ? folder.replaceAll("\\", "/") : folder).normalize("NFC");
47355
+ return config2.data.projects?.[key]?.hasTrustDialogAccepted === true;
47356
+ };
47357
+ for (; ; ) {
47358
+ if (trusted(dir)) return configPath;
47359
+ const gitEntry = lstatSync(join10(dir, ".git"), { throwIfNoEntry: false });
47360
+ if (gitEntry || dirname7(dir) === dir) {
47361
+ const mainRoot = gitEntry?.isFile() ? linkedWorktreeTrustRoot(dir) : null;
47362
+ if (mainRoot && mainRoot !== realpathSync3(home) && trusted(mainRoot)) return configPath;
47363
+ break;
47364
+ }
47365
+ dir = dirname7(dir);
47366
+ }
47367
+ }
47368
+ } catch {
47369
+ }
47370
+ throw new OrcaExecutionError(
47371
+ "E_LEAD_PROJECT_UNTRUSTED",
47372
+ `Cannot verify saved Claude Code folder trust for ${projectDir} in ${configPath}; the lead was not launched.`,
47373
+ `${fixPrefix}Open a terminal in ${JSON.stringify(projectDir)} with the same HOME and CLAUDE_CONFIG_DIR, run claude, accept the folder-trust dialog only if you trust this project, then /exit and retry cleo orchestrate lead. Restore readable valid user config first if needed.`
47374
+ );
47375
+ }
47282
47376
  function realOrResolved(path) {
47283
47377
  try {
47284
47378
  return realpathSync3(path);
@@ -47352,11 +47446,20 @@ async function prepareLeadMcp(dir, projectDir, opts = {}) {
47352
47446
  }
47353
47447
  };
47354
47448
  }
47355
- var RUNNER_IDENTITY_ENV, LEAD_MCP_FILE;
47449
+ var RUNNER_IDENTITY_ENV, LEAD_TRUST_ENV_KEYS, LEAD_MCP_FILE;
47356
47450
  var init_lead_mcp = __esm({
47357
47451
  "packages/adapters/src/providers/claude-code/lead-mcp.ts"() {
47358
47452
  "use strict";
47453
+ init_orca_execution2();
47359
47454
  RUNNER_IDENTITY_ENV = ["CLEO_SESSION_ID", "CLEO_AGENT_ID", "CLEO_AGENT_ROLE"];
47455
+ LEAD_TRUST_ENV_KEYS = [
47456
+ "HOME",
47457
+ "USERPROFILE",
47458
+ "CLAUDE_CONFIG_DIR",
47459
+ "CLAUDE_CODE_CUSTOM_OAUTH_URL",
47460
+ "CLAUDE_CODE_SANDBOXED",
47461
+ "CLAUDE_CODE_IGNORE_PERSISTED_TRUST"
47462
+ ];
47360
47463
  LEAD_MCP_FILE = "lead-mcp.json";
47361
47464
  }
47362
47465
  });
@@ -47559,7 +47662,7 @@ var init_suite_reaper = __esm({
47559
47662
  // packages/adapters/src/providers/claude-code/spawn.ts
47560
47663
  import { spawn as nodeSpawn2 } from "node:child_process";
47561
47664
  import { writeFile as writeFile3 } from "node:fs/promises";
47562
- import { dirname as dirname7, join as join11 } from "node:path";
47665
+ import { dirname as dirname8, join as join11 } from "node:path";
47563
47666
  import { E_LEAD_NO_OWNER_CHANNEL as E_LEAD_NO_OWNER_CHANNEL4 } from "@cleocode/contracts/operations/orchestrate.js";
47564
47667
  import { findOnPath as findOnPath3 } from "@cleocode/paths";
47565
47668
  function trackedWorkerInstanceId(options) {
@@ -47634,6 +47737,12 @@ var init_spawn2 = __esm({
47634
47737
  * @returns Spawn result with instance ID and status
47635
47738
  */
47636
47739
  async spawn(context) {
47740
+ const isLead = leadDeniedTools(context) !== null;
47741
+ const orcaEnv = isLead && context.leadTerminalLauncher ? orcaLeadEnv(envStrings(context.options)) : void 0;
47742
+ const claudeJsonPath = isLead ? requireLeadProjectTrust(
47743
+ context.workingDirectory ?? process.cwd(),
47744
+ orcaEnv?.env ?? { ...process.env, ...envStrings(context.options) }
47745
+ ) : void 0;
47637
47746
  const trackedId = trackedWorkerInstanceId(context.options);
47638
47747
  const instanceId = trackedId ?? `claude-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
47639
47748
  const startTime = (/* @__PURE__ */ new Date()).toISOString();
@@ -47656,19 +47765,20 @@ var init_spawn2 = __esm({
47656
47765
  tmpFile = await writeSpawnPromptFile("claude-spawn", enrichedPrompt);
47657
47766
  let settingsArgs = [];
47658
47767
  if (trackedId !== void 0) {
47659
- const settingsFile = join11(dirname7(tmpFile), "settings.json");
47768
+ const settingsFile = join11(dirname8(tmpFile), "settings.json");
47660
47769
  await writeFile3(settingsFile, workerExitSettings(trackedId), "utf-8");
47661
47770
  settingsArgs = ["--settings", settingsFile];
47662
47771
  }
47663
47772
  let leadMcp;
47664
47773
  if (leadDeniedTools(context) !== null) {
47665
- const dir = dirname7(tmpFile);
47774
+ const dir = dirname8(tmpFile);
47666
47775
  const binaries = {
47667
47776
  cleo: resolveAbsoluteBinary("cleo"),
47668
47777
  agentmbx: resolveAbsoluteBinary("agentmbx")
47669
47778
  };
47670
47779
  leadMcp = await prepareLeadMcp(dir, context.workingDirectory ?? process.cwd(), {
47671
47780
  identityEnv: envStrings(context.options),
47781
+ ...claudeJsonPath !== void 0 ? { claudeJsonPath } : {},
47672
47782
  ...binaries.cleo ? { cleoBin: binaries.cleo } : {}
47673
47783
  });
47674
47784
  const settingsFile = join11(dir, "lead-settings.json");
@@ -47697,7 +47807,7 @@ var init_spawn2 = __esm({
47697
47807
  leadMcp: leadMcp.report
47698
47808
  };
47699
47809
  }
47700
- if (context.leadTerminalLauncher) {
47810
+ if (context.leadTerminalLauncher && orcaEnv) {
47701
47811
  const command = resolveAbsoluteBinary("claude");
47702
47812
  if (!command || !context.onLeadStarted) {
47703
47813
  throw new Error(
@@ -47710,7 +47820,8 @@ var init_spawn2 = __esm({
47710
47820
  args: buildClaudeArgs(context, tmpFile, settingsArgs, leadMcp),
47711
47821
  cwd: context.workingDirectory ?? process.cwd(),
47712
47822
  tempDir: dir,
47713
- env: envStrings(context.options)
47823
+ env: orcaEnv.env,
47824
+ unsetEnv: orcaEnv.unset
47714
47825
  },
47715
47826
  context.onLeadStarted
47716
47827
  );
@@ -47795,7 +47906,7 @@ var init_spawn2 = __esm({
47795
47906
  // T11998: surface the ownership handle in the result so callers can
47796
47907
  // persist it or pass it to reapAgentSuite on session end.
47797
47908
  ownership,
47798
- ...leadMcp ? { leadMcp: leadMcp.report, leadTempDir: dirname7(tmpFile) } : {}
47909
+ ...leadMcp ? { leadMcp: leadMcp.report, leadTempDir: dirname8(tmpFile) } : {}
47799
47910
  };
47800
47911
  } catch (error48) {
47801
47912
  if (tmpFile) {
@@ -51106,9 +51217,9 @@ init_paths();
51106
51217
  init_heavy_command_hook_install();
51107
51218
  init_hook_config();
51108
51219
  import { execFileSync as execFileSync2, spawnSync as spawnSync3 } from "node:child_process";
51109
- import { existsSync as existsSync21, lstatSync, readFileSync as readFileSync13, statSync as statSync3 } from "node:fs";
51220
+ import { existsSync as existsSync21, lstatSync as lstatSync2, readFileSync as readFileSync13, statSync as statSync4 } from "node:fs";
51110
51221
  import { homedir as homedir13 } from "node:os";
51111
- import { dirname as dirname8, join as join30 } from "node:path";
51222
+ import { dirname as dirname9, join as join30 } from "node:path";
51112
51223
  import { JsonConfigParseError } from "@cleocode/caamp";
51113
51224
  import { findOnPath as findOnPath13 } from "@cleocode/paths";
51114
51225
  var HEAVY_HOOK_DELIVERY_PROVIDERS = Object.freeze([
@@ -51477,7 +51588,7 @@ function inspectProvider(provider, projectDir, mode, env, gitChecks) {
51477
51588
  snippet: codexHookSnippet()
51478
51589
  };
51479
51590
  }
51480
- const blocked = nonDirectoryAncestor(dirname8(target));
51591
+ const blocked = nonDirectoryAncestor(dirname9(target));
51481
51592
  if (blocked !== null) {
51482
51593
  return {
51483
51594
  ...base,
@@ -51526,10 +51637,10 @@ function hasOlderCleoMarker(cleoPath, dir, env) {
51526
51637
  const marker16 = olderCleoMarkerPath(cleoPath, dir, env);
51527
51638
  if (marker16 === null) return false;
51528
51639
  try {
51529
- const st = lstatSync(marker16);
51640
+ const st = lstatSync2(marker16);
51530
51641
  if (!st.isFile()) return false;
51531
51642
  if (Date.now() - st.mtimeMs > OLDER_CLEO_MARKER_TTL_MS) return false;
51532
- return statSync3(cleoPath).mtimeMs <= st.mtimeMs;
51643
+ return statSync4(cleoPath).mtimeMs <= st.mtimeMs;
51533
51644
  } catch {
51534
51645
  return false;
51535
51646
  }
@@ -51582,15 +51693,15 @@ var heavyHookDeliveryApi = Object.freeze({
51582
51693
  init_hook_template_installer();
51583
51694
 
51584
51695
  // packages/adapters/src/manifests.ts
51585
- import { existsSync as existsSync22, readdirSync as readdirSync4, readFileSync as readFileSync14 } from "node:fs";
51586
- import { dirname as dirname9, join as join31, resolve as resolve6 } from "node:path";
51696
+ import { existsSync as existsSync22, readdirSync as readdirSync5, readFileSync as readFileSync14 } from "node:fs";
51697
+ import { dirname as dirname10, join as join31, resolve as resolve6 } from "node:path";
51587
51698
  import { fileURLToPath as fileURLToPath3 } from "node:url";
51588
51699
  function getProviderManifests() {
51589
51700
  const manifests = [];
51590
- const moduleDir = dirname9(fileURLToPath3(import.meta.url));
51701
+ const moduleDir = dirname10(fileURLToPath3(import.meta.url));
51591
51702
  const manifestsDir = resolve6(moduleDir, "..", "src", "providers");
51592
51703
  if (!existsSync22(manifestsDir)) return [];
51593
- for (const providerId of readdirSync4(manifestsDir)) {
51704
+ for (const providerId of readdirSync5(manifestsDir)) {
51594
51705
  try {
51595
51706
  const manifestPath = join31(manifestsDir, providerId, "manifest.json");
51596
51707
  const raw = readFileSync14(manifestPath, "utf-8");