@pikku/core 0.12.83 → 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 (343) hide show
  1. package/CHANGELOG.md +68 -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 +4 -4
  104. package/dist/services/index.js +1 -1
  105. package/dist/services/meta-service.d.ts +3 -3
  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 +10 -10
  113. package/dist/types/core.types.js +1 -1
  114. package/dist/types/state.types.d.ts +5 -5
  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/voice-output.d.ts +1 -2
  171. package/dist/wirings/channel/channel-rpc.types.d.ts +2 -2
  172. package/dist/wirings/rpc/rpc-runner.d.ts +1 -1
  173. package/dist/wirings/rpc/rpc-runner.js +2 -2
  174. package/dist/wirings/rpc/rpc-types.d.ts +1 -1
  175. package/dist/wirings/virtual-user/prepare-virtual-user-run.js +1 -1
  176. package/dist/wirings/virtual-user/virtual-user-agents.d.ts +1 -1
  177. package/dist/wirings/workflow/run-timeline.d.ts +1 -2
  178. 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
  179. package/knowledge/decisions/internals/a-resumed-agent-turn-is-as-interruptible-as-the-first.md +1 -1
  180. package/knowledge/decisions/internals/actor-flow-drives-the-target-through-a-transport-seam.md +1 -1
  181. 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
  182. 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
  183. package/knowledge/decisions/internals/agent-context-waits-for-a-tool-result-still-being-written.md +1 -1
  184. package/knowledge/decisions/internals/{ai-agent-credential-suspensions-hide-the-tool-result.md → agent-credential-suspensions-hide-the-tool-result.md} +2 -2
  185. package/knowledge/decisions/internals/{ai-agent-delegate-and-supervise-hide-different-text.md → agent-delegate-and-supervise-hide-different-text.md} +4 -4
  186. package/knowledge/decisions/internals/{ai-agent-llm-tool-arguments-have-nulls-stripped.md → agent-llm-tool-arguments-have-nulls-stripped.md} +3 -3
  187. 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
  188. package/knowledge/decisions/internals/{ai-agent-onerror-hooks-cannot-change-the-failure.md → agent-onerror-hooks-cannot-change-the-failure.md} +6 -6
  189. package/knowledge/decisions/internals/{ai-agent-runner-methods-must-keep-their-receiver.md → agent-runner-methods-must-keep-their-receiver.md} +4 -4
  190. package/knowledge/decisions/internals/agent-speech-travels-as-a-custom-agui-event.md +1 -1
  191. package/knowledge/decisions/internals/{ai-agent-stream-persistence-is-best-effort.md → agent-stream-persistence-is-best-effort.md} +4 -4
  192. 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
  193. package/knowledge/decisions/internals/{ai-agent-tool-execute-failures-are-logged-unconditionally.md → agent-tool-execute-failures-are-logged-unconditionally.md} +3 -3
  194. 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
  195. 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
  196. package/knowledge/decisions/internals/an-agent-interrupt-is-not-a-failure.md +2 -2
  197. package/knowledge/decisions/internals/an-agent-run-owned-by-another-instance-says-so.md +3 -3
  198. package/knowledge/decisions/internals/an-agent-stream-send-must-return-the-inner-sends-promise.md +2 -2
  199. package/knowledge/decisions/internals/an-empty-text-part-is-omitted-from-an-agent-message.md +1 -1
  200. package/knowledge/decisions/internals/an-empty-transcript-is-not-recorded.md +1 -1
  201. package/knowledge/decisions/internals/speech-synthesis-picks-a-voice-per-sentence-and-warns-once.md +1 -1
  202. package/knowledge/decisions/internals/the-agent-done-event-goes-through-the-middleware-and-is-awaited.md +1 -1
  203. package/knowledge/decisions/internals/the-embedding-model-is-pinned-per-service-and-doc-query-embedding-is-split.md +1 -1
  204. package/knowledge/decisions/internals/the-per-invocation-rpc-view-is-a-class.md +5 -5
  205. package/knowledge/decisions/internals/the-transcript-event-is-sent-ahead-of-the-run.md +2 -2
  206. package/knowledge/decisions/internals/thread-history-records-the-transcript-not-the-audio.md +2 -2
  207. package/knowledge/decisions/internals/voice-output-speaks-unless-voice-input-explicitly-says-otherwise.md +1 -1
  208. package/knowledge/decisions/security/{ai-agent-approval-forwarding-requires-a-symbol-brand.md → agent-approval-forwarding-requires-a-symbol-brand.md} +3 -3
  209. package/knowledge/decisions/security/{ai-agent-credential-requests-are-symbol-branded.md → agent-credential-requests-are-symbol-branded.md} +4 -4
  210. 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
  211. package/knowledge/decisions/security/{ai-agent-ownership-failures-never-echo-the-resource.md → agent-ownership-failures-never-echo-the-resource.md} +2 -2
  212. package/knowledge/decisions/security/{ai-agent-resume-re-runs-the-authorization-gate.md → agent-resume-re-runs-the-authorization-gate.md} +4 -4
  213. package/knowledge/decisions/security/{ai-agent-sessionless-deployments-have-no-thread-ownership.md → agent-sessionless-deployments-have-no-thread-ownership.md} +5 -5
  214. package/knowledge/decisions/security/{ai-agent-thread-ownership-composes-the-session-principal.md → agent-thread-ownership-composes-the-session-principal.md} +2 -2
  215. 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
  216. package/knowledge/decisions/security/an-agent-approval-is-claimed-before-the-tool-runs.md +3 -3
  217. package/knowledge/decisions/security/an-empty-owners-constraint-matches-nothing.md +3 -3
  218. package/knowledge/decisions/security/console-addon-privileged-functions-gate-themselves.md +20 -13
  219. package/knowledge/decisions/security/index.md +1 -2
  220. package/package.json +4 -3
  221. package/scripts/generate-api-report.mts +32 -8
  222. package/src/agent-naming.test.ts +68 -0
  223. package/src/ecosystem/agent-scorer.ts +24 -0
  224. package/src/ecosystem/agent.ts +42 -0
  225. package/src/ecosystem/channel/local.ts +1 -0
  226. package/src/ecosystem/channel.ts +22 -0
  227. package/src/ecosystem/cli/channel.ts +25 -0
  228. package/src/ecosystem/cli.ts +21 -0
  229. package/src/ecosystem/credential.ts +10 -0
  230. package/src/ecosystem/dev.ts +12 -0
  231. package/src/ecosystem/function.ts +28 -0
  232. package/src/ecosystem/gateway.ts +4 -0
  233. package/src/ecosystem/hmac.ts +1 -0
  234. package/src/ecosystem/http.ts +22 -0
  235. package/src/ecosystem/mcp.ts +17 -0
  236. package/src/ecosystem/middleware.ts +27 -0
  237. package/src/ecosystem/node-host-resolver.ts +1 -0
  238. package/src/ecosystem/node.ts +5 -0
  239. package/src/ecosystem/oauth2.ts +4 -0
  240. package/src/ecosystem/persona.ts +30 -0
  241. package/src/ecosystem/queue.ts +23 -0
  242. package/src/ecosystem/remote.ts +9 -0
  243. package/src/ecosystem/role.ts +13 -0
  244. package/src/ecosystem/rpc.ts +7 -0
  245. package/src/ecosystem/safe-fetch.ts +8 -0
  246. package/src/ecosystem/scenario.ts +32 -0
  247. package/src/ecosystem/scheduler.ts +5 -0
  248. package/src/ecosystem/schema.ts +1 -0
  249. package/src/ecosystem/scope.ts +14 -0
  250. package/src/ecosystem/secret.ts +15 -0
  251. package/src/ecosystem/services/istanbul-coverage.ts +1 -0
  252. package/src/ecosystem/services/local-content-request-handler.ts +16 -0
  253. package/src/ecosystem/services/local-content.ts +1 -0
  254. package/src/ecosystem/services/v8-coverage.ts +1 -0
  255. package/src/ecosystem/services.ts +82 -0
  256. package/src/ecosystem/testing.ts +8 -0
  257. package/src/ecosystem/trigger.ts +7 -0
  258. package/src/ecosystem/types.ts +34 -0
  259. package/src/ecosystem/variable.ts +14 -0
  260. package/src/ecosystem/virtual-user.ts +48 -0
  261. package/src/ecosystem/workflow.ts +68 -0
  262. package/src/index.ts +8 -19
  263. package/src/pikku-state.ts +3 -3
  264. package/src/public-surface.json +173 -68
  265. package/src/public-surface.json.README +20 -2
  266. package/src/public-surface.test.ts +31 -3
  267. package/src/services/{ai-run-state-service.ts → agent-run-state-service.ts} +5 -5
  268. package/src/services/{ai-agent-runner-service.ts → agent-runner-service.ts} +18 -18
  269. package/src/services/{ai-storage-service.ts → agent-storage-service.ts} +7 -7
  270. package/src/services/http-personas-converse.test.ts +3 -3
  271. package/src/services/http-personas.ts +4 -4
  272. package/src/services/{in-memory-ai-run-state-service.ts → in-memory-agent-run-state-service.ts} +7 -7
  273. package/src/services/index.ts +9 -9
  274. package/src/services/meta-service.ts +3 -3
  275. package/src/testing/service-tests/agent-run-service-tests.ts +4 -4
  276. package/src/testing/service-tests/{ai-storage-service-tests.ts → agent-storage-service-tests.ts} +8 -8
  277. package/src/testing/service-tests.ts +10 -8
  278. package/src/types/core.types.ts +12 -12
  279. package/src/types/state.types.ts +6 -9
  280. package/src/wirings/actor-flow/run-conversation.test.ts +2 -2
  281. package/src/wirings/actor-flow/run-conversation.ts +7 -9
  282. package/src/wirings/{ai-agent/ai-agent-agui.test.ts → agent/agent-agui.test.ts} +126 -105
  283. package/src/wirings/{ai-agent/ai-agent-agui.ts → agent/agent-agui.ts} +7 -7
  284. package/src/wirings/{ai-agent/ai-agent-authorization.test.ts → agent/agent-authorization.test.ts} +6 -6
  285. package/src/wirings/{ai-agent/ai-agent-finalize.test.ts → agent/agent-finalize.test.ts} +17 -16
  286. package/src/wirings/{ai-agent/ai-agent-finalize.ts → agent/agent-finalize.ts} +22 -22
  287. package/src/wirings/{ai-agent/ai-agent-helpers.test.ts → agent/agent-helpers.test.ts} +1 -1
  288. package/src/wirings/{ai-agent/ai-agent-helpers.ts → agent/agent-helpers.ts} +1 -1
  289. package/src/wirings/{ai-agent/ai-agent-interrupt.test.ts → agent/agent-interrupt.test.ts} +67 -77
  290. package/src/wirings/{ai-agent/ai-agent-interrupt.ts → agent/agent-interrupt.ts} +5 -5
  291. package/src/wirings/{ai-agent/ai-agent-memory.test.ts → agent/agent-memory.test.ts} +12 -12
  292. package/src/wirings/{ai-agent/ai-agent-memory.ts → agent/agent-memory.ts} +36 -36
  293. package/src/wirings/{ai-agent/ai-agent-model-config.test.ts → agent/agent-model-config.test.ts} +2 -5
  294. package/src/wirings/{ai-agent/ai-agent-model-config.ts → agent/agent-model-config.ts} +1 -1
  295. package/src/wirings/{ai-agent/ai-agent-prepare.test.ts → agent/agent-prepare.test.ts} +18 -18
  296. package/src/wirings/{ai-agent/ai-agent-prepare.ts → agent/agent-prepare.ts} +52 -51
  297. package/src/wirings/{ai-agent/ai-agent-registry.test.ts → agent/agent-registry.test.ts} +49 -43
  298. package/src/wirings/{ai-agent/ai-agent-registry.ts → agent/agent-registry.ts} +14 -14
  299. package/src/wirings/{ai-agent/ai-agent-resume-authorization.test.ts → agent/agent-resume-authorization.test.ts} +18 -18
  300. package/src/wirings/{ai-agent → agent}/agent-rpc.ts +16 -20
  301. package/src/wirings/{ai-agent/ai-agent-runner.test.ts → agent/agent-runner.test.ts} +105 -106
  302. package/src/wirings/{ai-agent/ai-agent-runner.ts → agent/agent-runner.ts} +90 -80
  303. package/src/wirings/{ai-agent/ai-agent-stream-output-hooks.test.ts → agent/agent-stream-output-hooks.test.ts} +25 -25
  304. package/src/wirings/{ai-agent/ai-agent-stream.test.ts → agent/agent-stream.test.ts} +147 -143
  305. package/src/wirings/{ai-agent/ai-agent-stream.ts → agent/agent-stream.ts} +147 -146
  306. package/src/wirings/{ai-agent/ai-agent-thread-ownership.test.ts → agent/agent-thread-ownership.test.ts} +24 -28
  307. package/src/wirings/{ai-agent/ai-agent-turn.test.ts → agent/agent-turn.test.ts} +3 -5
  308. package/src/wirings/{ai-agent/ai-agent-turn.ts → agent/agent-turn.ts} +7 -7
  309. package/src/wirings/{ai-agent/ai-agent.types.ts → agent/agent.types.ts} +51 -48
  310. package/src/wirings/agent/index.ts +56 -0
  311. package/src/wirings/{ai-agent → agent}/voice-input.test.ts +15 -15
  312. package/src/wirings/{ai-agent → agent}/voice-input.ts +11 -11
  313. package/src/wirings/{ai-agent → agent}/voice-output.test.ts +23 -23
  314. package/src/wirings/{ai-agent → agent}/voice-output.ts +11 -11
  315. package/src/wirings/{ai-scorer/ai-scorer-grade.test.ts → agent-scorer/agent-scorer-grade.test.ts} +8 -8
  316. package/src/wirings/{ai-scorer/ai-scorer-grade.ts → agent-scorer/agent-scorer-grade.ts} +9 -9
  317. package/src/wirings/{ai-scorer/ai-scorer-judge.test.ts → agent-scorer/agent-scorer-judge.test.ts} +11 -14
  318. package/src/wirings/{ai-scorer/ai-scorer-judge.ts → agent-scorer/agent-scorer-judge.ts} +11 -11
  319. package/src/wirings/{ai-scorer/ai-scorer-live.test.ts → agent-scorer/agent-scorer-live.test.ts} +11 -11
  320. package/src/wirings/{ai-scorer/ai-scorer-live.ts → agent-scorer/agent-scorer-live.ts} +3 -3
  321. package/src/wirings/{ai-scorer/ai-scorer-registry.ts → agent-scorer/agent-scorer-registry.ts} +11 -8
  322. package/src/wirings/{ai-scorer/ai-scorer-sampling.test.ts → agent-scorer/agent-scorer-sampling.test.ts} +1 -1
  323. package/src/wirings/{ai-scorer/ai-scorer-snapshots.test.ts → agent-scorer/agent-scorer-snapshots.test.ts} +2 -2
  324. package/src/wirings/{ai-scorer/ai-scorer-snapshots.ts → agent-scorer/agent-scorer-snapshots.ts} +1 -1
  325. package/src/wirings/{ai-scorer/ai-scorer-worker.test.ts → agent-scorer/agent-scorer-worker.test.ts} +15 -15
  326. package/src/wirings/{ai-scorer/ai-scorer-worker.ts → agent-scorer/agent-scorer-worker.ts} +9 -7
  327. package/src/wirings/{ai-scorer/ai-scorer.ts → agent-scorer/agent-scorer.ts} +7 -7
  328. package/src/wirings/{ai-scorer/ai-scorer.types.ts → agent-scorer/agent-scorer.types.ts} +6 -6
  329. package/src/wirings/agent-scorer/index.ts +22 -0
  330. package/src/wirings/channel/channel-rpc.types.ts +2 -2
  331. package/src/wirings/rpc/rpc-runner.ts +2 -2
  332. package/src/wirings/rpc/rpc-types.ts +1 -1
  333. package/src/wirings/virtual-user/prepare-virtual-user-run.ts +1 -1
  334. package/src/wirings/virtual-user/run-virtual-user.test.ts +2 -2
  335. package/src/wirings/virtual-user/run-virtual-user.ts +3 -3
  336. package/src/wirings/virtual-user/virtual-user-agents.ts +1 -1
  337. package/src/wirings/workflow/run-timeline.ts +1 -1
  338. package/src/wirings-stay-decoupled.test.ts +3 -3
  339. package/tsconfig.tsbuildinfo +1 -1
  340. package/src/wirings/ai-agent/index.ts +0 -65
  341. package/src/wirings/ai-scorer/index.ts +0 -24
  342. /package/src/wirings/{ai-agent/ai-agent-utils.ts → agent/agent-utils.ts} +0 -0
  343. /package/src/wirings/{ai-scorer/ai-scorer-sampling.ts → agent-scorer/agent-scorer-sampling.ts} +0 -0
