@processfocus/runtime-local 0.1.0-next.2 → 0.1.0-next.4

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 (332) hide show
  1. package/README.md +51 -253
  2. package/dist/authentication-server.mjs +52 -84
  3. package/dist/chunk-3wzp2sax.js +4806 -0
  4. package/dist/chunk-5kjvzbwr.js +512 -0
  5. package/dist/chunk-egeb4821.js +156 -0
  6. package/dist/chunk-q5v72erd.js +241 -0
  7. package/dist/{chunk-yhzbn4vx.js → chunk-wvbz0nmd.js} +19485 -34180
  8. package/dist/{chunk-352j1ayk.js → chunk-y8fnwbx0.js} +51781 -36259
  9. package/dist/dashboard-source/apps/frontend/app/(protected)/act-on-behalf/actions.ts +12 -12
  10. package/dist/dashboard-source/apps/frontend/app/(protected)/act-on-behalf/delegations-client.tsx +31 -21
  11. package/dist/dashboard-source/apps/frontend/app/(protected)/act-on-behalf/page.tsx +3 -0
  12. package/dist/dashboard-source/apps/frontend/app/(protected)/client-index.tsx +1 -12
  13. package/dist/dashboard-source/apps/frontend/app/(protected)/connected-apps/disconnect-form.tsx +57 -0
  14. package/dist/dashboard-source/apps/frontend/app/(protected)/connected-apps/page.tsx +97 -0
  15. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/(.)[executionId]/client.tsx +1 -1
  16. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/(.)[executionId]/page.tsx +2 -0
  17. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/(.)[executionId]/process-state/page.tsx +2 -0
  18. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/default.tsx +3 -0
  19. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/[executionId]/page.tsx +3 -1
  20. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/[executionId]/process-state/page.tsx +2 -0
  21. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/client-layout.tsx +19 -0
  22. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/default.tsx +6 -0
  23. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/executions-client.tsx +1637 -0
  24. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/layout.tsx +5 -7
  25. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/page.tsx +4 -1589
  26. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/process-state-page-client.tsx +1 -1
  27. package/dist/dashboard-source/apps/frontend/app/(protected)/layout.tsx +41 -33
  28. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/@modal/(.)item/[id]/client.tsx +11 -17
  29. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/@modal/(.)item/[id]/page.tsx +2 -0
  30. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/@modal/default.tsx +3 -0
  31. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/[...listPath]/list-page-client.tsx +169 -18
  32. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/[...listPath]/page.tsx +21 -14
  33. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-create-form.tsx +36 -18
  34. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-item-edit-form.tsx +22 -28
  35. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-item-load-error.tsx +49 -0
  36. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-schema-form.tsx +28 -0
  37. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/default.tsx +6 -0
  38. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/hooks/metric-control-url-state.ts +7 -16
  39. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/hooks/use-list-deleted-callback.ts +4 -6
  40. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/hooks/use-list-item-detail.ts +45 -142
  41. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/item/[id]/client.tsx +10 -20
  42. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/item/[id]/page.tsx +2 -0
  43. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/layout.tsx +3 -0
  44. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/lib/list-process-dialog.tsx +72 -0
  45. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/lib/list-refresh-provider.tsx +65 -0
  46. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/lib/list-refresh.ts +162 -16
  47. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/utils.tsx +19 -0
  48. package/dist/dashboard-source/apps/frontend/app/(protected)/org-chart/page.tsx +4 -9
  49. package/dist/dashboard-source/apps/frontend/app/(protected)/page.tsx +4 -0
  50. package/dist/dashboard-source/apps/frontend/app/(protected)/passkeys/actions.ts +15 -18
  51. package/dist/dashboard-source/apps/frontend/app/(protected)/passkeys/page.tsx +12 -6
  52. package/dist/dashboard-source/apps/frontend/app/(protected)/passkeys/passkeys-client.tsx +7 -16
  53. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/@modal/(.)start/[...startStepPath]/client.tsx +26 -48
  54. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/@modal/(.)start/[...startStepPath]/page.tsx +4 -7
  55. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/@modal/default.tsx +3 -0
  56. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/client-layout.tsx +28 -0
  57. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/client.tsx +1 -3
  58. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/components/start-process-form.tsx +193 -117
  59. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/default.tsx +6 -0
  60. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/layout.tsx +7 -9
  61. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/page.tsx +3 -0
  62. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/processes-client.tsx +60 -204
  63. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/start/[...startStepPath]/client.tsx +12 -51
  64. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/start/[...startStepPath]/page.tsx +27 -4
  65. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/page.tsx +5 -4
  66. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/workflow-flow.tsx +0 -5
  67. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/workflow-form-preview-sheet.tsx +26 -19
  68. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/[[...tab]]/page.tsx +5 -2
  69. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/cedar-authorize.ts +85 -9
  70. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/cedar-types.ts +12 -1
  71. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/explorer.tsx +66 -4
  72. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/layout.tsx +3 -0
  73. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/load-handbook.ts +41 -13
  74. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/[invitationId]/page.tsx +2 -0
  75. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/invitation-detail-client.tsx +442 -365
  76. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/new/page.tsx +8 -2
  77. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/page.tsx +7 -0
  78. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations-table.tsx +61 -43
  79. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/page.tsx +6 -67
  80. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/providers/page.tsx +7 -0
  81. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/roles/page.tsx +7 -0
  82. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/settings-client.tsx +111 -189
  83. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/settings-page.tsx +86 -0
  84. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/[userId]/client.tsx +141 -256
  85. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/[userId]/page.tsx +2 -0
  86. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/[userId]/tokens/page.tsx +2 -0
  87. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/page.tsx +7 -0
  88. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users-table.tsx +6 -4
  89. package/dist/dashboard-source/apps/frontend/app/(protected)/stats/[...statsPath]/page.tsx +3 -0
  90. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/@modal/(.)complete/[...stepPath]/client.tsx +30 -9
  91. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/@modal/(.)complete/[...stepPath]/page.tsx +3 -1
  92. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/@modal/default.tsx +3 -0
  93. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/complete/[...stepPath]/client.tsx +2 -4
  94. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/complete/[...stepPath]/page.tsx +3 -1
  95. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/components/complete-todo-form.tsx +47 -54
  96. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/components/public-completion-correction-form.tsx +37 -54
  97. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/components/todo-form-actions.tsx +1 -1
  98. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/correct/[...stepPath]/page.tsx +3 -1
  99. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/default.tsx +6 -0
  100. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/layout.tsx +3 -0
  101. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/lib/mobile-todo-list.ts +4 -25
  102. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/page.tsx +4 -1315
  103. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/to-dos-client.tsx +1282 -0
  104. package/dist/dashboard-source/apps/frontend/app/api/auth/callback/route.ts +81 -65
  105. package/dist/dashboard-source/apps/frontend/app/api/auth/delegation/route.ts +8 -2
  106. package/dist/dashboard-source/apps/frontend/app/api/auth/login/route.ts +0 -1
  107. package/dist/dashboard-source/apps/frontend/app/api/auth/logout/route.ts +10 -5
  108. package/dist/dashboard-source/apps/frontend/app/api/auth/passkey/start/route.ts +1 -3
  109. package/dist/dashboard-source/apps/frontend/app/api/auth/refresh/route.ts +0 -1
  110. package/dist/dashboard-source/apps/frontend/app/api/auth/revalidate-google/route.ts +68 -0
  111. package/dist/dashboard-source/apps/frontend/app/api/auth/switch-role/route.ts +1 -3
  112. package/dist/dashboard-source/apps/frontend/app/api/dev/import-events/route.ts +69 -1
  113. package/dist/dashboard-source/apps/frontend/app/api/embed/lookup/route.ts +25 -7
  114. package/dist/dashboard-source/apps/frontend/app/api/embed/submit/route.ts +1 -2
  115. package/dist/dashboard-source/apps/frontend/app/api/public/start/[address]/route.ts +49 -0
  116. package/dist/dashboard-source/apps/frontend/app/api/public/to-dos/lookup/route.ts +4 -3
  117. package/dist/dashboard-source/apps/frontend/app/api/revalidate/route.ts +15 -4
  118. package/dist/dashboard-source/apps/frontend/app/app-shell.tsx +14 -6
  119. package/dist/dashboard-source/apps/frontend/app/cli-auth/route.ts +2 -1
  120. package/dist/dashboard-source/apps/frontend/app/embed/[...startStepPath]/embed-client.tsx +31 -18
  121. package/dist/dashboard-source/apps/frontend/app/embed/[...startStepPath]/page.tsx +5 -1
  122. package/dist/dashboard-source/apps/frontend/app/login/page.tsx +4 -4
  123. package/dist/dashboard-source/apps/frontend/app/login/passkey-button.tsx +11 -6
  124. package/dist/dashboard-source/apps/frontend/app/login/passkey-help/page.tsx +67 -0
  125. package/dist/dashboard-source/apps/frontend/app/mcp/[[...endpoint]]/route.ts +44 -0
  126. package/dist/dashboard-source/apps/frontend/app/public/form/[token]/public-todo-client.tsx +44 -25
  127. package/dist/dashboard-source/apps/frontend/app/public/start/[address]/form/page.tsx +10 -0
  128. package/dist/dashboard-source/apps/frontend/app/public/start/[address]/layout.tsx +32 -0
  129. package/dist/dashboard-source/apps/frontend/app/public/start/[address]/page-client.tsx +319 -0
  130. package/dist/dashboard-source/apps/frontend/app/public/start/[address]/page-content.tsx +41 -0
  131. package/dist/dashboard-source/apps/frontend/app/public/start/[address]/page.tsx +10 -0
  132. package/dist/dashboard-source/apps/frontend/app/public.css +1 -1
  133. package/dist/dashboard-source/apps/frontend/app/register/passkey/register-passkey-client.tsx +17 -0
  134. package/dist/dashboard-source/apps/frontend/components/DashboardSection.tsx +9 -15
  135. package/dist/dashboard-source/apps/frontend/components/Header.tsx +14 -8
  136. package/dist/dashboard-source/apps/frontend/components/anonymous-page-link.tsx +57 -0
  137. package/dist/dashboard-source/apps/frontend/components/anonymous-start-form.tsx +24 -0
  138. package/dist/dashboard-source/apps/frontend/components/app-sidebar.tsx +21 -7
  139. package/dist/dashboard-source/apps/frontend/components/auth-provider.tsx +12 -7
  140. package/dist/dashboard-source/apps/frontend/components/browser-only.tsx +19 -0
  141. package/dist/dashboard-source/apps/frontend/components/config-provider.tsx +0 -1
  142. package/dist/dashboard-source/apps/frontend/components/delegation-expiry.tsx +24 -13
  143. package/dist/dashboard-source/apps/frontend/components/form-dialog-content.tsx +22 -2
  144. package/dist/dashboard-source/apps/frontend/components/journey-timeline.tsx +52 -45
  145. package/dist/dashboard-source/apps/frontend/components/notification-bell.tsx +0 -1
  146. package/dist/dashboard-source/apps/frontend/components/sidebar-lists.tsx +0 -1
  147. package/dist/dashboard-source/apps/frontend/components/token-refresh-scheduler.tsx +38 -11
  148. package/dist/dashboard-source/apps/frontend/components/ui/sidebar.tsx +0 -1
  149. package/dist/dashboard-source/apps/frontend/components/ui/tab-pill.tsx +26 -15
  150. package/dist/dashboard-source/apps/frontend/components/workflow/step-node.tsx +0 -1
  151. package/dist/dashboard-source/apps/frontend/components/workflow/workflow-edge.tsx +5 -0
  152. package/dist/dashboard-source/apps/frontend/hooks/use-form-metadata.ts +21 -10
  153. package/dist/dashboard-source/apps/frontend/hooks/use-process-draft.ts +173 -0
  154. package/dist/dashboard-source/apps/frontend/hooks/use-weekly-execution-stats.ts +1 -3
  155. package/dist/dashboard-source/apps/frontend/lib/anonymous-page-form-values.ts +6 -0
  156. package/dist/dashboard-source/apps/frontend/lib/anonymous-page-server.ts +65 -0
  157. package/dist/dashboard-source/apps/frontend/lib/appsync-events/adapter.ts +9 -3
  158. package/dist/dashboard-source/apps/frontend/lib/appsync-events/client.ts +7 -340
  159. package/dist/dashboard-source/apps/frontend/lib/auth/client-session.ts +2 -0
  160. package/dist/dashboard-source/apps/frontend/lib/auth/delegations.ts +9 -7
  161. package/dist/dashboard-source/apps/frontend/lib/auth/google-revalidation.ts +111 -0
  162. package/dist/dashboard-source/apps/frontend/lib/auth/logout.ts +1 -1
  163. package/dist/dashboard-source/apps/frontend/lib/auth/passkeys.ts +28 -30
  164. package/dist/dashboard-source/apps/frontend/lib/auth/providers.ts +10 -0
  165. package/dist/dashboard-source/apps/frontend/lib/auth/realtime-session-token.ts +1 -0
  166. package/dist/dashboard-source/apps/frontend/lib/auth/reauthentication-state.ts +4 -4
  167. package/dist/dashboard-source/apps/frontend/lib/auth/session-admission.ts +11 -7
  168. package/dist/dashboard-source/apps/frontend/lib/auth/session.ts +27 -10
  169. package/dist/dashboard-source/apps/frontend/lib/auth/ssr-session.ts +76 -9
  170. package/dist/dashboard-source/apps/frontend/lib/auth/verify-passkey.ts +25 -3
  171. package/dist/dashboard-source/apps/frontend/lib/collections/collection-provider-factory.tsx +115 -23
  172. package/dist/dashboard-source/apps/frontend/lib/collections/draft-process-execution.ts +1 -8
  173. package/dist/dashboard-source/apps/frontend/lib/collections/execution.ts +6 -2
  174. package/dist/dashboard-source/apps/frontend/lib/collections/graphql-stream.ts +21 -1
  175. package/dist/dashboard-source/apps/frontend/lib/collections/process-collection-provider.tsx +3 -0
  176. package/dist/dashboard-source/apps/frontend/lib/collections/process.ts +8 -2
  177. package/dist/dashboard-source/apps/frontend/lib/collections/replication-factory.ts +16 -4
  178. package/dist/dashboard-source/apps/frontend/lib/collections/todo.ts +1 -1
  179. package/dist/dashboard-source/apps/frontend/lib/dev/import-completed-query-invalidation.tsx +66 -9
  180. package/dist/dashboard-source/apps/frontend/lib/dev/import-completed-refresh.ts +10 -6
  181. package/dist/dashboard-source/apps/frontend/lib/effect/navigation.ts +4 -0
  182. package/dist/dashboard-source/apps/frontend/lib/effect/page-runtime.ts +29 -0
  183. package/dist/dashboard-source/apps/frontend/lib/effect/params.ts +18 -12
  184. package/dist/dashboard-source/apps/frontend/lib/effect/run-effect.ts +1 -1
  185. package/dist/dashboard-source/apps/frontend/lib/effect/runtime.ts +19 -23
  186. package/dist/dashboard-source/apps/frontend/lib/effect/services/access-token.ts +9 -12
  187. package/dist/dashboard-source/apps/frontend/lib/effect/services/authorization.ts +12 -12
  188. package/dist/dashboard-source/apps/frontend/lib/effect/services/form-validation.ts +20 -18
  189. package/dist/dashboard-source/apps/frontend/lib/effect/services/graphql.ts +32 -16
  190. package/dist/dashboard-source/apps/frontend/lib/embed-form-server.ts +35 -0
  191. package/dist/dashboard-source/apps/frontend/lib/embed-manifest.ts +10 -103
  192. package/dist/dashboard-source/apps/frontend/lib/forms/invitation.ts +43 -0
  193. package/dist/dashboard-source/apps/frontend/lib/forms/provider-user.ts +64 -0
  194. package/dist/dashboard-source/apps/frontend/lib/frontend-form-loaders.ts +40 -0
  195. package/dist/dashboard-source/apps/frontend/lib/frontend-manifest.ts +1 -33
  196. package/dist/dashboard-source/apps/frontend/lib/generated/gql/gql.ts +123 -33
  197. package/dist/dashboard-source/apps/frontend/lib/generated/gql/graphql.ts +168 -30
  198. package/dist/dashboard-source/apps/frontend/lib/generated/gql/index.ts +1 -0
  199. package/dist/dashboard-source/apps/frontend/lib/graphql/anonymous-page.ts +27 -0
  200. package/dist/dashboard-source/apps/frontend/lib/graphql/dependent-lookup-query.ts +1 -0
  201. package/dist/dashboard-source/apps/frontend/lib/graphql/list-queries.ts +34 -29
  202. package/dist/dashboard-source/apps/frontend/lib/graphql/lookup-provider.tsx +82 -10
  203. package/dist/dashboard-source/apps/frontend/lib/graphql/org-chart-operations.ts +2 -5
  204. package/dist/dashboard-source/apps/frontend/lib/graphql/queries.ts +25 -4
  205. package/dist/dashboard-source/apps/frontend/lib/graphql/server-client.ts +11 -0
  206. package/dist/dashboard-source/apps/frontend/lib/graphql/settings-queries.ts +13 -104
  207. package/dist/dashboard-source/apps/frontend/lib/graphql/user-queries.ts +11 -4
  208. package/dist/dashboard-source/apps/frontend/lib/graphql/workflow-operations.ts +1 -3
  209. package/dist/dashboard-source/apps/frontend/lib/graphql/workflow-queries.ts +1 -0
  210. package/dist/dashboard-source/apps/frontend/lib/list-detail-selection.ts +54 -0
  211. package/dist/dashboard-source/apps/frontend/lib/mcp/executions.ts +110 -0
  212. package/dist/dashboard-source/apps/frontend/lib/mcp/list-writes.ts +395 -0
  213. package/dist/dashboard-source/apps/frontend/lib/mcp/lists.ts +263 -0
  214. package/dist/dashboard-source/apps/frontend/lib/mcp/oauth.ts +889 -0
  215. package/dist/dashboard-source/apps/frontend/lib/mcp/origin.ts +50 -0
  216. package/dist/dashboard-source/apps/frontend/lib/mcp/processes.ts +436 -0
  217. package/dist/dashboard-source/apps/frontend/lib/mcp/read-tool.ts +72 -0
  218. package/dist/dashboard-source/apps/frontend/lib/mcp/result.ts +4 -0
  219. package/dist/dashboard-source/apps/frontend/lib/mcp/server.ts +71 -0
  220. package/dist/dashboard-source/apps/frontend/lib/mcp/store.ts +107 -0
  221. package/dist/dashboard-source/apps/frontend/lib/mcp/todos.ts +260 -0
  222. package/dist/dashboard-source/apps/frontend/lib/notifications/notification-preference.ts +0 -1
  223. package/dist/dashboard-source/apps/frontend/lib/notifications/todo-notification-observer.ts +0 -5
  224. package/dist/dashboard-source/apps/frontend/lib/org-chart-data.ts +0 -2
  225. package/dist/dashboard-source/apps/frontend/lib/org-identity.ts +6 -4
  226. package/dist/dashboard-source/apps/frontend/lib/organisation-form-loaders.ts +4 -0
  227. package/dist/dashboard-source/apps/frontend/lib/public-todo-form-runtime.ts +0 -1
  228. package/dist/dashboard-source/apps/frontend/lib/public-todo-model.ts +39 -139
  229. package/dist/dashboard-source/apps/frontend/lib/public-todo-server.ts +17 -16
  230. package/dist/dashboard-source/apps/frontend/lib/query-client.ts +0 -1
  231. package/dist/dashboard-source/apps/frontend/lib/todo-utils.ts +1 -77
  232. package/dist/dashboard-source/apps/frontend/lib/workflow/layout.ts +3 -7
  233. package/dist/dashboard-source/apps/frontend/next.config.ts +33 -13
  234. package/dist/dashboard-source/apps/frontend/package.json +47 -47
  235. package/dist/dashboard-source/apps/frontend/proxy.ts +72 -14
  236. package/dist/dashboard-source/modules/auth-local-cedar/src/index.ts +0 -3
  237. package/dist/dashboard-source/modules/auth-local-cedar/src/lib/auth-local-cedar.ts +165 -233
  238. package/dist/dashboard-source/modules/auth-local-cedar/src/lib/cedar-reload-notifier.ts +4 -3
  239. package/dist/dashboard-source/modules/auth-local-cedar/src/lib/config-base.ts +111 -75
  240. package/dist/dashboard-source/modules/auth-local-cedar/src/lib/policy-watcher.ts +14 -18
  241. package/dist/dashboard-source/modules/auth-policy/src/index.ts +1 -0
  242. package/dist/dashboard-source/modules/auth-policy/src/lib/auth-policy.ts +19 -37
  243. package/dist/dashboard-source/modules/auth-policy/src/lib/current-principal.ts +33 -29
  244. package/dist/dashboard-source/modules/auth-policy/src/lib/policy-revision.ts +23 -0
  245. package/dist/dashboard-source/modules/auth-policy/src/lib/types.ts +24 -49
  246. package/dist/dashboard-source/modules/auth-session/src/index.ts +4 -0
  247. package/dist/dashboard-source/modules/auth-session/src/lib/project-subscription.ts +13 -0
  248. package/dist/dashboard-source/modules/auth-session/src/lib/realtime-recipient.ts +10 -2
  249. package/dist/dashboard-source/modules/auth-session/src/lib/subjects.ts +82 -8
  250. package/dist/dashboard-source/modules/auth-session/src/lib/workload-access.ts +48 -0
  251. package/dist/dashboard-source/modules/auth-session/src/lib/workload-audit.ts +52 -0
  252. package/dist/dashboard-source/modules/aws-common/src/index.ts +0 -1
  253. package/dist/dashboard-source/modules/effect-json-logger/src/lib/effect-json-logger.ts +6 -9
  254. package/dist/dashboard-source/modules/form/src/hooks/use-local-storage.ts +5 -3
  255. package/dist/dashboard-source/modules/form/src/index.ts +1 -10
  256. package/dist/dashboard-source/modules/form/src/lib/effect-schema-form.tsx +1271 -0
  257. package/dist/dashboard-source/modules/form/src/lib/form-actions.ts +26 -0
  258. package/dist/dashboard-source/modules/form/src/lib/form-prefill.tsx +79 -0
  259. package/dist/dashboard-source/modules/form/src/lib/initial-focus.ts +31 -0
  260. package/dist/dashboard-source/modules/form/src/lib/lookup-context.tsx +18 -0
  261. package/dist/dashboard-source/modules/form/src/lib/plugin-registry.ts +4 -0
  262. package/dist/dashboard-source/modules/form/src/lib/plugin-scripts.ts +26 -0
  263. package/dist/dashboard-source/modules/form/src/lib/registered-plugin-field.tsx +57 -0
  264. package/dist/dashboard-source/modules/form/src/lib/schema-lookup.tsx +124 -0
  265. package/dist/dashboard-source/modules/form/src/lib/schema-typeahead.tsx +522 -0
  266. package/dist/dashboard-source/modules/form/src/lib/validation-logic.ts +172 -0
  267. package/dist/dashboard-source/modules/form-schema/src/index.ts +4 -1
  268. package/dist/dashboard-source/modules/form-schema/src/lib/annotation-helpers.ts +19 -14
  269. package/dist/dashboard-source/modules/form-schema/src/lib/email.ts +13 -11
  270. package/dist/dashboard-source/modules/form-schema/src/lib/field-count.ts +15 -13
  271. package/dist/dashboard-source/modules/form-schema/src/lib/form-annotations.ts +14 -0
  272. package/dist/dashboard-source/modules/form-schema/src/lib/form-presentation.ts +33 -0
  273. package/dist/dashboard-source/modules/form-schema/src/lib/form-schema.ts +186 -80
  274. package/dist/dashboard-source/modules/form-schema/src/lib/number-from-string.ts +26 -0
  275. package/dist/dashboard-source/modules/form-schema/src/lib/phone.ts +8 -7
  276. package/dist/dashboard-source/modules/form-schema/src/lib/public-completion-correction.ts +7 -0
  277. package/dist/dashboard-source/modules/form-schema/src/lib/search-lookup-items.ts +27 -0
  278. package/dist/dashboard-source/modules/form-submission-schema/src/index.ts +5 -0
  279. package/dist/dashboard-source/modules/form-submission-schema/src/lib/executable-rules.ts +379 -0
  280. package/dist/dashboard-source/modules/form-submission-schema/src/lib/form-submission-schema.ts +475 -0
  281. package/dist/dashboard-source/modules/form-submission-schema/src/lib/json-schema.ts +58 -0
  282. package/dist/dashboard-source/modules/form-submission-schema/src/lib/schema-defaults.ts +158 -0
  283. package/dist/dashboard-source/modules/form-submission-schema/src/lib/submission-utils.ts +75 -0
  284. package/dist/dashboard-source/modules/frontend-manifest/src/lib/browser-plugin-artifact.ts +46 -0
  285. package/dist/dashboard-source/modules/frontend-manifest/src/lib/frontend-manifest.ts +37 -30
  286. package/dist/dashboard-source/modules/frontend-plugin-host/src/lib/frontend-plugin-host.ts +9 -1
  287. package/dist/dashboard-source/modules/openauth/src/client.ts +25 -17
  288. package/dist/dashboard-source/modules/openauth/src/util.ts +16 -0
  289. package/dist/dashboard-source/modules/{aws-common/src/lib/project-balance-admission.ts → project-accounting/src/admission.ts} +4 -8
  290. package/dist/dashboard-source/modules/realtime-client/src/appsync-client.ts +377 -0
  291. package/dist/dashboard-source/modules/realtime-client/src/index.ts +5 -0
  292. package/dist/dashboard-source/modules/realtime-client/src/subscription-presence.ts +163 -0
  293. package/dist/dashboard-source/modules/request-time/src/lib/request-time.ts +6 -24
  294. package/dist/dashboard-source/modules/rxdb-collections/generated/execution-schema.json +28 -21
  295. package/dist/dashboard-source/modules/rxdb-collections/src/lib/rxdb-collections.ts +25 -18
  296. package/dist/dashboard-source/modules/rxdb-collections/src/lib/to-rxdb-schema.ts +60 -10
  297. package/dist/dashboard-source/modules/shadcn-components/src/index.ts +18 -2
  298. package/dist/dashboard-source/modules/shadcn-components/src/lib/date-calendar.tsx +93 -0
  299. package/dist/dashboard-source/modules/shadcn-components/src/lib/date-field.tsx +147 -48
  300. package/dist/dashboard-source/modules/shadcn-components/src/lib/date-time-display.tsx +273 -0
  301. package/dist/dashboard-source/modules/shadcn-components/src/lib/local-date-time-input.tsx +108 -0
  302. package/dist/dashboard-source/modules/shadcn-components/src/lib/lookup-field.tsx +237 -351
  303. package/dist/dashboard-source/modules/shadcn-components/src/lib/ui/popover.tsx +2 -1
  304. package/dist/dashboard-source.json +47 -47
  305. package/dist/graphql-server.mjs +272 -200
  306. package/dist/job-worker-supervisor.mjs +262 -0
  307. package/dist/job-worker.mjs +234 -133
  308. package/dist/main.mjs +30 -6
  309. package/dist/prepare-dashboard.mjs +8 -8
  310. package/dist/resources/cedar/policies.cedar +80 -38
  311. package/dist/resources/cedar/schema.cedarschema +39 -21
  312. package/dist/resources/graphql-schema/rxdb.graphql +2 -0
  313. package/dist/resources/graphql-schema/system.graphql +191 -51
  314. package/package.json +63 -62
  315. package/dist/chunk-6ntmymmx.js +0 -85
  316. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/utils.ts +0 -20
  317. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/components/process-form-actions.tsx +0 -105
  318. package/dist/dashboard-source/apps/frontend/hooks/use-draft-process-save.ts +0 -189
  319. package/dist/dashboard-source/apps/frontend/hooks/use-draft-state.ts +0 -79
  320. package/dist/dashboard-source/apps/frontend/hooks/use-processes-query.ts +0 -56
  321. package/dist/dashboard-source/modules/form/src/lib/ajv-standard-schema.ts +0 -152
  322. package/dist/dashboard-source/modules/form/src/lib/client-components-to-form.tsx +0 -1421
  323. package/dist/dashboard-source/modules/form/src/lib/friendly-validation-message.ts +0 -85
  324. package/dist/dashboard-source/modules/form/src/lib/walker.tsx +0 -1549
  325. package/dist/dashboard-source/modules/form-client-representation/src/lib/client-form-definition.ts +0 -440
  326. package/dist/dashboard-source/modules/form-client-representation/src/lib/plugin-registry.ts +0 -13
  327. package/dist/dashboard-source/modules/form-client-representation/src/lib/types.ts +0 -336
  328. package/dist/dashboard-source/modules/form-rule/src/index.ts +0 -21
  329. package/dist/dashboard-source/modules/form-rule/src/lib/evaluator.ts +0 -531
  330. package/dist/dashboard-source/modules/form-rule/src/lib/paths.ts +0 -102
  331. package/dist/dashboard-source/modules/form-rule/src/lib/types.ts +0 -121
  332. package/dist/dashboard-source/modules/form-schema/src/lib/property-signature.ts +0 -45
