@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.
Files changed (445) hide show
  1. package/dist/access-database.d.ts +22 -0
  2. package/dist/api/handlers/logs.d.ts +66 -0
  3. package/dist/api/handlers/stats.d.ts +50 -0
  4. package/dist/api/logs.d.ts +145 -0
  5. package/dist/api/types.d.ts +21 -0
  6. package/dist/{chunk-assets-swq50rh3.js → chunk-assets-vsan7gav.js} +11 -11
  7. package/dist/{chunk-body-capture-gtta9q26.js → chunk-body-capture-sbk6cdf9.js} +2 -2
  8. package/dist/{chunk-handler-ehkkxpnq.js → chunk-handler-9k6b95w4.js} +2 -2
  9. package/dist/{chunk-main-rcw37zhd.js → chunk-main-1p15rgq5.js} +1 -1
  10. package/dist/{chunk-main-10pgdbgn.js → chunk-main-2efrk1nt.js} +1 -1
  11. package/dist/{chunk-main-a4eygw79.js → chunk-main-d74e7qxc.js} +1 -1
  12. package/dist/{chunk-main-p5rpfk7t.js → chunk-main-gwaw6pxp.js} +1 -1
  13. package/dist/{chunk-main-25kbhd4n.js → chunk-main-mqgkewnx.js} +1 -1
  14. package/dist/{chunk-main-0w3jk2x4.js → chunk-main-qm1tgaka.js} +2 -2
  15. package/dist/{chunk-master-276v10xm.js → chunk-master-wtcfwd6g.js} +6 -6
  16. package/dist/{chunk-plugin-context-manager-nexyp0jb.js → chunk-plugin-context-manager-kabrbg0s.js} +1 -1
  17. package/dist/{chunk-plugin-manager-dvxc5w6p.js → chunk-plugin-manager-q1bt6xnw.js} +2 -2
  18. package/dist/{chunk-runtime-upgrade-sjxsa2r6.js → chunk-runtime-upgrade-rvm3d096.js} +3 -3
  19. package/dist/{chunk-runtime-qbfd9z3p.js → chunk-runtime-xmp308t7.js} +2 -2
  20. package/dist/{chunk-worker-5mdsmhte.js → chunk-worker-99q8qnj9.js} +9 -9
  21. package/dist/config-publication/admission-handoff.d.ts +13 -0
  22. package/dist/config-publication/coordinator-types.d.ts +176 -0
  23. package/dist/config-publication/current-startup.d.ts +26 -0
  24. package/dist/config-publication/drain-workers.d.ts +15 -0
  25. package/dist/config-publication/index.d.ts +6 -0
  26. package/dist/config-publication/master-coordinator.d.ts +45 -0
  27. package/dist/config-publication/master-messages.d.ts +2 -0
  28. package/dist/config-publication/message-fields.d.ts +20 -0
  29. package/dist/config-publication/messages.d.ts +3 -0
  30. package/dist/config-publication/process-cleanup.d.ts +30 -0
  31. package/dist/config-publication/process-identity.d.ts +14 -0
  32. package/dist/config-publication/process-termination.d.ts +7 -0
  33. package/dist/config-publication/publication-runner.d.ts +50 -0
  34. package/dist/config-publication/recovery-disposition.d.ts +17 -0
  35. package/dist/config-publication/types.d.ts +137 -0
  36. package/dist/config-publication/waiter-safety.d.ts +2 -0
  37. package/dist/config-publication/worker-messages.d.ts +2 -0
  38. package/dist/config-publication/worker-runtime-contract.d.ts +76 -0
  39. package/dist/config-publication/worker-runtime-plugins.d.ts +8 -0
  40. package/dist/config-publication/worker-runtime.d.ts +22 -0
  41. package/dist/config-publication/worker-wait.d.ts +44 -0
  42. package/dist/config-storage/active-publication.d.ts +37 -0
  43. package/dist/config-storage/aggregate.d.ts +4 -0
  44. package/dist/config-storage/async-config-repository.d.ts +125 -0
  45. package/dist/config-storage/commit-transaction.d.ts +13 -0
  46. package/dist/config-storage/compiler.d.ts +4 -0
  47. package/dist/config-storage/config-repository.d.ts +118 -0
  48. package/dist/config-storage/consistent-read.d.ts +2 -0
  49. package/dist/config-storage/content-hash.d.ts +17 -0
  50. package/dist/config-storage/cross-table-audit.d.ts +20 -0
  51. package/dist/config-storage/current-revision.d.ts +2 -0
  52. package/dist/config-storage/domain-validation.d.ts +5 -0
  53. package/dist/config-storage/expression-ast.d.ts +2 -0
  54. package/dist/config-storage/expression-call-policy.d.ts +2 -0
  55. package/dist/config-storage/expression-syntax.d.ts +2 -0
  56. package/dist/config-storage/gateway-target-validation.d.ts +5 -0
  57. package/dist/config-storage/global-scalars.d.ts +6 -0
  58. package/dist/config-storage/global-validation.d.ts +2 -0
  59. package/dist/config-storage/immutable-snapshot.d.ts +4 -0
  60. package/dist/config-storage/index.d.ts +21 -0
  61. package/dist/config-storage/json-preflight.d.ts +15 -0
  62. package/dist/config-storage/management-protection.d.ts +10 -0
  63. package/dist/config-storage/materialize.d.ts +3 -0
  64. package/dist/config-storage/menu-store.d.ts +12 -0
  65. package/dist/config-storage/migrations/baseline.d.ts +8 -0
  66. package/dist/config-storage/migrations/index.d.ts +8 -0
  67. package/dist/config-storage/migrations/management-protection.d.ts +2 -0
  68. package/dist/config-storage/migrations/plan.d.ts +9 -0
  69. package/dist/config-storage/migrations/prepared-worker-allocation.d.ts +2 -0
  70. package/dist/config-storage/migrations/publication-retirement.d.ts +3 -0
  71. package/dist/config-storage/migrations/publication-targets.d.ts +3 -0
  72. package/dist/config-storage/migrations/request-logs-default.d.ts +2 -0
  73. package/dist/config-storage/migrations/runtime-cutover.d.ts +2 -0
  74. package/dist/config-storage/migrations/service-references.d.ts +3 -0
  75. package/dist/config-storage/migrations/ui-menus.d.ts +2 -0
  76. package/dist/config-storage/migrations/websocket-connections.d.ts +2 -0
  77. package/dist/config-storage/migrations/websocket-message-size.d.ts +2 -0
  78. package/dist/config-storage/migrations/worker-launch-capacity.d.ts +2 -0
  79. package/dist/config-storage/modification-validation.d.ts +4 -0
  80. package/dist/config-storage/operation-records.d.ts +42 -0
  81. package/dist/config-storage/operation-relations.d.ts +6 -0
  82. package/dist/config-storage/operation-store.d.ts +12 -0
  83. package/dist/config-storage/persisted-json.d.ts +2 -0
  84. package/dist/config-storage/persisted-validation.d.ts +7 -0
  85. package/dist/config-storage/plugin-name.d.ts +2 -0
  86. package/dist/config-storage/plugin-schema.d.ts +16 -0
  87. package/dist/config-storage/policy-fields.d.ts +15 -0
  88. package/dist/config-storage/prepared-command.d.ts +14 -0
  89. package/dist/config-storage/read-materialization.d.ts +4 -0
  90. package/dist/config-storage/recovery-store.d.ts +21 -0
  91. package/dist/config-storage/relation-materialization.d.ts +30 -0
  92. package/dist/config-storage/repository-snapshot.d.ts +5 -0
  93. package/dist/config-storage/repository-types.d.ts +216 -0
  94. package/dist/config-storage/repository-validation.d.ts +6 -0
  95. package/dist/config-storage/request-logs-default.d.ts +5 -0
  96. package/dist/config-storage/retirement-store.d.ts +78 -0
  97. package/dist/config-storage/route-policy-validation.d.ts +2 -0
  98. package/dist/config-storage/runtime-config.d.ts +14 -0
  99. package/dist/config-storage/runtime-cutover.d.ts +13 -0
  100. package/dist/config-storage/runtime-recovery-budget.d.ts +35 -0
  101. package/dist/config-storage/schema-fingerprint.d.ts +5 -0
  102. package/dist/config-storage/schema.d.ts +2 -0
  103. package/dist/config-storage/service-policy-validation.d.ts +4 -0
  104. package/dist/config-storage/service-reference-upgrade.d.ts +4 -0
  105. package/dist/config-storage/serving-snapshot.d.ts +9 -0
  106. package/dist/config-storage/snapshot-validation.d.ts +3 -0
  107. package/dist/config-storage/sqlite-errors.d.ts +3 -0
  108. package/dist/config-storage/sqlite-query.d.ts +3 -0
  109. package/dist/config-storage/sqlite-version.d.ts +10 -0
  110. package/dist/config-storage/storage-protocol.d.ts +52 -0
  111. package/dist/config-storage/utf16.d.ts +2 -0
  112. package/dist/config-storage/validation.d.ts +31 -0
  113. package/dist/config-storage/worker-launch-store.d.ts +93 -0
  114. package/dist/config-worker/http-provider.d.ts +6 -0
  115. package/dist/config-worker/lifecycle.d.ts +84 -0
  116. package/dist/config-worker/private-transport.d.ts +31 -0
  117. package/dist/config-worker/process-environment.d.ts +38 -0
  118. package/dist/config-worker/rate-limit-provider.d.ts +31 -0
  119. package/dist/config-worker/runtime-dependencies.d.ts +12 -0
  120. package/dist/config-worker/snapshot-compiler.d.ts +5 -0
  121. package/dist/config-worker/supervised-process-entry.d.ts +8 -0
  122. package/dist/core-version.d.ts +1 -0
  123. package/dist/daemon-control/bootstrap.d.ts +41 -0
  124. package/dist/daemon-control/index.d.ts +1 -0
  125. package/dist/daemon-control/launch-identity.d.ts +26 -0
  126. package/dist/daemon-control/shutdown.d.ts +22 -0
  127. package/dist/data-admission/errors.d.ts +16 -0
  128. package/dist/data-admission/host.d.ts +92 -0
  129. package/dist/data-admission/keyed-state.d.ts +21 -0
  130. package/dist/data-admission/rpc.d.ts +40 -0
  131. package/dist/data-admission/worker.d.ts +66 -0
  132. package/dist/database-schema.d.ts +2 -0
  133. package/dist/expression-engine.d.ts +33 -0
  134. package/dist/gateway/admission-plugin.d.ts +7 -0
  135. package/dist/gateway/auxiliary-request.d.ts +7 -0
  136. package/dist/gateway/body-contracts.d.ts +39 -0
  137. package/dist/gateway/body-events.d.ts +58 -0
  138. package/dist/gateway/body-factory.d.ts +4 -0
  139. package/dist/gateway/body-observation-stream.d.ts +6 -0
  140. package/dist/gateway/body-plugin.d.ts +8 -0
  141. package/dist/gateway/body-resources.d.ts +37 -0
  142. package/dist/gateway/body-service.d.ts +116 -0
  143. package/dist/gateway/contracts.d.ts +196 -0
  144. package/dist/gateway/controlled-views.d.ts +5 -0
  145. package/dist/gateway/dispatch-plugin.d.ts +11 -0
  146. package/dist/gateway/dispatch-targets.d.ts +4 -0
  147. package/dist/gateway/forward-plugin.d.ts +136 -0
  148. package/dist/gateway/plugin.d.ts +23 -0
  149. package/dist/gateway/plugin.js +18 -18
  150. package/dist/gateway/request-log-contracts.d.ts +346 -0
  151. package/dist/gateway/request-log.d.ts +105 -0
  152. package/dist/gateway/request-plugin.d.ts +98 -0
  153. package/dist/gateway/request-rules-plugin.d.ts +61 -0
  154. package/dist/gateway/response-plugin.d.ts +34 -0
  155. package/dist/gateway/response-views.d.ts +33 -0
  156. package/dist/gateway/responses-websocket-session.d.ts +24 -0
  157. package/dist/gateway/retry-action.d.ts +7 -0
  158. package/dist/gateway/retry-plugin.d.ts +7 -0
  159. package/dist/gateway/routing-plugin.d.ts +11 -0
  160. package/dist/gateway/runtime.d.ts +15 -0
  161. package/dist/gateway/selection-plugin.d.ts +7 -0
  162. package/dist/gateway/sse-response.d.ts +6 -0
  163. package/dist/gateway/websocket-contracts.d.ts +71 -0
  164. package/dist/gateway/websocket-credential.d.ts +3 -0
  165. package/dist/gateway/websocket-plugin.d.ts +9 -0
  166. package/dist/hooks/impl.d.ts +119 -0
  167. package/dist/hooks/index.d.ts +7 -0
  168. package/dist/hooks/plugin-hooks.d.ts +308 -0
  169. package/dist/hooks/types.d.ts +130 -0
  170. package/dist/ingress/admission-registry.d.ts +56 -0
  171. package/dist/ingress/admission-set.d.ts +29 -0
  172. package/dist/ingress/index.d.ts +4 -0
  173. package/dist/ingress/master-controller.d.ts +278 -0
  174. package/dist/ingress/runtime.d.ts +29 -0
  175. package/dist/ingress/supervision-http.d.ts +118 -0
  176. package/dist/ingress.d.ts +5 -0
  177. package/dist/instance-lock.d.ts +2 -0
  178. package/dist/logger/access-log-writer.d.ts +120 -0
  179. package/dist/logger/body-capture.d.ts +21 -0
  180. package/dist/logger/body-log-redaction.d.ts +6 -0
  181. package/dist/logger/body-storage.d.ts +71 -0
  182. package/dist/logger/content-capture.d.ts +47 -0
  183. package/dist/logger/dated-log-files.d.ts +5 -0
  184. package/dist/logger/header-storage.d.ts +54 -0
  185. package/dist/logger/log-cleanup.d.ts +69 -0
  186. package/dist/logger/log-url.d.ts +2 -0
  187. package/dist/logger/request-logger.d.ts +308 -0
  188. package/dist/logger/transport-outcome.d.ts +25 -0
  189. package/dist/logger/websocket-body-capture.d.ts +26 -0
  190. package/dist/logger.d.ts +16 -0
  191. package/dist/main.d.ts +19 -0
  192. package/dist/main.js +8 -8
  193. package/dist/management-listener/index.d.ts +2 -0
  194. package/dist/management-listener/listener.d.ts +48 -0
  195. package/dist/management-listener/request-source.d.ts +4 -0
  196. package/dist/master-runtime/component-recovery.d.ts +40 -0
  197. package/dist/master-runtime/composition.d.ts +129 -0
  198. package/dist/master-runtime/configuration-recovery.d.ts +80 -0
  199. package/dist/master-runtime/control-api-body.d.ts +9 -0
  200. package/dist/master-runtime/control-api.d.ts +122 -0
  201. package/dist/master-runtime/error-chain.d.ts +9 -0
  202. package/dist/master-runtime/initialize-configuration.d.ts +4 -0
  203. package/dist/master-runtime/instance-lock.d.ts +25 -0
  204. package/dist/master-runtime/kernel-exit-timer.d.ts +7 -0
  205. package/dist/master-runtime/kernel-monotonic-clock.d.ts +15 -0
  206. package/dist/master-runtime/management-auth.d.ts +43 -0
  207. package/dist/master-runtime/master-plugin-catalog-api.d.ts +18 -0
  208. package/dist/master-runtime/master-stats.d.ts +52 -0
  209. package/dist/master-runtime/menu-api.d.ts +19 -0
  210. package/dist/master-runtime/observability-client.d.ts +49 -0
  211. package/dist/master-runtime/offline-recovery.d.ts +9 -0
  212. package/dist/master-runtime/offline-storage-session.d.ts +8 -0
  213. package/dist/master-runtime/plugin-journal-recovery.d.ts +28 -0
  214. package/dist/master-runtime/process-identity.d.ts +48 -0
  215. package/dist/master-runtime/process-options.d.ts +59 -0
  216. package/dist/master-runtime/publication-task-manager.d.ts +47 -0
  217. package/dist/master-runtime/reconcile-plugin-dependencies.d.ts +7 -0
  218. package/dist/master-runtime/recovery-prompt.d.ts +9 -0
  219. package/dist/master-runtime/route-body-plan.d.ts +31 -0
  220. package/dist/master-runtime/runtime-cleanup.d.ts +3 -0
  221. package/dist/master-runtime/runtime-contracts.d.ts +101 -0
  222. package/dist/master-runtime/runtime-evidence.d.ts +8 -0
  223. package/dist/master-runtime/runtime-status.d.ts +36 -0
  224. package/dist/master-runtime/runtime-supervisor.d.ts +30 -0
  225. package/dist/master-runtime/runtime-upgrade.d.ts +11 -0
  226. package/dist/master-runtime/runtime-upstreams.d.ts +14 -0
  227. package/dist/master-runtime/runtime.d.ts +23 -0
  228. package/dist/master-runtime/shutdown-diagnostics.d.ts +28 -0
  229. package/dist/master-runtime/signal-handlers.d.ts +18 -0
  230. package/dist/master-runtime/stopped-instance-lock.d.ts +6 -0
  231. package/dist/master-runtime/stopped-process.d.ts +2 -0
  232. package/dist/master-runtime/supervised-worker-client.d.ts +108 -0
  233. package/dist/master-runtime/supervised-worker-discovery.d.ts +41 -0
  234. package/dist/master-runtime/supervised-worker-factory.d.ts +298 -0
  235. package/dist/master-runtime/supervised-worker-process-adapter.d.ts +146 -0
  236. package/dist/master-runtime/worker-initialization-diagnostics.d.ts +18 -0
  237. package/dist/master.d.ts +2 -0
  238. package/dist/oauth-callback.d.ts +8 -0
  239. package/dist/plugin-artifact-contract.d.ts +4 -0
  240. package/dist/plugin-artifact-negotiation.d.ts +12 -0
  241. package/dist/plugin-artifact-types.d.ts +61 -0
  242. package/dist/plugin-context-manager.d.ts +91 -0
  243. package/dist/plugin-control/artifact-loader.d.ts +3 -0
  244. package/dist/plugin-control/contracts.d.ts +180 -0
  245. package/dist/plugin-control/host.d.ts +90 -0
  246. package/dist/plugin-control/index.d.ts +3 -0
  247. package/dist/plugin-control/master-invocation-projector.d.ts +52 -0
  248. package/dist/plugin-control/request-service-authority.d.ts +33 -0
  249. package/dist/plugin-control/secret-crypto.d.ts +13 -0
  250. package/dist/plugin-control/secret-store.d.ts +15 -0
  251. package/dist/plugin-dependencies.d.ts +30 -0
  252. package/dist/plugin-durable-state.d.ts +62 -0
  253. package/dist/plugin-extensions.d.ts +99 -0
  254. package/dist/plugin-logger.d.ts +17 -0
  255. package/dist/plugin-manifest-catalog/catalog.d.ts +28 -0
  256. package/dist/plugin-manifest-catalog/config-constraint-parser.d.ts +3 -0
  257. package/dist/plugin-manifest-catalog/config-default-validator.d.ts +3 -0
  258. package/dist/plugin-manifest-catalog/config-field-parser.d.ts +3 -0
  259. package/dist/plugin-manifest-catalog/config-field-references.d.ts +2 -0
  260. package/dist/plugin-manifest-catalog/index.d.ts +6 -0
  261. package/dist/plugin-manifest-catalog/manifest-filesystem.d.ts +9 -0
  262. package/dist/plugin-manifest-catalog/manifest-json.d.ts +1 -0
  263. package/dist/plugin-manifest-catalog/manifest-nested-parser.d.ts +11 -0
  264. package/dist/plugin-manifest-catalog/manifest-parser.d.ts +2 -0
  265. package/dist/plugin-manifest-catalog/manifest-semver.d.ts +4 -0
  266. package/dist/plugin-manifest-catalog/manifest-values.d.ts +6 -0
  267. package/dist/plugin-manifest-catalog/parse-utils.d.ts +19 -0
  268. package/dist/plugin-manifest-catalog/plugin-field-value.d.ts +3 -0
  269. package/dist/plugin-manifest-catalog/runtime-identity.d.ts +12 -0
  270. package/dist/plugin-manifest-catalog/types.d.ts +187 -0
  271. package/dist/plugin-path-resolver.d.ts +17 -0
  272. package/dist/plugin-registry.d.ts +165 -0
  273. package/dist/plugin-runtime-config.d.ts +10 -0
  274. package/dist/plugin-runtime-diff.d.ts +15 -0
  275. package/dist/plugin-runtime-orchestrator.d.ts +69 -0
  276. package/dist/plugin-runtime-state-machine.d.ts +78 -0
  277. package/dist/plugin-runtime-status.d.ts +29 -0
  278. package/dist/plugin-services/channels.d.ts +391 -0
  279. package/dist/plugin-services/command-journal.d.ts +234 -0
  280. package/dist/plugin-services/contracts.d.ts +23 -0
  281. package/dist/plugin-services/host-rpc.d.ts +268 -0
  282. package/dist/plugin-services/peer-broker.d.ts +351 -0
  283. package/dist/plugin-services/peer-channel-hub.d.ts +457 -0
  284. package/dist/plugin-services/peer-channel-protocol.d.ts +339 -0
  285. package/dist/plugin-services/peer-directory.d.ts +163 -0
  286. package/dist/plugin-services/peer-executor-proof.d.ts +13 -0
  287. package/dist/plugin-services/peer-frame.d.ts +65 -0
  288. package/dist/plugin-services/peer-journal.d.ts +25 -0
  289. package/dist/plugin-services/peer-protocol.d.ts +128 -0
  290. package/dist/plugin-services/peer-rpc-link.d.ts +218 -0
  291. package/dist/plugin-services/peer-rpc-mapping.d.ts +133 -0
  292. package/dist/plugin-services/peer-websocket.d.ts +146 -0
  293. package/dist/plugin-services/persistence.d.ts +166 -0
  294. package/dist/plugin-services/rpc-runtime.d.ts +227 -0
  295. package/dist/plugin-services/snapshot-store.d.ts +77 -0
  296. package/dist/plugin-services/wire-contract.d.ts +158 -0
  297. package/dist/plugin-services.d.ts +237 -0
  298. package/dist/plugin-state/client.d.ts +160 -0
  299. package/dist/plugin-state/message-size.d.ts +2 -0
  300. package/dist/plugin-state/operations.d.ts +4 -0
  301. package/dist/plugin-state/protocol.d.ts +40 -0
  302. package/dist/plugin-state/storage-rpc.d.ts +7 -0
  303. package/dist/plugin.types.d.ts +999 -0
  304. package/dist/plugins/anthropic-request-sanitizer/index.js +17 -17
  305. package/dist/plugins/anthropic-request-sanitizer/index.js.map +1 -1
  306. package/dist/plugins/anthropic-tool-name-transformer/index.js +17 -17
  307. package/dist/plugins/anthropic-tool-name-transformer/index.js.map +1 -1
  308. package/dist/plugins/chatgpt-oauth/control.js +24 -24
  309. package/dist/plugins/chatgpt-oauth/control.js.map +1 -1
  310. package/dist/plugins/chatgpt-oauth/index.js +23 -23
  311. package/dist/plugins/chatgpt-oauth/index.js.map +1 -1
  312. package/dist/plugins/codex-router/control.js +19 -19
  313. package/dist/plugins/codex-router/control.js.map +1 -1
  314. package/dist/plugins/codex-router/index.js +31 -31
  315. package/dist/plugins/codex-router/index.js.map +1 -1
  316. package/dist/plugins/deepseek-reasoning-fix/index.js +17 -17
  317. package/dist/plugins/deepseek-reasoning-fix/index.js.map +1 -1
  318. package/dist/plugins/key-access/control.js +18 -18
  319. package/dist/plugins/key-access/control.js.map +1 -1
  320. package/dist/plugins/key-access/index.js +19 -19
  321. package/dist/plugins/key-access/index.js.map +1 -1
  322. package/dist/plugins/key-access/ingress.js +18 -18
  323. package/dist/plugins/key-access/ingress.js.map +1 -1
  324. package/dist/plugins/key-rate-limit/control.js +3 -3
  325. package/dist/plugins/key-rate-limit/control.js.map +1 -1
  326. package/dist/plugins/key-rate-limit/index.js +18 -18
  327. package/dist/plugins/key-rate-limit/index.js.map +1 -1
  328. package/dist/plugins/key-rate-limit/ingress.js +2 -2
  329. package/dist/plugins/key-rate-limit/ingress.js.map +1 -1
  330. package/dist/plugins/llm-protocol-adapter/control.js +48 -48
  331. package/dist/plugins/llm-protocol-adapter/control.js.map +1 -1
  332. package/dist/plugins/llm-protocol-adapter/index.js +53 -53
  333. package/dist/plugins/llm-protocol-adapter/index.js.map +1 -1
  334. package/dist/plugins/llm-tps/control.js +5 -5
  335. package/dist/plugins/llm-tps/control.js.map +1 -1
  336. package/dist/plugins/llm-tps/index.js +20 -20
  337. package/dist/plugins/llm-tps/index.js.map +1 -1
  338. package/dist/plugins/model-mapping/control.js +4 -4
  339. package/dist/plugins/model-mapping/control.js.map +1 -1
  340. package/dist/plugins/model-mapping/index.js +19 -19
  341. package/dist/plugins/model-mapping/index.js.map +1 -1
  342. package/dist/plugins/models-dev/control.js +10 -10
  343. package/dist/plugins/models-dev/control.js.map +1 -1
  344. package/dist/plugins/models-dev/index.js +23 -23
  345. package/dist/plugins/models-dev/index.js.map +1 -1
  346. package/dist/plugins/request-body-redaction/control.js +2 -2
  347. package/dist/plugins/request-body-redaction/control.js.map +1 -1
  348. package/dist/plugins/request-body-redaction/index.js +21 -21
  349. package/dist/plugins/request-body-redaction/index.js.map +1 -1
  350. package/dist/plugins/request-logs/index.js +27 -27
  351. package/dist/plugins/request-logs/index.js.map +1 -1
  352. package/dist/plugins/request-logs/ingress.js +2 -2
  353. package/dist/plugins/request-logs/ingress.js.map +1 -1
  354. package/dist/plugins/signature-repair/index.js +17 -17
  355. package/dist/plugins/signature-repair/index.js.map +1 -1
  356. package/dist/plugins/sse-envelope.d.ts +3 -0
  357. package/dist/plugins/token-budget/control.js +19 -19
  358. package/dist/plugins/token-budget/control.js.map +1 -1
  359. package/dist/plugins/token-budget/index.js +19 -19
  360. package/dist/plugins/token-budget/index.js.map +1 -1
  361. package/dist/plugins/token-budget/ingress.js +2 -2
  362. package/dist/plugins/token-budget/ingress.js.map +1 -1
  363. package/dist/plugins/token-metering/index.js +30 -30
  364. package/dist/plugins/token-metering/index.js.map +1 -1
  365. package/dist/plugins/token-stats/control.js +22 -22
  366. package/dist/plugins/token-stats/control.js.map +1 -1
  367. package/dist/plugins/token-stats/index.js +22 -22
  368. package/dist/plugins/token-stats/index.js.map +1 -1
  369. package/dist/plugins/user-auth/control.js +21 -21
  370. package/dist/plugins/user-auth/control.js.map +1 -1
  371. package/dist/plugins/user-auth/index.js +17 -17
  372. package/dist/plugins/user-auth/index.js.map +1 -1
  373. package/dist/public-listener/admission-registry.d.ts +15 -0
  374. package/dist/public-listener/forwarding.d.ts +24 -0
  375. package/dist/public-listener/headers.d.ts +5 -0
  376. package/dist/public-listener/index.d.ts +4 -0
  377. package/dist/public-listener/listener.d.ts +21 -0
  378. package/dist/public-listener/websocket.d.ts +4 -0
  379. package/dist/rate-limit/http.d.ts +80 -0
  380. package/dist/rate-limit/index.d.ts +7 -0
  381. package/dist/rate-limit/json.d.ts +8 -0
  382. package/dist/rate-limit/profile.d.ts +46 -0
  383. package/dist/rate-limit/protocol.d.ts +104 -0
  384. package/dist/rate-limit/store.d.ts +61 -0
  385. package/dist/scoped-plugin-registry.d.ts +645 -0
  386. package/dist/supervision/index.d.ts +12 -0
  387. package/dist/supervision/process-lifetime-guard.d.ts +54 -0
  388. package/dist/supervision/protocol.d.ts +173 -0
  389. package/dist/supervision/state-repository.d.ts +15 -0
  390. package/dist/supervision/strict-json.d.ts +2 -0
  391. package/dist/supervision/worker-descriptor.d.ts +77 -0
  392. package/dist/supervision/worker-http.d.ts +135 -0
  393. package/dist/supervision/worker-runtime-snapshot.d.ts +64 -0
  394. package/dist/token-stats-window.d.ts +23 -0
  395. package/dist/ui/assets.d.ts +8 -0
  396. package/dist/ui/icon-resources.d.ts +28 -0
  397. package/dist/ui/menu-icons.d.ts +15 -0
  398. package/dist/ui/menu-layout.d.ts +10 -0
  399. package/dist/ui/plugin-sandbox-policy.d.ts +11 -0
  400. package/dist/ui/server.d.ts +10 -0
  401. package/dist/updates/archive-installer.d.ts +8 -0
  402. package/dist/updates/controller.d.ts +50 -0
  403. package/dist/updates/download.d.ts +8 -0
  404. package/dist/updates/installation.d.ts +26 -0
  405. package/dist/updates/names.d.ts +3 -0
  406. package/dist/updates/release.d.ts +23 -0
  407. package/dist/updates/restart.d.ts +13 -0
  408. package/dist/utils/config-validator.d.ts +40 -0
  409. package/dist/utils/endpoint-resolver.d.ts +20 -0
  410. package/dist/utils/expression-dependencies.d.ts +10 -0
  411. package/dist/utils/plugin-helpers.d.ts +46 -0
  412. package/dist/websocket/headers.d.ts +9 -0
  413. package/dist/websocket/index.d.ts +3 -0
  414. package/dist/websocket/message.d.ts +3 -0
  415. package/dist/websocket/observation.d.ts +36 -0
  416. package/dist/websocket/transport.d.ts +197 -0
  417. package/dist/worker/health/checker.d.ts +54 -0
  418. package/dist/worker/health/scheduler.d.ts +27 -0
  419. package/dist/worker/request/body-source.d.ts +1 -0
  420. package/dist/worker/request/context-builder.d.ts +78 -0
  421. package/dist/worker/request/context.d.ts +55 -0
  422. package/dist/worker/request/credential.d.ts +10 -0
  423. package/dist/worker/request/handler.d.ts +3 -0
  424. package/dist/worker/request/proxy.d.ts +4 -0
  425. package/dist/worker/request/response-detector.d.ts +9 -0
  426. package/dist/worker/request/snapshot.d.ts +18 -0
  427. package/dist/worker/response/attempt-observation.d.ts +24 -0
  428. package/dist/worker/response/processor.d.ts +4 -0
  429. package/dist/worker/response/streaming-response.d.ts +1 -0
  430. package/dist/worker/rules/deep-merge.d.ts +2 -0
  431. package/dist/worker/rules/modifier.d.ts +3 -0
  432. package/dist/worker/state/plugin-manager.d.ts +95 -0
  433. package/dist/worker/state/runtime-state.d.ts +90 -0
  434. package/dist/worker/types.d.ts +44 -0
  435. package/dist/worker/upstream/condition-filter.d.ts +31 -0
  436. package/dist/worker/upstream/failover-coordinator.d.ts +93 -0
  437. package/dist/worker/upstream/filter.d.ts +37 -0
  438. package/dist/worker/upstream/priority-group.d.ts +66 -0
  439. package/dist/worker/upstream/selector.d.ts +10 -0
  440. package/dist/worker/upstream/service-execution.d.ts +17 -0
  441. package/dist/worker/utils/jitter.d.ts +81 -0
  442. package/dist/worker/utils/slow-start.d.ts +67 -0
  443. package/dist/worker/utils/status-code-matcher.d.ts +10 -0
  444. package/dist/worker.d.ts +1 -0
  445. package/package.json +2 -2
