Files
Netcatty/electron/capabilities/catalog/vault.cjs
T
陈大猫andCursor 9aed2c41d4 feat(ai): unify capability registry, harness tools, and agent runtime (#1685)
* feat(ai): unify capability registry, harness tools, and agent runtime

Centralize MCP/CLI/Catty tool surfaces in the capability catalog with codegen,
move Catty-only harness tools into catalog with local execution, converge
mcpServerBridge builtin dispatch via registry, and wire AgentRuntime with
vault bridge, permission grants, and Round 2 catalog parity.

Co-authored-by: Cursor <cursoragent@cursor.com>

* feat(ai): vault host tools, artifact cards, and external agent vault guidance

Unify vault host create/import with capability RPC routing, add chat artifact cards with Vault navigation, and align external MCP agents with Catty rules so host creation never falls back to Vault Notes.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(ai): address Bugbot findings for streaming, vault bridge, and grants

Clear Catty streaming by chat sessionId, read latest vault state via getters on agent mutations, and stack grant persisters so unmounting one AI panel does not break others.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(vault): clear pending openNoteId after chat navigation focus

NotesManager notifies VaultView once the one-shot openNoteId request is applied so the id does not stick for the rest of the session.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(vault): serialize vault agent IPC mutations to prevent lost writes

Queue vault agent bridge handlers so concurrent hosts.create or note.create tool calls cannot overwrite each other via stale read-modify-write snapshots.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(vault): keep synchronous vault snapshot for agent IPC reads

Mirror hosts, notes, and groups in a ref updated immediately on agent writes so serialized mutations see the latest state before React re-renders.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(ai): sync Catty MCP sessions and defer runtime cleanup on delete

Register terminal sessions with the main process before Catty tool calls, and clear ToolOutputStore only after stopping an active turn when deleting a chat session.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(ai): avoid deleting a newer abort controller on late stop

Only remove the session abort-controller entry when stop finishes if it still refers to the controller that was stopped.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(ai): sync vault snapshot on render and await active turn on stop

Refresh vault agent reads when React props change without clobbering in-flight agent writes, and wait for runTurn to finish before clearing ToolOutputStore on session delete.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(ai): reload permission grants from storage before auto-approve

Re-read persisted grant rules on each approval check so revocations in Settings take effect without requiring a chat hook remount.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(ai): sync permission grants to main process immediately on write

Push MCP permissionGrantsSnapshot as soon as Always allow persists a rule so the next tool call in the same agent turn sees the grant without waiting for useEffect.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 00:08:39 +08:00

263 lines
8.0 KiB
JavaScript

"use strict";
const { CAPABILITY_STATUS } = require("../constants.cjs");
/** @type {import("../types.cjs").CapabilityDefinition[]} */
const VAULT_CAPABILITIES = [
{
id: "vault.host.get",
domain: "vault",
status: CAPABILITY_STATUS.IMPLEMENTED,
description: "Get host metadata from the vault.",
policy: {
write: false,
sensitiveRead: true,
longRunning: false,
requiresChatSession: false,
bypassesObserverBlock: false,
bypassesApproval: true,
bypassesChatCancel: true,
},
surfaces: {
cli: { command: ["vault", "host", "get"] },
global: { rpcMethod: "vault/host/get" },
public: { rpcMethod: "public/vault/host/get", mcpTool: "host_get" },
},
},
{
id: "vault.host.list",
domain: "vault",
status: CAPABILITY_STATUS.IMPLEMENTED,
description: "List saved hosts in the vault (metadata only — no passwords or keys).",
policy: {
write: false,
sensitiveRead: true,
longRunning: false,
requiresChatSession: false,
bypassesObserverBlock: false,
bypassesApproval: true,
bypassesChatCancel: true,
},
surfaces: {
global: { rpcMethod: "vault/hosts/list" },
public: { rpcMethod: "public/vault/hosts/list", mcpTool: "vault_hosts_list" },
},
},
{
id: "vault.hosts.create",
domain: "vault",
status: CAPABILITY_STATUS.IMPLEMENTED,
description: "Create vault hosts from structured host objects. Use when the user wants to add/create a host (Vault → Hosts). NOT for Vault → Notes sidebar documentation.",
policy: {
write: true,
sensitiveRead: false,
longRunning: false,
requiresChatSession: false,
bypassesObserverBlock: false,
bypassesApproval: false,
bypassesChatCancel: false,
},
surfaces: {
global: { rpcMethod: "vault/hosts/create" },
public: { rpcMethod: "public/vault/hosts/create", mcpTool: "vault_hosts_create" },
},
},
{
id: "vault.host.import",
domain: "vault",
status: CAPABILITY_STATUS.IMPLEMENTED,
description: "Parse known host export file formats (PuTTY, MobaXterm, CSV, SecureCRT, ssh_config) into vault hosts. For arbitrary unstructured text, map to host objects and use vault_hosts_create instead.",
policy: {
write: true,
sensitiveRead: false,
longRunning: false,
requiresChatSession: false,
bypassesObserverBlock: false,
bypassesApproval: false,
bypassesChatCancel: false,
},
surfaces: {
global: { rpcMethod: "vault/hosts/import" },
public: { rpcMethod: "public/vault/hosts/import", mcpTool: "vault_hosts_import" },
},
},
{
id: "vault.host.notes.get",
domain: "vault",
status: CAPABILITY_STATUS.IMPLEMENTED,
description: "Read host metadata notes attached to a saved host (Host Details panel — not Vault sidebar Notes).",
policy: {
write: false,
sensitiveRead: true,
longRunning: false,
requiresChatSession: false,
bypassesObserverBlock: false,
bypassesApproval: true,
bypassesChatCancel: true,
},
surfaces: {
cli: { command: ["vault", "host-notes", "get"] },
global: { rpcMethod: "vault/host/notes/get" },
public: { rpcMethod: "public/vault/hostNotes/get", mcpTool: "host_notes_get" },
},
},
{
id: "vault.host.notes.set",
domain: "vault",
status: CAPABILITY_STATUS.IMPLEMENTED,
description: "Update host metadata notes on a saved host (Host Details panel — not Vault sidebar Notes).",
policy: {
write: true,
sensitiveRead: false,
longRunning: false,
requiresChatSession: false,
bypassesObserverBlock: false,
bypassesApproval: false,
bypassesChatCancel: false,
},
surfaces: {
cli: { command: ["vault", "host-notes", "set"] },
global: { rpcMethod: "vault/host/notes/set" },
public: { rpcMethod: "public/vault/hostNotes/set", mcpTool: "host_notes_set" },
},
},
{
id: "vault.note.list",
domain: "vault",
status: CAPABILITY_STATUS.IMPLEMENTED,
description: "List notes in Vault → Notes (markdown notes visible in the vault sidebar).",
policy: {
write: false,
sensitiveRead: false,
longRunning: false,
requiresChatSession: false,
bypassesObserverBlock: false,
bypassesApproval: true,
bypassesChatCancel: true,
},
surfaces: {
global: { rpcMethod: "vault/notes/list" },
public: { rpcMethod: "public/vault/notes/list", mcpTool: "vault_notes_list" },
},
},
{
id: "vault.note.get",
domain: "vault",
status: CAPABILITY_STATUS.IMPLEMENTED,
description: "Get a Vault → Notes entry by id (full markdown content).",
policy: {
write: false,
sensitiveRead: false,
longRunning: false,
requiresChatSession: false,
bypassesObserverBlock: false,
bypassesApproval: true,
bypassesChatCancel: true,
},
surfaces: {
global: { rpcMethod: "vault/notes/get" },
public: { rpcMethod: "public/vault/notes/get", mcpTool: "vault_notes_get" },
},
},
{
id: "vault.note.create",
domain: "vault",
status: CAPABILITY_STATUS.IMPLEMENTED,
description: "Create a note in Vault → Notes sidebar (markdown documentation). NOT for adding SSH hosts — use vault_hosts_create for that.",
policy: {
write: true,
sensitiveRead: false,
longRunning: false,
requiresChatSession: false,
bypassesObserverBlock: false,
bypassesApproval: false,
bypassesChatCancel: false,
},
surfaces: {
global: { rpcMethod: "vault/notes/create" },
public: { rpcMethod: "public/vault/notes/create", mcpTool: "vault_notes_create" },
},
},
{
id: "vault.note.update",
domain: "vault",
status: CAPABILITY_STATUS.IMPLEMENTED,
description: "Update an existing Vault → Notes entry by id.",
policy: {
write: true,
sensitiveRead: false,
longRunning: false,
requiresChatSession: false,
bypassesObserverBlock: false,
bypassesApproval: false,
bypassesChatCancel: false,
},
surfaces: {
global: { rpcMethod: "vault/notes/update" },
public: { rpcMethod: "public/vault/notes/update", mcpTool: "vault_notes_update" },
},
},
{
id: "vault.snippets.list",
domain: "vault",
status: CAPABILITY_STATUS.IMPLEMENTED,
description: "List code snippets stored in the vault.",
policy: {
write: false,
sensitiveRead: false,
longRunning: false,
requiresChatSession: false,
bypassesObserverBlock: false,
bypassesApproval: true,
bypassesChatCancel: true,
},
surfaces: {
cli: { command: ["snippets", "list"] },
global: { rpcMethod: "vault/snippets/list" },
public: { rpcMethod: "public/vault/snippets/list", mcpTool: "snippets_list" },
},
},
{
id: "vault.snippets.get",
domain: "vault",
status: CAPABILITY_STATUS.IMPLEMENTED,
description: "Get a single code snippet from the vault.",
policy: {
write: false,
sensitiveRead: false,
longRunning: false,
requiresChatSession: false,
bypassesObserverBlock: false,
bypassesApproval: true,
bypassesChatCancel: true,
},
surfaces: {
cli: { command: ["snippets", "get"] },
global: { rpcMethod: "vault/snippets/get" },
public: { rpcMethod: "public/vault/snippets/get", mcpTool: "snippets_get" },
},
},
{
id: "vault.snippets.run",
domain: "vault",
status: CAPABILITY_STATUS.IMPLEMENTED,
description: "Resolve snippet variables and execute a snippet in a terminal session.",
policy: {
write: true,
sensitiveRead: false,
longRunning: true,
requiresChatSession: true,
bypassesObserverBlock: false,
bypassesApproval: false,
bypassesChatCancel: false,
},
surfaces: {
cli: { command: ["snippets", "run"] },
global: { rpcMethod: "vault/snippets/run" },
public: { rpcMethod: "public/vault/snippets/run", mcpTool: "snippets_run" },
},
},
];
module.exports = { VAULT_CAPABILITIES };