feat(app): features screen with tool switches and MCP servers; v2 drops host file and screen tools

- Settings `features` (weather, webSearch, meals) and `mcpServers` (name, command, args, env names,
  enabled), edited on the new 기능 screen. The tools of a feature that is off go into the brain's
  `disabled_tools`; only enabled MCP servers go into its `mcps`.
- MCP environment values (API keys) live only in the encrypted secrets (`mcp:<server>:<NAME>`),
  shown as stored or not, masked in logs, removed with their server, and reach the worker only in
  `JARVIS_MCP_ENV`, which the brain takes out of its environment before giving each server its own.
- `enabled_builtin_tools(cfg)` is the one list the router, toolSearchTool and the executor use, so
  a turned-off tool is neither offered nor run, also when the model names it.
- The v2 brain never offers v1's `localFiles` (home folder read/write/delete) and `screenshot`:
  anyone in the voice or chat channels could ask for them. Screen viewing comes in M7.
- The brain connects MCP servers on its own thread and logs each outcome without debug logging.
- Stored secrets are masked in the log hub as soon as the data folder is found.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-13 09:56:17 +09:00
parent d4bd4acfe9
commit 3ef4281180
23 changed files with 717 additions and 39 deletions

View File

@@ -121,6 +121,8 @@ function editor(f, value) {
break;
case "chatChannels":
return chatChannelsEditor(f, value);
case "mcpServers":
return mcpServersEditor(f, value);
default:
el = h("span", { class: "muted" }, JSON.stringify(value));
read = () => value;
@@ -181,6 +183,66 @@ function chatChannelsEditor(f, value) {
return { el: h("div", {}, table, h("button", { class: "btn", onclick: () => addRow() }, "채널 추가")), read, wide: true };
}
// One card per MCP server. Environment values (API keys) are secrets: they are typed here and stored
// encrypted by the app on their own (mcp_env_set), and only "stored" or not ever comes back.
function mcpServersEditor(f, value) {
const list = h("div");
const saved = new Set((value || []).map((s) => s.name));
let status = {};
const addServer = (s = {}) => {
const name = h("input", { type: "text", value: s.name ?? "", placeholder: "이름 (영문, 숫자, - _)", "data-k": "name" });
const command = h("input", { type: "text", value: s.command ?? "", placeholder: "명령 (예: npx, uvx)", "data-k": "command" });
const args = h("textarea", { placeholder: "인자, 한 줄에 하나", "data-k": "args" }, (s.args || []).join("\n"));
const env = h("textarea", { placeholder: "환경 변수 이름, 한 줄에 하나 (예: BRAVE_API_KEY)", "data-k": "env" }, (s.env || []).join("\n"));
const enabled = h("input", { type: "checkbox", class: "switch", "data-k": "enabled" });
enabled.checked = s.enabled ?? true;
const values = h("div", { class: "small" });
const fillValues = () => {
values.replaceChildren();
if (!saved.has(s.name)) {
if ((s.env || []).length || env.value.trim()) values.append(h("div", { class: "muted" }, "환경 변수 값은 서버를 저장한 뒤 넣을 수 있습니다."));
return;
}
for (const v of s.env || []) {
const box = h("input", { type: "password", placeholder: status[s.name]?.[v] ? "저장됨 (바꾸려면 입력)" : "값 없음", autocomplete: "off" });
const put = async (val) => {
try {
const r = await api("mcp_env_set", { server: s.name, name: v, value: val });
status[s.name] = { ...(status[s.name] || {}), [v]: r.set };
box.value = "";
fillValues();
toast(r.restartNeeded ? "저장했습니다. 다시 시작하면 적용됩니다." : "저장했습니다.");
} catch (e) { fail(e); }
};
values.append(h("div", { class: "field" }, h("label", {}, v), box,
h("button", { class: "btn", onclick: () => box.value.trim() ? put(box.value) : toast("값을 입력해 주세요", true) }, "값 저장"),
status[s.name]?.[v] ? h("button", { class: "btn", onclick: () => put("") }, "값 지우기") : null));
}
};
const card = h("div", { class: "card mcp" },
h("div", { class: "field" }, h("label", {}, "이름"), name),
h("div", { class: "field" }, h("label", {}, "명령"), command),
h("div", { class: "field" }, h("label", {}, "인자"), args),
h("div", { class: "field" }, h("label", {}, "환경 변수"), env),
h("div", { class: "field" }, h("label", {}, "켜기"), enabled),
values,
h("button", { class: "btn", onclick: () => card.remove() }, "서버 삭제"));
card.fillValues = fillValues;
list.append(card);
fillValues();
};
(value || []).forEach(addServer);
api("mcp_env_status").then((st) => { status = st; for (const c of list.children) c.fillValues(); }).catch(() => {});
const lines = (t) => t.split("\n").map((x) => x.trim()).filter(Boolean);
const read = () => [...list.children].map((card) => {
const k = (key) => card.querySelector(`[data-k="${key}"]`);
return { name: k("name").value.trim(), command: k("command").value.trim(), args: lines(k("args").value),
env: lines(k("env").value), enabled: k("enabled").checked };
});
return { el: h("div", {}, h("div", { class: "hint" }, "MCP 서버는 이 PC에서 프로그램으로 실행됩니다. 믿을 수 있는 서버만 추가해 주세요."),
list, h("button", { class: "btn", onclick: () => addServer() }, "서버 추가")), read, wide: true };
}
async function settingsScreen(screen, title, extra) {
const [all, view] = await Promise.all([fields(), api("settings_view")]);
const list = all.filter((f) => f.screen === screen);
@@ -205,6 +267,7 @@ async function settingsScreen(screen, title, extra) {
return;
}
toast(r.restartNeeded ? "저장했습니다. 다시 시작하면 적용됩니다." : "저장했습니다.");
if (changes.mcpServers) show(current); // the saved servers' value inputs
} catch (e) { fail(e); }
};
const view_ = h("div", {}, h("h1", {}, title), extra,
@@ -413,7 +476,7 @@ async function show(name) {
try {
if (name === "dashboard") { screen.replaceChildren(); await refresh(); ticker = setInterval(refresh, 1000); return; }
if (name === "logs") { const l = logsScreen(); screen.replaceChildren(l.view); ticker = setInterval(l.tick, 1000); return; }
const titles = { bot: "봇", channels: "채널·호출", chat: "채팅 채널", memory: "대화 기억", model: "모델" };
const titles = { bot: "봇", channels: "채널·호출", chat: "채팅 채널", memory: "대화 기억", model: "모델", features: "기능" };
const extra = name === "bot" ? await tokenCard() : null;
const view = await settingsScreen(name, titles[name], extra);
if (my === gen) screen.replaceChildren(view);

View File

@@ -17,6 +17,7 @@
<button data-screen="chat" class="nav">채팅 채널</button>
<button data-screen="memory" class="nav">대화 기억</button>
<button data-screen="model" class="nav">모델</button>
<button data-screen="features" class="nav">기능</button>
<button data-screen="logs" class="nav">로그</button>
<div class="side-foot" id="version"></div>
</nav>