omnicell-router 0.7.0 → 0.8.2

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 (246) hide show
  1. package/backend/dist/cli/clients/activity.d.ts +35 -0
  2. package/backend/dist/cli/clients/activity.js +67 -0
  3. package/backend/dist/cli/clients/base.d.ts +13 -2
  4. package/backend/dist/cli/clients/claude.d.ts +2 -2
  5. package/backend/dist/cli/clients/codex.d.ts +2 -2
  6. package/backend/dist/cli/clients/core-adapters.d.ts +3 -4
  7. package/backend/dist/cli/clients/core-adapters.js +3 -4
  8. package/backend/dist/cli/clients/cursor-proxy.d.ts +88 -0
  9. package/backend/dist/cli/clients/cursor-proxy.js +421 -0
  10. package/backend/dist/cli/clients/dsh.d.ts +2 -2
  11. package/backend/dist/cli/clients/grok.d.ts +2 -2
  12. package/backend/dist/cli/clients/index.d.ts +8 -1
  13. package/backend/dist/cli/clients/index.js +55 -21
  14. package/backend/dist/cli/clients/kimi.d.ts +2 -2
  15. package/backend/dist/cli/clients/launcher.d.ts +8 -0
  16. package/backend/dist/cli/clients/model-meta.js +1 -1
  17. package/backend/dist/cli/clients/omp.d.ts +2 -2
  18. package/backend/dist/cli/clients/openclaw.d.ts +2 -2
  19. package/backend/dist/cli/clients/opencode-proxy.d.ts +11 -0
  20. package/backend/dist/cli/clients/opencode-proxy.js +351 -0
  21. package/backend/dist/cli/clients/opencode.d.ts +2 -2
  22. package/backend/dist/cli/clients/pi.d.ts +2 -2
  23. package/backend/dist/cli/clients/plugin-adapters.d.ts +3 -1
  24. package/backend/dist/cli/clients/plugin-adapters.js +6 -29
  25. package/backend/dist/cli/clients/qoder-proxy.d.ts +84 -0
  26. package/backend/dist/cli/clients/qoder-proxy.js +497 -0
  27. package/backend/dist/cli/clients/reserved.d.ts +2 -6
  28. package/backend/dist/cli/clients/reserved.js +2 -0
  29. package/backend/dist/cli/clients/workbuddy.d.ts +2 -2
  30. package/backend/dist/cli/index.js +60 -9
  31. package/backend/dist/cli/types.d.ts +29 -8
  32. package/backend/dist/compression/caveman-prompts.d.ts +1 -1
  33. package/backend/dist/config/comments-en.js +6 -12
  34. package/backend/dist/config/comments-zh.js +6 -12
  35. package/backend/dist/config/defaults.d.ts +56 -1
  36. package/backend/dist/config/defaults.js +68 -0
  37. package/backend/dist/config/index.d.ts +9 -2
  38. package/backend/dist/config/index.js +26 -3
  39. package/backend/dist/config/types.d.ts +55 -43
  40. package/backend/dist/forward-proxy/egress.d.ts +10 -2
  41. package/backend/dist/forward-proxy/egress.js +42 -4
  42. package/backend/dist/forward-proxy/ordered-relay.d.ts +29 -0
  43. package/backend/dist/forward-proxy/ordered-relay.js +46 -0
  44. package/backend/dist/forward-proxy/rules.d.ts +66 -19
  45. package/backend/dist/forward-proxy/rules.js +61 -14
  46. package/backend/dist/forward-proxy/server.js +226 -77
  47. package/backend/dist/forward-proxy/system-proxy.d.ts +42 -2
  48. package/backend/dist/forward-proxy/system-proxy.js +199 -22
  49. package/backend/dist/harness/common/market.d.ts +3 -3
  50. package/backend/dist/harness/host/adapters/amp.d.ts +1 -1
  51. package/backend/dist/harness/host/adapters/antigravity.d.ts +1 -1
  52. package/backend/dist/harness/host/adapters/claude.d.ts +1 -1
  53. package/backend/dist/harness/host/adapters/cline.d.ts +1 -1
  54. package/backend/dist/harness/host/adapters/codex.d.ts +1 -1
  55. package/backend/dist/harness/host/adapters/cursor.d.ts +1 -1
  56. package/backend/dist/harness/host/adapters/dsh.d.ts +2 -2
  57. package/backend/dist/harness/host/adapters/factory.d.ts +1 -1
  58. package/backend/dist/harness/host/adapters/gemini-cli.d.ts +1 -1
  59. package/backend/dist/harness/host/adapters/grok.d.ts +1 -1
  60. package/backend/dist/harness/host/adapters/kimi.d.ts +1 -1
  61. package/backend/dist/harness/host/adapters/omp.d.ts +1 -1
  62. package/backend/dist/harness/host/adapters/openclaw.d.ts +1 -1
  63. package/backend/dist/harness/host/adapters/opencode.d.ts +1 -1
  64. package/backend/dist/harness/host/adapters/pi.d.ts +1 -1
  65. package/backend/dist/harness/host/adapters/universal.d.ts +1 -1
  66. package/backend/dist/harness/host/adapters/windsurf.d.ts +1 -1
  67. package/backend/dist/harness/host/adapters/zed.d.ts +1 -1
  68. package/backend/dist/harness/skill/skills-sh.d.ts +1 -1
  69. package/backend/dist/harness/translation.js +64 -21
  70. package/backend/dist/harness/types.d.ts +1 -1
  71. package/backend/dist/harness/types.js +1 -1
  72. package/backend/dist/index.js +31 -18
  73. package/backend/dist/ir/adapters/anthropic-stream.d.ts +18 -0
  74. package/backend/dist/ir/adapters/anthropic-stream.js +247 -0
  75. package/backend/dist/ir/adapters/anthropic.d.ts +29 -0
  76. package/backend/dist/ir/adapters/anthropic.js +788 -0
  77. package/backend/dist/ir/adapters/chat.d.ts +15 -0
  78. package/backend/dist/ir/adapters/chat.js +602 -0
  79. package/backend/dist/ir/adapters/google-stream.d.ts +22 -0
  80. package/backend/dist/ir/adapters/google-stream.js +242 -0
  81. package/backend/dist/ir/adapters/google.d.ts +9 -0
  82. package/backend/dist/ir/adapters/google.js +317 -0
  83. package/backend/dist/ir/adapters/openai-responses-output.js +8 -5
  84. package/backend/dist/ir/adapters/openai-responses.d.ts +15 -0
  85. package/backend/dist/ir/adapters/openai-responses.js +26 -1
  86. package/backend/dist/ir/adapters/responses-output.d.ts +50 -0
  87. package/backend/dist/ir/adapters/responses-output.js +348 -0
  88. package/backend/dist/ir/adapters/responses-stream.d.ts +12 -0
  89. package/backend/dist/ir/adapters/responses-stream.js +178 -0
  90. package/backend/dist/ir/adapters/responses.d.ts +14 -0
  91. package/backend/dist/ir/adapters/responses.js +646 -0
  92. package/backend/dist/ir/errors.d.ts +2 -2
  93. package/backend/dist/ir/types.d.ts +2 -1
  94. package/backend/dist/metrics/request-cost.d.ts +11 -2
  95. package/backend/dist/metrics/request-cost.js +12 -3
  96. package/backend/dist/observability/request-identity.d.ts +1 -1
  97. package/backend/dist/observability/trace-id.d.ts +40 -0
  98. package/backend/dist/observability/trace-id.js +134 -0
  99. package/backend/dist/observability/upstream-events.d.ts +82 -60
  100. package/backend/dist/observability/upstream-events.js +142 -67
  101. package/backend/dist/opencode/catalog/types.d.ts +9 -0
  102. package/backend/dist/opencode/credentials/types.d.ts +2 -2
  103. package/backend/dist/opencode/probe.d.ts +24 -1
  104. package/backend/dist/opencode/probe.js +28 -4
  105. package/backend/dist/opencode/user-config.d.ts +5 -0
  106. package/backend/dist/pipeline/directives.d.ts +6 -2
  107. package/backend/dist/pipeline/directives.js +7 -3
  108. package/backend/dist/pipeline/orchestrator.d.ts +28 -27
  109. package/backend/dist/pipeline/orchestrator.js +220 -194
  110. package/backend/dist/pipeline/unresolved-model.d.ts +33 -0
  111. package/backend/dist/pipeline/unresolved-model.js +43 -0
  112. package/backend/dist/plugins/catalog-def.d.ts +143 -0
  113. package/backend/dist/plugins/catalog-def.js +177 -0
  114. package/backend/dist/plugins/gateways.d.ts +62 -3
  115. package/backend/dist/plugins/gateways.js +139 -2
  116. package/backend/dist/plugins/host.d.ts +42 -5
  117. package/backend/dist/plugins/host.js +454 -38
  118. package/backend/dist/plugins/manifest.d.ts +119 -10
  119. package/backend/dist/plugins/manifest.js +265 -14
  120. package/backend/dist/plugins/pack.js +26 -0
  121. package/backend/dist/plugins/types.d.ts +187 -21
  122. package/backend/dist/protocols/systemone/convert.d.ts +1 -0
  123. package/backend/dist/protocols/systemone/convert.js +6 -1
  124. package/backend/dist/protocols/systemone/decide.js +18 -8
  125. package/backend/dist/providers/anthropic-messages.d.ts +12 -0
  126. package/backend/dist/providers/anthropic-messages.js +53 -0
  127. package/backend/dist/providers/anthropic.d.ts +7 -8
  128. package/backend/dist/providers/anthropic.js +36 -324
  129. package/backend/dist/providers/base.d.ts +14 -2
  130. package/backend/dist/providers/boot-direct.js +68 -38
  131. package/backend/dist/providers/dispatch.d.ts +5 -19
  132. package/backend/dist/providers/dispatch.js +46 -58
  133. package/backend/dist/providers/executors/anthropic-messages.d.ts +1 -0
  134. package/backend/dist/providers/executors/anthropic-messages.js +3 -0
  135. package/backend/dist/providers/executors/dispatch.d.ts +16 -2
  136. package/backend/dist/providers/executors/dispatch.js +39 -9
  137. package/backend/dist/providers/executors/google-gemini.d.ts +1 -0
  138. package/backend/dist/providers/executors/google-gemini.js +3 -0
  139. package/backend/dist/providers/executors/http-stream.js +16 -3
  140. package/backend/dist/providers/executors/openai-chat.d.ts +1 -0
  141. package/backend/dist/providers/executors/openai-chat.js +3 -0
  142. package/backend/dist/providers/executors/openai-responses.d.ts +1 -0
  143. package/backend/dist/providers/executors/openai-responses.js +3 -0
  144. package/backend/dist/providers/executors/plugin-adapter.js +4 -4
  145. package/backend/dist/providers/google-gemini.d.ts +12 -0
  146. package/backend/dist/providers/google-gemini.js +50 -0
  147. package/backend/dist/providers/google.d.ts +7 -8
  148. package/backend/dist/providers/google.js +35 -308
  149. package/backend/dist/providers/http-json.d.ts +19 -0
  150. package/backend/dist/providers/http-json.js +104 -0
  151. package/backend/dist/providers/http-stream.d.ts +52 -0
  152. package/backend/dist/providers/http-stream.js +423 -0
  153. package/backend/dist/providers/member-match.d.ts +4 -5
  154. package/backend/dist/providers/member-match.js +4 -5
  155. package/backend/dist/providers/openai-chat.d.ts +13 -0
  156. package/backend/dist/providers/openai-chat.js +99 -0
  157. package/backend/dist/providers/openai-compatible.d.ts +7 -4
  158. package/backend/dist/providers/openai-compatible.js +71 -368
  159. package/backend/dist/providers/openai-responses.d.ts +12 -0
  160. package/backend/dist/providers/openai-responses.js +68 -0
  161. package/backend/dist/providers/opencode-proxy.d.ts +5 -5
  162. package/backend/dist/providers/opencode-proxy.js +49 -125
  163. package/backend/dist/providers/plugin-adapter.d.ts +9 -0
  164. package/backend/dist/providers/plugin-adapter.js +31 -0
  165. package/backend/dist/providers/registry.d.ts +49 -24
  166. package/backend/dist/providers/registry.js +97 -55
  167. package/backend/dist/providers/responses.d.ts +7 -28
  168. package/backend/dist/providers/responses.js +45 -253
  169. package/backend/dist/providers/tool-markup-leak.d.ts +41 -0
  170. package/backend/dist/providers/tool-markup-leak.js +57 -0
  171. package/backend/dist/providers/tool-markup-recovery.d.ts +27 -0
  172. package/backend/dist/providers/tool-markup-recovery.js +786 -0
  173. package/backend/dist/providers/virtual-meta.d.ts +21 -2
  174. package/backend/dist/providers/virtual-meta.js +49 -9
  175. package/backend/dist/proxy/asset-download.d.ts +54 -0
  176. package/backend/dist/proxy/asset-download.js +420 -0
  177. package/backend/dist/proxy/manual-node-spec.d.ts +16 -16
  178. package/backend/dist/proxy/mihomo-binary.d.ts +17 -2
  179. package/backend/dist/proxy/mihomo-binary.js +62 -51
  180. package/backend/dist/proxy/mihomo-client.js +15 -1
  181. package/backend/dist/proxy/mihomo-config.js +11 -2
  182. package/backend/dist/proxy/mihomo-geo.d.ts +87 -0
  183. package/backend/dist/proxy/mihomo-geo.js +213 -0
  184. package/backend/dist/proxy/mihomo-logs.d.ts +27 -0
  185. package/backend/dist/proxy/mihomo-logs.js +70 -0
  186. package/backend/dist/proxy/mihomo-pac.d.ts +11 -0
  187. package/backend/dist/proxy/mihomo-pac.js +15 -0
  188. package/backend/dist/proxy/mihomo-rules-import.d.ts +1 -1
  189. package/backend/dist/proxy/mihomo-rules-import.js +7 -7
  190. package/backend/dist/proxy/mihomo-sidecar.d.ts +17 -1
  191. package/backend/dist/proxy/mihomo-sidecar.js +148 -26
  192. package/backend/dist/quota/adapters/minimax.js +36 -13
  193. package/backend/dist/quota/cli-login.d.ts +8 -0
  194. package/backend/dist/quota/cli-login.js +18 -0
  195. package/backend/dist/quota/declarations.js +10 -0
  196. package/backend/dist/quota/dsl.js +18 -5
  197. package/backend/dist/quota/engine.d.ts +22 -1
  198. package/backend/dist/quota/engine.js +170 -29
  199. package/backend/dist/quota/prober.d.ts +5 -0
  200. package/backend/dist/quota/prober.js +11 -2
  201. package/backend/dist/quota/types.d.ts +87 -8
  202. package/backend/dist/quota/verdict.d.ts +35 -0
  203. package/backend/dist/quota/verdict.js +135 -0
  204. package/backend/dist/ratelimit/admission.d.ts +131 -0
  205. package/backend/dist/ratelimit/admission.js +233 -0
  206. package/backend/dist/ratelimit/rate-limiter.js +6 -0
  207. package/backend/dist/resilience/types.d.ts +2 -2
  208. package/backend/dist/router/layer2-decision.d.ts +1 -1
  209. package/backend/dist/router/layer2-decision.js +5 -8
  210. package/backend/dist/routes/console.js +248 -52
  211. package/backend/dist/routes/mihomo.d.ts +2 -0
  212. package/backend/dist/routes/mihomo.js +334 -29
  213. package/backend/dist/routes/responses.d.ts +87 -8
  214. package/backend/dist/routes/responses.js +314 -33
  215. package/backend/dist/server.js +34 -6
  216. package/backend/dist/session/session-manager.d.ts +6 -0
  217. package/backend/dist/session/session-manager.js +20 -9
  218. package/backend/dist/surfaces/chat-pipeline.d.ts +2 -2
  219. package/backend/dist/surfaces/chat-pipeline.js +17 -7
  220. package/backend/dist/surfaces/chat.js +15 -0
  221. package/backend/dist/surfaces/decision-pipeline.js +7 -10
  222. package/backend/dist/surfaces/direct-forward.d.ts +3 -0
  223. package/backend/dist/surfaces/direct-forward.js +206 -0
  224. package/backend/dist/surfaces/rate-limit-response.d.ts +17 -0
  225. package/backend/dist/surfaces/rate-limit-response.js +57 -0
  226. package/backend/dist/surfaces/types.d.ts +11 -0
  227. package/backend/dist/trace/tracker.d.ts +32 -1
  228. package/backend/dist/trace/tracker.js +29 -4
  229. package/backend/dist/types/router.d.ts +34 -12
  230. package/backend/dist/types/router.js +35 -6
  231. package/backend/dist/utils/chat-stream.d.ts +21 -8
  232. package/backend/dist/utils/chat-stream.js +46 -9
  233. package/backend/dist/utils/event-ring.d.ts +4 -0
  234. package/backend/dist/utils/event-ring.js +4 -0
  235. package/backend/dist/utils/popularity.js +29 -4
  236. package/backend/dist/utils/proxy.d.ts +7 -0
  237. package/backend/dist/utils/proxy.js +35 -10
  238. package/backend/dist/utils/retry-after.d.ts +21 -0
  239. package/backend/dist/utils/retry-after.js +36 -0
  240. package/bin/ocr.js +2 -2
  241. package/frontend/dist/assets/index-55VVwfFQ.js +1521 -0
  242. package/frontend/dist/assets/{index-CQSLGFTV.css → index-DxZ9MHKB.css} +1 -1
  243. package/frontend/dist/assets/workbuddy.color-DOMpQkxJ.svg +29 -0
  244. package/frontend/dist/index.html +2 -2
  245. package/package.json +1 -1
  246. package/frontend/dist/assets/index-CLvxJjp_.js +0 -1476