@@ -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
 
@@ -2,12 +2,12 @@
2
2
  type: decision
3
3
  title: An interrupt for a run owned by another instance says so, rather than returning false
4
4
  description: A bare false is indistinguishable from "already finished", which is the one deployment shape the in-process registry cannot cover
5
- tags: core, ai-agent
5
+ tags: core, agent
6
6
  ---
7
7
 
8
8
  # An interrupt for a run owned by another instance says so
9
9
 
10
- `interruptAIAgent` resolves a run through `aiRunState`, then tries to abort it
10
+ `interruptAgent` resolves a run through `agentRunState`, then tries to abort it
11
11
  via the in-process registry. A run still marked `running` that this process has
12
12
  no abort handle for is executing on another instance.
13
13
 
@@ -19,7 +19,7 @@ the condition instead.
19
19
 
20
20
  **What this rules out:** collapsing the two outcomes into one boolean because
21
21
  the caller "only cares whether it stopped". The caller cares a great deal about
22
- the difference between *stopped* and *cannot be stopped from here*.
22
+ the difference between _stopped_ and _cannot be stopped from here_.
23
23
 
24
24
  The fix for the underlying gap is `signalRunInterrupt`, which fans the interrupt
25
25
  out over `eventHub` so every instance tries locally.
@@ -2,12 +2,12 @@
2
2
  type: decision
