experimental-a2 0.19.0 → 0.21.1

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 (320) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/README.md +1 -1
  3. package/dist/{actor-C7b-1arn.d.ts → actor-HnGmrOZZ.d.ts} +5 -5
  4. package/dist/{actor-C7b-1arn.d.ts.map → actor-HnGmrOZZ.d.ts.map} +1 -1
  5. package/dist/actor-client.d.ts +1 -1
  6. package/dist/actor-client.js +2 -2
  7. package/dist/actor-react.d.ts +3 -3
  8. package/dist/actor-react.js +5 -5
  9. package/dist/{actor-shared-t7w8xIKP.js → actor-shared-DFET5q16.js} +3 -3
  10. package/dist/{actor-shared-t7w8xIKP.js.map → actor-shared-DFET5q16.js.map} +1 -1
  11. package/dist/actor.d.ts +1 -1
  12. package/dist/actor.js +54 -43
  13. package/dist/actor.js.map +1 -1
  14. package/dist/{ai-Cz3hqVhk.d.ts → ai-CvEnqVfo.d.ts} +8 -8
  15. package/dist/{ai-Cz3hqVhk.d.ts.map → ai-CvEnqVfo.d.ts.map} +1 -1
  16. package/dist/{ai-mMiWul1T.js → ai-CzE672Q3.js} +9 -9
  17. package/dist/ai-CzE672Q3.js.map +1 -0
  18. package/dist/ai-client.d.ts +2 -2
  19. package/dist/ai-client.js +2 -2
  20. package/dist/ai-fx.d.ts +1 -1
  21. package/dist/ai-fx.d.ts.map +1 -1
  22. package/dist/ai-fx.js +36 -9
  23. package/dist/ai-fx.js.map +1 -1
  24. package/dist/{ai-harness-CV6rXbB3.d.ts → ai-harness-Bfk-Lycn.d.ts} +2 -2
  25. package/dist/ai-harness-Bfk-Lycn.d.ts.map +1 -0
  26. package/dist/{ai-harness-BuuC-gJ3.js → ai-harness-dQeJaR1t.js} +17 -4
  27. package/dist/ai-harness-dQeJaR1t.js.map +1 -0
  28. package/dist/ai-pi.d.ts +1 -1
  29. package/dist/ai-pi.js +4 -4
  30. package/dist/ai-pi.js.map +1 -1
  31. package/dist/ai-react.d.ts +5 -5
  32. package/dist/ai-react.js +2 -2
  33. package/dist/ai-server.d.ts +14 -17
  34. package/dist/ai-server.d.ts.map +1 -1
  35. package/dist/ai-server.js +84 -75
  36. package/dist/ai-server.js.map +1 -1
  37. package/dist/ai.d.ts +2 -2
  38. package/dist/ai.js +2 -2
  39. package/dist/{client-BhHLoNKF.js → client-9IeTsiAs.js} +5 -5
  40. package/dist/{client-BhHLoNKF.js.map → client-9IeTsiAs.js.map} +1 -1
  41. package/dist/{client-h_DKFAjj.d.ts → client-CUMbS_38.d.ts} +3 -3
  42. package/dist/{client-h_DKFAjj.d.ts.map → client-CUMbS_38.d.ts.map} +1 -1
  43. package/dist/client.d.ts +3 -3
  44. package/dist/client.js +1 -1
  45. package/dist/{contract-BYKASlCV.js → contract-CWukt01d.js} +2 -2
  46. package/dist/contract-CWukt01d.js.map +1 -0
  47. package/dist/index.d.ts +5 -5
  48. package/dist/index.js +3 -3
  49. package/dist/{initial-snapshot-Bx-c0pDP.d.ts → initial-snapshot-D3Lve43o.d.ts} +4 -4
  50. package/dist/initial-snapshot-D3Lve43o.d.ts.map +1 -0
  51. package/dist/{internal-CscSY7K_.js → internal-Bc4PvfHk.js} +10 -3
  52. package/dist/internal-Bc4PvfHk.js.map +1 -0
  53. package/dist/otel.d.ts +1 -1
  54. package/dist/otel.js +1 -1
  55. package/dist/otel.js.map +1 -1
  56. package/dist/{react-BBXgHWFc.d.ts → react-BoHvC3v9.d.ts} +4 -4
  57. package/dist/{react-BBXgHWFc.d.ts.map → react-BoHvC3v9.d.ts.map} +1 -1
  58. package/dist/react.d.ts +1 -1
  59. package/dist/react.js +1 -1
  60. package/dist/{reducer-CqA59Q6U.d.ts → reducer-CYPHsSmd.d.ts} +2 -2
  61. package/dist/{reducer-CqA59Q6U.d.ts.map → reducer-CYPHsSmd.d.ts.map} +1 -1
  62. package/dist/{reducer-BAXc8JyF.js → reducer-CjmvZSAb.js} +2 -2
  63. package/dist/{reducer-BAXc8JyF.js.map → reducer-CjmvZSAb.js.map} +1 -1
  64. package/dist/runtime-consumer-BWmht60z.js +12 -0
  65. package/dist/runtime-consumer-BWmht60z.js.map +1 -0
  66. package/dist/scheduler-qstash.d.ts +2 -2
  67. package/dist/scheduler-qstash.d.ts.map +1 -1
  68. package/dist/scheduler-qstash.js +7 -7
  69. package/dist/scheduler-qstash.js.map +1 -1
  70. package/dist/scheduler-task-X1SToDjP.js.map +1 -1
  71. package/dist/scheduler-vercel.d.ts +2 -2
  72. package/dist/scheduler-vercel.d.ts.map +1 -1
  73. package/dist/scheduler-vercel.js +5 -4
  74. package/dist/scheduler-vercel.js.map +1 -1
  75. package/dist/{server-DYAATFuT.d.ts → server-BshFZ0eL.d.ts} +108 -41
  76. package/dist/server-BshFZ0eL.d.ts.map +1 -0
  77. package/dist/{server-D-Y4pqwu.js → server-DvIB8kj5.js} +423 -135
  78. package/dist/server-DvIB8kj5.js.map +1 -0
  79. package/dist/server.browser.js +1 -1
  80. package/dist/server.browser.js.map +1 -1
  81. package/dist/server.d.ts +4 -4
  82. package/dist/server.js +2 -2
  83. package/dist/{session-clear-C-QwTXV1.d.ts → session-clear-Bk_29eEw.d.ts} +2 -2
  84. package/dist/session-clear-Bk_29eEw.d.ts.map +1 -0
  85. package/dist/{session-clear-DGI4jTQ5.js → session-clear-wHd5GCpZ.js} +5 -4
  86. package/dist/session-clear-wHd5GCpZ.js.map +1 -0
  87. package/dist/store-N8PXxDAS.js.map +1 -1
  88. package/dist/store-Z2qjw50n.d.ts +523 -0
  89. package/dist/store-Z2qjw50n.d.ts.map +1 -0
  90. package/dist/store-codec-DwrWlgQx.js +65 -0
  91. package/dist/store-codec-DwrWlgQx.js.map +1 -0
  92. package/dist/store-memory.d.ts +1 -1
  93. package/dist/store-memory.d.ts.map +1 -1
  94. package/dist/store-memory.js +393 -210
  95. package/dist/store-memory.js.map +1 -1
  96. package/dist/{store-polling-7WJV0YWP.js → store-polling-DYNyxCev.js} +2 -2
  97. package/dist/{store-polling-7WJV0YWP.js.map → store-polling-DYNyxCev.js.map} +1 -1
  98. package/dist/store-postgres.d.ts +1 -1
  99. package/dist/store-postgres.d.ts.map +1 -1
  100. package/dist/store-postgres.js +1595 -673
  101. package/dist/store-postgres.js.map +1 -1
  102. package/dist/{store-presence-polling-B1ixeqIS.js → store-presence-polling-CzQ0wdtM.js} +3 -3
  103. package/dist/{store-presence-polling-B1ixeqIS.js.map → store-presence-polling-CzQ0wdtM.js.map} +1 -1
  104. package/dist/store-redis-http.d.ts +1 -1
  105. package/dist/store-redis-http.js +4 -4
  106. package/dist/store-redis-notify-IiVdlYHc.js +2919 -0
  107. package/dist/store-redis-notify-IiVdlYHc.js.map +1 -0
  108. package/dist/store-redis.d.ts +1 -1
  109. package/dist/store-redis.js +2 -2
  110. package/dist/store-sqlite.d.ts +1 -1
  111. package/dist/store-sqlite.d.ts.map +1 -1
  112. package/dist/store-sqlite.js +517 -287
  113. package/dist/store-sqlite.js.map +1 -1
  114. package/dist/{telemetry-Cyfqo6Qt.d.ts → telemetry-CWwsh-Gx.d.ts} +3 -3
  115. package/dist/telemetry-CWwsh-Gx.d.ts.map +1 -0
  116. package/dist/{wire-BKxH1vbP.js → wire-CZGqNZRx.js} +5 -4
  117. package/dist/wire-CZGqNZRx.js.map +1 -0
  118. package/docs/01-quickstart.mdx +28 -19
  119. package/docs/02-examples.mdx +1 -1
  120. package/docs/actors/01-introduction.mdx +9 -1
  121. package/docs/actors/02-concurrency.mdx +1 -1
  122. package/docs/actors/meta.ts +1 -1
  123. package/docs/agents/01-introduction.mdx +1 -1
  124. package/docs/agents/02-tools.mdx +13 -12
  125. package/docs/agents/03-conversations.mdx +31 -21
  126. package/docs/agents/04-harnesses.mdx +7 -3
  127. package/docs/agents/meta.ts +1 -1
  128. package/docs/client/03-presence.mdx +18 -14
  129. package/docs/client/meta.ts +1 -1
  130. package/docs/contract/01-events.mdx +2 -2
  131. package/docs/contract/02-state.mdx +18 -14
  132. package/docs/contract/03-sessions.mdx +32 -25
  133. package/docs/index.mdx +31 -26
  134. package/docs/reference/01-core.mdx +12 -12
  135. package/docs/reference/02-server.mdx +247 -192
  136. package/docs/reference/04-ai.mdx +29 -20
  137. package/docs/reference/05-telemetry.mdx +146 -0
  138. package/docs/reference/06-errors.mdx +24 -18
  139. package/docs/reference/meta.ts +1 -1
  140. package/docs/schedulers/01-overview.mdx +112 -0
  141. package/docs/schedulers/02-vercel-queues.mdx +87 -0
  142. package/docs/schedulers/03-qstash.mdx +123 -0
  143. package/docs/schedulers/meta.ts +1 -0
  144. package/docs/server/01-consumers.mdx +415 -0
  145. package/docs/server/02-timers.mdx +33 -23
  146. package/docs/server/03-cancellation.mdx +52 -44
  147. package/docs/server/04-routes.mdx +4 -1
  148. package/docs/server/05-sql-projections.mdx +391 -0
  149. package/docs/server/06-guarantees.mdx +60 -50
  150. package/docs/stores/01-overview.mdx +37 -0
  151. package/docs/stores/02-redis.mdx +57 -0
  152. package/docs/stores/03-redis-http.mdx +56 -0
  153. package/docs/stores/04-postgres.mdx +172 -0
  154. package/docs/stores/05-sqlite.mdx +36 -0
  155. package/docs/stores/06-memory.mdx +22 -0
  156. package/docs/stores/meta.ts +1 -0
  157. package/docs/upgrades/01-overview.mdx +30 -0
  158. package/docs/upgrades/79-0-21.mdx +165 -0
  159. package/docs/upgrades/80-0-20.mdx +43 -0
  160. package/docs/upgrades/81-0-19.mdx +33 -0
  161. package/docs/upgrades/82-0-18.mdx +33 -0
  162. package/docs/upgrades/83-0-17.mdx +69 -0
  163. package/docs/upgrades/meta.ts +3 -0
  164. package/examples/playground/DEPLOY.md +48 -11
  165. package/examples/playground/app/a0/apps/[appId]/route.ts +6 -10
  166. package/examples/playground/app/a0/chat.test.tsx +421 -330
  167. package/examples/playground/app/a0/sandbox-log.ts +17 -15
  168. package/examples/playground/app/a0/server.ts +4 -4
  169. package/examples/playground/app/a0/shell.tsx +1 -1
  170. package/examples/playground/app/a0/uploads/route.test.ts +59 -0
  171. package/examples/playground/app/a2slack/a2slack.css +1067 -0
  172. package/examples/playground/app/a2slack/c/[channel]/page.tsx +20 -0
  173. package/examples/playground/app/a2slack/consumers/agent.ts +63 -0
  174. package/examples/playground/app/a2slack/consumers/feed.ts +164 -0
  175. package/examples/playground/app/a2slack/consumers/notify.ts +116 -0
  176. package/examples/playground/app/a2slack/consumers/search.ts +37 -0
  177. package/examples/playground/app/a2slack/consumers/triage.ts +31 -0
  178. package/examples/playground/app/a2slack/consumers/welcome.ts +25 -0
  179. package/examples/playground/app/a2slack/db/a2.ts +206 -0
  180. package/examples/playground/app/a2slack/db/index.ts +73 -0
  181. package/examples/playground/app/a2slack/db/migrations/0000_extensions.sql +4 -0
  182. package/examples/playground/app/a2slack/db/migrations/0001_workspace.sql +74 -0
  183. package/examples/playground/app/a2slack/db/migrations/0002_a2.sql +215 -0
  184. package/examples/playground/app/a2slack/db/migrations/0003_a2_batch.sql +67 -0
  185. package/examples/playground/app/a2slack/db/migrations/meta/0000_snapshot.json +18 -0
  186. package/examples/playground/app/a2slack/db/migrations/meta/0001_snapshot.json +500 -0
  187. package/examples/playground/app/a2slack/db/migrations/meta/0002_snapshot.json +1159 -0
  188. package/examples/playground/app/a2slack/db/migrations/meta/0003_snapshot.json +1159 -0
  189. package/examples/playground/app/a2slack/db/migrations/meta/_journal.json +34 -0
  190. package/examples/playground/app/a2slack/db/queries.ts +263 -0
  191. package/examples/playground/app/a2slack/db/schema.ts +145 -0
  192. package/examples/playground/app/a2slack/drills/a2slack.drill.ts +708 -0
  193. package/examples/playground/app/a2slack/drills/harness.ts +244 -0
  194. package/examples/playground/app/a2slack/events/route.ts +36 -0
  195. package/examples/playground/app/a2slack/identity.ts +44 -0
  196. package/examples/playground/app/a2slack/inbox/route.ts +8 -0
  197. package/examples/playground/app/a2slack/lag/data/route.ts +8 -0
  198. package/examples/playground/app/a2slack/lag/page.tsx +101 -0
  199. package/examples/playground/app/a2slack/lag.ts +73 -0
  200. package/examples/playground/app/a2slack/layout.tsx +43 -0
  201. package/examples/playground/app/a2slack/messages/route.ts +17 -0
  202. package/examples/playground/app/a2slack/model.test.ts +208 -0
  203. package/examples/playground/app/a2slack/model.ts +369 -0
  204. package/examples/playground/app/a2slack/models.test.ts +72 -0
  205. package/examples/playground/app/a2slack/page.tsx +10 -0
  206. package/examples/playground/app/a2slack/scheduler/route.ts +5 -0
  207. package/examples/playground/app/a2slack/search/route.ts +40 -0
  208. package/examples/playground/app/a2slack/search-index.ts +108 -0
  209. package/examples/playground/app/a2slack/server.test.ts +315 -0
  210. package/examples/playground/app/a2slack/server.ts +55 -0
  211. package/examples/playground/app/a2slack/sessions.ts +50 -0
  212. package/examples/playground/app/a2slack/thread/route.ts +8 -0
  213. package/examples/playground/app/a2slack/ui/ChannelView.tsx +87 -0
  214. package/examples/playground/app/a2slack/ui/Composer.tsx +117 -0
  215. package/examples/playground/app/a2slack/ui/DotsShadow.tsx +42 -0
  216. package/examples/playground/app/a2slack/ui/Feed.tsx +157 -0
  217. package/examples/playground/app/a2slack/ui/InboxContext.tsx +63 -0
  218. package/examples/playground/app/a2slack/ui/InboxView.tsx +82 -0
  219. package/examples/playground/app/a2slack/ui/Menu.tsx +128 -0
  220. package/examples/playground/app/a2slack/ui/MessageRow.tsx +314 -0
  221. package/examples/playground/app/a2slack/ui/NameGate.tsx +35 -0
  222. package/examples/playground/app/a2slack/ui/SearchContext.tsx +146 -0
  223. package/examples/playground/app/a2slack/ui/SearchResults.tsx +97 -0
  224. package/examples/playground/app/a2slack/ui/Shell.tsx +34 -0
  225. package/examples/playground/app/a2slack/ui/Sidebar.tsx +199 -0
  226. package/examples/playground/app/a2slack/ui/ThreadPanel.tsx +134 -0
  227. package/examples/playground/app/a2slack/ui/useInbox.ts +71 -0
  228. package/examples/playground/app/agent/[agentId]/agent-queue.test.tsx +116 -90
  229. package/examples/playground/app/agent/[agentId]/compaction-panel.test.tsx +107 -76
  230. package/examples/playground/app/agent/ingress.test.ts +41 -17
  231. package/examples/playground/app/agent/model-input.test.tsx +92 -43
  232. package/examples/playground/app/agent/server.ts +3 -3
  233. package/examples/playground/app/chat/[chatId]/agent-stream-drawer.test.tsx +2 -2
  234. package/examples/playground/app/chat/[chatId]/chat-client.tsx +1 -1
  235. package/examples/playground/app/chat/server.test.ts +38 -65
  236. package/examples/playground/app/chat/server.ts +45 -35
  237. package/examples/playground/app/components/activity-history.test.tsx +60 -18
  238. package/examples/playground/app/components/demo-icons.tsx +7 -0
  239. package/examples/playground/app/components/demos.tsx +7 -0
  240. package/examples/playground/app/components/fast-link.test.tsx +3 -5
  241. package/examples/playground/app/initial-state.test.tsx +86 -45
  242. package/examples/playground/app/orders/[orderId]/order-client.tsx +2 -2
  243. package/examples/playground/app/orders/page.tsx +1 -1
  244. package/examples/playground/app/orders/server.ts +49 -30
  245. package/examples/playground/app/recovery/[recoveryId]/recovery-client.tsx +14 -15
  246. package/examples/playground/app/recovery/page.tsx +4 -4
  247. package/examples/playground/app/recovery/server.ts +23 -32
  248. package/examples/playground/drizzle.config.ts +14 -0
  249. package/examples/playground/next.config.ts +6 -1
  250. package/examples/playground/package.json +13 -1
  251. package/examples/playground/scripts/migrate.mjs +31 -0
  252. package/examples/playground/test/agent.ts +35 -0
  253. package/examples/playground/test/model.ts +149 -0
  254. package/examples/playground/test/serve.ts +184 -0
  255. package/examples/playground/test/server-only.ts +1 -0
  256. package/examples/playground/vercel.json +9 -0
  257. package/examples/playground/vitest.config.ts +27 -0
  258. package/examples/playground/vitest.drills.config.ts +32 -0
  259. package/package.json +7 -2
  260. package/sql/postgres/drizzle-schema.ts +206 -0
  261. package/sql/postgres/notifications.sql +24 -0
  262. package/sql/postgres/schema.sql +276 -0
  263. package/src/actor.ts +101 -71
  264. package/src/ai-agent.ts +154 -115
  265. package/src/ai-control-server.ts +8 -8
  266. package/src/ai-fx.ts +41 -9
  267. package/src/ai-harness.ts +28 -2
  268. package/src/ai-pi.ts +2 -2
  269. package/src/ai-server.ts +2 -2
  270. package/src/ai.ts +7 -7
  271. package/src/contract.ts +1 -1
  272. package/src/deterministic-id.ts +26 -3
  273. package/src/errors.ts +9 -6
  274. package/src/idempotent-replay.ts +0 -1
  275. package/src/index.ts +1 -1
  276. package/src/internal.ts +17 -6
  277. package/src/otel.ts +1 -1
  278. package/src/postgres-notifications.ts +0 -22
  279. package/src/postgres-resources.ts +6 -9
  280. package/src/postgres-schema.ts +121 -0
  281. package/src/push-envelope.ts +20 -0
  282. package/src/runtime-consumer.ts +10 -0
  283. package/src/scheduler-qstash.ts +12 -5
  284. package/src/scheduler-task.ts +2 -2
  285. package/src/scheduler-vercel.ts +10 -4
  286. package/src/server.browser.ts +1 -1
  287. package/src/server.ts +839 -238
  288. package/src/session-socket.ts +1 -1
  289. package/src/store-codec.ts +66 -0
  290. package/src/store-memory.ts +581 -255
  291. package/src/store-postgres.ts +1984 -943
  292. package/src/store-redis-core.ts +1624 -1152
  293. package/src/store-redis-notify.ts +2 -0
  294. package/src/store-sqlite.ts +891 -486
  295. package/src/store.ts +227 -97
  296. package/src/telemetry.ts +2 -1
  297. package/src/wire.ts +1 -0
  298. package/dist/ai-harness-BuuC-gJ3.js.map +0 -1
  299. package/dist/ai-harness-CV6rXbB3.d.ts.map +0 -1
  300. package/dist/ai-mMiWul1T.js.map +0 -1
  301. package/dist/contract-BYKASlCV.js.map +0 -1
  302. package/dist/idempotent-replay-JdgMQRRm.js +0 -21
  303. package/dist/idempotent-replay-JdgMQRRm.js.map +0 -1
  304. package/dist/initial-snapshot-Bx-c0pDP.d.ts.map +0 -1
  305. package/dist/internal-CscSY7K_.js.map +0 -1
  306. package/dist/server-D-Y4pqwu.js.map +0 -1
  307. package/dist/server-DYAATFuT.d.ts.map +0 -1
  308. package/dist/session-clear-C-QwTXV1.d.ts.map +0 -1
  309. package/dist/session-clear-DGI4jTQ5.js.map +0 -1
  310. package/dist/store-CyLUy86v.d.ts +0 -404
  311. package/dist/store-CyLUy86v.d.ts.map +0 -1
  312. package/dist/store-codec-DTG0Ftek.js +0 -10
  313. package/dist/store-codec-DTG0Ftek.js.map +0 -1
  314. package/dist/store-redis-notify-CM0AfLY0.js +0 -2544
  315. package/dist/store-redis-notify-CM0AfLY0.js.map +0 -1
  316. package/dist/telemetry-Cyfqo6Qt.d.ts.map +0 -1
  317. package/dist/wire-BKxH1vbP.js.map +0 -1
  318. package/docs/reference/05-adapters.mdx +0 -351
  319. package/docs/server/01-handlers.mdx +0 -200
  320. package/docs/server/05-production.mdx +0 -323
