@hotmeshio/long-tail 0.22.2 → 0.22.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (255) hide show
  1. package/build/api/escalations/lookups.d.ts +9 -2
  2. package/build/api/escalations/lookups.js +15 -3
  3. package/build/api/escalations/metadata.d.ts +2 -0
  4. package/build/api/escalations/metadata.js +9 -0
  5. package/build/api/scan-codes/locate.js +4 -0
  6. package/build/api/scan-codes/present.d.ts +1 -1
  7. package/build/api/scan-codes/present.js +43 -0
  8. package/build/api/scan-codes/verb-accumulate.js +5 -1
  9. package/build/api/scan-codes/verb-fill.js +4 -1
  10. package/build/api/scan-codes/verb-into-subject.d.ts +12 -0
  11. package/build/api/scan-codes/verb-into-subject.js +157 -0
  12. package/build/api/scan-codes/verbs-subject.d.ts +23 -4
  13. package/build/api/scan-codes/verbs-subject.js +32 -55
  14. package/build/api/scan-codes/verbs.d.ts +10 -8
  15. package/build/api/scan-codes/verbs.js +25 -16
  16. package/build/index.d.ts +1 -1
  17. package/build/index.js +3 -2
  18. package/build/sdk/index.d.ts +1 -0
  19. package/build/services/escalation/claim-asserted.d.ts +10 -0
  20. package/build/services/escalation/claim-asserted.js +64 -0
  21. package/build/services/escalation/facets.d.ts +3 -1
  22. package/build/services/escalation/facets.js +7 -3
  23. package/build/services/escalation/index.d.ts +1 -0
  24. package/build/services/escalation/index.js +3 -1
  25. package/build/services/knowledge/lookup-cache.d.ts +16 -4
  26. package/build/services/knowledge/lookup-cache.js +53 -20
  27. package/build/services/knowledge/lookup-refs.d.ts +3 -2
  28. package/build/services/knowledge/lookup-refs.js +6 -4
  29. package/build/services/knowledge/sql.d.ts +2 -0
  30. package/build/services/knowledge/sql.js +9 -1
  31. package/build/services/mcp/server-tools.js +1 -1
  32. package/build/services/orchestrator/condition.d.ts +13 -10
  33. package/build/services/orchestrator/condition.js +8 -6
  34. package/build/services/scan-code/index.d.ts +1 -1
  35. package/build/services/scan-code/index.js +2 -1
  36. package/build/services/scan-code/validate-facts.d.ts +5 -0
  37. package/build/services/scan-code/validate-facts.js +24 -0
  38. package/build/services/scan-code/validate-query.d.ts +8 -0
  39. package/build/services/scan-code/validate-query.js +36 -0
  40. package/build/services/scan-code/validate-subject.js +29 -2
  41. package/build/services/scan-code/validate.js +17 -8
  42. package/build/shared/scan-code/gtin.d.ts +6 -0
  43. package/build/shared/scan-code/gtin.js +13 -0
  44. package/build/shared/scan-code/index.d.ts +1 -1
  45. package/build/shared/scan-code/index.js +2 -1
  46. package/build/system/mcp-servers/admin/schemas.d.ts +185 -5
  47. package/build/system/mcp-servers/admin/schemas.js +16 -3
  48. package/build/system/seed/tool-manifests-admin.d.ts +202 -1
  49. package/build/system/seed/tool-manifests-admin.js +2 -2
  50. package/build/tsconfig.tsbuildinfo +1 -1
  51. package/build/types/escalation.d.ts +14 -8
  52. package/build/types/escalation.js +16 -7
  53. package/build/types/index.d.ts +3 -3
  54. package/build/types/index.js +3 -1
  55. package/build/types/scan-code/response.d.ts +5 -0
  56. package/build/types/scan-code/rule.d.ts +32 -2
  57. package/dashboard/dist/assets/{AdminDashboard-DBW12qQt.js → AdminDashboard-hI5-kKpL.js} +2 -2
  58. package/dashboard/dist/assets/{AdminDashboard-DBW12qQt.js.map → AdminDashboard-hI5-kKpL.js.map} +1 -1
  59. package/dashboard/dist/assets/{AgentConfigPage-CmHv8U9M.js → AgentConfigPage-DetU4HZe.js} +2 -2
  60. package/dashboard/dist/assets/{AgentConfigPage-CmHv8U9M.js.map → AgentConfigPage-DetU4HZe.js.map} +1 -1
  61. package/dashboard/dist/assets/{AgentDetailPage-D1scIbz-.js → AgentDetailPage-DrGXo8KQ.js} +2 -2
  62. package/dashboard/dist/assets/{AgentDetailPage-D1scIbz-.js.map → AgentDetailPage-DrGXo8KQ.js.map} +1 -1
  63. package/dashboard/dist/assets/{AgentsPage-BA_ai9HJ.js → AgentsPage-D4md5BzM.js} +2 -2
  64. package/dashboard/dist/assets/{AgentsPage-BA_ai9HJ.js.map → AgentsPage-D4md5BzM.js.map} +1 -1
  65. package/dashboard/dist/assets/{AvailableEscalationsPage-C2_5aEFW.js → AvailableEscalationsPage-B2bS2ZJy.js} +2 -2
  66. package/dashboard/dist/assets/{AvailableEscalationsPage-C2_5aEFW.js.map → AvailableEscalationsPage-B2bS2ZJy.js.map} +1 -1
  67. package/dashboard/dist/assets/{BotPicker-BZo4Kp4a.js → BotPicker-BXtey255.js} +2 -2
  68. package/dashboard/dist/assets/{BotPicker-BZo4Kp4a.js.map → BotPicker-BXtey255.js.map} +1 -1
  69. package/dashboard/dist/assets/{BulkAssignModal-BFhyxY2T.js → BulkAssignModal-CSL_PeZv.js} +2 -2
  70. package/dashboard/dist/assets/{BulkAssignModal-BFhyxY2T.js.map → BulkAssignModal-CSL_PeZv.js.map} +1 -1
  71. package/dashboard/dist/assets/{CapabilitiesPage-CvOX6vAc.js → CapabilitiesPage-5scufTHW.js} +2 -2
  72. package/dashboard/dist/assets/{CapabilitiesPage-CvOX6vAc.js.map → CapabilitiesPage-5scufTHW.js.map} +1 -1
  73. package/dashboard/dist/assets/{CollapsibleSection-GCJsV9Oq.js → CollapsibleSection-DjjDGxP_.js} +2 -2
  74. package/dashboard/dist/assets/{CollapsibleSection-GCJsV9Oq.js.map → CollapsibleSection-DjjDGxP_.js.map} +1 -1
  75. package/dashboard/dist/assets/{ConfirmDeleteModal-CAgYLcef.js → ConfirmDeleteModal-DJSmsHQM.js} +2 -2
  76. package/dashboard/dist/assets/{ConfirmDeleteModal-CAgYLcef.js.map → ConfirmDeleteModal-DJSmsHQM.js.map} +1 -1
  77. package/dashboard/dist/assets/{CountdownTimer-Dik2z0M_.js → CountdownTimer-C5ZRYPfF.js} +2 -2
  78. package/dashboard/dist/assets/{CountdownTimer-Dik2z0M_.js.map → CountdownTimer-C5ZRYPfF.js.map} +1 -1
  79. package/dashboard/dist/assets/{CredentialsPage-twd2xCOW.js → CredentialsPage-CV6e60yC.js} +2 -2
  80. package/dashboard/dist/assets/{CredentialsPage-twd2xCOW.js.map → CredentialsPage-CV6e60yC.js.map} +1 -1
  81. package/dashboard/dist/assets/{CronLabel-DdnIuudX.js → CronLabel-CnqhqW0B.js} +2 -2
  82. package/dashboard/dist/assets/{CronLabel-DdnIuudX.js.map → CronLabel-CnqhqW0B.js.map} +1 -1
  83. package/dashboard/dist/assets/{ElapsedCell-DCctVv5R.js → ElapsedCell-C1IOn-tj.js} +2 -2
  84. package/dashboard/dist/assets/{ElapsedCell-DCctVv5R.js.map → ElapsedCell-C1IOn-tj.js.map} +1 -1
  85. package/dashboard/dist/assets/{EntityTimelinePanel-CMnskyWv.js → EntityTimelinePanel-Dz6Liig4.js} +2 -2
  86. package/dashboard/dist/assets/{EntityTimelinePanel-CMnskyWv.js.map → EntityTimelinePanel-Dz6Liig4.js.map} +1 -1
  87. package/dashboard/dist/assets/{EscalationListSchemaPage-VfCn6WDb.js → EscalationListSchemaPage-bgdmLmrh.js} +2 -2
  88. package/dashboard/dist/assets/{EscalationListSchemaPage-VfCn6WDb.js.map → EscalationListSchemaPage-bgdmLmrh.js.map} +1 -1
  89. package/dashboard/dist/assets/{EscalationListView-CGQZxcC-.js → EscalationListView-CrlD3ZGt.js} +2 -2
  90. package/dashboard/dist/assets/{EscalationListView-CGQZxcC-.js.map → EscalationListView-CrlD3ZGt.js.map} +1 -1
  91. package/dashboard/dist/assets/{EscalationSchemaPage-BX0tx-PM.js → EscalationSchemaPage-dxXO_T3t.js} +2 -2
  92. package/dashboard/dist/assets/{EscalationSchemaPage-BX0tx-PM.js.map → EscalationSchemaPage-dxXO_T3t.js.map} +1 -1
  93. package/dashboard/dist/assets/{EscalationTimeline-DKoSM56J.js → EscalationTimeline-C3WQZQuM.js} +2 -2
  94. package/dashboard/dist/assets/{EscalationTimeline-DKoSM56J.js.map → EscalationTimeline-C3WQZQuM.js.map} +1 -1
  95. package/dashboard/dist/assets/{EscalationTitleSelect-DWGLBOmS.js → EscalationTitleSelect-CTtcETUO.js} +2 -2
  96. package/dashboard/dist/assets/{EscalationTitleSelect-DWGLBOmS.js.map → EscalationTitleSelect-CTtcETUO.js.map} +1 -1
  97. package/dashboard/dist/assets/{EscalationsOverview-C2XoguaA.js → EscalationsOverview-DAjZ7JY2.js} +2 -2
  98. package/dashboard/dist/assets/{EscalationsOverview-C2XoguaA.js.map → EscalationsOverview-DAjZ7JY2.js.map} +1 -1
  99. package/dashboard/dist/assets/{EventTable-CBUWq7--.js → EventTable-B72DQP_v.js} +2 -2
  100. package/dashboard/dist/assets/{EventTable-CBUWq7--.js.map → EventTable-B72DQP_v.js.map} +1 -1
  101. package/dashboard/dist/assets/{FilterBar-8IdbleZ9.js → FilterBar-CCTaA_LH.js} +2 -2
  102. package/dashboard/dist/assets/{FilterBar-8IdbleZ9.js.map → FilterBar-CCTaA_LH.js.map} +1 -1
  103. package/dashboard/dist/assets/{GraphInvokePage-CUvoPzsW.js → GraphInvokePage-CAsCgFo3.js} +2 -2
  104. package/dashboard/dist/assets/{GraphInvokePage-CUvoPzsW.js.map → GraphInvokePage-CAsCgFo3.js.map} +1 -1
  105. package/dashboard/dist/assets/{HomePage-BP7v9GLJ.js → HomePage-DseE_iSr.js} +2 -2
  106. package/dashboard/dist/assets/{HomePage-BP7v9GLJ.js.map → HomePage-DseE_iSr.js.map} +1 -1
  107. package/dashboard/dist/assets/{ListToolbar-Cnacuwoy.js → ListToolbar-1zdqnjW6.js} +2 -2
  108. package/dashboard/dist/assets/{ListToolbar-Cnacuwoy.js.map → ListToolbar-1zdqnjW6.js.map} +1 -1
  109. package/dashboard/dist/assets/{McpOverview-C2JoNoDA.js → McpOverview-DS_JXDW5.js} +2 -2
  110. package/dashboard/dist/assets/{McpOverview-C2JoNoDA.js.map → McpOverview-DS_JXDW5.js.map} +1 -1
  111. package/dashboard/dist/assets/{McpQueryDetailPage-C_nih0w-.js → McpQueryDetailPage-BeMUGcv3.js} +2 -2
  112. package/dashboard/dist/assets/{McpQueryDetailPage-C_nih0w-.js.map → McpQueryDetailPage-BeMUGcv3.js.map} +1 -1
  113. package/dashboard/dist/assets/{McpQueryPage-U_wNXow2.js → McpQueryPage-CeiLO_LR.js} +2 -2
  114. package/dashboard/dist/assets/{McpQueryPage-U_wNXow2.js.map → McpQueryPage-CeiLO_LR.js.map} +1 -1
  115. package/dashboard/dist/assets/{McpRunDetailPage-DtKoJq6J.js → McpRunDetailPage-DYp1uZK2.js} +2 -2
  116. package/dashboard/dist/assets/{McpRunDetailPage-DtKoJq6J.js.map → McpRunDetailPage-DYp1uZK2.js.map} +1 -1
  117. package/dashboard/dist/assets/{McpRunsPage-CnYtfGhf.js → McpRunsPage-VeaDzcL4.js} +2 -2
  118. package/dashboard/dist/assets/{McpRunsPage-CnYtfGhf.js.map → McpRunsPage-VeaDzcL4.js.map} +1 -1
  119. package/dashboard/dist/assets/{OperationsPage-C7hupIer.js → OperationsPage-DK2mgaXf.js} +2 -2
  120. package/dashboard/dist/assets/{OperationsPage-C7hupIer.js.map → OperationsPage-DK2mgaXf.js.map} +1 -1
  121. package/dashboard/dist/assets/{OperatorDashboard-fVuLn2D5.js → OperatorDashboard-BNjLF0f7.js} +2 -2
  122. package/dashboard/dist/assets/{OperatorDashboard-fVuLn2D5.js.map → OperatorDashboard-BNjLF0f7.js.map} +1 -1
  123. package/dashboard/dist/assets/{PersonaDetailPage-C-4o8lPw.js → PersonaDetailPage-IQ2fZLa6.js} +2 -2
  124. package/dashboard/dist/assets/{PersonaDetailPage-C-4o8lPw.js.map → PersonaDetailPage-IQ2fZLa6.js.map} +1 -1
  125. package/dashboard/dist/assets/{PersonasPage-BL1FwLmv.js → PersonasPage-DpGFEcU-.js} +2 -2
  126. package/dashboard/dist/assets/{PersonasPage-BL1FwLmv.js.map → PersonasPage-DpGFEcU-.js.map} +1 -1
  127. package/dashboard/dist/assets/{PortalPage-tJG5sgb1.js → PortalPage-D07xyvG_.js} +2 -2
  128. package/dashboard/dist/assets/{PortalPage-tJG5sgb1.js.map → PortalPage-D07xyvG_.js.map} +1 -1
  129. package/dashboard/dist/assets/{ProcessDetailPage-Dz_jY4Yt.js → ProcessDetailPage-t8EEYSMk.js} +2 -2
  130. package/dashboard/dist/assets/{ProcessDetailPage-Dz_jY4Yt.js.map → ProcessDetailPage-t8EEYSMk.js.map} +1 -1
  131. package/dashboard/dist/assets/{ProcessesListPage-Cbn9cter.js → ProcessesListPage-BDUXLFdb.js} +2 -2
  132. package/dashboard/dist/assets/{ProcessesListPage-Cbn9cter.js.map → ProcessesListPage-BDUXLFdb.js.map} +1 -1
  133. package/dashboard/dist/assets/{ResolverForm-Bk8iXQ6-.js → ResolverForm-BwWOYv_Z.js} +6 -6
  134. package/dashboard/dist/assets/ResolverForm-BwWOYv_Z.js.map +1 -0
  135. package/dashboard/dist/assets/{RoleDetailPage-owPi6gI9.js → RoleDetailPage-zMF3x2xi.js} +2 -2
  136. package/dashboard/dist/assets/{RoleDetailPage-owPi6gI9.js.map → RoleDetailPage-zMF3x2xi.js.map} +1 -1
  137. package/dashboard/dist/assets/{RolesPage-NwmMvZFa.js → RolesPage-CEBp_PpL.js} +2 -2
  138. package/dashboard/dist/assets/{RolesPage-NwmMvZFa.js.map → RolesPage-CEBp_PpL.js.map} +1 -1
  139. package/dashboard/dist/assets/{RunAsSelector-tgEooTyU.js → RunAsSelector-CC_EHN3z.js} +2 -2
  140. package/dashboard/dist/assets/{RunAsSelector-tgEooTyU.js.map → RunAsSelector-CC_EHN3z.js.map} +1 -1
  141. package/dashboard/dist/assets/{ScanCodesPage-CUv_8ic6.js → ScanCodesPage-DD4uU-jY.js} +2 -2
  142. package/dashboard/dist/assets/{ScanCodesPage-CUv_8ic6.js.map → ScanCodesPage-DD4uU-jY.js.map} +1 -1
  143. package/dashboard/dist/assets/ScanSchemeDetailPage-CUW8gYFh.js +2 -0
  144. package/dashboard/dist/assets/ScanSchemeDetailPage-CUW8gYFh.js.map +1 -0
  145. package/dashboard/dist/assets/ScanStationPage-DpO_ESuf.js +2 -0
  146. package/dashboard/dist/assets/ScanStationPage-DpO_ESuf.js.map +1 -0
  147. package/dashboard/dist/assets/{StickyPagination-CsTI_gvJ.js → StickyPagination-cNqSDm5f.js} +2 -2
  148. package/dashboard/dist/assets/{StickyPagination-CsTI_gvJ.js.map → StickyPagination-cNqSDm5f.js.map} +1 -1
  149. package/dashboard/dist/assets/{StreamMessageDetail-auRlvjTh.js → StreamMessageDetail-C4oZqQdB.js} +2 -2
  150. package/dashboard/dist/assets/{StreamMessageDetail-auRlvjTh.js.map → StreamMessageDetail-C4oZqQdB.js.map} +1 -1
  151. package/dashboard/dist/assets/{SwimlaneTimeline-BLoVHYAd.js → SwimlaneTimeline-BjBiV7GT.js} +2 -2
  152. package/dashboard/dist/assets/{SwimlaneTimeline-BLoVHYAd.js.map → SwimlaneTimeline-BjBiV7GT.js.map} +1 -1
  153. package/dashboard/dist/assets/{TaskDetailPage-BPsZ1bK_.js → TaskDetailPage-pO_AnVS1.js} +2 -2
  154. package/dashboard/dist/assets/{TaskDetailPage-BPsZ1bK_.js.map → TaskDetailPage-pO_AnVS1.js.map} +1 -1
  155. package/dashboard/dist/assets/{TasksListPage-BNGM74yT.js → TasksListPage-DKDHlWP7.js} +2 -2
  156. package/dashboard/dist/assets/{TasksListPage-BNGM74yT.js.map → TasksListPage-DKDHlWP7.js.map} +1 -1
  157. package/dashboard/dist/assets/{TimeAgo-BnAHXGK7.js → TimeAgo-D2qchUuJ.js} +2 -2
  158. package/dashboard/dist/assets/{TimeAgo-BnAHXGK7.js.map → TimeAgo-D2qchUuJ.js.map} +1 -1
  159. package/dashboard/dist/assets/{TimestampCell-J4yae6mc.js → TimestampCell-DeswZGGo.js} +2 -2
  160. package/dashboard/dist/assets/{TimestampCell-J4yae6mc.js.map → TimestampCell-DeswZGGo.js.map} +1 -1
  161. package/dashboard/dist/assets/{ToolTestPanel-BdzzgXDu.js → ToolTestPanel-DJh7PIUa.js} +2 -2
  162. package/dashboard/dist/assets/{ToolTestPanel-BdzzgXDu.js.map → ToolTestPanel-DJh7PIUa.js.map} +1 -1
  163. package/dashboard/dist/assets/{TopicDetailPage-DJKg8lb7.js → TopicDetailPage-CsgDJ4Z4.js} +2 -2
  164. package/dashboard/dist/assets/{TopicDetailPage-DJKg8lb7.js.map → TopicDetailPage-CsgDJ4Z4.js.map} +1 -1
  165. package/dashboard/dist/assets/{TopicsPage-DQV0WxG6.js → TopicsPage-tBRZDVDN.js} +2 -2
  166. package/dashboard/dist/assets/{TopicsPage-DQV0WxG6.js.map → TopicsPage-tBRZDVDN.js.map} +1 -1
  167. package/dashboard/dist/assets/{UserName-Ct09nGh5.js → UserName-B-5JcDck.js} +2 -2
  168. package/dashboard/dist/assets/{UserName-Ct09nGh5.js.map → UserName-B-5JcDck.js.map} +1 -1
  169. package/dashboard/dist/assets/{WorkflowExecutionPage-B5WJOsee.js → WorkflowExecutionPage-BPHVnhp6.js} +2 -2
  170. package/dashboard/dist/assets/{WorkflowExecutionPage-B5WJOsee.js.map → WorkflowExecutionPage-BPHVnhp6.js.map} +1 -1
  171. package/dashboard/dist/assets/{WorkflowsDashboard-Hc87TRgD.js → WorkflowsDashboard-CxLlfZmY.js} +2 -2
  172. package/dashboard/dist/assets/{WorkflowsDashboard-Hc87TRgD.js.map → WorkflowsDashboard-CxLlfZmY.js.map} +1 -1
  173. package/dashboard/dist/assets/{WorkflowsOverview-CJQbyOj-.js → WorkflowsOverview-C4az5rwp.js} +2 -2
  174. package/dashboard/dist/assets/{WorkflowsOverview-CJQbyOj-.js.map → WorkflowsOverview-C4az5rwp.js.map} +1 -1
  175. package/dashboard/dist/assets/{YamlWorkflowDetailPage-BMeED677.js → YamlWorkflowDetailPage-BmhlAUFQ.js} +2 -2
  176. package/dashboard/dist/assets/{YamlWorkflowDetailPage-BMeED677.js.map → YamlWorkflowDetailPage-BmhlAUFQ.js.map} +1 -1
  177. package/dashboard/dist/assets/{YamlWorkflowsPage-BMMg0Id6.js → YamlWorkflowsPage-CSbG5o2V.js} +2 -2
  178. package/dashboard/dist/assets/{YamlWorkflowsPage-BMMg0Id6.js.map → YamlWorkflowsPage-CSbG5o2V.js.map} +1 -1
  179. package/dashboard/dist/assets/{agents-CdFkgFvg.js → agents-BohEn7vw.js} +2 -2
  180. package/dashboard/dist/assets/{agents-CdFkgFvg.js.map → agents-BohEn7vw.js.map} +1 -1
  181. package/dashboard/dist/assets/{bots-Mj3LHWWg.js → bots-BG2EO-Wi.js} +2 -2
  182. package/dashboard/dist/assets/{bots-Mj3LHWWg.js.map → bots-BG2EO-Wi.js.map} +1 -1
  183. package/dashboard/dist/assets/{capabilities-Dw1ObK2-.js → capabilities-CeFrBmYX.js} +2 -2
  184. package/dashboard/dist/assets/{capabilities-Dw1ObK2-.js.map → capabilities-CeFrBmYX.js.map} +1 -1
  185. package/dashboard/dist/assets/{controlplane-DcNE1APv.js → controlplane-Dhvt8l8F.js} +2 -2
  186. package/dashboard/dist/assets/{controlplane-DcNE1APv.js.map → controlplane-Dhvt8l8F.js.map} +1 -1
  187. package/dashboard/dist/assets/{escalation-columns-D364Trpy.js → escalation-columns-BWMNxImp.js} +2 -2
  188. package/dashboard/dist/assets/{escalation-columns-D364Trpy.js.map → escalation-columns-BWMNxImp.js.map} +1 -1
  189. package/dashboard/dist/assets/{index-DPStdq4T.js → index-Bd_dgyfJ.js} +2 -2
  190. package/dashboard/dist/assets/{index-DPStdq4T.js.map → index-Bd_dgyfJ.js.map} +1 -1
  191. package/dashboard/dist/assets/{index-B3veJ698.js → index-C8VlM2Oe.js} +2 -2
  192. package/dashboard/dist/assets/{index-B3veJ698.js.map → index-C8VlM2Oe.js.map} +1 -1
  193. package/dashboard/dist/assets/{index-BiVce3n0.js → index-CiqSVDga.js} +2 -2
  194. package/dashboard/dist/assets/{index-BiVce3n0.js.map → index-CiqSVDga.js.map} +1 -1
  195. package/dashboard/dist/assets/{index-DkcI4V_H.js → index-Cl_YXEdp.js} +2 -2
  196. package/dashboard/dist/assets/{index-DkcI4V_H.js.map → index-Cl_YXEdp.js.map} +1 -1
  197. package/dashboard/dist/assets/index-CtZWpy22.js +2 -0
  198. package/dashboard/dist/assets/index-CtZWpy22.js.map +1 -0
  199. package/dashboard/dist/assets/{index-Bq5XNEzD.js → index-D90D9y0J.js} +2 -2
  200. package/dashboard/dist/assets/{index-Bq5XNEzD.js.map → index-D90D9y0J.js.map} +1 -1
  201. package/dashboard/dist/assets/{index-eDm6cz0F.js → index-DABkM7s-.js} +2 -2
  202. package/dashboard/dist/assets/{index-eDm6cz0F.js.map → index-DABkM7s-.js.map} +1 -1
  203. package/dashboard/dist/assets/{index-WSm8bgE7.js → index-Dbwu51xm.js} +3 -3
  204. package/dashboard/dist/assets/{index-WSm8bgE7.js.map → index-Dbwu51xm.js.map} +1 -1
  205. package/dashboard/dist/assets/{index-Dyotfa_k.js → index-Dc3Om6G3.js} +2 -2
  206. package/dashboard/dist/assets/{index-Dyotfa_k.js.map → index-Dc3Om6G3.js.map} +1 -1
  207. package/dashboard/dist/assets/{index-BRGTmoYY.js → index-Dc_zWK23.js} +2 -2
  208. package/dashboard/dist/assets/{index-BRGTmoYY.js.map → index-Dc_zWK23.js.map} +1 -1
  209. package/dashboard/dist/assets/{index-MDD4JYtu.js → index-Y-bdW8vo.js} +2 -2
  210. package/dashboard/dist/assets/{index-MDD4JYtu.js.map → index-Y-bdW8vo.js.map} +1 -1
  211. package/dashboard/dist/assets/{index-Bd6-KmBE.js → index-dYKgd06u.js} +2 -2
  212. package/dashboard/dist/assets/{index-Bd6-KmBE.js.map → index-dYKgd06u.js.map} +1 -1
  213. package/dashboard/dist/assets/{index-BQeHJHYN.js → index-fUsx_gYx.js} +25 -25
  214. package/dashboard/dist/assets/index-fUsx_gYx.js.map +1 -0
  215. package/dashboard/dist/assets/{knowledge-Bafewjxk.js → knowledge-CCcTidNV.js} +2 -2
  216. package/dashboard/dist/assets/{knowledge-Bafewjxk.js.map → knowledge-CCcTidNV.js.map} +1 -1
  217. package/dashboard/dist/assets/{mcp-vLIutbnc.js → mcp-CLA1z7Pg.js} +2 -2
  218. package/dashboard/dist/assets/{mcp-vLIutbnc.js.map → mcp-CLA1z7Pg.js.map} +1 -1
  219. package/dashboard/dist/assets/{mcp-query-BzTtIG90.js → mcp-query-CWG0WMAs.js} +2 -2
  220. package/dashboard/dist/assets/{mcp-query-BzTtIG90.js.map → mcp-query-CWG0WMAs.js.map} +1 -1
  221. package/dashboard/dist/assets/metadata-display-B7X5hGxG.js +2 -0
  222. package/dashboard/dist/assets/metadata-display-B7X5hGxG.js.map +1 -0
  223. package/dashboard/dist/assets/{personas-WD40EDS_.js → personas-8jURIzx6.js} +2 -2
  224. package/dashboard/dist/assets/{personas-WD40EDS_.js.map → personas-8jURIzx6.js.map} +1 -1
  225. package/dashboard/dist/assets/{pipelines-DFwULWs3.js → pipelines-hVVRAXqG.js} +2 -2
  226. package/dashboard/dist/assets/{pipelines-DFwULWs3.js.map → pipelines-hVVRAXqG.js.map} +1 -1
  227. package/dashboard/dist/assets/{tasks-La_-WAUn.js → tasks-BE1O57Bf.js} +2 -2
  228. package/dashboard/dist/assets/{tasks-La_-WAUn.js.map → tasks-BE1O57Bf.js.map} +1 -1
  229. package/dashboard/dist/assets/{topics-CzYMlvqm.js → topics-Bg96Wp1r.js} +2 -2
  230. package/dashboard/dist/assets/{topics-CzYMlvqm.js.map → topics-Bg96Wp1r.js.map} +1 -1
  231. package/dashboard/dist/assets/{useDebouncedValue-C0FQyANW.js → useDebouncedValue-DmEveyEy.js} +2 -2
  232. package/dashboard/dist/assets/{useDebouncedValue-C0FQyANW.js.map → useDebouncedValue-DmEveyEy.js.map} +1 -1
  233. package/dashboard/dist/assets/{useNamespace-WW_XjAb3.js → useNamespace-DHgkzIuL.js} +2 -2
  234. package/dashboard/dist/assets/{useNamespace-WW_XjAb3.js.map → useNamespace-DHgkzIuL.js.map} +1 -1
  235. package/dashboard/dist/assets/{useYamlActivityEvents-B3YxPeFt.js → useYamlActivityEvents-RU0PvU8S.js} +2 -2
  236. package/dashboard/dist/assets/{useYamlActivityEvents-B3YxPeFt.js.map → useYamlActivityEvents-RU0PvU8S.js.map} +1 -1
  237. package/dashboard/dist/assets/{yaml-workflows-COHOjdhF.js → yaml-workflows-DQWE9ijc.js} +2 -2
  238. package/dashboard/dist/assets/{yaml-workflows-COHOjdhF.js.map → yaml-workflows-DQWE9ijc.js.map} +1 -1
  239. package/dashboard/dist/index.html +1 -1
  240. package/docs/hitl/lookups.md +27 -18
  241. package/docs/hitl/x-lt-validation.md +1 -1
  242. package/docs/hitl/x-lt-widget.md +1 -1
  243. package/docs/hitl-guide.md +1 -1
  244. package/docs/scan-codes.md +86 -16
  245. package/package.json +1 -1
  246. package/dashboard/dist/assets/ResolverForm-Bk8iXQ6-.js.map +0 -1
  247. package/dashboard/dist/assets/ScanSchemeDetailPage-YHqbu7oK.js +0 -2
  248. package/dashboard/dist/assets/ScanSchemeDetailPage-YHqbu7oK.js.map +0 -1
  249. package/dashboard/dist/assets/ScanStationPage-B275l6r_.js +0 -2
  250. package/dashboard/dist/assets/ScanStationPage-B275l6r_.js.map +0 -1
  251. package/dashboard/dist/assets/index-BQeHJHYN.js.map +0 -1
  252. package/dashboard/dist/assets/index-BmNAVd4s.js +0 -2
  253. package/dashboard/dist/assets/index-BmNAVd4s.js.map +0 -1
  254. package/dashboard/dist/assets/metadata-display-COo3mMCr.js +0 -2
  255. package/dashboard/dist/assets/metadata-display-COo3mMCr.js.map +0 -1
