@agilesyndrome/cf-genai-base 5.0.1 → 6.0.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 (696) hide show
  1. package/CHANGELOG.md +99 -0
  2. package/CLI.md +9 -13
  3. package/CONTRACT.md +32 -15
  4. package/README.md +95 -28
  5. package/bin/cf-genai.js +24 -8
  6. package/dist/admin/auth.d.ts +12 -0
  7. package/dist/admin/auth.d.ts.map +1 -0
  8. package/dist/admin/auth.js +103 -0
  9. package/dist/admin/auth.js.map +1 -0
  10. package/dist/admin/index.d.ts +2 -0
  11. package/dist/admin/index.d.ts.map +1 -0
  12. package/dist/admin/index.js +2 -0
  13. package/dist/admin/index.js.map +1 -0
  14. package/dist/admin/router.d.ts +4 -0
  15. package/dist/admin/router.d.ts.map +1 -0
  16. package/dist/admin/router.js +24 -0
  17. package/dist/admin/router.js.map +1 -0
  18. package/dist/admin/types.d.ts +43 -0
  19. package/dist/admin/types.d.ts.map +1 -0
  20. package/dist/admin/types.js +2 -0
  21. package/dist/admin/types.js.map +1 -0
  22. package/dist/api/client.d.ts +34 -0
  23. package/dist/api/client.d.ts.map +1 -0
  24. package/dist/api/client.js +59 -0
  25. package/dist/api/client.js.map +1 -0
  26. package/dist/api/contracts.d.ts +31 -0
  27. package/dist/api/contracts.d.ts.map +1 -0
  28. package/dist/api/contracts.js +101 -0
  29. package/dist/api/contracts.js.map +1 -0
  30. package/dist/api/http.d.ts +12 -0
  31. package/dist/api/http.d.ts.map +1 -0
  32. package/dist/api/http.js +36 -0
  33. package/dist/api/http.js.map +1 -0
  34. package/dist/api/index.d.ts +14 -0
  35. package/dist/api/index.d.ts.map +1 -0
  36. package/dist/api/index.js +11 -0
  37. package/dist/api/index.js.map +1 -0
  38. package/dist/api/testing.d.ts +10 -0
  39. package/dist/api/testing.d.ts.map +1 -0
  40. package/dist/api/testing.js +26 -0
  41. package/dist/api/testing.js.map +1 -0
  42. package/dist/app.d.ts +21 -0
  43. package/dist/app.d.ts.map +1 -0
  44. package/dist/app.js +23 -0
  45. package/dist/app.js.map +1 -0
  46. package/dist/auth/constants.d.ts +9 -0
  47. package/dist/auth/constants.d.ts.map +1 -0
  48. package/{src → dist}/auth/constants.js +2 -2
  49. package/dist/auth/constants.js.map +1 -0
  50. package/dist/auth/domains.d.ts +3 -0
  51. package/dist/auth/domains.d.ts.map +1 -0
  52. package/dist/auth/domains.js +8 -0
  53. package/dist/auth/domains.js.map +1 -0
  54. package/dist/auth/encoding.d.ts +7 -0
  55. package/dist/auth/encoding.d.ts.map +1 -0
  56. package/dist/auth/encoding.js +41 -0
  57. package/dist/auth/encoding.js.map +1 -0
  58. package/dist/auth/groups/d1.d.ts +16 -0
  59. package/dist/auth/groups/d1.d.ts.map +1 -0
  60. package/dist/auth/groups/d1.js +66 -0
  61. package/dist/auth/groups/d1.js.map +1 -0
  62. package/dist/auth/groups/domain.d.ts +8 -0
  63. package/dist/auth/groups/domain.d.ts.map +1 -0
  64. package/dist/auth/groups/domain.js +99 -0
  65. package/dist/auth/groups/domain.js.map +1 -0
  66. package/dist/auth/groups/index.d.ts +7 -0
  67. package/dist/auth/groups/index.d.ts.map +1 -0
  68. package/dist/auth/groups/index.js +7 -0
  69. package/dist/auth/groups/index.js.map +1 -0
  70. package/dist/auth/groups/model.d.ts +38 -0
  71. package/dist/auth/groups/model.d.ts.map +1 -0
  72. package/dist/auth/groups/model.js +2 -0
  73. package/dist/auth/groups/model.js.map +1 -0
  74. package/dist/auth/groups/policy.d.ts +5 -0
  75. package/dist/auth/groups/policy.d.ts.map +1 -0
  76. package/dist/auth/groups/policy.js +8 -0
  77. package/dist/auth/groups/policy.js.map +1 -0
  78. package/dist/auth/groups/service.d.ts +20 -0
  79. package/dist/auth/groups/service.d.ts.map +1 -0
  80. package/dist/auth/groups/service.js +40 -0
  81. package/dist/auth/groups/service.js.map +1 -0
  82. package/dist/auth/groups/validation.d.ts +5 -0
  83. package/dist/auth/groups/validation.d.ts.map +1 -0
  84. package/dist/auth/groups/validation.js +22 -0
  85. package/dist/auth/groups/validation.js.map +1 -0
  86. package/dist/auth/groups/views/list.d.ts +10 -0
  87. package/dist/auth/groups/views/list.d.ts.map +1 -0
  88. package/dist/auth/groups/views/list.js +4 -0
  89. package/dist/auth/groups/views/list.js.map +1 -0
  90. package/dist/auth/identity/index.d.ts +58 -0
  91. package/dist/auth/identity/index.d.ts.map +1 -0
  92. package/dist/auth/identity/index.js +58 -0
  93. package/dist/auth/identity/index.js.map +1 -0
  94. package/dist/auth/impersonation/constants.d.ts +2 -0
  95. package/dist/auth/impersonation/constants.d.ts.map +1 -0
  96. package/dist/auth/impersonation/constants.js +2 -0
  97. package/dist/auth/impersonation/constants.js.map +1 -0
  98. package/dist/auth/impersonation/domain.d.ts +6 -0
  99. package/dist/auth/impersonation/domain.d.ts.map +1 -0
  100. package/dist/auth/impersonation/domain.js +16 -0
  101. package/dist/auth/impersonation/domain.js.map +1 -0
  102. package/dist/auth/impersonation/index.d.ts +6 -0
  103. package/dist/auth/impersonation/index.d.ts.map +1 -0
  104. package/dist/auth/impersonation/index.js +6 -0
  105. package/dist/auth/impersonation/index.js.map +1 -0
  106. package/dist/auth/impersonation/model.d.ts +12 -0
  107. package/dist/auth/impersonation/model.d.ts.map +1 -0
  108. package/dist/auth/impersonation/model.js +2 -0
  109. package/dist/auth/impersonation/model.js.map +1 -0
  110. package/dist/auth/impersonation/service.d.ts +4 -0
  111. package/dist/auth/impersonation/service.d.ts.map +1 -0
  112. package/dist/auth/impersonation/service.js +32 -0
  113. package/dist/auth/impersonation/service.js.map +1 -0
  114. package/dist/auth/impersonation/validation.d.ts +4 -0
  115. package/dist/auth/impersonation/validation.d.ts.map +1 -0
  116. package/dist/auth/impersonation/validation.js +14 -0
  117. package/dist/auth/impersonation/validation.js.map +1 -0
  118. package/dist/auth/index.d.ts +13 -0
  119. package/dist/auth/index.d.ts.map +1 -0
  120. package/dist/auth/index.js +13 -0
  121. package/dist/auth/index.js.map +1 -0
  122. package/dist/auth/oauth-single/constants.d.ts +4 -0
  123. package/dist/auth/oauth-single/constants.d.ts.map +1 -0
  124. package/dist/auth/oauth-single/constants.js +5 -0
  125. package/dist/auth/oauth-single/constants.js.map +1 -0
  126. package/dist/auth/oauth-single/cookies.d.ts +10 -0
  127. package/dist/auth/oauth-single/cookies.d.ts.map +1 -0
  128. package/dist/auth/oauth-single/cookies.js +59 -0
  129. package/dist/auth/oauth-single/cookies.js.map +1 -0
  130. package/dist/auth/oauth-single/domain.d.ts +14 -0
  131. package/dist/auth/oauth-single/domain.d.ts.map +1 -0
  132. package/dist/auth/oauth-single/domain.js +12 -0
  133. package/dist/auth/oauth-single/domain.js.map +1 -0
  134. package/dist/auth/oauth-single/index.d.ts +31 -0
  135. package/dist/auth/oauth-single/index.d.ts.map +1 -0
  136. package/dist/auth/oauth-single/index.js +215 -0
  137. package/dist/auth/oauth-single/index.js.map +1 -0
  138. package/dist/auth/oauth-single/model.d.ts +75 -0
  139. package/dist/auth/oauth-single/model.d.ts.map +1 -0
  140. package/dist/auth/oauth-single/model.js +2 -0
  141. package/dist/auth/oauth-single/model.js.map +1 -0
  142. package/dist/auth/oauth-single/protocol.d.ts +9 -0
  143. package/dist/auth/oauth-single/protocol.d.ts.map +1 -0
  144. package/dist/auth/oauth-single/protocol.js +190 -0
  145. package/dist/auth/oauth-single/protocol.js.map +1 -0
  146. package/dist/auth/oauth-single/session.d.ts +7 -0
  147. package/dist/auth/oauth-single/session.d.ts.map +1 -0
  148. package/dist/auth/oauth-single/session.js +78 -0
  149. package/dist/auth/oauth-single/session.js.map +1 -0
  150. package/dist/auth/repositories.d.ts +58 -0
  151. package/dist/auth/repositories.d.ts.map +1 -0
  152. package/dist/auth/repositories.js +31 -0
  153. package/dist/auth/repositories.js.map +1 -0
  154. package/dist/auth/scopes/d1.d.ts +17 -0
  155. package/dist/auth/scopes/d1.d.ts.map +1 -0
  156. package/dist/auth/scopes/d1.js +54 -0
  157. package/dist/auth/scopes/d1.js.map +1 -0
  158. package/dist/auth/scopes/domain.d.ts +7 -0
  159. package/dist/auth/scopes/domain.d.ts.map +1 -0
  160. package/dist/auth/scopes/domain.js +25 -0
  161. package/dist/auth/scopes/domain.js.map +1 -0
  162. package/dist/auth/scopes/index.d.ts +4 -0
  163. package/dist/auth/scopes/index.d.ts.map +1 -0
  164. package/dist/auth/scopes/index.js +4 -0
  165. package/dist/auth/scopes/index.js.map +1 -0
  166. package/dist/auth/scopes/model.d.ts +26 -0
  167. package/dist/auth/scopes/model.d.ts.map +1 -0
  168. package/dist/auth/scopes/model.js +2 -0
  169. package/dist/auth/scopes/model.js.map +1 -0
  170. package/dist/auth/scopes/policy.d.ts +3 -0
  171. package/dist/auth/scopes/policy.d.ts.map +1 -0
  172. package/dist/auth/scopes/policy.js +4 -0
  173. package/dist/auth/scopes/policy.js.map +1 -0
  174. package/dist/auth/scopes/service.d.ts +4 -0
  175. package/dist/auth/scopes/service.d.ts.map +1 -0
  176. package/dist/auth/scopes/service.js +4 -0
  177. package/dist/auth/scopes/service.js.map +1 -0
  178. package/dist/auth/scopes/validation.d.ts +6 -0
  179. package/dist/auth/scopes/validation.d.ts.map +1 -0
  180. package/dist/auth/scopes/validation.js +33 -0
  181. package/dist/auth/scopes/validation.js.map +1 -0
  182. package/dist/auth/scopes/views/list.d.ts +9 -0
  183. package/dist/auth/scopes/views/list.d.ts.map +1 -0
  184. package/dist/auth/scopes/views/list.js +4 -0
  185. package/dist/auth/scopes/views/list.js.map +1 -0
  186. package/dist/auth/subscriptions/d1.d.ts +10 -0
  187. package/dist/auth/subscriptions/d1.d.ts.map +1 -0
  188. package/dist/auth/subscriptions/d1.js +86 -0
  189. package/dist/auth/subscriptions/d1.js.map +1 -0
  190. package/dist/auth/subscriptions/domain.d.ts +10 -0
  191. package/dist/auth/subscriptions/domain.d.ts.map +1 -0
  192. package/dist/auth/subscriptions/domain.js +33 -0
  193. package/dist/auth/subscriptions/domain.js.map +1 -0
  194. package/dist/auth/subscriptions/index.d.ts +6 -0
  195. package/dist/auth/subscriptions/index.d.ts.map +1 -0
  196. package/dist/auth/subscriptions/index.js +6 -0
  197. package/dist/auth/subscriptions/index.js.map +1 -0
  198. package/dist/auth/subscriptions/model.d.ts +20 -0
  199. package/dist/auth/subscriptions/model.d.ts.map +1 -0
  200. package/dist/auth/subscriptions/model.js +2 -0
  201. package/dist/auth/subscriptions/model.js.map +1 -0
  202. package/dist/auth/subscriptions/service.d.ts +12 -0
  203. package/dist/auth/subscriptions/service.d.ts.map +1 -0
  204. package/dist/auth/subscriptions/service.js +71 -0
  205. package/dist/auth/subscriptions/service.js.map +1 -0
  206. package/dist/auth/subscriptions/validation.d.ts +3 -0
  207. package/dist/auth/subscriptions/validation.d.ts.map +1 -0
  208. package/dist/auth/subscriptions/validation.js +21 -0
  209. package/dist/auth/subscriptions/validation.js.map +1 -0
  210. package/dist/auth/tenants/d1.d.ts +12 -0
  211. package/dist/auth/tenants/d1.d.ts.map +1 -0
  212. package/dist/auth/tenants/d1.js +40 -0
  213. package/dist/auth/tenants/d1.js.map +1 -0
  214. package/dist/auth/tenants/delete.d.ts +3 -0
  215. package/dist/auth/tenants/delete.d.ts.map +1 -0
  216. package/dist/auth/tenants/delete.js +28 -0
  217. package/dist/auth/tenants/delete.js.map +1 -0
  218. package/dist/auth/tenants/domain.d.ts +8 -0
  219. package/dist/auth/tenants/domain.d.ts.map +1 -0
  220. package/dist/auth/tenants/domain.js +64 -0
  221. package/dist/auth/tenants/domain.js.map +1 -0
  222. package/dist/auth/tenants/index.d.ts +7 -0
  223. package/dist/auth/tenants/index.d.ts.map +1 -0
  224. package/dist/auth/tenants/index.js +7 -0
  225. package/dist/auth/tenants/index.js.map +1 -0
  226. package/dist/auth/tenants/model.d.ts +28 -0
  227. package/dist/auth/tenants/model.d.ts.map +1 -0
  228. package/dist/auth/tenants/model.js +2 -0
  229. package/dist/auth/tenants/model.js.map +1 -0
  230. package/dist/auth/tenants/policy.d.ts +3 -0
  231. package/dist/auth/tenants/policy.d.ts.map +1 -0
  232. package/dist/auth/tenants/policy.js +4 -0
  233. package/dist/auth/tenants/policy.js.map +1 -0
  234. package/dist/auth/tenants/service.d.ts +14 -0
  235. package/dist/auth/tenants/service.d.ts.map +1 -0
  236. package/dist/auth/tenants/service.js +37 -0
  237. package/dist/auth/tenants/service.js.map +1 -0
  238. package/dist/auth/tenants/validation.d.ts +5 -0
  239. package/dist/auth/tenants/validation.d.ts.map +1 -0
  240. package/dist/auth/tenants/validation.js +21 -0
  241. package/dist/auth/tenants/validation.js.map +1 -0
  242. package/dist/auth/tenants/views/list.d.ts +8 -0
  243. package/dist/auth/tenants/views/list.d.ts.map +1 -0
  244. package/dist/auth/tenants/views/list.js +3 -0
  245. package/dist/auth/tenants/views/list.js.map +1 -0
  246. package/dist/auth/users/access.d.ts +9 -0
  247. package/dist/auth/users/access.d.ts.map +1 -0
  248. package/dist/auth/users/access.js +53 -0
  249. package/dist/auth/users/access.js.map +1 -0
  250. package/dist/auth/users/d1.d.ts +19 -0
  251. package/dist/auth/users/d1.d.ts.map +1 -0
  252. package/dist/auth/users/d1.js +68 -0
  253. package/dist/auth/users/d1.js.map +1 -0
  254. package/dist/auth/users/domain.d.ts +13 -0
  255. package/dist/auth/users/domain.d.ts.map +1 -0
  256. package/dist/auth/users/domain.js +129 -0
  257. package/dist/auth/users/domain.js.map +1 -0
  258. package/dist/auth/users/index.d.ts +7 -0
  259. package/dist/auth/users/index.d.ts.map +1 -0
  260. package/dist/auth/users/index.js +7 -0
  261. package/dist/auth/users/index.js.map +1 -0
  262. package/dist/auth/users/model.d.ts +44 -0
  263. package/dist/auth/users/model.d.ts.map +1 -0
  264. package/dist/auth/users/model.js +2 -0
  265. package/dist/auth/users/model.js.map +1 -0
  266. package/dist/auth/users/service.d.ts +8 -0
  267. package/dist/auth/users/service.d.ts.map +1 -0
  268. package/dist/auth/users/service.js +62 -0
  269. package/dist/auth/users/service.js.map +1 -0
  270. package/dist/auth/users/validation.d.ts +4 -0
  271. package/dist/auth/users/validation.d.ts.map +1 -0
  272. package/dist/auth/users/validation.js +23 -0
  273. package/dist/auth/users/validation.js.map +1 -0
  274. package/dist/cli/cli.d.ts +9 -0
  275. package/dist/cli/cli.d.ts.map +1 -0
  276. package/dist/cli/cli.js +201 -0
  277. package/dist/cli/cli.js.map +1 -0
  278. package/dist/cli/d1.d.ts +24 -0
  279. package/dist/cli/d1.d.ts.map +1 -0
  280. package/dist/cli/d1.js +175 -0
  281. package/dist/cli/d1.js.map +1 -0
  282. package/dist/cli/operations.d.ts +3 -0
  283. package/dist/cli/operations.d.ts.map +1 -0
  284. package/dist/cli/operations.js +63 -0
  285. package/dist/cli/operations.js.map +1 -0
  286. package/dist/cli/project.d.ts +136 -0
  287. package/dist/cli/project.d.ts.map +1 -0
  288. package/dist/cli/project.js +738 -0
  289. package/dist/cli/project.js.map +1 -0
  290. package/dist/cli/status.d.ts +24 -0
  291. package/dist/cli/status.d.ts.map +1 -0
  292. package/dist/cli/status.js +55 -0
  293. package/dist/cli/status.js.map +1 -0
  294. package/dist/cli/tenants.d.ts +9 -0
  295. package/dist/cli/tenants.d.ts.map +1 -0
  296. package/dist/cli/tenants.js +32 -0
  297. package/dist/cli/tenants.js.map +1 -0
  298. package/dist/cli/types.d.ts +43 -0
  299. package/dist/cli/types.d.ts.map +1 -0
  300. package/dist/cli/types.js +2 -0
  301. package/dist/cli/types.js.map +1 -0
  302. package/dist/cli/users.d.ts +8 -0
  303. package/dist/cli/users.d.ts.map +1 -0
  304. package/dist/cli/users.js +74 -0
  305. package/dist/cli/users.js.map +1 -0
  306. package/dist/cli/version.d.ts +12 -0
  307. package/dist/cli/version.d.ts.map +1 -0
  308. package/dist/cli/version.js +60 -0
  309. package/dist/cli/version.js.map +1 -0
  310. package/dist/core/circuits/availability.d.ts +48 -0
  311. package/dist/core/circuits/availability.d.ts.map +1 -0
  312. package/dist/core/circuits/availability.js +87 -0
  313. package/dist/core/circuits/availability.js.map +1 -0
  314. package/dist/core/circuits/d1.d.ts +11 -0
  315. package/dist/core/circuits/d1.d.ts.map +1 -0
  316. package/dist/core/circuits/d1.js +83 -0
  317. package/dist/core/circuits/d1.js.map +1 -0
  318. package/dist/core/circuits/domain.d.ts +7 -0
  319. package/dist/core/circuits/domain.d.ts.map +1 -0
  320. package/dist/core/circuits/domain.js +36 -0
  321. package/dist/core/circuits/domain.js.map +1 -0
  322. package/dist/core/circuits/index.d.ts +6 -0
  323. package/dist/core/circuits/index.d.ts.map +1 -0
  324. package/dist/core/circuits/index.js +6 -0
  325. package/dist/core/circuits/index.js.map +1 -0
  326. package/dist/core/circuits/model.d.ts +50 -0
  327. package/dist/core/circuits/model.d.ts.map +1 -0
  328. package/dist/core/circuits/model.js +2 -0
  329. package/dist/core/circuits/model.js.map +1 -0
  330. package/dist/core/circuits/service.d.ts +9 -0
  331. package/dist/core/circuits/service.d.ts.map +1 -0
  332. package/dist/core/circuits/service.js +63 -0
  333. package/dist/core/circuits/service.js.map +1 -0
  334. package/dist/core/circuits/validation.d.ts +4 -0
  335. package/dist/core/circuits/validation.d.ts.map +1 -0
  336. package/dist/core/circuits/validation.js +35 -0
  337. package/dist/core/circuits/validation.js.map +1 -0
  338. package/dist/core/constants.d.ts +9 -0
  339. package/dist/core/constants.d.ts.map +1 -0
  340. package/{src → dist}/core/constants.js +2 -1
  341. package/dist/core/constants.js.map +1 -0
  342. package/dist/core/database/index.d.ts +14 -0
  343. package/dist/core/database/index.d.ts.map +1 -0
  344. package/dist/core/database/index.js +65 -0
  345. package/dist/core/database/index.js.map +1 -0
  346. package/dist/core/domains.d.ts +2 -0
  347. package/dist/core/domains.d.ts.map +1 -0
  348. package/dist/core/domains.js +7 -0
  349. package/dist/core/domains.js.map +1 -0
  350. package/dist/core/events/audit.d.ts +8 -0
  351. package/dist/core/events/audit.d.ts.map +1 -0
  352. package/dist/core/events/audit.js +27 -0
  353. package/dist/core/events/audit.js.map +1 -0
  354. package/dist/core/events/domain.d.ts +19 -0
  355. package/dist/core/events/domain.d.ts.map +1 -0
  356. package/dist/core/events/domain.js +39 -0
  357. package/dist/core/events/domain.js.map +1 -0
  358. package/dist/core/events/hub.d.ts +10 -0
  359. package/dist/core/events/hub.d.ts.map +1 -0
  360. package/dist/core/events/hub.js +56 -0
  361. package/dist/core/events/hub.js.map +1 -0
  362. package/dist/core/events/index.d.ts +57 -0
  363. package/dist/core/events/index.d.ts.map +1 -0
  364. package/dist/core/events/index.js +170 -0
  365. package/dist/core/events/index.js.map +1 -0
  366. package/dist/core/healthchecks/d1.d.ts +7 -0
  367. package/dist/core/healthchecks/d1.d.ts.map +1 -0
  368. package/dist/core/healthchecks/d1.js +43 -0
  369. package/dist/core/healthchecks/d1.js.map +1 -0
  370. package/dist/core/healthchecks/domain.d.ts +7 -0
  371. package/dist/core/healthchecks/domain.d.ts.map +1 -0
  372. package/dist/core/healthchecks/domain.js +51 -0
  373. package/dist/core/healthchecks/domain.js.map +1 -0
  374. package/dist/core/healthchecks/features.d.ts +19 -0
  375. package/dist/core/healthchecks/features.d.ts.map +1 -0
  376. package/dist/core/healthchecks/features.js +100 -0
  377. package/dist/core/healthchecks/features.js.map +1 -0
  378. package/dist/core/healthchecks/index.d.ts +6 -0
  379. package/dist/core/healthchecks/index.d.ts.map +1 -0
  380. package/dist/core/healthchecks/index.js +6 -0
  381. package/dist/core/healthchecks/index.js.map +1 -0
  382. package/dist/core/healthchecks/model.d.ts +64 -0
  383. package/dist/core/healthchecks/model.d.ts.map +1 -0
  384. package/dist/core/healthchecks/model.js +2 -0
  385. package/dist/core/healthchecks/model.js.map +1 -0
  386. package/dist/core/healthchecks/service.d.ts +8 -0
  387. package/dist/core/healthchecks/service.d.ts.map +1 -0
  388. package/dist/core/healthchecks/service.js +29 -0
  389. package/dist/core/healthchecks/service.js.map +1 -0
  390. package/dist/core/healthchecks/validation.d.ts +5 -0
  391. package/dist/core/healthchecks/validation.d.ts.map +1 -0
  392. package/dist/core/healthchecks/validation.js +51 -0
  393. package/dist/core/healthchecks/validation.js.map +1 -0
  394. package/dist/core/index.d.ts +9 -0
  395. package/dist/core/index.d.ts.map +1 -0
  396. package/dist/core/index.js +9 -0
  397. package/dist/core/index.js.map +1 -0
  398. package/dist/core/jobs/d1.d.ts +19 -0
  399. package/dist/core/jobs/d1.d.ts.map +1 -0
  400. package/dist/core/jobs/d1.js +139 -0
  401. package/dist/core/jobs/d1.js.map +1 -0
  402. package/dist/core/jobs/domain.d.ts +8 -0
  403. package/dist/core/jobs/domain.d.ts.map +1 -0
  404. package/dist/core/jobs/domain.js +59 -0
  405. package/dist/core/jobs/domain.js.map +1 -0
  406. package/dist/core/jobs/events.d.ts +3 -0
  407. package/dist/core/jobs/events.d.ts.map +1 -0
  408. package/dist/core/jobs/events.js +25 -0
  409. package/dist/core/jobs/events.js.map +1 -0
  410. package/dist/core/jobs/index.d.ts +7 -0
  411. package/dist/core/jobs/index.d.ts.map +1 -0
  412. package/dist/core/jobs/index.js +7 -0
  413. package/dist/core/jobs/index.js.map +1 -0
  414. package/dist/core/jobs/model.d.ts +86 -0
  415. package/dist/core/jobs/model.d.ts.map +1 -0
  416. package/dist/core/jobs/model.js +2 -0
  417. package/dist/core/jobs/model.js.map +1 -0
  418. package/dist/core/jobs/service.d.ts +39 -0
  419. package/dist/core/jobs/service.d.ts.map +1 -0
  420. package/dist/core/jobs/service.js +84 -0
  421. package/dist/core/jobs/service.js.map +1 -0
  422. package/dist/core/jobs/validation.d.ts +8 -0
  423. package/dist/core/jobs/validation.d.ts.map +1 -0
  424. package/dist/core/jobs/validation.js +39 -0
  425. package/dist/core/jobs/validation.js.map +1 -0
  426. package/dist/core/security/index.d.ts +30 -0
  427. package/dist/core/security/index.d.ts.map +1 -0
  428. package/dist/core/security/index.js +138 -0
  429. package/dist/core/security/index.js.map +1 -0
  430. package/dist/data/context.d.ts +20 -0
  431. package/dist/data/context.d.ts.map +1 -0
  432. package/dist/data/context.js +65 -0
  433. package/dist/data/context.js.map +1 -0
  434. package/dist/data/index.d.ts +5 -0
  435. package/dist/data/index.d.ts.map +1 -0
  436. package/{src → dist}/data/index.js +2 -0
  437. package/dist/data/index.js.map +1 -0
  438. package/dist/data/json.d.ts +3 -0
  439. package/dist/data/json.d.ts.map +1 -0
  440. package/dist/data/json.js +14 -0
  441. package/dist/data/json.js.map +1 -0
  442. package/dist/data/model.d.ts +96 -0
  443. package/dist/data/model.d.ts.map +1 -0
  444. package/dist/data/model.js +3 -0
  445. package/dist/data/model.js.map +1 -0
  446. package/dist/data/policy.d.ts +14 -0
  447. package/dist/data/policy.d.ts.map +1 -0
  448. package/dist/data/policy.js +89 -0
  449. package/dist/data/policy.js.map +1 -0
  450. package/dist/data/reader.d.ts +9 -0
  451. package/dist/data/reader.d.ts.map +1 -0
  452. package/dist/data/reader.js +203 -0
  453. package/dist/data/reader.js.map +1 -0
  454. package/dist/data/resources.d.ts +9 -0
  455. package/dist/data/resources.d.ts.map +1 -0
  456. package/dist/data/resources.js +129 -0
  457. package/dist/data/resources.js.map +1 -0
  458. package/dist/domain/app-domain.d.ts +36 -0
  459. package/dist/domain/app-domain.d.ts.map +1 -0
  460. package/dist/domain/app-domain.js +79 -0
  461. package/dist/domain/app-domain.js.map +1 -0
  462. package/dist/domain/index.d.ts +3 -0
  463. package/dist/domain/index.d.ts.map +1 -0
  464. package/dist/domain/index.js +3 -0
  465. package/dist/domain/index.js.map +1 -0
  466. package/dist/domain/model.d.ts +37 -0
  467. package/dist/domain/model.d.ts.map +1 -0
  468. package/dist/domain/model.js +2 -0
  469. package/dist/domain/model.js.map +1 -0
  470. package/dist/features/index.d.ts +25 -0
  471. package/dist/features/index.d.ts.map +1 -0
  472. package/dist/features/index.js +61 -0
  473. package/dist/features/index.js.map +1 -0
  474. package/dist/features/llm/client.d.ts +3 -0
  475. package/dist/features/llm/client.d.ts.map +1 -0
  476. package/dist/features/llm/client.js +327 -0
  477. package/dist/features/llm/client.js.map +1 -0
  478. package/dist/features/llm/config.d.ts +7 -0
  479. package/dist/features/llm/config.d.ts.map +1 -0
  480. package/dist/features/llm/config.js +93 -0
  481. package/dist/features/llm/config.js.map +1 -0
  482. package/dist/features/llm/constants.d.ts +5 -0
  483. package/dist/features/llm/constants.d.ts.map +1 -0
  484. package/dist/features/llm/constants.js +6 -0
  485. package/dist/features/llm/constants.js.map +1 -0
  486. package/dist/features/llm/errors.d.ts +12 -0
  487. package/dist/features/llm/errors.d.ts.map +1 -0
  488. package/dist/features/llm/errors.js +19 -0
  489. package/dist/features/llm/errors.js.map +1 -0
  490. package/dist/features/llm/feature.d.ts +6 -0
  491. package/dist/features/llm/feature.d.ts.map +1 -0
  492. package/dist/features/llm/feature.js +37 -0
  493. package/dist/features/llm/feature.js.map +1 -0
  494. package/dist/features/llm/index.d.ts +9 -0
  495. package/dist/features/llm/index.d.ts.map +1 -0
  496. package/dist/features/llm/index.js +6 -0
  497. package/dist/features/llm/index.js.map +1 -0
  498. package/dist/features/llm/model.d.ts +171 -0
  499. package/dist/features/llm/model.d.ts.map +1 -0
  500. package/dist/features/llm/model.js +2 -0
  501. package/dist/features/llm/model.js.map +1 -0
  502. package/dist/features/llm/schema.d.ts +4 -0
  503. package/dist/features/llm/schema.d.ts.map +1 -0
  504. package/dist/features/llm/schema.js +82 -0
  505. package/dist/features/llm/schema.js.map +1 -0
  506. package/dist/features/llm/service.d.ts +29 -0
  507. package/dist/features/llm/service.d.ts.map +1 -0
  508. package/dist/features/llm/service.js +55 -0
  509. package/dist/features/llm/service.js.map +1 -0
  510. package/dist/features/messaging/constants.d.ts +3 -0
  511. package/dist/features/messaging/constants.d.ts.map +1 -0
  512. package/dist/features/messaging/constants.js +4 -0
  513. package/dist/features/messaging/constants.js.map +1 -0
  514. package/dist/features/messaging/domain.d.ts +9 -0
  515. package/dist/features/messaging/domain.d.ts.map +1 -0
  516. package/dist/features/messaging/domain.js +14 -0
  517. package/dist/features/messaging/domain.js.map +1 -0
  518. package/dist/features/messaging/feature.d.ts +7 -0
  519. package/dist/features/messaging/feature.d.ts.map +1 -0
  520. package/dist/features/messaging/feature.js +23 -0
  521. package/dist/features/messaging/feature.js.map +1 -0
  522. package/dist/features/messaging/index.d.ts +12 -0
  523. package/dist/features/messaging/index.d.ts.map +1 -0
  524. package/dist/features/messaging/index.js +8 -0
  525. package/dist/features/messaging/index.js.map +1 -0
  526. package/dist/features/messaging/jobs.d.ts +38 -0
  527. package/dist/features/messaging/jobs.d.ts.map +1 -0
  528. package/dist/features/messaging/jobs.js +40 -0
  529. package/dist/features/messaging/jobs.js.map +1 -0
  530. package/dist/features/messaging/models.d.ts +65 -0
  531. package/dist/features/messaging/models.d.ts.map +1 -0
  532. package/dist/features/messaging/models.js +97 -0
  533. package/dist/features/messaging/models.js.map +1 -0
  534. package/dist/features/messaging/resources.d.ts +8 -0
  535. package/dist/features/messaging/resources.d.ts.map +1 -0
  536. package/dist/features/messaging/resources.js +11 -0
  537. package/dist/features/messaging/resources.js.map +1 -0
  538. package/dist/features/messaging/store.d.ts +46 -0
  539. package/dist/features/messaging/store.d.ts.map +1 -0
  540. package/dist/features/messaging/store.js +208 -0
  541. package/dist/features/messaging/store.js.map +1 -0
  542. package/dist/index.d.ts +20 -0
  543. package/dist/index.d.ts.map +1 -0
  544. package/{src → dist}/index.js +7 -2
  545. package/dist/index.js.map +1 -0
  546. package/dist/input.d.ts +18 -0
  547. package/dist/input.d.ts.map +1 -0
  548. package/dist/input.js +49 -0
  549. package/dist/input.js.map +1 -0
  550. package/dist/repository/model.d.ts +61 -0
  551. package/dist/repository/model.d.ts.map +1 -0
  552. package/dist/repository/model.js +2 -0
  553. package/dist/repository/model.js.map +1 -0
  554. package/dist/repository.d.ts +11 -0
  555. package/dist/repository.d.ts.map +1 -0
  556. package/dist/repository.js +118 -0
  557. package/dist/repository.js.map +1 -0
  558. package/dist/runtime/domains.d.ts +14 -0
  559. package/dist/runtime/domains.d.ts.map +1 -0
  560. package/dist/runtime/domains.js +42 -0
  561. package/dist/runtime/domains.js.map +1 -0
  562. package/dist/runtime/features.d.ts +10 -0
  563. package/dist/runtime/features.d.ts.map +1 -0
  564. package/dist/runtime/features.js +37 -0
  565. package/dist/runtime/features.js.map +1 -0
  566. package/dist/runtime/health.d.ts +6 -0
  567. package/dist/runtime/health.d.ts.map +1 -0
  568. package/dist/runtime/health.js +28 -0
  569. package/dist/runtime/health.js.map +1 -0
  570. package/dist/runtime/hono.d.ts +30 -0
  571. package/dist/runtime/hono.d.ts.map +1 -0
  572. package/dist/runtime/hono.js +50 -0
  573. package/dist/runtime/hono.js.map +1 -0
  574. package/dist/runtime/model.d.ts +133 -0
  575. package/dist/runtime/model.d.ts.map +1 -0
  576. package/dist/runtime/model.js +2 -0
  577. package/dist/runtime/model.js.map +1 -0
  578. package/dist/runtime/responses.d.ts +9 -0
  579. package/dist/runtime/responses.d.ts.map +1 -0
  580. package/dist/runtime/responses.js +14 -0
  581. package/dist/runtime/responses.js.map +1 -0
  582. package/dist/runtime/worker.d.ts +10 -0
  583. package/dist/runtime/worker.d.ts.map +1 -0
  584. package/dist/runtime/worker.js +216 -0
  585. package/dist/runtime/worker.js.map +1 -0
  586. package/dist/ui/index.d.ts +3 -0
  587. package/dist/ui/index.d.ts.map +1 -0
  588. package/dist/ui/index.js +3 -0
  589. package/dist/ui/index.js.map +1 -0
  590. package/dist/ui/react/admin-access.d.ts +2 -0
  591. package/dist/ui/react/admin-access.d.ts.map +1 -0
  592. package/dist/ui/react/admin-access.js +47 -0
  593. package/dist/ui/react/admin-access.js.map +1 -0
  594. package/dist/ui/react/admin-audit.d.ts +2 -0
  595. package/dist/ui/react/admin-audit.d.ts.map +1 -0
  596. package/dist/ui/react/admin-audit.js +13 -0
  597. package/dist/ui/react/admin-audit.js.map +1 -0
  598. package/dist/ui/react/admin-catalogs.d.ts +6 -0
  599. package/dist/ui/react/admin-catalogs.d.ts.map +1 -0
  600. package/dist/ui/react/admin-catalogs.js +37 -0
  601. package/dist/ui/react/admin-catalogs.js.map +1 -0
  602. package/dist/ui/react/admin-dashboard.d.ts +39 -0
  603. package/dist/ui/react/admin-dashboard.d.ts.map +1 -0
  604. package/dist/ui/react/admin-dashboard.js +135 -0
  605. package/dist/ui/react/admin-dashboard.js.map +1 -0
  606. package/dist/ui/react/admin-details.d.ts +27 -0
  607. package/dist/ui/react/admin-details.d.ts.map +1 -0
  608. package/dist/ui/react/admin-details.js +82 -0
  609. package/dist/ui/react/admin-details.js.map +1 -0
  610. package/dist/ui/react/admin-shell.d.ts +20 -0
  611. package/dist/ui/react/admin-shell.d.ts.map +1 -0
  612. package/dist/ui/react/admin-shell.js +24 -0
  613. package/dist/ui/react/admin-shell.js.map +1 -0
  614. package/dist/ui/react/bootstrap.d.ts +9 -0
  615. package/dist/ui/react/bootstrap.d.ts.map +1 -0
  616. package/dist/ui/react/bootstrap.js +45 -0
  617. package/dist/ui/react/bootstrap.js.map +1 -0
  618. package/dist/ui/react/foundation.d.ts +35 -0
  619. package/dist/ui/react/foundation.d.ts.map +1 -0
  620. package/dist/ui/react/foundation.js +62 -0
  621. package/dist/ui/react/foundation.js.map +1 -0
  622. package/dist/ui/react/index.d.ts +12 -0
  623. package/dist/ui/react/index.d.ts.map +1 -0
  624. package/dist/ui/react/index.js +12 -0
  625. package/dist/ui/react/index.js.map +1 -0
  626. package/dist/ui/react/jobs.d.ts +62 -0
  627. package/dist/ui/react/jobs.d.ts.map +1 -0
  628. package/dist/ui/react/jobs.js +114 -0
  629. package/dist/ui/react/jobs.js.map +1 -0
  630. package/dist/ui/react/live-events.d.ts +18 -0
  631. package/dist/ui/react/live-events.d.ts.map +1 -0
  632. package/dist/ui/react/live-events.js +94 -0
  633. package/dist/ui/react/live-events.js.map +1 -0
  634. package/dist/ui/react/types.d.ts +79 -0
  635. package/dist/ui/react/types.d.ts.map +1 -0
  636. package/dist/ui/react/types.js +32 -0
  637. package/dist/ui/react/types.js.map +1 -0
  638. package/dist/ui/ssr.d.ts +55 -0
  639. package/dist/ui/ssr.d.ts.map +1 -0
  640. package/dist/ui/ssr.js +30 -0
  641. package/dist/ui/ssr.js.map +1 -0
  642. package/{src → dist}/ui/styles.css +22 -1
  643. package/migrations/0007_messaging.sql +52 -0
  644. package/migrations/0008_messaging_tenant_integrity.sql +44 -0
  645. package/migrations/0009_healthcheck_measurements.sql +3 -0
  646. package/migrations/0010_admin_dashboard_refinements.sql +24 -0
  647. package/package.json +162 -21
  648. package/changelog.md +0 -25
  649. package/src/admin/index.js +0 -1
  650. package/src/admin/routes.js +0 -64
  651. package/src/api/client.js +0 -8
  652. package/src/api/contracts.js +0 -24
  653. package/src/api/index.js +0 -7
  654. package/src/api/jobs.js +0 -37
  655. package/src/api/testing.js +0 -13
  656. package/src/app.js +0 -5
  657. package/src/auth/encoding.js +0 -6
  658. package/src/auth/groups.js +0 -5
  659. package/src/auth/impersonation.js +0 -15
  660. package/src/auth/index.js +0 -8
  661. package/src/auth/oauth-single.js +0 -193
  662. package/src/auth/scopes.js +0 -32
  663. package/src/auth/subscriptions.js +0 -25
  664. package/src/auth/tenants.js +0 -34
  665. package/src/auth/users.js +0 -31
  666. package/src/cli/cli.js +0 -133
  667. package/src/cli/d1.js +0 -165
  668. package/src/cli/operations.js +0 -34
  669. package/src/cli/project.js +0 -560
  670. package/src/cli/status.js +0 -46
  671. package/src/cli/tenants.js +0 -16
  672. package/src/cli/users.js +0 -34
  673. package/src/cli/version.js +0 -54
  674. package/src/core/circuits.js +0 -134
  675. package/src/core/d1.js +0 -54
  676. package/src/core/event-hub.js +0 -29
  677. package/src/core/events.js +0 -63
  678. package/src/core/identity.js +0 -39
  679. package/src/core/index.js +0 -7
  680. package/src/core/jobs.js +0 -185
  681. package/src/core/security.js +0 -71
  682. package/src/data/context.js +0 -16
  683. package/src/data/reader.js +0 -63
  684. package/src/data/resources.js +0 -42
  685. package/src/repository.js +0 -63
  686. package/src/runtime/features.js +0 -17
  687. package/src/runtime/health.js +0 -17
  688. package/src/runtime/worker.js +0 -45
  689. package/src/ui/index.js +0 -1
  690. package/src/ui/react/admin-access.jsx +0 -29
  691. package/src/ui/react/admin-catalogs.jsx +0 -39
  692. package/src/ui/react/admin-shell.jsx +0 -17
  693. package/src/ui/react/foundation.jsx +0 -40
  694. package/src/ui/react/index.jsx +0 -6
  695. package/src/ui/react/jobs.jsx +0 -63
  696. package/src/ui/react/live-events.jsx +0 -55
