@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":"plugin-testkit.d.ts","sourceRoot":"","sources":["../../src/testing/plugin-testkit.ts"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,uBAAuB,EAG5B,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACN,KAAK,iBAAiB,EAGtB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EACN,KAAK,aAAa,EAKlB,KAAK,gBAAgB,EAGrB,KAAK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AS,2BAA2B,EAAE,CAAC;IACjE,QAAQ,CAAC,eAAe,EAAE,SAAS,8BAA8B,EAAE,CAAC;IACpE,QAAQ,CAAC,iBAAiB,EAAE,SAAS,6BAA6B,EAAE,CAAC;IACrE,QAAQ,CAAC,gBAAgB,EAAE,wBAAwB,CAAC,kBAAkB,CAAC,CAAC;IACxE,QAAQ,CAAC,SAAS,EAAE,wBAAwB,CAAC;CAC7C;AAED,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAC;IACpC,oFAAoF;IACpF,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa,CAAC;IACrC,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,OAAO,IAAI,wBAAwB,CAAC;IACpC,UAAU,IAAI,uBAAuB,CAAC;IACtC,gFAAgF;IAChF,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACzB;AAuJD,8EAA8E;AAC9E,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CA+XhF;AAED,gFAAgF;AAChF,wBAAsB,mBAAmB,CACxC,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,OAAO,CAAC,uBAAuB,CAAC,GACzC,OAAO,CAAC,uBAAuB,CAAC,CAYlC","sourcesContent":["import { installBootstrapLifecycle } from \"../core/extensions/bootstrap-lifecycle.ts\";\nimport {\n\ttype CapabilityPluginFactory,\n\ttype CapabilityPluginHandle,\n\tloadCapabilityPlugin,\n} from \"../core/extensions/capability-plugin.ts\";\nimport {\n\ttype CapabilityRuntime,\n\tcreateCapabilityRuntime,\n\tresolvePluginCapabilityOrder,\n} from \"../core/extensions/capability-runtime.ts\";\nimport {\n\ttype CapabilityAPI,\n\ttype CapabilityDirectoryAPI,\n\ttype CapabilityProviderHandler,\n\ttype DisposableRegistration,\n\tEXPERIMENTAL_PUBLIC_API_VERSION,\n\ttype HostCapabilities,\n\ttype LifecycleDispatchRequest,\n\ttype LifecycleDispatchResult,\n\ttype LifecycleEvent,\n\ttype LifecyclePhase,\n\ttype OperationHandle,\n\ttype OperationStatus,\n\ttype PluginCapabilityDeclaration,\n\ttype PluginManifest,\n\ttype RuntimeInspectorSnapshot,\n\ttype StateAPI,\n\ttype StateChange,\n\ttype StateEntry,\n\ttype StateSetOptions,\n} from \"../core/extensions/public-api.ts\";\n\n/**\n * A deterministic, runtime-only fixture for experimental capability plugins.\n *\n * It deliberately does not create an AgentSession or a model provider. Tests\n * that need those integration points should use the existing session harness.\n */\nexport interface PluginTestKitPlugin {\n\treadonly manifest: PluginManifest;\n\treadonly factory: CapabilityPluginFactory;\n}\n\nexport interface PluginTestKitOptions {\n\treadonly plugins: readonly PluginTestKitPlugin[];\n\treadonly host?: Omit<HostCapabilities, \"apiVersion\">;\n\treadonly clock?: () => number;\n\t/** Injects stable runtime identifiers for deterministic transcript tests. */\n\treadonly idFactory?: (kind: string, sequence: number) => string;\n\t/** Logical root used to identify inline manifests without a host filesystem path. */\n\treadonly manifestRoot?: string;\n\t/**\n\t * Installs the bootstrap lifecycle catalog (host parity: the real session\n\t * host installs it) before the plugin load loop, so plugin factories can\n\t * registerObserve standard events. Off by default to keep existing\n\t * transcripts unchanged; the installed handle is disposed by\n\t * runtime.disposeAll() inside dispose().\n\t */\n\treadonly lifecycle?: boolean;\n}\n\nexport interface PluginTestKitManifestIdentity {\n\treadonly pluginId: string;\n\treadonly version: string;\n\treadonly entry: string;\n}\n\nexport interface PluginTestKitLifecycleEnvelope {\n\treadonly eventId: string;\n\treadonly type: string;\n\treadonly version: number;\n\treadonly phase: LifecycleEvent[\"phase\"];\n\treadonly deliveryId: string;\n\treadonly source: string;\n\treadonly operationId?: string;\n\treadonly correlationId?: string;\n\treadonly causationId?: string;\n\treadonly data: unknown;\n}\n\nexport interface PluginTestKitLifecycleFailureReport {\n\treadonly eventId: string;\n\treadonly type: string;\n\treadonly version: number;\n\treadonly phase: LifecyclePhase;\n\treadonly status: \"transform-failed\" | \"execute-failed\" | \"delivered\" | \"queued\";\n\treadonly attempted: number;\n\treadonly succeeded: number;\n\treadonly queued?: number;\n\treadonly failed: number;\n\treadonly failures: readonly {\n\t\treadonly pluginId: string;\n\t\treadonly registrationId: string;\n\t\treadonly kind: string;\n\t\treadonly error: unknown;\n\t}[];\n}\n\n/** A dispatch rejection is retained even when no event envelope was created. */\nexport interface PluginTestKitLifecycleFailure {\n\treadonly eventId: string | null;\n\treadonly type: string | null;\n\treadonly version: number | null;\n\treadonly phase: LifecyclePhase | null;\n\treadonly deliveryId: string | null;\n\treadonly source: string | null;\n\treadonly operationId?: string;\n\treadonly correlationId?: string;\n\treadonly causationId?: string;\n\treadonly data?: unknown;\n\treadonly status: \"rejected\" | \"cancelled\" | \"transform-failed\" | \"execute-failed\";\n\treadonly error: unknown;\n\treadonly report?: PluginTestKitLifecycleFailureReport;\n}\n\nexport interface PluginTestKitStateMutation {\n\treadonly pluginId: string;\n\treadonly action: \"set\" | \"delete\";\n\treadonly key: string;\n\treadonly status: \"committed\" | \"rejected\";\n\treadonly revision?: number;\n\treadonly expectedRevision?: number;\n\treadonly value?: unknown;\n\treadonly operationId?: string;\n\treadonly correlationId?: string;\n\treadonly error?: unknown;\n}\n\nexport interface PluginTestKitStateWatchDelivery {\n\treadonly pluginId: string;\n\treadonly watcherId: string;\n\treadonly key: string;\n\treadonly revision: number;\n\treadonly status: \"delivered\" | \"failed\";\n\treadonly value?: unknown;\n\treadonly operationId?: string;\n\treadonly correlationId?: string;\n\treadonly error?: unknown;\n}\n\nexport interface PluginTestKitCapabilityCall {\n\treadonly operationId: string | null;\n\treadonly callerPluginId: string;\n\treadonly providerPluginId: string;\n\treadonly capabilityId: string;\n\treadonly capabilityVersion: number;\n\treadonly capabilityKind: PluginCapabilityDeclaration[\"kind\"];\n\treadonly status: OperationStatus;\n\treadonly error?: unknown;\n}\n\nexport interface PluginTestKitTranscript {\n\treadonly version: 1;\n\treadonly manifestRoot: string;\n\treadonly manifests: readonly PluginTestKitManifestIdentity[];\n\treadonly inputOrder: readonly string[];\n\treadonly loadOrder: readonly string[];\n\treadonly state: readonly {\n\t\treadonly pluginId: string;\n\t\treadonly entries: readonly StateEntry[];\n\t}[];\n\treadonly stateMutations: readonly PluginTestKitStateMutation[];\n\treadonly stateWatchDeliveries: readonly PluginTestKitStateWatchDelivery[];\n\treadonly capabilityCalls: readonly PluginTestKitCapabilityCall[];\n\treadonly lifecycleEvents: readonly PluginTestKitLifecycleEnvelope[];\n\treadonly lifecycleFailures: readonly PluginTestKitLifecycleFailure[];\n\treadonly lifecycleReports: RuntimeInspectorSnapshot[\"lifecycleReports\"];\n\treadonly inspector: RuntimeInspectorSnapshot;\n}\n\nexport interface PluginTestKit {\n\treadonly runtime: CapabilityRuntime;\n\t/** Resolves after every manifest is topology-ordered and its factory has loaded. */\n\treadonly ready: Promise<void>;\n\tapi(pluginId: string): CapabilityAPI;\n\trevoke(pluginId: string): void;\n\tinspect(): RuntimeInspectorSnapshot;\n\ttranscript(): PluginTestKitTranscript;\n\t/** Waits for lifecycle facts initiated by runtime-owned detached operations. */\n\tflushLifecycle(): Promise<void>;\n\tdispose(): Promise<void>;\n}\n\nfunction snapshot<T>(value: T): T {\n\tconst clone = structuredClone(value);\n\tconst freeze = (candidate: unknown): void => {\n\t\tif (!candidate || typeof candidate !== \"object\" || ArrayBuffer.isView(candidate)) return;\n\t\tfor (const child of Object.values(candidate as Record<string, unknown>)) freeze(child);\n\t\tObject.freeze(candidate);\n\t};\n\tfreeze(clone);\n\treturn clone;\n}\n\nfunction transcriptValue(value: unknown, seen = new WeakSet<object>()): unknown {\n\tif (value === null || typeof value === \"string\" || typeof value === \"boolean\") return value;\n\tif (typeof value === \"number\") return Number.isFinite(value) ? value : String(value);\n\tif (typeof value === \"bigint\") return `${value}n`;\n\tif (value === undefined) return null;\n\tif (value instanceof Error) {\n\t\tif (seen.has(value)) return \"[Circular]\";\n\t\tseen.add(value);\n\t\tconst output: Record<string, unknown> = { name: value.name, message: value.message };\n\t\tconst code = (value as Error & { code?: unknown }).code;\n\t\tif (code !== undefined) output.code = transcriptValue(code, seen);\n\t\tconst cause = (value as Error & { cause?: unknown }).cause;\n\t\tif (cause !== undefined) output.cause = transcriptValue(cause, seen);\n\t\tfor (const key of Object.keys(value).sort()) {\n\t\t\tif (key === \"code\" || key === \"cause\") continue;\n\t\t\toutput[key] = transcriptValue((value as unknown as Record<string, unknown>)[key], seen);\n\t\t}\n\t\treturn output;\n\t}\n\tif (typeof value !== \"object\") return String(value);\n\tif (seen.has(value)) return \"[Circular]\";\n\tseen.add(value);\n\tif (Array.isArray(value)) return value.map((item) => transcriptValue(item, seen));\n\tconst output: Record<string, unknown> = {};\n\tfor (const key of Object.keys(value as Record<string, unknown>).sort()) {\n\t\toutput[key] = transcriptValue((value as Record<string, unknown>)[key], seen);\n\t}\n\treturn output;\n}\n\nfunction canonicalJson(value: unknown): string {\n\tconst serialized = JSON.stringify(transcriptValue(value));\n\t// v8 ignore next -- transcriptValue 已消毒全部值,JSON.stringify 不会返回 undefined\n\tif (serialized === undefined) throw new Error(\"Plugin testkit transcript is not JSON-serializable\");\n\treturn serialized;\n}\n\ntype PluginTestKitLifecycleReport = PluginTestKitLifecycleFailureReport;\n\nfunction lifecycleFailureReport(error: unknown): PluginTestKitLifecycleReport | undefined {\n\tif (!error || typeof error !== \"object\") return undefined;\n\tconst report = (error as { report?: unknown }).report;\n\tif (!report || typeof report !== \"object\") return undefined;\n\tconst candidate = report as RuntimeInspectorSnapshot[\"lifecycleReports\"][number];\n\t// v8 ignore next -- report 由 runtime 构造、形状恒满足;此处仅防御伪造的 report\n\tif (\n\t\ttypeof candidate.eventId !== \"string\" ||\n\t\ttypeof candidate.type !== \"string\" ||\n\t\t!Number.isSafeInteger(candidate.version) ||\n\t\t(candidate.phase !== \"raw\" && candidate.phase !== \"candidate\" && candidate.phase !== \"committed\") ||\n\t\t(candidate.status !== \"transform-failed\" &&\n\t\t\tcandidate.status !== \"execute-failed\" &&\n\t\t\tcandidate.status !== \"delivered\") ||\n\t\t!Array.isArray(candidate.failures)\n\t) {\n\t\treturn undefined;\n\t}\n\treturn {\n\t\teventId: candidate.eventId,\n\t\ttype: candidate.type,\n\t\tversion: candidate.version,\n\t\tphase: candidate.phase,\n\t\tstatus: candidate.status,\n\t\tattempted: candidate.attempted,\n\t\tsucceeded: candidate.succeeded,\n\t\tfailed: candidate.failed,\n\t\tfailures: candidate.failures.map((failure) => ({\n\t\t\tpluginId: failure.pluginId,\n\t\t\tregistrationId: failure.registrationId,\n\t\t\tkind: failure.kind,\n\t\t\terror: transcriptValue(failure.error),\n\t\t})),\n\t};\n}\n\nfunction defaultHost(): HostCapabilities {\n\treturn {\n\t\tapiVersion: EXPERIMENTAL_PUBLIC_API_VERSION,\n\t\tmode: \"full-control\",\n\t\tfeatures: [\"logger-v1\", \"diagnostics-v1\", \"plugin-state-v1\", \"runtime-inspector-v1\"],\n\t\ttransports: [\"in-process\"],\n\t};\n}\n\nconst DEFAULT_MANIFEST_ROOT = \"<plugin-testkit>\";\n\ninterface MutablePluginTestKitStateMutation {\n\tpluginId: string;\n\taction: \"set\" | \"delete\";\n\tkey: string;\n\tstatus: \"committed\" | \"rejected\";\n\trevision?: number;\n\texpectedRevision?: number;\n\tvalue?: unknown;\n\toperationId?: string;\n\tcorrelationId?: string;\n\terror?: unknown;\n}\n\ninterface MutablePluginTestKitStateWatchDelivery {\n\tpluginId: string;\n\twatcherId: string;\n\tkey: string;\n\trevision: number;\n\tstatus: \"delivered\" | \"failed\";\n\tvalue?: unknown;\n\toperationId?: string;\n\tcorrelationId?: string;\n\terror?: unknown;\n}\n\ninterface MutablePluginTestKitCapabilityCall {\n\toperationId: string | null;\n\tcallerPluginId: string;\n\tproviderPluginId: string;\n\tcapabilityId: string;\n\tcapabilityVersion: number;\n\tcapabilityKind: PluginCapabilityDeclaration[\"kind\"];\n\tstatus: OperationStatus;\n\terror?: unknown;\n}\n\ninterface MutablePluginTestKitLifecycleFailure {\n\teventId: string | null;\n\ttype: string | null;\n\tversion: number | null;\n\tphase: LifecyclePhase | null;\n\tdeliveryId: string | null;\n\tsource: string | null;\n\toperationId?: string;\n\tcorrelationId?: string;\n\tcausationId?: string;\n\tdata?: unknown;\n\tstatus: \"rejected\" | \"cancelled\" | \"transform-failed\" | \"execute-failed\";\n\terror: unknown;\n\treport?: PluginTestKitLifecycleFailureReport;\n}\n\n/** Create a runtime-only fixture with deterministic topology and teardown. */\nexport function createPluginTestKit(options: PluginTestKitOptions): PluginTestKit {\n\tconst manifestRoot = options.manifestRoot ?? DEFAULT_MANIFEST_ROOT;\n\tif (typeof manifestRoot !== \"string\" || !manifestRoot.trim()) {\n\t\tthrow new Error(\"Plugin testkit manifestRoot must be a non-empty string\");\n\t}\n\tconst inputPlugins = options.plugins.map((plugin) => ({\n\t\tmanifest: snapshot(plugin.manifest),\n\t\tfactory: plugin.factory,\n\t}));\n\tconst suppliedHost = options.host;\n\tconst host: HostCapabilities = {\n\t\t...defaultHost(),\n\t\t...suppliedHost,\n\t\tfeatures: suppliedHost?.features ?? defaultHost().features,\n\t\ttransports: suppliedHost?.transports ?? defaultHost().transports,\n\t};\n\tconst pluginsByManifest = new Map(inputPlugins.map((plugin) => [plugin.manifest, plugin]));\n\tconst handles = new Map<string, CapabilityPluginHandle>();\n\tconst revokedState = new Map<string, readonly StateEntry[]>();\n\tconst retainedState = new Map<string, readonly StateEntry[]>();\n\tconst loadOrder: string[] = [];\n\tconst stateMutations: MutablePluginTestKitStateMutation[] = [];\n\tconst stateWatchDeliveries: MutablePluginTestKitStateWatchDelivery[] = [];\n\tconst capabilityCalls: MutablePluginTestKitCapabilityCall[] = [];\n\tconst lifecycleEvents: PluginTestKitLifecycleEnvelope[] = [];\n\tconst lifecycleFailures: MutablePluginTestKitLifecycleFailure[] = [];\n\tconst pendingLifecycleDispatches = new Set<Promise<void>>();\n\tlet disposePromise: Promise<void> | undefined;\n\tconst recordLifecycleDispatch = (\n\t\trequest: LifecycleDispatchRequest<unknown>,\n\t\tsettled: Promise<LifecycleDispatchResult<unknown>>,\n\t): void => {\n\t\tconst recorded = settled.then(\n\t\t\t(result) => {\n\t\t\t\tlifecycleEvents.push(\n\t\t\t\t\tsnapshot({\n\t\t\t\t\t\teventId: result.event.id,\n\t\t\t\t\t\ttype: result.event.type,\n\t\t\t\t\t\tversion: result.event.version,\n\t\t\t\t\t\tphase: result.event.phase,\n\t\t\t\t\t\tdeliveryId: result.event.deliveryId,\n\t\t\t\t\t\tsource: result.event.source,\n\t\t\t\t\t\t...(result.event.operationId === undefined ? {} : { operationId: result.event.operationId }),\n\t\t\t\t\t\t...(result.event.correlationId === undefined ? {} : { correlationId: result.event.correlationId }),\n\t\t\t\t\t\t...(result.event.causationId === undefined ? {} : { causationId: result.event.causationId }),\n\t\t\t\t\t\tdata: transcriptValue(result.event.data),\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t},\n\t\t\t(error) => {\n\t\t\t\tconst requestObject =\n\t\t\t\t\trequest && typeof request === \"object\" ? (request as unknown as Record<string, unknown>) : undefined;\n\t\t\t\tconst report = lifecycleFailureReport(error);\n\t\t\t\tconst rawPhase = requestObject?.phase;\n\t\t\t\tconst phase: LifecyclePhase | null =\n\t\t\t\t\trawPhase === \"raw\" || rawPhase === \"candidate\" || rawPhase === \"committed\" ? rawPhase : null;\n\t\t\t\tconst rawSource = requestObject?.source;\n\t\t\t\tconst source =\n\t\t\t\t\trawSource === undefined\n\t\t\t\t\t\t? requestObject === undefined\n\t\t\t\t\t\t\t? null\n\t\t\t\t\t\t\t: \"host\"\n\t\t\t\t\t\t: typeof rawSource === \"string\"\n\t\t\t\t\t\t\t? rawSource\n\t\t\t\t\t\t\t: null;\n\t\t\t\tconst rawVersion = requestObject?.version;\n\t\t\t\tconst version = typeof rawVersion === \"number\" && Number.isSafeInteger(rawVersion) ? rawVersion : null;\n\t\t\t\tconst failure: MutablePluginTestKitLifecycleFailure = {\n\t\t\t\t\teventId: report?.eventId ?? null,\n\t\t\t\t\ttype: typeof requestObject?.type === \"string\" ? requestObject.type : null,\n\t\t\t\t\tversion,\n\t\t\t\t\tphase,\n\t\t\t\t\tdeliveryId: null,\n\t\t\t\t\tsource,\n\t\t\t\t\t...(typeof requestObject?.operationId === \"string\" ? { operationId: requestObject.operationId } : {}),\n\t\t\t\t\t...(typeof requestObject?.correlationId === \"string\"\n\t\t\t\t\t\t? { correlationId: requestObject.correlationId }\n\t\t\t\t\t\t: {}),\n\t\t\t\t\t...(typeof requestObject?.causationId === \"string\" ? { causationId: requestObject.causationId } : {}),\n\t\t\t\t\t...(requestObject !== undefined && \"data\" in requestObject\n\t\t\t\t\t\t? { data: transcriptValue(requestObject.data) }\n\t\t\t\t\t\t: {}),\n\t\t\t\t\tstatus:\n\t\t\t\t\t\treport?.status === \"transform-failed\" || report?.status === \"execute-failed\"\n\t\t\t\t\t\t\t? report.status\n\t\t\t\t\t\t\t: requestObject?.signal instanceof AbortSignal && requestObject.signal.aborted\n\t\t\t\t\t\t\t\t? \"cancelled\"\n\t\t\t\t\t\t\t\t: \"rejected\",\n\t\t\t\t\terror: transcriptValue(error),\n\t\t\t\t\t...(report === undefined ? {} : { report }),\n\t\t\t\t};\n\t\t\t\tlifecycleFailures.push(snapshot(failure));\n\t\t\t},\n\t\t);\n\t\tpendingLifecycleDispatches.add(recorded);\n\t\tvoid recorded.then(() => pendingLifecycleDispatches.delete(recorded));\n\t};\n\tconst runtime = createCapabilityRuntime(host, {\n\t\tclock: options.clock ?? (() => 0),\n\t\tidFactory: options.idFactory ?? ((kind, sequence) => `testkit:${kind}:${sequence}`),\n\t\tonLifecycleDispatch: recordLifecycleDispatch,\n\t});\n\t// Must run before the ready loop: plugin factories registerObserve during load.\n\tif (options.lifecycle === true) installBootstrapLifecycle(runtime);\n\n\tconst inputManifests = inputPlugins.map(({ manifest }) => ({\n\t\tpluginId: manifest.id,\n\t\tversion: manifest.version,\n\t\tentry: manifest.entry,\n\t}));\n\tconst inputOrder = inputPlugins.map(({ manifest }) => manifest.id);\n\tconst wrappedToRawAPI = new WeakMap<CapabilityAPI, CapabilityAPI>();\n\tconst wrapStateAPI = (pluginId: string, state: StateAPI): StateAPI => {\n\t\tconst operationMetadata = (options?: StateSetOptions) => ({\n\t\t\t...(options?.expectedRevision === undefined ? {} : { expectedRevision: options.expectedRevision }),\n\t\t\t...(options?.operationId === undefined ? {} : { operationId: options.operationId }),\n\t\t\t...(options?.correlationId === undefined ? {} : { correlationId: options.correlationId }),\n\t\t});\n\t\tconst recordMutation = (\n\t\t\taction: \"set\" | \"delete\",\n\t\t\tkey: string,\n\t\t\tmetadata: ReturnType<typeof operationMetadata>,\n\t\t\tresult: { status: \"committed\"; revision: number; value?: unknown } | { status: \"rejected\"; error: unknown },\n\t\t): void => {\n\t\t\tstateMutations.push({\n\t\t\t\tpluginId,\n\t\t\t\taction,\n\t\t\t\tkey,\n\t\t\t\t...metadata,\n\t\t\t\t...result,\n\t\t\t});\n\t\t};\n\t\treturn Object.freeze({\n\t\t\tget: (key: string) => state.get(key),\n\t\t\tset: (key: string, value: Parameters<StateAPI[\"set\"]>[1], options?: StateSetOptions) => {\n\t\t\t\tconst metadata = operationMetadata(options);\n\t\t\t\ttry {\n\t\t\t\t\tconst revision = state.set(key, value, options);\n\t\t\t\t\trecordMutation(\"set\", key, metadata, {\n\t\t\t\t\t\tstatus: \"committed\",\n\t\t\t\t\t\trevision,\n\t\t\t\t\t\tvalue: transcriptValue(value),\n\t\t\t\t\t});\n\t\t\t\t\treturn revision;\n\t\t\t\t} catch (error) {\n\t\t\t\t\trecordMutation(\"set\", key, metadata, { status: \"rejected\", error: transcriptValue(error) });\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t},\n\t\t\tdelete: (key: string, options?: StateSetOptions) => {\n\t\t\t\tconst metadata = operationMetadata(options);\n\t\t\t\ttry {\n\t\t\t\t\tconst revision = state.delete(key, options);\n\t\t\t\t\trecordMutation(\"delete\", key, metadata, { status: \"committed\", revision });\n\t\t\t\t\treturn revision;\n\t\t\t\t} catch (error) {\n\t\t\t\t\trecordMutation(\"delete\", key, metadata, { status: \"rejected\", error: transcriptValue(error) });\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t},\n\t\t\tlist: (prefix?: string) => state.list(prefix),\n\t\t\twatch: (prefix: string | undefined, handler: (change: StateChange) => void) => {\n\t\t\t\tlet watcherId = \"<pending>\";\n\t\t\t\tconst registration = state.watch(prefix, (change) => {\n\t\t\t\t\tconst delivery: MutablePluginTestKitStateWatchDelivery = {\n\t\t\t\t\t\tpluginId,\n\t\t\t\t\t\twatcherId,\n\t\t\t\t\t\tkey: change.key,\n\t\t\t\t\t\trevision: change.revision,\n\t\t\t\t\t\tstatus: \"delivered\",\n\t\t\t\t\t\t...(change.value === undefined ? {} : { value: transcriptValue(change.value) }),\n\t\t\t\t\t\t...(change.operationId === undefined ? {} : { operationId: change.operationId }),\n\t\t\t\t\t\t...(change.correlationId === undefined ? {} : { correlationId: change.correlationId }),\n\t\t\t\t\t};\n\t\t\t\t\tstateWatchDeliveries.push(delivery);\n\t\t\t\t\ttry {\n\t\t\t\t\t\thandler(change);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tdelivery.status = \"failed\";\n\t\t\t\t\t\tdelivery.error = transcriptValue(error);\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\twatcherId = registration.id;\n\t\t\t\treturn registration;\n\t\t\t},\n\t\t});\n\t};\n\tconst wrapCapabilityDirectory = (\n\t\tcallerPluginId: string,\n\t\tcapabilities: CapabilityDirectoryAPI,\n\t): CapabilityDirectoryAPI =>\n\t\tObject.freeze({\n\t\t\tprovide: <TInput = unknown, TResult = unknown>(\n\t\t\t\tdeclaration: PluginCapabilityDeclaration,\n\t\t\t\thandler: CapabilityProviderHandler<TInput, TResult>,\n\t\t\t): DisposableRegistration => capabilities.provide(declaration, handler),\n\t\t\trequire: <TResult = unknown>(id: string, requireOptions?: { version?: number }) => {\n\t\t\t\tconst handle = capabilities.require<TResult>(id, requireOptions);\n\t\t\t\treturn Object.freeze({\n\t\t\t\t\tdeclaration: handle.declaration,\n\t\t\t\t\towner: handle.owner,\n\t\t\t\t\tcall: (input: unknown, callOptions?: { signal?: AbortSignal }): OperationHandle<TResult> => {\n\t\t\t\t\t\tlet operation: OperationHandle<TResult>;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\toperation = handle.call(input, callOptions);\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tcapabilityCalls.push({\n\t\t\t\t\t\t\t\toperationId: null,\n\t\t\t\t\t\t\t\tcallerPluginId,\n\t\t\t\t\t\t\t\tproviderPluginId: handle.owner,\n\t\t\t\t\t\t\t\tcapabilityId: handle.declaration.id,\n\t\t\t\t\t\t\t\tcapabilityVersion: handle.declaration.version,\n\t\t\t\t\t\t\t\tcapabilityKind: handle.declaration.kind,\n\t\t\t\t\t\t\t\tstatus: \"failed\",\n\t\t\t\t\t\t\t\terror: transcriptValue(error),\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst record: MutablePluginTestKitCapabilityCall = {\n\t\t\t\t\t\t\toperationId: operation.id,\n\t\t\t\t\t\t\tcallerPluginId,\n\t\t\t\t\t\t\tproviderPluginId: handle.owner,\n\t\t\t\t\t\t\tcapabilityId: handle.declaration.id,\n\t\t\t\t\t\t\tcapabilityVersion: handle.declaration.version,\n\t\t\t\t\t\t\tcapabilityKind: handle.declaration.kind,\n\t\t\t\t\t\t\tstatus: operation.status(),\n\t\t\t\t\t\t};\n\t\t\t\t\t\tcapabilityCalls.push(record);\n\t\t\t\t\t\tvoid operation.result.then(\n\t\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t\trecord.status = operation.status();\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t(error) => {\n\t\t\t\t\t\t\t\trecord.status = operation.status();\n\t\t\t\t\t\t\t\trecord.error = transcriptValue(error);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn operation;\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t},\n\t\t\tlist: (listOptions?: { kind?: PluginCapabilityDeclaration[\"kind\"] }) => capabilities.list(listOptions),\n\t\t});\n\tconst originalCreateAPI = runtime.createAPI.bind(runtime);\n\tconst originalRevokeAPI = runtime.revokeAPI.bind(runtime);\n\truntime.createAPI = (manifest) => {\n\t\tconst rawAPI = originalCreateAPI(manifest);\n\t\tconst wrappedAPI = Object.freeze({\n\t\t\t...rawAPI,\n\t\t\tcapabilities: wrapCapabilityDirectory(rawAPI.manifest.id, rawAPI.capabilities),\n\t\t\t...(rawAPI.state === undefined ? {} : { state: wrapStateAPI(rawAPI.manifest.id, rawAPI.state) }),\n\t\t});\n\t\twrappedToRawAPI.set(wrappedAPI, rawAPI);\n\t\treturn wrappedAPI;\n\t};\n\truntime.revokeAPI = (api) => {\n\t\t// v8 ignore next -- 所有 API 均经包装后的 createAPI 创建,映射必命中\n\t\tconst rawAPI = wrappedToRawAPI.get(api) ?? api;\n\t\tfor (const [pluginId, handle] of handles) {\n\t\t\tif (handle.api === api || handle.api === rawAPI) captureState(pluginId, handle);\n\t\t}\n\t\toriginalRevokeAPI(rawAPI);\n\t};\n\n\tconst captureState = (pluginId: string, handle: CapabilityPluginHandle): void => {\n\t\tif (retainedState.has(pluginId) || revokedState.has(pluginId)) return;\n\t\tretainedState.set(pluginId, snapshot(handle.api.state?.list() ?? []));\n\t};\n\tconst stateTranscript = (): readonly { readonly pluginId: string; readonly entries: readonly StateEntry[] }[] =>\n\t\t[...handles.entries()].map(([pluginId, handle]) => {\n\t\t\treturn {\n\t\t\t\tpluginId,\n\t\t\t\tentries: retainedState.get(pluginId) ?? snapshot(handle.api.state?.list() ?? []),\n\t\t\t};\n\t\t});\n\n\tlet closing = false;\n\tconst ready = (async () => {\n\t\ttry {\n\t\t\tconst ordered = resolvePluginCapabilityOrder(inputPlugins.map((plugin) => plugin.manifest));\n\t\t\tfor (const manifest of ordered) {\n\t\t\t\tif (closing) throw new Error(\"Plugin testkit was disposed during startup\");\n\t\t\t\tconst plugin = pluginsByManifest.get(manifest);\n\t\t\t\t// v8 ignore next -- plugins 数组同时供给加载顺序与 factory 映射,必可解析\n\t\t\t\tif (!plugin) throw new Error(`Plugin testkit cannot resolve factory: ${manifest.id}`);\n\t\t\t\tconst handle = await loadCapabilityPlugin(runtime, plugin.manifest, plugin.factory);\n\t\t\t\thandles.set(manifest.id, handle);\n\t\t\t\tloadOrder.push(manifest.id);\n\t\t\t}\n\t\t} catch (startupError) {\n\t\t\tconst failures: unknown[] = [startupError];\n\t\t\tfor (const handle of [...handles.values()].reverse()) {\n\t\t\t\ttry {\n\t\t\t\t\tawait handle.dispose();\n\t\t\t\t} catch (error) {\n\t\t\t\t\tfailures.push(error);\n\t\t\t\t}\n\t\t\t}\n\t\t\thandles.clear();\n\t\t\ttry {\n\t\t\t\tawait runtime.disposeAll();\n\t\t\t} catch (error) {\n\t\t\t\tfailures.push(error);\n\t\t\t}\n\t\t\tif (failures.length > 1) throw new AggregateError(failures, \"Plugin testkit startup rollback failed\");\n\t\t\tthrow startupError;\n\t\t}\n\t})();\n\n\treturn {\n\t\truntime,\n\t\tready,\n\t\tapi(pluginId) {\n\t\t\tconst handle = handles.get(pluginId);\n\t\t\tif (!handle) throw new Error(`Plugin testkit has no loaded plugin: ${pluginId}`);\n\t\t\treturn handle.api;\n\t\t},\n\t\trevoke(pluginId) {\n\t\t\tconst handle = handles.get(pluginId);\n\t\t\tif (!handle) throw new Error(`Plugin testkit has no loaded plugin: ${pluginId}`);\n\t\t\tif (handle.api.state) {\n\t\t\t\tconst entries = snapshot(handle.api.state.list());\n\t\t\t\trevokedState.set(pluginId, entries);\n\t\t\t\tretainedState.set(pluginId, entries);\n\t\t\t}\n\t\t\truntime.revokeAPI(handle.api);\n\t\t},\n\t\tinspect: () => runtime.inspect(),\n\t\tflushLifecycle: async () => {\n\t\t\twhile (pendingLifecycleDispatches.size > 0) {\n\t\t\t\tawait Promise.all([...pendingLifecycleDispatches]);\n\t\t\t}\n\t\t\tawait runtime.drainLifecycleDeliveries();\n\t\t},\n\t\ttranscript: () =>\n\t\t\tsnapshot(\n\t\t\t\ttranscriptValue({\n\t\t\t\t\tversion: 1 as const,\n\t\t\t\t\tmanifestRoot,\n\t\t\t\t\tmanifests: inputManifests,\n\t\t\t\t\tinputOrder,\n\t\t\t\t\tloadOrder,\n\t\t\t\t\tstate: stateTranscript(),\n\t\t\t\t\tstateMutations,\n\t\t\t\t\tstateWatchDeliveries,\n\t\t\t\t\tcapabilityCalls,\n\t\t\t\t\tlifecycleEvents,\n\t\t\t\t\tlifecycleFailures,\n\t\t\t\t\tlifecycleReports: runtime.inspect().lifecycleReports,\n\t\t\t\t\tinspector: runtime.inspect(),\n\t\t\t\t}) as PluginTestKitTranscript,\n\t\t\t),\n\t\tdispose: async () => {\n\t\t\tdisposePromise ??= (async () => {\n\t\t\t\tclosing = true;\n\t\t\t\tconst failures: unknown[] = [];\n\t\t\t\ttry {\n\t\t\t\t\tawait ready;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (!(error instanceof Error && error.message === \"Plugin testkit was disposed during startup\")) {\n\t\t\t\t\t\tfailures.push(error);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (const [pluginId, handle] of handles) captureState(pluginId, handle);\n\t\t\t\tfor (const handle of [...handles.values()].reverse()) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait handle.dispose();\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tfailures.push(error);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tawait runtime.disposeAll();\n\t\t\t\t} catch (error) {\n\t\t\t\t\tfailures.push(error);\n\t\t\t\t}\n\t\t\t\tif (failures.length === 1) throw failures[0];\n\t\t\t\tif (failures.length > 1) throw new AggregateError(failures, \"Plugin testkit disposal failed\");\n\t\t\t})();\n\t\t\treturn disposePromise;\n\t\t},\n\t};\n}\n\n/** Runs a fixture repeatedly and rejects on the first transcript divergence. */\nexport async function repeatPluginTestKit(\n\ttimes: number,\n\trun: () => Promise<PluginTestKitTranscript>,\n): Promise<PluginTestKitTranscript> {\n\tif (!Number.isSafeInteger(times) || times < 1)\n\t\tthrow new Error(\"Plugin testkit repeat count must be a positive integer\");\n\tlet baseline: PluginTestKitTranscript | undefined;\n\tfor (let index = 0; index < times; index += 1) {\n\t\tconst transcript = await run();\n\t\tif (baseline && canonicalJson(transcript) !== canonicalJson(baseline)) {\n\t\t\tthrow new Error(`Plugin testkit transcript diverged on run ${index + 1}`);\n\t\t}\n\t\tbaseline = transcript;\n\t}\n\treturn baseline!;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"plugin-testkit.d.ts","sourceRoot":"","sources":["../../src/testing/plugin-testkit.ts"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,uBAAuB,EAG5B,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACN,KAAK,iBAAiB,EAGtB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EACN,KAAK,aAAa,EAKlB,KAAK,gBAAgB,EAGrB,KAAK,cAAc,EACnB,KAAK,cAAc,EAEnB,KAAK,eAAe,EACpB,KAAK,2BAA2B,EAChC,KAAK,cAAc,EACnB,KAAK,wBAAwB,EAG7B,KAAK,UAAU,EAEf,MAAM,kCAAkC,CAAC;AAG1C;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,uBAAuB,CAAC;CAC1C;AAED,MAAM,WAAW,oBAAoB;IACpC,QAAQ,CAAC,OAAO,EAAE,SAAS,mB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AAQ,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa,CAAC;IACrC,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,OAAO,IAAI,wBAAwB,CAAC;IACpC,UAAU,IAAI,uBAAuB,CAAC;IACtC,gFAAgF;IAChF,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACzB;AAuJD,8EAA8E;AAC9E,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CA+XhF;AAED,gFAAgF;AAChF,wBAAsB,mBAAmB,CACxC,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,OAAO,CAAC,uBAAuB,CAAC,GACzC,OAAO,CAAC,uBAAuB,CAAC,CAYlC","sourcesContent":["import { installBootstrapLifecycle } from \"../core/extensions/bootstrap-lifecycle.ts\";\nimport {\n\ttype CapabilityPluginFactory,\n\ttype CapabilityPluginHandle,\n\tloadCapabilityPlugin,\n} from \"../core/extensions/capability-plugin.ts\";\nimport {\n\ttype CapabilityRuntime,\n\tcreateCapabilityRuntime,\n\tresolvePluginCapabilityOrder,\n} from \"../core/extensions/capability-runtime.ts\";\nimport {\n\ttype CapabilityAPI,\n\ttype CapabilityDirectoryAPI,\n\ttype CapabilityProviderHandler,\n\ttype DisposableRegistration,\n\tEXPERIMENTAL_PUBLIC_API_VERSION,\n\ttype HostCapabilities,\n\ttype LifecycleDispatchRequest,\n\ttype LifecycleDispatchResult,\n\ttype LifecycleEvent,\n\ttype LifecyclePhase,\n\ttype OperationHandle,\n\ttype OperationStatus,\n\ttype PluginCapabilityDeclaration,\n\ttype PluginManifest,\n\ttype RuntimeInspectorSnapshot,\n\ttype StateAPI,\n\ttype StateChange,\n\ttype StateEntry,\n\ttype StateSetOptions,\n} from \"../core/extensions/public-api.ts\";\nimport { t } from \"../core/i18n/index.ts\";\n\n/**\n * A deterministic, runtime-only fixture for experimental capability plugins.\n *\n * It deliberately does not create an AgentSession or a model provider. Tests\n * that need those integration points should use the existing session harness.\n */\nexport interface PluginTestKitPlugin {\n\treadonly manifest: PluginManifest;\n\treadonly factory: CapabilityPluginFactory;\n}\n\nexport interface PluginTestKitOptions {\n\treadonly plugins: readonly PluginTestKitPlugin[];\n\treadonly host?: Omit<HostCapabilities, \"apiVersion\">;\n\treadonly clock?: () => number;\n\t/** Injects stable runtime identifiers for deterministic transcript tests. */\n\treadonly idFactory?: (kind: string, sequence: number) => string;\n\t/** Logical root used to identify inline manifests without a host filesystem path. */\n\treadonly manifestRoot?: string;\n\t/**\n\t * Installs the bootstrap lifecycle catalog (host parity: the real session\n\t * host installs it) before the plugin load loop, so plugin factories can\n\t * registerObserve standard events. Off by default to keep existing\n\t * transcripts unchanged; the installed handle is disposed by\n\t * runtime.disposeAll() inside dispose().\n\t */\n\treadonly lifecycle?: boolean;\n}\n\nexport interface PluginTestKitManifestIdentity {\n\treadonly pluginId: string;\n\treadonly version: string;\n\treadonly entry: string;\n}\n\nexport interface PluginTestKitLifecycleEnvelope {\n\treadonly eventId: string;\n\treadonly type: string;\n\treadonly version: number;\n\treadonly phase: LifecycleEvent[\"phase\"];\n\treadonly deliveryId: string;\n\treadonly source: string;\n\treadonly operationId?: string;\n\treadonly correlationId?: string;\n\treadonly causationId?: string;\n\treadonly data: unknown;\n}\n\nexport interface PluginTestKitLifecycleFailureReport {\n\treadonly eventId: string;\n\treadonly type: string;\n\treadonly version: number;\n\treadonly phase: LifecyclePhase;\n\treadonly status: \"transform-failed\" | \"execute-failed\" | \"delivered\" | \"queued\";\n\treadonly attempted: number;\n\treadonly succeeded: number;\n\treadonly queued?: number;\n\treadonly failed: number;\n\treadonly failures: readonly {\n\t\treadonly pluginId: string;\n\t\treadonly registrationId: string;\n\t\treadonly kind: string;\n\t\treadonly error: unknown;\n\t}[];\n}\n\n/** A dispatch rejection is retained even when no event envelope was created. */\nexport interface PluginTestKitLifecycleFailure {\n\treadonly eventId: string | null;\n\treadonly type: string | null;\n\treadonly version: number | null;\n\treadonly phase: LifecyclePhase | null;\n\treadonly deliveryId: string | null;\n\treadonly source: string | null;\n\treadonly operationId?: string;\n\treadonly correlationId?: string;\n\treadonly causationId?: string;\n\treadonly data?: unknown;\n\treadonly status: \"rejected\" | \"cancelled\" | \"transform-failed\" | \"execute-failed\";\n\treadonly error: unknown;\n\treadonly report?: PluginTestKitLifecycleFailureReport;\n}\n\nexport interface PluginTestKitStateMutation {\n\treadonly pluginId: string;\n\treadonly action: \"set\" | \"delete\";\n\treadonly key: string;\n\treadonly status: \"committed\" | \"rejected\";\n\treadonly revision?: number;\n\treadonly expectedRevision?: number;\n\treadonly value?: unknown;\n\treadonly operationId?: string;\n\treadonly correlationId?: string;\n\treadonly error?: unknown;\n}\n\nexport interface PluginTestKitStateWatchDelivery {\n\treadonly pluginId: string;\n\treadonly watcherId: string;\n\treadonly key: string;\n\treadonly revision: number;\n\treadonly status: \"delivered\" | \"failed\";\n\treadonly value?: unknown;\n\treadonly operationId?: string;\n\treadonly correlationId?: string;\n\treadonly error?: unknown;\n}\n\nexport interface PluginTestKitCapabilityCall {\n\treadonly operationId: string | null;\n\treadonly callerPluginId: string;\n\treadonly providerPluginId: string;\n\treadonly capabilityId: string;\n\treadonly capabilityVersion: number;\n\treadonly capabilityKind: PluginCapabilityDeclaration[\"kind\"];\n\treadonly status: OperationStatus;\n\treadonly error?: unknown;\n}\n\nexport interface PluginTestKitTranscript {\n\treadonly version: 1;\n\treadonly manifestRoot: string;\n\treadonly manifests: readonly PluginTestKitManifestIdentity[];\n\treadonly inputOrder: readonly string[];\n\treadonly loadOrder: readonly string[];\n\treadonly state: readonly {\n\t\treadonly pluginId: string;\n\t\treadonly entries: readonly StateEntry[];\n\t}[];\n\treadonly stateMutations: readonly PluginTestKitStateMutation[];\n\treadonly stateWatchDeliveries: readonly PluginTestKitStateWatchDelivery[];\n\treadonly capabilityCalls: readonly PluginTestKitCapabilityCall[];\n\treadonly lifecycleEvents: readonly PluginTestKitLifecycleEnvelope[];\n\treadonly lifecycleFailures: readonly PluginTestKitLifecycleFailure[];\n\treadonly lifecycleReports: RuntimeInspectorSnapshot[\"lifecycleReports\"];\n\treadonly inspector: RuntimeInspectorSnapshot;\n}\n\nexport interface PluginTestKit {\n\treadonly runtime: CapabilityRuntime;\n\t/** Resolves after every manifest is topology-ordered and its factory has loaded. */\n\treadonly ready: Promise<void>;\n\tapi(pluginId: string): CapabilityAPI;\n\trevoke(pluginId: string): void;\n\tinspect(): RuntimeInspectorSnapshot;\n\ttranscript(): PluginTestKitTranscript;\n\t/** Waits for lifecycle facts initiated by runtime-owned detached operations. */\n\tflushLifecycle(): Promise<void>;\n\tdispose(): Promise<void>;\n}\n\nfunction snapshot<T>(value: T): T {\n\tconst clone = structuredClone(value);\n\tconst freeze = (candidate: unknown): void => {\n\t\tif (!candidate || typeof candidate !== \"object\" || ArrayBuffer.isView(candidate)) return;\n\t\tfor (const child of Object.values(candidate as Record<string, unknown>)) freeze(child);\n\t\tObject.freeze(candidate);\n\t};\n\tfreeze(clone);\n\treturn clone;\n}\n\nfunction transcriptValue(value: unknown, seen = new WeakSet<object>()): unknown {\n\tif (value === null || typeof value === \"string\" || typeof value === \"boolean\") return value;\n\tif (typeof value === \"number\") return Number.isFinite(value) ? value : String(value);\n\tif (typeof value === \"bigint\") return `${value}n`;\n\tif (value === undefined) return null;\n\tif (value instanceof Error) {\n\t\tif (seen.has(value)) return \"[Circular]\";\n\t\tseen.add(value);\n\t\tconst output: Record<string, unknown> = { name: value.name, message: value.message };\n\t\tconst code = (value as Error & { code?: unknown }).code;\n\t\tif (code !== undefined) output.code = transcriptValue(code, seen);\n\t\tconst cause = (value as Error & { cause?: unknown }).cause;\n\t\tif (cause !== undefined) output.cause = transcriptValue(cause, seen);\n\t\tfor (const key of Object.keys(value).sort()) {\n\t\t\tif (key === \"code\" || key === \"cause\") continue;\n\t\t\toutput[key] = transcriptValue((value as unknown as Record<string, unknown>)[key], seen);\n\t\t}\n\t\treturn output;\n\t}\n\tif (typeof value !== \"object\") return String(value);\n\tif (seen.has(value)) return \"[Circular]\";\n\tseen.add(value);\n\tif (Array.isArray(value)) return value.map((item) => transcriptValue(item, seen));\n\tconst output: Record<string, unknown> = {};\n\tfor (const key of Object.keys(value as Record<string, unknown>).sort()) {\n\t\toutput[key] = transcriptValue((value as Record<string, unknown>)[key], seen);\n\t}\n\treturn output;\n}\n\nfunction canonicalJson(value: unknown): string {\n\tconst serialized = JSON.stringify(transcriptValue(value));\n\t// v8 ignore next -- transcriptValue 已消毒全部值,JSON.stringify 不会返回 undefined\n\tif (serialized === undefined) throw new Error(\"Plugin testkit transcript is not JSON-serializable\");\n\treturn serialized;\n}\n\ntype PluginTestKitLifecycleReport = PluginTestKitLifecycleFailureReport;\n\nfunction lifecycleFailureReport(error: unknown): PluginTestKitLifecycleReport | undefined {\n\tif (!error || typeof error !== \"object\") return undefined;\n\tconst report = (error as { report?: unknown }).report;\n\tif (!report || typeof report !== \"object\") return undefined;\n\tconst candidate = report as RuntimeInspectorSnapshot[\"lifecycleReports\"][number];\n\t// v8 ignore next -- report 由 runtime 构造、形状恒满足;此处仅防御伪造的 report\n\tif (\n\t\ttypeof candidate.eventId !== \"string\" ||\n\t\ttypeof candidate.type !== \"string\" ||\n\t\t!Number.isSafeInteger(candidate.version) ||\n\t\t(candidate.phase !== \"raw\" && candidate.phase !== \"candidate\" && candidate.phase !== \"committed\") ||\n\t\t(candidate.status !== \"transform-failed\" &&\n\t\t\tcandidate.status !== \"execute-failed\" &&\n\t\t\tcandidate.status !== \"delivered\") ||\n\t\t!Array.isArray(candidate.failures)\n\t) {\n\t\treturn undefined;\n\t}\n\treturn {\n\t\teventId: candidate.eventId,\n\t\ttype: candidate.type,\n\t\tversion: candidate.version,\n\t\tphase: candidate.phase,\n\t\tstatus: candidate.status,\n\t\tattempted: candidate.attempted,\n\t\tsucceeded: candidate.succeeded,\n\t\tfailed: candidate.failed,\n\t\tfailures: candidate.failures.map((failure) => ({\n\t\t\tpluginId: failure.pluginId,\n\t\t\tregistrationId: failure.registrationId,\n\t\t\tkind: failure.kind,\n\t\t\terror: transcriptValue(failure.error),\n\t\t})),\n\t};\n}\n\nfunction defaultHost(): HostCapabilities {\n\treturn {\n\t\tapiVersion: EXPERIMENTAL_PUBLIC_API_VERSION,\n\t\tmode: \"full-control\",\n\t\tfeatures: [\"logger-v1\", \"diagnostics-v1\", \"plugin-state-v1\", \"runtime-inspector-v1\"],\n\t\ttransports: [\"in-process\"],\n\t};\n}\n\nconst DEFAULT_MANIFEST_ROOT = \"<plugin-testkit>\";\n\ninterface MutablePluginTestKitStateMutation {\n\tpluginId: string;\n\taction: \"set\" | \"delete\";\n\tkey: string;\n\tstatus: \"committed\" | \"rejected\";\n\trevision?: number;\n\texpectedRevision?: number;\n\tvalue?: unknown;\n\toperationId?: string;\n\tcorrelationId?: string;\n\terror?: unknown;\n}\n\ninterface MutablePluginTestKitStateWatchDelivery {\n\tpluginId: string;\n\twatcherId: string;\n\tkey: string;\n\trevision: number;\n\tstatus: \"delivered\" | \"failed\";\n\tvalue?: unknown;\n\toperationId?: string;\n\tcorrelationId?: string;\n\terror?: unknown;\n}\n\ninterface MutablePluginTestKitCapabilityCall {\n\toperationId: string | null;\n\tcallerPluginId: string;\n\tproviderPluginId: string;\n\tcapabilityId: string;\n\tcapabilityVersion: number;\n\tcapabilityKind: PluginCapabilityDeclaration[\"kind\"];\n\tstatus: OperationStatus;\n\terror?: unknown;\n}\n\ninterface MutablePluginTestKitLifecycleFailure {\n\teventId: string | null;\n\ttype: string | null;\n\tversion: number | null;\n\tphase: LifecyclePhase | null;\n\tdeliveryId: string | null;\n\tsource: string | null;\n\toperationId?: string;\n\tcorrelationId?: string;\n\tcausationId?: string;\n\tdata?: unknown;\n\tstatus: \"rejected\" | \"cancelled\" | \"transform-failed\" | \"execute-failed\";\n\terror: unknown;\n\treport?: PluginTestKitLifecycleFailureReport;\n}\n\n/** Create a runtime-only fixture with deterministic topology and teardown. */\nexport function createPluginTestKit(options: PluginTestKitOptions): PluginTestKit {\n\tconst manifestRoot = options.manifestRoot ?? DEFAULT_MANIFEST_ROOT;\n\tif (typeof manifestRoot !== \"string\" || !manifestRoot.trim()) {\n\t\tthrow new Error(t(\"Plugin testkit manifestRoot must be a non-empty string\"));\n\t}\n\tconst inputPlugins = options.plugins.map((plugin) => ({\n\t\tmanifest: snapshot(plugin.manifest),\n\t\tfactory: plugin.factory,\n\t}));\n\tconst suppliedHost = options.host;\n\tconst host: HostCapabilities = {\n\t\t...defaultHost(),\n\t\t...suppliedHost,\n\t\tfeatures: suppliedHost?.features ?? defaultHost().features,\n\t\ttransports: suppliedHost?.transports ?? defaultHost().transports,\n\t};\n\tconst pluginsByManifest = new Map(inputPlugins.map((plugin) => [plugin.manifest, plugin]));\n\tconst handles = new Map<string, CapabilityPluginHandle>();\n\tconst revokedState = new Map<string, readonly StateEntry[]>();\n\tconst retainedState = new Map<string, readonly StateEntry[]>();\n\tconst loadOrder: string[] = [];\n\tconst stateMutations: MutablePluginTestKitStateMutation[] = [];\n\tconst stateWatchDeliveries: MutablePluginTestKitStateWatchDelivery[] = [];\n\tconst capabilityCalls: MutablePluginTestKitCapabilityCall[] = [];\n\tconst lifecycleEvents: PluginTestKitLifecycleEnvelope[] = [];\n\tconst lifecycleFailures: MutablePluginTestKitLifecycleFailure[] = [];\n\tconst pendingLifecycleDispatches = new Set<Promise<void>>();\n\tlet disposePromise: Promise<void> | undefined;\n\tconst recordLifecycleDispatch = (\n\t\trequest: LifecycleDispatchRequest<unknown>,\n\t\tsettled: Promise<LifecycleDispatchResult<unknown>>,\n\t): void => {\n\t\tconst recorded = settled.then(\n\t\t\t(result) => {\n\t\t\t\tlifecycleEvents.push(\n\t\t\t\t\tsnapshot({\n\t\t\t\t\t\teventId: result.event.id,\n\t\t\t\t\t\ttype: result.event.type,\n\t\t\t\t\t\tversion: result.event.version,\n\t\t\t\t\t\tphase: result.event.phase,\n\t\t\t\t\t\tdeliveryId: result.event.deliveryId,\n\t\t\t\t\t\tsource: result.event.source,\n\t\t\t\t\t\t...(result.event.operationId === undefined ? {} : { operationId: result.event.operationId }),\n\t\t\t\t\t\t...(result.event.correlationId === undefined ? {} : { correlationId: result.event.correlationId }),\n\t\t\t\t\t\t...(result.event.causationId === undefined ? {} : { causationId: result.event.causationId }),\n\t\t\t\t\t\tdata: transcriptValue(result.event.data),\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t},\n\t\t\t(error) => {\n\t\t\t\tconst requestObject =\n\t\t\t\t\trequest && typeof request === \"object\" ? (request as unknown as Record<string, unknown>) : undefined;\n\t\t\t\tconst report = lifecycleFailureReport(error);\n\t\t\t\tconst rawPhase = requestObject?.phase;\n\t\t\t\tconst phase: LifecyclePhase | null =\n\t\t\t\t\trawPhase === \"raw\" || rawPhase === \"candidate\" || rawPhase === \"committed\" ? rawPhase : null;\n\t\t\t\tconst rawSource = requestObject?.source;\n\t\t\t\tconst source =\n\t\t\t\t\trawSource === undefined\n\t\t\t\t\t\t? requestObject === undefined\n\t\t\t\t\t\t\t? null\n\t\t\t\t\t\t\t: \"host\"\n\t\t\t\t\t\t: typeof rawSource === \"string\"\n\t\t\t\t\t\t\t? rawSource\n\t\t\t\t\t\t\t: null;\n\t\t\t\tconst rawVersion = requestObject?.version;\n\t\t\t\tconst version = typeof rawVersion === \"number\" && Number.isSafeInteger(rawVersion) ? rawVersion : null;\n\t\t\t\tconst failure: MutablePluginTestKitLifecycleFailure = {\n\t\t\t\t\teventId: report?.eventId ?? null,\n\t\t\t\t\ttype: typeof requestObject?.type === \"string\" ? requestObject.type : null,\n\t\t\t\t\tversion,\n\t\t\t\t\tphase,\n\t\t\t\t\tdeliveryId: null,\n\t\t\t\t\tsource,\n\t\t\t\t\t...(typeof requestObject?.operationId === \"string\" ? { operationId: requestObject.operationId } : {}),\n\t\t\t\t\t...(typeof requestObject?.correlationId === \"string\"\n\t\t\t\t\t\t? { correlationId: requestObject.correlationId }\n\t\t\t\t\t\t: {}),\n\t\t\t\t\t...(typeof requestObject?.causationId === \"string\" ? { causationId: requestObject.causationId } : {}),\n\t\t\t\t\t...(requestObject !== undefined && \"data\" in requestObject\n\t\t\t\t\t\t? { data: transcriptValue(requestObject.data) }\n\t\t\t\t\t\t: {}),\n\t\t\t\t\tstatus:\n\t\t\t\t\t\treport?.status === \"transform-failed\" || report?.status === \"execute-failed\"\n\t\t\t\t\t\t\t? report.status\n\t\t\t\t\t\t\t: requestObject?.signal instanceof AbortSignal && requestObject.signal.aborted\n\t\t\t\t\t\t\t\t? \"cancelled\"\n\t\t\t\t\t\t\t\t: \"rejected\",\n\t\t\t\t\terror: transcriptValue(error),\n\t\t\t\t\t...(report === undefined ? {} : { report }),\n\t\t\t\t};\n\t\t\t\tlifecycleFailures.push(snapshot(failure));\n\t\t\t},\n\t\t);\n\t\tpendingLifecycleDispatches.add(recorded);\n\t\tvoid recorded.then(() => pendingLifecycleDispatches.delete(recorded));\n\t};\n\tconst runtime = createCapabilityRuntime(host, {\n\t\tclock: options.clock ?? (() => 0),\n\t\tidFactory: options.idFactory ?? ((kind, sequence) => `testkit:${kind}:${sequence}`),\n\t\tonLifecycleDispatch: recordLifecycleDispatch,\n\t});\n\t// Must run before the ready loop: plugin factories registerObserve during load.\n\tif (options.lifecycle === true) installBootstrapLifecycle(runtime);\n\n\tconst inputManifests = inputPlugins.map(({ manifest }) => ({\n\t\tpluginId: manifest.id,\n\t\tversion: manifest.version,\n\t\tentry: manifest.entry,\n\t}));\n\tconst inputOrder = inputPlugins.map(({ manifest }) => manifest.id);\n\tconst wrappedToRawAPI = new WeakMap<CapabilityAPI, CapabilityAPI>();\n\tconst wrapStateAPI = (pluginId: string, state: StateAPI): StateAPI => {\n\t\tconst operationMetadata = (options?: StateSetOptions) => ({\n\t\t\t...(options?.expectedRevision === undefined ? {} : { expectedRevision: options.expectedRevision }),\n\t\t\t...(options?.operationId === undefined ? {} : { operationId: options.operationId }),\n\t\t\t...(options?.correlationId === undefined ? {} : { correlationId: options.correlationId }),\n\t\t});\n\t\tconst recordMutation = (\n\t\t\taction: \"set\" | \"delete\",\n\t\t\tkey: string,\n\t\t\tmetadata: ReturnType<typeof operationMetadata>,\n\t\t\tresult: { status: \"committed\"; revision: number; value?: unknown } | { status: \"rejected\"; error: unknown },\n\t\t): void => {\n\t\t\tstateMutations.push({\n\t\t\t\tpluginId,\n\t\t\t\taction,\n\t\t\t\tkey,\n\t\t\t\t...metadata,\n\t\t\t\t...result,\n\t\t\t});\n\t\t};\n\t\treturn Object.freeze({\n\t\t\tget: (key: string) => state.get(key),\n\t\t\tset: (key: string, value: Parameters<StateAPI[\"set\"]>[1], options?: StateSetOptions) => {\n\t\t\t\tconst metadata = operationMetadata(options);\n\t\t\t\ttry {\n\t\t\t\t\tconst revision = state.set(key, value, options);\n\t\t\t\t\trecordMutation(\"set\", key, metadata, {\n\t\t\t\t\t\tstatus: \"committed\",\n\t\t\t\t\t\trevision,\n\t\t\t\t\t\tvalue: transcriptValue(value),\n\t\t\t\t\t});\n\t\t\t\t\treturn revision;\n\t\t\t\t} catch (error) {\n\t\t\t\t\trecordMutation(\"set\", key, metadata, { status: \"rejected\", error: transcriptValue(error) });\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t},\n\t\t\tdelete: (key: string, options?: StateSetOptions) => {\n\t\t\t\tconst metadata = operationMetadata(options);\n\t\t\t\ttry {\n\t\t\t\t\tconst revision = state.delete(key, options);\n\t\t\t\t\trecordMutation(\"delete\", key, metadata, { status: \"committed\", revision });\n\t\t\t\t\treturn revision;\n\t\t\t\t} catch (error) {\n\t\t\t\t\trecordMutation(\"delete\", key, metadata, { status: \"rejected\", error: transcriptValue(error) });\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t},\n\t\t\tlist: (prefix?: string) => state.list(prefix),\n\t\t\twatch: (prefix: string | undefined, handler: (change: StateChange) => void) => {\n\t\t\t\tlet watcherId = \"<pending>\";\n\t\t\t\tconst registration = state.watch(prefix, (change) => {\n\t\t\t\t\tconst delivery: MutablePluginTestKitStateWatchDelivery = {\n\t\t\t\t\t\tpluginId,\n\t\t\t\t\t\twatcherId,\n\t\t\t\t\t\tkey: change.key,\n\t\t\t\t\t\trevision: change.revision,\n\t\t\t\t\t\tstatus: \"delivered\",\n\t\t\t\t\t\t...(change.value === undefined ? {} : { value: transcriptValue(change.value) }),\n\t\t\t\t\t\t...(change.operationId === undefined ? {} : { operationId: change.operationId }),\n\t\t\t\t\t\t...(change.correlationId === undefined ? {} : { correlationId: change.correlationId }),\n\t\t\t\t\t};\n\t\t\t\t\tstateWatchDeliveries.push(delivery);\n\t\t\t\t\ttry {\n\t\t\t\t\t\thandler(change);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tdelivery.status = \"failed\";\n\t\t\t\t\t\tdelivery.error = transcriptValue(error);\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\twatcherId = registration.id;\n\t\t\t\treturn registration;\n\t\t\t},\n\t\t});\n\t};\n\tconst wrapCapabilityDirectory = (\n\t\tcallerPluginId: string,\n\t\tcapabilities: CapabilityDirectoryAPI,\n\t): CapabilityDirectoryAPI =>\n\t\tObject.freeze({\n\t\t\tprovide: <TInput = unknown, TResult = unknown>(\n\t\t\t\tdeclaration: PluginCapabilityDeclaration,\n\t\t\t\thandler: CapabilityProviderHandler<TInput, TResult>,\n\t\t\t): DisposableRegistration => capabilities.provide(declaration, handler),\n\t\t\trequire: <TResult = unknown>(id: string, requireOptions?: { version?: number }) => {\n\t\t\t\tconst handle = capabilities.require<TResult>(id, requireOptions);\n\t\t\t\treturn Object.freeze({\n\t\t\t\t\tdeclaration: handle.declaration,\n\t\t\t\t\towner: handle.owner,\n\t\t\t\t\tcall: (input: unknown, callOptions?: { signal?: AbortSignal }): OperationHandle<TResult> => {\n\t\t\t\t\t\tlet operation: OperationHandle<TResult>;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\toperation = handle.call(input, callOptions);\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tcapabilityCalls.push({\n\t\t\t\t\t\t\t\toperationId: null,\n\t\t\t\t\t\t\t\tcallerPluginId,\n\t\t\t\t\t\t\t\tproviderPluginId: handle.owner,\n\t\t\t\t\t\t\t\tcapabilityId: handle.declaration.id,\n\t\t\t\t\t\t\t\tcapabilityVersion: handle.declaration.version,\n\t\t\t\t\t\t\t\tcapabilityKind: handle.declaration.kind,\n\t\t\t\t\t\t\t\tstatus: \"failed\",\n\t\t\t\t\t\t\t\terror: transcriptValue(error),\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst record: MutablePluginTestKitCapabilityCall = {\n\t\t\t\t\t\t\toperationId: operation.id,\n\t\t\t\t\t\t\tcallerPluginId,\n\t\t\t\t\t\t\tproviderPluginId: handle.owner,\n\t\t\t\t\t\t\tcapabilityId: handle.declaration.id,\n\t\t\t\t\t\t\tcapabilityVersion: handle.declaration.version,\n\t\t\t\t\t\t\tcapabilityKind: handle.declaration.kind,\n\t\t\t\t\t\t\tstatus: operation.status(),\n\t\t\t\t\t\t};\n\t\t\t\t\t\tcapabilityCalls.push(record);\n\t\t\t\t\t\tvoid operation.result.then(\n\t\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t\trecord.status = operation.status();\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t(error) => {\n\t\t\t\t\t\t\t\trecord.status = operation.status();\n\t\t\t\t\t\t\t\trecord.error = transcriptValue(error);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn operation;\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t},\n\t\t\tlist: (listOptions?: { kind?: PluginCapabilityDeclaration[\"kind\"] }) => capabilities.list(listOptions),\n\t\t});\n\tconst originalCreateAPI = runtime.createAPI.bind(runtime);\n\tconst originalRevokeAPI = runtime.revokeAPI.bind(runtime);\n\truntime.createAPI = (manifest) => {\n\t\tconst rawAPI = originalCreateAPI(manifest);\n\t\tconst wrappedAPI = Object.freeze({\n\t\t\t...rawAPI,\n\t\t\tcapabilities: wrapCapabilityDirectory(rawAPI.manifest.id, rawAPI.capabilities),\n\t\t\t...(rawAPI.state === undefined ? {} : { state: wrapStateAPI(rawAPI.manifest.id, rawAPI.state) }),\n\t\t});\n\t\twrappedToRawAPI.set(wrappedAPI, rawAPI);\n\t\treturn wrappedAPI;\n\t};\n\truntime.revokeAPI = (api) => {\n\t\t// v8 ignore next -- 所有 API 均经包装后的 createAPI 创建,映射必命中\n\t\tconst rawAPI = wrappedToRawAPI.get(api) ?? api;\n\t\tfor (const [pluginId, handle] of handles) {\n\t\t\tif (handle.api === api || handle.api === rawAPI) captureState(pluginId, handle);\n\t\t}\n\t\toriginalRevokeAPI(rawAPI);\n\t};\n\n\tconst captureState = (pluginId: string, handle: CapabilityPluginHandle): void => {\n\t\tif (retainedState.has(pluginId) || revokedState.has(pluginId)) return;\n\t\tretainedState.set(pluginId, snapshot(handle.api.state?.list() ?? []));\n\t};\n\tconst stateTranscript = (): readonly { readonly pluginId: string; readonly entries: readonly StateEntry[] }[] =>\n\t\t[...handles.entries()].map(([pluginId, handle]) => {\n\t\t\treturn {\n\t\t\t\tpluginId,\n\t\t\t\tentries: retainedState.get(pluginId) ?? snapshot(handle.api.state?.list() ?? []),\n\t\t\t};\n\t\t});\n\n\tlet closing = false;\n\tconst ready = (async () => {\n\t\ttry {\n\t\t\tconst ordered = resolvePluginCapabilityOrder(inputPlugins.map((plugin) => plugin.manifest));\n\t\t\tfor (const manifest of ordered) {\n\t\t\t\tif (closing) throw new Error(\"Plugin testkit was disposed during startup\");\n\t\t\t\tconst plugin = pluginsByManifest.get(manifest);\n\t\t\t\t// v8 ignore next -- plugins 数组同时供给加载顺序与 factory 映射,必可解析\n\t\t\t\tif (!plugin) throw new Error(`Plugin testkit cannot resolve factory: ${manifest.id}`);\n\t\t\t\tconst handle = await loadCapabilityPlugin(runtime, plugin.manifest, plugin.factory);\n\t\t\t\thandles.set(manifest.id, handle);\n\t\t\t\tloadOrder.push(manifest.id);\n\t\t\t}\n\t\t} catch (startupError) {\n\t\t\tconst failures: unknown[] = [startupError];\n\t\t\tfor (const handle of [...handles.values()].reverse()) {\n\t\t\t\ttry {\n\t\t\t\t\tawait handle.dispose();\n\t\t\t\t} catch (error) {\n\t\t\t\t\tfailures.push(error);\n\t\t\t\t}\n\t\t\t}\n\t\t\thandles.clear();\n\t\t\ttry {\n\t\t\t\tawait runtime.disposeAll();\n\t\t\t} catch (error) {\n\t\t\t\tfailures.push(error);\n\t\t\t}\n\t\t\tif (failures.length > 1) throw new AggregateError(failures, \"Plugin testkit startup rollback failed\");\n\t\t\tthrow startupError;\n\t\t}\n\t})();\n\n\treturn {\n\t\truntime,\n\t\tready,\n\t\tapi(pluginId) {\n\t\t\tconst handle = handles.get(pluginId);\n\t\t\tif (!handle) throw new Error(`Plugin testkit has no loaded plugin: ${pluginId}`);\n\t\t\treturn handle.api;\n\t\t},\n\t\trevoke(pluginId) {\n\t\t\tconst handle = handles.get(pluginId);\n\t\t\tif (!handle) throw new Error(`Plugin testkit has no loaded plugin: ${pluginId}`);\n\t\t\tif (handle.api.state) {\n\t\t\t\tconst entries = snapshot(handle.api.state.list());\n\t\t\t\trevokedState.set(pluginId, entries);\n\t\t\t\tretainedState.set(pluginId, entries);\n\t\t\t}\n\t\t\truntime.revokeAPI(handle.api);\n\t\t},\n\t\tinspect: () => runtime.inspect(),\n\t\tflushLifecycle: async () => {\n\t\t\twhile (pendingLifecycleDispatches.size > 0) {\n\t\t\t\tawait Promise.all([...pendingLifecycleDispatches]);\n\t\t\t}\n\t\t\tawait runtime.drainLifecycleDeliveries();\n\t\t},\n\t\ttranscript: () =>\n\t\t\tsnapshot(\n\t\t\t\ttranscriptValue({\n\t\t\t\t\tversion: 1 as const,\n\t\t\t\t\tmanifestRoot,\n\t\t\t\t\tmanifests: inputManifests,\n\t\t\t\t\tinputOrder,\n\t\t\t\t\tloadOrder,\n\t\t\t\t\tstate: stateTranscript(),\n\t\t\t\t\tstateMutations,\n\t\t\t\t\tstateWatchDeliveries,\n\t\t\t\t\tcapabilityCalls,\n\t\t\t\t\tlifecycleEvents,\n\t\t\t\t\tlifecycleFailures,\n\t\t\t\t\tlifecycleReports: runtime.inspect().lifecycleReports,\n\t\t\t\t\tinspector: runtime.inspect(),\n\t\t\t\t}) as PluginTestKitTranscript,\n\t\t\t),\n\t\tdispose: async () => {\n\t\t\tdisposePromise ??= (async () => {\n\t\t\t\tclosing = true;\n\t\t\t\tconst failures: unknown[] = [];\n\t\t\t\ttry {\n\t\t\t\t\tawait ready;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (!(error instanceof Error && error.message === \"Plugin testkit was disposed during startup\")) {\n\t\t\t\t\t\tfailures.push(error);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (const [pluginId, handle] of handles) captureState(pluginId, handle);\n\t\t\t\tfor (const handle of [...handles.values()].reverse()) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait handle.dispose();\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tfailures.push(error);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tawait runtime.disposeAll();\n\t\t\t\t} catch (error) {\n\t\t\t\t\tfailures.push(error);\n\t\t\t\t}\n\t\t\t\tif (failures.length === 1) throw failures[0];\n\t\t\t\tif (failures.length > 1) throw new AggregateError(failures, \"Plugin testkit disposal failed\");\n\t\t\t})();\n\t\t\treturn disposePromise;\n\t\t},\n\t};\n}\n\n/** Runs a fixture repeatedly and rejects on the first transcript divergence. */\nexport async function repeatPluginTestKit(\n\ttimes: number,\n\trun: () => Promise<PluginTestKitTranscript>,\n): Promise<PluginTestKitTranscript> {\n\tif (!Number.isSafeInteger(times) || times < 1)\n\t\tthrow new Error(t(\"Plugin testkit repeat count must be a positive integer\"));\n\tlet baseline: PluginTestKitTranscript | undefined;\n\tfor (let index = 0; index < times; index += 1) {\n\t\tconst transcript = await run();\n\t\tif (baseline && canonicalJson(transcript) !== canonicalJson(baseline)) {\n\t\t\tthrow new Error(t(\"Plugin testkit transcript diverged on run {run}\", { run: index + 1 }));\n\t\t}\n\t\tbaseline = transcript;\n\t}\n\treturn baseline!;\n}\n"]}
|
|
@@ -2,6 +2,7 @@ import { installBootstrapLifecycle } from "../core/extensions/bootstrap-lifecycl
|
|
|
2
2
|
import { loadCapabilityPlugin, } from "../core/extensions/capability-plugin.js";
|
|
3
3
|
import { createCapabilityRuntime, resolvePluginCapabilityOrder, } from "../core/extensions/capability-runtime.js";
|
|
4
4
|
import { EXPERIMENTAL_PUBLIC_API_VERSION, } from "../core/extensions/public-api.js";
|
|
5
|
+
import { t } from "../core/i18n/index.js";
|
|
5
6
|
function snapshot(value) {
|
|
6
7
|
const clone = structuredClone(value);
|
|
7
8
|
const freeze = (candidate) => {
|
|
@@ -109,7 +110,7 @@ const DEFAULT_MANIFEST_ROOT = "<plugin-testkit>";
|
|
|
109
110
|
export function createPluginTestKit(options) {
|
|
110
111
|
const manifestRoot = options.manifestRoot ?? DEFAULT_MANIFEST_ROOT;
|
|
111
112
|
if (typeof manifestRoot !== "string" || !manifestRoot.trim()) {
|
|
112
|
-
throw new Error("Plugin testkit manifestRoot must be a non-empty string");
|
|
113
|
+
throw new Error(t("Plugin testkit manifestRoot must be a non-empty string"));
|
|
113
114
|
}
|
|
114
115
|
const inputPlugins = options.plugins.map((plugin) => ({
|
|
115
116
|
manifest: snapshot(plugin.manifest),
|
|
@@ -479,12 +480,12 @@ export function createPluginTestKit(options) {
|
|
|
479
480
|
/** Runs a fixture repeatedly and rejects on the first transcript divergence. */
|
|
480
481
|
export async function repeatPluginTestKit(times, run) {
|
|
481
482
|
if (!Number.isSafeInteger(times) || times < 1)
|
|
482
|
-
throw new Error("Plugin testkit repeat count must be a positive integer");
|
|
483
|
+
throw new Error(t("Plugin testkit repeat count must be a positive integer"));
|
|
483
484
|
let baseline;
|
|
484
485
|
for (let index = 0; index < times; index += 1) {
|
|
485
486
|
const transcript = await run();
|
|
486
487
|
if (baseline && canonicalJson(transcript) !== canonicalJson(baseline)) {
|
|
487
|
-
throw new Error(
|
|
488
|
+
throw new Error(t("Plugin testkit transcript diverged on run {run}", { run: index + 1 }));
|
|
488
489
|
}
|
|
489
490
|
baseline = transcript;
|
|
490
491
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-testkit.js","sourceRoot":"","sources":["../../src/testing/plugin-testkit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,EAGN,oBAAoB,GACpB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAEN,uBAAuB,EACvB,4BAA4B,GAC5B,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAKN,+BAA+B,GAe/B,MAAM,kCAAkC,CAAC;AAyJ1C,SAAS,QAAQ,CAAI,KAAQ,EAAK;IACjC,MAAM,KAAK,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;IACrC,MAAM,MAAM,GAAG,CAAC,SAAkB,EAAQ,EAAE,CAAC;QAC5C,IAAI,CAAC,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC;YAAE,OAAO;QACzF,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,SAAoC,CAAC;YAAE,MAAM,CAAC,KAAK,CAAC,CAAC;QACvF,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAAA,CACzB,CAAC;IACF,MAAM,CAAC,KAAK,CAAC,CAAC;IACd,OAAO,KAAK,CAAC;AAAA,CACb;AAED,SAAS,eAAe,CAAC,KAAc,EAAE,IAAI,GAAG,IAA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QAAQ,CAAC,MAAM,KAAK,CAAC;oBAAE,MAAM,QAAQ,CAAC,CAAC,CAAC,CAAC;gBAC7C,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;oBAAE,MAAM,IAAI,cAAc,CAAC,QAAQ,EAAE,gCAAgC,CAAC,CAAC;YAAA,CAC9F,CAAC,EAAE,CAAC;YACL,OAAO,cAAc,CAAC;QAAA,CACtB;KACD,CAAC;AAAA,CACF;AAED,gFAAgF;AAChF,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACxC,KAAa,EACb,GAA2C,EACR;IACnC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC;QAC5C,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;IAC3E,IAAI,QAA6C,CAAC;IAClD,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QAC/C,MAAM,UAAU,GAAG,MAAM,GAAG,EAAE,CAAC;QAC/B,IAAI,QAAQ,IAAI,aAAa,CAAC,UAAU,CAAC,KAAK,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC;YACvE,MAAM,IAAI,KAAK,CAAC,6CAA6C,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC;QAC3E,CAAC;QACD,QAAQ,GAAG,UAAU,CAAC;IACvB,CAAC;IACD,OAAO,QAAS,CAAC;AAAA,CACjB","sourcesContent":["import { installBootstrapLifecycle } from \"../core/extensions/bootstrap-lifecycle.ts\";\nimport {\n\ttype CapabilityPluginFactory,\n\ttype CapabilityPluginHandle,\n\tloadCapabilityPlugin,\n} from \"../core/extensions/capability-plugin.ts\";\nimport {\n\ttype CapabilityRuntime,\n\tcreateCapabilityRuntime,\n\tresolvePluginCapabilityOrder,\n} from \"../core/extensions/capability-runtime.ts\";\nimport {\n\ttype CapabilityAPI,\n\ttype CapabilityDirectoryAPI,\n\ttype CapabilityProviderHandler,\n\ttype DisposableRegistration,\n\tEXPERIMENTAL_PUBLIC_API_VERSION,\n\ttype HostCapabilities,\n\ttype LifecycleDispatchRequest,\n\ttype LifecycleDispatchResult,\n\ttype LifecycleEvent,\n\ttype LifecyclePhase,\n\ttype OperationHandle,\n\ttype OperationStatus,\n\ttype PluginCapabilityDeclaration,\n\ttype PluginManifest,\n\ttype RuntimeInspectorSnapshot,\n\ttype StateAPI,\n\ttype StateChange,\n\ttype StateEntry,\n\ttype StateSetOptions,\n} from \"../core/extensions/public-api.ts\";\n\n/**\n * A deterministic, runtime-only fixture for experimental capability plugins.\n *\n * It deliberately does not create an AgentSession or a model provider. Tests\n * that need those integration points should use the existing session harness.\n */\nexport interface PluginTestKitPlugin {\n\treadonly manifest: PluginManifest;\n\treadonly factory: CapabilityPluginFactory;\n}\n\nexport interface PluginTestKitOptions {\n\treadonly plugins: readonly PluginTestKitPlugin[];\n\treadonly host?: Omit<HostCapabilities, \"apiVersion\">;\n\treadonly clock?: () => number;\n\t/** Injects stable runtime identifiers for deterministic transcript tests. */\n\treadonly idFactory?: (kind: string, sequence: number) => string;\n\t/** Logical root used to identify inline manifests without a host filesystem path. */\n\treadonly manifestRoot?: string;\n\t/**\n\t * Installs the bootstrap lifecycle catalog (host parity: the real session\n\t * host installs it) before the plugin load loop, so plugin factories can\n\t * registerObserve standard events. Off by default to keep existing\n\t * transcripts unchanged; the installed handle is disposed by\n\t * runtime.disposeAll() inside dispose().\n\t */\n\treadonly lifecycle?: boolean;\n}\n\nexport interface PluginTestKitManifestIdentity {\n\treadonly pluginId: string;\n\treadonly version: string;\n\treadonly entry: string;\n}\n\nexport interface PluginTestKitLifecycleEnvelope {\n\treadonly eventId: string;\n\treadonly type: string;\n\treadonly version: number;\n\treadonly phase: LifecycleEvent[\"phase\"];\n\treadonly deliveryId: string;\n\treadonly source: string;\n\treadonly operationId?: string;\n\treadonly correlationId?: string;\n\treadonly causationId?: string;\n\treadonly data: unknown;\n}\n\nexport interface PluginTestKitLifecycleFailureReport {\n\treadonly eventId: string;\n\treadonly type: string;\n\treadonly version: number;\n\treadonly phase: LifecyclePhase;\n\treadonly status: \"transform-failed\" | \"execute-failed\" | \"delivered\" | \"queued\";\n\treadonly attempted: number;\n\treadonly succeeded: number;\n\treadonly queued?: number;\n\treadonly failed: number;\n\treadonly failures: readonly {\n\t\treadonly pluginId: string;\n\t\treadonly registrationId: string;\n\t\treadonly kind: string;\n\t\treadonly error: unknown;\n\t}[];\n}\n\n/** A dispatch rejection is retained even when no event envelope was created. */\nexport interface PluginTestKitLifecycleFailure {\n\treadonly eventId: string | null;\n\treadonly type: string | null;\n\treadonly version: number | null;\n\treadonly phase: LifecyclePhase | null;\n\treadonly deliveryId: string | null;\n\treadonly source: string | null;\n\treadonly operationId?: string;\n\treadonly correlationId?: string;\n\treadonly causationId?: string;\n\treadonly data?: unknown;\n\treadonly status: \"rejected\" | \"cancelled\" | \"transform-failed\" | \"execute-failed\";\n\treadonly error: unknown;\n\treadonly report?: PluginTestKitLifecycleFailureReport;\n}\n\nexport interface PluginTestKitStateMutation {\n\treadonly pluginId: string;\n\treadonly action: \"set\" | \"delete\";\n\treadonly key: string;\n\treadonly status: \"committed\" | \"rejected\";\n\treadonly revision?: number;\n\treadonly expectedRevision?: number;\n\treadonly value?: unknown;\n\treadonly operationId?: string;\n\treadonly correlationId?: string;\n\treadonly error?: unknown;\n}\n\nexport interface PluginTestKitStateWatchDelivery {\n\treadonly pluginId: string;\n\treadonly watcherId: string;\n\treadonly key: string;\n\treadonly revision: number;\n\treadonly status: \"delivered\" | \"failed\";\n\treadonly value?: unknown;\n\treadonly operationId?: string;\n\treadonly correlationId?: string;\n\treadonly error?: unknown;\n}\n\nexport interface PluginTestKitCapabilityCall {\n\treadonly operationId: string | null;\n\treadonly callerPluginId: string;\n\treadonly providerPluginId: string;\n\treadonly capabilityId: string;\n\treadonly capabilityVersion: number;\n\treadonly capabilityKind: PluginCapabilityDeclaration[\"kind\"];\n\treadonly status: OperationStatus;\n\treadonly error?: unknown;\n}\n\nexport interface PluginTestKitTranscript {\n\treadonly version: 1;\n\treadonly manifestRoot: string;\n\treadonly manifests: readonly PluginTestKitManifestIdentity[];\n\treadonly inputOrder: readonly string[];\n\treadonly loadOrder: readonly string[];\n\treadonly state: readonly {\n\t\treadonly pluginId: string;\n\t\treadonly entries: readonly StateEntry[];\n\t}[];\n\treadonly stateMutations: readonly PluginTestKitStateMutation[];\n\treadonly stateWatchDeliveries: readonly PluginTestKitStateWatchDelivery[];\n\treadonly capabilityCalls: readonly PluginTestKitCapabilityCall[];\n\treadonly lifecycleEvents: readonly PluginTestKitLifecycleEnvelope[];\n\treadonly lifecycleFailures: readonly PluginTestKitLifecycleFailure[];\n\treadonly lifecycleReports: RuntimeInspectorSnapshot[\"lifecycleReports\"];\n\treadonly inspector: RuntimeInspectorSnapshot;\n}\n\nexport interface PluginTestKit {\n\treadonly runtime: CapabilityRuntime;\n\t/** Resolves after every manifest is topology-ordered and its factory has loaded. */\n\treadonly ready: Promise<void>;\n\tapi(pluginId: string): CapabilityAPI;\n\trevoke(pluginId: string): void;\n\tinspect(): RuntimeInspectorSnapshot;\n\ttranscript(): PluginTestKitTranscript;\n\t/** Waits for lifecycle facts initiated by runtime-owned detached operations. */\n\tflushLifecycle(): Promise<void>;\n\tdispose(): Promise<void>;\n}\n\nfunction snapshot<T>(value: T): T {\n\tconst clone = structuredClone(value);\n\tconst freeze = (candidate: unknown): void => {\n\t\tif (!candidate || typeof candidate !== \"object\" || ArrayBuffer.isView(candidate)) return;\n\t\tfor (const child of Object.values(candidate as Record<string, unknown>)) freeze(child);\n\t\tObject.freeze(candidate);\n\t};\n\tfreeze(clone);\n\treturn clone;\n}\n\nfunction transcriptValue(value: unknown, seen = new WeakSet<object>()): unknown {\n\tif (value === null || typeof value === \"string\" || typeof value === \"boolean\") return value;\n\tif (typeof value === \"number\") return Number.isFinite(value) ? value : String(value);\n\tif (typeof value === \"bigint\") return `${value}n`;\n\tif (value === undefined) return null;\n\tif (value instanceof Error) {\n\t\tif (seen.has(value)) return \"[Circular]\";\n\t\tseen.add(value);\n\t\tconst output: Record<string, unknown> = { name: value.name, message: value.message };\n\t\tconst code = (value as Error & { code?: unknown }).code;\n\t\tif (code !== undefined) output.code = transcriptValue(code, seen);\n\t\tconst cause = (value as Error & { cause?: unknown }).cause;\n\t\tif (cause !== undefined) output.cause = transcriptValue(cause, seen);\n\t\tfor (const key of Object.keys(value).sort()) {\n\t\t\tif (key === \"code\" || key === \"cause\") continue;\n\t\t\toutput[key] = transcriptValue((value as unknown as Record<string, unknown>)[key], seen);\n\t\t}\n\t\treturn output;\n\t}\n\tif (typeof value !== \"object\") return String(value);\n\tif (seen.has(value)) return \"[Circular]\";\n\tseen.add(value);\n\tif (Array.isArray(value)) return value.map((item) => transcriptValue(item, seen));\n\tconst output: Record<string, unknown> = {};\n\tfor (const key of Object.keys(value as Record<string, unknown>).sort()) {\n\t\toutput[key] = transcriptValue((value as Record<string, unknown>)[key], seen);\n\t}\n\treturn output;\n}\n\nfunction canonicalJson(value: unknown): string {\n\tconst serialized = JSON.stringify(transcriptValue(value));\n\t// v8 ignore next -- transcriptValue 已消毒全部值,JSON.stringify 不会返回 undefined\n\tif (serialized === undefined) throw new Error(\"Plugin testkit transcript is not JSON-serializable\");\n\treturn serialized;\n}\n\ntype PluginTestKitLifecycleReport = PluginTestKitLifecycleFailureReport;\n\nfunction lifecycleFailureReport(error: unknown): PluginTestKitLifecycleReport | undefined {\n\tif (!error || typeof error !== \"object\") return undefined;\n\tconst report = (error as { report?: unknown }).report;\n\tif (!report || typeof report !== \"object\") return undefined;\n\tconst candidate = report as RuntimeInspectorSnapshot[\"lifecycleReports\"][number];\n\t// v8 ignore next -- report 由 runtime 构造、形状恒满足;此处仅防御伪造的 report\n\tif (\n\t\ttypeof candidate.eventId !== \"string\" ||\n\t\ttypeof candidate.type !== \"string\" ||\n\t\t!Number.isSafeInteger(candidate.version) ||\n\t\t(candidate.phase !== \"raw\" && candidate.phase !== \"candidate\" && candidate.phase !== \"committed\") ||\n\t\t(candidate.status !== \"transform-failed\" &&\n\t\t\tcandidate.status !== \"execute-failed\" &&\n\t\t\tcandidate.status !== \"delivered\") ||\n\t\t!Array.isArray(candidate.failures)\n\t) {\n\t\treturn undefined;\n\t}\n\treturn {\n\t\teventId: candidate.eventId,\n\t\ttype: candidate.type,\n\t\tversion: candidate.version,\n\t\tphase: candidate.phase,\n\t\tstatus: candidate.status,\n\t\tattempted: candidate.attempted,\n\t\tsucceeded: candidate.succeeded,\n\t\tfailed: candidate.failed,\n\t\tfailures: candidate.failures.map((failure) => ({\n\t\t\tpluginId: failure.pluginId,\n\t\t\tregistrationId: failure.registrationId,\n\t\t\tkind: failure.kind,\n\t\t\terror: transcriptValue(failure.error),\n\t\t})),\n\t};\n}\n\nfunction defaultHost(): HostCapabilities {\n\treturn {\n\t\tapiVersion: EXPERIMENTAL_PUBLIC_API_VERSION,\n\t\tmode: \"full-control\",\n\t\tfeatures: [\"logger-v1\", \"diagnostics-v1\", \"plugin-state-v1\", \"runtime-inspector-v1\"],\n\t\ttransports: [\"in-process\"],\n\t};\n}\n\nconst DEFAULT_MANIFEST_ROOT = \"<plugin-testkit>\";\n\ninterface MutablePluginTestKitStateMutation {\n\tpluginId: string;\n\taction: \"set\" | \"delete\";\n\tkey: string;\n\tstatus: \"committed\" | \"rejected\";\n\trevision?: number;\n\texpectedRevision?: number;\n\tvalue?: unknown;\n\toperationId?: string;\n\tcorrelationId?: string;\n\terror?: unknown;\n}\n\ninterface MutablePluginTestKitStateWatchDelivery {\n\tpluginId: string;\n\twatcherId: string;\n\tkey: string;\n\trevision: number;\n\tstatus: \"delivered\" | \"failed\";\n\tvalue?: unknown;\n\toperationId?: string;\n\tcorrelationId?: string;\n\terror?: unknown;\n}\n\ninterface MutablePluginTestKitCapabilityCall {\n\toperationId: string | null;\n\tcallerPluginId: string;\n\tproviderPluginId: string;\n\tcapabilityId: string;\n\tcapabilityVersion: number;\n\tcapabilityKind: PluginCapabilityDeclaration[\"kind\"];\n\tstatus: OperationStatus;\n\terror?: unknown;\n}\n\ninterface MutablePluginTestKitLifecycleFailure {\n\teventId: string | null;\n\ttype: string | null;\n\tversion: number | null;\n\tphase: LifecyclePhase | null;\n\tdeliveryId: string | null;\n\tsource: string | null;\n\toperationId?: string;\n\tcorrelationId?: string;\n\tcausationId?: string;\n\tdata?: unknown;\n\tstatus: \"rejected\" | \"cancelled\" | \"transform-failed\" | \"execute-failed\";\n\terror: unknown;\n\treport?: PluginTestKitLifecycleFailureReport;\n}\n\n/** Create a runtime-only fixture with deterministic topology and teardown. */\nexport function createPluginTestKit(options: PluginTestKitOptions): PluginTestKit {\n\tconst manifestRoot = options.manifestRoot ?? DEFAULT_MANIFEST_ROOT;\n\tif (typeof manifestRoot !== \"string\" || !manifestRoot.trim()) {\n\t\tthrow new Error(\"Plugin testkit manifestRoot must be a non-empty string\");\n\t}\n\tconst inputPlugins = options.plugins.map((plugin) => ({\n\t\tmanifest: snapshot(plugin.manifest),\n\t\tfactory: plugin.factory,\n\t}));\n\tconst suppliedHost = options.host;\n\tconst host: HostCapabilities = {\n\t\t...defaultHost(),\n\t\t...suppliedHost,\n\t\tfeatures: suppliedHost?.features ?? defaultHost().features,\n\t\ttransports: suppliedHost?.transports ?? defaultHost().transports,\n\t};\n\tconst pluginsByManifest = new Map(inputPlugins.map((plugin) => [plugin.manifest, plugin]));\n\tconst handles = new Map<string, CapabilityPluginHandle>();\n\tconst revokedState = new Map<string, readonly StateEntry[]>();\n\tconst retainedState = new Map<string, readonly StateEntry[]>();\n\tconst loadOrder: string[] = [];\n\tconst stateMutations: MutablePluginTestKitStateMutation[] = [];\n\tconst stateWatchDeliveries: MutablePluginTestKitStateWatchDelivery[] = [];\n\tconst capabilityCalls: MutablePluginTestKitCapabilityCall[] = [];\n\tconst lifecycleEvents: PluginTestKitLifecycleEnvelope[] = [];\n\tconst lifecycleFailures: MutablePluginTestKitLifecycleFailure[] = [];\n\tconst pendingLifecycleDispatches = new Set<Promise<void>>();\n\tlet disposePromise: Promise<void> | undefined;\n\tconst recordLifecycleDispatch = (\n\t\trequest: LifecycleDispatchRequest<unknown>,\n\t\tsettled: Promise<LifecycleDispatchResult<unknown>>,\n\t): void => {\n\t\tconst recorded = settled.then(\n\t\t\t(result) => {\n\t\t\t\tlifecycleEvents.push(\n\t\t\t\t\tsnapshot({\n\t\t\t\t\t\teventId: result.event.id,\n\t\t\t\t\t\ttype: result.event.type,\n\t\t\t\t\t\tversion: result.event.version,\n\t\t\t\t\t\tphase: result.event.phase,\n\t\t\t\t\t\tdeliveryId: result.event.deliveryId,\n\t\t\t\t\t\tsource: result.event.source,\n\t\t\t\t\t\t...(result.event.operationId === undefined ? {} : { operationId: result.event.operationId }),\n\t\t\t\t\t\t...(result.event.correlationId === undefined ? {} : { correlationId: result.event.correlationId }),\n\t\t\t\t\t\t...(result.event.causationId === undefined ? {} : { causationId: result.event.causationId }),\n\t\t\t\t\t\tdata: transcriptValue(result.event.data),\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t},\n\t\t\t(error) => {\n\t\t\t\tconst requestObject =\n\t\t\t\t\trequest && typeof request === \"object\" ? (request as unknown as Record<string, unknown>) : undefined;\n\t\t\t\tconst report = lifecycleFailureReport(error);\n\t\t\t\tconst rawPhase = requestObject?.phase;\n\t\t\t\tconst phase: LifecyclePhase | null =\n\t\t\t\t\trawPhase === \"raw\" || rawPhase === \"candidate\" || rawPhase === \"committed\" ? rawPhase : null;\n\t\t\t\tconst rawSource = requestObject?.source;\n\t\t\t\tconst source =\n\t\t\t\t\trawSource === undefined\n\t\t\t\t\t\t? requestObject === undefined\n\t\t\t\t\t\t\t? null\n\t\t\t\t\t\t\t: \"host\"\n\t\t\t\t\t\t: typeof rawSource === \"string\"\n\t\t\t\t\t\t\t? rawSource\n\t\t\t\t\t\t\t: null;\n\t\t\t\tconst rawVersion = requestObject?.version;\n\t\t\t\tconst version = typeof rawVersion === \"number\" && Number.isSafeInteger(rawVersion) ? rawVersion : null;\n\t\t\t\tconst failure: MutablePluginTestKitLifecycleFailure = {\n\t\t\t\t\teventId: report?.eventId ?? null,\n\t\t\t\t\ttype: typeof requestObject?.type === \"string\" ? requestObject.type : null,\n\t\t\t\t\tversion,\n\t\t\t\t\tphase,\n\t\t\t\t\tdeliveryId: null,\n\t\t\t\t\tsource,\n\t\t\t\t\t...(typeof requestObject?.operationId === \"string\" ? { operationId: requestObject.operationId } : {}),\n\t\t\t\t\t...(typeof requestObject?.correlationId === \"string\"\n\t\t\t\t\t\t? { correlationId: requestObject.correlationId }\n\t\t\t\t\t\t: {}),\n\t\t\t\t\t...(typeof requestObject?.causationId === \"string\" ? { causationId: requestObject.causationId } : {}),\n\t\t\t\t\t...(requestObject !== undefined && \"data\" in requestObject\n\t\t\t\t\t\t? { data: transcriptValue(requestObject.data) }\n\t\t\t\t\t\t: {}),\n\t\t\t\t\tstatus:\n\t\t\t\t\t\treport?.status === \"transform-failed\" || report?.status === \"execute-failed\"\n\t\t\t\t\t\t\t? report.status\n\t\t\t\t\t\t\t: requestObject?.signal instanceof AbortSignal && requestObject.signal.aborted\n\t\t\t\t\t\t\t\t? \"cancelled\"\n\t\t\t\t\t\t\t\t: \"rejected\",\n\t\t\t\t\terror: transcriptValue(error),\n\t\t\t\t\t...(report === undefined ? {} : { report }),\n\t\t\t\t};\n\t\t\t\tlifecycleFailures.push(snapshot(failure));\n\t\t\t},\n\t\t);\n\t\tpendingLifecycleDispatches.add(recorded);\n\t\tvoid recorded.then(() => pendingLifecycleDispatches.delete(recorded));\n\t};\n\tconst runtime = createCapabilityRuntime(host, {\n\t\tclock: options.clock ?? (() => 0),\n\t\tidFactory: options.idFactory ?? ((kind, sequence) => `testkit:${kind}:${sequence}`),\n\t\tonLifecycleDispatch: recordLifecycleDispatch,\n\t});\n\t// Must run before the ready loop: plugin factories registerObserve during load.\n\tif (options.lifecycle === true) installBootstrapLifecycle(runtime);\n\n\tconst inputManifests = inputPlugins.map(({ manifest }) => ({\n\t\tpluginId: manifest.id,\n\t\tversion: manifest.version,\n\t\tentry: manifest.entry,\n\t}));\n\tconst inputOrder = inputPlugins.map(({ manifest }) => manifest.id);\n\tconst wrappedToRawAPI = new WeakMap<CapabilityAPI, CapabilityAPI>();\n\tconst wrapStateAPI = (pluginId: string, state: StateAPI): StateAPI => {\n\t\tconst operationMetadata = (options?: StateSetOptions) => ({\n\t\t\t...(options?.expectedRevision === undefined ? {} : { expectedRevision: options.expectedRevision }),\n\t\t\t...(options?.operationId === undefined ? {} : { operationId: options.operationId }),\n\t\t\t...(options?.correlationId === undefined ? {} : { correlationId: options.correlationId }),\n\t\t});\n\t\tconst recordMutation = (\n\t\t\taction: \"set\" | \"delete\",\n\t\t\tkey: string,\n\t\t\tmetadata: ReturnType<typeof operationMetadata>,\n\t\t\tresult: { status: \"committed\"; revision: number; value?: unknown } | { status: \"rejected\"; error: unknown },\n\t\t): void => {\n\t\t\tstateMutations.push({\n\t\t\t\tpluginId,\n\t\t\t\taction,\n\t\t\t\tkey,\n\t\t\t\t...metadata,\n\t\t\t\t...result,\n\t\t\t});\n\t\t};\n\t\treturn Object.freeze({\n\t\t\tget: (key: string) => state.get(key),\n\t\t\tset: (key: string, value: Parameters<StateAPI[\"set\"]>[1], options?: StateSetOptions) => {\n\t\t\t\tconst metadata = operationMetadata(options);\n\t\t\t\ttry {\n\t\t\t\t\tconst revision = state.set(key, value, options);\n\t\t\t\t\trecordMutation(\"set\", key, metadata, {\n\t\t\t\t\t\tstatus: \"committed\",\n\t\t\t\t\t\trevision,\n\t\t\t\t\t\tvalue: transcriptValue(value),\n\t\t\t\t\t});\n\t\t\t\t\treturn revision;\n\t\t\t\t} catch (error) {\n\t\t\t\t\trecordMutation(\"set\", key, metadata, { status: \"rejected\", error: transcriptValue(error) });\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t},\n\t\t\tdelete: (key: string, options?: StateSetOptions) => {\n\t\t\t\tconst metadata = operationMetadata(options);\n\t\t\t\ttry {\n\t\t\t\t\tconst revision = state.delete(key, options);\n\t\t\t\t\trecordMutation(\"delete\", key, metadata, { status: \"committed\", revision });\n\t\t\t\t\treturn revision;\n\t\t\t\t} catch (error) {\n\t\t\t\t\trecordMutation(\"delete\", key, metadata, { status: \"rejected\", error: transcriptValue(error) });\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t},\n\t\t\tlist: (prefix?: string) => state.list(prefix),\n\t\t\twatch: (prefix: string | undefined, handler: (change: StateChange) => void) => {\n\t\t\t\tlet watcherId = \"<pending>\";\n\t\t\t\tconst registration = state.watch(prefix, (change) => {\n\t\t\t\t\tconst delivery: MutablePluginTestKitStateWatchDelivery = {\n\t\t\t\t\t\tpluginId,\n\t\t\t\t\t\twatcherId,\n\t\t\t\t\t\tkey: change.key,\n\t\t\t\t\t\trevision: change.revision,\n\t\t\t\t\t\tstatus: \"delivered\",\n\t\t\t\t\t\t...(change.value === undefined ? {} : { value: transcriptValue(change.value) }),\n\t\t\t\t\t\t...(change.operationId === undefined ? {} : { operationId: change.operationId }),\n\t\t\t\t\t\t...(change.correlationId === undefined ? {} : { correlationId: change.correlationId }),\n\t\t\t\t\t};\n\t\t\t\t\tstateWatchDeliveries.push(delivery);\n\t\t\t\t\ttry {\n\t\t\t\t\t\thandler(change);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tdelivery.status = \"failed\";\n\t\t\t\t\t\tdelivery.error = transcriptValue(error);\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\twatcherId = registration.id;\n\t\t\t\treturn registration;\n\t\t\t},\n\t\t});\n\t};\n\tconst wrapCapabilityDirectory = (\n\t\tcallerPluginId: string,\n\t\tcapabilities: CapabilityDirectoryAPI,\n\t): CapabilityDirectoryAPI =>\n\t\tObject.freeze({\n\t\t\tprovide: <TInput = unknown, TResult = unknown>(\n\t\t\t\tdeclaration: PluginCapabilityDeclaration,\n\t\t\t\thandler: CapabilityProviderHandler<TInput, TResult>,\n\t\t\t): DisposableRegistration => capabilities.provide(declaration, handler),\n\t\t\trequire: <TResult = unknown>(id: string, requireOptions?: { version?: number }) => {\n\t\t\t\tconst handle = capabilities.require<TResult>(id, requireOptions);\n\t\t\t\treturn Object.freeze({\n\t\t\t\t\tdeclaration: handle.declaration,\n\t\t\t\t\towner: handle.owner,\n\t\t\t\t\tcall: (input: unknown, callOptions?: { signal?: AbortSignal }): OperationHandle<TResult> => {\n\t\t\t\t\t\tlet operation: OperationHandle<TResult>;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\toperation = handle.call(input, callOptions);\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tcapabilityCalls.push({\n\t\t\t\t\t\t\t\toperationId: null,\n\t\t\t\t\t\t\t\tcallerPluginId,\n\t\t\t\t\t\t\t\tproviderPluginId: handle.owner,\n\t\t\t\t\t\t\t\tcapabilityId: handle.declaration.id,\n\t\t\t\t\t\t\t\tcapabilityVersion: handle.declaration.version,\n\t\t\t\t\t\t\t\tcapabilityKind: handle.declaration.kind,\n\t\t\t\t\t\t\t\tstatus: \"failed\",\n\t\t\t\t\t\t\t\terror: transcriptValue(error),\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst record: MutablePluginTestKitCapabilityCall = {\n\t\t\t\t\t\t\toperationId: operation.id,\n\t\t\t\t\t\t\tcallerPluginId,\n\t\t\t\t\t\t\tproviderPluginId: handle.owner,\n\t\t\t\t\t\t\tcapabilityId: handle.declaration.id,\n\t\t\t\t\t\t\tcapabilityVersion: handle.declaration.version,\n\t\t\t\t\t\t\tcapabilityKind: handle.declaration.kind,\n\t\t\t\t\t\t\tstatus: operation.status(),\n\t\t\t\t\t\t};\n\t\t\t\t\t\tcapabilityCalls.push(record);\n\t\t\t\t\t\tvoid operation.result.then(\n\t\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t\trecord.status = operation.status();\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t(error) => {\n\t\t\t\t\t\t\t\trecord.status = operation.status();\n\t\t\t\t\t\t\t\trecord.error = transcriptValue(error);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn operation;\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t},\n\t\t\tlist: (listOptions?: { kind?: PluginCapabilityDeclaration[\"kind\"] }) => capabilities.list(listOptions),\n\t\t});\n\tconst originalCreateAPI = runtime.createAPI.bind(runtime);\n\tconst originalRevokeAPI = runtime.revokeAPI.bind(runtime);\n\truntime.createAPI = (manifest) => {\n\t\tconst rawAPI = originalCreateAPI(manifest);\n\t\tconst wrappedAPI = Object.freeze({\n\t\t\t...rawAPI,\n\t\t\tcapabilities: wrapCapabilityDirectory(rawAPI.manifest.id, rawAPI.capabilities),\n\t\t\t...(rawAPI.state === undefined ? {} : { state: wrapStateAPI(rawAPI.manifest.id, rawAPI.state) }),\n\t\t});\n\t\twrappedToRawAPI.set(wrappedAPI, rawAPI);\n\t\treturn wrappedAPI;\n\t};\n\truntime.revokeAPI = (api) => {\n\t\t// v8 ignore next -- 所有 API 均经包装后的 createAPI 创建,映射必命中\n\t\tconst rawAPI = wrappedToRawAPI.get(api) ?? api;\n\t\tfor (const [pluginId, handle] of handles) {\n\t\t\tif (handle.api === api || handle.api === rawAPI) captureState(pluginId, handle);\n\t\t}\n\t\toriginalRevokeAPI(rawAPI);\n\t};\n\n\tconst captureState = (pluginId: string, handle: CapabilityPluginHandle): void => {\n\t\tif (retainedState.has(pluginId) || revokedState.has(pluginId)) return;\n\t\tretainedState.set(pluginId, snapshot(handle.api.state?.list() ?? []));\n\t};\n\tconst stateTranscript = (): readonly { readonly pluginId: string; readonly entries: readonly StateEntry[] }[] =>\n\t\t[...handles.entries()].map(([pluginId, handle]) => {\n\t\t\treturn {\n\t\t\t\tpluginId,\n\t\t\t\tentries: retainedState.get(pluginId) ?? snapshot(handle.api.state?.list() ?? []),\n\t\t\t};\n\t\t});\n\n\tlet closing = false;\n\tconst ready = (async () => {\n\t\ttry {\n\t\t\tconst ordered = resolvePluginCapabilityOrder(inputPlugins.map((plugin) => plugin.manifest));\n\t\t\tfor (const manifest of ordered) {\n\t\t\t\tif (closing) throw new Error(\"Plugin testkit was disposed during startup\");\n\t\t\t\tconst plugin = pluginsByManifest.get(manifest);\n\t\t\t\t// v8 ignore next -- plugins 数组同时供给加载顺序与 factory 映射,必可解析\n\t\t\t\tif (!plugin) throw new Error(`Plugin testkit cannot resolve factory: ${manifest.id}`);\n\t\t\t\tconst handle = await loadCapabilityPlugin(runtime, plugin.manifest, plugin.factory);\n\t\t\t\thandles.set(manifest.id, handle);\n\t\t\t\tloadOrder.push(manifest.id);\n\t\t\t}\n\t\t} catch (startupError) {\n\t\t\tconst failures: unknown[] = [startupError];\n\t\t\tfor (const handle of [...handles.values()].reverse()) {\n\t\t\t\ttry {\n\t\t\t\t\tawait handle.dispose();\n\t\t\t\t} catch (error) {\n\t\t\t\t\tfailures.push(error);\n\t\t\t\t}\n\t\t\t}\n\t\t\thandles.clear();\n\t\t\ttry {\n\t\t\t\tawait runtime.disposeAll();\n\t\t\t} catch (error) {\n\t\t\t\tfailures.push(error);\n\t\t\t}\n\t\t\tif (failures.length > 1) throw new AggregateError(failures, \"Plugin testkit startup rollback failed\");\n\t\t\tthrow startupError;\n\t\t}\n\t})();\n\n\treturn {\n\t\truntime,\n\t\tready,\n\t\tapi(pluginId) {\n\t\t\tconst handle = handles.get(pluginId);\n\t\t\tif (!handle) throw new Error(`Plugin testkit has no loaded plugin: ${pluginId}`);\n\t\t\treturn handle.api;\n\t\t},\n\t\trevoke(pluginId) {\n\t\t\tconst handle = handles.get(pluginId);\n\t\t\tif (!handle) throw new Error(`Plugin testkit has no loaded plugin: ${pluginId}`);\n\t\t\tif (handle.api.state) {\n\t\t\t\tconst entries = snapshot(handle.api.state.list());\n\t\t\t\trevokedState.set(pluginId, entries);\n\t\t\t\tretainedState.set(pluginId, entries);\n\t\t\t}\n\t\t\truntime.revokeAPI(handle.api);\n\t\t},\n\t\tinspect: () => runtime.inspect(),\n\t\tflushLifecycle: async () => {\n\t\t\twhile (pendingLifecycleDispatches.size > 0) {\n\t\t\t\tawait Promise.all([...pendingLifecycleDispatches]);\n\t\t\t}\n\t\t\tawait runtime.drainLifecycleDeliveries();\n\t\t},\n\t\ttranscript: () =>\n\t\t\tsnapshot(\n\t\t\t\ttranscriptValue({\n\t\t\t\t\tversion: 1 as const,\n\t\t\t\t\tmanifestRoot,\n\t\t\t\t\tmanifests: inputManifests,\n\t\t\t\t\tinputOrder,\n\t\t\t\t\tloadOrder,\n\t\t\t\t\tstate: stateTranscript(),\n\t\t\t\t\tstateMutations,\n\t\t\t\t\tstateWatchDeliveries,\n\t\t\t\t\tcapabilityCalls,\n\t\t\t\t\tlifecycleEvents,\n\t\t\t\t\tlifecycleFailures,\n\t\t\t\t\tlifecycleReports: runtime.inspect().lifecycleReports,\n\t\t\t\t\tinspector: runtime.inspect(),\n\t\t\t\t}) as PluginTestKitTranscript,\n\t\t\t),\n\t\tdispose: async () => {\n\t\t\tdisposePromise ??= (async () => {\n\t\t\t\tclosing = true;\n\t\t\t\tconst failures: unknown[] = [];\n\t\t\t\ttry {\n\t\t\t\t\tawait ready;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (!(error instanceof Error && error.message === \"Plugin testkit was disposed during startup\")) {\n\t\t\t\t\t\tfailures.push(error);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (const [pluginId, handle] of handles) captureState(pluginId, handle);\n\t\t\t\tfor (const handle of [...handles.values()].reverse()) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait handle.dispose();\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tfailures.push(error);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tawait runtime.disposeAll();\n\t\t\t\t} catch (error) {\n\t\t\t\t\tfailures.push(error);\n\t\t\t\t}\n\t\t\t\tif (failures.length === 1) throw failures[0];\n\t\t\t\tif (failures.length > 1) throw new AggregateError(failures, \"Plugin testkit disposal failed\");\n\t\t\t})();\n\t\t\treturn disposePromise;\n\t\t},\n\t};\n}\n\n/** Runs a fixture repeatedly and rejects on the first transcript divergence. */\nexport async function repeatPluginTestKit(\n\ttimes: number,\n\trun: () => Promise<PluginTestKitTranscript>,\n): Promise<PluginTestKitTranscript> {\n\tif (!Number.isSafeInteger(times) || times < 1)\n\t\tthrow new Error(\"Plugin testkit repeat count must be a positive integer\");\n\tlet baseline: PluginTestKitTranscript | undefined;\n\tfor (let index = 0; index < times; index += 1) {\n\t\tconst transcript = await run();\n\t\tif (baseline && canonicalJson(transcript) !== canonicalJson(baseline)) {\n\t\t\tthrow new Error(`Plugin testkit transcript diverged on run ${index + 1}`);\n\t\t}\n\t\tbaseline = transcript;\n\t}\n\treturn baseline!;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"plugin-testkit.js","sourceRoot":"","sources":["../../src/testing/plugin-testkit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,EAGN,oBAAoB,GACpB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAEN,uBAAuB,EACvB,4BAA4B,GAC5B,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAKN,+BAA+B,GAe/B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,CAAC,EAAE,MAAM,uBAAuB,CAAC;AAyJ1C,SAAS,QAAQ,CAAI,KAAQ,EAAK;IACjC,MAAM,KAAK,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;IACrC,MAAM,MAAM,GAAG,CAAC,SAAkB,EAAQ,EAAE,CAAC;QAC5C,IAAI,CAAC,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC;YAAE,OAAO;QACzF,KAAK,MAAM,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D,OAAO,QAAS,CAAC;AAAA,CACjB","sourcesContent":["import { installBootstrapLifecycle } from \"../core/extensions/bootstrap-lifecycle.ts\";\nimport {\n\ttype CapabilityPluginFactory,\n\ttype CapabilityPluginHandle,\n\tloadCapabilityPlugin,\n} from \"../core/extensions/capability-plugin.ts\";\nimport {\n\ttype CapabilityRuntime,\n\tcreateCapabilityRuntime,\n\tresolvePluginCapabilityOrder,\n} from \"../core/extensions/capability-runtime.ts\";\nimport {\n\ttype CapabilityAPI,\n\ttype CapabilityDirectoryAPI,\n\ttype CapabilityProviderHandler,\n\ttype DisposableRegistration,\n\tEXPERIMENTAL_PUBLIC_API_VERSION,\n\ttype HostCapabilities,\n\ttype LifecycleDispatchRequest,\n\ttype LifecycleDispatchResult,\n\ttype LifecycleEvent,\n\ttype LifecyclePhase,\n\ttype OperationHandle,\n\ttype OperationStatus,\n\ttype PluginCapabilityDeclaration,\n\ttype PluginManifest,\n\ttype RuntimeInspectorSnapshot,\n\ttype StateAPI,\n\ttype StateChange,\n\ttype StateEntry,\n\ttype StateSetOptions,\n} from \"../core/extensions/public-api.ts\";\nimport { t } from \"../core/i18n/index.ts\";\n\n/**\n * A deterministic, runtime-only fixture for experimental capability plugins.\n *\n * It deliberately does not create an AgentSession or a model provider. Tests\n * that need those integration points should use the existing session harness.\n */\nexport interface PluginTestKitPlugin {\n\treadonly manifest: PluginManifest;\n\treadonly factory: CapabilityPluginFactory;\n}\n\nexport interface PluginTestKitOptions {\n\treadonly plugins: readonly PluginTestKitPlugin[];\n\treadonly host?: Omit<HostCapabilities, \"apiVersion\">;\n\treadonly clock?: () => number;\n\t/** Injects stable runtime identifiers for deterministic transcript tests. */\n\treadonly idFactory?: (kind: string, sequence: number) => string;\n\t/** Logical root used to identify inline manifests without a host filesystem path. */\n\treadonly manifestRoot?: string;\n\t/**\n\t * Installs the bootstrap lifecycle catalog (host parity: the real session\n\t * host installs it) before the plugin load loop, so plugin factories can\n\t * registerObserve standard events. Off by default to keep existing\n\t * transcripts unchanged; the installed handle is disposed by\n\t * runtime.disposeAll() inside dispose().\n\t */\n\treadonly lifecycle?: boolean;\n}\n\nexport interface PluginTestKitManifestIdentity {\n\treadonly pluginId: string;\n\treadonly version: string;\n\treadonly entry: string;\n}\n\nexport interface PluginTestKitLifecycleEnvelope {\n\treadonly eventId: string;\n\treadonly type: string;\n\treadonly version: number;\n\treadonly phase: LifecycleEvent[\"phase\"];\n\treadonly deliveryId: string;\n\treadonly source: string;\n\treadonly operationId?: string;\n\treadonly correlationId?: string;\n\treadonly causationId?: string;\n\treadonly data: unknown;\n}\n\nexport interface PluginTestKitLifecycleFailureReport {\n\treadonly eventId: string;\n\treadonly type: string;\n\treadonly version: number;\n\treadonly phase: LifecyclePhase;\n\treadonly status: \"transform-failed\" | \"execute-failed\" | \"delivered\" | \"queued\";\n\treadonly attempted: number;\n\treadonly succeeded: number;\n\treadonly queued?: number;\n\treadonly failed: number;\n\treadonly failures: readonly {\n\t\treadonly pluginId: string;\n\t\treadonly registrationId: string;\n\t\treadonly kind: string;\n\t\treadonly error: unknown;\n\t}[];\n}\n\n/** A dispatch rejection is retained even when no event envelope was created. */\nexport interface PluginTestKitLifecycleFailure {\n\treadonly eventId: string | null;\n\treadonly type: string | null;\n\treadonly version: number | null;\n\treadonly phase: LifecyclePhase | null;\n\treadonly deliveryId: string | null;\n\treadonly source: string | null;\n\treadonly operationId?: string;\n\treadonly correlationId?: string;\n\treadonly causationId?: string;\n\treadonly data?: unknown;\n\treadonly status: \"rejected\" | \"cancelled\" | \"transform-failed\" | \"execute-failed\";\n\treadonly error: unknown;\n\treadonly report?: PluginTestKitLifecycleFailureReport;\n}\n\nexport interface PluginTestKitStateMutation {\n\treadonly pluginId: string;\n\treadonly action: \"set\" | \"delete\";\n\treadonly key: string;\n\treadonly status: \"committed\" | \"rejected\";\n\treadonly revision?: number;\n\treadonly expectedRevision?: number;\n\treadonly value?: unknown;\n\treadonly operationId?: string;\n\treadonly correlationId?: string;\n\treadonly error?: unknown;\n}\n\nexport interface PluginTestKitStateWatchDelivery {\n\treadonly pluginId: string;\n\treadonly watcherId: string;\n\treadonly key: string;\n\treadonly revision: number;\n\treadonly status: \"delivered\" | \"failed\";\n\treadonly value?: unknown;\n\treadonly operationId?: string;\n\treadonly correlationId?: string;\n\treadonly error?: unknown;\n}\n\nexport interface PluginTestKitCapabilityCall {\n\treadonly operationId: string | null;\n\treadonly callerPluginId: string;\n\treadonly providerPluginId: string;\n\treadonly capabilityId: string;\n\treadonly capabilityVersion: number;\n\treadonly capabilityKind: PluginCapabilityDeclaration[\"kind\"];\n\treadonly status: OperationStatus;\n\treadonly error?: unknown;\n}\n\nexport interface PluginTestKitTranscript {\n\treadonly version: 1;\n\treadonly manifestRoot: string;\n\treadonly manifests: readonly PluginTestKitManifestIdentity[];\n\treadonly inputOrder: readonly string[];\n\treadonly loadOrder: readonly string[];\n\treadonly state: readonly {\n\t\treadonly pluginId: string;\n\t\treadonly entries: readonly StateEntry[];\n\t}[];\n\treadonly stateMutations: readonly PluginTestKitStateMutation[];\n\treadonly stateWatchDeliveries: readonly PluginTestKitStateWatchDelivery[];\n\treadonly capabilityCalls: readonly PluginTestKitCapabilityCall[];\n\treadonly lifecycleEvents: readonly PluginTestKitLifecycleEnvelope[];\n\treadonly lifecycleFailures: readonly PluginTestKitLifecycleFailure[];\n\treadonly lifecycleReports: RuntimeInspectorSnapshot[\"lifecycleReports\"];\n\treadonly inspector: RuntimeInspectorSnapshot;\n}\n\nexport interface PluginTestKit {\n\treadonly runtime: CapabilityRuntime;\n\t/** Resolves after every manifest is topology-ordered and its factory has loaded. */\n\treadonly ready: Promise<void>;\n\tapi(pluginId: string): CapabilityAPI;\n\trevoke(pluginId: string): void;\n\tinspect(): RuntimeInspectorSnapshot;\n\ttranscript(): PluginTestKitTranscript;\n\t/** Waits for lifecycle facts initiated by runtime-owned detached operations. */\n\tflushLifecycle(): Promise<void>;\n\tdispose(): Promise<void>;\n}\n\nfunction snapshot<T>(value: T): T {\n\tconst clone = structuredClone(value);\n\tconst freeze = (candidate: unknown): void => {\n\t\tif (!candidate || typeof candidate !== \"object\" || ArrayBuffer.isView(candidate)) return;\n\t\tfor (const child of Object.values(candidate as Record<string, unknown>)) freeze(child);\n\t\tObject.freeze(candidate);\n\t};\n\tfreeze(clone);\n\treturn clone;\n}\n\nfunction transcriptValue(value: unknown, seen = new WeakSet<object>()): unknown {\n\tif (value === null || typeof value === \"string\" || typeof value === \"boolean\") return value;\n\tif (typeof value === \"number\") return Number.isFinite(value) ? value : String(value);\n\tif (typeof value === \"bigint\") return `${value}n`;\n\tif (value === undefined) return null;\n\tif (value instanceof Error) {\n\t\tif (seen.has(value)) return \"[Circular]\";\n\t\tseen.add(value);\n\t\tconst output: Record<string, unknown> = { name: value.name, message: value.message };\n\t\tconst code = (value as Error & { code?: unknown }).code;\n\t\tif (code !== undefined) output.code = transcriptValue(code, seen);\n\t\tconst cause = (value as Error & { cause?: unknown }).cause;\n\t\tif (cause !== undefined) output.cause = transcriptValue(cause, seen);\n\t\tfor (const key of Object.keys(value).sort()) {\n\t\t\tif (key === \"code\" || key === \"cause\") continue;\n\t\t\toutput[key] = transcriptValue((value as unknown as Record<string, unknown>)[key], seen);\n\t\t}\n\t\treturn output;\n\t}\n\tif (typeof value !== \"object\") return String(value);\n\tif (seen.has(value)) return \"[Circular]\";\n\tseen.add(value);\n\tif (Array.isArray(value)) return value.map((item) => transcriptValue(item, seen));\n\tconst output: Record<string, unknown> = {};\n\tfor (const key of Object.keys(value as Record<string, unknown>).sort()) {\n\t\toutput[key] = transcriptValue((value as Record<string, unknown>)[key], seen);\n\t}\n\treturn output;\n}\n\nfunction canonicalJson(value: unknown): string {\n\tconst serialized = JSON.stringify(transcriptValue(value));\n\t// v8 ignore next -- transcriptValue 已消毒全部值,JSON.stringify 不会返回 undefined\n\tif (serialized === undefined) throw new Error(\"Plugin testkit transcript is not JSON-serializable\");\n\treturn serialized;\n}\n\ntype PluginTestKitLifecycleReport = PluginTestKitLifecycleFailureReport;\n\nfunction lifecycleFailureReport(error: unknown): PluginTestKitLifecycleReport | undefined {\n\tif (!error || typeof error !== \"object\") return undefined;\n\tconst report = (error as { report?: unknown }).report;\n\tif (!report || typeof report !== \"object\") return undefined;\n\tconst candidate = report as RuntimeInspectorSnapshot[\"lifecycleReports\"][number];\n\t// v8 ignore next -- report 由 runtime 构造、形状恒满足;此处仅防御伪造的 report\n\tif (\n\t\ttypeof candidate.eventId !== \"string\" ||\n\t\ttypeof candidate.type !== \"string\" ||\n\t\t!Number.isSafeInteger(candidate.version) ||\n\t\t(candidate.phase !== \"raw\" && candidate.phase !== \"candidate\" && candidate.phase !== \"committed\") ||\n\t\t(candidate.status !== \"transform-failed\" &&\n\t\t\tcandidate.status !== \"execute-failed\" &&\n\t\t\tcandidate.status !== \"delivered\") ||\n\t\t!Array.isArray(candidate.failures)\n\t) {\n\t\treturn undefined;\n\t}\n\treturn {\n\t\teventId: candidate.eventId,\n\t\ttype: candidate.type,\n\t\tversion: candidate.version,\n\t\tphase: candidate.phase,\n\t\tstatus: candidate.status,\n\t\tattempted: candidate.attempted,\n\t\tsucceeded: candidate.succeeded,\n\t\tfailed: candidate.failed,\n\t\tfailures: candidate.failures.map((failure) => ({\n\t\t\tpluginId: failure.pluginId,\n\t\t\tregistrationId: failure.registrationId,\n\t\t\tkind: failure.kind,\n\t\t\terror: transcriptValue(failure.error),\n\t\t})),\n\t};\n}\n\nfunction defaultHost(): HostCapabilities {\n\treturn {\n\t\tapiVersion: EXPERIMENTAL_PUBLIC_API_VERSION,\n\t\tmode: \"full-control\",\n\t\tfeatures: [\"logger-v1\", \"diagnostics-v1\", \"plugin-state-v1\", \"runtime-inspector-v1\"],\n\t\ttransports: [\"in-process\"],\n\t};\n}\n\nconst DEFAULT_MANIFEST_ROOT = \"<plugin-testkit>\";\n\ninterface MutablePluginTestKitStateMutation {\n\tpluginId: string;\n\taction: \"set\" | \"delete\";\n\tkey: string;\n\tstatus: \"committed\" | \"rejected\";\n\trevision?: number;\n\texpectedRevision?: number;\n\tvalue?: unknown;\n\toperationId?: string;\n\tcorrelationId?: string;\n\terror?: unknown;\n}\n\ninterface MutablePluginTestKitStateWatchDelivery {\n\tpluginId: string;\n\twatcherId: string;\n\tkey: string;\n\trevision: number;\n\tstatus: \"delivered\" | \"failed\";\n\tvalue?: unknown;\n\toperationId?: string;\n\tcorrelationId?: string;\n\terror?: unknown;\n}\n\ninterface MutablePluginTestKitCapabilityCall {\n\toperationId: string | null;\n\tcallerPluginId: string;\n\tproviderPluginId: string;\n\tcapabilityId: string;\n\tcapabilityVersion: number;\n\tcapabilityKind: PluginCapabilityDeclaration[\"kind\"];\n\tstatus: OperationStatus;\n\terror?: unknown;\n}\n\ninterface MutablePluginTestKitLifecycleFailure {\n\teventId: string | null;\n\ttype: string | null;\n\tversion: number | null;\n\tphase: LifecyclePhase | null;\n\tdeliveryId: string | null;\n\tsource: string | null;\n\toperationId?: string;\n\tcorrelationId?: string;\n\tcausationId?: string;\n\tdata?: unknown;\n\tstatus: \"rejected\" | \"cancelled\" | \"transform-failed\" | \"execute-failed\";\n\terror: unknown;\n\treport?: PluginTestKitLifecycleFailureReport;\n}\n\n/** Create a runtime-only fixture with deterministic topology and teardown. */\nexport function createPluginTestKit(options: PluginTestKitOptions): PluginTestKit {\n\tconst manifestRoot = options.manifestRoot ?? DEFAULT_MANIFEST_ROOT;\n\tif (typeof manifestRoot !== \"string\" || !manifestRoot.trim()) {\n\t\tthrow new Error(t(\"Plugin testkit manifestRoot must be a non-empty string\"));\n\t}\n\tconst inputPlugins = options.plugins.map((plugin) => ({\n\t\tmanifest: snapshot(plugin.manifest),\n\t\tfactory: plugin.factory,\n\t}));\n\tconst suppliedHost = options.host;\n\tconst host: HostCapabilities = {\n\t\t...defaultHost(),\n\t\t...suppliedHost,\n\t\tfeatures: suppliedHost?.features ?? defaultHost().features,\n\t\ttransports: suppliedHost?.transports ?? defaultHost().transports,\n\t};\n\tconst pluginsByManifest = new Map(inputPlugins.map((plugin) => [plugin.manifest, plugin]));\n\tconst handles = new Map<string, CapabilityPluginHandle>();\n\tconst revokedState = new Map<string, readonly StateEntry[]>();\n\tconst retainedState = new Map<string, readonly StateEntry[]>();\n\tconst loadOrder: string[] = [];\n\tconst stateMutations: MutablePluginTestKitStateMutation[] = [];\n\tconst stateWatchDeliveries: MutablePluginTestKitStateWatchDelivery[] = [];\n\tconst capabilityCalls: MutablePluginTestKitCapabilityCall[] = [];\n\tconst lifecycleEvents: PluginTestKitLifecycleEnvelope[] = [];\n\tconst lifecycleFailures: MutablePluginTestKitLifecycleFailure[] = [];\n\tconst pendingLifecycleDispatches = new Set<Promise<void>>();\n\tlet disposePromise: Promise<void> | undefined;\n\tconst recordLifecycleDispatch = (\n\t\trequest: LifecycleDispatchRequest<unknown>,\n\t\tsettled: Promise<LifecycleDispatchResult<unknown>>,\n\t): void => {\n\t\tconst recorded = settled.then(\n\t\t\t(result) => {\n\t\t\t\tlifecycleEvents.push(\n\t\t\t\t\tsnapshot({\n\t\t\t\t\t\teventId: result.event.id,\n\t\t\t\t\t\ttype: result.event.type,\n\t\t\t\t\t\tversion: result.event.version,\n\t\t\t\t\t\tphase: result.event.phase,\n\t\t\t\t\t\tdeliveryId: result.event.deliveryId,\n\t\t\t\t\t\tsource: result.event.source,\n\t\t\t\t\t\t...(result.event.operationId === undefined ? {} : { operationId: result.event.operationId }),\n\t\t\t\t\t\t...(result.event.correlationId === undefined ? {} : { correlationId: result.event.correlationId }),\n\t\t\t\t\t\t...(result.event.causationId === undefined ? {} : { causationId: result.event.causationId }),\n\t\t\t\t\t\tdata: transcriptValue(result.event.data),\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t},\n\t\t\t(error) => {\n\t\t\t\tconst requestObject =\n\t\t\t\t\trequest && typeof request === \"object\" ? (request as unknown as Record<string, unknown>) : undefined;\n\t\t\t\tconst report = lifecycleFailureReport(error);\n\t\t\t\tconst rawPhase = requestObject?.phase;\n\t\t\t\tconst phase: LifecyclePhase | null =\n\t\t\t\t\trawPhase === \"raw\" || rawPhase === \"candidate\" || rawPhase === \"committed\" ? rawPhase : null;\n\t\t\t\tconst rawSource = requestObject?.source;\n\t\t\t\tconst source =\n\t\t\t\t\trawSource === undefined\n\t\t\t\t\t\t? requestObject === undefined\n\t\t\t\t\t\t\t? null\n\t\t\t\t\t\t\t: \"host\"\n\t\t\t\t\t\t: typeof rawSource === \"string\"\n\t\t\t\t\t\t\t? rawSource\n\t\t\t\t\t\t\t: null;\n\t\t\t\tconst rawVersion = requestObject?.version;\n\t\t\t\tconst version = typeof rawVersion === \"number\" && Number.isSafeInteger(rawVersion) ? rawVersion : null;\n\t\t\t\tconst failure: MutablePluginTestKitLifecycleFailure = {\n\t\t\t\t\teventId: report?.eventId ?? null,\n\t\t\t\t\ttype: typeof requestObject?.type === \"string\" ? requestObject.type : null,\n\t\t\t\t\tversion,\n\t\t\t\t\tphase,\n\t\t\t\t\tdeliveryId: null,\n\t\t\t\t\tsource,\n\t\t\t\t\t...(typeof requestObject?.operationId === \"string\" ? { operationId: requestObject.operationId } : {}),\n\t\t\t\t\t...(typeof requestObject?.correlationId === \"string\"\n\t\t\t\t\t\t? { correlationId: requestObject.correlationId }\n\t\t\t\t\t\t: {}),\n\t\t\t\t\t...(typeof requestObject?.causationId === \"string\" ? { causationId: requestObject.causationId } : {}),\n\t\t\t\t\t...(requestObject !== undefined && \"data\" in requestObject\n\t\t\t\t\t\t? { data: transcriptValue(requestObject.data) }\n\t\t\t\t\t\t: {}),\n\t\t\t\t\tstatus:\n\t\t\t\t\t\treport?.status === \"transform-failed\" || report?.status === \"execute-failed\"\n\t\t\t\t\t\t\t? report.status\n\t\t\t\t\t\t\t: requestObject?.signal instanceof AbortSignal && requestObject.signal.aborted\n\t\t\t\t\t\t\t\t? \"cancelled\"\n\t\t\t\t\t\t\t\t: \"rejected\",\n\t\t\t\t\terror: transcriptValue(error),\n\t\t\t\t\t...(report === undefined ? {} : { report }),\n\t\t\t\t};\n\t\t\t\tlifecycleFailures.push(snapshot(failure));\n\t\t\t},\n\t\t);\n\t\tpendingLifecycleDispatches.add(recorded);\n\t\tvoid recorded.then(() => pendingLifecycleDispatches.delete(recorded));\n\t};\n\tconst runtime = createCapabilityRuntime(host, {\n\t\tclock: options.clock ?? (() => 0),\n\t\tidFactory: options.idFactory ?? ((kind, sequence) => `testkit:${kind}:${sequence}`),\n\t\tonLifecycleDispatch: recordLifecycleDispatch,\n\t});\n\t// Must run before the ready loop: plugin factories registerObserve during load.\n\tif (options.lifecycle === true) installBootstrapLifecycle(runtime);\n\n\tconst inputManifests = inputPlugins.map(({ manifest }) => ({\n\t\tpluginId: manifest.id,\n\t\tversion: manifest.version,\n\t\tentry: manifest.entry,\n\t}));\n\tconst inputOrder = inputPlugins.map(({ manifest }) => manifest.id);\n\tconst wrappedToRawAPI = new WeakMap<CapabilityAPI, CapabilityAPI>();\n\tconst wrapStateAPI = (pluginId: string, state: StateAPI): StateAPI => {\n\t\tconst operationMetadata = (options?: StateSetOptions) => ({\n\t\t\t...(options?.expectedRevision === undefined ? {} : { expectedRevision: options.expectedRevision }),\n\t\t\t...(options?.operationId === undefined ? {} : { operationId: options.operationId }),\n\t\t\t...(options?.correlationId === undefined ? {} : { correlationId: options.correlationId }),\n\t\t});\n\t\tconst recordMutation = (\n\t\t\taction: \"set\" | \"delete\",\n\t\t\tkey: string,\n\t\t\tmetadata: ReturnType<typeof operationMetadata>,\n\t\t\tresult: { status: \"committed\"; revision: number; value?: unknown } | { status: \"rejected\"; error: unknown },\n\t\t): void => {\n\t\t\tstateMutations.push({\n\t\t\t\tpluginId,\n\t\t\t\taction,\n\t\t\t\tkey,\n\t\t\t\t...metadata,\n\t\t\t\t...result,\n\t\t\t});\n\t\t};\n\t\treturn Object.freeze({\n\t\t\tget: (key: string) => state.get(key),\n\t\t\tset: (key: string, value: Parameters<StateAPI[\"set\"]>[1], options?: StateSetOptions) => {\n\t\t\t\tconst metadata = operationMetadata(options);\n\t\t\t\ttry {\n\t\t\t\t\tconst revision = state.set(key, value, options);\n\t\t\t\t\trecordMutation(\"set\", key, metadata, {\n\t\t\t\t\t\tstatus: \"committed\",\n\t\t\t\t\t\trevision,\n\t\t\t\t\t\tvalue: transcriptValue(value),\n\t\t\t\t\t});\n\t\t\t\t\treturn revision;\n\t\t\t\t} catch (error) {\n\t\t\t\t\trecordMutation(\"set\", key, metadata, { status: \"rejected\", error: transcriptValue(error) });\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t},\n\t\t\tdelete: (key: string, options?: StateSetOptions) => {\n\t\t\t\tconst metadata = operationMetadata(options);\n\t\t\t\ttry {\n\t\t\t\t\tconst revision = state.delete(key, options);\n\t\t\t\t\trecordMutation(\"delete\", key, metadata, { status: \"committed\", revision });\n\t\t\t\t\treturn revision;\n\t\t\t\t} catch (error) {\n\t\t\t\t\trecordMutation(\"delete\", key, metadata, { status: \"rejected\", error: transcriptValue(error) });\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t},\n\t\t\tlist: (prefix?: string) => state.list(prefix),\n\t\t\twatch: (prefix: string | undefined, handler: (change: StateChange) => void) => {\n\t\t\t\tlet watcherId = \"<pending>\";\n\t\t\t\tconst registration = state.watch(prefix, (change) => {\n\t\t\t\t\tconst delivery: MutablePluginTestKitStateWatchDelivery = {\n\t\t\t\t\t\tpluginId,\n\t\t\t\t\t\twatcherId,\n\t\t\t\t\t\tkey: change.key,\n\t\t\t\t\t\trevision: change.revision,\n\t\t\t\t\t\tstatus: \"delivered\",\n\t\t\t\t\t\t...(change.value === undefined ? {} : { value: transcriptValue(change.value) }),\n\t\t\t\t\t\t...(change.operationId === undefined ? {} : { operationId: change.operationId }),\n\t\t\t\t\t\t...(change.correlationId === undefined ? {} : { correlationId: change.correlationId }),\n\t\t\t\t\t};\n\t\t\t\t\tstateWatchDeliveries.push(delivery);\n\t\t\t\t\ttry {\n\t\t\t\t\t\thandler(change);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tdelivery.status = \"failed\";\n\t\t\t\t\t\tdelivery.error = transcriptValue(error);\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\twatcherId = registration.id;\n\t\t\t\treturn registration;\n\t\t\t},\n\t\t});\n\t};\n\tconst wrapCapabilityDirectory = (\n\t\tcallerPluginId: string,\n\t\tcapabilities: CapabilityDirectoryAPI,\n\t): CapabilityDirectoryAPI =>\n\t\tObject.freeze({\n\t\t\tprovide: <TInput = unknown, TResult = unknown>(\n\t\t\t\tdeclaration: PluginCapabilityDeclaration,\n\t\t\t\thandler: CapabilityProviderHandler<TInput, TResult>,\n\t\t\t): DisposableRegistration => capabilities.provide(declaration, handler),\n\t\t\trequire: <TResult = unknown>(id: string, requireOptions?: { version?: number }) => {\n\t\t\t\tconst handle = capabilities.require<TResult>(id, requireOptions);\n\t\t\t\treturn Object.freeze({\n\t\t\t\t\tdeclaration: handle.declaration,\n\t\t\t\t\towner: handle.owner,\n\t\t\t\t\tcall: (input: unknown, callOptions?: { signal?: AbortSignal }): OperationHandle<TResult> => {\n\t\t\t\t\t\tlet operation: OperationHandle<TResult>;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\toperation = handle.call(input, callOptions);\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tcapabilityCalls.push({\n\t\t\t\t\t\t\t\toperationId: null,\n\t\t\t\t\t\t\t\tcallerPluginId,\n\t\t\t\t\t\t\t\tproviderPluginId: handle.owner,\n\t\t\t\t\t\t\t\tcapabilityId: handle.declaration.id,\n\t\t\t\t\t\t\t\tcapabilityVersion: handle.declaration.version,\n\t\t\t\t\t\t\t\tcapabilityKind: handle.declaration.kind,\n\t\t\t\t\t\t\t\tstatus: \"failed\",\n\t\t\t\t\t\t\t\terror: transcriptValue(error),\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst record: MutablePluginTestKitCapabilityCall = {\n\t\t\t\t\t\t\toperationId: operation.id,\n\t\t\t\t\t\t\tcallerPluginId,\n\t\t\t\t\t\t\tproviderPluginId: handle.owner,\n\t\t\t\t\t\t\tcapabilityId: handle.declaration.id,\n\t\t\t\t\t\t\tcapabilityVersion: handle.declaration.version,\n\t\t\t\t\t\t\tcapabilityKind: handle.declaration.kind,\n\t\t\t\t\t\t\tstatus: operation.status(),\n\t\t\t\t\t\t};\n\t\t\t\t\t\tcapabilityCalls.push(record);\n\t\t\t\t\t\tvoid operation.result.then(\n\t\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t\trecord.status = operation.status();\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t(error) => {\n\t\t\t\t\t\t\t\trecord.status = operation.status();\n\t\t\t\t\t\t\t\trecord.error = transcriptValue(error);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn operation;\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t},\n\t\t\tlist: (listOptions?: { kind?: PluginCapabilityDeclaration[\"kind\"] }) => capabilities.list(listOptions),\n\t\t});\n\tconst originalCreateAPI = runtime.createAPI.bind(runtime);\n\tconst originalRevokeAPI = runtime.revokeAPI.bind(runtime);\n\truntime.createAPI = (manifest) => {\n\t\tconst rawAPI = originalCreateAPI(manifest);\n\t\tconst wrappedAPI = Object.freeze({\n\t\t\t...rawAPI,\n\t\t\tcapabilities: wrapCapabilityDirectory(rawAPI.manifest.id, rawAPI.capabilities),\n\t\t\t...(rawAPI.state === undefined ? {} : { state: wrapStateAPI(rawAPI.manifest.id, rawAPI.state) }),\n\t\t});\n\t\twrappedToRawAPI.set(wrappedAPI, rawAPI);\n\t\treturn wrappedAPI;\n\t};\n\truntime.revokeAPI = (api) => {\n\t\t// v8 ignore next -- 所有 API 均经包装后的 createAPI 创建,映射必命中\n\t\tconst rawAPI = wrappedToRawAPI.get(api) ?? api;\n\t\tfor (const [pluginId, handle] of handles) {\n\t\t\tif (handle.api === api || handle.api === rawAPI) captureState(pluginId, handle);\n\t\t}\n\t\toriginalRevokeAPI(rawAPI);\n\t};\n\n\tconst captureState = (pluginId: string, handle: CapabilityPluginHandle): void => {\n\t\tif (retainedState.has(pluginId) || revokedState.has(pluginId)) return;\n\t\tretainedState.set(pluginId, snapshot(handle.api.state?.list() ?? []));\n\t};\n\tconst stateTranscript = (): readonly { readonly pluginId: string; readonly entries: readonly StateEntry[] }[] =>\n\t\t[...handles.entries()].map(([pluginId, handle]) => {\n\t\t\treturn {\n\t\t\t\tpluginId,\n\t\t\t\tentries: retainedState.get(pluginId) ?? snapshot(handle.api.state?.list() ?? []),\n\t\t\t};\n\t\t});\n\n\tlet closing = false;\n\tconst ready = (async () => {\n\t\ttry {\n\t\t\tconst ordered = resolvePluginCapabilityOrder(inputPlugins.map((plugin) => plugin.manifest));\n\t\t\tfor (const manifest of ordered) {\n\t\t\t\tif (closing) throw new Error(\"Plugin testkit was disposed during startup\");\n\t\t\t\tconst plugin = pluginsByManifest.get(manifest);\n\t\t\t\t// v8 ignore next -- plugins 数组同时供给加载顺序与 factory 映射,必可解析\n\t\t\t\tif (!plugin) throw new Error(`Plugin testkit cannot resolve factory: ${manifest.id}`);\n\t\t\t\tconst handle = await loadCapabilityPlugin(runtime, plugin.manifest, plugin.factory);\n\t\t\t\thandles.set(manifest.id, handle);\n\t\t\t\tloadOrder.push(manifest.id);\n\t\t\t}\n\t\t} catch (startupError) {\n\t\t\tconst failures: unknown[] = [startupError];\n\t\t\tfor (const handle of [...handles.values()].reverse()) {\n\t\t\t\ttry {\n\t\t\t\t\tawait handle.dispose();\n\t\t\t\t} catch (error) {\n\t\t\t\t\tfailures.push(error);\n\t\t\t\t}\n\t\t\t}\n\t\t\thandles.clear();\n\t\t\ttry {\n\t\t\t\tawait runtime.disposeAll();\n\t\t\t} catch (error) {\n\t\t\t\tfailures.push(error);\n\t\t\t}\n\t\t\tif (failures.length > 1) throw new AggregateError(failures, \"Plugin testkit startup rollback failed\");\n\t\t\tthrow startupError;\n\t\t}\n\t})();\n\n\treturn {\n\t\truntime,\n\t\tready,\n\t\tapi(pluginId) {\n\t\t\tconst handle = handles.get(pluginId);\n\t\t\tif (!handle) throw new Error(`Plugin testkit has no loaded plugin: ${pluginId}`);\n\t\t\treturn handle.api;\n\t\t},\n\t\trevoke(pluginId) {\n\t\t\tconst handle = handles.get(pluginId);\n\t\t\tif (!handle) throw new Error(`Plugin testkit has no loaded plugin: ${pluginId}`);\n\t\t\tif (handle.api.state) {\n\t\t\t\tconst entries = snapshot(handle.api.state.list());\n\t\t\t\trevokedState.set(pluginId, entries);\n\t\t\t\tretainedState.set(pluginId, entries);\n\t\t\t}\n\t\t\truntime.revokeAPI(handle.api);\n\t\t},\n\t\tinspect: () => runtime.inspect(),\n\t\tflushLifecycle: async () => {\n\t\t\twhile (pendingLifecycleDispatches.size > 0) {\n\t\t\t\tawait Promise.all([...pendingLifecycleDispatches]);\n\t\t\t}\n\t\t\tawait runtime.drainLifecycleDeliveries();\n\t\t},\n\t\ttranscript: () =>\n\t\t\tsnapshot(\n\t\t\t\ttranscriptValue({\n\t\t\t\t\tversion: 1 as const,\n\t\t\t\t\tmanifestRoot,\n\t\t\t\t\tmanifests: inputManifests,\n\t\t\t\t\tinputOrder,\n\t\t\t\t\tloadOrder,\n\t\t\t\t\tstate: stateTranscript(),\n\t\t\t\t\tstateMutations,\n\t\t\t\t\tstateWatchDeliveries,\n\t\t\t\t\tcapabilityCalls,\n\t\t\t\t\tlifecycleEvents,\n\t\t\t\t\tlifecycleFailures,\n\t\t\t\t\tlifecycleReports: runtime.inspect().lifecycleReports,\n\t\t\t\t\tinspector: runtime.inspect(),\n\t\t\t\t}) as PluginTestKitTranscript,\n\t\t\t),\n\t\tdispose: async () => {\n\t\t\tdisposePromise ??= (async () => {\n\t\t\t\tclosing = true;\n\t\t\t\tconst failures: unknown[] = [];\n\t\t\t\ttry {\n\t\t\t\t\tawait ready;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (!(error instanceof Error && error.message === \"Plugin testkit was disposed during startup\")) {\n\t\t\t\t\t\tfailures.push(error);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (const [pluginId, handle] of handles) captureState(pluginId, handle);\n\t\t\t\tfor (const handle of [...handles.values()].reverse()) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait handle.dispose();\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tfailures.push(error);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tawait runtime.disposeAll();\n\t\t\t\t} catch (error) {\n\t\t\t\t\tfailures.push(error);\n\t\t\t\t}\n\t\t\t\tif (failures.length === 1) throw failures[0];\n\t\t\t\tif (failures.length > 1) throw new AggregateError(failures, \"Plugin testkit disposal failed\");\n\t\t\t})();\n\t\t\treturn disposePromise;\n\t\t},\n\t};\n}\n\n/** Runs a fixture repeatedly and rejects on the first transcript divergence. */\nexport async function repeatPluginTestKit(\n\ttimes: number,\n\trun: () => Promise<PluginTestKitTranscript>,\n): Promise<PluginTestKitTranscript> {\n\tif (!Number.isSafeInteger(times) || times < 1)\n\t\tthrow new Error(t(\"Plugin testkit repeat count must be a positive integer\"));\n\tlet baseline: PluginTestKitTranscript | undefined;\n\tfor (let index = 0; index < times; index += 1) {\n\t\tconst transcript = await run();\n\t\tif (baseline && canonicalJson(transcript) !== canonicalJson(baseline)) {\n\t\t\tthrow new Error(t(\"Plugin testkit transcript diverged on run {run}\", { run: index + 1 }));\n\t\t}\n\t\tbaseline = transcript;\n\t}\n\treturn baseline!;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-delivery-queue.d.ts","sourceRoot":"","sources":["../../src/testing/runtime-delivery-queue.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runtime-delivery-queue.d.ts","sourceRoot":"","sources":["../../src/testing/runtime-delivery-queue.ts"],"names":[],"mappings":"AAEA,4EAA4E;AAC5E,eAAO,MAAM,u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CACD;AAeD;;;;;;;;;;;;GAYG;AACH,wBAAgB,8BAA8B,CAAC,CAAC,EAC/C,OAAO,EAAE,+BAA+B,CAAC,CAAC,CAAC,GACzC,wBAAwB,CAAC,CAAC,CAAC,CAsH7B","sourcesContent":["import { t } from \"../core/i18n/index.ts\";\n\n/** Stable error code required by the model.stream backpressure contract. */\nexport const MODEL_STREAM_BACKPRESSURE_OVERFLOW_CODE = \"model_stream_backpressure_overflow\" as const;\n\nexport type RuntimeOnlyDeliveryQueueStatus = \"active\" | \"overflowed\" | \"closed\";\n\nexport interface RuntimeOnlyDeliveryQueueSnapshot {\n\treadonly status: RuntimeOnlyDeliveryQueueStatus;\n\treadonly capacity: number;\n\t/** Weight of in-flight and queued values that have not finished delivery. */\n\treadonly pending: number;\n\treadonly accepted: number;\n\treadonly delivered: number;\n\treadonly rejected: number;\n}\n\nexport interface RuntimeOnlyDeliveryQueueOptions<T> {\n\t/** Maximum pending weight for this subscription. */\n\treadonly capacity: number;\n\t/** Defaults to one event per value. */\n\treadonly measure?: (value: T) => number;\n\treadonly deliver: (value: T) => void | Promise<void>;\n}\n\nexport interface RuntimeOnlyDeliveryQueue<T> {\n\tenqueue(value: T): Promise<void>;\n\tdrain(): Promise<void>;\n\tclose(): void;\n\tsnapshot(): RuntimeOnlyDeliveryQueueSnapshot;\n}\n\nexport class RuntimeOnlyBackpressureOverflowError extends Error {\n\treadonly code = MODEL_STREAM_BACKPRESSURE_OVERFLOW_CODE;\n\treadonly capacity: number;\n\treadonly pending: number;\n\treadonly attempted: number;\n\n\tconstructor(capacity: number, pending: number, attempted: number) {\n\t\tsuper(\n\t\t\t`Runtime-only delivery queue overflow: pending ${pending} + attempted ${attempted} exceeds capacity ${capacity}`,\n\t\t);\n\t\tthis.name = \"RuntimeOnlyBackpressureOverflowError\";\n\t\tthis.capacity = capacity;\n\t\tthis.pending = pending;\n\t\tthis.attempted = attempted;\n\t}\n}\n\ninterface QueueEntry<T> {\n\treadonly value: T;\n\treadonly weight: number;\n\treadonly resolve: () => void;\n\treadonly reject: (error: unknown) => void;\n}\n\nfunction assertPositiveSafeInteger(value: number, name: string): void {\n\tif (!Number.isSafeInteger(value) || value < 1) {\n\t\tthrow new Error(t(\"Runtime-only delivery queue {name} must be a positive safe integer\", { name }));\n\t}\n}\n\n/**\n * Creates a deterministic host-side subscription queue for runtime-only tests.\n *\n * Overflow rejects only the new enqueue, permanently terminates this queue,\n * and leaves already accepted values in order for delivery. Other queues are\n * independent and are not affected.\n *\n * Test-only divergence from the production lifecycle delivery queue: a handler\n * failure closes this whole queue and rejects every pending value with the\n * same error, while the production queue isolates the failure to that single\n * delivery and keeps accepting. Tests that need production semantics must use\n * the production runtime, not this fixture.\n */\nexport function createRuntimeOnlyDeliveryQueue<T>(\n\toptions: RuntimeOnlyDeliveryQueueOptions<T>,\n): RuntimeOnlyDeliveryQueue<T> {\n\tassertPositiveSafeInteger(options.capacity, \"capacity\");\n\tconst measure = options.measure ?? (() => 1);\n\tconst entries: QueueEntry<T>[] = [];\n\tlet status: RuntimeOnlyDeliveryQueueStatus = \"active\";\n\tlet pending = 0;\n\tlet accepted = 0;\n\tlet delivered = 0;\n\tlet rejected = 0;\n\tlet processing = false;\n\tlet drainPromise: Promise<void> | undefined;\n\tlet resolveDrain: (() => void) | undefined;\n\n\tconst ensureDrainPromise = (): Promise<void> => {\n\t\tif (drainPromise === undefined) {\n\t\t\tdrainPromise = new Promise<void>((resolve) => {\n\t\t\t\tresolveDrain = resolve;\n\t\t\t});\n\t\t}\n\t\treturn drainPromise;\n\t};\n\n\tconst settleDrainIfIdle = (): void => {\n\t\tif (processing || entries.length > 0) return;\n\t\tresolveDrain?.();\n\t\tdrainPromise = undefined;\n\t\tresolveDrain = undefined;\n\t};\n\n\tconst pump = async (): Promise<void> => {\n\t\tif (processing) return;\n\t\tprocessing = true;\n\t\ttry {\n\t\t\twhile (entries.length > 0) {\n\t\t\t\tconst entry = entries.shift();\n\t\t\t\t// v8 ignore next -- 循环条件保证 shift 必有元素\n\t\t\t\tif (entry === undefined) continue;\n\t\t\t\ttry {\n\t\t\t\t\tawait options.deliver(entry.value);\n\t\t\t\t\tdelivered += 1;\n\t\t\t\t\tentry.resolve();\n\t\t\t\t} catch (error) {\n\t\t\t\t\tstatus = \"closed\";\n\t\t\t\t\trejected += 1;\n\t\t\t\t\tentry.reject(error);\n\t\t\t\t\twhile (entries.length > 0) {\n\t\t\t\t\t\tconst pendingEntry = entries.shift();\n\t\t\t\t\t\t// v8 ignore next -- 循环条件保证 shift 必有元素\n\t\t\t\t\t\tif (pendingEntry === undefined) continue;\n\t\t\t\t\t\tpending -= pendingEntry.weight;\n\t\t\t\t\t\trejected += 1;\n\t\t\t\t\t\tpendingEntry.reject(error);\n\t\t\t\t\t}\n\t\t\t\t} finally {\n\t\t\t\t\tpending -= entry.weight;\n\t\t\t\t}\n\t\t\t\tif (status === \"closed\") break;\n\t\t\t}\n\t\t} finally {\n\t\t\tprocessing = false;\n\t\t\tsettleDrainIfIdle();\n\t\t}\n\t};\n\n\tconst enqueue = (value: T): Promise<void> => {\n\t\tif (status !== \"active\") {\n\t\t\trejected += 1;\n\t\t\tif (status === \"overflowed\") {\n\t\t\t\treturn Promise.reject(new RuntimeOnlyBackpressureOverflowError(options.capacity, pending, 0));\n\t\t\t}\n\t\t\treturn Promise.reject(new Error(`Runtime-only delivery queue is ${status}`));\n\t\t}\n\t\tconst weight = measure(value);\n\t\tassertPositiveSafeInteger(weight, \"measure result\");\n\t\tif (pending + weight > options.capacity) {\n\t\t\tstatus = \"overflowed\";\n\t\t\trejected += 1;\n\t\t\treturn Promise.reject(new RuntimeOnlyBackpressureOverflowError(options.capacity, pending, weight));\n\t\t}\n\t\taccepted += 1;\n\t\tpending += weight;\n\t\tconst result = new Promise<void>((resolve, reject) => {\n\t\t\tentries.push({ value, weight, resolve, reject });\n\t\t});\n\t\tensureDrainPromise();\n\t\tvoid pump();\n\t\treturn result;\n\t};\n\n\treturn {\n\t\tenqueue,\n\t\tdrain: () => {\n\t\t\tif (!processing && entries.length === 0) return Promise.resolve();\n\t\t\treturn ensureDrainPromise();\n\t\t},\n\t\tclose: () => {\n\t\t\tif (status === \"closed\") return;\n\t\t\tstatus = \"closed\";\n\t\t\twhile (entries.length > 0) {\n\t\t\t\tconst entry = entries.shift();\n\t\t\t\t// v8 ignore next -- 循环条件保证 shift 必有元素\n\t\t\t\tif (entry === undefined) continue;\n\t\t\t\tpending -= entry.weight;\n\t\t\t\trejected += 1;\n\t\t\t\tentry.reject(new Error(\"Runtime-only delivery queue was closed\"));\n\t\t\t}\n\t\t\tsettleDrainIfIdle();\n\t\t},\n\t\tsnapshot: () =>\n\t\t\tObject.freeze({\n\t\t\t\tstatus,\n\t\t\t\tcapacity: options.capacity,\n\t\t\t\tpending,\n\t\t\t\taccepted,\n\t\t\t\tdelivered,\n\t\t\t\trejected,\n\t\t\t}),\n\t};\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { t } from "../core/i18n/index.js";
|
|
1
2
|
/** Stable error code required by the model.stream backpressure contract. */
|
|
2
3
|
export const MODEL_STREAM_BACKPRESSURE_OVERFLOW_CODE = "model_stream_backpressure_overflow";
|
|
3
4
|
export class RuntimeOnlyBackpressureOverflowError extends Error {
|
|
@@ -15,7 +16,7 @@ export class RuntimeOnlyBackpressureOverflowError extends Error {
|
|
|
15
16
|
}
|
|
16
17
|
function assertPositiveSafeInteger(value, name) {
|
|
17
18
|
if (!Number.isSafeInteger(value) || value < 1) {
|
|
18
|
-
throw new Error(
|
|
19
|
+
throw new Error(t("Runtime-only delivery queue {name} must be a positive safe integer", { name }));
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
22
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-delivery-queue.js","sourceRoot":"","sources":["../../src/testing/runtime-delivery-queue.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,MAAM,CAAC,MAAM,uCAAuC,GAAG,oCAA6C,CAA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port const MODEL_STREAM_BACKPRESSURE_OVERFLOW_CODE = \"model_stream_backpressure_overflow\" as const;\n\nexport type RuntimeOnlyDeliveryQueueStatus = \"active\" | \"overflowed\" | \"closed\";\n\nexport interface RuntimeOnlyDeliveryQueueSnapshot {\n\treadonly status: RuntimeOnlyDeliveryQueueStatus;\n\treadonly capacity: number;\n\t/** Weight of in-flight and queued values that have not finished delivery. */\n\treadonly pending: number;\n\treadonly accepted: number;\n\treadonly delivered: number;\n\treadonly rejected: number;\n}\n\nexport interface RuntimeOnlyDeliveryQueueOptions<T> {\n\t/** Maximum pending weight for this subscription. */\n\treadonly capacity: number;\n\t/** Defaults to one event per value. */\n\treadonly measure?: (value: T) => number;\n\treadonly deliver: (value: T) => void | Promise<void>;\n}\n\nexport interface RuntimeOnlyDeliveryQueue<T> {\n\tenqueue(value: T): Promise<void>;\n\tdrain(): Promise<void>;\n\tclose(): void;\n\tsnapshot(): RuntimeOnlyDeliveryQueueSnapshot;\n}\n\nexport class RuntimeOnlyBackpressureOverflowError extends Error {\n\treadonly code = MODEL_STREAM_BACKPRESSURE_OVERFLOW_CODE;\n\treadonly capacity: number;\n\treadonly pending: number;\n\treadonly attempted: number;\n\n\tconstructor(capacity: number, pending: number, attempted: number) {\n\t\tsuper(\n\t\t\t`Runtime-only delivery queue overflow: pending ${pending} + attempted ${attempted} exceeds capacity ${capacity}`,\n\t\t);\n\t\tthis.name = \"RuntimeOnlyBackpressureOverflowError\";\n\t\tthis.capacity = capacity;\n\t\tthis.pending = pending;\n\t\tthis.attempted = attempted;\n\t}\n}\n\ninterface QueueEntry<T> {\n\treadonly value: T;\n\treadonly weight: number;\n\treadonly resolve: () => void;\n\treadonly reject: (error: unknown) => void;\n}\n\nfunction assertPositiveSafeInteger(value: number, name: string): void {\n\tif (!Number.isSafeInteger(value) || value < 1) {\n\t\tthrow new Error(`Runtime-only delivery queue ${name} must be a positive safe integer`);\n\t}\n}\n\n/**\n * Creates a deterministic host-side subscription queue for runtime-only tests.\n *\n * Overflow rejects only the new enqueue, permanently terminates this queue,\n * and leaves already accepted values in order for delivery. Other queues are\n * independent and are not affected.\n *\n * Test-only divergence from the production lifecycle delivery queue: a handler\n * failure closes this whole queue and rejects every pending value with the\n * same error, while the production queue isolates the failure to that single\n * delivery and keeps accepting. Tests that need production semantics must use\n * the production runtime, not this fixture.\n */\nexport function createRuntimeOnlyDeliveryQueue<T>(\n\toptions: RuntimeOnlyDeliveryQueueOptions<T>,\n): RuntimeOnlyDeliveryQueue<T> {\n\tassertPositiveSafeInteger(options.capacity, \"capacity\");\n\tconst measure = options.measure ?? (() => 1);\n\tconst entries: QueueEntry<T>[] = [];\n\tlet status: RuntimeOnlyDeliveryQueueStatus = \"active\";\n\tlet pending = 0;\n\tlet accepted = 0;\n\tlet delivered = 0;\n\tlet rejected = 0;\n\tlet processing = false;\n\tlet drainPromise: Promise<void> | undefined;\n\tlet resolveDrain: (() => void) | undefined;\n\n\tconst ensureDrainPromise = (): Promise<void> => {\n\t\tif (drainPromise === undefined) {\n\t\t\tdrainPromise = new Promise<void>((resolve) => {\n\t\t\t\tresolveDrain = resolve;\n\t\t\t});\n\t\t}\n\t\treturn drainPromise;\n\t};\n\n\tconst settleDrainIfIdle = (): void => {\n\t\tif (processing || entries.length > 0) return;\n\t\tresolveDrain?.();\n\t\tdrainPromise = undefined;\n\t\tresolveDrain = undefined;\n\t};\n\n\tconst pump = async (): Promise<void> => {\n\t\tif (processing) return;\n\t\tprocessing = true;\n\t\ttry {\n\t\t\twhile (entries.length > 0) {\n\t\t\t\tconst entry = entries.shift();\n\t\t\t\t// v8 ignore next -- 循环条件保证 shift 必有元素\n\t\t\t\tif (entry === undefined) continue;\n\t\t\t\ttry {\n\t\t\t\t\tawait options.deliver(entry.value);\n\t\t\t\t\tdelivered += 1;\n\t\t\t\t\tentry.resolve();\n\t\t\t\t} catch (error) {\n\t\t\t\t\tstatus = \"closed\";\n\t\t\t\t\trejected += 1;\n\t\t\t\t\tentry.reject(error);\n\t\t\t\t\twhile (entries.length > 0) {\n\t\t\t\t\t\tconst pendingEntry = entries.shift();\n\t\t\t\t\t\t// v8 ignore next -- 循环条件保证 shift 必有元素\n\t\t\t\t\t\tif (pendingEntry === undefined) continue;\n\t\t\t\t\t\tpending -= pendingEntry.weight;\n\t\t\t\t\t\trejected += 1;\n\t\t\t\t\t\tpendingEntry.reject(error);\n\t\t\t\t\t}\n\t\t\t\t} finally {\n\t\t\t\t\tpending -= entry.weight;\n\t\t\t\t}\n\t\t\t\tif (status === \"closed\") break;\n\t\t\t}\n\t\t} finally {\n\t\t\tprocessing = false;\n\t\t\tsettleDrainIfIdle();\n\t\t}\n\t};\n\n\tconst enqueue = (value: T): Promise<void> => {\n\t\tif (status !== \"active\") {\n\t\t\trejected += 1;\n\t\t\tif (status === \"overflowed\") {\n\t\t\t\treturn Promise.reject(new RuntimeOnlyBackpressureOverflowError(options.capacity, pending, 0));\n\t\t\t}\n\t\t\treturn Promise.reject(new Error(`Runtime-only delivery queue is ${status}`));\n\t\t}\n\t\tconst weight = measure(value);\n\t\tassertPositiveSafeInteger(weight, \"measure result\");\n\t\tif (pending + weight > options.capacity) {\n\t\t\tstatus = \"overflowed\";\n\t\t\trejected += 1;\n\t\t\treturn Promise.reject(new RuntimeOnlyBackpressureOverflowError(options.capacity, pending, weight));\n\t\t}\n\t\taccepted += 1;\n\t\tpending += weight;\n\t\tconst result = new Promise<void>((resolve, reject) => {\n\t\t\tentries.push({ value, weight, resolve, reject });\n\t\t});\n\t\tensureDrainPromise();\n\t\tvoid pump();\n\t\treturn result;\n\t};\n\n\treturn {\n\t\tenqueue,\n\t\tdrain: () => {\n\t\t\tif (!processing && entries.length === 0) return Promise.resolve();\n\t\t\treturn ensureDrainPromise();\n\t\t},\n\t\tclose: () => {\n\t\t\tif (status === \"closed\") return;\n\t\t\tstatus = \"closed\";\n\t\t\twhile (entries.length > 0) {\n\t\t\t\tconst entry = entries.shift();\n\t\t\t\t// v8 ignore next -- 循环条件保证 shift 必有元素\n\t\t\t\tif (entry === undefined) continue;\n\t\t\t\tpending -= entry.weight;\n\t\t\t\trejected += 1;\n\t\t\t\tentry.reject(new Error(\"Runtime-only delivery queue was closed\"));\n\t\t\t}\n\t\t\tsettleDrainIfIdle();\n\t\t},\n\t\tsnapshot: () =>\n\t\t\tObject.freeze({\n\t\t\t\tstatus,\n\t\t\t\tcapacity: options.capacity,\n\t\t\t\tpending,\n\t\t\t\taccepted,\n\t\t\t\tdelivered,\n\t\t\t\trejected,\n\t\t\t}),\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"runtime-delivery-queue.js","sourceRoot":"","sources":["../../src/testing/runtime-delivery-queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,uBAAuB,CAAC;AAE1C,4EAA4E;AAC5E,MAAM,CAAC,MAAM,uCAAuC,GAAG,oCAA6C,CAAC;AA6BrG,MAAM,OAAO,oCAAqC,SAAQ,KAAK;IACrD,IAAI,GAAG,uCAAuC,CAAC;IAC/C,QAAQ,CAAS;IACjB,OAAO,CAAS;IAChB,SAAS,CAAS;IAE3B,YAAY,QAAgB,EAAE,OAAe,EAAE,SAAiB,EAAE;QACjE,KAAK,CACJ,iDAAiD,OAAO,gBAAgB,SAAS,qBAAqB,QAAQ,EAAE,CAChH,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,sCAAsC,CAAC;QACnD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAAA,CAC3B;CACD;AASD,SAAS,yBAAyB,CAAC,KAAa,EAAE,IAAY,EAAQ;IACrE,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,oEAAoE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,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MAAM,GAAG,CAAC,EAAE,CAAC;gBAC3B,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;gBAC9B,0DAAsC;gBACtC,IAAI,KAAK,KAAK,SAAS;oBAAE,SAAS;gBAClC,OAAO,IAAI,KAAK,CAAC,MAAM,CAAC;gBACxB,QAAQ,IAAI,CAAC,CAAC;gBACd,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC,CAAC;YACnE,CAAC;YACD,iBAAiB,EAAE,CAAC;QAAA,CACpB;QACD,QAAQ,EAAE,GAAG,EAAE,CACd,MAAM,CAAC,MAAM,CAAC;YACb,MAAM;YACN,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,OAAO;YACP,QAAQ;YACR,SAAS;YACT,QAAQ;SACR,CAAC;KACH,CAAC;AAAA,CACF","sourcesContent":["import { t } from \"../core/i18n/index.ts\";\n\n/** Stable error code required by the model.stream backpressure contract. */\nexport const MODEL_STREAM_BACKPRESSURE_OVERFLOW_CODE = \"model_stream_backpressure_overflow\" as const;\n\nexport type RuntimeOnlyDeliveryQueueStatus = \"active\" | \"overflowed\" | \"closed\";\n\nexport interface RuntimeOnlyDeliveryQueueSnapshot {\n\treadonly status: RuntimeOnlyDeliveryQueueStatus;\n\treadonly capacity: number;\n\t/** Weight of in-flight and queued values that have not finished delivery. */\n\treadonly pending: number;\n\treadonly accepted: number;\n\treadonly delivered: number;\n\treadonly rejected: number;\n}\n\nexport interface RuntimeOnlyDeliveryQueueOptions<T> {\n\t/** Maximum pending weight for this subscription. */\n\treadonly capacity: number;\n\t/** Defaults to one event per value. */\n\treadonly measure?: (value: T) => number;\n\treadonly deliver: (value: T) => void | Promise<void>;\n}\n\nexport interface RuntimeOnlyDeliveryQueue<T> {\n\tenqueue(value: T): Promise<void>;\n\tdrain(): Promise<void>;\n\tclose(): void;\n\tsnapshot(): RuntimeOnlyDeliveryQueueSnapshot;\n}\n\nexport class RuntimeOnlyBackpressureOverflowError extends Error {\n\treadonly code = MODEL_STREAM_BACKPRESSURE_OVERFLOW_CODE;\n\treadonly capacity: number;\n\treadonly pending: number;\n\treadonly attempted: number;\n\n\tconstructor(capacity: number, pending: number, attempted: number) {\n\t\tsuper(\n\t\t\t`Runtime-only delivery queue overflow: pending ${pending} + attempted ${attempted} exceeds capacity ${capacity}`,\n\t\t);\n\t\tthis.name = \"RuntimeOnlyBackpressureOverflowError\";\n\t\tthis.capacity = capacity;\n\t\tthis.pending = pending;\n\t\tthis.attempted = attempted;\n\t}\n}\n\ninterface QueueEntry<T> {\n\treadonly value: T;\n\treadonly weight: number;\n\treadonly resolve: () => void;\n\treadonly reject: (error: unknown) => void;\n}\n\nfunction assertPositiveSafeInteger(value: number, name: string): void {\n\tif (!Number.isSafeInteger(value) || value < 1) {\n\t\tthrow new Error(t(\"Runtime-only delivery queue {name} must be a positive safe integer\", { name }));\n\t}\n}\n\n/**\n * Creates a deterministic host-side subscription queue for runtime-only tests.\n *\n * Overflow rejects only the new enqueue, permanently terminates this queue,\n * and leaves already accepted values in order for delivery. Other queues are\n * independent and are not affected.\n *\n * Test-only divergence from the production lifecycle delivery queue: a handler\n * failure closes this whole queue and rejects every pending value with the\n * same error, while the production queue isolates the failure to that single\n * delivery and keeps accepting. Tests that need production semantics must use\n * the production runtime, not this fixture.\n */\nexport function createRuntimeOnlyDeliveryQueue<T>(\n\toptions: RuntimeOnlyDeliveryQueueOptions<T>,\n): RuntimeOnlyDeliveryQueue<T> {\n\tassertPositiveSafeInteger(options.capacity, \"capacity\");\n\tconst measure = options.measure ?? (() => 1);\n\tconst entries: QueueEntry<T>[] = [];\n\tlet status: RuntimeOnlyDeliveryQueueStatus = \"active\";\n\tlet pending = 0;\n\tlet accepted = 0;\n\tlet delivered = 0;\n\tlet rejected = 0;\n\tlet processing = false;\n\tlet drainPromise: Promise<void> | undefined;\n\tlet resolveDrain: (() => void) | undefined;\n\n\tconst ensureDrainPromise = (): Promise<void> => {\n\t\tif (drainPromise === undefined) {\n\t\t\tdrainPromise = new Promise<void>((resolve) => {\n\t\t\t\tresolveDrain = resolve;\n\t\t\t});\n\t\t}\n\t\treturn drainPromise;\n\t};\n\n\tconst settleDrainIfIdle = (): void => {\n\t\tif (processing || entries.length > 0) return;\n\t\tresolveDrain?.();\n\t\tdrainPromise = undefined;\n\t\tresolveDrain = undefined;\n\t};\n\n\tconst pump = async (): Promise<void> => {\n\t\tif (processing) return;\n\t\tprocessing = true;\n\t\ttry {\n\t\t\twhile (entries.length > 0) {\n\t\t\t\tconst entry = entries.shift();\n\t\t\t\t// v8 ignore next -- 循环条件保证 shift 必有元素\n\t\t\t\tif (entry === undefined) continue;\n\t\t\t\ttry {\n\t\t\t\t\tawait options.deliver(entry.value);\n\t\t\t\t\tdelivered += 1;\n\t\t\t\t\tentry.resolve();\n\t\t\t\t} catch (error) {\n\t\t\t\t\tstatus = \"closed\";\n\t\t\t\t\trejected += 1;\n\t\t\t\t\tentry.reject(error);\n\t\t\t\t\twhile (entries.length > 0) {\n\t\t\t\t\t\tconst pendingEntry = entries.shift();\n\t\t\t\t\t\t// v8 ignore next -- 循环条件保证 shift 必有元素\n\t\t\t\t\t\tif (pendingEntry === undefined) continue;\n\t\t\t\t\t\tpending -= pendingEntry.weight;\n\t\t\t\t\t\trejected += 1;\n\t\t\t\t\t\tpendingEntry.reject(error);\n\t\t\t\t\t}\n\t\t\t\t} finally {\n\t\t\t\t\tpending -= entry.weight;\n\t\t\t\t}\n\t\t\t\tif (status === \"closed\") break;\n\t\t\t}\n\t\t} finally {\n\t\t\tprocessing = false;\n\t\t\tsettleDrainIfIdle();\n\t\t}\n\t};\n\n\tconst enqueue = (value: T): Promise<void> => {\n\t\tif (status !== \"active\") {\n\t\t\trejected += 1;\n\t\t\tif (status === \"overflowed\") {\n\t\t\t\treturn Promise.reject(new RuntimeOnlyBackpressureOverflowError(options.capacity, pending, 0));\n\t\t\t}\n\t\t\treturn Promise.reject(new Error(`Runtime-only delivery queue is ${status}`));\n\t\t}\n\t\tconst weight = measure(value);\n\t\tassertPositiveSafeInteger(weight, \"measure result\");\n\t\tif (pending + weight > options.capacity) {\n\t\t\tstatus = \"overflowed\";\n\t\t\trejected += 1;\n\t\t\treturn Promise.reject(new RuntimeOnlyBackpressureOverflowError(options.capacity, pending, weight));\n\t\t}\n\t\taccepted += 1;\n\t\tpending += weight;\n\t\tconst result = new Promise<void>((resolve, reject) => {\n\t\t\tentries.push({ value, weight, resolve, reject });\n\t\t});\n\t\tensureDrainPromise();\n\t\tvoid pump();\n\t\treturn result;\n\t};\n\n\treturn {\n\t\tenqueue,\n\t\tdrain: () => {\n\t\t\tif (!processing && entries.length === 0) return Promise.resolve();\n\t\t\treturn ensureDrainPromise();\n\t\t},\n\t\tclose: () => {\n\t\t\tif (status === \"closed\") return;\n\t\t\tstatus = \"closed\";\n\t\t\twhile (entries.length > 0) {\n\t\t\t\tconst entry = entries.shift();\n\t\t\t\t// v8 ignore next -- 循环条件保证 shift 必有元素\n\t\t\t\tif (entry === undefined) continue;\n\t\t\t\tpending -= entry.weight;\n\t\t\t\trejected += 1;\n\t\t\t\tentry.reject(new Error(\"Runtime-only delivery queue was closed\"));\n\t\t\t}\n\t\t\tsettleDrainIfIdle();\n\t\t},\n\t\tsnapshot: () =>\n\t\t\tObject.freeze({\n\t\t\t\tstatus,\n\t\t\t\tcapacity: options.capacity,\n\t\t\t\tpending,\n\t\t\t\taccepted,\n\t\t\t\tdelivered,\n\t\t\t\trejected,\n\t\t\t}),\n\t};\n}\n"]}
|