@things-factory/ai-assistant 10.1.27 → 10.1.29

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 (210) hide show
  1. package/client/components/assistant-chat.ts +701 -63
  2. package/client/components/assistant-mode.test.ts +105 -55
  3. package/client/components/assistant-mode.ts +144 -82
  4. package/client/components/chat-echo-dedup.test.ts +23 -0
  5. package/client/components/chat-echo-dedup.ts +29 -3
  6. package/client/components/chat-input-builder.test.ts +20 -20
  7. package/client/components/chat-input-builder.ts +16 -14
  8. package/client/components/chat-proposal-survival.test.ts +73 -0
  9. package/client/components/mention-popup.ts +31 -8
  10. package/client/components/panel-aria.test.ts +54 -0
  11. package/client/components/proposal-outcome-line.ts +33 -0
  12. package/client/utils/assistant-session-controller.test.ts +75 -0
  13. package/client/utils/assistant-session-controller.ts +37 -1
  14. package/client/utils/assistant-session-transport.ts +13 -5
  15. package/dist-client/components/assistant-chat.d.ts +140 -13
  16. package/dist-client/components/assistant-chat.js +659 -71
  17. package/dist-client/components/assistant-chat.js.map +1 -1
  18. package/dist-client/components/assistant-mode.d.ts +102 -68
  19. package/dist-client/components/assistant-mode.js +79 -19
  20. package/dist-client/components/assistant-mode.js.map +1 -1
  21. package/dist-client/components/assistant-mode.test.js +90 -53
  22. package/dist-client/components/assistant-mode.test.js.map +1 -1
  23. package/dist-client/components/chat-echo-dedup.d.ts +2 -0
  24. package/dist-client/components/chat-echo-dedup.js +27 -4
  25. package/dist-client/components/chat-echo-dedup.js.map +1 -1
  26. package/dist-client/components/chat-echo-dedup.test.js +20 -0
  27. package/dist-client/components/chat-echo-dedup.test.js.map +1 -1
  28. package/dist-client/components/chat-input-builder.d.ts +12 -7
  29. package/dist-client/components/chat-input-builder.js +8 -10
  30. package/dist-client/components/chat-input-builder.js.map +1 -1
  31. package/dist-client/components/chat-input-builder.test.js +17 -18
  32. package/dist-client/components/chat-input-builder.test.js.map +1 -1
  33. package/dist-client/components/chat-proposal-survival.test.d.ts +1 -0
  34. package/dist-client/components/chat-proposal-survival.test.js +61 -0
  35. package/dist-client/components/chat-proposal-survival.test.js.map +1 -0
  36. package/dist-client/components/mention-popup.js +28 -8
  37. package/dist-client/components/mention-popup.js.map +1 -1
  38. package/dist-client/components/panel-aria.test.d.ts +1 -0
  39. package/dist-client/components/panel-aria.test.js +49 -0
  40. package/dist-client/components/panel-aria.test.js.map +1 -0
  41. package/dist-client/components/proposal-outcome-line.d.ts +9 -0
  42. package/dist-client/components/proposal-outcome-line.js +15 -0
  43. package/dist-client/components/proposal-outcome-line.js.map +1 -0
  44. package/dist-client/tsconfig.tsbuildinfo +1 -1
  45. package/dist-client/utils/assistant-session-controller.d.ts +20 -0
  46. package/dist-client/utils/assistant-session-controller.js +16 -0
  47. package/dist-client/utils/assistant-session-controller.js.map +1 -1
  48. package/dist-client/utils/assistant-session-controller.test.d.ts +1 -0
  49. package/dist-client/utils/assistant-session-controller.test.js +56 -0
  50. package/dist-client/utils/assistant-session-controller.test.js.map +1 -0
  51. package/dist-client/utils/assistant-session-transport.js +13 -5
  52. package/dist-client/utils/assistant-session-transport.js.map +1 -1
  53. package/dist-server/door-declaration-report.d.ts +14 -0
  54. package/dist-server/door-declaration-report.js +54 -0
  55. package/dist-server/door-declaration-report.js.map +1 -0
  56. package/dist-server/service/assistant-capability-resolver.d.ts +17 -0
  57. package/dist-server/service/assistant-capability-resolver.js +88 -0
  58. package/dist-server/service/assistant-capability-resolver.js.map +1 -0
  59. package/dist-server/service/assistant-chat-resolver.d.ts +6 -6
  60. package/dist-server/service/assistant-chat-resolver.js +185 -44
  61. package/dist-server/service/assistant-chat-resolver.js.map +1 -1
  62. package/dist-server/service/assistant-mode/assistant-mode-resolver.d.ts +33 -0
  63. package/dist-server/service/assistant-mode/assistant-mode-resolver.js +148 -0
  64. package/dist-server/service/assistant-mode/assistant-mode-resolver.js.map +1 -0
  65. package/dist-server/service/assistant-mode/index.d.ts +9 -0
  66. package/dist-server/service/assistant-mode/index.js +19 -0
  67. package/dist-server/service/assistant-mode/index.js.map +1 -0
  68. package/dist-server/service/assistant-mode/registry.d.ts +18 -0
  69. package/dist-server/service/assistant-mode/registry.js +136 -0
  70. package/dist-server/service/assistant-mode/registry.js.map +1 -0
  71. package/dist-server/service/assistant-mode/resolve.d.ts +43 -0
  72. package/dist-server/service/assistant-mode/resolve.js +65 -0
  73. package/dist-server/service/assistant-mode/resolve.js.map +1 -0
  74. package/dist-server/service/assistant-mode/types.d.ts +120 -0
  75. package/dist-server/service/assistant-mode/types.js +12 -0
  76. package/dist-server/service/assistant-mode/types.js.map +1 -0
  77. package/dist-server/service/chat-message/carried-turns.d.ts +48 -0
  78. package/dist-server/service/chat-message/carried-turns.js +92 -0
  79. package/dist-server/service/chat-message/carried-turns.js.map +1 -0
  80. package/dist-server/service/chat-message/chat-message-subscription.d.ts +1 -1
  81. package/dist-server/service/chat-message/chat-message-subscription.js +24 -6
  82. package/dist-server/service/chat-message/chat-message-subscription.js.map +1 -1
  83. package/dist-server/service/chat-message/chat-message.d.ts +32 -0
  84. package/dist-server/service/chat-message/chat-message.js +17 -0
  85. package/dist-server/service/chat-message/chat-message.js.map +1 -1
  86. package/dist-server/service/chat-message/door-access.d.ts +27 -0
  87. package/dist-server/service/chat-message/door-access.js +34 -0
  88. package/dist-server/service/chat-message/door-access.js.map +1 -0
  89. package/dist-server/service/chat-message/fold-session-history.d.ts +30 -0
  90. package/dist-server/service/chat-message/fold-session-history.js +133 -0
  91. package/dist-server/service/chat-message/fold-session-history.js.map +1 -0
  92. package/dist-server/service/chat-message/llm-history.d.ts +7 -0
  93. package/dist-server/service/chat-message/llm-history.js +23 -11
  94. package/dist-server/service/chat-message/llm-history.js.map +1 -1
  95. package/dist-server/service/chat-message/message-doors.d.ts +29 -0
  96. package/dist-server/service/chat-message/message-doors.js +107 -0
  97. package/dist-server/service/chat-message/message-doors.js.map +1 -0
  98. package/dist-server/service/chat-message/proposal-outcome.d.ts +18 -0
  99. package/dist-server/service/chat-message/proposal-outcome.js +31 -0
  100. package/dist-server/service/chat-message/proposal-outcome.js.map +1 -0
  101. package/dist-server/service/chat-message/reader-gate.d.ts +3 -0
  102. package/dist-server/service/chat-message/reader-gate.js +39 -0
  103. package/dist-server/service/chat-message/reader-gate.js.map +1 -0
  104. package/dist-server/service/chat-message/room-message.d.ts +4 -0
  105. package/dist-server/service/chat-message/room-message.js +25 -0
  106. package/dist-server/service/chat-message/room-message.js.map +1 -0
  107. package/dist-server/service/chat-session/chat-session.d.ts +36 -0
  108. package/dist-server/service/chat-session/chat-session.js +27 -2
  109. package/dist-server/service/chat-session/chat-session.js.map +1 -1
  110. package/dist-server/service/chat-session/session-anchor.d.ts +10 -1
  111. package/dist-server/service/chat-session/session-anchor.js +12 -4
  112. package/dist-server/service/chat-session/session-anchor.js.map +1 -1
  113. package/dist-server/service/chat-session/session-inbox.d.ts +6 -1
  114. package/dist-server/service/chat-session/session-inbox.js +3 -2
  115. package/dist-server/service/chat-session/session-inbox.js.map +1 -1
  116. package/dist-server/service/chat-session/session-kind.d.ts +14 -0
  117. package/dist-server/service/chat-session/session-kind.js +30 -0
  118. package/dist-server/service/chat-session/session-kind.js.map +1 -0
  119. package/dist-server/service/chat-session/session-visibility.d.ts +15 -0
  120. package/dist-server/service/chat-session/session-visibility.js +35 -0
  121. package/dist-server/service/chat-session/session-visibility.js.map +1 -0
  122. package/dist-server/service/chat-session/station-session-guard.d.ts +1 -5
  123. package/dist-server/service/chat-session/station-session-guard.js +7 -2
  124. package/dist-server/service/chat-session/station-session-guard.js.map +1 -1
  125. package/dist-server/service/chat-session-participant/mention-invite.d.ts +29 -0
  126. package/dist-server/service/chat-session-participant/mention-invite.js +103 -0
  127. package/dist-server/service/chat-session-participant/mention-invite.js.map +1 -0
  128. package/dist-server/service/chat-session-resolver.d.ts +17 -0
  129. package/dist-server/service/chat-session-resolver.js +271 -15
  130. package/dist-server/service/chat-session-resolver.js.map +1 -1
  131. package/dist-server/service/grounding-sources.d.ts +14 -0
  132. package/dist-server/service/grounding-sources.js +26 -0
  133. package/dist-server/service/grounding-sources.js.map +1 -0
  134. package/dist-server/service/index.d.ts +9 -1
  135. package/dist-server/service/index.js +21 -0
  136. package/dist-server/service/index.js.map +1 -1
  137. package/dist-server/service/request-translator.d.ts +2 -0
  138. package/dist-server/service/request-translator.js +20 -0
  139. package/dist-server/service/request-translator.js.map +1 -0
  140. package/dist-server/service/testing/conversation-script.d.ts +123 -0
  141. package/dist-server/service/testing/conversation-script.js +202 -0
  142. package/dist-server/service/testing/conversation-script.js.map +1 -0
  143. package/dist-server/service/testing/mode-conformance.d.ts +50 -0
  144. package/dist-server/service/testing/mode-conformance.js +103 -0
  145. package/dist-server/service/testing/mode-conformance.js.map +1 -0
  146. package/dist-server/tool-registry-boot-report.d.ts +3 -0
  147. package/dist-server/tool-registry-boot-report.js +32 -2
  148. package/dist-server/tool-registry-boot-report.js.map +1 -1
  149. package/dist-server/tsconfig.tsbuildinfo +1 -1
  150. package/package.json +5 -5
  151. package/server/door-declaration-report.test.ts +53 -0
  152. package/server/door-declaration-report.ts +61 -0
  153. package/server/explicit-graphql-types.test.ts +56 -0
  154. package/server/service/assistant-capability-resolver.ts +66 -0
  155. package/server/service/assistant-chat-resolver.ts +205 -42
  156. package/server/service/assistant-mode/assistant-mode-resolver.ts +108 -0
  157. package/server/service/assistant-mode/index.ts +16 -0
  158. package/server/service/assistant-mode/registry.test.ts +105 -0
  159. package/server/service/assistant-mode/registry.ts +147 -0
  160. package/server/service/assistant-mode/resolve.test.ts +120 -0
  161. package/server/service/assistant-mode/resolve.ts +105 -0
  162. package/server/service/assistant-mode/subject-defaults.test.ts +86 -0
  163. package/server/service/assistant-mode/types.ts +121 -0
  164. package/server/service/chat-message/carried-turns.test.ts +80 -0
  165. package/server/service/chat-message/carried-turns.ts +112 -0
  166. package/server/service/chat-message/chat-message-subscription.ts +20 -4
  167. package/server/service/chat-message/chat-message.ts +44 -0
  168. package/server/service/chat-message/door-access.test.ts +72 -0
  169. package/server/service/chat-message/door-access.ts +65 -0
  170. package/server/service/chat-message/fold-history-window.test.ts +184 -0
  171. package/server/service/chat-message/fold-session-history.test.ts +98 -0
  172. package/server/service/chat-message/fold-session-history.ts +115 -0
  173. package/server/service/chat-message/llm-history.test.ts +58 -7
  174. package/server/service/chat-message/llm-history.ts +30 -11
  175. package/server/service/chat-message/message-doors.test.ts +87 -0
  176. package/server/service/chat-message/message-doors.ts +117 -0
  177. package/server/service/chat-message/proposal-outcome.test.ts +48 -0
  178. package/server/service/chat-message/proposal-outcome.ts +42 -0
  179. package/server/service/chat-message/reader-gate.ts +44 -0
  180. package/server/service/chat-message/room-message.test.ts +21 -0
  181. package/server/service/chat-message/room-message.ts +22 -0
  182. package/server/service/chat-session/chat-session.ts +46 -1
  183. package/server/service/chat-session/session-anchor.ts +12 -3
  184. package/server/service/chat-session/session-inbox.test.ts +18 -0
  185. package/server/service/chat-session/session-inbox.ts +11 -2
  186. package/server/service/chat-session/session-kind.test.ts +24 -0
  187. package/server/service/chat-session/session-kind.ts +32 -0
  188. package/server/service/chat-session/session-visibility.test.ts +52 -0
  189. package/server/service/chat-session/session-visibility.ts +34 -0
  190. package/server/service/chat-session/station-session-guard.ts +10 -2
  191. package/server/service/chat-session-participant/mention-invite.test.ts +125 -0
  192. package/server/service/chat-session-participant/mention-invite.ts +121 -0
  193. package/server/service/chat-session-resolver.ts +276 -15
  194. package/server/service/grounding-sources.test.ts +55 -0
  195. package/server/service/grounding-sources.ts +46 -0
  196. package/server/service/index.ts +21 -0
  197. package/server/service/request-translator.test.ts +45 -0
  198. package/server/service/request-translator.ts +33 -0
  199. package/server/service/station-session-guard.test.ts +12 -5
  200. package/server/service/testing/conversation-scenario.test.ts +163 -0
  201. package/server/service/testing/conversation-script.test.ts +131 -0
  202. package/server/service/testing/conversation-script.ts +288 -0
  203. package/server/service/testing/mode-conformance.ts +122 -0
  204. package/server/tool-registry-boot-report.ts +31 -2
  205. package/test/assistant-chat-call-sites.test.ts +82 -0
  206. package/translations/en.json +46 -3
  207. package/translations/ja.json +46 -3
  208. package/translations/ko.json +46 -3
  209. package/translations/ms.json +46 -3
  210. package/translations/zh.json +46 -3