@@ -1,10 +1,14 @@
1
1
  import 'server-only'
2
2
  import { tool } from 'ai'
3
3
  import { idempotentId } from 'experimental-a2'
4
- import { handlerContext, inputs } from 'experimental-a2/ai'
4
+ import { consumerContext, inputs } from 'experimental-a2/ai'
5
5
  import { agent } from 'experimental-a2/ai/server'
6
6
  import { vercelQueues } from 'experimental-a2/scheduler-vercel'
7
- import { createServer, type A2Operation } from 'experimental-a2/server'
7
+ import {
8
+ consumer,
9
+ createServer,
10
+ type A2Operation,
11
+ } from 'experimental-a2/server'
8
12
  import { store } from '@/lib/store'
9
13
  import {
10
14
  chat,
@@ -22,7 +26,7 @@ const tools = {
22
26
  'Post a visible message to the multiplayer chat. Call it once for each chat bubble you want to send; this tool is the only way to speak in the room.',
23
27
  inputSchema: chatPostInputSchema,
24
28
  execute: async ({ message }, { toolCallId }) => {
25
- const context = handlerContext(chatAgent)
29
+ const context = consumerContext(chatAgent)
26
30
  context.signal.throwIfAborted()
27
31
  const { generationId, messageId } = context.event.payload.call
28
32
  // The agent's session shares the room's id. The explicit id makes a
@@ -114,42 +118,48 @@ Use as many post calls as the moment naturally calls for. Several short messages
114
118
  },
115
119
  })
