@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,127 @@
1
+ /**
2
+ * Deployment configuration (#110).
3
+ *
4
+ * Lives here rather than in `@retinue/agentkit`, and that is deliberate: the library reads
5
+ * `process.env` **zero times**, so a host can configure it however it likes — from a file, a secret
6
+ * manager, a test fixture. A library that reads the environment cannot be configured by its host, and
7
+ * that property erodes one convenient `process.env.DATABASE_URL` at a time, so there is a test for it.
8
+ *
9
+ * `loadConfig` takes the environment as an argument for the same reason. It makes "fails with a
10
+ * message naming the problem" testable without mutating global state, and it means a caller can load
11
+ * configuration from somewhere that is not `process.env` at all.
12
+ */
13
+ import { readEnv } from "../core/env.js";
14
+ /** Thrown when configuration is unusable. Carries the variable names so the message is actionable. */
15
+ export class ConfigurationError extends Error {
16
+ variables;
17
+ constructor(problems, variables) {
18
+ super(`Invalid configuration:\n - ${problems.join("\n - ")}`);
19
+ this.name = "ConfigurationError";
20
+ this.variables = variables;
21
+ }
22
+ }
23
+ const SCHEMA_MODES = ["auto", "plan", "off"];
24
+ const LOG_LEVELS = ["debug", "info", "warn", "error"];
25
+ export const DEFAULT_CONFIG = {
26
+ schemaMode: "off",
27
+ port: 4000,
28
+ workerConcurrency: 4,
29
+ logLevel: "info",
30
+ };
31
+ /**
32
+ * Validate the whole environment and report **every** problem at once.
33
+ *
34
+ * Deliberately not fail-on-first: a deployment with three missing variables should learn all three
35
+ * from one boot, not discover them across three deploys. That is what "fail fast with a precise
36
+ * message" is actually worth.
37
+ */
38
+ export const loadConfig = (env) => {
39
+ const problems = [];
40
+ const variables = [];
41
+ const fail = (variable, problem) => {
42
+ problems.push(`${variable}: ${problem}`);
43
+ variables.push(variable);
44
+ };
45
+ /**
46
+ * The prefix is added here, not written at each call — #192.
47
+ *
48
+ * Every variable was `AGENTKIT_*` and is now `RETINUE_*`. `readEnv` accepts both and warns on the old one, so
49
+ * a deployment keeps working for one release while it is corrected. Adding the prefix in one place means a
50
+ * caller cannot accidentally name the legacy variable directly and skip the warning.
51
+ *
52
+ * Errors always name the **current** variable, because an error naming the deprecated one would teach the
53
+ * reader to set the wrong thing.
54
+ */
55
+ const lookup = (suffix) => readEnv(env, suffix);
56
+ const named = (suffix) => `RETINUE_${suffix}`;
57
+ const required = (suffix) => {
58
+ const variable = named(suffix);
59
+ const value = lookup(suffix);
60
+ if (value === undefined || value.trim() === "") {
61
+ // Named, because "invalid configuration" without the name means reading the source to deploy.
62
+ fail(variable, "is required but was not set");
63
+ return "";
64
+ }
65
+ return value;
66
+ };
67
+ const databaseUrl = required("DATABASE_URL");
68
+ if (databaseUrl !== "" && !/^postgres(ql)?:\/\//.test(databaseUrl)) {
69
+ fail(named("DATABASE_URL"), `must be a postgres:// URL, got "${databaseUrl.slice(0, 12)}…"`);
70
+ }
71
+ const redisUrl = required("REDIS_URL");
72
+ if (redisUrl !== "" && !/^rediss?:\/\//.test(redisUrl)) {
73
+ fail(named("REDIS_URL"), `must be a redis:// URL, got "${redisUrl.slice(0, 12)}…"`);
74
+ }
75
+ const rawSchemaMode = lookup("SCHEMA_MODE") ?? DEFAULT_CONFIG.schemaMode;
76
+ if (!SCHEMA_MODES.includes(rawSchemaMode)) {
77
+ fail(named("SCHEMA_MODE"), `must be one of ${SCHEMA_MODES.join(", ")}, got "${rawSchemaMode}"`);
78
+ }
79
+ const positiveInt = (suffix, fallback) => {
80
+ // `PORT` has no prefix — it is the conventional name and always has been, so it is read directly.
81
+ const variable = suffix === "PORT" ? "PORT" : named(suffix);
82
+ const raw = suffix === "PORT" ? env["PORT"] : lookup(suffix);
83
+ if (raw === undefined || raw.trim() === "")
84
+ return fallback;
85
+ const value = Number(raw);
86
+ if (!Number.isInteger(value) || value <= 0) {
87
+ // A zero concurrency is the interesting case: it boots a worker that consumes nothing and looks
88
+ // healthy, which is worse than refusing to start.
89
+ fail(variable, `must be a positive integer, got "${raw}"`);
90
+ return fallback;
91
+ }
92
+ return value;
93
+ };
94
+ const port = positiveInt("PORT", DEFAULT_CONFIG.port);
95
+ const workerConcurrency = positiveInt("WORKER_CONCURRENCY", DEFAULT_CONFIG.workerConcurrency);
96
+ const rawLogLevel = lookup("LOG_LEVEL") ?? DEFAULT_CONFIG.logLevel;
97
+ if (!LOG_LEVELS.includes(rawLogLevel)) {
98
+ fail(named("LOG_LEVEL"), `must be one of ${LOG_LEVELS.join(", ")}, got "${rawLogLevel}"`);
99
+ }
100
+ if (problems.length > 0)
101
+ throw new ConfigurationError(problems, variables);
102
+ return {
103
+ databaseUrl,
104
+ redisUrl,
105
+ schemaMode: rawSchemaMode,
106
+ port,
107
+ workerConcurrency,
108
+ logLevel: rawLogLevel,
109
+ };
110
+ };
111
+ /** The variables a deployment must set, for the README and for error messages to stay in step. */
112
+ /**
113
+ * The variables a deployment must set, by their **full current names**.
114
+ *
115
+ * The prefix belongs here even though `lookup` adds it internally: this is what a deployment reads to know what
116
+ * to configure, and a list saying `DATABASE_URL` would have people setting a variable nothing reads. The rename
117
+ * briefly stripped it — a regex over the file caught this constant along with the internal literals — and the
118
+ * test that asserts the error names every missing variable is what found it.
119
+ */
120
+ export const REQUIRED_VARIABLES = ["RETINUE_DATABASE_URL", "RETINUE_REDIS_URL"];
121
+ export const OPTIONAL_VARIABLES = [
122
+ "SCHEMA_MODE",
123
+ "WORKER_CONCURRENCY",
124
+ "LOG_LEVEL",
125
+ "PORT",
126
+ ];
127
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Health and readiness probes (#110).
3
+ *
4
+ * `/healthz` and `/readyz` answer different questions, and conflating them is the mistake this file
5
+ * exists to avoid.
6
+ *
7
+ * **`/healthz` — is this process alive?** It must succeed while the database is down. An orchestrator
8
+ * that restarts a process because a *dependency* is unavailable turns a brief database blip into a
9
+ * restart storm, and the restarted process is no more able to reach the database than the one it
10
+ * replaced.
11
+ *
12
+ * **`/readyz` — should traffic come here?** Dependencies reachable, schema at the expected version.
13
+ * Not-ready is a **503**, because a load balancer keys off the status code, not the body — a 200 with
14
+ * `{"ready": false}` is a page nobody gets.
15
+ */
16
+ /** One dependency check. Failing is expected and normal; throwing is treated as failing. */
17
+ export type Probe = {
18
+ readonly name: string;
19
+ readonly check: () => Promise<void> | void;
20
+ };
21
+ export type ProbeResult = {
22
+ readonly name: string;
23
+ readonly ok: boolean;
24
+ readonly error?: string;
25
+ };
26
+ export type HealthRoutesOptions = {
27
+ readonly probes: readonly Probe[];
28
+ /** Reported in the payload so an operator can tell which build answered. */
29
+ readonly version?: string;
30
+ readonly healthPath?: string;
31
+ readonly readyPath?: string;
32
+ };
33
+ export declare const createHealthRoutes: (options: HealthRoutesOptions) => {
34
+ healthPath: string;
35
+ readyPath: string;
36
+ /** Liveness. Deliberately touches nothing external. */
37
+ health(): Response;
38
+ ready(): Promise<Response>;
39
+ /** Returns null when the path is not one of ours, so a host can compose this into its handler. */
40
+ handle(request: Request): Promise<Response | null>;
41
+ };
42
+ export type HealthRoutes = ReturnType<typeof createHealthRoutes>;
43
+ /** `SELECT 1`. The cheapest question that distinguishes "reachable" from "resolves in DNS". */
44
+ export declare const postgresProbe: (sql: {
45
+ query(text: string): Promise<unknown>;
46
+ }) => Probe;
47
+ export declare const redisProbe: (redis: {
48
+ ping(): Promise<string>;
49
+ }) => Probe;
50
+ /**
51
+ * Schema version. Separate from the Postgres probe on purpose: "the database is unreachable" and "the
52
+ * database is reachable but the schema is behind" need different operator responses, and a single
53
+ * probe would report them identically.
54
+ */
55
+ export declare const schemaProbe: (manager: {
56
+ currentVersion(): Promise<number>;
57
+ targetVersion(): number;
58
+ }) => Probe;
59
+ //# sourceMappingURL=health.d.ts.map
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Health and readiness probes (#110).
3
+ *
4
+ * `/healthz` and `/readyz` answer different questions, and conflating them is the mistake this file
5
+ * exists to avoid.
6
+ *
7
+ * **`/healthz` — is this process alive?** It must succeed while the database is down. An orchestrator
8
+ * that restarts a process because a *dependency* is unavailable turns a brief database blip into a
9
+ * restart storm, and the restarted process is no more able to reach the database than the one it
10
+ * replaced.
11
+ *
12
+ * **`/readyz` — should traffic come here?** Dependencies reachable, schema at the expected version.
13
+ * Not-ready is a **503**, because a load balancer keys off the status code, not the body — a 200 with
14
+ * `{"ready": false}` is a page nobody gets.
15
+ */
16
+ export const createHealthRoutes = (options) => {
17
+ const healthPath = options.healthPath ?? "/healthz";
18
+ const readyPath = options.readyPath ?? "/readyz";
19
+ const runProbes = async () =>
20
+ // All probes run, always — a 503 that names only the first failure sends an operator round the
21
+ // loop once per broken dependency.
22
+ Promise.all(options.probes.map(async (probe) => {
23
+ try {
24
+ await probe.check();
25
+ return { name: probe.name, ok: true };
26
+ }
27
+ catch (error) {
28
+ return { name: probe.name, ok: false, error: error instanceof Error ? error.message : String(error) };
29
+ }
30
+ }));
31
+ return {
32
+ healthPath,
33
+ readyPath,
34
+ /** Liveness. Deliberately touches nothing external. */
35
+ health() {
36
+ return Response.json({ status: "ok", ...(options.version === undefined ? {} : { version: options.version }) }, { status: 200 });
37
+ },
38
+ async ready() {
39
+ const results = await runProbes();
40
+ const ok = results.every((r) => r.ok);
41
+ return Response.json({
42
+ status: ok ? "ready" : "not-ready",
43
+ ...(options.version === undefined ? {} : { version: options.version }),
44
+ probes: results,
45
+ },
46
+ // 503, not 200-with-a-flag: the load balancer reads the status.
47
+ { status: ok ? 200 : 503 });
48
+ },
49
+ /** Returns null when the path is not one of ours, so a host can compose this into its handler. */
50
+ async handle(request) {
51
+ const { pathname } = new URL(request.url);
52
+ if (pathname === healthPath)
53
+ return this.health();
54
+ if (pathname === readyPath)
55
+ return this.ready();
56
+ return null;
57
+ },
58
+ };
59
+ };
60
+ /** `SELECT 1`. The cheapest question that distinguishes "reachable" from "resolves in DNS". */
61
+ export const postgresProbe = (sql) => ({
62
+ name: "postgres",
63
+ check: async () => {
64
+ await sql.query("SELECT 1");
65
+ },
66
+ });
67
+ export const redisProbe = (redis) => ({
68
+ name: "redis",
69
+ check: async () => {
70
+ const reply = await redis.ping();
71
+ if (reply !== "PONG")
72
+ throw new Error(`unexpected PING reply: ${reply}`);
73
+ },
74
+ });
75
+ /**
76
+ * Schema version. Separate from the Postgres probe on purpose: "the database is unreachable" and "the
77
+ * database is reachable but the schema is behind" need different operator responses, and a single
78
+ * probe would report them identically.
79
+ */
80
+ export const schemaProbe = (manager) => ({
81
+ name: "schema",
82
+ check: async () => {
83
+ const current = await manager.currentVersion();
84
+ const target = manager.targetVersion();
85
+ if (current !== target) {
86
+ throw new Error(`schema at version ${current}, expected ${target}`);
87
+ }
88
+ },
89
+ });
90
+ //# sourceMappingURL=health.js.map
@@ -0,0 +1,39 @@
1
+ import { type SseRouteOptions } from "./sse-route.js";
2
+ import type { HealthRoutes } from "./health.js";
3
+ import type { GraphQLContext, ResolverDeps } from "../index.js";
4
+ import type { ExecutionContext } from "../index.js";
5
+ /**
6
+ * Turns a request into an execution context, or `null` to refuse it.
7
+ *
8
+ * Deliberately the caller's function. Identity is the one thing a library cannot supply — it depends
9
+ * on the deployment's identity provider — and a default would be worse than an absent one. Note the
10
+ * consequence, recorded as an open question on #108: the security-critical step is entirely the
11
+ * caller's, and nothing here can verify it does the right thing.
12
+ */
13
+ export type Authenticate = (request: Request) => Promise<ExecutionContext | null> | ExecutionContext | null;
14
+ export type HostOptions = {
15
+ readonly deps: ResolverDeps;
16
+ readonly authenticate: Authenticate;
17
+ /** GraphQL endpoint path. Defaults to `/graphql`. */
18
+ readonly graphqlEndpoint?: string;
19
+ /** Landing page and introspection are off by default; a reference host is not a playground. */
20
+ readonly graphiql?: boolean;
21
+ /**
22
+ * Also serve the SSE streaming endpoint (#109) on the same fetch handler. Optional because the
23
+ * embedded profile is one deployment shape, not the only one — a host using GraphQL subscriptions
24
+ * exclusively should not have a second streaming surface it never wanted.
25
+ */
26
+ readonly sse?: Omit<SseRouteOptions, "deps" | "authenticate"> & {
27
+ readonly enabled: boolean;
28
+ };
29
+ /**
30
+ * Health and readiness routes, served **before** authentication. Deliberately: a load balancer has
31
+ * no credentials, and a probe that required them would report every healthy pod as unhealthy.
32
+ */
33
+ readonly health?: HealthRoutes;
34
+ };
35
+ /** Thrown when a request carries no usable identity. Surfaces as a GraphQL error, not a crash. */
36
+ export declare const UNAUTHENTICATED = "UNAUTHENTICATED";
37
+ export declare const createRetinueHost: (options: HostOptions) => import("graphql-yoga").YogaServerInstance<Record<string, never>, GraphQLContext>;
38
+ export type RetinueHost = ReturnType<typeof createRetinueHost>;
39
+ //# sourceMappingURL=host.d.ts.map
@@ -0,0 +1,124 @@
1
+ /**
2
+ * Reference GraphQL host (#108).
3
+ *
4
+ * `@retinue/agentkit` ships the schema as SDL and a thin resolver map with **no server dependency**,
5
+ * so a host can mount it on Yoga, Apollo or Mercurius. This is one such host, in its own workspace
6
+ * precisely so the library keeps that property — AC-6 of #108 is that `@retinue/agentkit` gained no
7
+ * GraphQL-server dependency, and putting Yoga inside it would have failed that outright.
8
+ *
9
+ * It is a *reference* host, not the sanctioned one. Nothing here is business logic: the resolver map
10
+ * is passed through untouched, and the only thing this layer decides is where the `ExecutionContext`
11
+ * comes from.
12
+ */
13
+ import { createGraphQLError, createSchema, createYoga } from "graphql-yoga";
14
+ import { createServerAdapter } from "@whatwg-node/server";
15
+ import { createRunEventSseRoute } from "./sse-route.js";
16
+ import { createResolvers, typeDefs } from "../graphql/index.js";
17
+ /** Thrown when a request carries no usable identity. Surfaces as a GraphQL error, not a crash. */
18
+ export const UNAUTHENTICATED = "UNAUTHENTICATED";
19
+ export const createRetinueHost = (options) => {
20
+ // Passed through untouched. AC-5 is "no business logic was added to the resolver layer", and the
21
+ // strongest form of that is a host that adds no resolver of its own — asserted in the tests.
22
+ const resolvers = createResolvers(options.deps);
23
+ const yoga = createYoga({
24
+ schema: createSchema({ typeDefs, resolvers: resolvers }),
25
+ graphqlEndpoint: options.graphqlEndpoint ?? "/graphql",
26
+ graphiql: options.graphiql ?? false,
27
+ landingPage: false,
28
+ /**
29
+ * The single place an `ExecutionContext` is constructed, which is what makes AC-2 and AC-3 one
30
+ * mechanism rather than two.
31
+ *
32
+ * Yoga runs this **before execution**, so throwing here means no resolver runs — that is AC-2,
33
+ * and it is a stronger statement than "the response was a 401". And because this is the only
34
+ * construction site, there is no ambient or default tenant for a request to fall back to, which
35
+ * is AC-3. A resolver cannot see a context it did not construct because there is nowhere else for
36
+ * one to come from.
37
+ */
38
+ context: async ({ request }) => {
39
+ const execution = await options.authenticate(request);
40
+ if (execution === null || execution === undefined) {
41
+ // `createGraphQLError` rather than a bare `new GraphQLError`. Yoga masks errors it considers
42
+ // unexpected, and a context-factory throw is one of them — a plain GraphQLError comes back as
43
+ // a 500 "Unexpected error", which would turn an authentication refusal into what looks like a
44
+ // server fault. Verified: the first version of this did exactly that.
45
+ throw createGraphQLError("Unauthenticated", {
46
+ extensions: { code: UNAUTHENTICATED, http: { status: 401 } },
47
+ });
48
+ }
49
+ return { execution };
50
+ },
51
+ });
52
+ const health = options.health;
53
+ if (options.sse?.enabled !== true && health === undefined)
54
+ return yoga;
55
+ const sse = options.sse?.enabled === true
56
+ ? createRunEventSseRoute({ deps: options.deps, authenticate: options.authenticate, ...options.sse })
57
+ : null;
58
+ /**
59
+ * One fetch handler for both surfaces. Composed rather than mounted on a router, because a router
60
+ * would be a second framework decision this workspace has no need to make — and the whole point of
61
+ * a fetch handler is that it composes.
62
+ */
63
+ /**
64
+ * Whether this is already a request.
65
+ *
66
+ * Duck-typed on `url` and `headers`, because there can be more than one `Request` class in a process and a
67
+ * nominal check picks the wrong one silently.
68
+ */
69
+ const isRequestLike = (value) => typeof value === "object" &&
70
+ value !== null &&
71
+ typeof value.url === "string" &&
72
+ typeof value.headers === "object";
73
+ const handle = async (input, init, ...rest) => {
74
+ /**
75
+ * Normalised **structurally**, not with `instanceof Request`.
76
+ *
77
+ * Yoga's `fetch` accepts a Request, a URL or a string, and callers use all three — the first version of this
78
+ * read `request.url` off a string and failed with "Invalid URL" for every caller that passed one.
79
+ *
80
+ * But `instanceof` was wrong too, and more subtly (#155). `@whatwg-node/server` — which Yoga itself is built
81
+ * on — constructs requests from its own ponyfilled class, so a genuine request arriving through the Node
82
+ * adapter is **not** `instanceof` the global `Request`. The check failed, the object fell through to
83
+ * `new Request(String(input))`, and every request died on `Failed to parse URL from [object Request]`.
84
+ *
85
+ * A request is a thing with a URL. Testing for that works across every implementation, which is the property
86
+ * that matters when two of them are in the same process.
87
+ */
88
+ const request = isRequestLike(input) ? input : new Request(String(input), init);
89
+ const url = new URL(request.url);
90
+ // Probes first and unauthenticated: a load balancer carries no credentials.
91
+ const probe = await health?.handle(request);
92
+ if (probe !== null && probe !== undefined)
93
+ return probe;
94
+ if (sse !== null && url.pathname === sse.path)
95
+ return sse.handle(request);
96
+ return yoga.fetch(request, ...rest);
97
+ };
98
+ /**
99
+ * A **server adapter**, so the returned object is both a fetch handler *and* a Node request listener.
100
+ *
101
+ * This was a real bug, found the first time anything actually served a request (#155). The previous version
102
+ * returned `Object.assign(fetch, yoga, …)` — a function whose callable body was the WHATWG `fetch`. Node's
103
+ * `http.createServer(listener)` calls its listener with `(IncomingMessage, ServerResponse)`, so
104
+ * `createServer(host)` reached `new Request(String(incomingMessage))` and threw
105
+ * `Failed to parse URL from [object Object]` on **every** request.
106
+ *
107
+ * The doc comment above it claimed "callers and `createServer(host)` are unaffected", and that claim had never
108
+ * been executed: the tests call `host.fetch(new Request(…))` directly, which is the one path that worked.
109
+ * `main.ts` — the documented way to run this — could not serve anything.
110
+ *
111
+ * `createServerAdapter` is what Yoga itself is built on, so this is the same conversion Yoga would have done,
112
+ * applied to the composed handler instead of to Yoga alone. Health probes and SSE now reach the Node path too;
113
+ * before, they were only reachable by a caller who already had a `Request`.
114
+ */
115
+ const adapter = createServerAdapter(handle);
116
+ // Yoga's own shape is preserved on top (`graphqlEndpoint`, `getEnveloped`, …) for callers that read it, and
117
+ // `fetch` is pinned to the adapter so one object serves both styles.
118
+ return Object.assign(adapter, yoga, {
119
+ fetch: adapter,
120
+ handle,
121
+ ...(sse === null ? {} : { ssePath: sse.path }),
122
+ });
123
+ };
124
+ //# sourceMappingURL=host.js.map
@@ -0,0 +1,15 @@
1
+ /**
2
+ * `@retinue/agentkit/server` — the reference GraphQL host for `@retinue/agentkit` (#108).
3
+ *
4
+ * A separate workspace on purpose: the library ships SDL plus a thin resolver map and takes no
5
+ * GraphQL-server dependency, so a host can mount it on Yoga, Apollo or Mercurius. This is one host.
6
+ */
7
+ export * from "./host.js";
8
+ export * from "./main.js";
9
+ export * from "./sse-route.js";
10
+ export * from "./config.js";
11
+ export * from "./health.js";
12
+ export * from "./boot.js";
13
+ export * from "./cli.js";
14
+ export * from "./cli-worker.js";
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,15 @@
1
+ /**
2
+ * `@retinue/agentkit/server` — the reference GraphQL host for `@retinue/agentkit` (#108).
3
+ *
4
+ * A separate workspace on purpose: the library ships SDL plus a thin resolver map and takes no
5
+ * GraphQL-server dependency, so a host can mount it on Yoga, Apollo or Mercurius. This is one host.
6
+ */
7
+ export * from "./host.js";
8
+ export * from "./main.js";
9
+ export * from "./sse-route.js";
10
+ export * from "./config.js";
11
+ export * from "./health.js";
12
+ export * from "./boot.js";
13
+ export * from "./cli.js";
14
+ export * from "./cli-worker.js";
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,16 @@
1
+ import { type Authenticate } from "./host.js";
2
+ import type { ResolverDeps } from "../index.js";
3
+ export type MainOptions = {
4
+ readonly deps: ResolverDeps;
5
+ readonly authenticate: Authenticate;
6
+ readonly port?: number;
7
+ readonly log?: (message: string) => void;
8
+ };
9
+ export declare const DEFAULT_PORT = 4000;
10
+ export declare const startServer: (options: MainOptions) => Promise<{
11
+ port: number;
12
+ yoga: import("graphql-yoga").YogaServerInstance<Record<string, never>, import("../index.js").GraphQLContext>;
13
+ /** Resolves once the socket is closed, so a caller can sequence shutdown. */
14
+ close: () => Promise<void>;
15
+ }>;
16
+ //# sourceMappingURL=main.d.ts.map
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Runnable entrypoint (#108 AC-1).
3
+ *
4
+ * Composition only. Every store, dispatcher and service it wires already exists and is already
5
+ * tested; this file's whole job is to be a documented command that serves the API.
6
+ *
7
+ * Run with:
8
+ * RETINUE_DATABASE_URL=postgres://… PORT=4000 node dist/main.js
9
+ *
10
+ * `authenticate` is deliberately not implemented here. A reference host cannot know a deployment's
11
+ * identity provider, and shipping a permissive default would be worse than shipping none — so the
12
+ * entrypoint refuses to start without one rather than quietly serving an open API.
13
+ */
14
+ import { createServer } from "node:http";
15
+ import { createRetinueHost } from "./host.js";
16
+ export const DEFAULT_PORT = 4000;
17
+ export const startServer = async (options) => {
18
+ const port = options.port ?? Number(process.env["PORT"] ?? DEFAULT_PORT);
19
+ const log = options.log ?? ((message) => console.log(message));
20
+ const yoga = createRetinueHost({ deps: options.deps, authenticate: options.authenticate });
21
+ const server = createServer(yoga);
22
+ await new Promise((resolve) => server.listen(port, resolve));
23
+ log(`agentkit graphql host listening on :${port}${yoga.graphqlEndpoint}`);
24
+ return {
25
+ port,
26
+ yoga,
27
+ /** Resolves once the socket is closed, so a caller can sequence shutdown. */
28
+ close: () => new Promise((resolve, reject) => server.close((error) => (error ? reject(error) : resolve()))),
29
+ };
30
+ };
31
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1,21 @@
1
+ import type { ConversationId, ExecutionContext, ResolverDeps } from "../index.js";
2
+ import type { Authenticate } from "./host.js";
3
+ export type SseRouteOptions = {
4
+ readonly deps: Pick<ResolverDeps, "conversations" | "eventLog" | "live" | "channelFor">;
5
+ readonly authenticate: Authenticate;
6
+ /**
7
+ * Finer-grained entitlement *within* a tenant, which the library cannot know. Optional: the
8
+ * cross-tenant case is already closed by the unconditional ownership check below, so this is for
9
+ * per-user policy rather than for the dangerous case.
10
+ */
11
+ readonly authorizeConversation?: (execution: ExecutionContext, conversationId: ConversationId) => Promise<boolean> | boolean;
12
+ /** How often a quiet stream emits a comment frame. Default 15s. */
13
+ readonly keepAliveMs?: number;
14
+ readonly path?: string;
15
+ };
16
+ export declare const createRunEventSseRoute: (options: SseRouteOptions) => {
17
+ path: string;
18
+ handle(request: Request): Promise<Response>;
19
+ };
20
+ export type RunEventSseRoute = ReturnType<typeof createRunEventSseRoute>;
21
+ //# sourceMappingURL=sse-route.d.ts.map