@pikku/addon-ollama 0.1.1 → 0.1.3

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 (268) hide show
  1. package/.pikku/addon/pikku-addon-types.gen.ts +105 -0
  2. package/.pikku/addon/pikku-package.gen.ts +11 -0
  3. package/.pikku/agent/pikku-agent-map.gen.d.ts +4 -0
  4. package/.pikku/agent/pikku-agent-types.gen.ts +84 -0
  5. package/.pikku/channel/pikku-channel-types.gen.ts +177 -0
  6. package/.pikku/console/pikku-addon-meta.gen.json +61 -0
  7. package/.pikku/console/pikku-node-types.gen.ts +8 -0
  8. package/.pikku/function/pikku-function-types.gen.ts +797 -0
  9. package/.pikku/function/pikku-functions-meta-verbose.gen.json +126 -0
  10. package/.pikku/function/pikku-functions-meta.gen.json +102 -0
  11. package/.pikku/function/pikku-functions-meta.gen.ts +7 -0
  12. package/.pikku/function/pikku-functions.gen.ts +14 -0
  13. package/.pikku/http/pikku-http-types.gen.ts +119 -0
  14. package/.pikku/mcp/pikku-mcp-types.gen.ts +183 -0
  15. package/.pikku/pikku-bootstrap-scenarios.gen.ts +9 -0
  16. package/.pikku/pikku-bootstrap.gen.ts +8 -0
  17. package/.pikku/pikku-meta-service.gen.ts +10 -0
  18. package/.pikku/pikku-services.gen.ts +50 -0
  19. package/.pikku/pikku-types.gen.ts +24 -0
  20. package/.pikku/queue/pikku-queue-types.gen.ts +27 -0
  21. package/.pikku/rpc/pikku-rpc-wirings-map.gen.d.ts +207 -0
  22. package/.pikku/rpc/pikku-rpc-wirings-map.internal.gen.d.ts +211 -0
  23. package/.pikku/rpc/pikku-rpc-wirings-map.remote.gen.d.ts +207 -0
  24. package/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.json +6 -0
  25. package/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.ts +6 -0
  26. package/.pikku/scenarios/features.gen.json +1 -0
  27. package/.pikku/scenarios/pikku-scenario-functions-meta.gen.json +1 -0
  28. package/.pikku/scenarios/pikku-scenario-functions-meta.gen.ts +12 -0
  29. package/.pikku/scenarios/pikku-scenario-functions.gen.ts +4 -0
  30. package/.pikku/scenarios/pikku-scenario-wirings-meta.gen.ts +15 -0
  31. package/.pikku/scenarios/pikku-scenario-wirings.gen.ts +4 -0
  32. package/.pikku/scenarios/schemas/register.gen.ts +4 -0
  33. package/.pikku/scheduler/pikku-scheduler-types.gen.ts +25 -0
  34. package/.pikku/schemas/register.gen.ts +39 -0
  35. package/.pikku/schemas/schemas/OllamaEmbedInput.schema.json +1 -0
  36. package/.pikku/schemas/schemas/OllamaEmbedManyInput.schema.json +1 -0
  37. package/.pikku/schemas/schemas/OllamaEmbedManyOutput.schema.json +1 -0
  38. package/.pikku/schemas/schemas/OllamaEmbedOutput.schema.json +1 -0
  39. package/.pikku/schemas/schemas/OllamaGenerateObjectInput.schema.json +1 -0
  40. package/.pikku/schemas/schemas/OllamaGenerateObjectOutput.schema.json +1 -0
  41. package/.pikku/schemas/schemas/OllamaGenerateTextInput.schema.json +1 -0
  42. package/.pikku/schemas/schemas/OllamaGenerateTextOutput.schema.json +1 -0
  43. package/.pikku/schemas/schemas/VariableSchema_ollama_base_url.schema.json +1 -0
  44. package/.pikku/scopes/pikku-personas-meta.gen.json +1 -0
  45. package/.pikku/scopes/pikku-personas.gen.ts +52 -0
  46. package/.pikku/scopes/pikku-roles-meta.gen.json +1 -0
  47. package/.pikku/scopes/pikku-roles.gen.ts +41 -0
  48. package/.pikku/scopes/pikku-scope-types.gen.ts +7 -0
  49. package/.pikku/scopes/pikku-scopes-meta.gen.json +1 -0
  50. package/.pikku/scopes/pikku-scopes.gen.ts +58 -0
  51. package/.pikku/secrets/pikku-secret-types.gen.ts +5 -0
  52. package/.pikku/secrets/pikku-secrets-meta.gen.json +1 -0
  53. package/.pikku/secrets/pikku-secrets.gen.ts +34 -0
  54. package/.pikku/trigger/pikku-trigger-types.gen.ts +160 -0
  55. package/.pikku/variables/pikku-variable-types.gen.ts +5 -0
  56. package/.pikku/variables/pikku-variables-meta.gen.json +10 -0
  57. package/.pikku/variables/pikku-variables.gen.ts +36 -0
  58. package/.pikku/workflow/personas.gen.json +1 -0
  59. package/.pikku/workflow/pikku-personas.gen.ts +38 -0
  60. package/.pikku/workflow/pikku-scenario-step-map.gen.d.ts +18 -0
  61. package/.pikku/workflow/pikku-workflow-map.gen.d.ts +38 -0
  62. package/.pikku/workflow/pikku-workflow-types.gen.ts +591 -0
  63. package/.pikku/workflow/pikku-workflow-wirings-meta.gen.ts +9 -0
  64. package/.pikku/workflow/pikku-workflow-wirings.gen.ts +3 -0
  65. package/dist/.pikku/addon/pikku-addon-types.gen.d.ts +4 -4
  66. package/dist/.pikku/addon/pikku-addon-types.gen.d.ts.map +1 -1
  67. package/dist/.pikku/addon/pikku-addon-types.gen.js +7 -3
  68. package/dist/.pikku/addon/pikku-addon-types.gen.js.map +1 -1
  69. package/dist/.pikku/addon/pikku-addon-types.gen.ts +11 -6
  70. package/dist/.pikku/addon/pikku-package.gen.js +2 -1
  71. package/dist/.pikku/addon/pikku-package.gen.js.map +1 -1
  72. package/dist/.pikku/addon/pikku-package.gen.ts +3 -1
  73. package/dist/.pikku/agent/pikku-agent-map.gen.d.ts +2 -14
  74. package/dist/.pikku/agent/pikku-agent-types.gen.d.ts +8 -6
  75. package/dist/.pikku/agent/pikku-agent-types.gen.d.ts.map +1 -1
  76. package/dist/.pikku/agent/pikku-agent-types.gen.js.map +1 -1
  77. package/dist/.pikku/agent/pikku-agent-types.gen.ts +15 -7
  78. package/dist/.pikku/channel/pikku-channel-types.gen.d.ts +112 -0
  79. package/dist/.pikku/channel/pikku-channel-types.gen.d.ts.map +1 -0
  80. package/dist/.pikku/channel/pikku-channel-types.gen.js +60 -0
  81. package/dist/.pikku/channel/pikku-channel-types.gen.js.map +1 -0
  82. package/dist/.pikku/channel/pikku-channel-types.gen.ts +177 -0
  83. package/dist/.pikku/console/pikku-addon-meta.gen.json +31 -28
  84. package/dist/.pikku/console/pikku-node-types.gen.d.ts +1 -1
  85. package/dist/.pikku/console/pikku-node-types.gen.ts +1 -1
  86. package/dist/.pikku/function/pikku-function-types.gen.d.ts +133 -133
  87. package/dist/.pikku/function/pikku-function-types.gen.d.ts.map +1 -1
  88. package/dist/.pikku/function/pikku-function-types.gen.js +98 -61
  89. package/dist/.pikku/function/pikku-function-types.gen.js.map +1 -1
  90. package/dist/.pikku/function/pikku-function-types.gen.ts +268 -157
  91. package/dist/.pikku/function/pikku-functions-meta-verbose.gen.json +64 -44
  92. package/dist/.pikku/function/pikku-functions-meta.gen.js +1 -1
  93. package/dist/.pikku/function/pikku-functions-meta.gen.json +67 -39
  94. package/dist/.pikku/function/pikku-functions-meta.gen.ts +1 -1
  95. package/dist/.pikku/function/pikku-functions.gen.js +2 -2
  96. package/dist/.pikku/function/pikku-functions.gen.js.map +1 -1
  97. package/dist/.pikku/function/pikku-functions.gen.ts +2 -2
  98. package/dist/.pikku/http/pikku-http-types.gen.d.ts +98 -0
  99. package/dist/.pikku/http/pikku-http-types.gen.d.ts.map +1 -0
  100. package/dist/.pikku/http/pikku-http-types.gen.js +50 -0
  101. package/dist/.pikku/http/pikku-http-types.gen.js.map +1 -0
  102. package/dist/.pikku/http/pikku-http-types.gen.ts +119 -0
  103. package/dist/.pikku/mcp/pikku-mcp-types.gen.d.ts +131 -0
  104. package/dist/.pikku/mcp/pikku-mcp-types.gen.d.ts.map +1 -0
  105. package/dist/.pikku/mcp/pikku-mcp-types.gen.js +38 -0
  106. package/dist/.pikku/mcp/pikku-mcp-types.gen.js.map +1 -0
  107. package/dist/.pikku/mcp/pikku-mcp-types.gen.ts +183 -0
  108. package/dist/.pikku/pikku-bootstrap-scenarios.gen.d.ts +10 -0
  109. package/dist/.pikku/pikku-bootstrap-scenarios.gen.d.ts.map +1 -0
  110. package/dist/.pikku/pikku-bootstrap-scenarios.gen.js +10 -0
  111. package/dist/.pikku/pikku-bootstrap-scenarios.gen.js.map +1 -0
  112. package/dist/.pikku/pikku-bootstrap-scenarios.gen.ts +9 -0
  113. package/dist/.pikku/pikku-bootstrap.gen.d.ts +4 -2
  114. package/dist/.pikku/pikku-bootstrap.gen.d.ts.map +1 -1
  115. package/dist/.pikku/pikku-bootstrap.gen.js +2 -10
  116. package/dist/.pikku/pikku-bootstrap.gen.js.map +1 -1
  117. package/dist/.pikku/pikku-bootstrap.gen.ts +2 -9
  118. package/dist/.pikku/pikku-meta-service.gen.d.ts +8 -0
  119. package/dist/.pikku/pikku-meta-service.gen.d.ts.map +1 -0
  120. package/dist/.pikku/pikku-meta-service.gen.js +10 -0
  121. package/dist/.pikku/pikku-meta-service.gen.js.map +1 -0
  122. package/dist/.pikku/pikku-meta-service.gen.ts +10 -0
  123. package/dist/.pikku/pikku-services.gen.d.ts +15 -2
  124. package/dist/.pikku/pikku-services.gen.d.ts.map +1 -1
  125. package/dist/.pikku/pikku-services.gen.js +14 -0
  126. package/dist/.pikku/pikku-services.gen.js.map +1 -1
  127. package/dist/.pikku/pikku-services.gen.ts +17 -2
  128. package/dist/.pikku/pikku-types.gen.d.ts +2 -1
  129. package/dist/.pikku/pikku-types.gen.d.ts.map +1 -1
  130. package/dist/.pikku/pikku-types.gen.js +3 -1
  131. package/dist/.pikku/pikku-types.gen.js.map +1 -1
  132. package/dist/.pikku/pikku-types.gen.ts +4 -1
  133. package/dist/.pikku/queue/pikku-queue-types.gen.d.ts +24 -0
  134. package/dist/.pikku/queue/pikku-queue-types.gen.d.ts.map +1 -0
  135. package/dist/.pikku/queue/pikku-queue-types.gen.js +17 -0
  136. package/dist/.pikku/queue/pikku-queue-types.gen.js.map +1 -0
  137. package/dist/.pikku/queue/pikku-queue-types.gen.ts +27 -0
  138. package/dist/.pikku/rpc/pikku-rpc-wirings-map.gen.d.ts +81 -62
  139. package/dist/.pikku/rpc/pikku-rpc-wirings-map.internal.gen.d.ts +84 -65
  140. package/dist/.pikku/rpc/pikku-rpc-wirings-map.remote.gen.d.ts +207 -0
  141. package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.d.ts +2 -0
  142. package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.d.ts.map +1 -0
  143. package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.js +7 -0
  144. package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.js.map +1 -0
  145. package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.json +6 -0
  146. package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.ts +6 -0
  147. package/dist/.pikku/scenarios/features.gen.json +1 -0
  148. package/dist/.pikku/scenarios/pikku-scenario-functions-meta.gen.d.ts +2 -0
  149. package/dist/.pikku/scenarios/pikku-scenario-functions-meta.gen.d.ts.map +1 -0
  150. package/dist/.pikku/scenarios/pikku-scenario-functions-meta.gen.js +11 -0
  151. package/dist/.pikku/scenarios/pikku-scenario-functions-meta.gen.js.map +1 -0
  152. package/dist/.pikku/scenarios/pikku-scenario-functions-meta.gen.json +1 -0
  153. package/dist/.pikku/scenarios/pikku-scenario-functions-meta.gen.ts +12 -0
  154. package/dist/.pikku/scenarios/pikku-scenario-functions.gen.d.ts +5 -0
  155. package/dist/.pikku/scenarios/pikku-scenario-functions.gen.d.ts.map +1 -0
  156. package/dist/.pikku/scenarios/pikku-scenario-functions.gen.js +2 -0
  157. package/dist/.pikku/scenarios/pikku-scenario-functions.gen.js.map +1 -0
  158. package/dist/.pikku/scenarios/pikku-scenario-functions.gen.ts +4 -0
  159. package/dist/.pikku/scenarios/pikku-scenario-wirings-meta.gen.d.ts +2 -0
  160. package/dist/.pikku/scenarios/pikku-scenario-wirings-meta.gen.d.ts.map +1 -0
  161. package/dist/.pikku/scenarios/pikku-scenario-wirings-meta.gen.js +11 -0
  162. package/dist/.pikku/scenarios/pikku-scenario-wirings-meta.gen.js.map +1 -0
  163. package/dist/.pikku/scenarios/pikku-scenario-wirings-meta.gen.ts +15 -0
  164. package/dist/.pikku/scenarios/pikku-scenario-wirings.gen.d.ts +5 -0
  165. package/dist/.pikku/scenarios/pikku-scenario-wirings.gen.d.ts.map +1 -0
  166. package/dist/.pikku/scenarios/pikku-scenario-wirings.gen.js +2 -0
  167. package/dist/.pikku/scenarios/pikku-scenario-wirings.gen.js.map +1 -0
  168. package/dist/.pikku/scenarios/pikku-scenario-wirings.gen.ts +4 -0
  169. package/dist/.pikku/scenarios/schemas/register.gen.d.ts +5 -0
  170. package/dist/.pikku/scenarios/schemas/register.gen.d.ts.map +1 -0
  171. package/dist/.pikku/scenarios/schemas/register.gen.js +5 -0
  172. package/dist/.pikku/scenarios/schemas/register.gen.js.map +1 -0
  173. package/dist/.pikku/scenarios/schemas/register.gen.ts +4 -0
  174. package/dist/.pikku/scheduler/pikku-scheduler-types.gen.d.ts +22 -0
  175. package/dist/.pikku/scheduler/pikku-scheduler-types.gen.d.ts.map +1 -0
  176. package/dist/.pikku/scheduler/pikku-scheduler-types.gen.js +17 -0
  177. package/dist/.pikku/scheduler/pikku-scheduler-types.gen.js.map +1 -0
  178. package/dist/.pikku/scheduler/pikku-scheduler-types.gen.ts +25 -0
  179. package/dist/.pikku/schemas/register.gen.js +11 -11
  180. package/dist/.pikku/schemas/register.gen.js.map +1 -1
  181. package/dist/.pikku/schemas/register.gen.ts +17 -17
  182. package/dist/.pikku/scopes/pikku-personas-meta.gen.json +1 -0
  183. package/dist/.pikku/scopes/pikku-personas.gen.d.ts +37 -0
  184. package/dist/.pikku/scopes/pikku-personas.gen.d.ts.map +1 -0
  185. package/dist/.pikku/scopes/pikku-personas.gen.js +18 -0
  186. package/dist/.pikku/scopes/pikku-personas.gen.js.map +1 -0
  187. package/dist/.pikku/scopes/pikku-personas.gen.ts +52 -0
  188. package/dist/.pikku/scopes/pikku-roles-meta.gen.json +1 -0
  189. package/dist/.pikku/scopes/pikku-roles.gen.d.ts +31 -0
  190. package/dist/.pikku/scopes/pikku-roles.gen.d.ts.map +1 -0
  191. package/dist/.pikku/scopes/pikku-roles.gen.js +19 -0
  192. package/dist/.pikku/scopes/pikku-roles.gen.js.map +1 -0
  193. package/dist/.pikku/scopes/pikku-roles.gen.ts +41 -0
  194. package/dist/.pikku/scopes/pikku-scope-types.gen.d.ts +8 -0
  195. package/dist/.pikku/scopes/pikku-scope-types.gen.d.ts.map +1 -0
  196. package/dist/.pikku/scopes/pikku-scope-types.gen.js +6 -0
  197. package/dist/.pikku/scopes/pikku-scope-types.gen.js.map +1 -0
  198. package/dist/.pikku/scopes/pikku-scope-types.gen.ts +7 -0
  199. package/dist/.pikku/scopes/pikku-scopes-meta.gen.json +1 -0
  200. package/dist/.pikku/scopes/pikku-scopes.gen.d.ts +36 -0
  201. package/dist/.pikku/scopes/pikku-scopes.gen.d.ts.map +1 -0
  202. package/dist/.pikku/scopes/pikku-scopes.gen.js +28 -0
  203. package/dist/.pikku/scopes/pikku-scopes.gen.js.map +1 -0
  204. package/dist/.pikku/scopes/pikku-scopes.gen.ts +58 -0
  205. package/dist/.pikku/secrets/pikku-secret-types.gen.d.ts +2 -2
  206. package/dist/.pikku/secrets/pikku-secret-types.gen.d.ts.map +1 -1
  207. package/dist/.pikku/secrets/pikku-secret-types.gen.js +2 -2
  208. package/dist/.pikku/secrets/pikku-secret-types.gen.js.map +1 -1
  209. package/dist/.pikku/secrets/pikku-secret-types.gen.ts +2 -2
  210. package/dist/.pikku/secrets/pikku-secrets.gen.d.ts +11 -1
  211. package/dist/.pikku/secrets/pikku-secrets.gen.d.ts.map +1 -1
  212. package/dist/.pikku/secrets/pikku-secrets.gen.js +11 -1
  213. package/dist/.pikku/secrets/pikku-secrets.gen.js.map +1 -1
  214. package/dist/.pikku/secrets/pikku-secrets.gen.ts +14 -1
  215. package/dist/.pikku/trigger/pikku-trigger-types.gen.d.ts +1 -1
  216. package/dist/.pikku/trigger/pikku-trigger-types.gen.js +1 -1
  217. package/dist/.pikku/trigger/pikku-trigger-types.gen.ts +1 -1
  218. package/dist/.pikku/variables/pikku-variable-types.gen.d.ts +2 -2
  219. package/dist/.pikku/variables/pikku-variable-types.gen.d.ts.map +1 -1
  220. package/dist/.pikku/variables/pikku-variable-types.gen.js +2 -2
  221. package/dist/.pikku/variables/pikku-variable-types.gen.js.map +1 -1
  222. package/dist/.pikku/variables/pikku-variable-types.gen.ts +2 -2
  223. package/dist/.pikku/variables/pikku-variables.gen.d.ts +11 -1
  224. package/dist/.pikku/variables/pikku-variables.gen.d.ts.map +1 -1
  225. package/dist/.pikku/variables/pikku-variables.gen.js +14 -4
  226. package/dist/.pikku/variables/pikku-variables.gen.js.map +1 -1
  227. package/dist/.pikku/variables/pikku-variables.gen.ts +17 -4
  228. package/dist/.pikku/workflow/personas.gen.json +1 -0
  229. package/dist/.pikku/workflow/pikku-personas.gen.d.ts +16 -0
  230. package/dist/.pikku/workflow/pikku-personas.gen.d.ts.map +1 -0
  231. package/dist/.pikku/workflow/pikku-personas.gen.js +18 -0
  232. package/dist/.pikku/workflow/pikku-personas.gen.js.map +1 -0
  233. package/dist/.pikku/workflow/pikku-personas.gen.ts +38 -0
  234. package/dist/.pikku/workflow/pikku-scenario-step-map.gen.d.ts +18 -0
  235. package/dist/.pikku/workflow/pikku-workflow-map.gen.d.ts +9 -5
  236. package/dist/.pikku/workflow/pikku-workflow-types.gen.d.ts +289 -31
  237. package/dist/.pikku/workflow/pikku-workflow-types.gen.d.ts.map +1 -1
  238. package/dist/.pikku/workflow/pikku-workflow-types.gen.js +66 -18
  239. package/dist/.pikku/workflow/pikku-workflow-types.gen.js.map +1 -1
  240. package/dist/.pikku/workflow/pikku-workflow-types.gen.ts +494 -61
  241. package/dist/.pikku/workflow/pikku-workflow-wirings-meta.gen.js +1 -1
  242. package/dist/.pikku/workflow/pikku-workflow-wirings-meta.gen.js.map +1 -1
  243. package/dist/.pikku/workflow/pikku-workflow-wirings-meta.gen.ts +3 -3
  244. package/dist/.pikku/workflow/pikku-workflow-wirings.gen.d.ts +1 -1
  245. package/dist/.pikku/workflow/pikku-workflow-wirings.gen.js +1 -1
  246. package/dist/.pikku/workflow/pikku-workflow-wirings.gen.ts +1 -1
  247. package/dist/src/functions/embeddings/embed-many.function.d.ts +2 -2
  248. package/dist/src/functions/embeddings/embed-many.function.d.ts.map +1 -1
  249. package/dist/src/functions/embeddings/embed.function.d.ts +2 -2
  250. package/dist/src/functions/embeddings/embed.function.d.ts.map +1 -1
  251. package/dist/src/functions/text/generate-object.function.d.ts +7 -7
  252. package/dist/src/functions/text/generate-object.function.d.ts.map +1 -1
  253. package/dist/src/functions/text/generate.function.d.ts +2 -2
  254. package/dist/src/functions/text/generate.function.d.ts.map +1 -1
  255. package/dist/src/ollama.variable.js +2 -2
  256. package/dist/src/ollama.variable.js.map +1 -1
  257. package/package.json +7 -6
  258. package/dist/.pikku/agent/pikku-agent-wirings-meta.gen.d.ts +0 -2
  259. package/dist/.pikku/agent/pikku-agent-wirings-meta.gen.d.ts.map +0 -1
  260. package/dist/.pikku/agent/pikku-agent-wirings-meta.gen.js +0 -7
  261. package/dist/.pikku/agent/pikku-agent-wirings-meta.gen.js.map +0 -1
  262. package/dist/.pikku/agent/pikku-agent-wirings-meta.gen.json +0 -3
  263. package/dist/.pikku/agent/pikku-agent-wirings-meta.gen.ts +0 -7
  264. package/dist/.pikku/agent/pikku-agent-wirings.gen.d.ts +0 -5
  265. package/dist/.pikku/agent/pikku-agent-wirings.gen.d.ts.map +0 -1
  266. package/dist/.pikku/agent/pikku-agent-wirings.gen.js +0 -5
  267. package/dist/.pikku/agent/pikku-agent-wirings.gen.js.map +0 -1
  268. package/dist/.pikku/agent/pikku-agent-wirings.gen.ts +0 -3