@@ -10,19 +10,94 @@
10
10
  * extension point is claimed SNI hosts; the runtime view reads `wires ?? []`),
11
11
  * every other shape rule holds for both plugin types.
12
12
  */
13
- import type { PluginManifest, PluginPart, PluginType } from './types.js';
14
- /** Contract version the CURRENT host implements. v1 is the FIRST plugin
15
- * mechanism: there is no legacy or forward compatibility — a package must
16
- * declare EXACTLY this value, anything else is an illegal package (ADR-0017
17
- * §6). A deliberate compatibility window can only be added later, together
18
- * with the test matrix that proves it. */
13
+ import type { PluginClaimEgress, PluginConfigField, PluginManifest, PluginPart, PluginType } from './types.js';
14
+ /** The plugin ENGINE version the host implements — the version of the plugin
15
+ * surface core offers package code (`createPlugin(host)` and everything
16
+ * reachable from it).
17
+ *
18
+ * ONE INTEGER, on purpose (ADR-0036). The engine version IS the plugin
19
+ * contract version: an engine release that does not change the surface a
20
+ * package can see is not a different engine where compatibility is concerned,
21
+ * and `createPlugin` has no second dimension for a package to depend on.
22
+ * A behaviour fix that a package can notice therefore ships as a contract
23
+ * bump — which is exactly what it is — and `engines` has no room to say
24
+ * anything `apiVersion` does not already say.
25
+ *
26
+ * Bump discipline: raising this constant is the ONLY step a surface change
27
+ * needs. Packages declaring the previous value are then refused with a
28
+ * sentence that says which side is behind; nothing else in core reads it. */
29
+ export declare const PLUGIN_ENGINE_VERSION = 1;
30
+ /** The plugin CONTRACT this host implements — the same number by another name.
31
+ * Kept as its own constant because readers come at it from two directions: a
32
+ * package DECLARES `apiVersion`, this host boasts `SUPPORTED_PLUGIN_API`, and
33
+ * the comparison between them is the whole rule (see
34
+ * `pluginEngineCompatibility`). Equal to {@link PLUGIN_ENGINE_VERSION} by
35
+ * construction, never by coincidence — see ADR-0036 on why there is one
36
+ * number. */
19
37
  export declare const SUPPORTED_PLUGIN_API = 1;
