@hotmeshio/long-tail 0.11.1 → 0.12.1

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 (266) hide show
  1. package/build/api/domain.d.ts +14 -0
  2. package/build/api/domain.js +76 -0
  3. package/build/api/escalations/cancel.js +16 -1
  4. package/build/api/escalations/helpers.js +5 -0
  5. package/build/lib/db/schemas/030_domain_dictionary.sql +18 -0
  6. package/build/lib/events/escalation-wire.d.ts +9 -0
  7. package/build/lib/events/escalation-wire.js +69 -0
  8. package/build/lib/events/system-events.js +13 -5
  9. package/build/lib/json-path/pick.d.ts +14 -0
  10. package/build/lib/json-path/pick.js +51 -0
  11. package/build/routes/domain.d.ts +2 -0
  12. package/build/routes/domain.js +62 -0
  13. package/build/routes/index.js +2 -0
  14. package/build/services/domain/index.d.ts +4 -0
  15. package/build/services/domain/index.js +14 -0
  16. package/build/services/domain/read.d.ts +21 -0
  17. package/build/services/domain/read.js +78 -0
  18. package/build/services/domain/seed.d.ts +11 -0
  19. package/build/services/domain/seed.js +65 -0
  20. package/build/services/domain/sql.d.ts +10 -0
  21. package/build/services/domain/sql.js +29 -0
  22. package/build/services/domain/validate.d.ts +29 -0
  23. package/build/services/domain/validate.js +50 -0
  24. package/build/services/domain/write.d.ts +23 -0
  25. package/build/services/domain/write.js +43 -0
  26. package/build/services/escalation/crud.js +16 -12
  27. package/build/services/mcp/db-server/schemas.d.ts +1 -1
  28. package/build/services/mcp/external-server.js +31 -1
  29. package/build/services/role/index.d.ts +2 -0
  30. package/build/services/role/index.js +7 -0
  31. package/build/services/role/sql.d.ts +1 -0
  32. package/build/services/role/sql.js +3 -1
  33. package/build/services/role/types.d.ts +21 -1
  34. package/build/services/role/types.js +20 -0
  35. package/build/start/workers.js +6 -0
  36. package/build/system/mcp-servers/admin/domain-context.d.ts +14 -0
  37. package/build/system/mcp-servers/admin/domain-context.js +220 -0
  38. package/build/system/mcp-servers/admin/exports.js +7 -4
  39. package/build/system/mcp-servers/admin/index.js +5 -3
  40. package/build/system/mcp-servers/admin/pipelines.js +9 -3
  41. package/build/system/mcp-servers/admin/schemas.d.ts +61 -32
  42. package/build/system/mcp-servers/admin/schemas.js +23 -5
  43. package/build/system/mcp-servers/admin/workflows.js +26 -0
  44. package/build/system/mcp-servers/db-query/schemas.d.ts +1 -1
  45. package/build/system/mcp-servers/human-queue-schemas.d.ts +1 -1
  46. package/build/system/seed/tool-manifests-admin.d.ts +286 -3
  47. package/build/system/seed/tool-manifests-admin.js +8 -5
  48. package/build/tsconfig.tsbuildinfo +1 -1
  49. package/build/types/domain-manifest.d.ts +77 -0
  50. package/build/types/domain-manifest.js +16 -0
  51. package/build/types/index.d.ts +2 -1
  52. package/build/types/index.js +2 -1
  53. package/build/types/startup.d.ts +10 -0
  54. package/dashboard/dist/assets/{AdminDashboard-D4ebrcNR.js → AdminDashboard-DpTZG5EL.js} +2 -2
  55. package/dashboard/dist/assets/{AdminDashboard-D4ebrcNR.js.map → AdminDashboard-DpTZG5EL.js.map} +1 -1
  56. package/dashboard/dist/assets/{AgentConfigPage-DP4KUuCX.js → AgentConfigPage-DVTL0NvC.js} +2 -2
  57. package/dashboard/dist/assets/{AgentConfigPage-DP4KUuCX.js.map → AgentConfigPage-DVTL0NvC.js.map} +1 -1
  58. package/dashboard/dist/assets/{AgentDetailPage-ktYiR1kq.js → AgentDetailPage-DOLKNPJl.js} +2 -2
  59. package/dashboard/dist/assets/{AgentDetailPage-ktYiR1kq.js.map → AgentDetailPage-DOLKNPJl.js.map} +1 -1
  60. package/dashboard/dist/assets/{AgentsPage-B4iqm4-h.js → AgentsPage-DiOZu6Xb.js} +2 -2
  61. package/dashboard/dist/assets/{AgentsPage-B4iqm4-h.js.map → AgentsPage-DiOZu6Xb.js.map} +1 -1
  62. package/dashboard/dist/assets/AvailableEscalationsPage-CY5lfx27.js +2 -0
  63. package/dashboard/dist/assets/AvailableEscalationsPage-CY5lfx27.js.map +1 -0
  64. package/dashboard/dist/assets/{BotPicker-CLrJuHnW.js → BotPicker-ButjLJr2.js} +2 -2
  65. package/dashboard/dist/assets/{BotPicker-CLrJuHnW.js.map → BotPicker-ButjLJr2.js.map} +1 -1
  66. package/dashboard/dist/assets/{CapabilitiesPage-DG5V0tMT.js → CapabilitiesPage-CW_r2OlX.js} +2 -2
  67. package/dashboard/dist/assets/{CapabilitiesPage-DG5V0tMT.js.map → CapabilitiesPage-CW_r2OlX.js.map} +1 -1
  68. package/dashboard/dist/assets/{CollapsibleSection-CvLHvVfU.js → CollapsibleSection-BOGRyCfm.js} +2 -2
  69. package/dashboard/dist/assets/{CollapsibleSection-CvLHvVfU.js.map → CollapsibleSection-BOGRyCfm.js.map} +1 -1
  70. package/dashboard/dist/assets/{CountdownTimer-Co57-iLY.js → CountdownTimer-UcHYZSg1.js} +2 -2
  71. package/dashboard/dist/assets/{CountdownTimer-Co57-iLY.js.map → CountdownTimer-UcHYZSg1.js.map} +1 -1
  72. package/dashboard/dist/assets/{CredentialsPage-qCJZ3rdi.js → CredentialsPage-A7OFYVsX.js} +2 -2
  73. package/dashboard/dist/assets/{CredentialsPage-qCJZ3rdi.js.map → CredentialsPage-A7OFYVsX.js.map} +1 -1
  74. package/dashboard/dist/assets/{CronLabel-C3iKifDN.js → CronLabel-Dve2Udsm.js} +2 -2
  75. package/dashboard/dist/assets/{CronLabel-C3iKifDN.js.map → CronLabel-Dve2Udsm.js.map} +1 -1
  76. package/dashboard/dist/assets/{CustomDurationPicker-C-Szl4rU.js → CustomDurationPicker-BoPrA-Em.js} +2 -2
  77. package/dashboard/dist/assets/{CustomDurationPicker-C-Szl4rU.js.map → CustomDurationPicker-BoPrA-Em.js.map} +1 -1
  78. package/dashboard/dist/assets/{DropZone-BWD9aGOz.js → DropZone-DovkhN2p.js} +2 -2
  79. package/dashboard/dist/assets/{DropZone-BWD9aGOz.js.map → DropZone-DovkhN2p.js.map} +1 -1
  80. package/dashboard/dist/assets/{ElapsedCell-CamZk5o1.js → ElapsedCell-B114P5mb.js} +2 -2
  81. package/dashboard/dist/assets/{ElapsedCell-CamZk5o1.js.map → ElapsedCell-B114P5mb.js.map} +1 -1
  82. package/dashboard/dist/assets/EntityTimelinePanel-BqDWyOa9.js +2 -0
  83. package/dashboard/dist/assets/EntityTimelinePanel-BqDWyOa9.js.map +1 -0
  84. package/dashboard/dist/assets/{EscalationListSchemaPage-BddDSfjl.js → EscalationListSchemaPage-DyyTyghx.js} +3 -3
  85. package/dashboard/dist/assets/{EscalationListSchemaPage-BddDSfjl.js.map → EscalationListSchemaPage-DyyTyghx.js.map} +1 -1
  86. package/dashboard/dist/assets/{EscalationSchemaPage-BRyCtw9R.js → EscalationSchemaPage-DLQG6EXQ.js} +2 -2
  87. package/dashboard/dist/assets/{EscalationSchemaPage-BRyCtw9R.js.map → EscalationSchemaPage-DLQG6EXQ.js.map} +1 -1
  88. package/dashboard/dist/assets/{EscalationsOverview-DUWYxJyD.js → EscalationsOverview-RrbkkEU0.js} +2 -2
  89. package/dashboard/dist/assets/{EscalationsOverview-DUWYxJyD.js.map → EscalationsOverview-RrbkkEU0.js.map} +1 -1
  90. package/dashboard/dist/assets/{EventTable-CtVuCgq6.js → EventTable-DOxubt7O.js} +2 -2
  91. package/dashboard/dist/assets/{EventTable-CtVuCgq6.js.map → EventTable-DOxubt7O.js.map} +1 -1
  92. package/dashboard/dist/assets/{FilterBar-BYsBgOiE.js → FilterBar-y659Gc3X.js} +2 -2
  93. package/dashboard/dist/assets/{FilterBar-BYsBgOiE.js.map → FilterBar-y659Gc3X.js.map} +1 -1
  94. package/dashboard/dist/assets/{GraphInvokePage-CA4skPN2.js → GraphInvokePage-oHLgSAl6.js} +2 -2
  95. package/dashboard/dist/assets/{GraphInvokePage-CA4skPN2.js.map → GraphInvokePage-oHLgSAl6.js.map} +1 -1
  96. package/dashboard/dist/assets/{HomePage-DwG-AnjQ.js → HomePage-C9FUpD7x.js} +2 -2
  97. package/dashboard/dist/assets/{HomePage-DwG-AnjQ.js.map → HomePage-C9FUpD7x.js.map} +1 -1
  98. package/dashboard/dist/assets/{ListToolbar-D86IN_hQ.js → ListToolbar-DfpSgWYU.js} +2 -2
  99. package/dashboard/dist/assets/{ListToolbar-D86IN_hQ.js.map → ListToolbar-DfpSgWYU.js.map} +1 -1
  100. package/dashboard/dist/assets/{McpOverview-CoEHGseD.js → McpOverview-6Ubpr9QS.js} +2 -2
  101. package/dashboard/dist/assets/{McpOverview-CoEHGseD.js.map → McpOverview-6Ubpr9QS.js.map} +1 -1
  102. package/dashboard/dist/assets/{McpQueryDetailPage-C9hMgJe1.js → McpQueryDetailPage-DFt-vQEp.js} +2 -2
  103. package/dashboard/dist/assets/{McpQueryDetailPage-C9hMgJe1.js.map → McpQueryDetailPage-DFt-vQEp.js.map} +1 -1
  104. package/dashboard/dist/assets/{McpQueryPage-B20Zn4QX.js → McpQueryPage-DQiG0AE3.js} +2 -2
  105. package/dashboard/dist/assets/{McpQueryPage-B20Zn4QX.js.map → McpQueryPage-DQiG0AE3.js.map} +1 -1
  106. package/dashboard/dist/assets/{McpRunDetailPage-DDKHf-3R.js → McpRunDetailPage-BgsSegyP.js} +2 -2
  107. package/dashboard/dist/assets/{McpRunDetailPage-DDKHf-3R.js.map → McpRunDetailPage-BgsSegyP.js.map} +1 -1
  108. package/dashboard/dist/assets/{McpRunsPage-Puyn3iJr.js → McpRunsPage-tCMxspqS.js} +2 -2
  109. package/dashboard/dist/assets/{McpRunsPage-Puyn3iJr.js.map → McpRunsPage-tCMxspqS.js.map} +1 -1
  110. package/dashboard/dist/assets/{NamespacePill-C09QuOEz.js → NamespacePill-BeifzjUm.js} +2 -2
  111. package/dashboard/dist/assets/{NamespacePill-C09QuOEz.js.map → NamespacePill-BeifzjUm.js.map} +1 -1
  112. package/dashboard/dist/assets/OperationsPage-DUaRmEPa.js +3 -0
  113. package/dashboard/dist/assets/OperationsPage-DUaRmEPa.js.map +1 -0
  114. package/dashboard/dist/assets/{OperatorDashboard-CXBbFLAL.js → OperatorDashboard-CayyjMcf.js} +2 -2
  115. package/dashboard/dist/assets/{OperatorDashboard-CXBbFLAL.js.map → OperatorDashboard-CayyjMcf.js.map} +1 -1
  116. package/dashboard/dist/assets/{PageHeader-B7YJxa4o.js → PageHeader-BpeBHqyc.js} +2 -2
  117. package/dashboard/dist/assets/{PageHeader-B7YJxa4o.js.map → PageHeader-BpeBHqyc.js.map} +1 -1
  118. package/dashboard/dist/assets/{PageHeaderWithStats-gT-5ovJh.js → PageHeaderWithStats-JXeUFa_g.js} +2 -2
  119. package/dashboard/dist/assets/{PageHeaderWithStats-gT-5ovJh.js.map → PageHeaderWithStats-JXeUFa_g.js.map} +1 -1
  120. package/dashboard/dist/assets/{PersonaDetailPage-BN5xNDDX.js → PersonaDetailPage-DBcxfdbN.js} +2 -2
  121. package/dashboard/dist/assets/{PersonaDetailPage-BN5xNDDX.js.map → PersonaDetailPage-DBcxfdbN.js.map} +1 -1
  122. package/dashboard/dist/assets/{PersonasPage-Bdtv6HPZ.js → PersonasPage-DPq0HQAB.js} +2 -2
  123. package/dashboard/dist/assets/{PersonasPage-Bdtv6HPZ.js.map → PersonasPage-DPq0HQAB.js.map} +1 -1
  124. package/dashboard/dist/assets/{ProcessDetailPage-BMg70ZAJ.js → ProcessDetailPage-QQZNNNMw.js} +2 -2
  125. package/dashboard/dist/assets/{ProcessDetailPage-BMg70ZAJ.js.map → ProcessDetailPage-QQZNNNMw.js.map} +1 -1
  126. package/dashboard/dist/assets/{ProcessesListPage-_KvdxGhL.js → ProcessesListPage-UKQMJ4Te.js} +2 -2
  127. package/dashboard/dist/assets/{ProcessesListPage-_KvdxGhL.js.map → ProcessesListPage-UKQMJ4Te.js.map} +1 -1
  128. package/dashboard/dist/assets/RoleDetailPage-DT-3sSRD.js +8 -0
  129. package/dashboard/dist/assets/RoleDetailPage-DT-3sSRD.js.map +1 -0
  130. package/dashboard/dist/assets/{RolePill-CtYI1_k1.js → RolePill-EocCXZh0.js} +2 -2
  131. package/dashboard/dist/assets/{RolePill-CtYI1_k1.js.map → RolePill-EocCXZh0.js.map} +1 -1
  132. package/dashboard/dist/assets/{RolesPage-Bv23VmUi.js → RolesPage-DZg4niqL.js} +2 -2
  133. package/dashboard/dist/assets/{RolesPage-Bv23VmUi.js.map → RolesPage-DZg4niqL.js.map} +1 -1
  134. package/dashboard/dist/assets/{RunAsSelector-D-Sjr7uB.js → RunAsSelector-DkcNR7L6.js} +2 -2
  135. package/dashboard/dist/assets/{RunAsSelector-D-Sjr7uB.js.map → RunAsSelector-DkcNR7L6.js.map} +1 -1
  136. package/dashboard/dist/assets/{ScanCodesPage-s3OEMJno.js → ScanCodesPage-U-alpwWF.js} +2 -2
  137. package/dashboard/dist/assets/{ScanCodesPage-s3OEMJno.js.map → ScanCodesPage-U-alpwWF.js.map} +1 -1
  138. package/dashboard/dist/assets/{ScanSchemeDetailPage-D8WQkZmw.js → ScanSchemeDetailPage-lXwlcraS.js} +2 -2
  139. package/dashboard/dist/assets/{ScanSchemeDetailPage-D8WQkZmw.js.map → ScanSchemeDetailPage-lXwlcraS.js.map} +1 -1
  140. package/dashboard/dist/assets/ScanStationPage-DYMiTp-v.js +2 -0
  141. package/dashboard/dist/assets/{ScanStationPage-CkRQaH5G.js.map → ScanStationPage-DYMiTp-v.js.map} +1 -1
  142. package/dashboard/dist/assets/{ScopeBadge-B76rOtA0.js → ScopeBadge-H5dEqeHi.js} +2 -2
  143. package/dashboard/dist/assets/{ScopeBadge-B76rOtA0.js.map → ScopeBadge-H5dEqeHi.js.map} +1 -1
  144. package/dashboard/dist/assets/{StickyPagination-BpTIMOL5.js → StickyPagination-D896Wquq.js} +2 -2
  145. package/dashboard/dist/assets/{StickyPagination-BpTIMOL5.js.map → StickyPagination-D896Wquq.js.map} +1 -1
  146. package/dashboard/dist/assets/{StreamMessageDetail-ChoWrZzO.js → StreamMessageDetail-DIh5qEGJ.js} +2 -2
  147. package/dashboard/dist/assets/{StreamMessageDetail-ChoWrZzO.js.map → StreamMessageDetail-DIh5qEGJ.js.map} +1 -1
  148. package/dashboard/dist/assets/{SwimlaneTimeline-nmIqEuEH.js → SwimlaneTimeline-B8SucVj5.js} +2 -2
  149. package/dashboard/dist/assets/{SwimlaneTimeline-nmIqEuEH.js.map → SwimlaneTimeline-B8SucVj5.js.map} +1 -1
  150. package/dashboard/dist/assets/{TagInput-BQAPOp17.js → TagInput-Ch5u6iPH.js} +2 -2
  151. package/dashboard/dist/assets/{TagInput-BQAPOp17.js.map → TagInput-Ch5u6iPH.js.map} +1 -1
  152. package/dashboard/dist/assets/{TaskDetailPage-KajZD2Cp.js → TaskDetailPage-Di-z_ZE2.js} +2 -2
  153. package/dashboard/dist/assets/{TaskDetailPage-KajZD2Cp.js.map → TaskDetailPage-Di-z_ZE2.js.map} +1 -1
  154. package/dashboard/dist/assets/{TaskQueuePill-C2NImrwl.js → TaskQueuePill-Bz146p-P.js} +2 -2
  155. package/dashboard/dist/assets/{TaskQueuePill-C2NImrwl.js.map → TaskQueuePill-Bz146p-P.js.map} +1 -1
  156. package/dashboard/dist/assets/{TasksListPage-CiqSfapP.js → TasksListPage-ClHGEdin.js} +2 -2
  157. package/dashboard/dist/assets/{TasksListPage-CiqSfapP.js.map → TasksListPage-ClHGEdin.js.map} +1 -1
  158. package/dashboard/dist/assets/{TimeAgo-ClauexJj.js → TimeAgo-BSDHd9Xo.js} +2 -2
  159. package/dashboard/dist/assets/{TimeAgo-ClauexJj.js.map → TimeAgo-BSDHd9Xo.js.map} +1 -1
  160. package/dashboard/dist/assets/{TimestampCell-CXmbCnAJ.js → TimestampCell-WQL3FxWl.js} +2 -2
  161. package/dashboard/dist/assets/{TimestampCell-CXmbCnAJ.js.map → TimestampCell-WQL3FxWl.js.map} +1 -1
  162. package/dashboard/dist/assets/{ToolPill-FOZm67TS.js → ToolPill-sj8OkBB0.js} +2 -2
  163. package/dashboard/dist/assets/{ToolPill-FOZm67TS.js.map → ToolPill-sj8OkBB0.js.map} +1 -1
  164. package/dashboard/dist/assets/{ToolTestPanel-DFUU0zGv.js → ToolTestPanel-IVIkqZTi.js} +2 -2
  165. package/dashboard/dist/assets/{ToolTestPanel-DFUU0zGv.js.map → ToolTestPanel-IVIkqZTi.js.map} +1 -1
  166. package/dashboard/dist/assets/{TopicDetailPage-DuN5BrsI.js → TopicDetailPage-BOasQo68.js} +2 -2
  167. package/dashboard/dist/assets/{TopicDetailPage-DuN5BrsI.js.map → TopicDetailPage-BOasQo68.js.map} +1 -1
  168. package/dashboard/dist/assets/{TopicsPage-DZ1NQdYG.js → TopicsPage-DV_orf_V.js} +2 -2
  169. package/dashboard/dist/assets/{TopicsPage-DZ1NQdYG.js.map → TopicsPage-DV_orf_V.js.map} +1 -1
  170. package/dashboard/dist/assets/{UserName-BPHG_MQs.js → UserName-rshjKBtm.js} +2 -2
  171. package/dashboard/dist/assets/{UserName-BPHG_MQs.js.map → UserName-rshjKBtm.js.map} +1 -1
  172. package/dashboard/dist/assets/{WorkflowExecutionPage-D_Z-tIjR.js → WorkflowExecutionPage-BpNGLwbK.js} +2 -2
  173. package/dashboard/dist/assets/{WorkflowExecutionPage-D_Z-tIjR.js.map → WorkflowExecutionPage-BpNGLwbK.js.map} +1 -1
  174. package/dashboard/dist/assets/{WorkflowPill-C5TEWlfO.js → WorkflowPill-BcA7S3gI.js} +2 -2
  175. package/dashboard/dist/assets/{WorkflowPill-C5TEWlfO.js.map → WorkflowPill-BcA7S3gI.js.map} +1 -1
  176. package/dashboard/dist/assets/{WorkflowsDashboard-VMBW1WuR.js → WorkflowsDashboard-BAXt8gv_.js} +2 -2
  177. package/dashboard/dist/assets/{WorkflowsDashboard-VMBW1WuR.js.map → WorkflowsDashboard-BAXt8gv_.js.map} +1 -1
  178. package/dashboard/dist/assets/{WorkflowsOverview-CUOXXcpg.js → WorkflowsOverview-DvOyzL6y.js} +2 -2
  179. package/dashboard/dist/assets/{WorkflowsOverview-CUOXXcpg.js.map → WorkflowsOverview-DvOyzL6y.js.map} +1 -1
  180. package/dashboard/dist/assets/{YamlWorkflowDetailPage-CsfzbboC.js → YamlWorkflowDetailPage-CraijGy6.js} +2 -2
  181. package/dashboard/dist/assets/{YamlWorkflowDetailPage-CsfzbboC.js.map → YamlWorkflowDetailPage-CraijGy6.js.map} +1 -1
  182. package/dashboard/dist/assets/{YamlWorkflowsPage-BpgKLSGT.js → YamlWorkflowsPage-CNz3ptmj.js} +2 -2
  183. package/dashboard/dist/assets/{YamlWorkflowsPage-BpgKLSGT.js.map → YamlWorkflowsPage-CNz3ptmj.js.map} +1 -1
  184. package/dashboard/dist/assets/{agents-Cg2FVYQP.js → agents-BswSJR-t.js} +2 -2
  185. package/dashboard/dist/assets/{agents-Cg2FVYQP.js.map → agents-BswSJR-t.js.map} +1 -1
  186. package/dashboard/dist/assets/{bots-vtVLRKGt.js → bots-VzlLx_GQ.js} +2 -2
  187. package/dashboard/dist/assets/{bots-vtVLRKGt.js.map → bots-VzlLx_GQ.js.map} +1 -1
  188. package/dashboard/dist/assets/{capabilities-DLsXhwlD.js → capabilities-B0bNlTTA.js} +2 -2
  189. package/dashboard/dist/assets/{capabilities-DLsXhwlD.js.map → capabilities-B0bNlTTA.js.map} +1 -1
  190. package/dashboard/dist/assets/{controlplane-Js7dxpX4.js → controlplane-DBESTVZS.js} +2 -2
  191. package/dashboard/dist/assets/{controlplane-Js7dxpX4.js.map → controlplane-DBESTVZS.js.map} +1 -1
  192. package/dashboard/dist/assets/escalation-columns-CoqsCdbP.js +2 -0
  193. package/dashboard/dist/assets/escalation-columns-CoqsCdbP.js.map +1 -0
  194. package/dashboard/dist/assets/{index-FYQ9yPhO.js → index-BBXmIWKx.js} +2 -2
  195. package/dashboard/dist/assets/{index-FYQ9yPhO.js.map → index-BBXmIWKx.js.map} +1 -1
  196. package/dashboard/dist/assets/{index-BTzhV9ST.js → index-BLzwfbZV.js} +2 -2
  197. package/dashboard/dist/assets/{index-BTzhV9ST.js.map → index-BLzwfbZV.js.map} +1 -1
  198. package/dashboard/dist/assets/{index-DglcqBHn.js → index-ByUjwu37.js} +4 -4
  199. package/dashboard/dist/assets/{index-DglcqBHn.js.map → index-ByUjwu37.js.map} +1 -1
  200. package/dashboard/dist/assets/{index-BvVJ538E.js → index-CALocCAr.js} +2 -2
  201. package/dashboard/dist/assets/{index-BvVJ538E.js.map → index-CALocCAr.js.map} +1 -1
  202. package/dashboard/dist/assets/{index-Bcv5k8Dw.js → index-C_lA7ghl.js} +2 -2
  203. package/dashboard/dist/assets/{index-Bcv5k8Dw.js.map → index-C_lA7ghl.js.map} +1 -1
  204. package/dashboard/dist/assets/{index-CSpTj5DB.js → index-Cd7jZylO.js} +2 -2
  205. package/dashboard/dist/assets/{index-CSpTj5DB.js.map → index-Cd7jZylO.js.map} +1 -1
  206. package/dashboard/dist/assets/{index-DQi6CjqF.js → index-Ci4lxPwS.js} +2 -2
  207. package/dashboard/dist/assets/{index-DQi6CjqF.js.map → index-Ci4lxPwS.js.map} +1 -1
  208. package/dashboard/dist/assets/{index-CcjdA7jA.js → index-Cqrp5B5S.js} +23 -23
  209. package/dashboard/dist/assets/index-Cqrp5B5S.js.map +1 -0
  210. package/dashboard/dist/assets/{index-7c7FEe5S.js → index-D8ljRGIb.js} +2 -2
  211. package/dashboard/dist/assets/{index-7c7FEe5S.js.map → index-D8ljRGIb.js.map} +1 -1
  212. package/dashboard/dist/assets/{index-DlO3bCfu.js → index-DJS-hvDt.js} +2 -2
  213. package/dashboard/dist/assets/{index-DlO3bCfu.js.map → index-DJS-hvDt.js.map} +1 -1
  214. package/dashboard/dist/assets/{index-vAkZ5dZe.js → index-DUfdCp8e.js} +2 -2
  215. package/dashboard/dist/assets/{index-vAkZ5dZe.js.map → index-DUfdCp8e.js.map} +1 -1
  216. package/dashboard/dist/assets/{index-KcaVfpWn.js → index-DYDcjn-b.js} +2 -2
  217. package/dashboard/dist/assets/{index-KcaVfpWn.js.map → index-DYDcjn-b.js.map} +1 -1
  218. package/dashboard/dist/assets/{index-BjfoWzJL.js → index-DsDFZzqr.js} +2 -2
  219. package/dashboard/dist/assets/{index-BjfoWzJL.js.map → index-DsDFZzqr.js.map} +1 -1
  220. package/dashboard/dist/assets/{knowledge-Bkvl3cIz.js → knowledge-DB2DgDa_.js} +2 -2
  221. package/dashboard/dist/assets/{knowledge-Bkvl3cIz.js.map → knowledge-DB2DgDa_.js.map} +1 -1
  222. package/dashboard/dist/assets/{mcp-DEtDLeIQ.js → mcp-D72yCeuf.js} +2 -2
  223. package/dashboard/dist/assets/{mcp-DEtDLeIQ.js.map → mcp-D72yCeuf.js.map} +1 -1
  224. package/dashboard/dist/assets/{mcp-query-BCRgnt0K.js → mcp-query-Cyyc_0E8.js} +2 -2
  225. package/dashboard/dist/assets/{mcp-query-BCRgnt0K.js.map → mcp-query-Cyyc_0E8.js.map} +1 -1
  226. package/dashboard/dist/assets/{personas-CABKq-0L.js → personas-xMDV7yXb.js} +2 -2
  227. package/dashboard/dist/assets/{personas-CABKq-0L.js.map → personas-xMDV7yXb.js.map} +1 -1
  228. package/dashboard/dist/assets/{pipelines-fuN8dVNl.js → pipelines-mlxfmi6m.js} +2 -2
  229. package/dashboard/dist/assets/{pipelines-fuN8dVNl.js.map → pipelines-mlxfmi6m.js.map} +1 -1
  230. package/dashboard/dist/assets/{tasks-u3YPNJBo.js → tasks-CxgOp_9H.js} +2 -2
  231. package/dashboard/dist/assets/{tasks-u3YPNJBo.js.map → tasks-CxgOp_9H.js.map} +1 -1
  232. package/dashboard/dist/assets/{topics-D37_RAIT.js → topics-CFb_L0Vs.js} +2 -2
  233. package/dashboard/dist/assets/{topics-D37_RAIT.js.map → topics-CFb_L0Vs.js.map} +1 -1
  234. package/dashboard/dist/assets/{useEventHooks-BbXfrFbq.js → useEventHooks-nC5kH-QW.js} +2 -2
  235. package/dashboard/dist/assets/{useEventHooks-BbXfrFbq.js.map → useEventHooks-nC5kH-QW.js.map} +1 -1
  236. package/dashboard/dist/assets/{useNamespace-DvuoFTda.js → useNamespace-DQeDgRFR.js} +2 -2
  237. package/dashboard/dist/assets/{useNamespace-DvuoFTda.js.map → useNamespace-DQeDgRFR.js.map} +1 -1
  238. package/dashboard/dist/assets/{useYamlActivityEvents-CL-Uf2cb.js → useYamlActivityEvents-BuGC3oBE.js} +2 -2
  239. package/dashboard/dist/assets/{useYamlActivityEvents-CL-Uf2cb.js.map → useYamlActivityEvents-BuGC3oBE.js.map} +1 -1
  240. package/dashboard/dist/assets/{users-CMxw_HzK.js → users-BZUTtM_6.js} +2 -2
  241. package/dashboard/dist/assets/{users-CMxw_HzK.js.map → users-BZUTtM_6.js.map} +1 -1
  242. package/dashboard/dist/assets/{vendor-icons-Aw7bzBxa.js → vendor-icons-BPsNpK3Y.js} +142 -137
  243. package/dashboard/dist/assets/vendor-icons-BPsNpK3Y.js.map +1 -0
  244. package/dashboard/dist/assets/{workflows-Bez-o6fu.js → workflows-DWhaZWVK.js} +2 -2
  245. package/dashboard/dist/assets/{workflows-Bez-o6fu.js.map → workflows-DWhaZWVK.js.map} +1 -1
  246. package/dashboard/dist/assets/{yaml-workflows-NrXcLsNm.js → yaml-workflows-C1TeDIIk.js} +2 -2
  247. package/dashboard/dist/assets/{yaml-workflows-NrXcLsNm.js.map → yaml-workflows-C1TeDIIk.js.map} +1 -1
  248. package/dashboard/dist/index.html +2 -2
  249. package/docs/domain-dictionary.md +115 -0
  250. package/docs/events.md +8 -0
  251. package/docs/hitl/x-lt-transition.md +13 -0
  252. package/docs/scan-codes.md +24 -0
  253. package/package.json +1 -1
  254. package/dashboard/dist/assets/AvailableEscalationsPage-tL3mM1RG.js +0 -2
  255. package/dashboard/dist/assets/AvailableEscalationsPage-tL3mM1RG.js.map +0 -1
  256. package/dashboard/dist/assets/EntityTimelinePanel-CABCW2dS.js +0 -2
  257. package/dashboard/dist/assets/EntityTimelinePanel-CABCW2dS.js.map +0 -1
  258. package/dashboard/dist/assets/OperationsPage-Bsrt4XTL.js +0 -3
  259. package/dashboard/dist/assets/OperationsPage-Bsrt4XTL.js.map +0 -1
  260. package/dashboard/dist/assets/RoleDetailPage-BM5BXc7j.js +0 -8
  261. package/dashboard/dist/assets/RoleDetailPage-BM5BXc7j.js.map +0 -1
  262. package/dashboard/dist/assets/ScanStationPage-CkRQaH5G.js +0 -2
  263. package/dashboard/dist/assets/escalation-columns-h0NLAJss.js +0 -2
  264. package/dashboard/dist/assets/escalation-columns-h0NLAJss.js.map +0 -1
  265. package/dashboard/dist/assets/index-CcjdA7jA.js.map +0 -1
  266. package/dashboard/dist/assets/vendor-icons-Aw7bzBxa.js.map +0 -1