package/CHANGELOG.md ADDED
@@ -0,0 +1,99 @@
1
+ # Changelog
2
+
3
+ ## 5.0.3
4
+
5
+ This release intentionally removes legacy compatibility paths. Applications
6
+ must migrate to the single v5 contract; no aliases or fallback behavior are
7
+ retained.
8
+
9
+ ### Consolidation
10
+
11
+ - `cf-genai-llm`, `cf-genai-messaging`, and `cf-genai-cli` are no longer
12
+ runtime dependencies. LLM and messaging now ship from
13
+ `@agilesyndrome/cf-genai-base/features/llm` and `/features/messaging`; the
14
+ `cf-genai` executable ships from base.
15
+ - Messaging storage is now base migration `0007_messaging.sql`. Vendor and
16
+ apply the base migrations, then remove separately vendored messaging schema
17
+ migrations when they are redundant for a new installation.
18
+ - Messaging tables and the built-in resource manifest are tenant-scoped by
19
+ default. Remove application-owned messaging resource declarations; existing
20
+ installations must add and backfill `tenant_id` before adopting the base
21
+ migration contract.
22
+ - The changelog filename is now `CHANGELOG.md`.
23
+ - Core operational code is divided into owned segments: `circuits/`,
24
+ `healthchecks/`, `events/`, `jobs/`, `database/`, and `security/`. Request
25
+ identity now lives under `auth/identity/`. Internal modules use these narrow
26
+ boundaries instead of the broad core barrel.
27
+ - Built-in features now use folder entrypoints. LLM code is divided into
28
+ client, configuration, schema, error, and manifest modules under
29
+ `features/llm/`; messaging code is divided into model, resource, store, job,
30
+ and manifest modules under `features/messaging/`.
31
+
32
+ ### Required application changes
33
+
34
+ - Replace imports of removed flat source modules with package segment exports:
35
+ `core/circuits.js` becomes `/core/circuits`, `core/events.js` becomes
36
+ `/core/events`, `core/jobs.js` becomes `/core/jobs`, `core/d1.js` becomes
37
+ `/core/database`, `core/security.js` becomes `/core/security`, and
38
+ `core/identity.js` becomes `/auth/identity`. The old source files and their
39
+ compatibility facades do not exist in v5.
40
+ - Replace direct source imports of `src/features/llm.js` and
41
+ `src/features/messaging.js` with their folder `index.js` files. Package
42
+ consumers continue to use `/features/llm` and `/features/messaging`; those
43
+ package paths now resolve to the folder entrypoints.
44
+
45
+ - Move every feature registration into `defineApp({ features: [...] })`.
46
+ Remove `createWorker.features` and `createWorker.featureOptions`. Configure a
47
+ built-in with `defineFeature("llm", options)` or
48
+ `defineFeature("messaging", options)`; put external feature objects such as
49
+ auth directly in the same application feature array.
50
+ - Remove `createWorker.auth` and `createWorker.repositories`. Register auth as
51
+ an application feature and repositories through `defineApp({ repositories })`.
52
+ - Replace `createFeature` imports with `createLLMFeature` or
53
+ `createMessagingFeature`. `createMessagingFeature` is no longer an alias.
54
+ - LLM clients expose only `generate`, `generateJob`, `generateMulti`, `review`,
55
+ `reviewMulti`, and `listModels`. Remove the `*WithSchema` method aliases.
56
+ - Use the fixed LLM signatures `(prompt, schema, options)`,
57
+ `(jobId, prompt, schema, options)`, and
58
+ `(originalText, prompts, schema, options)`. Object-wrapped requests and
59
+ schema-inside-options overloads are removed.
60
+ - Configure LLM credentials only with `apiToken` or `LLM_API_TOKEN`. Remove
61
+ `apiKey`, `LLM_API_KEY`, and `OPENAI_API_KEY`. Use `featureName`; the old
62
+ client `feature` option is removed.
63
+ - Messaging participants must be `{ type, key, name, metadata? }` objects.
64
+ Remove string participants and the `participantType`, `participantKey`,
65
+ `displayName`, `id`, `senderType`, `senderKey`, `senderName`, `recipients`,
66
+ and `kind` input aliases. Reply generators must return a message object, not
67
+ a string.
68
+ - Messaging stores now accept only a scoped data reader:
69
+ `createMessagingStore(env.data.tenant)`. Remove raw D1 bindings, table
70
+ prefixes, and authorization callbacks from store construction.
71
+ - Feature manifests now accept only `name`, `displayName`, `packageName`,
72
+ `version`, `healthchecks`, and `circuitBreakers` in their canonical casing.
73
+ Remove nested manifests, `id` names, snake-case manifest properties,
74
+ `healthChecks`, `circuit_breakers`, and circuit `dependencies`.
75
+ - Configure both an exact HTTPS `OIDC_DISCOVERY_URL` and `OIDC_ISSUER`. The
76
+ issuer-to-discovery fallback and automatic well-known URL construction are
77
+ removed.
78
+ - Use only the CLI forms `healthchecks ...`, `circuit-breakers ...`, and
79
+ `--env production`. Colon commands, singular domains, `circuit`, `update`
80
+ action aliases, `rename`, and `prod` are removed. `cf-genai upgrade` accepts
81
+ only `base` or `auth`; it no longer treats `llm` and `messaging` as aliases.
82
+ Top-level `backup` and `restore` aliases are removed; use `d1 backup` and
83
+ `d1 restore`.
84
+ - Read request IDs from the `X-Request-ID` response header. The browser client
85
+ no longer falls back to a `request_id` JSON field.
86
+
87
+ ## 5.0.0
88
+
89
+ - Replace `@agilesyndrome/cf-genai-base/authorization` imports with `/auth`.
90
+ - Replace direct `src/core.js` imports with `src/core/index.js` or the package `/core` entrypoint.
91
+ - Replace direct `src/data.js` imports with `src/data/index.js` or the package `/data` entrypoint.
92
+ - Replace direct `src/api/router.js` imports with `src/api/contracts.js` for route definitions and dispatch.
93
+ - Update internal imports to the canonical folder modules; the old facade files are removed.
94
+ - Update package consumers and lockfiles to version `5.0.0`.
95
+ - Replace server-rendered admin HTML and custom elements with the React UI entrypoint; apps own the shell and theme around base's admin components.
96
+ - Apply `migrations/0006_jobs.sql`; features now use generic durable job helpers and `GET /api/jobs` instead of inventing job tables and status endpoints.
97
+ - Configure an `EVENT_HUB` Durable Object and export `EventHub` from `@agilesyndrome/cf-genai-base/event-hub` to enable authenticated live job events over WebSockets.
98
+ - Dispatch long-running work through a Cloudflare Workflow with `dispatchJob`; execute its durable lifecycle with `executeJob` instead of relying on request-lifetime background work.
99
+ - Remove the lowercase `admin_token` environment alias; use `ADMIN_TOKEN` only.
package/CLI.md CHANGED
@@ -5,10 +5,6 @@ provides safe operational commands for Cloudflare Worker repositories using
5
5
  Wrangler and D1. The refresh command surface contains only local and staging