38
+ /** Lower bound of the supported CONTRACT window. Equal to
39
+ * `SUPPORTED_PLUGIN_API` today: one contract, no legacy. Raising it retires
40
+ * the contracts in `[MIN, SUPPORTED)` — packages declaring them are refused
41
+ * exactly like a too-new one. */
42
+ export declare const MIN_SUPPORTED_PLUGIN_API = 1;
43
+ /** Why a package was refused. Two directions, never one sentence: a package
44
+ * that targeted a retired contract is fixed by installing its newer release;
45
+ * a package that needs a newer engine is fixed by updating the GATEWAY, and
46
+ * reinstalling it moves nothing. */
47
+ export type PluginEngineRefusalReason = 'contract-too-old' | 'contract-too-new';
48
+ /** Whether a package may load on THIS host, and if not, which side is behind
49
+ * and therefore what the operator has to do about it. */
50
+ export type PluginEngineCompatibility = {
51
+ compatible: true;
52
+ required: number;
53
+ } | {
54
+ compatible: false;
55
+ reason: PluginEngineRefusalReason;
56
+ required: number;
57
+ };
58
+ /**
59
+ * The whole compatibility rule, in ONE place (ADR-0036). One declaration, one
60
+ * comparison:
61
+ *
62
+ * - `apiVersion` ABOVE `SUPPORTED_PLUGIN_API` — the package was written
63
+ * against a surface this build does not have. Fixed by updating the
64
+ * GATEWAY; reinstalling the same file moves nothing.
65
+ * - `apiVersion` BELOW `MIN_SUPPORTED_PLUGIN_API` — the contract it targets
66
+ * has been retired. Fixed by installing the package's newer release.
67
+ * - Otherwise it loads.
68
+ *
69
+ * There is no window, no floor and no ceiling: a package states the ONE engine
70
+ * it was developed against, and the integers compare. A package that wanted to
71
+ * say "and any later engine of this line" would be asserting compatibility it
72
+ * cannot know, which is why the contract does not offer the spelling.
73
+ */
74
+ export declare function pluginEngineCompatibility(manifest: PluginManifest): PluginEngineCompatibility;
75
+ /** The operator-facing sentence for a refused package. ONE wording, produced
76
+ * by CORE, never by a package: it is an instruction about what the operator
77
+ * must DO, and it has to name the right side to act on. */
78
+ export declare function pluginEngineRefusal(manifest: PluginManifest): string | undefined;
79
+ /** Reject a package the host cannot run. Called at INSTALL (before anything
80
+ * touches disk) and at LOAD (packages already on disk); the LOAD path turns
81
+ * the same verdict into a disabled console row instead of a failed one, so the
82
+ * message below is what the operator reads. */
83
+ export declare function assertSupportedPluginApi(manifest: PluginManifest): void;
20
84
  /** Where a config field is edited: the plugin drawer (default), the Client Hub
21
85
  * card the hook backs, or nowhere (stored, but dead for this hook). */
