@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.
Files changed (143) hide show
  1. package/CHANGELOG.md +13 -1
  2. package/dist/function/functions.types.d.ts +9 -9
  3. package/dist/handle-error.d.ts +1 -1
  4. package/dist/index.d.ts +11 -10
  5. package/dist/index.js +11 -10
  6. package/dist/pikku-state.d.ts +9 -9
  7. package/dist/services/user-session-service.d.ts +1 -1
  8. package/dist/types/core.types.d.ts +5 -5
  9. package/dist/types/core.types.js +9 -9
  10. package/dist/wirings/channel/channel-handler.d.ts +3 -0
  11. package/dist/{events → wirings}/channel/channel-handler.js +3 -3
  12. package/dist/wirings/channel/channel-runner.d.ts +14 -0
  13. package/dist/{events → wirings}/channel/channel-runner.js +13 -13
  14. package/dist/{events → wirings}/channel/channel.types.d.ts +7 -7
  15. package/dist/{events → wirings}/channel/eventhub-service.d.ts +4 -4
  16. package/dist/wirings/channel/eventhub-store.d.ts +5 -0
  17. package/dist/wirings/channel/local/local-channel-runner.d.ts +3 -0
  18. package/dist/{events → wirings}/channel/local/local-eventhub-service.d.ts +4 -4
  19. package/dist/{events → wirings}/channel/local/local-eventhub-service.js +1 -1
  20. package/dist/{events → wirings}/channel/serverless/serverless-channel-runner.d.ts +2 -2
  21. package/dist/{events → wirings}/http/http-runner.d.ts +12 -12
  22. package/dist/{events → wirings}/http/http-runner.js +15 -15
  23. package/dist/{events → wirings}/http/http.types.d.ts +32 -27
  24. package/dist/{events → wirings}/http/index.d.ts +1 -1
  25. package/dist/{events → wirings}/http/index.js +1 -1
  26. package/dist/{events → wirings}/mcp/mcp-runner.d.ts +4 -4
  27. package/dist/{events → wirings}/mcp/mcp-runner.js +3 -3
  28. package/dist/{events → wirings}/mcp/mcp.types.d.ts +7 -7
  29. package/dist/{events → wirings}/queue/index.d.ts +1 -1
  30. package/dist/{events → wirings}/queue/index.js +1 -1
  31. package/dist/{events → wirings}/queue/queue-runner.d.ts +2 -2
  32. package/dist/{events → wirings}/queue/queue-runner.js +1 -1
  33. package/dist/{events → wirings}/queue/queue.types.d.ts +3 -3
  34. package/dist/wirings/scheduler/index.d.ts +3 -0
  35. package/dist/wirings/scheduler/index.js +3 -0
  36. package/dist/{events → wirings}/scheduler/scheduler-runner.d.ts +2 -2
  37. package/dist/{events → wirings}/scheduler/scheduler-runner.js +1 -1
  38. package/dist/{events → wirings}/scheduler/scheduler.types.d.ts +3 -3
  39. package/package.json +9 -9
  40. package/src/function/functions.types.ts +13 -13
  41. package/src/handle-error.ts +1 -1
  42. package/src/index.ts +14 -13
  43. package/src/pikku-state.ts +11 -11
  44. package/src/services/user-session-service.ts +1 -1
  45. package/src/types/core.types.ts +5 -5
  46. package/src/{events → wirings}/channel/channel-handler.ts +5 -5
  47. package/src/{events → wirings}/channel/channel-runner.ts +18 -18
  48. package/src/{events → wirings}/channel/channel.types.ts +16 -16
  49. package/src/{events → wirings}/channel/eventhub-service.ts +12 -8
  50. package/src/wirings/channel/eventhub-store.ts +13 -0
  51. package/src/{events → wirings}/channel/local/local-channel-runner.test.ts +2 -2
  52. package/src/{events → wirings}/channel/local/local-channel-runner.ts +2 -2
  53. package/src/{events → wirings}/channel/local/local-eventhub-service.ts +16 -10
  54. package/src/{events → wirings}/channel/serverless/serverless-channel-runner.ts +2 -2
  55. package/src/{events → wirings}/http/http-runner.test.ts +4 -4
  56. package/src/{events → wirings}/http/http-runner.ts +32 -31
  57. package/src/{events → wirings}/http/http.types.ts +40 -35
  58. package/src/{events → wirings}/http/index.ts +1 -1
  59. package/src/{events → wirings}/mcp/mcp-runner.ts +10 -10
  60. package/src/{events → wirings}/mcp/mcp.types.ts +9 -7
  61. package/src/{events → wirings}/queue/index.ts +1 -1
  62. package/src/{events → wirings}/queue/queue-runner.ts +5 -5
  63. package/src/{events → wirings}/queue/queue.types.ts +3 -3
  64. package/src/{events → wirings}/scheduler/index.ts +1 -1
  65. package/src/{events → wirings}/scheduler/scheduler-runner.ts +4 -4
  66. package/src/{events → wirings}/scheduler/scheduler.types.ts +3 -3
  67. package/tsconfig.tsbuildinfo +1 -1
  68. package/dist/events/channel/channel-handler.d.ts +0 -3
  69. package/dist/events/channel/channel-runner.d.ts +0 -14
  70. package/dist/events/channel/eventhub-store.d.ts +0 -5
  71. package/dist/events/channel/local/local-channel-runner.d.ts +0 -3
  72. package/dist/events/scheduler/index.d.ts +0 -3
  73. package/dist/events/scheduler/index.js +0 -3
  74. package/src/events/channel/eventhub-store.ts +0 -8
  75. /package/dist/{events → wirings}/channel/channel-store.d.ts +0 -0
  76. /package/dist/{events → wirings}/channel/channel-store.js +0 -0
  77. /package/dist/{events → wirings}/channel/channel.types.js +0 -0
  78. /package/dist/{events → wirings}/channel/eventhub-service.js +0 -0
  79. /package/dist/{events → wirings}/channel/eventhub-store.js +0 -0
  80. /package/dist/{events → wirings}/channel/index.d.ts +0 -0
  81. /package/dist/{events → wirings}/channel/index.js +0 -0
  82. /package/dist/{events → wirings}/channel/local/index.d.ts +0 -0
  83. /package/dist/{events → wirings}/channel/local/index.js +0 -0
  84. /package/dist/{events → wirings}/channel/local/local-channel-handler.d.ts +0 -0
  85. /package/dist/{events → wirings}/channel/local/local-channel-handler.js +0 -0
  86. /package/dist/{events → wirings}/channel/local/local-channel-runner.js +0 -0
  87. /package/dist/{events → wirings}/channel/log-channels.d.ts +0 -0
  88. /package/dist/{events → wirings}/channel/log-channels.js +0 -0
  89. /package/dist/{events → wirings}/channel/pikku-abstract-channel-handler.d.ts +0 -0
  90. /package/dist/{events → wirings}/channel/pikku-abstract-channel-handler.js +0 -0
  91. /package/dist/{events → wirings}/channel/serverless/index.d.ts +0 -0
  92. /package/dist/{events → wirings}/channel/serverless/index.js +0 -0
  93. /package/dist/{events → wirings}/channel/serverless/serverless-channel-runner.js +0 -0
  94. /package/dist/{events → wirings}/http/http.types.js +0 -0
  95. /package/dist/{events → wirings}/http/log-http-routes.d.ts +0 -0
  96. /package/dist/{events → wirings}/http/log-http-routes.js +0 -0
  97. /package/dist/{events → wirings}/http/pikku-fetch-http-request.d.ts +0 -0
  98. /package/dist/{events → wirings}/http/pikku-fetch-http-request.js +0 -0
  99. /package/dist/{events → wirings}/http/pikku-fetch-http-response.d.ts +0 -0
  100. /package/dist/{events → wirings}/http/pikku-fetch-http-response.js +0 -0
  101. /package/dist/{events → wirings}/mcp/index.d.ts +0 -0
  102. /package/dist/{events → wirings}/mcp/index.js +0 -0
  103. /package/dist/{events → wirings}/mcp/mcp-endpoint-registry.d.ts +0 -0
  104. /package/dist/{events → wirings}/mcp/mcp-endpoint-registry.js +0 -0
  105. /package/dist/{events → wirings}/mcp/mcp.types.js +0 -0
  106. /package/dist/{events → wirings}/queue/queue.types.js +0 -0
  107. /package/dist/{events → wirings}/queue/register-queue-helper.d.ts +0 -0
  108. /package/dist/{events → wirings}/queue/register-queue-helper.js +0 -0
  109. /package/dist/{events → wirings}/queue/validate-worker-config.d.ts +0 -0
  110. /package/dist/{events → wirings}/queue/validate-worker-config.js +0 -0
  111. /package/dist/{events → wirings}/rpc/index.d.ts +0 -0
  112. /package/dist/{events → wirings}/rpc/index.js +0 -0
  113. /package/dist/{events → wirings}/rpc/rpc-runner.d.ts +0 -0
  114. /package/dist/{events → wirings}/rpc/rpc-runner.js +0 -0
  115. /package/dist/{events → wirings}/rpc/rpc-types.d.ts +0 -0
  116. /package/dist/{events → wirings}/rpc/rpc-types.js +0 -0
  117. /package/dist/{events → wirings}/scheduler/log-schedulers.d.ts +0 -0
  118. /package/dist/{events → wirings}/scheduler/log-schedulers.js +0 -0
  119. /package/dist/{events → wirings}/scheduler/scheduler.types.js +0 -0
  120. /package/src/{events → wirings}/channel/channel-store.ts +0 -0
  121. /package/src/{events → wirings}/channel/index.ts +0 -0
  122. /package/src/{events → wirings}/channel/local/index.ts +0 -0
  123. /package/src/{events → wirings}/channel/local/local-channel-handler.ts +0 -0
  124. /package/src/{events → wirings}/channel/local/local-eventhub-service.test.ts +0 -0
  125. /package/src/{events → wirings}/channel/log-channels.ts +0 -0
  126. /package/src/{events → wirings}/channel/pikku-abstract-channel-handler.test.ts +0 -0
  127. /package/src/{events → wirings}/channel/pikku-abstract-channel-handler.ts +0 -0
  128. /package/src/{events → wirings}/channel/serverless/index.ts +0 -0
  129. /package/src/{events → wirings}/http/log-http-routes.ts +0 -0
  130. /package/src/{events → wirings}/http/pikku-fetch-http-request.test.ts +0 -0
  131. /package/src/{events → wirings}/http/pikku-fetch-http-request.ts +0 -0
  132. /package/src/{events → wirings}/http/pikku-fetch-http-response.test.ts +0 -0
  133. /package/src/{events → wirings}/http/pikku-fetch-http-response.ts +0 -0
  134. /package/src/{events → wirings}/mcp/index.ts +0 -0
  135. /package/src/{events → wirings}/mcp/mcp-endpoint-registry.test.d.ts +0 -0
  136. /package/src/{events → wirings}/mcp/mcp-endpoint-registry.test.ts +0 -0
  137. /package/src/{events → wirings}/mcp/mcp-endpoint-registry.ts +0 -0
  138. /package/src/{events → wirings}/queue/register-queue-helper.ts +0 -0
  139. /package/src/{events → wirings}/queue/validate-worker-config.ts +0 -0
  140. /package/src/{events → wirings}/rpc/index.ts +0 -0
  141. /package/src/{events → wirings}/rpc/rpc-runner.ts +0 -0
  142. /package/src/{events → wirings}/rpc/rpc-types.ts +0 -0
  143. /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
