gemi 0.61.0 → 0.63.0-rc.0

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 (282) hide show
  1. package/dist/ai/Agent.d.ts +120 -0
  2. package/dist/ai/Agent.d.ts.map +1 -1
  3. package/dist/ai/AgentController.d.ts +255 -18
  4. package/dist/ai/AgentController.d.ts.map +1 -1
  5. package/dist/ai/client/conformance.d.ts +21 -0
  6. package/dist/ai/client/conformance.d.ts.map +1 -0
  7. package/dist/ai/client/index.js +20 -3
  8. package/dist/ai/client/index.js.map +1 -1
  9. package/dist/ai/client/reducer.d.ts.map +1 -1
  10. package/dist/ai/index.d.ts +4 -3
  11. package/dist/ai/index.d.ts.map +1 -1
  12. package/dist/ai/index.js +12 -12
  13. package/dist/ai/index.js.map +10 -9
  14. package/dist/ai/providers/capabilities.d.ts +18 -0
  15. package/dist/ai/providers/capabilities.d.ts.map +1 -1
  16. package/dist/ai/providers/fakeProvider.d.ts +10 -1
  17. package/dist/ai/providers/fakeProvider.d.ts.map +1 -1
  18. package/dist/ai/providers/request.d.ts +17 -0
  19. package/dist/ai/providers/request.d.ts.map +1 -1
  20. package/dist/ai/store/Attachments.d.ts +433 -0
  21. package/dist/ai/store/Attachments.d.ts.map +1 -0
  22. package/dist/ai/store/LiveRuns.d.ts +8 -1
  23. package/dist/ai/store/LiveRuns.d.ts.map +1 -1
  24. package/dist/ai/store/index.d.ts +1 -0
  25. package/dist/ai/store/index.d.ts.map +1 -1
  26. package/dist/ai/types.d.ts +93 -3
  27. package/dist/ai/types.d.ts.map +1 -1
  28. package/dist/ai/useChat.d.ts +33 -4
  29. package/dist/ai/useChat.d.ts.map +1 -1
  30. package/dist/app/App.d.ts.map +1 -1
  31. package/dist/app/index.js +2 -2
  32. package/dist/app/index.js.map +1 -1
  33. package/dist/bin/ai-client/extract.d.ts +36 -0
  34. package/dist/bin/ai-client/extract.d.ts.map +1 -0
  35. package/dist/bin/ai-client/generate.d.ts +22 -0
  36. package/dist/bin/ai-client/generate.d.ts.map +1 -0
  37. package/dist/bin/ai-client/kotlin.d.ts +13 -0
  38. package/dist/bin/ai-client/kotlin.d.ts.map +1 -0
  39. package/dist/bin/ai-client/model.d.ts +99 -0
  40. package/dist/bin/ai-client/model.d.ts.map +1 -0
  41. package/dist/bin/ai-client/swift.d.ts +10 -0
  42. package/dist/bin/ai-client/swift.d.ts.map +1 -0
  43. package/dist/bin/gemi.js +831 -17
  44. package/dist/bin/gemi.js.map +11 -5
  45. package/dist/bin/orm-generator.js +30 -16
  46. package/dist/bin/orm-generator.js.map +2 -2
  47. package/dist/broadcasting/index.js +1 -1
  48. package/dist/bun/plugin.js +1 -1
  49. package/dist/bun/preload.js +1 -1
  50. package/dist/{chunk-htesx7ym.js → chunk-0p1zytn6.js} +3 -3
  51. package/dist/{chunk-htesx7ym.js.map → chunk-0p1zytn6.js.map} +1 -1
  52. package/dist/{chunk-b0t4zp6b.js → chunk-1mf5vw0z.js} +3 -3
  53. package/dist/{chunk-b0t4zp6b.js.map → chunk-1mf5vw0z.js.map} +1 -1
  54. package/dist/chunk-2ctdp7ry.js +5 -0
  55. package/dist/chunk-2ctdp7ry.js.map +10 -0
  56. package/dist/{chunk-1aqzcgfr.js → chunk-2nq2006q.js} +2 -2
  57. package/dist/{chunk-1aqzcgfr.js.map → chunk-2nq2006q.js.map} +1 -1
  58. package/dist/chunk-35p0gqmf.js +6 -0
  59. package/dist/{chunk-91cj3nxk.js.map → chunk-35p0gqmf.js.map} +2 -2
  60. package/dist/{chunk-528n3vgy.js → chunk-38zft53j.js} +2 -2
  61. package/dist/{chunk-528n3vgy.js.map → chunk-38zft53j.js.map} +1 -1
  62. package/dist/{chunk-k2sjvt0c.js → chunk-43nt6e36.js} +2 -2
  63. package/dist/{chunk-k2sjvt0c.js.map → chunk-43nt6e36.js.map} +1 -1
  64. package/dist/{chunk-5gdv4n4a.js → chunk-4qgwyjwz.js} +3 -3
  65. package/dist/{chunk-5gdv4n4a.js.map → chunk-4qgwyjwz.js.map} +1 -1
  66. package/dist/chunk-607j9dy9.js +5 -0
  67. package/dist/chunk-607j9dy9.js.map +16 -0
  68. package/dist/{chunk-x6y1z4cq.js → chunk-68wejdfc.js} +2 -2
  69. package/dist/{chunk-x6y1z4cq.js.map → chunk-68wejdfc.js.map} +1 -1
  70. package/dist/{chunk-8ag0da2s.js → chunk-6afc71kp.js} +2 -2
  71. package/dist/{chunk-8ag0da2s.js.map → chunk-6afc71kp.js.map} +1 -1
  72. package/dist/{chunk-8r8epsef.js → chunk-78fnykzh.js} +2 -2
  73. package/dist/{chunk-8r8epsef.js.map → chunk-78fnykzh.js.map} +1 -1
  74. package/dist/{chunk-cf7bvd12.js → chunk-81se9gak.js} +2 -2
  75. package/dist/{chunk-cf7bvd12.js.map → chunk-81se9gak.js.map} +1 -1
  76. package/dist/{chunk-ywntv8yw.js → chunk-8jjw9hqf.js} +3 -3
  77. package/dist/{chunk-ywntv8yw.js.map → chunk-8jjw9hqf.js.map} +1 -1
  78. package/dist/{chunk-snb68dgr.js → chunk-92j4tjjx.js} +1 -1
  79. package/dist/chunk-995b5wsd.js +5 -0
  80. package/dist/chunk-995b5wsd.js.map +17 -0
  81. package/dist/chunk-9vj9b31s.js +24 -0
  82. package/dist/{chunk-hyxmmj9b.js.map → chunk-9vj9b31s.js.map} +6 -5
  83. package/dist/chunk-as2dbney.js +19 -0
  84. package/dist/{chunk-vqcswg7h.js.map → chunk-as2dbney.js.map} +10 -16
  85. package/dist/{chunk-wcv6qtpq.js → chunk-bmfm7dyp.js} +3 -3
  86. package/dist/{chunk-wcv6qtpq.js.map → chunk-bmfm7dyp.js.map} +1 -1
  87. package/dist/{chunk-k75phgj4.js → chunk-bykty4bm.js} +4 -4
  88. package/dist/{chunk-k75phgj4.js.map → chunk-bykty4bm.js.map} +1 -1
  89. package/dist/{chunk-j23cengk.js → chunk-dpbxpyrs.js} +2 -2
  90. package/dist/{chunk-j23cengk.js.map → chunk-dpbxpyrs.js.map} +1 -1
  91. package/dist/{chunk-xecj8025.js → chunk-dv772dyn.js} +3 -3
  92. package/dist/{chunk-xecj8025.js.map → chunk-dv772dyn.js.map} +1 -1
  93. package/dist/{chunk-exndjhza.js → chunk-e2441vnc.js} +2 -2
  94. package/dist/{chunk-exndjhza.js.map → chunk-e2441vnc.js.map} +1 -1
  95. package/dist/{chunk-5mhcwnyd.js → chunk-etgsft9d.js} +2 -2
  96. package/dist/{chunk-5mhcwnyd.js.map → chunk-etgsft9d.js.map} +1 -1
  97. package/dist/chunk-f51yvjvr.js +5 -0
  98. package/dist/chunk-f51yvjvr.js.map +11 -0
  99. package/dist/{chunk-yk5wqmyh.js → chunk-faj0stp9.js} +2 -2
  100. package/dist/{chunk-yk5wqmyh.js.map → chunk-faj0stp9.js.map} +1 -1
  101. package/dist/{chunk-rpjsmr41.js → chunk-fjs7ad18.js} +2 -2
  102. package/dist/{chunk-rpjsmr41.js.map → chunk-fjs7ad18.js.map} +1 -1
  103. package/dist/{chunk-f233yzxf.js → chunk-fxnzvbf1.js} +11 -11
  104. package/dist/chunk-fxnzvbf1.js.map +10 -0
  105. package/dist/{chunk-p3qd0gqa.js → chunk-fy5s4yse.js} +2 -2
  106. package/dist/{chunk-p3qd0gqa.js.map → chunk-fy5s4yse.js.map} +1 -1
  107. package/dist/{chunk-tr3cbx8k.js → chunk-gktc4g6g.js} +2 -2
  108. package/dist/{chunk-tr3cbx8k.js.map → chunk-gktc4g6g.js.map} +1 -1
  109. package/dist/{chunk-tds3xq6b.js → chunk-gs99rnym.js} +3 -3
  110. package/dist/{chunk-tds3xq6b.js.map → chunk-gs99rnym.js.map} +1 -1
  111. package/dist/{chunk-fz5g2z6h.js → chunk-hr90mpy9.js} +2 -2
  112. package/dist/{chunk-fz5g2z6h.js.map → chunk-hr90mpy9.js.map} +1 -1
  113. package/dist/chunk-hvm1aamv.js +5 -0
  114. package/dist/chunk-hvm1aamv.js.map +10 -0
  115. package/dist/{chunk-hsfjt13m.js → chunk-jg6vmate.js} +1 -1
  116. package/dist/chunk-kj5xryzy.js +9 -0
  117. package/dist/{chunk-ybqss0jy.js.map → chunk-kj5xryzy.js.map} +4 -4
  118. package/dist/{chunk-57a0nqfj.js → chunk-kpy138e2.js} +2 -2
  119. package/dist/{chunk-57a0nqfj.js.map → chunk-kpy138e2.js.map} +1 -1
  120. package/dist/{chunk-cyrxdj6a.js → chunk-ktnaj5c4.js} +2 -2
  121. package/dist/{chunk-cyrxdj6a.js.map → chunk-ktnaj5c4.js.map} +1 -1
  122. package/dist/{chunk-4dan69s4.js → chunk-kvr6e9md.js} +2 -2
  123. package/dist/{chunk-4dan69s4.js.map → chunk-kvr6e9md.js.map} +1 -1
  124. package/dist/{chunk-r962ae93.js → chunk-mxbtd91q.js} +2 -2
  125. package/dist/{chunk-r962ae93.js.map → chunk-mxbtd91q.js.map} +1 -1
  126. package/dist/chunk-njrjnkab.js +5 -0
  127. package/dist/{chunk-q6qghsy7.js.map → chunk-njrjnkab.js.map} +1 -1
  128. package/dist/chunk-nmrynp02.js +4 -0
  129. package/dist/chunk-nmrynp02.js.map +10 -0
  130. package/dist/{chunk-ms13evzp.js → chunk-nt9685gz.js} +2 -2
  131. package/dist/{chunk-ms13evzp.js.map → chunk-nt9685gz.js.map} +1 -1
  132. package/dist/{chunk-9xpa7dpy.js → chunk-nv93zp3x.js} +2 -2
  133. package/dist/{chunk-9xpa7dpy.js.map → chunk-nv93zp3x.js.map} +1 -1
  134. package/dist/{chunk-wpb1xpdp.js → chunk-p3v76b6c.js} +2 -2
  135. package/dist/{chunk-wpb1xpdp.js.map → chunk-p3v76b6c.js.map} +1 -1
  136. package/dist/{chunk-m45j7p1y.js → chunk-pa4cbxnf.js} +2 -2
  137. package/dist/{chunk-m45j7p1y.js.map → chunk-pa4cbxnf.js.map} +1 -1
  138. package/dist/{chunk-ygfwtgvm.js → chunk-ph5n045f.js} +2 -2
  139. package/dist/{chunk-ygfwtgvm.js.map → chunk-ph5n045f.js.map} +1 -1
  140. package/dist/{chunk-djp2xeqe.js → chunk-pspydm8f.js} +3 -3
  141. package/dist/{chunk-djp2xeqe.js.map → chunk-pspydm8f.js.map} +1 -1
  142. package/dist/{chunk-7t1hjs9f.js → chunk-pza618j0.js} +2 -2
  143. package/dist/{chunk-7t1hjs9f.js.map → chunk-pza618j0.js.map} +1 -1
  144. package/dist/{chunk-71pk1mxx.js → chunk-q3zthdy7.js} +2 -2
  145. package/dist/{chunk-71pk1mxx.js.map → chunk-q3zthdy7.js.map} +1 -1
  146. package/dist/{chunk-9nmvm20t.js → chunk-q4zvp9b9.js} +2 -2
  147. package/dist/{chunk-9nmvm20t.js.map → chunk-q4zvp9b9.js.map} +1 -1
  148. package/dist/{chunk-m0tp7zjp.js → chunk-qrb9d1fs.js} +2 -2
  149. package/dist/{chunk-m0tp7zjp.js.map → chunk-qrb9d1fs.js.map} +1 -1
  150. package/dist/{chunk-gcszdwcb.js → chunk-qskcpfpf.js} +2 -2
  151. package/dist/{chunk-gcszdwcb.js.map → chunk-qskcpfpf.js.map} +1 -1
  152. package/dist/{chunk-1b7e9rj7.js → chunk-t5kbqva2.js} +2 -2
  153. package/dist/{chunk-1b7e9rj7.js.map → chunk-t5kbqva2.js.map} +1 -1
  154. package/dist/{chunk-a1exbqcq.js → chunk-tabcfsep.js} +2 -2
  155. package/dist/{chunk-a1exbqcq.js.map → chunk-tabcfsep.js.map} +1 -1
  156. package/dist/{chunk-7xvaace2.js → chunk-v8m61g5d.js} +2 -2
  157. package/dist/{chunk-7xvaace2.js.map → chunk-v8m61g5d.js.map} +1 -1
  158. package/dist/{chunk-ys904esh.js → chunk-w9zbaxc2.js} +2 -2
  159. package/dist/{chunk-ys904esh.js.map → chunk-w9zbaxc2.js.map} +1 -1
  160. package/dist/chunk-wchrcptd.js +4 -0
  161. package/dist/{chunk-ds44bqr9.js.map → chunk-wchrcptd.js.map} +6 -7
  162. package/dist/{chunk-bb19bwg6.js → chunk-xjfpnmgn.js} +2 -2
  163. package/dist/{chunk-bb19bwg6.js.map → chunk-xjfpnmgn.js.map} +1 -1
  164. package/dist/{chunk-3aemqfdr.js → chunk-xm7rva5w.js} +7 -7
  165. package/dist/chunk-xm7rva5w.js.map +11 -0
  166. package/dist/{chunk-hxb1eg2z.js → chunk-xth9vh46.js} +2 -2
  167. package/dist/{chunk-hxb1eg2z.js.map → chunk-xth9vh46.js.map} +1 -1
  168. package/dist/{chunk-fb4cy6sq.js → chunk-y9wdr6h4.js} +2 -2
  169. package/dist/{chunk-fb4cy6sq.js.map → chunk-y9wdr6h4.js.map} +1 -1
  170. package/dist/{chunk-3296fwss.js → chunk-yspg0cvk.js} +2 -2
  171. package/dist/{chunk-3296fwss.js.map → chunk-yspg0cvk.js.map} +1 -1
  172. package/dist/chunk-zq2v9fgf.js +5 -0
  173. package/dist/{chunk-s41ees18.js.map → chunk-zq2v9fgf.js.map} +5 -4
  174. package/dist/config/index.js +1 -1
  175. package/dist/console/run.js +2 -2
  176. package/dist/console/run.js.map +1 -1
  177. package/dist/container/index.js +2 -2
  178. package/dist/container/index.js.map +1 -1
  179. package/dist/database/index.js +2 -2
  180. package/dist/database/index.js.map +1 -1
  181. package/dist/email/index.js +2 -2
  182. package/dist/email/index.js.map +1 -1
  183. package/dist/facades/Auth.d.ts.map +1 -1
  184. package/dist/facades/Storage.d.ts +6 -2
  185. package/dist/facades/Storage.d.ts.map +1 -1
  186. package/dist/facades/index.js +2 -2
  187. package/dist/facades/index.js.map +1 -1
  188. package/dist/foundation/index.js +2 -2
  189. package/dist/foundation/index.js.map +1 -1
  190. package/dist/gemi.d.ts +7 -0
  191. package/dist/http/ApiRouter.d.ts +18 -0
  192. package/dist/http/ApiRouter.d.ts.map +1 -1
  193. package/dist/http/HttpRequest.d.ts +13 -0
  194. package/dist/http/HttpRequest.d.ts.map +1 -1
  195. package/dist/http/McpRouter.d.ts +207 -0
  196. package/dist/http/McpRouter.d.ts.map +1 -0
  197. package/dist/http/McpRouter.test-d.d.ts +2 -0
  198. package/dist/http/McpRouter.test-d.d.ts.map +1 -0
  199. package/dist/http/RateLimitMiddleware.d.ts +13 -0
  200. package/dist/http/RateLimitMiddleware.d.ts.map +1 -1
  201. package/dist/http/errors.d.ts +8 -0
  202. package/dist/http/errors.d.ts.map +1 -1
  203. package/dist/http/getCookies.d.ts +15 -0
  204. package/dist/http/getCookies.d.ts.map +1 -1
  205. package/dist/http/index.d.ts +1 -0
  206. package/dist/http/index.d.ts.map +1 -1
  207. package/dist/http/index.js +2 -2
  208. package/dist/http/index.js.map +1 -1
  209. package/dist/http/modelOriginated.d.ts +21 -0
  210. package/dist/http/modelOriginated.d.ts.map +1 -0
  211. package/dist/http/requestContext.d.ts +34 -0
  212. package/dist/http/requestContext.d.ts.map +1 -1
  213. package/dist/i18n/dictionaryRuntime.js +2 -2
  214. package/dist/i18n/dictionaryRuntime.js.map +1 -1
  215. package/dist/i18n/index.js +2 -2
  216. package/dist/i18n/index.js.map +2 -2
  217. package/dist/kernel/index.js +2 -2
  218. package/dist/kernel/index.js.map +2 -2
  219. package/dist/orm/errors.d.ts +8 -0
  220. package/dist/orm/errors.d.ts.map +1 -1
  221. package/dist/orm/index.js +2 -2
  222. package/dist/orm/index.js.map +1 -1
  223. package/dist/server/httpDev.d.ts.map +1 -1
  224. package/dist/server/httpProd.d.ts.map +1 -1
  225. package/dist/server/index.js +2 -2
  226. package/dist/server/index.js.map +2 -2
  227. package/dist/server/unhandledError.d.ts +2 -0
  228. package/dist/server/unhandledError.d.ts.map +1 -0
  229. package/dist/services/file-storage/drivers/AzureBlobDriver.d.ts +3 -2
  230. package/dist/services/file-storage/drivers/AzureBlobDriver.d.ts.map +1 -1
  231. package/dist/services/file-storage/drivers/FileStorageDriver.d.ts +2 -2
  232. package/dist/services/file-storage/drivers/FileStorageDriver.d.ts.map +1 -1
  233. package/dist/services/file-storage/drivers/FileSystemDriver.d.ts +2 -2
  234. package/dist/services/file-storage/drivers/FileSystemDriver.d.ts.map +1 -1
  235. package/dist/services/file-storage/drivers/S3Driver.d.ts +2 -2
  236. package/dist/services/file-storage/drivers/S3Driver.d.ts.map +1 -1
  237. package/dist/services/file-storage/drivers/types.d.ts +9 -1
  238. package/dist/services/file-storage/drivers/types.d.ts.map +1 -1
  239. package/dist/services/index.d.ts +3 -2
  240. package/dist/services/index.d.ts.map +1 -1
  241. package/dist/services/index.js +6 -6
  242. package/dist/services/index.js.map +4 -4
  243. package/dist/services/mcp/McpRegistry.d.ts +150 -0
  244. package/dist/services/mcp/McpRegistry.d.ts.map +1 -0
  245. package/dist/services/mcp/toAgentTools.d.ts +20 -0
  246. package/dist/services/mcp/toAgentTools.d.ts.map +1 -0
  247. package/dist/services/pubsub/BroadcastManager.d.ts.map +1 -1
  248. package/dist/services/router/ApiRouteDispatcher.d.ts +83 -1
  249. package/dist/services/router/ApiRouteDispatcher.d.ts.map +1 -1
  250. package/dist/services/router/RouteServiceProvider.d.ts +6 -4
  251. package/dist/services/router/RouteServiceProvider.d.ts.map +1 -1
  252. package/dist/services/router/ViewRouteDispatcher.d.ts.map +1 -1
  253. package/dist/services/router/apiPath.d.ts +23 -0
  254. package/dist/services/router/apiPath.d.ts.map +1 -0
  255. package/dist/services/router/config.d.ts +5 -0
  256. package/dist/services/router/config.d.ts.map +1 -1
  257. package/dist/services/router/createFlatApiRoutes.d.ts +3 -1
  258. package/dist/services/router/createFlatApiRoutes.d.ts.map +1 -1
  259. package/dist/services/router/policyDenied.d.ts +28 -0
  260. package/dist/services/router/policyDenied.d.ts.map +1 -0
  261. package/dist/support/index.js +2 -2
  262. package/dist/support/index.js.map +1 -1
  263. package/package.json +5 -1
  264. package/skills/gemi-react-best-practices/rules/controller-authorize-every-tenant-read.md +1 -1
  265. package/skills/gemi-react-best-practices/rules/controller-throw-framework-errors.md +1 -1
  266. package/dist/chunk-3aemqfdr.js.map +0 -11
  267. package/dist/chunk-91cj3nxk.js +0 -6
  268. package/dist/chunk-ds44bqr9.js +0 -4
  269. package/dist/chunk-f233yzxf.js.map +0 -10
  270. package/dist/chunk-hyxmmj9b.js +0 -5
  271. package/dist/chunk-mca9wsvs.js +0 -5
  272. package/dist/chunk-mca9wsvs.js.map +0 -11
  273. package/dist/chunk-q6qghsy7.js +0 -5
  274. package/dist/chunk-s41ees18.js +0 -5
  275. package/dist/chunk-sz051605.js +0 -5
  276. package/dist/chunk-sz051605.js.map +0 -14
  277. package/dist/chunk-vqcswg7h.js +0 -19
  278. package/dist/chunk-xnytbrda.js +0 -4
  279. package/dist/chunk-xnytbrda.js.map +0 -10
  280. package/dist/chunk-ybqss0jy.js +0 -9
  281. /package/dist/{chunk-snb68dgr.js.map → chunk-92j4tjjx.js.map} +0 -0
  282. /package/dist/{chunk-hsfjt13m.js.map → chunk-jg6vmate.js.map} +0 -0