3
3
  title: A wrapped agent-stream send must return the inner send's promise
4
4
  description: Middleware runs asynchronously, so dropping the returned promise turns every awaited channel.send upstream into a no-op
5
- tags: core, ai-agent
5
+ tags: core, agent
6
6
  ---
7
7
 
8
8
  # A wrapped agent-stream send must return the inner send's promise
9
9
 
10
- `streamAIAgent` wraps the caller's channel so every event passes through the
10
+ `streamAgent` wraps the caller's channel so every event passes through the
11
11
  stream middleware. That wrapper's `send` returns whatever the inner `send`
12
12
  returns, and it must: the middleware chain is asynchronous, so a wrapper that
13
13
  calls the inner `send` and returns `undefined` resolves immediately while the
@@ -2,7 +2,7 @@
2
2
  type: decision
3
3
  title: A message with nothing to say carries no text part at all
4
4
  description: An attachment on its own is a real turn, and providers are entitled to reject an empty text part sitting beside it
5
- tags: core, ai-agent
5
+ tags: core, agent
6
6
  ---
7
7
 
8
8
  # A message with nothing to say carries no text part
@@ -2,7 +2,7 @@
2
2
  type: decision
3
3
  title: A transcript is recorded only when something was actually heard
4
4
  description: Recording an empty string sends a transcript event saying the user said nothing, which renders as an empty bubble rather than a pending one