@@ -1,15 +1,22 @@
1
1
  import { type EscalationLookupRef } from '../../types/escalation';
2
+ import type { LTEscalationRecord } from '../../types';
2
3
  import type { LTApiResult, LTApiAuth } from '../../types/sdk';
3
4
  /** The refs riding the row's envelope under the reserved key, or []. */
4
5
  export declare function readLookupRefs(envelope: string | null | undefined): EscalationLookupRef[];
6
+ /**
7
+ * When a current ref is read: now for a pending row, the moment it closed
8
+ * otherwise, so a closed row shows the edition its work was done against.
9
+ */
10
+ export declare function lookupAsOf(escalation: Pick<LTEscalationRecord, 'status' | 'resolved_at' | 'updated_at'>): string | null;
5
11
  /**
6
12
  * Resolve an escalation's versioned knowledge lookups.
7
13
  *
8
14
  * The refs on `envelope.lookups` ARE the grant: any user who may read the
9
15
  * escalation may read exactly the pinned editions it names — nothing else in
10
16
  * the knowledge store. Snapshots are immutable, so responses are served from
11
- * an in-process cache after the first read; a ref whose snapshot does not
12
- * exist answers with `missing: true` rather than failing the batch.
17
+ * an in-process cache after the first read; a current ref reads the newest
18
+ * edition (as of the close, for a closed row). A ref with no edition answers
19
+ * with `missing: true` rather than failing the batch.
13
20
  *
14
21
  * @param input.id — escalation UUID
15
22
  * @param auth — authenticated user context (must hold the escalation's role)
@@ -34,6 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.readLookupRefs = readLookupRefs;
37
+ exports.lookupAsOf = lookupAsOf;
37
38
  exports.getEscalationLookups = getEscalationLookups;
38
39
  const escalationService = __importStar(require("../../services/escalation"));
39
40
  const knowledge_1 = require("../../services/knowledge");
@@ -55,14 +56,25 @@ function readLookupRefs(envelope) {
55
56
  return [];
56
57
  }
57
58
  }
59
+ /**
60
+ * When a current ref is read: now for a pending row, the moment it closed
61
+ * otherwise, so a closed row shows the edition its work was done against.
62
+ */
63
+ function lookupAsOf(escalation) {
64
+ if (escalation.status === 'pending')
65
+ return null;
66
+ const closed = escalation.resolved_at ?? escalation.updated_at;
67
+ return closed ? new Date(closed).toISOString() : null;
68
+ }
58
69
  /**
59
70
  * Resolve an escalation's versioned knowledge lookups.
60
71
  *
61
72
  * The refs on `envelope.lookups` ARE the grant: any user who may read the
62
73
  * escalation may read exactly the pinned editions it names — nothing else in
63
74
  * the knowledge store. Snapshots are immutable, so responses are served from
64
- * an in-process cache after the first read; a ref whose snapshot does not
65
- * exist answers with `missing: true` rather than failing the batch.
75
+ * an in-process cache after the first read; a current ref reads the newest
76
+ * edition (as of the close, for a closed row). A ref with no edition answers
77
+ * with `missing: true` rather than failing the batch.
66
78
  *
67
79
  * @param input.id — escalation UUID
68
80
  * @param auth — authenticated user context (must hold the escalation's role)
@@ -81,7 +93,7 @@ async function getEscalationLookups(input, auth) {
81
93
  if (refs.length === 0) {
82
94
  return { status: 200, data: { lookups: [] } };
83
95
  }
84
- const lookups = await (0, knowledge_1.resolveLookupRefs)(refs);
96
+ const lookups = await (0, knowledge_1.resolveLookupRefs)(refs, lookupAsOf(escalation));
85
97
  return { status: 200, data: { lookups } };
86
98
  }
87
99
  catch (err) {
@@ -37,6 +37,8 @@ export declare function claimByMetadata(input: {
37
37
  metadata?: Record<string, any>;
38
38
  provisionIfAbsent?: ProvisionIfAbsent;
39
39
  restrictRoles?: string[];
40
+ /** Claims only this row, when it still matches every other condition. */
41
+ assertId?: string;
40
42
  }, auth: LTApiAuth): Promise<LTApiResult>;
