@pikku/addon-ollama 0.1.0 → 0.1.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 (177) hide show
  1. package/.pikku/addon/pikku-addon-types.gen.ts +31 -4
  2. package/.pikku/addon/pikku-package.gen.ts +3 -1
  3. package/.pikku/agent/pikku-agent-map.gen.d.ts +2 -14
  4. package/.pikku/agent/pikku-agent-types.gen.ts +13 -7
  5. package/.pikku/channel/pikku-channel-types.gen.ts +177 -0
  6. package/.pikku/console/pikku-addon-meta.gen.json +58 -0
  7. package/.pikku/console/pikku-node-types.gen.ts +1 -1
  8. package/.pikku/function/pikku-function-types.gen.ts +209 -103
  9. package/.pikku/function/pikku-functions-meta-verbose.gen.json +56 -44
  10. package/.pikku/function/pikku-functions-meta.gen.json +42 -38
  11. package/.pikku/function/pikku-functions-meta.gen.ts +1 -1
  12. package/.pikku/function/pikku-functions.gen.ts +2 -2
  13. package/.pikku/http/pikku-http-types.gen.ts +147 -0
  14. package/.pikku/mcp/pikku-mcp-types.gen.ts +183 -0
  15. package/.pikku/pikku-bootstrap.gen.ts +2 -9
  16. package/.pikku/pikku-meta-service.gen.ts +10 -0
  17. package/.pikku/pikku-services.gen.ts +14 -2
  18. package/.pikku/pikku-types.gen.ts +1 -1
  19. package/.pikku/queue/pikku-queue-types.gen.ts +27 -0
  20. package/.pikku/rpc/pikku-rpc-wirings-map.gen.d.ts +81 -62
  21. package/.pikku/rpc/pikku-rpc-wirings-map.internal.gen.d.ts +84 -65
  22. package/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.json +6 -0
  23. package/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.ts +6 -0
  24. package/.pikku/scheduler/pikku-scheduler-types.gen.ts +25 -0
  25. package/.pikku/schemas/register.gen.ts +17 -17
  26. package/.pikku/secrets/pikku-secret-types.gen.ts +1 -1
  27. package/.pikku/secrets/pikku-secrets.gen.ts +1 -1
  28. package/.pikku/trigger/pikku-trigger-types.gen.ts +1 -1
  29. package/.pikku/variables/pikku-variable-types.gen.ts +1 -1
  30. package/.pikku/variables/pikku-variables-meta.gen.json +1 -1
  31. package/.pikku/variables/pikku-variables.gen.ts +1 -1
  32. package/.pikku/workflow/pikku-workflow-map.gen.d.ts +9 -5
  33. package/.pikku/workflow/pikku-workflow-types.gen.ts +66 -57
  34. package/.pikku/workflow/pikku-workflow-wirings-meta.gen.ts +1 -1
  35. package/.pikku/workflow/pikku-workflow-wirings.gen.ts +1 -1
  36. package/dist/.pikku/addon/pikku-addon-types.gen.d.ts +19 -3
  37. package/dist/.pikku/addon/pikku-addon-types.gen.d.ts.map +1 -1
  38. package/dist/.pikku/addon/pikku-addon-types.gen.js +26 -3
  39. package/dist/.pikku/addon/pikku-addon-types.gen.js.map +1 -1
  40. package/dist/.pikku/addon/pikku-addon-types.gen.ts +31 -4
  41. package/dist/.pikku/addon/pikku-package.gen.js +2 -1
  42. package/dist/.pikku/addon/pikku-package.gen.js.map +1 -1
  43. package/dist/.pikku/addon/pikku-package.gen.ts +3 -1
  44. package/dist/.pikku/agent/pikku-agent-map.gen.d.ts +2 -14
  45. package/dist/.pikku/agent/pikku-agent-types.gen.d.ts +6 -6
  46. package/dist/.pikku/agent/pikku-agent-types.gen.d.ts.map +1 -1
  47. package/dist/.pikku/agent/pikku-agent-types.gen.js.map +1 -1
  48. package/dist/.pikku/agent/pikku-agent-types.gen.ts +13 -7
  49. package/dist/.pikku/channel/pikku-channel-types.gen.d.ts +112 -0
  50. package/dist/.pikku/channel/pikku-channel-types.gen.d.ts.map +1 -0
  51. package/dist/.pikku/channel/pikku-channel-types.gen.js +60 -0
  52. package/dist/.pikku/channel/pikku-channel-types.gen.js.map +1 -0
  53. package/dist/.pikku/channel/pikku-channel-types.gen.ts +177 -0
  54. package/dist/.pikku/console/pikku-addon-meta.gen.json +58 -0
  55. package/dist/.pikku/console/pikku-node-types.gen.d.ts +1 -1
  56. package/dist/.pikku/console/pikku-node-types.gen.ts +1 -1
  57. package/dist/.pikku/function/pikku-function-types.gen.d.ts +97 -84
  58. package/dist/.pikku/function/pikku-function-types.gen.d.ts.map +1 -1
  59. package/dist/.pikku/function/pikku-function-types.gen.js +96 -60
  60. package/dist/.pikku/function/pikku-function-types.gen.js.map +1 -1
  61. package/dist/.pikku/function/pikku-function-types.gen.ts +209 -103
  62. package/dist/.pikku/function/pikku-functions-meta-verbose.gen.json +56 -44
  63. package/dist/.pikku/function/pikku-functions-meta.gen.js +1 -1
  64. package/dist/.pikku/function/pikku-functions-meta.gen.json +42 -38
  65. package/dist/.pikku/function/pikku-functions-meta.gen.ts +1 -1
  66. package/dist/.pikku/function/pikku-functions.gen.js +2 -2
  67. package/dist/.pikku/function/pikku-functions.gen.js.map +1 -1
  68. package/dist/.pikku/function/pikku-functions.gen.ts +2 -2
  69. package/dist/.pikku/http/pikku-http-types.gen.d.ts +120 -0
  70. package/dist/.pikku/http/pikku-http-types.gen.d.ts.map +1 -0
  71. package/dist/.pikku/http/pikku-http-types.gen.js +72 -0
  72. package/dist/.pikku/http/pikku-http-types.gen.js.map +1 -0
  73. package/dist/.pikku/http/pikku-http-types.gen.ts +147 -0
  74. package/dist/.pikku/mcp/pikku-mcp-types.gen.d.ts +131 -0
  75. package/dist/.pikku/mcp/pikku-mcp-types.gen.d.ts.map +1 -0
  76. package/dist/.pikku/mcp/pikku-mcp-types.gen.js +38 -0
  77. package/dist/.pikku/mcp/pikku-mcp-types.gen.js.map +1 -0
  78. package/dist/.pikku/mcp/pikku-mcp-types.gen.ts +183 -0
  79. package/dist/.pikku/pikku-bootstrap.gen.d.ts +4 -2
  80. package/dist/.pikku/pikku-bootstrap.gen.d.ts.map +1 -1
  81. package/dist/.pikku/pikku-bootstrap.gen.js +2 -10
  82. package/dist/.pikku/pikku-bootstrap.gen.js.map +1 -1
  83. package/dist/.pikku/pikku-bootstrap.gen.ts +2 -9
  84. package/dist/.pikku/pikku-meta-service.gen.d.ts +8 -0
  85. package/dist/.pikku/pikku-meta-service.gen.d.ts.map +1 -0
  86. package/dist/.pikku/pikku-meta-service.gen.js +10 -0
  87. package/dist/.pikku/pikku-meta-service.gen.js.map +1 -0
  88. package/dist/.pikku/pikku-meta-service.gen.ts +10 -0
  89. package/dist/.pikku/pikku-services.gen.d.ts +12 -2
  90. package/dist/.pikku/pikku-services.gen.d.ts.map +1 -1
  91. package/dist/.pikku/pikku-services.gen.js +11 -0
  92. package/dist/.pikku/pikku-services.gen.js.map +1 -1
  93. package/dist/.pikku/pikku-services.gen.ts +14 -2
  94. package/dist/.pikku/pikku-types.gen.d.ts +1 -1
  95. package/dist/.pikku/pikku-types.gen.js +1 -1
  96. package/dist/.pikku/pikku-types.gen.ts +1 -1
  97. package/dist/.pikku/queue/pikku-queue-types.gen.d.ts +24 -0
  98. package/dist/.pikku/queue/pikku-queue-types.gen.d.ts.map +1 -0
  99. package/dist/.pikku/queue/pikku-queue-types.gen.js +17 -0
  100. package/dist/.pikku/queue/pikku-queue-types.gen.js.map +1 -0
  101. package/dist/.pikku/queue/pikku-queue-types.gen.ts +27 -0
  102. package/dist/.pikku/rpc/pikku-rpc-wirings-map.gen.d.ts +81 -62
  103. package/dist/.pikku/rpc/pikku-rpc-wirings-map.internal.gen.d.ts +84 -65
  104. package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.d.ts +2 -0
  105. package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.d.ts.map +1 -0
  106. package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.js +7 -0
  107. package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.js.map +1 -0
  108. package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.json +6 -0
  109. package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.ts +6 -0
  110. package/dist/.pikku/scheduler/pikku-scheduler-types.gen.d.ts +22 -0
  111. package/dist/.pikku/scheduler/pikku-scheduler-types.gen.d.ts.map +1 -0
  112. package/dist/.pikku/scheduler/pikku-scheduler-types.gen.js +17 -0
  113. package/dist/.pikku/scheduler/pikku-scheduler-types.gen.js.map +1 -0
  114. package/dist/.pikku/scheduler/pikku-scheduler-types.gen.ts +25 -0
  115. package/dist/.pikku/schemas/register.gen.js +11 -11
  116. package/dist/.pikku/schemas/register.gen.js.map +1 -1
  117. package/dist/.pikku/schemas/register.gen.ts +17 -17
  118. package/dist/.pikku/secrets/pikku-secret-types.gen.d.ts +1 -1
  119. package/dist/.pikku/secrets/pikku-secret-types.gen.js +1 -1
  120. package/dist/.pikku/secrets/pikku-secret-types.gen.ts +1 -1
  121. package/dist/.pikku/secrets/pikku-secrets.gen.d.ts +1 -1
  122. package/dist/.pikku/secrets/pikku-secrets.gen.js +1 -1
  123. package/dist/.pikku/secrets/pikku-secrets.gen.ts +1 -1
  124. package/dist/.pikku/trigger/pikku-trigger-types.gen.d.ts +1 -1
  125. package/dist/.pikku/trigger/pikku-trigger-types.gen.js +1 -1
  126. package/dist/.pikku/trigger/pikku-trigger-types.gen.ts +1 -1
  127. package/dist/.pikku/variables/pikku-variable-types.gen.d.ts +1 -1
  128. package/dist/.pikku/variables/pikku-variable-types.gen.js +1 -1
  129. package/dist/.pikku/variables/pikku-variable-types.gen.ts +1 -1
  130. package/dist/.pikku/variables/pikku-variables-meta.gen.json +1 -1
  131. package/dist/.pikku/variables/pikku-variables.gen.d.ts +1 -1
  132. package/dist/.pikku/variables/pikku-variables.gen.js +1 -1
  133. package/dist/.pikku/variables/pikku-variables.gen.ts +1 -1
  134. package/dist/.pikku/workflow/pikku-workflow-map.gen.d.ts +9 -5
  135. package/dist/.pikku/workflow/pikku-workflow-types.gen.d.ts +36 -27
  136. package/dist/.pikku/workflow/pikku-workflow-types.gen.d.ts.map +1 -1
  137. package/dist/.pikku/workflow/pikku-workflow-types.gen.js +5 -18
  138. package/dist/.pikku/workflow/pikku-workflow-types.gen.js.map +1 -1
  139. package/dist/.pikku/workflow/pikku-workflow-types.gen.ts +66 -57
  140. package/dist/.pikku/workflow/pikku-workflow-wirings-meta.gen.js +1 -1
  141. package/dist/.pikku/workflow/pikku-workflow-wirings-meta.gen.ts +1 -1
  142. package/dist/.pikku/workflow/pikku-workflow-wirings.gen.d.ts +1 -1
  143. package/dist/.pikku/workflow/pikku-workflow-wirings.gen.js +1 -1
  144. package/dist/.pikku/workflow/pikku-workflow-wirings.gen.ts +1 -1
  145. package/dist/src/functions/embeddings/embed-many.function.d.ts +3 -0
  146. package/dist/src/functions/embeddings/embed-many.function.d.ts.map +1 -1
  147. package/dist/src/functions/embeddings/embed-many.function.js +1 -1
  148. package/dist/src/functions/embeddings/embed-many.function.js.map +1 -1
  149. package/dist/src/functions/embeddings/embed.function.d.ts +3 -0
  150. package/dist/src/functions/embeddings/embed.function.d.ts.map +1 -1
  151. package/dist/src/functions/embeddings/embed.function.js +1 -1
  152. package/dist/src/functions/embeddings/embed.function.js.map +1 -1
  153. package/dist/src/functions/text/generate-object.function.d.ts +17 -4
  154. package/dist/src/functions/text/generate-object.function.d.ts.map +1 -1
  155. package/dist/src/functions/text/generate-object.function.js +2 -2
  156. package/dist/src/functions/text/generate-object.function.js.map +1 -1
  157. package/dist/src/functions/text/generate.function.d.ts +13 -0
  158. package/dist/src/functions/text/generate.function.d.ts.map +1 -1
  159. package/dist/src/functions/text/generate.function.js +2 -2
  160. package/dist/src/functions/text/generate.function.js.map +1 -1
  161. package/package.json +8 -8
  162. package/.pikku/agent/pikku-agent-wirings-meta.gen.json +0 -3
  163. package/.pikku/agent/pikku-agent-wirings-meta.gen.ts +0 -7
  164. package/.pikku/agent/pikku-agent-wirings.gen.ts +0 -3
  165. package/.pikku/console/pikku-nodes-meta.gen.json +0 -57
  166. package/dist/.pikku/agent/pikku-agent-wirings-meta.gen.d.ts +0 -2
  167. package/dist/.pikku/agent/pikku-agent-wirings-meta.gen.d.ts.map +0 -1
  168. package/dist/.pikku/agent/pikku-agent-wirings-meta.gen.js +0 -7
  169. package/dist/.pikku/agent/pikku-agent-wirings-meta.gen.js.map +0 -1
  170. package/dist/.pikku/agent/pikku-agent-wirings-meta.gen.json +0 -3
  171. package/dist/.pikku/agent/pikku-agent-wirings-meta.gen.ts +0 -7
  172. package/dist/.pikku/agent/pikku-agent-wirings.gen.d.ts +0 -5
  173. package/dist/.pikku/agent/pikku-agent-wirings.gen.d.ts.map +0 -1
  174. package/dist/.pikku/agent/pikku-agent-wirings.gen.js +0 -5
  175. package/dist/.pikku/agent/pikku-agent-wirings.gen.js.map +0 -1
  176. package/dist/.pikku/agent/pikku-agent-wirings.gen.ts +0 -3
  177. package/dist/.pikku/console/pikku-nodes-meta.gen.json +0 -57
