@retinue/agentkit 0.1.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 (405) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +310 -0
  3. package/dist/adapters/bullmq/consumer.d.ts +33 -0
  4. package/dist/adapters/bullmq/consumer.js +41 -0
  5. package/dist/adapters/bullmq/dispatcher.d.ts +74 -0
  6. package/dist/adapters/bullmq/dispatcher.js +160 -0
  7. package/dist/adapters/bullmq/export.d.ts +31 -0
  8. package/dist/adapters/bullmq/export.js +53 -0
  9. package/dist/adapters/bullmq/extraction.d.ts +42 -0
  10. package/dist/adapters/bullmq/extraction.js +63 -0
  11. package/dist/adapters/bullmq/index.d.ts +13 -0
  12. package/dist/adapters/bullmq/index.js +13 -0
  13. package/dist/adapters/bullmq/lock.d.ts +77 -0
  14. package/dist/adapters/bullmq/lock.js +126 -0
  15. package/dist/adapters/bullmq/queue.d.ts +50 -0
  16. package/dist/adapters/bullmq/queue.js +81 -0
  17. package/dist/adapters/memory/artifact-exports.d.ts +11 -0
  18. package/dist/adapters/memory/artifact-exports.js +102 -0
  19. package/dist/adapters/memory/artifacts.d.ts +15 -0
  20. package/dist/adapters/memory/artifacts.js +134 -0
  21. package/dist/adapters/memory/blobs.d.ts +7 -0
  22. package/dist/adapters/memory/blobs.js +27 -0
  23. package/dist/adapters/memory/evaluation.d.ts +18 -0
  24. package/dist/adapters/memory/evaluation.js +148 -0
  25. package/dist/adapters/memory/files.d.ts +27 -0
  26. package/dist/adapters/memory/files.js +0 -0
  27. package/dist/adapters/memory/flows.d.ts +16 -0
  28. package/dist/adapters/memory/flows.js +117 -0
  29. package/dist/adapters/memory/hitl.d.ts +9 -0
  30. package/dist/adapters/memory/hitl.js +130 -0
  31. package/dist/adapters/memory/idempotency.d.ts +13 -0
  32. package/dist/adapters/memory/idempotency.js +32 -0
  33. package/dist/adapters/memory/index.d.ts +39 -0
  34. package/dist/adapters/memory/index.js +107 -0
  35. package/dist/adapters/memory/knowledge.d.ts +43 -0
  36. package/dist/adapters/memory/knowledge.js +248 -0
  37. package/dist/adapters/memory/mcp.d.ts +9 -0
  38. package/dist/adapters/memory/mcp.js +37 -0
  39. package/dist/adapters/memory/message-store.d.ts +17 -0
  40. package/dist/adapters/memory/message-store.js +70 -0
  41. package/dist/adapters/memory/principal-memory.d.ts +7 -0
  42. package/dist/adapters/memory/principal-memory.js +83 -0
  43. package/dist/adapters/memory/runtime.d.ts +29 -0
  44. package/dist/adapters/memory/runtime.js +0 -0
  45. package/dist/adapters/memory/sessions.d.ts +29 -0
  46. package/dist/adapters/memory/sessions.js +0 -0
  47. package/dist/adapters/memory/skills.d.ts +10 -0
  48. package/dist/adapters/memory/skills.js +41 -0
  49. package/dist/adapters/memory/thread-summary.d.ts +7 -0
  50. package/dist/adapters/memory/thread-summary.js +29 -0
  51. package/dist/adapters/memory/usage-limits.d.ts +13 -0
  52. package/dist/adapters/memory/usage-limits.js +72 -0
  53. package/dist/adapters/memory/usage.d.ts +16 -0
  54. package/dist/adapters/memory/usage.js +279 -0
  55. package/dist/adapters/otel/index.d.ts +111 -0
  56. package/dist/adapters/otel/index.js +133 -0
  57. package/dist/adapters/postgres/artifact-exports.d.ts +12 -0
  58. package/dist/adapters/postgres/artifact-exports.js +117 -0
  59. package/dist/adapters/postgres/artifacts.d.ts +16 -0
  60. package/dist/adapters/postgres/artifacts.js +172 -0
  61. package/dist/adapters/postgres/checkpoint-store.d.ts +16 -0
  62. package/dist/adapters/postgres/checkpoint-store.js +34 -0
  63. package/dist/adapters/postgres/config.d.ts +15 -0
  64. package/dist/adapters/postgres/config.js +187 -0
  65. package/dist/adapters/postgres/conversation-store.d.ts +4 -0
  66. package/dist/adapters/postgres/conversation-store.js +82 -0
  67. package/dist/adapters/postgres/evaluation.d.ts +17 -0
  68. package/dist/adapters/postgres/evaluation.js +193 -0
  69. package/dist/adapters/postgres/file-content.d.ts +30 -0
  70. package/dist/adapters/postgres/file-content.js +111 -0
  71. package/dist/adapters/postgres/files.d.ts +19 -0
  72. package/dist/adapters/postgres/files.js +209 -0
  73. package/dist/adapters/postgres/flows.d.ts +20 -0
  74. package/dist/adapters/postgres/flows.js +206 -0
  75. package/dist/adapters/postgres/hitl.d.ts +5 -0
  76. package/dist/adapters/postgres/hitl.js +247 -0
  77. package/dist/adapters/postgres/index.d.ts +35 -0
  78. package/dist/adapters/postgres/index.js +35 -0
  79. package/dist/adapters/postgres/knowledge.d.ts +48 -0
  80. package/dist/adapters/postgres/knowledge.js +255 -0
  81. package/dist/adapters/postgres/memory.d.ts +14 -0
  82. package/dist/adapters/postgres/memory.js +194 -0
  83. package/dist/adapters/postgres/message-store.d.ts +11 -0
  84. package/dist/adapters/postgres/message-store.js +145 -0
  85. package/dist/adapters/postgres/migrations.d.ts +69 -0
  86. package/dist/adapters/postgres/migrations.js +1594 -0
  87. package/dist/adapters/postgres/pg-executor.d.ts +19 -0
  88. package/dist/adapters/postgres/pg-executor.js +32 -0
  89. package/dist/adapters/postgres/retention.d.ts +26 -0
  90. package/dist/adapters/postgres/retention.js +59 -0
  91. package/dist/adapters/postgres/rollups.d.ts +17 -0
  92. package/dist/adapters/postgres/rollups.js +267 -0
  93. package/dist/adapters/postgres/run-coordinator.d.ts +5 -0
  94. package/dist/adapters/postgres/run-coordinator.js +98 -0
  95. package/dist/adapters/postgres/run-event-log.d.ts +26 -0
  96. package/dist/adapters/postgres/run-event-log.js +30 -0
  97. package/dist/adapters/postgres/run-store.d.ts +4 -0
  98. package/dist/adapters/postgres/run-store.js +199 -0
  99. package/dist/adapters/postgres/schema.d.ts +39 -0
  100. package/dist/adapters/postgres/schema.js +70 -0
  101. package/dist/adapters/postgres/session-state.d.ts +7 -0
  102. package/dist/adapters/postgres/session-state.js +99 -0
  103. package/dist/adapters/postgres/sql.d.ts +8 -0
  104. package/dist/adapters/postgres/sql.js +2 -0
  105. package/dist/adapters/postgres/transaction.d.ts +37 -0
  106. package/dist/adapters/postgres/transaction.js +93 -0
  107. package/dist/adapters/postgres/unit-of-work.d.ts +18 -0
  108. package/dist/adapters/postgres/unit-of-work.js +8 -0
  109. package/dist/adapters/postgres/usage-limits.d.ts +15 -0
  110. package/dist/adapters/postgres/usage-limits.js +136 -0
  111. package/dist/adapters/postgres/usage.d.ts +15 -0
  112. package/dist/adapters/postgres/usage.js +226 -0
  113. package/dist/adapters/redis/index.d.ts +9 -0
  114. package/dist/adapters/redis/index.js +9 -0
  115. package/dist/adapters/redis/realtime.d.ts +74 -0
  116. package/dist/adapters/redis/realtime.js +112 -0
  117. package/dist/adapters/supabase/index.d.ts +88 -0
  118. package/dist/adapters/supabase/index.js +84 -0
  119. package/dist/adapters/supabase/realtime.d.ts +30 -0
  120. package/dist/adapters/supabase/realtime.js +53 -0
  121. package/dist/adapters/supabase/rls.d.ts +99 -0
  122. package/dist/adapters/supabase/rls.js +216 -0
  123. package/dist/adapters/supabase/storage.d.ts +50 -0
  124. package/dist/adapters/supabase/storage.js +207 -0
  125. package/dist/agents/agent.d.ts +66 -0
  126. package/dist/agents/agent.js +209 -0
  127. package/dist/agents/define.d.ts +21 -0
  128. package/dist/agents/define.js +63 -0
  129. package/dist/agents/engine.d.ts +98 -0
  130. package/dist/agents/engine.js +462 -0
  131. package/dist/agents/index.d.ts +50 -0
  132. package/dist/agents/index.js +17 -0
  133. package/dist/artifacts/index.d.ts +114 -0
  134. package/dist/artifacts/index.js +219 -0
  135. package/dist/authorization/index.d.ts +76 -0
  136. package/dist/authorization/index.js +76 -0
  137. package/dist/capabilities/index.d.ts +120 -0
  138. package/dist/capabilities/index.js +167 -0
  139. package/dist/capabilities/runtime.d.ts +89 -0
  140. package/dist/capabilities/runtime.js +84 -0
  141. package/dist/citations/index.d.ts +161 -0
  142. package/dist/citations/index.js +182 -0
  143. package/dist/context/assembler.d.ts +82 -0
  144. package/dist/context/assembler.js +129 -0
  145. package/dist/context/compaction.d.ts +45 -0
  146. package/dist/context/compaction.js +55 -0
  147. package/dist/context/index.d.ts +75 -0
  148. package/dist/context/index.js +17 -0
  149. package/dist/core/content-parts.d.ts +194 -0
  150. package/dist/core/content-parts.js +23 -0
  151. package/dist/core/context.d.ts +51 -0
  152. package/dist/core/context.js +9 -0
  153. package/dist/core/env.d.ts +25 -0
  154. package/dist/core/env.js +41 -0
  155. package/dist/core/errors.d.ts +30 -0
  156. package/dist/core/errors.js +65 -0
  157. package/dist/core/events.d.ts +139 -0
  158. package/dist/core/events.js +99 -0
  159. package/dist/core/ids.d.ts +52 -0
  160. package/dist/core/ids.js +13 -0
  161. package/dist/core/index.d.ts +9 -0
  162. package/dist/core/index.js +9 -0
  163. package/dist/core/tokens.d.ts +22 -0
  164. package/dist/core/tokens.js +22 -0
  165. package/dist/core/validation.d.ts +34 -0
  166. package/dist/core/validation.js +176 -0
  167. package/dist/documents/extraction.d.ts +121 -0
  168. package/dist/documents/extraction.js +293 -0
  169. package/dist/documents/index.d.ts +199 -0
  170. package/dist/documents/index.js +65 -0
  171. package/dist/documents/parsers/pdf.d.ts +47 -0
  172. package/dist/documents/parsers/pdf.js +508 -0
  173. package/dist/documents/parsers/text.d.ts +59 -0
  174. package/dist/documents/parsers/text.js +325 -0
  175. package/dist/documents/read-tool.d.ts +52 -0
  176. package/dist/documents/read-tool.js +109 -0
  177. package/dist/documents/render.d.ts +29 -0
  178. package/dist/documents/render.js +59 -0
  179. package/dist/documents/vision.d.ts +159 -0
  180. package/dist/documents/vision.js +214 -0
  181. package/dist/entries/adapters-bullmq.d.ts +8 -0
  182. package/dist/entries/adapters-bullmq.js +8 -0
  183. package/dist/entries/adapters-otel.d.ts +13 -0
  184. package/dist/entries/adapters-otel.js +13 -0
  185. package/dist/entries/adapters-postgres.d.ts +10 -0
  186. package/dist/entries/adapters-postgres.js +10 -0
  187. package/dist/entries/adapters-redis.d.ts +3 -0
  188. package/dist/entries/adapters-redis.js +3 -0
  189. package/dist/entries/context.d.ts +20 -0
  190. package/dist/entries/context.js +20 -0
  191. package/dist/entries/flows.d.ts +15 -0
  192. package/dist/entries/flows.js +15 -0
  193. package/dist/entries/hitl.d.ts +10 -0
  194. package/dist/entries/hitl.js +10 -0
  195. package/dist/entries/knowledge.d.ts +18 -0
  196. package/dist/entries/knowledge.js +19 -0
  197. package/dist/entries/mcp.d.ts +10 -0
  198. package/dist/entries/mcp.js +10 -0
  199. package/dist/entries/observability.d.ts +14 -0
  200. package/dist/entries/observability.js +16 -0
  201. package/dist/entries/persistence.d.ts +11 -0
  202. package/dist/entries/persistence.js +11 -0
  203. package/dist/entries/providers.d.ts +14 -0
  204. package/dist/entries/providers.js +14 -0
  205. package/dist/entries/runtime.d.ts +13 -0
  206. package/dist/entries/runtime.js +13 -0
  207. package/dist/entries/server.d.ts +24 -0
  208. package/dist/entries/server.js +24 -0
  209. package/dist/entries/tools.d.ts +21 -0
  210. package/dist/entries/tools.js +21 -0
  211. package/dist/entries/usage.d.ts +10 -0
  212. package/dist/entries/usage.js +10 -0
  213. package/dist/evaluation/gate.d.ts +168 -0
  214. package/dist/evaluation/gate.js +180 -0
  215. package/dist/evaluation/graders.d.ts +125 -0
  216. package/dist/evaluation/graders.js +203 -0
  217. package/dist/evaluation/index.d.ts +120 -0
  218. package/dist/evaluation/index.js +183 -0
  219. package/dist/evaluation/judge.d.ts +75 -0
  220. package/dist/evaluation/judge.js +111 -0
  221. package/dist/export/index.d.ts +162 -0
  222. package/dist/export/index.js +363 -0
  223. package/dist/export/markdown.d.ts +19 -0
  224. package/dist/export/markdown.js +29 -0
  225. package/dist/export/pdf.d.ts +73 -0
  226. package/dist/export/pdf.js +407 -0
  227. package/dist/files/context.d.ts +97 -0
  228. package/dist/files/context.js +185 -0
  229. package/dist/files/index.d.ts +210 -0
  230. package/dist/files/index.js +338 -0
  231. package/dist/files/read-tool.d.ts +81 -0
  232. package/dist/files/read-tool.js +163 -0
  233. package/dist/files/turn-parts.d.ts +96 -0
  234. package/dist/files/turn-parts.js +171 -0
  235. package/dist/flows/index.d.ts +270 -0
  236. package/dist/flows/index.js +62 -0
  237. package/dist/flows/interpreter.d.ts +146 -0
  238. package/dist/flows/interpreter.js +426 -0
  239. package/dist/flows/runner.d.ts +145 -0
  240. package/dist/flows/runner.js +270 -0
  241. package/dist/graphql/index.d.ts +8 -0
  242. package/dist/graphql/index.js +8 -0
  243. package/dist/graphql/resolvers.d.ts +237 -0
  244. package/dist/graphql/resolvers.js +253 -0
  245. package/dist/graphql/schema.d.ts +11 -0
  246. package/dist/graphql/schema.js +258 -0
  247. package/dist/graphql/sse.d.ts +77 -0
  248. package/dist/graphql/sse.js +100 -0
  249. package/dist/hitl/approved-execution.d.ts +127 -0
  250. package/dist/hitl/approved-execution.js +177 -0
  251. package/dist/hitl/index.d.ts +79 -0
  252. package/dist/hitl/index.js +12 -0
  253. package/dist/hitl/service.d.ts +221 -0
  254. package/dist/hitl/service.js +268 -0
  255. package/dist/idempotency/index.d.ts +70 -0
  256. package/dist/idempotency/index.js +59 -0
  257. package/dist/index.d.ts +103 -0
  258. package/dist/index.js +60 -0
  259. package/dist/knowledge/chunking.d.ts +57 -0
  260. package/dist/knowledge/chunking.js +158 -0
  261. package/dist/knowledge/index.d.ts +119 -0
  262. package/dist/knowledge/index.js +166 -0
  263. package/dist/knowledge/retrieval.d.ts +146 -0
  264. package/dist/knowledge/retrieval.js +170 -0
  265. package/dist/loadtest/harness.d.ts +168 -0
  266. package/dist/loadtest/harness.js +507 -0
  267. package/dist/loadtest/index.d.ts +13 -0
  268. package/dist/loadtest/index.js +13 -0
  269. package/dist/loadtest/injection.d.ts +89 -0
  270. package/dist/loadtest/injection.js +147 -0
  271. package/dist/loadtest/metrics.d.ts +197 -0
  272. package/dist/loadtest/metrics.js +160 -0
  273. package/dist/loadtest/runbooks.d.ts +28 -0
  274. package/dist/loadtest/runbooks.js +159 -0
  275. package/dist/loadtest/scenario.d.ts +104 -0
  276. package/dist/loadtest/scenario.js +208 -0
  277. package/dist/mcp/egress.d.ts +53 -0
  278. package/dist/mcp/egress.js +115 -0
  279. package/dist/mcp/index.d.ts +93 -0
  280. package/dist/mcp/index.js +33 -0
  281. package/dist/mcp/provider.d.ts +62 -0
  282. package/dist/mcp/provider.js +0 -0
  283. package/dist/models/index.d.ts +98 -0
  284. package/dist/models/index.js +74 -0
  285. package/dist/models/pricing.d.ts +24 -0
  286. package/dist/models/pricing.js +37 -0
  287. package/dist/models/provider-factory.d.ts +31 -0
  288. package/dist/models/provider-factory.js +67 -0
  289. package/dist/models/streaming.d.ts +145 -0
  290. package/dist/models/streaming.js +272 -0
  291. package/dist/models/vision.d.ts +38 -0
  292. package/dist/models/vision.js +62 -0
  293. package/dist/persistence/index.d.ts +1654 -0
  294. package/dist/persistence/index.js +226 -0
  295. package/dist/principal-memory/index.d.ts +106 -0
  296. package/dist/principal-memory/index.js +89 -0
  297. package/dist/retention/index.d.ts +89 -0
  298. package/dist/retention/index.js +70 -0
  299. package/dist/runtime/checkpoint.d.ts +37 -0
  300. package/dist/runtime/checkpoint.js +22 -0
  301. package/dist/runtime/index.d.ts +118 -0
  302. package/dist/runtime/index.js +69 -0
  303. package/dist/runtime/retry.d.ts +95 -0
  304. package/dist/runtime/retry.js +126 -0
  305. package/dist/runtime/serialization.d.ts +85 -0
  306. package/dist/runtime/serialization.js +95 -0
  307. package/dist/runtime/streaming.d.ts +54 -0
  308. package/dist/runtime/streaming.js +115 -0
  309. package/dist/runtime/worker.d.ts +130 -0
  310. package/dist/runtime/worker.js +405 -0
  311. package/dist/security/checklist.d.ts +53 -0
  312. package/dist/security/checklist.js +204 -0
  313. package/dist/security/findings.d.ts +56 -0
  314. package/dist/security/findings.js +168 -0
  315. package/dist/security/index.d.ts +14 -0
  316. package/dist/security/index.js +14 -0
  317. package/dist/security/prompt-safety.d.ts +100 -0
  318. package/dist/security/prompt-safety.js +133 -0
  319. package/dist/server/boot.d.ts +32 -0
  320. package/dist/server/boot.js +36 -0
  321. package/dist/server/cli-worker.d.ts +37 -0
  322. package/dist/server/cli-worker.js +151 -0
  323. package/dist/server/cli.d.ts +27 -0
  324. package/dist/server/cli.js +74 -0
  325. package/dist/server/config.d.ts +42 -0
  326. package/dist/server/config.js +127 -0
  327. package/dist/server/health.d.ts +59 -0
  328. package/dist/server/health.js +90 -0
  329. package/dist/server/host.d.ts +39 -0
  330. package/dist/server/host.js +124 -0
  331. package/dist/server/index.d.ts +15 -0
  332. package/dist/server/index.js +15 -0
  333. package/dist/server/main.d.ts +16 -0
  334. package/dist/server/main.js +31 -0
  335. package/dist/server/sse-route.d.ts +21 -0
  336. package/dist/server/sse-route.js +282 -0
  337. package/dist/skills/index.d.ts +67 -0
  338. package/dist/skills/index.js +31 -0
  339. package/dist/skills/resolver.d.ts +54 -0
  340. package/dist/skills/resolver.js +121 -0
  341. package/dist/teams/index.d.ts +93 -0
  342. package/dist/teams/index.js +207 -0
  343. package/dist/telemetry/index.d.ts +157 -0
  344. package/dist/telemetry/index.js +71 -0
  345. package/dist/telemetry/instrument.d.ts +108 -0
  346. package/dist/telemetry/instrument.js +232 -0
  347. package/dist/telemetry/log-events.d.ts +17 -0
  348. package/dist/telemetry/log-events.js +58 -0
  349. package/dist/telemetry/metrics.d.ts +123 -0
  350. package/dist/telemetry/metrics.js +135 -0
  351. package/dist/telemetry/noop.d.ts +39 -0
  352. package/dist/telemetry/noop.js +143 -0
  353. package/dist/telemetry/redaction.d.ts +64 -0
  354. package/dist/telemetry/redaction.js +153 -0
  355. package/dist/telemetry/spans.d.ts +56 -0
  356. package/dist/telemetry/spans.js +78 -0
  357. package/dist/telemetry/trace-context.d.ts +55 -0
  358. package/dist/telemetry/trace-context.js +60 -0
  359. package/dist/toolkit/compute.d.ts +53 -0
  360. package/dist/toolkit/compute.js +152 -0
  361. package/dist/toolkit/data.d.ts +98 -0
  362. package/dist/toolkit/data.js +235 -0
  363. package/dist/toolkit/http.d.ts +113 -0
  364. package/dist/toolkit/http.js +205 -0
  365. package/dist/toolkit/index.d.ts +21 -0
  366. package/dist/toolkit/index.js +17 -0
  367. package/dist/toolkit/web.d.ts +107 -0
  368. package/dist/toolkit/web.js +147 -0
  369. package/dist/tools/define.d.ts +25 -0
  370. package/dist/tools/define.js +45 -0
  371. package/dist/tools/delegating.d.ts +132 -0
  372. package/dist/tools/delegating.js +211 -0
  373. package/dist/tools/index.d.ts +129 -0
  374. package/dist/tools/index.js +33 -0
  375. package/dist/tools/library/compute.d.ts +11 -0
  376. package/dist/tools/library/compute.js +46 -0
  377. package/dist/tools/library/data.d.ts +16 -0
  378. package/dist/tools/library/data.js +92 -0
  379. package/dist/tools/library/http.d.ts +28 -0
  380. package/dist/tools/library/http.js +71 -0
  381. package/dist/tools/library/index.d.ts +97 -0
  382. package/dist/tools/library/index.js +134 -0
  383. package/dist/tools/library/knowledge.d.ts +39 -0
  384. package/dist/tools/library/knowledge.js +58 -0
  385. package/dist/tools/library/web.d.ts +19 -0
  386. package/dist/tools/library/web.js +65 -0
  387. package/dist/tools/meta-tools.d.ts +19 -0
  388. package/dist/tools/meta-tools.js +36 -0
  389. package/dist/tools/registry.d.ts +146 -0
  390. package/dist/tools/registry.js +291 -0
  391. package/dist/usage/index.d.ts +105 -0
  392. package/dist/usage/index.js +20 -0
  393. package/dist/usage/quota.d.ts +258 -0
  394. package/dist/usage/quota.js +510 -0
  395. package/dist/usage/recorder.d.ts +29 -0
  396. package/dist/usage/recorder.js +96 -0
  397. package/dist/usage/rollups.d.ts +121 -0
  398. package/dist/usage/rollups.js +157 -0
  399. package/dist/worker/export.d.ts +57 -0
  400. package/dist/worker/export.js +81 -0
  401. package/dist/worker/extraction.d.ts +57 -0
  402. package/dist/worker/extraction.js +84 -0
  403. package/dist/worker/main.d.ts +103 -0
  404. package/dist/worker/main.js +159 -0
  405. package/package.json +187 -0
