@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,3 +1,4 @@
|
|
|
1
|
+
import { t } from "../../core/i18n/index.js";
|
|
1
2
|
import { downloadNodeUrlPackageV1 } from "./node-url-package-source.js";
|
|
2
3
|
/**
|
|
3
4
|
* GitHub/Gitee release plugin package source (design
|
|
@@ -40,14 +41,14 @@ export class NodeReleasePackageSourceErrorV1 extends Error {
|
|
|
40
41
|
function boundedPositive(value, fallback, maximum, label) {
|
|
41
42
|
const result = value ?? fallback;
|
|
42
43
|
if (!Number.isSafeInteger(result) || result <= 0 || result > maximum)
|
|
43
|
-
throw new NodeReleasePackageSourceErrorV1("invalid_configuration",
|
|
44
|
+
throw new NodeReleasePackageSourceErrorV1("invalid_configuration", t("{label} must be a positive integer at most {maximum}", { label, maximum }));
|
|
44
45
|
return result;
|
|
45
46
|
}
|
|
46
47
|
function boundedToken(value, label) {
|
|
47
48
|
if (value === undefined)
|
|
48
49
|
return undefined;
|
|
49
50
|
if (value.length === 0 || value.length > 4096 || /[\r\n\s]/u.test(value))
|
|
50
|
-
throw new NodeReleasePackageSourceErrorV1("invalid_configuration",
|
|
51
|
+
throw new NodeReleasePackageSourceErrorV1("invalid_configuration", t("{label} is invalid", { label }));
|
|
51
52
|
return value;
|
|
52
53
|
}
|
|
53
54
|
function apiOrigin(value, label) {
|
|
@@ -56,14 +57,14 @@ function apiOrigin(value, label) {
|
|
|
56
57
|
parsed = new URL(value);
|
|
57
58
|
}
|
|
58
59
|
catch {
|
|
59
|
-
throw new NodeReleasePackageSourceErrorV1("invalid_configuration",
|
|
60
|
+
throw new NodeReleasePackageSourceErrorV1("invalid_configuration", t("{label} is invalid", { label }));
|
|
60
61
|
}
|
|
61
62
|
if ((parsed.protocol !== "http:" && parsed.protocol !== "https:") ||
|
|
62
63
|
parsed.username !== "" ||
|
|
63
64
|
parsed.password !== "")
|
|
64
|
-
throw new NodeReleasePackageSourceErrorV1("invalid_configuration",
|
|
65
|
+
throw new NodeReleasePackageSourceErrorV1("invalid_configuration", t("{label} must be http(s) without credentials", { label }));
|
|
65
66
|
if (parsed.search !== "" || parsed.hash !== "")
|
|
66
|
-
throw new NodeReleasePackageSourceErrorV1("invalid_configuration",
|
|
67
|
+
throw new NodeReleasePackageSourceErrorV1("invalid_configuration", t("{label} must not include a query or fragment", { label }));
|
|
67
68
|
// The Gitee default origin carries the `/api/v5` path prefix. The prefix is
|
|
68
69
|
// kept as a plain string because a URL normalizes an empty pathname back
|
|
69
70
|
// to "/", which would reintroduce a double slash when joining endpoints.
|
|
@@ -75,26 +76,26 @@ function jsonBytes(value) {
|
|
|
75
76
|
return JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(value));
|
|
76
77
|
}
|
|
77
78
|
catch {
|
|
78
|
-
throw new NodeReleasePackageSourceErrorV1("invalid_response", "release API response is not valid JSON");
|
|
79
|
+
throw new NodeReleasePackageSourceErrorV1("invalid_response", t("release API response is not valid JSON"));
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
82
|
function parseReleaseList(bytes) {
|
|
82
83
|
const value = jsonBytes(bytes);
|
|
83
84
|
if (!Array.isArray(value))
|
|
84
|
-
throw new NodeReleasePackageSourceErrorV1("invalid_response", "release API response is not a release list");
|
|
85
|
+
throw new NodeReleasePackageSourceErrorV1("invalid_response", t("release API response is not a release list"));
|
|
85
86
|
return value;
|
|
86
87
|
}
|
|
87
88
|
function parseReleaseObject(bytes) {
|
|
88
89
|
const value = jsonBytes(bytes);
|
|
89
90
|
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
90
|
-
throw new NodeReleasePackageSourceErrorV1("invalid_response", "release API response is not a release object");
|
|
91
|
+
throw new NodeReleasePackageSourceErrorV1("invalid_response", t("release API response is not a release object"));
|
|
91
92
|
return value;
|
|
92
93
|
}
|
|
93
94
|
/** First non-draft entry in API order; the array itself is the ordering contract. */
|
|
94
95
|
function firstPublishedRelease(releases) {
|
|
95
96
|
const published = releases.find((release) => release.draft !== true);
|
|
96
97
|
if (published === undefined)
|
|
97
|
-
throw new NodeReleasePackageSourceErrorV1("release_not_found", "repo has no published release");
|
|
98
|
+
throw new NodeReleasePackageSourceErrorV1("release_not_found", t("repo has no published release"));
|
|
98
99
|
return published;
|
|
99
100
|
}
|
|
100
101
|
/** Assets with a usable name; entries without a string name are ignored as API noise. */
|
|
@@ -102,7 +103,7 @@ function namedAssets(release) {
|
|
|
102
103
|
if (release.assets === undefined)
|
|
103
104
|
return [];
|
|
104
105
|
if (!Array.isArray(release.assets))
|
|
105
|
-
throw new NodeReleasePackageSourceErrorV1("invalid_response", "release assets are invalid");
|
|
106
|
+
throw new NodeReleasePackageSourceErrorV1("invalid_response", t("release assets are invalid"));
|
|
106
107
|
const entries = [];
|
|
107
108
|
for (const asset of release.assets) {
|
|
108
109
|
if (typeof asset !== "object" || asset === null)
|
|
@@ -124,12 +125,12 @@ function selectPackageAssetUrl(release) {
|
|
|
124
125
|
const candidates = assets.filter((asset) => isPackageAssetName(asset.name));
|
|
125
126
|
const assetNames = assets.map((asset) => asset.name).join(", ");
|
|
126
127
|
if (candidates.length === 0)
|
|
127
|
-
throw new NodeReleasePackageSourceErrorV1("release_asset_not_found", assetNames.length === 0 ? "release has no assets" :
|
|
128
|
+
throw new NodeReleasePackageSourceErrorV1("release_asset_not_found", assetNames.length === 0 ? t("release has no assets") : t("assets: {names}", { names: assetNames }));
|
|
128
129
|
if (candidates.length > 1)
|
|
129
|
-
throw new NodeReleasePackageSourceErrorV1("release_asset_ambiguous",
|
|
130
|
+
throw new NodeReleasePackageSourceErrorV1("release_asset_ambiguous", t("candidates: {names}", { names: candidates.map((asset) => asset.name).join(", ") }));
|
|
130
131
|
const chosen = candidates[0];
|
|
131
132
|
if (typeof chosen.url !== "string" || chosen.url.length === 0)
|
|
132
|
-
throw new NodeReleasePackageSourceErrorV1("invalid_response", "release asset has no download URL");
|
|
133
|
+
throw new NodeReleasePackageSourceErrorV1("invalid_response", t("release asset has no download URL"));
|
|
133
134
|
return chosen.url;
|
|
134
135
|
}
|
|
135
136
|
function isAbortLike(error) {
|
|
@@ -180,20 +181,20 @@ function rateLimitState(response) {
|
|
|
180
181
|
}
|
|
181
182
|
async function readBody(response, maxBytes, signal) {
|
|
182
183
|
if (response.body === null)
|
|
183
|
-
throw new NodeReleasePackageSourceErrorV1("invalid_response", "release API response has no body");
|
|
184
|
+
throw new NodeReleasePackageSourceErrorV1("invalid_response", t("release API response has no body"));
|
|
184
185
|
const reader = response.body.getReader();
|
|
185
186
|
const chunks = [];
|
|
186
187
|
let total = 0;
|
|
187
188
|
try {
|
|
188
189
|
for (;;) {
|
|
189
190
|
if (signal.aborted)
|
|
190
|
-
throw new DOMException("aborted", "AbortError");
|
|
191
|
+
throw new DOMException(t("aborted"), "AbortError");
|
|
191
192
|
const item = await reader.read();
|
|
192
193
|
if (item.done)
|
|
193
194
|
break;
|
|
194
195
|
total += item.value.byteLength;
|
|
195
196
|
if (total > maxBytes)
|
|
196
|
-
throw new NodeReleasePackageSourceErrorV1("response_too_large", "release API response exceeds the configured size limit");
|
|
197
|
+
throw new NodeReleasePackageSourceErrorV1("response_too_large", t("release API response exceeds the configured size limit"));
|
|
197
198
|
chunks.push(item.value);
|
|
198
199
|
}
|
|
199
200
|
}
|
|
@@ -212,7 +213,7 @@ async function readBody(response, maxBytes, signal) {
|
|
|
212
213
|
export function createNodeReleasePackageSourceV1(options = {}) {
|
|
213
214
|
const transport = options.fetch ?? globalThis.fetch;
|
|
214
215
|
if (typeof transport !== "function")
|
|
215
|
-
throw new NodeReleasePackageSourceErrorV1("invalid_configuration", "Node fetch is unavailable");
|
|
216
|
+
throw new NodeReleasePackageSourceErrorV1("invalid_configuration", t("Node fetch is unavailable"));
|
|
216
217
|
const githubOrigin = apiOrigin(options.githubApiOrigin ?? DEFAULT_GITHUB_API_ORIGIN_V1, "githubApiOrigin");
|
|
217
218
|
const giteeOrigin = apiOrigin(options.giteeApiOrigin ?? DEFAULT_GITEE_API_ORIGIN_V1, "giteeApiOrigin");
|
|
218
219
|
const githubToken = boundedToken(options.githubToken, "githubToken");
|
|
@@ -222,10 +223,10 @@ export function createNodeReleasePackageSourceV1(options = {}) {
|
|
|
222
223
|
const maxAssetBytes = boundedPositive(options.maxAssetBytes, DEFAULT_MAX_ASSET_BYTES_V1, MAX_ASSET_BYTES_V1, "maxAssetBytes");
|
|
223
224
|
const maxRedirects = options.maxRedirects ?? DEFAULT_REDIRECTS_V1;
|
|
224
225
|
if (!Number.isSafeInteger(maxRedirects) || maxRedirects < 0 || maxRedirects > MAX_REDIRECTS_V1)
|
|
225
|
-
throw new NodeReleasePackageSourceErrorV1("invalid_configuration",
|
|
226
|
+
throw new NodeReleasePackageSourceErrorV1("invalid_configuration", t("maxRedirects must be an integer between 0 and {max}", { max: MAX_REDIRECTS_V1 }));
|
|
226
227
|
const userAgent = options.userAgent ?? "agent-forge-plugin-release/1";
|
|
227
228
|
if (userAgent.length === 0 || userAgent.length > 256 || /[\r\n]/u.test(userAgent))
|
|
228
|
-
throw new NodeReleasePackageSourceErrorV1("invalid_configuration", "userAgent is invalid");
|
|
229
|
+
throw new NodeReleasePackageSourceErrorV1("invalid_configuration", t("userAgent is invalid"));
|
|
229
230
|
const fetchReleaseJson = async (url, headers, parentSignal) => {
|
|
230
231
|
let current = url;
|
|
231
232
|
for (let redirect = 0;; redirect += 1) {
|
|
@@ -242,15 +243,15 @@ export function createNodeReleasePackageSourceV1(options = {}) {
|
|
|
242
243
|
catch (error) {
|
|
243
244
|
request.cleanup();
|
|
244
245
|
if (request.timedOut())
|
|
245
|
-
throw new NodeReleasePackageSourceErrorV1("request_timed_out", "release API request timed out");
|
|
246
|
+
throw new NodeReleasePackageSourceErrorV1("request_timed_out", t("release API request timed out"));
|
|
246
247
|
if (isAbortLike(error))
|
|
247
|
-
throw new NodeReleasePackageSourceErrorV1("cancelled", "release API request was cancelled");
|
|
248
|
-
throw new NodeReleasePackageSourceErrorV1("request_failed", "release API request failed");
|
|
248
|
+
throw new NodeReleasePackageSourceErrorV1("cancelled", t("release API request was cancelled"));
|
|
249
|
+
throw new NodeReleasePackageSourceErrorV1("request_failed", t("release API request failed"));
|
|
249
250
|
}
|
|
250
251
|
if (!REDIRECT_STATUS.has(response.status)) {
|
|
251
252
|
try {
|
|
252
253
|
if (response.status === 404)
|
|
253
|
-
throw new NodeReleasePackageSourceErrorV1("release_not_found", "repo or release was not found");
|
|
254
|
+
throw new NodeReleasePackageSourceErrorV1("release_not_found", t("repo or release was not found"));
|
|
254
255
|
const limit = rateLimitState(response);
|
|
255
256
|
if (limit.limited) {
|
|
256
257
|
const message = limit.resetEpochSeconds === undefined
|
|
@@ -261,9 +262,9 @@ export function createNodeReleasePackageSourceV1(options = {}) {
|
|
|
261
262
|
});
|
|
262
263
|
}
|
|
263
264
|
if (response.status < 200 || response.status >= 300)
|
|
264
|
-
throw new NodeReleasePackageSourceErrorV1("request_failed", "release API request did not succeed");
|
|
265
|
+
throw new NodeReleasePackageSourceErrorV1("request_failed", t("release API request did not succeed"));
|
|
265
266
|
if (!isJsonResponse(response))
|
|
266
|
-
throw new NodeReleasePackageSourceErrorV1("invalid_response", "release API response must be JSON");
|
|
267
|
+
throw new NodeReleasePackageSourceErrorV1("invalid_response", t("release API response must be JSON"));
|
|
267
268
|
const bytes = await readBody(response, maxResponseBytes, request.signal);
|
|
268
269
|
return bytes;
|
|
269
270
|
}
|
|
@@ -276,22 +277,22 @@ export function createNodeReleasePackageSourceV1(options = {}) {
|
|
|
276
277
|
await response.body?.cancel().catch(() => undefined);
|
|
277
278
|
request.cleanup();
|
|
278
279
|
if (location === null || redirect >= maxRedirects)
|
|
279
|
-
throw new NodeReleasePackageSourceErrorV1("request_failed", "release API redirect limit exceeded");
|
|
280
|
+
throw new NodeReleasePackageSourceErrorV1("request_failed", t("release API redirect limit exceeded"));
|
|
280
281
|
let next;
|
|
281
282
|
try {
|
|
282
283
|
next = new URL(location, current);
|
|
283
284
|
}
|
|
284
285
|
catch {
|
|
285
|
-
throw new NodeReleasePackageSourceErrorV1("invalid_response", "release API redirect target is invalid");
|
|
286
|
+
throw new NodeReleasePackageSourceErrorV1("invalid_response", t("release API redirect target is invalid"));
|
|
286
287
|
}
|
|
287
288
|
if ((next.protocol !== "http:" && next.protocol !== "https:") || next.username !== "" || next.password !== "")
|
|
288
|
-
throw new NodeReleasePackageSourceErrorV1("invalid_response", "release API redirect must stay http(s)");
|
|
289
|
+
throw new NodeReleasePackageSourceErrorV1("invalid_response", t("release API redirect must stay http(s)"));
|
|
289
290
|
current = next;
|
|
290
291
|
}
|
|
291
292
|
};
|
|
292
293
|
const downloadReleaseAsset = async (input) => {
|
|
293
294
|
if (input.signal?.aborted === true)
|
|
294
|
-
throw new NodeReleasePackageSourceErrorV1("cancelled", "release asset download was cancelled");
|
|
295
|
+
throw new NodeReleasePackageSourceErrorV1("cancelled", t("release asset download was cancelled"));
|
|
295
296
|
const sourceLabel = `${input.kind}:${input.owner}/${input.repo}@${input.tag ?? "latest"}`;
|
|
296
297
|
const base = input.kind === "github" ? githubOrigin : giteeOrigin;
|
|
297
298
|
const segments = [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-release-package-source.js","sourceRoot":"","sources":["../../../src/plugins/ecosystem/node-release-package-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAExE;;;;;;;;;;;;;;GAcG;AAEH,MAAM,4BAA4B,GAAG,wBAAwB,CAAC;AAC9D,MAAM,2BAA2B,GAAG,0BAA0B,CAAC;AAC/D,MAAM,qBAAqB,GAAG,MAAM,CAAC;AACrC,MAAM,iBAAiB,GAAG,OAAO,CAAC;AAClC,MAAM,6BAA6B,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AACtD,MAAM,qBAAqB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAC/C,MAAM,0BAA0B,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;AACrD,MAAM,kBAAkB,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;AAC7C,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAC/B,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAC3B,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAc3D,MAAM,OAAO,+BAAgC,SAAQ,KAAK;IAChD,IAAI,CAAsC;IACnD,6FAA6F;IACpF,iBA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1G,MAAM,QAAQ,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC;QAChD,MAAM,QAAQ,GAAG,MAAM,wBAAwB,CAC9C;YACC,GAAG,CAAC,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC;YAChE,gBAAgB,EAAE,SAAS;YAC3B,eAAe,EAAE,aAAa;YAC9B,SAAS;SACT,EACD;YACC,GAAG,EAAE,QAAQ;YACb,GAAG,CAAC,KAAK,CAAC,iBAAiB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAChG,MAAM,EAAE,KAAK,CAAC,MAAM;SACpB,CACD,CAAC;QACF,OAAO;YACN,KAAK,EAAE,QAAQ,CAAC,KAAK;YACrB,SAAS,EAAE,QAAQ,CAAC,SAAS;YAC7B,SAAS,EAAE,QAAQ,CAAC,SAAS;YAC7B,WAAW;SACX,CAAC;IAAA,CACF,CAAC;IAEF,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,oBAAoB,EAAE,CAAC;AAAA,CAC5C","sourcesContent":["import { downloadNodeUrlPackageV1 } from \"./node-url-package-source.ts\";\n\n/**\n * GitHub/Gitee release plugin package source (design\n * `插件独立分发与启动装配设计.md` §4.6 \"GitHub\"/\"Gitee\" rows). Two-step\n * protocol: resolve one release through the repo's release API — the exact\n * tag endpoint when a tag is given, otherwise the first non-draft entry of\n * the first releases page in API order (no client-side sorting) — then pick\n * the release's single `.zip`/`.tgz` asset and download it with the same\n * bounded http(s) semantics as custom URL packages (redirect-per-hop, budget,\n * timeout, optional strong sha256). Zero or multiple matching assets are\n * explicit structured errors listing the asset names; nothing is guessed.\n * Authentication is optional: GitHub uses an `Authorization: Bearer` header,\n * Gitee an `access_token` query parameter. Anonymous rate limits (403/429\n * with `X-RateLimit-Remaining: 0`, or any 429) surface as `rate_limited`\n * carrying the advertised `X-RateLimit-Reset` epoch; there is no retry.\n */\n\nconst DEFAULT_GITHUB_API_ORIGIN_V1 = \"https://api.github.com\";\nconst DEFAULT_GITEE_API_ORIGIN_V1 = \"https://gitee.com/api/v5\";\nconst DEFAULT_TIMEOUT_MS_V1 = 15_000;\nconst MAX_TIMEOUT_MS_V1 = 120_000;\nconst DEFAULT_MAX_RESPONSE_BYTES_V1 = 8 * 1024 * 1024;\nconst MAX_RESPONSE_BYTES_V1 = 16 * 1024 * 1024;\nconst DEFAULT_MAX_ASSET_BYTES_V1 = 128 * 1024 * 1024;\nconst MAX_ASSET_BYTES_V1 = 512 * 1024 * 1024;\nconst DEFAULT_REDIRECTS_V1 = 3;\nconst MAX_REDIRECTS_V1 = 5;\nconst REDIRECT_STATUS = new Set([301, 302, 303, 307, 308]);\n\nexport type NodeReleasePackageSourceErrorCodeV1 =\n\t| \"cancelled\"\n\t| \"invalid_configuration\"\n\t| \"request_failed\"\n\t| \"request_timed_out\"\n\t| \"invalid_response\"\n\t| \"response_too_large\"\n\t| \"release_not_found\"\n\t| \"release_asset_not_found\"\n\t| \"release_asset_ambiguous\"\n\t| \"rate_limited\";\n\nexport class NodeReleasePackageSourceErrorV1 extends Error {\n\treadonly code: NodeReleasePackageSourceErrorCodeV1;\n\t/** Unix epoch seconds advertised by `X-RateLimit-Reset`; present only for `rate_limited`. */\n\treadonly resetEpochSeconds?: number;\n\n\tconstructor(\n\t\tcode: NodeReleasePackageSourceErrorCodeV1,\n\t\tmessage: string,\n\t\toptions?: { readonly resetEpochSeconds?: number },\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"NodeReleasePackageSourceErrorV1\";\n\t\tthis.code = code;\n\t\tif (options?.resetEpochSeconds !== undefined) this.resetEpochSeconds = options.resetEpochSeconds;\n\t}\n}\n\nexport interface NodeReleasePackageSourceOptionsV1 {\n\t/** Bare http(s) GitHub API origin; defaults to `https://api.github.com`. */\n\treadonly githubApiOrigin?: string;\n\t/** Bare http(s) Gitee API origin; defaults to `https://gitee.com/api/v5`. */\n\treadonly giteeApiOrigin?: string;\n\t/** Optional GitHub API token sent as a bearer header. */\n\treadonly githubToken?: string;\n\t/** Optional Gitee API token sent as an `access_token` query parameter. */\n\treadonly giteeToken?: string;\n\t/** Real fetch or a deterministic test replacement. */\n\treadonly fetch?: typeof globalThis.fetch;\n\treadonly requestTimeoutMs?: number;\n\treadonly maxResponseBytes?: number;\n\treadonly maxAssetBytes?: number;\n\treadonly maxRedirects?: number;\n\treadonly userAgent?: string;\n}\n\nexport interface NodeReleaseAssetDownloadV1 {\n\treadonly bytes: Uint8Array;\n\treadonly mediaType: \"application/zip\" | \"application/gzip\";\n\treadonly sha256Hex: string;\n\t/** `github:<owner>/<repo>@<tag|latest>` or the `gitee:` equivalent. */\n\treadonly sourceLabel: string;\n}\n\nexport interface NodeReleasePackageSourceV1 {\n\treadonly version: 1;\n\treadonly downloadReleaseAsset: (input: {\n\t\treadonly kind: \"github\" | \"gitee\";\n\t\treadonly owner: string;\n\t\treadonly repo: string;\n\t\treadonly tag?: string;\n\t\treadonly expectedDigestHex?: string;\n\t\treadonly signal?: AbortSignal;\n\t}) => Promise<NodeReleaseAssetDownloadV1>;\n}\n\ninterface ReleaseAssetShapeV1 {\n\treadonly name?: unknown;\n\treadonly browser_download_url?: unknown;\n}\n\ninterface ReleaseShapeV1 {\n\treadonly draft?: unknown;\n\treadonly assets?: unknown;\n}\n\nfunction boundedPositive(value: number | undefined, fallback: number, maximum: number, label: string): number {\n\tconst result = value ?? fallback;\n\tif (!Number.isSafeInteger(result) || result <= 0 || result > maximum)\n\t\tthrow new NodeReleasePackageSourceErrorV1(\n\t\t\t\"invalid_configuration\",\n\t\t\t`${label} must be a positive integer at most ${maximum}`,\n\t\t);\n\treturn result;\n}\n\nfunction boundedToken(value: string | undefined, label: string): string | undefined {\n\tif (value === undefined) return undefined;\n\tif (value.length === 0 || value.length > 4096 || /[\\r\\n\\s]/u.test(value))\n\t\tthrow new NodeReleasePackageSourceErrorV1(\"invalid_configuration\", `${label} is invalid`);\n\treturn value;\n}\n\nfunction apiOrigin(value: string, label: string): { readonly origin: string; readonly pathPrefix: string } {\n\tlet parsed: URL;\n\ttry {\n\t\tparsed = new URL(value);\n\t} catch {\n\t\tthrow new NodeReleasePackageSourceErrorV1(\"invalid_configuration\", `${label} is invalid`);\n\t}\n\tif (\n\t\t(parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") ||\n\t\tparsed.username !== \"\" ||\n\t\tparsed.password !== \"\"\n\t)\n\t\tthrow new NodeReleasePackageSourceErrorV1(\n\t\t\t\"invalid_configuration\",\n\t\t\t`${label} must be http(s) without credentials`,\n\t\t);\n\tif (parsed.search !== \"\" || parsed.hash !== \"\")\n\t\tthrow new NodeReleasePackageSourceErrorV1(\n\t\t\t\"invalid_configuration\",\n\t\t\t`${label} must not include a query or fragment`,\n\t\t);\n\t// The Gitee default origin carries the `/api/v5` path prefix. The prefix is\n\t// kept as a plain string because a URL normalizes an empty pathname back\n\t// to \"/\", which would reintroduce a double slash when joining endpoints.\n\tconst trimmed = parsed.pathname.replace(/\\/+$/u, \"\");\n\treturn { origin: parsed.origin, pathPrefix: trimmed === \"\" || trimmed === \"/\" ? \"\" : trimmed.replace(/^\\//u, \"\") };\n}\n\nfunction jsonBytes(value: Uint8Array): unknown {\n\ttry {\n\t\treturn JSON.parse(new TextDecoder(\"utf-8\", { fatal: true }).decode(value));\n\t} catch {\n\t\tthrow new NodeReleasePackageSourceErrorV1(\"invalid_response\", \"release API response is not valid JSON\");\n\t}\n}\n\nfunction parseReleaseList(bytes: Uint8Array): readonly ReleaseShapeV1[] {\n\tconst value = jsonBytes(bytes);\n\tif (!Array.isArray(value))\n\t\tthrow new NodeReleasePackageSourceErrorV1(\"invalid_response\", \"release API response is not a release list\");\n\treturn value as readonly ReleaseShapeV1[];\n}\n\nfunction parseReleaseObject(bytes: Uint8Array): ReleaseShapeV1 {\n\tconst value = jsonBytes(bytes);\n\tif (typeof value !== \"object\" || value === null || Array.isArray(value))\n\t\tthrow new NodeReleasePackageSourceErrorV1(\"invalid_response\", \"release API response is not a release object\");\n\treturn value as ReleaseShapeV1;\n}\n\n/** First non-draft entry in API order; the array itself is the ordering contract. */\nfunction firstPublishedRelease(releases: readonly ReleaseShapeV1[]): ReleaseShapeV1 {\n\tconst published = releases.find((release) => release.draft !== true);\n\tif (published === undefined)\n\t\tthrow new NodeReleasePackageSourceErrorV1(\"release_not_found\", \"repo has no published release\");\n\treturn published;\n}\n\ninterface ReleaseAssetNameV1 {\n\treadonly name: string;\n\treadonly url: unknown;\n}\n\n/** Assets with a usable name; entries without a string name are ignored as API noise. */\nfunction namedAssets(release: ReleaseShapeV1): readonly ReleaseAssetNameV1[] {\n\tif (release.assets === undefined) return [];\n\tif (!Array.isArray(release.assets))\n\t\tthrow new NodeReleasePackageSourceErrorV1(\"invalid_response\", \"release assets are invalid\");\n\tconst entries: ReleaseAssetNameV1[] = [];\n\tfor (const asset of release.assets) {\n\t\tif (typeof asset !== \"object\" || asset === null) continue;\n\t\tconst shape = asset as ReleaseAssetShapeV1;\n\t\tif (typeof shape.name !== \"string\" || shape.name.length === 0) continue;\n\t\tentries.push({ name: shape.name, url: shape.browser_download_url });\n\t}\n\treturn entries;\n}\n\nfunction isPackageAssetName(name: string): boolean {\n\tconst value = name.toLowerCase();\n\treturn value.endsWith(\".zip\") || value.endsWith(\".tgz\");\n}\n\n/** Select the release's single `.zip`/`.tgz` asset and return its download URL. */\nfunction selectPackageAssetUrl(release: ReleaseShapeV1): string {\n\tconst assets = namedAssets(release);\n\tconst candidates = assets.filter((asset) => isPackageAssetName(asset.name));\n\tconst assetNames = assets.map((asset) => asset.name).join(\", \");\n\tif (candidates.length === 0)\n\t\tthrow new NodeReleasePackageSourceErrorV1(\n\t\t\t\"release_asset_not_found\",\n\t\t\tassetNames.length === 0 ? \"release has no assets\" : `assets: ${assetNames}`,\n\t\t);\n\tif (candidates.length > 1)\n\t\tthrow new NodeReleasePackageSourceErrorV1(\n\t\t\t\"release_asset_ambiguous\",\n\t\t\t`candidates: ${candidates.map((asset) => asset.name).join(\", \")}`,\n\t\t);\n\tconst chosen = candidates[0]!;\n\tif (typeof chosen.url !== \"string\" || chosen.url.length === 0)\n\t\tthrow new NodeReleasePackageSourceErrorV1(\"invalid_response\", \"release asset has no download URL\");\n\treturn chosen.url;\n}\n\nfunction isAbortLike(error: unknown): boolean {\n\treturn error instanceof Error && (error.name === \"AbortError\" || error.name === \"AbortSignalError\");\n}\n\ninterface RequestSignal {\n\treadonly signal: AbortSignal;\n\treadonly timedOut: () => boolean;\n\treadonly cleanup: () => void;\n}\n\nfunction requestSignal(parent: AbortSignal | undefined, timeoutMs: number): RequestSignal {\n\tconst controller = new AbortController();\n\tlet timedOut = false;\n\tconst abort = () => controller.abort(parent?.reason);\n\tif (parent?.aborted === true) abort();\n\telse parent?.addEventListener(\"abort\", abort, { once: true });\n\tconst timeout = setTimeout(() => {\n\t\ttimedOut = true;\n\t\tcontroller.abort();\n\t}, timeoutMs);\n\treturn {\n\t\tsignal: controller.signal,\n\t\ttimedOut: () => timedOut,\n\t\tcleanup: () => {\n\t\t\tclearTimeout(timeout);\n\t\t\tparent?.removeEventListener(\"abort\", abort);\n\t\t},\n\t};\n}\n\nfunction isJsonResponse(response: Response): boolean {\n\tconst contentType = response.headers.get(\"content-type\");\n\tif (contentType === null) return false;\n\tconst mediaType = contentType.split(\";\", 1)[0]?.trim().toLowerCase();\n\treturn mediaType === \"application/json\" || mediaType === \"application/vnd.github+json\";\n}\n\n/**\n * Rate-limit verdict for 403/429 responses: any 429, and a 403 whose\n * `X-RateLimit-Remaining` is exactly `0`. The reset epoch is passed through\n * verbatim when present and integer-like; absent headers stay absent.\n */\nfunction rateLimitState(response: Response): { readonly limited: boolean; readonly resetEpochSeconds?: number } {\n\tconst limited =\n\t\tresponse.status === 429 || (response.status === 403 && response.headers.get(\"x-ratelimit-remaining\") === \"0\");\n\tif (!limited) return { limited: false };\n\tconst reset = response.headers.get(\"x-ratelimit-reset\");\n\tconst resetValue = reset === null ? Number.NaN : Number.parseInt(reset, 10);\n\tif (!Number.isSafeInteger(resetValue) || resetValue < 0) return { limited: true };\n\treturn { limited: true, resetEpochSeconds: resetValue };\n}\n\nasync function readBody(response: Response, maxBytes: number, signal: AbortSignal): Promise<Uint8Array> {\n\tif (response.body === null)\n\t\tthrow new NodeReleasePackageSourceErrorV1(\"invalid_response\", \"release API response has no body\");\n\tconst reader = response.body.getReader();\n\tconst chunks: Uint8Array[] = [];\n\tlet total = 0;\n\ttry {\n\t\tfor (;;) {\n\t\t\tif (signal.aborted) throw new DOMException(\"aborted\", \"AbortError\");\n\t\t\tconst item = await reader.read();\n\t\t\tif (item.done) break;\n\t\t\ttotal += item.value.byteLength;\n\t\t\tif (total > maxBytes)\n\t\t\t\tthrow new NodeReleasePackageSourceErrorV1(\n\t\t\t\t\t\"response_too_large\",\n\t\t\t\t\t\"release API response exceeds the configured size limit\",\n\t\t\t\t);\n\t\t\tchunks.push(item.value);\n\t\t}\n\t} finally {\n\t\treader.releaseLock();\n\t}\n\tconst bytes = new Uint8Array(total);\n\tlet offset = 0;\n\tfor (const chunk of chunks) {\n\t\tbytes.set(chunk, offset);\n\t\toffset += chunk.byteLength;\n\t}\n\treturn bytes;\n}\n\n/** Create the bounded GitHub/Gitee release reader. */\nexport function createNodeReleasePackageSourceV1(\n\toptions: NodeReleasePackageSourceOptionsV1 = {},\n): NodeReleasePackageSourceV1 {\n\tconst transport = options.fetch ?? globalThis.fetch;\n\tif (typeof transport !== \"function\")\n\t\tthrow new NodeReleasePackageSourceErrorV1(\"invalid_configuration\", \"Node fetch is unavailable\");\n\tconst githubOrigin = apiOrigin(options.githubApiOrigin ?? DEFAULT_GITHUB_API_ORIGIN_V1, \"githubApiOrigin\");\n\tconst giteeOrigin = apiOrigin(options.giteeApiOrigin ?? DEFAULT_GITEE_API_ORIGIN_V1, \"giteeApiOrigin\");\n\tconst githubToken = boundedToken(options.githubToken, \"githubToken\");\n\tconst giteeToken = boundedToken(options.giteeToken, \"giteeToken\");\n\tconst timeoutMs = boundedPositive(\n\t\toptions.requestTimeoutMs,\n\t\tDEFAULT_TIMEOUT_MS_V1,\n\t\tMAX_TIMEOUT_MS_V1,\n\t\t\"requestTimeoutMs\",\n\t);\n\tconst maxResponseBytes = boundedPositive(\n\t\toptions.maxResponseBytes,\n\t\tDEFAULT_MAX_RESPONSE_BYTES_V1,\n\t\tMAX_RESPONSE_BYTES_V1,\n\t\t\"maxResponseBytes\",\n\t);\n\tconst maxAssetBytes = boundedPositive(\n\t\toptions.maxAssetBytes,\n\t\tDEFAULT_MAX_ASSET_BYTES_V1,\n\t\tMAX_ASSET_BYTES_V1,\n\t\t\"maxAssetBytes\",\n\t);\n\tconst maxRedirects = options.maxRedirects ?? DEFAULT_REDIRECTS_V1;\n\tif (!Number.isSafeInteger(maxRedirects) || maxRedirects < 0 || maxRedirects > MAX_REDIRECTS_V1)\n\t\tthrow new NodeReleasePackageSourceErrorV1(\n\t\t\t\"invalid_configuration\",\n\t\t\t`maxRedirects must be an integer between 0 and ${MAX_REDIRECTS_V1}`,\n\t\t);\n\tconst userAgent = options.userAgent ?? \"agent-forge-plugin-release/1\";\n\tif (userAgent.length === 0 || userAgent.length > 256 || /[\\r\\n]/u.test(userAgent))\n\t\tthrow new NodeReleasePackageSourceErrorV1(\"invalid_configuration\", \"userAgent is invalid\");\n\n\tconst fetchReleaseJson = async (\n\t\turl: URL,\n\t\theaders: Readonly<Record<string, string>>,\n\t\tparentSignal: AbortSignal | undefined,\n\t): Promise<Uint8Array> => {\n\t\tlet current = url;\n\t\tfor (let redirect = 0; ; redirect += 1) {\n\t\t\tconst request = requestSignal(parentSignal, timeoutMs);\n\t\t\tlet response: Response;\n\t\t\ttry {\n\t\t\t\tresponse = await transport(current.toString(), {\n\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\theaders: { accept: \"application/json\", \"user-agent\": userAgent, ...headers },\n\t\t\t\t\tredirect: \"manual\",\n\t\t\t\t\tsignal: request.signal,\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\trequest.cleanup();\n\t\t\t\tif (request.timedOut())\n\t\t\t\t\tthrow new NodeReleasePackageSourceErrorV1(\"request_timed_out\", \"release API request timed out\");\n\t\t\t\tif (isAbortLike(error))\n\t\t\t\t\tthrow new NodeReleasePackageSourceErrorV1(\"cancelled\", \"release API request was cancelled\");\n\t\t\t\tthrow new NodeReleasePackageSourceErrorV1(\"request_failed\", \"release API request failed\");\n\t\t\t}\n\t\t\tif (!REDIRECT_STATUS.has(response.status)) {\n\t\t\t\ttry {\n\t\t\t\t\tif (response.status === 404)\n\t\t\t\t\t\tthrow new NodeReleasePackageSourceErrorV1(\"release_not_found\", \"repo or release was not found\");\n\t\t\t\t\tconst limit = rateLimitState(response);\n\t\t\t\t\tif (limit.limited) {\n\t\t\t\t\t\tconst message =\n\t\t\t\t\t\t\tlimit.resetEpochSeconds === undefined\n\t\t\t\t\t\t\t\t? \"rate limit was exceeded\"\n\t\t\t\t\t\t\t\t: `rate limit resets at ${new Date(limit.resetEpochSeconds * 1000).toISOString()}`;\n\t\t\t\t\t\tthrow new NodeReleasePackageSourceErrorV1(\"rate_limited\", message, {\n\t\t\t\t\t\t\t...(limit.resetEpochSeconds === undefined ? {} : { resetEpochSeconds: limit.resetEpochSeconds }),\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tif (response.status < 200 || response.status >= 300)\n\t\t\t\t\t\tthrow new NodeReleasePackageSourceErrorV1(\"request_failed\", \"release API request did not succeed\");\n\t\t\t\t\tif (!isJsonResponse(response))\n\t\t\t\t\t\tthrow new NodeReleasePackageSourceErrorV1(\"invalid_response\", \"release API response must be JSON\");\n\t\t\t\t\tconst bytes = await readBody(response, maxResponseBytes, request.signal);\n\t\t\t\t\treturn bytes;\n\t\t\t\t} finally {\n\t\t\t\t\tawait response.body?.cancel().catch(() => undefined);\n\t\t\t\t\trequest.cleanup();\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst location = response.headers.get(\"location\");\n\t\t\tawait response.body?.cancel().catch(() => undefined);\n\t\t\trequest.cleanup();\n\t\t\tif (location === null || redirect >= maxRedirects)\n\t\t\t\tthrow new NodeReleasePackageSourceErrorV1(\"request_failed\", \"release API redirect limit exceeded\");\n\t\t\tlet next: URL;\n\t\t\ttry {\n\t\t\t\tnext = new URL(location, current);\n\t\t\t} catch {\n\t\t\t\tthrow new NodeReleasePackageSourceErrorV1(\"invalid_response\", \"release API redirect target is invalid\");\n\t\t\t}\n\t\t\tif ((next.protocol !== \"http:\" && next.protocol !== \"https:\") || next.username !== \"\" || next.password !== \"\")\n\t\t\t\tthrow new NodeReleasePackageSourceErrorV1(\"invalid_response\", \"release API redirect must stay http(s)\");\n\t\t\tcurrent = next;\n\t\t}\n\t};\n\n\tconst downloadReleaseAsset: NodeReleasePackageSourceV1[\"downloadReleaseAsset\"] = async (input) => {\n\t\tif (input.signal?.aborted === true)\n\t\t\tthrow new NodeReleasePackageSourceErrorV1(\"cancelled\", \"release asset download was cancelled\");\n\t\tconst sourceLabel = `${input.kind}:${input.owner}/${input.repo}@${input.tag ?? \"latest\"}`;\n\t\tconst base = input.kind === \"github\" ? githubOrigin : giteeOrigin;\n\t\tconst segments = [\n\t\t\tbase.pathPrefix === \"\" ? undefined : base.pathPrefix,\n\t\t\t\"repos\",\n\t\t\tencodeURIComponent(input.owner),\n\t\t\tencodeURIComponent(input.repo),\n\t\t\t\"releases\",\n\t\t\t...(input.tag === undefined ? [] : [\"tags\", encodeURIComponent(input.tag)]),\n\t\t].filter((segment): segment is string => segment !== undefined);\n\t\tconst endpoint = new URL(`${base.origin}/${segments.join(\"/\")}`);\n\t\tconst headers: Readonly<Record<string, string>> =\n\t\t\tinput.kind === \"github\"\n\t\t\t\t? {\n\t\t\t\t\t\t\"x-github-api-version\": \"2022-11-28\",\n\t\t\t\t\t\t...(githubToken === undefined ? {} : { authorization: `Bearer ${githubToken}` }),\n\t\t\t\t\t}\n\t\t\t\t: {};\n\t\tif (input.kind === \"gitee\" && giteeToken !== undefined) endpoint.searchParams.set(\"access_token\", giteeToken);\n\t\tconst payload = await fetchReleaseJson(endpoint, headers, input.signal);\n\t\tconst release =\n\t\t\tinput.tag === undefined ? firstPublishedRelease(parseReleaseList(payload)) : parseReleaseObject(payload);\n\t\tconst assetUrl = selectPackageAssetUrl(release);\n\t\tconst download = await downloadNodeUrlPackageV1(\n\t\t\t{\n\t\t\t\t...(options.fetch === undefined ? {} : { fetch: options.fetch }),\n\t\t\t\trequestTimeoutMs: timeoutMs,\n\t\t\t\tmaxPackageBytes: maxAssetBytes,\n\t\t\t\tuserAgent,\n\t\t\t},\n\t\t\t{\n\t\t\t\turl: assetUrl,\n\t\t\t\t...(input.expectedDigestHex === undefined ? {} : { expectedDigestHex: input.expectedDigestHex }),\n\t\t\t\tsignal: input.signal,\n\t\t\t},\n\t\t);\n\t\treturn {\n\t\t\tbytes: download.bytes,\n\t\t\tmediaType: download.mediaType,\n\t\t\tsha256Hex: download.digestHex,\n\t\t\tsourceLabel,\n\t\t};\n\t};\n\n\treturn { version: 1, downloadReleaseAsset };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"node-release-package-source.js","sourceRoot":"","sources":["../../../src/plugins/ecosystem/node-release-package-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,0BAA0B,CAAC;AAC7C,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAExE;;;;;;;;;;;;;;GAcG;AAEH,MAAM,4BAA4B,GAAG,wBAAwB,CAAC;AAC9D,MAAM,2BAA2B,GAAG,0BAA0B,CAAC;AAC/D,MAAM,qBAAqB,GAAG,MAAM,CAAC;AACrC,MAAM,iBAAiB,GAAG,OAAO,CAAC;AAClC,MAAM,6BAA6B,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AACtD,MAAM,qBAAqB,GAAG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YACC,GAAG,CAAC,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC;YAChE,gBAAgB,EAAE,SAAS;YAC3B,eAAe,EAAE,aAAa;YAC9B,SAAS;SACT,EACD;YACC,GAAG,EAAE,QAAQ;YACb,GAAG,CAAC,KAAK,CAAC,iBAAiB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAChG,MAAM,EAAE,KAAK,CAAC,MAAM;SACpB,CACD,CAAC;QACF,OAAO;YACN,KAAK,EAAE,QAAQ,CAAC,KAAK;YACrB,SAAS,EAAE,QAAQ,CAAC,SAAS;YAC7B,SAAS,EAAE,QAAQ,CAAC,SAAS;YAC7B,WAAW;SACX,CAAC;IAAA,CACF,CAAC;IAEF,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,oBAAoB,EAAE,CAAC;AAAA,CAC5C","sourcesContent":["import { t } from \"../../core/i18n/index.ts\";\nimport { downloadNodeUrlPackageV1 } from \"./node-url-package-source.ts\";\n\n/**\n * GitHub/Gitee release plugin package source (design\n * `插件独立分发与启动装配设计.md` §4.6 \"GitHub\"/\"Gitee\" rows). Two-step\n * protocol: resolve one release through the repo's release API — the exact\n * tag endpoint when a tag is given, otherwise the first non-draft entry of\n * the first releases page in API order (no client-side sorting) — then pick\n * the release's single `.zip`/`.tgz` asset and download it with the same\n * bounded http(s) semantics as custom URL packages (redirect-per-hop, budget,\n * timeout, optional strong sha256). Zero or multiple matching assets are\n * explicit structured errors listing the asset names; nothing is guessed.\n * Authentication is optional: GitHub uses an `Authorization: Bearer` header,\n * Gitee an `access_token` query parameter. Anonymous rate limits (403/429\n * with `X-RateLimit-Remaining: 0`, or any 429) surface as `rate_limited`\n * carrying the advertised `X-RateLimit-Reset` epoch; there is no retry.\n */\n\nconst DEFAULT_GITHUB_API_ORIGIN_V1 = \"https://api.github.com\";\nconst DEFAULT_GITEE_API_ORIGIN_V1 = \"https://gitee.com/api/v5\";\nconst DEFAULT_TIMEOUT_MS_V1 = 15_000;\nconst MAX_TIMEOUT_MS_V1 = 120_000;\nconst DEFAULT_MAX_RESPONSE_BYTES_V1 = 8 * 1024 * 1024;\nconst MAX_RESPONSE_BYTES_V1 = 16 * 1024 * 1024;\nconst DEFAULT_MAX_ASSET_BYTES_V1 = 128 * 1024 * 1024;\nconst MAX_ASSET_BYTES_V1 = 512 * 1024 * 1024;\nconst DEFAULT_REDIRECTS_V1 = 3;\nconst MAX_REDIRECTS_V1 = 5;\nconst REDIRECT_STATUS = new Set([301, 302, 303, 307, 308]);\n\nexport type NodeReleasePackageSourceErrorCodeV1 =\n\t| \"cancelled\"\n\t| \"invalid_configuration\"\n\t| \"request_failed\"\n\t| \"request_timed_out\"\n\t| \"invalid_response\"\n\t| \"response_too_large\"\n\t| \"release_not_found\"\n\t| \"release_asset_not_found\"\n\t| \"release_asset_ambiguous\"\n\t| \"rate_limited\";\n\nexport class NodeReleasePackageSourceErrorV1 extends Error {\n\treadonly code: NodeReleasePackageSourceErrorCodeV1;\n\t/** Unix epoch seconds advertised by `X-RateLimit-Reset`; present only for `rate_limited`. */\n\treadonly resetEpochSeconds?: number;\n\n\tconstructor(\n\t\tcode: NodeReleasePackageSourceErrorCodeV1,\n\t\tmessage: string,\n\t\toptions?: { readonly resetEpochSeconds?: number },\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"NodeReleasePackageSourceErrorV1\";\n\t\tthis.code = code;\n\t\tif (options?.resetEpochSeconds !== undefined) this.resetEpochSeconds = options.resetEpochSeconds;\n\t}\n}\n\nexport interface NodeReleasePackageSourceOptionsV1 {\n\t/** Bare http(s) GitHub API origin; defaults to `https://api.github.com`. */\n\treadonly githubApiOrigin?: string;\n\t/** Bare http(s) Gitee API origin; defaults to `https://gitee.com/api/v5`. */\n\treadonly giteeApiOrigin?: string;\n\t/** Optional GitHub API token sent as a bearer header. */\n\treadonly githubToken?: string;\n\t/** Optional Gitee API token sent as an `access_token` query parameter. */\n\treadonly giteeToken?: string;\n\t/** Real fetch or a deterministic test replacement. */\n\treadonly fetch?: typeof globalThis.fetch;\n\treadonly requestTimeoutMs?: number;\n\treadonly maxResponseBytes?: number;\n\treadonly maxAssetBytes?: number;\n\treadonly maxRedirects?: number;\n\treadonly userAgent?: string;\n}\n\nexport interface NodeReleaseAssetDownloadV1 {\n\treadonly bytes: Uint8Array;\n\treadonly mediaType: \"application/zip\" | \"application/gzip\";\n\treadonly sha256Hex: string;\n\t/** `github:<owner>/<repo>@<tag|latest>` or the `gitee:` equivalent. */\n\treadonly sourceLabel: string;\n}\n\nexport interface NodeReleasePackageSourceV1 {\n\treadonly version: 1;\n\treadonly downloadReleaseAsset: (input: {\n\t\treadonly kind: \"github\" | \"gitee\";\n\t\treadonly owner: string;\n\t\treadonly repo: string;\n\t\treadonly tag?: string;\n\t\treadonly expectedDigestHex?: string;\n\t\treadonly signal?: AbortSignal;\n\t}) => Promise<NodeReleaseAssetDownloadV1>;\n}\n\ninterface ReleaseAssetShapeV1 {\n\treadonly name?: unknown;\n\treadonly browser_download_url?: unknown;\n}\n\ninterface ReleaseShapeV1 {\n\treadonly draft?: unknown;\n\treadonly assets?: unknown;\n}\n\nfunction boundedPositive(value: number | undefined, fallback: number, maximum: number, label: string): number {\n\tconst result = value ?? fallback;\n\tif (!Number.isSafeInteger(result) || result <= 0 || result > maximum)\n\t\tthrow new NodeReleasePackageSourceErrorV1(\n\t\t\t\"invalid_configuration\",\n\t\t\tt(\"{label} must be a positive integer at most {maximum}\", { label, maximum }),\n\t\t);\n\treturn result;\n}\n\nfunction boundedToken(value: string | undefined, label: string): string | undefined {\n\tif (value === undefined) return undefined;\n\tif (value.length === 0 || value.length > 4096 || /[\\r\\n\\s]/u.test(value))\n\t\tthrow new NodeReleasePackageSourceErrorV1(\"invalid_configuration\", t(\"{label} is invalid\", { label }));\n\treturn value;\n}\n\nfunction apiOrigin(value: string, label: string): { readonly origin: string; readonly pathPrefix: string } {\n\tlet parsed: URL;\n\ttry {\n\t\tparsed = new URL(value);\n\t} catch {\n\t\tthrow new NodeReleasePackageSourceErrorV1(\"invalid_configuration\", t(\"{label} is invalid\", { label }));\n\t}\n\tif (\n\t\t(parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") ||\n\t\tparsed.username !== \"\" ||\n\t\tparsed.password !== \"\"\n\t)\n\t\tthrow new NodeReleasePackageSourceErrorV1(\n\t\t\t\"invalid_configuration\",\n\t\t\tt(\"{label} must be http(s) without credentials\", { label }),\n\t\t);\n\tif (parsed.search !== \"\" || parsed.hash !== \"\")\n\t\tthrow new NodeReleasePackageSourceErrorV1(\n\t\t\t\"invalid_configuration\",\n\t\t\tt(\"{label} must not include a query or fragment\", { label }),\n\t\t);\n\t// The Gitee default origin carries the `/api/v5` path prefix. The prefix is\n\t// kept as a plain string because a URL normalizes an empty pathname back\n\t// to \"/\", which would reintroduce a double slash when joining endpoints.\n\tconst trimmed = parsed.pathname.replace(/\\/+$/u, \"\");\n\treturn { origin: parsed.origin, pathPrefix: trimmed === \"\" || trimmed === \"/\" ? \"\" : trimmed.replace(/^\\//u, \"\") };\n}\n\nfunction jsonBytes(value: Uint8Array): unknown {\n\ttry {\n\t\treturn JSON.parse(new TextDecoder(\"utf-8\", { fatal: true }).decode(value));\n\t} catch {\n\t\tthrow new NodeReleasePackageSourceErrorV1(\"invalid_response\", t(\"release API response is not valid JSON\"));\n\t}\n}\n\nfunction parseReleaseList(bytes: Uint8Array): readonly ReleaseShapeV1[] {\n\tconst value = jsonBytes(bytes);\n\tif (!Array.isArray(value))\n\t\tthrow new NodeReleasePackageSourceErrorV1(\"invalid_response\", t(\"release API response is not a release list\"));\n\treturn value as readonly ReleaseShapeV1[];\n}\n\nfunction parseReleaseObject(bytes: Uint8Array): ReleaseShapeV1 {\n\tconst value = jsonBytes(bytes);\n\tif (typeof value !== \"object\" || value === null || Array.isArray(value))\n\t\tthrow new NodeReleasePackageSourceErrorV1(\"invalid_response\", t(\"release API response is not a release object\"));\n\treturn value as ReleaseShapeV1;\n}\n\n/** First non-draft entry in API order; the array itself is the ordering contract. */\nfunction firstPublishedRelease(releases: readonly ReleaseShapeV1[]): ReleaseShapeV1 {\n\tconst published = releases.find((release) => release.draft !== true);\n\tif (published === undefined)\n\t\tthrow new NodeReleasePackageSourceErrorV1(\"release_not_found\", t(\"repo has no published release\"));\n\treturn published;\n}\n\ninterface ReleaseAssetNameV1 {\n\treadonly name: string;\n\treadonly url: unknown;\n}\n\n/** Assets with a usable name; entries without a string name are ignored as API noise. */\nfunction namedAssets(release: ReleaseShapeV1): readonly ReleaseAssetNameV1[] {\n\tif (release.assets === undefined) return [];\n\tif (!Array.isArray(release.assets))\n\t\tthrow new NodeReleasePackageSourceErrorV1(\"invalid_response\", t(\"release assets are invalid\"));\n\tconst entries: ReleaseAssetNameV1[] = [];\n\tfor (const asset of release.assets) {\n\t\tif (typeof asset !== \"object\" || asset === null) continue;\n\t\tconst shape = asset as ReleaseAssetShapeV1;\n\t\tif (typeof shape.name !== \"string\" || shape.name.length === 0) continue;\n\t\tentries.push({ name: shape.name, url: shape.browser_download_url });\n\t}\n\treturn entries;\n}\n\nfunction isPackageAssetName(name: string): boolean {\n\tconst value = name.toLowerCase();\n\treturn value.endsWith(\".zip\") || value.endsWith(\".tgz\");\n}\n\n/** Select the release's single `.zip`/`.tgz` asset and return its download URL. */\nfunction selectPackageAssetUrl(release: ReleaseShapeV1): string {\n\tconst assets = namedAssets(release);\n\tconst candidates = assets.filter((asset) => isPackageAssetName(asset.name));\n\tconst assetNames = assets.map((asset) => asset.name).join(\", \");\n\tif (candidates.length === 0)\n\t\tthrow new NodeReleasePackageSourceErrorV1(\n\t\t\t\"release_asset_not_found\",\n\t\t\tassetNames.length === 0 ? t(\"release has no assets\") : t(\"assets: {names}\", { names: assetNames }),\n\t\t);\n\tif (candidates.length > 1)\n\t\tthrow new NodeReleasePackageSourceErrorV1(\n\t\t\t\"release_asset_ambiguous\",\n\t\t\tt(\"candidates: {names}\", { names: candidates.map((asset) => asset.name).join(\", \") }),\n\t\t);\n\tconst chosen = candidates[0]!;\n\tif (typeof chosen.url !== \"string\" || chosen.url.length === 0)\n\t\tthrow new NodeReleasePackageSourceErrorV1(\"invalid_response\", t(\"release asset has no download URL\"));\n\treturn chosen.url;\n}\n\nfunction isAbortLike(error: unknown): boolean {\n\treturn error instanceof Error && (error.name === \"AbortError\" || error.name === \"AbortSignalError\");\n}\n\ninterface RequestSignal {\n\treadonly signal: AbortSignal;\n\treadonly timedOut: () => boolean;\n\treadonly cleanup: () => void;\n}\n\nfunction requestSignal(parent: AbortSignal | undefined, timeoutMs: number): RequestSignal {\n\tconst controller = new AbortController();\n\tlet timedOut = false;\n\tconst abort = () => controller.abort(parent?.reason);\n\tif (parent?.aborted === true) abort();\n\telse parent?.addEventListener(\"abort\", abort, { once: true });\n\tconst timeout = setTimeout(() => {\n\t\ttimedOut = true;\n\t\tcontroller.abort();\n\t}, timeoutMs);\n\treturn {\n\t\tsignal: controller.signal,\n\t\ttimedOut: () => timedOut,\n\t\tcleanup: () => {\n\t\t\tclearTimeout(timeout);\n\t\t\tparent?.removeEventListener(\"abort\", abort);\n\t\t},\n\t};\n}\n\nfunction isJsonResponse(response: Response): boolean {\n\tconst contentType = response.headers.get(\"content-type\");\n\tif (contentType === null) return false;\n\tconst mediaType = contentType.split(\";\", 1)[0]?.trim().toLowerCase();\n\treturn mediaType === \"application/json\" || mediaType === \"application/vnd.github+json\";\n}\n\n/**\n * Rate-limit verdict for 403/429 responses: any 429, and a 403 whose\n * `X-RateLimit-Remaining` is exactly `0`. The reset epoch is passed through\n * verbatim when present and integer-like; absent headers stay absent.\n */\nfunction rateLimitState(response: Response): { readonly limited: boolean; readonly resetEpochSeconds?: number } {\n\tconst limited =\n\t\tresponse.status === 429 || (response.status === 403 && response.headers.get(\"x-ratelimit-remaining\") === \"0\");\n\tif (!limited) return { limited: false };\n\tconst reset = response.headers.get(\"x-ratelimit-reset\");\n\tconst resetValue = reset === null ? Number.NaN : Number.parseInt(reset, 10);\n\tif (!Number.isSafeInteger(resetValue) || resetValue < 0) return { limited: true };\n\treturn { limited: true, resetEpochSeconds: resetValue };\n}\n\nasync function readBody(response: Response, maxBytes: number, signal: AbortSignal): Promise<Uint8Array> {\n\tif (response.body === null)\n\t\tthrow new NodeReleasePackageSourceErrorV1(\"invalid_response\", t(\"release API response has no body\"));\n\tconst reader = response.body.getReader();\n\tconst chunks: Uint8Array[] = [];\n\tlet total = 0;\n\ttry {\n\t\tfor (;;) {\n\t\t\tif (signal.aborted) throw new DOMException(t(\"aborted\"), \"AbortError\");\n\t\t\tconst item = await reader.read();\n\t\t\tif (item.done) break;\n\t\t\ttotal += item.value.byteLength;\n\t\t\tif (total > maxBytes)\n\t\t\t\tthrow new NodeReleasePackageSourceErrorV1(\n\t\t\t\t\t\"response_too_large\",\n\t\t\t\t\tt(\"release API response exceeds the configured size limit\"),\n\t\t\t\t);\n\t\t\tchunks.push(item.value);\n\t\t}\n\t} finally {\n\t\treader.releaseLock();\n\t}\n\tconst bytes = new Uint8Array(total);\n\tlet offset = 0;\n\tfor (const chunk of chunks) {\n\t\tbytes.set(chunk, offset);\n\t\toffset += chunk.byteLength;\n\t}\n\treturn bytes;\n}\n\n/** Create the bounded GitHub/Gitee release reader. */\nexport function createNodeReleasePackageSourceV1(\n\toptions: NodeReleasePackageSourceOptionsV1 = {},\n): NodeReleasePackageSourceV1 {\n\tconst transport = options.fetch ?? globalThis.fetch;\n\tif (typeof transport !== \"function\")\n\t\tthrow new NodeReleasePackageSourceErrorV1(\"invalid_configuration\", t(\"Node fetch is unavailable\"));\n\tconst githubOrigin = apiOrigin(options.githubApiOrigin ?? DEFAULT_GITHUB_API_ORIGIN_V1, \"githubApiOrigin\");\n\tconst giteeOrigin = apiOrigin(options.giteeApiOrigin ?? DEFAULT_GITEE_API_ORIGIN_V1, \"giteeApiOrigin\");\n\tconst githubToken = boundedToken(options.githubToken, \"githubToken\");\n\tconst giteeToken = boundedToken(options.giteeToken, \"giteeToken\");\n\tconst timeoutMs = boundedPositive(\n\t\toptions.requestTimeoutMs,\n\t\tDEFAULT_TIMEOUT_MS_V1,\n\t\tMAX_TIMEOUT_MS_V1,\n\t\t\"requestTimeoutMs\",\n\t);\n\tconst maxResponseBytes = boundedPositive(\n\t\toptions.maxResponseBytes,\n\t\tDEFAULT_MAX_RESPONSE_BYTES_V1,\n\t\tMAX_RESPONSE_BYTES_V1,\n\t\t\"maxResponseBytes\",\n\t);\n\tconst maxAssetBytes = boundedPositive(\n\t\toptions.maxAssetBytes,\n\t\tDEFAULT_MAX_ASSET_BYTES_V1,\n\t\tMAX_ASSET_BYTES_V1,\n\t\t\"maxAssetBytes\",\n\t);\n\tconst maxRedirects = options.maxRedirects ?? DEFAULT_REDIRECTS_V1;\n\tif (!Number.isSafeInteger(maxRedirects) || maxRedirects < 0 || maxRedirects > MAX_REDIRECTS_V1)\n\t\tthrow new NodeReleasePackageSourceErrorV1(\n\t\t\t\"invalid_configuration\",\n\t\t\tt(\"maxRedirects must be an integer between 0 and {max}\", { max: MAX_REDIRECTS_V1 }),\n\t\t);\n\tconst userAgent = options.userAgent ?? \"agent-forge-plugin-release/1\";\n\tif (userAgent.length === 0 || userAgent.length > 256 || /[\\r\\n]/u.test(userAgent))\n\t\tthrow new NodeReleasePackageSourceErrorV1(\"invalid_configuration\", t(\"userAgent is invalid\"));\n\n\tconst fetchReleaseJson = async (\n\t\turl: URL,\n\t\theaders: Readonly<Record<string, string>>,\n\t\tparentSignal: AbortSignal | undefined,\n\t): Promise<Uint8Array> => {\n\t\tlet current = url;\n\t\tfor (let redirect = 0; ; redirect += 1) {\n\t\t\tconst request = requestSignal(parentSignal, timeoutMs);\n\t\t\tlet response: Response;\n\t\t\ttry {\n\t\t\t\tresponse = await transport(current.toString(), {\n\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\theaders: { accept: \"application/json\", \"user-agent\": userAgent, ...headers },\n\t\t\t\t\tredirect: \"manual\",\n\t\t\t\t\tsignal: request.signal,\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\trequest.cleanup();\n\t\t\t\tif (request.timedOut())\n\t\t\t\t\tthrow new NodeReleasePackageSourceErrorV1(\"request_timed_out\", t(\"release API request timed out\"));\n\t\t\t\tif (isAbortLike(error))\n\t\t\t\t\tthrow new NodeReleasePackageSourceErrorV1(\"cancelled\", t(\"release API request was cancelled\"));\n\t\t\t\tthrow new NodeReleasePackageSourceErrorV1(\"request_failed\", t(\"release API request failed\"));\n\t\t\t}\n\t\t\tif (!REDIRECT_STATUS.has(response.status)) {\n\t\t\t\ttry {\n\t\t\t\t\tif (response.status === 404)\n\t\t\t\t\t\tthrow new NodeReleasePackageSourceErrorV1(\"release_not_found\", t(\"repo or release was not found\"));\n\t\t\t\t\tconst limit = rateLimitState(response);\n\t\t\t\t\tif (limit.limited) {\n\t\t\t\t\t\tconst message =\n\t\t\t\t\t\t\tlimit.resetEpochSeconds === undefined\n\t\t\t\t\t\t\t\t? \"rate limit was exceeded\"\n\t\t\t\t\t\t\t\t: `rate limit resets at ${new Date(limit.resetEpochSeconds * 1000).toISOString()}`;\n\t\t\t\t\t\tthrow new NodeReleasePackageSourceErrorV1(\"rate_limited\", message, {\n\t\t\t\t\t\t\t...(limit.resetEpochSeconds === undefined ? {} : { resetEpochSeconds: limit.resetEpochSeconds }),\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tif (response.status < 200 || response.status >= 300)\n\t\t\t\t\t\tthrow new NodeReleasePackageSourceErrorV1(\"request_failed\", t(\"release API request did not succeed\"));\n\t\t\t\t\tif (!isJsonResponse(response))\n\t\t\t\t\t\tthrow new NodeReleasePackageSourceErrorV1(\"invalid_response\", t(\"release API response must be JSON\"));\n\t\t\t\t\tconst bytes = await readBody(response, maxResponseBytes, request.signal);\n\t\t\t\t\treturn bytes;\n\t\t\t\t} finally {\n\t\t\t\t\tawait response.body?.cancel().catch(() => undefined);\n\t\t\t\t\trequest.cleanup();\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst location = response.headers.get(\"location\");\n\t\t\tawait response.body?.cancel().catch(() => undefined);\n\t\t\trequest.cleanup();\n\t\t\tif (location === null || redirect >= maxRedirects)\n\t\t\t\tthrow new NodeReleasePackageSourceErrorV1(\"request_failed\", t(\"release API redirect limit exceeded\"));\n\t\t\tlet next: URL;\n\t\t\ttry {\n\t\t\t\tnext = new URL(location, current);\n\t\t\t} catch {\n\t\t\t\tthrow new NodeReleasePackageSourceErrorV1(\"invalid_response\", t(\"release API redirect target is invalid\"));\n\t\t\t}\n\t\t\tif ((next.protocol !== \"http:\" && next.protocol !== \"https:\") || next.username !== \"\" || next.password !== \"\")\n\t\t\t\tthrow new NodeReleasePackageSourceErrorV1(\"invalid_response\", t(\"release API redirect must stay http(s)\"));\n\t\t\tcurrent = next;\n\t\t}\n\t};\n\n\tconst downloadReleaseAsset: NodeReleasePackageSourceV1[\"downloadReleaseAsset\"] = async (input) => {\n\t\tif (input.signal?.aborted === true)\n\t\t\tthrow new NodeReleasePackageSourceErrorV1(\"cancelled\", t(\"release asset download was cancelled\"));\n\t\tconst sourceLabel = `${input.kind}:${input.owner}/${input.repo}@${input.tag ?? \"latest\"}`;\n\t\tconst base = input.kind === \"github\" ? githubOrigin : giteeOrigin;\n\t\tconst segments = [\n\t\t\tbase.pathPrefix === \"\" ? undefined : base.pathPrefix,\n\t\t\t\"repos\",\n\t\t\tencodeURIComponent(input.owner),\n\t\t\tencodeURIComponent(input.repo),\n\t\t\t\"releases\",\n\t\t\t...(input.tag === undefined ? [] : [\"tags\", encodeURIComponent(input.tag)]),\n\t\t].filter((segment): segment is string => segment !== undefined);\n\t\tconst endpoint = new URL(`${base.origin}/${segments.join(\"/\")}`);\n\t\tconst headers: Readonly<Record<string, string>> =\n\t\t\tinput.kind === \"github\"\n\t\t\t\t? {\n\t\t\t\t\t\t\"x-github-api-version\": \"2022-11-28\",\n\t\t\t\t\t\t...(githubToken === undefined ? {} : { authorization: `Bearer ${githubToken}` }),\n\t\t\t\t\t}\n\t\t\t\t: {};\n\t\tif (input.kind === \"gitee\" && giteeToken !== undefined) endpoint.searchParams.set(\"access_token\", giteeToken);\n\t\tconst payload = await fetchReleaseJson(endpoint, headers, input.signal);\n\t\tconst release =\n\t\t\tinput.tag === undefined ? firstPublishedRelease(parseReleaseList(payload)) : parseReleaseObject(payload);\n\t\tconst assetUrl = selectPackageAssetUrl(release);\n\t\tconst download = await downloadNodeUrlPackageV1(\n\t\t\t{\n\t\t\t\t...(options.fetch === undefined ? {} : { fetch: options.fetch }),\n\t\t\t\trequestTimeoutMs: timeoutMs,\n\t\t\t\tmaxPackageBytes: maxAssetBytes,\n\t\t\t\tuserAgent,\n\t\t\t},\n\t\t\t{\n\t\t\t\turl: assetUrl,\n\t\t\t\t...(input.expectedDigestHex === undefined ? {} : { expectedDigestHex: input.expectedDigestHex }),\n\t\t\t\tsignal: input.signal,\n\t\t\t},\n\t\t);\n\t\treturn {\n\t\t\tbytes: download.bytes,\n\t\t\tmediaType: download.mediaType,\n\t\t\tsha256Hex: download.digestHex,\n\t\t\tsourceLabel,\n\t\t};\n\t};\n\n\treturn { version: 1, downloadReleaseAsset };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-tar-writer.d.ts","sourceRoot":"","sources":["../../../src/plugins/ecosystem/node-tar-writer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"node-tar-writer.d.ts","sourceRoot":"","sources":["../../../src/plugins/ecosystem/node-tar-writer.ts"],"names":[],"mappings":"AAoBA,MAAM,MAAM,wBAAwB,GAAG,eAAe,GAAG,qBAAqB,CAAC;AAE/E,qBAAa,oBAAqB,SAAQ,KAAK;IAC9C,QAAQ,CAAC,IAAI,EAAE,wBAAwB,CAAC;IAExC,YAAY,IAAI,EAAE,wBAAwB,EAAE,OAAO,EAAE,MAAM,EAI1D;CACD;AAED,MAAM,WAAW,oBAAoB;IACpC,8EAA8E;IAC9E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC;CAC5B;AA6ED,0EAA0E;AAC1E,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,SAAS,oBAAoB,EAAE,GAAG,UAAU,CAyBxF;AAED,kGAAkG;AAClG,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,SAAS,oBAAoB,EAAE,GAAG,UAAU,CAI1F","sourcesContent":["import { gzipSync } from \"node:zlib\";\nimport { t } from \"../../core/i18n/index.ts\";\nimport { normalizedEntryName } from \"./node-package-install-host.ts\";\n\n/**\n * Minimal deterministic ustar tar+gzip writer. It exists so a local plugin\n * directory can be packed into the same `application/gzip` package shape the\n * install host already parses (`node-tar-package.ts`), reusing its entry-name\n * normalization. Output is fully deterministic: fixed mode/uid/gid/mtime, no\n * uname/gname, sorted-free (callers pass entries in their chosen order), and\n * a gzip wrapper with a zero mtime.\n */\n\nconst TAR_BLOCK_BYTES_V1 = 512;\nconst TAR_NAME_LENGTH_V1 = 100;\nconst TAR_MODE_LENGTH_V1 = 8;\nconst TAR_SIZE_LENGTH_V1 = 12;\nconst TAR_CHECKSUM_LENGTH_V1 = 8;\nconst TAR_PREFIX_LENGTH_V1 = 155;\n\nexport type NodeTarWriterErrorCodeV1 = \"invalid_entry\" | \"entry_name_too_long\";\n\nexport class NodeTarWriterErrorV1 extends Error {\n\treadonly code: NodeTarWriterErrorCodeV1;\n\n\tconstructor(code: NodeTarWriterErrorCodeV1, message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"NodeTarWriterErrorV1\";\n\t\tthis.code = code;\n\t}\n}\n\nexport interface NodeTarWriterEntryV1 {\n\t/** Forward-slash normalized path; validated with the shared archive rules. */\n\treadonly name: string;\n\treadonly directory: boolean;\n\treadonly bytes?: Uint8Array;\n}\n\nfunction octalField(value: number, length: number): string {\n\tconst digits = length - 1;\n\tconst octal = value.toString(8);\n\tif (octal.length > digits) throw new NodeTarWriterErrorV1(\"invalid_entry\", t(\"tar header field overflows\"));\n\treturn `${octal.padStart(digits, \"0\")}\\0`;\n}\n\nfunction writeHeader(header: Uint8Array, entry: NodeTarWriterEntryV1, nameField: string, prefixField: string): void {\n\theader.fill(0);\n\tconst encode = (value: string, offset: number, length: number): void => {\n\t\tconst bytes = new TextEncoder().encode(value);\n\t\tif (bytes.byteLength > length)\n\t\t\tthrow new NodeTarWriterErrorV1(\"entry_name_too_long\", t(\"tar header name field overflows\"));\n\t\theader.set(bytes, offset);\n\t};\n\tencode(nameField, 0, TAR_NAME_LENGTH_V1 - 1);\n\tconst contentBytes = entry.directory ? 0 : (entry.bytes?.byteLength ?? 0);\n\tconst mode = octalField(entry.directory ? 0o755 : 0o644, TAR_MODE_LENGTH_V1);\n\tconst encodedMode = new TextEncoder().encode(mode);\n\theader.set(encodedMode, 100);\n\theader.set(new TextEncoder().encode(octalField(0, TAR_MODE_LENGTH_V1)), 108);\n\theader.set(new TextEncoder().encode(octalField(0, TAR_MODE_LENGTH_V1)), 116);\n\theader.set(new TextEncoder().encode(octalField(contentBytes, TAR_SIZE_LENGTH_V1)), 124);\n\theader.set(new TextEncoder().encode(octalField(0, TAR_SIZE_LENGTH_V1)), 136);\n\theader[156] = entry.directory ? 0x35 : 0x30;\n\tconst magic = new TextEncoder().encode(\"ustar\\0\");\n\theader.set(magic, 257);\n\theader.set(new TextEncoder().encode(\"00\"), 263);\n\tif (prefixField.length > 0) encode(prefixField, 345, TAR_PREFIX_LENGTH_V1 - 1);\n\tlet checksum = 0;\n\tfor (let index = 148; index < 148 + TAR_CHECKSUM_LENGTH_V1; index += 1) header[index] = 0x20;\n\tfor (const byte of header) checksum += byte;\n\tconst checksumText = `${checksum.toString(8).padStart(6, \"0\")}\\0 `;\n\theader.set(new TextEncoder().encode(checksumText), 148);\n}\n\nfunction entryFields(name: string): { readonly name: string; readonly prefix: string } {\n\tconst bytes = new TextEncoder().encode(name);\n\tif (bytes.byteLength <= TAR_NAME_LENGTH_V1 - 1) return { name, prefix: \"\" };\n\tlet split = -1;\n\tfor (let index = Math.min(bytes.byteLength, TAR_PREFIX_LENGTH_V1) - 1; index >= 0; index -= 1) {\n\t\tif (bytes[index] === 0x2f) {\n\t\t\tsplit = index;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (split <= 0)\n\t\tthrow new NodeTarWriterErrorV1(\"entry_name_too_long\", t(\"tar entry name cannot be split into ustar fields\"));\n\tconst prefix = name.slice(0, split);\n\tconst rest = name.slice(split + 1);\n\tconst restBytes = new TextEncoder().encode(rest);\n\tif (\n\t\trestBytes.byteLength > TAR_NAME_LENGTH_V1 - 1 ||\n\t\tnew TextEncoder().encode(prefix).byteLength > TAR_PREFIX_LENGTH_V1 - 1\n\t)\n\t\tthrow new NodeTarWriterErrorV1(\"entry_name_too_long\", t(\"tar entry name cannot be split into ustar fields\"));\n\treturn { name: rest, prefix };\n}\n\nfunction headerBlock(entry: NodeTarWriterEntryV1): Uint8Array {\n\tif (typeof entry.name !== \"string\" || entry.name.length === 0)\n\t\tthrow new NodeTarWriterErrorV1(\"invalid_entry\", t(\"tar entry name is invalid\"));\n\tconst normalized = normalizedEntryName(entry.directory ? `${entry.name}/` : entry.name);\n\tif (normalized.name !== entry.name)\n\t\tthrow new NodeTarWriterErrorV1(\"invalid_entry\", t(\"tar entry name is not normalized\"));\n\tif (entry.directory && entry.bytes !== undefined && entry.bytes.byteLength > 0)\n\t\tthrow new NodeTarWriterErrorV1(\"invalid_entry\", t(\"tar directory entry must be empty\"));\n\tif (!entry.directory && !(entry.bytes instanceof Uint8Array))\n\t\tthrow new NodeTarWriterErrorV1(\"invalid_entry\", t(\"tar file entry requires bytes\"));\n\tconst header = new Uint8Array(TAR_BLOCK_BYTES_V1);\n\tconst fields = entryFields(entry.name);\n\twriteHeader(header, entry, fields.name, fields.prefix);\n\treturn header;\n}\n\n/** Build deterministic ustar tar bytes (two zero EOF blocks included). */\nexport function buildNodeTarBytesV1(entries: readonly NodeTarWriterEntryV1[]): Uint8Array {\n\tif (!Array.isArray(entries)) throw new NodeTarWriterErrorV1(\"invalid_entry\", t(\"tar entries must be an array\"));\n\tconst names = new Set<string>();\n\tconst blocks: Uint8Array[] = [];\n\tfor (const entry of entries) {\n\t\tif (names.has(entry.name))\n\t\t\tthrow new NodeTarWriterErrorV1(\"invalid_entry\", t(\"duplicate tar entry name: {name}\", { name: entry.name }));\n\t\tnames.add(entry.name);\n\t\tblocks.push(headerBlock(entry));\n\t\tif (!entry.directory) {\n\t\t\tconst bytes = entry.bytes ?? new Uint8Array();\n\t\t\tconst padding = (TAR_BLOCK_BYTES_V1 - (bytes.byteLength % TAR_BLOCK_BYTES_V1)) % TAR_BLOCK_BYTES_V1;\n\t\t\tblocks.push(bytes, new Uint8Array(padding));\n\t\t}\n\t}\n\tblocks.push(new Uint8Array(TAR_BLOCK_BYTES_V1), new Uint8Array(TAR_BLOCK_BYTES_V1));\n\tlet total = 0;\n\tfor (const block of blocks) total += block.byteLength;\n\tconst output = new Uint8Array(total);\n\tlet offset = 0;\n\tfor (const block of blocks) {\n\t\toutput.set(block, offset);\n\t\toffset += block.byteLength;\n\t}\n\treturn output;\n}\n\n/** Build deterministic gzip-compressed ustar tar bytes (the `application/gzip` package shape). */\nexport function buildNodeTarGzBytesV1(entries: readonly NodeTarWriterEntryV1[]): Uint8Array {\n\t// Node's gzip wrapper writes a zero mtime header unless configured, so the\n\t// default compression is deterministic within one runtime.\n\treturn gzipSync(buildNodeTarBytesV1(entries));\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { gzipSync } from "node:zlib";
|
|
2
|
+
import { t } from "../../core/i18n/index.js";
|
|
2
3
|
import { normalizedEntryName } from "./node-package-install-host.js";
|
|
3
4
|
/**
|
|
4
5
|
* Minimal deterministic ustar tar+gzip writer. It exists so a local plugin
|
|
@@ -26,7 +27,7 @@ function octalField(value, length) {
|
|
|
26
27
|
const digits = length - 1;
|
|
27
28
|
const octal = value.toString(8);
|
|
28
29
|
if (octal.length > digits)
|
|
29
|
-
throw new NodeTarWriterErrorV1("invalid_entry", "tar header field overflows");
|
|
30
|
+
throw new NodeTarWriterErrorV1("invalid_entry", t("tar header field overflows"));
|
|
30
31
|
return `${octal.padStart(digits, "0")}\0`;
|
|
31
32
|
}
|
|
32
33
|
function writeHeader(header, entry, nameField, prefixField) {
|
|
@@ -34,7 +35,7 @@ function writeHeader(header, entry, nameField, prefixField) {
|
|
|
34
35
|
const encode = (value, offset, length) => {
|
|
35
36
|
const bytes = new TextEncoder().encode(value);
|
|
36
37
|
if (bytes.byteLength > length)
|
|
37
|
-
throw new NodeTarWriterErrorV1("entry_name_too_long", "tar header name field overflows");
|
|
38
|
+
throw new NodeTarWriterErrorV1("entry_name_too_long", t("tar header name field overflows"));
|
|
38
39
|
header.set(bytes, offset);
|
|
39
40
|
};
|
|
40
41
|
encode(nameField, 0, TAR_NAME_LENGTH_V1 - 1);
|
|
@@ -72,25 +73,25 @@ function entryFields(name) {
|
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
75
|
if (split <= 0)
|
|
75
|
-
throw new NodeTarWriterErrorV1("entry_name_too_long", "tar entry name cannot be split into ustar fields");
|
|
76
|
+
throw new NodeTarWriterErrorV1("entry_name_too_long", t("tar entry name cannot be split into ustar fields"));
|
|
76
77
|
const prefix = name.slice(0, split);
|
|
77
78
|
const rest = name.slice(split + 1);
|
|
78
79
|
const restBytes = new TextEncoder().encode(rest);
|
|
79
80
|
if (restBytes.byteLength > TAR_NAME_LENGTH_V1 - 1 ||
|
|
80
81
|
new TextEncoder().encode(prefix).byteLength > TAR_PREFIX_LENGTH_V1 - 1)
|
|
81
|
-
throw new NodeTarWriterErrorV1("entry_name_too_long", "tar entry name cannot be split into ustar fields");
|
|
82
|
+
throw new NodeTarWriterErrorV1("entry_name_too_long", t("tar entry name cannot be split into ustar fields"));
|
|
82
83
|
return { name: rest, prefix };
|
|
83
84
|
}
|
|
84
85
|
function headerBlock(entry) {
|
|
85
86
|
if (typeof entry.name !== "string" || entry.name.length === 0)
|
|
86
|
-
throw new NodeTarWriterErrorV1("invalid_entry", "tar entry name is invalid");
|
|
87
|
+
throw new NodeTarWriterErrorV1("invalid_entry", t("tar entry name is invalid"));
|
|
87
88
|
const normalized = normalizedEntryName(entry.directory ? `${entry.name}/` : entry.name);
|
|
88
89
|
if (normalized.name !== entry.name)
|
|
89
|
-
throw new NodeTarWriterErrorV1("invalid_entry", "tar entry name is not normalized");
|
|
90
|
+
throw new NodeTarWriterErrorV1("invalid_entry", t("tar entry name is not normalized"));
|
|
90
91
|
if (entry.directory && entry.bytes !== undefined && entry.bytes.byteLength > 0)
|
|
91
|
-
throw new NodeTarWriterErrorV1("invalid_entry", "tar directory entry must be empty");
|
|
92
|
+
throw new NodeTarWriterErrorV1("invalid_entry", t("tar directory entry must be empty"));
|
|
92
93
|
if (!entry.directory && !(entry.bytes instanceof Uint8Array))
|
|
93
|
-
throw new NodeTarWriterErrorV1("invalid_entry", "tar file entry requires bytes");
|
|
94
|
+
throw new NodeTarWriterErrorV1("invalid_entry", t("tar file entry requires bytes"));
|
|
94
95
|
const header = new Uint8Array(TAR_BLOCK_BYTES_V1);
|
|
95
96
|
const fields = entryFields(entry.name);
|
|
96
97
|
writeHeader(header, entry, fields.name, fields.prefix);
|
|
@@ -99,12 +100,12 @@ function headerBlock(entry) {
|
|
|
99
100
|
/** Build deterministic ustar tar bytes (two zero EOF blocks included). */
|
|
100
101
|
export function buildNodeTarBytesV1(entries) {
|
|
101
102
|
if (!Array.isArray(entries))
|
|
102
|
-
throw new NodeTarWriterErrorV1("invalid_entry", "tar entries must be an array");
|
|
103
|
+
throw new NodeTarWriterErrorV1("invalid_entry", t("tar entries must be an array"));
|
|
103
104
|
const names = new Set();
|
|
104
105
|
const blocks = [];
|
|
105
106
|
for (const entry of entries) {
|
|
106
107
|
if (names.has(entry.name))
|
|
107
|
-
throw new NodeTarWriterErrorV1("invalid_entry",
|
|
108
|
+
throw new NodeTarWriterErrorV1("invalid_entry", t("duplicate tar entry name: {name}", { name: entry.name }));
|
|
108
109
|
names.add(entry.name);
|
|
109
110
|
blocks.push(headerBlock(entry));
|
|
110
111
|
if (!entry.directory) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-tar-writer.js","sourceRoot":"","sources":["../../../src/plugins/ecosystem/node-tar-writer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAErE;;;;;;;GAOG;AAEH,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAC/B,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAC/B,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAC7B,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B,MAAM,sBAAsB,GAAG,CAAC,CAAC;AACjC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAIjC,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IACrC,IAAI,CAA2B;IAExC,YAAY,IAA8B,EAAE,OAAe,EAAE;QAC5D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAAA,CACjB;CACD;AASD,SAAS,UAAU,CAAC,KAAa,EAAE,MAAc,EAAU;IAC1D,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC;IAC1B,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAChC,IAAI,KAAK,CAAC,MAAM,GAAG,MAAM;QAAE,MAAM,IAAI,oBAAoB,CAAC,eAAe,EAAE,4BAA4B,CAAC,CAAC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,EAAE,MAAM,CAAC,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,UAAU,CAAC;IAC5B,CAAC;IACD,OAAO,MAAM,CAAC;AAAA,CACd;AAED,kGAAkG;AAClG,MAAM,UAAU,qBAAqB,CAAC,OAAwC,EAAc;IAC3F,2EAA2E;IAC3E,2DAA2D;IAC3D,OAAO,QAAQ,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC;AAAA,CAC9C","sourcesContent":["import { gzipSync } from \"node:zlib\";\nimport { normalizedEntryName } from \"./node-package-install-host.ts\";\n\n/**\n * Minimal deterministic ustar tar+gzip writer. It exists so a local plugin\n * directory can be packed into the same `application/gzip` package shape the\n * install host already parses (`node-tar-package.ts`), reusing its entry-name\n * normalization. Output is fully deterministic: fixed mode/uid/gid/mtime, no\n * uname/gname, sorted-free (callers pass entries in their chosen order), and\n * a gzip wrapper with a zero mtime.\n */\n\nconst TAR_BLOCK_BYTES_V1 = 512;\nconst TAR_NAME_LENGTH_V1 = 100;\nconst TAR_MODE_LENGTH_V1 = 8;\nconst TAR_SIZE_LENGTH_V1 = 12;\nconst TAR_CHECKSUM_LENGTH_V1 = 8;\nconst TAR_PREFIX_LENGTH_V1 = 155;\n\nexport type NodeTarWriterErrorCodeV1 = \"invalid_entry\" | \"entry_name_too_long\";\n\nexport class NodeTarWriterErrorV1 extends Error {\n\treadonly code: NodeTarWriterErrorCodeV1;\n\n\tconstructor(code: NodeTarWriterErrorCodeV1, message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"NodeTarWriterErrorV1\";\n\t\tthis.code = code;\n\t}\n}\n\nexport interface NodeTarWriterEntryV1 {\n\t/** Forward-slash normalized path; validated with the shared archive rules. */\n\treadonly name: string;\n\treadonly directory: boolean;\n\treadonly bytes?: Uint8Array;\n}\n\nfunction octalField(value: number, length: number): string {\n\tconst digits = length - 1;\n\tconst octal = value.toString(8);\n\tif (octal.length > digits) throw new NodeTarWriterErrorV1(\"invalid_entry\", \"tar header field overflows\");\n\treturn `${octal.padStart(digits, \"0\")}\\0`;\n}\n\nfunction writeHeader(header: Uint8Array, entry: NodeTarWriterEntryV1, nameField: string, prefixField: string): void {\n\theader.fill(0);\n\tconst encode = (value: string, offset: number, length: number): void => {\n\t\tconst bytes = new TextEncoder().encode(value);\n\t\tif (bytes.byteLength > length)\n\t\t\tthrow new NodeTarWriterErrorV1(\"entry_name_too_long\", \"tar header name field overflows\");\n\t\theader.set(bytes, offset);\n\t};\n\tencode(nameField, 0, TAR_NAME_LENGTH_V1 - 1);\n\tconst contentBytes = entry.directory ? 0 : (entry.bytes?.byteLength ?? 0);\n\tconst mode = octalField(entry.directory ? 0o755 : 0o644, TAR_MODE_LENGTH_V1);\n\tconst encodedMode = new TextEncoder().encode(mode);\n\theader.set(encodedMode, 100);\n\theader.set(new TextEncoder().encode(octalField(0, TAR_MODE_LENGTH_V1)), 108);\n\theader.set(new TextEncoder().encode(octalField(0, TAR_MODE_LENGTH_V1)), 116);\n\theader.set(new TextEncoder().encode(octalField(contentBytes, TAR_SIZE_LENGTH_V1)), 124);\n\theader.set(new TextEncoder().encode(octalField(0, TAR_SIZE_LENGTH_V1)), 136);\n\theader[156] = entry.directory ? 0x35 : 0x30;\n\tconst magic = new TextEncoder().encode(\"ustar\\0\");\n\theader.set(magic, 257);\n\theader.set(new TextEncoder().encode(\"00\"), 263);\n\tif (prefixField.length > 0) encode(prefixField, 345, TAR_PREFIX_LENGTH_V1 - 1);\n\tlet checksum = 0;\n\tfor (let index = 148; index < 148 + TAR_CHECKSUM_LENGTH_V1; index += 1) header[index] = 0x20;\n\tfor (const byte of header) checksum += byte;\n\tconst checksumText = `${checksum.toString(8).padStart(6, \"0\")}\\0 `;\n\theader.set(new TextEncoder().encode(checksumText), 148);\n}\n\nfunction entryFields(name: string): { readonly name: string; readonly prefix: string } {\n\tconst bytes = new TextEncoder().encode(name);\n\tif (bytes.byteLength <= TAR_NAME_LENGTH_V1 - 1) return { name, prefix: \"\" };\n\tlet split = -1;\n\tfor (let index = Math.min(bytes.byteLength, TAR_PREFIX_LENGTH_V1) - 1; index >= 0; index -= 1) {\n\t\tif (bytes[index] === 0x2f) {\n\t\t\tsplit = index;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (split <= 0)\n\t\tthrow new NodeTarWriterErrorV1(\"entry_name_too_long\", \"tar entry name cannot be split into ustar fields\");\n\tconst prefix = name.slice(0, split);\n\tconst rest = name.slice(split + 1);\n\tconst restBytes = new TextEncoder().encode(rest);\n\tif (\n\t\trestBytes.byteLength > TAR_NAME_LENGTH_V1 - 1 ||\n\t\tnew TextEncoder().encode(prefix).byteLength > TAR_PREFIX_LENGTH_V1 - 1\n\t)\n\t\tthrow new NodeTarWriterErrorV1(\"entry_name_too_long\", \"tar entry name cannot be split into ustar fields\");\n\treturn { name: rest, prefix };\n}\n\nfunction headerBlock(entry: NodeTarWriterEntryV1): Uint8Array {\n\tif (typeof entry.name !== \"string\" || entry.name.length === 0)\n\t\tthrow new NodeTarWriterErrorV1(\"invalid_entry\", \"tar entry name is invalid\");\n\tconst normalized = normalizedEntryName(entry.directory ? `${entry.name}/` : entry.name);\n\tif (normalized.name !== entry.name)\n\t\tthrow new NodeTarWriterErrorV1(\"invalid_entry\", \"tar entry name is not normalized\");\n\tif (entry.directory && entry.bytes !== undefined && entry.bytes.byteLength > 0)\n\t\tthrow new NodeTarWriterErrorV1(\"invalid_entry\", \"tar directory entry must be empty\");\n\tif (!entry.directory && !(entry.bytes instanceof Uint8Array))\n\t\tthrow new NodeTarWriterErrorV1(\"invalid_entry\", \"tar file entry requires bytes\");\n\tconst header = new Uint8Array(TAR_BLOCK_BYTES_V1);\n\tconst fields = entryFields(entry.name);\n\twriteHeader(header, entry, fields.name, fields.prefix);\n\treturn header;\n}\n\n/** Build deterministic ustar tar bytes (two zero EOF blocks included). */\nexport function buildNodeTarBytesV1(entries: readonly NodeTarWriterEntryV1[]): Uint8Array {\n\tif (!Array.isArray(entries)) throw new NodeTarWriterErrorV1(\"invalid_entry\", \"tar entries must be an array\");\n\tconst names = new Set<string>();\n\tconst blocks: Uint8Array[] = [];\n\tfor (const entry of entries) {\n\t\tif (names.has(entry.name))\n\t\t\tthrow new NodeTarWriterErrorV1(\"invalid_entry\", `duplicate tar entry name: ${entry.name}`);\n\t\tnames.add(entry.name);\n\t\tblocks.push(headerBlock(entry));\n\t\tif (!entry.directory) {\n\t\t\tconst bytes = entry.bytes ?? new Uint8Array();\n\t\t\tconst padding = (TAR_BLOCK_BYTES_V1 - (bytes.byteLength % TAR_BLOCK_BYTES_V1)) % TAR_BLOCK_BYTES_V1;\n\t\t\tblocks.push(bytes, new Uint8Array(padding));\n\t\t}\n\t}\n\tblocks.push(new Uint8Array(TAR_BLOCK_BYTES_V1), new Uint8Array(TAR_BLOCK_BYTES_V1));\n\tlet total = 0;\n\tfor (const block of blocks) total += block.byteLength;\n\tconst output = new Uint8Array(total);\n\tlet offset = 0;\n\tfor (const block of blocks) {\n\t\toutput.set(block, offset);\n\t\toffset += block.byteLength;\n\t}\n\treturn output;\n}\n\n/** Build deterministic gzip-compressed ustar tar bytes (the `application/gzip` package shape). */\nexport function buildNodeTarGzBytesV1(entries: readonly NodeTarWriterEntryV1[]): Uint8Array {\n\t// Node's gzip wrapper writes a zero mtime header unless configured, so the\n\t// default compression is deterministic within one runtime.\n\treturn gzipSync(buildNodeTarBytesV1(entries));\n}\n"]}
|
|
1
|
+
{"version":3,"file":"node-tar-writer.js","sourceRoot":"","sources":["../../../src/plugins/ecosystem/node-tar-writer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,CAAC,EAAE,MAAM,0BAA0B,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAErE;;;;;;;GAOG;AAEH,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAC/B,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAC/B,MAAM,kBAAkB,GAA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AK,CAAC,IAAI,CAAC,CAAC;QACtB,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;QAChC,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;YACtB,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,IAAI,UAAU,EAAE,CAAC;YAC9C,MAAM,OAAO,GAAG,CAAC,kBAAkB,GAAG,CAAC,KAAK,CAAC,UAAU,GAAG,kBAAkB,CAAC,CAAC,GAAG,kBAAkB,CAAC;YACpG,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;QAC7C,CAAC;IACF,CAAC;IACD,MAAM,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,kBAAkB,CAAC,EAAE,IAAI,UAAU,CAAC,kBAAkB,CAAC,CAAC,CAAC;IACpF,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,KAAK,IAAI,MAAM;QAAE,KAAK,IAAI,KAAK,CAAC,UAAU,CAAC;IACtD,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC;IACrC,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC5B,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,UAAU,CAAC;IAC5B,CAAC;IACD,OAAO,MAAM,CAAC;AAAA,CACd;AAED,kGAAkG;AAClG,MAAM,UAAU,qBAAqB,CAAC,OAAwC,EAAc;IAC3F,2EAA2E;IAC3E,2DAA2D;IAC3D,OAAO,QAAQ,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC;AAAA,CAC9C","sourcesContent":["import { gzipSync } from \"node:zlib\";\nimport { t } from \"../../core/i18n/index.ts\";\nimport { normalizedEntryName } from \"./node-package-install-host.ts\";\n\n/**\n * Minimal deterministic ustar tar+gzip writer. It exists so a local plugin\n * directory can be packed into the same `application/gzip` package shape the\n * install host already parses (`node-tar-package.ts`), reusing its entry-name\n * normalization. Output is fully deterministic: fixed mode/uid/gid/mtime, no\n * uname/gname, sorted-free (callers pass entries in their chosen order), and\n * a gzip wrapper with a zero mtime.\n */\n\nconst TAR_BLOCK_BYTES_V1 = 512;\nconst TAR_NAME_LENGTH_V1 = 100;\nconst TAR_MODE_LENGTH_V1 = 8;\nconst TAR_SIZE_LENGTH_V1 = 12;\nconst TAR_CHECKSUM_LENGTH_V1 = 8;\nconst TAR_PREFIX_LENGTH_V1 = 155;\n\nexport type NodeTarWriterErrorCodeV1 = \"invalid_entry\" | \"entry_name_too_long\";\n\nexport class NodeTarWriterErrorV1 extends Error {\n\treadonly code: NodeTarWriterErrorCodeV1;\n\n\tconstructor(code: NodeTarWriterErrorCodeV1, message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"NodeTarWriterErrorV1\";\n\t\tthis.code = code;\n\t}\n}\n\nexport interface NodeTarWriterEntryV1 {\n\t/** Forward-slash normalized path; validated with the shared archive rules. */\n\treadonly name: string;\n\treadonly directory: boolean;\n\treadonly bytes?: Uint8Array;\n}\n\nfunction octalField(value: number, length: number): string {\n\tconst digits = length - 1;\n\tconst octal = value.toString(8);\n\tif (octal.length > digits) throw new NodeTarWriterErrorV1(\"invalid_entry\", t(\"tar header field overflows\"));\n\treturn `${octal.padStart(digits, \"0\")}\\0`;\n}\n\nfunction writeHeader(header: Uint8Array, entry: NodeTarWriterEntryV1, nameField: string, prefixField: string): void {\n\theader.fill(0);\n\tconst encode = (value: string, offset: number, length: number): void => {\n\t\tconst bytes = new TextEncoder().encode(value);\n\t\tif (bytes.byteLength > length)\n\t\t\tthrow new NodeTarWriterErrorV1(\"entry_name_too_long\", t(\"tar header name field overflows\"));\n\t\theader.set(bytes, offset);\n\t};\n\tencode(nameField, 0, TAR_NAME_LENGTH_V1 - 1);\n\tconst contentBytes = entry.directory ? 0 : (entry.bytes?.byteLength ?? 0);\n\tconst mode = octalField(entry.directory ? 0o755 : 0o644, TAR_MODE_LENGTH_V1);\n\tconst encodedMode = new TextEncoder().encode(mode);\n\theader.set(encodedMode, 100);\n\theader.set(new TextEncoder().encode(octalField(0, TAR_MODE_LENGTH_V1)), 108);\n\theader.set(new TextEncoder().encode(octalField(0, TAR_MODE_LENGTH_V1)), 116);\n\theader.set(new TextEncoder().encode(octalField(contentBytes, TAR_SIZE_LENGTH_V1)), 124);\n\theader.set(new TextEncoder().encode(octalField(0, TAR_SIZE_LENGTH_V1)), 136);\n\theader[156] = entry.directory ? 0x35 : 0x30;\n\tconst magic = new TextEncoder().encode(\"ustar\\0\");\n\theader.set(magic, 257);\n\theader.set(new TextEncoder().encode(\"00\"), 263);\n\tif (prefixField.length > 0) encode(prefixField, 345, TAR_PREFIX_LENGTH_V1 - 1);\n\tlet checksum = 0;\n\tfor (let index = 148; index < 148 + TAR_CHECKSUM_LENGTH_V1; index += 1) header[index] = 0x20;\n\tfor (const byte of header) checksum += byte;\n\tconst checksumText = `${checksum.toString(8).padStart(6, \"0\")}\\0 `;\n\theader.set(new TextEncoder().encode(checksumText), 148);\n}\n\nfunction entryFields(name: string): { readonly name: string; readonly prefix: string } {\n\tconst bytes = new TextEncoder().encode(name);\n\tif (bytes.byteLength <= TAR_NAME_LENGTH_V1 - 1) return { name, prefix: \"\" };\n\tlet split = -1;\n\tfor (let index = Math.min(bytes.byteLength, TAR_PREFIX_LENGTH_V1) - 1; index >= 0; index -= 1) {\n\t\tif (bytes[index] === 0x2f) {\n\t\t\tsplit = index;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (split <= 0)\n\t\tthrow new NodeTarWriterErrorV1(\"entry_name_too_long\", t(\"tar entry name cannot be split into ustar fields\"));\n\tconst prefix = name.slice(0, split);\n\tconst rest = name.slice(split + 1);\n\tconst restBytes = new TextEncoder().encode(rest);\n\tif (\n\t\trestBytes.byteLength > TAR_NAME_LENGTH_V1 - 1 ||\n\t\tnew TextEncoder().encode(prefix).byteLength > TAR_PREFIX_LENGTH_V1 - 1\n\t)\n\t\tthrow new NodeTarWriterErrorV1(\"entry_name_too_long\", t(\"tar entry name cannot be split into ustar fields\"));\n\treturn { name: rest, prefix };\n}\n\nfunction headerBlock(entry: NodeTarWriterEntryV1): Uint8Array {\n\tif (typeof entry.name !== \"string\" || entry.name.length === 0)\n\t\tthrow new NodeTarWriterErrorV1(\"invalid_entry\", t(\"tar entry name is invalid\"));\n\tconst normalized = normalizedEntryName(entry.directory ? `${entry.name}/` : entry.name);\n\tif (normalized.name !== entry.name)\n\t\tthrow new NodeTarWriterErrorV1(\"invalid_entry\", t(\"tar entry name is not normalized\"));\n\tif (entry.directory && entry.bytes !== undefined && entry.bytes.byteLength > 0)\n\t\tthrow new NodeTarWriterErrorV1(\"invalid_entry\", t(\"tar directory entry must be empty\"));\n\tif (!entry.directory && !(entry.bytes instanceof Uint8Array))\n\t\tthrow new NodeTarWriterErrorV1(\"invalid_entry\", t(\"tar file entry requires bytes\"));\n\tconst header = new Uint8Array(TAR_BLOCK_BYTES_V1);\n\tconst fields = entryFields(entry.name);\n\twriteHeader(header, entry, fields.name, fields.prefix);\n\treturn header;\n}\n\n/** Build deterministic ustar tar bytes (two zero EOF blocks included). */\nexport function buildNodeTarBytesV1(entries: readonly NodeTarWriterEntryV1[]): Uint8Array {\n\tif (!Array.isArray(entries)) throw new NodeTarWriterErrorV1(\"invalid_entry\", t(\"tar entries must be an array\"));\n\tconst names = new Set<string>();\n\tconst blocks: Uint8Array[] = [];\n\tfor (const entry of entries) {\n\t\tif (names.has(entry.name))\n\t\t\tthrow new NodeTarWriterErrorV1(\"invalid_entry\", t(\"duplicate tar entry name: {name}\", { name: entry.name }));\n\t\tnames.add(entry.name);\n\t\tblocks.push(headerBlock(entry));\n\t\tif (!entry.directory) {\n\t\t\tconst bytes = entry.bytes ?? new Uint8Array();\n\t\t\tconst padding = (TAR_BLOCK_BYTES_V1 - (bytes.byteLength % TAR_BLOCK_BYTES_V1)) % TAR_BLOCK_BYTES_V1;\n\t\t\tblocks.push(bytes, new Uint8Array(padding));\n\t\t}\n\t}\n\tblocks.push(new Uint8Array(TAR_BLOCK_BYTES_V1), new Uint8Array(TAR_BLOCK_BYTES_V1));\n\tlet total = 0;\n\tfor (const block of blocks) total += block.byteLength;\n\tconst output = new Uint8Array(total);\n\tlet offset = 0;\n\tfor (const block of blocks) {\n\t\toutput.set(block, offset);\n\t\toffset += block.byteLength;\n\t}\n\treturn output;\n}\n\n/** Build deterministic gzip-compressed ustar tar bytes (the `application/gzip` package shape). */\nexport function buildNodeTarGzBytesV1(entries: readonly NodeTarWriterEntryV1[]): Uint8Array {\n\t// Node's gzip wrapper writes a zero mtime header unless configured, so the\n\t// default compression is deterministic within one runtime.\n\treturn gzipSync(buildNodeTarBytesV1(entries));\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-url-package-source.d.ts","sourceRoot":"","sources":["../../../src/plugins/ecosystem/node-url-package-source.ts"],"names":[],"mappings":"AACA,OAAO,EAAkC,KAAK,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAiBxG,MAAM,MAAM,+BAA+B,GACxC,WAAW,GACX,uBAAuB,GACvB,aAAa,GACb,gBAAgB,GAChB,mBAAmB,GACnB,oBAAoB,GACpB,iBAAiB,CAAC;AAErB,qBAAa,2BAA4B,SAAQ,KAAK;IACrD,QAAQ,CAAC,IAAI,EAAE,+BAA+B,CAAC;IAE/C,YAAY,IAAI,EAAE,+BAA+B,EAAE,OAAO,EAAE,MAAM,EAIjE;CACD;AAED,MAAM,WAAW,6BAA6B;IAC7C,sDAAsD;IACtD,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IACzC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,wBAAwB;IACxC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,wBAAwB,CAAC;IAC7C,mFAAmF;IACnF,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC3B;AAkCD;;;;GAIG;AACH,wBAAsB,wBAAwB,CAC7C,OAAO,EAAE,6BAA6B,EACtC,KAAK,EAAE;IACN,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC9B,GACC,OAAO,CAAC,wBAAwB,CAAC,CAyHnC","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { detectPluginPackageMediaTypeV1, type PluginPackageMediaTypeV1 } from \"./node-package-media.ts\";\n\n/**\n * Custom-URL plugin package download (design §4.6 \"自定义 URL\" row). The URL\n * is the package file itself (zip/tgz); integrity is layered: a `#sha256:<hex>`\n * ref fragment becomes a strong digest check, otherwise TLS plus the double\n * manifest validation performed by the install host.\n */\n\nconst DEFAULT_TIMEOUT_MS_V1 = 30_000;\nconst MAX_TIMEOUT_MS_V1 = 120_000;\nconst DEFAULT_MAX_PACKAGE_BYTES_V1 = 128 * 1024 * 1024;\nconst MAX_PACKAGE_BYTES_V1 = 512 * 1024 * 1024;\nconst DEFAULT_REDIRECTS_V1 = 3;\nconst MAX_REDIRECTS_V1 = 5;\nconst REDIRECT_STATUS = new Set([301, 302, 303, 307, 308]);\n\nexport type NodeUrlPackageSourceErrorCodeV1 =\n\t| \"cancelled\"\n\t| \"invalid_configuration\"\n\t| \"invalid_url\"\n\t| \"request_failed\"\n\t| \"request_timed_out\"\n\t| \"response_too_large\"\n\t| \"digest_mismatch\";\n\nexport class NodeUrlPackageSourceErrorV1 extends Error {\n\treadonly code: NodeUrlPackageSourceErrorCodeV1;\n\n\tconstructor(code: NodeUrlPackageSourceErrorCodeV1, message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"NodeUrlPackageSourceErrorV1\";\n\t\tthis.code = code;\n\t}\n}\n\nexport interface NodeUrlPackageSourceOptionsV1 {\n\t/** Real fetch or a deterministic test replacement. */\n\treadonly fetch?: typeof globalThis.fetch;\n\treadonly requestTimeoutMs?: number;\n\treadonly maxPackageBytes?: number;\n\treadonly maxRedirects?: number;\n\treadonly userAgent?: string;\n}\n\nexport interface NodeUrlPackageDownloadV1 {\n\treadonly bytes: Uint8Array;\n\treadonly mediaType: PluginPackageMediaTypeV1;\n\t/** sha256 hex of the downloaded bytes; always computed, verified when expected. */\n\treadonly digestHex: string;\n}\n\nfunction boundedPositive(value: number | undefined, fallback: number, maximum: number, label: string): number {\n\tconst result = value ?? fallback;\n\tif (!Number.isSafeInteger(result) || result <= 0 || result > maximum)\n\t\tthrow new NodeUrlPackageSourceErrorV1(\n\t\t\t\"invalid_configuration\",\n\t\t\t`${label} must be a positive integer at most ${maximum}`,\n\t\t);\n\treturn result;\n}\n\nfunction packageUrl(value: string): URL {\n\tlet parsed: URL;\n\ttry {\n\t\tparsed = new URL(value);\n\t} catch {\n\t\tthrow new NodeUrlPackageSourceErrorV1(\"invalid_url\", \"plugin package URL is invalid\");\n\t}\n\tif (\n\t\t(parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") ||\n\t\tparsed.username !== \"\" ||\n\t\tparsed.password !== \"\"\n\t)\n\t\tthrow new NodeUrlPackageSourceErrorV1(\"invalid_url\", \"plugin package URL must use http(s) without credentials\");\n\tif (parsed.hash !== \"\")\n\t\tthrow new NodeUrlPackageSourceErrorV1(\"invalid_url\", \"plugin package URL must not include a fragment\");\n\treturn parsed;\n}\n\nfunction isAbortLike(error: unknown): boolean {\n\treturn error instanceof Error && (error.name === \"AbortError\" || error.name === \"AbortSignalError\");\n}\n\n/**\n * Download one package file over http(s). Redirects are followed manually and\n * every hop must again be a valid http(s) URL without credentials. When\n * `expectedDigestHex` is present the sha256 of the bytes must match exactly.\n */\nexport async function downloadNodeUrlPackageV1(\n\toptions: NodeUrlPackageSourceOptionsV1,\n\tinput: {\n\t\treadonly url: string;\n\t\treadonly expectedDigestHex?: string;\n\t\treadonly signal?: AbortSignal;\n\t},\n): Promise<NodeUrlPackageDownloadV1> {\n\tconst transport = options.fetch ?? globalThis.fetch;\n\tif (typeof transport !== \"function\")\n\t\tthrow new NodeUrlPackageSourceErrorV1(\"invalid_configuration\", \"Node fetch is unavailable\");\n\tconst timeoutMs = boundedPositive(\n\t\toptions.requestTimeoutMs,\n\t\tDEFAULT_TIMEOUT_MS_V1,\n\t\tMAX_TIMEOUT_MS_V1,\n\t\t\"requestTimeoutMs\",\n\t);\n\tconst maxPackageBytes = boundedPositive(\n\t\toptions.maxPackageBytes,\n\t\tDEFAULT_MAX_PACKAGE_BYTES_V1,\n\t\tMAX_PACKAGE_BYTES_V1,\n\t\t\"maxPackageBytes\",\n\t);\n\tconst maxRedirects = options.maxRedirects ?? DEFAULT_REDIRECTS_V1;\n\tif (!Number.isSafeInteger(maxRedirects) || maxRedirects < 0 || maxRedirects > MAX_REDIRECTS_V1)\n\t\tthrow new NodeUrlPackageSourceErrorV1(\n\t\t\t\"invalid_configuration\",\n\t\t\t`maxRedirects must be an integer between 0 and ${MAX_REDIRECTS_V1}`,\n\t\t);\n\tconst userAgent = options.userAgent ?? \"agent-forge-plugin-url/1\";\n\tif (userAgent.length === 0 || userAgent.length > 256 || /[\\r\\n]/u.test(userAgent))\n\t\tthrow new NodeUrlPackageSourceErrorV1(\"invalid_configuration\", \"userAgent is invalid\");\n\tif (input.expectedDigestHex !== undefined && !/^[0-9a-f]{64}$/u.test(input.expectedDigestHex))\n\t\tthrow new NodeUrlPackageSourceErrorV1(\"invalid_url\", \"expected sha256 digest is invalid\");\n\n\tlet current = packageUrl(input.url);\n\tlet response: Response | undefined;\n\tconst controller = new AbortController();\n\tlet timedOut = false;\n\tconst abort = () => controller.abort(input.signal?.reason);\n\tif (input.signal?.aborted === true) abort();\n\telse input.signal?.addEventListener(\"abort\", abort, { once: true });\n\tconst timeout = setTimeout(() => {\n\t\ttimedOut = true;\n\t\tcontroller.abort();\n\t}, timeoutMs);\n\ttry {\n\t\tfor (let redirect = 0; ; redirect += 1) {\n\t\t\tif (controller.signal.aborted)\n\t\t\t\tthrow new NodeUrlPackageSourceErrorV1(\"cancelled\", \"plugin package download was cancelled\");\n\t\t\tlet hop: Response;\n\t\t\ttry {\n\t\t\t\thop = await transport(current.toString(), {\n\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\theaders: { accept: \"*/*\", \"user-agent\": userAgent },\n\t\t\t\t\tredirect: \"manual\",\n\t\t\t\t\tsignal: controller.signal,\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tif (timedOut)\n\t\t\t\t\tthrow new NodeUrlPackageSourceErrorV1(\"request_timed_out\", \"plugin package download timed out\");\n\t\t\t\tif (isAbortLike(error) || input.signal?.aborted === true)\n\t\t\t\t\tthrow new NodeUrlPackageSourceErrorV1(\"cancelled\", \"plugin package download was cancelled\");\n\t\t\t\tthrow new NodeUrlPackageSourceErrorV1(\"request_failed\", \"plugin package download failed\");\n\t\t\t}\n\t\t\tif (!REDIRECT_STATUS.has(hop.status)) {\n\t\t\t\tresponse = hop;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tconst location = hop.headers.get(\"location\");\n\t\t\tawait hop.body?.cancel().catch(() => undefined);\n\t\t\tif (location === null || redirect >= maxRedirects)\n\t\t\t\tthrow new NodeUrlPackageSourceErrorV1(\"request_failed\", \"plugin package redirect limit exceeded\");\n\t\t\tcurrent = packageUrl(new URL(location, current).toString());\n\t\t}\n\t\tif (response === undefined)\n\t\t\tthrow new NodeUrlPackageSourceErrorV1(\"request_failed\", \"plugin package download failed\");\n\t\tif (response.status < 200 || response.status >= 300)\n\t\t\tthrow new NodeUrlPackageSourceErrorV1(\"request_failed\", \"plugin package download did not succeed\");\n\t\tif (response.body === null)\n\t\t\tthrow new NodeUrlPackageSourceErrorV1(\"request_failed\", \"plugin package response has no body\");\n\t\tconst reader = response.body.getReader();\n\t\tconst chunks: Uint8Array[] = [];\n\t\tconst hash = createHash(\"sha256\");\n\t\tlet total = 0;\n\t\ttry {\n\t\t\tfor (;;) {\n\t\t\t\tif (controller.signal.aborted)\n\t\t\t\t\tthrow new NodeUrlPackageSourceErrorV1(\"cancelled\", \"plugin package download was cancelled\");\n\t\t\t\tconst item = await reader.read();\n\t\t\t\tif (item.done) break;\n\t\t\t\ttotal += item.value.byteLength;\n\t\t\t\tif (total > maxPackageBytes)\n\t\t\t\t\tthrow new NodeUrlPackageSourceErrorV1(\n\t\t\t\t\t\t\"response_too_large\",\n\t\t\t\t\t\t\"plugin package exceeds the configured size limit\",\n\t\t\t\t\t);\n\t\t\t\thash.update(item.value);\n\t\t\t\tchunks.push(item.value);\n\t\t\t}\n\t\t} finally {\n\t\t\treader.releaseLock();\n\t\t}\n\t\tif (controller.signal.aborted)\n\t\t\tthrow new NodeUrlPackageSourceErrorV1(\"cancelled\", \"plugin package download was cancelled\");\n\t\tconst bytes = new Uint8Array(total);\n\t\tlet offset = 0;\n\t\tfor (const chunk of chunks) {\n\t\t\tbytes.set(chunk, offset);\n\t\t\toffset += chunk.byteLength;\n\t\t}\n\t\tconst digestHex = hash.digest(\"hex\");\n\t\tif (input.expectedDigestHex !== undefined && digestHex !== input.expectedDigestHex)\n\t\t\tthrow new NodeUrlPackageSourceErrorV1(\n\t\t\t\t\"digest_mismatch\",\n\t\t\t\t\"plugin package bytes do not match the expected sha256 digest\",\n\t\t\t);\n\t\tconst fileName = current.pathname.split(\"/\").pop();\n\t\tconst mediaType = detectPluginPackageMediaTypeV1(\n\t\t\tbytes,\n\t\t\tfileName === undefined || fileName.length === 0 ? undefined : fileName,\n\t\t);\n\t\treturn { bytes, mediaType, digestHex };\n\t} finally {\n\t\tclearTimeout(timeout);\n\t\tinput.signal?.removeEventListener(\"abort\", abort);\n\t\tawait response?.body?.cancel().catch(() => undefined);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"node-url-package-source.d.ts","sourceRoot":"","sources":["../../../src/plugins/ecosystem/node-url-package-source.ts"],"names":[],"mappings":"AAEA,OAAO,EAAkC,KAAK,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAiBxG,MAAM,MAAM,+BAA+B,GACxC,WAAW,GACX,uBAAuB,GACvB,aAAa,GACb,gBAAgB,GAChB,mBAAmB,GACnB,oBAAoB,GACpB,iBAAiB,CAAC;AAErB,qBAAa,2BAA4B,SAAQ,KAAK;IACrD,QAAQ,CAAC,IAAI,EAAE,+BAA+B,CAAC;IAE/C,YAAY,IAAI,EAAE,+BAA+B,EAAE,OAAO,EAAE,MAAM,EAIjE;CACD;AAED,MAAM,WAAW,6BAA6B;IAC7C,sDAAsD;IACtD,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IACzC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,wBAAwB;IACxC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,wBAAwB,CAAC;IAC7C,mFAAmF;IACnF,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC3B;AAqCD;;;;GAIG;AACH,wBAAsB,wBAAwB,CAC7C,OAAO,EAAE,6BAA6B,EACtC,KAAK,EAAE;IACN,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC9B,GACC,OAAO,CAAC,wBAAwB,CAAC,CAyHnC","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { t } from \"../../core/i18n/index.ts\";\nimport { detectPluginPackageMediaTypeV1, type PluginPackageMediaTypeV1 } from \"./node-package-media.ts\";\n\n/**\n * Custom-URL plugin package download (design §4.6 \"自定义 URL\" row). The URL\n * is the package file itself (zip/tgz); integrity is layered: a `#sha256:<hex>`\n * ref fragment becomes a strong digest check, otherwise TLS plus the double\n * manifest validation performed by the install host.\n */\n\nconst DEFAULT_TIMEOUT_MS_V1 = 30_000;\nconst MAX_TIMEOUT_MS_V1 = 120_000;\nconst DEFAULT_MAX_PACKAGE_BYTES_V1 = 128 * 1024 * 1024;\nconst MAX_PACKAGE_BYTES_V1 = 512 * 1024 * 1024;\nconst DEFAULT_REDIRECTS_V1 = 3;\nconst MAX_REDIRECTS_V1 = 5;\nconst REDIRECT_STATUS = new Set([301, 302, 303, 307, 308]);\n\nexport type NodeUrlPackageSourceErrorCodeV1 =\n\t| \"cancelled\"\n\t| \"invalid_configuration\"\n\t| \"invalid_url\"\n\t| \"request_failed\"\n\t| \"request_timed_out\"\n\t| \"response_too_large\"\n\t| \"digest_mismatch\";\n\nexport class NodeUrlPackageSourceErrorV1 extends Error {\n\treadonly code: NodeUrlPackageSourceErrorCodeV1;\n\n\tconstructor(code: NodeUrlPackageSourceErrorCodeV1, message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"NodeUrlPackageSourceErrorV1\";\n\t\tthis.code = code;\n\t}\n}\n\nexport interface NodeUrlPackageSourceOptionsV1 {\n\t/** Real fetch or a deterministic test replacement. */\n\treadonly fetch?: typeof globalThis.fetch;\n\treadonly requestTimeoutMs?: number;\n\treadonly maxPackageBytes?: number;\n\treadonly maxRedirects?: number;\n\treadonly userAgent?: string;\n}\n\nexport interface NodeUrlPackageDownloadV1 {\n\treadonly bytes: Uint8Array;\n\treadonly mediaType: PluginPackageMediaTypeV1;\n\t/** sha256 hex of the downloaded bytes; always computed, verified when expected. */\n\treadonly digestHex: string;\n}\n\nfunction boundedPositive(value: number | undefined, fallback: number, maximum: number, label: string): number {\n\tconst result = value ?? fallback;\n\tif (!Number.isSafeInteger(result) || result <= 0 || result > maximum)\n\t\tthrow new NodeUrlPackageSourceErrorV1(\n\t\t\t\"invalid_configuration\",\n\t\t\tt(\"{label} must be a positive integer at most {maximum}\", { label, maximum }),\n\t\t);\n\treturn result;\n}\n\nfunction packageUrl(value: string): URL {\n\tlet parsed: URL;\n\ttry {\n\t\tparsed = new URL(value);\n\t} catch {\n\t\tthrow new NodeUrlPackageSourceErrorV1(\"invalid_url\", t(\"plugin package URL is invalid\"));\n\t}\n\tif (\n\t\t(parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") ||\n\t\tparsed.username !== \"\" ||\n\t\tparsed.password !== \"\"\n\t)\n\t\tthrow new NodeUrlPackageSourceErrorV1(\n\t\t\t\"invalid_url\",\n\t\t\tt(\"plugin package URL must use http(s) without credentials\"),\n\t\t);\n\tif (parsed.hash !== \"\")\n\t\tthrow new NodeUrlPackageSourceErrorV1(\"invalid_url\", t(\"plugin package URL must not include a fragment\"));\n\treturn parsed;\n}\n\nfunction isAbortLike(error: unknown): boolean {\n\treturn error instanceof Error && (error.name === \"AbortError\" || error.name === \"AbortSignalError\");\n}\n\n/**\n * Download one package file over http(s). Redirects are followed manually and\n * every hop must again be a valid http(s) URL without credentials. When\n * `expectedDigestHex` is present the sha256 of the bytes must match exactly.\n */\nexport async function downloadNodeUrlPackageV1(\n\toptions: NodeUrlPackageSourceOptionsV1,\n\tinput: {\n\t\treadonly url: string;\n\t\treadonly expectedDigestHex?: string;\n\t\treadonly signal?: AbortSignal;\n\t},\n): Promise<NodeUrlPackageDownloadV1> {\n\tconst transport = options.fetch ?? globalThis.fetch;\n\tif (typeof transport !== \"function\")\n\t\tthrow new NodeUrlPackageSourceErrorV1(\"invalid_configuration\", t(\"Node fetch is unavailable\"));\n\tconst timeoutMs = boundedPositive(\n\t\toptions.requestTimeoutMs,\n\t\tDEFAULT_TIMEOUT_MS_V1,\n\t\tMAX_TIMEOUT_MS_V1,\n\t\t\"requestTimeoutMs\",\n\t);\n\tconst maxPackageBytes = boundedPositive(\n\t\toptions.maxPackageBytes,\n\t\tDEFAULT_MAX_PACKAGE_BYTES_V1,\n\t\tMAX_PACKAGE_BYTES_V1,\n\t\t\"maxPackageBytes\",\n\t);\n\tconst maxRedirects = options.maxRedirects ?? DEFAULT_REDIRECTS_V1;\n\tif (!Number.isSafeInteger(maxRedirects) || maxRedirects < 0 || maxRedirects > MAX_REDIRECTS_V1)\n\t\tthrow new NodeUrlPackageSourceErrorV1(\n\t\t\t\"invalid_configuration\",\n\t\t\tt(\"maxRedirects must be an integer between 0 and {max}\", { max: MAX_REDIRECTS_V1 }),\n\t\t);\n\tconst userAgent = options.userAgent ?? \"agent-forge-plugin-url/1\";\n\tif (userAgent.length === 0 || userAgent.length > 256 || /[\\r\\n]/u.test(userAgent))\n\t\tthrow new NodeUrlPackageSourceErrorV1(\"invalid_configuration\", t(\"userAgent is invalid\"));\n\tif (input.expectedDigestHex !== undefined && !/^[0-9a-f]{64}$/u.test(input.expectedDigestHex))\n\t\tthrow new NodeUrlPackageSourceErrorV1(\"invalid_url\", t(\"expected sha256 digest is invalid\"));\n\n\tlet current = packageUrl(input.url);\n\tlet response: Response | undefined;\n\tconst controller = new AbortController();\n\tlet timedOut = false;\n\tconst abort = () => controller.abort(input.signal?.reason);\n\tif (input.signal?.aborted === true) abort();\n\telse input.signal?.addEventListener(\"abort\", abort, { once: true });\n\tconst timeout = setTimeout(() => {\n\t\ttimedOut = true;\n\t\tcontroller.abort();\n\t}, timeoutMs);\n\ttry {\n\t\tfor (let redirect = 0; ; redirect += 1) {\n\t\t\tif (controller.signal.aborted)\n\t\t\t\tthrow new NodeUrlPackageSourceErrorV1(\"cancelled\", t(\"plugin package download was cancelled\"));\n\t\t\tlet hop: Response;\n\t\t\ttry {\n\t\t\t\thop = await transport(current.toString(), {\n\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\theaders: { accept: \"*/*\", \"user-agent\": userAgent },\n\t\t\t\t\tredirect: \"manual\",\n\t\t\t\t\tsignal: controller.signal,\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tif (timedOut)\n\t\t\t\t\tthrow new NodeUrlPackageSourceErrorV1(\"request_timed_out\", t(\"plugin package download timed out\"));\n\t\t\t\tif (isAbortLike(error) || input.signal?.aborted === true)\n\t\t\t\t\tthrow new NodeUrlPackageSourceErrorV1(\"cancelled\", t(\"plugin package download was cancelled\"));\n\t\t\t\tthrow new NodeUrlPackageSourceErrorV1(\"request_failed\", t(\"plugin package download failed\"));\n\t\t\t}\n\t\t\tif (!REDIRECT_STATUS.has(hop.status)) {\n\t\t\t\tresponse = hop;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tconst location = hop.headers.get(\"location\");\n\t\t\tawait hop.body?.cancel().catch(() => undefined);\n\t\t\tif (location === null || redirect >= maxRedirects)\n\t\t\t\tthrow new NodeUrlPackageSourceErrorV1(\"request_failed\", t(\"plugin package redirect limit exceeded\"));\n\t\t\tcurrent = packageUrl(new URL(location, current).toString());\n\t\t}\n\t\tif (response === undefined)\n\t\t\tthrow new NodeUrlPackageSourceErrorV1(\"request_failed\", t(\"plugin package download failed\"));\n\t\tif (response.status < 200 || response.status >= 300)\n\t\t\tthrow new NodeUrlPackageSourceErrorV1(\"request_failed\", t(\"plugin package download did not succeed\"));\n\t\tif (response.body === null)\n\t\t\tthrow new NodeUrlPackageSourceErrorV1(\"request_failed\", t(\"plugin package response has no body\"));\n\t\tconst reader = response.body.getReader();\n\t\tconst chunks: Uint8Array[] = [];\n\t\tconst hash = createHash(\"sha256\");\n\t\tlet total = 0;\n\t\ttry {\n\t\t\tfor (;;) {\n\t\t\t\tif (controller.signal.aborted)\n\t\t\t\t\tthrow new NodeUrlPackageSourceErrorV1(\"cancelled\", t(\"plugin package download was cancelled\"));\n\t\t\t\tconst item = await reader.read();\n\t\t\t\tif (item.done) break;\n\t\t\t\ttotal += item.value.byteLength;\n\t\t\t\tif (total > maxPackageBytes)\n\t\t\t\t\tthrow new NodeUrlPackageSourceErrorV1(\n\t\t\t\t\t\t\"response_too_large\",\n\t\t\t\t\t\tt(\"plugin package exceeds the configured size limit\"),\n\t\t\t\t\t);\n\t\t\t\thash.update(item.value);\n\t\t\t\tchunks.push(item.value);\n\t\t\t}\n\t\t} finally {\n\t\t\treader.releaseLock();\n\t\t}\n\t\tif (controller.signal.aborted)\n\t\t\tthrow new NodeUrlPackageSourceErrorV1(\"cancelled\", t(\"plugin package download was cancelled\"));\n\t\tconst bytes = new Uint8Array(total);\n\t\tlet offset = 0;\n\t\tfor (const chunk of chunks) {\n\t\t\tbytes.set(chunk, offset);\n\t\t\toffset += chunk.byteLength;\n\t\t}\n\t\tconst digestHex = hash.digest(\"hex\");\n\t\tif (input.expectedDigestHex !== undefined && digestHex !== input.expectedDigestHex)\n\t\t\tthrow new NodeUrlPackageSourceErrorV1(\n\t\t\t\t\"digest_mismatch\",\n\t\t\t\tt(\"plugin package bytes do not match the expected sha256 digest\"),\n\t\t\t);\n\t\tconst fileName = current.pathname.split(\"/\").pop();\n\t\tconst mediaType = detectPluginPackageMediaTypeV1(\n\t\t\tbytes,\n\t\t\tfileName === undefined || fileName.length === 0 ? undefined : fileName,\n\t\t);\n\t\treturn { bytes, mediaType, digestHex };\n\t} finally {\n\t\tclearTimeout(timeout);\n\t\tinput.signal?.removeEventListener(\"abort\", abort);\n\t\tawait response?.body?.cancel().catch(() => undefined);\n\t}\n}\n"]}
|