@hotmeshio/long-tail 0.1.5 → 0.1.7

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 (431) hide show
  1. package/README.md +78 -8
  2. package/build/api/auth.d.ts +5 -0
  3. package/build/api/auth.js +42 -0
  4. package/build/api/bot-accounts.d.ts +50 -0
  5. package/build/api/bot-accounts.js +215 -0
  6. package/build/api/controlplane.d.ts +20 -0
  7. package/build/api/controlplane.js +110 -0
  8. package/build/api/dba.d.ts +15 -0
  9. package/build/api/dba.js +68 -0
  10. package/build/api/escalations.d.ts +70 -0
  11. package/build/api/escalations.js +656 -0
  12. package/build/api/exports.d.ts +32 -0
  13. package/build/api/exports.js +146 -0
  14. package/build/api/index.d.ts +18 -0
  15. package/build/api/index.js +54 -0
  16. package/build/api/insight.d.ts +29 -0
  17. package/build/api/insight.js +90 -0
  18. package/build/api/maintenance.d.ts +7 -0
  19. package/build/api/maintenance.js +28 -0
  20. package/build/api/mcp-runs.d.ts +16 -0
  21. package/build/api/mcp-runs.js +62 -0
  22. package/build/api/mcp.d.ts +52 -0
  23. package/build/api/mcp.js +212 -0
  24. package/build/api/namespaces.d.ts +7 -0
  25. package/build/{routes/escalations/helpers.js → api/namespaces.js} +24 -12
  26. package/build/api/roles.d.ts +25 -0
  27. package/build/api/roles.js +159 -0
  28. package/build/api/settings.d.ts +2 -0
  29. package/build/api/settings.js +35 -0
  30. package/build/api/tasks.d.ts +27 -0
  31. package/build/api/tasks.js +96 -0
  32. package/build/api/users.d.ts +44 -0
  33. package/build/api/users.js +162 -0
  34. package/build/api/workflow-sets.d.ts +26 -0
  35. package/build/api/workflow-sets.js +119 -0
  36. package/build/api/workflows.d.ts +48 -0
  37. package/build/api/workflows.js +298 -0
  38. package/build/api/yaml-workflows.d.ts +87 -0
  39. package/build/api/yaml-workflows.js +556 -0
  40. package/build/index.d.ts +4 -0
  41. package/build/index.js +6 -1
  42. package/build/lib/db/migrate.js +3 -6
  43. package/{lib → build/lib}/db/schemas/001_schema.sql +3 -0
  44. package/build/lib/db/schemas/004_workflow_sets.sql +29 -0
  45. package/build/lib/db/schemas/005_unique_graph_topic.sql +7 -0
  46. package/{lib → build/lib}/db/schemas/011_system_workflow_configs.sql +14 -0
  47. package/build/lib/db/schemas/016_streamable_http.sql +7 -0
  48. package/build/lib/events/callback.d.ts +41 -0
  49. package/build/lib/events/callback.js +98 -0
  50. package/build/modules/config.js +1 -1
  51. package/build/routes/auth.js +37 -36
  52. package/build/routes/bot-accounts.js +34 -164
  53. package/build/routes/controlplane.js +20 -60
  54. package/build/routes/dba.js +18 -28
  55. package/build/routes/docs.js +25 -7
  56. package/build/routes/escalations/bulk.js +17 -192
  57. package/build/routes/escalations/list.js +29 -75
  58. package/build/routes/escalations/resolve.js +3 -193
  59. package/build/routes/escalations/single.js +13 -122
  60. package/build/routes/exports.js +44 -95
  61. package/build/routes/index.js +2 -0
  62. package/build/routes/insight.js +61 -40
  63. package/build/routes/maintenance.js +41 -17
  64. package/build/routes/mcp-runs.js +52 -60
  65. package/build/routes/mcp.js +55 -161
  66. package/build/routes/namespaces.js +9 -20
  67. package/build/routes/roles.js +23 -97
  68. package/build/routes/settings.js +37 -25
  69. package/build/routes/tasks.js +28 -64
  70. package/build/routes/users.js +24 -113
  71. package/build/routes/workflow-sets.d.ts +2 -0
  72. package/build/routes/workflow-sets.js +98 -0
  73. package/build/routes/workflows/config.js +23 -57
  74. package/build/routes/workflows/discovery.js +11 -85
  75. package/build/routes/workflows/invocation.js +16 -84
  76. package/build/routes/yaml-workflows/cron.d.ts +2 -0
  77. package/build/routes/yaml-workflows/cron.js +68 -0
  78. package/build/routes/yaml-workflows/crud.js +38 -193
  79. package/build/routes/yaml-workflows/deployment.js +15 -140
  80. package/build/routes/yaml-workflows/index.js +4 -1
  81. package/build/routes/yaml-workflows/versions.js +20 -58
  82. package/build/sdk/index.d.ts +327 -0
  83. package/build/sdk/index.js +298 -0
  84. package/build/services/controlplane/index.d.ts +1 -2
  85. package/build/services/controlplane/index.js +3 -3
  86. package/build/services/controlplane/sql.d.ts +2 -2
  87. package/build/services/controlplane/sql.js +4 -5
  88. package/build/services/controlplane/types.d.ts +1 -0
  89. package/build/services/cron/index.d.ts +17 -0
  90. package/build/services/cron/index.js +94 -1
  91. package/build/services/export/index.js +6 -1
  92. package/build/services/hotmesh-utils.js +2 -4
  93. package/build/services/insight/index.d.ts +18 -0
  94. package/build/services/insight/index.js +60 -0
  95. package/build/services/mcp/client/connection.d.ts +9 -0
  96. package/build/services/mcp/client/connection.js +49 -1
  97. package/build/services/mcp/client/tools.js +13 -1
  98. package/build/services/mcp/db-server/schemas.d.ts +2 -2
  99. package/build/services/mcp/db.d.ts +1 -1
  100. package/build/services/mcp/db.js +10 -0
  101. package/build/services/mcp/playwright-server/schemas.d.ts +4 -4
  102. package/build/services/mcp/sql.d.ts +1 -1
  103. package/build/services/mcp/sql.js +2 -2
  104. package/build/services/mcp/types.d.ts +3 -1
  105. package/build/services/mcp-runs/sql.js +1 -1
  106. package/build/services/workflow-sets/db.d.ts +16 -0
  107. package/build/services/workflow-sets/db.js +78 -0
  108. package/build/services/workflow-sets/index.d.ts +1 -0
  109. package/build/services/workflow-sets/index.js +11 -0
  110. package/build/services/workflow-sets/sql.d.ts +6 -0
  111. package/build/services/workflow-sets/sql.js +24 -0
  112. package/build/services/yaml-workflow/db-utils.d.ts +1 -0
  113. package/build/services/yaml-workflow/db-utils.js +4 -0
  114. package/build/services/yaml-workflow/db.d.ts +8 -0
  115. package/build/services/yaml-workflow/db.js +41 -0
  116. package/build/services/yaml-workflow/invoke.d.ts +19 -0
  117. package/build/services/yaml-workflow/invoke.js +80 -0
  118. package/build/services/yaml-workflow/pipeline/build/dag.js +1 -1
  119. package/build/services/yaml-workflow/pipeline/build/wiring.d.ts +1 -1
  120. package/build/services/yaml-workflow/pipeline/build/wiring.js +102 -2
  121. package/build/services/yaml-workflow/pipeline/prompts.d.ts +1 -1
  122. package/build/services/yaml-workflow/pipeline/prompts.js +44 -1
  123. package/build/services/yaml-workflow/sql.d.ts +5 -1
  124. package/build/services/yaml-workflow/sql.js +23 -3
  125. package/build/services/yaml-workflow/types.d.ts +16 -1
  126. package/build/services/yaml-workflow/workers/callbacks.js +16 -2
  127. package/build/services/yaml-workflow/workers/register.js +36 -1
  128. package/build/start/adapters.js +4 -0
  129. package/build/system/index.js +12 -0
  130. package/build/system/mcp-servers/admin/schemas.d.ts +12 -12
  131. package/build/system/mcp-servers/db-query/schemas.d.ts +2 -2
  132. package/build/system/mcp-servers/knowledge.js +1 -1
  133. package/build/system/mcp-servers/playwright/schemas.d.ts +18 -18
  134. package/build/system/mcp-servers/playwright-cli/schemas.d.ts +34 -34
  135. package/build/system/mcp-servers/playwright-cli/tools-capture.js +5 -1
  136. package/build/system/mcp-servers/vision.js +54 -17
  137. package/build/system/seed/server-definitions.d.ts +7 -0
  138. package/build/system/seed/server-definitions.js +6 -2
  139. package/build/system/seed/tool-manifests-workflows.d.ts +7 -0
  140. package/build/system/seed/tool-manifests-workflows.js +10 -3
  141. package/build/system/workflows/mcp-workflow-builder/activities/caches.d.ts +5 -0
  142. package/build/system/workflows/mcp-workflow-builder/activities/caches.js +8 -0
  143. package/build/system/workflows/mcp-workflow-builder/activities/index.d.ts +2 -0
  144. package/build/system/workflows/mcp-workflow-builder/activities/index.js +8 -0
  145. package/build/system/workflows/mcp-workflow-builder/activities/llm.d.ts +2 -0
  146. package/build/system/workflows/mcp-workflow-builder/activities/llm.js +25 -0
  147. package/build/system/workflows/mcp-workflow-builder/activities/tool-loader.d.ts +11 -0
  148. package/build/system/workflows/mcp-workflow-builder/activities/tool-loader.js +34 -0
  149. package/build/system/workflows/mcp-workflow-builder/index.d.ts +16 -0
  150. package/build/system/workflows/mcp-workflow-builder/index.js +253 -0
  151. package/build/system/workflows/mcp-workflow-builder/prompts.d.ts +8 -0
  152. package/build/system/workflows/mcp-workflow-builder/prompts.js +316 -0
  153. package/build/system/workflows/mcp-workflow-planner/activities/analyze.d.ts +11 -0
  154. package/build/system/workflows/mcp-workflow-planner/activities/analyze.js +36 -0
  155. package/build/system/workflows/mcp-workflow-planner/activities/index.d.ts +3 -0
  156. package/build/system/workflows/mcp-workflow-planner/activities/index.js +12 -0
  157. package/build/system/workflows/mcp-workflow-planner/activities/persist.d.ts +19 -0
  158. package/build/system/workflows/mcp-workflow-planner/activities/persist.js +55 -0
  159. package/build/system/workflows/mcp-workflow-planner/activities/plan.d.ts +10 -0
  160. package/build/system/workflows/mcp-workflow-planner/activities/plan.js +43 -0
  161. package/build/system/workflows/mcp-workflow-planner/index.d.ts +7 -0
  162. package/build/system/workflows/mcp-workflow-planner/index.js +152 -0
  163. package/build/system/workflows/mcp-workflow-planner/prompts.d.ts +7 -0
  164. package/build/system/workflows/mcp-workflow-planner/prompts.js +77 -0
  165. package/build/system/workflows/shared/tool-loader.js +3 -0
  166. package/build/tsconfig.tsbuildinfo +1 -1
  167. package/build/types/index.d.ts +1 -0
  168. package/build/types/mcp.d.ts +4 -3
  169. package/build/types/sdk.d.ts +27 -0
  170. package/build/types/sdk.js +2 -0
  171. package/build/types/workflow-set.d.ts +44 -0
  172. package/build/types/workflow-set.js +5 -0
  173. package/build/types/yaml-workflow.d.ts +6 -2
  174. package/dashboard/dist/assets/AdminDashboard-DRjkRSjJ.js +2 -0
  175. package/dashboard/dist/assets/{AdminDashboard-CTyAMUJR.js.map → AdminDashboard-DRjkRSjJ.js.map} +1 -1
  176. package/dashboard/dist/assets/AvailableEscalationsPage-CnivX4Tz.js +2 -0
  177. package/dashboard/dist/assets/AvailableEscalationsPage-CnivX4Tz.js.map +1 -0
  178. package/dashboard/dist/assets/BotPicker-DwwaBhTH.js +2 -0
  179. package/dashboard/dist/assets/{BotPicker-C51nKFEu.js.map → BotPicker-DwwaBhTH.js.map} +1 -1
  180. package/dashboard/dist/assets/{CollapsibleSection-BSyfd8uL.js → CollapsibleSection-DQpaVA0M.js} +2 -2
  181. package/dashboard/dist/assets/{CollapsibleSection-BSyfd8uL.js.map → CollapsibleSection-DQpaVA0M.js.map} +1 -1
  182. package/dashboard/dist/assets/{ConfirmDeleteModal-CBdhia5T.js → ConfirmDeleteModal-B7JoDNvt.js} +2 -2
  183. package/dashboard/dist/assets/{ConfirmDeleteModal-CBdhia5T.js.map → ConfirmDeleteModal-B7JoDNvt.js.map} +1 -1
  184. package/dashboard/dist/assets/{CopyableId-dGlewBCS.js → CopyableId-AqoZayBG.js} +2 -2
  185. package/dashboard/dist/assets/{CopyableId-dGlewBCS.js.map → CopyableId-AqoZayBG.js.map} +1 -1
  186. package/dashboard/dist/assets/CredentialsPage-qGw1kQzi.js +2 -0
  187. package/dashboard/dist/assets/CredentialsPage-qGw1kQzi.js.map +1 -0
  188. package/dashboard/dist/assets/{CustomDurationPicker-BataWFj8.js → CustomDurationPicker-D1HUQcd0.js} +2 -2
  189. package/dashboard/dist/assets/{CustomDurationPicker-BataWFj8.js.map → CustomDurationPicker-D1HUQcd0.js.map} +1 -1
  190. package/dashboard/dist/assets/{DataTable-B3uf5CCo.js → DataTable-DKvSKoVG.js} +2 -2
  191. package/dashboard/dist/assets/{DataTable-B3uf5CCo.js.map → DataTable-DKvSKoVG.js.map} +1 -1
  192. package/dashboard/dist/assets/{ElapsedCell-G5oSwTpT.js → ElapsedCell-B0yrReGQ.js} +2 -2
  193. package/dashboard/dist/assets/{ElapsedCell-G5oSwTpT.js.map → ElapsedCell-B0yrReGQ.js.map} +1 -1
  194. package/dashboard/dist/assets/{EmptyState-BChBJNGS.js → EmptyState-X0fIzYID.js} +2 -2
  195. package/dashboard/dist/assets/{EmptyState-BChBJNGS.js.map → EmptyState-X0fIzYID.js.map} +1 -1
  196. package/dashboard/dist/assets/{EscalationsOverview-CxUv8xjG.js → EscalationsOverview-BQAT9W7r.js} +2 -2
  197. package/dashboard/dist/assets/{EscalationsOverview-CxUv8xjG.js.map → EscalationsOverview-BQAT9W7r.js.map} +1 -1
  198. package/dashboard/dist/assets/{EventTable-CVt8B0BZ.js → EventTable-CX1KNLhZ.js} +2 -2
  199. package/dashboard/dist/assets/{EventTable-CVt8B0BZ.js.map → EventTable-CX1KNLhZ.js.map} +1 -1
  200. package/dashboard/dist/assets/{FilterBar-CShf0oe7.js → FilterBar-DMTvuQy-.js} +2 -2
  201. package/dashboard/dist/assets/{FilterBar-CShf0oe7.js.map → FilterBar-DMTvuQy-.js.map} +1 -1
  202. package/dashboard/dist/assets/ListToolbar-DTOSxoEy.js +2 -0
  203. package/dashboard/dist/assets/ListToolbar-DTOSxoEy.js.map +1 -0
  204. package/dashboard/dist/assets/{McpOverview-CbaZRnJl.js → McpOverview-BaKTIWrG.js} +2 -2
  205. package/dashboard/dist/assets/{McpOverview-CbaZRnJl.js.map → McpOverview-BaKTIWrG.js.map} +1 -1
  206. package/dashboard/dist/assets/McpQueryDetailPage-CC08T5k8.js +5 -0
  207. package/dashboard/dist/assets/McpQueryDetailPage-CC08T5k8.js.map +1 -0
  208. package/dashboard/dist/assets/McpQueryPage-CVfF9dYg.js +2 -0
  209. package/dashboard/dist/assets/McpQueryPage-CVfF9dYg.js.map +1 -0
  210. package/dashboard/dist/assets/McpRunDetailPage-CKs1RWeV.js +2 -0
  211. package/dashboard/dist/assets/McpRunDetailPage-CKs1RWeV.js.map +1 -0
  212. package/dashboard/dist/assets/McpRunsPage-CcPD_tY1.js +2 -0
  213. package/dashboard/dist/assets/McpRunsPage-CcPD_tY1.js.map +1 -0
  214. package/dashboard/dist/assets/{Modal-CI5RBPOQ.js → Modal-_2AbWxJT.js} +2 -2
  215. package/dashboard/dist/assets/{Modal-CI5RBPOQ.js.map → Modal-_2AbWxJT.js.map} +1 -1
  216. package/dashboard/dist/assets/OperatorDashboard-BGiRaRDr.js +2 -0
  217. package/dashboard/dist/assets/OperatorDashboard-BGiRaRDr.js.map +1 -0
  218. package/dashboard/dist/assets/{PageHeader-SMD9qtOO.js → PageHeader-DVr5Qyzm.js} +2 -2
  219. package/dashboard/dist/assets/{PageHeader-SMD9qtOO.js.map → PageHeader-DVr5Qyzm.js.map} +1 -1
  220. package/dashboard/dist/assets/{PageHeaderWithStats-TikLQsTp.js → PageHeaderWithStats-D0KRASML.js} +2 -2
  221. package/dashboard/dist/assets/{PageHeaderWithStats-TikLQsTp.js.map → PageHeaderWithStats-D0KRASML.js.map} +1 -1
  222. package/dashboard/dist/assets/{PriorityBadge-CQ0EsLTA.js → PriorityBadge-Bx2559OU.js} +2 -2
  223. package/dashboard/dist/assets/{PriorityBadge-CQ0EsLTA.js.map → PriorityBadge-Bx2559OU.js.map} +1 -1
  224. package/dashboard/dist/assets/ProcessDetailPage-69I--sry.js +2 -0
  225. package/dashboard/dist/assets/ProcessDetailPage-69I--sry.js.map +1 -0
  226. package/dashboard/dist/assets/ProcessesListPage-BDpUbua2.js +2 -0
  227. package/dashboard/dist/assets/ProcessesListPage-BDpUbua2.js.map +1 -0
  228. package/dashboard/dist/assets/{RolePill-Crj4TH5p.js → RolePill-CcAqEaSt.js} +2 -2
  229. package/dashboard/dist/assets/{RolePill-Crj4TH5p.js.map → RolePill-CcAqEaSt.js.map} +1 -1
  230. package/dashboard/dist/assets/{RolesPage-C_RInUwS.js → RolesPage-Cl23Hjet.js} +2 -2
  231. package/dashboard/dist/assets/{RolesPage-C_RInUwS.js.map → RolesPage-Cl23Hjet.js.map} +1 -1
  232. package/dashboard/dist/assets/{RowActions-Cp5HyK_w.js → RowActions-B4mqIt3Z.js} +2 -2
  233. package/dashboard/dist/assets/{RowActions-Cp5HyK_w.js.map → RowActions-B4mqIt3Z.js.map} +1 -1
  234. package/dashboard/dist/assets/{StatCard-BKZLSgNV.js → StatCard-Cz_2OjAZ.js} +2 -2
  235. package/dashboard/dist/assets/{StatCard-BKZLSgNV.js.map → StatCard-Cz_2OjAZ.js.map} +1 -1
  236. package/dashboard/dist/assets/{StatusBadge-BYNGGZK5.js → StatusBadge-Wi2FJZsn.js} +2 -2
  237. package/dashboard/dist/assets/{StatusBadge-BYNGGZK5.js.map → StatusBadge-Wi2FJZsn.js.map} +1 -1
  238. package/dashboard/dist/assets/StepIndicator-PW5NRDMb.js +2 -0
  239. package/dashboard/dist/assets/StepIndicator-PW5NRDMb.js.map +1 -0
  240. package/dashboard/dist/assets/{StickyPagination-CTosgiU2.js → StickyPagination-Bl2Uzz65.js} +2 -2
  241. package/dashboard/dist/assets/{StickyPagination-CTosgiU2.js.map → StickyPagination-Bl2Uzz65.js.map} +1 -1
  242. package/dashboard/dist/assets/{SwimlaneTimeline-ylG5Ps1s.js → SwimlaneTimeline-CUPqMd0z.js} +2 -2
  243. package/dashboard/dist/assets/{SwimlaneTimeline-ylG5Ps1s.js.map → SwimlaneTimeline-CUPqMd0z.js.map} +1 -1
  244. package/dashboard/dist/assets/TagInput-BLtf86Ly.js +2 -0
  245. package/dashboard/dist/assets/TagInput-BLtf86Ly.js.map +1 -0
  246. package/dashboard/dist/assets/{TaskDetailPage-C9pDGdD2.js → TaskDetailPage-BXJFX74D.js} +2 -2
  247. package/dashboard/dist/assets/{TaskDetailPage-C9pDGdD2.js.map → TaskDetailPage-BXJFX74D.js.map} +1 -1
  248. package/dashboard/dist/assets/{TaskQueuePill-BtJbZTT0.js → TaskQueuePill-CWYj3xKe.js} +2 -2
  249. package/dashboard/dist/assets/{TaskQueuePill-BtJbZTT0.js.map → TaskQueuePill-CWYj3xKe.js.map} +1 -1
  250. package/dashboard/dist/assets/{TasksListPage-DtFLUEhg.js → TasksListPage-C3cX94Mw.js} +2 -2
  251. package/dashboard/dist/assets/{TasksListPage-DtFLUEhg.js.map → TasksListPage-C3cX94Mw.js.map} +1 -1
  252. package/dashboard/dist/assets/{TimeAgo-WuM6xImZ.js → TimeAgo-B_5yDDHV.js} +2 -2
  253. package/dashboard/dist/assets/{TimeAgo-WuM6xImZ.js.map → TimeAgo-B_5yDDHV.js.map} +1 -1
  254. package/dashboard/dist/assets/{TimestampCell-IVL_-Upy.js → TimestampCell-DRX724uU.js} +2 -2
  255. package/dashboard/dist/assets/{TimestampCell-IVL_-Upy.js.map → TimestampCell-DRX724uU.js.map} +1 -1
  256. package/dashboard/dist/assets/{UserName-DU9qeg13.js → UserName-Ca8FA469.js} +2 -2
  257. package/dashboard/dist/assets/{UserName-DU9qeg13.js.map → UserName-Ca8FA469.js.map} +1 -1
  258. package/dashboard/dist/assets/WorkflowExecutionPage-BBYWEV2P.js +2 -0
  259. package/dashboard/dist/assets/WorkflowExecutionPage-BBYWEV2P.js.map +1 -0
  260. package/dashboard/dist/assets/WorkflowPill-BXifAuLi.js +2 -0
  261. package/dashboard/dist/assets/{WorkflowPill-Diw8iWBP.js.map → WorkflowPill-BXifAuLi.js.map} +1 -1
  262. package/dashboard/dist/assets/WorkflowsDashboard-Drl3juz9.js +2 -0
  263. package/dashboard/dist/assets/WorkflowsDashboard-Drl3juz9.js.map +1 -0
  264. package/dashboard/dist/assets/{WorkflowsOverview-CPuvA4t3.js → WorkflowsOverview-03IRrDLg.js} +2 -2
  265. package/dashboard/dist/assets/{WorkflowsOverview-CPuvA4t3.js.map → WorkflowsOverview-03IRrDLg.js.map} +1 -1
  266. package/dashboard/dist/assets/YamlWorkflowsPage-DC2cLxVi.js +2 -0
  267. package/dashboard/dist/assets/YamlWorkflowsPage-DC2cLxVi.js.map +1 -0
  268. package/dashboard/dist/assets/{bots-BPiZXf2h.js → bots-DZEXcgiJ.js} +2 -2
  269. package/dashboard/dist/assets/{bots-BPiZXf2h.js.map → bots-DZEXcgiJ.js.map} +1 -1
  270. package/dashboard/dist/assets/{escalation-DTY_OKRh.js → escalation-Cw48lNaF.js} +2 -2
  271. package/dashboard/dist/assets/{escalation-DTY_OKRh.js.map → escalation-Cw48lNaF.js.map} +1 -1
  272. package/dashboard/dist/assets/{escalation-columns-C91fHSkp.js → escalation-columns-NINpo3qf.js} +2 -2
  273. package/dashboard/dist/assets/{escalation-columns-C91fHSkp.js.map → escalation-columns-NINpo3qf.js.map} +1 -1
  274. package/dashboard/dist/assets/helpers-Cuu3xKfr.js +2 -0
  275. package/dashboard/dist/assets/helpers-Cuu3xKfr.js.map +1 -0
  276. package/dashboard/dist/assets/helpers-fk_qr729.js +2 -0
  277. package/dashboard/dist/assets/helpers-fk_qr729.js.map +1 -0
  278. package/dashboard/dist/assets/index-B98ipWxE.js +2 -0
  279. package/dashboard/dist/assets/{index-CDWOfCmi.js.map → index-B98ipWxE.js.map} +1 -1
  280. package/dashboard/dist/assets/{index-D_qEAYrg.js → index-BIG3KooI.js} +2 -2
  281. package/dashboard/dist/assets/{index-D_qEAYrg.js.map → index-BIG3KooI.js.map} +1 -1
  282. package/dashboard/dist/assets/{index-DSzSoku1.js → index-BwN3KP_L.js} +91 -93
  283. package/dashboard/dist/assets/index-BwN3KP_L.js.map +1 -0
  284. package/dashboard/dist/assets/index-Bxe8h1x4.js +17 -0
  285. package/dashboard/dist/assets/index-Bxe8h1x4.js.map +1 -0
  286. package/dashboard/dist/assets/index-CNI7k7oB.js +6 -0
  287. package/dashboard/dist/assets/index-CNI7k7oB.js.map +1 -0
  288. package/dashboard/dist/assets/index-CORHB0WC.js +2 -0
  289. package/dashboard/dist/assets/index-CORHB0WC.js.map +1 -0
  290. package/dashboard/dist/assets/index-DcIKW-cZ.css +1 -0
  291. package/dashboard/dist/assets/index-Dj-z-x8M.js +2 -0
  292. package/dashboard/dist/assets/index-Dj-z-x8M.js.map +1 -0
  293. package/dashboard/dist/assets/index-DwRytW9O.js +5 -0
  294. package/dashboard/dist/assets/index-DwRytW9O.js.map +1 -0
  295. package/dashboard/dist/assets/index-aRvL-dXp.js +2 -0
  296. package/dashboard/dist/assets/index-aRvL-dXp.js.map +1 -0
  297. package/dashboard/dist/assets/index-b03HlbnH.js +2 -0
  298. package/dashboard/dist/assets/{index-BtOwLI0K.js.map → index-b03HlbnH.js.map} +1 -1
  299. package/dashboard/dist/assets/mcp-BZoFryNc.js +2 -0
  300. package/dashboard/dist/assets/mcp-BZoFryNc.js.map +1 -0
  301. package/dashboard/dist/assets/mcp-query-wiw1kwm8.js +2 -0
  302. package/dashboard/dist/assets/mcp-query-wiw1kwm8.js.map +1 -0
  303. package/dashboard/dist/assets/{mcp-runs-DmXYJD19.js → mcp-runs-BaEKnf5v.js} +2 -2
  304. package/dashboard/dist/assets/{mcp-runs-DmXYJD19.js.map → mcp-runs-BaEKnf5v.js.map} +1 -1
  305. package/dashboard/dist/assets/{namespaces-DoGa7jc7.js → namespaces-BwnZI4_A.js} +2 -2
  306. package/dashboard/dist/assets/{namespaces-DoGa7jc7.js.map → namespaces-BwnZI4_A.js.map} +1 -1
  307. package/dashboard/dist/assets/{roles-wCdQ2Z7k.js → roles-Bgn1K8zU.js} +2 -2
  308. package/dashboard/dist/assets/{roles-wCdQ2Z7k.js.map → roles-Bgn1K8zU.js.map} +1 -1
  309. package/dashboard/dist/assets/{settings-DDe_L7JT.js → settings-CizYiutL.js} +2 -2
  310. package/dashboard/dist/assets/{settings-DDe_L7JT.js.map → settings-CizYiutL.js.map} +1 -1
  311. package/dashboard/dist/assets/{tasks-3Hih8Bt7.js → tasks-Bmte_hc4.js} +2 -2
  312. package/dashboard/dist/assets/{tasks-3Hih8Bt7.js.map → tasks-Bmte_hc4.js.map} +1 -1
  313. package/dashboard/dist/assets/useEventHooks-CUCxpiI2.js +2 -0
  314. package/dashboard/dist/assets/useEventHooks-CUCxpiI2.js.map +1 -0
  315. package/dashboard/dist/assets/useExpandedRows-Cg9iq6Vy.js +2 -0
  316. package/dashboard/dist/assets/useExpandedRows-Cg9iq6Vy.js.map +1 -0
  317. package/dashboard/dist/assets/{useYamlActivityEvents-B5dHec6Y.js → useYamlActivityEvents-Cum02Ej9.js} +2 -2
  318. package/dashboard/dist/assets/useYamlActivityEvents-Cum02Ej9.js.map +1 -0
  319. package/dashboard/dist/assets/{users-BTagPmGW.js → users-NSDgTt-z.js} +2 -2
  320. package/dashboard/dist/assets/{users-BTagPmGW.js.map → users-NSDgTt-z.js.map} +1 -1
  321. package/dashboard/dist/assets/{vendor-icons-DCLlGYO9.js → vendor-icons-D1DdudfH.js} +141 -66
  322. package/dashboard/dist/assets/vendor-icons-D1DdudfH.js.map +1 -0
  323. package/dashboard/dist/assets/{workflows-B20dR3NE.js → workflows-k0XRdGXx.js} +2 -2
  324. package/dashboard/dist/assets/{workflows-B20dR3NE.js.map → workflows-k0XRdGXx.js.map} +1 -1
  325. package/dashboard/dist/assets/yaml-workflows-DAre8I78.js +2 -0
  326. package/dashboard/dist/assets/yaml-workflows-DAre8I78.js.map +1 -0
  327. package/dashboard/dist/index.html +3 -3
  328. package/docs/api/mcp-servers.md +60 -2
  329. package/docs/architecture.md +3 -3
  330. package/docs/dashboard.md +1 -1
  331. package/docs/epic-integration.md +224 -0
  332. package/docs/escalation-strategies.md +2 -3
  333. package/docs/events.md +28 -0
  334. package/docs/mcp.md +301 -31
  335. package/docs/sdk.md +177 -0
  336. package/docs/story.md +157 -0
  337. package/docs/workflow-builder.md +371 -0
  338. package/package.json +5 -4
  339. package/build/routes/escalations/helpers.d.ts +0 -5
  340. package/build/routes/resolve.d.ts +0 -9
  341. package/build/routes/resolve.js +0 -19
  342. package/build/routes/yaml-workflows/helpers.d.ts +0 -2
  343. package/build/routes/yaml-workflows/helpers.js +0 -8
  344. package/dashboard/dist/assets/AdminDashboard-CTyAMUJR.js +0 -2
  345. package/dashboard/dist/assets/AvailableEscalationsPage-BMXV3Q4l.js +0 -2
  346. package/dashboard/dist/assets/AvailableEscalationsPage-BMXV3Q4l.js.map +0 -1
  347. package/dashboard/dist/assets/BotPicker-C51nKFEu.js +0 -2
  348. package/dashboard/dist/assets/CredentialsPage-CoBNFSAu.js +0 -2
  349. package/dashboard/dist/assets/CredentialsPage-CoBNFSAu.js.map +0 -1
  350. package/dashboard/dist/assets/McpQueryDetailPage-CGoR9XK6.js +0 -5
  351. package/dashboard/dist/assets/McpQueryDetailPage-CGoR9XK6.js.map +0 -1
  352. package/dashboard/dist/assets/McpQueryPage-BjXoYQuU.js +0 -2
  353. package/dashboard/dist/assets/McpQueryPage-BjXoYQuU.js.map +0 -1
  354. package/dashboard/dist/assets/McpRunDetailPage-DLkA5Aar.js +0 -2
  355. package/dashboard/dist/assets/McpRunDetailPage-DLkA5Aar.js.map +0 -1
  356. package/dashboard/dist/assets/McpRunsPage-DCh9n11D.js +0 -2
  357. package/dashboard/dist/assets/McpRunsPage-DCh9n11D.js.map +0 -1
  358. package/dashboard/dist/assets/OperatorDashboard-Dc80suXd.js +0 -2
  359. package/dashboard/dist/assets/OperatorDashboard-Dc80suXd.js.map +0 -1
  360. package/dashboard/dist/assets/ProcessDetailPage-B2GKuGzk.js +0 -2
  361. package/dashboard/dist/assets/ProcessDetailPage-B2GKuGzk.js.map +0 -1
  362. package/dashboard/dist/assets/ProcessesListPage-CTjI3Wn6.js +0 -2
  363. package/dashboard/dist/assets/ProcessesListPage-CTjI3Wn6.js.map +0 -1
  364. package/dashboard/dist/assets/RefreshButton-BcQDObrv.js +0 -2
  365. package/dashboard/dist/assets/RefreshButton-BcQDObrv.js.map +0 -1
  366. package/dashboard/dist/assets/RunAsSelector-BhyWtofX.js +0 -2
  367. package/dashboard/dist/assets/RunAsSelector-BhyWtofX.js.map +0 -1
  368. package/dashboard/dist/assets/WorkflowExecutionPage-DOocX81f.js +0 -2
  369. package/dashboard/dist/assets/WorkflowExecutionPage-DOocX81f.js.map +0 -1
  370. package/dashboard/dist/assets/WorkflowPill-Diw8iWBP.js +0 -2
  371. package/dashboard/dist/assets/WorkflowsDashboard-DDtUIrTy.js +0 -2
  372. package/dashboard/dist/assets/WorkflowsDashboard-DDtUIrTy.js.map +0 -1
  373. package/dashboard/dist/assets/YamlWorkflowsPage-DlwwkluN.js +0 -2
  374. package/dashboard/dist/assets/YamlWorkflowsPage-DlwwkluN.js.map +0 -1
  375. package/dashboard/dist/assets/helpers-DBUZ9pnG.js +0 -2
  376. package/dashboard/dist/assets/helpers-DBUZ9pnG.js.map +0 -1
  377. package/dashboard/dist/assets/index-BOeA-gfK.js +0 -17
  378. package/dashboard/dist/assets/index-BOeA-gfK.js.map +0 -1
  379. package/dashboard/dist/assets/index-BZ6K_kmL.js +0 -3
  380. package/dashboard/dist/assets/index-BZ6K_kmL.js.map +0 -1
  381. package/dashboard/dist/assets/index-Bpm0yeoi.js +0 -2
  382. package/dashboard/dist/assets/index-Bpm0yeoi.js.map +0 -1
  383. package/dashboard/dist/assets/index-BtOwLI0K.js +0 -2
  384. package/dashboard/dist/assets/index-CBF3ZvRZ.js +0 -6
  385. package/dashboard/dist/assets/index-CBF3ZvRZ.js.map +0 -1
  386. package/dashboard/dist/assets/index-CDWOfCmi.js +0 -2
  387. package/dashboard/dist/assets/index-Ce6sL__n.js +0 -2
  388. package/dashboard/dist/assets/index-Ce6sL__n.js.map +0 -1
  389. package/dashboard/dist/assets/index-DSzSoku1.js.map +0 -1
  390. package/dashboard/dist/assets/index-gCy9XX3W.css +0 -1
  391. package/dashboard/dist/assets/mcp-BzVpaaKF.js +0 -2
  392. package/dashboard/dist/assets/mcp-BzVpaaKF.js.map +0 -1
  393. package/dashboard/dist/assets/mcp-query-wTuxTTCV.js +0 -2
  394. package/dashboard/dist/assets/mcp-query-wTuxTTCV.js.map +0 -1
  395. package/dashboard/dist/assets/useNatsEvents-DeGKHFTX.js +0 -2
  396. package/dashboard/dist/assets/useNatsEvents-DeGKHFTX.js.map +0 -1
  397. package/dashboard/dist/assets/useYamlActivityEvents-B5dHec6Y.js.map +0 -1
  398. package/dashboard/dist/assets/vendor-icons-DCLlGYO9.js.map +0 -1
  399. package/dashboard/dist/assets/yaml-workflows-CaLPMQha.js +0 -2
  400. package/dashboard/dist/assets/yaml-workflows-CaLPMQha.js.map +0 -1
  401. package/docs/img/01-login.png +0 -0
  402. package/docs/img/02-dashboard-home.png +0 -0
  403. package/docs/img/03-processes-list.png +0 -0
  404. package/docs/img/04-escalations-list.png +0 -0
  405. package/docs/img/05-mcp-servers.png +0 -0
  406. package/docs/img/06-mcp-pipelines.png +0 -0
  407. package/docs/img/07-workflows-list.png +0 -0
  408. package/docs/img/compilation/01-query-submit.png +0 -0
  409. package/docs/img/compilation/02-mcp-servers.png +0 -0
  410. package/docs/img/compilation/03-query-completed.png +0 -0
  411. package/docs/img/compilation/04-wizard-original.png +0 -0
  412. package/docs/img/compilation/05-wizard-timeline.png +0 -0
  413. package/docs/img/compilation/06-wizard-profile.png +0 -0
  414. package/docs/img/compilation/07-wizard-deploy.png +0 -0
  415. package/docs/img/compilation/08-wizard-test-modal.png +0 -0
  416. package/docs/img/compilation/09-wizard-test-compare.png +0 -0
  417. package/docs/img/compilation/10-wizard-verify.png +0 -0
  418. package/lib/db/README.md +0 -8
  419. /package/{lib → build/lib}/db/schemas/002_seed.sql +0 -0
  420. /package/{lib → build/lib}/db/schemas/003_workflow_discovery.sql +0 -0
  421. /package/{lib → build/lib}/db/schemas/004_query_router.sql +0 -0
  422. /package/{lib → build/lib}/db/schemas/005_triage_router.sql +0 -0
  423. /package/{lib → build/lib}/db/schemas/006_oauth.sql +0 -0
  424. /package/{lib → build/lib}/db/schemas/007_security.sql +0 -0
  425. /package/{lib → build/lib}/db/schemas/008_bot_accounts.sql +0 -0
  426. /package/{lib → build/lib}/db/schemas/009_audit_trail.sql +0 -0
  427. /package/{lib → build/lib}/db/schemas/010_credential_providers.sql +0 -0
  428. /package/{lib → build/lib}/db/schemas/012_drop_modality.sql +0 -0
  429. /package/{lib → build/lib}/db/schemas/013_execute_as.sql +0 -0
  430. /package/{lib → build/lib}/db/schemas/014_ephemeral_credentials.sql +0 -0
  431. /package/{lib → build/lib}/db/schemas/015_knowledge.sql +0 -0