22
- export declare const CONFIG_PLACEMENTS: readonly ['drawer', 'card', 'none'];
23
- /** Reject a package built for any other contract version. Called at INSTALL
24
- * (before anything touches disk) and at LOAD (packages already on disk). */
25
- export declare function assertSupportedPluginApi(apiVersion: number): void;
86
+ export declare const CONFIG_PLACEMENTS: readonly ["drawer", "card", "none"];
87
+ /**
88
+ * The plugin-level outbound-leg switch (ADR-0018 Revision 5), keyed and valued by
89
+ * CORE. Once a package claims a host, the leg under that host is the package's
90
+ * business — but the operator keeps the last word over the code they installed,
91
+ * and that word is spoken ONCE per plugin, not once per host: one switch that
92
+ * reaches every host this gateway claims.
93
+ *
94
+ * The default is `inherit`, deliberately NOT the manifest's own declaration:
95
+ * the switch sits ABOVE the plugin's code, and a default of `proxy` would make
96
+ * every untouched plugin a silent override of its own `egressFor()` answers.
97
+ * `inherit` is the state that leaves the claim in charge.
98
+ */
99
+ export declare const GATEWAY_EGRESS_CONFIG_KEY = "egress";
100
+ export declare const GATEWAY_EGRESS_VALUES: readonly ["inherit", "proxy", "direct"];
26
101
  /** The three extension axes (ADR-0017 / ADR-0027), in the order a console row
27
102
  * prefers to label them: a package that is both an ingress hook and a traffic
28
103
  * owner reads as a client adapter first, because that is the half the operator
@@ -36,6 +111,40 @@ export declare function isPluginType(value: unknown): value is PluginType;
36
111
  * Assumes a validated manifest.
37
112
  */
38
113
  export declare function normalizePluginParts(manifest: PluginManifest): PluginPart[];