5
- tags: core, ai-agent
5
+ tags: core, agent
6
6
  ---
7
7
 
8
8
  # A transcript is recorded only when something was actually heard
@@ -2,7 +2,7 @@
2
2
  type: decision
3
3
  title: Speech synthesis picks a voice per sentence but announces a limitation once
4
4
  description: A bilingual reply should speak the half it can, and repeating the notice for every sentence would bury the reply itself
5
- tags: core, ai-agent
5
+ tags: core, agent
6
6
  ---
7
7
 
8
8
  # Speech synthesis picks a voice per sentence, and warns once per reply
@@ -2,7 +2,7 @@
2
2
  type: decision
3
3
  title: The agent `done` event goes through the middleware and is awaited
4
4
  description: `done` is the only end-of-reply signal a stream hook gets, and buffering hooks flush on it — sending it raw discards work already paid for
5
- tags: core, ai-agent
5
+ tags: core, agent
6
6
  ---
7
7
 
8
8
  # The agent `done` event goes through the middleware and is awaited
@@ -24,6 +24,6 @@ same call.
24
24
 
25
25
  **What this rules out:** adding a per-call `model` parameter, collapsing
26
26
  `embedDocuments` and `embedQuery` into one `embed`, and pointing a vector store
27
- at `AIAgentRunnerService.embed` / `embedMany` instead — those take a per-call
27
+ at `AgentRunnerService.embed` / `embedMany` instead — those take a per-call
28
28
  model on purpose and drag in the whole agent-runner tool loop, and they give back