- CoreAPIFunction,
13
- CoreAPIFunctionSessionless,
14
- CoreAPIPermission,
12
+ CorePikkuFunction,
13
+ CorePikkuFunctionSessionless,
14
+ CorePikkuPermission,
15
15
  CorePermissionGroup,
16
16
  } from '../../function/functions.types.js'
17
17
 
18
- type ExtractRouteParams<S extends string> =
18
+ type ExtractHTTPWiringParams<S extends string> =
19
19
  S extends `${string}:${infer Param}/${infer Rest}`
20
- ? Param | ExtractRouteParams<`/${Rest}`>
20
+ ? Param | ExtractHTTPWiringParams<`/${Rest}`>
21
21
  : S extends `${string}:${infer Param}`
22
22
  ? Param
23
23
  : never
24
24
 
25
- export type AssertRouteParams<In, Route extends string> =
26
- ExtractRouteParams<Route> extends keyof In
25
+ export type AssertHTTPWiringParams<In, HTTPWiring extends string> =
26
+ ExtractHTTPWiringParams<HTTPWiring> extends keyof In
27
27
  ? unknown
28
- : ['Error: Route parameters', ExtractRouteParams<Route>, 'not in', keyof In]
28
+ : [
29
+ 'Error: HTTPWiring parameters',
30
+ ExtractHTTPWiringParams<HTTPWiring>,
31
+ 'not in',
32
+ keyof In,
33
+ ]
29
34
 