6
6
  targets.
7
7
 
8
- Projects that previously installed `@agilesyndrome/cf-genai-cli` should remove
9
- that dependency. Installing `@agilesyndrome/cf-genai-base` now installs the
10
- same `cf-genai` executable.
11
-
12
8
  Automation can import the command runner from
13
9
  `@agilesyndrome/cf-genai-base/cli`. The migrated helper modules remain
14
10
  available through subpaths such as `@agilesyndrome/cf-genai-base/cli/d1` and
@@ -23,14 +19,14 @@ cf-genai lint data-access
23
19
  cf-genai test
24
20
  cf-genai ci
25
21
  cf-genai dev
22
+ cf-genai storybook
26
23
  cf-genai upgrade base latest
27
24
  cf-genai upgrade auth latest
28
- cf-genai upgrade llm 5.0.0
29
- cf-genai upgrade messaging latest
30
25
  cf-genai release --confirm
31
26
  cf-genai release --first --confirm
32
27
  cf-genai release --add-trust --confirm
33
28
  cf-genai release --dry-run
29
+ cf-genai release --pre --confirm
34
30
  cf-genai release --version 4.1 --confirm
35
31
  cf-genai release-status
36
32
  cf-genai release-status --wait 3 --json
@@ -87,17 +83,17 @@ clean checkout on `main`, fetches and compares `origin/main`, pushes and
87
83
  verifies the release commit before creating the tag, and only then pushes the
