codeep 1.3.42 → 2.0.1

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.
Files changed (60) hide show
  1. package/README.md +208 -0
  2. package/dist/acp/commands.js +770 -7
  3. package/dist/acp/protocol.d.ts +11 -2
  4. package/dist/acp/server.js +179 -11
  5. package/dist/acp/session.d.ts +3 -0
  6. package/dist/acp/session.js +5 -0
  7. package/dist/api/index.js +39 -6
  8. package/dist/config/index.d.ts +13 -0
  9. package/dist/config/index.js +45 -0
  10. package/dist/config/providers.js +76 -1
  11. package/dist/renderer/App.d.ts +12 -0
  12. package/dist/renderer/App.js +109 -4
  13. package/dist/renderer/agentExecution.js +5 -0
  14. package/dist/renderer/commands.js +638 -2
  15. package/dist/renderer/components/Help.js +28 -0
  16. package/dist/renderer/components/Login.d.ts +1 -0
  17. package/dist/renderer/components/Login.js +24 -9
  18. package/dist/renderer/handlers.d.ts +11 -1
  19. package/dist/renderer/handlers.js +30 -0
  20. package/dist/renderer/main.js +73 -0
  21. package/dist/utils/agent.d.ts +17 -0
  22. package/dist/utils/agent.js +91 -7
  23. package/dist/utils/agentChat.d.ts +10 -2
  24. package/dist/utils/agentChat.js +48 -9
  25. package/dist/utils/agentStream.js +6 -2
  26. package/dist/utils/checkpoints.d.ts +93 -0
  27. package/dist/utils/checkpoints.js +205 -0
  28. package/dist/utils/context.d.ts +24 -0
  29. package/dist/utils/context.js +57 -0
  30. package/dist/utils/customCommands.d.ts +62 -0
  31. package/dist/utils/customCommands.js +201 -0
  32. package/dist/utils/hooks.d.ts +97 -0
  33. package/dist/utils/hooks.js +223 -0
  34. package/dist/utils/mcpClient.d.ts +229 -0
  35. package/dist/utils/mcpClient.js +497 -0
  36. package/dist/utils/mcpConfig.d.ts +55 -0
  37. package/dist/utils/mcpConfig.js +177 -0
  38. package/dist/utils/mcpMarketplace.d.ts +49 -0
  39. package/dist/utils/mcpMarketplace.js +175 -0
  40. package/dist/utils/mcpRegistry.d.ts +129 -0
  41. package/dist/utils/mcpRegistry.js +427 -0
  42. package/dist/utils/mcpSamplingBridge.d.ts +32 -0
  43. package/dist/utils/mcpSamplingBridge.js +88 -0
  44. package/dist/utils/mcpStreamableHttp.d.ts +65 -0
  45. package/dist/utils/mcpStreamableHttp.js +207 -0
  46. package/dist/utils/openrouterPrefs.d.ts +36 -0
  47. package/dist/utils/openrouterPrefs.js +83 -0
  48. package/dist/utils/skillBundles.d.ts +84 -0
  49. package/dist/utils/skillBundles.js +257 -0
  50. package/dist/utils/skillBundlesCloud.d.ts +69 -0
  51. package/dist/utils/skillBundlesCloud.js +202 -0
  52. package/dist/utils/tokenTracker.d.ts +14 -2
  53. package/dist/utils/tokenTracker.js +59 -41
  54. package/dist/utils/toolExecution.d.ts +17 -1
  55. package/dist/utils/toolExecution.js +184 -6
  56. package/dist/utils/tools.d.ts +22 -6
  57. package/dist/utils/tools.js +83 -8
  58. package/package.json +3 -2
  59. package/bin/codeep-macos-arm64 +0 -0
  60. package/bin/codeep-macos-x64 +0 -0
