@pikku/core 0.12.63 → 0.12.66

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 (225) hide show
  1. package/CHANGELOG.md +368 -0
  2. package/dist/dev/hot-reload.js +13 -55
  3. package/dist/dev/module-runner.d.ts +14 -0
  4. package/dist/dev/module-runner.js +59 -0
  5. package/dist/dev/reload-meta.d.ts +13 -0
  6. package/dist/dev/reload-meta.js +22 -0
  7. package/dist/errors/errors.d.ts +12 -0
  8. package/dist/errors/errors.js +19 -0
  9. package/dist/function/function-runner.d.ts +5 -5
  10. package/dist/function/function-runner.js +39 -111
  11. package/dist/function/functions.types.d.ts +17 -7
  12. package/dist/index.d.ts +5 -1
  13. package/dist/index.js +3 -1
  14. package/dist/middleware/auth-apikey.d.ts +1 -0
  15. package/dist/middleware/auth-bearer.d.ts +1 -0
  16. package/dist/middleware/auth-cookie.d.ts +1 -0
  17. package/dist/middleware/cors.d.ts +1 -0
  18. package/dist/middleware/index.d.ts +1 -1
  19. package/dist/middleware/index.js +1 -1
  20. package/dist/middleware/remote-auth.d.ts +1 -0
  21. package/dist/middleware/telemetry.d.ts +2 -0
  22. package/dist/middleware/timeout.d.ts +1 -0
  23. package/dist/permissions.d.ts +42 -27
  24. package/dist/permissions.js +101 -203
  25. package/dist/pikku-state.js +0 -2
  26. package/dist/scopes.d.ts +17 -0
  27. package/dist/scopes.js +59 -0
  28. package/dist/services/ai-embedding-service.d.ts +31 -0
  29. package/dist/services/ai-embedding-service.js +1 -0
  30. package/dist/services/credential-wire-service.d.ts +3 -1
  31. package/dist/services/credential-wire-service.js +10 -4
  32. package/dist/services/index.d.ts +4 -0
  33. package/dist/services/index.js +2 -0
  34. package/dist/services/meta-service.d.ts +15 -2
  35. package/dist/services/meta-service.js +51 -1
  36. package/dist/services/queue-webhook-service.d.ts +55 -0
  37. package/dist/services/queue-webhook-service.js +136 -0
  38. package/dist/services/scope-service.d.ts +67 -0
  39. package/dist/services/scope-service.js +1 -0
  40. package/dist/services/typed-secret-service.d.ts +8 -0
  41. package/dist/services/typed-secret-service.js +39 -4
  42. package/dist/services/webhook-service.d.ts +140 -0
  43. package/dist/services/webhook-service.js +44 -0
  44. package/dist/services/workflow-service.d.ts +7 -0
  45. package/dist/testing/service-tests.js +37 -0
  46. package/dist/types/core.types.d.ts +34 -6
  47. package/dist/types/state.types.d.ts +20 -2
  48. package/dist/utils/hmac.d.ts +16 -0
  49. package/dist/utils/hmac.js +26 -0
  50. package/dist/utils/safe-fetch.d.ts +51 -0
  51. package/dist/utils/safe-fetch.js +192 -0
  52. package/dist/wirings/ai-agent/ai-agent-agui.d.ts +84 -0
  53. package/dist/wirings/ai-agent/ai-agent-agui.js +305 -0
  54. package/dist/wirings/ai-agent/ai-agent-prepare.d.ts +105 -1
  55. package/dist/wirings/ai-agent/ai-agent-prepare.js +249 -11
  56. package/dist/wirings/ai-agent/ai-agent-runner.js +10 -1
  57. package/dist/wirings/ai-agent/ai-agent-stream.js +88 -16
  58. package/dist/wirings/ai-agent/ai-agent.types.d.ts +56 -2
  59. package/dist/wirings/ai-agent/index.d.ts +2 -1
  60. package/dist/wirings/ai-agent/index.js +2 -1
  61. package/dist/wirings/ai-agent/voice-input.d.ts +1 -0
  62. package/dist/wirings/ai-agent/voice-input.js +5 -41
  63. package/dist/wirings/ai-agent/voice-output.d.ts +1 -0
  64. package/dist/wirings/channel/channel-common.js +0 -1
  65. package/dist/wirings/channel/channel-handler.js +1 -4
  66. package/dist/wirings/channel/channel-middleware-runner.d.ts +12 -0
  67. package/dist/wirings/channel/channel-middleware-runner.js +34 -19
  68. package/dist/wirings/channel/channel.types.d.ts +2 -6
  69. package/dist/wirings/cli/cli-runner.js +3 -2
  70. package/dist/wirings/cli/cli.types.d.ts +1 -2
  71. package/dist/wirings/cli/command-parser.d.ts +2 -0
  72. package/dist/wirings/cli/command-parser.js +59 -2
  73. package/dist/wirings/credential/credential.types.d.ts +14 -0
  74. package/dist/wirings/credential/validate-credential-definitions.js +1 -0
  75. package/dist/wirings/gateway/gateway-runner.js +100 -50
  76. package/dist/wirings/gateway/gateway.types.d.ts +8 -5
  77. package/dist/wirings/http/http-routes.js +0 -3
  78. package/dist/wirings/http/http-runner.d.ts +9 -29
  79. package/dist/wirings/http/http-runner.js +9 -34
  80. package/dist/wirings/http/http.types.d.ts +4 -12
  81. package/dist/wirings/mcp/mcp-runner.js +0 -2
  82. package/dist/wirings/mcp/mcp.types.d.ts +5 -11
  83. package/dist/wirings/oauth2/index.d.ts +0 -3
  84. package/dist/wirings/oauth2/index.js +1 -2
  85. package/dist/wirings/rpc/addon-runner.d.ts +28 -0
  86. package/dist/wirings/rpc/addon-runner.js +173 -0
  87. package/dist/wirings/rpc/index.d.ts +5 -1
  88. package/dist/wirings/rpc/index.js +3 -1
  89. package/dist/wirings/rpc/remote-addon-auth.d.ts +26 -0
  90. package/dist/wirings/rpc/remote-addon-auth.js +43 -0
  91. package/dist/wirings/rpc/rpc-runner.d.ts +19 -0
  92. package/dist/wirings/rpc/rpc-runner.js +109 -3
  93. package/dist/wirings/rpc/rpc-types.d.ts +15 -1
  94. package/dist/wirings/rpc/wire-addon.js +9 -0
  95. package/dist/wirings/rpc/wire-remote-addon.d.ts +47 -0
  96. package/dist/wirings/rpc/wire-remote-addon.js +19 -0
  97. package/dist/wirings/scope/index.d.ts +3 -0
  98. package/dist/wirings/scope/index.js +2 -0
  99. package/dist/wirings/scope/scope.types.d.ts +39 -0
  100. package/dist/wirings/scope/scope.types.js +1 -0
  101. package/dist/wirings/scope/validate-scope-definitions.d.ts +16 -0
  102. package/dist/wirings/scope/validate-scope-definitions.js +76 -0
  103. package/dist/wirings/scope/wire-scope.d.ts +33 -0
  104. package/dist/wirings/scope/wire-scope.js +32 -0
  105. package/dist/wirings/secret/secret.types.d.ts +14 -0
  106. package/dist/wirings/secret/validate-secret-definitions.js +2 -0
  107. package/dist/wirings/variable/validate-variable-definitions.js +2 -0
  108. package/dist/wirings/variable/variable.types.d.ts +14 -0
  109. package/dist/wirings/workflow/dsl/index.d.ts +1 -1
  110. package/dist/wirings/workflow/dsl/workflow-dsl.types.d.ts +89 -7
  111. package/dist/wirings/workflow/graph/graph-node.d.ts +2 -0
  112. package/dist/wirings/workflow/graph/graph-runner.js +3 -0
  113. package/dist/wirings/workflow/graph/wire-workflow-graph.d.ts +6 -0
  114. package/dist/wirings/workflow/graph/wire-workflow-graph.js +1 -0
  115. package/dist/wirings/workflow/graph/workflow-graph.types.d.ts +5 -0
  116. package/dist/wirings/workflow/index.d.ts +2 -2
  117. package/dist/wirings/workflow/index.js +1 -1
  118. package/dist/wirings/workflow/pikku-workflow-service.d.ts +59 -1
  119. package/dist/wirings/workflow/pikku-workflow-service.js +187 -0
  120. package/dist/wirings/workflow/workflow.types.d.ts +1 -3
  121. package/package.json +6 -1
  122. package/run-tests.sh +1 -0
  123. package/src/dev/hot-reload.ts +13 -68
  124. package/src/dev/module-runner.test.ts +169 -0
  125. package/src/dev/module-runner.ts +103 -0
  126. package/src/dev/reload-meta.test.ts +31 -2
  127. package/src/dev/reload-meta.ts +26 -0
  128. package/src/errors/errors.ts +24 -0
  129. package/src/function/function-runner.test.ts +276 -142
  130. package/src/function/function-runner.ts +52 -145
  131. package/src/function/functions.types.ts +28 -38
  132. package/src/index.ts +8 -6
  133. package/src/middleware/index.ts +1 -5
  134. package/src/permissions.test.ts +160 -373
  135. package/src/permissions.ts +137 -279
  136. package/src/pikku-state.ts +0 -2
  137. package/src/scopes.test.ts +167 -0
  138. package/src/scopes.ts +69 -0
  139. package/src/services/ai-embedding-service.ts +31 -0
  140. package/src/services/credential-wire-service.ts +10 -4
  141. package/src/services/index.ts +20 -0
  142. package/src/services/meta-service.ts +68 -3
  143. package/src/services/queue-webhook-service.test.ts +408 -0
  144. package/src/services/queue-webhook-service.ts +182 -0
  145. package/src/services/scope-service.ts +75 -0
  146. package/src/services/typed-secret-service.test.ts +35 -0
  147. package/src/services/typed-secret-service.ts +39 -4
  148. package/src/services/webhook-service.ts +180 -0
  149. package/src/services/workflow-service.ts +7 -0
  150. package/src/testing/service-tests.ts +49 -0
  151. package/src/types/core.types.ts +42 -14
  152. package/src/types/state.types.ts +23 -3
  153. package/src/utils/hmac.ts +27 -0
  154. package/src/utils/safe-fetch.test.ts +373 -0
  155. package/src/utils/safe-fetch.ts +213 -0
  156. package/src/wirings/ai-agent/ai-agent-agui.test.ts +1127 -0
  157. package/src/wirings/ai-agent/ai-agent-agui.ts +386 -0
  158. package/src/wirings/ai-agent/ai-agent-authorization.test.ts +204 -0
  159. package/src/wirings/ai-agent/ai-agent-prepare.test.ts +483 -0
  160. package/src/wirings/ai-agent/ai-agent-prepare.ts +324 -13
  161. package/src/wirings/ai-agent/ai-agent-resume-authorization.test.ts +207 -0
  162. package/src/wirings/ai-agent/ai-agent-runner.test.ts +48 -1
  163. package/src/wirings/ai-agent/ai-agent-runner.ts +28 -0
  164. package/src/wirings/ai-agent/ai-agent-stream.test.ts +301 -10
  165. package/src/wirings/ai-agent/ai-agent-stream.ts +122 -16
  166. package/src/wirings/ai-agent/ai-agent.types.ts +57 -0
  167. package/src/wirings/ai-agent/index.ts +5 -0
  168. package/src/wirings/ai-agent/voice-input.test.ts +90 -0
  169. package/src/wirings/ai-agent/voice-input.ts +9 -40
  170. package/src/wirings/channel/channel-common.ts +0 -1
  171. package/src/wirings/channel/channel-handler.ts +1 -9
  172. package/src/wirings/channel/channel-middleware-runner.test.ts +28 -2
  173. package/src/wirings/channel/channel-middleware-runner.ts +39 -27
  174. package/src/wirings/channel/channel.types.ts +0 -6
  175. package/src/wirings/cli/cli-runner.ts +4 -2
  176. package/src/wirings/cli/cli.types.ts +0 -2
  177. package/src/wirings/cli/command-parser.test.ts +130 -0
  178. package/src/wirings/cli/command-parser.ts +80 -2
  179. package/src/wirings/credential/credential.types.ts +14 -0
  180. package/src/wirings/credential/validate-credential-definitions.ts +1 -0
  181. package/src/wirings/gateway/gateway-authorization.test.ts +444 -0
  182. package/src/wirings/gateway/gateway-runner.ts +114 -68
  183. package/src/wirings/gateway/gateway.types.ts +7 -9
  184. package/src/wirings/http/http-routes.ts +0 -3
  185. package/src/wirings/http/http-runner.test.ts +1 -11
  186. package/src/wirings/http/http-runner.ts +16 -39
  187. package/src/wirings/http/http.types.ts +7 -14
  188. package/src/wirings/mcp/mcp-runner.ts +0 -2
  189. package/src/wirings/mcp/mcp.types.ts +3 -11
  190. package/src/wirings/oauth2/index.ts +0 -3
  191. package/src/wirings/rpc/addon-runner.ts +233 -0
  192. package/src/wirings/rpc/index.ts +17 -1
  193. package/src/wirings/rpc/remote-addon-auth.ts +69 -0
  194. package/src/wirings/rpc/rpc-runner.test.ts +319 -16
  195. package/src/wirings/rpc/rpc-runner.ts +155 -3
  196. package/src/wirings/rpc/rpc-types.ts +16 -5
  197. package/src/wirings/rpc/wire-addon.test.ts +6 -3
  198. package/src/wirings/rpc/wire-addon.ts +9 -0
  199. package/src/wirings/rpc/wire-remote-addon.ts +57 -0
  200. package/src/wirings/scope/index.ts +14 -0
  201. package/src/wirings/scope/scope.test.ts +135 -0
  202. package/src/wirings/scope/scope.types.ts +44 -0
  203. package/src/wirings/scope/validate-scope-definitions.ts +110 -0
  204. package/src/wirings/scope/wire-scope.ts +34 -0
  205. package/src/wirings/secret/secret.types.ts +14 -0
  206. package/src/wirings/secret/validate-secret-definitions.ts +2 -0
  207. package/src/wirings/variable/validate-variable-definitions.ts +2 -0
  208. package/src/wirings/variable/variable.types.ts +14 -0
  209. package/src/wirings/workflow/dsl/index.ts +4 -0
  210. package/src/wirings/workflow/dsl/workflow-dsl.types.ts +97 -6
  211. package/src/wirings/workflow/graph/graph-node.ts +2 -0
  212. package/src/wirings/workflow/graph/graph-runner.test.ts +58 -0
  213. package/src/wirings/workflow/graph/graph-runner.ts +3 -0
  214. package/src/wirings/workflow/graph/wire-workflow-graph.ts +7 -0
  215. package/src/wirings/workflow/graph/workflow-graph.types.ts +5 -0
  216. package/src/wirings/workflow/index.ts +5 -0
  217. package/src/wirings/workflow/pikku-workflow-service.test.ts +341 -0
  218. package/src/wirings/workflow/pikku-workflow-service.ts +272 -0
  219. package/src/wirings/workflow/workflow-on-error.test.ts +154 -0
  220. package/src/wirings/workflow/workflow-step-session.test.ts +21 -5
  221. package/src/wirings/workflow/workflow.types.ts +4 -2
  222. package/tsconfig.tsbuildinfo +1 -1
  223. package/src/wirings/oauth2/oauth2-client.test.ts +0 -930
  224. package/src/wirings/oauth2/oauth2-client.ts +0 -331
  225. package/src/wirings/oauth2/oauth2-routes.ts +0 -234
