@pikku/core 0.8.1 → 0.9.0

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 (146) 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-endpoint-registry.d.ts +0 -1
  27. package/dist/{events → wirings}/mcp/mcp-endpoint-registry.js +0 -10
  28. package/dist/{events → wirings}/mcp/mcp-runner.d.ts +4 -4
  29. package/dist/{events → wirings}/mcp/mcp-runner.js +4 -4
  30. package/dist/{events → wirings}/mcp/mcp.types.d.ts +7 -7
  31. package/dist/{events → wirings}/queue/index.d.ts +1 -1
  32. package/dist/{events → wirings}/queue/index.js +1 -1
  33. package/dist/{events → wirings}/queue/queue-runner.d.ts +2 -2
  34. package/dist/{events → wirings}/queue/queue-runner.js +1 -1
  35. package/dist/{events → wirings}/queue/queue.types.d.ts +3 -3
  36. package/dist/wirings/scheduler/index.d.ts +3 -0
  37. package/dist/wirings/scheduler/index.js +3 -0
  38. package/dist/{events → wirings}/scheduler/scheduler-runner.d.ts +2 -2
  39. package/dist/{events → wirings}/scheduler/scheduler-runner.js +1 -1
  40. package/dist/{events → wirings}/scheduler/scheduler.types.d.ts +3 -3
  41. package/lcov.info +3072 -2982
  42. package/package.json +9 -9
  43. package/src/function/functions.types.ts +13 -13
  44. package/src/handle-error.ts +1 -1
  45. package/src/index.ts +14 -13
  46. package/src/pikku-state.ts +11 -11
  47. package/src/services/user-session-service.ts +1 -1
  48. package/src/types/core.types.ts +5 -5
  49. package/src/{events → wirings}/channel/channel-handler.ts +5 -5
  50. package/src/{events → wirings}/channel/channel-runner.ts +18 -18
  51. package/src/{events → wirings}/channel/channel.types.ts +16 -16
  52. package/src/{events → wirings}/channel/eventhub-service.ts +12 -8
  53. package/src/wirings/channel/eventhub-store.ts +13 -0
  54. package/src/{events → wirings}/channel/local/local-channel-runner.test.ts +2 -2
  55. package/src/{events → wirings}/channel/local/local-channel-runner.ts +2 -2
  56. package/src/{events → wirings}/channel/local/local-eventhub-service.ts +16 -10
  57. package/src/{events → wirings}/channel/serverless/serverless-channel-runner.ts +2 -2
  58. package/src/{events → wirings}/http/http-runner.test.ts +4 -4
  59. package/src/{events → wirings}/http/http-runner.ts +32 -31
  60. package/src/{events → wirings}/http/http.types.ts +40 -35
  61. package/src/{events → wirings}/http/index.ts +1 -1
  62. package/src/wirings/mcp/mcp-endpoint-registry.test.js +338 -0
  63. package/src/wirings/mcp/mcp-endpoint-registry.test.js.map +1 -0
  64. package/src/{events → wirings}/mcp/mcp-endpoint-registry.ts +0 -10
  65. package/src/{events → wirings}/mcp/mcp-runner.ts +10 -10
  66. package/src/{events → wirings}/mcp/mcp.types.ts +9 -7
  67. package/src/{events → wirings}/queue/index.ts +1 -1
  68. package/src/{events → wirings}/queue/queue-runner.ts +5 -5
  69. package/src/{events → wirings}/queue/queue.types.ts +3 -3
  70. package/src/{events → wirings}/scheduler/index.ts +1 -1
  71. package/src/{events → wirings}/scheduler/scheduler-runner.ts +4 -4
  72. package/src/{events → wirings}/scheduler/scheduler.types.ts +3 -3
  73. package/tsconfig.tsbuildinfo +1 -1
  74. package/dist/events/channel/channel-handler.d.ts +0 -3
  75. package/dist/events/channel/channel-runner.d.ts +0 -14
  76. package/dist/events/channel/eventhub-store.d.ts +0 -5
  77. package/dist/events/channel/local/local-channel-runner.d.ts +0 -3
  78. package/dist/events/scheduler/index.d.ts +0 -3
  79. package/dist/events/scheduler/index.js +0 -3
  80. package/src/events/channel/eventhub-store.ts +0 -8
  81. /package/dist/{events → wirings}/channel/channel-store.d.ts +0 -0
  82. /package/dist/{events → wirings}/channel/channel-store.js +0 -0
  83. /package/dist/{events → wirings}/channel/channel.types.js +0 -0
  84. /package/dist/{events → wirings}/channel/eventhub-service.js +0 -0
  85. /package/dist/{events → wirings}/channel/eventhub-store.js +0 -0
  86. /package/dist/{events → wirings}/channel/index.d.ts +0 -0
  87. /package/dist/{events → wirings}/channel/index.js +0 -0
  88. /package/dist/{events → wirings}/channel/local/index.d.ts +0 -0
  89. /package/dist/{events → wirings}/channel/local/index.js +0 -0
  90. /package/dist/{events → wirings}/channel/local/local-channel-handler.d.ts +0 -0
  91. /package/dist/{events → wirings}/channel/local/local-channel-handler.js +0 -0
  92. /package/dist/{events → wirings}/channel/local/local-channel-runner.js +0 -0
  93. /package/dist/{events → wirings}/channel/log-channels.d.ts +0 -0
  94. /package/dist/{events → wirings}/channel/log-channels.js +0 -0
  95. /package/dist/{events → wirings}/channel/pikku-abstract-channel-handler.d.ts +0 -0
  96. /package/dist/{events → wirings}/channel/pikku-abstract-channel-handler.js +0 -0
  97. /package/dist/{events → wirings}/channel/serverless/index.d.ts +0 -0
  98. /package/dist/{events → wirings}/channel/serverless/index.js +0 -0
  99. /package/dist/{events → wirings}/channel/serverless/serverless-channel-runner.js +0 -0
  100. /package/dist/{events → wirings}/http/http.types.js +0 -0
  101. /package/dist/{events → wirings}/http/log-http-routes.d.ts +0 -0
  102. /package/dist/{events → wirings}/http/log-http-routes.js +0 -0
  103. /package/dist/{events → wirings}/http/pikku-fetch-http-request.d.ts +0 -0
  104. /package/dist/{events → wirings}/http/pikku-fetch-http-request.js +0 -0
  105. /package/dist/{events → wirings}/http/pikku-fetch-http-response.d.ts +0 -0
  106. /package/dist/{events → wirings}/http/pikku-fetch-http-response.js +0 -0
  107. /package/dist/{events → wirings}/mcp/index.d.ts +0 -0
  108. /package/dist/{events → wirings}/mcp/index.js +0 -0
  109. /package/dist/{events → wirings}/mcp/mcp.types.js +0 -0
  110. /package/dist/{events → wirings}/queue/queue.types.js +0 -0
  111. /package/dist/{events → wirings}/queue/register-queue-helper.d.ts +0 -0
  112. /package/dist/{events → wirings}/queue/register-queue-helper.js +0 -0
  113. /package/dist/{events → wirings}/queue/validate-worker-config.d.ts +0 -0
  114. /package/dist/{events → wirings}/queue/validate-worker-config.js +0 -0
  115. /package/dist/{events → wirings}/rpc/index.d.ts +0 -0
  116. /package/dist/{events → wirings}/rpc/index.js +0 -0
  117. /package/dist/{events → wirings}/rpc/rpc-runner.d.ts +0 -0
  118. /package/dist/{events → wirings}/rpc/rpc-runner.js +0 -0
  119. /package/dist/{events → wirings}/rpc/rpc-types.d.ts +0 -0
  120. /package/dist/{events → wirings}/rpc/rpc-types.js +0 -0
  121. /package/dist/{events → wirings}/scheduler/log-schedulers.d.ts +0 -0
  122. /package/dist/{events → wirings}/scheduler/log-schedulers.js +0 -0
  123. /package/dist/{events → wirings}/scheduler/scheduler.types.js +0 -0
  124. /package/src/{events → wirings}/channel/channel-store.ts +0 -0
  125. /package/src/{events → wirings}/channel/index.ts +0 -0
  126. /package/src/{events → wirings}/channel/local/index.ts +0 -0
  127. /package/src/{events → wirings}/channel/local/local-channel-handler.ts +0 -0
  128. /package/src/{events → wirings}/channel/local/local-eventhub-service.test.ts +0 -0
  129. /package/src/{events → wirings}/channel/log-channels.ts +0 -0
  130. /package/src/{events → wirings}/channel/pikku-abstract-channel-handler.test.ts +0 -0
  131. /package/src/{events → wirings}/channel/pikku-abstract-channel-handler.ts +0 -0
  132. /package/src/{events → wirings}/channel/serverless/index.ts +0 -0
  133. /package/src/{events → wirings}/http/log-http-routes.ts +0 -0
  134. /package/src/{events → wirings}/http/pikku-fetch-http-request.test.ts +0 -0
  135. /package/src/{events → wirings}/http/pikku-fetch-http-request.ts +0 -0
  136. /package/src/{events → wirings}/http/pikku-fetch-http-response.test.ts +0 -0
  137. /package/src/{events → wirings}/http/pikku-fetch-http-response.ts +0 -0
  138. /package/src/{events → wirings}/mcp/index.ts +0 -0
  139. /package/src/{events → wirings}/mcp/mcp-endpoint-registry.test.d.ts +0 -0
  140. /package/src/{events → wirings}/mcp/mcp-endpoint-registry.test.ts +0 -0
  141. /package/src/{events → wirings}/queue/register-queue-helper.ts +0 -0
  142. /package/src/{events → wirings}/queue/validate-worker-config.ts +0 -0
  143. /package/src/{events → wirings}/rpc/index.ts +0 -0
  144. /package/src/{events → wirings}/rpc/rpc-runner.ts +0 -0
  145. /package/src/{events → wirings}/rpc/rpc-types.ts +0 -0
  146. /package/src/{events → wirings}/scheduler/log-schedulers.ts +0 -0
