@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.
- package/.pikku/addon/pikku-addon-types.gen.ts +31 -4
- package/.pikku/addon/pikku-package.gen.ts +3 -1
- package/.pikku/agent/pikku-agent-map.gen.d.ts +2 -14
- package/.pikku/agent/pikku-agent-types.gen.ts +13 -7
- package/.pikku/channel/pikku-channel-types.gen.ts +177 -0
- package/.pikku/console/pikku-addon-meta.gen.json +58 -0
- package/.pikku/console/pikku-node-types.gen.ts +1 -1
- package/.pikku/function/pikku-function-types.gen.ts +209 -103
- package/.pikku/function/pikku-functions-meta-verbose.gen.json +56 -44
- package/.pikku/function/pikku-functions-meta.gen.json +42 -38
- package/.pikku/function/pikku-functions-meta.gen.ts +1 -1
- package/.pikku/function/pikku-functions.gen.ts +2 -2
- package/.pikku/http/pikku-http-types.gen.ts +147 -0
- package/.pikku/mcp/pikku-mcp-types.gen.ts +183 -0
- package/.pikku/pikku-bootstrap.gen.ts +2 -9
- package/.pikku/pikku-meta-service.gen.ts +10 -0
- package/.pikku/pikku-services.gen.ts +14 -2
- package/.pikku/pikku-types.gen.ts +1 -1
- package/.pikku/queue/pikku-queue-types.gen.ts +27 -0
- package/.pikku/rpc/pikku-rpc-wirings-map.gen.d.ts +81 -62
- package/.pikku/rpc/pikku-rpc-wirings-map.internal.gen.d.ts +84 -65
- package/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.json +6 -0
- package/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.ts +6 -0
- package/.pikku/scheduler/pikku-scheduler-types.gen.ts +25 -0
- package/.pikku/schemas/register.gen.ts +17 -17
- package/.pikku/secrets/pikku-secret-types.gen.ts +1 -1
- package/.pikku/secrets/pikku-secrets.gen.ts +1 -1
- package/.pikku/trigger/pikku-trigger-types.gen.ts +1 -1
- package/.pikku/variables/pikku-variable-types.gen.ts +1 -1
- package/.pikku/variables/pikku-variables-meta.gen.json +1 -1
- package/.pikku/variables/pikku-variables.gen.ts +1 -1
- package/.pikku/workflow/pikku-workflow-map.gen.d.ts +9 -5
- package/.pikku/workflow/pikku-workflow-types.gen.ts +66 -57
- package/.pikku/workflow/pikku-workflow-wirings-meta.gen.ts +1 -1
- package/.pikku/workflow/pikku-workflow-wirings.gen.ts +1 -1
- package/dist/.pikku/addon/pikku-addon-types.gen.d.ts +19 -3
- package/dist/.pikku/addon/pikku-addon-types.gen.d.ts.map +1 -1
- package/dist/.pikku/addon/pikku-addon-types.gen.js +26 -3
- package/dist/.pikku/addon/pikku-addon-types.gen.js.map +1 -1
- package/dist/.pikku/addon/pikku-addon-types.gen.ts +31 -4
- package/dist/.pikku/addon/pikku-package.gen.js +2 -1
- package/dist/.pikku/addon/pikku-package.gen.js.map +1 -1
- package/dist/.pikku/addon/pikku-package.gen.ts +3 -1
- package/dist/.pikku/agent/pikku-agent-map.gen.d.ts +2 -14
- package/dist/.pikku/agent/pikku-agent-types.gen.d.ts +6 -6
- package/dist/.pikku/agent/pikku-agent-types.gen.d.ts.map +1 -1
- package/dist/.pikku/agent/pikku-agent-types.gen.js.map +1 -1
- package/dist/.pikku/agent/pikku-agent-types.gen.ts +13 -7
- package/dist/.pikku/channel/pikku-channel-types.gen.d.ts +112 -0
- package/dist/.pikku/channel/pikku-channel-types.gen.d.ts.map +1 -0
- package/dist/.pikku/channel/pikku-channel-types.gen.js +60 -0
- package/dist/.pikku/channel/pikku-channel-types.gen.js.map +1 -0
- package/dist/.pikku/channel/pikku-channel-types.gen.ts +177 -0
- package/dist/.pikku/console/pikku-addon-meta.gen.json +58 -0
- package/dist/.pikku/console/pikku-node-types.gen.d.ts +1 -1
- package/dist/.pikku/console/pikku-node-types.gen.ts +1 -1
- package/dist/.pikku/function/pikku-function-types.gen.d.ts +97 -84
- package/dist/.pikku/function/pikku-function-types.gen.d.ts.map +1 -1
- package/dist/.pikku/function/pikku-function-types.gen.js +96 -60
- package/dist/.pikku/function/pikku-function-types.gen.js.map +1 -1
- package/dist/.pikku/function/pikku-function-types.gen.ts +209 -103
- package/dist/.pikku/function/pikku-functions-meta-verbose.gen.json +56 -44
- package/dist/.pikku/function/pikku-functions-meta.gen.js +1 -1
- package/dist/.pikku/function/pikku-functions-meta.gen.json +42 -38
- package/dist/.pikku/function/pikku-functions-meta.gen.ts +1 -1
- package/dist/.pikku/function/pikku-functions.gen.js +2 -2
- package/dist/.pikku/function/pikku-functions.gen.js.map +1 -1
- package/dist/.pikku/function/pikku-functions.gen.ts +2 -2
- package/dist/.pikku/http/pikku-http-types.gen.d.ts +120 -0
- package/dist/.pikku/http/pikku-http-types.gen.d.ts.map +1 -0
- package/dist/.pikku/http/pikku-http-types.gen.js +72 -0
- package/dist/.pikku/http/pikku-http-types.gen.js.map +1 -0
- package/dist/.pikku/http/pikku-http-types.gen.ts +147 -0
- package/dist/.pikku/mcp/pikku-mcp-types.gen.d.ts +131 -0
- package/dist/.pikku/mcp/pikku-mcp-types.gen.d.ts.map +1 -0
- package/dist/.pikku/mcp/pikku-mcp-types.gen.js +38 -0
- package/dist/.pikku/mcp/pikku-mcp-types.gen.js.map +1 -0
- package/dist/.pikku/mcp/pikku-mcp-types.gen.ts +183 -0
- package/dist/.pikku/pikku-bootstrap.gen.d.ts +4 -2
- package/dist/.pikku/pikku-bootstrap.gen.d.ts.map +1 -1
- package/dist/.pikku/pikku-bootstrap.gen.js +2 -10
- package/dist/.pikku/pikku-bootstrap.gen.js.map +1 -1
- package/dist/.pikku/pikku-bootstrap.gen.ts +2 -9
- package/dist/.pikku/pikku-meta-service.gen.d.ts +8 -0
- package/dist/.pikku/pikku-meta-service.gen.d.ts.map +1 -0
- package/dist/.pikku/pikku-meta-service.gen.js +10 -0
- package/dist/.pikku/pikku-meta-service.gen.js.map +1 -0
- package/dist/.pikku/pikku-meta-service.gen.ts +10 -0
- package/dist/.pikku/pikku-services.gen.d.ts +12 -2
- package/dist/.pikku/pikku-services.gen.d.ts.map +1 -1
- package/dist/.pikku/pikku-services.gen.js +11 -0
- package/dist/.pikku/pikku-services.gen.js.map +1 -1
- package/dist/.pikku/pikku-services.gen.ts +14 -2
- package/dist/.pikku/pikku-types.gen.d.ts +1 -1
- package/dist/.pikku/pikku-types.gen.js +1 -1
- package/dist/.pikku/pikku-types.gen.ts +1 -1
- package/dist/.pikku/queue/pikku-queue-types.gen.d.ts +24 -0
- package/dist/.pikku/queue/pikku-queue-types.gen.d.ts.map +1 -0
- package/dist/.pikku/queue/pikku-queue-types.gen.js +17 -0
- package/dist/.pikku/queue/pikku-queue-types.gen.js.map +1 -0
- package/dist/.pikku/queue/pikku-queue-types.gen.ts +27 -0
- package/dist/.pikku/rpc/pikku-rpc-wirings-map.gen.d.ts +81 -62
- package/dist/.pikku/rpc/pikku-rpc-wirings-map.internal.gen.d.ts +84 -65
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.d.ts +2 -0
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.d.ts.map +1 -0
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.js +7 -0
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.js.map +1 -0
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.json +6 -0
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.ts +6 -0
- package/dist/.pikku/scheduler/pikku-scheduler-types.gen.d.ts +22 -0
- package/dist/.pikku/scheduler/pikku-scheduler-types.gen.d.ts.map +1 -0
- package/dist/.pikku/scheduler/pikku-scheduler-types.gen.js +17 -0
- package/dist/.pikku/scheduler/pikku-scheduler-types.gen.js.map +1 -0
- package/dist/.pikku/scheduler/pikku-scheduler-types.gen.ts +25 -0
- package/dist/.pikku/schemas/register.gen.js +11 -11
- package/dist/.pikku/schemas/register.gen.js.map +1 -1
- package/dist/.pikku/schemas/register.gen.ts +17 -17
- package/dist/.pikku/secrets/pikku-secret-types.gen.d.ts +1 -1
- package/dist/.pikku/secrets/pikku-secret-types.gen.js +1 -1
- package/dist/.pikku/secrets/pikku-secret-types.gen.ts +1 -1
- package/dist/.pikku/secrets/pikku-secrets.gen.d.ts +1 -1
- package/dist/.pikku/secrets/pikku-secrets.gen.js +1 -1
- package/dist/.pikku/secrets/pikku-secrets.gen.ts +1 -1
- package/dist/.pikku/trigger/pikku-trigger-types.gen.d.ts +1 -1
- package/dist/.pikku/trigger/pikku-trigger-types.gen.js +1 -1
- package/dist/.pikku/trigger/pikku-trigger-types.gen.ts +1 -1
- package/dist/.pikku/variables/pikku-variable-types.gen.d.ts +1 -1
- package/dist/.pikku/variables/pikku-variable-types.gen.js +1 -1
- package/dist/.pikku/variables/pikku-variable-types.gen.ts +1 -1
- package/dist/.pikku/variables/pikku-variables-meta.gen.json +1 -1
- package/dist/.pikku/variables/pikku-variables.gen.d.ts +1 -1
- package/dist/.pikku/variables/pikku-variables.gen.js +1 -1
- package/dist/.pikku/variables/pikku-variables.gen.ts +1 -1
- package/dist/.pikku/workflow/pikku-workflow-map.gen.d.ts +9 -5
- package/dist/.pikku/workflow/pikku-workflow-types.gen.d.ts +36 -27
- package/dist/.pikku/workflow/pikku-workflow-types.gen.d.ts.map +1 -1
- package/dist/.pikku/workflow/pikku-workflow-types.gen.js +5 -18
- package/dist/.pikku/workflow/pikku-workflow-types.gen.js.map +1 -1
- package/dist/.pikku/workflow/pikku-workflow-types.gen.ts +66 -57
- package/dist/.pikku/workflow/pikku-workflow-wirings-meta.gen.js +1 -1
- package/dist/.pikku/workflow/pikku-workflow-wirings-meta.gen.ts +1 -1
- package/dist/.pikku/workflow/pikku-workflow-wirings.gen.d.ts +1 -1
- package/dist/.pikku/workflow/pikku-workflow-wirings.gen.js +1 -1
- package/dist/.pikku/workflow/pikku-workflow-wirings.gen.ts +1 -1
- package/dist/src/functions/embeddings/embed-many.function.d.ts +3 -0
- package/dist/src/functions/embeddings/embed-many.function.d.ts.map +1 -1
- package/dist/src/functions/embeddings/embed-many.function.js +1 -1
- package/dist/src/functions/embeddings/embed-many.function.js.map +1 -1
- package/dist/src/functions/embeddings/embed.function.d.ts +3 -0
- package/dist/src/functions/embeddings/embed.function.d.ts.map +1 -1
- package/dist/src/functions/embeddings/embed.function.js +1 -1
- package/dist/src/functions/embeddings/embed.function.js.map +1 -1
- package/dist/src/functions/text/generate-object.function.d.ts +17 -4
- package/dist/src/functions/text/generate-object.function.d.ts.map +1 -1
- package/dist/src/functions/text/generate-object.function.js +2 -2
- package/dist/src/functions/text/generate-object.function.js.map +1 -1
- package/dist/src/functions/text/generate.function.d.ts +13 -0
- package/dist/src/functions/text/generate.function.d.ts.map +1 -1
- package/dist/src/functions/text/generate.function.js +2 -2
- package/dist/src/functions/text/generate.function.js.map +1 -1
- package/package.json +8 -8
- package/.pikku/agent/pikku-agent-wirings-meta.gen.json +0 -3
- package/.pikku/agent/pikku-agent-wirings-meta.gen.ts +0 -7
- package/.pikku/agent/pikku-agent-wirings.gen.ts +0 -3
- package/.pikku/console/pikku-nodes-meta.gen.json +0 -57
- package/dist/.pikku/agent/pikku-agent-wirings-meta.gen.d.ts +0 -2
- package/dist/.pikku/agent/pikku-agent-wirings-meta.gen.d.ts.map +0 -1
- package/dist/.pikku/agent/pikku-agent-wirings-meta.gen.js +0 -7
- package/dist/.pikku/agent/pikku-agent-wirings-meta.gen.js.map +0 -1
- package/dist/.pikku/agent/pikku-agent-wirings-meta.gen.json +0 -3
- package/dist/.pikku/agent/pikku-agent-wirings-meta.gen.ts +0 -7
- package/dist/.pikku/agent/pikku-agent-wirings.gen.d.ts +0 -5
- package/dist/.pikku/agent/pikku-agent-wirings.gen.d.ts.map +0 -1
- package/dist/.pikku/agent/pikku-agent-wirings.gen.js +0 -5
- package/dist/.pikku/agent/pikku-agent-wirings.gen.js.map +0 -1
- package/dist/.pikku/agent/pikku-agent-wirings.gen.ts +0 -3
- 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.
|
|
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 {
|
|
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
|
-
*
|
|
154
|
-
*
|
|
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
|
|
158
|
-
* @param rpcName - The name of the
|
|
159
|
-
* @returns A Pikku function that proxies calls
|
|
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
|
-
* //
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
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
|
|
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
|
|
219
|
-
|
|
220
|
-
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
|
269
|
-
|
|
281
|
+
export const addTagMiddleware = (tag, middleware) => {
|
|
282
|
+
addTagMiddlewareCore(tag, middleware, '@pikku/addon-ollama');
|
|
270
283
|
};
|
|
271
284
|
/**
|
|
272
|
-
*
|
|
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
|
-
*
|
|
275
|
-
* any wiring (HTTP, Channel, Queue, Scheduler, MCP) that includes the matching tag.
|
|
288
|
+
* Resolution order: global -> wire -> tag -> function.
|
|
276
289
|
*
|
|
277
|
-
* @
|
|
278
|
-
*
|
|
279
|
-
|
|
280
|
-
|
|
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
|
-
*
|
|
284
|
-
|
|
285
|
-
|
|
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
|
-
*
|
|
288
|
-
* addPermission('auth', [authPermission])
|
|
309
|
+
* Resolution order: global -> wire -> tag -> function.
|
|
289
310
|
*
|
|
290
|
-
*
|
|
291
|
-
*
|
|
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
|
-
|
|
295
|
-
|
|
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
|
|
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;
|
|
1
|
+
{"version":3,"file":"pikku-function-types.gen.js","sourceRoot":"","sources":["../../../.pikku/function/pikku-function-types.gen.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;GAEG;AAIH,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACjE,OAAO,EACL,gBAAgB,IAAI,oBAAoB,EACxC,mBAAmB,IAAI,uBAAuB,EAC9C,gBAAgB,IAAI,oBAAoB,EACxC,mBAAmB,IAAI,uBAAuB,GAC/C,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,UAAU,IAAI,YAAY,EAAsB,MAAM,sBAAsB,CAAA;AAyDrF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAA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C3I,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.
|
|
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 {
|
|
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
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
RequiredWires
|
|
308
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
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
|
-
|
|
391
|
-
|
|
461
|
+
SchemaInferred<InputSchema>,
|
|
462
|
+
SchemaInferred<OutputSchema>,
|
|
392
463
|
RequiredWires
|
|
393
464
|
>
|
|
394
|
-
|
|
395
|
-
permissions?: CorePermissionGroup<PikkuPermission<InferSchemaOutput<InputSchema>>>
|
|
396
|
-
middleware?: PikkuMiddleware[]
|
|
397
|
-
input: InputSchema
|
|
465
|
+
input?: InputSchema
|
|
398
466
|
output?: OutputSchema
|
|
399
|
-
|
|
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
|
|
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
|
-
*
|
|
478
|
-
*
|
|
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
|
|
482
|
-
* @param rpcName - The name of the
|
|
483
|
-
* @returns A Pikku function that proxies calls
|
|
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
|
-
* //
|
|
488
|
-
*
|
|
489
|
-
*
|
|
490
|
-
*
|
|
491
|
-
*
|
|
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
|
|
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
|
|
560
|
-
|
|
561
|
-
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
|
617
|
-
|
|
683
|
+
export const addTagMiddleware = (tag: string, middleware: PikkuMiddleware[]) => {
|
|
684
|
+
addTagMiddlewareCore(tag, middleware as any, '@pikku/addon-ollama')
|
|
618
685
|
}
|
|
619
686
|
|
|
620
687
|
/**
|
|
621
|
-
*
|
|
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
|
-
*
|
|
624
|
-
* any wiring (HTTP, Channel, Queue, Scheduler, MCP) that includes the matching tag.
|
|
691
|
+
* Resolution order: global -> wire -> tag -> function.
|
|
625
692
|
*
|
|
626
|
-
* @
|
|
627
|
-
*
|
|
628
|
-
|
|
629
|
-
|
|
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
|
-
*
|
|
633
|
-
|
|
634
|
-
|
|
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
|
-
*
|
|
637
|
-
* addPermission('auth', [authPermission])
|
|
714
|
+
* Resolution order: global -> wire -> tag -> function.
|
|
638
715
|
*
|
|
639
|
-
*
|
|
640
|
-
*
|
|
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
|
-
|
|
644
|
-
|
|
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
|
|
648
|
-
|
|
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]
|