116
120
 
117
- /** The room. Each message goes on to the agent's session, marked for whether it should answer. */
121
+ /**
122
+ * Each room message goes on to the agent's session, marked for whether it
123
+ * should answer. One lane keeps the agent's messages in the room's order.
124
+ */
125
+ const forwardToAgent = consumer({
126
+ contract: chat,
127
+ name: 'forward-to-agent',
128
+ types: ['message.sent'],
129
+ lane: 'a2.chat.ingress',
130
+ }).run(async (context) => {
131
+ const ambient = (await context.session.state()).state.ambient.enabled
132
+ const { author, text } = context.event.payload
133
+ const mode: ChatParticipantMode = ambient
134
+ ? 'ambient'
135
+ : mentionsAgent(text)
136
+ ? 'mention'
137
+ : 'passive'
138
+ const message: ChatAgentMessage = {
139
+ // Event ids are unique across a store's sessions, so the forward
140
+ // derives its own; a retried forward converges on the same id.
141
+ id: await idempotentId('chat.message', context.event.id),
142
+ role: 'user',
143
+ metadata: {
144
+ kind: 'participant',
145
+ author,
146
+ text,
147
+ sentAt: context.event.createdAt.toISOString(),
148
+ mode,
149
+ },
150
+ parts: [{ type: 'text', text: `${author}: ${text}` }],
151
+ }
152
+ await chatAgentServer
153
+ .session(context.session.id)
154
+ .append(...inputs.message(message, { generate: mode !== 'passive' }))
155
+ })
156
+
157
+ /** The room. Its messages reach the agent through `forwardToAgent`. */
118
158
  export const chatServer = createServer({
119
159
  ...(store ? { store } : {}),
120
160
  ...(chatScheduler ? { scheduler: chatScheduler } : {}),
121
161
  contract: chat,
122
- handlers: {
123
- 'message.sent': {
124
- lane: 'a2.chat.ingress',
125
- handler: async (context) => {
126
- const ambient = (await context.session.state()).state.ambient.enabled
127
- const { author, text } = context.event.payload
128
- const mode: ChatParticipantMode = ambient
129
- ? 'ambient'
130
- : mentionsAgent(text)
131
- ? 'mention'
132
- : 'passive'
133
- const message: ChatAgentMessage = {
134
- // Event ids are unique across a store's sessions, so the forward
135
- // derives its own; a retried forward converges on the same id.
136
- id: await idempotentId('chat.message', context.event.id),
137
- role: 'user',
138
- metadata: {
139
- kind: 'participant',
140
- author,
141
- text,
142
- sentAt: context.event.createdAt.toISOString(),
143
- mode,
144
- },
145
- parts: [{ type: 'text', text: `${author}: ${text}` }],
146
- }
147
- await chatAgentServer
148
- .session(context.session.id)
149
- .append(...inputs.message(message, { generate: mode !== 'passive' }))
150
- },
151
- },
152
- },
162
+ consumers: [forwardToAgent],
153
163
  })