41
43
  /**
42
44
  * Resolve an escalation by metadata key-value pair.
@@ -94,6 +94,9 @@ async function claimByMetadata(input, auth) {
94
94
  if (!input.key || !input.value) {
95
95
  return { status: 400, error: 'key and value are required' };
96
96
  }
97
+ if (input.assertId !== undefined && !(0, uuid_1.isUuid)(input.assertId)) {
98
+ return { status: 404, error: 'No pending escalation found for this metadata' };
99
+ }
97
100
  const resolved = await (0, helpers_1.resolveAssignee)(input.assignee, auth, input.provisionIfAbsent);
98
101
  if ('error' in resolved)
99
102
  return resolved.error;
@@ -105,6 +108,12 @@ async function claimByMetadata(input, auth) {
105
108
  // (expected queues) intersects with the scope inside the same SQL filter.
106
109
  const writeScope = await (0, helpers_1.getEscalationWriteScope)(auth.userId);
107
110
  const allowedRoles = restrictScopeRoles(writeScope.allRoles, writeScope.global, input.restrictRoles);
111
+ if (input.assertId !== undefined) {
112
+ const asserted = await escalationService.claimAssertedByMetadata(input.assertId, input.key, input.value, claimUserId, input.durationMinutes, input.metadata, allowedRoles);
113
+ if (!asserted)
114
+ return { status: 404, error: 'No pending escalation found for this metadata' };
115
+ return { status: 200, data: asserted };
116
+ }
108
117
  const result = await escalationService.claimByMetadata(input.key, input.value, claimUserId, input.durationMinutes, input.metadata, allowedRoles);
109
118
  if (!result) {
110
119
  // No rows matched. Check if candidates existed (role mismatch vs no match).
@@ -61,6 +61,8 @@ async function locateForStep(step, ctx, limit) {
61
61
  return escalationService.listEscalations({
62
62
  metadata: facets,
63
63
  status,
64
+ type: step.query?.types?.[0],
65
+ subtype: step.query?.subtypes?.[0],
64
66
  assigned_to: ctx.auth.userId,
65
67
  visibleRoles: roles ?? undefined,
66
68
  limit,
@@ -71,6 +73,8 @@ async function locateForStep(step, ctx, limit) {
71
73
  return null;
72
74
  return escalationService.searchByFacets({
73
75
  roles: roles ?? undefined,
76
+ types: step.query?.types,
77
+ subtypes: step.query?.subtypes,
74
78
  facets,
75
79
  status,
76
80
  available: availability === types_1.SCAN_AVAILABILITY.AVAILABLE
@@ -1,6 +1,6 @@
1
1
  import { type ScanExecuteResponse, type ScanStep } from '../../types';
2
2
  import type { LTApiResult } from '../../types/sdk';
3
- import type { StepContext } from './context';
3
+ import { type StepContext } from './context';
4
4
  /**
5
5
  * Locate the target and present the step's choices. Choices whose identity
6
6
  * requirement is unsatisfied come back withheld — the screen renders the
@@ -1,10 +1,52 @@
1
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
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.presentStep = presentStep;
37
+ const scanCodeService = __importStar(require("../../services/scan-code"));
4
38
  const types_1 = require("../../types");
5
39
  const identity_1 = require("./identity");
6
40
  const locate_1 = require("./locate");
7
41
  const verbs_1 = require("./verbs");
42
+ const context_1 = require("./context");
43
+ /** The step's facts rendered against the presented row; unreadable tokens render empty. */
44
+ function renderFacts(step, ctx, row) {
45
+ if (!step.facts)
46
+ return undefined;
47
+ const tpl = { ...(0, context_1.templateContext)(ctx), item: row.metadata ?? {} };
48
+ return step.facts.map((fact) => ({ label: fact.label, value: scanCodeService.renderScanCopy(fact.value, tpl) }));
49
+ }
8
50
  // ── The info-choice outcome — locate → present reality + labeled choices ───