@@ -0,0 +1,145 @@
1
+ /**
2
+ * The durable driver — REQ-038 (#187).
3
+ *
4
+ * `advance` decides; this performs. The loop is: ask the interpreter for an effect, perform it, **persist**, and
5
+ * ask again — until the execution settles or parks. Persisting between every step is the whole of the durability
6
+ * story: a crash anywhere in the loop leaves a stored execution that `resume` can pick up, and because the
7
+ * interpreter is pure there is nothing else that was in flight.
8
+ *
9
+ * ## Persist after performing, not before
10
+ *
11
+ * The order matters and is worth stating, because both orders look reasonable. Persisting *before* performing
12
+ * would record a step as complete that might not happen — a crash then skips it, silently. Persisting *after*
13
+ * means a crash re-asks for the same effect, with the same idempotency key, and the idempotency store answers
14
+ * with the first result. So the failure mode is a duplicate *attempt*, which the key absorbs, rather than a
15
+ * skipped step, which nothing detects.
16
+ *
17
+ * That is why the key is derived from `(executionId, step, attempt)` rather than generated: a generated key would
18
+ * be new on every resume and the "duplicate attempt" would become a duplicate *effect*.
19
+ */
20
+ import type { StepOutcome } from "./interpreter.js";
21
+ import type { FlowExecution } from "./index.js";
22
+ import type { FlowDefinitionStore, FlowExecutionStore } from "../persistence/index.js";
23
+ import type { ExecutionContext } from "../core/context.js";
24
+ /**
25
+ * What a host has to be able to do for a flow to run.
26
+ *
27
+ * Ports, not a class: the platform cannot know how a deployment runs an agent or asks a person, and every one of
28
+ * these is something the deployment already does for its assistant surface. A flow is composition over them, not
29
+ * a second way of doing them.
30
+ */
31
+ export type FlowEffectHandler = {
32
+ /**
33
+ * Run an agent step.
34
+ *
35
+ * A handler that creates a **child run** returns `parked-on-run` and the flow waits for it; one that runs a
36
+ * turn inline returns `ok`. Both are legal, and the first is what #202 is for: a child run earns
37
+ * checkpointing, recovery, quota admission and its own usage rows, and an inline turn earns none of them.
38
+ *
39
+ * `budgetRemaining` is what the flow has left, re-derived per step. A child given its own independent ceiling
40
+ * is a member that can outspend the team.
41
+ */
42
+ runAgent(context: ExecutionContext, input: {
43
+ readonly agentId: string;
44
+ readonly prompt: string;
45
+ readonly instructions?: string;
46
+ readonly idempotencyKey: string;
47
+ readonly budgetRemaining: {
48
+ readonly steps: number;
49
+ readonly costMinorUnits?: number;
50
+ readonly wallClockMs?: number;
51
+ };
52
+ readonly member?: string;
53
+ }): Promise<StepOutcome>;
54
+ callTool(context: ExecutionContext, input: {
55
+ readonly tool: string;
56
+ readonly input: Readonly<Record<string, unknown>>;
57
+ readonly idempotencyKey: string;
58
+ }): Promise<StepOutcome>;
59
+ /** Raises a question through the *existing* HITL path and returns `parked` with the interaction it raised. */
60
+ askHuman(context: ExecutionContext, input: {
61
+ readonly question: string;
62
+ readonly options?: readonly string[];
63
+ }): Promise<StepOutcome>;
64
+ /** A team, which is a compiled flow — so a handler may simply call the runner again. */
65
+ runTeam?(context: ExecutionContext, input: {
66
+ readonly teamId: string;
67
+ readonly prompt: string;
68
+ readonly idempotencyKey: string;
69
+ }): Promise<StepOutcome>;
70
+ runSubflow?(context: ExecutionContext, input: {
71
+ readonly flowId: string;
72
+ readonly depth: number;
73
+ readonly idempotencyKey: string;
74
+ }): Promise<StepOutcome>;
75
+ };
76
+ export type FlowRunnerDeps = {
77
+ readonly definitions: FlowDefinitionStore;
78
+ readonly executions: FlowExecutionStore;
79
+ readonly handler: FlowEffectHandler;
80
+ readonly clock?: () => Date;
81
+ readonly idFactory?: () => string;
82
+ /**
83
+ * How a child run's terminal state is read — #202.
84
+ *
85
+ * Optional, and its absence is why `resume` can only *poll* when it is present: a deployment that runs agent
86
+ * steps inline never parks on a run and needs none of this. Supplied, it is what makes the wake-up correct
87
+ * rather than dependent on a notification arriving — a crash between the child completing and the parent being
88
+ * told loses the message, and nothing would ever look again.
89
+ */
90
+ readonly runs?: {
91
+ findById(input: {
92
+ readonly tenantId: ExecutionContext["tenantId"];
93
+ readonly id: string;
94
+ }): Promise<{
95
+ readonly status: string;
96
+ readonly error?: {
97
+ readonly message: string;
98
+ };
99
+ } | null>;
100
+ };
101
+ /**
102
+ * How many effects one call may perform before returning.
103
+ *
104
+ * Not a duplicate of the flow's step budget — that is the flow's own ceiling and this is the *worker's*. A long
105
+ * flow should be able to hand its worker slot back and be picked up again rather than holding it for an hour,
106
+ * and without this the two concerns share one number.
107
+ */
108
+ readonly maxEffectsPerCall?: number;
109
+ };
110
+ export type RunResult = {
111
+ readonly execution: FlowExecution;
112
+ /** Why this call stopped: the flow settled, it parked, or the worker's slice ran out. */
113
+ readonly stopped: "settled" | "waiting" | "slice-exhausted";
114
+ };
115
+ export declare const createFlowRunner: (deps: FlowRunnerDeps) => {
116
+ /** Start a flow at its latest version, pinning that version for this execution's whole life. */
117
+ start(context: ExecutionContext, input: {
118
+ readonly flowId: string;
119
+ readonly runId: FlowExecution["runId"];
120
+ readonly state?: Readonly<Record<string, unknown>>;
121
+ readonly depth?: number;
122
+ }): Promise<RunResult>;
123
+ /** Continue a stored execution — after a restart, or after a slice ran out. */
124
+ resume(context: ExecutionContext, executionId: string): Promise<RunResult>;
125
+ /**
126
+ * Deliver an answer or a signal to a parked execution.
127
+ *
128
+ * The value goes through the interpreter as a `resumed` outcome, so the parked step's `assignTo` receives it
129
+ * exactly as any other step's result would. A separate "apply an answer" path would be a second way to write
130
+ * state, and the two would eventually disagree about where an answer lands.
131
+ */
132
+ resumeWith(context: ExecutionContext, executionId: string, value: unknown): Promise<RunResult>;
133
+ /**
134
+ * A child run settled — #202.
135
+ *
136
+ * The fast path. Correctness does not depend on it: `drive` polls the child's state on every resume, so a
137
+ * lost notification costs latency rather than a stuck flow. Returns `null` when no execution was waiting for
138
+ * this run, which is the common case in a deployment where most runs are chat turns.
139
+ */
140
+ notifyRunFinished(context: ExecutionContext, runId: FlowExecution["runId"]): Promise<RunResult | null>;
141
+ /** Everything parked on a signal, so delivering one can wake what was waiting. */
142
+ deliverSignal(context: ExecutionContext, signal: string, value?: unknown): Promise<readonly RunResult[]>;
143
+ };
144
+ export type FlowRunner = ReturnType<typeof createFlowRunner>;
145
+ //# sourceMappingURL=runner.d.ts.map
@@ -0,0 +1,270 @@
1
+ /**
2
+ * The durable driver — REQ-038 (#187).
3
+ *
4
+ * `advance` decides; this performs. The loop is: ask the interpreter for an effect, perform it, **persist**, and
5
+ * ask again — until the execution settles or parks. Persisting between every step is the whole of the durability
6
+ * story: a crash anywhere in the loop leaves a stored execution that `resume` can pick up, and because the
7
+ * interpreter is pure there is nothing else that was in flight.
8
+ *
9
+ * ## Persist after performing, not before
10
+ *
11
+ * The order matters and is worth stating, because both orders look reasonable. Persisting *before* performing
12
+ * would record a step as complete that might not happen — a crash then skips it, silently. Persisting *after*
13
+ * means a crash re-asks for the same effect, with the same idempotency key, and the idempotency store answers
14
+ * with the first result. So the failure mode is a duplicate *attempt*, which the key absorbs, rather than a
15
+ * skipped step, which nothing detects.
16
+ *
17
+ * That is why the key is derived from `(executionId, step, attempt)` rather than generated: a generated key would
18
+ * be new on every resume and the "duplicate attempt" would become a duplicate *effect*.
19
+ */
20
+ import { AgentPlatformError } from "../core/errors.js";
21
+ import { advance, beginExecution } from "./interpreter.js";
22
+ const toStored = (execution) => ({
23
+ id: execution.id,
24
+ flowId: execution.flowId,
25
+ flowVersion: execution.flowVersion,
26
+ runId: execution.runId,
27
+ status: execution.status,
28
+ currentStep: execution.currentStep,
29
+ steps: execution.spend.steps,
30
+ execution,
31
+ ...(execution.waitingFor?.kind === "signal" ? { waitingSignal: execution.waitingFor.signal } : {}),
32
+ ...(execution.waitingFor?.kind === "run" ? { waitingRunId: execution.waitingFor.runId } : {}),
33
+ startedAt: execution.startedAt,
34
+ ...(execution.finishedAt === undefined ? {} : { finishedAt: execution.finishedAt }),
35
+ });
36
+ export const createFlowRunner = (deps) => {
37
+ const clock = deps.clock ?? (() => new Date());
38
+ const newId = deps.idFactory ?? (() => `flowexec-${crypto.randomUUID()}`);
39
+ const slice = deps.maxEffectsPerCall ?? 50;
40
+ /** Read the definition **at the execution's pinned version**, never the latest. */
41
+ const definitionFor = async (context, execution) => {
42
+ const stored = await deps.definitions.get({
43
+ tenantId: context.tenantId,
44
+ flowId: execution.flowId,
45
+ version: execution.flowVersion,
46
+ });
47
+ if (stored === null) {
48
+ /**
49
+ * A definition that has gone missing under a running execution.
50
+ *
51
+ * Refused rather than falling back to `latest`, which is the tempting repair and the wrong one: the whole
52
+ * point of pinning is that the execution runs the shape it started with, and silently running a *different*
53
+ * shape is worse than stopping.
54
+ */
55
+ throw new AgentPlatformError({
56
+ code: "not_found",
57
+ message: `flow ${execution.flowId} version ${execution.flowVersion} is not stored; execution ${execution.id} cannot continue on a different version`,
58
+ retryable: false,
59
+ });
60
+ }
61
+ return stored.definition;
62
+ };
63
+ const perform = async (context, effect) => {
64
+ switch (effect.kind) {
65
+ case "run-agent":
66
+ return deps.handler.runAgent(context, effect);
67
+ case "call-tool":
68
+ return deps.handler.callTool(context, effect);
69
+ case "ask-human":
70
+ return deps.handler.askHuman(context, effect);
71
+ case "run-team":
72
+ if (deps.handler.runTeam === undefined) {
73
+ // Named, and not a generic failure: a flow with a team step in a deployment that wired no team handler
74
+ // is a wiring problem, and "unsupported step" would send someone reading the interpreter.
75
+ return { kind: "failed", error: "this deployment has no team handler wired, so a team step cannot run" };
76
+ }
77
+ return deps.handler.runTeam(context, effect);
78
+ case "run-subflow":
79
+ if (deps.handler.runSubflow === undefined) {
80
+ return { kind: "failed", error: "this deployment has no subflow handler wired" };
81
+ }
82
+ return deps.handler.runSubflow(context, effect);
83
+ case "sleep":
84
+ /**
85
+ * Not slept through.
86
+ *
87
+ * A worker that blocks for a flow's `wait` is a worker holding a slot for something with no work in it —
88
+ * and a wait measured in hours would hold it for hours. `untilMs` is stored on the execution, so whatever
89
+ * wakes flows up reads it; a zero-length sleep (the retry backoff case) simply continues.
90
+ */
91
+ return effect.untilMs <= clock().getTime() ? { kind: "resumed" } : null;
92
+ case "await-signal":
93
+ return null;
94
+ case "settled":
95
+ return null;
96
+ default: {
97
+ const unreachable = effect;
98
+ throw new AgentPlatformError({ code: "internal", message: `unhandled effect ${JSON.stringify(unreachable)}`, retryable: false });
99
+ }
100
+ }
101
+ };
102
+ /**
103
+ * Has the child run this execution is parked on finished?
104
+ *
105
+ * The poll half of the wake-up. `notifyRunFinished` is the fast path and this is the correct one: a parent that
106
+ * only ever woke on a notification would sit forever if the process died between the child settling and the
107
+ * message being sent. Called at the top of `drive`, so any resume — a worker sweep, an operator, a retry —
108
+ * notices.
109
+ */
110
+ const childOutcome = async (context, execution) => {
111
+ if (execution.waitingFor?.kind !== "run" || deps.runs === undefined)
112
+ return null;
113
+ const child = await deps.runs.findById({ tenantId: context.tenantId, id: execution.waitingFor.runId });
114
+ if (child === null) {
115
+ // A parked parent whose child does not exist. Failing is the only honest answer: waiting forever for
116
+ // something that was never created is the shape of a stuck automation nobody can explain.
117
+ return { kind: "failed", error: `child run ${execution.waitingFor.runId} does not exist` };
118
+ }
119
+ if (child.status === "completed")
120
+ return { kind: "resumed" };
121
+ if (child.status === "failed" || child.status === "cancelled") {
122
+ // Routed through the step's `onFailure`, so a team's `escalate` reaches its manager — #202 AC-6.
123
+ return { kind: "failed", error: child.error?.message ?? `child run ${child.status}` };
124
+ }
125
+ return null;
126
+ };
127
+ const drive = async (context, initial) => {
128
+ let execution = initial;
129
+ const definition = await definitionFor(context, execution);
130
+ // Before anything else: if this execution is parked on a run that has since settled, take that outcome.
131
+ const settled = await childOutcome(context, execution);
132
+ if (settled !== null) {
133
+ const now = clock();
134
+ const { execution: next } = advance({ definition, execution, outcome: settled, nowMs: now.getTime(), nowIso: now.toISOString() });
135
+ execution = next;
136
+ await deps.executions.save({ tenantId: context.tenantId, execution: toStored(execution) });
137
+ if (execution.status === "completed" || execution.status === "failed" || execution.status === "cancelled") {
138
+ return { execution, stopped: "settled" };
139
+ }
140
+ }
141
+ else if (execution.waitingFor?.kind === "run") {
142
+ // Still running. Nothing to do, and saying "waiting" is more useful than driving a step that cannot start.
143
+ return { execution, stopped: "waiting" };
144
+ }
145
+ for (let performed = 0; performed < slice; performed += 1) {
146
+ const { execution: next, effect } = advance({
147
+ definition,
148
+ execution,
149
+ nowMs: clock().getTime(),
150
+ nowIso: clock().toISOString(),
151
+ });
152
+ execution = next;
153
+ // Persisted before the effect is performed *only* as a record of intent — the status and step, not a
154
+ // completed step. The completed-step write happens below, after the outcome.
155
+ await deps.executions.save({ tenantId: context.tenantId, execution: toStored(execution) });
156
+ if (effect.kind === "settled")
157
+ return { execution, stopped: "settled" };
158
+ if (execution.status === "waiting" && (effect.kind === "ask-human" || effect.kind === "await-signal")) {
159
+ // Parked. The outcome arrives later, from a person or a signal, through `resumeWith`.
160
+ return { execution, stopped: "waiting" };
161
+ }
162
+ const outcome = await perform(context, effect);
163
+ if (outcome === null)
164
+ return { execution, stopped: "waiting" };
165
+ const { execution: after } = advance({
166
+ definition,
167
+ execution,
168
+ outcome,
169
+ nowMs: clock().getTime(),
170
+ nowIso: clock().toISOString(),
171
+ });
172
+ execution = after;
173
+ await deps.executions.save({ tenantId: context.tenantId, execution: toStored(execution) });
174
+ if (execution.status === "completed" || execution.status === "failed" || execution.status === "cancelled") {
175
+ return { execution, stopped: "settled" };
176
+ }
177
+ if (execution.status === "waiting")
178
+ return { execution, stopped: "waiting" };
179
+ }
180
+ // The worker's slice, not the flow's budget. It hands the slot back and something re-enqueues.
181
+ return { execution, stopped: "slice-exhausted" };
182
+ };
183
+ return {
184
+ /** Start a flow at its latest version, pinning that version for this execution's whole life. */
185
+ async start(context, input) {
186
+ const stored = await deps.definitions.latest({ tenantId: context.tenantId, flowId: input.flowId });
187
+ if (stored === null) {
188
+ throw new AgentPlatformError({ code: "not_found", message: `no flow named ${input.flowId}`, retryable: false });
189
+ }
190
+ const definition = stored.definition;
191
+ const now = clock();
192
+ const execution = beginExecution({
193
+ id: newId(),
194
+ // The version comes from the stored row rather than the document, so a definition whose body disagrees
195
+ // with its row cannot pin a version that does not exist.
196
+ definition: { ...definition, version: stored.version },
197
+ tenantId: context.tenantId,
198
+ runId: input.runId,
199
+ principalId: context.principalId,
200
+ ...(context.conversationId === undefined ? {} : { conversationId: context.conversationId }),
201
+ ...(input.state === undefined ? {} : { state: input.state }),
202
+ ...(input.depth === undefined ? {} : { depth: input.depth }),
203
+ nowMs: now.getTime(),
204
+ nowIso: now.toISOString(),
205
+ });
206
+ await deps.executions.create({ tenantId: context.tenantId, execution: toStored(execution) });
207
+ return drive(context, execution);
208
+ },
209
+ /** Continue a stored execution — after a restart, or after a slice ran out. */
210
+ async resume(context, executionId) {
211
+ const stored = await deps.executions.get({ tenantId: context.tenantId, executionId });
212
+ if (stored === null) {
213
+ throw new AgentPlatformError({ code: "not_found", message: `no flow execution ${executionId}`, retryable: false });
214
+ }
215
+ return drive(context, stored.execution);
216
+ },
217
+ /**
218
+ * Deliver an answer or a signal to a parked execution.
219
+ *
220
+ * The value goes through the interpreter as a `resumed` outcome, so the parked step's `assignTo` receives it
221
+ * exactly as any other step's result would. A separate "apply an answer" path would be a second way to write
222
+ * state, and the two would eventually disagree about where an answer lands.
223
+ */
224
+ async resumeWith(context, executionId, value) {
225
+ const stored = await deps.executions.get({ tenantId: context.tenantId, executionId });
226
+ if (stored === null) {
227
+ throw new AgentPlatformError({ code: "not_found", message: `no flow execution ${executionId}`, retryable: false });
228
+ }
229
+ const execution = stored.execution;
230
+ const definition = await definitionFor(context, execution);
231
+ const now = clock();
232
+ const { execution: next } = advance({
233
+ definition,
234
+ execution,
235
+ outcome: { kind: "resumed", value },
236
+ nowMs: now.getTime(),
237
+ nowIso: now.toISOString(),
238
+ });
239
+ await deps.executions.save({ tenantId: context.tenantId, execution: toStored(next) });
240
+ if (next.status === "completed" || next.status === "failed")
241
+ return { execution: next, stopped: "settled" };
242
+ return drive(context, next);
243
+ },
244
+ /**
245
+ * A child run settled — #202.
246
+ *
247
+ * The fast path. Correctness does not depend on it: `drive` polls the child's state on every resume, so a
248
+ * lost notification costs latency rather than a stuck flow. Returns `null` when no execution was waiting for
249
+ * this run, which is the common case in a deployment where most runs are chat turns.
250
+ */
251
+ async notifyRunFinished(context, runId) {
252
+ const stored = await deps.executions.waitingOnRun({ tenantId: context.tenantId, runId });
253
+ if (stored === null)
254
+ return null;
255
+ return drive(context, stored.execution);
256
+ },
257
+ /** Everything parked on a signal, so delivering one can wake what was waiting. */
258
+ async deliverSignal(context, signal, value) {
259
+ const waiting = await deps.executions.waitingOnSignal({ tenantId: context.tenantId, signal });
260
+ const results = [];
261
+ for (const stored of waiting) {
262
+ // Sequentially, not in parallel: each of these can perform external writes, and a signal fanning out to
263
+ // fifty executions at once is a thundering herd nobody asked for.
264
+ results.push(await this.resumeWith(context, stored.id, value));
265
+ }
266
+ return results;
267
+ },
268
+ };
269
+ };
270
+ //# sourceMappingURL=runner.js.map
@@ -0,0 +1,8 @@
1
+ /**
2
+ * GraphQL boundary — `docs/06`. Ships SDL typeDefs + a thin resolver map for the host to mount on
3
+ * any GraphQL server (no server dependency taken by the library).
4
+ */
5
+ export * from "./schema.js";
6
+ export * from "./resolvers.js";
7
+ export * from "./sse.js";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,8 @@
1
+ /**
2
+ * GraphQL boundary — `docs/06`. Ships SDL typeDefs + a thin resolver map for the host to mount on
3
+ * any GraphQL server (no server dependency taken by the library).
4
+ */
5
+ export * from "./schema.js";
6
+ export * from "./resolvers.js";
7
+ export * from "./sse.js";
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,237 @@
1
+ /**
2
+ * Thin GraphQL resolvers — `docs/06` → "Resolvers are thin: authenticate, validate, construct
3
+ * execution context and call platform services." The host's GraphQL server builds the execution
4
+ * context (from its auth) and puts it on the resolver context; every resolver here just validates
5
+ * shape and delegates to a service. No business logic lives in this layer.
6
+ */
7
+ import type { ExecutionContext } from "../core/context.js";
8
+ import type { QuotaGuard } from "../usage/index.js";
9
+ import type { UsageRollupStore } from "../persistence/index.js";
10
+ import type { ConversationId, RunId } from "../core/ids.js";
11
+ import type { ConversationStore, UsageStore } from "../persistence/index.js";
12
+ import type { ContextInspection } from "../context/index.js";
13
+ import type { ToolRegistry } from "../tools/index.js";
14
+ import { type JobDispatcher } from "../runtime/index.js";
15
+ import { type LiveEventSource } from "../runtime/index.js";
16
+ import type { RunEventLog } from "../core/events.js";
17
+ import type { RunStore, ConversationRunCoordinator } from "../persistence/index.js";
18
+ import type { createQuestionService, createApprovalService } from "../hitl/index.js";
19
+ /** The resolver context the host supplies per request — the authenticated execution context. */
20
+ export type GraphQLContext = {
21
+ readonly execution: ExecutionContext;
22
+ };
23
+ export type ResolverDeps = {
24
+ readonly conversations: ConversationStore;
25
+ readonly runs: RunStore;
26
+ readonly usage: UsageStore;
27
+ readonly toolRegistry: ToolRegistry;
28
+ readonly questions: ReturnType<typeof createQuestionService>;
29
+ readonly approvals: ReturnType<typeof createApprovalService>;
30
+ readonly coordinator: ConversationRunCoordinator;
31
+ readonly dispatcher: JobDispatcher;
32
+ readonly eventLog: RunEventLog;
33
+ /**
34
+ * Quota enforcement at admission (#139).
35
+ *
36
+ * Optional: a deployment with no limits configured is valid, and its absence means unbounded — the same
37
+ * direction `resolveLimits` takes, because a misconfigured quota that blocks everything is an outage and one
38
+ * that blocks nothing is a bill the rollups make visible.
39
+ */
40
+ readonly quota?: QuotaGuard;
41
+ /**
42
+ * Rollups for the spend panel (#140).
43
+ *
44
+ * Optional for the same reason `quota` is: a deployment that has not run the rollup job yet should still
45
+ * serve a usage query, from the ledger, rather than erroring. Its absence costs a chart, not the page.
46
+ */
47
+ readonly rollups?: UsageRollupStore;
48
+ readonly live: LiveEventSource;
49
+ readonly channelFor?: (conversationId: ConversationId) => string;
50
+ /** Host-provided context assembly for the inspector (providers are app-specific). */
51
+ readonly inspectContext?: (execution: ExecutionContext, input: {
52
+ conversationId: ConversationId;
53
+ runId?: RunId;
54
+ }) => Promise<ContextInspection | null>;
55
+ };
56
+ export declare const createResolvers: (deps: ResolverDeps) => {
57
+ Query: {
58
+ conversations(_: unknown, args: {
59
+ limit: number;
60
+ cursor?: string;
61
+ }, ctx: GraphQLContext): Promise<import("../core/context.js").Page<import("../persistence/index.js").Conversation>>;
62
+ conversation(_: unknown, args: {
63
+ id: string;
64
+ }, ctx: GraphQLContext): Promise<import("../persistence/index.js").Conversation | null>;
65
+ run(_: unknown, args: {
66
+ id: string;
67
+ }, ctx: GraphQLContext): Promise<{
68
+ id: string;
69
+ conversationId: string | undefined;
70
+ status: string;
71
+ createdAt: string;
72
+ finishedAt: string | null;
73
+ } | null>;
74
+ toolCatalog(_: unknown, args: {
75
+ preloaded: string[];
76
+ categories: string[];
77
+ excluded: string[];
78
+ }, ctx: GraphQLContext): Promise<import("../tools/registry.js").ToolCatalog>;
79
+ usage(_: unknown, args: {
80
+ runId?: string;
81
+ }, ctx: GraphQLContext): Promise<import("../persistence/index.js").UsageTotals>;
82
+ /**
83
+ * The spend panel's one query (#140).
84
+ *
85
+ * Headline totals and buckets come from the **rollups**, so a page load never scans raw records however
86
+ * much a tenant has used. Breakdowns come from the ledger over the same bounded range — a deliberate
87
+ * trade documented on `UsageStore.breakdown`.
88
+ *
89
+ * Everything in one resolver so a panel cannot show a total from one moment and a breakdown from another;
90
+ * the discrepancy would look like a bug in the numbers rather than in the fetching.
91
+ */
92
+ usageReport(_: unknown, args: {
93
+ period: string;
94
+ from: string;
95
+ to: string;
96
+ breakdownLimit?: number;
97
+ }, ctx: GraphQLContext): Promise<{
98
+ period: "hour" | "day";
99
+ from: string;
100
+ to: string;
101
+ totals: import("../persistence/index.js").UsageTotals;
102
+ buckets: {
103
+ bucketStart: string;
104
+ currency: string;
105
+ totals: import("../persistence/index.js").UsageRollup;
106
+ }[];
107
+ byModel: readonly {
108
+ readonly key: string;
109
+ readonly totals: import("../persistence/index.js").UsageTotals;
110
+ }[];
111
+ byConversation: readonly {
112
+ readonly key: string;
113
+ readonly totals: import("../persistence/index.js").UsageTotals;
114
+ }[];
115
+ quota: {
116
+ window: string;
117
+ period: "hour" | "day" | "week" | "month" | null;
118
+ modelId: string | null;
119
+ costLimitMinorUnits: number | null;
120
+ inputTokenLimit: number | null;
121
+ outputTokenLimit: number | null;
122
+ warnAt: number;
123
+ warning: boolean;
124
+ exceeded: boolean;
125
+ } | null;
126
+ currency: string;
127
+ }>;
128
+ /**
129
+ * #163. Shaped for rendering: the optional fields are filled in rather than passed through, because a
130
+ * client that has to treat `null` as "one choice" and `undefined` as "one choice" and `false` as "one
131
+ * choice" will eventually treat one of them as "several".
132
+ */
133
+ pendingQuestion(_: unknown, args: {
134
+ runId: string;
135
+ }, ctx: GraphQLContext): Promise<{
136
+ interactionId: import("../core/ids.js").InteractionId;
137
+ runId: RunId;
138
+ createdAt: string;
139
+ questions: {
140
+ key: string;
141
+ prompt: string;
142
+ options: readonly string[];
143
+ multiple: boolean;
144
+ allowOther: boolean;
145
+ }[];
146
+ } | null>;
147
+ /** #163, the mirror of `pendingQuestion`. Wired the same way so the two cannot drift. */
148
+ pendingApproval(_: unknown, args: {
149
+ runId: string;
150
+ }, ctx: GraphQLContext): Promise<{
151
+ interactionId: import("../core/ids.js").InteractionId;
152
+ runId: RunId;
153
+ toolName: string;
154
+ summary: string;
155
+ riskCategory: string;
156
+ expiresAt: string;
157
+ normalizedInput: unknown;
158
+ } | null>;
159
+ conversationContext(_: unknown, args: {
160
+ conversationId: string;
161
+ runId?: string;
162
+ }, ctx: GraphQLContext): Promise<ContextInspection | null>;
163
+ };
164
+ Mutation: {
165
+ createConversation(_: unknown, args: {
166
+ id: string;
167
+ title: string;
168
+ }, ctx: GraphQLContext): Promise<import("../persistence/index.js").Conversation>;
169
+ renameConversation(_: unknown, args: {
170
+ id: string;
171
+ expectedVersion: number;
172
+ title: string;
173
+ }, ctx: GraphQLContext): Promise<import("../persistence/index.js").Conversation>;
174
+ archiveConversation(_: unknown, args: {
175
+ id: string;
176
+ expectedVersion: number;
177
+ }, ctx: GraphQLContext): Promise<import("../persistence/index.js").Conversation>;
178
+ deleteConversation(_: unknown, args: {
179
+ id: string;
180
+ }, ctx: GraphQLContext): Promise<boolean>;
181
+ sendMessage(_: unknown, args: {
182
+ conversationId: string;
183
+ runId: string;
184
+ }, ctx: GraphQLContext): Promise<{
185
+ id: string;
186
+ conversationId: string | undefined;
187
+ status: string;
188
+ createdAt: string;
189
+ finishedAt: string | null;
190
+ }>;
191
+ cancelRun(_: unknown, args: {
192
+ runId: string;
193
+ }, ctx: GraphQLContext): Promise<boolean>;
194
+ answerQuestion(_: unknown, args: {
195
+ input: {
196
+ interactionId: string;
197
+ runId: string;
198
+ answers: Record<string, string>;
199
+ };
200
+ }, ctx: GraphQLContext): Promise<boolean>;
201
+ decideApproval(_: unknown, args: {
202
+ input: {
203
+ interactionId: string;
204
+ runId: string;
205
+ decision: string;
206
+ };
207
+ }, ctx: GraphQLContext): Promise<boolean>;
208
+ };
209
+ Subscription: {
210
+ runEvents: {
211
+ subscribe(_: unknown, args: {
212
+ runId: string;
213
+ conversationId: string;
214
+ after?: number;
215
+ }, ctx: GraphQLContext): AsyncIterable<import("../core/events.js").RunEvent>;
216
+ resolve: (event: {
217
+ type: string;
218
+ runId: string;
219
+ sequence: number;
220
+ occurredAt: string;
221
+ }) => {
222
+ type: string;
223
+ runId: string;
224
+ sequence: number;
225
+ occurredAt: string;
226
+ payload: {
227
+ type: string;
228
+ runId: string;
229
+ sequence: number;
230
+ occurredAt: string;
231
+ };
232
+ };
233
+ };
234
+ };
235
+ };
236
+ export type RetinueResolvers = ReturnType<typeof createResolvers>;
237
+ //# sourceMappingURL=resolvers.d.ts.map