114
+ /** The hosts a manifest's client-gateway part claims, under BOTH spellings
115
+ * (`type`/top-level `hosts`, or the `parts` entry). Empty for a package that
116
+ * is not a gateway at all. */
117
+ export declare function gatewayClaimedHosts(manifest: PluginManifest): string[];
118
+ /**
119
+ * Whether the console should offer the operator the plugin-level leg switch:
120
+ * a gateway with at least one CONCRETE claimed host. A wildcard gateway claims
121
+ * no host, so a switch over it would be a switch over traffic it does not own
122
+ * (the same refusal the manifest validator applies to `egress` on `'*'`).
123
+ */
124
+ export declare function hasOwnableClaim(manifest: PluginManifest): boolean;
125
+ /**
126
+ * The field core injects into a gateway's `configSchema` so the operator's
127
+ * switch appears in the plugin's own settings drawer (ADR-0018 Revision 5). No
128
+ * `title`/`desc`/`enumLabels` on purpose: this row is CORE chrome, not package
129
+ * content, so its wording comes from the console's translation tables the same
130
+ * as every other label (`isCoreEgressField` in the frontend recognizes it) and
131
+ * never from a package author's English.
132
+ */
133
+ export declare function gatewayEgressField(): PluginConfigField;
134
+ /**
135
+ * The operator's EXPLICIT leg choice out of a merged plugin config. `inherit` —
136
+ * the untouched default — is deliberately NOT a choice: it means "let the claim
137
+ * answer", so it must not outrank the plugin's own `egressFor()` the way a
138
+ * picked value does.
139
+ */
140
+ export declare function operatorEgressChoice(values: Record<string, unknown>): PluginClaimEgress | undefined;
141
+ /**
142
+ * Add the core switch to a gateway manifest, idempotently and without touching
143
+ * any other field. Called at MANIFEST READ, before the host SDK hands the
144
+ * manifest to a plugin's `config()` closure: injected later, the drawer, the
145
+ * merge and the plugin's own read would disagree about whether the key exists.
146
+ */
147
+ export declare function withGatewayEgressField(manifest: PluginManifest): PluginManifest;
39
148
  export declare function isValidPluginId(id: unknown): id is string;
40
149
  export declare function validatePluginManifest(manifest: unknown, label: string): void;
41
150
  /** Validate one plugin's `configSchema` (flat primitive fields, ADR-0017 §7)
@@ -1,19 +1,95 @@
1
- /** Contract version the CURRENT host implements. v1 is the FIRST plugin
2
- * mechanism: there is no legacy or forward compatibility — a package must
3
- * declare EXACTLY this value, anything else is an illegal package (ADR-0017
4
- * §6). A deliberate compatibility window can only be added later, together
5
- * with the test matrix that proves it. */
6
- export const SUPPORTED_PLUGIN_API = 1;
1
+ /** The plugin ENGINE version the host implements — the version of the plugin
2
+ * surface core offers package code (`createPlugin(host)` and everything
3
+ * reachable from it).
4
+ *
5
+ * ONE INTEGER, on purpose (ADR-0036). The engine version IS the plugin
6
+ * contract version: an engine release that does not change the surface a
7
+ * package can see is not a different engine where compatibility is concerned,
8
+ * and `createPlugin` has no second dimension for a package to depend on.
9
+ * A behaviour fix that a package can notice therefore ships as a contract
10
+ * bump — which is exactly what it is — and `engines` has no room to say
11
+ * anything `apiVersion` does not already say.
12
+ *
13
+ * Bump discipline: raising this constant is the ONLY step a surface change
14
+ * needs. Packages declaring the previous value are then refused with a
15
+ * sentence that says which side is behind; nothing else in core reads it. */
16
+ export const PLUGIN_ENGINE_VERSION = 1;
17
+ /** The plugin CONTRACT this host implements — the same number by another name.
18
+ * Kept as its own constant because readers come at it from two directions: a
19
+ * package DECLARES `apiVersion`, this host boasts `SUPPORTED_PLUGIN_API`, and
20
+ * the comparison between them is the whole rule (see
21
+ * `pluginEngineCompatibility`). Equal to {@link PLUGIN_ENGINE_VERSION} by
22
+ * construction, never by coincidence — see ADR-0036 on why there is one
23
+ * number. */
24
+ export const SUPPORTED_PLUGIN_API = PLUGIN_ENGINE_VERSION;
25
+ /** Lower bound of the supported CONTRACT window. Equal to
26
+ * `SUPPORTED_PLUGIN_API` today: one contract, no legacy. Raising it retires
27
+ * the contracts in `[MIN, SUPPORTED)` — packages declaring them are refused
28
+ * exactly like a too-new one. */
29
+ export const MIN_SUPPORTED_PLUGIN_API = SUPPORTED_PLUGIN_API;
30
+ /**
31
+ * The whole compatibility rule, in ONE place (ADR-0036). One declaration, one
32
+ * comparison:
33
+ *
34
+ * - `apiVersion` ABOVE `SUPPORTED_PLUGIN_API` — the package was written
35
+ * against a surface this build does not have. Fixed by updating the
36
+ * GATEWAY; reinstalling the same file moves nothing.
37
+ * - `apiVersion` BELOW `MIN_SUPPORTED_PLUGIN_API` — the contract it targets
38
+ * has been retired. Fixed by installing the package's newer release.
39
+ * - Otherwise it loads.
40
+ *
41
+ * There is no window, no floor and no ceiling: a package states the ONE engine
42
+ * it was developed against, and the integers compare. A package that wanted to
43
+ * say "and any later engine of this line" would be asserting compatibility it
44
+ * cannot know, which is why the contract does not offer the spelling.
45
+ */
46
+ export function pluginEngineCompatibility(manifest) {
47
+ const required = manifest.apiVersion;
48
+ if (required > SUPPORTED_PLUGIN_API)
49
+ return { compatible: false, reason: 'contract-too-new', required };
50
+ if (required < MIN_SUPPORTED_PLUGIN_API)
51
+ return { compatible: false, reason: 'contract-too-old', required };
52
+ return { compatible: true, required };
53
+ }
54
+ /** The operator-facing sentence for a refused package. ONE wording, produced
55
+ * by CORE, never by a package: it is an instruction about what the operator
56
+ * must DO, and it has to name the right side to act on. */
57
+ export function pluginEngineRefusal(manifest) {
58
+ const verdict = pluginEngineCompatibility(manifest);
59
+ if (verdict.compatible)
60
+ return undefined;
61
+ const who = `'${manifest.id}' ${manifest.version}`;
62
+ if (verdict.reason === 'contract-too-new') {
63
+ return `plugin ${who} targets plugin contract ${verdict.required}, newer than this gateway's ${SUPPORTED_PLUGIN_API} — update OmniCellRouter to use this plugin`;
64
+ }
65
+ return `plugin ${who} targets plugin contract ${verdict.required}, which this gateway no longer supports (supported: ${MIN_SUPPORTED_PLUGIN_API}–${SUPPORTED_PLUGIN_API}) — update the plugin to a newer release`;
66
+ }
67
+ /** Reject a package the host cannot run. Called at INSTALL (before anything
68
+ * touches disk) and at LOAD (packages already on disk); the LOAD path turns
69
+ * the same verdict into a disabled console row instead of a failed one, so the
70
+ * message below is what the operator reads. */
71
+ export function assertSupportedPluginApi(manifest) {
72
+ const refusal = pluginEngineRefusal(manifest);
73
+ if (refusal)
74
+ throw new Error(refusal);
75
+ }
7
76
  /** Where a config field is edited: the plugin drawer (default), the Client Hub
8
77
  * card the hook backs, or nowhere (stored, but dead for this hook). */
