@zerowall/dsh-claude-coderun 0.1.0-preview.3 → 0.1.0-preview.5

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/index.js CHANGED
@@ -17,7 +17,7 @@ var __runInitializers = (array, flags, self, value) => {
17
17
  return value;
18
18
  };
19
19
  var __decorateElement = (array, flags, name2, decorators, target, extra) => {
20
- var fn, it, done, ctx, access2, k = flags & 7, s = !!(flags & 8), p = !!(flags & 16);
20
+ var fn, it, done, ctx, access, k = flags & 7, s = !!(flags & 8), p = !!(flags & 16);
21
21
  var j = k > 3 ? array.length + 1 : k ? s ? 1 : 2 : 0, key = __decoratorStrings[k + 5];
22
22
  var initializers = k > 3 && (array[j - 1] = []), extraInitializers = array[j] || (array[j] = []);
23
23
  var desc = k && (!p && !s && (target = target.prototype), k < 5 && (k > 3 || !p) && __getOwnPropDesc(k < 4 ? target : { get [name2]() {
@@ -29,9 +29,9 @@ var __decorateElement = (array, flags, name2, decorators, target, extra) => {
29
29
  for (var i = decorators.length - 1; i >= 0; i--) {
30
30
  ctx = __decoratorContext(k, name2, done = {}, array[3], extraInitializers);
31
31
  if (k) {
32
- ctx.static = s, ctx.private = p, access2 = ctx.access = { has: p ? (x) => __privateIn(target, x) : (x) => name2 in x };
33
- if (k ^ 3) access2.get = p ? (x) => (k ^ 1 ? __privateGet : __privateMethod)(x, target, k ^ 4 ? extra : desc.get) : (x) => x[name2];
34
- if (k > 2) access2.set = p ? (x, y) => __privateSet(x, target, y, k ^ 4 ? extra : desc.set) : (x, y) => x[name2] = y;
32
+ ctx.static = s, ctx.private = p, access = ctx.access = { has: p ? (x) => __privateIn(target, x) : (x) => name2 in x };
33
+ if (k ^ 3) access.get = p ? (x) => (k ^ 1 ? __privateGet : __privateMethod)(x, target, k ^ 4 ? extra : desc.get) : (x) => x[name2];
34
+ if (k > 2) access.set = p ? (x, y) => __privateSet(x, target, y, k ^ 4 ? extra : desc.set) : (x, y) => x[name2] = y;
35
35
  }
36
36
  it = (0, decorators[i])(k ? k < 4 ? p ? extra : desc[key] : k > 4 ? void 0 : { get: desc.get, set: desc.set } : target, ctx), done._ = 1;
37
37
  if (k ^ 4 || it === void 0) __expectFn(it) && (k > 4 ? initializers.unshift(it) : k ? p ? extra = it : desc[key] = it : target = it);
@@ -87,9 +87,9 @@ import { createToolResultMessage as createToolResultMessage3, isAgentLoopRequest
87
87
  import { NO_START_CAPABILITIES, assertUsableCwd, settleRunResult, subprocessRunHandle } from "@deepseek-ai/dsh-subagent";
88
88
  import { credentialRef } from "@deepseek-ai/dsh-credentials";
89
89
  import { Remote, TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
90
- import { createHash as createHash4, randomUUID as randomUUID4 } from "node:crypto";
91
- import { chmod, lstat as lstat2, mkdir as mkdir3, readdir as readdir2, readFile as readFile2, rename as rename2, rm as rm2, writeFile as writeFile3 } from "node:fs/promises";
92
- import { isAbsolute as isAbsolute4, join as join5, resolve as resolve3 } from "node:path";
90
+ import { createHash as createHash2, randomUUID as randomUUID4 } from "node:crypto";
91
+ import { chmod, lstat as lstat2, mkdir as mkdir3, readdir as readdir3, readFile as readFile2, rename as rename2, rm as rm3, writeFile as writeFile3 } from "node:fs/promises";
92
+ import { isAbsolute as isAbsolute2, join as join5, resolve as resolve2 } from "node:path";
93
93
  import { stripVTControlCharacters } from "node:util";
94
94
  import { SecretBrokerClient } from "@zerowall/dsh-plugin-ai-cloud/secrets";
95
95
 
@@ -97,7 +97,7 @@ import { SecretBrokerClient } from "@zerowall/dsh-plugin-ai-cloud/secrets";
97
97
  import { randomUUID } from "node:crypto";
98
98
  import { existsSync as nodeExistsSync } from "node:fs";
99
99
  import * as nodeFs from "node:fs/promises";
100
- import { isAbsolute, join, relative, resolve, sep } from "node:path";
100
+ import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
101
101
  var CLAUDE_CODE_PACKAGE = "@anthropic-ai/claude-code";
102
102
  var CLAUDE_CODE_VERSION = "2.1.309";
103
103
  var CLAUDE_CODE_REGISTRY = "https://registry.npmmirror.com";
@@ -309,6 +309,7 @@ var ClaudeRuntimeManager = class {
309
309
  "--expose-internals",
310
310
  this.#pnpm.pnpmPath,
311
311
  "install",
312
+ "--node-linker=hoisted",
312
313
  `--registry=${this.#registry}`,
313
314
  `--store-dir=${this.storeDir}`
314
315
  ], {
@@ -520,7 +521,9 @@ var ClaudeRuntimeManager = class {
520
521
  return env;
521
522
  }
522
523
  #buildInstallEnvironment(userConfigFile) {
523
- return this.#buildEnvironment({ npm_config_userconfig: userConfigFile });
524
+ const env = this.#buildEnvironment({ npm_config_userconfig: userConfigFile });
525
+ env.PATH = [dirname(this.#pnpm.executable), env.PATH].filter(Boolean).join(this.#platform === "win32" ? ";" : ":");
526
+ return env;
524
527
  }
525
528
  #resolveCliRelative(packageJson) {
526
529
  if (this.#platform === "win32") return join("bin", "claude.exe");
@@ -729,7 +732,7 @@ var ClaudeRuntimeManager = class {
729
732
  // src/host/installer.ts
730
733
  import { spawn } from "node:child_process";
731
734
  import { join as join2 } from "node:path";
732
- var runInstaller = (command, args, options) => new Promise((resolve4, reject) => {
735
+ var runInstaller = (command, args, options) => new Promise((resolve3, reject) => {
733
736
  const { timeoutMs = 3e5, signal, ...spawnOptions } = options;
734
737
  if (signal?.aborted) {
735
738
  reject(new Error("Claude Code preparation was canceled."));
@@ -793,153 +796,40 @@ var runInstaller = (command, args, options) => new Promise((resolve4, reject) =>
793
796
  child.once("close", async (code) => {
794
797
  await stopping;
795
798
  if (failure) reject(failure);
796
- else resolve4({ code: code ?? -1, ...versionProbe ? { stdout } : {} });
799
+ else resolve3({ code: code ?? -1, ...versionProbe ? { stdout } : {} });
797
800
  });
798
801
  });
799
802
 
800
- // src/host/mcp-launcher.ts
801
- import { createHash } from "node:crypto";
802
- import { constants } from "node:fs";
803
- import { access, mkdir, realpath, stat, writeFile } from "node:fs/promises";
804
- import { delimiter, extname, isAbsolute as isAbsolute2, join as join3 } from "node:path";
805
- var launcherSource = `'use strict';
806
- const { spawn } = require('node:child_process');
807
- const { readFileSync } = require('node:fs');
808
- const { isAbsolute } = require('node:path');
809
- let spec;
810
- try {
811
- spec = JSON.parse(readFileSync(process.argv[2], 'utf8'));
812
- if (!isAbsolute(spec.command) || !isAbsolute(spec.cwd) || !Array.isArray(spec.args)
813
- || spec.args.some(value => typeof value !== 'string' || value.includes('\\0'))
814
- || spec.env !== undefined && (typeof spec.env !== 'object' || Object.values(spec.env).some(value => typeof value !== 'string' || !/^ZW_CLAUDE_MCP_[A-F0-9]{20}$/.test(value)))) throw new Error();
815
- } catch {
816
- process.stderr.write('ZeroWall MCP launch configuration is invalid.\\n');
817
- process.exit(1);
818
- }
819
- let child;
820
- try {
821
- const childEnv = { ...process.env };
822
- const inherited = new Set(['PATH', 'SYSTEMROOT', 'WINDIR', 'TEMP', 'TMP', 'USERPROFILE', 'HOMEDRIVE', 'HOMEPATH',
823
- 'APPDATA', 'LOCALAPPDATA', 'HOME', 'LANG', 'LC_ALL', 'LC_CTYPE', 'TZ', 'TERM', 'NO_COLOR', 'FORCE_COLOR']);
824
- for (const key of Object.keys(childEnv)) if (!inherited.has(key.toUpperCase())) delete childEnv[key];
825
- delete childEnv.ELECTRON_RUN_AS_NODE;
826
- if (spec.electron === true) childEnv.ELECTRON_RUN_AS_NODE = '1';
827
- for (const [target, reference] of Object.entries(spec.env || {})) {
828
- if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(target) || typeof process.env[reference] !== 'string') throw new Error();
829
- childEnv[target] = process.env[reference];
830
- }
831
- child = spawn(spec.command, spec.args, { cwd: spec.cwd, shell: false, windowsHide: true,
832
- env: childEnv, stdio: ['pipe', 'pipe', 'pipe'] });
833
- } catch {
834
- process.stderr.write('ZeroWall MCP process could not start.\\n');
835
- process.exit(1);
836
- }
837
- let stopping = false;
838
- let eofTimer;
839
- const stop = () => {
840
- if (stopping) return;
841
- stopping = true;
842
- process.stdin.unpipe(child.stdin);
843
- child.stdin.destroy();
844
- child.kill();
845
- };
846
- process.on('SIGTERM', stop);
847
- process.on('SIGINT', stop);
848
- process.on('SIGHUP', stop);
849
- process.on('exit', () => { if (child.exitCode === null) child.kill(); });
850
- process.stdin.on('error', stop);
851
- process.stdout.on('error', stop);
852
- process.stderr.on('error', stop);
853
- child.stdin.on('error', stop);
854
- process.stdin.pipe(child.stdin);
855
- process.stdin.once('end', () => {
856
- // Give an orderly protocol shutdown a short window before stopping a server
857
- // that keeps running after Claude closes its input.
858
- eofTimer = setTimeout(stop, 1000);
859
- eofTimer.unref();
860
- });
861
- child.stdout.pipe(process.stdout, { end: false });
862
- child.stderr.pipe(process.stderr, { end: false });
863
- child.once('error', () => {
864
- process.stderr.write('ZeroWall MCP process could not start.\\n');
865
- });
866
- child.once('close', (code, signal) => {
867
- clearTimeout(eofTimer);
868
- process.stdin.unpipe(child.stdin);
869
- process.stdin.destroy();
870
- process.exitCode = Number.isInteger(code) ? code : signal ? 143 : 1;
871
- });
872
- `;
873
- async function resolveNativeFromPath(command, searchPath) {
874
- if (!searchPath || /[\\/:]/u.test(command) || command !== command.trim()) return void 0;
875
- const extensions = process.platform === "win32" ? extname(command) ? /\.(?:exe|com)$/iu.test(command) ? [""] : [] : [".exe", ".com"] : [""];
876
- for (const entry of searchPath.split(delimiter)) {
877
- const directory = entry.replace(/^"(.*)"$/u, "$1");
878
- if (!isAbsolute2(directory)) continue;
879
- for (const suffix of extensions) {
880
- try {
881
- const candidate = await realpath(join3(directory, `${command}${suffix}`));
882
- if (!(await stat(candidate)).isFile()) continue;
883
- if (process.platform !== "win32") await access(candidate, constants.X_OK);
884
- return candidate;
885
- } catch {
886
- }
887
- }
888
- }
889
- return void 0;
803
+ // src/host/skill-files.ts
804
+ import { cp, mkdir, readdir, rm, symlink, writeFile } from "node:fs/promises";
805
+ import { join as join3 } from "node:path";
806
+ function claudeHostText(text) {
807
+ return text.replace(/\bmcp__(?!zerowall__)([A-Za-z0-9_-]+)__([A-Za-z0-9_-]+)/gu, "mcp__zerowall__mcp__$1__$2");
890
808
  }
891
- async function writeClaudeMcpLaunchers(projection, options) {
892
- if (!isAbsolute2(options.root) || !isAbsolute2(options.executable) || options.root.includes("\0") || options.executable.includes("\0")) throw new Error("Invalid MCP launcher runtime.");
893
- const root = join3(options.root, "mcp-launchers");
894
- const wrapped = projection.servers.some((server) => server.type === "stdio" && server.launcher);
895
- if (wrapped) {
896
- await mkdir(root, { recursive: true, mode: 448 });
897
- await writeFile(join3(root, "launch.cjs"), launcherSource, { mode: 384 });
898
- }
899
- const servers = [];
900
- const skipped = [];
901
- for (const server of projection.servers) {
902
- if (server.type !== "stdio") {
903
- servers.push(server);
904
- continue;
905
- }
906
- const { launcher } = server;
907
- if (!launcher) {
908
- skipped.push({ serverName: server.serverName, reason: "unsupported-launch" });
909
- continue;
910
- }
911
- const command = launcher.useBundledNode ? options.executable : launcher.resolveFromPath ? await resolveNativeFromPath(launcher.command, options.searchPath) : launcher.command;
912
- if (!command) {
913
- skipped.push({ serverName: server.serverName, reason: "unsupported-launch" });
914
- continue;
915
- }
916
- const specPath = join3(root, `${createHash("sha256").update(server.serverName).digest("hex")}.json`);
917
- const env = Object.fromEntries(Object.entries(server.env ?? {}).map(([target, placeholder]) => {
918
- const match = /^\$\{(ZW_CLAUDE_MCP_[A-F0-9]{20})\}$/u.exec(placeholder);
919
- if (!match) throw new Error("Claude MCP launcher credential placeholder is invalid.");
920
- return [target, match[1]];
921
- }));
922
- await writeFile(specPath, JSON.stringify({
923
- command,
924
- args: launcher.args,
925
- cwd: launcher.cwd,
926
- env,
927
- electron: Boolean(options.electron && launcher.useBundledNode)
928
- }), { mode: 384 });
929
- servers.push({
930
- serverName: server.serverName,
931
- type: "stdio",
932
- command: options.executable,
933
- args: [join3(root, "launch.cjs"), specPath],
934
- ...server.env || options.electron ? { env: { ...server.env, ...options.electron ? { ELECTRON_RUN_AS_NODE: "1" } : {} } } : {}
935
- });
809
+ async function writeClaudeSkills(root, projection) {
810
+ const skillsRoot = join3(root, "skills");
811
+ await mkdir(skillsRoot, { recursive: true, mode: 448 });
812
+ const active = new Set(projection.skills.map((skill) => skill.name));
813
+ for (const entry of await readdir(skillsRoot)) if (!active.has(entry)) await rm(join3(skillsRoot, entry), { recursive: true, force: true });
814
+ for (const skill of projection.skills) {
815
+ const directory = join3(skillsRoot, skill.name);
816
+ await rm(directory, { recursive: true, force: true });
817
+ await mkdir(directory, { recursive: true, mode: 448 });
818
+ const resource = skill.resourceBase;
819
+ if (resource?.kind === "directory") {
820
+ for (const entry of await readdir(resource.path, { withFileTypes: true })) {
821
+ if (["SKILL.md", ".git", "node_modules", "__pycache__"].includes(entry.name)) continue;
822
+ const source = join3(resource.path, entry.name), target = join3(directory, entry.name);
823
+ if (entry.isDirectory() && !/\.asar(?:[\\/]|$)/u.test(source)) await symlink(source, target, process.platform === "win32" ? "junction" : "dir");
824
+ else await cp(source, target, { recursive: true, dereference: true });
825
+ }
826
+ }
827
+ const hint = resource?.kind === "url" ? "Resolve relative resource URLs against " + resource.url : resource?.kind === "opaque" ? resource.description : "Relative resources are available in this skill directory.";
828
+ await writeFile(join3(directory, "SKILL.md"), "---\nname: " + skill.name + "\ndescription: " + JSON.stringify(skill.description) + "\ndisable-model-invocation: " + !skill.invocation.modelInvocable + "\nuser-invocable: " + (skill.invocation.userInvocable !== false) + "\n---\n" + hint + "\n\n" + claudeHostText(skill.content), { mode: 384 });
936
829
  }
937
- return { servers, skipped };
938
830
  }
939
831
 
940
832
  // src/host/projection.ts
941
- import { createHash as createHash2 } from "node:crypto";
942
- import { basename, extname as extname2, isAbsolute as isAbsolute3, resolve as resolve2 } from "node:path";
943
833
  var skillNamePattern = /^[a-z0-9]+(?:-[a-z0-9]+)*$/u;
944
834
  async function projectSkillsForClaude(registry, cwd, scope) {
945
835
  const lookup = { cwd, ...scope === void 0 ? {} : { scope } };
@@ -988,162 +878,6 @@ async function projectSkillsForClaude(registry, cwd, scope) {
988
878
  }
989
879
  return { skills, skipped };
990
880
  }
991
- var mcpServerNamePattern = /^[A-Za-z0-9][A-Za-z0-9_-]{0,99}$/u;
992
- var referenceNamePattern = /^[A-Za-z_][A-Za-z0-9_]*$/u;
993
- var httpHeaderNamePattern = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/u;
994
- function normalizedMcpUrl(value) {
995
- if (typeof value !== "string" || value !== value.trim() || /[\u0000-\u0020\u007f?#]/u.test(value)) return void 0;
996
- try {
997
- const url = new URL(value);
998
- if (!["https:", "http:"].includes(url.protocol) || url.username || url.password || url.search || url.hash) return void 0;
999
- return url.href;
1000
- } catch {
1001
- return void 0;
1002
- }
1003
- }
1004
- function normalizedWorkingDirectory(value) {
1005
- if (typeof value !== "string" || value.includes("\0") || !isAbsolute3(value)) return void 0;
1006
- const absolute = resolve2(value);
1007
- return process.platform === "win32" ? absolute.toLowerCase() : absolute;
1008
- }
1009
- function independentLaunch(record, cwd, allowPath) {
1010
- const command = record.command;
1011
- const commandName = basename(command).toLowerCase();
1012
- if (commandName === "node" || commandName === "node.exe") {
1013
- return { cwd, command, args: [...record.args], useBundledNode: true };
1014
- }
1015
- if (/\.(?:cmd|bat|ps1|sh|cjs|mjs|js)$/iu.test(command)) return void 0;
1016
- if (!isAbsolute3(command)) {
1017
- if (!allowPath || /[\\/:]/u.test(command) || command !== command.trim()) return void 0;
1018
- return { cwd, command, args: [...record.args], useBundledNode: false, resolveFromPath: true };
1019
- }
1020
- if (process.platform === "win32" && extname2(command).toLowerCase() !== ".exe") return void 0;
1021
- return { cwd, command, args: [...record.args], useBundledNode: false };
1022
- }
1023
- function projectMcpForClaude(records, cwd) {
1024
- const sessionCwd = normalizedWorkingDirectory(cwd);
1025
- const counts2 = /* @__PURE__ */ new Map();
1026
- for (const record of records) counts2.set(record.serverName, (counts2.get(record.serverName) ?? 0) + 1);
1027
- const servers = [];
1028
- const skipped = [];
1029
- for (const record of records) {
1030
- const serverName = typeof record.serverName === "string" ? record.serverName : "";
1031
- if (record.enabled !== true) {
1032
- skipped.push({ serverName, reason: "disabled" });
1033
- continue;
1034
- }
1035
- if (record.transport !== "stdio" && record.transport !== "streamable-http") {
1036
- skipped.push({ serverName, reason: "unsupported-transport" });
1037
- continue;
1038
- }
1039
- if (serverName.startsWith("zerowall_managed_") || typeof record.command === "string" && record.command.startsWith("zerowall-managed:")) {
1040
- skipped.push({ serverName, reason: "managed-server" });
1041
- continue;
1042
- }
1043
- if (Object.keys((record.transport === "stdio" ? record.headerRefs : record.envRefs) ?? {}).length > 0) {
1044
- skipped.push({ serverName, reason: "credential-reference" });
1045
- continue;
1046
- }
1047
- const refs = record.transport === "stdio" ? record.envRefs ?? {} : record.headerRefs ?? {};
1048
- const targets = Object.keys(refs);
1049
- if (new Set(targets.map((target) => target.toLowerCase())).size !== targets.length || Object.entries(refs).some(([target, ref]) => typeof ref !== "string" || !referenceNamePattern.test(ref) || (record.transport === "streamable-http" ? !httpHeaderNamePattern.test(target) : !referenceNamePattern.test(target) || /^(?:ANTHROPIC_|CLAUDE_|DSH_|NPM_CONFIG_|PNPM_|XDG_)/iu.test(target) || ["PATH", "HOME", "USERPROFILE", "APPDATA", "LOCALAPPDATA", "SYSTEMROOT", "WINDIR", "COMSPEC", "NODE_OPTIONS", "NODE_PATH", "ELECTRON_RUN_AS_NODE", "TEMP", "TMP", "TMPDIR"].includes(target.toUpperCase())))) {
1050
- skipped.push({ serverName, reason: "invalid-credential-reference" });
1051
- continue;
1052
- }
1053
- if ((counts2.get(serverName) ?? 0) !== 1) {
1054
- skipped.push({ serverName, reason: "duplicate-server-name" });
1055
- continue;
1056
- }
1057
- if (!mcpServerNamePattern.test(serverName)) {
1058
- skipped.push({ serverName, reason: "invalid-launch" });
1059
- continue;
1060
- }
1061
- if (record.transport === "streamable-http") {
1062
- const url = normalizedMcpUrl(record.url);
1063
- if (!url) {
1064
- skipped.push({ serverName, reason: "invalid-launch" });
1065
- continue;
1066
- }
1067
- servers.push({ serverName, type: "http", url, headerRefs: { ...refs } });
1068
- continue;
1069
- }
1070
- if (typeof record.command !== "string" || record.command.trim() === "" || record.command.includes("\0") || !Array.isArray(record.args) || record.args.some((argument) => typeof argument !== "string" || argument.includes("\0"))) {
1071
- skipped.push({ serverName, reason: "invalid-launch" });
1072
- continue;
1073
- }
1074
- if (process.platform === "win32" && /\.(?:cmd|bat)$/iu.test(record.command)) {
1075
- skipped.push({ serverName, reason: "unsupported-launch" });
1076
- continue;
1077
- }
1078
- if (!sessionCwd || record.cwd !== void 0 && (typeof record.cwd !== "string" || record.cwd.trim() !== "" && !normalizedWorkingDirectory(record.cwd))) {
1079
- skipped.push({ serverName, reason: "unsupported-working-directory" });
1080
- continue;
1081
- }
1082
- const requestedCwd = typeof record.cwd === "string" && record.cwd.trim() !== "" ? resolve2(record.cwd) : cwd;
1083
- const differentCwd = record.cwd !== void 0 && record.cwd.trim() !== "" && normalizedWorkingDirectory(record.cwd) !== sessionCwd;
1084
- const launcher = independentLaunch(record, requestedCwd, !differentCwd);
1085
- if (!launcher) {
1086
- skipped.push({ serverName, reason: "unsupported-launch" });
1087
- continue;
1088
- }
1089
- servers.push({
1090
- serverName,
1091
- type: "stdio",
1092
- command: record.command,
1093
- args: [...record.args],
1094
- envRefs: { ...record.envRefs },
1095
- launcher
1096
- });
1097
- }
1098
- return { servers, skipped };
1099
- }
1100
- async function prepareClaudeMcpRuntime(projection, resolveReference) {
1101
- const servers = [];
1102
- const environment = {};
1103
- const skipped = [...projection.skipped];
1104
- for (const server of projection.servers) {
1105
- const placeholders = {};
1106
- const serverEnvironment = {};
1107
- const refs = server.type === "stdio" ? server.envRefs : server.headerRefs;
1108
- let available = true;
1109
- for (const [target, reference] of Object.entries(refs)) {
1110
- let value;
1111
- try {
1112
- value = await resolveReference(reference);
1113
- } catch {
1114
- value = void 0;
1115
- }
1116
- if (typeof value !== "string" || !value.trim() || value.includes("\0") || server.type === "http" && /[\r\n]/u.test(value)) {
1117
- available = false;
1118
- break;
1119
- }
1120
- const variable = `ZW_CLAUDE_MCP_${createHash2("sha256").update(`${server.serverName}\0${target}`).digest("hex").slice(0, 20).toUpperCase()}`;
1121
- serverEnvironment[variable] = value;
1122
- placeholders[target] = `\${${variable}}`;
1123
- }
1124
- if (!available) {
1125
- skipped.push({ serverName: server.serverName, reason: "credential-unavailable" });
1126
- continue;
1127
- }
1128
- Object.assign(environment, serverEnvironment);
1129
- if (server.type === "http") {
1130
- servers.push({
1131
- serverName: server.serverName,
1132
- type: "http",
1133
- url: server.url,
1134
- ...Object.keys(placeholders).length ? { headers: placeholders } : {}
1135
- });
1136
- } else servers.push({
1137
- serverName: server.serverName,
1138
- type: "stdio",
1139
- command: server.command,
1140
- args: server.args,
1141
- ...Object.keys(placeholders).length ? { env: placeholders } : {},
1142
- ..."launcher" in server && server.launcher ? { launcher: server.launcher } : {}
1143
- });
1144
- }
1145
- return { servers, environment, skipped };
1146
- }
1147
881
 
1148
882
  // src/host/route.ts
1149
883
  function selectedClaudeModel(projection, fallback, loggedHeader) {
@@ -1412,8 +1146,8 @@ var CLAUDE_MODE_BY_SANDBOX = {
1412
1146
  };
1413
1147
 
1414
1148
  // src/host/session-binding.ts
1415
- import { createHash as createHash3, randomUUID as randomUUID2 } from "node:crypto";
1416
- import { lstat, mkdir as mkdir2, readFile, readdir, rename, rm, writeFile as writeFile2 } from "node:fs/promises";
1149
+ import { createHash, randomUUID as randomUUID2 } from "node:crypto";
1150
+ import { lstat, mkdir as mkdir2, readFile, readdir as readdir2, rename, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
1417
1151
  import { join as join4 } from "node:path";
1418
1152
  import { createReadStream } from "node:fs";
1419
1153
  import { createInterface } from "node:readline";
@@ -1423,7 +1157,7 @@ var ClaudeSessionBindings = class {
1423
1157
  }
1424
1158
  configDir;
1425
1159
  file(id) {
1426
- return join4(this.configDir, "bindings", `${createHash3("sha256").update(id).digest("hex")}.json`);
1160
+ return join4(this.configDir, "bindings", `${createHash("sha256").update(id).digest("hex")}.json`);
1427
1161
  }
1428
1162
  async load(id, cwd) {
1429
1163
  let previous;
@@ -1476,12 +1210,12 @@ var ClaudeSessionBindings = class {
1476
1210
  try {
1477
1211
  await rename(temporary, file);
1478
1212
  } finally {
1479
- await rm(temporary, { force: true });
1213
+ await rm2(temporary, { force: true });
1480
1214
  }
1481
1215
  }
1482
1216
  async transcript(nativeId) {
1483
1217
  const root = join4(this.configDir, "projects");
1484
- const directories = await readdir(root, { withFileTypes: true }).catch((error) => {
1218
+ const directories = await readdir2(root, { withFileTypes: true }).catch((error) => {
1485
1219
  if (error.code === "ENOENT") return [];
1486
1220
  throw error;
1487
1221
  });
@@ -1498,7 +1232,7 @@ var ClaudeSessionBindings = class {
1498
1232
  };
1499
1233
  function inputKey(value) {
1500
1234
  const message = value;
1501
- return createHash3("sha256").update(typeof message?.id === "string" ? message.id : JSON.stringify(value)).digest("hex");
1235
+ return createHash("sha256").update(typeof message?.id === "string" ? message.id : JSON.stringify(value)).digest("hex");
1502
1236
  }
1503
1237
 
1504
1238
  // src/host/sdk-driver.ts
@@ -1550,7 +1284,7 @@ async function settleClaudeToolCalls(agent) {
1550
1284
  }
1551
1285
 
1552
1286
  // src/host/sdk-driver.ts
1553
- function createHostToolBridge(agent, schemas, signal, source, state = { concluded: false }, currentSchemas = () => schemas) {
1287
+ function createHostToolBridge(agent, schemas, signal, source, state = { concluded: false }, currentSchemas = () => schemas, synchronizeResources) {
1554
1288
  const server = createSdkMcpServer({ name: "zerowall", version: "1.0.0", instructions: "These are built-in tools executing through the current ZeroWall Host, not separate external MCP services. Image tools are mcp__zerowall__generate_image and mcp__zerowall__edit_image when listed. Preserve the configured image model and parameters. After capability_search enables tools, their real schemas are refreshed; if needed call RefreshMcpTools for server zerowall once, then ToolSearch for the exact returned bridge name. Do not reconnect unrelated external servers." });
1555
1289
  server.instance.server.registerCapabilities({ tools: { listChanged: true } });
1556
1290
  let published = JSON.stringify(currentSchemas());
@@ -1600,8 +1334,8 @@ function createHostToolBridge(agent, schemas, signal, source, state = { conclude
1600
1334
  server.instance.server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
1601
1335
  const previous = queue;
1602
1336
  let release;
1603
- queue = new Promise((resolve4) => {
1604
- release = resolve4;
1337
+ queue = new Promise((resolve3) => {
1338
+ release = resolve3;
1605
1339
  });
1606
1340
  await previous;
1607
1341
  try {
@@ -1627,12 +1361,18 @@ function createHostToolBridge(agent, schemas, signal, source, state = { conclude
1627
1361
  const content = await mcpContent(agent, result.content, lifetime);
1628
1362
  for (const context2 of batch.additionalContexts) content.push(...await mcpContent(agent, context2.content, lifetime));
1629
1363
  await state.delivered?.(batch.additionalContexts.map(inputKey));
1364
+ try {
1365
+ await synchronizeResources?.();
1366
+ } catch (_error) {
1367
+ content.push({ type: "text", text: "The operation completed, but the updated Skills could not be projected. Retry resource synchronization before using new Skills." });
1368
+ }
1630
1369
  const latest = currentSchemas();
1631
1370
  const fingerprint = JSON.stringify(latest);
1632
1371
  if (fingerprint !== published) {
1633
1372
  if (!await notifyChanges()) {
1634
1373
  content.push({ type: "text", text: "The Host tool list changed but its notification could not be delivered. Call RefreshMcpTools for server zerowall to re-list tools; do not repeat the operation that just completed." });
1635
1374
  }
1375
+ content.push({ type: "text", text: "Available bridge names: " + latest.map((schema2) => "mcp__zerowall__" + schema2.name).slice(0, 40).join(", ") });
1636
1376
  content.push({ type: "text", text: 'Host tool schemas changed. Use the updated tools; if a newly enabled tool is not in ToolSearch yet, call RefreshMcpTools with {"server":"zerowall"} once, then search its exact mcp__zerowall__ name. No external MCP connection is required.' });
1637
1377
  }
1638
1378
  return { content, isError: result.isError };
@@ -1782,8 +1522,9 @@ function resourceStatus(skills, servers, tools, runtime = [], disabledSkills = [
1782
1522
  for (const name2 of disabledSkills) if (!rows.some((row2) => row2.name === name2)) rows.push({ kind: "skill", name: name2, state: "disabled" });
1783
1523
  for (const server of servers) {
1784
1524
  const status = runtime.find((row2) => row2.serverName === server.serverName)?.runtimeState;
1525
+ const lazy = tools.some((tool) => tool.name === "capability_search") && server.enabled && !["error", "unavailable"].includes(status ?? "");
1785
1526
  const available = tools.some((tool) => tool.name.startsWith(`mcp__${server.serverName}__`));
1786
- rows.push({ kind: "mcp", name: server.serverName, state: !server.enabled ? "disabled" : available ? "synced" : status === "error" ? "failed" : "unavailable", detail: available ? "\u901A\u8FC7\u73B0\u6709 Host \u8FDE\u63A5\u6865\u63A5" : status ?? "\u5F53\u524D\u4F1A\u8BDD\u6CA1\u6709\u53EF\u7528\u5DE5\u5177" });
1527
+ rows.push({ kind: "mcp", name: server.serverName, state: !server.enabled ? "disabled" : available ? "synced" : status === "error" ? "failed" : lazy ? "on-demand" : "unavailable", detail: available ? "\u901A\u8FC7\u73B0\u6709 Host \u8FDE\u63A5\u6865\u63A5" : lazy ? "\u901A\u8FC7 capability_search \u6309\u9700\u8FDE\u63A5\uFF0C\u5DE5\u5177\u7531 Host \u6865\u63A5" : status ?? "\u5F53\u524D\u4F1A\u8BDD\u6CA1\u6709\u53EF\u7528\u5DE5\u5177" });
1787
1528
  }
1788
1529
  return rows;
1789
1530
  }
@@ -2479,10 +2220,10 @@ var ClaudeCodeService = class extends (_a = TypertRemoteService, _status_dec = [
2479
2220
  }
2480
2221
  config;
2481
2222
  desktop() {
2482
- return Boolean(process.env.ZEROWALL_DESKTOP_RUNTIME_ROOT && isAbsolute4(process.env.ZEROWALL_DESKTOP_RUNTIME_ROOT));
2223
+ return Boolean(process.env.ZEROWALL_DESKTOP_RUNTIME_ROOT && isAbsolute2(process.env.ZEROWALL_DESKTOP_RUNTIME_ROOT));
2483
2224
  }
2484
2225
  runtimeRoot() {
2485
- return resolve3(this.config.runtimeRoot ?? process.env.ZEROWALL_CLAUDE_RUNTIME_ROOT ?? join5(resolveDshHome(), "zerowall", "claude-code", "runtime"));
2226
+ return resolve2(this.config.runtimeRoot ?? process.env.ZEROWALL_CLAUDE_RUNTIME_ROOT ?? join5(resolveDshHome(), "zerowall", "claude-code", "runtime"));
2486
2227
  }
2487
2228
  anyRunning() {
2488
2229
  return [...this.sessions.values()].some((state) => state.busy || state.turn?.view.running === true);
@@ -2519,16 +2260,16 @@ var ClaudeCodeService = class extends (_a = TypertRemoteService, _status_dec = [
2519
2260
  if (this.sessionOccupied(owner)) return;
2520
2261
  const waiters = owner.availableWaiters;
2521
2262
  delete owner.availableWaiters;
2522
- for (const resolve4 of waiters ?? []) resolve4();
2263
+ for (const resolve3 of waiters ?? []) resolve3();
2523
2264
  }
2524
2265
  async waitForSessionAvailable(owner, signal) {
2525
2266
  while (this.sessionOccupied(owner)) {
2526
2267
  if (signal?.aborted) throw new Error("Claude Code request was canceled.");
2527
- await new Promise((resolve4, reject) => {
2268
+ await new Promise((resolve3, reject) => {
2528
2269
  const cleanup = () => signal?.removeEventListener("abort", abort);
2529
2270
  const ready = () => {
2530
2271
  cleanup();
2531
- resolve4();
2272
+ resolve3();
2532
2273
  };
2533
2274
  const abort = () => {
2534
2275
  owner.availableWaiters?.delete(ready);
@@ -2686,7 +2427,7 @@ var ClaudeCodeService = class extends (_a = TypertRemoteService, _status_dec = [
2686
2427
  const root = this.desktop() ? join5(this.runtime().configDir, "output-styles") : "";
2687
2428
  const user = [];
2688
2429
  try {
2689
- for (const entry of root ? (await readdir2(root, { withFileTypes: true })).slice(0, 256) : []) {
2430
+ for (const entry of root ? (await readdir3(root, { withFileTypes: true })).slice(0, 256) : []) {
2690
2431
  if (!entry.isFile() || !entry.name.toLowerCase().endsWith(".md")) continue;
2691
2432
  const fallback = entry.name.slice(0, -3);
2692
2433
  let value = fallback;
@@ -2820,7 +2561,7 @@ var ClaudeCodeService = class extends (_a = TypertRemoteService, _status_dec = [
2820
2561
  output.finish();
2821
2562
  turn.view.running = false;
2822
2563
  this.sessions.delete(id);
2823
- if (turn.projectionRoot) await rm2(turn.projectionRoot, { recursive: true, force: true }).catch(() => void 0);
2564
+ if (turn.projectionRoot) await rm3(turn.projectionRoot, { recursive: true, force: true }).catch(() => void 0);
2824
2565
  if (turn.binding) {
2825
2566
  turn.binding.state = turn.cancel.signal.aborted ? "stopped" : diagnostic ? "failed" : "idle";
2826
2567
  await turn.bindingStore.save(id, turn.binding);
@@ -2876,7 +2617,7 @@ var ClaudeCodeService = class extends (_a = TypertRemoteService, _status_dec = [
2876
2617
  await rename2(temporary, path);
2877
2618
  await chmod(path, 384);
2878
2619
  } finally {
2879
- await rm2(temporary, { force: true }).catch(() => void 0);
2620
+ await rm3(temporary, { force: true }).catch(() => void 0);
2880
2621
  }
2881
2622
  }
2882
2623
  async install(agent) {
@@ -3079,52 +2820,18 @@ var ClaudeCodeService = class extends (_a = TypertRemoteService, _status_dec = [
3079
2820
  if (!executable) throw new Error("\u8BF7\u5148\u5B89\u88C5 Claude Code\u3002");
3080
2821
  const workingDirectory = this.ctx.get("workingDirectory");
3081
2822
  const cwd = execution.cwd ?? workingDirectory.get(agent.session);
3082
- if (!isAbsolute4(cwd)) throw new Error("\u5F53\u524D\u4F1A\u8BDD\u6CA1\u6709\u6709\u6548\u7684\u9879\u76EE\u76EE\u5F55\u3002");
2823
+ if (!isAbsolute2(cwd)) throw new Error("\u5F53\u524D\u4F1A\u8BDD\u6CA1\u6709\u6709\u6548\u7684\u9879\u76EE\u76EE\u5F55\u3002");
3083
2824
  assertUsableCwd("Claude Code", "working directory", cwd);
3084
2825
  const route2 = await this.route(agent, selected);
3085
2826
  cancel.signal.throwIfAborted();
3086
2827
  const skillsRegistry = agent.ctx.get("skills");
3087
2828
  const projects = this.ctx.get("zerowallMcpConfigurationStore");
3088
- const skills = await projectSkillsForClaude(skillsRegistry, cwd, execution.scope ?? agent);
3089
- const credentials = this.ctx.get("credentials");
3090
- const mcp = await prepareClaudeMcpRuntime(projectMcpForClaude(projects.listMcpServers(), cwd), async (reference) => {
3091
- const specialKey = reference === "R_PLATFORM_MCP_AUTHORIZATION" ? "zerowall.mcp.rdatalinux_authorization" : reference === "HUAGONGSHE_MCP_AUTHORIZATION" ? "zerowall.mcp.huagongshe_token" : void 0;
3092
- if (specialKey) {
3093
- const value = await this.secrets.get(specialKey).catch(() => void 0);
3094
- if (value?.trim()) return reference === "HUAGONGSHE_MCP_AUTHORIZATION" ? `Bearer ${value.trim()}` : value;
3095
- }
3096
- const stored = await this.secrets.get(`zerowall.environment.var.${reference.toLowerCase()}`).catch(() => void 0);
3097
- return stored ?? (await credentials.resolve(credentialRef(reference)))?.value;
3098
- });
2829
+ let skills = await projectSkillsForClaude(skillsRegistry, cwd, execution.scope ?? agent);
3099
2830
  cancel.signal.throwIfAborted();
3100
- projectionRoot = join5(runtime.configDir, "sessions", createHash4("sha256").update(agent.id).digest("hex"), "projection");
3101
- await rm2(projectionRoot, { recursive: true, force: true }).catch(() => void 0);
2831
+ projectionRoot = join5(runtime.configDir, "sessions", createHash2("sha256").update(agent.id).digest("hex"), "projection");
2832
+ await rm3(projectionRoot, { recursive: true, force: true }).catch(() => void 0);
3102
2833
  await mkdir3(projectionRoot, { recursive: true, mode: 448 });
3103
- const skillRoot = join5(projectionRoot, "skills");
3104
- for (const skill of skills.skills) {
3105
- const resource = skill.resourceBase;
3106
- const hint = resource?.kind === "directory" ? `Resolve every relative skill resource path against this original base directory: ${resource.path}.` : resource?.kind === "url" ? `Resolve every relative skill resource URL against this original base URL: ${resource.url}.` : resource?.kind === "opaque" ? `Original skill resources: ${resource.description}` : "";
3107
- const dir = join5(skillRoot, skill.name);
3108
- await mkdir3(dir, { recursive: true, mode: 448 });
3109
- await writeFile3(join5(dir, "SKILL.md"), `---
3110
- name: ${skill.name}
3111
- description: ${JSON.stringify(skill.description)}
3112
- disable-model-invocation: ${!skill.invocation.modelInvocable}
3113
- user-invocable: ${skill.invocation.userInvocable !== false}
3114
- ---
3115
- ${hint}
3116
-
3117
- ${skill.content}`, { mode: 384 });
3118
- }
3119
- const mcpPath = join5(projectionRoot, "mcp.json");
3120
- const searchPath = Object.entries(process.env).find(([key]) => key.toUpperCase() === "PATH")?.[1];
3121
- const { servers: mcpServers, skipped: launchSkipped } = await writeClaudeMcpLaunchers(mcp, {
3122
- root: projectionRoot,
3123
- executable: process.execPath,
3124
- electron: Boolean(process.versions.electron),
3125
- ...searchPath ? { searchPath } : {}
3126
- });
3127
- await writeFile3(mcpPath, JSON.stringify({ mcpServers: Object.fromEntries(mcpServers.map(({ serverName, ...config }) => [serverName, config])) }), { mode: 384 });
2834
+ await writeClaudeSkills(projectionRoot, skills);
3128
2835
  const pluginMeta = join5(projectionRoot, ".claude-plugin");
3129
2836
  await mkdir3(pluginMeta, { mode: 448 });
3130
2837
  await writeFile3(join5(pluginMeta, "plugin.json"), JSON.stringify({ name: "zerowall-session-skills", version: "0.1.0" }), { mode: 384 });
@@ -3141,7 +2848,7 @@ ${skill.content}`, { mode: 384 });
3141
2848
  ANTHROPIC_DEFAULT_HAIKU_MODEL: route2.model,
3142
2849
  ANTHROPIC_DEFAULT_SONNET_MODEL: route2.model,
3143
2850
  ANTHROPIC_DEFAULT_OPUS_MODEL: route2.model
3144
- }, void 0, mcp.environment, configuredEnvironment);
2851
+ }, void 0, {}, configuredEnvironment);
3145
2852
  const settingsEnvironment = claudeSettingsEnvironment(nativeSettings, route2.model, baseEnvironment);
3146
2853
  const environment = settingsEnvironment.env;
3147
2854
  const turn = {
@@ -3155,10 +2862,10 @@ ${skill.content}`, { mode: 384 });
3155
2862
  renderer: nativeSettings.renderer ?? "plugin",
3156
2863
  activity: [],
3157
2864
  skills: skills.skills.length,
3158
- mcp: mcpServers.length,
3159
- skipped: [...settingsEnvironment.warnings.map((item) => `\u8BBE\u7F6E\uFF1A${item}`), ...skills.skipped.map((item) => `Skill ${item.name}: ${item.reason}`), ...[...mcp.skipped.filter((item) => item.reason !== "managed-server"), ...launchSkipped].map((item) => `MCP ${item.serverName}: ${item.reason === "unsupported-working-directory" ? "\u5DE5\u4F5C\u76EE\u5F55\u65E0\u6548\uFF1AMCP \u76EE\u5F55\u5FC5\u987B\u4E3A\u7A7A\u767D\u6216\u7EDD\u5BF9\u76EE\u5F55\u3002" : item.reason === "unsupported-launch" ? "\u542F\u52A8\u65B9\u5F0F\u4E0D\u517C\u5BB9\uFF1A\u72EC\u7ACB\u76EE\u5F55\u4EC5\u652F\u6301 Node \u6216\u7EDD\u5BF9\u539F\u751F\u53EF\u6267\u884C\u6587\u4EF6\uFF1BWindows \u4E0D\u652F\u6301 .cmd/.bat\uFF0C\u8BF7\u4F7F\u7528\u670D\u52A1\u7684\u7EDD\u5BF9\u53EF\u6267\u884C\u5165\u53E3\u3002" : item.reason}`)]
2865
+ mcp: 0,
2866
+ skipped: [...settingsEnvironment.warnings.map((item) => `\u8BBE\u7F6E\uFF1A${item}`), ...skills.skipped.map((item) => `Skill ${item.name}: ${item.reason}`)]
3160
2867
  },
3161
- safe: new ClaudeSafeOutput([route2.apiKey, ...Object.values(mcp.environment), ...Object.values(configuredEnvironment)]),
2868
+ safe: new ClaudeSafeOutput([route2.apiKey, ...Object.values(configuredEnvironment)]),
3162
2869
  cancel
3163
2870
  };
3164
2871
  owner.turn = turn;
@@ -3189,19 +2896,36 @@ ${skill.content}`, { mode: 384 });
3189
2896
  await store.save(agent.id, binding);
3190
2897
  } };
3191
2898
  const bridgeAgent = execution.scope ?? agent;
2899
+ const skillRegistry = bridgeAgent.ctx.get("skills");
2900
+ if (!skillRegistry) throw new Error("The Skills registry is unavailable.");
2901
+ let skillCatalog = JSON.stringify((await skillsRegistry.snapshot({ cwd, scope: bridgeAgent })).skills);
3192
2902
  const bridge = createHostToolBridge(
3193
2903
  bridgeAgent,
3194
2904
  schemas,
3195
2905
  cancel.signal,
3196
2906
  route2,
3197
2907
  bridgeState,
3198
- () => bridgeAgent.ctx.get("tools").schemas(bridgeAgent)
2908
+ () => bridgeAgent.ctx.get("tools").schemas(bridgeAgent),
2909
+ async () => {
2910
+ const current = await skillsRegistry.snapshot({ cwd, scope: bridgeAgent });
2911
+ if (!current.complete) throw new Error("The Skills catalog is incomplete.");
2912
+ if (JSON.stringify(current.skills) !== skillCatalog) {
2913
+ skills = await projectSkillsForClaude(skillsRegistry, cwd, bridgeAgent);
2914
+ await writeClaudeSkills(projectionRoot, skills);
2915
+ skillCatalog = JSON.stringify(current.skills);
2916
+ turn.view.skills = skills.skills.length;
2917
+ }
2918
+ const tools = bridgeAgent.ctx.get("tools").schemas(bridgeAgent);
2919
+ const runtime2 = await this.ctx.get("zerowallMcp")?.list() ?? [];
2920
+ const inventory = await skillRegistry.inventory({ cwd });
2921
+ const disabled2 = inventory.entries.filter((entry) => entry.effective && !entry.enabled).map((entry) => entry.skill.name);
2922
+ turn.view.resources = resourceStatus(skills, projects.listMcpServers(), tools, runtime2, disabled2);
2923
+ turn.view.mcp = turn.view.resources.filter((row2) => row2.kind === "mcp" && row2.state === "synced").length;
2924
+ }
3199
2925
  );
3200
2926
  if (bridgeState.drain) turn.drainBridge = bridgeState.drain;
3201
2927
  const mcpService = this.ctx.get("zerowallMcp");
3202
2928
  const mcpRuntime = await mcpService?.list().catch(() => []) ?? [];
3203
- const skillRegistry = bridgeAgent.ctx.get("skills");
3204
- if (!skillRegistry) throw new Error("The Skills registry is unavailable.");
3205
2929
  const skillInventory = await skillRegistry.inventory({ cwd });
3206
2930
  const disabled = skillInventory.entries.filter((entry) => entry.effective && !entry.enabled).map((entry) => entry.skill.name);
3207
2931
  turn.view.resources = resourceStatus(skills, projects.listMcpServers(), schemas, mcpRuntime, disabled);
@@ -3229,7 +2953,7 @@ ${skill.content}`, { mode: 384 });
3229
2953
  plugins: [{ type: "local", path: projectionRoot }],
3230
2954
  ...nativeSettings.outputStyle && nativeSettings.outputStyle !== "Default" ? { settings: { outputStyle: nativeSettings.outputStyle } } : {},
3231
2955
  includePartialMessages: true,
3232
- systemPrompt: sdkSystemPrompt(execution.request),
2956
+ systemPrompt: claudeHostText(sdkSystemPrompt(execution.request)) + "\n\nAll Host tools are bridged through server zerowall. For a Host tool NAME, call mcp__zerowall__NAME with its real schema. This includes external tools: mcp__zerowallrmcp__r_runtime becomes mcp__zerowall__mcp__zerowallrmcp__r_runtime. Use mcp__zerowall__capability_search for on-demand MCP connections, then RefreshMcpTools for server zerowall and ToolSearch if needed. Skills use the same Host registry and enablement settings; read them through the projected Skills plugin or the Host skill tools. Do not create a second direct MCP connection.",
3233
2957
  mcpServers: { zerowall: bridge },
3234
2958
  strictMcpConfig: true,
3235
2959
  // Keep MCP tools out of the SDK's bare allowedTools auto-approval
@@ -3288,7 +3012,7 @@ ${skill.content}`, { mode: 384 });
3288
3012
  if (message === "Claude Code \u5DF2\u8FBE\u5230\u6700\u5927\u5E76\u53D1\u8FDB\u7A0B\u6570\uFF0C\u8BF7\u7B49\u5F85\u5176\u4ED6\u4EFB\u52A1\u5B8C\u6210\u3002") throw new Error(message);
3289
3013
  throw new Error("Claude Code \u65E0\u6CD5\u51C6\u5907\u5F53\u524D\u4F1A\u8BDD\uFF0C\u8BF7\u68C0\u67E5\u6A21\u578B\u914D\u7F6E\u4E0E\u8D44\u6E90\u72B6\u6001\u3002");
3290
3014
  } finally {
3291
- if (!processOwnsProjection && projectionRoot) await rm2(projectionRoot, { recursive: true, force: true }).catch(() => void 0);
3015
+ if (!processOwnsProjection && projectionRoot) await rm3(projectionRoot, { recursive: true, force: true }).catch(() => void 0);
3292
3016
  if (!processOwnsProjection) release();
3293
3017
  delete owner.preparing;
3294
3018
  owner.busy = false;
@@ -3646,7 +3370,7 @@ ${skill.content}`, { mode: 384 });
3646
3370
  activity: turn.view.activity ?? []
3647
3371
  });
3648
3372
  } finally {
3649
- if (turn.projectionRoot) await rm2(turn.projectionRoot, { recursive: true, force: true }).catch(() => void 0);
3373
+ if (turn.projectionRoot) await rm3(turn.projectionRoot, { recursive: true, force: true }).catch(() => void 0);
3650
3374
  }
3651
3375
  }
3652
3376
  this.notifySessionAvailable(owner);
@@ -3769,7 +3493,7 @@ ${lines.join("\n")}
3769
3493
  turn.binding.state = completed ? "idle" : turn.cancel.signal.aborted ? "stopped" : "failed";
3770
3494
  await turn.bindingStore.save(agent.id, turn.binding).catch(() => void 0);
3771
3495
  }
3772
- if (turn.projectionRoot) await rm2(turn.projectionRoot, { recursive: true, force: true }).catch(() => void 0);
3496
+ if (turn.projectionRoot) await rm3(turn.projectionRoot, { recursive: true, force: true }).catch(() => void 0);
3773
3497
  const owner = this.owner(agent);
3774
3498
  this.notifySessionAvailable(owner);
3775
3499
  }