@pikku/core 0.10.2 → 0.11.1
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/CHANGELOG.md +19 -0
- package/dist/errors/errors.d.ts +1 -1
- package/dist/errors/errors.js +3 -3
- package/dist/function/function-runner.d.ts +6 -7
- package/dist/function/function-runner.js +35 -16
- package/dist/function/functions.types.d.ts +23 -30
- package/dist/function/functions.types.js +9 -6
- package/dist/handle-error.d.ts +1 -1
- package/dist/handle-error.js +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/middleware/auth-apikey.d.ts +1 -0
- package/dist/middleware/auth-apikey.js +3 -3
- package/dist/middleware/auth-bearer.d.ts +1 -0
- package/dist/middleware/auth-bearer.js +3 -3
- package/dist/middleware/auth-cookie.d.ts +1 -0
- package/dist/middleware/auth-cookie.js +5 -5
- package/dist/middleware/timeout.d.ts +1 -0
- package/dist/middleware/timeout.js +3 -2
- package/dist/middleware-runner.d.ts +3 -6
- package/dist/middleware-runner.js +11 -11
- package/dist/permissions.d.ts +6 -6
- package/dist/permissions.js +15 -15
- package/dist/pikku-state.d.ts +7 -2
- package/dist/pikku-state.js +4 -0
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.js +1 -0
- package/dist/services/scheduler-service.d.ts +63 -0
- package/dist/services/scheduler-service.js +6 -0
- package/dist/services/user-session-service.d.ts +7 -3
- package/dist/services/user-session-service.js +8 -1
- package/dist/time-utils.d.ts +14 -0
- package/dist/time-utils.js +62 -0
- package/dist/types/core.types.d.ts +48 -35
- package/dist/types/core.types.js +3 -13
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +3 -3
- package/dist/wirings/channel/channel-common.js +2 -3
- package/dist/wirings/channel/channel-handler.d.ts +3 -2
- package/dist/wirings/channel/channel-handler.js +6 -9
- package/dist/wirings/channel/channel-runner.d.ts +2 -2
- package/dist/wirings/channel/channel.types.d.ts +10 -5
- package/dist/wirings/channel/local/local-channel-runner.d.ts +1 -1
- package/dist/wirings/channel/local/local-channel-runner.js +19 -26
- package/dist/wirings/channel/serverless/serverless-channel-runner.d.ts +1 -1
- package/dist/wirings/channel/serverless/serverless-channel-runner.js +41 -46
- package/dist/wirings/cli/channel/cli-channel-runner.js +1 -1
- package/dist/wirings/cli/cli-runner.d.ts +5 -5
- package/dist/wirings/cli/cli-runner.js +11 -29
- package/dist/wirings/cli/cli.types.d.ts +15 -11
- package/dist/wirings/http/http-runner.d.ts +6 -6
- package/dist/wirings/http/http-runner.js +25 -39
- package/dist/wirings/http/http.types.d.ts +5 -10
- package/dist/wirings/mcp/mcp-runner.d.ts +2 -2
- package/dist/wirings/mcp/mcp-runner.js +12 -19
- package/dist/wirings/mcp/mcp.types.d.ts +6 -0
- package/dist/wirings/queue/queue-runner.d.ts +3 -3
- package/dist/wirings/queue/queue-runner.js +7 -14
- package/dist/wirings/queue/queue.types.d.ts +4 -13
- package/dist/wirings/rpc/index.d.ts +1 -1
- package/dist/wirings/rpc/index.js +1 -1
- package/dist/wirings/rpc/rpc-runner.d.ts +13 -7
- package/dist/wirings/rpc/rpc-runner.js +50 -26
- package/dist/wirings/rpc/rpc-types.d.ts +1 -0
- package/dist/wirings/scheduler/scheduler-runner.d.ts +3 -3
- package/dist/wirings/scheduler/scheduler-runner.js +13 -24
- package/dist/wirings/scheduler/scheduler.types.d.ts +3 -8
- package/dist/wirings/workflow/index.d.ts +15 -0
- package/dist/wirings/workflow/index.js +14 -0
- package/dist/wirings/workflow/pikku-workflow-service.d.ts +160 -0
- package/dist/wirings/workflow/pikku-workflow-service.js +430 -0
- package/dist/wirings/workflow/workflow-runner.d.ts +34 -0
- package/dist/wirings/workflow/workflow-runner.js +65 -0
- package/dist/wirings/workflow/workflow.types.d.ts +332 -0
- package/dist/wirings/workflow/workflow.types.js +1 -0
- package/package.json +3 -4
- package/src/errors/errors.ts +3 -3
- package/src/factory-functions.test.ts +9 -36
- package/src/function/function-runner.test.ts +57 -68
- package/src/function/function-runner.ts +51 -28
- package/src/function/function-runner.ts.bak +188 -0
- package/src/function/functions.types.ts +69 -51
- package/src/handle-error.ts +1 -1
- package/src/index.ts +2 -0
- package/src/middleware/auth-apikey.test.ts +360 -0
- package/src/middleware/auth-apikey.ts +3 -7
- package/src/middleware/auth-bearer.test.ts +447 -0
- package/src/middleware/auth-bearer.ts +27 -33
- package/src/middleware/auth-cookie.test.ts +525 -0
- package/src/middleware/auth-cookie.ts +6 -6
- package/src/middleware/timeout.ts +4 -2
- package/src/middleware-runner.test.ts +58 -127
- package/src/middleware-runner.ts +13 -15
- package/src/permissions.test.ts +41 -45
- package/src/permissions.ts +21 -20
- package/src/pikku-state.ts +14 -2
- package/src/services/index.ts +1 -0
- package/src/services/scheduler-service.ts +76 -0
- package/src/services/user-session-service.ts +14 -4
- package/src/time-utils.ts +75 -0
- package/src/types/core.types.ts +92 -51
- package/src/utils.ts +4 -4
- package/src/wirings/channel/channel-common.ts +4 -7
- package/src/wirings/channel/channel-handler.ts +16 -22
- package/src/wirings/channel/channel-runner.ts +2 -2
- package/src/wirings/channel/channel.types.ts +14 -11
- package/src/wirings/channel/local/local-channel-runner.test.ts +5 -3
- package/src/wirings/channel/local/local-channel-runner.ts +23 -38
- package/src/wirings/channel/serverless/serverless-channel-runner.ts +51 -77
- package/src/wirings/cli/channel/cli-channel-runner.ts +1 -1
- package/src/wirings/cli/cli-runner.test.ts +7 -7
- package/src/wirings/cli/cli-runner.ts +25 -63
- package/src/wirings/cli/cli.types.ts +22 -16
- package/src/wirings/http/http-runner.test.ts +8 -8
- package/src/wirings/http/http-runner.ts +29 -56
- package/src/wirings/http/http.types.ts +5 -14
- package/src/wirings/mcp/mcp-runner.ts +23 -48
- package/src/wirings/mcp/mcp.types.ts +6 -0
- package/src/wirings/queue/queue-runner.test.ts +641 -0
- package/src/wirings/queue/queue-runner.ts +10 -24
- package/src/wirings/queue/queue.types.ts +5 -15
- package/src/wirings/rpc/index.ts +1 -1
- package/src/wirings/rpc/rpc-runner.ts +71 -32
- package/src/wirings/rpc/rpc-types.ts +1 -0
- package/src/wirings/scheduler/scheduler-runner.test.ts +627 -0
- package/src/wirings/scheduler/scheduler-runner.ts +24 -50
- package/src/wirings/scheduler/scheduler.types.ts +3 -9
- package/src/wirings/workflow/index.ts +43 -0
- package/src/wirings/workflow/pikku-workflow-service.ts +746 -0
- package/src/wirings/workflow/workflow-runner.ts +72 -0
- package/src/wirings/workflow/workflow.types.ts +422 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/services/file-channel-store.d.ts +0 -19
- package/dist/services/file-channel-store.js +0 -69
- package/dist/services/file-eventhub-store.d.ts +0 -17
- package/dist/services/file-eventhub-store.js +0 -71
- package/src/services/file-channel-store.ts +0 -86
- package/src/services/file-eventhub-store.ts +0 -90
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
PikkuWiringTypes,
|
|
2
|
+
PikkuWire,
|
|
4
3
|
type CoreServices,
|
|
5
4
|
type CoreSingletonServices,
|
|
6
5
|
type CoreUserSession,
|
|
7
|
-
type
|
|
6
|
+
type CreateWireServices,
|
|
8
7
|
} from '../../types/core.types.js'
|
|
9
8
|
import type {
|
|
10
9
|
CoreMCPResource,
|
|
@@ -20,11 +19,11 @@ import type {
|
|
|
20
19
|
CorePikkuFunctionSessionless,
|
|
21
20
|
} from '../../function/functions.types.js'
|
|
22
21
|
import { getErrorResponse } from '../../errors/error-handler.js'
|
|
23
|
-
import {
|
|
22
|
+
import { closeWireServices } from '../../utils.js'
|
|
24
23
|
import { pikkuState } from '../../pikku-state.js'
|
|
25
24
|
import { addFunction, runPikkuFunc } from '../../function/function-runner.js'
|
|
26
|
-
import { rpcService } from '../rpc/rpc-runner.js'
|
|
27
25
|
import { BadRequestError, NotFoundError } from '../../errors/errors.js'
|
|
26
|
+
import { PikkuSessionService } from '../../services/user-session-service.js'
|
|
28
27
|
|
|
29
28
|
export class MCPError extends Error {
|
|
30
29
|
constructor(public readonly error: JsonRpcErrorResponse) {
|
|
@@ -37,7 +36,7 @@ export class MCPError extends Error {
|
|
|
37
36
|
export type RunMCPEndpointParams<Tools extends string = any> = {
|
|
38
37
|
singletonServices: CoreSingletonServices
|
|
39
38
|
mcp?: PikkuMCP<Tools>
|
|
40
|
-
|
|
39
|
+
createWireServices?: CreateWireServices<
|
|
41
40
|
CoreSingletonServices,
|
|
42
41
|
CoreServices<CoreSingletonServices>,
|
|
43
42
|
CoreUserSession
|
|
@@ -209,13 +208,9 @@ async function runMCPPikkuFunc(
|
|
|
209
208
|
name: string,
|
|
210
209
|
mcp: CoreMCPResource | CoreMCPTool | CoreMCPPrompt | undefined,
|
|
211
210
|
pikkuFuncName: string | undefined,
|
|
212
|
-
{
|
|
213
|
-
singletonServices,
|
|
214
|
-
createSessionServices,
|
|
215
|
-
mcp: mcpInteraction,
|
|
216
|
-
}: RunMCPEndpointParams
|
|
211
|
+
{ singletonServices, createWireServices, mcp: mcpWire }: RunMCPEndpointParams
|
|
217
212
|
): Promise<JsonRpcResponse> {
|
|
218
|
-
let
|
|
213
|
+
let wireServices: any
|
|
219
214
|
|
|
220
215
|
try {
|
|
221
216
|
// Validate JSON-RPC request structure
|
|
@@ -239,23 +234,9 @@ async function runMCPPikkuFunc(
|
|
|
239
234
|
|
|
240
235
|
singletonServices.logger.debug(`Running MCP ${type}: ${name}`)
|
|
241
236
|
|
|
242
|
-
const
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
sessionServices = await createSessionServices?.(
|
|
246
|
-
singletonServices,
|
|
247
|
-
interaction,
|
|
248
|
-
undefined
|
|
249
|
-
)
|
|
250
|
-
|
|
251
|
-
return rpcService.injectRPCService(
|
|
252
|
-
{
|
|
253
|
-
...singletonServices,
|
|
254
|
-
...sessionServices,
|
|
255
|
-
mcp: mcpInteraction,
|
|
256
|
-
},
|
|
257
|
-
interaction
|
|
258
|
-
)
|
|
237
|
+
const wire: PikkuWire = {
|
|
238
|
+
mcp: mcpWire,
|
|
239
|
+
session: new PikkuSessionService(),
|
|
259
240
|
}
|
|
260
241
|
|
|
261
242
|
// Get metadata for the MCP endpoint to access pre-resolved middleware
|
|
@@ -268,23 +249,17 @@ async function runMCPPikkuFunc(
|
|
|
268
249
|
meta = pikkuState('mcp', 'promptsMeta')[name]
|
|
269
250
|
}
|
|
270
251
|
|
|
271
|
-
const result = await runPikkuFunc(
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
inheritedPermissions: meta?.permissions,
|
|
283
|
-
wirePermissions: mcp.permissions,
|
|
284
|
-
tags: mcp.tags,
|
|
285
|
-
interaction,
|
|
286
|
-
}
|
|
287
|
-
)
|
|
252
|
+
const result = await runPikkuFunc('mcp', `${type}:${name}`, pikkuFuncName, {
|
|
253
|
+
singletonServices,
|
|
254
|
+
createWireServices,
|
|
255
|
+
data: () => request.params,
|
|
256
|
+
inheritedMiddleware: meta?.middleware,
|
|
257
|
+
wireMiddleware: mcp.middleware,
|
|
258
|
+
inheritedPermissions: meta?.permissions,
|
|
259
|
+
wirePermissions: mcp.permissions,
|
|
260
|
+
tags: mcp.tags,
|
|
261
|
+
wire,
|
|
262
|
+
})
|
|
288
263
|
|
|
289
264
|
return {
|
|
290
265
|
id: request.id,
|
|
@@ -316,8 +291,8 @@ async function runMCPPikkuFunc(
|
|
|
316
291
|
})
|
|
317
292
|
}
|
|
318
293
|
} finally {
|
|
319
|
-
if (
|
|
320
|
-
await
|
|
294
|
+
if (wireServices) {
|
|
295
|
+
await closeWireServices(singletonServices.logger, wireServices)
|
|
321
296
|
}
|
|
322
297
|
}
|
|
323
298
|
}
|
|
@@ -104,6 +104,8 @@ export type CoreMCPResource<
|
|
|
104
104
|
uri: string
|
|
105
105
|
title: string
|
|
106
106
|
description: string
|
|
107
|
+
summary?: string
|
|
108
|
+
errors?: string[]
|
|
107
109
|
mimeType?: string
|
|
108
110
|
size?: number
|
|
109
111
|
streaming?: boolean
|
|
@@ -126,6 +128,8 @@ export type CoreMCPTool<
|
|
|
126
128
|
name: string
|
|
127
129
|
title?: string
|
|
128
130
|
description: string
|
|
131
|
+
summary?: string
|
|
132
|
+
errors?: string[]
|
|
129
133
|
func: PikkuFunctionConfig
|
|
130
134
|
tags?: string[]
|
|
131
135
|
streaming?: boolean
|
|
@@ -145,6 +149,8 @@ export type CoreMCPPrompt<
|
|
|
145
149
|
> = {
|
|
146
150
|
name: string
|
|
147
151
|
description: string
|
|
152
|
+
summary?: string
|
|
153
|
+
errors?: string[]
|
|
148
154
|
func: PikkuFunctionConfig
|
|
149
155
|
tags?: string[]
|
|
150
156
|
middleware?: PikkuMiddleware[]
|