@agimon-ai/po-core 0.0.0-alpha.140 → 0.0.0-alpha.141

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 (236) hide show
  1. package/dist/apiContracts.cjs +136 -46
  2. package/dist/apiContracts.cjs.map +1 -1
  3. package/dist/apiContracts.d.mts +9 -6
  4. package/dist/apiContracts.d.mts.map +1 -1
  5. package/dist/apiContracts.mjs +136 -46
  6. package/dist/apiContracts.mjs.map +1 -1
  7. package/dist/backgroundWork.cjs +2 -0
  8. package/dist/backgroundWork.d.mts +2 -2
  9. package/dist/backgroundWork.mjs +1 -1
  10. package/dist/headlessHub.cjs +32 -28
  11. package/dist/headlessHub.cjs.map +1 -1
  12. package/dist/headlessHub.d.mts +13 -13
  13. package/dist/headlessHub.d.mts.map +1 -1
  14. package/dist/headlessHub.mjs +26 -22
  15. package/dist/headlessHub.mjs.map +1 -1
  16. package/dist/headlessProtocol.cjs +25 -16
  17. package/dist/headlessProtocol.cjs.map +1 -1
  18. package/dist/headlessProtocol.d.mts.map +1 -1
  19. package/dist/headlessProtocol.mjs +25 -16
  20. package/dist/headlessProtocol.mjs.map +1 -1
  21. package/dist/headlessServer.cjs +3 -3
  22. package/dist/headlessServer.cjs.map +1 -1
  23. package/dist/headlessServer.mjs +3 -3
  24. package/dist/headlessServer.mjs.map +1 -1
  25. package/dist/index.cjs +2 -0
  26. package/dist/index.d.mts +2 -2
  27. package/dist/index.mjs +2 -2
  28. package/dist/machineApi.cjs +1 -1
  29. package/dist/machineApi.cjs.map +1 -1
  30. package/dist/machineApi.mjs +1 -1
  31. package/dist/machineApi.mjs.map +1 -1
  32. package/dist/native.cjs +29 -23
  33. package/dist/native.d.mts +6 -5
  34. package/dist/native.mjs +5 -4
  35. package/dist/pluginProtocol.cjs +15 -0
  36. package/dist/pluginProtocol.d.mts +2 -2
  37. package/dist/pluginProtocol.mjs +1 -1
  38. package/dist/remoteApi.cjs +1 -1
  39. package/dist/remoteApi.cjs.map +1 -1
  40. package/dist/remoteApi.mjs +1 -1
  41. package/dist/remoteApi.mjs.map +1 -1
  42. package/dist/serverPlugin.cjs +14 -9
  43. package/dist/serverPlugin.d.mts +4 -2
  44. package/dist/serverPlugin.mjs +3 -2
  45. package/dist/src/constants/template.cjs +6 -0
  46. package/dist/src/constants/template.cjs.map +1 -1
  47. package/dist/src/constants/template.d.mts +4 -0
  48. package/dist/src/constants/template.d.mts.map +1 -1
  49. package/dist/src/constants/template.mjs +5 -1
  50. package/dist/src/constants/template.mjs.map +1 -1
  51. package/dist/src/extensions/serverPlugin.cjs +40 -6
  52. package/dist/src/extensions/serverPlugin.cjs.map +1 -1
  53. package/dist/src/extensions/serverPlugin.d.mts +1 -1
  54. package/dist/src/extensions/serverPlugin.d.mts.map +1 -1
  55. package/dist/src/extensions/serverPlugin.mjs +37 -3
  56. package/dist/src/extensions/serverPlugin.mjs.map +1 -1
  57. package/dist/src/extensions/webPlugin.cjs.map +1 -1
  58. package/dist/src/extensions/webPlugin.d.mts +1 -1
  59. package/dist/src/extensions/webPlugin.d.mts.map +1 -1
  60. package/dist/src/extensions/webPlugin.mjs.map +1 -1
  61. package/dist/src/schemas/apiContracts.d.mts +2 -2
  62. package/dist/src/schemas/apiContracts.d.mts.map +1 -1
  63. package/dist/src/schemas/backgroundWork.cjs +10 -2
  64. package/dist/src/schemas/backgroundWork.cjs.map +1 -1
  65. package/dist/src/schemas/backgroundWork.d.mts +5 -1
  66. package/dist/src/schemas/backgroundWork.d.mts.map +1 -1
  67. package/dist/src/schemas/backgroundWork.mjs +9 -3
  68. package/dist/src/schemas/backgroundWork.mjs.map +1 -1
  69. package/dist/src/schemas/brain.cjs +1 -1
  70. package/dist/src/schemas/brain.cjs.map +1 -1
  71. package/dist/src/schemas/brain.mjs +1 -1
  72. package/dist/src/schemas/brain.mjs.map +1 -1
  73. package/dist/src/schemas/federation.cjs +20 -0
  74. package/dist/src/schemas/federation.cjs.map +1 -1
  75. package/dist/src/schemas/federation.d.mts +14 -2
  76. package/dist/src/schemas/federation.d.mts.map +1 -1
  77. package/dist/src/schemas/federation.mjs +19 -1
  78. package/dist/src/schemas/federation.mjs.map +1 -1
  79. package/dist/src/schemas/globalServices.cjs +22 -4
  80. package/dist/src/schemas/globalServices.cjs.map +1 -1
  81. package/dist/src/schemas/globalServices.d.mts +12 -2
  82. package/dist/src/schemas/globalServices.d.mts.map +1 -1
  83. package/dist/src/schemas/globalServices.mjs +19 -5
  84. package/dist/src/schemas/globalServices.mjs.map +1 -1
  85. package/dist/src/schemas/help.cjs +2 -2
  86. package/dist/src/schemas/help.cjs.map +1 -1
  87. package/dist/src/schemas/help.d.mts +2 -2
  88. package/dist/src/schemas/help.mjs +2 -2
  89. package/dist/src/schemas/help.mjs.map +1 -1
  90. package/dist/src/schemas/httpApiContracts.cjs +6 -5
  91. package/dist/src/schemas/httpApiContracts.cjs.map +1 -1
  92. package/dist/src/schemas/httpApiContracts.mjs +6 -5
  93. package/dist/src/schemas/httpApiContracts.mjs.map +1 -1
  94. package/dist/src/schemas/modelGateway.cjs +1 -1
  95. package/dist/src/schemas/modelGateway.cjs.map +1 -1
  96. package/dist/src/schemas/modelGateway.mjs +1 -1
  97. package/dist/src/schemas/modelGateway.mjs.map +1 -1
  98. package/dist/src/schemas/packageApi.cjs +3 -3
  99. package/dist/src/schemas/packageApi.cjs.map +1 -1
  100. package/dist/src/schemas/packageApi.d.mts +16 -13
  101. package/dist/src/schemas/packageApi.d.mts.map +1 -1
  102. package/dist/src/schemas/packageApi.mjs +3 -3
  103. package/dist/src/schemas/packageApi.mjs.map +1 -1
  104. package/dist/src/schemas/pluginProtocol.cjs +112 -10
  105. package/dist/src/schemas/pluginProtocol.cjs.map +1 -1
  106. package/dist/src/schemas/pluginProtocol.d.mts +64 -4
  107. package/dist/src/schemas/pluginProtocol.d.mts.map +1 -1
  108. package/dist/src/schemas/pluginProtocol.mjs +98 -11
  109. package/dist/src/schemas/pluginProtocol.mjs.map +1 -1
  110. package/dist/src/schemas/protocolHubContract.cjs +3 -3
  111. package/dist/src/schemas/protocolHubContract.cjs.map +1 -1
  112. package/dist/src/schemas/protocolHubContract.d.mts +1 -1
  113. package/dist/src/schemas/protocolHubContract.d.mts.map +1 -1
  114. package/dist/src/schemas/protocolHubContract.mjs +3 -3
  115. package/dist/src/schemas/protocolHubContract.mjs.map +1 -1
  116. package/dist/src/schemas/remoteOrigin.cjs +1 -1
  117. package/dist/src/schemas/remoteOrigin.cjs.map +1 -1
  118. package/dist/src/schemas/remoteOrigin.mjs +1 -1
  119. package/dist/src/schemas/remoteOrigin.mjs.map +1 -1
  120. package/dist/src/schemas/sandboxIdentity.cjs +1 -1
  121. package/dist/src/schemas/sandboxIdentity.cjs.map +1 -1
  122. package/dist/src/schemas/sandboxIdentity.mjs +1 -1
  123. package/dist/src/schemas/sandboxIdentity.mjs.map +1 -1
  124. package/dist/src/schemas/serverPlugin.cjs +5 -3
  125. package/dist/src/schemas/serverPlugin.cjs.map +1 -1
  126. package/dist/src/schemas/serverPlugin.d.mts +1 -1
  127. package/dist/src/schemas/serverPlugin.d.mts.map +1 -1
  128. package/dist/src/schemas/serverPlugin.mjs +5 -3
  129. package/dist/src/schemas/serverPlugin.mjs.map +1 -1
  130. package/dist/src/schemas/serverScope.cjs +4 -3
  131. package/dist/src/schemas/serverScope.cjs.map +1 -1
  132. package/dist/src/schemas/serverScope.d.mts +1 -1
  133. package/dist/src/schemas/serverScope.d.mts.map +1 -1
  134. package/dist/src/schemas/serverScope.mjs +4 -3
  135. package/dist/src/schemas/serverScope.mjs.map +1 -1
  136. package/dist/src/schemas/sessionApiContracts.cjs +1 -1
  137. package/dist/src/schemas/sessionApiContracts.cjs.map +1 -1
  138. package/dist/src/schemas/sessionApiContracts.mjs +1 -1
  139. package/dist/src/schemas/sessionApiContracts.mjs.map +1 -1
  140. package/dist/src/schemas/sharedModels.cjs +2 -2
  141. package/dist/src/schemas/sharedModels.cjs.map +1 -1
  142. package/dist/src/schemas/sharedModels.mjs +2 -2
  143. package/dist/src/schemas/sharedModels.mjs.map +1 -1
  144. package/dist/src/schemas/workspaceRegistry.cjs +1 -1
  145. package/dist/src/schemas/workspaceRegistry.cjs.map +1 -1
  146. package/dist/src/schemas/workspaceRegistry.mjs +1 -1
  147. package/dist/src/schemas/workspaceRegistry.mjs.map +1 -1
  148. package/dist/src/schemas/workspaceSandboxes.cjs +1 -1
  149. package/dist/src/schemas/workspaceSandboxes.cjs.map +1 -1
  150. package/dist/src/schemas/workspaceSandboxes.mjs +1 -1
  151. package/dist/src/schemas/workspaceSandboxes.mjs.map +1 -1
  152. package/dist/src/server/directHarnessRuntime.cjs +5 -0
  153. package/dist/src/server/directHarnessRuntime.cjs.map +1 -1
  154. package/dist/src/server/directHarnessRuntime.mjs +5 -0
  155. package/dist/src/server/directHarnessRuntime.mjs.map +1 -1
  156. package/dist/src/server/serverScope.cjs +29 -10
  157. package/dist/src/server/serverScope.cjs.map +1 -1
  158. package/dist/src/server/serverScope.d.mts +1 -0
  159. package/dist/src/server/serverScope.d.mts.map +1 -1
  160. package/dist/src/server/serverScope.mjs +24 -5
  161. package/dist/src/server/serverScope.mjs.map +1 -1
  162. package/dist/src/services/legacyScope/index.cjs +57 -0
  163. package/dist/src/services/legacyScope/index.cjs.map +1 -0
  164. package/dist/src/services/legacyScope/index.d.mts +17 -0
  165. package/dist/src/services/legacyScope/index.d.mts.map +1 -0
  166. package/dist/src/services/legacyScope/index.mjs +54 -0
  167. package/dist/src/services/legacyScope/index.mjs.map +1 -0
  168. package/dist/src/services/legacyScope/type.d.mts +5 -0
  169. package/dist/src/services/legacyScope/type.d.mts.map +1 -0
  170. package/dist/src/services/modelGatewayContainer/index.cjs +6 -6
  171. package/dist/src/services/modelGatewayContainer/index.cjs.map +1 -1
  172. package/dist/src/services/modelGatewayContainer/index.mjs +6 -6
  173. package/dist/src/services/modelGatewayContainer/index.mjs.map +1 -1
  174. package/dist/src/services/modelGatewayHost/index.cjs +4 -3
  175. package/dist/src/services/modelGatewayHost/index.cjs.map +1 -1
  176. package/dist/src/services/modelGatewayHost/index.d.mts.map +1 -1
  177. package/dist/src/services/modelGatewayHost/index.mjs +4 -3
  178. package/dist/src/services/modelGatewayHost/index.mjs.map +1 -1
  179. package/dist/src/services/packageApiHarness/index.cjs +1 -1
  180. package/dist/src/services/packageApiHarness/index.cjs.map +1 -1
  181. package/dist/src/services/packageApiHarness/index.mjs +1 -1
  182. package/dist/src/services/packageApiHarness/index.mjs.map +1 -1
  183. package/dist/src/services/serverHost/index.cjs +3 -3
  184. package/dist/src/services/serverHost/index.cjs.map +1 -1
  185. package/dist/src/services/serverHost/index.d.mts +1 -1
  186. package/dist/src/services/serverHost/index.mjs +3 -3
  187. package/dist/src/services/serverHost/index.mjs.map +1 -1
  188. package/dist/src/systems/main/adapters/headlessSessionHost.cjs +1 -1
  189. package/dist/src/systems/main/adapters/headlessSessionHost.cjs.map +1 -1
  190. package/dist/src/systems/main/adapters/headlessSessionHost.d.mts.map +1 -1
  191. package/dist/src/systems/main/adapters/headlessSessionHost.mjs +2 -2
  192. package/dist/src/systems/main/adapters/headlessSessionHost.mjs.map +1 -1
  193. package/dist/src/web/hostSlots.cjs +21 -21
  194. package/dist/src/web/hostSlots.cjs.map +1 -1
  195. package/dist/src/web/hostSlots.d.mts +21 -21
  196. package/dist/src/web/hostSlots.d.mts.map +1 -1
  197. package/dist/src/web/hostSlots.mjs +21 -21
  198. package/dist/src/web/hostSlots.mjs.map +1 -1
  199. package/dist/src/web/models/globalStore.cjs +4 -1
  200. package/dist/src/web/models/globalStore.cjs.map +1 -1
  201. package/dist/src/web/models/globalStore.d.mts +3 -1
  202. package/dist/src/web/models/globalStore.d.mts.map +1 -1
  203. package/dist/src/web/models/globalStore.mjs +4 -2
  204. package/dist/src/web/models/globalStore.mjs.map +1 -1
  205. package/dist/src/web/services/apiClient/index.cjs +1 -1
  206. package/dist/src/web/services/apiClient/index.cjs.map +1 -1
  207. package/dist/src/web/services/apiClient/index.d.mts +1 -1
  208. package/dist/src/web/services/apiClient/index.d.mts.map +1 -1
  209. package/dist/src/web/services/apiClient/index.mjs +1 -1
  210. package/dist/src/web/services/apiClient/index.mjs.map +1 -1
  211. package/dist/src/web/services/apiPaths/index.cjs +1 -1
  212. package/dist/src/web/services/apiPaths/index.cjs.map +1 -1
  213. package/dist/src/web/services/apiPaths/index.d.mts +1 -1
  214. package/dist/src/web/services/apiPaths/index.mjs +1 -1
  215. package/dist/src/web/services/apiPaths/index.mjs.map +1 -1
  216. package/dist/src/web/services/apiRoutes/index.cjs +1 -1
  217. package/dist/src/web/services/apiRoutes/index.cjs.map +1 -1
  218. package/dist/src/web/services/apiRoutes/index.mjs +1 -1
  219. package/dist/src/web/services/apiRoutes/index.mjs.map +1 -1
  220. package/dist/src/web/services/hubRevisions/index.cjs +13 -7
  221. package/dist/src/web/services/hubRevisions/index.cjs.map +1 -1
  222. package/dist/src/web/services/hubRevisions/index.d.mts +3 -1
  223. package/dist/src/web/services/hubRevisions/index.d.mts.map +1 -1
  224. package/dist/src/web/services/hubRevisions/index.mjs +13 -8
  225. package/dist/src/web/services/hubRevisions/index.mjs.map +1 -1
  226. package/dist/src/web/types/extensionFile.d.mts +1 -1
  227. package/dist/src/web/types/webPlugin.d.mts +9 -9
  228. package/dist/src/web/types/webPlugin.d.mts.map +1 -1
  229. package/dist/web.cjs +42 -36
  230. package/dist/web.d.mts +9 -8
  231. package/dist/web.mjs +5 -4
  232. package/dist/webCompositions.cjs +1 -1
  233. package/dist/webCompositions.cjs.map +1 -1
  234. package/dist/webCompositions.mjs +1 -1
  235. package/dist/webCompositions.mjs.map +1 -1
  236. package/package.json +4 -4
