@ai-agent-forge/agent-forge 0.86.7 → 0.88.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +45 -0
- package/README.md +10 -11
- package/dist/artifacts/artifact-store.d.ts.map +1 -1
- package/dist/artifacts/artifact-store.js +9 -5
- package/dist/artifacts/artifact-store.js.map +1 -1
- package/dist/bundle/.build-manifest.json +430 -413
- package/dist/bundle/chunks/{chunk-A7GUOX2H.js → chunk-6ZKDNZHA.js} +5 -1
- package/dist/bundle/chunks/chunk-HLJEVRWP.js +13 -0
- package/dist/bundle/chunks/chunk-YGHQME4V.js +1456 -0
- package/dist/bundle/chunks/image-resize-worker.js +12 -1
- package/dist/bundle/chunks/{virtual-modules-3IZ4MYSQ.js → virtual-modules-KZ5DRH7Q.js} +1 -1
- package/dist/bundle/cli.js +1 -1
- package/dist/bundle/client.js +1 -1
- package/dist/bundle/index.js +2 -2
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +231 -185
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/auth-check.d.ts.map +1 -1
- package/dist/cli/auth-check.js +17 -4
- package/dist/cli/auth-check.js.map +1 -1
- package/dist/cli/auth-command.d.ts.map +1 -1
- package/dist/cli/auth-command.js +15 -9
- package/dist/cli/auth-command.js.map +1 -1
- package/dist/cli/credential-print.d.ts.map +1 -1
- package/dist/cli/credential-print.js +14 -7
- package/dist/cli/credential-print.js.map +1 -1
- package/dist/cli/experimental/command.d.ts.map +1 -1
- package/dist/cli/experimental/command.js +6 -5
- package/dist/cli/experimental/command.js.map +1 -1
- package/dist/cli/list-models.d.ts.map +1 -1
- package/dist/cli/list-models.js +9 -8
- package/dist/cli/list-models.js.map +1 -1
- package/dist/cli/plugin-manager-controller.d.ts.map +1 -1
- package/dist/cli/plugin-manager-controller.js +2 -1
- package/dist/cli/plugin-manager-controller.js.map +1 -1
- package/dist/cli/serve.d.ts.map +1 -1
- package/dist/cli/serve.js +8 -5
- package/dist/cli/serve.js.map +1 -1
- package/dist/client/remote-session.d.ts.map +1 -1
- package/dist/client/remote-session.js +16 -9
- package/dist/client/remote-session.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +5 -3
- package/dist/config.js.map +1 -1
- package/dist/core/agent-capability-contract.d.ts +0 -7
- package/dist/core/agent-capability-contract.d.ts.map +1 -1
- package/dist/core/agent-capability-contract.js +72 -68
- package/dist/core/agent-capability-contract.js.map +1 -1
- package/dist/core/agent-session-bash.d.ts.map +1 -1
- package/dist/core/agent-session-bash.js +5 -4
- package/dist/core/agent-session-bash.js.map +1 -1
- package/dist/core/agent-session-compaction.d.ts +6 -10
- package/dist/core/agent-session-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-compaction.js +35 -133
- package/dist/core/agent-session-compaction.js.map +1 -1
- package/dist/core/agent-session-context.d.ts.map +1 -1
- package/dist/core/agent-session-context.js +18 -13
- package/dist/core/agent-session-context.js.map +1 -1
- package/dist/core/agent-session-internal.d.ts +0 -6
- package/dist/core/agent-session-internal.d.ts.map +1 -1
- package/dist/core/agent-session-internal.js.map +1 -1
- package/dist/core/agent-session-model.d.ts.map +1 -1
- package/dist/core/agent-session-model.js +2 -1
- package/dist/core/agent-session-model.js.map +1 -1
- package/dist/core/agent-session-retry.d.ts.map +1 -1
- package/dist/core/agent-session-retry.js +3 -3
- package/dist/core/agent-session-retry.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +7 -6
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +1 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session-tools.d.ts.map +1 -1
- package/dist/core/agent-session-tools.js +3 -2
- package/dist/core/agent-session-tools.js.map +1 -1
- package/dist/core/agent-session.d.ts +40 -22
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +147 -67
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-guidance.d.ts.map +1 -1
- package/dist/core/auth-guidance.js +11 -5
- package/dist/core/auth-guidance.js.map +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +9 -6
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +2 -1
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/embedded-sdk.d.ts.map +1 -1
- package/dist/core/embedded-sdk.js +10 -6
- package/dist/core/embedded-sdk.js.map +1 -1
- package/dist/core/export-html/index.d.ts.map +1 -1
- package/dist/core/export-html/index.js +9 -4
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/extensions/agent-composition.d.ts.map +1 -1
- package/dist/core/extensions/agent-composition.js +26 -19
- package/dist/core/extensions/agent-composition.js.map +1 -1
- package/dist/core/extensions/bootstrap-agent-loop.d.ts.map +1 -1
- package/dist/core/extensions/bootstrap-agent-loop.js +3 -2
- package/dist/core/extensions/bootstrap-agent-loop.js.map +1 -1
- package/dist/core/extensions/bootstrap-compaction-policy.d.ts.map +1 -1
- package/dist/core/extensions/bootstrap-compaction-policy.js +0 -34
- package/dist/core/extensions/bootstrap-compaction-policy.js.map +1 -1
- package/dist/core/extensions/bootstrap-lifecycle.d.ts.map +1 -1
- package/dist/core/extensions/bootstrap-lifecycle.js +20 -17
- package/dist/core/extensions/bootstrap-lifecycle.js.map +1 -1
- package/dist/core/extensions/bootstrap-overflow-policy.d.ts.map +1 -1
- package/dist/core/extensions/bootstrap-overflow-policy.js +2 -1
- package/dist/core/extensions/bootstrap-overflow-policy.js.map +1 -1
- package/dist/core/extensions/bootstrap-retry-policy.d.ts.map +1 -1
- package/dist/core/extensions/bootstrap-retry-policy.js +4 -3
- package/dist/core/extensions/bootstrap-retry-policy.js.map +1 -1
- package/dist/core/extensions/bootstrap-skills.d.ts.map +1 -1
- package/dist/core/extensions/bootstrap-skills.js +7 -6
- package/dist/core/extensions/bootstrap-skills.js.map +1 -1
- package/dist/core/extensions/bootstrap-tools.d.ts.map +1 -1
- package/dist/core/extensions/bootstrap-tools.js +2 -1
- package/dist/core/extensions/bootstrap-tools.js.map +1 -1
- package/dist/core/extensions/capability-plugin.d.ts.map +1 -1
- package/dist/core/extensions/capability-plugin.js +37 -13
- package/dist/core/extensions/capability-plugin.js.map +1 -1
- package/dist/core/extensions/capability-runtime-events.d.ts.map +1 -1
- package/dist/core/extensions/capability-runtime-events.js +17 -13
- package/dist/core/extensions/capability-runtime-events.js.map +1 -1
- package/dist/core/extensions/capability-runtime-guards.d.ts.map +1 -1
- package/dist/core/extensions/capability-runtime-guards.js +16 -15
- package/dist/core/extensions/capability-runtime-guards.js.map +1 -1
- package/dist/core/extensions/capability-runtime-manifest.d.ts.map +1 -1
- package/dist/core/extensions/capability-runtime-manifest.js +52 -30
- package/dist/core/extensions/capability-runtime-manifest.js.map +1 -1
- package/dist/core/extensions/capability-runtime-validation.d.ts.map +1 -1
- package/dist/core/extensions/capability-runtime-validation.js +66 -65
- package/dist/core/extensions/capability-runtime-validation.js.map +1 -1
- package/dist/core/extensions/capability-runtime.d.ts.map +1 -1
- package/dist/core/extensions/capability-runtime.js +147 -127
- package/dist/core/extensions/capability-runtime.js.map +1 -1
- package/dist/core/extensions/compaction-memory-failure-mode.d.ts.map +1 -1
- package/dist/core/extensions/compaction-memory-failure-mode.js +3 -2
- package/dist/core/extensions/compaction-memory-failure-mode.js.map +1 -1
- package/dist/core/extensions/context-strategy-binding.d.ts.map +1 -1
- package/dist/core/extensions/context-strategy-binding.js +7 -4
- package/dist/core/extensions/context-strategy-binding.js.map +1 -1
- package/dist/core/extensions/lifecycle-catalog.d.ts.map +1 -1
- package/dist/core/extensions/lifecycle-catalog.js +290 -279
- package/dist/core/extensions/lifecycle-catalog.js.map +1 -1
- package/dist/core/extensions/lifecycle-delivery-queue.d.ts.map +1 -1
- package/dist/core/extensions/lifecycle-delivery-queue.js +3 -2
- package/dist/core/extensions/lifecycle-delivery-queue.js.map +1 -1
- package/dist/core/extensions/provider-failover.d.ts +7 -3
- package/dist/core/extensions/provider-failover.d.ts.map +1 -1
- package/dist/core/extensions/provider-failover.js +9 -8
- package/dist/core/extensions/provider-failover.js.map +1 -1
- package/dist/core/facade/coding-agent-facade.d.ts +6 -6
- package/dist/core/facade/coding-agent-facade.d.ts.map +1 -1
- package/dist/core/facade/coding-agent-facade.js +2 -3
- package/dist/core/facade/coding-agent-facade.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/http-dispatcher.js +2 -1
- package/dist/core/http-dispatcher.js.map +1 -1
- package/dist/core/i18n/index.d.ts +14 -0
- package/dist/core/i18n/index.d.ts.map +1 -0
- package/dist/core/i18n/index.js +67 -0
- package/dist/core/i18n/index.js.map +1 -0
- package/dist/core/i18n/locales/en/example.d.ts +7 -0
- package/dist/core/i18n/locales/en/example.d.ts.map +1 -0
- package/dist/core/i18n/locales/en/example.js +7 -0
- package/dist/core/i18n/locales/en/example.js.map +1 -0
- package/dist/core/i18n/locales/zh-cn/cli.d.ts +8 -0
- package/dist/core/i18n/locales/zh-cn/cli.d.ts.map +1 -0
- package/dist/core/i18n/locales/zh-cn/cli.js +229 -0
- package/dist/core/i18n/locales/zh-cn/cli.js.map +1 -0
- package/dist/core/i18n/locales/zh-cn/common.d.ts +6 -0
- package/dist/core/i18n/locales/zh-cn/common.d.ts.map +1 -0
- package/dist/core/i18n/locales/zh-cn/common.js +6 -0
- package/dist/core/i18n/locales/zh-cn/common.js.map +1 -0
- package/dist/core/i18n/locales/zh-cn/core-contract-core.d.ts +13 -0
- package/dist/core/i18n/locales/zh-cn/core-contract-core.d.ts.map +1 -0
- package/dist/core/i18n/locales/zh-cn/core-contract-core.js +173 -0
- package/dist/core/i18n/locales/zh-cn/core-contract-core.js.map +1 -0
- package/dist/core/i18n/locales/zh-cn/core-contract-extensions.d.ts +12 -0
- package/dist/core/i18n/locales/zh-cn/core-contract-extensions.d.ts.map +1 -0
- package/dist/core/i18n/locales/zh-cn/core-contract-extensions.js +582 -0
- package/dist/core/i18n/locales/zh-cn/core-contract-extensions.js.map +1 -0
- package/dist/core/i18n/locales/zh-cn/core-contract-final.d.ts +9 -0
- package/dist/core/i18n/locales/zh-cn/core-contract-final.d.ts.map +1 -0
- package/dist/core/i18n/locales/zh-cn/core-contract-final.js +55 -0
- package/dist/core/i18n/locales/zh-cn/core-contract-final.js.map +1 -0
- package/dist/core/i18n/locales/zh-cn/core-contract-plugins.d.ts +11 -0
- package/dist/core/i18n/locales/zh-cn/core-contract-plugins.d.ts.map +1 -0
- package/dist/core/i18n/locales/zh-cn/core-contract-plugins.js +455 -0
- package/dist/core/i18n/locales/zh-cn/core-contract-plugins.js.map +1 -0
- package/dist/core/i18n/locales/zh-cn/core-errors.d.ts +9 -0
- package/dist/core/i18n/locales/zh-cn/core-errors.d.ts.map +1 -0
- package/dist/core/i18n/locales/zh-cn/core-errors.js +191 -0
- package/dist/core/i18n/locales/zh-cn/core-errors.js.map +1 -0
- package/dist/core/i18n/locales/zh-cn/example.d.ts +7 -0
- package/dist/core/i18n/locales/zh-cn/example.d.ts.map +1 -0
- package/dist/core/i18n/locales/zh-cn/example.js +10 -0
- package/dist/core/i18n/locales/zh-cn/example.js.map +1 -0
- package/dist/core/i18n/locales/zh-cn/index.d.ts +2 -0
- package/dist/core/i18n/locales/zh-cn/index.d.ts.map +1 -0
- package/dist/core/i18n/locales/zh-cn/index.js +41 -0
- package/dist/core/i18n/locales/zh-cn/index.js.map +1 -0
- package/dist/core/i18n/locales/zh-cn/interactive-mode.d.ts +10 -0
- package/dist/core/i18n/locales/zh-cn/interactive-mode.d.ts.map +1 -0
- package/dist/core/i18n/locales/zh-cn/interactive-mode.js +267 -0
- package/dist/core/i18n/locales/zh-cn/interactive-mode.js.map +1 -0
- package/dist/core/i18n/locales/zh-cn/keybindings.d.ts +11 -0
- package/dist/core/i18n/locales/zh-cn/keybindings.d.ts.map +1 -0
- package/dist/core/i18n/locales/zh-cn/keybindings.js +67 -0
- package/dist/core/i18n/locales/zh-cn/keybindings.js.map +1 -0
- package/dist/core/i18n/locales/zh-cn/slash-commands.d.ts +7 -0
- package/dist/core/i18n/locales/zh-cn/slash-commands.d.ts.map +1 -0
- package/dist/core/i18n/locales/zh-cn/slash-commands.js +39 -0
- package/dist/core/i18n/locales/zh-cn/slash-commands.js.map +1 -0
- package/dist/core/i18n/locales/zh-cn/tui-builtin.d.ts +10 -0
- package/dist/core/i18n/locales/zh-cn/tui-builtin.d.ts.map +1 -0
- package/dist/core/i18n/locales/zh-cn/tui-builtin.js +15 -0
- package/dist/core/i18n/locales/zh-cn/tui-builtin.js.map +1 -0
- package/dist/core/i18n/locales/zh-cn/tui-components-misc.d.ts +13 -0
- package/dist/core/i18n/locales/zh-cn/tui-components-misc.d.ts.map +1 -0
- package/dist/core/i18n/locales/zh-cn/tui-components-misc.js +102 -0
- package/dist/core/i18n/locales/zh-cn/tui-components-misc.js.map +1 -0
- package/dist/core/i18n/locales/zh-cn/tui-components-selectors.d.ts +12 -0
- package/dist/core/i18n/locales/zh-cn/tui-components-selectors.d.ts.map +1 -0
- package/dist/core/i18n/locales/zh-cn/tui-components-selectors.js +286 -0
- package/dist/core/i18n/locales/zh-cn/tui-components-selectors.js.map +1 -0
- package/dist/core/i18n/locales/zh-cn/tui-interactive-misc.d.ts +9 -0
- package/dist/core/i18n/locales/zh-cn/tui-interactive-misc.d.ts.map +1 -0
- package/dist/core/i18n/locales/zh-cn/tui-interactive-misc.js +79 -0
- package/dist/core/i18n/locales/zh-cn/tui-interactive-misc.js.map +1 -0
- package/dist/core/i18n/locales/zh-cn/tui-self-owned.d.ts +8 -0
- package/dist/core/i18n/locales/zh-cn/tui-self-owned.d.ts.map +1 -0
- package/dist/core/i18n/locales/zh-cn/tui-self-owned.js +72 -0
- package/dist/core/i18n/locales/zh-cn/tui-self-owned.js.map +1 -0
- package/dist/core/keybindings.d.ts +15 -0
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +18 -0
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/logger.d.ts.map +1 -1
- package/dist/core/logger.js +5 -1
- package/dist/core/logger.js.map +1 -1
- package/dist/core/model-config.d.ts +0 -1
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +9 -1
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +2 -1
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +11 -7
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/package-install-host.d.ts.map +1 -1
- package/dist/core/package-install-host.js +4 -3
- package/dist/core/package-install-host.js.map +1 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +15 -10
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/package-resource-collection.d.ts.map +1 -1
- package/dist/core/package-resource-collection.js +2 -1
- package/dist/core/package-resource-collection.js.map +1 -1
- package/dist/core/package-source.d.ts.map +1 -1
- package/dist/core/package-source.js +3 -2
- package/dist/core/package-source.js.map +1 -1
- package/dist/core/provider-composer.d.ts +2 -2
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +29 -21
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +6 -2
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/resolve-config-value.d.ts.map +1 -1
- package/dist/core/resolve-config-value.js +15 -5
- package/dist/core/resolve-config-value.js.map +1 -1
- package/dist/core/sdk.d.ts +27 -5
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +80 -55
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-cwd.d.ts.map +1 -1
- package/dist/core/session-cwd.js +5 -2
- package/dist/core/session-cwd.js.map +1 -1
- package/dist/core/session-export.d.ts.map +1 -1
- package/dist/core/session-export.js +2 -1
- package/dist/core/session-export.js.map +1 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +39 -29
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/session-storage.d.ts.map +1 -1
- package/dist/core/session-storage.js +3 -3
- package/dist/core/session-storage.js.map +1 -1
- package/dist/core/settings-manager.d.ts +20 -20
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +47 -59
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +53 -32
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +25 -2
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +11 -7
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js +9 -4
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +4 -3
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +3 -2
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +2 -1
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +6 -2
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +2 -1
- package/dist/core/tools/write.js.map +1 -1
- package/dist/durable/durable-service.d.ts.map +1 -1
- package/dist/durable/durable-service.js +25 -18
- package/dist/durable/durable-service.js.map +1 -1
- package/dist/host/checkpoint-commit.d.ts.map +1 -1
- package/dist/host/checkpoint-commit.js +2 -1
- package/dist/host/checkpoint-commit.js.map +1 -1
- package/dist/host/manual-compaction.d.ts.map +1 -1
- package/dist/host/manual-compaction.js +2 -1
- package/dist/host/manual-compaction.js.map +1 -1
- package/dist/host/output-projection.d.ts +0 -13
- package/dist/host/output-projection.d.ts.map +1 -1
- package/dist/host/output-projection.js +16 -2
- package/dist/host/output-projection.js.map +1 -1
- package/dist/host/summary-retry.d.ts.map +1 -1
- package/dist/host/summary-retry.js +3 -2
- package/dist/host/summary-retry.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +97 -60
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/agents-view.d.ts.map +1 -1
- package/dist/modes/interactive/components/agents-view.js +18 -15
- package/dist/modes/interactive/components/agents-view.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +6 -5
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +12 -7
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.js +2 -1
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +6 -5
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.js +9 -5
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +18 -15
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-entry.js +2 -1
- package/dist/modes/interactive/components/custom-entry.js.map +1 -1
- package/dist/modes/interactive/components/dialog-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/dialog-editor.js +5 -4
- package/dist/modes/interactive/components/dialog-editor.js.map +1 -1
- package/dist/modes/interactive/components/dialog-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/dialog-input.js +2 -1
- package/dist/modes/interactive/components/dialog-input.js.map +1 -1
- package/dist/modes/interactive/components/dialog-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/dialog-selector.js +4 -3
- package/dist/modes/interactive/components/dialog-selector.js.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.js +11 -10
- package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +0 -2
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +8 -10
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +1 -0
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js +1 -0
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.js +3 -2
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +12 -11
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/mermaid.d.ts.map +1 -1
- package/dist/modes/interactive/components/mermaid.js +6 -2
- package/dist/modes/interactive/components/mermaid.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +28 -16
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +10 -9
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/plugin-manager-entry.d.ts.map +1 -1
- package/dist/modes/interactive/components/plugin-manager-entry.js +22 -13
- package/dist/modes/interactive/components/plugin-manager-entry.js.map +1 -1
- package/dist/modes/interactive/components/plugin-selection-entry.d.ts.map +1 -1
- package/dist/modes/interactive/components/plugin-selection-entry.js +27 -12
- package/dist/modes/interactive/components/plugin-selection-entry.js.map +1 -1
- package/dist/modes/interactive/components/queue-manager-selector.d.ts +60 -0
- package/dist/modes/interactive/components/queue-manager-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/queue-manager-selector.js +166 -0
- package/dist/modes/interactive/components/queue-manager-selector.js.map +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +16 -14
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +43 -31
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +4 -6
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +115 -120
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-submenu.js +5 -4
- package/dist/modes/interactive/components/settings-submenu.js.map +1 -1
- package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/show-images-selector.js +3 -2
- package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +4 -3
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
- package/dist/modes/interactive/components/status-indicator.js +14 -5
- package/dist/modes/interactive/components/status-indicator.js.map +1 -1
- package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/theme-selector.js +2 -1
- package/dist/modes/interactive/components/theme-selector.js.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +11 -4
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +8 -3
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tree-list.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-list.js +7 -6
- package/dist/modes/interactive/components/tree-list.js.map +1 -1
- package/dist/modes/interactive/components/tree-render.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-render.js +28 -23
- package/dist/modes/interactive/components/tree-render.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +9 -7
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.js +5 -4
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
- package/dist/modes/interactive/components/workflow-view.d.ts.map +1 -1
- package/dist/modes/interactive/components/workflow-view.js +36 -21
- package/dist/modes/interactive/components/workflow-view.js.map +1 -1
- package/dist/modes/interactive/external-editor.d.ts.map +1 -1
- package/dist/modes/interactive/external-editor.js +2 -1
- package/dist/modes/interactive/external-editor.js.map +1 -1
- package/dist/modes/interactive/interactive-auth.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-auth.js +71 -40
- package/dist/modes/interactive/interactive-auth.js.map +1 -1
- package/dist/modes/interactive/interactive-commands.d.ts +1 -0
- package/dist/modes/interactive/interactive-commands.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-commands.js +3 -0
- package/dist/modes/interactive/interactive-commands.js.map +1 -1
- package/dist/modes/interactive/interactive-dialog-ui.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-dialog-ui.js +5 -5
- package/dist/modes/interactive/interactive-dialog-ui.js.map +1 -1
- package/dist/modes/interactive/interactive-format.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-format.js +34 -18
- package/dist/modes/interactive/interactive-format.js.map +1 -1
- package/dist/modes/interactive/interactive-helpers.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-helpers.js +7 -2
- package/dist/modes/interactive/interactive-helpers.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +4 -2
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +350 -279
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/interactive-selectors.d.ts +9 -0
- package/dist/modes/interactive/interactive-selectors.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-selectors.js +79 -25
- package/dist/modes/interactive/interactive-selectors.js.map +1 -1
- package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-controller.js +5 -1
- package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +26 -23
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/json-event.d.ts.map +1 -1
- package/dist/modes/json-event.js +3 -2
- package/dist/modes/json-event.js.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +3 -2
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +0 -8
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +3 -14
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +0 -9
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +0 -19
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +28 -13
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/plugins/ecosystem/catalog.d.ts.map +1 -1
- package/dist/plugins/ecosystem/catalog.js +3 -2
- package/dist/plugins/ecosystem/catalog.js.map +1 -1
- package/dist/plugins/ecosystem/cli.d.ts.map +1 -1
- package/dist/plugins/ecosystem/cli.js +2 -1
- package/dist/plugins/ecosystem/cli.js.map +1 -1
- package/dist/plugins/ecosystem/default-plugin-market.d.ts.map +1 -1
- package/dist/plugins/ecosystem/default-plugin-market.js +3 -2
- package/dist/plugins/ecosystem/default-plugin-market.js.map +1 -1
- package/dist/plugins/ecosystem/distribution.d.ts.map +1 -1
- package/dist/plugins/ecosystem/distribution.js +2 -1
- package/dist/plugins/ecosystem/distribution.js.map +1 -1
- package/dist/plugins/ecosystem/installer.d.ts.map +1 -1
- package/dist/plugins/ecosystem/installer.js +3 -2
- package/dist/plugins/ecosystem/installer.js.map +1 -1
- package/dist/plugins/ecosystem/node-disk-registry-source.d.ts.map +1 -1
- package/dist/plugins/ecosystem/node-disk-registry-source.js +20 -17
- package/dist/plugins/ecosystem/node-disk-registry-source.js.map +1 -1
- package/dist/plugins/ecosystem/node-distribution-host.d.ts.map +1 -1
- package/dist/plugins/ecosystem/node-distribution-host.js +35 -34
- package/dist/plugins/ecosystem/node-distribution-host.js.map +1 -1
- package/dist/plugins/ecosystem/node-npm-registry-source.d.ts.map +1 -1
- package/dist/plugins/ecosystem/node-npm-registry-source.js +35 -34
- package/dist/plugins/ecosystem/node-npm-registry-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 +9 -8
- package/dist/plugins/ecosystem/node-package-install-host.js.map +1 -1
- package/dist/plugins/ecosystem/node-package-install-persistence.d.ts.map +1 -1
- package/dist/plugins/ecosystem/node-package-install-persistence.js +4 -3
- package/dist/plugins/ecosystem/node-package-install-persistence.js.map +1 -1
- package/dist/plugins/ecosystem/node-plugin-bootstrap.d.ts +9 -2
- package/dist/plugins/ecosystem/node-plugin-bootstrap.d.ts.map +1 -1
- package/dist/plugins/ecosystem/node-plugin-bootstrap.js +44 -5
- package/dist/plugins/ecosystem/node-plugin-bootstrap.js.map +1 -1
- package/dist/plugins/ecosystem/node-plugin-trust-root.d.ts.map +1 -1
- package/dist/plugins/ecosystem/node-plugin-trust-root.js +10 -9
- package/dist/plugins/ecosystem/node-plugin-trust-root.js.map +1 -1
- package/dist/plugins/ecosystem/node-registry-source.d.ts.map +1 -1
- package/dist/plugins/ecosystem/node-registry-source.js +31 -30
- package/dist/plugins/ecosystem/node-registry-source.js.map +1 -1
- package/dist/plugins/ecosystem/node-release-package-source.d.ts.map +1 -1
- package/dist/plugins/ecosystem/node-release-package-source.js +30 -29
- package/dist/plugins/ecosystem/node-release-package-source.js.map +1 -1
- package/dist/plugins/ecosystem/node-tar-writer.d.ts.map +1 -1
- package/dist/plugins/ecosystem/node-tar-writer.js +11 -10
- package/dist/plugins/ecosystem/node-tar-writer.js.map +1 -1
- package/dist/plugins/ecosystem/node-url-package-source.d.ts.map +1 -1
- package/dist/plugins/ecosystem/node-url-package-source.js +21 -20
- package/dist/plugins/ecosystem/node-url-package-source.js.map +1 -1
- package/dist/plugins/ecosystem/plugin-acquisition.d.ts.map +1 -1
- package/dist/plugins/ecosystem/plugin-acquisition.js +3 -2
- package/dist/plugins/ecosystem/plugin-acquisition.js.map +1 -1
- package/dist/plugins/ecosystem/plugin-bootstrap.d.ts +9 -1
- package/dist/plugins/ecosystem/plugin-bootstrap.d.ts.map +1 -1
- package/dist/plugins/ecosystem/plugin-bootstrap.js +5 -0
- package/dist/plugins/ecosystem/plugin-bootstrap.js.map +1 -1
- package/dist/plugins/ecosystem/registry-cli-adapter.d.ts.map +1 -1
- package/dist/plugins/ecosystem/registry-cli-adapter.js +2 -1
- package/dist/plugins/ecosystem/registry-cli-adapter.js.map +1 -1
- package/dist/plugins/ecosystem/registry.d.ts.map +1 -1
- package/dist/plugins/ecosystem/registry.js +35 -32
- package/dist/plugins/ecosystem/registry.js.map +1 -1
- package/dist/plugins/ecosystem/resolver.d.ts.map +1 -1
- package/dist/plugins/ecosystem/resolver.js +3 -2
- package/dist/plugins/ecosystem/resolver.js.map +1 -1
- package/dist/plugins/ecosystem/selection-store.d.ts.map +1 -1
- package/dist/plugins/ecosystem/selection-store.js +11 -10
- package/dist/plugins/ecosystem/selection-store.js.map +1 -1
- package/dist/plugins/ecosystem/selection.d.ts.map +1 -1
- package/dist/plugins/ecosystem/selection.js +8 -7
- package/dist/plugins/ecosystem/selection.js.map +1 -1
- package/dist/plugins/ecosystem/state.d.ts.map +1 -1
- package/dist/plugins/ecosystem/state.js +24 -23
- package/dist/plugins/ecosystem/state.js.map +1 -1
- package/dist/plugins/ecosystem/updates.d.ts.map +1 -1
- package/dist/plugins/ecosystem/updates.js +5 -4
- package/dist/plugins/ecosystem/updates.js.map +1 -1
- package/dist/plugins/mcp-http.d.ts +0 -17
- package/dist/plugins/mcp-http.d.ts.map +1 -1
- package/dist/plugins/mcp-http.js +30 -7
- package/dist/plugins/mcp-http.js.map +1 -1
- package/dist/plugins/plugin-supervisor.d.ts.map +1 -1
- package/dist/plugins/plugin-supervisor.js +19 -1
- package/dist/plugins/plugin-supervisor.js.map +1 -1
- package/dist/profile/first-roles.d.ts.map +1 -1
- package/dist/profile/first-roles.js +10 -1
- package/dist/profile/first-roles.js.map +1 -1
- package/dist/profile/goal-plugin.d.ts.map +1 -1
- package/dist/profile/goal-plugin.js +24 -5
- package/dist/profile/goal-plugin.js.map +1 -1
- package/dist/profile/identity.d.ts.map +1 -1
- package/dist/profile/identity.js +7 -6
- package/dist/profile/identity.js.map +1 -1
- package/dist/profile/lock.d.ts.map +1 -1
- package/dist/profile/lock.js +15 -1
- package/dist/profile/lock.js.map +1 -1
- package/dist/profile/plan-plugin.d.ts.map +1 -1
- package/dist/profile/plan-plugin.js +26 -13
- package/dist/profile/plan-plugin.js.map +1 -1
- package/dist/profile/plugin-profiles.d.ts.map +1 -1
- package/dist/profile/plugin-profiles.js +2 -1
- package/dist/profile/plugin-profiles.js.map +1 -1
- package/dist/profile/policy-manifest.d.ts.map +1 -1
- package/dist/profile/policy-manifest.js +5 -4
- package/dist/profile/policy-manifest.js.map +1 -1
- package/dist/profile/profile-registry.d.ts +0 -12
- package/dist/profile/profile-registry.d.ts.map +1 -1
- package/dist/profile/profile-registry.js +14 -1
- package/dist/profile/profile-registry.js.map +1 -1
- package/dist/profile/role-catalog.d.ts +0 -1
- package/dist/profile/role-catalog.d.ts.map +1 -1
- package/dist/profile/role-catalog.js +17 -15
- package/dist/profile/role-catalog.js.map +1 -1
- package/dist/profile/role-orchestrator.d.ts.map +1 -1
- package/dist/profile/role-orchestrator.js +8 -7
- package/dist/profile/role-orchestrator.js.map +1 -1
- package/dist/profile/role-runner.d.ts.map +1 -1
- package/dist/profile/role-runner.js +3 -2
- package/dist/profile/role-runner.js.map +1 -1
- package/dist/profile/root-facade.d.ts.map +1 -1
- package/dist/profile/root-facade.js +2 -1
- package/dist/profile/root-facade.js.map +1 -1
- package/dist/profile/skill-discovery-wiring.d.ts.map +1 -1
- package/dist/profile/skill-discovery-wiring.js +7 -2
- package/dist/profile/skill-discovery-wiring.js.map +1 -1
- package/dist/profile/state-store.d.ts.map +1 -1
- package/dist/profile/state-store.js +13 -9
- package/dist/profile/state-store.js.map +1 -1
- package/dist/profile/todo-plugin.d.ts.map +1 -1
- package/dist/profile/todo-plugin.js +9 -4
- package/dist/profile/todo-plugin.js.map +1 -1
- package/dist/profiles/builtin-suites.d.ts +13 -6
- package/dist/profiles/builtin-suites.d.ts.map +1 -1
- package/dist/profiles/builtin-suites.js +15 -6
- package/dist/profiles/builtin-suites.js.map +1 -1
- package/dist/profiles/suite-loader.d.ts +25 -1
- package/dist/profiles/suite-loader.d.ts.map +1 -1
- package/dist/profiles/suite-loader.js +34 -9
- package/dist/profiles/suite-loader.js.map +1 -1
- package/dist/remote/server-entry.d.ts.map +1 -1
- package/dist/remote/server-entry.js +3 -2
- package/dist/remote/server-entry.js.map +1 -1
- package/dist/remote/session-source.d.ts.map +1 -1
- package/dist/remote/session-source.js +8 -4
- package/dist/remote/session-source.js.map +1 -1
- package/dist/share/session-share.d.ts.map +1 -1
- package/dist/share/session-share.js +14 -2
- package/dist/share/session-share.js.map +1 -1
- package/dist/testing/plugin-testkit.d.ts.map +1 -1
- package/dist/testing/plugin-testkit.js +4 -3
- package/dist/testing/plugin-testkit.js.map +1 -1
- package/dist/testing/runtime-delivery-queue.d.ts.map +1 -1
- package/dist/testing/runtime-delivery-queue.js +2 -1
- package/dist/testing/runtime-delivery-queue.js.map +1 -1
- package/dist/testing/session-plugin-testkit.d.ts.map +1 -1
- package/dist/testing/session-plugin-testkit.js +10 -7
- package/dist/testing/session-plugin-testkit.js.map +1 -1
- package/dist/utils/ansi.d.ts.map +1 -1
- package/dist/utils/ansi.js +2 -1
- package/dist/utils/ansi.js.map +1 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +7 -6
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/image-resize-worker.d.ts.map +1 -1
- package/dist/utils/image-resize-worker.js +3 -2
- package/dist/utils/image-resize-worker.js.map +1 -1
- package/dist/utils/photon.d.ts +2 -2
- package/dist/utils/photon.d.ts.map +1 -1
- package/dist/utils/photon.js +2 -2
- package/dist/utils/photon.js.map +1 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +9 -8
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +23 -13
- package/dist/utils/tools-manager.js.map +1 -1
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js +5 -1
- package/dist/utils/version-check.js.map +1 -1
- package/docs/compaction.md +1 -3
- package/docs/docs.json +4 -0
- package/docs/index.md +1 -0
- package/docs/keybindings.md +3 -0
- package/docs/mcp.md +103 -0
- package/docs/models.md +14 -22
- package/docs/providers.md +0 -1
- package/docs/quickstart.md +1 -1
- package/docs/rpc.md +1 -26
- package/docs/sdk.md +4 -6
- package/docs/settings.md +10 -12
- package/docs/skills.md +1 -9
- package/docs/terminal-setup.md +2 -3
- package/docs/usage.md +7 -6
- 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/examples/sdk/10-settings.ts +2 -4
- package/examples/sdk/12-full-control.ts +1 -2
- package/package.json +1 -3
- package/dist/bundle/chunks/chunk-EALJ5DDX.js +0 -1452
- package/dist/core/extensions/microcompact.d.ts +0 -80
- package/dist/core/extensions/microcompact.d.ts.map +0 -1
- package/dist/core/extensions/microcompact.js +0 -134
- package/dist/core/extensions/microcompact.js.map +0 -1
- package/dist/server/create-harness.d.ts +0 -26
- package/dist/server/create-harness.d.ts.map +0 -1
- package/dist/server/create-harness.js +0 -106
- package/dist/server/create-harness.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-plugin-market.js","sourceRoot":"","sources":["../../../src/plugins/ecosystem/default-plugin-market.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,EACN,4BAA4B,EAC5B,wBAAwB,EACxB,oCA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GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;KAC9C,CAAC,CAAC;IACH,OAAO;QACN,QAAQ;QACR,WAAW,EAAE,sCAAsC,CAAC,QAAQ,CAAC;QAC7D,WAAW,EAAE,eAAe;QAC5B,SAAS,EAAE,uBAAuB,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;QACzD,GAAG,CAAC,gBAAgB,KAAK,SAAS,IAAI,SAAS,KAAK,SAAS;YAC5D,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,YAAY,EAAE,0BAA0B,CAAC,EAAE,IAAI,EAAE,gBAAgB,CAAC,IAAI,EAAE,eAAe,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;QAC7G,UAAU,EAAE,wBAAwB,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,4BAA4B,CAAC,EAAE,CAAC;QACxG,iBAAiB,EAAE,wBAAwB,CAAC;YAC3C,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,eAAe,EAAE,4BAA4B,CAAC;SAC1E,CAAC;QACF,KAAK,EAAE,KAAK,IAAI,EAAE,CAAC;YAClB,MAAM,WAAW,CAAC,KAAK,EAAE,CAAC;YAC1B,MAAM,eAAe,CAAC,KAAK,EAAE,CAAC;YAC9B,MAAM,gBAAgB,EAAE,KAAK,EAAE,CAAC;QAAA,CAChC;KACD,CAAC;AAAA,CACF","sourcesContent":["/**\n * Default CLI wiring for the plugin marketplace write side (P1-5): one\n * factory composes the disk install store, an optional HTTP registry origin,\n * the HTTP distribution host, and the persistent package install host into\n * the registry/installer/distribution surfaces the ecosystem CLI and the TUI\n * manager consume. Nothing here discovers keys or origins implicitly: the\n * registry origin comes from an explicit option or the\n * AGENT_FORGE_PLUGIN_REGISTRY_ORIGIN environment variable, and its absence\n * keeps disk-only semantics (install resolves to not_found, remove/rollback\n * and state management stay fully usable). Host injection always wins; the\n * factory is only invoked when no host-supplied boundary exists.\n */\n\nimport { join } from \"node:path\";\nimport { CONFIG_DIR_NAME } from \"../../config.ts\";\nimport type { PluginEcosystemRegistryV1 } from \"./cli.ts\";\nimport {\n\tDEFAULT_PLUGIN_STATE_FILE_V1,\n\tdefaultPluginHostFactsV1,\n\tdefaultPluginInstallStoreDirectoryV1,\n\tdefaultPluginInstallStoreInstanceRootV1,\n} from \"./default-active-bindings.ts\";\nimport { createPluginDistributionV1, type PluginDistributionV1 } from \"./distribution.ts\";\nimport { createPluginInstallerV1, type PluginInstallerV1 } from \"./installer.ts\";\nimport { createNodeDiskPluginRegistrySourceV1 } from \"./node-disk-registry-source.ts\";\nimport {\n\tcreateNodeHttpPluginDistributionHostV1,\n\ttype NodeHttpPluginDistributionHostV1,\n} from \"./node-distribution-host.ts\";\nimport {\n\tcreateNodePackageInstallHostV1,\n\tNodePackageInstallErrorV1,\n\ttype NodeZipPackageLimitsV1,\n} from \"./node-package-install-host.ts\";\nimport { createNodePluginAcquisitionHostV1, type NodePluginAcquisitionHostV1 } from \"./node-plugin-acquisition-host.ts\";\nimport { createNodePluginTrustRootV1, type NodePluginTrustRootKeyV1 } from \"./node-plugin-trust-root.ts\";\nimport { createNodeHttpPluginRegistrySourceV1 } from \"./node-registry-source.ts\";\nimport { createPluginRegistryV1, type PluginRegistrySourceV1, type PluginRegistryV1 } from \"./registry.ts\";\nimport { createPluginEcosystemRegistryAdapterV1 } from \"./registry-cli-adapter.ts\";\nimport { createPluginStateStoreV1, type PluginStateStoreV1 } from \"./state.ts\";\n\n/** Environment variable carrying the exact http(s) marketplace origin. */\nexport const DEFAULT_PLUGIN_REGISTRY_ORIGIN_ENV_V1 = \"AGENT_FORGE_PLUGIN_REGISTRY_ORIGIN\";\n\n/**\n * Environment variable carrying the Ed25519 trust root as a JSON array of\n * `{keyId, publicKeyPem}` entries. Downloads never verify without an explicit\n * trust root; there is no implicit key discovery.\n */\nexport const DEFAULT_PLUGIN_TRUST_KEYS_ENV_V1 = \"AGENT_FORGE_PLUGIN_TRUST_KEYS\";\n\n/** Registry document path below the configured origin. */\nexport const DEFAULT_PLUGIN_REGISTRY_PATH_V1 = \"/v1/plugin-registry.json\";\n\nexport interface DefaultPluginMarketOptionsV1 {\n\treadonly agentDir: string;\n\treadonly cwd: string;\n\t/** Exact http(s) registry origin; defaults to the environment variable. */\n\treadonly registryOrigin?: string;\n\t/** Explicit Ed25519 trust root; defaults to the environment variable. */\n\treadonly trustKeys?: readonly NodePluginTrustRootKeyV1[];\n\t/** Optional acquisition host override (tests); defaults to a real Node host. */\n\treadonly acquisition?: NodePluginAcquisitionHostV1;\n\t/** Optional package limits shared by acquisition and the install host; defaults apply. */\n\treadonly limits?: NodeZipPackageLimitsV1;\n\t/** Deterministic fetch replacement for tests. */\n\treadonly fetch?: typeof globalThis.fetch;\n}\n\nexport interface DefaultPluginMarketWiringV1 {\n\t/** Verified registry for the manager controller snapshot. */\n\treadonly registry: PluginRegistryV1;\n\t/** CLI-facing adapter over the same verified registry. */\n\treadonly cliRegistry: PluginEcosystemRegistryV1;\n\t/** Multi-source acquisition boundary for `plugin install <ref>`. */\n\treadonly acquisition: NodePluginAcquisitionHostV1;\n\treadonly installer: PluginInstallerV1;\n\t/** Present only when a registry origin is configured. */\n\treadonly distribution?: PluginDistributionV1;\n\treadonly stateStore: PluginStateStoreV1;\n\treadonly projectStateStore: PluginStateStoreV1;\n\t/** Releases the distribution host's cached artifacts when present. */\n\treadonly close: () => Promise<void>;\n}\n\n/**\n * Compose the default marketplace boundaries over one agent directory. The\n * disk install store is always part of the registry so installed plugins can\n * be listed, updated, and removed offline; a configured origin adds the HTTP\n * registry and package download. Installation failures surface structured\n * errors, never synthetic success.\n */\nexport async function createDefaultPluginMarketWiringV1(\n\toptions: DefaultPluginMarketOptionsV1,\n): Promise<DefaultPluginMarketWiringV1> {\n\tconst origin = (options.registryOrigin ?? process.env[DEFAULT_PLUGIN_REGISTRY_ORIGIN_ENV_V1])?.trim();\n\tconst effectiveOrigin = origin === \"\" ? undefined : origin;\n\tconst storeParent = defaultPluginInstallStoreDirectoryV1(options.agentDir);\n\t// The install host persists under this fixed subdirectory; the disk\n\t// registry source must read the same instance root to observe installs.\n\tconst instanceRoot = defaultPluginInstallStoreInstanceRootV1(options.agentDir);\n\tconst diskSource = createNodeDiskPluginRegistrySourceV1({ rootDirectory: instanceRoot });\n\tconst httpSource =\n\t\teffectiveOrigin === undefined\n\t\t\t? undefined\n\t\t\t: createNodeHttpPluginRegistrySourceV1({\n\t\t\t\t\turl: new URL(effectiveOrigin + DEFAULT_PLUGIN_REGISTRY_PATH_V1),\n\t\t\t\t\tallowedOrigins: [effectiveOrigin],\n\t\t\t\t\t...(options.fetch === undefined ? {} : { fetch: options.fetch }),\n\t\t\t\t});\n\tconst source: PluginRegistrySourceV1 = {\n\t\t...(httpSource === undefined ? {} : { source: httpSource.source }),\n\t\tlist: async ({ signal } = {}) => {\n\t\t\tconst disk = await diskSource.list({ signal });\n\t\t\tif (httpSource === undefined) return disk;\n\t\t\tconst remote = await httpSource.list({ signal });\n\t\t\treturn Object.freeze([...remote, ...disk]);\n\t\t},\n\t};\n\tconst distributionHost =\n\t\teffectiveOrigin === undefined\n\t\t\t? undefined\n\t\t\t: await createNodeHttpPluginDistributionHostV1({\n\t\t\t\t\tallowedOrigins: [effectiveOrigin],\n\t\t\t\t\tartifactDirectory: join(storeParent, \"distribution-cache-v1\"),\n\t\t\t\t\t...(options.fetch === undefined ? {} : { fetch: options.fetch }),\n\t\t\t\t});\n\tlet trustKeys = options.trustKeys;\n\tif (trustKeys === undefined && effectiveOrigin !== undefined) {\n\t\tconst raw = process.env[DEFAULT_PLUGIN_TRUST_KEYS_ENV_V1];\n\t\tif (raw !== undefined && raw.trim() !== \"\") {\n\t\t\tlet parsed: unknown;\n\t\t\ttry {\n\t\t\t\tparsed = JSON.parse(raw);\n\t\t\t} catch {\n\t\t\t\tthrow new Error(`${DEFAULT_PLUGIN_TRUST_KEYS_ENV_V1} must be a JSON array of {keyId, publicKeyPem}`);\n\t\t\t}\n\t\t\tif (!Array.isArray(parsed)) throw new Error(`${DEFAULT_PLUGIN_TRUST_KEYS_ENV_V1} must be a JSON array`);\n\t\t\ttrustKeys = parsed as NodePluginTrustRootKeyV1[];\n\t\t}\n\t}\n\tconst trustRoot =\n\t\ttrustKeys === undefined || distributionHost === undefined\n\t\t\t? undefined\n\t\t\t: createNodePluginTrustRootV1({ keys: trustKeys });\n\t// Acquisition artifacts (npm/URL/local refs) and signed distribution\n\t// artifacts share one install host; ownership decides which reader serves.\n\tconst acquisitionHost =\n\t\toptions.acquisition ??\n\t\tcreateNodePluginAcquisitionHostV1({\n\t\t\t...(options.limits === undefined ? {} : { limits: options.limits }),\n\t\t\t...(options.fetch === undefined ? {} : { fetch: options.fetch }),\n\t\t});\n\tconst openArtifact: NodeHttpPluginDistributionHostV1[\"openArtifact\"] = (input) => {\n\t\tif (acquisitionHost.ownsArtifact(input.artifact)) return acquisitionHost.openArtifact(input);\n\t\tconst reader = distributionHost?.openArtifact;\n\t\tif (reader === undefined) throw new NodePackageInstallErrorV1(\"invalid_artifact\");\n\t\treturn reader(input);\n\t};\n\tconst installHost = await createNodePackageInstallHostV1({\n\t\topenArtifact,\n\t\tinstallationDirectory: storeParent,\n\t\tpersistence: \"persistent\",\n\t\tsupportedScopes: [\"global\", \"project\"],\n\t\t...(options.limits === undefined ? {} : { ...options.limits }),\n\t});\n\tconst registry = createPluginRegistryV1({\n\t\tsource,\n\t\thost: defaultPluginHostFactsV1(),\n\t\tverify: {\n\t\t\tverify: ({ manifestDigest, expectedDigest }) =>\n\t\t\t\texpectedDigest === undefined || expectedDigest === manifestDigest\n\t\t\t\t\t? { status: \"accepted\" }\n\t\t\t\t\t: { status: \"rejected\", reason: \"Manifest digest does not match the expected digest\" },\n\t\t},\n\t\tsourceVerifier: () => ({ status: \"accepted\" }),\n\t});\n\treturn {\n\t\tregistry,\n\t\tcliRegistry: createPluginEcosystemRegistryAdapterV1(registry),\n\t\tacquisition: acquisitionHost,\n\t\tinstaller: createPluginInstallerV1({ host: installHost }),\n\t\t...(distributionHost === undefined || trustRoot === undefined\n\t\t\t? {}\n\t\t\t: { distribution: createPluginDistributionV1({ host: distributionHost.host, verifySignature: trustRoot }) }),\n\t\tstateStore: createPluginStateStoreV1({ filePath: join(options.agentDir, DEFAULT_PLUGIN_STATE_FILE_V1) }),\n\t\tprojectStateStore: createPluginStateStoreV1({\n\t\t\tfilePath: join(options.cwd, CONFIG_DIR_NAME, DEFAULT_PLUGIN_STATE_FILE_V1),\n\t\t}),\n\t\tclose: async () => {\n\t\t\tawait installHost.close();\n\t\t\tawait acquisitionHost.close();\n\t\t\tawait distributionHost?.close();\n\t\t},\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"default-plugin-market.js","sourceRoot":"","sources":["../../../src/plugins/ecosystem/default-plugin-market.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,0BAA0B,CAAC;AAE7C,OAAO,EACN,4BAA4B,EAC5B,wBAAwB,EACxB,oCAAoC,EACpC,uCAAuC,GACvC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,0BAA0B,EAA6B,MAAM,mBAAmB,CAAC;AAC1F,OAAO,EAAE,uBAAuB,EAA0B,MAAM,gBAAgB,CAAC;AACjF,OAAO,EAAE,oCAAoC,EAAE,MAAM,gCAAgC,CAAC;AACtF,OAAO,EACN,sCAAsC,GAEtC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACN,8BAA8B,EAC9B,yBAAyB,GAEzB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,iCAAiC,EAAoC,MAAM,mCAAmC,CAAC;AACxH,OAAO,EAAE,2BAA2B,EAAiC,MAAM,6BAA6B,CAAC;AACzG,OA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E,0BAA0B,CAAC,EAAE,IAAI,EAAE,gBAAgB,CAAC,IAAI,EAAE,eAAe,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;QAC7G,UAAU,EAAE,wBAAwB,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,4BAA4B,CAAC,EAAE,CAAC;QACxG,iBAAiB,EAAE,wBAAwB,CAAC;YAC3C,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,eAAe,EAAE,4BAA4B,CAAC;SAC1E,CAAC;QACF,KAAK,EAAE,KAAK,IAAI,EAAE,CAAC;YAClB,MAAM,WAAW,CAAC,KAAK,EAAE,CAAC;YAC1B,MAAM,eAAe,CAAC,KAAK,EAAE,CAAC;YAC9B,MAAM,gBAAgB,EAAE,KAAK,EAAE,CAAC;QAAA,CAChC;KACD,CAAC;AAAA,CACF","sourcesContent":["/**\n * Default CLI wiring for the plugin marketplace write side (P1-5): one\n * factory composes the disk install store, an optional HTTP registry origin,\n * the HTTP distribution host, and the persistent package install host into\n * the registry/installer/distribution surfaces the ecosystem CLI and the TUI\n * manager consume. Nothing here discovers keys or origins implicitly: the\n * registry origin comes from an explicit option or the\n * AGENT_FORGE_PLUGIN_REGISTRY_ORIGIN environment variable, and its absence\n * keeps disk-only semantics (install resolves to not_found, remove/rollback\n * and state management stay fully usable). Host injection always wins; the\n * factory is only invoked when no host-supplied boundary exists.\n */\n\nimport { join } from \"node:path\";\nimport { CONFIG_DIR_NAME } from \"../../config.ts\";\nimport { t } from \"../../core/i18n/index.ts\";\nimport type { PluginEcosystemRegistryV1 } from \"./cli.ts\";\nimport {\n\tDEFAULT_PLUGIN_STATE_FILE_V1,\n\tdefaultPluginHostFactsV1,\n\tdefaultPluginInstallStoreDirectoryV1,\n\tdefaultPluginInstallStoreInstanceRootV1,\n} from \"./default-active-bindings.ts\";\nimport { createPluginDistributionV1, type PluginDistributionV1 } from \"./distribution.ts\";\nimport { createPluginInstallerV1, type PluginInstallerV1 } from \"./installer.ts\";\nimport { createNodeDiskPluginRegistrySourceV1 } from \"./node-disk-registry-source.ts\";\nimport {\n\tcreateNodeHttpPluginDistributionHostV1,\n\ttype NodeHttpPluginDistributionHostV1,\n} from \"./node-distribution-host.ts\";\nimport {\n\tcreateNodePackageInstallHostV1,\n\tNodePackageInstallErrorV1,\n\ttype NodeZipPackageLimitsV1,\n} from \"./node-package-install-host.ts\";\nimport { createNodePluginAcquisitionHostV1, type NodePluginAcquisitionHostV1 } from \"./node-plugin-acquisition-host.ts\";\nimport { createNodePluginTrustRootV1, type NodePluginTrustRootKeyV1 } from \"./node-plugin-trust-root.ts\";\nimport { createNodeHttpPluginRegistrySourceV1 } from \"./node-registry-source.ts\";\nimport { createPluginRegistryV1, type PluginRegistrySourceV1, type PluginRegistryV1 } from \"./registry.ts\";\nimport { createPluginEcosystemRegistryAdapterV1 } from \"./registry-cli-adapter.ts\";\nimport { createPluginStateStoreV1, type PluginStateStoreV1 } from \"./state.ts\";\n\n/** Environment variable carrying the exact http(s) marketplace origin. */\nexport const DEFAULT_PLUGIN_REGISTRY_ORIGIN_ENV_V1 = \"AGENT_FORGE_PLUGIN_REGISTRY_ORIGIN\";\n\n/**\n * Environment variable carrying the Ed25519 trust root as a JSON array of\n * `{keyId, publicKeyPem}` entries. Downloads never verify without an explicit\n * trust root; there is no implicit key discovery.\n */\nexport const DEFAULT_PLUGIN_TRUST_KEYS_ENV_V1 = \"AGENT_FORGE_PLUGIN_TRUST_KEYS\";\n\n/** Registry document path below the configured origin. */\nexport const DEFAULT_PLUGIN_REGISTRY_PATH_V1 = \"/v1/plugin-registry.json\";\n\nexport interface DefaultPluginMarketOptionsV1 {\n\treadonly agentDir: string;\n\treadonly cwd: string;\n\t/** Exact http(s) registry origin; defaults to the environment variable. */\n\treadonly registryOrigin?: string;\n\t/** Explicit Ed25519 trust root; defaults to the environment variable. */\n\treadonly trustKeys?: readonly NodePluginTrustRootKeyV1[];\n\t/** Optional acquisition host override (tests); defaults to a real Node host. */\n\treadonly acquisition?: NodePluginAcquisitionHostV1;\n\t/** Optional package limits shared by acquisition and the install host; defaults apply. */\n\treadonly limits?: NodeZipPackageLimitsV1;\n\t/** Deterministic fetch replacement for tests. */\n\treadonly fetch?: typeof globalThis.fetch;\n}\n\nexport interface DefaultPluginMarketWiringV1 {\n\t/** Verified registry for the manager controller snapshot. */\n\treadonly registry: PluginRegistryV1;\n\t/** CLI-facing adapter over the same verified registry. */\n\treadonly cliRegistry: PluginEcosystemRegistryV1;\n\t/** Multi-source acquisition boundary for `plugin install <ref>`. */\n\treadonly acquisition: NodePluginAcquisitionHostV1;\n\treadonly installer: PluginInstallerV1;\n\t/** Present only when a registry origin is configured. */\n\treadonly distribution?: PluginDistributionV1;\n\treadonly stateStore: PluginStateStoreV1;\n\treadonly projectStateStore: PluginStateStoreV1;\n\t/** Releases the distribution host's cached artifacts when present. */\n\treadonly close: () => Promise<void>;\n}\n\n/**\n * Compose the default marketplace boundaries over one agent directory. The\n * disk install store is always part of the registry so installed plugins can\n * be listed, updated, and removed offline; a configured origin adds the HTTP\n * registry and package download. Installation failures surface structured\n * errors, never synthetic success.\n */\nexport async function createDefaultPluginMarketWiringV1(\n\toptions: DefaultPluginMarketOptionsV1,\n): Promise<DefaultPluginMarketWiringV1> {\n\tconst origin = (options.registryOrigin ?? process.env[DEFAULT_PLUGIN_REGISTRY_ORIGIN_ENV_V1])?.trim();\n\tconst effectiveOrigin = origin === \"\" ? undefined : origin;\n\tconst storeParent = defaultPluginInstallStoreDirectoryV1(options.agentDir);\n\t// The install host persists under this fixed subdirectory; the disk\n\t// registry source must read the same instance root to observe installs.\n\tconst instanceRoot = defaultPluginInstallStoreInstanceRootV1(options.agentDir);\n\tconst diskSource = createNodeDiskPluginRegistrySourceV1({ rootDirectory: instanceRoot });\n\tconst httpSource =\n\t\teffectiveOrigin === undefined\n\t\t\t? undefined\n\t\t\t: createNodeHttpPluginRegistrySourceV1({\n\t\t\t\t\turl: new URL(effectiveOrigin + DEFAULT_PLUGIN_REGISTRY_PATH_V1),\n\t\t\t\t\tallowedOrigins: [effectiveOrigin],\n\t\t\t\t\t...(options.fetch === undefined ? {} : { fetch: options.fetch }),\n\t\t\t\t});\n\tconst source: PluginRegistrySourceV1 = {\n\t\t...(httpSource === undefined ? {} : { source: httpSource.source }),\n\t\tlist: async ({ signal } = {}) => {\n\t\t\tconst disk = await diskSource.list({ signal });\n\t\t\tif (httpSource === undefined) return disk;\n\t\t\tconst remote = await httpSource.list({ signal });\n\t\t\treturn Object.freeze([...remote, ...disk]);\n\t\t},\n\t};\n\tconst distributionHost =\n\t\teffectiveOrigin === undefined\n\t\t\t? undefined\n\t\t\t: await createNodeHttpPluginDistributionHostV1({\n\t\t\t\t\tallowedOrigins: [effectiveOrigin],\n\t\t\t\t\tartifactDirectory: join(storeParent, \"distribution-cache-v1\"),\n\t\t\t\t\t...(options.fetch === undefined ? {} : { fetch: options.fetch }),\n\t\t\t\t});\n\tlet trustKeys = options.trustKeys;\n\tif (trustKeys === undefined && effectiveOrigin !== undefined) {\n\t\tconst raw = process.env[DEFAULT_PLUGIN_TRUST_KEYS_ENV_V1];\n\t\tif (raw !== undefined && raw.trim() !== \"\") {\n\t\t\tlet parsed: unknown;\n\t\t\ttry {\n\t\t\t\tparsed = JSON.parse(raw);\n\t\t\t} catch {\n\t\t\t\tthrow new Error(\n\t\t\t\t\tt(\"{env} must be a JSON array of {keyId, publicKeyPem}\", { env: DEFAULT_PLUGIN_TRUST_KEYS_ENV_V1 }),\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (!Array.isArray(parsed))\n\t\t\t\tthrow new Error(t(\"{env} must be a JSON array\", { env: DEFAULT_PLUGIN_TRUST_KEYS_ENV_V1 }));\n\t\t\ttrustKeys = parsed as NodePluginTrustRootKeyV1[];\n\t\t}\n\t}\n\tconst trustRoot =\n\t\ttrustKeys === undefined || distributionHost === undefined\n\t\t\t? undefined\n\t\t\t: createNodePluginTrustRootV1({ keys: trustKeys });\n\t// Acquisition artifacts (npm/URL/local refs) and signed distribution\n\t// artifacts share one install host; ownership decides which reader serves.\n\tconst acquisitionHost =\n\t\toptions.acquisition ??\n\t\tcreateNodePluginAcquisitionHostV1({\n\t\t\t...(options.limits === undefined ? {} : { limits: options.limits }),\n\t\t\t...(options.fetch === undefined ? {} : { fetch: options.fetch }),\n\t\t});\n\tconst openArtifact: NodeHttpPluginDistributionHostV1[\"openArtifact\"] = (input) => {\n\t\tif (acquisitionHost.ownsArtifact(input.artifact)) return acquisitionHost.openArtifact(input);\n\t\tconst reader = distributionHost?.openArtifact;\n\t\tif (reader === undefined) throw new NodePackageInstallErrorV1(\"invalid_artifact\");\n\t\treturn reader(input);\n\t};\n\tconst installHost = await createNodePackageInstallHostV1({\n\t\topenArtifact,\n\t\tinstallationDirectory: storeParent,\n\t\tpersistence: \"persistent\",\n\t\tsupportedScopes: [\"global\", \"project\"],\n\t\t...(options.limits === undefined ? {} : { ...options.limits }),\n\t});\n\tconst registry = createPluginRegistryV1({\n\t\tsource,\n\t\thost: defaultPluginHostFactsV1(),\n\t\tverify: {\n\t\t\tverify: ({ manifestDigest, expectedDigest }) =>\n\t\t\t\texpectedDigest === undefined || expectedDigest === manifestDigest\n\t\t\t\t\t? { status: \"accepted\" }\n\t\t\t\t\t: { status: \"rejected\", reason: \"Manifest digest does not match the expected digest\" },\n\t\t},\n\t\tsourceVerifier: () => ({ status: \"accepted\" }),\n\t});\n\treturn {\n\t\tregistry,\n\t\tcliRegistry: createPluginEcosystemRegistryAdapterV1(registry),\n\t\tacquisition: acquisitionHost,\n\t\tinstaller: createPluginInstallerV1({ host: installHost }),\n\t\t...(distributionHost === undefined || trustRoot === undefined\n\t\t\t? {}\n\t\t\t: { distribution: createPluginDistributionV1({ host: distributionHost.host, verifySignature: trustRoot }) }),\n\t\tstateStore: createPluginStateStoreV1({ filePath: join(options.agentDir, DEFAULT_PLUGIN_STATE_FILE_V1) }),\n\t\tprojectStateStore: createPluginStateStoreV1({\n\t\t\tfilePath: join(options.cwd, CONFIG_DIR_NAME, DEFAULT_PLUGIN_STATE_FILE_V1),\n\t\t}),\n\t\tclose: async () => {\n\t\t\tawait installHost.close();\n\t\t\tawait acquisitionHost.close();\n\t\t\tawait distributionHost?.close();\n\t\t},\n\t};\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"distribution.d.ts","sourceRoot":"","sources":["../../../src/plugins/ecosystem/distribution.ts"],"names":[],"mappings":"AAEA,sFAAsF;AACtF,eAAO,MAAM,uCAAuC,GAAa,CAAC;AAElE,yEAAyE;AACzE,eAAO,MAAM,2CAA2C,QAAY,CAAC;AACrE,iFAAiF;AACjF,eAAO,MAAM,sCAAsC,OAAO,CAAC;AAC3D,2DAA2D;AAC3D,eAAO,MAAM,yCAAyC,QAAY,CAAC;AACnE,6CAA6C;AAC7C,eAAO,MAAM,6CAA6C,OAAO,CAAC;AAClE,8FAA8F;AAC9F,eAAO,MAAM,yCAAyC,QAAoB,CAAC;AAE3E,wFAAwF;AACxF,MAAM,WAAW,8BAA8B;IAC9C,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC3B;AAED,mEAAmE;AACnE,MAAM,WAAW,4BAA4B;IAC5C,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IACpB,QAAQ,CAAC,MAAM,EA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BAA8B,CAAC;IACnE,eAAe,CAAC,KAAK,EAAE;QAAE,UAAU,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;IAC7G,eAAe,CAAC,KAAK,EAAE;QACtB,UAAU,EAAE,OAAO,CAAC;QACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,MAAM,CAAC,EAAE,WAAW,CAAC;KACrB,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;IAC1C,eAAe,CAAC,KAAK,EAAE;QAAE,QAAQ,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnF;AAuPD,kGAAkG;AAClG,wBAAgB,0BAA0B,CAAC,OAAO,GAAE,2BAAgC,GAAG,oBAAoB,CAkG1G","sourcesContent":["import { detachedFreeze, isPlainRecord } from \"@agent-forge/plugin-sdk\";\n\n/** Distribution contract version. The host and package must agree on this version. */\nexport const PLUGIN_DISTRIBUTION_CONTRACT_VERSION_V1 = 1 as const;\n\n/** Maximum serialized descriptor size crossing the registry boundary. */\nexport const MAX_PLUGIN_DISTRIBUTION_DESCRIPTOR_BYTES_V1 = 16 * 1024;\n/** Maximum length of identity, URI, digest, signature, and media-type fields. */\nexport const MAX_PLUGIN_DISTRIBUTION_FIELD_CHARS_V1 = 2048;\n/** Maximum descriptor metadata size returned by a host. */\nexport const MAX_PLUGIN_DISTRIBUTION_METADATA_BYTES_V1 = 16 * 1024;\n/** Maximum opaque artifact handle length. */\nexport const MAX_PLUGIN_DISTRIBUTION_ARTIFACT_REF_CHARS_V1 = 2048;\n/** Maximum package size accepted by this contract. Larger artifacts need a newer contract. */\nexport const MAX_PLUGIN_DISTRIBUTION_ARTIFACT_BYTES_V1 = 512 * 1024 * 1024;\n\n/** A signed, bounded package descriptor. It contains no package bytes or local path. */\nexport interface PluginDistributionDescriptorV1 {\n\treadonly version: 1;\n\treadonly source: string;\n\treadonly pluginId: string;\n\treadonly pluginVersion: string;\n\treadonly manifestDigest: string;\n\treadonly artifactDigest: string;\n\treadonly signature: string;\n\treadonly expiresAt: string;\n\treadonly sizeBytes: number;\n\treadonly mediaType: string;\n}\n\n/** Metadata resolved by a host before any artifact is acquired. */\nexport interface PluginDistributionMetadataV1 {\n\treadonly version: 1;\n\treadonly source: string;\n\treadonly pluginId: string;\n\treadonly pluginVersion: string;\n\treadonly manifestDigest: string;\n\treadonly artifactDigest: string;\n\treadonly expiresAt: string;\n\treadonly sizeBytes: number;\n\treadonly mediaType: string;\n}\n\n/** Host-owned acquisition result. `artifactRef` is opaque and is never a path. */\nexport interface PluginDistributionArtifactHandleV1 {\n\treadonly artifactRef: string;\n\treadonly artifactDigest: string;\n\treadonly sizeBytes: number;\n\treadonly mediaType: string;\n}\n\n/** Model-facing acquisition projection. It deliberately contains no bytes or metadata payload. */\nexport interface PluginDistributionArtifactV1 extends PluginDistributionMetadataV1 {\n\treadonly artifactRef: string;\n}\n\nexport interface PluginDistributionSignatureVerificationInputV1 {\n\treadonly descriptor: PluginDistributionDescriptorV1;\n}\n\nexport type PluginDistributionSignatureVerificationV1 =\n\t| { readonly status: \"accepted\" }\n\t| { readonly status: \"rejected\"; readonly reason?: string };\n\nexport type PluginDistributionSignatureVerifierV1 = (\n\tinput: PluginDistributionSignatureVerificationInputV1,\n) => PluginDistributionSignatureVerificationV1 | Promise<PluginDistributionSignatureVerificationV1>;\n\n/**\n * Host boundary for registry metadata and package bytes. The core never opens a\n * URL, reads a path, or receives package bytes; hosts return only bounded metadata\n * and opaque artifact references.\n */\nexport interface PluginDistributionHostV1 {\n\treadonly resolveMetadata?: (input: {\n\t\treadonly descriptor: PluginDistributionDescriptorV1;\n\t\treadonly signal?: AbortSignal;\n\t}) => Promise<PluginDistributionMetadataV1>;\n\treadonly acquireArtifact?: (input: {\n\t\treadonly descriptor: PluginDistributionDescriptorV1;\n\t\treadonly metadata: PluginDistributionMetadataV1;\n\t\treadonly signal?: AbortSignal;\n\t}) => Promise<PluginDistributionArtifactHandleV1>;\n\treadonly releaseArtifact?: (input: {\n\t\treadonly artifact: PluginDistributionArtifactV1;\n\t\treadonly signal?: AbortSignal;\n\t}) => Promise<void>;\n}\n\nexport interface PluginDistributionOptionsV1 {\n\treadonly host?: PluginDistributionHostV1;\n\t/** Required for trust. There is no implicit signature acceptance fallback. */\n\treadonly verifySignature?: PluginDistributionSignatureVerifierV1;\n\t/** Alias for callers using the registry verifier naming. */\n\treadonly verify?: PluginDistributionSignatureVerifierV1;\n\t/** Injected clock for deterministic tests; returns epoch milliseconds. */\n\treadonly now?: () => number;\n}\n\nexport type PluginDistributionErrorCodeV1 =\n\t| \"unsupported\"\n\t| \"cancelled\"\n\t| \"invalid_descriptor\"\n\t| \"invalid_metadata\"\n\t| \"invalid_artifact\"\n\t| \"source_mismatch\"\n\t| \"identity_mismatch\"\n\t| \"digest_mismatch\"\n\t| \"signature_invalid\"\n\t| \"expired\"\n\t| \"size_mismatch\"\n\t| \"media_type_mismatch\"\n\t| \"host_failed\"\n\t| \"release_failed\";\n\nconst ERROR_MESSAGES: Readonly<Record<PluginDistributionErrorCodeV1, string>> = {\n\tunsupported: \"Plugin distribution is unsupported on this host\",\n\tcancelled: \"Plugin distribution operation was cancelled\",\n\tinvalid_descriptor: \"Plugin distribution descriptor is invalid\",\n\tinvalid_metadata: \"Plugin distribution metadata is invalid\",\n\tinvalid_artifact: \"Plugin distribution artifact handle is invalid\",\n\tsource_mismatch: \"Plugin distribution source does not match the descriptor\",\n\tidentity_mismatch: \"Plugin distribution plugin identity does not match the descriptor\",\n\tdigest_mismatch: \"Plugin distribution digest does not match the descriptor\",\n\tsignature_invalid: \"Plugin distribution signature was rejected\",\n\texpired: \"Plugin distribution descriptor has expired\",\n\tsize_mismatch: \"Plugin distribution size does not match the descriptor\",\n\tmedia_type_mismatch: \"Plugin distribution media type does not match the descriptor\",\n\thost_failed: \"Plugin distribution host operation failed\",\n\trelease_failed: \"Plugin distribution artifact release failed\",\n};\n\n/** Stable, non-leaking distribution error. Host exception messages are never retained. */\nexport class PluginDistributionErrorV1 extends Error {\n\treadonly code: PluginDistributionErrorCodeV1;\n\n\tconstructor(code: PluginDistributionErrorCodeV1) {\n\t\tsuper(ERROR_MESSAGES[code]);\n\t\tthis.name = \"PluginDistributionErrorV1\";\n\t\tthis.code = code;\n\t}\n}\n\nexport interface PluginDistributionV1 {\n\t/** Validate and detach a descriptor before passing it to a host or verifier. */\n\tvalidateDescriptor(input: unknown): PluginDistributionDescriptorV1;\n\tresolveMetadata(input: { descriptor: unknown; signal?: AbortSignal }): Promise<PluginDistributionMetadataV1>;\n\tacquireArtifact(input: {\n\t\tdescriptor: unknown;\n\t\tmetadata?: unknown;\n\t\tsignal?: AbortSignal;\n\t}): Promise<PluginDistributionArtifactV1>;\n\treleaseArtifact(input: { artifact: unknown; signal?: AbortSignal }): Promise<void>;\n}\n\nconst DESCRIPTOR_KEYS = [\n\t\"version\",\n\t\"source\",\n\t\"pluginId\",\n\t\"pluginVersion\",\n\t\"manifestDigest\",\n\t\"artifactDigest\",\n\t\"signature\",\n\t\"expiresAt\",\n\t\"sizeBytes\",\n\t\"mediaType\",\n] as const;\nconst METADATA_KEYS = [\n\t\"version\",\n\t\"source\",\n\t\"pluginId\",\n\t\"pluginVersion\",\n\t\"manifestDigest\",\n\t\"artifactDigest\",\n\t\"expiresAt\",\n\t\"sizeBytes\",\n\t\"mediaType\",\n] as const;\nconst ARTIFACT_KEYS = [\"artifactRef\", \"artifactDigest\", \"sizeBytes\", \"mediaType\"] as const;\n\nfunction reject(code: PluginDistributionErrorCodeV1): never {\n\tthrow new PluginDistributionErrorV1(code);\n}\n\nfunction hasExactKeys(value: Record<string, unknown>, keys: readonly string[]): boolean {\n\tconst expected = new Set(keys);\n\treturn (\n\t\tObject.keys(value).every((key) => expected.has(key) && expected.size === keys.length) &&\n\t\tkeys.every((key) => key in value)\n\t);\n}\n\nfunction boundedString(value: unknown, code: PluginDistributionErrorCodeV1): string {\n\tif (\n\t\ttypeof value !== \"string\" ||\n\t\tvalue.trim().length === 0 ||\n\t\tvalue.length > MAX_PLUGIN_DISTRIBUTION_FIELD_CHARS_V1 ||\n\t\t/[\\u0000-\\u001f\\u007f]/u.test(value)\n\t) {\n\t\treject(code);\n\t}\n\treturn value;\n}\n\nfunction identityString(value: unknown, code: PluginDistributionErrorCodeV1): string {\n\tconst result = boundedString(value, code);\n\tif (/\\s/u.test(result)) reject(code);\n\treturn result;\n}\n\nfunction sourceString(value: unknown, code: PluginDistributionErrorCodeV1): string {\n\tconst source = boundedString(value, code);\n\tif (/\\s/u.test(source) || /^(?:file:|[a-zA-Z]:[\\\\/]|[\\\\/]{1,2}|\\\\\\\\)/iu.test(source)) reject(code);\n\tif (/^https?:\\/\\//iu.test(source)) {\n\t\ttry {\n\t\t\tconst parsed = new URL(source);\n\t\t\tif (parsed.username !== \"\" || parsed.password !== \"\") {\n\t\t\t\tparsed.username = \"\";\n\t\t\t\tparsed.password = \"\";\n\t\t\t}\n\t\t\tparsed.search = \"\";\n\t\t\tparsed.hash = \"\";\n\t\t\tconst pathname = parsed.pathname.length > 512 ? `${parsed.pathname.slice(0, 509)}...` : parsed.pathname;\n\t\t\treturn `${parsed.origin}${pathname || \"/\"}`;\n\t\t} catch {\n\t\t\treject(code);\n\t\t}\n\t}\n\treturn source;\n}\n\nfunction digestString(value: unknown, code: PluginDistributionErrorCodeV1): string {\n\tconst digest = identityString(value, code);\n\t// Hosts may use a cryptographic digest or a versioned digest token. The\n\t// boundary validates shape and equality; only the host can verify bytes.\n\tif (!/^(?:[a-z][a-z0-9+.-]{0,15}:[A-Za-z0-9._~-]{1,128}|[0-9a-f]{16,128})$/u.test(digest)) reject(code);\n\treturn digest;\n}\n\nfunction signatureString(value: unknown): string {\n\tconst signature = boundedString(value, \"invalid_descriptor\");\n\tif (signature.length > 512 || /\\s/u.test(signature)) reject(\"invalid_descriptor\");\n\treturn signature;\n}\n\nfunction expiryString(value: unknown, code: PluginDistributionErrorCodeV1): string {\n\tconst expiry = boundedString(value, code);\n\tif (!/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{3})?Z$/u.test(expiry)) reject(code);\n\tconst timestamp = Date.parse(expiry);\n\tif (!Number.isFinite(timestamp) || new Date(timestamp).toISOString() !== expiry) reject(code);\n\treturn expiry;\n}\n\nfunction positiveSize(value: unknown, code: PluginDistributionErrorCodeV1): number {\n\tif (\n\t\ttypeof value !== \"number\" ||\n\t\t!Number.isSafeInteger(value) ||\n\t\tvalue < 1 ||\n\t\tvalue > MAX_PLUGIN_DISTRIBUTION_ARTIFACT_BYTES_V1\n\t)\n\t\treject(code);\n\treturn value;\n}\n\nfunction mediaTypeString(value: unknown, code: PluginDistributionErrorCodeV1): string {\n\tconst mediaType = boundedString(value, code).toLowerCase();\n\tif (\n\t\tmediaType.length > 256 ||\n\t\t!/^[a-z0-9!#$&^_.+-]+\\/[a-z0-9!#$&^_.+-]+(?:\\s*;\\s*[a-z0-9!#$&^_.+-]+=[a-z0-9!#$&^_.+-]+)*$/u.test(mediaType)\n\t)\n\t\treject(code);\n\treturn mediaType;\n}\n\nfunction serializedBytes(value: unknown, code: PluginDistributionErrorCodeV1): number {\n\ttry {\n\t\tconst serialized = JSON.stringify(value);\n\t\tif (serialized === undefined) reject(code);\n\t\treturn new TextEncoder().encode(serialized).byteLength;\n\t} catch {\n\t\treject(code);\n\t}\n}\n\nfunction descriptorValue(value: unknown): PluginDistributionDescriptorV1 {\n\tif (!isPlainRecord(value) || !hasExactKeys(value, DESCRIPTOR_KEYS)) reject(\"invalid_descriptor\");\n\tif (value.version !== PLUGIN_DISTRIBUTION_CONTRACT_VERSION_V1) reject(\"invalid_descriptor\");\n\tconst descriptor = {\n\t\tversion: PLUGIN_DISTRIBUTION_CONTRACT_VERSION_V1,\n\t\tsource: sourceString(value.source, \"invalid_descriptor\"),\n\t\tpluginId: identityString(value.pluginId, \"invalid_descriptor\"),\n\t\tpluginVersion: identityString(value.pluginVersion, \"invalid_descriptor\"),\n\t\tmanifestDigest: digestString(value.manifestDigest, \"invalid_descriptor\"),\n\t\tartifactDigest: digestString(value.artifactDigest, \"invalid_descriptor\"),\n\t\tsignature: signatureString(value.signature),\n\t\texpiresAt: expiryString(value.expiresAt, \"invalid_descriptor\"),\n\t\tsizeBytes: positiveSize(value.sizeBytes, \"invalid_descriptor\"),\n\t\tmediaType: mediaTypeString(value.mediaType, \"invalid_descriptor\"),\n\t};\n\tif (serializedBytes(descriptor, \"invalid_descriptor\") > MAX_PLUGIN_DISTRIBUTION_DESCRIPTOR_BYTES_V1)\n\t\treject(\"invalid_descriptor\");\n\treturn detachedFreeze(descriptor);\n}\n\nfunction metadataValue(value: unknown): PluginDistributionMetadataV1 {\n\tif (!isPlainRecord(value) || !hasExactKeys(value, METADATA_KEYS)) reject(\"invalid_metadata\");\n\tif (value.version !== PLUGIN_DISTRIBUTION_CONTRACT_VERSION_V1) reject(\"invalid_metadata\");\n\tconst metadata = {\n\t\tversion: PLUGIN_DISTRIBUTION_CONTRACT_VERSION_V1,\n\t\tsource: sourceString(value.source, \"invalid_metadata\"),\n\t\tpluginId: identityString(value.pluginId, \"invalid_metadata\"),\n\t\tpluginVersion: identityString(value.pluginVersion, \"invalid_metadata\"),\n\t\tmanifestDigest: digestString(value.manifestDigest, \"invalid_metadata\"),\n\t\tartifactDigest: digestString(value.artifactDigest, \"invalid_metadata\"),\n\t\texpiresAt: expiryString(value.expiresAt, \"invalid_metadata\"),\n\t\tsizeBytes: positiveSize(value.sizeBytes, \"invalid_metadata\"),\n\t\tmediaType: mediaTypeString(value.mediaType, \"invalid_metadata\"),\n\t};\n\tif (serializedBytes(metadata, \"invalid_metadata\") > MAX_PLUGIN_DISTRIBUTION_METADATA_BYTES_V1)\n\t\treject(\"invalid_metadata\");\n\treturn detachedFreeze(metadata);\n}\n\nfunction artifactHandleValue(value: unknown): PluginDistributionArtifactHandleV1 {\n\tif (!isPlainRecord(value) || !hasExactKeys(value, ARTIFACT_KEYS)) reject(\"invalid_artifact\");\n\tconst artifact = {\n\t\tartifactRef: boundedString(value.artifactRef, \"invalid_artifact\"),\n\t\tartifactDigest: digestString(value.artifactDigest, \"invalid_artifact\"),\n\t\tsizeBytes: positiveSize(value.sizeBytes, \"invalid_artifact\"),\n\t\tmediaType: mediaTypeString(value.mediaType, \"invalid_artifact\"),\n\t};\n\tif (\n\t\t/[\\s\\u0000-\\u001f\\u007f]/u.test(artifact.artifactRef) ||\n\t\t/^(?:file:|[a-zA-Z]:[\\\\/]|[\\\\/]{1,2}|\\\\\\\\)/iu.test(artifact.artifactRef) ||\n\t\tartifact.artifactRef.length > MAX_PLUGIN_DISTRIBUTION_ARTIFACT_REF_CHARS_V1\n\t)\n\t\treject(\"invalid_artifact\");\n\treturn detachedFreeze(artifact);\n}\n\nfunction assertDescriptorMetadataMatch(\n\tdescriptor: PluginDistributionDescriptorV1,\n\tmetadata: PluginDistributionMetadataV1,\n): void {\n\tif (metadata.source !== descriptor.source) reject(\"source_mismatch\");\n\tif (metadata.pluginId !== descriptor.pluginId || metadata.pluginVersion !== descriptor.pluginVersion)\n\t\treject(\"identity_mismatch\");\n\tif (metadata.manifestDigest !== descriptor.manifestDigest || metadata.artifactDigest !== descriptor.artifactDigest)\n\t\treject(\"digest_mismatch\");\n\tif (metadata.expiresAt !== descriptor.expiresAt) reject(\"expired\");\n\tif (metadata.sizeBytes !== descriptor.sizeBytes) reject(\"size_mismatch\");\n\tif (metadata.mediaType !== descriptor.mediaType) reject(\"media_type_mismatch\");\n}\n\nfunction assertArtifactMatch(\n\tdescriptor: PluginDistributionDescriptorV1,\n\tartifact: PluginDistributionArtifactHandleV1,\n): void {\n\tif (artifact.artifactDigest !== descriptor.artifactDigest) reject(\"digest_mismatch\");\n\tif (artifact.sizeBytes !== descriptor.sizeBytes) reject(\"size_mismatch\");\n\tif (artifact.mediaType !== descriptor.mediaType) reject(\"media_type_mismatch\");\n}\n\nfunction isCancelled(error: unknown, signal: AbortSignal | undefined): boolean {\n\treturn (\n\t\tsignal?.aborted === true ||\n\t\t(error instanceof Error && (error.name === \"AbortError\" || error.name === \"AbortSignalError\"))\n\t);\n}\n\nfunction assertNotExpired(descriptor: PluginDistributionDescriptorV1, now: () => number): void {\n\tlet current: number;\n\ttry {\n\t\tcurrent = now();\n\t} catch {\n\t\treject(\"expired\");\n\t}\n\tif (!Number.isFinite(current)) reject(\"expired\");\n\tif (Date.parse(descriptor.expiresAt) <= current) reject(\"expired\");\n}\n\nasync function verifyDescriptor(\n\tdescriptor: PluginDistributionDescriptorV1,\n\tverifySignature: PluginDistributionSignatureVerifierV1 | undefined,\n\tnow: () => number,\n\tsignal: AbortSignal | undefined,\n): Promise<void> {\n\tif (signal?.aborted) reject(\"cancelled\");\n\tassertNotExpired(descriptor, now);\n\tif (verifySignature === undefined) reject(\"unsupported\");\n\tlet verification: PluginDistributionSignatureVerificationV1;\n\ttry {\n\t\tverification = await verifySignature({ descriptor });\n\t} catch {\n\t\treject(\"signature_invalid\");\n\t}\n\tif (signal?.aborted) reject(\"cancelled\");\n\tif (!isPlainRecord(verification) || verification.status !== \"accepted\") reject(\"signature_invalid\");\n}\n\n/** Create a host-injected distribution client. No host means all side effects are unsupported. */\nexport function createPluginDistributionV1(options: PluginDistributionOptionsV1 = {}): PluginDistributionV1 {\n\tconst verifySignature = options.verifySignature ?? options.verify;\n\tconst now = options.now ?? (() => Date.now());\n\tconst resolveMetadataForDescriptor = async (\n\t\tdescriptor: PluginDistributionDescriptorV1,\n\t\tsignal: AbortSignal | undefined,\n\t): Promise<PluginDistributionMetadataV1> => {\n\t\tif (signal?.aborted) reject(\"cancelled\");\n\t\tif (options.host?.resolveMetadata === undefined) reject(\"unsupported\");\n\t\tlet result: PluginDistributionMetadataV1;\n\t\ttry {\n\t\t\tresult = await options.host.resolveMetadata({ descriptor, signal });\n\t\t} catch (error) {\n\t\t\tif (isCancelled(error, signal)) reject(\"cancelled\");\n\t\t\treject(\"host_failed\");\n\t\t}\n\t\tif (signal?.aborted) reject(\"cancelled\");\n\t\tconst metadata = metadataValue(result);\n\t\tassertDescriptorMetadataMatch(descriptor, metadata);\n\t\tassertNotExpired(descriptor, now);\n\t\treturn metadata;\n\t};\n\n\tconst resolveMetadata = async (input: {\n\t\tdescriptor: unknown;\n\t\tsignal?: AbortSignal;\n\t}): Promise<PluginDistributionMetadataV1> => {\n\t\tconst descriptor = descriptorValue(input.descriptor);\n\t\tawait verifyDescriptor(descriptor, verifySignature, now, input.signal);\n\t\treturn resolveMetadataForDescriptor(descriptor, input.signal);\n\t};\n\n\tconst acquireArtifact = async (input: {\n\t\tdescriptor: unknown;\n\t\tmetadata?: unknown;\n\t\tsignal?: AbortSignal;\n\t}): Promise<PluginDistributionArtifactV1> => {\n\t\tconst descriptor = descriptorValue(input.descriptor);\n\t\tawait verifyDescriptor(descriptor, verifySignature, now, input.signal);\n\t\tif (options.host?.acquireArtifact === undefined) reject(\"unsupported\");\n\t\tconst metadata =\n\t\t\tinput.metadata === undefined\n\t\t\t\t? await resolveMetadataForDescriptor(descriptor, input.signal)\n\t\t\t\t: metadataValue(input.metadata);\n\t\tassertDescriptorMetadataMatch(descriptor, metadata);\n\t\tassertNotExpired(descriptor, now);\n\t\tlet result: PluginDistributionArtifactHandleV1;\n\t\tlet acquired: PluginDistributionArtifactV1 | undefined;\n\t\ttry {\n\t\t\tresult = await options.host.acquireArtifact({ descriptor, metadata, signal: input.signal });\n\t\t\tconst handle = artifactHandleValue(result);\n\t\t\tacquired = detachedFreeze({ ...metadata, artifactRef: handle.artifactRef });\n\t\t\tassertArtifactMatch(descriptor, handle);\n\t\t\tassertNotExpired(descriptor, now);\n\t\t\tif (input.signal?.aborted) reject(\"cancelled\");\n\t\t\treturn acquired;\n\t\t} catch (error) {\n\t\t\tif (acquired !== undefined && options.host.releaseArtifact !== undefined) {\n\t\t\t\tawait options.host.releaseArtifact({ artifact: acquired }).catch(() => undefined);\n\t\t\t}\n\t\t\tif (error instanceof PluginDistributionErrorV1) throw error;\n\t\t\tif (isCancelled(error, input.signal)) reject(\"cancelled\");\n\t\t\treject(\"host_failed\");\n\t\t}\n\t};\n\n\tconst releaseArtifact = async (input: { artifact: unknown; signal?: AbortSignal }): Promise<void> => {\n\t\tif (input.signal?.aborted) reject(\"cancelled\");\n\t\tif (options.host?.releaseArtifact === undefined) reject(\"unsupported\");\n\t\tconst value = input.artifact;\n\t\tif (!isPlainRecord(value) || !hasExactKeys(value, [...METADATA_KEYS, \"artifactRef\"])) reject(\"invalid_artifact\");\n\t\tconst metadataInput = Object.fromEntries(METADATA_KEYS.map((key) => [key, value[key]]));\n\t\tconst artifact = {\n\t\t\t...metadataValue(metadataInput),\n\t\t\tartifactRef: artifactHandleValue({\n\t\t\t\tartifactRef: value.artifactRef,\n\t\t\t\tartifactDigest: value.artifactDigest,\n\t\t\t\tsizeBytes: value.sizeBytes,\n\t\t\t\tmediaType: value.mediaType,\n\t\t\t}).artifactRef,\n\t\t};\n\t\ttry {\n\t\t\tawait options.host.releaseArtifact({ artifact: detachedFreeze(artifact), signal: input.signal });\n\t\t} catch (error) {\n\t\t\tif (isCancelled(error, input.signal)) reject(\"cancelled\");\n\t\t\treject(\"release_failed\");\n\t\t}\n\t\tif (input.signal?.aborted) reject(\"cancelled\");\n\t};\n\n\treturn {\n\t\tvalidateDescriptor(input) {\n\t\t\treturn descriptorValue(input);\n\t\t},\n\t\tresolveMetadata,\n\t\tacquireArtifact,\n\t\treleaseArtifact,\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"distribution.d.ts","sourceRoot":"","sources":["../../../src/plugins/ecosystem/distribution.ts"],"names":[],"mappings":"AAGA,sFAAsF;AACtF,eAAO,MAAM,uCAAuC,GAAa,CAAC;AAElE,yEAAyE;AACzE,eAAO,MAAM,2CAA2C,QAAY,CAAC;AACrE,iFAAiF;AACjF,eAAO,MAAM,sCAAsC,OAAO,CAAC;A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C,CAAC;CACnF;AAuPD,kGAAkG;AAClG,wBAAgB,0BAA0B,CAAC,OAAO,GAAE,2BAAgC,GAAG,oBAAoB,CAkG1G","sourcesContent":["import { detachedFreeze, isPlainRecord } from \"@agent-forge/plugin-sdk\";\nimport { t } from \"../../core/i18n/index.ts\";\n\n/** Distribution contract version. The host and package must agree on this version. */\nexport const PLUGIN_DISTRIBUTION_CONTRACT_VERSION_V1 = 1 as const;\n\n/** Maximum serialized descriptor size crossing the registry boundary. */\nexport const MAX_PLUGIN_DISTRIBUTION_DESCRIPTOR_BYTES_V1 = 16 * 1024;\n/** Maximum length of identity, URI, digest, signature, and media-type fields. */\nexport const MAX_PLUGIN_DISTRIBUTION_FIELD_CHARS_V1 = 2048;\n/** Maximum descriptor metadata size returned by a host. */\nexport const MAX_PLUGIN_DISTRIBUTION_METADATA_BYTES_V1 = 16 * 1024;\n/** Maximum opaque artifact handle length. */\nexport const MAX_PLUGIN_DISTRIBUTION_ARTIFACT_REF_CHARS_V1 = 2048;\n/** Maximum package size accepted by this contract. Larger artifacts need a newer contract. */\nexport const MAX_PLUGIN_DISTRIBUTION_ARTIFACT_BYTES_V1 = 512 * 1024 * 1024;\n\n/** A signed, bounded package descriptor. It contains no package bytes or local path. */\nexport interface PluginDistributionDescriptorV1 {\n\treadonly version: 1;\n\treadonly source: string;\n\treadonly pluginId: string;\n\treadonly pluginVersion: string;\n\treadonly manifestDigest: string;\n\treadonly artifactDigest: string;\n\treadonly signature: string;\n\treadonly expiresAt: string;\n\treadonly sizeBytes: number;\n\treadonly mediaType: string;\n}\n\n/** Metadata resolved by a host before any artifact is acquired. */\nexport interface PluginDistributionMetadataV1 {\n\treadonly version: 1;\n\treadonly source: string;\n\treadonly pluginId: string;\n\treadonly pluginVersion: string;\n\treadonly manifestDigest: string;\n\treadonly artifactDigest: string;\n\treadonly expiresAt: string;\n\treadonly sizeBytes: number;\n\treadonly mediaType: string;\n}\n\n/** Host-owned acquisition result. `artifactRef` is opaque and is never a path. */\nexport interface PluginDistributionArtifactHandleV1 {\n\treadonly artifactRef: string;\n\treadonly artifactDigest: string;\n\treadonly sizeBytes: number;\n\treadonly mediaType: string;\n}\n\n/** Model-facing acquisition projection. It deliberately contains no bytes or metadata payload. */\nexport interface PluginDistributionArtifactV1 extends PluginDistributionMetadataV1 {\n\treadonly artifactRef: string;\n}\n\nexport interface PluginDistributionSignatureVerificationInputV1 {\n\treadonly descriptor: PluginDistributionDescriptorV1;\n}\n\nexport type PluginDistributionSignatureVerificationV1 =\n\t| { readonly status: \"accepted\" }\n\t| { readonly status: \"rejected\"; readonly reason?: string };\n\nexport type PluginDistributionSignatureVerifierV1 = (\n\tinput: PluginDistributionSignatureVerificationInputV1,\n) => PluginDistributionSignatureVerificationV1 | Promise<PluginDistributionSignatureVerificationV1>;\n\n/**\n * Host boundary for registry metadata and package bytes. The core never opens a\n * URL, reads a path, or receives package bytes; hosts return only bounded metadata\n * and opaque artifact references.\n */\nexport interface PluginDistributionHostV1 {\n\treadonly resolveMetadata?: (input: {\n\t\treadonly descriptor: PluginDistributionDescriptorV1;\n\t\treadonly signal?: AbortSignal;\n\t}) => Promise<PluginDistributionMetadataV1>;\n\treadonly acquireArtifact?: (input: {\n\t\treadonly descriptor: PluginDistributionDescriptorV1;\n\t\treadonly metadata: PluginDistributionMetadataV1;\n\t\treadonly signal?: AbortSignal;\n\t}) => Promise<PluginDistributionArtifactHandleV1>;\n\treadonly releaseArtifact?: (input: {\n\t\treadonly artifact: PluginDistributionArtifactV1;\n\t\treadonly signal?: AbortSignal;\n\t}) => Promise<void>;\n}\n\nexport interface PluginDistributionOptionsV1 {\n\treadonly host?: PluginDistributionHostV1;\n\t/** Required for trust. There is no implicit signature acceptance fallback. */\n\treadonly verifySignature?: PluginDistributionSignatureVerifierV1;\n\t/** Alias for callers using the registry verifier naming. */\n\treadonly verify?: PluginDistributionSignatureVerifierV1;\n\t/** Injected clock for deterministic tests; returns epoch milliseconds. */\n\treadonly now?: () => number;\n}\n\nexport type PluginDistributionErrorCodeV1 =\n\t| \"unsupported\"\n\t| \"cancelled\"\n\t| \"invalid_descriptor\"\n\t| \"invalid_metadata\"\n\t| \"invalid_artifact\"\n\t| \"source_mismatch\"\n\t| \"identity_mismatch\"\n\t| \"digest_mismatch\"\n\t| \"signature_invalid\"\n\t| \"expired\"\n\t| \"size_mismatch\"\n\t| \"media_type_mismatch\"\n\t| \"host_failed\"\n\t| \"release_failed\";\n\nconst ERROR_MESSAGES: Readonly<Record<PluginDistributionErrorCodeV1, string>> = {\n\tunsupported: \"Plugin distribution is unsupported on this host\",\n\tcancelled: \"Plugin distribution operation was cancelled\",\n\tinvalid_descriptor: \"Plugin distribution descriptor is invalid\",\n\tinvalid_metadata: \"Plugin distribution metadata is invalid\",\n\tinvalid_artifact: \"Plugin distribution artifact handle is invalid\",\n\tsource_mismatch: \"Plugin distribution source does not match the descriptor\",\n\tidentity_mismatch: \"Plugin distribution plugin identity does not match the descriptor\",\n\tdigest_mismatch: \"Plugin distribution digest does not match the descriptor\",\n\tsignature_invalid: \"Plugin distribution signature was rejected\",\n\texpired: \"Plugin distribution descriptor has expired\",\n\tsize_mismatch: \"Plugin distribution size does not match the descriptor\",\n\tmedia_type_mismatch: \"Plugin distribution media type does not match the descriptor\",\n\thost_failed: \"Plugin distribution host operation failed\",\n\trelease_failed: \"Plugin distribution artifact release failed\",\n};\n\n/** Stable, non-leaking distribution error. Host exception messages are never retained. */\nexport class PluginDistributionErrorV1 extends Error {\n\treadonly code: PluginDistributionErrorCodeV1;\n\n\tconstructor(code: PluginDistributionErrorCodeV1) {\n\t\tsuper(t(ERROR_MESSAGES[code]));\n\t\tthis.name = \"PluginDistributionErrorV1\";\n\t\tthis.code = code;\n\t}\n}\n\nexport interface PluginDistributionV1 {\n\t/** Validate and detach a descriptor before passing it to a host or verifier. */\n\tvalidateDescriptor(input: unknown): PluginDistributionDescriptorV1;\n\tresolveMetadata(input: { descriptor: unknown; signal?: AbortSignal }): Promise<PluginDistributionMetadataV1>;\n\tacquireArtifact(input: {\n\t\tdescriptor: unknown;\n\t\tmetadata?: unknown;\n\t\tsignal?: AbortSignal;\n\t}): Promise<PluginDistributionArtifactV1>;\n\treleaseArtifact(input: { artifact: unknown; signal?: AbortSignal }): Promise<void>;\n}\n\nconst DESCRIPTOR_KEYS = [\n\t\"version\",\n\t\"source\",\n\t\"pluginId\",\n\t\"pluginVersion\",\n\t\"manifestDigest\",\n\t\"artifactDigest\",\n\t\"signature\",\n\t\"expiresAt\",\n\t\"sizeBytes\",\n\t\"mediaType\",\n] as const;\nconst METADATA_KEYS = [\n\t\"version\",\n\t\"source\",\n\t\"pluginId\",\n\t\"pluginVersion\",\n\t\"manifestDigest\",\n\t\"artifactDigest\",\n\t\"expiresAt\",\n\t\"sizeBytes\",\n\t\"mediaType\",\n] as const;\nconst ARTIFACT_KEYS = [\"artifactRef\", \"artifactDigest\", \"sizeBytes\", \"mediaType\"] as const;\n\nfunction reject(code: PluginDistributionErrorCodeV1): never {\n\tthrow new PluginDistributionErrorV1(code);\n}\n\nfunction hasExactKeys(value: Record<string, unknown>, keys: readonly string[]): boolean {\n\tconst expected = new Set(keys);\n\treturn (\n\t\tObject.keys(value).every((key) => expected.has(key) && expected.size === keys.length) &&\n\t\tkeys.every((key) => key in value)\n\t);\n}\n\nfunction boundedString(value: unknown, code: PluginDistributionErrorCodeV1): string {\n\tif (\n\t\ttypeof value !== \"string\" ||\n\t\tvalue.trim().length === 0 ||\n\t\tvalue.length > MAX_PLUGIN_DISTRIBUTION_FIELD_CHARS_V1 ||\n\t\t/[\\u0000-\\u001f\\u007f]/u.test(value)\n\t) {\n\t\treject(code);\n\t}\n\treturn value;\n}\n\nfunction identityString(value: unknown, code: PluginDistributionErrorCodeV1): string {\n\tconst result = boundedString(value, code);\n\tif (/\\s/u.test(result)) reject(code);\n\treturn result;\n}\n\nfunction sourceString(value: unknown, code: PluginDistributionErrorCodeV1): string {\n\tconst source = boundedString(value, code);\n\tif (/\\s/u.test(source) || /^(?:file:|[a-zA-Z]:[\\\\/]|[\\\\/]{1,2}|\\\\\\\\)/iu.test(source)) reject(code);\n\tif (/^https?:\\/\\//iu.test(source)) {\n\t\ttry {\n\t\t\tconst parsed = new URL(source);\n\t\t\tif (parsed.username !== \"\" || parsed.password !== \"\") {\n\t\t\t\tparsed.username = \"\";\n\t\t\t\tparsed.password = \"\";\n\t\t\t}\n\t\t\tparsed.search = \"\";\n\t\t\tparsed.hash = \"\";\n\t\t\tconst pathname = parsed.pathname.length > 512 ? `${parsed.pathname.slice(0, 509)}...` : parsed.pathname;\n\t\t\treturn `${parsed.origin}${pathname || \"/\"}`;\n\t\t} catch {\n\t\t\treject(code);\n\t\t}\n\t}\n\treturn source;\n}\n\nfunction digestString(value: unknown, code: PluginDistributionErrorCodeV1): string {\n\tconst digest = identityString(value, code);\n\t// Hosts may use a cryptographic digest or a versioned digest token. The\n\t// boundary validates shape and equality; only the host can verify bytes.\n\tif (!/^(?:[a-z][a-z0-9+.-]{0,15}:[A-Za-z0-9._~-]{1,128}|[0-9a-f]{16,128})$/u.test(digest)) reject(code);\n\treturn digest;\n}\n\nfunction signatureString(value: unknown): string {\n\tconst signature = boundedString(value, \"invalid_descriptor\");\n\tif (signature.length > 512 || /\\s/u.test(signature)) reject(\"invalid_descriptor\");\n\treturn signature;\n}\n\nfunction expiryString(value: unknown, code: PluginDistributionErrorCodeV1): string {\n\tconst expiry = boundedString(value, code);\n\tif (!/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{3})?Z$/u.test(expiry)) reject(code);\n\tconst timestamp = Date.parse(expiry);\n\tif (!Number.isFinite(timestamp) || new Date(timestamp).toISOString() !== expiry) reject(code);\n\treturn expiry;\n}\n\nfunction positiveSize(value: unknown, code: PluginDistributionErrorCodeV1): number {\n\tif (\n\t\ttypeof value !== \"number\" ||\n\t\t!Number.isSafeInteger(value) ||\n\t\tvalue < 1 ||\n\t\tvalue > MAX_PLUGIN_DISTRIBUTION_ARTIFACT_BYTES_V1\n\t)\n\t\treject(code);\n\treturn value;\n}\n\nfunction mediaTypeString(value: unknown, code: PluginDistributionErrorCodeV1): string {\n\tconst mediaType = boundedString(value, code).toLowerCase();\n\tif (\n\t\tmediaType.length > 256 ||\n\t\t!/^[a-z0-9!#$&^_.+-]+\\/[a-z0-9!#$&^_.+-]+(?:\\s*;\\s*[a-z0-9!#$&^_.+-]+=[a-z0-9!#$&^_.+-]+)*$/u.test(mediaType)\n\t)\n\t\treject(code);\n\treturn mediaType;\n}\n\nfunction serializedBytes(value: unknown, code: PluginDistributionErrorCodeV1): number {\n\ttry {\n\t\tconst serialized = JSON.stringify(value);\n\t\tif (serialized === undefined) reject(code);\n\t\treturn new TextEncoder().encode(serialized).byteLength;\n\t} catch {\n\t\treject(code);\n\t}\n}\n\nfunction descriptorValue(value: unknown): PluginDistributionDescriptorV1 {\n\tif (!isPlainRecord(value) || !hasExactKeys(value, DESCRIPTOR_KEYS)) reject(\"invalid_descriptor\");\n\tif (value.version !== PLUGIN_DISTRIBUTION_CONTRACT_VERSION_V1) reject(\"invalid_descriptor\");\n\tconst descriptor = {\n\t\tversion: PLUGIN_DISTRIBUTION_CONTRACT_VERSION_V1,\n\t\tsource: sourceString(value.source, \"invalid_descriptor\"),\n\t\tpluginId: identityString(value.pluginId, \"invalid_descriptor\"),\n\t\tpluginVersion: identityString(value.pluginVersion, \"invalid_descriptor\"),\n\t\tmanifestDigest: digestString(value.manifestDigest, \"invalid_descriptor\"),\n\t\tartifactDigest: digestString(value.artifactDigest, \"invalid_descriptor\"),\n\t\tsignature: signatureString(value.signature),\n\t\texpiresAt: expiryString(value.expiresAt, \"invalid_descriptor\"),\n\t\tsizeBytes: positiveSize(value.sizeBytes, \"invalid_descriptor\"),\n\t\tmediaType: mediaTypeString(value.mediaType, \"invalid_descriptor\"),\n\t};\n\tif (serializedBytes(descriptor, \"invalid_descriptor\") > MAX_PLUGIN_DISTRIBUTION_DESCRIPTOR_BYTES_V1)\n\t\treject(\"invalid_descriptor\");\n\treturn detachedFreeze(descriptor);\n}\n\nfunction metadataValue(value: unknown): PluginDistributionMetadataV1 {\n\tif (!isPlainRecord(value) || !hasExactKeys(value, METADATA_KEYS)) reject(\"invalid_metadata\");\n\tif (value.version !== PLUGIN_DISTRIBUTION_CONTRACT_VERSION_V1) reject(\"invalid_metadata\");\n\tconst metadata = {\n\t\tversion: PLUGIN_DISTRIBUTION_CONTRACT_VERSION_V1,\n\t\tsource: sourceString(value.source, \"invalid_metadata\"),\n\t\tpluginId: identityString(value.pluginId, \"invalid_metadata\"),\n\t\tpluginVersion: identityString(value.pluginVersion, \"invalid_metadata\"),\n\t\tmanifestDigest: digestString(value.manifestDigest, \"invalid_metadata\"),\n\t\tartifactDigest: digestString(value.artifactDigest, \"invalid_metadata\"),\n\t\texpiresAt: expiryString(value.expiresAt, \"invalid_metadata\"),\n\t\tsizeBytes: positiveSize(value.sizeBytes, \"invalid_metadata\"),\n\t\tmediaType: mediaTypeString(value.mediaType, \"invalid_metadata\"),\n\t};\n\tif (serializedBytes(metadata, \"invalid_metadata\") > MAX_PLUGIN_DISTRIBUTION_METADATA_BYTES_V1)\n\t\treject(\"invalid_metadata\");\n\treturn detachedFreeze(metadata);\n}\n\nfunction artifactHandleValue(value: unknown): PluginDistributionArtifactHandleV1 {\n\tif (!isPlainRecord(value) || !hasExactKeys(value, ARTIFACT_KEYS)) reject(\"invalid_artifact\");\n\tconst artifact = {\n\t\tartifactRef: boundedString(value.artifactRef, \"invalid_artifact\"),\n\t\tartifactDigest: digestString(value.artifactDigest, \"invalid_artifact\"),\n\t\tsizeBytes: positiveSize(value.sizeBytes, \"invalid_artifact\"),\n\t\tmediaType: mediaTypeString(value.mediaType, \"invalid_artifact\"),\n\t};\n\tif (\n\t\t/[\\s\\u0000-\\u001f\\u007f]/u.test(artifact.artifactRef) ||\n\t\t/^(?:file:|[a-zA-Z]:[\\\\/]|[\\\\/]{1,2}|\\\\\\\\)/iu.test(artifact.artifactRef) ||\n\t\tartifact.artifactRef.length > MAX_PLUGIN_DISTRIBUTION_ARTIFACT_REF_CHARS_V1\n\t)\n\t\treject(\"invalid_artifact\");\n\treturn detachedFreeze(artifact);\n}\n\nfunction assertDescriptorMetadataMatch(\n\tdescriptor: PluginDistributionDescriptorV1,\n\tmetadata: PluginDistributionMetadataV1,\n): void {\n\tif (metadata.source !== descriptor.source) reject(\"source_mismatch\");\n\tif (metadata.pluginId !== descriptor.pluginId || metadata.pluginVersion !== descriptor.pluginVersion)\n\t\treject(\"identity_mismatch\");\n\tif (metadata.manifestDigest !== descriptor.manifestDigest || metadata.artifactDigest !== descriptor.artifactDigest)\n\t\treject(\"digest_mismatch\");\n\tif (metadata.expiresAt !== descriptor.expiresAt) reject(\"expired\");\n\tif (metadata.sizeBytes !== descriptor.sizeBytes) reject(\"size_mismatch\");\n\tif (metadata.mediaType !== descriptor.mediaType) reject(\"media_type_mismatch\");\n}\n\nfunction assertArtifactMatch(\n\tdescriptor: PluginDistributionDescriptorV1,\n\tartifact: PluginDistributionArtifactHandleV1,\n): void {\n\tif (artifact.artifactDigest !== descriptor.artifactDigest) reject(\"digest_mismatch\");\n\tif (artifact.sizeBytes !== descriptor.sizeBytes) reject(\"size_mismatch\");\n\tif (artifact.mediaType !== descriptor.mediaType) reject(\"media_type_mismatch\");\n}\n\nfunction isCancelled(error: unknown, signal: AbortSignal | undefined): boolean {\n\treturn (\n\t\tsignal?.aborted === true ||\n\t\t(error instanceof Error && (error.name === \"AbortError\" || error.name === \"AbortSignalError\"))\n\t);\n}\n\nfunction assertNotExpired(descriptor: PluginDistributionDescriptorV1, now: () => number): void {\n\tlet current: number;\n\ttry {\n\t\tcurrent = now();\n\t} catch {\n\t\treject(\"expired\");\n\t}\n\tif (!Number.isFinite(current)) reject(\"expired\");\n\tif (Date.parse(descriptor.expiresAt) <= current) reject(\"expired\");\n}\n\nasync function verifyDescriptor(\n\tdescriptor: PluginDistributionDescriptorV1,\n\tverifySignature: PluginDistributionSignatureVerifierV1 | undefined,\n\tnow: () => number,\n\tsignal: AbortSignal | undefined,\n): Promise<void> {\n\tif (signal?.aborted) reject(\"cancelled\");\n\tassertNotExpired(descriptor, now);\n\tif (verifySignature === undefined) reject(\"unsupported\");\n\tlet verification: PluginDistributionSignatureVerificationV1;\n\ttry {\n\t\tverification = await verifySignature({ descriptor });\n\t} catch {\n\t\treject(\"signature_invalid\");\n\t}\n\tif (signal?.aborted) reject(\"cancelled\");\n\tif (!isPlainRecord(verification) || verification.status !== \"accepted\") reject(\"signature_invalid\");\n}\n\n/** Create a host-injected distribution client. No host means all side effects are unsupported. */\nexport function createPluginDistributionV1(options: PluginDistributionOptionsV1 = {}): PluginDistributionV1 {\n\tconst verifySignature = options.verifySignature ?? options.verify;\n\tconst now = options.now ?? (() => Date.now());\n\tconst resolveMetadataForDescriptor = async (\n\t\tdescriptor: PluginDistributionDescriptorV1,\n\t\tsignal: AbortSignal | undefined,\n\t): Promise<PluginDistributionMetadataV1> => {\n\t\tif (signal?.aborted) reject(\"cancelled\");\n\t\tif (options.host?.resolveMetadata === undefined) reject(\"unsupported\");\n\t\tlet result: PluginDistributionMetadataV1;\n\t\ttry {\n\t\t\tresult = await options.host.resolveMetadata({ descriptor, signal });\n\t\t} catch (error) {\n\t\t\tif (isCancelled(error, signal)) reject(\"cancelled\");\n\t\t\treject(\"host_failed\");\n\t\t}\n\t\tif (signal?.aborted) reject(\"cancelled\");\n\t\tconst metadata = metadataValue(result);\n\t\tassertDescriptorMetadataMatch(descriptor, metadata);\n\t\tassertNotExpired(descriptor, now);\n\t\treturn metadata;\n\t};\n\n\tconst resolveMetadata = async (input: {\n\t\tdescriptor: unknown;\n\t\tsignal?: AbortSignal;\n\t}): Promise<PluginDistributionMetadataV1> => {\n\t\tconst descriptor = descriptorValue(input.descriptor);\n\t\tawait verifyDescriptor(descriptor, verifySignature, now, input.signal);\n\t\treturn resolveMetadataForDescriptor(descriptor, input.signal);\n\t};\n\n\tconst acquireArtifact = async (input: {\n\t\tdescriptor: unknown;\n\t\tmetadata?: unknown;\n\t\tsignal?: AbortSignal;\n\t}): Promise<PluginDistributionArtifactV1> => {\n\t\tconst descriptor = descriptorValue(input.descriptor);\n\t\tawait verifyDescriptor(descriptor, verifySignature, now, input.signal);\n\t\tif (options.host?.acquireArtifact === undefined) reject(\"unsupported\");\n\t\tconst metadata =\n\t\t\tinput.metadata === undefined\n\t\t\t\t? await resolveMetadataForDescriptor(descriptor, input.signal)\n\t\t\t\t: metadataValue(input.metadata);\n\t\tassertDescriptorMetadataMatch(descriptor, metadata);\n\t\tassertNotExpired(descriptor, now);\n\t\tlet result: PluginDistributionArtifactHandleV1;\n\t\tlet acquired: PluginDistributionArtifactV1 | undefined;\n\t\ttry {\n\t\t\tresult = await options.host.acquireArtifact({ descriptor, metadata, signal: input.signal });\n\t\t\tconst handle = artifactHandleValue(result);\n\t\t\tacquired = detachedFreeze({ ...metadata, artifactRef: handle.artifactRef });\n\t\t\tassertArtifactMatch(descriptor, handle);\n\t\t\tassertNotExpired(descriptor, now);\n\t\t\tif (input.signal?.aborted) reject(\"cancelled\");\n\t\t\treturn acquired;\n\t\t} catch (error) {\n\t\t\tif (acquired !== undefined && options.host.releaseArtifact !== undefined) {\n\t\t\t\tawait options.host.releaseArtifact({ artifact: acquired }).catch(() => undefined);\n\t\t\t}\n\t\t\tif (error instanceof PluginDistributionErrorV1) throw error;\n\t\t\tif (isCancelled(error, input.signal)) reject(\"cancelled\");\n\t\t\treject(\"host_failed\");\n\t\t}\n\t};\n\n\tconst releaseArtifact = async (input: { artifact: unknown; signal?: AbortSignal }): Promise<void> => {\n\t\tif (input.signal?.aborted) reject(\"cancelled\");\n\t\tif (options.host?.releaseArtifact === undefined) reject(\"unsupported\");\n\t\tconst value = input.artifact;\n\t\tif (!isPlainRecord(value) || !hasExactKeys(value, [...METADATA_KEYS, \"artifactRef\"])) reject(\"invalid_artifact\");\n\t\tconst metadataInput = Object.fromEntries(METADATA_KEYS.map((key) => [key, value[key]]));\n\t\tconst artifact = {\n\t\t\t...metadataValue(metadataInput),\n\t\t\tartifactRef: artifactHandleValue({\n\t\t\t\tartifactRef: value.artifactRef,\n\t\t\t\tartifactDigest: value.artifactDigest,\n\t\t\t\tsizeBytes: value.sizeBytes,\n\t\t\t\tmediaType: value.mediaType,\n\t\t\t}).artifactRef,\n\t\t};\n\t\ttry {\n\t\t\tawait options.host.releaseArtifact({ artifact: detachedFreeze(artifact), signal: input.signal });\n\t\t} catch (error) {\n\t\t\tif (isCancelled(error, input.signal)) reject(\"cancelled\");\n\t\t\treject(\"release_failed\");\n\t\t}\n\t\tif (input.signal?.aborted) reject(\"cancelled\");\n\t};\n\n\treturn {\n\t\tvalidateDescriptor(input) {\n\t\t\treturn descriptorValue(input);\n\t\t},\n\t\tresolveMetadata,\n\t\tacquireArtifact,\n\t\treleaseArtifact,\n\t};\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { detachedFreeze, isPlainRecord } from "@agent-forge/plugin-sdk";
|
|
2
|
+
import { t } from "../../core/i18n/index.js";
|
|
2
3
|
/** Distribution contract version. The host and package must agree on this version. */
|
|
3
4
|
export const PLUGIN_DISTRIBUTION_CONTRACT_VERSION_V1 = 1;
|
|
4
5
|
/** Maximum serialized descriptor size crossing the registry boundary. */
|
|
@@ -31,7 +32,7 @@ const ERROR_MESSAGES = {
|
|
|
31
32
|
export class PluginDistributionErrorV1 extends Error {
|
|
32
33
|
code;
|
|
33
34
|
constructor(code) {
|
|
34
|
-
super(ERROR_MESSAGES[code]);
|
|
35
|
+
super(t(ERROR_MESSAGES[code]));
|
|
35
36
|
this.name = "PluginDistributionErrorV1";
|
|
36
37
|
this.code = code;
|
|
37
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"distribution.js","sourceRoot":"","sources":["../../../src/plugins/ecosystem/distribution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,yBAAyB,CA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ACd,CAAC;QACF,IAAI,CAAC;YACJ,MAAM,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,QAAQ,EAAE,cAAc,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;QAClG,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,IAAI,WAAW,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC;gBAAE,MAAM,CAAC,WAAW,CAAC,CAAC;YAC1D,MAAM,CAAC,gBAAgB,CAAC,CAAC;QAC1B,CAAC;QACD,IAAI,KAAK,CAAC,MAAM,EAAE,OAAO;YAAE,MAAM,CAAC,WAAW,CAAC,CAAC;IAAA,CAC/C,CAAC;IAEF,OAAO;QACN,kBAAkB,CAAC,KAAK,EAAE;YACzB,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;QAAA,CAC9B;QACD,eAAe;QACf,eAAe;QACf,eAAe;KACf,CAAC;AAAA,CACF","sourcesContent":["import { detachedFreeze, isPlainRecord } from \"@agent-forge/plugin-sdk\";\n\n/** Distribution contract version. The host and package must agree on this version. */\nexport const PLUGIN_DISTRIBUTION_CONTRACT_VERSION_V1 = 1 as const;\n\n/** Maximum serialized descriptor size crossing the registry boundary. */\nexport const MAX_PLUGIN_DISTRIBUTION_DESCRIPTOR_BYTES_V1 = 16 * 1024;\n/** Maximum length of identity, URI, digest, signature, and media-type fields. */\nexport const MAX_PLUGIN_DISTRIBUTION_FIELD_CHARS_V1 = 2048;\n/** Maximum descriptor metadata size returned by a host. */\nexport const MAX_PLUGIN_DISTRIBUTION_METADATA_BYTES_V1 = 16 * 1024;\n/** Maximum opaque artifact handle length. */\nexport const MAX_PLUGIN_DISTRIBUTION_ARTIFACT_REF_CHARS_V1 = 2048;\n/** Maximum package size accepted by this contract. Larger artifacts need a newer contract. */\nexport const MAX_PLUGIN_DISTRIBUTION_ARTIFACT_BYTES_V1 = 512 * 1024 * 1024;\n\n/** A signed, bounded package descriptor. It contains no package bytes or local path. */\nexport interface PluginDistributionDescriptorV1 {\n\treadonly version: 1;\n\treadonly source: string;\n\treadonly pluginId: string;\n\treadonly pluginVersion: string;\n\treadonly manifestDigest: string;\n\treadonly artifactDigest: string;\n\treadonly signature: string;\n\treadonly expiresAt: string;\n\treadonly sizeBytes: number;\n\treadonly mediaType: string;\n}\n\n/** Metadata resolved by a host before any artifact is acquired. */\nexport interface PluginDistributionMetadataV1 {\n\treadonly version: 1;\n\treadonly source: string;\n\treadonly pluginId: string;\n\treadonly pluginVersion: string;\n\treadonly manifestDigest: string;\n\treadonly artifactDigest: string;\n\treadonly expiresAt: string;\n\treadonly sizeBytes: number;\n\treadonly mediaType: string;\n}\n\n/** Host-owned acquisition result. `artifactRef` is opaque and is never a path. */\nexport interface PluginDistributionArtifactHandleV1 {\n\treadonly artifactRef: string;\n\treadonly artifactDigest: string;\n\treadonly sizeBytes: number;\n\treadonly mediaType: string;\n}\n\n/** Model-facing acquisition projection. It deliberately contains no bytes or metadata payload. */\nexport interface PluginDistributionArtifactV1 extends PluginDistributionMetadataV1 {\n\treadonly artifactRef: string;\n}\n\nexport interface PluginDistributionSignatureVerificationInputV1 {\n\treadonly descriptor: PluginDistributionDescriptorV1;\n}\n\nexport type PluginDistributionSignatureVerificationV1 =\n\t| { readonly status: \"accepted\" }\n\t| { readonly status: \"rejected\"; readonly reason?: string };\n\nexport type PluginDistributionSignatureVerifierV1 = (\n\tinput: PluginDistributionSignatureVerificationInputV1,\n) => PluginDistributionSignatureVerificationV1 | Promise<PluginDistributionSignatureVerificationV1>;\n\n/**\n * Host boundary for registry metadata and package bytes. The core never opens a\n * URL, reads a path, or receives package bytes; hosts return only bounded metadata\n * and opaque artifact references.\n */\nexport interface PluginDistributionHostV1 {\n\treadonly resolveMetadata?: (input: {\n\t\treadonly descriptor: PluginDistributionDescriptorV1;\n\t\treadonly signal?: AbortSignal;\n\t}) => Promise<PluginDistributionMetadataV1>;\n\treadonly acquireArtifact?: (input: {\n\t\treadonly descriptor: PluginDistributionDescriptorV1;\n\t\treadonly metadata: PluginDistributionMetadataV1;\n\t\treadonly signal?: AbortSignal;\n\t}) => Promise<PluginDistributionArtifactHandleV1>;\n\treadonly releaseArtifact?: (input: {\n\t\treadonly artifact: PluginDistributionArtifactV1;\n\t\treadonly signal?: AbortSignal;\n\t}) => Promise<void>;\n}\n\nexport interface PluginDistributionOptionsV1 {\n\treadonly host?: PluginDistributionHostV1;\n\t/** Required for trust. There is no implicit signature acceptance fallback. */\n\treadonly verifySignature?: PluginDistributionSignatureVerifierV1;\n\t/** Alias for callers using the registry verifier naming. */\n\treadonly verify?: PluginDistributionSignatureVerifierV1;\n\t/** Injected clock for deterministic tests; returns epoch milliseconds. */\n\treadonly now?: () => number;\n}\n\nexport type PluginDistributionErrorCodeV1 =\n\t| \"unsupported\"\n\t| \"cancelled\"\n\t| \"invalid_descriptor\"\n\t| \"invalid_metadata\"\n\t| \"invalid_artifact\"\n\t| \"source_mismatch\"\n\t| \"identity_mismatch\"\n\t| \"digest_mismatch\"\n\t| \"signature_invalid\"\n\t| \"expired\"\n\t| \"size_mismatch\"\n\t| \"media_type_mismatch\"\n\t| \"host_failed\"\n\t| \"release_failed\";\n\nconst ERROR_MESSAGES: Readonly<Record<PluginDistributionErrorCodeV1, string>> = {\n\tunsupported: \"Plugin distribution is unsupported on this host\",\n\tcancelled: \"Plugin distribution operation was cancelled\",\n\tinvalid_descriptor: \"Plugin distribution descriptor is invalid\",\n\tinvalid_metadata: \"Plugin distribution metadata is invalid\",\n\tinvalid_artifact: \"Plugin distribution artifact handle is invalid\",\n\tsource_mismatch: \"Plugin distribution source does not match the descriptor\",\n\tidentity_mismatch: \"Plugin distribution plugin identity does not match the descriptor\",\n\tdigest_mismatch: \"Plugin distribution digest does not match the descriptor\",\n\tsignature_invalid: \"Plugin distribution signature was rejected\",\n\texpired: \"Plugin distribution descriptor has expired\",\n\tsize_mismatch: \"Plugin distribution size does not match the descriptor\",\n\tmedia_type_mismatch: \"Plugin distribution media type does not match the descriptor\",\n\thost_failed: \"Plugin distribution host operation failed\",\n\trelease_failed: \"Plugin distribution artifact release failed\",\n};\n\n/** Stable, non-leaking distribution error. Host exception messages are never retained. */\nexport class PluginDistributionErrorV1 extends Error {\n\treadonly code: PluginDistributionErrorCodeV1;\n\n\tconstructor(code: PluginDistributionErrorCodeV1) {\n\t\tsuper(ERROR_MESSAGES[code]);\n\t\tthis.name = \"PluginDistributionErrorV1\";\n\t\tthis.code = code;\n\t}\n}\n\nexport interface PluginDistributionV1 {\n\t/** Validate and detach a descriptor before passing it to a host or verifier. */\n\tvalidateDescriptor(input: unknown): PluginDistributionDescriptorV1;\n\tresolveMetadata(input: { descriptor: unknown; signal?: AbortSignal }): Promise<PluginDistributionMetadataV1>;\n\tacquireArtifact(input: {\n\t\tdescriptor: unknown;\n\t\tmetadata?: unknown;\n\t\tsignal?: AbortSignal;\n\t}): Promise<PluginDistributionArtifactV1>;\n\treleaseArtifact(input: { artifact: unknown; signal?: AbortSignal }): Promise<void>;\n}\n\nconst DESCRIPTOR_KEYS = [\n\t\"version\",\n\t\"source\",\n\t\"pluginId\",\n\t\"pluginVersion\",\n\t\"manifestDigest\",\n\t\"artifactDigest\",\n\t\"signature\",\n\t\"expiresAt\",\n\t\"sizeBytes\",\n\t\"mediaType\",\n] as const;\nconst METADATA_KEYS = [\n\t\"version\",\n\t\"source\",\n\t\"pluginId\",\n\t\"pluginVersion\",\n\t\"manifestDigest\",\n\t\"artifactDigest\",\n\t\"expiresAt\",\n\t\"sizeBytes\",\n\t\"mediaType\",\n] as const;\nconst ARTIFACT_KEYS = [\"artifactRef\", \"artifactDigest\", \"sizeBytes\", \"mediaType\"] as const;\n\nfunction reject(code: PluginDistributionErrorCodeV1): never {\n\tthrow new PluginDistributionErrorV1(code);\n}\n\nfunction hasExactKeys(value: Record<string, unknown>, keys: readonly string[]): boolean {\n\tconst expected = new Set(keys);\n\treturn (\n\t\tObject.keys(value).every((key) => expected.has(key) && expected.size === keys.length) &&\n\t\tkeys.every((key) => key in value)\n\t);\n}\n\nfunction boundedString(value: unknown, code: PluginDistributionErrorCodeV1): string {\n\tif (\n\t\ttypeof value !== \"string\" ||\n\t\tvalue.trim().length === 0 ||\n\t\tvalue.length > MAX_PLUGIN_DISTRIBUTION_FIELD_CHARS_V1 ||\n\t\t/[\\u0000-\\u001f\\u007f]/u.test(value)\n\t) {\n\t\treject(code);\n\t}\n\treturn value;\n}\n\nfunction identityString(value: unknown, code: PluginDistributionErrorCodeV1): string {\n\tconst result = boundedString(value, code);\n\tif (/\\s/u.test(result)) reject(code);\n\treturn result;\n}\n\nfunction sourceString(value: unknown, code: PluginDistributionErrorCodeV1): string {\n\tconst source = boundedString(value, code);\n\tif (/\\s/u.test(source) || /^(?:file:|[a-zA-Z]:[\\\\/]|[\\\\/]{1,2}|\\\\\\\\)/iu.test(source)) reject(code);\n\tif (/^https?:\\/\\//iu.test(source)) {\n\t\ttry {\n\t\t\tconst parsed = new URL(source);\n\t\t\tif (parsed.username !== \"\" || parsed.password !== \"\") {\n\t\t\t\tparsed.username = \"\";\n\t\t\t\tparsed.password = \"\";\n\t\t\t}\n\t\t\tparsed.search = \"\";\n\t\t\tparsed.hash = \"\";\n\t\t\tconst pathname = parsed.pathname.length > 512 ? `${parsed.pathname.slice(0, 509)}...` : parsed.pathname;\n\t\t\treturn `${parsed.origin}${pathname || \"/\"}`;\n\t\t} catch {\n\t\t\treject(code);\n\t\t}\n\t}\n\treturn source;\n}\n\nfunction digestString(value: unknown, code: PluginDistributionErrorCodeV1): string {\n\tconst digest = identityString(value, code);\n\t// Hosts may use a cryptographic digest or a versioned digest token. The\n\t// boundary validates shape and equality; only the host can verify bytes.\n\tif (!/^(?:[a-z][a-z0-9+.-]{0,15}:[A-Za-z0-9._~-]{1,128}|[0-9a-f]{16,128})$/u.test(digest)) reject(code);\n\treturn digest;\n}\n\nfunction signatureString(value: unknown): string {\n\tconst signature = boundedString(value, \"invalid_descriptor\");\n\tif (signature.length > 512 || /\\s/u.test(signature)) reject(\"invalid_descriptor\");\n\treturn signature;\n}\n\nfunction expiryString(value: unknown, code: PluginDistributionErrorCodeV1): string {\n\tconst expiry = boundedString(value, code);\n\tif (!/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{3})?Z$/u.test(expiry)) reject(code);\n\tconst timestamp = Date.parse(expiry);\n\tif (!Number.isFinite(timestamp) || new Date(timestamp).toISOString() !== expiry) reject(code);\n\treturn expiry;\n}\n\nfunction positiveSize(value: unknown, code: PluginDistributionErrorCodeV1): number {\n\tif (\n\t\ttypeof value !== \"number\" ||\n\t\t!Number.isSafeInteger(value) ||\n\t\tvalue < 1 ||\n\t\tvalue > MAX_PLUGIN_DISTRIBUTION_ARTIFACT_BYTES_V1\n\t)\n\t\treject(code);\n\treturn value;\n}\n\nfunction mediaTypeString(value: unknown, code: PluginDistributionErrorCodeV1): string {\n\tconst mediaType = boundedString(value, code).toLowerCase();\n\tif (\n\t\tmediaType.length > 256 ||\n\t\t!/^[a-z0-9!#$&^_.+-]+\\/[a-z0-9!#$&^_.+-]+(?:\\s*;\\s*[a-z0-9!#$&^_.+-]+=[a-z0-9!#$&^_.+-]+)*$/u.test(mediaType)\n\t)\n\t\treject(code);\n\treturn mediaType;\n}\n\nfunction serializedBytes(value: unknown, code: PluginDistributionErrorCodeV1): number {\n\ttry {\n\t\tconst serialized = JSON.stringify(value);\n\t\tif (serialized === undefined) reject(code);\n\t\treturn new TextEncoder().encode(serialized).byteLength;\n\t} catch {\n\t\treject(code);\n\t}\n}\n\nfunction descriptorValue(value: unknown): PluginDistributionDescriptorV1 {\n\tif (!isPlainRecord(value) || !hasExactKeys(value, DESCRIPTOR_KEYS)) reject(\"invalid_descriptor\");\n\tif (value.version !== PLUGIN_DISTRIBUTION_CONTRACT_VERSION_V1) reject(\"invalid_descriptor\");\n\tconst descriptor = {\n\t\tversion: PLUGIN_DISTRIBUTION_CONTRACT_VERSION_V1,\n\t\tsource: sourceString(value.source, \"invalid_descriptor\"),\n\t\tpluginId: identityString(value.pluginId, \"invalid_descriptor\"),\n\t\tpluginVersion: identityString(value.pluginVersion, \"invalid_descriptor\"),\n\t\tmanifestDigest: digestString(value.manifestDigest, \"invalid_descriptor\"),\n\t\tartifactDigest: digestString(value.artifactDigest, \"invalid_descriptor\"),\n\t\tsignature: signatureString(value.signature),\n\t\texpiresAt: expiryString(value.expiresAt, \"invalid_descriptor\"),\n\t\tsizeBytes: positiveSize(value.sizeBytes, \"invalid_descriptor\"),\n\t\tmediaType: mediaTypeString(value.mediaType, \"invalid_descriptor\"),\n\t};\n\tif (serializedBytes(descriptor, \"invalid_descriptor\") > MAX_PLUGIN_DISTRIBUTION_DESCRIPTOR_BYTES_V1)\n\t\treject(\"invalid_descriptor\");\n\treturn detachedFreeze(descriptor);\n}\n\nfunction metadataValue(value: unknown): PluginDistributionMetadataV1 {\n\tif (!isPlainRecord(value) || !hasExactKeys(value, METADATA_KEYS)) reject(\"invalid_metadata\");\n\tif (value.version !== PLUGIN_DISTRIBUTION_CONTRACT_VERSION_V1) reject(\"invalid_metadata\");\n\tconst metadata = {\n\t\tversion: PLUGIN_DISTRIBUTION_CONTRACT_VERSION_V1,\n\t\tsource: sourceString(value.source, \"invalid_metadata\"),\n\t\tpluginId: identityString(value.pluginId, \"invalid_metadata\"),\n\t\tpluginVersion: identityString(value.pluginVersion, \"invalid_metadata\"),\n\t\tmanifestDigest: digestString(value.manifestDigest, \"invalid_metadata\"),\n\t\tartifactDigest: digestString(value.artifactDigest, \"invalid_metadata\"),\n\t\texpiresAt: expiryString(value.expiresAt, \"invalid_metadata\"),\n\t\tsizeBytes: positiveSize(value.sizeBytes, \"invalid_metadata\"),\n\t\tmediaType: mediaTypeString(value.mediaType, \"invalid_metadata\"),\n\t};\n\tif (serializedBytes(metadata, \"invalid_metadata\") > MAX_PLUGIN_DISTRIBUTION_METADATA_BYTES_V1)\n\t\treject(\"invalid_metadata\");\n\treturn detachedFreeze(metadata);\n}\n\nfunction artifactHandleValue(value: unknown): PluginDistributionArtifactHandleV1 {\n\tif (!isPlainRecord(value) || !hasExactKeys(value, ARTIFACT_KEYS)) reject(\"invalid_artifact\");\n\tconst artifact = {\n\t\tartifactRef: boundedString(value.artifactRef, \"invalid_artifact\"),\n\t\tartifactDigest: digestString(value.artifactDigest, \"invalid_artifact\"),\n\t\tsizeBytes: positiveSize(value.sizeBytes, \"invalid_artifact\"),\n\t\tmediaType: mediaTypeString(value.mediaType, \"invalid_artifact\"),\n\t};\n\tif (\n\t\t/[\\s\\u0000-\\u001f\\u007f]/u.test(artifact.artifactRef) ||\n\t\t/^(?:file:|[a-zA-Z]:[\\\\/]|[\\\\/]{1,2}|\\\\\\\\)/iu.test(artifact.artifactRef) ||\n\t\tartifact.artifactRef.length > MAX_PLUGIN_DISTRIBUTION_ARTIFACT_REF_CHARS_V1\n\t)\n\t\treject(\"invalid_artifact\");\n\treturn detachedFreeze(artifact);\n}\n\nfunction assertDescriptorMetadataMatch(\n\tdescriptor: PluginDistributionDescriptorV1,\n\tmetadata: PluginDistributionMetadataV1,\n): void {\n\tif (metadata.source !== descriptor.source) reject(\"source_mismatch\");\n\tif (metadata.pluginId !== descriptor.pluginId || metadata.pluginVersion !== descriptor.pluginVersion)\n\t\treject(\"identity_mismatch\");\n\tif (metadata.manifestDigest !== descriptor.manifestDigest || metadata.artifactDigest !== descriptor.artifactDigest)\n\t\treject(\"digest_mismatch\");\n\tif (metadata.expiresAt !== descriptor.expiresAt) reject(\"expired\");\n\tif (metadata.sizeBytes !== descriptor.sizeBytes) reject(\"size_mismatch\");\n\tif (metadata.mediaType !== descriptor.mediaType) reject(\"media_type_mismatch\");\n}\n\nfunction assertArtifactMatch(\n\tdescriptor: PluginDistributionDescriptorV1,\n\tartifact: PluginDistributionArtifactHandleV1,\n): void {\n\tif (artifact.artifactDigest !== descriptor.artifactDigest) reject(\"digest_mismatch\");\n\tif (artifact.sizeBytes !== descriptor.sizeBytes) reject(\"size_mismatch\");\n\tif (artifact.mediaType !== descriptor.mediaType) reject(\"media_type_mismatch\");\n}\n\nfunction isCancelled(error: unknown, signal: AbortSignal | undefined): boolean {\n\treturn (\n\t\tsignal?.aborted === true ||\n\t\t(error instanceof Error && (error.name === \"AbortError\" || error.name === \"AbortSignalError\"))\n\t);\n}\n\nfunction assertNotExpired(descriptor: PluginDistributionDescriptorV1, now: () => number): void {\n\tlet current: number;\n\ttry {\n\t\tcurrent = now();\n\t} catch {\n\t\treject(\"expired\");\n\t}\n\tif (!Number.isFinite(current)) reject(\"expired\");\n\tif (Date.parse(descriptor.expiresAt) <= current) reject(\"expired\");\n}\n\nasync function verifyDescriptor(\n\tdescriptor: PluginDistributionDescriptorV1,\n\tverifySignature: PluginDistributionSignatureVerifierV1 | undefined,\n\tnow: () => number,\n\tsignal: AbortSignal | undefined,\n): Promise<void> {\n\tif (signal?.aborted) reject(\"cancelled\");\n\tassertNotExpired(descriptor, now);\n\tif (verifySignature === undefined) reject(\"unsupported\");\n\tlet verification: PluginDistributionSignatureVerificationV1;\n\ttry {\n\t\tverification = await verifySignature({ descriptor });\n\t} catch {\n\t\treject(\"signature_invalid\");\n\t}\n\tif (signal?.aborted) reject(\"cancelled\");\n\tif (!isPlainRecord(verification) || verification.status !== \"accepted\") reject(\"signature_invalid\");\n}\n\n/** Create a host-injected distribution client. No host means all side effects are unsupported. */\nexport function createPluginDistributionV1(options: PluginDistributionOptionsV1 = {}): PluginDistributionV1 {\n\tconst verifySignature = options.verifySignature ?? options.verify;\n\tconst now = options.now ?? (() => Date.now());\n\tconst resolveMetadataForDescriptor = async (\n\t\tdescriptor: PluginDistributionDescriptorV1,\n\t\tsignal: AbortSignal | undefined,\n\t): Promise<PluginDistributionMetadataV1> => {\n\t\tif (signal?.aborted) reject(\"cancelled\");\n\t\tif (options.host?.resolveMetadata === undefined) reject(\"unsupported\");\n\t\tlet result: PluginDistributionMetadataV1;\n\t\ttry {\n\t\t\tresult = await options.host.resolveMetadata({ descriptor, signal });\n\t\t} catch (error) {\n\t\t\tif (isCancelled(error, signal)) reject(\"cancelled\");\n\t\t\treject(\"host_failed\");\n\t\t}\n\t\tif (signal?.aborted) reject(\"cancelled\");\n\t\tconst metadata = metadataValue(result);\n\t\tassertDescriptorMetadataMatch(descriptor, metadata);\n\t\tassertNotExpired(descriptor, now);\n\t\treturn metadata;\n\t};\n\n\tconst resolveMetadata = async (input: {\n\t\tdescriptor: unknown;\n\t\tsignal?: AbortSignal;\n\t}): Promise<PluginDistributionMetadataV1> => {\n\t\tconst descriptor = descriptorValue(input.descriptor);\n\t\tawait verifyDescriptor(descriptor, verifySignature, now, input.signal);\n\t\treturn resolveMetadataForDescriptor(descriptor, input.signal);\n\t};\n\n\tconst acquireArtifact = async (input: {\n\t\tdescriptor: unknown;\n\t\tmetadata?: unknown;\n\t\tsignal?: AbortSignal;\n\t}): Promise<PluginDistributionArtifactV1> => {\n\t\tconst descriptor = descriptorValue(input.descriptor);\n\t\tawait verifyDescriptor(descriptor, verifySignature, now, input.signal);\n\t\tif (options.host?.acquireArtifact === undefined) reject(\"unsupported\");\n\t\tconst metadata =\n\t\t\tinput.metadata === undefined\n\t\t\t\t? await resolveMetadataForDescriptor(descriptor, input.signal)\n\t\t\t\t: metadataValue(input.metadata);\n\t\tassertDescriptorMetadataMatch(descriptor, metadata);\n\t\tassertNotExpired(descriptor, now);\n\t\tlet result: PluginDistributionArtifactHandleV1;\n\t\tlet acquired: PluginDistributionArtifactV1 | undefined;\n\t\ttry {\n\t\t\tresult = await options.host.acquireArtifact({ descriptor, metadata, signal: input.signal });\n\t\t\tconst handle = artifactHandleValue(result);\n\t\t\tacquired = detachedFreeze({ ...metadata, artifactRef: handle.artifactRef });\n\t\t\tassertArtifactMatch(descriptor, handle);\n\t\t\tassertNotExpired(descriptor, now);\n\t\t\tif (input.signal?.aborted) reject(\"cancelled\");\n\t\t\treturn acquired;\n\t\t} catch (error) {\n\t\t\tif (acquired !== undefined && options.host.releaseArtifact !== undefined) {\n\t\t\t\tawait options.host.releaseArtifact({ artifact: acquired }).catch(() => undefined);\n\t\t\t}\n\t\t\tif (error instanceof PluginDistributionErrorV1) throw error;\n\t\t\tif (isCancelled(error, input.signal)) reject(\"cancelled\");\n\t\t\treject(\"host_failed\");\n\t\t}\n\t};\n\n\tconst releaseArtifact = async (input: { artifact: unknown; signal?: AbortSignal }): Promise<void> => {\n\t\tif (input.signal?.aborted) reject(\"cancelled\");\n\t\tif (options.host?.releaseArtifact === undefined) reject(\"unsupported\");\n\t\tconst value = input.artifact;\n\t\tif (!isPlainRecord(value) || !hasExactKeys(value, [...METADATA_KEYS, \"artifactRef\"])) reject(\"invalid_artifact\");\n\t\tconst metadataInput = Object.fromEntries(METADATA_KEYS.map((key) => [key, value[key]]));\n\t\tconst artifact = {\n\t\t\t...metadataValue(metadataInput),\n\t\t\tartifactRef: artifactHandleValue({\n\t\t\t\tartifactRef: value.artifactRef,\n\t\t\t\tartifactDigest: value.artifactDigest,\n\t\t\t\tsizeBytes: value.sizeBytes,\n\t\t\t\tmediaType: value.mediaType,\n\t\t\t}).artifactRef,\n\t\t};\n\t\ttry {\n\t\t\tawait options.host.releaseArtifact({ artifact: detachedFreeze(artifact), signal: input.signal });\n\t\t} catch (error) {\n\t\t\tif (isCancelled(error, input.signal)) reject(\"cancelled\");\n\t\t\treject(\"release_failed\");\n\t\t}\n\t\tif (input.signal?.aborted) reject(\"cancelled\");\n\t};\n\n\treturn {\n\t\tvalidateDescriptor(input) {\n\t\t\treturn descriptorValue(input);\n\t\t},\n\t\tresolveMetadata,\n\t\tacquireArtifact,\n\t\treleaseArtifact,\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"distribution.js","sourceRoot":"","sources":["../../../src/plugins/ecosystem/distribution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,EAAE,CAAC,EAAE,MAAM,0BAA0B,CAAC;AAE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AAC,WAAW;SACd,CAAC;QACF,IAAI,CAAC;YACJ,MAAM,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,QAAQ,EAAE,cAAc,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;QAClG,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,IAAI,WAAW,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC;gBAAE,MAAM,CAAC,WAAW,CAAC,CAAC;YAC1D,MAAM,CAAC,gBAAgB,CAAC,CAAC;QAC1B,CAAC;QACD,IAAI,KAAK,CAAC,MAAM,EAAE,OAAO;YAAE,MAAM,CAAC,WAAW,CAAC,CAAC;IAAA,CAC/C,CAAC;IAEF,OAAO;QACN,kBAAkB,CAAC,KAAK,EAAE;YACzB,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;QAAA,CAC9B;QACD,eAAe;QACf,eAAe;QACf,eAAe;KACf,CAAC;AAAA,CACF","sourcesContent":["import { detachedFreeze, isPlainRecord } from \"@agent-forge/plugin-sdk\";\nimport { t } from \"../../core/i18n/index.ts\";\n\n/** Distribution contract version. The host and package must agree on this version. */\nexport const PLUGIN_DISTRIBUTION_CONTRACT_VERSION_V1 = 1 as const;\n\n/** Maximum serialized descriptor size crossing the registry boundary. */\nexport const MAX_PLUGIN_DISTRIBUTION_DESCRIPTOR_BYTES_V1 = 16 * 1024;\n/** Maximum length of identity, URI, digest, signature, and media-type fields. */\nexport const MAX_PLUGIN_DISTRIBUTION_FIELD_CHARS_V1 = 2048;\n/** Maximum descriptor metadata size returned by a host. */\nexport const MAX_PLUGIN_DISTRIBUTION_METADATA_BYTES_V1 = 16 * 1024;\n/** Maximum opaque artifact handle length. */\nexport const MAX_PLUGIN_DISTRIBUTION_ARTIFACT_REF_CHARS_V1 = 2048;\n/** Maximum package size accepted by this contract. Larger artifacts need a newer contract. */\nexport const MAX_PLUGIN_DISTRIBUTION_ARTIFACT_BYTES_V1 = 512 * 1024 * 1024;\n\n/** A signed, bounded package descriptor. It contains no package bytes or local path. */\nexport interface PluginDistributionDescriptorV1 {\n\treadonly version: 1;\n\treadonly source: string;\n\treadonly pluginId: string;\n\treadonly pluginVersion: string;\n\treadonly manifestDigest: string;\n\treadonly artifactDigest: string;\n\treadonly signature: string;\n\treadonly expiresAt: string;\n\treadonly sizeBytes: number;\n\treadonly mediaType: string;\n}\n\n/** Metadata resolved by a host before any artifact is acquired. */\nexport interface PluginDistributionMetadataV1 {\n\treadonly version: 1;\n\treadonly source: string;\n\treadonly pluginId: string;\n\treadonly pluginVersion: string;\n\treadonly manifestDigest: string;\n\treadonly artifactDigest: string;\n\treadonly expiresAt: string;\n\treadonly sizeBytes: number;\n\treadonly mediaType: string;\n}\n\n/** Host-owned acquisition result. `artifactRef` is opaque and is never a path. */\nexport interface PluginDistributionArtifactHandleV1 {\n\treadonly artifactRef: string;\n\treadonly artifactDigest: string;\n\treadonly sizeBytes: number;\n\treadonly mediaType: string;\n}\n\n/** Model-facing acquisition projection. It deliberately contains no bytes or metadata payload. */\nexport interface PluginDistributionArtifactV1 extends PluginDistributionMetadataV1 {\n\treadonly artifactRef: string;\n}\n\nexport interface PluginDistributionSignatureVerificationInputV1 {\n\treadonly descriptor: PluginDistributionDescriptorV1;\n}\n\nexport type PluginDistributionSignatureVerificationV1 =\n\t| { readonly status: \"accepted\" }\n\t| { readonly status: \"rejected\"; readonly reason?: string };\n\nexport type PluginDistributionSignatureVerifierV1 = (\n\tinput: PluginDistributionSignatureVerificationInputV1,\n) => PluginDistributionSignatureVerificationV1 | Promise<PluginDistributionSignatureVerificationV1>;\n\n/**\n * Host boundary for registry metadata and package bytes. The core never opens a\n * URL, reads a path, or receives package bytes; hosts return only bounded metadata\n * and opaque artifact references.\n */\nexport interface PluginDistributionHostV1 {\n\treadonly resolveMetadata?: (input: {\n\t\treadonly descriptor: PluginDistributionDescriptorV1;\n\t\treadonly signal?: AbortSignal;\n\t}) => Promise<PluginDistributionMetadataV1>;\n\treadonly acquireArtifact?: (input: {\n\t\treadonly descriptor: PluginDistributionDescriptorV1;\n\t\treadonly metadata: PluginDistributionMetadataV1;\n\t\treadonly signal?: AbortSignal;\n\t}) => Promise<PluginDistributionArtifactHandleV1>;\n\treadonly releaseArtifact?: (input: {\n\t\treadonly artifact: PluginDistributionArtifactV1;\n\t\treadonly signal?: AbortSignal;\n\t}) => Promise<void>;\n}\n\nexport interface PluginDistributionOptionsV1 {\n\treadonly host?: PluginDistributionHostV1;\n\t/** Required for trust. There is no implicit signature acceptance fallback. */\n\treadonly verifySignature?: PluginDistributionSignatureVerifierV1;\n\t/** Alias for callers using the registry verifier naming. */\n\treadonly verify?: PluginDistributionSignatureVerifierV1;\n\t/** Injected clock for deterministic tests; returns epoch milliseconds. */\n\treadonly now?: () => number;\n}\n\nexport type PluginDistributionErrorCodeV1 =\n\t| \"unsupported\"\n\t| \"cancelled\"\n\t| \"invalid_descriptor\"\n\t| \"invalid_metadata\"\n\t| \"invalid_artifact\"\n\t| \"source_mismatch\"\n\t| \"identity_mismatch\"\n\t| \"digest_mismatch\"\n\t| \"signature_invalid\"\n\t| \"expired\"\n\t| \"size_mismatch\"\n\t| \"media_type_mismatch\"\n\t| \"host_failed\"\n\t| \"release_failed\";\n\nconst ERROR_MESSAGES: Readonly<Record<PluginDistributionErrorCodeV1, string>> = {\n\tunsupported: \"Plugin distribution is unsupported on this host\",\n\tcancelled: \"Plugin distribution operation was cancelled\",\n\tinvalid_descriptor: \"Plugin distribution descriptor is invalid\",\n\tinvalid_metadata: \"Plugin distribution metadata is invalid\",\n\tinvalid_artifact: \"Plugin distribution artifact handle is invalid\",\n\tsource_mismatch: \"Plugin distribution source does not match the descriptor\",\n\tidentity_mismatch: \"Plugin distribution plugin identity does not match the descriptor\",\n\tdigest_mismatch: \"Plugin distribution digest does not match the descriptor\",\n\tsignature_invalid: \"Plugin distribution signature was rejected\",\n\texpired: \"Plugin distribution descriptor has expired\",\n\tsize_mismatch: \"Plugin distribution size does not match the descriptor\",\n\tmedia_type_mismatch: \"Plugin distribution media type does not match the descriptor\",\n\thost_failed: \"Plugin distribution host operation failed\",\n\trelease_failed: \"Plugin distribution artifact release failed\",\n};\n\n/** Stable, non-leaking distribution error. Host exception messages are never retained. */\nexport class PluginDistributionErrorV1 extends Error {\n\treadonly code: PluginDistributionErrorCodeV1;\n\n\tconstructor(code: PluginDistributionErrorCodeV1) {\n\t\tsuper(t(ERROR_MESSAGES[code]));\n\t\tthis.name = \"PluginDistributionErrorV1\";\n\t\tthis.code = code;\n\t}\n}\n\nexport interface PluginDistributionV1 {\n\t/** Validate and detach a descriptor before passing it to a host or verifier. */\n\tvalidateDescriptor(input: unknown): PluginDistributionDescriptorV1;\n\tresolveMetadata(input: { descriptor: unknown; signal?: AbortSignal }): Promise<PluginDistributionMetadataV1>;\n\tacquireArtifact(input: {\n\t\tdescriptor: unknown;\n\t\tmetadata?: unknown;\n\t\tsignal?: AbortSignal;\n\t}): Promise<PluginDistributionArtifactV1>;\n\treleaseArtifact(input: { artifact: unknown; signal?: AbortSignal }): Promise<void>;\n}\n\nconst DESCRIPTOR_KEYS = [\n\t\"version\",\n\t\"source\",\n\t\"pluginId\",\n\t\"pluginVersion\",\n\t\"manifestDigest\",\n\t\"artifactDigest\",\n\t\"signature\",\n\t\"expiresAt\",\n\t\"sizeBytes\",\n\t\"mediaType\",\n] as const;\nconst METADATA_KEYS = [\n\t\"version\",\n\t\"source\",\n\t\"pluginId\",\n\t\"pluginVersion\",\n\t\"manifestDigest\",\n\t\"artifactDigest\",\n\t\"expiresAt\",\n\t\"sizeBytes\",\n\t\"mediaType\",\n] as const;\nconst ARTIFACT_KEYS = [\"artifactRef\", \"artifactDigest\", \"sizeBytes\", \"mediaType\"] as const;\n\nfunction reject(code: PluginDistributionErrorCodeV1): never {\n\tthrow new PluginDistributionErrorV1(code);\n}\n\nfunction hasExactKeys(value: Record<string, unknown>, keys: readonly string[]): boolean {\n\tconst expected = new Set(keys);\n\treturn (\n\t\tObject.keys(value).every((key) => expected.has(key) && expected.size === keys.length) &&\n\t\tkeys.every((key) => key in value)\n\t);\n}\n\nfunction boundedString(value: unknown, code: PluginDistributionErrorCodeV1): string {\n\tif (\n\t\ttypeof value !== \"string\" ||\n\t\tvalue.trim().length === 0 ||\n\t\tvalue.length > MAX_PLUGIN_DISTRIBUTION_FIELD_CHARS_V1 ||\n\t\t/[\\u0000-\\u001f\\u007f]/u.test(value)\n\t) {\n\t\treject(code);\n\t}\n\treturn value;\n}\n\nfunction identityString(value: unknown, code: PluginDistributionErrorCodeV1): string {\n\tconst result = boundedString(value, code);\n\tif (/\\s/u.test(result)) reject(code);\n\treturn result;\n}\n\nfunction sourceString(value: unknown, code: PluginDistributionErrorCodeV1): string {\n\tconst source = boundedString(value, code);\n\tif (/\\s/u.test(source) || /^(?:file:|[a-zA-Z]:[\\\\/]|[\\\\/]{1,2}|\\\\\\\\)/iu.test(source)) reject(code);\n\tif (/^https?:\\/\\//iu.test(source)) {\n\t\ttry {\n\t\t\tconst parsed = new URL(source);\n\t\t\tif (parsed.username !== \"\" || parsed.password !== \"\") {\n\t\t\t\tparsed.username = \"\";\n\t\t\t\tparsed.password = \"\";\n\t\t\t}\n\t\t\tparsed.search = \"\";\n\t\t\tparsed.hash = \"\";\n\t\t\tconst pathname = parsed.pathname.length > 512 ? `${parsed.pathname.slice(0, 509)}...` : parsed.pathname;\n\t\t\treturn `${parsed.origin}${pathname || \"/\"}`;\n\t\t} catch {\n\t\t\treject(code);\n\t\t}\n\t}\n\treturn source;\n}\n\nfunction digestString(value: unknown, code: PluginDistributionErrorCodeV1): string {\n\tconst digest = identityString(value, code);\n\t// Hosts may use a cryptographic digest or a versioned digest token. The\n\t// boundary validates shape and equality; only the host can verify bytes.\n\tif (!/^(?:[a-z][a-z0-9+.-]{0,15}:[A-Za-z0-9._~-]{1,128}|[0-9a-f]{16,128})$/u.test(digest)) reject(code);\n\treturn digest;\n}\n\nfunction signatureString(value: unknown): string {\n\tconst signature = boundedString(value, \"invalid_descriptor\");\n\tif (signature.length > 512 || /\\s/u.test(signature)) reject(\"invalid_descriptor\");\n\treturn signature;\n}\n\nfunction expiryString(value: unknown, code: PluginDistributionErrorCodeV1): string {\n\tconst expiry = boundedString(value, code);\n\tif (!/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{3})?Z$/u.test(expiry)) reject(code);\n\tconst timestamp = Date.parse(expiry);\n\tif (!Number.isFinite(timestamp) || new Date(timestamp).toISOString() !== expiry) reject(code);\n\treturn expiry;\n}\n\nfunction positiveSize(value: unknown, code: PluginDistributionErrorCodeV1): number {\n\tif (\n\t\ttypeof value !== \"number\" ||\n\t\t!Number.isSafeInteger(value) ||\n\t\tvalue < 1 ||\n\t\tvalue > MAX_PLUGIN_DISTRIBUTION_ARTIFACT_BYTES_V1\n\t)\n\t\treject(code);\n\treturn value;\n}\n\nfunction mediaTypeString(value: unknown, code: PluginDistributionErrorCodeV1): string {\n\tconst mediaType = boundedString(value, code).toLowerCase();\n\tif (\n\t\tmediaType.length > 256 ||\n\t\t!/^[a-z0-9!#$&^_.+-]+\\/[a-z0-9!#$&^_.+-]+(?:\\s*;\\s*[a-z0-9!#$&^_.+-]+=[a-z0-9!#$&^_.+-]+)*$/u.test(mediaType)\n\t)\n\t\treject(code);\n\treturn mediaType;\n}\n\nfunction serializedBytes(value: unknown, code: PluginDistributionErrorCodeV1): number {\n\ttry {\n\t\tconst serialized = JSON.stringify(value);\n\t\tif (serialized === undefined) reject(code);\n\t\treturn new TextEncoder().encode(serialized).byteLength;\n\t} catch {\n\t\treject(code);\n\t}\n}\n\nfunction descriptorValue(value: unknown): PluginDistributionDescriptorV1 {\n\tif (!isPlainRecord(value) || !hasExactKeys(value, DESCRIPTOR_KEYS)) reject(\"invalid_descriptor\");\n\tif (value.version !== PLUGIN_DISTRIBUTION_CONTRACT_VERSION_V1) reject(\"invalid_descriptor\");\n\tconst descriptor = {\n\t\tversion: PLUGIN_DISTRIBUTION_CONTRACT_VERSION_V1,\n\t\tsource: sourceString(value.source, \"invalid_descriptor\"),\n\t\tpluginId: identityString(value.pluginId, \"invalid_descriptor\"),\n\t\tpluginVersion: identityString(value.pluginVersion, \"invalid_descriptor\"),\n\t\tmanifestDigest: digestString(value.manifestDigest, \"invalid_descriptor\"),\n\t\tartifactDigest: digestString(value.artifactDigest, \"invalid_descriptor\"),\n\t\tsignature: signatureString(value.signature),\n\t\texpiresAt: expiryString(value.expiresAt, \"invalid_descriptor\"),\n\t\tsizeBytes: positiveSize(value.sizeBytes, \"invalid_descriptor\"),\n\t\tmediaType: mediaTypeString(value.mediaType, \"invalid_descriptor\"),\n\t};\n\tif (serializedBytes(descriptor, \"invalid_descriptor\") > MAX_PLUGIN_DISTRIBUTION_DESCRIPTOR_BYTES_V1)\n\t\treject(\"invalid_descriptor\");\n\treturn detachedFreeze(descriptor);\n}\n\nfunction metadataValue(value: unknown): PluginDistributionMetadataV1 {\n\tif (!isPlainRecord(value) || !hasExactKeys(value, METADATA_KEYS)) reject(\"invalid_metadata\");\n\tif (value.version !== PLUGIN_DISTRIBUTION_CONTRACT_VERSION_V1) reject(\"invalid_metadata\");\n\tconst metadata = {\n\t\tversion: PLUGIN_DISTRIBUTION_CONTRACT_VERSION_V1,\n\t\tsource: sourceString(value.source, \"invalid_metadata\"),\n\t\tpluginId: identityString(value.pluginId, \"invalid_metadata\"),\n\t\tpluginVersion: identityString(value.pluginVersion, \"invalid_metadata\"),\n\t\tmanifestDigest: digestString(value.manifestDigest, \"invalid_metadata\"),\n\t\tartifactDigest: digestString(value.artifactDigest, \"invalid_metadata\"),\n\t\texpiresAt: expiryString(value.expiresAt, \"invalid_metadata\"),\n\t\tsizeBytes: positiveSize(value.sizeBytes, \"invalid_metadata\"),\n\t\tmediaType: mediaTypeString(value.mediaType, \"invalid_metadata\"),\n\t};\n\tif (serializedBytes(metadata, \"invalid_metadata\") > MAX_PLUGIN_DISTRIBUTION_METADATA_BYTES_V1)\n\t\treject(\"invalid_metadata\");\n\treturn detachedFreeze(metadata);\n}\n\nfunction artifactHandleValue(value: unknown): PluginDistributionArtifactHandleV1 {\n\tif (!isPlainRecord(value) || !hasExactKeys(value, ARTIFACT_KEYS)) reject(\"invalid_artifact\");\n\tconst artifact = {\n\t\tartifactRef: boundedString(value.artifactRef, \"invalid_artifact\"),\n\t\tartifactDigest: digestString(value.artifactDigest, \"invalid_artifact\"),\n\t\tsizeBytes: positiveSize(value.sizeBytes, \"invalid_artifact\"),\n\t\tmediaType: mediaTypeString(value.mediaType, \"invalid_artifact\"),\n\t};\n\tif (\n\t\t/[\\s\\u0000-\\u001f\\u007f]/u.test(artifact.artifactRef) ||\n\t\t/^(?:file:|[a-zA-Z]:[\\\\/]|[\\\\/]{1,2}|\\\\\\\\)/iu.test(artifact.artifactRef) ||\n\t\tartifact.artifactRef.length > MAX_PLUGIN_DISTRIBUTION_ARTIFACT_REF_CHARS_V1\n\t)\n\t\treject(\"invalid_artifact\");\n\treturn detachedFreeze(artifact);\n}\n\nfunction assertDescriptorMetadataMatch(\n\tdescriptor: PluginDistributionDescriptorV1,\n\tmetadata: PluginDistributionMetadataV1,\n): void {\n\tif (metadata.source !== descriptor.source) reject(\"source_mismatch\");\n\tif (metadata.pluginId !== descriptor.pluginId || metadata.pluginVersion !== descriptor.pluginVersion)\n\t\treject(\"identity_mismatch\");\n\tif (metadata.manifestDigest !== descriptor.manifestDigest || metadata.artifactDigest !== descriptor.artifactDigest)\n\t\treject(\"digest_mismatch\");\n\tif (metadata.expiresAt !== descriptor.expiresAt) reject(\"expired\");\n\tif (metadata.sizeBytes !== descriptor.sizeBytes) reject(\"size_mismatch\");\n\tif (metadata.mediaType !== descriptor.mediaType) reject(\"media_type_mismatch\");\n}\n\nfunction assertArtifactMatch(\n\tdescriptor: PluginDistributionDescriptorV1,\n\tartifact: PluginDistributionArtifactHandleV1,\n): void {\n\tif (artifact.artifactDigest !== descriptor.artifactDigest) reject(\"digest_mismatch\");\n\tif (artifact.sizeBytes !== descriptor.sizeBytes) reject(\"size_mismatch\");\n\tif (artifact.mediaType !== descriptor.mediaType) reject(\"media_type_mismatch\");\n}\n\nfunction isCancelled(error: unknown, signal: AbortSignal | undefined): boolean {\n\treturn (\n\t\tsignal?.aborted === true ||\n\t\t(error instanceof Error && (error.name === \"AbortError\" || error.name === \"AbortSignalError\"))\n\t);\n}\n\nfunction assertNotExpired(descriptor: PluginDistributionDescriptorV1, now: () => number): void {\n\tlet current: number;\n\ttry {\n\t\tcurrent = now();\n\t} catch {\n\t\treject(\"expired\");\n\t}\n\tif (!Number.isFinite(current)) reject(\"expired\");\n\tif (Date.parse(descriptor.expiresAt) <= current) reject(\"expired\");\n}\n\nasync function verifyDescriptor(\n\tdescriptor: PluginDistributionDescriptorV1,\n\tverifySignature: PluginDistributionSignatureVerifierV1 | undefined,\n\tnow: () => number,\n\tsignal: AbortSignal | undefined,\n): Promise<void> {\n\tif (signal?.aborted) reject(\"cancelled\");\n\tassertNotExpired(descriptor, now);\n\tif (verifySignature === undefined) reject(\"unsupported\");\n\tlet verification: PluginDistributionSignatureVerificationV1;\n\ttry {\n\t\tverification = await verifySignature({ descriptor });\n\t} catch {\n\t\treject(\"signature_invalid\");\n\t}\n\tif (signal?.aborted) reject(\"cancelled\");\n\tif (!isPlainRecord(verification) || verification.status !== \"accepted\") reject(\"signature_invalid\");\n}\n\n/** Create a host-injected distribution client. No host means all side effects are unsupported. */\nexport function createPluginDistributionV1(options: PluginDistributionOptionsV1 = {}): PluginDistributionV1 {\n\tconst verifySignature = options.verifySignature ?? options.verify;\n\tconst now = options.now ?? (() => Date.now());\n\tconst resolveMetadataForDescriptor = async (\n\t\tdescriptor: PluginDistributionDescriptorV1,\n\t\tsignal: AbortSignal | undefined,\n\t): Promise<PluginDistributionMetadataV1> => {\n\t\tif (signal?.aborted) reject(\"cancelled\");\n\t\tif (options.host?.resolveMetadata === undefined) reject(\"unsupported\");\n\t\tlet result: PluginDistributionMetadataV1;\n\t\ttry {\n\t\t\tresult = await options.host.resolveMetadata({ descriptor, signal });\n\t\t} catch (error) {\n\t\t\tif (isCancelled(error, signal)) reject(\"cancelled\");\n\t\t\treject(\"host_failed\");\n\t\t}\n\t\tif (signal?.aborted) reject(\"cancelled\");\n\t\tconst metadata = metadataValue(result);\n\t\tassertDescriptorMetadataMatch(descriptor, metadata);\n\t\tassertNotExpired(descriptor, now);\n\t\treturn metadata;\n\t};\n\n\tconst resolveMetadata = async (input: {\n\t\tdescriptor: unknown;\n\t\tsignal?: AbortSignal;\n\t}): Promise<PluginDistributionMetadataV1> => {\n\t\tconst descriptor = descriptorValue(input.descriptor);\n\t\tawait verifyDescriptor(descriptor, verifySignature, now, input.signal);\n\t\treturn resolveMetadataForDescriptor(descriptor, input.signal);\n\t};\n\n\tconst acquireArtifact = async (input: {\n\t\tdescriptor: unknown;\n\t\tmetadata?: unknown;\n\t\tsignal?: AbortSignal;\n\t}): Promise<PluginDistributionArtifactV1> => {\n\t\tconst descriptor = descriptorValue(input.descriptor);\n\t\tawait verifyDescriptor(descriptor, verifySignature, now, input.signal);\n\t\tif (options.host?.acquireArtifact === undefined) reject(\"unsupported\");\n\t\tconst metadata =\n\t\t\tinput.metadata === undefined\n\t\t\t\t? await resolveMetadataForDescriptor(descriptor, input.signal)\n\t\t\t\t: metadataValue(input.metadata);\n\t\tassertDescriptorMetadataMatch(descriptor, metadata);\n\t\tassertNotExpired(descriptor, now);\n\t\tlet result: PluginDistributionArtifactHandleV1;\n\t\tlet acquired: PluginDistributionArtifactV1 | undefined;\n\t\ttry {\n\t\t\tresult = await options.host.acquireArtifact({ descriptor, metadata, signal: input.signal });\n\t\t\tconst handle = artifactHandleValue(result);\n\t\t\tacquired = detachedFreeze({ ...metadata, artifactRef: handle.artifactRef });\n\t\t\tassertArtifactMatch(descriptor, handle);\n\t\t\tassertNotExpired(descriptor, now);\n\t\t\tif (input.signal?.aborted) reject(\"cancelled\");\n\t\t\treturn acquired;\n\t\t} catch (error) {\n\t\t\tif (acquired !== undefined && options.host.releaseArtifact !== undefined) {\n\t\t\t\tawait options.host.releaseArtifact({ artifact: acquired }).catch(() => undefined);\n\t\t\t}\n\t\t\tif (error instanceof PluginDistributionErrorV1) throw error;\n\t\t\tif (isCancelled(error, input.signal)) reject(\"cancelled\");\n\t\t\treject(\"host_failed\");\n\t\t}\n\t};\n\n\tconst releaseArtifact = async (input: { artifact: unknown; signal?: AbortSignal }): Promise<void> => {\n\t\tif (input.signal?.aborted) reject(\"cancelled\");\n\t\tif (options.host?.releaseArtifact === undefined) reject(\"unsupported\");\n\t\tconst value = input.artifact;\n\t\tif (!isPlainRecord(value) || !hasExactKeys(value, [...METADATA_KEYS, \"artifactRef\"])) reject(\"invalid_artifact\");\n\t\tconst metadataInput = Object.fromEntries(METADATA_KEYS.map((key) => [key, value[key]]));\n\t\tconst artifact = {\n\t\t\t...metadataValue(metadataInput),\n\t\t\tartifactRef: artifactHandleValue({\n\t\t\t\tartifactRef: value.artifactRef,\n\t\t\t\tartifactDigest: value.artifactDigest,\n\t\t\t\tsizeBytes: value.sizeBytes,\n\t\t\t\tmediaType: value.mediaType,\n\t\t\t}).artifactRef,\n\t\t};\n\t\ttry {\n\t\t\tawait options.host.releaseArtifact({ artifact: detachedFreeze(artifact), signal: input.signal });\n\t\t} catch (error) {\n\t\t\tif (isCancelled(error, input.signal)) reject(\"cancelled\");\n\t\t\treject(\"release_failed\");\n\t\t}\n\t\tif (input.signal?.aborted) reject(\"cancelled\");\n\t};\n\n\treturn {\n\t\tvalidateDescriptor(input) {\n\t\t\treturn descriptorValue(input);\n\t\t},\n\t\tresolveMetadata,\n\t\tacquireArtifact,\n\t\treleaseArtifact,\n\t};\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installer.d.ts","sourceRoot":"","sources":["../../../src/plugins/ecosystem/installer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,mBAAm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AAC;KAC9B,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACrC,QAAQ,CAAC,KAAK,EAAE;QACf,QAAQ,CAAC,YAAY,EAAE,oBAAoB,CAAC;QAC5C,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAC;QACtC,QAAQ,CAAC,KAAK,CAAC,EAAE,yBAAyB,CAAC;QAC3C,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;KAC9B,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACrC,QAAQ,CAAC,KAAK,EAAE;QACf,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAC;QACtC,QAAQ,CAAC,QAAQ,EAAE,oBAAoB,CAAC;QACxC,QAAQ,CAAC,KAAK,CAAC,EAAE,yBAAyB,CAAC;QAC3C,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;KAC9B,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACrC,yEAAyE;IACzE,MAAM,CAAC,KAAK,EAAE;QACb,QAAQ,CAAC,YAAY,EAAE,oBAAoB,CAAC;QAC5C,QAAQ,CAAC,KAAK,CAAC,EAAE,yBAAyB,CAAC;QAC3C,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;KAC9B,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;CACrC;AAmLD,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,wBAAwB,GAAG,iBAAiB,CAyJ5F","sourcesContent":["import type { PluginDistributionArtifactV1 } from \"./distribution.ts\";\nimport type { HostFactsV1, PluginSourceVerifierV1, PluginUpdateRecordV1 } from \"./types.ts\";\n\nimport { stagePluginUpdateV1, type UpdateVerificationV1, verifyPluginUpdateV1 } from \"./updates.ts\";\n\nconst MAX_INSTALLATION_REF_CHARS_V1 = 2048;\nexport const MAX_PLUGIN_SCOPE_REF_CHARS_V1 = 2048;\n/** Stable host namespace for installations that are not project-local. */\nexport const DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1 = \"global:default\";\n\nexport type PluginInstallationScopeV1 = \"global\" | \"project\";\n\ninterface PluginScopeIdentityV1 {\n\treadonly scope: PluginInstallationScopeV1;\n\t/** Opaque host namespace; it must never disclose a local project path. */\n\treadonly scopeRef: string;\n}\n\nexport interface PluginInstallationV1 {\n\treadonly version: 1;\n\treadonly pluginId: string;\n\treadonly pluginVersion: string;\n\treadonly manifestDigest: string;\n\t/** The host installation namespace. It is part of the opaque installation identity. */\n\treadonly scope: PluginInstallationScopeV1;\n\t/** Concrete host namespace that distinguishes global and individual project installations. */\n\treadonly scopeRef?: string;\n\t/** Opaque host-owned installation handle; never a local path. */\n\treadonly installationRef: string;\n\treadonly state: \"installed\" | \"active\" | \"retained\";\n}\n\nexport interface PluginInstallHostV1 {\n\t/**\n\t * Scopes that this host can isolate physically. Omitting this declaration\n\t * preserves the legacy global-only host behavior; project operations must be\n\t * declared explicitly.\n\t */\n\treadonly supportedScopes?: readonly PluginInstallationScopeV1[];\n\t/** Host operations are atomic from the installer's perspective: an abort may\n\t * prevent starting work, but once a method resolves its side effect is committed. */\n\tinstall(input: {\n\t\treadonly record: PluginUpdateRecordV1;\n\t\treadonly scope: PluginInstallationScopeV1;\n\t\treadonly scopeRef: string;\n\t\t/** A host-owned, digest-bound package reference. Package bytes never cross this contract. */\n\t\treadonly artifact?: PluginDistributionArtifactV1;\n\t\treadonly signal?: AbortSignal;\n\t}): Promise<{\n\t\treadonly installationRef: string;\n\t\treadonly scope?: PluginInstallationScopeV1;\n\t\treadonly scopeRef?: string;\n\t}>;\n\tactivate(input: {\n\t\treadonly installation: PluginInstallationV1;\n\t\treadonly record: PluginUpdateRecordV1;\n\t\treadonly scope: PluginInstallationScopeV1;\n\t\treadonly scopeRef: string;\n\t\treadonly signal?: AbortSignal;\n\t}): Promise<void>;\n\trollback(input: {\n\t\treadonly failed: PluginInstallationV1;\n\t\treadonly previous: PluginInstallationV1;\n\t\treadonly scope: PluginInstallationScopeV1;\n\t\treadonly scopeRef: string;\n\t\treadonly signal?: AbortSignal;\n\t}): Promise<void>;\n\t/**\n\t * Remove a host-owned installation. The method is optional so hosts can\n\t * still expose state-only management while they are migrating; callers that\n\t * need physical cleanup must treat a missing method as unsupported.\n\t */\n\tuninstall?: (input: {\n\t\treadonly installation: PluginInstallationV1;\n\t\treadonly scope: PluginInstallationScopeV1;\n\t\treadonly scopeRef: string;\n\t\treadonly signal?: AbortSignal;\n\t}) => Promise<void>;\n}\n\nexport interface PluginInstallerOptionsV1 {\n\treadonly host: PluginInstallHostV1;\n\treadonly verifier?: PluginSourceVerifierV1;\n}\n\nexport type PluginInstallerErrorCodeV1 =\n\t| \"invalid_installation\"\n\t| \"unsupported_scope\"\n\t| \"install_failed\"\n\t| \"activation_failed\"\n\t| \"rollback_failed\"\n\t| \"uninstall_failed\";\n\nexport type PluginInstallerResultV1 =\n\t| {\n\t\t\treadonly status: \"succeeded\";\n\t\t\treadonly installation: PluginInstallationV1;\n\t }\n\t| {\n\t\t\treadonly status: \"cancelled\";\n\t\t\treadonly error: { readonly code: \"cancelled\"; readonly message: string };\n\t }\n\t| {\n\t\t\treadonly status: \"failed\";\n\t\t\treadonly error: {\n\t\t\t\treadonly code: PluginInstallerErrorCodeV1;\n\t\t\t\treadonly message: string;\n\t\t\t};\n\t };\n\nexport interface PluginInstallerV1 {\n\t/** Declared, host-backed installation scopes. Project support is never inferred. */\n\treadonly supportedScopes: readonly PluginInstallationScopeV1[];\n\tprepare(input: {\n\t\treadonly manifest: PluginUpdateRecordV1[\"manifest\"];\n\t\treadonly source: string;\n\t\treadonly host: HostFactsV1;\n\t\treadonly expectedDigest?: string;\n\t}): UpdateVerificationV1;\n\tinstall(input: {\n\t\treadonly record: PluginUpdateRecordV1;\n\t\t/** Omitting scope preserves the existing global installation behavior. */\n\t\treadonly scope?: PluginInstallationScopeV1;\n\t\t/** Required for project installations; global defaults to `global:default`. */\n\t\treadonly scopeRef?: string;\n\t\treadonly artifact?: PluginDistributionArtifactV1;\n\t\treadonly signal?: AbortSignal;\n\t}): Promise<PluginInstallerResultV1>;\n\tactivate(input: {\n\t\treadonly installation: PluginInstallationV1;\n\t\treadonly record: PluginUpdateRecordV1;\n\t\treadonly scope?: PluginInstallationScopeV1;\n\t\treadonly scopeRef?: string;\n\t\treadonly signal?: AbortSignal;\n\t}): Promise<PluginInstallerResultV1>;\n\trollback(input: {\n\t\treadonly failed: PluginInstallationV1;\n\t\treadonly previous: PluginInstallationV1;\n\t\treadonly scope?: PluginInstallationScopeV1;\n\t\treadonly scopeRef?: string;\n\t\treadonly signal?: AbortSignal;\n\t}): Promise<PluginInstallerResultV1>;\n\t/** Remove one installed version after validating its opaque identity. */\n\tremove(input: {\n\t\treadonly installation: PluginInstallationV1;\n\t\treadonly scope?: PluginInstallationScopeV1;\n\t\treadonly scopeRef?: string;\n\t\treadonly signal?: AbortSignal;\n\t}): Promise<PluginInstallerResultV1>;\n}\n\nfunction opaqueInstallationRef(value: unknown): string {\n\tif (typeof value !== \"string\" || value.trim() === \"\" || value.length > MAX_INSTALLATION_REF_CHARS_V1)\n\t\tthrow new Error(\"installation reference is invalid\");\n\tif (/^(?:file:|[a-zA-Z]:[\\\\/]|[\\\\/]{1,2}|\\\\\\\\)/iu.test(value) || /\\s/u.test(value))\n\t\tthrow new Error(\"installation reference must be opaque\");\n\treturn value;\n}\n\nfunction opaqueScopeRef(value: unknown): string {\n\tif (typeof value !== \"string\" || value.trim() === \"\" || value.length > MAX_PLUGIN_SCOPE_REF_CHARS_V1)\n\t\tthrow new Error(\"plugin installation scope reference is invalid\");\n\tif (/^(?:file:|[a-zA-Z]:[\\\\/]|[\\\\/]{1,2}|\\\\\\\\)/iu.test(value) || /\\s/u.test(value))\n\t\tthrow new Error(\"plugin installation scope reference must be opaque\");\n\treturn value;\n}\n\nfunction installationFrom(\n\trecord: PluginUpdateRecordV1,\n\tinstallationRef: string,\n\tscopeIdentity: PluginScopeIdentityV1,\n\tstate: PluginInstallationV1[\"state\"],\n): PluginInstallationV1 {\n\treturn Object.freeze({\n\t\tversion: 1,\n\t\tpluginId: record.pluginId,\n\t\tpluginVersion: record.pluginVersion,\n\t\tmanifestDigest: record.manifestDigest,\n\t\tscope: scopeIdentity.scope,\n\t\tscopeRef: scopeIdentity.scopeRef,\n\t\tinstallationRef: opaqueInstallationRef(installationRef),\n\t\tstate,\n\t});\n}\n\nfunction cancelled(): PluginInstallerResultV1 {\n\treturn {\n\t\tstatus: \"cancelled\",\n\t\terror: {\n\t\t\tcode: \"cancelled\",\n\t\t\tmessage: \"Plugin installation operation was cancelled\",\n\t\t},\n\t};\n}\n\nfunction failure(code: PluginInstallerErrorCodeV1): PluginInstallerResultV1 {\n\treturn {\n\t\tstatus: \"failed\",\n\t\terror: {\n\t\t\tcode,\n\t\t\tmessage:\n\t\t\t\tcode === \"invalid_installation\"\n\t\t\t\t\t? \"The plugin installation handle is invalid\"\n\t\t\t\t\t: code === \"unsupported_scope\"\n\t\t\t\t\t\t? \"The plugin installer does not support this scope\"\n\t\t\t\t\t\t: code === \"install_failed\"\n\t\t\t\t\t\t\t? \"The host plugin installer failed\"\n\t\t\t\t\t\t\t: code === \"activation_failed\"\n\t\t\t\t\t\t\t\t? \"The host plugin activation failed\"\n\t\t\t\t\t\t\t\t: code === \"rollback_failed\"\n\t\t\t\t\t\t\t\t\t? \"The host plugin rollback failed\"\n\t\t\t\t\t\t\t\t\t: \"The host plugin uninstall failed\",\n\t\t},\n\t};\n}\n\nfunction validateInstallation(installation: PluginInstallationV1): void {\n\tif (\n\t\tinstallation.version !== 1 ||\n\t\ttypeof installation.pluginId !== \"string\" ||\n\t\ttypeof installation.pluginVersion !== \"string\" ||\n\t\ttypeof installation.manifestDigest !== \"string\" ||\n\t\tinstallation.pluginId.trim() === \"\" ||\n\t\tinstallation.pluginVersion.trim() === \"\" ||\n\t\tinstallation.manifestDigest.trim() === \"\"\n\t)\n\t\tthrow new Error(\"plugin installation handle is invalid\");\n\tif (installation.scope !== \"global\" && installation.scope !== \"project\")\n\t\tthrow new Error(\"plugin installation scope is invalid\");\n\tconst scopeRef =\n\t\tinstallation.scopeRef === undefined\n\t\t\t? installation.scope === \"global\"\n\t\t\t\t? DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1\n\t\t\t\t: (() => {\n\t\t\t\t\t\tthrow new Error(\"project installation scope reference is required\");\n\t\t\t\t\t})()\n\t\t\t: opaqueScopeRef(installation.scopeRef);\n\tif (installation.scope === \"global\" && scopeRef !== DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1)\n\t\tthrow new Error(\"plugin global installation scope reference is invalid\");\n\topaqueInstallationRef(installation.installationRef);\n}\n\nfunction ensureIdentity(\n\tinstallation: PluginInstallationV1,\n\trecord: PluginUpdateRecordV1,\n\tscopeIdentity: PluginScopeIdentityV1,\n): void {\n\tvalidateInstallation(installation);\n\tif (\n\t\tinstallation.pluginId !== record.pluginId ||\n\t\tinstallation.pluginVersion !== record.pluginVersion ||\n\t\tinstallation.manifestDigest !== record.manifestDigest ||\n\t\tinstallation.scope !== scopeIdentity.scope ||\n\t\t(installation.scopeRef ?? DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1) !== scopeIdentity.scopeRef\n\t)\n\t\tthrow new Error(\"plugin installation identity mismatch\");\n}\n\nfunction normalizeScope(scope: PluginInstallationScopeV1 | undefined): PluginInstallationScopeV1 {\n\tif (scope === undefined) return \"global\";\n\tif (scope === \"global\" || scope === \"project\") return scope;\n\tthrow new Error(\"plugin installation scope is invalid\");\n}\n\nfunction normalizeScopeIdentity(\n\tscope: PluginInstallationScopeV1 | undefined,\n\tscopeRef: string | undefined,\n): PluginScopeIdentityV1 {\n\tconst normalizedScope = normalizeScope(scope);\n\tif (scopeRef === undefined) {\n\t\tif (normalizedScope !== \"global\") throw new Error(\"project installation scope reference is required\");\n\t\treturn Object.freeze({ scope: normalizedScope, scopeRef: DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1 });\n\t}\n\tconst normalizedScopeRef = opaqueScopeRef(scopeRef);\n\tif (normalizedScope === \"global\" && normalizedScopeRef !== DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1)\n\t\tthrow new Error(\"plugin global installation scope reference is invalid\");\n\treturn Object.freeze({ scope: normalizedScope, scopeRef: normalizedScopeRef });\n}\n\nfunction declaredScopes(host: PluginInstallHostV1): readonly PluginInstallationScopeV1[] {\n\tif (host.supportedScopes === undefined) return Object.freeze([\"global\"]);\n\tif (\n\t\t!Array.isArray(host.supportedScopes) ||\n\t\tnew Set(host.supportedScopes).size !== host.supportedScopes.length ||\n\t\thost.supportedScopes.some((scope) => scope !== \"global\" && scope !== \"project\")\n\t)\n\t\treturn Object.freeze([]);\n\treturn Object.freeze([...host.supportedScopes]);\n}\n\nfunction hostAcceptedScope(\n\tinstallation: { readonly scope?: PluginInstallationScopeV1; readonly scopeRef?: string },\n\tscopeIdentity: PluginScopeIdentityV1,\n): void {\n\tif (scopeIdentity.scope === \"global\" && installation.scope === undefined && installation.scopeRef === undefined)\n\t\treturn;\n\tif (installation.scope !== scopeIdentity.scope || installation.scopeRef !== scopeIdentity.scopeRef)\n\t\tthrow new Error(\"plugin installation scope mismatch\");\n}\n\nfunction ensureArtifactIdentity(artifact: PluginDistributionArtifactV1, record: PluginUpdateRecordV1): void {\n\tif (\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\ttypeof artifact.artifactRef !== \"string\" ||\n\t\tartifact.artifactRef.trim() === \"\"\n\t)\n\t\tthrow new Error(\"plugin distribution artifact identity mismatch\");\n\topaqueInstallationRef(artifact.artifactRef);\n}\n\nfunction isInvalidInstallationError(value: unknown): boolean {\n\treturn (\n\t\tvalue instanceof Error &&\n\t\t(value.message === \"plugin installation handle is invalid\" ||\n\t\t\tvalue.message === \"plugin installation scope is invalid\" ||\n\t\t\tvalue.message === \"plugin installation scope reference is invalid\" ||\n\t\t\tvalue.message === \"plugin installation scope reference must be opaque\" ||\n\t\t\tvalue.message === \"plugin global installation scope reference is invalid\" ||\n\t\t\tvalue.message === \"project installation scope reference is required\" ||\n\t\t\tvalue.message === \"plugin installation identity mismatch\" ||\n\t\t\tvalue.message === \"plugin installation scope mismatch\" ||\n\t\t\tvalue.message === \"plugin distribution artifact identity mismatch\")\n\t);\n}\n\nexport function createPluginInstallerV1(options: PluginInstallerOptionsV1): PluginInstallerV1 {\n\tconst supportedScopes = declaredScopes(options.host);\n\tconst supportsScope = (scope: PluginInstallationScopeV1): boolean => supportedScopes.includes(scope);\n\treturn {\n\t\tsupportedScopes,\n\t\tprepare(input) {\n\t\t\tconst staged = stagePluginUpdateV1({\n\t\t\t\tmanifest: input.manifest,\n\t\t\t\tsource: input.source,\n\t\t\t});\n\t\t\treturn verifyPluginUpdateV1({\n\t\t\t\trecord: staged,\n\t\t\t\thost: input.host,\n\t\t\t\texpectedDigest: input.expectedDigest,\n\t\t\t\tverifier: options.verifier,\n\t\t\t});\n\t\t},\n\t\tasync install(input) {\n\t\t\tif (input.signal?.aborted) return cancelled();\n\t\t\tlet scopeIdentity: PluginScopeIdentityV1;\n\t\t\ttry {\n\t\t\t\tscopeIdentity = normalizeScopeIdentity(input.scope, input.scopeRef);\n\t\t\t} catch {\n\t\t\t\treturn failure(\"invalid_installation\");\n\t\t\t}\n\t\t\tif (!supportsScope(scopeIdentity.scope)) return failure(\"unsupported_scope\");\n\t\t\tif (input.record.state !== \"verified\") return failure(\"invalid_installation\");\n\t\t\ttry {\n\t\t\t\tif (input.artifact !== undefined) ensureArtifactIdentity(input.artifact, input.record);\n\t\t\t\tconst installed = await options.host.install({\n\t\t\t\t\trecord: input.record,\n\t\t\t\t\tscope: scopeIdentity.scope,\n\t\t\t\t\tscopeRef: scopeIdentity.scopeRef,\n\t\t\t\t\t...(input.artifact === undefined ? {} : { artifact: input.artifact }),\n\t\t\t\t\tsignal: input.signal,\n\t\t\t\t});\n\t\t\t\thostAcceptedScope(installed, scopeIdentity);\n\t\t\t\treturn {\n\t\t\t\t\tstatus: \"succeeded\",\n\t\t\t\t\tinstallation: installationFrom(input.record, installed.installationRef, scopeIdentity, \"installed\"),\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\tif (isInvalidInstallationError(error)) return failure(\"invalid_installation\");\n\t\t\t\treturn input.signal?.aborted ? cancelled() : failure(\"install_failed\");\n\t\t\t}\n\t\t},\n\t\tasync activate(input) {\n\t\t\tif (input.signal?.aborted) return cancelled();\n\t\t\tlet scopeIdentity: PluginScopeIdentityV1;\n\t\t\ttry {\n\t\t\t\tscopeIdentity = normalizeScopeIdentity(input.scope, input.scopeRef);\n\t\t\t\tif (!supportsScope(scopeIdentity.scope)) return failure(\"unsupported_scope\");\n\t\t\t\tensureIdentity(input.installation, input.record, scopeIdentity);\n\t\t\t\tif (input.installation.state !== \"installed\" || input.record.state !== \"verified\")\n\t\t\t\t\treturn failure(\"invalid_installation\");\n\t\t\t\tawait options.host.activate({\n\t\t\t\t\tinstallation: input.installation,\n\t\t\t\t\trecord: input.record,\n\t\t\t\t\tscope: scopeIdentity.scope,\n\t\t\t\t\tscopeRef: scopeIdentity.scopeRef,\n\t\t\t\t\tsignal: input.signal,\n\t\t\t\t});\n\t\t\t\treturn {\n\t\t\t\t\tstatus: \"succeeded\",\n\t\t\t\t\tinstallation: Object.freeze({\n\t\t\t\t\t\t...input.installation,\n\t\t\t\t\t\tstate: \"active\" as const,\n\t\t\t\t\t}),\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\tif (isInvalidInstallationError(error)) return failure(\"invalid_installation\");\n\t\t\t\treturn input.signal?.aborted ? cancelled() : failure(\"activation_failed\");\n\t\t\t}\n\t\t},\n\t\tasync rollback(input) {\n\t\t\tif (input.signal?.aborted) return cancelled();\n\t\t\tlet scopeIdentity: PluginScopeIdentityV1;\n\t\t\ttry {\n\t\t\t\tscopeIdentity = normalizeScopeIdentity(input.scope, input.scopeRef);\n\t\t\t\tif (!supportsScope(scopeIdentity.scope)) return failure(\"unsupported_scope\");\n\t\t\t\tvalidateInstallation(input.failed);\n\t\t\t\tvalidateInstallation(input.previous);\n\t\t\t\tif (input.failed.state !== \"installed\" && input.failed.state !== \"active\")\n\t\t\t\t\treturn failure(\"invalid_installation\");\n\t\t\t\tif (input.previous.state !== \"active\") return failure(\"invalid_installation\");\n\t\t\t\tif (\n\t\t\t\t\tinput.failed.pluginId !== input.previous.pluginId ||\n\t\t\t\t\tinput.failed.scope !== scopeIdentity.scope ||\n\t\t\t\t\tinput.previous.scope !== scopeIdentity.scope ||\n\t\t\t\t\t(input.failed.scopeRef ?? DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1) !== scopeIdentity.scopeRef ||\n\t\t\t\t\t(input.previous.scopeRef ?? DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1) !== scopeIdentity.scopeRef\n\t\t\t\t)\n\t\t\t\t\treturn failure(\"invalid_installation\");\n\t\t\t\tawait options.host.rollback({\n\t\t\t\t\tfailed: input.failed,\n\t\t\t\t\tprevious: input.previous,\n\t\t\t\t\tscope: scopeIdentity.scope,\n\t\t\t\t\tscopeRef: scopeIdentity.scopeRef,\n\t\t\t\t\tsignal: input.signal,\n\t\t\t\t});\n\t\t\t\treturn {\n\t\t\t\t\tstatus: \"succeeded\",\n\t\t\t\t\tinstallation: Object.freeze({\n\t\t\t\t\t\t...input.previous,\n\t\t\t\t\t\tstate: \"active\" as const,\n\t\t\t\t\t}),\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\tif (isInvalidInstallationError(error)) return failure(\"invalid_installation\");\n\t\t\t\treturn input.signal?.aborted ? cancelled() : failure(\"rollback_failed\");\n\t\t\t}\n\t\t},\n\t\tasync remove(input) {\n\t\t\tif (input.signal?.aborted) return cancelled();\n\t\t\tlet scopeIdentity: PluginScopeIdentityV1;\n\t\t\ttry {\n\t\t\t\tscopeIdentity = normalizeScopeIdentity(input.scope, input.scopeRef);\n\t\t\t\tif (!supportsScope(scopeIdentity.scope)) return failure(\"unsupported_scope\");\n\t\t\t\tvalidateInstallation(input.installation);\n\t\t\t} catch {\n\t\t\t\treturn failure(\"invalid_installation\");\n\t\t\t}\n\t\t\tif (\n\t\t\t\tinput.installation.state !== \"installed\" &&\n\t\t\t\tinput.installation.state !== \"active\" &&\n\t\t\t\tinput.installation.state !== \"retained\"\n\t\t\t)\n\t\t\t\treturn failure(\"invalid_installation\");\n\t\t\tif (\n\t\t\t\tinput.installation.scope !== scopeIdentity.scope ||\n\t\t\t\t(input.installation.scopeRef ?? DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1) !== scopeIdentity.scopeRef\n\t\t\t)\n\t\t\t\treturn failure(\"invalid_installation\");\n\t\t\tif (options.host.uninstall === undefined) return failure(\"uninstall_failed\");\n\t\t\ttry {\n\t\t\t\tawait options.host.uninstall({\n\t\t\t\t\tinstallation: input.installation,\n\t\t\t\t\tscope: scopeIdentity.scope,\n\t\t\t\t\tscopeRef: scopeIdentity.scopeRef,\n\t\t\t\t\tsignal: input.signal,\n\t\t\t\t});\n\t\t\t\treturn {\n\t\t\t\t\tstatus: \"succeeded\",\n\t\t\t\t\tinstallation: Object.freeze({\n\t\t\t\t\t\t...input.installation,\n\t\t\t\t\t\tstate: \"retained\" as const,\n\t\t\t\t\t}),\n\t\t\t\t};\n\t\t\t} catch {\n\t\t\t\treturn input.signal?.aborted ? cancelled() : failure(\"uninstall_failed\");\n\t\t\t}\n\t\t},\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"installer.d.ts","sourceRoot":"","sources":["../../../src/plugins/ecosystem/installer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,mBAAmB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AC;KAC9B,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACrC,QAAQ,CAAC,KAAK,EAAE;QACf,QAAQ,CAAC,YAAY,EAAE,oBAAoB,CAAC;QAC5C,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAC;QACtC,QAAQ,CAAC,KAAK,CAAC,EAAE,yBAAyB,CAAC;QAC3C,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;KAC9B,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACrC,QAAQ,CAAC,KAAK,EAAE;QACf,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAC;QACtC,QAAQ,CAAC,QAAQ,EAAE,oBAAoB,CAAC;QACxC,QAAQ,CAAC,KAAK,CAAC,EAAE,yBAAyB,CAAC;QAC3C,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;KAC9B,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACrC,yEAAyE;IACzE,MAAM,CAAC,KAAK,EAAE;QACb,QAAQ,CAAC,YAAY,EAAE,oBAAoB,CAAC;QAC5C,QAAQ,CAAC,KAAK,CAAC,EAAE,yBAAyB,CAAC;QAC3C,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;KAC9B,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;CACrC;AAmLD,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,wBAAwB,GAAG,iBAAiB,CAyJ5F","sourcesContent":["import { t } from \"../../core/i18n/index.ts\";\nimport type { PluginDistributionArtifactV1 } from \"./distribution.ts\";\nimport type { HostFactsV1, PluginSourceVerifierV1, PluginUpdateRecordV1 } from \"./types.ts\";\n\nimport { stagePluginUpdateV1, type UpdateVerificationV1, verifyPluginUpdateV1 } from \"./updates.ts\";\n\nconst MAX_INSTALLATION_REF_CHARS_V1 = 2048;\nexport const MAX_PLUGIN_SCOPE_REF_CHARS_V1 = 2048;\n/** Stable host namespace for installations that are not project-local. */\nexport const DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1 = \"global:default\";\n\nexport type PluginInstallationScopeV1 = \"global\" | \"project\";\n\ninterface PluginScopeIdentityV1 {\n\treadonly scope: PluginInstallationScopeV1;\n\t/** Opaque host namespace; it must never disclose a local project path. */\n\treadonly scopeRef: string;\n}\n\nexport interface PluginInstallationV1 {\n\treadonly version: 1;\n\treadonly pluginId: string;\n\treadonly pluginVersion: string;\n\treadonly manifestDigest: string;\n\t/** The host installation namespace. It is part of the opaque installation identity. */\n\treadonly scope: PluginInstallationScopeV1;\n\t/** Concrete host namespace that distinguishes global and individual project installations. */\n\treadonly scopeRef?: string;\n\t/** Opaque host-owned installation handle; never a local path. */\n\treadonly installationRef: string;\n\treadonly state: \"installed\" | \"active\" | \"retained\";\n}\n\nexport interface PluginInstallHostV1 {\n\t/**\n\t * Scopes that this host can isolate physically. Omitting this declaration\n\t * preserves the legacy global-only host behavior; project operations must be\n\t * declared explicitly.\n\t */\n\treadonly supportedScopes?: readonly PluginInstallationScopeV1[];\n\t/** Host operations are atomic from the installer's perspective: an abort may\n\t * prevent starting work, but once a method resolves its side effect is committed. */\n\tinstall(input: {\n\t\treadonly record: PluginUpdateRecordV1;\n\t\treadonly scope: PluginInstallationScopeV1;\n\t\treadonly scopeRef: string;\n\t\t/** A host-owned, digest-bound package reference. Package bytes never cross this contract. */\n\t\treadonly artifact?: PluginDistributionArtifactV1;\n\t\treadonly signal?: AbortSignal;\n\t}): Promise<{\n\t\treadonly installationRef: string;\n\t\treadonly scope?: PluginInstallationScopeV1;\n\t\treadonly scopeRef?: string;\n\t}>;\n\tactivate(input: {\n\t\treadonly installation: PluginInstallationV1;\n\t\treadonly record: PluginUpdateRecordV1;\n\t\treadonly scope: PluginInstallationScopeV1;\n\t\treadonly scopeRef: string;\n\t\treadonly signal?: AbortSignal;\n\t}): Promise<void>;\n\trollback(input: {\n\t\treadonly failed: PluginInstallationV1;\n\t\treadonly previous: PluginInstallationV1;\n\t\treadonly scope: PluginInstallationScopeV1;\n\t\treadonly scopeRef: string;\n\t\treadonly signal?: AbortSignal;\n\t}): Promise<void>;\n\t/**\n\t * Remove a host-owned installation. The method is optional so hosts can\n\t * still expose state-only management while they are migrating; callers that\n\t * need physical cleanup must treat a missing method as unsupported.\n\t */\n\tuninstall?: (input: {\n\t\treadonly installation: PluginInstallationV1;\n\t\treadonly scope: PluginInstallationScopeV1;\n\t\treadonly scopeRef: string;\n\t\treadonly signal?: AbortSignal;\n\t}) => Promise<void>;\n}\n\nexport interface PluginInstallerOptionsV1 {\n\treadonly host: PluginInstallHostV1;\n\treadonly verifier?: PluginSourceVerifierV1;\n}\n\nexport type PluginInstallerErrorCodeV1 =\n\t| \"invalid_installation\"\n\t| \"unsupported_scope\"\n\t| \"install_failed\"\n\t| \"activation_failed\"\n\t| \"rollback_failed\"\n\t| \"uninstall_failed\";\n\nexport type PluginInstallerResultV1 =\n\t| {\n\t\t\treadonly status: \"succeeded\";\n\t\t\treadonly installation: PluginInstallationV1;\n\t }\n\t| {\n\t\t\treadonly status: \"cancelled\";\n\t\t\treadonly error: { readonly code: \"cancelled\"; readonly message: string };\n\t }\n\t| {\n\t\t\treadonly status: \"failed\";\n\t\t\treadonly error: {\n\t\t\t\treadonly code: PluginInstallerErrorCodeV1;\n\t\t\t\treadonly message: string;\n\t\t\t};\n\t };\n\nexport interface PluginInstallerV1 {\n\t/** Declared, host-backed installation scopes. Project support is never inferred. */\n\treadonly supportedScopes: readonly PluginInstallationScopeV1[];\n\tprepare(input: {\n\t\treadonly manifest: PluginUpdateRecordV1[\"manifest\"];\n\t\treadonly source: string;\n\t\treadonly host: HostFactsV1;\n\t\treadonly expectedDigest?: string;\n\t}): UpdateVerificationV1;\n\tinstall(input: {\n\t\treadonly record: PluginUpdateRecordV1;\n\t\t/** Omitting scope preserves the existing global installation behavior. */\n\t\treadonly scope?: PluginInstallationScopeV1;\n\t\t/** Required for project installations; global defaults to `global:default`. */\n\t\treadonly scopeRef?: string;\n\t\treadonly artifact?: PluginDistributionArtifactV1;\n\t\treadonly signal?: AbortSignal;\n\t}): Promise<PluginInstallerResultV1>;\n\tactivate(input: {\n\t\treadonly installation: PluginInstallationV1;\n\t\treadonly record: PluginUpdateRecordV1;\n\t\treadonly scope?: PluginInstallationScopeV1;\n\t\treadonly scopeRef?: string;\n\t\treadonly signal?: AbortSignal;\n\t}): Promise<PluginInstallerResultV1>;\n\trollback(input: {\n\t\treadonly failed: PluginInstallationV1;\n\t\treadonly previous: PluginInstallationV1;\n\t\treadonly scope?: PluginInstallationScopeV1;\n\t\treadonly scopeRef?: string;\n\t\treadonly signal?: AbortSignal;\n\t}): Promise<PluginInstallerResultV1>;\n\t/** Remove one installed version after validating its opaque identity. */\n\tremove(input: {\n\t\treadonly installation: PluginInstallationV1;\n\t\treadonly scope?: PluginInstallationScopeV1;\n\t\treadonly scopeRef?: string;\n\t\treadonly signal?: AbortSignal;\n\t}): Promise<PluginInstallerResultV1>;\n}\n\nfunction opaqueInstallationRef(value: unknown): string {\n\tif (typeof value !== \"string\" || value.trim() === \"\" || value.length > MAX_INSTALLATION_REF_CHARS_V1)\n\t\tthrow new Error(t(\"installation reference is invalid\"));\n\tif (/^(?:file:|[a-zA-Z]:[\\\\/]|[\\\\/]{1,2}|\\\\\\\\)/iu.test(value) || /\\s/u.test(value))\n\t\tthrow new Error(t(\"installation reference must be opaque\"));\n\treturn value;\n}\n\nfunction opaqueScopeRef(value: unknown): string {\n\tif (typeof value !== \"string\" || value.trim() === \"\" || value.length > MAX_PLUGIN_SCOPE_REF_CHARS_V1)\n\t\tthrow new Error(\"plugin installation scope reference is invalid\");\n\tif (/^(?:file:|[a-zA-Z]:[\\\\/]|[\\\\/]{1,2}|\\\\\\\\)/iu.test(value) || /\\s/u.test(value))\n\t\tthrow new Error(\"plugin installation scope reference must be opaque\");\n\treturn value;\n}\n\nfunction installationFrom(\n\trecord: PluginUpdateRecordV1,\n\tinstallationRef: string,\n\tscopeIdentity: PluginScopeIdentityV1,\n\tstate: PluginInstallationV1[\"state\"],\n): PluginInstallationV1 {\n\treturn Object.freeze({\n\t\tversion: 1,\n\t\tpluginId: record.pluginId,\n\t\tpluginVersion: record.pluginVersion,\n\t\tmanifestDigest: record.manifestDigest,\n\t\tscope: scopeIdentity.scope,\n\t\tscopeRef: scopeIdentity.scopeRef,\n\t\tinstallationRef: opaqueInstallationRef(installationRef),\n\t\tstate,\n\t});\n}\n\nfunction cancelled(): PluginInstallerResultV1 {\n\treturn {\n\t\tstatus: \"cancelled\",\n\t\terror: {\n\t\t\tcode: \"cancelled\",\n\t\t\tmessage: \"Plugin installation operation was cancelled\",\n\t\t},\n\t};\n}\n\nfunction failure(code: PluginInstallerErrorCodeV1): PluginInstallerResultV1 {\n\treturn {\n\t\tstatus: \"failed\",\n\t\terror: {\n\t\t\tcode,\n\t\t\tmessage:\n\t\t\t\tcode === \"invalid_installation\"\n\t\t\t\t\t? \"The plugin installation handle is invalid\"\n\t\t\t\t\t: code === \"unsupported_scope\"\n\t\t\t\t\t\t? \"The plugin installer does not support this scope\"\n\t\t\t\t\t\t: code === \"install_failed\"\n\t\t\t\t\t\t\t? \"The host plugin installer failed\"\n\t\t\t\t\t\t\t: code === \"activation_failed\"\n\t\t\t\t\t\t\t\t? \"The host plugin activation failed\"\n\t\t\t\t\t\t\t\t: code === \"rollback_failed\"\n\t\t\t\t\t\t\t\t\t? \"The host plugin rollback failed\"\n\t\t\t\t\t\t\t\t\t: \"The host plugin uninstall failed\",\n\t\t},\n\t};\n}\n\nfunction validateInstallation(installation: PluginInstallationV1): void {\n\tif (\n\t\tinstallation.version !== 1 ||\n\t\ttypeof installation.pluginId !== \"string\" ||\n\t\ttypeof installation.pluginVersion !== \"string\" ||\n\t\ttypeof installation.manifestDigest !== \"string\" ||\n\t\tinstallation.pluginId.trim() === \"\" ||\n\t\tinstallation.pluginVersion.trim() === \"\" ||\n\t\tinstallation.manifestDigest.trim() === \"\"\n\t)\n\t\tthrow new Error(\"plugin installation handle is invalid\");\n\tif (installation.scope !== \"global\" && installation.scope !== \"project\")\n\t\tthrow new Error(\"plugin installation scope is invalid\");\n\tconst scopeRef =\n\t\tinstallation.scopeRef === undefined\n\t\t\t? installation.scope === \"global\"\n\t\t\t\t? DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1\n\t\t\t\t: (() => {\n\t\t\t\t\t\tthrow new Error(\"project installation scope reference is required\");\n\t\t\t\t\t})()\n\t\t\t: opaqueScopeRef(installation.scopeRef);\n\tif (installation.scope === \"global\" && scopeRef !== DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1)\n\t\tthrow new Error(\"plugin global installation scope reference is invalid\");\n\topaqueInstallationRef(installation.installationRef);\n}\n\nfunction ensureIdentity(\n\tinstallation: PluginInstallationV1,\n\trecord: PluginUpdateRecordV1,\n\tscopeIdentity: PluginScopeIdentityV1,\n): void {\n\tvalidateInstallation(installation);\n\tif (\n\t\tinstallation.pluginId !== record.pluginId ||\n\t\tinstallation.pluginVersion !== record.pluginVersion ||\n\t\tinstallation.manifestDigest !== record.manifestDigest ||\n\t\tinstallation.scope !== scopeIdentity.scope ||\n\t\t(installation.scopeRef ?? DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1) !== scopeIdentity.scopeRef\n\t)\n\t\tthrow new Error(\"plugin installation identity mismatch\");\n}\n\nfunction normalizeScope(scope: PluginInstallationScopeV1 | undefined): PluginInstallationScopeV1 {\n\tif (scope === undefined) return \"global\";\n\tif (scope === \"global\" || scope === \"project\") return scope;\n\tthrow new Error(\"plugin installation scope is invalid\");\n}\n\nfunction normalizeScopeIdentity(\n\tscope: PluginInstallationScopeV1 | undefined,\n\tscopeRef: string | undefined,\n): PluginScopeIdentityV1 {\n\tconst normalizedScope = normalizeScope(scope);\n\tif (scopeRef === undefined) {\n\t\tif (normalizedScope !== \"global\") throw new Error(\"project installation scope reference is required\");\n\t\treturn Object.freeze({ scope: normalizedScope, scopeRef: DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1 });\n\t}\n\tconst normalizedScopeRef = opaqueScopeRef(scopeRef);\n\tif (normalizedScope === \"global\" && normalizedScopeRef !== DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1)\n\t\tthrow new Error(\"plugin global installation scope reference is invalid\");\n\treturn Object.freeze({ scope: normalizedScope, scopeRef: normalizedScopeRef });\n}\n\nfunction declaredScopes(host: PluginInstallHostV1): readonly PluginInstallationScopeV1[] {\n\tif (host.supportedScopes === undefined) return Object.freeze([\"global\"]);\n\tif (\n\t\t!Array.isArray(host.supportedScopes) ||\n\t\tnew Set(host.supportedScopes).size !== host.supportedScopes.length ||\n\t\thost.supportedScopes.some((scope) => scope !== \"global\" && scope !== \"project\")\n\t)\n\t\treturn Object.freeze([]);\n\treturn Object.freeze([...host.supportedScopes]);\n}\n\nfunction hostAcceptedScope(\n\tinstallation: { readonly scope?: PluginInstallationScopeV1; readonly scopeRef?: string },\n\tscopeIdentity: PluginScopeIdentityV1,\n): void {\n\tif (scopeIdentity.scope === \"global\" && installation.scope === undefined && installation.scopeRef === undefined)\n\t\treturn;\n\tif (installation.scope !== scopeIdentity.scope || installation.scopeRef !== scopeIdentity.scopeRef)\n\t\tthrow new Error(\"plugin installation scope mismatch\");\n}\n\nfunction ensureArtifactIdentity(artifact: PluginDistributionArtifactV1, record: PluginUpdateRecordV1): void {\n\tif (\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\ttypeof artifact.artifactRef !== \"string\" ||\n\t\tartifact.artifactRef.trim() === \"\"\n\t)\n\t\tthrow new Error(\"plugin distribution artifact identity mismatch\");\n\topaqueInstallationRef(artifact.artifactRef);\n}\n\nfunction isInvalidInstallationError(value: unknown): boolean {\n\treturn (\n\t\tvalue instanceof Error &&\n\t\t(value.message === \"plugin installation handle is invalid\" ||\n\t\t\tvalue.message === \"plugin installation scope is invalid\" ||\n\t\t\tvalue.message === \"plugin installation scope reference is invalid\" ||\n\t\t\tvalue.message === \"plugin installation scope reference must be opaque\" ||\n\t\t\tvalue.message === \"plugin global installation scope reference is invalid\" ||\n\t\t\tvalue.message === \"project installation scope reference is required\" ||\n\t\t\tvalue.message === \"plugin installation identity mismatch\" ||\n\t\t\tvalue.message === \"plugin installation scope mismatch\" ||\n\t\t\tvalue.message === \"plugin distribution artifact identity mismatch\")\n\t);\n}\n\nexport function createPluginInstallerV1(options: PluginInstallerOptionsV1): PluginInstallerV1 {\n\tconst supportedScopes = declaredScopes(options.host);\n\tconst supportsScope = (scope: PluginInstallationScopeV1): boolean => supportedScopes.includes(scope);\n\treturn {\n\t\tsupportedScopes,\n\t\tprepare(input) {\n\t\t\tconst staged = stagePluginUpdateV1({\n\t\t\t\tmanifest: input.manifest,\n\t\t\t\tsource: input.source,\n\t\t\t});\n\t\t\treturn verifyPluginUpdateV1({\n\t\t\t\trecord: staged,\n\t\t\t\thost: input.host,\n\t\t\t\texpectedDigest: input.expectedDigest,\n\t\t\t\tverifier: options.verifier,\n\t\t\t});\n\t\t},\n\t\tasync install(input) {\n\t\t\tif (input.signal?.aborted) return cancelled();\n\t\t\tlet scopeIdentity: PluginScopeIdentityV1;\n\t\t\ttry {\n\t\t\t\tscopeIdentity = normalizeScopeIdentity(input.scope, input.scopeRef);\n\t\t\t} catch {\n\t\t\t\treturn failure(\"invalid_installation\");\n\t\t\t}\n\t\t\tif (!supportsScope(scopeIdentity.scope)) return failure(\"unsupported_scope\");\n\t\t\tif (input.record.state !== \"verified\") return failure(\"invalid_installation\");\n\t\t\ttry {\n\t\t\t\tif (input.artifact !== undefined) ensureArtifactIdentity(input.artifact, input.record);\n\t\t\t\tconst installed = await options.host.install({\n\t\t\t\t\trecord: input.record,\n\t\t\t\t\tscope: scopeIdentity.scope,\n\t\t\t\t\tscopeRef: scopeIdentity.scopeRef,\n\t\t\t\t\t...(input.artifact === undefined ? {} : { artifact: input.artifact }),\n\t\t\t\t\tsignal: input.signal,\n\t\t\t\t});\n\t\t\t\thostAcceptedScope(installed, scopeIdentity);\n\t\t\t\treturn {\n\t\t\t\t\tstatus: \"succeeded\",\n\t\t\t\t\tinstallation: installationFrom(input.record, installed.installationRef, scopeIdentity, \"installed\"),\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\tif (isInvalidInstallationError(error)) return failure(\"invalid_installation\");\n\t\t\t\treturn input.signal?.aborted ? cancelled() : failure(\"install_failed\");\n\t\t\t}\n\t\t},\n\t\tasync activate(input) {\n\t\t\tif (input.signal?.aborted) return cancelled();\n\t\t\tlet scopeIdentity: PluginScopeIdentityV1;\n\t\t\ttry {\n\t\t\t\tscopeIdentity = normalizeScopeIdentity(input.scope, input.scopeRef);\n\t\t\t\tif (!supportsScope(scopeIdentity.scope)) return failure(\"unsupported_scope\");\n\t\t\t\tensureIdentity(input.installation, input.record, scopeIdentity);\n\t\t\t\tif (input.installation.state !== \"installed\" || input.record.state !== \"verified\")\n\t\t\t\t\treturn failure(\"invalid_installation\");\n\t\t\t\tawait options.host.activate({\n\t\t\t\t\tinstallation: input.installation,\n\t\t\t\t\trecord: input.record,\n\t\t\t\t\tscope: scopeIdentity.scope,\n\t\t\t\t\tscopeRef: scopeIdentity.scopeRef,\n\t\t\t\t\tsignal: input.signal,\n\t\t\t\t});\n\t\t\t\treturn {\n\t\t\t\t\tstatus: \"succeeded\",\n\t\t\t\t\tinstallation: Object.freeze({\n\t\t\t\t\t\t...input.installation,\n\t\t\t\t\t\tstate: \"active\" as const,\n\t\t\t\t\t}),\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\tif (isInvalidInstallationError(error)) return failure(\"invalid_installation\");\n\t\t\t\treturn input.signal?.aborted ? cancelled() : failure(\"activation_failed\");\n\t\t\t}\n\t\t},\n\t\tasync rollback(input) {\n\t\t\tif (input.signal?.aborted) return cancelled();\n\t\t\tlet scopeIdentity: PluginScopeIdentityV1;\n\t\t\ttry {\n\t\t\t\tscopeIdentity = normalizeScopeIdentity(input.scope, input.scopeRef);\n\t\t\t\tif (!supportsScope(scopeIdentity.scope)) return failure(\"unsupported_scope\");\n\t\t\t\tvalidateInstallation(input.failed);\n\t\t\t\tvalidateInstallation(input.previous);\n\t\t\t\tif (input.failed.state !== \"installed\" && input.failed.state !== \"active\")\n\t\t\t\t\treturn failure(\"invalid_installation\");\n\t\t\t\tif (input.previous.state !== \"active\") return failure(\"invalid_installation\");\n\t\t\t\tif (\n\t\t\t\t\tinput.failed.pluginId !== input.previous.pluginId ||\n\t\t\t\t\tinput.failed.scope !== scopeIdentity.scope ||\n\t\t\t\t\tinput.previous.scope !== scopeIdentity.scope ||\n\t\t\t\t\t(input.failed.scopeRef ?? DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1) !== scopeIdentity.scopeRef ||\n\t\t\t\t\t(input.previous.scopeRef ?? DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1) !== scopeIdentity.scopeRef\n\t\t\t\t)\n\t\t\t\t\treturn failure(\"invalid_installation\");\n\t\t\t\tawait options.host.rollback({\n\t\t\t\t\tfailed: input.failed,\n\t\t\t\t\tprevious: input.previous,\n\t\t\t\t\tscope: scopeIdentity.scope,\n\t\t\t\t\tscopeRef: scopeIdentity.scopeRef,\n\t\t\t\t\tsignal: input.signal,\n\t\t\t\t});\n\t\t\t\treturn {\n\t\t\t\t\tstatus: \"succeeded\",\n\t\t\t\t\tinstallation: Object.freeze({\n\t\t\t\t\t\t...input.previous,\n\t\t\t\t\t\tstate: \"active\" as const,\n\t\t\t\t\t}),\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\tif (isInvalidInstallationError(error)) return failure(\"invalid_installation\");\n\t\t\t\treturn input.signal?.aborted ? cancelled() : failure(\"rollback_failed\");\n\t\t\t}\n\t\t},\n\t\tasync remove(input) {\n\t\t\tif (input.signal?.aborted) return cancelled();\n\t\t\tlet scopeIdentity: PluginScopeIdentityV1;\n\t\t\ttry {\n\t\t\t\tscopeIdentity = normalizeScopeIdentity(input.scope, input.scopeRef);\n\t\t\t\tif (!supportsScope(scopeIdentity.scope)) return failure(\"unsupported_scope\");\n\t\t\t\tvalidateInstallation(input.installation);\n\t\t\t} catch {\n\t\t\t\treturn failure(\"invalid_installation\");\n\t\t\t}\n\t\t\tif (\n\t\t\t\tinput.installation.state !== \"installed\" &&\n\t\t\t\tinput.installation.state !== \"active\" &&\n\t\t\t\tinput.installation.state !== \"retained\"\n\t\t\t)\n\t\t\t\treturn failure(\"invalid_installation\");\n\t\t\tif (\n\t\t\t\tinput.installation.scope !== scopeIdentity.scope ||\n\t\t\t\t(input.installation.scopeRef ?? DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1) !== scopeIdentity.scopeRef\n\t\t\t)\n\t\t\t\treturn failure(\"invalid_installation\");\n\t\t\tif (options.host.uninstall === undefined) return failure(\"uninstall_failed\");\n\t\t\ttry {\n\t\t\t\tawait options.host.uninstall({\n\t\t\t\t\tinstallation: input.installation,\n\t\t\t\t\tscope: scopeIdentity.scope,\n\t\t\t\t\tscopeRef: scopeIdentity.scopeRef,\n\t\t\t\t\tsignal: input.signal,\n\t\t\t\t});\n\t\t\t\treturn {\n\t\t\t\t\tstatus: \"succeeded\",\n\t\t\t\t\tinstallation: Object.freeze({\n\t\t\t\t\t\t...input.installation,\n\t\t\t\t\t\tstate: \"retained\" as const,\n\t\t\t\t\t}),\n\t\t\t\t};\n\t\t\t} catch {\n\t\t\t\treturn input.signal?.aborted ? cancelled() : failure(\"uninstall_failed\");\n\t\t\t}\n\t\t},\n\t};\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { t } from "../../core/i18n/index.js";
|
|
1
2
|
import { stagePluginUpdateV1, verifyPluginUpdateV1 } from "./updates.js";
|
|
2
3
|
const MAX_INSTALLATION_REF_CHARS_V1 = 2048;
|
|
3
4
|
export const MAX_PLUGIN_SCOPE_REF_CHARS_V1 = 2048;
|
|
@@ -5,9 +6,9 @@ export const MAX_PLUGIN_SCOPE_REF_CHARS_V1 = 2048;
|
|
|
5
6
|
export const DEFAULT_GLOBAL_PLUGIN_SCOPE_REF_V1 = "global:default";
|
|
6
7
|
function opaqueInstallationRef(value) {
|
|
7
8
|
if (typeof value !== "string" || value.trim() === "" || value.length > MAX_INSTALLATION_REF_CHARS_V1)
|
|
8
|
-
throw new Error("installation reference is invalid");
|
|
9
|
+
throw new Error(t("installation reference is invalid"));
|
|
9
10
|
if (/^(?:file:|[a-zA-Z]:[\\/]|[\\/]{1,2}|\\\\)/iu.test(value) || /\s/u.test(value))
|
|
10
|
-
throw new Error("installation reference must be opaque");
|
|
11
|
+
throw new Error(t("installation reference must be opaque"));
|
|
11
12
|
return value;
|
|
12
13
|
}
|
|
13
14
|
function opaqueScopeRef(value) {
|