9
51
  //
10
52
  // Some objects carry one code for their whole life: the next action cannot be
@@ -52,6 +94,7 @@ async function presentStep(step, ctx) {
52
94
  verb: step.verb,
53
95
  escalation,
54
96
  choices,
97
+ ...(step.facts ? { facts: renderFacts(step, ctx, escalation) } : {}),
55
98
  notPrimed: ctx.rule.notPrimed,
56
99
  ...(autoSelect ? { autoSelect: true } : {}),
57
100
  },
@@ -41,6 +41,7 @@ const context_1 = require("./context");
41
41
  const grant_1 = require("./grant");
42
42
  const locate_1 = require("./locate");
43
43
  const verbs_subject_1 = require("./verbs-subject");
44
+ const verb_into_subject_1 = require("./verb-into-subject");
44
45
  /**
45
46
  * Adds the scanned item to an accumulator. Two modes, one atomic write:
46
47
  *
@@ -66,7 +67,7 @@ async function accumulateStep(step, ctx) {
66
67
  if (options?.from === 'subject')
67
68
  return (0, verbs_subject_1.accumulateFromSubject)(step, ctx);
68
69
  if (options?.into === 'subject')
69
- return (0, verbs_subject_1.accumulateIntoSubject)(step, ctx);
70
+ return (0, verb_into_subject_1.accumulateIntoSubject)(step, ctx);
70
71
  let item;
71
72
  if (options?.containerFacet) {
72
73
  const located = await (0, locate_1.locateForStep)(step, ctx, 1);
@@ -113,6 +114,9 @@ async function accumulateStep(step, ctx) {
113
114
  payload: rendered.payload,
114
115
  metadata: rendered.metadata,
115
116
  restrictRoles: step.query?.roles,
117
+ ...(step.query?.types || step.query?.subtypes
118
+ ? { container: { types: step.query.types, subtypes: step.query.subtypes } }
119
+ : {}),
116
120
  };
117
121
  }
118
122
  const notPrimed = await (0, grant_1.spendGrant)(ctx);
@@ -96,8 +96,11 @@ async function fillStep(step, ctx) {
96
96
  const markdown = declared.length
97
97
  ? `All ${declared.length} of these are already checked off.`
98
98
  : scanCodeService.renderScanCopy(step.refuse?.markdown ?? STOCK_UNEXPECTED, tpl);
99
+ const expected = ctx.scheme.encoding === types_1.SCAN_ENCODINGS.GTIN
100
+ ? tpl.fill.pending.map((code) => scanCodeService.displayGtin(code))
101
+ : tpl.fill.pending;
99
102
  return (0, context_1.refused)(markdown, {
100
- refusal: { markdown, expected: tpl.fill.pending },
103
+ refusal: { markdown, expected },
101
104
  progress: progress(batch, 0),
102
105
  });
103
106
  }
@@ -0,0 +1,12 @@
1
+ import { type ScanExecuteResponse, type ScanStep } from '../../types';
2
+ import type { LTApiResult } from '../../types/sdk';
3
+ import { type StepContext } from './context';
4
+ type ScanResult = LTApiResult<ScanExecuteResponse>;
5
+ /**
6
+ * The held subject's row collects the scanned code. With `accumulate.item`,
7
+ * the code's own pending row is located and written as the reciprocal in the
8
+ * same statement, so the item's record and the subject's entry land together
9
+ * or not at all.
10
+ */
11
+ export declare function accumulateIntoSubject(step: ScanStep, ctx: StepContext): Promise<ScanResult | null>;
12
+ export {};
@@ -0,0 +1,157 @@
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.accumulateIntoSubject = accumulateIntoSubject;
37
+ const scanCodeService = __importStar(require("../../services/scan-code"));
38
+ const escalationService = __importStar(require("../../services/escalation"));
39
+ const accumulate_1 = require("../escalations/accumulate");
40
+ const helpers_1 = require("../escalations/helpers");
41
+ const metadata_1 = require("../escalations/metadata");
42
+ const escalation_1 = require("../../types/escalation");
43
+ const types_1 = require("../../types");
44
+ const context_1 = require("./context");
45
+ const grant_1 = require("./grant");
46
+ const subject_1 = require("./subject");
47
+ const verbs_subject_1 = require("./verbs-subject");
48
+ const STOCK_MISSING = 'That one is not waiting here.';
49
+ const ITEM_GONE = ['reciprocal-not-found', 'reciprocal-not-accumulator'];
50
+ /**
51
+ * The scanned code's own pending row: an accumulator carrying the scheme's
52
+ * target facet = the scanned target, within the selector and the actor's
53
+ * read scope. The held subject's row is never a candidate.
54
+ */
55
+ async function locateItem(step, ctx) {
56
+ const selector = step.params.accumulate.item;
57
+ const scope = await (0, helpers_1.getEscalationReadScope)(ctx.auth.userId);
58
+ const roles = (0, metadata_1.restrictScopeRoles)(scope.allRoles, scope.global, selector.roles);
59
+ if (roles !== null && roles.length === 0)
60
+ return {};
61
+ const found = await escalationService.searchByFacets({
62
+ roles: roles ?? undefined,
63
+ types: selector.types,
64
+ subtypes: selector.subtypes,
65
+ facets: { ...selector.facets, [ctx.scheme.target_facet]: ctx.parsed.target },
66
+ status: 'pending',
67
+ exists: [escalation_1.ESCALATION_ACCUMULATE_KEYS.COUNT],
68
+ limit: 3,
69
+ }, { total: false });
70
+ const rows = found.escalations.filter((row) => row.id !== ctx.subject?.row.id);
71
+ return rows.length > 1 ? { ambiguous: true } : { row: rows[0] };
72
+ }
73
+ /** The missing-item answer: the rule's copy when declared, else fall through. */
74
+ function missing(step, ctx) {
75
+ if (!step.refuse?.missing)
76
+ return null;
77
+ const copy = scanCodeService.renderScanCopy(step.refuse.missing, (0, verbs_subject_1.bags)(ctx, ctx.subject?.row));
78
+ return (0, context_1.refused)(copy, { clearSubject: false });
79
+ }
80
+ /** Progress of a bounded accumulator after an add; unbounded rows report none. */
81
+ function progressOf(data) {
82
+ if (data.remaining === null || data.remaining === undefined)
83
+ return undefined;
84
+ return { filled: data.count, total: data.count + data.remaining, remaining: data.remaining };
85
+ }
86
+ /**
87
+ * The held subject's row collects the scanned code. With `accumulate.item`,
88
+ * the code's own pending row is located and written as the reciprocal in the
89
+ * same statement, so the item's record and the subject's entry land together
90
+ * or not at all.
91
+ */
92
+ async function accumulateIntoSubject(step, ctx) {
93
+ const subject = ctx.subject;
94
+ const claimed = await (0, verbs_subject_1.claimGuard)(step, ctx, subject);
95
+ if (claimed)
96
+ return claimed;
97
+ // 1. Locate the scanned item's own row when the step names one
98
+ let item;
99
+ const wantsItem = !!step.params?.accumulate?.item;
100
+ if (wantsItem) {
101
+ const located = await locateItem(step, ctx);
102
+ if ('ambiguous' in located) {
103
+ return (0, context_1.conflict)(`more than one pending row carries ${ctx.scheme.target_facet} = ${ctx.parsed.target}`);
104
+ }
105
+ item = located.row;
106
+ }
107
+ // 2. Check the pairing before anything is written
108
+ if (wantsItem && !item)
109
+ return missing(step, ctx);
110
+ const mismatch = (0, verbs_subject_1.matchGuard)(step, ctx, subject.row, item);
111
+ if (mismatch)
112
+ return mismatch;
113
+ if (item && step.subject?.claimedByOther !== 'allow') {
114
+ const other = await (0, subject_1.claimedByOther)(item, ctx.auth.userId);
115
+ if (other)
116
+ return (0, context_1.refused)(`Claimed by **${other.displayName}**.`, { clearSubject: false });
117
+ }
118
+ // 3. Spend the badge, then write both rows in one statement
119
+ const values = (0, verbs_subject_1.rendered)(step, ctx, '{scan.target}', item);
120
+ if (!values)
121
+ return null;
122
+ const notPrimed = (await (0, grant_1.identityGate)(step, ctx)) ?? (await (0, grant_1.spendGrant)(ctx));
123
+ if (notPrimed)
124
+ return notPrimed;
125
+ const result = await (0, accumulate_1.accumulateItem)({
126
+ id: subject.row.id,
127
+ itemKey: values.itemKey,
128
+ payload: values.payload,
129
+ metadata: values.metadata,
130
+ ...(item ? { reciprocal: { id: item.id } } : {}),
131
+ }, ctx.auth);
132
+ // 4. Report
133
+ if (result.status !== 200) {
134
+ const outcome = result.data?.outcome;
135
+ if (outcome === 'duplicate-item')
136
+ return (0, verbs_subject_1.already)(step, subject.row, true);
137
+ if (item && outcome && ITEM_GONE.includes(outcome))
138
+ return missing(step, ctx) ?? (0, context_1.refused)(STOCK_MISSING, { clearSubject: false });
139
+ return (0, verbs_subject_1.failedAdd)(step, ctx, result, subject.row, !!item);
140
+ }
141
+ const data = result.data;
142
+ const progress = progressOf(data);
143
+ return (0, context_1.withDone)({
144
+ status: 200,
145
+ data: {
146
+ outcome: types_1.SCAN_OUTCOMES.EXECUTED,
147
+ verb: step.verb,
148
+ escalation: { id: subject.row.id, ...result.data },
149
+ clearSubject: data.outcome === 'completed',
150
+ ...(progress ? { progress } : {}),
151
+ },
152
+ }, step, (0, verbs_subject_1.bags)(ctx, afterAdd(subject.row, values.metadata, data.count), item));
153
+ }
154
+ /** The subject's row as the add left it, for `{container.…}` copy, without a re-read. */
155
+ function afterAdd(row, patch, count) {
156
+ return { ...row, metadata: { ...(row.metadata ?? {}), ...patch, [escalation_1.ESCALATION_ACCUMULATE_KEYS.COUNT]: count } };
157
+ }
@@ -1,14 +1,33 @@
1
+ import * as scanCodeService from '../../services/scan-code';
1
2
  import { type LTEscalationRecord, type ScanExecuteResponse, type ScanStep } from '../../types';
