@heyo-sh/heyo-cms 0.0.0-stage → 0.2.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 (401) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +44 -2
  3. package/dist/access/index.d.ts +9 -0
  4. package/dist/access/index.d.ts.map +1 -0
  5. package/dist/access/permissions.d.ts +54 -0
  6. package/dist/access/permissions.d.ts.map +1 -0
  7. package/dist/adapters/astro.d.ts +45 -0
  8. package/dist/adapters/astro.d.ts.map +1 -0
  9. package/dist/adapters/astro.js +1 -0
  10. package/dist/adapters/deliver.d.ts +26 -0
  11. package/dist/adapters/deliver.d.ts.map +1 -0
  12. package/dist/adapters/next.d.ts +45 -0
  13. package/dist/adapters/next.d.ts.map +1 -0
  14. package/dist/adapters/next.js +1 -0
  15. package/dist/adapters/nuxt.d.ts +51 -0
  16. package/dist/adapters/nuxt.d.ts.map +1 -0
  17. package/dist/adapters/nuxt.js +1 -0
  18. package/dist/adapters/react-router.d.ts +36 -0
  19. package/dist/adapters/react-router.d.ts.map +1 -0
  20. package/dist/adapters/react-router.js +1 -0
  21. package/dist/adapters/sveltekit.d.ts +41 -0
  22. package/dist/adapters/sveltekit.d.ts.map +1 -0
  23. package/dist/adapters/sveltekit.js +1 -0
  24. package/dist/ai/assistant/context.d.ts +64 -0
  25. package/dist/ai/assistant/context.d.ts.map +1 -0
  26. package/dist/ai/assistant/limits.d.ts +10 -0
  27. package/dist/ai/assistant/limits.d.ts.map +1 -0
  28. package/dist/ai/assistant/plans.d.ts +83 -0
  29. package/dist/ai/assistant/plans.d.ts.map +1 -0
  30. package/dist/ai/assistant/prompt.d.ts +22 -0
  31. package/dist/ai/assistant/prompt.d.ts.map +1 -0
  32. package/dist/ai/assistant/run.d.ts +59 -0
  33. package/dist/ai/assistant/run.d.ts.map +1 -0
  34. package/dist/ai/assistant/runtime.d.ts +35 -0
  35. package/dist/ai/assistant/runtime.d.ts.map +1 -0
  36. package/dist/ai/assistant/schema.d.ts +66 -0
  37. package/dist/ai/assistant/schema.d.ts.map +1 -0
  38. package/dist/ai/assistant/tools.d.ts +41 -0
  39. package/dist/ai/assistant/tools.d.ts.map +1 -0
  40. package/dist/ai/assistant/values.d.ts +33 -0
  41. package/dist/ai/assistant/values.d.ts.map +1 -0
  42. package/dist/ai/crypto.d.ts +12 -0
  43. package/dist/ai/crypto.d.ts.map +1 -0
  44. package/dist/ai/index.d.ts +19 -0
  45. package/dist/ai/index.d.ts.map +1 -0
  46. package/dist/ai/pi.d.ts +89 -0
  47. package/dist/ai/pi.d.ts.map +1 -0
  48. package/dist/ai/registry.d.ts +66 -0
  49. package/dist/ai/registry.d.ts.map +1 -0
  50. package/dist/ai/service.d.ts +31 -0
  51. package/dist/ai/service.d.ts.map +1 -0
  52. package/dist/ai/variant-translation.d.ts +6 -0
  53. package/dist/ai/variant-translation.d.ts.map +1 -0
  54. package/dist/ai.d.ts +12 -0
  55. package/dist/ai.d.ts.map +1 -0
  56. package/dist/ai.js +1 -0
  57. package/dist/auth/config.d.ts +65 -0
  58. package/dist/auth/config.d.ts.map +1 -0
  59. package/dist/auth/crypto.d.ts +44 -0
  60. package/dist/auth/crypto.d.ts.map +1 -0
  61. package/dist/auth/index.d.ts +15 -0
  62. package/dist/auth/index.d.ts.map +1 -0
  63. package/dist/auth/oauth.d.ts +93 -0
  64. package/dist/auth/oauth.d.ts.map +1 -0
  65. package/dist/auth/service.d.ts +38 -0
  66. package/dist/auth/service.d.ts.map +1 -0
  67. package/dist/auth/totp.d.ts +34 -0
  68. package/dist/auth/totp.d.ts.map +1 -0
  69. package/dist/auth.d.ts +9 -0
  70. package/dist/auth.d.ts.map +1 -0
  71. package/dist/auth.js +1 -0
  72. package/dist/cli.d.ts +3 -0
  73. package/dist/cli.d.ts.map +1 -0
  74. package/dist/cli.js +30 -0
  75. package/dist/client/index.d.ts +51 -0
  76. package/dist/client/index.d.ts.map +1 -0
  77. package/dist/client/types.d.ts +363 -0
  78. package/dist/client/types.d.ts.map +1 -0
  79. package/dist/client.d.ts +46 -0
  80. package/dist/client.d.ts.map +1 -0
  81. package/dist/client.js +1 -0
  82. package/dist/config.d.ts +31 -0
  83. package/dist/config.d.ts.map +1 -0
  84. package/dist/config.js +1 -0
  85. package/dist/content/export.d.ts +28 -0
  86. package/dist/content/export.d.ts.map +1 -0
  87. package/dist/content/import.d.ts +65 -0
  88. package/dist/content/import.d.ts.map +1 -0
  89. package/dist/content/records.d.ts +73 -0
  90. package/dist/content/records.d.ts.map +1 -0
  91. package/dist/content.d.ts +12 -0
  92. package/dist/content.d.ts.map +1 -0
  93. package/dist/content.js +1 -0
  94. package/dist/db/d1.d.ts +29 -0
  95. package/dist/db/d1.d.ts.map +1 -0
  96. package/dist/db/d1.js +1 -0
  97. package/dist/db/mongodb.d.ts +128 -0
  98. package/dist/db/mongodb.d.ts.map +1 -0
  99. package/dist/db/mongodb.js +2 -0
  100. package/dist/db/postgres.d.ts +37 -0
  101. package/dist/db/postgres.d.ts.map +1 -0
  102. package/dist/db/postgres.js +1 -0
  103. package/dist/db/sql/adapter.d.ts +57 -0
  104. package/dist/db/sql/adapter.d.ts.map +1 -0
  105. package/dist/db/sql/compile.d.ts +50 -0
  106. package/dist/db/sql/compile.d.ts.map +1 -0
  107. package/dist/db/sql/ddl.d.ts +34 -0
  108. package/dist/db/sql/ddl.d.ts.map +1 -0
  109. package/dist/db/sql/dialect.d.ts +37 -0
  110. package/dist/db/sql/dialect.d.ts.map +1 -0
  111. package/dist/db/sql/driver.d.ts +34 -0
  112. package/dist/db/sql/driver.d.ts.map +1 -0
  113. package/dist/db/sql/introspect.d.ts +15 -0
  114. package/dist/db/sql/introspect.d.ts.map +1 -0
  115. package/dist/db/sqlite.d.ts +50 -0
  116. package/dist/db/sqlite.d.ts.map +1 -0
  117. package/dist/db/sqlite.js +1 -0
  118. package/dist/defaults.d.ts +5 -0
  119. package/dist/defaults.d.ts.map +1 -0
  120. package/dist/duration.d.ts +12 -0
  121. package/dist/duration.d.ts.map +1 -0
  122. package/dist/editor/builtin.d.ts +45 -0
  123. package/dist/editor/builtin.d.ts.map +1 -0
  124. package/dist/editor/index.d.ts +14 -0
  125. package/dist/editor/index.d.ts.map +1 -0
  126. package/dist/editor/markdown.d.ts +19 -0
  127. package/dist/editor/markdown.d.ts.map +1 -0
  128. package/dist/editor/registry.d.ts +30 -0
  129. package/dist/editor/registry.d.ts.map +1 -0
  130. package/dist/editor/serialize.d.ts +41 -0
  131. package/dist/editor/serialize.d.ts.map +1 -0
  132. package/dist/editor.d.ts +10 -0
  133. package/dist/editor.d.ts.map +1 -0
  134. package/dist/editor.js +1 -0
  135. package/dist/engine/access.d.ts +33 -0
  136. package/dist/engine/access.d.ts.map +1 -0
  137. package/dist/engine/activity.d.ts +16 -0
  138. package/dist/engine/activity.d.ts.map +1 -0
  139. package/dist/engine/cursor.d.ts +19 -0
  140. package/dist/engine/cursor.d.ts.map +1 -0
  141. package/dist/engine/documents.d.ts +81 -0
  142. package/dist/engine/documents.d.ts.map +1 -0
  143. package/dist/engine/engine.d.ts +295 -0
  144. package/dist/engine/engine.d.ts.map +1 -0
  145. package/dist/engine/field-access.d.ts +21 -0
  146. package/dist/engine/field-access.d.ts.map +1 -0
  147. package/dist/engine/hooks.d.ts +58 -0
  148. package/dist/engine/hooks.d.ts.map +1 -0
  149. package/dist/engine/index.d.ts +20 -0
  150. package/dist/engine/index.d.ts.map +1 -0
  151. package/dist/engine/jobs.d.ts +63 -0
  152. package/dist/engine/jobs.d.ts.map +1 -0
  153. package/dist/engine/locales.d.ts +40 -0
  154. package/dist/engine/locales.d.ts.map +1 -0
  155. package/dist/engine/outbox.d.ts +81 -0
  156. package/dist/engine/outbox.d.ts.map +1 -0
  157. package/dist/engine/relations.d.ts +60 -0
  158. package/dist/engine/relations.d.ts.map +1 -0
  159. package/dist/engine/scoped-db.d.ts +13 -0
  160. package/dist/engine/scoped-db.d.ts.map +1 -0
  161. package/dist/engine/slugs.d.ts +124 -0
  162. package/dist/engine/slugs.d.ts.map +1 -0
  163. package/dist/engine/trash.d.ts +25 -0
  164. package/dist/engine/trash.d.ts.map +1 -0
  165. package/dist/errors.d.ts +42 -0
  166. package/dist/errors.d.ts.map +1 -0
  167. package/dist/fields/builtin.d.ts +169 -0
  168. package/dist/fields/builtin.d.ts.map +1 -0
  169. package/dist/fields/index.d.ts +3 -0
  170. package/dist/fields/index.d.ts.map +1 -0
  171. package/dist/fields/registry.d.ts +35 -0
  172. package/dist/fields/registry.d.ts.map +1 -0
  173. package/dist/fields.d.ts +9 -0
  174. package/dist/fields.d.ts.map +1 -0
  175. package/dist/fields.js +1 -0
  176. package/dist/http/guard.d.ts +45 -0
  177. package/dist/http/guard.d.ts.map +1 -0
  178. package/dist/http/handler.d.ts +31 -0
  179. package/dist/http/handler.d.ts.map +1 -0
  180. package/dist/http/index.d.ts +13 -0
  181. package/dist/http/index.d.ts.map +1 -0
  182. package/dist/http/openapi.d.ts +5 -0
  183. package/dist/http/openapi.d.ts.map +1 -0
  184. package/dist/http/params.d.ts +32 -0
  185. package/dist/http/params.d.ts.map +1 -0
  186. package/dist/http/request-db.d.ts +19 -0
  187. package/dist/http/request-db.d.ts.map +1 -0
  188. package/dist/http/respond.d.ts +48 -0
  189. package/dist/http/respond.d.ts.map +1 -0
  190. package/dist/http/rich-text.d.ts +41 -0
  191. package/dist/http/rich-text.d.ts.map +1 -0
  192. package/dist/http/router.d.ts +55 -0
  193. package/dist/http/router.d.ts.map +1 -0
  194. package/dist/http/routes/access.d.ts +13 -0
  195. package/dist/http/routes/access.d.ts.map +1 -0
  196. package/dist/http/routes/admin.d.ts +28 -0
  197. package/dist/http/routes/admin.d.ts.map +1 -0
  198. package/dist/http/routes/ai.d.ts +26 -0
  199. package/dist/http/routes/ai.d.ts.map +1 -0
  200. package/dist/http/routes/auth.d.ts +13 -0
  201. package/dist/http/routes/auth.d.ts.map +1 -0
  202. package/dist/http/routes/documents.d.ts +24 -0
  203. package/dist/http/routes/documents.d.ts.map +1 -0
  204. package/dist/http/routes/generate.d.ts +5 -0
  205. package/dist/http/routes/generate.d.ts.map +1 -0
  206. package/dist/http/routes/media.d.ts +58 -0
  207. package/dist/http/routes/media.d.ts.map +1 -0
  208. package/dist/http/routes/panel.d.ts +20 -0
  209. package/dist/http/routes/panel.d.ts.map +1 -0
  210. package/dist/http/routes/system.d.ts +25 -0
  211. package/dist/http/routes/system.d.ts.map +1 -0
  212. package/dist/http/routes/webhooks.d.ts +17 -0
  213. package/dist/http/routes/webhooks.d.ts.map +1 -0
  214. package/dist/http/spec.d.ts +28 -0
  215. package/dist/http/spec.d.ts.map +1 -0
  216. package/dist/http.d.ts +17 -0
  217. package/dist/http.d.ts.map +1 -0
  218. package/dist/http.js +1 -0
  219. package/dist/i18n/index.d.ts +12 -0
  220. package/dist/i18n/index.d.ts.map +1 -0
  221. package/dist/i18n/names.d.ts +25 -0
  222. package/dist/i18n/names.d.ts.map +1 -0
  223. package/dist/ids.d.ts +28 -0
  224. package/dist/ids.d.ts.map +1 -0
  225. package/dist/index-2ddk43me.js +2 -0
  226. package/dist/index-2prbs05k.js +2 -0
  227. package/dist/index-385ggnge.js +2 -0
  228. package/dist/index-466cwb0b.js +2 -0
  229. package/dist/index-4qrep5f0.js +26 -0
  230. package/dist/index-67e458ws.js +2 -0
  231. package/dist/index-6m1kjq9g.js +2 -0
  232. package/dist/index-6w10rch0.js +3 -0
  233. package/dist/index-761dec5z.js +2 -0
  234. package/dist/index-8nzmqy0f.js +2 -0
  235. package/dist/index-8x2em6c8.js +14 -0
  236. package/dist/index-91fa1gzf.js +2 -0
  237. package/dist/index-9g2n7xa6.js +2 -0
  238. package/dist/index-a8jcwqsf.js +2 -0
  239. package/dist/index-abfzb1ve.js +2 -0
  240. package/dist/index-cv0hpz3d.js +2 -0
  241. package/dist/index-ebtj6ebd.js +0 -0
  242. package/dist/index-g041kfa5.js +18 -0
  243. package/dist/index-g4crf47y.js +0 -0
  244. package/dist/index-hbx67b20.js +7 -0
  245. package/dist/index-hpast878.js +40 -0
  246. package/dist/index-kc1j3h6z.js +2 -0
  247. package/dist/index-p2cqsmvw.js +2 -0
  248. package/dist/index-rg9tpg3p.js +5 -0
  249. package/dist/index-rw0hze6x.js +2 -0
  250. package/dist/index-s9x07zb3.js +2 -0
  251. package/dist/index-sgdnp83t.js +2 -0
  252. package/dist/index-szaq03qq.js +2 -0
  253. package/dist/index-vkwzdfte.js +5 -0
  254. package/dist/index-vzhxn50e.js +2 -0
  255. package/dist/index-x72d1hzh.js +2 -0
  256. package/dist/index-y8kzzn94.js +2 -0
  257. package/dist/index-ypcmns0v.js +2 -0
  258. package/dist/index.d.ts +25 -0
  259. package/dist/index.d.ts.map +1 -0
  260. package/dist/index.js +1 -0
  261. package/dist/jobs/runner.d.ts +77 -0
  262. package/dist/jobs/runner.d.ts.map +1 -0
  263. package/dist/jobs.d.ts +11 -0
  264. package/dist/jobs.d.ts.map +1 -0
  265. package/dist/jobs.js +1 -0
  266. package/dist/media/cloudflare.d.ts +58 -0
  267. package/dist/media/cloudflare.d.ts.map +1 -0
  268. package/dist/media/document.d.ts +29 -0
  269. package/dist/media/document.d.ts.map +1 -0
  270. package/dist/media/gc.d.ts +46 -0
  271. package/dist/media/gc.d.ts.map +1 -0
  272. package/dist/media/index.d.ts +20 -0
  273. package/dist/media/index.d.ts.map +1 -0
  274. package/dist/media/pipeline.d.ts +55 -0
  275. package/dist/media/pipeline.d.ts.map +1 -0
  276. package/dist/media/probe.d.ts +6 -0
  277. package/dist/media/probe.d.ts.map +1 -0
  278. package/dist/media/service.d.ts +26 -0
  279. package/dist/media/service.d.ts.map +1 -0
  280. package/dist/media/sharp.d.ts +28 -0
  281. package/dist/media/sharp.d.ts.map +1 -0
  282. package/dist/media/strip.d.ts +16 -0
  283. package/dist/media/strip.d.ts.map +1 -0
  284. package/dist/media/urls.d.ts +77 -0
  285. package/dist/media/urls.d.ts.map +1 -0
  286. package/dist/media/usages.d.ts +77 -0
  287. package/dist/media/usages.d.ts.map +1 -0
  288. package/dist/media/variants.d.ts +61 -0
  289. package/dist/media/variants.d.ts.map +1 -0
  290. package/dist/migrations.d.ts +115 -0
  291. package/dist/migrations.d.ts.map +1 -0
  292. package/dist/migrations.js +1 -0
  293. package/dist/panel.d.ts +31 -0
  294. package/dist/panel.d.ts.map +1 -0
  295. package/dist/plugins/indexnow.d.ts +82 -0
  296. package/dist/plugins/indexnow.d.ts.map +1 -0
  297. package/dist/plugins.d.ts +9 -0
  298. package/dist/plugins.d.ts.map +1 -0
  299. package/dist/plugins.js +1 -0
  300. package/dist/query.d.ts +40 -0
  301. package/dist/query.d.ts.map +1 -0
  302. package/dist/query.js +1 -0
  303. package/dist/run-bjge3v8e.js +6 -0
  304. package/dist/schema/describe.d.ts +19 -0
  305. package/dist/schema/describe.d.ts.map +1 -0
  306. package/dist/schema/index.d.ts +5 -0
  307. package/dist/schema/index.d.ts.map +1 -0
  308. package/dist/schema/plan.d.ts +20 -0
  309. package/dist/schema/plan.d.ts.map +1 -0
  310. package/dist/schema/snapshot.d.ts +24 -0
  311. package/dist/schema/snapshot.d.ts.map +1 -0
  312. package/dist/schema/system.d.ts +31 -0
  313. package/dist/schema/system.d.ts.map +1 -0
  314. package/dist/schema.d.ts +7 -0
  315. package/dist/schema.d.ts.map +1 -0
  316. package/dist/schema.js +1 -0
  317. package/dist/slugify.d.ts +31 -0
  318. package/dist/slugify.d.ts.map +1 -0
  319. package/dist/storage/bytes.d.ts +17 -0
  320. package/dist/storage/bytes.d.ts.map +1 -0
  321. package/dist/storage/http.d.ts +43 -0
  322. package/dist/storage/http.d.ts.map +1 -0
  323. package/dist/storage/local.d.ts +31 -0
  324. package/dist/storage/local.d.ts.map +1 -0
  325. package/dist/storage/providers.d.ts +95 -0
  326. package/dist/storage/providers.d.ts.map +1 -0
  327. package/dist/storage/sign.d.ts +53 -0
  328. package/dist/storage/sign.d.ts.map +1 -0
  329. package/dist/strings.d.ts +13 -0
  330. package/dist/strings.d.ts.map +1 -0
  331. package/dist/telemetry.d.ts +137 -0
  332. package/dist/telemetry.d.ts.map +1 -0
  333. package/dist/telemetry.js +1 -0
  334. package/dist/types/activity.d.ts +68 -0
  335. package/dist/types/activity.d.ts.map +1 -0
  336. package/dist/types/actor.d.ts +26 -0
  337. package/dist/types/actor.d.ts.map +1 -0
  338. package/dist/types/ai.d.ts +357 -0
  339. package/dist/types/ai.d.ts.map +1 -0
  340. package/dist/types/api.d.ts +268 -0
  341. package/dist/types/api.d.ts.map +1 -0
  342. package/dist/types/auth.d.ts +310 -0
  343. package/dist/types/auth.d.ts.map +1 -0
  344. package/dist/types/config.d.ts +647 -0
  345. package/dist/types/config.d.ts.map +1 -0
  346. package/dist/types/database.d.ts +75 -0
  347. package/dist/types/database.d.ts.map +1 -0
  348. package/dist/types/editor.d.ts +166 -0
  349. package/dist/types/editor.d.ts.map +1 -0
  350. package/dist/types/events.d.ts +72 -0
  351. package/dist/types/events.d.ts.map +1 -0
  352. package/dist/types/fields.d.ts +142 -0
  353. package/dist/types/fields.d.ts.map +1 -0
  354. package/dist/types/hooks.d.ts +142 -0
  355. package/dist/types/hooks.d.ts.map +1 -0
  356. package/dist/types/index.d.ts +25 -0
  357. package/dist/types/index.d.ts.map +1 -0
  358. package/dist/types/instance.d.ts +263 -0
  359. package/dist/types/instance.d.ts.map +1 -0
  360. package/dist/types/jobs.d.ts +78 -0
  361. package/dist/types/jobs.d.ts.map +1 -0
  362. package/dist/types/json.d.ts +24 -0
  363. package/dist/types/json.d.ts.map +1 -0
  364. package/dist/types/locales.d.ts +30 -0
  365. package/dist/types/locales.d.ts.map +1 -0
  366. package/dist/types/media.d.ts +342 -0
  367. package/dist/types/media.d.ts.map +1 -0
  368. package/dist/types/panel.d.ts +249 -0
  369. package/dist/types/panel.d.ts.map +1 -0
  370. package/dist/types/plugin.d.ts +194 -0
  371. package/dist/types/plugin.d.ts.map +1 -0
  372. package/dist/types/query.d.ts +101 -0
  373. package/dist/types/query.d.ts.map +1 -0
  374. package/dist/types/schema.d.ts +203 -0
  375. package/dist/types/schema.d.ts.map +1 -0
  376. package/dist/types/storage.d.ts +61 -0
  377. package/dist/types/storage.d.ts.map +1 -0
  378. package/dist/types/telemetry.d.ts +14 -0
  379. package/dist/types/telemetry.d.ts.map +1 -0
  380. package/dist/types/trash.d.ts +42 -0
  381. package/dist/types/trash.d.ts.map +1 -0
  382. package/dist/types/webhooks.d.ts +133 -0
  383. package/dist/types/webhooks.d.ts.map +1 -0
  384. package/dist/types.d.ts +8 -0
  385. package/dist/types.d.ts.map +1 -0
  386. package/dist/types.js +1 -0
  387. package/dist/uploads.d.ts +22 -0
  388. package/dist/uploads.d.ts.map +1 -0
  389. package/dist/uploads.js +9 -0
  390. package/dist/webhooks/index.d.ts +10 -0
  391. package/dist/webhooks/index.d.ts.map +1 -0
  392. package/dist/webhooks/job.d.ts +17 -0
  393. package/dist/webhooks/job.d.ts.map +1 -0
  394. package/dist/webhooks/service.d.ts +53 -0
  395. package/dist/webhooks/service.d.ts.map +1 -0
  396. package/dist/webhooks/sign.d.ts +26 -0
  397. package/dist/webhooks/sign.d.ts.map +1 -0
  398. package/dist/webhooks.d.ts +10 -0
  399. package/dist/webhooks.d.ts.map +1 -0
  400. package/dist/webhooks.js +1 -0
  401. package/package.json +187 -4