9
78
  export const CONFIG_PLACEMENTS = ['drawer', 'card', 'none'];
10
- /** Reject a package built for any other contract version. Called at INSTALL
11
- * (before anything touches disk) and at LOAD (packages already on disk). */
12
- export function assertSupportedPluginApi(apiVersion) {
13
- if (apiVersion !== SUPPORTED_PLUGIN_API) {
14
- throw new Error(`plugin apiVersion ${apiVersion} does not match this host's plugin contract (${SUPPORTED_PLUGIN_API}) — rebuild the package with the current packager`);
15
- }
16
- }
79
+ /**
80
+ * The plugin-level outbound-leg switch (ADR-0018 Revision 5), keyed and valued by
81
+ * CORE. Once a package claims a host, the leg under that host is the package's
82
+ * business — but the operator keeps the last word over the code they installed,
83
+ * and that word is spoken ONCE per plugin, not once per host: one switch that
84
+ * reaches every host this gateway claims.
85
+ *
86
+ * The default is `inherit`, deliberately NOT the manifest's own declaration:
87
+ * the switch sits ABOVE the plugin's code, and a default of `proxy` would make
88
+ * every untouched plugin a silent override of its own `egressFor()` answers.
89
+ * `inherit` is the state that leaves the claim in charge.
90
+ */
91
+ export const GATEWAY_EGRESS_CONFIG_KEY = 'egress';
92
+ export const GATEWAY_EGRESS_VALUES = ['inherit', 'proxy', 'direct'];
17
93
  /** The three extension axes (ADR-0017 / ADR-0027), in the order a console row
18
94
  * prefers to label them: a package that is both an ingress hook and a traffic
19
95
  * owner reads as a client adapter first, because that is the half the operator
@@ -33,7 +109,64 @@ export function normalizePluginParts(manifest) {
33
109
  return manifest.parts;
34
110
  if (!isPluginType(manifest.type))
35
111
  return [];
36
- return [{ type: manifest.type, wires: manifest.wires, hosts: manifest.hosts }];
112
+ return [{ type: manifest.type, wires: manifest.wires, hosts: manifest.hosts, egress: manifest.egress }];
113
+ }
114
+ /** The hosts a manifest's client-gateway part claims, under BOTH spellings
115
+ * (`type`/top-level `hosts`, or the `parts` entry). Empty for a package that
116
+ * is not a gateway at all. */
117
+ export function gatewayClaimedHosts(manifest) {
118
+ return normalizePluginParts(manifest).find((p) => p.type === 'client-gateway')?.hosts ?? [];
119
+ }
120
+ /**
121
+ * Whether the console should offer the operator the plugin-level leg switch:
122
+ * a gateway with at least one CONCRETE claimed host. A wildcard gateway claims
123
+ * no host, so a switch over it would be a switch over traffic it does not own
124
+ * (the same refusal the manifest validator applies to `egress` on `'*'`).
125
+ */
126
+ export function hasOwnableClaim(manifest) {
127
+ return gatewayClaimedHosts(manifest).some((h) => String(h).trim() !== '*');
128
+ }
129
+ /**
130
+ * The field core injects into a gateway's `configSchema` so the operator's
131
+ * switch appears in the plugin's own settings drawer (ADR-0018 Revision 5). No
132
+ * `title`/`desc`/`enumLabels` on purpose: this row is CORE chrome, not package
133
+ * content, so its wording comes from the console's translation tables the same
134
+ * as every other label (`isCoreEgressField` in the frontend recognizes it) and
135
+ * never from a package author's English.
136
+ */
137
+ export function gatewayEgressField() {
138
+ return {
139
+ key: GATEWAY_EGRESS_CONFIG_KEY,
140
+ type: 'enum',
141
+ values: [...GATEWAY_EGRESS_VALUES],
142
+ default: 'inherit',
143
+ control: 'segmented',
144
+ essential: true,
145
+ };
146
+ }
147
+ /**
148
+ * The operator's EXPLICIT leg choice out of a merged plugin config. `inherit` —
149
+ * the untouched default — is deliberately NOT a choice: it means "let the claim
150
+ * answer", so it must not outrank the plugin's own `egressFor()` the way a
151
+ * picked value does.
152
+ */
153
+ export function operatorEgressChoice(values) {
154
+ const v = values[GATEWAY_EGRESS_CONFIG_KEY];
155
+ return v === 'proxy' || v === 'direct' ? v : undefined;
156
+ }
157
+ /**
158
+ * Add the core switch to a gateway manifest, idempotently and without touching
159
+ * any other field. Called at MANIFEST READ, before the host SDK hands the
160
+ * manifest to a plugin's `config()` closure: injected later, the drawer, the
161
+ * merge and the plugin's own read would disagree about whether the key exists.
162
+ */
163
+ export function withGatewayEgressField(manifest) {
164
+ if (!hasOwnableClaim(manifest))
165
+ return manifest;
166
+ const schema = manifest.configSchema ?? [];
167
+ if (schema.some((f) => f.key === GATEWAY_EGRESS_CONFIG_KEY))
168
+ return manifest;
169
+ return { ...manifest, configSchema: [gatewayEgressField(), ...schema] };
37
170
  }