@@ -0,0 +1,177 @@
1
+ /**
2
+ * On-disk MCP server config — the `mcpServers` array that ACP clients
3
+ * usually pass over the wire, but loaded straight from JSON so direct CLI
4
+ * users (and our VS Code extension) don't have to roll their own config UI.
5
+ *
6
+ * Lookup precedence:
7
+ * 1. `<workspace>/.codeep/mcp_servers.json` (project — committed with repo)
8
+ * 2. `~/.codeep/mcp_servers.json` (global — user's machine)
9
+ * Project entries shadow global entries with the same server name.
10
+ *
11
+ * File format mirrors what Claude Code accepts so existing user configs can
12
+ * be reused verbatim:
13
+ *
14
+ * {
15
+ * "mcpServers": {
16
+ * "fs": {
17
+ * "command": "npx",
18
+ * "args": ["@modelcontextprotocol/server-filesystem", "/some/path"],
19
+ * "env": { "READ_ONLY": "1" }
20
+ * },
21
+ * "gh": { ... }
22
+ * }
23
+ * }
24
+ *
25
+ * A flat array form (`{"mcpServers": [{...}, ...]}`) is also accepted because
26
+ * that's the shape ACP passes over JSON-RPC.
27
+ */
28
+ import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'fs';
29
+ import { join, dirname } from 'path';
30
+ import { homedir } from 'os';
31
+ const PROJECT_CONFIG_PATH = '.codeep/mcp_servers.json';
32
+ const GLOBAL_CONFIG_PATH = '.codeep/mcp_servers.json';
33
+ function parseEntries(raw, source) {
34
+ let parsed;
35
+ try {
36
+ parsed = JSON.parse(raw);
37
+ }
38
+ catch {
39
+ // A broken config file shouldn't kill the agent startup — just warn
40
+ // and move on. The user will notice via /mcp showing no servers.
41
+ process.stderr.write(`[codeep-mcp] Failed to parse ${source}: invalid JSON\n`);
42
+ return [];
43
+ }
44
+ const servers = parsed.mcpServers;
45
+ if (!servers)
46
+ return [];
47
+ if (Array.isArray(servers)) {
48
+ // Defensively filter — any entry needs name + either command or url.
49
+ return servers.filter(s => s && typeof s.name === 'string' && (typeof s.command === 'string' || typeof s.url === 'string'));
50
+ }
51
+ return Object.entries(servers).flatMap(([name, cfg]) => {
52
+ if (!cfg)
53
+ return [];
54
+ // Either `command` (stdio) or `url` (HTTP) — at least one required.
55
+ const hasStdio = typeof cfg.command === 'string';
56
+ const hasHttp = typeof cfg.url === 'string';
57
+ if (!hasStdio && !hasHttp)
58
+ return [];
59
+ return [{
60
+ name,
61
+ command: hasStdio ? cfg.command : undefined,
62
+ args: Array.isArray(cfg.args) ? cfg.args.filter(a => typeof a === 'string') : [],
63
+ env: cfg.env && typeof cfg.env === 'object' ? cfg.env : undefined,
64
+ url: hasHttp ? cfg.url : undefined,
65
+ headers: cfg.headers && typeof cfg.headers === 'object'
66
+ ? cfg.headers
67
+ : undefined,
68
+ }];
69
+ });
70
+ }
71
+ function loadFromFile(path) {
72
+ if (!existsSync(path))
73
+ return [];
74
+ try {
75
+ const raw = readFileSync(path, 'utf-8');
76
+ return parseEntries(raw, path);
77
+ }
78
+ catch {
79
+ return [];
80
+ }
81
+ }
82
+ /**
83
+ * Load MCP server definitions for a workspace. Project entries shadow
84
+ * global entries with the same server name. Workspace-less calls
85
+ * (TUI without project) return only the global config.
86
+ */
87
+ export function loadMcpServerConfig(workspaceRoot) {
88
+ const globalServers = loadFromFile(join(homedir(), GLOBAL_CONFIG_PATH));
89
+ const projectServers = workspaceRoot
90
+ ? loadFromFile(join(workspaceRoot, PROJECT_CONFIG_PATH))
91
+ : [];
92
+ // Project wins on name collisions.
93
+ const byName = new Map();
94
+ for (const s of globalServers)
95
+ byName.set(s.name, s);
96
+ for (const s of projectServers)
97
+ byName.set(s.name, s);
98
+ return [...byName.values()];
99
+ }
100
+ /**
101
+ * Merge two server lists: ACP-provided + on-disk. ACP wins on collisions
102
+ * — the client knows its own config, so a Zed-passed server overrides a
103
+ * project file entry of the same name (and we never have to teach Zed to
104
+ * "skip" file-based ones).
105
+ */
106
+ export function mergeMcpServers(fromConfig, fromAcp) {
107
+ const byName = new Map();
108
+ for (const s of fromConfig)
109
+ byName.set(s.name, s);
110
+ for (const s of fromAcp ?? [])
111
+ byName.set(s.name, s);
112
+ return [...byName.values()];
113
+ }
114
+ /**
115
+ * Add or replace a server entry in the project config file. Used by the
116
+ * interactive `/mcp add` command. Project file is created if missing.
117
+ */
118
+ export function addProjectMcpServer(workspaceRoot, server) {
119
+ const path = join(workspaceRoot, PROJECT_CONFIG_PATH);
120
+ let parsed = { mcpServers: {} };
121
+ if (existsSync(path)) {
122
+ try {
123
+ parsed = JSON.parse(readFileSync(path, 'utf-8'));
124
+ }
125
+ catch {
126
+ // Overwrite a broken file — user can recover from git if they care.
127
+ parsed = { mcpServers: {} };
128
+ }
129
+ }
130
+ // Normalize to map form for the on-disk file. Easier to edit by hand.
131
+ let map;
132
+ if (Array.isArray(parsed.mcpServers)) {
133
+ map = {};
134
+ for (const s of parsed.mcpServers) {
135
+ const { name: n, ...rest } = s;
136
+ map[n] = rest;
137
+ }
138
+ }
139
+ else {
140
+ map = parsed.mcpServers ?? {};
141
+ }
142
+ const { name, ...rest } = server;
143
+ map[name] = rest;
144
+ parsed.mcpServers = map;
145
+ mkdirSync(dirname(path), { recursive: true });
146
+ writeFileSync(path, JSON.stringify(parsed, null, 2) + '\n');
147
+ }
148
+ /**
149
+ * Remove a server entry from the project config file. Returns true if a
150
+ * server with that name was actually removed.
151
+ */
152
+ export function removeProjectMcpServer(workspaceRoot, name) {
153
+ const path = join(workspaceRoot, PROJECT_CONFIG_PATH);
154
+ if (!existsSync(path))
155
+ return false;
156
+ let parsed;
157
+ try {
158
+ parsed = JSON.parse(readFileSync(path, 'utf-8'));
159
+ }
160
+ catch {
161
+ return false;
162
+ }
163
+ if (Array.isArray(parsed.mcpServers)) {
164
+ const before = parsed.mcpServers.length;
165
+ parsed.mcpServers = parsed.mcpServers.filter(s => s.name !== name);
166
+ if (parsed.mcpServers.length === before)
167
+ return false;
168
+ }
169
+ else if (parsed.mcpServers && parsed.mcpServers[name]) {
170
+ delete parsed.mcpServers[name];
171
+ }
172
+ else {
173
+ return false;
174
+ }
175
+ writeFileSync(path, JSON.stringify(parsed, null, 2) + '\n');
176
+ return true;
177
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Curated catalog of popular MCP servers. Lets users discover and install
3
+ * server entries via `/mcp browse` and `/mcp install <id>` without having
4
+ * to know the right `command` / `args` incantation.
5
+ *
6
+ * Maintenance:
7
+ * - Keep this list short (< 30 entries). The point is curation, not
8
+ * completeness — anything more exhaustive belongs on the website.
9
+ * - Each entry's `args` should be the **invocation-without-runtime-args**
10
+ * so `/mcp install` can prompt for the things that vary per user
11
+ * (paths, tokens, etc.) via `argHints`.
12
+ * - Prefer official `@modelcontextprotocol/*` packages over third-party.
13
+ */
14
+ import type { McpServer } from '../acp/protocol.js';
15
+ export interface MarketplaceEntry {
16
+ /** Short id used by `/mcp install <id>` and shown in the catalog. */
17
+ id: string;
18
+ /** Human-readable display name. */
19
+ name: string;
20
+ /** One-line description shown in the marketplace listing. */
21
+ description: string;
22
+ /** Skeleton server config. `args` includes the package name; users
23
+ * may need to add path/argument args via `argHints`. */
24
+ server: Omit<McpServer, 'name'>;
25
+ /** Per-arg prompts shown by `/mcp install` so the user supplies the
26
+ * variable bits (file paths, db URLs, etc.). */
27
+ argHints?: {
28
+ description: string;
29
+ placeholder?: string;
30
+ required?: boolean;
31
+ }[];
32
+ /** Env vars that should be set (e.g. API tokens). Surfaced as a note. */
33
+ envNotes?: {
34
+ name: string;
35
+ description: string;
36
+ required?: boolean;
37
+ }[];
38
+ /** Homepage / docs URL for the curious. */
39
+ url?: string;
40
+ }
41
+ export declare const MCP_MARKETPLACE: MarketplaceEntry[];
42
+ export declare function findMarketplaceEntry(id: string): MarketplaceEntry | null;
43
+ /**
44
+ * Render the catalog as Markdown for `/mcp browse`. Compact: id + name +
45
+ * one-line description. Full details (env vars, args) on `/mcp install`.
46
+ */
47
+ export declare function formatMarketplaceList(): string;
48
+ /** Render install instructions for a single entry (without writing config). */
49
+ export declare function formatMarketplaceEntry(entry: MarketplaceEntry): string;
@@ -0,0 +1,175 @@
1
+ /**
2
+ * Curated catalog of popular MCP servers. Lets users discover and install
3
+ * server entries via `/mcp browse` and `/mcp install <id>` without having
4
+ * to know the right `command` / `args` incantation.
5
+ *
6
+ * Maintenance:
7
+ * - Keep this list short (< 30 entries). The point is curation, not
8
+ * completeness — anything more exhaustive belongs on the website.
9
+ * - Each entry's `args` should be the **invocation-without-runtime-args**
10
+ * so `/mcp install` can prompt for the things that vary per user
11
+ * (paths, tokens, etc.) via `argHints`.
12
+ * - Prefer official `@modelcontextprotocol/*` packages over third-party.
13
+ */
14
+ export const MCP_MARKETPLACE = [
15
+ {
16
+ id: 'filesystem',
17
+ name: 'Filesystem',
18
+ description: 'Read, list, and (optionally) write files in a sandbox directory.',
19
+ server: { command: 'npx', args: ['-y', '@modelcontextprotocol/server-filesystem'] },
20
+ argHints: [
21
+ { description: 'Absolute path to expose to the agent (one or more — pass several to allow several roots).', placeholder: '/Users/you/projects/notes', required: true },
22
+ ],
23
+ url: 'https://github.com/modelcontextprotocol/servers/tree/main/src/filesystem',
24
+ },
25
+ {
26
+ id: 'github',
27
+ name: 'GitHub',
28
+ description: 'Browse repositories, issues, PRs, and commits via the GitHub API.',
29
+ server: { command: 'npx', args: ['-y', '@modelcontextprotocol/server-github'] },
30
+ envNotes: [
31
+ { name: 'GITHUB_PERSONAL_ACCESS_TOKEN', description: 'Token with the `repo` scope (or `public_repo` if you only need public).', required: true },
32
+ ],
33
+ url: 'https://github.com/modelcontextprotocol/servers/tree/main/src/github',
34
+ },
35
+ {
36
+ id: 'gitlab',
37
+ name: 'GitLab',
38
+ description: 'Read repos, issues, MRs, and pipelines on GitLab (cloud or self-hosted).',
39
+ server: { command: 'npx', args: ['-y', '@modelcontextprotocol/server-gitlab'] },
40
+ envNotes: [
41
+ { name: 'GITLAB_PERSONAL_ACCESS_TOKEN', description: 'Token with `read_api` scope.', required: true },
42
+ { name: 'GITLAB_API_URL', description: 'Override for self-hosted GitLab (default: https://gitlab.com/api/v4).' },
43
+ ],
44
+ url: 'https://github.com/modelcontextprotocol/servers/tree/main/src/gitlab',
45
+ },
46
+ {
47
+ id: 'git',
48
+ name: 'Git (local repo)',
49
+ description: 'Inspect commits, blame, diffs, branches in a local git repository.',
50
+ server: { command: 'uvx', args: ['mcp-server-git'] },
51
+ argHints: [
52
+ { description: 'Path to a git repository (omit to use the current workspace).', placeholder: '/path/to/repo' },
53
+ ],
54
+ url: 'https://github.com/modelcontextprotocol/servers/tree/main/src/git',
55
+ },
56
+ {
57
+ id: 'postgres',
58
+ name: 'PostgreSQL',
59
+ description: 'Read-only SQL access to a Postgres database — schema introspection + query.',
60
+ server: { command: 'npx', args: ['-y', '@modelcontextprotocol/server-postgres'] },
61
+ argHints: [
62
+ { description: 'Postgres connection URI.', placeholder: 'postgresql://user:pass@localhost/dbname', required: true },
63
+ ],
64
+ url: 'https://github.com/modelcontextprotocol/servers/tree/main/src/postgres',
65
+ },
66
+ {
67
+ id: 'sqlite',
68
+ name: 'SQLite',
69
+ description: 'Query a SQLite database file with full SQL.',
70
+ server: { command: 'uvx', args: ['mcp-server-sqlite'] },
71
+ argHints: [
72
+ { description: 'Path to the .sqlite/.db file.', placeholder: '/path/to/data.db', required: true },
73
+ ],
74
+ url: 'https://github.com/modelcontextprotocol/servers/tree/main/src/sqlite',
75
+ },
76
+ {
77
+ id: 'fetch',
78
+ name: 'Fetch (web)',
79
+ description: 'Fetch arbitrary URLs and return the markdown-converted contents.',
80
+ server: { command: 'uvx', args: ['mcp-server-fetch'] },
81
+ url: 'https://github.com/modelcontextprotocol/servers/tree/main/src/fetch',
82
+ },
83
+ {
84
+ id: 'brave-search',
85
+ name: 'Brave Search',
86
+ description: 'Web search via the Brave Search API.',
87
+ server: { command: 'npx', args: ['-y', '@modelcontextprotocol/server-brave-search'] },
88
+ envNotes: [
89
+ { name: 'BRAVE_API_KEY', description: 'Get a free key at brave.com/search/api/.', required: true },
90
+ ],
91
+ url: 'https://github.com/modelcontextprotocol/servers/tree/main/src/brave-search',
92
+ },
93
+ {
94
+ id: 'slack',
95
+ name: 'Slack',
96
+ description: 'Read channels, post messages, look up users and threads.',
97
+ server: { command: 'npx', args: ['-y', '@modelcontextprotocol/server-slack'] },
98
+ envNotes: [
99
+ { name: 'SLACK_BOT_TOKEN', description: 'xoxb-… bot token.', required: true },
100
+ { name: 'SLACK_TEAM_ID', description: 'Numeric workspace id.', required: true },
101
+ ],
102
+ url: 'https://github.com/modelcontextprotocol/servers/tree/main/src/slack',
103
+ },
104
+ {
105
+ id: 'memory',
106
+ name: 'Memory (knowledge graph)',
107
+ description: 'Persistent knowledge graph the agent reads/writes across sessions.',
108
+ server: { command: 'npx', args: ['-y', '@modelcontextprotocol/server-memory'] },
109
+ url: 'https://github.com/modelcontextprotocol/servers/tree/main/src/memory',
110
+ },
111
+ {
112
+ id: 'time',
113
+ name: 'Time / timezones',
114
+ description: 'Current time, timezone conversion, IANA timezone lookup.',
115
+ server: { command: 'uvx', args: ['mcp-server-time'] },
116
+ url: 'https://github.com/modelcontextprotocol/servers/tree/main/src/time',
117
+ },
118
+ {
119
+ id: 'puppeteer',
120
+ name: 'Puppeteer (browser)',
121
+ description: 'Headless Chromium for navigating, screenshotting, and scraping pages.',
122
+ server: { command: 'npx', args: ['-y', '@modelcontextprotocol/server-puppeteer'] },
123
+ url: 'https://github.com/modelcontextprotocol/servers/tree/main/src/puppeteer',
124
+ },
125
+ ];
126
+ export function findMarketplaceEntry(id) {
127
+ const lower = id.toLowerCase();
128
+ return MCP_MARKETPLACE.find(e => e.id === lower) ?? null;
129
+ }
130
+ /**
131
+ * Render the catalog as Markdown for `/mcp browse`. Compact: id + name +
132
+ * one-line description. Full details (env vars, args) on `/mcp install`.
133
+ */
134
+ export function formatMarketplaceList() {
135
+ const lines = [
136
+ '## MCP marketplace',
137
+ '',
138
+ `${MCP_MARKETPLACE.length} curated servers. Install with \`/mcp install <id>\`.`,
139
+ '',
140
+ '| id | name | what it does |',
141
+ '|---|---|---|',
142
+ ];
143
+ for (const e of MCP_MARKETPLACE) {
144
+ lines.push(`| \`${e.id}\` | ${e.name} | ${e.description} |`);
145
+ }
146
+ return lines.join('\n');
147
+ }
148
+ /** Render install instructions for a single entry (without writing config). */
149
+ export function formatMarketplaceEntry(entry) {
150
+ const lines = [
151
+ `## ${entry.name} — \`${entry.id}\``,
152
+ '',
153
+ entry.description,
154
+ '',
155
+ `**Command:** \`${entry.server.command ?? entry.server.url} ${(entry.server.args ?? []).join(' ')}\``,
156
+ ];
157
+ if (entry.argHints?.length) {
158
+ lines.push('', '**Additional arguments needed:**');
159
+ for (const h of entry.argHints) {
160
+ const req = h.required ? ' (required)' : '';
161
+ const placeholder = h.placeholder ? ` _e.g._ \`${h.placeholder}\`` : '';
162
+ lines.push(`- ${h.description}${req}${placeholder}`);
163
+ }
164
+ }
165
+ if (entry.envNotes?.length) {
166
+ lines.push('', '**Environment variables:**');
167
+ for (const e of entry.envNotes) {
168
+ const req = e.required ? ' (required)' : '';
169
+ lines.push(`- \`${e.name}\`${req} — ${e.description}`);
170
+ }
171
+ }
172
+ if (entry.url)
173
+ lines.push('', `_Docs: ${entry.url}_`);
174
+ return lines.join('\n');
175
+ }
@@ -0,0 +1,129 @@
1
+ /**
2
+ * Per-session registry of MCP servers.
3
+ *
4
+ * `acp/server.ts handleSessionNew/Load/Resume` receives an optional
5
+ * `mcpServers: McpServer[]` from the ACP client. We spawn each one via
6
+ * `McpClient`, list its tools, and surface them under a flat namespace so
7
+ * the agent can call them like any built-in tool.
8
+ *
9
+ * Naming: tools are surfaced as `<serverName>__<toolName>` to avoid
10
+ * collisions across servers and with built-in agent tools. Underscores are
11
+ * legal in MCP tool names; `__` is rare enough in practice to serve as a
12
+ * delimiter without escaping.
13
+ */
14
+ import { SamplingCreateMessageParams, SamplingCreateMessageResult } from './mcpClient.js';
15
+ import type { McpServer } from '../acp/protocol.js';
16
+ /**
17
+ * Virtual-tool suffixes for the resource/prompt wrappers we generate per
18
+ * server. Keep these in lockstep with the dispatch switch in
19
+ * toolExecution.ts — adding a new wrapper requires both ends.
20
+ */
21
+ export declare const VIRTUAL_TOOL_SUFFIXES: {
22
+ readonly resourceList: "resource_list";
23
+ readonly resourceRead: "resource_read";
24
+ readonly promptList: "prompt_list";
25
+ readonly promptGet: "prompt_get";
26
+ };
27
+ export interface RegisteredTool {
28
+ /** Prefixed name as exposed to the agent (`server__tool`). */
29
+ agentName: string;
30
+ /** Original tool name on the server. */
31
+ toolName: string;
32
+ serverName: string;
33
+ description?: string;
34
+ inputSchema?: Record<string, unknown>;
35
+ }
36
+ /**
37
+ * Spawn the given servers and discover their tools. Failures on individual
38
+ * servers are reported in the result but don't abort the whole registration
39
+ * (one broken server shouldn't kill the rest).
40
+ *
41
+ * Idempotent: calling twice for the same sessionId disposes the prior set
42
+ * first.
43
+ */
44
+ export declare function registerSessionServers(sessionId: string, servers: McpServer[], opts?: {
45
+ workspaceRoot?: string;
46
+ /**
47
+ * Host LLM callback wired to the `sampling/createMessage` server request.
48
+ * Receives the originating server name so the host can rate-limit /
49
+ * budget-cap per server.
50
+ */
51
+ onSamplingRequest?: (params: SamplingCreateMessageParams, serverName: string) => Promise<SamplingCreateMessageResult>;
52
+ }): Promise<{
53
+ registered: RegisteredTool[];
54
+ errors: {
55
+ server: string;
56
+ error: string;
57
+ }[];
58
+ }>;
59
+ /**
60
+ * Wait for any in-flight `registerSessionServers` for this session to
61
+ * finish. No-op once registration has completed. Lets `callSessionTool`
62
+ * be tolerant of the race between session/new returning and the user
63
+ * sending their first prompt.
64
+ */
65
+ export declare function awaitSessionReady(sessionId: string): Promise<void>;
66
+ /** Return spawn errors recorded for a session, for the /mcp inspector. */
67
+ export declare function getSessionRegistrationErrors(sessionId: string): {
68
+ server: string;
69
+ error: string;
70
+ }[];
71
+ /**
72
+ * Atomically read + clear the catalog-dirty flags for a session.
73
+ * Called by the agent loop between iterations: if any flag is set,
74
+ * the relevant cached lists (tools / resources / prompts) should be
75
+ * re-fetched before the next dispatch. Returns the set of dirty kinds.
76
+ */
77
+ export declare function consumeSessionCatalogChanges(sessionId: string): Set<'tools' | 'resources' | 'prompts'>;
78
+ /** Return all tools registered for a session (built from cached server tool lists). */
79
+ export declare function getSessionTools(sessionId: string): Promise<RegisteredTool[]>;
80
+ /**
81
+ * Build the set of virtual tools that wrap the resource/prompt primitives
82
+ * for every server in the session. The agent calls these like normal
83
+ * `<server>__<tool>` entries; toolExecution.ts dispatches them through
84
+ * `callSessionResourceTool` below.
85
+ *
86
+ * We only emit a wrapper when the server actually exposes resources or
87
+ * prompts (probed via `listResources`/`listPrompts`) — no point teaching
88
+ * the model about a `read_resource` tool that always returns "no such
89
+ * resource".
90
+ */
91
+ export declare function getSessionVirtualTools(sessionId: string): Promise<RegisteredTool[]>;
92
+ /**
93
+ * Dispatch a virtual MCP tool (resource_list, resource_read, prompt_list,
94
+ * prompt_get) and return a JSON-serialised string the agent can consume.
95
+ * Throws if the tool name doesn't match a virtual wrapper.
96
+ */
97
+ export declare function callSessionVirtualTool(sessionId: string, agentName: string, args: Record<string, unknown>): Promise<string>;
98
+ /** Return true if a tool name matches one of the four virtual wrappers. */
99
+ export declare function isVirtualMcpToolName(name: string): boolean;
100
+ /** Return resources advertised by all session servers, grouped by server. */
101
+ export declare function getSessionResources(sessionId: string): Promise<{
102
+ serverName: string;
103
+ resources: import('./mcpClient.js').McpResource[];
104
+ }[]>;
105
+ /** Read a resource URI from any session server that advertises it. */
106
+ export declare function readSessionResource(sessionId: string, uri: string): Promise<import('./mcpClient.js').McpResourceContent[]>;
107
+ /** Return prompts advertised by all session servers, grouped by server. */
108
+ export declare function getSessionPrompts(sessionId: string): Promise<{
109
+ serverName: string;
110
+ prompts: import('./mcpClient.js').McpPrompt[];
111
+ }[]>;
112
+ /** Resolve a `<server>__<name>` prompt reference, returning the materialised messages. */
113
+ export declare function getSessionPrompt(sessionId: string, serverName: string, name: string, args?: Record<string, unknown>): Promise<{
114
+ description?: string;
115
+ messages: import('./mcpClient.js').McpPromptMessage[];
116
+ }>;
117
+ /** Forward a tool call to the right MCP server. Returns the tool's text output. */
118
+ export declare function callSessionTool(sessionId: string, agentName: string, args: Record<string, unknown>): Promise<string>;
119
+ /** True when an agent tool name looks like an MCP-prefixed tool. */
120
+ export declare function isMcpToolName(name: string): boolean;
121
+ /** Stop all MCP clients for a session and drop the registry entry. */
122
+ export declare function disposeSession(sessionId: string): Promise<void>;
123
+ /**
124
+ * Tear down every active MCP session. Wired up as a SIGINT/SIGTERM handler
125
+ * in `acp/server.ts` so killing the CLI doesn't leave orphan child processes.
126
+ */
127
+ export declare function disposeAllSessions(): Promise<void>;
128
+ /** For tests / debugging — how many sessions have active MCP clients. */
129
+ export declare function sessionCount(): number;