2
3
  import type { LTApiResult } from '../../types/sdk';
3
- import { type StepContext } from './context';
4
+ import { type HeldSubject, type StepContext } from './context';
4
5
  type ScanResult = LTApiResult<ScanExecuteResponse>;
6
+ /** The step's template bags with the subject, the container, and the scanned item's row once located. */
7
+ export declare function bags(ctx: StepContext, container?: LTEscalationRecord, item?: LTEscalationRecord): scanCodeService.ScanTemplateContext;
8
+ /** Refuse the act when someone else holds a live claim on the subject. */
9
+ export declare function claimGuard(step: ScanStep, ctx: StepContext, subject: HeldSubject): Promise<ScanResult | null>;
5
10
  /**
6
11
  * The pre-write guard. Returns the refusal when the pairing is wrong, null
7
12
  * when it holds (or the step declares no match).
8
13
  */
9
- export declare function matchGuard(step: ScanStep, ctx: StepContext, container?: LTEscalationRecord): ScanResult | null;
14
+ export declare function matchGuard(step: ScanStep, ctx: StepContext, container?: LTEscalationRecord, item?: LTEscalationRecord): ScanResult | null;
15
+ /**
16
+ * Map a failed add onto what the bench says. 404 falls through. `keepSubject`
17
+ * leaves the hold in place when the reciprocal was already placed (the
18
+ * subject is the container the actor is still filling).
19
+ */
20
+ export declare function failedAdd(step: ScanStep, ctx: StepContext, result: LTApiResult, container?: LTEscalationRecord, keepSubject?: boolean): ScanResult | null;
21
+ /** The step's itemKey, payload and metadata, or null when a template token has nothing to read. */
22
+ export declare function rendered(step: ScanStep, ctx: StepContext, itemKeyDefault?: string, item?: LTEscalationRecord): {
23
+ itemKey: string;
24
+ payload: Record<string, any> | undefined;
25
+ metadata: {
26
+ [x: string]: any;
27
+ };
28
+ } | null;
10
29
  /** The subject joins the scanned container; the subject's row is the reciprocal. */
