@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,101 +0,0 @@
1
- /*
2
- * The screen asks what its conversation offers.
3
- *
4
- * The `/` sentences, the `@` catalog and the two notices used to travel from the browser into the
5
- * request, which meant the screen and the door could describe the same conversation differently.
6
- * They are declared once, in the mode, as i18n keys — and this query hands them over already
7
- * written in the request's locale (ADR-0054, and the same rule A11 applied to the stop notice).
8
- * The persona, the tool categories and the limits stay on the server: nothing here returns them.
9
- */
10
- import { Arg, Ctx, Directive, Field, ObjectType, Query, Resolver } from 'type-graphql'
11
- import { GraphQLJSON } from 'graphql-scalars'
12
- import '@things-factory/auth-base'
13
-
14
- import { assistantModeView } from './resolve.js'
15
- import { assistantModeForSubject } from './registry.js'
16
- import { requestTranslator } from '../request-translator.js'
17
-
18
- @ObjectType({ description: 'One `/` sentence, in the words of this request.' })
19
- class AssistantModeSlashView {
20
- @Field({ description: 'Short name shown in the list.' })
21
- name: string
22
-
23
- @Field({ description: 'One line about what it does.' })
24
- description: string
25
-
26
- @Field({ description: 'The sentence that lands in the input.' })
27
- template: string
28
- }
29
-
30
- @ObjectType({ description: 'What a conversation offers on screen.' })
31
- class AssistantModeView {
32
- @Field({ description: 'The mode kind this describes.' })
33
- kind: string
34
-
35
- @Field(() => [AssistantModeSlashView], { description: 'What `/` offers.' })
36
- slashTemplates: AssistantModeSlashView[]
37
-
38
- @Field(() => GraphQLJSON, { description: 'What `@` offers.' })
39
- catalogEntries: any[]
40
-
41
- @Field(() => GraphQLJSON, { description: 'Follow-up chips for a proposal that arrived without its own.' })
42
- proposalChoices: any[]
43
-
44
- @Field({ nullable: true, description: 'What the empty input says — what this conversation is for.' })
45
- placeholder?: string
46
-
47
- @Field(() => GraphQLJSON, { nullable: true, description: 'Title and one line for an empty conversation.' })
48
- intro?: { title: string; subtitle: string }
49
-
50
- @Field(() => GraphQLJSON, { nullable: true, description: 'Example sentences this conversation can actually answer.' })
51
- examples?: Array<{ label: string; items: string[] }>
52
-
53
- @Field({ nullable: true, description: 'The line under an empty conversation.' })
54
- footerNotice?: string
55
-
56
- @Field({ nullable: true, description: 'The line shown once the host reports a proposal staged.' })
57
- stagedNotice?: string
58
-
59
- @Field(() => GraphQLJSON, {
60
- nullable: true,
61
- description: "What this conversation accepts as attachments: { kinds: ('image'|'text'|'spreadsheet'|'document')[], maxBytes, maxFiles, maxChars }. Null: none."
62
- })
63
- attachments?: any
64
- }
65
-
66
- @ObjectType({ description: 'The conversation a screen opens for what it is showing.' })
67
- class AssistantModeChoice {
68
- @Field({ description: 'The mode kind to open.' })
69
- kind: string
70
-
71
- @Field({ description: 'What the conversation is called in the conversation list, in the words of this request.' })
72
- label: string
73
- }
74
-
75
- @Resolver()
76
- export class AssistantModeResolver {
77
- /*
78
- * 이 화면의 대화 — 화면에 대화 하나(design/ai/screen-pattern.md §3).
79
- *
80
- * 화면은 자기가 무엇을 보여 주는지(`subject`)만 안다. 그 위에 어느 대화가 서는지는 앱 서버가 선언한다.
81
- */
82
- @Query(() => AssistantModeChoice, {
83
- nullable: true,
84
- description: 'The one conversation for this kind of subject. Null when no application declared one.'
85
- })
86
- @Directive('@privilege(category: "ai-assistant", privilege: "query", domainOwnerGranted: true)')
87
- async assistantModeFor(@Arg('subject') subject: string, @Ctx() context: any): Promise<AssistantModeChoice | null> {
88
- const mode = assistantModeForSubject(subject)
89
- if (!mode) return null
90
- const t = requestTranslator(context)
91
- return { kind: mode.kind, label: mode.labelKey ? t(mode.labelKey) : mode.kind }
92
- }
93
- @Query(() => AssistantModeView, {
94
- description: 'What this conversation offers on screen — `/` sentences, the `@` catalog and the notices, translated.'
95
- })
96
- /* Reading what a conversation offers is reading, and the same door the session list uses. */
97
- @Directive('@privilege(category: "ai-assistant", privilege: "query", domainOwnerGranted: true)')
98
- async assistantMode(@Arg('kind') kind: string, @Ctx() context: any): Promise<AssistantModeView> {
99
- return assistantModeView(kind, requestTranslator(context)) as AssistantModeView
100
- }
101
- }
@@ -1,48 +0,0 @@
1
- /*
2
- * A category another package opens in every conversation (ADR-0160 decision 9) - in reach everywhere, in front only on
3
- * the pages it names, never in an unattended run.
4
- */
5
- import { clearConversationCategories, modeFrontCategories, modeScreens, modeToolCategories, registerConversationCategory, turnSystemPrompt, unattendedToolCategories } from './mode-categories'
6
-
7
- const mode = { toolCategories: ['office-ops'], readTargets: ['office.receivables'] }
8
-
9
- beforeEach(() => {
10
- clearConversationCategories()
11
- registerConversationCategory({ name: 'dashboard-card', frontPages: ['my-dashboard'], frontAxes: ['dashboard-card'] })
12
- })
13
-
14
- afterAll(() => clearConversationCategories())
15
-
16
- describe('a category every conversation opens', () => {
17
- it('★ every mode opens it', () => {
18
- expect(modeToolCategories(mode)).toContain('dashboard-card')
19
- expect(modeToolCategories({})).toContain('dashboard-card')
20
- })
21
-
22
- it('★ it goes in front on its page, and only there', () => {
23
- expect(modeFrontCategories(mode, { page: 'my-dashboard' })).toContain('dashboard-card')
24
- expect(modeFrontCategories(mode, { page: 'receivable-page' })).not.toContain('dashboard-card')
25
- expect(modeFrontCategories(mode, {})).not.toContain('dashboard-card')
26
- })
27
-
28
- it('★ a record of its axis picked or anchored puts it in front, on any page - a picked card is changed by its tools', () => {
29
- expect(modeFrontCategories(mode, { page: 'receivable-page', selectionAxes: ['dashboard-card'] })).toContain('dashboard-card')
30
- expect(modeFrontCategories(mode, { subjectAxis: 'dashboard-card' })).toContain('dashboard-card')
31
- expect(modeFrontCategories(mode, { page: 'receivable-page', selectionAxes: ['contract'] })).not.toContain('dashboard-card')
32
- })
33
-
34
- it('★ its page rule is said in the turns asked from its pages, and only there', () => {
35
- registerConversationCategory({ name: 'dashboard-card', frontPages: ['my-dashboard'], pageRule: 'end in a card.' })
36
- expect(turnSystemPrompt('persona', { page: 'my-dashboard', subjectLine: 'open: x' })).toBe('persona\n\nopen: x\n\nend in a card.')
37
- expect(turnSystemPrompt('persona', { page: 'receivable-page' })).toBe('persona')
38
- expect(turnSystemPrompt('persona', {})).toBe('persona')
39
- })
40
-
41
- it('an unattended run never opens it - nobody is there to press the card', () => {
42
- expect(unattendedToolCategories(mode)).not.toContain('dashboard-card')
43
- })
44
-
45
- it('the boot report walks its page, so a budget overrun there is said at boot', () => {
46
- expect(modeScreens(mode)).toContainEqual({ page: 'my-dashboard' })
47
- })
48
- })
@@ -1,36 +0,0 @@
1
- /**
2
- * The open subjects the shared parts can name without an application's help (design/ai/screen-pattern.md §2-1):
3
- * the site (`domain`), an application's home (`application`) and a board (`board`). An application that names
4
- * one of these differently registers its own describer, which is read first.
5
- *
6
- * A board is read by entity name: the board entity belongs to board-service, and this package does not depend on
7
- * it. A deployment without boards has no board anchors, and a read that fails says the subject could not be read.
8
- */
9
- import { Domain, getRepository } from '@things-factory/shell'
10
- import { registerFallbackSubject } from '@things-factory/ai-client-base'
11
-
12
- registerFallbackSubject({
13
- anchorType: 'domain',
14
- async describe({ anchorId, domain }) {
15
- /* The site of this conversation only - another domain's name is not this person's to read. */
16
- if (anchorId !== domain.id) return undefined
17
- const found = await getRepository(Domain).findOne({ where: { id: anchorId } })
18
- return found ? { noun: 'site', name: found.description || found.name } : undefined
19
- }
20
- })
21
-
22
- registerFallbackSubject({
23
- anchorType: 'application',
24
- async describe({ anchorId }) {
25
- /* The application's home is a place, not a record: nothing narrower is open. */
26
- return { noun: 'home of the application', name: anchorId }
27
- }
28
- })
29
-
30
- registerFallbackSubject({
31
- anchorType: 'board',
32
- async describe({ anchorId, domain }) {
33
- const found: any = await getRepository('Board').findOne({ where: { id: anchorId, domain: { id: domain.id } } })
34
- return found?.name ? { noun: 'board', name: found.name } : undefined
35
- }
36
- })
@@ -1,22 +0,0 @@
1
- /**
2
- * Modes — what each conversation is, declared by the app server that owns the screen.
3
- *
4
- * Design: ADR-0061 decision 7 (`operato-application/adr/ADR-0061.md`) and the AI standard's A2.
5
- */
6
- export {
7
- registerAssistantMode,
8
- getAssistantMode,
9
- listAssistantModes,
10
- assistantModeForSubject,
11
- getAssistantModeWarnings,
12
- clearAssistantModes
13
- } from './registry.js'
14
- export { resolveModeSettings, assistantModeView } from './resolve.js'
15
- /* A category another package opens in every conversation, in front on the pages it names (ADR-0160 decision 9). */
16
- export { registerConversationCategory, conversationCategoriesOf, turnSystemPrompt, type ConversationCategory } from './mode-categories.js'
17
- /* The record an open 360 is about, named by the module that owns it (screen-pattern §2-1). */
18
- export { recordSubjectDescriber, registerRecordSubject, type RecordSubject } from './record-subject.js'
19
- export { ABSENCE_RULE, FINISH_RULE, NEXT_REQUEST_RULE, SELECTION_RULE, SPEAKER_RULE, conversationPrompt, isPersonRequest, splitNextRequest } from './screen-rules.js'
20
- export type { AssistantModeSpec, AssistantModeSlash, AssistantModeWarning, UnattendedLimits } from './types.js'
21
- export type { AssistantModeRef, ModeSettings, AssistantModeView, AssistantModeSlashView, Translate } from './resolve.js'
22
- export { registerTurnLine, turnLinesOf, type TurnLine, type TurnLineInput } from './turn-lines.js'
@@ -1,178 +0,0 @@
1
- /* Read by the resolver and by the boot report, so the report and the conversation open the same tools. */
2
- import { entryTargetOf } from '../data-entry/entry-target.js'
3
- import { detailReadOf, readTargetOf } from '../data-read/read-target.js'
4
- import { HELP_CATEGORY } from '../help-documents/help-keys.js'
5
- import { PEOPLE_CATEGORIES } from '../people/people-keys.js'
6
- /**
7
- * A category another package opens in every conversation - a dashboard card (ADR-0160 decision 9). It is in reach of
8
- * every conversation; it is put in front only on the pages it names, and found with `openTools` elsewhere (ADR-0061
9
- * decision 9). Never in an unattended run: its tools are proposals, and nobody is there to press the card.
10
- */
11
- export interface ConversationCategory {
12
- name: string
13
- /** The application routes whose conversations put it in front (`my-dashboard`). */
14
- frontPages?: string[]
15
- /**
16
- * The axes of the records whose selection or anchor puts it in front (`dashboard-card`) - a card picked to change is
17
- * changed by this category's tools, wherever the dock is open.
18
- */
19
- frontAxes?: string[]
20
- /**
21
- * What a turn asked from one of its front pages must end in - said in that turn's system prompt only. On 나의 대시보드
22
- * a request to see a figure is a card; asked 「이번 달 지출 합계」 there, the model answered 「0원」 in words (2026-10-25).
23
- */
24
- pageRule?: string
25
- }
26
-
27
- const conversationCategories = new Map<string, ConversationCategory>()
28
-
29
- export function registerConversationCategory(category: ConversationCategory): void {
30
- conversationCategories.set(category.name, category)
31
- }
32
-
33
- export function conversationCategoriesOf(): ConversationCategory[] {
34
- return [...conversationCategories.values()]
35
- }
36
-
37
- export function clearConversationCategories(): void {
38
- conversationCategories.clear()
39
- }
40
-
41
- /** The system prompt of one turn - the mode's, the open record's line, and the rules of the page it is asked from. */
42
- export function turnSystemPrompt(modePrompt: string, screen: { page?: string; subjectLine?: string } = {}): string {
43
- const pageRules = screen.page ? conversationCategoriesOf().filter(one => one.pageRule && (one.frontPages ?? []).includes(screen.page!)).map(one => one.pageRule!) : []
44
- return [modePrompt, screen.subjectLine, ...pageRules].filter(Boolean).join('\n\n')
45
- }
46
-
47
- /**
48
- * The categories a mode opens: its own, the AI 작업 패널 (design/ai/workspace.md), the attachment reader when it
49
- * takes files (design/ai/shared-dock.md §9-4), and one propose tool per record it may enter (design/ai/data-entry.md).
50
- */
51
- export function modeToolCategories(mode: { toolCategories?: string[]; attachments?: { kinds?: string[] }; entryTargets?: string[]; readTargets?: string[] }): string[] | undefined {
52
- const extra = [
53
- /* Every conversation may put a large result on the AI 작업 패널 (design/ai/workspace.md). */
54
- 'assistant-workspace',
55
- /* Every conversation may read who works here and offer to bring one of them in (people/, ADR-0073 decision 3). */
56
- ...PEOPLE_CATEGORIES,
57
- /* Every conversation may read the application's help (ADR-0181). */
58
- HELP_CATEGORY,
59
- ...(mode.attachments?.kinds?.length ? ['chat-attachments'] : []),
60
- ...(mode.entryTargets ?? []).map(key => `data-entry:${key}`),
61
- ...(mode.readTargets ?? []).map(key => `data-read:${key}`),
62
- ...conversationCategoriesOf().map(one => one.name)
63
- ]
64
- return [...new Set([...(mode.toolCategories ?? []), ...extra])]
65
- }
66
-
67
- /**
68
- * The categories an unattended run of a mode opens: its own and the lists it reads (design/ai/unattended-run.md §3).
69
- *
70
- * Not the 입력안 tools - nobody is there to press the card - nor the AI 작업 패널 or the attachment reader: there is no
71
- * conversation for a card or a file to belong to.
72
- */
73
- export function unattendedToolCategories(mode: { toolCategories?: string[]; readTargets?: string[] }): string[] {
74
- return [...new Set([...(mode.toolCategories ?? []), ...(mode.readTargets ?? []).map(key => `data-read:${key}`)])]
75
- }
76
-
77
- /** The screen a turn is asked from - the page the dock is on, and the record its conversation is anchored to. */
78
- export interface TurnScreen {
79
- /** The application's route of the open page (`cash-transaction-list`), as the dock sends it. */
80
- page?: string
81
- /** The axis of the record the conversation is anchored to (`contract` of `subject` · `contract:<id>`), from the stored anchor. */
82
- subjectAxis?: string
83
- /** The axes of the records the latest selection named (`contract` of `[keys] contracts contract:<id>`) - `selectionAxesOf`. */
84
- selectionAxes?: string[]
85
- }
86
-
87
- /** The line of a selection note the model reads - the client's `SELECTION_KEYS_PREFIX` (assistant-selection.ts). */
88
- export const SELECTION_KEYS_LINE = '[keys]'
89
-
90
- /**
91
- * The axes of the records the latest selection note names (「AI와 작업」, shared-dock §2-11-1): a list hands its rows as
92
- * `<axis>:<uuid>`, so the rows' list is read with the tool of that axis. Put in front like an anchored record's - picked
93
- * on 미수금, the contracts' read was not in front, and the model looked for them among attachments and a dashboard's cards
94
- * before it opened the right tool (2026-10-25). A note is the server's (`appendSessionNote`, system); a person's words
95
- * are never read for it.
96
- */
97
- export function selectionAxesOf(rows: { role?: string; content?: string | null }[]): string[] {
98
- for (let i = rows.length - 1; i >= 0; i--) {
99
- if (rows[i].role !== 'system') continue
100
- const line = String(rows[i].content ?? '')
101
- .split('\n')
102
- .find(one => one.startsWith(SELECTION_KEYS_LINE))
103
- if (!line) continue
104
- const keys = line.slice(SELECTION_KEYS_LINE.length).trim().split(/\s+/)
105
- return [...new Set(keys.map(one => one.match(/^([a-z0-9-]+):/)?.[1]).filter((one): one is string => !!one))]
106
- }
107
- return []
108
- }
109
-
110
- type FrontMode = { toolCategories?: string[]; attachments?: { kinds?: string[] }; entryTargets?: string[]; readTargets?: string[] }
111
-
112
- /**
113
- * The records the open screen is about, among those the mode reads and enters (ADR-0061 decision 9). A key's page is
114
- * the screen that lists its records (ReadTarget.screen.route), the screen a card's records are seen on
115
- * (EntryTarget.screen) and the pages a read of one record names (DetailRead.frontPages); a key's last part is the axis
116
- * of its record (`office.contract` is the record of the axis `contract`) - reading and entering one record share its key.
117
- */
118
- export function screenTargetKeys(mode: FrontMode, screen: TurnScreen, routeOf: (key: string) => string | undefined = key => readTargetOf(key)?.screen?.route): string[] {
119
- const keys = [...new Set([...(mode.readTargets ?? []), ...(mode.entryTargets ?? [])])]
120
- return keys.filter(
121
- key =>
122
- (!!screen.page && pagesOfKey(mode, key, routeOf).includes(screen.page)) ||
123
- (!!screen.subjectAxis && axesOfKey(mode, key).includes(screen.subjectAxis)) ||
124
- (!!screen.selectionAxes?.length && axesOfKey(mode, key).some(axis => screen.selectionAxes!.includes(axis)))
125
- )
126
- }
127
-
128
- /**
129
- * The pages a key is in front on. A card's own screen counts as its page: on 내 주간업무보고 the report line card was
130
- * not in front, the model opened it with `openTools`, and the answer that followed was hidden (2026-11-12).
131
- */
132
- function pagesOfKey(mode: FrontMode, key: string, routeOf: (key: string) => string | undefined): string[] {
133
- const card = (mode.entryTargets ?? []).includes(key) ? entryTargetOf(key)?.screen : undefined
134
- const answer = (mode.readTargets ?? []).includes(key) ? detailReadOf(key)?.frontPages ?? [] : []
135
- return [routeOf(key), card, ...answer].filter((page): page is string => !!page)
136
- }
137
-
138
- /** The records a key is about: its last part, and the axes a card joins or a whole answer covers (EntryTarget.axes · DetailRead.axes). */
139
- function axesOfKey(mode: FrontMode, key: string): string[] {
140
- const card = (mode.entryTargets ?? []).includes(key) ? entryTargetOf(key)?.axes ?? [] : []
141
- const answer = (mode.readTargets ?? []).includes(key) ? detailReadOf(key)?.axes ?? [] : []
142
- return [key.split('.').pop()!, ...card, ...answer]
143
- }
144
-
145
- /**
146
- * The categories a turn puts in front when the mode's tools do not fit in one call: the mode's own, the AI 작업 패널, the
147
- * people list and the invite card, the attachment reader, and the open screen's records. The rest the model opens with `openTools`.
148
- */
149
- export function modeFrontCategories(mode: FrontMode, screen: TurnScreen = {}): string[] {
150
- const keys = screenTargetKeys(mode, screen)
151
- return [
152
- ...new Set([
153
- ...(mode.toolCategories ?? []),
154
- 'assistant-workspace',
155
- /*
156
- * Two tools, always in front: 「정연희 초대해 줘」 asked in a conversation whose tools did not fit got the answer that
157
- * there was no tool to look people up (2026-10-24).
158
- */
159
- ...PEOPLE_CATEGORIES,
160
- /* Two tools, always in front: 「지출결의는 어디서 올려?」 is asked on any screen (ADR-0181). */
161
- HELP_CATEGORY,
162
- ...(mode.attachments?.kinds?.length ? ['chat-attachments'] : []),
163
- ...keys.filter(key => (mode.readTargets ?? []).includes(key)).map(key => `data-read:${key}`),
164
- ...keys.filter(key => (mode.entryTargets ?? []).includes(key)).map(key => `data-entry:${key}`),
165
- ...conversationCategoriesOf()
166
- .filter(one => (!!screen.page && (one.frontPages ?? []).includes(screen.page)) || (one.frontAxes ?? []).some(axis => axis === screen.subjectAxis || !!screen.selectionAxes?.includes(axis)))
167
- .map(one => one.name)
168
- ])
169
- ]
170
- }
171
-
172
- /** Each screen the mode could be asked from - a page that lists one of its records, a record's axis - for the boot report. */
173
- export function modeScreens(mode: FrontMode, routeOf: (key: string) => string | undefined = key => readTargetOf(key)?.screen?.route): TurnScreen[] {
174
- const keys = [...new Set([...(mode.readTargets ?? []), ...(mode.entryTargets ?? [])])]
175
- const pages = [...new Set([...keys.flatMap(key => pagesOfKey(mode, key, routeOf)), ...conversationCategoriesOf().flatMap(one => one.frontPages ?? [])])]
176
- const axes = [...new Set(keys.flatMap(key => axesOfKey(mode, key)))]
177
- return [{}, ...pages.map(page => ({ page })), ...axes.map(subjectAxis => ({ subjectAxis }))]
178
- }
@@ -1,181 +0,0 @@
1
- /*
2
- * What a turn puts in front when its mode's tools do not fit in one call (ADR-0061 decision 9) - the open screen's
3
- * records, found from what is already declared: a list's screen route and a key's last part.
4
- */
5
- import { clearReadTargets, declareDetailRead, declareReadTarget } from '../data-read/read-target'
6
- import { listReadTarget } from '../data-read/list-read'
7
- import { modeFrontCategories, modeScreens, screenTargetKeys, selectionAxesOf, SELECTION_KEYS_LINE } from './mode-categories'
8
- import { readFileSync } from 'node:fs'
9
- import { join } from 'node:path'
10
- import { clearEntryTargets, declareEntryTarget } from '../data-entry/entry-target'
11
-
12
- const list = (key: string, route?: string) =>
13
- listReadTarget({ key, title: `title.${key}`, name: key, listQuery: 'rows', selection: 'id name', columns: [{ name: 'name', type: 'string' }], ...(route ? { route } : {}) } as any)
14
-
15
- const mode = {
16
- toolCategories: ['office-ops'],
17
- attachments: { kinds: ['image'] },
18
- readTargets: ['office.cash-transaction', 'office.contract', 'office.contract-allocation', 'office.loan-summary'],
19
- entryTargets: ['office.cash-transaction', 'office.contract', 'office.contract-round', 'office.expense-line']
20
- }
21
-
22
- beforeEach(() => {
23
- clearReadTargets()
24
- declareReadTarget(list('office.cash-transaction', 'cash-transaction-list'))
25
- declareReadTarget(list('office.contract', 'contract-list'))
26
- declareReadTarget(list('office.contract-allocation', 'contract-allocation-list'))
27
- })
28
-
29
- describe('the open screen decides what goes in front', () => {
30
- it('★ a list page: that list read and its record entered - one key, both ways', () => {
31
- expect(modeFrontCategories(mode, { page: 'cash-transaction-list' })).toEqual([
32
- 'office-ops',
33
- 'assistant-workspace',
34
- 'data-read:organization.employee',
35
- 'chat-invite',
36
- 'help-documents',
37
- 'chat-attachments',
38
- 'data-read:office.cash-transaction',
39
- 'data-entry:office.cash-transaction'
40
- ])
41
- })
42
-
43
- it('★ a record\'s conversation: the keys whose last part is its axis - never a key that only starts with it', () => {
44
- expect(screenTargetKeys(mode, { subjectAxis: 'contract' })).toEqual(['office.contract'])
45
- expect(screenTargetKeys(mode, { subjectAxis: 'contract-round' })).toEqual(['office.contract-round'])
46
- })
47
-
48
- it('★ the rows a person picked put their list in front - by the axis of their keys, from the latest note only', () => {
49
- const rows = [
50
- { role: 'system', content: 'Selected 1 · 미수금: H1\n[keys] contracts contract:a1' },
51
- { role: 'user', content: '[keys] loans loan:x - typed by a person, never read for it' },
52
- { role: 'system', content: 'Selected 2 · 입출금: A, B\n[keys] transactions cash-transaction:b1 cash-transaction:b2' }
53
- ]
54
- expect(selectionAxesOf(rows)).toEqual(['cash-transaction'])
55
- expect(selectionAxesOf(rows.slice(0, 2))).toEqual(['contract'])
56
- expect(selectionAxesOf([{ role: 'system', content: 'Selected 1 · L\n[keys] rows a1' }])).toEqual([])
57
- expect(selectionAxesOf([])).toEqual([])
58
- expect(screenTargetKeys(mode, { selectionAxes: ['contract'] })).toEqual(['office.contract'])
59
- expect(modeFrontCategories(mode, { page: 'receivable-page', selectionAxes: ['contract'] })).toEqual(expect.arrayContaining(['data-read:office.contract', 'data-entry:office.contract']))
60
- })
61
-
62
- it('★ a turn puts the stored conversation\'s selection in front - never the client\'s', () => {
63
- const resolver = readFileSync(join(__dirname, '../assistant-chat-resolver.ts'), 'utf-8')
64
- expect(resolver).toMatch(/modeFrontCategories\([\s\S]{0,400}selectionAxes: selectionAxesOf\(storedRows as any\)/)
65
- })
66
-
67
- it('the note\'s key line is the one the client writes', () => {
68
- const client = readFileSync(join(__dirname, '../../../client/utils/assistant-selection.ts'), 'utf-8')
69
- expect(client).toContain(`export const SELECTION_KEYS_PREFIX = '${SELECTION_KEYS_LINE}'`)
70
- })
71
-
72
- it('★ a record the mode does not read or enter is not put in front', () => {
73
- expect(modeFrontCategories({ ...mode, readTargets: [], entryTargets: [] }, { page: 'cash-transaction-list' })).toEqual(['office-ops', 'assistant-workspace', 'data-read:organization.employee', 'chat-invite', 'help-documents', 'chat-attachments'])
74
- })
75
-
76
- it('no screen: the mode\'s own, the AI 작업 패널 and the attachment reader', () => {
77
- expect(modeFrontCategories(mode)).toEqual(['office-ops', 'assistant-workspace', 'data-read:organization.employee', 'chat-invite', 'help-documents', 'chat-attachments'])
78
- expect(modeFrontCategories(mode, { page: 'some-other-page' })).toEqual(['office-ops', 'assistant-workspace', 'data-read:organization.employee', 'chat-invite', 'help-documents', 'chat-attachments'])
79
- })
80
-
81
- it('the screens the boot report walks: none, each list page, each axis', () => {
82
- expect(modeScreens(mode)).toEqual([
83
- {},
84
- { page: 'cash-transaction-list' },
85
- { page: 'contract-list' },
86
- { page: 'contract-allocation-list' },
87
- { subjectAxis: 'cash-transaction' },
88
- { subjectAxis: 'contract' },
89
- { subjectAxis: 'contract-allocation' },
90
- { subjectAxis: 'loan-summary' },
91
- { subjectAxis: 'contract-round' },
92
- { subjectAxis: 'expense-line' }
93
- ])
94
- })
95
- })
96
-
97
- /* 2026-10-24: asked to link a deposit from its 360, the model read the evidence and never opened the link card. */
98
- describe('a card about several records is in front on each of their screens', () => {
99
- const link = {
100
- key: 'office.tax-invoice-binding',
101
- labelKey: 'label.link',
102
- description: 'a link of an invoice to a bank line or a round.',
103
- mutation: 'mutation ($binding: Binding!) { bind(binding: $binding) { id } }',
104
- variables: (row: any) => ({ binding: row.values }),
105
- appliedOf: (data: any) => ({ id: data?.bind?.id }),
106
- fields: [{ name: 'amount', type: 'number' as const, required: true }],
107
- axes: ['cash-transaction', 'tax-invoice', 'contract-round']
108
- }
109
- const linking = { ...mode, entryTargets: [...mode.entryTargets, link.key] }
110
- beforeEach(() => {
111
- clearEntryTargets()
112
- declareEntryTarget(link as any)
113
- })
114
-
115
- it('★ a deposit\'s 360 puts the link card in front with the deposit\'s own', () => {
116
- expect(screenTargetKeys(linking, { subjectAxis: 'cash-transaction' })).toEqual(['office.cash-transaction', 'office.tax-invoice-binding'])
117
- expect(modeFrontCategories(linking, { subjectAxis: 'cash-transaction' })).toContain('data-entry:office.tax-invoice-binding')
118
- expect(screenTargetKeys(linking, { subjectAxis: 'contract-round' })).toEqual(['office.contract-round', 'office.tax-invoice-binding'])
119
- })
120
-
121
- it('★ not on a screen of a record it does not join, and not for a mode that does not enter it', () => {
122
- expect(screenTargetKeys(linking, { subjectAxis: 'contract' })).toEqual(['office.contract'])
123
- expect(screenTargetKeys(mode, { subjectAxis: 'cash-transaction' })).toEqual(['office.cash-transaction'])
124
- })
125
-
126
- it('the boot report walks the axes a card declares, so its screens are counted against the budget', () => {
127
- expect(modeScreens(linking)).toContainEqual({ subjectAxis: 'tax-invoice' })
128
- })
129
- })
130
-
131
- /* 2026-10-24: asked on a deposit's 360 why it was in the management check, the model never opened the check read. */
132
- describe('a whole answer about any record is in front on their screens', () => {
133
- const checks = { key: 'office.checks', description: 'the management check.', query: 'query { officeChecks { today } }', axes: ['cash-transaction', 'contract'] }
134
- const reading = { ...mode, readTargets: [...mode.readTargets, checks.key] }
135
- beforeEach(() => declareDetailRead(checks as any))
136
-
137
- it('★ the check read is in front on a deposit\'s and a contract\'s 360', () => {
138
- expect(modeFrontCategories(reading, { subjectAxis: 'cash-transaction' })).toContain('data-read:office.checks')
139
- expect(modeFrontCategories(reading, { subjectAxis: 'contract' })).toContain('data-read:office.checks')
140
- })
141
-
142
- it('★ not on a record it does not cover, nor for a mode that does not read it', () => {
143
- expect(modeFrontCategories(reading, { subjectAxis: 'expense-line' })).not.toContain('data-read:office.checks')
144
- expect(modeFrontCategories(mode, { subjectAxis: 'cash-transaction' })).not.toContain('data-read:office.checks')
145
- })
146
- })
147
-
148
- /* 2026-11-12: asked 「AI로 초안 작성」 on 내 주간업무보고, neither the week's read nor the report line card was in front. */
149
- describe('a page puts in front the cards seen on it and the reads that name it', () => {
150
- const line = {
151
- key: 'office.weekly-report-line',
152
- labelKey: 'label.line',
153
- description: 'a line of the weekly report.',
154
- mutation: 'mutation ($line: Line!) { saveLine(line: $line) { id } }',
155
- variables: (row: any) => ({ line: row.values }),
156
- appliedOf: (data: any) => ({ id: data?.saveLine?.id }),
157
- fields: [{ name: 'content', type: 'string' as const, required: true }],
158
- screen: 'my-weekly-report'
159
- }
160
- const week = { key: 'office.my-weekly-report', description: 'the week.', query: 'query ($weekStart: String!) { myWeeklyReport(weekStart: $weekStart) { id } }', args: [{ name: 'weekStart', type: 'date', required: true }], frontPages: ['my-weekly-report'] }
161
- const writing = { ...mode, readTargets: [...mode.readTargets, week.key], entryTargets: [...mode.entryTargets, line.key] }
162
- beforeEach(() => {
163
- clearEntryTargets()
164
- declareEntryTarget(line as any)
165
- declareDetailRead(week as any)
166
- })
167
-
168
- it('★ on 내 주간업무보고 the week\'s read and the line card are in front', () => {
169
- expect(screenTargetKeys(writing, { page: 'my-weekly-report' })).toEqual(['office.my-weekly-report', 'office.weekly-report-line'])
170
- expect(modeFrontCategories(writing, { page: 'my-weekly-report' })).toEqual(expect.arrayContaining(['data-read:office.my-weekly-report', 'data-entry:office.weekly-report-line']))
171
- })
172
-
173
- it('★ not on another page, nor for a mode that does not read or enter them', () => {
174
- expect(screenTargetKeys(writing, { page: 'cash-transaction-list' })).toEqual(['office.cash-transaction'])
175
- expect(screenTargetKeys(mode, { page: 'my-weekly-report' })).toEqual([])
176
- })
177
-
178
- it('the boot report walks those pages, so they are counted against the budget', () => {
179
- expect(modeScreens(writing)).toContainEqual({ page: 'my-weekly-report' })
180
- })
181
- })
@@ -1,37 +0,0 @@
1
- /*
2
- * A screen has one conversation (operato-application design/ai/screen-pattern.md §3).
3
- *
4
- * Two conversations on one subject put a picker in front of the person, a choice between our internal units. The
5
- * boot report names the subject instead, and the screen opens the one conversation for what it shows.
6
- */
7
- import { assistantModeForSubject, clearAssistantModes, getAssistantModeWarnings, registerAssistantMode } from './registry'
8
-
9
- const persona = 'you are here'
10
-
11
- describe('assistant mode — one conversation per subject', () => {
12
- beforeEach(() => clearAssistantModes())
13
- afterAll(() => clearAssistantModes())
14
-
15
- it('★ two conversations on one subject is a boot warning naming both', () => {
16
- registerAssistantMode({ kind: 'twin.board', systemPrompt: persona, subjects: ['board'] })
17
- registerAssistantMode({ kind: 'twin.space', systemPrompt: persona, subjects: ['space', 'board'] })
18
-
19
- const twice = getAssistantModeWarnings().filter(w => w.code === 'assistant-mode-subject-claimed-twice')
20
- expect(twice.map(w => w.params.subject)).toEqual(['board'])
21
- expect(twice[0].params.kinds).toEqual(['twin.board', 'twin.space'])
22
- })
23
-
24
- it('one conversation on each subject says nothing', () => {
25
- registerAssistantMode({ kind: 'twin.board', systemPrompt: persona, subjects: ['board'] })
26
- registerAssistantMode({ kind: 'twin.space', systemPrompt: persona, subjects: ['space'] })
27
-
28
- expect(getAssistantModeWarnings()).toEqual([])
29
- })
30
-
31
- it('★ a screen opens the conversation for its subject, and nothing for a subject nobody declared', () => {
32
- registerAssistantMode({ kind: 'plant.station', systemPrompt: persona, subjects: ['station'] })
33
-
34
- expect(assistantModeForSubject('station')?.kind).toBe('plant.station')
35
- expect(assistantModeForSubject('nothing-shows-this')).toBeUndefined()
36
- })
37
- })