@pikku/core 0.12.82 → 0.12.84

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 (364) hide show
  1. package/CHANGELOG.md +101 -0
  2. package/README.md +1 -1
  3. package/dist/ecosystem/agent-scorer.d.ts +12 -0
  4. package/dist/ecosystem/agent-scorer.js +5 -0
  5. package/dist/ecosystem/agent.d.ts +18 -0
  6. package/dist/ecosystem/agent.js +6 -0
  7. package/dist/ecosystem/ai-agent.d.ts +18 -0
  8. package/dist/ecosystem/ai-agent.js +6 -0
  9. package/dist/ecosystem/ai-scorer.d.ts +12 -0
  10. package/dist/ecosystem/ai-scorer.js +5 -0
  11. package/dist/ecosystem/channel/local.d.ts +1 -0
  12. package/dist/ecosystem/channel/local.js +1 -0
  13. package/dist/ecosystem/channel.d.ts +12 -0
  14. package/dist/ecosystem/channel.js +4 -0
  15. package/dist/ecosystem/cli/channel.d.ts +16 -0
  16. package/dist/ecosystem/cli/channel.js +2 -0
  17. package/dist/ecosystem/cli.d.ts +9 -0
  18. package/dist/ecosystem/cli.js +2 -0
  19. package/dist/ecosystem/credential.d.ts +9 -0
  20. package/dist/ecosystem/credential.js +1 -0
  21. package/dist/ecosystem/dev.d.ts +8 -0
  22. package/dist/ecosystem/dev.js +1 -0
  23. package/dist/ecosystem/function.d.ts +13 -0
  24. package/dist/ecosystem/function.js +2 -0
  25. package/dist/ecosystem/gateway.d.ts +1 -0
  26. package/dist/ecosystem/gateway.js +1 -0
  27. package/dist/ecosystem/hmac.d.ts +1 -0
  28. package/dist/ecosystem/hmac.js +1 -0
  29. package/dist/ecosystem/http.d.ts +11 -0
  30. package/dist/ecosystem/http.js +3 -0
  31. package/dist/ecosystem/mcp.d.ts +3 -0
  32. package/dist/ecosystem/mcp.js +2 -0
  33. package/dist/ecosystem/middleware.d.ts +17 -0
  34. package/dist/ecosystem/middleware.js +6 -0
  35. package/dist/ecosystem/node-host-resolver.d.ts +1 -0
  36. package/dist/ecosystem/node-host-resolver.js +1 -0
  37. package/dist/ecosystem/node.d.ts +1 -0
  38. package/dist/ecosystem/node.js +1 -0
  39. package/dist/ecosystem/oauth2.d.ts +1 -0
  40. package/dist/ecosystem/oauth2.js +1 -0
  41. package/dist/ecosystem/persona.d.ts +15 -0
  42. package/dist/ecosystem/persona.js +4 -0
  43. package/dist/ecosystem/queue.d.ts +11 -0
  44. package/dist/ecosystem/queue.js +2 -0
  45. package/dist/ecosystem/remote.d.ts +8 -0
  46. package/dist/ecosystem/remote.js +1 -0
  47. package/dist/ecosystem/role.d.ts +3 -0
  48. package/dist/ecosystem/role.js +2 -0
  49. package/dist/ecosystem/rpc.d.ts +4 -0
  50. package/dist/ecosystem/rpc.js +2 -0
  51. package/dist/ecosystem/safe-fetch.d.ts +7 -0
  52. package/dist/ecosystem/safe-fetch.js +1 -0
  53. package/dist/ecosystem/scenario.d.ts +15 -0
  54. package/dist/ecosystem/scenario.js +4 -0
  55. package/dist/ecosystem/scheduler.d.ts +2 -0
  56. package/dist/ecosystem/scheduler.js +1 -0
  57. package/dist/ecosystem/schema.d.ts +1 -0
  58. package/dist/ecosystem/schema.js +1 -0
  59. package/dist/ecosystem/scope.d.ts +3 -0
  60. package/dist/ecosystem/scope.js +2 -0
  61. package/dist/ecosystem/secret.d.ts +9 -0
  62. package/dist/ecosystem/secret.js +1 -0
  63. package/dist/ecosystem/services/istanbul-coverage.d.ts +1 -0
  64. package/dist/ecosystem/services/istanbul-coverage.js +1 -0
  65. package/dist/ecosystem/services/local-content-request-handler.d.ts +9 -0
  66. package/dist/ecosystem/services/local-content-request-handler.js +1 -0
  67. package/dist/ecosystem/services/local-content.d.ts +1 -0
  68. package/dist/ecosystem/services/local-content.js +1 -0
  69. package/dist/ecosystem/services/v8-coverage.d.ts +1 -0
  70. package/dist/ecosystem/services/v8-coverage.js +1 -0
  71. package/dist/ecosystem/services.d.ts +28 -0
  72. package/dist/ecosystem/services.js +6 -0
  73. package/dist/ecosystem/testing.d.ts +7 -0
  74. package/dist/ecosystem/testing.js +1 -0
  75. package/dist/ecosystem/trigger.d.ts +1 -0
  76. package/dist/ecosystem/trigger.js +1 -0
  77. package/dist/ecosystem/types.d.ts +9 -0
  78. package/dist/ecosystem/types.js +5 -0
  79. package/dist/ecosystem/variable.d.ts +8 -0
  80. package/dist/ecosystem/variable.js +1 -0
  81. package/dist/ecosystem/virtual-user.d.ts +21 -0
  82. package/dist/ecosystem/virtual-user.js +5 -0
  83. package/dist/ecosystem/workflow.d.ts +18 -0
  84. package/dist/ecosystem/workflow.js +4 -0
  85. package/dist/index.d.ts +8 -8
  86. package/dist/index.js +3 -3
  87. package/dist/middleware/auth-apikey.d.ts +1 -1
  88. package/dist/middleware/auth-bearer.d.ts +1 -1
  89. package/dist/middleware/auth-cookie.d.ts +1 -1
  90. package/dist/middleware/cors.d.ts +1 -1
  91. package/dist/middleware/remote-auth.d.ts +1 -1
  92. package/dist/middleware/telemetry.d.ts +2 -2
  93. package/dist/services/agent-run-state-service.d.ts +29 -0
  94. package/dist/services/agent-run-state-service.js +1 -0
  95. package/dist/services/agent-runner-service.d.ts +220 -0
  96. package/dist/services/agent-runner-service.js +1 -0
  97. package/dist/services/agent-storage-service.d.ts +18 -0
  98. package/dist/services/agent-storage-service.js +1 -0
  99. package/dist/services/http-personas.d.ts +1 -1
  100. package/dist/services/http-personas.js +3 -3
  101. package/dist/services/in-memory-agent-run-state-service.d.ts +19 -0
  102. package/dist/services/in-memory-agent-run-state-service.js +54 -0
  103. package/dist/services/index.d.ts +9 -10
  104. package/dist/services/index.js +3 -3
  105. package/dist/services/meta-service.d.ts +5 -4
  106. package/dist/testing/service-tests/agent-run-service-tests.d.ts +1 -1
  107. package/dist/testing/service-tests/agent-run-service-tests.js +3 -3
  108. package/dist/testing/service-tests/agent-storage-service-tests.d.ts +3 -0
  109. package/dist/testing/service-tests/agent-storage-service-tests.js +302 -0
  110. package/dist/testing/service-tests.d.ts +4 -4
  111. package/dist/testing/service-tests.js +4 -4
  112. package/dist/types/core.types.d.ts +12 -11
  113. package/dist/types/core.types.js +1 -1
  114. package/dist/types/state.types.d.ts +11 -6
  115. package/dist/wirings/actor-flow/run-conversation.d.ts +2 -2
  116. package/dist/wirings/agent/agent-agui.d.ts +79 -0
  117. package/dist/wirings/agent/agent-agui.js +327 -0
  118. package/dist/wirings/agent/agent-finalize.d.ts +58 -0
  119. package/dist/wirings/agent/agent-finalize.js +138 -0
  120. package/dist/wirings/agent/agent-helpers.d.ts +35 -0
  121. package/dist/wirings/agent/agent-helpers.js +47 -0
  122. package/dist/wirings/agent/agent-interrupt.d.ts +153 -0
  123. package/dist/wirings/agent/agent-interrupt.js +257 -0
  124. package/dist/wirings/agent/agent-memory.d.ts +42 -0
  125. package/dist/wirings/agent/agent-memory.js +333 -0
  126. package/dist/wirings/agent/agent-model-config.d.ts +16 -0
  127. package/dist/wirings/agent/agent-model-config.js +51 -0
  128. package/dist/wirings/agent/agent-prepare.d.ts +117 -0
  129. package/dist/wirings/agent/agent-prepare.js +728 -0
  130. package/dist/wirings/agent/agent-registry.d.ts +16 -0
  131. package/dist/wirings/agent/agent-registry.js +51 -0
  132. package/dist/wirings/agent/agent-rpc.d.ts +15 -0
  133. package/dist/wirings/agent/agent-rpc.js +53 -0
  134. package/dist/wirings/agent/agent-runner.d.ts +7 -0
  135. package/dist/wirings/agent/agent-runner.js +580 -0
  136. package/dist/wirings/agent/agent-stream.d.ts +41 -0
  137. package/dist/wirings/agent/agent-stream.js +1029 -0
  138. package/dist/wirings/agent/agent-turn.d.ts +57 -0
  139. package/dist/wirings/agent/agent-turn.js +82 -0
  140. package/dist/wirings/agent/agent-utils.d.ts +1 -0
  141. package/dist/wirings/agent/agent-utils.js +1 -0
  142. package/dist/wirings/agent/agent.types.d.ts +625 -0
  143. package/dist/wirings/agent/agent.types.js +1 -0
  144. package/dist/wirings/agent/index.d.ts +12 -0
  145. package/dist/wirings/agent/index.js +10 -0
  146. package/dist/wirings/agent/voice-input.d.ts +69 -0
  147. package/dist/wirings/agent/voice-input.js +150 -0
  148. package/dist/wirings/agent/voice-output.d.ts +85 -0
  149. package/dist/wirings/agent/voice-output.js +196 -0
  150. package/dist/wirings/agent-scorer/agent-scorer-grade.d.ts +26 -0
  151. package/dist/wirings/agent-scorer/agent-scorer-grade.js +33 -0
  152. package/dist/wirings/agent-scorer/agent-scorer-judge.d.ts +17 -0
  153. package/dist/wirings/agent-scorer/agent-scorer-judge.js +92 -0
  154. package/dist/wirings/agent-scorer/agent-scorer-live.d.ts +15 -0
  155. package/dist/wirings/agent-scorer/agent-scorer-live.js +38 -0
  156. package/dist/wirings/agent-scorer/agent-scorer-registry.d.ts +18 -0
  157. package/dist/wirings/agent-scorer/agent-scorer-registry.js +46 -0
  158. package/dist/wirings/agent-scorer/agent-scorer-sampling.d.ts +8 -0
  159. package/dist/wirings/agent-scorer/agent-scorer-sampling.js +31 -0
  160. package/dist/wirings/agent-scorer/agent-scorer-snapshots.d.ts +10 -0
  161. package/dist/wirings/agent-scorer/agent-scorer-snapshots.js +40 -0
  162. package/dist/wirings/agent-scorer/agent-scorer-worker.d.ts +15 -0
  163. package/dist/wirings/agent-scorer/agent-scorer-worker.js +60 -0
  164. package/dist/wirings/agent-scorer/agent-scorer.d.ts +39 -0
  165. package/dist/wirings/agent-scorer/agent-scorer.js +40 -0
  166. package/dist/wirings/agent-scorer/agent-scorer.types.d.ts +90 -0
  167. package/dist/wirings/agent-scorer/agent-scorer.types.js +4 -0
  168. package/dist/wirings/agent-scorer/index.d.ts +6 -0
  169. package/dist/wirings/agent-scorer/index.js +5 -0
  170. package/dist/wirings/ai-agent/ai-agent-prepare.js +2 -0
  171. package/dist/wirings/ai-agent/voice-output.d.ts +1 -2
  172. package/dist/wirings/channel/channel-rpc.types.d.ts +2 -2
  173. package/dist/wirings/rpc/addon-runner.d.ts +4 -0
  174. package/dist/wirings/rpc/addon-runner.js +14 -2
  175. package/dist/wirings/rpc/rpc-runner.d.ts +1 -1
  176. package/dist/wirings/rpc/rpc-runner.js +4 -2
  177. package/dist/wirings/rpc/rpc-types.d.ts +5 -1
  178. package/dist/wirings/rpc/wire-addon.d.ts +12 -0
  179. package/dist/wirings/rpc/wire-addon.js +4 -0
  180. package/dist/wirings/virtual-user/prepare-virtual-user-run.js +1 -1
  181. package/dist/wirings/virtual-user/virtual-user-agents.d.ts +1 -1
  182. package/dist/wirings/workflow/feature.d.ts +2 -1
  183. package/dist/wirings/workflow/index.d.ts +3 -14
  184. package/dist/wirings/workflow/index.js +0 -8
  185. package/dist/wirings/workflow/pikku-scenario-service.d.ts +10 -0
  186. package/dist/wirings/workflow/pikku-scenario-service.js +9 -0
  187. package/dist/wirings/workflow/run-timeline.d.ts +1 -2
  188. package/dist/wirings/workflow/scenario.types.d.ts +37 -0
  189. package/dist/wirings/workflow/scenario.types.js +1 -0
  190. package/dist/wirings/workflow/workflow.types.d.ts +2 -37
  191. package/knowledge/decisions/internals/{a-non-streaming-agent-run-registers-with-airunstate-too.md → a-non-streaming-agent-run-registers-with-agentrunstate-too.md} +6 -6
  192. package/knowledge/decisions/internals/a-resumed-agent-turn-is-as-interruptible-as-the-first.md +1 -1
  193. package/knowledge/decisions/internals/actor-flow-drives-the-target-through-a-transport-seam.md +1 -1
  194. package/knowledge/decisions/internals/{ai-agent-agui-bridge-obeys-the-client-ordering-contract.md → agent-agui-bridge-obeys-the-client-ordering-contract.md} +5 -5
  195. package/knowledge/decisions/internals/{ai-agent-audio-chunks-carry-the-format-the-provider-returned.md → agent-audio-chunks-carry-the-format-the-provider-returned.md} +2 -2
  196. package/knowledge/decisions/internals/agent-context-waits-for-a-tool-result-still-being-written.md +1 -1
  197. package/knowledge/decisions/internals/{ai-agent-credential-suspensions-hide-the-tool-result.md → agent-credential-suspensions-hide-the-tool-result.md} +2 -2
  198. package/knowledge/decisions/internals/{ai-agent-delegate-and-supervise-hide-different-text.md → agent-delegate-and-supervise-hide-different-text.md} +4 -4
  199. package/knowledge/decisions/internals/{ai-agent-llm-tool-arguments-have-nulls-stripped.md → agent-llm-tool-arguments-have-nulls-stripped.md} +3 -3
  200. package/knowledge/decisions/internals/{ai-agent-model-config-stays-a-single-resolution-seam.md → agent-model-config-stays-a-single-resolution-seam.md} +3 -3
  201. package/knowledge/decisions/internals/{ai-agent-onerror-hooks-cannot-change-the-failure.md → agent-onerror-hooks-cannot-change-the-failure.md} +6 -6
  202. package/knowledge/decisions/internals/{ai-agent-runner-methods-must-keep-their-receiver.md → agent-runner-methods-must-keep-their-receiver.md} +4 -4
  203. package/knowledge/decisions/internals/agent-speech-travels-as-a-custom-agui-event.md +1 -1
  204. package/knowledge/decisions/internals/{ai-agent-stream-persistence-is-best-effort.md → agent-stream-persistence-is-best-effort.md} +4 -4
  205. package/knowledge/decisions/internals/{ai-agent-sub-agents-inherit-the-parent-context-block.md → agent-sub-agents-inherit-the-parent-context-block.md} +3 -3
  206. package/knowledge/decisions/internals/{ai-agent-tool-execute-failures-are-logged-unconditionally.md → agent-tool-execute-failures-are-logged-unconditionally.md} +3 -3
  207. package/knowledge/decisions/internals/{ai-agent-voice-input-transcribes-audio-parts-in-place.md → agent-voice-input-transcribes-audio-parts-in-place.md} +2 -2
  208. package/knowledge/decisions/internals/{ai-agent-working-memory-is-persisted-only-when-valid.md → agent-working-memory-is-persisted-only-when-valid.md} +2 -2
  209. package/knowledge/decisions/internals/an-agent-interrupt-is-not-a-failure.md +2 -2
  210. package/knowledge/decisions/internals/an-agent-run-owned-by-another-instance-says-so.md +3 -3
  211. package/knowledge/decisions/internals/an-agent-stream-send-must-return-the-inner-sends-promise.md +2 -2
  212. package/knowledge/decisions/internals/an-empty-text-part-is-omitted-from-an-agent-message.md +1 -1
  213. package/knowledge/decisions/internals/an-empty-transcript-is-not-recorded.md +1 -1
  214. package/knowledge/decisions/internals/speech-synthesis-picks-a-voice-per-sentence-and-warns-once.md +1 -1
  215. package/knowledge/decisions/internals/the-agent-done-event-goes-through-the-middleware-and-is-awaited.md +1 -1
  216. package/knowledge/decisions/internals/the-embedding-model-is-pinned-per-service-and-doc-query-embedding-is-split.md +1 -1
  217. package/knowledge/decisions/internals/the-per-invocation-rpc-view-is-a-class.md +5 -5
  218. package/knowledge/decisions/internals/the-transcript-event-is-sent-ahead-of-the-run.md +2 -2
  219. package/knowledge/decisions/internals/thread-history-records-the-transcript-not-the-audio.md +2 -2
  220. package/knowledge/decisions/internals/voice-output-speaks-unless-voice-input-explicitly-says-otherwise.md +1 -1
  221. package/knowledge/decisions/security/{ai-agent-approval-forwarding-requires-a-symbol-brand.md → agent-approval-forwarding-requires-a-symbol-brand.md} +3 -3
  222. package/knowledge/decisions/security/{ai-agent-credential-requests-are-symbol-branded.md → agent-credential-requests-are-symbol-branded.md} +4 -4
  223. package/knowledge/decisions/security/{ai-agent-gate-requires-a-session-only-when-auth-is-true.md → agent-gate-requires-a-session-only-when-auth-is-true.md} +3 -3
  224. package/knowledge/decisions/security/{ai-agent-ownership-failures-never-echo-the-resource.md → agent-ownership-failures-never-echo-the-resource.md} +2 -2
  225. package/knowledge/decisions/security/{ai-agent-resume-re-runs-the-authorization-gate.md → agent-resume-re-runs-the-authorization-gate.md} +4 -4
  226. package/knowledge/decisions/security/{ai-agent-sessionless-deployments-have-no-thread-ownership.md → agent-sessionless-deployments-have-no-thread-ownership.md} +5 -5
  227. package/knowledge/decisions/security/{ai-agent-thread-ownership-composes-the-session-principal.md → agent-thread-ownership-composes-the-session-principal.md} +2 -2
  228. package/knowledge/decisions/security/{ai-agent-tool-filtering-reads-the-live-function-config.md → agent-tool-filtering-reads-the-live-function-config.md} +2 -2
  229. package/knowledge/decisions/security/an-agent-approval-is-claimed-before-the-tool-runs.md +3 -3
  230. package/knowledge/decisions/security/an-empty-owners-constraint-matches-nothing.md +3 -3
  231. package/knowledge/decisions/security/console-addon-privileged-functions-gate-themselves.md +20 -13
  232. package/knowledge/decisions/security/index.md +1 -2
  233. package/package.json +4 -4
  234. package/scripts/generate-api-report.mts +32 -8
  235. package/src/agent-naming.test.ts +68 -0
  236. package/src/ecosystem/agent-scorer.ts +24 -0
  237. package/src/ecosystem/agent.ts +42 -0
  238. package/src/ecosystem/channel/local.ts +1 -0
  239. package/src/ecosystem/channel.ts +22 -0
  240. package/src/ecosystem/cli/channel.ts +25 -0
  241. package/src/ecosystem/cli.ts +21 -0
  242. package/src/ecosystem/credential.ts +10 -0
  243. package/src/ecosystem/dev.ts +12 -0
  244. package/src/ecosystem/function.ts +28 -0
  245. package/src/ecosystem/gateway.ts +4 -0
  246. package/src/ecosystem/hmac.ts +1 -0
  247. package/src/ecosystem/http.ts +22 -0
  248. package/src/ecosystem/mcp.ts +17 -0
  249. package/src/ecosystem/middleware.ts +27 -0
  250. package/src/ecosystem/node-host-resolver.ts +1 -0
  251. package/src/ecosystem/node.ts +5 -0
  252. package/src/ecosystem/oauth2.ts +4 -0
  253. package/src/ecosystem/persona.ts +30 -0
  254. package/src/ecosystem/queue.ts +23 -0
  255. package/src/ecosystem/remote.ts +9 -0
  256. package/src/ecosystem/role.ts +13 -0
  257. package/src/ecosystem/rpc.ts +7 -0
  258. package/src/ecosystem/safe-fetch.ts +8 -0
  259. package/src/ecosystem/scenario.ts +32 -0
  260. package/src/ecosystem/scheduler.ts +5 -0
  261. package/src/ecosystem/schema.ts +1 -0
  262. package/src/ecosystem/scope.ts +14 -0
  263. package/src/ecosystem/secret.ts +15 -0
  264. package/src/ecosystem/services/istanbul-coverage.ts +1 -0
  265. package/src/ecosystem/services/local-content-request-handler.ts +16 -0
  266. package/src/ecosystem/services/local-content.ts +1 -0
  267. package/src/ecosystem/services/v8-coverage.ts +1 -0
  268. package/src/ecosystem/services.ts +82 -0
  269. package/src/ecosystem/testing.ts +8 -0
  270. package/src/ecosystem/trigger.ts +7 -0
  271. package/src/ecosystem/types.ts +34 -0
  272. package/src/ecosystem/variable.ts +14 -0
  273. package/src/ecosystem/virtual-user.ts +48 -0
  274. package/src/ecosystem/workflow.ts +68 -0
  275. package/src/index.ts +8 -19
  276. package/src/pikku-state.ts +3 -3
  277. package/src/public-surface.json +183 -91
  278. package/src/public-surface.json.README +20 -2
  279. package/src/public-surface.test.ts +31 -3
  280. package/src/services/{ai-run-state-service.ts → agent-run-state-service.ts} +5 -5
  281. package/src/services/{ai-agent-runner-service.ts → agent-runner-service.ts} +18 -18
  282. package/src/services/{ai-storage-service.ts → agent-storage-service.ts} +7 -7
  283. package/src/services/http-personas-converse.test.ts +3 -3
  284. package/src/services/http-personas.ts +4 -4
  285. package/src/services/{in-memory-ai-run-state-service.ts → in-memory-agent-run-state-service.ts} +7 -7
  286. package/src/services/index.ts +13 -24
  287. package/src/services/meta-service.ts +5 -7
  288. package/src/testing/service-tests/agent-run-service-tests.ts +4 -4
  289. package/src/testing/service-tests/{ai-storage-service-tests.ts → agent-storage-service-tests.ts} +8 -8
  290. package/src/testing/service-tests.ts +10 -8
  291. package/src/types/core.types.ts +13 -13
  292. package/src/types/state.types.ts +11 -10
  293. package/src/wirings/actor-flow/run-conversation.test.ts +2 -2
  294. package/src/wirings/actor-flow/run-conversation.ts +7 -9
  295. package/src/wirings/{ai-agent/ai-agent-agui.test.ts → agent/agent-agui.test.ts} +126 -105
  296. package/src/wirings/{ai-agent/ai-agent-agui.ts → agent/agent-agui.ts} +7 -7
  297. package/src/wirings/{ai-agent/ai-agent-authorization.test.ts → agent/agent-authorization.test.ts} +6 -6
  298. package/src/wirings/{ai-agent/ai-agent-finalize.test.ts → agent/agent-finalize.test.ts} +17 -16
  299. package/src/wirings/{ai-agent/ai-agent-finalize.ts → agent/agent-finalize.ts} +22 -22
  300. package/src/wirings/{ai-agent/ai-agent-helpers.test.ts → agent/agent-helpers.test.ts} +1 -1
  301. package/src/wirings/{ai-agent/ai-agent-helpers.ts → agent/agent-helpers.ts} +1 -1
  302. package/src/wirings/{ai-agent/ai-agent-interrupt.test.ts → agent/agent-interrupt.test.ts} +67 -77
  303. package/src/wirings/{ai-agent/ai-agent-interrupt.ts → agent/agent-interrupt.ts} +5 -5
  304. package/src/wirings/{ai-agent/ai-agent-memory.test.ts → agent/agent-memory.test.ts} +12 -12
  305. package/src/wirings/{ai-agent/ai-agent-memory.ts → agent/agent-memory.ts} +36 -36
  306. package/src/wirings/{ai-agent/ai-agent-model-config.test.ts → agent/agent-model-config.test.ts} +2 -5
  307. package/src/wirings/{ai-agent/ai-agent-model-config.ts → agent/agent-model-config.ts} +1 -1
  308. package/src/wirings/{ai-agent/ai-agent-prepare.test.ts → agent/agent-prepare.test.ts} +18 -18
  309. package/src/wirings/{ai-agent/ai-agent-prepare.ts → agent/agent-prepare.ts} +54 -51
  310. package/src/wirings/{ai-agent/ai-agent-registry.test.ts → agent/agent-registry.test.ts} +49 -43
  311. package/src/wirings/{ai-agent/ai-agent-registry.ts → agent/agent-registry.ts} +14 -14
  312. package/src/wirings/{ai-agent/ai-agent-resume-authorization.test.ts → agent/agent-resume-authorization.test.ts} +18 -18
  313. package/src/wirings/{ai-agent → agent}/agent-rpc.ts +16 -20
  314. package/src/wirings/{ai-agent/ai-agent-runner.test.ts → agent/agent-runner.test.ts} +105 -106
  315. package/src/wirings/{ai-agent/ai-agent-runner.ts → agent/agent-runner.ts} +90 -80
  316. package/src/wirings/{ai-agent/ai-agent-stream-output-hooks.test.ts → agent/agent-stream-output-hooks.test.ts} +25 -25
  317. package/src/wirings/{ai-agent/ai-agent-stream.test.ts → agent/agent-stream.test.ts} +147 -143
  318. package/src/wirings/{ai-agent/ai-agent-stream.ts → agent/agent-stream.ts} +147 -146
  319. package/src/wirings/{ai-agent/ai-agent-thread-ownership.test.ts → agent/agent-thread-ownership.test.ts} +24 -28
  320. package/src/wirings/{ai-agent/ai-agent-turn.test.ts → agent/agent-turn.test.ts} +3 -5
  321. package/src/wirings/{ai-agent/ai-agent-turn.ts → agent/agent-turn.ts} +7 -7
  322. package/src/wirings/{ai-agent/ai-agent.types.ts → agent/agent.types.ts} +51 -48
  323. package/src/wirings/agent/index.ts +56 -0
  324. package/src/wirings/{ai-agent → agent}/voice-input.test.ts +15 -15
  325. package/src/wirings/{ai-agent → agent}/voice-input.ts +11 -11
  326. package/src/wirings/{ai-agent → agent}/voice-output.test.ts +23 -23
  327. package/src/wirings/{ai-agent → agent}/voice-output.ts +11 -11
  328. package/src/wirings/{ai-scorer/ai-scorer-grade.test.ts → agent-scorer/agent-scorer-grade.test.ts} +8 -8
  329. package/src/wirings/{ai-scorer/ai-scorer-grade.ts → agent-scorer/agent-scorer-grade.ts} +9 -9
  330. package/src/wirings/{ai-scorer/ai-scorer-judge.test.ts → agent-scorer/agent-scorer-judge.test.ts} +11 -14
  331. package/src/wirings/{ai-scorer/ai-scorer-judge.ts → agent-scorer/agent-scorer-judge.ts} +11 -11
  332. package/src/wirings/{ai-scorer/ai-scorer-live.test.ts → agent-scorer/agent-scorer-live.test.ts} +11 -11
  333. package/src/wirings/{ai-scorer/ai-scorer-live.ts → agent-scorer/agent-scorer-live.ts} +3 -3
  334. package/src/wirings/{ai-scorer/ai-scorer-registry.ts → agent-scorer/agent-scorer-registry.ts} +11 -8
  335. package/src/wirings/{ai-scorer/ai-scorer-sampling.test.ts → agent-scorer/agent-scorer-sampling.test.ts} +1 -1
  336. package/src/wirings/{ai-scorer/ai-scorer-snapshots.test.ts → agent-scorer/agent-scorer-snapshots.test.ts} +2 -2
  337. package/src/wirings/{ai-scorer/ai-scorer-snapshots.ts → agent-scorer/agent-scorer-snapshots.ts} +1 -1
  338. package/src/wirings/{ai-scorer/ai-scorer-worker.test.ts → agent-scorer/agent-scorer-worker.test.ts} +15 -15
  339. package/src/wirings/{ai-scorer/ai-scorer-worker.ts → agent-scorer/agent-scorer-worker.ts} +9 -7
  340. package/src/wirings/{ai-scorer/ai-scorer.ts → agent-scorer/agent-scorer.ts} +7 -7
  341. package/src/wirings/{ai-scorer/ai-scorer.types.ts → agent-scorer/agent-scorer.types.ts} +6 -6
  342. package/src/wirings/agent-scorer/index.ts +22 -0
  343. package/src/wirings/channel/channel-rpc.types.ts +2 -2
  344. package/src/wirings/rpc/addon-runner.ts +31 -3
  345. package/src/wirings/rpc/addon-secrets.test.ts +130 -0
  346. package/src/wirings/rpc/rpc-runner.ts +4 -2
  347. package/src/wirings/rpc/rpc-types.ts +5 -1
  348. package/src/wirings/rpc/wire-addon.ts +16 -0
  349. package/src/wirings/virtual-user/prepare-virtual-user-run.ts +1 -1
  350. package/src/wirings/virtual-user/run-virtual-user.test.ts +2 -2
  351. package/src/wirings/virtual-user/run-virtual-user.ts +3 -3
  352. package/src/wirings/virtual-user/virtual-user-agents.ts +1 -1
  353. package/src/wirings/workflow/feature.ts +2 -5
  354. package/src/wirings/workflow/index.ts +1 -49
  355. package/src/wirings/workflow/pikku-scenario-service.ts +21 -1
  356. package/src/wirings/workflow/run-timeline.ts +1 -1
  357. package/src/wirings/workflow/scenario.types.ts +63 -0
  358. package/src/wirings/workflow/workflow.types.ts +1 -54
  359. package/src/wirings-stay-decoupled.test.ts +3 -3
  360. package/tsconfig.tsbuildinfo +1 -1
  361. package/src/wirings/ai-agent/index.ts +0 -65
  362. package/src/wirings/ai-scorer/index.ts +0 -24
  363. /package/src/wirings/{ai-agent/ai-agent-utils.ts → agent/agent-utils.ts} +0 -0
  364. /package/src/wirings/{ai-scorer/ai-scorer-sampling.ts → agent-scorer/agent-scorer-sampling.ts} +0 -0
