@pikku/core 0.8.2 → 0.9.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 +13 -1
- package/dist/function/functions.types.d.ts +9 -9
- package/dist/handle-error.d.ts +1 -1
- package/dist/index.d.ts +11 -10
- package/dist/index.js +11 -10
- package/dist/pikku-state.d.ts +9 -9
- package/dist/services/user-session-service.d.ts +1 -1
- package/dist/types/core.types.d.ts +5 -5
- package/dist/types/core.types.js +9 -9
- package/dist/wirings/channel/channel-handler.d.ts +3 -0
- package/dist/{events → wirings}/channel/channel-handler.js +3 -3
- package/dist/wirings/channel/channel-runner.d.ts +14 -0
- package/dist/{events → wirings}/channel/channel-runner.js +13 -13
- package/dist/{events → wirings}/channel/channel.types.d.ts +7 -7
- package/dist/{events → wirings}/channel/eventhub-service.d.ts +4 -4
- package/dist/wirings/channel/eventhub-store.d.ts +5 -0
- package/dist/wirings/channel/local/local-channel-runner.d.ts +3 -0
- package/dist/{events → wirings}/channel/local/local-eventhub-service.d.ts +4 -4
- package/dist/{events → wirings}/channel/local/local-eventhub-service.js +1 -1
- package/dist/{events → wirings}/channel/serverless/serverless-channel-runner.d.ts +2 -2
- package/dist/{events → wirings}/http/http-runner.d.ts +12 -12
- package/dist/{events → wirings}/http/http-runner.js +15 -15
- package/dist/{events → wirings}/http/http.types.d.ts +32 -27
- package/dist/{events → wirings}/http/index.d.ts +1 -1
- package/dist/{events → wirings}/http/index.js +1 -1
- package/dist/{events → wirings}/mcp/mcp-runner.d.ts +4 -4
- package/dist/{events → wirings}/mcp/mcp-runner.js +3 -3
- package/dist/{events → wirings}/mcp/mcp.types.d.ts +7 -7
- package/dist/{events → wirings}/queue/index.d.ts +1 -1
- package/dist/{events → wirings}/queue/index.js +1 -1
- package/dist/{events → wirings}/queue/queue-runner.d.ts +2 -2
- package/dist/{events → wirings}/queue/queue-runner.js +1 -1
- package/dist/{events → wirings}/queue/queue.types.d.ts +3 -3
- package/dist/wirings/scheduler/index.d.ts +3 -0
- package/dist/wirings/scheduler/index.js +3 -0
- package/dist/{events → wirings}/scheduler/scheduler-runner.d.ts +2 -2
- package/dist/{events → wirings}/scheduler/scheduler-runner.js +1 -1
- package/dist/{events → wirings}/scheduler/scheduler.types.d.ts +3 -3
- package/package.json +9 -9
- package/src/function/functions.types.ts +13 -13
- package/src/handle-error.ts +1 -1
- package/src/index.ts +14 -13
- package/src/pikku-state.ts +11 -11
- package/src/services/user-session-service.ts +1 -1
- package/src/types/core.types.ts +5 -5
- package/src/{events → wirings}/channel/channel-handler.ts +5 -5
- package/src/{events → wirings}/channel/channel-runner.ts +18 -18
- package/src/{events → wirings}/channel/channel.types.ts +16 -16
- package/src/{events → wirings}/channel/eventhub-service.ts +12 -8
- package/src/wirings/channel/eventhub-store.ts +13 -0
- package/src/{events → wirings}/channel/local/local-channel-runner.test.ts +2 -2
- package/src/{events → wirings}/channel/local/local-channel-runner.ts +2 -2
- package/src/{events → wirings}/channel/local/local-eventhub-service.ts +16 -10
- package/src/{events → wirings}/channel/serverless/serverless-channel-runner.ts +2 -2
- package/src/{events → wirings}/http/http-runner.test.ts +4 -4
- package/src/{events → wirings}/http/http-runner.ts +32 -31
- package/src/{events → wirings}/http/http.types.ts +40 -35
- package/src/{events → wirings}/http/index.ts +1 -1
- package/src/{events → wirings}/mcp/mcp-runner.ts +10 -10
- package/src/{events → wirings}/mcp/mcp.types.ts +9 -7
- package/src/{events → wirings}/queue/index.ts +1 -1
- package/src/{events → wirings}/queue/queue-runner.ts +5 -5
- package/src/{events → wirings}/queue/queue.types.ts +3 -3
- package/src/{events → wirings}/scheduler/index.ts +1 -1
- package/src/{events → wirings}/scheduler/scheduler-runner.ts +4 -4
- package/src/{events → wirings}/scheduler/scheduler.types.ts +3 -3
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/events/channel/channel-handler.d.ts +0 -3
- package/dist/events/channel/channel-runner.d.ts +0 -14
- package/dist/events/channel/eventhub-store.d.ts +0 -5
- package/dist/events/channel/local/local-channel-runner.d.ts +0 -3
- package/dist/events/scheduler/index.d.ts +0 -3
- package/dist/events/scheduler/index.js +0 -3
- package/src/events/channel/eventhub-store.ts +0 -8
- /package/dist/{events → wirings}/channel/channel-store.d.ts +0 -0
- /package/dist/{events → wirings}/channel/channel-store.js +0 -0
- /package/dist/{events → wirings}/channel/channel.types.js +0 -0
- /package/dist/{events → wirings}/channel/eventhub-service.js +0 -0
- /package/dist/{events → wirings}/channel/eventhub-store.js +0 -0
- /package/dist/{events → wirings}/channel/index.d.ts +0 -0
- /package/dist/{events → wirings}/channel/index.js +0 -0
- /package/dist/{events → wirings}/channel/local/index.d.ts +0 -0
- /package/dist/{events → wirings}/channel/local/index.js +0 -0
- /package/dist/{events → wirings}/channel/local/local-channel-handler.d.ts +0 -0
- /package/dist/{events → wirings}/channel/local/local-channel-handler.js +0 -0
- /package/dist/{events → wirings}/channel/local/local-channel-runner.js +0 -0
- /package/dist/{events → wirings}/channel/log-channels.d.ts +0 -0
- /package/dist/{events → wirings}/channel/log-channels.js +0 -0
- /package/dist/{events → wirings}/channel/pikku-abstract-channel-handler.d.ts +0 -0
- /package/dist/{events → wirings}/channel/pikku-abstract-channel-handler.js +0 -0
- /package/dist/{events → wirings}/channel/serverless/index.d.ts +0 -0
- /package/dist/{events → wirings}/channel/serverless/index.js +0 -0
- /package/dist/{events → wirings}/channel/serverless/serverless-channel-runner.js +0 -0
- /package/dist/{events → wirings}/http/http.types.js +0 -0
- /package/dist/{events → wirings}/http/log-http-routes.d.ts +0 -0
- /package/dist/{events → wirings}/http/log-http-routes.js +0 -0
- /package/dist/{events → wirings}/http/pikku-fetch-http-request.d.ts +0 -0
- /package/dist/{events → wirings}/http/pikku-fetch-http-request.js +0 -0
- /package/dist/{events → wirings}/http/pikku-fetch-http-response.d.ts +0 -0
- /package/dist/{events → wirings}/http/pikku-fetch-http-response.js +0 -0
- /package/dist/{events → wirings}/mcp/index.d.ts +0 -0
- /package/dist/{events → wirings}/mcp/index.js +0 -0
- /package/dist/{events → wirings}/mcp/mcp-endpoint-registry.d.ts +0 -0
- /package/dist/{events → wirings}/mcp/mcp-endpoint-registry.js +0 -0
- /package/dist/{events → wirings}/mcp/mcp.types.js +0 -0
- /package/dist/{events → wirings}/queue/queue.types.js +0 -0
- /package/dist/{events → wirings}/queue/register-queue-helper.d.ts +0 -0
- /package/dist/{events → wirings}/queue/register-queue-helper.js +0 -0
- /package/dist/{events → wirings}/queue/validate-worker-config.d.ts +0 -0
- /package/dist/{events → wirings}/queue/validate-worker-config.js +0 -0
- /package/dist/{events → wirings}/rpc/index.d.ts +0 -0
- /package/dist/{events → wirings}/rpc/index.js +0 -0
- /package/dist/{events → wirings}/rpc/rpc-runner.d.ts +0 -0
- /package/dist/{events → wirings}/rpc/rpc-runner.js +0 -0
- /package/dist/{events → wirings}/rpc/rpc-types.d.ts +0 -0
- /package/dist/{events → wirings}/rpc/rpc-types.js +0 -0
- /package/dist/{events → wirings}/scheduler/log-schedulers.d.ts +0 -0
- /package/dist/{events → wirings}/scheduler/log-schedulers.js +0 -0
- /package/dist/{events → wirings}/scheduler/scheduler.types.js +0 -0
- /package/src/{events → wirings}/channel/channel-store.ts +0 -0
- /package/src/{events → wirings}/channel/index.ts +0 -0
- /package/src/{events → wirings}/channel/local/index.ts +0 -0
- /package/src/{events → wirings}/channel/local/local-channel-handler.ts +0 -0
- /package/src/{events → wirings}/channel/local/local-eventhub-service.test.ts +0 -0
- /package/src/{events → wirings}/channel/log-channels.ts +0 -0
- /package/src/{events → wirings}/channel/pikku-abstract-channel-handler.test.ts +0 -0
- /package/src/{events → wirings}/channel/pikku-abstract-channel-handler.ts +0 -0
- /package/src/{events → wirings}/channel/serverless/index.ts +0 -0
- /package/src/{events → wirings}/http/log-http-routes.ts +0 -0
- /package/src/{events → wirings}/http/pikku-fetch-http-request.test.ts +0 -0
- /package/src/{events → wirings}/http/pikku-fetch-http-request.ts +0 -0
- /package/src/{events → wirings}/http/pikku-fetch-http-response.test.ts +0 -0
- /package/src/{events → wirings}/http/pikku-fetch-http-response.ts +0 -0
- /package/src/{events → wirings}/mcp/index.ts +0 -0
- /package/src/{events → wirings}/mcp/mcp-endpoint-registry.test.d.ts +0 -0
- /package/src/{events → wirings}/mcp/mcp-endpoint-registry.test.ts +0 -0
- /package/src/{events → wirings}/mcp/mcp-endpoint-registry.ts +0 -0
- /package/src/{events → wirings}/queue/register-queue-helper.ts +0 -0
- /package/src/{events → wirings}/queue/validate-worker-config.ts +0 -0
- /package/src/{events → wirings}/rpc/index.ts +0 -0
- /package/src/{events → wirings}/rpc/rpc-runner.ts +0 -0
- /package/src/{events → wirings}/rpc/rpc-types.ts +0 -0
- /package/src/{events → wirings}/scheduler/log-schedulers.ts +0 -0
|
@@ -9,25 +9,30 @@ import type {
|
|
|
9
9
|
PikkuMiddleware,
|
|
10
10
|
} from '../../types/core.types.js'
|
|
11
11
|
import type {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
CorePikkuFunction,
|
|
13
|
+
CorePikkuFunctionSessionless,
|
|
14
|
+
CorePikkuPermission,
|
|
15
15
|
CorePermissionGroup,
|
|
16
16
|
} from '../../function/functions.types.js'
|
|
17
17
|
|
|
18
|
-
type
|
|
18
|
+
type ExtractHTTPWiringParams<S extends string> =
|
|
19
19
|
S extends `${string}:${infer Param}/${infer Rest}`
|
|
20
|
-
? Param |
|
|
20
|
+
? Param | ExtractHTTPWiringParams<`/${Rest}`>
|
|
21
21
|
: S extends `${string}:${infer Param}`
|
|
22
22
|
? Param
|
|
23
23
|
: never
|
|
24
24
|
|
|
25
|
-
export type
|
|
26
|
-
|
|
25
|
+
export type AssertHTTPWiringParams<In, HTTPWiring extends string> =
|
|
26
|
+
ExtractHTTPWiringParams<HTTPWiring> extends keyof In
|
|
27
27
|
? unknown
|
|
28
|
-
: [
|
|
28
|
+
: [
|
|
29
|
+
'Error: HTTPWiring parameters',
|
|
30
|
+
ExtractHTTPWiringParams<HTTPWiring>,
|
|
31
|
+
'not in',
|
|
32
|
+
keyof In,
|
|
33
|
+
]
|
|
29
34
|
|
|
30
|
-
export type
|
|
35
|
+
export type RunHTTPWiringOptions = Partial<{
|
|
31
36
|
skipUserSession: boolean
|
|
32
37
|
respondWith404: boolean
|
|
33
38
|
logWarningsForStatusCodes: number[]
|
|
@@ -37,7 +42,7 @@ export type RunRouteOptions = Partial<{
|
|
|
37
42
|
ignoreMiddleware: boolean
|
|
38
43
|
}>
|
|
39
44
|
|
|
40
|
-
export type
|
|
45
|
+
export type RunHTTPWiringParams = {
|
|
41
46
|
singletonServices: CoreSingletonServices
|
|
42
47
|
createSessionServices: CreateSessionServices<
|
|
43
48
|
CoreSingletonServices,
|
|
@@ -47,8 +52,8 @@ export type RunRouteParams = {
|
|
|
47
52
|
}
|
|
48
53
|
|
|
49
54
|
/**
|
|
50
|
-
* Represents the HTTP methods supported for API
|
|
51
|
-
*/
|
|
55
|
+
* Represents the HTTP methods supported for API HTTP wirings.
|
|
56
|
+
t */
|
|
52
57
|
export type HTTPMethod =
|
|
53
58
|
| 'post'
|
|
54
59
|
| 'get'
|
|
@@ -59,7 +64,7 @@ export type HTTPMethod =
|
|
|
59
64
|
| 'options'
|
|
60
65
|
|
|
61
66
|
/**
|
|
62
|
-
* Represents an API
|
|
67
|
+
* Represents an API HTTP wiring without a function, including metadata such as content type, route, and timeout settings.
|
|
63
68
|
*/
|
|
64
69
|
export type CoreHTTPFunction = {
|
|
65
70
|
contentType?: 'xml' | 'json'
|
|
@@ -98,29 +103,29 @@ export type PikkuQuery<T = Record<string, string | undefined>> = Record<
|
|
|
98
103
|
>
|
|
99
104
|
|
|
100
105
|
/**
|
|
101
|
-
* Represents a core API
|
|
106
|
+
* Represents a core API HTTP wiring, which can have different configurations depending on whether it requires authentication and permissions.
|
|
102
107
|
*
|
|
103
108
|
* @template In - The input type.
|
|
104
109
|
* @template Out - The output type.
|
|
105
110
|
* @template R - The route string type.
|
|
106
|
-
* @template
|
|
107
|
-
* @template
|
|
108
|
-
* @template
|
|
111
|
+
* @template PikkuFunction - The API function type, defaults to `CorePikkuFunction`.
|
|
112
|
+
* @template PikkuFunctionSessionless - The sessionless API function type, defaults to `CorePikkuFunctionSessionless`.
|
|
113
|
+
* @template PikkuPermission - The permission function type, defaults to `CorePikkuPermission`.
|
|
109
114
|
*/
|
|
110
|
-
export type
|
|
115
|
+
export type CoreHTTPFunctionWiring<
|
|
111
116
|
In,
|
|
112
117
|
Out,
|
|
113
118
|
R extends string,
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
119
|
+
PikkuFunction = CorePikkuFunction<In, Out>,
|
|
120
|
+
PikkuFunctionSessionless = CorePikkuFunctionSessionless<In, Out>,
|
|
121
|
+
PikkuPermission = CorePikkuPermission<In>,
|
|
117
122
|
APIMiddleware = PikkuMiddleware,
|
|
118
123
|
> =
|
|
119
124
|
| (CoreHTTPFunction & {
|
|
120
125
|
route: R
|
|
121
126
|
method: HTTPMethod
|
|
122
|
-
func:
|
|
123
|
-
permissions?: CorePermissionGroup<
|
|
127
|
+
func: PikkuFunction
|
|
128
|
+
permissions?: CorePermissionGroup<PikkuPermission>
|
|
124
129
|
auth?: true
|
|
125
130
|
tags?: string[]
|
|
126
131
|
middleware?: APIMiddleware[]
|
|
@@ -129,7 +134,7 @@ export type CoreHTTPFunctionRoute<
|
|
|
129
134
|
| (CoreHTTPFunction & {
|
|
130
135
|
route: R
|
|
131
136
|
method: HTTPMethod
|
|
132
|
-
func:
|
|
137
|
+
func: PikkuFunctionSessionless
|
|
133
138
|
permissions?: undefined
|
|
134
139
|
auth?: false
|
|
135
140
|
tags?: string[]
|
|
@@ -139,8 +144,8 @@ export type CoreHTTPFunctionRoute<
|
|
|
139
144
|
| (CoreHTTPFunction & {
|
|
140
145
|
route: R
|
|
141
146
|
method: 'get'
|
|
142
|
-
func:
|
|
143
|
-
permissions?: CorePermissionGroup<
|
|
147
|
+
func: PikkuFunction
|
|
148
|
+
permissions?: CorePermissionGroup<PikkuPermission>
|
|
144
149
|
auth?: true
|
|
145
150
|
sse?: boolean
|
|
146
151
|
tags?: string[]
|
|
@@ -149,7 +154,7 @@ export type CoreHTTPFunctionRoute<
|
|
|
149
154
|
| (CoreHTTPFunction & {
|
|
150
155
|
route: R
|
|
151
156
|
method: 'get'
|
|
152
|
-
func:
|
|
157
|
+
func: PikkuFunctionSessionless
|
|
153
158
|
permissions?: undefined
|
|
154
159
|
auth?: false
|
|
155
160
|
sse?: boolean
|
|
@@ -159,8 +164,8 @@ export type CoreHTTPFunctionRoute<
|
|
|
159
164
|
| (CoreHTTPFunction & {
|
|
160
165
|
route: R
|
|
161
166
|
method: 'post'
|
|
162
|
-
func:
|
|
163
|
-
permissions?: CorePermissionGroup<
|
|
167
|
+
func: PikkuFunction
|
|
168
|
+
permissions?: CorePermissionGroup<PikkuPermission>
|
|
164
169
|
auth?: true
|
|
165
170
|
query?: Array<keyof In>
|
|
166
171
|
tags?: string[]
|
|
@@ -170,7 +175,7 @@ export type CoreHTTPFunctionRoute<
|
|
|
170
175
|
| (CoreHTTPFunction & {
|
|
171
176
|
route: R
|
|
172
177
|
method: 'post'
|
|
173
|
-
func:
|
|
178
|
+
func: PikkuFunctionSessionless
|
|
174
179
|
permissions?: undefined
|
|
175
180
|
auth?: false
|
|
176
181
|
query?: Array<keyof In>
|
|
@@ -180,7 +185,7 @@ export type CoreHTTPFunctionRoute<
|
|
|
180
185
|
})
|
|
181
186
|
|
|
182
187
|
/**
|
|
183
|
-
* Represents the input types for
|
|
188
|
+
* Represents the input types for HTTP wiring metadata, including parameters, query, and body types.
|
|
184
189
|
*/
|
|
185
190
|
export type HTTPFunctionMetaInputTypes = {
|
|
186
191
|
params?: string
|
|
@@ -189,9 +194,9 @@ export type HTTPFunctionMetaInputTypes = {
|
|
|
189
194
|
}
|
|
190
195
|
|
|
191
196
|
/**
|
|
192
|
-
* Represents metadata for a set of
|
|
197
|
+
* Represents metadata for a set of HTTP wirings, including HTTP wiring details, methods, input/output types, and documentation.
|
|
193
198
|
*/
|
|
194
|
-
export type
|
|
199
|
+
export type HTTPWiringMeta = {
|
|
195
200
|
pikkuFuncName: string
|
|
196
201
|
route: string
|
|
197
202
|
method: HTTPMethod
|
|
@@ -202,7 +207,7 @@ export type HTTPRouteMeta = {
|
|
|
202
207
|
tags?: string[]
|
|
203
208
|
sse?: true
|
|
204
209
|
}
|
|
205
|
-
export type
|
|
210
|
+
export type HTTPWiringsMeta = Array<HTTPWiringMeta>
|
|
206
211
|
|
|
207
212
|
export type HTTPFunctionsMeta = Array<{
|
|
208
213
|
name: string
|
|
@@ -210,7 +215,7 @@ export type HTTPFunctionsMeta = Array<{
|
|
|
210
215
|
outputs: string[] | null
|
|
211
216
|
}>
|
|
212
217
|
|
|
213
|
-
export type
|
|
218
|
+
export type HTTPWiringMiddleware = {
|
|
214
219
|
route: string
|
|
215
220
|
middleware: PikkuMiddleware[]
|
|
216
221
|
}
|
|
@@ -2,6 +2,6 @@ export * from './pikku-fetch-http-request.js'
|
|
|
2
2
|
export * from './pikku-fetch-http-response.js'
|
|
3
3
|
export * from './log-http-routes.js'
|
|
4
4
|
|
|
5
|
-
export { fetch, fetchData,
|
|
5
|
+
export { fetch, fetchData, wireHTTP } from './http-runner.js'
|
|
6
6
|
|
|
7
7
|
export type * from './http.types.js'
|
|
@@ -13,7 +13,7 @@ import type {
|
|
|
13
13
|
JsonRpcErrorResponse,
|
|
14
14
|
PikkuMCP,
|
|
15
15
|
} from './mcp.types.js'
|
|
16
|
-
import type {
|
|
16
|
+
import type { CorePikkuFunctionSessionless } from '../../function/functions.types.js'
|
|
17
17
|
import { getErrorResponse } from '../../errors/error-handler.js'
|
|
18
18
|
import { closeSessionServices } from '../../utils.js'
|
|
19
19
|
import { pikkuState } from '../../pikku-state.js'
|
|
@@ -46,10 +46,10 @@ export type JsonRpcError = {
|
|
|
46
46
|
data?: any
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
export const
|
|
50
|
-
|
|
49
|
+
export const wireMCPResource = <
|
|
50
|
+
PikkuFunction extends CorePikkuFunctionSessionless<any, any>,
|
|
51
51
|
>(
|
|
52
|
-
mcpResource: CoreMCPResource<
|
|
52
|
+
mcpResource: CoreMCPResource<PikkuFunction>
|
|
53
53
|
) => {
|
|
54
54
|
const resourcesMeta = pikkuState('mcp', 'resourcesMeta')
|
|
55
55
|
const mcpResourceMeta = resourcesMeta[mcpResource.uri]
|
|
@@ -66,10 +66,10 @@ export const addMCPResource = <
|
|
|
66
66
|
resources.set(mcpResource.uri, mcpResource)
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
export const
|
|
70
|
-
|
|
69
|
+
export const wireMCPTool = <
|
|
70
|
+
PikkuFunction extends CorePikkuFunctionSessionless<any, any>,
|
|
71
71
|
>(
|
|
72
|
-
mcpTool: CoreMCPTool<
|
|
72
|
+
mcpTool: CoreMCPTool<PikkuFunction>
|
|
73
73
|
) => {
|
|
74
74
|
const toolsMeta = pikkuState('mcp', 'toolsMeta')
|
|
75
75
|
const mcpToolMeta = toolsMeta[mcpTool.name]
|
|
@@ -86,10 +86,10 @@ export const addMCPTool = <
|
|
|
86
86
|
tools.set(mcpTool.name, mcpTool)
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
export const
|
|
90
|
-
|
|
89
|
+
export const wireMCPPrompt = <
|
|
90
|
+
PikkuFunction extends CorePikkuFunctionSessionless<any, any>,
|
|
91
91
|
>(
|
|
92
|
-
mcpPrompt: CoreMCPPrompt<
|
|
92
|
+
mcpPrompt: CoreMCPPrompt<PikkuFunction>
|
|
93
93
|
) => {
|
|
94
94
|
const promptsMeta = pikkuState('mcp', 'promptsMeta')
|
|
95
95
|
const mcpPromptMeta = promptsMeta[mcpPrompt.name]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CorePikkuFunctionSessionless } from '../../function/functions.types.js'
|
|
2
2
|
|
|
3
3
|
export type PikkuMCP<Tools extends string = any> = {
|
|
4
4
|
// elicitInput: <Input>(message: string) => Promise<{ action: string, content: Input }>
|
|
@@ -54,7 +54,7 @@ export type MCPPromptMeta = Record<
|
|
|
54
54
|
* Represents an MCP resource with specific properties.
|
|
55
55
|
*/
|
|
56
56
|
export type CoreMCPResource<
|
|
57
|
-
|
|
57
|
+
PikkuFunction = CorePikkuFunctionSessionless<any, any>,
|
|
58
58
|
> = {
|
|
59
59
|
uri: string
|
|
60
60
|
title: string
|
|
@@ -62,19 +62,21 @@ export type CoreMCPResource<
|
|
|
62
62
|
mimeType?: string
|
|
63
63
|
size?: number
|
|
64
64
|
streaming?: boolean
|
|
65
|
-
func:
|
|
65
|
+
func: PikkuFunction
|
|
66
66
|
tags?: string[]
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
70
|
* Represents an MCP tool with specific properties.
|
|
71
71
|
*/
|
|
72
|
-
export type CoreMCPTool<
|
|
72
|
+
export type CoreMCPTool<
|
|
73
|
+
PikkuFunction = CorePikkuFunctionSessionless<any, any>,
|
|
74
|
+
> = {
|
|
73
75
|
name: string
|
|
74
76
|
title?: string
|
|
75
77
|
description: string
|
|
76
78
|
annotations?: Record<string, any>
|
|
77
|
-
func:
|
|
79
|
+
func: PikkuFunction
|
|
78
80
|
tags?: string[]
|
|
79
81
|
streaming?: boolean
|
|
80
82
|
}
|
|
@@ -83,11 +85,11 @@ export type CoreMCPTool<APIFunction = CoreAPIFunctionSessionless<any, any>> = {
|
|
|
83
85
|
* Represents an MCP prompt with specific properties.
|
|
84
86
|
*/
|
|
85
87
|
export type CoreMCPPrompt<
|
|
86
|
-
|
|
88
|
+
PikkuFunction = CorePikkuFunctionSessionless<any, MCPPromptResponse>,
|
|
87
89
|
> = {
|
|
88
90
|
name: string
|
|
89
91
|
description?: string
|
|
90
|
-
func:
|
|
92
|
+
func: PikkuFunction
|
|
91
93
|
tags?: string[]
|
|
92
94
|
}
|
|
93
95
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CoreServices } from '../../types/core.types.js'
|
|
2
2
|
import type { CoreQueueWorker, QueueJob } from './queue.types.js'
|
|
3
|
-
import type {
|
|
3
|
+
import type { CorePikkuFunctionSessionless } from '../../function/functions.types.js'
|
|
4
4
|
import { getErrorResponse } from '../../errors/error-handler.js'
|
|
5
5
|
import { pikkuState } from '../../pikku-state.js'
|
|
6
6
|
import { addFunction, runPikkuFunc } from '../../function/function-runner.js'
|
|
@@ -17,15 +17,15 @@ class QueueWorkerNotFoundError extends Error {
|
|
|
17
17
|
/**
|
|
18
18
|
* Add a queue processor to the system
|
|
19
19
|
*/
|
|
20
|
-
export const
|
|
20
|
+
export const wireQueueWorker = <
|
|
21
21
|
InputData = any,
|
|
22
22
|
OutputData = any,
|
|
23
|
-
|
|
23
|
+
PikkuFunction extends CorePikkuFunctionSessionless<
|
|
24
24
|
InputData,
|
|
25
25
|
OutputData
|
|
26
|
-
> =
|
|
26
|
+
> = CorePikkuFunctionSessionless<InputData, OutputData>,
|
|
27
27
|
>(
|
|
28
|
-
queueWorker: CoreQueueWorker<
|
|
28
|
+
queueWorker: CoreQueueWorker<PikkuFunction>
|
|
29
29
|
) => {
|
|
30
30
|
// Get processor metadata
|
|
31
31
|
const meta = pikkuState('queue', 'meta')
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { APIDocs } from '../../types/core.types.js'
|
|
2
|
-
import {
|
|
2
|
+
import { CorePikkuFunctionSessionless } from '../../function/functions.types.js'
|
|
3
3
|
import { QueueConfigMapping } from './validate-worker-config.js'
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -165,10 +165,10 @@ export type queueWorkersMeta = Record<
|
|
|
165
165
|
* Core queue processor definition
|
|
166
166
|
*/
|
|
167
167
|
export type CoreQueueWorker<
|
|
168
|
-
|
|
168
|
+
PikkuFunction = CorePikkuFunctionSessionless<any, any>,
|
|
169
169
|
> = {
|
|
170
170
|
queueName: string
|
|
171
|
-
func:
|
|
171
|
+
func: PikkuFunction
|
|
172
172
|
config?: PikkuWorkerConfig
|
|
173
173
|
docs?: APIDocs
|
|
174
174
|
session?: undefined
|
|
@@ -5,7 +5,7 @@ import type {
|
|
|
5
5
|
CreateSessionServices,
|
|
6
6
|
} from '../../types/core.types.js'
|
|
7
7
|
import type { CoreScheduledTask } from './scheduler.types.js'
|
|
8
|
-
import type {
|
|
8
|
+
import type { CorePikkuFunctionSessionless } from '../../function/functions.types.js'
|
|
9
9
|
import { getErrorResponse } from '../../errors/error-handler.js'
|
|
10
10
|
import { closeSessionServices } from '../../utils.js'
|
|
11
11
|
import { pikkuState } from '../../pikku-state.js'
|
|
@@ -23,10 +23,10 @@ export type RunScheduledTasksParams = {
|
|
|
23
23
|
>
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
export const
|
|
27
|
-
|
|
26
|
+
export const wireScheduler = <
|
|
27
|
+
PikkuFunction extends CorePikkuFunctionSessionless<void, void>,
|
|
28
28
|
>(
|
|
29
|
-
scheduledTask: CoreScheduledTask<
|
|
29
|
+
scheduledTask: CoreScheduledTask<PikkuFunction>
|
|
30
30
|
) => {
|
|
31
31
|
const meta = pikkuState('scheduler', 'meta')
|
|
32
32
|
const taskMeta = meta[scheduledTask.name]
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { APIDocs, CoreUserSession } from '../../types/core.types.js'
|
|
2
|
-
import {
|
|
2
|
+
import { CorePikkuFunctionSessionless } from '../../function/functions.types.js'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Represents metadata for scheduled tasks, including title, schedule, and documentation.
|
|
@@ -21,11 +21,11 @@ export type ScheduledTasksMeta<UserSession extends CoreUserSession = any> =
|
|
|
21
21
|
* Represents a core scheduled task.
|
|
22
22
|
*/
|
|
23
23
|
export type CoreScheduledTask<
|
|
24
|
-
|
|
24
|
+
PikkuFunction = CorePikkuFunctionSessionless<void, void>,
|
|
25
25
|
> = {
|
|
26
26
|
name: string
|
|
27
27
|
schedule: string
|
|
28
|
-
func:
|
|
28
|
+
func: PikkuFunction
|
|
29
29
|
docs?: APIDocs
|
|
30
30
|
tags?: string[]
|
|
31
31
|
}
|