@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,31 +0,0 @@
1
- /*
2
- * Pressing an invite card seats the person through the invite door, as the one who pressed (ADR-0073 decision 3).
3
- * The card is ai-assistant's own tool (server: people/invite-tools.ts), so its handler is registered here, by the
4
- * package that declared it - the dock knows no proposal kind (design/ai/shared-dock.md §4).
5
- */
6
- import gql from 'graphql-tag'
7
-
8
- import { i18next } from '@operato/i18n'
9
- import { client } from '@operato/graphql'
10
-
11
- import { registerProposalHandler } from './assistant-proposals.js'
12
- import { inviteProposalHandler } from './invite-proposal.js'
13
-
14
- registerProposalHandler(
15
- 'proposeInvite',
16
- inviteProposalHandler(
17
- async (sessionId, userIds) => {
18
- const result = await client.mutate({
19
- mutation: gql`
20
- mutation ($id: String!, $users: [String!]!) {
21
- inviteToAISession(sessionId: $id, userIds: $users)
22
- }
23
- `,
24
- variables: { id: sessionId, users: userIds }
25
- })
26
- if (result.errors?.length) throw new Error(result.errors[0].message)
27
- return result.data?.inviteToAISession ?? []
28
- },
29
- (key, options) => String(i18next.t(key, options))
30
- )
31
- )
@@ -1,40 +0,0 @@
1
- import { inviteProposalHandler, invitedBy, isInviteProposal } from './invite-proposal'
2
-
3
- const card = (people: any[], extra: any = {}) => ({ tool: 'proposeInvite', kind: 'invite', people, ...extra })
4
- const kim = { userId: 'u-1', name: '정연희', department: 'Sales' }
5
- const lee = { userId: 'u-2', name: '정연희', department: 'Finance' }
6
- const t = (_key: string, options: any) => String(options.defaultValue).replace('{names}', options.names)
7
- const context = (sessionId?: string) => ({ sessionId, confirm: async () => true, notify: () => {} }) as any
8
-
9
- describe('the invite card', () => {
10
- it('is the invite tool\'s card with someone on it', () => {
11
- expect(isInviteProposal(card([kim]))).toBe(true)
12
- expect(isInviteProposal(card([]))).toBe(false)
13
- expect(isInviteProposal({ ...card([kim]), tool: 'proposeAction' })).toBe(false)
14
- })
15
-
16
- it('★ one person: pressing invites them; several: only the one picked - nothing is guessed', () => {
17
- expect(invitedBy(card([kim]))).toEqual([kim])
18
- expect(invitedBy(card([kim, lee]))).toEqual([])
19
- expect(invitedBy(card([kim, lee], { chosen: 'u-2' }))).toEqual([lee])
20
- })
21
-
22
- it('★ pressing calls the invite door with the conversation and the person picked', async () => {
23
- const calls: any[] = []
24
- const handler = inviteProposalHandler(async (sessionId, userIds) => (calls.push([sessionId, userIds]), userIds), t)
25
- expect(await handler(card([kim, lee], { chosen: 'u-2' }), context('s1'))).toMatchObject({ verdict: 'accepted', applied: 1, note: '정연희 joined this conversation and was told.' })
26
- expect(calls).toEqual([['s1', ['u-2']]])
27
- })
28
-
29
- it('no pick, no conversation, or nobody seated - said, never accepted', async () => {
30
- const handler = inviteProposalHandler(async (_s, userIds) => userIds, t)
31
- expect(await handler(card([kim, lee]), context('s1'))).toEqual({ verdict: 'refused', errorCode: 'no-person-chosen' })
32
- expect(await handler(card([kim]), context())).toEqual({ verdict: 'unavailable', errorCode: 'no-conversation' })
33
- expect(await inviteProposalHandler(async () => [], t)(card([kim]), context('s1'))).toEqual({ verdict: 'refused', errorCode: 'already-here' })
34
- })
35
-
36
- it("the door's refusal is not swallowed - it is thrown to the dock, which reports it", async () => {
37
- const handler = inviteProposalHandler(async () => { throw new Error('only the person who started this group conversation can bring people in.') }, t)
38
- await expect(handler(card([kim]), context('s1'))).rejects.toThrow(/only the person who started/)
39
- })
40
- })
@@ -1,54 +0,0 @@
1
- /*
2
- * The invite card (server: people/invite-tools.ts) - who it offers, and what pressing it does.
3
- *
4
- * Pressing is the person's act: the dock calls `inviteToAISession` with their own request, and the door decides
5
- * whether they may seat anyone here (`maySeat`). The model's card seats nobody by itself. A card with several people
6
- * of one name is pressed on one of them - the press carries `chosen`; nothing is guessed.
7
- */
8
- import type { ProposalHandler } from './assistant-proposals.js'
9
-
10
- export interface InvitePerson {
11
- userId: string
12
- name: string
13
- department?: string
14
- position?: string
15
- }
16
-
17
- export function isInviteProposal(proposal: any): boolean {
18
- return proposal?.kind === 'invite' && proposal?.tool === 'proposeInvite' && Array.isArray(proposal?.people) && proposal.people.length > 0
19
- }
20
-
21
- /** The people a press brings in: the one picked, or the only one on the card. */
22
- export function invitedBy(proposal: any): InvitePerson[] {
23
- const people: InvitePerson[] = Array.isArray(proposal?.people) ? proposal.people.filter((one: any) => one?.userId) : []
24
- if (proposal?.chosen) return people.filter(one => one.userId === proposal.chosen)
25
- return people.length === 1 ? people : []
26
- }
27
-
28
- /** One line under a person's name - where they work. */
29
- export function personLine(person: InvitePerson): string {
30
- return [person.department, person.position].filter(Boolean).join(' · ')
31
- }
32
-
33
- /**
34
- * Presses the card through the invite door. `invite` is the door - `inviteToAISession(sessionId, userIds)`, answering the
35
- * ids seated now; it throws the door's refusal, which the dock reports as `refused` with that message.
36
- */
37
- export function inviteProposalHandler(
38
- invite: (sessionId: string, userIds: string[]) => Promise<string[]>,
39
- t: (key: string, options: Record<string, unknown>) => string
40
- ): ProposalHandler {
41
- return async (proposal, context) => {
42
- const people = invitedBy(proposal)
43
- if (!people.length) return { verdict: 'refused', errorCode: 'no-person-chosen' }
44
- if (!context.sessionId) return { verdict: 'unavailable', errorCode: 'no-conversation' }
45
- const seated = await invite(context.sessionId, people.map(one => one.userId))
46
- if (!seated.length) return { verdict: 'refused', errorCode: 'already-here' }
47
- const names = people.filter(one => seated.includes(one.userId)).map(one => one.name).join(', ')
48
- return {
49
- verdict: 'accepted',
50
- applied: seated.length,
51
- note: t('ai-assistant.people.invited', { names, defaultValue: '{names} joined this conversation and was told.' })
52
- }
53
- }
54
- }
@@ -1,33 +0,0 @@
1
- /**
2
- * The page's menu gives the dock its room (2026-10-12). When the dock opens beside the page, the left menu folds to its
3
- * icons; when the dock closes, the menu opens again - only if it is still folded the way the dock left it. A menu the
4
- * person folded themselves stays folded, and the dock's fold is never saved as the person's choice: it sets the menu's
5
- * state without the menu's own `setCollapsed`, which stores it.
6
- */
7
- export interface MenuLike {
8
- collapsed: boolean
9
- }
10
-
11
- export function foldForDock(menu: MenuLike | undefined): boolean {
12
- if (!menu || menu.collapsed) return false
13
- menu.collapsed = true
14
- return true
15
- }
16
-
17
- export function unfoldAfterDock(menu: MenuLike | undefined, foldedByDock: boolean): void {
18
- if (!menu || !foldedByDock || !menu.collapsed) return
19
- menu.collapsed = false
20
- }
21
-
22
- /** The framework's menu (`ox-menu-part` of @operato/menu), wherever the layout put it. */
23
- export function findMenu(root: Document | ShadowRoot = document): (HTMLElement & MenuLike) | undefined {
24
- const found = root.querySelector('ox-menu-part') as (HTMLElement & MenuLike) | null
25
- if (found) return found
26
- for (const element of root.querySelectorAll('*')) {
27
- if (element.shadowRoot) {
28
- const inner = findMenu(element.shadowRoot)
29
- if (inner) return inner
30
- }
31
- }
32
- return undefined
33
- }
@@ -1,21 +0,0 @@
1
- /*
2
- * The card that opens an application's list screen with the conditions of a question (design/ai/read-targets.md §5).
3
- * It reads nothing and runs nothing - the person presses it and the page opens beside the dock.
4
- */
5
-
6
- /** An address inside the application - never another origin, never a script. */
7
- export function isAppAddress(href: unknown): href is string {
8
- return typeof href === 'string' && !!href.trim() && !/^[a-z][a-z0-9+.-]*:/i.test(href.trim()) && !href.trim().startsWith('//')
9
- }
10
-
11
- export function isOpenPageProposal(proposal: any): boolean {
12
- return proposal?.kind === 'open-page' && isAppAddress(proposal?.href)
13
- }
14
-
15
- /** The line under the card's title - the conditions the screen does not take, said, never dropped quietly. */
16
- export function openPageNote(proposal: any, t: (key: string, options?: any) => string): string {
17
- const missing: string[] = Array.isArray(proposal?.notAppliedLabels) ? proposal.notAppliedLabels : []
18
- return missing.length
19
- ? t('ai-assistant.screen.not-applied', { defaultValue: 'the screen does not take: {conditions}', conditions: missing.join(', ') })
20
- : ''
21
- }
@@ -1,145 +0,0 @@
1
- /*
2
- * A table pasted into the composer, carried as a file (design/ai/data-entry.md §4-1, design/ai/shared-dock.md §9-5).
3
- *
4
- * Rows copied from a spreadsheet or a web page are what an AI 입력 is made from most often. Pasted as words they
5
- * reach the model as something the person said, and the entry card cannot check a row against them nor read a
6
- * printed total. Carried as a CSV file they are a source like an attached sheet: each row is found on its line.
7
- *
8
- * - The HTML of the clipboard is read first when it holds a table - a spreadsheet and a browser both put one there,
9
- * and it keeps a cell that holds a line break or a tab whole. A web page whose words lie mostly outside the table
10
- * is not a table paste; it is left as words.
11
- * - Otherwise the plain text is a table when its lines are tab-separated (a spreadsheet's own text).
12
- * - The file has the shape of a read sheet: a line naming it, then every row led by its own number.
13
- * - The limit is on the text, as for a sheet - a table over it is refused, never cut.
14
- *
15
- * Pure: the screen hands in the clipboard's strings.
16
- */
17
- import { textCharsOf, type AttachmentPolicy } from './attachment-policy.js'
18
- import { csvField } from './spreadsheet-text.js'
19
-
20
- export interface PastedTable {
21
- rows: string[][]
22
- columns: number
23
- }
24
-
25
- /** Words outside the table beyond this are a page that holds a table, not a table. */
26
- const WORDS_OUTSIDE_A_TABLE = 20
27
-
28
- const ENTITIES: Record<string, string> = { nbsp: ' ', amp: '&', lt: '<', gt: '>', quot: '"', apos: "'", '#39': "'" }
29
-
30
- function decodeEntities(text: string): string {
31
- return text.replace(/&(#x[0-9a-f]+|#\d+|[a-z]+\d*|#39);/gi, (whole, name: string) => {
32
- const lower = name.toLowerCase()
33
- if (lower in ENTITIES) return ENTITIES[lower]
34
- if (lower.startsWith('#x')) return String.fromCodePoint(parseInt(lower.slice(2), 16))
35
- if (lower.startsWith('#')) return String.fromCodePoint(parseInt(lower.slice(1), 10))
36
- return whole
37
- })
38
- }
39
-
40
- /** What a piece of HTML shows as words - a line break and a cell's own breaks become one space. */
41
- function wordsOf(html: string): string {
42
- return decodeEntities(html.replace(/<br\s*\/?>/gi, ' ').replace(/<[^>]*>/g, ''))
43
- .replace(/\s+/g, ' ')
44
- .trim()
45
- }
46
-
47
- /** What the clipboard's HTML shows, without what is never shown - comments, styles, scripts, the head. */
48
- function shownHtml(html: string): string {
49
- return html
50
- .replace(/<!--[\s\S]*?-->/g, '')
51
- .replace(/<(style|script|head)\b[\s\S]*?<\/\1\s*>/gi, '')
52
- }
53
-
54
- /** The rows of the tables in the clipboard's HTML, or null when it holds none or is mostly not a table. */
55
- export function tableOfHtml(html: string | null | undefined): string[][] | null {
56
- if (!html || !/<table\b/i.test(html)) return null
57
- const shown = shownHtml(html)
58
- const outside = wordsOf(shown.replace(/<table\b[\s\S]*?<\/table\s*>/gi, ' '))
59
- if (outside.replace(/\s/g, '').length > WORDS_OUTSIDE_A_TABLE) return null
60
-
61
- const rows: string[][] = []
62
- for (const part of shown.split(/<tr\b[^>]*>/i).slice(1)) {
63
- const body = part.split(/<\/table\s*>/i)[0]
64
- const row: string[] = []
65
- for (const cell of body.matchAll(/<(td|th)\b([^>]*)>([\s\S]*?)(?=<\/?(?:td|th|tr)\b|$)/gi)) {
66
- row.push(wordsOf(cell[3]))
67
- const span = Number(/\bcolspan\s*=\s*["']?(\d+)/i.exec(cell[2])?.[1] ?? 1)
68
- for (let more = 1; more < Math.min(span, 100); more++) row.push('')
69
- }
70
- if (row.some(text => text !== '')) rows.push(row)
71
- }
72
- return rows.length ? rows : null
73
- }
74
-
75
- /** The rows of a spreadsheet's plain text - tab-separated lines, a cell with a break or a tab in quotes. */
76
- export function tableOfText(text: string | null | undefined): string[][] | null {
77
- if (!text || !text.includes('\t')) return null
78
- const rows: string[][] = []
79
- let row: string[] = []
80
- let cell = ''
81
- let quoted = false
82
- for (let at = 0; at < text.length; at++) {
83
- const c = text[at]
84
- if (quoted) {
85
- if (c === '"' && text[at + 1] === '"') (cell += '"'), at++
86
- else if (c === '"') quoted = false
87
- else cell += c
88
- } else if (c === '"' && cell === '') quoted = true
89
- else if (c === '\t') row.push(cell), (cell = '')
90
- else if (c === '\n' || c === '\r') {
91
- if (c === '\r' && text[at + 1] === '\n') at++
92
- row.push(cell), rows.push(row), (row = []), (cell = '')
93
- } else cell += c
94
- }
95
- if (cell !== '' || row.length) row.push(cell), rows.push(row)
96
- const kept = rows.map(one => one.map(text => text.replace(/\s+/g, ' ').trim())).filter(one => one.some(text => text !== ''))
97
- /* One tab in a sentence is not a table - most lines must be split into columns. */
98
- if (kept.filter(one => one.length > 1).length < Math.max(2, Math.ceil(kept.length / 2))) return null
99
- return kept
100
- }
101
-
102
- /** The table a paste holds, or null for words - at least two rows of at least two columns. */
103
- export function pastedTable(clipboard: { html?: string | null; text?: string | null }): PastedTable | null {
104
- const fromHtml = tableOfHtml(clipboard.html)
105
- /* A page the HTML shows to be mostly words stays words - its plain text would read the table out of it anyway. */
106
- if (!fromHtml && clipboard.html && /<table\b/i.test(clipboard.html)) return null
107
- for (const rows of [fromHtml, tableOfText(clipboard.text)]) {
108
- if (!rows) continue
109
- const trimmed = rows.map(row => {
110
- let cells = row
111
- while (cells.length && cells[cells.length - 1] === '') cells = cells.slice(0, -1)
112
- return cells
113
- })
114
- const columns = Math.max(...trimmed.map(row => row.length))
115
- if (trimmed.length >= 2 && columns >= 2) return { rows: trimmed, columns }
116
- }
117
- return null
118
- }
119
-
120
- /** The table as the text of its file: a line naming it, then every row led by its own number. */
121
- export function pastedTableText(table: PastedTable, name: string): string {
122
- const lines = table.rows.map((row, i) => [String(i + 1), ...row].map(csvField).join(','))
123
- return [`# ${name} · a table the person pasted · the first column is the row number in the pasted table`, ...lines].join('\n') + '\n'
124
- }
125
-
126
- export type PasteRefusal = { code: 'attachment-paste-too-long'; rows: number; maxChars: number }
127
-
128
- /**
129
- * What a paste becomes in a conversation under this policy: a table file, a refusal, or null - the paste stays words
130
- * (no table in it, or a conversation that takes no text files).
131
- */
132
- export function pastedTableFile(
133
- clipboard: { html?: string | null; text?: string | null },
134
- policy: AttachmentPolicy | null | undefined,
135
- nameOf: (rows: number) => string
136
- ): { name: string; text: string; table: PastedTable } | { refusal: PasteRefusal } | null {
137
- if (!policy?.kinds?.some(kind => kind === 'text' || kind === 'spreadsheet')) return null
138
- const table = pastedTable(clipboard)
139
- if (!table) return null
140
- const name = nameOf(table.rows.length)
141
- const text = pastedTableText(table, name)
142
- const maxChars = textCharsOf(policy)
143
- if (text.length > maxChars) return { refusal: { code: 'attachment-paste-too-long', rows: table.rows.length, maxChars } }
144
- return { name: `${name.replace(/[\\/:*?"<>|]/g, '_')}.csv`, text, table }
145
- }
@@ -1,25 +0,0 @@
1
- /*
2
- * A PDF page drawn into an image - for a scanned page, whose text has to be read from its picture. The PDF is opened
3
- * through @operato/utils pdf-loader (document-text.ts reads the pages' text).
4
- */
5
-
6
- /** The longest side of a drawn page, in pixels - enough for a model to read print, small enough to send. */
7
- export const PAGE_IMAGE_SIDE = 1600
8
-
9
- /** One page drawn into a JPEG. */
10
- export async function drawPdfPage(pdf: any, number: number): Promise<Blob> {
11
- const page = await pdf.getPage(number)
12
- const base = page.getViewport({ scale: 1 })
13
- const viewport = page.getViewport({ scale: Math.min(2, PAGE_IMAGE_SIDE / Math.max(base.width, base.height)) })
14
- const canvas = document.createElement('canvas')
15
- canvas.width = Math.ceil(viewport.width)
16
- canvas.height = Math.ceil(viewport.height)
17
- const context = canvas.getContext('2d')!
18
- /* A page draws on transparent pixels; a JPEG would turn them black. */
19
- context.fillStyle = '#ffffff'
20
- context.fillRect(0, 0, canvas.width, canvas.height)
21
- await page.render({ canvas, canvasContext: context, viewport }).promise
22
- return await new Promise<Blob>((resolve, reject) =>
23
- canvas.toBlob(blob => (blob ? resolve(blob) : reject(new Error('the page could not be drawn'))), 'image/jpeg', 0.85)
24
- )
25
- }
@@ -1,125 +0,0 @@
1
- /*
2
- * A spreadsheet read into text the conversation can carry (design/ai/shared-dock.md §9-5).
3
- *
4
- * The door takes images and text only; a mode that opens 'spreadsheet' has the screen read each .xlsx sheet into
5
- * CSV before sending, so the model reads the sheet and the entry card can name where a row came from.
6
- *
7
- * - Read with exceljs. The old binary .xls is not read - it is refused by name (exceljs cannot open it, and the
8
- * npm SheetJS that can has unfixed flaws; a file a person uploads is not opened with it).
9
- * - A cell is its value - a formula as its computed result, a date as ISO, rich text as its text.
10
- * - Every line carries the sheet's own row number. Empty rows are left out, never renumbered, so "sheet · row" on a
11
- * card is the row the person sees in Excel.
12
- * - The limit is on the text after reading - a small .xlsx can be a long text. A sheet over it is refused, never cut:
13
- * a cut ledger is read as the whole ledger.
14
- */
15
-
16
- export type SpreadsheetKind = 'xlsx' | 'xls'
17
-
18
- const XLSX_TYPE = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
19
- const XLS_TYPE = 'application/vnd.ms-excel'
20
-
21
- /** A spreadsheet by its type, or by its name when the browser did not know the type. */
22
- export function spreadsheetKindOf(file: { type?: string; name?: string }): SpreadsheetKind | null {
23
- const type = (file.type || '').toLowerCase()
24
- const name = (file.name || '').toLowerCase()
25
- if (type === XLSX_TYPE || name.endsWith('.xlsx')) return 'xlsx'
26
- if (type === XLS_TYPE || name.endsWith('.xls')) return 'xls'
27
- return null
28
- }
29
-
30
- /** The picker's `accept` for spreadsheets. */
31
- export const SPREADSHEET_ACCEPT = ['.xlsx', XLSX_TYPE]
32
-
33
- const pad = (n: number) => String(n).padStart(2, '0')
34
-
35
- /** One cell as text - what Excel shows as the value, not how it is stored. */
36
- export function cellText(value: unknown): string {
37
- if (value === null || value === undefined) return ''
38
- if (value instanceof Date) {
39
- if (isNaN(value.getTime())) return ''
40
- const day = `${value.getUTCFullYear()}-${pad(value.getUTCMonth() + 1)}-${pad(value.getUTCDate())}`
41
- const h = value.getUTCHours()
42
- const m = value.getUTCMinutes()
43
- const s = value.getUTCSeconds()
44
- return h || m || s ? `${day}T${pad(h)}:${pad(m)}:${pad(s)}` : day
45
- }
46
- if (typeof value === 'object') {
47
- const v = value as any
48
- if ('result' in v) return cellText(v.result)
49
- if ('formula' in v || 'sharedFormula' in v) return ''
50
- if (Array.isArray(v.richText)) return v.richText.map((part: any) => part?.text ?? '').join('')
51
- if ('text' in v) return cellText(v.text)
52
- if ('error' in v) return String(v.error)
53
- return ''
54
- }
55
- return String(value)
56
- }
57
-
58
- /** One CSV field - quoted when it holds a comma, a quote or a line break. */
59
- export const csvField = (text: string) => (/[",\n\r]/.test(text) ? `"${text.replace(/"/g, '""')}"` : text)
60
-
61
- export interface SheetRow {
62
- /** The row number in the sheet - 1 for Excel's first row. */
63
- number: number
64
- cells: unknown[]
65
- }
66
-
67
- /** One sheet as CSV: a line naming the file and sheet, then every non-empty row led by its own row number. */
68
- export function sheetText(fileName: string, sheetName: string, rows: SheetRow[]): string {
69
- const lines = rows
70
- .map(row => ({ number: row.number, cells: row.cells.map(cellText) }))
71
- .filter(row => row.cells.some(cell => cell.trim() !== ''))
72
- .map(row => {
73
- let cells = row.cells
74
- while (cells.length && cells[cells.length - 1] === '') cells = cells.slice(0, -1)
75
- return [String(row.number), ...cells].map(csvField).join(',')
76
- })
77
- return [`# ${fileName} · sheet "${sheetName}" · the first column is the sheet's own row number`, ...lines].join('\n') + '\n'
78
- }
79
-
80
- export interface SheetFile {
81
- name: string
82
- text: string
83
- }
84
-
85
- export type SpreadsheetRefusal = { code: 'attachment-xls-not-read'; name: string } | { code: 'attachment-sheet-too-long'; name: string; maxChars: number } | { code: 'attachment-sheet-unreadable'; name: string }
86
- | { code: 'attachment-sheet-empty'; name: string }
87
-
88
- /** The file name a sheet travels under - "거래내역.xlsx" sheet "9월" → "거래내역 - 9월.csv". */
89
- export function sheetFileName(fileName: string, sheetName: string): string {
90
- return `${fileName.replace(/\.xlsx?$/i, '')} - ${sheetName.replace(/[\\/:*?"<>|]/g, '_')}.csv`
91
- }
92
-
93
- /**
94
- * Every non-empty sheet of an .xlsx as text, or why not. `load` is exceljs's Workbook - passed in so the screen
95
- * loads the library only when a spreadsheet is attached.
96
- */
97
- export async function readSpreadsheet(
98
- data: ArrayBuffer | Uint8Array,
99
- fileName: string,
100
- maxChars: number,
101
- Workbook: new () => any
102
- ): Promise<{ files: SheetFile[] } | { refusal: SpreadsheetRefusal }> {
103
- const workbook = new Workbook()
104
- try {
105
- await workbook.xlsx.load(data)
106
- } catch {
107
- return { refusal: { code: 'attachment-sheet-unreadable', name: fileName } }
108
- }
109
- const files: SheetFile[] = []
110
- for (const sheet of workbook.worksheets) {
111
- const rows: SheetRow[] = []
112
- sheet.eachRow({ includeEmpty: false }, (row: any, number: number) => {
113
- const values = Array.isArray(row.values) ? row.values.slice(1) : []
114
- rows.push({ number, cells: values })
115
- })
116
- if (!rows.length) continue
117
- const text = sheetText(fileName, sheet.name, rows)
118
- const name = sheetFileName(fileName, sheet.name)
119
- if (text.length > maxChars) return { refusal: { code: 'attachment-sheet-too-long', name: `${fileName} · ${sheet.name}`, maxChars } }
120
- files.push({ name, text })
121
- }
122
- /* A workbook with nothing in it is said, not dropped: the person would think it was sent. */
123
- if (!files.length) return { refusal: { code: 'attachment-sheet-empty', name: fileName } }
124
- return { files }
125
- }
@@ -1,89 +0,0 @@
1
- /*
2
- * The AI 작업 패널 on the screen - which versions a workspace has, and the table's sort and CSV
3
- * (operato-application/design/ai/workspace.md). Pure - tested without a browser.
4
- */
5
-
6
- export interface WorkspaceBlockView {
7
- kind: string
8
- [key: string]: any
9
- }
10
-
11
- export interface WorkspaceView {
12
- name: string
13
- title: string
14
- summary?: string
15
- blocks: WorkspaceBlockView[]
16
- }
17
-
18
- export interface WorkspaceVersion {
19
- /** 1-based, in the order the conversation made them. */
20
- version: number
21
- messageId: string
22
- createdAt?: string
23
- workspace: WorkspaceView
24
- }
25
-
26
- export function isWorkspaceProposal(proposal: any): boolean {
27
- return proposal?.kind === 'workspace' && !!proposal?.workspace?.name
28
- }
29
-
30
- /**
31
- * Every version of the named workspace in a conversation, oldest first. A message the reader may not see
32
- * comes back redacted without its proposals, so a version behind a door is simply not among them.
33
- */
34
- export function workspaceVersions(messages: { id: string; createdAt?: string; proposalsJson?: any[] | null }[], name: string): WorkspaceVersion[] {
35
- const versions: WorkspaceVersion[] = []
36
- for (const message of messages) {
37
- for (const proposal of message.proposalsJson ?? []) {
38
- if (isWorkspaceProposal(proposal) && proposal.workspace.name === name) {
39
- versions.push({ version: versions.length + 1, messageId: message.id, createdAt: message.createdAt, workspace: proposal.workspace })
40
- }
41
- }
42
- }
43
- return versions
44
- }
45
-
46
- /** The version of a card within its conversation - "2 of 3" on the card and on the page. */
47
- export function versionOfCard(proposalsInOrder: any[][], name: string, key: string): { version: number; of: number } {
48
- let version = 0
49
- let of = 0
50
- for (const list of proposalsInOrder)
51
- for (const one of list ?? []) {
52
- if (!isWorkspaceProposal(one) || one.workspace.name !== name) continue
53
- of += 1
54
- if (one.key === key) version = of
55
- }
56
- return { version, of }
57
- }
58
-
59
- export function workspaceAddress(sessionId: string, name: string, version?: number): string {
60
- const query = new URLSearchParams({ session: sessionId, name })
61
- if (version) query.set('version', String(version))
62
- return `assistant-workspace?${query.toString()}`
63
- }
64
-
65
- /** Sorts by one column - numbers as numbers, empty last, the rest by the reader's collation. */
66
- export function sortRows(rows: Record<string, any>[], column: string, direction: 'asc' | 'desc', locale?: string): Record<string, any>[] {
67
- const factor = direction === 'asc' ? 1 : -1
68
- const collator = new Intl.Collator(locale, { numeric: true })
69
- return [...rows].sort((a, b) => {
70
- const x = a[column]
71
- const y = b[column]
72
- const emptyX = x === null || x === undefined || x === ''
73
- const emptyY = y === null || y === undefined || y === ''
74
- if (emptyX || emptyY) return emptyX === emptyY ? 0 : emptyX ? 1 : -1
75
- if (typeof x === 'number' && typeof y === 'number') return (x - y) * factor
76
- return collator.compare(String(x), String(y)) * factor
77
- })
78
- }
79
-
80
- const csvCell = (value: unknown) => {
81
- const text = value === null || value === undefined ? '' : String(value)
82
- return /[",\n\r]/.test(text) ? `"${text.replace(/"/g, '""')}"` : text
83
- }
84
-
85
- /** The table as CSV - the heading row in the column labels, a BOM so a spreadsheet reads Korean. */
86
- export function tableCsv(columns: { name: string; label?: string }[], rows: Record<string, any>[]): string {
87
- const lines = [columns.map(column => csvCell(column.label || column.name)).join(','), ...rows.map(row => columns.map(column => csvCell(row[column.name])).join(','))]
88
- return '' + lines.join('\r\n')
89
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../client/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC1B,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AACtC,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,gDAAgD,CAAA;AACnF,OAAO,EAAE,WAAW,EAAE,MAAM,mDAAmD,CAAA;AAE/E,OAAO,oCAAoC,CAAA;AAC3C,OAAO,oCAAoC,CAAA;AAE3C;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS;IAC/B,IAAI,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;QAC5B,IAAI,CAAC,CAAC,MAAM,YAAY,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC,CAAC;YAAE,OAAM;QAE3G,KAAK,CAAC,QAAQ,CAAC;YACb,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,CAAA,+CAA+C,EAAE;SACrG,CAAC,CAAA;QACF,KAAK,CAAC,QAAQ,CAAC;YACb,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,CAAA,+CAA+C,EAAE;SACrG,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { html } from 'lit'\nimport { store } from '@operato/shell'\nimport { auth, hasPrivilege } from '@things-factory/auth-base/dist-client/index.js'\nimport { ADD_SETTING } from '@things-factory/setting-base/dist-client/index.js'\n\nimport './settings/ai-agent-setting-let.js'\nimport './settings/ai-usage-setting-let.js'\n\n/**\n * Every application that carries the AI assistant gets its domain's AI agents and AI usage in Settings ›\n * {domain} settings (design/ai/agent-settings.md §7). They are the domain's, not the person's, so they go on the\n * tenant tab - and only for someone who may change the domain's settings, as the doors behind them require.\n */\nexport default function bootstrap() {\n auth.on('profile', async () => {\n if (!(await hasPrivilege({ privilege: 'mutation', category: 'setting', domainOwnerGranted: true }))) return\n\n store.dispatch({\n type: ADD_SETTING,\n setting: { seq: 60, scope: 'tenant', template: html`<ai-agent-setting-let></ai-agent-setting-let>` }\n })\n store.dispatch({\n type: ADD_SETTING,\n setting: { seq: 61, scope: 'tenant', template: html`<ai-usage-setting-let></ai-usage-setting-let>` }\n })\n })\n}\n"]}