dineway 0.1.49 → 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 (418) hide show
  1. package/dist/{activity-events-CwM7yxPW.mjs → activity-events-y6eT8UW6.mjs} +6 -38
  2. package/dist/actor-CrObAPV0.mjs +37 -0
  3. package/dist/after-BfniwgIf.mjs +9 -0
  4. package/dist/{allowed-origins-CyGnbgBd.mjs → allowed-origins-_oeyP6x-.mjs} +1 -1
  5. package/dist/api/route-utils.d.mts +10 -10
  6. package/dist/api/route-utils.mjs +16 -13
  7. package/dist/api/schemas/index.d.mts +2 -2
  8. package/dist/api/schemas/index.mjs +5 -4
  9. package/dist/{api-BMIxRIEN.mjs → api-ByrU2q-Z.mjs} +60 -36
  10. package/dist/{api-tokens-DtvdtIkm.mjs → api-tokens-CjVMQT-X.mjs} +6 -2
  11. package/dist/{apply-D_RlTYtC.mjs → apply-bZswmZPm.mjs} +117 -77
  12. package/dist/astro/image-endpoint.d.mts +7 -0
  13. package/dist/astro/image-endpoint.mjs +54 -0
  14. package/dist/astro/index.d.mts +35 -11
  15. package/dist/astro/index.mjs +157 -23
  16. package/dist/astro/integration/shims/use-sync-external-store-with-selector.js +71 -0
  17. package/dist/astro/integration/shims/use-sync-external-store.js +1 -0
  18. package/dist/astro/middleware/auth.d.mts +10 -10
  19. package/dist/astro/middleware/auth.mjs +42 -24
  20. package/dist/astro/middleware/redirect.mjs +13 -4
  21. package/dist/astro/middleware/request-context.mjs +8 -5
  22. package/dist/astro/middleware/seed.d.mts +1 -1
  23. package/dist/astro/middleware/seed.mjs +2 -2
  24. package/dist/astro/middleware/setup.mjs +1 -1
  25. package/dist/astro/middleware.mjs +333 -192
  26. package/dist/astro/routes/admin.astro +6 -1
  27. package/dist/astro/routes/api/admin/allowed-domains/_domain_.mjs +7 -6
  28. package/dist/astro/routes/api/admin/allowed-domains/index.mjs +7 -6
  29. package/dist/astro/routes/api/admin/api-tokens/_id_.mjs +4 -4
  30. package/dist/astro/routes/api/admin/api-tokens/index.mjs +6 -6
  31. package/dist/astro/routes/api/admin/briefing.mjs +21 -17
  32. package/dist/astro/routes/api/admin/byline-fields/_slug_/usage.mjs +4 -4
  33. package/dist/astro/routes/api/admin/byline-fields/_slug_.mjs +9 -8
  34. package/dist/astro/routes/api/admin/byline-fields/index.mjs +9 -8
  35. package/dist/astro/routes/api/admin/byline-fields/reorder.mjs +9 -8
  36. package/dist/astro/routes/api/admin/bylines/_id_/index.mjs +17 -14
  37. package/dist/astro/routes/api/admin/bylines/_id_/translations.mjs +17 -14
  38. package/dist/astro/routes/api/admin/bylines/index.mjs +17 -14
  39. package/dist/astro/routes/api/admin/comments/_id_/status.mjs +14 -12
  40. package/dist/astro/routes/api/admin/comments/_id_.mjs +6 -5
  41. package/dist/astro/routes/api/admin/comments/bulk.mjs +11 -9
  42. package/dist/astro/routes/api/admin/comments/counts.mjs +6 -5
  43. package/dist/astro/routes/api/admin/comments/index.mjs +11 -9
  44. package/dist/astro/routes/api/admin/context/_id_/history.mjs +26 -24
  45. package/dist/astro/routes/api/admin/context/_id_/index.mjs +26 -24
  46. package/dist/astro/routes/api/admin/context/_id_/review.mjs +31 -28
  47. package/dist/astro/routes/api/admin/context/_id_/supersede.mjs +31 -28
  48. package/dist/astro/routes/api/admin/context/diff.mjs +30 -27
  49. package/dist/astro/routes/api/admin/context/index.mjs +31 -28
  50. package/dist/astro/routes/api/admin/context/stale.mjs +30 -27
  51. package/dist/astro/routes/api/admin/hitl-requests/_id_/index.mjs +26 -24
  52. package/dist/astro/routes/api/admin/hitl-requests/_id_/resolve.mjs +30 -27
  53. package/dist/astro/routes/api/admin/hitl-requests/index.mjs +30 -27
  54. package/dist/astro/routes/api/admin/hooks/exclusive/_hookName_.mjs +27 -25
  55. package/dist/astro/routes/api/admin/hooks/exclusive/index.mjs +3 -3
  56. package/dist/astro/routes/api/admin/oauth-clients/_id_.mjs +6 -6
  57. package/dist/astro/routes/api/admin/oauth-clients/index.mjs +6 -6
  58. package/dist/astro/routes/api/admin/plugins/_id_/disable.mjs +55 -51
  59. package/dist/astro/routes/api/admin/plugins/_id_/enable.mjs +55 -51
  60. package/dist/astro/routes/api/admin/plugins/_id_/index.mjs +47 -43
  61. package/dist/astro/routes/api/admin/plugins/_id_/uninstall.mjs +53 -49
  62. package/dist/astro/routes/api/admin/plugins/_id_/update.mjs +52 -48
  63. package/dist/astro/routes/api/admin/plugins/index.mjs +47 -43
  64. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/icon.mjs +2 -2
  65. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/index.mjs +46 -42
  66. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.mjs +52 -48
  67. package/dist/astro/routes/api/admin/plugins/marketplace/index.mjs +46 -42
  68. package/dist/astro/routes/api/admin/plugins/updates.mjs +46 -42
  69. package/dist/astro/routes/api/admin/review-requests/_id_/index.mjs +5 -5
  70. package/dist/astro/routes/api/admin/review-requests/_id_/resolve.mjs +31 -27
  71. package/dist/astro/routes/api/admin/review-requests/index.mjs +10 -9
  72. package/dist/astro/routes/api/admin/themes/marketplace/_id_/index.mjs +46 -42
  73. package/dist/astro/routes/api/admin/themes/marketplace/_id_/thumbnail.mjs +2 -2
  74. package/dist/astro/routes/api/admin/themes/marketplace/index.mjs +46 -42
  75. package/dist/astro/routes/api/admin/users/_id_/disable.mjs +3 -3
  76. package/dist/astro/routes/api/admin/users/_id_/enable.mjs +2 -2
  77. package/dist/astro/routes/api/admin/users/_id_/index.mjs +8 -7
  78. package/dist/astro/routes/api/admin/users/_id_/send-recovery.mjs +4 -4
  79. package/dist/astro/routes/api/admin/users/index.mjs +7 -6
  80. package/dist/astro/routes/api/auth/dev-bypass.mjs +4 -4
  81. package/dist/astro/routes/api/auth/invite/accept.mjs +2 -2
  82. package/dist/astro/routes/api/auth/invite/complete.mjs +12 -11
  83. package/dist/astro/routes/api/auth/invite/index.mjs +9 -8
  84. package/dist/astro/routes/api/auth/invite/register-options.mjs +11 -10
  85. package/dist/astro/routes/api/auth/logout.mjs +2 -2
  86. package/dist/astro/routes/api/auth/magic-link/send.mjs +11 -10
  87. package/dist/astro/routes/api/auth/magic-link/verify.mjs +3 -3
  88. package/dist/astro/routes/api/auth/me.mjs +9 -8
  89. package/dist/astro/routes/api/auth/mode.mjs +1 -1
  90. package/dist/astro/routes/api/auth/oauth/_provider_/callback.mjs +3 -3
  91. package/dist/astro/routes/api/auth/oauth/_provider_.mjs +2 -2
  92. package/dist/astro/routes/api/auth/passkey/_id_.mjs +6 -5
  93. package/dist/astro/routes/api/auth/passkey/index.mjs +1 -1
  94. package/dist/astro/routes/api/auth/passkey/options.mjs +12 -11
  95. package/dist/astro/routes/api/auth/passkey/register/options.mjs +10 -9
  96. package/dist/astro/routes/api/auth/passkey/register/verify.mjs +11 -10
  97. package/dist/astro/routes/api/auth/passkey/verify.mjs +11 -10
  98. package/dist/astro/routes/api/auth/setup-token/index.mjs +5 -5
  99. package/dist/astro/routes/api/auth/setup-token/verify.mjs +2 -2
  100. package/dist/astro/routes/api/auth/signup/complete.mjs +12 -11
  101. package/dist/astro/routes/api/auth/signup/request.mjs +11 -10
  102. package/dist/astro/routes/api/auth/signup/verify.mjs +2 -2
  103. package/dist/astro/routes/api/comments/_collection_/_contentId_/index.mjs +15 -13
  104. package/dist/astro/routes/api/comments/_collection_/_contentId_/reactions.d.mts +8 -0
  105. package/dist/astro/routes/api/comments/_collection_/_contentId_/reactions.mjs +160 -0
  106. package/dist/astro/routes/api/content/_collection_/_id_/compare.mjs +2 -2
  107. package/dist/astro/routes/api/content/_collection_/_id_/discard-draft.mjs +5 -5
  108. package/dist/astro/routes/api/content/_collection_/_id_/duplicate.mjs +5 -5
  109. package/dist/astro/routes/api/content/_collection_/_id_/permanent.mjs +5 -5
  110. package/dist/astro/routes/api/content/_collection_/_id_/preview-url.mjs +11 -10
  111. package/dist/astro/routes/api/content/_collection_/_id_/publish.mjs +10 -9
  112. package/dist/astro/routes/api/content/_collection_/_id_/restore.mjs +5 -5
  113. package/dist/astro/routes/api/content/_collection_/_id_/revisions.mjs +2 -2
  114. package/dist/astro/routes/api/content/_collection_/_id_/schedule.mjs +10 -9
  115. package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.mjs +16 -14
  116. package/dist/astro/routes/api/content/_collection_/_id_/translations.mjs +2 -2
  117. package/dist/astro/routes/api/content/_collection_/_id_/unpublish.mjs +5 -5
  118. package/dist/astro/routes/api/content/_collection_/_id_.mjs +10 -9
  119. package/dist/astro/routes/api/content/_collection_/authors.mjs +2 -2
  120. package/dist/astro/routes/api/content/_collection_/index.mjs +10 -9
  121. package/dist/astro/routes/api/content/_collection_/trash.mjs +7 -6
  122. package/dist/astro/routes/api/dashboard.mjs +9 -8
  123. package/dist/astro/routes/api/dev/emails.mjs +2 -2
  124. package/dist/astro/routes/api/health.mjs +1 -1
  125. package/dist/astro/routes/api/import/probe.d.mts +3 -3
  126. package/dist/astro/routes/api/import/probe.mjs +22 -10
  127. package/dist/astro/routes/api/import/wordpress/analyze.mjs +9 -6
  128. package/dist/astro/routes/api/import/wordpress/execute.d.mts +19 -1
  129. package/dist/astro/routes/api/import/wordpress/execute.mjs +84 -37
  130. package/dist/astro/routes/api/import/wordpress/media.d.mts +13 -1
  131. package/dist/astro/routes/api/import/wordpress/media.mjs +19 -13
  132. package/dist/astro/routes/api/import/wordpress/prepare.mjs +35 -32
  133. package/dist/astro/routes/api/import/wordpress/rewrite-urls.d.mts +18 -1
  134. package/dist/astro/routes/api/import/wordpress/rewrite-urls.mjs +120 -100
  135. package/dist/astro/routes/api/import/wordpress-plugin/analyze.d.mts +1 -1
  136. package/dist/astro/routes/api/import/wordpress-plugin/analyze.mjs +24 -12
  137. package/dist/astro/routes/api/import/wordpress-plugin/execute.d.mts +56 -2
  138. package/dist/astro/routes/api/import/wordpress-plugin/execute.mjs +283 -55
  139. package/dist/astro/routes/api/manifest.mjs +14 -5
  140. package/dist/astro/routes/api/mcp.mjs +265 -69
  141. package/dist/astro/routes/api/media/_id_/confirm.mjs +38 -10
  142. package/dist/astro/routes/api/media/_id_.mjs +11 -7
  143. package/dist/astro/routes/api/media/file/_...key_.mjs +1 -1
  144. package/dist/astro/routes/api/media/providers/_providerId_/_itemId_.mjs +2 -2
  145. package/dist/astro/routes/api/media/providers/_providerId_/index.mjs +2 -2
  146. package/dist/astro/routes/api/media/providers/index.mjs +2 -2
  147. package/dist/astro/routes/api/media/upload-url.mjs +11 -10
  148. package/dist/astro/routes/api/media.mjs +27 -34
  149. package/dist/astro/routes/api/menus/_name_/items/_id_.mjs +31 -28
  150. package/dist/astro/routes/api/menus/_name_/items.mjs +31 -28
  151. package/dist/astro/routes/api/menus/_name_/reorder.mjs +31 -28
  152. package/dist/astro/routes/api/menus/_name_/translations.mjs +31 -28
  153. package/dist/astro/routes/api/menus/_name_.mjs +31 -28
  154. package/dist/astro/routes/api/menus/index.mjs +31 -28
  155. package/dist/astro/routes/api/oauth/authorize.mjs +7 -7
  156. package/dist/astro/routes/api/oauth/device/authorize.mjs +6 -6
  157. package/dist/astro/routes/api/oauth/device/code.mjs +9 -9
  158. package/dist/astro/routes/api/oauth/device/token.mjs +8 -8
  159. package/dist/astro/routes/api/oauth/register.mjs +4 -4
  160. package/dist/astro/routes/api/oauth/token/refresh.mjs +6 -6
  161. package/dist/astro/routes/api/oauth/token/revoke.mjs +6 -6
  162. package/dist/astro/routes/api/oauth/token.mjs +6 -6
  163. package/dist/astro/routes/api/openapi.json.mjs +4 -3
  164. package/dist/astro/routes/api/plugins/_pluginId_/_...path_.mjs +30 -30
  165. package/dist/astro/routes/api/redirects/404s/index.mjs +11 -10
  166. package/dist/astro/routes/api/redirects/404s/summary.mjs +11 -10
  167. package/dist/astro/routes/api/redirects/_id_.mjs +32 -29
  168. package/dist/astro/routes/api/redirects/index.mjs +32 -29
  169. package/dist/astro/routes/api/revisions/_revisionId_/index.mjs +2 -2
  170. package/dist/astro/routes/api/revisions/_revisionId_/restore.mjs +2 -2
  171. package/dist/astro/routes/api/schema/collections/_slug_/fields/_fieldSlug_.mjs +47 -43
  172. package/dist/astro/routes/api/schema/collections/_slug_/fields/index.mjs +47 -43
  173. package/dist/astro/routes/api/schema/collections/_slug_/fields/reorder.mjs +47 -43
  174. package/dist/astro/routes/api/schema/collections/_slug_/index.mjs +47 -43
  175. package/dist/astro/routes/api/schema/collections/index.mjs +47 -43
  176. package/dist/astro/routes/api/schema/index.mjs +13 -14
  177. package/dist/astro/routes/api/schema/orphans/_slug_.mjs +46 -42
  178. package/dist/astro/routes/api/schema/orphans/index.mjs +46 -42
  179. package/dist/astro/routes/api/search/enable.mjs +11 -10
  180. package/dist/astro/routes/api/search/index.mjs +10 -9
  181. package/dist/astro/routes/api/search/rebuild.mjs +11 -10
  182. package/dist/astro/routes/api/search/stats.mjs +6 -6
  183. package/dist/astro/routes/api/search/suggest.mjs +10 -9
  184. package/dist/astro/routes/api/sections/_slug_.mjs +31 -28
  185. package/dist/astro/routes/api/sections/index.mjs +31 -28
  186. package/dist/astro/routes/api/settings/email.mjs +4 -4
  187. package/dist/astro/routes/api/settings.mjs +31 -28
  188. package/dist/astro/routes/api/setup/admin-verify.mjs +14 -13
  189. package/dist/astro/routes/api/setup/admin.mjs +12 -11
  190. package/dist/astro/routes/api/setup/dev-bypass.mjs +31 -25
  191. package/dist/astro/routes/api/setup/dev-reset.mjs +2 -2
  192. package/dist/astro/routes/api/setup/index.mjs +29 -25
  193. package/dist/astro/routes/api/setup/status.mjs +3 -3
  194. package/dist/astro/routes/api/snapshot.mjs +8 -7
  195. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_/translations.mjs +34 -31
  196. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_.mjs +34 -31
  197. package/dist/astro/routes/api/taxonomies/_name_/terms/index.mjs +34 -31
  198. package/dist/astro/routes/api/taxonomies/index.mjs +34 -31
  199. package/dist/astro/routes/api/themes/preview.mjs +5 -5
  200. package/dist/astro/routes/api/typegen.mjs +4 -4
  201. package/dist/astro/routes/api/well-known/auth.mjs +3 -3
  202. package/dist/astro/routes/api/well-known/oauth-authorization-server.mjs +3 -3
  203. package/dist/astro/routes/api/well-known/oauth-protected-resource.mjs +3 -3
  204. package/dist/astro/routes/api/widget-areas/_name_/reorder.mjs +30 -27
  205. package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.mjs +31 -28
  206. package/dist/astro/routes/api/widget-areas/_name_/widgets.mjs +31 -28
  207. package/dist/astro/routes/api/widget-areas/_name_.mjs +28 -26
  208. package/dist/astro/routes/api/widget-areas/index.mjs +31 -28
  209. package/dist/astro/routes/api/widget-components.mjs +2 -2
  210. package/dist/astro/routes/robots.txt.mjs +8 -7
  211. package/dist/astro/routes/sitemap-_collection_.xml.mjs +23 -14
  212. package/dist/astro/routes/sitemap.xml.mjs +9 -8
  213. package/dist/astro/session-driver.d.mts +1 -1
  214. package/dist/astro/session-driver.mjs +2 -2
  215. package/dist/astro/types.d.mts +21 -13
  216. package/dist/{audit-BeNsSyfU.mjs → audit-ByVKIwWF.mjs} +1 -1
  217. package/dist/auth/providers/github.d.mts +1 -1
  218. package/dist/auth/providers/google.d.mts +1 -1
  219. package/dist/{auth-control-guard-Dr14I98m.mjs → auth-control-guard-CqeUmQsv.mjs} +1 -1
  220. package/dist/{authorize-BLO0m7fW.mjs → authorize-CcBxcHtz.mjs} +1 -1
  221. package/dist/{briefing-DJX6irto.mjs → briefing-BJaJI8dm.mjs} +2 -1
  222. package/dist/{briefing-CkTee1ex.mjs → briefing-CawZ59CY.mjs} +90 -28
  223. package/dist/bundle-7C_DpkEq.mjs +602 -0
  224. package/dist/{byline-BVC1lV6G.mjs → byline-e51-fWRs.mjs} +30 -62
  225. package/dist/{byline-fields-uJlygdzM.d.mts → byline-fields-CUvbslGc.d.mts} +80 -37
  226. package/dist/{byline-fields-Cj39WhXC.mjs → byline-fields-D-N5qVIG.mjs} +1 -1
  227. package/dist/{byline-fields-cNrLJVRs.mjs → byline-fields-DOJO16Gm.mjs} +3 -3
  228. package/dist/{byline-registry-4v6tXMNX.mjs → byline-registry-87nNnYl4.mjs} +2 -2
  229. package/dist/{bylines-LN9XISRo.mjs → bylines-CMQNCNFh.mjs} +9 -3
  230. package/dist/{bylines-DwokOFj6.mjs → bylines-y4LO-dTj.mjs} +5 -5
  231. package/dist/{cache-Bac05gBd.mjs → cache-C-FNTFYK.mjs} +2 -2
  232. package/dist/{chunks-CuUt7K50.mjs → chunks-CxBt-GxR.mjs} +1 -1
  233. package/dist/cli/index.mjs +94 -659
  234. package/dist/client/external-auth-headers.d.mts +1 -1
  235. package/dist/client/index.d.mts +1 -1
  236. package/dist/client/index.mjs +2 -1
  237. package/dist/{comment-Beue8-15.mjs → comment-DlA4iChg.mjs} +13 -3
  238. package/dist/comment-reaction-DfFao1ST.mjs +58 -0
  239. package/dist/{comments-DcjFIfqX.mjs → comments-DApFGMsP.mjs} +1 -1
  240. package/dist/{content-CBxYGWfL.mjs → content-Bh4BDjv8.mjs} +51 -34
  241. package/dist/content-refresh-CgutSUfO.mjs +1576 -0
  242. package/dist/{context-CQVNZaR8.mjs → context-C5W3G18y.mjs} +111 -50
  243. package/dist/{context-Df1xVYyr.mjs → context-CK4ym2Sf.mjs} +2 -2
  244. package/dist/{context-route-helpers-B9wj8Rmh.mjs → context-route-helpers-MASyGgWf.mjs} +2 -1
  245. package/dist/{cron-DxCAU_Sn.mjs → cron-cKcNTix_.mjs} +7 -3
  246. package/dist/{dashboard-B7ZUNuyF.mjs → dashboard-DQkVT7Ei.mjs} +4 -4
  247. package/dist/db/index.d.mts +3 -3
  248. package/dist/db/index.mjs +1 -1
  249. package/dist/db/libsql.d.mts +1 -1
  250. package/dist/db/postgres.d.mts +1 -1
  251. package/dist/db/sqlite.d.mts +1 -1
  252. package/dist/{device-flow-BZVGftqi.mjs → device-flow-BnqRH-T9.mjs} +5 -5
  253. package/dist/{placeholder-d54Qr_7n.mjs → enrich-DIFIFA8O.mjs} +36 -9
  254. package/dist/{error-DCSuUAZW.mjs → error-CytFlgcd.mjs} +5 -0
  255. package/dist/field-defs-cache-DRNdhBJv.mjs +49 -0
  256. package/dist/{fts-manager-B5l_qwrA.mjs → fts-manager-Crzypjqu.mjs} +1 -1
  257. package/dist/hitl-Hw1RmWOq.mjs +677 -0
  258. package/dist/{hitl-requests-7NlzVeUA.mjs → hitl-requests-B4Vbcmaq.mjs} +2 -2
  259. package/dist/{hitl-route-helpers-k---_H3-.mjs → hitl-route-helpers-hEVzvP8l.mjs} +5 -4
  260. package/dist/import-Bh9biJfx.mjs +1354 -0
  261. package/dist/{index-CZiWCQDp.d.mts → index-D4y6NGiy.d.mts} +75 -3
  262. package/dist/index.d.mts +17 -16
  263. package/dist/index.mjs +80 -68
  264. package/dist/{jsonld-DZ67souc.d.mts → jsonld-Dq0gsnOH.d.mts} +8 -4
  265. package/dist/{load-D9OiGr2m.mjs → load-DmYeniXl.mjs} +1 -1
  266. package/dist/{loader--GOYux8M.mjs → loader-CjWqjweO.mjs} +117 -31
  267. package/dist/{manifest-schema-qh2P7RDX.mjs → manifest-schema-BxVPYMJR.mjs} +34 -1
  268. package/dist/mcp-reviewed-executor-TwVbMzG6.mjs +555 -0
  269. package/dist/media/image-endpoint.d.mts +32 -0
  270. package/dist/media/image-endpoint.mjs +111 -0
  271. package/dist/media/index.d.mts +27 -2
  272. package/dist/media/index.mjs +5 -3
  273. package/dist/media/local-runtime.d.mts +16 -11
  274. package/dist/media/local-runtime.mjs +9 -7
  275. package/dist/{media-CbKyYukG.mjs → media-DMj0grzC.mjs} +3 -1
  276. package/dist/{media-allowlist-BYxJIcTO.mjs → media-allowlist-BlVCSzHx.mjs} +1 -1
  277. package/dist/media-url-lEKSrpr9.mjs +20 -0
  278. package/dist/{menus-BZbXf-ej.mjs → menus-TaW1gKnk.mjs} +19 -5
  279. package/dist/{menus-C7F0sCrC.mjs → menus-xvsnVZXw.mjs} +80 -15
  280. package/dist/{normalize-ByemhhfW.mjs → normalize-5ek_z7de.mjs} +8 -1
  281. package/dist/{oauth-authorization-DF-LCsIA.mjs → oauth-authorization-DiaGvRVz.mjs} +5 -5
  282. package/dist/{oauth-clients-Du-V0fEm.mjs → oauth-clients-Dl9E8dEM.mjs} +2 -2
  283. package/dist/object-cache/memory.d.mts +14 -0
  284. package/dist/object-cache/memory.mjs +55 -0
  285. package/dist/object-cache-D51qOseS.mjs +419 -0
  286. package/dist/page/index.d.mts +4 -3
  287. package/dist/page/index.mjs +2 -2
  288. package/dist/{parse-CneSgl7-.mjs → parse-CbymENaR.mjs} +1 -1
  289. package/dist/{parser-DxfsARXL.mjs → parser-C1nYd-81.mjs} +151 -9
  290. package/dist/{placeholder-CXfoCtCd.d.mts → placeholder-uvNRZBX9.d.mts} +12 -4
  291. package/dist/plugin-utils.d.mts +9 -9
  292. package/dist/plugins/adapt-sandbox-entry.d.mts +9 -9
  293. package/dist/plugins/adapt-sandbox-entry.mjs +11 -2
  294. package/dist/{plugins-DzfqRREq.mjs → plugins-BolVa-tl.mjs} +831 -63
  295. package/dist/{transport-LSdZVXHF.mjs → portable-text-dA_UlJwW.mjs} +1 -134
  296. package/dist/{preview-C-3YTX2U.mjs → preview-vSVg6fwG.mjs} +4 -3
  297. package/dist/process-cache-7xgAO9JY.mjs +106 -0
  298. package/dist/{provider-loader-9it4vd6L.d.mts → provider-loader-MD8zAbnH.d.mts} +1 -1
  299. package/dist/{public-url-B4xV4rGa.d.mts → public-url-gsp3oUbu.d.mts} +1 -1
  300. package/dist/{query-Ds0EnMFX.mjs → query-CfRCdaL3.mjs} +281 -76
  301. package/dist/{query-CZ3TH_Uu.mjs → query-jaAmw8E1.mjs} +11 -6
  302. package/dist/{rate-limit-i0G3IAOX.mjs → rate-limit-ZLdyWoZF.mjs} +2 -2
  303. package/dist/{redirect-CEACczxo.mjs → redirect-BAjt4Z6b.mjs} +2 -2
  304. package/dist/{redirects-DYj1yPxs.mjs → redirects-BTdwpQtE.mjs} +47 -24
  305. package/dist/{redirects-ocRJmQHP.mjs → redirects-CA-xylPG.mjs} +19 -11
  306. package/dist/{registry-D7HACema.mjs → registry-CtyVedcN.mjs} +130 -77
  307. package/dist/request-context.d.mts +2 -0
  308. package/dist/{request-meta-DAb6xaP9.mjs → request-meta-CUypToDJ.mjs} +1 -1
  309. package/dist/{review-requests-Qum4713s.mjs → review-requests-C9Ff11Vq.mjs} +1 -1
  310. package/dist/{review-requests-BW2NxY-l.mjs → review-requests-DUyEmtmG.mjs} +1 -1
  311. package/dist/{runner-09sTqtv0.d.mts → runner-1tC2tIRV.d.mts} +1 -1
  312. package/dist/runner-DB7CRfOF.mjs +6740 -0
  313. package/dist/{runtime-C4-2lSFg.d.mts → runtime-BOeiQsCv.d.mts} +1952 -1489
  314. package/dist/runtime.d.mts +10 -10
  315. package/dist/runtime.mjs +3 -3
  316. package/dist/schema-DXdYj4R3.mjs +8 -0
  317. package/dist/{search-Gdrqj582.mjs → search-DSaLgEFI.mjs} +5 -3
  318. package/dist/{secrets-CeGpBFV2.mjs → secrets-CDZo2k8L.mjs} +14 -11
  319. package/dist/{sections-BOjU13Y-.mjs → sections-PVVXHGfp.mjs} +2 -2
  320. package/dist/seed/index.d.mts +2 -2
  321. package/dist/seed/index.mjs +21 -18
  322. package/dist/seo/index.d.mts +1 -1
  323. package/dist/seo/index.mjs +3 -12
  324. package/dist/{seo-CLj8lS7Q.mjs → seo-CQG3GCHQ.mjs} +5 -2
  325. package/dist/{seo-contributions-CqVvReEj.mjs → seo-contributions-C1EnikHB.mjs} +11 -3
  326. package/dist/{seo-5lJOtB5J.mjs → seo-qa7Dn0jK.mjs} +22 -4
  327. package/dist/{service-jGlhrICs.mjs → service-DiN4ZuPp.mjs} +2 -2
  328. package/dist/session-user-CAKImna3.mjs +22 -0
  329. package/dist/{settings-CUXOxzsT.mjs → settings-BbqgHWpU.mjs} +28 -55
  330. package/dist/{settings-DlBsT2VS.mjs → settings-i4VPP8bT.mjs} +2 -2
  331. package/dist/{setup-complete-BRrdPYjZ.mjs → setup-complete-B8fl-mjV.mjs} +1 -1
  332. package/dist/{site-activity-DONFrMBJ.mjs → site-activity-Dy3FROs0.mjs} +1 -1
  333. package/dist/{site-context-C8Az_P_I.mjs → site-context-DQiL8Fl5.mjs} +23 -652
  334. package/dist/{site-url-DIMD68go.mjs → site-url-BML3GQYm.mjs} +1 -1
  335. package/dist/status-DANd8ERo.mjs +21 -0
  336. package/dist/storage/local.d.mts +1 -1
  337. package/dist/storage/local.mjs +1 -1
  338. package/dist/storage/s3.d.mts +1 -1
  339. package/dist/storage/s3.mjs +1 -1
  340. package/dist/{taxonomies-D9Sw4wWM.mjs → taxonomies-9s-v03H-.mjs} +36 -29
  341. package/dist/taxonomies-DRiixp_E.mjs +443 -0
  342. package/dist/{taxonomy-B169Nm6B.mjs → taxonomy-Dvsw6BOs.mjs} +44 -9
  343. package/dist/transport-BNmCqLu7.mjs +134 -0
  344. package/dist/types-4garmdWa.mjs +66 -0
  345. package/dist/{types-DSPGWjxO.d.mts → types-C8XW6L19.d.mts} +225 -4
  346. package/dist/{types-GaCtZ1k9.d.mts → types-CDpH6MA4.d.mts} +18 -0
  347. package/dist/{types-DRIKLmJI.d.mts → types-C_ly5eTp.d.mts} +17 -2
  348. package/dist/types-DF7ZuGGk.d.mts +118 -0
  349. package/dist/types-DU0bU2Wu.d.mts +2392 -0
  350. package/dist/{types-CwawBUTa.d.mts → types-DW_-sFyz.d.mts} +2 -1
  351. package/dist/{types-CSgR9nQB.mjs → types-Dq1qT19x.mjs} +1 -1
  352. package/dist/ui/server-runtime.d.mts +15 -15
  353. package/dist/ui/server-runtime.mjs +24 -20
  354. package/dist/url-Cac7a9QZ.mjs +33 -0
  355. package/dist/{user-DTLoZs16.mjs → user-BIZPzCb9.mjs} +2 -2
  356. package/dist/{utils-B8hBJ9Oz.mjs → utils-CMDhr5Xd.mjs} +129 -7
  357. package/dist/{validate-DzjCdy6v.d.mts → validate-CZvb-BKB.d.mts} +10 -7
  358. package/dist/{validate-DWmPO6oj.mjs → validate-DNs0pTSc.mjs} +11 -6
  359. package/dist/version-BTvfRGc6.mjs +6 -0
  360. package/dist/{widgets-BpJ8EpPd.mjs → widgets-f0ibZUIq.mjs} +46 -43
  361. package/dist/{wordpress-slugs-DHNR9LpG.mjs → wordpress-slugs-BhHJX8XE.mjs} +1 -1
  362. package/dist/{zod-generator-K91-g665.mjs → zod-generator-B7TMjyFJ.mjs} +41 -13
  363. package/package.json +30 -8
  364. package/src/components/Block.astro +50 -0
  365. package/src/components/Comments.astro +143 -1
  366. package/src/components/DinewayHead.astro +19 -2
  367. package/src/components/DinewayImage.astro +66 -33
  368. package/src/components/DinewayMedia.astro +1 -2
  369. package/src/components/Image.astro +85 -40
  370. package/src/components/InlinePortableTextEditor.tsx +12 -2
  371. package/src/components/JsonLdScript.astro +9 -0
  372. package/src/components/LiveSearch.astro +40 -4
  373. package/src/components/index.ts +4 -0
  374. package/src/components/live-search-routing.ts +30 -0
  375. package/src/components/portable-text-text-align.ts +15 -0
  376. package/src/ui.ts +2 -0
  377. package/dist/entity-aliases-4y93Yjuc.mjs +0 -51
  378. package/dist/import-4YBXbDkI.mjs +0 -684
  379. package/dist/runner-DzIpHGND.mjs +0 -2836
  380. package/dist/schema-Bsi-VpYv.mjs +0 -8
  381. package/dist/taxonomies-CZ-_DitR.mjs +0 -327
  382. package/dist/types-CuJOqHfM.d.mts +0 -758
  383. package/dist/version-C4gfn0PJ.mjs +0 -6
  384. /package/dist/{adapters-OQCImOL7.d.mts → adapters-NVSs4UH7.d.mts} +0 -0
  385. /package/dist/{api-tokens-CYUoFGo7.mjs → api-tokens-2r7OWi_I.mjs} +0 -0
  386. /package/dist/{challenge-store-DFxX0_15.mjs → challenge-store-Bjlepa2E.mjs} +0 -0
  387. /package/dist/{components--pg6zBvu.mjs → components-Bclf98Be.mjs} +0 -0
  388. /package/dist/{context-types-r8oFvyOq.mjs → context-types-DqTo6C79.mjs} +0 -0
  389. /package/dist/{default-B6iaLvP7.mjs → default--K40jqm0.mjs} +0 -0
  390. /package/dist/{email-console-BOVqIYpB.mjs → email-console-ChgKFO8-.mjs} +0 -0
  391. /package/dist/{escape-BDgouFFY.mjs → escape-Bd4P_xKg.mjs} +0 -0
  392. /package/dist/{experimental-workflows-CSMffP6q.mjs → experimental-workflows-BMsUnIAw.mjs} +0 -0
  393. /package/dist/{mime-CbKsKDCB.mjs → mime-CA7Lgovc.mjs} +0 -0
  394. /package/dist/{mode-CZqCF9dZ.mjs → mode-C4CIyjtR.mjs} +0 -0
  395. /package/dist/{oauth-state-store-qncPB_IU.mjs → oauth-state-store-CNoXafF7.mjs} +0 -0
  396. /package/dist/{oauth-user-lookup-BFjWF8wK.mjs → oauth-user-lookup-Ygw4bNyt.mjs} +0 -0
  397. /package/dist/{options-LsPjZlqD.mjs → options-DQPTH5n0.mjs} +0 -0
  398. /package/dist/{passkey-config-DzHQK90v.mjs → passkey-config-BUwu8BA3.mjs} +0 -0
  399. /package/dist/{patterns-DKAX6oqN.mjs → patterns-BhAvqO0S.mjs} +0 -0
  400. /package/dist/{provider-loader-DzUxejk7.mjs → provider-loader-D0w9dqjm.mjs} +0 -0
  401. /package/dist/{public-url-B_m9IwdV.mjs → public-url-BEz_sM9n.mjs} +0 -0
  402. /package/dist/{redirect-BjIBtDWY.mjs → redirect-wphRBv4y.mjs} +0 -0
  403. /package/dist/{request-cache-ho99schz.mjs → request-cache-D9GQBxMP.mjs} +0 -0
  404. /package/dist/{resolve-DTuDyYKs.mjs → resolve-Cb6Dbz-C.mjs} +0 -0
  405. /package/dist/{setup-nonce-pyGfc9hV.mjs → setup-nonce-CoyjILvW.mjs} +0 -0
  406. /package/dist/{sidecar-client-mJxwayYN.mjs → sidecar-client-C3mqXg4C.mjs} +0 -0
  407. /package/dist/{slugify-BqebcqBg.mjs → slugify-KSsVD_D3.mjs} +0 -0
  408. /package/dist/{ssrf-DiKqWd3N.mjs → ssrf-DWe8jwAp.mjs} +0 -0
  409. /package/dist/{tokens-SLmgowfd.mjs → tokens-1RK1n6ED.mjs} +0 -0
  410. /package/dist/{transaction-CFLhEOuH.mjs → transaction-C2EOMTJA.mjs} +0 -0
  411. /package/dist/{transport-BnsNxh2l.d.mts → transport-CcJu3Co8.d.mts} +0 -0
  412. /package/dist/{trusted-proxy-BgIIcbsN.mjs → trusted-proxy-DTXQ2IMv.mjs} +0 -0
  413. /package/dist/{types-CJ8DkL0q.mjs → types-B3t5cxhU.mjs} +0 -0
  414. /package/dist/{types-nP9vGUFq.d.mts → types-C46EvNdc.d.mts} +0 -0
  415. /package/dist/{types-Cg276-3z.mjs → types-C5CVgwsV.mjs} +0 -0
  416. /package/dist/{types-DZpT-PnG.d.mts → types-POH8PQZh.d.mts} +0 -0
  417. /package/dist/{types-Dryvv7LH.d.mts → types-Rc3gQqqw.d.mts} +0 -0
  418. /package/dist/{url-w7Mp5qAD.mjs → url-CpyFDFpO.mjs} +0 -0
