@pikku/core 0.11.2 → 0.12.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 (344) hide show
  1. package/CHANGELOG.md +33 -2
  2. package/dist/crypto-utils.d.ts +2 -0
  3. package/dist/crypto-utils.js +78 -0
  4. package/dist/errors/errors.d.ts +8 -0
  5. package/dist/errors/errors.js +16 -0
  6. package/dist/errors/index.d.ts +0 -1
  7. package/dist/errors/index.js +0 -1
  8. package/dist/function/function-runner.d.ts +7 -1
  9. package/dist/function/function-runner.js +82 -23
  10. package/dist/function/functions.types.d.ts +31 -87
  11. package/dist/function/functions.types.js +16 -46
  12. package/dist/function/index.d.ts +2 -2
  13. package/dist/function/index.js +1 -2
  14. package/dist/handle-error.js +1 -10
  15. package/dist/index.d.ts +28 -26
  16. package/dist/index.js +18 -29
  17. package/dist/middleware/auth-apikey.d.ts +2 -2
  18. package/dist/middleware/auth-apikey.js +3 -3
  19. package/dist/middleware/auth-bearer.d.ts +2 -2
  20. package/dist/middleware/auth-bearer.js +3 -6
  21. package/dist/middleware/auth-cookie.d.ts +2 -2
  22. package/dist/middleware/auth-cookie.js +6 -8
  23. package/dist/middleware/cors.d.ts +46 -0
  24. package/dist/middleware/cors.js +73 -0
  25. package/dist/middleware/index.d.ts +5 -3
  26. package/dist/middleware/index.js +5 -3
  27. package/dist/middleware/remote-auth.d.ts +5 -0
  28. package/dist/middleware/remote-auth.js +55 -0
  29. package/dist/middleware/timeout.d.ts +2 -2
  30. package/dist/middleware-runner.js +8 -10
  31. package/dist/permissions.js +11 -15
  32. package/dist/pikku-state.d.ts +1 -0
  33. package/dist/pikku-state.js +18 -8
  34. package/dist/schema.js +12 -11
  35. package/dist/services/ai-agent-runner-service.d.ts +24 -0
  36. package/dist/services/ai-agent-runner-service.js +1 -0
  37. package/dist/services/ai-run-state-service.d.ts +13 -0
  38. package/dist/services/ai-run-state-service.js +1 -0
  39. package/dist/services/ai-storage-service.d.ts +18 -0
  40. package/dist/services/ai-storage-service.js +1 -0
  41. package/dist/services/deployment-service.d.ts +19 -0
  42. package/dist/services/deployment-service.js +1 -0
  43. package/dist/services/gopass-secrets.d.ts +47 -0
  44. package/dist/services/gopass-secrets.js +94 -0
  45. package/dist/services/in-memory-trigger-service.d.ts +23 -0
  46. package/dist/services/in-memory-trigger-service.js +50 -0
  47. package/dist/services/in-memory-workflow-service.d.ts +59 -0
  48. package/dist/services/in-memory-workflow-service.js +287 -0
  49. package/dist/services/index.d.ts +25 -11
  50. package/dist/services/index.js +10 -13
  51. package/dist/services/local-secrets.d.ts +23 -0
  52. package/dist/services/local-secrets.js +45 -0
  53. package/dist/services/local-variables.d.ts +5 -0
  54. package/dist/services/local-variables.js +18 -0
  55. package/dist/services/scheduler-service.d.ts +21 -1
  56. package/dist/services/scheduler-service.js +14 -0
  57. package/dist/services/schema-service.d.ts +6 -0
  58. package/dist/services/scoped-secret-service.d.ts +16 -0
  59. package/dist/services/scoped-secret-service.js +35 -0
  60. package/dist/services/secret-service.d.ts +25 -4
  61. package/dist/services/trigger-service.d.ts +23 -0
  62. package/dist/services/trigger-service.js +1 -0
  63. package/dist/services/typed-secret-service.d.ts +30 -0
  64. package/dist/services/typed-secret-service.js +40 -0
  65. package/dist/services/typed-variables-service.d.ts +27 -0
  66. package/dist/services/typed-variables-service.js +46 -0
  67. package/dist/services/user-session-service.d.ts +13 -0
  68. package/dist/services/user-session-service.js +17 -0
  69. package/dist/services/variables-service.d.ts +5 -0
  70. package/dist/services/workflow-service.d.ts +9 -4
  71. package/dist/types/core.types.d.ts +48 -12
  72. package/dist/types/core.types.js +8 -1
  73. package/dist/types/state.types.d.ts +43 -51
  74. package/dist/utils.d.ts +3 -2
  75. package/dist/utils.js +15 -3
  76. package/dist/version.d.ts +6 -0
  77. package/dist/version.js +19 -0
  78. package/dist/wirings/ai-agent/ai-agent-memory.d.ts +29 -0
  79. package/dist/wirings/ai-agent/ai-agent-memory.js +199 -0
  80. package/dist/wirings/ai-agent/ai-agent-model-config.d.ts +9 -0
  81. package/dist/wirings/ai-agent/ai-agent-model-config.js +36 -0
  82. package/dist/wirings/ai-agent/ai-agent-prepare.d.ts +60 -0
  83. package/dist/wirings/ai-agent/ai-agent-prepare.js +312 -0
  84. package/dist/wirings/ai-agent/ai-agent-registry.d.ts +15 -0
  85. package/dist/wirings/ai-agent/ai-agent-registry.js +47 -0
  86. package/dist/wirings/ai-agent/ai-agent-runner.d.ts +3 -0
  87. package/dist/wirings/ai-agent/ai-agent-runner.js +96 -0
  88. package/dist/wirings/ai-agent/ai-agent-stream.d.ts +11 -0
  89. package/dist/wirings/ai-agent/ai-agent-stream.js +503 -0
  90. package/dist/wirings/ai-agent/ai-agent.types.d.ts +254 -0
  91. package/dist/wirings/ai-agent/ai-agent.types.js +1 -0
  92. package/dist/wirings/ai-agent/index.d.ts +5 -0
  93. package/dist/wirings/ai-agent/index.js +4 -0
  94. package/dist/wirings/channel/channel-common.d.ts +7 -4
  95. package/dist/wirings/channel/channel-common.js +15 -8
  96. package/dist/wirings/channel/channel-handler.js +12 -3
  97. package/dist/wirings/channel/channel-middleware-runner.d.ts +9 -0
  98. package/dist/wirings/channel/channel-middleware-runner.js +73 -0
  99. package/dist/wirings/channel/channel-runner.js +7 -7
  100. package/dist/wirings/channel/channel.types.d.ts +5 -1
  101. package/dist/wirings/channel/define-channel-routes.d.ts +21 -0
  102. package/dist/wirings/channel/define-channel-routes.js +23 -0
  103. package/dist/wirings/channel/index.d.ts +10 -8
  104. package/dist/wirings/channel/index.js +7 -8
  105. package/dist/wirings/channel/local/index.d.ts +3 -3
  106. package/dist/wirings/channel/local/index.js +3 -3
  107. package/dist/wirings/channel/local/local-channel-runner.js +18 -6
  108. package/dist/wirings/channel/serverless/index.d.ts +1 -1
  109. package/dist/wirings/channel/serverless/index.js +1 -1
  110. package/dist/wirings/channel/serverless/serverless-channel-runner.js +15 -4
  111. package/dist/wirings/cli/channel/index.d.ts +1 -1
  112. package/dist/wirings/cli/channel/index.js +1 -1
  113. package/dist/wirings/cli/cli-runner.d.ts +1 -1
  114. package/dist/wirings/cli/cli-runner.js +12 -8
  115. package/dist/wirings/cli/cli.types.d.ts +6 -6
  116. package/dist/wirings/cli/define-cli-commands.d.ts +19 -0
  117. package/dist/wirings/cli/define-cli-commands.js +20 -0
  118. package/dist/wirings/cli/index.d.ts +2 -3
  119. package/dist/wirings/cli/index.js +1 -3
  120. package/dist/wirings/http/http-routes.d.ts +69 -0
  121. package/dist/wirings/http/http-routes.js +139 -0
  122. package/dist/wirings/http/http-runner.js +49 -23
  123. package/dist/wirings/http/http.types.d.ts +78 -38
  124. package/dist/wirings/http/index.d.ts +5 -4
  125. package/dist/wirings/http/index.js +4 -3
  126. package/dist/wirings/mcp/index.d.ts +4 -3
  127. package/dist/wirings/mcp/index.js +3 -3
  128. package/dist/wirings/mcp/mcp-runner.d.ts +1 -3
  129. package/dist/wirings/mcp/mcp-runner.js +25 -39
  130. package/dist/wirings/mcp/mcp.types.d.ts +3 -3
  131. package/dist/wirings/node/index.d.ts +2 -0
  132. package/dist/wirings/node/index.js +1 -0
  133. package/dist/wirings/node/node.types.d.ts +20 -0
  134. package/dist/wirings/node/node.types.js +1 -0
  135. package/dist/wirings/oauth2/index.d.ts +3 -0
  136. package/dist/wirings/oauth2/index.js +2 -0
  137. package/dist/wirings/oauth2/oauth2-client.d.ts +47 -0
  138. package/dist/wirings/oauth2/oauth2-client.js +267 -0
  139. package/dist/wirings/oauth2/oauth2.types.d.ts +65 -0
  140. package/dist/wirings/oauth2/oauth2.types.js +4 -0
  141. package/dist/wirings/oauth2/wire-oauth2-credential.d.ts +20 -0
  142. package/dist/wirings/oauth2/wire-oauth2-credential.js +21 -0
  143. package/dist/wirings/queue/index.d.ts +2 -2
  144. package/dist/wirings/queue/index.js +1 -1
  145. package/dist/wirings/queue/queue-runner.d.ts +7 -0
  146. package/dist/wirings/queue/queue-runner.js +17 -6
  147. package/dist/wirings/queue/queue.types.d.ts +8 -2
  148. package/dist/wirings/rpc/index.d.ts +1 -1
  149. package/dist/wirings/rpc/index.js +1 -1
  150. package/dist/wirings/rpc/rpc-runner.d.ts +33 -5
  151. package/dist/wirings/rpc/rpc-runner.js +134 -16
  152. package/dist/wirings/rpc/rpc-types.d.ts +8 -4
  153. package/dist/wirings/scheduler/index.d.ts +3 -3
  154. package/dist/wirings/scheduler/index.js +2 -3
  155. package/dist/wirings/scheduler/scheduler-runner.d.ts +5 -0
  156. package/dist/wirings/scheduler/scheduler-runner.js +23 -5
  157. package/dist/wirings/secret/index.d.ts +3 -0
  158. package/dist/wirings/secret/index.js +2 -0
  159. package/dist/wirings/secret/secret.types.d.ts +27 -0
  160. package/dist/wirings/secret/secret.types.js +1 -0
  161. package/dist/wirings/secret/validate-secret-definitions.d.ts +6 -0
  162. package/dist/wirings/secret/validate-secret-definitions.js +55 -0
  163. package/dist/wirings/trigger/index.d.ts +3 -2
  164. package/dist/wirings/trigger/index.js +2 -2
  165. package/dist/wirings/trigger/pikku-trigger-service.d.ts +26 -0
  166. package/dist/wirings/trigger/pikku-trigger-service.js +75 -0
  167. package/dist/wirings/trigger/trigger-runner.d.ts +21 -8
  168. package/dist/wirings/trigger/trigger-runner.js +46 -18
  169. package/dist/wirings/trigger/trigger.types.d.ts +99 -11
  170. package/dist/wirings/trigger/trigger.types.js +40 -1
  171. package/dist/wirings/variable/index.d.ts +3 -0
  172. package/dist/wirings/variable/index.js +2 -0
  173. package/dist/wirings/variable/validate-variable-definitions.d.ts +6 -0
  174. package/dist/wirings/variable/validate-variable-definitions.js +45 -0
  175. package/dist/wirings/variable/variable.types.d.ts +18 -0
  176. package/dist/wirings/variable/variable.types.js +1 -0
  177. package/dist/wirings/workflow/dsl/index.d.ts +1 -1
  178. package/dist/wirings/workflow/dsl/workflow-dsl.types.d.ts +7 -1
  179. package/dist/wirings/workflow/dsl/workflow-runner.js +3 -2
  180. package/dist/wirings/workflow/graph/graph-node.d.ts +1 -6
  181. package/dist/wirings/workflow/graph/graph-runner.d.ts +5 -31
  182. package/dist/wirings/workflow/graph/graph-runner.js +384 -296
  183. package/dist/wirings/workflow/graph/index.d.ts +4 -3
  184. package/dist/wirings/workflow/graph/index.js +3 -3
  185. package/dist/wirings/workflow/graph/template.d.ts +15 -0
  186. package/dist/wirings/workflow/graph/template.js +27 -0
  187. package/dist/wirings/workflow/graph/wire-workflow-graph.d.ts +15 -0
  188. package/dist/wirings/workflow/graph/wire-workflow-graph.js +8 -0
  189. package/dist/wirings/workflow/graph/workflow-graph.types.d.ts +0 -13
  190. package/dist/wirings/workflow/index.d.ts +6 -6
  191. package/dist/wirings/workflow/index.js +6 -4
  192. package/dist/wirings/workflow/pikku-workflow-service.d.ts +28 -14
  193. package/dist/wirings/workflow/pikku-workflow-service.js +200 -56
  194. package/dist/wirings/workflow/workflow-helpers.d.ts +36 -0
  195. package/dist/wirings/workflow/workflow-helpers.js +38 -0
  196. package/dist/wirings/workflow/workflow-utils.d.ts +1 -23
  197. package/dist/wirings/workflow/workflow-utils.js +1 -66
  198. package/dist/wirings/workflow/workflow.types.d.ts +40 -93
  199. package/package.json +13 -15
  200. package/run-tests.sh +4 -1
  201. package/src/crypto-utils.ts +99 -0
  202. package/src/errors/errors.ts +17 -0
  203. package/src/errors/index.ts +0 -1
  204. package/src/factory-functions.test.ts +42 -2
  205. package/src/function/function-runner.test.ts +4 -11
  206. package/src/function/function-runner.ts +114 -29
  207. package/src/function/functions.types.ts +62 -132
  208. package/src/function/index.ts +5 -2
  209. package/src/handle-error.ts +2 -10
  210. package/src/index.ts +99 -25
  211. package/src/middleware/auth-apikey.test.ts +15 -12
  212. package/src/middleware/auth-apikey.ts +3 -3
  213. package/src/middleware/auth-bearer.test.ts +17 -14
  214. package/src/middleware/auth-bearer.ts +25 -27
  215. package/src/middleware/auth-cookie.test.ts +16 -13
  216. package/src/middleware/auth-cookie.ts +6 -8
  217. package/src/middleware/cors.ts +96 -0
  218. package/src/middleware/index.ts +5 -3
  219. package/src/middleware/remote-auth.ts +68 -0
  220. package/src/middleware-runner.test.ts +122 -0
  221. package/src/middleware-runner.ts +12 -12
  222. package/src/permissions.test.ts +81 -7
  223. package/src/permissions.ts +15 -17
  224. package/src/pikku-state.ts +20 -8
  225. package/src/run-tests-script.test.ts +49 -0
  226. package/src/schema.ts +18 -15
  227. package/src/services/ai-agent-runner-service.ts +29 -0
  228. package/src/services/ai-run-state-service.ts +20 -0
  229. package/src/services/ai-storage-service.ts +39 -0
  230. package/src/services/deployment-service.ts +22 -0
  231. package/src/services/gopass-secrets.ts +95 -0
  232. package/src/services/in-memory-trigger-service.ts +68 -0
  233. package/src/services/in-memory-workflow-service.ts +395 -0
  234. package/src/services/index.ts +49 -14
  235. package/src/services/local-secrets.ts +51 -0
  236. package/src/services/local-variables.ts +22 -0
  237. package/src/services/scheduler-service.ts +29 -1
  238. package/src/services/schema-service.ts +7 -0
  239. package/src/services/scoped-secret-service.ts +41 -0
  240. package/src/services/secret-service.ts +25 -4
  241. package/src/services/trigger-service.ts +38 -0
  242. package/src/services/typed-secret-service.ts +70 -0
  243. package/src/services/typed-variables-service.ts +81 -0
  244. package/src/services/user-session-service.ts +23 -0
  245. package/src/services/variables-service.ts +5 -0
  246. package/src/services/workflow-service.ts +22 -2
  247. package/src/types/core.types.ts +76 -11
  248. package/src/types/state.types.ts +37 -63
  249. package/src/utils.ts +20 -6
  250. package/src/version.test.ts +80 -0
  251. package/src/version.ts +25 -0
  252. package/src/wirings/ai-agent/ai-agent-memory.ts +300 -0
  253. package/src/wirings/ai-agent/ai-agent-model-config.ts +43 -0
  254. package/src/wirings/ai-agent/ai-agent-prepare.ts +470 -0
  255. package/src/wirings/ai-agent/ai-agent-registry.test.ts +37 -0
  256. package/src/wirings/ai-agent/ai-agent-registry.ts +82 -0
  257. package/src/wirings/ai-agent/ai-agent-runner.test.ts +75 -0
  258. package/src/wirings/ai-agent/ai-agent-runner.ts +137 -0
  259. package/src/wirings/ai-agent/ai-agent-stream.test.ts +246 -0
  260. package/src/wirings/ai-agent/ai-agent-stream.ts +774 -0
  261. package/src/wirings/ai-agent/ai-agent.types.ts +273 -0
  262. package/src/wirings/ai-agent/index.ts +28 -0
  263. package/src/wirings/channel/channel-common.ts +32 -19
  264. package/src/wirings/channel/channel-handler.ts +17 -4
  265. package/src/wirings/channel/channel-middleware-runner.ts +119 -0
  266. package/src/wirings/channel/channel-runner.ts +9 -10
  267. package/src/wirings/channel/channel.types.ts +17 -1
  268. package/src/wirings/channel/define-channel-routes.ts +25 -0
  269. package/src/wirings/channel/index.ts +23 -8
  270. package/src/wirings/channel/local/index.ts +3 -3
  271. package/src/wirings/channel/local/local-channel-runner.test.ts +44 -1
  272. package/src/wirings/channel/local/local-channel-runner.ts +22 -6
  273. package/src/wirings/channel/serverless/index.ts +5 -1
  274. package/src/wirings/channel/serverless/serverless-channel-runner.ts +20 -4
  275. package/src/wirings/cli/channel/index.ts +1 -1
  276. package/src/wirings/cli/cli-runner.test.ts +9 -9
  277. package/src/wirings/cli/cli-runner.ts +17 -10
  278. package/src/wirings/cli/cli.types.ts +11 -11
  279. package/src/wirings/cli/command-parser.test.ts +8 -8
  280. package/src/wirings/cli/define-cli-commands.ts +24 -0
  281. package/src/wirings/cli/index.ts +10 -4
  282. package/src/wirings/http/http-routes.test.ts +322 -0
  283. package/src/wirings/http/http-routes.ts +198 -0
  284. package/src/wirings/http/http-runner.test.ts +3 -3
  285. package/src/wirings/http/http-runner.ts +63 -29
  286. package/src/wirings/http/http.types.ts +121 -37
  287. package/src/wirings/http/index.ts +16 -4
  288. package/src/wirings/mcp/index.ts +27 -3
  289. package/src/wirings/mcp/mcp-endpoint-registry.test.ts +3 -3
  290. package/src/wirings/mcp/mcp-runner.ts +39 -50
  291. package/src/wirings/mcp/mcp.types.ts +3 -3
  292. package/src/wirings/node/index.ts +2 -0
  293. package/src/wirings/node/node.types.ts +23 -0
  294. package/src/wirings/oauth2/index.ts +3 -0
  295. package/src/wirings/oauth2/oauth2-client.test.ts +929 -0
  296. package/src/wirings/oauth2/oauth2-client.ts +335 -0
  297. package/src/wirings/oauth2/oauth2.types.ts +69 -0
  298. package/src/wirings/oauth2/wire-oauth2-credential.ts +23 -0
  299. package/src/wirings/queue/index.ts +14 -2
  300. package/src/wirings/queue/queue-runner.test.ts +97 -55
  301. package/src/wirings/queue/queue-runner.ts +33 -7
  302. package/src/wirings/queue/queue.types.ts +12 -2
  303. package/src/wirings/rpc/index.ts +1 -1
  304. package/src/wirings/rpc/rpc-runner.ts +187 -17
  305. package/src/wirings/rpc/rpc-types.ts +13 -4
  306. package/src/wirings/scheduler/index.ts +7 -4
  307. package/src/wirings/scheduler/scheduler-runner.test.ts +70 -26
  308. package/src/wirings/scheduler/scheduler-runner.ts +45 -5
  309. package/src/wirings/secret/index.ts +9 -0
  310. package/src/wirings/secret/secret.types.ts +32 -0
  311. package/src/wirings/secret/validate-secret-definitions.ts +82 -0
  312. package/src/wirings/trigger/index.ts +10 -2
  313. package/src/wirings/trigger/pikku-trigger-service.ts +134 -0
  314. package/src/wirings/trigger/trigger-runner.ts +80 -38
  315. package/src/wirings/trigger/trigger.types.ts +144 -22
  316. package/src/wirings/variable/index.ts +8 -0
  317. package/src/wirings/variable/validate-variable-definitions.ts +69 -0
  318. package/src/wirings/variable/variable.types.ts +22 -0
  319. package/src/wirings/workflow/dsl/index.ts +1 -0
  320. package/src/wirings/workflow/dsl/workflow-dsl.types.ts +9 -1
  321. package/src/wirings/workflow/dsl/workflow-runner.ts +4 -3
  322. package/src/wirings/workflow/graph/graph-node.ts +1 -6
  323. package/src/wirings/workflow/graph/graph-runner.test.ts +495 -0
  324. package/src/wirings/workflow/graph/graph-runner.ts +496 -374
  325. package/src/wirings/workflow/graph/index.ts +14 -3
  326. package/src/wirings/workflow/graph/template.ts +42 -0
  327. package/src/wirings/workflow/graph/wire-workflow-graph.ts +29 -0
  328. package/src/wirings/workflow/graph/workflow-graph.types.ts +0 -22
  329. package/src/wirings/workflow/index.ts +21 -10
  330. package/src/wirings/workflow/pikku-workflow-service.test.ts +212 -0
  331. package/src/wirings/workflow/pikku-workflow-service.ts +285 -66
  332. package/src/wirings/workflow/workflow-helpers.ts +79 -0
  333. package/src/wirings/workflow/workflow-utils.ts +0 -120
  334. package/src/wirings/workflow/workflow.types.ts +45 -90
  335. package/tsconfig.tsbuildinfo +1 -1
  336. package/dist/wirings/forge-node/forge-node.types.d.ts +0 -120
  337. package/dist/wirings/forge-node/forge-node.types.js +0 -38
  338. package/dist/wirings/forge-node/index.d.ts +0 -1
  339. package/dist/wirings/forge-node/index.js +0 -1
  340. package/dist/wirings/workflow/wire-workflow.d.ts +0 -42
  341. package/dist/wirings/workflow/wire-workflow.js +0 -53
  342. package/src/wirings/forge-node/forge-node.types.ts +0 -135
  343. package/src/wirings/forge-node/index.ts +0 -1
  344. package/src/wirings/workflow/wire-workflow.ts +0 -94
