@agimon-ai/po-config 0.0.0-alpha.21 → 0.0.0-alpha.23
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/agentPluginMcp.cjs +67 -0
- package/dist/agentPluginMcp.cjs.map +1 -1
- package/dist/agentPluginMcp.d.mts +4 -1
- package/dist/agentPluginMcp.d.mts.map +1 -1
- package/dist/agentPluginMcp.mjs +67 -1
- package/dist/agentPluginMcp.mjs.map +1 -1
- package/dist/{completion-Ba0TiBHa.d.mts → completion-CqlF0TFY.d.mts} +3 -93
- package/dist/completion-CqlF0TFY.d.mts.map +1 -0
- package/dist/domains-Bo9krPQ5.d.mts +93 -0
- package/dist/domains-Bo9krPQ5.d.mts.map +1 -0
- package/dist/domains.d.mts +2 -1
- package/dist/index.d.mts +2 -1
- package/package.json +5 -5
- package/dist/completion-Ba0TiBHa.d.mts.map +0 -1
package/dist/agentPluginMcp.cjs
CHANGED
|
@@ -377,6 +377,72 @@ function normalizeAgentPluginMcpSource(source, options) {
|
|
|
377
377
|
return disabledResult(label, error);
|
|
378
378
|
}
|
|
379
379
|
}
|
|
380
|
+
const AGENT_PLUGIN_SCHEMA = "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json";
|
|
381
|
+
function isPlainObject(value) {
|
|
382
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
383
|
+
}
|
|
384
|
+
function stablePluginIdentity(entry) {
|
|
385
|
+
const source = entry.source;
|
|
386
|
+
const identity = source?.type === "git" ? [
|
|
387
|
+
"git",
|
|
388
|
+
source.url,
|
|
389
|
+
source.path ?? ""
|
|
390
|
+
] : source?.type === "npm" ? [
|
|
391
|
+
"npm",
|
|
392
|
+
source.registry ?? "",
|
|
393
|
+
source.package
|
|
394
|
+
] : ["local", node_fs.default.realpathSync(entry.directory)];
|
|
395
|
+
return (0, node_crypto.createHash)("sha256").update(JSON.stringify(identity)).digest("hex");
|
|
396
|
+
}
|
|
397
|
+
function rootAgentPluginSchema(entry) {
|
|
398
|
+
const manifestPath = node_path.default.join(entry.directory, "plugin.json");
|
|
399
|
+
if (entry.manifest?.path === manifestPath && entry.manifest.agentPluginSchema === AGENT_PLUGIN_SCHEMA) return AGENT_PLUGIN_SCHEMA;
|
|
400
|
+
try {
|
|
401
|
+
const stat = node_fs.default.lstatSync(manifestPath);
|
|
402
|
+
if (stat.isSymbolicLink() || !stat.isFile()) return void 0;
|
|
403
|
+
const parsed = JSON.parse(node_fs.default.readFileSync(manifestPath, "utf8"));
|
|
404
|
+
return isPlainObject(parsed) && parsed.$schema === AGENT_PLUGIN_SCHEMA ? AGENT_PLUGIN_SCHEMA : void 0;
|
|
405
|
+
} catch {
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
/** One plugin's MCP config as a projection source, or nothing when it ships none. Shared by sync and settings. */
|
|
410
|
+
async function pluginMcpSource(entry, pluginDataRoot) {
|
|
411
|
+
if (entry.mcp === false) return void 0;
|
|
412
|
+
const pluginRoot = node_fs.default.realpathSync(entry.directory);
|
|
413
|
+
const agentPlugin = rootAgentPluginSchema(entry) === AGENT_PLUGIN_SCHEMA;
|
|
414
|
+
const configPath = node_path.default.join(pluginRoot, agentPlugin ? "mcp.json" : ".mcp.json");
|
|
415
|
+
let stat;
|
|
416
|
+
try {
|
|
417
|
+
stat = await node_fs.default.promises.lstat(configPath);
|
|
418
|
+
} catch (error) {
|
|
419
|
+
if (error.code === "ENOENT") return void 0;
|
|
420
|
+
throw error;
|
|
421
|
+
}
|
|
422
|
+
if (!stat.isFile() || stat.isSymbolicLink()) return void 0;
|
|
423
|
+
const content = await node_fs.default.promises.readFile(configPath);
|
|
424
|
+
const contentDigest = (0, node_crypto.createHash)("sha256").update(content).digest("hex");
|
|
425
|
+
const pluginId = stablePluginIdentity(entry);
|
|
426
|
+
const sourceId = `plugin:${pluginId}`;
|
|
427
|
+
if (!agentPlugin) return {
|
|
428
|
+
sourceId,
|
|
429
|
+
owner: "plugin",
|
|
430
|
+
format: "native",
|
|
431
|
+
configPath,
|
|
432
|
+
contentDigest
|
|
433
|
+
};
|
|
434
|
+
return {
|
|
435
|
+
sourceId,
|
|
436
|
+
owner: "plugin",
|
|
437
|
+
format: "agent-plugin-v1",
|
|
438
|
+
configPath,
|
|
439
|
+
contentDigest,
|
|
440
|
+
pluginId,
|
|
441
|
+
pluginRoot,
|
|
442
|
+
pluginDataDirectory: node_path.default.join(pluginDataRoot, pluginId),
|
|
443
|
+
mcpSchemaUrl: _agimon_ai_po_core_mcpProjection.AGENT_PLUGIN_MCP_SCHEMA_URL
|
|
444
|
+
};
|
|
445
|
+
}
|
|
380
446
|
//#endregion
|
|
381
447
|
//#region src/services/agentPluginMcp/index.ts
|
|
382
448
|
async function realContainedPath(fs, root, candidate, label, context) {
|
|
@@ -497,5 +563,6 @@ async function normalizeAgentPluginMcpSourceAsync(fs, source, options, context)
|
|
|
497
563
|
//#endregion
|
|
498
564
|
exports.normalizeAgentPluginMcpSource = normalizeAgentPluginMcpSource;
|
|
499
565
|
exports.normalizeAgentPluginMcpSourceAsync = normalizeAgentPluginMcpSourceAsync;
|
|
566
|
+
exports.pluginMcpSource = pluginMcpSource;
|
|
500
567
|
|
|
501
568
|
//# sourceMappingURL=agentPluginMcp.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentPluginMcp.cjs","names":["path","createHash","AGENT_PLUGIN_MCP_SCHEMA_URL","realContainedPath","fs","normalizeCommand","path","normalizeWorkingDirectory","normalizeServer","writeStagedInternalConfig","randomUUID","path","getOrThrow","nodeHost","writeFileAtomic"],"sources":["../src/services/agentPluginMcp/normalize.ts","../src/services/agentPluginMcp/sync.ts","../src/services/agentPluginMcp/index.ts"],"sourcesContent":["/** Pure Agent Plugin MCP normalisation shared by the async API and the deprecated Node-only sync shim. */\nimport { createHash } from 'node:crypto';\nimport path from 'node:path';\n\nimport { AGENT_PLUGIN_MCP_SCHEMA_URL, type PoMcpAgentPluginProjectionSource } from '@agimon-ai/po-core/mcpProjection';\n\n/** Same token grammar as node:http `validateHeaderName` (RFC 9110 tchar). */\nconst HTTP_TOKEN = /^[\\^_`a-zA-Z\\-0-9!#$%&'*+.|~]+$/u;\n/** Same rejected characters as node:http `validateHeaderValue`. */\nconst INVALID_HEADER_VALUE_CHARACTER = /[^\\t\\x20-\\x7e\\x80-\\xff]/u;\nconst IPV4_OCTET = '(?:25[0-5]|2[0-4]\\\\d|1\\\\d\\\\d|[1-9]?\\\\d)';\nconst IPV4_ADDRESS = new RegExp(`^${IPV4_OCTET}(?:\\\\.${IPV4_OCTET}){3}$`, 'u');\n\nfunction isIPv4(value: string): boolean {\n return IPV4_ADDRESS.test(value);\n}\n\nexport const PRIVATE_FILE_MODE = 0o600;\nexport const PRIVATE_DIRECTORY_MODE = 0o700;\nexport const RESERVED_ENVIRONMENT_KEYS = new Set(['PLUGIN_ROOT', 'PLUGIN_DATA']);\nexport const PROXY_SERVER_ALIASES = new Set(['mcp-proxy', 'agiflow-proxy']);\n\nexport type JsonObject = Record<string, unknown>;\n\nexport interface AgentPluginMcpConfigSource {\n path: string;\n format: 'internal';\n cacheKey: string;\n}\n\nexport interface NormalizedAgentPluginMcpSource {\n /** Owner-only, content-addressed layer that bypasses Claude env interpolation. */\n configSource?: AgentPluginMcpConfigSource;\n /** Claude-compatible definitions for an external merged config. */\n claudeConfig: { mcpServers: Record<string, JsonObject> };\n serverNames: string[];\n droppedServers: string[];\n diagnostics: string[];\n}\n\nexport interface NormalizeAgentPluginMcpOptions {\n stagingDirectory: string;\n /** Empty and absent lists both mean keep every server. */\n allowedServers?: readonly string[];\n /** Po strips nested wrappers; external-only callers may opt out. */\n stripProxyWrappers?: boolean;\n}\n\nexport interface NormalizedServer {\n internal: JsonObject;\n claude: JsonObject;\n}\n\nexport function isObject(value: unknown): value is JsonObject {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nexport function onlyKeys(value: JsonObject, allowed: readonly string[], label: string): void {\n const unexpected = Object.keys(value).find((key) => !allowed.includes(key));\n if (unexpected) throw new Error(`${label} contains unsupported field \"${unexpected}\"`);\n}\n\nexport function nonEmptyString(value: unknown, label: string): string {\n if (typeof value !== 'string' || value.length === 0) throw new Error(`${label} must be a non-empty string`);\n return value;\n}\n\nexport function optionalStringArray(value: unknown, label: string): string[] | undefined {\n if (value === undefined) return undefined;\n if (!Array.isArray(value)) throw new Error(`${label} must be an array of strings`);\n return value.map((item, index) => {\n if (typeof item !== 'string') throw new Error(`${label}[${index}] must be a string`);\n return item;\n });\n}\n\nfunction optionalStringRecord(value: unknown, label: string): Record<string, string> | undefined {\n if (value === undefined) return undefined;\n if (!isObject(value)) throw new Error(`${label} must be an object of string values`);\n return Object.fromEntries(\n Object.entries(value).map(([key, item]) => {\n if (typeof item !== 'string') throw new Error(`${label}.${key} must be a string`);\n return [key, item];\n }),\n );\n}\n\nexport function expandPluginPlaceholders(value: string, pluginRoot: string, pluginDataDirectory: string): string {\n // The portable contract is a single, non-recursive replacement pass. An\n // unrecognised placeholder remains literal and mcp-proxy must not reinterpret it.\n return value.replace(/\\$\\{PLUGIN_(ROOT|DATA)\\}/gu, (placeholder) =>\n placeholder === '${PLUGIN_ROOT}' ? pluginRoot : pluginDataDirectory,\n );\n}\n\nexport function isInside(root: string, candidate: string): boolean {\n const relative = path.relative(root, candidate);\n return relative === '' || (!relative.startsWith(`..${path.sep}`) && relative !== '..' && !path.isAbsolute(relative));\n}\n\nexport function normalizeEnvironment(\n value: unknown,\n pluginRoot: string,\n pluginDataDirectory: string,\n): Record<string, string> {\n const declared = optionalStringRecord(value, 'env') ?? {};\n for (const key of Object.keys(declared)) {\n const reservedKey = process.platform === 'win32' ? key.toUpperCase() : key;\n if (RESERVED_ENVIRONMENT_KEYS.has(reservedKey)) {\n throw new Error(`env key \"${key}\" is reserved by Agent Plugins`);\n }\n }\n return {\n ...Object.fromEntries(\n Object.entries(declared).map(([key, item]) => [\n key,\n expandPluginPlaceholders(item, pluginRoot, pluginDataDirectory),\n ]),\n ),\n PLUGIN_ROOT: pluginRoot,\n PLUGIN_DATA: pluginDataDirectory,\n };\n}\n\nfunction isLoopbackHost(hostname: string): boolean {\n const bareHostname = hostname.startsWith('[') && hostname.endsWith(']') ? hostname.slice(1, -1) : hostname;\n if (bareHostname.toLowerCase() === 'localhost') return true;\n if (isIPv4(bareHostname)) return bareHostname.split('.')[0] === '127';\n return bareHostname === '::1';\n}\n\nexport function normalizeUrl(value: unknown): string {\n const raw = nonEmptyString(value, 'url');\n let parsed: URL;\n try {\n parsed = new URL(raw);\n } catch {\n throw new Error('url must be an absolute HTTP(S) URL');\n }\n if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {\n throw new Error('url must use http or https');\n }\n if (parsed.username || parsed.password) throw new Error('url must not contain user information');\n if (parsed.hash) throw new Error('url must not contain a fragment');\n if (parsed.protocol === 'http:' && !isLoopbackHost(parsed.hostname)) {\n throw new Error('non-loopback MCP URLs must use https');\n }\n return raw;\n}\n\nexport function normalizeHeaders(value: unknown): Record<string, string> | undefined {\n const headers = optionalStringRecord(value, 'headers');\n if (!headers) return undefined;\n const seen = new Set<string>();\n for (const [name, item] of Object.entries(headers)) {\n const canonical = name.toLowerCase();\n if (seen.has(canonical)) throw new Error(`headers contain duplicate name \"${name}\"`);\n seen.add(canonical);\n if (!HTTP_TOKEN.test(name) || INVALID_HEADER_VALUE_CHARACTER.test(item)) {\n throw new Error(`header \"${name}\" is invalid`);\n }\n }\n return headers;\n}\n\nexport function stagedInternalPath(\n source: PoMcpAgentPluginProjectionSource,\n contents: string,\n stagingDirectory: string,\n): string {\n const digest = createHash('sha256')\n .update(source.sourceId)\n .update('\\0')\n .update(source.contentDigest)\n .update('\\0')\n .update(contents)\n .digest('hex')\n .slice(0, 20);\n return path.join(stagingDirectory, `agent-plugin-mcp-${digest}.internal.json`);\n}\n\nexport function emptyResult(diagnostic: string): NormalizedAgentPluginMcpSource {\n return {\n claudeConfig: { mcpServers: {} },\n serverNames: [],\n droppedServers: [],\n diagnostics: [diagnostic],\n };\n}\n\nexport function sourceLabel(source: PoMcpAgentPluginProjectionSource): string {\n return `Agent Plugin MCP source \"${source.sourceId}\"`;\n}\n\n/** Checks the projection identity before any file is touched. */\nexport function assertProjectionSource(source: PoMcpAgentPluginProjectionSource): void {\n if (source.mcpSchemaUrl !== AGENT_PLUGIN_MCP_SCHEMA_URL) {\n throw new Error(`unsupported schema \"${String(source.mcpSchemaUrl)}\"`);\n }\n if (!path.isAbsolute(source.pluginRoot) || !path.isAbsolute(source.pluginDataDirectory)) {\n throw new Error('pluginRoot and pluginDataDirectory must be absolute');\n }\n}\n\nexport function assertRootConfigPath(configPath: string, pluginRoot: string): void {\n if (path.dirname(configPath) !== pluginRoot || path.basename(configPath) !== 'mcp.json') {\n throw new Error('portable plugin config must be root mcp.json');\n }\n}\n\n/** Verifies the digest and document shape of the raw mcp.json bytes; returns its server map. */\nexport function parseMcpDocument(\n source: PoMcpAgentPluginProjectionSource,\n bytes: Uint8Array,\n label: string,\n): Record<string, unknown> {\n const digest = createHash('sha256').update(bytes).digest('hex');\n if (digest !== source.contentDigest) throw new Error('content digest does not match the projection');\n const parsed: unknown = JSON.parse(new TextDecoder('utf-8', { ignoreBOM: true }).decode(bytes));\n if (!isObject(parsed)) throw new Error('document must be an object');\n onlyKeys(parsed, ['$schema', 'mcpServers'], label);\n if (parsed.$schema !== source.mcpSchemaUrl) throw new Error('$schema does not match the projected schema');\n if (!isObject(parsed.mcpServers)) throw new Error('mcpServers must be an object');\n return parsed.mcpServers;\n}\n\n/** Whether a declared server is skipped (empty name), dropped by the allowlist or wrapper rule, or normalised. */\nexport function serverDisposition(name: string, options: NormalizeAgentPluginMcpOptions): 'empty' | 'dropped' | 'keep' {\n if (!name) return 'empty';\n const allowed = options.allowedServers;\n const keepAll = !allowed || allowed.length === 0;\n const stripProxyWrappers = options.stripProxyWrappers ?? true;\n if ((!keepAll && !allowed.includes(name)) || (stripProxyWrappers && PROXY_SERVER_ALIASES.has(name))) return 'dropped';\n return 'keep';\n}\n\nexport function emptyServerDiagnostic(label: string): string {\n return `${label} contains an empty server name; that entry was skipped.`;\n}\n\nexport function skippedServerDiagnostic(label: string, name: string, error: unknown): string {\n return `${label} skipped server \"${name}\": ${error instanceof Error ? error.message : String(error)}`;\n}\n\nexport function disabledResult(label: string, error: unknown): NormalizedAgentPluginMcpSource {\n return emptyResult(`${label} was disabled: ${error instanceof Error ? error.message : String(error)}`);\n}\n\n/** The declared transport of one server; stdio declarations are also checked for unsupported fields. */\nexport function serverType(raw: unknown, name: string): string {\n if (!isObject(raw)) throw new Error('definition must be an object');\n const type = nonEmptyString(raw.type, 'type');\n if (type === 'stdio') onlyKeys(raw, ['type', 'command', 'args', 'env', 'cwd'], `server \"${name}\"`);\n return type;\n}\n\nexport function stdioServer(\n name: string,\n config: { command: string; args?: string[]; env: Record<string, string>; cwd: string },\n): NormalizedServer {\n return {\n internal: { name, transport: 'stdio', config },\n claude: { type: 'stdio', ...config },\n };\n}\n\n/** A streamable-http or sse server; any other type is unsupported. */\nexport function remoteServer(raw: JsonObject, name: string, type: string): NormalizedServer {\n if (type === 'streamable-http' || type === 'sse') {\n onlyKeys(raw, ['type', 'url', 'headers'], `server \"${name}\"`);\n const url = normalizeUrl(raw.url);\n const headers = normalizeHeaders(raw.headers);\n const transport = type === 'streamable-http' ? 'http' : 'sse';\n const config = { url, ...(headers ? { headers } : {}) };\n return {\n internal: { name, transport, config },\n claude: { type: transport, ...config },\n };\n }\n throw new Error(`unsupported transport type \"${type}\"`);\n}\n\nexport function stagedContents(internalServers: Record<string, JsonObject>): string {\n return `${JSON.stringify({ mcpServers: internalServers }, null, 2)}\\n`;\n}\n\nexport function stagedCacheKey(source: PoMcpAgentPluginProjectionSource, configPath: string, contents: string): string {\n return createHash('sha256')\n .update('agent-plugin-v1\\0')\n .update(source.sourceId)\n .update('\\0')\n .update(source.contentDigest)\n .update('\\0')\n .update(configPath)\n .update('\\0')\n .update(contents)\n .digest('hex');\n}\n\n/** The containment base and expanded path of a declared cwd, or undefined when the plugin root is the default. */\nexport function workingDirectoryCandidate(\n declared: unknown,\n pluginRoot: string,\n pluginDataDirectory: string,\n): { base: string; candidate: string } | undefined {\n if (declared === undefined) return undefined;\n const cwd = nonEmptyString(declared, 'cwd');\n if (cwd.startsWith('./')) return { base: pluginRoot, candidate: path.resolve(pluginRoot, cwd) };\n const expanded = expandPluginPlaceholders(cwd, pluginRoot, pluginDataDirectory);\n if (cwd === '${PLUGIN_ROOT}' || cwd.startsWith('${PLUGIN_ROOT}/')) {\n return { base: pluginRoot, candidate: path.resolve(expanded) };\n }\n if (cwd === '${PLUGIN_DATA}' || cwd.startsWith('${PLUGIN_DATA}/')) {\n return { base: pluginDataDirectory, candidate: path.resolve(expanded) };\n }\n throw new Error('cwd must start with ./, ${PLUGIN_ROOT}, or ${PLUGIN_DATA}');\n}\n\n/** Rejects a command that is neither a bare executable name nor a ./ path; true when it must be resolved. */\nexport function isPluginRelativeCommand(command: string): boolean {\n if (command.startsWith('./')) return true;\n if (command === '.' || command === '..' || /[\\s/\\\\]/u.test(command)) {\n throw new Error('command must be a bare executable name or a ./ path inside the plugin');\n }\n return false;\n}\n","import { randomUUID } from 'node:crypto';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport type { PoMcpAgentPluginProjectionSource } from '@agimon-ai/po-core/mcpProjection';\n\nimport {\n type JsonObject,\n type NormalizeAgentPluginMcpOptions,\n type NormalizedAgentPluginMcpSource,\n type NormalizedServer,\n PRIVATE_DIRECTORY_MODE,\n PRIVATE_FILE_MODE,\n assertProjectionSource,\n assertRootConfigPath,\n disabledResult,\n emptyServerDiagnostic,\n expandPluginPlaceholders,\n isInside,\n isPluginRelativeCommand,\n nonEmptyString,\n normalizeEnvironment,\n optionalStringArray,\n parseMcpDocument,\n remoteServer,\n serverDisposition,\n serverType,\n skippedServerDiagnostic,\n sourceLabel,\n stagedCacheKey,\n stagedContents,\n stagedInternalPath,\n stdioServer,\n workingDirectoryCandidate,\n} from './normalize';\n\nfunction realContainedPath(root: string, candidate: string, label: string): string {\n let realCandidate: string;\n try {\n realCandidate = fs.realpathSync(candidate);\n } catch {\n throw new Error(`${label} does not exist`);\n }\n if (!isInside(root, realCandidate)) throw new Error(`${label} escapes its allowed plugin directory`);\n return realCandidate;\n}\n\nfunction normalizeCommand(command: string, pluginRoot: string): string {\n if (!isPluginRelativeCommand(command)) return command;\n const resolved = realContainedPath(pluginRoot, path.resolve(pluginRoot, command), 'command');\n if (!fs.statSync(resolved).isFile()) throw new Error('command must resolve to a regular file');\n try {\n fs.accessSync(resolved, fs.constants.X_OK);\n } catch {\n throw new Error('command must resolve to an executable file');\n }\n return resolved;\n}\n\nfunction normalizeWorkingDirectory(declared: unknown, pluginRoot: string, pluginDataDirectory: string): string {\n const declaredCwd = workingDirectoryCandidate(declared, pluginRoot, pluginDataDirectory);\n if (!declaredCwd) return pluginRoot;\n const resolved = realContainedPath(declaredCwd.base, declaredCwd.candidate, 'cwd');\n if (!fs.statSync(resolved).isDirectory()) throw new Error('cwd must resolve to a directory');\n return resolved;\n}\n\nfunction normalizeServer(\n raw: unknown,\n pluginRoot: string,\n pluginDataDirectory: string,\n name: string,\n): NormalizedServer {\n const type = serverType(raw, name);\n const declaration = raw as JsonObject;\n if (type !== 'stdio') return remoteServer(declaration, name, type);\n const command = normalizeCommand(nonEmptyString(declaration.command, 'command'), pluginRoot);\n const args = optionalStringArray(declaration.args, 'args')?.map((item) =>\n expandPluginPlaceholders(item, pluginRoot, pluginDataDirectory),\n );\n const env = normalizeEnvironment(declaration.env, pluginRoot, pluginDataDirectory);\n const cwd = normalizeWorkingDirectory(declaration.cwd, pluginRoot, pluginDataDirectory);\n return stdioServer(name, { command, ...(args ? { args } : {}), env, cwd });\n}\n\nfunction writeStagedInternalConfig(target: string, contents: string, stagingDirectory: string): void {\n fs.mkdirSync(stagingDirectory, { mode: PRIVATE_DIRECTORY_MODE, recursive: true });\n fs.chmodSync(stagingDirectory, PRIVATE_DIRECTORY_MODE);\n const temporaryPath = `${target}.${process.pid}-${randomUUID()}.tmp`;\n try {\n fs.writeFileSync(temporaryPath, contents, { flag: 'wx', mode: PRIVATE_FILE_MODE });\n try {\n fs.renameSync(temporaryPath, target);\n } catch (error) {\n const code = (error as NodeJS.ErrnoException).code;\n if (code !== 'EEXIST' && code !== 'EPERM') throw error;\n const stat = fs.lstatSync(target);\n if (stat.isSymbolicLink() || !stat.isFile() || fs.readFileSync(target, 'utf8') !== contents) {\n throw new Error('content-addressed staging path is occupied by different content');\n }\n }\n fs.chmodSync(target, PRIVATE_FILE_MODE);\n } finally {\n fs.rmSync(temporaryPath, { force: true });\n }\n}\n\n/**\n * Validates one Agent Plugins v1 `mcp.json` and stages a native mcp-proxy layer.\n *\n * Server validation is isolated: one malformed server is diagnosed and skipped.\n * Document/schema, source identity, or plugin-boundary failures reject the whole\n * source. Only the two portable plugin placeholders are expanded; the staged\n * layer is tagged `internal`, so legacy `${ENV}` interpolation cannot run again.\n *\n * @deprecated Node-only sync shim; use normalizeAgentPluginMcpSourceAsync. Removed in M2.\n */\nexport function normalizeAgentPluginMcpSource(\n source: PoMcpAgentPluginProjectionSource,\n options: NormalizeAgentPluginMcpOptions,\n): NormalizedAgentPluginMcpSource {\n const label = sourceLabel(source);\n try {\n assertProjectionSource(source);\n const pluginRoot = fs.realpathSync(source.pluginRoot);\n try {\n const dataStat = fs.lstatSync(source.pluginDataDirectory);\n if (dataStat.isSymbolicLink() || !dataStat.isDirectory()) {\n throw new Error('pluginDataDirectory must be a real directory');\n }\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error;\n fs.mkdirSync(source.pluginDataDirectory, { mode: PRIVATE_DIRECTORY_MODE, recursive: true });\n }\n fs.chmodSync(source.pluginDataDirectory, PRIVATE_DIRECTORY_MODE);\n fs.accessSync(source.pluginDataDirectory, fs.constants.W_OK);\n const pluginDataDirectory = fs.realpathSync(source.pluginDataDirectory);\n const configPath = realContainedPath(pluginRoot, source.configPath, 'mcp.json');\n assertRootConfigPath(configPath, pluginRoot);\n\n const servers = parseMcpDocument(source, fs.readFileSync(configPath), label);\n const internalServers = Object.create(null) as Record<string, JsonObject>;\n const claudeServers = Object.create(null) as Record<string, JsonObject>;\n const droppedServers: string[] = [];\n const diagnostics: string[] = [];\n\n for (const [name, rawServer] of Object.entries(servers)) {\n const disposition = serverDisposition(name, options);\n if (disposition === 'empty') {\n diagnostics.push(emptyServerDiagnostic(label));\n continue;\n }\n if (disposition === 'dropped') {\n droppedServers.push(name);\n continue;\n }\n try {\n const normalized = normalizeServer(rawServer, pluginRoot, pluginDataDirectory, name);\n internalServers[name] = normalized.internal;\n claudeServers[name] = normalized.claude;\n } catch (error) {\n droppedServers.push(name);\n diagnostics.push(skippedServerDiagnostic(label, name, error));\n }\n }\n\n const contents = stagedContents(internalServers);\n const target = stagedInternalPath(source, contents, options.stagingDirectory);\n writeStagedInternalConfig(target, contents, options.stagingDirectory);\n return {\n configSource: { path: target, format: 'internal', cacheKey: stagedCacheKey(source, configPath, contents) },\n claudeConfig: { mcpServers: claudeServers },\n serverNames: Object.keys(internalServers),\n droppedServers,\n diagnostics,\n };\n } catch (error) {\n return disabledResult(label, error);\n }\n}\n","import path from 'node:path';\n\nimport type { PoMcpAgentPluginProjectionSource } from '@agimon-ai/po-core/mcpProjection';\nimport { type FileSystem, getOrThrow, nodeHost, writeFileAtomic } from '@agimon-ai/po-core/platform';\n\nimport {\n type JsonObject,\n type NormalizeAgentPluginMcpOptions,\n type NormalizedAgentPluginMcpSource,\n type NormalizedServer,\n PRIVATE_DIRECTORY_MODE,\n PRIVATE_FILE_MODE,\n assertProjectionSource,\n assertRootConfigPath,\n disabledResult,\n emptyServerDiagnostic,\n expandPluginPlaceholders,\n isInside,\n isPluginRelativeCommand,\n nonEmptyString,\n normalizeEnvironment,\n optionalStringArray,\n parseMcpDocument,\n remoteServer,\n serverDisposition,\n serverType,\n skippedServerDiagnostic,\n sourceLabel,\n stagedCacheKey,\n stagedContents,\n stagedInternalPath,\n stdioServer,\n workingDirectoryCandidate,\n} from './normalize';\n\nexport type {\n AgentPluginMcpConfigSource,\n NormalizeAgentPluginMcpOptions,\n NormalizedAgentPluginMcpSource,\n} from './normalize';\nexport { normalizeAgentPluginMcpSource } from './sync';\n\ntype Context = Parameters<FileSystem['readTextFile']>[1];\n\nasync function realContainedPath(\n fs: FileSystem,\n root: string,\n candidate: string,\n label: string,\n context: Context,\n): Promise<string> {\n const real = await fs.canonicalPath(candidate, context);\n if (!real.ok) throw new Error(`${label} does not exist`);\n if (!isInside(root, real.value)) throw new Error(`${label} escapes its allowed plugin directory`);\n return real.value;\n}\n\nasync function normalizeCommand(\n fs: FileSystem,\n command: string,\n pluginRoot: string,\n context: Context,\n): Promise<string> {\n if (!isPluginRelativeCommand(command)) return command;\n const resolved = await realContainedPath(fs, pluginRoot, path.resolve(pluginRoot, command), 'command', context);\n if (getOrThrow(await fs.fileInfo(resolved, context)).kind !== 'file') {\n throw new Error('command must resolve to a regular file');\n }\n // Execute bits stand in for access(X_OK); the edge has no modes, so nodeHost reports none and the check is skipped.\n const mode = await nodeHost.fileMode(resolved);\n if (mode !== undefined && (mode & 0o111) === 0) throw new Error('command must resolve to an executable file');\n return resolved;\n}\n\nasync function normalizeWorkingDirectory(\n fs: FileSystem,\n declared: unknown,\n pluginRoot: string,\n pluginDataDirectory: string,\n context: Context,\n): Promise<string> {\n const declaredCwd = workingDirectoryCandidate(declared, pluginRoot, pluginDataDirectory);\n if (!declaredCwd) return pluginRoot;\n const resolved = await realContainedPath(fs, declaredCwd.base, declaredCwd.candidate, 'cwd', context);\n if (getOrThrow(await fs.fileInfo(resolved, context)).kind !== 'directory') {\n throw new Error('cwd must resolve to a directory');\n }\n return resolved;\n}\n\nasync function normalizeServer(\n fs: FileSystem,\n raw: unknown,\n pluginRoot: string,\n pluginDataDirectory: string,\n name: string,\n context: Context,\n): Promise<NormalizedServer> {\n const type = serverType(raw, name);\n const declaration = raw as JsonObject;\n if (type !== 'stdio') return remoteServer(declaration, name, type);\n const command = await normalizeCommand(fs, nonEmptyString(declaration.command, 'command'), pluginRoot, context);\n const args = optionalStringArray(declaration.args, 'args')?.map((item) =>\n expandPluginPlaceholders(item, pluginRoot, pluginDataDirectory),\n );\n const env = normalizeEnvironment(declaration.env, pluginRoot, pluginDataDirectory);\n const cwd = await normalizeWorkingDirectory(fs, declaration.cwd, pluginRoot, pluginDataDirectory, context);\n return stdioServer(name, { command, ...(args ? { args } : {}), env, cwd });\n}\n\n/** Owner-only plugin data directory; a symbolic link or non-directory rejects the source. */\nasync function preparePluginDataDirectory(fs: FileSystem, directory: string, context: Context): Promise<string> {\n const info = await fs.fileInfo(directory, context);\n if (info.ok) {\n if (info.value.kind !== 'directory') throw new Error('pluginDataDirectory must be a real directory');\n } else if (info.error.code === 'not_found') {\n getOrThrow(await fs.createDir(directory, { recursive: true }, context));\n } else {\n throw info.error;\n }\n await nodeHost.setMode(directory, PRIVATE_DIRECTORY_MODE);\n return getOrThrow(await fs.canonicalPath(directory, context));\n}\n\n/**\n * Content-addressed and owner-only. The name hashes the contents, so replacing an\n * existing staged file through a uniquely named temporary file never changes what it holds.\n */\nasync function writeStagedInternalConfig(\n fs: FileSystem,\n target: string,\n contents: string,\n stagingDirectory: string,\n context: Context,\n): Promise<void> {\n getOrThrow(await fs.createDir(stagingDirectory, { recursive: true }, context));\n await nodeHost.setMode(stagingDirectory, PRIVATE_DIRECTORY_MODE);\n await writeFileAtomic(fs, target, contents, context);\n await nodeHost.setMode(target, PRIVATE_FILE_MODE);\n}\n\n/**\n * Validates one Agent Plugins v1 `mcp.json` and stages a native mcp-proxy layer,\n * reading and writing through the injected file system.\n *\n * Server validation is isolated: one malformed server is diagnosed and skipped.\n * Document/schema, source identity, or plugin-boundary failures reject the whole\n * source. Only the two portable plugin placeholders are expanded; the staged\n * layer is tagged `internal`, so legacy `${ENV}` interpolation cannot run again.\n */\nexport async function normalizeAgentPluginMcpSourceAsync(\n fs: FileSystem,\n source: PoMcpAgentPluginProjectionSource,\n options: NormalizeAgentPluginMcpOptions,\n context: Context,\n): Promise<NormalizedAgentPluginMcpSource> {\n const label = sourceLabel(source);\n try {\n assertProjectionSource(source);\n const pluginRoot = getOrThrow(await fs.canonicalPath(source.pluginRoot, context));\n const pluginDataDirectory = await preparePluginDataDirectory(fs, source.pluginDataDirectory, context);\n const configPath = await realContainedPath(fs, pluginRoot, source.configPath, 'mcp.json', context);\n assertRootConfigPath(configPath, pluginRoot);\n\n const bytes = getOrThrow(await fs.readBinaryFile(configPath, context));\n const servers = parseMcpDocument(source, bytes, label);\n const internalServers = Object.create(null) as Record<string, JsonObject>;\n const claudeServers = Object.create(null) as Record<string, JsonObject>;\n const droppedServers: string[] = [];\n const diagnostics: string[] = [];\n\n for (const [name, rawServer] of Object.entries(servers)) {\n const disposition = serverDisposition(name, options);\n if (disposition === 'empty') {\n diagnostics.push(emptyServerDiagnostic(label));\n continue;\n }\n if (disposition === 'dropped') {\n droppedServers.push(name);\n continue;\n }\n try {\n const normalized = await normalizeServer(fs, rawServer, pluginRoot, pluginDataDirectory, name, context);\n internalServers[name] = normalized.internal;\n claudeServers[name] = normalized.claude;\n } catch (error) {\n droppedServers.push(name);\n diagnostics.push(skippedServerDiagnostic(label, name, error));\n }\n }\n\n const contents = stagedContents(internalServers);\n const target = stagedInternalPath(source, contents, options.stagingDirectory);\n await writeStagedInternalConfig(fs, target, contents, options.stagingDirectory, context);\n return {\n configSource: { path: target, format: 'internal', cacheKey: stagedCacheKey(source, configPath, contents) },\n claudeConfig: { mcpServers: claudeServers },\n serverNames: Object.keys(internalServers),\n droppedServers,\n diagnostics,\n };\n } catch (error) {\n return disabledResult(label, error);\n }\n}\n"],"mappings":";;;;;;;;;;;;AAOA,MAAM,aAAa;;AAEnB,MAAM,iCAAiC;AACvC,MAAM,aAAa;AACnB,MAAM,eAAe,IAAI,OAAO,IAAI,WAAW,QAAQ,WAAW,QAAQ,GAAG;AAE7E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WAAW;GACnC,SAAS,OAAO;IACd,eAAe,KAAK,IAAI;IACxB,YAAY,KAAK,wBAAwB,OAAO,MAAM,KAAK,CAAC;GAC9D;EACF;EAEA,MAAM,WAAW,eAAe,eAAe;EAC/C,MAAM,SAAS,mBAAmB,QAAQ,UAAU,QAAQ,gBAAgB;EAC5E,MAAM,0BAA0B,IAAI,QAAQ,UAAU,QAAQ,kBAAkB,OAAO;EACvF,OAAO;GACL,cAAc;IAAE,MAAM;IAAQ,QAAQ;IAAY,UAAU,eAAe,QAAQ,YAAY,QAAQ;GAAE;GACzG,cAAc,EAAE,YAAY,cAAc;GAC1C,aAAa,OAAO,KAAK,eAAe;GACxC;GACA;EACF;CACF,SAAS,OAAO;EACd,OAAO,eAAe,OAAO,KAAK;CACpC;AACF"}
|
|
1
|
+
{"version":3,"file":"agentPluginMcp.cjs","names":["path","createHash","AGENT_PLUGIN_MCP_SCHEMA_URL","realContainedPath","fs","normalizeCommand","path","normalizeWorkingDirectory","normalizeServer","writeStagedInternalConfig","randomUUID","createHash","AGENT_PLUGIN_MCP_SCHEMA_URL","path","getOrThrow","nodeHost","writeFileAtomic"],"sources":["../src/services/agentPluginMcp/normalize.ts","../src/services/agentPluginMcp/sync.ts","../src/services/agentPluginMcp/index.ts"],"sourcesContent":["/** Pure Agent Plugin MCP normalisation shared by the async API and the deprecated Node-only sync shim. */\nimport { createHash } from 'node:crypto';\nimport path from 'node:path';\n\nimport { AGENT_PLUGIN_MCP_SCHEMA_URL, type PoMcpAgentPluginProjectionSource } from '@agimon-ai/po-core/mcpProjection';\n\n/** Same token grammar as node:http `validateHeaderName` (RFC 9110 tchar). */\nconst HTTP_TOKEN = /^[\\^_`a-zA-Z\\-0-9!#$%&'*+.|~]+$/u;\n/** Same rejected characters as node:http `validateHeaderValue`. */\nconst INVALID_HEADER_VALUE_CHARACTER = /[^\\t\\x20-\\x7e\\x80-\\xff]/u;\nconst IPV4_OCTET = '(?:25[0-5]|2[0-4]\\\\d|1\\\\d\\\\d|[1-9]?\\\\d)';\nconst IPV4_ADDRESS = new RegExp(`^${IPV4_OCTET}(?:\\\\.${IPV4_OCTET}){3}$`, 'u');\n\nfunction isIPv4(value: string): boolean {\n return IPV4_ADDRESS.test(value);\n}\n\nexport const PRIVATE_FILE_MODE = 0o600;\nexport const PRIVATE_DIRECTORY_MODE = 0o700;\nexport const RESERVED_ENVIRONMENT_KEYS = new Set(['PLUGIN_ROOT', 'PLUGIN_DATA']);\nexport const PROXY_SERVER_ALIASES = new Set(['mcp-proxy', 'agiflow-proxy']);\n\nexport type JsonObject = Record<string, unknown>;\n\nexport interface AgentPluginMcpConfigSource {\n path: string;\n format: 'internal';\n cacheKey: string;\n}\n\nexport interface NormalizedAgentPluginMcpSource {\n /** Owner-only, content-addressed layer that bypasses Claude env interpolation. */\n configSource?: AgentPluginMcpConfigSource;\n /** Claude-compatible definitions for an external merged config. */\n claudeConfig: { mcpServers: Record<string, JsonObject> };\n serverNames: string[];\n droppedServers: string[];\n diagnostics: string[];\n}\n\nexport interface NormalizeAgentPluginMcpOptions {\n stagingDirectory: string;\n /** Empty and absent lists both mean keep every server. */\n allowedServers?: readonly string[];\n /** Po strips nested wrappers; external-only callers may opt out. */\n stripProxyWrappers?: boolean;\n}\n\nexport interface NormalizedServer {\n internal: JsonObject;\n claude: JsonObject;\n}\n\nexport function isObject(value: unknown): value is JsonObject {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nexport function onlyKeys(value: JsonObject, allowed: readonly string[], label: string): void {\n const unexpected = Object.keys(value).find((key) => !allowed.includes(key));\n if (unexpected) throw new Error(`${label} contains unsupported field \"${unexpected}\"`);\n}\n\nexport function nonEmptyString(value: unknown, label: string): string {\n if (typeof value !== 'string' || value.length === 0) throw new Error(`${label} must be a non-empty string`);\n return value;\n}\n\nexport function optionalStringArray(value: unknown, label: string): string[] | undefined {\n if (value === undefined) return undefined;\n if (!Array.isArray(value)) throw new Error(`${label} must be an array of strings`);\n return value.map((item, index) => {\n if (typeof item !== 'string') throw new Error(`${label}[${index}] must be a string`);\n return item;\n });\n}\n\nfunction optionalStringRecord(value: unknown, label: string): Record<string, string> | undefined {\n if (value === undefined) return undefined;\n if (!isObject(value)) throw new Error(`${label} must be an object of string values`);\n return Object.fromEntries(\n Object.entries(value).map(([key, item]) => {\n if (typeof item !== 'string') throw new Error(`${label}.${key} must be a string`);\n return [key, item];\n }),\n );\n}\n\nexport function expandPluginPlaceholders(value: string, pluginRoot: string, pluginDataDirectory: string): string {\n // The portable contract is a single, non-recursive replacement pass. An\n // unrecognised placeholder remains literal and mcp-proxy must not reinterpret it.\n return value.replace(/\\$\\{PLUGIN_(ROOT|DATA)\\}/gu, (placeholder) =>\n placeholder === '${PLUGIN_ROOT}' ? pluginRoot : pluginDataDirectory,\n );\n}\n\nexport function isInside(root: string, candidate: string): boolean {\n const relative = path.relative(root, candidate);\n return relative === '' || (!relative.startsWith(`..${path.sep}`) && relative !== '..' && !path.isAbsolute(relative));\n}\n\nexport function normalizeEnvironment(\n value: unknown,\n pluginRoot: string,\n pluginDataDirectory: string,\n): Record<string, string> {\n const declared = optionalStringRecord(value, 'env') ?? {};\n for (const key of Object.keys(declared)) {\n const reservedKey = process.platform === 'win32' ? key.toUpperCase() : key;\n if (RESERVED_ENVIRONMENT_KEYS.has(reservedKey)) {\n throw new Error(`env key \"${key}\" is reserved by Agent Plugins`);\n }\n }\n return {\n ...Object.fromEntries(\n Object.entries(declared).map(([key, item]) => [\n key,\n expandPluginPlaceholders(item, pluginRoot, pluginDataDirectory),\n ]),\n ),\n PLUGIN_ROOT: pluginRoot,\n PLUGIN_DATA: pluginDataDirectory,\n };\n}\n\nfunction isLoopbackHost(hostname: string): boolean {\n const bareHostname = hostname.startsWith('[') && hostname.endsWith(']') ? hostname.slice(1, -1) : hostname;\n if (bareHostname.toLowerCase() === 'localhost') return true;\n if (isIPv4(bareHostname)) return bareHostname.split('.')[0] === '127';\n return bareHostname === '::1';\n}\n\nexport function normalizeUrl(value: unknown): string {\n const raw = nonEmptyString(value, 'url');\n let parsed: URL;\n try {\n parsed = new URL(raw);\n } catch {\n throw new Error('url must be an absolute HTTP(S) URL');\n }\n if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {\n throw new Error('url must use http or https');\n }\n if (parsed.username || parsed.password) throw new Error('url must not contain user information');\n if (parsed.hash) throw new Error('url must not contain a fragment');\n if (parsed.protocol === 'http:' && !isLoopbackHost(parsed.hostname)) {\n throw new Error('non-loopback MCP URLs must use https');\n }\n return raw;\n}\n\nexport function normalizeHeaders(value: unknown): Record<string, string> | undefined {\n const headers = optionalStringRecord(value, 'headers');\n if (!headers) return undefined;\n const seen = new Set<string>();\n for (const [name, item] of Object.entries(headers)) {\n const canonical = name.toLowerCase();\n if (seen.has(canonical)) throw new Error(`headers contain duplicate name \"${name}\"`);\n seen.add(canonical);\n if (!HTTP_TOKEN.test(name) || INVALID_HEADER_VALUE_CHARACTER.test(item)) {\n throw new Error(`header \"${name}\" is invalid`);\n }\n }\n return headers;\n}\n\nexport function stagedInternalPath(\n source: PoMcpAgentPluginProjectionSource,\n contents: string,\n stagingDirectory: string,\n): string {\n const digest = createHash('sha256')\n .update(source.sourceId)\n .update('\\0')\n .update(source.contentDigest)\n .update('\\0')\n .update(contents)\n .digest('hex')\n .slice(0, 20);\n return path.join(stagingDirectory, `agent-plugin-mcp-${digest}.internal.json`);\n}\n\nexport function emptyResult(diagnostic: string): NormalizedAgentPluginMcpSource {\n return {\n claudeConfig: { mcpServers: {} },\n serverNames: [],\n droppedServers: [],\n diagnostics: [diagnostic],\n };\n}\n\nexport function sourceLabel(source: PoMcpAgentPluginProjectionSource): string {\n return `Agent Plugin MCP source \"${source.sourceId}\"`;\n}\n\n/** Checks the projection identity before any file is touched. */\nexport function assertProjectionSource(source: PoMcpAgentPluginProjectionSource): void {\n if (source.mcpSchemaUrl !== AGENT_PLUGIN_MCP_SCHEMA_URL) {\n throw new Error(`unsupported schema \"${String(source.mcpSchemaUrl)}\"`);\n }\n if (!path.isAbsolute(source.pluginRoot) || !path.isAbsolute(source.pluginDataDirectory)) {\n throw new Error('pluginRoot and pluginDataDirectory must be absolute');\n }\n}\n\nexport function assertRootConfigPath(configPath: string, pluginRoot: string): void {\n if (path.dirname(configPath) !== pluginRoot || path.basename(configPath) !== 'mcp.json') {\n throw new Error('portable plugin config must be root mcp.json');\n }\n}\n\n/** Verifies the digest and document shape of the raw mcp.json bytes; returns its server map. */\nexport function parseMcpDocument(\n source: PoMcpAgentPluginProjectionSource,\n bytes: Uint8Array,\n label: string,\n): Record<string, unknown> {\n const digest = createHash('sha256').update(bytes).digest('hex');\n if (digest !== source.contentDigest) throw new Error('content digest does not match the projection');\n const parsed: unknown = JSON.parse(new TextDecoder('utf-8', { ignoreBOM: true }).decode(bytes));\n if (!isObject(parsed)) throw new Error('document must be an object');\n onlyKeys(parsed, ['$schema', 'mcpServers'], label);\n if (parsed.$schema !== source.mcpSchemaUrl) throw new Error('$schema does not match the projected schema');\n if (!isObject(parsed.mcpServers)) throw new Error('mcpServers must be an object');\n return parsed.mcpServers;\n}\n\n/** Whether a declared server is skipped (empty name), dropped by the allowlist or wrapper rule, or normalised. */\nexport function serverDisposition(name: string, options: NormalizeAgentPluginMcpOptions): 'empty' | 'dropped' | 'keep' {\n if (!name) return 'empty';\n const allowed = options.allowedServers;\n const keepAll = !allowed || allowed.length === 0;\n const stripProxyWrappers = options.stripProxyWrappers ?? true;\n if ((!keepAll && !allowed.includes(name)) || (stripProxyWrappers && PROXY_SERVER_ALIASES.has(name))) return 'dropped';\n return 'keep';\n}\n\nexport function emptyServerDiagnostic(label: string): string {\n return `${label} contains an empty server name; that entry was skipped.`;\n}\n\nexport function skippedServerDiagnostic(label: string, name: string, error: unknown): string {\n return `${label} skipped server \"${name}\": ${error instanceof Error ? error.message : String(error)}`;\n}\n\nexport function disabledResult(label: string, error: unknown): NormalizedAgentPluginMcpSource {\n return emptyResult(`${label} was disabled: ${error instanceof Error ? error.message : String(error)}`);\n}\n\n/** The declared transport of one server; stdio declarations are also checked for unsupported fields. */\nexport function serverType(raw: unknown, name: string): string {\n if (!isObject(raw)) throw new Error('definition must be an object');\n const type = nonEmptyString(raw.type, 'type');\n if (type === 'stdio') onlyKeys(raw, ['type', 'command', 'args', 'env', 'cwd'], `server \"${name}\"`);\n return type;\n}\n\nexport function stdioServer(\n name: string,\n config: { command: string; args?: string[]; env: Record<string, string>; cwd: string },\n): NormalizedServer {\n return {\n internal: { name, transport: 'stdio', config },\n claude: { type: 'stdio', ...config },\n };\n}\n\n/** A streamable-http or sse server; any other type is unsupported. */\nexport function remoteServer(raw: JsonObject, name: string, type: string): NormalizedServer {\n if (type === 'streamable-http' || type === 'sse') {\n onlyKeys(raw, ['type', 'url', 'headers'], `server \"${name}\"`);\n const url = normalizeUrl(raw.url);\n const headers = normalizeHeaders(raw.headers);\n const transport = type === 'streamable-http' ? 'http' : 'sse';\n const config = { url, ...(headers ? { headers } : {}) };\n return {\n internal: { name, transport, config },\n claude: { type: transport, ...config },\n };\n }\n throw new Error(`unsupported transport type \"${type}\"`);\n}\n\nexport function stagedContents(internalServers: Record<string, JsonObject>): string {\n return `${JSON.stringify({ mcpServers: internalServers }, null, 2)}\\n`;\n}\n\nexport function stagedCacheKey(source: PoMcpAgentPluginProjectionSource, configPath: string, contents: string): string {\n return createHash('sha256')\n .update('agent-plugin-v1\\0')\n .update(source.sourceId)\n .update('\\0')\n .update(source.contentDigest)\n .update('\\0')\n .update(configPath)\n .update('\\0')\n .update(contents)\n .digest('hex');\n}\n\n/** The containment base and expanded path of a declared cwd, or undefined when the plugin root is the default. */\nexport function workingDirectoryCandidate(\n declared: unknown,\n pluginRoot: string,\n pluginDataDirectory: string,\n): { base: string; candidate: string } | undefined {\n if (declared === undefined) return undefined;\n const cwd = nonEmptyString(declared, 'cwd');\n if (cwd.startsWith('./')) return { base: pluginRoot, candidate: path.resolve(pluginRoot, cwd) };\n const expanded = expandPluginPlaceholders(cwd, pluginRoot, pluginDataDirectory);\n if (cwd === '${PLUGIN_ROOT}' || cwd.startsWith('${PLUGIN_ROOT}/')) {\n return { base: pluginRoot, candidate: path.resolve(expanded) };\n }\n if (cwd === '${PLUGIN_DATA}' || cwd.startsWith('${PLUGIN_DATA}/')) {\n return { base: pluginDataDirectory, candidate: path.resolve(expanded) };\n }\n throw new Error('cwd must start with ./, ${PLUGIN_ROOT}, or ${PLUGIN_DATA}');\n}\n\n/** Rejects a command that is neither a bare executable name nor a ./ path; true when it must be resolved. */\nexport function isPluginRelativeCommand(command: string): boolean {\n if (command.startsWith('./')) return true;\n if (command === '.' || command === '..' || /[\\s/\\\\]/u.test(command)) {\n throw new Error('command must be a bare executable name or a ./ path inside the plugin');\n }\n return false;\n}\n","import { createHash, randomUUID } from 'node:crypto';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport {\n AGENT_PLUGIN_MCP_SCHEMA_URL,\n type PoMcpAgentPluginProjectionSource,\n type PoMcpProjectionSource,\n} from '@agimon-ai/po-core/mcpProjection';\n\nimport type { PluginEntry } from '../../types/domains';\nimport {\n type JsonObject,\n type NormalizeAgentPluginMcpOptions,\n type NormalizedAgentPluginMcpSource,\n type NormalizedServer,\n PRIVATE_DIRECTORY_MODE,\n PRIVATE_FILE_MODE,\n assertProjectionSource,\n assertRootConfigPath,\n disabledResult,\n emptyServerDiagnostic,\n expandPluginPlaceholders,\n isInside,\n isPluginRelativeCommand,\n nonEmptyString,\n normalizeEnvironment,\n optionalStringArray,\n parseMcpDocument,\n remoteServer,\n serverDisposition,\n serverType,\n skippedServerDiagnostic,\n sourceLabel,\n stagedCacheKey,\n stagedContents,\n stagedInternalPath,\n stdioServer,\n workingDirectoryCandidate,\n} from './normalize';\n\nfunction realContainedPath(root: string, candidate: string, label: string): string {\n let realCandidate: string;\n try {\n realCandidate = fs.realpathSync(candidate);\n } catch {\n throw new Error(`${label} does not exist`);\n }\n if (!isInside(root, realCandidate)) throw new Error(`${label} escapes its allowed plugin directory`);\n return realCandidate;\n}\n\nfunction normalizeCommand(command: string, pluginRoot: string): string {\n if (!isPluginRelativeCommand(command)) return command;\n const resolved = realContainedPath(pluginRoot, path.resolve(pluginRoot, command), 'command');\n if (!fs.statSync(resolved).isFile()) throw new Error('command must resolve to a regular file');\n try {\n fs.accessSync(resolved, fs.constants.X_OK);\n } catch {\n throw new Error('command must resolve to an executable file');\n }\n return resolved;\n}\n\nfunction normalizeWorkingDirectory(declared: unknown, pluginRoot: string, pluginDataDirectory: string): string {\n const declaredCwd = workingDirectoryCandidate(declared, pluginRoot, pluginDataDirectory);\n if (!declaredCwd) return pluginRoot;\n const resolved = realContainedPath(declaredCwd.base, declaredCwd.candidate, 'cwd');\n if (!fs.statSync(resolved).isDirectory()) throw new Error('cwd must resolve to a directory');\n return resolved;\n}\n\nfunction normalizeServer(\n raw: unknown,\n pluginRoot: string,\n pluginDataDirectory: string,\n name: string,\n): NormalizedServer {\n const type = serverType(raw, name);\n const declaration = raw as JsonObject;\n if (type !== 'stdio') return remoteServer(declaration, name, type);\n const command = normalizeCommand(nonEmptyString(declaration.command, 'command'), pluginRoot);\n const args = optionalStringArray(declaration.args, 'args')?.map((item) =>\n expandPluginPlaceholders(item, pluginRoot, pluginDataDirectory),\n );\n const env = normalizeEnvironment(declaration.env, pluginRoot, pluginDataDirectory);\n const cwd = normalizeWorkingDirectory(declaration.cwd, pluginRoot, pluginDataDirectory);\n return stdioServer(name, { command, ...(args ? { args } : {}), env, cwd });\n}\n\nfunction writeStagedInternalConfig(target: string, contents: string, stagingDirectory: string): void {\n fs.mkdirSync(stagingDirectory, { mode: PRIVATE_DIRECTORY_MODE, recursive: true });\n fs.chmodSync(stagingDirectory, PRIVATE_DIRECTORY_MODE);\n const temporaryPath = `${target}.${process.pid}-${randomUUID()}.tmp`;\n try {\n fs.writeFileSync(temporaryPath, contents, { flag: 'wx', mode: PRIVATE_FILE_MODE });\n try {\n fs.renameSync(temporaryPath, target);\n } catch (error) {\n const code = (error as NodeJS.ErrnoException).code;\n if (code !== 'EEXIST' && code !== 'EPERM') throw error;\n const stat = fs.lstatSync(target);\n if (stat.isSymbolicLink() || !stat.isFile() || fs.readFileSync(target, 'utf8') !== contents) {\n throw new Error('content-addressed staging path is occupied by different content');\n }\n }\n fs.chmodSync(target, PRIVATE_FILE_MODE);\n } finally {\n fs.rmSync(temporaryPath, { force: true });\n }\n}\n\n/**\n * Validates one Agent Plugins v1 `mcp.json` and stages a native mcp-proxy layer.\n *\n * Server validation is isolated: one malformed server is diagnosed and skipped.\n * Document/schema, source identity, or plugin-boundary failures reject the whole\n * source. Only the two portable plugin placeholders are expanded; the staged\n * layer is tagged `internal`, so legacy `${ENV}` interpolation cannot run again.\n *\n * @deprecated Node-only sync shim; use normalizeAgentPluginMcpSourceAsync. Removed in M2.\n */\nexport function normalizeAgentPluginMcpSource(\n source: PoMcpAgentPluginProjectionSource,\n options: NormalizeAgentPluginMcpOptions,\n): NormalizedAgentPluginMcpSource {\n const label = sourceLabel(source);\n try {\n assertProjectionSource(source);\n const pluginRoot = fs.realpathSync(source.pluginRoot);\n try {\n const dataStat = fs.lstatSync(source.pluginDataDirectory);\n if (dataStat.isSymbolicLink() || !dataStat.isDirectory()) {\n throw new Error('pluginDataDirectory must be a real directory');\n }\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error;\n fs.mkdirSync(source.pluginDataDirectory, { mode: PRIVATE_DIRECTORY_MODE, recursive: true });\n }\n fs.chmodSync(source.pluginDataDirectory, PRIVATE_DIRECTORY_MODE);\n fs.accessSync(source.pluginDataDirectory, fs.constants.W_OK);\n const pluginDataDirectory = fs.realpathSync(source.pluginDataDirectory);\n const configPath = realContainedPath(pluginRoot, source.configPath, 'mcp.json');\n assertRootConfigPath(configPath, pluginRoot);\n\n const servers = parseMcpDocument(source, fs.readFileSync(configPath), label);\n const internalServers = Object.create(null) as Record<string, JsonObject>;\n const claudeServers = Object.create(null) as Record<string, JsonObject>;\n const droppedServers: string[] = [];\n const diagnostics: string[] = [];\n\n for (const [name, rawServer] of Object.entries(servers)) {\n const disposition = serverDisposition(name, options);\n if (disposition === 'empty') {\n diagnostics.push(emptyServerDiagnostic(label));\n continue;\n }\n if (disposition === 'dropped') {\n droppedServers.push(name);\n continue;\n }\n try {\n const normalized = normalizeServer(rawServer, pluginRoot, pluginDataDirectory, name);\n internalServers[name] = normalized.internal;\n claudeServers[name] = normalized.claude;\n } catch (error) {\n droppedServers.push(name);\n diagnostics.push(skippedServerDiagnostic(label, name, error));\n }\n }\n\n const contents = stagedContents(internalServers);\n const target = stagedInternalPath(source, contents, options.stagingDirectory);\n writeStagedInternalConfig(target, contents, options.stagingDirectory);\n return {\n configSource: { path: target, format: 'internal', cacheKey: stagedCacheKey(source, configPath, contents) },\n claudeConfig: { mcpServers: claudeServers },\n serverNames: Object.keys(internalServers),\n droppedServers,\n diagnostics,\n };\n } catch (error) {\n return disabledResult(label, error);\n }\n}\n\nconst AGENT_PLUGIN_SCHEMA = 'https://agent-plugins.org/schemas/1.0.0/plugin.schema.json';\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction stablePluginIdentity(entry: PluginEntry): string {\n const source = entry.source;\n const identity =\n source?.type === 'git'\n ? ['git', source.url, source.path ?? '']\n : source?.type === 'npm'\n ? ['npm', source.registry ?? '', source.package]\n : ['local', fs.realpathSync(entry.directory)];\n return createHash('sha256').update(JSON.stringify(identity)).digest('hex');\n}\n\nfunction rootAgentPluginSchema(entry: PluginEntry): string | undefined {\n const manifestPath = path.join(entry.directory, 'plugin.json');\n if (entry.manifest?.path === manifestPath && entry.manifest.agentPluginSchema === AGENT_PLUGIN_SCHEMA) {\n return AGENT_PLUGIN_SCHEMA;\n }\n try {\n const stat = fs.lstatSync(manifestPath);\n if (stat.isSymbolicLink() || !stat.isFile()) return undefined;\n const parsed = JSON.parse(fs.readFileSync(manifestPath, 'utf8')) as unknown;\n return isPlainObject(parsed) && parsed.$schema === AGENT_PLUGIN_SCHEMA ? AGENT_PLUGIN_SCHEMA : undefined;\n } catch {\n return undefined;\n }\n}\n\n/** One plugin's MCP config as a projection source, or nothing when it ships none. Shared by sync and settings. */\nexport async function pluginMcpSource(\n entry: PluginEntry,\n pluginDataRoot: string,\n): Promise<PoMcpProjectionSource | undefined> {\n if (entry.mcp === false) return undefined;\n const pluginRoot = fs.realpathSync(entry.directory);\n const agentPlugin = rootAgentPluginSchema(entry) === AGENT_PLUGIN_SCHEMA;\n const configPath = path.join(pluginRoot, agentPlugin ? 'mcp.json' : '.mcp.json');\n let stat: fs.Stats;\n try {\n stat = await fs.promises.lstat(configPath);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return undefined;\n throw error;\n }\n if (!stat.isFile() || stat.isSymbolicLink()) return undefined;\n const content = await fs.promises.readFile(configPath);\n const contentDigest = createHash('sha256').update(content).digest('hex');\n const pluginId = stablePluginIdentity(entry);\n const sourceId = `plugin:${pluginId}`;\n if (!agentPlugin) return { sourceId, owner: 'plugin', format: 'native', configPath, contentDigest };\n return {\n sourceId,\n owner: 'plugin',\n format: 'agent-plugin-v1',\n configPath,\n contentDigest,\n pluginId,\n pluginRoot,\n pluginDataDirectory: path.join(pluginDataRoot, pluginId),\n mcpSchemaUrl: AGENT_PLUGIN_MCP_SCHEMA_URL,\n };\n}\n","import path from 'node:path';\n\nimport type { PoMcpAgentPluginProjectionSource } from '@agimon-ai/po-core/mcpProjection';\nimport { type FileSystem, getOrThrow, nodeHost, writeFileAtomic } from '@agimon-ai/po-core/platform';\n\nimport {\n type JsonObject,\n type NormalizeAgentPluginMcpOptions,\n type NormalizedAgentPluginMcpSource,\n type NormalizedServer,\n PRIVATE_DIRECTORY_MODE,\n PRIVATE_FILE_MODE,\n assertProjectionSource,\n assertRootConfigPath,\n disabledResult,\n emptyServerDiagnostic,\n expandPluginPlaceholders,\n isInside,\n isPluginRelativeCommand,\n nonEmptyString,\n normalizeEnvironment,\n optionalStringArray,\n parseMcpDocument,\n remoteServer,\n serverDisposition,\n serverType,\n skippedServerDiagnostic,\n sourceLabel,\n stagedCacheKey,\n stagedContents,\n stagedInternalPath,\n stdioServer,\n workingDirectoryCandidate,\n} from './normalize';\n\nexport type {\n AgentPluginMcpConfigSource,\n NormalizeAgentPluginMcpOptions,\n NormalizedAgentPluginMcpSource,\n} from './normalize';\nexport { normalizeAgentPluginMcpSource, pluginMcpSource } from './sync';\n\ntype Context = Parameters<FileSystem['readTextFile']>[1];\n\nasync function realContainedPath(\n fs: FileSystem,\n root: string,\n candidate: string,\n label: string,\n context: Context,\n): Promise<string> {\n const real = await fs.canonicalPath(candidate, context);\n if (!real.ok) throw new Error(`${label} does not exist`);\n if (!isInside(root, real.value)) throw new Error(`${label} escapes its allowed plugin directory`);\n return real.value;\n}\n\nasync function normalizeCommand(\n fs: FileSystem,\n command: string,\n pluginRoot: string,\n context: Context,\n): Promise<string> {\n if (!isPluginRelativeCommand(command)) return command;\n const resolved = await realContainedPath(fs, pluginRoot, path.resolve(pluginRoot, command), 'command', context);\n if (getOrThrow(await fs.fileInfo(resolved, context)).kind !== 'file') {\n throw new Error('command must resolve to a regular file');\n }\n // Execute bits stand in for access(X_OK); the edge has no modes, so nodeHost reports none and the check is skipped.\n const mode = await nodeHost.fileMode(resolved);\n if (mode !== undefined && (mode & 0o111) === 0) throw new Error('command must resolve to an executable file');\n return resolved;\n}\n\nasync function normalizeWorkingDirectory(\n fs: FileSystem,\n declared: unknown,\n pluginRoot: string,\n pluginDataDirectory: string,\n context: Context,\n): Promise<string> {\n const declaredCwd = workingDirectoryCandidate(declared, pluginRoot, pluginDataDirectory);\n if (!declaredCwd) return pluginRoot;\n const resolved = await realContainedPath(fs, declaredCwd.base, declaredCwd.candidate, 'cwd', context);\n if (getOrThrow(await fs.fileInfo(resolved, context)).kind !== 'directory') {\n throw new Error('cwd must resolve to a directory');\n }\n return resolved;\n}\n\nasync function normalizeServer(\n fs: FileSystem,\n raw: unknown,\n pluginRoot: string,\n pluginDataDirectory: string,\n name: string,\n context: Context,\n): Promise<NormalizedServer> {\n const type = serverType(raw, name);\n const declaration = raw as JsonObject;\n if (type !== 'stdio') return remoteServer(declaration, name, type);\n const command = await normalizeCommand(fs, nonEmptyString(declaration.command, 'command'), pluginRoot, context);\n const args = optionalStringArray(declaration.args, 'args')?.map((item) =>\n expandPluginPlaceholders(item, pluginRoot, pluginDataDirectory),\n );\n const env = normalizeEnvironment(declaration.env, pluginRoot, pluginDataDirectory);\n const cwd = await normalizeWorkingDirectory(fs, declaration.cwd, pluginRoot, pluginDataDirectory, context);\n return stdioServer(name, { command, ...(args ? { args } : {}), env, cwd });\n}\n\n/** Owner-only plugin data directory; a symbolic link or non-directory rejects the source. */\nasync function preparePluginDataDirectory(fs: FileSystem, directory: string, context: Context): Promise<string> {\n const info = await fs.fileInfo(directory, context);\n if (info.ok) {\n if (info.value.kind !== 'directory') throw new Error('pluginDataDirectory must be a real directory');\n } else if (info.error.code === 'not_found') {\n getOrThrow(await fs.createDir(directory, { recursive: true }, context));\n } else {\n throw info.error;\n }\n await nodeHost.setMode(directory, PRIVATE_DIRECTORY_MODE);\n return getOrThrow(await fs.canonicalPath(directory, context));\n}\n\n/**\n * Content-addressed and owner-only. The name hashes the contents, so replacing an\n * existing staged file through a uniquely named temporary file never changes what it holds.\n */\nasync function writeStagedInternalConfig(\n fs: FileSystem,\n target: string,\n contents: string,\n stagingDirectory: string,\n context: Context,\n): Promise<void> {\n getOrThrow(await fs.createDir(stagingDirectory, { recursive: true }, context));\n await nodeHost.setMode(stagingDirectory, PRIVATE_DIRECTORY_MODE);\n await writeFileAtomic(fs, target, contents, context);\n await nodeHost.setMode(target, PRIVATE_FILE_MODE);\n}\n\n/**\n * Validates one Agent Plugins v1 `mcp.json` and stages a native mcp-proxy layer,\n * reading and writing through the injected file system.\n *\n * Server validation is isolated: one malformed server is diagnosed and skipped.\n * Document/schema, source identity, or plugin-boundary failures reject the whole\n * source. Only the two portable plugin placeholders are expanded; the staged\n * layer is tagged `internal`, so legacy `${ENV}` interpolation cannot run again.\n */\nexport async function normalizeAgentPluginMcpSourceAsync(\n fs: FileSystem,\n source: PoMcpAgentPluginProjectionSource,\n options: NormalizeAgentPluginMcpOptions,\n context: Context,\n): Promise<NormalizedAgentPluginMcpSource> {\n const label = sourceLabel(source);\n try {\n assertProjectionSource(source);\n const pluginRoot = getOrThrow(await fs.canonicalPath(source.pluginRoot, context));\n const pluginDataDirectory = await preparePluginDataDirectory(fs, source.pluginDataDirectory, context);\n const configPath = await realContainedPath(fs, pluginRoot, source.configPath, 'mcp.json', context);\n assertRootConfigPath(configPath, pluginRoot);\n\n const bytes = getOrThrow(await fs.readBinaryFile(configPath, context));\n const servers = parseMcpDocument(source, bytes, label);\n const internalServers = Object.create(null) as Record<string, JsonObject>;\n const claudeServers = Object.create(null) as Record<string, JsonObject>;\n const droppedServers: string[] = [];\n const diagnostics: string[] = [];\n\n for (const [name, rawServer] of Object.entries(servers)) {\n const disposition = serverDisposition(name, options);\n if (disposition === 'empty') {\n diagnostics.push(emptyServerDiagnostic(label));\n continue;\n }\n if (disposition === 'dropped') {\n droppedServers.push(name);\n continue;\n }\n try {\n const normalized = await normalizeServer(fs, rawServer, pluginRoot, pluginDataDirectory, name, context);\n internalServers[name] = normalized.internal;\n claudeServers[name] = normalized.claude;\n } catch (error) {\n droppedServers.push(name);\n diagnostics.push(skippedServerDiagnostic(label, name, error));\n }\n }\n\n const contents = stagedContents(internalServers);\n const target = stagedInternalPath(source, contents, options.stagingDirectory);\n await writeStagedInternalConfig(fs, target, contents, options.stagingDirectory, context);\n return {\n configSource: { path: target, format: 'internal', cacheKey: stagedCacheKey(source, configPath, contents) },\n claudeConfig: { mcpServers: claudeServers },\n serverNames: Object.keys(internalServers),\n droppedServers,\n diagnostics,\n };\n } catch (error) {\n return disabledResult(label, error);\n }\n}\n"],"mappings":";;;;;;;;;;;;AAOA,MAAM,aAAa;;AAEnB,MAAM,iCAAiC;AACvC,MAAM,aAAa;AACnB,M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|
1
2
|
import { FileSystem } from "@agimon-ai/po-core/platform";
|
|
2
|
-
import { PoMcpAgentPluginProjectionSource } from "@agimon-ai/po-core/mcpProjection";
|
|
3
|
+
import { PoMcpAgentPluginProjectionSource, PoMcpProjectionSource } from "@agimon-ai/po-core/mcpProjection";
|
|
3
4
|
//#region src/services/agentPluginMcp/normalize.d.ts
|
|
4
5
|
type JsonObject = Record<string, unknown>;
|
|
5
6
|
interface AgentPluginMcpConfigSource {
|
|
@@ -38,6 +39,8 @@ interface NormalizeAgentPluginMcpOptions {
|
|
|
38
39
|
* @deprecated Node-only sync shim; use normalizeAgentPluginMcpSourceAsync. Removed in M2.
|
|
39
40
|
*/
|
|
40
41
|
export declare function normalizeAgentPluginMcpSource(source: PoMcpAgentPluginProjectionSource, options: NormalizeAgentPluginMcpOptions): NormalizedAgentPluginMcpSource;
|
|
42
|
+
/** One plugin's MCP config as a projection source, or nothing when it ships none. Shared by sync and settings. */
|
|
43
|
+
export declare function pluginMcpSource(entry: PluginEntry, pluginDataRoot: string): Promise<PoMcpProjectionSource | undefined>;
|
|
41
44
|
//#endregion
|
|
42
45
|
//#region src/services/agentPluginMcp/index.d.ts
|
|
43
46
|
type Context = Parameters<FileSystem['readTextFile']>[1];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentPluginMcp.d.mts","names":[],"sources":["../src/services/agentPluginMcp/normalize.ts","../src/services/agentPluginMcp/sync.ts","../src/services/agentPluginMcp/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"agentPluginMcp.d.mts","names":[],"sources":["../src/services/agentPluginMcp/normalize.ts","../src/services/agentPluginMcp/sync.ts","../src/services/agentPluginMcp/index.ts"],"mappings":";;;;KAsBY,aAAa;UAER;EACf;EACA;EACA;;UAGe;;EAEf,eAAe;;EAEf;IAAgB,YAAY,eAAe;;EAC3C;EACA;EACA;;UAGe;EACf;;EAEA;;EAEA;;;;;;;;;;;;;;wBC6Ec,8BACd,QAAQ,kCACR,SAAS,iCACR;;wBA8FmB,gBACpB,OAAO,aACP,yBACC,QAAQ;;;KCpLN,UAAU,WAAW;;;;;;;;;;wBA4GJ,mCACpB,IAAI,YACJ,QAAQ,kCACR,SAAS,gCACT,SAAS,UACR,QAAQ"}
|
package/dist/agentPluginMcp.mjs
CHANGED
|
@@ -373,6 +373,72 @@ function normalizeAgentPluginMcpSource(source, options) {
|
|
|
373
373
|
return disabledResult(label, error);
|
|
374
374
|
}
|
|
375
375
|
}
|
|
376
|
+
const AGENT_PLUGIN_SCHEMA = "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json";
|
|
377
|
+
function isPlainObject(value) {
|
|
378
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
379
|
+
}
|
|
380
|
+
function stablePluginIdentity(entry) {
|
|
381
|
+
const source = entry.source;
|
|
382
|
+
const identity = source?.type === "git" ? [
|
|
383
|
+
"git",
|
|
384
|
+
source.url,
|
|
385
|
+
source.path ?? ""
|
|
386
|
+
] : source?.type === "npm" ? [
|
|
387
|
+
"npm",
|
|
388
|
+
source.registry ?? "",
|
|
389
|
+
source.package
|
|
390
|
+
] : ["local", fs.realpathSync(entry.directory)];
|
|
391
|
+
return createHash("sha256").update(JSON.stringify(identity)).digest("hex");
|
|
392
|
+
}
|
|
393
|
+
function rootAgentPluginSchema(entry) {
|
|
394
|
+
const manifestPath = path.join(entry.directory, "plugin.json");
|
|
395
|
+
if (entry.manifest?.path === manifestPath && entry.manifest.agentPluginSchema === AGENT_PLUGIN_SCHEMA) return AGENT_PLUGIN_SCHEMA;
|
|
396
|
+
try {
|
|
397
|
+
const stat = fs.lstatSync(manifestPath);
|
|
398
|
+
if (stat.isSymbolicLink() || !stat.isFile()) return void 0;
|
|
399
|
+
const parsed = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
|
|
400
|
+
return isPlainObject(parsed) && parsed.$schema === AGENT_PLUGIN_SCHEMA ? AGENT_PLUGIN_SCHEMA : void 0;
|
|
401
|
+
} catch {
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
/** One plugin's MCP config as a projection source, or nothing when it ships none. Shared by sync and settings. */
|
|
406
|
+
async function pluginMcpSource(entry, pluginDataRoot) {
|
|
407
|
+
if (entry.mcp === false) return void 0;
|
|
408
|
+
const pluginRoot = fs.realpathSync(entry.directory);
|
|
409
|
+
const agentPlugin = rootAgentPluginSchema(entry) === AGENT_PLUGIN_SCHEMA;
|
|
410
|
+
const configPath = path.join(pluginRoot, agentPlugin ? "mcp.json" : ".mcp.json");
|
|
411
|
+
let stat;
|
|
412
|
+
try {
|
|
413
|
+
stat = await fs.promises.lstat(configPath);
|
|
414
|
+
} catch (error) {
|
|
415
|
+
if (error.code === "ENOENT") return void 0;
|
|
416
|
+
throw error;
|
|
417
|
+
}
|
|
418
|
+
if (!stat.isFile() || stat.isSymbolicLink()) return void 0;
|
|
419
|
+
const content = await fs.promises.readFile(configPath);
|
|
420
|
+
const contentDigest = createHash("sha256").update(content).digest("hex");
|
|
421
|
+
const pluginId = stablePluginIdentity(entry);
|
|
422
|
+
const sourceId = `plugin:${pluginId}`;
|
|
423
|
+
if (!agentPlugin) return {
|
|
424
|
+
sourceId,
|
|
425
|
+
owner: "plugin",
|
|
426
|
+
format: "native",
|
|
427
|
+
configPath,
|
|
428
|
+
contentDigest
|
|
429
|
+
};
|
|
430
|
+
return {
|
|
431
|
+
sourceId,
|
|
432
|
+
owner: "plugin",
|
|
433
|
+
format: "agent-plugin-v1",
|
|
434
|
+
configPath,
|
|
435
|
+
contentDigest,
|
|
436
|
+
pluginId,
|
|
437
|
+
pluginRoot,
|
|
438
|
+
pluginDataDirectory: path.join(pluginDataRoot, pluginId),
|
|
439
|
+
mcpSchemaUrl: AGENT_PLUGIN_MCP_SCHEMA_URL
|
|
440
|
+
};
|
|
441
|
+
}
|
|
376
442
|
//#endregion
|
|
377
443
|
//#region src/services/agentPluginMcp/index.ts
|
|
378
444
|
async function realContainedPath(fs, root, candidate, label, context) {
|
|
@@ -491,6 +557,6 @@ async function normalizeAgentPluginMcpSourceAsync(fs, source, options, context)
|
|
|
491
557
|
}
|
|
492
558
|
}
|
|
493
559
|
//#endregion
|
|
494
|
-
export { normalizeAgentPluginMcpSource, normalizeAgentPluginMcpSourceAsync };
|
|
560
|
+
export { normalizeAgentPluginMcpSource, normalizeAgentPluginMcpSourceAsync, pluginMcpSource };
|
|
495
561
|
|
|
496
562
|
//# sourceMappingURL=agentPluginMcp.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentPluginMcp.mjs","names":["realContainedPath","normalizeCommand","normalizeWorkingDirectory","normalizeServer","writeStagedInternalConfig"],"sources":["../src/services/agentPluginMcp/normalize.ts","../src/services/agentPluginMcp/sync.ts","../src/services/agentPluginMcp/index.ts"],"sourcesContent":["/** Pure Agent Plugin MCP normalisation shared by the async API and the deprecated Node-only sync shim. */\nimport { createHash } from 'node:crypto';\nimport path from 'node:path';\n\nimport { AGENT_PLUGIN_MCP_SCHEMA_URL, type PoMcpAgentPluginProjectionSource } from '@agimon-ai/po-core/mcpProjection';\n\n/** Same token grammar as node:http `validateHeaderName` (RFC 9110 tchar). */\nconst HTTP_TOKEN = /^[\\^_`a-zA-Z\\-0-9!#$%&'*+.|~]+$/u;\n/** Same rejected characters as node:http `validateHeaderValue`. */\nconst INVALID_HEADER_VALUE_CHARACTER = /[^\\t\\x20-\\x7e\\x80-\\xff]/u;\nconst IPV4_OCTET = '(?:25[0-5]|2[0-4]\\\\d|1\\\\d\\\\d|[1-9]?\\\\d)';\nconst IPV4_ADDRESS = new RegExp(`^${IPV4_OCTET}(?:\\\\.${IPV4_OCTET}){3}$`, 'u');\n\nfunction isIPv4(value: string): boolean {\n return IPV4_ADDRESS.test(value);\n}\n\nexport const PRIVATE_FILE_MODE = 0o600;\nexport const PRIVATE_DIRECTORY_MODE = 0o700;\nexport const RESERVED_ENVIRONMENT_KEYS = new Set(['PLUGIN_ROOT', 'PLUGIN_DATA']);\nexport const PROXY_SERVER_ALIASES = new Set(['mcp-proxy', 'agiflow-proxy']);\n\nexport type JsonObject = Record<string, unknown>;\n\nexport interface AgentPluginMcpConfigSource {\n path: string;\n format: 'internal';\n cacheKey: string;\n}\n\nexport interface NormalizedAgentPluginMcpSource {\n /** Owner-only, content-addressed layer that bypasses Claude env interpolation. */\n configSource?: AgentPluginMcpConfigSource;\n /** Claude-compatible definitions for an external merged config. */\n claudeConfig: { mcpServers: Record<string, JsonObject> };\n serverNames: string[];\n droppedServers: string[];\n diagnostics: string[];\n}\n\nexport interface NormalizeAgentPluginMcpOptions {\n stagingDirectory: string;\n /** Empty and absent lists both mean keep every server. */\n allowedServers?: readonly string[];\n /** Po strips nested wrappers; external-only callers may opt out. */\n stripProxyWrappers?: boolean;\n}\n\nexport interface NormalizedServer {\n internal: JsonObject;\n claude: JsonObject;\n}\n\nexport function isObject(value: unknown): value is JsonObject {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nexport function onlyKeys(value: JsonObject, allowed: readonly string[], label: string): void {\n const unexpected = Object.keys(value).find((key) => !allowed.includes(key));\n if (unexpected) throw new Error(`${label} contains unsupported field \"${unexpected}\"`);\n}\n\nexport function nonEmptyString(value: unknown, label: string): string {\n if (typeof value !== 'string' || value.length === 0) throw new Error(`${label} must be a non-empty string`);\n return value;\n}\n\nexport function optionalStringArray(value: unknown, label: string): string[] | undefined {\n if (value === undefined) return undefined;\n if (!Array.isArray(value)) throw new Error(`${label} must be an array of strings`);\n return value.map((item, index) => {\n if (typeof item !== 'string') throw new Error(`${label}[${index}] must be a string`);\n return item;\n });\n}\n\nfunction optionalStringRecord(value: unknown, label: string): Record<string, string> | undefined {\n if (value === undefined) return undefined;\n if (!isObject(value)) throw new Error(`${label} must be an object of string values`);\n return Object.fromEntries(\n Object.entries(value).map(([key, item]) => {\n if (typeof item !== 'string') throw new Error(`${label}.${key} must be a string`);\n return [key, item];\n }),\n );\n}\n\nexport function expandPluginPlaceholders(value: string, pluginRoot: string, pluginDataDirectory: string): string {\n // The portable contract is a single, non-recursive replacement pass. An\n // unrecognised placeholder remains literal and mcp-proxy must not reinterpret it.\n return value.replace(/\\$\\{PLUGIN_(ROOT|DATA)\\}/gu, (placeholder) =>\n placeholder === '${PLUGIN_ROOT}' ? pluginRoot : pluginDataDirectory,\n );\n}\n\nexport function isInside(root: string, candidate: string): boolean {\n const relative = path.relative(root, candidate);\n return relative === '' || (!relative.startsWith(`..${path.sep}`) && relative !== '..' && !path.isAbsolute(relative));\n}\n\nexport function normalizeEnvironment(\n value: unknown,\n pluginRoot: string,\n pluginDataDirectory: string,\n): Record<string, string> {\n const declared = optionalStringRecord(value, 'env') ?? {};\n for (const key of Object.keys(declared)) {\n const reservedKey = process.platform === 'win32' ? key.toUpperCase() : key;\n if (RESERVED_ENVIRONMENT_KEYS.has(reservedKey)) {\n throw new Error(`env key \"${key}\" is reserved by Agent Plugins`);\n }\n }\n return {\n ...Object.fromEntries(\n Object.entries(declared).map(([key, item]) => [\n key,\n expandPluginPlaceholders(item, pluginRoot, pluginDataDirectory),\n ]),\n ),\n PLUGIN_ROOT: pluginRoot,\n PLUGIN_DATA: pluginDataDirectory,\n };\n}\n\nfunction isLoopbackHost(hostname: string): boolean {\n const bareHostname = hostname.startsWith('[') && hostname.endsWith(']') ? hostname.slice(1, -1) : hostname;\n if (bareHostname.toLowerCase() === 'localhost') return true;\n if (isIPv4(bareHostname)) return bareHostname.split('.')[0] === '127';\n return bareHostname === '::1';\n}\n\nexport function normalizeUrl(value: unknown): string {\n const raw = nonEmptyString(value, 'url');\n let parsed: URL;\n try {\n parsed = new URL(raw);\n } catch {\n throw new Error('url must be an absolute HTTP(S) URL');\n }\n if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {\n throw new Error('url must use http or https');\n }\n if (parsed.username || parsed.password) throw new Error('url must not contain user information');\n if (parsed.hash) throw new Error('url must not contain a fragment');\n if (parsed.protocol === 'http:' && !isLoopbackHost(parsed.hostname)) {\n throw new Error('non-loopback MCP URLs must use https');\n }\n return raw;\n}\n\nexport function normalizeHeaders(value: unknown): Record<string, string> | undefined {\n const headers = optionalStringRecord(value, 'headers');\n if (!headers) return undefined;\n const seen = new Set<string>();\n for (const [name, item] of Object.entries(headers)) {\n const canonical = name.toLowerCase();\n if (seen.has(canonical)) throw new Error(`headers contain duplicate name \"${name}\"`);\n seen.add(canonical);\n if (!HTTP_TOKEN.test(name) || INVALID_HEADER_VALUE_CHARACTER.test(item)) {\n throw new Error(`header \"${name}\" is invalid`);\n }\n }\n return headers;\n}\n\nexport function stagedInternalPath(\n source: PoMcpAgentPluginProjectionSource,\n contents: string,\n stagingDirectory: string,\n): string {\n const digest = createHash('sha256')\n .update(source.sourceId)\n .update('\\0')\n .update(source.contentDigest)\n .update('\\0')\n .update(contents)\n .digest('hex')\n .slice(0, 20);\n return path.join(stagingDirectory, `agent-plugin-mcp-${digest}.internal.json`);\n}\n\nexport function emptyResult(diagnostic: string): NormalizedAgentPluginMcpSource {\n return {\n claudeConfig: { mcpServers: {} },\n serverNames: [],\n droppedServers: [],\n diagnostics: [diagnostic],\n };\n}\n\nexport function sourceLabel(source: PoMcpAgentPluginProjectionSource): string {\n return `Agent Plugin MCP source \"${source.sourceId}\"`;\n}\n\n/** Checks the projection identity before any file is touched. */\nexport function assertProjectionSource(source: PoMcpAgentPluginProjectionSource): void {\n if (source.mcpSchemaUrl !== AGENT_PLUGIN_MCP_SCHEMA_URL) {\n throw new Error(`unsupported schema \"${String(source.mcpSchemaUrl)}\"`);\n }\n if (!path.isAbsolute(source.pluginRoot) || !path.isAbsolute(source.pluginDataDirectory)) {\n throw new Error('pluginRoot and pluginDataDirectory must be absolute');\n }\n}\n\nexport function assertRootConfigPath(configPath: string, pluginRoot: string): void {\n if (path.dirname(configPath) !== pluginRoot || path.basename(configPath) !== 'mcp.json') {\n throw new Error('portable plugin config must be root mcp.json');\n }\n}\n\n/** Verifies the digest and document shape of the raw mcp.json bytes; returns its server map. */\nexport function parseMcpDocument(\n source: PoMcpAgentPluginProjectionSource,\n bytes: Uint8Array,\n label: string,\n): Record<string, unknown> {\n const digest = createHash('sha256').update(bytes).digest('hex');\n if (digest !== source.contentDigest) throw new Error('content digest does not match the projection');\n const parsed: unknown = JSON.parse(new TextDecoder('utf-8', { ignoreBOM: true }).decode(bytes));\n if (!isObject(parsed)) throw new Error('document must be an object');\n onlyKeys(parsed, ['$schema', 'mcpServers'], label);\n if (parsed.$schema !== source.mcpSchemaUrl) throw new Error('$schema does not match the projected schema');\n if (!isObject(parsed.mcpServers)) throw new Error('mcpServers must be an object');\n return parsed.mcpServers;\n}\n\n/** Whether a declared server is skipped (empty name), dropped by the allowlist or wrapper rule, or normalised. */\nexport function serverDisposition(name: string, options: NormalizeAgentPluginMcpOptions): 'empty' | 'dropped' | 'keep' {\n if (!name) return 'empty';\n const allowed = options.allowedServers;\n const keepAll = !allowed || allowed.length === 0;\n const stripProxyWrappers = options.stripProxyWrappers ?? true;\n if ((!keepAll && !allowed.includes(name)) || (stripProxyWrappers && PROXY_SERVER_ALIASES.has(name))) return 'dropped';\n return 'keep';\n}\n\nexport function emptyServerDiagnostic(label: string): string {\n return `${label} contains an empty server name; that entry was skipped.`;\n}\n\nexport function skippedServerDiagnostic(label: string, name: string, error: unknown): string {\n return `${label} skipped server \"${name}\": ${error instanceof Error ? error.message : String(error)}`;\n}\n\nexport function disabledResult(label: string, error: unknown): NormalizedAgentPluginMcpSource {\n return emptyResult(`${label} was disabled: ${error instanceof Error ? error.message : String(error)}`);\n}\n\n/** The declared transport of one server; stdio declarations are also checked for unsupported fields. */\nexport function serverType(raw: unknown, name: string): string {\n if (!isObject(raw)) throw new Error('definition must be an object');\n const type = nonEmptyString(raw.type, 'type');\n if (type === 'stdio') onlyKeys(raw, ['type', 'command', 'args', 'env', 'cwd'], `server \"${name}\"`);\n return type;\n}\n\nexport function stdioServer(\n name: string,\n config: { command: string; args?: string[]; env: Record<string, string>; cwd: string },\n): NormalizedServer {\n return {\n internal: { name, transport: 'stdio', config },\n claude: { type: 'stdio', ...config },\n };\n}\n\n/** A streamable-http or sse server; any other type is unsupported. */\nexport function remoteServer(raw: JsonObject, name: string, type: string): NormalizedServer {\n if (type === 'streamable-http' || type === 'sse') {\n onlyKeys(raw, ['type', 'url', 'headers'], `server \"${name}\"`);\n const url = normalizeUrl(raw.url);\n const headers = normalizeHeaders(raw.headers);\n const transport = type === 'streamable-http' ? 'http' : 'sse';\n const config = { url, ...(headers ? { headers } : {}) };\n return {\n internal: { name, transport, config },\n claude: { type: transport, ...config },\n };\n }\n throw new Error(`unsupported transport type \"${type}\"`);\n}\n\nexport function stagedContents(internalServers: Record<string, JsonObject>): string {\n return `${JSON.stringify({ mcpServers: internalServers }, null, 2)}\\n`;\n}\n\nexport function stagedCacheKey(source: PoMcpAgentPluginProjectionSource, configPath: string, contents: string): string {\n return createHash('sha256')\n .update('agent-plugin-v1\\0')\n .update(source.sourceId)\n .update('\\0')\n .update(source.contentDigest)\n .update('\\0')\n .update(configPath)\n .update('\\0')\n .update(contents)\n .digest('hex');\n}\n\n/** The containment base and expanded path of a declared cwd, or undefined when the plugin root is the default. */\nexport function workingDirectoryCandidate(\n declared: unknown,\n pluginRoot: string,\n pluginDataDirectory: string,\n): { base: string; candidate: string } | undefined {\n if (declared === undefined) return undefined;\n const cwd = nonEmptyString(declared, 'cwd');\n if (cwd.startsWith('./')) return { base: pluginRoot, candidate: path.resolve(pluginRoot, cwd) };\n const expanded = expandPluginPlaceholders(cwd, pluginRoot, pluginDataDirectory);\n if (cwd === '${PLUGIN_ROOT}' || cwd.startsWith('${PLUGIN_ROOT}/')) {\n return { base: pluginRoot, candidate: path.resolve(expanded) };\n }\n if (cwd === '${PLUGIN_DATA}' || cwd.startsWith('${PLUGIN_DATA}/')) {\n return { base: pluginDataDirectory, candidate: path.resolve(expanded) };\n }\n throw new Error('cwd must start with ./, ${PLUGIN_ROOT}, or ${PLUGIN_DATA}');\n}\n\n/** Rejects a command that is neither a bare executable name nor a ./ path; true when it must be resolved. */\nexport function isPluginRelativeCommand(command: string): boolean {\n if (command.startsWith('./')) return true;\n if (command === '.' || command === '..' || /[\\s/\\\\]/u.test(command)) {\n throw new Error('command must be a bare executable name or a ./ path inside the plugin');\n }\n return false;\n}\n","import { randomUUID } from 'node:crypto';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport type { PoMcpAgentPluginProjectionSource } from '@agimon-ai/po-core/mcpProjection';\n\nimport {\n type JsonObject,\n type NormalizeAgentPluginMcpOptions,\n type NormalizedAgentPluginMcpSource,\n type NormalizedServer,\n PRIVATE_DIRECTORY_MODE,\n PRIVATE_FILE_MODE,\n assertProjectionSource,\n assertRootConfigPath,\n disabledResult,\n emptyServerDiagnostic,\n expandPluginPlaceholders,\n isInside,\n isPluginRelativeCommand,\n nonEmptyString,\n normalizeEnvironment,\n optionalStringArray,\n parseMcpDocument,\n remoteServer,\n serverDisposition,\n serverType,\n skippedServerDiagnostic,\n sourceLabel,\n stagedCacheKey,\n stagedContents,\n stagedInternalPath,\n stdioServer,\n workingDirectoryCandidate,\n} from './normalize';\n\nfunction realContainedPath(root: string, candidate: string, label: string): string {\n let realCandidate: string;\n try {\n realCandidate = fs.realpathSync(candidate);\n } catch {\n throw new Error(`${label} does not exist`);\n }\n if (!isInside(root, realCandidate)) throw new Error(`${label} escapes its allowed plugin directory`);\n return realCandidate;\n}\n\nfunction normalizeCommand(command: string, pluginRoot: string): string {\n if (!isPluginRelativeCommand(command)) return command;\n const resolved = realContainedPath(pluginRoot, path.resolve(pluginRoot, command), 'command');\n if (!fs.statSync(resolved).isFile()) throw new Error('command must resolve to a regular file');\n try {\n fs.accessSync(resolved, fs.constants.X_OK);\n } catch {\n throw new Error('command must resolve to an executable file');\n }\n return resolved;\n}\n\nfunction normalizeWorkingDirectory(declared: unknown, pluginRoot: string, pluginDataDirectory: string): string {\n const declaredCwd = workingDirectoryCandidate(declared, pluginRoot, pluginDataDirectory);\n if (!declaredCwd) return pluginRoot;\n const resolved = realContainedPath(declaredCwd.base, declaredCwd.candidate, 'cwd');\n if (!fs.statSync(resolved).isDirectory()) throw new Error('cwd must resolve to a directory');\n return resolved;\n}\n\nfunction normalizeServer(\n raw: unknown,\n pluginRoot: string,\n pluginDataDirectory: string,\n name: string,\n): NormalizedServer {\n const type = serverType(raw, name);\n const declaration = raw as JsonObject;\n if (type !== 'stdio') return remoteServer(declaration, name, type);\n const command = normalizeCommand(nonEmptyString(declaration.command, 'command'), pluginRoot);\n const args = optionalStringArray(declaration.args, 'args')?.map((item) =>\n expandPluginPlaceholders(item, pluginRoot, pluginDataDirectory),\n );\n const env = normalizeEnvironment(declaration.env, pluginRoot, pluginDataDirectory);\n const cwd = normalizeWorkingDirectory(declaration.cwd, pluginRoot, pluginDataDirectory);\n return stdioServer(name, { command, ...(args ? { args } : {}), env, cwd });\n}\n\nfunction writeStagedInternalConfig(target: string, contents: string, stagingDirectory: string): void {\n fs.mkdirSync(stagingDirectory, { mode: PRIVATE_DIRECTORY_MODE, recursive: true });\n fs.chmodSync(stagingDirectory, PRIVATE_DIRECTORY_MODE);\n const temporaryPath = `${target}.${process.pid}-${randomUUID()}.tmp`;\n try {\n fs.writeFileSync(temporaryPath, contents, { flag: 'wx', mode: PRIVATE_FILE_MODE });\n try {\n fs.renameSync(temporaryPath, target);\n } catch (error) {\n const code = (error as NodeJS.ErrnoException).code;\n if (code !== 'EEXIST' && code !== 'EPERM') throw error;\n const stat = fs.lstatSync(target);\n if (stat.isSymbolicLink() || !stat.isFile() || fs.readFileSync(target, 'utf8') !== contents) {\n throw new Error('content-addressed staging path is occupied by different content');\n }\n }\n fs.chmodSync(target, PRIVATE_FILE_MODE);\n } finally {\n fs.rmSync(temporaryPath, { force: true });\n }\n}\n\n/**\n * Validates one Agent Plugins v1 `mcp.json` and stages a native mcp-proxy layer.\n *\n * Server validation is isolated: one malformed server is diagnosed and skipped.\n * Document/schema, source identity, or plugin-boundary failures reject the whole\n * source. Only the two portable plugin placeholders are expanded; the staged\n * layer is tagged `internal`, so legacy `${ENV}` interpolation cannot run again.\n *\n * @deprecated Node-only sync shim; use normalizeAgentPluginMcpSourceAsync. Removed in M2.\n */\nexport function normalizeAgentPluginMcpSource(\n source: PoMcpAgentPluginProjectionSource,\n options: NormalizeAgentPluginMcpOptions,\n): NormalizedAgentPluginMcpSource {\n const label = sourceLabel(source);\n try {\n assertProjectionSource(source);\n const pluginRoot = fs.realpathSync(source.pluginRoot);\n try {\n const dataStat = fs.lstatSync(source.pluginDataDirectory);\n if (dataStat.isSymbolicLink() || !dataStat.isDirectory()) {\n throw new Error('pluginDataDirectory must be a real directory');\n }\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error;\n fs.mkdirSync(source.pluginDataDirectory, { mode: PRIVATE_DIRECTORY_MODE, recursive: true });\n }\n fs.chmodSync(source.pluginDataDirectory, PRIVATE_DIRECTORY_MODE);\n fs.accessSync(source.pluginDataDirectory, fs.constants.W_OK);\n const pluginDataDirectory = fs.realpathSync(source.pluginDataDirectory);\n const configPath = realContainedPath(pluginRoot, source.configPath, 'mcp.json');\n assertRootConfigPath(configPath, pluginRoot);\n\n const servers = parseMcpDocument(source, fs.readFileSync(configPath), label);\n const internalServers = Object.create(null) as Record<string, JsonObject>;\n const claudeServers = Object.create(null) as Record<string, JsonObject>;\n const droppedServers: string[] = [];\n const diagnostics: string[] = [];\n\n for (const [name, rawServer] of Object.entries(servers)) {\n const disposition = serverDisposition(name, options);\n if (disposition === 'empty') {\n diagnostics.push(emptyServerDiagnostic(label));\n continue;\n }\n if (disposition === 'dropped') {\n droppedServers.push(name);\n continue;\n }\n try {\n const normalized = normalizeServer(rawServer, pluginRoot, pluginDataDirectory, name);\n internalServers[name] = normalized.internal;\n claudeServers[name] = normalized.claude;\n } catch (error) {\n droppedServers.push(name);\n diagnostics.push(skippedServerDiagnostic(label, name, error));\n }\n }\n\n const contents = stagedContents(internalServers);\n const target = stagedInternalPath(source, contents, options.stagingDirectory);\n writeStagedInternalConfig(target, contents, options.stagingDirectory);\n return {\n configSource: { path: target, format: 'internal', cacheKey: stagedCacheKey(source, configPath, contents) },\n claudeConfig: { mcpServers: claudeServers },\n serverNames: Object.keys(internalServers),\n droppedServers,\n diagnostics,\n };\n } catch (error) {\n return disabledResult(label, error);\n }\n}\n","import path from 'node:path';\n\nimport type { PoMcpAgentPluginProjectionSource } from '@agimon-ai/po-core/mcpProjection';\nimport { type FileSystem, getOrThrow, nodeHost, writeFileAtomic } from '@agimon-ai/po-core/platform';\n\nimport {\n type JsonObject,\n type NormalizeAgentPluginMcpOptions,\n type NormalizedAgentPluginMcpSource,\n type NormalizedServer,\n PRIVATE_DIRECTORY_MODE,\n PRIVATE_FILE_MODE,\n assertProjectionSource,\n assertRootConfigPath,\n disabledResult,\n emptyServerDiagnostic,\n expandPluginPlaceholders,\n isInside,\n isPluginRelativeCommand,\n nonEmptyString,\n normalizeEnvironment,\n optionalStringArray,\n parseMcpDocument,\n remoteServer,\n serverDisposition,\n serverType,\n skippedServerDiagnostic,\n sourceLabel,\n stagedCacheKey,\n stagedContents,\n stagedInternalPath,\n stdioServer,\n workingDirectoryCandidate,\n} from './normalize';\n\nexport type {\n AgentPluginMcpConfigSource,\n NormalizeAgentPluginMcpOptions,\n NormalizedAgentPluginMcpSource,\n} from './normalize';\nexport { normalizeAgentPluginMcpSource } from './sync';\n\ntype Context = Parameters<FileSystem['readTextFile']>[1];\n\nasync function realContainedPath(\n fs: FileSystem,\n root: string,\n candidate: string,\n label: string,\n context: Context,\n): Promise<string> {\n const real = await fs.canonicalPath(candidate, context);\n if (!real.ok) throw new Error(`${label} does not exist`);\n if (!isInside(root, real.value)) throw new Error(`${label} escapes its allowed plugin directory`);\n return real.value;\n}\n\nasync function normalizeCommand(\n fs: FileSystem,\n command: string,\n pluginRoot: string,\n context: Context,\n): Promise<string> {\n if (!isPluginRelativeCommand(command)) return command;\n const resolved = await realContainedPath(fs, pluginRoot, path.resolve(pluginRoot, command), 'command', context);\n if (getOrThrow(await fs.fileInfo(resolved, context)).kind !== 'file') {\n throw new Error('command must resolve to a regular file');\n }\n // Execute bits stand in for access(X_OK); the edge has no modes, so nodeHost reports none and the check is skipped.\n const mode = await nodeHost.fileMode(resolved);\n if (mode !== undefined && (mode & 0o111) === 0) throw new Error('command must resolve to an executable file');\n return resolved;\n}\n\nasync function normalizeWorkingDirectory(\n fs: FileSystem,\n declared: unknown,\n pluginRoot: string,\n pluginDataDirectory: string,\n context: Context,\n): Promise<string> {\n const declaredCwd = workingDirectoryCandidate(declared, pluginRoot, pluginDataDirectory);\n if (!declaredCwd) return pluginRoot;\n const resolved = await realContainedPath(fs, declaredCwd.base, declaredCwd.candidate, 'cwd', context);\n if (getOrThrow(await fs.fileInfo(resolved, context)).kind !== 'directory') {\n throw new Error('cwd must resolve to a directory');\n }\n return resolved;\n}\n\nasync function normalizeServer(\n fs: FileSystem,\n raw: unknown,\n pluginRoot: string,\n pluginDataDirectory: string,\n name: string,\n context: Context,\n): Promise<NormalizedServer> {\n const type = serverType(raw, name);\n const declaration = raw as JsonObject;\n if (type !== 'stdio') return remoteServer(declaration, name, type);\n const command = await normalizeCommand(fs, nonEmptyString(declaration.command, 'command'), pluginRoot, context);\n const args = optionalStringArray(declaration.args, 'args')?.map((item) =>\n expandPluginPlaceholders(item, pluginRoot, pluginDataDirectory),\n );\n const env = normalizeEnvironment(declaration.env, pluginRoot, pluginDataDirectory);\n const cwd = await normalizeWorkingDirectory(fs, declaration.cwd, pluginRoot, pluginDataDirectory, context);\n return stdioServer(name, { command, ...(args ? { args } : {}), env, cwd });\n}\n\n/** Owner-only plugin data directory; a symbolic link or non-directory rejects the source. */\nasync function preparePluginDataDirectory(fs: FileSystem, directory: string, context: Context): Promise<string> {\n const info = await fs.fileInfo(directory, context);\n if (info.ok) {\n if (info.value.kind !== 'directory') throw new Error('pluginDataDirectory must be a real directory');\n } else if (info.error.code === 'not_found') {\n getOrThrow(await fs.createDir(directory, { recursive: true }, context));\n } else {\n throw info.error;\n }\n await nodeHost.setMode(directory, PRIVATE_DIRECTORY_MODE);\n return getOrThrow(await fs.canonicalPath(directory, context));\n}\n\n/**\n * Content-addressed and owner-only. The name hashes the contents, so replacing an\n * existing staged file through a uniquely named temporary file never changes what it holds.\n */\nasync function writeStagedInternalConfig(\n fs: FileSystem,\n target: string,\n contents: string,\n stagingDirectory: string,\n context: Context,\n): Promise<void> {\n getOrThrow(await fs.createDir(stagingDirectory, { recursive: true }, context));\n await nodeHost.setMode(stagingDirectory, PRIVATE_DIRECTORY_MODE);\n await writeFileAtomic(fs, target, contents, context);\n await nodeHost.setMode(target, PRIVATE_FILE_MODE);\n}\n\n/**\n * Validates one Agent Plugins v1 `mcp.json` and stages a native mcp-proxy layer,\n * reading and writing through the injected file system.\n *\n * Server validation is isolated: one malformed server is diagnosed and skipped.\n * Document/schema, source identity, or plugin-boundary failures reject the whole\n * source. Only the two portable plugin placeholders are expanded; the staged\n * layer is tagged `internal`, so legacy `${ENV}` interpolation cannot run again.\n */\nexport async function normalizeAgentPluginMcpSourceAsync(\n fs: FileSystem,\n source: PoMcpAgentPluginProjectionSource,\n options: NormalizeAgentPluginMcpOptions,\n context: Context,\n): Promise<NormalizedAgentPluginMcpSource> {\n const label = sourceLabel(source);\n try {\n assertProjectionSource(source);\n const pluginRoot = getOrThrow(await fs.canonicalPath(source.pluginRoot, context));\n const pluginDataDirectory = await preparePluginDataDirectory(fs, source.pluginDataDirectory, context);\n const configPath = await realContainedPath(fs, pluginRoot, source.configPath, 'mcp.json', context);\n assertRootConfigPath(configPath, pluginRoot);\n\n const bytes = getOrThrow(await fs.readBinaryFile(configPath, context));\n const servers = parseMcpDocument(source, bytes, label);\n const internalServers = Object.create(null) as Record<string, JsonObject>;\n const claudeServers = Object.create(null) as Record<string, JsonObject>;\n const droppedServers: string[] = [];\n const diagnostics: string[] = [];\n\n for (const [name, rawServer] of Object.entries(servers)) {\n const disposition = serverDisposition(name, options);\n if (disposition === 'empty') {\n diagnostics.push(emptyServerDiagnostic(label));\n continue;\n }\n if (disposition === 'dropped') {\n droppedServers.push(name);\n continue;\n }\n try {\n const normalized = await normalizeServer(fs, rawServer, pluginRoot, pluginDataDirectory, name, context);\n internalServers[name] = normalized.internal;\n claudeServers[name] = normalized.claude;\n } catch (error) {\n droppedServers.push(name);\n diagnostics.push(skippedServerDiagnostic(label, name, error));\n }\n }\n\n const contents = stagedContents(internalServers);\n const target = stagedInternalPath(source, contents, options.stagingDirectory);\n await writeStagedInternalConfig(fs, target, contents, options.stagingDirectory, context);\n return {\n configSource: { path: target, format: 'internal', cacheKey: stagedCacheKey(source, configPath, contents) },\n claudeConfig: { mcpServers: claudeServers },\n serverNames: Object.keys(internalServers),\n droppedServers,\n diagnostics,\n };\n } catch (error) {\n return disabledResult(label, error);\n }\n}\n"],"mappings":";;;;;;;;AAOA,MAAM,aAAa;;AAEnB,MAAM,iCAAiC;AACvC,MAAM,aAAa;AACnB,MAAM,eAAe,IAAI,OAAO,IAAI,WAAW,QAAQ,WAAW,QAAQ,GAAG;AAE7E,SAAS,OAAO,OAAwB;CACtC,OAAO,aAAa,KAAK,KAAK;AAChC;AAIA,MAAa,4CAA4B,IAAI,IAAI,CAAC,eAAe,aAAa,CAAC;AAC/E,MAAa,uCAAuB,IAAI,IAAI,CAAC,aAAa,eAAe,CAAC;AAiC1E,SAAgB,SAAS,OAAqC;CAC5D,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,SAAgB,SAAS,OAAmB,SAA4B,OAAqB;CAC3F,MAAM,aAAa,OAAO,KAAK,KAAK,CAAC,CAAC,MAAM,QAAQ,CAAC,QAAQ,SAAS,GAAG,CAAC;CAC1E,IAAI,YAAY,MAAM,IAAI,MAAM,GAAG,MAAM,+BAA+B,WAAW,EAAE;AACvF;AAEA,SAAgB,eAAe,OAAgB,OAAuB;CACpE,IAAI,OAAO,UAAU,YAAY,MAAM,WAAW,GAAG,MAAM,IAAI,MAAM,GAA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qBAAqB,MAAM,OAAO;IACtG,gBAAgB,QAAQ,WAAW;IACnC,cAAc,QAAQ,WAAW;GACnC,SAAS,OAAO;IACd,eAAe,KAAK,IAAI;IACxB,YAAY,KAAK,wBAAwB,OAAO,MAAM,KAAK,CAAC;GAC9D;EACF;EAEA,MAAM,WAAW,eAAe,eAAe;EAC/C,MAAM,SAAS,mBAAmB,QAAQ,UAAU,QAAQ,gBAAgB;EAC5E,MAAM,0BAA0B,IAAI,QAAQ,UAAU,QAAQ,kBAAkB,OAAO;EACvF,OAAO;GACL,cAAc;IAAE,MAAM;IAAQ,QAAQ;IAAY,UAAU,eAAe,QAAQ,YAAY,QAAQ;GAAE;GACzG,cAAc,EAAE,YAAY,cAAc;GAC1C,aAAa,OAAO,KAAK,eAAe;GACxC;GACA;EACF;CACF,SAAS,OAAO;EACd,OAAO,eAAe,OAAO,KAAK;CACpC;AACF"}
|
|
1
|
+
{"version":3,"file":"agentPluginMcp.mjs","names":["realContainedPath","normalizeCommand","normalizeWorkingDirectory","normalizeServer","writeStagedInternalConfig"],"sources":["../src/services/agentPluginMcp/normalize.ts","../src/services/agentPluginMcp/sync.ts","../src/services/agentPluginMcp/index.ts"],"sourcesContent":["/** Pure Agent Plugin MCP normalisation shared by the async API and the deprecated Node-only sync shim. */\nimport { createHash } from 'node:crypto';\nimport path from 'node:path';\n\nimport { AGENT_PLUGIN_MCP_SCHEMA_URL, type PoMcpAgentPluginProjectionSource } from '@agimon-ai/po-core/mcpProjection';\n\n/** Same token grammar as node:http `validateHeaderName` (RFC 9110 tchar). */\nconst HTTP_TOKEN = /^[\\^_`a-zA-Z\\-0-9!#$%&'*+.|~]+$/u;\n/** Same rejected characters as node:http `validateHeaderValue`. */\nconst INVALID_HEADER_VALUE_CHARACTER = /[^\\t\\x20-\\x7e\\x80-\\xff]/u;\nconst IPV4_OCTET = '(?:25[0-5]|2[0-4]\\\\d|1\\\\d\\\\d|[1-9]?\\\\d)';\nconst IPV4_ADDRESS = new RegExp(`^${IPV4_OCTET}(?:\\\\.${IPV4_OCTET}){3}$`, 'u');\n\nfunction isIPv4(value: string): boolean {\n return IPV4_ADDRESS.test(value);\n}\n\nexport const PRIVATE_FILE_MODE = 0o600;\nexport const PRIVATE_DIRECTORY_MODE = 0o700;\nexport const RESERVED_ENVIRONMENT_KEYS = new Set(['PLUGIN_ROOT', 'PLUGIN_DATA']);\nexport const PROXY_SERVER_ALIASES = new Set(['mcp-proxy', 'agiflow-proxy']);\n\nexport type JsonObject = Record<string, unknown>;\n\nexport interface AgentPluginMcpConfigSource {\n path: string;\n format: 'internal';\n cacheKey: string;\n}\n\nexport interface NormalizedAgentPluginMcpSource {\n /** Owner-only, content-addressed layer that bypasses Claude env interpolation. */\n configSource?: AgentPluginMcpConfigSource;\n /** Claude-compatible definitions for an external merged config. */\n claudeConfig: { mcpServers: Record<string, JsonObject> };\n serverNames: string[];\n droppedServers: string[];\n diagnostics: string[];\n}\n\nexport interface NormalizeAgentPluginMcpOptions {\n stagingDirectory: string;\n /** Empty and absent lists both mean keep every server. */\n allowedServers?: readonly string[];\n /** Po strips nested wrappers; external-only callers may opt out. */\n stripProxyWrappers?: boolean;\n}\n\nexport interface NormalizedServer {\n internal: JsonObject;\n claude: JsonObject;\n}\n\nexport function isObject(value: unknown): value is JsonObject {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nexport function onlyKeys(value: JsonObject, allowed: readonly string[], label: string): void {\n const unexpected = Object.keys(value).find((key) => !allowed.includes(key));\n if (unexpected) throw new Error(`${label} contains unsupported field \"${unexpected}\"`);\n}\n\nexport function nonEmptyString(value: unknown, label: string): string {\n if (typeof value !== 'string' || value.length === 0) throw new Error(`${label} must be a non-empty string`);\n return value;\n}\n\nexport function optionalStringArray(value: unknown, label: string): string[] | undefined {\n if (value === undefined) return undefined;\n if (!Array.isArray(value)) throw new Error(`${label} must be an array of strings`);\n return value.map((item, index) => {\n if (typeof item !== 'string') throw new Error(`${label}[${index}] must be a string`);\n return item;\n });\n}\n\nfunction optionalStringRecord(value: unknown, label: string): Record<string, string> | undefined {\n if (value === undefined) return undefined;\n if (!isObject(value)) throw new Error(`${label} must be an object of string values`);\n return Object.fromEntries(\n Object.entries(value).map(([key, item]) => {\n if (typeof item !== 'string') throw new Error(`${label}.${key} must be a string`);\n return [key, item];\n }),\n );\n}\n\nexport function expandPluginPlaceholders(value: string, pluginRoot: string, pluginDataDirectory: string): string {\n // The portable contract is a single, non-recursive replacement pass. An\n // unrecognised placeholder remains literal and mcp-proxy must not reinterpret it.\n return value.replace(/\\$\\{PLUGIN_(ROOT|DATA)\\}/gu, (placeholder) =>\n placeholder === '${PLUGIN_ROOT}' ? pluginRoot : pluginDataDirectory,\n );\n}\n\nexport function isInside(root: string, candidate: string): boolean {\n const relative = path.relative(root, candidate);\n return relative === '' || (!relative.startsWith(`..${path.sep}`) && relative !== '..' && !path.isAbsolute(relative));\n}\n\nexport function normalizeEnvironment(\n value: unknown,\n pluginRoot: string,\n pluginDataDirectory: string,\n): Record<string, string> {\n const declared = optionalStringRecord(value, 'env') ?? {};\n for (const key of Object.keys(declared)) {\n const reservedKey = process.platform === 'win32' ? key.toUpperCase() : key;\n if (RESERVED_ENVIRONMENT_KEYS.has(reservedKey)) {\n throw new Error(`env key \"${key}\" is reserved by Agent Plugins`);\n }\n }\n return {\n ...Object.fromEntries(\n Object.entries(declared).map(([key, item]) => [\n key,\n expandPluginPlaceholders(item, pluginRoot, pluginDataDirectory),\n ]),\n ),\n PLUGIN_ROOT: pluginRoot,\n PLUGIN_DATA: pluginDataDirectory,\n };\n}\n\nfunction isLoopbackHost(hostname: string): boolean {\n const bareHostname = hostname.startsWith('[') && hostname.endsWith(']') ? hostname.slice(1, -1) : hostname;\n if (bareHostname.toLowerCase() === 'localhost') return true;\n if (isIPv4(bareHostname)) return bareHostname.split('.')[0] === '127';\n return bareHostname === '::1';\n}\n\nexport function normalizeUrl(value: unknown): string {\n const raw = nonEmptyString(value, 'url');\n let parsed: URL;\n try {\n parsed = new URL(raw);\n } catch {\n throw new Error('url must be an absolute HTTP(S) URL');\n }\n if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {\n throw new Error('url must use http or https');\n }\n if (parsed.username || parsed.password) throw new Error('url must not contain user information');\n if (parsed.hash) throw new Error('url must not contain a fragment');\n if (parsed.protocol === 'http:' && !isLoopbackHost(parsed.hostname)) {\n throw new Error('non-loopback MCP URLs must use https');\n }\n return raw;\n}\n\nexport function normalizeHeaders(value: unknown): Record<string, string> | undefined {\n const headers = optionalStringRecord(value, 'headers');\n if (!headers) return undefined;\n const seen = new Set<string>();\n for (const [name, item] of Object.entries(headers)) {\n const canonical = name.toLowerCase();\n if (seen.has(canonical)) throw new Error(`headers contain duplicate name \"${name}\"`);\n seen.add(canonical);\n if (!HTTP_TOKEN.test(name) || INVALID_HEADER_VALUE_CHARACTER.test(item)) {\n throw new Error(`header \"${name}\" is invalid`);\n }\n }\n return headers;\n}\n\nexport function stagedInternalPath(\n source: PoMcpAgentPluginProjectionSource,\n contents: string,\n stagingDirectory: string,\n): string {\n const digest = createHash('sha256')\n .update(source.sourceId)\n .update('\\0')\n .update(source.contentDigest)\n .update('\\0')\n .update(contents)\n .digest('hex')\n .slice(0, 20);\n return path.join(stagingDirectory, `agent-plugin-mcp-${digest}.internal.json`);\n}\n\nexport function emptyResult(diagnostic: string): NormalizedAgentPluginMcpSource {\n return {\n claudeConfig: { mcpServers: {} },\n serverNames: [],\n droppedServers: [],\n diagnostics: [diagnostic],\n };\n}\n\nexport function sourceLabel(source: PoMcpAgentPluginProjectionSource): string {\n return `Agent Plugin MCP source \"${source.sourceId}\"`;\n}\n\n/** Checks the projection identity before any file is touched. */\nexport function assertProjectionSource(source: PoMcpAgentPluginProjectionSource): void {\n if (source.mcpSchemaUrl !== AGENT_PLUGIN_MCP_SCHEMA_URL) {\n throw new Error(`unsupported schema \"${String(source.mcpSchemaUrl)}\"`);\n }\n if (!path.isAbsolute(source.pluginRoot) || !path.isAbsolute(source.pluginDataDirectory)) {\n throw new Error('pluginRoot and pluginDataDirectory must be absolute');\n }\n}\n\nexport function assertRootConfigPath(configPath: string, pluginRoot: string): void {\n if (path.dirname(configPath) !== pluginRoot || path.basename(configPath) !== 'mcp.json') {\n throw new Error('portable plugin config must be root mcp.json');\n }\n}\n\n/** Verifies the digest and document shape of the raw mcp.json bytes; returns its server map. */\nexport function parseMcpDocument(\n source: PoMcpAgentPluginProjectionSource,\n bytes: Uint8Array,\n label: string,\n): Record<string, unknown> {\n const digest = createHash('sha256').update(bytes).digest('hex');\n if (digest !== source.contentDigest) throw new Error('content digest does not match the projection');\n const parsed: unknown = JSON.parse(new TextDecoder('utf-8', { ignoreBOM: true }).decode(bytes));\n if (!isObject(parsed)) throw new Error('document must be an object');\n onlyKeys(parsed, ['$schema', 'mcpServers'], label);\n if (parsed.$schema !== source.mcpSchemaUrl) throw new Error('$schema does not match the projected schema');\n if (!isObject(parsed.mcpServers)) throw new Error('mcpServers must be an object');\n return parsed.mcpServers;\n}\n\n/** Whether a declared server is skipped (empty name), dropped by the allowlist or wrapper rule, or normalised. */\nexport function serverDisposition(name: string, options: NormalizeAgentPluginMcpOptions): 'empty' | 'dropped' | 'keep' {\n if (!name) return 'empty';\n const allowed = options.allowedServers;\n const keepAll = !allowed || allowed.length === 0;\n const stripProxyWrappers = options.stripProxyWrappers ?? true;\n if ((!keepAll && !allowed.includes(name)) || (stripProxyWrappers && PROXY_SERVER_ALIASES.has(name))) return 'dropped';\n return 'keep';\n}\n\nexport function emptyServerDiagnostic(label: string): string {\n return `${label} contains an empty server name; that entry was skipped.`;\n}\n\nexport function skippedServerDiagnostic(label: string, name: string, error: unknown): string {\n return `${label} skipped server \"${name}\": ${error instanceof Error ? error.message : String(error)}`;\n}\n\nexport function disabledResult(label: string, error: unknown): NormalizedAgentPluginMcpSource {\n return emptyResult(`${label} was disabled: ${error instanceof Error ? error.message : String(error)}`);\n}\n\n/** The declared transport of one server; stdio declarations are also checked for unsupported fields. */\nexport function serverType(raw: unknown, name: string): string {\n if (!isObject(raw)) throw new Error('definition must be an object');\n const type = nonEmptyString(raw.type, 'type');\n if (type === 'stdio') onlyKeys(raw, ['type', 'command', 'args', 'env', 'cwd'], `server \"${name}\"`);\n return type;\n}\n\nexport function stdioServer(\n name: string,\n config: { command: string; args?: string[]; env: Record<string, string>; cwd: string },\n): NormalizedServer {\n return {\n internal: { name, transport: 'stdio', config },\n claude: { type: 'stdio', ...config },\n };\n}\n\n/** A streamable-http or sse server; any other type is unsupported. */\nexport function remoteServer(raw: JsonObject, name: string, type: string): NormalizedServer {\n if (type === 'streamable-http' || type === 'sse') {\n onlyKeys(raw, ['type', 'url', 'headers'], `server \"${name}\"`);\n const url = normalizeUrl(raw.url);\n const headers = normalizeHeaders(raw.headers);\n const transport = type === 'streamable-http' ? 'http' : 'sse';\n const config = { url, ...(headers ? { headers } : {}) };\n return {\n internal: { name, transport, config },\n claude: { type: transport, ...config },\n };\n }\n throw new Error(`unsupported transport type \"${type}\"`);\n}\n\nexport function stagedContents(internalServers: Record<string, JsonObject>): string {\n return `${JSON.stringify({ mcpServers: internalServers }, null, 2)}\\n`;\n}\n\nexport function stagedCacheKey(source: PoMcpAgentPluginProjectionSource, configPath: string, contents: string): string {\n return createHash('sha256')\n .update('agent-plugin-v1\\0')\n .update(source.sourceId)\n .update('\\0')\n .update(source.contentDigest)\n .update('\\0')\n .update(configPath)\n .update('\\0')\n .update(contents)\n .digest('hex');\n}\n\n/** The containment base and expanded path of a declared cwd, or undefined when the plugin root is the default. */\nexport function workingDirectoryCandidate(\n declared: unknown,\n pluginRoot: string,\n pluginDataDirectory: string,\n): { base: string; candidate: string } | undefined {\n if (declared === undefined) return undefined;\n const cwd = nonEmptyString(declared, 'cwd');\n if (cwd.startsWith('./')) return { base: pluginRoot, candidate: path.resolve(pluginRoot, cwd) };\n const expanded = expandPluginPlaceholders(cwd, pluginRoot, pluginDataDirectory);\n if (cwd === '${PLUGIN_ROOT}' || cwd.startsWith('${PLUGIN_ROOT}/')) {\n return { base: pluginRoot, candidate: path.resolve(expanded) };\n }\n if (cwd === '${PLUGIN_DATA}' || cwd.startsWith('${PLUGIN_DATA}/')) {\n return { base: pluginDataDirectory, candidate: path.resolve(expanded) };\n }\n throw new Error('cwd must start with ./, ${PLUGIN_ROOT}, or ${PLUGIN_DATA}');\n}\n\n/** Rejects a command that is neither a bare executable name nor a ./ path; true when it must be resolved. */\nexport function isPluginRelativeCommand(command: string): boolean {\n if (command.startsWith('./')) return true;\n if (command === '.' || command === '..' || /[\\s/\\\\]/u.test(command)) {\n throw new Error('command must be a bare executable name or a ./ path inside the plugin');\n }\n return false;\n}\n","import { createHash, randomUUID } from 'node:crypto';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport {\n AGENT_PLUGIN_MCP_SCHEMA_URL,\n type PoMcpAgentPluginProjectionSource,\n type PoMcpProjectionSource,\n} from '@agimon-ai/po-core/mcpProjection';\n\nimport type { PluginEntry } from '../../types/domains';\nimport {\n type JsonObject,\n type NormalizeAgentPluginMcpOptions,\n type NormalizedAgentPluginMcpSource,\n type NormalizedServer,\n PRIVATE_DIRECTORY_MODE,\n PRIVATE_FILE_MODE,\n assertProjectionSource,\n assertRootConfigPath,\n disabledResult,\n emptyServerDiagnostic,\n expandPluginPlaceholders,\n isInside,\n isPluginRelativeCommand,\n nonEmptyString,\n normalizeEnvironment,\n optionalStringArray,\n parseMcpDocument,\n remoteServer,\n serverDisposition,\n serverType,\n skippedServerDiagnostic,\n sourceLabel,\n stagedCacheKey,\n stagedContents,\n stagedInternalPath,\n stdioServer,\n workingDirectoryCandidate,\n} from './normalize';\n\nfunction realContainedPath(root: string, candidate: string, label: string): string {\n let realCandidate: string;\n try {\n realCandidate = fs.realpathSync(candidate);\n } catch {\n throw new Error(`${label} does not exist`);\n }\n if (!isInside(root, realCandidate)) throw new Error(`${label} escapes its allowed plugin directory`);\n return realCandidate;\n}\n\nfunction normalizeCommand(command: string, pluginRoot: string): string {\n if (!isPluginRelativeCommand(command)) return command;\n const resolved = realContainedPath(pluginRoot, path.resolve(pluginRoot, command), 'command');\n if (!fs.statSync(resolved).isFile()) throw new Error('command must resolve to a regular file');\n try {\n fs.accessSync(resolved, fs.constants.X_OK);\n } catch {\n throw new Error('command must resolve to an executable file');\n }\n return resolved;\n}\n\nfunction normalizeWorkingDirectory(declared: unknown, pluginRoot: string, pluginDataDirectory: string): string {\n const declaredCwd = workingDirectoryCandidate(declared, pluginRoot, pluginDataDirectory);\n if (!declaredCwd) return pluginRoot;\n const resolved = realContainedPath(declaredCwd.base, declaredCwd.candidate, 'cwd');\n if (!fs.statSync(resolved).isDirectory()) throw new Error('cwd must resolve to a directory');\n return resolved;\n}\n\nfunction normalizeServer(\n raw: unknown,\n pluginRoot: string,\n pluginDataDirectory: string,\n name: string,\n): NormalizedServer {\n const type = serverType(raw, name);\n const declaration = raw as JsonObject;\n if (type !== 'stdio') return remoteServer(declaration, name, type);\n const command = normalizeCommand(nonEmptyString(declaration.command, 'command'), pluginRoot);\n const args = optionalStringArray(declaration.args, 'args')?.map((item) =>\n expandPluginPlaceholders(item, pluginRoot, pluginDataDirectory),\n );\n const env = normalizeEnvironment(declaration.env, pluginRoot, pluginDataDirectory);\n const cwd = normalizeWorkingDirectory(declaration.cwd, pluginRoot, pluginDataDirectory);\n return stdioServer(name, { command, ...(args ? { args } : {}), env, cwd });\n}\n\nfunction writeStagedInternalConfig(target: string, contents: string, stagingDirectory: string): void {\n fs.mkdirSync(stagingDirectory, { mode: PRIVATE_DIRECTORY_MODE, recursive: true });\n fs.chmodSync(stagingDirectory, PRIVATE_DIRECTORY_MODE);\n const temporaryPath = `${target}.${process.pid}-${randomUUID()}.tmp`;\n try {\n fs.writeFileSync(temporaryPath, contents, { flag: 'wx', mode: PRIVATE_FILE_MODE });\n try {\n fs.renameSync(temporaryPath, target);\n } catch (error) {\n const code = (error as NodeJS.ErrnoException).code;\n if (code !== 'EEXIST' && code !== 'EPERM') throw error;\n const stat = fs.lstatSync(target);\n if (stat.isSymbolicLink() || !stat.isFile() || fs.readFileSync(target, 'utf8') !== contents) {\n throw new Error('content-addressed staging path is occupied by different content');\n }\n }\n fs.chmodSync(target, PRIVATE_FILE_MODE);\n } finally {\n fs.rmSync(temporaryPath, { force: true });\n }\n}\n\n/**\n * Validates one Agent Plugins v1 `mcp.json` and stages a native mcp-proxy layer.\n *\n * Server validation is isolated: one malformed server is diagnosed and skipped.\n * Document/schema, source identity, or plugin-boundary failures reject the whole\n * source. Only the two portable plugin placeholders are expanded; the staged\n * layer is tagged `internal`, so legacy `${ENV}` interpolation cannot run again.\n *\n * @deprecated Node-only sync shim; use normalizeAgentPluginMcpSourceAsync. Removed in M2.\n */\nexport function normalizeAgentPluginMcpSource(\n source: PoMcpAgentPluginProjectionSource,\n options: NormalizeAgentPluginMcpOptions,\n): NormalizedAgentPluginMcpSource {\n const label = sourceLabel(source);\n try {\n assertProjectionSource(source);\n const pluginRoot = fs.realpathSync(source.pluginRoot);\n try {\n const dataStat = fs.lstatSync(source.pluginDataDirectory);\n if (dataStat.isSymbolicLink() || !dataStat.isDirectory()) {\n throw new Error('pluginDataDirectory must be a real directory');\n }\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error;\n fs.mkdirSync(source.pluginDataDirectory, { mode: PRIVATE_DIRECTORY_MODE, recursive: true });\n }\n fs.chmodSync(source.pluginDataDirectory, PRIVATE_DIRECTORY_MODE);\n fs.accessSync(source.pluginDataDirectory, fs.constants.W_OK);\n const pluginDataDirectory = fs.realpathSync(source.pluginDataDirectory);\n const configPath = realContainedPath(pluginRoot, source.configPath, 'mcp.json');\n assertRootConfigPath(configPath, pluginRoot);\n\n const servers = parseMcpDocument(source, fs.readFileSync(configPath), label);\n const internalServers = Object.create(null) as Record<string, JsonObject>;\n const claudeServers = Object.create(null) as Record<string, JsonObject>;\n const droppedServers: string[] = [];\n const diagnostics: string[] = [];\n\n for (const [name, rawServer] of Object.entries(servers)) {\n const disposition = serverDisposition(name, options);\n if (disposition === 'empty') {\n diagnostics.push(emptyServerDiagnostic(label));\n continue;\n }\n if (disposition === 'dropped') {\n droppedServers.push(name);\n continue;\n }\n try {\n const normalized = normalizeServer(rawServer, pluginRoot, pluginDataDirectory, name);\n internalServers[name] = normalized.internal;\n claudeServers[name] = normalized.claude;\n } catch (error) {\n droppedServers.push(name);\n diagnostics.push(skippedServerDiagnostic(label, name, error));\n }\n }\n\n const contents = stagedContents(internalServers);\n const target = stagedInternalPath(source, contents, options.stagingDirectory);\n writeStagedInternalConfig(target, contents, options.stagingDirectory);\n return {\n configSource: { path: target, format: 'internal', cacheKey: stagedCacheKey(source, configPath, contents) },\n claudeConfig: { mcpServers: claudeServers },\n serverNames: Object.keys(internalServers),\n droppedServers,\n diagnostics,\n };\n } catch (error) {\n return disabledResult(label, error);\n }\n}\n\nconst AGENT_PLUGIN_SCHEMA = 'https://agent-plugins.org/schemas/1.0.0/plugin.schema.json';\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction stablePluginIdentity(entry: PluginEntry): string {\n const source = entry.source;\n const identity =\n source?.type === 'git'\n ? ['git', source.url, source.path ?? '']\n : source?.type === 'npm'\n ? ['npm', source.registry ?? '', source.package]\n : ['local', fs.realpathSync(entry.directory)];\n return createHash('sha256').update(JSON.stringify(identity)).digest('hex');\n}\n\nfunction rootAgentPluginSchema(entry: PluginEntry): string | undefined {\n const manifestPath = path.join(entry.directory, 'plugin.json');\n if (entry.manifest?.path === manifestPath && entry.manifest.agentPluginSchema === AGENT_PLUGIN_SCHEMA) {\n return AGENT_PLUGIN_SCHEMA;\n }\n try {\n const stat = fs.lstatSync(manifestPath);\n if (stat.isSymbolicLink() || !stat.isFile()) return undefined;\n const parsed = JSON.parse(fs.readFileSync(manifestPath, 'utf8')) as unknown;\n return isPlainObject(parsed) && parsed.$schema === AGENT_PLUGIN_SCHEMA ? AGENT_PLUGIN_SCHEMA : undefined;\n } catch {\n return undefined;\n }\n}\n\n/** One plugin's MCP config as a projection source, or nothing when it ships none. Shared by sync and settings. */\nexport async function pluginMcpSource(\n entry: PluginEntry,\n pluginDataRoot: string,\n): Promise<PoMcpProjectionSource | undefined> {\n if (entry.mcp === false) return undefined;\n const pluginRoot = fs.realpathSync(entry.directory);\n const agentPlugin = rootAgentPluginSchema(entry) === AGENT_PLUGIN_SCHEMA;\n const configPath = path.join(pluginRoot, agentPlugin ? 'mcp.json' : '.mcp.json');\n let stat: fs.Stats;\n try {\n stat = await fs.promises.lstat(configPath);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return undefined;\n throw error;\n }\n if (!stat.isFile() || stat.isSymbolicLink()) return undefined;\n const content = await fs.promises.readFile(configPath);\n const contentDigest = createHash('sha256').update(content).digest('hex');\n const pluginId = stablePluginIdentity(entry);\n const sourceId = `plugin:${pluginId}`;\n if (!agentPlugin) return { sourceId, owner: 'plugin', format: 'native', configPath, contentDigest };\n return {\n sourceId,\n owner: 'plugin',\n format: 'agent-plugin-v1',\n configPath,\n contentDigest,\n pluginId,\n pluginRoot,\n pluginDataDirectory: path.join(pluginDataRoot, pluginId),\n mcpSchemaUrl: AGENT_PLUGIN_MCP_SCHEMA_URL,\n };\n}\n","import path from 'node:path';\n\nimport type { PoMcpAgentPluginProjectionSource } from '@agimon-ai/po-core/mcpProjection';\nimport { type FileSystem, getOrThrow, nodeHost, writeFileAtomic } from '@agimon-ai/po-core/platform';\n\nimport {\n type JsonObject,\n type NormalizeAgentPluginMcpOptions,\n type NormalizedAgentPluginMcpSource,\n type NormalizedServer,\n PRIVATE_DIRECTORY_MODE,\n PRIVATE_FILE_MODE,\n assertProjectionSource,\n assertRootConfigPath,\n disabledResult,\n emptyServerDiagnostic,\n expandPluginPlaceholders,\n isInside,\n isPluginRelativeCommand,\n nonEmptyString,\n normalizeEnvironment,\n optionalStringArray,\n parseMcpDocument,\n remoteServer,\n serverDisposition,\n serverType,\n skippedServerDiagnostic,\n sourceLabel,\n stagedCacheKey,\n stagedContents,\n stagedInternalPath,\n stdioServer,\n workingDirectoryCandidate,\n} from './normalize';\n\nexport type {\n AgentPluginMcpConfigSource,\n NormalizeAgentPluginMcpOptions,\n NormalizedAgentPluginMcpSource,\n} from './normalize';\nexport { normalizeAgentPluginMcpSource, pluginMcpSource } from './sync';\n\ntype Context = Parameters<FileSystem['readTextFile']>[1];\n\nasync function realContainedPath(\n fs: FileSystem,\n root: string,\n candidate: string,\n label: string,\n context: Context,\n): Promise<string> {\n const real = await fs.canonicalPath(candidate, context);\n if (!real.ok) throw new Error(`${label} does not exist`);\n if (!isInside(root, real.value)) throw new Error(`${label} escapes its allowed plugin directory`);\n return real.value;\n}\n\nasync function normalizeCommand(\n fs: FileSystem,\n command: string,\n pluginRoot: string,\n context: Context,\n): Promise<string> {\n if (!isPluginRelativeCommand(command)) return command;\n const resolved = await realContainedPath(fs, pluginRoot, path.resolve(pluginRoot, command), 'command', context);\n if (getOrThrow(await fs.fileInfo(resolved, context)).kind !== 'file') {\n throw new Error('command must resolve to a regular file');\n }\n // Execute bits stand in for access(X_OK); the edge has no modes, so nodeHost reports none and the check is skipped.\n const mode = await nodeHost.fileMode(resolved);\n if (mode !== undefined && (mode & 0o111) === 0) throw new Error('command must resolve to an executable file');\n return resolved;\n}\n\nasync function normalizeWorkingDirectory(\n fs: FileSystem,\n declared: unknown,\n pluginRoot: string,\n pluginDataDirectory: string,\n context: Context,\n): Promise<string> {\n const declaredCwd = workingDirectoryCandidate(declared, pluginRoot, pluginDataDirectory);\n if (!declaredCwd) return pluginRoot;\n const resolved = await realContainedPath(fs, declaredCwd.base, declaredCwd.candidate, 'cwd', context);\n if (getOrThrow(await fs.fileInfo(resolved, context)).kind !== 'directory') {\n throw new Error('cwd must resolve to a directory');\n }\n return resolved;\n}\n\nasync function normalizeServer(\n fs: FileSystem,\n raw: unknown,\n pluginRoot: string,\n pluginDataDirectory: string,\n name: string,\n context: Context,\n): Promise<NormalizedServer> {\n const type = serverType(raw, name);\n const declaration = raw as JsonObject;\n if (type !== 'stdio') return remoteServer(declaration, name, type);\n const command = await normalizeCommand(fs, nonEmptyString(declaration.command, 'command'), pluginRoot, context);\n const args = optionalStringArray(declaration.args, 'args')?.map((item) =>\n expandPluginPlaceholders(item, pluginRoot, pluginDataDirectory),\n );\n const env = normalizeEnvironment(declaration.env, pluginRoot, pluginDataDirectory);\n const cwd = await normalizeWorkingDirectory(fs, declaration.cwd, pluginRoot, pluginDataDirectory, context);\n return stdioServer(name, { command, ...(args ? { args } : {}), env, cwd });\n}\n\n/** Owner-only plugin data directory; a symbolic link or non-directory rejects the source. */\nasync function preparePluginDataDirectory(fs: FileSystem, directory: string, context: Context): Promise<string> {\n const info = await fs.fileInfo(directory, context);\n if (info.ok) {\n if (info.value.kind !== 'directory') throw new Error('pluginDataDirectory must be a real directory');\n } else if (info.error.code === 'not_found') {\n getOrThrow(await fs.createDir(directory, { recursive: true }, context));\n } else {\n throw info.error;\n }\n await nodeHost.setMode(directory, PRIVATE_DIRECTORY_MODE);\n return getOrThrow(await fs.canonicalPath(directory, context));\n}\n\n/**\n * Content-addressed and owner-only. The name hashes the contents, so replacing an\n * existing staged file through a uniquely named temporary file never changes what it holds.\n */\nasync function writeStagedInternalConfig(\n fs: FileSystem,\n target: string,\n contents: string,\n stagingDirectory: string,\n context: Context,\n): Promise<void> {\n getOrThrow(await fs.createDir(stagingDirectory, { recursive: true }, context));\n await nodeHost.setMode(stagingDirectory, PRIVATE_DIRECTORY_MODE);\n await writeFileAtomic(fs, target, contents, context);\n await nodeHost.setMode(target, PRIVATE_FILE_MODE);\n}\n\n/**\n * Validates one Agent Plugins v1 `mcp.json` and stages a native mcp-proxy layer,\n * reading and writing through the injected file system.\n *\n * Server validation is isolated: one malformed server is diagnosed and skipped.\n * Document/schema, source identity, or plugin-boundary failures reject the whole\n * source. Only the two portable plugin placeholders are expanded; the staged\n * layer is tagged `internal`, so legacy `${ENV}` interpolation cannot run again.\n */\nexport async function normalizeAgentPluginMcpSourceAsync(\n fs: FileSystem,\n source: PoMcpAgentPluginProjectionSource,\n options: NormalizeAgentPluginMcpOptions,\n context: Context,\n): Promise<NormalizedAgentPluginMcpSource> {\n const label = sourceLabel(source);\n try {\n assertProjectionSource(source);\n const pluginRoot = getOrThrow(await fs.canonicalPath(source.pluginRoot, context));\n const pluginDataDirectory = await preparePluginDataDirectory(fs, source.pluginDataDirectory, context);\n const configPath = await realContainedPath(fs, pluginRoot, source.configPath, 'mcp.json', context);\n assertRootConfigPath(configPath, pluginRoot);\n\n const bytes = getOrThrow(await fs.readBinaryFile(configPath, context));\n const servers = parseMcpDocument(source, bytes, label);\n const internalServers = Object.create(null) as Record<string, JsonObject>;\n const claudeServers = Object.create(null) as Record<string, JsonObject>;\n const droppedServers: string[] = [];\n const diagnostics: string[] = [];\n\n for (const [name, rawServer] of Object.entries(servers)) {\n const disposition = serverDisposition(name, options);\n if (disposition === 'empty') {\n diagnostics.push(emptyServerDiagnostic(label));\n continue;\n }\n if (disposition === 'dropped') {\n droppedServers.push(name);\n continue;\n }\n try {\n const normalized = await normalizeServer(fs, rawServer, pluginRoot, pluginDataDirectory, name, context);\n internalServers[name] = normalized.internal;\n claudeServers[name] = normalized.claude;\n } catch (error) {\n droppedServers.push(name);\n diagnostics.push(skippedServerDiagnostic(label, name, error));\n }\n }\n\n const contents = stagedContents(internalServers);\n const target = stagedInternalPath(source, contents, options.stagingDirectory);\n await writeStagedInternalConfig(fs, target, contents, options.stagingDirectory, context);\n return {\n configSource: { path: target, format: 'internal', cacheKey: stagedCacheKey(source, configPath, contents) },\n claudeConfig: { mcpServers: claudeServers },\n serverNames: Object.keys(internalServers),\n droppedServers,\n diagnostics,\n };\n } catch (error) {\n return disabledResult(label, error);\n }\n}\n"],"mappings":";;;;;;;;AAOA,MAAM,aAAa;;AAEnB,MAAM,iCAAiC;AACvC,MAAM,aAAa;AACnB,MAAM,eAAe,IAAI,OAAO,IAAI,WAAW,QAAQ,WAAW,QAAQ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AAC;GAC9D;EACF;EAEA,MAAM,WAAW,eAAe,eAAe;EAC/C,MAAM,SAAS,mBAAmB,QAAQ,UAAU,QAAQ,gBAAgB;EAC5E,MAAM,0BAA0B,IAAI,QAAQ,UAAU,QAAQ,kBAAkB,OAAO;EACvF,OAAO;GACL,cAAc;IAAE,MAAM;IAAQ,QAAQ;IAAY,UAAU,eAAe,QAAQ,YAAY,QAAQ;GAAE;GACzG,cAAc,EAAE,YAAY,cAAc;GAC1C,aAAa,OAAO,KAAK,eAAe;GACxC;GACA;EACF;CACF,SAAS,OAAO;EACd,OAAO,eAAe,OAAO,KAAK;CACpC;AACF"}
|
|
@@ -1,96 +1,6 @@
|
|
|
1
|
+
import { a as GitPluginSource, n as DomainManifest, p as PluginSource, u as PluginEntry } from "./domains-Bo9krPQ5.mjs";
|
|
1
2
|
import "./index-DNEK9W6n.mjs";
|
|
2
3
|
import { FileSystem } from "@agimon-ai/po-core/platform";
|
|
3
|
-
//#region src/types/domains.d.ts
|
|
4
|
-
interface LocalPluginSource {
|
|
5
|
-
type: 'local';
|
|
6
|
-
/** Absolute plugin directory after resolving the declaring config or marketplace root. */
|
|
7
|
-
path: string;
|
|
8
|
-
}
|
|
9
|
-
interface GitPluginSource {
|
|
10
|
-
type: 'git';
|
|
11
|
-
url: string;
|
|
12
|
-
/** Optional repository-relative plugin directory. */
|
|
13
|
-
path?: string;
|
|
14
|
-
ref?: string;
|
|
15
|
-
sha?: string;
|
|
16
|
-
}
|
|
17
|
-
interface NpmPluginSource {
|
|
18
|
-
type: 'npm';
|
|
19
|
-
package: string;
|
|
20
|
-
version?: string;
|
|
21
|
-
registry?: string;
|
|
22
|
-
}
|
|
23
|
-
type PluginSource = LocalPluginSource | GitPluginSource | NpmPluginSource;
|
|
24
|
-
type PluginSkillDiscovery = 'recursive' | 'direct-children';
|
|
25
|
-
interface PluginManifestMetadata {
|
|
26
|
-
path: string;
|
|
27
|
-
name?: string;
|
|
28
|
-
version?: string;
|
|
29
|
-
description?: string;
|
|
30
|
-
agentPluginSchema?: string;
|
|
31
|
-
}
|
|
32
|
-
interface PluginCatalogEntry {
|
|
33
|
-
source: PluginSource;
|
|
34
|
-
description?: string;
|
|
35
|
-
marketplace?: string;
|
|
36
|
-
manifest?: PluginManifestMetadata;
|
|
37
|
-
}
|
|
38
|
-
interface PluginCatalog {
|
|
39
|
-
/** Marketplace, plugin, or plugin-container roots resolved against their declaring config. */
|
|
40
|
-
roots: string[];
|
|
41
|
-
/** Supported marketplace manifests discovered in precedence order. */
|
|
42
|
-
marketplaces: string[];
|
|
43
|
-
/** Named explicit and marketplace plugin entries. */
|
|
44
|
-
entries: Record<string, PluginCatalogEntry>;
|
|
45
|
-
/** Non-fatal errors from automatic marketplace and folder discovery. */
|
|
46
|
-
diagnostics: string[];
|
|
47
|
-
}
|
|
48
|
-
/** A named plugin, or a subset of one. */
|
|
49
|
-
type DomainPlugin = string | {
|
|
50
|
-
name: string;
|
|
51
|
-
skills?: string[];
|
|
52
|
-
agents?: string[];
|
|
53
|
-
hooks?: boolean;
|
|
54
|
-
mcp?: boolean;
|
|
55
|
-
};
|
|
56
|
-
interface DomainMcpAllowlist {
|
|
57
|
-
/** Server names kept from the repository-level .mcp.json. */
|
|
58
|
-
servers?: string[];
|
|
59
|
-
/** Upstream server names kept in the agiflow-proxy config. */
|
|
60
|
-
proxy?: string[];
|
|
61
|
-
}
|
|
62
|
-
interface DomainDefinition {
|
|
63
|
-
description?: string;
|
|
64
|
-
plugins?: DomainPlugin[];
|
|
65
|
-
mcp?: DomainMcpAllowlist;
|
|
66
|
-
sharedSkills?: boolean;
|
|
67
|
-
}
|
|
68
|
-
interface ResolvedDomain extends DomainDefinition {
|
|
69
|
-
baseDirectory: string;
|
|
70
|
-
}
|
|
71
|
-
interface DomainManifest {
|
|
72
|
-
plugins: PluginCatalog;
|
|
73
|
-
domains: Record<string, ResolvedDomain>;
|
|
74
|
-
aliases: Record<string, string[]>;
|
|
75
|
-
defaultDomains?: string[];
|
|
76
|
-
}
|
|
77
|
-
interface PluginEntry {
|
|
78
|
-
/** Catalog identifier when the entry came from domains.yaml. */
|
|
79
|
-
name?: string;
|
|
80
|
-
directory: string;
|
|
81
|
-
/** The domain that admitted this plugin; absent for an explicit directory. */
|
|
82
|
-
domain?: string;
|
|
83
|
-
/** Omitted for legacy programmatic callers that already supply a directory. */
|
|
84
|
-
source?: PluginSource;
|
|
85
|
-
/** Manifest metadata retained so resource adapters can apply schema-gated plugin contracts. */
|
|
86
|
-
manifest?: PluginManifestMetadata;
|
|
87
|
-
skillDiscovery?: PluginSkillDiscovery;
|
|
88
|
-
skills?: string[];
|
|
89
|
-
agents?: string[];
|
|
90
|
-
hooks?: boolean;
|
|
91
|
-
mcp?: boolean;
|
|
92
|
-
}
|
|
93
|
-
//#endregion
|
|
94
4
|
//#region src/services/pluginCatalog/parse.d.ts
|
|
95
5
|
declare const MARKETPLACE_MANIFEST_RELATIVE_PATHS: readonly ['.agents/plugins/marketplace.json', '.agents/plugins/api_marketplace.json', '.claude-plugin/marketplace.json', '.cursor-plugin/marketplace.json'];
|
|
96
6
|
declare function pluginDirectoryForSource(source: PluginSource, homePoDirectory: string): string;
|
|
@@ -169,5 +79,5 @@ declare function domainCompletionItems(domainNames: string[], query: string): Ar
|
|
|
169
79
|
label: string;
|
|
170
80
|
}>;
|
|
171
81
|
//#endregion
|
|
172
|
-
export {
|
|
173
|
-
//# sourceMappingURL=completion-
|
|
82
|
+
export { findPluginManifestPathAsync as _, loadDomainsAsync as a, isRemotePluginSource as b, resolveSharedSkillsAsync as c, resolvePluginDirectories as d, resolvePluginEntries as f, defaultDomainsForMajorMode as g, PO_DOMAINS_ENV as h, listDomainNamesAsync as i, listDomainNames as l, DEFAULT_DOMAIN as m, domainCompletionPrefix as n, resolvePluginDirectoriesAsync as o, resolveSharedSkills as p, expandDomainNames as r, resolvePluginEntriesAsync as s, domainCompletionItems as t, loadDomains as u, findPluginManifestPath as v, pluginDirectoryForSource as x, MARKETPLACE_MANIFEST_RELATIVE_PATHS as y };
|
|
83
|
+
//# sourceMappingURL=completion-CqlF0TFY.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"completion-CqlF0TFY.d.mts","names":[],"sources":["../src/services/pluginCatalog/parse.ts","../src/services/pluginCatalog/sync.ts","../src/services/pluginCatalog/index.ts","../src/services/domains/core.ts","../src/services/domains/sync.ts","../src/services/domains/index.ts","../src/services/domains/completion.ts"],"mappings":";;;;cAgBa;iBAgWG,yBAAyB,QAAQ,cAAc;iBAU/C,qBACd,QAAQ,eACP,UAAU,kBAAkB,QAAQ;EAAgB;;;;;;;;iBCnVvC,uBAAuB;;;KCnBlC,UAAU,WAAW;;iBAwDJ,4BACpB,IAAI,YACJ,oBACA,SAAS,UACR;;;cC4KU;cACA;;;;;;;;iBAiBG,2BACd,mBACA,aAAa,OAAO,YACpB;;;;;;;;iBC7Pc,YAAY,kBAAkB,yBAAmD;;iBAMjF,gBAAgB,kBAAkB;;iBAKlC,oBAAoB,kBAAkB,uBAAuB;;iBAK7D,qBACd,kBACA,uBACA,+BACA,yBACC;;iBAkBa,yBACd,kBACA,uBACA,+BACA;;;KClDG,YAAY,WAAW;;;;;;;;iBAkCN,iBACpB,IAAI,YACJ,kBACA,SAAS,WACT,yBACC,QAAQ;iBAOW,qBACpB,IAAI,YACJ,kBACA,SAAS,WACT,yBACC;;;;;;;iBAUmB,yBACpB,IAAI,YACJ,kBACA,uBACA,SAAS,WACT,yBACC;;iBAKmB,0BACpB,IAAI,YACJ,kBACA,uBACA,+BACA,SAAS,WACT,yBACC,QAAQ;iBAiBW,8BACpB,IAAI,YACJ,kBACA,uBACA,+BACA,SAAS,WACT,yBACC;;;;iBCjHa,kBAAkB,UAAU,gBAAgB;iBAW5C,uBAAuB;iBAKvB,sBAAsB,uBAAuB,gBAAgB;EAAQ;EAAe"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
//#region src/types/domains.d.ts
|
|
2
|
+
interface LocalPluginSource {
|
|
3
|
+
type: 'local';
|
|
4
|
+
/** Absolute plugin directory after resolving the declaring config or marketplace root. */
|
|
5
|
+
path: string;
|
|
6
|
+
}
|
|
7
|
+
interface GitPluginSource {
|
|
8
|
+
type: 'git';
|
|
9
|
+
url: string;
|
|
10
|
+
/** Optional repository-relative plugin directory. */
|
|
11
|
+
path?: string;
|
|
12
|
+
ref?: string;
|
|
13
|
+
sha?: string;
|
|
14
|
+
}
|
|
15
|
+
interface NpmPluginSource {
|
|
16
|
+
type: 'npm';
|
|
17
|
+
package: string;
|
|
18
|
+
version?: string;
|
|
19
|
+
registry?: string;
|
|
20
|
+
}
|
|
21
|
+
type PluginSource = LocalPluginSource | GitPluginSource | NpmPluginSource;
|
|
22
|
+
type PluginSkillDiscovery = 'recursive' | 'direct-children';
|
|
23
|
+
interface PluginManifestMetadata {
|
|
24
|
+
path: string;
|
|
25
|
+
name?: string;
|
|
26
|
+
version?: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
agentPluginSchema?: string;
|
|
29
|
+
}
|
|
30
|
+
interface PluginCatalogEntry {
|
|
31
|
+
source: PluginSource;
|
|
32
|
+
description?: string;
|
|
33
|
+
marketplace?: string;
|
|
34
|
+
manifest?: PluginManifestMetadata;
|
|
35
|
+
}
|
|
36
|
+
interface PluginCatalog {
|
|
37
|
+
/** Marketplace, plugin, or plugin-container roots resolved against their declaring config. */
|
|
38
|
+
roots: string[];
|
|
39
|
+
/** Supported marketplace manifests discovered in precedence order. */
|
|
40
|
+
marketplaces: string[];
|
|
41
|
+
/** Named explicit and marketplace plugin entries. */
|
|
42
|
+
entries: Record<string, PluginCatalogEntry>;
|
|
43
|
+
/** Non-fatal errors from automatic marketplace and folder discovery. */
|
|
44
|
+
diagnostics: string[];
|
|
45
|
+
}
|
|
46
|
+
/** A named plugin, or a subset of one. */
|
|
47
|
+
type DomainPlugin = string | {
|
|
48
|
+
name: string;
|
|
49
|
+
skills?: string[];
|
|
50
|
+
agents?: string[];
|
|
51
|
+
hooks?: boolean;
|
|
52
|
+
mcp?: boolean;
|
|
53
|
+
};
|
|
54
|
+
interface DomainMcpAllowlist {
|
|
55
|
+
/** Server names kept from the repository-level .mcp.json. */
|
|
56
|
+
servers?: string[];
|
|
57
|
+
/** Upstream server names kept in the agiflow-proxy config. */
|
|
58
|
+
proxy?: string[];
|
|
59
|
+
}
|
|
60
|
+
interface DomainDefinition {
|
|
61
|
+
description?: string;
|
|
62
|
+
plugins?: DomainPlugin[];
|
|
63
|
+
mcp?: DomainMcpAllowlist;
|
|
64
|
+
sharedSkills?: boolean;
|
|
65
|
+
}
|
|
66
|
+
interface ResolvedDomain extends DomainDefinition {
|
|
67
|
+
baseDirectory: string;
|
|
68
|
+
}
|
|
69
|
+
interface DomainManifest {
|
|
70
|
+
plugins: PluginCatalog;
|
|
71
|
+
domains: Record<string, ResolvedDomain>;
|
|
72
|
+
aliases: Record<string, string[]>;
|
|
73
|
+
defaultDomains?: string[];
|
|
74
|
+
}
|
|
75
|
+
interface PluginEntry {
|
|
76
|
+
/** Catalog identifier when the entry came from domains.yaml. */
|
|
77
|
+
name?: string;
|
|
78
|
+
directory: string;
|
|
79
|
+
/** The domain that admitted this plugin; absent for an explicit directory. */
|
|
80
|
+
domain?: string;
|
|
81
|
+
/** Omitted for legacy programmatic callers that already supply a directory. */
|
|
82
|
+
source?: PluginSource;
|
|
83
|
+
/** Manifest metadata retained so resource adapters can apply schema-gated plugin contracts. */
|
|
84
|
+
manifest?: PluginManifestMetadata;
|
|
85
|
+
skillDiscovery?: PluginSkillDiscovery;
|
|
86
|
+
skills?: string[];
|
|
87
|
+
agents?: string[];
|
|
88
|
+
hooks?: boolean;
|
|
89
|
+
mcp?: boolean;
|
|
90
|
+
}
|
|
91
|
+
//#endregion
|
|
92
|
+
export { GitPluginSource as a, PluginCatalog as c, PluginManifestMetadata as d, PluginSkillDiscovery as f, DomainPlugin as i, PluginCatalogEntry as l, ResolvedDomain as m, DomainManifest as n, LocalPluginSource as o, PluginSource as p, DomainMcpAllowlist as r, NpmPluginSource as s, DomainDefinition as t, PluginEntry as u };
|
|
93
|
+
//# sourceMappingURL=domains-Bo9krPQ5.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domains-Bo9krPQ5.d.mts","names":[],"sources":["../src/types/domains.ts"],"mappings":";UAAiB;EACf;;EAEA;;UAGe;EACf;EACA;;EAEA;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA;;KAGU,eAAe,oBAAoB,kBAAkB;KACrD;UAEK;EACf;EACA;EACA;EACA;EACA;;UAGe;EACf,QAAQ;EACR;EACA;EACA,WAAW;;UAGI;;EAEf;;EAEA;;EAEA,SAAS,eAAe;;EAExB;;;KAIU;EAEN;EAAc;EAAmB;EAAmB;EAAiB;;UAE1D;;EAEf;;EAEA;;UAGe;EACf;EACA,UAAU;EACV,MAAM;EACN;;UAGe,uBAAuB;EACtC;;UAGe;EACf,SAAS;EACT,SAAS,eAAe;EACxB,SAAS;EACT;;UAGe;;EAEf;EACA;;EAEA;;EAEA,SAAS;;EAET,WAAW;EACX,iBAAiB;EACjB;EACA;EACA;EACA"}
|
package/dist/domains.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as GitPluginSource, c as PluginCatalog, d as PluginManifestMetadata, f as PluginSkillDiscovery, i as DomainPlugin, l as PluginCatalogEntry, m as ResolvedDomain, n as DomainManifest, o as LocalPluginSource, p as PluginSource, r as DomainMcpAllowlist, s as NpmPluginSource, t as DomainDefinition, u as PluginEntry } from "./domains-Bo9krPQ5.mjs";
|
|
2
2
|
import { n as PO_DIR } from "./index-DNEK9W6n.mjs";
|
|
3
|
+
import { _ as findPluginManifestPathAsync, a as loadDomainsAsync, b as isRemotePluginSource, c as resolveSharedSkillsAsync, d as resolvePluginDirectories, f as resolvePluginEntries, g as defaultDomainsForMajorMode, h as PO_DOMAINS_ENV, i as listDomainNamesAsync, l as listDomainNames, m as DEFAULT_DOMAIN, n as domainCompletionPrefix, o as resolvePluginDirectoriesAsync, p as resolveSharedSkills, r as expandDomainNames, s as resolvePluginEntriesAsync, t as domainCompletionItems, u as loadDomains, v as findPluginManifestPath, x as pluginDirectoryForSource, y as MARKETPLACE_MANIFEST_RELATIVE_PATHS } from "./completion-CqlF0TFY.mjs";
|
|
3
4
|
export { DEFAULT_DOMAIN, type DomainDefinition, type DomainManifest, type DomainMcpAllowlist, type DomainPlugin, type GitPluginSource, type LocalPluginSource, MARKETPLACE_MANIFEST_RELATIVE_PATHS, type NpmPluginSource, PO_DIR, PO_DOMAINS_ENV, type PluginCatalog, type PluginCatalogEntry, type PluginEntry, type PluginManifestMetadata, type PluginSkillDiscovery, type PluginSource, type ResolvedDomain, defaultDomainsForMajorMode, domainCompletionItems, domainCompletionPrefix, expandDomainNames, findPluginManifestPath, findPluginManifestPathAsync, isRemotePluginSource, listDomainNames, listDomainNamesAsync, loadDomains, loadDomainsAsync, pluginDirectoryForSource, resolvePluginDirectories, resolvePluginDirectoriesAsync, resolvePluginEntries, resolvePluginEntriesAsync, resolveSharedSkills, resolveSharedSkillsAsync };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { a as GitPluginSource, c as PluginCatalog, d as PluginManifestMetadata, f as PluginSkillDiscovery, i as DomainPlugin, l as PluginCatalogEntry, m as ResolvedDomain, n as DomainManifest, o as LocalPluginSource, p as PluginSource, r as DomainMcpAllowlist, s as NpmPluginSource, t as DomainDefinition, u as PluginEntry } from "./domains-Bo9krPQ5.mjs";
|
|
1
2
|
import { n as writePrivateAtomicJson, t as writePrivateAtomicJsonAsync } from "./index-fTuf8tVH.mjs";
|
|
2
3
|
import { A as PoSelectionConfig, B as VoiceTtsConfig, C as PoConfigLayers, D as PoConfigTransitionRecord, E as PoConfigTransitionPhase, F as VoiceAutoCaptureConfig, I as VoiceConfig, L as VoiceEngine, M as ResolvedVoiceAutoCaptureConfig, N as ResolvedVoiceConfig, O as PoConfigTransitionStrategy, P as VoiceAdapterConfig, R as VoiceMode, S as PoConfigLayer, V as VoiceTtsEngine, _ as PlanningModeConfig, b as PoConfig, c as EditorConfig, d as IPoConfigService, g as PlanningAgentConfig, h as PackageAttribution, i as AutocompactTokenConfig, j as ProjectTrust, k as PoHarnessContext, l as HarnessState, m as PO_CONFIG_SERVICE, n as AutocompactOverrideConfig, o as ConfigValueOrigin, r as AutocompactThresholdConfig, s as DeepReadonly, t as AutocompactModeConfig, u as IPoConfigLoader, v as PlanningThinkingLevel, w as PoConfigPendingSelection, x as PoConfigContext, y as PluginHookSource, z as VoiceModelConfig } from "./config-pxC7FyUJ.mjs";
|
|
3
4
|
import { C as loadPoConfigLenient, D as resolvePlanningPlansDirectory, E as repositoryPoConfigPath, S as loadPoConfigLayers, T as globalPoConfigPath, _ as readPoConfig, a as PO_VOICE_MODES, b as loadPoConfig, c as configRootKeys, d as parseAutocompactModeConfig, f as parsePlanningModeConfig, g as ReadPoConfigOptions, h as valueAtKeyPath, i as PO_VOICE_LIVE_VOICES, l as configScopeOf, m as resolveVoiceConfig, n as PO_PLANNING_THINKING_LEVELS, o as PO_VOICE_TTS_ENGINES, p as parsePoConfig, r as PO_VOICE_ENGINES, s as configLeafKeys, t as ConfigKeyScope, u as mergePoConfigs, v as readPoConfigLayers, w as globalPoConfigDirectory, x as loadPoConfigAsync, y as readPoConfigLenient } from "./index-D3vGEYup.mjs";
|
|
4
5
|
import { i as PiConfigPaths, n as PiConfig, r as PiConfigLoadOptions, t as ConfigAdapterRegistrationOptions } from "./piConfig-C9rGUqPe.mjs";
|
|
5
6
|
import { a as unsetPoConfigValue, c as PoConfigScope, i as setPoConfigValue, l as WritePoConfigOptions, n as unsetPoConfigValueAsync, o as writePoConfigValues, r as writePoConfigValuesAsync, s as PoConfigEdit, t as setPoConfigValueAsync } from "./index-COokUToB.mjs";
|
|
6
|
-
import { A as PluginCatalogEntry, C as DomainManifest, D as LocalPluginSource, E as GitPluginSource, F as ResolvedDomain, M as PluginManifestMetadata, N as PluginSkillDiscovery, O as NpmPluginSource, P as PluginSource, S as DomainDefinition, T as DomainPlugin, _ as findPluginManifestPathAsync, b as isRemotePluginSource, d as resolvePluginDirectories, f as resolvePluginEntries, j as PluginEntry, k as PluginCatalog, l as listDomainNames, n as domainCompletionPrefix, p as resolveSharedSkills, r as expandDomainNames, t as domainCompletionItems, u as loadDomains, v as findPluginManifestPath, w as DomainMcpAllowlist, x as pluginDirectoryForSource, y as MARKETPLACE_MANIFEST_RELATIVE_PATHS } from "./completion-Ba0TiBHa.mjs";
|
|
7
7
|
import { n as PO_DIR } from "./index-DNEK9W6n.mjs";
|
|
8
|
+
import { _ as findPluginManifestPathAsync, b as isRemotePluginSource, d as resolvePluginDirectories, f as resolvePluginEntries, l as listDomainNames, n as domainCompletionPrefix, p as resolveSharedSkills, r as expandDomainNames, t as domainCompletionItems, u as loadDomains, v as findPluginManifestPath, x as pluginDirectoryForSource, y as MARKETPLACE_MANIFEST_RELATIVE_PATHS } from "./completion-CqlF0TFY.mjs";
|
|
8
9
|
import { a as readHarnessState, i as projectHarnessEnvironment, n as HARNESS_STATE_KEYS, r as HarnessStateParseReporter, t as FILE_ONLY_STATE_FIELDS } from "./index-BTOU4XiI.mjs";
|
|
9
10
|
import { _ as HARNESS_STATE_POINTER, a as requireHarnessPaths, b as resetHarnessStore, d as getHarnessState, f as getSessionHarnessState, g as updateHarnessState, h as snapshotHarnessState, l as createHarnessSession, m as restoreHarnessStateSnapshot, o as requireHarnessRoot, p as loadHarnessState, r as harnessRoot, u as disposeHarnessState, v as HarnessStateFile, x as LoadedHarnessState, y as HarnessStateTransactionSnapshot } from "./index-dYgF03lE.mjs";
|
|
10
11
|
import { a as loadPiConfigAsync, c as piConfigPaths, d as MIN_IMAGE_MAX_DIMENSION, f as PiImageSettings, h as parsePiImageSettings, i as loadPiConfig, l as piImageSettingsPath, m as clampImageMaxDimension, o as loadPiImageSettings, p as PiImageSettingsUpdate, s as savePiImageSettings, u as DEFAULT_IMAGE_MAX_DIMENSION } from "./index-7RuIAWX1.mjs";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agimon-ai/po-config",
|
|
3
|
-
"version": "0.0.0-alpha.
|
|
3
|
+
"version": "0.0.0-alpha.23",
|
|
4
4
|
"description": "Typed configuration loading, validation, and host services for composing Po sessions.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent-configuration",
|
|
@@ -139,15 +139,15 @@
|
|
|
139
139
|
"registry": "https://registry.npmjs.org/"
|
|
140
140
|
},
|
|
141
141
|
"dependencies": {
|
|
142
|
-
"@agimon-ai/po-core": "0.0.0-alpha.
|
|
143
|
-
"@agimon-ai/po-telemetry": "0.0.0-alpha.
|
|
144
|
-
"@agimon-ai/po-web-components": "0.0.0-alpha.
|
|
142
|
+
"@agimon-ai/po-core": "0.0.0-alpha.23",
|
|
143
|
+
"@agimon-ai/po-telemetry": "0.0.0-alpha.23",
|
|
144
|
+
"@agimon-ai/po-web-components": "0.0.0-alpha.23",
|
|
145
145
|
"@deepseek-ai/cordis": "4.0.5",
|
|
146
146
|
"typebox": "1.3.37",
|
|
147
147
|
"yaml": "2.9.1"
|
|
148
148
|
},
|
|
149
149
|
"devDependencies": {
|
|
150
|
-
"@agimon-ai/po-build": "0.0.0-alpha.
|
|
150
|
+
"@agimon-ai/po-build": "0.0.0-alpha.23",
|
|
151
151
|
"@earendil-works/pi-coding-agent": "1.3.0",
|
|
152
152
|
"@modelcontextprotocol/ext-apps": "2.0.3",
|
|
153
153
|
"@modelcontextprotocol/server": "2.3.1",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"completion-Ba0TiBHa.d.mts","names":[],"sources":["../src/types/domains.ts","../src/services/pluginCatalog/parse.ts","../src/services/pluginCatalog/sync.ts","../src/services/pluginCatalog/index.ts","../src/services/domains/core.ts","../src/services/domains/sync.ts","../src/services/domains/index.ts","../src/services/domains/completion.ts"],"m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