@@ -0,0 +1,59 @@
1
+ /**
2
+ * The panel-wide AI assistant.
3
+ *
4
+ * One agent, running inside the CMS process, with a small set of typed tools
5
+ * that call the ordinary public API. That last part is the whole design: a
6
+ * mutating tool goes through `cms.api.*` / `cms.globals.*` / `cms.media.*`
7
+ * with the real actor and `source: "ai"`, so an agent write passes exactly the
8
+ * same access control, field access, validation, hooks, media accounting,
9
+ * events and activity log as somebody typing into the form.
10
+ *
11
+ * There is no SQL tool, no adapter access, no fetch, no file read and no
12
+ * credential tool. The question "what could a prompt injection make this do"
13
+ * has a bounded answer because the surface is bounded.
14
+ *
15
+ * Nothing re-exports this directory as a barrel on purpose: `ai/service.ts`
16
+ * imports `./assistant/run` lazily, so a project without the assistant never
17
+ * resolves the agent runtime's optional dependencies.
18
+ */
19
+ import type { Actor } from "../../types/actor";
20
+ import type { AiApprovePlanArgs, AiApprovePlanResult, AiAssistantArgs, AiAssistantEvent } from "../../types/ai";
21
+ import type { AiAuth, ResolvedCmsConfig } from "../../types/config";
22
+ import type { DatabaseAdapter } from "../../types/database";
23
+ import type { CmsInstance } from "../../types/instance";
24
+ import type { JsonObject } from "../../types/json";
25
+ export interface AssistantRunOptions {
26
+ args: AiAssistantArgs;
27
+ config: ResolvedCmsConfig;
28
+ cms: CmsInstance;
29
+ database: () => Promise<DatabaseAdapter>;
30
+ authFor: (provider: string) => Promise<AiAuth>;
31
+ record: (type: "ai.agent.completed" | "ai.agent.failed" | "ai.agent.mutation.applied", data: JsonObject, actor: Actor | null, failure?: unknown) => Promise<void>;
32
+ }
33
+ /**
34
+ * One run of the assistant, as a stream of events the panel understands.
35
+ *
36
+ * An async generator rather than a callback or a `Response`: the HTTP layer
37
+ * wants a stream, a test wants an array, and `cms.ai.runAssistant()` as a local
38
+ * API wants to be awaited in a loop. All three are the same object here, and
39
+ * none of them can see pi's own event vocabulary.
40
+ */
41
+ export declare function runAssistant(options: AssistantRunOptions): AsyncGenerator<AiAssistantEvent>;
42
+ export interface ApprovePlanOptions {
43
+ args: AiApprovePlanArgs;
44
+ config: ResolvedCmsConfig;
45
+ cms: CmsInstance;
46
+ database: () => Promise<DatabaseAdapter>;
47
+ record: (type: "ai.agent.completed" | "ai.agent.failed" | "ai.agent.mutation.applied", data: JsonObject, actor: Actor | null, failure?: unknown) => Promise<void>;
48
+ }
49
+ /**
50
+ * Executing a plan a human approved.
51
+ *
52
+ * The model is not in this function and that is the whole point. The row is
53
+ * read, the session is checked again, the permissions are checked again by
54
+ * the engine on every write, and the operations run exactly as they were
55
+ * stored. An approval that went back through the model would be an approval
56
+ * of something the editor never saw.
57
+ */
58
+ export declare function approvePlan(options: ApprovePlanOptions): Promise<AiApprovePlanResult>;
59
+ //# sourceMappingURL=run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/ai/assistant/run.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EACV,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAKjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EACV,MAAM,EAEN,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,kBAAkB,CAAC;AAoB9D,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,eAAe,CAAC;IACtB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,GAAG,EAAE,WAAW,CAAC;IACjB,QAAQ,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAAC;IACzC,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/C,MAAM,EAAE,CACN,IAAI,EACF,oBAAoB,GAAG,iBAAiB,GAAG,2BAA2B,EACxE,IAAI,EAAE,UAAU,EAChB,KAAK,EAAE,KAAK,GAAG,IAAI,EACnB,OAAO,CAAC,EAAE,OAAO,KACd,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB;AAED;;;;;;;GAOG;AACH,wBAAuB,YAAY,CACjC,OAAO,EAAE,mBAAmB,GAC3B,cAAc,CAAC,gBAAgB,CAAC,CA2OlC;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,iBAAiB,CAAC;IACxB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,GAAG,EAAE,WAAW,CAAC;IACjB,QAAQ,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAAC;IACzC,MAAM,EAAE,CACN,IAAI,EACF,oBAAoB,GAAG,iBAAiB,GAAG,2BAA2B,EACxE,IAAI,EAAE,UAAU,EAChB,KAAK,EAAE,KAAK,GAAG,IAAI,EACnB,OAAO,CAAC,EAAE,OAAO,KACd,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB;AAED;;;;;;;;GAQG;AACH,wBAAsB,WAAW,CAC/B,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,mBAAmB,CAAC,CAgD9B"}
@@ -0,0 +1,35 @@
1
+ import type { AiUsage } from "../../types/ai";
2
+ /**
3
+ * `@mariozechner/pi-agent-core`, under the floor.
4
+ *
5
+ * The same arrangement as `pi-ai` in `../pi.ts` and for the same two reasons:
6
+ * a deployment without AI must not carry an agent runtime in its bundle, and
7
+ * the package is an optional peer dependency — a CMS that refused to start
8
+ * because the agent library is missing would make the assistant mandatory in
9
+ * all but name.
10
+ *
11
+ * The one difference is that there is no fallback. `ai.complete` is a real
12
+ * seam for a field action, because a field action is one prompt and one
13
+ * answer. An agent is a tool-call loop, and a single completion cannot
14
+ * emulate one; pretending otherwise would produce an assistant that confidently
15
+ * describes writes it never made. So when the package is absent the endpoint
16
+ * says so, by name.
17
+ */
18
+ type AgentModule = typeof import("@mariozechner/pi-agent-core");
19
+ export type Agent = InstanceType<AgentModule["Agent"]>;
20
+ export type AgentTool = import("@mariozechner/pi-agent-core").AgentTool;
21
+ export type AgentEvent = Parameters<Parameters<Agent["subscribe"]>[0]>[0];
22
+ export declare function agentRuntime(): Promise<AgentModule>;
23
+ /** What a tool hands back to the model. Text only, by construction. */
24
+ export declare function toolText(text: string): {
25
+ content: {
26
+ type: "text";
27
+ text: string;
28
+ }[];
29
+ details: Record<string, never>;
30
+ };
31
+ /** The empty usage a run that never reached a model still has to report. */
32
+ export declare function emptyUsage(): AiUsage;
33
+ export declare function addUsage(left: AiUsage, right: AiUsage): AiUsage;
34
+ export {};
35
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/ai/assistant/runtime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;;;;;;;;;;;;;;GAeG;AAEH,KAAK,WAAW,GAAG,cAAc,6BAA6B,CAAC,CAAC;AAEhE,MAAM,MAAM,KAAK,GAAG,YAAY,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;AACvD,MAAM,MAAM,SAAS,GAAG,OAAO,6BAA6B,EAAE,SAAS,CAAC;AACxE,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAI1E,wBAAsB,YAAY,IAAI,OAAO,CAAC,WAAW,CAAC,CAQzD;AAED,uEAAuE;AACvE,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG;IACtC,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC1C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;CAChC,CAEA;AAED,4EAA4E;AAC5E,wBAAgB,UAAU,IAAI,OAAO,CAEpC;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAO/D"}
@@ -0,0 +1,66 @@
1
+ import type { Actor } from "../../types/actor";
2
+ import type { ResolvedCmsConfig, ResolvedCollection } from "../../types/config";
3
+ /**
4
+ * The project, as the model may know it.
5
+ *
6
+ * This is the whole answer to "how does the agent know the format of the
7
+ * database". Not a dump of the configuration — the configuration is full of
8
+ * closures, secrets and hook bodies — but a serialisable projection of it,
9
+ * rebuilt per actor, containing only what that actor can already see by
10
+ * opening the panel.
11
+ *
12
+ * Fetched on demand through `describe_cms` rather than pasted into the system
13
+ * prompt. A project with sixty collections would otherwise cost its entire
14
+ * schema in tokens on every turn of every conversation, including the ones
15
+ * that only asked what time it is.
16
+ */
17
+ export interface AssistantFieldDescription {
18
+ name: string;
19
+ type: string;
20
+ label: string;
21
+ required: boolean;
22
+ localized: boolean;
23
+ /** Present for `select`/`multiselect`: the values that are legal. */
24
+ options?: string[];
25
+ /** Present for `relation`: the collection an id has to come from. */
26
+ relationTo?: string;
27
+ /** `false` means the actor may read it but not write it. */
28
+ writable: boolean;
29
+ }
30
+ export interface AssistantCollectionDescription {
31
+ name: string;
32
+ slug: string;
33
+ label: string;
34
+ kind: "collection" | "global";
35
+ titleField: string | null;
36
+ fields: AssistantFieldDescription[];
37
+ can: {
38
+ read: boolean;
39
+ create: boolean;
40
+ update: boolean;
41
+ delete: boolean;
42
+ };
43
+ }
44
+ export interface AssistantSchema {
45
+ collections: AssistantCollectionDescription[];
46
+ globals: AssistantCollectionDescription[];
47
+ defaultLocale: string;
48
+ locales: string[];
49
+ media: boolean;
50
+ trash: boolean;
51
+ /**
52
+ * Changes when the shape does.
53
+ *
54
+ * The cache key for one run. A schema the agent looked at two tool calls ago
55
+ * is still the schema it is writing against, and re-deriving it per call
56
+ * would be the one part of this file that costs anything.
57
+ */
58
+ fingerprint: string;
59
+ }
60
+ export declare function describeCmsFor(config: ResolvedCmsConfig, actor: Actor | null, locales: string[]): AssistantSchema;
61
+ /** Whether a field could be written at all by this actor, right now. */
62
+ export declare function mayWriteField(collection: ResolvedCollection, name: string, actor: Actor | null, locale: string): boolean;
63
+ /** Whether a field's value may be read by this actor. */
64
+ export declare function mayReadField(collection: ResolvedCollection, name: string, actor: Actor | null, locale: string): boolean;
65
+ export declare function titleField(collection: ResolvedCollection): string | null;
66
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/ai/assistant/schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAIhF;;;;;;;;;;;;;GAaG;AAEH,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,qEAAqE;IACrE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4DAA4D;IAC5D,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,8BAA8B;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,YAAY,GAAG,QAAQ,CAAC;IAC9B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,MAAM,EAAE,yBAAyB,EAAE,CAAC;IACpC,GAAG,EAAE;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,OAAO,CAAA;KAAE,CAAC;CAC3E;AAED,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,8BAA8B,EAAE,CAAC;IAC9C,OAAO,EAAE,8BAA8B,EAAE,CAAC;IAC1C,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf;;;;;;OAMG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,cAAc,CAC5B,MAAM,EAAE,iBAAiB,EACzB,KAAK,EAAE,KAAK,GAAG,IAAI,EACnB,OAAO,EAAE,MAAM,EAAE,GAChB,eAAe,CAkBjB;AA+ED,wEAAwE;AACxE,wBAAgB,aAAa,CAC3B,UAAU,EAAE,kBAAkB,EAC9B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,KAAK,GAAG,IAAI,EACnB,MAAM,EAAE,MAAM,GACb,OAAO,CAUT;AAED,yDAAyD;AACzD,wBAAgB,YAAY,CAC1B,UAAU,EAAE,kBAAkB,EAC9B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,KAAK,GAAG,IAAI,EACnB,MAAM,EAAE,MAAM,GACb,OAAO,CAGT;AA4BD,wBAAgB,UAAU,CAAC,UAAU,EAAE,kBAAkB,GAAG,MAAM,GAAG,IAAI,CAYxE"}
@@ -0,0 +1,41 @@
1
+ import type { Actor } from "../../types/actor";
2
+ import type { AiMutationTarget } from "../../types/ai";
3
+ import type { CollectionApi, GlobalApi } from "../../types/api";
4
+ import type { ResolvedCmsConfig, ResolvedCollection } from "../../types/config";
5
+ import type { CmsInstance } from "../../types/instance";
6
+ import type { JsonObject } from "../../types/json";
7
+ import { type ResolvedPageContext } from "./context";
8
+ import { planSummary, PlanStore } from "./plans";
9
+ import { type AgentTool } from "./runtime";
10
+ /**
11
+ * What a tool is allowed to change about the run around it.
12
+ *
13
+ * Narrow on purpose. A tool may read the configuration, call the instance,
14
+ * announce a mutation and park a plan. It cannot reach the transport, the
15
+ * conversation, the model or the system prompt — which is what makes "the
16
+ * record said to ignore previous instructions" a sentence in a tool result
17
+ * rather than a privilege escalation.
18
+ */
19
+ export interface ToolContext {
20
+ config: ResolvedCmsConfig;
21
+ cms: CmsInstance;
22
+ actor: Actor | null;
23
+ page: ResolvedPageContext;
24
+ runId: string;
25
+ plans: PlanStore;
26
+ /** Announced to the panel the moment a write commits. */
27
+ onMutation: (target: AiMutationTarget, fields: string[]) => void;
28
+ /** Announced when a plan needs a human. */
29
+ onPlan: (plan: ReturnType<typeof planSummary>) => void;
30
+ /** Spent by every tool call; the server's budget, not the model's. */
31
+ spend: () => void;
32
+ signal?: AbortSignal | undefined;
33
+ }
34
+ export declare function createAssistantTools(context: ToolContext): AgentTool[];
35
+ export declare function collectionApi(context: {
36
+ cms: CmsInstance;
37
+ }, collection: ResolvedCollection): CollectionApi<JsonObject>;
38
+ export declare function globalApi(context: {
39
+ cms: CmsInstance;
40
+ }, global: ResolvedCollection): GlobalApi<JsonObject>;
41
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/ai/assistant/tools.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAChF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,kBAAkB,CAAC;AAE9D,OAAO,EAAgC,KAAK,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACnF,OAAO,EAEL,WAAW,EACX,SAAS,EAEV,MAAM,SAAS,CAAC;AAQjB,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAarD;;;;;;;;GAQG;AACH,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,iBAAiB,CAAC;IAC1B,GAAG,EAAE,WAAW,CAAC;IACjB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,IAAI,EAAE,mBAAmB,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,SAAS,CAAC;IACjB,yDAAyD;IACzD,UAAU,EAAE,CAAC,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACjE,2CAA2C;IAC3C,MAAM,EAAE,CAAC,IAAI,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,KAAK,IAAI,CAAC;IACvD,sEAAsE;IACtE,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;CAClC;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,WAAW,GAAG,SAAS,EAAE,CAoBtE;AA8iCD,wBAAgB,aAAa,CAC3B,OAAO,EAAE;IAAE,GAAG,EAAE,WAAW,CAAA;CAAE,EAC7B,UAAU,EAAE,kBAAkB,GAC7B,aAAa,CAAC,UAAU,CAAC,CAQ3B;AAED,wBAAgB,SAAS,CACvB,OAAO,EAAE;IAAE,GAAG,EAAE,WAAW,CAAA;CAAE,EAC7B,MAAM,EAAE,kBAAkB,GACzB,SAAS,CAAC,UAAU,CAAC,CAMvB"}
@@ -0,0 +1,33 @@
1
+ import type { ResolvedCollection } from "../../types/config";
2
+ import type { JsonObject, JsonValue } from "../../types/json";
3
+ /**
4
+ * The record, rendered for a model.
5
+ *
6
+ * Rich text becomes Markdown, because a ProseMirror document costs three times
7
+ * the tokens to say the same thing and no model writes one back correctly.
8
+ * Everything is length-capped, with the truncation stated in the text rather
9
+ * than hidden: a model that cannot tell it was given half a document will
10
+ * confidently rewrite the half it saw and delete the rest.
11
+ */
12
+ export declare function renderRecord(collection: ResolvedCollection, document: JsonObject, visible: string[]): string;
13
+ /**
14
+ * One field of a patch, in the shape the field stores.
15
+ *
16
+ * Exactly one conversion happens here — Markdown to a ProseMirror document for
17
+ * `richText` — and nothing else is "helpfully" coerced. A model that answered
18
+ * `"42"` for a number field has misunderstood the schema, and silently
19
+ * parsing it would hide the misunderstanding until the day it answers
20
+ * `"forty-two"`. The validation error is the useful outcome: the agent reads
21
+ * it, re-reads the schema and corrects itself.
22
+ */
23
+ export declare function shapeFieldValue(collection: ResolvedCollection, name: string, value: JsonValue): JsonValue;
24
+ /**
25
+ * The title a human would recognise the record by.
26
+ *
27
+ * Falls back to the id, which is always true and occasionally useful. A search
28
+ * result labelled `undefined` is worse than one labelled `doc_8sKq…`.
29
+ */
30
+ export declare function recordTitle(document: JsonObject, titleField: string | null): string;
31
+ /** A one-line gist of a record, for a search result that must stay short. */
32
+ export declare function recordSummary(collection: ResolvedCollection, document: JsonObject, skip: string[], limit?: number): string;
33
+ //# sourceMappingURL=values.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"values.d.ts","sourceRoot":"","sources":["../../../src/ai/assistant/values.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAO9D;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAC1B,UAAU,EAAE,kBAAkB,EAC9B,QAAQ,EAAE,UAAU,EACpB,OAAO,EAAE,MAAM,EAAE,GAChB,MAAM,CAuBR;AA6BD;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,kBAAkB,EAC9B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,SAAS,GACf,SAAS,CAYX;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,UAAU,EACpB,UAAU,EAAE,MAAM,GAAG,IAAI,GACxB,MAAM,CAKR;AAED,6EAA6E;AAC7E,wBAAgB,aAAa,CAC3B,UAAU,EAAE,kBAAkB,EAC9B,QAAQ,EAAE,UAAU,EACpB,IAAI,EAAE,MAAM,EAAE,EACd,KAAK,SAAM,GACV,MAAM,CAaR"}
@@ -0,0 +1,12 @@
1
+ export declare function encryptSecret(plaintext: string, secret: string): Promise<string>;
2
+ /**
3
+ * Decrypts, or says what is wrong.
4
+ *
5
+ * A value that will not decrypt is almost always a rotated secret rather
6
+ * than tampering, and the error says so: the alternative is an operator
7
+ * staring at "AI failed" after changing an environment variable.
8
+ */
9
+ export declare function decryptSecret(stored: string, secret: string): Promise<string>;
10
+ /** The last four characters, so a key can be recognised but not used. */
11
+ export declare function keyHint(token: string): string;
12
+ //# sourceMappingURL=crypto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../src/ai/crypto.ts"],"names":[],"mappings":"AAsCA,wBAAsB,aAAa,CACjC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,MAAM,CAAC,CAWjB;AAED;;;;;;GAMG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,MAAM,CAAC,CAmBjB;AAED,yEAAyE;AACzE,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7C"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * The AI runtime (section 8).
3
+ *
4
+ * Two things live here and they are deliberately separate. A **field action**
5
+ * is one prompt about one field that produces a value a human approves —
6
+ * `field.ai` is its only switch. The **assistant** is a panel-wide agent with
7
+ * tools that read and write through the ordinary API; `ai.assistant` is its
8
+ * only switch. Importing this module registers the built-in field actions, so
9
+ * `generate`, `improve`, `summarize`, `translate`, `alt` and `tags` exist for
10
+ * any field type that declares them — and `defineAiAction()` adds one on
11
+ * exactly the same terms.
12
+ */
13
+ export { aiActionsFor, altAction, customAiAction, defineAiAction, generateAction, getAiAction, improveAction, registeredAiActions, summarizeAction, tagsAction, translateAction, } from "./registry";
14
+ export { decryptSecret, encryptSecret, keyHint } from "./crypto";
15
+ export { assertModelExists, authTypesForAiProvider, modelsForProvider, piCompletion, } from "./pi";
16
+ export { aiCredentialsTable, createAi } from "./service";
17
+ export { describeCmsFor } from "./assistant/schema";
18
+ export type { AssistantSchema } from "./assistant/schema";
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ai/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EACL,YAAY,EACZ,SAAS,EACT,cAAc,EACd,cAAc,EACd,cAAc,EACd,WAAW,EACX,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,UAAU,EACV,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACjE,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,iBAAiB,EACjB,YAAY,GACb,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAIzD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,89 @@
1
+ import type { AiCompletionFn, AiUsage } from "../types/ai";
2
+ import type { AiAuth } from "../types/config";
3
+ import type { AiModelRef } from "../types/fields";
4
+ type PiApi = import("@mariozechner/pi-ai").Api;
5
+ type PiModel<T extends PiApi> = import("@mariozechner/pi-ai").Model<T>;
6
+ /**
7
+ * The two ways pi lets a caller authenticate, as the agent takes them.
8
+ *
9
+ * Typed structurally rather than against `AgentOptions` on purpose: this file
10
+ * must stay importable when `@mariozechner/pi-agent-core` is not installed,
11
+ * which is the normal case for a deployment that only uses field actions.
12
+ */
13
+ export interface PiAgentAuthOptions {
14
+ getApiKey?: (provider?: string) => string | Promise<string>;
15
+ streamFn?: (...args: Parameters<typeof import("@mariozechner/pi-ai").streamSimple>) => ReturnType<typeof import("@mariozechner/pi-ai").streamSimple>;
16
+ }
17
+ /**
18
+ * pi, under the floor.
19
+ *
20
+ * The same arrangement as `heyo-docs` (section 8): pi owns the provider
21
+ * catalogue and the transport, and it never appears in the configuration. A
22
+ * user writes `{ provider: "openai", model: "gpt-4o-mini" }` and the only
23
+ * thing this file does is look that pair up, attach the right kind of
24
+ * credential, and hand back text and a token count.
25
+ *
26
+ * Imported dynamically for two reasons that both matter in this project: a
27
+ * deployment without an `ai` section must not carry a provider catalogue in
28
+ * its bundle, and `@mariozechner/pi-ai` is an optional peer dependency — a
29
+ * CMS that refuses to start because AI is not installed would make AI
30
+ * mandatory in all but name.
31
+ */
32
+ type PiModule = typeof import("@mariozechner/pi-ai");
33
+ export declare function pi(): Promise<PiModule>;
34
+ /**
35
+ * The model object pi works with, from the `{ provider, model }` pair the
36
+ * configuration carries.
37
+ *
38
+ * Shared with the agent rather than reimplemented beside it: a one-shot
39
+ * completion and an agent run must not disagree about which model
40
+ * `{ provider: "openai", model: "gpt-4o-mini" }` names, and the failure mode
41
+ * if they did would be a run that silently costs ten times as much.
42
+ */
43
+ export declare function piModelFor(reference: AiModelRef): Promise<PiModel<PiApi>>;
44
+ /**
45
+ * Refuses credentials a provider cannot use, before a request is built.
46
+ *
47
+ * The alternative is a 401 from somebody else's API with a message about a
48
+ * header the operator never wrote.
49
+ */
50
+ export declare function assertAuthMatches(provider: string, auth: AiAuth): void;
51
+ /**
52
+ * How the agent authenticates, in pi's own vocabulary.
53
+ *
54
+ * API keys and OAuth are a function that produces a bearer token; Bedrock is
55
+ * not, because AWS signs the request rather than carrying a token, so it has
56
+ * to replace the stream function instead. Keeping all three here — rather
57
+ * than in the agent — is what makes `ai.auth` mean the same thing for a field
58
+ * action and for the assistant.
59
+ */
60
+ export declare function piAgentAuthOptions(provider: string, auth: AiAuth): Promise<PiAgentAuthOptions>;
61
+ export declare function authTypesForAiProvider(provider: string): readonly AiAuth["type"][];
62
+ /**
63
+ * Checks a provider and model against the catalogue pi actually ships.
64
+ *
65
+ * Done before a request leaves, so a typo in a model name is an error that
66
+ * names the provider rather than a 404 from somebody's API an hour later.
67
+ */
68
+ export declare function assertModelExists(provider: string, model: string): Promise<void>;
69
+ /** Models pi knows for a provider; empty when the provider is unknown. */
70
+ export declare function modelsForProvider(provider: string): Promise<string[]>;
71
+ /**
72
+ * The default completion: one prompt in, one answer out.
73
+ *
74
+ * Non-streaming on purpose. A field action produces a value that a person
75
+ * approves before it is stored, so the only thing streaming would buy is a
76
+ * progress animation — at the price of a second transport contract through
77
+ * the handler, the adapters and the panel.
78
+ */
79
+ export declare const piCompletion: AiCompletionFn;
80
+ export declare function toUsage(usage: {
81
+ input: number;
82
+ output: number;
83
+ totalTokens: number;
84
+ cost: {
85
+ total: number;
86
+ };
87
+ }): AiUsage;
88
+ export {};
89
+ //# sourceMappingURL=pi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pi.d.ts","sourceRoot":"","sources":["../../src/ai/pi.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EAGd,OAAO,EACR,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,KAAK,KAAK,GAAG,OAAO,qBAAqB,EAAE,GAAG,CAAC;AAC/C,KAAK,OAAO,CAAC,CAAC,SAAS,KAAK,IAAI,OAAO,qBAAqB,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;AAEvE;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IACjC,SAAS,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5D,QAAQ,CAAC,EAAE,CACT,GAAG,IAAI,EAAE,UAAU,CAAC,cAAc,qBAAqB,EAAE,YAAY,CAAC,KACnE,UAAU,CAAC,cAAc,qBAAqB,EAAE,YAAY,CAAC,CAAC;CACpE;AAED;;;;;;;;;;;;;;GAcG;AAEH,KAAK,QAAQ,GAAG,cAAc,qBAAqB,CAAC,CAAC;AAIrD,wBAAsB,EAAE,IAAI,OAAO,CAAC,QAAQ,CAAC,CAQ5C;AAED;;;;;;;;GAQG;AACH,wBAAsB,UAAU,CAC9B,SAAS,EAAE,UAAU,GACpB,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAiBzB;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAOtE;AAED;;;;;;;;GAQG;AACH,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,kBAAkB,CAAC,CA2B7B;AAKD,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,MAAM,GACf,SAAS,MAAM,CAAC,MAAM,CAAC,EAAE,CAI3B;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CAgBf;AAED,0EAA0E;AAC1E,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAS3E;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,EAAE,cAiE1B,CAAC;AAEF,wBAAgB,OAAO,CAAC,KAAK,EAAE;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CACzB,GAAG,OAAO,CAOV"}
@@ -0,0 +1,66 @@
1
+ import type { AiActionContext, AiActionDefinition } from "../types/ai";
2
+ export declare function defineAiAction(definition: AiActionDefinition): AiActionDefinition;
3
+ export declare function getAiAction(id: string): AiActionDefinition | undefined;
4
+ /** Action ids a field of this type may expose, in a stable menu order. */
5
+ export declare function aiActionsFor(fieldType: string): string[];
6
+ export declare function registeredAiActions(): string[];
7
+ /**
8
+ * An action that exists only on one field.
9
+ *
10
+ * `field.ai` accepts a key nobody registered as long as it brings its own
11
+ * prompt — that is what makes `ai: { "tone-of-voice": { prompt: "…" } }`
12
+ * work without a `defineAiAction()` call. The behaviour is `generate`'s,
13
+ * because "write this field, here is the instruction" is the only thing a
14
+ * prompt alone can mean.
15
+ */
16
+ export declare function customAiAction(id: string, prompt: string): AiActionDefinition;
17
+ /**
18
+ * Write the field from scratch.
19
+ *
20
+ * The context fields are the whole of what the model sees. That is the point
21
+ * of `context` being per action: a title generated from the body should not
22
+ * also be shown the internal notes, and the only way to be sure is to name
23
+ * what travels.
24
+ */
25
+ export declare const generateAction: AiActionDefinition;
26
+ export declare const improveAction: AiActionDefinition;
27
+ export declare const summarizeAction: AiActionDefinition;
28
+ /**
29
+ * Translate from another locale.
30
+ *
31
+ * Only on a localized field, and that is checked rather than assumed: a
32
+ * translation written into a field that stores one value for every language
33
+ * would overwrite the original, which is the kind of data loss an editor
34
+ * discovers a week later.
35
+ */
36
+ export declare const translateAction: AiActionDefinition;
37
+ /**
38
+ * Alternative text for an image.
39
+ *
40
+ * The bytes are sent when the deployment can load them and the model can
41
+ * read them; when it cannot, the action still answers from the filename and
42
+ * the document, because a wrong-but-editable suggestion beats a button that
43
+ * only works on some providers. The result is a suggestion either way: it
44
+ * lands in the form, and a person approves it.
45
+ */
46
+ export declare const altAction: AiActionDefinition;
47
+ /**
48
+ * Pick values from a fixed set.
49
+ *
50
+ * Constrained to the declared options and filtered against them afterwards:
51
+ * a model that invents a tag would otherwise fail validation on save, which
52
+ * is a confusing place to learn that the suggestion was never valid.
53
+ */
54
+ export declare const tagsAction: AiActionDefinition;
55
+ /**
56
+ * The system prompt.
57
+ *
58
+ * Built from the field rather than from a global instruction, because the
59
+ * model's job is "fill this field" and the most useful thing it can be told
60
+ * is what the field is.
61
+ */
62
+ export declare function systemPrompt(context: AiActionContext): string;
63
+ /** The named context fields, rendered for a prompt. Nothing else travels. */
64
+ export declare function contextBlock(context: AiActionContext): string;
65
+ export declare function renderValue(value: unknown): string;
66
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/ai/registry.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAEnB,MAAM,aAAa,CAAC;AAerB,wBAAgB,cAAc,CAC5B,UAAU,EAAE,kBAAkB,GAC7B,kBAAkB,CAgBpB;AAED,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS,CAEtE;AAED,0EAA0E;AAC1E,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAQxD;AAED,wBAAgB,mBAAmB,IAAI,MAAM,EAAE,CAE9C;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,kBAAkB,CAQ7E;AAQD;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,EAAE,kBAQ3B,CAAC;AAEH,eAAO,MAAM,aAAa,EAAE,kBAkB1B,CAAC;AAEH,eAAO,MAAM,eAAe,EAAE,kBAQ5B,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,EAAE,kBAuB5B,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,EAAE,kBAqCtB,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,EAAE,kBAwCvB,CAAC;AA4CH;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,CAe7D;AAED,6EAA6E;AAC7E,wBAAgB,YAAY,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,CAQ7D;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAalD"}
@@ -0,0 +1,31 @@
1
+ import type { CmsAi } from "../types/ai";
2
+ import type { ResolvedCmsConfig } from "../types/config";
3
+ import type { DatabaseAdapter } from "../types/database";
4
+ import type { CmsInstance } from "../types/instance";
5
+ import type { Tx } from "../types/query";
6
+ import type { BufferedEvent, OutboxEntryMeta } from "../engine/outbox";
7
+ export declare const aiCredentialsTable = "cms_ai_credentials";
8
+ export interface AiServiceOptions {
9
+ config: ResolvedCmsConfig;
10
+ database(): Promise<DatabaseAdapter>;
11
+ /** The bound instance, for reading documents and files under access control. */
12
+ cms(): CmsInstance;
13
+ emit(tx: Tx, events: BufferedEvent[], meta: OutboxEntryMeta): Promise<void>;
14
+ deliver(): void;
15
+ }
16
+ /**
17
+ * `cms.ai`.
18
+ *
19
+ * Present whether or not the configuration has an `ai` section, exactly like
20
+ * `cms.media` is present without `uploads`: the alternative is an optional
21
+ * property every caller has to narrow, and a 500 that says "cannot read
22
+ * property run of undefined" instead of a sentence naming the missing
23
+ * section.
24
+ *
25
+ * Everything the runtime does is one of two things — run one action on one
26
+ * field, or hold one conversation about one document — and both of them end
27
+ * by handing a value back to a human. Nothing in this file writes a document
28
+ * (section 8).
29
+ */
30
+ export declare function createAi(options: AiServiceOptions): CmsAi;
31
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/ai/service.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAYV,KAAK,EACN,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAEV,iBAAiB,EAElB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAMvE,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AAEvD,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,iBAAiB,CAAC;IAC1B,QAAQ,IAAI,OAAO,CAAC,eAAe,CAAC,CAAC;IACrC,gFAAgF;IAChF,GAAG,IAAI,WAAW,CAAC;IACnB,IAAI,CAAC,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5E,OAAO,IAAI,IAAI,CAAC;CACjB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,gBAAgB,GAAG,KAAK,CA6dzD"}
@@ -0,0 +1,6 @@
1
+ import type { AiActionContext, AiActionOutcome } from "../types/ai";
2
+ /** Translate prose in place, leaving the rich-text tree (including media IDs,
3
+ * links, marks and plugin nodes) intact. Markdown round-tripping the entire
4
+ * document would silently turn an image with a mediaId into a plain URL. */
5
+ export declare function translateVariantRichText(context: AiActionContext): Promise<AiActionOutcome>;
6
+ //# sourceMappingURL=variant-translation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variant-translation.d.ts","sourceRoot":"","sources":["../../src/ai/variant-translation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAW,MAAM,aAAa,CAAC;AAG7E;;4EAE4E;AAC5E,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,eAAe,CAAC,CA8D1B"}
package/dist/ai.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * `@heyo-sh/heyo-cms/ai`.
3
+ *
4
+ * `defineAiAction()` and the pieces an action needs. The configuration never
5
+ * mentions pi; this entry point is where a deployment reaches past it — to
6
+ * register an action, to check a model against the catalogue, or to replace
7
+ * the completion function altogether.
8
+ */
9
+ export { aiActionsFor, altAction, assertModelExists, authTypesForAiProvider, customAiAction, defineAiAction, describeCmsFor, generateAction, getAiAction, improveAction, modelsForProvider, piCompletion, registeredAiActions, summarizeAction, tagsAction, translateAction, } from "./ai/index";
10
+ export type { AssistantSchema } from "./ai/index";
11
+ export type { AiActionContext, AiActionDefinition, AiActionOutcome, AiApprovePlanArgs, AiApprovePlanResult, AiAssistantArgs, AiAssistantEvent, AiAssistantTurn, AiCompletionFn, AiCompletionRequest, AiCompletionResult, AiImageInput, AiMutationTarget, AiPageContext, AiPageContextKind, AiPlanOperationSummary, AiPlanSummary, AiProviderStatus, AiRunArgs, AiRunResult, AiUsage, CmsAi, } from "./types/ai";
12
+ //# sourceMappingURL=ai.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../src/ai.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACL,YAAY,EACZ,SAAS,EACT,iBAAiB,EACjB,sBAAsB,EACtB,cAAc,EACd,cAAc,EACd,cAAc,EACd,cAAc,EACd,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,UAAU,EACV,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,YAAY,EACV,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,sBAAsB,EACtB,aAAa,EACb,gBAAgB,EAChB,SAAS,EACT,WAAW,EACX,OAAO,EACP,KAAK,GACN,MAAM,YAAY,CAAC"}
package/dist/ai.js ADDED
@@ -0,0 +1 @@
1
+ import"./index-g041kfa5.js";import{pe,Y,Le,me,Ct,Ao,ko,Ro,ro,io,so}from"./index-8x2em6c8.js";import"./index-sgdnp83t.js";import"./index-6m1kjq9g.js";import{Rn,Sn,Qn,Ke,xt}from"./index-6w10rch0.js";export{Le as aiActionsFor,io as altAction,Sn as assertModelExists,Rn as authTypesForAiProvider,Ct as customAiAction,pe as defineAiAction,xt as describeCmsFor,Ao as generateAction,Y as getAiAction,ko as improveAction,Qn as modelsForProvider,Ke as piCompletion,me as registeredAiActions,Ro as summarizeAction,so as tagsAction,ro as translateAction};
@@ -0,0 +1,65 @@
1
+ import type { ApiKeyConfig, AuthMethod, Duration, EditorAuthConfig, FirstUserConfig, OAuthCredentials, OidcConfig, PasswordPolicy, TokenDelivery } from "../types/config";
2
+ export interface CmsUsersOptions {
3
+ methods: AuthMethod[];
4
+ sso?: OidcConfig;
5
+ twoFactor?: boolean;
6
+ apiKeys?: ApiKeyConfig;
7
+ session?: {
8
+ expiresIn?: Duration;
9
+ };
10
+ invites?: {
11
+ expiresIn?: Duration;
12
+ };
13
+ magicLink?: {
14
+ expiresIn?: Duration;
15
+ };
16
+ passwordReset?: {
17
+ expiresIn?: Duration;
18
+ };
19
+ providers?: Record<string, OAuthCredentials>;
20
+ password?: PasswordPolicy;
21
+ /**
22
+ * Whether the first account can be claimed from the sign-in screen.
23
+ *
24
+ * On by default, and only while there are no accounts at all: an empty
25
+ * `cms_users` is the only state in which the route answers, and the account
26
+ * that answers it is the one that closes it. `false` leaves
27
+ * `heyo-cms create-admin` as the only way in.
28
+ */
29
+ firstUser?: FirstUserConfig;
30
+ /**
31
+ * Delivers a magic link or a reset link to its owner.
32
+ *
33
+ * The CMS still sends no email: it hands the message to this function and
34
+ * the application decides what a mailbox is. Without it the magic-link and
35
+ * password-reset HTTP routes are not registered, because over HTTP the
36
+ * caller is an anonymous browser and a response carrying the token would
37
+ * let a stranger sign in as an administrator.
38
+ */
39
+ deliverToken?: (message: TokenDelivery) => void | Promise<void>;
40
+ }
41
+ /**
42
+ * Editor authentication.
43
+ *
44
+ * The CMS authenticates editors and nothing else: there is no identity for the
45
+ * users of the application being built, by design (section 0). API keys are
46
+ * configured here rather than as a separate feature, because a key is an
47
+ * authentication method that produces the same `Actor` a session does.
48
+ */
49
+ export declare function cmsUsers(options: CmsUsersOptions): EditorAuthConfig;
50
+ export interface OidcOptions {
51
+ issuer: string;
52
+ clientId?: string;
53
+ clientSecret?: string;
54
+ mapRoles?: (claims: Record<string, unknown>) => string[];
55
+ scope?: string;
56
+ provision?: boolean;
57
+ }
58
+ /**
59
+ * Single sign-on for organisations.
60
+ *
61
+ * `mapRoles` is the whole point: a company that already decides access in its
62
+ * identity provider should not have to decide it again in the CMS.
63
+ */
64
+ export declare function oidc(options: OidcOptions): OidcConfig;
65
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/auth/config.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,cAAc,EACd,aAAa,EACd,MAAM,iBAAiB,CAAC;AAEzB,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,GAAG,CAAC,EAAE,UAAU,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,QAAQ,CAAA;KAAE,CAAC;IACnC,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,QAAQ,CAAA;KAAE,CAAC;IACnC,SAAS,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,QAAQ,CAAA;KAAE,CAAC;IACrC,aAAa,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,QAAQ,CAAA;KAAE,CAAC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC7C,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B;;;;;;;;OAQG;IACH,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACjE;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,gBAAgB,CA+DnE;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,EAAE,CAAC;IACzD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,UAAU,CAQrD"}