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

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 (326) hide show
  1. package/README.md +48 -253
  2. package/dist/authentication-server.mjs +52 -84
  3. package/dist/{chunk-yhzbn4vx.js → chunk-04r0t2mb.js} +34324 -49067
  4. package/dist/chunk-727y6qkb.js +156 -0
  5. package/dist/chunk-bg5r4wpv.js +4755 -0
  6. package/dist/chunk-cbd36jq1.js +512 -0
  7. package/dist/chunk-d4ctj079.js +241 -0
  8. package/dist/{chunk-352j1ayk.js → chunk-r5s2v669.js} +51753 -36263
  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)/executions/@modal/(.)[executionId]/client.tsx +1 -1
  14. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/(.)[executionId]/page.tsx +2 -0
  15. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/(.)[executionId]/process-state/page.tsx +2 -0
  16. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/default.tsx +3 -0
  17. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/[executionId]/page.tsx +3 -1
  18. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/[executionId]/process-state/page.tsx +2 -0
  19. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/client-layout.tsx +19 -0
  20. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/default.tsx +6 -0
  21. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/executions-client.tsx +1637 -0
  22. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/layout.tsx +5 -7
  23. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/page.tsx +4 -1589
  24. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/process-state-page-client.tsx +1 -1
  25. package/dist/dashboard-source/apps/frontend/app/(protected)/layout.tsx +41 -33
  26. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/@modal/(.)item/[id]/client.tsx +11 -17
  27. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/@modal/(.)item/[id]/page.tsx +2 -0
  28. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/@modal/default.tsx +3 -0
  29. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/[...listPath]/list-page-client.tsx +145 -19
  30. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/[...listPath]/page.tsx +10 -2
  31. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-create-form.tsx +29 -13
  32. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-item-edit-form.tsx +22 -28
  33. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-item-load-error.tsx +49 -0
  34. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-schema-form.tsx +28 -0
  35. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/default.tsx +6 -0
  36. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/hooks/metric-control-url-state.ts +7 -16
  37. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/hooks/use-list-deleted-callback.ts +4 -6
  38. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/hooks/use-list-item-detail.ts +45 -142
  39. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/item/[id]/client.tsx +10 -20
  40. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/item/[id]/page.tsx +2 -0
  41. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/layout.tsx +3 -0
  42. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/lib/list-process-dialog.tsx +72 -0
  43. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/lib/list-refresh-provider.tsx +65 -0
  44. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/lib/list-refresh.ts +162 -16
  45. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/utils.tsx +19 -0
  46. package/dist/dashboard-source/apps/frontend/app/(protected)/org-chart/page.tsx +4 -9
  47. package/dist/dashboard-source/apps/frontend/app/(protected)/page.tsx +4 -0
  48. package/dist/dashboard-source/apps/frontend/app/(protected)/passkeys/actions.ts +15 -18
  49. package/dist/dashboard-source/apps/frontend/app/(protected)/passkeys/page.tsx +12 -6
  50. package/dist/dashboard-source/apps/frontend/app/(protected)/passkeys/passkeys-client.tsx +7 -16
  51. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/@modal/(.)start/[...startStepPath]/client.tsx +26 -48
  52. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/@modal/(.)start/[...startStepPath]/page.tsx +4 -7
  53. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/@modal/default.tsx +3 -0
  54. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/client-layout.tsx +28 -0
  55. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/client.tsx +1 -3
  56. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/components/start-process-form.tsx +193 -117
  57. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/default.tsx +6 -0
  58. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/layout.tsx +7 -9
  59. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/page.tsx +3 -0
  60. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/processes-client.tsx +60 -204
  61. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/start/[...startStepPath]/client.tsx +12 -51
  62. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/start/[...startStepPath]/page.tsx +27 -4
  63. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/page.tsx +5 -4
  64. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/workflow-flow.tsx +0 -5
  65. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/workflow-form-preview-sheet.tsx +26 -19
  66. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/[[...tab]]/page.tsx +5 -2
  67. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/cedar-authorize.ts +85 -9
  68. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/cedar-types.ts +12 -1
  69. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/explorer.tsx +66 -4
  70. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/layout.tsx +3 -0
  71. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/load-handbook.ts +41 -13
  72. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/[invitationId]/page.tsx +2 -0
  73. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/invitation-detail-client.tsx +442 -365
  74. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/new/page.tsx +8 -2
  75. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/page.tsx +7 -0
  76. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations-table.tsx +61 -43
  77. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/page.tsx +6 -67
  78. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/providers/page.tsx +7 -0
  79. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/roles/page.tsx +7 -0
  80. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/settings-client.tsx +111 -189
  81. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/settings-page.tsx +86 -0
  82. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/[userId]/client.tsx +141 -256
  83. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/[userId]/page.tsx +2 -0
  84. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/[userId]/tokens/page.tsx +2 -0
  85. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/page.tsx +7 -0
  86. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users-table.tsx +6 -4
  87. package/dist/dashboard-source/apps/frontend/app/(protected)/stats/[...statsPath]/page.tsx +3 -0
  88. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/@modal/(.)complete/[...stepPath]/client.tsx +30 -9
  89. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/@modal/(.)complete/[...stepPath]/page.tsx +3 -1
  90. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/@modal/default.tsx +3 -0
  91. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/complete/[...stepPath]/client.tsx +2 -4
  92. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/complete/[...stepPath]/page.tsx +3 -1
  93. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/components/complete-todo-form.tsx +47 -54
  94. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/components/public-completion-correction-form.tsx +37 -54
  95. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/components/todo-form-actions.tsx +1 -1
  96. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/correct/[...stepPath]/page.tsx +3 -1
  97. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/default.tsx +6 -0
  98. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/layout.tsx +3 -0
  99. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/lib/mobile-todo-list.ts +4 -25
  100. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/page.tsx +4 -1315
  101. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/to-dos-client.tsx +1282 -0
  102. package/dist/dashboard-source/apps/frontend/app/api/auth/callback/route.ts +81 -65
  103. package/dist/dashboard-source/apps/frontend/app/api/auth/delegation/route.ts +8 -2
  104. package/dist/dashboard-source/apps/frontend/app/api/auth/login/route.ts +0 -1
  105. package/dist/dashboard-source/apps/frontend/app/api/auth/logout/route.ts +10 -5
  106. package/dist/dashboard-source/apps/frontend/app/api/auth/passkey/start/route.ts +1 -3
  107. package/dist/dashboard-source/apps/frontend/app/api/auth/refresh/route.ts +0 -1
  108. package/dist/dashboard-source/apps/frontend/app/api/auth/revalidate-google/route.ts +68 -0
  109. package/dist/dashboard-source/apps/frontend/app/api/auth/switch-role/route.ts +1 -3
  110. package/dist/dashboard-source/apps/frontend/app/api/embed/lookup/route.ts +25 -7
  111. package/dist/dashboard-source/apps/frontend/app/api/embed/submit/route.ts +1 -2
  112. package/dist/dashboard-source/apps/frontend/app/api/public/start/[address]/route.ts +49 -0
  113. package/dist/dashboard-source/apps/frontend/app/api/public/to-dos/lookup/route.ts +4 -3
  114. package/dist/dashboard-source/apps/frontend/app/api/revalidate/route.ts +15 -4
  115. package/dist/dashboard-source/apps/frontend/app/app-shell.tsx +11 -4
  116. package/dist/dashboard-source/apps/frontend/app/cli-auth/route.ts +2 -1
  117. package/dist/dashboard-source/apps/frontend/app/embed/[...startStepPath]/embed-client.tsx +31 -18
  118. package/dist/dashboard-source/apps/frontend/app/embed/[...startStepPath]/page.tsx +5 -1
  119. package/dist/dashboard-source/apps/frontend/app/login/page.tsx +4 -4
  120. package/dist/dashboard-source/apps/frontend/app/login/passkey-button.tsx +11 -6
  121. package/dist/dashboard-source/apps/frontend/app/login/passkey-help/page.tsx +67 -0
  122. package/dist/dashboard-source/apps/frontend/app/mcp/[[...endpoint]]/route.ts +47 -0
  123. package/dist/dashboard-source/apps/frontend/app/public/form/[token]/public-todo-client.tsx +44 -25
  124. package/dist/dashboard-source/apps/frontend/app/public/start/[address]/form/page.tsx +10 -0
  125. package/dist/dashboard-source/apps/frontend/app/public/start/[address]/layout.tsx +32 -0
  126. package/dist/dashboard-source/apps/frontend/app/public/start/[address]/page-client.tsx +319 -0
  127. package/dist/dashboard-source/apps/frontend/app/public/start/[address]/page-content.tsx +41 -0
  128. package/dist/dashboard-source/apps/frontend/app/public/start/[address]/page.tsx +10 -0
  129. package/dist/dashboard-source/apps/frontend/app/public.css +1 -1
  130. package/dist/dashboard-source/apps/frontend/app/register/passkey/register-passkey-client.tsx +17 -0
  131. package/dist/dashboard-source/apps/frontend/components/DashboardSection.tsx +9 -15
  132. package/dist/dashboard-source/apps/frontend/components/Header.tsx +4 -8
  133. package/dist/dashboard-source/apps/frontend/components/anonymous-page-link.tsx +57 -0
  134. package/dist/dashboard-source/apps/frontend/components/anonymous-start-form.tsx +24 -0
  135. package/dist/dashboard-source/apps/frontend/components/app-sidebar.tsx +21 -7
  136. package/dist/dashboard-source/apps/frontend/components/auth-provider.tsx +12 -7
  137. package/dist/dashboard-source/apps/frontend/components/browser-only.tsx +19 -0
  138. package/dist/dashboard-source/apps/frontend/components/config-provider.tsx +0 -1
  139. package/dist/dashboard-source/apps/frontend/components/delegation-expiry.tsx +24 -13
  140. package/dist/dashboard-source/apps/frontend/components/form-dialog-content.tsx +22 -2
  141. package/dist/dashboard-source/apps/frontend/components/journey-timeline.tsx +52 -45
  142. package/dist/dashboard-source/apps/frontend/components/notification-bell.tsx +0 -1
  143. package/dist/dashboard-source/apps/frontend/components/sidebar-lists.tsx +0 -1
  144. package/dist/dashboard-source/apps/frontend/components/token-refresh-scheduler.tsx +38 -11
  145. package/dist/dashboard-source/apps/frontend/components/ui/sidebar.tsx +0 -1
  146. package/dist/dashboard-source/apps/frontend/components/ui/tab-pill.tsx +26 -15
  147. package/dist/dashboard-source/apps/frontend/components/workflow/step-node.tsx +0 -1
  148. package/dist/dashboard-source/apps/frontend/components/workflow/workflow-edge.tsx +5 -0
  149. package/dist/dashboard-source/apps/frontend/hooks/use-form-metadata.ts +21 -10
  150. package/dist/dashboard-source/apps/frontend/hooks/use-process-draft.ts +173 -0
  151. package/dist/dashboard-source/apps/frontend/hooks/use-weekly-execution-stats.ts +1 -3
  152. package/dist/dashboard-source/apps/frontend/lib/anonymous-page-form-values.ts +6 -0
  153. package/dist/dashboard-source/apps/frontend/lib/anonymous-page-server.ts +65 -0
  154. package/dist/dashboard-source/apps/frontend/lib/appsync-events/adapter.ts +9 -3
  155. package/dist/dashboard-source/apps/frontend/lib/appsync-events/client.ts +7 -340
  156. package/dist/dashboard-source/apps/frontend/lib/auth/client-session.ts +2 -0
  157. package/dist/dashboard-source/apps/frontend/lib/auth/delegations.ts +9 -7
  158. package/dist/dashboard-source/apps/frontend/lib/auth/google-revalidation.ts +111 -0
  159. package/dist/dashboard-source/apps/frontend/lib/auth/logout.ts +1 -1
  160. package/dist/dashboard-source/apps/frontend/lib/auth/passkeys.ts +28 -30
  161. package/dist/dashboard-source/apps/frontend/lib/auth/providers.ts +10 -0
  162. package/dist/dashboard-source/apps/frontend/lib/auth/realtime-session-token.ts +1 -0
  163. package/dist/dashboard-source/apps/frontend/lib/auth/reauthentication-state.ts +4 -4
  164. package/dist/dashboard-source/apps/frontend/lib/auth/session-admission.ts +11 -7
  165. package/dist/dashboard-source/apps/frontend/lib/auth/session.ts +27 -10
  166. package/dist/dashboard-source/apps/frontend/lib/auth/ssr-session.ts +76 -9
  167. package/dist/dashboard-source/apps/frontend/lib/auth/verify-passkey.ts +25 -3
  168. package/dist/dashboard-source/apps/frontend/lib/collections/collection-provider-factory.tsx +112 -21
  169. package/dist/dashboard-source/apps/frontend/lib/collections/draft-process-execution.ts +1 -8
  170. package/dist/dashboard-source/apps/frontend/lib/collections/execution.ts +6 -2
  171. package/dist/dashboard-source/apps/frontend/lib/collections/process-collection-provider.tsx +3 -0
  172. package/dist/dashboard-source/apps/frontend/lib/collections/process.ts +8 -2
  173. package/dist/dashboard-source/apps/frontend/lib/collections/replication-factory.ts +16 -4
  174. package/dist/dashboard-source/apps/frontend/lib/collections/todo.ts +1 -1
  175. package/dist/dashboard-source/apps/frontend/lib/effect/navigation.ts +4 -0
  176. package/dist/dashboard-source/apps/frontend/lib/effect/page-runtime.ts +29 -0
  177. package/dist/dashboard-source/apps/frontend/lib/effect/params.ts +18 -12
  178. package/dist/dashboard-source/apps/frontend/lib/effect/run-effect.ts +1 -1
  179. package/dist/dashboard-source/apps/frontend/lib/effect/runtime.ts +19 -23
  180. package/dist/dashboard-source/apps/frontend/lib/effect/services/access-token.ts +9 -12
  181. package/dist/dashboard-source/apps/frontend/lib/effect/services/authorization.ts +12 -12
  182. package/dist/dashboard-source/apps/frontend/lib/effect/services/form-validation.ts +20 -18
  183. package/dist/dashboard-source/apps/frontend/lib/effect/services/graphql.ts +32 -16
  184. package/dist/dashboard-source/apps/frontend/lib/embed-form-server.ts +35 -0
  185. package/dist/dashboard-source/apps/frontend/lib/embed-manifest.ts +10 -103
  186. package/dist/dashboard-source/apps/frontend/lib/forms/invitation.ts +43 -0
  187. package/dist/dashboard-source/apps/frontend/lib/forms/provider-user.ts +64 -0
  188. package/dist/dashboard-source/apps/frontend/lib/frontend-form-loaders.ts +40 -0
  189. package/dist/dashboard-source/apps/frontend/lib/frontend-manifest.ts +1 -33
  190. package/dist/dashboard-source/apps/frontend/lib/generated/gql/gql.ts +123 -33
  191. package/dist/dashboard-source/apps/frontend/lib/generated/gql/graphql.ts +169 -30
  192. package/dist/dashboard-source/apps/frontend/lib/generated/gql/index.ts +1 -0
  193. package/dist/dashboard-source/apps/frontend/lib/graphql/anonymous-page.ts +27 -0
  194. package/dist/dashboard-source/apps/frontend/lib/graphql/dependent-lookup-query.ts +1 -0
  195. package/dist/dashboard-source/apps/frontend/lib/graphql/list-queries.ts +34 -29
  196. package/dist/dashboard-source/apps/frontend/lib/graphql/lookup-provider.tsx +82 -10
  197. package/dist/dashboard-source/apps/frontend/lib/graphql/org-chart-operations.ts +2 -5
  198. package/dist/dashboard-source/apps/frontend/lib/graphql/queries.ts +25 -4
  199. package/dist/dashboard-source/apps/frontend/lib/graphql/server-client.ts +11 -0
  200. package/dist/dashboard-source/apps/frontend/lib/graphql/settings-queries.ts +13 -104
  201. package/dist/dashboard-source/apps/frontend/lib/graphql/user-queries.ts +11 -4
  202. package/dist/dashboard-source/apps/frontend/lib/graphql/workflow-operations.ts +1 -3
  203. package/dist/dashboard-source/apps/frontend/lib/graphql/workflow-queries.ts +1 -0
  204. package/dist/dashboard-source/apps/frontend/lib/list-detail-selection.ts +54 -0
  205. package/dist/dashboard-source/apps/frontend/lib/mcp/executions.ts +110 -0
  206. package/dist/dashboard-source/apps/frontend/lib/mcp/list-writes.ts +395 -0
  207. package/dist/dashboard-source/apps/frontend/lib/mcp/lists.ts +263 -0
  208. package/dist/dashboard-source/apps/frontend/lib/mcp/oauth.ts +900 -0
  209. package/dist/dashboard-source/apps/frontend/lib/mcp/origin.ts +42 -0
  210. package/dist/dashboard-source/apps/frontend/lib/mcp/processes.ts +436 -0
  211. package/dist/dashboard-source/apps/frontend/lib/mcp/read-tool.ts +72 -0
  212. package/dist/dashboard-source/apps/frontend/lib/mcp/result.ts +4 -0
  213. package/dist/dashboard-source/apps/frontend/lib/mcp/server.ts +71 -0
  214. package/dist/dashboard-source/apps/frontend/lib/mcp/store.ts +193 -0
  215. package/dist/dashboard-source/apps/frontend/lib/mcp/todos.ts +237 -0
  216. package/dist/dashboard-source/apps/frontend/lib/notifications/notification-preference.ts +0 -1
  217. package/dist/dashboard-source/apps/frontend/lib/notifications/todo-notification-observer.ts +0 -5
  218. package/dist/dashboard-source/apps/frontend/lib/org-chart-data.ts +0 -2
  219. package/dist/dashboard-source/apps/frontend/lib/org-identity.ts +6 -4
  220. package/dist/dashboard-source/apps/frontend/lib/organisation-form-loaders.ts +4 -0
  221. package/dist/dashboard-source/apps/frontend/lib/public-todo-form-runtime.ts +0 -1
  222. package/dist/dashboard-source/apps/frontend/lib/public-todo-model.ts +39 -139
  223. package/dist/dashboard-source/apps/frontend/lib/public-todo-server.ts +17 -16
  224. package/dist/dashboard-source/apps/frontend/lib/query-client.ts +0 -1
  225. package/dist/dashboard-source/apps/frontend/lib/todo-utils.ts +1 -77
  226. package/dist/dashboard-source/apps/frontend/lib/workflow/layout.ts +3 -7
  227. package/dist/dashboard-source/apps/frontend/next.config.ts +33 -13
  228. package/dist/dashboard-source/apps/frontend/package.json +48 -47
  229. package/dist/dashboard-source/apps/frontend/proxy.ts +72 -14
  230. package/dist/dashboard-source/modules/auth-local-cedar/src/index.ts +0 -3
  231. package/dist/dashboard-source/modules/auth-local-cedar/src/lib/auth-local-cedar.ts +165 -233
  232. package/dist/dashboard-source/modules/auth-local-cedar/src/lib/cedar-reload-notifier.ts +4 -3
  233. package/dist/dashboard-source/modules/auth-local-cedar/src/lib/config-base.ts +111 -75
  234. package/dist/dashboard-source/modules/auth-local-cedar/src/lib/policy-watcher.ts +14 -18
  235. package/dist/dashboard-source/modules/auth-policy/src/index.ts +1 -0
  236. package/dist/dashboard-source/modules/auth-policy/src/lib/auth-policy.ts +19 -37
  237. package/dist/dashboard-source/modules/auth-policy/src/lib/current-principal.ts +33 -29
  238. package/dist/dashboard-source/modules/auth-policy/src/lib/policy-revision.ts +23 -0
  239. package/dist/dashboard-source/modules/auth-policy/src/lib/types.ts +24 -49
  240. package/dist/dashboard-source/modules/auth-session/src/index.ts +4 -0
  241. package/dist/dashboard-source/modules/auth-session/src/lib/project-subscription.ts +13 -0
  242. package/dist/dashboard-source/modules/auth-session/src/lib/realtime-recipient.ts +10 -2
  243. package/dist/dashboard-source/modules/auth-session/src/lib/subjects.ts +82 -8
  244. package/dist/dashboard-source/modules/auth-session/src/lib/workload-access.ts +48 -0
  245. package/dist/dashboard-source/modules/auth-session/src/lib/workload-audit.ts +52 -0
  246. package/dist/dashboard-source/modules/aws-common/src/index.ts +0 -1
  247. package/dist/dashboard-source/modules/effect-json-logger/src/lib/effect-json-logger.ts +6 -9
  248. package/dist/dashboard-source/modules/form/src/hooks/use-local-storage.ts +5 -3
  249. package/dist/dashboard-source/modules/form/src/index.ts +1 -10
  250. package/dist/dashboard-source/modules/form/src/lib/effect-schema-form.tsx +1271 -0
  251. package/dist/dashboard-source/modules/form/src/lib/form-actions.ts +26 -0
  252. package/dist/dashboard-source/modules/form/src/lib/form-prefill.tsx +79 -0
  253. package/dist/dashboard-source/modules/form/src/lib/initial-focus.ts +31 -0
  254. package/dist/dashboard-source/modules/form/src/lib/lookup-context.tsx +18 -0
  255. package/dist/dashboard-source/modules/form/src/lib/plugin-registry.ts +4 -0
  256. package/dist/dashboard-source/modules/form/src/lib/plugin-scripts.ts +26 -0
  257. package/dist/dashboard-source/modules/form/src/lib/registered-plugin-field.tsx +57 -0
  258. package/dist/dashboard-source/modules/form/src/lib/schema-lookup.tsx +124 -0
  259. package/dist/dashboard-source/modules/form/src/lib/schema-typeahead.tsx +522 -0
  260. package/dist/dashboard-source/modules/form/src/lib/validation-logic.ts +172 -0
  261. package/dist/dashboard-source/modules/form-schema/src/index.ts +4 -1
  262. package/dist/dashboard-source/modules/form-schema/src/lib/annotation-helpers.ts +19 -14
  263. package/dist/dashboard-source/modules/form-schema/src/lib/email.ts +13 -11
  264. package/dist/dashboard-source/modules/form-schema/src/lib/field-count.ts +15 -13
  265. package/dist/dashboard-source/modules/form-schema/src/lib/form-annotations.ts +14 -0
  266. package/dist/dashboard-source/modules/form-schema/src/lib/form-presentation.ts +33 -0
  267. package/dist/dashboard-source/modules/form-schema/src/lib/form-schema.ts +186 -80
  268. package/dist/dashboard-source/modules/form-schema/src/lib/number-from-string.ts +26 -0
  269. package/dist/dashboard-source/modules/form-schema/src/lib/phone.ts +8 -7
  270. package/dist/dashboard-source/modules/form-schema/src/lib/public-completion-correction.ts +7 -0
  271. package/dist/dashboard-source/modules/form-schema/src/lib/search-lookup-items.ts +27 -0
  272. package/dist/dashboard-source/modules/form-submission-schema/src/index.ts +5 -0
  273. package/dist/dashboard-source/modules/form-submission-schema/src/lib/executable-rules.ts +379 -0
  274. package/dist/dashboard-source/modules/form-submission-schema/src/lib/form-submission-schema.ts +475 -0
  275. package/dist/dashboard-source/modules/form-submission-schema/src/lib/json-schema.ts +58 -0
  276. package/dist/dashboard-source/modules/form-submission-schema/src/lib/schema-defaults.ts +158 -0
  277. package/dist/dashboard-source/modules/form-submission-schema/src/lib/submission-utils.ts +75 -0
  278. package/dist/dashboard-source/modules/frontend-manifest/src/lib/browser-plugin-artifact.ts +46 -0
  279. package/dist/dashboard-source/modules/frontend-manifest/src/lib/frontend-manifest.ts +37 -30
  280. package/dist/dashboard-source/modules/frontend-plugin-host/src/lib/frontend-plugin-host.ts +9 -1
  281. package/dist/dashboard-source/modules/openauth/src/client.ts +25 -17
  282. package/dist/dashboard-source/modules/openauth/src/util.ts +16 -0
  283. package/dist/dashboard-source/modules/{aws-common/src/lib/project-balance-admission.ts → project-accounting/src/admission.ts} +4 -8
  284. package/dist/dashboard-source/modules/realtime-client/src/appsync-client.ts +377 -0
  285. package/dist/dashboard-source/modules/realtime-client/src/index.ts +5 -0
  286. package/dist/dashboard-source/modules/realtime-client/src/subscription-presence.ts +163 -0
  287. package/dist/dashboard-source/modules/request-time/src/lib/request-time.ts +6 -24
  288. package/dist/dashboard-source/modules/rxdb-collections/generated/execution-schema.json +28 -21
  289. package/dist/dashboard-source/modules/rxdb-collections/src/lib/rxdb-collections.ts +25 -18
  290. package/dist/dashboard-source/modules/rxdb-collections/src/lib/to-rxdb-schema.ts +60 -10
  291. package/dist/dashboard-source/modules/shadcn-components/src/index.ts +18 -2
  292. package/dist/dashboard-source/modules/shadcn-components/src/lib/date-calendar.tsx +93 -0
  293. package/dist/dashboard-source/modules/shadcn-components/src/lib/date-field.tsx +147 -48
  294. package/dist/dashboard-source/modules/shadcn-components/src/lib/date-time-display.tsx +272 -0
  295. package/dist/dashboard-source/modules/shadcn-components/src/lib/local-date-time-input.tsx +108 -0
  296. package/dist/dashboard-source/modules/shadcn-components/src/lib/lookup-field.tsx +237 -351
  297. package/dist/dashboard-source/modules/shadcn-components/src/lib/ui/popover.tsx +2 -1
  298. package/dist/dashboard-source.json +48 -47
  299. package/dist/graphql-server.mjs +245 -200
  300. package/dist/job-worker-supervisor.mjs +262 -0
  301. package/dist/job-worker.mjs +234 -133
  302. package/dist/main.mjs +23 -4
  303. package/dist/prepare-dashboard.mjs +8 -8
  304. package/dist/resources/cedar/policies.cedar +80 -38
  305. package/dist/resources/cedar/schema.cedarschema +39 -21
  306. package/dist/resources/graphql-schema/rxdb.graphql +2 -0
  307. package/dist/resources/graphql-schema/system.graphql +190 -51
  308. package/package.json +64 -62
  309. package/dist/chunk-6ntmymmx.js +0 -85
  310. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/utils.ts +0 -20
  311. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/components/process-form-actions.tsx +0 -105
  312. package/dist/dashboard-source/apps/frontend/hooks/use-draft-process-save.ts +0 -189
  313. package/dist/dashboard-source/apps/frontend/hooks/use-draft-state.ts +0 -79
  314. package/dist/dashboard-source/apps/frontend/hooks/use-processes-query.ts +0 -56
  315. package/dist/dashboard-source/modules/form/src/lib/ajv-standard-schema.ts +0 -152
  316. package/dist/dashboard-source/modules/form/src/lib/client-components-to-form.tsx +0 -1421
  317. package/dist/dashboard-source/modules/form/src/lib/friendly-validation-message.ts +0 -85
  318. package/dist/dashboard-source/modules/form/src/lib/walker.tsx +0 -1549
  319. package/dist/dashboard-source/modules/form-client-representation/src/lib/client-form-definition.ts +0 -440
  320. package/dist/dashboard-source/modules/form-client-representation/src/lib/plugin-registry.ts +0 -13
  321. package/dist/dashboard-source/modules/form-client-representation/src/lib/types.ts +0 -336
  322. package/dist/dashboard-source/modules/form-rule/src/index.ts +0 -21
  323. package/dist/dashboard-source/modules/form-rule/src/lib/evaluator.ts +0 -531
  324. package/dist/dashboard-source/modules/form-rule/src/lib/paths.ts +0 -102
  325. package/dist/dashboard-source/modules/form-rule/src/lib/types.ts +0 -121
  326. package/dist/dashboard-source/modules/form-schema/src/lib/property-signature.ts +0 -45