29
29
  neither guarantee.
@@ -11,16 +11,16 @@ tags: core, rpc, performance
11
11
  an object literal, and that literal declared `get agent()` so the agent facade
12
12
  stayed lazy — most requests never touch it, and reading it builds five closures.
13
13
 
14
- The laziness is right. Declaring the accessor *on the literal* was not: a
14
+ The laziness is right. Declaring the accessor _on the literal_ was not: a
15
15
  literal containing an accessor needs a real property descriptor per instance,
16
16
  which takes it off V8's fast object-literal construction path and slows the
17
17
  whole object, not just the accessor.
18
18
 
19
19
  Measured with `benchmarks/bench-profile-granular.ts`, three runs each:
20
20
 
21
- | shape | per call |
22
- | --- | --- |
23
- | object literal with `get agent()` | 1.106 / 1.433 / 1.147 µs |
21
+ | shape | per call |
22
+ | ----------------------------------- | ------------------------ |
23
+ | object literal with `get agent()` | 1.106 / 1.433 / 1.147 µs |
24
24
  | class with `agent` on the prototype | 0.523 / 0.461 / 0.525 µs |
25
25
 
26
26
  Roughly 2.4×, well outside the run-to-run variance, on a path every request
@@ -28,7 +28,7 @@ takes. On the same machine a full `fetchData` measures 12–19µs, so this was o
28
28
  the order of a tenth of a request spent constructing one object.