@@ -1,6 +1,7 @@
1
1
  import type { HttpRequest } from "../http";
2
2
  import type { AgentProvider } from "./AgentProvider";
3
3
  import type { Infer, Schema } from "./Schema";
4
+ import type { ScopedAttachments, ToolAttachments } from "./store/Attachments";
4
5
  import type { AgentMessage, AgentStreamEvent, AgentStreamFrame, ClientTurn, FinishReason, NestedRun, PendingToolCall, ToolShapes, Usage } from "./types";
5
6
  /**
6
7
  * Everything a tool needs from the request it is running inside.
@@ -40,6 +41,43 @@ export interface ToolContext {
40
41
  * to tell it otherwise: the tool body ran once already.
41
42
  */
42
43
  readonly resumed: boolean;
44
+ /**
45
+ * Files, both directions.
46
+ *
47
+ * WHAT THIS FIXES. Before it, files travelled one way: a user's upload became
48
+ * a provider file id the model could look at, and a tool that *produced*
49
+ * something — an edited image, a rendered chart — had a string to return and
50
+ * nowhere to put the bytes. `put(blob)` parks them and answers a record whose
51
+ * `id` is the handle everything else uses; `put(blob, { showModel: true })`
52
+ * also sends them to the provider and puts them in front of the model as an
53
+ * input-role message once this tool call settles, which is what makes
54
+ * generate → look → fix a loop rather than a one-way report.
55
+ *
56
+ * SCOPED, AND THAT IS THE WHOLE SECURITY STORY. The object is built from the
57
+ * `ScopedAttachments` the controller resolved for *this request* (see
58
+ * `AgentController.attachmentScope`), and none of its methods takes a scope,
59
+ * so there is nothing for a tool to pass the model's arguments into. An id
60
+ * that came from another user resolves to `AttachmentNotFoundError`, with the
61
+ * same wording an unknown id gets.
62
+ *
63
+ * PER TOOL CALL, LIKE `runAgent`, AND FOR THE SAME REASON. `put` is memoized
64
+ * by call index within the tool call, so a tool that escalates and is
65
+ * re-entered does not store, upload or inject a second time. Read the note on
66
+ * `ToolAttachments.put` before writing a body whose `put` calls sit in a
67
+ * branch.
68
+ *
69
+ * ALWAYS PRESENT, NEVER NULL. A request with no attachment scope — an
70
+ * unauthenticated, thread-less chat — gets an object whose every method
71
+ * throws with a sentence naming `attachmentScope()`. A nullable `ctx`
72
+ * member would be a guard every tool has to remember and most would not,
73
+ * and the failure of forgetting is a `TypeError` in a tool body rather than
74
+ * an explanation.
75
+ */
76
+ attachments: ToolAttachments;
77
+ /**
78
+ * What the user sent with the turn this tool call answers. See `ToolTurn`.
79
+ */
80
+ readonly turn: ToolTurn;
43
81
  /**
44
82
  * Runs another agent from inside this tool, wired into the parent run.
45
83
  *
@@ -86,6 +124,72 @@ export interface ToolContext {
86
124
  */