11
30
  export declare function accumulateFromSubject(step: ScanStep, ctx: StepContext): Promise<ScanResult | null>;
12
- /** The subject's own row collects the scanned code. */
13
- export declare function accumulateIntoSubject(step: ScanStep, ctx: StepContext): Promise<ScanResult | null>;
31
+ /** The item is already where the scan says: harmless, nothing written. */
32
+ export declare function already(step: ScanStep, row: LTEscalationRecord, keepSubject?: boolean): ScanResult;
14
33
  export {};
@@ -33,9 +33,13 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.bags = bags;
37
+ exports.claimGuard = claimGuard;
36
38
  exports.matchGuard = matchGuard;
39
+ exports.failedAdd = failedAdd;
40
+ exports.rendered = rendered;
37
41
  exports.accumulateFromSubject = accumulateFromSubject;
38
- exports.accumulateIntoSubject = accumulateIntoSubject;
42
+ exports.already = already;
39
43
  const scanCodeService = __importStar(require("../../services/scan-code"));
40
44
  const escalationService = __importStar(require("../../services/escalation"));
41
45
  const accumulate_1 = require("../escalations/accumulate");
@@ -52,13 +56,18 @@ const subject_1 = require("./subject");
52
56
  // the pairing first (match), refusing with nothing written when it is wrong,
