@things-factory/ai-assistant 10.1.278 → 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 (531) 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/package.json +25 -10
  23. package/things-factory.config.js +4 -1
  24. package/translations/en.json +46 -4
  25. package/translations/es.json +43 -1
  26. package/translations/ja.json +43 -1
  27. package/translations/ko.json +46 -4
  28. package/translations/ms.json +43 -1
  29. package/translations/zh.json +43 -1
  30. package/client/bootstrap.ts +0 -27
  31. package/client/components/assistant-chat.test.ts +0 -149
  32. package/client/components/assistant-chat.ts +0 -5599
  33. package/client/components/assistant-dock.ts +0 -1036
  34. package/client/components/assistant-invite.ts +0 -138
  35. package/client/components/assistant-mode.test.ts +0 -119
  36. package/client/components/assistant-mode.ts +0 -174
  37. package/client/components/assistant-selection-bar.test.ts +0 -167
  38. package/client/components/assistant-selection-bar.ts +0 -178
  39. package/client/components/assistant-session-manager.ts +0 -915
  40. package/client/components/assistant-session-toolbar.ts +0 -80
  41. package/client/components/chat-defaults.ts +0 -64
  42. package/client/components/chat-echo-dedup.test.ts +0 -253
  43. package/client/components/chat-echo-dedup.ts +0 -190
  44. package/client/components/chat-input-builder.test.ts +0 -86
  45. package/client/components/chat-input-builder.ts +0 -133
  46. package/client/components/chat-proposal-survival.test.ts +0 -73
  47. package/client/components/entry-review.ts +0 -346
  48. package/client/components/markdown.test.ts +0 -518
  49. package/client/components/markdown.ts +0 -508
  50. package/client/components/mention-popup-helpers.ts +0 -433
  51. package/client/components/mention-popup.test.ts +0 -588
  52. package/client/components/mention-popup.ts +0 -261
  53. package/client/components/panel-aria.test.ts +0 -59
  54. package/client/components/proposal-outcome-line.ts +0 -74
  55. package/client/components/proposal-request.test.ts +0 -73
  56. package/client/components/reply-message.test.ts +0 -15
  57. package/client/components/reply-message.ts +0 -11
  58. package/client/components/roster-identity.test.ts +0 -8
  59. package/client/components/roster-identity.ts +0 -4
  60. package/client/components/workspace-view.ts +0 -486
  61. package/client/index.ts +0 -36
  62. package/client/pages/assistant-workspace-page.ts +0 -317
  63. package/client/route.ts +0 -9
  64. package/client/settings/agent-settings-model.ts +0 -164
  65. package/client/settings/ai-agent-setting-let.ts +0 -667
  66. package/client/settings/ai-usage-setting-let.ts +0 -240
  67. package/client/settings/usage-model.ts +0 -46
  68. package/client/setup-assistant-dock.ts +0 -177
  69. package/client/tsconfig.json +0 -13
  70. package/client/utils/addressed-draft.test.ts +0 -31
  71. package/client/utils/agent-choice.ts +0 -56
  72. package/client/utils/applied-screens.ts +0 -36
  73. package/client/utils/assistant-activity.ts +0 -122
  74. package/client/utils/assistant-ask.test.ts +0 -38
  75. package/client/utils/assistant-ask.ts +0 -93
  76. package/client/utils/assistant-capability-read.ts +0 -24
  77. package/client/utils/assistant-capability.test.ts +0 -17
  78. package/client/utils/assistant-capability.ts +0 -19
  79. package/client/utils/assistant-navigation.test.ts +0 -66
  80. package/client/utils/assistant-navigation.ts +0 -11
  81. package/client/utils/assistant-proposals.ts +0 -85
  82. package/client/utils/assistant-request-context.ts +0 -63
  83. package/client/utils/assistant-selection.test.ts +0 -54
  84. package/client/utils/assistant-selection.ts +0 -75
  85. package/client/utils/assistant-session-actions.ts +0 -32
  86. package/client/utils/assistant-session-admin.ts +0 -239
  87. package/client/utils/assistant-session-controller.test.ts +0 -75
  88. package/client/utils/assistant-session-controller.ts +0 -208
  89. package/client/utils/assistant-session-transport.ts +0 -46
  90. package/client/utils/assistant-surface.ts +0 -178
  91. package/client/utils/assistant-typing.test.ts +0 -33
  92. package/client/utils/assistant-typing.ts +0 -53
  93. package/client/utils/attachment-policy.ts +0 -106
  94. package/client/utils/composer-frame.ts +0 -77
  95. package/client/utils/document-text.ts +0 -332
  96. package/client/utils/entry-hash.ts +0 -35
  97. package/client/utils/entry-proposal.ts +0 -215
  98. package/client/utils/entry-workspace.ts +0 -70
  99. package/client/utils/invite-proposal-register.ts +0 -31
  100. package/client/utils/invite-proposal.test.ts +0 -40
  101. package/client/utils/invite-proposal.ts +0 -54
  102. package/client/utils/menu-room.ts +0 -33
  103. package/client/utils/open-page.ts +0 -21
  104. package/client/utils/pasted-table.ts +0 -145
  105. package/client/utils/pdf-pages.ts +0 -25
  106. package/client/utils/spreadsheet-text.ts +0 -125
  107. package/client/utils/workspace.ts +0 -89
  108. package/dist-client/bootstrap.js.map +0 -1
  109. package/dist-client/components/assistant-chat.js.map +0 -1
  110. package/dist-client/components/assistant-chat.test.d.ts +0 -1
  111. package/dist-client/components/assistant-chat.test.js +0 -138
  112. package/dist-client/components/assistant-chat.test.js.map +0 -1
  113. package/dist-client/components/assistant-dock.js.map +0 -1
  114. package/dist-client/components/assistant-invite.js.map +0 -1
  115. package/dist-client/components/assistant-mode.js.map +0 -1
  116. package/dist-client/components/assistant-mode.test.d.ts +0 -1
  117. package/dist-client/components/assistant-mode.test.js +0 -100
  118. package/dist-client/components/assistant-mode.test.js.map +0 -1
  119. package/dist-client/components/assistant-selection-bar.js.map +0 -1
  120. package/dist-client/components/assistant-selection-bar.test.d.ts +0 -1
  121. package/dist-client/components/assistant-selection-bar.test.js +0 -148
  122. package/dist-client/components/assistant-selection-bar.test.js.map +0 -1
  123. package/dist-client/components/assistant-session-manager.js.map +0 -1
  124. package/dist-client/components/assistant-session-toolbar.js.map +0 -1
  125. package/dist-client/components/chat-defaults.js.map +0 -1
  126. package/dist-client/components/chat-echo-dedup.js.map +0 -1
  127. package/dist-client/components/chat-echo-dedup.test.d.ts +0 -1
  128. package/dist-client/components/chat-echo-dedup.test.js +0 -223
  129. package/dist-client/components/chat-echo-dedup.test.js.map +0 -1
  130. package/dist-client/components/chat-input-builder.js.map +0 -1
  131. package/dist-client/components/chat-input-builder.test.d.ts +0 -1
  132. package/dist-client/components/chat-input-builder.test.js +0 -70
  133. package/dist-client/components/chat-input-builder.test.js.map +0 -1
  134. package/dist-client/components/chat-proposal-survival.test.d.ts +0 -1
  135. package/dist-client/components/chat-proposal-survival.test.js +0 -61
  136. package/dist-client/components/chat-proposal-survival.test.js.map +0 -1
  137. package/dist-client/components/entry-review.js.map +0 -1
  138. package/dist-client/components/markdown.js.map +0 -1
  139. package/dist-client/components/markdown.test.d.ts +0 -1
  140. package/dist-client/components/markdown.test.js +0 -418
  141. package/dist-client/components/markdown.test.js.map +0 -1
  142. package/dist-client/components/mention-popup-helpers.js.map +0 -1
  143. package/dist-client/components/mention-popup.js.map +0 -1
  144. package/dist-client/components/mention-popup.test.d.ts +0 -1
  145. package/dist-client/components/mention-popup.test.js +0 -474
  146. package/dist-client/components/mention-popup.test.js.map +0 -1
  147. package/dist-client/components/panel-aria.test.d.ts +0 -1
  148. package/dist-client/components/panel-aria.test.js +0 -53
  149. package/dist-client/components/panel-aria.test.js.map +0 -1
  150. package/dist-client/components/proposal-outcome-line.js.map +0 -1
  151. package/dist-client/components/proposal-request.test.d.ts +0 -1
  152. package/dist-client/components/proposal-request.test.js +0 -63
  153. package/dist-client/components/proposal-request.test.js.map +0 -1
  154. package/dist-client/components/reply-message.js.map +0 -1
  155. package/dist-client/components/reply-message.test.d.ts +0 -1
  156. package/dist-client/components/reply-message.test.js +0 -16
  157. package/dist-client/components/reply-message.test.js.map +0 -1
  158. package/dist-client/components/roster-identity.js.map +0 -1
  159. package/dist-client/components/roster-identity.test.d.ts +0 -1
  160. package/dist-client/components/roster-identity.test.js +0 -9
  161. package/dist-client/components/roster-identity.test.js.map +0 -1
  162. package/dist-client/components/workspace-view.js.map +0 -1
  163. package/dist-client/index.js.map +0 -1
  164. package/dist-client/pages/assistant-workspace-page.js.map +0 -1
  165. package/dist-client/route.js.map +0 -1
  166. package/dist-client/settings/agent-settings-model.js.map +0 -1
  167. package/dist-client/settings/ai-agent-setting-let.js.map +0 -1
  168. package/dist-client/settings/ai-usage-setting-let.d.ts +0 -25
  169. package/dist-client/settings/ai-usage-setting-let.js +0 -258
  170. package/dist-client/settings/ai-usage-setting-let.js.map +0 -1
  171. package/dist-client/settings/usage-model.d.ts +0 -32
  172. package/dist-client/settings/usage-model.js +0 -25
  173. package/dist-client/settings/usage-model.js.map +0 -1
  174. package/dist-client/setup-assistant-dock.js.map +0 -1
  175. package/dist-client/tsconfig.tsbuildinfo +0 -1
  176. package/dist-client/utils/addressed-draft.test.d.ts +0 -1
  177. package/dist-client/utils/addressed-draft.test.js +0 -27
  178. package/dist-client/utils/addressed-draft.test.js.map +0 -1
  179. package/dist-client/utils/agent-choice.js.map +0 -1
  180. package/dist-client/utils/applied-screens.js.map +0 -1
  181. package/dist-client/utils/assistant-activity.js.map +0 -1
  182. package/dist-client/utils/assistant-ask.js.map +0 -1
  183. package/dist-client/utils/assistant-ask.test.d.ts +0 -1
  184. package/dist-client/utils/assistant-ask.test.js +0 -40
  185. package/dist-client/utils/assistant-ask.test.js.map +0 -1
  186. package/dist-client/utils/assistant-capability-read.js.map +0 -1
  187. package/dist-client/utils/assistant-capability.js.map +0 -1
  188. package/dist-client/utils/assistant-capability.test.d.ts +0 -1
  189. package/dist-client/utils/assistant-capability.test.js +0 -16
  190. package/dist-client/utils/assistant-capability.test.js.map +0 -1
  191. package/dist-client/utils/assistant-navigation.js.map +0 -1
  192. package/dist-client/utils/assistant-navigation.test.d.ts +0 -1
  193. package/dist-client/utils/assistant-navigation.test.js +0 -63
  194. package/dist-client/utils/assistant-navigation.test.js.map +0 -1
  195. package/dist-client/utils/assistant-proposals.js.map +0 -1
  196. package/dist-client/utils/assistant-request-context.js.map +0 -1
  197. package/dist-client/utils/assistant-selection.js.map +0 -1
  198. package/dist-client/utils/assistant-selection.test.d.ts +0 -1
  199. package/dist-client/utils/assistant-selection.test.js +0 -46
  200. package/dist-client/utils/assistant-selection.test.js.map +0 -1
  201. package/dist-client/utils/assistant-session-actions.js.map +0 -1
  202. package/dist-client/utils/assistant-session-admin.js.map +0 -1
  203. package/dist-client/utils/assistant-session-controller.js.map +0 -1
  204. package/dist-client/utils/assistant-session-controller.test.d.ts +0 -1
  205. package/dist-client/utils/assistant-session-controller.test.js +0 -56
  206. package/dist-client/utils/assistant-session-controller.test.js.map +0 -1
  207. package/dist-client/utils/assistant-session-transport.js.map +0 -1
  208. package/dist-client/utils/assistant-surface.js.map +0 -1
  209. package/dist-client/utils/assistant-typing.js.map +0 -1
  210. package/dist-client/utils/assistant-typing.test.d.ts +0 -1
  211. package/dist-client/utils/assistant-typing.test.js +0 -30
  212. package/dist-client/utils/assistant-typing.test.js.map +0 -1
  213. package/dist-client/utils/attachment-policy.js.map +0 -1
  214. package/dist-client/utils/composer-frame.js.map +0 -1
  215. package/dist-client/utils/document-text.js.map +0 -1
  216. package/dist-client/utils/entry-hash.js.map +0 -1
  217. package/dist-client/utils/entry-proposal.js.map +0 -1
  218. package/dist-client/utils/entry-workspace.js.map +0 -1
  219. package/dist-client/utils/invite-proposal-register.js.map +0 -1
  220. package/dist-client/utils/invite-proposal.js.map +0 -1
  221. package/dist-client/utils/invite-proposal.test.d.ts +0 -1
  222. package/dist-client/utils/invite-proposal.test.js +0 -35
  223. package/dist-client/utils/invite-proposal.test.js.map +0 -1
  224. package/dist-client/utils/menu-room.js.map +0 -1
  225. package/dist-client/utils/open-page.js.map +0 -1
  226. package/dist-client/utils/pasted-table.js.map +0 -1
  227. package/dist-client/utils/pdf-pages.js.map +0 -1
  228. package/dist-client/utils/spreadsheet-text.js.map +0 -1
  229. package/dist-client/utils/workspace.js.map +0 -1
  230. package/dist-server/door-declaration-report.js.map +0 -1
  231. package/dist-server/index.js.map +0 -1
  232. package/dist-server/role-tasks.js.map +0 -1
  233. package/dist-server/service/ai-agent-resolver.js.map +0 -1
  234. package/dist-server/service/assistant-capability-resolver.js.map +0 -1
  235. package/dist-server/service/assistant-chat-resolver.js.map +0 -1
  236. package/dist-server/service/assistant-mode/assistant-mode-resolver.js.map +0 -1
  237. package/dist-server/service/assistant-mode/fallback-subjects.js.map +0 -1
  238. package/dist-server/service/assistant-mode/index.js.map +0 -1
  239. package/dist-server/service/assistant-mode/mode-categories.js.map +0 -1
  240. package/dist-server/service/assistant-mode/record-subject.js.map +0 -1
  241. package/dist-server/service/assistant-mode/registry.js.map +0 -1
  242. package/dist-server/service/assistant-mode/resolve.js.map +0 -1
  243. package/dist-server/service/assistant-mode/screen-rules.js.map +0 -1
  244. package/dist-server/service/assistant-mode/turn-lines.js.map +0 -1
  245. package/dist-server/service/assistant-mode/types.js.map +0 -1
  246. package/dist-server/service/chat-message/carried-turns.js.map +0 -1
  247. package/dist-server/service/chat-message/chat-message-broadcast.js.map +0 -1
  248. package/dist-server/service/chat-message/chat-message-publish.js.map +0 -1
  249. package/dist-server/service/chat-message/chat-message-room.js.map +0 -1
  250. package/dist-server/service/chat-message/chat-message-subscription.js.map +0 -1
  251. package/dist-server/service/chat-message/chat-message.js.map +0 -1
  252. package/dist-server/service/chat-message/chat-typing-subscription.js.map +0 -1
  253. package/dist-server/service/chat-message/chat-typing.js.map +0 -1
  254. package/dist-server/service/chat-message/door-access.js.map +0 -1
  255. package/dist-server/service/chat-message/fold-history.js.map +0 -1
  256. package/dist-server/service/chat-message/fold-session-history.js.map +0 -1
  257. package/dist-server/service/chat-message/history-summary.js.map +0 -1
  258. package/dist-server/service/chat-message/index.js.map +0 -1
  259. package/dist-server/service/chat-message/llm-history.js.map +0 -1
  260. package/dist-server/service/chat-message/message-doors.js.map +0 -1
  261. package/dist-server/service/chat-message/proposal-outcome.js.map +0 -1
  262. package/dist-server/service/chat-message/reader-gate.js.map +0 -1
  263. package/dist-server/service/chat-message/room-message.js.map +0 -1
  264. package/dist-server/service/chat-message/room-turn.js.map +0 -1
  265. package/dist-server/service/chat-message/used-tools.js.map +0 -1
  266. package/dist-server/service/chat-session/attachment-policy.js.map +0 -1
  267. package/dist-server/service/chat-session/attachment-route.js.map +0 -1
  268. package/dist-server/service/chat-session/attachment-tool-result.js.map +0 -1
  269. package/dist-server/service/chat-session/attachment-tools.js.map +0 -1
  270. package/dist-server/service/chat-session/chat-session.js.map +0 -1
  271. package/dist-server/service/chat-session/index.js.map +0 -1
  272. package/dist-server/service/chat-session/session-activity-broadcast.js.map +0 -1
  273. package/dist-server/service/chat-session/session-activity-publish.js.map +0 -1
  274. package/dist-server/service/chat-session/session-activity-subscription.js.map +0 -1
  275. package/dist-server/service/chat-session/session-anchor.js.map +0 -1
  276. package/dist-server/service/chat-session/session-attachments.js.map +0 -1
  277. package/dist-server/service/chat-session/session-cleanup.js.map +0 -1
  278. package/dist-server/service/chat-session/session-inbox.js.map +0 -1
  279. package/dist-server/service/chat-session/session-kind.js.map +0 -1
  280. package/dist-server/service/chat-session/session-name.js.map +0 -1
  281. package/dist-server/service/chat-session/session-purge.js.map +0 -1
  282. package/dist-server/service/chat-session/session-retention.js.map +0 -1
  283. package/dist-server/service/chat-session/session-visibility.js.map +0 -1
  284. package/dist-server/service/chat-session/session-write-gate.js.map +0 -1
  285. package/dist-server/service/chat-session/station-session-guard.js.map +0 -1
  286. package/dist-server/service/chat-session/turn-attachments.js.map +0 -1
  287. package/dist-server/service/chat-session-participant/chat-session-participant.js.map +0 -1
  288. package/dist-server/service/chat-session-participant/index.js.map +0 -1
  289. package/dist-server/service/chat-session-participant/invite-notification.js.map +0 -1
  290. package/dist-server/service/chat-session-participant/mention-invite.js.map +0 -1
  291. package/dist-server/service/chat-session-participant/participant-lookup-roles.js.map +0 -1
  292. package/dist-server/service/chat-session-participant/participant-lookup.js.map +0 -1
  293. package/dist-server/service/chat-session-participant/presence.js.map +0 -1
  294. package/dist-server/service/chat-session-participant/read-roster.js.map +0 -1
  295. package/dist-server/service/chat-session-resolver.js.map +0 -1
  296. package/dist-server/service/data-entry/entry-apply.js.map +0 -1
  297. package/dist-server/service/data-entry/entry-hash.js.map +0 -1
  298. package/dist-server/service/data-entry/entry-refusal.js.map +0 -1
  299. package/dist-server/service/data-entry/entry-resolver.js.map +0 -1
  300. package/dist-server/service/data-entry/entry-screen.js.map +0 -1
  301. package/dist-server/service/data-entry/entry-sources.js.map +0 -1
  302. package/dist-server/service/data-entry/entry-target.js.map +0 -1
  303. package/dist-server/service/data-entry/entry-tools.js.map +0 -1
  304. package/dist-server/service/data-entry/entry-update.js.map +0 -1
  305. package/dist-server/service/data-read/list-read.js.map +0 -1
  306. package/dist-server/service/data-read/read-target.js.map +0 -1
  307. package/dist-server/service/data-read/read-tools.js.map +0 -1
  308. package/dist-server/service/grounding-sources.js.map +0 -1
  309. package/dist-server/service/help-documents/help-keys.js.map +0 -1
  310. package/dist-server/service/help-documents/help-tools.js.map +0 -1
  311. package/dist-server/service/index.js.map +0 -1
  312. package/dist-server/service/people/index.js.map +0 -1
  313. package/dist-server/service/people/invite-tools.js.map +0 -1
  314. package/dist-server/service/people/people-keys.js.map +0 -1
  315. package/dist-server/service/people/people-read.js.map +0 -1
  316. package/dist-server/service/people/person-subject.js.map +0 -1
  317. package/dist-server/service/request-translator.js.map +0 -1
  318. package/dist-server/service/testing/conversation-script.js.map +0 -1
  319. package/dist-server/service/testing/mode-conformance.js.map +0 -1
  320. package/dist-server/service/tool-access.js.map +0 -1
  321. package/dist-server/service/types.js.map +0 -1
  322. package/dist-server/service/unattended-run/assistant-run.js.map +0 -1
  323. package/dist-server/service/unattended-run/index.js.map +0 -1
  324. package/dist-server/service/unattended-run/limits.js.map +0 -1
  325. package/dist-server/service/unattended-run/run-as.js.map +0 -1
  326. package/dist-server/service/unattended-run/run-budget.js.map +0 -1
  327. package/dist-server/service/unattended-run/run-ledger.js.map +0 -1
  328. package/dist-server/service/unattended-run/run-outcome.js.map +0 -1
  329. package/dist-server/service/unattended-run/run-store.js.map +0 -1
  330. package/dist-server/service/unattended-run/run-unattended.js.map +0 -1
  331. package/dist-server/service/unattended-run/unattended-prompt.js.map +0 -1
  332. package/dist-server/service/workspace/workspace-blocks.js.map +0 -1
  333. package/dist-server/service/workspace/workspace-tools.js.map +0 -1
  334. package/dist-server/tool-registry-boot-report.js.map +0 -1
  335. package/dist-server/tsconfig.tsbuildinfo +0 -1
  336. package/docs/session-controller.md +0 -52
  337. package/server/door-declaration-report.test.ts +0 -53
  338. package/server/door-declaration-report.ts +0 -61
  339. package/server/explicit-graphql-types.test.ts +0 -56
  340. package/server/index.ts +0 -36
  341. package/server/role-tasks.ts +0 -14
  342. package/server/service/ai-agent-resolver.ts +0 -330
  343. package/server/service/assistant-capability-resolver.ts +0 -66
  344. package/server/service/assistant-chat-resolver.ts +0 -640
  345. package/server/service/assistant-mode/assistant-mode-resolver.ts +0 -101
  346. package/server/service/assistant-mode/conversation-category.test.ts +0 -48
  347. package/server/service/assistant-mode/fallback-subjects.ts +0 -36
  348. package/server/service/assistant-mode/index.ts +0 -22
  349. package/server/service/assistant-mode/mode-categories.ts +0 -178
  350. package/server/service/assistant-mode/mode-front.test.ts +0 -183
  351. package/server/service/assistant-mode/one-conversation-per-subject.test.ts +0 -37
  352. package/server/service/assistant-mode/open-subject-door.test.ts +0 -52
  353. package/server/service/assistant-mode/record-subject.test.ts +0 -41
  354. package/server/service/assistant-mode/record-subject.ts +0 -44
  355. package/server/service/assistant-mode/registry.test.ts +0 -171
  356. package/server/service/assistant-mode/registry.ts +0 -139
  357. package/server/service/assistant-mode/resolve.test.ts +0 -129
  358. package/server/service/assistant-mode/resolve.ts +0 -113
  359. package/server/service/assistant-mode/screen-rules.test.ts +0 -99
  360. package/server/service/assistant-mode/screen-rules.ts +0 -103
  361. package/server/service/assistant-mode/turn-lines.ts +0 -43
  362. package/server/service/assistant-mode/types.ts +0 -138
  363. package/server/service/chat-message/carried-turns.test.ts +0 -80
  364. package/server/service/chat-message/carried-turns.ts +0 -112
  365. package/server/service/chat-message/chat-message-broadcast.integration.test.ts +0 -73
  366. package/server/service/chat-message/chat-message-broadcast.test.ts +0 -40
  367. package/server/service/chat-message/chat-message-broadcast.ts +0 -70
  368. package/server/service/chat-message/chat-message-publish.ts +0 -22
  369. package/server/service/chat-message/chat-message-room.test.ts +0 -145
  370. package/server/service/chat-message/chat-message-room.ts +0 -50
  371. package/server/service/chat-message/chat-message-subscription.ts +0 -77
  372. package/server/service/chat-message/chat-message.ts +0 -289
  373. package/server/service/chat-message/chat-typing-subscription.ts +0 -52
  374. package/server/service/chat-message/chat-typing.test.ts +0 -45
  375. package/server/service/chat-message/chat-typing.ts +0 -48
  376. package/server/service/chat-message/door-access.test.ts +0 -72
  377. package/server/service/chat-message/door-access.ts +0 -65
  378. package/server/service/chat-message/fold-history-window.test.ts +0 -184
  379. package/server/service/chat-message/fold-history.test.ts +0 -98
  380. package/server/service/chat-message/fold-history.ts +0 -77
  381. package/server/service/chat-message/fold-session-history.test.ts +0 -116
  382. package/server/service/chat-message/fold-session-history.ts +0 -115
  383. package/server/service/chat-message/history-summary.test.ts +0 -127
  384. package/server/service/chat-message/history-summary.ts +0 -100
  385. package/server/service/chat-message/index.ts +0 -13
  386. package/server/service/chat-message/llm-history.test.ts +0 -245
  387. package/server/service/chat-message/llm-history.ts +0 -182
  388. package/server/service/chat-message/message-doors.test.ts +0 -124
  389. package/server/service/chat-message/message-doors.ts +0 -132
  390. package/server/service/chat-message/proposal-outcome.test.ts +0 -111
  391. package/server/service/chat-message/proposal-outcome.ts +0 -99
  392. package/server/service/chat-message/reader-gate.ts +0 -44
  393. package/server/service/chat-message/room-message.test.ts +0 -21
  394. package/server/service/chat-message/room-message.ts +0 -22
  395. package/server/service/chat-message/room-turn.ts +0 -42
  396. package/server/service/chat-message/used-tools.test.ts +0 -19
  397. package/server/service/chat-message/used-tools.ts +0 -25
  398. package/server/service/chat-session/attachment-policy.test.ts +0 -42
  399. package/server/service/chat-session/attachment-policy.ts +0 -91
  400. package/server/service/chat-session/attachment-route.ts +0 -45
  401. package/server/service/chat-session/attachment-tool-result.test.ts +0 -63
  402. package/server/service/chat-session/attachment-tool-result.ts +0 -37
  403. package/server/service/chat-session/attachment-tools.ts +0 -66
  404. package/server/service/chat-session/chat-session.ts +0 -244
  405. package/server/service/chat-session/group-room.test.ts +0 -233
  406. package/server/service/chat-session/index.ts +0 -5
  407. package/server/service/chat-session/session-activity-broadcast.ts +0 -77
  408. package/server/service/chat-session/session-activity-publish.ts +0 -49
  409. package/server/service/chat-session/session-activity-receivers.test.ts +0 -26
  410. package/server/service/chat-session/session-activity-subscription.ts +0 -66
  411. package/server/service/chat-session/session-anchor.ts +0 -142
  412. package/server/service/chat-session/session-attachments.ts +0 -90
  413. package/server/service/chat-session/session-cleanup.test.ts +0 -83
  414. package/server/service/chat-session/session-cleanup.ts +0 -69
  415. package/server/service/chat-session/session-inbox.test.ts +0 -273
  416. package/server/service/chat-session/session-inbox.ts +0 -240
  417. package/server/service/chat-session/session-kind.test.ts +0 -24
  418. package/server/service/chat-session/session-kind.ts +0 -32
  419. package/server/service/chat-session/session-name.ts +0 -32
  420. package/server/service/chat-session/session-purge.test.ts +0 -24
  421. package/server/service/chat-session/session-purge.ts +0 -117
  422. package/server/service/chat-session/session-retention.ts +0 -17
  423. package/server/service/chat-session/session-visibility.test.ts +0 -130
  424. package/server/service/chat-session/session-visibility.ts +0 -68
  425. package/server/service/chat-session/session-write-gate.test.ts +0 -59
  426. package/server/service/chat-session/session-write-gate.ts +0 -31
  427. package/server/service/chat-session/station-session-guard.ts +0 -25
  428. package/server/service/chat-session/turn-attachments.test.ts +0 -106
  429. package/server/service/chat-session/turn-attachments.ts +0 -45
  430. package/server/service/chat-session-participant/chat-session-participant.ts +0 -135
  431. package/server/service/chat-session-participant/index.ts +0 -8
  432. package/server/service/chat-session-participant/invite-notification.test.ts +0 -80
  433. package/server/service/chat-session-participant/invite-notification.ts +0 -118
  434. package/server/service/chat-session-participant/mention-invite.test.ts +0 -173
  435. package/server/service/chat-session-participant/mention-invite.ts +0 -180
  436. package/server/service/chat-session-participant/participant-lookup-roles.ts +0 -6
  437. package/server/service/chat-session-participant/participant-lookup.ts +0 -22
  438. package/server/service/chat-session-participant/presence.test.ts +0 -39
  439. package/server/service/chat-session-participant/presence.ts +0 -21
  440. package/server/service/chat-session-participant/read-roster.test.ts +0 -27
  441. package/server/service/chat-session-participant/read-roster.ts +0 -17
  442. package/server/service/chat-session-resolver.ts +0 -1455
  443. package/server/service/data-entry/data-entry-update.test.ts +0 -378
  444. package/server/service/data-entry/data-entry.test.ts +0 -494
  445. package/server/service/data-entry/entry-apply.ts +0 -247
  446. package/server/service/data-entry/entry-hash.ts +0 -35
  447. package/server/service/data-entry/entry-refusal.test.ts +0 -73
  448. package/server/service/data-entry/entry-refusal.ts +0 -20
  449. package/server/service/data-entry/entry-resolver.ts +0 -74
  450. package/server/service/data-entry/entry-screen.ts +0 -14
  451. package/server/service/data-entry/entry-sources.ts +0 -39
  452. package/server/service/data-entry/entry-target.ts +0 -774
  453. package/server/service/data-entry/entry-tools.ts +0 -282
  454. package/server/service/data-entry/entry-update.ts +0 -238
  455. package/server/service/data-read/data-read.test.ts +0 -395
  456. package/server/service/data-read/detail-lists.test.ts +0 -61
  457. package/server/service/data-read/list-missing.test.ts +0 -49
  458. package/server/service/data-read/list-read.ts +0 -146
  459. package/server/service/data-read/list-status.test.ts +0 -46
  460. package/server/service/data-read/read-target.ts +0 -509
  461. package/server/service/data-read/read-tools.ts +0 -334
  462. package/server/service/data-read/read-words.test.ts +0 -99
  463. package/server/service/data-read/record-keys.test.ts +0 -42
  464. package/server/service/grounding-sources.test.ts +0 -55
  465. package/server/service/grounding-sources.ts +0 -46
  466. package/server/service/help-documents/help-keys.ts +0 -2
  467. package/server/service/help-documents/help-tools.test.ts +0 -40
  468. package/server/service/help-documents/help-tools.ts +0 -88
  469. package/server/service/index.ts +0 -99
  470. package/server/service/people/index.ts +0 -15
  471. package/server/service/people/invite-tools.ts +0 -159
  472. package/server/service/people/invite.test.ts +0 -159
  473. package/server/service/people/people-keys.ts +0 -16
  474. package/server/service/people/people-read.test.ts +0 -82
  475. package/server/service/people/people-read.ts +0 -56
  476. package/server/service/people/person-subject.test.ts +0 -161
  477. package/server/service/people/person-subject.ts +0 -83
  478. package/server/service/request-translator.test.ts +0 -45
  479. package/server/service/request-translator.ts +0 -33
  480. package/server/service/session-anchor.test.ts +0 -198
  481. package/server/service/station-session-guard.test.ts +0 -31
  482. package/server/service/testing/conversation-scenario.test.ts +0 -164
  483. package/server/service/testing/conversation-script.test.ts +0 -133
  484. package/server/service/testing/conversation-script.ts +0 -296
  485. package/server/service/testing/mode-conformance.test.ts +0 -61
  486. package/server/service/testing/mode-conformance.ts +0 -165
  487. package/server/service/tool-access.test.ts +0 -96
  488. package/server/service/tool-access.ts +0 -36
  489. package/server/service/types.ts +0 -15
  490. package/server/service/unattended-run/assistant-run.ts +0 -199
  491. package/server/service/unattended-run/index.ts +0 -10
  492. package/server/service/unattended-run/limits.ts +0 -24
  493. package/server/service/unattended-run/run-as.ts +0 -38
  494. package/server/service/unattended-run/run-budget.ts +0 -58
  495. package/server/service/unattended-run/run-ledger.ts +0 -31
  496. package/server/service/unattended-run/run-outcome.ts +0 -43
  497. package/server/service/unattended-run/run-store-race.pg.test.ts +0 -83
  498. package/server/service/unattended-run/run-store.ts +0 -162
  499. package/server/service/unattended-run/run-unattended.test.ts +0 -478
  500. package/server/service/unattended-run/run-unattended.ts +0 -248
  501. package/server/service/unattended-run/unattended-prompt.ts +0 -24
  502. package/server/service/workspace/workspace-blocks.ts +0 -134
  503. package/server/service/workspace/workspace-tools.ts +0 -108
  504. package/server/service/workspace/workspace.test.ts +0 -74
  505. package/server/tool-registry-boot-report.test.ts +0 -41
  506. package/server/tool-registry-boot-report.ts +0 -63
  507. package/test/ai-agent-settings.test.ts +0 -123
  508. package/test/applied-screens.test.ts +0 -65
  509. package/test/assistant-chat-call-sites.test.ts +0 -92
  510. package/test/assistant-dock.test.ts +0 -294
  511. package/test/assistant-request-context.test.ts +0 -72
  512. package/test/assistant-session-controller.test.ts +0 -87
  513. package/test/assistant-session-manager.test.ts +0 -186
  514. package/test/assistant-session-toolbar.test.ts +0 -43
  515. package/test/attachment-one-rule.test.ts +0 -46
  516. package/test/attachment-policy-agree.test.ts +0 -38
  517. package/test/composer-frame.test.ts +0 -173
  518. package/test/document-text.test.ts +0 -175
  519. package/test/entry-card-styles.test.ts +0 -18
  520. package/test/entry-proposal.test.ts +0 -186
  521. package/test/entry-workspace.test.ts +0 -89
  522. package/test/menu-room.test.ts +0 -33
  523. package/test/open-doors.test.ts +0 -164
  524. package/test/open-page.test.ts +0 -31
  525. package/test/pasted-table.test.ts +0 -147
  526. package/test/refusals-in-korean.test.ts +0 -80
  527. package/test/session-discovery.test.ts +0 -43
  528. package/test/spreadsheet-text.test.ts +0 -92
  529. package/test/translations.test.ts +0 -80
  530. package/test/workspace.test.ts +0 -54
  531. package/tsconfig.json +0 -9