88
84
  tag that triggers npm publishing. The release tag publishes the package through GitHub Actions with provenance. `config check` runs a Wrangler deploy dry-run. Production refresh remains intentionally unavailable; backups and restores are available with explicit file paths.
89
85
 
90
- `upgrade PACKAGE VERSION` upgrades the first-party `base`, `auth`, `llm`, or
91
- `messaging` package with npm and vendors package migrations not already represented in the repository's
86
+ `upgrade PACKAGE VERSION` upgrades the first-party `base` or `auth` package
87
+ with npm and vendors package migrations not already represented in the repository's
92
88
  `migrations/` directory. The generated files are ordinary committed Wrangler
93
89
  migrations, so the same schema change is applied consistently to local,
94
90
  staging, and production D1 databases. Review and commit the package files,
95
91
  `package.json`, `package-lock.json`, and generated migrations together.
96
92
  Operational status can be read directly from the current site directory through Wrangler (no CLI login prompt):
97
- cf-genai healthcheck:list --env local
98
- cf-genai healthcheck:list --env staging
99
- cf-genai circuit-breaker:list --env prod
100
- cf-genai circuit-breaker:set llm:openai-models on --env staging
93
+ cf-genai healthchecks list --env local
94
+ cf-genai healthchecks list --env staging
95
+ cf-genai circuit-breakers list --env production
96
+ cf-genai circuit-breakers set llm:openai-models on --env staging
101
97
  The standardized admin surface mirrors cf-genai-base and uses Wrangler authentication from the current machine:
102
98
  cf-genai admin status --env staging
103
99
  cf-genai admin features --env staging
@@ -118,4 +114,4 @@ The standardized admin surface mirrors cf-genai-base and uses Wrangler authentic
118
114
  Back up and restore a complete D1 database with explicit files:
119
115
  cf-genai d1 backup production --output ./backup.sql --confirm-production
120
116
  cf-genai d1 restore staging --file ./backup.sql --yes
121
- `release` creates the version commit and tag; the tag-triggered workflow publishes to npm. `release-status` verifies a clean, pushed workspace, the remote release tag, successful GitHub Actions runs for that tag, npm publication, and whether the declared `cf-genai-base` version is current. An older base version is shown in yellow with an upgrade command. `--wait` is one total timeout in minutes shared by GitHub Actions and npm polling; the default is five minutes. Use `release --version MAJOR.MINOR` to explicitly jump to a version such as `5.0`; the CLI assigns patch `0`, accepts an equal prepared manifest version when its tag and npm version do not exist, rejects older versions, and refuses any version already present on npm or GitHub. This is useful for synchronizing packages onto a common release line.
117
+ `release` creates the version commit and tag; the tag-triggered workflow publishes to npm. Use `release --pre --confirm` for a prerelease build: each run creates a new monotonic version such as `<version>-pre.0`, `<version>-pre.1`, and an immutable release tag. `release-status` verifies a clean, pushed workspace, the remote release tag, successful GitHub Actions runs for that tag, npm publication, and whether the declared `cf-genai-base` version is current. An older base version is shown in yellow with an upgrade command. `--wait` is one total timeout in minutes shared by GitHub Actions and npm polling; the default is five minutes. Use `release --version MAJOR.MINOR` to explicitly jump to a version such as `5.0`; the CLI assigns patch `0`, accepts an equal prepared manifest version when its tag and npm version do not exist, rejects older versions, and refuses any version already present on npm or GitHub. This is useful for synchronizing packages onto a common release line.
package/CONTRACT.md CHANGED
@@ -4,20 +4,35 @@ Every site built from this foundation follows the same edge contract.
4
4
 
