@hotmeshio/long-tail 0.1.13 → 0.1.15

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 (424) hide show
  1. package/README.md +15 -0
  2. package/build/api/escalations/bulk.d.ts +78 -0
  3. package/build/api/escalations/bulk.js +279 -0
  4. package/build/api/escalations/claim.d.ts +30 -0
  5. package/build/api/escalations/claim.js +121 -0
  6. package/build/api/escalations/create.d.ts +29 -0
  7. package/build/api/escalations/create.js +101 -0
  8. package/build/api/escalations/helpers.d.ts +10 -0
  9. package/build/api/escalations/helpers.js +80 -0
  10. package/build/api/escalations/index.d.ts +6 -0
  11. package/build/api/escalations/index.js +26 -0
  12. package/build/api/escalations/list.d.ts +75 -0
  13. package/build/api/escalations/list.js +170 -0
  14. package/build/api/escalations/resolve.d.ts +18 -0
  15. package/build/api/escalations/resolve.js +243 -0
  16. package/build/api/escalations/single.d.ts +37 -0
  17. package/build/api/escalations/single.js +123 -0
  18. package/build/api/files.d.ts +16 -0
  19. package/build/api/files.js +61 -0
  20. package/build/api/knowledge.d.ts +36 -0
  21. package/build/api/knowledge.js +112 -0
  22. package/build/api/mcp/index.d.ts +2 -0
  23. package/build/api/mcp/index.js +16 -0
  24. package/build/api/{mcp.d.ts → mcp/servers.d.ts} +1 -33
  25. package/build/api/{mcp.js → mcp/servers.js} +4 -65
  26. package/build/api/mcp/tools.d.ts +33 -0
  27. package/build/api/mcp/tools.js +64 -0
  28. package/build/api/mcp-runs.d.ts +2 -0
  29. package/build/api/mcp-runs.js +2 -0
  30. package/build/api/settings.js +9 -1
  31. package/build/api/workflow-sets.d.ts +11 -0
  32. package/build/api/workflow-sets.js +62 -0
  33. package/build/api/workflows/config.d.ts +64 -0
  34. package/build/api/workflows/config.js +142 -0
  35. package/build/api/workflows/discovery.d.ts +29 -0
  36. package/build/api/workflows/discovery.js +153 -0
  37. package/build/api/workflows/index.d.ts +3 -0
  38. package/build/api/workflows/index.js +18 -0
  39. package/build/api/workflows/invocation.d.ts +67 -0
  40. package/build/api/workflows/invocation.js +188 -0
  41. package/build/api/yaml-workflows/cron.d.ts +39 -0
  42. package/build/api/yaml-workflows/cron.js +127 -0
  43. package/build/api/{yaml-workflows.d.ts → yaml-workflows/crud.d.ts} +22 -137
  44. package/build/api/{yaml-workflows.js → yaml-workflows/crud.js} +86 -358
  45. package/build/api/yaml-workflows/deploy.d.ts +71 -0
  46. package/build/api/yaml-workflows/deploy.js +223 -0
  47. package/build/api/yaml-workflows/helpers.d.ts +2 -0
  48. package/build/api/yaml-workflows/helpers.js +8 -0
  49. package/build/api/yaml-workflows/index.d.ts +4 -0
  50. package/build/api/yaml-workflows/index.js +27 -0
  51. package/build/api/yaml-workflows/versions.d.ts +43 -0
  52. package/build/api/yaml-workflows/versions.js +124 -0
  53. package/build/bin/ltc.d.ts +2 -0
  54. package/build/bin/ltc.js +220 -0
  55. package/build/examples/seed-data.d.ts +55 -0
  56. package/build/examples/seed-data.js +161 -0
  57. package/build/examples/seed.js +7 -164
  58. package/build/lib/cli/auth.d.ts +23 -0
  59. package/build/lib/cli/auth.js +167 -0
  60. package/build/lib/cli/client.d.ts +6 -0
  61. package/build/lib/cli/client.js +31 -0
  62. package/build/lib/cli/commands/escalations.d.ts +19 -0
  63. package/build/lib/cli/commands/escalations.js +69 -0
  64. package/build/lib/cli/commands/knowledge.d.ts +18 -0
  65. package/build/lib/cli/commands/knowledge.js +87 -0
  66. package/build/lib/cli/commands/mcp.d.ts +8 -0
  67. package/build/lib/cli/commands/mcp.js +33 -0
  68. package/build/lib/cli/commands/pipelines.d.ts +16 -0
  69. package/build/lib/cli/commands/pipelines.js +67 -0
  70. package/build/lib/cli/commands/status.d.ts +1 -0
  71. package/build/lib/cli/commands/status.js +28 -0
  72. package/build/lib/cli/commands/users.d.ts +7 -0
  73. package/build/lib/cli/commands/users.js +25 -0
  74. package/build/lib/cli/commands/workflows.d.ts +16 -0
  75. package/build/lib/cli/commands/workflows.js +104 -0
  76. package/build/lib/cli/compile.d.ts +2 -0
  77. package/build/lib/cli/compile.js +165 -0
  78. package/build/lib/cli/format.d.ts +23 -0
  79. package/build/lib/cli/format.js +94 -0
  80. package/build/lib/cli/init.d.ts +1 -0
  81. package/build/lib/cli/init.js +61 -0
  82. package/build/lib/cli/output.d.ts +27 -0
  83. package/build/lib/cli/output.js +126 -0
  84. package/build/lib/cli/scanner.d.ts +10 -0
  85. package/build/lib/cli/scanner.js +164 -0
  86. package/build/lib/cli/types.d.ts +16 -0
  87. package/build/lib/cli/types.js +2 -0
  88. package/build/lib/logger/index.d.ts +0 -9
  89. package/build/lib/logger/index.js +9 -4
  90. package/build/lib/storage/index.js +2 -2
  91. package/build/lib/storage/local.d.ts +15 -0
  92. package/build/lib/storage/local.js +63 -0
  93. package/build/lib/storage/mime.d.ts +4 -0
  94. package/build/lib/storage/mime.js +31 -0
  95. package/build/lib/storage/s3.d.ts +16 -0
  96. package/build/lib/storage/s3.js +70 -0
  97. package/build/lib/storage/types.d.ts +18 -0
  98. package/build/modules/utils.d.ts +73 -0
  99. package/build/modules/utils.js +84 -0
  100. package/build/routes/file-browser.d.ts +2 -0
  101. package/build/routes/file-browser.js +126 -0
  102. package/build/routes/files.js +25 -17
  103. package/build/routes/index.js +4 -0
  104. package/build/routes/knowledge.d.ts +2 -0
  105. package/build/routes/knowledge.js +141 -0
  106. package/build/routes/mcp-runs.js +2 -0
  107. package/build/routes/workflow-sets.js +9 -0
  108. package/build/routes/yaml-workflows/crud.js +9 -0
  109. package/build/routes/yaml-workflows/deployment.js +8 -0
  110. package/build/sdk/index.d.ts +17 -0
  111. package/build/sdk/index.js +19 -0
  112. package/build/services/insight/index.d.ts +13 -0
  113. package/build/services/insight/index.js +4 -7
  114. package/build/services/insight/prompts.d.ts +1 -1
  115. package/build/services/insight/prompts.js +1 -1
  116. package/build/services/mcp/client/connection-dispatch.d.ts +18 -0
  117. package/build/services/mcp/client/connection-dispatch.js +78 -0
  118. package/build/services/mcp/client/connection-lifecycle.d.ts +48 -0
  119. package/build/services/mcp/client/connection-lifecycle.js +296 -0
  120. package/build/services/mcp/client/connection-test.d.ts +10 -0
  121. package/build/services/mcp/client/connection-test.js +49 -0
  122. package/build/services/mcp/client/connection.d.ts +3 -68
  123. package/build/services/mcp/client/connection.js +15 -393
  124. package/build/services/mcp/server-lifecycle.d.ts +27 -0
  125. package/build/services/mcp/server-lifecycle.js +49 -0
  126. package/build/services/mcp/server-tools.d.ts +13 -0
  127. package/build/services/mcp/server-tools.js +287 -0
  128. package/build/services/mcp/server.d.ts +2 -26
  129. package/build/services/mcp/server.js +7 -315
  130. package/build/services/mcp-runs/queries.d.ts +2 -0
  131. package/build/services/mcp-runs/queries.js +11 -1
  132. package/build/services/mcp-runs/sql.d.ts +1 -1
  133. package/build/services/mcp-runs/sql.js +2 -2
  134. package/build/services/workflow-sets/db.d.ts +1 -0
  135. package/build/services/workflow-sets/db.js +6 -0
  136. package/build/services/workflow-sets/index.d.ts +1 -1
  137. package/build/services/workflow-sets/index.js +2 -1
  138. package/build/services/workflow-sets/sql.d.ts +1 -0
  139. package/build/services/workflow-sets/sql.js +6 -1
  140. package/build/services/yaml-workflow/builder-regenerate.d.ts +25 -0
  141. package/build/services/yaml-workflow/builder-regenerate.js +111 -0
  142. package/build/services/yaml-workflow/db-versions.d.ts +17 -0
  143. package/build/services/yaml-workflow/db-versions.js +76 -0
  144. package/build/services/yaml-workflow/db.d.ts +14 -12
  145. package/build/services/yaml-workflow/db.js +32 -70
  146. package/build/services/yaml-workflow/deployer-helpers.js +48 -17
  147. package/build/services/yaml-workflow/durable-compiler/index.d.ts +22 -0
  148. package/build/services/yaml-workflow/durable-compiler/index.js +168 -0
  149. package/build/services/yaml-workflow/durable-compiler/parser.d.ts +12 -0
  150. package/build/services/yaml-workflow/durable-compiler/parser.js +110 -0
  151. package/build/services/yaml-workflow/durable-compiler/prompts.d.ts +18 -0
  152. package/build/services/yaml-workflow/durable-compiler/prompts.js +570 -0
  153. package/build/services/yaml-workflow/durable-compiler/types.d.ts +51 -0
  154. package/build/services/yaml-workflow/durable-compiler/types.js +5 -0
  155. package/build/services/yaml-workflow/generator.js +4 -4
  156. package/build/services/yaml-workflow/pipeline/build/dag-assembly.d.ts +17 -0
  157. package/build/services/yaml-workflow/pipeline/build/dag-assembly.js +192 -0
  158. package/build/services/yaml-workflow/pipeline/build/dag.d.ts +4 -13
  159. package/build/services/yaml-workflow/pipeline/build/dag.js +9 -185
  160. package/build/services/yaml-workflow/pipeline/build/index.d.ts +2 -1
  161. package/build/services/yaml-workflow/pipeline/build/index.js +3 -2
  162. package/build/services/yaml-workflow/pipeline/build/utils.d.ts +0 -2
  163. package/build/services/yaml-workflow/pipeline/build/utils.js +0 -8
  164. package/build/services/yaml-workflow/pipeline/prompt-templates.d.ts +10 -0
  165. package/build/services/yaml-workflow/pipeline/prompt-templates.js +270 -0
  166. package/build/services/yaml-workflow/pipeline/prompts.d.ts +3 -6
  167. package/build/services/yaml-workflow/pipeline/prompts.js +8 -263
  168. package/build/services/yaml-workflow/sql.d.ts +2 -1
  169. package/build/services/yaml-workflow/sql.js +10 -3
  170. package/build/start/workers.js +6 -5
  171. package/build/system/activities/file-storage.d.ts +4 -0
  172. package/build/system/activities/file-storage.js +7 -1
  173. package/build/system/activities/knowledge.d.ts +23 -0
  174. package/build/system/activities/knowledge.js +50 -10
  175. package/build/system/activities/schema-exchange.d.ts +50 -0
  176. package/build/system/activities/schema-exchange.js +210 -0
  177. package/build/system/activities/sql.d.ts +4 -1
  178. package/build/system/activities/sql.js +37 -2
  179. package/build/system/index.js +1 -0
  180. package/build/system/mcp-servers/file-storage.js +3 -1
  181. package/build/system/mcp-servers/human-queue-schemas.d.ts +91 -0
  182. package/build/system/mcp-servers/human-queue-schemas.js +42 -0
  183. package/build/system/mcp-servers/human-queue.d.ts +2 -6
  184. package/build/system/mcp-servers/human-queue.js +9 -51
  185. package/build/system/mcp-servers/knowledge.js +69 -6
  186. package/build/system/mcp-servers/schema-exchange.d.ts +4 -0
  187. package/build/system/mcp-servers/schema-exchange.js +93 -0
  188. package/build/system/mcp-servers/workflow-compiler.js +54 -0
  189. package/build/system/seed/server-definitions.d.ts +112 -1
  190. package/build/system/seed/server-definitions.js +37 -0
  191. package/build/system/seed/tool-manifests-data.d.ts +87 -0
  192. package/build/system/seed/tool-manifests-data.js +37 -1
  193. package/build/system/seed/tool-manifests-knowledge.d.ts +9 -1
  194. package/build/system/seed/tool-manifests-knowledge.js +6 -5
  195. package/build/system/workflows/mcp-triage/activities-proxy.d.ts +21 -0
  196. package/build/system/workflows/mcp-triage/activities-proxy.js +70 -0
  197. package/build/system/workflows/mcp-triage/index.js +17 -75
  198. package/build/system/workflows/mcp-workflow-builder/prompts.d.ts +1 -1
  199. package/build/system/workflows/mcp-workflow-builder/prompts.js +21 -20
  200. package/build/system/workflows/mcp-workflow-planner/activities/persist.d.ts +2 -1
  201. package/build/system/workflows/mcp-workflow-planner/activities/persist.js +4 -3
  202. package/build/system/workflows/mcp-workflow-planner/index.js +41 -5
  203. package/build/system/workflows/mcp-workflow-planner/prompts.d.ts +1 -1
  204. package/build/system/workflows/mcp-workflow-planner/prompts.js +3 -3
  205. package/build/tsconfig.tsbuildinfo +1 -1
  206. package/dashboard/dist/assets/{AdminDashboard-DUrSBQOl.js → AdminDashboard-NLryl1_B.js} +2 -2
  207. package/dashboard/dist/assets/{AdminDashboard-DUrSBQOl.js.map → AdminDashboard-NLryl1_B.js.map} +1 -1
  208. package/dashboard/dist/assets/AvailableEscalationsPage-6vexlrk3.js +2 -0
  209. package/dashboard/dist/assets/AvailableEscalationsPage-6vexlrk3.js.map +1 -0
  210. package/dashboard/dist/assets/{BotPicker-Cg5iNEkm.js → BotPicker-DWhn0tr1.js} +2 -2
  211. package/dashboard/dist/assets/{BotPicker-Cg5iNEkm.js.map → BotPicker-DWhn0tr1.js.map} +1 -1
  212. package/dashboard/dist/assets/{CollapsibleSection-Kd9UIyeU.js → CollapsibleSection-CgYgQiOc.js} +2 -2
  213. package/dashboard/dist/assets/{CollapsibleSection-Kd9UIyeU.js.map → CollapsibleSection-CgYgQiOc.js.map} +1 -1
  214. package/dashboard/dist/assets/{ConfirmDeleteModal-DZMgmlof.js → ConfirmDeleteModal-DCKAPXD3.js} +2 -2
  215. package/dashboard/dist/assets/{ConfirmDeleteModal-DZMgmlof.js.map → ConfirmDeleteModal-DCKAPXD3.js.map} +1 -1
  216. package/dashboard/dist/assets/{CopyableId-cPFTRm8q.js → CopyableId-DXkaAOYk.js} +2 -2
  217. package/dashboard/dist/assets/{CopyableId-cPFTRm8q.js.map → CopyableId-DXkaAOYk.js.map} +1 -1
  218. package/dashboard/dist/assets/CredentialsPage-B361BOfU.js +2 -0
  219. package/dashboard/dist/assets/{CredentialsPage-DJablIbs.js.map → CredentialsPage-B361BOfU.js.map} +1 -1
  220. package/dashboard/dist/assets/{CustomDurationPicker-NgIP6YDW.js → CustomDurationPicker-D2G1ldiF.js} +2 -2
  221. package/dashboard/dist/assets/{CustomDurationPicker-NgIP6YDW.js.map → CustomDurationPicker-D2G1ldiF.js.map} +1 -1
  222. package/dashboard/dist/assets/{DataTable-CTRhTAfT.js → DataTable-DXSUbA26.js} +2 -2
  223. package/dashboard/dist/assets/{DataTable-CTRhTAfT.js.map → DataTable-DXSUbA26.js.map} +1 -1
  224. package/dashboard/dist/assets/{ElapsedCell-HcSJ_MMs.js → ElapsedCell-CQGqkXP_.js} +2 -2
  225. package/dashboard/dist/assets/{ElapsedCell-HcSJ_MMs.js.map → ElapsedCell-CQGqkXP_.js.map} +1 -1
  226. package/dashboard/dist/assets/{EmptyState-joNbd4gg.js → EmptyState-Dep92Wkg.js} +2 -2
  227. package/dashboard/dist/assets/{EmptyState-joNbd4gg.js.map → EmptyState-Dep92Wkg.js.map} +1 -1
  228. package/dashboard/dist/assets/{EscalationsOverview-DpXDnQux.js → EscalationsOverview-DVEFVjs7.js} +2 -2
  229. package/dashboard/dist/assets/{EscalationsOverview-DpXDnQux.js.map → EscalationsOverview-DVEFVjs7.js.map} +1 -1
  230. package/dashboard/dist/assets/{EventTable-CYem3v8n.js → EventTable-BMJAPkMi.js} +2 -2
  231. package/dashboard/dist/assets/{EventTable-CYem3v8n.js.map → EventTable-BMJAPkMi.js.map} +1 -1
  232. package/dashboard/dist/assets/{FilterBar-BiO8SOzc.js → FilterBar-DbVbCzH2.js} +2 -2
  233. package/dashboard/dist/assets/{FilterBar-BiO8SOzc.js.map → FilterBar-DbVbCzH2.js.map} +1 -1
  234. package/dashboard/dist/assets/{ListToolbar-6yRDh2e9.js → ListToolbar-0XNuXj0M.js} +2 -2
  235. package/dashboard/dist/assets/{ListToolbar-6yRDh2e9.js.map → ListToolbar-0XNuXj0M.js.map} +1 -1
  236. package/dashboard/dist/assets/{McpOverview-CUgSxkQe.js → McpOverview-CeYnCzBN.js} +2 -2
  237. package/dashboard/dist/assets/{McpOverview-CUgSxkQe.js.map → McpOverview-CeYnCzBN.js.map} +1 -1
  238. package/dashboard/dist/assets/McpQueryDetailPage-t3qW3QNa.js +5 -0
  239. package/dashboard/dist/assets/McpQueryDetailPage-t3qW3QNa.js.map +1 -0
  240. package/dashboard/dist/assets/McpQueryPage-CfUcdzaj.js +2 -0
  241. package/dashboard/dist/assets/{McpQueryPage-lV6kfDG5.js.map → McpQueryPage-CfUcdzaj.js.map} +1 -1
  242. package/dashboard/dist/assets/McpRunDetailPage-CZtodW_Z.js +2 -0
  243. package/dashboard/dist/assets/McpRunDetailPage-CZtodW_Z.js.map +1 -0
  244. package/dashboard/dist/assets/McpRunsPage-Dzgq7HGt.js +2 -0
  245. package/dashboard/dist/assets/McpRunsPage-Dzgq7HGt.js.map +1 -0
  246. package/dashboard/dist/assets/{Modal-BuTvD0pz.js → Modal-yyhUeKoA.js} +2 -2
  247. package/dashboard/dist/assets/{Modal-BuTvD0pz.js.map → Modal-yyhUeKoA.js.map} +1 -1
  248. package/dashboard/dist/assets/OperatorDashboard-Ceh7OQtZ.js +2 -0
  249. package/dashboard/dist/assets/{OperatorDashboard-C9SSV96T.js.map → OperatorDashboard-Ceh7OQtZ.js.map} +1 -1
  250. package/dashboard/dist/assets/{PageHeader-BcTVF9ul.js → PageHeader-CZ9a8cpr.js} +2 -2
  251. package/dashboard/dist/assets/{PageHeader-BcTVF9ul.js.map → PageHeader-CZ9a8cpr.js.map} +1 -1
  252. package/dashboard/dist/assets/{PageHeaderWithStats-BI7JG5x6.js → PageHeaderWithStats-BJuNs5NM.js} +2 -2
  253. package/dashboard/dist/assets/{PageHeaderWithStats-BI7JG5x6.js.map → PageHeaderWithStats-BJuNs5NM.js.map} +1 -1
  254. package/dashboard/dist/assets/{PriorityBadge-DqVaOU65.js → PriorityBadge-BrPikMFy.js} +2 -2
  255. package/dashboard/dist/assets/{PriorityBadge-DqVaOU65.js.map → PriorityBadge-BrPikMFy.js.map} +1 -1
  256. package/dashboard/dist/assets/{ProcessDetailPage-hFMhf9qa.js → ProcessDetailPage-2miaYd8G.js} +2 -2
  257. package/dashboard/dist/assets/{ProcessDetailPage-hFMhf9qa.js.map → ProcessDetailPage-2miaYd8G.js.map} +1 -1
  258. package/dashboard/dist/assets/{ProcessesListPage-ByVoBCQ3.js → ProcessesListPage-DqpRDqjk.js} +2 -2
  259. package/dashboard/dist/assets/{ProcessesListPage-ByVoBCQ3.js.map → ProcessesListPage-DqpRDqjk.js.map} +1 -1
  260. package/dashboard/dist/assets/{RolePill-D9ZIkYiu.js → RolePill-DxbJMfJu.js} +2 -2
  261. package/dashboard/dist/assets/{RolePill-D9ZIkYiu.js.map → RolePill-DxbJMfJu.js.map} +1 -1
  262. package/dashboard/dist/assets/{RolesPage-SMedMuqa.js → RolesPage-CYHRo21-.js} +2 -2
  263. package/dashboard/dist/assets/{RolesPage-SMedMuqa.js.map → RolesPage-CYHRo21-.js.map} +1 -1
  264. package/dashboard/dist/assets/{RowActions-yDhwwDbU.js → RowActions-DurFwIwe.js} +2 -2
  265. package/dashboard/dist/assets/{RowActions-yDhwwDbU.js.map → RowActions-DurFwIwe.js.map} +1 -1
  266. package/dashboard/dist/assets/RunAsSelector-CNKraP6u.js +2 -0
  267. package/dashboard/dist/assets/RunAsSelector-CNKraP6u.js.map +1 -0
  268. package/dashboard/dist/assets/{StatCard-BrBnQFxh.js → StatCard-CKplpK3w.js} +2 -2
  269. package/dashboard/dist/assets/{StatCard-BrBnQFxh.js.map → StatCard-CKplpK3w.js.map} +1 -1
  270. package/dashboard/dist/assets/{StatusBadge-xgb-lZku.js → StatusBadge-Dm0V1dNN.js} +2 -2
  271. package/dashboard/dist/assets/{StatusBadge-xgb-lZku.js.map → StatusBadge-Dm0V1dNN.js.map} +1 -1
  272. package/dashboard/dist/assets/{StepIndicator-B9ps2SvM.js → StepIndicator-Dicx0WTZ.js} +2 -2
  273. package/dashboard/dist/assets/{StepIndicator-B9ps2SvM.js.map → StepIndicator-Dicx0WTZ.js.map} +1 -1
  274. package/dashboard/dist/assets/{StickyPagination-DTIjBKN3.js → StickyPagination-B2jYvU3-.js} +2 -2
  275. package/dashboard/dist/assets/{StickyPagination-DTIjBKN3.js.map → StickyPagination-B2jYvU3-.js.map} +1 -1
  276. package/dashboard/dist/assets/SwimlaneTimeline-ClwumkT1.js +2 -0
  277. package/dashboard/dist/assets/SwimlaneTimeline-ClwumkT1.js.map +1 -0
  278. package/dashboard/dist/assets/{TagInput-CdNUuqk4.js → TagInput-CypDZ6Kl.js} +2 -2
  279. package/dashboard/dist/assets/{TagInput-CdNUuqk4.js.map → TagInput-CypDZ6Kl.js.map} +1 -1
  280. package/dashboard/dist/assets/{TaskDetailPage-C-nzaNea.js → TaskDetailPage-DooDNJGT.js} +2 -2
  281. package/dashboard/dist/assets/{TaskDetailPage-C-nzaNea.js.map → TaskDetailPage-DooDNJGT.js.map} +1 -1
  282. package/dashboard/dist/assets/{TaskQueuePill-Lvr2-NzS.js → TaskQueuePill-C1hZ-j31.js} +2 -2
  283. package/dashboard/dist/assets/{TaskQueuePill-Lvr2-NzS.js.map → TaskQueuePill-C1hZ-j31.js.map} +1 -1
  284. package/dashboard/dist/assets/{TasksListPage-DSUmD84y.js → TasksListPage-D7CdkAeg.js} +2 -2
  285. package/dashboard/dist/assets/{TasksListPage-DSUmD84y.js.map → TasksListPage-D7CdkAeg.js.map} +1 -1
  286. package/dashboard/dist/assets/{TimeAgo-BZdLdrIh.js → TimeAgo-B5LXB2aj.js} +2 -2
  287. package/dashboard/dist/assets/{TimeAgo-BZdLdrIh.js.map → TimeAgo-B5LXB2aj.js.map} +1 -1
  288. package/dashboard/dist/assets/{TimestampCell-QX_0i5FK.js → TimestampCell-Crb9b0Gw.js} +2 -2
  289. package/dashboard/dist/assets/{TimestampCell-QX_0i5FK.js.map → TimestampCell-Crb9b0Gw.js.map} +1 -1
  290. package/dashboard/dist/assets/{UserName-DyZMXcBm.js → UserName-OPg-nkRa.js} +2 -2
  291. package/dashboard/dist/assets/{UserName-DyZMXcBm.js.map → UserName-OPg-nkRa.js.map} +1 -1
  292. package/dashboard/dist/assets/{WorkflowExecutionPage-DjVxfZaF.js → WorkflowExecutionPage-CcLVrs9b.js} +2 -2
  293. package/dashboard/dist/assets/{WorkflowExecutionPage-DjVxfZaF.js.map → WorkflowExecutionPage-CcLVrs9b.js.map} +1 -1
  294. package/dashboard/dist/assets/WorkflowPill-CCV4MMj7.js +2 -0
  295. package/dashboard/dist/assets/WorkflowPill-CCV4MMj7.js.map +1 -0
  296. package/dashboard/dist/assets/{WorkflowsDashboard-DZjuiFZ0.js → WorkflowsDashboard-DB1SncBi.js} +2 -2
  297. package/dashboard/dist/assets/{WorkflowsDashboard-DZjuiFZ0.js.map → WorkflowsDashboard-DB1SncBi.js.map} +1 -1
  298. package/dashboard/dist/assets/{WorkflowsOverview-CLnLRpOu.js → WorkflowsOverview-DvShiYJV.js} +2 -2
  299. package/dashboard/dist/assets/{WorkflowsOverview-CLnLRpOu.js.map → WorkflowsOverview-DvShiYJV.js.map} +1 -1
  300. package/dashboard/dist/assets/YamlWorkflowsPage-DCBoMeGI.js +2 -0
  301. package/dashboard/dist/assets/YamlWorkflowsPage-DCBoMeGI.js.map +1 -0
  302. package/dashboard/dist/assets/{bots-DIM6lBoY.js → bots-Dqos20NE.js} +2 -2
  303. package/dashboard/dist/assets/{bots-DIM6lBoY.js.map → bots-Dqos20NE.js.map} +1 -1
  304. package/dashboard/dist/assets/{escalation-JOTuOqjq.js → escalation-A0CsbvNV.js} +2 -2
  305. package/dashboard/dist/assets/{escalation-JOTuOqjq.js.map → escalation-A0CsbvNV.js.map} +1 -1
  306. package/dashboard/dist/assets/escalation-columns-BpBJN6k4.js +2 -0
  307. package/dashboard/dist/assets/{escalation-columns-Cyg58nkg.js.map → escalation-columns-BpBJN6k4.js.map} +1 -1
  308. package/dashboard/dist/assets/{helpers-B1BDxBZd.js → helpers-CmznCuAx.js} +2 -2
  309. package/dashboard/dist/assets/{helpers-B1BDxBZd.js.map → helpers-CmznCuAx.js.map} +1 -1
  310. package/dashboard/dist/assets/index-BIeYV5QK.js +2 -0
  311. package/dashboard/dist/assets/index-BIeYV5QK.js.map +1 -0
  312. package/dashboard/dist/assets/index-BYwD3kHN.js +5 -0
  313. package/dashboard/dist/assets/index-BYwD3kHN.js.map +1 -0
  314. package/dashboard/dist/assets/index-C5TUqJu0.css +1 -0
  315. package/dashboard/dist/assets/index-C8-UaN4N.js +2 -0
  316. package/dashboard/dist/assets/{index-Cg5nfiYX.js.map → index-C8-UaN4N.js.map} +1 -1
  317. package/dashboard/dist/assets/index-CAj5LT9H.js +15 -0
  318. package/dashboard/dist/assets/index-CAj5LT9H.js.map +1 -0
  319. package/dashboard/dist/assets/index-CjxHCVxl.js +2 -0
  320. package/dashboard/dist/assets/{index-Cf60K3x9.js.map → index-CjxHCVxl.js.map} +1 -1
  321. package/dashboard/dist/assets/index-Cr0Rqsj7.js +2 -0
  322. package/dashboard/dist/assets/index-Cr0Rqsj7.js.map +1 -0
  323. package/dashboard/dist/assets/index-DZHNte4o.js +2 -0
  324. package/dashboard/dist/assets/{index-Di12t56M.js.map → index-DZHNte4o.js.map} +1 -1
  325. package/dashboard/dist/assets/{index-Ds0JoXS2.js → index-VnYkWW8r.js} +2 -2
  326. package/dashboard/dist/assets/{index-Ds0JoXS2.js.map → index-VnYkWW8r.js.map} +1 -1
  327. package/dashboard/dist/assets/{index-BcR6PfpY.js → index-XGOmZ117.js} +2 -2
  328. package/dashboard/dist/assets/{index-BcR6PfpY.js.map → index-XGOmZ117.js.map} +1 -1
  329. package/dashboard/dist/assets/index-ZjOUzWhc.js +2 -0
  330. package/dashboard/dist/assets/index-ZjOUzWhc.js.map +1 -0
  331. package/dashboard/dist/assets/{index-BYZX9tOb.js → index-puKKZ5l8.js} +77 -77
  332. package/dashboard/dist/assets/index-puKKZ5l8.js.map +1 -0
  333. package/dashboard/dist/assets/{index-BizfauqT.js → index-t5frSddy.js} +4 -4
  334. package/dashboard/dist/assets/{index-BizfauqT.js.map → index-t5frSddy.js.map} +1 -1
  335. package/dashboard/dist/assets/{mcp-B_xbczAt.js → mcp-DrWymhSu.js} +2 -2
  336. package/dashboard/dist/assets/{mcp-B_xbczAt.js.map → mcp-DrWymhSu.js.map} +1 -1
  337. package/dashboard/dist/assets/mcp-query-BhUxVEMS.js +2 -0
  338. package/dashboard/dist/assets/mcp-query-BhUxVEMS.js.map +1 -0
  339. package/dashboard/dist/assets/mcp-runs-DUfz4mLd.js +2 -0
  340. package/dashboard/dist/assets/mcp-runs-DUfz4mLd.js.map +1 -0
  341. package/dashboard/dist/assets/{namespaces-C3WtdO_9.js → namespaces-Cm6AY5sh.js} +2 -2
  342. package/dashboard/dist/assets/{namespaces-C3WtdO_9.js.map → namespaces-Cm6AY5sh.js.map} +1 -1
  343. package/dashboard/dist/assets/{roles-BDAsPpZG.js → roles-2v1Kc7BJ.js} +2 -2
  344. package/dashboard/dist/assets/{roles-BDAsPpZG.js.map → roles-2v1Kc7BJ.js.map} +1 -1
  345. package/dashboard/dist/assets/{settings-Ife_UwAp.js → settings-DTQNp6tH.js} +2 -2
  346. package/dashboard/dist/assets/{settings-Ife_UwAp.js.map → settings-DTQNp6tH.js.map} +1 -1
  347. package/dashboard/dist/assets/{tasks-BquNDHDI.js → tasks-CS1rgG1s.js} +2 -2
  348. package/dashboard/dist/assets/{tasks-BquNDHDI.js.map → tasks-CS1rgG1s.js.map} +1 -1
  349. package/dashboard/dist/assets/useEventHooks-BjXX8x3a.js +2 -0
  350. package/dashboard/dist/assets/{useEventHooks-anv_B2Yy.js.map → useEventHooks-BjXX8x3a.js.map} +1 -1
  351. package/dashboard/dist/assets/useFilterParams-CGRYFw_A.js +2 -0
  352. package/dashboard/dist/assets/useFilterParams-CGRYFw_A.js.map +1 -0
  353. package/dashboard/dist/assets/useYamlActivityEvents-BeR-nVWQ.js +2 -0
  354. package/dashboard/dist/assets/useYamlActivityEvents-BeR-nVWQ.js.map +1 -0
  355. package/dashboard/dist/assets/{users-CFcxB4v6.js → users-DYsdQ7Md.js} +2 -2
  356. package/dashboard/dist/assets/{users-CFcxB4v6.js.map → users-DYsdQ7Md.js.map} +1 -1
  357. package/dashboard/dist/assets/{vendor-icons-T4r2DSPD.js → vendor-icons-CWl44VA6.js} +132 -82
  358. package/dashboard/dist/assets/vendor-icons-CWl44VA6.js.map +1 -0
  359. package/dashboard/dist/assets/{workflows-CeRci9z3.js → workflows-2QAXh3UD.js} +2 -2
  360. package/dashboard/dist/assets/{workflows-CeRci9z3.js.map → workflows-2QAXh3UD.js.map} +1 -1
  361. package/dashboard/dist/assets/yaml-workflows-sx8-UEE3.js +2 -0
  362. package/dashboard/dist/assets/yaml-workflows-sx8-UEE3.js.map +1 -0
  363. package/dashboard/dist/index.html +3 -3
  364. package/docs/api/http/file-browser.md +101 -0
  365. package/docs/api/http/knowledge.md +203 -0
  366. package/docs/api/http/settings.md +6 -4
  367. package/docs/api/sdk/files.md +68 -0
  368. package/docs/api/sdk/knowledge.md +126 -0
  369. package/docs/api/sdk/settings.md +3 -2
  370. package/docs/cli.md +171 -0
  371. package/docs/compilation.md +16 -0
  372. package/docs/compiler.md +311 -0
  373. package/docs/events.md +19 -0
  374. package/docs/schema-exchange.md +173 -0
  375. package/docs/self-test.md +106 -0
  376. package/docs/workflows.md +19 -0
  377. package/package.json +15 -2
  378. package/build/api/escalations.d.ts +0 -271
  379. package/build/api/escalations.js +0 -932
  380. package/build/api/workflows.d.ts +0 -158
  381. package/build/api/workflows.js +0 -414
  382. package/dashboard/dist/assets/AvailableEscalationsPage-Dbd1qUK_.js +0 -2
  383. package/dashboard/dist/assets/AvailableEscalationsPage-Dbd1qUK_.js.map +0 -1
  384. package/dashboard/dist/assets/CredentialsPage-DJablIbs.js +0 -2
  385. package/dashboard/dist/assets/McpQueryDetailPage-BWbinTM_.js +0 -5
  386. package/dashboard/dist/assets/McpQueryDetailPage-BWbinTM_.js.map +0 -1
  387. package/dashboard/dist/assets/McpQueryPage-lV6kfDG5.js +0 -2
  388. package/dashboard/dist/assets/McpRunDetailPage-D6gaxH3_.js +0 -2
  389. package/dashboard/dist/assets/McpRunDetailPage-D6gaxH3_.js.map +0 -1
  390. package/dashboard/dist/assets/McpRunsPage-DKvTklh9.js +0 -2
  391. package/dashboard/dist/assets/McpRunsPage-DKvTklh9.js.map +0 -1
  392. package/dashboard/dist/assets/OperatorDashboard-C9SSV96T.js +0 -2
  393. package/dashboard/dist/assets/SwimlaneTimeline-RK4Yu66z.js +0 -2
  394. package/dashboard/dist/assets/SwimlaneTimeline-RK4Yu66z.js.map +0 -1
  395. package/dashboard/dist/assets/WorkflowPill-CZqGslD6.js +0 -2
  396. package/dashboard/dist/assets/WorkflowPill-CZqGslD6.js.map +0 -1
  397. package/dashboard/dist/assets/YamlWorkflowsPage-VjdhnLmO.js +0 -2
  398. package/dashboard/dist/assets/YamlWorkflowsPage-VjdhnLmO.js.map +0 -1
  399. package/dashboard/dist/assets/escalation-columns-Cyg58nkg.js +0 -2
  400. package/dashboard/dist/assets/helpers-BCix9c_m.js +0 -2
  401. package/dashboard/dist/assets/helpers-BCix9c_m.js.map +0 -1
  402. package/dashboard/dist/assets/index-BUK3qR-1.js +0 -2
  403. package/dashboard/dist/assets/index-BUK3qR-1.js.map +0 -1
  404. package/dashboard/dist/assets/index-BYZX9tOb.js.map +0 -1
  405. package/dashboard/dist/assets/index-Cf60K3x9.js +0 -2
  406. package/dashboard/dist/assets/index-Cg5nfiYX.js +0 -2
  407. package/dashboard/dist/assets/index-D1wVX50Z.js +0 -15
  408. package/dashboard/dist/assets/index-D1wVX50Z.js.map +0 -1
  409. package/dashboard/dist/assets/index-DDYFpi4l.js +0 -5
  410. package/dashboard/dist/assets/index-DDYFpi4l.js.map +0 -1
  411. package/dashboard/dist/assets/index-DcIKW-cZ.css +0 -1
  412. package/dashboard/dist/assets/index-Di12t56M.js +0 -2
  413. package/dashboard/dist/assets/mcp-query-B8-P_QoG.js +0 -2
  414. package/dashboard/dist/assets/mcp-query-B8-P_QoG.js.map +0 -1
  415. package/dashboard/dist/assets/mcp-runs-CWeZinoF.js +0 -2
  416. package/dashboard/dist/assets/mcp-runs-CWeZinoF.js.map +0 -1
  417. package/dashboard/dist/assets/useEventHooks-anv_B2Yy.js +0 -2
  418. package/dashboard/dist/assets/useFilterParams-BUyLHcx_.js +0 -2
  419. package/dashboard/dist/assets/useFilterParams-BUyLHcx_.js.map +0 -1
  420. package/dashboard/dist/assets/useYamlActivityEvents-DN-PTgVx.js +0 -2
  421. package/dashboard/dist/assets/useYamlActivityEvents-DN-PTgVx.js.map +0 -1
  422. package/dashboard/dist/assets/vendor-icons-T4r2DSPD.js.map +0 -1
  423. package/dashboard/dist/assets/yaml-workflows-DLwd2BOX.js +0 -2
  424. package/dashboard/dist/assets/yaml-workflows-DLwd2BOX.js.map +0 -1