@@ -1,15 +1,21 @@
1
1
  /**
2
- * This file was generated by @pikku/cli@0.12.6
2
+ * This file was generated by @pikku/cli@0.12.96
3
3
  */
4
4
  /**
5
5
  * Core function, middleware, and permission types for all wirings
6
6
  */
7
7
 
8
- import { CorePikkuFunctionConfig, CorePikkuAuth, CorePikkuAuthConfig, CorePikkuPermission, CorePikkuMiddleware, CorePermissionGroup, addMiddleware as addMiddlewareCore, addPermission as addPermissionCore, PikkuWire, PickRequired } from '@pikku/core'
8
+ import type { CorePikkuMiddleware, CorePermissionGroup, ListInput, ListOutput, PikkuWire, PickRequired, SecretlessServices, SecretService } from '@pikku/core'
9
+ import type { CorePikkuFunctionConfig, CorePikkuAuth, CorePikkuAuthConfig, CorePikkuPermission } from '@pikku/core/function'
10
+ import { pikkuAuth as pikkuAuthCore } from '@pikku/core/function'
11
+ import {
12
+ addTagMiddleware as addTagMiddlewareCore,
13
+ addGlobalMiddleware as addGlobalMiddlewareCore,
14
+ addGlobalPermission as addGlobalPermissionCore,
15
+ } from '@pikku/core/middleware'
9
16
  import { pikkuState as __pikkuState, CreateWireServices } from '@pikku/core/internal'