5
5
  ## API, UI, and repositories
6
6
 
7
- `defineRoute({ method, path, auth, scope, csrf, handler })` defines a route
8
- contract. Applications pass contracts through `createWorker({ apiRoutes })`;
9
- base enforces authentication, administrator status, same-origin mutation
10
- rules, and scope checks before invoking the handler. `@agilesyndrome/cf-genai-base/api`
11
- also exposes `apiFetch` and `apiJson` for browser clients.
12
-
13
- `createRepositories(env, definitions)` creates named application or feature
7
+ `AppDomain` owns route contracts alongside a concept's model, views, data
8
+ resources, and repositories. Applications register domains through
9
+ `defineApp({ domains })`; base gives every domain route to Hono and enforces
10
+ authentication, administrator status, same-origin mutation rules, custom
11
+ policies, and scope checks before invoking the handler. `defineRoute` remains
12
+ the low-level contract helper used by the domain dispatcher.
13
+
14
+ `defineApp` snapshots and freezes its manifest arrays. TypeScript consumers
15
+ retain the concrete domain and feature registration types, and built-in
16
+ `defineFeature` options are selected from the feature name.
17
+
18
+ The `/api` browser client returns `JsonValue | Response`: empty, `null`, or
19
+ non-JSON success bodies preserve the original unread `Response`. Callers that
20
+ need a narrower JSON result pass a `validateJson` type guard, which both checks
21
+ the untrusted payload and infers the result type. `ApiError` exposes only the
22
+ safe server message, HTTP `status`, and `X-Request-ID` as `requestId`.
23
+
24
+ Core security helpers expose typed same-origin inputs, bounded JSON-object
25
+ reading results, status-bearing request errors, and secure response helpers;
26
+ JSON parsing remains runtime-validated and request bodies are read from clones.
27
+
28
+ `createRepositories(env, definitions)` creates named application or domain
14
29
  repositories over the request-scoped data reader. Definitions may declare
15
30
  relations to other repositories. Repositories must not expose raw D1 or accept
16
31
  unvalidated table, column, or SQL fragments from callers.
17
32
 
18
33
  ## Worker entrypoint
19
34
 
20
- `createWorker({ fetch, features?, middleware?, auth?, authorize?, scheduled?, security? })` owns the Worker lifecycle and reserved admin boundary. Features run in declaration order and may call `next()` or return a response. A feature may also declare `{ routes: [{ match, handle }] }`; matching handlers receive `{ request, env, ctx, state, next }` and run before the site handler. The site router owns pages, APIs, D1 queries, and R2 object keys. `scheduled`
35
+ `createWorker({ fetch, app, middleware?, authorize?, scheduled?, security? })` owns the Worker lifecycle and reserved admin boundary. An application requests built-ins with `defineApp({ name, features: [defineFeature("llm", options), defineFeature("messaging", options)] })`; base resolves only those registrations and ignores every unrequested built-in. External feature objects are registered in the same `app.features` array. Business APIs, views, data resources, and repositories are composed through `AppDomain` instances registered in `app.domains` or `feature.domains`. Duplicate and unknown features fail during Worker construction. Feature middleware runs in declaration order and may call `next()` or return a response; feature endpoints must be domains so Hono remains the only route matcher. The site router owns pages that are not supplied by a domain. `scheduled`
21
36
  is optional and must use `ctx.waitUntil` for background work.
22
37
 
23
38
  ## Routes
@@ -28,18 +43,19 @@ is optional and must use `ctx.waitUntil` for background work.
28
43
  - `/admin` and `/admin/*` are browser admin routes; `/api/admin` and `/api/admin/*` are admin API routes.
29
44
  - Admin routes use `AUTH_STRATEGY`; omitted or empty means `http_basic`. Basic auth accepts username `admin` and the value of `ADMIN_TOKEN`. Missing token means all admin routes return 401.
30
45
  - `AUTH_STRATEGY=oauth` delegates identity establishment to the configured auth provider and uses `authorize` for admin policy.
31
- - `scopes` registers an application scope manifest. `scopeRoutes` associates route prefixes or match functions with required scopes.
32
- - Base protects `/admin` and `/api/admin`; browser pages are React applications that consume the JSON admin APIs. Import `AdminShell` and the platform catalogs from `@agilesyndrome/cf-genai-base/ui` and apply the application's theme around them.
33
- - Base provides `/api/admin/users`, `/api/admin/scopes`, `/api/admin/groups`, `/api/admin/status`, `/api/admin/features`, `/api/admin/healthchecks`, `/api/admin/circuit-breakers`, and `/api/admin/users/:id/scopes|groups` for platform administrators when the authorization and core migrations are installed. It also provides short-lived `/api/admin/users/:id/impersonate` and `/api/admin/impersonate/clear` controls. `GET /api/tenant` returns the authenticated active tenant and validated memberships; invalid `X-Tenant-ID` values return 400. `GET /api/admin/features` returns the installed runtime feature manifests, package names and versions, per-feature health rollups, healthchecks, and circuit breakers. React platform components consume these JSON APIs. Feature manifests may provide `name`, `displayName`, `packageName`, and `version`.
46
+ - Domain route `scopes` register the application scope manifest and enforce access at the exact Hono route. Use `scopeMode: "any"` when any declared scope is sufficient; the default requires all declared scopes.
47
+ - Base protects `/admin` and `/api/admin`; browser pages are React applications that consume the JSON admin APIs. `AdminDashboard` is the complete single-route administration UI; it includes all platform catalogs and owns internal list/detail navigation. `AdminShell` and the individual components remain available for custom routed interfaces.
48
+ - Base provides list/detail APIs for users, groups, tenants, features, healthchecks, and circuit breakers, plus relationship replacement for user scopes, groups, and tenants. Built-in admin domains declare delegated `users:*`, `groups:*`, `tenants:*`, `operations:*`, `subscriptions:*`, and `impersonation:start` capabilities; platform administrators satisfy all route capabilities. It also provides short-lived impersonation controls. `GET /api/tenant` returns the authenticated active tenant and validated memberships; invalid `X-Tenant-ID` values return 400. React platform components consume these JSON APIs.
34
49
  - Public APIs must be explicitly listed in provider-specific auth configuration.
35
50
  - Mutating `/api/*` requests require a same-origin `Origin` header.
36
51
  - `createWorker` supplies request-scoped `data`, `user`, `authUser`, `userId`, `context`, `event`, and audited D1 access to route handlers. `Event(who, what, where, when, details)` creates normalized events; installed features may consume them through `eventHandler`.
37
- - `migrations/0006_jobs.sql` adds generic durable jobs and job events. Features create and update jobs with the exported lifecycle helpers; `GET /api/jobs`, `GET /api/jobs/:id`, and `GET /api/jobs/:id/events` expose only the authenticated owner's records. `GET /api/events` is an optional authenticated WebSocket stream backed by the configured `EVENT_HUB` Durable Object.
52
+ - `migrations/0006_jobs.sql` adds generic durable jobs and job events. Features create and update jobs with the exported lifecycle helpers; `GET /api/jobs`, `GET /api/jobs/:id`, and `GET /api/jobs/:id/events` expose only the authenticated owner's records, while `POST /api/jobs/:id/cancel` cancels an owned queued/running job. Administrators may request `GET /api/jobs?all=true`. `GET /api/events` is an optional authenticated WebSocket stream backed by the configured `EVENT_HUB` Durable Object.
38
53
 
39
54
  ## Environment and bindings
40
55
 
41
56
  Required OIDC secrets for the standard auth plugin:
42
57
 
58
+ - `OIDC_DISCOVERY_URL`
43
59
  - `OIDC_ISSUER`
44
60
  - `OIDC_CLIENT_ID`
45
61
  - `OIDC_CLIENT_SECRET`
@@ -56,7 +72,8 @@ Build metadata is optional: `BUILD_SHA` and `BUILD_NUMBER`.
56
72
  The package includes ordered migrations. Each site must apply
57
73
  `migrations/0001_authorization.sql` before enabling the generic user/scope APIs,
58
74
  `migrations/0004_tenants.sql` for tenant membership and subscriptions, and
59
- `migrations/0006_jobs.sql` before creating or reading durable jobs.
75
+ `migrations/0006_jobs.sql` before creating or reading durable jobs. Apps that
76
+ request messaging also apply `migrations/0007_messaging.sql`.
60
77
  The tenant migration seeds the `Easley Family` tenant and `VIP` subscription,
61
78
  and migrates existing authorization users into that tenant.
62
79
 
@@ -72,8 +89,8 @@ must remain in the application router rather than in the shared auth package.
72
89
 
73
90
  ## Scoped data contract
74
91
 
75
- `createWorker` accepts `dataResources`, and features may expose the same
76
- manifest through `feature.dataResources`. Each resource must declare a safe
92
+ Domains expose persistence manifests through `domain.dataResources` and
93
+ `domain.repositories`; apps and features register those domains. Each resource must declare a safe
77
94
  name, table, explicit columns, and one scope: `user`, `tenant`, `public`, or
78
95
  `system`. Public resources are read-only and predicate on the worker's
79
96
  `publicTenantId`, including for authenticated users.
package/README.md CHANGED
@@ -10,6 +10,18 @@ The base owns the shared security boundary as well as Worker lifecycle concerns.
10
10
  Use D1 bindings for durable application data and R2 bindings for binary assets;
11
11
  do not put either into module-level state.
12
12
 
