@x-code-cli/core 0.2.9 → 0.3.0
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/dist/agent/compression.d.ts +12 -2
- package/dist/agent/compression.d.ts.map +1 -1
- package/dist/agent/compression.js +51 -2
- package/dist/agent/compression.js.map +1 -1
- package/dist/agent/file-ingest.js +2 -2
- package/dist/agent/file-ingest.js.map +1 -1
- package/dist/agent/loop-state.d.ts +3 -2
- package/dist/agent/loop-state.d.ts.map +1 -1
- package/dist/agent/loop-state.js.map +1 -1
- package/dist/agent/loop.d.ts.map +1 -1
- package/dist/agent/loop.js +140 -9
- package/dist/agent/loop.js.map +1 -1
- package/dist/agent/memory-extractor.js +5 -5
- package/dist/agent/memory-extractor.js.map +1 -1
- package/dist/agent/plan-storage.js +1 -1
- package/dist/agent/plan-storage.js.map +1 -1
- package/dist/agent/sub-agents/index.d.ts +2 -1
- package/dist/agent/sub-agents/index.d.ts.map +1 -1
- package/dist/agent/sub-agents/index.js +1 -1
- package/dist/agent/sub-agents/index.js.map +1 -1
- package/dist/agent/sub-agents/loader.d.ts +13 -3
- package/dist/agent/sub-agents/loader.d.ts.map +1 -1
- package/dist/agent/sub-agents/loader.js +36 -9
- package/dist/agent/sub-agents/loader.js.map +1 -1
- package/dist/agent/sub-agents/registry.d.ts +18 -1
- package/dist/agent/sub-agents/registry.d.ts.map +1 -1
- package/dist/agent/sub-agents/registry.js +38 -5
- package/dist/agent/sub-agents/registry.js.map +1 -1
- package/dist/agent/sub-agents/runner.d.ts.map +1 -1
- package/dist/agent/sub-agents/runner.js +45 -1
- package/dist/agent/sub-agents/runner.js.map +1 -1
- package/dist/agent/sub-agents/types.d.ts +4 -1
- package/dist/agent/sub-agents/types.d.ts.map +1 -1
- package/dist/agent/system-prompt.d.ts +21 -0
- package/dist/agent/system-prompt.d.ts.map +1 -1
- package/dist/agent/system-prompt.js +68 -2
- package/dist/agent/system-prompt.js.map +1 -1
- package/dist/agent/tool-execution.d.ts.map +1 -1
- package/dist/agent/tool-execution.js +220 -1
- package/dist/agent/tool-execution.js.map +1 -1
- package/dist/commands/index.d.ts +6 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +3 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/loader.d.ts +13 -0
- package/dist/commands/loader.d.ts.map +1 -0
- package/dist/commands/loader.js +93 -0
- package/dist/commands/loader.js.map +1 -0
- package/dist/commands/registry.d.ts +44 -0
- package/dist/commands/registry.d.ts.map +1 -0
- package/dist/commands/registry.js +102 -0
- package/dist/commands/registry.js.map +1 -0
- package/dist/commands/types.d.ts +23 -0
- package/dist/commands/types.d.ts.map +1 -0
- package/dist/commands/types.js +26 -0
- package/dist/commands/types.js.map +1 -0
- package/dist/config/index.d.ts +9 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +12 -10
- package/dist/config/index.js.map +1 -1
- package/dist/hooks/bus.d.ts +54 -0
- package/dist/hooks/bus.d.ts.map +1 -0
- package/dist/hooks/bus.js +165 -0
- package/dist/hooks/bus.js.map +1 -0
- package/dist/hooks/config-schema.d.ts +854 -0
- package/dist/hooks/config-schema.d.ts.map +1 -0
- package/dist/hooks/config-schema.js +79 -0
- package/dist/hooks/config-schema.js.map +1 -0
- package/dist/hooks/executor.d.ts +16 -0
- package/dist/hooks/executor.d.ts.map +1 -0
- package/dist/hooks/executor.js +183 -0
- package/dist/hooks/executor.js.map +1 -0
- package/dist/hooks/index.d.ts +10 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +6 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/registry.d.ts +23 -0
- package/dist/hooks/registry.d.ts.map +1 -0
- package/dist/hooks/registry.js +49 -0
- package/dist/hooks/registry.js.map +1 -0
- package/dist/hooks/types.d.ts +165 -0
- package/dist/hooks/types.d.ts.map +1 -0
- package/dist/hooks/types.js +25 -0
- package/dist/hooks/types.js.map +1 -0
- package/dist/hooks/variables.d.ts +22 -0
- package/dist/hooks/variables.d.ts.map +1 -0
- package/dist/hooks/variables.js +80 -0
- package/dist/hooks/variables.js.map +1 -0
- package/dist/index.d.ts +56 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +37 -1
- package/dist/index.js.map +1 -1
- package/dist/knowledge/auto-memory.d.ts +1 -1
- package/dist/knowledge/auto-memory.d.ts.map +1 -1
- package/dist/knowledge/auto-memory.js +10 -10
- package/dist/knowledge/auto-memory.js.map +1 -1
- package/dist/knowledge/loader.js +12 -12
- package/dist/knowledge/loader.js.map +1 -1
- package/dist/mcp/arg-parser.d.ts +49 -0
- package/dist/mcp/arg-parser.d.ts.map +1 -0
- package/dist/mcp/arg-parser.js +357 -0
- package/dist/mcp/arg-parser.js.map +1 -0
- package/dist/mcp/client.d.ts +73 -0
- package/dist/mcp/client.d.ts.map +1 -0
- package/dist/mcp/client.js +376 -0
- package/dist/mcp/client.js.map +1 -0
- package/dist/mcp/config-schema.d.ts +64 -0
- package/dist/mcp/config-schema.d.ts.map +1 -0
- package/dist/mcp/config-schema.js +86 -0
- package/dist/mcp/config-schema.js.map +1 -0
- package/dist/mcp/config-writer.d.ts +41 -0
- package/dist/mcp/config-writer.d.ts.map +1 -0
- package/dist/mcp/config-writer.js +138 -0
- package/dist/mcp/config-writer.js.map +1 -0
- package/dist/mcp/env-safety.d.ts +12 -0
- package/dist/mcp/env-safety.d.ts.map +1 -0
- package/dist/mcp/env-safety.js +80 -0
- package/dist/mcp/env-safety.js.map +1 -0
- package/dist/mcp/expand-env.d.ts +14 -0
- package/dist/mcp/expand-env.d.ts.map +1 -0
- package/dist/mcp/expand-env.js +52 -0
- package/dist/mcp/expand-env.js.map +1 -0
- package/dist/mcp/loader.d.ts +81 -0
- package/dist/mcp/loader.d.ts.map +1 -0
- package/dist/mcp/loader.js +223 -0
- package/dist/mcp/loader.js.map +1 -0
- package/dist/mcp/name-mangling.d.ts +11 -0
- package/dist/mcp/name-mangling.d.ts.map +1 -0
- package/dist/mcp/name-mangling.js +82 -0
- package/dist/mcp/name-mangling.js.map +1 -0
- package/dist/mcp/oauth/callback-server.d.ts +25 -0
- package/dist/mcp/oauth/callback-server.d.ts.map +1 -0
- package/dist/mcp/oauth/callback-server.js +118 -0
- package/dist/mcp/oauth/callback-server.js.map +1 -0
- package/dist/mcp/oauth/provider.d.ts +80 -0
- package/dist/mcp/oauth/provider.d.ts.map +1 -0
- package/dist/mcp/oauth/provider.js +292 -0
- package/dist/mcp/oauth/provider.js.map +1 -0
- package/dist/mcp/oauth/token-storage.d.ts +42 -0
- package/dist/mcp/oauth/token-storage.d.ts.map +1 -0
- package/dist/mcp/oauth/token-storage.js +121 -0
- package/dist/mcp/oauth/token-storage.js.map +1 -0
- package/dist/mcp/permissions.d.ts +28 -0
- package/dist/mcp/permissions.d.ts.map +1 -0
- package/dist/mcp/permissions.js +105 -0
- package/dist/mcp/permissions.js.map +1 -0
- package/dist/mcp/registry.d.ts +150 -0
- package/dist/mcp/registry.d.ts.map +1 -0
- package/dist/mcp/registry.js +334 -0
- package/dist/mcp/registry.js.map +1 -0
- package/dist/mcp/resources.d.ts +7 -0
- package/dist/mcp/resources.d.ts.map +1 -0
- package/dist/mcp/resources.js +40 -0
- package/dist/mcp/resources.js.map +1 -0
- package/dist/mcp/tool-bridge.d.ts +16 -0
- package/dist/mcp/tool-bridge.d.ts.map +1 -0
- package/dist/mcp/tool-bridge.js +56 -0
- package/dist/mcp/tool-bridge.js.map +1 -0
- package/dist/mcp/trust.d.ts +31 -0
- package/dist/mcp/trust.d.ts.map +1 -0
- package/dist/mcp/trust.js +103 -0
- package/dist/mcp/trust.js.map +1 -0
- package/dist/mcp/types.d.ts +73 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +13 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/permissions/session-store.d.ts +13 -2
- package/dist/permissions/session-store.d.ts.map +1 -1
- package/dist/permissions/session-store.js +264 -62
- package/dist/permissions/session-store.js.map +1 -1
- package/dist/plugins/consent.d.ts +87 -0
- package/dist/plugins/consent.d.ts.map +1 -0
- package/dist/plugins/consent.js +181 -0
- package/dist/plugins/consent.js.map +1 -0
- package/dist/plugins/enable-state.d.ts +34 -0
- package/dist/plugins/enable-state.d.ts.map +1 -0
- package/dist/plugins/enable-state.js +159 -0
- package/dist/plugins/enable-state.js.map +1 -0
- package/dist/plugins/installer.d.ts +64 -0
- package/dist/plugins/installer.d.ts.map +1 -0
- package/dist/plugins/installer.js +416 -0
- package/dist/plugins/installer.js.map +1 -0
- package/dist/plugins/integration.d.ts +91 -0
- package/dist/plugins/integration.d.ts.map +1 -0
- package/dist/plugins/integration.js +233 -0
- package/dist/plugins/integration.js.map +1 -0
- package/dist/plugins/loader.d.ts +69 -0
- package/dist/plugins/loader.d.ts.map +1 -0
- package/dist/plugins/loader.js +243 -0
- package/dist/plugins/loader.js.map +1 -0
- package/dist/plugins/manifest.d.ts +23 -0
- package/dist/plugins/manifest.d.ts.map +1 -0
- package/dist/plugins/manifest.js +143 -0
- package/dist/plugins/manifest.js.map +1 -0
- package/dist/plugins/marketplace.d.ts +100 -0
- package/dist/plugins/marketplace.d.ts.map +1 -0
- package/dist/plugins/marketplace.js +529 -0
- package/dist/plugins/marketplace.js.map +1 -0
- package/dist/plugins/paths.d.ts +44 -0
- package/dist/plugins/paths.d.ts.map +1 -0
- package/dist/plugins/paths.js +89 -0
- package/dist/plugins/paths.js.map +1 -0
- package/dist/plugins/refresh.d.ts +61 -0
- package/dist/plugins/refresh.d.ts.map +1 -0
- package/dist/plugins/refresh.js +98 -0
- package/dist/plugins/refresh.js.map +1 -0
- package/dist/plugins/registry.d.ts +40 -0
- package/dist/plugins/registry.d.ts.map +1 -0
- package/dist/plugins/registry.js +80 -0
- package/dist/plugins/registry.js.map +1 -0
- package/dist/plugins/types.d.ts +225 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/plugins/types.js +16 -0
- package/dist/plugins/types.js.map +1 -0
- package/dist/plugins/user-config.d.ts +22 -0
- package/dist/plugins/user-config.d.ts.map +1 -0
- package/dist/plugins/user-config.js +96 -0
- package/dist/plugins/user-config.js.map +1 -0
- package/dist/providers/cache-control.d.ts +9 -0
- package/dist/providers/cache-control.d.ts.map +1 -1
- package/dist/providers/cache-control.js +31 -4
- package/dist/providers/cache-control.js.map +1 -1
- package/dist/skills/loader.d.ts +19 -0
- package/dist/skills/loader.d.ts.map +1 -0
- package/dist/skills/loader.js +197 -0
- package/dist/skills/loader.js.map +1 -0
- package/dist/skills/registry.d.ts +74 -0
- package/dist/skills/registry.d.ts.map +1 -0
- package/dist/skills/registry.js +136 -0
- package/dist/skills/registry.js.map +1 -0
- package/dist/skills/settings.d.ts +13 -0
- package/dist/skills/settings.d.ts.map +1 -0
- package/dist/skills/settings.js +100 -0
- package/dist/skills/settings.js.map +1 -0
- package/dist/tools/activate-skill.d.ts +5 -0
- package/dist/tools/activate-skill.d.ts.map +1 -0
- package/dist/tools/activate-skill.js +33 -0
- package/dist/tools/activate-skill.js.map +1 -0
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/todo-write.d.ts +1 -1
- package/dist/tools/web-fetch.d.ts.map +1 -1
- package/dist/tools/web-fetch.js +2 -1
- package/dist/tools/web-fetch.js.map +1 -1
- package/dist/types/index.d.ts +46 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utils.d.ts +23 -2
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +76 -20
- package/dist/utils.js.map +1 -1
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +47 -0
- package/dist/version.js.map +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export declare function isProjectTrusted(projectPath: string): Promise<boolean>;
|
|
2
|
+
export declare function trustProject(projectPath: string): Promise<void>;
|
|
3
|
+
export type TrustChoice = 'trust' | 'skip' | 'exit';
|
|
4
|
+
/** Ask the user whether to trust the project's MCP config.
|
|
5
|
+
*
|
|
6
|
+
* Caller passes a generic askUser callback (the same one the agent loop
|
|
7
|
+
* uses for askUser tool calls) so trust prompts render in the same dialog
|
|
8
|
+
* style as the rest of the UI. We show the actual command strings so the
|
|
9
|
+
* user can audit what would run.
|
|
10
|
+
*
|
|
11
|
+
* Returns:
|
|
12
|
+
* 'trust' — user accepted; caller should persist via trustProject(...)
|
|
13
|
+
* 'skip' — load only user-level mcpServers
|
|
14
|
+
* 'exit' — caller should terminate the CLI */
|
|
15
|
+
export declare function promptForTrust(projectPath: string, serverSummaries: Array<{
|
|
16
|
+
name: string;
|
|
17
|
+
preview: string;
|
|
18
|
+
}>, askUser: (question: string, options: Array<{
|
|
19
|
+
label: string;
|
|
20
|
+
description: string;
|
|
21
|
+
}>) => Promise<string>): Promise<TrustChoice>;
|
|
22
|
+
/** Build the one-line preview shown for each server in the trust dialog.
|
|
23
|
+
* Stdio servers expose their full command + args; HTTP servers show the
|
|
24
|
+
* URL. We intentionally don't truncate — the user needs to see the whole
|
|
25
|
+
* thing to make an informed call. */
|
|
26
|
+
export declare function buildServerPreview(config: {
|
|
27
|
+
command?: string;
|
|
28
|
+
args?: string[];
|
|
29
|
+
url?: string;
|
|
30
|
+
}): string;
|
|
31
|
+
//# sourceMappingURL=trust.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trust.d.ts","sourceRoot":"","sources":["../../src/mcp/trust.ts"],"names":[],"mappings":"AA8DA,wBAAsB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAI5E;AAED,wBAAsB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAMrE;AAED,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAA;AAEnD;;;;;;;;;;kDAUkD;AAClD,wBAAsB,cAAc,CAClC,WAAW,EAAE,MAAM,EACnB,eAAe,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,EACzD,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,GACrG,OAAO,CAAC,WAAW,CAAC,CAiBtB;AAED;;;sCAGsC;AACtC,wBAAgB,kBAAkB,CAAC,MAAM,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAOtG"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// @x-code-cli/core — MCP project-level trust gate
|
|
2
|
+
//
|
|
3
|
+
// A `.x-code/config.json` checked into a git repo can declare MCP servers
|
|
4
|
+
// with arbitrary `command` strings — i.e. cloning a hostile repo and
|
|
5
|
+
// launching the CLI would silently spawn whatever that command says.
|
|
6
|
+
// Before honouring any project-level mcpServers block, we therefore
|
|
7
|
+
// require an explicit consent step keyed to the absolute project path.
|
|
8
|
+
//
|
|
9
|
+
// Persistence file: ~/.x-code/trusted-projects.json (mode 0600).
|
|
10
|
+
// Format: { trusted: [{ path: <absolute>, trustedAt: <ISO> }, ...] }
|
|
11
|
+
//
|
|
12
|
+
// User config (~/.x-code/config.json) is NOT subject to this gate —
|
|
13
|
+
// the user wrote it themselves; trust is implicit.
|
|
14
|
+
import fs from 'node:fs/promises';
|
|
15
|
+
import path from 'node:path';
|
|
16
|
+
import { userXcodeDir } from '../utils.js';
|
|
17
|
+
function trustedFile() {
|
|
18
|
+
return path.join(userXcodeDir(), 'trusted-projects.json');
|
|
19
|
+
}
|
|
20
|
+
/** Normalise a path for stable comparison across platforms.
|
|
21
|
+
* Absolute + resolved + lowercased on Windows (case-insensitive FS),
|
|
22
|
+
* preserved case on macOS/Linux. */
|
|
23
|
+
function normalize(p) {
|
|
24
|
+
const resolved = path.resolve(p);
|
|
25
|
+
return process.platform === 'win32' ? resolved.toLowerCase() : resolved;
|
|
26
|
+
}
|
|
27
|
+
async function readStore() {
|
|
28
|
+
try {
|
|
29
|
+
const raw = await fs.readFile(trustedFile(), 'utf-8');
|
|
30
|
+
const parsed = JSON.parse(raw);
|
|
31
|
+
if (parsed && typeof parsed === 'object' && Array.isArray(parsed.trusted)) {
|
|
32
|
+
return parsed;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
// missing file or malformed — start fresh
|
|
37
|
+
}
|
|
38
|
+
return { trusted: [] };
|
|
39
|
+
}
|
|
40
|
+
async function writeStore(store) {
|
|
41
|
+
await fs.mkdir(userXcodeDir(), { recursive: true });
|
|
42
|
+
// Atomic write: tmp + rename. Avoids a half-written file if the process
|
|
43
|
+
// is killed mid-write (the trust file is small but the principle holds —
|
|
44
|
+
// we never want a corrupted JSON to lock the user out of MCP).
|
|
45
|
+
const tmp = trustedFile() + '.tmp';
|
|
46
|
+
await fs.writeFile(tmp, JSON.stringify(store, null, 2) + '\n', { encoding: 'utf-8', mode: 0o600 });
|
|
47
|
+
await fs.rename(tmp, trustedFile());
|
|
48
|
+
}
|
|
49
|
+
export async function isProjectTrusted(projectPath) {
|
|
50
|
+
const normalized = normalize(projectPath);
|
|
51
|
+
const store = await readStore();
|
|
52
|
+
return store.trusted.some((e) => normalize(e.path) === normalized);
|
|
53
|
+
}
|
|
54
|
+
export async function trustProject(projectPath) {
|
|
55
|
+
const normalized = normalize(projectPath);
|
|
56
|
+
const store = await readStore();
|
|
57
|
+
if (store.trusted.some((e) => normalize(e.path) === normalized))
|
|
58
|
+
return;
|
|
59
|
+
store.trusted.push({ path: path.resolve(projectPath), trustedAt: new Date().toISOString() });
|
|
60
|
+
await writeStore(store);
|
|
61
|
+
}
|
|
62
|
+
/** Ask the user whether to trust the project's MCP config.
|
|
63
|
+
*
|
|
64
|
+
* Caller passes a generic askUser callback (the same one the agent loop
|
|
65
|
+
* uses for askUser tool calls) so trust prompts render in the same dialog
|
|
66
|
+
* style as the rest of the UI. We show the actual command strings so the
|
|
67
|
+
* user can audit what would run.
|
|
68
|
+
*
|
|
69
|
+
* Returns:
|
|
70
|
+
* 'trust' — user accepted; caller should persist via trustProject(...)
|
|
71
|
+
* 'skip' — load only user-level mcpServers
|
|
72
|
+
* 'exit' — caller should terminate the CLI */
|
|
73
|
+
export async function promptForTrust(projectPath, serverSummaries, askUser) {
|
|
74
|
+
const lines = serverSummaries.map((s) => ` • ${s.name}: ${s.preview}`).join('\n');
|
|
75
|
+
const question = `This project wants to load ${serverSummaries.length} MCP server(s):\n` +
|
|
76
|
+
lines +
|
|
77
|
+
`\n\nThese commands will run on your machine. Trust only if you trust this project.`;
|
|
78
|
+
const answer = await askUser(question, [
|
|
79
|
+
{ label: 'Trust this project', description: 'Remember this choice. The project MCP servers will load.' },
|
|
80
|
+
{ label: 'Skip project MCP', description: 'Use only user-level mcpServers for this session. No write to disk.' },
|
|
81
|
+
{ label: 'Exit X-Code', description: 'Close the CLI without loading any MCP servers.' },
|
|
82
|
+
]);
|
|
83
|
+
const lower = answer.toLowerCase();
|
|
84
|
+
if (lower.startsWith('trust'))
|
|
85
|
+
return 'trust';
|
|
86
|
+
if (lower.startsWith('exit'))
|
|
87
|
+
return 'exit';
|
|
88
|
+
return 'skip';
|
|
89
|
+
}
|
|
90
|
+
/** Build the one-line preview shown for each server in the trust dialog.
|
|
91
|
+
* Stdio servers expose their full command + args; HTTP servers show the
|
|
92
|
+
* URL. We intentionally don't truncate — the user needs to see the whole
|
|
93
|
+
* thing to make an informed call. */
|
|
94
|
+
export function buildServerPreview(config) {
|
|
95
|
+
if (config.url)
|
|
96
|
+
return config.url;
|
|
97
|
+
if (config.command) {
|
|
98
|
+
const parts = [config.command, ...(config.args ?? [])];
|
|
99
|
+
return parts.join(' ');
|
|
100
|
+
}
|
|
101
|
+
return '(invalid config)';
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=trust.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trust.js","sourceRoot":"","sources":["../../src/mcp/trust.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,EAAE;AACF,0EAA0E;AAC1E,qEAAqE;AACrE,qEAAqE;AACrE,oEAAoE;AACpE,uEAAuE;AACvE,EAAE;AACF,iEAAiE;AACjE,qEAAqE;AACrE,EAAE;AACF,oEAAoE;AACpE,mDAAmD;AACnD,OAAO,EAAE,MAAM,kBAAkB,CAAA;AACjC,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,SAAS,WAAW;IAClB,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,uBAAuB,CAAC,CAAA;AAC3D,CAAC;AAWD;;qCAEqC;AACrC,SAAS,SAAS,CAAC,CAAS;IAC1B,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;IAChC,OAAO,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAA;AACzE,CAAC;AAED,KAAK,UAAU,SAAS;IACtB,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,WAAW,EAAE,EAAE,OAAO,CAAC,CAAA;QACrD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAY,CAAA;QACzC,IAAI,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAE,MAAuB,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5F,OAAO,MAAsB,CAAA;QAC/B,CAAC;IACH,CAAC;IAA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AAC;QACnB,MAAM,KAAK,GAAG,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAA;QACtD,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACxB,CAAC;IACD,OAAO,kBAAkB,CAAA;AAC3B,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/** stdio-based MCP server (local subprocess). */
|
|
2
|
+
export interface McpStdioServerConfig {
|
|
3
|
+
command: string;
|
|
4
|
+
args?: string[];
|
|
5
|
+
env?: Record<string, string>;
|
|
6
|
+
cwd?: string;
|
|
7
|
+
/** First-connect timeout in ms. Default 30_000. */
|
|
8
|
+
timeout?: number;
|
|
9
|
+
/** Default true. Setting to false skips the server entirely. */
|
|
10
|
+
enabled?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/** Streamable HTTP MCP server (remote). */
|
|
13
|
+
export interface McpHttpServerConfig {
|
|
14
|
+
url: string;
|
|
15
|
+
/** Static headers attached to every request (e.g. `X-Custom: foo`).
|
|
16
|
+
* OAuth `Authorization: Bearer ...` is added automatically — do NOT put
|
|
17
|
+
* the access token here, store it via the OAuth flow instead. */
|
|
18
|
+
headers?: Record<string, string>;
|
|
19
|
+
timeout?: number;
|
|
20
|
+
enabled?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export type McpServerConfig = McpStdioServerConfig | McpHttpServerConfig;
|
|
23
|
+
/** Discriminator: tells stdio vs http servers apart at runtime. */
|
|
24
|
+
export declare function isStdioConfig(c: McpServerConfig): c is McpStdioServerConfig;
|
|
25
|
+
export declare function isHttpConfig(c: McpServerConfig): c is McpHttpServerConfig;
|
|
26
|
+
/** Per-server runtime status. UI reads this via /mcp list. */
|
|
27
|
+
export type McpServerStatus = {
|
|
28
|
+
kind: 'disabled';
|
|
29
|
+
} | {
|
|
30
|
+
kind: 'connecting';
|
|
31
|
+
} | {
|
|
32
|
+
kind: 'connected';
|
|
33
|
+
toolCount: number;
|
|
34
|
+
resourceCount: number;
|
|
35
|
+
} | {
|
|
36
|
+
kind: 'needs_auth';
|
|
37
|
+
authUrl?: string;
|
|
38
|
+
} | {
|
|
39
|
+
kind: 'failed';
|
|
40
|
+
error: string;
|
|
41
|
+
};
|
|
42
|
+
/** One MCP tool, after name-mangling.
|
|
43
|
+
*
|
|
44
|
+
* callableName is the model-facing name (<server>__<tool>);
|
|
45
|
+
* rawName is what we pass back to client.callTool — MCP servers don't
|
|
46
|
+
* know about our prefix scheme. */
|
|
47
|
+
export interface McpToolEntry {
|
|
48
|
+
callableName: string;
|
|
49
|
+
rawName: string;
|
|
50
|
+
serverName: string;
|
|
51
|
+
description: string;
|
|
52
|
+
/** JSON Schema as received from the server. We pass it directly to the
|
|
53
|
+
* AI SDK via `jsonSchema(...)` — no zod conversion. */
|
|
54
|
+
inputSchema: Record<string, unknown>;
|
|
55
|
+
}
|
|
56
|
+
/** One MCP resource (data the server lets us pull). */
|
|
57
|
+
export interface McpResourceEntry {
|
|
58
|
+
uri: string;
|
|
59
|
+
name: string;
|
|
60
|
+
description?: string;
|
|
61
|
+
mimeType?: string;
|
|
62
|
+
serverName: string;
|
|
63
|
+
}
|
|
64
|
+
/** Result of calling an MCP tool — flattened from MCP's content-blocks
|
|
65
|
+
* into something we can shove into a tool_result message. The raw blocks
|
|
66
|
+
* are kept on the side in case a future UI wants images/audio. */
|
|
67
|
+
export interface McpCallResult {
|
|
68
|
+
/** Text representation suitable for tool_result. */
|
|
69
|
+
text: string;
|
|
70
|
+
/** True iff the server marked the call as an error (MCP `isError` flag). */
|
|
71
|
+
isError: boolean;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/mcp/types.ts"],"names":[],"mappings":"AAMA,iDAAiD;AACjD,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CA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,WAAW,EAAE,MAAM,CAAA;IACnB;4DACwD;IACxD,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACrC;AAED,uDAAuD;AACvD,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;CACnB;AAED;;mEAEmE;AACnE,MAAM,WAAW,aAAa;IAC5B,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAA;IACZ,4EAA4E;IAC5E,OAAO,EAAE,OAAO,CAAA;CACjB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// @x-code-cli/core — MCP public types
|
|
2
|
+
//
|
|
3
|
+
// Shared shapes used across the mcp/ subsystem. Kept dependency-free so the
|
|
4
|
+
// loader/registry/UI layers can import without circular hops back into the
|
|
5
|
+
// agent loop or CLI.
|
|
6
|
+
/** Discriminator: tells stdio vs http servers apart at runtime. */
|
|
7
|
+
export function isStdioConfig(c) {
|
|
8
|
+
return 'command' in c;
|
|
9
|
+
}
|
|
10
|
+
export function isHttpConfig(c) {
|
|
11
|
+
return 'url' in c;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/mcp/types.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,EAAE;AACF,4EAA4E;AAC5E,2EAA2E;AAC3E,qBAAqB;AA2BrB,mEAAmE;AACnE,MAAM,UAAU,aAAa,CAAC,CAAkB;IAC9C,OAAO,SAAS,IAAI,CAAC,CAAA;AACvB,CAAC;AACD,MAAM,UAAU,YAAY,CAAC,CAAkB;IAC7C,OAAO,KAAK,IAAI,CAAC,CAAA;AACnB,CAAC"}
|
|
@@ -5,12 +5,20 @@ export interface AllowRule {
|
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
7
|
* Extract a command prefix suitable for prefix-match rules.
|
|
8
|
-
* Returns `null` when no meaningful prefix can be derived
|
|
8
|
+
* Returns `null` when no meaningful prefix can be safely derived —
|
|
9
|
+
* callers fall back to exact-match.
|
|
9
10
|
*
|
|
10
11
|
* 'git commit -m "fix"' → 'git commit'
|
|
12
|
+
* 'git -C /tmp commit -m fix' → 'git commit'
|
|
13
|
+
* 'docker -H tcp://host:2375 ps' → 'docker ps'
|
|
14
|
+
* 'kubectl -n prod get pods' → 'kubectl get'
|
|
15
|
+
* 'cargo +nightly build --release' → 'cargo build'
|
|
11
16
|
* 'pnpm run build' → 'pnpm run'
|
|
12
17
|
* 'npm install lodash' → 'npm install'
|
|
13
18
|
* 'NODE_ENV=prod npm run dev' → 'npm run'
|
|
19
|
+
* 'FOO=1 git status' → null (unsafe env)
|
|
20
|
+
* 'sudo npm install' → null (wrapper)
|
|
21
|
+
* 'bash -c "git status"' → null (wrapper)
|
|
14
22
|
* 'powershell -Command "Get-CimInstance ..."' → 'Get-CimInstance'
|
|
15
23
|
* 'powershell -NoProfile -Command "Get-CimInstance ..."' → 'Get-CimInstance'
|
|
16
24
|
* 'powershell -ExecutionPolicy Bypass -c "git status"' → 'git'
|
|
@@ -32,8 +40,11 @@ export declare function extractCommandPrefix(command: string): string | null;
|
|
|
32
40
|
* the prefix regex; without this fallback the user gets only Yes/No
|
|
33
41
|
* forever for repeated identical commands).
|
|
34
42
|
* Write tools (writeFile / edit): `all edits this session` (session-only)
|
|
43
|
+
* MCP tools (isMcp=true): `this MCP tool` (persisted to disk via
|
|
44
|
+
* McpPermissionStore — the label matches that posture, unlike write
|
|
45
|
+
* tools which fall back to session-only).
|
|
35
46
|
*/
|
|
36
|
-
export declare function suggestRuleLabel(toolName: string, input: Record<string, unknown
|
|
47
|
+
export declare function suggestRuleLabel(toolName: string, input: Record<string, unknown>, isMcp?: boolean): string | null;
|
|
37
48
|
/**
|
|
38
49
|
* Build the AllowRule for a "don't ask again" approval.
|
|
39
50
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-store.d.ts","sourceRoot":"","sources":["../../src/permissions/session-store.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAA;CAClC;
|
|
1
|
+
{"version":3,"file":"session-store.d.ts","sourceRoot":"","sources":["../../src/permissions/session-store.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAA;CAClC;AA4ID;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA+CnE;AAyED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,UAAQ,GAAG,MAAM,GAAG,IAAI,CAU/G;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAgB9C;AA8ED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,CAEzD;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GA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