@@ -0,0 +1,224 @@
1
+ # Capturing SOPs: Epic Referral Intake
2
+
3
+ ## The Problem Isn't the Integration
4
+
5
+ An engineering team is building for medical back-office customers who process referral intake. The customers know how to do this work. They know that BlueCross referrals in Texas require a specific prior-auth form submitted through the payer portal before the clinical documents are attached. They know that Epic flags certain `ServiceRequest` resources as urgent but the actual urgency depends on the referring provider's specialty. They know that when a coverage check returns `active` but the plan code starts with `HMO-`, there's an additional step the system doesn't surface.
6
+
7
+ This knowledge is institutional. It lives in the heads of intake coordinators who've been doing this for years. Some of it is written down — in training binders, in shared docs that were last updated eighteen months ago, in Slack threads that nobody will ever find again. Most of it isn't written down at all. It's the "ask Linda" layer of operations.
8
+
9
+ The engineering team doesn't need another integration platform. They need a way to capture what Linda knows and make it executable. When Linda leaves or the team scales from five coordinators to fifty, the knowledge should still be there — not as documentation that someone has to read and interpret, but as compiled tools that run the process the way Linda would.
10
+
11
+ That's the actual problem. Epic's FHIR APIs are the data layer. The institutional knowledge is the value layer. Long Tail is the machine that converts one into the other.
12
+
13
+ ---
14
+
15
+ ## Why Not Traditional Tools
16
+
17
+ The engineering team has evaluated the usual options:
18
+
19
+ **Integration middleware** builds point-to-point connections between systems. It moves data. It doesn't encode decisions. The middleware can sync a `ServiceRequest` from Epic to an internal queue, but it can't encode the rule that BlueCross-Texas referrals need a payer portal submission before document attachment. That logic ends up in custom code bolted onto the middleware, maintained by engineers who don't understand the clinical workflow, informed by specs that were wrong the day they were written.
20
+
21
+ **RPA** records clicks and replays them. It captures *what* the coordinator does in the browser, not *why*. When Epic's UI changes — and it changes often — the recording breaks. When the underlying rule changes — a payer updates their prior-auth requirements — the recording doesn't know. RPA captures motion, not knowledge.
22
+
23
+ **Custom software** works if the requirements are static. They aren't. Payers change rules quarterly. Epic releases updates. New customers bring new Epic configurations. The engineering team would spend most of their time maintaining the gap between what the software does and what the process requires, mediated by Jira tickets that describe the problem in terms the coordinator understands but the engineer has to translate.
24
+
25
+ The team wants to bypass all of this. Connect directly to Epic's FHIR APIs. Let the people who know the process describe it. Compile what works into tools. When something changes, the tool fails, the right person fixes it, and the updated knowledge compiles back in. No translation layer between the domain expert and the executable process.
26
+
27
+ ---
28
+
29
+ ## The Starting Point: Epic as Data Layer
30
+
31
+ Epic exposes FHIR R4 APIs through open.epic.com. The engineering team registers a custom MCP server that wraps the FHIR endpoints their referral workflows need. Each tool maps to a FHIR operation:
32
+
33
+ - `search_service_requests` — find referrals by patient, date, status, referring provider
34
+ - `get_patient` — retrieve patient demographics by MRN or FHIR ID
35
+ - `search_coverage` — check insurance status and plan details
36
+ - `search_document_references` — find clinical documents linked to a referral
37
+ - `create_task` — post a follow-up action back to Epic
38
+ - `update_service_request` — transition referral status
39
+
40
+ The server handles FHIR serialization, pagination, and query syntax. The team tags it `['ehr', 'epic', 'fhir', 'referrals']`. They also register the browser automation server for payer portals that don't have APIs.
41
+
42
+ This is plumbing. It takes a week. The interesting part is what happens next.
43
+
44
+ ---
45
+
46
+ ## Capturing the First SOP
47
+
48
+ ### The Session with Linda
49
+
50
+ The engineering team sits with Linda, the senior intake coordinator. They open the Pipeline Designer — the development environment where AI-assisted exploration is allowed — and ask Linda to walk through a referral.
51
+
52
+ Linda describes it as she does it:
53
+
54
+ > *"First I pull up the referral in Epic and check the insurance. If it's BlueCross and the plan code starts with HMO, I have to go to the BlueCross portal and submit a prior-auth request before I can attach the clinical docs. If it's Aetna, I check whether the referring provider is in-network first, because out-of-network Aetna referrals need a different form. For everything else, I just verify the coverage is active and move to documents."*
55
+
56
+ The engineer translates this into a prompt. The dynamic path runs — the LLM discovers the FHIR tools, executes the queries Linda described, follows her branching logic, and produces the result. Every FHIR call is checkpointed. The execution trace captures not just the API calls but the decision structure: the payer-specific branches, the ordering constraints, the conditions that trigger each path.
57
+
58
+ Linda looks at the output. "That's right, except when the coverage check returns `active` but there's a `copay-exception` extension, you need to flag it for manual review." The engineer adds this to the prompt and reruns. The LLM adjusts.
59
+
60
+ ### What Just Happened
61
+
62
+ Linda's institutional knowledge — the payer-specific rules, the ordering constraints, the exception handling — is now captured in an execution trace. Not in a spec document. Not in a Jira ticket. In a recorded sequence of API calls with decision points and branching logic that produced the correct result.
63
+
64
+ The AI is scaffolding here. It translated Linda's description into tool calls. It won't be in the production path. But it bridged the gap between "how Linda describes the process" and "a sequence of API operations that implements it." That gap is where traditional approaches lose fidelity.
65
+
66
+ ### Compilation
67
+
68
+ The team opens the Compilation Wizard. The compiler examines the execution trace and separates what's fixed (the branching logic, the FHIR query patterns, the payer-specific rules) from what's dynamic (the patient ID, the referral ID, the specific plan code values). It produces a deterministic DAG with typed inputs and typed outputs.
69
+
70
+ The team names it `intake-referral-coverage-check`, tags it `['referrals', 'insurance', 'epic', 'intake']`, and deploys it. Linda's knowledge about payer-specific coverage rules is now a compiled, versioned, executable tool. No LLM in the execution path. It runs the process the way Linda described it, every time, without Linda.
71
+
72
+ ---
73
+
74
+ ## Capturing the Next SOP, and the Next
75
+
76
+ The team runs more sessions. Each one captures a different piece of the intake process:
77
+
78
+ **Document verification.** Maria knows which clinical documents are required for each referral type. Orthopedic referrals need recent imaging. Cardiology needs an EKG report and recent labs. Behavioral health needs a clinical summary but not labs. Maria walks through the logic. The system captures it. The compiled tool checks `DocumentReference` resources against referral-type requirements and identifies what's missing.
79
+
80
+ **Provider validation.** James knows the receiving provider network. He knows which practices have stopped accepting certain insurance plans, which have capacity constraints, and which require specific referral formats. The compiled tool queries `Practitioner` and `Organization` resources and validates the referral against James's routing knowledge.
81
+
82
+ **Status transitions.** The team captures the full referral lifecycle: `draft` → `active` → `on-hold` (waiting for documents) → `active` (documents received) → `completed` (scheduled). Each transition has preconditions. Each precondition is a compiled check. The workflow won't advance a referral to `active` unless coverage is verified and required documents are attached — because that's how Linda's team actually does it.
83
+
84
+ Each compiled tool encodes one person's domain knowledge as an executable, testable, versionable artifact. The SOP isn't a document anymore. It's a tool.
85
+
86
+ ---
87
+
88
+ ## Connecting Directly
89
+
90
+ ### No Middleware in the Middle
91
+
92
+ The compiled workflows call Epic's FHIR APIs directly. There's no integration platform transforming data between systems. The `ServiceRequest` resource in Epic is the referral. The `Coverage` resource is the insurance. The `Task` resource is the follow-up action. Epic is the source of truth, and the workflows read and write to it without translation.
93
+
94
+ This matters for a practical reason: when Epic changes something — a new required field, a modified search parameter, an updated extension — the impact is immediate and visible. The compiled tool fails. The system creates an escalation with the full FHIR `OperationOutcome` error. The team knows exactly what changed and where.
95
+
96
+ With middleware in between, the same change produces a vague data-mapping error three layers deep, and someone spends a week figuring out which system changed what.
97
+
98
+ ### FHIR as the Shared Language
99
+
100
+ The tools the team builds speak FHIR. This means:
101
+
102
+ **Epic is the canonical record.** Workflows don't maintain shadow copies of referrals in a separate database. They query Epic for current state and write results back to Epic. If an intake coordinator opens Epic directly, they see the same status the workflow set.
103
+
104
+ **Tasks stay in Epic.** When a workflow identifies missing documents, it creates a FHIR `Task` resource assigned to the appropriate party. The referring provider's office sees the task in their Epic instance. No separate task-tracking system. No "check the portal for your action items" emails.
105
+
106
+ **Audit is in the workflow engine.** Every FHIR call, every decision branch, every escalation is recorded in the workflow execution history. The compliance team can trace a referral from intake to scheduling, including which credentials were used, which rules were applied, and which human decisions were made along the way.
107
+
108
+ ---
109
+
110
+ ## Identity: Who's Acting, On Whose Behalf
111
+
112
+ The engineering team serves multiple back-office customers. Each customer connects to their own Epic instance with their own SMART on FHIR credentials (registered at open.epic.com). The same compiled workflows run against different Epic environments.
113
+
114
+ **Service accounts per customer.** Each customer gets a bot account with stored Epic credentials — the SMART on FHIR private key, client ID, and token endpoint, encrypted at rest. When a workflow runs for Customer A, the credential cascade resolves Customer A's Epic token automatically.
115
+
116
+ **Dual identity.** Every workflow execution records who initiated it (the scheduler, the webhook, the human operator) and who it runs as (the customer's service account). The audit trail answers both questions.
117
+
118
+ **Scope enforcement.** The interceptor injects the principal's scopes into every activity. A customer scoped to `['epic:read', 'epic:referral:write']` cannot trigger a `Task` creation that requires `epic:task:write`. The FHIR token might allow it. The workflow layer doesn't.
119
+
120
+ **Ephemeral credentials for payer portals.** When a workflow needs to submit a prior-auth form on a payer's web portal, it escalates to a human operator for login credentials. The credential is encrypted, stored with a TTL, exchanged atomically at dispatch time, and deleted after use. It never persists in workflow state.
121
+
122
+ This isn't a section the team's customers think about. It's plumbing the engineering team builds once. But it's the plumbing that makes "one codebase, many customers, many Epic instances" possible without credential leakage or cross-tenant contamination.
123
+
124
+ ---
125
+
126
+ ## The Living Part: When Knowledge Needs to Update
127
+
128
+ ### Payer Rule Changes
129
+
130
+ Aetna updates their prior-authorization requirements for orthopedic referrals. The compiled `intake-referral-coverage-check` tool doesn't know this — it encodes last quarter's rules. Referrals that should trigger prior-auth are sailing through without it.
131
+
132
+ The failure surfaces when a downstream scheduling workflow can't complete because the payer rejects the referral. The escalation includes the full context: which referral, which payer, which step failed, and the payer's rejection reason.
133
+
134
+ The team brings Linda back to the Pipeline Designer. "Oh, Aetna changed this in March. Now any ortho referral with a plan code starting with `PPO-` also needs prior auth, not just the HMO plans." The engineer reruns the dynamic path with the updated logic. It succeeds. They compile. The new version deploys. The old version is still there for rollback.
135
+
136
+ Linda's updated knowledge is now in the system. The SOP evolved. No spec document was rewritten. No Jira ticket went through a sprint. The compiled tool *is* the current SOP.
137
+
138
+ ### Epic API Changes
139
+
140
+ Epic updates their FHIR implementation. A field that was optional on `ServiceRequest` is now required. The compiled tool starts returning 422 errors.
141
+
142
+ The system doesn't swallow these. Non-2xx FHIR responses throw typed errors with the status code, the `OperationOutcome` body, and the request context. The interceptor catches the failure and escalates with full diagnostic information.
143
+
144
+ The team uses the dynamic path in development — AI is allowed there — to explore the change against Epic's sandbox. The LLM reads the error, adjusts the query, succeeds. The team compiles the corrected pattern. Production resumes.
145
+
146
+ ### New Customer, Different Epic Configuration
147
+
148
+ A new customer's Epic instance has a custom extension on `Coverage` resources that indicates whether a plan requires a specialist referral versus an open-access referral. The existing compiled tools don't read this extension.
149
+
150
+ The team doesn't rewrite the tools. They run a dynamic session against the new customer's sandbox, discover the extension, and compile a customer-specific variant of the coverage check. They tag it `['referrals', 'insurance', 'epic', 'customer-b']`. The routing layer uses tags to match the right tool to the right customer.
151
+
152
+ The core intake workflow stays the same. The coverage-check step resolves to a different compiled tool depending on which customer's service account is running. The process is the same. The payer-specific and Epic-specific details differ. The tag system handles the routing.
153
+
154
+ ---
155
+
156
+ ## The Composition: SOPs Build on SOPs
157
+
158
+ Individual compiled tools are building blocks. The full referral intake process composes them:
159
+
160
+ 1. **Validate referral** — check required FHIR fields, verify referring provider, confirm receiving practice accepts the referral type
161
+ 2. **Check coverage** — payer-specific insurance verification with prior-auth detection
162
+ 3. **Verify documents** — referral-type-specific clinical document requirements
163
+ 4. **Resolve gaps** — if documents are missing or prior-auth is needed, escalate to the appropriate party and wait
164
+ 5. **Transition status** — advance the referral through Epic's status lifecycle with appropriate `Task` creation
165
+
166
+ Each step is a compiled tool that encodes one person's domain knowledge. The composition is itself compiled — a deterministic DAG that sequences the steps with conditional branches and escalation points. No LLM anywhere in the production path.
167
+
168
+ The escalation in step 4 is where institutional knowledge grows. When the workflow pauses for a missing document, the coordinator who resolves it might say: "This always happens with referrals from Dr. Chen's office — they never attach the imaging report." That pattern becomes a compiled pre-check that flags Dr. Chen's referrals for document follow-up *before* the gap-resolution step. The SOP gets tighter with use.
169
+
170
+ ---
171
+
172
+ ## The Browser Layer: Payer Portals Without APIs
173
+
174
+ Some parts of referral intake require browser interaction. Payer authorization portals, legacy fax gateways, state Medicaid enrollment systems — these have web interfaces but no APIs.
175
+
176
+ The team compiles browser workflows the same way they compile FHIR workflows. In development, the LLM navigates the portal, discovers the form fields, submits the request, and captures the confirmation. The engineer reviews the execution, corrects any brittle selectors, and compiles. In production, the compiled DAG replays the exact browser sequence — no LLM, deterministic, durable.
177
+
178
+ When a portal redesigns its interface, the compiled script fails. The escalation includes a screenshot of the new layout. The team recompiles against the updated page. The browser backend is pluggable — Playwright locally, a managed browser service in production — but the compiled workflow doesn't change.
179
+
180
+ This is where "bypassing traditional tools" is most literal. Instead of an RPA platform that records mouse movements and breaks on every UI change, the team has compiled browser workflows that encode the *intent* (submit prior-auth form with these fields) in a structure that can be updated when the surface changes.
181
+
182
+ ---
183
+
184
+ ## What the Engineering Team Built
185
+
186
+ After three months, the engineering team has delivered something that none of the traditional tools could:
187
+
188
+ **Executable SOPs.** Each compiled workflow encodes a specific piece of the intake process as described by the people who do it. The SOPs aren't documents — they're running code that produces the same result the domain expert would, deterministically, across every customer's Epic instance.
189
+
190
+ **A knowledge inventory that grows.** Every session with a domain expert produces compiled tools. Every escalation resolution that reveals a repeatable pattern produces another. The system accumulates operational knowledge monotonically — new compilations add capabilities, version history preserves the evolution.
191
+
192
+ **Self-maintaining integrations.** When Epic's API changes, the affected tool fails and escalates with precise diagnostic context. The fix is a recompilation, not a rewrite. When a payer changes rules, the domain expert describes the change, the dynamic path validates it, and the compiled tool updates. The engineering team isn't maintaining a gap between spec and implementation because there is no spec — the compiled tool is the specification.
193
+
194
+ **Customer isolation without code branches.** Service accounts, credential scoping, and tag-based routing handle multi-tenancy. The same compiled workflows serve every customer. Customer-specific variations are separate compiled tools selected by the routing layer. No `if (customer === 'A')` branches in the codebase.
195
+
196
+ **A compliance-ready audit trail.** Every referral processed has a complete execution record: which FHIR calls were made, which credentials were used, which human decisions were involved, which compiled tool version ran. The data is in Postgres — queryable, exportable, backupable.
197
+
198
+ ### What Didn't Ship
199
+
200
+ No middleware platform. No RPA licenses. No integration-platform-as-a-service subscription. No custom application with a six-month development timeline and a maintenance budget.
201
+
202
+ The engineering team wrote one MCP server that wraps Epic's FHIR APIs. They compiled workflows from sessions with domain experts. They deployed it on their own infrastructure — Postgres and containers. The institutional knowledge that previously lived in Linda's head and Maria's training binder now lives in compiled tools that run without either of them present.
203
+
204
+ ---
205
+
206
+ ## From 0 to 1, and 1 to 1.5
207
+
208
+ The system didn't arrive complete. It grew.
209
+
210
+ **0 to 1** was the first compiled SOP: Linda's coverage-check workflow running against Epic's sandbox. A single tool that encoded a single person's knowledge about a single piece of the intake process. It proved the concept — institutional knowledge could be captured as a compiled tool and executed without AI, without the domain expert present, against a real FHIR API.
211
+
212
+ **1 to 1.1** was multi-tenancy: the same tool running against multiple customers' Epic instances with proper credential isolation.
213
+
214
+ **1.1 to 1.2** was breadth: capturing more SOPs from more domain experts. Document verification from Maria. Provider routing from James. Each session added to the tool inventory.
215
+
216
+ **1.2 to 1.3** was composition: individual tools assembled into the full intake pipeline, with escalation points where human judgment is still required.
217
+
218
+ **1.3 to 1.5** is the living part: the system updating itself when the landscape shifts. A payer changes rules, a compiled tool fails, the domain expert describes the change, the tool recompiles. The gap between "how the process works" and "what the system does" stays small because the feedback loop is tight — failure to escalation to resolution to recompilation.
219
+
220
+ **1.5 to 2** is where it gets interesting. The escalation history reveals patterns. Which payers change rules most often. Which Epic configurations cause the most failures. Which referral types need the most human intervention. The engineering team uses this data to prioritize: build more specific tools where the escalation rate is highest. The system's own operational history guides its evolution.
221
+
222
+ The long tail of referral edge cases gets shorter. Not because someone anticipated every case, but because the system compiled solutions as the team encountered them. Each solved case is a permanent capability. The SOP library grows. The escalation rate drops. The domain experts spend less time on routine intake and more time on the genuinely novel cases — the ones that actually need human judgment.
223
+
224
+ That's what a living system looks like. Not software that was correct when it shipped. Software that gets more correct the longer it runs, because it absorbs what the people around it know.
@@ -11,7 +11,7 @@ Escalation strategies are the pluggable layer that decides what happens when a r
11
11
  - [How It Works](#how-it-works)
12
12
  - [The Default Strategy](#the-default-strategy)
13
13
  - [The MCP Strategy](#the-mcp-strategy)
14
- - [The `_lt` Namespace](#the-_lt-namespace)
14
+ - [The _lt Namespace](#the-_lt-namespace)
15
15
  - [The Triage Workflow](#the-triage-workflow)
16
16
  - [Writing a Custom Strategy](#writing-a-custom-strategy)
17
17
  - [Configuration](#configuration)
@@ -114,8 +114,7 @@ The `mcpTriage` workflow is a single, self-contained workflow that handles the e
114
114
 
115
115
  1. **Queries upstream tasks** — reads all tasks sharing the same `originId` to understand what happened before
116
116
  2. **Reads the resolver hint** — `_lt.hint` tells it what kind of remediation is needed
117
- 3. **Calls MCP tools** — based on the hint, calls the appropriate tools:
118
- - `image_orientation` → lists document pages, calls `rotate_page` for each
117
+ 3. **Calls MCP tools** — based on the hint, calls the appropriate tools: `image_orientation` → lists document pages, calls `rotate_page` for each
119
118
  4. **Handles the exit directly** — either starts the original workflow with corrected data (direct resolution) or creates a targeted escalation on the original task
120
119
  5. **Signals back** — the re-invoked workflow succeeds, and the interceptor signals through standard channels back to the original parent orchestrator
121
120
 
package/docs/events.md CHANGED
@@ -133,6 +133,34 @@ await eventRegistry.connect();
133
133
 
134
134
  On disconnect, the adapter calls `drain()` on the NATS connection, ensuring in-flight publishes complete before closing.
135
135
 
136
+ ## Callback Adapter
137
+
138
+ `CallbackEventAdapter` delivers events via registered callbacks. Use it when Long Tail runs as an embedded package and you want event subscriptions without socket.io or NATS.
139
+
140
+ ```typescript
141
+ import { eventRegistry, CallbackEventAdapter } from '@hotmeshio/long-tail';
142
+
143
+ const adapter = new CallbackEventAdapter();
144
+ eventRegistry.register(adapter);
145
+ await adapter.connect();
146
+
147
+ // Exact match
148
+ const unsub = adapter.on('escalation.claimed', (event) => {
149
+ console.log('claimed:', event.escalationId);
150
+ });
151
+
152
+ // Category wildcard — matches all task.* events
153
+ adapter.on('task.*', (event) => { ... });
154
+
155
+ // Global wildcard
156
+ adapter.on('*', (event) => { ... });
157
+
158
+ // Unsubscribe
159
+ unsub();
160
+ ```
161
+
162
+ The adapter is registered automatically by `start()`. If you use `createClient()`, the SDK exposes it as `lt.events.on()` — see the [SDK guide](sdk.md) for details.
163
+
136
164
  ## In-Memory Adapter
137
165
 
138
166
  `InMemoryEventAdapter` captures events in an array. It exists for testing.