@@ -1,10 +1,15 @@
1
1
  import type { SerializeOptions } from 'cookie';
2
2
  import type { PikkuError } from '../../errors/error-handler.js';
3
3
  import type { APIDocs, CoreServices, CoreSingletonServices, CoreUserSession, CreateSessionServices, PikkuMiddleware } from '../../types/core.types.js';
4
- import type { CoreAPIFunction, CoreAPIFunctionSessionless, CoreAPIPermission, CorePermissionGroup } from '../../function/functions.types.js';
5
- type ExtractRouteParams<S extends string> = S extends `${string}:${infer Param}/${infer Rest}` ? Param | ExtractRouteParams<`/${Rest}`> : S extends `${string}:${infer Param}` ? Param : never;
6
- export type AssertRouteParams<In, Route extends string> = ExtractRouteParams<Route> extends keyof In ? unknown : ['Error: Route parameters', ExtractRouteParams<Route>, 'not in', keyof In];
7
- export type RunRouteOptions = Partial<{
4
+ import type { CorePikkuFunction, CorePikkuFunctionSessionless, CorePikkuPermission, CorePermissionGroup } from '../../function/functions.types.js';
5
+ type ExtractHTTPWiringParams<S extends string> = S extends `${string}:${infer Param}/${infer Rest}` ? Param | ExtractHTTPWiringParams<`/${Rest}`> : S extends `${string}:${infer Param}` ? Param : never;
6
+ export type AssertHTTPWiringParams<In, HTTPWiring extends string> = ExtractHTTPWiringParams<HTTPWiring> extends keyof In ? unknown : [
7
+ 'Error: HTTPWiring parameters',
8
+ ExtractHTTPWiringParams<HTTPWiring>,
9
+ 'not in',
10
+ keyof In
11
+ ];
12
+ export type RunHTTPWiringOptions = Partial<{
8
13
  skipUserSession: boolean;
9
14
  respondWith404: boolean;
10
15
  logWarningsForStatusCodes: number[];
@@ -13,16 +18,16 @@ export type RunRouteOptions = Partial<{
13
18
  generateRequestId: () => string;
14
19
  ignoreMiddleware: boolean;
15
20
  }>;
16
- export type RunRouteParams = {
21
+ export type RunHTTPWiringParams = {
17
22
  singletonServices: CoreSingletonServices;
18
23
  createSessionServices: CreateSessionServices<CoreSingletonServices, CoreServices<CoreSingletonServices>, CoreUserSession>;
19
24
  };
20
25
  /**
21
- * Represents the HTTP methods supported for API routes.
22
- */
26
+ * Represents the HTTP methods supported for API HTTP wirings.
27
+ t */
23
28
  export type HTTPMethod = 'post' | 'get' | 'delete' | 'patch' | 'head' | 'put' | 'options';
24
29
  /**
25
- * Represents an API route without a function, including metadata such as content type, route, and timeout settings.
30
+ * Represents an API HTTP wiring without a function, including metadata such as content type, route, and timeout settings.
26
31
  */
27
32
  export type CoreHTTPFunction = {
28
33
  contentType?: 'xml' | 'json';
@@ -53,20 +58,20 @@ export type RequestHeaders = Record<string, string | string[] | undefined> | ((h
53
58
  */
54
59
  export type PikkuQuery<T = Record<string, string | undefined>> = Record<string, string | T | null | Array<T | null>>;
55
60
  /**
56
- * Represents a core API route, which can have different configurations depending on whether it requires authentication and permissions.
61
+ * Represents a core API HTTP wiring, which can have different configurations depending on whether it requires authentication and permissions.
57
62
  *
58
63
  * @template In - The input type.
59
64
  * @template Out - The output type.
60
65
  * @template R - The route string type.
61
- * @template APIFunction - The API function type, defaults to `CoreAPIFunction`.
62
- * @template APIFunctionSessionless - The sessionless API function type, defaults to `CoreAPIFunctionSessionless`.
63
- * @template APIPermission - The permission function type, defaults to `CoreAPIPermission`.
66
+ * @template PikkuFunction - The API function type, defaults to `CorePikkuFunction`.
67
+ * @template PikkuFunctionSessionless - The sessionless API function type, defaults to `CorePikkuFunctionSessionless`.
68
+ * @template PikkuPermission - The permission function type, defaults to `CorePikkuPermission`.
64
69
  */
65
- export type CoreHTTPFunctionRoute<In, Out, R extends string, APIFunction = CoreAPIFunction<In, Out>, APIFunctionSessionless = CoreAPIFunctionSessionless<In, Out>, APIPermission = CoreAPIPermission<In>, APIMiddleware = PikkuMiddleware> = (CoreHTTPFunction & {
70
+ export type CoreHTTPFunctionWiring<In, Out, R extends string, PikkuFunction = CorePikkuFunction<In, Out>, PikkuFunctionSessionless = CorePikkuFunctionSessionless<In, Out>, PikkuPermission = CorePikkuPermission<In>, APIMiddleware = PikkuMiddleware> = (CoreHTTPFunction & {
66
71
  route: R;
67
72
  method: HTTPMethod;
68
- func: APIFunction;
69
- permissions?: CorePermissionGroup<APIPermission>;
73
+ func: PikkuFunction;
74
+ permissions?: CorePermissionGroup<PikkuPermission>;
70
75
  auth?: true;
71
76
  tags?: string[];
72
77
  middleware?: APIMiddleware[];
@@ -74,7 +79,7 @@ export type CoreHTTPFunctionRoute<In, Out, R extends string, APIFunction = CoreA
74
79
  }) | (CoreHTTPFunction & {
75
80
  route: R;
76
81
  method: HTTPMethod;
77
- func: APIFunctionSessionless;
82
+ func: PikkuFunctionSessionless;
78
83
  permissions?: undefined;
79
84
  auth?: false;
80
85
  tags?: string[];
@@ -83,8 +88,8 @@ export type CoreHTTPFunctionRoute<In, Out, R extends string, APIFunction = CoreA
83
88
  }) | (CoreHTTPFunction & {
84
89
  route: R;
85
90
  method: 'get';
86
- func: APIFunction;
87
- permissions?: CorePermissionGroup<APIPermission>;
91
+ func: PikkuFunction;
92
+ permissions?: CorePermissionGroup<PikkuPermission>;
88
93
  auth?: true;
89
94
  sse?: boolean;
90
95
  tags?: string[];
@@ -92,7 +97,7 @@ export type CoreHTTPFunctionRoute<In, Out, R extends string, APIFunction = CoreA
92
97
  }) | (CoreHTTPFunction & {
93
98
  route: R;
94
99
  method: 'get';
95
- func: APIFunctionSessionless;
100
+ func: PikkuFunctionSessionless;
96
101
  permissions?: undefined;
97
102
  auth?: false;
98
103
  sse?: boolean;
@@ -101,8 +106,8 @@ export type CoreHTTPFunctionRoute<In, Out, R extends string, APIFunction = CoreA
101
106
  }) | (CoreHTTPFunction & {
102
107
  route: R;
103
108
  method: 'post';
104
- func: APIFunction;
105
- permissions?: CorePermissionGroup<APIPermission>;
109
+ func: PikkuFunction;
110
+ permissions?: CorePermissionGroup<PikkuPermission>;
106
111
  auth?: true;
107
112
  query?: Array<keyof In>;
108
113
  tags?: string[];
@@ -111,7 +116,7 @@ export type CoreHTTPFunctionRoute<In, Out, R extends string, APIFunction = CoreA
111
116
  }) | (CoreHTTPFunction & {
112
117
  route: R;
113
118
  method: 'post';
114
- func: APIFunctionSessionless;
119
+ func: PikkuFunctionSessionless;
115
120
  permissions?: undefined;
116
121
  auth?: false;
117
122
  query?: Array<keyof In>;
@@ -120,7 +125,7 @@ export type CoreHTTPFunctionRoute<In, Out, R extends string, APIFunction = CoreA
120
125
  sse?: undefined;
121
126
  });
122
127
  /**
123
- * Represents the input types for route metadata, including parameters, query, and body types.
128
+ * Represents the input types for HTTP wiring metadata, including parameters, query, and body types.
124
129
  */
125
130
  export type HTTPFunctionMetaInputTypes = {
126
131
  params?: string;
@@ -128,9 +133,9 @@ export type HTTPFunctionMetaInputTypes = {
128
133
  body?: string;
129
134
  };
130
135
  /**
131
- * Represents metadata for a set of routes, including route details, methods, input/output types, and documentation.
136
+ * Represents metadata for a set of HTTP wirings, including HTTP wiring details, methods, input/output types, and documentation.
132
137
  */
133
- export type HTTPRouteMeta = {
138
+ export type HTTPWiringMeta = {
134
139
  pikkuFuncName: string;
135
140
  route: string;
136
141
  method: HTTPMethod;
@@ -141,13 +146,13 @@ export type HTTPRouteMeta = {
141
146
  tags?: string[];
142
147
  sse?: true;
143
148
  };
144
- export type HTTPRoutesMeta = Array<HTTPRouteMeta>;
149
+ export type HTTPWiringsMeta = Array<HTTPWiringMeta>;
145
150
  export type HTTPFunctionsMeta = Array<{
146
151
  name: string;
147
152
  inputs: string[] | null;
148
153
  outputs: string[] | null;
149
154
  }>;
150
- export type HTTPRouteMiddleware = {
155
+ export type HTTPWiringMiddleware = {
151
156
  route: string;
152
157
  middleware: PikkuMiddleware[];
153
158
  };
@@ -1,5 +1,5 @@
1
1
  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
- export { fetch, fetchData, addHTTPRoute } from './http-runner.js';
4
+ export { fetch, fetchData, wireHTTP } from './http-runner.js';
5
5
  export type * from './http.types.js';
@@ -1,4 +1,4 @@
1
1
  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
- export { fetch, fetchData, addHTTPRoute } from './http-runner.js';
4
+ export { fetch, fetchData, wireHTTP } from './http-runner.js';
@@ -28,7 +28,6 @@ export declare class MCPEndpointRegistry {
28
28
  private resourcesMeta;
29
29
  private toolsMeta;
30
30
  private promptsMeta;
31
- loadFromMCPJsonFile(mcpJsonPath: string): Promise<void>;
32
31
  loadFromMCPJson(mcpData: any): Promise<void>;
33
32
  setResourcesMeta(meta: MCPResourceMeta): void;
34
33
  setToolsMeta(meta: MCPToolMeta): void;
@@ -1,4 +1,3 @@
1
- import { readFile } from 'fs/promises';
2
1
  export class MCPEndpointRegistry {
3
2
  tools = new Map();
4
3
  resources = new Map();
@@ -6,15 +5,6 @@ export class MCPEndpointRegistry {
6
5
  resourcesMeta = {};
7
6
  toolsMeta = {};
8
7
  promptsMeta = {};
9
- async loadFromMCPJsonFile(mcpJsonPath) {
10
- try {
11
- const mcpJsonContent = await readFile(mcpJsonPath, 'utf-8');
12
- await this.loadFromMCPJson(JSON.parse(mcpJsonContent));
13
- }
14
- catch (error) {
15
- throw new Error(`Failed to load MCP JSON from ${mcpJsonPath}: ${error}`);
16
- }
17
- }
18
8
  async loadFromMCPJson(mcpData) {
19
9
  if (mcpData.tools && Array.isArray(mcpData.tools)) {
20
10
  for (const tool of mcpData.tools) {
@@ -1,6 +1,6 @@
1
1
  import type { CoreServices, CoreSingletonServices, CoreUserSession, CreateSessionServices } from '../../types/core.types.js';
2
2
  import type { CoreMCPResource, CoreMCPTool, CoreMCPPrompt, JsonRpcRequest, JsonRpcResponse, JsonRpcErrorResponse, PikkuMCP } from './mcp.types.js';
3
- import type { CoreAPIFunctionSessionless } from '../../function/functions.types.js';
3
+ import type { CorePikkuFunctionSessionless } from '../../function/functions.types.js';
4
4
  export declare class MCPError extends Error {
5
5
  readonly error: JsonRpcErrorResponse;
6
6
  constructor(error: JsonRpcErrorResponse);
@@ -16,9 +16,9 @@ export type JsonRpcError = {
16
16
  message: string;
17
17
  data?: any;
18
18
  };
19
- export declare const addMCPResource: <APIFunction extends CoreAPIFunctionSessionless<any, any>>(mcpResource: CoreMCPResource<APIFunction>) => void;
20
- export declare const addMCPTool: <APIFunction extends CoreAPIFunctionSessionless<any, any>>(mcpTool: CoreMCPTool<APIFunction>) => void;
21
- export declare const addMCPPrompt: <APIFunction extends CoreAPIFunctionSessionless<any, any>>(mcpPrompt: CoreMCPPrompt<APIFunction>) => void;
19
+ export declare const wireMCPResource: <PikkuFunction extends CorePikkuFunctionSessionless<any, any>>(mcpResource: CoreMCPResource<PikkuFunction>) => void;
20
+ export declare const wireMCPTool: <PikkuFunction extends CorePikkuFunctionSessionless<any, any>>(mcpTool: CoreMCPTool<PikkuFunction>) => void;
21
+ export declare const wireMCPPrompt: <PikkuFunction extends CorePikkuFunctionSessionless<any, any>>(mcpPrompt: CoreMCPPrompt<PikkuFunction>) => void;
22
22
  export declare function runMCPResource(request: JsonRpcRequest, params: RunMCPEndpointParams, uri: string): Promise<JsonRpcResponse>;
23
23
  export declare function runMCPTool(request: JsonRpcRequest, params: RunMCPEndpointParams, name: string): Promise<JsonRpcResponse>;
24
24
  export declare function runMCPPrompt(request: JsonRpcRequest, params: RunMCPEndpointParams, name: string): Promise<JsonRpcResponse>;
@@ -13,7 +13,7 @@ export class MCPError extends Error {
13
13
  this.stack = new Error().stack;
14
14
  }
15
15
  }
16
- export const addMCPResource = (mcpResource) => {
16
+ export const wireMCPResource = (mcpResource) => {
17
17
  const resourcesMeta = pikkuState('mcp', 'resourcesMeta');
18
18
  const mcpResourceMeta = resourcesMeta[mcpResource.uri];
19
19
  if (!mcpResourceMeta) {
@@ -28,7 +28,7 @@ export const addMCPResource = (mcpResource) => {
28
28
  }
29
29
  resources.set(mcpResource.uri, mcpResource);
30
30
  };
31
- export const addMCPTool = (mcpTool) => {
31
+ export const wireMCPTool = (mcpTool) => {
32
32
  const toolsMeta = pikkuState('mcp', 'toolsMeta');
33
33
  const mcpToolMeta = toolsMeta[mcpTool.name];
34
34
  if (!mcpToolMeta) {
@@ -43,11 +43,11 @@ export const addMCPTool = (mcpTool) => {
43
43
  }
44
44
  tools.set(mcpTool.name, mcpTool);
45
45
  };
46
- export const addMCPPrompt = (mcpPrompt) => {
46
+ export const wireMCPPrompt = (mcpPrompt) => {
47
47
  const promptsMeta = pikkuState('mcp', 'promptsMeta');
48
48
  const mcpPromptMeta = promptsMeta[mcpPrompt.name];
49
49
  if (!mcpPromptMeta) {
50
- throw new Error(`MCP prompt metadata not found for '${mcpPrompt.name}'`);
50
+ throw new Error(`MCP prompt metadata not found for '${mcpPrompt.name}' ${JSON.stringify(promptsMeta)}`);
51
51
  }
52
52
  addFunction(mcpPromptMeta.pikkuFuncName, {
53
53
  func: mcpPrompt.func,
@@ -1,4 +1,4 @@
1
- import { CoreAPIFunctionSessionless } from '../../function/functions.types.js';
1
+ import { CorePikkuFunctionSessionless } from '../../function/functions.types.js';
2
2
  export type PikkuMCP<Tools extends string = any> = {
3
3
  uri?: string;
4
4
  sendResourceUpdated: (uri: string) => void;
@@ -38,35 +38,35 @@ export type MCPPromptMeta = Record<string, Omit<CoreMCPPrompt, 'func'> & {
38
38
  /**
39
39
  * Represents an MCP resource with specific properties.
40
40
  */
41
- export type CoreMCPResource<APIFunction = CoreAPIFunctionSessionless<any, any>> = {
41
+ export type CoreMCPResource<PikkuFunction = CorePikkuFunctionSessionless<any, any>> = {
42
42
  uri: string;
43
43
  title: string;
44
44
  description?: string;
45
45
  mimeType?: string;
46
46
  size?: number;
47
47
  streaming?: boolean;
48
- func: APIFunction;
48
+ func: PikkuFunction;
49
49
  tags?: string[];
50
50
  };
51
51
  /**
52
52
  * Represents an MCP tool with specific properties.
53
53
  */
54
- export type CoreMCPTool<APIFunction = CoreAPIFunctionSessionless<any, any>> = {
54
+ export type CoreMCPTool<PikkuFunction = CorePikkuFunctionSessionless<any, any>> = {
55
55
  name: string;
56
56
  title?: string;
57
57
  description: string;
58
58
  annotations?: Record<string, any>;
59
- func: APIFunction;
59
+ func: PikkuFunction;
60
60
  tags?: string[];
61
61
  streaming?: boolean;
62
62
  };
63
63
  /**
64
64
  * Represents an MCP prompt with specific properties.
65
65
  */
66
- export type CoreMCPPrompt<APIFunction = CoreAPIFunctionSessionless<any, MCPPromptResponse>> = {
66
+ export type CoreMCPPrompt<PikkuFunction = CorePikkuFunctionSessionless<any, MCPPromptResponse>> = {
67
67
  name: string;
68
68
  description?: string;
69
- func: APIFunction;
69
+ func: PikkuFunction;
70
70
  tags?: string[];
71
71
  };
72
72
  export type JsonRpcRequest = {
@@ -1,5 +1,5 @@
1
1
  export type * from './queue.types.js';
2
- export { addQueueWorker, runQueueJob, getQueueWorkers, removeQueueWorker, } from './queue-runner.js';
2
+ export { wireQueueWorker, runQueueJob, getQueueWorkers, removeQueueWorker, } from './queue-runner.js';
3
3
  export { validateWorkerConfig } from './validate-worker-config.js';
4
4
  export type { QueueConfigMapping } from './validate-worker-config.js';
5
5
  export { registerQueueWorkers } from './register-queue-helper.js';
@@ -1,5 +1,5 @@
1
1
  // Queue processor management
2
- export { addQueueWorker, runQueueJob, getQueueWorkers, removeQueueWorker, } from './queue-runner.js';
2
+ export { wireQueueWorker, runQueueJob, getQueueWorkers, removeQueueWorker, } from './queue-runner.js';
3
3
  // Configuration validation
4
4
  export { validateWorkerConfig } from './validate-worker-config.js';
5
5
  // Queue registration helper
@@ -1,11 +1,11 @@
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 { CreateSessionServices } from '../../types/core.types.js';
5
5
  /**
6
6
  * Add a queue processor to the system
7
7
  */
8
- export declare const addQueueWorker: <InputData = any, OutputData = any, APIFunction extends CoreAPIFunctionSessionless<InputData, OutputData> = CoreAPIFunctionSessionless<InputData, OutputData>>(queueWorker: CoreQueueWorker<APIFunction>) => void;
8
+ export declare const wireQueueWorker: <InputData = any, OutputData = any, PikkuFunction extends CorePikkuFunctionSessionless<InputData, OutputData> = CorePikkuFunctionSessionless<InputData, OutputData>>(queueWorker: CoreQueueWorker<PikkuFunction>) => void;
9
9
  /**
10
10
  * Get all registered queue processors
11
11
  */
@@ -12,7 +12,7 @@ class QueueWorkerNotFoundError extends Error {
12
12
  /**
13
13
  * Add a queue processor to the system
14
14
  */
15
- export const addQueueWorker = (queueWorker) => {
15
+ export const wireQueueWorker = (queueWorker) => {
16
16
  // Get processor metadata
17
17
  const meta = pikkuState('queue', 'meta');
18
18
  const processorMeta = meta[queueWorker.queueName];
@@ -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
  * Configuration for queue workers - how jobs are processed
@@ -144,9 +144,9 @@ export type queueWorkersMeta = Record<string, {
144
144
  /**
145
145
  * Core queue processor definition
146
146
  */
147
- export type CoreQueueWorker<APIFunction = CoreAPIFunctionSessionless<any, any>> = {
147
+ export type CoreQueueWorker<PikkuFunction = CorePikkuFunctionSessionless<any, any>> = {
148
148
  queueName: string;
149
- func: APIFunction;
149
+ func: PikkuFunction;
150
150
  config?: PikkuWorkerConfig;
151
151
  docs?: APIDocs;
152
152
  session?: undefined;
@@ -0,0 +1,3 @@
1
+ export * from './scheduler.types.js';
2
+ export { runScheduledTask, wireScheduler, getScheduledTasks, } from './scheduler-runner.js';
3
+ export * from './log-schedulers.js';
@@ -0,0 +1,3 @@
1
+ export * from './scheduler.types.js';
2
+ export { runScheduledTask, wireScheduler, getScheduledTasks, } from './scheduler-runner.js';
3
+ export * from './log-schedulers.js';
@@ -1,12 +1,12 @@
1
1
  import type { CoreServices, CoreSingletonServices, CoreUserSession, CreateSessionServices } from '../../types/core.types.js';
2
2
  import type { CoreScheduledTask } from './scheduler.types.js';
3
- import type { CoreAPIFunctionSessionless } from '../../function/functions.types.js';
3
+ import type { CorePikkuFunctionSessionless } from '../../function/functions.types.js';
4
4
  export type RunScheduledTasksParams = {
5
5
  name: string;
6
6
  session?: CoreUserSession;
7
7
  singletonServices: CoreSingletonServices;
8
8
  createSessionServices?: CreateSessionServices<CoreSingletonServices, CoreServices<CoreSingletonServices>, CoreUserSession>;
9
9
  };
10
- export declare const addScheduledTask: <APIFunction extends CoreAPIFunctionSessionless<void, void>>(scheduledTask: CoreScheduledTask<APIFunction>) => void;
10
+ export declare const wireScheduler: <PikkuFunction extends CorePikkuFunctionSessionless<void, void>>(scheduledTask: CoreScheduledTask<PikkuFunction>) => void;
11
11
  export declare function runScheduledTask({ name, session, singletonServices, createSessionServices, }: RunScheduledTasksParams): Promise<void>;
12
12
  export declare const getScheduledTasks: () => Map<string, CoreScheduledTask>;
@@ -3,7 +3,7 @@ import { closeSessionServices } from '../../utils.js';
3
3
  import { pikkuState } from '../../pikku-state.js';
4
4
  import { addFunction, runPikkuFunc } from '../../function/function-runner.js';
5
5
  import { rpcService } from '../rpc/rpc-runner.js';
6
- export const addScheduledTask = (scheduledTask) => {
6
+ export const wireScheduler = (scheduledTask) => {
7
7
  const meta = pikkuState('scheduler', 'meta');
8
8
  const taskMeta = meta[scheduledTask.name];
9
9
  if (!taskMeta) {
@@ -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
  * Represents metadata for scheduled tasks, including title, schedule, and documentation.
5
5
  */
@@ -14,10 +14,10 @@ export type ScheduledTasksMeta<UserSession extends CoreUserSession = any> = Reco
14
14
  /**
15
15
  * Represents a core scheduled task.
16
16
  */
17
- export type CoreScheduledTask<APIFunction = CoreAPIFunctionSessionless<void, void>> = {
17
+ export type CoreScheduledTask<PikkuFunction = CorePikkuFunctionSessionless<void, void>> = {
18
18
  name: string;
19
19
  schedule: string;
20
- func: APIFunction;
20
+ func: PikkuFunction;
21
21
  docs?: APIDocs;
22
22
  tags?: string[];
23
23
  };