@@ -1,4 +1,8 @@
1
1
  import { runMiddleware, combineMiddleware } from '../middleware-runner.js'
2
+ import {
3
+ combineChannelMiddleware,
4
+ wrapChannelWithMiddleware,
5
+ } from '../wirings/channel/channel-middleware-runner.js'
2
6
  import { runPermissions } from '../permissions.js'
3
7
  import { pikkuState } from '../pikku-state.js'
4
8
  import { coerceTopLevelDataFromSchema, validateSchema } from '../schema.js'
@@ -14,12 +18,17 @@ import {
14
18
  CreateWireServices,
15
19
  CoreConfig,
16
20
  } from '../types/core.types.js'
21
+ import type { CorePikkuChannelMiddleware } from '../wirings/channel/channel.types.js'
17
22
  import {
18
23
  CorePermissionGroup,
19
24
  CorePikkuFunctionConfig,
20
25
  CorePikkuPermission,
21
26
  } from './functions.types.js'
22
- import { SessionService } from '../services/user-session-service.js'
27
+ import { parseVersionedId } from '../version.js'
28
+ import {
29
+ SessionService,
30
+ createFunctionSessionWireProps,
31
+ } from '../services/user-session-service.js'
23
32
  import { ForbiddenError } from '../errors/errors.js'