87
125
  runAgent<A extends AnyAgent>(agent: A, params?: RunAgentParams): Promise<NestedRunResult>;
88
126
  }
127
+ /**
128
+ * The files of the turn a tool call belongs to, as data the model cannot write.
129
+ *
130
+ * WHAT THIS FIXES. Every method on `ctx.attachments` takes an id, and before
131
+ * this the only ids a tool could get were the ones the model put in its
132
+ * arguments. So a tool meant to use "the image the user attached" had to trust
133
+ * the model to name it, and a prompt-injected document could name a different
134
+ * upload of the same user's — yesterday's contract instead of today's photo —
135
+ * which the scope check passes, because it is the user's file. Reading the ids
136
+ * from here instead leaves the model nothing to steer.
137
+ *
138
+ * WHICH TURN: THE USER MESSAGE BEFORE THIS CALL, NOT THE LATEST ONE. Found by
139
+ * walking back from the assistant message that made the call, never by taking
140
+ * the last user message in the history when the tool runs, and the difference
141
+ * is re-entry. An escalating tool runs again from the top on a later turn (see
142
+ * `runAgent`), and "latest" is recomputed each time: a turn that answers the
143
+ * sub-agent can carry text or files of its own, and when the re-entered tool
144
+ * asks again, that turn's user message is appended *after* the still-open call
145
+ * — so on the next re-entry "latest" is the answer turn, and a tool that read
146
+ * "the image" would pick a different file, or none, on its second attempt. The
147
+ * replay checks do not reliably catch that: `putMismatch` compares the media
148
+ * type and showModel, never the bytes, and a sub-run seeded with the file as
149
+ * a message part fingerprints as `<file>` whichever file it was. The message
150
+ * that preceded the call is in the history on every attempt and does not
151
+ * move, so every attempt sees the same list.
152
+ *
153
+ * ONE TURN, NOT THE THREAD. The whole thread is what "the image I sent earlier"
154
+ * needs, and it is the wider thing to bind to: a tool that picks "the first
155
+ * image" out of forty turns picks whichever one the history happens to put
156
+ * first, and the user who uploaded a new one sees the old one used. A tool that
157
+ * wants earlier turns can take an id from the model and let the scope check it;
158
+ * one that binds should bind to the turn the user is looking at. A turn with
159
+ * text and no files gives an empty list, which is also the answer to "the user
160
+ * attached nothing this time".
161
+ *
162
+ * NOT THE FILES A TOOL MADE. A file a tool showed with `put(…, { showModel:
163
+ * true })` is injected as a user-role message and carries an `attachmentId`
164
+ * too, and taking it would make it "the user's upload" to the next tool — so
165
+ * the walk steps over every message a tool call's record names as injected,
166
+ * the same test `historyForProvider` uses. A tool that wants what an earlier
167
+ * tool produced has that tool's result to read the id from.
168
+ *
169
+ * IDS ONLY, AND NOT TRUSTED. The name and type beside them on the `FilePart`
170
+ * are what the client said, so they are left off rather than offered as a
171
+ * second, weaker copy of what `ctx.attachments.get(id)` answers from the
172
+ * store. And the ids themselves are only as trustworthy as the history they
173
+ * came from — which, for a stateless client, is whatever it posted. That is
174
+ * fine for the reason everything else about attachments is fine: resolution
175
+ * goes through `ctx.attachments`, whose scope was fixed by the request, so an
176
+ * id from somebody else's upload answers `AttachmentNotFoundError` here
177
+ * exactly as it would from the model's arguments. This list narrows which of
178
+ * the caller's own files a tool reaches for; it grants nothing.
179
+ *
180
+ * Inside a sub-run the turn is the sub-run's own: the message its parent's
181
+ * tool started it with, which has files only if that tool put them there. The
182
+ * parent's upload is not inherited — the tool that called `runAgent` read its
183
+ * own `ctx.turn` and decided what the sub-agent is given.
184
+ */
185
+ export interface ToolTurn {
186
+ /**
187
+ * The `attachmentId`s on that user message's file parts, in order, without
188
+ * duplicates, and only ids of gemi's own shape. Frozen, and computed once
189
+ * before the body runs.
190
+ */
191
+ readonly attachments: readonly string[];
192
+ }
89
193
  /** What `ctx.runAgent` is given. `messages` and `prompt` are alternatives. */