@@ -1,45 +1,19 @@
1
1
  // @bun
2
2
  import {
3
3
  layer,
4
- Runtime,
5
- CurrentPrincipal,
6
- RequestTime,
7
- DelegationSessionServiceIsolated,
8
- layer2,
4
+ normalizePath,
9
5
  OrganisationProvider,
6
+ OrganisationProviderFromPath,
10
7
  OrganisationProviderFromPathDev,
11
8
  CedarPoliciesProvider,
12
9
  OrgCedarPoliciesProvider,
13
- DatabaseConnectionInfo,
14
- LOCAL_SQLITE_BUSY_TIMEOUT_MS,
15
- TypedSqliteDrizzleLayer,
16
- FileOperations,
17
- UserDetails,
18
- SqliteDelegationDatabaseLive,
19
- SqliteAuthenticationDatabaseLive,
20
- SqliteCompletedJobOperationsLive,
21
- SqliteFileOperationsLive,
22
- SqliteFlowExecutionOperationsLive,
23
- SqliteGraphqlDbOperationsLive,
24
- SqliteScheduledFlowOperationsLive,
25
- DEFAULT_GRAPHQL_PORT,
26
- GRAPHQL_PORT_FILE,
27
- makeLocalSqlClientLayer,
28
10
  CedarReloadNotifierService,
29
11
  LocalCedarConfigStatic,
30
12
  LocalCedarConfigHotReload,
31
- LocalCedarAuthorizationLive
32
- } from "./chunk-yhzbn4vx.js";
33
- import {
34
- HttpClient,
35
- post,
36
- bodyJson,
37
- filterStatusOk,
38
- AuthConfig,
39
- AuthConfigLive,
13
+ LocalCedarAuthorizationLive,
14
+ DelegationSessionServiceIsolated,
40
15
  resolveBusinessMetricDimensions,
41
16
  BusinessMetricDimensions,
42
- makeDashboardActivityLayer,
43
17
  versionInfo,
44
18
  GraphQLError,
45
19
  parse,
@@ -48,6 +22,9 @@ import {
48
22
  execute,
49
23
  subscribe,
50
24
  LocalDelegatedRealtime,
25
+ AuthConfig,
26
+ AuthConfigLive,
27
+ makeDashboardActivityLayer,
51
28
  DraftProcessEvents,
52
29
  TodoSummaryComputation,
53
30
  TodoSummaryComputationLive,
@@ -63,30 +40,66 @@ import {
63
40
  TodoCollectionOps,
64
41
  TodoCollectionOpsLive,
65
42
  TodoEvents,
66
- hasInvalidDownloadFilename,
67
- formatContentDisposition,
68
43
  ListExportServiceLive,
69
44
  DynamicSchemaConfig,
70
45
  AppSchemaBuilderLive,
71
46
  Yoga,
72
47
  ResolverRuntime,
73
48
  YogaLive,
74
- SqliteQueueServiceLive,
49
+ makeMcpOAuthStorageRoute,
75
50
  warnIgnoredCronDeclarations,
76
51
  getEffectiveFrontendBaseUrl,
77
52
  LocalDocumentStoreConfig,
78
53
  generateLocalDocumentStoreToken,
79
54
  LocalDocumentStoreServiceLive,
80
- makeServerPluginWebhookRouter
81
- } from "./chunk-352j1ayk.js";
55
+ makeServerPluginWebhookRouter,
56
+ PROJECT_ACCOUNTING_QUEUE,
57
+ ProjectAccountingChange,
58
+ ProjectAccountingEvents,
59
+ LocalQueueServiceLive
60
+ } from "./chunk-y8fnwbx0.js";
61
+ import {
62
+ hasInvalidDownloadFilename,
63
+ formatContentDisposition,
64
+ QueueService,
65
+ Runtime,
66
+ DatabaseConnectionInfo,
67
+ LOCAL_SQLITE_BUSY_TIMEOUT_MS,
68
+ CurrentPrincipal,
69
+ AuthenticationDelegationIdentityFactsLive,
70
+ TypedSqliteDrizzleLayer,
71
+ FileOperations,
72
+ UserDetails,
73
+ SqliteDelegationDatabaseLive,
74
+ SqliteAuthenticationDatabaseLive,
75
+ makeLocalSqlClientLayer
76
+ } from "./chunk-wvbz0nmd.js";
77
+ import {
78
+ NumberFromString,
79
+ DEFAULT_GRAPHQL_PORT,
80
+ GRAPHQL_PORT_FILE
81
+ } from "./chunk-5kjvzbwr.js";
82
+ import {
83
+ RequestTime,
84
+ SqliteCompletedJobOperationsLive,
85
+ SqliteFileOperationsLive,
86
+ SqliteFlowExecutionOperationsLive,
87
+ SqliteGraphqlDbOperationsLive,
88
+ SqliteMcpOAuthRecordsLive,
89
+ SqliteScheduledFlowOperationsLive
90
+ } from "./chunk-3wzp2sax.js";
82
91
  import {
83
92
  serveOnExactPort,
84
93
  serveWithPortFallback,
85
- writePortFile
86
- } from "./chunk-6ntmymmx.js";
94
+ writePortFile,
95
+ LocalRuntimeAuditLive,
96
+ LocalPolicyRevisionPublisherLive
97
+ } from "./chunk-egeb4821.js";
87
98
 
