@ai-agent-forge/agent-forge 0.88.5 → 0.88.6
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 +28 -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/alignment/agent-forge.json +19 -0
- package/bundled-plugins/alignment/dist/baseline.d.ts +12 -0
- package/bundled-plugins/alignment/dist/baseline.d.ts.map +1 -0
- package/bundled-plugins/alignment/dist/baseline.js +68 -0
- package/bundled-plugins/alignment/dist/baseline.js.map +1 -0
- package/bundled-plugins/alignment/dist/engine.d.ts +102 -0
- package/bundled-plugins/alignment/dist/engine.d.ts.map +1 -0
- package/bundled-plugins/alignment/dist/engine.js +654 -0
- package/bundled-plugins/alignment/dist/engine.js.map +1 -0
- package/bundled-plugins/alignment/dist/entry.d.ts +14 -0
- package/bundled-plugins/alignment/dist/entry.d.ts.map +1 -0
- package/bundled-plugins/alignment/dist/entry.js +23 -0
- package/bundled-plugins/alignment/dist/entry.js.map +1 -0
- package/bundled-plugins/alignment/dist/export.d.ts +15 -0
- package/bundled-plugins/alignment/dist/export.d.ts.map +1 -0
- package/bundled-plugins/alignment/dist/export.js +122 -0
- package/bundled-plugins/alignment/dist/export.js.map +1 -0
- package/bundled-plugins/alignment/dist/http-server.d.ts +33 -0
- package/bundled-plugins/alignment/dist/http-server.d.ts.map +1 -0
- package/bundled-plugins/alignment/dist/http-server.js +119 -0
- package/bundled-plugins/alignment/dist/http-server.js.map +1 -0
- package/bundled-plugins/alignment/dist/index.d.ts +24 -0
- package/bundled-plugins/alignment/dist/index.d.ts.map +1 -0
- package/bundled-plugins/alignment/dist/index.js +719 -0
- package/bundled-plugins/alignment/dist/index.js.map +1 -0
- package/bundled-plugins/alignment/dist/page.d.ts +15 -0
- package/bundled-plugins/alignment/dist/page.d.ts.map +1 -0
- package/bundled-plugins/alignment/dist/page.js +832 -0
- package/bundled-plugins/alignment/dist/page.js.map +1 -0
- package/bundled-plugins/alignment/dist/render.d.ts +40 -0
- package/bundled-plugins/alignment/dist/render.d.ts.map +1 -0
- package/bundled-plugins/alignment/dist/render.js +194 -0
- package/bundled-plugins/alignment/dist/render.js.map +1 -0
- package/bundled-plugins/alignment/dist/types.d.ts +217 -0
- package/bundled-plugins/alignment/dist/types.d.ts.map +1 -0
- package/bundled-plugins/alignment/dist/types.js +30 -0
- package/bundled-plugins/alignment/dist/types.js.map +1 -0
- package/bundled-plugins/alignment/plugin.json +12 -0
- package/bundled-plugins/browser-playwright/MANUAL.md +60 -0
- package/bundled-plugins/browser-playwright/agent-forge.json +25 -0
- package/bundled-plugins/browser-playwright/dist/capability.d.ts +25 -0
- package/bundled-plugins/browser-playwright/dist/capability.d.ts.map +1 -0
- package/bundled-plugins/browser-playwright/dist/capability.js +612 -0
- package/bundled-plugins/browser-playwright/dist/capability.js.map +1 -0
- package/bundled-plugins/browser-playwright/dist/entry.d.ts +13 -0
- package/bundled-plugins/browser-playwright/dist/entry.d.ts.map +1 -0
- package/bundled-plugins/browser-playwright/dist/entry.js +14 -0
- package/bundled-plugins/browser-playwright/dist/entry.js.map +1 -0
- package/bundled-plugins/browser-playwright/dist/index.d.ts +7 -0
- package/bundled-plugins/browser-playwright/dist/index.d.ts.map +1 -0
- package/bundled-plugins/browser-playwright/dist/index.js +5 -0
- package/bundled-plugins/browser-playwright/dist/index.js.map +1 -0
- package/bundled-plugins/browser-playwright/dist/operations.d.ts +69 -0
- package/bundled-plugins/browser-playwright/dist/operations.d.ts.map +1 -0
- package/bundled-plugins/browser-playwright/dist/operations.js +149 -0
- package/bundled-plugins/browser-playwright/dist/operations.js.map +1 -0
- package/bundled-plugins/browser-playwright/dist/playwright-driver.d.ts +275 -0
- package/bundled-plugins/browser-playwright/dist/playwright-driver.d.ts.map +1 -0
- package/bundled-plugins/browser-playwright/dist/playwright-driver.js +953 -0
- package/bundled-plugins/browser-playwright/dist/playwright-driver.js.map +1 -0
- package/bundled-plugins/browser-playwright/dist/setup.d.ts +88 -0
- package/bundled-plugins/browser-playwright/dist/setup.d.ts.map +1 -0
- package/bundled-plugins/browser-playwright/dist/setup.js +252 -0
- package/bundled-plugins/browser-playwright/dist/setup.js.map +1 -0
- package/bundled-plugins/browser-playwright/dist/types.d.ts +270 -0
- package/bundled-plugins/browser-playwright/dist/types.d.ts.map +1 -0
- package/bundled-plugins/browser-playwright/dist/types.js +2 -0
- package/bundled-plugins/browser-playwright/dist/types.js.map +1 -0
- package/bundled-plugins/browser-playwright/plugin.json +20 -0
- package/bundled-plugins/coding-tools/agent-forge.json +1 -1
- package/bundled-plugins/coding-tools/dist/bash.d.ts +2 -7
- package/bundled-plugins/coding-tools/dist/bash.d.ts.map +1 -1
- package/bundled-plugins/coding-tools/dist/bash.js +2 -34
- package/bundled-plugins/coding-tools/dist/bash.js.map +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/mcp-http/dist/mcp-http.d.ts.map +1 -1
- package/bundled-plugins/mcp-http/dist/mcp-http.js +84 -31
- package/bundled-plugins/mcp-http/dist/mcp-http.js.map +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 +60 -58
- package/dist/bundle/chunks/{anthropic-messages-3FJHRAJL.js → anthropic-messages-NL4Y6WPB.js} +1 -1
- package/dist/bundle/chunks/{azure-openai-responses-GCL47IDS.js → azure-openai-responses-CPXC42HO.js} +1 -1
- package/dist/bundle/chunks/bedrock-converse-stream.js +1 -1
- package/dist/bundle/chunks/chunk-5LRQFZFE.js +2 -0
- package/dist/bundle/chunks/{chunk-HTEVUY7F.js → chunk-7HSJPQKN.js} +1 -1
- package/dist/bundle/chunks/{chunk-AC2FIS4G.js → chunk-EDO7Q6XR.js} +1 -1
- package/dist/bundle/chunks/{chunk-755VNWIF.js → chunk-ISLHFRER.js} +6 -6
- package/dist/bundle/chunks/{chunk-HV64ASMT.js → chunk-K3S6GTL7.js} +1 -1
- package/dist/bundle/chunks/{chunk-HEL6TAWE.js → chunk-POLDAUYA.js} +37 -36
- package/dist/bundle/chunks/{chunk-V3ACW7VD.js → chunk-WJSKB3FC.js} +1 -1
- package/dist/bundle/chunks/{chunk-32YDZI4J.js → chunk-ZS5JEI76.js} +1 -1
- package/dist/bundle/chunks/{google-generative-ai-6BMXWA44.js → google-generative-ai-UMZ53EFA.js} +1 -1
- package/dist/bundle/chunks/{google-vertex-6H7NLRTK.js → google-vertex-ZNR5NS6H.js} +1 -1
- package/dist/bundle/chunks/image-resize-worker.js +1 -1
- package/dist/bundle/chunks/{mistral-conversations-IXUHSFSJ.js → mistral-conversations-IT66WUNN.js} +1 -1
- package/dist/bundle/chunks/{openai-codex-responses-YHUAEVCM.js → openai-codex-responses-FOVCVG6I.js} +1 -1
- package/dist/bundle/chunks/{openai-completions-ULQCFC72.js → openai-completions-FLQ7CBOL.js} +1 -1
- package/dist/bundle/chunks/{openai-responses-NLLAJDPS.js → openai-responses-ABGYHS2T.js} +1 -1
- package/dist/bundle/chunks/{pi-messages-EJTI2EJ3.js → pi-messages-6K5W6LUN.js} +1 -1
- package/dist/bundle/chunks/{virtual-modules-TQWEGNNZ.js → virtual-modules-2QGILFV7.js} +1 -1
- package/dist/bundle/cli.js +1 -1
- package/dist/bundle/client.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/client/remote-session.d.ts.map +1 -1
- package/dist/client/remote-session.js +65 -6
- package/dist/client/remote-session.js.map +1 -1
- package/dist/core/agent-session-store.d.ts.map +1 -1
- package/dist/core/agent-session-store.js +20 -3
- package/dist/core/agent-session-store.js.map +1 -1
- package/dist/core/extensions/agent-composition.d.ts.map +1 -1
- package/dist/core/extensions/agent-composition.js +20 -1
- package/dist/core/extensions/agent-composition.js.map +1 -1
- package/dist/core/i18n/locales/zh-cn/core-errors.d.ts.map +1 -1
- package/dist/core/i18n/locales/zh-cn/core-errors.js +1 -0
- package/dist/core/i18n/locales/zh-cn/core-errors.js.map +1 -1
- package/dist/core/i18n/locales/zh-cn/interactive-mode.d.ts.map +1 -1
- package/dist/core/i18n/locales/zh-cn/interactive-mode.js +10 -3
- package/dist/core/i18n/locales/zh-cn/interactive-mode.js.map +1 -1
- package/dist/core/keybindings.d.ts +35 -0
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +34 -0
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +62 -15
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +11 -3
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +2 -2
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/capability-mount.d.ts.map +1 -1
- package/dist/core/tools/capability-mount.js +4 -21
- package/dist/core/tools/capability-mount.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +2 -2
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts +2 -0
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +25 -0
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/changelog-pager.d.ts +53 -0
- package/dist/modes/interactive/components/changelog-pager.d.ts.map +1 -0
- package/dist/modes/interactive/components/changelog-pager.js +239 -0
- package/dist/modes/interactive/components/changelog-pager.js.map +1 -0
- package/dist/modes/interactive/components/tool-execution.d.ts +6 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +12 -0
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tool-run-group.d.ts +41 -11
- package/dist/modes/interactive/components/tool-run-group.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-run-group.js +126 -14
- package/dist/modes/interactive/components/tool-run-group.js.map +1 -1
- package/dist/modes/interactive/interactive-commands.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-commands.js +23 -13
- package/dist/modes/interactive/interactive-commands.js.map +1 -1
- package/dist/modes/interactive/interactive-events.d.ts +14 -4
- package/dist/modes/interactive/interactive-events.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-events.js +94 -12
- package/dist/modes/interactive/interactive-events.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +6 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +21 -5
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/plugins/ecosystem/node-local-package-source.d.ts +2 -1
- package/dist/plugins/ecosystem/node-local-package-source.d.ts.map +1 -1
- package/dist/plugins/ecosystem/node-local-package-source.js +110 -4
- package/dist/plugins/ecosystem/node-local-package-source.js.map +1 -1
- package/dist/plugins/ecosystem/node-package-install-host.d.ts.map +1 -1
- package/dist/plugins/ecosystem/node-package-install-host.js +106 -39
- package/dist/plugins/ecosystem/node-package-install-host.js.map +1 -1
- package/dist/plugins/ecosystem/node-plugin-bootstrap.d.ts.map +1 -1
- package/dist/plugins/ecosystem/node-plugin-bootstrap.js +59 -2
- package/dist/plugins/ecosystem/node-plugin-bootstrap.js.map +1 -1
- package/dist/suites/builtin-suites.d.ts.map +1 -1
- package/dist/suites/builtin-suites.js +2 -2
- package/dist/suites/builtin-suites.js.map +1 -1
- package/dist/utils/changelog.d.ts +27 -0
- package/dist/utils/changelog.d.ts.map +1 -1
- package/dist/utils/changelog.js +110 -0
- package/dist/utils/changelog.js.map +1 -1
- package/docs/keybindings.md +14 -0
- 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
- package/dist/bundle/chunks/chunk-A3JYRWB6.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-package-install-host.js","sourceRoot":"","sources":["../../../src/plugins/ecosystem/node-package-install-host.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,6BAA6B,EAAE,MAAM,4CAA4C,CAAC;AAC3F,OAAO,EAAE,CAAC,EAAE,MAAM,0BAA0B,CAAC;AAG7C,OAAO,EACN,qCAAqC,GAGrC,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAEtD,MAAM,oCAAoC,GAAG,CAAU,CAAC;AACxD,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAU,CAAC;AACzD,MAAM,4BAA4B,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;AACvD,MAAM,oBAAoB,GAAG,GAAG,GAA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V,QAAQ,EAAE,MAAM,CAAC,QAAQ;oBACzB,aAAa,EAAE,MAAM,CAAC,aAAa;oBACnC,cAAc,EAAE,MAAM,CAAC,cAAc;oBACrC,KAAK,EAAE,MAAM,CAAC,KAAK;oBACnB,QAAQ,EAAE,MAAM,CAAC,QAAQ;oBACzB,eAAe,EAAE,MAAM,CAAC,eAAe;oBACvC,KAAK,EAAE,QAAQ;iBACf,CAAC;gBACF,MAAM,OAAO,GAAG,MAAM,WAAW,CAAC,YAAY,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,IAAI,eAAe,EAAE,CAAC,MAAM,CAAC,CAAC;gBAC3G,IAAI,OAAO,KAAK,SAAS;oBAAE,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;YAChF,CAAC;QACF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;YAC1C,IAAI,KAAK,YAAY,yBAAyB;gBAAE,MAAM,KAAK,CAAC;YAC5D,MAAM,IAAI,yBAAyB,CAAC,wBAAwB,CAAC,CAAC;QAC/D,CAAC;IACF,CAAC;IACD,OAAO,IAAI,CAAC;AAAA,CACZ","sourcesContent":["import { spawn } from \"node:child_process\";\nimport { createHash, randomUUID } from \"node:crypto\";\nimport { mkdir, mkdtemp, rename, rm, writeFile } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { isAbsolute, join } from \"node:path\";\nimport { inflateRawSync } from \"node:zlib\";\nimport { parseCapabilityPluginManifest } from \"../../core/extensions/capability-plugin.ts\";\nimport { t } from \"../../core/i18n/index.ts\";\nimport type { PluginDistributionArtifactV1 } from \"./distribution.ts\";\nimport type { PluginInstallationScopeV1, PluginInstallationV1, PluginInstallHostV1 } from \"./installer.ts\";\nimport {\n\tcreateNodePackageInstallPersistenceV1,\n\ttype NodePackageInstallPersistenceV1,\n\ttype NodePackageInstallPersistentRecordV1,\n} from \"./node-package-install-persistence.ts\";\nimport { parseNodeTarGzPackageV1 } from \"./node-tar-package.ts\";\nimport type { PluginManifestV1, PluginUpdateRecordV1 } from \"./types.ts\";\nimport { pluginManifestDigestV1 } from \"./updates.ts\";\n\nconst NODE_PACKAGE_INSTALL_HOST_VERSION_V1 = 1 as const;\nexport const NODE_PACKAGE_FORMAT_VERSION_V1 = 1 as const;\nconst DEFAULT_MAX_ARCHIVE_BYTES_V1 = 128 * 1024 * 1024;\nconst MAX_ARCHIVE_BYTES_V1 = 512 * 1024 * 1024;\nconst DEFAULT_MAX_EXTRACTED_BYTES_V1 = 256 * 1024 * 1024;\nconst MAX_EXTRACTED_BYTES_V1 = 1024 * 1024 * 1024;\nconst DEFAULT_MAX_ENTRY_BYTES_V1 = 64 * 1024 * 1024;\nconst MAX_ENTRY_BYTES_V1 = 256 * 1024 * 1024;\nconst DEFAULT_MAX_ENTRIES_V1 = 2048;\nconst MAX_ENTRIES_V1 = 8192;\nconst MAX_PACKAGE_MANIFEST_BYTES_V1 = 64 * 1024;\nconst ECOSYSTEM_MANIFEST_FILE_V1 = \"agent-forge.json\";\nconst CAPABILITY_MANIFEST_FILE_V1 = \"plugin.json\";\n/**\n * Host-supplied runtime dependency specifiers: at plugin load time these\n * resolve to the host's own copies through jiti virtual modules (supply\n * contract in core/extensions/virtual-modules.ts, mirrored by\n * HOST_SUPPLIED_PLUGIN_SPECIFIERS in scripts/check-plugin-boundary.mjs), so\n * they are never materialized into a store copy. Both the workspace scope\n * (source/checkout packages) and the published-name scope of the same\n * packages (scripts/release-packages.mjs name map) are covered; a future\n * plugin-to-plugin runtime dependency must therefore not use these scopes.\n */\nconst HOST_SUPPLIED_DEPENDENCY_PREFIXES_V1: readonly string[] = [\"@agent-forge/\", \"@ai-agent-forge/\"];\nconst HOST_SUPPLIED_DEPENDENCIES_V1: ReadonlySet<string> = new Set([\"typebox\"]);\n\nconst LOCAL_FILE_HEADER_V1 = 0x04034b50;\nconst CENTRAL_FILE_HEADER_V1 = 0x02014b50;\nconst END_OF_CENTRAL_DIRECTORY_V1 = 0x06054b50;\nconst ZIP64_END_OF_CENTRAL_DIRECTORY_V1 = 0x06064b50;\nconst ZIP64_END_OF_CENTRAL_DIRECTORY_LOCATOR_V1 = 0x07064b50;\n\nexport type NodePackageInstallErrorCodeV1 =\n\t| \"cancelled\"\n\t| \"host_closed\"\n\t| \"invalid_artifact\"\n\t| \"unsupported_media_type\"\n\t| \"archive_invalid\"\n\t| \"archive_budget_exceeded\"\n\t| \"package_manifest_missing\"\n\t| \"package_manifest_invalid\"\n\t| \"package_manifest_mismatch\"\n\t| \"dependency_install_failed\"\n\t| \"installation_unknown\"\n\t| \"installation_identity_mismatch\"\n\t| \"installation_io_failed\";\n\nexport class NodePackageInstallErrorV1 extends Error {\n\treadonly code: NodePackageInstallErrorCodeV1;\n\n\tconstructor(code: NodePackageInstallErrorCodeV1) {\n\t\tsuper(t(\"Node package installation failed: {code}\", { code }));\n\t\tthis.name = \"NodePackageInstallErrorV1\";\n\t\tthis.code = code;\n\t}\n}\n\nexport interface NodeZipPackageEntryV1 {\n\treadonly name: string;\n\treadonly directory: boolean;\n\treadonly bytes: Uint8Array;\n}\n\nexport interface NodeZipPackageLimitsV1 {\n\treadonly maxArchiveBytes?: number;\n\treadonly maxExtractedBytes?: number;\n\treadonly maxEntryBytes?: number;\n\treadonly maxEntries?: number;\n}\n\nexport interface NodePackageInstallHostOptionsV1 extends NodeZipPackageLimitsV1 {\n\t/** An opaque artifact reader owned by the distribution host. */\n\treadonly openArtifact: (input: {\n\t\treadonly artifact: PluginDistributionArtifactV1;\n\t\treadonly signal?: AbortSignal;\n\t}) => AsyncIterable<Uint8Array>;\n\t/** Parent directory owned by the host; no local path leaves this adapter. */\n\treadonly installationDirectory?: string;\n\treadonly supportedScopes?: readonly PluginInstallationScopeV1[];\n\t/** Persistent host-owned index; omitted keeps the test-friendly ephemeral mode. */\n\treadonly persistence?: \"ephemeral\" | \"persistent\";\n\treadonly persistenceLockTimeoutMs?: number;\n\t/**\n\t * Host-only runtime assembly seam. The directory and manifest path never\n\t * cross the public installer DTO or model/tool context.\n\t */\n\treadonly loadPlugin?: (input: {\n\t\treadonly installation: PluginInstallationV1;\n\t\treadonly record?: PluginUpdateRecordV1;\n\t\treadonly directory: string;\n\t\treadonly manifestPath: string;\n\t\treadonly signal: AbortSignal;\n\t}) => Promise<{ readonly dispose?: () => void | Promise<void> } | void>;\n\t/**\n\t * Omitted keeps the production behavior: declared non-host-supplied\n\t * runtime dependencies are materialized into the staging copy before the\n\t * atomic rename. Deterministic offline fixture chains\n\t * (test/*-package-fixtures) pass \"skip\" so installing real first-party\n\t * packages through the acquisition chain stays registry-free.\n\t */\n\treadonly dependencyMaterialization?: \"skip\";\n}\n\n/** Minimal structural bridge for an AgentSession-owned capability loader. */\nexport interface NodePackageInstallCapabilityPluginSessionV1 {\n\treadonly loadCapabilityPluginManifest: (manifestPath: string) => Promise<{\n\t\treadonly dispose: () => void | Promise<void>;\n\t}>;\n}\n\n/**\n * Adapt an AgentSession-like loader to the host-only runtime seam. The\n * manifest path is never returned as a DTO or sent through model context.\n */\nexport function createNodePackageInstallSessionLoaderV1(\n\tsession: NodePackageInstallCapabilityPluginSessionV1,\n): NonNullable<NodePackageInstallHostOptionsV1[\"loadPlugin\"]> {\n\treturn async ({ manifestPath }) => {\n\t\tconst handle = await session.loadCapabilityPluginManifest(manifestPath);\n\t\treturn { dispose: handle.dispose };\n\t};\n}\n\n/**\n * Create a package host with an explicit AgentSession-compatible runtime\n * loader. This is an opt-in composition helper; it does not alter Core's\n * default session construction or install untrusted package code.\n */\nexport async function createNodePackageInstallHostForSessionV1(\n\toptions: NodePackageInstallHostOptionsV1,\n\tsession: NodePackageInstallCapabilityPluginSessionV1,\n): Promise<NodePackageInstallHostV1> {\n\tif (options.loadPlugin !== undefined) throw new Error(t(\"loadPlugin must be omitted when binding a session\"));\n\treturn await createNodePackageInstallHostV1({\n\t\t...options,\n\t\tloadPlugin: createNodePackageInstallSessionLoaderV1(session),\n\t});\n}\n\nexport interface NodePackageInstallHostV1 extends PluginInstallHostV1 {\n\treadonly version: typeof NODE_PACKAGE_INSTALL_HOST_VERSION_V1;\n\treadonly uninstall: NonNullable<PluginInstallHostV1[\"uninstall\"]>;\n\t/** Host-only bridge for local runtime assembly; never put this path in a DTO or transcript. */\n\treadonly getInstallationDirectory: (input: { readonly installation: PluginInstallationV1 }) => string;\n\treadonly close: () => Promise<void>;\n}\n\ninterface ZipEntryDescriptorV1 {\n\treadonly name: string;\n\treadonly directory: boolean;\n\treadonly flags: number;\n\treadonly method: number;\n\treadonly compressedSize: number;\n\treadonly uncompressedSize: number;\n\treadonly crc32: number;\n\treadonly localOffset: number;\n}\n\ninterface ZipLocalSpanV1 {\n\treadonly start: number;\n\treadonly end: number;\n}\n\ninterface InstalledRecordV1 {\n\treadonly installationRef: string;\n\treadonly directory: string;\n\treadonly pluginId: string;\n\treadonly pluginVersion: string;\n\treadonly manifestDigest: string;\n\treadonly scope: PluginInstallationScopeV1;\n\treadonly scopeRef: string;\n\tstate: \"installed\" | \"active\" | \"retained\";\n}\n\nfunction positiveLimit(value: number | undefined, fallback: number, maximum: number, label: string): number {\n\tconst result = value ?? fallback;\n\tif (!Number.isSafeInteger(result) || result < 1 || result > maximum)\n\t\tthrow new Error(t(\"{label} must be a positive integer at most {maximum}\", { label, maximum }));\n\treturn result;\n}\n\n/** Resolve the archive budget limits shared by the ZIP and tgz package parsers. */\nexport function resolveNodePackageLimitsV1(limitsInput: NodeZipPackageLimitsV1): Required<NodeZipPackageLimitsV1> {\n\treturn {\n\t\tmaxArchiveBytes: positiveLimit(\n\t\t\tlimitsInput.maxArchiveBytes,\n\t\t\tDEFAULT_MAX_ARCHIVE_BYTES_V1,\n\t\t\tMAX_ARCHIVE_BYTES_V1,\n\t\t\t\"maxArchiveBytes\",\n\t\t),\n\t\tmaxExtractedBytes: positiveLimit(\n\t\t\tlimitsInput.maxExtractedBytes,\n\t\t\tDEFAULT_MAX_EXTRACTED_BYTES_V1,\n\t\t\tMAX_EXTRACTED_BYTES_V1,\n\t\t\t\"maxExtractedBytes\",\n\t\t),\n\t\tmaxEntryBytes: positiveLimit(\n\t\t\tlimitsInput.maxEntryBytes,\n\t\t\tDEFAULT_MAX_ENTRY_BYTES_V1,\n\t\t\tMAX_ENTRY_BYTES_V1,\n\t\t\t\"maxEntryBytes\",\n\t\t),\n\t\tmaxEntries: positiveLimit(limitsInput.maxEntries, DEFAULT_MAX_ENTRIES_V1, MAX_ENTRIES_V1, \"maxEntries\"),\n\t};\n}\n\nfunction readU16(bytes: Uint8Array, offset: number): number {\n\tif (offset < 0 || offset + 2 > bytes.byteLength) throw new NodePackageInstallErrorV1(\"archive_invalid\");\n\treturn bytes[offset]! | (bytes[offset + 1]! << 8);\n}\n\nfunction readU32(bytes: Uint8Array, offset: number): number {\n\tif (offset < 0 || offset + 4 > bytes.byteLength) throw new NodePackageInstallErrorV1(\"archive_invalid\");\n\treturn (bytes[offset]! | (bytes[offset + 1]! << 8) | (bytes[offset + 2]! << 16) | (bytes[offset + 3]! << 24)) >>> 0;\n}\n\nfunction decodeName(bytes: Uint8Array, utf8: boolean): string {\n\ttry {\n\t\tconst value = new TextDecoder(\"utf-8\", { fatal: true }).decode(bytes);\n\t\tif (!utf8 && /[^\\x00-\\x7f]/u.test(value)) throw new Error(t(\"non-ascii zip name\"));\n\t\treturn value;\n\t} catch {\n\t\tthrow new NodePackageInstallErrorV1(\"archive_invalid\");\n\t}\n}\n\n/** Normalized archive entry name shared by the ZIP and tgz package parsers. */\nexport function normalizedEntryName(value: string): { readonly name: string; readonly directory: boolean } {\n\tif (value.length === 0 || value.includes(\"\\\\\") || /[\\u0000-\\u001f\\u007f]/u.test(value))\n\t\tthrow new NodePackageInstallErrorV1(\"archive_invalid\");\n\tconst directory = value.endsWith(\"/\");\n\tif (value.startsWith(\"/\") || /^[a-z]:/iu.test(value)) throw new NodePackageInstallErrorV1(\"archive_invalid\");\n\tconst parts = value.split(\"/\");\n\tif (directory) parts.pop();\n\tif (\n\t\tparts.length === 0 ||\n\t\tparts.some(\n\t\t\t(part) =>\n\t\t\t\tpart === \"\" ||\n\t\t\t\tpart === \".\" ||\n\t\t\t\tpart === \"..\" ||\n\t\t\t\tpart.includes(\":\") ||\n\t\t\t\t/[ .]$/u.test(part) ||\n\t\t\t\t/^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\\..*)?$/iu.test(part),\n\t\t)\n\t)\n\t\tthrow new NodePackageInstallErrorV1(\"archive_invalid\");\n\treturn { name: parts.join(\"/\"), directory };\n}\n\nfunction crcTable(): Uint32Array {\n\tconst table = new Uint32Array(256);\n\tfor (let index = 0; index < table.length; index += 1) {\n\t\tlet value = index;\n\t\tfor (let bit = 0; bit < 8; bit += 1) value = (value & 1) === 0 ? value >>> 1 : (value >>> 1) ^ 0xedb88320;\n\t\ttable[index] = value >>> 0;\n\t}\n\treturn table;\n}\n\nconst CRC_TABLE_V1 = crcTable();\n\nfunction crc32(bytes: Uint8Array): number {\n\tlet value = 0xffffffff;\n\tfor (const byte of bytes) value = (value >>> 8) ^ CRC_TABLE_V1[(value ^ byte) & 0xff]!;\n\treturn (value ^ 0xffffffff) >>> 0;\n}\n\nfunction findEndOfCentralDirectory(bytes: Uint8Array): {\n\treadonly offset: number;\n\treadonly entries: number;\n\treadonly size: number;\n\treadonly start: number;\n} {\n\tconst minimum = Math.max(0, bytes.byteLength - 0xffff - 22);\n\tfor (let offset = bytes.byteLength - 22; offset >= minimum; offset -= 1) {\n\t\tif (readU32(bytes, offset) !== END_OF_CENTRAL_DIRECTORY_V1) continue;\n\t\tconst disk = readU16(bytes, offset + 4);\n\t\tconst centralDisk = readU16(bytes, offset + 6);\n\t\tconst entries = readU16(bytes, offset + 10);\n\t\tconst centralEntries = readU16(bytes, offset + 8);\n\t\tconst size = readU32(bytes, offset + 12);\n\t\tconst start = readU32(bytes, offset + 16);\n\t\tconst commentLength = readU16(bytes, offset + 20);\n\t\tif (\n\t\t\tdisk !== 0 ||\n\t\t\tcentralDisk !== 0 ||\n\t\t\tentries !== centralEntries ||\n\t\t\toffset + 22 + commentLength !== bytes.byteLength\n\t\t)\n\t\t\tthrow new NodePackageInstallErrorV1(\"archive_invalid\");\n\t\tif (entries === 0xffff || size === 0xffffffff || start === 0xffffffff)\n\t\t\tthrow new NodePackageInstallErrorV1(\"archive_invalid\");\n\t\tif (start + size > offset) throw new NodePackageInstallErrorV1(\"archive_invalid\");\n\t\treturn { offset, entries, size, start };\n\t}\n\tfor (let offset = Math.max(0, bytes.byteLength - 64); offset < bytes.byteLength - 3; offset += 1) {\n\t\tconst signature = readU32(bytes, offset);\n\t\tif (signature === ZIP64_END_OF_CENTRAL_DIRECTORY_V1 || signature === ZIP64_END_OF_CENTRAL_DIRECTORY_LOCATOR_V1)\n\t\t\tthrow new NodePackageInstallErrorV1(\"archive_invalid\");\n\t}\n\tthrow new NodePackageInstallErrorV1(\"archive_invalid\");\n}\n\nfunction parseCentralDirectory(\n\tbytes: Uint8Array,\n\tlimits: Required<NodeZipPackageLimitsV1>,\n): readonly ZipEntryDescriptorV1[] {\n\tconst end = findEndOfCentralDirectory(bytes);\n\tif (end.entries > limits.maxEntries || end.size > bytes.byteLength || end.start + end.size > end.offset)\n\t\tthrow new NodePackageInstallErrorV1(\"archive_budget_exceeded\");\n\tconst entries: ZipEntryDescriptorV1[] = [];\n\tconst names = new Set<string>();\n\tlet offset = end.start;\n\tfor (let index = 0; index < end.entries; index += 1) {\n\t\tif (readU32(bytes, offset) !== CENTRAL_FILE_HEADER_V1) throw new NodePackageInstallErrorV1(\"archive_invalid\");\n\t\tconst madeBy = readU16(bytes, offset + 4) >>> 8;\n\t\tconst flags = readU16(bytes, offset + 8);\n\t\tconst method = readU16(bytes, offset + 10);\n\t\tconst crc = readU32(bytes, offset + 16);\n\t\tconst compressedSize = readU32(bytes, offset + 20);\n\t\tconst uncompressedSize = readU32(bytes, offset + 24);\n\t\tconst nameLength = readU16(bytes, offset + 28);\n\t\tconst extraLength = readU16(bytes, offset + 30);\n\t\tconst commentLength = readU16(bytes, offset + 32);\n\t\tconst disk = readU16(bytes, offset + 34);\n\t\tconst externalAttributes = readU32(bytes, offset + 38);\n\t\tconst localOffset = readU32(bytes, offset + 42);\n\t\tconst nameStart = offset + 46;\n\t\tconst recordEnd = nameStart + nameLength + extraLength + commentLength;\n\t\tif (\n\t\t\trecordEnd > end.start + end.size ||\n\t\t\tdisk !== 0 ||\n\t\t\t(flags & ~(0x8 | 0x800)) !== 0 ||\n\t\t\t(flags & 1) !== 0 ||\n\t\t\t(flags & 0x40) !== 0\n\t\t)\n\t\t\tthrow new NodePackageInstallErrorV1(\"archive_invalid\");\n\t\tif (method !== 0 && method !== 8) throw new NodePackageInstallErrorV1(\"archive_invalid\");\n\t\tif (uncompressedSize > limits.maxEntryBytes || compressedSize > limits.maxArchiveBytes)\n\t\t\tthrow new NodePackageInstallErrorV1(\"archive_budget_exceeded\");\n\t\tconst name = normalizedEntryName(\n\t\t\tdecodeName(bytes.subarray(nameStart, nameStart + nameLength), (flags & 0x800) !== 0),\n\t\t);\n\t\tif (names.has(name.name)) throw new NodePackageInstallErrorV1(\"archive_invalid\");\n\t\tnames.add(name.name);\n\t\tconst unixMode = madeBy === 3 ? (externalAttributes >>> 16) & 0xffff : 0;\n\t\tif ((unixMode & 0xf000) === 0xa000) throw new NodePackageInstallErrorV1(\"archive_invalid\");\n\t\tentries.push({\n\t\t\tname: name.name,\n\t\t\tdirectory: name.directory,\n\t\t\tflags,\n\t\t\tmethod,\n\t\t\tcompressedSize,\n\t\t\tuncompressedSize,\n\t\t\tcrc32: crc,\n\t\t\tlocalOffset,\n\t\t});\n\t\toffset = recordEnd;\n\t}\n\tif (offset !== end.start + end.size) throw new NodePackageInstallErrorV1(\"archive_invalid\");\n\t// Validate the local-file regions before extraction. A forged central\n\t// directory must not be able to point into another entry or into the\n\t// central directory/EOCD; otherwise extraction could reinterpret metadata\n\t// bytes as package contents.\n\tconst spans: ZipLocalSpanV1[] = [];\n\tfor (const entry of entries) {\n\t\tif (entry.localOffset < 0 || entry.localOffset + 30 > end.start)\n\t\t\tthrow new NodePackageInstallErrorV1(\"archive_invalid\");\n\t\tif (readU32(bytes, entry.localOffset) !== LOCAL_FILE_HEADER_V1)\n\t\t\tthrow new NodePackageInstallErrorV1(\"archive_invalid\");\n\t\tconst localNameLength = readU16(bytes, entry.localOffset + 26);\n\t\tconst localExtraLength = readU16(bytes, entry.localOffset + 28);\n\t\tconst dataStart = entry.localOffset + 30 + localNameLength + localExtraLength;\n\t\tconst dataEnd = dataStart + entry.compressedSize;\n\t\tif (dataStart < entry.localOffset + 30 || dataEnd < dataStart || dataEnd > end.start)\n\t\t\tthrow new NodePackageInstallErrorV1(\"archive_invalid\");\n\t\tspans.push({ start: entry.localOffset, end: dataEnd });\n\t}\n\tspans.sort((left, right) => left.start - right.start || left.end - right.end);\n\tfor (let index = 1; index < spans.length; index += 1) {\n\t\tif (spans[index - 1]!.end > spans[index]!.start) throw new NodePackageInstallErrorV1(\"archive_invalid\");\n\t}\n\treturn entries;\n}\n\nfunction extractEntry(bytes: Uint8Array, entry: ZipEntryDescriptorV1, maxEntryBytes: number): Uint8Array {\n\tif (entry.directory) {\n\t\tif (entry.compressedSize !== 0 || entry.uncompressedSize !== 0)\n\t\t\tthrow new NodePackageInstallErrorV1(\"archive_invalid\");\n\t\treturn new Uint8Array();\n\t}\n\tif (entry.localOffset + 30 > bytes.byteLength) throw new NodePackageInstallErrorV1(\"archive_invalid\");\n\tif (readU32(bytes, entry.localOffset) !== LOCAL_FILE_HEADER_V1)\n\t\tthrow new NodePackageInstallErrorV1(\"archive_invalid\");\n\tconst localFlags = readU16(bytes, entry.localOffset + 6);\n\tconst localMethod = readU16(bytes, entry.localOffset + 8);\n\tconst nameLength = readU16(bytes, entry.localOffset + 26);\n\tconst extraLength = readU16(bytes, entry.localOffset + 28);\n\tconst localName = decodeName(\n\t\tbytes.subarray(entry.localOffset + 30, entry.localOffset + 30 + nameLength),\n\t\t(entry.flags & 0x800) !== 0,\n\t);\n\tif (normalizedEntryName(localName).name !== entry.name || localFlags !== entry.flags || localMethod !== entry.method)\n\t\tthrow new NodePackageInstallErrorV1(\"archive_invalid\");\n\tconst localCompressedSize = readU32(bytes, entry.localOffset + 18);\n\tconst localUncompressedSize = readU32(bytes, entry.localOffset + 22);\n\tif (\n\t\t(entry.flags & 8) === 0 &&\n\t\t(localCompressedSize !== entry.compressedSize || localUncompressedSize !== entry.uncompressedSize)\n\t)\n\t\tthrow new NodePackageInstallErrorV1(\"archive_invalid\");\n\tconst dataStart = entry.localOffset + 30 + nameLength + extraLength;\n\tconst dataEnd = dataStart + entry.compressedSize;\n\tif (dataStart > bytes.byteLength || dataEnd > bytes.byteLength)\n\t\tthrow new NodePackageInstallErrorV1(\"archive_invalid\");\n\tconst compressed = bytes.subarray(dataStart, dataEnd);\n\tlet output: Uint8Array;\n\ttry {\n\t\toutput =\n\t\t\tentry.method === 0\n\t\t\t\t? new Uint8Array(compressed)\n\t\t\t\t: inflateRawSync(compressed, { maxOutputLength: maxEntryBytes });\n\t} catch {\n\t\tthrow new NodePackageInstallErrorV1(\"archive_invalid\");\n\t}\n\tif (\n\t\toutput.byteLength !== entry.uncompressedSize ||\n\t\toutput.byteLength > maxEntryBytes ||\n\t\tcrc32(output) !== entry.crc32\n\t)\n\t\tthrow new NodePackageInstallErrorV1(\"archive_invalid\");\n\treturn output;\n}\n\nexport function parseNodeZipPackageV1(\n\tinput: Uint8Array,\n\tlimitsInput: NodeZipPackageLimitsV1 = {},\n): readonly NodeZipPackageEntryV1[] {\n\tif (!(input instanceof Uint8Array)) throw new NodePackageInstallErrorV1(\"archive_invalid\");\n\tconst limits = resolveNodePackageLimitsV1(limitsInput);\n\tif (input.byteLength > limits.maxArchiveBytes) throw new NodePackageInstallErrorV1(\"archive_budget_exceeded\");\n\tconst descriptors = parseCentralDirectory(input, limits);\n\tlet extractedBytes = 0;\n\treturn Object.freeze(\n\t\tdescriptors.map((descriptor) => {\n\t\t\tconst bytes = extractEntry(input, descriptor, limits.maxEntryBytes);\n\t\t\textractedBytes += bytes.byteLength;\n\t\t\tif (extractedBytes > limits.maxExtractedBytes) throw new NodePackageInstallErrorV1(\"archive_budget_exceeded\");\n\t\t\treturn Object.freeze({ name: descriptor.name, directory: descriptor.directory, bytes });\n\t\t}),\n\t);\n}\n\nfunction manifestKeys(value: Record<string, unknown>): boolean {\n\tconst allowed = new Set([\n\t\t\"packageFormatVersion\",\n\t\t\"id\",\n\t\t\"pluginVersion\",\n\t\t\"apiVersion\",\n\t\t\"minHostVersion\",\n\t\t\"maxHostVersion\",\n\t\t\"capabilityRefs\",\n\t\t\"requires\",\n\t\t\"platform\",\n\t\t\"testOnly\",\n\t]);\n\treturn Object.keys(value).every((key) => allowed.has(key));\n}\n\nfunction packageManifest(value: unknown, record: PluginUpdateRecordV1): void {\n\tif (value === null || typeof value !== \"object\" || Array.isArray(value))\n\t\tthrow new NodePackageInstallErrorV1(\"package_manifest_invalid\");\n\tconst manifest = value as Record<string, unknown>;\n\tif (\n\t\t!manifestKeys(manifest) ||\n\t\tmanifest.packageFormatVersion !== NODE_PACKAGE_FORMAT_VERSION_V1 ||\n\t\tmanifest.id !== record.pluginId ||\n\t\tmanifest.pluginVersion !== record.pluginVersion\n\t)\n\t\tthrow new NodePackageInstallErrorV1(\"package_manifest_mismatch\");\n\tif (typeof manifest.apiVersion !== \"string\" || manifest.apiVersion !== record.manifest.apiVersion)\n\t\tthrow new NodePackageInstallErrorV1(\"package_manifest_mismatch\");\n\ttry {\n\t\tif (pluginManifestDigestV1(manifest as unknown as PluginManifestV1) !== record.manifestDigest)\n\t\t\tthrow new NodePackageInstallErrorV1(\"package_manifest_mismatch\");\n\t} catch (error) {\n\t\tif (error instanceof NodePackageInstallErrorV1) throw error;\n\t\tthrow new NodePackageInstallErrorV1(\"package_manifest_invalid\");\n\t}\n}\n\nfunction capabilityManifest(\n\tvalue: unknown,\n\trecord: PluginUpdateRecordV1,\n\tentries: readonly NodeZipPackageEntryV1[],\n): void {\n\tlet manifest: ReturnType<typeof parseCapabilityPluginManifest>;\n\ttry {\n\t\tmanifest = parseCapabilityPluginManifest(value, \"<installed plugin.json>\");\n\t} catch {\n\t\tthrow new NodePackageInstallErrorV1(\"package_manifest_invalid\");\n\t}\n\tif (manifest.id !== record.pluginId || manifest.version !== record.pluginVersion)\n\t\tthrow new NodePackageInstallErrorV1(\"package_manifest_mismatch\");\n\tconst entryValue = manifest.entry.startsWith(\"./\") ? manifest.entry.slice(2) : manifest.entry;\n\tconst entry = normalizedEntryName(entryValue);\n\tif (entry.directory || !entries.some((candidate) => candidate.name === entry.name && !candidate.directory))\n\t\tthrow new NodePackageInstallErrorV1(\"package_manifest_mismatch\");\n}\n\nfunction opaqueScope(value: string): string {\n\tif (\n\t\ttypeof value !== \"string\" ||\n\t\tvalue.trim() === \"\" ||\n\t\tvalue.length > 2048 ||\n\t\t/\\s|[\\u0000-\\u001f\\u007f]/u.test(value)\n\t)\n\t\tthrow new NodePackageInstallErrorV1(\"installation_identity_mismatch\");\n\treturn value;\n}\n\nfunction installationKey(scope: PluginInstallationScopeV1, scopeRef: string, pluginId: string): string {\n\treturn `${scope}\\u0000${scopeRef}\\u0000${pluginId}`;\n}\n\nfunction identityMatches(\n\trecord: InstalledRecordV1,\n\tinput: {\n\t\treadonly pluginId: string;\n\t\treadonly pluginVersion: string;\n\t\treadonly manifestDigest: string;\n\t\treadonly scope: PluginInstallationScopeV1;\n\t\treadonly scopeRef: string;\n\t},\n): boolean {\n\treturn (\n\t\trecord.pluginId === input.pluginId &&\n\t\trecord.pluginVersion === input.pluginVersion &&\n\t\trecord.manifestDigest === input.manifestDigest &&\n\t\trecord.scope === input.scope &&\n\t\trecord.scopeRef === input.scopeRef\n\t);\n}\n\nfunction artifactIdentityMatchesRecord(artifact: PluginDistributionArtifactV1, record: PluginUpdateRecordV1): boolean {\n\treturn (\n\t\tartifact.version === 1 &&\n\t\tartifact.pluginId === record.pluginId &&\n\t\tartifact.pluginVersion === record.pluginVersion &&\n\t\tartifact.manifestDigest === record.manifestDigest\n\t);\n}\n\nfunction expectedArtifactDigest(value: string): { readonly algorithm: \"sha256\" | \"sha512\"; readonly hex: string } {\n\tconst prefixed = /^(sha256|sha512):([0-9a-f]+)$/iu.exec(value);\n\tif (prefixed !== null) {\n\t\tconst algorithm = prefixed[1]!.toLowerCase() as \"sha256\" | \"sha512\";\n\t\tconst hex = prefixed[2]!.toLowerCase();\n\t\tif ((algorithm === \"sha256\" && hex.length === 64) || (algorithm === \"sha512\" && hex.length === 128))\n\t\t\treturn { algorithm, hex };\n\t}\n\tif (/^[0-9a-f]{64}$/iu.test(value)) return { algorithm: \"sha256\", hex: value.toLowerCase() };\n\tif (/^[0-9a-f]{128}$/iu.test(value)) return { algorithm: \"sha512\", hex: value.toLowerCase() };\n\tthrow new NodePackageInstallErrorV1(\"invalid_artifact\");\n}\n\nasync function collectArtifact(\n\topenArtifact: NodePackageInstallHostOptionsV1[\"openArtifact\"],\n\tartifact: PluginDistributionArtifactV1,\n\tmaxBytes: number,\n\tsignal: AbortSignal,\n): Promise<Uint8Array> {\n\tconst chunks: Uint8Array[] = [];\n\tlet total = 0;\n\tfor await (const chunk of openArtifact({ artifact, signal })) {\n\t\tif (signal.aborted) throw new NodePackageInstallErrorV1(\"cancelled\");\n\t\tif (!(chunk instanceof Uint8Array)) throw new NodePackageInstallErrorV1(\"invalid_artifact\");\n\t\tif (chunk.byteLength > maxBytes - total) throw new NodePackageInstallErrorV1(\"archive_budget_exceeded\");\n\t\tchunks.push(new Uint8Array(chunk));\n\t\ttotal += chunk.byteLength;\n\t}\n\tconst result = new Uint8Array(total);\n\tlet offset = 0;\n\tfor (const chunk of chunks) {\n\t\tresult.set(chunk, offset);\n\t\toffset += chunk.byteLength;\n\t}\n\treturn result;\n}\n\nfunction packagePath(root: string, key: string): string {\n\treturn join(root, createHash(\"sha256\").update(key).digest(\"hex\"));\n}\n\nfunction isHostSuppliedDependencyV1(name: string): boolean {\n\treturn (\n\t\tHOST_SUPPLIED_DEPENDENCIES_V1.has(name) ||\n\t\tHOST_SUPPLIED_DEPENDENCY_PREFIXES_V1.some((prefix) => name.startsWith(prefix))\n\t);\n}\n\n/**\n * Install declared runtime dependencies inside the staging directory before\n * the atomic rename (2026-10-07 user ruling): npm tarballs never carry\n * node_modules, so a store copy of a plugin with runtime dependencies\n * (e.g. memory's onnxruntime-node) would otherwise have no dependency tree\n * at load time. A failed dependency install fails the whole installation\n * while staging is still private — no half-installed store copy is ever\n * renamed into place, and the next startup retry heals it.\n */\nasync function installStagingRuntimeDependencies(\n\tstaging: string,\n\tentries: readonly NodeZipPackageEntryV1[],\n\tsignal: AbortSignal,\n): Promise<void> {\n\tconst packageEntry = entries.find((entry) => entry.name === \"package.json\" && !entry.directory);\n\tif (packageEntry === undefined) return;\n\tlet manifest: unknown;\n\ttry {\n\t\tmanifest = JSON.parse(new TextDecoder(\"utf-8\", { fatal: true }).decode(packageEntry.bytes));\n\t} catch {\n\t\t// Package identity is already fully validated by the two manifests;\n\t\t// a package without a parseable package.json installs unchanged.\n\t\treturn;\n\t}\n\tif (typeof manifest !== \"object\" || manifest === null || Array.isArray(manifest)) return;\n\tconst record = manifest as Record<string, unknown>;\n\tconst dependencies = record.dependencies;\n\tif (typeof dependencies !== \"object\" || dependencies === null || Array.isArray(dependencies)) return;\n\tconst runtime: Record<string, unknown> = Object.fromEntries(\n\t\tObject.entries(dependencies as Record<string, unknown>).filter(([name]) => !isHostSuppliedDependencyV1(name)),\n\t);\n\tif (Object.keys(runtime).length === 0) return;\n\t// Rewrite the staging package.json to the runtime closure. Host-supplied\n\t// specifiers stay out (they resolve through jiti virtual modules and the\n\t// source-form names do not exist on the registry), and devDependencies are\n\t// dropped — npm resolves root devDependency metadata even under --omit=dev,\n\t// so unpublished dev names would fail the whole install with a 404.\n\tawait writeFile(\n\t\tjoin(staging, \"package.json\"),\n\t\tJSON.stringify({ ...record, dependencies: runtime, devDependencies: undefined }),\n\t\t{ flag: \"w\", mode: 0o600 },\n\t);\n\tconst win32 = process.platform === \"win32\";\n\tawait new Promise<void>((resolve, reject) => {\n\t\t// Node >= 18.20 refuses to spawn .cmd shims directly (EINVAL); the\n\t\t// fixed argument list contains no shell metacharacters, so the shell\n\t\t// join is safe (scripts/release.mjs precedent).\n\t\tconst child = spawn(\n\t\t\twin32 ? \"npm.cmd\" : \"npm\",\n\t\t\t[\"install\", \"--omit=dev\", \"--ignore-scripts\", \"--no-audit\", \"--no-fund\", \"--loglevel=error\"],\n\t\t\t// Inherits process.env so registry/proxy configuration follows\n\t\t\t// the host; abort kills the child and surfaces as a rejection.\n\t\t\t{ cwd: staging, signal, shell: win32, stdio: \"ignore\" },\n\t\t);\n\t\tchild.once(\"error\", reject);\n\t\tchild.once(\"close\", (code) => {\n\t\t\tif (code === 0) {\n\t\t\t\tresolve();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\treject(new NodePackageInstallErrorV1(\"dependency_install_failed\"));\n\t\t});\n\t});\n}\n\nasync function writeEntries(\n\troot: string,\n\tentries: readonly NodeZipPackageEntryV1[],\n\tsignal: AbortSignal,\n): Promise<void> {\n\tawait mkdir(root, { recursive: true, mode: 0o700 });\n\tfor (const entry of entries) {\n\t\tif (signal.aborted) throw new NodePackageInstallErrorV1(\"cancelled\");\n\t\tconst target = join(root, ...entry.name.split(\"/\"));\n\t\tif (entry.directory) {\n\t\t\tawait mkdir(target, { recursive: true, mode: 0o700 });\n\t\t\tcontinue;\n\t\t}\n\t\tconst parent = join(root, ...entry.name.split(\"/\").slice(0, -1));\n\t\tawait mkdir(parent, { recursive: true, mode: 0o700 });\n\t\tawait writeFile(target, entry.bytes, { flag: \"wx\", mode: 0o600 });\n\t}\n}\n\n/**\n * Host-owned ZIP/tgz package installer. It extracts only a bounded,\n * non-encrypted ZIP (\"application/zip\") or gzip-compressed tar\n * (\"application/gzip\") package and never executes package contents. The\n * returned installation handle is opaque; paths stay inside the host-owned\n * instance directory.\n */\nexport async function createNodePackageInstallHostV1(\n\toptions: NodePackageInstallHostOptionsV1,\n): Promise<NodePackageInstallHostV1> {\n\tif (typeof options.openArtifact !== \"function\") throw new Error(t(\"openArtifact is required\"));\n\tconst limits = resolveNodePackageLimitsV1(options);\n\tconst parent = options.installationDirectory ?? tmpdir();\n\tif (!isAbsolute(parent)) throw new Error(t(\"installationDirectory must be absolute\"));\n\tif (options.persistence !== undefined && options.persistence !== \"ephemeral\" && options.persistence !== \"persistent\")\n\t\tthrow new Error(t(\"persistence mode is invalid\"));\n\tconst supportedScopes = options.supportedScopes ?? [\"global\", \"project\"];\n\tif (\n\t\t!Array.isArray(supportedScopes) ||\n\t\tsupportedScopes.length === 0 ||\n\t\tnew Set(supportedScopes).size !== supportedScopes.length ||\n\t\tsupportedScopes.some((scope) => scope !== \"global\" && scope !== \"project\")\n\t)\n\t\tthrow new Error(t(\"supportedScopes is invalid\"));\n\tawait mkdir(parent, { recursive: true, mode: 0o700 });\n\tconst persistent = options.persistence === \"persistent\";\n\tconst instanceRoot = persistent\n\t\t? join(parent, \"agent-forge-plugin-install-store-v1\")\n\t\t: await mkdtemp(join(parent, \"agent-forge-plugin-install-\"));\n\tconst persistence: NodePackageInstallPersistenceV1 | undefined = persistent\n\t\t? await createNodePackageInstallPersistenceV1({\n\t\t\t\trootDirectory: instanceRoot,\n\t\t\t\tlockTimeoutMs: options.persistenceLockTimeoutMs,\n\t\t\t})\n\t\t: undefined;\n\tconst records = new Map<string, InstalledRecordV1>();\n\tconst activeByKey = new Map<string, string>();\n\tif (persistence !== undefined) {\n\t\tfor (const record of await persistence.load()) records.set(record.installationRef, { ...record });\n\t}\n\tfor (const record of records.values()) {\n\t\tif (record.state === \"active\")\n\t\t\tactiveByKey.set(installationKey(record.scope, record.scopeRef, record.pluginId), record.installationRef);\n\t}\n\tlet closed = false;\n\tconst activeOperations = new Set<AbortController>();\n\tconst runtimeHandles = new Map<string, { readonly dispose?: () => void | Promise<void> }>();\n\tconst applyPersistentSnapshot = (snapshot: readonly NodePackageInstallPersistentRecordV1[]): void => {\n\t\trecords.clear();\n\t\tactiveByKey.clear();\n\t\tfor (const value of snapshot) records.set(value.installationRef, { ...value });\n\t\tfor (const value of records.values()) {\n\t\t\tif (value.state === \"active\")\n\t\t\t\tactiveByKey.set(installationKey(value.scope, value.scopeRef, value.pluginId), value.installationRef);\n\t\t}\n\t};\n\tconst commitRecords = async (\n\t\tupdate: (values: Map<string, NodePackageInstallPersistentRecordV1>) => void | Promise<void>,\n\t): Promise<void> => {\n\t\tif (persistence === undefined) {\n\t\t\tawait update(records);\n\t\t\treturn;\n\t\t}\n\t\tapplyPersistentSnapshot(await persistence.mutate({ update }));\n\t};\n\tlet drained: (() => void) | undefined;\n\tlet closePromise: Promise<void> | undefined;\n\n\tconst begin = (\n\t\tparentSignal: AbortSignal | undefined,\n\t): { readonly controller: AbortController; readonly signal: AbortSignal } => {\n\t\tif (closed) throw new NodePackageInstallErrorV1(\"host_closed\");\n\t\tconst controller = new AbortController();\n\t\tif (parentSignal?.aborted) controller.abort(parentSignal.reason);\n\t\telse parentSignal?.addEventListener(\"abort\", () => controller.abort(parentSignal.reason), { once: true });\n\t\tactiveOperations.add(controller);\n\t\treturn { controller, signal: controller.signal };\n\t};\n\tconst end = (controller: AbortController): void => {\n\t\tactiveOperations.delete(controller);\n\t\tif (activeOperations.size === 0) {\n\t\t\tdrained?.();\n\t\t\tdrained = undefined;\n\t\t}\n\t};\n\tconst waitDrained = async (): Promise<void> => {\n\t\tif (activeOperations.size === 0) return;\n\t\tawait new Promise<void>((resolve) => {\n\t\t\tdrained = resolve;\n\t\t});\n\t};\n\tconst getRecord = (\n\t\tinstallation: PluginInstallationV1,\n\t\trecord: PluginUpdateRecordV1,\n\t\tscope: PluginInstallationScopeV1,\n\t\tscopeRef: string,\n\t): InstalledRecordV1 => {\n\t\tconst value = records.get(installation.installationRef);\n\t\tif (\n\t\t\tvalue === undefined ||\n\t\t\tinstallation.pluginId !== record.pluginId ||\n\t\t\tinstallation.pluginVersion !== record.pluginVersion ||\n\t\t\tinstallation.manifestDigest !== record.manifestDigest ||\n\t\t\tinstallation.scope !== scope ||\n\t\t\tinstallation.scopeRef !== scopeRef ||\n\t\t\t!identityMatches(value, {\n\t\t\t\tpluginId: record.pluginId,\n\t\t\t\tpluginVersion: record.pluginVersion,\n\t\t\t\tmanifestDigest: record.manifestDigest,\n\t\t\t\tscope,\n\t\t\t\tscopeRef,\n\t\t\t})\n\t\t)\n\t\t\tthrow new NodePackageInstallErrorV1(\"installation_identity_mismatch\");\n\t\treturn value;\n\t};\n\tconst disposeRuntime = async (installationRef: string): Promise<void> => {\n\t\tconst handle = runtimeHandles.get(installationRef);\n\t\tif (handle === undefined) return;\n\t\tif (handle.dispose !== undefined) await Promise.resolve(handle.dispose());\n\t\truntimeHandles.delete(installationRef);\n\t};\n\tconst loadRuntime = async (\n\t\tinstallation: PluginInstallationV1,\n\t\trecord: PluginUpdateRecordV1 | undefined,\n\t\tdirectory: string,\n\t\tsignal: AbortSignal,\n\t): Promise<{ readonly dispose?: () => void | Promise<void> } | undefined> => {\n\t\tif (options.loadPlugin === undefined) return undefined;\n\t\ttry {\n\t\t\tconst loaded = await options.loadPlugin({\n\t\t\t\tinstallation,\n\t\t\t\trecord,\n\t\t\t\tdirectory,\n\t\t\t\tmanifestPath: join(directory, CAPABILITY_MANIFEST_FILE_V1),\n\t\t\t\tsignal,\n\t\t\t});\n\t\t\treturn loaded ?? undefined;\n\t\t} catch (error) {\n\t\t\tif (error instanceof NodePackageInstallErrorV1) throw error;\n\t\t\tthrow new NodePackageInstallErrorV1(\"installation_io_failed\");\n\t\t}\n\t};\n\n\tconst host: NodePackageInstallHostV1 = {\n\t\tversion: NODE_PACKAGE_INSTALL_HOST_VERSION_V1,\n\t\tsupportedScopes: Object.freeze([...supportedScopes]),\n\t\tgetInstallationDirectory(input) {\n\t\t\tconst record = records.get(input.installation.installationRef);\n\t\t\tif (\n\t\t\t\trecord === undefined ||\n\t\t\t\trecord.pluginId !== input.installation.pluginId ||\n\t\t\t\trecord.pluginVersion !== input.installation.pluginVersion ||\n\t\t\t\trecord.manifestDigest !== input.installation.manifestDigest ||\n\t\t\t\trecord.scope !== input.installation.scope ||\n\t\t\t\trecord.scopeRef !== input.installation.scopeRef\n\t\t\t)\n\t\t\t\tthrow new NodePackageInstallErrorV1(\"installation_unknown\");\n\t\t\treturn record.directory;\n\t\t},\n\t\tasync install(input) {\n\t\t\tconst operation = begin(input.signal);\n\t\t\tlet staging: string | undefined;\n\t\t\ttry {\n\t\t\t\tif (input.artifact === undefined) throw new NodePackageInstallErrorV1(\"invalid_artifact\");\n\t\t\t\tif (!artifactIdentityMatchesRecord(input.artifact, input.record))\n\t\t\t\t\tthrow new NodePackageInstallErrorV1(\"invalid_artifact\");\n\t\t\t\tconst mediaType = input.artifact.mediaType.toLowerCase();\n\t\t\t\tif (mediaType !== \"application/zip\" && mediaType !== \"application/gzip\")\n\t\t\t\t\tthrow new NodePackageInstallErrorV1(\"unsupported_media_type\");\n\t\t\t\tconst scopeRef = opaqueScope(input.scopeRef);\n\t\t\t\tconst bytes = await collectArtifact(\n\t\t\t\t\toptions.openArtifact,\n\t\t\t\t\tinput.artifact,\n\t\t\t\t\tlimits.maxArchiveBytes,\n\t\t\t\t\toperation.signal,\n\t\t\t\t);\n\t\t\t\tif (input.artifact.sizeBytes !== bytes.byteLength) throw new NodePackageInstallErrorV1(\"invalid_artifact\");\n\t\t\t\tconst digest = expectedArtifactDigest(input.artifact.artifactDigest);\n\t\t\t\tif (createHash(digest.algorithm).update(bytes).digest(\"hex\") !== digest.hex)\n\t\t\t\t\tthrow new NodePackageInstallErrorV1(\"invalid_artifact\");\n\t\t\t\tconst entries =\n\t\t\t\t\tmediaType === \"application/gzip\"\n\t\t\t\t\t\t? await parseNodeTarGzPackageV1(bytes, limits)\n\t\t\t\t\t\t: parseNodeZipPackageV1(bytes, limits);\n\t\t\t\tconst manifestEntry = entries.find(\n\t\t\t\t\t(entry) => entry.name === ECOSYSTEM_MANIFEST_FILE_V1 && !entry.directory,\n\t\t\t\t);\n\t\t\t\tif (manifestEntry === undefined) throw new NodePackageInstallErrorV1(\"package_manifest_missing\");\n\t\t\t\tif (manifestEntry.bytes.byteLength > MAX_PACKAGE_MANIFEST_BYTES_V1)\n\t\t\t\t\tthrow new NodePackageInstallErrorV1(\"package_manifest_invalid\");\n\t\t\t\tlet manifest: unknown;\n\t\t\t\ttry {\n\t\t\t\t\tmanifest = JSON.parse(new TextDecoder(\"utf-8\", { fatal: true }).decode(manifestEntry.bytes));\n\t\t\t\t} catch {\n\t\t\t\t\tthrow new NodePackageInstallErrorV1(\"package_manifest_invalid\");\n\t\t\t\t}\n\t\t\t\tpackageManifest(manifest, input.record);\n\t\t\t\tconst capabilityEntry = entries.find(\n\t\t\t\t\t(entry) => entry.name === CAPABILITY_MANIFEST_FILE_V1 && !entry.directory,\n\t\t\t\t);\n\t\t\t\tif (capabilityEntry === undefined) throw new NodePackageInstallErrorV1(\"package_manifest_missing\");\n\t\t\t\tif (capabilityEntry.bytes.byteLength > MAX_PACKAGE_MANIFEST_BYTES_V1)\n\t\t\t\t\tthrow new NodePackageInstallErrorV1(\"package_manifest_invalid\");\n\t\t\t\tlet capability: unknown;\n\t\t\t\ttry {\n\t\t\t\t\tcapability = JSON.parse(new TextDecoder(\"utf-8\", { fatal: true }).decode(capabilityEntry.bytes));\n\t\t\t\t} catch {\n\t\t\t\t\tthrow new NodePackageInstallErrorV1(\"package_manifest_invalid\");\n\t\t\t\t}\n\t\t\t\tcapabilityManifest(capability, input.record, entries);\n\t\t\t\tconst key = installationKey(input.scope, scopeRef, input.record.pluginId);\n\t\t\t\tstaging = join(instanceRoot, `.staging-${randomUUID()}`);\n\t\t\t\tawait writeEntries(staging, entries, operation.signal);\n\t\t\t\t// Materialize declared runtime dependencies while staging is\n\t\t\t\t// still private; a failure throws before the rename, so no\n\t\t\t\t// half-installed copy ever reaches the store.\n\t\t\t\tif (options.dependencyMaterialization !== \"skip\") {\n\t\t\t\t\tawait installStagingRuntimeDependencies(staging, entries, operation.signal);\n\t\t\t\t}\n\t\t\t\tconst installRef = `plugin-install://node-zip/${randomUUID()}`;\n\t\t\t\tconst destination = packagePath(instanceRoot, `${key}\\u0000${installRef}`);\n\t\t\t\tawait rename(staging, destination);\n\t\t\t\tstaging = undefined;\n\t\t\t\tconst installedRecord: InstalledRecordV1 = {\n\t\t\t\t\tinstallationRef: installRef,\n\t\t\t\t\tdirectory: destination,\n\t\t\t\t\tpluginId: input.record.pluginId,\n\t\t\t\t\tpluginVersion: input.record.pluginVersion,\n\t\t\t\t\tmanifestDigest: input.record.manifestDigest,\n\t\t\t\t\tscope: input.scope,\n\t\t\t\t\tscopeRef,\n\t\t\t\t\tstate: \"installed\",\n\t\t\t\t};\n\t\t\t\ttry {\n\t\t\t\t\tawait commitRecords((values) => {\n\t\t\t\t\t\tvalues.set(installRef, installedRecord);\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\tawait rm(destination, { recursive: true, force: true }).catch(() => undefined);\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t\treturn { installationRef: installRef, scope: input.scope, scopeRef };\n\t\t\t} catch (error) {\n\t\t\t\tif (operation.signal.aborted || input.signal?.aborted) throw new NodePackageInstallErrorV1(\"cancelled\");\n\t\t\t\tif (error instanceof NodePackageInstallErrorV1) throw error;\n\t\t\t\tthrow new NodePackageInstallErrorV1(\"installation_io_failed\");\n\t\t\t} finally {\n\t\t\t\tif (staging !== undefined) await rm(staging, { recursive: true, force: true }).catch(() => undefined);\n\t\t\t\tend(operation.controller);\n\t\t\t}\n\t\t},\n\t\tasync activate(input) {\n\t\t\tconst operation = begin(input.signal);\n\t\t\tlet candidate: { readonly dispose?: () => void | Promise<void> } | undefined;\n\t\t\ttry {\n\t\t\t\tconst scopeRef = opaqueScope(input.scopeRef);\n\t\t\t\tconst record = getRecord(input.installation, input.record, input.scope, scopeRef);\n\t\t\t\tif (record.state !== \"installed\") throw new NodePackageInstallErrorV1(\"installation_identity_mismatch\");\n\t\t\t\tcandidate = await loadRuntime(input.installation, input.record, record.directory, operation.signal);\n\t\t\t\tconst key = installationKey(input.scope, scopeRef, input.record.pluginId);\n\t\t\t\tconst previousRef = activeByKey.get(key);\n\t\t\t\tif (previousRef !== undefined) {\n\t\t\t\t\tconst previous = records.get(previousRef);\n\t\t\t\t\tif (previous !== undefined) {\n\t\t\t\t\t\tawait disposeRuntime(previousRef);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tawait commitRecords((values) => {\n\t\t\t\t\tconst candidateRecord = values.get(input.installation.installationRef);\n\t\t\t\t\tif (candidateRecord === undefined) throw new NodePackageInstallErrorV1(\"installation_identity_mismatch\");\n\t\t\t\t\tif (previousRef !== undefined) {\n\t\t\t\t\t\tconst previousRecord = values.get(previousRef);\n\t\t\t\t\t\tif (previousRecord !== undefined) values.set(previousRef, { ...previousRecord, state: \"retained\" });\n\t\t\t\t\t}\n\t\t\t\t\tvalues.set(input.installation.installationRef, { ...candidateRecord, state: \"active\" });\n\t\t\t\t});\n\t\t\t\tactiveByKey.set(key, input.installation.installationRef);\n\t\t\t\tif (candidate !== undefined) runtimeHandles.set(input.installation.installationRef, candidate);\n\t\t\t\tcandidate = undefined;\n\t\t\t} catch (error) {\n\t\t\t\tif (candidate?.dispose !== undefined) await Promise.resolve(candidate.dispose()).catch(() => undefined);\n\t\t\t\tif (error instanceof NodePackageInstallErrorV1) throw error;\n\t\t\t\tthrow new NodePackageInstallErrorV1(\"installation_io_failed\");\n\t\t\t} finally {\n\t\t\t\tend(operation.controller);\n\t\t\t}\n\t\t},\n\t\tasync rollback(input) {\n\t\t\tconst operation = begin(input.signal);\n\t\t\tlet candidate: { readonly dispose?: () => void | Promise<void> } | undefined;\n\t\t\ttry {\n\t\t\t\tconst scopeRef = opaqueScope(input.scopeRef);\n\t\t\t\tconst failed = records.get(input.failed.installationRef);\n\t\t\t\tif (\n\t\t\t\t\tfailed === undefined ||\n\t\t\t\t\t!identityMatches(failed, {\n\t\t\t\t\t\tpluginId: input.failed.pluginId,\n\t\t\t\t\t\tpluginVersion: input.failed.pluginVersion,\n\t\t\t\t\t\tmanifestDigest: input.failed.manifestDigest,\n\t\t\t\t\t\tscope: input.scope,\n\t\t\t\t\t\tscopeRef,\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t\t\t\tthrow new NodePackageInstallErrorV1(\"installation_identity_mismatch\");\n\t\t\t\tconst previous = records.get(input.previous.installationRef);\n\t\t\t\tif (\n\t\t\t\t\tprevious === undefined ||\n\t\t\t\t\t!identityMatches(previous, {\n\t\t\t\t\t\tpluginId: input.previous.pluginId,\n\t\t\t\t\t\tpluginVersion: input.previous.pluginVersion,\n\t\t\t\t\t\tmanifestDigest: input.previous.manifestDigest,\n\t\t\t\t\t\tscope: input.scope,\n\t\t\t\t\t\tscopeRef,\n\t\t\t\t\t}) ||\n\t\t\t\t\t(previous.state !== \"active\" && previous.state !== \"retained\") ||\n\t\t\t\t\tfailed.pluginId !== previous.pluginId\n\t\t\t\t)\n\t\t\t\t\tthrow new NodePackageInstallErrorV1(\"installation_identity_mismatch\");\n\t\t\t\tconst previousInstallation: PluginInstallationV1 = {\n\t\t\t\t\tversion: 1,\n\t\t\t\t\tpluginId: previous.pluginId,\n\t\t\t\t\tpluginVersion: previous.pluginVersion,\n\t\t\t\t\tmanifestDigest: previous.manifestDigest,\n\t\t\t\t\tscope: previous.scope,\n\t\t\t\t\tscopeRef: previous.scopeRef,\n\t\t\t\t\tinstallationRef: input.previous.installationRef,\n\t\t\t\t\tstate: \"active\",\n\t\t\t\t};\n\t\t\t\tcandidate = await loadRuntime(previousInstallation, undefined, previous.directory, operation.signal);\n\t\t\t\tawait disposeRuntime(input.failed.installationRef);\n\t\t\t\tawait rm(failed.directory, { recursive: true, force: true });\n\t\t\t\tawait commitRecords((values) => {\n\t\t\t\t\tvalues.delete(input.failed.installationRef);\n\t\t\t\t\tconst previousRecord = values.get(input.previous.installationRef);\n\t\t\t\t\tif (previousRecord !== undefined)\n\t\t\t\t\t\tvalues.set(input.previous.installationRef, { ...previousRecord, state: \"active\" });\n\t\t\t\t});\n\t\t\t\tactiveByKey.set(installationKey(input.scope, scopeRef, failed.pluginId), input.previous.installationRef);\n\t\t\t\tif (candidate !== undefined) runtimeHandles.set(input.previous.installationRef, candidate);\n\t\t\t\tcandidate = undefined;\n\t\t\t} catch (error) {\n\t\t\t\tif (candidate?.dispose !== undefined) await Promise.resolve(candidate.dispose()).catch(() => undefined);\n\t\t\t\tif (error instanceof NodePackageInstallErrorV1) throw error;\n\t\t\t\tthrow new NodePackageInstallErrorV1(\"installation_io_failed\");\n\t\t\t} finally {\n\t\t\t\tend(operation.controller);\n\t\t\t}\n\t\t},\n\t\tasync uninstall(input) {\n\t\t\tconst operation = begin(input.signal);\n\t\t\ttry {\n\t\t\t\tconst scopeRef = opaqueScope(input.scopeRef);\n\t\t\t\tconst record = records.get(input.installation.installationRef);\n\t\t\t\tif (\n\t\t\t\t\trecord === undefined ||\n\t\t\t\t\t!identityMatches(record, {\n\t\t\t\t\t\tpluginId: input.installation.pluginId,\n\t\t\t\t\t\tpluginVersion: input.installation.pluginVersion,\n\t\t\t\t\t\tmanifestDigest: input.installation.manifestDigest,\n\t\t\t\t\t\tscope: input.scope,\n\t\t\t\t\t\tscopeRef,\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t\t\t\tthrow new NodePackageInstallErrorV1(\"installation_unknown\");\n\t\t\t\tawait disposeRuntime(input.installation.installationRef);\n\t\t\t\t// force:false keeps rm strict, but a directory that is already\n\t\t\t\t// gone (ghost record from an interrupted uninstall) is the\n\t\t\t\t// desired end state — continue to the index commit instead of\n\t\t\t\t// bricking every later store operation on ENOENT.\n\t\t\t\tawait rm(record.directory, { recursive: true, force: false }).catch((error: unknown) => {\n\t\t\t\t\tif ((error as NodeJS.ErrnoException).code === \"ENOENT\") return;\n\t\t\t\t\tthrow error;\n\t\t\t\t});\n\t\t\t\tawait commitRecords((values) => {\n\t\t\t\t\tvalues.delete(input.installation.installationRef);\n\t\t\t\t});\n\t\t\t\tconst key = installationKey(input.scope, scopeRef, record.pluginId);\n\t\t\t\tif (activeByKey.get(key) === input.installation.installationRef) activeByKey.delete(key);\n\t\t\t} finally {\n\t\t\t\tend(operation.controller);\n\t\t\t}\n\t\t},\n\t\tasync close() {\n\t\t\tif (closePromise !== undefined) return await closePromise;\n\t\t\tclosed = true;\n\t\t\tfor (const operation of activeOperations) operation.abort();\n\t\t\tclosePromise = (async () => {\n\t\t\t\tawait waitDrained();\n\t\t\t\tlet disposeError = false;\n\t\t\t\tfor (const installationRef of runtimeHandles.keys()) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait disposeRuntime(installationRef);\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tdisposeError = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (persistence === undefined) await rm(instanceRoot, { recursive: true, force: true });\n\t\t\t\telse await persistence.close();\n\t\t\t\trecords.clear();\n\t\t\t\tactiveByKey.clear();\n\t\t\t\tif (disposeError) throw new NodePackageInstallErrorV1(\"installation_io_failed\");\n\t\t\t})();\n\t\t\treturn await closePromise;\n\t\t},\n\t};\n\tif (options.loadPlugin !== undefined) {\n\t\ttry {\n\t\t\tfor (const record of records.values()) {\n\t\t\t\tif (record.state !== \"active\") continue;\n\t\t\t\tconst installation: PluginInstallationV1 = {\n\t\t\t\t\tversion: 1,\n\t\t\t\t\tpluginId: record.pluginId,\n\t\t\t\t\tpluginVersion: record.pluginVersion,\n\t\t\t\t\tmanifestDigest: record.manifestDigest,\n\t\t\t\t\tscope: record.scope,\n\t\t\t\t\tscopeRef: record.scopeRef,\n\t\t\t\t\tinstallationRef: record.installationRef,\n\t\t\t\t\tstate: \"active\",\n\t\t\t\t};\n\t\t\t\tconst runtime = await loadRuntime(installation, undefined, record.directory, new AbortController().signal);\n\t\t\t\tif (runtime !== undefined) runtimeHandles.set(record.installationRef, runtime);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tawait host.close().catch(() => undefined);\n\t\t\tif (error instanceof NodePackageInstallErrorV1) throw error;\n\t\t\tthrow new NodePackageInstallErrorV1(\"installation_io_failed\");\n\t\t}\n\t}\n\treturn host;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"node-package-install-host.js","sourceRoot":"","sources":["../../../src/plugins/ecosystem/node-package-install-host.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,6BAA6B,EAAE,MAAM,4CAA4C,CAAC;AAC3F,OAAO,EAAE,CAAC,EAAE,MAAM,0BAA0B,CAAC;AAG7C,OAAO,EACN,qCAAqC,GAGrC,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAEtD,MAAM,oCAAoC,GAAG,CAAU,CAAC;AACxD,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAU,CAAC;AACzD,MAAM,4BAA4B,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;AACvD,MAAM,oBAAoB,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;AAC/C,MAAM,8BAA8B,GAAG,GAAG,GAAG,IAAI,GAA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C,wBAAwB,CAAC,CAAC;QAC/D,CAAC;IACF,CAAC;IACD,OAAO,IAAI,CAAC;AAAA,CACZ","sourcesContent":["import { spawn } from \"node:child_process\";\nimport { createHash, randomUUID } from \"node:crypto\";\nimport { mkdir, mkdtemp, rename, rm, writeFile } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { isAbsolute, join } from \"node:path\";\nimport { inflateRawSync } from \"node:zlib\";\nimport { parseCapabilityPluginManifest } from \"../../core/extensions/capability-plugin.ts\";\nimport { t } from \"../../core/i18n/index.ts\";\nimport type { PluginDistributionArtifactV1 } from \"./distribution.ts\";\nimport type { PluginInstallationScopeV1, PluginInstallationV1, PluginInstallHostV1 } from \"./installer.ts\";\nimport {\n\tcreateNodePackageInstallPersistenceV1,\n\ttype NodePackageInstallPersistenceV1,\n\ttype NodePackageInstallPersistentRecordV1,\n} from \"./node-package-install-persistence.ts\";\nimport { parseNodeTarGzPackageV1 } from \"./node-tar-package.ts\";\nimport type { PluginManifestV1, PluginUpdateRecordV1 } from \"./types.ts\";\nimport { pluginManifestDigestV1 } from \"./updates.ts\";\n\nconst NODE_PACKAGE_INSTALL_HOST_VERSION_V1 = 1 as const;\nexport const NODE_PACKAGE_FORMAT_VERSION_V1 = 1 as const;\nconst DEFAULT_MAX_ARCHIVE_BYTES_V1 = 128 * 1024 * 1024;\nconst MAX_ARCHIVE_BYTES_V1 = 512 * 1024 * 1024;\nconst DEFAULT_MAX_EXTRACTED_BYTES_V1 = 256 * 1024 * 1024;\nconst MAX_EXTRACTED_BYTES_V1 = 1024 * 1024 * 1024;\nconst DEFAULT_MAX_ENTRY_BYTES_V1 = 64 * 1024 * 1024;\nconst MAX_ENTRY_BYTES_V1 = 256 * 1024 * 1024;\nconst DEFAULT_MAX_ENTRIES_V1 = 2048;\nconst MAX_ENTRIES_V1 = 8192;\nconst MAX_PACKAGE_MANIFEST_BYTES_V1 = 64 * 1024;\nconst ECOSYSTEM_MANIFEST_FILE_V1 = \"agent-forge.json\";\nconst CAPABILITY_MANIFEST_FILE_V1 = \"plugin.json\";\n/**\n * Host-supplied runtime dependency specifiers: at plugin load time these\n * resolve to the host's own copies through jiti virtual modules (supply\n * contract in core/extensions/virtual-modules.ts, mirrored by\n * HOST_SUPPLIED_PLUGIN_SPECIFIERS in scripts/check-plugin-boundary.mjs), so\n * they are never materialized into a store copy. Both the workspace scope\n * (source/checkout packages) and the published-name scope of the same\n * packages (scripts/release-packages.mjs name map) are covered; a future\n * plugin-to-plugin runtime dependency must therefore not use these scopes.\n */\nconst HOST_SUPPLIED_DEPENDENCY_PREFIXES_V1: readonly string[] = [\"@agent-forge/\", \"@ai-agent-forge/\"];\nconst HOST_SUPPLIED_DEPENDENCIES_V1: ReadonlySet<string> = new Set([\"typebox\"]);\n\nconst LOCAL_FILE_HEADER_V1 = 0x04034b50;\nconst CENTRAL_FILE_HEADER_V1 = 0x02014b50;\nconst END_OF_CENTRAL_DIRECTORY_V1 = 0x06054b50;\nconst ZIP64_END_OF_CENTRAL_DIRECTORY_V1 = 0x06064b50;\nconst ZIP64_END_OF_CENTRAL_DIRECTORY_LOCATOR_V1 = 0x07064b50;\n\nexport type NodePackageInstallErrorCodeV1 =\n\t| \"cancelled\"\n\t| \"host_closed\"\n\t| \"invalid_artifact\"\n\t| \"unsupported_media_type\"\n\t| \"archive_invalid\"\n\t| \"archive_budget_exceeded\"\n\t| \"package_manifest_missing\"\n\t| \"package_manifest_invalid\"\n\t| \"package_manifest_mismatch\"\n\t| \"dependency_install_failed\"\n\t| \"installation_unknown\"\n\t| \"installation_identity_mismatch\"\n\t| \"installation_io_failed\";\n\nexport class NodePackageInstallErrorV1 extends Error {\n\treadonly code: NodePackageInstallErrorCodeV1;\n\n\tconstructor(code: NodePackageInstallErrorCodeV1) {\n\t\tsuper(t(\"Node package installation failed: {code}\", { code }));\n\t\tthis.name = \"NodePackageInstallErrorV1\";\n\t\tthis.code = code;\n\t}\n}\n\nexport interface NodeZipPackageEntryV1 {\n\treadonly name: string;\n\treadonly directory: boolean;\n\treadonly bytes: Uint8Array;\n}\n\nexport interface NodeZipPackageLimitsV1 {\n\treadonly maxArchiveBytes?: number;\n\treadonly maxExtractedBytes?: number;\n\treadonly maxEntryBytes?: number;\n\treadonly maxEntries?: number;\n}\n\nexport interface NodePackageInstallHostOptionsV1 extends NodeZipPackageLimitsV1 {\n\t/** An opaque artifact reader owned by the distribution host. */\n\treadonly openArtifact: (input: {\n\t\treadonly artifact: PluginDistributionArtifactV1;\n\t\treadonly signal?: AbortSignal;\n\t}) => AsyncIterable<Uint8Array>;\n\t/** Parent directory owned by the host; no local path leaves this adapter. */\n\treadonly installationDirectory?: string;\n\treadonly supportedScopes?: readonly PluginInstallationScopeV1[];\n\t/** Persistent host-owned index; omitted keeps the test-friendly ephemeral mode. */\n\treadonly persistence?: \"ephemeral\" | \"persistent\";\n\treadonly persistenceLockTimeoutMs?: number;\n\t/**\n\t * Host-only runtime assembly seam. The directory and manifest path never\n\t * cross the public installer DTO or model/tool context.\n\t */\n\treadonly loadPlugin?: (input: {\n\t\treadonly installation: PluginInstallationV1;\n\t\treadonly record?: PluginUpdateRecordV1;\n\t\treadonly directory: string;\n\t\treadonly manifestPath: string;\n\t\treadonly signal: AbortSignal;\n\t}) => Promise<{ readonly dispose?: () => void | Promise<void> } | void>;\n\t/**\n\t * Omitted keeps the production behavior: declared non-host-supplied\n\t * runtime dependencies are materialized into the staging copy before the\n\t * atomic rename. Deterministic offline fixture chains\n\t * (test/*-package-fixtures) pass \"skip\" so installing real first-party\n\t * packages through the acquisition chain stays registry-free.\n\t */\n\treadonly dependencyMaterialization?: \"skip\";\n}\n\n/** Minimal structural bridge for an AgentSession-owned capability loader. */\nexport interface NodePackageInstallCapabilityPluginSessionV1 {\n\treadonly loadCapabilityPluginManifest: (manifestPath: string) => Promise<{\n\t\treadonly dispose: () => void | Promise<void>;\n\t}>;\n}\n\n/**\n * Adapt an AgentSession-like loader to the host-only runtime seam. The\n * manifest path is never returned as a DTO or sent through model context.\n */\nexport function createNodePackageInstallSessionLoaderV1(\n\tsession: NodePackageInstallCapabilityPluginSessionV1,\n): NonNullable<NodePackageInstallHostOptionsV1[\"loadPlugin\"]> {\n\treturn async ({ manifestPath }) => {\n\t\tconst handle = await session.loadCapabilityPluginManifest(manifestPath);\n\t\treturn { dispose: handle.dispose };\n\t};\n}\n\n/**\n * Create a package host with an explicit AgentSession-compatible runtime\n * loader. This is an opt-in composition helper; it does not alter Core's\n * default session construction or install untrusted package code.\n */\nexport async function createNodePackageInstallHostForSessionV1(\n\toptions: NodePackageInstallHostOptionsV1,\n\tsession: NodePackageInstallCapabilityPluginSessionV1,\n): Promise<NodePackageInstallHostV1> {\n\tif (options.loadPlugin !== undefined) throw new Error(t(\"loadPlugin must be omitted when binding a session\"));\n\treturn await createNodePackageInstallHostV1({\n\t\t...options,\n\t\tloadPlugin: createNodePackageInstallSessionLoaderV1(session),\n\t});\n}\n\nexport interface NodePackageInstallHostV1 extends PluginInstallHostV1 {\n\treadonly version: typeof NODE_PACKAGE_INSTALL_HOST_VERSION_V1;\n\treadonly uninstall: NonNullable<PluginInstallHostV1[\"uninstall\"]>;\n\t/** Host-only bridge for local runtime assembly; never put this path in a DTO or transcript. */\n\treadonly getInstallationDirectory: (input: { readonly installation: PluginInstallationV1 }) => string;\n\treadonly close: () => Promise<void>;\n}\n\ninterface ZipEntryDescriptorV1 {\n\treadonly name: string;\n\treadonly directory: boolean;\n\treadonly flags: number;\n\treadonly method: number;\n\treadonly compressedSize: number;\n\treadonly uncompressedSize: number;\n\treadonly crc32: number;\n\treadonly localOffset: number;\n}\n\ninterface ZipLocalSpanV1 {\n\treadonly start: number;\n\treadonly end: number;\n}\n\ninterface InstalledRecordV1 {\n\treadonly installationRef: string;\n\treadonly directory: string;\n\treadonly pluginId: string;\n\treadonly pluginVersion: string;\n\treadonly manifestDigest: string;\n\treadonly scope: PluginInstallationScopeV1;\n\treadonly scopeRef: string;\n\tstate: \"installed\" | \"active\" | \"retained\";\n}\n\nfunction positiveLimit(value: number | undefined, fallback: number, maximum: number, label: string): number {\n\tconst result = value ?? fallback;\n\tif (!Number.isSafeInteger(result) || result < 1 || result > maximum)\n\t\tthrow new Error(t(\"{label} must be a positive integer at most {maximum}\", { label, maximum }));\n\treturn result;\n}\n\n/** Resolve the archive budget limits shared by the ZIP and tgz package parsers. */\nexport function resolveNodePackageLimitsV1(limitsInput: NodeZipPackageLimitsV1): Required<NodeZipPackageLimitsV1> {\n\treturn {\n\t\tmaxArchiveBytes: positiveLimit(\n\t\t\tlimitsInput.maxArchiveBytes,\n\t\t\tDEFAULT_MAX_ARCHIVE_BYTES_V1,\n\t\t\tMAX_ARCHIVE_BYTES_V1,\n\t\t\t\"maxArchiveBytes\",\n\t\t),\n\t\tmaxExtractedBytes: positiveLimit(\n\t\t\tlimitsInput.maxExtractedBytes,\n\t\t\tDEFAULT_MAX_EXTRACTED_BYTES_V1,\n\t\t\tMAX_EXTRACTED_BYTES_V1,\n\t\t\t\"maxExtractedBytes\",\n\t\t),\n\t\tmaxEntryBytes: positiveLimit(\n\t\t\tlimitsInput.maxEntryBytes,\n\t\t\tDEFAULT_MAX_ENTRY_BYTES_V1,\n\t\t\tMAX_ENTRY_BYTES_V1,\n\t\t\t\"maxEntryBytes\",\n\t\t),\n\t\tmaxEntries: positiveLimit(limitsInput.maxEntries, DEFAULT_MAX_ENTRIES_V1, MAX_ENTRIES_V1, \"maxEntries\"),\n\t};\n}\n\nfunction readU16(bytes: Uint8Array, offset: number): number {\n\tif (offset < 0 || offset + 2 > bytes.byteLength) throw new NodePackageInstallErrorV1(\"archive_invalid\");\n\treturn bytes[offset]! | (bytes[offset + 1]! << 8);\n}\n\nfunction readU32(bytes: Uint8Array, offset: number): number {\n\tif (offset < 0 || offset + 4 > bytes.byteLength) throw new NodePackageInstallErrorV1(\"archive_invalid\");\n\treturn (bytes[offset]! | (bytes[offset + 1]! << 8) | (bytes[offset + 2]! << 16) | (bytes[offset + 3]! << 24)) >>> 0;\n}\n\nfunction decodeName(bytes: Uint8Array, utf8: boolean): string {\n\ttry {\n\t\tconst value = new TextDecoder(\"utf-8\", { fatal: true }).decode(bytes);\n\t\tif (!utf8 && /[^\\x00-\\x7f]/u.test(value)) throw new Error(t(\"non-ascii zip name\"));\n\t\treturn value;\n\t} catch {\n\t\tthrow new NodePackageInstallErrorV1(\"archive_invalid\");\n\t}\n}\n\n/** Normalized archive entry name shared by the ZIP and tgz package parsers. */\nexport function normalizedEntryName(value: string): { readonly name: string; readonly directory: boolean } {\n\tif (value.length === 0 || value.includes(\"\\\\\") || /[\\u0000-\\u001f\\u007f]/u.test(value))\n\t\tthrow new NodePackageInstallErrorV1(\"archive_invalid\");\n\tconst directory = value.endsWith(\"/\");\n\tif (value.startsWith(\"/\") || /^[a-z]:/iu.test(value)) throw new NodePackageInstallErrorV1(\"archive_invalid\");\n\tconst parts = value.split(\"/\");\n\tif (directory) parts.pop();\n\tif (\n\t\tparts.length === 0 ||\n\t\tparts.some(\n\t\t\t(part) =>\n\t\t\t\tpart === \"\" ||\n\t\t\t\tpart === \".\" ||\n\t\t\t\tpart === \"..\" ||\n\t\t\t\tpart.includes(\":\") ||\n\t\t\t\t/[ .]$/u.test(part) ||\n\t\t\t\t/^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\\..*)?$/iu.test(part),\n\t\t)\n\t)\n\t\tthrow new NodePackageInstallErrorV1(\"archive_invalid\");\n\treturn { name: parts.join(\"/\"), directory };\n}\n\nfunction crcTable(): Uint32Array {\n\tconst table = new Uint32Array(256);\n\tfor (let index = 0; index < table.length; index += 1) {\n\t\tlet value = index;\n\t\tfor (let bit = 0; bit < 8; bit += 1) value = (value & 1) === 0 ? value >>> 1 : (value >>> 1) ^ 0xedb88320;\n\t\ttable[index] = value >>> 0;\n\t}\n\treturn table;\n}\n\nconst CRC_TABLE_V1 = crcTable();\n\nfunction crc32(bytes: Uint8Array): number {\n\tlet value = 0xffffffff;\n\tfor (const byte of bytes) value = (value >>> 8) ^ CRC_TABLE_V1[(value ^ byte) & 0xff]!;\n\treturn (value ^ 0xffffffff) >>> 0;\n}\n\nfunction findEndOfCentralDirectory(bytes: Uint8Array): {\n\treadonly offset: number;\n\treadonly entries: number;\n\treadonly size: number;\n\treadonly start: number;\n} {\n\tconst minimum = Math.max(0, bytes.byteLength - 0xffff - 22);\n\tfor (let offset = bytes.byteLength - 22; offset >= minimum; offset -= 1) {\n\t\tif (readU32(bytes, offset) !== END_OF_CENTRAL_DIRECTORY_V1) continue;\n\t\tconst disk = readU16(bytes, offset + 4);\n\t\tconst centralDisk = readU16(bytes, offset + 6);\n\t\tconst entries = readU16(bytes, offset + 10);\n\t\tconst centralEntries = readU16(bytes, offset + 8);\n\t\tconst size = readU32(bytes, offset + 12);\n\t\tconst start = readU32(bytes, offset + 16);\n\t\tconst commentLength = readU16(bytes, offset + 20);\n\t\tif (\n\t\t\tdisk !== 0 ||\n\t\t\tcentralDisk !== 0 ||\n\t\t\tentries !== centralEntries ||\n\t\t\toffset + 22 + commentLength !== bytes.byteLength\n\t\t)\n\t\t\tthrow new NodePackageInstallErrorV1(\"archive_invalid\");\n\t\tif (entries === 0xffff || size === 0xffffffff || start === 0xffffffff)\n\t\t\tthrow new NodePackageInstallErrorV1(\"archive_invalid\");\n\t\tif (start + size > offset) throw new NodePackageInstallErrorV1(\"archive_invalid\");\n\t\treturn { offset, entries, size, start };\n\t}\n\tfor (let offset = Math.max(0, bytes.byteLength - 64); offset < bytes.byteLength - 3; offset += 1) {\n\t\tconst signature = readU32(bytes, offset);\n\t\tif (signature === ZIP64_END_OF_CENTRAL_DIRECTORY_V1 || signature === ZIP64_END_OF_CENTRAL_DIRECTORY_LOCATOR_V1)\n\t\t\tthrow new NodePackageInstallErrorV1(\"archive_invalid\");\n\t}\n\tthrow new NodePackageInstallErrorV1(\"archive_invalid\");\n}\n\nfunction parseCentralDirectory(\n\tbytes: Uint8Array,\n\tlimits: Required<NodeZipPackageLimitsV1>,\n): readonly ZipEntryDescriptorV1[] {\n\tconst end = findEndOfCentralDirectory(bytes);\n\tif (end.entries > limits.maxEntries || end.size > bytes.byteLength || end.start + end.size > end.offset)\n\t\tthrow new NodePackageInstallErrorV1(\"archive_budget_exceeded\");\n\tconst entries: ZipEntryDescriptorV1[] = [];\n\tconst names = new Set<string>();\n\tlet offset = end.start;\n\tfor (let index = 0; index < end.entries; index += 1) {\n\t\tif (readU32(bytes, offset) !== CENTRAL_FILE_HEADER_V1) throw new NodePackageInstallErrorV1(\"archive_invalid\");\n\t\tconst madeBy = readU16(bytes, offset + 4) >>> 8;\n\t\tconst flags = readU16(bytes, offset + 8);\n\t\tconst method = readU16(bytes, offset + 10);\n\t\tconst crc = readU32(bytes, offset + 16);\n\t\tconst compressedSize = readU32(bytes, offset + 20);\n\t\tconst uncompressedSize = readU32(bytes, offset + 24);\n\t\tconst nameLength = readU16(bytes, offset + 28);\n\t\tconst extraLength = readU16(bytes, offset + 30);\n\t\tconst commentLength = readU16(bytes, offset + 32);\n\t\tconst disk = readU16(bytes, offset + 34);\n\t\tconst externalAttributes = readU32(bytes, offset + 38);\n\t\tconst localOffset = readU32(bytes, offset + 42);\n\t\tconst nameStart = offset + 46;\n\t\tconst recordEnd = nameStart + nameLength + extraLength + commentLength;\n\t\tif (\n\t\t\trecordEnd > end.start + end.size ||\n\t\t\tdisk !== 0 ||\n\t\t\t(flags & ~(0x8 | 0x800)) !== 0 ||\n\t\t\t(flags & 1) !== 0 ||\n\t\t\t(flags & 0x40) !== 0\n\t\t)\n\t\t\tthrow new NodePackageInstallErrorV1(\"archive_invalid\");\n\t\tif (method !== 0 && method !== 8) throw new NodePackageInstallErrorV1(\"archive_invalid\");\n\t\tif (uncompressedSize > limits.maxEntryBytes || compressedSize > limits.maxArchiveBytes)\n\t\t\tthrow new NodePackageInstallErrorV1(\"archive_budget_exceeded\");\n\t\tconst name = normalizedEntryName(\n\t\t\tdecodeName(bytes.subarray(nameStart, nameStart + nameLength), (flags & 0x800) !== 0),\n\t\t);\n\t\tif (names.has(name.name)) throw new NodePackageInstallErrorV1(\"archive_invalid\");\n\t\tnames.add(name.name);\n\t\tconst unixMode = madeBy === 3 ? (externalAttributes >>> 16) & 0xffff : 0;\n\t\tif ((unixMode & 0xf000) === 0xa000) throw new NodePackageInstallErrorV1(\"archive_invalid\");\n\t\tentries.push({\n\t\t\tname: name.name,\n\t\t\tdirectory: name.directory,\n\t\t\tflags,\n\t\t\tmethod,\n\t\t\tcompressedSize,\n\t\t\tuncompressedSize,\n\t\t\tcrc32: crc,\n\t\t\tlocalOffset,\n\t\t});\n\t\toffset = recordEnd;\n\t}\n\tif (offset !== end.start + end.size) throw new NodePackageInstallErrorV1(\"archive_invalid\");\n\t// Validate the local-file regions before extraction. A forged central\n\t// directory must not be able to point into another entry or into the\n\t// central directory/EOCD; otherwise extraction could reinterpret metadata\n\t// bytes as package contents.\n\tconst spans: ZipLocalSpanV1[] = [];\n\tfor (const entry of entries) {\n\t\tif (entry.localOffset < 0 || entry.localOffset + 30 > end.start)\n\t\t\tthrow new NodePackageInstallErrorV1(\"archive_invalid\");\n\t\tif (readU32(bytes, entry.localOffset) !== LOCAL_FILE_HEADER_V1)\n\t\t\tthrow new NodePackageInstallErrorV1(\"archive_invalid\");\n\t\tconst localNameLength = readU16(bytes, entry.localOffset + 26);\n\t\tconst localExtraLength = readU16(bytes, entry.localOffset + 28);\n\t\tconst dataStart = entry.localOffset + 30 + localNameLength + localExtraLength;\n\t\tconst dataEnd = dataStart + entry.compressedSize;\n\t\tif (dataStart < entry.localOffset + 30 || dataEnd < dataStart || dataEnd > end.start)\n\t\t\tthrow new NodePackageInstallErrorV1(\"archive_invalid\");\n\t\tspans.push({ start: entry.localOffset, end: dataEnd });\n\t}\n\tspans.sort((left, right) => left.start - right.start || left.end - right.end);\n\tfor (let index = 1; index < spans.length; index += 1) {\n\t\tif (spans[index - 1]!.end > spans[index]!.start) throw new NodePackageInstallErrorV1(\"archive_invalid\");\n\t}\n\treturn entries;\n}\n\nfunction extractEntry(bytes: Uint8Array, entry: ZipEntryDescriptorV1, maxEntryBytes: number): Uint8Array {\n\tif (entry.directory) {\n\t\tif (entry.compressedSize !== 0 || entry.uncompressedSize !== 0)\n\t\t\tthrow new NodePackageInstallErrorV1(\"archive_invalid\");\n\t\treturn new Uint8Array();\n\t}\n\tif (entry.localOffset + 30 > bytes.byteLength) throw new NodePackageInstallErrorV1(\"archive_invalid\");\n\tif (readU32(bytes, entry.localOffset) !== LOCAL_FILE_HEADER_V1)\n\t\tthrow new NodePackageInstallErrorV1(\"archive_invalid\");\n\tconst localFlags = readU16(bytes, entry.localOffset + 6);\n\tconst localMethod = readU16(bytes, entry.localOffset + 8);\n\tconst nameLength = readU16(bytes, entry.localOffset + 26);\n\tconst extraLength = readU16(bytes, entry.localOffset + 28);\n\tconst localName = decodeName(\n\t\tbytes.subarray(entry.localOffset + 30, entry.localOffset + 30 + nameLength),\n\t\t(entry.flags & 0x800) !== 0,\n\t);\n\tif (normalizedEntryName(localName).name !== entry.name || localFlags !== entry.flags || localMethod !== entry.method)\n\t\tthrow new NodePackageInstallErrorV1(\"archive_invalid\");\n\tconst localCompressedSize = readU32(bytes, entry.localOffset + 18);\n\tconst localUncompressedSize = readU32(bytes, entry.localOffset + 22);\n\tif (\n\t\t(entry.flags & 8) === 0 &&\n\t\t(localCompressedSize !== entry.compressedSize || localUncompressedSize !== entry.uncompressedSize)\n\t)\n\t\tthrow new NodePackageInstallErrorV1(\"archive_invalid\");\n\tconst dataStart = entry.localOffset + 30 + nameLength + extraLength;\n\tconst dataEnd = dataStart + entry.compressedSize;\n\tif (dataStart > bytes.byteLength || dataEnd > bytes.byteLength)\n\t\tthrow new NodePackageInstallErrorV1(\"archive_invalid\");\n\tconst compressed = bytes.subarray(dataStart, dataEnd);\n\tlet output: Uint8Array;\n\ttry {\n\t\toutput =\n\t\t\tentry.method === 0\n\t\t\t\t? new Uint8Array(compressed)\n\t\t\t\t: inflateRawSync(compressed, { maxOutputLength: maxEntryBytes });\n\t} catch {\n\t\tthrow new NodePackageInstallErrorV1(\"archive_invalid\");\n\t}\n\tif (\n\t\toutput.byteLength !== entry.uncompressedSize ||\n\t\toutput.byteLength > maxEntryBytes ||\n\t\tcrc32(output) !== entry.crc32\n\t)\n\t\tthrow new NodePackageInstallErrorV1(\"archive_invalid\");\n\treturn output;\n}\n\nexport function parseNodeZipPackageV1(\n\tinput: Uint8Array,\n\tlimitsInput: NodeZipPackageLimitsV1 = {},\n): readonly NodeZipPackageEntryV1[] {\n\tif (!(input instanceof Uint8Array)) throw new NodePackageInstallErrorV1(\"archive_invalid\");\n\tconst limits = resolveNodePackageLimitsV1(limitsInput);\n\tif (input.byteLength > limits.maxArchiveBytes) throw new NodePackageInstallErrorV1(\"archive_budget_exceeded\");\n\tconst descriptors = parseCentralDirectory(input, limits);\n\tlet extractedBytes = 0;\n\treturn Object.freeze(\n\t\tdescriptors.map((descriptor) => {\n\t\t\tconst bytes = extractEntry(input, descriptor, limits.maxEntryBytes);\n\t\t\textractedBytes += bytes.byteLength;\n\t\t\tif (extractedBytes > limits.maxExtractedBytes) throw new NodePackageInstallErrorV1(\"archive_budget_exceeded\");\n\t\t\treturn Object.freeze({ name: descriptor.name, directory: descriptor.directory, bytes });\n\t\t}),\n\t);\n}\n\nfunction manifestKeys(value: Record<string, unknown>): boolean {\n\tconst allowed = new Set([\n\t\t\"packageFormatVersion\",\n\t\t\"id\",\n\t\t\"pluginVersion\",\n\t\t\"apiVersion\",\n\t\t\"minHostVersion\",\n\t\t\"maxHostVersion\",\n\t\t\"capabilityRefs\",\n\t\t\"requires\",\n\t\t\"platform\",\n\t\t\"testOnly\",\n\t]);\n\treturn Object.keys(value).every((key) => allowed.has(key));\n}\n\nfunction packageManifest(value: unknown, record: PluginUpdateRecordV1): void {\n\tif (value === null || typeof value !== \"object\" || Array.isArray(value))\n\t\tthrow new NodePackageInstallErrorV1(\"package_manifest_invalid\");\n\tconst manifest = value as Record<string, unknown>;\n\tif (\n\t\t!manifestKeys(manifest) ||\n\t\tmanifest.packageFormatVersion !== NODE_PACKAGE_FORMAT_VERSION_V1 ||\n\t\tmanifest.id !== record.pluginId ||\n\t\tmanifest.pluginVersion !== record.pluginVersion\n\t)\n\t\tthrow new NodePackageInstallErrorV1(\"package_manifest_mismatch\");\n\tif (typeof manifest.apiVersion !== \"string\" || manifest.apiVersion !== record.manifest.apiVersion)\n\t\tthrow new NodePackageInstallErrorV1(\"package_manifest_mismatch\");\n\ttry {\n\t\tif (pluginManifestDigestV1(manifest as unknown as PluginManifestV1) !== record.manifestDigest)\n\t\t\tthrow new NodePackageInstallErrorV1(\"package_manifest_mismatch\");\n\t} catch (error) {\n\t\tif (error instanceof NodePackageInstallErrorV1) throw error;\n\t\tthrow new NodePackageInstallErrorV1(\"package_manifest_invalid\");\n\t}\n}\n\nfunction capabilityManifest(\n\tvalue: unknown,\n\trecord: PluginUpdateRecordV1,\n\tentries: readonly NodeZipPackageEntryV1[],\n): void {\n\tlet manifest: ReturnType<typeof parseCapabilityPluginManifest>;\n\ttry {\n\t\tmanifest = parseCapabilityPluginManifest(value, \"<installed plugin.json>\");\n\t} catch {\n\t\tthrow new NodePackageInstallErrorV1(\"package_manifest_invalid\");\n\t}\n\tif (manifest.id !== record.pluginId || manifest.version !== record.pluginVersion)\n\t\tthrow new NodePackageInstallErrorV1(\"package_manifest_mismatch\");\n\tconst entryValue = manifest.entry.startsWith(\"./\") ? manifest.entry.slice(2) : manifest.entry;\n\tconst entry = normalizedEntryName(entryValue);\n\tif (entry.directory || !entries.some((candidate) => candidate.name === entry.name && !candidate.directory))\n\t\tthrow new NodePackageInstallErrorV1(\"package_manifest_mismatch\");\n}\n\nfunction opaqueScope(value: string): string {\n\tif (\n\t\ttypeof value !== \"string\" ||\n\t\tvalue.trim() === \"\" ||\n\t\tvalue.length > 2048 ||\n\t\t/\\s|[\\u0000-\\u001f\\u007f]/u.test(value)\n\t)\n\t\tthrow new NodePackageInstallErrorV1(\"installation_identity_mismatch\");\n\treturn value;\n}\n\nfunction installationKey(scope: PluginInstallationScopeV1, scopeRef: string, pluginId: string): string {\n\treturn `${scope}\\u0000${scopeRef}\\u0000${pluginId}`;\n}\n\nfunction identityMatches(\n\trecord: InstalledRecordV1,\n\tinput: {\n\t\treadonly pluginId: string;\n\t\treadonly pluginVersion: string;\n\t\treadonly manifestDigest: string;\n\t\treadonly scope: PluginInstallationScopeV1;\n\t\treadonly scopeRef: string;\n\t},\n): boolean {\n\treturn (\n\t\trecord.pluginId === input.pluginId &&\n\t\trecord.pluginVersion === input.pluginVersion &&\n\t\trecord.manifestDigest === input.manifestDigest &&\n\t\trecord.scope === input.scope &&\n\t\trecord.scopeRef === input.scopeRef\n\t);\n}\n\nfunction artifactIdentityMatchesRecord(artifact: PluginDistributionArtifactV1, record: PluginUpdateRecordV1): boolean {\n\treturn (\n\t\tartifact.version === 1 &&\n\t\tartifact.pluginId === record.pluginId &&\n\t\tartifact.pluginVersion === record.pluginVersion &&\n\t\tartifact.manifestDigest === record.manifestDigest\n\t);\n}\n\nfunction expectedArtifactDigest(value: string): { readonly algorithm: \"sha256\" | \"sha512\"; readonly hex: string } {\n\tconst prefixed = /^(sha256|sha512):([0-9a-f]+)$/iu.exec(value);\n\tif (prefixed !== null) {\n\t\tconst algorithm = prefixed[1]!.toLowerCase() as \"sha256\" | \"sha512\";\n\t\tconst hex = prefixed[2]!.toLowerCase();\n\t\tif ((algorithm === \"sha256\" && hex.length === 64) || (algorithm === \"sha512\" && hex.length === 128))\n\t\t\treturn { algorithm, hex };\n\t}\n\tif (/^[0-9a-f]{64}$/iu.test(value)) return { algorithm: \"sha256\", hex: value.toLowerCase() };\n\tif (/^[0-9a-f]{128}$/iu.test(value)) return { algorithm: \"sha512\", hex: value.toLowerCase() };\n\tthrow new NodePackageInstallErrorV1(\"invalid_artifact\");\n}\n\nasync function collectArtifact(\n\topenArtifact: NodePackageInstallHostOptionsV1[\"openArtifact\"],\n\tartifact: PluginDistributionArtifactV1,\n\tmaxBytes: number,\n\tsignal: AbortSignal,\n): Promise<Uint8Array> {\n\tconst chunks: Uint8Array[] = [];\n\tlet total = 0;\n\tfor await (const chunk of openArtifact({ artifact, signal })) {\n\t\tif (signal.aborted) throw new NodePackageInstallErrorV1(\"cancelled\");\n\t\tif (!(chunk instanceof Uint8Array)) throw new NodePackageInstallErrorV1(\"invalid_artifact\");\n\t\tif (chunk.byteLength > maxBytes - total) throw new NodePackageInstallErrorV1(\"archive_budget_exceeded\");\n\t\tchunks.push(new Uint8Array(chunk));\n\t\ttotal += chunk.byteLength;\n\t}\n\tconst result = new Uint8Array(total);\n\tlet offset = 0;\n\tfor (const chunk of chunks) {\n\t\tresult.set(chunk, offset);\n\t\toffset += chunk.byteLength;\n\t}\n\treturn result;\n}\n\nfunction packagePath(root: string, key: string): string {\n\treturn join(root, createHash(\"sha256\").update(key).digest(\"hex\"));\n}\n\nfunction isHostSuppliedDependencyV1(name: string): boolean {\n\treturn (\n\t\tHOST_SUPPLIED_DEPENDENCIES_V1.has(name) ||\n\t\tHOST_SUPPLIED_DEPENDENCY_PREFIXES_V1.some((prefix) => name.startsWith(prefix))\n\t);\n}\n\n/**\n * Install declared runtime dependencies inside the staging directory before\n * the atomic rename (2026-10-07 user ruling): npm tarballs never carry\n * node_modules, so a store copy of a plugin with runtime dependencies\n * (e.g. memory's onnxruntime-node) would otherwise have no dependency tree\n * at load time. A failed dependency install fails the whole installation\n * while staging is still private — no half-installed store copy is ever\n * renamed into place, and the next startup retry heals it.\n */\nasync function installStagingRuntimeDependencies(\n\tstaging: string,\n\tentries: readonly NodeZipPackageEntryV1[],\n\tsignal: AbortSignal,\n): Promise<void> {\n\tconst packageEntry = entries.find((entry) => entry.name === \"package.json\" && !entry.directory);\n\tif (packageEntry === undefined) return;\n\tlet manifest: unknown;\n\ttry {\n\t\tmanifest = JSON.parse(new TextDecoder(\"utf-8\", { fatal: true }).decode(packageEntry.bytes));\n\t} catch {\n\t\t// Unlike the two manifests, a package.json with parse errors is not\n\t\t// part of install validation: the package installs unchanged and the\n\t\t// missing runtime dependencies surface later as module-not-found at\n\t\t// plugin load (registered boundary in the distribution design).\n\t\treturn;\n\t}\n\tif (typeof manifest !== \"object\" || manifest === null || Array.isArray(manifest)) return;\n\tconst record = manifest as Record<string, unknown>;\n\tconst dependencies = record.dependencies;\n\tif (typeof dependencies !== \"object\" || dependencies === null || Array.isArray(dependencies)) return;\n\tconst runtime: Record<string, unknown> = Object.fromEntries(\n\t\tObject.entries(dependencies as Record<string, unknown>).filter(([name]) => !isHostSuppliedDependencyV1(name)),\n\t);\n\tif (Object.keys(runtime).length === 0) return;\n\t// Rewrite the staging package.json to the runtime closure. Host-supplied\n\t// specifiers stay out (they resolve through jiti virtual modules and the\n\t// source-form names do not exist on the registry), and devDependencies are\n\t// dropped — npm resolves root devDependency metadata even under --omit=dev,\n\t// so unpublished dev names would fail the whole install with a 404.\n\tawait writeFile(\n\t\tjoin(staging, \"package.json\"),\n\t\tJSON.stringify({ ...record, dependencies: runtime, devDependencies: undefined }),\n\t\t{ flag: \"w\", mode: 0o600 },\n\t);\n\tconst win32 = process.platform === \"win32\";\n\tawait new Promise<void>((resolve, reject) => {\n\t\t// Node >= 18.20 refuses to spawn .cmd shims directly (EINVAL); the\n\t\t// fixed argument list contains no shell metacharacters, so the shell\n\t\t// join is safe (scripts/release.mjs precedent).\n\t\tconst child = spawn(\n\t\t\twin32 ? \"npm.cmd\" : \"npm\",\n\t\t\t[\"install\", \"--omit=dev\", \"--ignore-scripts\", \"--no-audit\", \"--no-fund\", \"--loglevel=error\"],\n\t\t\t// Inherits process.env so registry/proxy configuration follows\n\t\t\t// the host; abort kills the child and surfaces as a rejection.\n\t\t\t{ cwd: staging, signal, shell: win32, stdio: \"ignore\" },\n\t\t);\n\t\tchild.once(\"error\", reject);\n\t\tchild.once(\"close\", (code) => {\n\t\t\tif (code === 0) {\n\t\t\t\tresolve();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\treject(new NodePackageInstallErrorV1(\"dependency_install_failed\"));\n\t\t});\n\t});\n}\n\nasync function writeEntries(\n\troot: string,\n\tentries: readonly NodeZipPackageEntryV1[],\n\tsignal: AbortSignal,\n): Promise<void> {\n\tawait mkdir(root, { recursive: true, mode: 0o700 });\n\tfor (const entry of entries) {\n\t\tif (signal.aborted) throw new NodePackageInstallErrorV1(\"cancelled\");\n\t\tconst target = join(root, ...entry.name.split(\"/\"));\n\t\tif (entry.directory) {\n\t\t\tawait mkdir(target, { recursive: true, mode: 0o700 });\n\t\t\tcontinue;\n\t\t}\n\t\tconst parent = join(root, ...entry.name.split(\"/\").slice(0, -1));\n\t\tawait mkdir(parent, { recursive: true, mode: 0o700 });\n\t\tawait writeFile(target, entry.bytes, { flag: \"wx\", mode: 0o600 });\n\t}\n}\n\n/**\n * Host-owned ZIP/tgz package installer. It extracts only a bounded,\n * non-encrypted ZIP (\"application/zip\") or gzip-compressed tar\n * (\"application/gzip\") package and never executes package contents. The\n * returned installation handle is opaque; paths stay inside the host-owned\n * instance directory.\n */\nexport async function createNodePackageInstallHostV1(\n\toptions: NodePackageInstallHostOptionsV1,\n): Promise<NodePackageInstallHostV1> {\n\tif (typeof options.openArtifact !== \"function\") throw new Error(t(\"openArtifact is required\"));\n\tconst limits = resolveNodePackageLimitsV1(options);\n\tconst parent = options.installationDirectory ?? tmpdir();\n\tif (!isAbsolute(parent)) throw new Error(t(\"installationDirectory must be absolute\"));\n\tif (options.persistence !== undefined && options.persistence !== \"ephemeral\" && options.persistence !== \"persistent\")\n\t\tthrow new Error(t(\"persistence mode is invalid\"));\n\tconst supportedScopes = options.supportedScopes ?? [\"global\", \"project\"];\n\tif (\n\t\t!Array.isArray(supportedScopes) ||\n\t\tsupportedScopes.length === 0 ||\n\t\tnew Set(supportedScopes).size !== supportedScopes.length ||\n\t\tsupportedScopes.some((scope) => scope !== \"global\" && scope !== \"project\")\n\t)\n\t\tthrow new Error(t(\"supportedScopes is invalid\"));\n\tawait mkdir(parent, { recursive: true, mode: 0o700 });\n\tconst persistent = options.persistence === \"persistent\";\n\tconst instanceRoot = persistent\n\t\t? join(parent, \"agent-forge-plugin-install-store-v1\")\n\t\t: await mkdtemp(join(parent, \"agent-forge-plugin-install-\"));\n\tconst persistence: NodePackageInstallPersistenceV1 | undefined = persistent\n\t\t? await createNodePackageInstallPersistenceV1({\n\t\t\t\trootDirectory: instanceRoot,\n\t\t\t\tlockTimeoutMs: options.persistenceLockTimeoutMs,\n\t\t\t})\n\t\t: undefined;\n\tconst records = new Map<string, InstalledRecordV1>();\n\tconst activeByKey = new Map<string, string>();\n\tif (persistence !== undefined) {\n\t\tfor (const record of await persistence.load()) records.set(record.installationRef, { ...record });\n\t}\n\tfor (const record of records.values()) {\n\t\tif (record.state === \"active\")\n\t\t\tactiveByKey.set(installationKey(record.scope, record.scopeRef, record.pluginId), record.installationRef);\n\t}\n\tlet closed = false;\n\tconst activeOperations = new Set<AbortController>();\n\tconst runtimeHandles = new Map<string, { readonly dispose?: () => void | Promise<void> }>();\n\t// Activation serialization: NodePackageInstallHostV1 is a public API and\n\t// third-party callers may activate the same installation key concurrently.\n\t// Two interleaved activations can both pass the state guard and overwrite\n\t// each other's runtimeHandles entry — the losing dispose stops its own\n\t// handle while the ledger still reads \"active\", silently leaking the\n\t// surviving runtime, because the persistence layer only serializes\n\t// commits and not this in-memory path. Each activation chains onto the\n\t// previous one for its key, preserving the existing success semantics: a\n\t// queued activation starts only after the previous one settles and is\n\t// then rejected by the state guard like any sequential re-activation.\n\t// rollback/uninstall stay unchained; their interleavings with activate\n\t// are tolerated by the persistence snapshot and the ENOENT handling in\n\t// uninstall.\n\tconst activationChains = new Map<string, Promise<void>>();\n\tconst applyPersistentSnapshot = (snapshot: readonly NodePackageInstallPersistentRecordV1[]): void => {\n\t\trecords.clear();\n\t\tactiveByKey.clear();\n\t\tfor (const value of snapshot) records.set(value.installationRef, { ...value });\n\t\tfor (const value of records.values()) {\n\t\t\tif (value.state === \"active\")\n\t\t\t\tactiveByKey.set(installationKey(value.scope, value.scopeRef, value.pluginId), value.installationRef);\n\t\t}\n\t};\n\tconst commitRecords = async (\n\t\tupdate: (values: Map<string, NodePackageInstallPersistentRecordV1>) => void | Promise<void>,\n\t): Promise<void> => {\n\t\tif (persistence === undefined) {\n\t\t\tawait update(records);\n\t\t\treturn;\n\t\t}\n\t\tapplyPersistentSnapshot(await persistence.mutate({ update }));\n\t};\n\tlet drained: (() => void) | undefined;\n\tlet closePromise: Promise<void> | undefined;\n\n\tconst begin = (\n\t\tparentSignal: AbortSignal | undefined,\n\t): { readonly controller: AbortController; readonly signal: AbortSignal } => {\n\t\tif (closed) throw new NodePackageInstallErrorV1(\"host_closed\");\n\t\tconst controller = new AbortController();\n\t\tif (parentSignal?.aborted) controller.abort(parentSignal.reason);\n\t\telse parentSignal?.addEventListener(\"abort\", () => controller.abort(parentSignal.reason), { once: true });\n\t\tactiveOperations.add(controller);\n\t\treturn { controller, signal: controller.signal };\n\t};\n\tconst end = (controller: AbortController): void => {\n\t\tactiveOperations.delete(controller);\n\t\tif (activeOperations.size === 0) {\n\t\t\tdrained?.();\n\t\t\tdrained = undefined;\n\t\t}\n\t};\n\tconst waitDrained = async (): Promise<void> => {\n\t\tif (activeOperations.size === 0) return;\n\t\tawait new Promise<void>((resolve) => {\n\t\t\tdrained = resolve;\n\t\t});\n\t};\n\tconst getRecord = (\n\t\tinstallation: PluginInstallationV1,\n\t\trecord: PluginUpdateRecordV1,\n\t\tscope: PluginInstallationScopeV1,\n\t\tscopeRef: string,\n\t): InstalledRecordV1 => {\n\t\tconst value = records.get(installation.installationRef);\n\t\tif (\n\t\t\tvalue === undefined ||\n\t\t\tinstallation.pluginId !== record.pluginId ||\n\t\t\tinstallation.pluginVersion !== record.pluginVersion ||\n\t\t\tinstallation.manifestDigest !== record.manifestDigest ||\n\t\t\tinstallation.scope !== scope ||\n\t\t\tinstallation.scopeRef !== scopeRef ||\n\t\t\t!identityMatches(value, {\n\t\t\t\tpluginId: record.pluginId,\n\t\t\t\tpluginVersion: record.pluginVersion,\n\t\t\t\tmanifestDigest: record.manifestDigest,\n\t\t\t\tscope,\n\t\t\t\tscopeRef,\n\t\t\t})\n\t\t)\n\t\t\tthrow new NodePackageInstallErrorV1(\"installation_identity_mismatch\");\n\t\treturn value;\n\t};\n\tconst disposeRuntime = async (installationRef: string): Promise<void> => {\n\t\tconst handle = runtimeHandles.get(installationRef);\n\t\tif (handle === undefined) return;\n\t\tif (handle.dispose !== undefined) await Promise.resolve(handle.dispose());\n\t\truntimeHandles.delete(installationRef);\n\t};\n\t// A dispose that throws keeps its entry in runtimeHandles (disposeRuntime\n\t// deletes only after a successful dispose), so re-registering the same\n\t// installation ref must not silently overwrite the stale leftover: the\n\t// combined handle releases the new runtime first and the stale one in\n\t// `finally`, so a failure on either side still reclaims the other.\n\tconst registerRuntimeHandle = (\n\t\tinstallationRef: string,\n\t\thandle: { readonly dispose?: () => void | Promise<void> },\n\t): void => {\n\t\tconst existing = runtimeHandles.get(installationRef);\n\t\tif (existing === undefined) {\n\t\t\truntimeHandles.set(installationRef, handle);\n\t\t\treturn;\n\t\t}\n\t\truntimeHandles.set(installationRef, {\n\t\t\tdispose: async () => {\n\t\t\t\ttry {\n\t\t\t\t\tawait Promise.resolve(handle.dispose?.());\n\t\t\t\t} finally {\n\t\t\t\t\tawait Promise.resolve(existing.dispose?.());\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\t};\n\tconst loadRuntime = async (\n\t\tinstallation: PluginInstallationV1,\n\t\trecord: PluginUpdateRecordV1 | undefined,\n\t\tdirectory: string,\n\t\tsignal: AbortSignal,\n\t): Promise<{ readonly dispose?: () => void | Promise<void> } | undefined> => {\n\t\tif (options.loadPlugin === undefined) return undefined;\n\t\ttry {\n\t\t\tconst loaded = await options.loadPlugin({\n\t\t\t\tinstallation,\n\t\t\t\trecord,\n\t\t\t\tdirectory,\n\t\t\t\tmanifestPath: join(directory, CAPABILITY_MANIFEST_FILE_V1),\n\t\t\t\tsignal,\n\t\t\t});\n\t\t\treturn loaded ?? undefined;\n\t\t} catch (error) {\n\t\t\tif (error instanceof NodePackageInstallErrorV1) throw error;\n\t\t\tthrow new NodePackageInstallErrorV1(\"installation_io_failed\");\n\t\t}\n\t};\n\n\tconst host: NodePackageInstallHostV1 = {\n\t\tversion: NODE_PACKAGE_INSTALL_HOST_VERSION_V1,\n\t\tsupportedScopes: Object.freeze([...supportedScopes]),\n\t\tgetInstallationDirectory(input) {\n\t\t\tconst record = records.get(input.installation.installationRef);\n\t\t\tif (\n\t\t\t\trecord === undefined ||\n\t\t\t\trecord.pluginId !== input.installation.pluginId ||\n\t\t\t\trecord.pluginVersion !== input.installation.pluginVersion ||\n\t\t\t\trecord.manifestDigest !== input.installation.manifestDigest ||\n\t\t\t\trecord.scope !== input.installation.scope ||\n\t\t\t\trecord.scopeRef !== input.installation.scopeRef\n\t\t\t)\n\t\t\t\tthrow new NodePackageInstallErrorV1(\"installation_unknown\");\n\t\t\treturn record.directory;\n\t\t},\n\t\tasync install(input) {\n\t\t\tconst operation = begin(input.signal);\n\t\t\tlet staging: string | undefined;\n\t\t\ttry {\n\t\t\t\tif (input.artifact === undefined) throw new NodePackageInstallErrorV1(\"invalid_artifact\");\n\t\t\t\tif (!artifactIdentityMatchesRecord(input.artifact, input.record))\n\t\t\t\t\tthrow new NodePackageInstallErrorV1(\"invalid_artifact\");\n\t\t\t\tconst mediaType = input.artifact.mediaType.toLowerCase();\n\t\t\t\tif (mediaType !== \"application/zip\" && mediaType !== \"application/gzip\")\n\t\t\t\t\tthrow new NodePackageInstallErrorV1(\"unsupported_media_type\");\n\t\t\t\tconst scopeRef = opaqueScope(input.scopeRef);\n\t\t\t\tconst bytes = await collectArtifact(\n\t\t\t\t\toptions.openArtifact,\n\t\t\t\t\tinput.artifact,\n\t\t\t\t\tlimits.maxArchiveBytes,\n\t\t\t\t\toperation.signal,\n\t\t\t\t);\n\t\t\t\tif (input.artifact.sizeBytes !== bytes.byteLength) throw new NodePackageInstallErrorV1(\"invalid_artifact\");\n\t\t\t\tconst digest = expectedArtifactDigest(input.artifact.artifactDigest);\n\t\t\t\tif (createHash(digest.algorithm).update(bytes).digest(\"hex\") !== digest.hex)\n\t\t\t\t\tthrow new NodePackageInstallErrorV1(\"invalid_artifact\");\n\t\t\t\tconst entries =\n\t\t\t\t\tmediaType === \"application/gzip\"\n\t\t\t\t\t\t? await parseNodeTarGzPackageV1(bytes, limits)\n\t\t\t\t\t\t: parseNodeZipPackageV1(bytes, limits);\n\t\t\t\tconst manifestEntry = entries.find(\n\t\t\t\t\t(entry) => entry.name === ECOSYSTEM_MANIFEST_FILE_V1 && !entry.directory,\n\t\t\t\t);\n\t\t\t\tif (manifestEntry === undefined) throw new NodePackageInstallErrorV1(\"package_manifest_missing\");\n\t\t\t\tif (manifestEntry.bytes.byteLength > MAX_PACKAGE_MANIFEST_BYTES_V1)\n\t\t\t\t\tthrow new NodePackageInstallErrorV1(\"package_manifest_invalid\");\n\t\t\t\tlet manifest: unknown;\n\t\t\t\ttry {\n\t\t\t\t\tmanifest = JSON.parse(new TextDecoder(\"utf-8\", { fatal: true }).decode(manifestEntry.bytes));\n\t\t\t\t} catch {\n\t\t\t\t\tthrow new NodePackageInstallErrorV1(\"package_manifest_invalid\");\n\t\t\t\t}\n\t\t\t\tpackageManifest(manifest, input.record);\n\t\t\t\tconst capabilityEntry = entries.find(\n\t\t\t\t\t(entry) => entry.name === CAPABILITY_MANIFEST_FILE_V1 && !entry.directory,\n\t\t\t\t);\n\t\t\t\tif (capabilityEntry === undefined) throw new NodePackageInstallErrorV1(\"package_manifest_missing\");\n\t\t\t\tif (capabilityEntry.bytes.byteLength > MAX_PACKAGE_MANIFEST_BYTES_V1)\n\t\t\t\t\tthrow new NodePackageInstallErrorV1(\"package_manifest_invalid\");\n\t\t\t\tlet capability: unknown;\n\t\t\t\ttry {\n\t\t\t\t\tcapability = JSON.parse(new TextDecoder(\"utf-8\", { fatal: true }).decode(capabilityEntry.bytes));\n\t\t\t\t} catch {\n\t\t\t\t\tthrow new NodePackageInstallErrorV1(\"package_manifest_invalid\");\n\t\t\t\t}\n\t\t\t\tcapabilityManifest(capability, input.record, entries);\n\t\t\t\tconst key = installationKey(input.scope, scopeRef, input.record.pluginId);\n\t\t\t\tstaging = join(instanceRoot, `.staging-${randomUUID()}`);\n\t\t\t\tawait writeEntries(staging, entries, operation.signal);\n\t\t\t\t// Materialize declared runtime dependencies while staging is\n\t\t\t\t// still private; a failure throws before the rename, so no\n\t\t\t\t// half-installed copy ever reaches the store.\n\t\t\t\tif (options.dependencyMaterialization !== \"skip\") {\n\t\t\t\t\tawait installStagingRuntimeDependencies(staging, entries, operation.signal);\n\t\t\t\t}\n\t\t\t\tconst installRef = `plugin-install://node-zip/${randomUUID()}`;\n\t\t\t\tconst destination = packagePath(instanceRoot, `${key}\\u0000${installRef}`);\n\t\t\t\tawait rename(staging, destination);\n\t\t\t\tstaging = undefined;\n\t\t\t\tconst installedRecord: InstalledRecordV1 = {\n\t\t\t\t\tinstallationRef: installRef,\n\t\t\t\t\tdirectory: destination,\n\t\t\t\t\tpluginId: input.record.pluginId,\n\t\t\t\t\tpluginVersion: input.record.pluginVersion,\n\t\t\t\t\tmanifestDigest: input.record.manifestDigest,\n\t\t\t\t\tscope: input.scope,\n\t\t\t\t\tscopeRef,\n\t\t\t\t\tstate: \"installed\",\n\t\t\t\t};\n\t\t\t\ttry {\n\t\t\t\t\tawait commitRecords((values) => {\n\t\t\t\t\t\tvalues.set(installRef, installedRecord);\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\tawait rm(destination, { recursive: true, force: true }).catch(() => undefined);\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t\treturn { installationRef: installRef, scope: input.scope, scopeRef };\n\t\t\t} catch (error) {\n\t\t\t\tif (operation.signal.aborted || input.signal?.aborted) throw new NodePackageInstallErrorV1(\"cancelled\");\n\t\t\t\tif (error instanceof NodePackageInstallErrorV1) throw error;\n\t\t\t\tthrow new NodePackageInstallErrorV1(\"installation_io_failed\");\n\t\t\t} finally {\n\t\t\t\tif (staging !== undefined) await rm(staging, { recursive: true, force: true }).catch(() => undefined);\n\t\t\t\tend(operation.controller);\n\t\t\t}\n\t\t},\n\t\tasync activate(input) {\n\t\t\t// Validate before queueing: a malformed request fails at call time\n\t\t\t// instead of waiting behind pending activations.\n\t\t\tconst key = installationKey(input.scope, opaqueScope(input.scopeRef), input.record.pluginId);\n\t\t\tconst activateBody = async (): Promise<void> => {\n\t\t\t\tconst operation = begin(input.signal);\n\t\t\t\tlet candidate: { readonly dispose?: () => void | Promise<void> } | undefined;\n\t\t\t\ttry {\n\t\t\t\t\tconst scopeRef = opaqueScope(input.scopeRef);\n\t\t\t\t\tconst record = getRecord(input.installation, input.record, input.scope, scopeRef);\n\t\t\t\t\tif (record.state !== \"installed\") throw new NodePackageInstallErrorV1(\"installation_identity_mismatch\");\n\t\t\t\t\tcandidate = await loadRuntime(input.installation, input.record, record.directory, operation.signal);\n\t\t\t\t\tconst previousRef = activeByKey.get(key);\n\t\t\t\t\t// Commit the persisted ledger before stopping the previous\n\t\t\t\t\t// runtime: if the commit fails, the old runtime is still\n\t\t\t\t\t// running and still matches the ledger, so the caller can\n\t\t\t\t\t// retry or roll back from a consistent state. Between the\n\t\t\t\t\t// commit and the dispose below the old and new runtimes\n\t\t\t\t\t// coexist briefly — the previous plugin keeps serving until\n\t\t\t\t\t// it is replaced here, which is the correct activation\n\t\t\t\t\t// window. The new handle is registered before the old\n\t\t\t\t\t// runtime is disposed, so even if disposeRuntime propagates\n\t\t\t\t\t// a failing old-runtime dispose, the committed new version\n\t\t\t\t\t// stays live and the error surfaces through the catch below.\n\t\t\t\t\tawait commitRecords((values) => {\n\t\t\t\t\t\tconst candidateRecord = values.get(input.installation.installationRef);\n\t\t\t\t\t\tif (candidateRecord === undefined)\n\t\t\t\t\t\t\tthrow new NodePackageInstallErrorV1(\"installation_identity_mismatch\");\n\t\t\t\t\t\tif (previousRef !== undefined) {\n\t\t\t\t\t\t\tconst previousRecord = values.get(previousRef);\n\t\t\t\t\t\t\tif (previousRecord !== undefined)\n\t\t\t\t\t\t\t\tvalues.set(previousRef, { ...previousRecord, state: \"retained\" });\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvalues.set(input.installation.installationRef, { ...candidateRecord, state: \"active\" });\n\t\t\t\t\t});\n\t\t\t\t\tactiveByKey.set(key, input.installation.installationRef);\n\t\t\t\t\tif (candidate !== undefined) registerRuntimeHandle(input.installation.installationRef, candidate);\n\t\t\t\t\tcandidate = undefined;\n\t\t\t\t\tif (previousRef !== undefined) {\n\t\t\t\t\t\tconst previous = records.get(previousRef);\n\t\t\t\t\t\tif (previous !== undefined) {\n\t\t\t\t\t\t\tawait disposeRuntime(previousRef);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (candidate?.dispose !== undefined) await Promise.resolve(candidate.dispose()).catch(() => undefined);\n\t\t\t\t\tif (error instanceof NodePackageInstallErrorV1) throw error;\n\t\t\t\t\tthrow new NodePackageInstallErrorV1(\"installation_io_failed\");\n\t\t\t\t} finally {\n\t\t\t\t\tend(operation.controller);\n\t\t\t\t}\n\t\t\t};\n\t\t\t// Chain onto the previous activation for this key; the queued body\n\t\t\t// runs only after it settles, whatever its outcome.\n\t\t\tconst queued = activationChains.get(key) ?? Promise.resolve();\n\t\t\tconst run = queued.catch(() => undefined).then(() => activateBody());\n\t\t\tactivationChains.set(key, run);\n\t\t\ttry {\n\t\t\t\tawait run;\n\t\t\t} finally {\n\t\t\t\t// Drop the chain entry only while it is still the newest run, so\n\t\t\t\t// a queued successor keeps later arrivals chained onto it.\n\t\t\t\tif (activationChains.get(key) === run) activationChains.delete(key);\n\t\t\t}\n\t\t},\n\t\tasync rollback(input) {\n\t\t\tconst operation = begin(input.signal);\n\t\t\tlet candidate: { readonly dispose?: () => void | Promise<void> } | undefined;\n\t\t\ttry {\n\t\t\t\tconst scopeRef = opaqueScope(input.scopeRef);\n\t\t\t\tconst failed = records.get(input.failed.installationRef);\n\t\t\t\tif (\n\t\t\t\t\tfailed === undefined ||\n\t\t\t\t\t!identityMatches(failed, {\n\t\t\t\t\t\tpluginId: input.failed.pluginId,\n\t\t\t\t\t\tpluginVersion: input.failed.pluginVersion,\n\t\t\t\t\t\tmanifestDigest: input.failed.manifestDigest,\n\t\t\t\t\t\tscope: input.scope,\n\t\t\t\t\t\tscopeRef,\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t\t\t\tthrow new NodePackageInstallErrorV1(\"installation_identity_mismatch\");\n\t\t\t\tconst previous = records.get(input.previous.installationRef);\n\t\t\t\tif (\n\t\t\t\t\tprevious === undefined ||\n\t\t\t\t\t!identityMatches(previous, {\n\t\t\t\t\t\tpluginId: input.previous.pluginId,\n\t\t\t\t\t\tpluginVersion: input.previous.pluginVersion,\n\t\t\t\t\t\tmanifestDigest: input.previous.manifestDigest,\n\t\t\t\t\t\tscope: input.scope,\n\t\t\t\t\t\tscopeRef,\n\t\t\t\t\t}) ||\n\t\t\t\t\t(previous.state !== \"active\" && previous.state !== \"retained\") ||\n\t\t\t\t\tfailed.pluginId !== previous.pluginId\n\t\t\t\t)\n\t\t\t\t\tthrow new NodePackageInstallErrorV1(\"installation_identity_mismatch\");\n\t\t\t\tconst previousInstallation: PluginInstallationV1 = {\n\t\t\t\t\tversion: 1,\n\t\t\t\t\tpluginId: previous.pluginId,\n\t\t\t\t\tpluginVersion: previous.pluginVersion,\n\t\t\t\t\tmanifestDigest: previous.manifestDigest,\n\t\t\t\t\tscope: previous.scope,\n\t\t\t\t\tscopeRef: previous.scopeRef,\n\t\t\t\t\tinstallationRef: input.previous.installationRef,\n\t\t\t\t\tstate: \"active\",\n\t\t\t\t};\n\t\t\t\tcandidate = await loadRuntime(previousInstallation, undefined, previous.directory, operation.signal);\n\t\t\t\tawait disposeRuntime(input.failed.installationRef);\n\t\t\t\tawait rm(failed.directory, { recursive: true, force: true });\n\t\t\t\tawait commitRecords((values) => {\n\t\t\t\t\tvalues.delete(input.failed.installationRef);\n\t\t\t\t\tconst previousRecord = values.get(input.previous.installationRef);\n\t\t\t\t\tif (previousRecord !== undefined)\n\t\t\t\t\t\tvalues.set(input.previous.installationRef, { ...previousRecord, state: \"active\" });\n\t\t\t\t});\n\t\t\t\tactiveByKey.set(installationKey(input.scope, scopeRef, failed.pluginId), input.previous.installationRef);\n\t\t\t\tif (candidate !== undefined) registerRuntimeHandle(input.previous.installationRef, candidate);\n\t\t\t\tcandidate = undefined;\n\t\t\t} catch (error) {\n\t\t\t\tif (candidate?.dispose !== undefined) await Promise.resolve(candidate.dispose()).catch(() => undefined);\n\t\t\t\tif (error instanceof NodePackageInstallErrorV1) throw error;\n\t\t\t\tthrow new NodePackageInstallErrorV1(\"installation_io_failed\");\n\t\t\t} finally {\n\t\t\t\tend(operation.controller);\n\t\t\t}\n\t\t},\n\t\tasync uninstall(input) {\n\t\t\tconst operation = begin(input.signal);\n\t\t\ttry {\n\t\t\t\tconst scopeRef = opaqueScope(input.scopeRef);\n\t\t\t\tconst record = records.get(input.installation.installationRef);\n\t\t\t\tif (\n\t\t\t\t\trecord === undefined ||\n\t\t\t\t\t!identityMatches(record, {\n\t\t\t\t\t\tpluginId: input.installation.pluginId,\n\t\t\t\t\t\tpluginVersion: input.installation.pluginVersion,\n\t\t\t\t\t\tmanifestDigest: input.installation.manifestDigest,\n\t\t\t\t\t\tscope: input.scope,\n\t\t\t\t\t\tscopeRef,\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t\t\t\tthrow new NodePackageInstallErrorV1(\"installation_unknown\");\n\t\t\t\tawait disposeRuntime(input.installation.installationRef);\n\t\t\t\t// force:false keeps rm strict, but a directory that is already\n\t\t\t\t// gone (ghost record from an interrupted uninstall) is the\n\t\t\t\t// desired end state — continue to the index commit instead of\n\t\t\t\t// bricking every later store operation on ENOENT.\n\t\t\t\tawait rm(record.directory, { recursive: true, force: false }).catch((error: unknown) => {\n\t\t\t\t\tif ((error as NodeJS.ErrnoException).code === \"ENOENT\") return;\n\t\t\t\t\tthrow error;\n\t\t\t\t});\n\t\t\t\tawait commitRecords((values) => {\n\t\t\t\t\tvalues.delete(input.installation.installationRef);\n\t\t\t\t});\n\t\t\t\tconst key = installationKey(input.scope, scopeRef, record.pluginId);\n\t\t\t\tif (activeByKey.get(key) === input.installation.installationRef) activeByKey.delete(key);\n\t\t\t} finally {\n\t\t\t\tend(operation.controller);\n\t\t\t}\n\t\t},\n\t\tasync close() {\n\t\t\tif (closePromise !== undefined) return await closePromise;\n\t\t\tclosed = true;\n\t\t\tfor (const operation of activeOperations) operation.abort();\n\t\t\tclosePromise = (async () => {\n\t\t\t\tawait waitDrained();\n\t\t\t\tlet disposeError = false;\n\t\t\t\tfor (const installationRef of runtimeHandles.keys()) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait disposeRuntime(installationRef);\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tdisposeError = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (persistence === undefined) await rm(instanceRoot, { recursive: true, force: true });\n\t\t\t\telse await persistence.close();\n\t\t\t\trecords.clear();\n\t\t\t\tactiveByKey.clear();\n\t\t\t\tif (disposeError) throw new NodePackageInstallErrorV1(\"installation_io_failed\");\n\t\t\t})();\n\t\t\treturn await closePromise;\n\t\t},\n\t};\n\tif (options.loadPlugin !== undefined) {\n\t\ttry {\n\t\t\tfor (const record of records.values()) {\n\t\t\t\tif (record.state !== \"active\") continue;\n\t\t\t\tconst installation: PluginInstallationV1 = {\n\t\t\t\t\tversion: 1,\n\t\t\t\t\tpluginId: record.pluginId,\n\t\t\t\t\tpluginVersion: record.pluginVersion,\n\t\t\t\t\tmanifestDigest: record.manifestDigest,\n\t\t\t\t\tscope: record.scope,\n\t\t\t\t\tscopeRef: record.scopeRef,\n\t\t\t\t\tinstallationRef: record.installationRef,\n\t\t\t\t\tstate: \"active\",\n\t\t\t\t};\n\t\t\t\tconst runtime = await loadRuntime(installation, undefined, record.directory, new AbortController().signal);\n\t\t\t\tif (runtime !== undefined) runtimeHandles.set(record.installationRef, runtime);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tawait host.close().catch(() => undefined);\n\t\t\tif (error instanceof NodePackageInstallErrorV1) throw error;\n\t\t\tthrow new NodePackageInstallErrorV1(\"installation_io_failed\");\n\t\t}\n\t}\n\treturn host;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-plugin-bootstrap.d.ts","sourceRoot":"","sources":["../../../src/plugins/ecosystem/node-plugin-bootstrap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AASrF,OAAO,EAGN,KAAK,sBAAsB,EAC3B,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACN,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAE5B,MAAM,uBAAuB,CAAC;AAG/B,6EAA6E;AAC7E,eAAO,MAAM,mCAAmC,iCAAiC,CAAC;AAKlF,MAAM,WAAW,4BAA4B;IAC5C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,+CAA+C;IAC/C,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,6BAA6B,EAAE,CAAC;IAC7D,2EAA2E;IAC3E,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,sBAAsB,CAAC;IACzC,iDAAiD;IACjD,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IACzC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B,sFAAsF;IACtF,QAAQ,CAAC,IAAI,CAAC,EAAE,qBAAqB,CAAC;IACtC,0EAA0E;IAC1E,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACrD;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,uBAAuB,KAAK,IAAI,CAAC;CAC9D;AAED,MAAM,MAAM,2BAA2B,GAAG,uBAAuB,GAAG;IACnE;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;CAC1C,CAAC;AAqCF;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAC7C,OAAO,EAAE,4BAA4B,GACnC,OAAO,CAAC,2BAA2B,CAAC,CAuPtC","sourcesContent":["/**\n * Node wiring for the startup plugin bootstrap (design\n * `插件独立分发与启动装配设计.md` §4.4, §0.7).\n *\n * `AGENT_FORGE_PLUGIN_BOOTSTRAP=off` skips everything, including the local\n * comparison. The comparison dependency reads the global and project\n * plugin-state.json stores only — read-only, and it never constructs an HTTP\n * client, so an assembled environment starts offline (G3). Network objects\n * (npm acquisition host, install host) are built lazily inside the install\n * action and closed when the bootstrap finishes. Installs go through the\n * npm acquisition path exclusively and persist the `npm:<host>` source label\n * in the global plugin state (same prepare/install/activate/upsert\n * transaction shape as the CLI install flow, implemented as a library\n * function without going through the CLI layer).\n */\n\nimport { join } from \"node:path\";\nimport { CONFIG_DIR_NAME } from \"../../config.ts\";\nimport { t } from \"../../core/i18n/index.ts\";\nimport { isOfflineModeEnabled } from \"../../core/package-process-runner.ts\";\nimport type { PluginBootstrapFactoryEntryV1 } from \"./bootstrap-factory-manifest.ts\";\nimport { BOOTSTRAP_FACTORY_PLUGIN_MANIFEST_V1 } from \"./bootstrap-factory-manifest.ts\";\nimport {\n\tDEFAULT_PLUGIN_STATE_FILE_V1,\n\tdefaultPluginHostFactsV1,\n\tdefaultPluginInstallStoreDirectoryV1,\n\tprojectPluginScopeRefV1,\n} from \"./default-active-bindings.ts\";\nimport { createPluginInstallerV1, DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1, type PluginInstallerV1 } from \"./installer.ts\";\nimport {\n\tcreateNodePackageInstallHostV1,\n\ttype NodePackageInstallHostV1,\n\ttype NodeZipPackageLimitsV1,\n} from \"./node-package-install-host.ts\";\nimport { createNodePluginAcquisitionHostV1, type NodePluginAcquisitionHostV1 } from \"./node-plugin-acquisition-host.ts\";\nimport {\n\ttype PluginBootstrapActionV1,\n\ttype PluginBootstrapDepsV1,\n\ttype PluginBootstrapResultV1,\n\trunPluginBootstrapV1,\n} from \"./plugin-bootstrap.ts\";\nimport { createPluginStateStoreV1, type PluginStateStoreV1 } from \"./state.ts\";\n\n/** Environment variable disabling the startup bootstrap entirely (`off`). */\nexport const AGENT_FORGE_PLUGIN_BOOTSTRAP_ENV_V1 = \"AGENT_FORGE_PLUGIN_BOOTSTRAP\";\n\n/** The only recognized disabling value; every other value (and absence) keeps bootstrap on. */\nconst PLUGIN_BOOTSTRAP_DISABLED_VALUE_V1 = \"off\";\n\nexport interface NodePluginBootstrapOptionsV1 {\n\treadonly agentDir: string;\n\treadonly cwd: string;\n\t/** Defaults to the frozen factory manifest. */\n\treadonly manifest?: readonly PluginBootstrapFactoryEntryV1[];\n\t/** Bare http(s) npm registry origin; forwarded to the acquisition host. */\n\treadonly npmRegistry?: string;\n\t/** npm registry bearer token; forwarded to the acquisition host. */\n\treadonly npmToken?: string;\n\treadonly limits?: NodeZipPackageLimitsV1;\n\t/** Deterministic fetch replacement for tests. */\n\treadonly fetch?: typeof globalThis.fetch;\n\treadonly signal?: AbortSignal;\n\t/** Full dependency override for deterministic tests; the env switch still applies. */\n\treadonly deps?: PluginBootstrapDepsV1;\n\t/** Overrides the first-run progress line (stderr) for tests and hosts. */\n\treadonly onPendingInstalls?: (count: number) => void;\n\t/**\n\t * Overrides the per-plugin progress renderer (stderr) for tests and hosts.\n\t * The default prints one line per installed/aligned/failed entry and stays\n\t * silent for satisfied entries.\n\t */\n\treadonly onAction?: (action: PluginBootstrapActionV1) => void;\n}\n\nexport type NodePluginBootstrapResultV1 = PluginBootstrapResultV1 & {\n\t/**\n\t * Present when a posture switch short-circuited the run before any local\n\t * comparison: the wiring-level env off switch, or the offline posture\n\t * (设计 §4.4 offline 姿态门, 2026-10-03 — offline installs cannot succeed\n\t * and would only fail slowly, so the run is skipped immediately).\n\t */\n\treadonly skipped?: \"disabled\" | \"offline\";\n};\n\n/** Install-scoped boundaries; created lazily by the first install action. */\ninterface InstallSessionV1 {\n\treadonly acquisition: NodePluginAcquisitionHostV1;\n\treadonly installHost: NodePackageInstallHostV1;\n\treadonly installer: PluginInstallerV1;\n\treadonly stateStore: PluginStateStoreV1;\n}\n\nfunction readActiveVersions(\n\tstore: PluginStateStoreV1,\n\tscope: \"global\" | \"project\",\n\tscopeRef: string,\n\tsignal: AbortSignal | undefined,\n): Promise<ReadonlyMap<string, string>> {\n\treturn (async () => {\n\t\tconst result = await store.read({ ...(signal === undefined ? {} : { signal }) });\n\t\tif (result.status !== \"ok\" && result.status !== \"missing\")\n\t\t\tthrow new Error(\n\t\t\t\tt(\"plugin state read failed ({detail}) for the {scope} scope\", {\n\t\t\t\t\tdetail: result.diagnostics[0]?.code ?? result.status,\n\t\t\t\t\tscope,\n\t\t\t\t}),\n\t\t\t);\n\t\tconst versions = new Map<string, string>();\n\t\tfor (const record of result.snapshot.records) {\n\t\t\tif (record.state.scope !== scope || record.state.scopeRef !== scopeRef) continue;\n\t\t\t// Enabled is deliberately not filtered: a disabled plugin still owns\n\t\t\t// its active installation record, and bootstrap never touches it (G5).\n\t\t\tif (record.state.lifecycle !== \"active\") continue;\n\t\t\tversions.set(record.pluginId, record.pluginVersion);\n\t\t}\n\t\treturn versions;\n\t})();\n}\n\n/**\n * Run the startup bootstrap for one agent directory. The function resolves\n * with a structured result and never throws for per-plugin failures; only a\n * wiring-level construction error propagates to the caller (main.ts guards\n * startup with its own catch).\n */\nexport async function runNodePluginBootstrapV1(\n\toptions: NodePluginBootstrapOptionsV1,\n): Promise<NodePluginBootstrapResultV1> {\n\tif (process.env[AGENT_FORGE_PLUGIN_BOOTSTRAP_ENV_V1]?.trim() === PLUGIN_BOOTSTRAP_DISABLED_VALUE_V1) {\n\t\treturn Object.freeze({\n\t\t\tversion: 1,\n\t\t\tstatus: \"succeeded\",\n\t\t\tactions: Object.freeze([]),\n\t\t\tdiagnostics: Object.freeze([]),\n\t\t\tdurationMs: 0,\n\t\t\tskipped: \"disabled\",\n\t\t});\n\t}\n\tif (isOfflineModeEnabled()) {\n\t\treturn Object.freeze({\n\t\t\tversion: 1,\n\t\t\tstatus: \"succeeded\",\n\t\t\tactions: Object.freeze([]),\n\t\t\tdiagnostics: Object.freeze([\n\t\t\t\t{\n\t\t\t\t\tcode: \"bootstrap_skipped_offline\",\n\t\t\t\t\tmessage: t(\n\t\t\t\t\t\t\"Offline posture (AGENT_FORGE_OFFLINE) skips the startup plugin bootstrap; run `agent-forge plugin install <package>` explicitly to install plugins.\",\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t] as const),\n\t\t\tdurationMs: 0,\n\t\t\tskipped: \"offline\",\n\t\t});\n\t}\n\tif (options.deps !== undefined) {\n\t\treturn await runPluginBootstrapV1({\n\t\t\tmanifest: options.manifest ?? BOOTSTRAP_FACTORY_PLUGIN_MANIFEST_V1,\n\t\t\tdeps: options.deps,\n\t\t\t...(options.onPendingInstalls === undefined ? {} : { onPendingInstalls: options.onPendingInstalls }),\n\t\t\t...(options.onAction === undefined ? {} : { onAction: options.onAction }),\n\t\t});\n\t}\n\tlet session: InstallSessionV1 | undefined;\n\tconst ensureSession = async (): Promise<InstallSessionV1> => {\n\t\tif (session !== undefined) return session;\n\t\tconst acquisition = createNodePluginAcquisitionHostV1({\n\t\t\t...(options.npmRegistry === undefined ? {} : { npmRegistry: options.npmRegistry }),\n\t\t\t...(options.npmToken === undefined ? {} : { npmToken: options.npmToken }),\n\t\t\t...(options.fetch === undefined ? {} : { fetch: options.fetch }),\n\t\t\t...(options.limits === undefined ? {} : { limits: options.limits }),\n\t\t});\n\t\tconst installHost = await createNodePackageInstallHostV1({\n\t\t\topenArtifact: (input) => acquisition.openArtifact(input),\n\t\t\tinstallationDirectory: defaultPluginInstallStoreDirectoryV1(options.agentDir),\n\t\t\tpersistence: \"persistent\",\n\t\t\tsupportedScopes: [\"global\", \"project\"],\n\t\t\t...(options.limits === undefined ? {} : { ...options.limits }),\n\t\t});\n\t\tsession = {\n\t\t\tacquisition,\n\t\t\tinstallHost,\n\t\t\tinstaller: createPluginInstallerV1({ host: installHost }),\n\t\t\tstateStore: createPluginStateStoreV1({ filePath: join(options.agentDir, DEFAULT_PLUGIN_STATE_FILE_V1) }),\n\t\t};\n\t\treturn session;\n\t};\n\tconst deps: PluginBootstrapDepsV1 = {\n\t\tlistActive: async ({ signal }) => {\n\t\t\tconst globalVersions = readActiveVersions(\n\t\t\t\tcreatePluginStateStoreV1({ filePath: join(options.agentDir, DEFAULT_PLUGIN_STATE_FILE_V1) }),\n\t\t\t\t\"global\",\n\t\t\t\tDEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1,\n\t\t\t\tsignal,\n\t\t\t);\n\t\t\tconst projectVersions = readActiveVersions(\n\t\t\t\tcreatePluginStateStoreV1({ filePath: join(options.cwd, CONFIG_DIR_NAME, DEFAULT_PLUGIN_STATE_FILE_V1) }),\n\t\t\t\t\"project\",\n\t\t\t\tprojectPluginScopeRefV1(options.cwd),\n\t\t\t\tsignal,\n\t\t\t);\n\t\t\tconst [globalResult, projectResult] = await Promise.all([globalVersions, projectVersions]);\n\t\t\t// Project precedence mirrors active-binding resolution: a project\n\t\t\t// installation shadows the same plugin id from the global scope.\n\t\t\treturn new Map([...globalResult, ...projectResult]);\n\t\t},\n\t\tinstallFromNpm: async ({ npmName, range, signal }) => {\n\t\t\t// Download retry (设计 §4.4 下载重试, 2026-10-04): transient registry\n\t\t\t// failures retried with backoff at this wiring layer so the decision\n\t\t\t// loop stays pure. Abort propagates immediately between attempts.\n\t\t\tlet lastError: unknown;\n\t\t\tfor (let attempt = 1; attempt <= 3; attempt++) {\n\t\t\t\tif (signal?.aborted === true) throw lastError ?? new Error(\"install aborted\");\n\t\t\t\ttry {\n\t\t\t\t\treturn await installFromNpmOnce({ npmName, range, signal });\n\t\t\t\t} catch (error) {\n\t\t\t\t\tlastError = error;\n\t\t\t\t\t// Abort during the attempt surfaces as the attempt's own error;\n\t\t\t\t\t// the loop-top check and the backoff listener cover the pauses.\n\t\t\t\t\tif (attempt === 3) throw error;\n\t\t\t\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\t\t\t\tconst timer = setTimeout(resolve, 400 * 2 ** (attempt - 1));\n\t\t\t\t\t\tsignal?.addEventListener(\n\t\t\t\t\t\t\t\"abort\",\n\t\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\t\t\t\treject(lastError);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ once: true },\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 lastError;\n\t\t},\n\t\t...(options.signal === undefined ? {} : { signal: options.signal }),\n\t};\n\tconst installFromNpmOnce = async (input: {\n\t\treadonly npmName: string;\n\t\treadonly range?: string;\n\t\treadonly signal?: AbortSignal;\n\t}): Promise<{ readonly pluginVersion: string; readonly source: string }> => {\n\t\tconst { npmName, range, signal } = input;\n\t\t{\n\t\t\tconst active = await ensureSession();\n\t\t\t// npm refs only (§0.7): scoped or plain names with the shared minimal\n\t\t\t// range subset; no github/gitee/url/local ref can be expressed here.\n\t\t\tconst ref = range === undefined ? npmName : `${npmName}@${range}`;\n\t\t\tconst acquired = await active.acquisition.resolvePackage({ ref, ...(signal === undefined ? {} : { signal }) });\n\t\t\tlet released = false;\n\t\t\tconst release = async (): Promise<void> => {\n\t\t\t\tif (released) return;\n\t\t\t\treleased = true;\n\t\t\t\tawait acquired.release();\n\t\t\t};\n\t\t\ttry {\n\t\t\t\tconst verified = active.installer.prepare({\n\t\t\t\t\tmanifest: acquired.manifest,\n\t\t\t\t\tsource: acquired.source,\n\t\t\t\t\thost: defaultPluginHostFactsV1(),\n\t\t\t\t});\n\t\t\t\tif (verified.status !== \"verified\")\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\tt(\"installer prepare rejected {pluginId}: {reason}\", {\n\t\t\t\t\t\t\tpluginId: acquired.manifest.id,\n\t\t\t\t\t\t\treason: verified.reason,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\tconst installed = await active.installer.install({\n\t\t\t\t\trecord: verified.record,\n\t\t\t\t\tscope: \"global\",\n\t\t\t\t\tscopeRef: DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1,\n\t\t\t\t\tartifact: acquired.artifact,\n\t\t\t\t\t...(signal === undefined ? {} : { signal }),\n\t\t\t\t});\n\t\t\t\tif (installed.status !== \"succeeded\")\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\tt(\"plugin install failed ({code}) for {pluginId}\", {\n\t\t\t\t\t\t\tcode: installed.error.code,\n\t\t\t\t\t\t\tpluginId: acquired.manifest.id,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\tconst activated = await active.installer.activate({\n\t\t\t\t\tinstallation: installed.installation,\n\t\t\t\t\trecord: verified.record,\n\t\t\t\t\tscope: \"global\",\n\t\t\t\t\tscopeRef: DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1,\n\t\t\t\t\t...(signal === undefined ? {} : { signal }),\n\t\t\t\t});\n\t\t\t\tif (activated.status !== \"succeeded\") {\n\t\t\t\t\tawait active.installer\n\t\t\t\t\t\t.remove({\n\t\t\t\t\t\t\tinstallation: installed.installation,\n\t\t\t\t\t\t\tscope: \"global\",\n\t\t\t\t\t\t\tscopeRef: DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1,\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.catch(() => undefined);\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\tt(\"plugin activation failed ({code}) for {pluginId}\", {\n\t\t\t\t\t\t\tcode: activated.error.code,\n\t\t\t\t\t\t\tpluginId: acquired.manifest.id,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst persisted = await active.stateStore.upsert({\n\t\t\t\t\tinstallation: activated.installation,\n\t\t\t\t\tscope: \"global\",\n\t\t\t\t\tenabled: true,\n\t\t\t\t\tsource: acquired.source,\n\t\t\t\t\t...(signal === undefined ? {} : { signal }),\n\t\t\t\t});\n\t\t\t\tif (persisted.status !== \"ok\") {\n\t\t\t\t\tawait active.installer\n\t\t\t\t\t\t.remove({\n\t\t\t\t\t\t\tinstallation: activated.installation,\n\t\t\t\t\t\t\tscope: \"global\",\n\t\t\t\t\t\t\tscopeRef: DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1,\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.catch(() => undefined);\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\tt(\"plugin state persist failed ({status}) for {pluginId}\", {\n\t\t\t\t\t\t\tstatus: persisted.status,\n\t\t\t\t\t\t\tpluginId: acquired.manifest.id,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn { pluginVersion: activated.installation.pluginVersion, source: acquired.source };\n\t\t\t} finally {\n\t\t\t\tawait release();\n\t\t\t}\n\t\t}\n\t};\n\ttry {\n\t\treturn await runPluginBootstrapV1({\n\t\t\tmanifest: options.manifest ?? BOOTSTRAP_FACTORY_PLUGIN_MANIFEST_V1,\n\t\t\tdeps,\n\t\t\t// First-run progress line (设计 §4.4, 2026-10-03): a fresh install is\n\t\t\t// otherwise silent for the whole network install window.\n\t\t\tonPendingInstalls:\n\t\t\t\toptions.onPendingInstalls ??\n\t\t\t\t((count: number) => {\n\t\t\t\t\tconsole.error(t(\"First run: installing {count} factory plugins…\", { count }));\n\t\t\t\t}),\n\t\t\t// Per-plugin progress (设计 §4.4 逐插件进度, 2026-10-04): one stderr\n\t\t\t// line per installed/aligned/failed entry; satisfied entries stay\n\t\t\t// silent so an all-green startup prints nothing extra.\n\t\t\tonAction:\n\t\t\t\toptions.onAction ??\n\t\t\t\t((action: PluginBootstrapActionV1) => {\n\t\t\t\t\tif (action.status === \"installed\") {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\tt(\"{pluginId}: installed {version}\", {\n\t\t\t\t\t\t\t\tpluginId: action.pluginId,\n\t\t\t\t\t\t\t\tversion: action.installedVersion ?? \"\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\t\t} else if (action.status === \"failed\") {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\tt(\n\t\t\t\t\t\t\t\t\"{pluginId}: install failed ({code}) — startup continues; the next startup retries automatically\",\n\t\t\t\t\t\t\t\t{ pluginId: action.pluginId, code: action.errorCode ?? \"install_failed\" },\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t});\n\t} finally {\n\t\tconst active = session;\n\t\tsession = undefined;\n\t\tif (active !== undefined) {\n\t\t\tawait active.installHost.close().catch(() => undefined);\n\t\t\tawait active.acquisition.close().catch(() => undefined);\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"node-plugin-bootstrap.d.ts","sourceRoot":"","sources":["../../../src/plugins/ecosystem/node-plugin-bootstrap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AASrF,OAAO,EAGN,KAAK,sBAAsB,EAC3B,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACN,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAE5B,MAAM,uBAAuB,CAAC;AAG/B,6EAA6E;AAC7E,eAAO,MAAM,mCAAmC,iCAAiC,CAAC;AAKlF,MAAM,WAAW,4BAA4B;IAC5C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,+CAA+C;IAC/C,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,6BAA6B,EAAE,CAAC;IAC7D,2EAA2E;IAC3E,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,sBAAsB,CAAC;IACzC,iDAAiD;IACjD,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IACzC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B,sFAAsF;IACtF,QAAQ,CAAC,IAAI,CAAC,EAAE,qBAAqB,CAAC;IACtC,0EAA0E;IAC1E,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACrD;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,uBAAuB,KAAK,IAAI,CAAC;CAC9D;AAED,MAAM,MAAM,2BAA2B,GAAG,uBAAuB,GAAG;IACnE;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;CAC1C,CAAC;AAmEF;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAC7C,OAAO,EAAE,4BAA4B,GACnC,OAAO,CAAC,2BAA2B,CAAC,CA0RtC","sourcesContent":["/**\n * Node wiring for the startup plugin bootstrap (design\n * `插件独立分发与启动装配设计.md` §4.4, §0.7).\n *\n * `AGENT_FORGE_PLUGIN_BOOTSTRAP=off` skips everything, including the local\n * comparison. The comparison dependency reads the global and project\n * plugin-state.json stores only — read-only, and it never constructs an HTTP\n * client, so an assembled environment starts offline (G3). Network objects\n * (npm acquisition host, install host) are built lazily inside the install\n * action and closed when the bootstrap finishes. Installs go through the\n * npm acquisition path exclusively and persist the `npm:<host>` source label\n * in the global plugin state (same prepare/install/activate/upsert\n * transaction shape as the CLI install flow, implemented as a library\n * function without going through the CLI layer).\n */\n\nimport { join } from \"node:path\";\nimport { CONFIG_DIR_NAME } from \"../../config.ts\";\nimport { t } from \"../../core/i18n/index.ts\";\nimport { isOfflineModeEnabled } from \"../../core/package-process-runner.ts\";\nimport type { PluginBootstrapFactoryEntryV1 } from \"./bootstrap-factory-manifest.ts\";\nimport { BOOTSTRAP_FACTORY_PLUGIN_MANIFEST_V1 } from \"./bootstrap-factory-manifest.ts\";\nimport {\n\tDEFAULT_PLUGIN_STATE_FILE_V1,\n\tdefaultPluginHostFactsV1,\n\tdefaultPluginInstallStoreDirectoryV1,\n\tprojectPluginScopeRefV1,\n} from \"./default-active-bindings.ts\";\nimport { createPluginInstallerV1, DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1, type PluginInstallerV1 } from \"./installer.ts\";\nimport {\n\tcreateNodePackageInstallHostV1,\n\ttype NodePackageInstallHostV1,\n\ttype NodeZipPackageLimitsV1,\n} from \"./node-package-install-host.ts\";\nimport { createNodePluginAcquisitionHostV1, type NodePluginAcquisitionHostV1 } from \"./node-plugin-acquisition-host.ts\";\nimport {\n\ttype PluginBootstrapActionV1,\n\ttype PluginBootstrapDepsV1,\n\ttype PluginBootstrapResultV1,\n\trunPluginBootstrapV1,\n} from \"./plugin-bootstrap.ts\";\nimport { createPluginStateStoreV1, type PluginStateRecordV1, type PluginStateStoreV1 } from \"./state.ts\";\n\n/** Environment variable disabling the startup bootstrap entirely (`off`). */\nexport const AGENT_FORGE_PLUGIN_BOOTSTRAP_ENV_V1 = \"AGENT_FORGE_PLUGIN_BOOTSTRAP\";\n\n/** The only recognized disabling value; every other value (and absence) keeps bootstrap on. */\nconst PLUGIN_BOOTSTRAP_DISABLED_VALUE_V1 = \"off\";\n\nexport interface NodePluginBootstrapOptionsV1 {\n\treadonly agentDir: string;\n\treadonly cwd: string;\n\t/** Defaults to the frozen factory manifest. */\n\treadonly manifest?: readonly PluginBootstrapFactoryEntryV1[];\n\t/** Bare http(s) npm registry origin; forwarded to the acquisition host. */\n\treadonly npmRegistry?: string;\n\t/** npm registry bearer token; forwarded to the acquisition host. */\n\treadonly npmToken?: string;\n\treadonly limits?: NodeZipPackageLimitsV1;\n\t/** Deterministic fetch replacement for tests. */\n\treadonly fetch?: typeof globalThis.fetch;\n\treadonly signal?: AbortSignal;\n\t/** Full dependency override for deterministic tests; the env switch still applies. */\n\treadonly deps?: PluginBootstrapDepsV1;\n\t/** Overrides the first-run progress line (stderr) for tests and hosts. */\n\treadonly onPendingInstalls?: (count: number) => void;\n\t/**\n\t * Overrides the per-plugin progress renderer (stderr) for tests and hosts.\n\t * The default prints one line per installed/aligned/failed entry and stays\n\t * silent for satisfied entries.\n\t */\n\treadonly onAction?: (action: PluginBootstrapActionV1) => void;\n}\n\nexport type NodePluginBootstrapResultV1 = PluginBootstrapResultV1 & {\n\t/**\n\t * Present when a posture switch short-circuited the run before any local\n\t * comparison: the wiring-level env off switch, or the offline posture\n\t * (设计 §4.4 offline 姿态门, 2026-10-03 — offline installs cannot succeed\n\t * and would only fail slowly, so the run is skipped immediately).\n\t */\n\treadonly skipped?: \"disabled\" | \"offline\";\n};\n\n/** Install-scoped boundaries; created lazily by the first install action. */\ninterface InstallSessionV1 {\n\treadonly acquisition: NodePluginAcquisitionHostV1;\n\treadonly installHost: NodePackageInstallHostV1;\n\treadonly installer: PluginInstallerV1;\n\treadonly stateStore: PluginStateStoreV1;\n}\n\nfunction readActiveVersions(\n\tstore: PluginStateStoreV1,\n\tscope: \"global\" | \"project\",\n\tscopeRef: string,\n\tsignal: AbortSignal | undefined,\n): Promise<ReadonlyMap<string, string>> {\n\treturn (async () => {\n\t\tconst result = await store.read({ ...(signal === undefined ? {} : { signal }) });\n\t\tif (result.status !== \"ok\" && result.status !== \"missing\")\n\t\t\tthrow new Error(\n\t\t\t\tt(\"plugin state read failed ({detail}) for the {scope} scope\", {\n\t\t\t\t\tdetail: result.diagnostics[0]?.code ?? result.status,\n\t\t\t\t\tscope,\n\t\t\t\t}),\n\t\t\t);\n\t\tconst versions = new Map<string, string>();\n\t\tfor (const record of result.snapshot.records) {\n\t\t\tif (record.state.scope !== scope || record.state.scopeRef !== scopeRef) continue;\n\t\t\t// Enabled is deliberately not filtered: a disabled plugin still owns\n\t\t\t// its active installation record, and bootstrap never touches it (G5).\n\t\t\tif (record.state.lifecycle !== \"active\") continue;\n\t\t\tversions.set(record.pluginId, record.pluginVersion);\n\t\t}\n\t\treturn versions;\n\t})();\n}\n\n/**\n * Previous active installation record for one plugin id in the bootstrap's\n * global installation scope, or undefined when the plugin has no active\n * global installation. Mirrors the CLI update transaction's previous lookup\n * (cli.ts `findCurrentStateRecord`): same plugin id, same scope/scopeRef,\n * lifecycle active — bootstrap installs exclusively into this scope, so only\n * a record here can have had its runtime disposed by host.activate.\n */\nasync function readPreviousActiveRecord(\n\tstore: PluginStateStoreV1,\n\tpluginId: string,\n\tsignal: AbortSignal | undefined,\n): Promise<PluginStateRecordV1 | undefined> {\n\tconst result = await store.read({ ...(signal === undefined ? {} : { signal }) });\n\tif (result.status !== \"ok\" && result.status !== \"missing\")\n\t\tthrow new Error(\n\t\t\tt(\"plugin state read failed ({detail}) for the {scope} scope\", {\n\t\t\t\tdetail: result.diagnostics[0]?.code ?? result.status,\n\t\t\t\tscope: \"global\",\n\t\t\t}),\n\t\t);\n\treturn result.snapshot.records.find(\n\t\t(record) =>\n\t\t\trecord.pluginId === pluginId &&\n\t\t\trecord.state.scope === \"global\" &&\n\t\t\trecord.state.scopeRef === DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1 &&\n\t\t\trecord.state.lifecycle === \"active\",\n\t);\n}\n\n/**\n * Run the startup bootstrap for one agent directory. The function resolves\n * with a structured result and never throws for per-plugin failures; only a\n * wiring-level construction error propagates to the caller (main.ts guards\n * startup with its own catch).\n */\nexport async function runNodePluginBootstrapV1(\n\toptions: NodePluginBootstrapOptionsV1,\n): Promise<NodePluginBootstrapResultV1> {\n\tif (process.env[AGENT_FORGE_PLUGIN_BOOTSTRAP_ENV_V1]?.trim() === PLUGIN_BOOTSTRAP_DISABLED_VALUE_V1) {\n\t\treturn Object.freeze({\n\t\t\tversion: 1,\n\t\t\tstatus: \"succeeded\",\n\t\t\tactions: Object.freeze([]),\n\t\t\tdiagnostics: Object.freeze([]),\n\t\t\tdurationMs: 0,\n\t\t\tskipped: \"disabled\",\n\t\t});\n\t}\n\tif (isOfflineModeEnabled()) {\n\t\treturn Object.freeze({\n\t\t\tversion: 1,\n\t\t\tstatus: \"succeeded\",\n\t\t\tactions: Object.freeze([]),\n\t\t\tdiagnostics: Object.freeze([\n\t\t\t\t{\n\t\t\t\t\tcode: \"bootstrap_skipped_offline\",\n\t\t\t\t\tmessage: t(\n\t\t\t\t\t\t\"Offline posture (AGENT_FORGE_OFFLINE) skips the startup plugin bootstrap; run `agent-forge plugin install <package>` explicitly to install plugins.\",\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t] as const),\n\t\t\tdurationMs: 0,\n\t\t\tskipped: \"offline\",\n\t\t});\n\t}\n\tif (options.deps !== undefined) {\n\t\treturn await runPluginBootstrapV1({\n\t\t\tmanifest: options.manifest ?? BOOTSTRAP_FACTORY_PLUGIN_MANIFEST_V1,\n\t\t\tdeps: options.deps,\n\t\t\t...(options.onPendingInstalls === undefined ? {} : { onPendingInstalls: options.onPendingInstalls }),\n\t\t\t...(options.onAction === undefined ? {} : { onAction: options.onAction }),\n\t\t});\n\t}\n\tlet session: InstallSessionV1 | undefined;\n\tconst ensureSession = async (): Promise<InstallSessionV1> => {\n\t\tif (session !== undefined) return session;\n\t\tconst acquisition = createNodePluginAcquisitionHostV1({\n\t\t\t...(options.npmRegistry === undefined ? {} : { npmRegistry: options.npmRegistry }),\n\t\t\t...(options.npmToken === undefined ? {} : { npmToken: options.npmToken }),\n\t\t\t...(options.fetch === undefined ? {} : { fetch: options.fetch }),\n\t\t\t...(options.limits === undefined ? {} : { limits: options.limits }),\n\t\t});\n\t\tconst installHost = await createNodePackageInstallHostV1({\n\t\t\topenArtifact: (input) => acquisition.openArtifact(input),\n\t\t\tinstallationDirectory: defaultPluginInstallStoreDirectoryV1(options.agentDir),\n\t\t\tpersistence: \"persistent\",\n\t\t\tsupportedScopes: [\"global\", \"project\"],\n\t\t\t...(options.limits === undefined ? {} : { ...options.limits }),\n\t\t});\n\t\tsession = {\n\t\t\tacquisition,\n\t\t\tinstallHost,\n\t\t\tinstaller: createPluginInstallerV1({ host: installHost }),\n\t\t\tstateStore: createPluginStateStoreV1({ filePath: join(options.agentDir, DEFAULT_PLUGIN_STATE_FILE_V1) }),\n\t\t};\n\t\treturn session;\n\t};\n\tconst deps: PluginBootstrapDepsV1 = {\n\t\tlistActive: async ({ signal }) => {\n\t\t\tconst globalVersions = readActiveVersions(\n\t\t\t\tcreatePluginStateStoreV1({ filePath: join(options.agentDir, DEFAULT_PLUGIN_STATE_FILE_V1) }),\n\t\t\t\t\"global\",\n\t\t\t\tDEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1,\n\t\t\t\tsignal,\n\t\t\t);\n\t\t\tconst projectVersions = readActiveVersions(\n\t\t\t\tcreatePluginStateStoreV1({ filePath: join(options.cwd, CONFIG_DIR_NAME, DEFAULT_PLUGIN_STATE_FILE_V1) }),\n\t\t\t\t\"project\",\n\t\t\t\tprojectPluginScopeRefV1(options.cwd),\n\t\t\t\tsignal,\n\t\t\t);\n\t\t\tconst [globalResult, projectResult] = await Promise.all([globalVersions, projectVersions]);\n\t\t\t// Project precedence mirrors active-binding resolution: a project\n\t\t\t// installation shadows the same plugin id from the global scope.\n\t\t\treturn new Map([...globalResult, ...projectResult]);\n\t\t},\n\t\tinstallFromNpm: async ({ npmName, range, signal }) => {\n\t\t\t// Download retry (设计 §4.4 下载重试, 2026-10-04): transient registry\n\t\t\t// failures retried with backoff at this wiring layer so the decision\n\t\t\t// loop stays pure. Abort propagates immediately between attempts.\n\t\t\tlet lastError: unknown;\n\t\t\tfor (let attempt = 1; attempt <= 3; attempt++) {\n\t\t\t\tif (signal?.aborted === true) throw lastError ?? new Error(\"install aborted\");\n\t\t\t\ttry {\n\t\t\t\t\treturn await installFromNpmOnce({ npmName, range, signal });\n\t\t\t\t} catch (error) {\n\t\t\t\t\tlastError = error;\n\t\t\t\t\t// Abort during the attempt surfaces as the attempt's own error;\n\t\t\t\t\t// the loop-top check and the backoff listener cover the pauses.\n\t\t\t\t\tif (attempt === 3) throw error;\n\t\t\t\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\t\t\t\tconst timer = setTimeout(resolve, 400 * 2 ** (attempt - 1));\n\t\t\t\t\t\tsignal?.addEventListener(\n\t\t\t\t\t\t\t\"abort\",\n\t\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\t\t\t\treject(lastError);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ once: true },\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 lastError;\n\t\t},\n\t\t...(options.signal === undefined ? {} : { signal: options.signal }),\n\t};\n\tconst installFromNpmOnce = async (input: {\n\t\treadonly npmName: string;\n\t\treadonly range?: string;\n\t\treadonly signal?: AbortSignal;\n\t}): Promise<{ readonly pluginVersion: string; readonly source: string }> => {\n\t\tconst { npmName, range, signal } = input;\n\t\t{\n\t\t\tconst active = await ensureSession();\n\t\t\t// npm refs only (§0.7): scoped or plain names with the shared minimal\n\t\t\t// range subset; no github/gitee/url/local ref can be expressed here.\n\t\t\tconst ref = range === undefined ? npmName : `${npmName}@${range}`;\n\t\t\tconst acquired = await active.acquisition.resolvePackage({ ref, ...(signal === undefined ? {} : { signal }) });\n\t\t\tlet released = false;\n\t\t\tconst release = async (): Promise<void> => {\n\t\t\t\tif (released) return;\n\t\t\t\treleased = true;\n\t\t\t\tawait acquired.release();\n\t\t\t};\n\t\t\ttry {\n\t\t\t\tconst verified = active.installer.prepare({\n\t\t\t\t\tmanifest: acquired.manifest,\n\t\t\t\t\tsource: acquired.source,\n\t\t\t\t\thost: defaultPluginHostFactsV1(),\n\t\t\t\t});\n\t\t\t\tif (verified.status !== \"verified\")\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\tt(\"installer prepare rejected {pluginId}: {reason}\", {\n\t\t\t\t\t\t\tpluginId: acquired.manifest.id,\n\t\t\t\t\t\t\treason: verified.reason,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\tconst installed = await active.installer.install({\n\t\t\t\t\trecord: verified.record,\n\t\t\t\t\tscope: \"global\",\n\t\t\t\t\tscopeRef: DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1,\n\t\t\t\t\tartifact: acquired.artifact,\n\t\t\t\t\t...(signal === undefined ? {} : { signal }),\n\t\t\t\t});\n\t\t\t\tif (installed.status !== \"succeeded\")\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\tt(\"plugin install failed ({code}) for {pluginId}\", {\n\t\t\t\t\t\t\tcode: installed.error.code,\n\t\t\t\t\t\t\tpluginId: acquired.manifest.id,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\tconst activated = await active.installer.activate({\n\t\t\t\t\tinstallation: installed.installation,\n\t\t\t\t\trecord: verified.record,\n\t\t\t\t\tscope: \"global\",\n\t\t\t\t\tscopeRef: DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1,\n\t\t\t\t\t...(signal === undefined ? {} : { signal }),\n\t\t\t\t});\n\t\t\t\tif (activated.status !== \"succeeded\") {\n\t\t\t\t\t// CLI update-transaction alignment (cli.ts activate-failure\n\t\t\t\t\t// path): host.activate disposed the previous runtime for this\n\t\t\t\t\t// installation key before the new candidate failed to commit,\n\t\t\t\t\t// so restore the previous active installation through the\n\t\t\t\t\t// installer rollback. Rollback runs before the failed\n\t\t\t\t\t// candidate is removed because host.rollback requires the\n\t\t\t\t\t// failed record to still exist.\n\t\t\t\t\tlet restoreFailure: string | undefined;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst previous = await readPreviousActiveRecord(active.stateStore, acquired.manifest.id, signal);\n\t\t\t\t\t\tif (previous !== undefined) {\n\t\t\t\t\t\t\tconst rolledBack = await active.installer.rollback({\n\t\t\t\t\t\t\t\tfailed: installed.installation,\n\t\t\t\t\t\t\t\tprevious: {\n\t\t\t\t\t\t\t\t\tversion: 1,\n\t\t\t\t\t\t\t\t\tpluginId: previous.pluginId,\n\t\t\t\t\t\t\t\t\tpluginVersion: previous.pluginVersion,\n\t\t\t\t\t\t\t\t\tmanifestDigest: previous.manifestDigest,\n\t\t\t\t\t\t\t\t\tscope: previous.state.scope,\n\t\t\t\t\t\t\t\t\tscopeRef: previous.state.scopeRef,\n\t\t\t\t\t\t\t\t\tinstallationRef: previous.installationRef,\n\t\t\t\t\t\t\t\t\tstate: \"active\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tscope: \"global\",\n\t\t\t\t\t\t\t\tscopeRef: DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1,\n\t\t\t\t\t\t\t\t...(signal === undefined ? {} : { signal }),\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tif (rolledBack.status !== \"succeeded\") restoreFailure = rolledBack.error.code;\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\trestoreFailure = error instanceof Error ? error.message : String(error);\n\t\t\t\t\t}\n\t\t\t\t\tawait active.installer\n\t\t\t\t\t\t.remove({\n\t\t\t\t\t\t\tinstallation: installed.installation,\n\t\t\t\t\t\t\tscope: \"global\",\n\t\t\t\t\t\t\tscopeRef: DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1,\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.catch(() => undefined);\n\t\t\t\t\tconst activationMessage = t(\"plugin activation failed ({code}) for {pluginId}\", {\n\t\t\t\t\t\tcode: activated.error.code,\n\t\t\t\t\t\tpluginId: acquired.manifest.id,\n\t\t\t\t\t});\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\trestoreFailure === undefined\n\t\t\t\t\t\t\t? activationMessage\n\t\t\t\t\t\t\t: `${activationMessage}; previous version restore failed: ${restoreFailure}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst persisted = await active.stateStore.upsert({\n\t\t\t\t\tinstallation: activated.installation,\n\t\t\t\t\tscope: \"global\",\n\t\t\t\t\tenabled: true,\n\t\t\t\t\tsource: acquired.source,\n\t\t\t\t\t...(signal === undefined ? {} : { signal }),\n\t\t\t\t});\n\t\t\t\tif (persisted.status !== \"ok\") {\n\t\t\t\t\tawait active.installer\n\t\t\t\t\t\t.remove({\n\t\t\t\t\t\t\tinstallation: activated.installation,\n\t\t\t\t\t\t\tscope: \"global\",\n\t\t\t\t\t\t\tscopeRef: DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1,\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.catch(() => undefined);\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\tt(\"plugin state persist failed ({status}) for {pluginId}\", {\n\t\t\t\t\t\t\tstatus: persisted.status,\n\t\t\t\t\t\t\tpluginId: acquired.manifest.id,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn { pluginVersion: activated.installation.pluginVersion, source: acquired.source };\n\t\t\t} finally {\n\t\t\t\tawait release();\n\t\t\t}\n\t\t}\n\t};\n\ttry {\n\t\treturn await runPluginBootstrapV1({\n\t\t\tmanifest: options.manifest ?? BOOTSTRAP_FACTORY_PLUGIN_MANIFEST_V1,\n\t\t\tdeps,\n\t\t\t// First-run progress line (设计 §4.4, 2026-10-03): a fresh install is\n\t\t\t// otherwise silent for the whole network install window.\n\t\t\tonPendingInstalls:\n\t\t\t\toptions.onPendingInstalls ??\n\t\t\t\t((count: number) => {\n\t\t\t\t\tconsole.error(t(\"First run: installing {count} factory plugins…\", { count }));\n\t\t\t\t}),\n\t\t\t// Per-plugin progress (设计 §4.4 逐插件进度, 2026-10-04): one stderr\n\t\t\t// line per installed/aligned/failed entry; satisfied entries stay\n\t\t\t// silent so an all-green startup prints nothing extra.\n\t\t\tonAction:\n\t\t\t\toptions.onAction ??\n\t\t\t\t((action: PluginBootstrapActionV1) => {\n\t\t\t\t\tif (action.status === \"installed\") {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\tt(\"{pluginId}: installed {version}\", {\n\t\t\t\t\t\t\t\tpluginId: action.pluginId,\n\t\t\t\t\t\t\t\tversion: action.installedVersion ?? \"\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\t\t} else if (action.status === \"failed\") {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\tt(\n\t\t\t\t\t\t\t\t\"{pluginId}: install failed ({code}) — startup continues; the next startup retries automatically\",\n\t\t\t\t\t\t\t\t{ pluginId: action.pluginId, code: action.errorCode ?? \"install_failed\" },\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t});\n\t} finally {\n\t\tconst active = session;\n\t\tsession = undefined;\n\t\tif (active !== undefined) {\n\t\t\tawait active.installHost.close().catch(() => undefined);\n\t\t\tawait active.acquisition.close().catch(() => undefined);\n\t\t}\n\t}\n}\n"]}
|