@things-factory/ai-assistant 10.1.277 → 10.1.279

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 (537) hide show
  1. package/dist-client/bootstrap.d.ts +4 -4
  2. package/dist-client/bootstrap.js +4 -8
  3. package/dist-client/components/ai-model-price-table.d.ts +32 -0
  4. package/dist-client/components/ai-model-price-table.js +311 -0
  5. package/dist-client/components/ai-usage-table.d.ts +17 -0
  6. package/dist-client/components/ai-usage-table.js +151 -0
  7. package/dist-client/index.d.ts +1 -0
  8. package/dist-client/index.js +2 -0
  9. package/dist-client/pages/ai-model-price-page.d.ts +37 -0
  10. package/dist-client/pages/ai-model-price-page.js +312 -0
  11. package/dist-client/route.d.ts +1 -1
  12. package/dist-client/route.js +4 -0
  13. package/dist-client/settings/ai-agent-setting-let.js +11 -0
  14. package/dist-client/utils/model-price-model.d.ts +31 -0
  15. package/dist-client/utils/model-price-model.js +30 -0
  16. package/dist-client/utils/usage-charts.d.ts +21 -0
  17. package/dist-client/utils/usage-charts.js +45 -0
  18. package/dist-client/utils/usage-model.d.ts +44 -0
  19. package/dist-client/utils/usage-model.js +44 -0
  20. package/dist-server/service/ai-agent-resolver.d.ts +46 -0
  21. package/dist-server/service/ai-agent-resolver.js +252 -0
  22. package/dist-server/service/assistant-mode/mode-categories.js +2 -2
  23. package/dist-server/service/chat-message/message-doors.d.ts +6 -10
  24. package/dist-server/service/chat-message/message-doors.js +5 -12
  25. package/dist-server/service/data-read/read-target.d.ts +3 -4
  26. package/dist-server/service/people/person-subject.d.ts +9 -5
  27. package/dist-server/service/people/person-subject.js +14 -19
  28. package/package.json +25 -10
  29. package/things-factory.config.js +4 -1
  30. package/translations/en.json +46 -4
  31. package/translations/es.json +43 -1
  32. package/translations/ja.json +43 -1
  33. package/translations/ko.json +46 -4
  34. package/translations/ms.json +43 -1
  35. package/translations/zh.json +43 -1
  36. package/client/bootstrap.ts +0 -27
  37. package/client/components/assistant-chat.test.ts +0 -149
  38. package/client/components/assistant-chat.ts +0 -5599
  39. package/client/components/assistant-dock.ts +0 -1036
  40. package/client/components/assistant-invite.ts +0 -138
  41. package/client/components/assistant-mode.test.ts +0 -119
  42. package/client/components/assistant-mode.ts +0 -174
  43. package/client/components/assistant-selection-bar.test.ts +0 -167
  44. package/client/components/assistant-selection-bar.ts +0 -178
  45. package/client/components/assistant-session-manager.ts +0 -915
  46. package/client/components/assistant-session-toolbar.ts +0 -80
  47. package/client/components/chat-defaults.ts +0 -64
  48. package/client/components/chat-echo-dedup.test.ts +0 -253
  49. package/client/components/chat-echo-dedup.ts +0 -190
  50. package/client/components/chat-input-builder.test.ts +0 -86
  51. package/client/components/chat-input-builder.ts +0 -133
  52. package/client/components/chat-proposal-survival.test.ts +0 -73
  53. package/client/components/entry-review.ts +0 -346
  54. package/client/components/markdown.test.ts +0 -518
  55. package/client/components/markdown.ts +0 -508
  56. package/client/components/mention-popup-helpers.ts +0 -433
  57. package/client/components/mention-popup.test.ts +0 -588
  58. package/client/components/mention-popup.ts +0 -261
  59. package/client/components/panel-aria.test.ts +0 -59
  60. package/client/components/proposal-outcome-line.ts +0 -74
  61. package/client/components/proposal-request.test.ts +0 -73
  62. package/client/components/reply-message.test.ts +0 -15
  63. package/client/components/reply-message.ts +0 -11
  64. package/client/components/roster-identity.test.ts +0 -8
  65. package/client/components/roster-identity.ts +0 -4
  66. package/client/components/workspace-view.ts +0 -486
  67. package/client/index.ts +0 -36
  68. package/client/pages/assistant-workspace-page.ts +0 -317
  69. package/client/route.ts +0 -9
  70. package/client/settings/agent-settings-model.ts +0 -164
  71. package/client/settings/ai-agent-setting-let.ts +0 -667
  72. package/client/settings/ai-usage-setting-let.ts +0 -240
  73. package/client/settings/usage-model.ts +0 -46
  74. package/client/setup-assistant-dock.ts +0 -177
  75. package/client/tsconfig.json +0 -13
  76. package/client/utils/addressed-draft.test.ts +0 -31
  77. package/client/utils/agent-choice.ts +0 -56
  78. package/client/utils/applied-screens.ts +0 -36
  79. package/client/utils/assistant-activity.ts +0 -122
  80. package/client/utils/assistant-ask.test.ts +0 -38
  81. package/client/utils/assistant-ask.ts +0 -93
  82. package/client/utils/assistant-capability-read.ts +0 -24
  83. package/client/utils/assistant-capability.test.ts +0 -17
  84. package/client/utils/assistant-capability.ts +0 -19
  85. package/client/utils/assistant-navigation.test.ts +0 -66
  86. package/client/utils/assistant-navigation.ts +0 -11
  87. package/client/utils/assistant-proposals.ts +0 -85
  88. package/client/utils/assistant-request-context.ts +0 -63
  89. package/client/utils/assistant-selection.test.ts +0 -54
  90. package/client/utils/assistant-selection.ts +0 -75
  91. package/client/utils/assistant-session-actions.ts +0 -32
  92. package/client/utils/assistant-session-admin.ts +0 -239
  93. package/client/utils/assistant-session-controller.test.ts +0 -75
  94. package/client/utils/assistant-session-controller.ts +0 -208
  95. package/client/utils/assistant-session-transport.ts +0 -46
  96. package/client/utils/assistant-surface.ts +0 -178
  97. package/client/utils/assistant-typing.test.ts +0 -33
  98. package/client/utils/assistant-typing.ts +0 -53
  99. package/client/utils/attachment-policy.ts +0 -106
  100. package/client/utils/composer-frame.ts +0 -77
  101. package/client/utils/document-text.ts +0 -332
  102. package/client/utils/entry-hash.ts +0 -35
  103. package/client/utils/entry-proposal.ts +0 -215
  104. package/client/utils/entry-workspace.ts +0 -70
  105. package/client/utils/invite-proposal-register.ts +0 -31
  106. package/client/utils/invite-proposal.test.ts +0 -40
  107. package/client/utils/invite-proposal.ts +0 -54
  108. package/client/utils/menu-room.ts +0 -33
  109. package/client/utils/open-page.ts +0 -21
  110. package/client/utils/pasted-table.ts +0 -145
  111. package/client/utils/pdf-pages.ts +0 -25
  112. package/client/utils/spreadsheet-text.ts +0 -125
  113. package/client/utils/workspace.ts +0 -89
  114. package/dist-client/bootstrap.js.map +0 -1
  115. package/dist-client/components/assistant-chat.js.map +0 -1
  116. package/dist-client/components/assistant-chat.test.d.ts +0 -1
  117. package/dist-client/components/assistant-chat.test.js +0 -138
  118. package/dist-client/components/assistant-chat.test.js.map +0 -1
  119. package/dist-client/components/assistant-dock.js.map +0 -1
  120. package/dist-client/components/assistant-invite.js.map +0 -1
  121. package/dist-client/components/assistant-mode.js.map +0 -1
  122. package/dist-client/components/assistant-mode.test.d.ts +0 -1
  123. package/dist-client/components/assistant-mode.test.js +0 -100
  124. package/dist-client/components/assistant-mode.test.js.map +0 -1
  125. package/dist-client/components/assistant-selection-bar.js.map +0 -1
  126. package/dist-client/components/assistant-selection-bar.test.d.ts +0 -1
  127. package/dist-client/components/assistant-selection-bar.test.js +0 -148
  128. package/dist-client/components/assistant-selection-bar.test.js.map +0 -1
  129. package/dist-client/components/assistant-session-manager.js.map +0 -1
  130. package/dist-client/components/assistant-session-toolbar.js.map +0 -1
  131. package/dist-client/components/chat-defaults.js.map +0 -1
  132. package/dist-client/components/chat-echo-dedup.js.map +0 -1
  133. package/dist-client/components/chat-echo-dedup.test.d.ts +0 -1
  134. package/dist-client/components/chat-echo-dedup.test.js +0 -223
  135. package/dist-client/components/chat-echo-dedup.test.js.map +0 -1
  136. package/dist-client/components/chat-input-builder.js.map +0 -1
  137. package/dist-client/components/chat-input-builder.test.d.ts +0 -1
  138. package/dist-client/components/chat-input-builder.test.js +0 -70
  139. package/dist-client/components/chat-input-builder.test.js.map +0 -1
  140. package/dist-client/components/chat-proposal-survival.test.d.ts +0 -1
  141. package/dist-client/components/chat-proposal-survival.test.js +0 -61
  142. package/dist-client/components/chat-proposal-survival.test.js.map +0 -1
  143. package/dist-client/components/entry-review.js.map +0 -1
  144. package/dist-client/components/markdown.js.map +0 -1
  145. package/dist-client/components/markdown.test.d.ts +0 -1
  146. package/dist-client/components/markdown.test.js +0 -418
  147. package/dist-client/components/markdown.test.js.map +0 -1
  148. package/dist-client/components/mention-popup-helpers.js.map +0 -1
  149. package/dist-client/components/mention-popup.js.map +0 -1
  150. package/dist-client/components/mention-popup.test.d.ts +0 -1
  151. package/dist-client/components/mention-popup.test.js +0 -474
  152. package/dist-client/components/mention-popup.test.js.map +0 -1
  153. package/dist-client/components/panel-aria.test.d.ts +0 -1
  154. package/dist-client/components/panel-aria.test.js +0 -53
  155. package/dist-client/components/panel-aria.test.js.map +0 -1
  156. package/dist-client/components/proposal-outcome-line.js.map +0 -1
  157. package/dist-client/components/proposal-request.test.d.ts +0 -1
  158. package/dist-client/components/proposal-request.test.js +0 -63
  159. package/dist-client/components/proposal-request.test.js.map +0 -1
  160. package/dist-client/components/reply-message.js.map +0 -1
  161. package/dist-client/components/reply-message.test.d.ts +0 -1
  162. package/dist-client/components/reply-message.test.js +0 -16
  163. package/dist-client/components/reply-message.test.js.map +0 -1
  164. package/dist-client/components/roster-identity.js.map +0 -1
  165. package/dist-client/components/roster-identity.test.d.ts +0 -1
  166. package/dist-client/components/roster-identity.test.js +0 -9
  167. package/dist-client/components/roster-identity.test.js.map +0 -1
  168. package/dist-client/components/workspace-view.js.map +0 -1
  169. package/dist-client/index.js.map +0 -1
  170. package/dist-client/pages/assistant-workspace-page.js.map +0 -1
  171. package/dist-client/route.js.map +0 -1
  172. package/dist-client/settings/agent-settings-model.js.map +0 -1
  173. package/dist-client/settings/ai-agent-setting-let.js.map +0 -1
  174. package/dist-client/settings/ai-usage-setting-let.d.ts +0 -25
  175. package/dist-client/settings/ai-usage-setting-let.js +0 -258
  176. package/dist-client/settings/ai-usage-setting-let.js.map +0 -1
  177. package/dist-client/settings/usage-model.d.ts +0 -32
  178. package/dist-client/settings/usage-model.js +0 -25
  179. package/dist-client/settings/usage-model.js.map +0 -1
  180. package/dist-client/setup-assistant-dock.js.map +0 -1
  181. package/dist-client/tsconfig.tsbuildinfo +0 -1
  182. package/dist-client/utils/addressed-draft.test.d.ts +0 -1
  183. package/dist-client/utils/addressed-draft.test.js +0 -27
  184. package/dist-client/utils/addressed-draft.test.js.map +0 -1
  185. package/dist-client/utils/agent-choice.js.map +0 -1
  186. package/dist-client/utils/applied-screens.js.map +0 -1
  187. package/dist-client/utils/assistant-activity.js.map +0 -1
  188. package/dist-client/utils/assistant-ask.js.map +0 -1
  189. package/dist-client/utils/assistant-ask.test.d.ts +0 -1
  190. package/dist-client/utils/assistant-ask.test.js +0 -40
  191. package/dist-client/utils/assistant-ask.test.js.map +0 -1
  192. package/dist-client/utils/assistant-capability-read.js.map +0 -1
  193. package/dist-client/utils/assistant-capability.js.map +0 -1
  194. package/dist-client/utils/assistant-capability.test.d.ts +0 -1
  195. package/dist-client/utils/assistant-capability.test.js +0 -16
  196. package/dist-client/utils/assistant-capability.test.js.map +0 -1
  197. package/dist-client/utils/assistant-navigation.js.map +0 -1
  198. package/dist-client/utils/assistant-navigation.test.d.ts +0 -1
  199. package/dist-client/utils/assistant-navigation.test.js +0 -63
  200. package/dist-client/utils/assistant-navigation.test.js.map +0 -1
  201. package/dist-client/utils/assistant-proposals.js.map +0 -1
  202. package/dist-client/utils/assistant-request-context.js.map +0 -1
  203. package/dist-client/utils/assistant-selection.js.map +0 -1
  204. package/dist-client/utils/assistant-selection.test.d.ts +0 -1
  205. package/dist-client/utils/assistant-selection.test.js +0 -46
  206. package/dist-client/utils/assistant-selection.test.js.map +0 -1
  207. package/dist-client/utils/assistant-session-actions.js.map +0 -1
  208. package/dist-client/utils/assistant-session-admin.js.map +0 -1
  209. package/dist-client/utils/assistant-session-controller.js.map +0 -1
  210. package/dist-client/utils/assistant-session-controller.test.d.ts +0 -1
  211. package/dist-client/utils/assistant-session-controller.test.js +0 -56
  212. package/dist-client/utils/assistant-session-controller.test.js.map +0 -1
  213. package/dist-client/utils/assistant-session-transport.js.map +0 -1
  214. package/dist-client/utils/assistant-surface.js.map +0 -1
  215. package/dist-client/utils/assistant-typing.js.map +0 -1
  216. package/dist-client/utils/assistant-typing.test.d.ts +0 -1
  217. package/dist-client/utils/assistant-typing.test.js +0 -30
  218. package/dist-client/utils/assistant-typing.test.js.map +0 -1
  219. package/dist-client/utils/attachment-policy.js.map +0 -1
  220. package/dist-client/utils/composer-frame.js.map +0 -1
  221. package/dist-client/utils/document-text.js.map +0 -1
  222. package/dist-client/utils/entry-hash.js.map +0 -1
  223. package/dist-client/utils/entry-proposal.js.map +0 -1
  224. package/dist-client/utils/entry-workspace.js.map +0 -1
  225. package/dist-client/utils/invite-proposal-register.js.map +0 -1
  226. package/dist-client/utils/invite-proposal.js.map +0 -1
  227. package/dist-client/utils/invite-proposal.test.d.ts +0 -1
  228. package/dist-client/utils/invite-proposal.test.js +0 -35
  229. package/dist-client/utils/invite-proposal.test.js.map +0 -1
  230. package/dist-client/utils/menu-room.js.map +0 -1
  231. package/dist-client/utils/open-page.js.map +0 -1
  232. package/dist-client/utils/pasted-table.js.map +0 -1
  233. package/dist-client/utils/pdf-pages.js.map +0 -1
  234. package/dist-client/utils/spreadsheet-text.js.map +0 -1
  235. package/dist-client/utils/workspace.js.map +0 -1
  236. package/dist-server/door-declaration-report.js.map +0 -1
  237. package/dist-server/index.js.map +0 -1
  238. package/dist-server/role-tasks.js.map +0 -1
  239. package/dist-server/service/ai-agent-resolver.js.map +0 -1
  240. package/dist-server/service/assistant-capability-resolver.js.map +0 -1
  241. package/dist-server/service/assistant-chat-resolver.js.map +0 -1
  242. package/dist-server/service/assistant-mode/assistant-mode-resolver.js.map +0 -1
  243. package/dist-server/service/assistant-mode/fallback-subjects.js.map +0 -1
  244. package/dist-server/service/assistant-mode/index.js.map +0 -1
  245. package/dist-server/service/assistant-mode/mode-categories.js.map +0 -1
  246. package/dist-server/service/assistant-mode/record-subject.js.map +0 -1
  247. package/dist-server/service/assistant-mode/registry.js.map +0 -1
  248. package/dist-server/service/assistant-mode/resolve.js.map +0 -1
  249. package/dist-server/service/assistant-mode/screen-rules.js.map +0 -1
  250. package/dist-server/service/assistant-mode/turn-lines.js.map +0 -1
  251. package/dist-server/service/assistant-mode/types.js.map +0 -1
  252. package/dist-server/service/chat-message/carried-turns.js.map +0 -1
  253. package/dist-server/service/chat-message/chat-message-broadcast.js.map +0 -1
  254. package/dist-server/service/chat-message/chat-message-publish.js.map +0 -1
  255. package/dist-server/service/chat-message/chat-message-room.js.map +0 -1
  256. package/dist-server/service/chat-message/chat-message-subscription.js.map +0 -1
  257. package/dist-server/service/chat-message/chat-message.js.map +0 -1
  258. package/dist-server/service/chat-message/chat-typing-subscription.js.map +0 -1
  259. package/dist-server/service/chat-message/chat-typing.js.map +0 -1
  260. package/dist-server/service/chat-message/door-access.js.map +0 -1
  261. package/dist-server/service/chat-message/fold-history.js.map +0 -1
  262. package/dist-server/service/chat-message/fold-session-history.js.map +0 -1
  263. package/dist-server/service/chat-message/history-summary.js.map +0 -1
  264. package/dist-server/service/chat-message/index.js.map +0 -1
  265. package/dist-server/service/chat-message/llm-history.js.map +0 -1
  266. package/dist-server/service/chat-message/message-doors.js.map +0 -1
  267. package/dist-server/service/chat-message/proposal-outcome.js.map +0 -1
  268. package/dist-server/service/chat-message/reader-gate.js.map +0 -1
  269. package/dist-server/service/chat-message/room-message.js.map +0 -1
  270. package/dist-server/service/chat-message/room-turn.js.map +0 -1
  271. package/dist-server/service/chat-message/used-tools.js.map +0 -1
  272. package/dist-server/service/chat-session/attachment-policy.js.map +0 -1
  273. package/dist-server/service/chat-session/attachment-route.js.map +0 -1
  274. package/dist-server/service/chat-session/attachment-tool-result.js.map +0 -1
  275. package/dist-server/service/chat-session/attachment-tools.js.map +0 -1
  276. package/dist-server/service/chat-session/chat-session.js.map +0 -1
  277. package/dist-server/service/chat-session/index.js.map +0 -1
  278. package/dist-server/service/chat-session/session-activity-broadcast.js.map +0 -1
  279. package/dist-server/service/chat-session/session-activity-publish.js.map +0 -1
  280. package/dist-server/service/chat-session/session-activity-subscription.js.map +0 -1
  281. package/dist-server/service/chat-session/session-anchor.js.map +0 -1
  282. package/dist-server/service/chat-session/session-attachments.js.map +0 -1
  283. package/dist-server/service/chat-session/session-cleanup.js.map +0 -1
  284. package/dist-server/service/chat-session/session-inbox.js.map +0 -1
  285. package/dist-server/service/chat-session/session-kind.js.map +0 -1
  286. package/dist-server/service/chat-session/session-name.js.map +0 -1
  287. package/dist-server/service/chat-session/session-purge.js.map +0 -1
  288. package/dist-server/service/chat-session/session-retention.js.map +0 -1
  289. package/dist-server/service/chat-session/session-visibility.js.map +0 -1
  290. package/dist-server/service/chat-session/session-write-gate.js.map +0 -1
  291. package/dist-server/service/chat-session/station-session-guard.js.map +0 -1
  292. package/dist-server/service/chat-session/turn-attachments.js.map +0 -1
  293. package/dist-server/service/chat-session-participant/chat-session-participant.js.map +0 -1
  294. package/dist-server/service/chat-session-participant/index.js.map +0 -1
  295. package/dist-server/service/chat-session-participant/invite-notification.js.map +0 -1
  296. package/dist-server/service/chat-session-participant/mention-invite.js.map +0 -1
  297. package/dist-server/service/chat-session-participant/participant-lookup-roles.js.map +0 -1
  298. package/dist-server/service/chat-session-participant/participant-lookup.js.map +0 -1
  299. package/dist-server/service/chat-session-participant/presence.js.map +0 -1
  300. package/dist-server/service/chat-session-participant/read-roster.js.map +0 -1
  301. package/dist-server/service/chat-session-resolver.js.map +0 -1
  302. package/dist-server/service/data-entry/entry-apply.js.map +0 -1
  303. package/dist-server/service/data-entry/entry-hash.js.map +0 -1
  304. package/dist-server/service/data-entry/entry-refusal.js.map +0 -1
  305. package/dist-server/service/data-entry/entry-resolver.js.map +0 -1
  306. package/dist-server/service/data-entry/entry-screen.js.map +0 -1
  307. package/dist-server/service/data-entry/entry-sources.js.map +0 -1
  308. package/dist-server/service/data-entry/entry-target.js.map +0 -1
  309. package/dist-server/service/data-entry/entry-tools.js.map +0 -1
  310. package/dist-server/service/data-entry/entry-update.js.map +0 -1
  311. package/dist-server/service/data-read/list-read.js.map +0 -1
  312. package/dist-server/service/data-read/read-target.js.map +0 -1
  313. package/dist-server/service/data-read/read-tools.js.map +0 -1
  314. package/dist-server/service/grounding-sources.js.map +0 -1
  315. package/dist-server/service/help-documents/help-keys.js.map +0 -1
  316. package/dist-server/service/help-documents/help-tools.js.map +0 -1
  317. package/dist-server/service/index.js.map +0 -1
  318. package/dist-server/service/people/index.js.map +0 -1
  319. package/dist-server/service/people/invite-tools.js.map +0 -1
  320. package/dist-server/service/people/people-keys.js.map +0 -1
  321. package/dist-server/service/people/people-read.js.map +0 -1
  322. package/dist-server/service/people/person-subject.js.map +0 -1
  323. package/dist-server/service/request-translator.js.map +0 -1
  324. package/dist-server/service/testing/conversation-script.js.map +0 -1
  325. package/dist-server/service/testing/mode-conformance.js.map +0 -1
  326. package/dist-server/service/tool-access.js.map +0 -1
  327. package/dist-server/service/types.js.map +0 -1
  328. package/dist-server/service/unattended-run/assistant-run.js.map +0 -1
  329. package/dist-server/service/unattended-run/index.js.map +0 -1
  330. package/dist-server/service/unattended-run/limits.js.map +0 -1
  331. package/dist-server/service/unattended-run/run-as.js.map +0 -1
  332. package/dist-server/service/unattended-run/run-budget.js.map +0 -1
  333. package/dist-server/service/unattended-run/run-ledger.js.map +0 -1
  334. package/dist-server/service/unattended-run/run-outcome.js.map +0 -1
  335. package/dist-server/service/unattended-run/run-store.js.map +0 -1
  336. package/dist-server/service/unattended-run/run-unattended.js.map +0 -1
  337. package/dist-server/service/unattended-run/unattended-prompt.js.map +0 -1
  338. package/dist-server/service/workspace/workspace-blocks.js.map +0 -1
  339. package/dist-server/service/workspace/workspace-tools.js.map +0 -1
  340. package/dist-server/tool-registry-boot-report.js.map +0 -1
  341. package/dist-server/tsconfig.tsbuildinfo +0 -1
  342. package/docs/session-controller.md +0 -52
  343. package/server/door-declaration-report.test.ts +0 -53
  344. package/server/door-declaration-report.ts +0 -61
  345. package/server/explicit-graphql-types.test.ts +0 -56
  346. package/server/index.ts +0 -36
  347. package/server/role-tasks.ts +0 -14
  348. package/server/service/ai-agent-resolver.ts +0 -330
  349. package/server/service/assistant-capability-resolver.ts +0 -66
  350. package/server/service/assistant-chat-resolver.ts +0 -640
  351. package/server/service/assistant-mode/assistant-mode-resolver.ts +0 -101
  352. package/server/service/assistant-mode/conversation-category.test.ts +0 -48
  353. package/server/service/assistant-mode/fallback-subjects.ts +0 -36
  354. package/server/service/assistant-mode/index.ts +0 -22
  355. package/server/service/assistant-mode/mode-categories.ts +0 -178
  356. package/server/service/assistant-mode/mode-front.test.ts +0 -181
  357. package/server/service/assistant-mode/one-conversation-per-subject.test.ts +0 -37
  358. package/server/service/assistant-mode/open-subject-door.test.ts +0 -52
  359. package/server/service/assistant-mode/record-subject.test.ts +0 -41
  360. package/server/service/assistant-mode/record-subject.ts +0 -44
  361. package/server/service/assistant-mode/registry.test.ts +0 -171
  362. package/server/service/assistant-mode/registry.ts +0 -139
  363. package/server/service/assistant-mode/resolve.test.ts +0 -129
  364. package/server/service/assistant-mode/resolve.ts +0 -113
  365. package/server/service/assistant-mode/screen-rules.test.ts +0 -99
  366. package/server/service/assistant-mode/screen-rules.ts +0 -103
  367. package/server/service/assistant-mode/turn-lines.ts +0 -43
  368. package/server/service/assistant-mode/types.ts +0 -138
  369. package/server/service/chat-message/carried-turns.test.ts +0 -80
  370. package/server/service/chat-message/carried-turns.ts +0 -112
  371. package/server/service/chat-message/chat-message-broadcast.integration.test.ts +0 -73
  372. package/server/service/chat-message/chat-message-broadcast.test.ts +0 -40
  373. package/server/service/chat-message/chat-message-broadcast.ts +0 -70
  374. package/server/service/chat-message/chat-message-publish.ts +0 -22
  375. package/server/service/chat-message/chat-message-room.test.ts +0 -145
  376. package/server/service/chat-message/chat-message-room.ts +0 -50
  377. package/server/service/chat-message/chat-message-subscription.ts +0 -77
  378. package/server/service/chat-message/chat-message.ts +0 -289
  379. package/server/service/chat-message/chat-typing-subscription.ts +0 -52
  380. package/server/service/chat-message/chat-typing.test.ts +0 -45
  381. package/server/service/chat-message/chat-typing.ts +0 -48
  382. package/server/service/chat-message/door-access.test.ts +0 -72
  383. package/server/service/chat-message/door-access.ts +0 -65
  384. package/server/service/chat-message/fold-history-window.test.ts +0 -184
  385. package/server/service/chat-message/fold-history.test.ts +0 -98
  386. package/server/service/chat-message/fold-history.ts +0 -77
  387. package/server/service/chat-message/fold-session-history.test.ts +0 -116
  388. package/server/service/chat-message/fold-session-history.ts +0 -115
  389. package/server/service/chat-message/history-summary.test.ts +0 -127
  390. package/server/service/chat-message/history-summary.ts +0 -100
  391. package/server/service/chat-message/index.ts +0 -13
  392. package/server/service/chat-message/llm-history.test.ts +0 -245
  393. package/server/service/chat-message/llm-history.ts +0 -182
  394. package/server/service/chat-message/message-doors.test.ts +0 -124
  395. package/server/service/chat-message/message-doors.ts +0 -137
  396. package/server/service/chat-message/proposal-outcome.test.ts +0 -111
  397. package/server/service/chat-message/proposal-outcome.ts +0 -99
  398. package/server/service/chat-message/reader-gate.ts +0 -44
  399. package/server/service/chat-message/room-message.test.ts +0 -21
  400. package/server/service/chat-message/room-message.ts +0 -22
  401. package/server/service/chat-message/room-turn.ts +0 -42
  402. package/server/service/chat-message/used-tools.test.ts +0 -19
  403. package/server/service/chat-message/used-tools.ts +0 -25
  404. package/server/service/chat-session/attachment-policy.test.ts +0 -42
  405. package/server/service/chat-session/attachment-policy.ts +0 -91
  406. package/server/service/chat-session/attachment-route.ts +0 -45
  407. package/server/service/chat-session/attachment-tool-result.test.ts +0 -63
  408. package/server/service/chat-session/attachment-tool-result.ts +0 -37
  409. package/server/service/chat-session/attachment-tools.ts +0 -66
  410. package/server/service/chat-session/chat-session.ts +0 -244
  411. package/server/service/chat-session/group-room.test.ts +0 -233
  412. package/server/service/chat-session/index.ts +0 -5
  413. package/server/service/chat-session/session-activity-broadcast.ts +0 -77
  414. package/server/service/chat-session/session-activity-publish.ts +0 -49
  415. package/server/service/chat-session/session-activity-receivers.test.ts +0 -26
  416. package/server/service/chat-session/session-activity-subscription.ts +0 -66
  417. package/server/service/chat-session/session-anchor.ts +0 -142
  418. package/server/service/chat-session/session-attachments.ts +0 -90
  419. package/server/service/chat-session/session-cleanup.test.ts +0 -83
  420. package/server/service/chat-session/session-cleanup.ts +0 -69
  421. package/server/service/chat-session/session-inbox.test.ts +0 -273
  422. package/server/service/chat-session/session-inbox.ts +0 -240
  423. package/server/service/chat-session/session-kind.test.ts +0 -24
  424. package/server/service/chat-session/session-kind.ts +0 -32
  425. package/server/service/chat-session/session-name.ts +0 -32
  426. package/server/service/chat-session/session-purge.test.ts +0 -24
  427. package/server/service/chat-session/session-purge.ts +0 -117
  428. package/server/service/chat-session/session-retention.ts +0 -17
  429. package/server/service/chat-session/session-visibility.test.ts +0 -130
  430. package/server/service/chat-session/session-visibility.ts +0 -68
  431. package/server/service/chat-session/session-write-gate.test.ts +0 -59
  432. package/server/service/chat-session/session-write-gate.ts +0 -31
  433. package/server/service/chat-session/station-session-guard.ts +0 -25
  434. package/server/service/chat-session/turn-attachments.test.ts +0 -106
  435. package/server/service/chat-session/turn-attachments.ts +0 -45
  436. package/server/service/chat-session-participant/chat-session-participant.ts +0 -135
  437. package/server/service/chat-session-participant/index.ts +0 -8
  438. package/server/service/chat-session-participant/invite-notification.test.ts +0 -80
  439. package/server/service/chat-session-participant/invite-notification.ts +0 -118
  440. package/server/service/chat-session-participant/mention-invite.test.ts +0 -173
  441. package/server/service/chat-session-participant/mention-invite.ts +0 -180
  442. package/server/service/chat-session-participant/participant-lookup-roles.ts +0 -6
  443. package/server/service/chat-session-participant/participant-lookup.ts +0 -22
  444. package/server/service/chat-session-participant/presence.test.ts +0 -39
  445. package/server/service/chat-session-participant/presence.ts +0 -21
  446. package/server/service/chat-session-participant/read-roster.test.ts +0 -27
  447. package/server/service/chat-session-participant/read-roster.ts +0 -17
  448. package/server/service/chat-session-resolver.ts +0 -1455
  449. package/server/service/data-entry/data-entry-update.test.ts +0 -378
  450. package/server/service/data-entry/data-entry.test.ts +0 -494
  451. package/server/service/data-entry/entry-apply.ts +0 -247
  452. package/server/service/data-entry/entry-hash.ts +0 -35
  453. package/server/service/data-entry/entry-refusal.test.ts +0 -73
  454. package/server/service/data-entry/entry-refusal.ts +0 -20
  455. package/server/service/data-entry/entry-resolver.ts +0 -74
  456. package/server/service/data-entry/entry-screen.ts +0 -14
  457. package/server/service/data-entry/entry-sources.ts +0 -39
  458. package/server/service/data-entry/entry-target.ts +0 -774
  459. package/server/service/data-entry/entry-tools.ts +0 -282
  460. package/server/service/data-entry/entry-update.ts +0 -238
  461. package/server/service/data-read/data-read.test.ts +0 -395
  462. package/server/service/data-read/detail-lists.test.ts +0 -61
  463. package/server/service/data-read/list-missing.test.ts +0 -49
  464. package/server/service/data-read/list-read.ts +0 -146
  465. package/server/service/data-read/list-status.test.ts +0 -46
  466. package/server/service/data-read/read-target.ts +0 -510
  467. package/server/service/data-read/read-tools.ts +0 -334
  468. package/server/service/data-read/read-words.test.ts +0 -99
  469. package/server/service/data-read/record-keys.test.ts +0 -42
  470. package/server/service/grounding-sources.test.ts +0 -55
  471. package/server/service/grounding-sources.ts +0 -46
  472. package/server/service/help-documents/help-keys.ts +0 -2
  473. package/server/service/help-documents/help-tools.test.ts +0 -40
  474. package/server/service/help-documents/help-tools.ts +0 -88
  475. package/server/service/index.ts +0 -99
  476. package/server/service/people/index.ts +0 -15
  477. package/server/service/people/invite-tools.ts +0 -159
  478. package/server/service/people/invite.test.ts +0 -159
  479. package/server/service/people/people-keys.ts +0 -16
  480. package/server/service/people/people-read.test.ts +0 -82
  481. package/server/service/people/people-read.ts +0 -56
  482. package/server/service/people/person-subject.test.ts +0 -163
  483. package/server/service/people/person-subject.ts +0 -88
  484. package/server/service/request-translator.test.ts +0 -45
  485. package/server/service/request-translator.ts +0 -33
  486. package/server/service/session-anchor.test.ts +0 -198
  487. package/server/service/station-session-guard.test.ts +0 -31
  488. package/server/service/testing/conversation-scenario.test.ts +0 -164
  489. package/server/service/testing/conversation-script.test.ts +0 -133
  490. package/server/service/testing/conversation-script.ts +0 -296
  491. package/server/service/testing/mode-conformance.test.ts +0 -61
  492. package/server/service/testing/mode-conformance.ts +0 -165
  493. package/server/service/tool-access.test.ts +0 -96
  494. package/server/service/tool-access.ts +0 -36
  495. package/server/service/types.ts +0 -15
  496. package/server/service/unattended-run/assistant-run.ts +0 -199
  497. package/server/service/unattended-run/index.ts +0 -10
  498. package/server/service/unattended-run/limits.ts +0 -24
  499. package/server/service/unattended-run/run-as.ts +0 -38
  500. package/server/service/unattended-run/run-budget.ts +0 -58
  501. package/server/service/unattended-run/run-ledger.ts +0 -31
  502. package/server/service/unattended-run/run-outcome.ts +0 -43
  503. package/server/service/unattended-run/run-store-race.pg.test.ts +0 -83
  504. package/server/service/unattended-run/run-store.ts +0 -162
  505. package/server/service/unattended-run/run-unattended.test.ts +0 -478
  506. package/server/service/unattended-run/run-unattended.ts +0 -248
  507. package/server/service/unattended-run/unattended-prompt.ts +0 -24
  508. package/server/service/workspace/workspace-blocks.ts +0 -134
  509. package/server/service/workspace/workspace-tools.ts +0 -108
  510. package/server/service/workspace/workspace.test.ts +0 -74
  511. package/server/tool-registry-boot-report.test.ts +0 -41
  512. package/server/tool-registry-boot-report.ts +0 -63
  513. package/test/ai-agent-settings.test.ts +0 -123
  514. package/test/applied-screens.test.ts +0 -65
  515. package/test/assistant-chat-call-sites.test.ts +0 -92
  516. package/test/assistant-dock.test.ts +0 -294
  517. package/test/assistant-request-context.test.ts +0 -72
  518. package/test/assistant-session-controller.test.ts +0 -87
  519. package/test/assistant-session-manager.test.ts +0 -186
  520. package/test/assistant-session-toolbar.test.ts +0 -43
  521. package/test/attachment-one-rule.test.ts +0 -46
  522. package/test/attachment-policy-agree.test.ts +0 -38
  523. package/test/composer-frame.test.ts +0 -173
  524. package/test/document-text.test.ts +0 -175
  525. package/test/entry-card-styles.test.ts +0 -18
  526. package/test/entry-proposal.test.ts +0 -186
  527. package/test/entry-workspace.test.ts +0 -89
  528. package/test/menu-room.test.ts +0 -33
  529. package/test/open-doors.test.ts +0 -164
  530. package/test/open-page.test.ts +0 -31
  531. package/test/pasted-table.test.ts +0 -147
  532. package/test/refusals-in-korean.test.ts +0 -80
  533. package/test/session-discovery.test.ts +0 -43
  534. package/test/spreadsheet-text.test.ts +0 -92
  535. package/test/translations.test.ts +0 -80
  536. package/test/workspace.test.ts +0 -54
  537. package/tsconfig.json +0 -9