@@ -1,12 +1,12 @@
1
1
  /**
2
- * This file was generated by @pikku/cli@0.12.1
2
+ * This file was generated by @pikku/cli@0.12.55
3
3
  */
4
4
  /**
5
5
  * Core function, middleware, and permission types for all wirings
6
6
  */
7
- import { addMiddleware as addMiddlewareCore, addPermission as addPermissionCore } from '@pikku/core';
7
+ import { pikkuAuth as pikkuAuthCore } from '@pikku/core/function';
8
+ import { addTagMiddleware as addTagMiddlewareCore, addGlobalMiddleware as addGlobalMiddlewareCore, addTagPermission as addTagPermissionCore, addGlobalPermission as addGlobalPermissionCore, } from '@pikku/core/middleware';
8
9
  import { pikkuState as __pikkuState } from '@pikku/core/internal';
9
- import { pikkuAuth as pikkuAuthCore } from '@pikku/core';
10
10
  /**
11
11
  * Factory function for creating permissions with tree-shaking support.
12
12
  * Supports both direct function and configuration object syntax.
@@ -124,9 +124,28 @@ export const pikkuMiddlewareFactory = (factory) => {
124
124
  export const pikkuPermissionFactory = (factory) => {
125
125
  return factory;
126
126
  };
127
+ /**
128
+ * Factory function for creating approval description functions with tree-shaking support.
129
+ *
130
+ * @example
131
+ * ```typescript
132
+ * export const deleteTodoApproval = pikkuApprovalDescription(
133
+ * async ({ todoStore }, { id }) => {
134
+ * const todo = await todoStore.get(id)
135
+ * return \`Delete todo: "${todo.title}"\`
136
+ * }
137
+ * )
138
+ * ```
139
+ */
140
+ export const pikkuApprovalDescription = (fn) => {
141
+ return fn;
142
+ };
127
143
  export function pikkuFunc(func) {
128
144
  return typeof func === 'function' ? { func } : func;
129
145
  }