@@ -0,0 +1,999 @@
1
+ import type { PluginConfigConstraint, PluginRuntimeScope } from '@jeffusion/bungee-types';
2
+ export type { PluginConfigConstraint, PluginAllowedTuplesConstraint, PluginRuntimeScope } from '@jeffusion/bungee-types';
3
+ /**
4
+ * Plugin 系统类型定义
5
+ */
6
+ /**
7
+ * 插件配置值类型
8
+ * 定义了插件配置中允许的值类型,比 `any` 更具体
9
+ */
10
+ export type PluginConfigValue = string | number | boolean | null | PluginConfigValue[] | {
11
+ [key: string]: PluginConfigValue;
12
+ };
13
+ export interface CredentialOutboundHeaderProfile {
14
+ readonly passthrough: readonly string[];
15
+ readonly set: Readonly<Record<string, string>>;
16
+ }
17
+ export interface CredentialRequestPolicy {
18
+ readonly pathname: string;
19
+ readonly methods: readonly string[];
20
+ readonly outboundHeaders?: CredentialOutboundHeaderProfile;
21
+ }
22
+ /**
23
+ * 插件 manifest.json 规范
24
+ *
25
+ * manifest.json 是插件的声明性配置文件,作为插件元数据的唯一真相来源。
26
+ * 框架通过读取此文件来发现插件能力,无需执行插件代码。
27
+ *
28
+ * @example
29
+ * ```json
30
+ * {
31
+ * "name": "token-stats",
32
+ * "version": "1.0.0",
33
+ * "description": "Track AI API token usage",
34
+ * "main": "server/index.ts",
35
+ * "ui": {
36
+ * "components": [
37
+ * { "name": "TokenStatsChart", "entry": "ui/TokenStatsChart.svelte" }
38
+ * ]
39
+ * },
40
+ * "contributes": {
41
+ * "nativeWidgets": [...],
42
+ * "api": [...]
43
+ * },
44
+ * "translations": { "en": {...}, "zh-CN": {...} }
45
+ * }
46
+ * ```
47
+ */
48
+ export interface PluginManifest {
49
+ /**
50
+ * 插件唯一标识符(必填)
51
+ * 用于路由、存储命名空间等
52
+ */
53
+ name: string;
54
+ /**
55
+ * 插件版本号(必填)
56
+ * 遵循 semver 规范
57
+ */
58
+ version: string;
59
+ schemaVersion?: number | string;
60
+ artifactKind?: string;
61
+ /**
62
+ * 插件描述(支持翻译键)
63
+ */
64
+ description?: string;
65
+ /**
66
+ * 图标(Material Icon 名称或 URL)
67
+ */
68
+ icon?: string;
69
+ /**
70
+ * 作者信息
71
+ */
72
+ author?: string | {
73
+ name: string;
74
+ email?: string;
75
+ url?: string;
76
+ };
77
+ /**
78
+ * 许可证
79
+ */
80
+ license?: string;
81
+ /**
82
+ * 项目主页
83
+ */
84
+ homepage?: string;
85
+ /**
86
+ * 代码仓库
87
+ */
88
+ repository?: string | {
89
+ type: string;
90
+ url: string;
91
+ };
92
+ /**
93
+ * 关键词(用于搜索)
94
+ */
95
+ keywords?: string[];
96
+ /**
97
+ * 服务端入口配置
98
+ */
99
+ main?: string;
100
+ capabilities?: string[];
101
+ /** Global providers run once whenever activated; global-and-scoped also retains application bindings. Defaults to scoped. */
102
+ runtimeScope?: PluginRuntimeScope;
103
+ services?: import('./plugin-services').PluginServiceDeclarations;
104
+ /** Optional control-plane runtime capability. */
105
+ ingress?: {
106
+ entry: string;
107
+ };
108
+ management?: {
109
+ loginComponent?: string;
110
+ setupComponent?: string;
111
+ };
112
+ control?: {
113
+ entry: string;
114
+ rpc: Array<{
115
+ name: string;
116
+ access: 'bound-attempt';
117
+ }>;
118
+ };
119
+ /**
120
+ * UI 扩展模式(冻结边界)
121
+ * - none: 无 UI 扩展
122
+ * - native-static: 原生静态组件(依赖构建期注册表,不支持运行时注入)
123
+ * - sandbox-iframe: 独立沙箱扩展(通过 iframe 隔离,独立服务资源)
124
+ */
125
+ uiExtensionMode?: 'none' | 'native-static' | 'sandbox-iframe';
126
+ /**
127
+ * UI 组件配置
128
+ */
129
+ ui?: {
130
+ /**
131
+ * 组件列表
132
+ * 用于自动注册到组件白名单
133
+ */
134
+ components?: Array<{
135
+ /** 组件名称(用于 nativeWidgets.component 引用) */
136
+ name: string;
137
+ /** 组件入口文件路径(相对于插件根目录) */
138
+ entry: string;
139
+ }>;
140
+ };
141
+ /**
142
+ * 权限声明
143
+ * 用于安全预检(用户上传插件场景)
144
+ */
145
+ permissions?: Array<'network' | 'storage' | 'filesystem' | string>;
146
+ /**
147
+ * 插件依赖
148
+ */
149
+ dependencies?: Record<string, string>;
150
+ /** Optional providers are never included in automatic activation closure. */
151
+ optionalDependencies?: Record<string, string>;
152
+ /**
153
+ * 引擎版本要求
154
+ */
155
+ engines?: {
156
+ bungee?: string;
157
+ node?: string;
158
+ };
159
+ /**
160
+ * 贡献点配置
161
+ */
162
+ contributes?: {
163
+ /**
164
+ * 原生仪表板组件
165
+ */
166
+ nativeWidgets?: Array<{
167
+ id: string;
168
+ title: string;
169
+ size: 'small' | 'medium' | 'large' | 'full';
170
+ component: string;
171
+ presentation?: 'kpi';
172
+ props?: Record<string, any>;
173
+ }>;
174
+ /**
175
+ * API 端点
176
+ */
177
+ api?: Array<{
178
+ path: string;
179
+ methods: Array<'GET' | 'POST' | 'PUT' | 'DELETE'>;
180
+ handler: string;
181
+ execution: 'control';
182
+ capability?: string;
183
+ methodCapabilities?: Record<string, string>;
184
+ }>;
185
+ resourceExtensions?: Array<{
186
+ resource: 'api-key';
187
+ component: string;
188
+ path: '/keys/:keyId';
189
+ }>;
190
+ upstreamSources?: Array<{
191
+ id: string;
192
+ label: string;
193
+ listAccounts: string;
194
+ createDraft: string;
195
+ credentialPolicy: {
196
+ allowedOrigins: string[];
197
+ allowedRequests: CredentialRequestPolicy[];
198
+ allowedHeaderNames: string[];
199
+ };
200
+ }>;
201
+ /**
202
+ * iframe 仪表板组件(Legacy)
203
+ */
204
+ widgets?: Array<{
205
+ title: string;
206
+ path: string;
207
+ size?: 'small' | 'medium' | 'large' | 'full';
208
+ }>;
209
+ /**
210
+ * 导航菜单
211
+ */
212
+ navigation?: Array<{
213
+ label: string;
214
+ path: string;
215
+ icon?: string;
216
+ target?: 'sidebar' | 'header';
217
+ component?: string;
218
+ layout?: 'standalone';
219
+ }>;
220
+ /**
221
+ * 设置页路径
222
+ */
223
+ settings?: string;
224
+ /**
225
+ * 原生静态设置组件名称(仅 builtin 插件可声明)
226
+ */
227
+ nativeSettingsComponent?: string;
228
+ /**
229
+ * 命令贡献
230
+ */
231
+ commands?: Array<{
232
+ command: string;
233
+ title: string;
234
+ category?: string;
235
+ icon?: string;
236
+ }>;
237
+ };
238
+ /**
239
+ * UI 展示元数据(新架构)
240
+ * 用于存放 UI 相关的元数据,支持翻译键
241
+ */
242
+ metadata?: {
243
+ /** 显示名称(支持翻译键) */
244
+ name?: string;
245
+ /** 描述(支持翻译键) */
246
+ description?: string;
247
+ /** 图标 */
248
+ icon?: string;
249
+ /** 贡献点配置(与顶层 contributes 合并) */
250
+ contributes?: PluginManifest['contributes'];
251
+ };
252
+ /**
253
+ * 配置 Schema
254
+ * 用于动态生成配置表单
255
+ */
256
+ configSchema?: PluginConfigField[];
257
+ configConstraints?: readonly PluginConfigConstraint[];
258
+ /**
259
+ * 多语言翻译
260
+ */
261
+ translations?: PluginTranslations;
262
+ }
263
+ /**
264
+ * 从 manifest 加载的插件信息
265
+ * 包含 manifest 数据和解析后的路径信息
266
+ */
267
+ export interface LoadedPluginManifest extends PluginManifest {
268
+ /** 插件根目录的绝对路径 */
269
+ pluginDir: string;
270
+ /** manifest.json 文件的绝对路径 */
271
+ manifestPath: string;
272
+ /** 服务端入口的绝对路径 */
273
+ mainPath?: string;
274
+ /** 控制面入口的绝对路径 */
275
+ controlPath?: string;
276
+ uiAssetsPath?: string;
277
+ }
278
+ export type { PluginHooks, RequestContext, MutableRequestContext, ResponseContext, ErrorContext, StreamChunkContext, FinallyContext, PluginInitContext, PluginLogger, } from './hooks';
279
+ export { createPluginHooks, clearHooks, getHooksStats, resetHooksStats } from './hooks';
280
+ export type { TapInfo } from './hooks';
281
+ /**
282
+ * 插件配置字段类型
283
+ */
284
+ export type PluginConfigFieldType = 'string' | 'number' | 'boolean' | 'select' | 'multiselect' | 'textarea' | 'json' | 'gateway_target' | 'model_mapping' | 'object' | 'array';
285
+ /**
286
+ * 验证规则
287
+ */
288
+ export interface ValidationRule {
289
+ /**
290
+ * 正则表达式模式
291
+ */
292
+ pattern?: string;
293
+ /**
294
+ * 最小值/最小长度
295
+ */
296
+ min?: number;
297
+ /**
298
+ * 最大值/最大长度
299
+ */
300
+ max?: number;
301
+ /**
302
+ * 自定义错误消息
303
+ */
304
+ message?: string;
305
+ }
306
+ /**
307
+ * 字段转换规则(可序列化)
308
+ * 用于定义虚拟字段与实际字段之间的转换关系
309
+ */
310
+ export interface FieldTransform {
311
+ /**
312
+ * 转换类型
313
+ */
314
+ type: 'split' | 'concat' | 'compute';
315
+ /**
316
+ * split 类型专用:分隔符
317
+ * @example '-' 将 "a-b" 拆分为 ["a", "b"]
318
+ */
319
+ separator?: string;
320
+ /**
321
+ * split/concat 类型专用:目标字段列表
322
+ * @example ['from', 'to']
323
+ */
324
+ fields?: string[];
325
+ }
326
+ export type PluginShowIfCondition = {
327
+ field: string;
328
+ value: PluginConfigValue;
329
+ } | {
330
+ all: PluginShowIfCondition[];
331
+ } | {
332
+ any: PluginShowIfCondition[];
333
+ };
334
+ /**
335
+ * 插件翻译内容
336
+ *
337
+ * 用于为插件的 UI 元素提供多语言支持
338
+ *
339
+ * 格式说明:
340
+ * - 第一层 key 为语言代码(如 'en', 'zh-CN')
341
+ * - 第二层 key 为翻译键(使用点号分隔的扁平结构)
342
+ * - 系统会自动为所有翻译键添加 `plugins.{pluginName}` 前缀
343
+ *
344
+ * @example
345
+ * ```typescript
346
+ * static readonly translations: PluginTranslations = {
347
+ * 'en': {
348
+ * 'field.label': 'Field Label',
349
+ * 'field.description': 'Field description text',
350
+ * 'options.value1.label': 'Option 1'
351
+ * },
352
+ * 'zh-CN': {
353
+ * 'field.label': '字段标签',
354
+ * 'field.description': '字段描述文本',
355
+ * 'options.value1.label': '选项 1'
356
+ * }
357
+ * };
358
+ * ```
359
+ */
360
+ export type PluginTranslations = Record<string, Record<string, string>>;
361
+ /**
362
+ * 插件配置字段定义
363
+ * 用于动态生成配置表单
364
+ */
365
+ export interface PluginConfigField {
366
+ /**
367
+ * 字段名(配置对象的 key)
368
+ */
369
+ name: string;
370
+ /**
371
+ * 字段类型
372
+ */
373
+ type: PluginConfigFieldType;
374
+ /**
375
+ * 显示标签(支持 i18n key 或直接字符串)
376
+ */
377
+ label: string;
378
+ /**
379
+ * 是否必填
380
+ */
381
+ required?: boolean;
382
+ /**
383
+ * 默认值
384
+ */
385
+ default?: PluginConfigValue;
386
+ /**
387
+ * select/multiselect 的选项列表
388
+ */
389
+ options?: Array<{
390
+ label: string;
391
+ value: string;
392
+ description?: string;
393
+ }>;
394
+ /**
395
+ * 描述/帮助文本
396
+ */
397
+ description?: string;
398
+ /**
399
+ * 占位符文本
400
+ */
401
+ placeholder?: string;
402
+ catalogPlugin?: string;
403
+ sourceCatalogProviderField?: string;
404
+ targetCatalogProviderField?: string;
405
+ /**
406
+ * 验证规则
407
+ */
408
+ validation?: ValidationRule;
409
+ /**
410
+ * 条件显示(依赖其他字段的值)
411
+ */
412
+ showIf?: PluginShowIfCondition;
413
+ /**
414
+ * 子字段定义(type=object 时使用)
415
+ */
416
+ properties?: PluginConfigField[];
417
+ /**
418
+ * 数组元素类型(type=array 时使用)
419
+ */
420
+ items?: PluginConfigField;
421
+ /**
422
+ * 字段转换规则(可序列化)
423
+ * 定义虚拟字段与实际字段之间的映射关系
424
+ *
425
+ * 当设置此属性时:
426
+ * - 该字段为"虚拟字段",仅用于 UI 交互
427
+ * - UI 输入值会根据转换规则展开为多个实际字段
428
+ * - 实际字段的值会根据转换规则合并显示在 UI 中
429
+ * - 虚拟字段本身不会保存到配置中
430
+ *
431
+ * @example
432
+ * // 将 "anthropic-openai" 拆分为 { from: "anthropic", to: "openai" }
433
+ * fieldTransform: {
434
+ * type: 'split',
435
+ * separator: '-',
436
+ * fields: ['from', 'to']
437
+ * }
438
+ */
439
+ fieldTransform?: FieldTransform;
440
+ }
441
+ /**
442
+ * 类型守卫:检查插件类是否有 configSchema
443
+ */
444
+ export declare function hasConfigSchema(PluginClass: any): PluginClass is {
445
+ configSchema: PluginConfigField[];
446
+ };
447
+ /**
448
+ * Plugin 存储接口
449
+ * 提供基于 Key-Value 的持久化存储能力
450
+ */
451
+ /** Trusted observation plugins may execute SQL only against access.db, never config.db.
452
+ * Callers must perform database work within the callback; hosts revoke subsequent operations.
453
+ */
454
+ export interface PluginObservationStorage {
455
+ withDatabase<T>(operation: (database: import('bun:sqlite').Database) => T): T;
456
+ /** Returns a bounded remaining-time reader for a same-host kernel deadline in milliseconds. */
457
+ writeBudgetMs?(deadlineAt: number): () => number;
458
+ }
459
+ /** Result of a strict, side-effect-free namespaced KV read. */
460
+ export type PluginStorageReadResult<T> = {
461
+ readonly found: false;
462
+ } | {
463
+ readonly found: true;
464
+ readonly value: T;
465
+ };
466
+ export interface PluginStorage {
467
+ readonly observation?: PluginObservationStorage;
468
+ /** Invoke a registered observation adapter method in this plugin namespace. */
469
+ invokeObservation?<T>(operation: string, args: readonly unknown[]): Promise<T>;
470
+ /** Immediate namespaced KV access for cross-process shared values. */
471
+ uncached?(): PluginStorage;
472
+ /** Flush pending KV writes during host disposal. */
473
+ flush?(): Promise<void>;
474
+ /** Legacy embedder extension; the core does not construct or grant it by name. */
475
+ readonly metering?: TokenStatsMeteringStorage;
476
+ /**
477
+ * 获取值
478
+ * @param key 键
479
+ * @returns 值,如果不存在则返回 null
480
+ */
481
+ get<T = any>(key: string): Promise<T | null>;
482
+ /**
483
+ * 严格只读获取值:直接读取当前命名空间的已提交数据。
484
+ * 不访问/回填/刷新 LRU 缓存,也不清除过期记录;SQL/JSON 错误直接抛出。
485
+ * 有效 JSON null 视为 found:true,缺失或已过期视为 found:false。
486
+ * 可选仅为既有 embedder / 测试 fixture 的源码兼容;Bungee 实际存储实现必须提供。
487
+ */
488
+ readStrict?<T = unknown>(key: string): Promise<PluginStorageReadResult<T>>;
489
+ /**
490
+ * 设置值
491
+ * @param key 键
492
+ * @param value 值(必须可序列化)
493
+ * @param ttlSeconds 过期时间(秒),可选
494
+ */
495
+ set(key: string, value: any, ttlSeconds?: number): Promise<void>;
496
+ /**
497
+ * 删除值
498
+ * @param key 键
499
+ */
500
+ delete(key: string): Promise<void>;
501
+ /**
502
+ * 获取所有键(支持前缀过滤)
503
+ * @param prefix 前缀,可选
504
+ */
505
+ keys(prefix?: string): Promise<string[]>;
506
+ /**
507
+ * 清空存储(仅限当前插件的命名空间)
508
+ */
509
+ clear(): Promise<void>;
510
+ /**
511
+ * 原子递增操作
512
+ * 原子地递增指定对象字段的值,避免并发竞争
513
+ * @param key 键
514
+ * @param field 字段名
515
+ * @param delta 递增量(默认1,可为负数)
516
+ * @returns 递增后的新值
517
+ */
518
+ increment(key: string, field: string, delta?: number): Promise<number>;
519
+ /**
520
+ * 比较并交换操作
521
+ * 仅当当前值等于期望值时,才更新为新值(原子操作)
522
+ * @param key 键
523
+ * @param field 字段名
524
+ * @param expected 期望的当前值
525
+ * @param newValue 新值
526
+ * @returns 是否更新成功
527
+ */
528
+ compareAndSet(key: string, field: string, expected: any, newValue: any): Promise<boolean>;
529
+ }
530
+ export type TokenStatsMetricName = 'inputTokens' | 'outputTokens' | 'officialInputTokens' | 'officialOutputTokens' | 'estimatedInputTokens' | 'estimatedOutputTokens' | 'cacheReadTokens' | 'cacheWriteTokens' | 'partialOutputs' | 'logicalRequests' | 'upstreamAttempts' | 'observationIncompleteAttempts' | 'inputAuthorityOfficial' | 'inputAuthorityLocal' | 'inputAuthorityHeuristic' | 'inputAuthorityPartial' | 'inputAuthorityNone' | 'outputAuthorityOfficial' | 'outputAuthorityLocal' | 'outputAuthorityHeuristic' | 'outputAuthorityPartial' | 'outputAuthorityNone';
531
+ export type TokenStatsMetrics = Partial<Record<TokenStatsMetricName, number>>;
532
+ export type TokenStatsGroupBy = 'model' | 'time';
533
+ export type TokenStatsRange = '1h' | '12h' | '24h' | '1d' | '7d' | '30d' | 'day' | 'week' | 'month';
534
+ export type TokenStatsValueSource = 'usage' | 'estimated' | 'partial' | 'unknown';
535
+ /** One ended upstream attempt; provider is the wire protocol family, not a vendor name. */
536
+ export interface TokenStatsAttempt {
537
+ readonly key_id?: string | null;
538
+ readonly attempt_id: string;
539
+ readonly request_id: string;
540
+ readonly finished_at_ms: number;
541
+ readonly route_id: string;
542
+ readonly upstream_id: string;
543
+ readonly provider: string;
544
+ readonly outcome: string;
545
+ readonly model: string;
546
+ readonly input_tokens: number | null;
547
+ readonly output_tokens: number | null;
548
+ readonly input_source: TokenStatsValueSource;
549
+ readonly output_source: TokenStatsValueSource;
550
+ readonly cache_read_tokens: number | null;
551
+ readonly cache_write_tokens: number | null;
552
+ readonly cost_usd: number | null;
553
+ readonly observation_incomplete: boolean;
554
+ }
555
+ export type TokenStatsSnapshotMetrics = Record<TokenStatsMetricName, number> & {
556
+ readonly estimatedCostUsd: number | null;
557
+ };
558
+ export interface TokenStatsMeteringStorage {
559
+ listClientModels?(input: {
560
+ page?: number;
561
+ pageSize?: number;
562
+ keyword?: string;
563
+ }): Promise<{
564
+ models: string[];
565
+ total: number;
566
+ page: number;
567
+ pageSize: number;
568
+ }>;
569
+ recordAttempt(row: TokenStatsAttempt): Promise<void>;
570
+ queryWindowSnapshot(input: {
571
+ asOfMs: number;
572
+ range: TokenStatsRange;
573
+ groupBy: TokenStatsGroupBy;
574
+ timeZone?: string;
575
+ keyId?: string;
576
+ }): Promise<{
577
+ all: TokenStatsSnapshotMetrics;
578
+ data: Array<{
579
+ dimension: string;
580
+ bucketStartMs?: number;
581
+ metrics: TokenStatsSnapshotMetrics;
582
+ }>;
583
+ bucketMs?: number;
584
+ bucketStarts?: number[];
585
+ /** Exclusive end of the last displayed bucket; calendar axes include future periods. */
586
+ bucketEndMs?: number;
587
+ present: boolean;
588
+ }>;
589
+ }
590
+ /**
591
+ * Plugin 元数据接口
592
+ * 用于 UI 展示和系统集成
593
+ */
594
+ export interface PluginMetadata {
595
+ /**
596
+ * 显示名称(支持翻译键或直接字符串)
597
+ * 默认使用插件的 name,此字段用于提供更友好的 UI 显示名
598
+ *
599
+ * 支持翻译键格式:包含 `.` 且不包含空格
600
+ * @example 'metadata.displayName' // 翻译键,会自动翻译
601
+ * @example 'My Plugin' // 直接字符串,不翻译
602
+ */
603
+ name?: string;
604
+ /**
605
+ * 插件描述(支持翻译键或直接字符串)
606
+ * 用于 UI 展示插件的详细说明
607
+ *
608
+ * 支持翻译键格式:包含 `.` 且不包含空格
609
+ * @example 'metadata.description' // 翻译键,会自动翻译
610
+ * @example 'A demo plugin for testing' // 直接字符串,不翻译
611
+ */
612
+ description?: string;
613
+ /**
614
+ * 图标(Material Icon 名称或 URL)
615
+ */
616
+ icon?: string;
617
+ /**
618
+ * 作者信息
619
+ */
620
+ author?: {
621
+ name: string;
622
+ email?: string;
623
+ url?: string;
624
+ } | string;
625
+ /**
626
+ * 许可证
627
+ */
628
+ license?: string;
629
+ /**
630
+ * 项目主页
631
+ */
632
+ homepage?: string;
633
+ /**
634
+ * 代码仓库
635
+ */
636
+ repository?: {
637
+ type: string;
638
+ url: string;
639
+ } | string;
640
+ /**
641
+ * 关键词(用于搜索)
642
+ */
643
+ keywords?: string[];
644
+ /**
645
+ * 分类
646
+ */
647
+ categories?: string[];
648
+ /**
649
+ * 插件激活事件
650
+ * 声明插件何时被激活
651
+ */
652
+ activationEvents?: string[];
653
+ /**
654
+ * 插件能力声明
655
+ * 声明插件使用的系统能力
656
+ */
657
+ /**
658
+ * 插件权限声明
659
+ * 声明插件需要的系统权限(如 network, storage, api:routes 等)
660
+ */
661
+ permissions?: string[];
662
+ capabilities?: {
663
+ /**
664
+ * 是否需要网络访问
665
+ */
666
+ network?: boolean;
667
+ /**
668
+ * 是否需要文件系统访问
669
+ */
670
+ filesystem?: boolean;
671
+ /**
672
+ * 是否需要数据库访问
673
+ */
674
+ database?: boolean;
675
+ /**
676
+ * 自定义能力声明
677
+ */
678
+ custom?: string[];
679
+ };
680
+ /**
681
+ * 依赖的其他插件
682
+ */
683
+ dependencies?: Record<string, string>;
684
+ /**
685
+ * 可选依赖
686
+ */
687
+ optionalDependencies?: Record<string, string>;
688
+ /**
689
+ * 引擎版本要求
690
+ */
691
+ engines?: {
692
+ bungee?: string;
693
+ node?: string;
694
+ };
695
+ /**
696
+ * 贡献点配置
697
+ * 统一声明插件提供的 UI 和功能能力
698
+ */
699
+ contributes?: {
700
+ /**
701
+ * 导航集成
702
+ */
703
+ navigation?: Array<{
704
+ label: string;
705
+ path: string;
706
+ icon?: string;
707
+ target?: 'sidebar' | 'header';
708
+ /** Optional statically registered native page component. */
709
+ component?: string;
710
+ layout?: 'standalone';
711
+ }>;
712
+ /**
713
+ * 仪表板集成
714
+ */
715
+ widgets?: Array<{
716
+ title: string;
717
+ path: string;
718
+ size?: 'small' | 'medium' | 'large' | 'full';
719
+ }>;
720
+ /**
721
+ * 设置页路径
722
+ */
723
+ settings?: string;
724
+ /**
725
+ * 命令贡献
726
+ * 声明插件提供的命令
727
+ */
728
+ commands?: Array<{
729
+ command: string;
730
+ title: string;
731
+ category?: string;
732
+ icon?: string;
733
+ }>;
734
+ /**
735
+ * 配置贡献
736
+ * 声明插件的配置项
737
+ */
738
+ configuration?: {
739
+ title?: string;
740
+ properties: Record<string, {
741
+ type: 'string' | 'number' | 'boolean' | 'array' | 'object';
742
+ default?: any;
743
+ description?: string;
744
+ enum?: any[];
745
+ items?: any;
746
+ properties?: any;
747
+ }>;
748
+ };
749
+ /**
750
+ * 原生仪表板组件(非 iframe)
751
+ *
752
+ * 与 widgets 不同,nativeWidgets 直接渲染为 Svelte 组件,
753
+ * 可以复用主应用的图表库和样式系统。
754
+ *
755
+ * 安全说明:组件必须是内置的,插件只能通过 component 名称引用白名单中的组件
756
+ *
757
+ * @example
758
+ * ```typescript
759
+ * nativeWidgets: [{
760
+ * id: 'token-stats-chart',
761
+ * title: 'Token 统计',
762
+ * size: 'medium',
763
+ * component: 'TokenStatsChart',
764
+ * props: { days: 7 }
765
+ * }]
766
+ * ```
767
+ */
768
+ nativeWidgets?: Array<{
769
+ /** 唯一标识符 */
770
+ id: string;
771
+ /** 显示标题(支持 i18n key) */
772
+ title: string;
773
+ /** 尺寸:small=1x1, medium=2x1, large=2x2, full=4x2 */
774
+ size: 'small' | 'medium' | 'large' | 'full';
775
+ /** 组件名称(映射到内置组件白名单) */
776
+ component: string;
777
+ presentation?: 'kpi';
778
+ /** 传递给组件的 props */
779
+ props?: Record<string, any>;
780
+ }>;
781
+ /**
782
+ * API 端点贡献
783
+ *
784
+ * 允许插件注册自己的 API 端点,端点路径强制在 /api/plugins/:pluginName/ 命名空间下。
785
+ * 只有 global scope 的插件实例才能处理 API 请求。
786
+ *
787
+ * @example
788
+ * ```typescript
789
+ * api: [{
790
+ * path: '/stats', // 实际路径: /api/plugins/my-plugin/stats
791
+ * methods: ['GET'],
792
+ * handler: 'getStats', // 调用控制面处理器的 getStats 方法
793
+ * execution: 'control'
794
+ * }]
795
+ * ```
796
+ */
797
+ api?: Array<{
798
+ /** 相对路径(相对于 /api/plugins/:pluginName) */
799
+ path: string;
800
+ /** 支持的 HTTP 方法 */
801
+ methods: Array<'GET' | 'POST' | 'PUT' | 'DELETE'>;
802
+ /** 处理器方法名(Plugin 类的方法) */
803
+ handler: string;
804
+ execution: 'control';
805
+ capability?: string;
806
+ methodCapabilities?: Record<string, string>;
807
+ }>;
808
+ };
809
+ /**
810
+ * @deprecated 使用 contributes.widgets 和 contributes.settings 代替
811
+ */
812
+ ui?: {
813
+ dashboard?: Array<{
814
+ id: string;
815
+ title: string;
816
+ path: string;
817
+ size?: {
818
+ w: number;
819
+ h: number;
820
+ };
821
+ }>;
822
+ settings?: string;
823
+ };
824
+ }
825
+ import type { PluginHooks, PluginInitContext } from './hooks';
826
+ /**
827
+ * Plugin 接口(基于 Hook Registry 模式)
828
+ *
829
+ * 所有插件必须实现此接口。插件不再直接定义钩子方法,而是通过 register(hooks) 方法注册回调。
830
+ *
831
+ * @example
832
+ * ```typescript
833
+ * export const MyPlugin = definePlugin(
834
+ * class implements Plugin {
835
+ * static readonly name = 'my-plugin';
836
+ * static readonly version = '1.0.0';
837
+ *
838
+ * bodyRequirements(): PluginBodyRequirements { return { request: 'none' }; }
839
+ * register(hooks: PluginHooks) {
840
+ * // 并行执行的初始化(非阻塞)
841
+ * hooks.onRequestInit.tapPromise({ name: 'my-plugin' }, async (ctx) => {
842
+ * await this.recordMetric();
843
+ * });
844
+ *
845
+ * // 串行执行的请求修改(阻塞)
846
+ * hooks.onBeforeRequest.tapPromise({ name: 'my-plugin' }, async (ctx) => {
847
+ * ctx.headers['X-Custom'] = 'value';
848
+ * return ctx;
849
+ * });
850
+ * }
851
+ * }
852
+ * );
853
+ * ```
854
+ */
855
+ /** SDK 3: content demand is evaluated before reading each selected request body. */
856
+ export interface PluginBodyRequirementContext {
857
+ readonly requestId: string;
858
+ readonly method: string;
859
+ readonly url: URL;
860
+ readonly routeId?: string;
861
+ readonly serviceId?: string;
862
+ readonly upstreamId?: string;
863
+ readonly stage: 'route' | 'selected';
864
+ }
865
+ export interface PluginBodyRequirements {
866
+ readonly request: 'none' | 'json-read' | 'json-write';
867
+ readonly response?: readonly ('json' | 'sse-json')[];
868
+ /** Replay retention is independent of content decoding. */
869
+ readonly replay?: boolean;
870
+ /** Optional bounded observation never upgrades forwarding demands. */
871
+ readonly observe?: Readonly<{
872
+ request?: boolean;
873
+ response?: boolean;
874
+ sse?: boolean;
875
+ }>;
876
+ }
877
+ export interface SSEEnvelope {
878
+ data: string;
879
+ json?: unknown;
880
+ event?: string;
881
+ id?: string;
882
+ retry?: string;
883
+ comments?: string[];
884
+ /** Original complete event; remove after modifying data or metadata. */
885
+ raw?: string;
886
+ }
887
+ export interface Plugin {
888
+ bodyRequirements(context: PluginBodyRequirementContext): PluginBodyRequirements;
889
+ resolveAdmissionModel?: import('./data-admission/worker').WorkerAdmissionPlugin['resolveAdmissionModel'];
890
+ prepareAdmissionAttempt?: import('./data-admission/worker').WorkerAdmissionPlugin['prepareAdmissionAttempt'];
891
+ /**
892
+ * 插件初始化
893
+ * 在 register 之前调用,用于初始化配置和资源
894
+ */
895
+ init?(context: PluginInitContext): Promise<void>;
896
+ /**
897
+ * 注册 Hooks
898
+ * 插件在此方法中选择需要的 hooks 并注册回调
899
+ *
900
+ * 流式处理现在也通过 Hook 注册:
901
+ * - hooks.onStreamChunk: 处理流式响应的每个 chunk(支持 N:M 转换)
902
+ * - hooks.onFlushStream: 流结束时刷新缓冲区
903
+ */
904
+ register(hooks: PluginHooks): void;
905
+ /**
906
+ * 重置状态(对象池使用)
907
+ */
908
+ reset?(): void | Promise<void>;
909
+ /**
910
+ * 插件销毁
911
+ */
912
+ onDestroy?(): Promise<void>;
913
+ }
914
+ /**
915
+ * Plugin 构造器类型
916
+ * 约束插件类必须提供静态元数据
917
+ */
918
+ export type PluginConstructor = {
919
+ new (...args: any[]): Plugin;
920
+ /**
921
+ * 插件唯一标识符(静态属性,必填)
922
+ */
923
+ readonly name: string;
924
+ /**
925
+ * 插件版本号(静态属性,必填)
926
+ */
927
+ readonly version: string;
928
+ /**
929
+ * 插件配置 Schema(静态属性,可选)
930
+ * 如果插件需要配置,应定义此静态属性来描述配置项
931
+ */
932
+ readonly configSchema?: PluginConfigField[];
933
+ /**
934
+ * 插件扩展元数据(静态属性,可选)
935
+ * 用于 UI 集成、权限声明、依赖管理等高级功能
936
+ */
937
+ readonly metadata?: PluginMetadata;
938
+ /**
939
+ * 插件翻译内容(静态属性,可选)
940
+ *
941
+ * 用于提供插件 UI 元素的多语言翻译
942
+ * 系统会自动收集并注册到前端 i18n 系统
943
+ */
944
+ readonly translations?: PluginTranslations;
945
+ };
946
+ /**
947
+ * 插件定义辅助函数
948
+ * 提供编译时类型检查,确保插件满足所有静态和实例要求
949
+ *
950
+ * @example
951
+ * ```typescript
952
+ * export const MyPlugin = definePlugin(
953
+ * class implements Plugin {
954
+ * static readonly name = 'my-plugin';
955
+ * static readonly version = '1.0.0';
956
+ * static readonly metadata = {
957
+ * name: 'My Plugin',
958
+ * description: 'My plugin description',
959
+ * icon: 'extension'
960
+ * };
961
+ *
962
+ * constructor(options: MyOptions) { }
963
+ *
964
+ * bodyRequirements(): PluginBodyRequirements { return { request: 'none' }; }
965
+ * register(hooks: PluginHooks) {
966
+ * hooks.onBeforeRequest.tapPromise({ name: 'my-plugin' }, async (ctx) => {
967
+ * // Plugin logic here
968
+ * return ctx;
969
+ * });
970
+ * }
971
+ * }
972
+ * );
973
+ *
974
+ * export default MyPlugin;
975
+ * ```
976
+ */
977
+ export declare function definePlugin<T extends Plugin>(plugin: PluginConstructor & {
978
+ new (...args: any[]): T;
979
+ }): typeof plugin;
980
+ /**
981
+ * 运行时辅助函数:获取插件实例的名称
982
+ * 从插件类的静态属性读取
983
+ */
984
+ export declare function getPluginName(plugin: Plugin): string;
985
+ /**
986
+ * 运行时辅助函数:获取插件实例的版本
987
+ * 从插件类的静态属性读取
988
+ */
989
+ export declare function getPluginVersion(plugin: Plugin): string;
990
+ /**
991
+ * 运行时辅助函数:获取插件实例的描述
992
+ * 从插件类的 metadata.description 静态属性读取
993
+ */
994
+ export declare function getPluginDescription(plugin: Plugin): string | undefined;
995
+ /**
996
+ * 运行时辅助函数:获取插件实例的元数据
997
+ * 从插件类的静态属性读取
998
+ */
999
+ export declare function getPluginMetadata(plugin: Plugin): PluginMetadata | undefined;