@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
@@ -0,0 +1,153 @@
1
+ import type { AgentStorageService } from '../../services/agent-storage-service.js';
2
+ /**
3
+ * Why an in-flight agent run was cut short.
4
+ *
5
+ * Deliberately carries no interjection text. A voice interruption is not a
6
+ * cancel button — it is the user starting to talk — but what they said arrives
7
+ * a second later as an ordinary next turn on the same thread, and that turn
8
+ * already has a working path through `streamAgent`. The model then sees its
9
+ * own truncated message (marked `interrupted`) followed by the interjection and
10
+ * decides for itself whether to resume, correct itself or drop the thread.
11
+ * Nothing here classifies the interjection; a second delivery path for the same
12
+ * text would only give the two ways to disagree about ordering.
13
+ */
14
+ export interface AgentInterruption {
15
+ /** `'speech'` — the user started talking over the agent (voice barge-in).
16
+ * `'user'` — an explicit stop (a button). `'timeout'` — a caller-side deadline. */
17
+ reason: 'speech' | 'user' | 'timeout';
18
+ }
19
+ /**
20
+ * Thrown out of the step loop when a run is interrupted, so an interruption is
21
+ * distinguishable from a genuine failure at the one `catch` that would
22
+ * otherwise mark the run `failed`.
23
+ */
24
+ export declare class AgentInterruptedError extends Error {
25
+ readonly runId: string;
26
+ readonly interruption: AgentInterruption;
27
+ constructor(runId: string, interruption: AgentInterruption);
28
+ }
29
+ /**
30
+ * A tool call that settled after its run was interrupted, so its result never
31
+ * reached the model.
32
+ *
33
+ * These are not failures, and they are only ever mutations. The tool ran, its
34
+ * side effect happened, and the only thing the interrupt cost was the reply
35
+ * describing it — so the result is worth mentioning on the next turn. Reads are
36
+ * excluded at the call site: nothing changed, so there is nothing to account
37
+ * for, and a stale answer is worse than re-reading.
38
+ */
39
+ export interface OrphanedToolResult {
40
+ toolCallId: string;
41
+ toolName: string;
42
+ result: unknown;
43
+ /** Set instead of `result` when the tool threw after the interrupt. */
44
+ error?: string;
45
+ }
46
+ /** What an authorized interrupt actually achieved. */
47
+ export interface AgentInterruptResult {
48
+ /**
49
+ * Whether a generating run was stopped. `false` is routine, not an error:
50
+ * racing a run that finishes on its own is the normal case in voice.
51
+ */
52
+ stopped: boolean;
53
+ /**
54
+ * Tools that were still executing when the interrupt landed. Their side
55
+ * effects have already happened and cannot be undone from here — this is for
56
+ * saying something true ("the deploy is still going"), not for offering to
57
+ * roll it back. Each will surface as an `undelivered` tool message on the
58
+ * thread once it settles.
59
+ */
60
+ inFlightTools: string[];
61
+ }
62
+ export interface InterruptibleRunHandle {
63
+ readonly signal: AbortSignal;
64
+ /** Set at the moment the run is interrupted; `undefined` on a clean run. */
65
+ readonly interruption: AgentInterruption | undefined;
66
+ /** Names of tools executing right now — what an interrupt would talk over. */
67
+ readonly inFlightTools: string[];
68
+ /**
69
+ * Wrap a tool execution so it survives an interrupt. Before the interrupt
70
+ * this is a pass-through; after one, the settled value is collected as an
71
+ * {@link OrphanedToolResult} rather than vanishing with the aborted stream.
72
+ */
73
+ trackTool<T>(toolName: string, toolCallId: string, exec: () => Promise<T>, opts?: {
74
+ collectResult?: boolean;
75
+ }): Promise<T>;
76
+ /**
77
+ * Resolves once every tool still running at the moment of the interrupt has
78
+ * settled, with the results the model never got to see.
79
+ *
80
+ * Deliberately not awaited before the stream closes: barge-in has to stop the
81
+ * agent talking immediately, and a tool holding that up for its own duration
82
+ * is the one thing voice cannot tolerate.
83
+ */
84
+ settle(timeoutMs?: number): Promise<OrphanedToolResult[]>;
85
+ release(): void;
86
+ }
87
+ /**
88
+ * Make a run interruptible for the duration of its stream. The returned signal
89
+ * is threaded into the model call, so an interrupt cancels the upstream HTTP
90
+ * request rather than merely stopping delivery of tokens we are still paying
91
+ * for.
92
+ */
93
+ export declare const registerInterruptibleRun: (runId: string) => InterruptibleRunHandle;
94
+ /**
95
+ * Stop a run that is generating right now.
96
+ *
97
+ * Plumbing: this performs NO authorization, so anyone holding a runId can stop
98
+ * it. Reach for {@link interruptAgent} instead unless the caller has already
99
+ * established that the run belongs to the session — which in practice means
100
+ * only the runner itself and code already inside an authorized run.
101
+ *
102
+ * Returns `false` when the run is not in flight in this process — already
103
+ * finished, never started, or running elsewhere — which callers should treat as
104
+ * "nothing to interrupt", not as an error: racing a run that finishes on its own
105
+ * is the normal case in voice.
106
+ */
107
+ export declare const signalRunInterrupt: (runId: string, interruption?: AgentInterruption) => boolean;
108
+ /** Whether a run is currently interruptible in this process. */
109
+ export declare const isRunInterruptible: (runId: string) => boolean;
110
+ /**
111
+ * Tools executing in a run right now. Empty for a run that is merely
112
+ * generating, or one this process does not hold.
113
+ *
114
+ * Callers use this to say something true about work that outlives the reply —
115
+ * "that deploy is still going" — rather than to offer to stop it. By the time a
116
+ * tool is executing its side effect has already happened, and pikku functions
117
+ * receive no abort signal, so there is nothing left to cancel.
118
+ */
119
+ export declare const getInFlightTools: (runId: string) => string[];
120
+ /**
121
+ * Wrap tool definitions so their results survive an interrupt.
122
+ *
123
+ * Applied by the runner after the handle exists rather than in `buildToolDefs`,
124
+ * which builds tools before there is a runId to attach them to.
125
+ */
126
+ export declare const trackToolExecution: <T extends {
127
+ name: string;
128
+ readonly?: boolean;
129
+ execute: (input: any) => Promise<any>;
130
+ }>(tools: T[], handle: InterruptibleRunHandle) => T[];
131
+ export declare const trackInterruptNote: (threadId: string, write: Promise<void>) => void;
132
+ /** Await an interrupted tool result still being written to this thread. */
133
+ export declare const awaitPendingInterruptNote: (threadId: string) => Promise<void>;
134
+ /**
135
+ * Write the results of tools that were still running when a run was cut off.
136
+ *
137
+ * Saved as an ordinary tool message so it reaches the model through the same
138
+ * context load as everything else — there is no separate "notes" channel to
139
+ * keep in sync, and storage that drops the `undelivered` flag still keeps the
140
+ * result itself.
141
+ *
142
+ * Callers should hand this to {@link trackInterruptNote} rather than awaiting
143
+ * it: an interrupt has to end the reply immediately, and a slow tool must not
144
+ * hold that up.
145
+ */
146
+ export declare const persistOrphanedToolResults: (handle: InterruptibleRunHandle, storage: AgentStorageService, threadId: string) => Promise<void>;
147
+ /**
148
+ * Whether a thrown value is an abort rather than a failure. The AI SDK
149
+ * surfaces cancellation as a DOMException/Error named `AbortError`, so the
150
+ * name is the only portable signal — there is no shared error class to
151
+ * `instanceof` against across fetch, undici and the provider SDKs.
152
+ */
153
+ export declare const isAbortError: (err: unknown) => boolean;
@@ -0,0 +1,257 @@
1
+ import { randomUUID } from './agent-utils.js';
2
+ import { AbandonedError, runInAbortScope, } from '../../function/abort-scope.js';
3
+ /**
4
+ * Thrown out of the step loop when a run is interrupted, so an interruption is
5
+ * distinguishable from a genuine failure at the one `catch` that would
6
+ * otherwise mark the run `failed`.
7
+ */
8
+ export class AgentInterruptedError extends Error {
9
+ runId;
10
+ interruption;
11
+ constructor(runId, interruption) {
12
+ super(`Agent run ${runId} interrupted (${interruption.reason})`);
13
+ this.runId = runId;
14
+ this.interruption = interruption;
15
+ this.name = 'AgentInterruptedError';
16
+ }
17
+ }
18
+ /**
19
+ * Live runs, keyed by runId.
20
+ *
21
+ * Module-level rather than `pikkuState` because the value is an
22
+ * `AbortController` — a process-local object that cannot be serialised or
23
+ * shared. That is also this registry's limit: an interrupt only reaches a run
24
+ * executing in the same process. Single-process and channel-attached callers
25
+ * (where the interrupt arrives on the socket already carrying the run) are
26
+ * covered; a horizontally-scaled deployment interrupting over a *separate* HTTP
27
+ * request needs the interrupt fanned out over `eventHub` to every instance
28
+ * first, with each instance calling `signalRunInterrupt` locally.
29
+ */
30
+ const runs = new Map();
31
+ /**
32
+ * Make a run interruptible for the duration of its stream. The returned signal
33
+ * is threaded into the model call, so an interrupt cancels the upstream HTTP
34
+ * request rather than merely stopping delivery of tokens we are still paying
35
+ * for.
36
+ */
37
+ export const registerInterruptibleRun = (runId) => {
38
+ const entry = {
39
+ controller: new AbortController(),
40
+ inFlight: new Map(),
41
+ orphaned: [],
42
+ pending: new Set(),
43
+ };
44
+ runs.set(runId, entry);
45
+ return {
46
+ signal: entry.controller.signal,
47
+ get interruption() {
48
+ return entry.interruption;
49
+ },
50
+ get inFlightTools() {
51
+ return [...entry.inFlight.values()];
52
+ },
53
+ trackTool: async (toolName, toolCallId, exec, opts) => {
54
+ entry.inFlight.set(toolCallId, toolName);
55
+ const call = exec();
56
+ // Tracked separately from the returned promise so an interrupt can wait
57
+ // on the tool without the caller's rejection becoming an unhandled one.
58
+ const tracked = call.then((result) => {
59
+ entry.inFlight.delete(toolCallId);
60
+ // Read now rather than at call time: a tool that uses
61
+ // `beginChanges()` only reveals partway through whether it mutated.
62
+ if ((opts?.collectResult ?? true) &&
63
+ entry.controller.signal.aborted) {
64
+ entry.orphaned.push({ toolCallId, toolName, result });
65
+ }
66
+ }, (err) => {
67
+ entry.inFlight.delete(toolCallId);
68
+ // A tool that stopped *at* its own checkpoint changed nothing by
69
+ // construction, so it never files a note — reporting "it aborted"
70
+ // is exactly the noise `beginChanges()` exists to remove.
71
+ if (err instanceof AbandonedError)
72
+ return;
73
+ if ((opts?.collectResult ?? true) &&
74
+ entry.controller.signal.aborted) {
75
+ entry.orphaned.push({
76
+ toolCallId,
77
+ toolName,
78
+ result: undefined,
79
+ error: err instanceof Error ? err.message : String(err),
80
+ });
81
+ }
82
+ });
83
+ entry.pending.add(tracked);
84
+ void tracked.finally(() => entry.pending.delete(tracked));
85
+ return call;
86
+ },
87
+ settle: async (timeoutMs = 30_000) => {
88
+ if (entry.pending.size > 0) {
89
+ // A tool that never settles must not strand the note forever; whatever
90
+ // has landed by the deadline is what gets reported.
91
+ let timer;
92
+ await Promise.race([
93
+ Promise.all([...entry.pending]),
94
+ new Promise((resolve) => {
95
+ timer = setTimeout(resolve, timeoutMs);
96
+ }),
97
+ ]);
98
+ if (timer)
99
+ clearTimeout(timer);
100
+ }
101
+ return entry.orphaned;
102
+ },
103
+ release: () => {
104
+ if (runs.get(runId) === entry)
105
+ runs.delete(runId);
106
+ },
107
+ };
108
+ };
109
+ /**
110
+ * Stop a run that is generating right now.
111
+ *
112
+ * Plumbing: this performs NO authorization, so anyone holding a runId can stop
113
+ * it. Reach for {@link interruptAgent} instead unless the caller has already
114
+ * established that the run belongs to the session — which in practice means
115
+ * only the runner itself and code already inside an authorized run.
116
+ *
117
+ * Returns `false` when the run is not in flight in this process — already
118
+ * finished, never started, or running elsewhere — which callers should treat as
119
+ * "nothing to interrupt", not as an error: racing a run that finishes on its own
120
+ * is the normal case in voice.
121
+ */
122
+ export const signalRunInterrupt = (runId, interruption = { reason: 'user' }) => {
123
+ const entry = runs.get(runId);
124
+ if (!entry || entry.controller.signal.aborted)
125
+ return false;
126
+ entry.interruption = interruption;
127
+ entry.controller.abort();
128
+ return true;
129
+ };
130
+ /** Whether a run is currently interruptible in this process. */
131
+ export const isRunInterruptible = (runId) => runs.has(runId);
132
+ /**
133
+ * Tools executing in a run right now. Empty for a run that is merely
134
+ * generating, or one this process does not hold.
135
+ *
136
+ * Callers use this to say something true about work that outlives the reply —
137
+ * "that deploy is still going" — rather than to offer to stop it. By the time a
138
+ * tool is executing its side effect has already happened, and pikku functions
139
+ * receive no abort signal, so there is nothing left to cancel.
140
+ */
141
+ export const getInFlightTools = (runId) => {
142
+ const entry = runs.get(runId);
143
+ return entry ? [...entry.inFlight.values()] : [];
144
+ };
145
+ /**
146
+ * Wrap tool definitions so their results survive an interrupt.
147
+ *
148
+ * Applied by the runner after the handle exists rather than in `buildToolDefs`,
149
+ * which builds tools before there is a runId to attach them to.
150
+ */
151
+ export const trackToolExecution = (tools, handle) => tools.map((tool) => {
152
+ // Reads run outside the scope entirely: they never produce a note and have
153
+ // nothing to declare, so `beginChanges()` inside one is a no-op rather than
154
+ // a contradiction to resolve.
155
+ if (tool.readonly) {
156
+ return {
157
+ ...tool,
158
+ execute: (input) => handle.trackTool(tool.name, randomUUID(), () => tool.execute(input), {
159
+ collectResult: false,
160
+ }),
161
+ };
162
+ }
163
+ return {
164
+ ...tool,
165
+ execute: (input) => {
166
+ // Assumed to have changed something unless it says otherwise — the tool
167
+ // that never declares its checkpoint is the one that cannot be assumed
168
+ // harmless. `beginChanges()` can only ever make this more precise.
169
+ const call = { mutating: true };
170
+ const scope = {
171
+ get abandoned() {
172
+ return handle.signal.aborted;
173
+ },
174
+ get reason() {
175
+ return handle.interruption?.reason;
176
+ },
177
+ onBeginChanges: () => {
178
+ call.mutating = true;
179
+ },
180
+ };
181
+ return handle.trackTool(tool.name, randomUUID(), () => runInAbortScope(scope, () => tool.execute(input)), {
182
+ get collectResult() {
183
+ return call.mutating;
184
+ },
185
+ });
186
+ },
187
+ };
188
+ });
189
+ /**
190
+ * Threads with an interrupted tool call still settling.
191
+ *
192
+ * The note describing that result has to be in the thread before the turn that
193
+ * ought to mention it loads its context, and the user's next sentence usually
194
+ * arrives well inside a slow tool. Runs await this for their own thread first,
195
+ * so the ordering holds without the interrupt itself blocking on anything.
196
+ */
197
+ const pendingNotes = new Map();
198
+ export const trackInterruptNote = (threadId, write) => {
199
+ const done = write.finally(() => {
200
+ if (pendingNotes.get(threadId) === done)
201
+ pendingNotes.delete(threadId);
202
+ });
203
+ pendingNotes.set(threadId, done);
204
+ };
205
+ /** Await an interrupted tool result still being written to this thread. */
206
+ export const awaitPendingInterruptNote = async (threadId) => {
207
+ await pendingNotes.get(threadId);
208
+ };
209
+ /**
210
+ * Write the results of tools that were still running when a run was cut off.
211
+ *
212
+ * Saved as an ordinary tool message so it reaches the model through the same
213
+ * context load as everything else — there is no separate "notes" channel to
214
+ * keep in sync, and storage that drops the `undelivered` flag still keeps the
215
+ * result itself.
216
+ *
217
+ * Callers should hand this to {@link trackInterruptNote} rather than awaiting
218
+ * it: an interrupt has to end the reply immediately, and a slow tool must not
219
+ * hold that up.
220
+ */
221
+ export const persistOrphanedToolResults = async (handle, storage, threadId) => {
222
+ let orphaned;
223
+ try {
224
+ orphaned = await handle.settle();
225
+ }
226
+ finally {
227
+ handle.release();
228
+ }
229
+ if (orphaned.length === 0)
230
+ return;
231
+ await storage.saveMessages(threadId, [
232
+ {
233
+ id: randomUUID(),
234
+ role: 'tool',
235
+ toolResults: orphaned.map((entry) => ({
236
+ id: entry.toolCallId,
237
+ name: entry.toolName,
238
+ result: entry.error
239
+ ? `Error: ${entry.error}`
240
+ : typeof entry.result === 'string'
241
+ ? entry.result
242
+ : JSON.stringify(entry.result),
243
+ ...(entry.error ? { error: entry.error } : {}),
244
+ })),
245
+ undelivered: true,
246
+ createdAt: new Date(),
247
+ },
248
+ ]);
249
+ };
250
+ /**
251
+ * Whether a thrown value is an abort rather than a failure. The AI SDK
252
+ * surfaces cancellation as a DOMException/Error named `AbortError`, so the
253
+ * name is the only portable signal — there is no shared error class to
254
+ * `instanceof` against across fetch, undici and the provider SDKs.
255
+ */
256
+ export const isAbortError = (err) => err instanceof Error &&
257
+ (err.name === 'AbortError' || err.name === 'TimeoutError');
@@ -0,0 +1,42 @@
1
+ import type { CoreSingletonServices } from '../../types/core.types.js';
2
+ import type { CoreAgent, AgentMemoryConfig, AgentInput, AgentStep, AgentMessage } from './agent.types.js';
3
+ import type { AgentStorageService } from '../../services/agent-storage-service.js';
4
+ import type { Logger } from '../../services/logger.js';
5
+ import type { SchemaService } from '../../services/schema-service.js';
6
+ import type { PikkuAgentMiddlewareHooks } from './agent.types.js';
7
+ export declare function resolveMemoryServices(agent: CoreAgent, singletonServices: CoreSingletonServices): {
8
+ storage: AgentStorageService | undefined;
9
+ };
10
+ export declare function isWorkingMemoryEnabled(memoryConfig: AgentMemoryConfig | undefined, storage: AgentStorageService | undefined): boolean;
11
+ export declare function deepMergeWorkingMemory(existing: Record<string, unknown>, updates: Record<string, unknown>): Record<string, unknown>;
12
+ export declare function buildWorkingMemoryPrompt(currentState: Record<string, unknown> | null, jsonSchema?: Record<string, unknown>): string;
13
+ export declare function loadContextMessages(memoryConfig: AgentMemoryConfig | undefined, storage: AgentStorageService | undefined, input: AgentInput, workingMemoryJsonSchema?: Record<string, unknown>): Promise<AgentMessage[]>;
14
+ export declare function saveMessages(storage: AgentStorageService | undefined, threadId: string, resourceId: string, memoryConfig: AgentMemoryConfig | undefined, userMessage: AgentMessage | null | undefined, result: {
15
+ text: string;
16
+ uiSpec?: unknown;
17
+ steps: Pick<AgentStep, 'toolCalls'>[];
18
+ }): Promise<string>;
19
+ export declare function trimMessages(messages: AgentMessage[], maxTokenBudget?: number): AgentMessage[];
20
+ export declare function parseWorkingMemory(text: string): Record<string, unknown> | null;
21
+ export declare function stripWorkingMemoryTags(text: string): string;
22
+ export declare function extractWorkingMemory(text: string): {
23
+ workingMemory: Record<string, unknown> | null;
24
+ cleanedText: string;
25
+ };
26
+ export declare function stripWorkingMemoryForStreaming(text: string): string;
27
+ export declare function createWorkingMemoryMiddleware(options: {
28
+ storage?: AgentStorageService;
29
+ threadId: string;
30
+ workingMemorySchemaName?: string | null;
31
+ logger?: Logger;
32
+ schemaService?: SchemaService;
33
+ }): PikkuAgentMiddlewareHooks<{
34
+ rawText?: string;
35
+ emittedVisibleText?: string;
36
+ }>;
37
+ export declare function getWorkingMemoryMiddleware(memoryConfig: AgentMemoryConfig | undefined, storage: AgentStorageService | undefined, options: {
38
+ threadId: string;
39
+ workingMemorySchemaName?: string | null;
40
+ logger?: Logger;
41
+ schemaService?: SchemaService;
42
+ }): PikkuAgentMiddlewareHooks[];