53
57
  // then writes by id in one atomic statement: the subject joins the scanned
54
58
  // container with its own row as the reciprocal (from: 'subject'), or the
55
- // subject's row collects the scanned code (into: 'subject').
59
+ // subject's row collects the scanned code (into: 'subject', in
60
+ // verb-into-subject.ts).
56
61
  const STOCK_REFUSAL = 'That is not where this one goes.';
57
62
  const STOCK_CONFLICT = 'That container just closed. Scan it again, or the next one.';
58
63
  const STOCK_PLACED = 'This one is already placed.';
59
- /** The step's template bags with the subject (and the container, once located). */
60
- function bags(ctx, container) {
61
- return { ...(0, context_1.templateContext)(ctx), ...(container ? { container: container.metadata ?? {} } : {}) };
64
+ /** The step's template bags with the subject, the container, and the scanned item's row once located. */
65
+ function bags(ctx, container, item) {
66
+ return {
67
+ ...(0, context_1.templateContext)(ctx),
68
+ ...(container ? { container: container.metadata ?? {} } : {}),
69
+ ...(item ? { item: item.metadata ?? {} } : {}),
70
+ };
62
71
  }
63
72
  /** Refuse the act when someone else holds a live claim on the subject. */
64
73
  async function claimGuard(step, ctx, subject) {
@@ -82,10 +91,10 @@ async function locateContainer(step, ctx) {
82
91
  status: 'pending',
83
92
  exists: [escalation_1.ESCALATION_ACCUMULATE_KEYS.COUNT],
84
93
  limit: 2,
85
- });
94
+ }, { total: false });
86
95
  return found.escalations.filter((row) => row.id !== ctx.subject?.row.id);
87
96
  }
88
- const WHOLE_BAG_TOKEN = /^\{(subject|container)\.([a-zA-Z0-9_]+)\}$/;
97
+ const WHOLE_BAG_TOKEN = /^\{(subject|container|item)\.([a-zA-Z0-9_]+)\}$/;
89
98
  /**
90
99
  * One match.target template as the values it allows. A template that is a
91
100
  * single bag token naming a list facet (`{subject.offeredContainers}`) allows every
@@ -110,11 +119,11 @@ function expandTarget(template, tpl) {
110
119
  * The pre-write guard. Returns the refusal when the pairing is wrong, null
111
120
  * when it holds (or the step declares no match).
112
121
  */
