@ai-agent-forge/agent-forge 0.88.3 → 0.88.5
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/CHANGELOG.md +8 -0
- package/bundled-plugins/agent-loop-policy/agent-forge.json +1 -1
- package/bundled-plugins/agent-loop-policy/plugin.json +1 -1
- package/bundled-plugins/coding-tools/agent-forge.json +1 -1
- package/bundled-plugins/coding-tools/plugin.json +1 -1
- package/bundled-plugins/compaction-policy/agent-forge.json +1 -1
- package/bundled-plugins/compaction-policy/plugin.json +1 -1
- package/bundled-plugins/overflow-policy/agent-forge.json +1 -1
- package/bundled-plugins/overflow-policy/plugin.json +1 -1
- package/bundled-plugins/provider-failover/agent-forge.json +1 -1
- package/bundled-plugins/provider-failover/plugin.json +1 -1
- package/bundled-plugins/retry-policy/agent-forge.json +1 -1
- package/bundled-plugins/retry-policy/plugin.json +1 -1
- package/dist/bundle/.build-manifest.json +7 -7
- package/dist/bundle/chunks/{chunk-B42Y2VME.js → chunk-HEL6TAWE.js} +8 -8
- package/dist/bundle/cli.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/core/extensions/capability-plugin.d.ts.map +1 -1
- package/dist/core/extensions/capability-plugin.js +15 -8
- package/dist/core/extensions/capability-plugin.js.map +1 -1
- package/dist/core/extensions/virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/virtual-modules.js +8 -5
- package/dist/core/extensions/virtual-modules.js.map +1 -1
- package/dist/plugins/ecosystem/node-package-install-host.d.ts +9 -1
- package/dist/plugins/ecosystem/node-package-install-host.d.ts.map +1 -1
- package/dist/plugins/ecosystem/node-package-install-host.js +79 -0
- package/dist/plugins/ecosystem/node-package-install-host.js.map +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/extensions/with-deps/plugin.json +1 -1
- package/package.json +1 -1
|
@@ -25,8 +25,11 @@ function getVirtualModules() {
|
|
|
25
25
|
}
|
|
26
26
|
// Host-resolved heavy-dependency aliases (D-075 S4 fourth batch, installed-
|
|
27
27
|
// code-loading): the memory plugin package carries its vector stack pinned in
|
|
28
|
-
// its own package.json
|
|
29
|
-
// the
|
|
28
|
+
// its own package.json; an npm-installed tarball ships no node_modules itself —
|
|
29
|
+
// the install host materializes declared runtime dependencies into the store
|
|
30
|
+
// copy (node-package-install-host), and this alias table stays a tolerant
|
|
31
|
+
// fallback channel for stores that predate that or hosts without the package.
|
|
32
|
+
// Unlike the SDK/protocol virtual modules below,
|
|
30
33
|
// lancedb/transformers are NATIVE/lazy packages the host must not bundle or
|
|
31
34
|
// import here: they stay host dependencies, and each specifier is resolved
|
|
32
35
|
// ONCE (module-level cache, successes only) to the host's own entry file
|
|
@@ -44,7 +47,8 @@ const hostHeavyDependencyAliases = new Set([
|
|
|
44
47
|
"@lancedb/lancedb",
|
|
45
48
|
"@huggingface/transformers",
|
|
46
49
|
// memory 的 onnxruntime 预检(nativeBinaryCheck)在插件内直接 resolve 该传递
|
|
47
|
-
//
|
|
50
|
+
// 依赖;与 transformers 同走宿主 alias 通道——安装店副本经依赖物化后自解析
|
|
51
|
+
// 可达(node-package-install-host),宿主解析失败=条目缺席=插件侧回退,宽容契约不变。
|
|
48
52
|
"onnxruntime-node",
|
|
49
53
|
]);
|
|
50
54
|
const resolvedHeavyDependencyAliases = new Map();
|
|
@@ -467,8 +471,9 @@ export async function loadCapabilityPluginFromManifest(runtime, manifestPath, op
|
|
|
467
471
|
}
|
|
468
472
|
const parsed = parseCapabilityPluginManifest(raw, manifestPath);
|
|
469
473
|
// hostDependencyPaths (安装店重依赖可见性): 宿主已解析的重依赖入口绝对路径
|
|
470
|
-
// 并进 manifest config
|
|
471
|
-
//
|
|
474
|
+
// 并进 manifest config——npm tarball 形态的安装店副本自身无依赖树, 声明运行
|
|
475
|
+
// 依赖的包由安装宿主物化 (node-package-install-host), 未物化的副本里插件内
|
|
476
|
+
// createRequire 自解析不可达 (memory 的 onnxruntime native 预检实证); 与 jiti alias 通道互补
|
|
472
477
|
// (alias 拦截 import, 本通道喂插件内的路径式消费)。公共同道: 第一方与第三方
|
|
473
478
|
// 插件同样可读。仍低于插件侧 config 文件通道 (agent-dir 配置合并在其上)。
|
|
474
479
|
const hostDependencyOverride = { hostDependencyPaths: hostDependencyPathsConfig() };
|
|
@@ -478,9 +483,11 @@ export async function loadCapabilityPluginFromManifest(runtime, manifestPath, op
|
|
|
478
483
|
: { ...parsed, config: { ...parsed.config, ...hostDependencyOverride, ...callerOverride } };
|
|
479
484
|
const entryPath = path.resolve(path.dirname(manifestPath), manifest.entry);
|
|
480
485
|
// Host-resolved authoring dependencies (D-075 §4.1): installed plugin
|
|
481
|
-
// packages live in the install store
|
|
482
|
-
//
|
|
483
|
-
//
|
|
486
|
+
// packages live in the install store; npm tarballs never include
|
|
487
|
+
// dependencies, and the SDK and pinned typebox specifiers stay
|
|
488
|
+
// host-supplied by contract (the install host skips them when
|
|
489
|
+
// materializing runtime dependencies, see node-package-install-host), so
|
|
490
|
+
// their bare imports resolve against the host's own copies
|
|
484
491
|
// through jiti virtual modules (./virtual-modules.ts, lazy). Works
|
|
485
492
|
// identically in the bundle and Bun binaries where no source-tree
|
|
486
493
|
// node_modules exists at all. D-075 S4 third batch: the protocol package
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capability-plugin.js","sourceRoot":"","sources":["../../../src/core/extensions/capability-plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAKN,6BAA6B,GAC7B,MAAM,yBAAyB,CAAC;AAIjC,OAAO,EAAE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AAE;YAC9D,IAAI,EAAE,SAAS;YACf,MAAM,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;SAC9D,CAAC,CACF,CAAC;IACH,CAAC;IACD,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,6EAA6E,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;IAClH,CAAC;IACD,OAAO,oBAAoB,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAkC,CAAC,CAAC;AAAA,CACnF","sourcesContent":["import type { Dirent } from \"node:fs\";\nimport { lstatSync, readdirSync, realpathSync, statSync } from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport { createRequire } from \"node:module\";\nimport * as path from \"node:path\";\nimport {\n\ttype CapabilityPluginFactory,\n\ttype CapabilityPluginInstance,\n\ttype CapabilityPluginSyncFactory,\n\ttype CapabilityPluginSyncInstance,\n\tparseCapabilityPluginManifest,\n} from \"@agent-forge/plugin-sdk\";\n// Type-only: the runtime dependency stays deferred until the first plugin\n// load (getCreateJiti below).\nimport type { createJiti } from \"jiti/static\";\nimport { t } from \"../i18n/index.ts\";\nimport type { CapabilityRuntime } from \"./capability-runtime.ts\";\nimport {\n\tPLUGIN_DISPOSE_EVENT_ID,\n\tPLUGIN_DISPOSE_EVENT_VERSION,\n\tPLUGIN_READY_EVENT_ID,\n\tPLUGIN_READY_EVENT_VERSION,\n\ttype PluginDisposeEventDataV1,\n} from \"./lifecycle-catalog.ts\";\nimport type { CapabilityAPI, PluginConfig, PluginManifest } from \"./public-api.ts\";\n\n// Authoring-surface symbols moved to @agent-forge/plugin-sdk (D-075 S2);\n// re-exported here so existing host imports keep resolving.\nexport type {\n\tCapabilityPluginFactory,\n\tCapabilityPluginFactoryResult,\n\tCapabilityPluginInstance,\n\tCapabilityPluginSyncFactory,\n\tCapabilityPluginSyncInstance,\n} from \"@agent-forge/plugin-sdk\";\nexport { parseCapabilityPluginManifest } from \"@agent-forge/plugin-sdk\";\n\nexport interface CapabilityPluginHandle {\n\treadonly manifest: PluginManifest;\n\treadonly api: CapabilityAPI;\n\t/** Resolves once the plugin.ready lifecycle delivery has settled. */\n\treadonly ready: Promise<void>;\n\tdispose(): Promise<void>;\n}\n\nconst activePlugins = new WeakMap<CapabilityRuntime, Map<string, symbol>>();\n\n// Upstream pi 40c256ccc parity: importing this module sits on every startup\n// path, so the jiti transform pipeline (Babel included) and the bundled\n// virtual modules stay deferred until the first plugin actually loads. The\n// dynamic imports below are deliberate lazy-load points; the thin\n// jiti-static-loader entry keeps jiti/static statically reachable for the\n// Bun and Node bundlers that must embed it.\nlet createJitiPromise: Promise<typeof createJiti> | undefined;\n\nfunction getCreateJiti(): Promise<typeof createJiti> {\n\tcreateJitiPromise ??= import(\"./jiti-static-loader.ts\").then((module) => module.createJiti);\n\treturn createJitiPromise;\n}\n\nlet virtualModulesPromise: Promise<Record<string, unknown>> | undefined;\n\nfunction getVirtualModules(): Promise<Record<string, unknown>> {\n\tvirtualModulesPromise ??= import(\"./virtual-modules.ts\").then((module) => module.VIRTUAL_MODULES);\n\treturn virtualModulesPromise;\n}\n\n// Host-resolved heavy-dependency aliases (D-075 S4 fourth batch, installed-\n// code-loading): the memory plugin package carries its vector stack pinned in\n// its own package.json, but an npm-installed tarball ships no node_modules —\n// the same void the SDK/protocol virtual modules below fill. Unlike those,\n// lancedb/transformers are NATIVE/lazy packages the host must not bundle or\n// import here: they stay host dependencies, and each specifier is resolved\n// ONCE (module-level cache, successes only) to the host's own entry file\n// path and handed to jiti as an alias. The alias reliably intercepts only\n// STATIC imports on the entry chain of files jiti transforms — lazy\n// `await import()` calls inside an installed ESM dist bypass the transform\n// pipeline and hit the native resolver, so those lazy paths are supplied by\n// the hostDependencyPaths absolute-path channel instead (hostDependencyPaths-\n// Config below plus the plugin-side host-module-import). Resolution failures\n// are tolerated on both channels: the alias table is a best-effort supply\n// path, and heavy-dependency failures must surface at the plugin's point of\n// use, where the memory plugin reports structured failures with an action\n// list.\nconst hostHeavyDependencyAliases: ReadonlySet<string> = new Set([\n\t\"@lancedb/lancedb\",\n\t\"@huggingface/transformers\",\n\t// memory 的 onnxruntime 预检(nativeBinaryCheck)在插件内直接 resolve 该传递\n\t// 依赖;安装店副本无 node_modules,必须与 transformers 同走宿主 alias 通道。\n\t\"onnxruntime-node\",\n]);\n\nconst resolvedHeavyDependencyAliases: Map<string, string> = new Map();\n\n/**\n * Explicit injection object for {@link buildHostDependencyAliases}. Both fields\n * are required on purpose: with optional positional parameters a test could\n * inject only `resolve` and silently write its fake results into the\n * module-level production cache (`resolvedHeavyDependencyAliases`), hijacking\n * every later real plugin load in the same vitest worker. Making the object\n * mandatory means a test cannot supply a resolver without also supplying the\n * cache it pollutes.\n */\nexport interface HostDependencyAliasResolution {\n\treadonly resolve: (specifier: string) => string;\n\treadonly cache: Map<string, string>;\n}\n\nconst defaultHostDependencyAliasResolution: HostDependencyAliasResolution = {\n\tresolve: (specifier) => createRequire(import.meta.url).resolve(specifier),\n\tcache: resolvedHeavyDependencyAliases,\n};\n\n/**\n * Tolerant heavy-dependency resolution shared by the jiti alias channel and\n * the hostDependencyPaths config channel: each specifier is resolved against\n * the host installation (successes cached module-level), and a specifier that\n * fails to resolve is simply absent from the result. The alias table is a\n * best-effort supply path — heavy-dependency failures must surface at the\n * plugin's point of use, where the memory plugin reports structured failures\n * with an action list. Exported for deterministic tests; production callers\n * pass {@link defaultHostDependencyAliasResolution} explicitly.\n */\nexport function buildHostDependencyAliases(\n\tspecifiers: ReadonlySet<string> | readonly string[],\n\tresolution: HostDependencyAliasResolution,\n): Record<string, string> {\n\tconst aliases: Record<string, string> = {};\n\tfor (const specifier of specifiers) {\n\t\tconst cached = resolution.cache.get(specifier);\n\t\tif (cached !== undefined) {\n\t\t\taliases[specifier] = cached;\n\t\t\tcontinue;\n\t\t}\n\t\ttry {\n\t\t\tconst resolved = resolution.resolve(specifier);\n\t\t\tresolution.cache.set(specifier, resolved);\n\t\t\taliases[specifier] = resolved;\n\t\t} catch {\n\t\t\t// Tolerant by contract: absent entry = plugin-side fallback.\n\t\t}\n\t}\n\treturn aliases;\n}\n\n/**\n * Host-resolved heavy-dependency entry paths (specifier → absolute path) for\n * the config channel that feeds the lazy `await import()` paths the jiti\n * alias channel cannot reach (installed ESM dists bypass the transform\n * pipeline). Tolerant like the alias table: a specifier the host installation\n * cannot resolve is simply absent, and plugin code falls back to its own\n * resolution (or reports the structured failure). camelCase keys keep the\n * JSON config channel idiomatic for plugin consumers.\n */\nfunction hostDependencyPathsConfig(): Record<string, string> {\n\tconst paths: Record<string, string> = {};\n\tfor (const [specifier, entryPath] of Object.entries(\n\t\tbuildHostDependencyAliases(hostHeavyDependencyAliases, defaultHostDependencyAliasResolution),\n\t)) {\n\t\tpaths[camelCaseDependencyKey(specifier)] = entryPath;\n\t}\n\treturn paths;\n}\n\nfunction camelCaseDependencyKey(specifier: string): string {\n\tconst scoped = specifier.replace(/^@[^/]+\\//, \"\");\n\treturn scoped.replace(/[-.](.)/g, (_, character: string) => character.toUpperCase());\n}\n\nfunction isPluginInstance(value: unknown): value is CapabilityPluginInstance {\n\treturn typeof value === \"object\" && value !== null && typeof (value as { dispose?: unknown }).dispose === \"function\";\n}\n\nfunction normalizePluginInstance(value: unknown, manifest: PluginManifest): CapabilityPluginInstance | undefined {\n\tif (value === undefined) return undefined;\n\tif (!isPluginInstance(value)) {\n\t\tthrow new Error(\n\t\t\tt(\"Capability plugin factory must return void or an instance with dispose(): {id}\", { id: manifest.id }),\n\t\t);\n\t}\n\treturn value;\n}\n\nfunction normalizePluginSyncInstance(\n\tvalue: unknown,\n\tmanifest: PluginManifest,\n): CapabilityPluginSyncInstance | undefined {\n\tif (value === undefined) return undefined;\n\tif (!isPluginInstance(value)) {\n\t\tthrow new Error(\n\t\t\tt(\"Synchronous capability plugin factory must return void or an instance with dispose(): {id}\", {\n\t\t\t\tid: manifest.id,\n\t\t\t}),\n\t\t);\n\t}\n\treturn value as CapabilityPluginSyncInstance;\n}\n\nfunction throwCleanupErrors(errors: unknown[], manifestId: string): void {\n\tif (errors.length === 0) return;\n\tif (errors.length === 1) throw errors[0];\n\tthrow new AggregateError(errors, `Capability plugin cleanup failed: ${manifestId}`);\n}\n\nasync function dispatchPluginDisposeEvent(\n\truntime: CapabilityRuntime,\n\tmanifest: PluginManifest,\n\tstatus: PluginDisposeEventDataV1[\"status\"],\n): Promise<void> {\n\tif (!runtime.hasLifecycleEvent(PLUGIN_DISPOSE_EVENT_ID, PLUGIN_DISPOSE_EVENT_VERSION)) return;\n\tawait runtime.dispatchLifecycle({\n\t\ttype: PLUGIN_DISPOSE_EVENT_ID,\n\t\tversion: PLUGIN_DISPOSE_EVENT_VERSION,\n\t\tphase: \"committed\",\n\t\tdata: {\n\t\t\tversion: 1,\n\t\t\tpluginId: manifest.id,\n\t\t\tpluginVersion: manifest.version,\n\t\t\tstatus,\n\t\t},\n\t\tsource: \"capability-plugin\",\n\t});\n}\n\nasync function dispatchPluginReadyEvent(runtime: CapabilityRuntime, manifest: PluginManifest): Promise<void> {\n\tif (!runtime.hasLifecycleEvent(PLUGIN_READY_EVENT_ID, PLUGIN_READY_EVENT_VERSION)) return;\n\tawait runtime.dispatchLifecycle({\n\t\ttype: PLUGIN_READY_EVENT_ID,\n\t\tversion: PLUGIN_READY_EVENT_VERSION,\n\t\tphase: \"committed\",\n\t\tdata: {\n\t\t\tversion: 1,\n\t\t\tpluginId: manifest.id,\n\t\t\tpluginVersion: manifest.version,\n\t\t},\n\t\tsource: \"capability-plugin\",\n\t});\n}\n\nfunction isMissingPathError(error: unknown): boolean {\n\treturn typeof error === \"object\" && error !== null && \"code\" in error && error.code === \"ENOENT\";\n}\n\nfunction compareNames(left: string, right: string): number {\n\treturn left < right ? -1 : left > right ? 1 : 0;\n}\n\n/**\n * Find installed capability manifests below the given plugin directories.\n *\n * Directories are visited in caller order; entries in each directory use a\n * stable lexical order. Missing roots are normal for a first-run host.\n * Existing unreadable or malformed filesystem paths fail explicitly rather\n * than silently changing the loaded plugin set. Dependency and hidden\n * directories are never traversed.\n */\nexport function discoverCapabilityPluginManifests(pluginDirectories: readonly string[]): string[] {\n\tconst manifests: string[] = [];\n\tconst seenDirectories = new Set<string>();\n\tconst seenManifests = new Set<string>();\n\n\tconst visit = (directory: string, optional: boolean): void => {\n\t\tconst resolvedDirectory = path.resolve(directory);\n\t\tlet stats: ReturnType<typeof statSync>;\n\t\ttry {\n\t\t\tstats = statSync(resolvedDirectory);\n\t\t} catch (error) {\n\t\t\tif (optional && isMissingPathError(error)) {\n\t\t\t\ttry {\n\t\t\t\t\tif (!lstatSync(resolvedDirectory).isSymbolicLink()) return;\n\t\t\t\t} catch (linkError) {\n\t\t\t\t\tif (isMissingPathError(linkError)) return;\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\tt(\"Failed to inspect capability plugin directory {directory}: {reason}\", {\n\t\t\t\t\t\t\tdirectory: resolvedDirectory,\n\t\t\t\t\t\t\treason: linkError instanceof Error ? linkError.message : String(linkError),\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow new Error(\n\t\t\t\tt(\"Failed to inspect capability plugin directory {directory}: {reason}\", {\n\t\t\t\t\tdirectory: resolvedDirectory,\n\t\t\t\t\treason: error instanceof Error ? error.message : String(error),\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t\tif (!stats.isDirectory()) {\n\t\t\tthrow new Error(\n\t\t\t\tt(\"Capability plugin path must be a directory: {directory}\", { directory: resolvedDirectory }),\n\t\t\t);\n\t\t}\n\n\t\tlet canonicalDirectory: string;\n\t\ttry {\n\t\t\tcanonicalDirectory = realpathSync(resolvedDirectory);\n\t\t} catch (error) {\n\t\t\tthrow new Error(\n\t\t\t\tt(\"Failed to resolve capability plugin directory {directory}: {reason}\", {\n\t\t\t\t\tdirectory: resolvedDirectory,\n\t\t\t\t\treason: error instanceof Error ? error.message : String(error),\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t\tif (seenDirectories.has(canonicalDirectory)) return;\n\t\tseenDirectories.add(canonicalDirectory);\n\n\t\tlet entries: Dirent<string>[];\n\t\ttry {\n\t\t\tentries = readdirSync(resolvedDirectory, { withFileTypes: true, encoding: \"utf8\" });\n\t\t} catch (error) {\n\t\t\tthrow new Error(\n\t\t\t\tt(\"Failed to read capability plugin directory {directory}: {reason}\", {\n\t\t\t\t\tdirectory: resolvedDirectory,\n\t\t\t\t\treason: error instanceof Error ? error.message : String(error),\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tfor (const entry of entries.sort((left, right) => compareNames(left.name, right.name))) {\n\t\t\tif (entry.name === \"node_modules\" || entry.name.startsWith(\".\")) continue;\n\t\t\tconst entryPath = path.join(resolvedDirectory, entry.name);\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tvisit(entryPath, false);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!entry.isFile() || entry.name !== \"plugin.json\") continue;\n\n\t\t\tlet canonicalManifest: string;\n\t\t\ttry {\n\t\t\t\tcanonicalManifest = realpathSync(entryPath);\n\t\t\t} catch (error) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\tt(\"Failed to resolve capability plugin manifest {path}: {reason}\", {\n\t\t\t\t\t\tpath: entryPath,\n\t\t\t\t\t\treason: error instanceof Error ? error.message : String(error),\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (seenManifests.has(canonicalManifest)) continue;\n\t\t\tseenManifests.add(canonicalManifest);\n\t\t\tmanifests.push(canonicalManifest);\n\t\t}\n\t};\n\n\tfor (const pluginDirectory of pluginDirectories) visit(pluginDirectory, true);\n\treturn manifests;\n}\n\n/**\n * Load a capability plugin through the public facade only.\n * Filesystem discovery and package installation stay outside this mechanism.\n */\nexport async function loadCapabilityPlugin(\n\truntime: CapabilityRuntime,\n\tmanifest: PluginManifest,\n\tfactory: CapabilityPluginFactory,\n): Promise<CapabilityPluginHandle> {\n\tconst active = activePlugins.get(runtime) ?? new Map<string, symbol>();\n\tif (active.has(manifest.id)) throw new Error(t(\"Capability plugin is already loaded: {id}\", { id: manifest.id }));\n\tconst ownerToken = Symbol(manifest.id);\n\tactive.set(manifest.id, ownerToken);\n\tactivePlugins.set(runtime, active);\n\tlet api: CapabilityAPI | undefined;\n\tlet instance: CapabilityPluginInstance | undefined;\n\tconst cleanup = async (notifyDispose: boolean): Promise<void> => {\n\t\tconst errors: unknown[] = [];\n\t\tif (api) runtime.revokeAPI(api);\n\t\ttry {\n\t\t\tawait runtime.disposePlugin(manifest.id);\n\t\t} catch (error) {\n\t\t\terrors.push(error);\n\t\t}\n\t\ttry {\n\t\t\tawait instance?.dispose();\n\t\t} catch (error) {\n\t\t\terrors.push(error);\n\t\t}\n\t\tif (notifyDispose) {\n\t\t\ttry {\n\t\t\t\tawait dispatchPluginDisposeEvent(runtime, manifest, errors.length === 0 ? \"disposed\" : \"failed\");\n\t\t\t} catch (error) {\n\t\t\t\terrors.push(error);\n\t\t\t}\n\t\t}\n\t\tthrowCleanupErrors(errors, manifest.id);\n\t};\n\ttry {\n\t\tapi = runtime.createAPI(manifest);\n\t\tinstance = normalizePluginInstance(await factory(api), manifest);\n\t\tawait dispatchPluginReadyEvent(runtime, manifest);\n\t\tconst pluginApi = api;\n\t\tlet disposePromise: Promise<void> | undefined;\n\t\treturn {\n\t\t\tmanifest,\n\t\t\tapi: pluginApi,\n\t\t\tready: Promise.resolve(),\n\t\t\tdispose: async () => {\n\t\t\t\tdisposePromise ??= (async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait cleanup(true);\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tif (active.get(manifest.id) === ownerToken) active.delete(manifest.id);\n\t\t\t\t\t}\n\t\t\t\t})();\n\t\t\t\treturn disposePromise;\n\t\t\t},\n\t\t};\n\t} catch (error) {\n\t\ttry {\n\t\t\tawait cleanup(false);\n\t\t} catch (cleanupError) {\n\t\t\tthrow new AggregateError([error, cleanupError], `Capability plugin startup cleanup failed: ${manifest.id}`);\n\t\t} finally {\n\t\t\tif (active.get(manifest.id) === ownerToken) active.delete(manifest.id);\n\t\t}\n\t\tthrow error;\n\t}\n}\n\n/** Load a synchronous embedded plugin during host construction. */\nexport function loadCapabilityPluginSync(\n\truntime: CapabilityRuntime,\n\tmanifest: PluginManifest,\n\tfactory: CapabilityPluginSyncFactory,\n): CapabilityPluginHandle {\n\tconst active = activePlugins.get(runtime) ?? new Map<string, symbol>();\n\tif (active.has(manifest.id)) throw new Error(t(\"Capability plugin is already loaded: {id}\", { id: manifest.id }));\n\tconst ownerToken = Symbol(manifest.id);\n\tactive.set(manifest.id, ownerToken);\n\tactivePlugins.set(runtime, active);\n\tlet api: CapabilityAPI | undefined;\n\tlet instance: CapabilityPluginSyncInstance | undefined;\n\tconst cleanupRegistrationsSync = (): unknown[] => {\n\t\tconst errors: unknown[] = [];\n\t\tif (api) runtime.revokeAPI(api);\n\t\ttry {\n\t\t\truntime.disposePluginSync(manifest.id);\n\t\t} catch (error) {\n\t\t\terrors.push(error);\n\t\t}\n\t\treturn errors;\n\t};\n\tconst cleanupSync = async (): Promise<void> => {\n\t\tconst errors = cleanupRegistrationsSync();\n\t\tlet result: unknown;\n\t\ttry {\n\t\t\tresult = instance?.dispose();\n\t\t} catch (error) {\n\t\t\terrors.push(error);\n\t\t}\n\t\tif (result && typeof (result as PromiseLike<void>).then === \"function\") {\n\t\t\tconst contractError = new Error(\n\t\t\t\t`Synchronous capability plugin disposer must not return a Promise: ${manifest.id}`,\n\t\t\t);\n\t\t\ttry {\n\t\t\t\tawait result;\n\t\t\t} catch (error) {\n\t\t\t\terrors.push(error);\n\t\t\t}\n\t\t\terrors.push(contractError);\n\t\t}\n\t\ttry {\n\t\t\tawait dispatchPluginDisposeEvent(runtime, manifest, errors.length === 0 ? \"disposed\" : \"failed\");\n\t\t} catch (error) {\n\t\t\terrors.push(error);\n\t\t}\n\t\tthrowCleanupErrors(errors, manifest.id);\n\t};\n\ttry {\n\t\tapi = runtime.createAPI(manifest);\n\t\tinstance = normalizePluginSyncInstance(factory(api), manifest);\n\t} catch (error) {\n\t\ttry {\n\t\t\tthrowCleanupErrors(cleanupRegistrationsSync(), manifest.id);\n\t\t} catch (cleanupError) {\n\t\t\tthrow new AggregateError([error, cleanupError], `Capability plugin startup cleanup failed: ${manifest.id}`);\n\t\t} finally {\n\t\t\tif (active.get(manifest.id) === ownerToken) active.delete(manifest.id);\n\t\t}\n\t\tthrow error;\n\t}\n\tconst ready = dispatchPluginReadyEvent(runtime, manifest);\n\t// The embedded constructor API is synchronous; retain a handled promise so\n\t// hosts may explicitly await lifecycle delivery without risking an unhandled rejection.\n\tvoid ready.catch(() => undefined);\n\tlet disposePromise: Promise<void> | undefined;\n\treturn {\n\t\tmanifest,\n\t\tapi: api!,\n\t\tready,\n\t\tdispose: async () => {\n\t\t\tdisposePromise ??= (async () => {\n\t\t\t\tlet readyError: unknown;\n\t\t\t\ttry {\n\t\t\t\t\tawait ready;\n\t\t\t\t} catch (error) {\n\t\t\t\t\treadyError = error;\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tawait cleanupSync();\n\t\t\t\t\tif (readyError !== undefined) throw readyError;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (readyError !== undefined && error !== readyError) {\n\t\t\t\t\t\tthrow new AggregateError([readyError, error], `Capability plugin cleanup failed: ${manifest.id}`);\n\t\t\t\t\t}\n\t\t\t\t\tthrow error;\n\t\t\t\t} finally {\n\t\t\t\t\tif (active.get(manifest.id) === ownerToken) active.delete(manifest.id);\n\t\t\t\t}\n\t\t\t})();\n\t\t\treturn disposePromise;\n\t\t},\n\t};\n}\n\n/**\n * Load a plugin from its JSON manifest. This is intentionally separate from\n * legacy extension discovery until both systems share the same public facade.\n *\n * `options.configOverride` (D-075 S4 third batch) merges host-declared values\n * over the manifest's own `config` defaults before the plugin API is built —\n * a public channel (first-party and third-party plugins alike) for hosts that\n * vouch for facts the manifest cannot know, e.g. the CLI declaring its own\n * process entry trustworthy so the subagent-delegate package auto-pools. It\n * stays below any plugin-side config channel: the agent-dir config file the\n * plugin entry reads merges over whatever the host injected here.\n */\nexport async function loadCapabilityPluginFromManifest(\n\truntime: CapabilityRuntime,\n\tmanifestPath: string,\n\toptions?: { readonly configOverride?: PluginConfig },\n): Promise<CapabilityPluginHandle> {\n\tlet raw: unknown;\n\ttry {\n\t\traw = JSON.parse(await readFile(manifestPath, \"utf8\"));\n\t} catch (error) {\n\t\tthrow new Error(\n\t\t\tt(\"Failed to read capability plugin manifest {path}: {reason}\", {\n\t\t\t\tpath: manifestPath,\n\t\t\t\treason: error instanceof Error ? error.message : String(error),\n\t\t\t}),\n\t\t);\n\t}\n\tconst parsed = parseCapabilityPluginManifest(raw, manifestPath);\n\t// hostDependencyPaths (安装店重依赖可见性): 宿主已解析的重依赖入口绝对路径\n\t// 并进 manifest config——安装店副本无 node_modules, 插件内 createRequire 自\n\t// 解析不可达 (memory 的 onnxruntime native 预检实证); 与 jiti alias 通道互补\n\t// (alias 拦截 import, 本通道喂插件内的路径式消费)。公共同道: 第一方与第三方\n\t// 插件同样可读。仍低于插件侧 config 文件通道 (agent-dir 配置合并在其上)。\n\tconst hostDependencyOverride = { hostDependencyPaths: hostDependencyPathsConfig() };\n\tconst callerOverride = options?.configOverride;\n\tconst manifest =\n\t\tcallerOverride === undefined || Object.keys(callerOverride).length === 0\n\t\t\t? { ...parsed, config: { ...parsed.config, ...hostDependencyOverride } }\n\t\t\t: { ...parsed, config: { ...parsed.config, ...hostDependencyOverride, ...callerOverride } };\n\tconst entryPath = path.resolve(path.dirname(manifestPath), manifest.entry);\n\t// Host-resolved authoring dependencies (D-075 §4.1): installed plugin\n\t// packages live in the install store, which carries no node_modules (npm\n\t// tarballs never include dependencies), so their bare imports of the SDK\n\t// and the pinned typebox dependency resolve against the host's own copies\n\t// through jiti virtual modules (./virtual-modules.ts, lazy). Works\n\t// identically in the bundle and Bun binaries where no source-tree\n\t// node_modules exists at all. D-075 S4 third batch: the protocol package\n\t// joins — the subagent-delegate package's runtime imports\n\t// (`@agent-forge/protocol`) resolve the same way. S4 fourth batch: the\n\t// memory package's native vector stack (`@lancedb/lancedb`,\n\t// `@huggingface/transformers`) resolves through the jiti alias channel\n\t// instead — those stay real host node_modules entries, so plugins load the\n\t// host's native builds rather than a virtual copy.\n\tconst [createJitiImpl, virtualModules] = await Promise.all([getCreateJiti(), getVirtualModules()]);\n\tconst jiti = createJitiImpl(import.meta.url, {\n\t\tmoduleCache: false,\n\t\ttsconfigPaths: true,\n\t\talias: buildHostDependencyAliases(hostHeavyDependencyAliases, defaultHostDependencyAliasResolution),\n\t\tvirtualModules,\n\t});\n\tlet factory: unknown;\n\ttry {\n\t\tfactory = await jiti.import(entryPath, { default: true });\n\t} catch (error) {\n\t\tthrow new Error(\n\t\t\tt(\"Failed to import capability plugin entry {path}: {reason}\", {\n\t\t\t\tpath: entryPath,\n\t\t\t\treason: error instanceof Error ? error.message : String(error),\n\t\t\t}),\n\t\t);\n\t}\n\tif (typeof factory !== \"function\") {\n\t\tthrow new Error(t(\"Capability plugin entry must default-export a factory function: {entryPath}\", { entryPath }));\n\t}\n\treturn loadCapabilityPlugin(runtime, manifest, factory as CapabilityPluginFactory);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"capability-plugin.js","sourceRoot":"","sources":["../../../src/core/extensions/capability-plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAKN,6BAA6B,GAC7B,MAAM,yBAAyB,CAAC;AAI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,IAAI,EAAE,CAAC,CAAC;IAC3D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CACd,CAAC,CAAC,2DAA2D,EAAE;YAC9D,IAAI,EAAE,SAAS;YACf,MAAM,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;SAC9D,CAAC,CACF,CAAC;IACH,CAAC;IACD,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,6EAA6E,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;IAClH,CAAC;IACD,OAAO,oBAAoB,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAkC,CAAC,CAAC;AAAA,CACnF","sourcesContent":["import type { Dirent } from \"node:fs\";\nimport { lstatSync, readdirSync, realpathSync, statSync } from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport { createRequire } from \"node:module\";\nimport * as path from \"node:path\";\nimport {\n\ttype CapabilityPluginFactory,\n\ttype CapabilityPluginInstance,\n\ttype CapabilityPluginSyncFactory,\n\ttype CapabilityPluginSyncInstance,\n\tparseCapabilityPluginManifest,\n} from \"@agent-forge/plugin-sdk\";\n// Type-only: the runtime dependency stays deferred until the first plugin\n// load (getCreateJiti below).\nimport type { createJiti } from \"jiti/static\";\nimport { t } from \"../i18n/index.ts\";\nimport type { CapabilityRuntime } from \"./capability-runtime.ts\";\nimport {\n\tPLUGIN_DISPOSE_EVENT_ID,\n\tPLUGIN_DISPOSE_EVENT_VERSION,\n\tPLUGIN_READY_EVENT_ID,\n\tPLUGIN_READY_EVENT_VERSION,\n\ttype PluginDisposeEventDataV1,\n} from \"./lifecycle-catalog.ts\";\nimport type { CapabilityAPI, PluginConfig, PluginManifest } from \"./public-api.ts\";\n\n// Authoring-surface symbols moved to @agent-forge/plugin-sdk (D-075 S2);\n// re-exported here so existing host imports keep resolving.\nexport type {\n\tCapabilityPluginFactory,\n\tCapabilityPluginFactoryResult,\n\tCapabilityPluginInstance,\n\tCapabilityPluginSyncFactory,\n\tCapabilityPluginSyncInstance,\n} from \"@agent-forge/plugin-sdk\";\nexport { parseCapabilityPluginManifest } from \"@agent-forge/plugin-sdk\";\n\nexport interface CapabilityPluginHandle {\n\treadonly manifest: PluginManifest;\n\treadonly api: CapabilityAPI;\n\t/** Resolves once the plugin.ready lifecycle delivery has settled. */\n\treadonly ready: Promise<void>;\n\tdispose(): Promise<void>;\n}\n\nconst activePlugins = new WeakMap<CapabilityRuntime, Map<string, symbol>>();\n\n// Upstream pi 40c256ccc parity: importing this module sits on every startup\n// path, so the jiti transform pipeline (Babel included) and the bundled\n// virtual modules stay deferred until the first plugin actually loads. The\n// dynamic imports below are deliberate lazy-load points; the thin\n// jiti-static-loader entry keeps jiti/static statically reachable for the\n// Bun and Node bundlers that must embed it.\nlet createJitiPromise: Promise<typeof createJiti> | undefined;\n\nfunction getCreateJiti(): Promise<typeof createJiti> {\n\tcreateJitiPromise ??= import(\"./jiti-static-loader.ts\").then((module) => module.createJiti);\n\treturn createJitiPromise;\n}\n\nlet virtualModulesPromise: Promise<Record<string, unknown>> | undefined;\n\nfunction getVirtualModules(): Promise<Record<string, unknown>> {\n\tvirtualModulesPromise ??= import(\"./virtual-modules.ts\").then((module) => module.VIRTUAL_MODULES);\n\treturn virtualModulesPromise;\n}\n\n// Host-resolved heavy-dependency aliases (D-075 S4 fourth batch, installed-\n// code-loading): the memory plugin package carries its vector stack pinned in\n// its own package.json; an npm-installed tarball ships no node_modules itself —\n// the install host materializes declared runtime dependencies into the store\n// copy (node-package-install-host), and this alias table stays a tolerant\n// fallback channel for stores that predate that or hosts without the package.\n// Unlike the SDK/protocol virtual modules below,\n// lancedb/transformers are NATIVE/lazy packages the host must not bundle or\n// import here: they stay host dependencies, and each specifier is resolved\n// ONCE (module-level cache, successes only) to the host's own entry file\n// path and handed to jiti as an alias. The alias reliably intercepts only\n// STATIC imports on the entry chain of files jiti transforms — lazy\n// `await import()` calls inside an installed ESM dist bypass the transform\n// pipeline and hit the native resolver, so those lazy paths are supplied by\n// the hostDependencyPaths absolute-path channel instead (hostDependencyPaths-\n// Config below plus the plugin-side host-module-import). Resolution failures\n// are tolerated on both channels: the alias table is a best-effort supply\n// path, and heavy-dependency failures must surface at the plugin's point of\n// use, where the memory plugin reports structured failures with an action\n// list.\nconst hostHeavyDependencyAliases: ReadonlySet<string> = new Set([\n\t\"@lancedb/lancedb\",\n\t\"@huggingface/transformers\",\n\t// memory 的 onnxruntime 预检(nativeBinaryCheck)在插件内直接 resolve 该传递\n\t// 依赖;与 transformers 同走宿主 alias 通道——安装店副本经依赖物化后自解析\n\t// 可达(node-package-install-host),宿主解析失败=条目缺席=插件侧回退,宽容契约不变。\n\t\"onnxruntime-node\",\n]);\n\nconst resolvedHeavyDependencyAliases: Map<string, string> = new Map();\n\n/**\n * Explicit injection object for {@link buildHostDependencyAliases}. Both fields\n * are required on purpose: with optional positional parameters a test could\n * inject only `resolve` and silently write its fake results into the\n * module-level production cache (`resolvedHeavyDependencyAliases`), hijacking\n * every later real plugin load in the same vitest worker. Making the object\n * mandatory means a test cannot supply a resolver without also supplying the\n * cache it pollutes.\n */\nexport interface HostDependencyAliasResolution {\n\treadonly resolve: (specifier: string) => string;\n\treadonly cache: Map<string, string>;\n}\n\nconst defaultHostDependencyAliasResolution: HostDependencyAliasResolution = {\n\tresolve: (specifier) => createRequire(import.meta.url).resolve(specifier),\n\tcache: resolvedHeavyDependencyAliases,\n};\n\n/**\n * Tolerant heavy-dependency resolution shared by the jiti alias channel and\n * the hostDependencyPaths config channel: each specifier is resolved against\n * the host installation (successes cached module-level), and a specifier that\n * fails to resolve is simply absent from the result. The alias table is a\n * best-effort supply path — heavy-dependency failures must surface at the\n * plugin's point of use, where the memory plugin reports structured failures\n * with an action list. Exported for deterministic tests; production callers\n * pass {@link defaultHostDependencyAliasResolution} explicitly.\n */\nexport function buildHostDependencyAliases(\n\tspecifiers: ReadonlySet<string> | readonly string[],\n\tresolution: HostDependencyAliasResolution,\n): Record<string, string> {\n\tconst aliases: Record<string, string> = {};\n\tfor (const specifier of specifiers) {\n\t\tconst cached = resolution.cache.get(specifier);\n\t\tif (cached !== undefined) {\n\t\t\taliases[specifier] = cached;\n\t\t\tcontinue;\n\t\t}\n\t\ttry {\n\t\t\tconst resolved = resolution.resolve(specifier);\n\t\t\tresolution.cache.set(specifier, resolved);\n\t\t\taliases[specifier] = resolved;\n\t\t} catch {\n\t\t\t// Tolerant by contract: absent entry = plugin-side fallback.\n\t\t}\n\t}\n\treturn aliases;\n}\n\n/**\n * Host-resolved heavy-dependency entry paths (specifier → absolute path) for\n * the config channel that feeds the lazy `await import()` paths the jiti\n * alias channel cannot reach (installed ESM dists bypass the transform\n * pipeline). Tolerant like the alias table: a specifier the host installation\n * cannot resolve is simply absent, and plugin code falls back to its own\n * resolution (or reports the structured failure). camelCase keys keep the\n * JSON config channel idiomatic for plugin consumers.\n */\nfunction hostDependencyPathsConfig(): Record<string, string> {\n\tconst paths: Record<string, string> = {};\n\tfor (const [specifier, entryPath] of Object.entries(\n\t\tbuildHostDependencyAliases(hostHeavyDependencyAliases, defaultHostDependencyAliasResolution),\n\t)) {\n\t\tpaths[camelCaseDependencyKey(specifier)] = entryPath;\n\t}\n\treturn paths;\n}\n\nfunction camelCaseDependencyKey(specifier: string): string {\n\tconst scoped = specifier.replace(/^@[^/]+\\//, \"\");\n\treturn scoped.replace(/[-.](.)/g, (_, character: string) => character.toUpperCase());\n}\n\nfunction isPluginInstance(value: unknown): value is CapabilityPluginInstance {\n\treturn typeof value === \"object\" && value !== null && typeof (value as { dispose?: unknown }).dispose === \"function\";\n}\n\nfunction normalizePluginInstance(value: unknown, manifest: PluginManifest): CapabilityPluginInstance | undefined {\n\tif (value === undefined) return undefined;\n\tif (!isPluginInstance(value)) {\n\t\tthrow new Error(\n\t\t\tt(\"Capability plugin factory must return void or an instance with dispose(): {id}\", { id: manifest.id }),\n\t\t);\n\t}\n\treturn value;\n}\n\nfunction normalizePluginSyncInstance(\n\tvalue: unknown,\n\tmanifest: PluginManifest,\n): CapabilityPluginSyncInstance | undefined {\n\tif (value === undefined) return undefined;\n\tif (!isPluginInstance(value)) {\n\t\tthrow new Error(\n\t\t\tt(\"Synchronous capability plugin factory must return void or an instance with dispose(): {id}\", {\n\t\t\t\tid: manifest.id,\n\t\t\t}),\n\t\t);\n\t}\n\treturn value as CapabilityPluginSyncInstance;\n}\n\nfunction throwCleanupErrors(errors: unknown[], manifestId: string): void {\n\tif (errors.length === 0) return;\n\tif (errors.length === 1) throw errors[0];\n\tthrow new AggregateError(errors, `Capability plugin cleanup failed: ${manifestId}`);\n}\n\nasync function dispatchPluginDisposeEvent(\n\truntime: CapabilityRuntime,\n\tmanifest: PluginManifest,\n\tstatus: PluginDisposeEventDataV1[\"status\"],\n): Promise<void> {\n\tif (!runtime.hasLifecycleEvent(PLUGIN_DISPOSE_EVENT_ID, PLUGIN_DISPOSE_EVENT_VERSION)) return;\n\tawait runtime.dispatchLifecycle({\n\t\ttype: PLUGIN_DISPOSE_EVENT_ID,\n\t\tversion: PLUGIN_DISPOSE_EVENT_VERSION,\n\t\tphase: \"committed\",\n\t\tdata: {\n\t\t\tversion: 1,\n\t\t\tpluginId: manifest.id,\n\t\t\tpluginVersion: manifest.version,\n\t\t\tstatus,\n\t\t},\n\t\tsource: \"capability-plugin\",\n\t});\n}\n\nasync function dispatchPluginReadyEvent(runtime: CapabilityRuntime, manifest: PluginManifest): Promise<void> {\n\tif (!runtime.hasLifecycleEvent(PLUGIN_READY_EVENT_ID, PLUGIN_READY_EVENT_VERSION)) return;\n\tawait runtime.dispatchLifecycle({\n\t\ttype: PLUGIN_READY_EVENT_ID,\n\t\tversion: PLUGIN_READY_EVENT_VERSION,\n\t\tphase: \"committed\",\n\t\tdata: {\n\t\t\tversion: 1,\n\t\t\tpluginId: manifest.id,\n\t\t\tpluginVersion: manifest.version,\n\t\t},\n\t\tsource: \"capability-plugin\",\n\t});\n}\n\nfunction isMissingPathError(error: unknown): boolean {\n\treturn typeof error === \"object\" && error !== null && \"code\" in error && error.code === \"ENOENT\";\n}\n\nfunction compareNames(left: string, right: string): number {\n\treturn left < right ? -1 : left > right ? 1 : 0;\n}\n\n/**\n * Find installed capability manifests below the given plugin directories.\n *\n * Directories are visited in caller order; entries in each directory use a\n * stable lexical order. Missing roots are normal for a first-run host.\n * Existing unreadable or malformed filesystem paths fail explicitly rather\n * than silently changing the loaded plugin set. Dependency and hidden\n * directories are never traversed.\n */\nexport function discoverCapabilityPluginManifests(pluginDirectories: readonly string[]): string[] {\n\tconst manifests: string[] = [];\n\tconst seenDirectories = new Set<string>();\n\tconst seenManifests = new Set<string>();\n\n\tconst visit = (directory: string, optional: boolean): void => {\n\t\tconst resolvedDirectory = path.resolve(directory);\n\t\tlet stats: ReturnType<typeof statSync>;\n\t\ttry {\n\t\t\tstats = statSync(resolvedDirectory);\n\t\t} catch (error) {\n\t\t\tif (optional && isMissingPathError(error)) {\n\t\t\t\ttry {\n\t\t\t\t\tif (!lstatSync(resolvedDirectory).isSymbolicLink()) return;\n\t\t\t\t} catch (linkError) {\n\t\t\t\t\tif (isMissingPathError(linkError)) return;\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\tt(\"Failed to inspect capability plugin directory {directory}: {reason}\", {\n\t\t\t\t\t\t\tdirectory: resolvedDirectory,\n\t\t\t\t\t\t\treason: linkError instanceof Error ? linkError.message : String(linkError),\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow new Error(\n\t\t\t\tt(\"Failed to inspect capability plugin directory {directory}: {reason}\", {\n\t\t\t\t\tdirectory: resolvedDirectory,\n\t\t\t\t\treason: error instanceof Error ? error.message : String(error),\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t\tif (!stats.isDirectory()) {\n\t\t\tthrow new Error(\n\t\t\t\tt(\"Capability plugin path must be a directory: {directory}\", { directory: resolvedDirectory }),\n\t\t\t);\n\t\t}\n\n\t\tlet canonicalDirectory: string;\n\t\ttry {\n\t\t\tcanonicalDirectory = realpathSync(resolvedDirectory);\n\t\t} catch (error) {\n\t\t\tthrow new Error(\n\t\t\t\tt(\"Failed to resolve capability plugin directory {directory}: {reason}\", {\n\t\t\t\t\tdirectory: resolvedDirectory,\n\t\t\t\t\treason: error instanceof Error ? error.message : String(error),\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t\tif (seenDirectories.has(canonicalDirectory)) return;\n\t\tseenDirectories.add(canonicalDirectory);\n\n\t\tlet entries: Dirent<string>[];\n\t\ttry {\n\t\t\tentries = readdirSync(resolvedDirectory, { withFileTypes: true, encoding: \"utf8\" });\n\t\t} catch (error) {\n\t\t\tthrow new Error(\n\t\t\t\tt(\"Failed to read capability plugin directory {directory}: {reason}\", {\n\t\t\t\t\tdirectory: resolvedDirectory,\n\t\t\t\t\treason: error instanceof Error ? error.message : String(error),\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tfor (const entry of entries.sort((left, right) => compareNames(left.name, right.name))) {\n\t\t\tif (entry.name === \"node_modules\" || entry.name.startsWith(\".\")) continue;\n\t\t\tconst entryPath = path.join(resolvedDirectory, entry.name);\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tvisit(entryPath, false);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!entry.isFile() || entry.name !== \"plugin.json\") continue;\n\n\t\t\tlet canonicalManifest: string;\n\t\t\ttry {\n\t\t\t\tcanonicalManifest = realpathSync(entryPath);\n\t\t\t} catch (error) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\tt(\"Failed to resolve capability plugin manifest {path}: {reason}\", {\n\t\t\t\t\t\tpath: entryPath,\n\t\t\t\t\t\treason: error instanceof Error ? error.message : String(error),\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (seenManifests.has(canonicalManifest)) continue;\n\t\t\tseenManifests.add(canonicalManifest);\n\t\t\tmanifests.push(canonicalManifest);\n\t\t}\n\t};\n\n\tfor (const pluginDirectory of pluginDirectories) visit(pluginDirectory, true);\n\treturn manifests;\n}\n\n/**\n * Load a capability plugin through the public facade only.\n * Filesystem discovery and package installation stay outside this mechanism.\n */\nexport async function loadCapabilityPlugin(\n\truntime: CapabilityRuntime,\n\tmanifest: PluginManifest,\n\tfactory: CapabilityPluginFactory,\n): Promise<CapabilityPluginHandle> {\n\tconst active = activePlugins.get(runtime) ?? new Map<string, symbol>();\n\tif (active.has(manifest.id)) throw new Error(t(\"Capability plugin is already loaded: {id}\", { id: manifest.id }));\n\tconst ownerToken = Symbol(manifest.id);\n\tactive.set(manifest.id, ownerToken);\n\tactivePlugins.set(runtime, active);\n\tlet api: CapabilityAPI | undefined;\n\tlet instance: CapabilityPluginInstance | undefined;\n\tconst cleanup = async (notifyDispose: boolean): Promise<void> => {\n\t\tconst errors: unknown[] = [];\n\t\tif (api) runtime.revokeAPI(api);\n\t\ttry {\n\t\t\tawait runtime.disposePlugin(manifest.id);\n\t\t} catch (error) {\n\t\t\terrors.push(error);\n\t\t}\n\t\ttry {\n\t\t\tawait instance?.dispose();\n\t\t} catch (error) {\n\t\t\terrors.push(error);\n\t\t}\n\t\tif (notifyDispose) {\n\t\t\ttry {\n\t\t\t\tawait dispatchPluginDisposeEvent(runtime, manifest, errors.length === 0 ? \"disposed\" : \"failed\");\n\t\t\t} catch (error) {\n\t\t\t\terrors.push(error);\n\t\t\t}\n\t\t}\n\t\tthrowCleanupErrors(errors, manifest.id);\n\t};\n\ttry {\n\t\tapi = runtime.createAPI(manifest);\n\t\tinstance = normalizePluginInstance(await factory(api), manifest);\n\t\tawait dispatchPluginReadyEvent(runtime, manifest);\n\t\tconst pluginApi = api;\n\t\tlet disposePromise: Promise<void> | undefined;\n\t\treturn {\n\t\t\tmanifest,\n\t\t\tapi: pluginApi,\n\t\t\tready: Promise.resolve(),\n\t\t\tdispose: async () => {\n\t\t\t\tdisposePromise ??= (async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait cleanup(true);\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tif (active.get(manifest.id) === ownerToken) active.delete(manifest.id);\n\t\t\t\t\t}\n\t\t\t\t})();\n\t\t\t\treturn disposePromise;\n\t\t\t},\n\t\t};\n\t} catch (error) {\n\t\ttry {\n\t\t\tawait cleanup(false);\n\t\t} catch (cleanupError) {\n\t\t\tthrow new AggregateError([error, cleanupError], `Capability plugin startup cleanup failed: ${manifest.id}`);\n\t\t} finally {\n\t\t\tif (active.get(manifest.id) === ownerToken) active.delete(manifest.id);\n\t\t}\n\t\tthrow error;\n\t}\n}\n\n/** Load a synchronous embedded plugin during host construction. */\nexport function loadCapabilityPluginSync(\n\truntime: CapabilityRuntime,\n\tmanifest: PluginManifest,\n\tfactory: CapabilityPluginSyncFactory,\n): CapabilityPluginHandle {\n\tconst active = activePlugins.get(runtime) ?? new Map<string, symbol>();\n\tif (active.has(manifest.id)) throw new Error(t(\"Capability plugin is already loaded: {id}\", { id: manifest.id }));\n\tconst ownerToken = Symbol(manifest.id);\n\tactive.set(manifest.id, ownerToken);\n\tactivePlugins.set(runtime, active);\n\tlet api: CapabilityAPI | undefined;\n\tlet instance: CapabilityPluginSyncInstance | undefined;\n\tconst cleanupRegistrationsSync = (): unknown[] => {\n\t\tconst errors: unknown[] = [];\n\t\tif (api) runtime.revokeAPI(api);\n\t\ttry {\n\t\t\truntime.disposePluginSync(manifest.id);\n\t\t} catch (error) {\n\t\t\terrors.push(error);\n\t\t}\n\t\treturn errors;\n\t};\n\tconst cleanupSync = async (): Promise<void> => {\n\t\tconst errors = cleanupRegistrationsSync();\n\t\tlet result: unknown;\n\t\ttry {\n\t\t\tresult = instance?.dispose();\n\t\t} catch (error) {\n\t\t\terrors.push(error);\n\t\t}\n\t\tif (result && typeof (result as PromiseLike<void>).then === \"function\") {\n\t\t\tconst contractError = new Error(\n\t\t\t\t`Synchronous capability plugin disposer must not return a Promise: ${manifest.id}`,\n\t\t\t);\n\t\t\ttry {\n\t\t\t\tawait result;\n\t\t\t} catch (error) {\n\t\t\t\terrors.push(error);\n\t\t\t}\n\t\t\terrors.push(contractError);\n\t\t}\n\t\ttry {\n\t\t\tawait dispatchPluginDisposeEvent(runtime, manifest, errors.length === 0 ? \"disposed\" : \"failed\");\n\t\t} catch (error) {\n\t\t\terrors.push(error);\n\t\t}\n\t\tthrowCleanupErrors(errors, manifest.id);\n\t};\n\ttry {\n\t\tapi = runtime.createAPI(manifest);\n\t\tinstance = normalizePluginSyncInstance(factory(api), manifest);\n\t} catch (error) {\n\t\ttry {\n\t\t\tthrowCleanupErrors(cleanupRegistrationsSync(), manifest.id);\n\t\t} catch (cleanupError) {\n\t\t\tthrow new AggregateError([error, cleanupError], `Capability plugin startup cleanup failed: ${manifest.id}`);\n\t\t} finally {\n\t\t\tif (active.get(manifest.id) === ownerToken) active.delete(manifest.id);\n\t\t}\n\t\tthrow error;\n\t}\n\tconst ready = dispatchPluginReadyEvent(runtime, manifest);\n\t// The embedded constructor API is synchronous; retain a handled promise so\n\t// hosts may explicitly await lifecycle delivery without risking an unhandled rejection.\n\tvoid ready.catch(() => undefined);\n\tlet disposePromise: Promise<void> | undefined;\n\treturn {\n\t\tmanifest,\n\t\tapi: api!,\n\t\tready,\n\t\tdispose: async () => {\n\t\t\tdisposePromise ??= (async () => {\n\t\t\t\tlet readyError: unknown;\n\t\t\t\ttry {\n\t\t\t\t\tawait ready;\n\t\t\t\t} catch (error) {\n\t\t\t\t\treadyError = error;\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tawait cleanupSync();\n\t\t\t\t\tif (readyError !== undefined) throw readyError;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (readyError !== undefined && error !== readyError) {\n\t\t\t\t\t\tthrow new AggregateError([readyError, error], `Capability plugin cleanup failed: ${manifest.id}`);\n\t\t\t\t\t}\n\t\t\t\t\tthrow error;\n\t\t\t\t} finally {\n\t\t\t\t\tif (active.get(manifest.id) === ownerToken) active.delete(manifest.id);\n\t\t\t\t}\n\t\t\t})();\n\t\t\treturn disposePromise;\n\t\t},\n\t};\n}\n\n/**\n * Load a plugin from its JSON manifest. This is intentionally separate from\n * legacy extension discovery until both systems share the same public facade.\n *\n * `options.configOverride` (D-075 S4 third batch) merges host-declared values\n * over the manifest's own `config` defaults before the plugin API is built —\n * a public channel (first-party and third-party plugins alike) for hosts that\n * vouch for facts the manifest cannot know, e.g. the CLI declaring its own\n * process entry trustworthy so the subagent-delegate package auto-pools. It\n * stays below any plugin-side config channel: the agent-dir config file the\n * plugin entry reads merges over whatever the host injected here.\n */\nexport async function loadCapabilityPluginFromManifest(\n\truntime: CapabilityRuntime,\n\tmanifestPath: string,\n\toptions?: { readonly configOverride?: PluginConfig },\n): Promise<CapabilityPluginHandle> {\n\tlet raw: unknown;\n\ttry {\n\t\traw = JSON.parse(await readFile(manifestPath, \"utf8\"));\n\t} catch (error) {\n\t\tthrow new Error(\n\t\t\tt(\"Failed to read capability plugin manifest {path}: {reason}\", {\n\t\t\t\tpath: manifestPath,\n\t\t\t\treason: error instanceof Error ? error.message : String(error),\n\t\t\t}),\n\t\t);\n\t}\n\tconst parsed = parseCapabilityPluginManifest(raw, manifestPath);\n\t// hostDependencyPaths (安装店重依赖可见性): 宿主已解析的重依赖入口绝对路径\n\t// 并进 manifest config——npm tarball 形态的安装店副本自身无依赖树, 声明运行\n\t// 依赖的包由安装宿主物化 (node-package-install-host), 未物化的副本里插件内\n\t// createRequire 自解析不可达 (memory 的 onnxruntime native 预检实证); 与 jiti alias 通道互补\n\t// (alias 拦截 import, 本通道喂插件内的路径式消费)。公共同道: 第一方与第三方\n\t// 插件同样可读。仍低于插件侧 config 文件通道 (agent-dir 配置合并在其上)。\n\tconst hostDependencyOverride = { hostDependencyPaths: hostDependencyPathsConfig() };\n\tconst callerOverride = options?.configOverride;\n\tconst manifest =\n\t\tcallerOverride === undefined || Object.keys(callerOverride).length === 0\n\t\t\t? { ...parsed, config: { ...parsed.config, ...hostDependencyOverride } }\n\t\t\t: { ...parsed, config: { ...parsed.config, ...hostDependencyOverride, ...callerOverride } };\n\tconst entryPath = path.resolve(path.dirname(manifestPath), manifest.entry);\n\t// Host-resolved authoring dependencies (D-075 §4.1): installed plugin\n\t// packages live in the install store; npm tarballs never include\n\t// dependencies, and the SDK and pinned typebox specifiers stay\n\t// host-supplied by contract (the install host skips them when\n\t// materializing runtime dependencies, see node-package-install-host), so\n\t// their bare imports resolve against the host's own copies\n\t// through jiti virtual modules (./virtual-modules.ts, lazy). Works\n\t// identically in the bundle and Bun binaries where no source-tree\n\t// node_modules exists at all. D-075 S4 third batch: the protocol package\n\t// joins — the subagent-delegate package's runtime imports\n\t// (`@agent-forge/protocol`) resolve the same way. S4 fourth batch: the\n\t// memory package's native vector stack (`@lancedb/lancedb`,\n\t// `@huggingface/transformers`) resolves through the jiti alias channel\n\t// instead — those stay real host node_modules entries, so plugins load the\n\t// host's native builds rather than a virtual copy.\n\tconst [createJitiImpl, virtualModules] = await Promise.all([getCreateJiti(), getVirtualModules()]);\n\tconst jiti = createJitiImpl(import.meta.url, {\n\t\tmoduleCache: false,\n\t\ttsconfigPaths: true,\n\t\talias: buildHostDependencyAliases(hostHeavyDependencyAliases, defaultHostDependencyAliasResolution),\n\t\tvirtualModules,\n\t});\n\tlet factory: unknown;\n\ttry {\n\t\tfactory = await jiti.import(entryPath, { default: true });\n\t} catch (error) {\n\t\tthrow new Error(\n\t\t\tt(\"Failed to import capability plugin entry {path}: {reason}\", {\n\t\t\t\tpath: entryPath,\n\t\t\t\treason: error instanceof Error ? error.message : String(error),\n\t\t\t}),\n\t\t);\n\t}\n\tif (typeof factory !== \"function\") {\n\t\tthrow new Error(t(\"Capability plugin entry must default-export a factory function: {entryPath}\", { entryPath }));\n\t}\n\treturn loadCapabilityPlugin(runtime, manifest, factory as CapabilityPluginFactory);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtual-modules.d.ts","sourceRoot":"","sources":["../../../src/core/extensions/virtual-modules.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"virtual-modules.d.ts","sourceRoot":"","sources":["../../../src/core/extensions/virtual-modules.ts"],"names":[],"mappings":"AAqDA,kFAAkF;AAClF,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAkDnD,CAAC","sourcesContent":["// Virtual modules the host supplies to installed capability plugins through\n// jiti: npm tarballs never include dependencies, and the install host skips\n// these host-supplied specifiers when materializing runtime dependencies into\n// a store copy (node-package-install-host), so their bare imports always\n// resolve against the host's own copies.\n// The imports below MUST stay static so the Node bundle and the Bun binary\n// embed the modules; the file itself is loaded lazily by capability-plugin.ts\n// (upstream pi 40c256ccc parity) so importing the loader costs nothing until\n// the first plugin load.\n//\n// The full key list below is the host module supply contract (D-082 ruling 3;\n// registry entry `plugin.host-module-supply`): any capability plugin may\n// declare and import these exact specifiers. Adding or removing a supplied\n// specifier must update HOST_SUPPLIED_PLUGIN_SPECIFIERS in\n// scripts/check-plugin-boundary.mjs and the root tsconfig.json paths in the\n// same change (sync enforced by test/host-module-supply.test.ts).\nimport * as aiCompat from \"@agent-forge/ai/compat\";\nimport * as pluginSdk from \"@agent-forge/plugin-sdk\";\nimport * as pluginSdkSessionLineage from \"@agent-forge/plugin-sdk/session-lineage\";\nimport * as protocol from \"@agent-forge/protocol\";\nimport * as protocolSubagent from \"@agent-forge/protocol/subagent\";\nimport * as tui from \"@agent-forge/tui\";\nimport * as typebox from \"typebox\";\nimport * as typeboxValue from \"typebox/value\";\n// Same undici copy the http-dispatcher already bundles: plugin packages\n// declare it pinned but undici stays host-supplied (the install-time\n// dependency materialization skips host-supplied specifiers), so the\n// image-generation plugin's proxy-aware fetch resolves to this namespace.\nimport * as undici from \"undici\";\nimport * as hostDiff from \"../../modes/interactive/components/diff.ts\";\nimport * as hostKeybindingHints from \"../../modes/interactive/components/keybinding-hints.ts\";\nimport * as hostVisualTruncate from \"../../modes/interactive/components/visual-truncate.ts\";\nimport * as hostTheme from \"../../theme/theme.ts\";\nimport * as hostAnsi from \"../../utils/ansi.ts\";\nimport * as hostChildProcess from \"../../utils/child-process.ts\";\nimport * as hostImageProcess from \"../../utils/image-process.ts\";\nimport * as hostMime from \"../../utils/mime.ts\";\nimport * as hostPaths from \"../../utils/paths.ts\";\nimport * as hostShell from \"../../utils/shell.ts\";\nimport * as hostText from \"../../utils/text.ts\";\nimport * as hostToolsManager from \"../../utils/tools-manager.ts\";\nimport * as hostCompaction from \"../compaction/index.ts\";\nimport * as hostI18n from \"../i18n/index.ts\";\nimport * as hostBashOperations from \"../tools/bash-operations.ts\";\nimport * as hostEditDiff from \"../tools/edit-diff.ts\";\nimport * as hostFileMutationQueue from \"../tools/file-mutation-queue.ts\";\nimport * as hostOutputAccumulator from \"../tools/output-accumulator.ts\";\nimport * as hostPathUtils from \"../tools/path-utils.ts\";\nimport * as hostReadmePath from \"../tools/readme-path.ts\";\nimport * as hostRenderUtils from \"../tools/render-utils.ts\";\nimport * as hostToolDefinition from \"../tools/tool-definition.ts\";\nimport * as hostTruncate from \"../tools/truncate.ts\";\n\n/** Modules available to capability plugins via the jiti virtualModules option. */\nexport const VIRTUAL_MODULES: Record<string, unknown> = {\n\t\"@agent-forge/plugin-sdk\": pluginSdk,\n\t\"@agent-forge/plugin-sdk/session-lineage\": pluginSdkSessionLineage,\n\t\"@agent-forge/protocol/subagent\": protocolSubagent,\n\t// 记忆插件 Slice B2 起 inference-{client,protocol}.ts import 根说明符\n\t// (FrameDecoder/encodeFrame/decodeCbor)——protocol 属宿主供给面, 安装物化\n\t// 时跳过、tarball 也不含依赖树, 缺此条即 plugin_load_failed (0.88.2 安装链回归, 2026-10-07 修复)。\n\t\"@agent-forge/protocol\": protocol,\n\ttypebox,\n\t\"typebox/value\": typeboxValue,\n\t// 0.85.13 regression fix (0.85.14): the image-generation plugin's\n\t// undici dependency (EnvHttpProxyAgent proxy support) resolved to\n\t// nowhere in the install-store shape and the plugin failed to load\n\t// (\"Cannot find module 'undici'\"). Virtual module = the host's own\n\t// copy, identical in the bundle and Bun binary forms; red-verified\n\t// by test/plugin-virtual-undici.test.ts.\n\tundici,\n\t// Host module supply contract (D-082): rendering and tool-support modules\n\t// for capability plugins (coding-tools first). Contract notes live in the\n\t// file header; the sync gate is test/host-module-supply.test.ts. The host\n\t// namespaces are spread into plain objects: jiti's CJS interop touches the\n\t// module namespace's `default` property, and vitest's namespace proxies for\n\t// inlined source modules (including vi.mock replacements) throw on a\n\t// missing `default`, which failed the whole plugin entry import.\n\t\"@agent-forge/tui\": { ...tui },\n\t// D-082 批 3:默认策略插件的运行时依赖供给(ai 兼容层分类器、压缩摘要执行机制)。\n\t\"@agent-forge/ai/compat\": { ...aiCompat },\n\t\"@agent-forge/host/compaction\": { ...hostCompaction },\n\t\"@agent-forge/host/i18n\": { ...hostI18n },\n\t\"@agent-forge/host/theme\": { ...hostTheme },\n\t\"@agent-forge/host/keybinding-hints\": { ...hostKeybindingHints },\n\t\"@agent-forge/host/visual-truncate\": { ...hostVisualTruncate },\n\t\"@agent-forge/host/diff\": { ...hostDiff },\n\t\"@agent-forge/host/render-utils\": { ...hostRenderUtils },\n\t\"@agent-forge/host/tool-definition\": { ...hostToolDefinition },\n\t\"@agent-forge/host/truncate\": { ...hostTruncate },\n\t\"@agent-forge/host/edit-diff\": { ...hostEditDiff },\n\t\"@agent-forge/host/file-mutation-queue\": { ...hostFileMutationQueue },\n\t\"@agent-forge/host/output-accumulator\": { ...hostOutputAccumulator },\n\t\"@agent-forge/host/path-utils\": { ...hostPathUtils },\n\t\"@agent-forge/host/readme-path\": { ...hostReadmePath },\n\t\"@agent-forge/host/paths\": { ...hostPaths },\n\t\"@agent-forge/host/shell\": { ...hostShell },\n\t\"@agent-forge/host/text\": { ...hostText },\n\t\"@agent-forge/host/ansi\": { ...hostAnsi },\n\t\"@agent-forge/host/mime\": { ...hostMime },\n\t\"@agent-forge/host/image-process\": { ...hostImageProcess },\n\t\"@agent-forge/host/child-process\": { ...hostChildProcess },\n\t\"@agent-forge/host/tools-manager\": { ...hostToolsManager },\n\t\"@agent-forge/host/bash-operations\": { ...hostBashOperations },\n};\n"]}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// Virtual modules the host supplies to installed capability plugins through
|
|
2
|
-
// jiti:
|
|
3
|
-
//
|
|
2
|
+
// jiti: npm tarballs never include dependencies, and the install host skips
|
|
3
|
+
// these host-supplied specifiers when materializing runtime dependencies into
|
|
4
|
+
// a store copy (node-package-install-host), so their bare imports always
|
|
5
|
+
// resolve against the host's own copies.
|
|
4
6
|
// The imports below MUST stay static so the Node bundle and the Bun binary
|
|
5
7
|
// embed the modules; the file itself is loaded lazily by capability-plugin.ts
|
|
6
8
|
// (upstream pi 40c256ccc parity) so importing the loader costs nothing until
|
|
@@ -21,7 +23,8 @@ import * as tui from "@agent-forge/tui";
|
|
|
21
23
|
import * as typebox from "typebox";
|
|
22
24
|
import * as typeboxValue from "typebox/value";
|
|
23
25
|
// Same undici copy the http-dispatcher already bundles: plugin packages
|
|
24
|
-
// declare it pinned but
|
|
26
|
+
// declare it pinned but undici stays host-supplied (the install-time
|
|
27
|
+
// dependency materialization skips host-supplied specifiers), so the
|
|
25
28
|
// image-generation plugin's proxy-aware fetch resolves to this namespace.
|
|
26
29
|
import * as undici from "undici";
|
|
27
30
|
import * as hostDiff from "../../modes/interactive/components/diff.js";
|
|
@@ -53,8 +56,8 @@ export const VIRTUAL_MODULES = {
|
|
|
53
56
|
"@agent-forge/plugin-sdk/session-lineage": pluginSdkSessionLineage,
|
|
54
57
|
"@agent-forge/protocol/subagent": protocolSubagent,
|
|
55
58
|
// 记忆插件 Slice B2 起 inference-{client,protocol}.ts import 根说明符
|
|
56
|
-
// (FrameDecoder/encodeFrame/decodeCbor)
|
|
57
|
-
// 缺此条即 plugin_load_failed (0.88.2 安装链回归, 2026-10-07 修复)。
|
|
59
|
+
// (FrameDecoder/encodeFrame/decodeCbor)——protocol 属宿主供给面, 安装物化
|
|
60
|
+
// 时跳过、tarball 也不含依赖树, 缺此条即 plugin_load_failed (0.88.2 安装链回归, 2026-10-07 修复)。
|
|
58
61
|
"@agent-forge/protocol": protocol,
|
|
59
62
|
typebox,
|
|
60
63
|
"typebox/value": typeboxValue,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtual-modules.js","sourceRoot":"","sources":["../../../src/core/extensions/virtual-modules.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,
|
|
1
|
+
{"version":3,"file":"virtual-modules.js","sourceRoot":"","sources":["../../../src/core/extensions/virtual-modules.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,4EAA4E;AAC5E,8EAA8E;AAC9E,yEAAyE;AACzE,yCAAyC;AACzC,2EAA2E;AAC3E,8EAA8E;AAC9E,6EAA6E;AAC7E,yBAAyB;AACzB,EAAE;AACF,8EAA8E;AAC9E,yEAAyE;AACzE,2EAA2E;AAC3E,2DAA2D;AAC3D,4EAA4E;AAC5E,kEAAkE;AAClE,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,SAAS,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,uBAAuB,MAAM,yCAAyC,CAAC;AACnF,OAAO,KAAK,QAAQ,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,gBAAgB,MAAM,gCAAgC,CAAC;AACnE,OAAO,KAAK,GAAG,MAAM,kBAAkB,CAAC;AACxC,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,KAAK,YAAY,MAAM,eAAe,CAAC;AAC9C,wEAAwE;AACxE,qEAAqE;AACrE,qEAAqE;AACrE,0EAA0E;AAC1E,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,QAAQ,MAAM,4CAA4C,CAAC;AACvE,OAAO,KAAK,mBAAmB,MAAM,wDA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,EAAE,EAAE,GAAG,gBAAgB,EAAE;IAC1D,iCAAiC,EAAE,EAAE,GAAG,gBAAgB,EAAE;IAC1D,mCAAmC,EAAE,EAAE,GAAG,kBAAkB,EAAE;CAC9D,CAAC","sourcesContent":["// Virtual modules the host supplies to installed capability plugins through\n// jiti: npm tarballs never include dependencies, and the install host skips\n// these host-supplied specifiers when materializing runtime dependencies into\n// a store copy (node-package-install-host), so their bare imports always\n// resolve against the host's own copies.\n// The imports below MUST stay static so the Node bundle and the Bun binary\n// embed the modules; the file itself is loaded lazily by capability-plugin.ts\n// (upstream pi 40c256ccc parity) so importing the loader costs nothing until\n// the first plugin load.\n//\n// The full key list below is the host module supply contract (D-082 ruling 3;\n// registry entry `plugin.host-module-supply`): any capability plugin may\n// declare and import these exact specifiers. Adding or removing a supplied\n// specifier must update HOST_SUPPLIED_PLUGIN_SPECIFIERS in\n// scripts/check-plugin-boundary.mjs and the root tsconfig.json paths in the\n// same change (sync enforced by test/host-module-supply.test.ts).\nimport * as aiCompat from \"@agent-forge/ai/compat\";\nimport * as pluginSdk from \"@agent-forge/plugin-sdk\";\nimport * as pluginSdkSessionLineage from \"@agent-forge/plugin-sdk/session-lineage\";\nimport * as protocol from \"@agent-forge/protocol\";\nimport * as protocolSubagent from \"@agent-forge/protocol/subagent\";\nimport * as tui from \"@agent-forge/tui\";\nimport * as typebox from \"typebox\";\nimport * as typeboxValue from \"typebox/value\";\n// Same undici copy the http-dispatcher already bundles: plugin packages\n// declare it pinned but undici stays host-supplied (the install-time\n// dependency materialization skips host-supplied specifiers), so the\n// image-generation plugin's proxy-aware fetch resolves to this namespace.\nimport * as undici from \"undici\";\nimport * as hostDiff from \"../../modes/interactive/components/diff.ts\";\nimport * as hostKeybindingHints from \"../../modes/interactive/components/keybinding-hints.ts\";\nimport * as hostVisualTruncate from \"../../modes/interactive/components/visual-truncate.ts\";\nimport * as hostTheme from \"../../theme/theme.ts\";\nimport * as hostAnsi from \"../../utils/ansi.ts\";\nimport * as hostChildProcess from \"../../utils/child-process.ts\";\nimport * as hostImageProcess from \"../../utils/image-process.ts\";\nimport * as hostMime from \"../../utils/mime.ts\";\nimport * as hostPaths from \"../../utils/paths.ts\";\nimport * as hostShell from \"../../utils/shell.ts\";\nimport * as hostText from \"../../utils/text.ts\";\nimport * as hostToolsManager from \"../../utils/tools-manager.ts\";\nimport * as hostCompaction from \"../compaction/index.ts\";\nimport * as hostI18n from \"../i18n/index.ts\";\nimport * as hostBashOperations from \"../tools/bash-operations.ts\";\nimport * as hostEditDiff from \"../tools/edit-diff.ts\";\nimport * as hostFileMutationQueue from \"../tools/file-mutation-queue.ts\";\nimport * as hostOutputAccumulator from \"../tools/output-accumulator.ts\";\nimport * as hostPathUtils from \"../tools/path-utils.ts\";\nimport * as hostReadmePath from \"../tools/readme-path.ts\";\nimport * as hostRenderUtils from \"../tools/render-utils.ts\";\nimport * as hostToolDefinition from \"../tools/tool-definition.ts\";\nimport * as hostTruncate from \"../tools/truncate.ts\";\n\n/** Modules available to capability plugins via the jiti virtualModules option. */\nexport const VIRTUAL_MODULES: Record<string, unknown> = {\n\t\"@agent-forge/plugin-sdk\": pluginSdk,\n\t\"@agent-forge/plugin-sdk/session-lineage\": pluginSdkSessionLineage,\n\t\"@agent-forge/protocol/subagent\": protocolSubagent,\n\t// 记忆插件 Slice B2 起 inference-{client,protocol}.ts import 根说明符\n\t// (FrameDecoder/encodeFrame/decodeCbor)——protocol 属宿主供给面, 安装物化\n\t// 时跳过、tarball 也不含依赖树, 缺此条即 plugin_load_failed (0.88.2 安装链回归, 2026-10-07 修复)。\n\t\"@agent-forge/protocol\": protocol,\n\ttypebox,\n\t\"typebox/value\": typeboxValue,\n\t// 0.85.13 regression fix (0.85.14): the image-generation plugin's\n\t// undici dependency (EnvHttpProxyAgent proxy support) resolved to\n\t// nowhere in the install-store shape and the plugin failed to load\n\t// (\"Cannot find module 'undici'\"). Virtual module = the host's own\n\t// copy, identical in the bundle and Bun binary forms; red-verified\n\t// by test/plugin-virtual-undici.test.ts.\n\tundici,\n\t// Host module supply contract (D-082): rendering and tool-support modules\n\t// for capability plugins (coding-tools first). Contract notes live in the\n\t// file header; the sync gate is test/host-module-supply.test.ts. The host\n\t// namespaces are spread into plain objects: jiti's CJS interop touches the\n\t// module namespace's `default` property, and vitest's namespace proxies for\n\t// inlined source modules (including vi.mock replacements) throw on a\n\t// missing `default`, which failed the whole plugin entry import.\n\t\"@agent-forge/tui\": { ...tui },\n\t// D-082 批 3:默认策略插件的运行时依赖供给(ai 兼容层分类器、压缩摘要执行机制)。\n\t\"@agent-forge/ai/compat\": { ...aiCompat },\n\t\"@agent-forge/host/compaction\": { ...hostCompaction },\n\t\"@agent-forge/host/i18n\": { ...hostI18n },\n\t\"@agent-forge/host/theme\": { ...hostTheme },\n\t\"@agent-forge/host/keybinding-hints\": { ...hostKeybindingHints },\n\t\"@agent-forge/host/visual-truncate\": { ...hostVisualTruncate },\n\t\"@agent-forge/host/diff\": { ...hostDiff },\n\t\"@agent-forge/host/render-utils\": { ...hostRenderUtils },\n\t\"@agent-forge/host/tool-definition\": { ...hostToolDefinition },\n\t\"@agent-forge/host/truncate\": { ...hostTruncate },\n\t\"@agent-forge/host/edit-diff\": { ...hostEditDiff },\n\t\"@agent-forge/host/file-mutation-queue\": { ...hostFileMutationQueue },\n\t\"@agent-forge/host/output-accumulator\": { ...hostOutputAccumulator },\n\t\"@agent-forge/host/path-utils\": { ...hostPathUtils },\n\t\"@agent-forge/host/readme-path\": { ...hostReadmePath },\n\t\"@agent-forge/host/paths\": { ...hostPaths },\n\t\"@agent-forge/host/shell\": { ...hostShell },\n\t\"@agent-forge/host/text\": { ...hostText },\n\t\"@agent-forge/host/ansi\": { ...hostAnsi },\n\t\"@agent-forge/host/mime\": { ...hostMime },\n\t\"@agent-forge/host/image-process\": { ...hostImageProcess },\n\t\"@agent-forge/host/child-process\": { ...hostChildProcess },\n\t\"@agent-forge/host/tools-manager\": { ...hostToolsManager },\n\t\"@agent-forge/host/bash-operations\": { ...hostBashOperations },\n};\n"]}
|
|
@@ -3,7 +3,7 @@ import type { PluginInstallationScopeV1, PluginInstallationV1, PluginInstallHost
|
|
|
3
3
|
import type { PluginUpdateRecordV1 } from "./types.ts";
|
|
4
4
|
declare const NODE_PACKAGE_INSTALL_HOST_VERSION_V1: 1;
|
|
5
5
|
export declare const NODE_PACKAGE_FORMAT_VERSION_V1: 1;
|
|
6
|
-
export type NodePackageInstallErrorCodeV1 = "cancelled" | "host_closed" | "invalid_artifact" | "unsupported_media_type" | "archive_invalid" | "archive_budget_exceeded" | "package_manifest_missing" | "package_manifest_invalid" | "package_manifest_mismatch" | "installation_unknown" | "installation_identity_mismatch" | "installation_io_failed";
|
|
6
|
+
export type NodePackageInstallErrorCodeV1 = "cancelled" | "host_closed" | "invalid_artifact" | "unsupported_media_type" | "archive_invalid" | "archive_budget_exceeded" | "package_manifest_missing" | "package_manifest_invalid" | "package_manifest_mismatch" | "dependency_install_failed" | "installation_unknown" | "installation_identity_mismatch" | "installation_io_failed";
|
|
7
7
|
export declare class NodePackageInstallErrorV1 extends Error {
|
|
8
8
|
readonly code: NodePackageInstallErrorCodeV1;
|
|
9
9
|
constructor(code: NodePackageInstallErrorCodeV1);
|
|
@@ -44,6 +44,14 @@ export interface NodePackageInstallHostOptionsV1 extends NodeZipPackageLimitsV1
|
|
|
44
44
|
}) => Promise<{
|
|
45
45
|
readonly dispose?: () => void | Promise<void>;
|
|
46
46
|
} | void>;
|
|
47
|
+
/**
|
|
48
|
+
* Omitted keeps the production behavior: declared non-host-supplied
|
|
49
|
+
* runtime dependencies are materialized into the staging copy before the
|
|
50
|
+
* atomic rename. Deterministic offline fixture chains
|
|
51
|
+
* (test/*-package-fixtures) pass "skip" so installing real first-party
|
|
52
|
+
* packages through the acquisition chain stays registry-free.
|
|
53
|
+
*/
|
|
54
|
+
readonly dependencyMaterialization?: "skip";
|
|
47
55
|
}
|
|
48
56
|
/** Minimal structural bridge for an AgentSession-owned capability loader. */
|
|
49
57
|
export interface NodePackageInstallCapabilityPluginSessionV1 {
|