13
+ The Worker transport is built on [Hono](https://hono.dev/): middleware ordering,
14
+ HTTP method/path matching, and admin/API dispatch all use Hono's runtime. Existing
15
+ feature middleware keeps the package's compatibility signature while new integrations
16
+ can use Hono middleware directly. For Worker-rendered documents, import
17
+ `createSsrRenderer`, `SiteDocument`, or `renderSiteDocument` from
18
+ `@agilesyndrome/cf-genai-base/ui/ssr`; the interactive admin components remain
19
+ React-based and are intentionally separate from Hono JSX SSR.
20
+
21
+ The site document contract owns safe metadata, canonical URLs, Open Graph
22
+ fields, theme color, stylesheets, scripts, and body data attributes. A site
23
+ supplies its own children, theme CSS, navigation, and content components.
24
+
13
25
  Base also provides provider-neutral authorization helpers and browser components
14
26
  through `@agilesyndrome/cf-genai-base/auth` and
15
27
  `@agilesyndrome/cf-genai-base/ui`. Applications declare their scope manifest,
@@ -18,24 +30,66 @@ API. The UI components are themeable with CSS custom properties and do not
18
30
  contain application-specific components.
19
31
 
20
32
  ```js
21
- import { createWorker, healthResponse } from "@agilesyndrome/cf-genai-base";
33
+ import { createWorker, defineApp, defineFeature } from "@agilesyndrome/cf-genai-base";
22
34
 
23
35
  export default createWorker({
24
- features: [auth],
36
+ app: defineApp({
37
+ name: "cookbook",
38
+ features: [
39
+ auth,
40
+ defineFeature("llm", { apiToken: (env) => env.LLM_API_TOKEN }),
41
+ defineFeature("messaging", { displayName: "Cookbook chat" }),
42
+ ],
43
+ }),
25
44
  fetch: async (request, env) => {
26
- if (new URL(request.url).pathname === "/health") return healthResponse(env);
27
45
  return router(request, env);
28
46
  },
29
47
  });
30
48
  ```
31
49
 
32
- Features expose `middleware(request, env, ctx, next, state)` and may short-circuit reserved routes, attach request state, or call `next()`.
50
+ Built-in features are inert unless an application registers them in
51
+ `app.features`. Feature-specific APIs use explicit subpaths:
52
+
53
+ ```js
54
+ import { createLLM } from "@agilesyndrome/cf-genai-base/features/llm";
55
+ import { createMessagingStore } from "@agilesyndrome/cf-genai-base/features/messaging";
56
+ ```
57
+
58
+ The LLM feature provides OpenAI-compatible generation, typed JSON repair,
59
+ review, model healthchecks, circuit breakers, and durable job integration. The
60
+ `/features/llm` entrypoint exports its complete TypeScript contract, including
61
+ `LLMEnvironment`, client and request options, provider configuration, JSON
62
+ Schema inputs and `InferJSONSchema`, token usage, generation/review inputs,
63
+ job options, loggers, and callbacks. Pass a literal schema with `as const` (or
64
+ `satisfies JSONSchemaInput`) to preserve the generated value type.
65
+ The messaging feature provides conversations, participants, messages, scoped and
66
+ tenant-isolated stores, and durable reply jobs. Construct the store with the
67
+ request-scoped reader, for example `createMessagingStore(env.data.tenant)`. Apply
68
+ `migrations/0007_messaging.sql` when messaging is requested.
69
+
70
+ Features expose `middleware(request, env, ctx, next, state)` and may
71
+ short-circuit routes, attach request state, or call `next()`.
33
72
 
34
73
  Base protects `/admin` and `/api/admin`; the React UI package owns the browser
35
- pages. Import `AdminShell` and the platform catalogs from
74
+ pages. For a complete single-route UI, import `AdminDashboard` from
75
+ `@agilesyndrome/cf-genai-base/ui` and mount `<AdminDashboard />`, or use
76
+ `mountAdminDashboards` for declarative roots. It includes
77
+ users and access assignments, tenants, user groups, scopes, subscriptions,
78
+ jobs, features, health checks, and circuit breakers with internal list/detail
79
+ navigation. Use `enabledSections` to hide an unavailable optional domain and
80
+ `applicationSections` to add site-owned panels. Import `AdminShell` and the platform catalogs from
36
81
  `@agilesyndrome/cf-genai-base/ui`. Sites provide their own application links and
37
82
  theme while the base components consume the shared JSON admin APIs.
38
83
 
84
+ ```jsx
85
+ import { AdminDashboard } from "@agilesyndrome/cf-genai-base/ui";
86
+ import "@agilesyndrome/cf-genai-base/ui/styles.css";
87
+
88
+ export function AdminPage() {
89
+ return <AdminDashboard />;
90
+ }
91
+ ```
92
+
39
93
  ## Command-line tools
40
94
 
41
95
  Install base in a project (or globally) and use the bundled executable:
@@ -48,21 +102,23 @@ cf-genai check
48
102
  cf-genai test
49
103
  cf-genai ci
50
104
  cf-genai dev
105
+ cf-genai storybook
51
106
  cf-genai upgrade base latest
52
107
  cf-genai release --confirm
53
108
  cf-genai release-status --wait 3
54
109
  ```
55
110
 
56
- Projects upgrading from the standalone package should remove
57
- `@agilesyndrome/cf-genai-cli`; their existing base dependency now supplies the
58
- same `cf-genai` executable.
59
-
60
- The CLI includes all commands formerly published by
61
- `@agilesyndrome/cf-genai-cli`: project checks and releases, scoped-data linting,
62
- package upgrades with migration vendoring, D1 refresh/backup/restore/migration,
63
- site status, and user, tenant, healthcheck, circuit-breaker, and platform admin
111
+ The CLI includes project checks and releases, scoped-data linting, package
112
+ upgrades with migration vendoring, D1 refresh/backup/restore/migration, site
113
+ status, and user, tenant, healthcheck, circuit-breaker, and platform admin
64
114
  operations.
65
115
 
116
+ In this repository, `npm install` activates the checked-in Git hooks. Each
117
+ commit runs `cf-genai ci`, the same full verification command used by GitHub
118
+ Actions. Verification includes typechecking, source whitespace/unsafe-type
119
+ checks, compilation, unit tests, the example integration suite, export checks,
120
+ and package assembly.
121
+
66
122
  ```sh
67
123
  cf-genai status --env staging
68
124
  cf-genai d1 refresh local
@@ -92,15 +148,17 @@ Cloudflare configuration is incomplete.
92
148
  ## Core operational services
93
149
 
94
150
  The package is organized by responsibility: `runtime` composes Workers,
95
- `core` owns request/event/security/D1 primitives, `auth` owns authorization
96
- data access, `api` owns route contracts and the browser client, `admin` owns
97
- platform administration, and `ui` owns shared browser components. Each
98
- responsibility has a canonical folder entrypoint; import from `core`, `auth`,
99
- `data`, `api`, `admin`, or `ui` as appropriate.
151
+ `core` owns operational primitives, `auth` owns identity and authorization,
152
+ `api` owns route contracts and the browser client, `admin` owns platform
153
+ administration, and `ui` owns shared browser components. Core services have
154
+ focused package entrypoints: `/core/circuits`, `/core/healthchecks`,
155
+ `/core/events`, `/core/jobs`, `/core/database`, and `/core/security`; request
156
+ identity is `/auth/identity`. Prefer these narrow imports when an app needs one
157
+ concern. The root package remains the application-composition surface.
100
158
 
101
159
  Apply `migrations/0002_core.sql` and `migrations/0006_jobs.sql` after the authorization migration. The package exports `registerHealthcheck`, `updateHealthcheck`, `registerCircuitBreaker`, `setCircuitBreaker`, `evaluateCircuitBreaker`, and generic job lifecycle helpers from `/cf-genai-base`. Healthchecks use `red`, `yellow` (unknown/transient), or `green`; breakers use `off`, `tripped`, or `on`, with `any` or `all` healthcheck evaluation. Automated evaluation may only move `on` to `tripped`, or self-healing `tripped` to `on`; admin API writes are the human control plane for the `off` state.
102
160
 
103
- Admin APIs are `GET /api/admin/healthchecks`, `PUT /api/admin/healthchecks/:id`, `GET /api/admin/circuit-breakers`, `GET|PUT /api/admin/circuit-breakers/:id`, and `GET /api/admin/features`. React platform components consume these JSON responses. The catalog lists each installed runtime feature, its `packageName` and `version`, its most severe healthcheck state, all feature healthchecks, and its circuit breakers (including the feature roll-up breaker). Feature manifests may expose `healthchecks` and `circuitBreakers`; add `displayName`, `packageName`, and `version` to make the installation identity explicit. Use `createD1(env, { who })` for downstream D1 calls; it emits EventLog and AuditLog console records with the requesting actor.
161
+ Admin APIs are `GET /api/admin/healthchecks`, `GET|PUT /api/admin/healthchecks/:id`, `GET /api/admin/circuit-breakers`, `GET|PUT /api/admin/circuit-breakers/:id`, and `GET /api/admin/features`. Reads require `operations:read`; mutations require `operations:manage`, while platform administrators bypass capability checks. React platform components provide both catalog and detail views. The catalog lists each installed runtime feature, its `packageName` and `version`, its most severe healthcheck state, all feature healthchecks, and its circuit breakers. Use `createD1(env, { who })` for downstream D1 calls; it emits EventLog and AuditLog records with the requesting actor.
104
162
 
105
163
 
106
164
  ## User administration
@@ -116,11 +174,11 @@ Use the selected D1 target (local by default) to inspect and update users:
116
174
  cf-genai user get someone.com --target staging
117
175
  cf-genai user update someone.com --roles admin --target production
118
176
 
119
- `user:get` also reports scopes, groups, and tenant memberships. The shared admin user page displays each user’s tenant memberships and lets an administrator attach or detach tenants. The admin API exposes `GET|POST /api/admin/tenants`, `GET|PUT /api/admin/tenants/:id`, and `GET|PUT /api/admin/users/:id/tenants`. Production commands should be run through the repository credentials wrapper and reviewed as an administrative change.
177
+ `user:get` also reports scopes, groups, and tenant memberships. The shared admin UI provides list and detail views and atomically replaces a user’s complete access assignment through `PUT /api/admin/users/:id/access`; individual relationship endpoints remain available. The admin API also exposes `GET /api/admin/users/:id`, `GET|POST /api/admin/tenants`, and `GET|PUT|PATCH|DELETE /api/admin/tenants/:id`. The default tenant cannot be deleted, and other tenants must first have no users, subscriptions, or messaging conversations. Tenant deletion also requires an `X-Confirm-Delete` header equal to the tenant ID. Production commands should be run through the repository credentials wrapper and reviewed as an administrative change.
120
178
 
121
179
  ## Scoped data access
122
180
 
123
- Features may register D1 resources with `dataResources` and receive the
181
+ Domains may register D1 resources with `dataResources` and receive the
124
182
  scoped reader on the request state as `state.data`. Resources declare `user`,
125
183
  `tenant`, `public`, or `system` scope, their physical table, and an explicit column
126
184
  allowlist. Use `state.data.tenant`, `state.data.public`, `state.data.user`, or
@@ -128,7 +186,8 @@ allowlist. Use `state.data.tenant`, `state.data.public`, `state.data.user`, or
128
186
  the reader applies ownership predicates, supports bounded native pagination via
129
187
  page with limit/offset, count, and safe bulk updateWhere/deleteWhere
130
188
  operations, and never accepts raw SQL. Resources can explicitly restrict
131
- their operations to read, create, update, and delete.
189
+ their operations to read, create, update, and delete, require capabilities per
190
+ operation with `operationScopes`, and protect columns with `columnScopes`.
132
191
 
133
192
  Anonymous tenant reads require both publicTenantId on createWorker and a
134
193
  resource-level publicRead declaration. Use publicRead true only when the
@@ -138,8 +197,10 @@ system access. A `public` resource is read-only and always predicates on the
138
197
  worker's `publicTenantId`, including authenticated users; use it for shared
139
198
  catalog data such as GTA's `gta-public` tenant.
140
199
 
141
- Applications may pass subscriptionManifest to createWorker to register their
142
- own subscription IDs and entitlement values. Base exposes
200
+ Applications register `new AuthSubscriptionsDomain(manifest)` in
201
+ `defineApp({ domains })` to own their subscription IDs and entitlement values.
202
+ That domain exposes catalog/detail APIs at `/api/admin/subscriptions` and tenant
203
+ assignment at `/api/admin/tenants/:id/subscriptions`. Base also exposes
143
204
  requireSubscription and requireEntitlement but does not know any
144
205
  product-specific subscription such as VIP. Authenticated users can inspect
145
206
  their validated active tenant at GET /api/tenant.
@@ -149,6 +210,12 @@ POST /api/admin/users/:id/impersonate and clear it with
149
210
  POST /api/admin/impersonate/clear. Impersonation affects scoped data context
150
211
  only and does not grant the target user administrator permissions.
151
212
 
213
+ The messaging store derives user senders from the scoped reader context and
214
+ limits conversations to their creator, participants, and system actors.
215
+ Creator-only operations manage participants, titles, messages, and deletion.
216
+ Trusted host adapters without an actor context remain responsible for their
217
+ own authorization.
218
+
152
219
  For example, a tenant-owned resource registers its `tenant_id` column with
153
220
  base, while feature code calls `state.data.tenant.list("recipes")` without
154
221
  passing a tenant ID. The active tenant must be a validated membership. A
@@ -185,9 +252,9 @@ are the shared identity, request, security, and feature-gating contracts.
185
252
  The layered web surface is React-first: `/api` exports route contracts, scoped
186
253
  repositories, the browser `apiFetch`/`apiJson` client, and job/event endpoints;
187
254
  `/ui` exports React admin primitives, live event hooks, and durable job
188
- notifications. Repositories are registered with
189
- `createWorker({ repositories })`, can be supplied by applications or features,
190
- and may declare links to other repositories while remaining behind the scoped
191
- data reader. `GET /api/jobs` and `GET /api/jobs/:id` expose an authenticated
255
+ notifications. Repositories are registered by `AppDomain` instances in
256
+ `defineApp({ domains })` or `feature.domains`; they may declare links to other
257
+ repositories while remaining behind the scoped data reader. `GET /api/jobs`
258
+ and `GET /api/jobs/:id` expose an authenticated
192
259
  user's durable job records. `GET /api/events` upgrades to the authenticated live
193
260
  event stream when the optional `EVENT_HUB` Durable Object binding is configured.
package/bin/cf-genai.js CHANGED
@@ -1,11 +1,27 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { main } from "../src/cli/cli.js";
4
-
5
- try {
6
- const result = await main(process.argv.slice(2));
7
- if (result?.ok === false) process.exitCode = 1;
8
- } catch (error) {
9
- console.error(`Error: ${error.message}`);
10
- process.exitCode = 1;
3
+ import { existsSync } from "node:fs";
4
+ import { spawnSync } from "node:child_process";
5
+ import { fileURLToPath } from "node:url";
6
+
7
+ // Keep this JavaScript launcher as the npm bin compatibility boundary. Published
8
+ // packages load compiled TypeScript output; source checkouts run the TypeScript
9
+ // entrypoint through the development dependency installed by npm ci/install.
10
+ const builtEntrypoint = new URL("../dist/cli/cli.js", import.meta.url);
11
+ const sourceEntrypoint = new URL("../src/cli/cli.ts", import.meta.url);
12
+
13
+ if (!existsSync(builtEntrypoint)) {
14
+ const sourceRunner = new URL("../scripts/run-cli.mjs", import.meta.url);
15
+ const result = spawnSync(process.execPath, ["--import", "tsx", fileURLToPath(sourceRunner), ...process.argv.slice(2)], { stdio: "inherit" });
16
+ process.exitCode = result.status ?? 1;
17
+ } else {
18
+ const { main } = await import(builtEntrypoint.href);
19
+
20
+ try {
21
+ const result = await main(process.argv.slice(2));
22
+ if (result?.ok === false) process.exitCode = 1;
23
+ } catch (error) {
24
+ console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
25
+ process.exitCode = 1;
26
+ }
11
27
  }
@@ -0,0 +1,12 @@
1
+ import type { AdminBindings, AdminIdentity, AdminRequestState, AdminUserProvider } from "./types.js";
2
+ export declare function authenticateAdminRequest<Env extends AdminBindings, User extends AdminIdentity, State extends AdminRequestState<User>>(request: Request, env: Env, url: URL, state: State, provider?: AdminUserProvider<Env, User> | null): Promise<Response | null>;
3
+ export declare function requireSameOriginMutation(request: Request, url: URL): Response | null;
4
+ export declare function actorFor(user: AdminIdentity): string;
5
+ export declare function isPlatformAdministrator(state: AdminRequestState): boolean;
6
+ export declare function isAdminPath(pathname: string): boolean;
7
+ export declare function administratorRequired(url: URL): Response;
8
+ export declare function authenticationRequired(request: Request): Response;
9
+ export declare function oauthAuthenticationRequired(url: URL): Response;
10
+ export declare function safeReturnTo(value: string): string;
11
+ export declare function prepareAdminState<Env extends AdminBindings, User extends AdminIdentity, State extends AdminRequestState<User>>(env: Env, user: User, state: State): Promise<void>;
12
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/admin/auth.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAIpB,wBAAsB,wBAAwB,CAC5C,GAAG,SAAS,aAAa,EACzB,IAAI,SAAS,aAAa,EAC1B,KAAK,SAAS,iBAAiB,CAAC,IAAI,CAAC,EAErC,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK,EACZ,QAAQ,CAAC,EAAE,iBAAiB,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI,GAC7C,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAyB1B;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,GAAG,QAAQ,GAAG,IAAI,CASrF;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAEpD;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAEzE;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAErD;AAED,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,GAAG,GAAG,QAAQ,CAIxD;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,QAAQ,CAKjE;AAED,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,GAAG,GAAG,QAAQ,CAG9D;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAElD;AA2BD,wBAAsB,iBAAiB,CACrC,GAAG,SAAS,aAAa,EACzB,IAAI,SAAS,aAAa,EAC1B,KAAK,SAAS,iBAAiB,CAAC,IAAI,CAAC,EACrC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAInD"}
@@ -0,0 +1,103 @@
1
+ import { ensureUser } from "../auth/index.js";
2
+ import { requestActor } from "../auth/identity/index.js";
3
+ import { jsonError, NO_STORE_HEADERS } from "../api/http.js";
4
+ const MUTATING_METHODS = new Set(["POST", "PUT", "PATCH", "DELETE"]);
5
+ export async function authenticateAdminRequest(request, env, url, state, provider) {
6
+ const strategy = String(env.AUTH_STRATEGY ?? "http_basic").trim().toLowerCase();
7
+ if (strategy === "http_basic") {
8
+ const user = basicUser(request, env);
9
+ if (!user)
10
+ return authenticationRequired(request);
11
+ state.user = user;
12
+ return null;
13
+ }
14
+ if (strategy === "oauth") {
15
+ const user = Object.hasOwn(state, "user")
16
+ ? state.user
17
+ : provider
18
+ ? await provider.getUser(request, env)
19
+ : null;
20
+ if (!user)
21
+ return oauthAuthenticationRequired(url);
22
+ state.user = user;
23
+ return null;
24
+ }
25
+ return new Response("Unsupported AUTH_STRATEGY", {
26
+ status: 500,
27
+ headers: NO_STORE_HEADERS,
28
+ });
29
+ }
30
+ export function requireSameOriginMutation(request, url) {
31
+ if (!MUTATING_METHODS.has(request.method) || !url.pathname.startsWith("/api/"))
32
+ return null;
33
+ const origin = request.headers.get("Origin");
34
+ try {
35
+ if (origin && new URL(origin).origin === url.origin)
36
+ return null;
37
+ }
38
+ catch {
39
+ // A malformed Origin is untrusted just like a cross-origin value.
40
+ }
41
+ return jsonError("A same-origin request is required.", 403);
42
+ }
43
+ export function actorFor(user) {
44
+ return user.auth_strategy === "http_basic" ? "user:admin" : `user:${user.sub || "unknown"}`;
45
+ }
46
+ export function isPlatformAdministrator(state) {
47
+ return state.user?.auth_strategy === "http_basic" || Boolean(state.authUser?.is_admin);
48
+ }
49
+ export function isAdminPath(pathname) {
50
+ return pathname === "/admin" || pathname.startsWith("/admin/") || pathname === "/api/admin" || pathname.startsWith("/api/admin/");
51
+ }
52
+ export function administratorRequired(url) {
53
+ return url.pathname.startsWith("/api/")
54
+ ? jsonError("Administrator access is required.", 403)
55
+ : new Response("Administrator access is required.", { status: 403, headers: NO_STORE_HEADERS });
56
+ }
57
+ export function authenticationRequired(request) {
58
+ const headers = { ...NO_STORE_HEADERS, "WWW-Authenticate": 'Basic realm="admin", charset="UTF-8"' };
59
+ return new URL(request.url).pathname.startsWith("/api/")
60
+ ? Response.json({ error: "Authentication is required." }, { status: 401, headers })
61
+ : new Response("Authentication is required.", { status: 401, headers });
62
+ }
63
+ export function oauthAuthenticationRequired(url) {
64
+ if (url.pathname.startsWith("/api/"))
65
+ return jsonError("Authentication is required.", 401);
66
+ return Response.redirect(`${url.origin}/auth/login?return_to=${encodeURIComponent(safeReturnTo(url.pathname + url.search))}`, 302);
67
+ }
68
+ export function safeReturnTo(value) {
69
+ return value.startsWith("/") && !value.startsWith("//") && !value.startsWith("/auth/") ? value : "/";
70
+ }
71
+ function basicUser(request, env) {
72
+ const token = String(env.ADMIN_TOKEN ?? "");
73
+ if (!token)
74
+ return null;
75
+ const header = request.headers.get("Authorization") ?? "";
76
+ if (!header.toLowerCase().startsWith("basic "))
77
+ return null;
78
+ let decoded;
79
+ try {
80
+ decoded = atob(header.slice(6).trim());
81
+ }
82
+ catch {
83
+ return null;
84
+ }
85
+ const separator = decoded.indexOf(":");
86
+ if (separator < 0 || !constantTimeEqual(decoded.slice(0, separator), "admin") || !constantTimeEqual(decoded.slice(separator + 1), token))
87
+ return null;
88
+ return { sub: "basic:admin", email: "", name: "admin", roles: ["admin"], auth_strategy: "http_basic" };
89
+ }
90
+ function constantTimeEqual(a, b) {
91
+ const aa = new TextEncoder().encode(a);
92
+ const bb = new TextEncoder().encode(b);
93
+ let difference = aa.length ^ bb.length;
94
+ for (let index = 0; index < Math.max(aa.length, bb.length); index += 1)
95
+ difference |= (aa[index] ?? 0) ^ (bb[index] ?? 0);
96
+ return difference === 0;
97
+ }
98
+ export async function prepareAdminState(env, user, state) {
99
+ const actor = actorFor(user);
100
+ state.authUser = user.authUser ?? (await ensureUser(env, user, { who: actor }));
101
+ state.requestedBy = requestActor(state);
102
+ }
103
+ //# sourceMappingURL=auth.js.map