29
29
 
30
30
  The obvious alternative is worse. Making `agent` an eager property removes the
31
- accessor but builds those five closures unconditionally, and measured *slower*
31
+ accessor but builds those five closures unconditionally, and measured _slower_
32
32
  than the original at 1.967µs. A prototype accessor is the only shape that keeps
33
33
  the laziness and the fast construction path.
34
34
 
@@ -2,7 +2,7 @@
2
2
  type: decision
3
3
  title: A voice turn's transcript is sent before the run starts, on the raw channel
4
4
  description: The client does not know what it said, and an answer starts streaming within a few hundred milliseconds — a question arriving after its answer reads as the wrong question
5
- tags: core, ai-agent
5
+ tags: core, agent
6
6
  ---
7
7
 
8
8
  # A voice turn's transcript is sent ahead of the run
@@ -10,7 +10,7 @@ tags: core, ai-agent
10
10
  A voice client sends audio, so it does not know what it said. Until the
11
11
  transcript reaches it, its own message renders as a blank bubble.
12
12
 
13
- The event is sent *before* the run rather than alongside it because the answer
13
+ The event is sent _before_ the run rather than alongside it because the answer
14
14
  begins streaming within a few hundred milliseconds. Sent concurrently, the
15
15
  transcript routinely lands after the first tokens of its own answer — and a