88
99
  // src/graphql-server/graphql-server.ts
89
- import * as Otel from "@effect/opentelemetry";
100
+ import { randomUUID } from "crypto";
101
+ import { join as join2, resolve } from "path";
102
+ import * as NodeSdk from "@effect/opentelemetry/NodeSdk";
90
103
  import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-http";
91
104
  import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
92
105
  import { PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics";
@@ -96,71 +109,73 @@ import {
96
109
  Config as Config2,
97
110
  Context,
98
111
  DateTime,
99
- Effect as Effect4,
112
+ Effect as Effect5,
100
113
  Exit as Exit2,
101
- FiberRef,
102
- Layer as Layer4,
103
- LogLevel,
114
+ FileSystem,
115
+ Layer as Layer5,
104
116
  Logger,
105
117
  ManagedRuntime,
106
- Option as Option3,
107
- Redacted
118
+ Option as Option4,
119
+ Redacted,
120
+ References
108
121
  } from "effect";
122
+ import { FetchHttpClient } from "effect/http";
109
123
 
110
124
  // src/services/event-hub.ts
111
- import { Cause, Effect, Layer, Queue, Runtime as Runtime2 } from "effect";
125
+ import { Cause, Effect, Layer, Queue } from "effect";
112
126
  var DEFAULT_BUFFER_SIZE = 32;
113
127
  var createEventHubLayer = (tag, options = {}) => {
114
128
  const bufferSize = options.bufferSize ?? DEFAULT_BUFFER_SIZE;
115
- return Layer.effect(tag, Effect.sync(() => {
116
- const subscribers = new Set;
117
- return {
118
- emit: (event, _schema) => Effect.forEach(Array.from(subscribers), (queue) => Queue.offer(queue, event), { discard: true }),
119
- subscribe: () => Effect.gen(function* () {
120
- const queue = yield* Queue.sliding(bufferSize);
121
- subscribers.add(queue);
122
- const runtime = yield* Effect.runtime();
123
- const run = Runtime2.runPromise(runtime);
124
- let closed = false;
125
- const close = async () => {
126
- closed = true;
127
- subscribers.delete(queue);
128
- await run(Queue.shutdown(queue));
129
- };
130
- const iterator = {
131
- [Symbol.asyncIterator]() {
132
- return this;
133
- },
134
- async next() {
129
+ return Layer.effect(tag, createEventHub(bufferSize));
130
+ };
131
+ var createEventHub = (bufferSize = DEFAULT_BUFFER_SIZE) => Effect.sync(() => {
132
+ const subscribers = new Map;
133
+ return {
134
+ emit: (event) => Effect.forEach(Array.from(subscribers).filter(([, accepts]) => accepts(event)), ([queue]) => Queue.offer(queue, event), { discard: true }),
135
+ subscribe: (accepts = () => true) => Effect.gen(function* () {
136
+ const queue = yield* Queue.sliding(bufferSize);
137
+ subscribers.set(queue, accepts);
138
+ const runtime = yield* Effect.context();
139
+ const run = Effect.runPromiseWith(runtime);
140
+ let closed = false;
141
+ const close = async () => {
142
+ closed = true;
143
+ subscribers.delete(queue);
144
+ await run(Queue.shutdown(queue));
145
+ };
146
+ const iterator = {
147
+ [Symbol.asyncIterator]() {
148
+ return this;
149
+ },
150
+ async next() {
151
+ if (closed)
152
+ return { done: true, value: undefined };
153
+ try {
154
+ const event = await run(Queue.take(queue));
155
+ return closed ? { done: true, value: undefined } : { done: false, value: event };
156
+ } catch (error) {
135
157
  if (closed)
136
158
  return { done: true, value: undefined };
137
159
  try {
138
- const event = await run(Queue.take(queue));
139
- return closed ? { done: true, value: undefined } : { done: false, value: event };
140
- } catch (error) {
141
- if (closed)
142
- return { done: true, value: undefined };
143
- try {
144
- await run(Effect.logError("Subscriber queue error", Cause.die(error)));
145
- } catch {}
146
- await close();
147
- throw error;
148
- }
149
- },
150
- async return() {
151
- await close();
152
- return { done: true, value: undefined };
153
- },
154
- async throw(error) {
160
+ await run(Effect.logError("Subscriber queue error", Cause.die(error)));
161
+ } catch {}
155
162
  await close();
156
163
  throw error;
157
164
  }
158
- };
159
- return iterator;
160
- })
161
- };
162
- }));
163
- };
165
+ },
166
+ async return() {
167
+ await close();
168
+ return { done: true, value: undefined };
169
+ },
170
+ async throw(error) {
171
+ await close();
172
+ throw error;
173
+ }
174
+ };
175
+ return iterator;
176
+ })
177
+ };
178
+ });
164
179
 
