@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,207 @@
1
+ /**
2
+ * `FileContentStore` over Supabase Storage — the production object-storage adapter (#129).
3
+ *
4
+ * This is the first store where Supabase is not simply Postgres. Every other port aliases straight to the
5
+ * Postgres implementation, and `supabase-conformance.test.ts` asserts that by identity. File bytes are the
6
+ * exception, and not incidentally: #102 declined to make `blobs` a pointer table, and `0013_files` keeps
7
+ * only metadata, precisely so that bytes live somewhere built for them.
8
+ *
9
+ * **Over `fetch`, not an SDK.** Supabase Storage is a plain REST API with a bearer token, so an SDK would
10
+ * add a dependency, a client lifecycle and an auth model for four HTTP calls. `fetch` is injected rather
11
+ * than reached for, so the conformance harness runs the real URL construction and status handling against
12
+ * an in-process double instead of a live bucket.
13
+ *
14
+ * **Two properties that are not obvious from the port:**
15
+ *
16
+ * - **The tenant is the path prefix, and a content key may not contain a separator.** `sanitizeMediaRefs` in
17
+ * ShareFlow is the cautionary tale this is written against — its workspace-prefix check was *"the ONLY
18
+ * thing standing between a forged path and a signed URL to another tenant's private object."* Here the
19
+ * key is validated to a character class, so `../` cannot be spelled at all.
20
+ * - **Listing is offset-paged, because the API is.** Unlike the metadata stores, which use keyset cursors
21
+ * deliberately, this one cannot: a concurrent upload can shift a page. That is tolerable only because the
22
+ * sole caller is reconciliation, which reports rather than deletes and runs again.
23
+ */
24
+ import { AgentPlatformError } from "../../core/errors.js";
25
+ /**
26
+ * What a content key may contain.
27
+ *
28
+ * No `/`, so a key cannot leave its tenant's prefix; no `.` runs, so `..` cannot be spelled. The service
29
+ * mints keys as `f_<uuid>`, which satisfies this — the check is here for the caller that does not.
30
+ */
31
+ const SAFE_KEY = /^[A-Za-z0-9][A-Za-z0-9._-]{0,190}$/;
32
+ const assertSafeKey = (contentKey) => {
33
+ if (!SAFE_KEY.test(contentKey) || contentKey.includes(".."))
34
+ throw new AgentPlatformError({
35
+ code: "invalid_input",
36
+ message: `content key ${JSON.stringify(contentKey)} is not a valid object name`,
37
+ retryable: false,
38
+ });
39
+ };
40
+ /** Tenant ids come from the host, but a traversal here would cross a tenant boundary, so they are checked too. */
41
+ const assertSafeTenant = (tenantId) => {
42
+ if (!SAFE_KEY.test(tenantId) || tenantId.includes(".."))
43
+ throw new AgentPlatformError({
44
+ code: "invalid_input",
45
+ message: "tenant id is not a valid object path segment",
46
+ retryable: false,
47
+ });
48
+ };
49
+ const objectPath = (tenantId, contentKey) => {
50
+ assertSafeTenant(tenantId);
51
+ assertSafeKey(contentKey);
52
+ return `${tenantId}/${contentKey}`;
53
+ };
54
+ /**
55
+ * A storage failure: the status, the path, and a truncated body.
56
+ *
57
+ * `retryable` follows the status rather than a guess: 5xx and 429 are worth another attempt, a 4xx is the
58
+ * request being wrong and retrying it just repeats the mistake.
59
+ *
60
+ * **The service key is redacted from the body.** Found while testing this file: the body is quoted for
61
+ * diagnostics, and a service — or a proxy's error page in front of it — that echoes the request would put
62
+ * the service-role key into an error message, which is to say into logs. Redacting at the one place error
63
+ * messages are built is the only version of this that stays true as callers are added.
64
+ */
65
+ const makeStorageError = (serviceKey) => (status, what, detail) => new AgentPlatformError({
66
+ code: status === 404 ? "not_found" : status === 403 || status === 401 ? "forbidden" : "internal",
67
+ message: `storage ${what} failed with ${status}: ${detail
68
+ .replaceAll(serviceKey, "[redacted]")
69
+ .slice(0, 200)}`,
70
+ retryable: status >= 500 || status === 429,
71
+ });
72
+ const sha256Hex = async (bytes) => {
73
+ const digest = await crypto.subtle.digest("SHA-256", bytes);
74
+ return [...new Uint8Array(digest)].map((b) => b.toString(16).padStart(2, "0")).join("");
75
+ };
76
+ /** Offset cursors, because the list API takes an offset. Opaque so the shape stays this file's business. */
77
+ const encodeOffset = (offset) => Buffer.from(String(offset), "utf8").toString("base64url");
78
+ const decodeOffset = (cursor) => {
79
+ const parsed = Number.parseInt(Buffer.from(cursor, "base64url").toString("utf8"), 10);
80
+ return Number.isSafeInteger(parsed) && parsed >= 0 ? parsed : 0;
81
+ };
82
+ export const createSupabaseStorageFileContentStore = (config) => {
83
+ const base = `${config.url.replace(/\/+$/, "")}/storage/v1`;
84
+ const headers = { Authorization: `Bearer ${config.serviceKey}` };
85
+ const storageError = makeStorageError(config.serviceKey);
86
+ return {
87
+ async putFile({ tenantId, contentKey, mediaType, bytes, maxBytes }) {
88
+ const path = objectPath(tenantId, contentKey);
89
+ // Buffered, not streamed, and the bound is the reason it is acceptable: the checksum is over the whole
90
+ // object, so the bytes have to be seen anyway, and `maxBytes` caps what can be held. The cap is
91
+ // re-enforced here rather than trusted from `streamWithCap`, because a second caller can skip a check
92
+ // that lives above the adapter.
93
+ const chunks = [];
94
+ let size = 0;
95
+ for await (const chunk of bytes) {
96
+ size += chunk.byteLength;
97
+ if (size > maxBytes)
98
+ throw new AgentPlatformError({
99
+ code: "invalid_input",
100
+ message: `the file exceeds the ${maxBytes} byte limit`,
101
+ retryable: false,
102
+ });
103
+ chunks.push(chunk);
104
+ }
105
+ const body = new Uint8Array(size);
106
+ let offset = 0;
107
+ for (const chunk of chunks) {
108
+ body.set(chunk, offset);
109
+ offset += chunk.byteLength;
110
+ }
111
+ const response = await config.fetch(`${base}/object/${config.bucket}/${path}`, {
112
+ method: "POST",
113
+ headers: {
114
+ ...headers,
115
+ "Content-Type": mediaType,
116
+ // No upsert. A content key is minted per upload, so a collision is not a retry — it is two files
117
+ // pointed at one object, and overwriting would replace the first one's bytes.
118
+ "x-upsert": "false",
119
+ },
120
+ body,
121
+ });
122
+ if (!response.ok)
123
+ throw storageError(response.status, `upload of ${path}`, await response.text());
124
+ return { contentKey, byteSize: size, checksum: await sha256Hex(body) };
125
+ },
126
+ async readFile({ tenantId, contentKey }) {
127
+ const path = objectPath(tenantId, contentKey);
128
+ const response = await config.fetch(`${base}/object/${config.bucket}/${path}`, { headers });
129
+ // Absent is `null`, per the port: the read path turns that into "contents are missing", which is the
130
+ // orphan seen from the other direction. Any other failure throws, because an unreachable bucket must
131
+ // not be reported as a missing file — that would send someone hunting a data-loss bug during an outage.
132
+ if (response.status === 404 || response.status === 400)
133
+ return null;
134
+ if (!response.ok)
135
+ throw storageError(response.status, `read of ${path}`, await response.text());
136
+ const buffer = new Uint8Array(await response.arrayBuffer());
137
+ return (async function* () {
138
+ yield buffer;
139
+ })();
140
+ },
141
+ async signedUrl({ tenantId, contentKey, expiresInSeconds }) {
142
+ const path = objectPath(tenantId, contentKey);
143
+ const response = await config.fetch(`${base}/object/sign/${config.bucket}/${path}`, {
144
+ method: "POST",
145
+ headers: { ...headers, "Content-Type": "application/json" },
146
+ // The expiry as given. Clamping lives in `signedReadUrl`, once, so there is one answer to "how long
147
+ // does a URL live" rather than a floor here and a ceiling there.
148
+ body: JSON.stringify({ expiresIn: expiresInSeconds }),
149
+ });
150
+ if (response.status === 404)
151
+ return null;
152
+ if (!response.ok)
153
+ throw storageError(response.status, `signing of ${path}`, await response.text());
154
+ const parsed = JSON.parse(await response.text());
155
+ const signed = parsed.signedURL ?? parsed.signedUrl;
156
+ if (signed === undefined)
157
+ throw storageError(502, `signing of ${path}`, "the response carried no signed URL");
158
+ // Relative in the API's response. Returned absolute, because a caller cannot use half a URL and would
159
+ // have to reconstruct the base — which is how the wrong project's URL gets built.
160
+ return signed.startsWith("http") ? signed : `${base}${signed.startsWith("/") ? "" : "/"}${signed}`;
161
+ },
162
+ async deleteFile({ tenantId, contentKey }) {
163
+ const path = objectPath(tenantId, contentKey);
164
+ const response = await config.fetch(`${base}/object/${config.bucket}/${path}`, {
165
+ method: "DELETE",
166
+ headers,
167
+ });
168
+ // Idempotent: a retried sweep must not fail on the object it already removed. The state moves only
169
+ // after this call returns, so a 404 here is the previous attempt having succeeded.
170
+ if (response.status === 404 || response.ok)
171
+ return;
172
+ throw storageError(response.status, `delete of ${path}`, await response.text());
173
+ },
174
+ async listObjects({ tenantId, prefix, limit, cursor }) {
175
+ assertSafeTenant(tenantId);
176
+ const offset = cursor === undefined ? 0 : decodeOffset(cursor);
177
+ const response = await config.fetch(`${base}/object/list/${config.bucket}`, {
178
+ method: "POST",
179
+ headers: { ...headers, "Content-Type": "application/json" },
180
+ body: JSON.stringify({
181
+ // The tenant prefix is not optional and not appended to the caller's — it is the caller's prefix
182
+ // scoped *inside* the tenant's. A caller passing `../other-tenant/` gets a literal prefix that
183
+ // matches nothing, because the key check above means no object is named that.
184
+ prefix: `${tenantId}/${prefix ?? ""}`,
185
+ limit: limit + 1,
186
+ offset,
187
+ sortBy: { column: "name", order: "asc" },
188
+ }),
189
+ });
190
+ if (!response.ok)
191
+ throw storageError(response.status, "list", await response.text());
192
+ const rows = JSON.parse(await response.text());
193
+ const items = rows
194
+ .slice(0, limit)
195
+ .flatMap((row) =>
196
+ // A row with no name is a folder placeholder in this API. Skipped rather than surfaced as an
197
+ // object with an empty key, which reconciliation would then report as an orphan nobody can find.
198
+ row.name === undefined || row.name === ""
199
+ ? []
200
+ : [{ contentKey: row.name, byteSize: row.metadata?.size ?? 0 }]);
201
+ // Keys come back relative to the prefix the API was given, which is already tenant-scoped, so what
202
+ // the port returns is the bare content key — the same string `putFile` was handed.
203
+ return rows.length > limit ? { items, nextCursor: encodeOffset(offset + limit) } : { items };
204
+ },
205
+ };
206
+ };
207
+ //# sourceMappingURL=storage.js.map
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Embedded agent facade — `docs/03` + `docs/06` (embedded profile).
3
+ *
4
+ * The batteries-included entry point: `createAgent({ manifest }).run({ conversationId, message })`.
5
+ * It wires the reference in-memory stores, the model registry + provider factory, the tool registry
6
+ * and the default engine into the durable worker, then runs a turn to completion and returns its
7
+ * parts. State persists across turns on the same conversation. Swap the in-memory adapters for
8
+ * Postgres/Supabase and drive the worker from a real queue to get the server profile — same engine,
9
+ * same contracts.
10
+ */
11
+ import type { ExecutionContext } from "../core/context.js";
12
+ import type { MessagePart } from "../core/content-parts.js";
13
+ import type { ModelDefinition, ModelRoleAssignments } from "../models/index.js";
14
+ import { type ProviderCredentials } from "../models/provider-factory.js";
15
+ import type { ModelProvider } from "../models/index.js";
16
+ import type { AuthorizationPolicy } from "../authorization/index.js";
17
+ import { type ContextProvider } from "../context/index.js";
18
+ import { type ToolProvider } from "../tools/index.js";
19
+ import { type AgentEngine, type ProcessOutcome } from "../runtime/index.js";
20
+ import { type ResolvedModelInfo } from "./engine.js";
21
+ import type { AgentManifest } from "./index.js";
22
+ import { type AgentManifestInput } from "./define.js";
23
+ export type CreateAgentConfig = {
24
+ readonly manifest: AgentManifestInput;
25
+ /** Model catalog; defaults to a small Anthropic catalog (smart/fast). */
26
+ readonly models?: readonly ModelDefinition[];
27
+ readonly roleAssignments?: ModelRoleAssignments;
28
+ readonly providerCredentials?: Partial<Record<ModelProvider, ProviderCredentials>>;
29
+ readonly tools?: readonly ToolProvider[];
30
+ /** Context providers (e.g. principal memory, retrieval) whose sections are prepended to the prompt. */
31
+ readonly contextProviders?: readonly ContextProvider[];
32
+ /**
33
+ * Random hex for the untrusted-content delimiter nonce (#145).
34
+ *
35
+ * Injected so a test can pin the exact bytes of a rendered prompt; defaults to `node:crypto`. A module that
36
+ * reaches for randomness directly is one whose output cannot be asserted, and the assertion here is precisely
37
+ * that a forged delimiter does not survive.
38
+ */
39
+ readonly randomHex?: (bytes: number) => string;
40
+ readonly authorization?: AuthorizationPolicy;
41
+ readonly tenantId?: string;
42
+ /** Test/advanced seam: override how a manifest resolves to a model (e.g. a mock model). */
43
+ readonly resolveModel?: (manifest: AgentManifest, context: ExecutionContext) => ResolvedModelInfo;
44
+ /** Test/advanced seam: supply the engine directly instead of building the default one. */
45
+ readonly engine?: AgentEngine;
46
+ readonly now?: () => number;
47
+ };
48
+ export type RunInput = {
49
+ readonly conversationId: string;
50
+ readonly message: string;
51
+ readonly principalId?: string;
52
+ readonly roleIds?: readonly string[];
53
+ };
54
+ export type RunResult = {
55
+ readonly runId: string;
56
+ readonly outcome: ProcessOutcome;
57
+ readonly parts: readonly MessagePart[];
58
+ /** Convenience: the assistant's concatenated text. */
59
+ readonly text: string;
60
+ };
61
+ export declare const createAgent: (config: CreateAgentConfig) => {
62
+ manifest: AgentManifest;
63
+ /** Run one turn to completion and return the assistant's parts. State persists on the conversation. */
64
+ run(input: RunInput): Promise<RunResult>;
65
+ };
66
+ //# sourceMappingURL=agent.d.ts.map
@@ -0,0 +1,209 @@
1
+ /**
2
+ * Embedded agent facade — `docs/03` + `docs/06` (embedded profile).
3
+ *
4
+ * The batteries-included entry point: `createAgent({ manifest }).run({ conversationId, message })`.
5
+ * It wires the reference in-memory stores, the model registry + provider factory, the tool registry
6
+ * and the default engine into the durable worker, then runs a turn to completion and returns its
7
+ * parts. State persists across turns on the same conversation. Swap the in-memory adapters for
8
+ * Postgres/Supabase and drive the worker from a real queue to get the server profile — same engine,
9
+ * same contracts.
10
+ */
11
+ import { AgentPlatformError } from "../core/errors.js";
12
+ import { asId } from "../core/ids.js";
13
+ import { createModelRegistry, computeModelCostMinorUnits } from "../models/index.js";
14
+ // From the module rather than the barrel: `models/index.ts` no longer re-exports the factory, because doing so
15
+ // made every root import load six provider SDKs (#196).
16
+ import { createProviderFactory, } from "../models/provider-factory.js";
17
+ import { gatherSections } from "../context/index.js";
18
+ import { randomBytes } from "node:crypto";
19
+ import { makeNonce, renderContextBlock } from "../security/prompt-safety.js";
20
+ import { createToolRegistry } from "../tools/index.js";
21
+ import { createDurableWorker } from "../runtime/index.js";
22
+ import { createMemoryCheckpointStore, createMemoryRunEventLog, createMemoryRunStore, } from "../adapters/memory/runtime.js";
23
+ import { createMemoryConversationStore } from "../adapters/memory/index.js";
24
+ import { createMemoryEventBus } from "../runtime/index.js";
25
+ import { createMemoryMessageStore } from "../adapters/memory/message-store.js";
26
+ import { createDefaultEngine } from "./engine.js";
27
+ import { DEFAULT_MODEL_CATALOG, DEFAULT_ROLE_ASSIGNMENTS, defineAgent, } from "./define.js";
28
+ /** Permissive policy used by the embedded facade when a caller wires tools but no authorization. */
29
+ const allowAllAuthorization = () => ({
30
+ async can() {
31
+ return { allow: true };
32
+ },
33
+ async filterTools(_ctx, tools) {
34
+ return tools;
35
+ },
36
+ async scope(context) {
37
+ return { tenantId: context.tenantId, roleIds: context.roleIds };
38
+ },
39
+ });
40
+ const textOf = (parts) => parts.filter((p) => p.type === "text").map((p) => p.text).join("");
41
+ /** The default nonce source. Real randomness, so a delimiter cannot be predicted across runs. */
42
+ const defaultRandomHex = (bytes) => randomBytes(bytes).toString("hex");
43
+ export const createAgent = (config) => {
44
+ const manifest = defineAgent(config.manifest);
45
+ const tenantId = asId(config.tenantId ?? "default");
46
+ const now = config.now ?? Date.now;
47
+ const conversations = createMemoryConversationStore();
48
+ const runs = createMemoryRunStore();
49
+ const checkpoints = createMemoryCheckpointStore();
50
+ const eventLog = createMemoryRunEventLog();
51
+ const bus = createMemoryEventBus();
52
+ const messages = createMemoryMessageStore();
53
+ const registry = createModelRegistry({
54
+ models: config.models ?? DEFAULT_MODEL_CATALOG,
55
+ roles: config.roleAssignments ?? DEFAULT_ROLE_ASSIGNMENTS,
56
+ });
57
+ const providerFactory = createProviderFactory({ credentials: config.providerCredentials ?? {} });
58
+ const authorization = config.authorization ?? allowAllAuthorization();
59
+ const toolRegistry = createToolRegistry({ providers: config.tools ?? [], authorization });
60
+ const resolveModel = config.resolveModel ??
61
+ ((m) => {
62
+ const def = registry.resolve(m.modelPolicy);
63
+ return {
64
+ model: providerFactory.languageModel(def),
65
+ modelId: def.modelId,
66
+ currency: def.pricing.currency,
67
+ price: (u) => computeModelCostMinorUnits(def.pricing, { inputTokens: u.inputTokens, outputTokens: u.outputTokens, cachedInputTokens: u.cachedInputTokens }),
68
+ };
69
+ });
70
+ const contextProviders = config.contextProviders ?? [];
71
+ const engine = config.engine ?? createDefaultEngine({
72
+ async loadManifest() {
73
+ return manifest; // single-manifest embedded agent
74
+ },
75
+ resolveModel,
76
+ ...(contextProviders.length > 0
77
+ ? {
78
+ /**
79
+ * The system prompt, with external content quarantined (#145, AC-4).
80
+ *
81
+ * The previous version was `sections.map(s => "## " + s.title + "\n" + s.body)`. That is the one place
82
+ * a model most readily treats text as instruction, and a section body can be a fetched page, an MCP
83
+ * result or an extracted document. `contextProviders` is the *intended extension point* for exactly
84
+ * that content, and nothing in the type system warned the next person who wired one.
85
+ *
86
+ * `renderContextBlock` groups untrusted sections after the trusted ones under a standing preamble and
87
+ * encloses each in a nonce-delimited block with delimiter forgery neutralised. A fresh nonce per
88
+ * assembly, so content cannot learn the delimiter from a previous turn.
89
+ */
90
+ systemPrompt: async (m, context) => {
91
+ const sections = await gatherSections(context, contextProviders);
92
+ if (sections.length === 0)
93
+ return m.instructions;
94
+ const ctxText = renderContextBlock(sections, makeNonce(config.randomHex ?? defaultRandomHex));
95
+ return `${m.instructions}\n\n# Context\n${ctxText}`;
96
+ },
97
+ }
98
+ : {}),
99
+ async loadHistory(context) {
100
+ /**
101
+ * The non-null assertion is gone — #198. It was the only thing standing between a conversation-less run
102
+ * and a query keyed on `undefined`, which Postgres would have accepted as a literal and returned nothing
103
+ * for. A refusal that names the capability is the whole point of making the field optional.
104
+ */
105
+ if (context.conversationId === undefined)
106
+ throw new AgentPlatformError({
107
+ code: "invalid_input",
108
+ message: "history needs a conversation, and this context has none. The embedded runtime is conversation-based; " +
109
+ "for a run without one, use the composed runtime with history turned off.",
110
+ retryable: false,
111
+ });
112
+ const page = await messages.listByConversation({ tenantId: context.tenantId, conversationId: context.conversationId, limit: 1_000 });
113
+ return page.items.map((m) => ({
114
+ role: m.role === "assistant" ? "assistant" : "user",
115
+ // Text only here, deliberately: the embedded facade has no file store to resolve an attachment
116
+ // through, and inventing one would be the modality bridge going around file authorization — the
117
+ // failure #185 exists to avoid, reintroduced by the convenience path.
118
+ content: textOf(m.parts),
119
+ }));
120
+ },
121
+ ...(config.tools && config.tools.length > 0
122
+ ? {
123
+ buildTools: async (context) => {
124
+ const resolvedTools = [];
125
+ const gathered = (await Promise.all((config.tools ?? []).map((p) => p.listTools(context)))).flat();
126
+ const permitted = new Set((await authorization.filterTools(context, gathered.map((t) => t.descriptor))).map((d) => d.name));
127
+ for (const t of gathered) {
128
+ if (!permitted.has(t.descriptor.name))
129
+ continue;
130
+ resolvedTools.push({
131
+ name: t.descriptor.name,
132
+ description: t.descriptor.description,
133
+ inputSchema: t.descriptor.inputSchema,
134
+ execute: async (input) => {
135
+ const result = await toolRegistry.execute(context, { name: t.descriptor.name, input });
136
+ if (!result.ok)
137
+ throw new AgentPlatformError(result.error);
138
+ return result.data;
139
+ },
140
+ });
141
+ }
142
+ return resolvedTools;
143
+ },
144
+ }
145
+ : {}),
146
+ });
147
+ // Per-run execution context, so the worker's buildContext returns the right principal/conversation.
148
+ const contextByRun = new Map();
149
+ const worker = createDurableWorker({
150
+ runs,
151
+ checkpoints,
152
+ publisher: bus.publisher,
153
+ eventLog,
154
+ engine,
155
+ workerId: "embedded",
156
+ now,
157
+ buildContext: (run) => contextByRun.get(run.id),
158
+ });
159
+ let seq = 0;
160
+ return {
161
+ manifest,
162
+ /** Run one turn to completion and return the assistant's parts. State persists on the conversation. */
163
+ async run(input) {
164
+ const conversationId = asId(input.conversationId);
165
+ const principalId = asId(input.principalId ?? "user");
166
+ const runId = asId(`run-${(seq += 1)}`);
167
+ const context = {
168
+ tenantId,
169
+ principalId,
170
+ roleIds: (input.roleIds ?? []).map((r) => asId(r)),
171
+ locale: "en",
172
+ timezone: "UTC",
173
+ requestId: asId(`req-${seq}`),
174
+ conversationId,
175
+ runId,
176
+ };
177
+ contextByRun.set(runId, context);
178
+ if (!(await conversations.findById({ tenantId, id: conversationId }))) {
179
+ await conversations.create({ tenantId, id: conversationId, title: input.message.slice(0, 80) || "Conversation" });
180
+ }
181
+ await messages.append({ tenantId, message: userMessage(conversationId, `${runId}:user`, input.message) });
182
+ await runs.create({ tenantId, id: runId, conversationId, agentId: asId(manifest.id), agentVersion: manifest.version });
183
+ const result = await worker.process({ tenantId, runId });
184
+ const checkpoint = await checkpoints.latest({ tenantId, runId });
185
+ const parts = checkpoint?.parts ?? [];
186
+ // Persist the assistant turn so the next run's history includes it.
187
+ if (parts.length > 0) {
188
+ await messages.append({ tenantId, message: assistantMessage(conversationId, `${runId}:assistant`, parts) });
189
+ }
190
+ contextByRun.delete(runId);
191
+ return { runId, outcome: result.outcome, parts, text: textOf(parts) };
192
+ },
193
+ };
194
+ };
195
+ const userMessage = (conversationId, id, text) => ({
196
+ id: asId(id),
197
+ conversationId,
198
+ role: "user",
199
+ parts: [{ id: asId(`${id}:0`), type: "text", schemaVersion: 1, createdAt: new Date(0).toISOString(), text }],
200
+ createdAt: new Date(0).toISOString(),
201
+ });
202
+ const assistantMessage = (conversationId, id, parts) => ({
203
+ id: asId(id),
204
+ conversationId,
205
+ role: "assistant",
206
+ parts,
207
+ createdAt: new Date(0).toISOString(),
208
+ });
209
+ //# sourceMappingURL=agent.js.map
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Declaring an agent — the half of `agent.ts` that needs no provider (#196).
3
+ *
4
+ * `defineAgent`, the execution defaults and the starter catalog are **declarations**: data describing what an
5
+ * agent is. They stay reachable from the package root because nothing about writing one requires a model SDK.
6
+ *
7
+ * `createAgent` — the embedded facade that builds a provider factory from credentials — stayed in `agent.ts` and
8
+ * moved behind the `providers` entry. That convenience is the one thing here that costs six optional peers, and
9
+ * the cost belongs in the import path rather than being paid by everyone who imports the root.
10
+ */
11
+ import type { ModelDefinition, ModelRoleAssignments } from "../models/index.js";
12
+ import type { AgentManifest } from "./index.js";
13
+ /** The subset a caller must supply; everything else gets a sensible default. */
14
+ export type AgentManifestInput = Pick<AgentManifest, "id" | "name" | "instructions" | "modelPolicy"> & Partial<AgentManifest>;
15
+ export declare const DEFAULT_EXECUTION_LIMITS: AgentManifest["limits"];
16
+ /** Fill a partial manifest with defaults so the common case is a few fields. */
17
+ export declare const defineAgent: (input: AgentManifestInput) => AgentManifest;
18
+ /** A small default catalog so `modelPolicy: { role: "smart" }` resolves out of the box. */
19
+ export declare const DEFAULT_MODEL_CATALOG: readonly ModelDefinition[];
20
+ export declare const DEFAULT_ROLE_ASSIGNMENTS: ModelRoleAssignments;
21
+ //# sourceMappingURL=define.d.ts.map
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Declaring an agent — the half of `agent.ts` that needs no provider (#196).
3
+ *
4
+ * `defineAgent`, the execution defaults and the starter catalog are **declarations**: data describing what an
5
+ * agent is. They stay reachable from the package root because nothing about writing one requires a model SDK.
6
+ *
7
+ * `createAgent` — the embedded facade that builds a provider factory from credentials — stayed in `agent.ts` and
8
+ * moved behind the `providers` entry. That convenience is the one thing here that costs six optional peers, and
9
+ * the cost belongs in the import path rather than being paid by everyone who imports the root.
10
+ */
11
+ export const DEFAULT_EXECUTION_LIMITS = {
12
+ maxSteps: 8,
13
+ maxToolCalls: 16,
14
+ wallClockTimeoutMs: 120_000,
15
+ maxInputTokens: 100_000,
16
+ maxOutputTokens: 4_096,
17
+ costCeilingMinorUnits: 100_000,
18
+ maxRetries: 5,
19
+ retryBackoffMs: 500,
20
+ maxInlineToolOutputBytes: 8_192,
21
+ };
22
+ /** Fill a partial manifest with defaults so the common case is a few fields. */
23
+ export const defineAgent = (input) => ({
24
+ version: 1,
25
+ description: "",
26
+ responseFormat: { kind: "text" },
27
+ toolPolicy: { preloaded: [], categories: [], excluded: [] },
28
+ skillPolicy: { assigned: [], allowTenantSkills: false },
29
+ authorizationPolicyId: "default",
30
+ contextProviderIds: [],
31
+ limits: DEFAULT_EXECUTION_LIMITS,
32
+ ...input,
33
+ });
34
+ /** A small default catalog so `modelPolicy: { role: "smart" }` resolves out of the box. */
35
+ export const DEFAULT_MODEL_CATALOG = [
36
+ {
37
+ provider: "anthropic",
38
+ modelId: "claude-sonnet-5",
39
+ label: "Claude Sonnet 5",
40
+ lifecycle: "generally-available",
41
+ inputModalities: ["text", "image"],
42
+ capabilities: { tools: true, structuredOutput: true, reasoning: true, nativeSearch: false },
43
+ limits: { contextTokens: 200_000, maxOutputTokens: 8_192 },
44
+ pricing: { currency: "USD", inputPerMillion: 3_000, outputPerMillion: 15_000 },
45
+ dataResidency: ["us"],
46
+ },
47
+ {
48
+ provider: "anthropic",
49
+ modelId: "claude-haiku-4-5-20251001",
50
+ label: "Claude Haiku 4.5",
51
+ lifecycle: "generally-available",
52
+ inputModalities: ["text", "image"],
53
+ capabilities: { tools: true, structuredOutput: true, reasoning: false, nativeSearch: false },
54
+ limits: { contextTokens: 200_000, maxOutputTokens: 8_192 },
55
+ pricing: { currency: "USD", inputPerMillion: 800, outputPerMillion: 4_000 },
56
+ dataResidency: ["us"],
57
+ },
58
+ ];
59
+ export const DEFAULT_ROLE_ASSIGNMENTS = {
60
+ smart: ["claude-sonnet-5"],
61
+ fast: ["claude-haiku-4-5-20251001"],
62
+ };
63
+ //# sourceMappingURL=define.js.map