@jeffusion/bungee-core 6.19.3 → 6.19.4
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/dist/access-database.d.ts +22 -0
- package/dist/api/handlers/logs.d.ts +66 -0
- package/dist/api/handlers/stats.d.ts +50 -0
- package/dist/api/logs.d.ts +145 -0
- package/dist/api/types.d.ts +21 -0
- package/dist/{chunk-assets-swq50rh3.js → chunk-assets-vsan7gav.js} +11 -11
- package/dist/{chunk-body-capture-gtta9q26.js → chunk-body-capture-sbk6cdf9.js} +2 -2
- package/dist/{chunk-handler-ehkkxpnq.js → chunk-handler-9k6b95w4.js} +2 -2
- package/dist/{chunk-main-rcw37zhd.js → chunk-main-1p15rgq5.js} +1 -1
- package/dist/{chunk-main-10pgdbgn.js → chunk-main-2efrk1nt.js} +1 -1
- package/dist/{chunk-main-a4eygw79.js → chunk-main-d74e7qxc.js} +1 -1
- package/dist/{chunk-main-p5rpfk7t.js → chunk-main-gwaw6pxp.js} +1 -1
- package/dist/{chunk-main-25kbhd4n.js → chunk-main-mqgkewnx.js} +1 -1
- package/dist/{chunk-main-0w3jk2x4.js → chunk-main-qm1tgaka.js} +2 -2
- package/dist/{chunk-master-276v10xm.js → chunk-master-wtcfwd6g.js} +6 -6
- package/dist/{chunk-plugin-context-manager-nexyp0jb.js → chunk-plugin-context-manager-kabrbg0s.js} +1 -1
- package/dist/{chunk-plugin-manager-dvxc5w6p.js → chunk-plugin-manager-q1bt6xnw.js} +2 -2
- package/dist/{chunk-runtime-upgrade-sjxsa2r6.js → chunk-runtime-upgrade-rvm3d096.js} +3 -3
- package/dist/{chunk-runtime-qbfd9z3p.js → chunk-runtime-xmp308t7.js} +2 -2
- package/dist/{chunk-worker-5mdsmhte.js → chunk-worker-99q8qnj9.js} +9 -9
- package/dist/config-publication/admission-handoff.d.ts +13 -0
- package/dist/config-publication/coordinator-types.d.ts +176 -0
- package/dist/config-publication/current-startup.d.ts +26 -0
- package/dist/config-publication/drain-workers.d.ts +15 -0
- package/dist/config-publication/index.d.ts +6 -0
- package/dist/config-publication/master-coordinator.d.ts +45 -0
- package/dist/config-publication/master-messages.d.ts +2 -0
- package/dist/config-publication/message-fields.d.ts +20 -0
- package/dist/config-publication/messages.d.ts +3 -0
- package/dist/config-publication/process-cleanup.d.ts +30 -0
- package/dist/config-publication/process-identity.d.ts +14 -0
- package/dist/config-publication/process-termination.d.ts +7 -0
- package/dist/config-publication/publication-runner.d.ts +50 -0
- package/dist/config-publication/recovery-disposition.d.ts +17 -0
- package/dist/config-publication/types.d.ts +137 -0
- package/dist/config-publication/waiter-safety.d.ts +2 -0
- package/dist/config-publication/worker-messages.d.ts +2 -0
- package/dist/config-publication/worker-runtime-contract.d.ts +76 -0
- package/dist/config-publication/worker-runtime-plugins.d.ts +8 -0
- package/dist/config-publication/worker-runtime.d.ts +22 -0
- package/dist/config-publication/worker-wait.d.ts +44 -0
- package/dist/config-storage/active-publication.d.ts +37 -0
- package/dist/config-storage/aggregate.d.ts +4 -0
- package/dist/config-storage/async-config-repository.d.ts +125 -0
- package/dist/config-storage/commit-transaction.d.ts +13 -0
- package/dist/config-storage/compiler.d.ts +4 -0
- package/dist/config-storage/config-repository.d.ts +118 -0
- package/dist/config-storage/consistent-read.d.ts +2 -0
- package/dist/config-storage/content-hash.d.ts +17 -0
- package/dist/config-storage/cross-table-audit.d.ts +20 -0
- package/dist/config-storage/current-revision.d.ts +2 -0
- package/dist/config-storage/domain-validation.d.ts +5 -0
- package/dist/config-storage/expression-ast.d.ts +2 -0
- package/dist/config-storage/expression-call-policy.d.ts +2 -0
- package/dist/config-storage/expression-syntax.d.ts +2 -0
- package/dist/config-storage/gateway-target-validation.d.ts +5 -0
- package/dist/config-storage/global-scalars.d.ts +6 -0
- package/dist/config-storage/global-validation.d.ts +2 -0
- package/dist/config-storage/immutable-snapshot.d.ts +4 -0
- package/dist/config-storage/index.d.ts +21 -0
- package/dist/config-storage/json-preflight.d.ts +15 -0
- package/dist/config-storage/management-protection.d.ts +10 -0
- package/dist/config-storage/materialize.d.ts +3 -0
- package/dist/config-storage/menu-store.d.ts +12 -0
- package/dist/config-storage/migrations/baseline.d.ts +8 -0
- package/dist/config-storage/migrations/index.d.ts +8 -0
- package/dist/config-storage/migrations/management-protection.d.ts +2 -0
- package/dist/config-storage/migrations/plan.d.ts +9 -0
- package/dist/config-storage/migrations/prepared-worker-allocation.d.ts +2 -0
- package/dist/config-storage/migrations/publication-retirement.d.ts +3 -0
- package/dist/config-storage/migrations/publication-targets.d.ts +3 -0
- package/dist/config-storage/migrations/request-logs-default.d.ts +2 -0
- package/dist/config-storage/migrations/runtime-cutover.d.ts +2 -0
- package/dist/config-storage/migrations/service-references.d.ts +3 -0
- package/dist/config-storage/migrations/ui-menus.d.ts +2 -0
- package/dist/config-storage/migrations/websocket-connections.d.ts +2 -0
- package/dist/config-storage/migrations/websocket-message-size.d.ts +2 -0
- package/dist/config-storage/migrations/worker-launch-capacity.d.ts +2 -0
- package/dist/config-storage/modification-validation.d.ts +4 -0
- package/dist/config-storage/operation-records.d.ts +42 -0
- package/dist/config-storage/operation-relations.d.ts +6 -0
- package/dist/config-storage/operation-store.d.ts +12 -0
- package/dist/config-storage/persisted-json.d.ts +2 -0
- package/dist/config-storage/persisted-validation.d.ts +7 -0
- package/dist/config-storage/plugin-name.d.ts +2 -0
- package/dist/config-storage/plugin-schema.d.ts +16 -0
- package/dist/config-storage/policy-fields.d.ts +15 -0
- package/dist/config-storage/prepared-command.d.ts +14 -0
- package/dist/config-storage/read-materialization.d.ts +4 -0
- package/dist/config-storage/recovery-store.d.ts +21 -0
- package/dist/config-storage/relation-materialization.d.ts +30 -0
- package/dist/config-storage/repository-snapshot.d.ts +5 -0
- package/dist/config-storage/repository-types.d.ts +216 -0
- package/dist/config-storage/repository-validation.d.ts +6 -0
- package/dist/config-storage/request-logs-default.d.ts +5 -0
- package/dist/config-storage/retirement-store.d.ts +78 -0
- package/dist/config-storage/route-policy-validation.d.ts +2 -0
- package/dist/config-storage/runtime-config.d.ts +14 -0
- package/dist/config-storage/runtime-cutover.d.ts +13 -0
- package/dist/config-storage/runtime-recovery-budget.d.ts +35 -0
- package/dist/config-storage/schema-fingerprint.d.ts +5 -0
- package/dist/config-storage/schema.d.ts +2 -0
- package/dist/config-storage/service-policy-validation.d.ts +4 -0
- package/dist/config-storage/service-reference-upgrade.d.ts +4 -0
- package/dist/config-storage/serving-snapshot.d.ts +9 -0
- package/dist/config-storage/snapshot-validation.d.ts +3 -0
- package/dist/config-storage/sqlite-errors.d.ts +3 -0
- package/dist/config-storage/sqlite-query.d.ts +3 -0
- package/dist/config-storage/sqlite-version.d.ts +10 -0
- package/dist/config-storage/storage-protocol.d.ts +52 -0
- package/dist/config-storage/utf16.d.ts +2 -0
- package/dist/config-storage/validation.d.ts +31 -0
- package/dist/config-storage/worker-launch-store.d.ts +93 -0
- package/dist/config-worker/http-provider.d.ts +6 -0
- package/dist/config-worker/lifecycle.d.ts +84 -0
- package/dist/config-worker/private-transport.d.ts +31 -0
- package/dist/config-worker/process-environment.d.ts +38 -0
- package/dist/config-worker/rate-limit-provider.d.ts +31 -0
- package/dist/config-worker/runtime-dependencies.d.ts +12 -0
- package/dist/config-worker/snapshot-compiler.d.ts +5 -0
- package/dist/config-worker/supervised-process-entry.d.ts +8 -0
- package/dist/core-version.d.ts +1 -0
- package/dist/daemon-control/bootstrap.d.ts +41 -0
- package/dist/daemon-control/index.d.ts +1 -0
- package/dist/daemon-control/launch-identity.d.ts +26 -0
- package/dist/daemon-control/shutdown.d.ts +22 -0
- package/dist/data-admission/errors.d.ts +16 -0
- package/dist/data-admission/host.d.ts +92 -0
- package/dist/data-admission/keyed-state.d.ts +21 -0
- package/dist/data-admission/rpc.d.ts +40 -0
- package/dist/data-admission/worker.d.ts +66 -0
- package/dist/database-schema.d.ts +2 -0
- package/dist/expression-engine.d.ts +33 -0
- package/dist/gateway/admission-plugin.d.ts +7 -0
- package/dist/gateway/auxiliary-request.d.ts +7 -0
- package/dist/gateway/body-contracts.d.ts +39 -0
- package/dist/gateway/body-events.d.ts +58 -0
- package/dist/gateway/body-factory.d.ts +4 -0
- package/dist/gateway/body-observation-stream.d.ts +6 -0
- package/dist/gateway/body-plugin.d.ts +8 -0
- package/dist/gateway/body-resources.d.ts +37 -0
- package/dist/gateway/body-service.d.ts +116 -0
- package/dist/gateway/contracts.d.ts +196 -0
- package/dist/gateway/controlled-views.d.ts +5 -0
- package/dist/gateway/dispatch-plugin.d.ts +11 -0
- package/dist/gateway/dispatch-targets.d.ts +4 -0
- package/dist/gateway/forward-plugin.d.ts +136 -0
- package/dist/gateway/plugin.d.ts +23 -0
- package/dist/gateway/plugin.js +18 -18
- package/dist/gateway/request-log-contracts.d.ts +346 -0
- package/dist/gateway/request-log.d.ts +105 -0
- package/dist/gateway/request-plugin.d.ts +98 -0
- package/dist/gateway/request-rules-plugin.d.ts +61 -0
- package/dist/gateway/response-plugin.d.ts +34 -0
- package/dist/gateway/response-views.d.ts +33 -0
- package/dist/gateway/responses-websocket-session.d.ts +24 -0
- package/dist/gateway/retry-action.d.ts +7 -0
- package/dist/gateway/retry-plugin.d.ts +7 -0
- package/dist/gateway/routing-plugin.d.ts +11 -0
- package/dist/gateway/runtime.d.ts +15 -0
- package/dist/gateway/selection-plugin.d.ts +7 -0
- package/dist/gateway/sse-response.d.ts +6 -0
- package/dist/gateway/websocket-contracts.d.ts +71 -0
- package/dist/gateway/websocket-credential.d.ts +3 -0
- package/dist/gateway/websocket-plugin.d.ts +9 -0
- package/dist/hooks/impl.d.ts +119 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/plugin-hooks.d.ts +308 -0
- package/dist/hooks/types.d.ts +130 -0
- package/dist/ingress/admission-registry.d.ts +56 -0
- package/dist/ingress/admission-set.d.ts +29 -0
- package/dist/ingress/index.d.ts +4 -0
- package/dist/ingress/master-controller.d.ts +278 -0
- package/dist/ingress/runtime.d.ts +29 -0
- package/dist/ingress/supervision-http.d.ts +118 -0
- package/dist/ingress.d.ts +5 -0
- package/dist/instance-lock.d.ts +2 -0
- package/dist/logger/access-log-writer.d.ts +120 -0
- package/dist/logger/body-capture.d.ts +21 -0
- package/dist/logger/body-log-redaction.d.ts +6 -0
- package/dist/logger/body-storage.d.ts +71 -0
- package/dist/logger/content-capture.d.ts +47 -0
- package/dist/logger/dated-log-files.d.ts +5 -0
- package/dist/logger/header-storage.d.ts +54 -0
- package/dist/logger/log-cleanup.d.ts +69 -0
- package/dist/logger/log-url.d.ts +2 -0
- package/dist/logger/request-logger.d.ts +308 -0
- package/dist/logger/transport-outcome.d.ts +25 -0
- package/dist/logger/websocket-body-capture.d.ts +26 -0
- package/dist/logger.d.ts +16 -0
- package/dist/main.d.ts +19 -0
- package/dist/main.js +8 -8
- package/dist/management-listener/index.d.ts +2 -0
- package/dist/management-listener/listener.d.ts +48 -0
- package/dist/management-listener/request-source.d.ts +4 -0
- package/dist/master-runtime/component-recovery.d.ts +40 -0
- package/dist/master-runtime/composition.d.ts +129 -0
- package/dist/master-runtime/configuration-recovery.d.ts +80 -0
- package/dist/master-runtime/control-api-body.d.ts +9 -0
- package/dist/master-runtime/control-api.d.ts +122 -0
- package/dist/master-runtime/error-chain.d.ts +9 -0
- package/dist/master-runtime/initialize-configuration.d.ts +4 -0
- package/dist/master-runtime/instance-lock.d.ts +25 -0
- package/dist/master-runtime/kernel-exit-timer.d.ts +7 -0
- package/dist/master-runtime/kernel-monotonic-clock.d.ts +15 -0
- package/dist/master-runtime/management-auth.d.ts +43 -0
- package/dist/master-runtime/master-plugin-catalog-api.d.ts +18 -0
- package/dist/master-runtime/master-stats.d.ts +52 -0
- package/dist/master-runtime/menu-api.d.ts +19 -0
- package/dist/master-runtime/observability-client.d.ts +49 -0
- package/dist/master-runtime/offline-recovery.d.ts +9 -0
- package/dist/master-runtime/offline-storage-session.d.ts +8 -0
- package/dist/master-runtime/plugin-journal-recovery.d.ts +28 -0
- package/dist/master-runtime/process-identity.d.ts +48 -0
- package/dist/master-runtime/process-options.d.ts +59 -0
- package/dist/master-runtime/publication-task-manager.d.ts +47 -0
- package/dist/master-runtime/reconcile-plugin-dependencies.d.ts +7 -0
- package/dist/master-runtime/recovery-prompt.d.ts +9 -0
- package/dist/master-runtime/route-body-plan.d.ts +31 -0
- package/dist/master-runtime/runtime-cleanup.d.ts +3 -0
- package/dist/master-runtime/runtime-contracts.d.ts +101 -0
- package/dist/master-runtime/runtime-evidence.d.ts +8 -0
- package/dist/master-runtime/runtime-status.d.ts +36 -0
- package/dist/master-runtime/runtime-supervisor.d.ts +30 -0
- package/dist/master-runtime/runtime-upgrade.d.ts +11 -0
- package/dist/master-runtime/runtime-upstreams.d.ts +14 -0
- package/dist/master-runtime/runtime.d.ts +23 -0
- package/dist/master-runtime/shutdown-diagnostics.d.ts +28 -0
- package/dist/master-runtime/signal-handlers.d.ts +18 -0
- package/dist/master-runtime/stopped-instance-lock.d.ts +6 -0
- package/dist/master-runtime/stopped-process.d.ts +2 -0
- package/dist/master-runtime/supervised-worker-client.d.ts +108 -0
- package/dist/master-runtime/supervised-worker-discovery.d.ts +41 -0
- package/dist/master-runtime/supervised-worker-factory.d.ts +298 -0
- package/dist/master-runtime/supervised-worker-process-adapter.d.ts +146 -0
- package/dist/master-runtime/worker-initialization-diagnostics.d.ts +18 -0
- package/dist/master.d.ts +2 -0
- package/dist/oauth-callback.d.ts +8 -0
- package/dist/plugin-artifact-contract.d.ts +4 -0
- package/dist/plugin-artifact-negotiation.d.ts +12 -0
- package/dist/plugin-artifact-types.d.ts +61 -0
- package/dist/plugin-context-manager.d.ts +91 -0
- package/dist/plugin-control/artifact-loader.d.ts +3 -0
- package/dist/plugin-control/contracts.d.ts +180 -0
- package/dist/plugin-control/host.d.ts +90 -0
- package/dist/plugin-control/index.d.ts +3 -0
- package/dist/plugin-control/master-invocation-projector.d.ts +52 -0
- package/dist/plugin-control/request-service-authority.d.ts +33 -0
- package/dist/plugin-control/secret-crypto.d.ts +13 -0
- package/dist/plugin-control/secret-store.d.ts +15 -0
- package/dist/plugin-dependencies.d.ts +30 -0
- package/dist/plugin-durable-state.d.ts +62 -0
- package/dist/plugin-extensions.d.ts +99 -0
- package/dist/plugin-logger.d.ts +17 -0
- package/dist/plugin-manifest-catalog/catalog.d.ts +28 -0
- package/dist/plugin-manifest-catalog/config-constraint-parser.d.ts +3 -0
- package/dist/plugin-manifest-catalog/config-default-validator.d.ts +3 -0
- package/dist/plugin-manifest-catalog/config-field-parser.d.ts +3 -0
- package/dist/plugin-manifest-catalog/config-field-references.d.ts +2 -0
- package/dist/plugin-manifest-catalog/index.d.ts +6 -0
- package/dist/plugin-manifest-catalog/manifest-filesystem.d.ts +9 -0
- package/dist/plugin-manifest-catalog/manifest-json.d.ts +1 -0
- package/dist/plugin-manifest-catalog/manifest-nested-parser.d.ts +11 -0
- package/dist/plugin-manifest-catalog/manifest-parser.d.ts +2 -0
- package/dist/plugin-manifest-catalog/manifest-semver.d.ts +4 -0
- package/dist/plugin-manifest-catalog/manifest-values.d.ts +6 -0
- package/dist/plugin-manifest-catalog/parse-utils.d.ts +19 -0
- package/dist/plugin-manifest-catalog/plugin-field-value.d.ts +3 -0
- package/dist/plugin-manifest-catalog/runtime-identity.d.ts +12 -0
- package/dist/plugin-manifest-catalog/types.d.ts +187 -0
- package/dist/plugin-path-resolver.d.ts +17 -0
- package/dist/plugin-registry.d.ts +165 -0
- package/dist/plugin-runtime-config.d.ts +10 -0
- package/dist/plugin-runtime-diff.d.ts +15 -0
- package/dist/plugin-runtime-orchestrator.d.ts +69 -0
- package/dist/plugin-runtime-state-machine.d.ts +78 -0
- package/dist/plugin-runtime-status.d.ts +29 -0
- package/dist/plugin-services/channels.d.ts +391 -0
- package/dist/plugin-services/command-journal.d.ts +234 -0
- package/dist/plugin-services/contracts.d.ts +23 -0
- package/dist/plugin-services/host-rpc.d.ts +268 -0
- package/dist/plugin-services/peer-broker.d.ts +351 -0
- package/dist/plugin-services/peer-channel-hub.d.ts +457 -0
- package/dist/plugin-services/peer-channel-protocol.d.ts +339 -0
- package/dist/plugin-services/peer-directory.d.ts +163 -0
- package/dist/plugin-services/peer-executor-proof.d.ts +13 -0
- package/dist/plugin-services/peer-frame.d.ts +65 -0
- package/dist/plugin-services/peer-journal.d.ts +25 -0
- package/dist/plugin-services/peer-protocol.d.ts +128 -0
- package/dist/plugin-services/peer-rpc-link.d.ts +218 -0
- package/dist/plugin-services/peer-rpc-mapping.d.ts +133 -0
- package/dist/plugin-services/peer-websocket.d.ts +146 -0
- package/dist/plugin-services/persistence.d.ts +166 -0
- package/dist/plugin-services/rpc-runtime.d.ts +227 -0
- package/dist/plugin-services/snapshot-store.d.ts +77 -0
- package/dist/plugin-services/wire-contract.d.ts +158 -0
- package/dist/plugin-services.d.ts +237 -0
- package/dist/plugin-state/client.d.ts +160 -0
- package/dist/plugin-state/message-size.d.ts +2 -0
- package/dist/plugin-state/operations.d.ts +4 -0
- package/dist/plugin-state/protocol.d.ts +40 -0
- package/dist/plugin-state/storage-rpc.d.ts +7 -0
- package/dist/plugin.types.d.ts +999 -0
- package/dist/plugins/anthropic-request-sanitizer/index.js +17 -17
- package/dist/plugins/anthropic-request-sanitizer/index.js.map +1 -1
- package/dist/plugins/anthropic-tool-name-transformer/index.js +17 -17
- package/dist/plugins/anthropic-tool-name-transformer/index.js.map +1 -1
- package/dist/plugins/chatgpt-oauth/control.js +24 -24
- package/dist/plugins/chatgpt-oauth/control.js.map +1 -1
- package/dist/plugins/chatgpt-oauth/index.js +23 -23
- package/dist/plugins/chatgpt-oauth/index.js.map +1 -1
- package/dist/plugins/codex-router/control.js +19 -19
- package/dist/plugins/codex-router/control.js.map +1 -1
- package/dist/plugins/codex-router/index.js +31 -31
- package/dist/plugins/codex-router/index.js.map +1 -1
- package/dist/plugins/deepseek-reasoning-fix/index.js +17 -17
- package/dist/plugins/deepseek-reasoning-fix/index.js.map +1 -1
- package/dist/plugins/key-access/control.js +18 -18
- package/dist/plugins/key-access/control.js.map +1 -1
- package/dist/plugins/key-access/index.js +19 -19
- package/dist/plugins/key-access/index.js.map +1 -1
- package/dist/plugins/key-access/ingress.js +18 -18
- package/dist/plugins/key-access/ingress.js.map +1 -1
- package/dist/plugins/key-rate-limit/control.js +3 -3
- package/dist/plugins/key-rate-limit/control.js.map +1 -1
- package/dist/plugins/key-rate-limit/index.js +18 -18
- package/dist/plugins/key-rate-limit/index.js.map +1 -1
- package/dist/plugins/key-rate-limit/ingress.js +2 -2
- package/dist/plugins/key-rate-limit/ingress.js.map +1 -1
- package/dist/plugins/llm-protocol-adapter/control.js +48 -48
- package/dist/plugins/llm-protocol-adapter/control.js.map +1 -1
- package/dist/plugins/llm-protocol-adapter/index.js +53 -53
- package/dist/plugins/llm-protocol-adapter/index.js.map +1 -1
- package/dist/plugins/llm-tps/control.js +5 -5
- package/dist/plugins/llm-tps/control.js.map +1 -1
- package/dist/plugins/llm-tps/index.js +20 -20
- package/dist/plugins/llm-tps/index.js.map +1 -1
- package/dist/plugins/model-mapping/control.js +4 -4
- package/dist/plugins/model-mapping/control.js.map +1 -1
- package/dist/plugins/model-mapping/index.js +19 -19
- package/dist/plugins/model-mapping/index.js.map +1 -1
- package/dist/plugins/models-dev/control.js +10 -10
- package/dist/plugins/models-dev/control.js.map +1 -1
- package/dist/plugins/models-dev/index.js +23 -23
- package/dist/plugins/models-dev/index.js.map +1 -1
- package/dist/plugins/request-body-redaction/control.js +2 -2
- package/dist/plugins/request-body-redaction/control.js.map +1 -1
- package/dist/plugins/request-body-redaction/index.js +21 -21
- package/dist/plugins/request-body-redaction/index.js.map +1 -1
- package/dist/plugins/request-logs/index.js +27 -27
- package/dist/plugins/request-logs/index.js.map +1 -1
- package/dist/plugins/request-logs/ingress.js +2 -2
- package/dist/plugins/request-logs/ingress.js.map +1 -1
- package/dist/plugins/signature-repair/index.js +17 -17
- package/dist/plugins/signature-repair/index.js.map +1 -1
- package/dist/plugins/sse-envelope.d.ts +3 -0
- package/dist/plugins/token-budget/control.js +19 -19
- package/dist/plugins/token-budget/control.js.map +1 -1
- package/dist/plugins/token-budget/index.js +19 -19
- package/dist/plugins/token-budget/index.js.map +1 -1
- package/dist/plugins/token-budget/ingress.js +2 -2
- package/dist/plugins/token-budget/ingress.js.map +1 -1
- package/dist/plugins/token-metering/index.js +30 -30
- package/dist/plugins/token-metering/index.js.map +1 -1
- package/dist/plugins/token-stats/control.js +22 -22
- package/dist/plugins/token-stats/control.js.map +1 -1
- package/dist/plugins/token-stats/index.js +22 -22
- package/dist/plugins/token-stats/index.js.map +1 -1
- package/dist/plugins/user-auth/control.js +21 -21
- package/dist/plugins/user-auth/control.js.map +1 -1
- package/dist/plugins/user-auth/index.js +17 -17
- package/dist/plugins/user-auth/index.js.map +1 -1
- package/dist/public-listener/admission-registry.d.ts +15 -0
- package/dist/public-listener/forwarding.d.ts +24 -0
- package/dist/public-listener/headers.d.ts +5 -0
- package/dist/public-listener/index.d.ts +4 -0
- package/dist/public-listener/listener.d.ts +21 -0
- package/dist/public-listener/websocket.d.ts +4 -0
- package/dist/rate-limit/http.d.ts +80 -0
- package/dist/rate-limit/index.d.ts +7 -0
- package/dist/rate-limit/json.d.ts +8 -0
- package/dist/rate-limit/profile.d.ts +46 -0
- package/dist/rate-limit/protocol.d.ts +104 -0
- package/dist/rate-limit/store.d.ts +61 -0
- package/dist/scoped-plugin-registry.d.ts +645 -0
- package/dist/supervision/index.d.ts +12 -0
- package/dist/supervision/process-lifetime-guard.d.ts +54 -0
- package/dist/supervision/protocol.d.ts +173 -0
- package/dist/supervision/state-repository.d.ts +15 -0
- package/dist/supervision/strict-json.d.ts +2 -0
- package/dist/supervision/worker-descriptor.d.ts +77 -0
- package/dist/supervision/worker-http.d.ts +135 -0
- package/dist/supervision/worker-runtime-snapshot.d.ts +64 -0
- package/dist/token-stats-window.d.ts +23 -0
- package/dist/ui/assets.d.ts +8 -0
- package/dist/ui/icon-resources.d.ts +28 -0
- package/dist/ui/menu-icons.d.ts +15 -0
- package/dist/ui/menu-layout.d.ts +10 -0
- package/dist/ui/plugin-sandbox-policy.d.ts +11 -0
- package/dist/ui/server.d.ts +10 -0
- package/dist/updates/archive-installer.d.ts +8 -0
- package/dist/updates/controller.d.ts +50 -0
- package/dist/updates/download.d.ts +8 -0
- package/dist/updates/installation.d.ts +26 -0
- package/dist/updates/names.d.ts +3 -0
- package/dist/updates/release.d.ts +23 -0
- package/dist/updates/restart.d.ts +13 -0
- package/dist/utils/config-validator.d.ts +40 -0
- package/dist/utils/endpoint-resolver.d.ts +20 -0
- package/dist/utils/expression-dependencies.d.ts +10 -0
- package/dist/utils/plugin-helpers.d.ts +46 -0
- package/dist/websocket/headers.d.ts +9 -0
- package/dist/websocket/index.d.ts +3 -0
- package/dist/websocket/message.d.ts +3 -0
- package/dist/websocket/observation.d.ts +36 -0
- package/dist/websocket/transport.d.ts +197 -0
- package/dist/worker/health/checker.d.ts +54 -0
- package/dist/worker/health/scheduler.d.ts +27 -0
- package/dist/worker/request/body-source.d.ts +1 -0
- package/dist/worker/request/context-builder.d.ts +78 -0
- package/dist/worker/request/context.d.ts +55 -0
- package/dist/worker/request/credential.d.ts +10 -0
- package/dist/worker/request/handler.d.ts +3 -0
- package/dist/worker/request/proxy.d.ts +4 -0
- package/dist/worker/request/response-detector.d.ts +9 -0
- package/dist/worker/request/snapshot.d.ts +18 -0
- package/dist/worker/response/attempt-observation.d.ts +24 -0
- package/dist/worker/response/processor.d.ts +4 -0
- package/dist/worker/response/streaming-response.d.ts +1 -0
- package/dist/worker/rules/deep-merge.d.ts +2 -0
- package/dist/worker/rules/modifier.d.ts +3 -0
- package/dist/worker/state/plugin-manager.d.ts +95 -0
- package/dist/worker/state/runtime-state.d.ts +90 -0
- package/dist/worker/types.d.ts +44 -0
- package/dist/worker/upstream/condition-filter.d.ts +31 -0
- package/dist/worker/upstream/failover-coordinator.d.ts +93 -0
- package/dist/worker/upstream/filter.d.ts +37 -0
- package/dist/worker/upstream/priority-group.d.ts +66 -0
- package/dist/worker/upstream/selector.d.ts +10 -0
- package/dist/worker/upstream/service-execution.d.ts +17 -0
- package/dist/worker/utils/jitter.d.ts +81 -0
- package/dist/worker/utils/slow-start.d.ts +67 -0
- package/dist/worker/utils/status-code-matcher.d.ts +10 -0
- package/dist/worker.d.ts +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request context builder module
|
|
3
|
+
* Constructs ExpressionContext for dynamic value processing
|
|
4
|
+
*/
|
|
5
|
+
import type { ExpressionContext } from '../../expression-engine';
|
|
6
|
+
import type { RequestSnapshot } from '../types';
|
|
7
|
+
/**
|
|
8
|
+
* Result type for context building functions
|
|
9
|
+
*/
|
|
10
|
+
export interface RequestContextResult {
|
|
11
|
+
/** Expression context for dynamic value processing */
|
|
12
|
+
context: ExpressionContext;
|
|
13
|
+
/** Whether the request is streaming (SSE) */
|
|
14
|
+
isStreamingRequest: boolean;
|
|
15
|
+
/** Parsed request body (empty object if not JSON) */
|
|
16
|
+
parsedBody: Record<string, any>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Builds request context from a Request object
|
|
20
|
+
*
|
|
21
|
+
* Parses the request and extracts all information needed for
|
|
22
|
+
* expression evaluation (headers, body, URL, method, env).
|
|
23
|
+
*
|
|
24
|
+
* **Note:** For failover scenarios, use `buildRequestContextFromSnapshot()` instead
|
|
25
|
+
* to ensure proper isolation.
|
|
26
|
+
*
|
|
27
|
+
* @param req - Incoming HTTP request
|
|
28
|
+
* @param rewrittenPath - Path after path_rewrite rules applied
|
|
29
|
+
* @param requestLog - Request log for debugging
|
|
30
|
+
* @returns Request context result
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const { context, isStreamingRequest, parsedBody } =
|
|
35
|
+
* await buildRequestContext(req, { pathname: '/api/v1', search: '?id=123' }, requestLog);
|
|
36
|
+
*
|
|
37
|
+
* // Use context for dynamic value processing
|
|
38
|
+
* const apiKey = processDynamicValue('${env.API_KEY}', context);
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare function buildRequestContext(req: Request, rewrittenPath: {
|
|
42
|
+
pathname: string;
|
|
43
|
+
search: string;
|
|
44
|
+
}, _requestLog: any): Promise<RequestContextResult>;
|
|
45
|
+
/**
|
|
46
|
+
* Builds request context from a snapshot instead of a Request object
|
|
47
|
+
*
|
|
48
|
+
* This ensures complete isolation for failover retries. Each upstream
|
|
49
|
+
* attempt receives a clean copy of the original context, preventing
|
|
50
|
+
* plugin modifications from affecting subsequent retries.
|
|
51
|
+
*
|
|
52
|
+
* **Key differences from `buildRequestContext()`:**
|
|
53
|
+
* - No async I/O (snapshot already contains parsed body)
|
|
54
|
+
* - Deep clones headers and body for complete isolation
|
|
55
|
+
* - Used exclusively in failover retry scenarios
|
|
56
|
+
*
|
|
57
|
+
* @param snapshot - Request snapshot created before plugin execution
|
|
58
|
+
* @param rewrittenPath - Path after path_rewrite rules applied
|
|
59
|
+
* @param requestLog - Request log for debugging
|
|
60
|
+
* @returns Request context result
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* // In failover retry loop
|
|
65
|
+
* for (const upstream of retryQueue) {
|
|
66
|
+
* // Each iteration gets a clean context from snapshot
|
|
67
|
+
* const { context, isStreamingRequest, parsedBody } =
|
|
68
|
+
* buildRequestContextFromSnapshot(snapshot, rewrittenPath, requestLog);
|
|
69
|
+
*
|
|
70
|
+
* // Plugins can modify context without affecting next retry
|
|
71
|
+
* await executePlugins(context);
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export declare function buildRequestContextFromSnapshot(snapshot: RequestSnapshot, rewrittenPath: {
|
|
76
|
+
pathname: string;
|
|
77
|
+
search: string;
|
|
78
|
+
}, _requestLog: any): RequestContextResult;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { PluginConfigValue } from '../../plugin.types';
|
|
2
|
+
import type { Endpoint } from '@jeffusion/bungee-types';
|
|
3
|
+
/**
|
|
4
|
+
* Join base path and relative path with slash normalization.
|
|
5
|
+
* Rules:
|
|
6
|
+
* - No double slashes in result
|
|
7
|
+
* - Single slash between segments
|
|
8
|
+
* - Empty segments handled gracefully
|
|
9
|
+
*/
|
|
10
|
+
export declare function joinPaths(base: string, relative: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Mutable request context interface (what the pipeline passes around).
|
|
13
|
+
* This matches the actual context shape used in handler.ts.
|
|
14
|
+
*/
|
|
15
|
+
export interface MutableRequestContext {
|
|
16
|
+
url: URL;
|
|
17
|
+
method: string;
|
|
18
|
+
headers: Record<string, string>;
|
|
19
|
+
body?: any;
|
|
20
|
+
annotations?: Record<string, PluginConfigValue>;
|
|
21
|
+
query?: Record<string, string>;
|
|
22
|
+
upstreamId?: string;
|
|
23
|
+
routeId?: string;
|
|
24
|
+
serviceName?: string;
|
|
25
|
+
[key: string]: any;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Deep clone a mutable request context for failover attempts.
|
|
29
|
+
* Each failover attempt starts from the same base state.
|
|
30
|
+
* Mutations on the clone do NOT affect the original.
|
|
31
|
+
*/
|
|
32
|
+
export declare function cloneMutableRequestContext(ctx: MutableRequestContext): MutableRequestContext;
|
|
33
|
+
/**
|
|
34
|
+
* Rebase a route-relative context to a specific upstream target.
|
|
35
|
+
* Called after Phase 1+2 (route and service plugins) have modified the context,
|
|
36
|
+
* before Phase 3 (upstream/endpoint plugins) executes.
|
|
37
|
+
*
|
|
38
|
+
* Algorithm:
|
|
39
|
+
* 1. Parse upstream.target as URL
|
|
40
|
+
* 2. Set ctx.url.protocol/host/port from target
|
|
41
|
+
* 3. Join paths: joinPaths(targetUrl.pathname, ctx.url.pathname)
|
|
42
|
+
* 4. Preserve query string from Phase 1+2
|
|
43
|
+
* 5. Set upstreamId
|
|
44
|
+
*/
|
|
45
|
+
export declare function rebaseToUpstream(ctx: MutableRequestContext, upstream: Endpoint): void;
|
|
46
|
+
/**
|
|
47
|
+
* Build context for request-level onFinally hooks.
|
|
48
|
+
* These execute once per request: global -> route -> service (in that order).
|
|
49
|
+
*/
|
|
50
|
+
export declare function buildRequestLevelFinallyContext(routeId: string, serviceName?: string): Record<string, any>;
|
|
51
|
+
/**
|
|
52
|
+
* Build context for final-upstream-level onFinally hooks.
|
|
53
|
+
* These execute for the final upstream only (the one that actually responded).
|
|
54
|
+
*/
|
|
55
|
+
export declare function buildFinalUpstreamFinallyContext(routeId: string, upstreamId: string, serviceName?: string): Record<string, any>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CredentialLease, CredentialOutboundHeaderProfile, CredentialPolicy, CredentialRequestPolicy } from '../../plugin-control/contracts';
|
|
2
|
+
declare const HOP_HEADERS: Set<string>;
|
|
3
|
+
export declare function credentialPolicyFromManifest(manifest: unknown, contributionId: string): CredentialPolicy;
|
|
4
|
+
export declare function stripCredentialHeaders(headers: Headers, policy: CredentialPolicy): void;
|
|
5
|
+
export declare function assertCredentialTarget(target: URL, source: URL, policy: CredentialPolicy, method: string, expectedPath?: string): CredentialRequestPolicy;
|
|
6
|
+
export declare function applyOutboundHeaderProfile(source: Headers, profile: CredentialOutboundHeaderProfile): Headers;
|
|
7
|
+
export declare function validateCredentialLease(value: unknown, now?: number): CredentialLease;
|
|
8
|
+
export declare function sanitizeError(error: unknown, secrets?: readonly string[]): Error;
|
|
9
|
+
export declare function sanitizeMessage(error: unknown, secrets?: readonly string[]): string;
|
|
10
|
+
export { HOP_HEADERS };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { executeForward } from '../../gateway/forward-plugin';
|
|
2
|
+
export { AttemptCleanupError, UpstreamResponseValidationError, UpstreamPhaseFailoverSignal, ManagedUpstreamAccessError, UpstreamTimeoutError, UpstreamNetworkError, isUpstreamTimeoutError, isUpstreamNetworkError, isManagedUpstreamAccessError, isUpstreamPhaseFailoverSignal, } from '../../gateway/forward-plugin';
|
|
3
|
+
export type { ProxyRequestResult, ProxyAttemptOptions } from '../../gateway/forward-plugin';
|
|
4
|
+
export declare const proxyRequest: typeof executeForward;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const MAX_BODY_INSPECT: number;
|
|
2
|
+
export declare const MAX_PEEK_BYTES = 4096;
|
|
3
|
+
export interface ResponseCheckResult {
|
|
4
|
+
hit: boolean;
|
|
5
|
+
matchedKeyword?: string;
|
|
6
|
+
response?: Response;
|
|
7
|
+
}
|
|
8
|
+
/** A bounded owned prefix; no cloned/tee branch can accumulate a response. */
|
|
9
|
+
export declare function checkResponseForFailover(response: Response, keywords: string[]): Promise<ResponseCheckResult>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { BodyViewIdentity } from '../../gateway/body-contracts';
|
|
2
|
+
import type { RequestSnapshot } from '../types';
|
|
3
|
+
import { BodyProcessingError } from './body-source';
|
|
4
|
+
export declare class RequestBodyTooLargeError extends BodyProcessingError {
|
|
5
|
+
readonly maxBytes: number;
|
|
6
|
+
readonly receivedBytes: number;
|
|
7
|
+
constructor(maxBytes: number, receivedBytes: number);
|
|
8
|
+
}
|
|
9
|
+
/** Metadata capture never reads, clones, or parses a payload. */
|
|
10
|
+
export declare function createRequestSnapshot(req: Request, bodyParserLimit?: string, signal?: AbortSignal, body?: ReadableStream<Uint8Array> | null, identity?: BodyViewIdentity): Promise<RequestSnapshot>;
|
|
11
|
+
export declare function readSnapshotJson(snapshot: RequestSnapshot, reason: string, emptyObject?: boolean): Promise<any>;
|
|
12
|
+
export declare function ensureSnapshotCloned(snapshot: RequestSnapshot): RequestSnapshot;
|
|
13
|
+
export declare const ensureSnapshotBodyCloned: typeof ensureSnapshotCloned;
|
|
14
|
+
/** A branch shares the controlled owner until its parent produced a new JSON representation. */
|
|
15
|
+
export declare function deriveRequestSnapshot(snapshot: RequestSnapshot, context: import('./context').MutableRequestContext, identity: BodyViewIdentity): {
|
|
16
|
+
snapshot: RequestSnapshot;
|
|
17
|
+
dispose: () => void;
|
|
18
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { AttemptObservationEvent } from '../../hooks/plugin-hooks';
|
|
2
|
+
import type { BodyHandle } from '../../gateway/body-contracts';
|
|
3
|
+
export interface AttemptBodyOptions {
|
|
4
|
+
maxBytes?: number;
|
|
5
|
+
bodyHandle?: BodyHandle;
|
|
6
|
+
backlogBytes?: number;
|
|
7
|
+
backlogEvents?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface AttemptResponseObservationContext {
|
|
10
|
+
readonly requestId: string;
|
|
11
|
+
readonly routeId: string;
|
|
12
|
+
readonly attemptId: string;
|
|
13
|
+
readonly upstreamId: string;
|
|
14
|
+
readonly status: number;
|
|
15
|
+
}
|
|
16
|
+
export interface ByteObservation extends TransformStream<Uint8Array, Uint8Array> {
|
|
17
|
+
completion: Promise<void>;
|
|
18
|
+
readonly endedAtMonotonicMs?: number;
|
|
19
|
+
finish(): void;
|
|
20
|
+
}
|
|
21
|
+
/** Copies a bounded side queue; slow or failing observers cannot stall wire delivery. */
|
|
22
|
+
export declare function createAttemptResponseObserver(protocol: 'json' | 'sse', context: AttemptResponseObservationContext, dispatch: (event: AttemptObservationEvent) => Promise<void>, onComplete?: () => void, coding?: string, phase?: 'request' | 'response', url?: string, signal?: AbortSignal, options?: AttemptBodyOptions): ByteObservation;
|
|
23
|
+
export declare function cloneFrozenObservationBody(body: Record<string, unknown>): Record<string, unknown>;
|
|
24
|
+
export declare function freezeObservationBody(body: Record<string, unknown>): Record<string, unknown>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { executeResponseRules } from '../../gateway/response-plugin';
|
|
2
|
+
export { completionStream } from '../../gateway/response-plugin';
|
|
3
|
+
export type { PrepareResponseResult, StreamCompletionState } from '../../gateway/response-plugin';
|
|
4
|
+
export declare const prepareResponse: typeof executeResponseRules;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isStreamingResponse(response: Response): boolean;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Global plugin registry management
|
|
3
|
+
*
|
|
4
|
+
* 管理两个独立的插件注册表:
|
|
5
|
+
*
|
|
6
|
+
* 1. PluginRegistry(元数据管理)
|
|
7
|
+
* - 用途:UI 元数据管理与插件发现
|
|
8
|
+
* - 不执行插件,只管理插件类信息
|
|
9
|
+
*
|
|
10
|
+
* 2. ScopedPluginRegistry(插件执行)
|
|
11
|
+
* - 用途:创建 Handler 实例、预编译 Hooks、实际执行插件
|
|
12
|
+
* - 支持三级作用域:global、route、upstream
|
|
13
|
+
*/
|
|
14
|
+
import { PluginRegistry } from '../../plugin-registry';
|
|
15
|
+
import type { AppConfig } from '@jeffusion/bungee-types';
|
|
16
|
+
import { PluginRuntimeOrchestrator, type PluginRuntimeOrchestratorApplyResult } from '../../plugin-runtime-orchestrator';
|
|
17
|
+
import type { PluginServiceHost } from '../../plugin-services';
|
|
18
|
+
/**
|
|
19
|
+
* Gets the current plugin registry instance
|
|
20
|
+
*
|
|
21
|
+
* @returns Plugin registry instance or null if not initialized
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const registry = getPluginRegistry();
|
|
26
|
+
* if (registry) {
|
|
27
|
+
* const metadata = registry.getAllPluginsMetadata();
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function getPluginRegistry(): PluginRegistry | null;
|
|
32
|
+
/**
|
|
33
|
+
* Sets the plugin registry instance
|
|
34
|
+
*
|
|
35
|
+
* **Note:** This function is for internal use only.
|
|
36
|
+
* External code should use `initializePluginRegistryForTests()` instead.
|
|
37
|
+
*
|
|
38
|
+
* @param registry - Plugin registry instance to set
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
export declare function setPluginRegistry(registry: PluginRegistry | null): void;
|
|
42
|
+
export declare function getPluginRuntimeOrchestrator(): PluginRuntimeOrchestrator | null;
|
|
43
|
+
export declare function initializePluginRuntime(config: AppConfig, options?: {
|
|
44
|
+
basePath?: string;
|
|
45
|
+
activatedPluginNames?: readonly string[];
|
|
46
|
+
/** Canonical worker service host shared with the host RPC adapter. */
|
|
47
|
+
services?: PluginServiceHost;
|
|
48
|
+
/** Host gate awaited before any plugin handler is created. */
|
|
49
|
+
beforeBootstrap?: (signal: AbortSignal) => Promise<void>;
|
|
50
|
+
/** Cancels cooperative plugin initialization during worker shutdown. */
|
|
51
|
+
signal?: AbortSignal;
|
|
52
|
+
}): Promise<PluginRuntimeOrchestratorApplyResult>;
|
|
53
|
+
export declare function reconcilePluginRuntime(config: AppConfig): Promise<PluginRuntimeOrchestratorApplyResult>;
|
|
54
|
+
/**
|
|
55
|
+
* Initialize Plugin Registries for testing
|
|
56
|
+
*
|
|
57
|
+
* 初始化测试环境的插件系统,包括:
|
|
58
|
+
* 1. PluginRegistry - 加载插件元数据(用于 UI)
|
|
59
|
+
* 2. ScopedPluginRegistry - 创建插件实例并预编译 Hooks(用于执行)
|
|
60
|
+
*
|
|
61
|
+
* **注意**:生产环境的初始化由 config worker lifecycle 完成。
|
|
62
|
+
*
|
|
63
|
+
* @param config - 应用配置
|
|
64
|
+
* @param basePath - 插件加载的基础路径(默认 process.cwd())
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```typescript
|
|
68
|
+
* // In test setup
|
|
69
|
+
* beforeEach(async () => {
|
|
70
|
+
* await initializePluginRegistryForTests(testConfig, '/path/to/plugins');
|
|
71
|
+
* });
|
|
72
|
+
*
|
|
73
|
+
* afterEach(async () => {
|
|
74
|
+
* await cleanupPluginRegistry();
|
|
75
|
+
* });
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export declare function initializePluginRegistryForTests(config: AppConfig, basePath?: string): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Clean up Plugin Registries
|
|
81
|
+
*
|
|
82
|
+
* 清理所有插件注册表,释放资源。
|
|
83
|
+
* 应在以下场景调用:
|
|
84
|
+
* - 测试清理(afterEach/afterAll)
|
|
85
|
+
* - 服务器关闭
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```typescript
|
|
89
|
+
* // In test teardown
|
|
90
|
+
* afterEach(async () => {
|
|
91
|
+
* await cleanupPluginRegistry();
|
|
92
|
+
* });
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
export declare function cleanupPluginRegistry(): Promise<void>;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime state management for upstream servers
|
|
3
|
+
* Tracks health status and failure times for failover functionality
|
|
4
|
+
*/
|
|
5
|
+
import type { AppConfig, Endpoint, LoadBalancingConfig } from '@jeffusion/bungee-types';
|
|
6
|
+
import type { RuntimeUpstream } from '../types';
|
|
7
|
+
/**
|
|
8
|
+
* Global runtime state tracking upstream health per route
|
|
9
|
+
* Map key: route path
|
|
10
|
+
* Map value: upstreams with runtime status
|
|
11
|
+
*/
|
|
12
|
+
export declare const roundRobinCursors: Map<string, number>;
|
|
13
|
+
export declare const runtimeState: Map<string, {
|
|
14
|
+
upstreams: RuntimeUpstream[];
|
|
15
|
+
load_balancing?: LoadBalancingConfig;
|
|
16
|
+
}>;
|
|
17
|
+
export declare const MAX_RUNTIME_STATE_SNAPSHOT_RECORDS = 1024;
|
|
18
|
+
export declare class RuntimeStateSnapshotError extends Error {
|
|
19
|
+
readonly code: 'duplicate_upstream_id' | 'unsafe_count';
|
|
20
|
+
readonly name = "RuntimeStateSnapshotError";
|
|
21
|
+
constructor(code: 'duplicate_upstream_id' | 'unsafe_count', message: string);
|
|
22
|
+
}
|
|
23
|
+
export interface RuntimeStateSnapshotRecord {
|
|
24
|
+
readonly state_key: string;
|
|
25
|
+
readonly upstream_id: string;
|
|
26
|
+
/** Circuit-breaker state only; this is not proof of an active health probe. */
|
|
27
|
+
readonly circuit_state: RuntimeUpstream['status'];
|
|
28
|
+
readonly active_request_count: number;
|
|
29
|
+
readonly last_used_time: number | null;
|
|
30
|
+
readonly last_failure_time: number | null;
|
|
31
|
+
readonly consecutive_failures: number;
|
|
32
|
+
readonly consecutive_successes: number;
|
|
33
|
+
readonly health_check_successes: number;
|
|
34
|
+
readonly health_check_failures: number;
|
|
35
|
+
readonly recovery_attempt_count: number;
|
|
36
|
+
}
|
|
37
|
+
export interface RuntimeStateSnapshot {
|
|
38
|
+
readonly records: readonly RuntimeStateSnapshotRecord[];
|
|
39
|
+
readonly overflow: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Initializes runtime state for routes that need upstream runtime tracking
|
|
43
|
+
*
|
|
44
|
+
* This function should be called during server startup to set up
|
|
45
|
+
* health tracking for upstream servers. Routes with failover enabled or
|
|
46
|
+
* load balancing configured have runtime state tracking.
|
|
47
|
+
*
|
|
48
|
+
* **Initialization rules:**
|
|
49
|
+
* - All upstreams start in HEALTHY status
|
|
50
|
+
* - last_failure_time is undefined initially
|
|
51
|
+
* - Routes with failover enabled or load balancing configured are tracked
|
|
52
|
+
* - Active health checks are started if configured
|
|
53
|
+
*
|
|
54
|
+
* @param config - Application configuration containing route definitions
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* const config: AppConfig = {
|
|
59
|
+
* routes: [
|
|
60
|
+
* {
|
|
61
|
+
* path: '/api',
|
|
62
|
+
* failover: { enabled: true },
|
|
63
|
+
* upstreams: [
|
|
64
|
+
* { target: 'http://server1:3000', weight: 100 },
|
|
65
|
+
* { target: 'http://server2:3000', weight: 100 }
|
|
66
|
+
* ]
|
|
67
|
+
* }
|
|
68
|
+
* ]
|
|
69
|
+
* };
|
|
70
|
+
* initializeRuntimeState(config);
|
|
71
|
+
* // Now runtimeState.get('/api') contains upstreams with HEALTHY status
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export declare function initializeRuntimeState(config: AppConfig): void;
|
|
75
|
+
export declare function createRuntimeUpstreams(endpoints: Endpoint[]): RuntimeUpstream[];
|
|
76
|
+
export declare function incrementActiveRequests(stateKey: string, upstreamId: string): void;
|
|
77
|
+
export declare function decrementActiveRequests(stateKey: string, upstreamId: string): void;
|
|
78
|
+
export declare function getActiveRequestCount(stateKey: string, upstreamId: string): number;
|
|
79
|
+
/**
|
|
80
|
+
* Synchronously copies the observable upstream state. `active_request_count`
|
|
81
|
+
* deliberately comes from the live counter map, not RuntimeUpstream's field.
|
|
82
|
+
*/
|
|
83
|
+
export declare function getRuntimeStateSnapshot(): RuntimeStateSnapshot;
|
|
84
|
+
export declare function tryAcquireHalfOpenSlot(stateKey: string, upstreamId: string): boolean;
|
|
85
|
+
export declare function releaseHalfOpenSlot(stateKey: string, upstreamId: string): void;
|
|
86
|
+
/**
|
|
87
|
+
* Cleanup runtime state and stop all health check schedulers
|
|
88
|
+
* Should be called on server shutdown
|
|
89
|
+
*/
|
|
90
|
+
export declare function cleanupRuntimeState(): void;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { RouteConfig, Endpoint, FailoverConfig, LoadBalancingConfig, ServiceHealthCheckConfig, ServiceReference } from '@jeffusion/bungee-types';
|
|
2
|
+
import type { ExpressionContext } from '../expression-engine';
|
|
3
|
+
export interface EffectiveRouteConfig extends RouteConfig {
|
|
4
|
+
endpoints: Endpoint[];
|
|
5
|
+
failover?: FailoverConfig;
|
|
6
|
+
load_balancing?: LoadBalancingConfig;
|
|
7
|
+
service_health_check?: ServiceHealthCheckConfig;
|
|
8
|
+
state_key?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface RuntimeTargetState {
|
|
11
|
+
upstream_id: string;
|
|
12
|
+
status: 'HEALTHY' | 'UNHEALTHY' | 'HALF_OPEN';
|
|
13
|
+
last_failure_time?: number;
|
|
14
|
+
last_used_time?: number;
|
|
15
|
+
consecutive_failures: number;
|
|
16
|
+
consecutive_successes: number;
|
|
17
|
+
recovery_attempt_count: number;
|
|
18
|
+
health_check_successes?: number;
|
|
19
|
+
health_check_failures?: number;
|
|
20
|
+
slow_start_recovery_time?: number;
|
|
21
|
+
slow_start_weight_factor?: number;
|
|
22
|
+
active_request_count?: number;
|
|
23
|
+
}
|
|
24
|
+
export interface RuntimeUpstream extends Endpoint, RuntimeTargetState {
|
|
25
|
+
}
|
|
26
|
+
export interface RuntimeServiceReference extends ServiceReference, RuntimeTargetState {
|
|
27
|
+
readonly kind: 'service';
|
|
28
|
+
readonly condition?: never;
|
|
29
|
+
readonly target?: never;
|
|
30
|
+
}
|
|
31
|
+
export type RuntimeCandidate = RuntimeUpstream | RuntimeServiceReference;
|
|
32
|
+
export declare function isServiceReference(candidate: RuntimeCandidate): candidate is RuntimeServiceReference;
|
|
33
|
+
export interface RequestSnapshot {
|
|
34
|
+
bodySource?: import("./request/body-source").BodySource;
|
|
35
|
+
method: string;
|
|
36
|
+
url: string;
|
|
37
|
+
headers: Record<string, string>;
|
|
38
|
+
body: any;
|
|
39
|
+
content_type: string;
|
|
40
|
+
is_json_body: boolean;
|
|
41
|
+
is_body_cloned?: boolean;
|
|
42
|
+
is_headers_cloned?: boolean;
|
|
43
|
+
}
|
|
44
|
+
export type UpstreamSelector = (upstreams: RuntimeUpstream[], route?: EffectiveRouteConfig, context?: ExpressionContext) => RuntimeUpstream | undefined;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Upstream condition filter module
|
|
3
|
+
* Filters upstreams based on condition expressions evaluated against request context
|
|
4
|
+
*/
|
|
5
|
+
import type { RuntimeCandidate } from '../types';
|
|
6
|
+
import type { ExpressionContext } from '../../expression-engine';
|
|
7
|
+
/**
|
|
8
|
+
* Filters upstreams based on their condition expressions
|
|
9
|
+
*
|
|
10
|
+
* Rules:
|
|
11
|
+
* - Upstreams without a condition are always included
|
|
12
|
+
* - Upstreams with a condition are included only if the expression evaluates to truthy
|
|
13
|
+
* - If condition evaluation fails, the upstream is excluded and a warning is logged
|
|
14
|
+
*
|
|
15
|
+
* @param upstreams - The upstreams to filter
|
|
16
|
+
* @param context - The expression context containing request data
|
|
17
|
+
* @returns Filtered array of upstreams that match their conditions
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const upstreams = [
|
|
22
|
+
* { target: 'http://openai', condition: "{{ body.model === 'gpt-4' }}" },
|
|
23
|
+
* { target: 'http://anthropic', condition: "{{ body.model === 'claude-3' }}" },
|
|
24
|
+
* { target: 'http://fallback' } // no condition, always matches
|
|
25
|
+
* ];
|
|
26
|
+
* const context = { body: { model: 'gpt-4' }, ... };
|
|
27
|
+
* const filtered = filterByCondition(upstreams, context);
|
|
28
|
+
* // Returns: [{ target: 'http://openai', ... }, { target: 'http://fallback', ... }]
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function filterByCondition<T extends RuntimeCandidate>(upstreams: T[], context: ExpressionContext): T[];
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Failover coordinator module
|
|
3
|
+
* Manages the entire failover process with priority-based upstream selection
|
|
4
|
+
*/
|
|
5
|
+
import type { EffectiveRouteConfig, RuntimeUpstream, RuntimeCandidate } from '../types';
|
|
6
|
+
import type { ExpressionContext } from '../../expression-engine';
|
|
7
|
+
/**
|
|
8
|
+
* Failover Coordinator
|
|
9
|
+
*
|
|
10
|
+
* Manages the entire failover flow:
|
|
11
|
+
* - Groups upstreams by priority
|
|
12
|
+
* - Attempts high priority groups first, then falls back to lower priorities
|
|
13
|
+
* - Tracks attempted and skipped upstreams
|
|
14
|
+
* - Provides iterator interface (hasNext/selectNext)
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const coordinator = new FailoverCoordinator(upstreams, route, 5000, context);
|
|
19
|
+
*
|
|
20
|
+
* while (coordinator.hasNext()) {
|
|
21
|
+
* const selection = coordinator.selectNext();
|
|
22
|
+
* if (!selection) break;
|
|
23
|
+
*
|
|
24
|
+
* const { upstream, shouldTransitionToHalfOpen } = selection;
|
|
25
|
+
*
|
|
26
|
+
* try {
|
|
27
|
+
* const response = await proxyRequest(...);
|
|
28
|
+
* return response; // Success
|
|
29
|
+
* } catch (error) {
|
|
30
|
+
* // Continue to next upstream
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare class FailoverCoordinator<T extends RuntimeCandidate = RuntimeUpstream> {
|
|
36
|
+
private priorityGroups;
|
|
37
|
+
private sortedPriorities;
|
|
38
|
+
private currentPriorityIndex;
|
|
39
|
+
private attemptedTargets;
|
|
40
|
+
private skippedTargets;
|
|
41
|
+
private totalUpstreams;
|
|
42
|
+
/**
|
|
43
|
+
* Creates a new Failover Coordinator
|
|
44
|
+
*
|
|
45
|
+
* @param upstreams - All upstreams for this route
|
|
46
|
+
* @param route - Route configuration
|
|
47
|
+
* @param recoveryIntervalMs - Recovery interval in milliseconds
|
|
48
|
+
* @param context - Expression context for condition evaluation (optional)
|
|
49
|
+
*/
|
|
50
|
+
constructor(upstreams: T[], route: EffectiveRouteConfig, recoveryIntervalMs: number, context?: ExpressionContext);
|
|
51
|
+
/**
|
|
52
|
+
* Check if there are more upstreams to try
|
|
53
|
+
*
|
|
54
|
+
* @returns True if there are more upstreams available
|
|
55
|
+
*/
|
|
56
|
+
hasNext(): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Select the next upstream to try
|
|
59
|
+
*
|
|
60
|
+
* Process:
|
|
61
|
+
* 1. Get current priority group
|
|
62
|
+
* 2. Try to select an upstream from it
|
|
63
|
+
* 3. If selection fails or upstream cannot be attempted:
|
|
64
|
+
* - If cannot attempt: skip it and retry
|
|
65
|
+
* - If no more upstreams in group: move to next priority
|
|
66
|
+
* 4. If selection succeeds and can attempt: mark as attempted and return
|
|
67
|
+
*
|
|
68
|
+
* @returns Selected upstream with transition info, or null if none available
|
|
69
|
+
*/
|
|
70
|
+
selectNext(): {
|
|
71
|
+
upstream: T;
|
|
72
|
+
shouldTransitionToHalfOpen: boolean;
|
|
73
|
+
} | null;
|
|
74
|
+
/**
|
|
75
|
+
* Get attempt statistics
|
|
76
|
+
*
|
|
77
|
+
* @returns Statistics about attempted/skipped/total upstreams
|
|
78
|
+
*/
|
|
79
|
+
getStats(): {
|
|
80
|
+
attempted: number;
|
|
81
|
+
skipped: number;
|
|
82
|
+
total: number;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Group upstreams by priority
|
|
86
|
+
*
|
|
87
|
+
* @param upstreams - All upstreams
|
|
88
|
+
* @param route - Route configuration
|
|
89
|
+
* @param recoveryIntervalMs - Recovery interval
|
|
90
|
+
* @returns Map of priority to PriorityGroup
|
|
91
|
+
*/
|
|
92
|
+
private groupByPriority;
|
|
93
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Upstream filter module
|
|
3
|
+
* Filters upstreams based on health status and recovery intervals
|
|
4
|
+
*/
|
|
5
|
+
import type { RuntimeTargetState } from '../types';
|
|
6
|
+
/**
|
|
7
|
+
* Checks if an upstream can be attempted based on its status and recovery interval
|
|
8
|
+
*
|
|
9
|
+
* Rules:
|
|
10
|
+
* - HEALTHY: Always can be attempted
|
|
11
|
+
* - HALF_OPEN: Always can be attempted (already in recovery test mode)
|
|
12
|
+
* - UNHEALTHY: Check if exponential backoff recovery interval has elapsed
|
|
13
|
+
*
|
|
14
|
+
* Recovery interval uses exponential backoff:
|
|
15
|
+
* - 1st attempt: baseInterval * 2^0 = baseInterval (default 5s)
|
|
16
|
+
* - 2nd attempt: baseInterval * 2^1 = baseInterval * 2 (default 10s)
|
|
17
|
+
* - 3rd attempt: baseInterval * 2^2 = baseInterval * 4 (default 20s)
|
|
18
|
+
* - And so on, capped at MAX_RECOVERY_INTERVAL_MS (5 minutes)
|
|
19
|
+
*
|
|
20
|
+
* @param upstream - The upstream to check
|
|
21
|
+
* @param recoveryIntervalMs - Base recovery interval in milliseconds
|
|
22
|
+
* @returns Object indicating if upstream can be attempted and if it should transition to HALF_OPEN
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const { canAttempt, shouldTransitionToHalfOpen } = canAttemptUpstream(upstream, 5000);
|
|
27
|
+
* if (!canAttempt) {
|
|
28
|
+
* // Skip this upstream
|
|
29
|
+
* } else if (shouldTransitionToHalfOpen) {
|
|
30
|
+
* upstream.status = 'HALF_OPEN';
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare function canAttemptUpstream(upstream: RuntimeTargetState, recoveryIntervalMs: number): {
|
|
35
|
+
canAttempt: boolean;
|
|
36
|
+
shouldTransitionToHalfOpen: boolean;
|
|
37
|
+
};
|