@@ -1,86 +0,0 @@
1
- /*
2
- * What this guards: **the two doors take different inputs, and neither one leaks into the other.**
3
- *
4
- * The chat component talks to one of two server operations. `boardAIChat` is board authoring and
5
- * carries the board model; `assistantChat` is for a surface with no document of its own. Sending
6
- * a board field to the neutral door, or dropping a required one, produces a GraphQL error the
7
- * user sees as "the assistant is broken".
8
- *
9
- * The required system prompt is the one that would be silent. A conversation with no persona
10
- * still answers — as nobody, on a surface that never said what it is — and that reads as a poor
11
- * model rather than a missing argument.
12
- */
13
- import { buildAssistantChatInput, buildChatMutationInput } from './chat-input-builder'
14
-
15
- const history = [{ role: 'user', content: 'what figures do we have' }]
16
-
17
- const args = (over: any = {}) => ({ history, mode: { kind: 'figure.modeller', target: 'fig-1' }, ...over })
18
-
19
- describe('the neutral door carries no document', () => {
20
- it('★ no board field reaches assistantChat', () => {
21
- const input = buildAssistantChatInput(args({ sessionId: 's-1' }))
22
-
23
- for (const field of ['currentBoard', 'selectedRefids', 'boardTools', 'knownTypes', 'componentSchemas', 'scopes', 'mentions']) {
24
- expect(input).not.toHaveProperty(field)
25
- }
26
- })
27
-
28
- it('carries the conversation, the session and which conversation this is', () => {
29
- const input = buildAssistantChatInput(args({ sessionId: 's-1' }))
30
-
31
- expect(input.sessionId).toBe('s-1')
32
- expect(input.messages).toBe(history)
33
- expect(input.mode).toEqual({ kind: 'figure.modeller', target: 'fig-1' })
34
- })
35
-
36
- it('★ the persona, the tools and the limits are not on the wire — they are the server\'s', () => {
37
- const input = buildAssistantChatInput(args({ sessionId: 's-1' }))
38
-
39
- for (const field of ['systemPrompt', 'toolCategories', 'model', 'temperature', 'maxTokens', 'requireGroundingTools']) {
40
- expect(input).not.toHaveProperty(field)
41
- }
42
- })
43
-
44
- it('★ the open page goes along - the server offers that screen\'s tools first (ADR-0061 decision 9)', () => {
45
- expect(buildAssistantChatInput(args({ page: 'cash-transaction-list' })).page).toBe('cash-transaction-list')
46
- expect(buildAssistantChatInput(args())).not.toHaveProperty('page')
47
- })
48
-
49
- it('a one-off question has no session — null, not absent, so the server reads it as ad-hoc', () => {
50
- expect(buildAssistantChatInput(args()).sessionId).toBeNull()
51
- })
52
- })
53
-
54
- describe('the mode is required', () => {
55
- it('★ refuses a turn with no mode instead of sending one', () => {
56
- expect(() => buildAssistantChatInput(args({ mode: { kind: '' } }))).toThrow(/mode.kind is required/)
57
- expect(() => buildAssistantChatInput(args({ mode: { kind: ' ' } }))).toThrow(/mode.kind is required/)
58
- expect(() => buildAssistantChatInput(args({ mode: undefined }))).toThrow(/mode.kind is required/)
59
- })
60
-
61
- it('a conversation about nothing in particular carries no target', () => {
62
- expect(buildAssistantChatInput(args({ mode: { kind: 'twin.none' } })).mode).toEqual({ kind: 'twin.none' })
63
- })
64
- })
65
-
66
- describe('optional fields are sent only when they mean something', () => {
67
-
68
- it('host context and truncation travel when given', () => {
69
- const input = buildAssistantChatInput(args({ hostContext: { figureId: 'fig-1' }, truncateAfterMessageId: 'm-9' }))
70
-
71
- expect(input.hostContext).toEqual({ figureId: 'fig-1' })
72
- expect(input.truncateAfterMessageId).toBe('m-9')
73
- })
74
- })
75
-
76
- describe('the board door is unchanged', () => {
77
- it('★ still carries selectedRefids — a missing one was why the AI did not know what was selected', () => {
78
- const input = buildChatMutationInput({ history, liveBoard: null, selectedRefids: [3, 7] } as any)
79
- expect(input.selectedRefids).toEqual([3, 7])
80
- })
81
-
82
- it('does not take a system prompt — the board conversation has its persona on the server', () => {
83
- const input = buildChatMutationInput({ history, liveBoard: null, selectedRefids: [] } as any)
84
- expect(input).not.toHaveProperty('systemPrompt')
85
- })
86
- })
@@ -1,133 +0,0 @@
1
- /**
2
- * boardAIChat GraphQL mutation 의 input 객체 빌더.
3
- *
4
- * board-ai-chat.ts (Lit / Material Web 의존) 와 분리 — pure 함수만 두면 jest 의 node
5
- * 환경에서도 import 가능. 회귀 테스트 (selectedRefids 누락 등) 가 단위 테스트로 잠긴다.
6
- */
7
-
8
- export interface ChatMutationInputArgs {
9
- sessionId?: string
10
- history: Array<{ role: string; content: string }>
11
- liveBoard: any
12
- scopes?: string[]
13
- /** 편집으로 접은 지점(마지막으로 남긴 서버 메시지 id) — 서버가 그 뒤 이력을 에이전트 문맥에서 뺀다. */
14
- truncateAfterMessageId?: string
15
- /** 이 대화면이 무엇을 보고 있는지(예: { spaceId }) — 도구가 대상을 알 수 있게. 없으면 모델이 식별자를 되묻는다. */
16
- hostContext?: any
17
- /**
18
- * 이 대화면이 쓸 수 있는 외부 도구 카테고리(registerToolCategory 이름).
19
- * 미지정 = 등록된 전부(현행 동작). 지정하면 정의와 **실행** 모두 그 범위로 제한된다.
20
- */
21
- toolCategories?: string[]
22
- /** 코어 보드 편집 도구(addComponent·스타일링·씬 조작) 사용 여부. 기본 true. */
23
- boardTools?: boolean
24
- /**
25
- * 첫 턴에 도구 호출을 강제할지 — 라이브 상태를 다루는 대화면에서 켠다.
26
- * 근거 없이 상태를 단언하는 답(도구를 아예 부르지 않은 답)을 원천에서 막는다.
27
- */
28
- requireGroundingTools?: boolean
29
- knownTypes?: string[]
30
- categories?: string[]
31
- componentSchemas?: any
32
- /**
33
- * 선택된 컴포넌트의 `refid` 배열 — things-scene universal numeric handle.
34
- * id (데이터 바인딩 이름) 와는 다른 개념.
35
- */
36
- selectedRefids: number[]
37
- /**
38
- * popup 에서 명시 선택한 #mention 매핑 — {token, refid}.
39
- * 사용자 textarea 에는 #token 만 보이고, 정확한 refid 는 이 별도 채널로 server 에 전달.
40
- * server 가 mention map 으로 LLM 에 정확한 refid 정보 첨부 (사용자 노출 0).
41
- */
42
- mentions?: Array<{ token: string; refid: number }>
43
- /**
44
- * The registered conversation this board chat is (ADR-0061 decision 7). When sent, the server
45
- * takes the persona, tool categories, model and limits from that mode and ignores the per-request
46
- * ones above. Omitted for a surface that declares no mode.
47
- */
48
- mode?: { kind: string; target?: string }
49
- /** The AI agent the person picked. Omitted, the domain default answers. */
50
- agentId?: string
51
- }
52
-
53
- /**
54
- * GraphQL mutation 의 input 객체를 빌드.
55
- *
56
- * 핵심 보호 — `selectedRefids` 가 항상 포함되어야 한다. 누락이 사용자에게 보고된
57
- * "AI 가 선택된 컴포넌트를 모른다" 의 root cause 였다.
58
- */
59
- export function buildChatMutationInput(args: ChatMutationInputArgs): Record<string, any> {
60
- return {
61
- sessionId: args.sessionId ?? null,
62
- messages: args.history,
63
- currentBoard: args.liveBoard ?? null,
64
- scopes: args.scopes,
65
- ...(args.truncateAfterMessageId ? { truncateAfterMessageId: args.truncateAfterMessageId } : {}),
66
- ...(args.hostContext ? { hostContext: args.hostContext } : {}),
67
- /* 미지정은 서버 기본(전부 허용)에 맡긴다 — null 을 보내 굳이 덮어쓰지 않는다. */
68
- ...(args.toolCategories ? { toolCategories: args.toolCategories } : {}),
69
- ...(args.boardTools === false ? { boardTools: false } : {}),
70
- ...(args.requireGroundingTools ? { requireGroundingTools: true } : {}),
71
- knownTypes: args.knownTypes,
72
- categories: args.categories,
73
- componentSchemas: args.componentSchemas,
74
- selectedRefids: args.selectedRefids,
75
- ...(args.mentions && args.mentions.length > 0 && { mentions: args.mentions }),
76
- ...(args.mode?.kind ? { mode: { kind: args.mode.kind, ...(args.mode.target ? { target: args.mode.target } : {}) } } : {}),
77
- ...(args.agentId ? { agentId: args.agentId } : {})
78
- }
79
- }
80
-
81
- /**
82
- * Input for `assistantChat` — the door for a surface that has no document of its own.
83
- *
84
- * Deliberately a separate builder rather than a flag on the one above. The two mutations take
85
- * different inputs, and folding them together would mean a board field reaching a surface that
86
- * has no board, or a required field going missing with nothing to notice it. The one thing they
87
- * share is the conversation, and that is passed the same way.
88
- */
89
- export interface AssistantChatInputArgs {
90
- sessionId?: string
91
- history: Array<{ role: string; content: string }>
92
- /**
93
- * Which conversation this is and what it is about. The persona, the tool categories, the model
94
- * and the limits belong to the mode the app server registered (ADR-0061 decision 7) — a caller
95
- * that could choose its own tool categories was a caller choosing its own authority.
96
- */
97
- mode: { kind: string; target?: string }
98
- truncateAfterMessageId?: string
99
- hostContext?: any
100
- /** Files stored with the conversation by attachToConversation, sent with this turn. */
101
- attachmentIds?: string[]
102
- /** The AI agent the person picked. Omitted, the domain default answers. */
103
- agentId?: string
104
- /** The route of the page the dock is on - the server offers that screen's tools first (ADR-0061 decision 9). */
105
- page?: string
106
- }
107
-
108
- /**
109
- * Build the neutral input.
110
- *
111
- * Refuses a conversation with no mode instead of sending one. A turn with no mode has no persona
112
- * and no tools, and an answer given as nobody reads like a bad model rather than a missing
113
- * argument — the server refuses it too, and this says so where the surface is.
114
- */
115
- export function buildAssistantChatInput(args: AssistantChatInputArgs): Record<string, any> {
116
- if (!args.mode?.kind?.trim()) {
117
- throw new Error(
118
- '[ox-assistant-chat] mode.kind is required when the chat talks to assistantChat — the app server ' +
119
- 'registers the mode and the screen names it (ADR-0061 decision 7)'
120
- )
121
- }
122
-
123
- return {
124
- sessionId: args.sessionId ?? null,
125
- messages: args.history,
126
- mode: { kind: args.mode.kind, ...(args.mode.target ? { target: args.mode.target } : {}) },
127
- ...(args.truncateAfterMessageId ? { truncateAfterMessageId: args.truncateAfterMessageId } : {}),
128
- ...(args.hostContext ? { hostContext: args.hostContext } : {}),
129
- ...(args.attachmentIds?.length ? { attachmentIds: args.attachmentIds } : {}),
130
- ...(args.agentId ? { agentId: args.agentId } : {}),
131
- ...(args.page ? { page: args.page } : {})
132
- }
133
- }
@@ -1,73 +0,0 @@
1
- /*
2
- * What this guards: the one thing a turn carries that is never stored — its proposals — survives
3
- * the race between the broadcast echo and the mutation's own answer.
4
- *
5
- * A proposal card exists only in the mutation result. The reply, the tool usages and the grounding
6
- * warnings are all in the database, so any path that rebuilds a line from the broadcast looks
7
- * right on screen and silently drops the one thing the person can act on. That shipped once
8
- * before (the comment in chat-echo-dedup remembers it), and on 2026-09-18 the twin saw it again:
9
- * `proposals` came back with one item and the line on screen had no `proposals` field at all.
10
- */
11
- import { receiveRemoteMessage, reconcileSentLine } from './chat-echo-dedup'
12
-
13
- const pending = (localId: string) => ({ role: 'assistant', content: '', pending: true, _localId: localId }) as any
14
- const echo = (id: string) => ({ id, role: 'assistant', content: 'placed at the centre', toolUsagesJson: [{ name: 'proposeSceneEdit' }] }) as any
15
- const answer = { proposals: [{ tool: 'proposeSceneEdit', proposed: true, kind: 'scene-edit' }], toolUsages: [{ name: 'proposeSceneEdit' }], content: 'placed at the centre', pending: false }
16
-
17
- it('★ echo first, then the answer — the card survives', () => {
18
- const absorbed = receiveRemoteMessage([pending('local-1-a')], new Set(), echo('server-1'))!
19
- const settled = reconcileSentLine(absorbed.lines, absorbed.seen, 'local-1-a', 'server-1', answer as any)
20
-
21
- expect(settled.lines).toHaveLength(1)
22
- expect((settled.lines[0] as any).proposals).toHaveLength(1)
23
- })
24
-
25
- it('★ the answer first, then the echo — the card survives', () => {
26
- const settled = reconcileSentLine([pending('local-1-a')], new Set(), 'local-1-a', 'server-1', answer as any)
27
- const after = receiveRemoteMessage(settled.lines, settled.seen, echo('server-1'))
28
-
29
- /* The echo is already known; it must not append a second line, and it must not replace this one. */
30
- const lines = after ? after.lines : settled.lines
31
- expect(lines).toHaveLength(1)
32
- expect((lines[0] as any).proposals).toHaveLength(1)
33
- })
34
-
35
- it('★ the pending line is gone when the echo arrives — the answer still finds its message', () => {
36
- /*
37
- * This is the shape the twin saw on 2026-09-18: a line carrying exactly what the database has,
38
- * no `proposals` field at all, while the response had one. It happens when the pending line is
39
- * no longer in `lines` by the time the echo arrives, and the echo is appended as a new line.
40
- *
41
- * The answer knows which stored message it is (`assistantMessageId`), so it merges there. What
42
- * it must never do is return with the card nowhere: the model tells the person to press a button
43
- * that does not exist.
44
- */
45
- const appended = receiveRemoteMessage([], new Set(), echo('server-1'))!
46
- expect((appended.lines[0] as any).proposals).toBeUndefined()
47
-
48
- const settled = reconcileSentLine(appended.lines, appended.seen, 'local-1-a', 'server-1', answer as any)
49
-
50
- expect(settled.lines).toHaveLength(1)
51
- expect((settled.lines[0] as any).proposals).toHaveLength(1)
52
- expect((settled.lines[0] as any).id).toBe('server-1')
53
- })
54
-
55
- it('★ the echo was appended beside a pending line — the card lands on the message that stays', () => {
56
- /*
57
- * The duplicate branch used to drop the local line and the answer with it. Everything the
58
- * database holds was already on the echo line, so the screen looked complete and only the card
59
- * was missing — the exact defect the absorption path exists to prevent.
60
- */
61
- const withBoth = { lines: [pending('local-1-a'), { id: 'server-1', role: 'assistant', content: 'placed at the centre' }], seen: new Set(['server-1']) }
62
-
63
- const settled = reconcileSentLine(withBoth.lines as any, withBoth.seen, 'local-1-a', 'server-1', answer as any)
64
-
65
- expect(settled.lines).toHaveLength(1)
66
- expect((settled.lines[0] as any).proposals).toHaveLength(1)
67
- })
68
-
69
- it('a turn with nothing to merge into is left alone — no line is invented', () => {
70
- const settled = reconcileSentLine([], new Set(), 'local-1-a', 'server-9', answer as any)
71
-
72
- expect(settled.lines).toEqual([])
73
- })
@@ -1,346 +0,0 @@
1
- /*
2
- * The rows of a data entry proposal, as the person reviews them (operato-application/design/ai/data-entry.md §5).
3
- *
4
- * Read-only on purpose: a correction is said in the conversation ("row 2 is 12,000", "drop the last one")
5
- * and the model proposes again. What is wrong in a cell is marked on the cell - blocking in the error
6
- * colour, a note in the outline - and where each row came from is on the row.
7
- */
8
- import '@material/web/icon/icon.js'
9
-
10
- import { LitElement, css, html, nothing } from 'lit'
11
- import { customElement, property } from 'lit/decorators.js'
12
-
13
- import { i18next } from '@operato/i18n'
14
- import { ScrollbarStyles } from '@operato/styles'
15
-
16
- import { entryCellIssues, entryIssueKey, type EntryIssueView, type EntryRowView, type EntryTotalView } from '../utils/entry-proposal.js'
17
-
18
- const SHOWN = 50
19
-
20
- const t = (key: string, defaultValue: string, options: Record<string, unknown> = {}) =>
21
- i18next.t(`ai-assistant.entry.${key}`, { defaultValue, ...options })
22
-
23
- function issueText(issue: EntryIssueView): string {
24
- const params = { ...(issue.params ?? {}) } as any
25
- if (Array.isArray(params.values)) params.values = params.values.join(', ')
26
- /* A code inside the message is worded by the key the application named for it. */
27
- for (const [name, prefix] of Object.entries(issue.paramKeys ?? {}))
28
- if (typeof params[name] === 'string' && params[name]) params[name] = String(i18next.t(`${prefix}${params[name].toLowerCase()}`, { defaultValue: params[name] }))
29
- return String(i18next.t(entryIssueKey(issue), { defaultValue: issue.code, ...params }))
30
- }
31
-
32
- /** Where a row came from, in the screen's words - "said in the conversation" is the framework's, never the model's English. */
33
- function sourceText(source: { attachmentId?: string; where?: string; person?: boolean }): string {
34
- if (source.person) return t('source-person', 'said in the conversation')
35
- return source.where || source.attachmentId || ''
36
- }
37
-
38
- /** An enum value in the person's words when the target names its key - the code only when it does not. */
39
- function valueOf(column: { valueKeyPrefix?: string }, value: unknown): string {
40
- if (column.valueKeyPrefix && typeof value === 'string' && value) return String(i18next.t(`${column.valueKeyPrefix}${value.toLowerCase()}`, { defaultValue: value }))
41
- return shown(value)
42
- }
43
-
44
- function shown(value: unknown): string {
45
- if (value === undefined || value === null) return ''
46
- /* A reference: the record's name the server found, or the text that found none. */
47
- if (typeof value === 'object') return String((value as any).label ?? (value as any).text ?? (value as any).id ?? '')
48
- if (typeof value === 'number') return value.toLocaleString(i18next.language || undefined)
49
- if (typeof value === 'boolean') return value ? '✓' : '—'
50
- return String(value)
51
- }
52
-
53
- @customElement('ox-assistant-entry-review')
54
- export class AssistantEntryReview extends LitElement {
55
- /* The inner scroll areas wear the standard scrollbar, as the dock does. */
56
- static styles = [
57
- ScrollbarStyles,
58
- css`
59
- :host {
60
- display: block;
61
- margin: 4px 0 2px;
62
- font-size: 12px;
63
- color: var(--md-sys-color-on-surface);
64
- }
65
-
66
- .summary {
67
- display: flex;
68
- flex-wrap: wrap;
69
- gap: 4px 10px;
70
- margin-bottom: 6px;
71
- color: var(--md-sys-color-on-surface-variant);
72
- }
73
-
74
- .summary .blocked {
75
- color: var(--md-sys-color-error);
76
- font-weight: 600;
77
- }
78
-
79
- .scroll {
80
- max-height: 320px;
81
- overflow: auto;
82
- border: 1px solid var(--md-sys-color-outline-variant);
83
- border-radius: 6px;
84
- }
85
-
86
- table {
87
- width: 100%;
88
- border-collapse: collapse;
89
- }
90
-
91
- th,
92
- td {
93
- padding: 4px 6px;
94
- border-bottom: 1px solid var(--md-sys-color-outline-variant);
95
- text-align: start;
96
- vertical-align: top;
97
- white-space: nowrap;
98
- }
99
-
100
- th {
101
- position: sticky;
102
- top: 0;
103
- background: var(--md-sys-color-surface-container);
104
- font-weight: 600;
105
- }
106
-
107
- td.num {
108
- text-align: end;
109
- font-variant-numeric: tabular-nums;
110
- }
111
-
112
- tr.blocked td {
113
- background: color-mix(in srgb, var(--md-sys-color-error) 6%, transparent);
114
- }
115
-
116
- td.bad {
117
- color: var(--md-sys-color-error);
118
- text-decoration: underline wavy var(--md-sys-color-error);
119
- text-underline-offset: 3px;
120
- }
121
-
122
- td.note {
123
- text-decoration: underline dotted var(--md-sys-color-outline);
124
- text-underline-offset: 3px;
125
- }
126
-
127
- .before {
128
- color: var(--md-sys-color-on-surface-variant);
129
- text-decoration: line-through;
130
- }
131
-
132
- .missing {
133
- color: var(--md-sys-color-error);
134
- font-style: italic;
135
- }
136
-
137
- .source {
138
- color: var(--md-sys-color-on-surface-variant);
139
- max-width: 180px;
140
- overflow: hidden;
141
- text-overflow: ellipsis;
142
- }
143
-
144
- .row-issue {
145
- display: block;
146
- color: var(--md-sys-color-on-surface-variant);
147
- white-space: normal;
148
- }
149
-
150
- .row-issue.blocking {
151
- color: var(--md-sys-color-error);
152
- }
153
-
154
- .verified {
155
- color: var(--md-sys-color-primary);
156
- }
157
-
158
- .verified md-icon,
159
- .totals md-icon {
160
- --md-icon-size: 14px;
161
- vertical-align: -2px;
162
- }
163
-
164
- .totals {
165
- display: flex;
166
- flex-wrap: wrap;
167
- gap: 2px 12px;
168
- margin: 6px 0 0;
169
- font-variant-numeric: tabular-nums;
170
- }
171
-
172
- .totals .differs {
173
- color: var(--md-sys-color-error);
174
- font-weight: 600;
175
- }
176
-
177
- .totals .matches {
178
- color: var(--md-sys-color-primary);
179
- }
180
-
181
- /* In the AI 작업 패널: every row, the page's height, the reading size of a page (design/ai/workspace.md §6-1). */
182
- :host([wide]) {
183
- font-size: 13px;
184
- }
185
-
186
- :host([wide]) .scroll {
187
- max-height: calc(100vh - 260px);
188
- }
189
-
190
- :host([wide]) th,
191
- :host([wide]) td {
192
- padding: 6px 10px;
193
- }
194
-
195
- :host([wide]) .source {
196
- max-width: 320px;
197
- }
198
-
199
- .more,
200
- .check-failed {
201
- margin-top: 4px;
202
- color: var(--md-sys-color-on-surface-variant);
203
- }
204
- `
205
- ]
206
-
207
- @property({ attribute: false }) proposal: any
208
- /** The 작업 패널's review - every row is drawn, not the first fifty. */
209
- @property({ type: Boolean, reflect: true }) wide = false
210
-
211
- /** The sum of each totalled field, beside the total the material prints - a missing row shows here without reading every row. */
212
- private renderTotals(totals: EntryTotalView[], columns: { name: string; labelKey?: string }[]) {
213
- if (!totals.length) return nothing
214
- const name = (field: string) => {
215
- const column = columns.find(one => one.name === field)
216
- return column?.labelKey ? i18next.t(column.labelKey) : field
217
- }
218
- return html`<div class="totals" role="status">
219
- ${totals.map(total => html`
220
- <span>${t('total', '{field} total {sum}', { field: name(total.field), sum: shown(total.all) })}</span>
221
- ${total.ready !== total.all ? html`<span>${t('total-ready', 'entered {sum}', { sum: shown(total.ready) })}</span>` : nothing}
222
- ${total.declared !== undefined
223
- ? html`<span>${total.declaredBy === 'file' ? t('total-declared-file', "the file's total line {sum}", { sum: shown(total.declared) }) : t('total-declared', 'the material says {sum}', { sum: shown(total.declared) })}${total.declaredFound === false ? ` (${t('total-not-found', 'not found in the file')})` : ''}</span>
224
- ${total.difference
225
- ? html`<span class="differs">${t('total-differs', 'differs by {sum}', { sum: shown(total.difference) })}</span>`
226
- : html`<span class="matches"><md-icon>task_alt</md-icon> ${t('total-matches', 'matches')}</span>`}`
227
- : nothing}
228
- `)}
229
- </div>`
230
- }
231
-
232
- /**
233
- * A 수정안 - each record by its name, each changing field as what it holds now and what it becomes, and how the
234
- * record was picked. The "now" is the server's reading, never the model's memory.
235
- */
236
- private renderChanges(p: any) {
237
- const columns: { name: string; type: string; labelKey?: string; valueKeyPrefix?: string }[] = p.columns ?? []
238
- const rows: any[] = p.rows ?? []
239
- const counts = p.counts ?? {}
240
- const via = (row: any) =>
241
- row.via === 'current' ? t('via-current', 'the record on screen') : row.via === 'selected' ? t('via-selected', 'selected on screen') : t('via-id', 'found in the conversation')
242
- return html`
243
- <div class="summary" role="status">
244
- <span>${t('changes', '{count} records', { count: counts.rows ?? rows.length })}</span>
245
- <span>${t('ready', '{count} ready', { count: counts.ready ?? 0 })}</span>
246
- ${counts.blocked ? html`<span class="blocked">${t('not-changed', '{count} will not be changed', { count: counts.blocked })}</span>` : nothing}
247
- </div>
248
- <div class="scroll">
249
- <table>
250
- <thead>
251
- <tr>
252
- <th>#</th>
253
- <th>${t('record', 'record')}</th>
254
- ${columns.map(column => html`<th>${column.labelKey ? i18next.t(column.labelKey) : column.name}</th>`)}
255
- <th>${t('picked', 'picked')}</th>
256
- </tr>
257
- </thead>
258
- <tbody>
259
- ${rows.slice(0, this.wide ? rows.length : SHOWN).map(row => {
260
- const blocked = (row.issues ?? []).some((issue: EntryIssueView) => issue.blocking)
261
- const whole = entryCellIssues(row)
262
- return html`<tr class=${blocked ? 'blocked' : ''}>
263
- <td class="num">${row.index + 1}</td>
264
- <td>${row.label || row.id}${whole.map(issue => html`<span class="row-issue ${issue.blocking ? 'blocking' : ''}">${issueText(issue)}</span>`)}</td>
265
- ${columns.map(column => {
266
- const issues = entryCellIssues(row, column.name)
267
- const bad = issues.some(issue => issue.blocking)
268
- const changes = column.name in (row.values ?? {})
269
- return html`<td class="${column.type === 'number' || column.type === 'integer' ? 'num' : ''} ${bad ? 'bad' : issues.length ? 'note' : ''}" title=${issues.map(issueText).join('\n')}>
270
- ${changes ? html`<span class="before">${valueOf(column, row.before?.[column.name]) || '—'}</span> → <strong>${valueOf(column, row.values[column.name]) || '—'}</strong>` : ''}
271
- </td>`
272
- })}
273
- <td class="source">${via(row)}</td>
274
- </tr>`
275
- })}
276
- </tbody>
277
- </table>
278
- </div>
279
- `
280
- }
281
-
282
- render() {
283
- const p = this.proposal ?? {}
284
- if (p.op === 'update') return this.renderChanges(p)
285
- const columns: { name: string; type: string; required?: boolean; labelKey?: string; valueKeyPrefix?: string }[] = p.columns ?? []
286
- const rows: EntryRowView[] = p.rows ?? []
287
- const counts = p.counts ?? {}
288
- return html`
289
- <div class="summary" role="status">
290
- ${counts.groups ? html`<span>${t('groups', '{count} records', { count: counts.groups })}</span>` : nothing}
291
- <span>${t('rows', '{count} rows', { count: counts.rows ?? rows.length })}</span>
292
- ${counts.groups && counts.groupsReady !== counts.groups ? html`<span class="blocked">${t('groups-kept-out', '{count} records kept out whole', { count: counts.groups - counts.groupsReady })}</span>` : nothing}
293
- <span>${t('ready', '{count} ready', { count: counts.ready ?? 0 })}</span>
294
- ${counts.blocked ? html`<span class="blocked">${t('blocked', '{count} will not be entered', { count: counts.blocked })}</span>` : nothing}
295
- ${counts.cut ? html`<span class="blocked">${t('cut', '{count} left out over the limit', { count: counts.cut })}</span>` : nothing}
296
- ${counts.verified ? html`<span class="verified"><md-icon>task_alt</md-icon> ${t('verified', '{count} found in their file', { count: counts.verified })}</span>` : nothing}
297
- ${counts.unmatched ? html`<span class="blocked">${t('unmatched', '{count} with a value their file does not have', { count: counts.unmatched })}</span>` : nothing}
298
- </div>
299
- <div class="scroll">
300
- <table>
301
- <thead>
302
- <tr>
303
- <th>#</th>
304
- ${columns.map(column => html`<th>${column.labelKey ? i18next.t(column.labelKey) : column.name}${column.required ? ' *' : ''}</th>`)}
305
- <th>${t('source', 'from')}</th>
306
- </tr>
307
- </thead>
308
- <tbody>
309
- ${rows.slice(0, this.wide ? rows.length : SHOWN).map(row => {
310
- const blocked = (row.issues ?? []).some(issue => issue.blocking)
311
- const whole = entryCellIssues(row)
312
- return html`
313
- <tr class=${blocked ? 'blocked' : ''}>
314
- <td class="num">${row.index + 1}</td>
315
- ${columns.map(column => {
316
- const issues = entryCellIssues(row, column.name)
317
- const bad = issues.some(issue => issue.blocking)
318
- const value = row.values?.[column.name]
319
- const text = valueOf(column, value)
320
- return html`<td
321
- class="${column.type === 'number' || column.type === 'integer' ? 'num' : ''} ${bad ? 'bad' : issues.length ? 'note' : ''}"
322
- title=${issues.map(issueText).join('\n')}
323
- >
324
- ${text || (issues.some(issue => issue.code === 'required') ? html`<span class="missing">${t('missing', 'missing')}</span>` : '')}
325
- </td>`
326
- })}
327
- <td class="source" title=${(row.sources ?? []).map(sourceText).join(' · ')}>
328
- ${row.evidence ? html`<span class="verified" title=${t('evidence', 'found on line {line} of the file', { line: row.evidence.line })}><md-icon>task_alt</md-icon></span> ` : nothing}
329
- ${(row.sources ?? []).map(sourceText).join(' · ')}
330
- ${whole
331
- .filter(issue => issue.code !== 'no-source')
332
- .map(issue => html`<span class="row-issue ${issue.blocking ? 'blocking' : ''}">${issueText(issue)}</span>`)}
333
- ${whole.some(issue => issue.code === 'no-source') ? html`<span class="row-issue">${issueText({ code: 'no-source', blocking: false })}</span>` : nothing}
334
- </td>
335
- </tr>
336
- `
337
- })}
338
- </tbody>
339
- </table>
340
- </div>
341
- ${this.renderTotals(p.totals ?? [], columns)}
342
- ${!this.wide && rows.length > SHOWN ? html`<div class="more">${t('more-rows', '{count} more rows are not shown - they are entered too.', { count: rows.length - SHOWN })}</div>` : nothing}
343
- ${p.checkFailed ? html`<div class="check-failed">${t('check-failed', 'the application could not check these rows; they are checked again when entered.')}</div>` : nothing}
344
- `
345
- }
346
- }