30
- export type RunRouteOptions = Partial<{
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 RunRouteParams = {
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 routes.
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 route without a function, including metadata such as content type, route, and timeout settings.
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 route, which can have different configurations depending on whether it requires authentication and permissions.
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 APIFunction - The API function type, defaults to `CoreAPIFunction`.
107
- * @template APIFunctionSessionless - The sessionless API function type, defaults to `CoreAPIFunctionSessionless`.
108
- * @template APIPermission - The permission function type, defaults to `CoreAPIPermission`.
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 CoreHTTPFunctionRoute<
115
+ export type CoreHTTPFunctionWiring<
111
116
  In,
112
117
  Out,
113
118
  R extends string,
114
- APIFunction = CoreAPIFunction<In, Out>,
115
- APIFunctionSessionless = CoreAPIFunctionSessionless<In, Out>,
116
- APIPermission = CoreAPIPermission<In>,
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: APIFunction
123
- permissions?: CorePermissionGroup<APIPermission>
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: APIFunctionSessionless
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: APIFunction
143
- permissions?: CorePermissionGroup<APIPermission>
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: APIFunctionSessionless
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: APIFunction
163
- permissions?: CorePermissionGroup<APIPermission>
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: APIFunctionSessionless
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 route metadata, including parameters, query, and body types.
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 routes, including route details, methods, input/output types, and documentation.
197
+ * Represents metadata for a set of HTTP wirings, including HTTP wiring details, methods, input/output types, and documentation.
193
198
  */
194
- export type HTTPRouteMeta = {
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 HTTPRoutesMeta = Array<HTTPRouteMeta>
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 HTTPRouteMiddleware = {
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, addHTTPRoute } from './http-runner.js'
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 { CoreAPIFunctionSessionless } from '../../function/functions.types.js'
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 addMCPResource = <
50
- APIFunction extends CoreAPIFunctionSessionless<any, any>,
49
+ export const wireMCPResource = <
50
+ PikkuFunction extends CorePikkuFunctionSessionless<any, any>,
51
51
  >(
52
- mcpResource: CoreMCPResource<APIFunction>
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 addMCPTool = <
70
- APIFunction extends CoreAPIFunctionSessionless<any, any>,
69
+ export const wireMCPTool = <
70
+ PikkuFunction extends CorePikkuFunctionSessionless<any, any>,
71
71
  >(
72
- mcpTool: CoreMCPTool<APIFunction>
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 addMCPPrompt = <
90
- APIFunction extends CoreAPIFunctionSessionless<any, any>,
89
+ export const wireMCPPrompt = <
90
+ PikkuFunction extends CorePikkuFunctionSessionless<any, any>,
91
91
  >(
92
- mcpPrompt: CoreMCPPrompt<APIFunction>
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 { CoreAPIFunctionSessionless } from '../../function/functions.types.js'
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
- APIFunction = CoreAPIFunctionSessionless<any, any>,
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: APIFunction
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<APIFunction = CoreAPIFunctionSessionless<any, any>> = {
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: APIFunction
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
- APIFunction = CoreAPIFunctionSessionless<any, MCPPromptResponse>,
88
+ PikkuFunction = CorePikkuFunctionSessionless<any, MCPPromptResponse>,
87
89
  > = {
88
90
  name: string
89
91
  description?: string
90
- func: APIFunction
92
+ func: PikkuFunction
91
93
  tags?: string[]
92
94
  }
93
95
 
@@ -3,7 +3,7 @@ export type * from './queue.types.js'
3
3
 
4
4
  // Queue processor management
5
5
  export {
6
- addQueueWorker,
6
+ wireQueueWorker,
7
7
  runQueueJob,
8
8
  getQueueWorkers,
9
9
  removeQueueWorker,
@@ -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 { CoreAPIFunctionSessionless } from '../../function/functions.types.js'
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 addQueueWorker = <
20
+ export const wireQueueWorker = <
21
21
  InputData = any,
22
22
  OutputData = any,
23
- APIFunction extends CoreAPIFunctionSessionless<
23
+ PikkuFunction extends CorePikkuFunctionSessionless<
24
24
  InputData,
25
25
  OutputData
26
- > = CoreAPIFunctionSessionless<InputData, OutputData>,
26
+ > = CorePikkuFunctionSessionless<InputData, OutputData>,
27
27
  >(
28
- queueWorker: CoreQueueWorker<APIFunction>
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 { CoreAPIFunctionSessionless } from '../../function/functions.types.js'
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
- APIFunction = CoreAPIFunctionSessionless<any, any>,
168
+ PikkuFunction = CorePikkuFunctionSessionless<any, any>,
169
169
  > = {
170
170
  queueName: string
171
- func: APIFunction
171
+ func: PikkuFunction
172
172
  config?: PikkuWorkerConfig
173
173
  docs?: APIDocs
174
174
  session?: undefined
@@ -2,7 +2,7 @@ export * from './scheduler.types.js'
2
2
 
3
3
  export {
4
4
  runScheduledTask,
5
- addScheduledTask,
5
+ wireScheduler,
6
6
  getScheduledTasks,
7
7
  } from './scheduler-runner.js'
8
8
 
@@ -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 { CoreAPIFunctionSessionless } from '../../function/functions.types.js'
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 addScheduledTask = <
27
- APIFunction extends CoreAPIFunctionSessionless<void, void>,
26
+ export const wireScheduler = <
27
+ PikkuFunction extends CorePikkuFunctionSessionless<void, void>,
28
28
  >(
29
- scheduledTask: CoreScheduledTask<APIFunction>
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 { CoreAPIFunctionSessionless } from '../../function/functions.types.js'
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
- APIFunction = CoreAPIFunctionSessionless<void, void>,
24
+ PikkuFunction = CorePikkuFunctionSessionless<void, void>,
25
25
  > = {
26
26
  name: string
27
27
  schedule: string
28
- func: APIFunction
28
+ func: PikkuFunction
29
29
  docs?: APIDocs
30
30
  tags?: string[]
31
31
  }