165
180
  // src/services/draft-process-events.ts
166
181
  var DraftProcessEventsLive = createEventHubLayer(DraftProcessEvents);
@@ -169,11 +184,12 @@ var DraftProcessEventsLive = createEventHubLayer(DraftProcessEvents);
169
184
  var ExecutionEventsLive = createEventHubLayer(ExecutionEvents);
170
185
 
171
186
  // src/services/http-cedar-reload-notifier.ts
172
- import { Cause as Cause2, Config, Effect as Effect2, Layer as Layer2, Option, Runtime as Runtime3 } from "effect";
187
+ import { Cause as Cause2, Config, Effect as Effect2, Layer as Layer2, Option } from "effect";
188
+ import { HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http";
173
189
  var HttpCedarReloadNotifierLive = Layer2.effect(CedarReloadNotifierService, Effect2.gen(function* () {
174
- const httpClient = yield* HttpClient;
175
- const runtime = yield* Effect2.runtime();
176
- const revalidateSecret = yield* Config.option(Config.string("REVALIDATE_SECRET"));
190
+ const httpClient = yield* HttpClient.HttpClient;
191
+ const runtime = yield* Effect2.context();
192
+ const revalidateSecret = yield* Config.option(Config.String("REVALIDATE_SECRET"));
177
193
  if (Option.isNone(revalidateSecret)) {
178
194
  yield* Effect2.logWarning("REVALIDATE_SECRET not configured; Cedar reloads will skip frontend cache invalidation");
179
195
  } else {
@@ -186,18 +202,18 @@ var HttpCedarReloadNotifierLive = Layer2.effect(CedarReloadNotifierService, Effe
186
202
  return;
187
203
  }
188
204
  const baseUrl = getEffectiveFrontendBaseUrl();
189
- const request = yield* post(`${baseUrl}/api/revalidate`).pipe(bodyJson({
205
+ const request = yield* HttpClientRequest.post(`${baseUrl}/api/revalidate`).pipe(HttpClientRequest.bodyJson({
190
206
  path: "/settings",
191
207
  tag: "cedar-policies",
192
208
  secret: revalidateSecret.value
193
209
  }));
194
210
  yield* Effect2.log(`Triggering frontend cache invalidation for cedar-policies and /settings at ${baseUrl}`);
195
- yield* httpClient.execute(request).pipe(Effect2.flatMap(filterStatusOk), Effect2.scoped, Effect2.matchEffect({
211
+ yield* httpClient.execute(request).pipe(Effect2.flatMap(HttpClientResponse.filterStatusOk), Effect2.scoped, Effect2.matchEffect({
196
212
  onSuccess: () => Effect2.log(`Successfully invalidated frontend cedar-policies cache and /settings at ${baseUrl}`),
197
213
  onFailure: (error) => Effect2.logWarning(`Failed to invalidate frontend cache at ${baseUrl} (non-fatal): ${error instanceof Error ? error.message : String(error)}`)
198
214
  }));
199
- }).pipe(Effect2.catchAllCause((cause) => Effect2.logWarning(`Failed to prepare frontend cache invalidation request (non-fatal): ${Cause2.pretty(cause)}`)));
200
- Runtime3.runFork(runtime, effect);
215
+ }).pipe(Effect2.catchCause((cause) => Effect2.logWarning(`Failed to prepare frontend cache invalidation request (non-fatal): ${Cause2.pretty(cause)}`)));
216
+ Effect2.runForkWith(runtime)(effect);
201
217
  }
202
218
  };
203
219
  }));
@@ -205,6 +221,32 @@ var HttpCedarReloadNotifierLive = Layer2.effect(CedarReloadNotifierService, Effe
205
221
  // src/services/process-events.ts
206
222
  var ProcessEventsLive = createEventHubLayer(ProcessEvents);
207
223
 
224
+ // src/services/project-accounting-events.ts
225
+ import { Effect as Effect3, Layer as Layer3, Option as Option2, Schedule } from "effect";
226
+ var ProjectAccountingEventsLive = Layer3.effect(ProjectAccountingEvents, Effect3.gen(function* () {
227
+ const queue = yield* QueueService;
228
+ const hub = yield* createEventHub();
229
+ const dispatch = Effect3.gen(function* () {
230
+ const claimed = yield* QueueService.claim(PROJECT_ACCOUNTING_QUEUE, ProjectAccountingChange);
231
+ if (Option2.isNone(claimed))
232
+ return;
233
+ const job = claimed.value;
234
+ yield* hub.emit(job.payload);
235
+ yield* queue.acknowledge(job.jobId, job.receipt);
236
+ });
237
+ yield* dispatch.pipe(Effect3.catchCause(Effect3.logError), Effect3.repeat(Schedule.spaced("250 millis")), Effect3.forkScoped);
238
+ return {
239
+ emit: hub.emit,
240
+ subscribe: (projectId, recipientPrincipalId, environmentId) => hub.subscribe((event) => {
241
+ if ("recipientPrincipalId" in event)
242
+ return event.recipientPrincipalId === recipientPrincipalId;
243
+ if ("deployment" in event)
244
+ return event.deployment.projectId === projectId && event.deployment.environmentId === environmentId;
245
+ return environmentId === undefined && event.projectId === projectId;
246
+ })
247
+ };
248
+ }));
249
+
208
250
  // src/services/todo-events.ts
209
251
  var TodoEventsLive = createEventHubLayer(TodoEvents);
210
252
 
@@ -215,13 +257,13 @@ import { join } from "path";
215
257
  import { parseArgs as utilParseArgs } from "util";
216
258
  import {
217
259
  Data,
218
- Effect as Effect3,
260
+ Effect as Effect4,
219
261
  Context as EffectContext,
220
262
  Exit,
221
- Layer as Layer3,
263
+ Layer as Layer4,
222
264
  Metric,
223
- Option as Option2,
224
- Schedule,
265
+ Option as Option3,
266
+ Schedule as Schedule2,
225
267
  Schema
226
268
  } from "effect";
227
269
 
@@ -376,6 +418,8 @@ function makeServer(options) {
376
418
  connectionInitWaitTimeout = 3000,
377
419
  onConnect,
378
420
  onDisconnect,
421
+ onPing,
422
+ onPong,
379
423
  onClose,
380
424
  onSubscribe,
381
425
  onOperation,
@@ -390,7 +434,7 @@ function makeServer(options) {
390
434
  const ctx = {
391
435
  connectionInitReceived: false,
392
436
  acknowledged: false,
393
- subscriptions: {},
437
+ subscriptions: /* @__PURE__ */ Object.create(null),
394
438
  extra
395
439
  };
396
440
  if (socket.protocol !== GRAPHQL_TRANSPORT_WS_PROTOCOL) {
@@ -430,14 +474,17 @@ function makeServer(options) {
430
474
  return;
431
475
  }
432
476
  case MessageType.Ping: {
433
- if (socket.onPing)
477
+ await onPing?.(ctx, message.payload);
478
+ if (socket.onPing) {
434
479
  return await socket.onPing(message.payload);
480
+ }
435
481
  await socket.send(stringifyMessage(message.payload ? { type: MessageType.Pong, payload: message.payload } : {
436
482
  type: MessageType.Pong
437
- }));
483
+ }, replacer));
438
484
  return;
439
485
  }
440
486
  case MessageType.Pong:
487
+ await onPong?.(ctx, message.payload);
441
488
  return await socket.onPong?.(message.payload);
442
489
  case MessageType.Subscribe: {
443
490
  if (!ctx.acknowledged)
@@ -559,7 +606,7 @@ function makeServer(options) {
559
606
  if (connectionInitWait)
560
607
  clearTimeout(connectionInitWait);
561
608
  const subs = { ...ctx.subscriptions };
562
- ctx.subscriptions = {};
609
+ ctx.subscriptions = /* @__PURE__ */ Object.create(null);
563
610
  await Promise.all(Object.values(subs).filter(isAsyncGenerator).map((sub) => sub.return(undefined)));
564
611
  if (ctx.acknowledged)
565
612
  await onDisconnect?.(ctx, code, reason);
@@ -653,9 +700,9 @@ class Mutex {
653
700
  }
654
701
  }
655
702
 
656
- class CallbackSecret extends EffectContext.Tag("processfocus:internal-tag/runtime-local/CallbackSecret")() {
703
+ class CallbackSecret extends EffectContext.Service()("processfocus:internal-tag/runtime-local/CallbackSecret") {
657
704
  }
658
- var CallbackSecretLive = Layer3.effect(CallbackSecret, Effect3.sync(() => Option2.fromNullable(process.env["INTERNAL_API_SECRET"])));
705
+ var CallbackSecretLive = Layer4.effect(CallbackSecret, Effect4.sync(() => Option3.fromNullishOr(process.env["INTERNAL_API_SECRET"])));
659
706
  var activeWebSocketConnections = Metric.gauge("graphql.websocket.connections.active", {
660
707
  description: "Number of active WebSocket connections (subscribers)"
661
708
  });
@@ -666,11 +713,11 @@ var activeGraphqlSubscriptions = Metric.gauge("graphql.subscriptions.active", {
666
713
  class InvalidUsageError extends Data.TaggedError("InvalidUsageError") {
667
714
  }
668
715
  var ParsedArgsSchema = Schema.Struct({
669
- port: Schema.optional(Schema.NumberFromString.pipe(Schema.int(), Schema.between(0, 65535))),
716
+ port: Schema.optional(NumberFromString.pipe(Schema.check(Schema.isInt()), Schema.check(Schema.isBetween({ minimum: 0, maximum: 65535 })))),
670
717
  org: Schema.String
671
718
  });
672
- var parseArgs = (args) => Effect3.gen(function* () {
673
- const parseResult = yield* Effect3.try({
719
+ var parseArgs = (args) => Effect4.gen(function* () {
720
+ const parseResult = yield* Effect4.try({
674
721
  try: () => utilParseArgs({
675
722
  args,
676
723
  options: {
@@ -687,19 +734,20 @@ var parseArgs = (args) => Effect3.gen(function* () {
687
734
  console.error("Error: --org is required (or set PF_ORG environment variable)");
688
735
  return yield* new InvalidUsageError({ _: undefined });
689
736
  }
690
- return yield* Schema.decodeUnknown(ParsedArgsSchema)({
737
+ return yield* Schema.decodeUnknownEffect(ParsedArgsSchema)({
691
738
  port: parseResult.values.port,
692
739
  org
693
- }).pipe(Effect3.mapError(() => new InvalidUsageError({ _: undefined })));
740
+ }).pipe(Effect4.mapError(() => new InvalidUsageError({ _: undefined })));
694
741
  });
695
- var makeServerEffect = (port) => Effect3.gen(function* () {
742
+ var makeServerEffect = (port) => Effect4.gen(function* () {
696
743
  const yoga = yield* Yoga;
697
744
  const resolverRuntime = yield* ResolverRuntime;
698
745
  const routeServerPluginWebhook = yield* makeServerPluginWebhookRouter;
699
746
  const callbackSecret = yield* CallbackSecret;
747
+ const routeMcpOAuthStorage = yield* makeMcpOAuthStorageRoute(process.env["PF_MCP_STORAGE_SECRET"]);
700
748
  const docStoreConfig = yield* LocalDocumentStoreConfig;
701
749
  const dbConnectionInfo = yield* DatabaseConnectionInfo;
702
- yield* Effect3.log(`\uD83D\uDCBE Connecting to database: ${dbConnectionInfo}`);
750
+ yield* Effect4.log(`\uD83D\uDCBE Connecting to database: ${dbConnectionInfo}`);
703
751
  const activeSubscriptions = new Map;
704
752
  let connectionCounter = 0;
705
753
  let connectionIdCounter = 0;
@@ -718,7 +766,7 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
718
766
  console.log(`
719
767
  \uD83D\uDD0C [WS #${connId}] Connection OPENED (total active: ${connectionCounter})`);
720
768
  console.log(` Timestamp: ${new Date().toISOString()}`);
721
- resolverRuntime.runFork(Metric.set(activeWebSocketConnections, connectionCounter));
769
+ resolverRuntime.runFork(Metric.update(activeWebSocketConnections, connectionCounter));
722
770
  return true;
723
771
  },
724
772
  onComplete: (ctx, id) => {
@@ -730,7 +778,7 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
730
778
  activeSubscriptions.delete(id);
731
779
  }
732
780
  console.log(`\uD83D\uDCCA [WS] Active subscriptions: ${activeSubscriptions.size}`);
733
- resolverRuntime.runFork(Metric.set(activeGraphqlSubscriptions, activeSubscriptions.size));
781
+ resolverRuntime.runFork(Metric.update(activeGraphqlSubscriptions, activeSubscriptions.size));
734
782
  },
735
783
  onSubscribe: async (ctx, id, payload) => {
736
784
  const connId = connectionToId.get(ctx) ?? 0;
@@ -743,7 +791,7 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
743
791
  \uD83D\uDCE5 [WS #${connId}] New subscription: id=${id.slice(0, 8)} operation=${payload.operationName}`);
744
792
  console.log(` Timestamp: ${new Date().toISOString()}`);
745
793
  console.log(`\uD83D\uDCCA [WS] Active subscriptions: ${activeSubscriptions.size}`);
746
- resolverRuntime.runFork(Metric.set(activeGraphqlSubscriptions, activeSubscriptions.size));
794
+ resolverRuntime.runFork(Metric.update(activeGraphqlSubscriptions, activeSubscriptions.size));
747
795
  const grouped = new Map;
748
796
  for (const [, s] of activeSubscriptions) {
749
797
  grouped.set(s.operation, (grouped.get(s.operation) || 0) + 1);
@@ -797,13 +845,16 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
797
845
  const serverOptions = {
798
846
  fetch: async (request, srv) => {
799
847
  const url = new URL(request.url);
848
+ const mcpOAuthEffect = routeMcpOAuthStorage(request);
849
+ if (mcpOAuthEffect !== undefined)
850
+ return resolverRuntime.runPromise(mcpOAuthEffect);
800
851
  const webhookEffect = routeServerPluginWebhook(request);
801
852
  if (webhookEffect !== undefined) {
802
853
  return resolverRuntime.runPromise(webhookEffect);
803
854
  }
804
855
  if (url.pathname === "/internal/todo-event" && request.method === "POST") {
805
856
  const providedSecret = request.headers.get("x-callback-secret");
806
- if (Option2.isNone(callbackSecret)) {
857
+ if (Option3.isNone(callbackSecret)) {
807
858
  return new Response("Unauthorized", { status: 401 });
808
859
  }
809
860
  if (!providedSecret || !constantTimeEqual(providedSecret, callbackSecret.value)) {
@@ -811,7 +862,7 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
811
862
  }
812
863
  const event = await request.json();
813
864
  const { schema } = yoga.getEnveloped({ req: request });
814
- const emitEffect = Effect3.flatMap(TodoEvents, (todoEvents) => todoEvents.emit(event, schema));
865
+ const emitEffect = Effect4.flatMap(TodoEvents, (todoEvents) => todoEvents.emit(event, schema));
815
866
  const result = await resolverRuntime.runPromiseExit(emitEffect);
816
867
  if (Exit.isFailure(result)) {
817
868
  console.error("Failed to process todo event callback:", result.cause);
@@ -821,7 +872,7 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
821
872
  }
822
873
  if (url.pathname === "/internal/process-event" && request.method === "POST") {
823
874
  const providedSecret = request.headers.get("x-callback-secret");
824
- if (Option2.isNone(callbackSecret)) {
875
+ if (Option3.isNone(callbackSecret)) {
825
876
  return new Response("Unauthorized", { status: 401 });
826
877
  }
827
878
  if (!providedSecret || !constantTimeEqual(providedSecret, callbackSecret.value)) {
@@ -829,7 +880,7 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
829
880
  }
830
881
  const event = await request.json();
831
882
  const { schema } = yoga.getEnveloped({ req: request });
832
- const emitEffect = Effect3.flatMap(ProcessEvents, (processEvents) => processEvents.emit(event, schema));
883
+ const emitEffect = Effect4.flatMap(ProcessEvents, (processEvents) => processEvents.emit(event, schema));
833
884
  const result = await resolverRuntime.runPromiseExit(emitEffect);
834
885
  if (Exit.isFailure(result)) {
835
886
  console.error("Failed to process process event callback:", result.cause);
@@ -839,7 +890,7 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
839
890
  }
840
891
  if (url.pathname === "/internal/execution-event" && request.method === "POST") {
841
892
  const providedSecret = request.headers.get("x-callback-secret");
842
- if (Option2.isNone(callbackSecret)) {
893
+ if (Option3.isNone(callbackSecret)) {
843
894
  return new Response("Unauthorized", { status: 401 });
844
895
  }
845
896
  if (!providedSecret || !constantTimeEqual(providedSecret, callbackSecret.value)) {
@@ -847,7 +898,7 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
847
898
  }
848
899
  const event = await request.json();
849
900
  const { schema } = yoga.getEnveloped({ req: request });
850
- const emitEffect = Effect3.flatMap(ExecutionEvents, (executionEvents) => executionEvents.emit(event, schema));
901
+ const emitEffect = Effect4.flatMap(ExecutionEvents, (executionEvents) => executionEvents.emit(event, schema));
851
902
  const result = await resolverRuntime.runPromiseExit(emitEffect);
852
903
  if (Exit.isFailure(result)) {
853
904
  console.error("Failed to process execution event callback:", result.cause);
@@ -857,7 +908,7 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
857
908
  }
858
909
  if (url.pathname === "/internal/import-completed" && request.method === "POST") {
859
910
  const providedSecret = request.headers.get("x-callback-secret");
860
- if (Option2.isNone(callbackSecret)) {
911
+ if (Option3.isNone(callbackSecret)) {
861
912
  return new Response("Unauthorized", { status: 401 });
862
913
  }
863
914
  if (!providedSecret || !constantTimeEqual(providedSecret, callbackSecret.value)) {
@@ -874,8 +925,8 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
874
925
  }
875
926
  const { processPaths } = body;
876
927
  const { schema } = yoga.getEnveloped({ req: request });
877
- const importCompletedEffect = Effect3.gen(function* () {
878
- yield* Effect3.log(`Received import-completed for ${processPaths.length} process(es): ${processPaths.join(", ")}`);
928
+ const importCompletedEffect = Effect4.gen(function* () {
929
+ yield* Effect4.log(`Received import-completed for ${processPaths.length} process(es): ${processPaths.join(", ")}`);
879
930
  const processOps = yield* ProcessCollectionOps;
880
931
  const executionOps = yield* ExecutionCollectionOps;
881
932
  const todoOps = yield* TodoCollectionOps;
@@ -883,10 +934,10 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
883
934
  const allProcessRows = yield* processOps.pull(null, 1e4);
884
935
  const matchedProcessRows = allProcessRows.filter((row) => processPaths.includes(row.path));
885
936
  if (matchedProcessRows.length === 0) {
886
- yield* Effect3.log(`No matching processes found (${allProcessRows.length} in DB, none matching requested paths)`);
937
+ yield* Effect4.log(`No matching processes found (${allProcessRows.length} in DB, none matching requested paths)`);
887
938
  return;
888
939
  }
889
- const graphqlProcesses = yield* Effect3.all(matchedProcessRows.map((row) => processOps.mapToGraphql(row)), { concurrency: "unbounded" });
940
+ const graphqlProcesses = yield* Effect4.all(matchedProcessRows.map((row) => processOps.mapToGraphql(row)), { concurrency: "unbounded" });
890
941
  const lastProcess = graphqlProcesses[graphqlProcesses.length - 1];
891
942
  if (lastProcess) {
892
943
  const processEvent = {
@@ -896,14 +947,14 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
896
947
  updatedAt: lastProcess.updatedAt
897
948
  }
898
949
  };
899
- yield* Effect3.flatMap(ProcessEvents, (processEvents) => processEvents.emit(processEvent, schema));
950
+ yield* Effect4.flatMap(ProcessEvents, (processEvents) => processEvents.emit(processEvent, schema));
900
951
  }
901
- yield* Effect3.log(`Emitted ${graphqlProcesses.length} process update(s)`);
952
+ yield* Effect4.log(`Emitted ${graphqlProcesses.length} process update(s)`);
902
953
  const matchedPaths = new Set(graphqlProcesses.map((p) => p.path));
903
954
  const allExecutionRows = yield* executionOps.pull(null, 1e4);
904
955
  const matchedExecutionRows = allExecutionRows.filter((row) => matchedPaths.has(row.execution.processPath));
905
956
  if (matchedExecutionRows.length > 0) {
906
- const graphqlExecutions = yield* Effect3.all(matchedExecutionRows.map((row) => executionOps.mapToGraphql(row).pipe(Effect3.map((document) => ({
957
+ const graphqlExecutions = yield* Effect4.all(matchedExecutionRows.map((row) => executionOps.mapToGraphql(row).pipe(Effect4.map((document) => ({
907
958
  ...document,
908
959
  startedByEmail: row.execution.startedByEmail,
909
960
  startedByRolePath: row.execution.startedByRolePath
@@ -917,16 +968,16 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
917
968
  updatedAt: lastExecution.updatedAt
918
969
  }
919
970
  };
920
- yield* Effect3.flatMap(ExecutionEvents, (executionEvents) => executionEvents.emit(executionEvent, schema));
971
+ yield* Effect4.flatMap(ExecutionEvents, (executionEvents) => executionEvents.emit(executionEvent, schema));
921
972
  }
922
- yield* Effect3.log(`Emitted ${graphqlExecutions.length} execution update(s)`);
973
+ yield* Effect4.log(`Emitted ${graphqlExecutions.length} execution update(s)`);
923
974
  }
924
975
  const matchedExecutionIds = new Set(matchedExecutionRows.map((row) => row.execution.id));
925
976
  const allTodoRows = yield* todoOps.pull(null, 1e4);
926
977
  const matchedTodoRows = allTodoRows.filter((row) => matchedExecutionIds.has(row.processExecutionId));
927
978
  if (matchedTodoRows.length > 0) {
928
979
  const matchedTodoRowsWithSummary = yield* todoSummaryComputation.enrichWithSummaries(matchedTodoRows);
929
- const graphqlTodos = yield* Effect3.all(matchedTodoRowsWithSummary.map((row) => todoOps.mapToGraphql(row)), { concurrency: "unbounded" });
980
+ const graphqlTodos = yield* Effect4.all(matchedTodoRowsWithSummary.map((row) => todoOps.mapToGraphql(row)), { concurrency: "unbounded" });
930
981
  const sortedTodos = [...graphqlTodos].sort((a, b) => {
931
982
  if (a.updatedAt !== b.updatedAt) {
932
983
  return a.updatedAt - b.updatedAt;
@@ -943,17 +994,17 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
943
994
  mode: "INCREMENTAL" /* Incremental */
944
995
  }
945
996
  };
946
- yield* Effect3.flatMap(TodoEvents, (todoEvents) => todoEvents.emit(todoEvent, schema));
997
+ yield* Effect4.flatMap(TodoEvents, (todoEvents) => todoEvents.emit(todoEvent, schema));
947
998
  }
948
- yield* Effect3.log(`Emitted ${graphqlTodos.length} todo update(s)`);
999
+ yield* Effect4.log(`Emitted ${graphqlTodos.length} todo update(s)`);
949
1000
  }
950
1001
  });
951
1002
  const result = await resolverRuntime.runPromiseExit(importCompletedEffect);
952
1003
  if (Exit.isFailure(result)) {
953
- await resolverRuntime.runPromise(Effect3.logError("Failed to process import-completed").pipe(Effect3.annotateLogs("cause", String(result.cause))));
1004
+ await resolverRuntime.runPromise(Effect4.logError("Failed to process import-completed").pipe(Effect4.annotateLogs("cause", String(result.cause))));
954
1005
  return new Response("Internal Server Error", { status: 500 });
955
1006
  }
956
- await resolverRuntime.runPromise(Effect3.log("Import-completed processing done"));
1007
+ await resolverRuntime.runPromise(Effect4.log("Import-completed processing done"));
957
1008
  return new Response(null, { status: 204 });
958
1009
  }
959
1010
  const fileCorsHeaders = {
@@ -979,14 +1030,14 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
979
1030
  if (Number.isNaN(expiresNum) || Date.now() / 1000 > expiresNum) {
980
1031
  return new Response("URL expired", { status: 403 });
981
1032
  }
982
- if (Option2.isNone(callbackSecret)) {
1033
+ if (Option3.isNone(callbackSecret)) {
983
1034
  return new Response("Unauthorized", { status: 401 });
984
1035
  }
985
1036
  const expectedToken = generateLocalDocumentStoreToken(storePrefix, fileId, expires, callbackSecret.value);
986
1037
  if (!constantTimeEqual(token, expectedToken)) {
987
1038
  return new Response("Unauthorized", { status: 401 });
988
1039
  }
989
- const fileResult = await resolverRuntime.runPromiseExit(Effect3.gen(function* () {
1040
+ const fileResult = await resolverRuntime.runPromiseExit(Effect4.gen(function* () {
990
1041
  const fileOps = yield* FileOperations;
991
1042
  return yield* fileOps.getFileWithStore(fileId);
992
1043
  }));
@@ -1066,10 +1117,10 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
1066
1117
  } catch {}
1067
1118
  return new Response(`File too large: exceeds limit of ${maxFileSize} bytes`, { status: 413, headers: fileCorsHeaders });
1068
1119
  }
1069
- const markResult = await resolverRuntime.runPromiseExit(Effect3.gen(function* () {
1120
+ const markResult = await resolverRuntime.runPromiseExit(Effect4.gen(function* () {
1070
1121
  const fileOps = yield* FileOperations;
1071
1122
  yield* fileOps.markFileUploaded(fileId, bytesWritten, contentType);
1072
- }).pipe(Effect3.retry(Schedule.exponential("100 millis").pipe(Schedule.compose(Schedule.recurs(2))))));
1123
+ }).pipe(Effect4.retry(Schedule2.exponential("100 millis").pipe((schedule) => Schedule2.max([schedule, Schedule2.recurs(2)])))));
1073
1124
  if (Exit.isFailure(markResult)) {
1074
1125
  console.error(`Failed to mark file ${fileId} as uploaded in DB:`, markResult.cause);
1075
1126
  try {
@@ -1106,7 +1157,7 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
1106
1157
  if (filename && hasInvalidDownloadFilename(filename)) {
1107
1158
  return new Response("Bad Request", { status: 400 });
1108
1159
  }
1109
- if (Option2.isNone(callbackSecret)) {
1160
+ if (Option3.isNone(callbackSecret)) {
1110
1161
  return new Response("Unauthorized", { status: 401 });
1111
1162
  }
1112
1163
  const expectedToken = generateLocalDocumentStoreToken(storePrefix, fileId, expires, callbackSecret.value, filename ?? undefined);
@@ -1145,7 +1196,11 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
1145
1196
  }
1146
1197
  return new Response;
1147
1198
  }
1148
- return yoga.fetch(request, srv);
1199
+ const response = await yoga.fetch(request, srv);
1200
+ if (response.headers.get("content-type")?.includes("text/event-stream")) {
1201
+ srv.timeout(request, 0);
1202
+ }
1203
+ return response;
1149
1204
  },
1150
1205
  websocket: {
1151
1206
  ...websocketHandler,
@@ -1161,7 +1216,7 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
1161
1216
  console.log(`
1162
1217
  \uD83D\uDD0C [WS #${connId}] Connection CLOSED: code=${code} reason=${reason} (remaining: ${connectionCounter})`);
1163
1218
  console.log(` Timestamp: ${new Date().toISOString()}`);
1164
- resolverRuntime.runFork(Metric.set(activeWebSocketConnections, connectionCounter));
1219
+ resolverRuntime.runFork(Metric.update(activeWebSocketConnections, connectionCounter));
1165
1220
  const remaining = Array.from(activeSubscriptions.entries()).filter(([, s]) => s.connectionId === connId);
1166
1221
  if (remaining.length > 0) {
1167
1222
  console.log(" \uD83E\uDDF9 Cleaning up orphaned subscriptions:", remaining.map(([id, s]) => `${id.slice(0, 8)}:${s.operation}`).join(", "));
@@ -1169,61 +1224,62 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
1169
1224
  activeSubscriptions.delete(id);
1170
1225
  }
1171
1226
  console.log(`\uD83D\uDCCA [WS] Active subscriptions: ${activeSubscriptions.size}`);
1172
- resolverRuntime.runFork(Metric.set(activeGraphqlSubscriptions, activeSubscriptions.size));
1227
+ resolverRuntime.runFork(Metric.update(activeGraphqlSubscriptions, activeSubscriptions.size));
1173
1228
  }
1174
1229
  }
1175
1230
  return websocketHandler.close?.(ws, code, reason);
1176
1231
  }
1177
1232
  }
1178
1233
  };
1179
- const serveEffect = Option2.isSome(port) ? serveOnExactPort(port.value, serverOptions) : serveWithPortFallback(DEFAULT_GRAPHQL_PORT, serverOptions);
1180
- const server = yield* Effect3.acquireRelease(serveEffect, (srv) => Effect3.promise(() => srv.stop()));
1181
- yield* Effect3.log(`\uD83D\uDE80 GraphQL server running at http://${server.hostname}:${server.port}/graphql`);
1182
- yield* Effect3.log(`\uD83D\uDD0C WebSocket subscriptions available at ws://${server.hostname}:${server.port}/graphql`);
1234
+ const serveEffect = Option3.isSome(port) ? serveOnExactPort(port.value, serverOptions) : serveWithPortFallback(DEFAULT_GRAPHQL_PORT, serverOptions);
1235
+ const server = yield* Effect4.acquireRelease(serveEffect, (srv) => Effect4.promise(() => srv.stop()));
1236
+ yield* Effect4.log(`\uD83D\uDE80 GraphQL server running at http://${server.hostname}:${server.port}/graphql`);
1237
+ yield* Effect4.log(`\uD83D\uDD0C WebSocket subscriptions available at ws://${server.hostname}:${server.port}/graphql`);
1183
1238
  return server;
1184
1239
  });
1185
1240
 
1186
1241
  // src/graphql-server/graphql-server.ts
1242
+ process.env["PF_RUNTIME_MODE"] = "local";
1187
1243
  var makeAuthorizationLayer = (policyPaths, schemaPaths) => {
1188
1244
  if (policyPaths.length > 0) {
1189
1245
  const hotReloadConfig = LocalCedarConfigHotReload("/", policyPaths, schemaPaths);
1190
- return Layer4.provideMerge(LocalCedarAuthorizationLive, hotReloadConfig);
1246
+ return LocalCedarAuthorizationLive.pipe(Layer5.provide(LocalPolicyRevisionPublisherLive), Layer5.provideMerge(hotReloadConfig));
1191
1247
  }
1192
1248
  const staticConfig = LocalCedarConfigStatic(undefined, schemaPaths);
1193
- return Layer4.provideMerge(LocalCedarAuthorizationLive, staticConfig);
1249
+ return LocalCedarAuthorizationLive.pipe(Layer5.provide(LocalPolicyRevisionPublisherLive), Layer5.provideMerge(staticConfig));
1194
1250
  };
1195
- var CliConfig = Context.GenericTag("processfocus:internal-tag/runtime-local/GraphqlServerCliConfig");
1196
- var CliConfigLive = Layer4.effect(CliConfig, parseArgs(process.argv.slice(2)).pipe(Effect4.map((args) => ({
1197
- port: Option3.fromNullable(args.port),
1251
+ var CliConfig = Context.Service("processfocus:internal-tag/runtime-local/GraphqlServerCliConfig");
1252
+ var CliConfigLive = Layer5.effect(CliConfig, parseArgs(process.argv.slice(2)).pipe(Effect5.map((args) => ({
1253
+ port: Option4.fromNullishOr(args.port),
1198
1254
  org: args.org
1199
- })), Effect4.catchAll((error) => {
1255
+ })), Effect5.catch((error) => {
1200
1256
  console.error("Invalid arguments. Usage: bun run main.ts [--port PORT | -p PORT] [--org ORG | -o ORG]");
1201
1257
  console.error(" --port, -p Exact port number (fails if in use, does not write port file)");
1202
1258
  console.error(" --org, -o Path to org project (or set PF_ORG env var)");
1203
- return Effect4.fail(error);
1259
+ return Effect5.fail(error);
1204
1260
  })));
1205
- var RequestTimeLive = Layer4.succeed(RequestTime, FiberRef.unsafeMake(DateTime.unsafeMake(0)));
1206
- var UserDetailsLive = Layer4.succeed(UserDetails, FiberRef.unsafeMake({
1261
+ var RequestTimeLive = Layer5.succeed(RequestTime, DateTime.makeUnsafe(0));
1262
+ var UserDetailsLive = Layer5.succeed(UserDetails, {
1207
1263
  by: "SYSTEM",
1208
1264
  id: null
1209
- }));
1210
- var CurrentPrincipalLive = Layer4.succeed(CurrentPrincipal, FiberRef.unsafeMake(null));
1265
+ });
1266
+ var CurrentPrincipalLive = Layer5.succeed(CurrentPrincipal, null);
1211
1267
  var businessMetricDimensions = resolveBusinessMetricDimensions({
1212
1268
  accountId: process.env["PF_AWS_ACCOUNT_ID"],
1213
1269
  project: process.env["PF_PROJECT"],
1214
1270
  environment: process.env["PF_ENV"]
1215
1271
  });
1216
- var BusinessMetricDimensionsLive = Layer4.succeed(BusinessMetricDimensions, businessMetricDimensions);
1272
+ var BusinessMetricDimensionsLive = Layer5.succeed(BusinessMetricDimensions, businessMetricDimensions);
1217
1273
  var DashboardActivityLive = process.env["PF_ANALYTICS_IDENTITY_KEY"] ? makeDashboardActivityLayer({
1218
1274
  dimensions: businessMetricDimensions,
1219
1275
  key: Redacted.make(process.env["PF_ANALYTICS_IDENTITY_KEY"] ?? ""),
1220
1276
  logsUrl: process.env["OTLP_LOGS_URL"] ?? "http://127.0.0.1:4318/v1/logs",
1221
1277
  headers: {}
1222
- }) : Layer4.empty;
1223
- var NodeSdkLive = Layer4.unwrapEffect(Effect4.gen(function* () {
1224
- const otlpMetricsUrl = yield* Config2.string("OTLP_METRICS_URL").pipe(Config2.withDefault("http://127.0.0.1:4318/v1/metrics"));
1225
- const otlpTracesUrl = yield* Config2.string("OTLP_TRACES_URL").pipe(Config2.withDefault("http://127.0.0.1:4318/v1/traces"));
1226
- return Otel.NodeSdk.layer(() => ({
1278
+ }) : Layer5.empty;
1279
+ var NodeSdkLive = Layer5.unwrap(Effect5.gen(function* () {
1280
+ const otlpMetricsUrl = yield* Config2.String("OTLP_METRICS_URL").pipe(Config2.withDefault("http://127.0.0.1:4318/v1/metrics"));
1281
+ const otlpTracesUrl = yield* Config2.String("OTLP_TRACES_URL").pipe(Config2.withDefault("http://127.0.0.1:4318/v1/traces"));
1282
+ return NodeSdk.layer(() => ({
1227
1283
  resource: {
1228
1284
  serviceName: "graphql-server",
1229
1285
  attributes: {
@@ -1244,55 +1300,71 @@ var NodeSdkLive = Layer4.unwrapEffect(Effect4.gen(function* () {
1244
1300
  }))
1245
1301
  }));
1246
1302
  }));
1247
- var main = Effect4.gen(function* () {
1303
+ var main = Effect5.gen(function* () {
1248
1304
  const cliConfig = yield* CliConfig;
1249
- const OrgProviderLayer = yield* Layer4.memoize(OrganisationProviderFromPathDev(cliConfig.org).pipe(Layer4.provide(layer2)));
1250
- const CedarPoliciesLayer = OrgCedarPoliciesProvider.pipe(Layer4.provide(OrgProviderLayer));
1251
- const orgProvider = yield* OrganisationProvider.pipe(Effect4.provide(OrgProviderLayer));
1305
+ const importDir = process.env["PF_LOCAL_GRAPHQL_IMPORT"] === "1" ? resolve(cliConfig.org, ".processfocus/local-graphql") : undefined;
1306
+ const OrgProviderLayer = (importDir ? Layer5.effect(OrganisationProvider, Effect5.gen(function* () {
1307
+ const slot = (yield* Effect5.promise(() => import(join2(importDir, "active.json")))).default;
1308
+ if (slot !== "a" && slot !== "b")
1309
+ return yield* Effect5.fail(new Error("Invalid local GraphQL import slot"));
1310
+ const loaded = yield* OrganisationProvider.pipe(Effect5.provide(OrganisationProviderFromPath(join2(importDir, slot))));
1311
+ return { ...loaded, orgPath: resolve(cliConfig.org) };
1312
+ })) : OrganisationProviderFromPathDev(cliConfig.org)).pipe(Layer5.provide(layer));
1313
+ const CedarPoliciesLayer = OrgCedarPoliciesProvider.pipe(Layer5.provide(OrgProviderLayer));
1314
+ const orgProvider = yield* OrganisationProvider.pipe(Effect5.provide(OrgProviderLayer));
1252
1315
  yield* warnIgnoredCronDeclarations(orgProvider.organisation, "local GraphQL runtime");
1253
- yield* Effect4.log(`\u2705 Loaded organisation: ${orgProvider.organisation.name}`);
1316
+ yield* Effect5.log(`\u2705 Loaded organisation: ${orgProvider.organisation.name}`);
1254
1317
  if (orgProvider.customDbLayer) {
1255
- yield* Effect4.log(`\uD83D\uDCE6 Custom database layer available from organisation`);
1318
+ yield* Effect5.log(`\uD83D\uDCE6 Custom database layer available from organisation`);
1256
1319
  }
1257
- const cedarPolicies = yield* CedarPoliciesProvider.pipe(Effect4.provide(CedarPoliciesLayer));
1258
- yield* Effect4.log(`\uD83D\uDCDC Loaded ${cedarPolicies.policyPaths.length} Cedar policy files`);
1259
- const DynamicSchemaConfigLive = Layer4.succeed(DynamicSchemaConfig, {
1320
+ const cedarPolicies = yield* CedarPoliciesProvider.pipe(Effect5.provide(CedarPoliciesLayer));
1321
+ yield* Effect5.log(`\uD83D\uDCDC Loaded ${cedarPolicies.policyPaths.length} Cedar policy files`);
1322
+ const DynamicSchemaConfigLive = Layer5.succeed(DynamicSchemaConfig, {
1260
1323
  schemaPath: orgProvider.schemaPath
1261
1324
  });
1262
1325
  const internalApiSecret = process.env["INTERNAL_API_SECRET"] ?? "dev-secret";
1263
- let resolvedServerPort = Option3.isSome(cliConfig.port) ? cliConfig.port.value : DEFAULT_GRAPHQL_PORT;
1264
- const LocalDocumentStoreConfigLive = Layer4.succeed(LocalDocumentStoreConfig, {
1326
+ let resolvedServerPort = Option4.isSome(cliConfig.port) ? cliConfig.port.value : DEFAULT_GRAPHQL_PORT;
1327
+ const LocalDocumentStoreConfigLive = Layer5.succeed(LocalDocumentStoreConfig, {
1265
1328
  baseUrl: () => `http://localhost:${resolvedServerPort}`,
1266
1329
  storagePath: `${orgProvider.orgPath}/files`,
1267
1330
  secret: internalApiSecret,
1268
1331
  maxFileSize: 100 * 1024 * 1024
1269
1332
  });
1270
1333
  const AuthorizationLive = makeAuthorizationLayer(cedarPolicies.policyPaths, cedarPolicies.schemaPaths);
1271
- const TodoSummaryComputationWithDeps = TodoSummaryComputationLive.pipe(Layer4.provide(SqliteGraphqlDbOperationsLive), Layer4.provide(OrgProviderLayer));
1272
- const SlaCalculationServiceWithDeps = SlaCalculationServiceLive.pipe(Layer4.provide(SqliteGraphqlDbOperationsLive));
1273
- const ExecutionCollectionOpsWithDeps = ExecutionCollectionOpsLive.pipe(Layer4.provide(SlaCalculationServiceWithDeps), Layer4.provide(SqliteGraphqlDbOperationsLive));
1274
- const ListExportServiceWithDeps = ListExportServiceLive.pipe(Layer4.provide(LocalDocumentStoreServiceLive), Layer4.provide(LocalDocumentStoreConfigLive), Layer4.provide(AuthorizationLive));
1334
+ const TodoSummaryComputationWithDeps = TodoSummaryComputationLive.pipe(Layer5.provide(SqliteGraphqlDbOperationsLive), Layer5.provide(OrgProviderLayer));
1335
+ const SlaCalculationServiceWithDeps = SlaCalculationServiceLive.pipe(Layer5.provide(SqliteGraphqlDbOperationsLive));
1336
+ const ExecutionCollectionOpsWithDeps = ExecutionCollectionOpsLive.pipe(Layer5.provide(SlaCalculationServiceWithDeps), Layer5.provide(SqliteGraphqlDbOperationsLive));
1337
+ const ListExportServiceWithDeps = ListExportServiceLive.pipe(Layer5.provide(LocalDocumentStoreServiceLive), Layer5.provide(LocalDocumentStoreConfigLive), Layer5.provide(AuthorizationLive));
1275
1338
  const LocalSqlClientLive = makeLocalSqlClientLayer({
1276
1339
  busy_timeout: LOCAL_SQLITE_BUSY_TIMEOUT_MS
1277
1340
  });
1278
- const customDbLayerDeps = Layer4.mergeAll(SqliteFileOperationsLive, AuthorizationLive, CurrentPrincipalLive, BusinessMetricDimensionsLive, DashboardActivityLive, RequestTimeLive).pipe(Layer4.provideMerge(TypedSqliteDrizzleLayer), Layer4.provideMerge(LocalSqlClientLive));
1279
- const customDbLayerWithDeps = orgProvider.customDbLayer ? Layer4.provide(orgProvider.customDbLayer, customDbLayerDeps) : undefined;
1280
- const HttpCedarReloadNotifierWithDeps = HttpCedarReloadNotifierLive.pipe(Layer4.provide(layer));
1281
- const SqliteQueueWithRequestContext = SqliteQueueServiceLive.pipe(Layer4.provide(Layer4.merge(RequestTimeLive, UserDetailsLive)));
1282
- const AppLayer = Layer4.mergeAll(DelegationSessionServiceIsolated.pipe(Layer4.provide(Layer4.mergeAll(SqliteAuthenticationDatabaseLive, SqliteDelegationDatabaseLive)), Layer4.provide(AuthorizationLive)), SqliteGraphqlDbOperationsLive, SqliteFileOperationsLive, SqliteFlowExecutionOperationsLive, SqliteCompletedJobOperationsLive, SqliteScheduledFlowOperationsLive, SqliteQueueWithRequestContext, DynamicSchemaConfigLive, Layer4.provide(LocalDocumentStoreServiceLive, LocalDocumentStoreConfigLive), LocalDocumentStoreConfigLive, ListExportServiceWithDeps, DraftProcessEventsLive, TodoEventsLive, ProcessEventsLive, ExecutionEventsLive, RequestTimeLive, UserDetailsLive, CurrentPrincipalLive, BusinessMetricDimensionsLive, DashboardActivityLive, AuthorizationLive, TodoSummaryComputationWithDeps, SlaCalculationServiceWithDeps, HttpCedarReloadNotifierWithDeps, Layer4.provide(DraftProcessExecutionCollectionOpsLive, SqliteGraphqlDbOperationsLive), Layer4.provide(ProcessCollectionOpsLive, SqliteGraphqlDbOperationsLive), Layer4.provide(ProcessDurationServiceLive, SqliteGraphqlDbOperationsLive), Layer4.provide(TodoCollectionOpsLive, SqliteGraphqlDbOperationsLive), ExecutionCollectionOpsWithDeps, ...customDbLayerWithDeps ? [customDbLayerWithDeps] : []).pipe(Layer4.provideMerge(OrgProviderLayer), Layer4.provideMerge(TypedSqliteDrizzleLayer), Layer4.provideMerge(LocalSqlClientLive), Layer4.provideMerge(layer));
1283
- const ServerLive = Layer4.scopedDiscard(Effect4.gen(function* () {
1341
+ const customDbLayerDeps = Layer5.mergeAll(SqliteFileOperationsLive, AuthorizationLive, CurrentPrincipalLive, BusinessMetricDimensionsLive, DashboardActivityLive, RequestTimeLive).pipe(Layer5.provideMerge(TypedSqliteDrizzleLayer), Layer5.provideMerge(LocalSqlClientLive));
1342
+ const customDbLayerWithDeps = orgProvider.customDbLayer ? Layer5.provide(orgProvider.customDbLayer, customDbLayerDeps) : undefined;
1343
+ const HttpCedarReloadNotifierWithDeps = HttpCedarReloadNotifierLive.pipe(Layer5.provide(FetchHttpClient.layer));
1344
+ const SqliteQueueWithRequestContext = LocalQueueServiceLive.pipe(Layer5.provide(Layer5.merge(RequestTimeLive, UserDetailsLive)));
1345
+ const AppLayer = Layer5.mergeAll(LocalRuntimeAuditLive, AuthenticationDelegationIdentityFactsLive.pipe(Layer5.provideMerge(SqliteAuthenticationDatabaseLive)), DelegationSessionServiceIsolated.pipe(Layer5.provide(Layer5.mergeAll(AuthenticationDelegationIdentityFactsLive.pipe(Layer5.provide(SqliteAuthenticationDatabaseLive)), SqliteDelegationDatabaseLive)), Layer5.provide(AuthorizationLive)), SqliteGraphqlDbOperationsLive, SqliteMcpOAuthRecordsLive, SqliteFileOperationsLive, SqliteFlowExecutionOperationsLive, SqliteCompletedJobOperationsLive, SqliteScheduledFlowOperationsLive, SqliteQueueWithRequestContext, DynamicSchemaConfigLive, Layer5.provide(LocalDocumentStoreServiceLive, LocalDocumentStoreConfigLive), LocalDocumentStoreConfigLive, ListExportServiceWithDeps, DraftProcessEventsLive, TodoEventsLive, ProcessEventsLive, ProjectAccountingEventsLive.pipe(Layer5.provide(SqliteQueueWithRequestContext)), ExecutionEventsLive, RequestTimeLive, UserDetailsLive, CurrentPrincipalLive, BusinessMetricDimensionsLive, DashboardActivityLive, AuthorizationLive, TodoSummaryComputationWithDeps, SlaCalculationServiceWithDeps, HttpCedarReloadNotifierWithDeps, Layer5.provide(DraftProcessExecutionCollectionOpsLive, SqliteGraphqlDbOperationsLive), Layer5.provide(ProcessCollectionOpsLive, SqliteGraphqlDbOperationsLive), Layer5.provide(ProcessDurationServiceLive, SqliteGraphqlDbOperationsLive), Layer5.provide(TodoCollectionOpsLive, SqliteGraphqlDbOperationsLive), ExecutionCollectionOpsWithDeps, ...customDbLayerWithDeps ? [customDbLayerWithDeps] : []).pipe(Layer5.provideMerge(OrgProviderLayer), Layer5.provideMerge(TypedSqliteDrizzleLayer), Layer5.provideMerge(LocalSqlClientLive), Layer5.provideMerge(FetchHttpClient.layer));
1346
+ const ServerLive = Layer5.effectDiscard(Effect5.gen(function* () {
1284
1347
  const authConfig = yield* AuthConfig;
1285
- yield* Effect4.log(`\uD83D\uDD10 Authentication server: ${authConfig.issuerUrl}`);
1348
+ yield* Effect5.log(`\uD83D\uDD10 Authentication server: ${authConfig.issuerUrl}`);
1286
1349
  const server = yield* makeServerEffect(cliConfig.port);
1287
1350
  resolvedServerPort = server.port;
1288
- if (Option3.isNone(cliConfig.port)) {
1351
+ if (Option4.isNone(cliConfig.port)) {
1289
1352
  yield* writePortFile(GRAPHQL_PORT_FILE, server.port);
1290
1353
  }
1291
- return yield* Effect4.never;
1354
+ if (importDir) {
1355
+ const fs = yield* FileSystem.FileSystem.pipe(Effect5.provide(layer));
1356
+ const ready = join2(importDir, "ready.json");
1357
+ yield* fs.writeFileString(`${ready}.tmp`, JSON.stringify({
1358
+ revision: randomUUID(),
1359
+ processPaths: orgProvider.organisation.processes().map((p) => normalizePath(p.node.path))
1360
+ }));
1361
+ yield* fs.rename(`${ready}.tmp`, ready);
1362
+ }
1363
+ return yield* Effect5.never;
1292
1364
  }));
1293
- const QueueCapabilityLive = SqliteQueueWithRequestContext.pipe(Layer4.provide(AppLayer));
1294
- const DocumentStoreCapabilityLive = LocalDocumentStoreServiceLive.pipe(Layer4.provide(LocalDocumentStoreConfigLive));
1295
- const EventPublisherCapabilityLive = Layer4.mergeAll(DraftProcessEventsLive, TodoEventsLive, ProcessEventsLive, ExecutionEventsLive).pipe(Layer4.provide(AppLayer));
1365
+ const QueueCapabilityLive = SqliteQueueWithRequestContext.pipe(Layer5.provide(AppLayer));
1366
+ const DocumentStoreCapabilityLive = LocalDocumentStoreServiceLive.pipe(Layer5.provide(LocalDocumentStoreConfigLive));
1367
+ const EventPublisherCapabilityLive = Layer5.mergeAll(DraftProcessEventsLive, TodoEventsLive, ProcessEventsLive, ProjectAccountingEventsLive.pipe(Layer5.provide(SqliteQueueWithRequestContext)), ExecutionEventsLive).pipe(Layer5.provide(AppLayer));
1296
1368
  return yield* Runtime.graphql({
1297
1369
  persistence: AppLayer,
1298
1370
  queue: QueueCapabilityLive,
@@ -1301,19 +1373,19 @@ var main = Effect4.gen(function* () {
1301
1373
  organisationLoader: OrgProviderLayer,
1302
1374
  authorization: AuthorizationLive,
1303
1375
  transport: (services) => {
1304
- const CapabilityLayer = Layer4.effectContext(Effect4.succeed(services));
1305
- const ResolverRuntimeLive = Layer4.effect(ResolverRuntime, Effect4.sync(() => ManagedRuntime.make(Layer4.merge(CapabilityLayer, LocalDelegatedRealtime.layer).pipe(Layer4.provide(NodeSdkLive)))));
1306
- const AppLive = ServerLive.pipe(Layer4.provide(YogaLive), Layer4.provide(AppSchemaBuilderLive), Layer4.provide(ResolverRuntimeLive), Layer4.provide(AuthConfigLive), Layer4.provide(CallbackSecretLive), Layer4.provide(CapabilityLayer));
1307
- return Layer4.launch(AppLive);
1376
+ const CapabilityLayer = Layer5.effectContext(Effect5.succeed(services));
1377
+ const ResolverRuntimeLive = Layer5.effect(ResolverRuntime, Effect5.sync(() => ManagedRuntime.make(Layer5.merge(CapabilityLayer, LocalDelegatedRealtime.layer).pipe(Layer5.provide(NodeSdkLive)))));
1378
+ const AppLive = ServerLive.pipe(Layer5.provide(YogaLive), Layer5.provide(AppSchemaBuilderLive), Layer5.provide(ResolverRuntimeLive), Layer5.provide(AuthConfigLive), Layer5.provide(CallbackSecretLive), Layer5.provide(CapabilityLayer));
1379
+ return Layer5.launch(AppLive);
1308
1380
  },
1309
1381
  logging: {
1310
- decorate: (effect) => effect.pipe(Logger.withMinimumLogLevel(LogLevel.Debug), Effect4.provide(Logger.pretty))
1382
+ decorate: (effect) => effect.pipe(Effect5.provideService(References.MinimumLogLevel, "Debug"), Effect5.provide(Logger.layer([Logger.consolePretty()])))
1311
1383
  }
1312
1384
  });
1313
1385
  });
1314
- Effect4.runPromiseExit(main.pipe(Effect4.scoped, Effect4.provide(CliConfigLive))).then((exit) => {
1386
+ Effect5.runPromiseExit(main.pipe(Effect5.scoped, Effect5.provide(CliConfigLive))).then((exit) => {
1315
1387
  if (Exit2.isFailure(exit)) {
1316
- console.error("GraphQL server failed to start:", Cause3.pretty(exit.cause, { renderErrorCause: true }));
1388
+ console.error("GraphQL server failed to start:", Cause3.pretty(exit.cause));
1317
1389
  process.exit(1);
1318
1390
  }
1319
1391
  });