@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,122 +0,0 @@
1
- /*
2
- * AI 세션 활동 구독 — **앱 전역 1회**. 도크가 닫혀 있어도(마운트되지 않아도) 새 소식을 안다.
3
- *
4
- * operato-twin 의 `twin-ai-activity.ts` 에서 올려 왔다(2026-09-25, design/ai/shared-dock.md §2-8) — 안 읽음은
5
- * 모든 앱에서 같은 기능이다. `setupAssistantDock()` 이 부팅에서 한 번 연다.
6
- *
7
- * ── 왜 도크가 아니라 여기인가 ───────────────────────────────────────────────
8
- * 도크는 asidebar viewpart 이고 닫혀 있으면 **렌더되지 않는다**(템플릿이 아예 안 붙는다). 그래서
9
- * 도크 안에서 구독하면 닫아 둔 동안 아무 소식을 받지 못한다 — 배지를 띄울 수 없다.
10
- * 구독은 부팅 시 한 번 열고, 도크·컨텍스트 밴드는 이 스토어를 본다.
11
- *
12
- * ── 종류에 따라 다르게 다룬다 ───────────────────────────────────────────────
13
- * message — 새 메시지. 안 읽은 세션으로 표시(배지 올림). **내가 보낸 것은 올리지 않는다.**
14
- * meta — 이름 변경 등. 목록 갱신만 알리고 배지는 올리지 않는다(소음 방지).
15
- *
16
- * 정확한 미읽음 **개수**는 세지 않는다 — 세션 수만 센다(서버 목록 정책과 같다).
17
- */
18
- import gql from 'graphql-tag'
19
-
20
- import { client, gqlContext } from '@operato/graphql'
21
-
22
-
23
- export interface SessionActivity {
24
- sessionId: string
25
- kind: 'message' | 'meta'
26
- anchorType?: string
27
- anchorId?: string
28
- at: string
29
- preview?: string
30
- actorId?: string
31
- }
32
-
33
- type Listener = (activity: SessionActivity) => void
34
-
35
- const listeners = new Set<Listener>()
36
- /** 안 읽은 세션 id — 개수가 아니라 세션 단위. 도크에서 그 세션을 열면 지운다. */
37
- const unreadSessions = new Set<string>()
38
- let subscription: { unsubscribe(): void } | null = null
39
-
40
- const ACTIVITY_SUBSCRIPTION = gql`
41
- subscription MySessionActivity {
42
- mySessionActivity {
43
- sessionId
44
- kind
45
- anchorType
46
- anchorId
47
- at
48
- preview
49
- actorId
50
- }
51
- }
52
- `
53
-
54
-
55
- export function unreadSessionCount(): number {
56
- return unreadSessions.size
57
- }
58
-
59
- export function isSessionUnread(sessionId: string): boolean {
60
- return unreadSessions.has(sessionId)
61
- }
62
-
63
- /** 그 세션을 읽었다 — 도크가 세션을 열 때 호출(서버 markSessionRead 와 짝). */
64
- export function clearSessionUnread(sessionId: string): void {
65
- if (unreadSessions.delete(sessionId)) notify({ sessionId, kind: 'meta', at: new Date().toISOString() })
66
- }
67
-
68
- export function subscribeSessionActivity(fn: Listener): () => void {
69
- listeners.add(fn)
70
- return () => listeners.delete(fn)
71
- }
72
-
73
- function notify(activity: SessionActivity) {
74
- listeners.forEach(fn => {
75
- try {
76
- fn(activity)
77
- } catch {
78
- /* 구독자 오류가 다른 구독자를 막지 않는다 */
79
- }
80
- })
81
- }
82
-
83
- /**
84
- * 구독 시작 — 부팅에서 1회. 재호출은 무시(중복 구독 방지).
85
- * 실패해도 앱을 막지 않는다 — 배지가 없을 뿐이고, 도크를 열면 목록을 직접 읽는다.
86
- */
87
- export function startSessionActivityFeed(): void {
88
- if (subscription) return
89
- try {
90
- subscription = client
91
- .subscribe({ query: ACTIVITY_SUBSCRIPTION, context: gqlContext() })
92
- .subscribe({
93
- next: ({ data }: any) => {
94
- const activity: SessionActivity | undefined = data?.mySessionActivity
95
- if (!activity?.sessionId) return
96
- /* 자기 발신은 배지를 올리지 않는다 — 방금 내가 쓴 것이 안 읽음으로 뜨면 어색하다.
97
- * 서버는 actorId(사용자 id)를 싣지만 클라는 내부 관리키를 판정에 쓰지 않는다 →
98
- * 자기 발신 판정은 도크가 열려 있는 세션인지로 대신한다(그 세션은 이미 읽고 있다). */
99
- if (activity.kind === 'message' && !isOpenSession(activity.sessionId)) {
100
- unreadSessions.add(activity.sessionId)
101
- }
102
- notify(activity)
103
- },
104
- error: () => {
105
- subscription = null // 재연결은 다음 호출에 맡긴다(자동 재시도 루프를 두지 않는다)
106
- }
107
- })
108
- } catch {
109
- subscription = null
110
- }
111
- }
112
-
113
- /* 도크가 지금 열어 둔 세션 — 그 세션의 활동은 배지를 올리지 않는다(보고 있으므로). */
114
- let openSessionId = ''
115
- export function setOpenSession(sessionId: string): void {
116
- openSessionId = sessionId || ''
117
- if (openSessionId) clearSessionUnread(openSessionId)
118
- }
119
- function isOpenSession(sessionId: string): boolean {
120
- return !!openSessionId && openSessionId === sessionId
121
- }
122
-
@@ -1,38 +0,0 @@
1
- /*
2
- * What becomes of a request a screen hands the dock - the screen waits on the answer and keeps the person's words
3
- * unless it was sent (design/ai/shared-dock.md §2-11-1, rule 5).
4
- */
5
- import { askAssistant, peekAssistantAsk, settleAssistantAsk, takeAssistantAsk } from './assistant-ask'
6
-
7
- beforeAll(() => {
8
- ;(globalThis as any).window = (globalThis as any).window ?? { dispatchEvent: () => true }
9
- ;(globalThis as any).CustomEvent = (globalThis as any).CustomEvent ?? class { constructor(public type: string) {} }
10
- })
11
- afterEach(() => takeAssistantAsk())
12
-
13
- describe('a request and its outcome', () => {
14
- it('★ the screen hears whether it was sent, and why not', async () => {
15
- const ask = { ask: 'read them', selection: { title: 'L', records: [{ id: 'a' }] } }
16
- const outcome = askAssistant(ask)
17
- expect(peekAssistantAsk()).toBe(ask)
18
- settleAssistantAsk(takeAssistantAsk()!, { sent: false, reason: 'not ready' })
19
- expect(await outcome).toEqual({ sent: false, reason: 'not ready' })
20
- })
21
-
22
- it('peeking leaves it waiting; it is settled once', async () => {
23
- const ask = { ask: 'x' }
24
- const outcome = askAssistant(ask)
25
- expect(peekAssistantAsk()).toBe(ask)
26
- expect(peekAssistantAsk()).toBe(ask)
27
- settleAssistantAsk(ask, { sent: true })
28
- settleAssistantAsk(ask, { sent: false, reason: 'late' })
29
- expect(await outcome).toEqual({ sent: true })
30
- })
31
-
32
- it('a request replaced before the dock took it is told it was not sent', async () => {
33
- const first = askAssistant({ ask: 'first' })
34
- askAssistant({ ask: 'second' })
35
- expect(await first).toEqual({ sent: false, reason: 'replaced' })
36
- expect(peekAssistantAsk()?.ask).toBe('second')
37
- })
38
- })
@@ -1,93 +0,0 @@
1
- /*
2
- * Asking the assistant from another screen - `askAssistant()` (design/ai/shared-dock.md §2-11).
3
- *
4
- * Generalised from operato-twin's promotion channel and operato-plant's ask box: a toast's "ask AI", a
5
- * header ask box, a performance page carrying its context. The request waits here until the dock takes it,
6
- * so a dock that is closed (not mounted) still gets it when it opens.
7
- */
8
- import type { AssistantSelection } from './assistant-selection.js'
9
- export interface AssistantAsk {
10
- /** Sent as the next question. */
11
- ask?: string
12
- /** Put in the input, not sent. */
13
- draft?: string
14
- /** Whom the draft is said to - one of the people of the conversation, not the assistant (`addressedDraft`). */
15
- to?: { id: string; name: string }
16
- /** Ask in the open conversation instead of a new one. */
17
- continueCurrent?: boolean
18
- /**
19
- * Open this conversation - one listed on the screen the dock stands on (a person's 360 for a question handed to them,
20
- * ADR-0200). The request waits until the dock lists it.
21
- */
22
- sessionId?: string
23
- /** A new conversation's name. */
24
- name?: string
25
- /** Turns carried into the new conversation before the question. */
26
- transcript?: { role: 'user' | 'ai'; content: string }[]
27
- /** A note stored first: what the screen was showing when the person asked. */
28
- context?: string
29
- /**
30
- * The records the person picked on the screen - a screen request (「AI와 작업」, design/ai/shared-dock.md §2-11-1). It
31
- * goes to this screen's conversation, never a new one; the selection is noted for that turn (a line the person reads,
32
- * the ids for the model - assistant-selection.ts) and `ask` is sent at once.
33
- */
34
- selection?: AssistantSelection
35
- }
36
-
37
- /** What became of a request - a screen keeps what the person wrote when it was not sent, and says nothing twice. */
38
- export interface AssistantAskOutcome {
39
- sent: boolean
40
- /** Why it was not sent, in the person's words - the dock has already said it. */
41
- reason?: string
42
- }
43
-
44
- type Listener = () => void
45
-
46
- let pending: AssistantAsk | undefined
47
- const listeners = new Set<Listener>()
48
- const settlers = new WeakMap<AssistantAsk, (outcome: AssistantAskOutcome) => void>()
49
-
50
- /**
51
- * Hands the request to the dock. The promise says what became of it once the dock has dealt with it - sent, or not and
52
- * why. A request replaced before the dock took it is not sent, and says so.
53
- */
54
- export function askAssistant(ask: AssistantAsk): Promise<AssistantAskOutcome> {
55
- if (pending && pending !== ask) settleAssistantAsk(pending, { sent: false, reason: 'replaced' })
56
- const outcome = new Promise<AssistantAskOutcome>(resolve => settlers.set(ask, resolve))
57
- pending = ask
58
- listeners.forEach(listener => listener())
59
- window.dispatchEvent(new CustomEvent('assistant-dock-open'))
60
- return outcome
61
- }
62
-
63
- /** The dock tells the screen what became of its request. Once; later calls do nothing. */
64
- export function settleAssistantAsk(ask: AssistantAsk, outcome: AssistantAskOutcome): void {
65
- const settle = settlers.get(ask)
66
- settlers.delete(ask)
67
- settle?.(outcome)
68
- }
69
-
70
- /** The waiting request, left waiting - the dock decides how to take it before taking it. */
71
- export function peekAssistantAsk(): AssistantAsk | undefined {
72
- return pending
73
- }
74
-
75
- /**
76
- * The dock could not take it yet and keeps it for when a conversation stands - a draft only. Nothing is announced:
77
- * it was already asked for, and announcing would make the dock take it again at once.
78
- */
79
- export function holdAssistantAsk(ask: AssistantAsk): void {
80
- pending = ask
81
- }
82
-
83
- /** The dock takes the request once. */
84
- export function takeAssistantAsk(): AssistantAsk | undefined {
85
- const ask = pending
86
- pending = undefined
87
- return ask
88
- }
89
-
90
- export function subscribeAssistantAsk(listener: Listener): () => void {
91
- listeners.add(listener)
92
- return () => listeners.delete(listener)
93
- }
@@ -1,24 +0,0 @@
1
- import { client } from '@operato/graphql'
2
- import gql from 'graphql-tag'
3
-
4
- import { capabilityOf, type AiCapability } from './assistant-capability.js'
5
-
6
- /**
7
- * Asks `aiCapability` (standard A7-a). A GraphQL error is thrown for the caller to show; the caller keeps
8
- * `unknown` meanwhile and asks again — it does not remember a failed read as an answer.
9
- */
10
- export async function readAiCapability(): Promise<AiCapability> {
11
- const result = await client.query({
12
- query: gql`
13
- query {
14
- aiCapability {
15
- state
16
- }
17
- }
18
- `,
19
- fetchPolicy: 'no-cache'
20
- })
21
-
22
- if (result.errors?.length) throw new Error(result.errors[0].message)
23
- return capabilityOf(result.data?.aiCapability)
24
- }
@@ -1,17 +0,0 @@
1
- /*
2
- * A7-a — the third state is never read as the first.
3
- */
4
- import { capabilityOf } from './assistant-capability'
5
-
6
- describe('capabilityOf', () => {
7
- it('passes the two answers the door gives', () => {
8
- expect(capabilityOf({ state: 'configured' })).toBe('configured')
9
- expect(capabilityOf({ state: 'not-configured' })).toBe('not-configured')
10
- })
11
-
12
- it('★ not asked yet, and an answer it cannot read, are unknown — never configured', () => {
13
- for (const answer of [undefined, null, {}, { state: null }, { state: 'yes' }, { state: 'CONFIGURED' }]) {
14
- expect(capabilityOf(answer as any)).toBe('unknown')
15
- }
16
- })
17
- })
@@ -1,19 +0,0 @@
1
- /*
2
- * Whether this deployment has an AI to answer — the rule every dock reads before offering a conversation.
3
- *
4
- * AI standard A7-a: a screen does not find out by failing. Without this a dock takes the question, sends
5
- * it, and only then shows the provider's error. `aiCapability` answers first.
6
- *
7
- * Three states, and the third is the screen's own: not asked yet, or an answer that could not be read.
8
- * It is never folded into `configured` — that is where the question started (a button that was always on).
9
- *
10
- * Pure, so it is tested without GraphQL. The read is `readAiCapability` (`assistant-capability-read.ts`).
11
- * Warehouse and twin each held a copy of this until it moved here (2026-09-24).
12
- */
13
-
14
- export type AiCapability = 'configured' | 'not-configured' | 'unknown'
15
-
16
- export function capabilityOf(answer: { state?: string | null } | null | undefined): AiCapability {
17
- const state = answer?.state
18
- return state === 'configured' || state === 'not-configured' ? state : 'unknown'
19
- }
@@ -1,66 +0,0 @@
1
- import { surfaceTransition } from './assistant-navigation.js'
2
- import { readFileSync } from 'node:fs'
3
- import { join } from 'node:path'
4
-
5
- describe('the page decides the conversation - no choice is put to the person', () => {
6
- test.each([false, true])('a different identity resets even when busy=%s', busy => {
7
- for (const sameSubject of [false, true]) {
8
- expect(surfaceTransition({ identityChanged: true, sameSubject, busy })).toBe('reset')
9
- }
10
- })
11
- test('★ another screen is followed - a conversation in progress or text being written does not hold the dock', () => {
12
- expect(surfaceTransition({ identityChanged: false, sameSubject: false, busy: false })).toBe('follow')
13
- })
14
- test('★ an answer in progress finishes in its own conversation first, then the dock follows', () => {
15
- expect(surfaceTransition({ identityChanged: false, sameSubject: false, busy: true })).toBe('wait')
16
- })
17
- test('returning to the same subject refreshes without reopening', () => {
18
- expect(surfaceTransition({ identityChanged: false, sameSubject: true, busy: true })).toBe('refresh')
19
- })
20
- })
21
-
22
- describe('navigation wiring', () => {
23
- const dock = readFileSync(join(__dirname, '../components/assistant-dock.ts'), 'utf8')
24
- test('★ what was being written stays with its subject and comes back on return', () => {
25
- expect(dock).toMatch(/if \(transition !== 'reset'\) this\.keepDraft\(\)/)
26
- expect(dock).toContain('void this.restoreDraft()')
27
- expect(dock).not.toContain('screenChanged')
28
- expect(dock).not.toContain('switch-to-screen')
29
- })
30
- test('history hides rather than unmounts the chat and its unsent input', () => {
31
- expect(dock).toContain('?hidden=${this.showingHistory}')
32
- expect(dock).toContain('ready && !this.loading && !this.failure')
33
- })
34
- test('identity changes clear a carried ask and reread capability', () => {
35
- expect(dock).toContain("if (transition === 'reset')")
36
- expect(dock).toContain('this.asking = undefined')
37
- expect(dock).toContain("this.capability = 'unknown'")
38
- })
39
- test('all direct board actions check the current screen, not the retained editor', () => {
40
- expect(dock).toContain('if (!this.mayApplyOnScreen()) return')
41
- expect(dock.match(/if \(this.mayApplyOnScreen\(\)\)/g)).toHaveLength(2)
42
- expect(dock).toContain("errorCode: 'conversation-screen-changed'")
43
- })
44
- })
45
-
46
-
47
- describe('a carried draft survives opening a new conversation', () => {
48
- test('automatic review starts after cleanup and is sent once per request', () => {
49
- const source = readFileSync(join(__dirname, '../components/assistant-chat.ts'), 'utf8')
50
- const update = source.slice(source.indexOf(' updated(changed:'), source.indexOf(' disconnectedCallback()', source.indexOf(' updated(changed:')))
51
- const placement = update.indexOf('if (this.autoAsk &&')
52
- expect(placement).toBeGreaterThan(update.indexOf("if (changed.has('sessionId')"))
53
- expect(update.slice(placement)).not.toContain("this.input = ''")
54
- expect(update.slice(placement)).toContain('!== this._autoAsked')
55
- expect(update.slice(placement)).toContain('void this.send()')
56
- })
57
- test('draft placement follows subject, mode and session cleanup', () => {
58
- const source = readFileSync(join(__dirname, '../components/assistant-chat.ts'), 'utf8')
59
- const update = source.slice(source.indexOf(' updated(changed:'), source.indexOf(' disconnectedCallback()', source.indexOf(' updated(changed:')))
60
- const placement = update.indexOf('const draft = assistantDraftDecision(')
61
- expect(placement).toBeGreaterThan(update.indexOf("if (changed.has('subject'))"))
62
- expect(placement).toBeGreaterThan(update.indexOf("if (changed.has('mode')"))
63
- expect(placement).toBeGreaterThan(update.indexOf("if (changed.has('sessionId')"))
64
- expect(update.slice(placement)).not.toContain("this.input = ''")
65
- })
66
- })
@@ -1,11 +0,0 @@
1
- /**
2
- * The page decides the conversation (design/ai/shared-dock.md §2-3, 2026-10-12): moving to another screen moves the
3
- * dock to that screen's conversation, with no choice put to the person. What was being written stays with its subject
4
- * and comes back on return. An answer in progress finishes first - then the dock follows. An identity change never
5
- * carries the old conversation.
6
- */
7
- export function surfaceTransition(input: { identityChanged: boolean; sameSubject: boolean; busy: boolean }): 'reset' | 'refresh' | 'wait' | 'follow' {
8
- if (input.identityChanged) return 'reset'
9
- if (input.sameSubject) return 'refresh'
10
- return input.busy ? 'wait' : 'follow'
11
- }
@@ -1,85 +0,0 @@
1
- /*
2
- * Proposal handlers - each proposal kind is applied by the package that declared its tool
3
- * (design/ai/shared-dock.md §4). The dock has no kind-specific code: it finds the handler, runs it,
4
- * and reports the outcome on every branch (ADR-0070). A kind nobody handles is `unavailable`.
5
- */
6
- import type { AssistantSurface } from './assistant-surface.js'
7
-
8
- export type ProposalVerdict = 'accepted' | 'refused' | 'unavailable' | 'declined'
9
-
10
- export interface ProposalOutcome {
11
- verdict: ProposalVerdict
12
- errorCode?: string
13
- applied?: number
14
- missed?: number
15
- /** A line for the conversation, besides the outcome itself (e.g. what was created). */
16
- note?: string
17
- /** The ids of the records it wrote - the screens that show them read again. Not reported to the conversation. */
18
- records?: string[]
19
- }
20
-
21
- export interface ProposalContext {
22
- sessionId?: string
23
- surface?: AssistantSurface
24
- /** Asks the person before anything irreversible. `false` → the handler returns `declined`. */
25
- confirm(options: { title: string; text: string; confirmText?: string; cancelText?: string; type?: 'warning' | 'info' }): Promise<boolean>
26
- notify(level: 'info' | 'error', message: string): void
27
- }
28
-
29
- export type ProposalHandler = (proposal: any, context: ProposalContext) => Promise<ProposalOutcome>
30
-
31
- const handlers = new Map<string, ProposalHandler>()
32
-
33
- /** Registered by the package that declares the tool - `proposeAction` by twin, a figure candidate by figure-ui. */
34
- export function registerProposalHandler(tool: string, handler: ProposalHandler): void {
35
- handlers.set(tool, handler)
36
- }
37
-
38
- export function proposalHandlerOf(tool: string | undefined): ProposalHandler | undefined {
39
- return tool ? handlers.get(tool) : undefined
40
- }
41
-
42
- /**
43
- * How a package's card is drawn in the conversation, besides the framework's line: an element drawn under it (given
44
- * `proposal`, `sessionId` and `proposalKey`), and the words of its button. A dashboard card draws its preview as the
45
- * one looking at the conversation (ADR-0160 decision 6). Registered by the package that declares the tool.
46
- */
47
- export interface ProposalView {
48
- /** A custom element's tag name - defined by the registering package. */
49
- previewTag?: string
50
- /** i18n key of the button, and its words when the key has none. */
51
- runLabelKey?: string
52
- runLabel?: string
53
- }
54
-
55
- const views = new Map<string, ProposalView>()
56
-
57
- export function registerProposalView(tool: string, view: ProposalView): void {
58
- views.set(tool, view)
59
- }
60
-
61
- export function proposalViewOf(tool: string | undefined): ProposalView | undefined {
62
- return tool ? views.get(tool) : undefined
63
- }
64
-
65
- /*
66
- * Data entry cards are the framework's, whatever record they enter (design/ai/data-entry.md §5): one
67
- * handler asks the server to enter the stored rows. The dock sets it; no app registers one per record.
68
- */
69
- let entryHandler: ProposalHandler | undefined
70
-
71
- export function setEntryProposalHandler(handler: ProposalHandler): void {
72
- entryHandler = handler
73
- }
74
-
75
- /** Runs the proposal - never throws; a failure is a `refused` outcome with its message as the code. */
76
- export async function runProposal(proposal: any, context: ProposalContext): Promise<ProposalOutcome> {
77
- const handler = proposal?.kind === 'entry' && entryHandler ? entryHandler : proposalHandlerOf(proposal?.tool)
78
- if (!handler) return { verdict: 'unavailable', errorCode: 'unknown-proposal-kind' }
79
- try {
80
- const outcome = await handler(proposal, context)
81
- return outcome?.verdict ? outcome : { verdict: 'unavailable', errorCode: 'no-outcome' }
82
- } catch (error) {
83
- return { verdict: 'refused', errorCode: (error as Error)?.message || 'failed' }
84
- }
85
- }
@@ -1,63 +0,0 @@
1
- /** Exact deterministic model signature, not a security hash. Only plain JSON models are supported. */
2
- export function assistantModelFingerprint(model: unknown): string | undefined {
3
- if (model === undefined) return undefined
4
- const normalize = (value: any): any => Array.isArray(value) ? value.map(normalize)
5
- : value && typeof value === 'object' ? Object.fromEntries(Object.keys(value).sort().map(key => [key, normalize(value[key])])) : value
6
- return JSON.stringify(normalize(model))
7
- }
8
- export interface AssistantRequestContext {
9
- systemPrompt?: string
10
- hostContext?: Record<string, unknown>
11
- }
12
- export function assistantAutoAskKey(text: string, requestId?: string): string {
13
- return requestId ? JSON.stringify([requestId, text]) : text
14
- }
15
- /**
16
- * Whether a draft handed in from outside fills the input now — the pair of `autoAsk` that does not send.
17
- *
18
- * A host sometimes wants a sentence placed in the input for the person to edit and send themselves
19
- * ("new twin → AI" in twin's instance list). Four rules, each a thing a person would notice:
20
- * · once per request — a re-render must not fill it again after the person cleared or changed it
21
- * · never over what the person is typing — their text is theirs
22
- * · when `autoAsk` comes for the same request, it wins — sending is the clearer intent
23
- * · no draft, nothing to do
24
- * Returns the key to remember when the draft was consumed (filled, or deliberately skipped), so a
25
- * skipped draft does not surface later by surprise.
26
- */
27
- export function assistantDraftDecision(input: {
28
- draft?: string
29
- draftRequestId?: string
30
- drafted?: string
31
- typed: string
32
- autoAsk?: string
33
- autoAskRequestId?: string
34
- }): { fill: boolean; consumed?: string } {
35
- if (!input.draft) return { fill: false }
36
-
37
- const key = assistantAutoAskKey(input.draft, input.draftRequestId)
38
- if (key === input.drafted) return { fill: false }
39
-
40
- const sameRequestAsked = !!input.autoAsk && !!input.draftRequestId && input.autoAskRequestId === input.draftRequestId
41
- if (sameRequestAsked) return { fill: false, consumed: key }
42
-
43
- if (input.typed.trim()) return { fill: false, consumed: key }
44
-
45
- return { fill: true, consumed: key }
46
- }
47
- /**
48
- * A draft said to a person, not to the assistant - `@name draft`, with the name kept as a mention so sending it goes to
49
- * the people of the conversation. An answer to a question handed on is said to the one who asked (ADR-0200 decision 3):
50
- * sent to the assistant, it reached nobody and the to-do stayed open (2026-11-12, :4730).
51
- */
52
- export function addressedDraft(draft: string, to?: { id: string; name: string }): { input: string; mention?: [string, string] } {
53
- if (!to?.id || !to.name) return { input: draft }
54
- const said = `@${to.name}`
55
- return { input: draft.startsWith(said) ? draft : `${said} ${draft.trim()}`.trimEnd() + ' ', mention: [to.name, to.id] }
56
- }
57
- export function assistantRecentSessions<T extends { id: string }>(sessions: T[], selected: string, limit: number): T[] {
58
- const count = Math.max(1, Math.floor(limit) || 5)
59
- const recent = sessions.slice(0, count)
60
- const active = sessions.find(session => session.id === selected)
61
- if (active && !recent.some(session => session.id === selected)) recent[recent.length - 1] = active
62
- return recent
63
- }
@@ -1,54 +0,0 @@
1
- import { noteForDisplay, selectedRecords, selectionLabel, selectionNote, SELECTION_KEYS_PREFIX, SELECTION_ROW_PICKER } from './assistant-selection'
2
-
3
- const t = (_key: string, defaultValue: string, options: any = {}) => defaultValue.replace(/\{(\w+)\}/g, (_, name) => String(options[name]))
4
- const contract = (id: string, label: string) => ({ id, label })
5
-
6
- describe('the records picked on a screen, as a note', () => {
7
- it('★ the person reads a line of names; the model reads the list and the ids', () => {
8
- const note = selectionNote({ title: '계약 대장', list: 'contracts', records: [contract('c-1', 'H2022019 · 브라이스톤 IT3.0 Website')] }, t)
9
- expect(note).toBe(`Selected 1 · 계약 대장: H2022019 · 브라이스톤 IT3.0 Website\n${SELECTION_KEYS_PREFIX} contracts c-1`)
10
- expect(note).not.toMatch(/[{}"]|explicit-page-selection/)
11
- })
12
-
13
- it('★ the screen draws the person\'s line only', () => {
14
- const note = selectionNote({ title: '계약 대장', list: 'contracts', records: [contract('c-1', 'H2022019')] }, t)
15
- expect(noteForDisplay(note)).toBe('Selected 1 · 계약 대장: H2022019')
16
- expect(noteForDisplay('a plain note\nsecond line')).toBe('a plain note\nsecond line')
17
- })
18
-
19
- it('every id reaches the model; the names are cut after a few, the rest counted', () => {
20
- const records = Array.from({ length: 7 }, (_, i) => contract(`c-${i}`, `C${i}`))
21
- const note = selectionNote({ title: 'L', records }, t)
22
- expect(note.split('\n')[0]).toBe('Selected 7 · L: C0, C1, C2, C3, C4 and 2 more')
23
- expect(note.split('\n')[1]).toBe(`${SELECTION_KEYS_PREFIX} ${records.map(one => one.id).join(' ')}`)
24
- })
25
-
26
- it('a record picked twice is one; nothing picked is no note', () => {
27
- expect(selectionNote({ title: 'L', records: [contract('a', 'A'), contract('a', 'A')] }, t)).toBe(`Selected 1 · L: A\n${SELECTION_KEYS_PREFIX} a`)
28
- expect(selectionNote({ title: 'L', records: [] }, t)).toBe('')
29
- })
30
- })
31
-
32
- describe('the rows a list hands over (ox-assistant-selection-bar)', () => {
33
- it('★ each row goes as the key its list\'s read tool takes - `<axis>:<uuid>`', () => {
34
- expect(selectedRecords([{ id: 'u1', code: 'H1', name: 'A' }], { axis: 'contract' })).toEqual([{ id: 'contract:u1', label: 'H1 · A' }])
35
- expect(selectedRecords([{ id: 'u1', name: 'A' }])).toEqual([{ id: 'u1', label: 'A' }])
36
- })
37
-
38
- it('saved rows only, each once, in screen order; never the whole row', () => {
39
- const row = { id: 'a', number: 'INV-1', title: 'T', bankDetails: 'secret' }
40
- const records = selectedRecords([row, row, { id: 'b', __dirty__: 'M', name: 'B' }, { name: 'no id' }, { id: 'c', name: 'C' }])
41
- expect(records).toEqual([{ id: 'a', label: 'INV-1 · T' }, { id: 'c', label: 'C' }])
42
- expect(JSON.stringify(records)).not.toMatch(/secret/)
43
- })
44
-
45
- it('a screen may say a row in its own words', () => {
46
- expect(selectedRecords([{ id: 'q', number: 'Q-7', version: 2 }], { labelOf: row => `${row.number} v${row.version}` })).toEqual([{ id: 'q', label: 'Q-7 v2' }])
47
- expect(selectionLabel({ code: 'C', description: 'D' })).toBe('C · D')
48
- expect(selectionLabel({})).toBe('')
49
- })
50
-
51
- it('the row picker is the grid\'s own, many at once', () => {
52
- expect(SELECTION_ROW_PICKER).toEqual({ type: 'gutter', gutterName: 'row-selector', multiple: true })
53
- })
54
- })