@@ -1,19 +1,6 @@
1
1
  // @bun
2
2
  import {
3
3
  layer,
4
- ExecutorError,
5
- ExecutorHost,
6
- FileResolutionHost,
7
- DEFAULT_VISIBILITY_TIMEOUT,
8
- QueueService,
9
- jobHandler,
10
- makeJobDispatcher,
11
- Runtime,
12
- makeServerPluginJobLayer,
13
- SqlClient,
14
- CurrentPrincipal,
15
- RequestTime,
16
- layer2,
17
4
  ConditionEvaluator,
18
5
  makeConditionEvaluator,
19
6
  ForEachItemsResolver,
@@ -27,7 +14,50 @@ import {
27
14
  makeSystemStepExecutor,
28
15
  CedarPoliciesProvider,
29
16
  OrgCedarPoliciesProvider,
17
+ LocalCedarConfigStatic,
18
+ LocalCedarConfigHotReload,
19
+ LocalCedarAuthorizationLive,
20
+ TodoSummaryComputationLive,
21
+ SlaCalculationServiceLive,
22
+ ExecutionCollectionOps,
23
+ ExecutionCollectionOpsLive,
24
+ ProcessCollectionOps,
25
+ ProcessCollectionOpsLive,
26
+ TodoCollectionOpsLive,
27
+ warnIgnoredCronDeclarations,
28
+ getEffectiveFrontendBaseUrl,
29
+ LocalDocumentStoreConfig,
30
+ LocalDocumentStoreServiceLive,
31
+ ExecutionFromJobPublishError,
32
+ ExecutionFromJobPublisher,
33
+ executionEventHandler,
34
+ ScheduledFlowNotFoundError,
35
+ flowExecutionHandler,
36
+ notificationDeliveryHandler,
37
+ ProcessFromJobPublishError,
38
+ ProcessFromJobPublisher,
39
+ processEventHandler,
40
+ systemStepExecutionHandler,
41
+ TodoFromJobPublishError,
42
+ TodoFromJobPublisher,
43
+ todoEventHandler,
44
+ makeNotificationDeliveryConfig,
45
+ LoggingEmailSenderLive,
46
+ buildTodoChangeEvent,
47
+ LocalQueueServiceLive
48
+ } from "./chunk-r5s2v669.js";
49
+ import {
50
+ ExecutorError,
51
+ ExecutorHost,
52
+ FileResolutionHost,
53
+ DEFAULT_VISIBILITY_TIMEOUT,
54
+ QueueService,
55
+ jobHandler,
56
+ makeJobDispatcher,
57
+ Runtime,
58
+ makeServerPluginJobLayer,
30
59
  LOCAL_SQLITE_BUSY_TIMEOUT_MS,
60
+ CurrentPrincipal,
31
61
  sql,
32
62
  eq,
33
63
  and,
@@ -43,64 +73,43 @@ import {
43
73
  FLOW_EXECUTION_QUEUE,
44
74
  TODO_EVENT_QUEUE,
45
75
  PROCESS_EVENT_QUEUE,
76
+ PROCESS_IMPORT_OUTBOX_QUEUE,
46
77
  EXECUTION_EVENT_QUEUE,
47
78
  SYSTEM_STEP_EXECUTION_QUEUE,
48
79
  NOTIFICATION_DELIVERY_QUEUE,
49
80
  UserDetails,
81
+ makeLocalSqlClientLayer
82
+ } from "./chunk-04r0t2mb.js";
83
+ import {
84
+ DEFAULT_GRAPHQL_PORT,
85
+ GRAPHQL_PORT_FILE,
86
+ decodePortFromFileContent
87
+ } from "./chunk-cbd36jq1.js";
88
+ import {
89
+ RequestTime,
50
90
  SqliteCompletedJobOperationsLive,
51
91
  SqliteFileOperationsLive,
52
92
  SqliteFlowExecutionOperationsLive,
53
93
  SqliteGraphqlDbOperationsLive,
54
94
  SqliteScheduledFlowOperationsLive,
55
- DEFAULT_GRAPHQL_PORT,
56
- GRAPHQL_PORT_FILE,
57
- decodePortFromFileContent,
58
- makeLocalSqlClientLayer,
59
- LocalCedarConfigStatic,
60
- LocalCedarConfigHotReload,
61
- LocalCedarAuthorizationLive
62
- } from "./chunk-yhzbn4vx.js";
95
+ SqliteQueueMaintenance
96
+ } from "./chunk-bg5r4wpv.js";
63
97
  import {
64
- HttpClient,
65
- post,
66
- setHeader,
67
- bodyJson,
68
- filterStatusOk,
69
- TodoSummaryComputationLive,
70
- SlaCalculationServiceLive,
71
- ExecutionCollectionOps,
72
- ExecutionCollectionOpsLive,
73
- ProcessCollectionOps,
74
- ProcessCollectionOpsLive,
75
- TodoCollectionOpsLive,
76
- SqliteQueueServiceLive,
77
- warnIgnoredCronDeclarations,
78
- getEffectiveFrontendBaseUrl,
79
- LocalDocumentStoreConfig,
80
- LocalDocumentStoreServiceLive,
81
- ScheduledFlowNotFoundError,
82
- ExecutionFromJobPublishError,
83
- ExecutionFromJobPublisher,
84
- executionEventHandler,
85
- makeNotificationDeliveryConfig,
86
- flowExecutionHandler,
87
- LoggingEmailSenderLive,
88
- notificationDeliveryHandler,
89
- ProcessFromJobPublishError,
90
- ProcessFromJobPublisher,
91
- processEventHandler,
92
- systemStepExecutionHandler,
93
- TodoFromJobPublishError,
94
- TodoFromJobPublisher,
95
- todoEventHandler,
96
- buildTodoChangeEvent
97
- } from "./chunk-352j1ayk.js";
98
+ AttemptEscalation,
99
+ readAttemptPolicy,
100
+ boundedQueueOperation,
101
+ runLocalAttempt,
102
+ readQueueObservationPolicy,
103
+ observeQueueHealth,
104
+ reportWorkerActivity,
105
+ startWorkerHeartbeat
106
+ } from "./chunk-d4ctj079.js";
98
107
 