146
+ export const pikkuListFunc = (config) => {
147
+ return pikkuFunc(config);
148
+ };
130
149
  export function pikkuSessionlessFunc(func) {
131
150
  return typeof func === 'function' ? { func } : func;
132
151
  }
@@ -150,27 +169,23 @@ export const pikkuVoidFunc = (func) => {
150
169
  return typeof func === 'function' ? { func } : func;
151
170
  };
152
171
  /**
153
- * Creates a wrapper function for addon package functions that are exposed via RPC.
154
- * This allows you to wire addon functions to any wiring type (HTTP, queue, etc.)
155
- * without type compatibility issues.
172
+ * References a registered function by name for use in any wiring.
173
+ * Works for both local and addon functions — resolves via RPC at runtime.
156
174
  *
157
- * @template Name - The RPC method name (must be a key in FlattenedRPCMap)
158
- * @param rpcName - The name of the RPC method to invoke
159
- * @returns A Pikku function that proxies calls to the addon RPC method
175
+ * @template Name - The function name (must be a key in FlattenedRPCMap)
176
+ * @param rpcName - The name of the function to reference
177
+ * @returns A Pikku function config that proxies calls via RPC
160
178
  *
161
179
  * @example
162
180
  * ```typescript
163
- * // Wire an addon function via HTTP
164
- * wireHTTP({
165
- * auth: false,
166
- * method: 'get',
167
- * route: '/addon/hello',
168
- * func: addon('ext:hello'),
169
- * tags: ['addon'],
170
- * })
181
+ * // Use in agent tools
182
+ * tools: [ref('todos:listTodos'), ref('myLocalFunc')]
183
+ *
184
+ * // Use in HTTP wiring
185
+ * wireHTTP({ route: '/greet', method: 'post', func: ref('greet') })
171
186
  * ```
172
187
  */