@@ -0,0 +1,115 @@
1
+ # The Domain Dictionary
2
+
3
+ Every deployment runs its own ontology on top of long-tail's primitives: the
4
+ operation speaks in printers, orders, batches, and resets, while the platform
5
+ speaks in roles, queues, workflows, escalations, and metadata facets. The domain
6
+ dictionary is where that translation is declared. An agent (or a teammate) that
7
+ knows the dictionary hears "printer PRN-001" and immediately knows the query —
8
+ the roles whose rows carry it, the facet that identifies it, `created_at desc`.
9
+
10
+ The dictionary lives in the database (`lt_domain`, one row per deployment). It
11
+ declares the **semantic overlay** — jargon terms, guidance, runbooks. Structure
12
+ is **derived** from the live registries when the dictionary is read: an entity's
13
+ id facet comes from its role's `entity_facet`, a role entry carries the live
14
+ row's title and verb semantics, a workflow entry carries the live config. The
15
+ merged view is always current.
16
+
17
+ ## The shape
18
+
19
+ ```json
20
+ {
21
+ "name": "acme print-farm",
22
+ "version": "1",
23
+ "overview": "One page: what this deployment runs.",
24
+ "terms": [
25
+ {
26
+ "term": "printer",
27
+ "aliases": ["machine"],
28
+ "kind": "entity",
29
+ "maps_to": { "roles": ["printer-fleet"] },
30
+ "guidance": "A machine on the floor, keyed by serialNumber. Find one with facets={serialNumber: value}."
31
+ },
32
+ {
33
+ "term": "reset",
34
+ "kind": "action",
35
+ "maps_to": { "verb": "cancel", "role": "print-operator" },
36
+ "guidance": "Cancel the demand row — the dispatcher re-mints the attempt."
37
+ },
38
+ {
39
+ "term": "the pipe",
40
+ "kind": "workflow",
41
+ "maps_to": { "workflow": "orderPipeline" },
42
+ "id_convention": "pipe-<orderId>",
43
+ "kill_road": "Terminate the pipe root with terminate_workflow; never cancel the demand row.",
44
+ "guidance": "One run per order."
45
+ },
46
+ {
47
+ "term": "claims expire = recovery",
48
+ "kind": "rule",
49
+ "guidance": "A lapsed claim returns the row to the queue. Expiry is recovery, not an error."
50
+ }
51
+ ],
52
+ "runbooks": [
53
+ { "name": "kill a test order", "steps": ["find the pipe root by id convention", "terminate_workflow on it"] }
54
+ ]
55
+ }
56
+ ```
57
+
58
+ Term kinds: `entity` (a tracked noun; `idFacet` derives from the role's
59
+ `entity_facet`, declare it only to override), `role` (jargon for a queue),
60
+ `workflow` (carries `kill_road` and `id_convention`), `facet` (a metadata key's
61
+ meaning; `values` lists a closed domain), `action` (a domain verb mapped to a
62
+ platform verb), `rule` (a standing law, stated imperatively).
63
+
64
+ ## Role verb semantics live on the role
65
+
66
+ What cancel or expiry MEANS for a row class is a property of the role itself.
67
+ Declare it under the reserved `lt_roles.properties` keys — editable with the
68
+ same `PATCH /api/roles/:role` that manages every other role dial:
69
+
70
+ ```json
71
+ { "on_cancel": "reset — the dispatcher re-mints the attempt",
72
+ "on_timeout": "the gate re-parks and keeps listening",
73
+ "worked_by": "machines" }
74
+ ```
75
+
76
+ `cancel_escalation` returns the role's `on_cancel` alongside the receipt, and
77
+ `get_domain_context` merges all three into role entries.
78
+
79
+ ## Registration and editing
80
+
81
+ Seed at boot by pointing the start config at a JSON file:
82
+
83
+ ```typescript
84
+ mcp: { domainDictionaryPath: 'src/longtail/domain.json' }
85
+ ```
86
+
87
+ Seeding is insert-if-absent: the DB row is runtime truth, and a name/version
88
+ mismatch between file and DB logs a drift warning. Edit live with
89
+ `PUT /api/domain` (admin) — the body is `{ doc, expected_version? }`;
90
+ `expected_version` arms optimistic concurrency (409 on conflict). Writes
91
+ validate references against the live registries: unknown roles and workflows
92
+ reject with 422 naming them; unknown facet keys warn (facets are discovered
93
+ from data and may simply have no rows yet). The boot seed applies the same
94
+ checks as warnings, so host seed ordering never blocks a boot.
95
+
96
+ ## The derived floor
97
+
98
+ `get_domain_context` works on every deployment, dictionary or none. The live
99
+ registries already self-describe the structure — roles carry titles,
100
+ descriptions, `entity_facet`, and verb semantics; workflow configs carry
101
+ descriptions and invocability; facet keys are discovered from data. With no
102
+ dictionary registered the tool serves that derived view (entities are named by
103
+ their facet key, e.g. `serialNumber`, and roles sharing a facet form the
104
+ entity's system). A registered dictionary adds what only humans know: the
105
+ jargon nouns and aliases, guidance, kill roads, and runbooks.
106
+
107
+ ## How agents consume it
108
+
109
+ - **MCP `instructions`** carry the overview plus a compact names-only index —
110
+ a session-sized breadcrumb pointing at the tool.
111
+ - **`get_domain_context`** (read-safe) returns the merged view: no args → the
112
+ index; `{ topic, name }` → specific entries, where `name` matches the term or
113
+ any alias case-insensitively and topic `term` searches every kind. Entries
114
+ referencing a since-removed role or workflow are annotated as dangling.
115
+ - **`GET /api/domain`** serves the raw document to dashboards and scripts.
package/docs/events.md CHANGED
@@ -81,6 +81,14 @@ System families declare the fields they populate. Which fields exist is a functi
81
81
 
82
82
  Escalation subjects carry the **role** (the queue) as the organizing token. Subscribe to one queue (`system.escalation.{role}.>`), one verb across queues (`system.escalation.*.*.created`), or one item across role hops (`system.escalation.*.{id}.>`). The role token is sanitized to subject-safe characters (`[A-Za-z0-9_-]`); a `reassigned` event publishes under **both** the departing and arriving role so either queue's subscribers observe the move.
83
83
 
84
+ #### Escalation `data` — one wire shape
85
+
86
+ A lifecycle event is a **notification**, not a transport. Its `data` is the **wire-safe projection** of the escalation row — routing/classification scalars plus the metadata **facets** — and never the heavy or sensitive JSON columns. Both publisher families (the service-mediated `crud.ts` path and the engine-mediated SDK hook) build `data` through one definition, `lib/events/escalation-wire.ts`, so the shape is identical regardless of who transitioned the row.
87
+
88
+ - **Kept:** the scalar columns (an allowlist) and every metadata facet (`orderId`, `serialNumber`, entity keys, `schema_version`, …) — the surface agent triggers filter/map on and the entity/faceted views route by. Verbs add their provenance alongside (`reason`, `released_by`, `resolved_by`, `from_role`/`to_role`).
89
+ - **Dropped:** `envelope`, `escalation_payload`, `resolver_payload`, and `metadata.form_schema`. A subscriber needing these fetches the row by id through the authenticated read API — the pub channel is not authenticated.
90
+ - **Bulk exception:** `publishBulk*` operate on many rows they don't hold in full; they publish the delta plus `bulk: true` (fetching each row to project would cost one query per row) and let subscribers fetch by id.
91
+
84
92
  Consumers (adapters, the agent trigger registry, input_mapping) type against the broad **`LTEvent`** — the base plus every extension as **optional** — since they can't assume any extension is present. Producers (`lib/events/publish.ts`) construct the precise `LT*Event` family types, all assignable to `LTEvent`.
85
93
 
86
94
  ### Who mints it
@@ -88,6 +88,19 @@ Resolution order on submit: `x-lt-transition` (wait for the hand-off) →
88
88
  transition step, `x-lt-transition-done` is also where the wait lands if the
89
89
  follow-on never arrives.
90
90
 
91
+ **Station recipe — submit lands on the list.** Shared-station flows (badge
92
+ scan → claim → resolve) arrive at the detail page from angles where browser
93
+ history is meaningless, so the `history.back()` default confuses. Declare the
94
+ destination on the role's form-schema root and every submit returns to the
95
+ role's queue:
96
+
97
+ ```jsonc
98
+ { "x-lt-transition-done": "/escalations/available?role={{escalation.role}}&status=available" }
99
+ ```
100
+
101
+ No `x-lt-transition` needed when there is no follow-on to wait for — the
102
+ navigation is immediate.
103
+
91
104
  ## If the live event is missed
92
105
 
93
106
  Event delivery is at-most-once: a crash between the commit and the publish drops
@@ -216,6 +216,30 @@ takes the badge layer, and `write_scope: 'none'` is the structural
216
216
  backstop — even a misconfigured rule cannot mutate as the station, because
217
217
  the RBAC write gate denies the account itself.
218
218
 
219
+ `write_scope: 'none'` is also what makes the badge challenge fire:
220
+ `requireActingIdentity` is satisfied by a badge grant **or** by a login whose
221
+ own write scope covers the step, so a write-capable base login self-satisfies
222
+ the requirement and claims/resolves as itself with no badge demanded. The
223
+ badge-every-time contract requires the read-all/write-none base login.
224
+
225
+ ### Kiosk mode — the locked station viewport
226
+
227
+ A role opts in with `properties.kiosk: true` (the reserved role-property key,
228
+ set with the same `PATCH /api/roles/:role` as every other dial). When the
229
+ signed-in user is a **member of exactly that one role** — the station-login
230
+ shape — the dashboard locks the viewport: the left nav is gone entirely, the
231
+ role's escalation list is home (`/` and every other surface redirect to it),
232
+ and the session is held to the list, the escalation detail page, and the scan
233
+ screens (choice, badge). The header toolbar and event feed remain. A user
234
+ holding more than one role, or an admin-type grant, always gets full chrome —
235
+ kiosk is for the single-role floor login, never a way to hide the product from
236
+ a real operator.
237
+
238
+ Pair kiosk with `x-lt-transition-done` on the role's form schema
239
+ (`"/escalations/available?role={{escalation.role}}&status=available"`) so a
240
+ resolve lands back on the list rather than walking browser history — see
241
+ [x-lt-transition](./hitl/x-lt-transition.md).
242
+
219
243
  Mutations attribute to the badged person (`assigned_to`, `resolved_by`)
220
244
  with the device recorded beside them (`scanStation` in the scan
221
245
  provenance) — every action individually owned and geographically placed.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/long-tail",
3
- "version": "0.11.1",
3
+ "version": "0.12.1",
4
4
  "description": "Long Tail Workflows — Durable AI workflows with human-in-the-loop escalation. Powered by PostgreSQL.",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -1,2 +0,0 @@
1
- import{j as e,a as f}from"./vendor-query-RUZdMvN6.js";import{u as At,l as Tt,m as Je,n as Le,p as Ot,w as Et,o as Ft,q as _t,r as $t,s as Lt,t as Bt,v as Rt,x as zt,i as qt,y as Dt,z as It,A as Ut,B as Vt,E as Gt,G as Ht,H as Qt,I as Jt,K as Kt,L as Wt,M as Xt,O as Yt,Q as Zt}from"./index-CcjdA7jA.js";import{i as es}from"./task-queues-7-sHKPsN.js";import{f as ts}from"./useEventHooks-BbXfrFbq.js";import{X as te,ag as ss,ah as as,C as ns,b as rs,ai as is,aj as ls,t as os,s as cs,ak as ds,B as us,al as Be,am as xs,Q as ms,P as hs,g as ps,an as fs}from"./vendor-icons-Aw7bzBxa.js";import{u as he,C as Ke,a as gs}from"./CustomDurationPicker-C-Szl4rU.js";import{m as bs,E as ys,a as js}from"./escalation-columns-h0NLAJss.js";import{i as vs,E as Ns}from"./CountdownTimer-Co57-iLY.js";import{u as Cs}from"./useFilterParams-crmlBw_l.js";import{u as We}from"./useDebouncedValue-C4P2jQuh.js";import{b as ks}from"./api-path-u2Jf9QXS.js";import{D as ws}from"./DataTable-Bir0Xs1p.js";import{S as Ss}from"./StickyPagination-BpTIMOL5.js";import{P as Ps}from"./constants-BHkpVaqx.js";import{M as pe}from"./Modal-BU7No9NH.js";import{u as Ms}from"./users-CMxw_HzK.js";import{R as As,a as Ts}from"./RowActions-eYrzgQSj.js";import{L as Os}from"./ListToolbar-D86IN_hQ.js";import{L as Re,u as Es,f as Fs,a as _s}from"./vendor-react-CdqEC2zv.js";import"./EntityTimelinePanel-CABCW2dS.js";import"./FilterBar-BYsBgOiE.js";import"./PriorityBadge-BETdj4M-.js";import"./RolePill-CtYI1_k1.js";import"./WorkflowPill-C5TEWlfO.js";import"./StatusBadge-DkgllZHv.js";import"./EmptyState-lpUFYfun.js";const $s=["<","<=",">",">=","="],Ls=["priority","created_at","updated_at","status","role"],z="input text-xs py-1",ze="select text-xs py-1",Z="text-text-tertiary hover:text-text-primary transition-colors";function qe(t){return t==="true"?!0:t==="false"?!1:t.trim()!==""&&!Number.isNaN(Number(t))?Number(t):t}const Bs=t=>Object.entries(t??{}).map(([s,l])=>({key:s,value:String(l)})),Rs=t=>(t??[]).map(s=>{const[l,i]=Object.entries(s)[0]??["",""];return{key:l,value:String(i)}});function R({title:t,hint:s,children:l}){return e.jsxs("div",{className:"border-t border-surface-border/50 py-3 first:border-t-0 first:pt-1",children:[e.jsxs("div",{className:"mb-1.5 flex items-baseline justify-between",children:[e.jsx("span",{className:"text-2xs font-medium uppercase tracking-wide text-text-tertiary",children:t}),s&&e.jsx("span",{className:"text-2xs font-mono text-text-tertiary/70",children:s})]}),l]})}function ee({value:t,onChange:s,placeholder:l}){return e.jsx("input",{list:"lt-facet-keys",className:`${z} w-40`,placeholder:l,value:t,onChange:i=>s(i.target.value)})}function zs({value:t,onChange:s,facetKeys:l=[],search:i="",onSearchChange:p}){const m=Bs(t.facets),h=Rs(t.block),d=t.range??[],x=t.exists??[],g=t.orderBy??[],C=r=>{const u={};for(const o of r)o.key&&(u[o.key]=qe(o.value));s({...t,facets:Object.keys(u).length?u:void 0})},S=r=>{const u=r.filter(o=>o.key).map(o=>({[o.key]:qe(o.value)}));s({...t,block:u.length?u:void 0})},P=r=>s({...t,range:r.length?r:void 0}),j=r=>s({...t,exists:r.length?r:void 0}),k=r=>s({...t,orderBy:r.length?r:void 0});return e.jsxs("div",{className:"text-xs",children:[e.jsx("datalist",{id:"lt-facet-keys",children:l.map(r=>e.jsx("option",{value:r},r))}),e.jsxs("datalist",{id:"lt-sort-fields",children:[Ls.map(r=>e.jsx("option",{value:r},r)),l.map(r=>e.jsx("option",{value:`metadata.${r}`},r))]}),p&&e.jsx(R,{title:"Match id",hint:"id · workflow · origin",children:e.jsx("input",{className:`${z} w-full`,placeholder:"Exact escalation, workflow, or origin id…",value:i,onChange:r=>p(r.target.value)})}),e.jsx(R,{title:"Has facet",hint:"metadata @>",children:[...m,{key:"",value:""}].map((r,u)=>e.jsxs("div",{className:"mb-1 flex items-center gap-1",children:[e.jsx(ee,{value:r.key,placeholder:"key",onChange:o=>{const c=[...m];c[u]={...r,key:o},C(c)}}),e.jsx("span",{className:"text-text-tertiary",children:"="}),e.jsx("input",{className:`${z} w-40`,placeholder:"value",value:r.value,onChange:o=>{const c=[...m];c[u]={...r,value:o.target.value},C(c)}}),u<m.length&&e.jsx("button",{className:Z,onClick:()=>C(m.filter((o,c)=>c!==u)),children:"×"})]},u))}),e.jsx(R,{title:"Range",hint:"numeric",children:[...d,{facet:"",op:"<=",value:0}].map((r,u)=>e.jsxs("div",{className:"mb-1 flex items-center gap-1",children:[e.jsx(ee,{value:r.facet,placeholder:"numeric facet",onChange:o=>{const c=[...d];c[u]={...r,facet:o},P(c.filter(a=>a.facet))}}),e.jsx("select",{className:ze,value:r.op,onChange:o=>{const c=[...d];c[u]={...r,op:o.target.value},P(c.filter(a=>a.facet))},children:$s.map(o=>e.jsx("option",{value:o,children:o},o))}),e.jsx("input",{type:"number",className:`${z} w-24`,value:r.value,onChange:o=>{const c=[...d];c[u]={...r,value:Number(o.target.value)},P(c.filter(a=>a.facet))}}),u<d.length&&e.jsx("button",{className:Z,onClick:()=>P(d.filter((o,c)=>c!==u)),children:"×"})]},u))}),e.jsx(R,{title:"Has key",hint:"metadata ? key",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[x.map(r=>e.jsxs("span",{className:"flex items-center gap-1 rounded bg-accent/15 px-1.5 py-0.5 text-accent",children:[r,e.jsx("button",{className:"text-accent/70 hover:text-accent",onClick:()=>j(x.filter(u=>u!==r)),children:"×"})]},r)),e.jsx(ee,{value:"",placeholder:"+ key",onChange:r=>{r&&!x.includes(r)&&j([...x,r])}})]})}),e.jsx(R,{title:"Exclude",hint:"NOT @>",children:[...h,{key:"",value:""}].map((r,u)=>e.jsxs("div",{className:"mb-1 flex items-center gap-1",children:[e.jsx(ee,{value:r.key,placeholder:"key",onChange:o=>{const c=[...h];c[u]={...r,key:o},S(c)}}),e.jsx("span",{className:"text-text-tertiary",children:"="}),e.jsx("input",{className:`${z} w-40`,placeholder:"value",value:r.value,onChange:o=>{const c=[...h];c[u]={...r,value:o.target.value},S(c)}}),u<h.length&&e.jsx("button",{className:Z,onClick:()=>S(h.filter((o,c)=>c!==u)),children:"×"})]},u))}),e.jsx(R,{title:"Sort by",children:[...g,{field:"",direction:"asc"}].map((r,u)=>e.jsxs("div",{className:"mb-1 flex items-center gap-1",children:[e.jsx("input",{list:"lt-sort-fields",className:`${z} w-44`,placeholder:"column or metadata.key",value:r.field,onChange:o=>{const c=[...g];c[u]={...r,field:o.target.value},k(c.filter(a=>a.field))}}),e.jsxs("select",{className:ze,value:r.direction??"asc",onChange:o=>{const c=[...g];c[u]={...r,direction:o.target.value},k(c.filter(a=>a.field))},children:[e.jsx("option",{value:"asc",children:"asc"}),e.jsx("option",{value:"desc",children:"desc"})]}),e.jsxs("label",{className:"flex items-center gap-1 text-text-tertiary",children:[e.jsx("input",{type:"checkbox",checked:!!r.numeric,onChange:o=>{const c=[...g];c[u]={...r,numeric:o.target.checked},k(c.filter(a=>a.field))}}),"num"]}),u<g.length&&e.jsx("button",{className:Z,onClick:()=>k(g.filter((o,c)=>c!==u)),children:"×"})]},u))})]})}function qs({value:t,onChange:s,facetKeys:l,search:i,onSearchChange:p,activeFacetCount:m,onClear:h,onClose:d}){return e.jsxs("div",{className:"h-full overflow-y-auto",children:[e.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-between px-4 py-3 bg-surface-raised border-b border-surface-border/50",children:[e.jsx("span",{className:"text-xs font-semibold text-text-primary",children:"Faceted query"}),e.jsxs("div",{className:"flex items-center gap-2",children:[m>0&&e.jsx("button",{onClick:h,className:"text-2xs text-text-tertiary hover:text-text-primary transition-colors",children:"Clear"}),e.jsx("button",{onClick:d,className:"p-1 rounded hover:bg-surface-hover text-text-tertiary hover:text-text-primary transition-colors",title:"Close",children:e.jsx(te,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"px-4 py-2",children:[e.jsxs("p",{className:"mb-2 text-2xs leading-snug text-text-tertiary",children:["Precise metadata facets plus exact correlation-id lookup — they compose in one SQL query. Facet keys are the ones that actually exist in your visible escalations. Set status to ",e.jsx("span",{className:"font-medium",children:"All"})," to find an order across every status; the whole query is shareable via the URL."]}),e.jsx(zs,{value:t,onChange:s,facetKeys:l,search:i,onSearchChange:p})]})]})}const De="created_at";function xe(t){return t.replace(/^metadata\./,"")}function Ds({orderBy:t,onChange:s}){const l=t==null?void 0:t[0],i=(l==null?void 0:l.field)??De,p=(l==null?void 0:l.direction)??"desc",m=i===De,h=d=>s([{...l??{},field:i,direction:d}]);return e.jsxs("div",{className:"flex items-center gap-1.5",children:[!m&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-accent/25 bg-accent/8 px-2 py-0.5 text-2xs font-medium text-accent/90",children:[e.jsx("span",{className:"text-text-quaternary",children:"sort"}),e.jsx("span",{className:"font-mono max-w-[120px] truncate",title:i,children:xe(i)}),e.jsx("button",{onClick:()=>s(void 0),className:"ml-0.5 -mr-0.5 flex items-center text-text-quaternary hover:text-status-error transition-colors","aria-label":"Reset sort to created date",children:e.jsx(te,{className:"w-2.5 h-2.5"})})]}),e.jsxs("div",{className:"flex items-center rounded overflow-hidden border border-surface-border",role:"radiogroup","aria-label":"Sort direction",children:[e.jsx("button",{type:"button",role:"radio","aria-checked":p==="desc",onClick:()=>h("desc"),className:`px-1.5 py-1 transition-colors ${p==="desc"?"bg-accent text-text-inverse":"icon-link hover:bg-surface-hover"}`,title:m?"Newest first":`${xe(i)} descending`,children:e.jsx(ss,{className:"w-3.5 h-3.5"})}),e.jsx("button",{type:"button",role:"radio","aria-checked":p==="asc",onClick:()=>h("asc"),className:`px-1.5 py-1 border-l border-surface-border transition-colors ${p==="asc"?"bg-accent text-text-inverse":"icon-link hover:bg-surface-hover"}`,title:m?"Oldest first":`${xe(i)} ascending`,children:e.jsx(as,{className:"w-3.5 h-3.5"})})]})]})}const Is=t=>t.isPriorityPending||t.isClaimPending||t.isAssignPending||t.isTriagePending||t.isCancelPending,me="inline-flex items-center h-7 px-2.5 text-2xs font-medium text-text-secondary bg-surface border border-surface-border rounded-[4px] hover:border-accent/50 hover:text-text-primary transition-colors disabled:opacity-50 disabled:hover:border-surface-border",Ie=`${me} appearance-none cursor-pointer`,Us="inline-flex items-center h-7 px-2.5 text-2xs font-medium text-status-error bg-surface border border-status-error/30 rounded-[4px] hover:border-status-error hover:bg-status-error/5 transition-colors disabled:opacity-50";function Vs(t){var d;const s=Is(t),l=he(),{data:i}=At(),p=Tt(),m=p!==null?p:((d=i==null?void 0:i.ai)==null?void 0:d.enabled)===!0,h=t.selectedCount>0;return e.jsx("div",{className:`grid transition-all duration-200 ease-in-out ${h?"grid-rows-[1fr] opacity-100":"grid-rows-[0fr] opacity-0 pointer-events-none"}`,children:e.jsx("div",{className:"overflow-hidden",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-2.5 pl-3 pr-2 mt-4 mb-3 bg-surface-sunken/60 border-l-2 border-l-accent",children:[e.jsxs("span",{className:"text-2xs font-semibold uppercase tracking-wider text-accent tabular-nums",children:[t.selectedCount," selected"]}),e.jsx("div",{className:"mx-1 h-4 w-px bg-surface-border"}),e.jsxs("select",{onChange:x=>{x.target.value&&(t.onSetPriority(parseInt(x.target.value)),x.target.value="")},disabled:s,className:Ie,defaultValue:"",children:[e.jsx("option",{value:"",disabled:!0,children:"Priority…"}),Ps.map(x=>e.jsx("option",{value:x.value,children:x.label},x.value))]}),e.jsxs("select",{onChange:x=>{x.target.value&&(t.onClaim(parseInt(x.target.value)),x.target.value="")},disabled:s,className:Ie,defaultValue:"",children:[e.jsx("option",{value:"",disabled:!0,children:"Claim for…"}),l.map(x=>e.jsx("option",{value:x.value,children:x.label},x.value))]}),e.jsx("button",{onClick:t.onAssign,disabled:s,className:me,children:t.isAssignPending?"Assigning…":"Assign to…"}),m&&e.jsx("button",{onClick:t.onTriage,disabled:s,className:me,children:t.isTriagePending?"Triaging…":"Triage"}),e.jsx("button",{onClick:t.onCancel,disabled:s,className:Us,children:t.isCancelPending?"Cancelling…":"Cancel"}),e.jsx("div",{className:"flex-1"}),s&&e.jsx("span",{className:"text-2xs text-text-tertiary animate-pulse",children:"Processing…"}),e.jsx("button",{onClick:t.onClearSelection,className:"px-1 text-2xs font-medium text-text-tertiary hover:text-text-primary transition-colors",children:"Clear"})]})})})}function Gs({open:t,onClose:s,selectedCount:l,selectedRoles:i,onSubmit:p,isPending:m}){const{isSuperAdmin:h}=Je(),d=he(),[x,g]=f.useState("user"),[C,S]=f.useState(null),[P,j]=f.useState(""),[k,r]=f.useState("30"),[u,o]=f.useState(0),c=f.useCallback(y=>o(y),[]),a=!h&&i.length===1?i[0]:void 0,N=We(P,250),{data:w,isLoading:M}=Ms({role:a,status:"active",search:N.trim()||void 0,limit:200}),A=(w==null?void 0:w.users)??[],T=()=>{g("user"),S(null),j(""),r("30"),o(0),s()},O=y=>{S(y),g("duration")},q=()=>{g("user")},D=()=>{if(!C)return;const y=k==="custom"?u:parseInt(k);!y||y<=0||p(C.id,y)};return e.jsx(pe,{open:t,onClose:T,title:"Assign Escalations",children:e.jsxs("div",{className:"space-y-4",children:[x==="user"&&e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-sm text-text-secondary",children:["Select a user to assign"," ",e.jsx("span",{className:"font-medium text-text-primary",children:l})," ","escalation(s) to:"]}),e.jsx("input",{type:"text",value:P,onChange:y=>j(y.target.value),placeholder:"Search by name or email...",className:"input text-xs w-full",autoFocus:!0}),e.jsxs("div",{className:"max-h-60 overflow-y-auto border border-surface-border rounded-lg divide-y divide-surface-border",children:[M&&e.jsx("p",{className:"text-xs text-text-tertiary p-3",children:"Loading users..."}),!M&&A.length===0&&e.jsx("p",{className:"text-xs text-text-tertiary p-3",children:"No users found"}),A.map(y=>e.jsxs("button",{onClick:()=>O(y),className:"w-full text-left px-3 py-2 hover:bg-surface-hover transition-colors",children:[e.jsx("p",{className:"text-xs font-medium text-text-primary",children:y.display_name||y.external_id}),y.email&&e.jsx("p",{className:"text-2xs text-text-tertiary",children:y.email})]},y.id))]}),e.jsx("div",{className:"flex justify-end pt-2",children:e.jsx("button",{onClick:T,className:"btn-secondary text-xs",children:"Cancel"})})]}),x==="duration"&&C&&e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-sm text-text-secondary",children:["Assign to"," ",e.jsx("span",{className:"font-medium text-text-primary",children:C.display_name||C.external_id})," ","for:"]}),e.jsxs("select",{value:k,onChange:y=>{r(y.target.value),o(0)},className:"select w-full text-sm",children:[d.map(y=>e.jsx("option",{value:y.value,children:y.label},y.value)),e.jsx("option",{value:"custom",children:"Other..."})]}),k==="custom"&&e.jsx(Ke,{onChange:c,autoFocus:!0}),e.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[e.jsx("button",{onClick:q,className:"btn-secondary text-xs",children:"Back"}),e.jsx("button",{onClick:D,disabled:m,className:"btn-primary text-xs",children:m?"Assigning...":"Assign"})]})]})]})})}function Hs({open:t,onClose:s,selectedCount:l,onSubmit:i,isPending:p}){const[m,h]=f.useState(""),d=()=>{i(m||void 0)};return e.jsx(pe,{open:t,onClose:s,title:"Submit for AI Triage",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-text-secondary",children:["Submit ",e.jsx("span",{className:"font-medium text-text-primary",children:l})," escalation(s) for AI triage? The triage orchestrator will take over resolution."]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-xs font-medium text-text-secondary block mb-1",children:["Triage hint ",e.jsx("span",{className:"text-text-tertiary",children:"(optional)"})]}),e.jsx("input",{type:"text",value:m,onChange:x=>h(x.target.value),placeholder:"e.g., image_orientation",className:"input text-xs font-mono w-full"}),e.jsx("p",{className:"text-2xs text-text-tertiary mt-1",children:"Guides the triage workflow on what remediation to apply"})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[e.jsx("button",{onClick:s,className:"btn-secondary text-xs",children:"Cancel"}),e.jsx("button",{onClick:d,disabled:p,className:"btn-primary text-xs",children:p?"Submitting...":"Submit for Triage"})]})]})})}function V(t,s,l){return i=>{t.mutate(i,{onSuccess:()=>{s(),l==null||l()}})}}function Qs(t){const s=()=>[...t.selectedIds];return{handleSetPriority:d=>{V(t.setPriority,t.clearSelection)({ids:s(),priority:d})},handleBulkClaim:d=>{V(t.bulkClaim,t.clearSelection)({ids:s(),durationMinutes:d})},handleBulkTriage:d=>{V(t.bulkTriage,t.clearSelection,t.closeTriageModal)({ids:s(),hint:d})},handleBulkAssign:(d,x)=>{V(t.bulkAssign,t.clearSelection,t.closeAssignModal)({ids:s(),targetUserId:d,durationMinutes:x})},handleBulkCancel:()=>{V(t.bulkCancel,t.clearSelection,t.closeCancelModal)({ids:s()})}}}function Js({claimTarget:t,onClose:s,claimDuration:l,onDurationChange:i,claimDurations:p,onCustomClaimChange:m,onClaim:h,isPending:d}){return e.jsx(pe,{open:!!t,onClose:s,title:"Claim Escalation",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-text-secondary",children:["Claim ",e.jsx("span",{className:"font-medium text-text-primary",children:t==null?void 0:t.type})," for:"]}),e.jsxs("select",{value:l,onChange:x=>{i(x.target.value)},className:"select w-full text-sm",children:[p.map(x=>e.jsx("option",{value:x.value,children:x.label},x.value)),e.jsx("option",{value:"custom",children:"Other..."})]}),l==="custom"&&e.jsx(Ke,{onChange:m,autoFocus:!0}),e.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[e.jsx("button",{onClick:s,className:"btn-secondary text-xs",children:"Cancel"}),e.jsx("button",{onClick:h,className:"btn-primary text-xs",disabled:d,children:d?"Claiming...":"Claim"})]})]})})}const Xe={pending:"--lt-status-queued-graphic",claimed:"--lt-status-claimed-graphic",resolved:"--lt-status-success-graphic",cancelled:"--lt-text-quaternary",expired:"--lt-text-tertiary"},Ye="--lt-text-quaternary";function Ks(t){return Xe[t]??Ye}const G=Object.fromEntries(Object.entries(Xe).map(([t,s])=>[t,`rgb(var(${s}))`])),Ue=40,Ws=64,Xs=24,Ve=3;function Ze(t){return t<6e4?`${Math.round(t/1e3)}s`:t<36e5?`${Math.round(t/6e4)}m`:t<864e5?`${(t/36e5).toFixed(1)}h`:`${(t/864e5).toFixed(1)}d`}function Ge(t){const s=Date.now()-t;return s<6e4?"just now":s<36e5?`${Math.round(s/6e4)}m ago`:s<864e5?`${Math.round(s/36e5)}h ago`:`${Math.round(s/864e5)}d ago`}function He(t){return t.replace(/-/g," ").replace(/\b\w/g,s=>s.toUpperCase())}function Ys(t,s){return t?[...s.filter(i=>i in t),...Object.keys(t).filter(i=>!s.includes(i))].map(i=>[i,t[i]]):[]}function Zs({e:t}){const s=t.endMs-t.startMs;if(s<=0)return null;const l=G.pending,i=G.claimed,p=t.status==="cancelled"||t.status==="expired"?G.cancelled:G.resolved;let m=100,h=0,d=0;return t.claimedMs!==null?(m=Math.max(0,Math.min(100,(t.claimedMs-t.startMs)/s*100)),t.isOpen?h=100-m:(h=Math.max(0,Math.min(100-m,(t.endMs-t.claimedMs)/s*100)),d=Math.max(0,100-m-h))):t.isOpen||(d=100,m=0),e.jsxs("div",{className:"mt-2 h-0.5 rounded-full overflow-hidden flex bg-surface-sunken",children:[m>0&&e.jsx("div",{style:{width:`${m}%`,backgroundColor:l,opacity:.6}}),h>0&&e.jsx("div",{style:{width:`${h}%`,backgroundColor:i,opacity:.6}}),d>0&&e.jsx("div",{style:{width:`${d}%`,backgroundColor:p,opacity:.6}})]})}function ea({gapMs:t,heightPx:s}){return e.jsx("div",{className:"relative flex items-center justify-center",style:{height:s},children:t>=6e4&&e.jsx("span",{className:"text-2xs text-text-quaternary font-mono bg-surface px-2 relative z-10",children:Ze(t)})})}function Qe({e:t,highlightKeys:s,onRowClick:l}){const[i,p]=f.useState(!1),m=G[t.displayStatus]??`rgb(var(${Ye}))`,h=Ys(t.metadata,s),d=i?h:h.slice(0,Ve),x=h.length-Ve;return e.jsxs("div",{className:"cursor-pointer max-w-[460px] min-w-[260px] w-full bg-surface-raised rounded-lg shadow-sm border border-surface-border/60 px-3.5 pt-2.5 pb-2 hover:shadow-md hover:border-surface-border transition-all duration-150",style:{borderTopWidth:"3px",borderTopColor:m},onClick:()=>l==null?void 0:l(t),children:[e.jsxs("div",{className:"flex items-baseline gap-2 mb-1.5",children:[e.jsx("span",{className:"text-2xs font-bold uppercase tracking-widest text-text-quaternary shrink-0",children:He(t.role)}),e.jsxs("span",{className:"text-xs font-semibold text-text-primary truncate",title:t.type,children:[t.type,t.subtype&&t.subtype!==t.type&&t.subtype!==""&&e.jsxs("span",{className:"font-normal text-text-tertiary",children:[" · ",t.subtype]})]})]}),d.length>0&&e.jsxs("div",{className:"border-t border-surface-border/40 pt-1 space-y-px",children:[d.map(([g,C])=>{const S=String(C),P=s.includes(g);return e.jsxs("div",{className:"group/row flex items-center gap-1.5 -mx-1 px-1 py-[2px] rounded",children:[e.jsx("span",{className:`shrink-0 w-[60px] text-2xs font-mono uppercase tracking-wide truncate ${P?"text-accent":"text-text-quaternary"}`,title:g,children:g}),e.jsx("span",{className:`flex-1 min-w-0 text-2xs font-medium truncate ${P?"text-text-primary":"text-text-tertiary"}`,title:S,children:S}),e.jsxs("span",{className:"flex items-center gap-px shrink-0 opacity-0 group-hover/row:opacity-100 transition-opacity",children:[e.jsx(Re,{to:Le(g,C,t.role),className:"p-0.5 rounded text-text-quaternary hover:text-accent transition-colors",title:`Filter ${He(t.role)}: ${g} = ${S}`,onClick:j=>j.stopPropagation(),children:e.jsx(is,{className:"w-2.5 h-2.5"})}),e.jsx(Re,{to:Le(g,C),className:"p-0.5 rounded text-text-quaternary hover:text-accent transition-colors",title:`Search all: ${g} = ${S}`,onClick:j=>j.stopPropagation(),children:e.jsx(ls,{className:"w-2.5 h-2.5"})})]})]},g)}),x>0&&e.jsx("button",{className:"flex items-center gap-0.5 text-2xs text-text-quaternary hover:text-accent transition-colors mt-0.5 -mx-1 px-1 py-px",onClick:g=>{g.stopPropagation(),p(C=>!C)},children:i?e.jsxs(e.Fragment,{children:[e.jsx(os,{className:"w-2.5 h-2.5"})," less"]}):e.jsxs(e.Fragment,{children:[e.jsx(cs,{className:"w-2.5 h-2.5"})," ",x," more"]})})]}),e.jsx(Zs,{e:t})]})}function ta({escalations:t,highlightKeys:s=[],onRowClick:l,total:i,page:p,totalPages:m,onPageChange:h}){var o,c;const d=Date.now(),g=t.map(a=>{const N=new Date(a.created_at).getTime(),w=a.resolved_at?new Date(a.resolved_at).getTime():null,M=a.claimed_at?new Date(a.claimed_at).getTime():null,A=!w&&a.status!=="cancelled"&&a.status!=="expired",T=w??(A?d:N+3e4),O=a.status==="pending"&&vs(a)?"claimed":a.status;return{...a,startMs:N,claimedMs:M,endMs:T,isOpen:A,displayStatus:O}});if(g.length===0)return e.jsx("p",{className:"mt-12 text-center text-sm text-text-tertiary",children:"No escalations matched."});const C=g.length,P=Math.max(Math.abs((((o=g[C-1])==null?void 0:o.startMs)??0)-(((c=g[0])==null?void 0:c.startMs)??0)),1)/Math.max(C-1,1),j=Ws/Math.max(P,1),r=new Set(g.map(a=>new Date(a.startMs).toDateString())).size>1;function u(a){const N=new Date(a),w=N.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return r?N.toLocaleDateString([],{month:"short",day:"numeric"})+" "+w:w}return e.jsxs("div",{className:"mt-4 pb-24",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute left-1/2 -translate-x-px inset-y-0 w-px bg-surface-border/80"}),g.map((a,N)=>{const w=g[N-1],M=w?Math.abs(a.startMs-w.startMs):null,A=M!==null?Math.max(Xs,Math.round(M*j)):0,T=N%2===0,O=Ks(a.displayStatus),q=`rgb(var(${O}))`,D=a.endMs-a.startMs,y=a.isOpen?Ge(a.startMs):`${Ge(a.startMs)} · ${Ze(D)}`;return e.jsxs("div",{children:[N>0&&e.jsx(ea,{gapMs:M,heightPx:A}),e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"flex-1 flex justify-end items-center",children:T?e.jsxs("div",{className:"flex items-center",children:[e.jsx(Qe,{e:a,highlightKeys:s,onRowClick:l}),e.jsx("div",{className:"flex-shrink-0 h-px bg-surface-border/70",style:{width:Ue}})]}):e.jsx("span",{className:"text-2xs text-text-quaternary font-mono tabular-nums pr-3",children:y})}),e.jsx("div",{className:"relative z-10 flex-shrink-0 w-3.5 h-3.5 rounded-full border-2 border-surface cursor-pointer transition-all duration-150 hover:scale-[1.5]",style:{backgroundColor:q,boxShadow:`0 0 0 3px rgb(var(${O}) / 0.16), 0 1px 3px rgb(var(${O}) / 0.19)`},onClick:()=>l==null?void 0:l(a)}),e.jsx("div",{className:"flex-1 flex justify-start items-center",children:T?e.jsx("span",{className:"text-2xs text-text-quaternary font-mono tabular-nums pl-3",children:y}):e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"flex-shrink-0 h-px bg-surface-border/70",style:{width:Ue}}),e.jsx(Qe,{e:a,highlightKeys:s,onRowClick:l})]})})]}),e.jsx("div",{className:"flex justify-center relative z-10 mt-0.5",children:e.jsx("span",{className:"text-2xs text-text-quaternary font-mono tabular-nums bg-surface px-1.5",children:u(a.startMs)})})]},a.id)})]}),m>1&&e.jsxs("div",{className:"sticky bottom-0 z-20 bg-surface/95 backdrop-blur-sm border-t border-surface-border -mx-page-x px-page-x pt-2 pb-4 flex items-center justify-between mt-10",children:[e.jsxs("span",{className:"text-2xs text-text-tertiary",children:["Page ",e.jsx("span",{className:"font-medium text-text-secondary",children:p})," ","of ",e.jsx("span",{className:"font-medium text-text-secondary",children:m})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>h(p-1),disabled:p<=1,className:"p-1.5 rounded hover:bg-surface-hover disabled:opacity-30 text-text-tertiary hover:text-text-primary transition-colors disabled:cursor-not-allowed",children:e.jsx(ns,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>h(p+1),disabled:p>=m,className:"p-1.5 rounded hover:bg-surface-hover disabled:opacity-30 text-text-tertiary hover:text-text-primary transition-colors disabled:cursor-not-allowed",children:e.jsx(rs,{className:"w-4 h-4"})})]})]})]})}function Aa(){var Ae,Te,Oe,Ee,Fe,_e,$e;const t=Es(),{filters:s,setFilter:l,pagination:i}=Cs({filters:{role:"",type:"",priority:"",status:"available",search:""}});ts({role:s.role||null,verbs:["created","claimed"]});const p=We(s.search,300),m=he(),[h,d]=f.useState(null),[x,g]=f.useState("30"),[C,S]=f.useState(0),P=f.useCallback(n=>S(n),[]),[j,k]=f.useState(new Set),[r,u]=f.useState(!1),[o,c]=Fs(),a=f.useMemo(()=>Ot(o),[o]),N=f.useCallback(n=>{c(b=>{const v=new URLSearchParams(b);return Et(v,n),v.delete("page"),v})},[c]),{data:w}=Ft(r),M=_t(a)+(s.search?1:0),A="facet-query",{setPanel:T,closePanel:O,open:q,ownerKey:D}=$t();f.useEffect(()=>{if(!r){O(A);return}T(e.jsx(qs,{value:a,onChange:N,facetKeys:(w==null?void 0:w.keys)??[],search:s.search??"",onSearchChange:n=>l("search",n),activeFacetCount:M,onClear:()=>{N({}),l("search","")},onClose:()=>u(!1)}),{width:420,key:A})},[r,a,N,w,s.search,l,M,T,O]);const y=q&&D===A,se=f.useRef(!1);f.useEffect(()=>{if(y){se.current=!0;return}se.current&&(se.current=!1,u(!1))},[y]);const[et,ae]=f.useState(!1),[tt,ne]=f.useState(!1),[st,re]=f.useState(!1),at=f.useCallback(n=>N({...a,orderBy:n}),[a,N]),H=_s(),{data:Q}=Lt(),fe=Bt(),nt=f.useCallback(()=>{var v;const n=window.prompt("Pin label:");if(!(n!=null&&n.trim()))return;const b=((v=Q==null?void 0:Q.preferences)==null?void 0:v.pinnedViews)??[];fe.mutate({pinnedViews:[...b,{id:Rt(),label:n.trim(),url:H.pathname+H.search,badge:!0}]})},[H.pathname,H.search,Q,fe]),{canBulk:rt}=zt(),ge=a.facets?Object.keys(a.facets):[],ie=o.get("view"),be=f.useCallback(n=>{c(b=>{const v=new URLSearchParams(b);return n?v.set("view",n):v.delete("view"),v},{replace:!0})},[c]),_=ie==="timeline",it=f.useCallback(n=>{const{[n]:b,...v}=a.facets??{};N({...a,facets:Object.keys(v).length>0?v:void 0})},[a,N]),ye=qt(),je=Dt(),ve=It(),le=Ut(),oe=Vt(),J=Gt(),{data:ce}=Ht(),{data:$}=Qt(),{data:de}=Jt(),{user:K,isSuperAdmin:lt,hasRoleType:ot}=Je(),Ne=lt||ot("admin"),Ce=f.useMemo(()=>new Set(((K==null?void 0:K.roles)??[]).map(n=>n.role)),[K]),ct=f.useMemo(()=>{const n=($==null?void 0:$.roles)??[];return(Ne?n:n.filter(v=>Ce.has(v.role)&&!es(v.role))).map(v=>({value:v.role,label:Kt(v)})).sort((v,Mt)=>v.label.localeCompare(Mt.label))},[$,Ne,Ce]);f.useEffect(()=>{k(new Set)},[s.role,s.type,s.priority,s.status,p,i.page,i.pageSize]);const I=s.status||"",U=I==="available",ue=I==="claimed",ke=ue?"pending":I==="resolved"?"resolved":I==="cancelled"?"cancelled":I==="expired"?"expired":void 0,we=100,Se={role:s.role||void 0,type:s.type||void 0,priority:s.priority?parseInt(s.priority):void 0,limit:_?we:i.pageSize,offset:i.offset,sort_by:"created_at",order:"desc",search:p||void 0,...a},dt=Wt({...Se,enabled:U}),ut=Xt({status:ke,claimed:ue||void 0,...Se,enabled:!U}),xt=U?dt:ut,{data:B,isLoading:mt,error:W,refetch:ht,isFetching:pt}=xt,ft=ks(`/escalations${U?"/available":""}`,{status:ke,claimed:ue||void 0,role:s.role||void 0,type:s.type||void 0,priority:s.priority||void 0,search:p||void 0,sort_by:"created_at",order:"desc",limit:i.pageSize,offset:i.offset,facets:a.facets&&Object.keys(a.facets).length?JSON.stringify(a.facets):void 0,block:(Ae=a.block)!=null&&Ae.length?JSON.stringify(a.block):void 0,range:(Te=a.range)!=null&&Te.length?JSON.stringify(a.range):void 0,exists:(Oe=a.exists)!=null&&Oe.length?JSON.stringify(a.exists):void 0,roles:(Ee=a.roles)!=null&&Ee.length?JSON.stringify(a.roles):void 0,orderBy:(Fe=a.orderBy)!=null&&Fe.length?JSON.stringify(a.orderBy):void 0,available:a.available!=null?String(a.available):void 0}),F=(B==null?void 0:B.escalations)??[],E=(B==null?void 0:B.total)??0,L=s.role||(((_e=a.roles)==null?void 0:_e.length)===1?a.roles[0]:null),X=(($e=Yt(L??"",void 0,!!L).data)==null?void 0:$e.list_schema)??null,Pe=!!L&&!!X&&!!X["x-lt-layout"]&&X["x-lt-layout"]!=="table",Y=Pe&&!_&&(ie?ie==="rich":!0),Me=f.useMemo(()=>{if(!a.jeopardy||!L)return null;const n=(($==null?void 0:$.roles)??[]).find(v=>v.role===L),b=(n==null?void 0:n.priority_threshold_minutes)??(n==null?void 0:n.sla_minutes)??null;return b!=null?Zt(b*6e4):null},[a.jeopardy,L,$]),gt=f.useMemo(()=>{const n=new Set;for(const b of F)j.has(b.id)&&n.add(b.role);return[...n]},[F,j]),bt=f.useCallback(()=>k(new Set),[]),yt=()=>{if(!h)return;const n=x==="custom"?C:parseInt(x);!n||n<=0||ye.mutate({id:h.id,durationMinutes:n},{onSuccess:()=>{d(null),t(`/escalations/detail/${h.id}`)}})},{handleSetPriority:jt,handleBulkClaim:vt,handleBulkTriage:Nt,handleBulkAssign:Ct,handleBulkCancel:kt}=Qs({selectedIds:j,clearSelection:bt,setPriority:je,bulkClaim:ve,bulkTriage:oe,bulkAssign:le,bulkCancel:J,closeTriageModal:()=>ae(!1),closeAssignModal:()=>ne(!1),closeCancelModal:()=>re(!1)}),wt=n=>{const b=new Set(j);b.has(n)?b.delete(n):b.add(n),k(b)},St=()=>{j.size===F.length?k(new Set):k(new Set(F.map(n=>n.id)))},Pt=[rt?{key:"select",label:e.jsx("input",{type:"checkbox",checked:F.length>0&&j.size===F.length,onChange:St,className:"rounded"}),render:n=>e.jsx("input",{type:"checkbox",checked:j.has(n.id),onChange:b=>{b.stopPropagation(),wt(n.id)},onClick:b=>b.stopPropagation(),className:"rounded"}),className:"w-10",priority:1}:{key:"spacer",label:"",render:()=>null,className:"w-10",priority:3},...bs({highlightKeys:ge}),{key:"actions",label:"",render:n=>e.jsx(As,{children:e.jsx(Ts,{icon:ds,title:"Claim escalation",onClick:()=>d(n),alwaysVisible:!0,colorClass:"text-accent/40 hover:text-accent",size:"sm"})}),className:"w-10 text-right"}];return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-10 min-w-0",children:[e.jsx(ys,{role:s.role,options:ct,onChange:n=>l("role",n)}),e.jsx("button",{onClick:()=>{window.location.hash="#docs:dashboard.md:all-escalations"},className:"text-text-quaternary hover:text-accent transition-colors mt-1 shrink-0",title:"Open docs for this page",children:e.jsx(us,{className:"w-4 h-4",strokeWidth:1.5})})]}),e.jsx(js,{filters:s,setFilter:l,roles:(ce==null?void 0:ce.roles)??[],types:(de==null?void 0:de.types)??[],showStatus:!0,showSearch:!1,actions:e.jsxs(e.Fragment,{children:[_&&e.jsxs("span",{className:"text-2xs text-text-tertiary whitespace-nowrap",children:[E>100&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"font-medium text-text-secondary",children:[(i.page-1)*100+1,"–",Math.min(i.page*100,E)]})," of "]}),e.jsx("span",{className:"font-medium text-text-secondary",children:E})," ",E===1?"escalation":"escalations"]}),e.jsx(Ds,{orderBy:a.orderBy,onChange:at}),e.jsx("span",{className:"h-3.5 w-px bg-surface-border shrink-0"}),e.jsx(Os,{onRefresh:()=>ht(),isFetching:pt,apiPath:ft}),Pe&&!_&&e.jsx("button",{onClick:()=>be(Y?"table":"rich"),className:"ml-2 inline-flex h-7 w-7 items-center justify-center rounded icon-link hover:bg-surface-hover",title:Y?"Table view":"Rich view",children:Y?e.jsx(Be,{className:"w-4 h-4"}):e.jsx(xs,{className:"w-4 h-4"})}),M>0&&e.jsx("button",{onClick:()=>be(_?"table":"timeline"),className:"ml-2 inline-flex h-7 w-7 items-center justify-center rounded icon-link hover:bg-surface-hover",title:_?"Table view":"Timeline view",children:_?e.jsx(Be,{className:"w-4 h-4"}):e.jsx(ms,{className:"w-4 h-4"})}),e.jsx("button",{onClick:nt,className:"ml-2 inline-flex h-7 w-7 items-center justify-center rounded icon-link hover:bg-surface-hover",title:"Pin this view — save the current filters to your Pinned section","data-testid":"pin-current-view",children:e.jsx(hs,{className:"w-4 h-4"})}),e.jsxs("button",{onClick:()=>u(n=>!n),className:"relative ml-2 inline-flex h-7 w-7 items-center justify-center rounded icon-link hover:bg-surface-hover",title:"Faceted query",children:[e.jsx(ps,{className:"w-4 h-4"}),M>0&&e.jsx("span",{className:"absolute -right-1 -top-1 flex h-3.5 min-w-[14px] items-center justify-center rounded-full bg-accent px-0.5 text-2xs font-medium text-text-inverse",children:M})]})]})}),e.jsx(Vs,{selectedCount:j.size,onClearSelection:()=>k(new Set),onSetPriority:jt,onClaim:vt,onAssign:()=>ne(!0),onTriage:()=>ae(!0),onCancel:()=>re(!0),isPriorityPending:je.isPending,isClaimPending:ve.isPending,isAssignPending:le.isPending,isTriagePending:oe.isPending,isCancelPending:J.isPending}),(a.facets&&Object.keys(a.facets).length>0||a.jeopardy)&&e.jsxs("div",{className:"sticky top-14 z-30 bg-surface/98 backdrop-blur-sm border-b border-surface-border/30 -mx-page-x px-page-x py-2 flex items-center gap-1.5 flex-wrap",children:[a.jeopardy&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-status-error px-2.5 py-0.5 text-2xs font-semibold text-text-inverse",children:[e.jsx(fs,{className:"w-2.5 h-2.5",strokeWidth:2.5}),"in jeopardy",Me&&e.jsxs("span",{className:"font-mono font-normal opacity-90",children:["> ",Me]}),e.jsx("button",{onClick:()=>N({...a,jeopardy:void 0}),className:"ml-0.5 -mr-0.5 flex items-center text-text-inverse/70 hover:text-text-inverse transition-colors","aria-label":"Clear jeopardy filter",children:e.jsx(te,{className:"w-2.5 h-2.5"})})]}),Object.entries(a.facets??{}).map(([n,b])=>e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-accent/25 bg-accent/8 px-2.5 py-0.5 text-2xs font-medium text-accent/90",children:[e.jsx("span",{className:"font-mono text-text-tertiary",children:n}),e.jsx("span",{className:"text-text-quaternary",children:"="}),e.jsx("span",{className:"font-mono max-w-[160px] truncate",title:String(b),children:String(b)}),e.jsx("button",{onClick:()=>it(n),className:"ml-0.5 -mr-0.5 flex items-center text-text-quaternary hover:text-status-error transition-colors","aria-label":`Remove ${n} filter`,children:e.jsx(te,{className:"w-2.5 h-2.5"})})]},n)),Object.keys(a.facets??{}).length>1&&e.jsx("button",{onClick:()=>N({...a,facets:void 0}),className:"text-2xs text-text-quaternary hover:text-text-secondary transition-colors px-1",children:"clear all"})]}),W&&e.jsx("div",{className:"mb-4 px-4 py-3 rounded-md bg-status-error/10 border border-status-error/20 text-xs text-status-error",children:W.message==="Session expired"?"Your session has expired. Please log in again.":`Failed to load escalations: ${W.message}`}),_?e.jsx(ta,{escalations:F,highlightKeys:ge,onRowClick:n=>t(`/escalations/detail/${n.id}`,{state:{from:"/escalations/available"}}),total:E,page:i.page,totalPages:Math.ceil(E/we),onPageChange:i.setPage}):Y?e.jsx(Ns,{role:L,listSchema:X,activeEscalations:F,onRowClick:n=>t(`/escalations/detail/${n.id}`,{state:{from:"/escalations/available"}}),onOpenGroup:n=>t(n),onAddFacet:(n,b)=>N({...a,facets:{...a.facets??{},[n]:typeof b=="object"&&b!==null?JSON.stringify(b):b}}),total:E,page:i.page,totalPages:i.totalPages(E),pageSize:i.pageSize,onPageChange:i.setPage,onPageSizeChange:i.setPageSize}):e.jsxs(e.Fragment,{children:[e.jsx(ws,{columns:Pt,data:F,layout:"fixed",keyFn:n=>n.id,onRowClick:n=>t(`/escalations/detail/${n.id}`,{state:{from:"/escalations/available"}}),isLoading:mt,emptyMessage:W?"Unable to load data":"No escalations"}),e.jsx(Ss,{page:i.page,totalPages:i.totalPages(E),onPageChange:i.setPage,total:E,pageSize:i.pageSize,onPageSizeChange:i.setPageSize})]}),e.jsx(Js,{claimTarget:h,onClose:()=>d(null),claimDuration:x,onDurationChange:n=>{g(n),S(0)},claimDurations:m,customClaimMinutes:C,onCustomClaimChange:P,onClaim:yt,isPending:ye.isPending}),e.jsx(Hs,{open:et,onClose:()=>ae(!1),selectedCount:j.size,onSubmit:Nt,isPending:oe.isPending}),e.jsx(Gs,{open:tt,onClose:()=>ne(!1),selectedCount:j.size,selectedRoles:gt,onSubmit:Ct,isPending:le.isPending}),e.jsx(gs,{open:st,onClose:()=>re(!1),onConfirm:kt,selectedCount:j.size,isPending:J.isPending,error:J.error})]})}export{Aa as AvailableEscalationsPage};
2
- //# sourceMappingURL=AvailableEscalationsPage-tL3mM1RG.js.map