99
108
  // src/job-worker/job-worker.ts
100
109
  import { existsSync as existsSync4 } from "fs";
101
110
  import { join as join2 } from "path";
102
111
  import { parseArgs as utilParseArgs } from "util";
103
- import * as Otel from "@effect/opentelemetry";
112
+ import * as NodeSdk from "@effect/opentelemetry/NodeSdk";
104
113
  import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-http";
105
114
  import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
106
115
  import { PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics";
@@ -111,12 +120,13 @@ import {
111
120
  DateTime as DateTime2,
112
121
  Effect as Effect8,
113
122
  Exit,
114
- FiberRef as FiberRef2,
115
123
  Layer as Layer6,
116
- LogLevel,
117
124
  Logger,
118
- Schema as Schema2
125
+ References,
126
+ Schema as Schema2,
127
+ Semaphore
119
128
  } from "effect";
129
+ import { FetchHttpClient } from "effect/http";
120
130
 
121
131
  // src/services/docker-file-resolver.ts
122
132
  import { Effect, Layer } from "effect";
@@ -131,7 +141,7 @@ import { existsSync } from "fs";
131
141
  import { mkdtemp, readFile, rm, writeFile } from "fs/promises";
132
142
  import { homedir, tmpdir } from "os";
133
143
  import { join, resolve } from "path";
134
- import { Data, Effect as Effect2, Either, Layer as Layer2, Schema } from "effect";
144
+ import { Data, Effect as Effect2, Layer as Layer2, Result, Schema } from "effect";
135
145
  var localInternalApiSecret = process.env["INTERNAL_API_SECRET"] ?? "dev-secret";
136
146
  var MAX_TAIL = 16384;
137
147
  var trimTail = (value) => value.length <= MAX_TAIL ? value : value.slice(value.length - MAX_TAIL);
@@ -159,7 +169,7 @@ var buildImageTag = (stepPath) => {
159
169
  return `pf-docker-step-${suffix}`;
160
170
  };
161
171
  var resolveDockerfilePath = (contextPath, dockerfile) => resolve(contextPath, dockerfile);
162
- var JsonValue = Schema.parseJson(Schema.Unknown);
172
+ var JsonValue = Schema.fromJsonString(Schema.Unknown);
163
173
 
164
174
  class DockerStepResultParseError extends Data.TaggedError("DockerStepResultParseError") {
165
175
  }
@@ -171,7 +181,7 @@ var parseResult = (resultPath) => Effect2.gen(function* () {
171
181
  cause
172
182
  })
173
183
  });