38
171
  /** A plugin id is a PATH COMPONENT — `<pluginsRoot>/<id>.zip`,
39
172
  * `<pluginsRoot>/unpacked/<id>/`, `<pluginsRoot>/bundled/<id>.zip` — so the
@@ -77,6 +210,11 @@ export function validatePluginManifest(manifest, label) {
77
210
  if (typeof m.apiVersion !== 'number' || !Number.isInteger(m.apiVersion) || m.apiVersion < 1) {
78
211
  fail('apiVersion must be a positive integer (the plugin contract version, currently 1)');
79
212
  }
213
+ // `engines` is RETIRED (ADR-0036 Amendment 1): the engine version is the
214
+ // contract version, so `apiVersion` above is the whole declaration. A
215
+ // package that still carries the field is not rejected for it — it is simply
216
+ // not read, the same way any other unknown key is not read — because a
217
+ // refusal here would fail packages for a field that used to be required.
80
218
  // --- Extension axes: `type` (exactly one) or `parts` (any subset) -------
81
219
  // ADR-0028: the axes are independent capabilities, so the manifest states
82
220
  // which slots a package fills. Both spellings are accepted, never together:
@@ -86,6 +224,20 @@ export function validatePluginManifest(manifest, label) {
86
224
  fail(`${label} must be a non-empty-string array`);
87
225
  }
88
226
  };
227
+ // The claim's outbound-leg declaration (ADR-0018 step 3). Refused on a
228
+ // wildcard claim: `'*'` is not a host, and a declaration that reached every
229
+ // host would let one installed package pin the egress of the whole machine —
230
+ // the exact blast radius Revision 4 was written to keep out of a claim.
231
+ const claimEgress = (value, label, hosts) => {
232
+ if (value === undefined)
233
+ return;
234
+ if (value !== 'inherit' && value !== 'proxy' && value !== 'direct') {
235
+ fail(`${label} must be 'inherit', 'proxy' or 'direct'`);
236
+ }
237
+ if (Array.isArray(hosts) && hosts.some((h) => String(h).trim() === '*')) {
238
+ fail(`${label} cannot ride a wildcard claim — it would pin the egress of every host`);
239
+ }
240
+ };
89
241
  if (m.type === undefined && m.parts === undefined) {
90
242
  fail('needs `type` (one axis) or `parts` (the axes this package occupies)');
91
243
  }
@@ -135,6 +287,10 @@ export function validatePluginManifest(manifest, label) {
135
287
  fail(`parts[${i}] is a client-gateway part and needs a non-empty hosts array`);
136
288
  }
137
289
  wildcardExclusive(part.hosts, `parts[${i}].hosts`, fail);
290
+ claimEgress(part.egress, `parts[${i}].egress`, part.hosts);
291
+ }
292
+ else if (part.egress !== undefined) {
293
+ fail(`parts[${i}].egress declares the exit of a host, and only a client-gateway part claims hosts`);
138
294
  }
139
295
  if (partType === 'client-adapter' && (part.wires !== undefined || part.hosts !== undefined)) {
140
296
  fail(`parts[${i}] is a client-adapter part — it contributes a Client Hub hook, not wires or hosts`);
@@ -152,6 +308,10 @@ export function validatePluginManifest(manifest, label) {
152
308
  fail('a client-gateway manifest needs a non-empty hosts array');
153
309
  }
154
310
  wildcardExclusive(m.hosts, 'hosts', fail);
311
+ claimEgress(m.egress, 'egress', m.hosts);
312
+ }
313
+ else if (m.egress !== undefined) {
314
+ fail('`egress` declares the exit of a host, and only a client-gateway plugin claims hosts');
155
315
  }
156
316
  }
157
317
  // Flat primitives only (ADR-0017 §7): a malformed schema fails loudly
@@ -161,6 +321,17 @@ export function validatePluginManifest(manifest, label) {
161
321
  if (m.configSections !== undefined && m.configSchema === undefined) {
162
322
  fail('configSections without configSchema groups nothing');
163
323
  }
324
+ // The leg switch is core-owned vocabulary (`GATEWAY_EGRESS_CONFIG_KEY`), and
325
+ // core INJECTS it into a gateway's schema. A package that declares the key
326
+ // itself is refused here rather than silently shadowed: two rows named
327
+ // `egress` in one drawer means the merged read can no longer say which one
328
+ // the operator touched, and the operator's word on the leg is the whole
329
+ // contract of that field.
330
+ if (hasOwnableClaim(m) &&
331
+ Array.isArray(m.configSchema) &&
332
+ m.configSchema.some((f) => f?.key === GATEWAY_EGRESS_CONFIG_KEY)) {
333
+ fail(`configSchema may not declare '${GATEWAY_EGRESS_CONFIG_KEY}' — the outbound-leg switch belongs to core`);
334
+ }
164
335
  if (m.logo !== undefined && typeof m.logo !== 'string')
165
336
  fail('logo must be a string');
166
337
  if (m.description !== undefined &&
@@ -168,6 +339,44 @@ export function validatePluginManifest(manifest, label) {
168
339
  (typeof m.description !== 'object' || m.description === null)) {
169
340
  fail('description must be a string or locale map');
170
341
  }
342
+ // Release history is presentation only, but a malformed entry is still a
343
+ // packaging bug the console would render as a blank drawer: every field is
344
+ // checked here, at the same install/load gate as the rest of the manifest.
345
+ // Duplicate versions are refused because the console keys rows by version —
346
+ // two notes for one release would silently collapse into one.
347
+ if (m.changelog !== undefined) {
348
+ if (!Array.isArray(m.changelog))
349
+ fail('changelog must be an array of release entries');
350
+ const seenVersions = new Set();
351
+ m.changelog.forEach((raw, i) => {
352
+ if (typeof raw !== 'object' || raw === null || Array.isArray(raw))
353
+ fail(`changelog[${i}] must be an object`);
354
+ const entry = raw;
355
+ if (typeof entry.version !== 'string' || !entry.version.trim()) {
356
+ fail(`changelog[${i}].version must be a non-empty string`);
357
+ }
358
+ else if (seenVersions.has(entry.version)) {
359
+ fail(`changelog declares version '${entry.version}' twice`);
360
+ }
361
+ else {
362
+ seenVersions.add(entry.version);
363
+ }
364
+ if (entry.date !== undefined && (typeof entry.date !== 'string' || !/^\d{4}-\d{2}-\d{2}$/.test(entry.date))) {
365
+ fail(`changelog[${i}].date must be a YYYY-MM-DD string`);
366
+ }
367
+ const notes = entry.notes;
368
+ // EVERY declared locale must carry text: the console picks one locale and
369
+ // renders it verbatim, so an empty value is a blank drawer for exactly the
370
+ // operator whose language the author thought was translated.
371
+ const notesPresent = typeof notes === 'string'
372
+ ? notes.trim().length > 0
373
+ : isTextOrLocaleMap(notes) &&
374
+ Object.keys(notes).length > 0 &&
375
+ Object.values(notes).every((text) => text.trim().length > 0);
376
+ if (!notesPresent)
377
+ fail(`changelog[${i}].notes must be a non-empty string or a locale map of strings`);
378
+ });
379
+ }
171
380
  if (m.warningLabels !== undefined) {
172
381
  if (typeof m.warningLabels !== 'object' || m.warningLabels === null || Array.isArray(m.warningLabels)) {
173
382
  fail('warningLabels must be an object keyed by warning code');
@@ -180,6 +389,45 @@ export function validatePluginManifest(manifest, label) {
180
389
  fail(`warningLabels['${code}'] must be a string or a locale map of strings`);
181
390
  }
182
391
  }
392
+ if (m.clientText !== undefined) {
393
+ const ct = m.clientText;
394
+ if (typeof ct !== 'object' || ct === null || Array.isArray(ct)) {
395
+ fail('clientText must be an object');
396
+ }
397
+ else {
398
+ const rec = ct;
399
+ for (const key of Object.keys(rec)) {
400
+ if (key !== 'setupOk' && key !== 'teardownOk' && key !== 'hint' && key !== 'errors' && key !== 'family') {
401
+ fail(`clientText key '${key}' is not one of setupOk, teardownOk, hint, errors, family`);
402
+ }
403
+ }
404
+ for (const simple of ['setupOk', 'teardownOk', 'hint']) {
405
+ const v = rec[simple];
406
+ if (v !== undefined && !isTextOrLocaleMap(v)) {
407
+ fail(`clientText.${simple} must be a string or a locale map of strings`);
408
+ }
409
+ }
410
+ for (const mapName of ['errors', 'family']) {
411
+ const map = rec[mapName];
412
+ if (map === undefined)
413
+ continue;
414
+ if (typeof map !== 'object' || map === null || Array.isArray(map)) {
415
+ fail(`clientText.${mapName} must be an object keyed by code`);
416
+ continue;
417
+ }
418
+ for (const [code, text] of Object.entries(map)) {
419
+ // A code is the ABI the hook returns; the console looks it up verbatim.
420
+ if (!/^[a-z][a-zA-Z0-9_]*$/.test(code))
421
+ fail(`clientText.${mapName} key '${code}' must be a lowerCamel or snake_case code`);
422
+ if (!isTextOrLocaleMap(text))
423
+ fail(`clientText.${mapName}['${code}'] must be a string or a locale map of strings`);
424
+ }
425
+ }
426
+ }
427
+ }
428
+ if (m.clientRank !== undefined && (typeof m.clientRank !== 'number' || !Number.isInteger(m.clientRank) || m.clientRank < 1)) {
429
+ fail('clientRank must be a positive integer');
430
+ }
183
431
  if (m.presets !== undefined) {
184
432
  if (!Array.isArray(m.presets))
185
433
  fail('presets must be an array');
@@ -213,6 +461,9 @@ const CONFIG_CONTROLS = {
213
461
  textarea: { string: true, 'string[]': true },
214
462
  model: { string: true },
215
463
  models: { 'string[]': true },
464
+ // A mapping table of `client=target[#label]` specs; each row maps one of the
465
+ // client's OWN model ids onto an OCR model the gateway rewrites to.
466
+ aliases: { 'string[]': true },
216
467
  // A short closed choice rendered as joined buttons instead of a dropdown --
217
468
  // the console's own mode switches (none / custom / follow) use the same shape.
218
469
  segmented: { enum: true },
@@ -3,6 +3,7 @@ import { builtinModules } from 'node:module';
3
3
  import { tmpdir } from 'node:os';
4
4
  import { basename, join } from 'node:path';
5
5
  import { zipSync } from 'fflate';
6
+ import { validatePluginManifest } from './manifest.js';
6
7
  /**
7
8
  * The ONE plugin packager: `scripts/build-plugins.ts` writes its zips with it
8
9
  * and the console's package export (`GET /api/admin/plugins/:id/package`)
@@ -44,6 +45,11 @@ const SKIPPED_DIRS = { node_modules: true, tests: true };
44
45
  * bundle is self-contained, so its dependency list would be a lie, and its
45
46
  * `type` could contradict the ESM output. */