10
- import { pikkuAuth as pikkuAuthCore } from '@pikku/core'
11
- import { PikkuError } from '@pikku/core/errors'
12
17
  import type { NodeType } from '@pikku/core/node'
18
+ import type { ScopeId } from '../scopes/pikku-scopes.gen.js'
13
19
  import type { StandardSchemaV1 } from '@standard-schema/spec'
14
20
  import { CorePikkuFunction, CorePikkuFunctionSessionless } from '@pikku/core/function'
15
21
 
@@ -19,13 +25,37 @@ import type { Services } from '../../types/application-types.d.js'
19
25
  import type { Config } from '../../types/application-types.d.js'
20
26
  import type { TypedPikkuRPC, FlattenedRPCMap } from '../rpc/pikku-rpc-wirings-map.internal.gen.d.js'
21
27
  import type { RequiredSingletonServices, RequiredWireServices } from '../pikku-services.gen.js'
22
- import type { TypedWorkflow } from '../workflow/pikku-workflow-types.gen.js'
28
+ import type { TypedWorkflow, TypedScenario, TypedPersonas } from '../workflow/pikku-workflow-types.gen.js'
23
29
 
24
30
  export type { SingletonServices as SingletonServices }
25
31
  export type { Services as Services }
26
32
  export type Session = UserSession