16
16
  question that appears beneath its answer reads as a question about something
@@ -2,7 +2,7 @@
2
2
  type: decision
3
3
  title: Thread history records what the model was asked, which for a spoken turn is the transcript
4
4
  description: The wire carried a base64 audio blob; persisting it writes megabytes of unreadable data and loses the only readable record of the turn
5
- tags: core, ai-agent
5
+ tags: core, agent
6
6
  ---
7
7
 
8
8
  # Thread history records the transcript, not the audio that arrived
@@ -13,7 +13,7 @@ carried a base64 audio blob, and `voiceInput` replaced it with a transcript
13
13
  before the model ever saw it.
14
14
 
15
15
  Persisting the blob would write megabytes of unreadable data into the history
16
- *and* discard the only readable record of what was said — the worst of both.
16
+ _and_ discard the only readable record of what was said — the worst of both.
17
17
 
18
18
  Both the streaming and non-streaming paths do this, and both check identity
19
19
  rather than assuming: a middleware is free to rewrite the message list into
@@ -2,7 +2,7 @@
2
2
  type: decision
3
3
  title: Only an explicit `false` silences a spoken reply
4
4
  description: The key being absent means no voice input is wired and nothing reported either way, so those callers keep the behaviour they had before the option existed
5
- tags: core, ai-agent
5
+ tags: core, agent
6
6
  ---
7
7
 
8
8
  # Only an explicit `false` silences a spoken reply
@@ -2,16 +2,16 @@
2
2
  type: decision
3
3
  title: Only a Symbol-branded framework result can request tool approval
4
4
  description: Approval markers are trusted from the APPROVAL_REQUIRED Symbol on a forwardsApproval tool, never from a JSON key an LLM could emit
5
- tags: ai-agent
5
+ tags: agent
6
6
  ---
7
7
 
8
8
  # Only a Symbol-branded framework result can request tool approval
9
9
 
10
10
  `checkForApprovals` in
11
- `packages/core/src/wirings/ai-agent/ai-agent-stream.ts` honours a forwarded
11
+ `packages/core/src/wirings/agent/agent-stream.ts` honours a forwarded
12
12
  approval only when both hold: the tool declares `forwardsApproval` (set solely by
13
13
  framework code on the sub-agent delegating tools built in
14
- `ai-agent-prepare.ts`), and its result carries the `APPROVAL_REQUIRED` unique
14
+ `agent-prepare.ts`), and its result carries the `APPROVAL_REQUIRED` unique
15
15
  Symbol. The companion `__approvalRequired` string key exists for transport, but
16
16
  is never what the decision reads.
17
17
 
@@ -2,14 +2,14 @@
2
2
  type: decision
3
3
  title: Credential requests are trusted only when Symbol-branded
4
4
  description: The string key is a wire field; the Symbol is the capability, and only core can mint it
5
- tags: ai-agent
5
+ tags: agent
6
6
  ---
7
7
 
8
8
  # Credential requests are trusted only when Symbol-branded
9
9
 
10
10
  A tool result asking the run to suspend and prompt for a credential is honoured
11
11
  only when it carries the `CREDENTIAL_REQUIRED` Symbol minted in
12
- `ai-agent-prepare.ts`. `checkForCredentialRequests` in `ai-agent-stream.ts`
12
+ `agent-prepare.ts`. `checkForCredentialRequests` in `agent-stream.ts`
13
13
  tests for that Symbol, never for the `__credentialRequired` string key that
14
14
  travels beside it on the wire.
15
15
 
@@ -24,7 +24,7 @@ primitive inside the product's own UI. This mirrors the `APPROVAL_REQUIRED`
24
24
  brand, which exists for the identical reason one function over.
25
25
 