154
164
 
155
165
  /** Room pushes: people's messages, typing, and ambient mode. Posts are the agent's. */
@@ -1,35 +1,77 @@
1
1
  // @vitest-environment jsdom
2
- import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'
3
- import { afterEach, expect, it, vi } from 'vitest'
2
+ import {
3
+ act,
4
+ cleanup,
5
+ fireEvent,
6
+ render,
7
+ screen,
8
+ waitFor,
9
+ } from '@testing-library/react'
10
+ import type { InitialSnapshot } from 'experimental-a2'
11
+ import { useAgent } from 'experimental-a2/ai/react'
12
+ import { createClient } from 'experimental-a2/client'
13
+ import type { ReactNode } from 'react'
14
+ import { afterEach, expect, it } from 'vitest'
15
+ import { serveAgent, type ServedAgent } from '@/test/agent'
16
+ import { demoAgent, type AgentState } from '../agent/model'
4
17
  import { ActivityFeed } from './activity-feed'
5
18
 
6
- afterEach(cleanup)
19
+ let served: ServedAgent | undefined
20
+
21
+ afterEach(async () => {
22
+ cleanup()
23
+ await served?.close()
24
+ })
7
25
 
8
26
  it('loads an earlier page only on request and keeps failures retryable', async () => {
9
- const loadHistory = vi
10
- .fn<() => Promise<unknown>>()
11
- .mockRejectedValueOnce(new Error('Read failed'))
12
- .mockResolvedValueOnce([])
13
- render(
14
- <ActivityFeed
15
- events={[]}
16
- index={100}
17
- history={{ loading: false, complete: false, oldestLoaded: null }}
18
- loadHistory={loadHistory}
19
- />,
20
- )
21
- expect(loadHistory).not.toHaveBeenCalled()
27
+ served = await serveAgent()
28
+ const { server, probe } = served
29
+ const client = createClient({ contract: demoAgent, api: served.url })
30
+ const id = crypto.randomUUID()
31
+ await server.session(id).append({
32
+ type: 'compaction.settings.updated',
33
+ payload: { mode: 'disabled' },
34
+ })
35
+ const operations = () => probe.operations.map(({ type }) => type)
36
+
37
+ function Feed({
38
+ initial,
39
+ }: {
40
+ initial: InitialSnapshot<AgentState>
41
+ }): ReactNode {
42
+ const session = useAgent({ client, id, initial })
43
+ return (
44
+ <ActivityFeed
45
+ events={session.events}
46
+ index={session.index}
47
+ history={session.history}
48
+ loadHistory={session.loadHistory}
49
+ />
50
+ )
51
+ }
52
+
53
+ probe.deny(({ type }) => type === 'history')
54
+ render(<Feed initial={await server.session(id).state()} />)
55
+ await waitFor(() => expect(operations()).toContain('stream'))
56
+ expect(operations()).not.toContain('history')
22
57
  await act(async () =>
23
58
  fireEvent.click(
24
59
  screen.getByRole('button', { name: 'Load earlier events' }),
25
60
  ),
26
61
  )
27
- expect(screen.getByRole('alert').textContent).toBe('Read failed')
62
+ expect((await screen.findByRole('alert')).textContent).toBe(
63
+ 'the operation is not authorized',
64
+ )
28
65
  await act(async () =>
29
66
  fireEvent.click(
30
67
  screen.getByRole('button', { name: 'Load earlier events' }),
31
68
  ),
32
69
  )
70
+ await waitFor(() =>
71
+ expect(screen.getByRole('list').textContent).toContain(
72
+ 'compaction.settings.updated',
73
+ ),
74
+ )
33
75
  expect(screen.queryByRole('alert')).toBeNull()
34
- expect(loadHistory).toHaveBeenCalledTimes(2)
76
+ expect(operations().filter((type) => type === 'history')).toHaveLength(2)
35
77
  })
