@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,334 +0,0 @@
1
- /*
2
- * The tools of an AI 조회 target (operato-application/design/ai/read-targets.md §4, §5).
3
- *
4
- * query<X> reads the rows through the application's list query as the person, and tells the model the count, the
5
- * sums, the groups and a few rows. A longer result goes on the AI 작업 패널 as a proposal the server builds from the rows
6
- * themselves - the table is never written by the model. open<X>Screen reads nothing: it hands the card the address
7
- * of the application's list screen with the conditions it takes.
8
- */
9
- import { registerToolCategory, type ToolCategory, type ToolSpec } from '@things-factory/ai-client-base'
10
-
11
- import { readFieldValue, rootFieldOf } from '../data-entry/entry-target.js'
12
- import type { GraphqlRunner } from '../data-entry/entry-update.js'
13
- import { runAsCaller } from '../data-entry/entry-tools.js'
14
- import { normalizeWorkspace, workspaceContents } from '../workspace/workspace-blocks.js'
15
- import {
16
- declareReadTarget,
17
- filtersOf,
18
- currenciesOf,
19
- declareDetailRead,
20
- detailToolName,
21
- MAX_DETAIL_CHARS,
22
- type DetailArg,
23
- type DetailRead,
24
- groupsOf,
25
- legendOf,
26
- queryToolName,
27
- readCategoryName,
28
- readCriteria,
29
- readRows,
30
- ROWS_FOR_MODEL,
31
- screenAddress,
32
- screenToolName,
33
- sumsOf,
34
- wordOf,
35
- type ReadCriterion,
36
- type ReadTarget
37
- } from './read-target.js'
38
-
39
- /** The reader's words for a key - the key's own default when the translator has none. */
40
- const wordsOf = (context: any) => (key: string | undefined, fallback: string) => {
41
- if (!key || typeof context?.t !== 'function') return fallback
42
- try {
43
- const said = context.t(key)
44
- return said && said !== key ? String(said) : fallback
45
- } catch {
46
- return fallback
47
- }
48
- }
49
-
50
- function criterionSchema(criterion: ReadCriterion): any {
51
- /* One type per field - Gemini's function schema refuses a list of types (2026-10-01). */
52
- const type = criterion.type === 'number' ? 'number' : criterion.type === 'integer' ? 'integer' : criterion.type === 'boolean' ? 'boolean' : 'string'
53
- const said = [criterion.description, criterion.type === 'date' ? 'YYYY-MM-DD' : criterion.format === 'month' ? 'YYYY-MM' : undefined, criterion.type === 'enum' ? `one of: ${criterion.values!.join(', ')}` : undefined]
54
- .filter(Boolean)
55
- .join('. ')
56
- if (criterion.many) return { type: 'array', items: { type }, ...(said ? { description: `${said} - one or more` } : {}) }
57
- return { type, ...(said ? { description: said } : {}) }
58
- }
59
-
60
- export async function queryRecords(target: ReadTarget, args: any, context: any, run: GraphqlRunner) {
61
- const { criteria, refused } = readCriteria(target, args)
62
- if (refused.length) {
63
- return { rejected: true, error: 'condition-unreadable', refused, message: `these conditions do not fit their type: ${refused.map(one => `${one.name} (${one.code})`).join(', ')}. Fix them and call again.` }
64
- }
65
- let read
66
- try {
67
- read = await readRows(target, filtersOf(target, criteria), run, typeof criteria.text === 'string' && target.search ? criteria.text : undefined, {
68
- timeZone: context?.state?.domain?.timezone
69
- })
70
- } catch (error: any) {
71
- return { rejected: true, error: 'query-failed', message: `the list could not be read: ${error?.message ?? error}` }
72
- }
73
- const { rows, total, complete } = read
74
- const sums = sumsOf(target, rows)
75
- const groupBy = typeof args?.groupBy === 'string' && args.groupBy ? args.groupBy : undefined
76
- const groups = groupBy ? groupsOf(target, rows, groupBy) : undefined
77
- const words = wordsOf(context)
78
- const label = words(target.labelKey, target.key)
79
- /* The rows keep their codes - a condition names them; the person is told the words (ADR-0163, 2026-10-26). */
80
- const legend = legendOf(target.columns, rows, words)
81
-
82
- const said = {
83
- target: target.key,
84
- criteria,
85
- total,
86
- read: rows.length,
87
- complete,
88
- sums,
89
- ...(groupBy ? (groups ? { groupBy, groups: groups.slice(0, 50), ...(groups.length > 50 ? { moreGroups: groups.length - 50 } : {}) } : { groupBy, groupRefused: 'no such column' }) : {}),
90
- rows: rows.slice(0, ROWS_FOR_MODEL),
91
- ...(rows.length > ROWS_FOR_MODEL ? { rowsNotShown: rows.length - ROWS_FOR_MODEL } : {}),
92
- ...(Object.keys(legend).length ? { legend, legendNote: 'a coded value is said by its word in legend, never by its code' } : {})
93
- }
94
- const incomplete = complete
95
- ? ''
96
- : ` Only ${rows.length} of ${total} rows were read; the sums and groups are of those rows, not of the list - say so, and ask the person to narrow the conditions.`
97
-
98
- if (rows.length === 1 && args?.show !== 'workspace') {
99
- return { ...said, record: rows[0], message: 'one record - answer from its fields; say a field it does not have as not recorded.' }
100
- }
101
- if (rows.length <= ROWS_FOR_MODEL && args?.show !== 'workspace') {
102
- return { ...said, message: `${rows.length} rows of ${total}.${incomplete} Answer from these rows; every number you say comes from them.` }
103
- }
104
-
105
- /* The workspace is built here from the rows as read - the model never copies the table. */
106
- const columns = target.columns.map(column => ({ name: column.name, label: words(column.labelKey, column.name), type: column.type }))
107
- const shownRows = rows.map(row => Object.fromEntries(Object.entries(row).map(([name, value]) => [name, wordOf(target.columns.find(one => one.name === name), value, words)])))
108
- const groupColumn = target.columns.find(one => one.name === groupBy)
109
- const totalColumns = target.columns.filter(one => one.total)
110
- /* A sum per currency is one figure and one group column per currency it holds - 「계약금액 (USD)」. */
111
- const sumColumns = totalColumns.flatMap(column => {
112
- const label = words(column.labelKey, column.name)
113
- const codes = currenciesOf([sums, ...(groups ?? []).map(group => group.sums)], column.name)
114
- return column.currency
115
- ? codes.map(code => ({ name: `${column.name}:${code}`, label: `${label} (${code})`, of: (one: Record<string, any>) => one[column.name]?.[code] ?? 0 }))
116
- : [{ name: column.name, label, of: (one: Record<string, any>) => one[column.name] }]
117
- })
118
- const title = typeof args?.title === 'string' && args.title.trim() ? args.title.trim() : `${label} · ${rows.length}`
119
- const { workspace } = normalizeWorkspace({
120
- name: typeof args?.name === 'string' && args.name ? args.name : target.key.replace(/\./g, '-'),
121
- title,
122
- ...(complete ? {} : { summary: `${total} / ${rows.length}` }),
123
- blocks: [
124
- {
125
- kind: 'metrics',
126
- items: [{ label: words('ai-assistant.read.count', 'rows'), value: String(rows.length), ...(complete ? {} : { note: `/ ${total}` }) }, ...sumColumns.map(column => ({ label: column.label, value: String(column.of(sums)) }))]
127
- },
128
- ...(groups
129
- ? [
130
- {
131
- kind: 'table',
132
- caption: words(target.columns.find(one => one.name === groupBy)?.labelKey, groupBy!),
133
- columns: [{ name: 'key', label: words(target.columns.find(one => one.name === groupBy)?.labelKey, groupBy!), type: 'string' }, { name: 'count', label: words('ai-assistant.read.count', 'rows'), type: 'number' }, ...sumColumns.map(column => ({ name: column.name, label: column.label, type: 'number' }))],
134
- rows: groups.map(group => ({ key: wordOf(groupColumn, group.key, words), count: group.count, ...Object.fromEntries(sumColumns.map(column => [column.name, column.of(group.sums)])) }))
135
- }
136
- ]
137
- : []),
138
- { kind: 'table', caption: label, columns, rows: shownRows }
139
- ]
140
- })
141
- return {
142
- proposed: true,
143
- kind: 'workspace',
144
- icon: 'table_view',
145
- label: title,
146
- ...said,
147
- forScreen: { workspace, contents: workspaceContents(workspace!) },
148
- message: `${rows.length} rows of ${total} are on the AI 작업 패널 as read - the person opens it from the card.${incomplete} Say the point in one or two lines from the sums, groups and rows above; do not write the table out.`
149
- }
150
- }
151
-
152
- export function openScreen(target: ReadTarget, args: any, context: any) {
153
- const { criteria, refused } = readCriteria(target, args)
154
- if (refused.length) return { rejected: true, error: 'condition-unreadable', refused, message: 'fix the conditions and call again.' }
155
- const address = screenAddress(target, criteria)
156
- if (!address) return { rejected: true, error: 'no-screen', message: 'this list has no screen to open.' }
157
- const words = wordsOf(context)
158
- return {
159
- proposed: true,
160
- kind: 'open-page',
161
- icon: 'open_in_new',
162
- label: words(target.screen!.labelKey ?? target.labelKey, target.key),
163
- target: target.key,
164
- href: address.href,
165
- applied: address.applied,
166
- notApplied: address.notApplied,
167
- /* The card says them in the reader's words. */
168
- notAppliedLabels: address.notApplied.map(name => words(target.criteria.find(one => one.name === name)?.labelKey ?? (name === 'text' || name === 'id' ? `ai-assistant.read.${name}` : undefined), name)),
169
- message:
170
- 'the card opens the screen when the person presses it.' +
171
- (address.notApplied.length ? ` The screen does not take ${address.notApplied.join(', ')} - say so.` : '')
172
- }
173
- }
174
-
175
- export function readCategoryOf(target: ReadTarget, run: (context: any) => GraphqlRunner = runAsCaller): ToolCategory {
176
- const door = rootFieldOf(target.query, 'query')
177
- const conditions = {
178
- ...Object.fromEntries(target.criteria.map(criterion => [criterion.name, criterionSchema(criterion)])),
179
- ...(target.search ? { text: { type: 'string', description: `words to find - ${target.search.description}` } } : {})
180
- }
181
- const specs: ToolSpec[] = [
182
- {
183
- kind: 'read',
184
- name: queryToolName(target.key),
185
- /* The person must be able to read the list on its screen - the tool is not a second way in. */
186
- doors: [door],
187
- description:
188
- `Read ${target.description} Set the conditions the question names. Returns the count, the sums, ` +
189
- `groups when groupBy is given (a date column groups by month) and the first ${ROWS_FOR_MODEL} rows; more rows go on the AI 작업 패널 as read.`,
190
- schema: {
191
- type: 'object',
192
- properties: {
193
- id: { type: 'string', description: 'One record by its id, from an earlier answer - its detail.' },
194
- ...conditions,
195
- groupBy: { type: 'string', description: `One column to group by: ${target.columns.map(one => one.name).join(', ')}.` },
196
- show: { type: 'string', enum: ['answer', 'workspace'], description: 'workspace to put even a short result on the AI 작업 패널.' },
197
- title: { type: 'string', description: 'The workspace title, in the person\'s language.' },
198
- name: { type: 'string', description: 'The workspace key; the same key again makes a new version.' }
199
- }
200
- },
201
- builder: (args: any, context: any) => queryRecords(target, args, context, run(context))
202
- } as ToolSpec,
203
- ...(target.screen
204
- ? [
205
- {
206
- kind: 'read',
207
- name: screenToolName(target.key),
208
- doors: [door],
209
- description: `Offer the person the screen that lists ${target.description} with these conditions. Reads nothing. The screen takes: ${target.screen.takes.join(', ')}.`,
210
- schema: { type: 'object', properties: conditions },
211
- builder: (args: any, context: any) => openScreen(target, args, context)
212
- } as ToolSpec
213
- ]
214
- : [])
215
- ]
216
- return {
217
- name: readCategoryName(target.key),
218
- description: `data read: ${target.key}`,
219
- guidance: [
220
- `- To answer from ${target.key} records - a list, or one record found by its name, code or id - call ${queryToolName(target.key)} with the conditions the question names. Every number you say comes from its result - never add up rows yourself; use its sums and groups.`,
221
- `- A list, a summary by item or month, or a comparison: call it with groupBy, and let a long result go on the AI 작업 패널 - then answer in one or two lines.`,
222
- `- When the result says complete: false, say how many of how many were read and ask to narrow - never call partial sums the total.`,
223
- ...(target.columns.some(one => one.currency)
224
- ? [`- Sums of ${target.columns.filter(one => one.currency).map(one => one.name).join(', ')} come per currency. Say each currency's sum; never add two currencies into one number. A comparison across currencies uses a rate you read, and says the rate and its date.`]
225
- : []),
226
- ...(target.screen ? [`- When the person wants to work on the records themselves (edit, sort, export), call ${screenToolName(target.key)}; say which conditions the screen does not take.`] : [])
227
- ].join('\n'),
228
- specs
229
- }
230
- }
231
-
232
- /**
233
- * What an application calls at boot to let the assistant read one of its lists. A mode opens it by naming the key
234
- * in `readTargets`.
235
- */
236
- export function registerReadTarget(target: ReadTarget): void {
237
- declareReadTarget(target)
238
- registerToolCategory(readCategoryOf(target))
239
- }
240
-
241
- /* ── One answer of a query (DetailRead) ───────────────────────────────────────────────────────────────────── */
242
-
243
- function argSchema(arg: DetailArg): any {
244
- const type = arg.type === 'number' ? 'number' : arg.type === 'integer' ? 'integer' : arg.type === 'boolean' ? 'boolean' : 'string'
245
- const said = [arg.description, arg.type === 'date' ? 'YYYY-MM-DD' : undefined, arg.type === 'enum' ? `one of: ${arg.values!.join(', ')}` : undefined].filter(Boolean).join('. ')
246
- return { type, ...(said ? { description: said } : {}) }
247
- }
248
-
249
- /**
250
- * What running a detail read as the person gave - the root field's value, or why there is none. Shared by the tool,
251
- * which hands the value to the model, and by every other reader of a detail read (a dashboard card, ADR-0160
252
- * decision 2), which has its own limits: the arguments, the door and the query are one, the size rule is the tool's.
253
- */
254
- export interface DetailRun {
255
- /** The root field's value - absent when `error` says why. */
256
- value?: unknown
257
- error?: 'argument-unreadable' | 'query-failed' | 'not-found'
258
- refused?: { name: string; code: string }[]
259
- message?: string
260
- }
261
-
262
- /** Runs the query as the person with the arguments given - read by their declared types, a missing required one refused. */
263
- export async function runDetail(target: DetailRead, args: any, run: GraphqlRunner): Promise<DetailRun> {
264
- const variables: Record<string, unknown> = {}
265
- const refused: { name: string; code: string }[] = []
266
- for (const arg of target.args ?? []) {
267
- const value = args?.[arg.name]
268
- if (value === undefined || value === null || value === '') {
269
- if (arg.required) refused.push({ name: arg.name, code: 'required' })
270
- continue
271
- }
272
- const { read, code } = readFieldValue({ name: arg.name, type: arg.type === 'string' ? 'text' : arg.type, values: arg.values, axis: arg.axis } as any, value)
273
- if (read === undefined) refused.push({ name: arg.name, code: code ?? 'unreadable' })
274
- else variables[arg.name] = read
275
- }
276
- if (refused.length) return { error: 'argument-unreadable', refused }
277
- let answer
278
- try {
279
- answer = await run(target.query, variables)
280
- } catch (error: any) {
281
- return { error: 'query-failed', message: String(error?.message ?? error) }
282
- }
283
- if (answer.errors?.length) return { error: 'query-failed', message: answer.errors.map(one => one.message).join('; ') }
284
- const root = rootFieldOf(target.query, 'query').replace(/^Query\./, '')
285
- const value = answer.data?.[root]
286
- if (value === null || value === undefined) return { error: 'not-found' }
287
- return { value }
288
- }
289
-
290
- /** Runs the query as the person with the arguments the model set; the answer as the query returned it. */
291
- export async function queryDetail(target: DetailRead, args: any, run: GraphqlRunner) {
292
- const ran = await runDetail(target, args, run)
293
- if (ran.error) {
294
- if (ran.error === 'argument-unreadable')
295
- return { rejected: true, error: 'argument-unreadable', refused: ran.refused, message: `these arguments are missing or do not fit their type: ${ran.refused.map(one => `${one.name} (${one.code})`).join(', ')}. Fix them and call again.` }
296
- if (ran.error === 'query-failed') return { rejected: true, error: 'query-failed', message: `it could not be read: ${ran.message}` }
297
- return { target: target.key, found: false, message: 'nothing was found for these arguments - say so; do not fill it in.' }
298
- }
299
- const value = ran.value
300
- const size = JSON.stringify(value).length
301
- if (size > MAX_DETAIL_CHARS) return { rejected: true, error: 'answer-too-large', size, message: `the answer runs to ${size} characters, more than ${MAX_DETAIL_CHARS} - narrow the arguments, or read the list it is made of.` }
302
- return { target: target.key, answer: value, message: 'answer from these fields; every number you say comes from them. Amounts are in the currency beside them - never add two currencies into one number.' }
303
- }
304
-
305
- export function detailCategoryOf(target: DetailRead, run: (context: any) => GraphqlRunner = runAsCaller): ToolCategory {
306
- const door = rootFieldOf(target.query, 'query')
307
- const name = detailToolName(target.key)
308
- return {
309
- name: readCategoryName(target.key),
310
- description: `data read: ${target.key}`,
311
- guidance: `- To answer about ${target.description.replace(/\.$/, '')}, call ${name}. Every number you say comes from its answer.`,
312
- specs: [
313
- {
314
- kind: 'read',
315
- name,
316
- /* The person must be able to run the query on its screen - the tool is not a second way in. */
317
- doors: [door],
318
- description: `Read ${target.description}`,
319
- schema: {
320
- type: 'object',
321
- ...((target.args ?? []).some(one => one.required) ? { required: (target.args ?? []).filter(one => one.required).map(one => one.name) } : {}),
322
- properties: Object.fromEntries((target.args ?? []).map(arg => [arg.name, argSchema(arg)]))
323
- },
324
- builder: (args: any, context: any) => queryDetail(target, args, run(context))
325
- } as ToolSpec
326
- ]
327
- }
328
- }
329
-
330
- /** What an application calls at boot to let the assistant read one answer of its API. A mode opens it by key in `readTargets`. */
331
- export function registerDetailRead(target: DetailRead): void {
332
- declareDetailRead(target)
333
- registerToolCategory(detailCategoryOf(target))
334
- }
@@ -1,99 +0,0 @@
1
- /*
2
- * What people read off a list (ADR-0163, 2026-10-26: answers and cards showed EVENT, unread and 2026-10-26T09:09:03Z):
3
- * a moment in the domain's time zone, and a coded value by its word - the rows keep the code, so a condition means the
4
- * same in every language.
5
- */
6
- import { listReadTarget } from './list-read'
7
- import { clearReadTargets, legendOf, localDateTime, rowOf, wordOf } from './read-target'
8
- import { queryRecords } from './read-tools'
9
-
10
- const WORDS: Record<string, string> = { 'notice.kind.HR': '인사', 'notice.kind.EVENT': '행사', 'notice.state.unread': '안 읽음' }
11
- const say = (key: string | undefined, fallback: string) => (key && WORDS[key]) || fallback
12
-
13
- describe('a moment', () => {
14
- it('★ is said in the domain\'s time zone, to the minute', () => {
15
- expect(localDateTime('2026-10-26T09:09:03.235Z', 'Asia/Seoul')).toBe('2026-10-26 18:09')
16
- /* Past midnight there, it is the next day. */
17
- expect(localDateTime('2026-10-26T20:00:00Z', 'Asia/Seoul')).toBe('2026-10-27 05:00')
18
- expect(localDateTime('2026-10-26T20:00:00Z', 'UTC')).toBe('2026-10-26 20:00')
19
- })
20
-
21
- it('★ a day, a month or anything else stays as it is', () => {
22
- expect(localDateTime('2026-10-26', 'Asia/Seoul')).toBe('2026-10-26')
23
- expect(localDateTime('2026-10', 'Asia/Seoul')).toBe('2026-10')
24
- expect(localDateTime('2026-10-26Tnot', 'Asia/Seoul')).toBe('2026-10-26Tnot')
25
- })
26
-
27
- it('★ a row reads its date columns so, and leaves the other columns alone', () => {
28
- const columns = [
29
- { name: 'at', type: 'date' as const },
30
- { name: 'note', type: 'string' as const }
31
- ]
32
- expect(rowOf({ columns }, { id: 'a', at: '2026-10-26T09:09:03.235Z', note: '2026-10-26T09:09:03.235Z' }, { timeZone: 'Asia/Seoul' })).toEqual({
33
- id: 'a',
34
- at: '2026-10-26 18:09',
35
- note: '2026-10-26T09:09:03.235Z'
36
- })
37
- })
38
- })
39
-
40
- describe('a coded value', () => {
41
- const kind = { name: 'kind', words: 'notice.kind.' }
42
- it('★ is read by its word, the code itself when there is none', () => {
43
- expect(wordOf(kind, 'HR', say)).toBe('인사')
44
- expect(wordOf(kind, 'SYSTEM', say)).toBe('SYSTEM')
45
- expect(wordOf({ name: 'title' }, 'HR', say)).toBe('HR')
46
- expect(wordOf(kind, null, say)).toBeNull()
47
- })
48
-
49
- it('★ the legend names the codes the rows hold, column by column', () => {
50
- expect(legendOf([kind, { name: 'title' }], [{ kind: 'HR', title: 'a' }, { kind: 'EVENT', title: 'b' }, { kind: null }], say)).toEqual({ kind: { HR: '인사', EVENT: '행사' } })
51
- })
52
- })
53
-
54
- describe('the read tool', () => {
55
- const target = listReadTarget({
56
- key: 'test.notices',
57
- title: 'title.notices',
58
- name: 'notices',
59
- listQuery: 'notices',
60
- selection: 'id title kind state publishedAt',
61
- columns: [
62
- { name: 'title', type: 'string' },
63
- { name: 'kind', type: 'string', words: 'notice.kind.' },
64
- { name: 'state', type: 'string', words: 'notice.state.' },
65
- { name: 'publishedAt', type: 'date' }
66
- ],
67
- status: { field: 'state', values: ['unread', 'read'] }
68
- })
69
- const items = Array.from({ length: 3 }, (_, i) => ({ id: `n${i}`, title: `t${i}`, kind: i ? 'EVENT' : 'HR', state: 'unread', publishedAt: '2026-10-26T09:09:03.235Z' }))
70
- const calls: any[] = []
71
- const run = async (_document: string, variables: any) => (calls.push(variables), { data: { notices: { items, total: items.length } } })
72
- /* Not this machine's zone - a read that forgot the domain's zone would read the machine's instead. */
73
- const context = { t: (key: string) => WORDS[key] ?? key, state: { domain: { timezone: 'UTC' } } }
74
-
75
- beforeEach(() => {
76
- clearReadTargets()
77
- calls.length = 0
78
- })
79
-
80
- it('★ gives the model the codes, their words and the moments in the domain\'s time - and its condition names the code', async () => {
81
- const result: any = await queryRecords(target, { status: 'unread' }, context, run)
82
- expect(calls[0].filters).toEqual([{ name: 'state', operator: 'eq', value: 'unread' }])
83
- expect(result.rows[0]).toMatchObject({ kind: 'HR', state: 'unread', publishedAt: '2026-10-26 09:09' })
84
- expect(result.legend).toEqual({ kind: { HR: '인사', EVENT: '행사' }, state: { unread: '안 읽음' } })
85
- })
86
-
87
- it('★ the 작업 패널 table shows the words', async () => {
88
- const result: any = await queryRecords(target, { show: 'workspace' }, context, run)
89
- const table = result.forScreen.workspace.blocks.find((one: any) => one.kind === 'table')
90
- expect(table.rows[0]).toMatchObject({ kind: '인사', state: '안 읽음', publishedAt: '2026-10-26 09:09' })
91
- })
92
- })
93
-
94
- describe('a column of many', () => {
95
- it('★ a path through a list reads each one, comma-separated - an invention\'s inventors', () => {
96
- const columns = [{ name: 'inventors', path: 'inventors.name', type: 'string' }, { name: 'none', path: 'none.name', type: 'string' }] as any
97
- expect(rowOf({ columns }, { id: 'a', inventors: [{ name: '김가람' }, { name: '이나래' }], none: [] })).toEqual({ id: 'a', inventors: '김가람, 이나래', none: null })
98
- })
99
- })
@@ -1,42 +0,0 @@
1
- /*
2
- * A read takes a record by the key it was shown by (2026-10-23) - `<axis>:<uuid>`, as an open record's anchor and an
3
- * application's evidence write it. A 360 read and a list read asked by id took the key as the id and found nothing.
4
- */
5
- import { readCriteria, type DetailRead, type ReadTarget } from './read-target'
6
- import { queryDetail } from './read-tools'
7
-
8
- const ID = 'f92c04ec-40c4-4be8-8160-080cff20e750'
9
-
10
- describe('a read names the record the model was shown', () => {
11
- const lines = { key: 'office.cash-transaction', criteria: [] } as unknown as ReadTarget
12
-
13
- it('★ a list read by id takes the key of its own axis - the target key\'s last part', () => {
14
- expect(readCriteria(lines, { id: `cash-transaction:${ID}` }).criteria).toEqual({ id: ID })
15
- expect(readCriteria(lines, { id: ID }).criteria).toEqual({ id: ID })
16
- /* Another record's key is not this record - asked as written, it finds nothing. */
17
- expect(readCriteria(lines, { id: `contract:${ID}` }).criteria).toEqual({ id: `contract:${ID}` })
18
- })
19
-
20
- it('★ a row whose own id is not a uuid is read by its key too - a training standing `<kind>:<year>:<employee>`', () => {
21
- const standings = { key: 'compliance.trainings', criteria: [] } as unknown as ReadTarget
22
- expect(readCriteria(standings, { id: `trainings:PRIVACY:2026:${ID}` }).criteria).toEqual({ id: `PRIVACY:2026:${ID}` })
23
- expect(readCriteria(standings, { id: `PRIVACY:2026:${ID}` }).criteria).toEqual({ id: `PRIVACY:2026:${ID}` })
24
- })
25
-
26
- it('★ a whole answer takes the key of the axis its id argument declares', async () => {
27
- const summary: DetailRead = {
28
- key: 'office.contract-360',
29
- description: "one contract's 360.",
30
- query: 'query ($id: String!) { contract360(id: $id) { code } }',
31
- args: [{ name: 'id', type: 'string', required: true, axis: 'contract' }]
32
- }
33
- const asked: any[] = []
34
- const run = async (_document: string, variables: any) => {
35
- asked.push(variables)
36
- return { data: { contract360: { code: 'H2026012' } } }
37
- }
38
- await queryDetail(summary, { id: `contract:${ID}` }, run)
39
- await queryDetail(summary, { id: `cash-transaction:${ID}` }, run)
40
- expect(asked).toEqual([{ id: ID }, { id: `cash-transaction:${ID}` }])
41
- })
42
- })
@@ -1,55 +0,0 @@
1
- /*
2
- * What this guards: the grounding warning does not fire on the person's own words.
3
- *
4
- * The guard compares identifiers in the answer against the evidence. The neutral door handed it
5
- * the tool results alone, so `EQ-CAM-DRIVER-01` — typed by the person, echoed by the assistant —
6
- * came back as an identifier with no basis whenever the tool that would have confirmed it refused
7
- * or was not called. A warning that fires on what the person just typed teaches people to ignore
8
- * warnings.
9
- */
10
- import { checkGrounding, buildGroundedCorpus } from '@things-factory/ai-client-base'
11
-
12
- import { groundingSourcesFor } from './grounding-sources'
13
-
14
- const corpus = (sources: any, toolResults: string[] = []) => buildGroundedCorpus({ ...sources, toolResults })
15
-
16
- it('★ an identifier the person typed is evidence', () => {
17
- const sources = groundingSourcesFor({
18
- systemPrompt: 'you answer about one space',
19
- messages: [{ content: 'EQ-CAM-DRIVER-01 을 가운데에 놓아줘' }]
20
- })
21
-
22
- expect(checkGrounding('EQ-CAM-DRIVER-01 배치를 제안했습니다', corpus(sources))).toEqual([])
23
- })
24
-
25
- it('★ an identifier the surface sent in its snapshot is evidence', () => {
26
- const sources = groundingSourcesFor({ hostContext: { components: [{ tag: 'EQ-CAM-DRIVER-01' }] } })
27
-
28
- expect(checkGrounding('EQ-CAM-DRIVER-01 은 이미 보드에 있습니다', corpus(sources))).toEqual([])
29
- })
30
-
31
- it('★ an identifier from nowhere is still flagged — this must not become an empty guard', () => {
32
- const sources = groundingSourcesFor({
33
- systemPrompt: 'you answer about one space',
34
- messages: [{ content: '지금 상태 알려줘' }],
35
- hostContext: { spaceId: 'S-12' }
36
- })
37
-
38
- expect(checkGrounding('EQ-NOT-REAL-99 가 멈춰 있습니다', corpus(sources))).toEqual(['EQ-NOT-REAL-99'])
39
- })
40
-
41
- it('the names in the system prompt are evidence — a mode may list what can be placed', () => {
42
- const sources = groundingSourcesFor({ systemPrompt: 'placeable types: twin-base-card, twin-storage' })
43
-
44
- expect(checkGrounding('twin-storage 로 놓겠습니다', corpus(sources))).toEqual([])
45
- })
46
-
47
- it('non-text turns and unserialisable context are left out rather than failing', () => {
48
- const circular: any = {}
49
- circular.self = circular
50
-
51
- const sources = groundingSourcesFor({ messages: [{ content: [{ type: 'image' }] as any }], hostContext: circular })
52
-
53
- expect(sources.messages).toBeUndefined()
54
- expect(sources.hostContext).toBeUndefined()
55
- })
@@ -1,46 +0,0 @@
1
- /*
2
- * What counts as evidence, besides the tool results (ADR-0042's cousin: the grounding guard).
3
- *
4
- * The guard flags identifiers in an answer that appear in none of the evidence — that is how an
5
- * invented order number or tag is caught. `ai-client-base` documents three legitimate sources
6
- * beside the tool results: the system prompt, the conversation itself, and the context the host
7
- * put in front of it. The neutral door passed none of them, so the corpus was the tool results
8
- * alone, and an identifier the **person themselves typed** came back flagged as unfounded.
9
- *
10
- * A warning that fires on the person's own words is worse than no warning: a few of those and the
11
- * warning stops being read, including the time it is right.
12
- */
13
- export interface GroundingSourceInput {
14
- systemPrompt?: string
15
- /** The turns handed to the model this call. Image parts and other non-text carry no identifiers. */
16
- messages?: Array<{ content?: unknown }>
17
- /** What the surface said it is looking at. Client-supplied, and evidence about that person's screen. */
18
- hostContext?: unknown
19
- }
20
-
21
- export function groundingSourcesFor(input: GroundingSourceInput): {
22
- systemPrompt?: string
23
- messages?: string[]
24
- hostContext?: string
25
- } {
26
- const messages = (input.messages ?? [])
27
- .map(message => (typeof message?.content === 'string' ? message.content : ''))
28
- .filter(Boolean)
29
-
30
- return {
31
- systemPrompt: input.systemPrompt,
32
- messages: messages.length ? messages : undefined,
33
- hostContext: stringifyHostContext(input.hostContext)
34
- }
35
- }
36
-
37
- /** The snapshot is evidence as text — only identifier tokens are read out of it. */
38
- function stringifyHostContext(hostContext: unknown): string | undefined {
39
- if (!hostContext || typeof hostContext !== 'object') return undefined
40
- try {
41
- return JSON.stringify(hostContext)
42
- } catch {
43
- /* A snapshot that cannot be serialised is no evidence — it is not a reason to fail the turn. */
44
- return undefined
45
- }
46
- }
@@ -1,2 +0,0 @@
1
- /* The help tools' category - every conversation carries it (mode-categories.ts), so it is named apart from the tools. */
2
- export const HELP_CATEGORY = 'help-documents'
@@ -1,40 +0,0 @@
1
- /*
2
- * The help tools (ADR-0181): the assistant finds a part of the application's help and reads it, in the person's language.
3
- */
4
- jest.mock('@things-factory/help', () => {
5
- const { HelpIndex, partsOfDocument } = jest.requireActual('../../../../help/server/help-index')
6
- const index = new HelpIndex([
7
- ...partsOfDocument('office/guide-employee.ko.html', '<h1>모든 직원</h1><h2 id="spending">경비 · 지출 올리기</h2><p>내 정보 › 내 지출결의 에서 새 결의를 작성합니다.</p>'),
8
- ...partsOfDocument('office/guide-employee.html', '<h1>Everyone</h1><h2 id="spending">Spending</h2><p>Write a new claim in My expense claims.</p>')
9
- ])
10
- return { searchHelp: async (q: string, o: any) => index.search(q, o), readHelp: async (t: string, s: string, l: string) => index.read(t, s, l) }
11
- })
12
-
13
- import { helpCategory, readHelpDocument, searchHelpDocuments } from './help-tools'
14
- import { modeFrontCategories, modeToolCategories } from '../assistant-mode/mode-categories'
15
-
16
- const korean = { state: { lng: 'ko' } }
17
-
18
- describe('the help tools', () => {
19
- it('finds a part with its title and its link', async () => {
20
- expect(await searchHelpDocuments({ query: '지출결의 올리기' }, korean)).toEqual({
21
- found: 1,
22
- parts: [{ topic: 'office/guide-employee', section: 'spending', title: '모든 직원 › 경비 · 지출 올리기', summary: '내 정보 › 내 지출결의 에서 새 결의를 작성합니다.', link: 'help?topic=office%2Fguide-employee&section=spending' }]
23
- })
24
- })
25
-
26
- it('says when the help has nothing, so the model does not answer from elsewhere', async () => {
27
- expect(await searchHelpDocuments({ query: '주식 매수 방법' }, korean)).toMatchObject({ found: 0, message: expect.stringContaining('say so') })
28
- })
29
-
30
- it('reads a part in the person\'s language', async () => {
31
- expect(await readHelpDocument({ topic: 'office/guide-employee', section: 'spending' }, { state: { lng: 'en' } })).toMatchObject({ found: true, title: 'Spending' })
32
- expect(await readHelpDocument({ topic: 'office/guide-employee', section: 'none' }, korean)).toMatchObject({ found: false })
33
- })
34
-
35
- it('reaches no door, and every conversation has it in front', () => {
36
- expect(helpCategory.specs.map(spec => spec.doors)).toEqual([[], []])
37
- expect(modeToolCategories({})).toContain('help-documents')
38
- expect(modeFrontCategories({})).toContain('help-documents')
39
- })
40
- })