Files
Netcatty/electron/capabilities/services/vaultService.test.cjs
T
陈大猫 64ff394847 feat(ai): add host_open for MCP agents and polish External MCP setup UI (#2066)
Agents could list vault hosts and run commands on open sessions, but could not
open a host themselves. Add vault.host.open (MCP: host_open) that opens a
terminal tab via the vault agent bridge, merges the new session into MCP scope,
and documents the flow in the Catty system prompt.

Also redesign External MCP client configuration into segmented tabs with
shared copyable code blocks so setup matches the settings design system.
2026-07-09 21:58:20 +08:00

46 lines
1.6 KiB
JavaScript

"use strict";
const test = require("node:test");
const assert = require("node:assert/strict");
const { createVaultService } = require("./vaultService.cjs");
test("vault service delegates host notes read to vault agent bridge", async () => {
let invokedOp = null;
const service = createVaultService({
invokeVaultAgent: async (op, params) => {
invokedOp = op;
return { ok: true, hostId: params.hostId, notes: "hello" };
},
});
const result = await service.getHostNotes({ hostId: "host-1" });
assert.equal(invokedOp, "host.notes.get");
assert.equal(result.ok, true);
assert.equal(result.notes, "hello");
});
test("vault service returns bridge unavailable when renderer bridge missing", async () => {
const service = createVaultService({});
const result = await service.listSnippets();
assert.equal(result.ok, false);
assert.match(result.error, /unavailable/i);
});
test("vault service delegates host open to vault agent bridge", async () => {
let invokedOp = null;
let invokedParams = null;
const service = createVaultService({
invokeVaultAgent: async (op, params) => {
invokedOp = op;
invokedParams = params;
return { ok: true, sessionId: "sess-1", hostId: params.hostId, status: "connecting" };
},
});
const result = await service.openHost({ hostId: "host-1", chatSessionId: "chat-1" });
assert.equal(invokedOp, "host.open");
assert.equal(invokedParams.hostId, "host-1");
assert.equal(invokedParams.chatSessionId, "chat-1");
assert.equal(result.ok, true);
assert.equal(result.sessionId, "sess-1");
});