90
194
  export interface RunAgentParams {
91
195
  /** Prior turns for the sub-agent. Starts empty when omitted. */
@@ -435,6 +539,22 @@ export interface AgentStreamParams {
435
539
  * pending call is resolved later; a store keyed by id should upsert.
436
540
  */
437
541
  onMessage?: (message: AgentMessage) => void | Promise<void>;
542
+ /**
543
+ * The attachment handle every tool of this run is given as `ctx.attachments`.
544
+ *
545
+ * Resolved by the controller from the request — `attachmentsFor(req,
546
+ * threadId)` — and passed in rather than reached for, because the scope is a
547
+ * fact about the caller and the run has no way to derive one. `null`, or
548
+ * omitted, is a request with no subject: the object tools get still exists
549
+ * and every method on it throws a sentence naming `attachmentScope()`.
550
+ *
551
+ * Handed down unchanged to a sub-run started by `ctx.runAgent`. A sub-agent
552
+ * is running on behalf of the same caller — that is the only reason it is
553
+ * allowed to run at all — so it reads and writes the same scope, and a tool
554
+ * three levels down can be given an id its parent parked. Widening it here
555
+ * would be the confused-deputy hole in reverse.
556
+ */
557
+ attachments?: ScopedAttachments | null;
438
558
  /**
439
559
  * Set by `ctx.runAgent` and by nothing else.
440
560
  *
@@ -1 +1 @@
1
- {"version":3,"file":"Agent.d.ts","sourceRoot":"","sources":["../../ai/Agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,EACV,aAAa,EAGd,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,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AE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,CAAC,EAAE,eAAe,CAAC;IAErC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAY;IAEnC,OAAO;IAyBP,MAAM,CAAC,MAAM,CACX,KAAK,CAAC,CAAC,SAAS,SAAS,SAAS,EAAE,EACpC,KAAK,CAAC,CAAC,SAAS,SAAS,KAAK,EAAE,EAChC,CAAC,SAAS,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS,GAAG,SAAS,EAC7C,MAAM,EAAE,iBAAiB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAIrD,MAAM,CAAC,MAAM,EAAE,iBAAiB,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;CAY1E;AAED,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;AAEnE,MAAM,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC"}
@@ -2,6 +2,7 @@ import { Controller } from "../http/Controller";
2
2
  import { HttpRequest } from "../http/HttpRequest";
3
3
  import type { MiddlewareInput } from "../http/middlewareList";
4
4
  import type { AgentRun, AgentRunResult, AnyAgent, ToolShapesOf } from "./Agent";
5
+ import { type AttachmentDestination, type AttachmentScope, type AttachmentStorage, type AttachmentStore, ScopedAttachments } from "./store/Attachments";
5
6
  import { FrameCursorEvictedError, liveRuns as defaultLiveRuns, LiveRunNotFoundError, MemoryLiveRuns } from "./store/LiveRuns";
6
7
  import { defaultAgentStore, MemoryAgentStore } from "./store/MemoryAgentStore";
7
8
  import type { AgentError, AgentMessage, PendingToolCall, ToolShapes } from "./types";
@@ -58,6 +59,8 @@ export interface AgentStore {
58
59
  }
59
60
  /** The default: conversations last as long as the process. */
60
61
  export { defaultAgentStore, MemoryAgentStore };
62
+ /** The attachment half of the same story. See `store/Attachments.ts`. */
63
+ export { type Attachment, type AttachmentDestination, AttachmentNotFoundError, type AttachmentScope, type AttachmentStorage, type AttachmentStore, defaultAttachmentStore, InvalidAttachmentScopeError, MemoryAttachmentStore, type PutAttachmentParams, ScopedAttachments, type ToolAttachmentPut, type ToolAttachmentRecord, type ToolAttachments, } from "./store/Attachments";
61
64
  /**
62
65
  * The runs currently in flight, and their frames.
63
66
  *
@@ -96,6 +99,59 @@ export type AgentHookContext = {
96
99
  runId: string;
97
100
  threadId?: string;
98
101
  };
102
+ /**
103
+ * What `POST /<path>/files` answers.
104
+ *
105
+ * TWO IDS, AND THEY ARE NOT INTERCHANGEABLE. `fileId` is the *provider's* id and
106
+ * means exactly what it always meant — the value a `FilePart` carries so the
107
+ * model can see the file. `attachmentId` is *gemi's*, and is the handle a tool
108
+ * resolves through `ScopedAttachments` to get the bytes back. A file can have
109
+ * both, and usually does.
110
+ *
111
+ * `fileId` stays first and stays named that on purpose: `useChat.uploadFile`
112
+ * already reads it, apps already put it in a `FilePart`, and renaming it or
113
+ * folding the two into one id would break vision for every existing app while
114
+ * looking like a tidier API. The two ids exist because there are two systems
115
+ * holding the file.
116
+ *
117
+ * Both are optional, and `destination` says which to expect: `provider` has no
118
+ * `attachmentId` (nothing was kept), `storage` has no `fileId` (the provider
119
+ * never saw it, so there is nothing for a `FilePart` to point at), `both` has
120
+ * both.
121
+ *
122
+ * `destination` ALONE IS NOT ENOUGH TO SAY WHY AN ID IS MISSING, which is why
123
+ * `downgraded` is here. An upload that reached a route with no authentication
124
+ * and no `threadId` answers `destination: "provider"` — truthfully, that is
125
+ * where the bytes went — and so does a controller that deliberately returns
126
+ * `"provider"` from `attachmentDestination`. Those two answers were byte
127
+ * identical, and they are the opposite situations: one is the app's policy
128
+ * working, the other is the app's policy silently not applying because the
129
+ * server could not tell who was calling. The server logs the second one once
130
+ * per process; the client saw nothing at all. `downgraded` is the difference,
131
+ * carried in the answer so a client — or an integration test — can assert on
132
+ * it.
133
+ */
134
+ export type UploadResult = {
135
+ /** The provider's id, for a `FilePart`. Absent when the file never went there. */
136
+ fileId?: string;
137
+ /** gemi's id, for a tool. Absent when nothing was kept — see `attachmentScope`. */
138
+ attachmentId?: string;
139
+ name: string;
140
+ mimeType: string;
141
+ size: number;
142
+ destination: AttachmentDestination;
143
+ /**
144
+ * Set only when the app's policy asked for a copy and the request had no
145
+ * subject to file it under, so the upload fell back to the provider alone.
146
+ * Absent when `destination` is what the app actually chose.
147
+ *
148
+ * A string rather than `true` because there is exactly one reason today and
149
+ * there will be more (a store that refused the write, say), and a boolean
150
+ * that later needs a reason beside it is two fields where one would have
151
+ * done.
152
+ */
153
+ downgraded?: "no_scope";
154
+ };
99
155
  /**
100
156
  * `Controller.kind` is typed as the literal `"controller"`, so a subclass that
101
157
  * declares a `kind` of its own fails the static-side check (TS2417). Widening
@@ -127,6 +183,41 @@ export declare abstract class AgentController<A extends AnyAgent = AnyAgent> ext
127
183
  * done. See `MemoryLiveRuns`.
128
184
  */
129
185
  liveRuns: MemoryLiveRuns;
186
+ /**
187
+ * Where attachment *records* live — the row that says which bytes, whose, and
188
+ * under what id. Defaults to the process-wide `MemoryAttachmentStore`, with
189
+ * the same warning `store` carries: assign something that outlives the
190
+ * request, because this controller is constructed per call.
191
+ */
192
+ attachments: AttachmentStore;
193
+ /**
194
+ * Where an attachment's *bytes* live. Defaults to the app's configured
195
+ * `FileStorage` through the `Storage` facade, which resolves the driver per
196
+ * call out of the container — so an app that configured S3 gets S3 here
197
+ * without saying so twice.
198
+ *
199
+ * Overridable mostly for tests and for an app that keeps user uploads in a
200
+ * different bucket from everything else.
201
+ */
202
+ attachmentStorage: AttachmentStorage;
203
+ /**
204
+ * How long the request that started a run is held open for its hooks, in
205
+ * milliseconds, once the run has settled. The run itself is not bounded
206
+ * here — the request is held for as long as it runs — only the app's code
207
+ * still going after it, from `onMessage` to an `onAwaitingInput` queued
208
+ * behind a slow `onToolCall`.
209
+ *
210
+ * The hooks read the user from that request (`ctx.req.ctx().user`,
211
+ * `Auth.user()`, a policied query), so the request stays open until they are
212
+ * done; but a hook that never settles — a `fetch` with no timeout — would
213
+ * then hold the store, the user and `onRequestEnd` forever, one per turn. Past
214
+ * this the request ends anyway: `onRequestEnd` runs, the user is released,
215
+ * and the hook runs on without one. Thirty seconds is far past a healthy
216
+ * write or notification, so a hook that reaches it is hung rather than slow.
217
+ * Raise it for a hook that is legitimately longer; `Infinity` holds the
218
+ * request until the hooks are done, however long that is.
219
+ */
220
+ protected hookHoldMs: number;
130
221
  /** Appended to the agent's static instructions for this request — the user's
131
222
  * name, tenant, today's date. */
132
223
  instructions(req: HttpRequest<any, any>): string | Promise<string> | void;
@@ -155,13 +246,14 @@ export declare abstract class AgentController<A extends AnyAgent = AnyAgent> ext
155
246
  * for the old run to unwind, which is as long as its slowest tool in flight —
156
247
  * and that wait is the thing that puts `assistant1` before `user2`.
157
248
  *
158
- * The wait is on `persistRun`, not on `run.result()`. `result()` settling is
159
- * the transcript being final, not stored: `appendMessages` runs after it, and
160
- * a `loadThread` in that gap reads a history the old answer is missing from,
161
- * which is the original bug by a shorter route. It is also *only* that:
162
- * `persistRun` settles once the transcript is stored and lets the app's
163
- * hooks run on without it, so a slow `onMessage` is not a slow thread and a
164
- * hung one is not a hung thread.
249
+ * The wait is on `persistRun`'s `stored`, not on `run.result()`. `result()`
250
+ * settling is the transcript being final, not stored: `appendMessages` runs
251
+ * after it, and a `loadThread` in that gap reads a history the old answer is
252
+ * missing from, which is the original bug by a shorter route. It is also
253
+ * *only* that: `stored` settles once the transcript is stored, and the app's
254
+ * hooks run on in `hooks`, which holds the old run's request and not the
255
+ * thread, so a slow `onMessage` is not a slow thread and a hung one is not a
256
+ * hung thread.
165
257
  *
166
258
  * The lock around it is what makes a *third* turn wait for the second rather
167
259
  * than for the first. Two turns arriving together both see the same live
@@ -201,14 +293,151 @@ export declare abstract class AgentController<A extends AnyAgent = AnyAgent> ext
201
293
  stop(req?: HttpRequest<any, any>): Promise<{
202
294
  stopped: boolean;
203
295
  } | Response>;
204
- /** `POST /<path>/files` — uploads an attachment and returns its file id. */
205
- upload(req?: HttpRequest<any, any>): Promise<{
206
- fileId: string;
207
- }>;
296
+ /**
297
+ * WHO A SCOPE BELONGS TO, and the one question in this file whose wrong
298
+ * answer is a data leak rather than a bug.
299
+ *
300
+ * An attachment id given to the model comes back *from* the model, and what
301
+ * the model writes is a function of everything it read — the user's text, a
302
+ * tool's output, a document someone uploaded. So the id is untrusted in
303
+ * exactly the way a request body is, and the scope it resolves under must come
304
+ * from the server's own knowledge of the request. Nothing that reaches this
305
+ * method may be readable or writable by the model: `req` is the HTTP request,
306
+ * and `threadId` is the client's handle, not the model's.
307
+ *
308
+ * THE DEFAULT IS THE AUTHENTICATED USER, falling back to the thread, falling
309
+ * back to `null`.
310
+ *
311
+ * - `user:<id>` when the request is authenticated. `req.ctx().user` is what
312
+ * `AuthenticationMiddleware` and the `Auth` facade put there, so an agent
313
+ * route behind `middlewares = ["auth"]` — which `ApiRouter.agent()` makes
314
+ * the default posture — has a subject without the app writing anything.
315
+ * - `thread:<id>` for an unauthenticated chat that has a thread. A `threadId`
316
+ * is minted by `createThread` as a uuid and is documented as a capability,
317
+ * and `upload` only passes one here that `store.loadThread` finds;
318
+ * an anonymous support widget has nothing better, and scoping to the
319
+ * conversation is strictly narrower than scoping to nothing.
320
+ * - `null` otherwise, which means no attachment id is minted at all. There is
321
+ * no third fallback on purpose. `sessionId()` is the tempting one and it is
322
+ * the wrong one: it is a cookie the visitor writes, documented as *not a
323
+ * credential*, so scoping to it is scoping to a value the caller chooses —
324
+ * which is not a scope, it is a lookup key with extra steps.
325
+ *
326
+ * WHAT THIS DEFAULT GETS WRONG, since it will get something wrong for someone:
327
+ * it is per user, not per conversation, so a user's own upload from one thread
328
+ * resolves in another thread of theirs. That is the loose direction, and it is
329
+ * chosen because the tight one breaks the flow the framework actually ships —
330
+ * `useChat.uploadFile` posts a file before any thread exists, so a per-thread
331
+ * default would make the first upload of every conversation unresolvable. An
332
+ * app that wants per-conversation isolation returns
333
+ * `{ key: \`user:${id}:thread:${threadId}\` }` here and has it; an app with
334
+ * tenants returns `{ key: \`org:${orgId}\` }` and has that. What the default
335
+ * must never be is broader than a user, and it is not.
336
+ *
337
+ * WHATEVER THIS READS MUST BE PRESENT ON EVERY AGENT ROUTE, and the default
338
+ * reads `req.ctx().user`, which is present only where authentication
339
+ * middleware ran. `agent()` mounts four routes and `.middleware()` guards
340
+ * them individually, so `middleware({ stream: "auth" })` — the example in
341
+ * `ApiRouter.agent`'s own doc — leaves `POST /chat/files` unauthenticated.
342
+ * The upload then files the record under `thread:<id>` (or nothing at all)
343
+ * while the run that follows, on the guarded route, resolves under
344
+ * `user:<id>`, and every id minted on upload is a miss for the rest of the
345
+ * conversation. It fails as `AttachmentNotFoundError`, worded identically to
346
+ * an id the model invented, which is the point of that error and is also why
347
+ * this particular misconfiguration is invisible. Guard `upload` and `stream`
348
+ * together, or derive the key from something both of them have.
349
+ *
350
+ * gemi does not detect the skew for you, and the reason is the module's whole
351
+ * premise: noticing that an id exists under a *different* scope requires
352
+ * looking it up without one, and an unscoped read is the thing that must not
353
+ * exist here — not even behind a `console.warn`. So the answer is the
354
+ * documentation you are reading and the identical error, not a probe.
355
+ *
356
+ * The key is opaque and compared with `===`. It is never sent to the client
357
+ * and never shown to the model.
358
+ */
359
+ protected attachmentScope(req: HttpRequest<any, any>, threadId?: string): AttachmentScope | null | Promise<AttachmentScope | null>;
360
+ /**
361
+ * WHERE ONE FILE'S BYTES SHOULD GO. Called once per upload, with the file in
362
+ * hand.
363
+ *
364
+ * The model needs to perceive a file only for vision or document reading; a
365
+ * tool needs the bytes only to forward them. Those are different needs and
366
+ * they were being answered the same way, because `upload` sent everything to
367
+ * the vendor unconditionally — which is a cost and a data-minimisation problem
368
+ * as much as a capability one. A CSV that exists to be imported belongs in
369
+ * storage and not at the provider; an image the model must look at and no tool
370
+ * will forward is the reverse.
371
+ *
372
+ * THE DEFAULT IS `"both"`, AND THE JUSTIFICATION IS THE FAILURE MODE, not the
373
+ * hit rate. A mimeType table was the obvious alternative — images and PDFs to
374
+ * the provider, everything else to storage — and it is wrong in the quiet
375
+ * direction. Getting `"both"` wrong sends a file to a vendor that did not need
376
+ * it: it costs money, it is visible on an invoice and in the vendor's file
377
+ * list, and it is corrected by overriding one method. Getting `"storage"`
378
+ * wrong drops the file out of the model's view with no error anywhere; the
379
+ * model answers as though the image were not there, which is indistinguishable
380
+ * from a bad prompt, and the developer debugs their instructions for an
381
+ * afternoon. Being wrong on the invoice beats being wrong in a way that
382
+ * presents as "the AI is stupid".
383
+ *
384
+ * `"both"` is also what keeps this change additive: every upload that reached
385
+ * the provider before still reaches it, and storage is added underneath. An
386
+ * app that never asks for an attachment id sees no difference except a second
387
+ * copy it owns.
388
+ *
389
+ * A client may ask, per file, for `"storage"` under a `"both"` policy — the
390
+ * one direction that only ever removes the vendor. It may not ask for
391
+ * anything else, including `"provider"`, which would let a form field decide
392
+ * that the app does not keep its own copy. See `narrowDestination`.
393
+ */
394
+ protected attachmentDestination(file: File, req: HttpRequest<any, any>): AttachmentDestination | Promise<AttachmentDestination>;
395
+ /**
396
+ * The attachment handle for this request — the object a tool is given.
397
+ *
398
+ * `null` when `attachmentScope` says the request has no subject, and a caller
399
+ * that gets `null` must not fall back to anything: there is no unscoped handle
400
+ * to fall back to, which is the point.
401
+ *
402
+ * Issue #490 hangs `ctx.attachments` off this.
403
+ */
404
+ protected attachmentsFor(req: HttpRequest<any, any>, threadId?: string): Promise<ScopedAttachments | null>;
405
+ /**
406
+ * `POST /<path>/files` — takes an attachment and answers the handles for it.
407
+ *
408
+ * `fileId` IS STILL IN THE ANSWER AND STILL MEANS THE SAME THING: the
409
+ * provider's id for the file, the thing a `FilePart` carries, unchanged. It
410
+ * has to stay, because it is what makes vision work and what
411
+ * `useChat.uploadFile` already reads; `attachmentId` is added beside it rather
412
+ * than in place of it. The two are not interchangeable, and swapping them
413
+ * would reach the vendor as a file id it has never issued — so
414
+ * `toResponsesInput` rejects a `gemi_att_` prefix in `FilePart.fileId` with a
415
+ * sentence saying so, rather than leaving it to whatever the vendor answers
416
+ * (not measured).
417
+ *
418
+ * `fileId` is absent exactly when the file did not go to the provider, which
419
+ * only happens when the app or the client asked for that. `attachmentId` is
420
+ * absent when there was no scope to file the record under — see
421
+ * `attachmentScope` — and the answer then carries `downgraded: "no_scope"`,
422
+ * which is the only thing separating that case from a controller that chose
423
+ * `"provider"` on purpose. Both answer `destination: "provider"`, because both
424
+ * are true about where the bytes went.
425
+ *
426
+ * ORDER: storage first, then the provider. If the second one fails the request
427
+ * fails either way, so the only question is where the orphan is left, and an
428
+ * orphan in our own bucket is ours to sweep on a schedule we set, while an
429
+ * orphan at the vendor sits under a retention policy that is not ours.
430
+ */
431
+ upload(req?: HttpRequest<any, any>): Promise<UploadResult>;
208
432
  /**
209
433
  * Protected, not private: these exist to be overridden. `onMessage` fires for
210
434
  * every completed message, user and assistant alike, and is the intended
211
435
  * persistence point for an app that is not using `store`.
436
+ *
437
+ * Every hook runs inside the request that started the run, which is held
438
+ * open for them — after the run, and after a client that left — so
439
+ * `ctx.req.ctx().user` is the user who sent the turn. See `hookHoldMs` for
440
+ * how long a hook that does not finish keeps it.
212
441
  */
213
442
  protected onMessage(message: AgentMessage, ctx: AgentHookContext): void | Promise<void>;
214
443
  protected onToolCall(call: {
@@ -247,13 +476,21 @@ export declare abstract class AgentController<A extends AnyAgent = AnyAgent> ext
247
476
  * a finished one does: `stop()` finalizes the transcript, so by the time this
248
477
  * resolves there is a valid history to store.
249
478
  *
250
- * Settles when the transcript is in the store, not when the app is done with
251
- * it. The next turn on this thread waits on this (see `withThread`), and the
252
- * hooks are the app's: an `onMessage` that writes to something slow would
253
- * make every later turn wait for it, once per message of the old run, and
254
- * one that never settles — which `safely` cannot catch — would hold the
255
- * thread, and every turn queued on it, behind an open connection each. So
256
- * the hooks run on after this on their own, reported the same way.
479
+ * `stored` settles when the transcript is in the store, not when the app is
480
+ * done with it. The next turn on this thread waits on that (see
481
+ * `withThread`), and the hooks are the app's: an `onMessage` that writes to
482
+ * something slow would make every later turn wait for it, once per message
483
+ * of the old run, and one that never settles — which `safely` cannot catch —
484
+ * would hold the thread, and every turn queued on it, behind an open
485
+ * connection each. So the hooks run on after it on their own, reported the
486
+ * same way.
487
+ *
488
+ * `hooks` settles once they have too, and every event-stream hook the run
489
+ * led to (`eventHooks`), or after `hookHoldMs` of them, and is what the
490
+ * request that started the run is held open for. Separate from
491
+ * `stored` for the reason above, and it has to exist from the start: by the
492
+ * time the hooks are called the run has settled, and the request with it,
493
+ * unless something was already holding it. Neither rejects.
257
494
  */
258
495
  private persistRun;
259
496
  /** The hooks on a finished run, in order. Never rejects: see `safely`. */
@@ -1 +1 @@
1
- {"version":3,"file":"AgentController.d.ts","sourceRoot":"","sources":["../../ai/AgentController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAChF,OAAO,EACL,uBAAuB,EACvB,QAAQ,IAAI,eAAe,EAC3B,oBAAoB,EACpB,cAAc,EACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE/E,OAAO,KAAK,EACV,UAAU,EACV,YAAY,EAGZ,eAAe,EACf,UAAU,EACX,MAAM,SAAS,CAAC;AAIjB;;;;;;;;GAQG;AACH,MAAM,WAAW,UAA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a,CAAC,CAAC,SAAS,UAAU,eAAe,CAAC,GAAG,CAAC,IAAI;IACpE,OAAO,EAAE,IAAI,CAAC;IACd,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,QAAQ,GAC5C,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,GAC/C,UAAU,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { applyFrame, initialChatState, markAborted } from "./reducer";
2
+ import { SSEFrameDecoder } from "./sse";
3
+ /**
4
+ * `applyFrame`, `markAborted` and `initialChatState`, recording as they run.
5
+ *
6
+ * Identical calls are kept once. The tests fold the same run from scratch many
7
+ * times over, and a corpus of the same case repeated is only slower to replay.
8
+ * The copy kept is named after the alphabetically first test that made the
9
+ * call, not the first to run, so the name does not depend on test order.
10
+ */
11
+ export declare function recordReducer(target: string): {
12
+ applyFrame: typeof applyFrame;
13
+ markAborted: typeof markAborted;
14
+ initialChatState: typeof initialChatState;
15
+ };
16
+ /**
17
+ * An `SSEFrameDecoder` that logs every push and flush with what came out and
18
+ * where the cursor stood after, one case per decoder.
19
+ */
20
+ export declare function recordDecoder(target: string): new () => SSEFrameDecoder;
21
+ //# sourceMappingURL=conformance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conformance.d.ts","sourceRoot":"","sources":["../../../ai/client/conformance.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAgIxC;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM;gBAqClC,OAAO,UAAU;iBAajB,OAAO,WAAW;sBAYlB,OAAO,gBAAgB;EAEhC;AAeD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,eAAe,CAuCvE"}
@@ -68,10 +68,12 @@ function reduce(state, event, now) {
68
68
  const existing = index === -1 ? void 0 : message.content[index];
69
69
  const progress = event.part.progress ?? existing?.progress;
70
70
  const nested = event.part.nested ?? existing?.nested;
71
+ const attachments = event.part.attachments ?? existing?.attachments;
71
72
  const part = {
72
73
  ...event.part,
73
74
  ...progress ? { progress } : {},
74
- ...nested ? { nested } : {}
75
+ ...nested ? { nested } : {},
76
+ ...attachments ? { attachments } : {}
75
77
  };
76
78
  const content = message.content.slice();
77
79
  if (index === -1) content.push(part);
@@ -120,6 +122,18 @@ function reduce(state, event, now) {
120
122
  pending: next.pending.filter((call) => call.toolCallId !== event.part.toolCallId)
121
123
  };
122
124
  }
125
+ case "message": {
126
+ const index = state.messages.findIndex((message) => message.id === event.message.id);
127
+ const messages = state.messages.slice();
128
+ if (index === -1) messages.push(event.message);
129
+ else messages[index] = event.message;
130
+ const runMessageIds = state.runMessageIds.includes(event.message.id) ? state.runMessageIds : [...state.runMessageIds, event.message.id];
131
+ return {
132
+ ...state,
133
+ messages,
134
+ runMessageIds
135
+ };
136
+ }
123
137
  case "awaiting-input": return {
124
138
  ...state,
125
139
  runId: event.runId,
@@ -587,7 +601,8 @@ function turnFrom(message) {
587
601
  for (const part of message.content) {
588
602
  if (part.type === "text") text += part.text;
589
603
  if (part.type === "file") files.push({
590
- fileId: part.fileId,
604
+ ...part.fileId ? { fileId: part.fileId } : {},
605
+ ...part.attachmentId ? { attachmentId: part.attachmentId } : {},
591
606
  name: part.name,
592
607
  mimeType: part.mimeType
593
608
  });
@@ -995,8 +1010,10 @@ function useChat(path, params = {}) {
995
1010
  const data = await response.json();
996
1011
  return {
997
1012
  fileId: data.fileId,
1013
+ attachmentId: data.attachmentId,
998
1014
  name: data.name ?? file.name,
999
- mimeType: data.mimeType ?? file.type
1015
+ mimeType: data.mimeType ?? file.type,
1016
+ downgraded: data.downgraded
1000
1017
  };
1001
1018
  }, [fail]);
1002
1019
  useEffect(() => {