@@ -40,6 +40,13 @@ export const ChatIcon = (): ReactNode => (
40
40
  </Glyph>
41
41
  )
42
42
 
43
+ export const A2slackIcon = (): ReactNode => (
44
+ <Glyph>
45
+ <path d="M3 4h18v13H10l-4 3.5V17H3z" />
46
+ <path className="accent" d="M10.5 7l-1 7M14.5 7l-1 7M8 9h8M7.5 12h8" />
47
+ </Glyph>
48
+ )
49
+
43
50
  export const AgentIcon = (): ReactNode => (
44
51
  <Glyph>
45
52
  <rect x="3" y="3" width="18" height="18" />
@@ -1,6 +1,7 @@
1
1
  import type { ReactNode } from 'react'
2
2
  import {
3
3
  A0Icon,
4
+ A2slackIcon,
4
5
  AgentIcon,
5
6
  CanvasIcon,
6
7
  ChatIcon,
@@ -24,6 +25,12 @@ export const demos: Demo[] = [
24
25
  { href: '/a0', name: 'A0', icon: <A0Icon />, fullWindow: true },
25
26
  { href: '/orders', name: 'Orders', icon: <OrdersIcon /> },
26
27
  { href: '/chat', name: 'Chat', icon: <ChatIcon /> },
28
+ {
29
+ href: '/a2slack',
30
+ name: 'a2slack',
31
+ icon: <A2slackIcon />,
32
+ fullWindow: true,
33
+ },
27
34
  { href: '/agent', name: 'Agent', icon: <AgentIcon /> },
28
35
  { href: '/canvas', name: 'Canvas', icon: <CanvasIcon /> },
29
36
  { href: '/documents', name: 'Documents', icon: <DocumentsIcon /> },
@@ -9,8 +9,8 @@ import {
9
9
  import { afterEach, beforeEach, expect, it, vi } from 'vitest'
10
10
  import { FastLink } from './fast-link'
11
11
 
12
- const push = vi.fn<(href: string) => void>()
13
- vi.mock('next/navigation', () => ({ useRouter: () => ({ push }) }))
12
+ // The App Router's router only exists inside a Next.js app.
13
+ vi.mock('next/navigation', () => ({ useRouter: () => ({ push: () => {} }) }))
14
14
 
15
15
  // Whether each click reached the browser's default; then stop jsdom's
16
16
  // unimplemented navigation.
@@ -20,7 +20,6 @@ const record = (event: MouseEvent): void => {
20
20
  event.preventDefault()
21
21
  }
22
22
  beforeEach(() => {
23
- push.mockReset()
24
23
  navigatedByClick = []
25
24
  document.addEventListener('click', record)
26
25
  })
@@ -40,10 +39,9 @@ const press = (): void => {
40
39
  fireEvent(link(), event)
41
40
  }
42
41
 
43
- it('navigates on the press and swallows only that click', () => {
42
+ it('swallows only the click that follows a press', () => {
44
43
  render(<FastLink href="/a0">Apps</FastLink>)
45
44
  press()
46
- expect(push).toHaveBeenCalledWith('/a0')
47
45
  fireEvent.click(link(), { detail: 1 })
48
46
  fireEvent.click(link(), { detail: 1 })
49
47
  expect(navigatedByClick).toEqual([false, true])
@@ -1,54 +1,95 @@
1
1
  import type { ReactElement } from 'react'
2
- import { beforeEach, expect, it, vi } from 'vitest'
2
+ import { afterEach, expect, it, vi, type Mock } from 'vitest'
3
3
  import AgentPage from './agent/[agentId]/page'
4
+ import { agentServer } from './agent/server'
4
5
  import ChatPage from './chat/[chatId]/page'
6
+ import { chatAgentServer, chatServer } from './chat/server'
5
7
 
6
- const agentReads = vi.hoisted(() => ({
7
- initial: { state: { agent: true }, index: 7 },
8
- state: vi.fn<() => Promise<{ state: { agent: boolean }; index: number }>>(),
9
- history: vi.fn<() => never>(),
10
- }))
11
- const reads = vi.hoisted(() => ({
12
- initial: { state: { marker: true }, index: 42 },
13
- state: vi.fn<() => Promise<{ state: { marker: boolean }; index: number }>>(),
14
- history: vi.fn<() => never>(),
15
- }))
16
- vi.mock('./agent/server', () => ({ agentServer: { session: () => reads } }))
17
- vi.mock('./chat/server', () => ({
18
- chatServer: { session: () => reads },
19
- chatAgentServer: { session: () => agentReads },
20
- }))
21
- vi.mock('./agent/[agentId]/agent-client', () => ({ AgentClient: () => null }))
22
- vi.mock('./chat/[chatId]/chat-client', () => ({ ChatClient: () => null }))
23
-
24
- beforeEach(() => {
25
- reads.state.mockReset().mockResolvedValue(reads.initial)
26
- agentReads.state.mockReset().mockResolvedValue(agentReads.initial)
27
- reads.history.mockReset().mockImplementation(() => {
28
- throw new Error('unexpected history read')
8
+ afterEach(() => {
9
+ vi.restoreAllMocks()
10
+ })
11
+
12
+ type Read = (...args: never[]) => unknown
13
+ type Handle = { state: Read; history: Read }
14
+ type Reads = { state: Mock<Read>; history: Mock<Read> }
15
+
16
+ /** The reads made through each session handle `server` hands out from now on. */
17
+ const readsOf = <H extends Handle>(server: {
18
+ session(id: string): H
19
+ }): Reads[] => {
20
+ const session = server.session.bind(server)
21
+ const handles: Reads[] = []
22
+ vi.spyOn(server, 'session').mockImplementation((id) => {
23
+ const handle = session(id)
24
+ const reads: Reads = {
25
+ state: vi.fn<Read>(handle.state),
26
+ history: vi.fn<Read>(handle.history),
27
+ }
28
+ handles.push(reads)
29
+ return { ...handle, ...reads }
30
+ })
31
+ return handles
32
+ }
33
+
34
+ const oneStateRead = (handles: Reads[]): void => {
35
+ expect(handles).toHaveLength(1)
36
+ expect(handles[0]!.state).toHaveBeenCalledExactlyOnceWith()
37
+ expect(handles[0]!.history).not.toHaveBeenCalled()
38
+ }
39
+
40
+ it('seeds agent from one state read without fetching raw history', async () => {
41
+ const agentId = crypto.randomUUID()
42
+ const session = agentServer.session(agentId)
43
+ await session.append({
44
+ type: 'compaction.settings.updated',
45
+ payload: { mode: 'manual', thresholdTokens: 1234 },
29
46
  })
47
+ await agentServer.drain(agentId)
48
+ const expected = await session.state()
49
+ expect(expected.state.compactionSettings).toEqual({
50
+ mode: 'manual',
51
+ thresholdTokens: 1234,
52
+ })
53
+
54
+ const reads = readsOf(agentServer)
55
+ const element = (await AgentPage({
56
+ params: Promise.resolve({ agentId }),
57
+ })) as ReactElement<{ initial: unknown; initialEvents?: unknown }>
58
+ oneStateRead(reads)
59
+ expect(element.props.initial).toEqual(expected)
60
+ expect(element.props.initialEvents).toBeUndefined()
30
61
  })
31
62
 
32
- it.each(['agent', 'chat'] as const)(
33
- 'seeds %s from one state read without fetching raw history',
34
- async (page) => {
35
- const element = (await (page === 'agent'
36
- ? AgentPage({ params: Promise.resolve({ agentId: 'one' }) })
37
- : ChatPage({
38
- params: Promise.resolve({ chatId: 'one' }),
39
- }))) as ReactElement<{ initial: unknown; initialEvents?: unknown }>
40
- expect(reads.state).toHaveBeenCalledExactlyOnceWith()
41
- expect(reads.history).not.toHaveBeenCalled()
42
- expect(element.props.initial).toBe(reads.initial)
43
- expect(element.props.initialEvents).toBeUndefined()
44
- },
45
- )
46
-
47
- it("seeds the chat's agent session from its own state read", async () => {
63
+ it('seeds chat and its agent session, each from one state read', async () => {
64
+ const chatId = crypto.randomUUID()
65
+ await chatServer.session(chatId).append({
66
+ type: 'message.sent',
67
+ payload: { author: 'alice', text: 'just chatting' },
68
+ })
69
+ // The room forwards the message to its agent in a background drain.
70
+ await vi.waitFor(async () => {
71
+ expect(
72
+ (await chatAgentServer.session(chatId).state()).state.messages,
73
+ ).toHaveLength(1)
74
+ })
75
+ await chatServer.drain(chatId)
76
+ await chatAgentServer.drain(chatId)
77
+ const room = await chatServer.session(chatId).state()
78
+ const agent = await chatAgentServer.session(chatId).state()
79
+ expect(room.state.messages).toHaveLength(1)
80
+
81
+ const roomReads = readsOf(chatServer)
82
+ const agentReads = readsOf(chatAgentServer)
48
83
  const element = (await ChatPage({
49
- params: Promise.resolve({ chatId: 'one' }),
50
- })) as ReactElement<{ children: ReactElement<{ agentInitial: unknown }> }>
51
- expect(agentReads.state).toHaveBeenCalledExactlyOnceWith()
52
- expect(agentReads.history).not.toHaveBeenCalled()
53
- expect(element.props.children.props.agentInitial).toBe(agentReads.initial)
84
+ params: Promise.resolve({ chatId }),
85
+ })) as ReactElement<{
86
+ initial: unknown
87
+ initialEvents?: unknown
88
+ children: ReactElement<{ agentInitial: unknown }>
89
+ }>
90
+ oneStateRead(roomReads)
91
+ oneStateRead(agentReads)
92
+ expect(element.props.initial).toEqual(room)
93
+ expect(element.props.initialEvents).toBeUndefined()
94
+ expect(element.props.children.props.agentInitial).toEqual(agent)
54
95
  })
@@ -118,7 +118,7 @@ export function OrderClient({ sessionId }: { sessionId: string }): ReactNode {
118
118
  <p className="hint">
119
119
  The button pushes <code>shop.started</code> optimistically — the
120
120
  badge flips before the server acks. Everything after that is
121
- handlers appending the next fact: courier assigned, picked up,
121
+ consumers appending the next fact: courier assigned, picked up,
122
122
  delivered — watch it arrive over the stream, hands off.
123
123
  </p>
124
124
  </>
@@ -129,7 +129,7 @@ export function OrderClient({ sessionId }: { sessionId: string }): ReactNode {
129
129
  </p>
130
130
  ) : (
131
131
  <p className="hint">
132
- Hands off from here — each status lands on its own as handlers append
132
+ Hands off from here — each status lands on its own as consumers append
133
133
  the next fact.
134
134
  </p>
135
135
  )}
@@ -8,7 +8,7 @@ export default function OrdersPage(): ReactNode {
8
8
  <p className="lede">
9
9
  Creating an order appends a single <code>created</code> event.
10
10
  Everything after that — the shop notification, the courier, the delivery
11
- itself — is handlers appending the next fact to the same log, all the
11
+ itself — is consumers appending the next fact to the same log, all the
12
12
  way to <code>delivered</code>.
13
13
  </p>
14
14
  <NewOrderForm />
@@ -1,6 +1,6 @@
1
1
  import 'server-only'
2
2
  import { vercelQueues } from 'experimental-a2/scheduler-vercel'
3
- import { createServer } from 'experimental-a2/server'
3
+ import { consumer, createServer } from 'experimental-a2/server'
4
4
  import { store } from '@/lib/store'
5
5
  import { orders } from './model'
6
6
 
@@ -14,37 +14,56 @@ export const ordersScheduler =
14
14
  ? vercelQueues({ topic: 'a2-orders' })
15
15
  : undefined
16
16
 
17
+ const notifyShop = consumer({
18
+ contract: orders,
19
+ name: 'notify-shop',
20
+ types: ['created'],
21
+ }).run(async ({ session }) => {
22
+ await wait(800)
23
+ await session.append('notify-shop', {
24
+ type: 'shop.notified',
25
+ payload: {},
26
+ })
27
+ })
28
+
29
+ const notifyDriver = consumer({
30
+ contract: orders,
31
+ name: 'notify-driver',
32
+ types: ['shop.started'],
33
+ }).run(async ({ session }) => {
34
+ await wait(1200)
35
+ const driverId = drivers[Math.floor(Math.random() * drivers.length)]!
36
+ await session.append('notify-driver', {
37
+ type: 'driver.notified',
38
+ payload: { driverId },
39
+ })
40
+ })
41
+
42
+ const pickUp = consumer({
43
+ contract: orders,
44
+ name: 'pick-up',
45
+ types: ['driver.notified'],
46
+ }).run(async ({ session }) => {
47
+ await wait(3000)
48
+ const etaMinutes = 3 + Math.floor(Math.random() * 5)
49
+ await session.append('courier-picked-up', {
50
+ type: 'courier.picked_up',
51
+ payload: { etaMinutes },
52
+ })
53
+ })
54
+
55
+ const deliver = consumer({
56
+ contract: orders,
57
+ name: 'deliver',
58
+ types: ['courier.picked_up'],
59
+ }).run(async ({ session }) => {
60
+ await wait(3500)
61
+ await session.append('delivered', { type: 'delivered', payload: {} })
62
+ })
63
+
17
64
  export const ordersServer = createServer({
18
65
  ...(store ? { store } : {}),
19
66
  ...(ordersScheduler ? { scheduler: ordersScheduler } : {}),
20
67
  contract: orders,
21
- handlers: {
22
- created: async ({ session }) => {
23
- await wait(800)
24
- await session.append('notify-shop', {
25
- type: 'shop.notified',
26
- payload: {},
27
- })
28
- },
29
- 'shop.started': async ({ session }) => {
30
- await wait(1200)
31
- const driverId = drivers[Math.floor(Math.random() * drivers.length)]!
32
- await session.append('notify-driver', {
33
- type: 'driver.notified',
34
- payload: { driverId },
35
- })
36
- },
37
- 'driver.notified': async ({ session }) => {
38
- await wait(3000)
39
- const etaMinutes = 3 + Math.floor(Math.random() * 5)
40
- await session.append('courier-picked-up', {
41
- type: 'courier.picked_up',
42
- payload: { etaMinutes },
43
- })
44
- },
45
- 'courier.picked_up': async ({ session }) => {
46
- await wait(3500)
47
- await session.append('delivered', { type: 'delivered', payload: {} })
48
- },
49
- },
68
+ consumers: [notifyShop, notifyDriver, pickUp, deliver],
50
69
  })
@@ -45,7 +45,7 @@ export function RecoveryClient({
45
45
  return (
46
46
  <article>
47
47
  <header className="session-header">
48
- <h1>Cross-invocation handler chain</h1>
48
+ <h1>Cross-invocation step chain</h1>
49
49
  <ConnectionPill connection={connection} />
50
50
  <span
51
51
  className={`badge${completed ? ' done' : running ? ' waiting' : ''}`}
@@ -59,14 +59,14 @@ export function RecoveryClient({
59
59
  </header>
60
60
 
61
61
  <p className="lede">
62
- Four handlers fit individually, but their 32-second chain does not fit
63
- in one 20-second function. Every invocation has the same limit.
62
+ Four steps fit individually, but their 32-second chain does not fit in
63
+ one 20-second function. Every invocation has the same limit.
64
64
  </p>
65
65
 
66
66
  <dl className="facts">
67
67
  <dt>Function limit</dt>
68
68
  <dd>{FUNCTION_LIMIT_SECONDS} seconds</dd>
69
- <dt>Each handler</dt>
69
+ <dt>Each step</dt>
70
70
  <dd>{STEP_SECONDS} seconds</dd>
71
71
  <dt>Whole chain</dt>
72
72
  <dd>
@@ -94,15 +94,14 @@ export function RecoveryClient({
94
94
  <h2>The chain is crossing function invocations</h2>
95
95
  <p>
96
96
  Each step waits eight seconds before appending its completion fact.
97
- A2 does not predict whether the next handler fits. The first
98
- invocation completes two handlers, starts the third, and is stopped
99
- by Vercel at 20 seconds. That event stays pending. Its claim
100
- watchdog acquires the expired claim and retries the same event in a
101
- fresh function.
97
+ A2 does not predict whether the next step fits. The first invocation
98
+ completes two steps, starts the third, and is stopped by Vercel at
99
+ 20 seconds. That event stays pending. Its claim watchdog acquires
100
+ the expired claim and retries the same event in a fresh function.
102
101
  </p>
103
102
  <p className="hint">
104
103
  Keep this page open. Claim heartbeats keep scheduling watchdogs
105
- while a handler is alive. The known function deadline caps the last
104
+ while a step is running. The known function deadline caps the last
106
105
  claim window, so the scheduler arrives just after Vercel stops the
107
106
  worker. Reloading can also trigger A2&apos;s separate
108
107
  interaction-healing path.
@@ -112,8 +111,8 @@ export function RecoveryClient({
112
111
 
113
112
  {completed ? (
114
113
  <p className="proof">
115
- All {state.completedSteps} bounded handlers finished. The scheduler
116
- added no event of its own; it only continued draining the pending
114
+ All {state.completedSteps} bounded steps finished. The scheduler added
115
+ no event of its own; it only continued draining the pending
117
116
  application events.
118
117
  </p>
119
118
  ) : null}
@@ -127,12 +126,12 @@ export function RecoveryClient({
127
126
  state.completedSteps < STEP_COUNT ? (
128
127
  <>
129
128
  Waiting for step {state.completedSteps + 1} of {STEP_COUNT}. The
130
- event log stays quiet while its {STEP_SECONDS}-second handler
131
- runs; the next row is the handler&apos;s real completion fact.
129
+ event log stays quiet while its {STEP_SECONDS}-second step runs;
130
+ the next row is the step&apos;s real completion fact.
132
131
  </>
133
132
  ) : (
134
133
  <>
135
- All four handlers finished. Waiting for the final{' '}
134
+ All four steps finished. Waiting for the final{' '}
136
135
  <code>pipeline.completed</code> fact from the active drain.
137
136
  </>
138
137
  )
@@ -6,10 +6,10 @@ export default function RecoveryPage(): ReactNode {
6
6
  <article>
7
7
  <h1>Recovery lab</h1>
8
8
  <p className="lede">
9
- Run four 8-second handlers in a chain. Each fits inside a 20-second
10
- Vercel function, but all 32 seconds cannot. Watch Vercel stop one
11
- mid-handler, then let A2 retry that pending event in a fresh invocation
12
- with the same limit.
9
+ Run four 8-second steps in a chain. Each fits inside a 20-second Vercel
10
+ function, but all 32 seconds cannot. Watch Vercel stop one mid-step,
11
+ then let A2 retry that pending event in a fresh invocation with the same
12
+ limit.
13
13
  </p>
14
14
  <NewRecoverySession />
15
15
  <p className="hint">