@@ -1,12 +1,35 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  let typebox = require("typebox");
3
3
  let typebox_value = require("typebox/value");
4
+ //#region src/services/legacyScope/index.ts
5
+ const warned = /* @__PURE__ */ new Set();
6
+ const MESSAGES = {
7
+ manifest: "a poServer manifest lists scope 'global'",
8
+ definition: "a server, web or native plugin definition declares a 'global' level or contract",
9
+ mount: "a plugin call addresses mount { scope: 'global' }",
10
+ revision: "a revision key starts with 'global:'",
11
+ federation: "a federation operation names scope 'global'",
12
+ contract: "an API contract names scope 'global'"
13
+ };
14
+ /** Warns once per alias kind that a retired `global` scope was read as `host`. */
15
+ function warnLegacyScope(alias) {
16
+ if (warned.has(alias)) return;
17
+ warned.add(alias);
18
+ console.warn(`[po] Deprecated: ${MESSAGES[alias]}. Scope 'global' was renamed to 'host'; run po sync.`);
19
+ }
20
+ /** `host` for the retired `global`, warning once for `alias`; any other value is returned unchanged. */
21
+ function normalizeLegacyScope(value, alias) {
22
+ if (value !== "global") return value;
23
+ warnLegacyScope(alias);
24
+ return "host";
25
+ }
26
+ //#endregion
4
27
  //#region src/schemas/apiContracts.ts