27
33
 
28
34
 
35
+ /**
36
+ * The services a wired function actually receives. The inspector records which
37
+ * services each wired `func`, `permissions` and `middleware` destructures and
38
+ * emits them as `RequiredSingletonServices`; intersecting that here makes those
39
+ * services **non-optional** at every call site. A service is optional only when
40
+ * nothing destructures it — in which case it is never created either. This is
41
+ * why an `if (!service)` guard inside a function body is always dead code.
42
+ */
43
+ export type WiredSingletonServices = RequiredSingletonServices & SingletonServices
44
+ export type WiredServices = SecretlessServices<RequiredSingletonServices & Services>
45
+
46
+ /** `WiredSingletonServices` without `secrets`, for auth gates. */
47
+ export type WiredAuthServices = SecretlessServices<WiredSingletonServices>
48
+
49
+ /**
50
+ * `WiredServices` with `secrets` restored, for the console's secret-admin
51
+ * functions. Reached by declaring `secretBroker: true` on a `pikkuFunc` config.
52
+ *
53
+ * Declaring it does not grant the service. The runner hands out the real
54
+ * `SecretService` only to the functions the inspector marks as secret brokers;
55
+ * every other function still receives the throwing accessor.
56
+ */
57
+ export type WiredSecretBrokerServices = WiredServices & { secrets: SecretService }
58
+
29
59
  /**
30
60
  * Inline node configuration for function definitions.
31
61
  */