26
26
  The brand survives because the object is passed by reference the whole way —
27
- core's `buildToolDefs` wrapper returns it, the Vercel adapter's `aiTool` hands
27
+ core's `buildToolDefs` wrapper returns it, the Vercel adapter's `agentTool` hands
28
28
  it back verbatim, and the AI SDK puts the raw value on the stream part rather
29
29
  than the JSON form it builds separately for the model.
30
30
 
@@ -33,5 +33,5 @@ result` for convenience, or introducing any path where a credential request is
33
33
  reconstructed from parsed JSON rather than passed by reference — either one
34
34
  silently converts the gate into a formality. Note the inverse holds for the
35
35
  `credentialFilteredChannel` suppression later in the same file: that one
36
- deliberately matches the *string* key, because it hides tool results from the
36
+ deliberately matches the _string_ key, because it hides tool results from the
37
37
  client and a broader match leaks less, not more.
@@ -2,14 +2,14 @@
2
2
  type: decision
3
3
  title: An agent requires a session only when auth is true, but always enforces scopes and permissions
4
4
  description: Agents follow pikkuSessionlessFunc semantics so crons and queue workers can run them; scopes are an AND gate checked before any permission I/O
5
- tags: ai-agent
5
+ tags: agent
6
6
  ---
7
7
 
8
8
  # An agent requires a session only when auth is true, but always enforces scopes and permissions
9
9
 
10
10
  `assertAgentAuthorized` in
11
- `packages/core/src/wirings/ai-agent/ai-agent-prepare.ts` enforces, in order:
12
- session presence (only when `CoreAIAgent.auth === true`), then `scopes`, then
11
+ `packages/core/src/wirings/agent/agent-prepare.ts` enforces, in order:
12
+ session presence (only when `CoreAgent.auth === true`), then `scopes`, then
13
13
  `permissions`. The ordering mirrors the function runner — scopes AND together so
14
14
  they can only narrow access, and a missing scope short-circuits before any
15
15
  permission function does I/O. Declared `scopes` are narrowed to the generated
@@ -2,13 +2,13 @@
2
2
  type: decision
3
3
  title: An agent ownership failure never echoes the resource it refused
4
4
  description: assertResourceOwner throws a bare ForbiddenError so the error cannot be used as an existence oracle, at the cost of thinner debugging output
5
- tags: ai-agent
5
+ tags: agent
6
6
  ---
7
7
 
8
8
  # An agent ownership failure never echoes the resource it refused
9
9
 
10
10
  `assertResourceOwner` in
11
- `packages/core/src/wirings/ai-agent/ai-agent-prepare.ts` compares a stored
11
+ `packages/core/src/wirings/agent/agent-prepare.ts` compares a stored
12
12
  thread/run `resourceId` against the caller's composed owner key and throws
13
13
  `ForbiddenError('Not authorized to access this thread' | '… run')` on a
14
14
  mismatch. The message deliberately carries no id.
@@ -2,14 +2,14 @@
2
2
  type: decision
3
3
  title: Resuming a suspended agent run re-runs the agent's authorization gate
4
4
  description: Ownership of the run is not enough — a grant revoked while the run was suspended must block the approval
5
- tags: ai-agent
5
+ tags: agent
6
6
  ---
7
7
 
8
8
  # Resuming a suspended agent run re-runs the agent's authorization gate
9
9
 
10
- Both `resumeAIAgent` (`ai-agent-stream.ts`) and `resumeAIAgentSync`
11
- (`ai-agent-runner.ts`) call `assertAgentAuthorized` after asserting run
12
- ownership and before touching `aiRunState.resolveApproval`.
10
+ Both `resumeAgent` (`agent-stream.ts`) and `resumeAgentSync`
11
+ (`agent-runner.ts`) call `assertAgentAuthorized` after asserting run
12
+ ownership and before touching `agentRunState.resolveApproval`.
13
13
 
14
14
  Ownership proves the run belongs to the caller, not that the caller may still
15
15
  act on it: a suspension can outlive the permission that created it, and the whole