viewable-one 0.12.7 → 0.12.9

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/lib/agents.mjs CHANGED
@@ -78,7 +78,8 @@
78
78
  // `acpServersFor` below is where the server is described.
79
79
 
80
80
  import { adapterEntry } from "./acp.mjs";
81
- import { computerAppsOffRule, conversationRules } from "./conversationRules.mjs";
81
+ import { computerAppsOffRule, conversationRules, drawnCardRule, otherAppsRule, refusalRule } from "./conversationRules.mjs";
82
+ import { CLAUDE_OTHER_LOGIN_TOOLS, OPENCODE_OTHER_LOGIN_RULES } from "./otherLogins.mjs";
82
83
  import { runEngineFor } from "./run-engine.mjs";
83
84
  // ONE LIST, not two: spawn.mjs's checkRequest is the validator a request
84
85
  // meets first, and this file's draft branch is what actually builds the
@@ -94,6 +95,11 @@ import { PLAN_MODE_AGENTS } from "./spawn.mjs";
94
95
  // SERVER_KEY, so this imports that one spelling rather than adding a fourth
95
96
  // copy of the literal.
96
97
  import { SERVER_KEY } from "./init-connect.mjs";
98
+ import { isBoardServer } from "./mcpjson.mjs";
99
+ import { readFile } from "node:fs/promises";
100
+ import { homedir } from "node:os";
101
+ import { dirname, join, resolve } from "node:path";
102
+ import { parse as parseJsonc } from "jsonc-parser";
97
103
  import { randomBytes } from "node:crypto";
98
104
 
99
105
  /** What a spawned session may do under Claude Code.
@@ -197,6 +203,9 @@ export const CLAUDE_CLICK_AND_SCREEN_TOOLS = [
197
203
  export const CLAUDE_DISALLOWED_TOOLS = [
198
204
  "EnterPlanMode", "AskUserQuestion",
199
205
  ...CLAUDE_CLICK_AND_SCREEN_TOOLS,
206
+ // Another login, token or saved key (#6995): `Bash(npx:*)` would run
207
+ // `npx supabase` without a question, and a deny rule is checked first.
208
+ ...CLAUDE_OTHER_LOGIN_TOOLS,
200
209
  ];
201
210
 
202
211
  /** The two tools that reach the web. Allowed up front only when the person
@@ -205,16 +214,28 @@ export const CLAUDE_DISALLOWED_TOOLS = [
205
214
  * one is a question in the idea ("Can I search the web?"). */
206
215
  export const CLAUDE_WEB_TOOLS = ["WebSearch", "WebFetch"];
207
216
 
217
+ /** THE READ-ONLY TOOL SET (#8261, Plan round 2 point 3 on #8251): an ask
218
+ * whose plan only reads apps gets the draft's read tools and the plan tools,
219
+ * with no Write, no Edit, no Bash and no web tools, so it can run in the
220
+ * linked folder with no copy and cannot send what it read anywhere but the
221
+ * board. `--tools` takes the rest away outright; the board server stays,
222
+ * because `--tools` names built-in tools only (Claude Code 2.1.332 help). */
223
+ export const CLAUDE_READ_ONLY_TOOLS = ["Read", "Glob", "Grep", "TaskCreate", "TaskUpdate", "TaskList", "TaskGet"];
224
+
208
225
  /** The allowlist for one run: the standing list, plus the web tools when the
209
- * request switched web search on. A plain function of the request, so the
210
- * one-shot and streaming command lines cannot disagree. */
226
+ * request switched web search on, or the read-only set with the board when
227
+ * the request only reads (`readOnly`). A plain function of the request, so
228
+ * the one-shot and streaming command lines cannot disagree. */
211
229
  export const claudeToolsFor = (wants = {}) => {
212
- const tools = wants.boardServerKey
213
- ? CLAUDE_TOOLS.map(tool => tool === `mcp__${SERVER_KEY}` ? `mcp__${wants.boardServerKey}` : tool)
214
- : CLAUDE_TOOLS;
230
+ const board = `mcp__${wants.boardServerKey || SERVER_KEY}`;
231
+ if (wants.readOnly === true) return [...CLAUDE_READ_ONLY_TOOLS, board];
232
+ const tools = CLAUDE_TOOLS.map(tool => tool === `mcp__${SERVER_KEY}` ? board : tool);
215
233
  return wants.webSearch === true ? [...tools, ...CLAUDE_WEB_TOOLS] : tools;
216
234
  };
217
235
 