46
47
  const PACKAGE_MANIFEST = 'package.json';
48
+ /** The plugin's OWN manifest (`plugin.json`) — the file the host validates on
49
+ * load and install. The packager ships it verbatim, so packaging is the one
50
+ * moment it can be validated BEFORE an operator is handed a package that only
51
+ * fails later. */
52
+ const PLUGIN_MANIFEST = 'plugin.json';
47
53
  const PACKAGE_MANIFEST_BODY = `${JSON.stringify({ type: 'module' }, null, 2)}\n`;
48
54
  /** Import/require spellings the bundler emits for a module it did NOT inline.
49
55
  * A wrapped import list (`import {`\n` a,`\n`} from "pkg"`) puts the specifier
@@ -212,6 +218,26 @@ export async function bundlePluginDir(dir) {
212
218
  if (external.length > 0) {
213
219
  throw new Error(`plugin bundle still references external packages (${external.join(', ')}); a compiled host cannot resolve them at runtime — import them statically (or ship the asset) so the packager can inline them`);
214
220
  }
221
+ // VALIDATE the manifest as part of packaging. `collectPluginAssets` copies
222
+ // `plugin.json` verbatim, so without this an author could mint a package
223
+ // whose `apiVersion` is a string or an impossible contract number and only
224
+ // find out when an operator installs it (ADR-0036 Amendment 1: that
225
+ // integer IS the engine declaration). Every package — the operator's
226
+ // export and `plugins:build` alike — is minted here, so this is the one
227
+ // place the promise holds.
228
+ const manifestEntry = files[PLUGIN_MANIFEST];
229
+ if (!manifestEntry)
230
+ throw new Error(`plugin source lacks ${PLUGIN_MANIFEST}`);
231
+ // A Zippable entry is `[data, options]`, never the bytes directly.
232
+ const manifestBytes = (Array.isArray(manifestEntry) ? manifestEntry[0] : manifestEntry);
233
+ let parsedManifest;
234
+ try {
235
+ parsedManifest = JSON.parse(new TextDecoder().decode(manifestBytes));
236
+ }
237
+ catch (err) {
238
+ throw new Error(`invalid ${PLUGIN_MANIFEST}: ${err instanceof Error ? err.message : String(err)}`);
239
+ }
240
+ validatePluginManifest(parsedManifest, `invalid ${PLUGIN_MANIFEST}`);
215
241
  files[PACKAGE_ENTRY] = [new TextEncoder().encode(bundleText), { mtime: ZIP_ENTRY_MTIME }];
216
242
  files[PACKAGE_MANIFEST] = [new TextEncoder().encode(PACKAGE_MANIFEST_BODY), { mtime: ZIP_ENTRY_MTIME }];
217
243
  return zipSync(files);