@@ -1,248 +0,0 @@
1
- /*
2
- * Run an assistant mode with no person in it, for scheduled work, and keep what it wrote as a draft
3
- * (operato-application/design/ai/unattended-run.md, ADR-0142 §8.1, user ruling C 2026-10-20).
4
- *
5
- * A server function and no GraphQL door: a door would let a person name someone else as `runAs`. The caller is a
6
- * server's scheduled task - Office's periodic strategy review is the first.
7
- *
8
- * identity (domain, source, subject, scheduledAt) is one row - a retry hands the stored run back (§5)
9
- * who the run-as user, judged again now; refused when they cannot ask the assistant themselves (§2)
10
- * tools the mode's read tools behind that user's own doors; no 입력안, no cards kept (§3)
11
- * limits the mode's: model requests, tokens, wall time (§4)
12
- * outcome succeeded with a draft, failed or refused with a code - never an empty success (§7)
13
- *
14
- * Every tool call goes through the registry door, so the recorders write it down as they do a turn's (§6).
15
- */
16
- import { aiClientFor, findToolSpec, registryAssistantChat, type AgentClient, type AiClientRequest, type ToolAccessCheck, type ToolCallRecord } from '@things-factory/ai-client-base'
17
- import { User, canUserCheckinDomain, checkPermission } from '@things-factory/auth-base'
18
- import { getRepository } from '@things-factory/shell'
19
-
20
- import { getAssistantMode } from '../assistant-mode/registry.js'
21
- import { unattendedToolCategories } from '../assistant-mode/mode-categories.js'
22
- import { doorsForAnswer } from '../chat-message/message-doors.js'
23
- import { groundingSourcesFor } from '../grounding-sources.js'
24
- import { toolAccessFor } from '../tool-access.js'
25
- import { AssistantRun } from './assistant-run.js'
26
- import { ABANDON_MARGIN_MS, unattendedLimits } from './limits.js'
27
- import { budgetedClient, RunBudgetExceeded } from './run-budget.js'
28
- import { judgeRunAs, type RunAsChecks } from './run-as.js'
29
- import { typeormRunStore, type RunEnding, type RunStore } from './run-store.js'
30
- import { unattendedPrompt } from './unattended-prompt.js'
31
-
32
- export interface UnattendedRunInput {
33
- /** The domain the run is in, as loaded - its parent and owner decide who can enter it. */
34
- domain: { id: string; [key: string]: any }
35
- /** The user the run acts as - the policy owner. Their privileges and doors only. */
36
- runAs: string
37
- /** Which occurrence this is. The same three again is the same run. */
38
- run: {
39
- /** Who scheduled it - `<app>.<work>`, e.g. `office.strategy-review`. */
40
- source: string
41
- /** What it is about in the source's terms - a policy id. */
42
- subject: string
43
- scheduledAt: Date
44
- }
45
- /** A registered mode that declares `unattended`. */
46
- mode: { kind: string; target?: string }
47
- /** What this occurrence is asked to do - the caller server's text, read by the model (English). */
48
- instruction: string
49
- /** What the run is about, for the tools. Filled by the caller's server; still never used for authorization. */
50
- hostContext?: Record<string, any>
51
- /** The language of the draft - the owner's. Absent: their account's locale. */
52
- lng?: string
53
- }
54
-
55
- /** What the run reaches outside itself. The defaults are the server's; the tests hand their own. */
56
- export interface UnattendedRunDeps {
57
- store: RunStore
58
- runAs: RunAsChecks<any, any>
59
- clientFor: (request: AiClientRequest) => Promise<AgentClient>
60
- toolAccess: (state: any) => ToolAccessCheck
61
- now: () => Date
62
- }
63
-
64
- const KEY = /^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*$/
65
-
66
- function invalid(field: string): Error {
67
- const error: any = new Error(`runAssistantUnattended: '${field}' is missing or not usable`)
68
- error.code = 'assistant-run-input-invalid'
69
- error.params = { field }
70
- return error
71
- }
72
-
73
- function checkInput(input: UnattendedRunInput) {
74
- if (!input?.domain?.id) throw invalid('domain')
75
- if (!input.runAs) throw invalid('runAs')
76
- if (!KEY.test(String(input.run?.source ?? '')) || input.run.source.length > 64) throw invalid('run.source')
77
- if (!String(input.run.subject ?? '').trim() || String(input.run.subject).length > 64) throw invalid('run.subject')
78
- if (!(input.run.scheduledAt instanceof Date) || !Number.isFinite(input.run.scheduledAt.valueOf())) throw invalid('run.scheduledAt')
79
- if (!input.mode?.kind) throw invalid('mode.kind')
80
- if (!String(input.instruction ?? '').trim()) throw invalid('instruction')
81
- }
82
-
83
- function defaultDeps(): UnattendedRunDeps {
84
- return {
85
- store: typeormRunStore(() => getRepository(AssistantRun)),
86
- runAs: {
87
- findUser: id => getRepository(User).findOne({ where: { id } }),
88
- mayCheckin: (user, domain) => canUserCheckinDomain(user, domain),
89
- /* No request: no address to refuse from, and no license prohibition - those cover writes this run never makes. */
90
- permits: (gate, user, domain) => checkPermission(gate as any, user, domain, false, [])
91
- },
92
- clientFor: aiClientFor,
93
- toolAccess: state => toolAccessFor({ state }),
94
- now: () => new Date()
95
- }
96
- }
97
-
98
- /** Why the loop stopped, as the run's code. Only a clean end with text is a draft. */
99
- function failureOf(loop: any, baseText: string): { code: string; params?: any } | undefined {
100
- const abort = loop?.abortReason
101
- if (abort?.type === 'max_iterations') return { code: 'assistant-run-step-limit', params: { steps: abort.iter } }
102
- if (abort?.type === 'provider_error') return { code: 'assistant-run-model-error', params: { message: String(abort.message ?? '').slice(0, 500) } }
103
- if (abort) return { code: 'assistant-run-model-error', params: { stopped: abort.type } }
104
- if (!baseText.trim()) return { code: 'assistant-run-empty-draft' }
105
- return undefined
106
- }
107
-
108
- const TIMED_OUT = Symbol('timed-out')
109
-
110
- export async function runAssistantUnattended(input: UnattendedRunInput, deps: UnattendedRunDeps = defaultDeps()): Promise<AssistantRun> {
111
- checkInput(input)
112
- const { domain, run } = input
113
- const mode = getAssistantMode(input.mode.kind)
114
- const limits = unattendedLimits(mode?.unattended)
115
- const startedAt = deps.now()
116
- /* The account as stored now - read once, and judged after the occurrence is held. */
117
- const account = await deps.runAs.findUser(input.runAs)
118
-
119
- const { claimed, row } = await deps.store.claim(
120
- { domainId: domain.id, source: run.source, subject: run.subject, scheduledAt: run.scheduledAt },
121
- {
122
- name: `${run.source} ${run.subject} ${run.scheduledAt.toISOString()}`,
123
- modeKind: input.mode.kind,
124
- modeTarget: input.mode.target,
125
- runAsId: account?.id,
126
- startedAt,
127
- deadlineAt: new Date(startedAt.valueOf() + limits.timeoutMs + ABANDON_MARGIN_MS)
128
- },
129
- startedAt
130
- )
131
- /* Succeeded, or running elsewhere and still alive - the caller gets that row and the model is not called again. */
132
- if (!claimed) return row
133
-
134
- const held = { id: row.id!, attempt: row.attempt }
135
- const end = (ending: RunEnding) => deps.store.finish(held, { finishedAt: deps.now(), ...ending })
136
- const refuse = (code: string, params?: any) => end({ status: 'refused', outcomeCode: code, outcomeParams: params ? JSON.stringify(params) : null } as any)
137
- const fail = (code: string, params?: any, spent?: RunEnding) =>
138
- end({ status: 'failed', outcomeCode: code, outcomeParams: params ? JSON.stringify(params) : null, ...spent } as any)
139
-
140
- if (!mode) return refuse('unknown-assistant-mode', { kind: input.mode.kind })
141
- if (!mode.unattended) return refuse('assistant-mode-not-unattended', { kind: mode.kind })
142
-
143
- const judged = await judgeRunAs(account, domain, deps.runAs)
144
- if ('refused' in judged) return refuse(judged.refused, { userId: input.runAs })
145
- const user = judged.user
146
-
147
- let agentClient: AgentClient
148
- try {
149
- agentClient = await deps.clientFor({ domain: domain as any, user, modeKind: mode.kind })
150
- } catch (error: any) {
151
- /* No AI here, or not the agent asked for - nothing ran. Its own code, as the conversation door says it. */
152
- if (error?.code) return refuse(String(error.code), error.params)
153
- return fail('assistant-run-model-error', { message: String(error?.message ?? error).slice(0, 500) })
154
- }
155
-
156
- const { client, spend } = budgetedClient(agentClient, limits)
157
- const reads: ToolCallRecord[] = []
158
- let over = false
159
- const state: any = { domain, user, lng: input.lng ?? user.locale, aiAgentId: agentClient.agent.id }
160
- const categories = unattendedToolCategories(mode)
161
- const systemPrompt = unattendedPrompt(mode.systemPrompt, state.lng)
162
- const messages = [{ role: 'user' as const, content: input.instruction }]
163
-
164
- const abort = new AbortController()
165
- let timer: ReturnType<typeof setTimeout> | undefined
166
- const timeout = new Promise<typeof TIMED_OUT>(resolve => {
167
- timer = setTimeout(() => {
168
- abort.abort()
169
- resolve(TIMED_OUT)
170
- }, limits.timeoutMs)
171
- })
172
-
173
- const spent = (): RunEnding => ({
174
- reads: JSON.stringify(reads),
175
- agentId: agentClient.agent.id,
176
- clientId: agentClient.id,
177
- modelCalls: spend.modelCalls,
178
- inputTokens: spend.inputTokens,
179
- outputTokens: spend.outputTokens
180
- })
181
-
182
- let result: any
183
- try {
184
- result = await Promise.race([
185
- registryAssistantChat({
186
- client,
187
- messages,
188
- systemPrompt,
189
- toolCategories: categories,
190
- /* No screen and no conversation - the mode's own tools in front, the lists opened as the run needs (ADR-0061 decision 9). */
191
- front: { categories: mode.toolCategories ?? [] },
192
- mode: { kind: mode.kind, ...(input.mode.target ? { target: input.mode.target } : {}) },
193
- toolAccess: deps.toolAccess(state),
194
- hostContext: input.hostContext,
195
- state,
196
- temperature: mode.temperature,
197
- maxTokens: mode.maxTokens,
198
- requireToolOnFirstTurn: mode.requireToolOnFirstTurn,
199
- /* Each step is one request. A run that reaches the last step without an answer failed - no wrap-up call (§4). */
200
- maxIterations: limits.maxModelCalls,
201
- salvageOnMaxIterations: false,
202
- signal: abort.signal,
203
- onToolCall: record => {
204
- if (!over) reads.push(record)
205
- },
206
- run: { id: held.id, source: run.source, subject: run.subject, scheduledAt: run.scheduledAt.toISOString() },
207
- groundingSources: groundingSourcesFor({ systemPrompt, messages: messages as any, hostContext: input.hostContext })
208
- }),
209
- timeout
210
- ])
211
- } catch (error: any) {
212
- over = true
213
- clearTimeout(timer)
214
- if (error instanceof RunBudgetExceeded) return fail(error.code, error.params, spent())
215
- return fail('assistant-run-model-error', { message: String(error?.message ?? error).slice(0, 500) }, spent())
216
- }
217
- over = true
218
- clearTimeout(timer)
219
-
220
- if (result === TIMED_OUT) return fail('assistant-run-timeout', { timeoutMs: limits.timeoutMs }, spent())
221
- /* The loop turns a refused request into a provider error; the budget says which limit it was. */
222
- if (spend.exceeded) return fail('assistant-run-budget-exceeded', spend.exceeded, spent())
223
-
224
- const failure = failureOf(result.loop, result.baseText ?? '')
225
- if (failure) return fail(failure.code, failure.params, spent())
226
-
227
- const doors = doorsForAnswer(
228
- result.loop.toolUsages ?? [],
229
- name => (findToolSpec(name, categories) as any)?.doors
230
- )
231
- return end({
232
- status: 'succeeded',
233
- draft: result.baseText,
234
- doors,
235
- cardsDropped: result.loop.proposals?.length ?? 0,
236
- groundingWarnings: result.groundingWarnings?.length ? JSON.stringify(result.groundingWarnings) : null,
237
- ...spent()
238
- } as any)
239
- }
240
-
241
- /** The stored run of an occurrence, for the application that scheduled it - read behind that application's own door. */
242
- export async function findAssistantRun(identity: { domainId: string; source: string; subject: string; scheduledAt: Date } | { id: string }): Promise<AssistantRun | null> {
243
- const repository = getRepository(AssistantRun)
244
- if ('id' in identity) return repository.findOne({ where: { id: identity.id } })
245
- return repository.findOne({
246
- where: { domain: { id: identity.domainId }, source: identity.source, subject: identity.subject, scheduledAt: identity.scheduledAt } as any
247
- })
248
- }
@@ -1,24 +0,0 @@
1
- /*
2
- * The rules every unattended run follows, after the mode's persona (design/ai/unattended-run.md §3). The reader is the
3
- * model, so the text is English (ADR-0061 A11); the draft is written in the owner's language.
4
- */
5
-
6
- const LANGUAGES: Record<string, string> = { ko: 'Korean', en: 'English', ja: 'Japanese', zh: 'Chinese', ms: 'Malay', vi: 'Vietnamese' }
7
-
8
- export function languageName(lng: string | undefined): string {
9
- const code = String(lng ?? '').trim().toLowerCase()
10
- if (!code) return 'English'
11
- return LANGUAGES[code] ?? LANGUAGES[code.split(/[-_]/)[0]] ?? `the language of locale "${code}"`
12
- }
13
-
14
- export const UNATTENDED_RULES = [
15
- 'No person is reading this as it is written. It runs on a schedule, and your answer is kept as a draft that its owner reads later.',
16
- '- Read before you write. Every figure and fact in the draft comes from a tool result of this run.',
17
- '- A read that failed or was refused is said as failed, with what the draft cannot say because of it. Never write it as "no change".',
18
- '- Nothing you call is shown to anyone: there are no cards and no screens to open. Put what matters in the text.',
19
- '- Do not ask questions - nobody will answer. Where something is missing, say what is missing.'
20
- ].join('\n')
21
-
22
- export function unattendedPrompt(persona: string, lng: string | undefined): string {
23
- return `${persona}\n\n${UNATTENDED_RULES}\n- Write the draft in ${languageName(lng)}.`
24
- }
@@ -1,134 +0,0 @@
1
- /*
2
- * The AI 작업 패널 - what a workspace is made of (operato-application/design/ai/workspace.md §3).
3
- *
4
- * The model does not write HTML. A workspace is a list of blocks of known kinds; the screen draws each, so
5
- * theme, language and accessibility are the framework's. A block that does not fit is not dropped: it is
6
- * kept as a fact in its place ("a block that cannot be drawn"), so the person sees that something was meant
7
- * to be there. Pure - tested without a server.
8
- */
9
-
10
- export const WORKSPACE_BLOCK_KINDS = ['heading', 'text', 'metrics', 'table', 'chart', 'steps'] as const
11
- export type WorkspaceBlockKind = (typeof WORKSPACE_BLOCK_KINDS)[number]
12
-
13
- export const MAX_BLOCKS = 40
14
- export const MAX_TABLE_ROWS = 1000
15
- export const MAX_SERIES = 8
16
- const MAX_TEXT = 20_000
17
-
18
- export interface WorkspaceBlock {
19
- kind: WorkspaceBlockKind | 'unreadable'
20
- [key: string]: unknown
21
- }
22
-
23
- export interface Workspace {
24
- name: string
25
- title: string
26
- summary?: string
27
- blocks: WorkspaceBlock[]
28
- }
29
-
30
- const text = (value: unknown, max = 500): string | undefined => (typeof value === 'string' && value.trim() ? value.trim().slice(0, max) : undefined)
31
- const scalar = (value: unknown): string | number | boolean | null =>
32
- value === null || value === undefined ? null : typeof value === 'number' || typeof value === 'boolean' ? value : String(value).slice(0, 500)
33
-
34
- /** A short key of the workspace - the same name in one conversation is the same workspace, a new version. */
35
- export function workspaceName(name: unknown, title: string): string {
36
- const given = typeof name === 'string' ? name.trim().toLowerCase() : ''
37
- if (/^[a-z0-9][a-z0-9-]{0,63}$/.test(given)) return given
38
- const slug = (given || title)
39
- .toLowerCase()
40
- .replace(/[^a-z0-9가-힣]+/g, '-')
41
- .replace(/^-+|-+$/g, '')
42
- .slice(0, 64)
43
- return slug || 'workspace'
44
- }
45
-
46
- function unreadable(kind: unknown, reason: string): WorkspaceBlock {
47
- return { kind: 'unreadable', was: typeof kind === 'string' ? kind.slice(0, 40) : null, reason }
48
- }
49
-
50
- function block(raw: any): WorkspaceBlock {
51
- const kind = raw?.kind
52
- switch (kind) {
53
- case 'heading': {
54
- const value = text(raw.text, 200)
55
- if (!value) return unreadable(kind, 'no-text')
56
- const level = [1, 2, 3].includes(raw.level) ? raw.level : 2
57
- return { kind, text: value, level }
58
- }
59
- case 'text': {
60
- const value = text(raw.markdown ?? raw.text, MAX_TEXT)
61
- return value ? { kind, markdown: value } : unreadable(kind, 'no-text')
62
- }
63
- case 'metrics': {
64
- const items = (Array.isArray(raw.items) ? raw.items : [])
65
- .filter((one: any) => text(one?.label) && one?.value !== undefined && one?.value !== null)
66
- .slice(0, 12)
67
- .map((one: any) => ({ label: text(one.label, 80), value: scalar(one.value), ...(text(one.unit, 20) ? { unit: text(one.unit, 20) } : {}), ...(text(one.note, 200) ? { note: text(one.note, 200) } : {}) }))
68
- return items.length ? { kind, items } : unreadable(kind, 'no-items')
69
- }
70
- case 'table': {
71
- const columns = (Array.isArray(raw.columns) ? raw.columns : [])
72
- .filter((one: any) => text(one?.name, 80))
73
- .slice(0, 30)
74
- .map((one: any) => ({ name: text(one.name, 80)!, ...(text(one.label, 80) ? { label: text(one.label, 80) } : {}), type: ['number', 'date', 'string'].includes(one.type) ? one.type : 'string' }))
75
- if (!columns.length) return unreadable(kind, 'no-columns')
76
- const given = Array.isArray(raw.rows) ? raw.rows : []
77
- /* A row is an object by column name, or an array in column order - models write both. */
78
- /* A number column reads "12,400" as 12400 - cells come as text from a model told one type per field. */
79
- const cell = (column: any, value: unknown) => {
80
- const read = scalar(value)
81
- if (column.type !== 'number' || typeof read !== 'string') return read
82
- const number = Number(read.replace(/[,\s₩$€]/g, ''))
83
- return read.trim() && Number.isFinite(number) ? number : read
84
- }
85
- const rows = given.slice(0, MAX_TABLE_ROWS).map((row: any) =>
86
- Object.fromEntries(columns.map((column: any, i: number) => [column.name, cell(column, Array.isArray(row) ? row[i] : row?.[column.name])]))
87
- )
88
- return { kind, columns, rows, ...(text(raw.caption, 300) ? { caption: text(raw.caption, 300) } : {}), ...(given.length > MAX_TABLE_ROWS ? { cut: given.length - MAX_TABLE_ROWS } : {}) }
89
- }
90
- case 'chart': {
91
- const x = (Array.isArray(raw.x) ? raw.x : []).slice(0, 200).map((one: unknown) => String(one ?? '').slice(0, 60))
92
- const series = (Array.isArray(raw.series) ? raw.series : [])
93
- .filter((one: any) => text(one?.name, 60) && Array.isArray(one?.values))
94
- .map((one: any) => ({ name: text(one.name, 60)!, values: x.map((_: unknown, i: number) => (typeof one.values[i] === 'number' && Number.isFinite(one.values[i]) ? one.values[i] : null)) }))
95
- if (!x.length || !series.length) return unreadable(kind, 'no-series')
96
- /* Never a ninth hue: past eight, the first seven stay and the rest fold into one "other". */
97
- const shown =
98
- series.length > MAX_SERIES
99
- ? [
100
- ...series.slice(0, MAX_SERIES - 1),
101
- { name: 'other', other: true, values: x.map((_: unknown, i: number) => series.slice(MAX_SERIES - 1).reduce((acc: number, one: any) => acc + (one.values[i] ?? 0), 0)) }
102
- ]
103
- : series
104
- return { kind, chart: raw.chart === 'line' || raw.type === 'line' || raw.shape === 'line' ? 'line' : 'bar', x, series: shown, ...(text(raw.unit, 20) ? { unit: text(raw.unit, 20) } : {}), ...(text(raw.caption, 300) ? { caption: text(raw.caption, 300) } : {}) }
105
- }
106
- case 'steps': {
107
- const items = (Array.isArray(raw.items) ? raw.items : [])
108
- .filter((one: any) => text(one?.label, 200))
109
- .slice(0, 50)
110
- .map((one: any) => ({ label: text(one.label, 200), state: ['done', 'doing', 'todo', 'failed'].includes(one.state) ? one.state : 'todo', ...(text(one.note, 300) ? { note: text(one.note, 300) } : {}) }))
111
- return items.length ? { kind, items } : unreadable(kind, 'no-items')
112
- }
113
- default:
114
- return unreadable(kind, 'unknown-kind')
115
- }
116
- }
117
-
118
- /** The workspace as the screen reads it. */
119
- export function normalizeWorkspace(args: any): { workspace?: Workspace; error?: string } {
120
- const title = text(args?.title, 200)
121
- if (!title) return { error: 'no-title' }
122
- const given = Array.isArray(args?.blocks) ? args.blocks : []
123
- if (!given.length) return { error: 'no-blocks' }
124
- const blocks = given.slice(0, MAX_BLOCKS).map(block)
125
- if (given.length > MAX_BLOCKS) blocks.push({ kind: 'unreadable', was: null, reason: 'too-many-blocks', cut: given.length - MAX_BLOCKS })
126
- return { workspace: { name: workspaceName(args?.name, title), title, ...(text(args?.summary, 500) ? { summary: text(args.summary, 500) } : {}), blocks } }
127
- }
128
-
129
- /** One line of what is in it - for the card in the conversation and for the model. */
130
- export function workspaceContents(workspace: Workspace): Record<string, number> {
131
- const counts: Record<string, number> = {}
132
- for (const one of workspace.blocks) if (['table', 'chart', 'metrics', 'steps'].includes(one.kind)) counts[one.kind] = (counts[one.kind] ?? 0) + 1
133
- return counts
134
- }
@@ -1,108 +0,0 @@
1
- /*
2
- * showInWorkspace - the model puts a large result on the AI 작업 패널 (operato-application/design/ai/workspace.md §5).
3
- *
4
- * The result rides on the answer as a proposal of kind 'workspace', so the conversation's gates hold for it:
5
- * who may read the conversation reads the workspace, and a value behind a door the reader cannot pass hides
6
- * it with the answer (ADR-0073). The tool itself reaches no door - what it carries came from the turn's other
7
- * tools, whose doors the answer row collects.
8
- */
9
- import { registerToolCategory, type ToolCategory, type ToolSpec } from '@things-factory/ai-client-base'
10
-
11
- import { normalizeWorkspace, workspaceContents, WORKSPACE_BLOCK_KINDS } from './workspace-blocks.js'
12
-
13
- export const WORKSPACE_CATEGORY = 'assistant-workspace'
14
-
15
- export function showInWorkspace(args: any) {
16
- const { workspace, error } = normalizeWorkspace(args)
17
- if (!workspace) return { rejected: true, error, message: 'a workspace needs a title and at least one block.' }
18
- const contents = workspaceContents(workspace)
19
- return {
20
- proposed: true,
21
- kind: 'workspace',
22
- icon: 'dashboard',
23
- label: workspace.title,
24
- workspace,
25
- contents,
26
- message: `put "${workspace.title}" on the workspace (${workspace.blocks.length} blocks). The person opens it from the card - say in one line what it holds; do not repeat its tables in the answer.`
27
- }
28
- }
29
-
30
- const spec = {
31
- kind: 'read',
32
- name: 'showInWorkspace',
33
- doors: [],
34
- description:
35
- 'Put a large result on the AI workspace - a page the person opens from a card, beside the conversation. Blocks: ' +
36
- 'heading{text,level}, text{markdown}, metrics{items:[{label,value,unit,note}]}, table{columns:[{name,label,type:number|date|string}],rows,caption}, ' +
37
- 'chart{chart:bar|line, x:[labels], series:[{name,values:[numbers]}], unit, caption}, steps{items:[{label,state:done|doing|todo|failed,note}]}.',
38
- schema: {
39
- type: 'object',
40
- properties: {
41
- name: { type: 'string', description: 'A short key, lowercase with dashes ("contracts-by-customer"). The same name again makes a new version of the same workspace.' },
42
- title: { type: 'string' },
43
- summary: { type: 'string', description: 'One line under the title.' },
44
- /*
45
- * Every field of every block is declared, each with one type: Gemini's function schema (an OpenAPI 3.0
46
- * subset) refuses a list of types and may leave out a field it was not told of (2026-10-01).
47
- */
48
- blocks: {
49
- type: 'array',
50
- items: {
51
- type: 'object',
52
- properties: {
53
- kind: { type: 'string', enum: [...WORKSPACE_BLOCK_KINDS] },
54
- text: { type: 'string', description: 'heading' },
55
- level: { type: 'integer', description: 'heading: 1-3' },
56
- markdown: { type: 'string', description: 'text' },
57
- caption: { type: 'string', description: 'table, chart' },
58
- unit: { type: 'string', description: 'chart' },
59
- chart: { type: 'string', enum: ['bar', 'line'], description: 'chart' },
60
- items: {
61
- type: 'array',
62
- description: 'metrics: {label,value,unit,note}; steps: {label,state,note}',
63
- items: {
64
- type: 'object',
65
- properties: {
66
- label: { type: 'string' },
67
- value: { type: 'string' },
68
- unit: { type: 'string' },
69
- note: { type: 'string' },
70
- state: { type: 'string', enum: ['done', 'doing', 'todo', 'failed'] }
71
- }
72
- }
73
- },
74
- columns: {
75
- type: 'array',
76
- description: 'table',
77
- items: { type: 'object', properties: { name: { type: 'string' }, label: { type: 'string' }, type: { type: 'string', enum: ['number', 'date', 'string'] } } }
78
- },
79
- rows: { type: 'array', description: 'table: each row is its cells in column order', items: { type: 'array', items: { type: 'string' } } },
80
- x: { type: 'array', description: 'chart: the labels along the bottom', items: { type: 'string' } },
81
- series: {
82
- type: 'array',
83
- description: 'chart',
84
- items: { type: 'object', properties: { name: { type: 'string' }, values: { type: 'array', items: { type: 'number' } } } }
85
- }
86
- },
87
- required: ['kind']
88
- }
89
- }
90
- },
91
- required: ['name', 'title', 'blocks']
92
- },
93
- builder: (args: any) => showInWorkspace(args)
94
- } as ToolSpec
95
-
96
- export const workspaceCategory: ToolCategory = {
97
- name: WORKSPACE_CATEGORY,
98
- description: 'the AI workspace - a page for results too large for the conversation',
99
- guidance: [
100
- '- When a result is more than a short table (over 20 rows, or two or more tables or charts), or the person asks for a page, call showInWorkspace. Keep the answer short: the point, and that it is on the workspace.',
101
- '- Every number in a block comes from a tool result in this conversation - never computed or guessed by you.',
102
- '- To change a workspace, call showInWorkspace again with the same name and the whole new content; it becomes a new version.',
103
- '- Never say something is on the workspace unless you called showInWorkspace in this turn.'
104
- ].join('\n'),
105
- specs: [spec]
106
- }
107
-
108
- registerToolCategory(workspaceCategory)
@@ -1,74 +0,0 @@
1
- /*
2
- * The AI 작업 패널 (design/ai/workspace.md) - what a block may be, what happens to one that is not, and what the
3
- * tool hands back.
4
- */
5
- import { normalizeWorkspace, workspaceName, MAX_SERIES } from './workspace-blocks'
6
- import { showInWorkspace, workspaceCategory } from './workspace-tools'
7
-
8
- describe('the workspace', () => {
9
- it('★ is blocks of known kinds - a block that does not fit stays in its place as a fact, never dropped silently', () => {
10
- const { workspace } = normalizeWorkspace({
11
- name: 'contracts',
12
- title: '2026 contracts',
13
- blocks: [{ kind: 'heading', text: 'By customer' }, { kind: 'html', html: '<script>x</script>' }, { kind: 'table', rows: [] }]
14
- })
15
- expect(workspace!.blocks).toEqual([
16
- { kind: 'heading', text: 'By customer', level: 2 },
17
- { kind: 'unreadable', was: 'html', reason: 'unknown-kind' },
18
- { kind: 'unreadable', was: 'table', reason: 'no-columns' }
19
- ])
20
- })
21
-
22
- it('reads a table row as an object by column or an array in column order, and cuts at the limit saying how many', () => {
23
- const rows = [{ customer: 'A', amount: 10 }, ['B', 20], ...Array.from({ length: 1000 }, () => ({ customer: 'x', amount: 1 }))]
24
- const table: any = normalizeWorkspace({ title: 't', blocks: [{ kind: 'table', columns: [{ name: 'customer' }, { name: 'amount', type: 'number' }], rows }] }).workspace!.blocks[0]
25
- expect(table.rows.slice(0, 2)).toEqual([{ customer: 'A', amount: 10 }, { customer: 'B', amount: 20 }])
26
- expect(table.rows).toHaveLength(1000)
27
- expect(table.cut).toBe(2)
28
- })
29
-
30
- it('★ a chart never gets a ninth colour - past eight series the rest fold into "other"', () => {
31
- const series = Array.from({ length: 10 }, (_, i) => ({ name: `s${i}`, values: [1, 2] }))
32
- const chart: any = normalizeWorkspace({ title: 't', blocks: [{ kind: 'chart', x: ['Jan', 'Feb'], series }] }).workspace!.blocks[0]
33
- expect(chart.series).toHaveLength(MAX_SERIES)
34
- expect(chart.series[MAX_SERIES - 1]).toEqual({ name: 'other', other: true, values: [3, 6] })
35
- expect(chart.chart).toBe('bar')
36
- })
37
-
38
- it('a value that is not a number is a gap in the chart, never a zero', () => {
39
- const chart: any = normalizeWorkspace({ title: 't', blocks: [{ kind: 'chart', chart: 'line', x: ['a', 'b', 'c'], series: [{ name: 'n', values: [1, 'x', 3] }] }] }).workspace!.blocks[0]
40
- expect(chart.series[0].values).toEqual([1, null, 3])
41
- })
42
-
43
- it('the same name is the same workspace - a name that is not a key is made one from it', () => {
44
- expect(workspaceName('contracts-by-customer', 'x')).toBe('contracts-by-customer')
45
- expect(workspaceName(undefined, '2026 Contracts / 고객사')).toBe('2026-contracts-고객사')
46
- })
47
-
48
- it('★ the tool hands back a proposal of kind workspace, so the answer row carries it - and the conversation gates it', () => {
49
- const result: any = showInWorkspace({ name: 'c', title: 'Contracts', blocks: [{ kind: 'table', columns: [{ name: 'a' }], rows: [[1]] }, { kind: 'metrics', items: [{ label: 'n', value: 26 }] }] })
50
- expect(result).toMatchObject({ proposed: true, kind: 'workspace', label: 'Contracts', contents: { table: 1, metrics: 1 } })
51
- expect((workspaceCategory.specs[0] as any).doors).toEqual([])
52
- })
53
-
54
- it('no title or no blocks is refused, with what it needs', () => {
55
- expect(showInWorkspace({ blocks: [{ kind: 'text', markdown: 'x' }] })).toMatchObject({ rejected: true, error: 'no-title' })
56
- expect(showInWorkspace({ title: 'x', blocks: [] })).toMatchObject({ rejected: true, error: 'no-blocks' })
57
- })
58
-
59
- it('a number column reads the text a model writes - "12,400" is 12400, a word stays a word', () => {
60
- const table: any = normalizeWorkspace({ title: 't', blocks: [{ kind: 'table', columns: [{ name: 'a', type: 'number' }], rows: [['12,400'], ['n/a']] }] }).workspace!.blocks[0]
61
- expect(table.rows).toEqual([{ a: 12400 }, { a: 'n/a' }])
62
- })
63
-
64
- it('★ every field of the tool has one type, and every object says its fields - what Gemini accepts', () => {
65
- const walk = (schema: any, path: string, out: string[]) => {
66
- if (!schema || typeof schema !== 'object') return out
67
- if (Array.isArray(schema.type)) out.push(`${path}: a list of types`)
68
- if (schema.type === 'object' && !Object.keys(schema.properties ?? {}).length) out.push(`${path}: an object with no fields`)
69
- for (const [key, value] of Object.entries(schema)) if (value && typeof value === 'object') walk(value, `${path}/${key}`, out)
70
- return out
71
- }
72
- expect(walk((workspaceCategory.specs[0] as any).schema, '', [])).toEqual([])
73
- })
74
- })
@@ -1,41 +0,0 @@
1
- /*
2
- * The boot report prints what registered but is not yet what the contracts require.
3
- *
4
- * It also asks the schema, through AUTH's field table, whether a door a tool names exists. That
5
- * import is why this suite did not load from 2026-09-18 (`0c3a8ac939`) until 2026-09-24: the
6
- * package root of auth-base brings shell and its ORM configuration with it, and jest has no module
7
- * list to give that configuration. The table is a function of one field name, so it is stood in
8
- * here — the door report has its own tests (`door-declaration-report.test.ts`).
9
- */
10
- jest.mock('@things-factory/env', () => ({ logger: { warn: jest.fn() } }))
11
- jest.mock('@things-factory/auth-base', () => ({ privilegeOfField: () => ({ known: false }) }))
12
- /* ai-client-base keeps the AI usage table since 2026-10-12, so its root brings shell too - the same stand-in. */
13
- jest.mock('@things-factory/ai-client-base', () => ({ getToolRegistryWarnings: () => [] }))
14
-
15
- import { formatAssistantModeWarnings, formatToolRegistryWarnings } from './tool-registry-boot-report'
16
-
17
- it('★ groups the recorded omissions by code and names every tool', () => {
18
- const lines = formatToolRegistryWarnings([
19
- { code: 'tool-doors-undeclared', params: { category: 'twin-authoring', tool: 'getOpenScene', kind: 'read' }, message: '' },
20
- { code: 'tool-doors-undeclared', params: { category: 'x-ops', tool: 'runThing', kind: 'external' }, message: '' }
21
- ])
22
-
23
- expect(lines).toEqual(['[ai-assistant] tool-doors-undeclared ×2: twin-authoring/getOpenScene(read), x-ops/runThing(external)'])
24
- })
25
-
26
- it('says nothing when every tool is declared', () => {
27
- expect(formatToolRegistryWarnings([])).toEqual([])
28
- })
29
-
30
- describe('a screen with two conversations is reported by its subject (ADR-0072 rule, ruled 2026-10-13)', () => {
31
- it('★ the boot line names the code, the subject and both conversations', () => {
32
- const lines = formatAssistantModeWarnings([
33
- {
34
- code: 'assistant-mode-subject-claimed-twice',
35
- params: { kind: 'twin.board', subject: 'board', kinds: ['twin.board', 'twin.space'] },
36
- message: ''
37
- }
38
- ])
39
- expect(lines).toEqual(['[ai-assistant] assistant-mode-subject-claimed-twice ×1: board:twin.board+twin.space'])
40
- })
41
- })