@@ -1,932 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.createEscalation = createEscalation;
37
- exports.listEscalations = listEscalations;
38
- exports.listAvailableEscalations = listAvailableEscalations;
39
- exports.listDistinctTypes = listDistinctTypes;
40
- exports.getEscalationStats = getEscalationStats;
41
- exports.getEscalation = getEscalation;
42
- exports.getEscalationsByWorkflowId = getEscalationsByWorkflowId;
43
- exports.escalateToRole = escalateToRole;
44
- exports.claimEscalation = claimEscalation;
45
- exports.releaseEscalation = releaseEscalation;
46
- exports.releaseExpiredClaims = releaseExpiredClaims;
47
- exports.updatePriority = updatePriority;
48
- exports.bulkClaim = bulkClaim;
49
- exports.bulkAssign = bulkAssign;
50
- exports.bulkEscalate = bulkEscalate;
51
- exports.bulkTriage = bulkTriage;
52
- exports.resolveEscalation = resolveEscalation;
53
- const escalationService = __importStar(require("../services/escalation"));
54
- const userService = __importStar(require("../services/user"));
55
- const roleService = __importStar(require("../services/role"));
56
- const taskService = __importStar(require("../services/task"));
57
- const publish_1 = require("../lib/events/publish");
58
- const escalation_strategy_1 = require("../services/escalation-strategy");
59
- const ephemeral_1 = require("../services/iam/ephemeral");
60
- const deployer_1 = require("../services/yaml-workflow/deployer");
61
- const workers_1 = require("../workers");
62
- const defaults_1 = require("../modules/defaults");
63
- // ── Private helpers ────────────────────────────────────────────────────────
64
- async function getVisibleRoles(userId) {
65
- const isSuperAdminUser = await userService.isSuperAdmin(userId);
66
- if (isSuperAdminUser)
67
- return undefined;
68
- const userRoles = await userService.getUserRoles(userId);
69
- return userRoles.map((r) => r.role);
70
- }
71
- function validateIds(ids) {
72
- return Array.isArray(ids) && ids.length > 0;
73
- }
74
- async function checkBulkPermission(userId, ids) {
75
- const isSuperAdminUser = await userService.isSuperAdmin(userId);
76
- if (isSuperAdminUser)
77
- return { allowed: true };
78
- const roles = await escalationService.getEscalationRoles(ids);
79
- for (const role of roles) {
80
- const canManage = await userService.isGroupAdmin(userId, role);
81
- if (!canManage) {
82
- return { allowed: false, status: 403, error: `Insufficient permissions for role "${role}"` };
83
- }
84
- }
85
- return { allowed: true };
86
- }
87
- function publishBulkClaimEvents(ids, assignedTo) {
88
- for (const id of ids) {
89
- (0, publish_1.publishEscalationEvent)({
90
- type: 'escalation.claimed',
91
- source: 'api',
92
- workflowId: '',
93
- workflowName: '',
94
- taskQueue: '',
95
- escalationId: id,
96
- status: 'claimed',
97
- data: { assigned_to: assignedTo, bulk: true },
98
- });
99
- }
100
- }
101
- // ── Create ────────────────────────────────────────────────────────────────
102
- /**
103
- * Create a standalone escalation (not tied to a workflow).
104
- *
105
- * Useful for manual work items, support tickets, or approval requests
106
- * that originate outside the durable workflow engine. The caller must
107
- * hold the target role or be a superadmin.
108
- *
109
- * @param input.type — escalation category (e.g. `"support"`, `"approval"`)
110
- * @param input.subtype — subcategory for finer routing
111
- * @param input.role — role responsible for resolving this escalation
112
- * @param input.description — human-readable summary
113
- * @param input.priority — 1 (critical) through 4 (low), default 2
114
- * @param input.envelope — serialized context for the resolver
115
- * @param input.metadata — arbitrary key-value data (e.g. signal_routing)
116
- * @param input.escalation_payload — serialized payload for the resolver UI
117
- * @param auth — authenticated user context (must hold target role or be superadmin)
118
- * @returns `{ status: 201, data: <escalation record> }`
119
- */
120
- async function createEscalation(input, auth) {
121
- try {
122
- const { type, role } = input;
123
- if (!type || typeof type !== 'string') {
124
- return { status: 400, error: 'type is required' };
125
- }
126
- if (!role || typeof role !== 'string') {
127
- return { status: 400, error: 'role is required' };
128
- }
129
- // RBAC: caller must hold the target role or be superadmin
130
- const isSuperAdminUser = await userService.isSuperAdmin(auth.userId);
131
- if (!isSuperAdminUser) {
132
- const userHasRole = await userService.hasRole(auth.userId, role);
133
- if (!userHasRole) {
134
- return { status: 403, error: `You must hold the "${role}" role or be a superadmin to create escalations for it` };
135
- }
136
- }
137
- const escalation = await escalationService.createEscalation({
138
- type,
139
- subtype: input.subtype ?? type,
140
- description: input.description,
141
- priority: input.priority,
142
- role,
143
- envelope: input.envelope ?? '{}',
144
- metadata: input.metadata,
145
- escalation_payload: input.escalation_payload,
146
- });
147
- (0, publish_1.publishEscalationEvent)({
148
- type: 'escalation.created',
149
- source: 'api',
150
- workflowId: '',
151
- workflowName: '',
152
- taskQueue: '',
153
- escalationId: escalation.id,
154
- status: 'pending',
155
- data: { type: input.type, role },
156
- });
157
- return { status: 201, data: escalation };
158
- }
159
- catch (err) {
160
- return { status: 500, error: err.message };
161
- }
162
- }
163
- // ── List routes ────────────────────────────────────────────────────────────
164
- /**
165
- * List escalations with optional filters.
166
- *
167
- * Results are scoped to the authenticated user's roles unless the user
168
- * is a superadmin (who sees all roles).
169
- *
170
- * @param input.status — filter by `pending`, `resolved`, or `cancelled`
171
- * @param input.role — filter by assigned role
172
- * @param input.type — filter by workflow type
173
- * @param input.subtype — filter by subtype
174
- * @param input.assigned_to — filter by assigned user ID
175
- * @param input.priority — filter by priority (1–4)
176
- * @param input.limit — max results (default: 50)
177
- * @param input.offset — pagination offset
178
- * @param input.sort_by — column to sort by (e.g. `created_at`, `priority`)
179
- * @param input.order — `asc` or `desc`
180
- * @param auth — authenticated user context (required for role scoping)
181
- * @returns `{ status: 200, data: { escalations, total } }`
182
- */
183
- async function listEscalations(input, auth) {
184
- try {
185
- const visibleRoles = await getVisibleRoles(auth.userId);
186
- if (visibleRoles && visibleRoles.length === 0) {
187
- return { status: 200, data: { escalations: [], total: 0 } };
188
- }
189
- const result = await escalationService.listEscalations({
190
- status: input.status,
191
- role: input.role,
192
- type: input.type,
193
- subtype: input.subtype,
194
- assigned_to: input.assigned_to,
195
- priority: input.priority,
196
- limit: input.limit,
197
- offset: input.offset,
198
- sort_by: input.sort_by,
199
- order: input.order,
200
- visibleRoles,
201
- });
202
- return { status: 200, data: result };
203
- }
204
- catch (err) {
205
- return { status: 500, error: err.message };
206
- }
207
- }
208
- /**
209
- * List escalations available for claim (pending and not actively claimed).
210
- *
211
- * Similar to `listEscalations` but excludes escalations with active claims.
212
- * Scoped to the authenticated user's roles.
213
- *
214
- * @param input.role — filter by role
215
- * @param input.type — filter by workflow type
216
- * @param input.subtype — filter by subtype
217
- * @param input.priority — filter by priority (1–4)
218
- * @param input.limit — max results (default: 50)
219
- * @param input.offset — pagination offset
220
- * @param input.sort_by — column to sort by
221
- * @param input.order — `asc` or `desc`
222
- * @param auth — authenticated user context
223
- * @returns `{ status: 200, data: { escalations, total } }`
224
- */
225
- async function listAvailableEscalations(input, auth) {
226
- try {
227
- const visibleRoles = await getVisibleRoles(auth.userId);
228
- if (visibleRoles && visibleRoles.length === 0) {
229
- return { status: 200, data: { escalations: [], total: 0 } };
230
- }
231
- const result = await escalationService.listAvailableEscalations({
232
- role: input.role,
233
- type: input.type,
234
- subtype: input.subtype,
235
- priority: input.priority,
236
- limit: input.limit,
237
- offset: input.offset,
238
- sort_by: input.sort_by,
239
- order: input.order,
240
- visibleRoles,
241
- });
242
- return { status: 200, data: result };
243
- }
244
- catch (err) {
245
- return { status: 500, error: err.message };
246
- }
247
- }
248
- /**
249
- * List all distinct escalation type values.
250
- *
251
- * @returns `{ status: 200, data: { types: string[] } }`
252
- */
253
- async function listDistinctTypes() {
254
- try {
255
- const types = await escalationService.listDistinctTypes();
256
- return { status: 200, data: { types } };
257
- }
258
- catch (err) {
259
- return { status: 500, error: err.message };
260
- }
261
- }
262
- /**
263
- * Get aggregate escalation statistics scoped to the user's roles.
264
- *
265
- * @param input.period — time window (`1h`, `24h`, `7d`, `30d`)
266
- * @param auth — authenticated user context
267
- * @returns `{ status: 200, data: { pending, claimed, created, resolved, by_role, by_type } }`
268
- */
269
- async function getEscalationStats(input, auth) {
270
- try {
271
- const visibleRoles = await getVisibleRoles(auth.userId);
272
- if (visibleRoles && visibleRoles.length === 0) {
273
- return {
274
- status: 200,
275
- data: {
276
- pending: 0,
277
- claimed: 0,
278
- created: 0,
279
- resolved: 0,
280
- by_role: [],
281
- by_type: [],
282
- },
283
- };
284
- }
285
- const stats = await escalationService.getEscalationStats(visibleRoles, input.period);
286
- return { status: 200, data: stats };
287
- }
288
- catch (err) {
289
- return { status: 500, error: err.message };
290
- }
291
- }
292
- // ── Single-escalation routes ───────────────────────────────────────────────
293
- /**
294
- * Get a single escalation by ID.
295
- *
296
- * Non-superadmin users must hold the escalation's assigned role.
297
- *
298
- * @param input.id — escalation UUID
299
- * @param auth — authenticated user context
300
- * @returns `{ status: 200, data: <escalation record> }` or 403/404
301
- */
302
- async function getEscalation(input, auth) {
303
- try {
304
- const escalation = await escalationService.getEscalation(input.id);
305
- if (!escalation) {
306
- return { status: 404, error: 'Escalation not found' };
307
- }
308
- const isSuperAdminUser = await userService.isSuperAdmin(auth.userId);
309
- if (!isSuperAdminUser) {
310
- const userHasRole = await userService.hasRole(auth.userId, escalation.role);
311
- if (!userHasRole) {
312
- return { status: 403, error: 'Not authorized to view this escalation' };
313
- }
314
- }
315
- return { status: 200, data: escalation };
316
- }
317
- catch (err) {
318
- return { status: 500, error: err.message };
319
- }
320
- }
321
- /**
322
- * List all escalations for a given workflow ID.
323
- *
324
- * @param input.workflowId — HotMesh workflow ID
325
- * @returns `{ status: 200, data: { escalations } }`
326
- */
327
- async function getEscalationsByWorkflowId(input) {
328
- try {
329
- const escalations = await escalationService.getEscalationsByWorkflowId(input.workflowId);
330
- return { status: 200, data: { escalations } };
331
- }
332
- catch (err) {
333
- return { status: 500, error: err.message };
334
- }
335
- }
336
- /**
337
- * Route a pending escalation to a different role.
338
- *
339
- * The user must be authorized to escalate from the current role to the
340
- * target role (checked via escalation chain configuration).
341
- *
342
- * @param input.id — escalation UUID
343
- * @param input.targetRole — destination role
344
- * @param auth — authenticated user context
345
- * @returns `{ status: 200, data: <updated escalation> }` or 403/404/409
346
- */
347
- async function escalateToRole(input, auth) {
348
- try {
349
- const { id, targetRole } = input;
350
- if (!targetRole || typeof targetRole !== 'string') {
351
- return { status: 400, error: 'targetRole is required' };
352
- }
353
- const escalation = await escalationService.getEscalation(id);
354
- if (!escalation) {
355
- return { status: 404, error: 'Escalation not found' };
356
- }
357
- if (escalation.status !== 'pending') {
358
- return { status: 409, error: 'Escalation is not pending' };
359
- }
360
- const canEscalate = await roleService.canEscalateTo(auth.userId, escalation.role, targetRole);
361
- if (!canEscalate) {
362
- return { status: 403, error: 'Not authorized to escalate to this role' };
363
- }
364
- const updated = await escalationService.escalateToRole(id, targetRole);
365
- if (!updated) {
366
- return { status: 409, error: 'Escalation could not be updated' };
367
- }
368
- return { status: 200, data: updated };
369
- }
370
- catch (err) {
371
- return { status: 500, error: err.message };
372
- }
373
- }
374
- /**
375
- * Claim a pending escalation for the authenticated user.
376
- *
377
- * Sets `assigned_to` and `assigned_until` on the escalation (soft lock).
378
- * Non-superadmin users must hold the escalation's role. Publishes a
379
- * `escalation.claimed` event.
380
- *
381
- * @param input.id — escalation UUID
382
- * @param input.durationMinutes — claim duration (default: 30)
383
- * @param auth — authenticated user context
384
- * @returns `{ status: 200, data: { escalation, isExtension } }` or 403/404/409
385
- */
386
- async function claimEscalation(input, auth) {
387
- try {
388
- const { id, durationMinutes } = input;
389
- const escalation = await escalationService.getEscalation(id);
390
- if (!escalation) {
391
- return { status: 404, error: 'Escalation not found' };
392
- }
393
- const isSuperAdminUser = await userService.isSuperAdmin(auth.userId);
394
- if (!isSuperAdminUser) {
395
- const userHasRole = await userService.hasRole(auth.userId, escalation.role);
396
- if (!userHasRole) {
397
- return {
398
- status: 403,
399
- error: `You must have the "${escalation.role}" role to claim this escalation`,
400
- };
401
- }
402
- }
403
- const result = await escalationService.claimEscalation(id, auth.userId, durationMinutes);
404
- if (!result) {
405
- return { status: 409, error: 'Escalation not available for claim' };
406
- }
407
- (0, publish_1.publishEscalationEvent)({
408
- type: 'escalation.claimed',
409
- source: 'api',
410
- workflowId: escalation.workflow_id || '',
411
- workflowName: escalation.workflow_type || '',
412
- taskQueue: escalation.task_queue || '',
413
- escalationId: id,
414
- status: 'claimed',
415
- data: { assigned_to: auth.userId },
416
- });
417
- return { status: 200, data: result };
418
- }
419
- catch (err) {
420
- return { status: 500, error: err.message };
421
- }
422
- }
423
- /**
424
- * Release a claimed escalation back to the pool.
425
- *
426
- * Only the user who holds the claim can release it. Publishes a
427
- * `escalation.released` event.
428
- *
429
- * @param input.id — escalation UUID
430
- * @param auth — authenticated user context
431
- * @returns `{ status: 200, data: { escalation } }` or 409
432
- */
433
- async function releaseEscalation(input, auth) {
434
- try {
435
- const result = await escalationService.releaseEscalation(input.id, auth.userId);
436
- if (!result) {
437
- return { status: 409, error: 'Escalation not found or not claimed by you' };
438
- }
439
- (0, publish_1.publishEscalationEvent)({
440
- type: 'escalation.released',
441
- source: 'api',
442
- workflowId: result.workflow_id || '',
443
- workflowName: result.workflow_type || '',
444
- taskQueue: result.task_queue || '',
445
- escalationId: input.id,
446
- status: 'released',
447
- data: { released_by: auth.userId },
448
- });
449
- return { status: 200, data: { escalation: result } };
450
- }
451
- catch (err) {
452
- return { status: 500, error: err.message };
453
- }
454
- }
455
- // ── Bulk routes ────────────────────────────────────────────────────────────
456
- /**
457
- * Release all escalation claims past their `assigned_until` deadline.
458
- *
459
- * Typically called on a maintenance schedule. Returns the count of
460
- * released claims.
461
- *
462
- * @returns `{ status: 200, data: { released: number } }`
463
- */
464
- async function releaseExpiredClaims() {
465
- try {
466
- const released = await escalationService.releaseExpiredClaims();
467
- return { status: 200, data: { released } };
468
- }
469
- catch (err) {
470
- return { status: 500, error: err.message };
471
- }
472
- }
473
- /**
474
- * Update priority for one or more escalations.
475
- *
476
- * @param input.ids — array of escalation UUIDs
477
- * @param input.priority — new priority (1=critical, 2=high, 3=medium, 4=low)
478
- * @param auth — authenticated user context (admin or role-holder required)
479
- * @returns `{ status: 200, data: { updated: number } }`
480
- */
481
- async function updatePriority(input, auth) {
482
- try {
483
- const { ids, priority } = input;
484
- if (!validateIds(ids)) {
485
- return { status: 400, error: 'ids must be a non-empty array' };
486
- }
487
- if (![1, 2, 3, 4].includes(priority)) {
488
- return { status: 400, error: 'priority must be 1, 2, 3, or 4' };
489
- }
490
- const perm = await checkBulkPermission(auth.userId, ids);
491
- if (!perm.allowed)
492
- return perm;
493
- const updated = await escalationService.updateEscalationsPriority(ids, priority);
494
- return { status: 200, data: { updated } };
495
- }
496
- catch (err) {
497
- return { status: 500, error: err.message };
498
- }
499
- }
500
- /**
501
- * Claim multiple escalations at once for the authenticated user.
502
- *
503
- * @param input.ids — array of escalation UUIDs
504
- * @param input.durationMinutes — claim duration (default: 30)
505
- * @param auth — authenticated user context
506
- * @returns `{ status: 200, data: { claimed, skipped } }`
507
- */
508
- async function bulkClaim(input, auth) {
509
- try {
510
- const { ids, durationMinutes } = input;
511
- if (!validateIds(ids)) {
512
- return { status: 400, error: 'ids must be a non-empty array' };
513
- }
514
- const perm = await checkBulkPermission(auth.userId, ids);
515
- if (!perm.allowed)
516
- return perm;
517
- const result = await escalationService.bulkClaimEscalations(ids, auth.userId, durationMinutes ?? 30);
518
- if (result.claimed > 0)
519
- publishBulkClaimEvents(ids, auth.userId);
520
- return { status: 200, data: result };
521
- }
522
- catch (err) {
523
- return { status: 500, error: err.message };
524
- }
525
- }
526
- /**
527
- * Assign multiple escalations to a specific user.
528
- *
529
- * Non-superadmin callers must verify the target user holds each
530
- * escalation's role. Publishes claim events for assigned items.
531
- *
532
- * @param input.ids — array of escalation UUIDs
533
- * @param input.targetUserId — user to assign to
534
- * @param input.durationMinutes — assignment duration (default: 30)
535
- * @param auth — authenticated user context
536
- * @returns `{ status: 200, data: { assigned, skipped } }`
537
- */
538
- async function bulkAssign(input, auth) {
539
- try {
540
- const { ids, targetUserId, durationMinutes } = input;
541
- if (!validateIds(ids)) {
542
- return { status: 400, error: 'ids must be a non-empty array' };
543
- }
544
- if (!targetUserId || typeof targetUserId !== 'string') {
545
- return { status: 400, error: 'targetUserId is required' };
546
- }
547
- const perm = await checkBulkPermission(auth.userId, ids);
548
- if (!perm.allowed)
549
- return perm;
550
- // Non-superadmin: target user must hold each escalation's role
551
- const isSuperAdminUser = await userService.isSuperAdmin(auth.userId);
552
- if (!isSuperAdminUser) {
553
- const roles = await escalationService.getEscalationRoles(ids);
554
- for (const role of roles) {
555
- const targetHasRole = await userService.hasRole(targetUserId, role);
556
- if (!targetHasRole) {
557
- return { status: 400, error: `Target user does not hold the "${role}" role` };
558
- }
559
- }
560
- }
561
- const result = await escalationService.bulkAssignEscalations(ids, targetUserId, durationMinutes ?? 30);
562
- if (result.assigned > 0)
563
- publishBulkClaimEvents(ids, targetUserId);
564
- return { status: 200, data: result };
565
- }
566
- catch (err) {
567
- return { status: 500, error: err.message };
568
- }
569
- }
570
- /**
571
- * Route multiple escalations to a different role.
572
- *
573
- * @param input.ids — array of escalation UUIDs
574
- * @param input.targetRole — destination role
575
- * @param auth — authenticated user context
576
- * @returns `{ status: 200, data: { updated: number } }`
577
- */
578
- async function bulkEscalate(input, auth) {
579
- try {
580
- const { ids, targetRole } = input;
581
- if (!validateIds(ids)) {
582
- return { status: 400, error: 'ids must be a non-empty array' };
583
- }
584
- if (!targetRole || typeof targetRole !== 'string') {
585
- return { status: 400, error: 'targetRole is required' };
586
- }
587
- const perm = await checkBulkPermission(auth.userId, ids);
588
- if (!perm.allowed)
589
- return perm;
590
- const updated = await escalationService.bulkEscalateToRole(ids, targetRole);
591
- return { status: 200, data: { updated } };
592
- }
593
- catch (err) {
594
- return { status: 500, error: err.message };
595
- }
596
- }
597
- /**
598
- * Trigger AI triage for multiple escalations.
599
- *
600
- * Resolves each escalation and starts a triage workflow that uses MCP
601
- * tools to analyze and potentially auto-resolve the issue.
602
- *
603
- * @param input.ids — array of escalation UUIDs
604
- * @param input.hint — optional natural-language guidance for the triage AI
605
- * @param auth — authenticated user context
606
- * @returns `{ status: 200, data: { triaged, workflows } }`
607
- */
608
- async function bulkTriage(input, auth) {
609
- try {
610
- const { ids, hint } = input;
611
- if (!validateIds(ids)) {
612
- return { status: 400, error: 'ids must be a non-empty array' };
613
- }
614
- const perm = await checkBulkPermission(auth.userId, ids);
615
- if (!perm.allowed)
616
- return perm;
617
- const resolved = await escalationService.bulkResolveForTriage(ids, hint);
618
- const client = (0, workers_1.createClient)();
619
- const workflowIds = [];
620
- for (const escalation of resolved) {
621
- const triageWorkflowId = await startTriageWorkflow(escalation, hint, auth.userId, client);
622
- workflowIds.push(triageWorkflowId);
623
- }
624
- return { status: 200, data: { triaged: resolved.length, workflows: workflowIds } };
625
- }
626
- catch (err) {
627
- return { status: 500, error: err.message };
628
- }
629
- }
630
- // ── Resolve route ──────────────────────────────────────────────────────────
631
- /**
632
- * Resolve a pending escalation with a human-provided payload.
633
- *
634
- * Handles two resolution paths:
635
- * 1. **Signal-routed** — if the escalation has `signal_routing` metadata,
636
- * the resolver payload is sent directly to the paused workflow via
637
- * `handle.signal()`. Supports both Durable and YAML engines.
638
- * 2. **Re-run** — the original workflow is re-started with the resolver
639
- * payload injected into `envelope.resolver`. The interceptor detects
640
- * the re-run and skips to the resolution branch.
641
- *
642
- * Password fields in the resolver payload are replaced with ephemeral
643
- * tokens (15-minute TTL) so plaintext never enters the signal store.
644
- *
645
- * Supports optional escalation strategy execution after resolution.
646
- *
647
- * @param input.id — escalation UUID
648
- * @param input.resolverPayload — human decision data
649
- * @param auth — authenticated user context
650
- * @returns `{ status: 200, data: { signaled, escalationId, workflowId } }` (signal path)
651
- * or `{ status: 200, data: { workflowId, resumed, escalationId } }` (re-run path)
652
- */
653
- async function resolveEscalation(input, auth) {
654
- try {
655
- const { id, resolverPayload } = input;
656
- if (!resolverPayload) {
657
- return { status: 400, error: 'resolverPayload is required' };
658
- }
659
- // 1. Read escalation (verify pending)
660
- const escalation = await escalationService.getEscalation(id);
661
- if (!escalation) {
662
- return { status: 404, error: 'Escalation not found' };
663
- }
664
- if (escalation.status !== 'pending') {
665
- return { status: 409, error: 'Escalation not available for resolution' };
666
- }
667
- // 2. Lightweight signal path: metadata.signal_id + escalation fields
668
- // The workflow called `await conditionLT(signalId)` and created its
669
- // own escalation with the signal_id in metadata. On resolution, we
670
- // inject $escalation_id into the payload and signal the running
671
- // workflow. The workflow is responsible for resolving the escalation
672
- // (conditionLT handles this automatically via a durable activity).
673
- const metadataSignalId = escalation.metadata?.signal_id;
674
- if (metadataSignalId && escalation.workflow_id && escalation.task_queue && escalation.workflow_type) {
675
- const client = (0, workers_1.createClient)();
676
- const handle = await client.workflow.getHandle(escalation.task_queue, escalation.workflow_type, escalation.workflow_id);
677
- await handle.signal(metadataSignalId, {
678
- ...resolverPayload,
679
- $escalation_id: escalation.id,
680
- });
681
- (0, publish_1.publishEscalationEvent)({
682
- type: 'escalation.resolved',
683
- source: 'api',
684
- workflowId: escalation.workflow_id,
685
- workflowName: escalation.workflow_type,
686
- taskQueue: escalation.task_queue,
687
- taskId: escalation.task_id,
688
- escalationId: escalation.id,
689
- originId: escalation.origin_id ?? undefined,
690
- status: 'resolved',
691
- });
692
- return {
693
- status: 200,
694
- data: {
695
- signaled: true,
696
- escalationId: escalation.id,
697
- workflowId: escalation.workflow_id,
698
- },
699
- };
700
- }
701
- // 3. waitFor signal escalation -- signal the paused workflow directly
702
- // (full signal_routing object from interceptor/MCP tool)
703
- const signalRouting = escalation.metadata?.signal_routing;
704
- if (signalRouting?.signalId) {
705
- // Replace password fields with ephemeral tokens so plaintext never enters the signal store
706
- let signalPayload = resolverPayload;
707
- const formSchema = escalation.metadata?.form_schema;
708
- if (formSchema?.properties) {
709
- signalPayload = { ...resolverPayload };
710
- for (const [key, def] of Object.entries(formSchema.properties)) {
711
- if (def?.format === 'password' && typeof signalPayload[key] === 'string') {
712
- const uuid = await (0, ephemeral_1.storeEphemeral)(signalPayload[key], {
713
- ttlSeconds: 900,
714
- label: key,
715
- });
716
- signalPayload[key] = (0, ephemeral_1.formatEphemeralToken)(uuid, key);
717
- }
718
- }
719
- }
720
- if (signalRouting.engine === 'yaml' && signalRouting.hookTopic && signalRouting.appId) {
721
- const engine = await (0, deployer_1.getEngine)(signalRouting.appId);
722
- await engine.signal(signalRouting.hookTopic, {
723
- ...signalPayload,
724
- escalationId: escalation.id,
725
- job_id: signalRouting.jobId,
726
- });
727
- }
728
- else if (signalRouting.workflowId) {
729
- const client = (0, workers_1.createClient)();
730
- const handle = await client.workflow.getHandle(signalRouting.taskQueue, signalRouting.workflowType, signalRouting.workflowId);
731
- await handle.signal(signalRouting.signalId, signalPayload);
732
- }
733
- // For YAML workflows, the resolve worker inside the workflow calls
734
- // claim_and_resolve to close the escalation transactionally. Only resolve
735
- // here for Durable workflows that lack an in-workflow resolve step.
736
- if (signalRouting.engine !== 'yaml') {
737
- await escalationService.resolveEscalation(escalation.id, resolverPayload);
738
- }
739
- (0, publish_1.publishEscalationEvent)({
740
- type: 'escalation.resolved',
741
- source: 'api',
742
- workflowId: escalation.workflow_id || signalRouting.workflowId,
743
- workflowName: escalation.workflow_type || signalRouting.workflowType,
744
- taskQueue: escalation.task_queue || signalRouting.taskQueue || signalRouting.appId,
745
- taskId: escalation.task_id,
746
- escalationId: escalation.id,
747
- originId: escalation.origin_id ?? undefined,
748
- status: signalRouting.engine === 'yaml' ? 'signaled' : 'resolved',
749
- });
750
- return {
751
- status: 200,
752
- data: {
753
- signaled: true,
754
- escalationId: escalation.id,
755
- workflowId: signalRouting.workflowId || signalRouting.appId,
756
- },
757
- };
758
- }
759
- // 4. Reconstruct the original envelope from the escalation or task
760
- let envelope = {};
761
- if (escalation.envelope) {
762
- try {
763
- envelope = JSON.parse(escalation.envelope);
764
- }
765
- catch { /* use empty */ }
766
- }
767
- else if (escalation.task_id) {
768
- const task = await taskService.getTask(escalation.task_id);
769
- if (task?.envelope) {
770
- try {
771
- envelope = JSON.parse(task.envelope);
772
- }
773
- catch { /* use empty */ }
774
- }
775
- }
776
- // 5. Check escalation strategy for triage routing
777
- const strategy = escalation_strategy_1.escalationStrategyRegistry.current;
778
- if (strategy) {
779
- const directive = await strategy.onResolution({
780
- escalation,
781
- resolverPayload,
782
- envelope,
783
- });
784
- if (directive.action === 'triage') {
785
- const originalTask = escalation.task_id
786
- ? await taskService.getTask(escalation.task_id)
787
- : null;
788
- const routing = originalTask?.metadata;
789
- const triageWorkflowId = `triage-${escalation.id}-${Date.now()}`;
790
- const client = (0, workers_1.createClient)();
791
- await taskService.createTask({
792
- workflow_id: triageWorkflowId,
793
- workflow_type: 'mcpTriageRouter',
794
- lt_type: 'mcpTriage',
795
- task_queue: 'long-tail-system',
796
- signal_id: `lt-triage-${triageWorkflowId}`,
797
- parent_workflow_id: triageWorkflowId,
798
- origin_id: escalation.origin_id || triageWorkflowId,
799
- parent_id: escalation.parent_id ?? undefined,
800
- envelope: JSON.stringify(directive.triageEnvelope),
801
- });
802
- await client.workflow.start({
803
- workflowName: 'mcpTriageRouter',
804
- args: [directive.triageEnvelope],
805
- taskQueue: 'long-tail-system',
806
- workflowId: triageWorkflowId,
807
- expire: defaults_1.JOB_EXPIRE_SECS,
808
- entity: 'mcpTriageRouter',
809
- });
810
- await escalationService.resolveEscalation(escalation.id, {
811
- ...resolverPayload,
812
- _lt: { ...resolverPayload._lt, triaged: true, triageWorkflowId },
813
- });
814
- (0, publish_1.publishEscalationEvent)({
815
- type: 'escalation.resolved',
816
- source: 'api',
817
- workflowId: escalation.workflow_id,
818
- workflowName: escalation.workflow_type,
819
- taskQueue: escalation.task_queue,
820
- taskId: escalation.task_id,
821
- escalationId: escalation.id,
822
- originId: escalation.origin_id ?? undefined,
823
- status: 'resolved',
824
- });
825
- return {
826
- status: 200,
827
- data: {
828
- started: true,
829
- escalationId: escalation.id,
830
- workflowId: triageWorkflowId,
831
- triage: true,
832
- },
833
- };
834
- }
835
- }
836
- // 6. If no workflow_type, this is a notification-only escalation -- acknowledge and close
837
- if (!escalation.workflow_type || !escalation.task_queue) {
838
- await escalationService.resolveEscalation(escalation.id, resolverPayload);
839
- return { status: 200, data: { acknowledged: true, escalationId: escalation.id } };
840
- }
841
- // 7. Standard re-run: inject resolver data and start original workflow
842
- envelope.resolver = resolverPayload;
843
- envelope.lt = {
844
- ...envelope.lt,
845
- escalationId: escalation.id,
846
- };
847
- const newWorkflowId = `rerun-${escalation.id}-${Date.now()}`;
848
- const client = (0, workers_1.createClient)();
849
- await client.workflow.start({
850
- workflowName: escalation.workflow_type,
851
- args: [envelope],
852
- taskQueue: escalation.task_queue,
853
- workflowId: newWorkflowId,
854
- expire: 180,
855
- });
856
- (0, publish_1.publishEscalationEvent)({
857
- type: 'escalation.resolved',
858
- source: 'api',
859
- workflowId: escalation.workflow_id,
860
- workflowName: escalation.workflow_type,
861
- taskQueue: escalation.task_queue,
862
- taskId: escalation.task_id,
863
- escalationId: escalation.id,
864
- originId: escalation.origin_id ?? undefined,
865
- status: 'resolved',
866
- });
867
- return {
868
- status: 200,
869
- data: { started: true, escalationId: escalation.id, workflowId: newWorkflowId },
870
- };
871
- }
872
- catch (err) {
873
- return { status: 500, error: err.message };
874
- }
875
- }
876
- // ── Triage workflow launcher (shared by bulkTriage) ────────────────────────
877
- async function startTriageWorkflow(escalation, hint, userId, client) {
878
- let escalationPayload = {};
879
- if (escalation.escalation_payload) {
880
- try {
881
- escalationPayload = JSON.parse(escalation.escalation_payload);
882
- }
883
- catch { }
884
- }
885
- let envelope = {};
886
- if (escalation.envelope) {
887
- try {
888
- envelope = JSON.parse(escalation.envelope);
889
- }
890
- catch { }
891
- }
892
- const triageWorkflowId = `triage-${escalation.id}-${Date.now()}`;
893
- const triageEnvelope = {
894
- data: {
895
- escalationId: escalation.id,
896
- originId: escalation.origin_id ?? undefined,
897
- originalWorkflowType: escalation.workflow_type,
898
- originalTaskQueue: escalation.task_queue,
899
- originalTaskId: escalation.task_id,
900
- escalationPayload,
901
- resolverPayload: {
902
- _lt: { needsTriage: true, ...(hint ? { hint } : {}) },
903
- },
904
- },
905
- metadata: envelope.metadata || {},
906
- lt: { ...(envelope.lt || {}), userId },
907
- };
908
- const routing = escalation.task_id
909
- ? (await taskService.getTask(escalation.task_id))?.metadata
910
- : null;
911
- await taskService.createTask({
912
- workflow_id: triageWorkflowId,
913
- workflow_type: 'mcpTriage',
914
- lt_type: 'mcpTriage',
915
- task_queue: 'long-tail-system',
916
- signal_id: `lt-triage-${triageWorkflowId}`,
917
- parent_workflow_id: routing?.parentWorkflowId || triageWorkflowId,
918
- origin_id: escalation.origin_id || triageWorkflowId,
919
- parent_id: escalation.parent_id ?? undefined,
920
- envelope: JSON.stringify(triageEnvelope),
921
- metadata: routing || undefined,
922
- });
923
- await client.workflow.start({
924
- workflowName: 'mcpTriage',
925
- args: [triageEnvelope],
926
- taskQueue: 'long-tail-system',
927
- workflowId: triageWorkflowId,
928
- expire: defaults_1.JOB_EXPIRE_SECS,
929
- entity: 'mcpTriage',
930
- });
931
- return triageWorkflowId;
932
- }