5
28
  const PO_API_CONTRACT_VERSION = 1;
6
29
  const PO_API_CONTRACT_FILE = "contracts.json";
7
30
  const Schema = typebox.Type.Unsafe(typebox.Type.Union([typebox.Type.Boolean(), typebox.Type.Record(typebox.Type.String(), typebox.Type.Unknown())]));
8
31
  const Scope = typebox.Type.Union([
9
- typebox.Type.Literal("global"),
32
+ typebox.Type.Literal("host"),
10
33
  typebox.Type.Literal("workspace"),
11
34
  typebox.Type.Literal("session")
12
35
  ]);
@@ -86,9 +109,32 @@ const PoApiContractSchema = typebox.Type.Object({
86
109
  function defineApiContract(contract) {
87
110
  return contract;
88
111
  }
112
+ /** Each `{ scope }` entry of `list` with the retired `global` read as `host`, warning once; anything else as is. */
113
+ function hostScoped(list) {
114
+ if (!Array.isArray(list)) return list;
115
+ return list.map((entry) => {
116
+ if (typeof entry !== "object" || entry === null || !("scope" in entry)) return entry;
117
+ const scope = normalizeLegacyScope(entry.scope, "contract");
118
+ return scope === entry.scope ? entry : {
119
+ ...entry,
120
+ scope
121
+ };
122
+ });
123
+ }
124
+ /** A contract built before the rename, with its operations' `global` scope read as `host`. */
125
+ function withHostContract(value) {
126
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return value;
127
+ const record = value;
128
+ return {
129
+ ...value,
130
+ http: hostScoped(record.http),
131
+ sockets: hostScoped(record.sockets)
132
+ };
133
+ }
89
134
  function parseApiContract(value) {
90
- if (!(0, typebox_value.Check)(PoApiContractSchema, value)) throw new Error("Invalid Po API contract");
91
- const contract = value;
135
+ const normalized = withHostContract(value);
136
+ if (!(0, typebox_value.Check)(PoApiContractSchema, normalized)) throw new Error("Invalid Po API contract");
137
+ const contract = normalized;
92
138
  const ids = /* @__PURE__ */ new Set();
93
139
  for (const entry of [...contract.http, ...contract.sockets]) {
94
140
  const key = `${entry.scope}:${entry.id}`;
@@ -125,8 +171,9 @@ function parseCompiledContracts(value) {
125
171
  fingerprint: typebox.Type.String({ pattern: "^[a-f0-9]{64}$" }),
126
172
  packages: typebox.Type.Array(PackageSchema)
127
173
  });
128
- if (!(0, typebox_value.Check)(CompiledSchema, value)) throw new Error("Invalid compiled API contracts");
129
- const data = value;
174
+ const normalized = withHostCompiled(value);
175
+ if (!(0, typebox_value.Check)(CompiledSchema, normalized)) throw new Error("Invalid compiled API contracts");
176
+ const data = normalized;
130
177
  const names = /* @__PURE__ */ new Set();
131
178
  for (const entry of data.packages) {
132
179
  if (names.has(entry.packageName) || entry.module?.split("/").includes("..")) throw new Error("Invalid compiled package contract");
@@ -135,6 +182,23 @@ function parseCompiledContracts(value) {
135
182
  }
136
183
  return data;
137
184
  }
185
+ /** Compiled contracts written before the rename, with `global` package scopes and contract scopes read as `host`. */
186
+ function withHostCompiled(value) {
187
+ if (typeof value !== "object" || value === null || !Array.isArray(value.packages)) return value;
188
+ const packages = value.packages.map((entry) => {
189
+ if (typeof entry !== "object" || entry === null) return entry;
190
+ const record = entry;
191
+ return {
192
+ ...entry,
193
+ ...Array.isArray(record.scopes) ? { scopes: record.scopes.map((scope) => normalizeLegacyScope(scope, "contract")) } : {},
194
+ ...record.contract === void 0 ? {} : { contract: withHostContract(record.contract) }
195
+ };
196
+ });
197
+ return {
198
+ ...value,
199
+ packages
200
+ };
201
+ }
138
202
  //#endregion
139
203
  //#region src/services/apiContracts/index.ts
140
204
  /** Stable bytes for diffs and hashes, independent of object insertion order. */
@@ -147,7 +211,7 @@ function canonicalContractJson(value) {
147
211
  return `${JSON.stringify(ordered(value), null, 2)}\n`;
148
212
  }
149
213
  const componentName = (value) => value.replace(/[^a-zA-Z0-9.-]/gu, (character) => `_${character.codePointAt(0).toString(16)}_`);
150
- const pluginPrefix = (scope) => scope === "global" ? "/api/plugins" : scope === "workspace" ? "/api/workspaces/{workspaceId}/plugins" : "/api/workspaces/{workspaceId}/sessions/{sessionId}/plugins";
214
+ const pluginPrefix = (scope) => scope === "host" ? "/api/plugins" : scope === "workspace" ? "/api/workspaces/{workspaceId}/plugins" : "/api/workspaces/{workspaceId}/sessions/{sessionId}/plugins";
151
215
  /** Compose declarations only. No handlers, lifecycle hooks, or platform resources are loaded. */
152
216
  function createApiDocuments(selections) {
153
217
  const paths = {};
@@ -155,7 +219,7 @@ function createApiDocuments(selections) {
155
219
  const messages = {};
156
220
  const operations = {};
157
221
  const channelMessages = {
158
- global: {},
222
+ host: {},
159
223
  workspace: {},
160
224
  session: {}
161
225
  };
@@ -224,7 +288,7 @@ function createApiDocuments(selections) {
224
288
  manifest.dynamic.push(...contract.dynamic.map((value) => `${entry.packageName}: ${value}`));
225
289
  for (const route of contract.http.filter((route) => route.scope === selected.scope)) {
226
290
  const id = `${entry.packageName}.${route.scope}.${route.id}`;
227
- const pathname = `${route.basePath === void 0 ? "" : route.basePath === "settings" ? `${route.scope === "global" ? "/api" : "/api/workspaces/{workspaceId}"}/settings` : `${pluginPrefix(route.scope)}/${route.basePath}`}${route.path === "/" ? "" : route.path}`;
291
+ const pathname = `${route.basePath === void 0 ? "" : route.basePath === "settings" ? `${route.scope === "host" ? "/api" : "/api/workspaces/{workspaceId}"}/settings` : `${pluginPrefix(route.scope)}/${route.basePath}`}${route.path === "/" ? "" : route.path}`;
228
292
  const method = route.method.toLowerCase();
229
293
  const path = paths[pathname] ??= {};
230
294
  if (path[method]) throw new Error(`Conflicting HTTP contract: ${route.method} ${pathname}`);
@@ -266,7 +330,7 @@ function createApiDocuments(selections) {
266
330
  const address = `${socket.scope}:${socket.direction}:${socket.kind}:${socket.service}:${socket.member}`;
267
331
  if (socketAddresses.has(address)) throw new Error(`Conflicting socket contract: ${address}`);
268
332
  socketAddresses.add(address);
269
- for (const channel of socket.scope === "global" ? ["global"] : [socket.scope, "global"]) {
333
+ for (const channel of socket.scope === "host" ? ["host"] : [socket.scope, "host"]) {
270
334
  const id = componentName(`${entry.packageName}.${socket.scope}.${socket.id}${channel === socket.scope ? "" : ".aggregate"}`);
271
335
  const addMessage = (suffix, payload) => {
272
336
  const name = `${id}.${suffix}`;
@@ -333,13 +397,13 @@ function createApiDocuments(selections) {
333
397
  asyncapi: "3.0.0",
334
398
  info,
335
399
  channels: Object.fromEntries(Object.entries(channelMessages).map(([scope, messages]) => [scope, {
336
- address: scope === "global" ? "/api/ws" : scope === "workspace" ? "/api/workspaces/{workspaceId}/ws" : "/api/workspaces/{workspaceId}/sessions/{sessionId}/ws",
337
- ...scope === "global" ? {} : { parameters: {
400
+ address: scope === "host" ? "/api/ws" : scope === "workspace" ? "/api/workspaces/{workspaceId}/ws" : "/api/workspaces/{workspaceId}/sessions/{sessionId}/ws",
401
+ ...scope === "host" ? {} : { parameters: {
338
402
  workspaceId: { description: "Admitted workspace identity." },
339
403
  ...scope === "session" ? { sessionId: { description: "Session owned by this workspace." } } : {}
340
404
  } },
341
405
  messages,
342
- description: "Decoded Pi/Chord values over framed CBOR. The global hub socket aggregates all scopes; workspace and session sockets restrict session access and package calls to their addressed scope. Remote paired-device sockets seal the same bytes."
406
+ description: "Decoded Pi/Chord values over framed CBOR. The host hub socket aggregates all scopes; workspace and session sockets restrict session access and package calls to their addressed scope. Remote paired-device sockets seal the same bytes."
343
407
  }])),
344
408
  operations,
345
409
  components: {
@@ -425,6 +489,52 @@ const API_BASE_PATH = "context";
425
489
  const ITEM_ROUTE = "/item";
426
490
  const CURRENT_ROUTE = "/current";
427
491
  //#endregion
492
+ //#region src/schemas/pluginProtocol.ts
493
+ const PoPluginHostMountSchema = typebox.Type.Union([
494
+ typebox.Type.Object({ scope: typebox.Type.Literal("host") }, { additionalProperties: false }),
495
+ typebox.Type.Object({
496
+ scope: typebox.Type.Literal("workspace"),
497
+ workspaceId: typebox.Type.String({ minLength: 1 })
498
+ }, { additionalProperties: false }),
499
+ typebox.Type.Object({
500
+ scope: typebox.Type.Literal("session"),
501
+ sessionId: typebox.Type.String({ minLength: 1 })
502
+ }, { additionalProperties: false })
503
+ ]);
504
+ /**
505
+ * The address is always exact. A workspace call never resolves to a host service.
506
+ * The wire still admits the retired `{ scope: 'global' }` from older clients; read it with
507
+ * `normalizePoPluginMount`. The static type names `host` only.
508
+ */
509
+ const PoPluginMountSchema = typebox.Type.Unsafe(typebox.Type.Union([...PoPluginHostMountSchema.anyOf, typebox.Type.Object({ scope: typebox.Type.Literal("global") }, { additionalProperties: false })]));
510
+ typebox.Type.Object({
511
+ mount: PoPluginMountSchema,
512
+ service: typebox.Type.String({ minLength: 1 }),
513
+ method: typebox.Type.String({ minLength: 1 }),
514
+ input: typebox.Type.Unknown()
515
+ }, { additionalProperties: false });
516
+ /** The host scope as the po.hub@1 wire spells it. */
517
+ const PO_WIRE_HOST_SCOPE = "global";
518
+ /** The mount as the po.hub@1 wire carries it. Byte-identical to the pre-rename schema. */
519
+ const PoPluginWireMountSchema = typebox.Type.Union([
520
+ typebox.Type.Object({ scope: typebox.Type.Literal(PO_WIRE_HOST_SCOPE) }, { additionalProperties: false }),
521
+ typebox.Type.Object({
522
+ scope: typebox.Type.Literal("workspace"),
523
+ workspaceId: typebox.Type.String({ minLength: 1 })
524
+ }, { additionalProperties: false }),
525
+ typebox.Type.Object({
526
+ scope: typebox.Type.Literal("session"),
527
+ sessionId: typebox.Type.String({ minLength: 1 })
528
+ }, { additionalProperties: false })
529
+ ]);
530
+ /** A plugin call as the po.hub@1 wire carries it. Byte-identical to the pre-rename schema. */
531
+ const PoPluginWireCallSchema = typebox.Type.Object({
532
+ mount: PoPluginWireMountSchema,
533
+ service: typebox.Type.String({ minLength: 1 }),
534
+ method: typebox.Type.String({ minLength: 1 }),
535
+ input: typebox.Type.Unknown()
536
+ }, { additionalProperties: false });
537
+ //#endregion
428
538
  //#region src/schemas/httpApiContracts.ts
429
539
  const Text$3 = typebox.Type.String();
430
540
  const Optional$2 = typebox.Type.Optional;
@@ -486,7 +596,7 @@ function jsonApiResponses(schema, status = 200) {
486
596
  const WebCompositionSchema = typebox.Type.Object({
487
597
  id: Text$3,
488
598
  scope: typebox.Type.Union([
489
- typebox.Type.Literal("global"),
599
+ typebox.Type.Literal(PO_WIRE_HOST_SCOPE),
490
600
  typebox.Type.Literal("workspace"),
491
601
  typebox.Type.Literal("session")
492
602
  ]),
@@ -502,7 +612,7 @@ const WebCompositionSchema = typebox.Type.Object({
502
612
  const NativeCompositionSchema = typebox.Type.Object({
503
613
  id: Text$3,
504
614
  scope: typebox.Type.Union([
505
- typebox.Type.Literal("global"),
615
+ typebox.Type.Literal(PO_WIRE_HOST_SCOPE),
506
616
  typebox.Type.Literal("workspace"),
507
617
  typebox.Type.Literal("session")
508
618
  ]),
@@ -517,7 +627,7 @@ const NativeCompositionSchema = typebox.Type.Object({
517
627
  /** A configured template id and the mount whose compositions offer it. */
518
628
  const TemplateDecisionSchema = typebox.Type.Object({
519
629
  id: Optional$2(Text$3),
520
- mount: typebox.Type.Union([typebox.Type.Object({ scope: typebox.Type.Literal("global") }), typebox.Type.Object({
630
+ mount: typebox.Type.Union([typebox.Type.Object({ scope: typebox.Type.Literal(PO_WIRE_HOST_SCOPE) }), typebox.Type.Object({
521
631
  scope: typebox.Type.Literal("workspace"),
522
632
  workspaceId: Text$3
523
633
  })])
@@ -627,7 +737,7 @@ const host = (id, path, method, result, extra = {}) => ({
627
737
  id,
628
738
  path,
629
739
  method,
630
- scope: "global",
740
+ scope: "host",
631
741
  authentication: "owner",
632
742
  description: id,
633
743
  responses: jsonApiResponses(result),
@@ -736,7 +846,7 @@ const headlessHttpContracts = [
736
846
  version: Text$3,
737
847
  operations: typebox.Type.Array(typebox.Type.Object({
738
848
  scope: typebox.Type.Union([
739
- typebox.Type.Literal("global"),
849
+ typebox.Type.Literal(PO_WIRE_HOST_SCOPE),
740
850
  typebox.Type.Literal("workspace"),
741
851
  typebox.Type.Literal("session")
742
852
  ]),
@@ -1251,7 +1361,7 @@ const route = (id, path, method, result, input, extra = {}) => ({
1251
1361
  id: `remote.${id}`,
1252
1362
  path: `/api/remote${path}`,
1253
1363
  method,
1254
- scope: "global",
1364
+ scope: "host",
1255
1365
  authentication: "owner",
1256
1366
  description: `Remote Control ${id}.`,
1257
1367
  availability: "Global host provides Remote Control. Tunnel routes additionally enforce device, origin and step-up policy.",
@@ -1418,7 +1528,7 @@ const remoteHttpContracts = [
1418
1528
  })),
1419
1529
  {
1420
1530
  id: "remote.pair.page",
1421
- scope: "global",
1531
+ scope: "host",
1422
1532
  path: "/pair",
1423
1533
  method: "GET",
1424
1534
  authentication: "none",
@@ -1449,7 +1559,7 @@ const Signed = typebox.Type.Object({
1449
1559
  });
1450
1560
  const bundleHttpContracts = [...["/bundle-manifest.json", "/api/web-plugins/{id}/{revision}/manifest"].flatMap((path) => ["GET", "HEAD"].map((method) => ({
1451
1561
  id: `bundle.${path}.${method}`,
1452
- scope: "global",
1562
+ scope: "host",
1453
1563
  path,
1454
1564
  method,
1455
1565
  authentication: "owner",
@@ -1461,7 +1571,7 @@ const bundleHttpContracts = [...["/bundle-manifest.json", "/api/web-plugins/{id}
1461
1571
  } : jsonApiResponses(Signed)
1462
1572
  }))), ...["/bundle-assets/{revision}/{assetPath}", "/api/web-plugins/{id}/{revision}/assets/{assetPath}"].flatMap((path) => ["GET", "HEAD"].map((method) => ({
1463
1573
  id: `asset.${path}.${method}`,
1464
- scope: "global",
1574
+ scope: "host",
1465
1575
  path,
1466
1576
  method,
1467
1577
  authentication: "owner",
@@ -1489,26 +1599,6 @@ const ChannelFrameSchema = typebox.Type.Object({
1489
1599
  const PoChannelsStateSchema = typebox.Type.Record(typebox.Type.String(), Json$3);
1490
1600
  typebox.Type.String({ minLength: 1 });
1491
1601
  //#endregion
1492
- //#region src/schemas/pluginProtocol.ts
1493
- /** The address is always exact. A workspace call never resolves to a global service. */
1494
- const PoPluginMountSchema = typebox.Type.Union([
1495
- typebox.Type.Object({ scope: typebox.Type.Literal("global") }, { additionalProperties: false }),
1496
- typebox.Type.Object({
1497
- scope: typebox.Type.Literal("workspace"),
1498
- workspaceId: typebox.Type.String({ minLength: 1 })
1499
- }, { additionalProperties: false }),
1500
- typebox.Type.Object({
1501
- scope: typebox.Type.Literal("session"),
1502
- sessionId: typebox.Type.String({ minLength: 1 })
1503
- }, { additionalProperties: false })
1504
- ]);
1505
- const PoPluginCallSchema = typebox.Type.Object({
1506
- mount: PoPluginMountSchema,
1507
- service: typebox.Type.String({ minLength: 1 }),
1508
- method: typebox.Type.String({ minLength: 1 }),
1509
- input: typebox.Type.Unknown()
1510
- }, { additionalProperties: false });
1511
- //#endregion
1512
1602
  //#region src/schemas/protocolHubContract.ts
1513
1603
  const Text$1 = typebox.Type.String();
1514
1604
  const Json$2 = typebox.Type.Unsafe({});
@@ -1829,7 +1919,7 @@ const ErrorSchema = typebox.Type.Object({
1829
1919
  });
1830
1920
  const documented = (id, service, member, direction, input, description) => ({
1831
1921
  id,
1832
- scope: service === "po.hub" ? "global" : "session",
1922
+ scope: service === "po.hub" ? "host" : "session",
1833
1923
  service,
1834
1924
  member,
1835
1925
  direction,
@@ -1874,7 +1964,7 @@ const ProtocolMessage = typebox.Type.Array(typebox.Type.Unknown(), { description
1874
1964
  const transportSocketContracts = [
1875
1965
  {
1876
1966
  id: "chord.client",
1877
- scope: "global",
1967
+ scope: "host",
1878
1968
  service: "$chord",
1879
1969
  member: "client",
1880
1970
  direction: "client-to-server",
@@ -1884,7 +1974,7 @@ const transportSocketContracts = [
1884
1974
  },
1885
1975
  {
1886
1976
  id: "chord.server",
1887
- scope: "global",
1977
+ scope: "host",
1888
1978
  service: "$chord",
1889
1979
  member: "server",
1890
1980
  direction: "server-to-client",
@@ -1894,12 +1984,12 @@ const transportSocketContracts = [
1894
1984
  },
1895
1985
  {
1896
1986
  id: "plugin.invoke",
1897
- scope: "global",
1987
+ scope: "host",
1898
1988
  service: "po.hub",
1899
1989
  member: "invoke",
1900
1990
  direction: "client-to-server",
1901
1991
  kind: "method",
1902
- input: PoPluginCallSchema,
1992
+ input: PoPluginWireCallSchema,
1903
1993
  output: Json,
1904
1994
  errors: WireError,
1905
1995
  description: "Invoke the selected scoped plugin method. Its declaration supplies input and output shapes."