173
- export const addon = (rpcName) => {
188
+ export const ref = (rpcName) => {
174
189
  return {
175
190
  func: async (_services, data, { rpc }) => {
176
191
  return rpc.invoke(rpcName, data);
@@ -215,9 +230,24 @@ export const pikkuConfig = (func) => func;
215
230
  */
216
231
  export const pikkuServices = (func) => {
217
232
  return async (config, existingServices = {}) => {
218
- const services = await func(config, existingServices);
219
- __pikkuState(null, 'package', 'singletonServices', services);
220
- return services;
233
+ const createdServices = await func(config, existingServices);
234
+ const services = { ...existingServices, ...createdServices };
235
+ const authFactory = __pikkuState(null, 'package', 'authFactory');
236
+ if (authFactory) {
237
+ let authInstance;
238
+ services.auth = () => {
239
+ authInstance ??= Promise.resolve()
240
+ .then(() => authFactory(services))
241
+ .catch((error) => {
242
+ authInstance = undefined;
243
+ throw error;
244
+ });
245
+ return authInstance;
246
+ };
247
+ }
248
+ const resolved = services;
249
+ __pikkuState(null, 'package', 'singletonServices', resolved);
250
+ return resolved;
221
251
  };
222
252
  };
223
253
  /**
@@ -243,56 +273,62 @@ export const pikkuWireServices = (func) => {
243
273
  return func;
244
274
  };
245
275
  /**
246
- * Adds global middleware for a specific tag.
247
- *
248
- * This function allows you to register middleware that will be applied to
249
- * any wiring (HTTP, Channel, Queue, Scheduler, MCP) that includes the matching tag.
250
- *
251
- * @param tag - The tag that the middleware should apply to.
252
- * @param middleware - The middleware array to apply for the specified tag.
253
- *
254
- * @throws Error if middleware for the tag already exists.
276
+ * Tag-scoped middleware. Applies to any wiring that carries the matching tag.
255
277
  *
256
278
  * @example
257
- * ```typescript
258
- * // Add admin middleware for admin endpoints
259
- * addMiddleware('admin', [adminMiddleware])
260
- *
261
- * // Add authentication middleware for auth endpoints
262
- * addMiddleware('auth', [authMiddleware])
263
- *
264
- * // Add logging middleware for all API endpoints
265
- * addMiddleware('api', [loggingMiddleware])
266
- * ```
279
+ * addTagMiddleware('admin', [adminMiddleware])
267
280
  */
268
- export const addMiddleware = (tag, middleware) => {
269
- addMiddlewareCore(tag, middleware, '@pikku/addon-ollama');
281
+ export const addTagMiddleware = (tag, middleware) => {
282
+ addTagMiddlewareCore(tag, middleware, '@pikku/addon-ollama');
270
283
  };
271
284
  /**
272
- * Adds global permissions for a specific tag.
285
+ * Wire-agnostic global middleware. Runs at the top of every wiring's
286
+ * middleware chain — before wire-, tag-, and function-level entries.
273
287
  *
274
- * This function allows you to register permissions that will be applied to
275
- * any wiring (HTTP, Channel, Queue, Scheduler, MCP) that includes the matching tag.
288
+ * Resolution order: global -> wire -> tag -> function.
276
289
  *
277
- * @param tag - The tag that the permissions should apply to.
278
- * @param permissions - The permissions array or object to apply for the specified tag.
279
- *
280
- * @throws Error if permissions for the tag already exist.
290
+ * @example
291
+ * addGlobalMiddleware([telemetryMiddleware])
292
+ */
293
+ export const addGlobalMiddleware = (middleware) => {
294
+ addGlobalMiddlewareCore(middleware, '@pikku/addon-ollama');
295
+ };
296
+ /**
297
+ * Tag-scoped permissions. Applies to any wiring that carries the matching tag.
281
298
  *
282
299
  * @example
283
- * ```typescript
284
- * // Add admin permissions for admin endpoints
285
- * addPermission('admin', [adminPermission])
300
+ * addTagPermission('admin', [adminPermission])
301
+ */
302
+ export const addTagPermission = (tag, permissions) => {
303
+ addTagPermissionCore(tag, permissions, '@pikku/addon-ollama');
304
+ };
305
+ /**
306
+ * Wire-agnostic global permissions. Runs at the top of every wiring's
307
+ * permission resolution — before wire-, tag-, and function-level entries.
286
308
  *
287
- * // Add authentication permissions for auth endpoints
288
- * addPermission('auth', [authPermission])
309
+ * Resolution order: global -> wire -> tag -> function.
289
310
  *
290
- * // Add read permissions for all API endpoints (as object)
291
- * addPermission('api', { read: readPermission })
292
- * ```
311
+ * @example
312
+ * addGlobalPermission([signedInUser])
313
+ */
314
+ export const addGlobalPermission = (permissions) => {
315
+ addGlobalPermissionCore(permissions, '@pikku/addon-ollama');
316
+ };
317
+ export { wireAddon } from '@pikku/core/rpc';
318
+ /**
319
+ * Addon contract references. Generated from each wired addon's published
320
+ * contract metadata — no addon source is imported. Functions are proxied via
321
+ * ref() (RPC) exactly like ref('namespace:fn').
293
322
  */
294
- export const addPermission = (tag, permissions) => {
295
- addPermissionCore(tag, permissions, '@pikku/addon-ollama');
323
+ const __addonHttp = {};
324
+ const __addonChannel = {};
325
+ const __addonCli = {};
326
+ export const refHTTP = (name, options) => {
327
+ const contract = __addonHttp[name];
328
+ return (options?.basePath !== undefined
329
+ ? { ...contract, basePath: options.basePath }
330
+ : contract);
296
331
  };
297
- export { wireAddon } from '@pikku/core';
332
+ export const refChannel = (name) => __addonChannel[name];
333
+ export const refCLI = (name) => __addonCli[name];
298
334
  //# sourceMappingURL=pikku-function-types.gen.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pikku-function-types.gen.js","sourceRoot":"","sources":["../../../.pikku/function/pikku-function-types.gen.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;GAEG;AAEH,OAAO,EAA8H,aAAa,IAAI,iBAAiB,EAAE,aAAa,IAAI,iBAAiB,EAA2B,MAAM,aAAa,CAAA;AACzP,OAAO,EAAE,UAAU,IAAI,YAAY,EAAsB,MAAM,sBAAsB,CAAA;AACrF,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,aAAa,CAAA;AAyDxD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,UAA2D,EACtC,EAAE;IACvB,OAAO,OAAO,UAAU,KAAK,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAA;AACxE,CAAC,CAAA;AAgBD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,IAAqE,EAC1C,EAAE;IAC7B,OAAO,aAAa,CAAC,IAAW,CAAQ,CAAA;AAC1C,CAAC,CAAA;AAcD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,UAAuF,EACpD,EAAE;IACrC,OAAO,OAAO,UAAU,KAAK,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAA;AACxE,CAAC,CAAA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,OAAuC,EACL,EAAE;IACpC,OAAO,OAAO,CAAA;AAChB,CAAC,CA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UAA6B,EAAE,EAAE;IACnE,uBAAuB,CAAC,UAAiB,EAAE,qBAAqB,CAAC,CAAA;AACnE,CAAC,CAAA;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAe,GAAW,EAAE,WAA6E,EAAE,EAAE;IAC3I,oBAAoB,CAAC,GAAG,EAAE,WAAkB,EAAE,qBAAqB,CAAC,CAAA;AACtE,CAAC,CAAA;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAe,WAA6E,EAAE,EAAE;IACjI,uBAAuB,CAAC,WAAkB,EAAE,qBAAqB,CAAC,CAAA;AACpE,CAAC,CAAA;AAED,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAI3C;;;;GAIG;AACH,MAAM,WAAW,GAAG,EAAW,CAAA;AAC/B,MAAM,cAAc,GAAG,EAAW,CAAA;AAClC,MAAM,UAAU,GAAG,EAAW,CAAA;AAE9B,MAAM,CAAC,MAAM,OAAO,GAAG,CACrB,IAAU,EACV,OAA+B,EACH,EAAE;IAC9B,MAAM,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAQ,CAAA;IACzC,OAAO,CACL,OAAO,EAAE,QAAQ,KAAK,SAAS;QAC7B,CAAC,CAAC,EAAE,GAAG,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE;QAC7C,CAAC,CAAC,QAAQ,CACiB,CAAA;AACjC,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,IAAU,EACqB,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,CAAA;AAExD,MAAM,CAAC,MAAM,MAAM,GAAG,CACpB,IAAU,EACiB,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA"}
@@ -1,13 +1,20 @@
1
1
  /**
2
- * This file was generated by @pikku/cli@0.12.1
2
+ * This file was generated by @pikku/cli@0.12.55
3
3
  */
4
4
  /**
5
5
  * Core function, middleware, and permission types for all wirings
6
6
  */
7
7
 
8
- import { CorePikkuFunctionConfig, CorePikkuAuth, CorePikkuAuthConfig, CorePikkuPermission, CorePikkuMiddleware, CorePermissionGroup, addMiddleware as addMiddlewareCore, addPermission as addPermissionCore, PikkuWire, PickRequired } from '@pikku/core'
8
+ import type { CorePikkuMiddleware, CorePermissionGroup, ListInput, ListOutput, PikkuWire, PickRequired } from '@pikku/core'
9
+ import type { CorePikkuFunctionConfig, CorePikkuAuth, CorePikkuAuthConfig, CorePikkuPermission } from '@pikku/core/function'
10
+ import { pikkuAuth as pikkuAuthCore } from '@pikku/core/function'
11
+ import {
12
+ addTagMiddleware as addTagMiddlewareCore,
13
+ addGlobalMiddleware as addGlobalMiddlewareCore,
14
+ addTagPermission as addTagPermissionCore,
15
+ addGlobalPermission as addGlobalPermissionCore,
16
+ } from '@pikku/core/middleware'
9
17
  import { pikkuState as __pikkuState, CreateWireServices } from '@pikku/core/internal'
10
- import { pikkuAuth as pikkuAuthCore } from '@pikku/core'
11
18
  import type { NodeType } from '@pikku/core/node'
12
19
  import type { StandardSchemaV1 } from '@standard-schema/spec'
13
20
  import { CorePikkuFunction, CorePikkuFunctionSessionless } from '@pikku/core/function'
@@ -222,6 +229,37 @@ export const pikkuPermissionFactory = <In = any>(
222
229
  return factory
223
230
  }
224
231
 
232
+ /**
233
+ * A function that generates a human-readable description of a pending approval action.
234
+ * Used by AI agents to show meaningful approval prompts instead of raw tool arguments.
235
+ *
236
+ * @template In - The input type (same as the function it describes)
237
+ * @template RequiredServices - The services required for this description function
238
+ */
239
+ export type PikkuApprovalDescription<In = unknown, RequiredServices extends Services = Services> = (
240
+ services: RequiredServices,
241
+ data: In
242
+ ) => Promise<string>
243
+
244
+ /**
245
+ * Factory function for creating approval description functions with tree-shaking support.
246
+ *
247
+ * @example
248
+ * ```typescript
249
+ * export const deleteTodoApproval = pikkuApprovalDescription(
250
+ * async ({ todoStore }, { id }) => {
251
+ * const todo = await todoStore.get(id)
252
+ * return \`Delete todo: "${todo.title}"\`
253
+ * }
254
+ * )
255
+ * ```
256
+ */
257
+ export const pikkuApprovalDescription = <In = unknown, RequiredServices extends Services = Services>(
258
+ fn: PikkuApprovalDescription<In, RequiredServices>
259
+ ): PikkuApprovalDescription<In, RequiredServices> => {
260
+ return fn
261
+ }
262
+
225
263
  /**
226
264
  * A sessionless API function that doesn't require user authentication.
227
265
  * Use this for public endpoints, health checks, or operations that don't need user context.
@@ -291,31 +329,36 @@ export type PikkuFunctionConfig<
291
329
  * Use this when you want to define input/output schemas using Zod.
292
330
  * Types are automatically inferred from the schemas.
293
331
  */
332
+ type SchemaInferred<S, Fallback = unknown> = S extends StandardSchemaV1
333
+ ? InferSchemaOutput<S>
334
+ : Fallback
335
+
336
+ /**
337
+ * Schema-overload variant for pikkuFunc. Derived from CorePikkuFunctionConfig
338
+ * so adding a field on the core type automatically propagates here.
339
+ */
294
340
  export type PikkuFunctionConfigWithSchema<
295
- InputSchema extends StandardSchemaV1,
341
+ InputSchema extends StandardSchemaV1 | undefined = undefined,
296
342
  OutputSchema extends StandardSchemaV1 | undefined = undefined,
297
343
  RequiredWires extends keyof PikkuWire = never
298
- > = {
299
- name?: string
300
- tags?: string[]
301
- expose?: boolean
302
- mcp?: boolean
303
- internal?: boolean
304
- func: PikkuFunction<
305
- InferSchemaOutput<InputSchema>,
306
- OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown,
307
- RequiredWires
308
- > | PikkuFunctionSessionless<
309
- InferSchemaOutput<InputSchema>,
310
- OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown,
311
- RequiredWires
312
- >
313
- auth?: boolean
314
- permissions?: CorePermissionGroup<PikkuPermission<InferSchemaOutput<InputSchema>>>
315
- middleware?: PikkuMiddleware[]
316
- input: InputSchema
344
+ > = Omit<
345
+ CorePikkuFunctionConfig<
346
+ | PikkuFunction<SchemaInferred<InputSchema>, SchemaInferred<OutputSchema>, RequiredWires>
347
+ | PikkuFunctionSessionless<SchemaInferred<InputSchema>, SchemaInferred<OutputSchema>, RequiredWires>
348
+ >,
349
+ 'func' | 'input' | 'output' | 'permissions' | 'approvalDescription'
350
+ > & {
351
+ func:
352
+ | PikkuFunction<SchemaInferred<InputSchema>, SchemaInferred<OutputSchema>, RequiredWires>
353
+ | PikkuFunctionSessionless<SchemaInferred<InputSchema>, SchemaInferred<OutputSchema>, RequiredWires>
354
+ input?: InputSchema
317
355
  output?: OutputSchema
318
- node?: NodeConfig
356
+ permissions?: InputSchema extends StandardSchemaV1
357
+ ? CorePermissionGroup<PikkuPermission<InferSchemaOutput<InputSchema>>>
358
+ : undefined
359
+ approvalDescription?: InputSchema extends StandardSchemaV1
360
+ ? PikkuApprovalDescription<InferSchemaOutput<InputSchema>>
361
+ : never
319
362
  }
320
363
 
321
364
  /**
@@ -357,11 +400,11 @@ export type PikkuFunctionConfigWithSchema<
357
400
  * ```
358
401
  */
359
402
  export function pikkuFunc<
360
- InputSchema extends StandardSchemaV1,
403
+ InputSchema extends StandardSchemaV1 | undefined = undefined,
361
404
  OutputSchema extends StandardSchemaV1 | undefined = undefined
362
405
  >(
363
406
  config: PikkuFunctionConfigWithSchema<InputSchema, OutputSchema, 'session' | 'rpc'>
364
- ): PikkuFunctionConfig<InferSchemaOutput<InputSchema>, OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown, 'session' | 'rpc'>
407
+ ): PikkuFunctionConfig<InputSchema extends StandardSchemaV1 ? InferSchemaOutput<InputSchema> : unknown, OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown, 'session' | 'rpc'>
365
408
  export function pikkuFunc<In, Out = unknown>(
366
409
  func:
367
410
  | PikkuFunction<In, Out, 'session' | 'rpc'>
@@ -371,32 +414,62 @@ export function pikkuFunc(func: any) {
371
414
  return typeof func === 'function' ? { func } : func
372
415
  }
373
416
 
417
+ export type PikkuListFunction<
418
+ F extends Record<string, unknown> = {},
419
+ Row = unknown,
420
+ S extends string = never
421
+ > =
422
+ | PikkuFunction<ListInput<F, S>, ListOutput<Row>, 'session' | 'rpc'>
423
+ | PikkuFunctionSessionless<
424
+ ListInput<F, S>,
425
+ ListOutput<Row>,
426
+ 'session' | 'rpc'
427
+ >
428
+
429
+ export const pikkuListFunc = <
430
+ F extends Record<string, unknown> = {},
431
+ Row = unknown,
432
+ S extends string = never
433
+ >(
434
+ config: PikkuFunctionConfig<
435
+ ListInput<F, S>,
436
+ ListOutput<Row>,
437
+ 'session' | 'rpc'
438
+ >
439
+ ): PikkuFunctionConfig<ListInput<F, S>, ListOutput<Row>, 'session' | 'rpc'> => {
440
+ return pikkuFunc(config)
441
+ }
442
+
374
443
  /**
375
444
  * Configuration object for sessionless Pikku functions with Zod schema validation.
376
445
  */
446
+ /**
447
+ * Schema-overload variant for pikkuSessionlessFunc. Derived from
448
+ * CorePikkuFunctionConfig to stay in sync with the generic-typed config.
449
+ */
377
450
  export type PikkuFunctionSessionlessConfigWithSchema<
378
- InputSchema extends StandardSchemaV1,
451
+ InputSchema extends StandardSchemaV1 | undefined = undefined,
379
452
  OutputSchema extends StandardSchemaV1 | undefined = undefined,
380
453
  RequiredWires extends keyof PikkuWire = never
381
- > = {
382
- name?: string
383
- description?: string
384
- tags?: string[]
385
- expose?: boolean
386
- mcp?: boolean
387
- internal?: boolean
388
- remote?: boolean
454
+ > = Omit<
455
+ CorePikkuFunctionConfig<
456
+ PikkuFunctionSessionless<SchemaInferred<InputSchema>, SchemaInferred<OutputSchema>, RequiredWires>
457
+ >,
458
+ 'func' | 'input' | 'output' | 'permissions' | 'approvalDescription'
459
+ > & {
389
460
  func: PikkuFunctionSessionless<
390
- InferSchemaOutput<InputSchema>,
391
- OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown,
461
+ SchemaInferred<InputSchema>,
462
+ SchemaInferred<OutputSchema>,
392
463
  RequiredWires
393
464
  >
394
- auth?: boolean
395
- permissions?: CorePermissionGroup<PikkuPermission<InferSchemaOutput<InputSchema>>>
396
- middleware?: PikkuMiddleware[]
397
- input: InputSchema
465
+ input?: InputSchema
398
466
  output?: OutputSchema
399
- node?: NodeConfig
467
+ permissions?: InputSchema extends StandardSchemaV1
468
+ ? CorePermissionGroup<PikkuPermission<InferSchemaOutput<InputSchema>>>
469
+ : undefined
470
+ approvalDescription?: InputSchema extends StandardSchemaV1
471
+ ? PikkuApprovalDescription<InferSchemaOutput<InputSchema>>
472
+ : never
400
473
  }
401
474
 
402
475
  /**
@@ -435,11 +508,11 @@ export type PikkuFunctionSessionlessConfigWithSchema<
435
508
  * ```
436
509
  */
437
510
  export function pikkuSessionlessFunc<
438
- InputSchema extends StandardSchemaV1,
511
+ InputSchema extends StandardSchemaV1 | undefined = undefined,
439
512
  OutputSchema extends StandardSchemaV1 | undefined = undefined
440
513
  >(
441
514
  config: PikkuFunctionSessionlessConfigWithSchema<InputSchema, OutputSchema, 'session' | 'rpc'>
442
- ): PikkuFunctionConfig<InferSchemaOutput<InputSchema>, OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown, 'session' | 'rpc'>
515
+ ): PikkuFunctionConfig<InputSchema extends StandardSchemaV1 ? InferSchemaOutput<InputSchema> : unknown, OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown, 'session' | 'rpc'>
443
516
  export function pikkuSessionlessFunc<In, Out = unknown>(
444
517
  func:
445
518
  | PikkuFunctionSessionless<In, Out, 'session' | 'rpc'>
@@ -474,27 +547,23 @@ export const pikkuVoidFunc = (
474
547
  }
475
548
 
476
549
  /**
477
- * Creates a wrapper function for addon package functions that are exposed via RPC.
478
- * This allows you to wire addon functions to any wiring type (HTTP, queue, etc.)
479
- * without type compatibility issues.
550
+ * References a registered function by name for use in any wiring.
551
+ * Works for both local and addon functions — resolves via RPC at runtime.
480
552
  *
481
- * @template Name - The RPC method name (must be a key in FlattenedRPCMap)
482
- * @param rpcName - The name of the RPC method to invoke
483
- * @returns A Pikku function that proxies calls to the addon RPC method
553
+ * @template Name - The function name (must be a key in FlattenedRPCMap)
554
+ * @param rpcName - The name of the function to reference
555
+ * @returns A Pikku function config that proxies calls via RPC
484
556
  *
485
557
  * @example
486
558
  * ```typescript
487
- * // Wire an addon function via HTTP
488
- * wireHTTP({
489
- * auth: false,
490
- * method: 'get',
491
- * route: '/addon/hello',
492
- * func: addon('ext:hello'),
493
- * tags: ['addon'],
494
- * })
559
+ * // Use in agent tools
560
+ * tools: [ref('todos:listTodos'), ref('myLocalFunc')]
561
+ *
562
+ * // Use in HTTP wiring
563
+ * wireHTTP({ route: '/greet', method: 'post', func: ref('greet') })
495
564
  * ```
496
565
  */
497
- export const addon = <Name extends keyof FlattenedRPCMap>(
566
+ export const ref = <Name extends keyof FlattenedRPCMap>(
498
567
  rpcName: Name
499
568
  ): PikkuFunctionConfig<
500
569
  FlattenedRPCMap[Name]['input'],
@@ -553,12 +622,27 @@ export const pikkuConfig = (
553
622
  * ```
554
623
  */
555
624
  export const pikkuServices = (
556
- func: (config: Config, existingServices: Partial<SingletonServices>) => Promise<RequiredSingletonServices>
625
+ func: (config: Config, existingServices: Partial<SingletonServices>) => Promise<Partial<Omit<RequiredSingletonServices, 'auth'>>>
557
626
  ) => {
558
627
  return async (config: Config, existingServices: Partial<SingletonServices> = {}) => {
559
- const services = await func(config, existingServices)
560
- __pikkuState(null, 'package', 'singletonServices', services as any)
561
- return services
628
+ const createdServices = await func(config, existingServices)
629
+ const services = { ...existingServices, ...createdServices }
630
+ const authFactory = __pikkuState(null, 'package', 'authFactory')
631
+ if (authFactory) {
632
+ let authInstance: Promise<unknown> | undefined
633
+ ;(services as any).auth = () => {
634
+ authInstance ??= Promise.resolve()
635
+ .then(() => authFactory(services as any))
636
+ .catch((error) => {
637
+ authInstance = undefined
638
+ throw error
639
+ })
640
+ return authInstance
641
+ }
642
+ }
643
+ const resolved = services as RequiredSingletonServices
644
+ __pikkuState(null, 'package', 'singletonServices', resolved as any)
645
+ return resolved
562
646
  }
563
647
  }
564
648
 
@@ -591,58 +675,80 @@ export const pikkuWireServices = (
591
675
  }
592
676
 
593
677
  /**
594
- * Adds global middleware for a specific tag.
595
- *
596
- * This function allows you to register middleware that will be applied to
597
- * any wiring (HTTP, Channel, Queue, Scheduler, MCP) that includes the matching tag.
598
- *
599
- * @param tag - The tag that the middleware should apply to.
600
- * @param middleware - The middleware array to apply for the specified tag.
601
- *
602
- * @throws Error if middleware for the tag already exists.
678
+ * Tag-scoped middleware. Applies to any wiring that carries the matching tag.
603
679
  *
604
680
  * @example
605
- * ```typescript
606
- * // Add admin middleware for admin endpoints
607
- * addMiddleware('admin', [adminMiddleware])
608
- *
609
- * // Add authentication middleware for auth endpoints
610
- * addMiddleware('auth', [authMiddleware])
611
- *
612
- * // Add logging middleware for all API endpoints
613
- * addMiddleware('api', [loggingMiddleware])
614
- * ```
681
+ * addTagMiddleware('admin', [adminMiddleware])
615
682
  */
616
- export const addMiddleware = (tag: string, middleware: PikkuMiddleware[]) => {
617
- addMiddlewareCore(tag, middleware as any, '@pikku/addon-ollama')
683
+ export const addTagMiddleware = (tag: string, middleware: PikkuMiddleware[]) => {
684
+ addTagMiddlewareCore(tag, middleware as any, '@pikku/addon-ollama')
618
685
  }
619
686
 
620
687
  /**
621
- * Adds global permissions for a specific tag.
688
+ * Wire-agnostic global middleware. Runs at the top of every wiring's
689
+ * middleware chain — before wire-, tag-, and function-level entries.
622
690
  *
623
- * This function allows you to register permissions that will be applied to
624
- * any wiring (HTTP, Channel, Queue, Scheduler, MCP) that includes the matching tag.
691
+ * Resolution order: global -> wire -> tag -> function.
625
692
  *
626
- * @param tag - The tag that the permissions should apply to.
627
- * @param permissions - The permissions array or object to apply for the specified tag.
628
- *
629
- * @throws Error if permissions for the tag already exist.
693
+ * @example
694
+ * addGlobalMiddleware([telemetryMiddleware])
695
+ */
696
+ export const addGlobalMiddleware = (middleware: PikkuMiddleware[]) => {
697
+ addGlobalMiddlewareCore(middleware as any, '@pikku/addon-ollama')
698
+ }
699
+
700
+ /**
701
+ * Tag-scoped permissions. Applies to any wiring that carries the matching tag.
630
702
  *
631
703
  * @example
632
- * ```typescript
633
- * // Add admin permissions for admin endpoints
634
- * addPermission('admin', [adminPermission])
704
+ * addTagPermission('admin', [adminPermission])
705
+ */
706
+ export const addTagPermission = <In = unknown>(tag: string, permissions: CorePermissionGroup<PikkuPermission<In>> | PikkuPermission<In>[]) => {
707
+ addTagPermissionCore(tag, permissions as any, '@pikku/addon-ollama')
708
+ }
709
+
710
+ /**
711
+ * Wire-agnostic global permissions. Runs at the top of every wiring's
712
+ * permission resolution — before wire-, tag-, and function-level entries.
635
713
  *
636
- * // Add authentication permissions for auth endpoints
637
- * addPermission('auth', [authPermission])
714
+ * Resolution order: global -> wire -> tag -> function.
638
715
  *
639
- * // Add read permissions for all API endpoints (as object)
640
- * addPermission('api', { read: readPermission })
641
- * ```
716
+ * @example
717
+ * addGlobalPermission([signedInUser])
718
+ */
719
+ export const addGlobalPermission = <In = unknown>(permissions: CorePermissionGroup<PikkuPermission<In>> | PikkuPermission<In>[]) => {
720
+ addGlobalPermissionCore(permissions as any, '@pikku/addon-ollama')
721
+ }
722
+
723
+ export { wireAddon } from '@pikku/core/rpc'
724
+ export type { WireAddonConfig } from '@pikku/core/rpc'
725
+
726
+
727
+ /**
728
+ * Addon contract references. Generated from each wired addon's published
729
+ * contract metadata — no addon source is imported. Functions are proxied via
730
+ * ref() (RPC) exactly like ref('namespace:fn').
642
731
  */
643
- export const addPermission = <In = unknown>(tag: string, permissions: CorePermissionGroup<PikkuPermission<In>> | PikkuPermission<In>[]) => {
644
- addPermissionCore(tag, permissions as any, '@pikku/addon-ollama')
732
+ const __addonHttp = {} as const
733
+ const __addonChannel = {} as const
734
+ const __addonCli = {} as const
735
+
736
+ export const refHTTP = <Name extends keyof typeof __addonHttp>(
737
+ name: Name,
738
+ options?: { basePath?: string }
739
+ ): (typeof __addonHttp)[Name] => {
740
+ const contract = __addonHttp[name] as any
741
+ return (
742
+ options?.basePath !== undefined
743
+ ? { ...contract, basePath: options.basePath }
744
+ : contract
745
+ ) as (typeof __addonHttp)[Name]
645
746
  }
646
747
 
647
- export { wireAddon } from '@pikku/core'
648
- export type { WireAddonConfig } from '@pikku/core'
748
+ export const refChannel = <Name extends keyof typeof __addonChannel>(
749
+ name: Name
750
+ ): (typeof __addonChannel)[Name] => __addonChannel[name]
751
+
752
+ export const refCLI = <Name extends keyof typeof __addonCli>(
753
+ name: Name
754
+ ): (typeof __addonCli)[Name] => __addonCli[name]