@@ -11,6 +11,18 @@ export type WireAddonConfig = {
11
11
  secretOverrides?: Record<string, string>;
12
12
  variableOverrides?: Record<string, string>;
13
13
  credentialOverrides?: Record<string, string>;
14
+ /**
15
+ * Secrets this instance may read on top of the ones it declared, named as the
16
+ * addon reads them — the scope check runs before `secretOverrides` renames
17
+ * them, so an overridden secret is named here by its addon-side key. Listing
18
+ * one in `secretOverrides` grants it too.
19
+ *
20
+ * For an addon whose secret names come off its input rather than its own
21
+ * source, this is how the host lends names the addon could not declare.
22
+ */
23
+ secretGrants?: string[];
24
+ /** Credentials this instance may read on top of the ones it declared. */
25
+ credentialGrants?: string[];
14
26
  /**
15
27
  * Hands this instance the whole `SecretService` instead of one scoped to the
16
28
  * secrets it declared. The value is the reason, recorded in the deploy
@@ -16,6 +16,10 @@ export const wireAddon = (config) => {
16
16
  ...(config.credentialOverrides
17
17
  ? { credentialOverrides: config.credentialOverrides }
18
18
  : {}),
19
+ ...(config.secretGrants ? { secretGrants: config.secretGrants } : {}),
20
+ ...(config.credentialGrants
21
+ ? { credentialGrants: config.credentialGrants }
22
+ : {}),
19
23
  ...(config.globalSecrets ? { globalSecrets: config.globalSecrets } : {}),
20
24
  ...(config.globalCredentials
21
25
  ? { globalCredentials: config.globalCredentials }
@@ -42,7 +42,7 @@ export const prepareVirtualUserRun = (input) => {
42
42
  }
43
43
  const scopes = personaScopes(input.persona, roleScopes);
44
44
  // Gated by the same scopes as the RPCs, because an agent is reached rather
45
- // than declared: `CoreAIAgent.scopes` is checked against the session, so a
45
+ // than declared: `CoreAgent.scopes` is checked against the session, so a
46
46
  // persona finds the specialists its roles unlock and no others.
47
47
  const agents = reachableAgents(input.agentsMeta ?? {}, scopes);
48
48
  return { catalogue, intents, scopes, agents };
@@ -2,7 +2,7 @@
2
2
  * Which of the product's agents a persona can actually talk to.
3
3
  *
4
4
  * An agent is not something a persona declares. It is something a persona
5
- * *reaches*, under exactly the rule an RPC is reached by: `CoreAIAgent.scopes`
5
+ * *reaches*, under exactly the rule an RPC is reached by: `CoreAgent.scopes`
6
6
  * is checked against the session, so a persona holding the scopes an agent
7
7
  * requires finds it in front of them, and one that does not, does not.
8
8
  *
@@ -1,4 +1,5 @@
1
- import type { CoreFeature, CoreWorkflow, FeaturePlanEntry } from './workflow.types.js';
1
+ import type { CoreWorkflow } from './workflow.types.js';
2
+ import type { CoreFeature, FeaturePlanEntry } from './scenario.types.js';
2
3
  export declare const addFeature: (featureId: string, feature: CoreFeature, packageName?: string | null) => void;
3
4
  export declare const resolveFeatureScenarios: (features: Map<string, CoreFeature>, registrations: Map<string, CoreWorkflow>) => {
4
5
  entries: FeaturePlanEntry[];
@@ -8,21 +8,10 @@ export { deriveInvocationId, uuidv5 } from './workflow-invocation-id.js';
8
8
  export { isRef } from './graph/workflow-graph.types.js';
9
9
  export type { RefValue } from './graph/workflow-graph.types.js';
10
10
  export { buildRunTimeline, reconstructStateAt, reconstructFinalState, } from './run-timeline.js';
11
- export type { RunTimeline, ReconstructedRunState, } from './run-timeline.js';
11
+ export type { RunTimeline, ReconstructedRunState } from './run-timeline.js';
12
12
  export { addWorkflow } from './dsl/workflow-runner.js';
13
- export { addFeature, resolveFeatureScenarios } from './feature.js';
14
13
  export { template, type TemplateString } from './graph/template.js';
15
14
  export { pikkuWorkflowGraph, type PikkuWorkflowGraphConfig, type PikkuWorkflowGraphResult, } from './graph/wire-workflow-graph.js';
16
15
  export type { WorkflowStepInput as WorkflowStepQueueInput, PikkuWorkflowOrchestratorInput, PikkuWorkflowSleeperInput, } from './workflow-queue-workers.js';
17
- export type { WorkflowService, WorkflowQueueOptions, WorkflowServiceConfig, WorkflowPlannedStep, WorkflowRunWire, WorkflowStatus, WorkflowVersionStatus, StepStatus, WorkflowRun, WorkflowRunStatus, StepState, WorkflowRunService, WorkflowRunMirror, CoreWorkflow, CoreFeature, FeatureMeta, FeaturesMeta, FeaturePlanEntry, PikkuWorkflow, ContextVariable, WorkflowContext, WorkflowsMeta, WorkflowsRuntimeMeta, } from './workflow.types.js';
18
- export type { WorkflowStepOptions, WorkflowWireDoRPC, WorkflowApprovalOptions, ApprovalOutcome, InputSource, OutputBinding, RpcStepMeta, Condition, BranchStepMeta, ParallelGroupStepMeta, FanoutStepMeta, ReturnStepMeta, InlineStepMeta, SleepStepMeta, CancelStepMeta, SuspendStepMeta, ApprovalStepMeta, SetStepMeta, SwitchCaseMeta, SwitchStepMeta, FilterStepMeta, ArrayPredicateStepMeta, ScenarioStepInvocation, ScenarioStepMeta, WorkflowStepMeta, WorkflowStepWire, PikkuWorkflowWire, PikkuScenarioWire, } from './workflow.types.js';
19
- export type { ScenarioStepPhase, ScenarioStepKind, ScenarioStepOptions, PikkuScenarioStepWire, ScenarioEnvironment, ScenarioSurface, ScenarioSurfaceResolution, } from './scenario-step.types.js';
20
- export { SCENARIO_SURFACES } from './scenario-step.types.js';
21
- export { resolveScenarioSurfaces } from './scenario-surface.js';
22
- export { requireActor, requireScenarioEnv } from './scenario-step-guards.js';
23
- export { pollUntil, type PollOptions } from './scenario-poll.js';
24
- export { createCookieJar } from './scenario-cookie-jar.js';
25
- export type { ScenarioCookieJar } from './scenario-cookie-jar.js';
26
- export type { ScenarioHttpResponse, ScenarioJsonRequest, } from '../../services/personas-service.js';
27
- export type { PikkuBrowserWire, TestIdSelector, ScenarioBrowserProvider, ScenarioBrowserFailure, } from './scenario-step.types.js';
28
- export { composeStepProse, renderStepTemplate } from './scenario-prose.js';
16
+ export type { WorkflowService, WorkflowQueueOptions, WorkflowServiceConfig, WorkflowPlannedStep, WorkflowRunWire, WorkflowStatus, WorkflowVersionStatus, StepStatus, WorkflowRun, WorkflowRunStatus, StepState, WorkflowRunService, WorkflowRunMirror, CoreWorkflow, PikkuWorkflow, ContextVariable, WorkflowContext, WorkflowsMeta, WorkflowsRuntimeMeta, } from './workflow.types.js';
17
+ export type { WorkflowStepOptions, WorkflowWireDoRPC, WorkflowApprovalOptions, ApprovalOutcome, InputSource, OutputBinding, RpcStepMeta, Condition, BranchStepMeta, ParallelGroupStepMeta, FanoutStepMeta, ReturnStepMeta, InlineStepMeta, SleepStepMeta, CancelStepMeta, SuspendStepMeta, ApprovalStepMeta, SetStepMeta, SwitchCaseMeta, SwitchStepMeta, FilterStepMeta, ArrayPredicateStepMeta, WorkflowStepMeta, WorkflowStepWire, PikkuWorkflowWire, } from './workflow.types.js';
@@ -7,13 +7,5 @@ export { deriveInvocationId, uuidv5 } from './workflow-invocation-id.js';
7
7
  export { isRef } from './graph/workflow-graph.types.js';
8
8
  export { buildRunTimeline, reconstructStateAt, reconstructFinalState, } from './run-timeline.js';
9
9
  export { addWorkflow } from './dsl/workflow-runner.js';
10
- export { addFeature, resolveFeatureScenarios } from './feature.js';
11
10
  export { template } from './graph/template.js';
12
11
  export { pikkuWorkflowGraph, } from './graph/wire-workflow-graph.js';
13
- export { SCENARIO_SURFACES } from './scenario-step.types.js';
14
- // Which of a step's bindings run: one for an action, every witness for a `then`
15
- export { resolveScenarioSurfaces } from './scenario-surface.js';
16
- export { requireActor, requireScenarioEnv } from './scenario-step-guards.js';
17
- export { pollUntil } from './scenario-poll.js';
18
- export { createCookieJar } from './scenario-cookie-jar.js';
19
- export { composeStepProse, renderStepTemplate } from './scenario-prose.js';
@@ -5,6 +5,16 @@ import type { PikkuRawWire } from '../../types/core.types.js';
5
5
  import type { ScenarioPersonas } from '../../services/personas-service.js';
6
6
  import type { ScenarioBrowserProvider, ScenarioEnvironment, ScenarioSurface } from './scenario-step.types.js';
7
7
  import type { PikkuWorkflowWire, WorkflowQueueOptions } from './workflow.types.js';
8
+ export { addFeature, resolveFeatureScenarios } from './feature.js';
9
+ export type * from './scenario.types.js';
10
+ export { SCENARIO_SURFACES } from './scenario-step.types.js';
11
+ export { resolveScenarioSurfaces } from './scenario-surface.js';
12
+ export { pollUntil, type PollOptions } from './scenario-poll.js';
13
+ export { createCookieJar } from './scenario-cookie-jar.js';
14
+ export type { ScenarioCookieJar } from './scenario-cookie-jar.js';
15
+ export { composeStepProse, renderStepTemplate } from './scenario-prose.js';
16
+ export { requireActor, requireScenarioEnv } from './scenario-step-guards.js';
17
+ export type { ScenarioHttpResponse, ScenarioJsonRequest, } from '../../services/personas-service.js';
8
18
  /**
9
19
  * A workflow service with the scenario capability attached — the two lines
10
20
  * `pikku scenario run` needs, in one call so no caller has to remember that the
@@ -7,6 +7,15 @@ import { InMemoryWorkflowService } from '../../services/in-memory-workflow-servi
7
7
  import { runScheduledTask } from '../scheduler/scheduler-runner.js';
8
8
  import { WorkflowStepNameNotString } from './workflow-errors.js';
9
9
  import { resolveScenarioSurfaces, witnessesAgree } from './scenario-surface.js';
10
+ export { addFeature, resolveFeatureScenarios } from './feature.js';
11
+ export { SCENARIO_SURFACES } from './scenario-step.types.js';
12
+ // Which of a step's bindings run: one for an action, every witness for a `then`
13
+ export { resolveScenarioSurfaces } from './scenario-surface.js';
14
+ export { pollUntil } from './scenario-poll.js';
15
+ export { createCookieJar } from './scenario-cookie-jar.js';
16
+ export { composeStepProse, renderStepTemplate } from './scenario-prose.js';
17
+ export { requireActor, requireScenarioEnv } from './scenario-step-guards.js';
18
+ // The readers themselves live on `@pikku/core/persona`
10
19
  /**
11
20
  * A workflow service with the scenario capability attached — the two lines
12
21
  * `pikku scenario run` needs, in one call so no caller has to remember that the
@@ -11,7 +11,7 @@ export interface RunTimelineEvent {
11
11
  error?: SerializedError;
12
12
  }
13
13
  export type RunTimeline = RunTimelineEvent[];
14
- type HistoryEntry = StepState & {
14
+ export type HistoryEntry = StepState & {
15
15
  stepName: string;
16
16
  };
17
17
  export declare function buildRunTimeline(history: HistoryEntry[]): RunTimeline;
@@ -35,4 +35,3 @@ export interface ReconstructedRunState {
35
35
  }
36
36
  export declare function reconstructStateAt(timeline: RunTimeline, at: number | Date): ReconstructedRunState;
37
37
  export declare function reconstructFinalState(timeline: RunTimeline): ReconstructedRunState;
38
- export {};
@@ -0,0 +1,37 @@
1
+ import type { CorePikkuFunctionConfig, CorePikkuFunctionHook } from '../../function/functions.types.js';
2
+ export type { ScenarioStepInvocation, ScenarioStepMeta, PikkuScenarioWire, } from './dsl/workflow-dsl.types.js';
3
+ export type { ScenarioStepPhase, ScenarioStepKind, ScenarioStepOptions, PikkuScenarioStepWire, ScenarioEnvironment, ScenarioSurface, ScenarioSurfaceResolution, PikkuBrowserWire, TestIdSelector, ScenarioBrowserProvider, ScenarioBrowserFailure, } from './scenario-step.types.js';
4
+ export type CoreFeatureScenario = CorePikkuFunctionConfig<any, any, any> | {
5
+ scenario: CorePikkuFunctionConfig<any, any, any>;
6
+ data: unknown;
7
+ };
8
+ export type CoreFeature = {
9
+ name: string;
10
+ description?: string;
11
+ tags?: string[];
12
+ scenarios: readonly CoreFeatureScenario[];
13
+ before?: CorePikkuFunctionHook;
14
+ after?: CorePikkuFunctionHook;
15
+ };
16
+ export type FeatureMetaEntry = {
17
+ scenario: string;
18
+ data?: unknown;
19
+ };
20
+ export type FeatureMeta = {
21
+ id: string;
22
+ name: string;
23
+ description?: string;
24
+ tags: string[];
25
+ entries: FeatureMetaEntry[];
26
+ unresolvedEntries: number;
27
+ hasBefore: boolean;
28
+ hasAfter: boolean;
29
+ };
30
+ export type FeaturesMeta = Record<string, FeatureMeta>;
31
+ export type FeaturePlanEntry = {
32
+ featureId: string;
33
+ featureName: string;
34
+ scenarioName: string;
35
+ data?: unknown;
36
+ tags: string[];
37
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,9 +1,8 @@
1
1
  import type { SerializedError, CommonWireMeta } from '../../types/core.types.js';
2
- import type { CorePikkuFunctionConfig, CorePikkuFunctionHook } from '../../function/functions.types.js';
2
+ import type { CorePikkuFunctionConfig } from '../../function/functions.types.js';
3
3
  import type { GroupConcurrencyConfig } from '../queue/queue.types.js';
4
4
  export type { WorkflowService } from '../../services/workflow-service.js';
5
- export type { WorkflowStepOptions, WorkflowWireDoRPC, WorkflowApprovalOptions, ApprovalOutcome, InputSource, OutputBinding, RpcStepMeta, Condition, BranchStepMeta, ParallelGroupStepMeta, FanoutStepMeta, ReturnStepMeta, InlineStepMeta, SleepStepMeta, CancelStepMeta, SuspendStepMeta, ApprovalStepMeta, SetStepMeta, SwitchCaseMeta, SwitchStepMeta, FilterStepMeta, ArrayPredicateStepMeta, ScenarioStepInvocation, ScenarioStepMeta, WorkflowStepMeta, WorkflowStepWire, PikkuWorkflowWire, PikkuScenarioWire, } from './dsl/workflow-dsl.types.js';
6
- export type { ScenarioStepPhase, ScenarioStepOptions, PikkuScenarioStepWire, PikkuBrowserWire, ScenarioBrowserProvider, } from './scenario-step.types.js';
5
+ export type { WorkflowStepOptions, WorkflowWireDoRPC, WorkflowApprovalOptions, ApprovalOutcome, InputSource, OutputBinding, RpcStepMeta, Condition, BranchStepMeta, ParallelGroupStepMeta, FanoutStepMeta, ReturnStepMeta, InlineStepMeta, SleepStepMeta, CancelStepMeta, SuspendStepMeta, ApprovalStepMeta, SetStepMeta, SwitchCaseMeta, SwitchStepMeta, FilterStepMeta, ArrayPredicateStepMeta, WorkflowStepMeta, WorkflowStepWire, PikkuWorkflowWire, } from './dsl/workflow-dsl.types.js';
7
6
  import type { WorkflowStepMeta } from './dsl/workflow-dsl.types.js';
8
7
  export interface WorkflowRunWire {
9
8
  type: string;
@@ -141,40 +140,6 @@ export type CoreWorkflow<PikkuFunctionConfig extends CorePikkuFunctionConfig<any
141
140
  middleware?: PikkuFunctionConfig['middleware'];
142
141
  tags?: string[];
143
142
  };
144
- export type CoreFeatureScenario = CorePikkuFunctionConfig<any, any, any> | {
145
- scenario: CorePikkuFunctionConfig<any, any, any>;
146
- data: unknown;
147
- };
148
- export type CoreFeature = {
149
- name: string;
150
- description?: string;
151
- tags?: string[];
152
- scenarios: readonly CoreFeatureScenario[];
153
- before?: CorePikkuFunctionHook;
154
- after?: CorePikkuFunctionHook;
155
- };
156
- export type FeatureMetaEntry = {
157
- scenario: string;
158
- data?: unknown;
159
- };
160
- export type FeatureMeta = {
161
- id: string;
162
- name: string;
163
- description?: string;
164
- tags: string[];
165
- entries: FeatureMetaEntry[];
166
- unresolvedEntries: number;
167
- hasBefore: boolean;
168
- hasAfter: boolean;
169
- };
170
- export type FeaturesMeta = Record<string, FeatureMeta>;
171
- export type FeaturePlanEntry = {
172
- featureId: string;
173
- featureName: string;
174
- scenarioName: string;
175
- data?: unknown;
176
- tags: string[];
177
- };
178
143
  export interface PikkuWorkflow {
179
144
  start: <I>(input: I) => Promise<{
180
145
  runId: string;
@@ -1,16 +1,16 @@
1
1
  ---
2
2
  type: decision
3
- title: A non-streaming agent run registers with aiRunState on the same terms as a streaming one
4
- description: Otherwise interruptAIAgent finds the run, passes the ownership check, then cannot stop it — and reports that as if the run were on another host
5
- tags: core, ai-agent
3
+ title: A non-streaming agent run registers with agentRunState on the same terms as a streaming one
4
+ description: Otherwise interruptAgent finds the run, passes the ownership check, then cannot stop it — and reports that as if the run were on another host
5
+ tags: core, agent
6
6
  ---
7
7
 
8
- # A non-streaming agent run registers with `aiRunState` too
8
+ # A non-streaming agent run registers with `agentRunState` too
9
9
 
10
- `runAIAgent` registers its run with `aiRunState` exactly as `streamAIAgent`
10
+ `runAgent` registers its run with `agentRunState` exactly as `streamAgent`
11
11
  does, even though nothing is streaming and there is no channel to interrupt.
12
12
 
13
- `interruptAIAgent` resolves a run through `aiRunState` first, checks ownership,
13
+ `interruptAgent` resolves a run through `agentRunState` first, checks ownership,
14
14
  then looks for a local abort handle. A run that skipped registration is invisible
15
15
  at the first step. A run that registered but has no handle is visible, passes the
16
16
  ownership check, and then cannot be stopped — which the interrupt path reports as
@@ -2,7 +2,7 @@
2
2
  type: decision
3
3
  title: A resumed turn is as interruptible as the first one
4
4
  description: It is the same person listening to the same voice, and after an approval it is where most of the reply actually gets spoken
5
- tags: core, ai-agent
5
+ tags: core, agent
6
6
  ---
7
7
 
8
8
  # A resumed turn is as interruptible as the first one
@@ -19,6 +19,6 @@ including middleware, permissions and session handling, rather than through an
19
19
  in-process call that skips all of it. It also lets the engine be unit-tested
20
20
  against scripted targets with no server at all.
21
21
 
22
- **What this rules out:** calling `runAIAgent` / `streamAIAgent` directly from the
22
+ **What this rules out:** calling `runAgent` / `streamAgent` directly from the
23
23
  conversation engine, and widening `TargetAgentDriver` with transport details
24
24
  (headers, cookies, channels) that would tie the engine to HTTP.
@@ -2,26 +2,26 @@
2
2
  type: decision
3
3
  title: The AG-UI bridge obeys the client's event-ordering contract exactly
4
4
  description: RUN_STARTED opens lazily, RUN_FINISHED fires once on done, and step names are globally sequential — a violation makes the client drop the whole stream
5
- tags: ai-agent
5
+ tags: agent
6
6
  ---
7
7
 
8
8
  # The AG-UI bridge obeys the client's event-ordering contract exactly
9
9
 
10
- `wrapChannelWithAGUI` in `packages/core/src/wirings/ai-agent/ai-agent-agui.ts`
10
+ `wrapChannelWithAGUI` in `packages/core/src/wirings/agent/agent-agui.ts`
11
11
  translates pikku stream events into AG-UI events under three rules that
12
12
  `@ag-ui/client`'s `verifyEvents` enforces on the browser side:
13
13
 
14
14
  `RUN_STARTED` is emitted lazily, from the first translated event, because the
15
15
  client rejects anything that arrives before it — and because the real
16
- `AIRunStateService` run id only exists after the channel has been wrapped, which
17
- is why `AGUIChannelOptions.getRunId` and `StreamAIAgentOptions.onRunCreated`
16
+ `AgentRunStateService` run id only exists after the channel has been wrapped, which
17
+ is why `AGUIChannelOptions.getRunId` and `StreamAgentOptions.onRunCreated`
18
18
  exist as late-bound sources. `RUN_FINISHED` is terminal for the client, so it is
19
19
  sent exactly once, on `done`, carrying usage accumulated across all steps; per-step
20
20
  `usage` events must not finish the run, or a multi-step tool run would emit later
21
21
  steps after the terminal event and the client would drop the whole stream.
22
22
  Step names must be unique among active steps, and sub-agents reuse step numbers
23
23
  on the shared channel, so each `step-start` closes the previous step and takes a
24
- sequential name. `ai-agent-agui.test.ts` re-implements those ordering rules so
24
+ sequential name. `agent-agui.test.ts` re-implements those ordering rules so
25
25
  the bridge is checked against the same contract the browser applies.
26
26
 
27
27
  **What this rules out:** emitting `RUN_STARTED` eagerly at wrap time; finishing
@@ -2,12 +2,12 @@
2
2
  type: decision
3
3
  title: Audio chunks are labelled with the format the provider actually returned
4
4
  description: The configured format is only a request, so the response's own format wins with the request and pcm16 as fallbacks
5
- tags: ai-agent
5
+ tags: agent
6
6
  ---
7
7
 
8
8
  # Audio chunks are labelled with the format the provider actually returned
9
9
 
10
- `synthesizeAudio` in `packages/core/src/wirings/ai-agent/voice-output.ts` labels
10
+ `synthesizeAudio` in `packages/core/src/wirings/agent/voice-output.ts` labels
11
11
  each `audio-delta` event with `result.audio.format` first, falling back to the
12
12
  requested `config.format` and finally to `pcm16`.
13
13
 
@@ -2,7 +2,7 @@
2
2
  type: decision
3
3
  title: Loading agent context waits for a tool result that may still be landing
4
4
  description: An interrupted run's tool can still be writing to the thread, and in voice the next turn arrives within seconds — soon enough to load context missing what it is about to be asked about
5
- tags: core, ai-agent
5
+ tags: core, agent
6
6
  ---
7
7
 
8
8
  # Loading agent context waits for a tool result that may still be landing
@@ -2,13 +2,13 @@
2
2
  type: decision
3
3
  title: A credential-required tool result never reaches the client or the transcript
4
4
  description: The run suspends with credential-request events instead, leaving the tool call unresulted so it can be resumed after connecting
5
- tags: ai-agent
5
+ tags: agent
6
6
  ---
7
7
 
8
8
  # A credential-required tool result never reaches the client or the transcript
9
9
 
10
10
  When a tool returns the `__credentialRequired` marker,
11
- `streamAIAgent` in `packages/core/src/wirings/ai-agent/ai-agent-stream.ts`
11
+ `streamAgent` in `packages/core/src/wirings/agent/agent-stream.ts`
12
12
  filters that `tool-result` out of the channel before it can be streamed or
13
13
  persisted, and `handleCredentialRequests` suspends the run and emits
14
14
  `credential-request` events carrying the `runId` instead. Those events — not the
@@ -2,18 +2,18 @@
2
2
  type: decision
3
3
  title: Delegate mode hides the parent's later text, supervise mode hides the sub-agent's
4
4
  description: Exactly one voice reaches the client per agent-mode; approvals and tool events always flow through either way
5
- tags: ai-agent
5
+ tags: agent
6
6
  ---
7
7
 
8
8
  # Delegate mode hides the parent's later text, supervise mode hides the sub-agent's
9
9
 
10
10
  An agent with sub-agents runs in one of two modes. In `'delegate'` (the default,
11
- handled in `streamAIAgent` in `ai-agent-stream.ts`) the parent's `text-delta` and
12
- `reasoning-delta` events are suppressed *after* the first sub-agent call —
11
+ handled in `streamAgent` in `agent-stream.ts`) the parent's `text-delta` and
12
+ `reasoning-delta` events are suppressed _after_ the first sub-agent call —
13
13
  `delegateState.delegated` is the latch — so a parent that answers directly still
14
14
  streams normally, while a parent that hands off does not narrate over its
15
15
  sub-agent. In `'supervise'` (handled where the sub-agent channel is built in
16
- `buildToolDefs` in `ai-agent-prepare.ts`) the inverse holds: the sub-agent's text
16
+ `buildToolDefs` in `agent-prepare.ts`) the inverse holds: the sub-agent's text
17
17
  and reasoning are dropped and only the supervisor speaks.
18
18
 
19
19
  Suppression is confined to text and reasoning. Approval requests, tool calls,
@@ -2,13 +2,13 @@
2
2
  type: decision
3
3
  title: Nulls are stripped from approved tool arguments before execution
4
4
  description: LLMs emit null for optional fields where the schema layer expects undefined, so a resumed tool call is cleaned recursively first
5
- tags: ai-agent
5
+ tags: agent
6
6
  ---
7
7
 
8
8
  # Nulls are stripped from approved tool arguments before execution
9
9
 
10
- `resumeAIAgentSync` in
11
- `packages/core/src/wirings/ai-agent/ai-agent-runner.ts` runs `stripNulls` over
10
+ `resumeAgentSync` in
11
+ `packages/core/src/wirings/agent/agent-runner.ts` runs `stripNulls` over
12
12
  the persisted arguments of an approved tool call before invoking the tool.
13
13
 
14
14
  Models routinely fill every property in a JSON schema, using `null` to mean "not
@@ -2,13 +2,13 @@
2
2
  type: decision
3
3
  title: Model resolution stays a single seam even though it is currently a passthrough
4
4
  description: resolveModelConfig looks removable but is the one merge point for per-request model overrides
5
- tags: ai-agent
5
+ tags: agent
6
6
  ---
7
7
 
8
8
  # Model resolution stays a single seam even though it is currently a passthrough
9
9
 
10
10
  `resolveModelConfig` in
11
- `packages/core/src/wirings/ai-agent/ai-agent-model-config.ts` returns the
11
+ `packages/core/src/wirings/agent/agent-model-config.ts` returns the
12
12
  agent's `model`, `temperature` and `maxSteps` unchanged, and ignores its
13
13
  `_agentName` argument. It reads as dead indirection and is not.
14
14
 
@@ -16,7 +16,7 @@ Models are declared per agent in the provider-qualified `provider/model` form
16
16
  (`openai/gpt-5-mini`); there is no config-level alias map to consult, which is
17
17
  why the current body is a copy. The function exists so that every caller —
18
18
  `prepareAgentRun`, both resume paths, and the per-request `input.model` /
19
- `input.temperature` overrides applied in `ai-agent-prepare.ts` — assembles the
19
+ `input.temperature` overrides applied in `agent-prepare.ts` — assembles the
20
20
  effective config the same way, through one place that can grow an alias map,
21
21
  per-tenant defaults or provider fallbacks without touching them.
22
22
 
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  type: decision
3
- title: An aiMiddleware onError hook cannot change how a run fails
3
+ title: An agentMiddleware onError hook cannot change how a run fails
4
4
  description: Hook throws are swallowed so observability code can never convert, mask, or replace the original error
5
- tags: ai-agent
5
+ tags: agent
6
6
  ---
7
7
 
8
- # An aiMiddleware onError hook cannot change how a run fails
8
+ # An agentMiddleware onError hook cannot change how a run fails
9
9
 
10
- Every `onError` invocation on the agent failure paths — in `streamAIAgent` and
11
- `continueAfterToolResult` (`ai-agent-stream.ts`) and in `runAIAgent` and
12
- `continueAfterToolResultSync` (`ai-agent-runner.ts`) — is wrapped in its own
10
+ Every `onError` invocation on the agent failure paths — in `streamAgent` and
11
+ `continueAfterToolResult` (`agent-stream.ts`) and in `runAgent` and
12
+ `continueAfterToolResultSync` (`agent-runner.ts`) — is wrapped in its own
13
13
  `try/catch` that discards whatever the hook throws. The run is then marked
14
14
  `failed` with the original error message, and the original error propagates.
15
15
 
@@ -2,18 +2,18 @@
2
2
  type: decision
3
3
  title: AI runner methods must be called on the runner, never as detached references
4
4
  description: Implementations use this internally, so grabbing transcribe or generateSpeech as a bare function loses the receiver and throws at runtime
5
- tags: ai-agent
5
+ tags: agent
6
6
  ---
7
7
 
8
8
  # AI runner methods must be called on the runner, never as detached references
9
9
 
10
10
  The voice middlewares in `voice-input.ts` and `voice-output.ts` invoke
11
- `aiAgentRunner.transcribe(...)` and `aiAgentRunner.generateSpeech?.(...)` as
11
+ `agentRunner.transcribe(...)` and `agentRunner.generateSpeech?.(...)` as
12
12
  method calls on the service object, and only ever test them for presence.
13
13
 
14
- `AIAgentRunnerService` is an interface implemented by classes — the reference
14
+ `AgentRunnerService` is an interface implemented by classes — the reference
15
15
  implementation's `transcribe` calls `this.getModel(...)`. Extracting the method
16
- into a local (`const { transcribe } = services.aiAgentRunner`) type-checks
16
+ into a local (`const { transcribe } = services.agentRunner`) type-checks
17
17
  cleanly and then fails at runtime with `this` undefined. The regression is
18
18
  pinned by a runner in `voice-input.test.ts` whose `transcribe` deliberately reads
19
19
  instance state through `this`.
@@ -2,7 +2,7 @@
2
2
  type: decision
3
3
  title: Agent speech travels as a CUSTOM AG-UI event rather than being dropped
4
4
  description: AG-UI has no speech event, and dropping it makes a voice agent reached over HTTP silently inaudible while the provider still bills for the audio
5
- tags: core, ai-agent
5
+ tags: core, agent
6
6
  ---
7
7
 
8
8
  # Agent speech travels as a CUSTOM AG-UI event
@@ -2,15 +2,15 @@
2
2
  type: decision
3
3
  title: Persisting an agent stream from send is best-effort and must never reject
4
4
  description: The persisting channel flushes fire-and-forget because send is synchronous; a storage failure degrades the transcript instead of killing the process
5
- tags: ai-agent
5
+ tags: agent
6
6
  ---
7
7
 
8
8
  # Persisting an agent stream from send is best-effort and must never reject
9
9
 
10
10
  `createPersistingChannel` in
11
- `packages/core/src/wirings/ai-agent/ai-agent-stream.ts` accumulates step text,
11
+ `packages/core/src/wirings/agent/agent-stream.ts` accumulates step text,
12
12
  tool calls and tool results, and writes them via `flushDetached` on the `usage`
13
- and `done` events. `AIStreamChannel.send` is synchronous, so it cannot await the
13
+ and `done` events. `AgentStreamChannel.send` is synchronous, so it cannot await the
14
14
  write. An unawaited rejection has nothing to propagate to and surfaces as an
15
15
  `unhandledRejection`, which takes the whole server process down — a model
16
16
  reusing a `toolCallId`, which is a primary key in AI storage, is enough to
@@ -18,7 +18,7 @@ trigger it. `flushDetached` therefore catches and logs, and the run carries on.
18
18
 
19
19
  The awaited `flush()` on the suspend paths (`handleApprovals`,
20
20
  `handleCredentialRequests`) is the seam that still surfaces persistence failures
21
- to a caller. The regression test lives in `ai-agent-stream.test.ts`; because the
21
+ to a caller. The regression test lives in `agent-stream.test.ts`; because the
22
22
  floating promise settles on a later macrotask, the assertion has to wait a real
23
23
  timer before checking that no `unhandledRejection` fired.
24
24
 
@@ -2,14 +2,14 @@
2
2
  type: decision
3
3
  title: A delegated sub-agent inherits the parent run's context block
4
4
  description: The sub-agent tool schema carries only message and session, so the parent's identifier block is forwarded rather than re-typed by the model
5
- tags: ai-agent
5
+ tags: agent
6
6
  ---
7
7
 
8
8
  # A delegated sub-agent inherits the parent run's context block
9
9
 
10
10
  `buildSubAgentRunInput` in
11
- `packages/core/src/wirings/ai-agent/ai-agent-prepare.ts` forwards the parent
12
- run's `AIAgentInput.context` — the "Current context" identifier block with
11
+ `packages/core/src/wirings/agent/agent-prepare.ts` forwards the parent
12
+ run's `AgentInput.context` — the "Current context" identifier block with
13
13
  organization, project and stage ids — into every delegated sub-agent run, on
14
14
  both the streaming and non-streaming paths. `buildToolDefs` threads it down as
15
15
  `parentContext` for the same reason.
@@ -2,12 +2,12 @@
2
2
  type: decision
3
3
  title: A tool's execute() failure is logged before the AI SDK swallows it
4
4
  description: Every agent tool is wrapped in a logging try/catch, because a thrown tool error otherwise becomes a conversational reply and is invisible server-side
5
- tags: ai-agent
5
+ tags: agent
6
6
  ---
7
7
 
8
8
  # A tool's execute() failure is logged before the AI SDK swallows it
9
9
 
10
- `buildToolDefs` in `packages/core/src/wirings/ai-agent/ai-agent-prepare.ts`
10
+ `buildToolDefs` in `packages/core/src/wirings/agent/agent-prepare.ts`
11
11
  wraps every tool it builds — RPC tools, sub-agent delegations and workflow tools
12
12
  alike — in a `try/catch` that logs through `singletonServices.logger` and
13
13
  rethrows.
@@ -18,7 +18,7 @@ and turns it into a conversational "tool error" reply to the model. The exceptio
18
18
  never reaches pikku's own logger, so without this wrapper a consistently failing
19
19
  tool is undiagnosable from the server side — the only symptom is an agent that
20
20
  keeps apologising. The wrapper is applied unconditionally, not only when an
21
- `aiMiddleware` `afterToolCall` hook happens to be registered.
21
+ `agentMiddleware` `afterToolCall` hook happens to be registered.
22
22
 
23
23
  **What this rules out:** folding the logging into the optional middleware
24
24
  wrapper below it, and relying on the AI SDK's own error reporting for tool
@@ -2,13 +2,13 @@
2
2
  type: decision
3
3
  title: Voice input transcribes audio parts sequentially and in place
4
4
  description: Each audio part is replaced by its text where it sat, one at a time, bounding concurrent downloads and preserving content order
5
- tags: ai-agent
5
+ tags: agent
6
6
  ---
7
7
 
8
8
  # Voice input transcribes audio parts sequentially and in place
9
9
 
10
10
  The `voiceInput` middleware in
11
- `packages/core/src/wirings/ai-agent/voice-input.ts` walks the last user
11
+ `packages/core/src/wirings/agent/voice-input.ts` walks the last user
12
12
  message's content parts in order and swaps each audio part for a text part at the
13
13
  same index, awaiting one transcription before starting the next.
14
14
 
@@ -2,13 +2,13 @@
2
2
  type: decision
3
3
  title: Working memory is persisted only when the merged value validates
4
4
  description: A failed schema check logs and drops the update rather than saving it, because invalid state poisons every later read
5
- tags: ai-agent
5
+ tags: agent
6
6
  ---
7
7
 
8
8
  # Working memory is persisted only when the merged value validates
9
9
 
10
10
  `createWorkingMemoryMiddleware` in
11
- `packages/core/src/wirings/ai-agent/ai-agent-memory.ts` parses the model's
11
+ `packages/core/src/wirings/agent/agent-memory.ts` parses the model's
12
12
  `<working_memory>` block, deep-merges it into the stored value, validates the
13
13
  merge against the agent's working-memory schema when one is declared, and calls
14
14
  `saveWorkingMemory` only if the merge is valid. An invalid merge is logged as a
@@ -2,7 +2,7 @@
2
2
  type: decision
3
3
  title: An interrupt is not a failure, and the non-streaming path throws rather than returning
4
4
  description: It skips the onError hooks and never becomes an errorMessage; with no partial reply to hand back, a typed throw is what distinguishes it from a provider outage
5
- tags: core, ai-agent
5
+ tags: core, agent
6
6
  ---
7
7
 
8
8
  # An interrupt is not a failure
@@ -14,7 +14,7 @@ that did not happen.
14
14
 
15
15
  The streaming and non-streaming paths then diverge, because what they can hand
16
16
  back differs. A stream has already delivered part of the reply, so it returns
17
- that fragment. `runAIAgent` has delivered nothing — there is no partial answer to
17
+ that fragment. `runAgent` has delivered nothing — there is no partial answer to
18
18
  return — so it throws a typed error instead. A caller can tell that apart from a
19
19
  provider outage, which returning an empty result would not allow.
20
20