@@ -43,7 +73,7 @@ export type NodeConfig = {
43
73
  * @template In - The input type that the permission check will receive
44
74
  * @template RequiredServices - The services required for this permission check
45
75
  */
46
- export type PikkuPermission<In = unknown, RequiredServices extends Services = Services> = CorePikkuPermission<In, RequiredServices, PikkuWire<In, never, false, Session>>
76
+ export type PikkuPermission<In = unknown, RequiredServices extends SecretlessServices<Services> = WiredServices> = CorePikkuPermission<In, RequiredServices, PikkuWire<In, never, false, Session>>
47
77
 
48
78
  /**
49
79
  * Type-safe middleware definition that can access your application's services and session.
@@ -51,12 +81,12 @@ export type PikkuPermission<In = unknown, RequiredServices extends Services = Se
51
81
  *
52
82
  * @template RequiredServices - The services required for this middleware
53
83
  */
54
- export type PikkuMiddleware<RequiredServices extends SingletonServices = SingletonServices> = CorePikkuMiddleware<RequiredServices>
84
+ export type PikkuMiddleware<RequiredServices extends SingletonServices = WiredSingletonServices> = CorePikkuMiddleware<RequiredServices>
55
85
 
56
86
  /**
57
87
  * Configuration object for creating a permission with metadata
58
88
  */
59
- export type PikkuPermissionConfig<In = unknown, RequiredServices extends Services = Services> = {
89
+ export type PikkuPermissionConfig<In = unknown, RequiredServices extends SecretlessServices<Services> = WiredServices> = {
60
90
  /** The permission function */
61
91
  func: PikkuPermission<In, RequiredServices>
62
92
  /** Optional human-readable name for the permission */
@@ -101,12 +131,12 @@ export const pikkuPermission = <In>(
101
131
  *
102
132
  * @template RequiredServices - The services required for this auth check
103
133
  */
104
- export type PikkuAuth<RequiredServices extends SingletonServices = SingletonServices> = CorePikkuAuth<RequiredServices, Session>
134
+ export type PikkuAuth<RequiredServices extends SecretlessServices<SingletonServices> = WiredAuthServices> = CorePikkuAuth<RequiredServices, Session>
105
135
 
106
136
  /**
107
137
  * Configuration object for creating an auth permission with metadata
108
138
  */
109
- export type PikkuAuthConfig<RequiredServices extends SingletonServices = SingletonServices> = CorePikkuAuthConfig<RequiredServices, Session>
139
+ export type PikkuAuthConfig<RequiredServices extends SecretlessServices<SingletonServices> = WiredAuthServices> = CorePikkuAuthConfig<RequiredServices, Session>
110
140
 
111
141
  /**
112
142
  * Factory function for creating auth-only permissions with tree-shaking support.
@@ -128,7 +158,7 @@ export type PikkuAuthConfig<RequiredServices extends SingletonServices = Singlet
128
158
  * })
129
159
  * \`\`\`
130
160
  */
131
- export const pikkuAuth = <RequiredServices extends SingletonServices = SingletonServices>(
161
+ export const pikkuAuth = <RequiredServices extends SecretlessServices<SingletonServices> = WiredAuthServices>(
132
162
  auth: PikkuAuth<RequiredServices> | PikkuAuthConfig<RequiredServices>
133
163
  ): PikkuPermission<any, any> => {
134
164
  return pikkuAuthCore(auth as any) as any
@@ -137,7 +167,7 @@ export const pikkuAuth = <RequiredServices extends SingletonServices = Singleton
137
167
  /**
138
168
  * Configuration object for creating middleware with metadata
139
169
  */
140
- export type PikkuMiddlewareConfig<RequiredServices extends SingletonServices = SingletonServices> = {
170
+ export type PikkuMiddlewareConfig<RequiredServices extends SingletonServices = WiredSingletonServices> = {
141
171
  /** The middleware function */
142
172
  func: PikkuMiddleware<RequiredServices>
143
173
  /** Optional human-readable name for the middleware */
@@ -169,7 +199,7 @@ export type PikkuMiddlewareConfig<RequiredServices extends SingletonServices = S
169
199
  * })
170
200
  * ```
171
201
  */
172
- export const pikkuMiddleware = <RequiredServices extends SingletonServices = SingletonServices>(
202
+ export const pikkuMiddleware = <RequiredServices extends SingletonServices = WiredSingletonServices>(
173
203
  middleware: PikkuMiddleware<RequiredServices> | PikkuMiddlewareConfig<RequiredServices>
174
204
  ): PikkuMiddleware<RequiredServices> => {
175
205
  return typeof middleware === 'function' ? middleware : middleware.func
@@ -230,7 +260,7 @@ export const pikkuPermissionFactory = <In = any>(
230
260
  * @template In - The input type (same as the function it describes)
231
261
  * @template RequiredServices - The services required for this description function
232
262
  */
233
- export type PikkuApprovalDescription<In = unknown, RequiredServices extends Services = Services> = (
263
+ export type PikkuApprovalDescription<In = unknown, RequiredServices extends SecretlessServices<Services> = WiredServices> = (
234
264
  services: RequiredServices,
235
265
  data: In
236
266
  ) => Promise<string>
@@ -248,7 +278,7 @@ export type PikkuApprovalDescription<In = unknown, RequiredServices extends Serv
248
278
  * )
249
279
  * ```
250
280
  */
251
- export const pikkuApprovalDescription = <In = unknown, RequiredServices extends Services = Services>(
281
+ export const pikkuApprovalDescription = <In = unknown, RequiredServices extends SecretlessServices<Services> = WiredServices>(
252
282
  fn: PikkuApprovalDescription<In, RequiredServices>
253
283
  ): PikkuApprovalDescription<In, RequiredServices> => {
254
284
  return fn
@@ -266,13 +296,13 @@ export type PikkuFunctionSessionless<
266
296
  In = unknown,
267
297
  Out = never,
268
298
  RequiredWires extends keyof PikkuWire = never,
269
- RequiredServices extends Services = Services
299
+ RequiredServices extends SecretlessServices<Services> = WiredServices
270
300
  > = CorePikkuFunctionSessionless<
271
301
  In,
272
302
  Out,
273
303
  RequiredServices,
274
304
  Session,
275
- PickRequired<PikkuWire<In, Out, false, Session, TypedPikkuRPC, null, any, TypedWorkflow>, RequiredWires>
305
+ PickRequired<PikkuWire<In, Out, false, Session, TypedPikkuRPC, null, any, TypedWorkflow, unknown, TypedScenario, TypedPersonas>, RequiredWires>
276
306
  >
277
307
 
278
308
  /**
@@ -287,13 +317,13 @@ export type PikkuFunction<
287
317
  In = unknown,
288
318
  Out = never,
289
319
  RequiredWires extends keyof PikkuWire = 'session',
290
- RequiredServices extends Services = Services
320
+ RequiredServices extends SecretlessServices<Services> = WiredServices
291
321
  > = CorePikkuFunction<
292
322
  In,
293
323
  Out,
294
324
  RequiredServices,
295
325
  Session,
296
- PickRequired<PikkuWire<In, Out, true, Session, TypedPikkuRPC, null, any, TypedWorkflow>, RequiredWires>
326
+ PickRequired<PikkuWire<In, Out, true, Session, TypedPikkuRPC, null, any, TypedWorkflow, unknown, TypedScenario, TypedPersonas>, RequiredWires>
297
327
  >
298
328
 
299
329
  /**
@@ -313,70 +343,66 @@ export type PikkuFunctionConfig<
313
343
  In = unknown,
314
344
  Out = unknown,
315
345
  RequiredWires extends keyof PikkuWire = never,
316
- PikkuFunc extends PikkuFunction<In, Out, RequiredWires> | PikkuFunctionSessionless<In, Out, RequiredWires> = PikkuFunction<In, Out, RequiredWires> | PikkuFunctionSessionless<In, Out, RequiredWires>,
346
+ PikkuFunc extends PikkuFunction<In, Out, RequiredWires, any> | PikkuFunctionSessionless<In, Out, RequiredWires, any> = PikkuFunction<In, Out, RequiredWires> | PikkuFunctionSessionless<In, Out, RequiredWires>,
317
347
  InputSchema extends StandardSchemaV1 | undefined = undefined,
318
348
  OutputSchema extends StandardSchemaV1 | undefined = undefined
319
- > = CorePikkuFunctionConfig<PikkuFunc, PikkuPermission<In>, PikkuMiddleware, InputSchema, OutputSchema>
349
+ > = CorePikkuFunctionConfig<PikkuFunc, PikkuPermission<In>, PikkuMiddleware, InputSchema, OutputSchema, ScopeId>
320
350
 
321
351
  /**
322
352
  * Configuration object for Pikku functions with Zod schema validation.
323
353
  * Use this when you want to define input/output schemas using Zod.
324
354
  * Types are automatically inferred from the schemas.
325
355
  */
356
+ type SchemaInferred<S, Fallback = unknown> = S extends StandardSchemaV1
357
+ ? InferSchemaOutput<S>
358
+ : Fallback
359
+
360
+ /**
361
+ * Schema-overload variant for pikkuFunc. Derived from CorePikkuFunctionConfig
362
+ * so adding a field on the core type automatically propagates here.
363
+ */
326
364
  export type PikkuFunctionConfigWithSchema<
327
365
  InputSchema extends StandardSchemaV1 | undefined = undefined,
328
366
  OutputSchema extends StandardSchemaV1 | undefined = undefined,
329
- RequiredWires extends keyof PikkuWire = never
330
- > = {
331
- name?: string
332
- tags?: string[]
333
- expose?: boolean
334
- mcp?: boolean
335
- internal?: boolean
336
- approvalRequired?: boolean
337
- approvalDescription?: InputSchema extends StandardSchemaV1 ? PikkuApprovalDescription<InferSchemaOutput<InputSchema>> : never
338
- func: PikkuFunction<
339
- InputSchema extends StandardSchemaV1 ? InferSchemaOutput<InputSchema> : unknown,
340
- OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown,
341
- RequiredWires
342
- > | PikkuFunctionSessionless<
343
- InputSchema extends StandardSchemaV1 ? InferSchemaOutput<InputSchema> : unknown,
344
- OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown,
345
- RequiredWires
346
- >
347
- auth?: boolean
348
- permissions?: InputSchema extends StandardSchemaV1 ? CorePermissionGroup<PikkuPermission<InferSchemaOutput<InputSchema>>> : undefined
349
- middleware?: PikkuMiddleware[]
367
+ RequiredWires extends keyof PikkuWire = never,
368
+ RequiredServices extends SecretlessServices<Services> = WiredServices
369
+ > = Omit<
370
+ CorePikkuFunctionConfig<
371
+ | PikkuFunction<SchemaInferred<InputSchema>, SchemaInferred<OutputSchema>, RequiredWires, RequiredServices>
372
+ | PikkuFunctionSessionless<SchemaInferred<InputSchema>, SchemaInferred<OutputSchema>, RequiredWires, RequiredServices>,
373
+ CorePikkuPermission<any>,
374
+ PikkuMiddleware,
375
+ undefined,
376
+ undefined,
377
+ ScopeId
378
+ >,
379
+ 'func' | 'input' | 'output' | 'permissions' | 'approvalDescription'
380
+ > & {
381
+ func:
382
+ | PikkuFunction<SchemaInferred<InputSchema>, SchemaInferred<OutputSchema>, RequiredWires, RequiredServices>
383
+ | PikkuFunctionSessionless<SchemaInferred<InputSchema>, SchemaInferred<OutputSchema>, RequiredWires, RequiredServices>
350
384
  input?: InputSchema
351
385
  output?: OutputSchema
352
- node?: NodeConfig
353
- errors?: Array<typeof PikkuError>
386
+ permissions?: InputSchema extends StandardSchemaV1
387
+ ? CorePermissionGroup<PikkuPermission<InferSchemaOutput<InputSchema>>>
388
+ : undefined
389
+ approvalDescription?: InputSchema extends StandardSchemaV1
390
+ ? PikkuApprovalDescription<InferSchemaOutput<InputSchema>>
391
+ : never
354
392
  }
355
393
 
356
394
  /**
357
395
  * Creates a Pikku function that can be either session-aware or sessionless.
358
396
  * This is the main function wrapper for creating API endpoints.
359
397
  *
360
- * Supports two patterns:
361
- * 1. Generic types: `pikkuFunc<Input, Output>({ func: ... })`
362
- * 2. Zod schemas: `pikkuFunc({ input: z.object(...), output: z.object(...), func: ... })`
398
+ * Define the input and output with Zod schemas — the function's types are
399
+ * inferred from them, and the schemas double as runtime validation.
363
400
  *
364
- * @template In - Input type for the function (inferred from schema if provided)
365
- * @template Out - Output type for the function (inferred from schema if provided)
366
- * @param func - Function definition, either direct function or configuration object
401
+ * @param config - Function definition with `input`/`output` Zod schemas and `func`.
367
402
  * @returns The normalized configuration object
368
403
  *
369
404
  * @example
370
405
  * ```typescript
371
- * // Pattern 1: Using generic types
372
- * const createUser = pikkuFunc<{name: string, email: string}, {id: number}>({
373
- * func: async ({db}, input) => {
374
- * const user = await db.users.create(input)
375
- * return { id: user.id }
376
- * }
377
- * })
378
- *
379
- * // Pattern 2: Using Zod schemas (types inferred automatically)
380
406
  * const createUserInput = z.object({ name: z.string(), email: z.string() })
381
407
  * const createUserOutput = z.object({ id: z.number() })
382
408
  *
@@ -391,6 +417,12 @@ export type PikkuFunctionConfigWithSchema<
391
417
  * })
392
418
  * ```
393
419
  */
420
+ export function pikkuFunc<
421
+ InputSchema extends StandardSchemaV1 | undefined = undefined,
422
+ OutputSchema extends StandardSchemaV1 | undefined = undefined
423
+ >(
424
+ config: PikkuFunctionConfigWithSchema<InputSchema, OutputSchema, 'session' | 'rpc', WiredSecretBrokerServices> & { secretBroker: true }
425
+ ): PikkuFunctionConfig<InputSchema extends StandardSchemaV1 ? InferSchemaOutput<InputSchema> : unknown, OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown, 'session' | 'rpc'>
394
426
  export function pikkuFunc<
395
427
  InputSchema extends StandardSchemaV1 | undefined = undefined,
396
428
  OutputSchema extends StandardSchemaV1 | undefined = undefined
@@ -406,60 +438,78 @@ export function pikkuFunc(func: any) {
406
438
  return typeof func === 'function' ? { func } : func
407
439
  }
408
440
 
441
+ export type PikkuListFunction<
442
+ F extends Record<string, unknown> = {},
443
+ Row = unknown,
444
+ S extends string = never
445
+ > =
446
+ | PikkuFunction<ListInput<F, S>, ListOutput<Row>, 'session' | 'rpc'>
447
+ | PikkuFunctionSessionless<
448
+ ListInput<F, S>,
449
+ ListOutput<Row>,
450
+ 'session' | 'rpc'
451
+ >
452
+
453
+ export const pikkuListFunc = <
454
+ F extends Record<string, unknown> = {},
455
+ Row = unknown,
456
+ S extends string = never
457
+ >(
458
+ config: PikkuFunctionConfig<
459
+ ListInput<F, S>,
460
+ ListOutput<Row>,
461
+ 'session' | 'rpc'
462
+ >
463
+ ): PikkuFunctionConfig<ListInput<F, S>, ListOutput<Row>, 'session' | 'rpc'> => {
464
+ return pikkuFunc(config)
465
+ }
466
+
409
467
  /**
410
468
  * Configuration object for sessionless Pikku functions with Zod schema validation.
411
469
  */
470
+ /**
471
+ * Schema-overload variant for pikkuSessionlessFunc. Derived from
472
+ * CorePikkuFunctionConfig to stay in sync with the generic-typed config.
473
+ */
412
474
  export type PikkuFunctionSessionlessConfigWithSchema<
413
475
  InputSchema extends StandardSchemaV1 | undefined = undefined,
414
476
  OutputSchema extends StandardSchemaV1 | undefined = undefined,
415
- RequiredWires extends keyof PikkuWire = never
416
- > = {
417
- name?: string
418
- description?: string
419
- tags?: string[]
420
- expose?: boolean
421
- mcp?: boolean
422
- internal?: boolean
423
- remote?: boolean
424
- approvalRequired?: boolean
425
- approvalDescription?: InputSchema extends StandardSchemaV1 ? PikkuApprovalDescription<InferSchemaOutput<InputSchema>> : never
477
+ RequiredWires extends keyof PikkuWire = never,
478
+ RequiredServices extends SecretlessServices<Services> = WiredServices
479
+ > = Omit<
480
+ CorePikkuFunctionConfig<
481
+ PikkuFunctionSessionless<SchemaInferred<InputSchema>, SchemaInferred<OutputSchema>, RequiredWires, RequiredServices>
482
+ >,
483
+ 'func' | 'input' | 'output' | 'permissions' | 'approvalDescription'
484
+ > & {
426
485
  func: PikkuFunctionSessionless<
427
- InputSchema extends StandardSchemaV1 ? InferSchemaOutput<InputSchema> : unknown,
428
- OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown,
429
- RequiredWires
486
+ SchemaInferred<InputSchema>,
487
+ SchemaInferred<OutputSchema>,
488
+ RequiredWires,
489
+ RequiredServices
430
490
  >
431
- auth?: boolean
432
- permissions?: InputSchema extends StandardSchemaV1 ? CorePermissionGroup<PikkuPermission<InferSchemaOutput<InputSchema>>> : undefined
433
- middleware?: PikkuMiddleware[]
434
491
  input?: InputSchema
435
492
  output?: OutputSchema
436
- node?: NodeConfig
437
- errors?: Array<typeof PikkuError>
493
+ permissions?: InputSchema extends StandardSchemaV1
494
+ ? CorePermissionGroup<PikkuPermission<InferSchemaOutput<InputSchema>>>
495
+ : undefined
496
+ approvalDescription?: InputSchema extends StandardSchemaV1
497
+ ? PikkuApprovalDescription<InferSchemaOutput<InputSchema>>
498
+ : never
438
499
  }
439
500
 
440
501
  /**
441
502
  * Creates a sessionless Pikku function that doesn't require user authentication.
442
503
  * Use this for public endpoints, webhooks, or background tasks.
443
504
  *
444
- * Supports two patterns:
445
- * 1. Generic types: `pikkuSessionlessFunc<Input, Output>({ func: ... })`
446
- * 2. Zod schemas: `pikkuSessionlessFunc({ input: z.object(...), func: ... })`
505
+ * Define the input and output with Zod schemas — the function's types are
506
+ * inferred from them, and the schemas double as runtime validation.
447
507
  *
448
- * @template In - Input type for the function (inferred from schema if provided)
449
- * @template Out - Output type for the function (inferred from schema if provided)
450
- * @param func - Function definition, either direct function or configuration object
508
+ * @param config - Function definition with `input`/`output` Zod schemas and `func`.
451
509
  * @returns The normalized configuration object
452
510
  *
453
511
  * @example
454
512
  * ```typescript
455
- * // Pattern 1: Using generic types
456
- * const healthCheck = pikkuSessionlessFunc<void, {status: string}>({
457
- * func: async ({logger}) => {
458
- * return { status: 'healthy' }
459
- * }
460
- * })
461
- *
462
- * // Pattern 2: Using Zod schemas
463
513
  * const greetInput = z.object({ name: z.string() })
464
514
  * const greetOutput = z.object({ message: z.string() })
465
515
  *
@@ -474,14 +524,15 @@ export type PikkuFunctionSessionlessConfigWithSchema<
474
524
  */
475
525
  export function pikkuSessionlessFunc<
476
526
  InputSchema extends StandardSchemaV1 | undefined = undefined,
477
- OutputSchema extends StandardSchemaV1 | undefined = undefined
527
+ OutputSchema extends StandardSchemaV1 | undefined = undefined,
528
+ RequiredServices extends SecretlessServices<Services> = WiredServices
478
529
  >(
479
- config: PikkuFunctionSessionlessConfigWithSchema<InputSchema, OutputSchema, 'session' | 'rpc'>
530
+ config: PikkuFunctionSessionlessConfigWithSchema<InputSchema, OutputSchema, 'session' | 'rpc', RequiredServices>
480
531
  ): PikkuFunctionConfig<InputSchema extends StandardSchemaV1 ? InferSchemaOutput<InputSchema> : unknown, OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown, 'session' | 'rpc'>
481
- export function pikkuSessionlessFunc<In, Out = unknown>(
532
+ export function pikkuSessionlessFunc<In, Out = unknown, RequiredServices extends SecretlessServices<Services> = WiredServices>(
482
533
  func:
483
- | PikkuFunctionSessionless<In, Out, 'session' | 'rpc'>
484
- | PikkuFunctionConfig<In, Out, 'session' | 'rpc'>
534
+ | PikkuFunctionSessionless<In, Out, 'session' | 'rpc', RequiredServices>
535
+ | PikkuFunctionConfig<In, Out, 'session' | 'rpc', PikkuFunctionSessionless<In, Out, 'session' | 'rpc', RequiredServices>>
485
536
  ): PikkuFunctionConfig<In, Out, 'session' | 'rpc'>
486
537
  export function pikkuSessionlessFunc(func: any) {
487
538
  return typeof func === 'function' ? { func } : func
@@ -512,27 +563,23 @@ export const pikkuVoidFunc = (
512
563
  }
513
564
 
514
565
  /**
515
- * Creates a wrapper function for addon package functions that are exposed via RPC.
516
- * This allows you to wire addon functions to any wiring type (HTTP, queue, etc.)
517
- * without type compatibility issues.
566
+ * References a registered function by name for use in any wiring.
567
+ * Works for both local and addon functions — resolves via RPC at runtime.
518
568
  *
519
- * @template Name - The RPC method name (must be a key in FlattenedRPCMap)
520
- * @param rpcName - The name of the RPC method to invoke
521
- * @returns A Pikku function that proxies calls to the addon RPC method
569
+ * @template Name - The function name (must be a key in FlattenedRPCMap)
570
+ * @param rpcName - The name of the function to reference
571
+ * @returns A Pikku function config that proxies calls via RPC
522
572
  *
523
573
  * @example
524
574
  * ```typescript
525
- * // Wire an addon function via HTTP
526
- * wireHTTP({
527
- * auth: false,
528
- * method: 'get',
529
- * route: '/addon/hello',
530
- * func: addon('ext:hello'),
531
- * tags: ['addon'],
532
- * })
575
+ * // Use in agent tools
576
+ * tools: [ref('todos:listTodos'), ref('myLocalFunc')]
577
+ *
578
+ * // Use in HTTP wiring
579
+ * wireHTTP({ route: '/greet', method: 'post', func: ref('greet') })
533
580
  * ```
534
581
  */
535
- export const addon = <Name extends keyof FlattenedRPCMap>(
582
+ export const ref = <Name extends keyof FlattenedRPCMap>(
536
583
  rpcName: Name
537
584
  ): PikkuFunctionConfig<
538
585
  FlattenedRPCMap[Name]['input'],
@@ -550,6 +597,43 @@ export const addon = <Name extends keyof FlattenedRPCMap>(
550
597
  >
551
598
  }
552
599
 
600
+ /**
601
+ * Declares a capability the connected client answers, reachable from any
602
+ * `wireChannel` function as `channel.remote(name, input)`.
603
+ *
604
+ * There is no `func`: this side owns the contract, the client owns the body.
605
+ * The `description` is what a person is shown when asked to approve the call,
606
+ * so write it for them rather than for the caller.
607
+ *
608
+ * @example
609
+ * ```typescript
610
+ * export const localCheckoutOutput = z.object({ sha: z.string(), branch: z.string() })
611
+ *
612
+ * export const localCheckout = pikkuRemoteChannelFunc({
613
+ * description: 'Read the current commit and branch of your working tree',
614
+ * output: localCheckoutOutput,
615
+ * })
616
+ * ```
617
+ */
618
+ export function pikkuRemoteChannelFunc<
619
+ InputSchema extends StandardSchemaV1 | undefined = undefined,
620
+ OutputSchema extends StandardSchemaV1 | undefined = undefined
621
+ >(
622
+ config: Omit<
623
+ PikkuFunctionSessionlessConfigWithSchema<InputSchema, OutputSchema, 'session' | 'rpc'>,
624
+ 'func'
625
+ >
626
+ ): PikkuFunctionConfig<SchemaInferred<InputSchema>, SchemaInferred<OutputSchema>, 'session' | 'rpc'> {
627
+ return {
628
+ ...config,
629
+ func: async (_services: any, _data: any, _wire: any) => {
630
+ throw new Error(
631
+ `${config.title ?? 'This'} is a remote channel capability and has no local implementation — reach it with channel.remote() on the channel whose client exposes it.`
632
+ )
633
+ },
634
+ } as any
635
+ }
636
+
553
637
  /**
554
638
  * Creates a Pikku config factory.
555
639
  * Use this to define your application's configuration factory.
@@ -591,12 +675,27 @@ export const pikkuConfig = (
591
675
  * ```
592
676
  */
593
677
  export const pikkuServices = (
594
- func: (config: Config, existingServices: Partial<SingletonServices>) => Promise<RequiredSingletonServices>
678
+ func: (config: Config, existingServices: Partial<SingletonServices>) => Promise<Partial<Omit<RequiredSingletonServices, 'auth'>>>
595
679
  ) => {
596
680
  return async (config: Config, existingServices: Partial<SingletonServices> = {}) => {
597
- const services = await func(config, existingServices)
598
- __pikkuState(null, 'package', 'singletonServices', services as any)
599
- return services
681
+ const createdServices = await func(config, existingServices)
682
+ const services = { ...existingServices, ...createdServices }
683
+ const authFactory = __pikkuState(null, 'package', 'authFactory')
684
+ if (authFactory) {
685
+ let authInstance: Promise<unknown> | undefined
686
+ ;(services as any).auth = () => {
687
+ authInstance ??= Promise.resolve()
688
+ .then(() => authFactory(services as any))
689
+ .catch((error) => {
690
+ authInstance = undefined
691
+ throw error
692
+ })
693
+ return authInstance
694
+ }
695
+ }
696
+ const resolved = services as RequiredSingletonServices
697
+ __pikkuState(null, 'package', 'singletonServices', resolved as any)
698
+ return resolved
600
699
  }
601
700
  }
602
701
 
@@ -629,58 +728,70 @@ export const pikkuWireServices = (
629
728
  }
630
729
 
631
730
  /**
632
- * Adds global middleware for a specific tag.
633
- *
634
- * This function allows you to register middleware that will be applied to
635
- * any wiring (HTTP, Channel, Queue, Scheduler, MCP) that includes the matching tag.
636
- *
637
- * @param tag - The tag that the middleware should apply to.
638
- * @param middleware - The middleware array to apply for the specified tag.
639
- *
640
- * @throws Error if middleware for the tag already exists.
731
+ * Tag-scoped middleware. Applies to any wiring that carries the matching tag.
641
732
  *
642
733
  * @example
643
- * ```typescript
644
- * // Add admin middleware for admin endpoints
645
- * addMiddleware('admin', [adminMiddleware])
646
- *
647
- * // Add authentication middleware for auth endpoints
648
- * addMiddleware('auth', [authMiddleware])
649
- *
650
- * // Add logging middleware for all API endpoints
651
- * addMiddleware('api', [loggingMiddleware])
652
- * ```
734
+ * addTagMiddleware('admin', [adminMiddleware])
653
735
  */
654
- export const addMiddleware = (tag: string, middleware: PikkuMiddleware[]) => {
655
- addMiddlewareCore(tag, middleware as any, '@pikku/addon-ollama')
736
+ export const addTagMiddleware = (tag: string, middleware: PikkuMiddleware[]) => {
737
+ addTagMiddlewareCore(tag, middleware as any, '@pikku/addon-ollama')
656
738
  }
657
739
 
658
740
  /**
659
- * Adds global permissions for a specific tag.
660
- *
661
- * This function allows you to register permissions that will be applied to
662
- * any wiring (HTTP, Channel, Queue, Scheduler, MCP) that includes the matching tag.
741
+ * Wire-agnostic global middleware. Runs at the top of every wiring's
742
+ * middleware chain — before wire-, tag-, and function-level entries.
663
743
  *
664
- * @param tag - The tag that the permissions should apply to.
665
- * @param permissions - The permissions array or object to apply for the specified tag.
666
- *
667
- * @throws Error if permissions for the tag already exist.
744
+ * Resolution order: global -> wire -> tag -> function.
668
745
  *
669
746
  * @example
670
- * ```typescript
671
- * // Add admin permissions for admin endpoints
672
- * addPermission('admin', [adminPermission])
747
+ * addGlobalMiddleware([telemetryMiddleware])
748
+ */
749
+ export const addGlobalMiddleware = (middleware: PikkuMiddleware[]) => {
750
+ addGlobalMiddlewareCore(middleware as any, '@pikku/addon-ollama')
751
+ }
752
+
753
+ /**
754
+ * Wire-agnostic global permissions. Runs at the top of every wiring's
755
+ * permission resolution — before wire-, tag-, and function-level entries.
673
756
  *
674
- * // Add authentication permissions for auth endpoints
675
- * addPermission('auth', [authPermission])
757
+ * Resolution order: global -> wire -> tag -> function.
676
758
  *
677
- * // Add read permissions for all API endpoints (as object)
678
- * addPermission('api', { read: readPermission })
679
- * ```
759
+ * @example
760
+ * addGlobalPermission([signedInUser])
761
+ */
762
+ export const addGlobalPermission = <In = unknown>(permissions: CorePermissionGroup<PikkuPermission<In>> | PikkuPermission<In>[]) => {
763
+ addGlobalPermissionCore(permissions as any, '@pikku/addon-ollama')
764
+ }
765
+
766
+ export { wireAddon, wireRemoteAddon } from '@pikku/core/rpc'
767
+ export type { WireAddonConfig, WireRemoteAddonConfig, RemoteAddonAuth } from '@pikku/core/rpc'
768
+
769
+
770
+ /**
771
+ * Addon contract references. Generated from each wired addon's published
772
+ * contract metadata — no addon source is imported. Functions are proxied via
773
+ * ref() (RPC) exactly like ref('namespace:fn').
680
774
  */
681
- export const addPermission = <In = unknown>(tag: string, permissions: CorePermissionGroup<PikkuPermission<In>> | PikkuPermission<In>[]) => {
682
- addPermissionCore(tag, permissions as any, '@pikku/addon-ollama')
775
+ const __addonHttp = {} as const
776
+ const __addonChannel = {} as const
777
+ const __addonCli = {} as const
778
+
779
+ export const refHTTP = <Name extends keyof typeof __addonHttp>(
780
+ name: Name,
781
+ options?: { basePath?: string }
782
+ ): (typeof __addonHttp)[Name] => {
783
+ const contract = __addonHttp[name] as any
784
+ return (
785
+ options?.basePath !== undefined
786
+ ? { ...contract, basePath: options.basePath }
787
+ : contract
788
+ ) as (typeof __addonHttp)[Name]
683
789
  }
684
790
 
685
- export { wireAddon } from '@pikku/core'
686
- export type { WireAddonConfig } from '@pikku/core'
791
+ export const refChannel = <Name extends keyof typeof __addonChannel>(
792
+ name: Name
793
+ ): (typeof __addonChannel)[Name] => __addonChannel[name]
794
+
795
+ export const refCLI = <Name extends keyof typeof __addonCli>(
796
+ name: Name
797
+ ): (typeof __addonCli)[Name] => __addonCli[name]