@@ -1,6 +1,6 @@
1
1
  import { pikkuState } from '../../pikku-state.js';
2
2
  import { NotFoundError, UnauthorizedError } from '../../errors/errors.js';
3
- import { addFunction } from '../../function/function-runner.js';
3
+ import { addFunction, runPikkuFunc } from '../../function/function-runner.js';
4
4
  import { runMiddleware } from '../../middleware-runner.js';
5
5
  import { httpRouter } from '../http/routers/http-router.js';
6
6
  /**
@@ -9,6 +9,52 @@ import { httpRouter } from '../http/routers/http-router.js';
9
9
  * requests share one construction).
10
10
  */
11
11
  const resolvedAdapters = new WeakMap();
12
+ /**
13
+ * The generated function id a gateway's handler is registered under.
14
+ */
15
+ const gatewayHandlerFuncId = (name) => `gateway__${name}__handler`;
16
+ /**
17
+ * Bridges a session established by gateway middleware onto the wire so the
18
+ * handler's gate can see it.
19
+ *
20
+ * Gateway middleware is the only place a webhook can acquire a session (e.g.
21
+ * mapping a verified platform sender to a user). Middleware that assigns
22
+ * `wire.session` needs nothing, but middleware using the idiomatic
23
+ * `wire.setSession()` writes to the enclosing wiring's session service, which
24
+ * the handler's own invocation does not read — without this the session would
25
+ * be silently invisible to `auth` and `scopes`.
26
+ */
27
+ const bridgeMiddlewareSession = async (wire) => {
28
+ if (wire.session || !wire.getSession)
29
+ return;
30
+ const session = await wire.getSession();
31
+ if (session) {
32
+ wire.session = session;
33
+ }
34
+ };
35
+ /**
36
+ * Registers a gateway's handler as a real pikku function so that invoking it
37
+ * goes through the function runner's gate. Without this the handler is called
38
+ * directly and its own `auth`, `scopes` and `permissions` are never evaluated.
39
+ *
40
+ * The handler is registered as sessionless: a gateway's inbound traffic is
41
+ * platform-authenticated (adapter signature verification), not session-bearing,
42
+ * so requiring a session by default would break every webhook. A handler that
43
+ * does need one declares `auth: true`, exactly like `pikkuSessionlessFunc`.
44
+ * `scopes` and `permissions` are always enforced when declared.
45
+ */
46
+ const registerGatewayHandler = (config) => {
47
+ const funcId = gatewayHandlerFuncId(config.name);
48
+ const funcMeta = pikkuState(null, 'function', 'meta');
49
+ funcMeta[funcId] = {
50
+ pikkuFuncId: funcId,
51
+ inputSchemaName: null,
52
+ outputSchemaName: null,
53
+ sessionless: true,
54
+ };
55
+ addFunction(funcId, config.func);
56
+ return funcId;
57
+ };
12
58
  export const resolveGatewayAdapter = (config, services) => {
13
59
  let resolved = resolvedAdapters.get(config);
14
60
  if (!resolved) {
@@ -107,12 +153,13 @@ const wireWebhookGateway = (config) => {
107
153
  * 2. Parse body via adapter → GatewayInboundMessage (or null to ignore)
108
154
  * 3. Populate `wire.gateway`
109
155
  * 4. Run user middleware (which can read `wire.gateway` for auth)
110
- * 5. Call user func with parsed message
156
+ * 5. Invoke the handler through the function runner, which enforces its
157
+ * `auth`/`scopes`/`permissions` before running it
111
158
  * 6. Auto-send response via adapter if func returns outbound content
112
159
  */
113
160
  const createWebhookPostHandler = (config) => {
114
- const { name, func: userFunc, middleware: userMiddleware } = config;
115
- const userFuncConfig = userFunc;
161
+ const { name, middleware: userMiddleware } = config;
162
+ const handlerFuncId = registerGatewayHandler(config);
116
163
  return async (services, data, wire) => {
117
164
  const adapter = await resolveGatewayAdapter(config, services);
118
165
  // Check for POST-based webhook verification (e.g. Slack url_verification)
@@ -136,23 +183,28 @@ const createWebhookPostHandler = (config) => {
136
183
  send: (msg) => adapter.send(parsed.senderId, msg),
137
184
  };
138
185
  wire.gateway = gateway;
139
- // Build combined middleware chain: gateway-level + func-level
140
- const allMiddleware = [
141
- ...(userMiddleware || []),
142
- ...(userFuncConfig.middleware || []),
143
- ];
144
- const exec = async () => {
145
- const result = await userFuncConfig.func(services, parsed, wire);
146
- // Auto-send response if the func returns outbound content
147
- if (result && (result.text || result.richContent || result.attachments)) {
148
- await adapter.send(parsed.senderId, result);
149
- }
150
- return { ok: true };
186
+ // Gateway middleware runs first and outside the gate, so it can establish
187
+ // the session the gate then checks. The handler is invoked through the
188
+ // function runner, which enforces its auth, scopes and permissions and
189
+ // applies the handler's own middleware.
190
+ const invoke = async () => {
191
+ await bridgeMiddlewareSession(wire);
192
+ return await runPikkuFunc('gateway', name, handlerFuncId, {
193
+ singletonServices: services,
194
+ data: () => parsed,
195
+ auth: config.auth,
196
+ wire: wire,
197
+ });
151
198
  };
152
- if (allMiddleware.length > 0) {
153
- return await runMiddleware(services, wire, allMiddleware, exec);
199
+ const gatewayMiddleware = userMiddleware;
200
+ const result = gatewayMiddleware?.length
201
+ ? await runMiddleware(services, wire, gatewayMiddleware, invoke)
202
+ : await invoke();
203
+ // Auto-send response if the func returns outbound content
204
+ if (result && (result.text || result.richContent || result.attachments)) {
205
+ await adapter.send(parsed.senderId, result);
154
206
  }
155
- return await exec();
207
+ return { ok: true };
156
208
  };
157
209
  };
158
210
  /**
@@ -215,8 +267,8 @@ const wireWebsocketGateway = (config) => {
215
267
  connect: { pikkuFuncId: connectFuncId },
216
268
  message: { pikkuFuncId: messageFuncId },
217
269
  };
218
- const userFuncConfig = config.func;
219
270
  const userMiddleware = config.middleware;
271
+ const handlerFuncId = registerGatewayHandler(config);
220
272
  // Register onConnect
221
273
  addFunction(connectFuncId, {
222
274
  auth: false,
@@ -249,22 +301,21 @@ const wireWebsocketGateway = (config) => {
249
301
  },
250
302
  };
251
303
  wire.gateway = gateway;
252
- const allMiddleware = [
253
- ...(userMiddleware || []),
254
- ...(userFuncConfig.middleware || []),
255
- ];
256
- const exec = async () => {
257
- const result = await userFuncConfig.func(services, parsed, wire);
258
- if (result &&
259
- (result.text || result.richContent || result.attachments)) {
260
- wire.channel?.send(result);
261
- }
304
+ const invoke = async () => {
305
+ await bridgeMiddlewareSession(wire);
306
+ return await runPikkuFunc('gateway', name, handlerFuncId, {
307
+ singletonServices: services,
308
+ data: () => parsed,
309
+ auth: config.auth,
310
+ wire: wire,
311
+ });
262
312
  };
263
- if (allMiddleware.length > 0) {
264
- await runMiddleware(services, wire, allMiddleware, exec);
265
- }
266
- else {
267
- await exec();
313
+ const gatewayMiddleware = userMiddleware;
314
+ const result = gatewayMiddleware?.length
315
+ ? await runMiddleware(services, wire, gatewayMiddleware, invoke)
316
+ : await invoke();
317
+ if (result && (result.text || result.richContent || result.attachments)) {
318
+ wire.channel?.send(result);
268
319
  }
269
320
  },
270
321
  });
@@ -300,8 +351,8 @@ const wireListenerGateway = (config) => {
300
351
  * @param singletonServices - Singleton services to pass to handler/middleware
301
352
  */
302
353
  export const createListenerMessageHandler = (name, config, singletonServices) => {
303
- const userFuncConfig = config.func;
304
354
  const userMiddleware = config.middleware;
355
+ const handlerFuncId = registerGatewayHandler(config);
305
356
  return async (rawData) => {
306
357
  const adapter = await resolveGatewayAdapter(config, singletonServices);
307
358
  const parsed = adapter.parse(rawData);
@@ -315,21 +366,20 @@ export const createListenerMessageHandler = (name, config, singletonServices) =>
315
366
  send: (msg) => adapter.send(parsed.senderId, msg),
316
367
  };
317
368
  wire.gateway = gateway;
318
- const allMiddleware = [
319
- ...(userMiddleware || []),
320
- ...(userFuncConfig.middleware || []),
321
- ];
322
- const exec = async () => {
323
- const result = await userFuncConfig.func(singletonServices, parsed, wire);
324
- if (result && (result.text || result.richContent || result.attachments)) {
325
- await adapter.send(parsed.senderId, result);
326
- }
369
+ const invoke = async () => {
370
+ await bridgeMiddlewareSession(wire);
371
+ return await runPikkuFunc('gateway', name, handlerFuncId, {
372
+ singletonServices,
373
+ data: () => parsed,
374
+ auth: config.auth,
375
+ wire,
376
+ });
327
377
  };
328
- if (allMiddleware.length > 0) {
329
- await runMiddleware(singletonServices, wire, allMiddleware, exec);
330
- }
331
- else {
332
- await exec();
378
+ const result = userMiddleware?.length
379
+ ? await runMiddleware(singletonServices, wire, userMiddleware, invoke)
380
+ : await invoke();
381
+ if (result && (result.text || result.richContent || result.attachments)) {
382
+ await adapter.send(parsed.senderId, result);
333
383
  }
334
384
  };
335
385
  };
@@ -1,5 +1,5 @@
1
1
  import type { CommonWireMeta, CorePikkuMiddleware, CorePikkuMiddlewareGroup, CoreSingletonServices } from '../../types/core.types.js';
2
- import type { CorePikkuFunctionConfig, CorePermissionGroup, CorePikkuPermission } from '../../function/functions.types.js';
2
+ import type { CorePikkuFunctionConfig } from '../../function/functions.types.js';
3
3
  import type { PikkuHTTPRequest } from '../http/http.types.js';
4
4
  /**
5
5
  * Attachment in gateway messages (images, files, etc.)
@@ -102,7 +102,7 @@ export type GatewayTransportType = 'webhook' | 'websocket' | 'listener';
102
102
  /**
103
103
  * Core gateway configuration for wireGateway()
104
104
  */
105
- export type CoreGateway<PikkuFunctionConfig = CorePikkuFunctionConfig<any, any>, PikkuPermission extends CorePikkuPermission = CorePikkuPermission, PikkuMiddleware extends CorePikkuMiddleware = CorePikkuMiddleware> = Partial<Pick<CommonWireMeta, 'title' | 'summary' | 'description' | 'errors'>> & {
105
+ export type CoreGateway<PikkuFunctionConfig = CorePikkuFunctionConfig<any, any>, PikkuMiddleware extends CorePikkuMiddleware = CorePikkuMiddleware> = Partial<Pick<CommonWireMeta, 'title' | 'summary' | 'description' | 'errors'>> & {
106
106
  /** Unique name for this gateway */
107
107
  name: string;
108
108
  /** Transport type */
@@ -117,11 +117,14 @@ export type CoreGateway<PikkuFunctionConfig = CorePikkuFunctionConfig<any, any>,
117
117
  func: PikkuFunctionConfig;
118
118
  /** Optional middleware chain (e.g., auth) */
119
119
  middleware?: CorePikkuMiddlewareGroup<any, any>;
120
- /** Optional permissions */
121
- permissions?: CorePermissionGroup | PikkuPermission[];
122
120
  /** Optional tags for categorization */
123
121
  tags?: string[];
124
- /** Whether authentication is required (default: true) */
122
+ /**
123
+ * Whether the handler requires a session. Left unset, the handler's own
124
+ * `auth` governs, and a gateway handler is sessionless by default — inbound
125
+ * gateway traffic is platform-authenticated by the adapter, not
126
+ * session-bearing. Set `true` to require a session for every message.
127
+ */
125
128
  auth?: boolean;
126
129
  };
127
130
  /**
@@ -83,7 +83,6 @@ function processRouteMap(map, parentConfig) {
83
83
  * - tags: Merges (parent + child)
84
84
  * - middleware: Merges (parent runs first)
85
85
  * - auth: Inner overrides outer
86
- * - permissions: Inner overrides outer
87
86
  */
88
87
  function mergeGroupConfig(parent, child) {
89
88
  return {
@@ -91,7 +90,6 @@ function mergeGroupConfig(parent, child) {
91
90
  tags: [...(parent.tags || []), ...(child.tags || [])],
92
91
  middleware: [...(parent.middleware || []), ...(child.middleware || [])],
93
92
  auth: child.auth ?? parent.auth,
94
- permissions: child.permissions ?? parent.permissions,
95
93
  };
96
94
  }
97
95
  /**
@@ -109,7 +107,6 @@ function registerRoute(route, groupConfig) {
109
107
  ...(groupConfig.middleware || []),
110
108
  ...(route.middleware || []),
111
109
  ],
112
- permissions: route.permissions ?? groupConfig.permissions,
113
110
  contentType: route.contentType,
114
111
  timeout: route.timeout,
115
112
  headers: route.headers,
@@ -1,5 +1,5 @@
1
1
  import type { CoreHTTPFunctionWiring, RunHTTPWiringOptions, PikkuHTTP, PikkuHTTPRequest, PikkuHTTPResponse } from './http.types.js';
2
- import type { CorePikkuFunction, CorePikkuFunctionSessionless, CorePikkuPermission, CorePermissionGroup } from '../../function/functions.types.js';
2
+ import type { CorePikkuFunction, CorePikkuFunctionSessionless, CorePikkuPermission } from '../../function/functions.types.js';
3
3
  import type { CorePikkuMiddleware, CorePikkuMiddlewareGroup } from '../../types/core.types.js';
4
4
  import { PikkuFetchHTTPResponse } from './pikku-fetch-http-response.js';
5
5
  /**
@@ -33,35 +33,15 @@ import { PikkuFetchHTTPResponse } from './pikku-fetch-http-response.js';
33
33
  */
34
34
  export declare const addHTTPMiddleware: <PikkuMiddleware extends CorePikkuMiddleware>(pattern: string, middleware: CorePikkuMiddlewareGroup, packageName?: string | null) => CorePikkuMiddlewareGroup;
35
35
  /**
36
- * Registers HTTP permissions for a specific route pattern.
37
- *
38
- * This function registers permissions at runtime that will be applied to
39
- * HTTP routes matching the specified pattern.
40
- *
41
- * For tree-shaking benefits, wrap in a factory function:
42
- * `export const x = () => addHTTPPermission('pattern', [...])`
43
- *
44
- * @template PikkuPermission The permission type.
45
- * @param {string} pattern - Route pattern (e.g., '*' for all routes, '/api/*' for specific routes).
46
- * @param {CorePermissionGroup | CorePikkuPermission[]} permissions - Permissions for this route pattern.
47
- *
48
- * @returns {CorePermissionGroup | CorePikkuPermission[]} The permissions (for chaining/wrapping).
49
- *
50
- * @example
51
- * ```typescript
52
- * // Recommended: tree-shakeable
53
- * export const httpGlobalPermissions = () => addHTTPPermission('*', [
54
- * authenticatedPermission,
55
- * rateLimitPermission
56
- * ])
57
- *
58
- * // Also works: no tree-shaking
59
- * export const apiPermissions = addHTTPPermission('/api/*', [
60
- * adminPermission
61
- * ])
62
- * ```
36
+ * @deprecated HTTP-route-level permissions were removed in #972 — permissions
37
+ * are now function-scoped only (declare them on the function via
38
+ * `pikkuFunc({ permissions })`). This throwing stub exists solely so the pinned
39
+ * bootstrap CLI (which still generates an `addHTTPPermission` wrapper) can
40
+ * resolve the import at build time; it is never called. Delete once
41
+ * `PIKKU_CLI_VERSION` in the CLI build is bumped past the release that removes
42
+ * HTTP-route permissions.
63
43
  */
64
- export declare const addHTTPPermission: <PikkuPermission extends CorePikkuPermission>(pattern: string, permissions: CorePermissionGroup | CorePikkuPermission[], packageName?: string | null) => CorePermissionGroup | CorePikkuPermission[];
44
+ export declare const addHTTPPermission: (_pattern: string, _permissions: Record<string, CorePikkuPermission | CorePikkuPermission[]> | CorePikkuPermission[]) => never;
65
45
  /**
66
46
  * Adds a new route to the global HTTP route registry.
67
47
  *
@@ -64,38 +64,16 @@ export const addHTTPMiddleware = (pattern, middleware, packageName = null) => {
64
64
  return middleware;
65
65
  };
66
66
  /**
67
- * Registers HTTP permissions for a specific route pattern.
68
- *
69
- * This function registers permissions at runtime that will be applied to
70
- * HTTP routes matching the specified pattern.
71
- *
72
- * For tree-shaking benefits, wrap in a factory function:
73
- * `export const x = () => addHTTPPermission('pattern', [...])`
74
- *
75
- * @template PikkuPermission The permission type.
76
- * @param {string} pattern - Route pattern (e.g., '*' for all routes, '/api/*' for specific routes).
77
- * @param {CorePermissionGroup | CorePikkuPermission[]} permissions - Permissions for this route pattern.
78
- *
79
- * @returns {CorePermissionGroup | CorePikkuPermission[]} The permissions (for chaining/wrapping).
80
- *
81
- * @example
82
- * ```typescript
83
- * // Recommended: tree-shakeable
84
- * export const httpGlobalPermissions = () => addHTTPPermission('*', [
85
- * authenticatedPermission,
86
- * rateLimitPermission
87
- * ])
88
- *
89
- * // Also works: no tree-shaking
90
- * export const apiPermissions = addHTTPPermission('/api/*', [
91
- * adminPermission
92
- * ])
93
- * ```
67
+ * @deprecated HTTP-route-level permissions were removed in #972 — permissions
68
+ * are now function-scoped only (declare them on the function via
69
+ * `pikkuFunc({ permissions })`). This throwing stub exists solely so the pinned
70
+ * bootstrap CLI (which still generates an `addHTTPPermission` wrapper) can
71
+ * resolve the import at build time; it is never called. Delete once
72
+ * `PIKKU_CLI_VERSION` in the CLI build is bumped past the release that removes
73
+ * HTTP-route permissions.
94
74
  */
95
- export const addHTTPPermission = (pattern, permissions, packageName = null) => {
96
- const httpGroups = pikkuState(packageName, 'permissions', 'httpGroup');
97
- httpGroups[pattern] = permissions;
98
- return permissions;
75
+ export const addHTTPPermission = (_pattern, _permissions) => {
76
+ throw new Error('addHTTPPermission was removed in #972 — HTTP-route-level permissions no longer exist. Declare permissions on the function definition instead: pikkuFunc({ permissions }).');
99
77
  };
100
78
  /**
101
79
  * Adds a new route to the global HTTP route registry.
@@ -156,7 +134,6 @@ const getMatchingRoute = (requestType, requestPath) => {
156
134
  matchedPath,
157
135
  params: matchedPath.params,
158
136
  route,
159
- permissions: route.permissions,
160
137
  meta: meta,
161
138
  };
162
139
  }
@@ -307,8 +284,6 @@ const executeRoute = async (services, matchedRoute, http, options) => {
307
284
  data,
308
285
  inheritedMiddleware: meta.middleware,
309
286
  wireMiddleware: route.middleware,
310
- inheritedPermissions: meta.permissions,
311
- wirePermissions: route.permissions,
312
287
  coerceDataFromSchema: options.coerceDataFromSchema,
313
288
  tags: route.tags,
314
289
  wire,
@@ -1,7 +1,7 @@
1
1
  import type { SerializeOptions } from 'cookie';
2
2
  import type { StandardSchemaV1 } from '@standard-schema/spec';
3
3
  import type { CorePikkuMiddleware, CommonWireMeta } from '../../types/core.types.js';
4
- import type { CorePikkuFunction, CorePikkuFunctionSessionless, CorePikkuPermission, CorePermissionGroup, CorePikkuFunctionConfig } from '../../function/functions.types.js';
4
+ import type { CorePikkuFunction, CorePikkuFunctionSessionless, CorePikkuPermission, CorePikkuFunctionConfig } from '../../function/functions.types.js';
5
5
  type ExtractHTTPWiringParams<S extends string> = S extends `${string}:${infer Param}/${infer Rest}` ? Param | ExtractHTTPWiringParams<`/${Rest}`> : S extends `${string}:${infer Param}` ? Param : never;
6
6
  export type AssertHTTPWiringParams<In, HTTPWiring extends string> = ExtractHTTPWiringParams<HTTPWiring> extends keyof In ? unknown : [
7
7
  'Error: HTTPWiring parameters',
@@ -71,11 +71,10 @@ export type PikkuQuery<T = Record<string, string | undefined>> = Record<string,
71
71
  * @template PikkuFunctionSessionless - The sessionless API function type, defaults to `CorePikkuFunctionSessionless`.
72
72
  * @template PikkuPermission - The permission function type, defaults to `CorePikkuPermission`.
73
73
  */
74
- export type CoreHTTPFunctionWiring<In, Out, R extends string, PikkuFunction extends CorePikkuFunction<In, Out, any, any, any> = CorePikkuFunction<In, Out>, PikkuFunctionSessionless extends CorePikkuFunctionSessionless<In, Out, any, any, any> = CorePikkuFunctionSessionless<In, Out>, PikkuPermission extends CorePikkuPermission<In, any, any> = CorePikkuPermission<In, any, any>, PikkuMiddleware extends CorePikkuMiddleware<any, any> = CorePikkuMiddleware<any>> = (CoreHTTPFunction & {
74
+ export type CoreHTTPFunctionWiring<In, Out, R extends string, PikkuFunction extends CorePikkuFunction<In, Out, any, any, any> = CorePikkuFunction<In, Out>, PikkuFunctionSessionless extends CorePikkuFunctionSessionless<In, Out, any, any, any> = CorePikkuFunctionSessionless<In, Out>, PikkuPermission extends CorePikkuPermission<In, any, any> = CorePikkuPermission<In, any, any>, PikkuMiddleware extends CorePikkuMiddleware<any, any> = CorePikkuMiddleware<any, any>> = (CoreHTTPFunction & {
75
75
  route: R;
76
76
  method: HTTPMethod;
77
77
  func: CorePikkuFunctionConfig<PikkuFunction, PikkuPermission, PikkuMiddleware>;
78
- permissions?: CorePermissionGroup<PikkuPermission>;
79
78
  auth?: true;
80
79
  middleware?: PikkuMiddleware[];
81
80
  sse?: undefined;
@@ -83,7 +82,6 @@ export type CoreHTTPFunctionWiring<In, Out, R extends string, PikkuFunction exte
83
82
  route: R;
84
83
  method: HTTPMethod;
85
84
  func: CorePikkuFunctionConfig<PikkuFunctionSessionless, PikkuPermission, PikkuMiddleware>;
86
- permissions?: undefined;
87
85
  auth?: false;
88
86
  middleware?: PikkuMiddleware[];
89
87
  sse?: undefined;
@@ -91,7 +89,6 @@ export type CoreHTTPFunctionWiring<In, Out, R extends string, PikkuFunction exte
91
89
  route: R;
92
90
  method: 'get';
93
91
  func: CorePikkuFunctionConfig<PikkuFunction, PikkuPermission, PikkuMiddleware>;
94
- permissions?: CorePermissionGroup<PikkuPermission>;
95
92
  auth?: true;
96
93
  middleware?: PikkuMiddleware[];
97
94
  sse?: boolean;
@@ -99,7 +96,6 @@ export type CoreHTTPFunctionWiring<In, Out, R extends string, PikkuFunction exte
99
96
  route: R;
100
97
  method: 'get';
101
98
  func: CorePikkuFunctionConfig<PikkuFunctionSessionless, PikkuPermission, PikkuMiddleware>;
102
- permissions?: undefined;
103
99
  auth?: false;
104
100
  middleware?: PikkuMiddleware[];
105
101
  sse?: boolean;
@@ -107,7 +103,6 @@ export type CoreHTTPFunctionWiring<In, Out, R extends string, PikkuFunction exte
107
103
  route: R;
108
104
  method: 'post';
109
105
  func: CorePikkuFunctionConfig<PikkuFunction, PikkuPermission, PikkuMiddleware>;
110
- permissions?: CorePermissionGroup<PikkuPermission>;
111
106
  auth?: true;
112
107
  middleware?: PikkuMiddleware[];
113
108
  query?: Array<keyof In>;
@@ -116,7 +111,6 @@ export type CoreHTTPFunctionWiring<In, Out, R extends string, PikkuFunction exte
116
111
  route: R;
117
112
  method: 'post';
118
113
  func: CorePikkuFunctionConfig<PikkuFunctionSessionless, PikkuPermission, PikkuMiddleware>;
119
- permissions?: undefined;
120
114
  auth?: false;
121
115
  middleware?: PikkuMiddleware[];
122
116
  query?: Array<keyof In>;
@@ -183,24 +177,22 @@ export interface PikkuHTTPResponse<Out = unknown> {
183
177
  /**
184
178
  * Single route configuration - supports all wireHTTP options
185
179
  */
186
- export type HTTPRouteConfig<PikkuFunction extends CorePikkuFunction<any, any, any, any, any> | CorePikkuFunctionSessionless<any, any, any, any, any> = CorePikkuFunction<any, any, any, any, any> | CorePikkuFunctionSessionless<any, any, any, any, any>, PikkuPermission extends CorePikkuPermission<any, any, any> = CorePikkuPermission<any>, PikkuMiddleware extends CorePikkuMiddleware<any, any> = CorePikkuMiddleware<any, any>> = HTTPRouteBaseConfig & {
180
+ export type HTTPRouteConfig<PikkuFunction extends CorePikkuFunction<any, any, any, any, any> | CorePikkuFunctionSessionless<any, any, any, any, any> = CorePikkuFunction<any, any, any, any, any> | CorePikkuFunctionSessionless<any, any, any, any, any>, PikkuPermission extends CorePikkuPermission<any, any, any> = CorePikkuPermission<any, any, any>, PikkuMiddleware extends CorePikkuMiddleware<any, any> = CorePikkuMiddleware<any, any>> = HTTPRouteBaseConfig & {
187
181
  method: HTTPMethod;
188
182
  route: string;
189
183
  func: CorePikkuFunctionConfig<PikkuFunction, PikkuPermission, PikkuMiddleware>;
190
184
  auth?: boolean;
191
- permissions?: CorePermissionGroup<PikkuPermission>;
192
185
  middleware?: PikkuMiddleware[];
193
186
  sse?: boolean;
194
187
  };
195
188
  /**
196
189
  * Group-level configuration applied to all routes
197
190
  */
198
- export type HTTPRoutesGroupConfig<PikkuPermission extends CorePikkuPermission<any, any, any> = CorePikkuPermission<any>, PikkuMiddleware extends CorePikkuMiddleware<any, any> = CorePikkuMiddleware<any, any>> = {
191
+ export type HTTPRoutesGroupConfig<PikkuPermission extends CorePikkuPermission<any, any, any> = CorePikkuPermission<any, any, any>, PikkuMiddleware extends CorePikkuMiddleware<any, any> = CorePikkuMiddleware<any, any>> = {
199
192
  basePath?: string;
200
193
  tags?: string[];
201
194
  auth?: boolean;
202
195
  middleware?: PikkuMiddleware[];
203
- permissions?: CorePermissionGroup<PikkuPermission>;
204
196
  };
205
197
  /**
206
198
  * Nested route map - allows hierarchical organization
@@ -134,8 +134,6 @@ async function runMCPPikkuFunc(request, type, name, mcp, pikkuFuncId, { mcp: mcp
134
134
  data: () => request.params,
135
135
  inheritedMiddleware: meta?.middleware,
136
136
  wireMiddleware: mcp?.middleware,
137
- inheritedPermissions: meta?.permissions,
138
- wirePermissions: mcp?.permissions,
139
137
  tags: mcp?.tags,
140
138
  wire,
141
139
  sessionService: mcpSessionService,
@@ -1,5 +1,5 @@
1
- import type { CorePermissionGroup, CorePikkuFunctionConfig, CorePikkuFunctionSessionless, CorePikkuPermission } from '../../function/functions.types.js';
2
- import type { CorePikkuMiddleware, MiddlewareMetadata, PermissionMetadata } from '../../types/core.types.js';
1
+ import type { CorePikkuFunctionConfig, CorePikkuFunctionSessionless, CorePikkuPermission } from '../../function/functions.types.js';
2
+ import type { CorePikkuMiddleware, MiddlewareMetadata } from '../../types/core.types.js';
3
3
  /**
4
4
  * Extract URI parameters from MCP resource URI template.
5
5
  * E.g., "user/{userId}/post/{postId}" => "userId" | "postId"
@@ -25,27 +25,25 @@ export type PikkuMCP<Tools extends string = any> = {
25
25
  /**
26
26
  * Represents metadata for MCP resources, including name, description, and documentation.
27
27
  */
28
- export type MCPResourceMeta = Record<string, Omit<CoreMCPResource, 'func' | 'middleware' | 'permissions'> & {
28
+ export type MCPResourceMeta = Record<string, Omit<CoreMCPResource, 'func' | 'middleware'> & {
29
29
  pikkuFuncId: string;
30
30
  inputSchema: string | null;
31
31
  outputSchema: string | null;
32
32
  middleware?: MiddlewareMetadata[];
33
- permissions?: PermissionMetadata[];
34
33
  }>;
35
34
  /**
36
35
  * Represents metadata for MCP tools, including name, description, and documentation.
37
36
  */
38
- export type MCPToolMeta = Record<string, Omit<CoreMCPTool, 'func' | 'middleware' | 'permissions'> & {
37
+ export type MCPToolMeta = Record<string, Omit<CoreMCPTool, 'func' | 'middleware'> & {
39
38
  pikkuFuncId: string;
40
39
  inputSchema: string | null;
41
40
  outputSchema: string | null;
42
41
  middleware?: MiddlewareMetadata[];
43
- permissions?: PermissionMetadata[];
44
42
  }>;
45
43
  /**
46
44
  * Represents metadata for MCP prompts, including name, description, and arguments.
47
45
  */
48
- export type MCPPromptMeta = Record<string, Omit<CoreMCPPrompt, 'func' | 'middleware' | 'permissions'> & {
46
+ export type MCPPromptMeta = Record<string, Omit<CoreMCPPrompt, 'func' | 'middleware'> & {
49
47
  pikkuFuncId: string;
50
48
  inputSchema: string | null;
51
49
  outputSchema: string | null;
@@ -55,7 +53,6 @@ export type MCPPromptMeta = Record<string, Omit<CoreMCPPrompt, 'func' | 'middlew
55
53
  required: boolean;
56
54
  }>;
57
55
  middleware?: MiddlewareMetadata[];
58
- permissions?: PermissionMetadata[];
59
56
  }>;
60
57
  /**
61
58
  * Represents an MCP resource with specific properties.
@@ -72,7 +69,6 @@ export type CoreMCPResource<PikkuFunctionConfig = CorePikkuFunctionConfig<CorePi
72
69
  func: PikkuFunctionConfig;
73
70
  tags?: string[];
74
71
  middleware?: PikkuMiddleware[];
75
- permissions?: CorePermissionGroup<PikkuPermission>;
76
72
  };
77
73
  /**
78
74
  * Represents an MCP tool with specific properties.
@@ -87,7 +83,6 @@ export type CoreMCPTool<PikkuFunctionConfig = CorePikkuFunctionConfig<CorePikkuF
87
83
  tags?: string[];
88
84
  streaming?: boolean;
89
85
  middleware?: PikkuMiddleware[];
90
- permissions?: CorePermissionGroup<PikkuPermission>;
91
86
  };
92
87
  /**
93
88
  * Represents an MCP prompt with specific properties.
@@ -100,7 +95,6 @@ export type CoreMCPPrompt<PikkuFunctionConfig = CorePikkuFunctionConfig<CorePikk
100
95
  func: PikkuFunctionConfig;
101
96
  tags?: string[];
102
97
  middleware?: PikkuMiddleware[];
103
- permissions?: CorePermissionGroup<PikkuPermission>;
104
98
  };
105
99
  export type JsonRpcRequest = {
106
100
  jsonrpc: string;
@@ -1,4 +1 @@
1
- export { OAuth2Client } from './oauth2-client.js';
2
- export { createOAuth2Handler } from './oauth2-routes.js';
3
- export type { CreateOAuth2HandlerOptions } from './oauth2-routes.js';
4
1
  export type { OAuth2AppCredential, OAuth2Token } from './oauth2.types.js';
@@ -1,2 +1 @@
1
- export { OAuth2Client } from './oauth2-client.js';
2
- export { createOAuth2Handler } from './oauth2-routes.js';
1
+ export {};
@@ -0,0 +1,28 @@
1
+ import type { CoreSingletonServices } from '../../types/core.types.js';
2
+ /**
3
+ * A single wired addon instance: a namespace (wireAddon `name`) plus the
4
+ * per-instance name-aliases that remap the logical names the addon reads to
5
+ * the actual project secret/variable/credential names.
6
+ */
7
+ export type AddonInstance = {
8
+ namespace: string;
9
+ secretOverrides?: Record<string, string>;
10
+ variableOverrides?: Record<string, string>;
11
+ credentialOverrides?: Record<string, string>;
12
+ };
13
+ /**
14
+ * Get or create singleton services for an addon instance.
15
+ * Services are cached in pikkuState to avoid recreation on each call.
16
+ *
17
+ * @param packageName - The addon package name
18
+ * @param parentServices - The parent/caller's singleton services (used as base)
19
+ * @param addonInstance - The wired instance whose overrides shape the services
20
+ * @returns The instance's singleton services
21
+ */
22
+ export declare const getOrCreatePackageSingletonServices: (packageName: string, parentServices: CoreSingletonServices, addonInstance?: AddonInstance) => Promise<CoreSingletonServices>;
23
+ /**
24
+ * Build the addon instance descriptor (namespace + per-instance overrides) for
25
+ * a bare intra-addon call, using the namespace currently executing on the wire.
26
+ * Returns undefined unless that namespace maps to the resolved package.
27
+ */
28
+ export declare const addonInstanceForNamespace: (namespace: string | undefined, expectedPackage: string) => AddonInstance | undefined;