@@ -43,7 +43,8 @@ import { buildMentionCandidates, buildCatalogCandidates, buildSlashCandidates, b
43
43
  * 뜨지 않는 것이 맞다.
44
44
  */
45
45
  import { chatDefaults } from './chat-defaults.js';
46
- import { isDifferentConversation, resolveConversation } from './assistant-mode.js';
46
+ import { isDifferentConversation, resolveConversation, pickInitialMode } from './assistant-mode.js';
47
+ import { parseProposalOutcomeLine } from './proposal-outcome-line.js';
47
48
  import { availableTriggers } from './chat-triggers.js';
48
49
  function formatFileSize(bytes) {
49
50
  if (!bytes || bytes < 1024)
@@ -91,9 +92,77 @@ const ASSISTANT_CHAT_MUTATION = gql `
91
92
  offeredTools
92
93
  proposals
93
94
  groundingWarnings
95
+ historyFolded
96
+ }
97
+ }
98
+ `;
99
+ /*
100
+ * What this conversation offers on screen, in this person's language.
101
+ *
102
+ * The `/` sentences, the `@` catalog and the two notices are declared with the mode on the server
103
+ * (ADR-0061 decision 7) and translated there, so the panel and the door cannot describe different
104
+ * conversations, and a host does not carry a second copy of the words.
105
+ */
106
+ /*
107
+ * 이 화면에 설 수 있는 대화들 — ADR-0072 A17 ①.
108
+ *
109
+ * 화면은 자기가 무엇을 보여 주는지만 말하고, 그 위에 어느 대화가 서는지는 앱 서버가 답한다.
110
+ */
111
+ const ASSISTANT_MODES_QUERY = gql `
112
+ query AssistantModes($subject: String!) {
113
+ assistantModes(subject: $subject) {
114
+ kind
115
+ label
116
+ isDefault
117
+ }
118
+ }
119
+ `;
120
+ const ASSISTANT_MODE_QUERY = gql `
121
+ query AssistantMode($kind: String!) {
122
+ assistantMode(kind: $kind) {
123
+ kind
124
+ slashTemplates {
125
+ name
126
+ description
127
+ template
128
+ }
129
+ catalogEntries
130
+ proposalChoices
131
+ placeholder
132
+ intro
133
+ examples
134
+ footerNotice
135
+ stagedNotice
136
+ }
137
+ }
138
+ `;
139
+ /*
140
+ * 방에 말하는 문 — 사람에게 하는 말이고 모델을 부르지 않는다(ADR-0070 A15).
141
+ *
142
+ * 이 문이 서기 전에는 화면에서 나가는 모든 말이 어시스턴트를 향했다. 옆 사람에게 한마디 하려면
143
+ * 어시스턴트가 반드시 대답했고, 그 대답이 다시 대화에 남았다.
144
+ */
145
+ /*
146
+ * `@` 가 고를 수 있는 사람들 — 이 도메인의 사용자.
147
+ *
148
+ * 호스트가 `userProvider` 를 주지 않으면 여기서 직접 묻는다. 주지 않는 것이 기본이었고, 그래서 앱 셋
149
+ * 어디에서도 `@이름` 을 **고를 수가 없었다** — 멘션이 사람을 불러들이는 기전(ADR-0071 결정 1)을 세워
150
+ * 놓고 부르는 자리가 없는 상태였다. 이 문은 `ai-assistant` 의 것이고 대화창이 그 문의 화면이다.
151
+ */
152
+ const DOMAIN_USERS_FOR_MENTION_QUERY = gql `
153
+ query DomainUsersForMention($query: String) {
154
+ domainUsersForMention(query: $query) {
155
+ id
156
+ name
157
+ email
94
158
  }
95
159
  }
96
160
  `;
161
+ const SAY_TO_ROOM_MUTATION = gql `
162
+ mutation SayToRoom($sessionId: String!, $content: String!) {
163
+ sayToRoom(sessionId: $sessionId, content: $content)
164
+ }
165
+ `;
97
166
  const CHAT_MESSAGES_QUERY = gql `
98
167
  query ChatMessages($sessionId: String!, $limit: Int, $offset: Int) {
99
168
  chatMessages(sessionId: $sessionId, limit: $limit, offset: $offset) {
@@ -104,6 +173,7 @@ const CHAT_MESSAGES_QUERY = gql `
104
173
  toolUsagesJson
105
174
  groundingWarningsJson
106
175
  createdAt
176
+ redacted
107
177
  creator {
108
178
  name
109
179
  email
@@ -123,6 +193,7 @@ const CHAT_MESSAGE_SUBSCRIPTION = gql `
123
193
  toolUsagesJson
124
194
  groundingWarningsJson
125
195
  createdAt
196
+ redacted
126
197
  creator {
127
198
  name
128
199
  email
@@ -186,22 +257,6 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
186
257
  this.selectedRefids = [];
187
258
  /** 코어 보드 편집 도구 사용 여부. 기본 true. 보드를 고칠 이유가 없는 면에서 false. */
188
259
  this.boardTools = true;
189
- /*
190
- * Which server operation this surface talks to. A closed set of two, named after the operations
191
- * themselves so a reader can grep either way.
192
- *
193
- * boardAIChat board authoring — lives in @things-factory/board-ai, carries the board model,
194
- * returns patches and scene actions
195
- * assistantChat a surface with no document of its own — lives here, runs registered tools only
196
- *
197
- * Default stays `boardAIChat`: every existing consumer is a board surface, and a default that
198
- * changed under them would move their conversation to a door with no board tools behind it.
199
- *
200
- * A host that has no board must pass `assistantChat` **and** `systemPrompt`. Until it does, the
201
- * chat calls a mutation that lives in a package it may not even load — which is how
202
- * operato-figure got `Cannot query field "boardAIChat" on type "Mutation"` (2026-09-11).
203
- */
204
- this.chatEndpoint = 'boardAIChat';
205
260
  /**
206
261
  * 라이브 상태를 다루는 대화면인가 — true 면 **첫 턴에 도구 호출을 강제**한다.
207
262
  *
@@ -209,7 +264,6 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
209
264
  * 그건 도구를 부르지 않고 답한 경우이므로, 조회를 먼저 하게 만들어 원천을 막는다.
210
265
  */
211
266
  this.requireGroundingTools = false;
212
- this.placeholder = '자연어로 명령하세요 (Shift+Enter 줄바꿈, Enter 전송)';
213
267
  this.lines = [];
214
268
  this.input = '';
215
269
  /** 되돌려진 patch id 들 — 한 번 revert 한 patch 는 버튼 비활성 */
@@ -260,6 +314,10 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
260
314
  * textarea 에는 @username 만 보이지만 server 한테는 정확한 userId 전달.
261
315
  * send 시 mutation input.userMentions 로 함께 전송. */
262
316
  this.pickedUserMentions = new Map();
317
+ this.modeViewToken = 0;
318
+ /** 이 subject 에 설 수 있는 대화들 — 기본이 먼저. 하나뿐이면 고르개를 그리지 않는다. */
319
+ this.modeChoices = [];
320
+ this.modeChoicesToken = 0;
263
321
  /*
264
322
  * The `@` and `/` candidates, built once per mode.
265
323
  *
@@ -318,8 +376,35 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
318
376
  this.foldNoticeDismissed = true;
319
377
  this.dispatchEvent(new CustomEvent('assistant-start-new-session', { bubbles: true, composed: true }));
320
378
  };
379
+ /**
380
+ * 실행은 호스트가 한다 — 이 컴포넌트는 도메인(트윈 명령 채널)을 모른다.
381
+ * 확인 대화·명령 전송·결과 기록은 호스트의 몫이고, 여기서는 중복 클릭만 막는다.
382
+ */
383
+ /**
384
+ * 누른 시각 — 「보내는 중」 옆의 경과 시간용.
385
+ *
386
+ * 시간으로 실패를 판정하지 않는다(ADR-0070 A12-a 결정 ②). 아는 사실은 「아직 답을 받지 못했다」
387
+ * 하나이고, 시간이 지났다고 실패로 바꾸면 그것이 지어낸 원인이다.
388
+ */
389
+ this.proposalSentAt = new Map();
321
390
  }
322
391
  static { OxAssistantChat_1 = this; }
392
+ /*
393
+ * ── 왜 이미지만 받나 ──────────────────────────────────────────────────────
394
+ * `.json` · `.txt` · `.csv` 도 받고 있었다. 그 파일들은 `hostContext.attachments` 로 실려 갔고
395
+ * **그것을 읽어 모델에 붙이는 코드가 없었다.** 사람이 CSV 를 붙이고 「이 표 좀 봐줘」라고 하면 화면에
396
+ * 파일 칩이 뜨고 답도 왔다. 그 답은 파일을 본 적이 없고, 오류도 안 났다(2026-09-18 표면 조사).
397
+ *
398
+ * 이미지는 길이 있다 — `assistant-chat-resolver.ts` 가 `hostContext.image` 를 마지막 사람 턴에
399
+ * 붙인다. 그래서 되는 것만 남기고 좁혔다. 못 하는 일을 화면이 권하지 않는다.
400
+ *
401
+ * ── 글 파일을 청하는 제품이 설 때의 모양 (수석 아키텍트, ADR-0071 보탬) ───
402
+ * 이미지와 **같은 자리**(사람 턴)에 붙인다. 크기 상한은 모드가 선언하고, 넘으면 보내기 전에 사실 한
403
+ * 줄로 거절한다 — 조용히 자르지 않는다. 비용은 사용량의 축이다(ADR-0061 결정 6).
404
+ *
405
+ * `attachments` 짐 자체는 그대로 둔다: figure 의 도구가 거기서 이미지를 찾는다
406
+ * (`figure-tools.ts` — `ctx.host.image` 가 없을 때의 갈래).
407
+ */
323
408
  async onAttachFiles(files) {
324
409
  if (!files || files.length === 0)
325
410
  return;
@@ -422,10 +507,11 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
422
507
  The screen still shows nothing either way. There is no sentence to show, and inventing one is
423
508
  what this whole correction removed.
424
509
  */
425
- if (!this.conversation.stagedNoticeKey && !OxAssistantChat_1.warnedMissingStagedNotice) {
510
+ if (!this.conversation.stagedNotice && !OxAssistantChat_1.warnedMissingStagedNotice) {
426
511
  OxAssistantChat_1.warnedMissingStagedNotice = true;
427
- console.warn('[assistant-chat] a host reported a proposal staged but registered no `stagedNoticeKey`, ' +
428
- 'so the card can say nothing. Pass one to `registerChatDefaults` from the host.');
512
+ console.warn('[assistant-chat] a host reported a proposal staged but declared no staged notice, so the card can ' +
513
+ 'say nothing. Declare `stagedNoticeKey` on the mode (the server translates it), or pass one to ' +
514
+ '`registerChatDefaults` from a host with no mode.');
429
515
  }
430
516
  this.stagedProposals = new Set(this.stagedProposals).add(this.proposalKey(proposal));
431
517
  }
@@ -437,6 +523,9 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
437
523
  get _myEmail() {
438
524
  return auth.credential?.email;
439
525
  }
526
+ get _myUserId() {
527
+ return auth.credential?.id;
528
+ }
440
529
  /*
441
530
  * ── What this conversation is, resolved ──────────────────────────────────────────────
442
531
  *
@@ -446,11 +535,113 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
446
535
  */
447
536
  get conversation() {
448
537
  return resolveConversation(this.mode, {
449
- systemPrompt: this.systemPrompt,
450
- toolCategories: this.toolCategories,
451
538
  hostContext: this.hostContext,
452
- chatEndpoint: this.chatEndpoint
453
- }, chatDefaults);
539
+ chatEndpoint: this.chatEndpoint,
540
+ /* A host with no mode still registers its wording as keys; it is translated here. */
541
+ footerNotice: chatDefaults.footerNoticeKey ? i18next.t(chatDefaults.footerNoticeKey) : undefined,
542
+ stagedNotice: chatDefaults.stagedNoticeKey ? i18next.t(chatDefaults.stagedNoticeKey) : undefined
543
+ }, chatDefaults, this.modeView);
544
+ }
545
+ /**
546
+ * 이 화면에 설 수 있는 대화를 서버에 묻는다.
547
+ *
548
+ * 화면이 종류 목록을 손에 들고 있으면, 대화를 하나 더 세운 날 그 화면만 모른 채로 남는다. 목록은
549
+ * 앱 서버의 선언에서 나온다(ADR-0072 A17 ①).
550
+ */
551
+ async loadModeChoices() {
552
+ const subject = this.subject;
553
+ if (!subject) {
554
+ this.modeChoices = [];
555
+ return;
556
+ }
557
+ const token = ++this.modeChoicesToken;
558
+ try {
559
+ const result = await client.query({
560
+ query: ASSISTANT_MODES_QUERY,
561
+ variables: { subject },
562
+ fetchPolicy: 'cache-first'
563
+ });
564
+ if (token !== this.modeChoicesToken)
565
+ return;
566
+ this.modeChoices = result.data?.assistantModes ?? [];
567
+ }
568
+ catch {
569
+ /*
570
+ * 못 물어봤다고 화면을 막지 않는다 — host 가 준 대화는 그대로 산다. 고르개만 안 나온다.
571
+ * 여기서 오류 문구를 띄우면 고를 것이 하나뿐인 화면에서도 빨간 줄이 뜬다.
572
+ */
573
+ if (token !== this.modeChoicesToken)
574
+ return;
575
+ this.modeChoices = [];
576
+ }
577
+ }
578
+ /**
579
+ * 사람이 다른 대화를 골랐다.
580
+ *
581
+ * 고른 것은 **이 subject 종류에 대해** 기억한다 — 보드를 열 때마다 저작 대화로 돌아가면, 현장을
582
+ * 물으려던 사람은 화면을 열 때마다 같은 손질을 다시 해야 한다. 기억은 이 브라우저에만 남는다
583
+ * (서버에 칸을 만들지 않는다 — A17 ①). 세션 자체는 자기가 어느 대화였는지 이미 안다.
584
+ */
585
+ onModePick(kind) {
586
+ if (!this.mode || kind === this.mode.kind)
587
+ return;
588
+ try {
589
+ if (this.subject)
590
+ localStorage.setItem(`assistant-mode:${this.subject}`, kind);
591
+ }
592
+ catch {
593
+ /* 저장이 막힌 브라우저에서도 고르기 자체는 된다 — 다음에 다시 고르면 될 뿐이다. */
594
+ }
595
+ this.askHostForMode(kind);
596
+ }
597
+ /**
598
+ * **고르는 것은 청하는 일이다** — `mode` 를 여기서 바꾸지 않는다.
599
+ *
600
+ * host 는 렌더마다 `mode` 를 다시 내려 준다. 패널이 자기 손으로 고쳐 두면 다음 렌더가 그것을 덮고,
601
+ * 더 나쁜 것은 host 가 **자기가 무엇을 열었는지 모르는 채로 남는다**는 것이다. host 는 대화의 세션을
602
+ * 대상별로 들고 있으므로, 대화가 바뀐 것을 모르면 앞 대화의 세션을 그대로 넘긴다 — 그러면 새 말이 앞
603
+ * 대화에 붙는다(2026-09-18 Figure 레인이 :3300 에서 본 것이 이것이다).
604
+ *
605
+ * 그래서 주인은 하나다: host 가 `mode` 를 갖고, 패널은 「이것으로 바꿔 달라」고 말한다. 기억은 패널이
606
+ * 진다(브라우저마다 다른 값이라 host 가 질 것이 아니다) — 기억한 것을 되살릴 때도 같은 청으로 나간다.
607
+ */
608
+ askHostForMode(kind) {
609
+ this.dispatchEvent(new CustomEvent('assistant-mode-change', { detail: { kind, subject: this.subject }, bubbles: true, composed: true }));
610
+ }
611
+ /** 이 subject 에서 지난번에 고른 대화 — 없으면 undefined. */
612
+ rememberedMode(subject) {
613
+ try {
614
+ return localStorage.getItem(`assistant-mode:${subject}`) ?? undefined;
615
+ }
616
+ catch {
617
+ return undefined;
618
+ }
619
+ }
620
+ async loadModeView() {
621
+ const mode = this.mode;
622
+ if (!mode?.kind) {
623
+ this.modeView = undefined;
624
+ return;
625
+ }
626
+ const token = ++this.modeViewToken;
627
+ try {
628
+ const result = await client.query({ query: ASSISTANT_MODE_QUERY, variables: { kind: mode.kind }, fetchPolicy: 'cache-first' });
629
+ /* A late answer for a conversation the person has already left is dropped. */
630
+ if (token !== this.modeViewToken)
631
+ return;
632
+ this.modeView = result.data?.assistantMode;
633
+ this.rebuildMentionCaches();
634
+ }
635
+ catch (error) {
636
+ if (token !== this.modeViewToken)
637
+ return;
638
+ this.modeView = undefined;
639
+ /*
640
+ * A kind this server does not have is a mismatched deployment, and the person should read it
641
+ * rather than watch an empty `/` list.
642
+ */
643
+ this.errorMessage = error instanceof Error ? error.message : String(error);
644
+ }
454
645
  }
455
646
  rebuildMentionCaches() {
456
647
  this.cachedCatalogCandidates = buildCatalogCandidates(this.conversation.catalogEntries);
@@ -484,6 +675,52 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
484
675
  }
485
676
 
486
677
  /* ── C4 Roster (participants + presence) ───────────── */
678
+ /* 이 대화의 주어 — 같은 화면 위에 두 대화가 설 때만 나온다(ADR-0072 A17 ①).
679
+ 지금 대화가 제목 굵기로 서고, 바꿀 자리가 그 옆에 붙는다. 세션 탭과 같은 무게로 그리지 않는다
680
+ (UX 레인, 2026-09-18) — 한쪽은 화제를 바꾸고 한쪽은 실타래를 바꾼다. */
681
+ .mode-subject {
682
+ display: flex;
683
+ align-items: baseline;
684
+ gap: 8px;
685
+ padding: 6px 12px;
686
+ border-bottom: 1px solid var(--md-sys-color-outline-variant, #e2e8f0);
687
+ }
688
+ .mode-now {
689
+ /* 고른 상태의 색은 세션 탭과 같은 계열이다 — 한 패널 안에서 「골랐다」가 두 색으로 나오면 읽는
690
+ 사람은 두 색이 서로 다른 뜻인 줄 안다.
691
+
692
+ 12px 이었다가 한 단 내렸다. 도크 제목(figure 의 .scope-title 이 12.5px / 650)과 0.5px ·
693
+ 굵기 50 차이는 눈에 닿지 않아서, 거의 같은 제목 줄이 둘 포개졌다. 도크 제목은 그 도크 전체를
694
+ 거느리고 이 줄은 그 안 대화 하나의 성질이다 — 11px 이면 이 패널의 다른 조작부와 같은 단이고,
695
+ 「이것이 주어다」는 색이 계속 진다(UX 레인, 2026-09-18). */
696
+ color: var(--primary-color, #007f87);
697
+ font-size: 11px;
698
+ font-weight: 600;
699
+ }
700
+ .mode-switch,
701
+ .mode-select {
702
+ appearance: none;
703
+ background: transparent;
704
+ border: 1px solid var(--md-sys-color-outline-variant, #cbd5e1);
705
+ border-radius: 999px;
706
+ color: var(--md-sys-color-on-surface-variant, #475569);
707
+ cursor: pointer;
708
+ font: inherit;
709
+ font-size: 11px;
710
+ padding: 2px 10px;
711
+ white-space: nowrap;
712
+ }
713
+ .mode-switch:hover:not([disabled]) {
714
+ background: color-mix(in srgb, var(--primary-color, #007f87) 7%, transparent);
715
+ color: var(--primary-color, #007f87);
716
+ }
717
+ /* 답하는 동안에도 「내가 지금 무엇에 대해 말하고 있나」는 또렷해야 한다 — 흐려지는 것은 바꿀
718
+ 자리뿐이다. 지금 대화까지 흐리면 그 한 줄이 가장 안 보인다. */
719
+ .mode-subject [disabled] {
720
+ cursor: default;
721
+ opacity: 0.5;
722
+ }
723
+
487
724
  .roster {
488
725
  display: flex;
489
726
  align-items: center;
@@ -1034,6 +1271,29 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
1034
1271
  overflow: visible;
1035
1272
  }
1036
1273
 
1274
+ /* 값이 안 온 줄 — ADR-0073 판정 1.
1275
+ 말풍선의 자리와 「AI」 딱지는 지킨다 — 그 줄은 어시스턴트의 답이 맞고, 읽는 사람이 못 지나간
1276
+ 것이다. 점선 테두리와 흐린 색이 「이것은 그가 쓴 문장이 아니다」를 말한다.
1277
+
1278
+ 기울임은 쓰지 않는다. 이 앱의 글꼴 묶음에 한글 이탤릭 자소가 없어 브라우저가 합성으로 기울이고,
1279
+ 획 균형이 무너져 작은 글자가 먼저 안 읽힌다. UX 레인이 :4000 에서 재 보았다 — 「권한」의 진행
1280
+ 폭이 normal·italic 둘 다 27.6875px 로 같다(2026-09-18). */
1281
+ .msg.redacted {
1282
+ background: transparent;
1283
+ border: 1px dashed var(--md-sys-color-outline-variant, #cbd5e1);
1284
+ color: var(--md-sys-color-outline, #94a3b8);
1285
+ }
1286
+ .redacted-body {
1287
+ align-items: center;
1288
+ display: flex;
1289
+ gap: 6px;
1290
+ }
1291
+ .redacted-body md-icon {
1292
+ /* md-icon 은 자기 크기를 이 변수로 잡는다 — width/height 만 주면 아무 일도 안 일어난다. */
1293
+ --md-icon-size: 14px;
1294
+ font-size: 14px;
1295
+ }
1296
+
1037
1297
  .msg.pending {
1038
1298
  opacity: 0.5;
1039
1299
  }
@@ -1894,6 +2154,20 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
1894
2154
  cursor: not-allowed;
1895
2155
  }
1896
2156
 
2157
+ /* 보내기 전에 보이는 초대 안내 — 누르기 전에 알아야 하는 사실이다. */
2158
+ .invite-notice {
2159
+ display: flex;
2160
+ align-items: center;
2161
+ gap: 6px;
2162
+ margin: 0 2px 4px;
2163
+ color: var(--md-sys-color-on-surface-variant, #475569);
2164
+ font-size: 11.5px;
2165
+ }
2166
+
2167
+ .invite-notice md-icon {
2168
+ --md-icon-size: 15px;
2169
+ }
2170
+
1897
2171
  /* ── Send button — ChatGPT 스타일 원형 ↑ (.input-row 안의 button 만) ─── */
1898
2172
  .input-row > button {
1899
2173
  width: 32px;
@@ -1915,6 +2189,15 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
1915
2189
  align-self: flex-end;
1916
2190
  margin-bottom: 2px;
1917
2191
  }
2192
+ /*
2193
+ 방에 말하는 자리는 **두 번째 행동**이다 — 이 화면의 첫 행동은 어시스턴트에게 묻는 것이다.
2194
+ 같은 무게로 두면 무엇이 기본인지 화면이 말하지 않게 된다(ADR-0070 A15 의 자리 둘).
2195
+ */
2196
+ .input-row > button.say-to-room {
2197
+ background: var(--md-sys-color-surface-container-highest, #e2e8f0);
2198
+ color: var(--md-sys-color-on-surface-variant, #475569);
2199
+ }
2200
+
1918
2201
  .input-row > button:disabled {
1919
2202
  background: var(--md-sys-color-surface-container-highest, #e2e8f0);
1920
2203
  color: var(--md-sys-color-outline, #94a3b8);
@@ -1949,6 +2232,25 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
1949
2232
  // 첫 마운트 시 sessionId 가 이미 set 돼있어도 loadHistory 는 첫 render 후 updated()
1950
2233
  // 가 처리 — 단일 진입점으로 일관 (이전엔 connectedCallback 과 updated 양쪽이 호출 →
1951
2234
  // 동시 fetch race 발생).
2235
+ /* 모드가 이미 붙어 있으면 무엇을 주는지 먼저 묻는다 — 바뀔 때는 updated 가 다시 묻는다. */
2236
+ if (this.mode?.kind)
2237
+ this.loadModeView();
2238
+ if (this.subject)
2239
+ this.onSubjectChanged();
2240
+ }
2241
+ /**
2242
+ * 화면이 보여 주는 것의 종류가 바뀌었다 — 설 수 있는 대화를 다시 묻고, 지난번 고른 것을 되살린다.
2243
+ *
2244
+ * 되살리는 것은 **고른 대화**이지 세션이 아니다. 세션은 자기가 어느 대화였는지 이미 알고, 다른
2245
+ * 대화로 가면 그때 새로 난다(ADR-0072 A17 ①).
2246
+ */
2247
+ async onSubjectChanged() {
2248
+ await this.loadModeChoices();
2249
+ if (this.modeChoices.length < 2 || !this.subject || !this.mode)
2250
+ return;
2251
+ const kind = pickInitialMode(this.mode.kind, this.modeChoices, this.rememberedMode(this.subject));
2252
+ if (kind && kind !== this.mode.kind)
2253
+ this.askHostForMode(kind);
1952
2254
  }
1953
2255
  updated(changed) {
1954
2256
  /*
@@ -1974,8 +2276,14 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
1974
2276
  * The host still owns `sessionId`; it hears `assistant-mode-changed` and decides whether
1975
2277
  * this subject gets a stored session of its own.
1976
2278
  */
2279
+ /* 보는 것의 종류가 바뀌면 설 수 있는 대화도 달라진다 — 보드에서 현장으로 넘어간 자리. */
2280
+ if (changed.has('subject'))
2281
+ this.onSubjectChanged();
1977
2282
  if (changed.has('mode') && isDifferentConversation(changed.get('mode'), this.mode)) {
2283
+ /* What this conversation offers is the new mode's; ask before drawing the panel again. */
2284
+ this.modeView = undefined;
1978
2285
  this.rebuildMentionCaches();
2286
+ this.loadModeView();
1979
2287
  this.lines = [];
1980
2288
  this.pickedMentions.clear();
1981
2289
  this.pickedUserMentions.clear();
@@ -2024,6 +2332,10 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
2024
2332
  disconnectedCallback() {
2025
2333
  this._stopPresence();
2026
2334
  this._stopMessageSubscription();
2335
+ if (this.elapsedTimer) {
2336
+ clearInterval(this.elapsedTimer);
2337
+ this.elapsedTimer = undefined;
2338
+ }
2027
2339
  super.disconnectedCallback();
2028
2340
  }
2029
2341
  // ── C4 presence/roster ─────────────────────────────────────────────────────
@@ -2160,6 +2472,7 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
2160
2472
  ${this.toastMessage
2161
2473
  ? html `<div class="toast show">${this.toastMessage}</div>`
2162
2474
  : nothing}
2475
+ ${this.renderModeSubject()}
2163
2476
  ${this.renderSessionTabs()}
2164
2477
  ${this.renderRoster()}
2165
2478
  <div class="messages" @click=${this.onBubbleClick}>
@@ -2177,8 +2490,12 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
2177
2490
  const prevSameSender = !!prev && prev.role === 'user' && prev.senderEmail === line.senderEmail;
2178
2491
  const showSenderLabel = isOther && !prevSameSender;
2179
2492
  const content = (line.content ?? '').trim();
2180
- const isMarkdown = line.role !== 'system' && content.length > 0;
2181
- const showActions = line.role !== 'system' && !line.pending && content.length > 0;
2493
+ /*
2494
+ * 가려진 줄은 어시스턴트의 말이 아니다 — 마크다운으로 그리지 않고, 복사·재실행 같은 손잡이도
2495
+ * 달지 않는다(ADR-0073 판정 1). 그 손잡이들은 있지도 않은 답을 다룬다.
2496
+ */
2497
+ const isMarkdown = line.role !== 'system' && content.length > 0 && !line.redacted;
2498
+ const showActions = line.role !== 'system' && !line.pending && content.length > 0 && !line.redacted;
2182
2499
  return html `
2183
2500
  ${showLabel
2184
2501
  ? html `<div class="msg-label">${i18next.t('ai-assistant.label.ai')}</div>`
@@ -2189,19 +2506,21 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
2189
2506
  <div
2190
2507
  class="msg ${line.role} ${isOther ? 'other' : ''} ${line.pending ? 'pending' : ''} ${line.systemOpen
2191
2508
  ? 'open'
2192
- : ''}">
2509
+ : ''} ${line.redacted ? 'redacted' : ''}">
2193
2510
  ${line.pending
2194
2511
  ? html `<span class="typing-dots"><span></span><span></span><span></span></span>`
2195
- : isMarkdown
2196
- ? html `<div class="md-body">${unsafeHTML(renderMarkdown(content))}</div>`
2197
- : line.role === 'system'
2198
- ? html `<span
2512
+ : line.redacted
2513
+ ? html `<div class="redacted-body"><md-icon>lock</md-icon><span>${content}</span></div>`
2514
+ : isMarkdown
2515
+ ? html `<div class="md-body">${unsafeHTML(renderMarkdown(content))}</div>`
2516
+ : line.role === 'system'
2517
+ ? html `<span
2199
2518
  class="sys-text"
2200
2519
  title=${i18next.t('ai-assistant.text.toggle-system-note', { defaultValue: 'click to expand' })}
2201
2520
  @click=${() => this.toggleSystemNote(idx)}
2202
2521
  >${content}</span
2203
2522
  >`
2204
- : content}
2523
+ : content}
2205
2524
  ${line.attachments && line.attachments.length > 0
2206
2525
  ? html `
2207
2526
  <div class="msg-attachments">
@@ -2290,7 +2609,7 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
2290
2609
  id="chat-file-input"
2291
2610
  type="file"
2292
2611
  multiple
2293
- accept="image/*,.json,.txt,.csv"
2612
+ accept="image/*"
2294
2613
  style="display: none"
2295
2614
  @change=${(e) => {
2296
2615
  const input = e.target;
@@ -2304,7 +2623,7 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
2304
2623
  type="button"
2305
2624
  class="action"
2306
2625
  @click=${() => this.renderRoot.querySelector('#chat-file-input')?.click()}
2307
- title=${i18next.t('ai-assistant.tooltip.attach-file', { defaultValue: 'Attach images or files (drag & drop or paste supported)' })}>
2626
+ title=${i18next.t('ai-assistant.tooltip.attach-file', { defaultValue: 'attach an image (drag & drop or paste supported)' })}>
2308
2627
  <md-icon>attach_file</md-icon>
2309
2628
  ${i18next.t('ai-assistant.button.attach', { defaultValue: 'Attach' })}
2310
2629
  </button>
@@ -2348,6 +2667,7 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
2348
2667
  </div>
2349
2668
  `
2350
2669
  : nothing}
2670
+ ${this.renderInviteNotice()}
2351
2671
  <div class="input-row">
2352
2672
  <div class="textarea-wrap">
2353
2673
  <textarea
@@ -2361,7 +2681,9 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
2361
2681
  }}
2362
2682
  ?disabled=${this.busy}
2363
2683
  rows="1"
2364
- placeholder=${this.placeholder ?? i18next.t('ai-assistant.text.input-placeholder')}></textarea>
2684
+ placeholder=${this.conversation.placeholder ??
2685
+ this.placeholder ??
2686
+ i18next.t('ai-assistant.text.input-placeholder')}></textarea>
2365
2687
  ${this.mentionOpen
2366
2688
  ? html `
2367
2689
  <ox-mention-popup
@@ -2381,6 +2703,27 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
2381
2703
  `
2382
2704
  : nothing}
2383
2705
  </div>
2706
+ ${ /*
2707
+ 두 자리다 — 어시스턴트에게 묻는 자리와 **방에 말하는 자리**. 누른 자리가 그 말의 대상을
2708
+ 정하고, 서버는 어느 문이 불렸는지로 그 사실을 저장한다(ADR-0070 A15 결정 ①).
2709
+
2710
+ **방에 사람이 있을 때만 보인다.** 혼자 쓰는 대화에서 「방에 말하기」는 아무에게도 하지 않는
2711
+ 말이고, 누를 일이 없는 단추는 무엇이 기본인지 흐린다. 조건은 참여자 목록과 같다(둘 이상) —
2712
+ 둘째 사람은 멘션으로 들어오고, 그 순간 이 자리도 함께 선다.
2713
+ */''}
2714
+ ${this.sessionId && this.participants.length >= 2
2715
+ ? html `
2716
+ <button
2717
+ class="say-to-room"
2718
+ ?disabled=${this.busy || !this.input.trim()}
2719
+ @click=${() => this.sayToRoom()}
2720
+ title=${i18next.t('ai-assistant.text.say-to-room-tooltip', {
2721
+ defaultValue: 'say this to the people here — the assistant does not answer'
2722
+ })}>
2723
+ <md-icon>forum</md-icon>
2724
+ </button>
2725
+ `
2726
+ : nothing}
2384
2727
  <button
2385
2728
  ?disabled=${this.busy || (!this.input.trim() && this.attachments.length === 0)}
2386
2729
  @click=${this.send}
@@ -2393,6 +2736,82 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
2393
2736
  </div>
2394
2737
  `;
2395
2738
  }
2739
+ /**
2740
+ * 방에 말한다 — 어시스턴트는 답하지 않는다.
2741
+ *
2742
+ * 저장되는 대화가 있을 때만 할 수 있다. 세션이 없는 즉석 질문에는 「방」이 없다 — 그 자리에서
2743
+ * 한 말은 누구에게도 남지 않는다.
2744
+ */
2745
+ async sayToRoom() {
2746
+ const body = this.input.trim();
2747
+ if (!body || this.busy)
2748
+ return;
2749
+ if (!this.sessionId) {
2750
+ /* 말할 방이 없다는 사실을 말한다 — 조용히 버리면 사람은 말했다고 믿는다. */
2751
+ this.errorMessage = i18next.t('ai-assistant.text.no-room-yet', {
2752
+ defaultValue: 'this conversation is not saved yet, so there is nobody else in it to talk to'
2753
+ });
2754
+ return;
2755
+ }
2756
+ const localId = `local-${++this._localSeq}-r`;
2757
+ this.lines = [...this.lines, { role: 'user', content: body, _localId: localId, senderEmail: this._myEmail }];
2758
+ this.input = '';
2759
+ this.busy = true;
2760
+ try {
2761
+ const result = await client.mutate({
2762
+ mutation: SAY_TO_ROOM_MUTATION,
2763
+ variables: { sessionId: this.sessionId, content: body }
2764
+ });
2765
+ /* 방송 에코와 겹치지 않게 서버 id 로 맞춘다 — 보낸 말이 두 줄로 보이지 않게. */
2766
+ this._reconcileSentLine(localId, result.data?.sayToRoom ?? undefined, {});
2767
+ }
2768
+ catch (error) {
2769
+ this.lines = this.lines.filter(line => line._localId !== localId);
2770
+ this.input = body;
2771
+ this.errorMessage = error instanceof Error ? error.message : String(error);
2772
+ }
2773
+ finally {
2774
+ this.busy = false;
2775
+ }
2776
+ }
2777
+ /**
2778
+ * 보내기 전에 말한다 — 「이 사람은 이 대화에 들어옵니다」(ADR-0071 결정 1 ④).
2779
+ *
2780
+ * 멘션은 사람을 불러들인다. 누른 뒤에 알면 이미 들어와 있고, 협의의 공개 범위는 되돌리기 어려운
2781
+ * 종류의 일이다. 그래서 **아직 보내지 않은 상태에서** 누가 들어오게 되는지 보인다.
2782
+ *
2783
+ * 초대할 수 없는 자리(보기 권한 · 아직 참여자가 아님)라면 그 사실을 말한다 — 눌렀는데 아무 일도
2784
+ * 일어나지 않는 것이 가장 나쁘다.
2785
+ */
2786
+ renderInviteNotice() {
2787
+ if (!this.sessionId)
2788
+ return nothing;
2789
+ const here = new Set(this.participants.map(p => p.user?.id).filter(Boolean));
2790
+ const incoming = [...this.pickedUserMentions.entries()]
2791
+ .filter(([token, userId]) => this.input.includes(`@${token}`) && !here.has(userId))
2792
+ .map(([token]) => token);
2793
+ if (incoming.length === 0)
2794
+ return nothing;
2795
+ const myRole = this.participants.find(p => p.user?.id && p.user.id === this._myUserId)?.role;
2796
+ const mayInvite = myRole === 'owner' || myRole === 'member';
2797
+ const names = incoming.map(token => `@${token}`).join(', ');
2798
+ return html `
2799
+ <div class="invite-notice">
2800
+ <md-icon>person_add</md-icon>
2801
+ <span>
2802
+ ${mayInvite
2803
+ ? i18next.t('ai-assistant.text.will-be-invited', {
2804
+ names,
2805
+ defaultValue: '{names} will join this conversation when you send'
2806
+ })
2807
+ : i18next.t('ai-assistant.text.cannot-invite', {
2808
+ names,
2809
+ defaultValue: '{names} will not join — only the people already in this conversation can bring someone in'
2810
+ })}
2811
+ </span>
2812
+ </div>
2813
+ `;
2814
+ }
2396
2815
  onKeyDown(e) {
2397
2816
  // Mention popup 활성 시 — 화살표/Enter/Tab/Esc 가로채서 popup 네비게이션
2398
2817
  if (this.mentionOpen) {
@@ -2512,14 +2931,32 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
2512
2931
  // 매칭된 후보 outline 만 갱신 — 카메라/선택 변경은 commit (Enter/click) 시점에만.
2513
2932
  this.highlightMatchedCandidates();
2514
2933
  }
2934
+ /**
2935
+ * 호스트가 목록을 주지 않을 때 이 도메인의 사용자를 직접 묻는다.
2936
+ *
2937
+ * 실패는 빈 목록이다 — 멘션을 못 고르는 것이지 대화가 막힐 일은 아니다.
2938
+ */
2939
+ async fetchDomainUsers(query) {
2940
+ try {
2941
+ const result = await client.query({
2942
+ query: DOMAIN_USERS_FOR_MENTION_QUERY,
2943
+ variables: { query },
2944
+ fetchPolicy: 'network-only'
2945
+ });
2946
+ return result.data?.domainUsersForMention ?? [];
2947
+ }
2948
+ catch {
2949
+ return [];
2950
+ }
2951
+ }
2515
2952
  /** `@` query 에 대한 userProvider 비동기 호출 — 응답 도착 시 popup 결과 갱신.
2516
2953
  * race 방지: token 으로 최신 호출 식별 (늦게 도착한 응답 무시). */
2517
2954
  async refreshUserCandidatesAsync(query, hashPos) {
2518
- if (!this.userProvider)
2519
- return;
2520
2955
  const token = ++this.userFetchToken;
2521
2956
  try {
2522
- const users = await Promise.resolve(this.userProvider(query));
2957
+ const users = this.userProvider
2958
+ ? await Promise.resolve(this.userProvider(query))
2959
+ : await this.fetchDomainUsers(query);
2523
2960
  if (token !== this.userFetchToken)
2524
2961
  return; // 더 최신 호출이 있음
2525
2962
  // popup 이 닫혔거나 trigger / hashPos 가 바뀌면 무시
@@ -2655,6 +3092,12 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
2655
3092
  * 읽었고, 그러면 호스트 값을 한쪽만 반영하는 상태가 만들어질 수 있었다.
2656
3093
  */
2657
3094
  get exampleGroups() {
3095
+ /*
3096
+ * 대화가 자기 예시를 가지면 그것이 먼저다 — 자리표·`/` 와 같은 차례(ADR-0061 결정 7). host 속성은
3097
+ * 대화를 모르므로, 한 화면에 대화가 둘 서면 한쪽에 맞는 글이 다른 쪽에도 뜬다.
3098
+ */
3099
+ if (this.modeView?.examples?.length)
3100
+ return this.modeView.examples;
2658
3101
  if (this.examples?.length)
2659
3102
  return this.examples;
2660
3103
  return OxAssistantChat_1.EXAMPLE_GROUPS.map(group => ({
@@ -2695,6 +3138,59 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
2695
3138
  ]; }
2696
3139
  /** 보드의 세션 탭 — 다중 세션 활성화 시 패널 상단. host 가 sessions 비워두면 표시 X.
2697
3140
  * 레이블은 session.name 우선, 없으면 fallback "세션 N". */
3141
+ /**
3142
+ * 이 대화의 **주어** — 같은 화면 위에 두 대화가 설 때만 나온다(ADR-0072 A17 ①).
3143
+ *
3144
+ * 하나뿐이면 아무것도 그리지 않는다. 고를 것이 없는 고르개는 자리만 차지하고, 사람에게 「무언가
3145
+ * 고를 것이 있다」는 잘못된 신호를 준다.
3146
+ *
3147
+ * ── 왜 탭 줄이 아닌가 (UX 레인, 2026-09-18) ───────────────────────────────
3148
+ * 처음에는 칩 줄에 `role="tablist"` 를 달았다. 바로 아래가 세션 탭이고 그쪽도 tablist 라서, 화면
3149
+ * 낭독기로 들으면 「탭 목록, 대화」 다음에 「탭 목록, Conversation history」 가 이어졌다 — 고르는
3150
+ * 축이 둘인데 둘 다 「탭」이라고 말한다. 게다가 ARIA 탭은 좌우 화살표 이동과 `tabpanel` 이 함께
3151
+ * 있어야 성립하고, 둘 다 없으면 낭독기는 「2 중 1번째 탭」이라 말하고 화살표는 아무 일도 안 한다.
3152
+ *
3153
+ * 무게도 다르다. 세션은 「어느 지난 대화냐」이고 모드는 「이 대화가 무엇에 대한 것이냐」이다. 같은
3154
+ * 무게로 그리면 어느 쪽이 화제를 바꾸고 어느 쪽이 실타래를 바꾸는지 구별되지 않는다. 그래서 지금
3155
+ * 대화가 제목 굵기로 서고, 바꿀 자리는 그 옆에 붙는다.
3156
+ *
3157
+ * ── 왜 도크 제목 줄로 안 올리나 (UX 레인 판정, 2026-09-18) ────────────────
3158
+ * 도크 제목은 「지금 어디에 있나」(이 도형 · 이 현장 · 이 스테이션 화면)이고 이 줄은 「이 대화가
3159
+ * 무엇에 대한 것이냐」이다. 대화의 주어는 대화 안에 있다. 그리고 세 도크가 각자 그리면 세 벌이 되고
3160
+ * 그 세 벌은 갈린다 — `modeChoices` 를 아는 것도 여기다. 올리면 목록과 고른 것이 세 자리로 나갔다
3161
+ * 돌아온다.
3162
+ */
3163
+ renderModeSubject() {
3164
+ if (this.modeChoices.length < 2)
3165
+ return nothing;
3166
+ const current = this.modeChoices.find(choice => choice.kind === this.mode?.kind);
3167
+ const others = this.modeChoices.filter(choice => choice.kind !== this.mode?.kind);
3168
+ return html `
3169
+ <div class="mode-subject">
3170
+ <span class="mode-now">${current?.label ?? this.mode?.kind ?? ''}</span>
3171
+ ${others.length === 1
3172
+ ? html `
3173
+ <button
3174
+ class="mode-switch"
3175
+ title=${i18next.t('ai-assistant.text.switch-conversation', { name: others[0].label })}
3176
+ aria-label=${i18next.t('ai-assistant.text.switch-conversation', { name: others[0].label })}
3177
+ ?disabled=${this.busy}
3178
+ @click=${() => this.onModePick(others[0].kind)}>
3179
+ ${others[0].label}
3180
+ </button>
3181
+ `
3182
+ : html `
3183
+ <select
3184
+ class="mode-select"
3185
+ aria-label=${i18next.t('ai-assistant.label.conversation')}
3186
+ ?disabled=${this.busy}
3187
+ @change=${(event) => this.onModePick(event.target.value)}>
3188
+ ${this.modeChoices.map(choice => html `<option value=${choice.kind} ?selected=${choice.kind === this.mode?.kind}>${choice.label}</option>`)}
3189
+ </select>
3190
+ `}
3191
+ </div>
3192
+ `;
3193
+ }
2698
3194
  renderSessionTabs() {
2699
3195
  if (!this.sessions || this.sessions.length === 0)
2700
3196
  return nothing;
@@ -2742,8 +3238,13 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
2742
3238
  <div class="empty">
2743
3239
  <div class="header">
2744
3240
  <md-icon class="icon">auto_awesome</md-icon>
2745
- <div class="title">${this.intro?.title ?? i18next.t('ai-assistant.text.empty-title')}</div>
2746
- <div class="subtitle">${this.intro?.subtitle ?? i18next.t('ai-assistant.text.empty-subtitle')}</div>
3241
+ <!-- 대화가 자기 글을 가지면 그것이 먼저다 — host 속성은 대화를 모른다. -->
3242
+ <div class="title">
3243
+ ${this.modeView?.intro?.title ?? this.intro?.title ?? i18next.t('ai-assistant.text.empty-title')}
3244
+ </div>
3245
+ <div class="subtitle">
3246
+ ${this.modeView?.intro?.subtitle ?? this.intro?.subtitle ?? i18next.t('ai-assistant.text.empty-subtitle')}
3247
+ </div>
2747
3248
  </div>
2748
3249
 
2749
3250
  ${this.triggerChips.length > 0
@@ -2780,8 +3281,8 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
2780
3281
  <span class="badge">${i18next.t('ai-assistant.label.korean-supported')}</span>
2781
3282
  <span class="badge">${i18next.t('ai-assistant.label.multi-command')}</span>
2782
3283
  <span class="badge">${i18next.t('ai-assistant.label.review-able')}</span>
2783
- ${this.conversation.footerNoticeKey
2784
- ? html `<br />${i18next.t(this.conversation.footerNoticeKey)}`
3284
+ ${this.conversation.footerNotice
3285
+ ? html `<br />${this.conversation.footerNotice}`
2785
3286
  : ''}
2786
3287
  </div>
2787
3288
  </div>
@@ -2942,7 +3443,8 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
2942
3443
  class="run"
2943
3444
  ?disabled=${sent}
2944
3445
  @click=${() => this.executeProposal(p, key)}>
2945
- ${sent ? i18next.t('ai-assistant.text.proposal-sent', { defaultValue: 'execution requested' })
3446
+ ${sent
3447
+ ? this.proposalStateText(key)
2946
3448
  : i18next.t('ai-assistant.button.run-proposal', { defaultValue: 'run' })}
2947
3449
  </button>
2948
3450
  ${ /*
@@ -2951,15 +3453,15 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
2951
3453
  This badge used to read "there are chips" as "the model is in the 3D viewer" and
2952
3454
  say so, in a component that plant and twin also use.
2953
3455
  */''}
2954
- ${this.stagedProposals.has(key) && this.conversation.stagedNoticeKey ? html `
3456
+ ${this.stagedProposals.has(key) && this.conversation.stagedNotice ? html `
2955
3457
  <span class="staged-badge">
2956
3458
  <md-icon>check_circle</md-icon>
2957
- <span>${i18next.t(this.conversation.stagedNoticeKey)}</span>
3459
+ <span>${this.conversation.stagedNotice}</span>
2958
3460
  </span>
2959
3461
  ` : nothing}
2960
3462
  </div>
2961
3463
  ${rawChoices.length ? html `
2962
- <div class="proposal-choices" role="group" aria-label="대화 선택지">
3464
+ <div class="proposal-choices" role="group" aria-label=${i18next.t('ai-assistant.text.proposal-choices', { defaultValue: 'follow-up choices' })}>
2963
3465
  ${rawChoices.map((c) => html `
2964
3466
  <button
2965
3467
  class="choice-chip ${c.primary ? 'primary' : ''}"
@@ -2976,6 +3478,43 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
2976
3478
  </div>
2977
3479
  `;
2978
3480
  }
3481
+ /**
3482
+ * 눌린 카드가 말하는 것 — **호스트가 한 일**이고, 아직 모르면 모른다고 말한다.
3483
+ *
3484
+ * 예전에는 누른 순간 「실행됨」이었다. 09-18 트윈에서 아무 일도 일어나지 않은 채 「✓ 반영했습니다」가
3485
+ * 떴다(ADR-0070 A12-a).
3486
+ */
3487
+ proposalStateText(key) {
3488
+ const outcome = this.proposalOutcomes.get(key);
3489
+ if (!outcome) {
3490
+ /* 답이 오기 전 — 아는 사실은 「보냈고 아직 답이 없다」뿐이다. 경과 시간을 함께 보인다. */
3491
+ const since = this.proposalSentAt.get(key);
3492
+ const seconds = since ? Math.max(0, Math.round((Date.now() - since) / 1000)) : 0;
3493
+ return i18next.t('ai-assistant.text.proposal-waiting', {
3494
+ seconds,
3495
+ defaultValue: 'sending — {seconds}s, no answer yet'
3496
+ });
3497
+ }
3498
+ const counted = typeof outcome.applied === 'number' && typeof outcome.total === 'number' && outcome.total > 0
3499
+ ? i18next.t('ai-assistant.text.proposal-applied-count', {
3500
+ applied: outcome.applied,
3501
+ total: outcome.total,
3502
+ defaultValue: ' {applied} of {total}'
3503
+ })
3504
+ : '';
3505
+ /* 사유는 호스트가 준 코드 그대로다 — 문장으로 바꾸지 않는다(ADR-0042). */
3506
+ const reason = outcome.errorCode ? ` (${outcome.errorCode})` : '';
3507
+ const verdict = i18next.t(`ai-assistant.verdict.${outcome.verdict}`, {
3508
+ defaultValue: outcome.verdict === 'accepted'
3509
+ ? 'done'
3510
+ : outcome.verdict === 'refused'
3511
+ ? 'refused'
3512
+ : outcome.verdict === 'declined'
3513
+ ? 'cancelled'
3514
+ : 'could not run'
3515
+ });
3516
+ return `${verdict}${counted}${reason}`;
3517
+ }
2979
3518
  onChoiceClick(choice, proposal, key) {
2980
3519
  if (choice.action === 'save') {
2981
3520
  this.dispatchEvent(new CustomEvent('assistant-choice', {
@@ -3020,25 +3559,67 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
3020
3559
  .map(k => `${JSON.stringify(k)}:${stable(v[k])}`)
3021
3560
  .join(',')}}`;
3022
3561
  };
3562
+ /*
3563
+ * 서버가 실어 보낸 키가 정본이다 — 무엇이 같은 조치인가는 제안을 만든 쪽이 안다(ADR-0061 결정
3564
+ * 7 뒤 정리). 예전에는 여기서 `command|instanceId|args` 로 다시 셌는데, 명령이 없는 제안(선언 ·
3565
+ * 새 트윈 초안)은 그 셋이 모두 비어 **서로 다른 제안이 한 카드로 접혔고**, 하나를 누르면 나머지가
3566
+ * 함께 「요청됨」이 됐다.
3567
+ */
3568
+ if (typeof p?.key === 'string' && p.key)
3569
+ return p.key;
3023
3570
  try {
3024
- return `${p?.command ?? ''}|${p?.instanceId ?? ''}|${stable(p?.args)}`;
3571
+ return `${p?.tool ?? ''}|${p?.command ?? ''}|${p?.instanceId ?? ''}|${stable(p?.args)}|${stable(p?.ops)}`;
3025
3572
  }
3026
3573
  catch {
3027
- return `${p?.command ?? ''}|${p?.instanceId ?? ''}`;
3574
+ return `${p?.tool ?? ''}|${p?.command ?? ''}|${p?.instanceId ?? ''}`;
3028
3575
  }
3029
3576
  }
3030
- /**
3031
- * 실행은 호스트가 한다 — 이 컴포넌트는 도메인(트윈 명령 채널)을 모른다.
3032
- * 확인 대화·명령 전송·결과 기록은 호스트의 몫이고, 여기서는 중복 클릭만 막는다.
3033
- */
3034
3577
  executeProposal(p, key) {
3035
3578
  this.sentProposals = new Set(this.sentProposals).add(key);
3579
+ this.proposalSentAt.set(key, Date.now());
3580
+ this._startElapsedTicker();
3036
3581
  this.dispatchEvent(new CustomEvent('assistant-proposal-execute', {
3037
- detail: { proposal: p, sessionId: this.sessionId },
3582
+ /*
3583
+ * `proposalKey` 를 함께 준다 — 호스트가 `reportProposalOutcome` 으로 답할 때 쓰는 이름이다.
3584
+ * 호스트가 자기 규칙으로 키를 다시 만들면 카드가 못 찾는 답이 생긴다(원본은 하나).
3585
+ */
3586
+ detail: { proposal: p, sessionId: this.sessionId, proposalKey: key },
3038
3587
  bubbles: true,
3039
3588
  composed: true
3040
3589
  }));
3041
3590
  }
3591
+ /**
3592
+ * 호스트가 무엇을 했는지 — 대화에 남은 `system` 행에서 읽는다(ADR-0070 A12-a 결정 ①).
3593
+ *
3594
+ * 카드가 자기 기억으로 상태를 들고 있으면 새로 고치는 순간 사라지고, 다른 창에서 실행한 것은
3595
+ * 애초에 보이지 않는다. 그래서 상태의 자리는 이력이다.
3596
+ */
3597
+ get proposalOutcomes() {
3598
+ const outcomes = new Map();
3599
+ for (const line of this.lines) {
3600
+ if (line.role !== 'system')
3601
+ continue;
3602
+ const parsed = parseProposalOutcomeLine(line.content ?? '');
3603
+ if (parsed)
3604
+ outcomes.set(parsed.key, parsed);
3605
+ }
3606
+ return outcomes;
3607
+ }
3608
+ /** 경과 시간을 보이는 동안에만 돈다 — 답이 오면 멈춘다. */
3609
+ _startElapsedTicker() {
3610
+ if (this.elapsedTimer)
3611
+ return;
3612
+ this.elapsedTimer = setInterval(() => {
3613
+ const outcomes = this.proposalOutcomes;
3614
+ const waiting = [...this.proposalSentAt.keys()].some(key => !outcomes.has(key));
3615
+ if (!waiting) {
3616
+ clearInterval(this.elapsedTimer);
3617
+ this.elapsedTimer = undefined;
3618
+ return;
3619
+ }
3620
+ this.requestUpdate();
3621
+ }, 1000);
3622
+ }
3042
3623
  /**
3043
3624
  * 접지 경고 — 답이 언급했지만 **근거에 없던** 대상을 알린다.
3044
3625
  *
@@ -3165,12 +3746,12 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
3165
3746
  /** 배지 문구 — 코드가 아니라 사람 말로. */
3166
3747
  outcomeLabel(outcome) {
3167
3748
  const map = {
3168
- ok: ['ai-assistant.text.outcome-ok', '조회'],
3169
- rejected: ['ai-assistant.text.outcome-rejected', '거절'],
3170
- queued: ['ai-assistant.text.outcome-queued', '적용 예정'],
3171
- proposed: ['ai-assistant.text.outcome-proposed', '제안'],
3172
- folded: ['ai-assistant.text.outcome-folded', '중복 접힘'],
3173
- error: ['ai-assistant.text.outcome-error', '오류']
3749
+ ok: ['ai-assistant.text.outcome-ok', 'read'],
3750
+ rejected: ['ai-assistant.text.outcome-rejected', 'rejected'],
3751
+ queued: ['ai-assistant.text.outcome-queued', 'to apply'],
3752
+ proposed: ['ai-assistant.text.outcome-proposed', 'proposed'],
3753
+ folded: ['ai-assistant.text.outcome-folded', 'duplicate'],
3754
+ error: ['ai-assistant.text.outcome-error', 'error']
3174
3755
  };
3175
3756
  const [key, fallback] = map[outcome] ?? map.ok;
3176
3757
  return i18next.t(key, { defaultValue: fallback });
@@ -3304,8 +3885,8 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
3304
3885
  this.attachments = [];
3305
3886
  const promptText = text || (attachmentsToSend.length > 0
3306
3887
  ? (attachmentsToSend[0].type.startsWith('image/')
3307
- ? '첨부된 이미지를 참고하여 제안해 주세요.'
3308
- : '첨부된 파일을 확인해 주세요.')
3888
+ ? i18next.t('ai-assistant.text.attached-image-ask', { defaultValue: 'here is an image — go by it.' })
3889
+ : i18next.t('ai-assistant.text.attached-file-ask', { defaultValue: 'here is a file — take a look.' }))
3309
3890
  : '');
3310
3891
  if (!this.sessionId && this.prepareSession) {
3311
3892
  this.busy = true;
@@ -3325,7 +3906,7 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
3325
3906
  let requestBase;
3326
3907
  try {
3327
3908
  const provided = this.contextProvider?.() || {};
3328
- requestContext = structuredClone({ systemPrompt: this.conversation.systemPrompt, hostContext: this.conversation.hostContext, ...provided });
3909
+ requestContext = structuredClone({ hostContext: this.conversation.hostContext, ...provided });
3329
3910
  liveBoard = structuredClone(this.boardProvider ? this.boardProvider() : this.currentBoard);
3330
3911
  requestBase = { version: 1, sessionId: this.sessionId, hostContext: requestContext.hostContext,
3331
3912
  modelFingerprint: assistantModelFingerprint(liveBoard) };
@@ -3407,11 +3988,9 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
3407
3988
  ? buildAssistantChatInput({
3408
3989
  sessionId: this.sessionId,
3409
3990
  history,
3410
- systemPrompt: requestContext.systemPrompt,
3991
+ mode: { kind: this.conversation.kind, target: this.conversation.target },
3411
3992
  truncateAfterMessageId: this._truncateAfterId,
3412
- hostContext: requestContext.hostContext,
3413
- toolCategories: this.conversation.toolCategories,
3414
- requireGroundingTools: this.requireGroundingTools
3993
+ hostContext: requestContext.hostContext
3415
3994
  })
3416
3995
  : buildChatMutationInput({
3417
3996
  sessionId: this.sessionId,
@@ -3420,7 +3999,8 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
3420
3999
  scopes: this.scopes,
3421
4000
  truncateAfterMessageId: this._truncateAfterId,
3422
4001
  hostContext: requestContext.hostContext,
3423
- toolCategories: this.conversation.toolCategories,
4002
+ /* The board door still takes its categories from the element — it declares no mode. */
4003
+ toolCategories: this.toolCategories,
3424
4004
  boardTools: this.boardTools,
3425
4005
  requireGroundingTools: this.requireGroundingTools,
3426
4006
  knownTypes: this.knownTypes,
@@ -3560,9 +4140,9 @@ __decorate([
3560
4140
  __metadata("design:type", Object)
3561
4141
  ], OxAssistantChat.prototype, "mode", void 0);
3562
4142
  __decorate([
3563
- property({ type: String, attribute: 'system-prompt' }),
4143
+ property({ type: String }),
3564
4144
  __metadata("design:type", String)
3565
- ], OxAssistantChat.prototype, "systemPrompt", void 0);
4145
+ ], OxAssistantChat.prototype, "subject", void 0);
3566
4146
  __decorate([
3567
4147
  property({ type: Boolean, attribute: 'require-grounding-tools' }),
3568
4148
  __metadata("design:type", Object)
@@ -3585,7 +4165,7 @@ __decorate([
3585
4165
  ], OxAssistantChat.prototype, "componentSchemas", void 0);
3586
4166
  __decorate([
3587
4167
  property({ type: String }),
3588
- __metadata("design:type", Object)
4168
+ __metadata("design:type", String)
3589
4169
  ], OxAssistantChat.prototype, "placeholder", void 0);
3590
4170
  __decorate([
3591
4171
  state(),
@@ -3695,6 +4275,14 @@ __decorate([
3695
4275
  state(),
3696
4276
  __metadata("design:type", Object)
3697
4277
  ], OxAssistantChat.prototype, "mentionOverflow", void 0);
4278
+ __decorate([
4279
+ state(),
4280
+ __metadata("design:type", Object)
4281
+ ], OxAssistantChat.prototype, "modeView", void 0);
4282
+ __decorate([
4283
+ state(),
4284
+ __metadata("design:type", Array)
4285
+ ], OxAssistantChat.prototype, "modeChoices", void 0);
3698
4286
  OxAssistantChat = OxAssistantChat_1 = __decorate([
3699
4287
  customElement('ox-assistant-chat')
3700
4288
  ], OxAssistantChat);