@@ -0,0 +1,677 @@
1
+ import { i as encodeCursor, r as decodeCursor } from "./types-Dq1qT19x.mjs";
2
+ import { i as parseSiteBriefingScope } from "./briefing-CawZ59CY.mjs";
3
+ import { ulid } from "ulidx";
4
+ import { Role } from "@dineway-ai/auth";
5
+
6
+ //#region src/database/repositories/entity-aliases.ts
7
+ const WHITESPACE_PATTERN = /\s+/g;
8
+ function isResolvableEntityType(value) {
9
+ return value === "content" || value === "collection" || value === "plugin" || value === "taxonomy" || value === "menu";
10
+ }
11
+ function mapEntityAlias(row) {
12
+ if (!isResolvableEntityType(row.entity_type)) throw new Error(`Invalid entity alias type: ${row.entity_type}`);
13
+ return {
14
+ id: row.id,
15
+ entityType: row.entity_type,
16
+ collectionSlug: row.collection_slug,
17
+ entityId: row.entity_id,
18
+ alias: row.alias,
19
+ normalizedAlias: row.normalized_alias,
20
+ createdAt: row.created_at
21
+ };
22
+ }
23
+ function normalizeEntityAlias(value) {
24
+ return value.trim().toLowerCase().replace(WHITESPACE_PATTERN, " ");
25
+ }
26
+ var EntityAliasRepository = class {
27
+ constructor(db) {
28
+ this.db = db;
29
+ }
30
+ async create(input) {
31
+ const id = ulid();
32
+ const normalizedAlias = normalizeEntityAlias(input.alias);
33
+ await this.db.insertInto("_dineway_entity_aliases").values({
34
+ id,
35
+ entity_type: input.entityType,
36
+ collection_slug: input.collectionSlug ?? null,
37
+ entity_id: input.entityId,
38
+ alias: input.alias,
39
+ normalized_alias: normalizedAlias
40
+ }).execute();
41
+ return mapEntityAlias(await this.db.selectFrom("_dineway_entity_aliases").selectAll().where("id", "=", id).executeTakeFirstOrThrow());
42
+ }
43
+ async findByNormalizedAlias(input) {
44
+ const limit = Math.min(Math.max(input.limit ?? 10, 1), 50);
45
+ const collectionSlug = input.collectionSlug;
46
+ let query = this.db.selectFrom("_dineway_entity_aliases").selectAll().where("normalized_alias", "=", input.normalizedAlias);
47
+ if (input.entityTypes && input.entityTypes.length > 0) query = query.where("entity_type", "in", input.entityTypes);
48
+ if (collectionSlug) query = query.where((eb) => eb.or([eb("collection_slug", "is", null), eb("collection_slug", "=", collectionSlug)]));
49
+ return (await query.orderBy("created_at", "desc").limit(limit).execute()).map(mapEntityAlias);
50
+ }
51
+ };
52
+
53
+ //#endregion
54
+ //#region src/database/repositories/hitl-requests.ts
55
+ const HITL_REQUEST_STATUSES = [
56
+ "pending",
57
+ "approved",
58
+ "rejected"
59
+ ];
60
+ const HITL_REQUEST_PRIORITIES = [
61
+ "low",
62
+ "normal",
63
+ "high",
64
+ "urgent"
65
+ ];
66
+ var HitlRequestRepository = class {
67
+ constructor(db) {
68
+ this.db = db;
69
+ }
70
+ async create(input) {
71
+ const id = ulid();
72
+ const now = input.createdAt ?? (/* @__PURE__ */ new Date()).toISOString();
73
+ await this.db.insertInto("_dineway_hitl_requests").values(toInsertableHitlRequest(id, input, now)).execute();
74
+ const request = await this.findById(id);
75
+ if (!request) throw new Error("Failed to create HITL request");
76
+ return request;
77
+ }
78
+ async findById(id) {
79
+ const row = await this.db.selectFrom("_dineway_hitl_requests").selectAll().where("id", "=", id).executeTakeFirst();
80
+ return row ? rowToHitlRequest(row) : null;
81
+ }
82
+ async list(query = {}) {
83
+ const limit = clampLimit$1(query.limit);
84
+ const rows = await this.queryRows(query).execute();
85
+ const items = rows.slice(0, limit).map(rowToHitlRequest);
86
+ const result = { items };
87
+ if (rows.length > limit && items.length > 0) {
88
+ const last = items.at(-1);
89
+ result.nextCursor = encodeCursor(last.createdAt, last.id);
90
+ }
91
+ return result;
92
+ }
93
+ async resolve(id, input) {
94
+ const resolvedAt = input.resolvedAt ?? (/* @__PURE__ */ new Date()).toISOString();
95
+ const result = await this.db.updateTable("_dineway_hitl_requests").set({
96
+ status: input.decision,
97
+ resolved_by_actor_type: input.resolvedByActorType,
98
+ resolved_by_actor_id: input.resolvedByActorId,
99
+ resolved_auth_metadata: jsonStringOrNull(input.resolvedAuthMetadata),
100
+ review_note: input.reviewNote ?? null,
101
+ resolved_at: resolvedAt,
102
+ updated_at: resolvedAt
103
+ }).where("id", "=", id).where("status", "=", "pending").executeTakeFirst();
104
+ if (Number(result.numUpdatedRows ?? 0) === 0) return null;
105
+ return this.findById(id);
106
+ }
107
+ queryRows(query) {
108
+ const limit = clampLimit$1(query.limit);
109
+ let q = this.db.selectFrom("_dineway_hitl_requests").selectAll().orderBy("created_at", "desc").orderBy("id", "desc").limit(limit + 1);
110
+ if (query.scope) q = q.where("scope", "=", query.scope);
111
+ if (query.scopes && query.scopes.length > 0) q = q.where("scope", "in", query.scopes);
112
+ if (query.statuses && query.statuses.length > 0) q = q.where("status", "in", query.statuses);
113
+ if (query.priority) q = q.where("priority", "=", query.priority);
114
+ if (query.actionType) q = q.where("action_type", "=", query.actionType);
115
+ if (query.targetRefType) q = q.where("target_ref_type", "=", query.targetRefType);
116
+ if (query.targetRefId) q = q.where("target_ref_id", "=", query.targetRefId);
117
+ if (query.relatedAssignmentId) q = q.where("related_assignment_id", "=", query.relatedAssignmentId);
118
+ if (query.requestedByActorType && query.requestedByActorId) q = q.where("requested_by_actor_type", "=", query.requestedByActorType).where("requested_by_actor_id", "=", query.requestedByActorId);
119
+ if (query.participantActor) q = q.where("requested_by_actor_type", "=", query.participantActor.actorType).where("requested_by_actor_id", "=", query.participantActor.actorId);
120
+ if (query.since) q = q.where("updated_at", ">=", query.since);
121
+ if (query.cursor) {
122
+ const decoded = decodeCursor(query.cursor);
123
+ if (decoded) q = q.where((eb) => eb.or([eb("created_at", "<", decoded.orderValue), eb.and([eb("created_at", "=", decoded.orderValue), eb("id", "<", decoded.id)])]));
124
+ }
125
+ return q;
126
+ }
127
+ };
128
+ function toInsertableHitlRequest(id, input, now) {
129
+ return {
130
+ id,
131
+ scope: input.scope,
132
+ action_type: input.actionType,
133
+ status: "pending",
134
+ priority: input.priority ?? "normal",
135
+ title: input.title,
136
+ summary: input.summary ?? null,
137
+ risk_reason: input.riskReason,
138
+ review_payload: JSON.stringify(input.reviewPayload),
139
+ target_ref_type: input.targetRefType,
140
+ target_ref_id: input.targetRefId,
141
+ requested_by_actor_type: input.requestedByActorType,
142
+ requested_by_actor_id: input.requestedByActorId,
143
+ requested_auth_metadata: jsonStringOrNull(input.requestedAuthMetadata),
144
+ resolved_by_actor_type: null,
145
+ resolved_by_actor_id: null,
146
+ resolved_auth_metadata: null,
147
+ review_note: null,
148
+ metadata: jsonString$1(input.metadata),
149
+ related_assignment_id: input.relatedAssignmentId ?? null,
150
+ related_handoff_snapshot_id: input.relatedHandoffSnapshotId ?? null,
151
+ sla_due_at: input.slaDueAt ?? null,
152
+ created_at: now,
153
+ updated_at: now,
154
+ resolved_at: null
155
+ };
156
+ }
157
+ function rowToHitlRequest(row) {
158
+ return {
159
+ id: row.id,
160
+ scope: row.scope,
161
+ actionType: row.action_type,
162
+ status: row.status,
163
+ priority: row.priority,
164
+ title: row.title,
165
+ summary: row.summary,
166
+ riskReason: row.risk_reason,
167
+ reviewPayload: parseRecord$2(row.review_payload),
168
+ targetRefType: row.target_ref_type,
169
+ targetRefId: row.target_ref_id,
170
+ requestedByActorType: row.requested_by_actor_type,
171
+ requestedByActorId: row.requested_by_actor_id,
172
+ requestedAuthMetadata: parseNullableRecord(row.requested_auth_metadata),
173
+ resolvedByActorType: row.resolved_by_actor_type,
174
+ resolvedByActorId: row.resolved_by_actor_id,
175
+ resolvedAuthMetadata: parseNullableRecord(row.resolved_auth_metadata),
176
+ reviewNote: row.review_note,
177
+ metadata: parseRecord$2(row.metadata),
178
+ relatedAssignmentId: row.related_assignment_id,
179
+ relatedHandoffSnapshotId: row.related_handoff_snapshot_id,
180
+ slaDueAt: row.sla_due_at,
181
+ createdAt: row.created_at,
182
+ updatedAt: row.updated_at,
183
+ resolvedAt: row.resolved_at
184
+ };
185
+ }
186
+ function jsonString$1(value) {
187
+ return JSON.stringify(value ?? {});
188
+ }
189
+ function jsonStringOrNull(value) {
190
+ return value ? JSON.stringify(value) : null;
191
+ }
192
+ function parseRecord$2(value) {
193
+ if (!value) return {};
194
+ try {
195
+ const parsed = JSON.parse(value);
196
+ return isRecord$3(parsed) ? parsed : {};
197
+ } catch {
198
+ return {};
199
+ }
200
+ }
201
+ function parseNullableRecord(value) {
202
+ if (!value) return null;
203
+ return parseRecord$2(value);
204
+ }
205
+ function isRecord$3(value) {
206
+ return typeof value === "object" && value !== null && !Array.isArray(value);
207
+ }
208
+ function clampLimit$1(limit) {
209
+ if (!limit || limit < 1) return 50;
210
+ return Math.min(limit, 100);
211
+ }
212
+
213
+ //#endregion
214
+ //#region src/site-context/action-hash.ts
215
+ async function buildStableActionHash(value) {
216
+ return sha256Hex(stableStringify(value));
217
+ }
218
+ function stableStringify(value) {
219
+ if (Array.isArray(value)) return `[${value.map((item) => stableStringify(item)).join(",")}]`;
220
+ if (isRecord$2(value)) return `{${Object.entries(value).filter(([, entryValue]) => entryValue !== void 0).toSorted(([left], [right]) => left.localeCompare(right)).map(([key, entryValue]) => `${JSON.stringify(key)}:${stableStringify(entryValue)}`).join(",")}}`;
221
+ return JSON.stringify(value ?? null);
222
+ }
223
+ function isRecord$2(value) {
224
+ return typeof value === "object" && value !== null && !Array.isArray(value);
225
+ }
226
+ async function sha256Hex(value) {
227
+ const buffer = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(value));
228
+ return Array.from(new Uint8Array(buffer), (byte) => byte.toString(16).padStart(2, "0")).join("");
229
+ }
230
+
231
+ //#endregion
232
+ //#region src/database/repositories/assignments.ts
233
+ const ASSIGNMENT_ACTOR_TYPES = [
234
+ "user",
235
+ "api_token",
236
+ "system"
237
+ ];
238
+ const ASSIGNMENT_STATUSES = [
239
+ "pending",
240
+ "accepted",
241
+ "in_progress",
242
+ "blocked",
243
+ "completed",
244
+ "declined",
245
+ "cancelled"
246
+ ];
247
+ const ASSIGNMENT_PRIORITIES = [
248
+ "low",
249
+ "normal",
250
+ "high",
251
+ "urgent"
252
+ ];
253
+ var AssignmentRepository = class {
254
+ constructor(db) {
255
+ this.db = db;
256
+ }
257
+ async create(input) {
258
+ const id = ulid();
259
+ const now = input.createdAt ?? (/* @__PURE__ */ new Date()).toISOString();
260
+ await this.db.insertInto("_dineway_assignments").values(toInsertableAssignment(id, input, now)).execute();
261
+ const assignment = await this.findById(id);
262
+ if (!assignment) throw new Error("Failed to create assignment");
263
+ return assignment;
264
+ }
265
+ async findById(id) {
266
+ const row = await this.db.selectFrom("_dineway_assignments").selectAll().where("id", "=", id).executeTakeFirst();
267
+ return row ? rowToAssignment(row) : null;
268
+ }
269
+ async list(query = {}) {
270
+ const limit = clampLimit(query.limit);
271
+ const rows = await this.queryRows(query).execute();
272
+ const items = rows.slice(0, limit).map(rowToAssignment);
273
+ const result = { items };
274
+ if (rows.length > limit && items.length > 0) {
275
+ const last = items.at(-1);
276
+ result.nextCursor = encodeCursor(last.createdAt, last.id);
277
+ }
278
+ return result;
279
+ }
280
+ async accept(id, input = {}) {
281
+ const value = input.acceptedAt ?? (/* @__PURE__ */ new Date()).toISOString();
282
+ return this.transition(id, ["pending"], {
283
+ status: "accepted",
284
+ assigned_to_actor_type: input.assignedToActorType ?? null,
285
+ assigned_to_actor_id: input.assignedToActorId ?? null,
286
+ accepted_at: value,
287
+ updated_at: value,
288
+ metadata: jsonString(input.metadata)
289
+ });
290
+ }
291
+ async start(id, input = {}) {
292
+ const value = input.at ?? (/* @__PURE__ */ new Date()).toISOString();
293
+ return this.transition(id, ["accepted", "blocked"], {
294
+ status: "in_progress",
295
+ started_at: value,
296
+ updated_at: value,
297
+ metadata: jsonString(input.metadata)
298
+ });
299
+ }
300
+ async block(id, input = {}) {
301
+ const value = input.at ?? (/* @__PURE__ */ new Date()).toISOString();
302
+ return this.transition(id, ["accepted", "in_progress"], {
303
+ status: "blocked",
304
+ blocked_at: value,
305
+ updated_at: value,
306
+ metadata: jsonString(input.metadata)
307
+ });
308
+ }
309
+ async complete(id, input = {}) {
310
+ const value = input.at ?? (/* @__PURE__ */ new Date()).toISOString();
311
+ return this.transition(id, [
312
+ "pending",
313
+ "accepted",
314
+ "in_progress"
315
+ ], {
316
+ status: "completed",
317
+ completed_at: value,
318
+ updated_at: value,
319
+ metadata: jsonString(input.metadata)
320
+ });
321
+ }
322
+ async decline(id, input = {}) {
323
+ const value = input.at ?? (/* @__PURE__ */ new Date()).toISOString();
324
+ return this.transition(id, ["pending", "accepted"], {
325
+ status: "declined",
326
+ declined_at: value,
327
+ updated_at: value,
328
+ metadata: jsonString(input.metadata)
329
+ });
330
+ }
331
+ async cancel(id, input = {}) {
332
+ const value = input.at ?? (/* @__PURE__ */ new Date()).toISOString();
333
+ return this.transition(id, [
334
+ "pending",
335
+ "accepted",
336
+ "in_progress",
337
+ "blocked"
338
+ ], {
339
+ status: "cancelled",
340
+ cancelled_at: value,
341
+ updated_at: value,
342
+ metadata: jsonString(input.metadata)
343
+ });
344
+ }
345
+ async linkHitlRequest(id, relatedHitlRequestId, at = (/* @__PURE__ */ new Date()).toISOString()) {
346
+ const result = await this.db.updateTable("_dineway_assignments").set({
347
+ related_hitl_request_id: relatedHitlRequestId,
348
+ updated_at: at
349
+ }).where("id", "=", id).executeTakeFirst();
350
+ if (Number(result.numUpdatedRows ?? 0) === 0) return null;
351
+ return this.findById(id);
352
+ }
353
+ queryRows(query) {
354
+ const limit = clampLimit(query.limit);
355
+ let q = this.db.selectFrom("_dineway_assignments").selectAll().orderBy("created_at", "desc").orderBy("id", "desc").limit(limit + 1);
356
+ if (query.scope) q = q.where("scope", "=", query.scope);
357
+ if (query.scopes && query.scopes.length > 0) q = q.where("scope", "in", query.scopes);
358
+ if (query.statuses && query.statuses.length > 0) q = q.where("status", "in", query.statuses);
359
+ if (query.priority) q = q.where("priority", "=", query.priority);
360
+ if (query.assignmentType) q = q.where("assignment_type", "=", query.assignmentType);
361
+ if (query.assignedToActorType && query.assignedToActorId) q = q.where("assigned_to_actor_type", "=", query.assignedToActorType).where("assigned_to_actor_id", "=", query.assignedToActorId);
362
+ if (query.assignedByActorType && query.assignedByActorId) q = q.where("assigned_by_actor_type", "=", query.assignedByActorType).where("assigned_by_actor_id", "=", query.assignedByActorId);
363
+ if (query.participantActor) q = q.where((eb) => eb.or([eb.and([eb("assigned_by_actor_type", "=", query.participantActor.actorType), eb("assigned_by_actor_id", "=", query.participantActor.actorId)]), eb.and([eb("assigned_to_actor_type", "=", query.participantActor.actorType), eb("assigned_to_actor_id", "=", query.participantActor.actorId)])]));
364
+ if (query.since) q = q.where("updated_at", ">=", query.since);
365
+ if (query.cursor) {
366
+ const decoded = decodeCursor(query.cursor);
367
+ if (decoded) q = q.where((eb) => eb.or([eb("created_at", "<", decoded.orderValue), eb.and([eb("created_at", "=", decoded.orderValue), eb("id", "<", decoded.id)])]));
368
+ }
369
+ return q;
370
+ }
371
+ async transition(id, validFrom, update) {
372
+ const result = await this.db.updateTable("_dineway_assignments").set(update).where("id", "=", id).where("status", "in", validFrom).executeTakeFirst();
373
+ if (Number(result.numUpdatedRows ?? 0) === 0) return null;
374
+ return this.findById(id);
375
+ }
376
+ };
377
+ function toInsertableAssignment(id, input, now) {
378
+ return {
379
+ id,
380
+ scope: input.scope,
381
+ assignment_type: input.assignmentType,
382
+ status: "pending",
383
+ priority: input.priority ?? "normal",
384
+ title: input.title,
385
+ summary: input.summary ?? null,
386
+ details: input.details ?? null,
387
+ assigned_by_actor_type: input.assignedByActorType,
388
+ assigned_by_actor_id: input.assignedByActorId,
389
+ assigned_to_actor_type: input.assignedToActorType ?? null,
390
+ assigned_to_actor_id: input.assignedToActorId ?? null,
391
+ metadata: jsonString(input.metadata),
392
+ related_handoff_snapshot_id: input.relatedHandoffSnapshotId ?? null,
393
+ related_hitl_request_id: input.relatedHitlRequestId ?? null,
394
+ due_at: input.dueAt ?? null,
395
+ created_at: now,
396
+ updated_at: now,
397
+ accepted_at: null,
398
+ started_at: null,
399
+ blocked_at: null,
400
+ completed_at: null,
401
+ declined_at: null,
402
+ cancelled_at: null
403
+ };
404
+ }
405
+ function rowToAssignment(row) {
406
+ return {
407
+ id: row.id,
408
+ scope: row.scope,
409
+ assignmentType: row.assignment_type,
410
+ status: row.status,
411
+ priority: row.priority,
412
+ title: row.title,
413
+ summary: row.summary,
414
+ details: row.details,
415
+ assignedByActorType: row.assigned_by_actor_type,
416
+ assignedByActorId: row.assigned_by_actor_id,
417
+ assignedToActorType: row.assigned_to_actor_type,
418
+ assignedToActorId: row.assigned_to_actor_id,
419
+ metadata: parseRecord$1(row.metadata),
420
+ relatedHandoffSnapshotId: row.related_handoff_snapshot_id,
421
+ relatedHitlRequestId: row.related_hitl_request_id,
422
+ dueAt: row.due_at,
423
+ createdAt: row.created_at,
424
+ updatedAt: row.updated_at,
425
+ acceptedAt: row.accepted_at,
426
+ startedAt: row.started_at,
427
+ blockedAt: row.blocked_at,
428
+ completedAt: row.completed_at,
429
+ declinedAt: row.declined_at,
430
+ cancelledAt: row.cancelled_at
431
+ };
432
+ }
433
+ function jsonString(value) {
434
+ return JSON.stringify(value ?? {});
435
+ }
436
+ function parseRecord$1(value) {
437
+ if (!value) return {};
438
+ try {
439
+ const parsed = JSON.parse(value);
440
+ return isRecord$1(parsed) ? parsed : {};
441
+ } catch {
442
+ return {};
443
+ }
444
+ }
445
+ function isRecord$1(value) {
446
+ return typeof value === "object" && value !== null && !Array.isArray(value);
447
+ }
448
+ function clampLimit(limit) {
449
+ if (!limit || limit < 1) return 50;
450
+ return Math.min(limit, 100);
451
+ }
452
+
453
+ //#endregion
454
+ //#region src/database/repositories/handoff-snapshots.ts
455
+ var HandoffSnapshotRepository = class {
456
+ constructor(db) {
457
+ this.db = db;
458
+ }
459
+ async create(input) {
460
+ const id = ulid();
461
+ await this.db.insertInto("_dineway_handoff_snapshots").values(toInsertableHandoffSnapshot(id, input)).execute();
462
+ return this.findById(id).then((snapshot) => {
463
+ if (!snapshot) throw new Error("Failed to create handoff snapshot");
464
+ return snapshot;
465
+ });
466
+ }
467
+ async findById(id) {
468
+ const row = await this.db.selectFrom("_dineway_handoff_snapshots").selectAll().where("id", "=", id).executeTakeFirst();
469
+ return row ? rowToHandoffSnapshot(row) : null;
470
+ }
471
+ async markResumed(id, resumedAt) {
472
+ const value = resumedAt ?? (/* @__PURE__ */ new Date()).toISOString();
473
+ await this.db.updateTable("_dineway_handoff_snapshots").set({ resumed_at: value }).where("id", "=", id).execute();
474
+ return this.findById(id);
475
+ }
476
+ };
477
+ function toInsertableHandoffSnapshot(id, input) {
478
+ return {
479
+ id,
480
+ scope: input.scope,
481
+ actor_type: input.actorType,
482
+ actor_id: input.actorId,
483
+ auth_metadata: jsonOrNull(input.authMetadata),
484
+ objective: input.objective,
485
+ reasoning: input.reasoning,
486
+ key_findings: JSON.stringify(input.keyFindings ?? []),
487
+ touched_objects: JSON.stringify(input.touchedObjects ?? []),
488
+ pending_actions: JSON.stringify(input.pendingActions ?? []),
489
+ tool_evidence: JSON.stringify(input.toolEvidence ?? []),
490
+ confidence: input.confidence ?? null,
491
+ handoff_kind: input.handoffKind ?? "pause",
492
+ reference_type: input.referenceType ?? null,
493
+ reference_id: input.referenceId ?? null,
494
+ created_at: input.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
495
+ resumed_at: null
496
+ };
497
+ }
498
+ function rowToHandoffSnapshot(row) {
499
+ return {
500
+ id: row.id,
501
+ scope: row.scope,
502
+ actorType: row.actor_type,
503
+ actorId: row.actor_id,
504
+ authMetadata: parseRecord(row.auth_metadata),
505
+ objective: row.objective,
506
+ reasoning: row.reasoning,
507
+ keyFindings: parseArray(row.key_findings),
508
+ touchedObjects: parseArray(row.touched_objects),
509
+ pendingActions: parseArray(row.pending_actions),
510
+ toolEvidence: parseArray(row.tool_evidence),
511
+ confidence: row.confidence,
512
+ handoffKind: row.handoff_kind,
513
+ referenceType: row.reference_type,
514
+ referenceId: row.reference_id,
515
+ createdAt: row.created_at,
516
+ resumedAt: row.resumed_at
517
+ };
518
+ }
519
+ function jsonOrNull(value) {
520
+ return value ? JSON.stringify(value) : null;
521
+ }
522
+ function parseRecord(value) {
523
+ if (!value) return null;
524
+ try {
525
+ const parsed = JSON.parse(value);
526
+ return isRecord(parsed) ? parsed : null;
527
+ } catch {
528
+ return null;
529
+ }
530
+ }
531
+ function parseArray(value) {
532
+ if (!value) return [];
533
+ try {
534
+ const parsed = JSON.parse(value);
535
+ return Array.isArray(parsed) ? parsed.filter((_item) => true) : [];
536
+ } catch {
537
+ return [];
538
+ }
539
+ }
540
+ function isRecord(value) {
541
+ return typeof value === "object" && value !== null && !Array.isArray(value);
542
+ }
543
+
544
+ //#endregion
545
+ //#region src/site-context/hitl.ts
546
+ const HITL_REQUEST_VALID_FROM = { resolve: ["pending"] };
547
+ var HitlRequestService = class {
548
+ repository;
549
+ assignments;
550
+ constructor(db) {
551
+ this.db = db;
552
+ this.repository = new HitlRequestRepository(db);
553
+ this.assignments = new AssignmentRepository(db);
554
+ }
555
+ async create(actor, input) {
556
+ parseSiteBriefingScope(input.scope);
557
+ const assignment = input.relatedAssignmentId ? await this.assignments.findById(input.relatedAssignmentId) : null;
558
+ if (input.relatedAssignmentId && !assignment) throw new Error(`Assignment not found: ${input.relatedAssignmentId}`);
559
+ if (assignment) {
560
+ this.assertRelatedAssignmentReadable(assignment, actor);
561
+ if (assignment.scope !== input.scope) throw new Error("Related assignment scope must match the HITL request scope.");
562
+ if (assignment.relatedHitlRequestId) throw new Error(`Assignment ${assignment.id} is already linked to HITL request ${assignment.relatedHitlRequestId}.`);
563
+ }
564
+ if (input.relatedHandoffSnapshotId) {
565
+ const snapshot = await new HandoffSnapshotRepository(this.db).findById(input.relatedHandoffSnapshotId);
566
+ if (!snapshot) throw new Error(`Handoff snapshot not found: ${input.relatedHandoffSnapshotId}`);
567
+ this.assertRelatedHandoffSnapshotReadable(snapshot, actor);
568
+ if (snapshot.scope !== input.scope) throw new Error("Related handoff snapshot scope must match the HITL request scope.");
569
+ }
570
+ const request = await this.repository.create({
571
+ scope: input.scope,
572
+ actionType: input.actionType,
573
+ title: input.title,
574
+ summary: input.summary,
575
+ riskReason: input.riskReason,
576
+ reviewPayload: input.reviewPayload,
577
+ targetRefType: input.targetRefType,
578
+ targetRefId: input.targetRefId,
579
+ requestedByActorType: actor.actorType,
580
+ requestedByActorId: actor.actorId,
581
+ requestedAuthMetadata: actor.authMetadata,
582
+ priority: input.priority,
583
+ metadata: input.metadata,
584
+ relatedAssignmentId: input.relatedAssignmentId,
585
+ relatedHandoffSnapshotId: input.relatedHandoffSnapshotId,
586
+ slaDueAt: input.slaDueAt,
587
+ createdAt: input.createdAt
588
+ });
589
+ if (assignment) {
590
+ if (!await this.assignments.linkHitlRequest(assignment.id, request.id, request.createdAt)) throw new Error(`Failed to link assignment ${assignment.id} to HITL request ${request.id}.`);
591
+ }
592
+ return request;
593
+ }
594
+ async get(id, actor) {
595
+ const request = await this.repository.findById(id);
596
+ if (!request) return null;
597
+ this.assertReadable(request, actor);
598
+ return request;
599
+ }
600
+ async list(actor, input = {}) {
601
+ return this.repository.list(this.buildListQuery(actor, input));
602
+ }
603
+ async resolve(input) {
604
+ const request = await this.loadExisting(input.id);
605
+ this.assertResolver(input.actor);
606
+ this.assertReadable(request, input.actor);
607
+ this.assertValidAction("resolve", request.status);
608
+ const resolved = await this.repository.resolve(request.id, {
609
+ decision: input.decision,
610
+ resolvedByActorType: input.actor.actorType,
611
+ resolvedByActorId: input.actor.actorId,
612
+ resolvedAuthMetadata: input.actor.authMetadata,
613
+ reviewNote: input.reviewNote,
614
+ resolvedAt: input.at
615
+ });
616
+ if (!resolved) throw new Error(`Failed to resolve HITL request ${request.id}.`);
617
+ return resolved;
618
+ }
619
+ buildListQuery(actor, input) {
620
+ const query = {
621
+ scope: input.scope,
622
+ scopes: input.scopes,
623
+ statuses: input.statuses,
624
+ priority: input.priority,
625
+ actionType: input.actionType,
626
+ targetRefType: input.targetRefType,
627
+ targetRefId: input.targetRefId,
628
+ relatedAssignmentId: input.relatedAssignmentId,
629
+ since: input.since,
630
+ limit: input.limit,
631
+ cursor: input.cursor
632
+ };
633
+ if (isHitlSupervisor(actor.userRole)) return query;
634
+ return {
635
+ ...query,
636
+ requestedByActorType: actor.actorType,
637
+ requestedByActorId: actor.actorId
638
+ };
639
+ }
640
+ async loadExisting(id) {
641
+ const request = await this.repository.findById(id);
642
+ if (!request) throw new Error(`HITL request not found: ${id}`);
643
+ return request;
644
+ }
645
+ assertReadable(request, actor) {
646
+ if (isHitlSupervisor(actor.userRole)) return;
647
+ if (request.requestedByActorType === actor.actorType && request.requestedByActorId === actor.actorId) return;
648
+ throw new Error("Insufficient permissions to read this HITL request.");
649
+ }
650
+ assertResolver(actor) {
651
+ if (isHitlSupervisor(actor.userRole)) return;
652
+ throw new Error("HITL requests may only be resolved by an editor or admin.");
653
+ }
654
+ assertRelatedAssignmentReadable(assignment, actor) {
655
+ if (isHitlSupervisor(actor.userRole)) return;
656
+ if (matchesActor(assignment.assignedByActorType, assignment.assignedByActorId, actor) || matchesActor(assignment.assignedToActorType, assignment.assignedToActorId, actor)) return;
657
+ throw new Error("Insufficient permissions to link this assignment to a HITL request.");
658
+ }
659
+ assertRelatedHandoffSnapshotReadable(snapshot, actor) {
660
+ if (isHitlSupervisor(actor.userRole)) return;
661
+ if (matchesActor(snapshot.actorType, snapshot.actorId, actor)) return;
662
+ throw new Error("Insufficient permissions to link this handoff snapshot to a HITL request.");
663
+ }
664
+ assertValidAction(action, status) {
665
+ const validFrom = HITL_REQUEST_VALID_FROM[action];
666
+ if (!validFrom.includes(status)) throw new Error(`Cannot ${action} a HITL request in status "${status}". Valid statuses: ${validFrom.join(", ")}.`);
667
+ }
668
+ };
669
+ function isHitlSupervisor(role) {
670
+ return role >= Role.EDITOR;
671
+ }
672
+ function matchesActor(actorType, actorId, actor) {
673
+ return actorType === actor.actorType && actorId === actor.actorId;
674
+ }
675
+
676
+ //#endregion
677
+ export { ASSIGNMENT_STATUSES as a, stableStringify as c, HitlRequestRepository as d, EntityAliasRepository as f, ASSIGNMENT_PRIORITIES as i, HITL_REQUEST_PRIORITIES as l, HandoffSnapshotRepository as n, AssignmentRepository as o, normalizeEntityAlias as p, ASSIGNMENT_ACTOR_TYPES as r, buildStableActionHash as s, HitlRequestService as t, HITL_REQUEST_STATUSES as u };
@@ -1,5 +1,5 @@
1
- import { t as ExperimentalSiteContextWorkflowDisabledError } from "./experimental-workflows-CSMffP6q.mjs";
2
- import { n as HitlRequestService } from "./site-context-C8Az_P_I.mjs";
1
+ import { t as HitlRequestService } from "./hitl-Hw1RmWOq.mjs";
2
+ import { t as ExperimentalSiteContextWorkflowDisabledError } from "./experimental-workflows-BMsUnIAw.mjs";
3
3
 
4
4
  //#region src/api/handlers/hitl-requests.ts
5
5
  const HITL_NOT_FOUND_RE = /not found/i;
@@ -1,7 +1,8 @@
1
- import { t as apiError } from "./error-DCSuUAZW.mjs";
2
- import { t as ExperimentalSiteContextWorkflowDisabledError } from "./experimental-workflows-CSMffP6q.mjs";
3
- import { t as WorkflowHitlCoordinator } from "./site-context-C8Az_P_I.mjs";
4
- import { T as resolveActorIdentity, p as logSiteActivitySafely } from "./activity-events-CwM7yxPW.mjs";
1
+ import { t as apiError } from "./error-CytFlgcd.mjs";
2
+ import { t as resolveActorIdentity } from "./actor-CrObAPV0.mjs";
3
+ import { p as logSiteActivitySafely } from "./activity-events-y6eT8UW6.mjs";
4
+ import { t as ExperimentalSiteContextWorkflowDisabledError } from "./experimental-workflows-BMsUnIAw.mjs";
5
+ import { t as WorkflowHitlCoordinator } from "./site-context-DQiL8Fl5.mjs";
5
6
  import { Role } from "@dineway-ai/auth";
6
7
 
7
8
  //#region src/api/hitl-route-helpers.ts