236
+ /** `--tools` for a read-only run: the built-in tools it may have at all. */
237
+ const readOnlyToolsArgs = (wants) => (wants.readOnly === true ? ["--tools", CLAUDE_READ_ONLY_TOOLS.join(",")] : []);
238
+
218
239
  export const AGENTS = {
219
240
  codex: {
220
241
  label: "Codex", bin: "codex", binEnv: "PM_CODEX_BIN", argsEnv: "PM_CODEX_ARGS",
@@ -272,6 +293,7 @@ export const AGENTS = {
272
293
  "--verbose",
273
294
  "--permission-mode",
274
295
  "acceptEdits",
296
+ ...readOnlyToolsArgs(wants),
275
297
  "--allowedTools",
276
298
  claudeToolsFor(wants).join(" "),
277
299
  // Variadic like --allowedTools, and for the same reason it sits after
@@ -305,6 +327,7 @@ export const AGENTS = {
305
327
  "--replay-user-messages",
306
328
  "--permission-mode", "acceptEdits",
307
329
  ...(wants.askPermissions === true ? ["--permission-prompt-tool", "stdio"] : []),
330
+ ...readOnlyToolsArgs(wants),
308
331
  "--allowedTools", claudeToolsFor(wants).join(" "),
309
332
  // The streaming path is the one long sessions take, and it is exactly
310
333
  // where spawn-mtf3xbm7 parked - so the same tools are barred here.
@@ -648,8 +671,11 @@ export function commandFor(agent, env = process.env, wants = {}) {
648
671
  // character, and a longer name would push the computer-apps --settings
649
672
  // past Windows' command-line limit. src/components/run/runWords.ts
650
673
  // matches this `v` + five hex shape to read the calls as board work.
674
+ // The caller may make the key first, so the prompt can name the run's own
675
+ // board tools by it (#7550, runnerExecute.mjs).
651
676
  const asked = { ...wants, env, ...(agentFor(agent) === "claude"
652
- ? { boardServerKey: boardRunKey() } : {}) };
677
+ ? { boardServerKey: typeof wants.boardServerKey === "string" && /^v[0-9a-f]{5}$/.test(wants.boardServerKey) ? wants.boardServerKey : boardRunKey() } : {}) };
678
+ let mcpConfigFile = null;
653
679
  let args = asked.streaming && spec.streamingArgs ? spec.streamingArgs(asked) : spec.args(asked);
654
680
  let overridden = false;
655
681
  if (typeof raw === "string" && raw.trim() !== "") {
@@ -749,17 +775,39 @@ export function commandFor(agent, env = process.env, wants = {}) {
749
775
  },
750
776
  }
751
777
  : {};
752
- // USE MY COMPUTER'S APPS (#481). Off, the default: strict, glytch
753
- // only, as above. On, for this one agent and this one person: the
754
- // strict flag goes, so the person's own Claude Code MCP servers load
755
- // beside glytch. Their tools are NOT added to --allowedTools, and an
756
- // ask rule covers every one of them, so a tool the person allowed in
757
- // their own settings before still asks each time; in -p mode that
758
- // ask is refused until the permission ask (#478) reaches the person.
759
- const apps = wants.computerApps === true
760
- ? ["--settings", JSON.stringify({ permissions: { ask: appAskRules(`mcp__${asked.boardServerKey}__`) } })]
761
- : ["--strict-mcp-config"];
762
- args = [...args, ...apps, "--mcp-config", JSON.stringify({ mcpServers })];
778
+ // USE MY COMPUTER'S APPS (#481). Off, the default: strict, the run's
779
+ // board only, as above. On, for this one agent and this one person:
780
+ // still strict (#7550), and the person's own Claude Code servers that
781
+ // the runner read (`appServers`, computerApps.mjs claudeAppServers)
782
+ // load beside the board. Dropping strict loaded every server Claude
783
+ // knows, a second Viewable board server among them, signed in to
784
+ // another account, whose same-named tools the model picked. Another
785
+ // board server is never passed, whoever handed it in; plugins and
786
+ // claude.ai connectors stay off (strict hides both, Claude Code
787
+ // 2.1.328; ENABLE_CLAUDEAI_MCP_SERVERS below says so again for
788
+ // connectors, without growing this command line).
789
+ //
790
+ // The app tools are NOT added to --allowedTools, and an ask rule
791
+ // covers every one of them, so a tool the person allowed in their own
792
+ // settings before still asks each time; in -p mode that ask is refused
793
+ // until the permission ask (#478) reaches the person.
794
+ //
795
+ // The servers' headers and env can hold the person's secrets, so with
796
+ // `mcpConfigPath` they go in a file the caller writes (0600) instead
797
+ // of the command line, where `ps` shows them and Windows caps the length.
798
+ // A run that only reads (#8261) never loads them: their tools could
799
+ // send what it read elsewhere. The board server alone.
800
+ if (wants.computerApps === true && wants.readOnly !== true) {
801
+ const apps = Object.fromEntries(Object.entries(wants.appServers && typeof wants.appServers === "object" ? wants.appServers : {})
802
+ .filter(([name, entry]) => name !== asked.boardServerKey && !isBoardServer(name, entry, { env })));
803
+ const config = JSON.stringify({ mcpServers: { ...mcpServers, ...apps } });
804
+ const settings = JSON.stringify({ permissions: { ask: appAskRules(`mcp__${asked.boardServerKey}__`) } });
805
+ const path = typeof wants.mcpConfigPath === "string" && wants.mcpConfigPath ? wants.mcpConfigPath : "";
806
+ if (path) mcpConfigFile = { path, text: config };
807
+ args = [...args, "--settings", settings, "--strict-mcp-config", "--mcp-config", path || config];
808
+ } else {
809
+ args = [...args, "--strict-mcp-config", "--mcp-config", JSON.stringify({ mcpServers })];
810
+ }
763
811
  }
764
812
  }
765
813
  // WHAT AN ACP ENGINE NEEDS THAT AN ARGUMENT LIST CANNOT CARRY. Model,
@@ -779,6 +827,9 @@ export function commandFor(agent, env = process.env, wants = {}) {
779
827
  label: spec.label,
780
828
  adapter: spec.adapter,
781
829
  allowTools: CLAUDE_TOOLS,
830
+ // The same Claude Code, so the same bar on other logins (#6995);
831
+ // the adapter adds its own AskUserQuestion rule beside it.
832
+ disallowTools: CLAUDE_OTHER_LOGIN_TOOLS,
782
833
  mode: "acceptEdits",
783
834
  model: typeof wants.model === "string" ? wants.model.trim() : "",
784
835
  mcpServers: acpServersFor(agent, {
@@ -801,11 +852,21 @@ export function commandFor(agent, env = process.env, wants = {}) {
801
852
  // refused. Only when the runner can actually ask (it passes
802
853
  // `askPermissions` only with a board to ask on).
803
854
  askPermissions: wants.askPermissions === true,
804
- // The person turned web search on for this run.
805
- webSearch: wants.webSearch === true,
806
- computerApps: wants.computerApps === true,
855
+ // The person turned web search on for this run; never on a run that only reads (#8261).
856
+ webSearch: wants.webSearch === true && wants.readOnly !== true,
857
+ computerApps: wants.computerApps === true && wants.readOnly !== true,
858
+ // An ask that only reads apps (#8261): the read-only sandbox, with the
859
+ // board server kept, since codex answers MCP calls in its own process.
860
+ readOnly: wants.readOnly === true,
807
861
  } : null;
808
- return { bin, args, spec, ignored, acp, codex };
862
+ // Claude: the run's own board server key, which child.mjs's permission step
863
+ // exempts from the other-board refusal (#7550); the MCP config file the
864
+ // caller writes before the spawn; and claude.ai connectors off in every run
865
+ // (Claude Code reads this variable, checked on 2.1.328).
866
+ const claudeExtras = agentFor(agent) === "claude"
867
+ ? { boardServerKey: asked.boardServerKey, mcpConfigFile, env: { ENABLE_CLAUDEAI_MCP_SERVERS: "false" } }
868
+ : {};
869
+ return { bin, args, spec, ignored, acp, codex, ...claudeExtras };
809
870
  }
810
871
 
811
872
  /** Give an engine what it needs to reach the board, in the tree it will run in.
@@ -840,14 +901,32 @@ export function commandFor(agent, env = process.env, wants = {}) {
840
901
  * (SERVER_KEY), not `board` - the verification above predates the rename
841
902
  * and is kept dated rather than rerun, since it was checking the shape
842
903
  * `opencode mcp add` produces, not the key name. */
843
- export async function prepareWorkspace(agent, { mcpUrl, token, sessionKey, boardId }) {
904
+ export async function prepareWorkspace(agent, { mcpUrl, token, sessionKey, boardId, cwd, env = process.env, home, read }) {
844
905
  const spec = AGENTS[agentFor(agent)];
845
906
  if (!spec.needsBoardSetup) return { wrote: null };
846
- if (!mcpUrl || !token) return { wrote: null };
907
+ // ANOTHER BOARD SERVER, SWITCHED OFF (#7550). opencode merges its global
908
+ // config, every opencode.json from the folder up and this content, a later
909
+ // `{"enabled": false}` winning (checked on opencode 1.18.23 with a scratch
910
+ // HOME: a folder `viewable` entry and a global one at app.viewable.one both
911
+ // read "disabled"). It runs --auto, so a second board server's calls would
912
+ // need no Allow at all. Every board entry but the run's own is switched off,
913
+ // with the apps switch on or off (it does not reach opencode), and a config
914
+ // that cannot be read stops the run: refused, never guessed.
915
+ const others = cwd ? await opencodeBoardEntries({ cwd, env, home, read }) : [];
916
+ const off = Object.fromEntries(others.filter((name) => name !== SERVER_KEY).map((name) => [name, { enabled: false }]));
917
+ if (!mcpUrl || !token) {
918
+ return Object.keys(off).length
919
+ ? { wrote: null, env: { OPENCODE_CONFIG_CONTENT: JSON.stringify({ $schema: "https://opencode.ai/config.json", permission: { bash: OPENCODE_OTHER_LOGIN_RULES }, mcp: off }) } }
920
+ : { wrote: null };
921
+ }
847
922
 
848
923
  const config = {
849
924
  $schema: "https://opencode.ai/config.json",
925
+ // --auto approves every command it does not deny, so another login is
926
+ // denied here by pattern (#6995, otherLogins.mjs).
927
+ permission: { bash: OPENCODE_OTHER_LOGIN_RULES },
850
928
  mcp: {
929
+ ...off,
851
930
  [SERVER_KEY]: {
852
931
  type: "remote",
853
932
  url: mcpUrl,
@@ -865,6 +944,45 @@ export async function prepareWorkspace(agent, { mcpUrl, token, sessionKey, board
865
944
  return { wrote: null, env: { OPENCODE_CONFIG_CONTENT: JSON.stringify(config) } };
866
945
  }
867
946
 
947
+ /** The names of the Viewable board servers in the opencode configs this run
948
+ * merges (#7550): the global folder, OPENCODE_CONFIG and OPENCODE_CONFIG_DIR,
949
+ * and an opencode.json(c) or .opencode/opencode.json(c) in the run's folder
950
+ * or any folder above it. Throws `{ refused: true }`, naming the file, when
951
+ * one is there and cannot be read. */
952
+ export async function opencodeBoardEntries({ cwd, env = process.env, home = env.HOME?.trim() || homedir(), read = readFile }) {
953
+ const global = env.XDG_CONFIG_HOME?.trim() ? join(env.XDG_CONFIG_HOME.trim(), "opencode") : join(home, ".config", "opencode");
954
+ const paths = [
955
+ ...["config.json", "opencode.json", "opencode.jsonc"].map((file) => join(global, file)),
956
+ ...(env.OPENCODE_CONFIG?.trim() ? [env.OPENCODE_CONFIG.trim()] : []),
957
+ ...(env.OPENCODE_CONFIG_DIR?.trim() ? ["opencode.json", "opencode.jsonc"].map((file) => join(env.OPENCODE_CONFIG_DIR.trim(), file)) : []),
958
+ ];
959
+ for (let dir = resolve(cwd), depth = 0; depth < 64; depth += 1) {
960
+ for (const file of ["opencode.json", "opencode.jsonc", join(".opencode", "opencode.json"), join(".opencode", "opencode.jsonc")]) paths.push(join(dir, file));
961
+ const up = dirname(dir);
962
+ if (up === dir) break;
963
+ dir = up;
964
+ }
965
+ const names = new Set();
966
+ for (const path of new Set(paths)) {
967
+ let raw;
968
+ try { raw = await read(path, "utf8"); } catch (error) {
969
+ if (error?.code === "ENOENT" || error?.code === "ENOTDIR" || error?.code === "EISDIR") continue;
970
+ throw opencodeRefusal(path);
971
+ }
972
+ const errors = [];
973
+ const data = parseJsonc(raw, errors, { allowTrailingComma: true });
974
+ const mcp = data?.mcp;
975
+ if (errors.length || data === null || typeof data !== "object" || Array.isArray(data) ||
976
+ (mcp !== undefined && (mcp === null || typeof mcp !== "object" || Array.isArray(mcp)))) throw opencodeRefusal(path);
977
+ for (const [name, entry] of Object.entries(mcp ?? {})) if (isBoardServer(name, entry, { env })) names.add(name);
978
+ }
979
+ return [...names];
980
+ }
981
+
982
+ const opencodeRefusal = (path) => Object.assign(new Error(
983
+ `Couldn't read ${path} to check it for another Viewable board, so this run did not start. Fix that file, or use Claude Code or Codex for this folder.`,
984
+ ), { refused: true });
985
+
868
986
  /** What every brief is prefixed with, in the tool names THAT engine uses.
869
987
  *
870
988
  * It was one fixed string naming `ask_user` and `report`. Claude Code answers
@@ -875,13 +993,17 @@ export async function prepareWorkspace(agent, { mcpUrl, token, sessionKey, board
875
993
  *
876
994
  * A session cannot be MADE to ask or report. It can only be told, accurately,
877
995
  * in the one place it always reads. */
878
- export function preambleFor(agent, { workplace, computerApps } = {}) {
879
- const spec = AGENTS[agentFor(agent)];
996
+ export function preambleFor(agent, { workplace, computerApps, boardServerKey, readApps, readOnly } = {}) {
997
+ const spec = specNamingBoard(agent, boardServerKey);
880
998
  const ask = spec.boardTool("ask_user");
881
999
  const report = spec.boardTool("report");
1000
+ // THE APPS THIS ASK'S PLAN READS THROUGH VIEWABLE (#8261, part 3 of #8251).
1001
+ // Only Claude Code and Codex, with the same words (#7581).
1002
+ const apps = ["claude", "codex"].includes(agentFor(agent)) ? plannedReadApps(readApps) : [];
1003
+ const appRead = spec.boardTool("app_read");
882
1004
  return (
883
1005
  "You were spawned from a canvas by a person who is not watching a terminal. " +
884
- (workplace ?? "You are in your own git worktree: commit your work on this branch, never " +
1006
+ (readOnly === true ? READ_ONLY_WORKPLACE : workplace ?? "You are in your own git worktree: commit your work on this branch, never " +
885
1007
  "merge to main, and never touch the checkout above you.\n\n") +
886
1008
  `If a permission or anything else blocks you, ask on the board with ${ask} ` +
887
1009
  `rather than stopping quietly - it lands as a question on your idea that the person answers ` +
@@ -893,11 +1015,20 @@ export function preambleFor(agent, { workplace, computerApps } = {}) {
893
1015
  // reads it - so the sentence named a surface the person cannot see any
894
1016
  // more. What has not changed is the consequence, which is the reason the
895
1017
  // sentence exists at all: silence looks exactly like success.
896
- `call ${report} before you finish, including when you did nothing: the ` +
897
- "card on the person's idea just reads finished, and they cannot " +
898
- "tell that apart from success.\n\n" +
1018
+ // #8013/#8014: the closing message is the answer on the card; `report` for the answer made a
1019
+ // second copy in a group. `report` stays for forks and evidence.
1020
+ `end with your closing message: it is your answer on the person's card, so say what you ` +
1021
+ "did there, including when you did nothing, or the card just reads finished and they " +
1022
+ "cannot tell that apart from success. Never repeat it in a report.\n\n" +
1023
+ `Call ${report} only for a fork only the person can rule on (decide) or for evidence from ` +
1024
+ "the code about one of their circles (flags), never for what you did.\n\n" +
1025
+ // A refusal stops the run and asks; it never sends it to another login (#6995).
1026
+ refusalRule(ask) +
1027
+ // A table ask lands as a drawn card, never as words saying it was made (#8102).
1028
+ (apps.length > 0 ? appReadRule(appRead, spec.boardTool("set_live_card"), apps) : "") +
1029
+ drawnCardRule(spec.boardTool("propose")) +
899
1030
  `Your board tools are named ${spec.boardTool("get_board")}, ` +
900
- `${spec.boardTool("get_node")}, ${spec.boardTool("propose")}, ${ask} and ${report}.\n\n` +
1031
+ `${spec.boardTool("get_node")}, ${spec.boardTool("propose")}, ${ask}${apps.length > 0 ? `, ${appRead}` : ""} and ${report}.\n\n` +
901
1032
  // brief 23 ruling 4a (2026-09-07): the app derives the run's structure
902
1033
  // - its steps, decisions and waiting state - from this session's own
903
1034
  // log, and this preamble is the one place every session reads. So the
@@ -928,6 +1059,62 @@ export function preambleFor(agent, { workplace, computerApps } = {}) {
928
1059
  );
929
1060
  }
930
1061
 
1062
+ /** Where a run that only reads works (#8261): the folder itself, with no copy. */
1063
+ export const READ_ONLY_WORKPLACE =
1064
+ "You are in the person's linked folder with tools that only read: you can read its files and the " +
1065
+ "board, and you cannot change a file or run a command here. Nothing in this ask needs you to.\n\n";
1066
+
1067
+ /** The request's `readApps`: app ids, once each (board-mcp's plannedApps reads the same field). */
1068
+ function plannedReadApps(readApps) {
1069
+ return Array.isArray(readApps) ? [...new Set(readApps.filter((app) => typeof app === "string" && app.trim() !== "").map((app) => app.trim()))] : [];
1070
+ }
1071
+
1072
+ /** HOW A COMPUTER SESSION READS A CONNECTED APP (#8261; Plan round 2 on
1073
+ * #8251). The app's plan step named the apps (`readApps`); board-mcp's
1074
+ * `app_read` reads only those, for this running ask (#8254). The session is
1075
+ * told to use it instead of a command line (the walk on #7791 read with `gh`),
1076
+ * to land a table or chart from the read it holds (`set_live_card` with
1077
+ * `{ shape, read_ref, columns }`, #8259), and to stop and say so when the read
1078
+ * is refused, never to read the app another way. Generic: nothing here names
1079
+ * an app (#4419); the ids are the request's own. */
1080
+ function appReadRule(appRead, setLiveCard, apps) {
1081
+ return (
1082
+ `This ask's plan reads these apps the person connected in Viewable: ${apps.join(", ")}. ` +
1083
+ `Read them only with ${appRead} { provider, tool, args }, provider being one of those ids: never with a ` +
1084
+ "command-line tool, a script, a web request or a login on this computer (no gh, no curl, no app's own CLI), " +
1085
+ "and the rule about the person's own apps on this computer does not apply to these. " +
1086
+ "Each read answers the app's rows and a read_ref that names the read for ten minutes. " +
1087
+ `To put a table or chart of what you read on the board, land it with ${setLiveCard} ` +
1088
+ "{ shape: \"table\" or \"chart\", read_ref, columns }, columns being the fields to show, in order: the board " +
1089
+ "builds the card from that read, so never type the rows in yourself; if the board refuses that, draw it as below. " +
1090
+ `If ${appRead} is refused (the run was stopped or ran out of time, the app is not in the plan, the account is ` +
1091
+ "not on Pro), stop that part and say so in your answer, in the refusal's own words. Never read the app another way.\n\n"
1092
+ );
1093
+ }
1094
+
1095
+ /** What a chat turn is told ahead of the app's own words (runnerExecute.mjs).
1096
+ * A chat turn gets no idea preamble, so the rules that hold for every run
1097
+ * travel here: a refusal stops and asks, for every engine (#6995), and, for
1098
+ * Claude Code and Codex, the other-apps rule and the apps-off rule that the
1099
+ * reply's Manage agent offer reads (#4204, #481). */
1100
+ export function chatRulesFor(agent, { computerApps, boardServerKey } = {}) {
1101
+ const engine = agentFor(agent);
1102
+ const local = ["claude", "codex"].includes(engine)
1103
+ ? `${otherAppsRule()}${computerApps === true ? "" : computerAppsOffRule()}`
1104
+ : "";
1105
+ return `${local}${refusalRule(specNamingBoard(engine, boardServerKey).boardTool("ask_user"))}`;
1106
+ }
1107
+
1108
+ /** The engine's spec, with Claude's board tools named by the run's own server
1109
+ * key when the caller made one (#7550): `mcp__v1a2b3__ask_user`, not a bare
1110
+ * `ask_user` that a second board server would also answer to. */
1111
+ function specNamingBoard(agent, boardServerKey) {
1112
+ const spec = AGENTS[agentFor(agent)];
1113
+ return agentFor(agent) === "claude" && typeof boardServerKey === "string" && /^v[0-9a-f]{5}$/.test(boardServerKey)
1114
+ ? { ...spec, boardTool: (name) => `mcp__${boardServerKey}__${name}` }
1115
+ : spec;
1116
+ }
1117
+
931
1118
  /** The plan-tool sentence of preambleFor, split out because `todoTool` now
932
1119
  * comes in two shapes: a plain tool name (codex's `update_plan`, opencode's
933
1120
  * `todowrite`) or, since 2026-09-21, `{write, update, fallback}` for the