113
- function matchGuard(step, ctx, container) {
122
+ function matchGuard(step, ctx, container, item) {
114
123
  const match = step.match;
115
124
  if (!match)
116
125
  return null;
117
- const tpl = bags(ctx, container);
126
+ const tpl = bags(ctx, container, item);
118
127
  const expected = (match.target ?? []).flatMap((t) => expandTarget(t, tpl));
119
128
  const targetOk = match.target === undefined || expected.includes(ctx.parsed.target);
120
129
  const subjectMeta = (ctx.subject?.row.metadata ?? {});
@@ -126,15 +135,20 @@ function matchGuard(step, ctx, container) {
126
135
  const markdown = scanCodeService.renderScanCopy(step.refuse?.markdown ?? STOCK_REFUSAL, tpl);
127
136
  return (0, context_1.refused)(markdown, { refusal: { markdown, ...(expected.length ? { expected } : {}) } });
128
137
  }
129
- /** Map a failed add onto what the bench says. 404 falls through. */
130
- function failedAdd(step, ctx, result, container) {
138
+ const PLACED_OUTCOMES = ['reciprocal-terminal', 'reciprocal-full', 'reciprocal-duplicate'];
139
+ /**
140
+ * Map a failed add onto what the bench says. 404 falls through. `keepSubject`
141
+ * leaves the hold in place when the reciprocal was already placed (the
142
+ * subject is the container the actor is still filling).
143
+ */
144
+ function failedAdd(step, ctx, result, container, keepSubject = false) {
131
145
  const outcome = result.data?.outcome;
132
146
  if (result.status === 404)
133
147
  return null;
134
148
  if (result.status === 403)
135
149
  return (0, context_1.forbidden)(result.error);
136
- if (outcome === 'reciprocal-terminal' || outcome === 'reciprocal-full' || outcome === 'reciprocal-duplicate') {
137
- return (0, context_1.refused)(STOCK_PLACED, { clearSubject: true });
150
+ if (outcome && PLACED_OUTCOMES.includes(outcome)) {
151
+ return (0, context_1.refused)(STOCK_PLACED, { clearSubject: !keepSubject });
138
152
  }
139
153
  if (outcome === 'claimed-by-other' || outcome === 'claim-expired')
140
154
  return (0, context_1.conflict)(result.error);
@@ -145,8 +159,9 @@ function failedAdd(step, ctx, result, container) {
145
159
  }
146
160
  return (0, context_1.refused)(result.error ?? STOCK_REFUSAL);
147
161
  }
148
- function rendered(step, ctx, itemKeyDefault) {
149
- const tpl = (0, context_1.templateContext)(ctx);
162
+ /** The step's itemKey, payload and metadata, or null when a template token has nothing to read. */
163
+ function rendered(step, ctx, itemKeyDefault, item) {
164
+ const tpl = bags(ctx, undefined, item);
150
165
  try {
151
166
  return {
152
167
  itemKey: scanCodeService.interpolateScanTemplate(step.params?.itemKey ?? itemKeyDefault ?? '', tpl),
@@ -217,46 +232,8 @@ async function accumulateFromSubject(step, ctx) {
217
232
  },
218
233
  }, step, bags(ctx, container));
219
234
  }
220
- /** The subject's own row collects the scanned code. */
221
- async function accumulateIntoSubject(step, ctx) {
222
- const subject = ctx.subject;
223
- const claimed = await claimGuard(step, ctx, subject);
224
- if (claimed)
225
- return claimed;
226
- const mismatch = matchGuard(step, ctx);
227
- if (mismatch)
228
- return mismatch;
229
- const values = rendered(step, ctx, '{scan.target}');
230
- if (!values)
231
- return null;
232
- const notPrimed = (await (0, grant_1.identityGate)(step, ctx)) ?? (await (0, grant_1.spendGrant)(ctx));
233
- if (notPrimed)
234
- return notPrimed;
235
- const result = await (0, accumulate_1.accumulateItem)({
236
- id: subject.row.id,
237
- itemKey: values.itemKey,
238
- payload: values.payload,
239
- metadata: values.metadata,
240
- }, ctx.auth);
241
- if (result.status !== 200) {
242
- if (result.data?.outcome === 'duplicate-item') {
243
- return already(step, subject.row);
244
- }
245
- return failedAdd(step, ctx, result);
246
- }
247
- const data = result.data;
248
- return (0, context_1.withDone)({
249
- status: 200,
250
- data: {
251
- outcome: types_1.SCAN_OUTCOMES.EXECUTED,
252
- verb: step.verb,
253
- escalation: { id: subject.row.id, ...result.data },
254
- clearSubject: data.outcome === 'completed',
255
- },
256
- }, step, bags(ctx));
257
- }
258
235
  /** The item is already where the scan says: harmless, nothing written. */
259
- function already(step, row) {
236
+ function already(step, row, keepSubject = false) {
260
237
  return {
261
238
  status: 200,
262
239
  data: {
@@ -264,7 +241,7 @@ function already(step, row) {
264
241
  verb: step.verb,
265
242
  escalation: { id: row.id },
266
243
  already: true,
267
- clearSubject: true,
244
+ clearSubject: !keepSubject,
268
245
  },
269
246
  };
270
247
  }
@@ -1,21 +1,23 @@
1
1
  import { type ScanExecuteResponse, type ScanStep } from '../../types';
2
2
  import type { LTApiResult } from '../../types/sdk';
3
3
  import { type StepContext } from './context';
4
- export declare function claimStep(step: ScanStep, ctx: StepContext): Promise<LTApiResult<ScanExecuteResponse> | null>;
4
+ /** Claims the scanned row; a presented choice passes the row it showed. */
5
+ export declare function claimStep(step: ScanStep, ctx: StepContext, presentedId?: string): Promise<LTApiResult<ScanExecuteResponse> | null>;
5
6
  /**
6
7
  * Resolves the row the step's query names: the scanned target, the extra
7
8
  * facets, and the claim state, all inside the atomic statement. A presented
8
9
  * choice passes the row it showed, so the resolve lands on that row or misses.
9
10
  */
10
11
  export declare function resolveStep(step: ScanStep, ctx: StepContext, presentedId?: string): Promise<LTApiResult<ScanExecuteResponse> | null>;
11
- export declare function escalateStep(step: ScanStep, ctx: StepContext): Promise<LTApiResult<ScanExecuteResponse> | null>;
12
- export declare function releaseStep(step: ScanStep, ctx: StepContext): Promise<LTApiResult<ScanExecuteResponse> | null>;
12
+ export declare function escalateStep(step: ScanStep, ctx: StepContext, presentedId?: string): Promise<LTApiResult<ScanExecuteResponse> | null>;
13
+ export declare function releaseStep(step: ScanStep, ctx: StepContext, presentedId?: string): Promise<LTApiResult<ScanExecuteResponse> | null>;
13
14
  /**
14
- * Dispatch one CHOICE verb against an already-presented row. Unlike the step
15
- * walk (where a miss falls through to the next step), the screen showed this
16
- * exact row — so a miss answers with the truth: FORBIDDEN when the actor
17
- * holds no write scope here, CONFLICT when a concurrent actor won the race.
15
+ * Dispatch one CHOICE verb against an already-presented row. Every verb that
16
+ * writes the row writes that row by id, so a code shared by several rows
17
+ * never moves the write elsewhere. Unlike the step walk (where a miss falls
18
+ * through to the next step), a miss answers with the truth: FORBIDDEN when
19
+ * the actor holds no write scope here, CONFLICT when a concurrent actor won.
18
20
  */
19
21
  export declare function dispatchChoiceVerb(step: ScanStep, ctx: StepContext, row: Record<string, any>): Promise<LTApiResult<ScanExecuteResponse>>;
20
- export declare function cancelStep(step: ScanStep, ctx: StepContext): Promise<LTApiResult<ScanExecuteResponse> | null>;
22
+ export declare function cancelStep(step: ScanStep, ctx: StepContext, presentedId?: string): Promise<LTApiResult<ScanExecuteResponse> | null>;
21
23
  export { accumulateStep } from './verb-accumulate';