context-mode 2.1.6 → 2.1.8

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/pi/index.js CHANGED
@@ -2601,10 +2601,10 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
2601
2601
  const shape = def.shape;
2602
2602
  const propValues = {};
2603
2603
  for (const key in shape) {
2604
- const field = shape[key]._zod;
2605
- if (field.values) {
2604
+ const field2 = shape[key]._zod;
2605
+ if (field2.values) {
2606
2606
  propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
2607
- for (const v of field.values)
2607
+ for (const v of field2.values)
2608
2608
  propValues[key].add(v);
2609
2609
  }
2610
2610
  }
@@ -11327,6 +11327,8 @@ var RRF_K = 60;
11327
11327
  var SOURCE_HANDLE_MAX_DIGITS = 10;
11328
11328
  var EXEC_TIMEOUT_MS = 6e5;
11329
11329
  var KILL_GRACE_MS = 1e3;
11330
+ var PIPE_EOF_GRACE_MS = 250;
11331
+ var PIPE_DRAIN_MAX_MS = 2e3;
11330
11332
  var DB_TIMEOUT_MS = 5e3;
11331
11333
  var DB_WAL_SUFFIX = "-wal";
11332
11334
  var DB_SHM_SUFFIX = "-shm";
@@ -11361,6 +11363,7 @@ var SHELL_FAMILY = Object.freeze(["sh", "bash", "zsh", "dash", "ksh", "fish"]);
11361
11363
  var PATHEXT_DEFAULT = ".COM;.EXE;.BAT;.CMD";
11362
11364
  var FETCH_MAX_HOPS = 5;
11363
11365
  var SOURCE_LABEL_MAX_CHARS = 80;
11366
+ var BACKGROUND_HOLD_NOTE = "note: the command ended while a background process still held its output; that process was stopped, so output it would write later does not exist.";
11364
11367
  var CANCELLED_LINE = "Cancelled.";
11365
11368
  var BACKGROUND_REPLY_PREFIX = "started in background, pid ";
11366
11369
  var PLAIN_OUTPUT_ENV = Object.freeze({ NO_COLOR: "1", FORCE_COLOR: "0" });
@@ -11610,7 +11613,7 @@ var DECISION_ANSWERS_KEY = "answers";
11610
11613
  var DECISION_OPTION_KEY = "option";
11611
11614
  var DECISION_LABEL_JOIN = " | ";
11612
11615
  var RELEASE_REPO_URL = "https://github.com/mksglu/context-mode.git";
11613
- var BUNDLE_SHA = true ? "ee0a1f6058f6abdb5af70b05f825a997bb15615d" : void 0;
11616
+ var BUNDLE_SHA = true ? "92c1ad26d57b45e786a3dc9149549c416badca09" : void 0;
11614
11617
  var DOCTOR_CHECK_ORDER = Object.freeze(["D1", "D2", "D3", "D4", "D5", "D5b", "D6", "D7", "D8", "D9", "D10", "D11"]);
11615
11618
  var DOCTOR_LABEL = Object.freeze({
11616
11619
  D1: "version",
@@ -11716,6 +11719,7 @@ var D5B_FIX = "disable chat.useClaudeHooks or the Claude Code hooks block";
11716
11719
  var VSCODE_CLAUDE_HOOKS_SETTING = "chat.useClaudeHooks";
11717
11720
  var VSCODE_SETTINGS_FILE = "settings.json";
11718
11721
  var D6_UNKNOWN_DETAIL = "no clientInfo or protocolVersion on the request";
11722
+ var D6_IN_PROCESS_DETAIL = "in-process plugin: this call ran inside the agent, no MCP session to read";
11719
11723
  function D7_DETAIL(got) {
11720
11724
  return `resolved project source ${got} does not match the host's actual cwd`;
11721
11725
  }
@@ -11832,6 +11836,90 @@ function D3_DETAIL(parts) {
11832
11836
  function D3_ROOT_DETAIL(paths) {
11833
11837
  return `pick one install for this project: ${paths.join(D3_PART_JOIN)}`;
11834
11838
  }
11839
+ var unsupported = (h) => Object.freeze(h);
11840
+ var UNSUPPORTED_HOSTS = Object.freeze([
11841
+ unsupported({
11842
+ id: "antigravity",
11843
+ name: "Antigravity",
11844
+ clientNames: ["antigravity", "antigravity-client", "antigravity-cli", "agy"],
11845
+ envVars: ["ANTIGRAVITY_CLI_ALIAS"],
11846
+ pluginPaths: [[".gemini", "config", "plugins"], [".gemini", "antigravity", "plugins"], [".gemini", "antigravity-cli", "plugins"], [".gemini", "antigravity-ide", "plugins"]],
11847
+ configDirs: [".gemini/antigravity", ".gemini/antigravity-cli", ".gemini/config"],
11848
+ binaries: ["agy"],
11849
+ source: "v1.0.169:src/adapters/client-map.ts:15-17; detect.ts:156,481-483; #1340"
11850
+ }),
11851
+ unsupported({
11852
+ id: "cursor",
11853
+ name: "Cursor",
11854
+ clientNames: ["cursor-vscode"],
11855
+ envVars: ["CURSOR_TRACE_ID", "CURSOR_CLI", "CURSOR_CWD"],
11856
+ pluginPaths: [],
11857
+ configDirs: [".cursor"],
11858
+ binaries: [],
11859
+ source: "v1.0.169:src/adapters/client-map.ts:18; detect.ts:163-165,584"
11860
+ }),
11861
+ unsupported({
11862
+ id: "omp",
11863
+ name: "OMP (oh-my-pi)",
11864
+ clientNames: ["omp-coding-agent"],
11865
+ envVars: [],
11866
+ pluginPaths: [],
11867
+ configDirs: [".omp"],
11868
+ binaries: ["omp"],
11869
+ source: "v1.0.169:src/adapters/client-map.ts:37; detect.ts:543 (PI_CODING_AGENT_DIR is not a signal: supported Pi reads it too)"
11870
+ }),
11871
+ unsupported({
11872
+ id: "openclaw",
11873
+ name: "OpenClaw",
11874
+ clientNames: [],
11875
+ envVars: [],
11876
+ pluginPaths: [],
11877
+ configDirs: [".openclaw"],
11878
+ binaries: [],
11879
+ source: "v1.0.169:src/adapters/detect.ts:252,575 (the runtime sets no env var)"
11880
+ }),
11881
+ unsupported({
11882
+ id: "kimi",
11883
+ name: "Kimi Code",
11884
+ clientNames: ["kimi-code", "kimi"],
11885
+ envVars: [],
11886
+ pluginPaths: [],
11887
+ configDirs: [".kimi-code"],
11888
+ binaries: ["kimi"],
11889
+ source: "v1.0.169:src/adapters/client-map.ts:42-44; detect.ts:567; adapters/kimi/index.ts:127"
11890
+ }),
11891
+ unsupported({
11892
+ id: "kilo",
11893
+ name: "Kilo Code",
11894
+ clientNames: ["kilo code"],
11895
+ envVars: ["KILO", "KILO_PID"],
11896
+ pluginPaths: [],
11897
+ configDirs: [".config/kilo"],
11898
+ binaries: [],
11899
+ source: "v1.0.169:src/adapters/client-map.ts:28; detect.ts:170-171,592"
11900
+ }),
11901
+ unsupported({
11902
+ id: "zed",
11903
+ name: "Zed",
11904
+ clientNames: ["zed"],
11905
+ envVars: ["ZED_SESSION_ID", "ZED_TERM"],
11906
+ pluginPaths: [],
11907
+ configDirs: [".config/zed"],
11908
+ binaries: [],
11909
+ source: "v1.0.169:src/adapters/client-map.ts:38-39; detect.ts:189-190,616"
11910
+ }),
11911
+ unsupported({
11912
+ id: "jetbrains-copilot",
11913
+ name: "JetBrains Copilot",
11914
+ clientNames: ["jetbrains client", "intellij idea", "pycharm"],
11915
+ envVars: ["IDEA_INITIAL_DIRECTORY"],
11916
+ pluginPaths: [],
11917
+ configDirs: [".config/JetBrains"],
11918
+ binaries: [],
11919
+ source: "v1.0.169:src/adapters/client-map.ts:23-25; detect.ts:213,600"
11920
+ })
11921
+ ]);
11922
+ var SUPPORTED_AGENTS_DOCS_URL = "https://github.com/mksglu/context-mode/blob/main/docs/install/README.md";
11835
11923
  var D3_ROOT_FIX_JOIN = " or ";
11836
11924
  function D3_ROOT_FIX(installs) {
11837
11925
  return `remove the extra install: ${installs.map((i) => `claude plugin uninstall ${i.key} --scope ${i.scope}`).join(D3_ROOT_FIX_JOIN)}`;
@@ -11930,6 +12018,14 @@ var V1_SCRIPT_NAMES = Object.freeze([
11930
12018
  var V1_HOOK_COMMAND = "context-mode hook";
11931
12019
  var V1_CODEX_HOOK_COMMAND = "context-mode hook codex";
11932
12020
  var V1_CODEX_HOOKS_DIR = Object.freeze(["hooks", "codex"]);
12021
+ var V1_CODEX_SCRIPT_NAMES = Object.freeze([
12022
+ "pretooluse.mjs",
12023
+ "posttooluse.mjs",
12024
+ "sessionstart.mjs",
12025
+ "precompact.mjs",
12026
+ "userpromptsubmit.mjs",
12027
+ "stop.mjs"
12028
+ ]);
11933
12029
  var V1_CACHE_HEAL_NAME = "context-mode-cache-heal";
11934
12030
  var V1_CACHE_HEAL_EXTS = Object.freeze([".mjs", ".sh"]);
11935
12031
  var V1_STATUSLINE_COMMAND = "context-mode statusline";
@@ -11989,7 +12085,6 @@ var PI_NPM_LATEST = `${V1_PI_PACKAGE}${NPM_VERSION_SEP}latest`;
11989
12085
  var V1_DATA_DIR_NAME = "context-mode";
11990
12086
  var V1_DATA_ROOT_ENTRIES = Object.freeze(["content", "platform.json"]);
11991
12087
  var V1_SESSIONS_DIR_NAME = "sessions";
11992
- var V1_SCRIPT_EXT = ".mjs";
11993
12088
  var V1_BIN_COMMAND = SERVER_KEY;
11994
12089
  var VSCODE_MCP_SERVERS_KEY = "servers";
11995
12090
  var ZCODE_EVENTS_KEY = "events";
@@ -12005,7 +12100,7 @@ var V1_REASON = Object.freeze({
12005
12100
  cacheHealFile: "old context-mode cache-heal script file",
12006
12101
  statusLine: "old context-mode statusLine (context-mode statusline): report only, never removed",
12007
12102
  mcpEntry: "old context-mode MCP entry mcpServers.context-mode",
12008
- codexHook: "old context-mode Codex hook entry: context-mode hook codex or hooks/codex/*.mjs",
12103
+ codexHook: "old context-mode Codex hook entry: context-mode hook codex or hooks/codex/<event>.mjs",
12009
12104
  codexToml: "old context-mode config.toml [mcp_servers.context-mode*] section",
12010
12105
  hookFile: "old context-mode hook file context-mode.json (runs context-mode hook)",
12011
12106
  vscodeMcp: "old context-mode MCP entry servers.context-mode in .vscode/mcp.json: report only, never removed",
@@ -12043,7 +12138,6 @@ var HOST_CONFIG_TEXT_PATH = "(given text)";
12043
12138
  var JSON_INDENT_UNIT = " ";
12044
12139
  var MCP_COMMAND_FIELD = "command";
12045
12140
  var MCP_ARGS_FIELD = "args";
12046
- var MCP_ENV_FIELD = "env";
12047
12141
  var ZCODE_MCP_FEATURE_KEY = Object.freeze(["features", "mcp"]);
12048
12142
  var CODEX_OMIT_TOOLS_FROM_FIELD = "omit_tools_from";
12049
12143
  var CODEX_OMIT_DEFERRED = Object.freeze(["deferred"]);
@@ -12176,6 +12270,7 @@ function readResult(p) {
12176
12270
  const text = p.content === void 0 ? "" : typeof p.content === "string" ? p.content : JSON.stringify(p.content);
12177
12271
  const info = { isError: p.isError === true, bytes: Buffer.byteLength(text), text };
12178
12272
  if (typeof p.exitCode === "number") info.exitCode = p.exitCode;
12273
+ if (p.keep === true) info.keep = true;
12179
12274
  return info;
12180
12275
  }
12181
12276
  function decode(raw) {
@@ -12290,7 +12385,7 @@ var CtxError = class extends Error {
12290
12385
  };
12291
12386
 
12292
12387
  // src/core/hooks/dispatch.ts
12293
- import { dirname as dirname4, join as join8, relative as relative3, resolve as resolve6, sep as sep3 } from "node:path";
12388
+ import { dirname as dirname4, join as join8, relative as relative3, resolve as resolve8, sep as sep3 } from "node:path";
12294
12389
 
12295
12390
  // src/core/contracts/agents.ts
12296
12391
  var AGENT_IDS = ["claude-code", "codex", "gemini", "qwen", "copilot-cli", "vscode", "kiro", "zcode", "pi", "opencode"];
@@ -12944,8 +13039,8 @@ function decode8(raw) {
12944
13039
  const ev = { event, agent: "kiro", sessionId: String(p.session_id ?? ""), cwd: String(p.cwd ?? "") };
12945
13040
  if (event === "SessionStart" && typeof p.source === "string" && KIRO_SOURCES[p.source] !== void 0) ev.source = KIRO_SOURCES[p.source];
12946
13041
  if (event === "UserPromptSubmit") {
12947
- const field = p[PROMPT_FIELD];
12948
- const prompt = typeof field === "string" ? field : process.env[PROMPT_ENV];
13042
+ const field2 = p[PROMPT_FIELD];
13043
+ const prompt = typeof field2 === "string" ? field2 : process.env[PROMPT_ENV];
12949
13044
  if (prompt !== void 0) ev.prompt = prompt;
12950
13045
  }
12951
13046
  if (event === "PreToolUse" || event === "PostToolUse") {
@@ -13030,6 +13125,11 @@ function decode10(raw) {
13030
13125
  const event = Object.prototype.hasOwnProperty.call(OPENCODE_EVENTS, native) ? OPENCODE_EVENTS[native] : void 0;
13031
13126
  if (event === void 0) throw new Error("opencode: unknown hook event " + String(p.type));
13032
13127
  const ev = { event, agent: "opencode", sessionId: String(p.sessionID ?? ""), cwd: String(p.directory ?? "") };
13128
+ if (typeof p.agentID === "string" && p.agentID !== "") {
13129
+ ev.agentId = p.agentID;
13130
+ ev.agentType = p.agentID;
13131
+ }
13132
+ if (Array.isArray(p.agentTools)) ev.agentTools = p.agentTools.filter((t) => typeof t === "string");
13033
13133
  if (event === "UserPromptSubmit" && typeof p.message === "string") ev.prompt = p.message;
13034
13134
  if (event === "PreToolUse" || event === "PostToolUse") {
13035
13135
  const name = String(p.tool ?? "");
@@ -13050,7 +13150,7 @@ function encode10(ev, d, _extra) {
13050
13150
  if (ev.event !== "PreToolUse") return { stdout: "", exitCode: 0 };
13051
13151
  return { stdout: d.rewritten === void 0 ? d.reason : d.rewritten + "\n" + d.reason, exitCode: 2 };
13052
13152
  case "replace":
13053
- return { stdout: "", exitCode: 0 };
13153
+ return { stdout: ev.event === "PostToolUse" ? d.output : "", exitCode: 0 };
13054
13154
  }
13055
13155
  }
13056
13156
 
@@ -13255,7 +13355,7 @@ var ADAPTERS = Object.freeze([
13255
13355
  }
13256
13356
  ]);
13257
13357
  var BY_ID = new Map(ADAPTERS.map((r) => [r.id, r]));
13258
- var REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "gemini", "copilot-cli", "pi"]);
13358
+ var REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "gemini", "copilot-cli", "pi", "opencode"]);
13259
13359
  function hasReplace(row5) {
13260
13360
  return REPLACE_ROWS.has(row5.id);
13261
13361
  }
@@ -13272,7 +13372,7 @@ function getAdapter(id) {
13272
13372
  }
13273
13373
 
13274
13374
  // src/core/policy/decide.ts
13275
- import { resolve as resolve3 } from "node:path";
13375
+ import { resolve as resolve5 } from "node:path";
13276
13376
 
13277
13377
  // src/core/policy/lexer.ts
13278
13378
  var OPS = ["&&", "||", ";;", "|&", ";", "|", "&", "(", ")"];
@@ -14676,6 +14776,17 @@ function claudeDirOf(env, home) {
14676
14776
  const dir = env[CLAUDE_CONFIG_DIR_ENV];
14677
14777
  return dir !== void 0 && dir !== "" ? dir : join(home, ...AGENT_HOME_DIR["claude-code"]);
14678
14778
  }
14779
+ function claudeProfileEnv(env, platform = process.platform) {
14780
+ const dir = env[CLAUDE_CONFIG_DIR_ENV];
14781
+ if (dir === void 0 || dir === "" || platform === "win32") return "";
14782
+ return `${CLAUDE_CONFIG_DIR_ENV}='${dir.split("'").join(`'"'"'`)}' `;
14783
+ }
14784
+ function hostUpdateCommand(agent, env, platform = process.platform) {
14785
+ const cmd = UPGRADE_HOST_COMMAND[agent];
14786
+ if (agent !== "claude-code") return cmd;
14787
+ const profile = claudeProfileEnv(env, platform);
14788
+ return profile === "" ? cmd : cmd.split(" && ").map((c) => profile + c).join(" && ");
14789
+ }
14679
14790
  function opencodeDirOf(env, home) {
14680
14791
  const own4 = env[OPENCODE_CONFIG_DIR_ENV];
14681
14792
  if (own4 !== void 0 && own4 !== "") return own4;
@@ -15210,10 +15321,10 @@ function READ_DENY_RANGE_MESSAGE(path8, size) {
15210
15321
  }
15211
15322
 
15212
15323
  // src/core/policy/own-file.ts
15213
- import { extname, join as join5 } from "node:path";
15324
+ import { extname, join as join5, resolve as resolve4 } from "node:path";
15214
15325
 
15215
15326
  // src/core/project/contain.ts
15216
- import { dirname as dirname2, join as join4, relative as relative2, sep as sep2 } from "node:path";
15327
+ import { dirname as dirname2, isAbsolute as isAbsolute2, join as join4, relative as relative2, resolve as resolve3, sep as sep2 } from "node:path";
15217
15328
  var { lstatSync, realpathSync: realpathSync2 } = process.getBuiltinModule("node:fs");
15218
15329
  function real(p) {
15219
15330
  try {
@@ -15257,6 +15368,29 @@ function isInsideAny(roots, p) {
15257
15368
  return qc.length >= rc.length && rc.every((c, i) => c === qc[i]);
15258
15369
  });
15259
15370
  }
15371
+ function hasParentStep(cwd, p) {
15372
+ const parts = isAbsolute2(p) ? components(p) : [...components(cwd), ...components(p)];
15373
+ return parts.includes("..");
15374
+ }
15375
+ var rootParts = /* @__PURE__ */ new Map();
15376
+ function lexicalRoot(root) {
15377
+ let rc = rootParts.get(root);
15378
+ if (rc === void 0) {
15379
+ rc = components(resolve3(root));
15380
+ rootParts.set(root, rc);
15381
+ }
15382
+ return rc;
15383
+ }
15384
+ function isLexicallyInsideAny(roots, p) {
15385
+ if (roots.length === 0) return false;
15386
+ const raw = components(p);
15387
+ if (raw.includes("..")) return false;
15388
+ const qc = sep2 === "/" && isAbsolute2(p) ? raw.filter((c) => c !== ".") : components(resolve3(p));
15389
+ return roots.some((root) => {
15390
+ const rc = lexicalRoot(root);
15391
+ return qc.length >= rc.length && rc.every((c, i) => c === qc[i]);
15392
+ });
15393
+ }
15260
15394
  function commonRoot(paths) {
15261
15395
  const reals = paths.map(real).filter((r) => r !== void 0);
15262
15396
  if (reals.length === 0) throw new RangeError("commonRoot needs at least one existing path");
@@ -15297,9 +15431,11 @@ function ownDirsOf(agent, env) {
15297
15431
  const own4 = agent === "claude-code" ? [claudeDirOf(env, home)] : agent === "codex" ? [codexDirOf(env, home)] : agent === "gemini" ? [geminiDirOf(env, home)] : agent === "copilot-cli" ? [copilotDirOf(env, home)] : agent === "kiro" ? [kiroDirOf(env, home)] : agent === "opencode" ? [opencodeDirOf(env, home)] : agent === "pi" ? [piAgentDirOf(env, home)] : agent === "vscode" ? [join5(home, ...AGENT_HOME_DIR.vscode), vscodeUserDirOf(env, home)] : [join5(home, ...AGENT_HOME_DIR[agent])];
15298
15432
  return [...own4, shared];
15299
15433
  }
15300
- function isOwnFile(agent, abs, env = process.env) {
15301
- if (extname(abs).toLowerCase() !== AGENT_FILE_EXT) return false;
15302
- return isInsideAny(ownDirsOf(agent, env), abs);
15434
+ function isOwnFile(agent, cwd, p, env = process.env) {
15435
+ if (extname(p).toLowerCase() !== AGENT_FILE_EXT) return false;
15436
+ const dirs = ownDirsOf(agent, env);
15437
+ const abs = resolve4(cwd, p);
15438
+ return !hasParentStep(cwd, p) && isLexicallyInsideAny(dirs, abs) || isInsideAny(dirs, abs);
15303
15439
  }
15304
15440
 
15305
15441
  // src/core/policy/read-media.ts
@@ -15390,7 +15526,7 @@ function readPaths(input) {
15390
15526
  }
15391
15527
  function userDenyHit(canonical, input, cwd, rules) {
15392
15528
  if (rules.length === 0) return null;
15393
- const readRule = (p) => matchesAnyDenyPattern(resolve3(cwd, p), rules, { tool: READ, projectDir: cwd });
15529
+ const readRule = (p) => matchesAnyDenyPattern(resolve5(cwd, p), rules, { tool: READ, projectDir: cwd });
15394
15530
  if (canonical === BASH) {
15395
15531
  const cmd = str(input.command);
15396
15532
  return cmd === void 0 ? null : matchesAnyDenyPattern(cmd, rules);
@@ -15527,8 +15663,9 @@ function fileSize(abs) {
15527
15663
  return -1;
15528
15664
  }
15529
15665
  }
15530
- function bigDeny(ev, row5, abs, size, root) {
15531
- if (size <= OUTPUT_CAP || isOwnFile(ev.agent, abs)) return null;
15666
+ function bigDeny(ev, row5, cwd, p, size, root) {
15667
+ const abs = resolve5(cwd, p);
15668
+ if (size <= OUTPUT_CAP || isOwnFile(ev.agent, cwd, p)) return null;
15532
15669
  return deny(executeCanOpen(root, abs) ? READ_DENY_MESSAGE(abs, size, row5.toolNamePrefix) : READ_DENY_RANGE_MESSAGE(abs, size));
15533
15670
  }
15534
15671
  function executeCanOpen(root, abs) {
@@ -15543,10 +15680,10 @@ function executeCanOpen(root, abs) {
15543
15680
  function read(ev, row5, input, root) {
15544
15681
  if (!present(input.offset) && !present(input.limit)) {
15545
15682
  for (const p of readPaths(input)) {
15546
- const abs = resolve3(ev.cwd, p);
15683
+ const abs = resolve5(ev.cwd, p);
15547
15684
  const size = fileSize(abs);
15548
15685
  if (size > OUTPUT_CAP && !isMediaRead(ev.agent, abs)) {
15549
- const d = bigDeny(ev, row5, abs, size, root);
15686
+ const d = bigDeny(ev, row5, ev.cwd, p, size, root);
15550
15687
  if (d !== null) return d;
15551
15688
  }
15552
15689
  }
@@ -15559,7 +15696,7 @@ function shellDump(ev, cmds, row5, root) {
15559
15696
  let verdict = null;
15560
15697
  for (const c of cmds) {
15561
15698
  const name = c.argv0.toLowerCase();
15562
- if (name === CD_COMMAND && c.args.length === 1 && c.insideConstruct === void 0) dir = resolve3(dir, c.args[0]);
15699
+ if (name === CD_COMMAND && c.args.length === 1 && c.insideConstruct === void 0) dir = resolve5(dir, c.args[0]);
15563
15700
  if (c.redirectsToFile || c.endsInBoundedSink || c.pipesOut === true || c.insideConstruct !== void 0) continue;
15564
15701
  if (!has(SHELL_DUMP_COMMANDS, name)) continue;
15565
15702
  const d = dumpTarget(name, c.args);
@@ -15568,8 +15705,8 @@ function shellDump(ev, cmds, row5, root) {
15568
15705
  verdict = ALLOW;
15569
15706
  continue;
15570
15707
  }
15571
- const abs = resolve3(dir, d.file);
15572
- const big = bigDeny(ev, row5, abs, fileSize(abs), root);
15708
+ const abs = resolve5(dir, d.file);
15709
+ const big = bigDeny(ev, row5, dir, d.file, fileSize(abs), root);
15573
15710
  if (big !== null) return big;
15574
15711
  }
15575
15712
  return verdict;
@@ -15577,7 +15714,7 @@ function shellDump(ev, cmds, row5, root) {
15577
15714
  function psShellDump(ev, cmd, row5, root) {
15578
15715
  if (row5.nativeTools.read !== void 0 && row5.nativeTools.read.length > 0 && dumpRunsThenReplaces(row5)) return null;
15579
15716
  for (const abs of psDumpFiles(cmd, ev.cwd)) {
15580
- const d = bigDeny(ev, row5, abs, fileSize(abs), root);
15717
+ const d = bigDeny(ev, row5, ev.cwd, abs, fileSize(abs), root);
15581
15718
  if (d !== null) return d;
15582
15719
  }
15583
15720
  return null;
@@ -15639,7 +15776,7 @@ function dumpTarget(name, args) {
15639
15776
  }
15640
15777
 
15641
15778
  // src/core/project/resolve.ts
15642
- import { basename as basename2, dirname as dirname3, join as join6, resolve as resolve4 } from "node:path";
15779
+ import { basename as basename2, dirname as dirname3, join as join6, resolve as resolve6 } from "node:path";
15643
15780
 
15644
15781
  // src/core/project/sha256.ts
15645
15782
  var K = new Uint32Array([
@@ -15804,7 +15941,7 @@ function gitDirs(dir) {
15804
15941
  const gitDir = gitDirAt(join6(cur, GIT_DIR_NAME));
15805
15942
  if (gitDir !== null) {
15806
15943
  const common = firstLine(join6(gitDir, GIT_COMMONDIR_FILE));
15807
- return { commonDir: realpathSync3.native(common === null ? gitDir : resolve4(gitDir, common)), worktree: cur, start };
15944
+ return { commonDir: realpathSync3.native(common === null ? gitDir : resolve6(gitDir, common)), worktree: cur, start };
15808
15945
  }
15809
15946
  const up = dirname3(cur);
15810
15947
  if (up === cur) return { commonDir: null, start };
@@ -15819,7 +15956,7 @@ function gitDirAt(dotGit) {
15819
15956
  } else {
15820
15957
  const line = firstLine(dotGit);
15821
15958
  if (line === null || !line.startsWith(GITDIR_FILE_PREFIX)) return null;
15822
- gitDir = resolve4(dirname3(dotGit), line.slice(GITDIR_FILE_PREFIX.length));
15959
+ gitDir = resolve6(dirname3(dotGit), line.slice(GITDIR_FILE_PREFIX.length));
15823
15960
  }
15824
15961
  } catch {
15825
15962
  return null;
@@ -19657,17 +19794,17 @@ function fitRow(row5, skewed, named2, budget) {
19657
19794
  const own4 = Object.keys(row5);
19658
19795
  const tier = (k) => skewed.includes(k) ? 0 : named2.has(k) ? 1 : typeof row5[k] !== "object" || row5[k] === null ? 2 : 3;
19659
19796
  const order = [...own4].sort((a, b) => tier(a) - tier(b) || own4.indexOf(a) - own4.indexOf(b));
19660
- const field = (k) => JSON.stringify(k) + ":" + JSON.stringify(row5[k]);
19797
+ const field2 = (k) => JSON.stringify(k) + ":" + JSON.stringify(row5[k]);
19661
19798
  const chosen = /* @__PURE__ */ new Set();
19662
19799
  let used = 2;
19663
19800
  for (const k of order) {
19664
- const cost = bytes(field(k)) + (chosen.size > 0 ? 1 : 0);
19801
+ const cost = bytes(field2(k)) + (chosen.size > 0 ? 1 : 0);
19665
19802
  if (used + cost > budget) continue;
19666
19803
  chosen.add(k);
19667
19804
  used += cost;
19668
19805
  }
19669
19806
  if (!skewed.every((k) => chosen.has(k))) return null;
19670
- return "{" + own4.filter((k) => chosen.has(k)).map(field).join(",") + "}";
19807
+ return "{" + own4.filter((k) => chosen.has(k)).map(field2).join(",") + "}";
19671
19808
  }
19672
19809
  function namedKeys(keys, query) {
19673
19810
  const score = rankTexts(keys, query, "any");
@@ -19882,7 +20019,7 @@ function shouldHint(db, sessionId, onceKey, everyN) {
19882
20019
  }
19883
20020
 
19884
20021
  // src/core/hooks/fallback.ts
19885
- import { join as join7, resolve as resolve5 } from "node:path";
20022
+ import { join as join7, resolve as resolve7 } from "node:path";
19886
20023
  var fs = process.getBuiltinModule("node:fs");
19887
20024
  function isRec(v) {
19888
20025
  return typeof v === "object" && v !== null && !Array.isArray(v);
@@ -20005,7 +20142,7 @@ function bigFile(abs) {
20005
20142
  function bigRead(agent, input, cwd) {
20006
20143
  if ((input.offset ?? null) !== null || (input.limit ?? null) !== null) return false;
20007
20144
  const many = Array.isArray(input[READ_PATH_LIST_KEY]) ? input[READ_PATH_LIST_KEY].filter((x) => typeof x === "string") : [];
20008
- return [firstString(input, READ_PATH_KEYS), ...many].some((p) => p !== "" && bigFile(resolve5(cwd, p)) && !isMediaRead(agent, resolve5(cwd, p)) && !isOwnFile(agent, resolve5(cwd, p)));
20145
+ return [firstString(input, READ_PATH_KEYS), ...many].some((p) => p !== "" && bigFile(resolve7(cwd, p)) && !isMediaRead(agent, resolve7(cwd, p)) && !isOwnFile(agent, cwd, p));
20009
20146
  }
20010
20147
  function failureOutput(agent, raw, err, cwdFallback = "") {
20011
20148
  const row5 = getAdapter(agent);
@@ -20264,12 +20401,17 @@ function askDetached(ev, project, tool, text) {
20264
20401
  process.stderr.write("hooks: decision write failed: " + message(err) + "\n");
20265
20402
  });
20266
20403
  }
20404
+ function toolSetSources(ev, project, env) {
20405
+ const src = { projectDir: project.worktree, env };
20406
+ if (ev.agentTools !== void 0) src.manifestTools = ev.agentTools;
20407
+ return src;
20408
+ }
20267
20409
  async function preToolUse(ev, row5, project, env) {
20268
20410
  const userDeny = readUserDeny(project.worktree, ev.agent);
20269
20411
  const decision0 = decide(ev, row5, userDeny, project);
20270
20412
  let decision = decision0;
20271
20413
  if (decision0.kind === "deny" && isSubagentCall(ev) && !isUserPolicyDeny(decision0.reason, row5)) {
20272
- const set3 = toolSetForAgentType(ev, { projectDir: project.worktree, env });
20414
+ const set3 = toolSetForAgentType(ev, toolSetSources(ev, project, env));
20273
20415
  const subCase = pickSubagentCase(ev, set3);
20274
20416
  const tool = ev.tool;
20275
20417
  const runs = set3 !== null || (ev.agentType ?? "") !== "" && hasReplace(row5);
@@ -20372,7 +20514,7 @@ async function postToolUse(ev, row5, project, env, settle3) {
20372
20514
  function ownRead(ev, tool, env) {
20373
20515
  if (!RANGE_READ_TOOLS.includes(tool.canonicalName)) return false;
20374
20516
  const p = READ_PATH_KEYS.map((k) => tool.input[k]).find((v) => typeof v === "string" && v !== "");
20375
- return p !== void 0 && isOwnFile(ev.agent, resolve6(ev.cwd, p), env);
20517
+ return p !== void 0 && isOwnFile(ev.agent, ev.cwd, p, env);
20376
20518
  }
20377
20519
  async function postReplace(ev, row5, project, env, tool, result, text) {
20378
20520
  if (result.bytes <= REPLACE_TRIGGER_BYTES) return ALLOW2;
@@ -20382,7 +20524,7 @@ async function postReplace(ev, row5, project, env, tool, result, text) {
20382
20524
  if (!hasReplace(row5)) return ALLOW2;
20383
20525
  let label2;
20384
20526
  if (isSubagentCall(ev)) {
20385
- const subCase = pickSubagentCase(ev, toolSetForAgentType(ev, { projectDir: project.worktree, env }));
20527
+ const subCase = pickSubagentCase(ev, toolSetForAgentType(ev, toolSetSources(ev, project, env)));
20386
20528
  if (subCase === "A") return ALLOW2;
20387
20529
  label2 = SUBAGENT_SOURCE_PREFIX + tool.canonicalName + ":" + String(ev.turn ?? 0);
20388
20530
  } else {
@@ -20421,7 +20563,7 @@ function replaceBudget(handleLine, more) {
20421
20563
  function hostToolResult(file2, sessionId, env) {
20422
20564
  if (sessionId === "" || sessionId.includes(sep3) || sessionId.includes("/")) return false;
20423
20565
  const projects = join8(claudeDirOf(env, homeDirOf(env) ?? ""), PROJECTS_DIR_NAME);
20424
- const steps = relative3(projects, resolve6(file2)).split(sep3);
20566
+ const steps = relative3(projects, resolve8(file2)).split(sep3);
20425
20567
  if (steps.length !== 4 || steps.includes("..") || steps.includes("")) return false;
20426
20568
  if (steps[1] !== sessionId || steps[2] !== CLAUDE_TOOL_RESULTS_DIR_NAME) return false;
20427
20569
  const st = lstatSync2(file2);
@@ -20627,11 +20769,11 @@ function noRuntimeError(lang) {
20627
20769
  }
20628
20770
 
20629
20771
  // src/core/sandbox/spawn.ts
20630
- import { spawn } from "node:child_process";
20772
+ import { spawn as spawn2 } from "node:child_process";
20631
20773
  import path2 from "node:path";
20632
20774
 
20633
20775
  // src/core/sandbox/kill.ts
20634
- import { execFileSync } from "node:child_process";
20776
+ import { spawn } from "node:child_process";
20635
20777
  function signalGroup(pid, signal) {
20636
20778
  try {
20637
20779
  process.kill(-pid, signal);
@@ -20645,7 +20787,10 @@ function killTree(pid) {
20645
20787
  return;
20646
20788
  }
20647
20789
  try {
20648
- execFileSync("taskkill", ["/F", "/T", "/PID", String(pid)], { stdio: "ignore", windowsHide: true });
20790
+ const t = spawn("taskkill", ["/F", "/T", "/PID", String(pid)], { stdio: "ignore", windowsHide: true });
20791
+ t.on("error", () => {
20792
+ });
20793
+ t.unref();
20649
20794
  } catch {
20650
20795
  }
20651
20796
  }
@@ -20658,13 +20803,13 @@ function startArgv(argv) {
20658
20803
  return sh === null ? null : [sh, ...argv];
20659
20804
  }
20660
20805
  function runProcess(argv, o) {
20661
- return new Promise((resolve10) => {
20806
+ return new Promise((resolve13) => {
20662
20807
  const isWin2 = process.platform === "win32";
20663
20808
  const start = startArgv(argv);
20664
- if (start === null) return resolve10(NOT_STARTED);
20809
+ if (start === null) return resolve13(NOT_STARTED);
20665
20810
  let child;
20666
20811
  try {
20667
- child = spawn(start[0], start.slice(1), {
20812
+ child = spawn2(start[0], start.slice(1), {
20668
20813
  cwd: o.cwd,
20669
20814
  env: o.env,
20670
20815
  stdio: ["pipe", "pipe", "pipe"],
@@ -20675,14 +20820,20 @@ function runProcess(argv, o) {
20675
20820
  windowsHide: true
20676
20821
  });
20677
20822
  } catch {
20678
- return resolve10(NOT_STARTED);
20823
+ return resolve13(NOT_STARTED);
20679
20824
  }
20680
20825
  const stdoutChunks = [];
20681
20826
  const stderrChunks = [];
20682
20827
  let killedBy = null;
20683
20828
  let settled = false;
20829
+ let held = false;
20830
+ let exited = false;
20831
+ let graceTimer;
20832
+ let drainTimer;
20833
+ let stopTimer;
20684
20834
  const kill = () => {
20685
20835
  if (child.pid !== void 0) killTree(child.pid);
20836
+ if (stopTimer === void 0) stopTimer = setTimeout(() => finishHeld(), KILL_GRACE_MS);
20686
20837
  };
20687
20838
  const onAbort = () => {
20688
20839
  if (killedBy !== null || settled) return;
@@ -20699,17 +20850,46 @@ function runProcess(argv, o) {
20699
20850
  if (settled) return;
20700
20851
  settled = true;
20701
20852
  clearTimeout(timer);
20853
+ clearTimeout(graceTimer);
20854
+ clearTimeout(drainTimer);
20855
+ clearTimeout(stopTimer);
20702
20856
  o.signal.removeEventListener("abort", onAbort);
20703
- resolve10({
20857
+ resolve13({
20704
20858
  stdout: Buffer.concat(stdoutChunks),
20705
20859
  stderr: Buffer.concat(stderrChunks),
20706
20860
  exitCode,
20707
- killed: killedBy
20861
+ killed: killedBy,
20862
+ ...held ? { held: true } : {}
20708
20863
  });
20709
20864
  };
20710
- child.stdout.on("data", (chunk) => stdoutChunks.push(chunk));
20711
- child.stderr.on("data", (chunk) => stderrChunks.push(chunk));
20865
+ const finishHeld = () => {
20866
+ if (settled) return;
20867
+ held = exited && killedBy === null;
20868
+ child.stdout.destroy();
20869
+ child.stderr.destroy();
20870
+ if (child.pid !== void 0) killTree(child.pid);
20871
+ settle3(child.exitCode);
20872
+ };
20873
+ const bump = () => {
20874
+ if (!exited || settled) return;
20875
+ clearTimeout(graceTimer);
20876
+ graceTimer = setTimeout(finishHeld, PIPE_EOF_GRACE_MS);
20877
+ };
20878
+ child.stdout.on("data", (chunk) => {
20879
+ stdoutChunks.push(chunk);
20880
+ bump();
20881
+ });
20882
+ child.stderr.on("data", (chunk) => {
20883
+ stderrChunks.push(chunk);
20884
+ bump();
20885
+ });
20712
20886
  child.on("close", (code) => settle3(code));
20887
+ child.on("exit", () => {
20888
+ if (settled) return;
20889
+ exited = true;
20890
+ graceTimer = setTimeout(finishHeld, PIPE_EOF_GRACE_MS);
20891
+ drainTimer = setTimeout(finishHeld, PIPE_DRAIN_MAX_MS);
20892
+ });
20713
20893
  child.on("error", () => settle3(null));
20714
20894
  child.stdin.on("error", () => {
20715
20895
  });
@@ -20805,8 +20985,8 @@ function bytes2(s) {
20805
20985
  function reply(text, isError) {
20806
20986
  return { text: capBytes(text, OUTPUT_CAP).text, isError, sandboxBytes: 0 };
20807
20987
  }
20808
- function invalid(field, action) {
20809
- return reply(formatError2("INVALID_ARGS", { field, action }), true);
20988
+ function invalid(field2, action) {
20989
+ return reply(formatError2("INVALID_ARGS", { field: field2, action }), true);
20810
20990
  }
20811
20991
  function sourceCount(db, scope, ctx, source) {
20812
20992
  const row5 = db.raw.prepare(COUNT_SOURCES).get({
@@ -21067,12 +21247,16 @@ function answer(db, input, scope, ctx, nm, ms, indexed, sort, pick4) {
21067
21247
  }
21068
21248
  async function handler(input, ctx) {
21069
21249
  const sort = input.sort ?? "relevance";
21070
- if (sort === "timeline" && input.offset !== void 0) {
21250
+ if (sort === "timeline" && (input.offset ?? 0) !== 0) {
21071
21251
  return invalid("offset", 'drop offset; page a timeline with "after"');
21072
21252
  }
21073
- if (sort === "relevance" && input.after !== void 0) {
21253
+ if (sort === "relevance" && (input.after ?? 0) !== 0) {
21074
21254
  return invalid("after", 'drop after, or pass sort:"timeline"');
21075
21255
  }
21256
+ if (input.source !== void 0 && input.source.trim() === "") {
21257
+ const { source: _blank, ...rest } = input;
21258
+ input = rest;
21259
+ }
21076
21260
  const scope = input.scope ?? "worktree";
21077
21261
  const db = await openDb(ctx.project, { readOnly: true });
21078
21262
  try {
@@ -21326,7 +21510,7 @@ var ctxBatch = Object.freeze({
21326
21510
  });
21327
21511
 
21328
21512
  // src/core/tools/doctor.ts
21329
- import { readdirSync as readdirSync7, readFileSync as readFileSync15, existsSync as existsSync16 } from "node:fs";
21513
+ import { readdirSync as readdirSync7, readFileSync as readFileSync16, existsSync as existsSync16 } from "node:fs";
21330
21514
  import { basename as basename5, join as join19 } from "node:path";
21331
21515
 
21332
21516
  // src/core/ops/bundle-dir.ts
@@ -21352,8 +21536,8 @@ function ownBundleDir() {
21352
21536
  }
21353
21537
 
21354
21538
  // src/core/ops/doctor-config.ts
21355
- import { existsSync as existsSync9, readdirSync as readdirSync5 } from "node:fs";
21356
- import { join as join14 } from "node:path";
21539
+ import { existsSync as existsSync9, readdirSync as readdirSync5, readFileSync as readFileSync11 } from "node:fs";
21540
+ import { dirname as dirname8, isAbsolute as isAbsolute4, join as join14, resolve as resolve9 } from "node:path";
21357
21541
 
21358
21542
  // src/core/ops/detect-v1.ts
21359
21543
  import { existsSync as existsSync6, opendirSync, readdirSync as readdirSync3, readFileSync as readFileSync8 } from "node:fs";
@@ -23859,7 +24043,7 @@ function listTarget(key, legacy, swap, isNative) {
23859
24043
  var piSource = (x) => isPlainObject3(x) ? x[PI_PACKAGE_SOURCE_KEY] : x;
23860
24044
  var opencodeSpec = (x) => isPlainObject3(x) ? x[OPENCODE_PACKAGE_FIELD] : x;
23861
24045
  var isNpmOf = (bare2) => (s) => typeof s === "string" && (s === bare2 || s.startsWith(bare2 + NPM_VERSION_SEP));
23862
- var swapField = (field, spec) => (x) => isPlainObject3(x) ? { ...x, [field]: spec } : spec;
24046
+ var swapField = (field2, spec) => (x) => isPlainObject3(x) ? { ...x, [field2]: spec } : spec;
23863
24047
  function ownTargets(agent, accept) {
23864
24048
  const mcp = OWN_MCP_ENTRY[agent];
23865
24049
  if (mcp !== void 0) {
@@ -24016,7 +24200,7 @@ function flatCommands(events, prefix) {
24016
24200
  return out;
24017
24201
  }
24018
24202
  var isV1Hook = (cmd) => cmd.includes(SERVER_KEY) && (V1_SCRIPT_NAMES.some((name) => cmd.includes(name)) || cmd.includes(V1_HOOK_COMMAND));
24019
- var isCodexScript = (cmd) => cmd.includes(V1_SCRIPT_EXT) && V1_PATH_SEPS.some((sep5) => cmd.includes(V1_CODEX_HOOKS_DIR.join(sep5) + sep5));
24203
+ var isCodexScript = (cmd) => V1_PATH_SEPS.some((sep5) => V1_CODEX_SCRIPT_NAMES.some((name) => cmd.includes(V1_CODEX_HOOKS_DIR.join(sep5) + sep5 + name)));
24020
24204
  function dataDir(dir, reason, out) {
24021
24205
  if (existsSync6(dir)) out.push(finding(dir, "", reason));
24022
24206
  }
@@ -24064,8 +24248,7 @@ function scanCodex(agentHome, out) {
24064
24248
  const config4 = readTomlValue(tomlFile);
24065
24249
  for (const span2 of readTomlTables(tomlFile)) {
24066
24250
  if (span2.path[0] !== V1_TOML_SECTION_ROOT || span2.path[1] !== SERVER_KEY) continue;
24067
- if (span2.path.length === 2 && isV2McpTable(hostConfigValueAt(config4, span2.path))) continue;
24068
- if (span2.path.length === 3 && span2.path[2] === MCP_ENV_FIELD && isV2McpTable(hostConfigValueAt(config4, span2.path.slice(0, 2)))) continue;
24251
+ if (isV2McpTable(hostConfigValueAt(config4, span2.path.slice(0, 2)))) continue;
24069
24252
  out.push(finding(tomlFile, span2.header.trim(), V1_REASON.codexToml));
24070
24253
  }
24071
24254
  dataDir(join12(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
@@ -24228,7 +24411,7 @@ function detectV1(agent, home, scope = {}) {
24228
24411
 
24229
24412
  // src/core/ops/plugin-root.ts
24230
24413
  import { existsSync as existsSync7, readdirSync as readdirSync4, readFileSync as readFileSync9, realpathSync as realpathSync4 } from "node:fs";
24231
- import { dirname as dirname7, isAbsolute as isAbsolute2, join as join13, sep as sep4 } from "node:path";
24414
+ import { dirname as dirname7, isAbsolute as isAbsolute3, join as join13, sep as sep4 } from "node:path";
24232
24415
  import { fileURLToPath as fileURLToPath2 } from "node:url";
24233
24416
  function missing(agent, path8) {
24234
24417
  return new CtxError("PLUGIN_ROOT_MISSING", { agent, path: path8 });
@@ -24340,7 +24523,7 @@ function configEntryRoot(adapter, env) {
24340
24523
  const value = parseHostConfig(adapter.id, file2, current.text, current.format);
24341
24524
  const args = hostConfigValueAt(value, [...spec.key, MCP_ARGS_FIELD]);
24342
24525
  const script = Array.isArray(args) ? args[0] : void 0;
24343
- if (typeof script !== "string" || !isAbsolute2(script)) throw missing(adapter.id, file2);
24526
+ if (typeof script !== "string" || !isAbsolute3(script)) throw missing(adapter.id, file2);
24344
24527
  return dirname7(script);
24345
24528
  }
24346
24529
  function candidate(adapter, env, worktree) {
@@ -24560,11 +24743,122 @@ function nativeMcpWrong(dir, row5) {
24560
24743
  return true;
24561
24744
  }
24562
24745
  }
24746
+ function opencodeEntrySpec(entry) {
24747
+ return isObject4(entry) ? entry[OPENCODE_PACKAGE_FIELD] : Array.isArray(entry) ? entry[0] : entry;
24748
+ }
24749
+ function isNativeOpencodeEntry(entry, key) {
24750
+ const spec = opencodeEntrySpec(entry);
24751
+ if (typeof spec !== "string") return false;
24752
+ return spec.startsWith(OPENCODE_NPM_SPEC_PREFIX) || key === OPENCODE_PLUGINS_KEY && spec === SERVER_KEY;
24753
+ }
24563
24754
  function isOwnOpencodeEntry(entry, key, own4) {
24564
- const spec = isObject4(entry) ? entry[OPENCODE_PACKAGE_FIELD] : entry;
24755
+ const spec = opencodeEntrySpec(entry);
24565
24756
  if (typeof spec !== "string") return false;
24566
- if (spec === OPENCODE_GIT_SPEC || spec.startsWith(OPENCODE_NPM_SPEC_PREFIX) || own4.includes(spec)) return true;
24567
- return key === OPENCODE_PLUGINS_KEY && spec === SERVER_KEY;
24757
+ return spec === OPENCODE_GIT_SPEC || own4.includes(spec) || isNativeOpencodeEntry(entry, key);
24758
+ }
24759
+ function stringLiterals(src) {
24760
+ const out = [];
24761
+ let i = 0;
24762
+ while (i < src.length) {
24763
+ const c = src[i];
24764
+ if (c === "/" && src[i + 1] === "/") {
24765
+ const n = src.indexOf("\n", i);
24766
+ i = n < 0 ? src.length : n;
24767
+ continue;
24768
+ }
24769
+ if (c === "/" && src[i + 1] === "*") {
24770
+ const n = src.indexOf("*/", i + 2);
24771
+ i = n < 0 ? src.length : n + 2;
24772
+ continue;
24773
+ }
24774
+ if (c === '"' || c === "'" || c === "`") {
24775
+ let j = i + 1;
24776
+ let s = "";
24777
+ while (j < src.length && src[j] !== c) {
24778
+ if (src[j] === "\\") {
24779
+ s += src[j + 1] ?? "";
24780
+ j += 2;
24781
+ continue;
24782
+ }
24783
+ s += src[j];
24784
+ j++;
24785
+ }
24786
+ out.push(s);
24787
+ i = j + 1;
24788
+ continue;
24789
+ }
24790
+ i++;
24791
+ }
24792
+ return out;
24793
+ }
24794
+ var OPENCODE_PLUGINS_DIR = "plugins";
24795
+ var OPENCODE_PROJECT_DIR = ".opencode";
24796
+ var OPENCODE_PLUGIN_EXTS = [".js", ".mjs", ".ts"];
24797
+ var OPENCODE_PLUGIN_INDEX = "index";
24798
+ var OPENCODE_DIR_FILE_MAX = 64 * 1024;
24799
+ var OWN_PLUGIN_MODULES = [SERVER_KEY, `${SERVER_KEY}/server`];
24800
+ var FILE_URL_PREFIX = "file://";
24801
+ var NODE_MODULES_DIR = "node_modules";
24802
+ var PACKAGE_JSON_FILE = "package.json";
24803
+ var OPENCODE_PACKAGE_DIR_HINT = `${NODE_MODULES_DIR}/${SERVER_KEY}`;
24804
+ function opencodePluginDirs(configDir, worktree) {
24805
+ return [configDir, opencodeProjectDir(worktree)];
24806
+ }
24807
+ function opencodeProjectDir(worktree) {
24808
+ return join14(worktree, OPENCODE_PROJECT_DIR);
24809
+ }
24810
+ function packageResolves(fromDir) {
24811
+ for (let d = fromDir; ; d = dirname8(d)) {
24812
+ if (existsSync9(join14(d, NODE_MODULES_DIR, SERVER_KEY, PACKAGE_JSON_FILE))) return true;
24813
+ if (dirname8(d) === d) return false;
24814
+ }
24815
+ }
24816
+ function opencodeDirPlugins(dirs) {
24817
+ const bundle = opencodePluginFile();
24818
+ const ownFile = join14(bundle, ...OPENCODE_PLUGIN_PATH).split("\\").join("/");
24819
+ const isModule = (p) => OWN_PLUGIN_MODULES.includes(p);
24820
+ const isPath = (p) => {
24821
+ if (p === ownFile || p === `${FILE_URL_PREFIX}${ownFile}`) return true;
24822
+ const seg = p.split("/");
24823
+ const n = seg.length;
24824
+ return n >= 3 && seg[n - 1] === "plugin.js" && seg[n - 2] === "opencode" && seg[n - 3] === SERVER_KEY;
24825
+ };
24826
+ const out = [];
24827
+ for (const dir of dirs) {
24828
+ const pdir = join14(dir, OPENCODE_PLUGINS_DIR);
24829
+ let names;
24830
+ try {
24831
+ names = readdirSync5(pdir);
24832
+ } catch {
24833
+ continue;
24834
+ }
24835
+ for (const name of names) {
24836
+ const loose = OPENCODE_PLUGIN_EXTS.some((x) => name.endsWith(x)) ? [join14(pdir, name)] : [];
24837
+ const files = [...loose, ...OPENCODE_PLUGIN_EXTS.map((x) => join14(pdir, name, `${OPENCODE_PLUGIN_INDEX}${x}`))];
24838
+ for (const f of files) {
24839
+ let text;
24840
+ try {
24841
+ const b = readFileSync11(f);
24842
+ if (b.length > OPENCODE_DIR_FILE_MAX) continue;
24843
+ text = b.toString("utf8");
24844
+ } catch {
24845
+ continue;
24846
+ }
24847
+ const lits = stringLiterals(text).map((s) => s.split("\\").join("/")).filter((p) => isModule(p) || isPath(p));
24848
+ if (!lits.length) continue;
24849
+ const loads = lits.some((p) => {
24850
+ if (isModule(p)) return packageResolves(dirname8(f));
24851
+ const bare2 = p.startsWith(FILE_URL_PREFIX) ? p.slice(FILE_URL_PREFIX.length) : p;
24852
+ return existsSync9(isAbsolute4(bare2) ? bare2 : resolve9(dirname8(f), bare2));
24853
+ });
24854
+ out.push({ file: f, loads });
24855
+ }
24856
+ }
24857
+ }
24858
+ return out;
24859
+ }
24860
+ function opencodeDirPlugin(dirs) {
24861
+ return opencodeDirPlugins(dirs).find((p) => p.loads)?.file;
24568
24862
  }
24569
24863
  function opencodeMcpOwn(entry) {
24570
24864
  if (!isObject4(entry)) return false;
@@ -24572,14 +24866,22 @@ function opencodeMcpOwn(entry) {
24572
24866
  const [node3, script, flag, agent] = cmd;
24573
24867
  return isNodeCommand(node3) && typeof script === "string" && lastSegment(script) === SERVER_ENTRY_FILE && flag === AGENT_ARG && agent === "opencode";
24574
24868
  }
24575
- function opencodeListed(file2) {
24576
- const { value } = readParsed("opencode", file2);
24869
+ function opencodeFileValue(file2) {
24870
+ if (!existsSync9(file2)) return {};
24871
+ return parseHostConfig("opencode", file2, hostText(readFileSync11(file2, "utf8")), "jsonc");
24872
+ }
24873
+ function opencodeValueListed(value) {
24577
24874
  const bundle = opencodePluginFile();
24578
24875
  const own4 = [bundle, join14(bundle, ...OPENCODE_PLUGIN_PATH)];
24579
24876
  if ([OPENCODE_PLUGIN_KEY, OPENCODE_PLUGINS_KEY].some((key) => list2(isObject4(value) ? value[key] : void 0).some((e) => isOwnOpencodeEntry(e, key, own4)))) return true;
24580
24877
  const mcp = isObject4(value) && isObject4(value.mcp) ? value.mcp : {};
24581
24878
  return opencodeMcpOwn(mcp[SERVER_KEY]) || isObject4(mcp.servers) && opencodeMcpOwn(mcp.servers[SERVER_KEY]);
24582
24879
  }
24880
+ function opencodeListed(file2, worktree) {
24881
+ const dirs = [dirname8(file2), worktree];
24882
+ if (dirs.some((dir) => OPENCODE_CONFIG_FILES.some((name) => opencodeValueListed(opencodeFileValue(join14(dir, name)))))) return true;
24883
+ return opencodeDirPlugin(opencodePluginDirs(dirname8(file2), worktree)) !== void 0;
24884
+ }
24583
24885
  function mcpWrong(row5, home, env, worktree) {
24584
24886
  const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
24585
24887
  if (native !== null) return nativeMcpWrong(native, row5);
@@ -24589,7 +24891,7 @@ function mcpWrong(row5, home, env, worktree) {
24589
24891
  resolvePluginRoot(row5, env, worktree);
24590
24892
  return false;
24591
24893
  }
24592
- if (row5.id === "opencode") return !opencodeListed(file2);
24894
+ if (row5.id === "opencode") return !opencodeListed(file2, worktree);
24593
24895
  const cur = readHostConfig(row5.id, file2);
24594
24896
  return mergeOwnEntries(row5.id, cur.text, cur.format, row5, { nodePath: true, listEntries: [opencodePluginFile()] }).edits.length > 0;
24595
24897
  } catch {
@@ -24800,8 +25102,8 @@ async function checkIndex(project) {
24800
25102
  }
24801
25103
 
24802
25104
  // src/core/ops/doctor-env.ts
24803
- import { existsSync as existsSync11, readFileSync as readFileSync11, realpathSync as realpathSync6 } from "node:fs";
24804
- import { isAbsolute as isAbsolute3, join as join15, relative as relative4 } from "node:path";
25105
+ import { existsSync as existsSync11, readFileSync as readFileSync12, realpathSync as realpathSync6 } from "node:fs";
25106
+ import { isAbsolute as isAbsolute5, join as join15, relative as relative4 } from "node:path";
24805
25107
  function pass3(id, detail = DOCTOR_PASS_DETAIL) {
24806
25108
  return { id, label: DOCTOR_LABEL[id], status: "PASS", detail };
24807
25109
  }
@@ -24811,9 +25113,12 @@ function unknown3(id, detail, fixCommand) {
24811
25113
  function fail4(id, detail, fixCommand) {
24812
25114
  return { id, label: DOCTOR_LABEL[id], status: "FAIL", detail, fixCommand };
24813
25115
  }
25116
+ function warn(id, detail, fixCommand) {
25117
+ return { id, label: DOCTOR_LABEL[id], status: "WARN", detail, fixCommand };
25118
+ }
24814
25119
  function bundleVersion(bundleDir2) {
24815
25120
  try {
24816
- const v = JSON.parse(readFileSync11(join15(bundleDir2, D1_PACKAGE_FILE), "utf8")).version;
25121
+ const v = JSON.parse(readFileSync12(join15(bundleDir2, D1_PACKAGE_FILE), "utf8")).version;
24817
25122
  return typeof v === "string" && v !== "" ? v : void 0;
24818
25123
  } catch {
24819
25124
  return void 0;
@@ -24897,20 +25202,21 @@ function highestTag(stdout, tag2) {
24897
25202
  }
24898
25203
  return best;
24899
25204
  }
24900
- function versionRow(head2, installed, tag2, source, latest, tail) {
25205
+ function versionRow(head2, installed, tag2, source, latest, tail, update) {
24901
25206
  const cmp = compareVersions(installed, latest) ?? (installed === latest ? 0 : -1);
24902
25207
  if (cmp === 0) return pass3("D1", head2 + D1_LATEST_PASS(tag2, source) + tail);
24903
25208
  if (cmp > 0) return pass3("D1", head2 + D1_LATEST_AHEAD(tag2, source, latest) + tail);
24904
- return fail4("D1", head2 + D1_LATEST_UPDATE(tag2, source, latest) + tail, DOCTOR_FIX_UPGRADE);
25209
+ return warn("D1", head2 + D1_LATEST_UPDATE(tag2, source, latest) + tail, update);
24905
25210
  }
24906
25211
  async function checkVersion(i) {
24907
25212
  if (i.bundleSha === void 0) return unknown3("D1", D1_DEV_BUILD_DETAIL);
24908
25213
  const head2 = D1_PREFIX(i.version, i.bundleSha) + ": ";
24909
25214
  if (i.version === void 0) return unknown3("D1", head2 + D1_LATEST_UNKNOWN + ", " + D1_NO_VERSION, D1_NPM_CHECK_FIX);
24910
25215
  const tag2 = channelOf(i.version);
25216
+ const update = i.updateCommand ?? DOCTOR_FIX_UPGRADE;
24911
25217
  const git2 = findRuntime(GIT_BIN, i.env);
24912
25218
  const npm = await npmLatest(i.registryUrl, tag2, i.signal, i.timeoutMs);
24913
- if (npm.ok) return versionRow(head2, i.version, tag2, D1_SOURCE_NPM, npm.version, "");
25219
+ if (npm.ok) return versionRow(head2, i.version, tag2, D1_SOURCE_NPM, npm.version, "", update);
24914
25220
  let cause = D1_GIT_MISSING;
24915
25221
  if (git2 !== null) {
24916
25222
  const r = await runProcess([git2, GIT_LS_REMOTE, ...GIT_LS_REMOTE_TAG_ARGS, RELEASE_REPO_URL, RELEASE_TAG_PATTERN], {
@@ -24921,7 +25227,7 @@ async function checkVersion(i) {
24921
25227
  });
24922
25228
  if (r.exitCode === 0 && r.killed === null) {
24923
25229
  const latest = highestTag(r.stdout.toString("utf8"), tag2);
24924
- if (latest !== void 0) return versionRow(head2, i.version, tag2, D1_SOURCE_TAGS, latest, D1_CAUSE_JOIN + npm.cause);
25230
+ if (latest !== void 0) return versionRow(head2, i.version, tag2, D1_SOURCE_TAGS, latest, D1_CAUSE_JOIN + npm.cause, update);
24925
25231
  cause = D1_GIT_NO_TAG(tag2);
24926
25232
  } else {
24927
25233
  cause = gitCause(r, i.timeoutMs);
@@ -24957,15 +25263,16 @@ async function checkNode(i) {
24957
25263
  if (!await sqliteLoads()) return fail4("D2", withBun(D2_SQLITE_DETAIL), D2_SQLITE_FIX);
24958
25264
  return pass3("D2", bun.length === 0 ? DOCTOR_PASS_DETAIL : bun.join(D4_REASON_JOIN));
24959
25265
  }
24960
- function checkMcp(ctx) {
25266
+ function checkMcp(ctx, adapter) {
24961
25267
  const named2 = ctx.clientInfo !== void 0 && ctx.clientInfo.name !== "";
24962
25268
  const versioned = ctx.protocolVersion !== void 0 && ctx.protocolVersion !== "";
24963
- return named2 || versioned ? pass3("D6") : unknown3("D6", D6_UNKNOWN_DETAIL);
25269
+ if (named2 || versioned) return pass3("D6");
25270
+ return adapter?.installMode === "in-process" ? pass3("D6", D6_IN_PROCESS_DETAIL) : unknown3("D6", D6_UNKNOWN_DETAIL);
24964
25271
  }
24965
25272
  function piCwdInside(worktree, piCwd) {
24966
25273
  if (piCwd === void 0 || !existsSync11(piCwd)) return false;
24967
25274
  const rel = relative4(worktree, realpathSync6.native(piCwd));
24968
- return rel === "" || !rel.startsWith("..") && !isAbsolute3(rel);
25275
+ return rel === "" || !rel.startsWith("..") && !isAbsolute5(rel);
24969
25276
  }
24970
25277
  function checkProject(i) {
24971
25278
  const bad = fail4("D7", D7_DETAIL(i.project.source), D7_FIX);
@@ -24986,7 +25293,7 @@ function checkShell(env) {
24986
25293
  }
24987
25294
 
24988
25295
  // src/core/ops/doctor-hook.ts
24989
- import { existsSync as existsSync13, mkdirSync as mkdirSync4, mkdtempSync, readFileSync as readFileSync12, realpathSync as realpathSync8, rmSync as rmSync2, writeFileSync as writeFileSync2 } from "node:fs";
25296
+ import { existsSync as existsSync13, mkdirSync as mkdirSync4, mkdtempSync, readFileSync as readFileSync13, realpathSync as realpathSync8, rmSync as rmSync2, writeFileSync as writeFileSync2 } from "node:fs";
24990
25297
  import { tmpdir as tmpdir2 } from "node:os";
24991
25298
  import path7 from "node:path";
24992
25299
 
@@ -26749,7 +27056,7 @@ function hasType(v, t) {
26749
27056
  function same(a, b) {
26750
27057
  return JSON.stringify(a) === JSON.stringify(b);
26751
27058
  }
26752
- function resolve7(root, ref) {
27059
+ function resolve10(root, ref) {
26753
27060
  const parts = ref.split("/");
26754
27061
  if (parts[0] !== "#") throw new Error(`hook-shape: only local $ref is read, got ${ref}`);
26755
27062
  let at2 = root;
@@ -26762,7 +27069,7 @@ function shapeErrors(schema, value, root = schema, at2 = "$") {
26762
27069
  if (!NOTE_KEYS.has(k) && !RULE_KEYS.has(k)) throw new Error(`hook-shape: keyword ${k} at ${at2} is not read by the checker`);
26763
27070
  }
26764
27071
  const errs = [];
26765
- if (typeof schema.$ref === "string") errs.push(...shapeErrors(resolve7(root, schema.$ref), value, root, at2));
27072
+ if (typeof schema.$ref === "string") errs.push(...shapeErrors(resolve10(root, schema.$ref), value, root, at2));
26766
27073
  if (Array.isArray(schema.allOf)) for (const s of schema.allOf) errs.push(...shapeErrors(s, value, root, at2));
26767
27074
  if (schema.type !== void 0) {
26768
27075
  const types = Array.isArray(schema.type) ? schema.type : [schema.type];
@@ -26814,7 +27121,7 @@ function nodeLaunch(env, host = { bun: process.versions.bun, execPath: process.e
26814
27121
  import { createHash } from "node:crypto";
26815
27122
  import { existsSync as existsSync12, realpathSync as realpathSync7 } from "node:fs";
26816
27123
  import path6 from "node:path";
26817
- import { spawn as spawn2, spawnSync as spawnSync2 } from "node:child_process";
27124
+ import { spawn as spawn3, spawnSync as spawnSync2 } from "node:child_process";
26818
27125
 
26819
27126
  // src/setup/spawn-bin.ts
26820
27127
  import { spawnSync } from "node:child_process";
@@ -26929,24 +27236,24 @@ function pluginHooksFromReply(m, pluginId) {
26929
27236
  function askPluginHooks(env, pluginId, cwd) {
26930
27237
  const bin = whichBin("codex", env);
26931
27238
  if (!bin) return Promise.resolve({ kind: "absent" });
26932
- return new Promise((resolve10) => {
27239
+ return new Promise((resolve13) => {
26933
27240
  let asked;
26934
27241
  const done_ = (hooks) => hooks === void 0 ? { kind: "silent" } : { kind: "list", hooks, codexHome: asked };
26935
27242
  let f;
26936
27243
  try {
26937
27244
  f = spawnForm(bin, ["app-server"], env);
26938
27245
  } catch {
26939
- resolve10({ kind: "silent" });
27246
+ resolve13({ kind: "silent" });
26940
27247
  return;
26941
27248
  }
26942
- const child = spawn2(f.command, f.args, { env, cwd, stdio: ["pipe", "pipe", "ignore"], windowsVerbatimArguments: f.windowsVerbatimArguments, windowsHide: true });
27249
+ const child = spawn3(f.command, f.args, { env, cwd, stdio: ["pipe", "pipe", "ignore"], windowsVerbatimArguments: f.windowsVerbatimArguments, windowsHide: true });
26943
27250
  let buf = "";
26944
27251
  let done = false;
26945
27252
  let exited = false;
26946
27253
  let result;
26947
27254
  const settle3 = () => {
26948
27255
  clearTimeout(grace);
26949
- resolve10(done_(result));
27256
+ resolve13(done_(result));
26950
27257
  };
26951
27258
  let grace;
26952
27259
  const finish2 = (v) => {
@@ -27038,7 +27345,7 @@ function loadFixture(bundleDir2, agent) {
27038
27345
  if (!existsSync13(file2)) return { cause: D5_FIXTURE_FILE_ABSENT(file2) };
27039
27346
  let all;
27040
27347
  try {
27041
- all = JSON.parse(hostText(readFileSync12(file2, "utf8")));
27348
+ all = JSON.parse(hostText(readFileSync13(file2, "utf8")));
27042
27349
  } catch (err) {
27043
27350
  return { cause: D5_FIXTURE_PARSE(file2, err instanceof Error ? err.message : String(err)) };
27044
27351
  }
@@ -27306,10 +27613,10 @@ async function checkHookRoundTrip(i) {
27306
27613
 
27307
27614
  // src/core/ops/db-heal.ts
27308
27615
  import { existsSync as existsSync14, mkdirSync as mkdirSync6, rmSync as rmSync4 } from "node:fs";
27309
- import { basename as basename4, dirname as dirname8, join as join17 } from "node:path";
27616
+ import { basename as basename4, dirname as dirname9, join as join17 } from "node:path";
27310
27617
 
27311
27618
  // src/core/store/owners.ts
27312
- import { mkdirSync as mkdirSync5, readdirSync as readdirSync6, readFileSync as readFileSync13, rmSync as rmSync3, writeFileSync as writeFileSync3 } from "node:fs";
27619
+ import { mkdirSync as mkdirSync5, readdirSync as readdirSync6, readFileSync as readFileSync14, rmSync as rmSync3, writeFileSync as writeFileSync3 } from "node:fs";
27313
27620
  import { basename as basename3, join as join16 } from "node:path";
27314
27621
  function ownersDir(configDir, projectKey) {
27315
27622
  return join16(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
@@ -27353,7 +27660,7 @@ function listLiveOwners(configDir, projectKey) {
27353
27660
  const file2 = join16(dir, name);
27354
27661
  let text;
27355
27662
  try {
27356
- text = readFileSync13(file2, "utf8");
27663
+ text = readFileSync14(file2, "utf8");
27357
27664
  } catch (err) {
27358
27665
  if (errCode2(err) === "ENOENT") continue;
27359
27666
  throw err;
@@ -27437,7 +27744,7 @@ async function healOrphan(project, files, row5) {
27437
27744
  const moved = [];
27438
27745
  let dir = "";
27439
27746
  try {
27440
- dir = makeOrphanDir(dirname8(project.dbPath));
27747
+ dir = makeOrphanDir(dirname9(project.dbPath));
27441
27748
  for (const f of files) {
27442
27749
  const to = join17(dir, basename4(f.path));
27443
27750
  renameWithRetry(f.path, to);
@@ -27504,9 +27811,40 @@ function buildReportHead(input) {
27504
27811
  return lines.concat(tail).join("\n");
27505
27812
  }
27506
27813
 
27814
+ // src/core/ops/unsupported-host.ts
27815
+ var SUPPORTED_AGENTS_LINE = `Supported agents: ${AGENT_IDS.join(", ")} (${SUPPORTED_AGENTS_DOCS_URL}).`;
27816
+ function UNSUPPORTED_HOST_LINE(name) {
27817
+ return `${name} is not a supported host today. The MCP server runs here; hooks are not checked. ${SUPPORTED_AGENTS_LINE}`;
27818
+ }
27819
+ function segmentsOf(dir) {
27820
+ let parts = [dir];
27821
+ for (const sep5 of V1_PATH_SEPS) parts = parts.flatMap((p) => p.split(sep5));
27822
+ return parts;
27823
+ }
27824
+ function hasRun(parts, run) {
27825
+ for (let i = 0; i + run.length <= parts.length; i++) if (run.every((seg, k) => parts[i + k] === seg)) return true;
27826
+ return false;
27827
+ }
27828
+ function unsupportedHostOf(sig) {
27829
+ if (sig.clientName !== void 0 && sig.clientName !== "") {
27830
+ const n = sig.clientName.toLowerCase();
27831
+ const hit = UNSUPPORTED_HOSTS.find((h) => h.clientNames.includes(n));
27832
+ if (hit !== void 0) return hit;
27833
+ }
27834
+ if (sig.bundleDir !== void 0) {
27835
+ const parts = segmentsOf(sig.bundleDir);
27836
+ const hit = UNSUPPORTED_HOSTS.find((h) => h.pluginPaths.some((p) => hasRun(parts, p)));
27837
+ if (hit !== void 0) return hit;
27838
+ }
27839
+ if (sig.clientName !== void 0 && sig.clientName !== "") return void 0;
27840
+ const env = sig.env;
27841
+ if (env === void 0) return void 0;
27842
+ return UNSUPPORTED_HOSTS.find((h) => h.envVars.some((v) => env[v] !== void 0 && env[v] !== ""));
27843
+ }
27844
+
27507
27845
  // src/core/ops/doctor-issue.ts
27508
27846
  import { spawnSync as spawnSync3 } from "node:child_process";
27509
- import { closeSync as closeSync2, existsSync as existsSync15, fstatSync, mkdirSync as mkdirSync7, openSync as openSync2, readFileSync as readFileSync14, readSync as readSync2, realpathSync as realpathSync9, writeFileSync as writeFileSync4 } from "node:fs";
27847
+ import { closeSync as closeSync2, existsSync as existsSync15, fstatSync, mkdirSync as mkdirSync7, openSync as openSync2, readFileSync as readFileSync15, readSync as readSync2, realpathSync as realpathSync9, writeFileSync as writeFileSync4 } from "node:fs";
27510
27848
  import { delimiter, join as join18 } from "node:path";
27511
27849
  var TOKEN_PREFIXES = ["ghp_", "gho_", "github_pat_", "sk-", "xoxb-", "AKIA"];
27512
27850
  function tildeOf(env) {
@@ -27609,7 +27947,7 @@ function agentConfig(adapter, env, worktree) {
27609
27947
  }
27610
27948
  let text = "";
27611
27949
  try {
27612
- text = readFileSync14(f.path, "utf8");
27950
+ text = readFileSync15(f.path, "utf8");
27613
27951
  } catch (err) {
27614
27952
  out.push(`${f.label}: ${f.path} (read: ${err instanceof Error ? err.message : String(err)})`);
27615
27953
  continue;
@@ -27623,12 +27961,13 @@ function agentConfig(adapter, env, worktree) {
27623
27961
  function failing(rows) {
27624
27962
  return rows.filter((r) => r.status === "FAIL");
27625
27963
  }
27626
- function issueTitle(agent, rows) {
27627
- return `ctx_doctor ${agent}: ${failing(rows).map((r) => `${r.id} ${r.label}`).join(", ")} FAIL`;
27964
+ function issueTitle(agent, rows, other) {
27965
+ return `ctx_doctor ${agent}${other === void 0 ? "" : ` (${other.name} is not a supported host today)`}: ${failing(rows).map((r) => `${r.id} ${r.label}`).join(", ")} FAIL`;
27628
27966
  }
27629
- function summaryOf(agent, rows) {
27967
+ function summaryOf(agent, rows, other) {
27630
27968
  const f = failing(rows)[0];
27631
- return f === void 0 ? `ctx_doctor ${agent}` : `${f.id} ${f.label} FAIL on ${agent}: ${f.detail}`;
27969
+ const tag2 = other === void 0 ? "" : `${other.name} is not a supported host today. `;
27970
+ return tag2 + (f === void 0 ? `ctx_doctor ${agent}` : `${f.id} ${f.label} FAIL on ${agent}: ${f.detail}`);
27632
27971
  }
27633
27972
  async function buildIssueBody(i) {
27634
27973
  const tilde = tildeOf(i.env);
@@ -27638,7 +27977,7 @@ async function buildIssueBody(i) {
27638
27977
  const envNames = DOCTOR_ENV_NAMES.map((n) => i.env[n] === void 0 ? `${n} (unset)` : `${n}=${i.env[n]}`);
27639
27978
  const pathTools = DOCTOR_PATH_TOOLS.map((t) => `PATH holds ${t}: ${onPath(i.env, t).join(", ") || "(absent)"}`);
27640
27979
  const sections = {
27641
- "Summary": [summaryOf(agent, i.rows)],
27980
+ "Summary": [summaryOf(agent, i.rows, i.unsupported)],
27642
27981
  "ctx-report": [i.table],
27643
27982
  "What happened": [
27644
27983
  "Rows that need a look:",
@@ -27684,9 +28023,9 @@ async function writeIssueReport(i) {
27684
28023
  const file2 = join18(dir, `${DOCTOR_REPORT_FILE_PREFIX}${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.md`);
27685
28024
  writeFileSync4(file2, body);
27686
28025
  const shown2 = tilde(file2);
27687
- const title = issueTitle(i.adapter.id, i.rows);
28026
+ const title = issueTitle(i.adapter.id, i.rows, i.unsupported);
27688
28027
  const gh = [`gh issue create --repo ${ISSUE_REPO_SLUG} --label bug \\`, `${DOCTOR_GH_NEXT}title ${JSON.stringify(title)} \\`, `${DOCTOR_GH_NEXT}body-file ${shown2}`];
27689
- return [DOCTOR_REPORT_LINE + shown2, DOCTOR_GH_LINE + gh[0], gh[1], gh[2], DOCTOR_URL_LINE + formUrl(title, summaryOf(i.adapter.id, i.rows)), DOCTOR_RULES_LINE + ISSUE_GUIDE_URL];
28028
+ return [DOCTOR_REPORT_LINE + shown2, DOCTOR_GH_LINE + gh[0], gh[1], gh[2], DOCTOR_URL_LINE + formUrl(title, summaryOf(i.adapter.id, i.rows, i.unsupported)), DOCTOR_RULES_LINE + ISSUE_GUIDE_URL];
27690
28029
  }
27691
28030
  function formUrl(title, summary) {
27692
28031
  const base = `${ISSUE_FORM_URL}&title=${encodeURIComponent(title)}`;
@@ -27715,6 +28054,12 @@ async function codexDb(ctx, adapter) {
27715
28054
  return null;
27716
28055
  }
27717
28056
  }
28057
+ function d1UpdateCommand(agent, env, other) {
28058
+ return other === void 0 ? hostUpdateCommand(agent, env) : UNSUPPORTED_HOST_LINE(other.name);
28059
+ }
28060
+ function unsupportedRow(id, h) {
28061
+ return { id, label: DOCTOR_LABEL[id], status: "WARN", detail: UNSUPPORTED_HOST_LINE(h.name) };
28062
+ }
27718
28063
  async function hookRow(ctx, adapter, host) {
27719
28064
  const db = await codexDb(ctx, adapter);
27720
28065
  const runStart = Date.now();
@@ -27742,7 +28087,7 @@ function ownServerId(configDir, projectKey) {
27742
28087
  if (!existsSync16(dir)) return "";
27743
28088
  for (const name of readdirSync7(dir)) {
27744
28089
  if (!name.endsWith(OWNER_PID_EXT)) continue;
27745
- if (readFileSync15(join19(dir, name), "utf8").trim() === String(process.pid)) return basename5(name, OWNER_PID_EXT);
28090
+ if (readFileSync16(join19(dir, name), "utf8").trim() === String(process.pid)) return basename5(name, OWNER_PID_EXT);
27746
28091
  }
27747
28092
  return "";
27748
28093
  }
@@ -27750,16 +28095,18 @@ async function runDoctorChecks(ctx, adapter, host0) {
27750
28095
  const host = adapter.id === "codex" ? { ...host0, env: { ...host0.env, CODEX_HOME: codexRunDirOf(host0.env, homeDirOf(host0.env) ?? "", host0.bundleDir) } } : host0;
27751
28096
  const env = host.env;
27752
28097
  const project = ctx.project;
28098
+ const other = adapter.installMode === "in-process" ? void 0 : unsupportedHostOf({ clientName: ctx.clientInfo?.name, bundleDir: host.bundleDir, env });
27753
28099
  let integrityFailed = false;
27754
28100
  let orphan = [];
27755
28101
  const checks = {
27756
- D1: () => checkVersion({ bundleSha: BUNDLE_SHA, version: bundleVersion(host.bundleDir), registryUrl: D1_REGISTRY_URL, timeoutMs: DOCTOR_GIT_TIMEOUT_MS, env: buildChildEnv(env), cwd: project.worktree, signal: ctx.signal }),
28102
+ D1: () => checkVersion({ bundleSha: BUNDLE_SHA, version: bundleVersion(host.bundleDir), registryUrl: D1_REGISTRY_URL, timeoutMs: DOCTOR_GIT_TIMEOUT_MS, env: buildChildEnv(env), cwd: project.worktree, signal: ctx.signal, updateCommand: d1UpdateCommand(adapter.id, env, other) }),
27757
28103
  D2: () => checkNode({ nodeVersion: process.version, bunVersion: process.versions.bun }),
27758
- D3: () => checkHostConfig(adapter, env, project.worktree),
28104
+ D3: () => other !== void 0 ? unsupportedRow("D3", other) : checkHostConfig(adapter, env, project.worktree),
28105
+ // D-UNSUPPORTED-HOSTS-1
27759
28106
  D4: () => checkV1Leftovers(adapter.id, requireHomeDir(env), { project: project.worktree, piAgentDir: piAgentDirOf(env, requireHomeDir(env)), claudeDir: claudeDirOf(env, requireHomeDir(env)), codexDir: codexDirOf(env, requireHomeDir(env)), geminiDir: geminiDirOf(env, requireHomeDir(env)), copilotDir: copilotDirOf(env, requireHomeDir(env)), kiroDir: kiroDirOf(env, requireHomeDir(env)), opencodeDir: opencodeDirOf(env, requireHomeDir(env)) }),
27760
- D5: () => hookRow(ctx, adapter, host),
28107
+ D5: () => other !== void 0 ? unsupportedRow("D5", other) : hookRow(ctx, adapter, host),
27761
28108
  D5b: () => checkDoubleFire(adapter.id, project.worktree),
27762
- D6: () => checkMcp(ctx),
28109
+ D6: () => checkMcp(ctx, adapter),
27763
28110
  D7: () => checkProject({ project, adapter, piCwd: host.piCwd }),
27764
28111
  D8: async () => {
27765
28112
  const r = await checkDb(project);
@@ -27806,7 +28153,7 @@ async function doctorReply(ctx, host) {
27806
28153
  let notes = [];
27807
28154
  if (failed) {
27808
28155
  try {
27809
- notes = await writeIssueReport({ ctx, adapter, env: host.env, bundleDir: host.bundleDir, rows, envLine: envLine2, table: table3 });
28156
+ notes = await writeIssueReport({ unsupported: adapter.installMode === "in-process" ? void 0 : unsupportedHostOf({ clientName: ctx.clientInfo?.name, bundleDir: host.bundleDir, env: host.env }), ctx, adapter, env: host.env, bundleDir: host.bundleDir, rows, envLine: envLine2, table: table3 });
27810
28157
  } catch (err) {
27811
28158
  notes = [`Report file: ${lineOf2(err)}`];
27812
28159
  }
@@ -27840,7 +28187,7 @@ var ctxDoctor = Object.freeze({
27840
28187
  // src/core/tools/execute.ts
27841
28188
  import { existsSync as existsSync17, mkdtempSync as mkdtempSync2, rmSync as rmSync5, writeFileSync as writeFileSync5 } from "node:fs";
27842
28189
  import { tmpdir as tmpdir3 } from "node:os";
27843
- import { dirname as dirname10, join as join20, parse as parse3, resolve as resolve8 } from "node:path";
28190
+ import { dirname as dirname11, join as join20, parse as parse3, resolve as resolve11 } from "node:path";
27844
28191
 
27845
28192
  // src/core/sandbox/win-build.ts
27846
28193
  var SEPARATORS2 = ";&|(\n";
@@ -27923,7 +28270,7 @@ function schemaLine(issue4) {
27923
28270
  }
27924
28271
  function fileError(given, abs, root) {
27925
28272
  let dir = abs;
27926
- while (!existsSync17(dir) && dirname10(dir) !== dir) dir = dirname10(dir);
28273
+ while (!existsSync17(dir) && dirname11(dir) !== dir) dir = dirname11(dir);
27927
28274
  if (isInside(root, dir)) return null;
27928
28275
  return new CtxError("OUTSIDE_ROOT", { p: given, root }).toLine();
27929
28276
  }
@@ -27957,7 +28304,7 @@ function spawnFailed(argv0, cwd) {
27957
28304
  }
27958
28305
  async function finish(input, ctx, r, exitCode, journal) {
27959
28306
  const isError = exitCode !== 0 && !(input.language === "shell" && exitCode === SOFT_EXIT && r.stderr.length === 0);
27960
- const combined = r.stdout.toString("utf8") + (exitCode !== 0 ? r.stderr.toString("utf8") : "");
28307
+ const combined = r.stdout.toString("utf8") + (exitCode !== 0 ? r.stderr.toString("utf8") : "") + (r.held === true ? "\n" + BACKGROUND_HOLD_NOTE + "\n" : "");
27961
28308
  const fullBytes = Buffer.byteLength(combined, "utf8");
27962
28309
  const head2 = summaryLine(exitCode, fullBytes);
27963
28310
  const intent = input.intent ?? "";
@@ -27987,7 +28334,7 @@ async function handler3(raw, ctx) {
27987
28334
  const cwd = ctx.project.worktree;
27988
28335
  const extra = { ...PLAIN_OUTPUT_ENV2 };
27989
28336
  if (input.file !== void 0) {
27990
- const abs = resolve8(cwd, input.file);
28337
+ const abs = resolve11(cwd, input.file);
27991
28338
  const bad = fileError(input.file, abs, ctx.project.containmentRoot);
27992
28339
  if (bad !== null) return fail5(bad);
27993
28340
  extra.CTX_FILE = abs;
@@ -28041,11 +28388,11 @@ var ctxExecute = {
28041
28388
  };
28042
28389
 
28043
28390
  // src/core/tools/index.ts
28044
- import { existsSync as existsSync18, readFileSync as readFileSync17, statSync as statSync8 } from "node:fs";
28045
- import { dirname as dirname11, extname as extname3, join as join22, relative as relative5, resolve as resolve9 } from "node:path";
28391
+ import { existsSync as existsSync18, readFileSync as readFileSync18, statSync as statSync8 } from "node:fs";
28392
+ import { dirname as dirname12, extname as extname3, join as join22, relative as relative5, resolve as resolve12 } from "node:path";
28046
28393
 
28047
28394
  // src/core/index/walk.ts
28048
- import { readdirSync as readdirSync8, readFileSync as readFileSync16, realpathSync as realpathSync10, statSync as statSync7 } from "node:fs";
28395
+ import { readdirSync as readdirSync8, readFileSync as readFileSync17, realpathSync as realpathSync10, statSync as statSync7 } from "node:fs";
28049
28396
  import { join as join21 } from "node:path";
28050
28397
  var GITIGNORE = ".gitignore";
28051
28398
  var GIT_DIR = ".git";
@@ -28107,7 +28454,7 @@ function compareFound(a, b) {
28107
28454
  function readRules(file2, base) {
28108
28455
  let body;
28109
28456
  try {
28110
- body = readFileSync16(file2, "utf8");
28457
+ body = readFileSync17(file2, "utf8");
28111
28458
  } catch {
28112
28459
  return [];
28113
28460
  }
@@ -28329,18 +28676,18 @@ function request(u, conn, proxy, signal) {
28329
28676
  const host = bare(u.hostname);
28330
28677
  const port = u.port === "" ? defaultPort(u.protocol) : Number(u.port);
28331
28678
  const path8 = u.pathname + u.search;
28332
- return new Promise((resolve10, reject) => {
28679
+ return new Promise((resolve13, reject) => {
28333
28680
  const onErr = (err) => reject(fail6(causeCode(err)));
28334
28681
  if (proxy === void 0) {
28335
28682
  const mod = u.protocol === "https:" ? https : http;
28336
28683
  const req = mod.request({ host: conn.address, port, path: path8, signal, servername: tlsName(host), headers: { host: u.host } });
28337
- req.on("response", resolve10).on("error", onErr).end();
28684
+ req.on("response", resolve13).on("error", onErr).end();
28338
28685
  return;
28339
28686
  }
28340
28687
  const proxyHeaders = proxy.auth === void 0 ? {} : { "proxy-authorization": proxy.auth };
28341
28688
  if (u.protocol === "http:") {
28342
28689
  const req = http.request({ host: conn.address, port: conn.port, path: u.href, signal, headers: { host: u.host, ...proxyHeaders } });
28343
- req.on("response", resolve10).on("error", onErr).end();
28690
+ req.on("response", resolve13).on("error", onErr).end();
28344
28691
  return;
28345
28692
  }
28346
28693
  const authority = (isIP(host) === 6 ? "[" + host + "]" : host) + ":" + port;
@@ -28360,16 +28707,16 @@ function request(u, conn, proxy, signal) {
28360
28707
  headers: { host: u.host },
28361
28708
  createConnection: () => tlsConnect({ socket, host, servername: tlsName(host) })
28362
28709
  });
28363
- req.on("response", resolve10).on("error", onErr).end();
28710
+ req.on("response", resolve13).on("error", onErr).end();
28364
28711
  });
28365
28712
  tunnel.end();
28366
28713
  });
28367
28714
  }
28368
28715
  function readBody(res) {
28369
- return new Promise((resolve10, reject) => {
28716
+ return new Promise((resolve13, reject) => {
28370
28717
  const parts = [];
28371
28718
  res.on("data", (b) => parts.push(b));
28372
- res.on("end", () => resolve10(Buffer.concat(parts)));
28719
+ res.on("end", () => resolve13(Buffer.concat(parts)));
28373
28720
  res.on("error", (err) => reject(fail6(causeCode(err))));
28374
28721
  res.on("aborted", () => reject(fail6("ECONNRESET")));
28375
28722
  });
@@ -32235,19 +32582,19 @@ function kindOfType(contentType) {
32235
32582
  }
32236
32583
  function readUtf8(absPath) {
32237
32584
  try {
32238
- return utf8.decode(readFileSync17(absPath));
32585
+ return utf8.decode(readFileSync18(absPath));
32239
32586
  } catch {
32240
32587
  return void 0;
32241
32588
  }
32242
32589
  }
32243
32590
  function missingOrOutside(given, abs, root) {
32244
32591
  let dir = abs;
32245
- while (!existsSync18(dir) && dirname11(dir) !== dir) dir = dirname11(dir);
32592
+ while (!existsSync18(dir) && dirname12(dir) !== dir) dir = dirname12(dir);
32246
32593
  if (dir !== abs && isInside(root, dir)) return new CtxError("INVALID_ARGS", { field: "path", action: "pass an existing file or folder" });
32247
32594
  return new CtxError("OUTSIDE_ROOT", { p: given, root });
32248
32595
  }
32249
32596
  function pathItems(input, project) {
32250
- const abs = resolve9(project.worktree, input.path);
32597
+ const abs = resolve12(project.worktree, input.path);
32251
32598
  if (!isInside(project.containmentRoot, abs)) throw missingOrOutside(input.path, abs, project.containmentRoot);
32252
32599
  const base = relative5(project.worktree, abs);
32253
32600
  if (statSync8(abs).isDirectory()) {
@@ -32419,7 +32766,8 @@ function reply3(text, isError) {
32419
32766
  return { text, isError, sandboxBytes: 0 };
32420
32767
  }
32421
32768
  async function handler6(input, ctx) {
32422
- const sessionId = input.session ?? ctx.sessionId;
32769
+ const given = input.session !== void 0 && input.session.trim() !== "" ? input.session : void 0;
32770
+ const sessionId = given ?? ctx.sessionId;
32423
32771
  if (sessionId === "") return reply3(RESUME_NO_SESSION_LINE, true);
32424
32772
  const db = await openDb(ctx.project, { readOnly: true });
32425
32773
  try {
@@ -32793,7 +33141,7 @@ var ctxStats = Object.freeze({
32793
33141
 
32794
33142
  // src/core/ops/host-write.ts
32795
33143
  import { copyFileSync, existsSync as existsSync19, mkdirSync as mkdirSync8, writeFileSync as writeFileSync6 } from "node:fs";
32796
- import { dirname as dirname12, join as join23 } from "node:path";
33144
+ import { dirname as dirname13, join as join23 } from "node:path";
32797
33145
  function defaultWrite(file2, text) {
32798
33146
  writeFileSync6(file2, text, "utf8");
32799
33147
  }
@@ -32825,7 +33173,7 @@ function writeWithRollback(file2, text, write2, atomic) {
32825
33173
  const trash = file2 + UPGRADE_TRASH_SUFFIX;
32826
33174
  const tmp = `${file2}${HOST_CONFIG_TMP_SUFFIX}.${process.pid}`;
32827
33175
  const had = existsSync19(file2);
32828
- mkdirSync8(dirname12(file2), { recursive: true });
33176
+ mkdirSync8(dirname13(file2), { recursive: true });
32829
33177
  if (had) copyFileSync(file2, trash);
32830
33178
  try {
32831
33179
  write2(tmp, text);
@@ -32992,7 +33340,7 @@ function runUninstall(input) {
32992
33340
  }
32993
33341
 
32994
33342
  // src/core/ops/v1-remove.ts
32995
- import { copyFileSync as copyFileSync2, existsSync as existsSync21, readFileSync as readFileSync18, rmSync as rmSync7 } from "node:fs";
33343
+ import { copyFileSync as copyFileSync2, existsSync as existsSync21, readFileSync as readFileSync19, rmSync as rmSync7 } from "node:fs";
32996
33344
  var isObj4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
32997
33345
  var areaOf = (f) => f.path === "" ? f.file : f.file + UPGRADE_AREA_KEY_SEP + f.path;
32998
33346
  var row3 = (f, after) => ({ area: areaOf(f), before: f.reason, after });
@@ -33043,8 +33391,8 @@ function locate(doc, path8) {
33043
33391
  return null;
33044
33392
  }
33045
33393
  function stripJsonEntries(agent, file2, findings, kept, undo) {
33046
- const layout = hostLayout(readFileSync18(file2, "utf8"));
33047
- const text = hostText(readFileSync18(file2, "utf8"));
33394
+ const layout = hostLayout(readFileSync19(file2, "utf8"));
33395
+ const text = hostText(readFileSync19(file2, "utf8"));
33048
33396
  const doc = parseHostConfig(agent, file2, text, "jsonc");
33049
33397
  const hit = /* @__PURE__ */ new Set();
33050
33398
  const byContainer = /* @__PURE__ */ new Map();
@@ -33094,7 +33442,7 @@ function removeV1(agent, findings, project) {
33094
33442
  continue;
33095
33443
  }
33096
33444
  if (file2.endsWith(TOML_EXT)) {
33097
- const rawToml = readFileSync18(file2, "utf8");
33445
+ const rawToml = readFileSync19(file2, "utf8");
33098
33446
  const tomlLayout = hostLayout(rawToml);
33099
33447
  let text = hostText(rawToml);
33100
33448
  for (const f of list4) {
@@ -33152,8 +33500,8 @@ function pluginRootRow(adapter, env) {
33152
33500
  }
33153
33501
  return root === own4 ? [] : [row4(UPGRADE_PLUGIN_ROOT_AREA, root, own4)];
33154
33502
  }
33155
- function hostRow(adapter) {
33156
- return row4(UPGRADE_HOST_AREA, "", UPGRADE_HOST_COMMAND[adapter.id]);
33503
+ function hostRow(adapter, env) {
33504
+ return row4(UPGRADE_HOST_AREA, "", hostUpdateCommand(adapter.id, env));
33157
33505
  }
33158
33506
  function upgrade(adapter, deps, home) {
33159
33507
  let removal = null;
@@ -33161,7 +33509,7 @@ function upgrade(adapter, deps, home) {
33161
33509
  const step5 = regenerateHostConfig(adapter, home, { env: deps.env, write: deps.write });
33162
33510
  const findings = detectV1(adapter.id, home, { project: deps.project.worktree, piAgentDir: piAgentDirOf(deps.env, home), claudeDir: claudeDirOf(deps.env, home), geminiDir: geminiDirOf(deps.env, home), copilotDir: copilotDirOf(deps.env, home), kiroDir: kiroDirOf(deps.env, home), opencodeDir: opencodeDirOf(deps.env, home) });
33163
33511
  removal = removeV1(adapter.id, findings, deps.project.worktree);
33164
- const rows = [hostRow(adapter), ...step5, ...removal.rows];
33512
+ const rows = [hostRow(adapter, deps.env), ...step5, ...removal.rows];
33165
33513
  removal.commit();
33166
33514
  return rows;
33167
33515
  } catch (err) {
@@ -33254,7 +33602,7 @@ function checkCall(tool, input) {
33254
33602
  // src/entries/server.ts
33255
33603
  import { randomUUID } from "node:crypto";
33256
33604
  import { existsSync as existsSync23, realpathSync as realpathSync12, rmSync as rmSync9 } from "node:fs";
33257
- import { dirname as dirname13, join as join26 } from "node:path";
33605
+ import { dirname as dirname14, join as join26 } from "node:path";
33258
33606
  import { fileURLToPath as fileURLToPath3 } from "node:url";
33259
33607
 
33260
33608
  // node_modules/@modelcontextprotocol/server/dist/chunk-Br0eD_fh.mjs
@@ -35789,14 +36137,14 @@ var $ZodObject2 = /* @__PURE__ */ $constructor2("$ZodObject", (inst, def) => {
35789
36137
  const shape = zod.def.shape;
35790
36138
  const propValues = {};
35791
36139
  for (const key in shape) {
35792
- const field = shape[key]._zod;
35793
- if (field.values) {
36140
+ const field2 = shape[key]._zod;
36141
+ if (field2.values) {
35794
36142
  if (!Object.prototype.hasOwnProperty.call(propValues, key)) {
35795
36143
  assignProp2(propValues, key, /* @__PURE__ */ new Set());
35796
36144
  }
35797
- for (const v of field.values)
36145
+ for (const v of field2.values)
35798
36146
  propValues[key].add(v);
35799
- if (field.optin !== void 0)
36147
+ if (field2.optin !== void 0)
35800
36148
  propValues[key].add(void 0);
35801
36149
  }
35802
36150
  }
@@ -36733,7 +37081,7 @@ var recursive = /* @__PURE__ */ new WeakMap();
36733
37081
  var NONE3 = 0;
36734
37082
  var ASSUMED = 1;
36735
37083
  var PROVEN = 2;
36736
- function isRecursive(inst, stack2, resolve10) {
37084
+ function isRecursive(inst, stack2, resolve13) {
36737
37085
  const cached4 = recursive.get(inst);
36738
37086
  if (cached4 !== void 0)
36739
37087
  return cached4 ? PROVEN : NONE3;
@@ -36743,7 +37091,7 @@ function isRecursive(inst, stack2, resolve10) {
36743
37091
  let result = NONE3;
36744
37092
  const check2 = (child) => {
36745
37093
  if (result !== PROVEN && child?._zod) {
36746
- const answer3 = isRecursive(child, stack2, resolve10);
37094
+ const answer3 = isRecursive(child, stack2, resolve13);
36747
37095
  if (answer3 > result)
36748
37096
  result = answer3;
36749
37097
  }
@@ -36754,7 +37102,7 @@ function isRecursive(inst, stack2, resolve10) {
36754
37102
  const desc = Object.getOwnPropertyDescriptor(sh, key);
36755
37103
  if (spread && !desc.enumerable)
36756
37104
  continue;
36757
- const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack2, resolve10) : NONE3;
37105
+ const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack2, resolve13) : NONE3;
36758
37106
  if (child > answer3)
36759
37107
  answer3 = child;
36760
37108
  }
@@ -36818,7 +37166,7 @@ function isRecursive(inst, stack2, resolve10) {
36818
37166
  break;
36819
37167
  // `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
36820
37168
  case "lazy": {
36821
- const inner = def._cachedInner ?? (resolve10 ? inst._zod.innerType : void 0);
37169
+ const inner = def._cachedInner ?? (resolve13 ? inst._zod.innerType : void 0);
36822
37170
  merge5(inner ? isRecursive(inner, stack2, false) : ASSUMED);
36823
37171
  break;
36824
37172
  }
@@ -38546,8 +38894,8 @@ var objectProcessor = (schema, ctx, _json, params) => {
38546
38894
  }
38547
38895
  const requiredKeys = [];
38548
38896
  for (const key of Object.keys(shape)) {
38549
- const field = def.shape[key];
38550
- if (ctx.io === "input" ? inputOptin(field) === void 0 : field._zod.optout === void 0) {
38897
+ const field2 = def.shape[key];
38898
+ if (ctx.io === "input" ? inputOptin(field2) === void 0 : field2._zod.optout === void 0) {
38551
38899
  requiredKeys.push(key);
38552
38900
  }
38553
38901
  }
@@ -43318,14 +43666,14 @@ var $ZodObject3 = /* @__PURE__ */ $constructor3("$ZodObject", (inst, def) => {
43318
43666
  const shape = zod.def.shape;
43319
43667
  const propValues = {};
43320
43668
  for (const key in shape) {
43321
- const field = shape[key]._zod;
43322
- if (field.values) {
43669
+ const field2 = shape[key]._zod;
43670
+ if (field2.values) {
43323
43671
  if (!Object.prototype.hasOwnProperty.call(propValues, key)) {
43324
43672
  assignProp3(propValues, key, /* @__PURE__ */ new Set());
43325
43673
  }
43326
- for (const v of field.values)
43674
+ for (const v of field2.values)
43327
43675
  propValues[key].add(v);
43328
- if (field.optin !== void 0)
43676
+ if (field2.optin !== void 0)
43329
43677
  propValues[key].add(void 0);
43330
43678
  }
43331
43679
  }
@@ -44262,7 +44610,7 @@ var recursive2 = /* @__PURE__ */ new WeakMap();
44262
44610
  var NONE4 = 0;
44263
44611
  var ASSUMED2 = 1;
44264
44612
  var PROVEN2 = 2;
44265
- function isRecursive2(inst, stack2, resolve10) {
44613
+ function isRecursive2(inst, stack2, resolve13) {
44266
44614
  const cached4 = recursive2.get(inst);
44267
44615
  if (cached4 !== void 0)
44268
44616
  return cached4 ? PROVEN2 : NONE4;
@@ -44272,7 +44620,7 @@ function isRecursive2(inst, stack2, resolve10) {
44272
44620
  let result = NONE4;
44273
44621
  const check2 = (child) => {
44274
44622
  if (result !== PROVEN2 && child?._zod) {
44275
- const answer3 = isRecursive2(child, stack2, resolve10);
44623
+ const answer3 = isRecursive2(child, stack2, resolve13);
44276
44624
  if (answer3 > result)
44277
44625
  result = answer3;
44278
44626
  }
@@ -44283,7 +44631,7 @@ function isRecursive2(inst, stack2, resolve10) {
44283
44631
  const desc = Object.getOwnPropertyDescriptor(sh, key);
44284
44632
  if (spread && !desc.enumerable)
44285
44633
  continue;
44286
- const child = desc.get ? ASSUMED2 : desc.value?._zod ? isRecursive2(desc.value, stack2, resolve10) : NONE4;
44634
+ const child = desc.get ? ASSUMED2 : desc.value?._zod ? isRecursive2(desc.value, stack2, resolve13) : NONE4;
44287
44635
  if (child > answer3)
44288
44636
  answer3 = child;
44289
44637
  }
@@ -44347,7 +44695,7 @@ function isRecursive2(inst, stack2, resolve10) {
44347
44695
  break;
44348
44696
  // `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
44349
44697
  case "lazy": {
44350
- const inner = def._cachedInner ?? (resolve10 ? inst._zod.innerType : void 0);
44698
+ const inner = def._cachedInner ?? (resolve13 ? inst._zod.innerType : void 0);
44351
44699
  merge5(inner ? isRecursive2(inner, stack2, false) : ASSUMED2);
44352
44700
  break;
44353
44701
  }
@@ -46088,8 +46436,8 @@ var objectProcessor2 = (schema, ctx, _json, params) => {
46088
46436
  }
46089
46437
  const requiredKeys = [];
46090
46438
  for (const key of Object.keys(shape)) {
46091
- const field = def.shape[key];
46092
- if (ctx.io === "input" ? inputOptin2(field) === void 0 : field._zod.optout === void 0) {
46439
+ const field2 = def.shape[key];
46440
+ if (ctx.io === "input" ? inputOptin2(field2) === void 0 : field2._zod.optout === void 0) {
46093
46441
  requiredKeys.push(key);
46094
46442
  }
46095
46443
  }
@@ -50851,7 +51199,7 @@ var PROPERTY_KEYS_BY_TYPE = {
50851
51199
  array: shapeKeys([UntitledMultiSelectEnumSchemaSchema, TitledMultiSelectEnumSchemaSchema])
50852
51200
  };
50853
51201
  var SUPPORTED_STRING_FORMATS = new Set(StringSchemaSchema.shape.format.unwrap().options);
50854
- function walkProperty(node3, path8, vendor, unsupported) {
51202
+ function walkProperty(node3, path8, vendor, unsupported2) {
50855
51203
  if (!isJsonObject(node3)) return node3;
50856
51204
  const allowedKeys = typeof node3.type === "string" && Object.hasOwn(PROPERTY_KEYS_BY_TYPE, node3.type) ? PROPERTY_KEYS_BY_TYPE[node3.type] : void 0;
50857
51205
  if (allowedKeys === void 0) return node3;
@@ -50859,17 +51207,17 @@ function walkProperty(node3, path8, vendor, unsupported) {
50859
51207
  for (const [key, value] of Object.entries(node3)) if (allowedKeys.has(key) || isAnnotationOnlyJsonSchemaKeyword(key)) pruned[key] = value;
50860
51208
  else if (key === "pattern" && node3.type === "string" && typeof node3.format === "string") {
50861
51209
  if (!SUPPORTED_STRING_FORMATS.has(node3.format)) pruned[key] = value;
50862
- else if (typeof value !== "string" || !isLibraryFormatPattern(node3.format, value, vendor)) unsupported.push(`${path8}.${key}`);
50863
- } else unsupported.push(`${path8}.${key}`);
51210
+ else if (typeof value !== "string" || !isLibraryFormatPattern(node3.format, value, vendor)) unsupported2.push(`${path8}.${key}`);
51211
+ } else unsupported2.push(`${path8}.${key}`);
50864
51212
  return pruned;
50865
51213
  }
50866
51214
  function walkRequestedSchema(converted, vendor) {
50867
51215
  const pruned = {};
50868
- const unsupported = [];
50869
- for (const [key, value] of Object.entries(converted)) if (key === "properties" && isJsonObject(value)) pruned[key] = Object.fromEntries(Object.entries(value).map(([name, node3]) => [name, walkProperty(node3, `properties.${name}`, vendor, unsupported)]));
51216
+ const unsupported2 = [];
51217
+ for (const [key, value] of Object.entries(converted)) if (key === "properties" && isJsonObject(value)) pruned[key] = Object.fromEntries(Object.entries(value).map(([name, node3]) => [name, walkProperty(node3, `properties.${name}`, vendor, unsupported2)]));
50870
51218
  else if (ROOT_KEYS.has(key)) pruned[key] = value;
50871
- else if (!isAnnotationOnlyJsonSchemaKeyword(key)) unsupported.push(key);
50872
- if (unsupported.length > 0) throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${unsupported.join(", ")}`);
51219
+ else if (!isAnnotationOnlyJsonSchemaKeyword(key)) unsupported2.push(key);
51220
+ if (unsupported2.length > 0) throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${unsupported2.join(", ")}`);
50873
51221
  return pruned;
50874
51222
  }
50875
51223
  function describeUnsupportedProperties(pruned, fallback) {
@@ -50951,14 +51299,14 @@ function inputRequiredRoundsExceededMessage(method, maxRounds) {
50951
51299
  return `Multi-round-trip request '${method}' still required input after ${maxRounds} rounds (inputRequired.maxRounds)`;
50952
51300
  }
50953
51301
  function sleep(ms, signal) {
50954
- return new Promise((resolve10, reject) => {
51302
+ return new Promise((resolve13, reject) => {
50955
51303
  if (signal?.aborted) {
50956
51304
  reject(signal.reason instanceof SdkError ? signal.reason : new SdkError(SdkErrorCode.RequestTimeout, String(signal.reason)));
50957
51305
  return;
50958
51306
  }
50959
51307
  const timer = setTimeout(() => {
50960
51308
  signal?.removeEventListener("abort", onAbort);
50961
- resolve10();
51309
+ resolve13();
50962
51310
  }, ms);
50963
51311
  const onAbort = () => {
50964
51312
  clearTimeout(timer);
@@ -51757,7 +52105,7 @@ var Protocol = class {
51757
52105
  const flowStartedAt = Date.now();
51758
52106
  let onAbort;
51759
52107
  let cleanupMessageId;
51760
- return new Promise((resolve10, reject) => {
52108
+ return new Promise((resolve13, reject) => {
51761
52109
  const earlyReject = (error42) => {
51762
52110
  reject(error42);
51763
52111
  };
@@ -51826,7 +52174,7 @@ var Protocol = class {
51826
52174
  }
51827
52175
  if (decoded.kind === "invalid") return reject(decoded.error);
51828
52176
  if (decoded.kind === "input_required") {
51829
- if (options?.allowInputRequired === true) return resolve10(manualInputRequiredValue(decoded));
52177
+ if (options?.allowInputRequired === true) return resolve13(manualInputRequiredValue(decoded));
51830
52178
  const flow = {
51831
52179
  codec,
51832
52180
  request: request2,
@@ -51838,11 +52186,11 @@ var Protocol = class {
51838
52186
  params
51839
52187
  }, resultSchema, legOptions)
51840
52188
  };
51841
- return resolve10(this._resolveNonCompleteResult(decoded, flow));
52189
+ return resolve13(this._resolveNonCompleteResult(decoded, flow));
51842
52190
  }
51843
52191
  const result = decoded.result;
51844
52192
  validateStandardSchema(resultSchema, result).then((parseResult) => {
51845
- if (parseResult.success) resolve10(parseResult.data);
52193
+ if (parseResult.success) resolve13(parseResult.data);
51846
52194
  else reject(new SdkError(SdkErrorCode.InvalidResult, `Invalid result for ${request2.method}: ${parseResult.error}`));
51847
52195
  }, reject);
51848
52196
  });
@@ -54758,7 +55106,7 @@ var require_compile = /* @__PURE__ */ __commonJSMin((exports) => {
54758
55106
  ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, ref);
54759
55107
  const schOrFunc = root.refs[ref];
54760
55108
  if (schOrFunc) return schOrFunc;
54761
- let _sch = resolve10.call(this, root, ref);
55109
+ let _sch = resolve13.call(this, root, ref);
54762
55110
  if (_sch === void 0) {
54763
55111
  const schema = (_a5 = root.localRefs) === null || _a5 === void 0 ? void 0 : _a5[ref];
54764
55112
  const { schemaId } = this.opts;
@@ -54784,7 +55132,7 @@ var require_compile = /* @__PURE__ */ __commonJSMin((exports) => {
54784
55132
  function sameSchemaEnv(s1, s2) {
54785
55133
  return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
54786
55134
  }
54787
- function resolve10(root, ref) {
55135
+ function resolve13(root, ref) {
54788
55136
  let sch;
54789
55137
  while (typeof (sch = this.refs[ref]) == "string") ref = sch;
54790
55138
  return sch || this.schemas[ref] || resolveSchema.call(this, root, ref);
@@ -55234,7 +55582,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin((exports, module) => {
55234
55582
  else if (typeof uri === "object") uri = parse6(serialize(uri, options), options);
55235
55583
  return uri;
55236
55584
  }
55237
- function resolve10(baseURI, relativeURI, options) {
55585
+ function resolve13(baseURI, relativeURI, options) {
55238
55586
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
55239
55587
  const resolved = resolveComponent(parse6(baseURI, schemelessOptions), parse6(relativeURI, schemelessOptions), schemelessOptions, true);
55240
55588
  schemelessOptions.skipEscape = true;
@@ -55408,7 +55756,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin((exports, module) => {
55408
55756
  const fastUri = {
55409
55757
  SCHEMES,
55410
55758
  normalize: normalize2,
55411
- resolve: resolve10,
55759
+ resolve: resolve13,
55412
55760
  resolveComponent,
55413
55761
  equal,
55414
55762
  serialize,
@@ -60377,9 +60725,9 @@ var McpServer = class {
60377
60725
  if (!prompt) throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Prompt ${ref.name} not found`);
60378
60726
  if (!prompt.enabled) throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Prompt ${ref.name} disabled`);
60379
60727
  if (!prompt.argsSchema) return EMPTY_COMPLETION_RESULT;
60380
- const field = unwrapOptionalSchema(getSchemaShape(prompt.argsSchema)?.[request2.params.argument.name]);
60381
- if (!isCompletable(field)) return EMPTY_COMPLETION_RESULT;
60382
- const completer = getCompleter(field);
60728
+ const field2 = unwrapOptionalSchema(getSchemaShape(prompt.argsSchema)?.[request2.params.argument.name]);
60729
+ if (!isCompletable(field2)) return EMPTY_COMPLETION_RESULT;
60730
+ const completer = getCompleter(field2);
60383
60731
  if (!completer) return EMPTY_COMPLETION_RESULT;
60384
60732
  return createCompletionResult(await completer(request2.params.argument.value, request2.params.context));
60385
60733
  }
@@ -60596,8 +60944,8 @@ var McpServer = class {
60596
60944
  if (argsSchema) {
60597
60945
  const shape = getSchemaShape(argsSchema);
60598
60946
  if (shape) {
60599
- if (Object.values(shape).some((field) => {
60600
- return isCompletable(unwrapOptionalSchema(field));
60947
+ if (Object.values(shape).some((field2) => {
60948
+ return isCompletable(unwrapOptionalSchema(field2));
60601
60949
  })) this.setCompletionRequestHandler();
60602
60950
  }
60603
60951
  }
@@ -60873,7 +61221,7 @@ var StdioServerTransport = class {
60873
61221
  }
60874
61222
  send(message3) {
60875
61223
  if (this._closed) return Promise.reject(/* @__PURE__ */ new Error("StdioServerTransport is closed"));
60876
- return new Promise((resolve10, reject) => {
61224
+ return new Promise((resolve13, reject) => {
60877
61225
  const json2 = serializeMessage(message3);
60878
61226
  let settled = false;
60879
61227
  const onError = (error42) => {
@@ -60888,14 +61236,14 @@ var StdioServerTransport = class {
60888
61236
  settled = true;
60889
61237
  this._stdout.off("error", onError);
60890
61238
  this._stdout.off("drain", onDrain);
60891
- resolve10();
61239
+ resolve13();
60892
61240
  };
60893
61241
  this._stdout.once("error", onError);
60894
61242
  if (this._stdout.write(json2)) {
60895
61243
  if (settled) return;
60896
61244
  settled = true;
60897
61245
  this._stdout.off("error", onError);
60898
- resolve10();
61246
+ resolve13();
60899
61247
  } else if (!settled) this._stdout.once("drain", onDrain);
60900
61248
  });
60901
61249
  }
@@ -60949,14 +61297,14 @@ var StdioConnectionChannel = class {
60949
61297
  */
60950
61298
  async whenRequestsAnswered(timeoutMs) {
60951
61299
  if (this._closed || this._pendingRequests.size === 0) return true;
60952
- return await new Promise((resolve10) => {
61300
+ return await new Promise((resolve13) => {
60953
61301
  const waiter = () => {
60954
61302
  clearTimeout(timer);
60955
- resolve10(true);
61303
+ resolve13(true);
60956
61304
  };
60957
61305
  const timer = setTimeout(() => {
60958
61306
  this._drainWaiters = this._drainWaiters.filter((pending) => pending !== waiter);
60959
- resolve10(false);
61307
+ resolve13(false);
60960
61308
  }, timeoutMs);
60961
61309
  this._drainWaiters.push(waiter);
60962
61310
  });
@@ -61476,12 +61824,12 @@ function sessionIdOf(meta3, agent, env, serverId) {
61476
61824
  return RUN_SESSION_PREFIX + serverId;
61477
61825
  }
61478
61826
  var CODEX_SANDBOX_STATE_META = "codex/sandbox-state-meta";
61479
- var FILE_URL_PREFIX = "file:";
61827
+ var FILE_URL_PREFIX2 = "file:";
61480
61828
  function workspaceFromMeta(meta3) {
61481
61829
  const state = meta3?.[CODEX_SANDBOX_STATE_META];
61482
61830
  const cwd = typeof state === "object" && state !== null ? state.sandboxCwd : void 0;
61483
61831
  if (typeof cwd !== "string" || cwd === "") return void 0;
61484
- if (!cwd.startsWith(FILE_URL_PREFIX)) return cwd;
61832
+ if (!cwd.startsWith(FILE_URL_PREFIX2)) return cwd;
61485
61833
  try {
61486
61834
  return fileURLToPath3(cwd);
61487
61835
  } catch {
@@ -61505,7 +61853,7 @@ async function workspaceFromRoots(server) {
61505
61853
  try {
61506
61854
  const { roots } = await server.server.listRoots(void 0, { timeout: ROOTS_TIMEOUT_MS });
61507
61855
  for (const root of roots) {
61508
- if (root.uri.startsWith(FILE_URL_PREFIX)) return fileURLToPath3(root.uri);
61856
+ if (root.uri.startsWith(FILE_URL_PREFIX2)) return fileURLToPath3(root.uri);
61509
61857
  }
61510
61858
  } catch (err) {
61511
61859
  console.error("context-mode: roots/list: " + (err instanceof Error ? err.message : String(err)));
@@ -61516,7 +61864,7 @@ function workspaceCwdOf(meta3, spawnCwd, script) {
61516
61864
  const fromHost = workspaceFromMeta(meta3);
61517
61865
  if (fromHost !== void 0) return fromHost;
61518
61866
  if (script === void 0 || script === "") return spawnCwd;
61519
- return realOrSame(spawnCwd) === realOrSame(dirname13(script)) ? "" : spawnCwd;
61867
+ return realOrSame(spawnCwd) === realOrSame(dirname14(script)) ? "" : spawnCwd;
61520
61868
  }
61521
61869
  function errorReply(err) {
61522
61870
  if (err instanceof CtxError) return { text: err.toLine(), isError: true, sandboxBytes: 0 };
@@ -61672,7 +62020,7 @@ async function startServer(argv, env) {
61672
62020
  }
61673
62021
  installExitGuard({ onShutdown: shutdown, isTTY: process.stdin.isTTY === true });
61674
62022
  handle = serveStdio(createServer);
61675
- await new Promise((resolve10) => process.once("exit", () => resolve10()));
62023
+ await new Promise((resolve13) => process.once("exit", () => resolve13()));
61676
62024
  }
61677
62025
  if (isEntry(import.meta.main, process.argv[1], fileURLToPath3(import.meta.url))) {
61678
62026
  const [, , ...cliArgs] = process.argv;
@@ -61688,6 +62036,19 @@ function textOf2(content) {
61688
62036
  if (!Array.isArray(content)) return "";
61689
62037
  return content.map((part) => part.type === "text" ? str3(part.text) : "").join("");
61690
62038
  }
62039
+ function field(v, key) {
62040
+ return typeof v === "object" && v !== null && !Array.isArray(v) ? v[key] : void 0;
62041
+ }
62042
+ function excludedTools(pi) {
62043
+ let settings;
62044
+ try {
62045
+ settings = pi.getSettings?.();
62046
+ } catch {
62047
+ return [];
62048
+ }
62049
+ const list4 = field(field(settings, "contextMode"), "excludeTools");
62050
+ return Array.isArray(list4) ? list4.filter((n) => typeof n === "string") : [];
62051
+ }
61691
62052
  function errorReply2(err) {
61692
62053
  return { text: err instanceof CtxError ? err.toLine() : INTERNAL_ERROR_LINE, isError: true, sandboxBytes: 0 };
61693
62054
  }
@@ -61796,10 +62157,13 @@ function piExtension(pi) {
61796
62157
  toolCallId: event.toolCallId,
61797
62158
  input: event.input,
61798
62159
  content: textOf2(event.content),
61799
- isError: event.isError === true
62160
+ isError: event.isError === true,
62161
+ keep: excludedTools(pi).includes(str3(event.toolName))
61800
62162
  }, turn);
61801
62163
  if (out.stdout === "") return void 0;
61802
- return { content: [{ type: "text", text: out.stdout }], details: { text: out.stdout } };
62164
+ const patch = { content: [{ type: "text", text: out.stdout }] };
62165
+ if (event.structuredContent !== void 0) patch.structuredContent = event.structuredContent;
62166
+ return patch;
61803
62167
  });
61804
62168
  pi.on("session_compact", () => {
61805
62169
  compactPending = true;