24
33
  import { rpcService } from '../wirings/rpc/rpc-runner.js'
25
34
  import { closeWireServices } from '../utils.js'
@@ -75,6 +84,30 @@ export const addFunction = (
75
84
  pikkuState(packageName, 'function', 'functions').set(funcName, funcConfig)
76
85
  }
77
86
 
87
+ export const getFunctionNames = (
88
+ packageName: string | null = null
89
+ ): string[] => {
90
+ const functionsMeta = pikkuState(packageName, 'function', 'meta')
91
+ return Object.keys(functionsMeta)
92
+ }
93
+
94
+ export const getAllFunctionNames = (): string[] => {
95
+ const functions: string[] = []
96
+
97
+ const mainFunctionsMeta = pikkuState(null, 'function', 'meta')
98
+ functions.push(...Object.keys(mainFunctionsMeta))
99
+
100
+ const externalPackages = pikkuState(null, 'rpc', 'externalPackages')
101
+ for (const [namespace, config] of externalPackages) {
102
+ const packageFunctionsMeta = pikkuState(config.package, 'function', 'meta')
103
+ for (const funcName of Object.keys(packageFunctionsMeta)) {
104
+ functions.push(`${namespace}:${funcName}`)
105
+ }
106
+ }
107
+
108
+ return functions
109
+ }
110
+
78
111
  export const runPikkuFuncDirectly = async <In, Out>(
79
112
  funcName: string,
80
113
  allServices: CoreServices,
@@ -89,10 +122,9 @@ export const runPikkuFuncDirectly = async <In, Out>(
89
122
  if (!funcConfig) {
90
123
  throw new Error(`Function not found: ${funcName}`)
91
124
  }
92
- // Inject session into wire
93
125
  const wireWithSession = {
94
126
  ...wire,
95
- session: userSession,
127
+ ...(userSession && createFunctionSessionWireProps(userSession)),
96
128
  }
97
129
  return (await funcConfig.func(allServices, data, wireWithSession)) as Out
98
130
  }
@@ -108,11 +140,14 @@ export const runPikkuFunc = async <In = any, Out = any>(
108
140
  auth: wiringAuth,
109
141
  inheritedMiddleware,
110
142
  wireMiddleware,
143
+ inheritedChannelMiddleware,
144
+ wireChannelMiddleware,
111
145
  inheritedPermissions,
112
146
  wirePermissions,
113
147
  coerceDataFromSchema,
114
148
  tags = [],
115
149
  wire,
150
+ sessionService,
116
151
  packageName = null,
117
152
  }: {
118
153
  singletonServices: CoreSingletonServices
@@ -121,22 +156,44 @@ export const runPikkuFunc = async <In = any, Out = any>(
121
156
  auth?: boolean
122
157
  inheritedMiddleware?: MiddlewareMetadata[]
123
158
  wireMiddleware?: CorePikkuMiddleware[]
159
+ inheritedChannelMiddleware?: MiddlewareMetadata[]
160
+ wireChannelMiddleware?: CorePikkuChannelMiddleware[]
124
161
  inheritedPermissions?: PermissionMetadata[]
125
162
  wirePermissions?: CorePermissionGroup | CorePikkuPermission[]
126
163
  coerceDataFromSchema?: boolean
127
164
  tags?: string[]
128
165
  wire: PikkuWire
166
+ sessionService?: SessionService<CoreUserSession>
129
167
  packageName?: string | null
130
168
  }
131
169
  ): Promise<Out> => {
132
- const funcConfig = pikkuState(packageName, 'function', 'functions').get(
133
- funcName
134
- )
170
+ wire = {
171
+ ...wire,
172
+ wireType: wire.wireType ?? wireType,
173
+ wireId: wire.wireId ?? wireId,
174
+ }
175
+
176
+ const funcMap = pikkuState(packageName, 'function', 'functions')
177
+ let funcConfig = funcMap.get(funcName)
178
+ const allMeta = pikkuState(packageName, 'function', 'meta')
179
+ let funcMeta = allMeta[funcName]
180
+
181
+ if (!funcConfig || !funcMeta) {
182
+ const { baseName, version } = parseVersionedId(funcName)
183
+ if (version !== null) {
184
+ funcConfig = funcConfig || funcMap.get(baseName)
185
+ funcMeta = funcMeta || allMeta[baseName]
186
+ if (funcConfig && funcMeta) {
187
+ singletonServices.logger.warn(
188
+ `Version '${funcName}' not registered, resolved to '${baseName}'`
189
+ )
190
+ }
191
+ }
192
+ }
193
+
135
194
  if (!funcConfig) {
136
195
  throw new Error(`Function not found: ${funcName}`)
137
196
  }
138
- const allMeta = pikkuState(packageName, 'function', 'meta')
139
- const funcMeta = allMeta[funcName]
140
197
  if (!funcMeta) {
141
198
  throw new Error(`Function meta not found: ${funcName}`)
142
199
  }
@@ -155,6 +212,21 @@ export const runPikkuFunc = async <In = any, Out = any>(
155
212
  }
156
213
  }
157
214
 
215
+ const allChannelMiddleware = combineChannelMiddleware(wireType, wireId, {
216
+ wireInheritedChannelMiddleware: inheritedChannelMiddleware,
217
+ wireChannelMiddleware,
218
+ packageName,
219
+ })
220
+
221
+ const resolvedWire =
222
+ allChannelMiddleware.length > 0 && wire.channel
223
+ ? wrapChannelWithMiddleware(
224
+ wire,
225
+ resolvedSingletonServices,
226
+ allChannelMiddleware
227
+ )
228
+ : wire
229
+
158
230
  // Convert tags to PermissionMetadata and merge with inheritedPermissions
159
231
  const mergedInheritedPermissions: PermissionMetadata[] = [
160
232
  ...(inheritedPermissions || []),
@@ -163,24 +235,38 @@ export const runPikkuFunc = async <In = any, Out = any>(
163
235
 
164
236
  // Helper function to run permissions and execute the function
165
237
  const executeFunction = async () => {
166
- const initialSession = wire.session?.freezeInitial()
238
+ const functionWireProps = sessionService
239
+ ? createFunctionSessionWireProps(sessionService)
240
+ : undefined
167
241
 
168
- const wireWithInitialSession: PikkuWire = {
169
- ...wire,
170
- initialSession,
242
+ const wireWithSession: PikkuWire = {
243
+ ...resolvedWire,
244
+ ...functionWireProps,
171
245
  }
172
246
 
173
- if (wiringAuth === true || funcConfig.auth === true) {
174
- // This means it was explicitly enabled in either wiring or function and has to be respected
175
- if (!initialSession) {
247
+ const session = wireWithSession.session
248
+
249
+ if (funcMeta.sessionless) {
250
+ if (wiringAuth === true || funcConfig.auth === true) {
251
+ if (!session) {
252
+ throw new ForbiddenError('Authentication required')
253
+ }
254
+ }
255
+ } else if (funcMeta.sessionless === false) {
256
+ if (wiringAuth === false || funcConfig.auth === false) {
257
+ resolvedSingletonServices.logger.warn(
258
+ `Function '${funcName}' requires a session but auth was explicitly disabled — use pikkuSessionlessFunc instead.`
259
+ )
260
+ } else if (!session) {
176
261
  throw new ForbiddenError('Authentication required')
177
262
  }
178
- }
179
- if (wiringAuth === undefined && funcConfig.auth === undefined) {
180
- // We always default to requiring auth unless explicitly disabled
181
- if (!initialSession) {
182
- // TODO: Critical, we need to figure out how to make this work with different wirings
183
- // throw new ForbiddenError('Authentication required')
263
+ } else {
264
+ // TODO: Remove after a couple of releases — backward compat for
265
+ // generated metadata that doesn't include the `sessionless` field yet.
266
+ if (wiringAuth === true || funcConfig.auth === true) {
267
+ if (!session) {
268
+ throw new ForbiddenError('Authentication required')
269
+ }
184
270
  }
185
271
  }
186
272
 
@@ -210,23 +296,22 @@ export const runPikkuFunc = async <In = any, Out = any>(
210
296
  funcInheritedPermissions: funcMeta.permissions,
211
297
  funcPermissions: funcConfig.permissions,
212
298
  services: resolvedSingletonServices,
213
- wire: { ...wireWithInitialSession, rpc: undefined } as any,
299
+ wire: { ...wireWithSession, rpc: undefined } as any,
214
300
  data: actualData,
215
301
  packageName,
216
302
  })
217
303
 
218
304
  const wireServices = await resolvedCreateWireServices?.(
219
305
  resolvedSingletonServices,
220
- wireWithInitialSession
306
+ wireWithSession
221
307
  )
222
308
  try {
223
309
  const services = { ...resolvedSingletonServices, ...wireServices }
224
- const rpc = rpcService.getContextRPCService(
225
- services,
226
- wireWithInitialSession
227
- )
310
+ const rpc = rpcService.getContextRPCService(services, wireWithSession, {
311
+ sessionService,
312
+ })
228
313
  return await funcConfig.func(services, actualData, {
229
- ...wireWithInitialSession,
314
+ ...wireWithSession,
230
315
  rpc,
231
316
  })
232
317
  } finally {
@@ -247,7 +332,7 @@ export const runPikkuFunc = async <In = any, Out = any>(
247
332
  if (allMiddleware.length > 0) {
248
333
  return (await runMiddleware<CorePikkuMiddleware>(
249
334
  resolvedSingletonServices,
250
- wire,
335
+ resolvedWire,
251
336
  allMiddleware,
252
337
  executeFunction
253
338
  )) as Out
@@ -6,7 +6,14 @@ import type {
6
6
  PikkuWire,
7
7
  PickRequired,
8
8
  } from '../types/core.types.js'
9
- import { Session } from 'inspector'
9
+ import type { StandardSchemaV1 } from '@standard-schema/spec'
10
+ import type { CoreNodeConfig } from '../wirings/node/node.types.js'
11
+
12
+ /**
13
+ * @deprecated Use StandardSchemaV1 from @standard-schema/spec instead.
14
+ * This alias exists only for backward compatibility with generated code.
15
+ */
16
+ export type ZodLike<T = any> = StandardSchemaV1<T, T>
10
17
 
11
18
  /**
12
19
  * Represents a core API function that performs an operation using core services and a user session.
@@ -20,6 +27,7 @@ export type CorePikkuFunction<
20
27
  In,
21
28
  Out,
22
29
  Services extends CoreSingletonServices = CoreServices,
30
+ Session extends CoreUserSession = CoreUserSession,
23
31
  Wire extends PikkuWire<In, Out> = PikkuWire<In, Out, true, Session>,
24
32
  > = (
25
33
  services: Services,
@@ -39,15 +47,16 @@ export type CorePikkuFunctionSessionless<
39
47
  In,
40
48
  Out,
41
49
  Services extends CoreSingletonServices = CoreServices,
42
- Wire extends PikkuWire<
50
+ Session extends CoreUserSession = CoreUserSession,
51
+ Wire extends PikkuWire<In, Out, false, Session, any, any, any> = PikkuWire<
43
52
  In,
44
53
  Out,
45
54
  false,
46
- CoreUserSession,
55
+ Session,
47
56
  any,
48
57
  any,
49
58
  any
50
- > = PikkuWire<In, Out, false, CoreUserSession, any, any, any>,
59
+ >,
51
60
  > = (
52
61
  services: Services,
53
62
  data: In,
@@ -94,8 +103,8 @@ export type CorePikkuPermissionConfig<
94
103
  > = {
95
104
  /** The permission function */
96
105
  func: CorePikkuPermission<In, Services, Wire>
97
- /** Optional human-readable title for the permission */
98
- title?: string
106
+ /** Optional human-readable name for the permission */
107
+ name?: string
99
108
  /** Optional description of what the permission checks */
100
109
  description?: string
101
110
  }
@@ -108,18 +117,18 @@ export type CorePikkuPermissionConfig<
108
117
  * ```typescript
109
118
  * // Direct function syntax
110
119
  * export const adminPermission = pikkuPermission(
111
- * async ({ logger }, _data, { session }) => {
112
- * const currentSession = await session.get()
120
+ * async ({ logger }, _data, { getSession }) => {
121
+ * const currentSession = await getSession()
113
122
  * return currentSession?.role === 'admin'
114
123
  * }
115
124
  * )
116
125
  *
117
126
  * // Configuration object syntax with metadata
118
127
  * export const adminPermission = pikkuPermission({
119
- * title: 'Admin Permission',
128
+ * name: 'Admin Permission',
120
129
  * description: 'Checks if user has admin role',
121
- * func: async ({ logger }, _data, { session }) => {
122
- * const currentSession = await session.get()
130
+ * func: async ({ logger }, _data, { getSession }) => {
131
+ * const currentSession = await getSession()
123
132
  * return currentSession?.role === 'admin'
124
133
  * }
125
134
  * })
@@ -168,8 +177,8 @@ export type CorePikkuPermissionFactory<
168
177
  * export const requireRole = pikkuPermissionFactory<{ role: string }>(({
169
178
  * role
170
179
  * }) => {
171
- * return pikkuPermission(async ({ logger }, data, { session }) => {
172
- * const currentSession = await session.get()
180
+ * return pikkuPermission(async ({ logger }, data, { getSession }) => {
181
+ * const currentSession = await getSession()
173
182
  * if (!currentSession || currentSession.role !== role) {
174
183
  * logger.warn(`Permission denied: required role '${role}'`)
175
184
  * return false
@@ -185,23 +194,45 @@ export const pikkuPermissionFactory = <In = any>(
185
194
  return factory
186
195
  }
187
196
 
197
+ export type CorePikkuAuth<
198
+ Services extends CoreSingletonServices = CoreServices,
199
+ Session extends CoreUserSession = CoreUserSession,
200
+ > = (services: Services, session: Session) => Promise<boolean> | boolean
201
+
202
+ export type CorePikkuAuthConfig<
203
+ Services extends CoreSingletonServices = CoreServices,
204
+ Session extends CoreUserSession = CoreUserSession,
205
+ > = {
206
+ func: CorePikkuAuth<Services, Session>
207
+ name?: string
208
+ description?: string
209
+ }
210
+
211
+ export const pikkuAuth = <
212
+ Services extends CoreSingletonServices = CoreServices,
213
+ Session extends CoreUserSession = CoreUserSession,
214
+ >(
215
+ auth:
216
+ | CorePikkuAuth<Services, Session>
217
+ | CorePikkuAuthConfig<Services, Session>
218
+ ): CorePikkuPermission<any, Services, any> => {
219
+ const fn = typeof auth === 'function' ? auth : auth.func
220
+ const wrapper = async (services: Services, _data: any, wire: any) => {
221
+ const session = wire.session
222
+ if (!session) return false
223
+ return fn(services, session as Session)
224
+ }
225
+ return wrapper as any
226
+ }
227
+
188
228
  export type CorePermissionGroup<PikkuPermission = CorePikkuPermission<any>> =
189
229
  | Record<string, PikkuPermission | PikkuPermission[]>
190
230
  | undefined
191
231
 
192
- /**
193
- * Zod schema type - matches z.ZodType shape for type inference
194
- * This avoids requiring zod as a dependency while allowing schema inference
195
- */
196
- export type ZodLike<T = any> = {
197
- _input: T
198
- _output: T
199
- }
200
-
201
232
  export type CorePikkuFunctionConfig<
202
233
  PikkuFunction extends
203
- | CorePikkuFunction<any, any, any, any>
204
- | CorePikkuFunctionSessionless<any, any, any, any>,
234
+ | CorePikkuFunction<any, any, any, any, any>
235
+ | CorePikkuFunctionSessionless<any, any, any, any, any>,
205
236
  PikkuPermission extends CorePikkuPermission<
206
237
  any,
207
238
  any,
@@ -211,126 +242,25 @@ export type CorePikkuFunctionConfig<
211
242
  any,
212
243
  any
213
244
  >,
214
- InputSchema extends ZodLike | undefined = undefined,
215
- OutputSchema extends ZodLike | undefined = undefined,
245
+ InputSchema extends StandardSchemaV1 | undefined = undefined,
246
+ OutputSchema extends StandardSchemaV1 | undefined = undefined,
216
247
  > = {
217
248
  /** Optional human-readable title for the function */
218
249
  title?: string
219
250
  /** Optional description of what the function does */
220
251
  description?: string
221
252
  override?: string
253
+ version?: number
222
254
  tags?: string[]
223
255
  expose?: boolean
224
- internal?: boolean
256
+ remote?: boolean
257
+ mcp?: boolean
258
+ requiresApproval?: boolean
225
259
  func: PikkuFunction
226
260
  auth?: boolean
227
261
  permissions?: CorePermissionGroup<PikkuPermission>
228
262
  middleware?: PikkuMiddleware[]
229
263
  input?: InputSchema
230
264
  output?: OutputSchema
231
- }
232
-
233
- /**
234
- * A trigger function that sets up a subscription and returns a teardown function.
235
- * The trigger is fired via wire.trigger.trigger(data).
236
- *
237
- * @template TConfig - Configuration type (hardcoded when wired)
238
- * @template TOutput - Output type produced when trigger fires
239
- * @template Services - Services available to the trigger
240
- */
241
- export type CorePikkuTriggerFunction<
242
- TConfig = unknown,
243
- TOutput = unknown,
244
- Services extends CoreSingletonServices = CoreSingletonServices,
245
- > = (
246
- services: Services,
247
- config: TConfig,
248
- wire: { trigger: { trigger: (data: TOutput) => void } }
249
- ) => Promise<() => void | Promise<void>>
250
-
251
- /**
252
- * Configuration object for creating a trigger function with metadata
253
- */
254
- export type CorePikkuTriggerFunctionConfig<
255
- TConfig = unknown,
256
- TOutput = unknown,
257
- Services extends CoreSingletonServices = CoreSingletonServices,
258
- ConfigSchema extends ZodLike | undefined = undefined,
259
- OutputSchema extends ZodLike | undefined = undefined,
260
- > = {
261
- /** Optional human-readable title for the trigger */
262
- title?: string
263
- /** Optional description of what the trigger does */
264
- description?: string
265
- /** Optional tags for categorization */
266
- tags?: string[]
267
- /** The trigger function */
268
- func: CorePikkuTriggerFunction<TConfig, TOutput, Services>
269
- /** Optional Zod schema for config validation */
270
- config?: ConfigSchema
271
- /** Optional Zod schema for output validation */
272
- output?: OutputSchema
273
- }
274
-
275
- /**
276
- * Factory function for creating trigger functions
277
- * Supports both direct function and configuration object syntax
278
- *
279
- * @example
280
- * ```typescript
281
- * // Direct function syntax
282
- * export const redisSubscribeTrigger = pikkuTriggerFunc<
283
- * { channel: string },
284
- * { message: string }
285
- * >(async ({ redis }, { channel }, { trigger }) => {
286
- * const subscriber = redis.duplicate()
287
- * await subscriber.subscribe(channel, (msg) => {
288
- * trigger.trigger({ message: msg })
289
- * })
290
- * return () => subscriber.unsubscribe()
291
- * })
292
- *
293
- * // Configuration object syntax with metadata
294
- * export const redisSubscribeTrigger = pikkuTriggerFunc({
295
- * title: 'Redis Subscribe Trigger',
296
- * description: 'Listens to Redis pub/sub channel',
297
- * config: z.object({ channel: z.string() }),
298
- * output: z.object({ message: z.string() }),
299
- * func: async ({ redis }, { channel }, { trigger }) => {
300
- * const subscriber = redis.duplicate()
301
- * await subscriber.subscribe(channel, (msg) => {
302
- * trigger.trigger({ message: msg })
303
- * })
304
- * return () => subscriber.unsubscribe()
305
- * }
306
- * })
307
- * ```
308
- */
309
- export const pikkuTriggerFunc = <
310
- TConfig = unknown,
311
- TOutput = unknown,
312
- Services extends CoreSingletonServices = CoreSingletonServices,
313
- ConfigSchema extends ZodLike | undefined = undefined,
314
- OutputSchema extends ZodLike | undefined = undefined,
315
- >(
316
- triggerOrConfig:
317
- | CorePikkuTriggerFunction<TConfig, TOutput, Services>
318
- | CorePikkuTriggerFunctionConfig<
319
- TConfig,
320
- TOutput,
321
- Services,
322
- ConfigSchema,
323
- OutputSchema
324
- >
325
- ): CorePikkuTriggerFunctionConfig<
326
- TConfig,
327
- TOutput,
328
- Services,
329
- ConfigSchema,
330
- OutputSchema
331
- > => {
332
- if (typeof triggerOrConfig === 'function') {
333
- return { func: triggerOrConfig }
334
- }
335
- return triggerOrConfig
265
+ node?: CoreNodeConfig
336
266
  }
@@ -1,2 +1,5 @@
1
- export * from './function-runner.js'
2
- export * from './functions.types.js'
1
+ export { addFunction, getAllFunctionNames } from './function-runner.js'
2
+ export type {
3
+ CorePikkuFunction,
4
+ CorePikkuFunctionSessionless,
5
+ } from './functions.types.js'
@@ -57,17 +57,9 @@ export const handleHTTPError = (
57
57
  }
58
58
  }
59
59
 
60
- // Handle 404 errors specifically
61
- if (e instanceof NotFoundError) {
62
- // TODO
63
- // http?.response?.end()
64
- }
65
-
66
- // Either bubble up or end the response
67
60
  if (bubbleError) {
68
61
  throw e
69
- } else {
70
- // TODO
71
- // http?.response?.end()
72
62
  }
63
+
64
+ http?.response?.close?.()
73
65
  }
package/src/index.ts CHANGED
@@ -1,37 +1,111 @@
1
1
  /**
2
2
  * @module @pikku/core
3
3
  */
4
- export * from './types/core.types.js'
5
- export * from './function/index.js'
6
- export * from './pikku-request.js'
7
- export * from './pikku-response.js'
8
- export * from './services/logger.js'
9
- export * from './services/schema-service.js'
10
- export * from './services/jwt-service.js'
11
- export * from './services/secret-service.js'
12
- export * from './services/user-session-service.js'
13
- export * from './services/scheduler-service.js'
14
- export * from './wirings/http/index.js'
15
- export * from './wirings/channel/index.js'
16
- export * from './wirings/scheduler/index.js'
17
- export * from './wirings/rpc/index.js'
18
- export * from './wirings/queue/index.js'
19
- export * from './wirings/workflow/index.js'
20
- export * from './wirings/workflow/graph/index.js'
21
- export * from './wirings/mcp/index.js'
22
- export * from './wirings/cli/index.js'
23
- export * from './wirings/forge-node/index.js'
24
- export * from './wirings/trigger/index.js'
25
- export * from './errors/index.js'
26
- export * from './middleware/index.js'
27
- export * from './utils.js'
28
- export * from './time-utils.js'
4
+ export type {
5
+ CommonWireMeta,
6
+ CoreConfig,
7
+ CorePikkuMiddleware,
8
+ CorePikkuMiddlewareConfig,
9
+ CorePikkuMiddlewareFactory,
10
+ CorePikkuMiddlewareGroup,
11
+ CoreServices,
12
+ CoreSingletonServices,
13
+ CoreUserSession,
14
+ CreateConfig,
15
+ CreateSingletonServices,
16
+ CreateWireServices,
17
+ FunctionMeta,
18
+ FunctionRuntimeMeta,
19
+ FunctionServicesMeta,
20
+ FunctionWiresMeta,
21
+ FunctionsMeta,
22
+ FunctionsRuntimeMeta,
23
+ JSONPrimitive,
24
+ JSONValue,
25
+ MakeRequired,
26
+ MiddlewareMetadata,
27
+ PermissionMetadata,
28
+ PickOptional,
29
+ PickRequired,
30
+ PikkuAIMiddlewareHooks,
31
+ PikkuWire,
32
+ PikkuWiringTypes,
33
+ RequireAtLeastOne,
34
+ SerializedError,
35
+ WireServices,
36
+ } from './types/core.types.js'
37
+ export {
38
+ pikkuAIMiddleware,
39
+ pikkuChannelMiddleware,
40
+ pikkuChannelMiddlewareFactory,
41
+ pikkuMiddleware,
42
+ pikkuMiddlewareFactory,
43
+ } from './types/core.types.js'
44
+ export type {
45
+ CorePikkuAuth,
46
+ CorePikkuAuthConfig,
47
+ CorePikkuFunction,
48
+ CorePikkuFunctionConfig,
49
+ CorePikkuPermission,
50
+ CorePikkuPermissionConfig,
51
+ CorePikkuPermissionFactory,
52
+ CorePermissionGroup,
53
+ ZodLike,
54
+ } from './function/functions.types.js'
55
+ export {
56
+ pikkuAuth,
57
+ pikkuPermission,
58
+ pikkuPermissionFactory,
59
+ } from './function/functions.types.js'
60
+ export { addFunction, getAllFunctionNames } from './function/index.js'
61
+ export { PikkuRequest } from './pikku-request.js'
62
+ export {
63
+ getRelativeTimeOffsetFromNow,
64
+ parseDurationString,
65
+ } from './time-utils.js'
66
+ export type { RelativeTimeInput } from './time-utils.js'
67
+ export {
68
+ formatVersionedId,
69
+ isVersionedId,
70
+ parseVersionedId,
71
+ } from './version.js'
29
72
  export {
30
73
  pikkuState,
31
74
  initializePikkuState,
32
75
  resetPikkuState,
33
76
  addPackageServiceFactories,
77
+ getPikkuMetaDir,
34
78
  } from './pikku-state.js'
79
+ export { runPikkuFunc } from './function/function-runner.js'
80
+ export { runCLICommand, pikkuCLIRender } from './wirings/cli/cli-runner.js'
81
+ export { fetch } from './wirings/http/http-runner.js'
82
+ export {
83
+ runMCPTool,
84
+ runMCPResource,
85
+ runMCPPrompt,
86
+ } from './wirings/mcp/mcp-runner.js'
87
+ export type {
88
+ MCPToolResponse,
89
+ MCPResourceResponse,
90
+ MCPPromptResponse,
91
+ } from './wirings/mcp/mcp.types.js'
92
+ export { runQueueJob } from './wirings/queue/queue-runner.js'
93
+ export { runScheduledTask } from './wirings/scheduler/scheduler-runner.js'
94
+ export { NotFoundError } from './errors/errors.js'
95
+ export type { EventHubService } from './wirings/channel/eventhub-service.js'
96
+ export type { QueueService } from './wirings/queue/queue.types.js'
97
+ export type { JWTService } from './services/jwt-service.js'
98
+ export type { HTTPMethod } from './wirings/http/http.types.js'
99
+ export type { GraphNodeConfig } from './wirings/workflow/graph/workflow-graph.types.js'
100
+ export { createGraph } from './wirings/workflow/graph/graph-node.js'
101
+ export { workflow as wireWorkflow } from './wirings/workflow/workflow-helpers.js'
35
102
  export type { PikkuPackageState } from './types/state.types.js'
36
103
  export { runMiddleware, addMiddleware } from './middleware-runner.js'
37
104
  export { addPermission } from './permissions.js'
105
+ export { isSerializable, stopSingletonServices } from './utils.js'
106
+ export {
107
+ type ScheduledTaskInfo,
108
+ type ScheduledTaskSummary,
109
+ type SchedulerRuntimeHandlers,
110
+ } from './services/scheduler-service.js'
111
+ export { SchedulerService } from './services/scheduler-service.js'