174
- return yield* Schema.decodeUnknown(JsonValue)(resultText).pipe(Effect2.map((result) => result), Effect2.mapError((cause) => new DockerStepResultParseError({
184
+ return yield* Schema.decodeUnknownEffect(JsonValue)(resultText).pipe(Effect2.map((result) => result), Effect2.mapError((cause) => new DockerStepResultParseError({
175
185
  message: "Failed to parse Docker step result envelope",
176
186
  cause
177
187
  })));
@@ -203,7 +213,7 @@ var acquireDockerStepWorkDir = Effect2.acquireRelease(Effect2.tryPromise({
203
213
  }), (hostWorkDir) => Effect2.tryPromise({
204
214
  try: () => rm(hostWorkDir, { recursive: true, force: true }),
205
215
  catch: (cause) => cause
206
- }).pipe(Effect2.catchAll((cause) => Effect2.logWarning("Failed to clean up Docker step work directory", {
216
+ }).pipe(Effect2.catch((cause) => Effect2.logWarning("Failed to clean up Docker step work directory", {
207
217
  hostWorkDir,
208
218
  error: String(cause)
209
219
  }))));
@@ -217,7 +227,7 @@ var makeLocalExecutorHostLayer = (orgPath, options) => {
217
227
  const hostWorkDir = yield* acquireDockerStepWorkDir;
218
228
  const inputPath = join(hostWorkDir, "input.json");
219
229
  const resultPath = join(hostWorkDir, "result.json");
220
- const encodedInput = yield* Schema.encode(JsonValue)(invocation.input).pipe(Effect2.mapError((cause) => new ExecutorError({
230
+ const encodedInput = yield* Schema.encodeEffect(JsonValue)(invocation.input).pipe(Effect2.mapError((cause) => new ExecutorError({
221
231
  message: "Failed to encode Docker step input manifest",
222
232
  cause
223
233
  })));
@@ -297,12 +307,12 @@ var makeLocalExecutorHostLayer = (orgPath, options) => {
297
307
  cause: error
298
308
  })
299
309
  });
300
- const resultEither = yield* Effect2.either(parseResult(resultPath).pipe(Effect2.mapError((error) => new DockerStepResultParseError({
310
+ const resultEither = yield* Effect2.result(parseResult(resultPath).pipe(Effect2.mapError((error) => new DockerStepResultParseError({
301
311
  message: `Failed to parse Docker step result for ${jobContext.stepPath}: ${String(error)}`,
302
312
  cause: error
303
313
  }))));
304
314
  if (runResult.exitCode !== 0) {
305
- const result = Either.isRight(resultEither) ? resultEither.right : undefined;
315
+ const result = Result.isSuccess(resultEither) ? resultEither.success : undefined;
306
316
  return yield* new ExecutorError({
307
317
  message: formatFailureMessage({
308
318
  title: `Docker step ${jobContext.stepPath} failed`,
@@ -315,10 +325,10 @@ var makeLocalExecutorHostLayer = (orgPath, options) => {
315
325
  })
316
326
  });
317
327
  }
318
- if (Either.isLeft(resultEither)) {
328
+ if (Result.isFailure(resultEither)) {
319
329
  return yield* new ExecutorError({
320
330
  message: formatFailureMessage({
321
- title: resultEither.left.message,
331
+ title: resultEither.failure.message,
322
332
  error: undefined,
323
333
  exitCode: runResult.exitCode,
324
334
  stderrTail: undefined,
@@ -326,10 +336,10 @@ var makeLocalExecutorHostLayer = (orgPath, options) => {
326
336
  stderr: runResult.stderr,
327
337
  stdout: runResult.stdout
328
338
  }),
329
- cause: resultEither.left
339
+ cause: resultEither.failure
330
340
  });
331
341
  }
332
- const result = resultEither.right;
342
+ const result = resultEither.success;
333
343
  if (result.status !== "success") {
334
344
  return yield* new ExecutorError({
335
345
  message: formatFailureMessage({
@@ -353,6 +363,8 @@ var makeLocalExecutorHostLayer = (orgPath, options) => {
353
363
 
354
364
  // src/services/http-execution-from-job-publisher.ts
355
365
  import { Array as Arr, Config as Config2, Effect as Effect4, Layer as Layer3 } from "effect";
366
+ import { HttpClient } from "effect/http";
367
+ import { SqlClient } from "effect/sql";
356
368
 
357
369
  // src/services/graphql-server-config.ts
358
370
  import { existsSync as existsSync2, readFileSync } from "fs";
@@ -372,30 +384,34 @@ var readGraphqlPort = (reader = defaultGraphqlPortFileReader) => {
372
384
  return DEFAULT_GRAPHQL_PORT;
373
385
  }
374
386
  };
375
- var GraphqlServerUrl = Config.string("GRAPHQL_SERVER_URL").pipe(Config.orElse(() => Config.sync(() => {
387
+ var GraphqlServerUrl = Config.String("GRAPHQL_SERVER_URL").pipe(Config.orElse(() => Config.succeed(undefined).pipe(Config.map(() => {
376
388
  const port = readGraphqlPort();
377
389
  return `http://localhost:${port}`;
378
- })));
390
+ }))));
379
391
 
380
392
  // src/services/post-internal-event.ts
381
393
  import { Effect as Effect3, Option } from "effect";
394
+ import {
395
+ HttpClientRequest,
396
+ HttpClientResponse
397
+ } from "effect/http";
382
398
  var postInternalEvent = (httpClient, baseUrl, path, event, callbackSecret, wrapError) => Effect3.gen(function* () {
383
- let request = post(`${baseUrl}${path}`);
384
- request = yield* bodyJson(request, event).pipe(Effect3.mapError(wrapError));
399
+ let request = HttpClientRequest.post(`${baseUrl}${path}`);
400
+ request = yield* HttpClientRequest.bodyJson(request, event).pipe(Effect3.mapError(wrapError));
385
401
  request = Option.match(callbackSecret, {
386
402
  onNone: () => request,
387
- onSome: (secret) => setHeader(request, "x-callback-secret", secret)
403
+ onSome: (secret) => HttpClientRequest.setHeader(request, "x-callback-secret", secret)
388
404
  });
389
- yield* httpClient.execute(request).pipe(Effect3.flatMap(filterStatusOk), Effect3.mapError(wrapError), Effect3.asVoid);
405
+ yield* httpClient.execute(request).pipe(Effect3.flatMap(HttpClientResponse.filterStatusOk), Effect3.mapError(wrapError), Effect3.asVoid);
390
406
  });
391
407
 
392
408
  // src/services/http-execution-from-job-publisher.ts
393
409
  var HttpExecutionFromJobPublisherLive = Layer3.effect(ExecutionFromJobPublisher, Effect4.gen(function* () {
394
410
  const executionOps = yield* ExecutionCollectionOps;
395
- const httpClient = yield* HttpClient;
411
+ const httpClient = yield* HttpClient.HttpClient;
396
412
  const userDetails = yield* UserDetails;
397
- const sqlClient = yield* SqlClient;
398
- const callbackSecret = yield* Config2.option(Config2.string("INTERNAL_API_SECRET"));
413
+ const sqlClient = yield* SqlClient.SqlClient;
414
+ const callbackSecret = yield* Config2.option(Config2.String("INTERNAL_API_SECRET"));
399
415
  const baseUrl = yield* GraphqlServerUrl;
400
416
  return {
401
417
  publishExecutionChanged: (executionId) => Effect4.gen(function* () {
@@ -410,7 +426,7 @@ var HttpExecutionFromJobPublisherLive = Layer3.effect(ExecutionFromJobPublisher,
410
426
  executionId,
411
427
  cause
412
428
  })));
413
- if (!Arr.isNonEmptyReadonlyArray(graphqlExecutions)) {
429
+ if (!Arr.isReadonlyArrayNonEmpty(graphqlExecutions)) {
414
430
  return "skipped-not-found";
415
431
  }
416
432
  const lastExecution = Arr.lastNonEmpty(graphqlExecutions);
@@ -432,11 +448,12 @@ var HttpExecutionFromJobPublisherLive = Layer3.effect(ExecutionFromJobPublisher,
432
448
 
433
449
  // src/services/http-process-from-job-publisher.ts
434
450
  import { Array as Arr2, Config as Config3, Effect as Effect5, Layer as Layer4 } from "effect";
451
+ import { HttpClient as HttpClient2 } from "effect/http";
435
452
  var HttpProcessFromJobPublisherLive = Layer4.effect(ProcessFromJobPublisher, Effect5.gen(function* () {
436
453
  const processOps = yield* ProcessCollectionOps;
437
- const httpClient = yield* HttpClient;
454
+ const httpClient = yield* HttpClient2.HttpClient;
438
455
  const userDetails = yield* UserDetails;
439
- const callbackSecret = yield* Config3.option(Config3.string("INTERNAL_API_SECRET"));
456
+ const callbackSecret = yield* Config3.option(Config3.String("INTERNAL_API_SECRET"));
440
457
  const baseUrl = yield* GraphqlServerUrl;
441
458
  return {
442
459
  publishProcessChanged: (processId) => Effect5.gen(function* () {
@@ -448,7 +465,7 @@ var HttpProcessFromJobPublisherLive = Layer4.effect(ProcessFromJobPublisher, Eff
448
465
  processId,
449
466
  cause
450
467
  })));
451
- if (!Arr2.isNonEmptyReadonlyArray(graphqlProcesses)) {
468
+ if (!Arr2.isReadonlyArrayNonEmpty(graphqlProcesses)) {
452
469
  return "skipped-not-found";
453
470
  }
454
471
  const lastProcess = Arr2.lastNonEmpty(graphqlProcesses);
@@ -470,9 +487,10 @@ var HttpProcessFromJobPublisherLive = Layer4.effect(ProcessFromJobPublisher, Eff
470
487
 
471
488
  // src/services/http-todo-from-job-publisher.ts
472
489
  import { Config as Config4, Effect as Effect6, Layer as Layer5 } from "effect";
490
+ import { HttpClient as HttpClient3 } from "effect/http";
473
491
  var HttpTodoFromJobPublisherLive = Layer5.effect(TodoFromJobPublisher, Effect6.gen(function* () {
474
- const httpClient = yield* HttpClient;
475
- const callbackSecret = yield* Config4.option(Config4.string("INTERNAL_API_SECRET"));
492
+ const httpClient = yield* HttpClient3.HttpClient;
493
+ const callbackSecret = yield* Config4.option(Config4.String("INTERNAL_API_SECRET"));
476
494
  const baseUrl = yield* GraphqlServerUrl;
477
495
  return {
478
496
  publishTodosCreated: (todos) => Effect6.gen(function* () {
@@ -498,7 +516,6 @@ import {
498
516
  Duration as D,
499
517
  DateTime,
500
518
  Effect as Effect7,
501
- FiberRef,
502
519
  Metric,
503
520
  Option as Option2,
504
521
  Random,
@@ -516,7 +533,7 @@ var MAX_POLL_JITTER = D.millis(100);
516
533
  var MAX_SUCCESS_DELAY_JITTER = D.millis(50);
517
534
  var PAUSED_POLL_DELAY = D.millis(100);
518
535
  var MAX_PAUSED_POLL_JITTER = D.millis(25);
519
- var SQLITE_BUSY_RETRY_SCHEDULE = Schedule.addDelay(Schedule.recurs(4), () => D.millis(50));
536
+ var SQLITE_BUSY_RETRY_SCHEDULE = Schedule.addDelay(Schedule.recurs(4), () => Effect7.succeed(D.millis(50)));
520
537
  var getLocalQueueSuccessDelay = () => {
521
538
  const configuredDelayMs = process.env["PF_LOCAL_QUEUE_SUCCESS_DELAY_MS"];
522
539
  if (!configuredDelayMs) {
@@ -553,7 +570,7 @@ var writeLocalQueueWorkerState = (state) => Effect7.try({
553
570
  return true;
554
571
  },
555
572
  catch: (error) => error instanceof Error ? error : new Error(String(error))
556
- }).pipe(Effect7.catchAll((error) => Effect7.logWarning("Failed to write local queue worker state", {
573
+ }).pipe(Effect7.catch((error) => Effect7.logWarning("Failed to write local queue worker state", {
557
574
  error: String(error)
558
575
  }).pipe(Effect7.as(false))));
559
576
  var isSqliteBusy = (error) => {
@@ -632,11 +649,11 @@ var jobsProcessed = Metric.counter("jobs.processed", {
632
649
  var jobsFailed = Metric.counter("jobs.failed", {
633
650
  description: "Number of jobs that failed"
634
651
  });
635
- var claimNextLocalJob = (queueNames) => Effect7.gen(function* () {
652
+ var claimNextLocalJob = (queueNames, visibilityTimeout = DEFAULT_VISIBILITY_TIMEOUT) => Effect7.gen(function* () {
636
653
  const db = yield* TypedSqliteDrizzle;
637
654
  const now = yield* DateTime.now;
638
655
  const lockedUntil = DateTime.add(now, {
639
- millis: D.toMillis(DEFAULT_VISIBILITY_TIMEOUT)
656
+ milliseconds: D.toMillis(visibilityTimeout)
640
657
  });
641
658
  const receipt = randomUUID();
642
659
  const claimOrder = [
@@ -644,7 +661,7 @@ var claimNextLocalJob = (queueNames) => Effect7.gen(function* () {
644
661
  desc(jobQueue.availableAt),
645
662
  desc(jobQueue.id)
646
663
  ];
647
- const availableJobConditions = and(inArray(jobQueue.queue, queueNames), lte(jobQueue.availableAt, now), or(isNull(jobQueue.lockedUntil), lte(jobQueue.lockedUntil, now)), lt(jobQueue.jobAttempts, jobQueue.jobRetryLimit), eq(jobQueue._deleted, false));
664
+ const availableJobConditions = and(isNull(jobQueue.terminalAt), inArray(jobQueue.queue, queueNames), lte(jobQueue.availableAt, now), or(isNull(jobQueue.lockedUntil), lte(jobQueue.lockedUntil, now)), lt(jobQueue.jobAttempts, jobQueue.jobRetryLimit), eq(jobQueue._deleted, false));
648
665
  const candidate = yield* db.select({ id: jobQueue.id }).from(jobQueue).where(availableJobConditions).orderBy(...claimOrder).limit(1).pipe(retrySqliteBusy);
649
666
  const candidateRow = candidate[0];
650
667
  if (candidateRow === undefined) {
@@ -678,21 +695,26 @@ var claimNextLocalJob = (queueNames) => Effect7.gen(function* () {
678
695
  lockedUntil
679
696
  });
680
697
  });
681
- var processClaimedJob = (job, queueHandlers) => Effect7.gen(function* () {
698
+ var processClaimedJob = (job, queueHandlers, policy, onEscalation = () => {}) => Effect7.flatMap(DateTime.now, (now) => Effect7.gen(function* () {
682
699
  const queueService = yield* QueueService;
683
- const requestTimeFiberRef = yield* RequestTime;
684
- const now = yield* DateTime.now;
685
- yield* FiberRef.set(requestTimeFiberRef, now);
700
+ const queueOperation = (operation, phase) => policy === undefined ? operation : boundedQueueOperation(operation, policy, new AttemptEscalation({
701
+ kind: "supervision-required",
702
+ jobId: job.jobId,
703
+ receipt: job.receipt,
704
+ phase,
705
+ executionDeadline: DateTime.formatIso(DateTime.makeUnsafe(DateTime.toEpochMillis(job.lockedUntil) - policy.visibilityMs + policy.executionMs)),
706
+ outcome: "unknown"
707
+ }), onEscalation);
686
708
  yield* Effect7.log(`Processing job ${job.jobId} (attempt ${job.attempts})`);
687
709
  const dispatcher = makeJobDispatcher(queueHandlers);
688
710
  const result = yield* Runtime.job(dispatcher, job);
689
711
  if (result.kind === "acknowledge") {
690
- yield* queueService.acknowledge(job.jobId, job.receipt).pipe(Effect7.tapErrorCause((cause) => Effect7.gen(function* () {
712
+ yield* queueOperation(queueService.acknowledge(job.jobId, job.receipt), "acknowledge").pipe(Effect7.tapCause((cause) => Effect7.gen(function* () {
691
713
  const message = Cause.pretty(cause);
692
714
  yield* Effect7.logError(`Job ${job.jobId} acknowledgement failed: ${message}`);
693
715
  yield* Effect7.annotateCurrentSpan("job.failed", true);
694
716
  yield* Effect7.annotateCurrentSpan("job.error", message);
695
- yield* Metric.increment(jobsFailed);
717
+ yield* Metric.update(jobsFailed, 1);
696
718
  })), Effect7.withSpan(`job.acknowledge.${job.queue}`, {
697
719
  attributes: {
698
720
  "job.id": job.jobId,
@@ -700,14 +722,14 @@ var processClaimedJob = (job, queueHandlers) => Effect7.gen(function* () {
700
722
  "job.attempts": job.attempts
701
723
  }
702
724
  }));
703
- yield* Metric.increment(jobsProcessed);
725
+ yield* Metric.update(jobsProcessed, 1);
704
726
  return;
705
727
  }
706
- const failure = Cause.failureOption(result.cause);
707
- if (Cause.isInterruptedOnly(result.cause)) {
728
+ const failure = Cause.findErrorOption(result.cause);
729
+ if (Cause.hasInterruptsOnly(result.cause)) {
708
730
  return yield* Effect7.interrupt;
709
731
  }
710
- if (Option2.isSome(failure) && failure.value instanceof ScheduledFlowNotFoundError) {
732
+ if (Option2.isSome(failure) && failure.value instanceof ScheduledFlowNotFoundError && job.attempts < job.maxAttempts) {
711
733
  yield* Effect7.logInfo(`Job ${job.jobId} will retry: scheduled flow not yet visible`, {
712
734
  scheduledFlowId: failure.value.scheduledFlowId,
713
735
  attempt: job.attempts,
@@ -716,15 +738,19 @@ var processClaimedJob = (job, queueHandlers) => Effect7.gen(function* () {
716
738
  return;
717
739
  }
718
740
  yield* Effect7.logError(`Job ${job.jobId} failed: ${Cause.pretty(result.cause)}`);
719
- yield* Metric.increment(jobsFailed);
741
+ yield* Metric.update(jobsFailed, 1);
720
742
  if (result.kind === "terminal") {
721
- yield* queueService.fail(job.jobId, job.receipt, { retryable: false });
722
- } else if (Option2.isSome(failure)) {
723
- yield* queueService.fail(job.jobId, job.receipt, {
724
- releaseImmediately: false
725
- });
743
+ yield* queueOperation(queueService.fail(job.jobId, job.receipt, {
744
+ retryable: false,
745
+ reason: Cause.pretty(result.cause)
746
+ }), "terminal-fail");
747
+ } else {
748
+ yield* queueOperation(queueService.fail(job.jobId, job.receipt, {
749
+ releaseImmediately: false,
750
+ reason: Cause.pretty(result.cause)
751
+ }), "retry-fail");
726
752
  }
727
- });
753
+ }).pipe(Effect7.provideService(RequestTime, now)));
728
754
  var createSingleQueuePoller = (queueHandlers, globalSemaphore, options = {}) => {
729
755
  const queueNames = Object.keys(queueHandlers);
730
756
  const successDelay = getLocalQueueSuccessDelay();
@@ -735,6 +761,17 @@ var createSingleQueuePoller = (queueHandlers, globalSemaphore, options = {}) =>
735
761
  onSome: (delay) => sleepWithJitter(delay, MAX_SUCCESS_DELAY_JITTER)
736
762
  });
737
763
  return Effect7.gen(function* () {
764
+ const policy = yield* readAttemptPolicy(options.attemptPolicy);
765
+ yield* readQueueObservationPolicy();
766
+ const maintenance = yield* SqliteQueueMaintenance;
767
+ const recover = maintenance.recover().pipe(Effect7.tap((count) => count > 0 ? Effect7.logWarning("Recovered terminal queue jobs", { count }) : Effect7.void), Effect7.catchCause((cause) => Effect7.logError("Queue terminal recovery failed", cause)));
768
+ yield* recover;
769
+ yield* reportWorkerActivity({
770
+ kind: "ready",
771
+ pid: process.pid,
772
+ instance: randomUUID()
773
+ });
774
+ let escalation;
738
775
  let idleSinceMs = null;
739
776
  let lastIdleStageLabel = null;
740
777
  let consecutivePollErrors = 0;
@@ -742,9 +779,11 @@ var createSingleQueuePoller = (queueHandlers, globalSemaphore, options = {}) =>
742
779
  let lastPauseState = false;
743
780
  let lastWorkerStateSnapshot = null;
744
781
  const activeJobsRef = yield* Ref.make(0);
782
+ let queueObservation;
783
+ const attempts = new Map;
745
784
  const writeState = (paused, pauseToken) => Effect7.gen(function* () {
746
785
  const activeJobs = yield* Ref.get(activeJobsRef);
747
- const snapshot = `${activeJobs}:${paused}:${pauseToken ?? ""}`;
786
+ const snapshot = `${activeJobs}:${paused}:${pauseToken ?? ""}:${escalation?.phase ?? ""}:${queueObservation?.sampledAt ?? ""}`;
748
787
  if (snapshot === lastWorkerStateSnapshot) {
749
788
  return;
750
789
  }
@@ -753,10 +792,14 @@ var createSingleQueuePoller = (queueHandlers, globalSemaphore, options = {}) =>
753
792
  activeJobs,
754
793
  paused,
755
794
  pauseToken,
756
- updatedAt: DateTime.formatIso(now)
795
+ updatedAt: DateTime.formatIso(now),
796
+ ...escalation ? { escalation } : {},
797
+ queueObservation,
798
+ longestAttempt: attempts.values().next().value
757
799
  };
758
800
  const written = yield* writeLocalQueueWorkerState(workerState);
759
801
  yield* notifyWorkerState(workerState);
802
+ yield* reportWorkerActivity({ kind: "state", state: workerState });
760
803
  if (written) {
761
804
  lastWorkerStateSnapshot = snapshot;
762
805
  }
@@ -782,20 +825,43 @@ var createSingleQueuePoller = (queueHandlers, globalSemaphore, options = {}) =>
782
825
  yield* waitWithPauseToken(pauseToken);
783
826
  return true;
784
827
  });
828
+ yield* writeState(readPauseToken() !== null, readPauseToken());
829
+ if (!process.send)
830
+ yield* Effect7.forkChild(observeQueueHealth((observation) => {
831
+ queueObservation = observation;
832
+ }).pipe(Effect7.forkChild, Effect7.andThen(Effect7.forever(Effect7.sleep(100).pipe(Effect7.andThen(Effect7.suspend(() => writeState(readPauseToken() !== null, readPauseToken()))))))));
785
833
  return yield* Effect7.forever(Effect7.gen(function* () {
834
+ if (escalation !== undefined) {
835
+ yield* writeState(true, null);
836
+ yield* Effect7.sleep(PAUSED_POLL_DELAY);
837
+ return;
838
+ }
786
839
  if (yield* waitIfPaused) {
787
840
  return;
788
841
  }
789
842
  yield* globalSemaphore.take(1);
790
843
  const releasePermit = globalSemaphore.release(1);
844
+ if (escalation !== undefined) {
845
+ yield* releasePermit;
846
+ return;
847
+ }
791
848
  const pauseToken = readPauseToken();
792
849
  if (pauseToken !== null) {
793
850
  yield* releasePermit;
794
851
  yield* waitWithPauseToken(pauseToken);
795
852
  return;
796
853
  }
797
- const jobOption = yield* claimNextLocalJob(queueNames).pipe(Effect7.withTracerEnabled(false), Effect7.tapErrorCause(() => releasePermit), Effect7.tap((jobOption) => Option2.isNone(jobOption) ? releasePermit : Effect7.void));
854
+ yield* reportWorkerActivity({ kind: "claim" });
855
+ const jobOption = yield* boundedQueueOperation(claimNextLocalJob(queueNames, D.millis(policy.visibilityMs)), policy, new AttemptEscalation({
856
+ kind: "supervision-required",
857
+ jobId: null,
858
+ receipt: null,
859
+ phase: "claim",
860
+ executionDeadline: null,
861
+ outcome: "unknown"
862
+ })).pipe(Effect7.withTracerEnabled(false), Effect7.tapCause(() => releasePermit), Effect7.tap((jobOption) => Option2.isNone(jobOption) ? releasePermit : Effect7.void));
798
863
  if (Option2.isNone(jobOption)) {
864
+ yield* reportWorkerActivity({ kind: "idle" });
799
865
  consecutivePollErrors = 0;
800
866
  const now = yield* DateTime.now;
801
867
  const nowMs = DateTime.toEpochMillis(now);
@@ -813,17 +879,50 @@ var createSingleQueuePoller = (queueHandlers, globalSemaphore, options = {}) =>
813
879
  consecutivePollErrors = 0;
814
880
  hasClaimedSinceStartup = true;
815
881
  const job = jobOption.value;
882
+ const startedAt = DateTime.toEpochMillis(job.lockedUntil) - policy.visibilityMs;
883
+ const attempt = {
884
+ jobId: job.jobId,
885
+ queue: job.queue,
886
+ receipt: job.receipt,
887
+ startedAt: DateTime.formatIso(DateTime.makeUnsafe(startedAt)),
888
+ executionDeadline: DateTime.formatIso(DateTime.makeUnsafe(startedAt + policy.executionMs))
889
+ };
890
+ attempts.set(job.receipt, attempt);
891
+ yield* reportWorkerActivity({
892
+ kind: "attempt",
893
+ ...attempt
894
+ });
816
895
  yield* Effect7.logDebug(`Processing job ${job.jobId} from ${job.queue}`);
817
896
  yield* Ref.update(activeJobsRef, (count) => count + 1);
818
- yield* writeState(false, null);
819
897
  const releaseJobPermit = Effect7.gen(function* () {
898
+ attempts.delete(job.receipt);
820
899
  yield* Ref.update(activeJobsRef, (count) => Math.max(0, count - 1));
900
+ yield* releasePermit;
821
901
  const pauseToken = readPauseToken();
822
902
  yield* writeState(pauseToken !== null, pauseToken);
823
- yield* releasePermit;
903
+ if (escalation === undefined)
904
+ yield* reportWorkerActivity({ kind: "idle" });
824
905
  });
825
- yield* Effect7.fork(processClaimedJob(job, queueHandlers).pipe(Effect7.tap(() => waitAfterSuccessfulJob), Effect7.catchAllCause((cause) => Effect7.logError(`Job processing failed for ${job.jobId}`, cause)), Effect7.ensuring(releaseJobPermit)));
826
- }).pipe(Effect7.catchAllCause((cause) => Effect7.gen(function* () {
906
+ yield* Effect7.forkChild(runLocalAttempt(job, writeState(false, null).pipe(Effect7.andThen(processClaimedJob(job, queueHandlers, policy, (error) => {
907
+ escalation = error;
908
+ })), Effect7.tap(() => waitAfterSuccessfulJob)), policy, (error) => {
909
+ escalation = error;
910
+ }).pipe(Effect7.catchCause((cause) => Effect7.gen(function* () {
911
+ const error = Cause.findErrorOption(cause);
912
+ if (Option2.isSome(error) && error.value instanceof AttemptEscalation) {
913
+ escalation = error.value;
914
+ }
915
+ yield* Effect7.logError(`Job processing failed for ${job.jobId}`, cause);
916
+ })), Effect7.ensuring(releaseJobPermit)));
917
+ }).pipe(Effect7.catchCause((cause) => Effect7.gen(function* () {
918
+ const error = Cause.findErrorOption(cause);
919
+ if (Option2.isSome(error) && error.value instanceof AttemptEscalation) {
920
+ escalation = error.value;
921
+ }
922
+ if (escalation === undefined)
923
+ yield* reportWorkerActivity({ kind: "idle" });
924
+ else
925
+ yield* writeState(true, null);
827
926
  consecutivePollErrors += 1;
828
927
  const errorDelay = getPollErrorDelay(consecutivePollErrors);
829
928
  yield* Effect7.logError("Failed to poll local queues", cause);
@@ -832,6 +931,7 @@ var createSingleQueuePoller = (queueHandlers, globalSemaphore, options = {}) =>
832
931
  });
833
932
  };
834
933
  // src/job-worker/job-worker.ts
934
+ process.env["PF_RUNTIME_MODE"] = "local";
835
935
  var makeAuthorizationLayer = (policyPaths, schemaPaths) => {
836
936
  if (policyPaths.length > 0) {
837
937
  const hotReloadConfig = LocalCedarConfigHotReload("/", policyPaths, schemaPaths);
@@ -865,33 +965,33 @@ var parseArgs = (args) => Effect8.gen(function* () {
865
965
  console.error("Error: --org is required (or set PF_ORG environment variable)");
866
966
  return yield* new InvalidUsageError({ _: undefined });
867
967
  }
868
- return yield* Schema2.decodeUnknown(ParsedArgsSchema)({
968
+ return yield* Schema2.decodeUnknownEffect(ParsedArgsSchema)({
869
969
  org,
870
970
  check: parseResult.values.check
871
971
  }).pipe(Effect8.mapError(() => new InvalidUsageError({ _: undefined })));
872
972
  });
873
- var CliConfig = Context.GenericTag("processfocus:internal-tag/runtime-local/JobWorkerCliConfig");
973
+ var CliConfig = Context.Service("processfocus:internal-tag/runtime-local/JobWorkerCliConfig");
874
974
  var CliConfigLive = Layer6.effect(CliConfig, parseArgs(process.argv.slice(2)).pipe(Effect8.map((args) => ({
875
975
  org: args.org,
876
976
  check: args.check
877
- })), Effect8.catchAll((error) => {
977
+ })), Effect8.catch((error) => {
878
978
  console.error("Invalid arguments. Usage: bun run job-worker.ts [--org ORG | -o ORG] [--check]");
879
979
  console.error(" --org, -o Path to org project (or set PF_ORG env var)");
880
980
  return Effect8.fail(error);
881
981
  })));
882
- var NodeSdkLive = Otel.NodeSdk.layer(() => ({
982
+ var NodeSdkLive = NodeSdk.layer(() => ({
883
983
  resource: { serviceName: "job-worker" },
884
984
  metricReader: new PeriodicExportingMetricReader({
885
985
  exporter: new OTLPMetricExporter({})
886
986
  }),
887
987
  spanProcessor: new BatchSpanProcessor(new OTLPTraceExporter({}))
888
988
  }));
889
- var RequestTimeLive = Layer6.succeed(RequestTime, FiberRef2.unsafeMake(DateTime2.unsafeMake(0)));
890
- var CurrentPrincipalLive = Layer6.succeed(CurrentPrincipal, FiberRef2.unsafeMake(null));
891
- var UserDetailsLive = Layer6.succeed(UserDetails, FiberRef2.unsafeMake({
989
+ var RequestTimeLive = Layer6.succeed(RequestTime, DateTime2.makeUnsafe(0));
990
+ var CurrentPrincipalLive = Layer6.succeed(CurrentPrincipal, null);
991
+ var UserDetailsLive = Layer6.succeed(UserDetails, {
892
992
  by: "SYSTEM",
893
993
  id: null
894
- }));
994
+ });
895
995
  var DefaultNotificationDeliveryConfigLive = makeNotificationDeliveryConfig(() => getEffectiveFrontendBaseUrl());
896
996
  var createAppLayer = (org, orgProviderLayer, policyPaths, schemaPaths, orgPath) => {
897
997
  const ConditionEvaluatorLive = Layer6.succeed(ConditionEvaluator, makeConditionEvaluator(org));
@@ -913,8 +1013,8 @@ var createAppLayer = (org, orgProviderLayer, policyPaths, schemaPaths, orgPath)
913
1013
  const SlaCalculationServiceWithDeps = SlaCalculationServiceLive.pipe(Layer6.provide(SqliteGraphqlDbOperationsLive));
914
1014
  const ExecutionCollectionOpsWithDeps = ExecutionCollectionOpsLive.pipe(Layer6.provide(SlaCalculationServiceWithDeps), Layer6.provide(SqliteGraphqlDbOperationsLive), Layer6.provide(orgProviderLayer));
915
1015
  const TodoSummaryComputationWithDeps = TodoSummaryComputationLive.pipe(Layer6.provide(SqliteGraphqlDbOperationsLive), Layer6.provide(orgProviderLayer));
916
- const SqliteQueueWithRequestContext = SqliteQueueServiceLive.pipe(Layer6.provide(Layer6.merge(RequestTimeLive, UserDetailsLive)));
917
- return Layer6.mergeAll(SqliteQueueWithRequestContext, SqliteFlowExecutionOperationsLive, SqliteScheduledFlowOperationsLive, SqliteCompletedJobOperationsLive, SqliteFileOperationsLive, SqliteGraphqlDbOperationsLive, ConditionEvaluatorLive, ScheduleEvaluatorLive, SystemStepExecutorLive, ForEachItemsResolverLive, DocumentStoreLive, LocalFileResolutionHostLive, ExecutorHostLive, RequestTimeLive, UserDetailsLive, CurrentPrincipalLive, AuthorizationLive, TodoCollectionOpsWithDeps, ProcessCollectionOpsWithDeps, ExecutionCollectionOpsWithDeps, TodoSummaryComputationWithDeps, HttpTodoFromJobPublisherLive, Layer6.provide(HttpProcessFromJobPublisherLive, Layer6.merge(ProcessCollectionOpsWithDeps, UserDetailsLive)), Layer6.provide(HttpExecutionFromJobPublisherLive, Layer6.merge(ExecutionCollectionOpsWithDeps, UserDetailsLive))).pipe(Layer6.provideMerge(orgProviderLayer), Layer6.provideMerge(TypedSqliteDrizzleLayer), Layer6.provideMerge(makeLocalSqlClientLayer({ busy_timeout: LOCAL_SQLITE_BUSY_TIMEOUT_MS })), Layer6.provideMerge(layer));
1016
+ const SqliteQueueWithRequestContext = LocalQueueServiceLive.pipe(Layer6.provide(Layer6.merge(RequestTimeLive, UserDetailsLive)));
1017
+ return Layer6.mergeAll(SqliteQueueWithRequestContext, SqliteFlowExecutionOperationsLive, SqliteScheduledFlowOperationsLive, SqliteCompletedJobOperationsLive, SqliteFileOperationsLive, SqliteGraphqlDbOperationsLive, ConditionEvaluatorLive, ScheduleEvaluatorLive, SystemStepExecutorLive, ForEachItemsResolverLive, DocumentStoreLive, LocalFileResolutionHostLive, ExecutorHostLive, RequestTimeLive, UserDetailsLive, CurrentPrincipalLive, AuthorizationLive, TodoCollectionOpsWithDeps, ProcessCollectionOpsWithDeps, ExecutionCollectionOpsWithDeps, TodoSummaryComputationWithDeps, HttpTodoFromJobPublisherLive, Layer6.provide(HttpProcessFromJobPublisherLive, Layer6.merge(ProcessCollectionOpsWithDeps, UserDetailsLive)), Layer6.provide(HttpExecutionFromJobPublisherLive, Layer6.merge(ExecutionCollectionOpsWithDeps, UserDetailsLive))).pipe(Layer6.provideMerge(orgProviderLayer), Layer6.provideMerge(TypedSqliteDrizzleLayer), Layer6.provideMerge(makeLocalSqlClientLayer({ busy_timeout: LOCAL_SQLITE_BUSY_TIMEOUT_MS })), Layer6.provideMerge(FetchHttpClient.layer));
918
1018
  };
919
1019
  var GLOBAL_MAX_CONCURRENT = 1;
920
1020
  var FRONTEND_PORT_FILE = ".frontend-port.json";
@@ -931,25 +1031,25 @@ var queueHandlers = {
931
1031
  [FLOW_EXECUTION_QUEUE]: jobHandler(flowExecutionHandler),
932
1032
  [TODO_EVENT_QUEUE]: jobHandler(todoEventHandler),
933
1033
  [PROCESS_EVENT_QUEUE]: jobHandler(processEventHandler),
1034
+ [PROCESS_IMPORT_OUTBOX_QUEUE]: jobHandler(processEventHandler),
934
1035
  [EXECUTION_EVENT_QUEUE]: jobHandler(executionEventHandler),
935
1036
  [SYSTEM_STEP_EXECUTION_QUEUE]: jobHandler(systemStepExecutionHandler),
936
1037
  [NOTIFICATION_DELIVERY_QUEUE]: jobHandler(notificationDeliveryHandler)
937
1038
  };
938
- var WorkerLive = Layer6.scopedDiscard(Effect8.gen(function* () {
1039
+ var WorkerLive = Layer6.effectDiscard(Effect8.gen(function* () {
939
1040
  yield* Effect8.log("Starting job worker...");
940
- const globalSemaphore = yield* Effect8.makeSemaphore(GLOBAL_MAX_CONCURRENT);
1041
+ const globalSemaphore = yield* Semaphore.make(GLOBAL_MAX_CONCURRENT);
941
1042
  const queueNames = Object.keys(queueHandlers).join(", ");
942
- yield* Effect8.fork(createSingleQueuePoller(queueHandlers, globalSemaphore));
943
1043
  yield* Effect8.log(`Job worker started, polling ${queueNames} queues with a single dispatcher`);
944
- return yield* Effect8.never;
1044
+ return yield* createSingleQueuePoller(queueHandlers, globalSemaphore);
945
1045
  }));
946
- var buildOrgProviderLayer = (orgPath) => OrganisationProviderFromPathDev(orgPath).pipe(Layer6.provide(layer2));
1046
+ var buildOrgProviderLayer = (orgPath) => OrganisationProviderFromPathDev(orgPath).pipe(Layer6.provide(layer));
947
1047
  var main = Effect8.gen(function* () {
948
1048
  const cliConfig = yield* CliConfig;
949
1049
  if (process.env["FRONTEND_BASE_URL"] === undefined) {
950
1050
  process.env["FRONTEND_BASE_URL"] = getEffectiveFrontendBaseUrl();
951
1051
  }
952
- const OrgProviderLayer = cliConfig.check ? OrganisationProviderFromPath(cliConfig.org).pipe(Layer6.provide(layer2)) : buildOrgProviderLayer(cliConfig.org);
1052
+ const OrgProviderLayer = cliConfig.check ? OrganisationProviderFromPath(cliConfig.org).pipe(Layer6.provide(layer)) : buildOrgProviderLayer(cliConfig.org);
953
1053
  const CedarPoliciesLayer = OrgCedarPoliciesProvider.pipe(Layer6.provide(OrgProviderLayer));
954
1054
  const orgProvider = yield* OrganisationProvider.pipe(Effect8.provide(OrgProviderLayer));
955
1055
  yield* warnIgnoredCronDeclarations(orgProvider.organisation, "local job worker");
@@ -982,8 +1082,9 @@ var main = Effect8.gen(function* () {
982
1082
  const AppLive = WorkerLive.pipe(Layer6.provide(AppLayerWithCustom));
983
1083
  return yield* Layer6.launch(AppLive).pipe(Effect8.provide(NodeSdkLive));
984
1084
  });
985
- var exit = await Effect8.runPromiseExit(main.pipe(Effect8.provide(CliConfigLive), Effect8.tapErrorCause((cause) => Effect8.logError(`Local runtime startup blocked: job worker initialization failed.
1085
+ startWorkerHeartbeat();
1086
+ var exit = await Effect8.runPromiseExit(main.pipe(Effect8.provide(CliConfigLive), Effect8.tapCause((cause) => Effect8.logError(`Local runtime startup blocked: job worker initialization failed.
986
1087
  ${cause}
987
- Fix the configuration above and restart the local runtime. Automatic process steps are unavailable.`)), Logger.withMinimumLogLevel(LogLevel.Debug), Effect8.provide(Logger.pretty)));
1088
+ Fix the configuration above and restart the local runtime. Automatic process steps are unavailable.`)), Effect8.provideService(References.MinimumLogLevel, "Debug"), Effect8.provide(Logger.layer([Logger.consolePretty()]))));
988
1089
  if (Exit.isFailure(exit))
989
1090
  process.exitCode = 1;