@devicai/ui 0.57.0 → 0.58.0

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 (171) hide show
  1. package/README.md +162 -0
  2. package/dist/cjs/api/types.js.map +1 -1
  3. package/dist/cjs/components/AICommandBar/AICommandBar.js +10 -7
  4. package/dist/cjs/components/AICommandBar/AICommandBar.js.map +1 -1
  5. package/dist/cjs/components/AICommandBar/useAICommandBar.js +7 -5
  6. package/dist/cjs/components/AICommandBar/useAICommandBar.js.map +1 -1
  7. package/dist/cjs/components/AIElementWrapper/AIElementWrapper.js +17 -14
  8. package/dist/cjs/components/AIElementWrapper/AIElementWrapper.js.map +1 -1
  9. package/dist/cjs/components/AIElementWrapper/useAIElementWrapper.js +7 -5
  10. package/dist/cjs/components/AIElementWrapper/useAIElementWrapper.js.map +1 -1
  11. package/dist/cjs/components/AIGenerationButton/AIGenerationButton.js +11 -6
  12. package/dist/cjs/components/AIGenerationButton/AIGenerationButton.js.map +1 -1
  13. package/dist/cjs/components/AIGenerationButton/useAIGenerationButton.js +6 -4
  14. package/dist/cjs/components/AIGenerationButton/useAIGenerationButton.js.map +1 -1
  15. package/dist/cjs/components/ChatDrawer/ChatDrawer.js +26 -12
  16. package/dist/cjs/components/ChatDrawer/ChatDrawer.js.map +1 -1
  17. package/dist/cjs/components/ChatDrawer/ChatInput.js +21 -15
  18. package/dist/cjs/components/ChatDrawer/ChatInput.js.map +1 -1
  19. package/dist/cjs/components/ChatDrawer/ChatMessages.js +54 -13
  20. package/dist/cjs/components/ChatDrawer/ChatMessages.js.map +1 -1
  21. package/dist/cjs/components/ChatDrawer/CompactionWidget.js +13 -4
  22. package/dist/cjs/components/ChatDrawer/CompactionWidget.js.map +1 -1
  23. package/dist/cjs/components/ChatDrawer/ConversationSelector.js +6 -4
  24. package/dist/cjs/components/ChatDrawer/ConversationSelector.js.map +1 -1
  25. package/dist/cjs/components/ChatDrawer/GuardrailNotice.js +40 -0
  26. package/dist/cjs/components/ChatDrawer/GuardrailNotice.js.map +1 -0
  27. package/dist/cjs/components/ChatDrawer/HandoffSubagentWidget.js +3 -1
  28. package/dist/cjs/components/ChatDrawer/HandoffSubagentWidget.js.map +1 -1
  29. package/dist/cjs/components/ChatDrawer/LimitBanner.js +19 -9
  30. package/dist/cjs/components/ChatDrawer/LimitBanner.js.map +1 -1
  31. package/dist/cjs/components/ChatDrawer/QueueNotice.js +19 -7
  32. package/dist/cjs/components/ChatDrawer/QueueNotice.js.map +1 -1
  33. package/dist/cjs/components/ChatDrawer/RecalledMemoriesWidget.js +17 -5
  34. package/dist/cjs/components/ChatDrawer/RecalledMemoriesWidget.js.map +1 -1
  35. package/dist/cjs/components/ChatDrawer/ReferenceChip.js +3 -1
  36. package/dist/cjs/components/ChatDrawer/ReferenceChip.js.map +1 -1
  37. package/dist/cjs/components/ChatDrawer/UsageBar.js +23 -18
  38. package/dist/cjs/components/ChatDrawer/UsageBar.js.map +1 -1
  39. package/dist/cjs/components/CoreMemoryModal/CoreMemoryModal.js +20 -9
  40. package/dist/cjs/components/CoreMemoryModal/CoreMemoryModal.js.map +1 -1
  41. package/dist/cjs/components/Feedback/FeedbackModal.js +5 -1
  42. package/dist/cjs/components/Feedback/FeedbackModal.js.map +1 -1
  43. package/dist/cjs/components/Feedback/MessageActions.js +3 -1
  44. package/dist/cjs/components/Feedback/MessageActions.js.map +1 -1
  45. package/dist/cjs/components/IntegrationsModal/ConnectFieldsForm.js +12 -8
  46. package/dist/cjs/components/IntegrationsModal/ConnectFieldsForm.js.map +1 -1
  47. package/dist/cjs/components/IntegrationsModal/IntegrationsHint.js +5 -3
  48. package/dist/cjs/components/IntegrationsModal/IntegrationsHint.js.map +1 -1
  49. package/dist/cjs/components/IntegrationsModal/IntegrationsLauncher.js +12 -3
  50. package/dist/cjs/components/IntegrationsModal/IntegrationsLauncher.js.map +1 -1
  51. package/dist/cjs/components/IntegrationsModal/IntegrationsPanel.js +34 -24
  52. package/dist/cjs/components/IntegrationsModal/IntegrationsPanel.js.map +1 -1
  53. package/dist/cjs/components/IntegrationsModal/IntegrationsToggle.js +15 -6
  54. package/dist/cjs/components/IntegrationsModal/IntegrationsToggle.js.map +1 -1
  55. package/dist/cjs/components/IntegrationsModal/McpConnectForm.js +15 -7
  56. package/dist/cjs/components/IntegrationsModal/McpConnectForm.js.map +1 -1
  57. package/dist/cjs/components/IntegrationsModal/McpServersSection.js +32 -19
  58. package/dist/cjs/components/IntegrationsModal/McpServersSection.js.map +1 -1
  59. package/dist/cjs/components/IntegrationsModal/useIntegrations.js +3 -1
  60. package/dist/cjs/components/IntegrationsModal/useIntegrations.js.map +1 -1
  61. package/dist/cjs/components/IntegrationsModal/useTenantMcp.js +3 -1
  62. package/dist/cjs/components/IntegrationsModal/useTenantMcp.js.map +1 -1
  63. package/dist/cjs/components/ThreadStateTag/ThreadStateTag.js +63 -40
  64. package/dist/cjs/components/ThreadStateTag/ThreadStateTag.js.map +1 -1
  65. package/dist/cjs/hooks/useDevicChat.js +11 -5
  66. package/dist/cjs/hooks/useDevicChat.js.map +1 -1
  67. package/dist/cjs/hooks/useSpeechRecording.js +8 -4
  68. package/dist/cjs/hooks/useSpeechRecording.js.map +1 -1
  69. package/dist/cjs/i18n/translate.js +48 -0
  70. package/dist/cjs/i18n/translate.js.map +1 -0
  71. package/dist/cjs/i18n/useTranslations.js +57 -0
  72. package/dist/cjs/i18n/useTranslations.js.map +1 -0
  73. package/dist/cjs/index.js +11 -0
  74. package/dist/cjs/index.js.map +1 -1
  75. package/dist/cjs/provider/DevicProvider.js +3 -1
  76. package/dist/cjs/provider/DevicProvider.js.map +1 -1
  77. package/dist/cjs/styles.css +1 -1
  78. package/dist/esm/api/types.d.ts +10 -1
  79. package/dist/esm/api/types.js.map +1 -1
  80. package/dist/esm/components/AICommandBar/AICommandBar.js +11 -8
  81. package/dist/esm/components/AICommandBar/AICommandBar.js.map +1 -1
  82. package/dist/esm/components/AICommandBar/AICommandBar.types.d.ts +10 -0
  83. package/dist/esm/components/AICommandBar/useAICommandBar.js +7 -5
  84. package/dist/esm/components/AICommandBar/useAICommandBar.js.map +1 -1
  85. package/dist/esm/components/AIElementWrapper/AIElementWrapper.js +17 -14
  86. package/dist/esm/components/AIElementWrapper/AIElementWrapper.js.map +1 -1
  87. package/dist/esm/components/AIElementWrapper/AIElementWrapper.types.d.ts +10 -0
  88. package/dist/esm/components/AIElementWrapper/useAIElementWrapper.js +7 -5
  89. package/dist/esm/components/AIElementWrapper/useAIElementWrapper.js.map +1 -1
  90. package/dist/esm/components/AIGenerationButton/AIGenerationButton.js +12 -7
  91. package/dist/esm/components/AIGenerationButton/AIGenerationButton.js.map +1 -1
  92. package/dist/esm/components/AIGenerationButton/AIGenerationButton.types.d.ts +10 -0
  93. package/dist/esm/components/AIGenerationButton/useAIGenerationButton.js +6 -4
  94. package/dist/esm/components/AIGenerationButton/useAIGenerationButton.js.map +1 -1
  95. package/dist/esm/components/ChatDrawer/ChatDrawer.js +27 -13
  96. package/dist/esm/components/ChatDrawer/ChatDrawer.js.map +1 -1
  97. package/dist/esm/components/ChatDrawer/ChatDrawer.types.d.ts +33 -0
  98. package/dist/esm/components/ChatDrawer/ChatInput.js +21 -15
  99. package/dist/esm/components/ChatDrawer/ChatInput.js.map +1 -1
  100. package/dist/esm/components/ChatDrawer/ChatMessages.d.ts +1 -1
  101. package/dist/esm/components/ChatDrawer/ChatMessages.js +54 -13
  102. package/dist/esm/components/ChatDrawer/ChatMessages.js.map +1 -1
  103. package/dist/esm/components/ChatDrawer/CompactionWidget.js +13 -4
  104. package/dist/esm/components/ChatDrawer/CompactionWidget.js.map +1 -1
  105. package/dist/esm/components/ChatDrawer/ConversationSelector.js +6 -4
  106. package/dist/esm/components/ChatDrawer/ConversationSelector.js.map +1 -1
  107. package/dist/esm/components/ChatDrawer/GuardrailNotice.d.ts +36 -0
  108. package/dist/esm/components/ChatDrawer/GuardrailNotice.js +38 -0
  109. package/dist/esm/components/ChatDrawer/GuardrailNotice.js.map +1 -0
  110. package/dist/esm/components/ChatDrawer/HandoffSubagentWidget.js +3 -1
  111. package/dist/esm/components/ChatDrawer/HandoffSubagentWidget.js.map +1 -1
  112. package/dist/esm/components/ChatDrawer/LimitBanner.js +19 -9
  113. package/dist/esm/components/ChatDrawer/LimitBanner.js.map +1 -1
  114. package/dist/esm/components/ChatDrawer/QueueNotice.js +19 -7
  115. package/dist/esm/components/ChatDrawer/QueueNotice.js.map +1 -1
  116. package/dist/esm/components/ChatDrawer/RecalledMemoriesWidget.js +17 -5
  117. package/dist/esm/components/ChatDrawer/RecalledMemoriesWidget.js.map +1 -1
  118. package/dist/esm/components/ChatDrawer/ReferenceChip.js +3 -1
  119. package/dist/esm/components/ChatDrawer/ReferenceChip.js.map +1 -1
  120. package/dist/esm/components/ChatDrawer/UsageBar.js +23 -18
  121. package/dist/esm/components/ChatDrawer/UsageBar.js.map +1 -1
  122. package/dist/esm/components/ChatDrawer/index.d.ts +2 -0
  123. package/dist/esm/components/CoreMemoryModal/CoreMemoryModal.js +20 -9
  124. package/dist/esm/components/CoreMemoryModal/CoreMemoryModal.js.map +1 -1
  125. package/dist/esm/components/Feedback/FeedbackModal.js +5 -1
  126. package/dist/esm/components/Feedback/FeedbackModal.js.map +1 -1
  127. package/dist/esm/components/Feedback/MessageActions.js +3 -1
  128. package/dist/esm/components/Feedback/MessageActions.js.map +1 -1
  129. package/dist/esm/components/IntegrationsModal/ConnectFieldsForm.js +12 -8
  130. package/dist/esm/components/IntegrationsModal/ConnectFieldsForm.js.map +1 -1
  131. package/dist/esm/components/IntegrationsModal/IntegrationsHint.js +5 -3
  132. package/dist/esm/components/IntegrationsModal/IntegrationsHint.js.map +1 -1
  133. package/dist/esm/components/IntegrationsModal/IntegrationsLauncher.js +12 -3
  134. package/dist/esm/components/IntegrationsModal/IntegrationsLauncher.js.map +1 -1
  135. package/dist/esm/components/IntegrationsModal/IntegrationsPanel.d.ts +1 -1
  136. package/dist/esm/components/IntegrationsModal/IntegrationsPanel.js +34 -24
  137. package/dist/esm/components/IntegrationsModal/IntegrationsPanel.js.map +1 -1
  138. package/dist/esm/components/IntegrationsModal/IntegrationsToggle.d.ts +1 -1
  139. package/dist/esm/components/IntegrationsModal/IntegrationsToggle.js +15 -6
  140. package/dist/esm/components/IntegrationsModal/IntegrationsToggle.js.map +1 -1
  141. package/dist/esm/components/IntegrationsModal/McpConnectForm.js +15 -7
  142. package/dist/esm/components/IntegrationsModal/McpConnectForm.js.map +1 -1
  143. package/dist/esm/components/IntegrationsModal/McpServersSection.js +32 -19
  144. package/dist/esm/components/IntegrationsModal/McpServersSection.js.map +1 -1
  145. package/dist/esm/components/IntegrationsModal/useIntegrations.js +3 -1
  146. package/dist/esm/components/IntegrationsModal/useIntegrations.js.map +1 -1
  147. package/dist/esm/components/IntegrationsModal/useTenantMcp.js +3 -1
  148. package/dist/esm/components/IntegrationsModal/useTenantMcp.js.map +1 -1
  149. package/dist/esm/components/ThreadStateTag/ThreadStateTag.js +63 -40
  150. package/dist/esm/components/ThreadStateTag/ThreadStateTag.js.map +1 -1
  151. package/dist/esm/hooks/useDevicChat.js +12 -6
  152. package/dist/esm/hooks/useDevicChat.js.map +1 -1
  153. package/dist/esm/hooks/useSpeechRecording.js +8 -4
  154. package/dist/esm/hooks/useSpeechRecording.js.map +1 -1
  155. package/dist/esm/i18n/index.d.ts +4 -0
  156. package/dist/esm/i18n/translate.d.ts +23 -0
  157. package/dist/esm/i18n/translate.js +43 -0
  158. package/dist/esm/i18n/translate.js.map +1 -0
  159. package/dist/esm/i18n/types.d.ts +27 -0
  160. package/dist/esm/i18n/useTranslations.d.ts +32 -0
  161. package/dist/esm/i18n/useTranslations.js +53 -0
  162. package/dist/esm/i18n/useTranslations.js.map +1 -0
  163. package/dist/esm/index.d.ts +4 -2
  164. package/dist/esm/index.js +3 -0
  165. package/dist/esm/index.js.map +1 -1
  166. package/dist/esm/provider/DevicProvider.d.ts +1 -1
  167. package/dist/esm/provider/DevicProvider.js +3 -1
  168. package/dist/esm/provider/DevicProvider.js.map +1 -1
  169. package/dist/esm/provider/types.d.ts +33 -0
  170. package/dist/esm/styles.css +1 -1
  171. package/package.json +1 -1
package/README.md CHANGED
@@ -12,6 +12,7 @@ React component library for integrating Devic AI assistants into your applicatio
12
12
  - **Model Interface Protocol** - Support for client-side tool execution
13
13
  - **Message queue** - Write while the assistant is still answering, on assistants that allow it
14
14
  - **Message Feedback** - Built-in thumbs up/down feedback with comments
15
+ - **Translations** - A `text: translation` dictionary for every text the library renders
15
16
  - **CSS Variables** - Easy theming with CSS custom properties
16
17
  - **TypeScript** - Full type definitions included
17
18
  - **React 17+** - Compatible with React 17 and above
@@ -96,6 +97,7 @@ Context provider for global configuration.
96
97
  tenantId="tenant-123" // Optional global tenant
97
98
  tenantMetadata={{ ... }} // Optional global metadata
98
99
  pollingInterval={1000} // How often a conversation in progress is polled
100
+ translations={{ ... }} // Optional `English text -> your text` dictionary
99
101
  >
100
102
  <App />
101
103
  </DevicProvider>
@@ -134,6 +136,12 @@ Values below 250 ms are clamped — below that the widget floods the API instead
134
136
  of answering sooner. The handoff widget, which only watches a subagent run,
135
137
  keeps its own 5 s default when nothing is configured.
136
138
 
139
+ #### Texts in another language
140
+
141
+ `translations` replaces the texts the library renders itself, keyed by the
142
+ English text — `{ 'New chat': 'Nueva conversación' }`. See
143
+ [Translations](#translations).
144
+
137
145
  #### Tenant sessions — proving who the end user is
138
146
 
139
147
  With an API key alone, the tenant is whatever the page says it is. The key sits
@@ -408,6 +416,48 @@ Both are also available from the hook: `useDevicChat().compactions` (the
408
416
  checkpoints, oldest first) and `useDevicChat().compaction` (the one being
409
417
  written right now, or `null`).
410
418
 
419
+ #### Turns stopped by a guardrail
420
+
421
+ An assistant with guardrails configured can have a turn stopped before it ever
422
+ reaches the model. The backend records that as a `guard_rail` message, and the
423
+ drawer draws it as a notice naming the guardrail that fired — not as a bubble,
424
+ because nobody said it.
425
+
426
+ To say it in another language, translate its texts like any other
427
+ ([Translations](#translations)):
428
+
429
+ ```ts
430
+ translations: {
431
+ 'Your message was stopped by the “{name}” guardrail.':
432
+ 'Tu mensaje ha sido bloqueado por el guardrail «{name}».',
433
+ 'This message was stopped by a guardrail.':
434
+ 'Este mensaje ha sido bloqueado por un guardrail.',
435
+ }
436
+ ```
437
+
438
+ Supply a renderer instead when the notice needs a different shape — to drop the
439
+ guardrail's name, for example, if end users should not see it:
440
+
441
+ ```tsx
442
+ <ChatDrawer
443
+ assistantId="my-assistant"
444
+ options={{
445
+ guardrailRenderer: ({ payload }) => (
446
+ <MyNotice tone="warning">
447
+ {`No puedo ayudarte con eso (${payload?.info?.guardrail_name ?? 'guardrail'}).`}
448
+ </MyNotice>
449
+ ),
450
+ }}
451
+ />
452
+ ```
453
+
454
+ `payload` is the provider result the backend recorded — `info.guardrail_name`,
455
+ `info.confidence`, `info.threshold` and `info.stage_name` (`"input"` when the
456
+ person's message was stopped, otherwise the answer was). `text` carries the
457
+ message instead when the backend sent a plain sentence. Return `null` to hide
458
+ the notice entirely, though a conversation that simply stops with no answer and
459
+ no explanation reads as a bug to the person in it.
460
+
411
461
  ### CoreMemoryModal
412
462
 
413
463
  Modal showing — and letting the end user edit — the **core memory** of an
@@ -1135,6 +1185,118 @@ Or use the `color` option in ChatDrawer:
1135
1185
  />
1136
1186
  ```
1137
1187
 
1188
+ ## Translations
1189
+
1190
+ Every text the library renders itself — the drawer header, the composer, the
1191
+ buttons, tooltips and dialogs — goes through a dictionary you can replace.
1192
+ It is a plain `English text → your text` map:
1193
+
1194
+ ```tsx
1195
+ <DevicProvider
1196
+ apiKey="devic-xxx"
1197
+ translations={{
1198
+ 'New chat': 'Nueva conversación',
1199
+ 'Type a message...': 'Escribe un mensaje...',
1200
+ 'Close chat': 'Cerrar el chat',
1201
+ 'Send message': 'Enviar mensaje',
1202
+ }}
1203
+ >
1204
+ <ChatDrawer assistantId="my-assistant" />
1205
+ </DevicProvider>
1206
+ ```
1207
+
1208
+ That is the whole mechanism. There is no i18n runtime bundled here and no key
1209
+ catalogue to learn: the key is what you see on screen, and the values come
1210
+ from whatever you already use — i18next, react-intl, a JSON file per locale.
1211
+ Hand it the strings for the current language and re-render when it changes:
1212
+
1213
+ ```tsx
1214
+ const { t, i18n } = useTranslation('devic');
1215
+
1216
+ <DevicProvider
1217
+ apiKey="devic-xxx"
1218
+ // Re-created when the language changes, which is what re-renders the widget.
1219
+ translations={useMemo(
1220
+ () => ({
1221
+ 'New chat': t('newChat'),
1222
+ 'Type a message...': t('inputPlaceholder'),
1223
+ }),
1224
+ [i18n.language]
1225
+ )}
1226
+ >
1227
+ ```
1228
+
1229
+ **Anything you leave out stays in English**, so a partial dictionary is fine —
1230
+ translate the drawer today and the apps dialog when you get to it.
1231
+
1232
+ ### Placeholders
1233
+
1234
+ Texts that carry a value use `{name}` placeholders. Keep them in the
1235
+ translation; they are filled after the lookup, so they may be reordered:
1236
+
1237
+ ```tsx
1238
+ translations={{
1239
+ '{count} messages': '{count} mensajes',
1240
+ 'Resets in {count} minutes.': 'Quedan {count} minutos para el reinicio.',
1241
+ '{label} — {count} switched off': '{count} desactivadas de {label}',
1242
+ }}
1243
+ ```
1244
+
1245
+ Counted texts come in a singular and a plural entry (`1 message` and
1246
+ `{count} messages`), so a language that inflects differently has somewhere to
1247
+ say so.
1248
+
1249
+ ### Per component
1250
+
1251
+ Each component takes its own `translations`, merged on top of the provider's.
1252
+ Use it when one widget must read differently from the rest of the page:
1253
+
1254
+ ```tsx
1255
+ <ChatDrawer
1256
+ assistantId="support"
1257
+ options={{ translations: { 'New chat': 'Nueva consulta' } }}
1258
+ />
1259
+ ```
1260
+
1261
+ Available on `ChatDrawer`, `AICommandBar`, `AIGenerationButton` and
1262
+ `AIElementWrapper`, and it reaches everything they mount — the message list,
1263
+ the composer and the dialogs they open. For anything else, wrap a subtree:
1264
+
1265
+ ```tsx
1266
+ import { DevicTranslationsProvider } from '@devicai/ui';
1267
+
1268
+ <DevicTranslationsProvider translations={{ Close: 'Cerrar' }}>
1269
+ <IntegrationsPanel assistantId="my-assistant" />
1270
+ </DevicTranslationsProvider>
1271
+ ```
1272
+
1273
+ Later layers win: provider → enclosing component → the component's own option.
1274
+
1275
+ ### What takes precedence
1276
+
1277
+ Texts that already have an option of their own (`welcomeMessage`,
1278
+ `inputPlaceholder`, `title`, `integrationsLabel`, `coreMemoryLabels`, …) keep
1279
+ winning over the dictionary — the dictionary only supplies their defaults. So
1280
+ a host that has always set `inputPlaceholder` sees no change, and one that
1281
+ never did gets it translated.
1282
+
1283
+ ### The full list
1284
+
1285
+ [TRANSLATIONS.md](./TRANSLATIONS.md) lists every text, grouped by where it
1286
+ appears. Two things to watch: copy the key exactly (same case, same `…` and
1287
+ `·`), and note that `AIElementWrapper` has shipped Spanish defaults since it
1288
+ was added, so its keys are Spanish.
1289
+
1290
+ ### Reading the dictionary yourself
1291
+
1292
+ `useTranslations` returns the same translator the components use, for a custom
1293
+ UI built on `useDevicChat`:
1294
+
1295
+ ```tsx
1296
+ const t = useTranslations();
1297
+ <button>{t('Send message')}</button>
1298
+ ```
1299
+
1138
1300
  ## Message Queue
1139
1301
 
1140
1302
  Assistants can be configured to accept messages sent while they are still
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sources":["../../../../src/api/types.ts"],"sourcesContent":["import type { AvatarStyle } from '../utils/avatar';\n\nimport type React from 'react';\n\n/**\n * File attachment for messages\n */\nexport interface ChatFile {\n name: string;\n downloadUrl?: string;\n fileType?: 'image' | 'document' | 'audio' | 'video' | 'other';\n}\n\n/**\n * Attachment as it appears on a message.\n *\n * Two shapes reach the UI for the same thing: the optimistic message built\n * locally on send uses `url`/`type`, while the history returned by the API\n * carries the stored `downloadUrl`/`fileType`. Both are accepted here; use\n * `normalizeMessageFile` before reading them.\n */\nexport interface MessageFile {\n name: string;\n url?: string;\n type?: string;\n downloadUrl?: string;\n fileType?: string;\n}\n\n/**\n * Message content structure\n */\nexport interface MessageContent {\n message?: string;\n data?: any;\n files?: MessageFile[];\n}\n\n/** Collapse either attachment shape into a single one the UI can render. */\nexport function normalizeMessageFile(file: MessageFile): {\n name: string;\n url: string;\n type: string;\n} {\n return {\n name: file.name,\n url: file.url || file.downloadUrl || '',\n type: file.type || file.fileType || 'other',\n };\n}\n\n/**\n * Tool call from the model\n */\nexport interface ToolCall {\n id: string;\n type: 'function';\n function: {\n name: string;\n arguments: string;\n };\n}\n\n/**\n * Chat message structure\n */\nexport interface ChatMessage {\n uid: string;\n role: 'user' | 'assistant' | 'developer' | 'system' | 'tool';\n content: MessageContent;\n timestamp: number;\n chatUid?: string;\n tool_calls?: ToolCall[];\n tool_call_id?: string;\n summary?: string;\n /**\n * Where `content.message` came from, when the model did not write it.\n * `'finish_tool'`: the assistant is configured to require a tool call to\n * finish (\"Require Tool Use to Finish\") and the backend lifted the reply from\n * the finish tool's `message` argument, so it can be read without parsing\n * tool calls. Absent on replies the model wrote itself — use it to label the\n * bubble as produced by the tool.\n */\n contentSource?: string;\n /**\n * Id of a speech-to-text transcript (from POST /api/v1/whisper) that seeded\n * this message. Present on user messages dictated by voice; the chat can use\n * it to fetch the source audio (GET /api/v1/whisper/:transcriptId) and offer\n * playback.\n */\n transcriptId?: string;\n /**\n * Original server uid, present when the UI adopted an optimistic uid for\n * this message to keep React keys stable. Server-side references (e.g.\n * memory recall anchors) match against it.\n */\n serverUid?: string;\n /**\n * Client-side only: the conversation was busy when this message was sent, so\n * it was accepted into the queue and is waiting its turn. Drawn as a message\n * that has not landed rather than as part of the conversation. Falls away on\n * its own once the message comes back inside the history.\n */\n queued?: boolean;\n /**\n * Client-side only: when this message was accepted into the queue. Used to\n * tell \"the server has not reported it yet\" from \"the server no longer has\n * it\", which the timestamp is the only honest way to decide.\n */\n queuedAt?: number;\n}\n\n/**\n * Previous conversation message for initialization\n */\nexport interface PreviousMessage {\n message: string;\n role: 'user' | 'assistant';\n}\n\n/**\n * Model interface tool schema following OpenAI function calling format\n */\nexport interface ModelInterfaceToolSchema {\n type: 'function';\n function: {\n name: string;\n description: string;\n parameters: {\n type: 'object';\n properties: Record<string, any>;\n required?: string[];\n };\n };\n}\n\n/**\n * Props passed to a response widget component.\n * The widget is responsible for collecting the user's response and\n * calling `submit` with the payload to resolve the tool call.\n */\nexport interface ResponseWidgetProps {\n /** The tool call this widget is responding to */\n toolCall: ToolCall;\n /** Parsed arguments from the tool call */\n params: any;\n /** Submit the tool response payload (sent as the tool call result to the model) */\n submit: (response: any) => void;\n /** Cancel the tool call. Sends an error response so the model can continue. */\n cancel?: (reason?: string) => void;\n /** Whether the widget is currently submitting */\n isSubmitting?: boolean;\n}\n\n/**\n * Interactive response widget configuration for a client-side tool.\n *\n * When the model calls a tool configured with a `responseWidget`, the\n * widget is rendered in the chat UI instead of executing a callback.\n * The user interacts with the widget, which calls `submit(response)` to\n * define the tool response sent back to the model.\n *\n * - `render: 'inline'` renders the widget in the message thread at the\n * position of the tool call. The text input remains enabled.\n * - `render: 'input'` replaces the chat input area with the widget\n * while it is pending. The text input is disabled until submission.\n */\nexport interface ResponseWidgetConfig {\n /** Where to render the widget */\n render: 'inline' | 'input';\n /** The widget component */\n component: React.ComponentType<ResponseWidgetProps>;\n}\n\n/**\n * Model interface tool definition for client-side tools.\n *\n * A tool must provide either a `callback` (executed automatically when\n * the model invokes the tool) or a `responseWidget` (renders UI for\n * the user to produce the tool response). Providing both is an error.\n */\nexport interface ModelInterfaceTool {\n toolName: string;\n schema: ModelInterfaceToolSchema;\n /** Executed automatically when the model calls this tool */\n callback?: (params: any) => Promise<any> | any;\n /** Interactive widget that collects the user's tool response */\n responseWidget?: ResponseWidgetConfig;\n}\n\n/**\n * Tool call response to send back to the API\n */\nexport interface ToolCallResponse {\n tool_call_id: string;\n content: any;\n role: 'tool';\n /**\n * The client-side tools still on offer for the rest of the turn. The API\n * reads them off the first response of the batch: leaving them out drops\n * the tools from the continuation, so the model cannot call them again.\n */\n tools?: ModelInterfaceToolSchema[];\n}\n\n/**\n * DTO for sending messages to the assistant\n */\nexport interface ProcessMessageDto {\n message: string;\n chatUid?: string;\n userName?: string;\n files?: ChatFile[];\n /** Tags to associate with this chat (top-level, distinct from `metadata`). */\n tags?: string[];\n metadata?: {\n promptTemplateParams?: Record<string, any>;\n tenantToken?: string;\n [key: string]: any;\n };\n tenantId?: string;\n previousConversation?: PreviousMessage[];\n enabledTools?: string[];\n provider?: string;\n model?: string;\n // Model interface protocol fields\n tools?: ModelInterfaceToolSchema[];\n applicationState?: Record<string, any>;\n skipSummarization?: boolean;\n /**\n * Id of a speech-to-text transcript (from POST /api/v1/whisper) that seeded\n * this message. Sent so the conversation keeps a link to the original audio.\n */\n transcriptId?: string;\n}\n\n/**\n * Response from the /whisper speech-to-text endpoint.\n */\nexport interface WhisperTranscriptionResponse {\n /** Public id of the transcript; send it back as ProcessMessageDto.transcriptId. */\n transcriptId: string;\n /** Transcribed text. */\n text: string;\n /** Language hint used, if any. */\n language?: string;\n /** Download URL of the source audio. */\n audioUrl?: string;\n /** Transcription model used. */\n model?: string;\n}\n\n/**\n * Response from the assistant\n */\nexport interface AssistantResponse {\n messages: ChatMessage[];\n chatUid: string;\n inputTokens?: number;\n outputTokens?: number;\n}\n\n/**\n * Async mode response\n */\nexport interface AsyncResponse {\n chatUid: string;\n message?: string;\n error?: string;\n /**\n * The conversation could not take the message right now, so it was queued\n * instead of starting a run of its own. Still an acceptance: the answer comes\n * later, and may cover several messages at once.\n */\n queued?: boolean;\n /** How many messages are queued on this conversation, this one included. */\n queuePosition?: number;\n /** When the queued message reaches the model. */\n willProcess?: QueueDisposition;\n}\n\n/**\n * When a queued message will reach the model.\n *\n * `after_delay` is the one that is not about being busy: an idle conversation\n * on an assistant with an input delay collects what is written during the\n * window, so a message can come back queued with nothing in flight at all.\n */\nexport type QueueDisposition = 'after_delay' | 'next_turn' | 'on_resume';\n\n/** Response of the stop endpoint. */\nexport interface StopChatResponse {\n chatUid: string;\n message: string;\n /**\n * Queued messages the stop threw away — answering them would be the opposite\n * of what was asked. Handed back so their text can be put where the user\n * wrote it. Absent on an API older than this, and when nothing was queued.\n */\n discardedMessages?: ChatMessage[];\n}\n\n/**\n * Real-time chat history status.\n * `limit_exceeded` means the message was blocked before reaching the LLM\n * because a configured tenant/subtenant usage limit was reached.\n */\nexport type RealtimeStatus =\n | 'processing'\n | 'completed'\n | 'error'\n | 'waiting_for_tool_response'\n | 'handed_off'\n | 'limit_exceeded'\n /** Collecting messages during the assistant's input delay, before any run. */\n | 'buffering';\n\n/**\n * Details of a tenant/subtenant usage limit that blocked a message.\n * Returned on the realtime endpoint when status is `limit_exceeded`, and on\n * the HTTP 429 body (`details`) when a synchronous request is blocked.\n */\nexport interface TenantLimitExceeded {\n /** Human-readable message describing the block. */\n message?: string;\n /** The rule that triggered the block (scope, metric, window, limit…). */\n blockingRule?: {\n scope?: 'tenant' | 'subtenant';\n subtenantId?: string;\n metric?: 'tokens' | 'cost';\n windowUnit?: 'hour' | 'day' | 'week' | 'month';\n windowEvery?: number;\n limit?: number;\n };\n /** Current consumption in the blocking window. */\n current?: number;\n /** The limit that was reached. */\n limit?: number;\n /** Epoch ms when the blocking window resets and usage is allowed again. */\n resetsAt?: number;\n}\n\n/** One fact a long-term-memory recall surfaced. */\nexport interface RecalledMemoryFact {\n fact: string;\n relation: string;\n /** Source entity name of the graph edge, when the fact connects two. */\n source: string | null;\n /** Target entity name of the graph edge, when the fact connects two. */\n target: string | null;\n /** ISO date the fact became valid, if known. */\n validAt: string | null;\n}\n\n/** One graph entity a long-term-memory recall surfaced. */\nexport interface RecalledMemoryEntity {\n id: string;\n name: string;\n type: string;\n summary: string | null;\n}\n\n/** One previous-session turn a conversation-start recall carried over. */\nexport interface RecalledMemoryTurn {\n role: string;\n content: string;\n}\n\n/**\n * One structured long-term-memory recall event of a conversation: the facts,\n * entities and previous-session turns a recall surfaced, plus the uid of the\n * message that brought it in (`messageUid`: the initial user message, or the\n * assistant message carrying the memory tool call — resolvable through\n * `toolCallId` while the run is still in flight).\n */\nexport interface RecalledMemoryRecord {\n uid: string;\n messageUid?: string;\n toolCallId?: string;\n source:\n | 'conversation_start'\n | 'search_memory'\n | 'search_memory_nodes'\n | 'explore_memory_graph';\n query?: string;\n facts?: RecalledMemoryFact[];\n entities?: RecalledMemoryEntity[];\n turns?: RecalledMemoryTurn[];\n timestampMs: number;\n}\n\n/**\n * Snapshot of the core-memory block a conversation saw (audit trail): the\n * render revision plus the injected entries as structured items.\n */\nexport interface CoreMemorySnapshot {\n uid: string;\n revision: string;\n items: Array<{\n id: number;\n section: string;\n content: string;\n pinned: boolean;\n source: string;\n }>;\n entries: number;\n omitted: number;\n chars: number;\n timestampMs: number;\n}\n\n/**\n * Real-time chat history response\n */\nexport interface RealtimeChatHistory {\n chatUID: string;\n clientUID: string;\n chatHistory: ChatMessage[];\n status: RealtimeStatus;\n lastUpdatedAt: number;\n pendingToolCalls?: ToolCall[];\n handedOffSubThreadId?: string;\n /** Present only when status is `limit_exceeded`. */\n limitExceeded?: TenantLimitExceeded;\n /**\n * Memory-recall events of the in-flight run — lets the UI show what the\n * assistant is recalling while the response is still processing.\n */\n recalledMemories?: RecalledMemoryRecord[];\n /**\n * Messages accepted into this conversation that the model has not seen yet.\n * Non-zero means more is coming: a `completed` status with messages still\n * queued is not the end of the exchange.\n */\n queuedMessages?: number;\n /**\n * The queued messages themselves. This is the conversation's queue, not the\n * caller's — it can include messages the same conversation received through\n * another channel. Absent on an API that does not return them, in which case\n * the widget falls back to its own optimistic copies.\n */\n pendingUserMessages?: ChatMessage[];\n /**\n * Compaction checkpoints of the in-flight run. A conversation that compacts\n * mid-run stops sending the messages above the cut immediately, so these\n * arrive here before they are persisted on the conversation.\n */\n compactions?: CompactionCheckpoint[];\n /** The compaction running right now, if any. */\n compaction?: CompactionActivity;\n}\n\n/**\n * A single usage rule with its current consumption (from GET\n * /api/v1/tenant-usage/:tenantId[/subtenants/:subtenantId]).\n */\nexport interface TenantUsageRule {\n scope: 'tenant' | 'subtenant';\n subtenantId?: string;\n metric: 'tokens' | 'cost';\n windowUnit: 'hour' | 'day' | 'week' | 'month';\n windowEvery: number;\n /** Configured limit for the window. */\n limit: number;\n /** Current consumption in the active window. */\n current: number;\n /** Utilization percentage (0..100, capped). */\n percent: number;\n /** Epoch ms when the active window resets. */\n resetsAt?: number;\n /** Where the rule comes from ('tier' | 'adhoc'). */\n origin?: string;\n /** Tier the rule belongs to, if any. */\n tierId?: string;\n}\n\n/**\n * Response of GET /api/v1/tenant-usage/:tenantId[/subtenants/:subtenantId]:\n * the effective usage rules with their current consumption + the active tier.\n */\nexport interface TenantUsage {\n tenantId: string;\n subtenantId?: string;\n tierId?: string;\n usage: TenantUsageRule[];\n}\n\n/**\n * A durable per-window usage history row (from GET\n * /api/v1/tenant-usage/:tenantId/history).\n */\nexport interface TenantUsageHistoryRow {\n clientUID: string;\n tenantId: string;\n subtenantId: string;\n scope: 'tenant' | 'subtenant';\n metric: 'tokens' | 'cost';\n windowUnit: 'hour' | 'day' | 'week' | 'month';\n windowEvery: number;\n windowKey: string;\n windowStart: number;\n windowEnd: number;\n /** Counted consumption (enforced). */\n consumption: number;\n /** Exempt consumption that did not count toward the limit, if any. */\n exemptConsumption?: number;\n limit: number;\n percent: number;\n tierId?: string;\n origin?: string;\n capturedAt: number;\n}\n\n/**\n * Options for querying tenant usage history.\n */\nexport interface TenantUsageHistoryQuery {\n subtenantId?: string;\n scope?: 'tenant' | 'subtenant';\n metric?: 'tokens' | 'cost';\n windowUnit?: 'hour' | 'day' | 'week' | 'month';\n /** Epoch ms lower bound (windowEnd >= from). */\n from?: number;\n /** Epoch ms upper bound (windowEnd <= to). */\n to?: number;\n limit?: number;\n skip?: number;\n}\n\n/**\n * Chat history structure\n */\n/** A concrete value carried verbatim through a compaction. */\nexport interface CompactionFact {\n kind: string;\n value: string;\n label?: string;\n}\n\n/** The structured body a compaction produced. */\nexport interface CompactionSummary {\n goal?: string;\n constraints?: string[];\n inProgress?: string;\n pending?: string[];\n decisions?: string[];\n data?: Array<{ label: string; value: string }>;\n done?: string[];\n openQuestions?: string[];\n /** Fallback when the model answered without structure. */\n raw?: string;\n}\n\n/**\n * One compaction of a conversation: the messages before its boundary folded\n * into a written summary plus the identifiers, paths and urls lifted out of\n * them verbatim. From then on the model receives the checkpoint instead of\n * those messages — which are still in the conversation, and still shown.\n *\n * Only the newest checkpoint is in force: each compaction merges the previous\n * summary into itself.\n */\nexport interface CompactionCheckpoint {\n uid: string;\n /** 1 for the first compaction of the conversation, 2 for the next… */\n index: number;\n timestampMs: number;\n trigger: 'auto' | 'manual';\n /** First message that still travels verbatim. */\n firstKeptMessageUid?: string;\n /** Last folded message: where the widget belongs in the conversation. */\n anchorMessageUid?: string;\n compactedMessageCount: number;\n summary: CompactionSummary;\n facts: CompactionFact[];\n tokensBefore: number;\n tokensAfter: number;\n provider?: string;\n model?: string;\n cost?: number;\n}\n\n/**\n * A compaction happening right now, from the realtime endpoint.\n *\n * A compaction is a model call of its own, taken between two assistant\n * messages, so a client that only knows `processing` shows a conversation\n * that appears to have stalled for a few seconds. Present while it runs and\n * on the single update that reports it finished.\n */\nexport interface CompactionActivity {\n state: 'running' | 'completed';\n startedAt: number;\n /**\n * What this pass is folding: the messages new since the last checkpoint.\n * Not the conversation's totals — a checkpoint's own\n * `compactedMessageCount` and `tokensBefore` are cumulative across every\n * compaction, so the two are on different scales and must not be paired.\n */\n messageCount: number;\n tokensBefore: number;\n /** Which checkpoint the pass produced, once it is done. */\n index?: number;\n finishedAt?: number;\n}\n\nexport interface ChatHistory {\n chatUID: string;\n clientUID: string;\n userUID: string;\n chatContent: ChatMessage[];\n name?: string;\n assistantSpecializationIdentifier: string;\n creationTimestampMs: number;\n lastEditTimestampMs?: number;\n llm?: string;\n inputTokens?: number;\n outputTokens?: number;\n metadata?: Record<string, any>;\n tenantId?: string;\n handedOff?: boolean;\n handedOffSubThreadId?: string;\n handedOffToolCallId?: string;\n /** Structured long-term-memory recall events of the conversation. */\n recalledMemories?: RecalledMemoryRecord[];\n /** Audit trail of the core-memory blocks the conversation saw. */\n coreMemories?: CoreMemorySnapshot[];\n /** Compaction checkpoints of the conversation, oldest first. */\n compactions?: CompactionCheckpoint[];\n}\n\n/** One core memory entry (the always-injected tier), as returned by the memory API. */\nexport interface CoreMemoryEntry {\n id: number;\n section: string;\n content: string;\n source: string;\n pinned: boolean;\n supersedes: number | null;\n archivedAt: string | null;\n createdAt?: string;\n updatedAt?: string;\n}\n\n/** Deployment caps of the core memory tier. */\nexport interface CoreMemoryLimits {\n maxChars: number;\n maxEntries: number;\n maxEntryChars: number;\n}\n\n/**\n * Response of GET /api/v1/memory/assistants/:identifier/core — the entries\n * of the bucket the assistant resolves for a tenant/subtenant combination.\n */\nexport interface CoreMemoryList {\n /** False when the assistant does not have the core memory tier enabled. */\n enabled: boolean;\n /** The resolved bucket tuple (tenant/subtenant/owner dimensions). */\n bucket: { tenantId?: string; subtenantId?: string; entityId?: string };\n entries: CoreMemoryEntry[];\n limits?: CoreMemoryLimits;\n}\n\n/**\n * Assistant specialization info\n */\nexport interface AssistantSpecialization {\n identifier: string;\n name: string;\n description: string;\n state: 'active' | 'inactive' | 'coming_soon';\n imgUrl?: string;\n /** Pinned style of the generated avatar shown when there is no imgUrl. */\n avatarStyle?: AvatarStyle;\n availableToolsGroups?: Array<{\n name: string;\n description?: string;\n uid?: string;\n iconUrl?: string;\n tools?: Array<{\n name: string;\n description: string;\n }>;\n }>;\n model?: string;\n isCustom?: boolean;\n creationTimestampMs?: number;\n /**\n * Whether this assistant offers MCP servers of the tenant's own.\n *\n * Same contract as `tenantIntegrations` below, absence included.\n */\n tenantMcpServers?: {\n enabled: boolean;\n /** Servers listed ready to connect. Says nothing about how many are connected. */\n count?: number;\n };\n /**\n * Whether this assistant offers connected apps to its tenants.\n *\n * **Absent means \"cannot tell\", not \"no\"** — an API older than this field\n * says nothing, and treating silence as a no would hide the connected-apps\n * button from anyone whose deployment has not caught up yet.\n */\n tenantIntegrations?: {\n enabled: boolean;\n /**\n * How many apps the catalogue offers. An upper bound — the listing drops\n * any the provider cannot resolve — and enough to size a placeholder.\n */\n count?: number;\n };\n /**\n * Whether this assistant accepts messages sent while the conversation is\n * busy, queueing them instead of refusing them.\n *\n * **Absent means no**, unlike `tenantIntegrations` above. Promising a queue\n * that does not exist is paid for with a 409 and with the user's text left in\n * the air, so silence is read as the safe answer rather than as the open one.\n */\n messageQueueEnabled?: boolean;\n /** How many messages may wait at once before further sends are refused. */\n maxQueuedMessages?: number;\n}\n\n/**\n * Summary of a conversation for listing\n */\nexport interface ConversationSummary {\n chatUID: string;\n name?: string;\n creationTimestampMs: number;\n lastEditTimestampMs?: number;\n}\n\nexport interface ListConversationsResponse {\n histories: ConversationSummary[];\n total: number;\n offset: number;\n limit: number;\n}\n\n/**\n * API error response\n */\nexport interface ApiError {\n statusCode: number;\n message: string;\n error?: string;\n /** Optional structured details (e.g. usage-limit blocking info on a 429). */\n details?: any;\n}\n\n/**\n * Feedback submission request\n */\nexport interface FeedbackSubmission {\n messageId: string;\n feedback?: boolean;\n feedbackComment?: string;\n feedbackData?: Record<string, any>;\n}\n\n/**\n * Feedback entry response\n */\nexport interface FeedbackEntry {\n _id: string;\n requestId: string;\n chatUID?: string;\n threadId?: string;\n agentId?: string;\n feedback?: boolean;\n feedbackComment?: string;\n feedbackData?: Record<string, any>;\n creationTimestamp: string;\n lastEditTimestamp?: string;\n}\n\n/**\n * Agent thread states\n */\nexport enum AgentThreadState {\n QUEUED = 'queued',\n PROCESSING = 'processing',\n COMPLETED = 'completed',\n FAILED = 'failed',\n TERMINATED = 'terminated',\n PAUSED = 'paused',\n PAUSED_FOR_APPROVAL = 'paused_for_approval',\n APPROVAL_REJECTED = 'approval_rejected',\n WAITING_FOR_RESPONSE = 'waiting_for_response',\n PAUSED_FOR_RESUME = 'paused_for_resume',\n HANDED_OFF = 'handed_off',\n GUARDRAIL_TRIGGER = 'guardrail_trigger',\n}\n\n/**\n * Task within an agent thread\n */\nexport interface AgentTaskDto {\n _id?: string;\n title?: string;\n description?: string;\n completed: boolean;\n}\n\n/**\n * Agent thread DTO\n */\nexport interface AgentThreadDto {\n _id?: string;\n agentId: string;\n state: AgentThreadState;\n threadContent: ChatMessage[];\n tasks?: AgentTaskDto[];\n finishReason?: string;\n pausedReason?: string;\n name?: string;\n creationTimestampMs?: number;\n lastEditTimestampMs?: number;\n pauseUntil?: number;\n isSubthread?: boolean;\n parentThreadId?: string;\n subThreadToolCallId?: string;\n parentAgentId?: string;\n}\n\n/**\n * Agent details\n */\nexport interface AgentDto {\n _id?: string;\n name: string;\n description?: string;\n imgUrl?: string;\n /** Pinned style of the generated avatar shown when there is no imgUrl. */\n avatarStyle?: AvatarStyle;\n agentId?: string;\n}\n\n/**\n * Hand-off tool response content\n */\nexport interface HandOffToolResponse {\n response: string;\n subthreadId: string;\n}\n\n/**\n * Represents a single tool call within a tool group\n */\nexport interface ToolGroupCall {\n name: string;\n input: any;\n output: any;\n toolCallId: string;\n}\n\n/**\n * Configuration for grouping consecutive tool calls under a single renderer\n */\nexport interface ToolGroupConfig {\n tools: string[];\n renderer: (calls: ToolGroupCall[]) => React.ReactNode;\n}\n\n/**\n * One of the end user's connected accounts for an app.\n *\n * The provider's own identifiers do not travel here beyond `id`, which the\n * client needs in order to name the account it wants disconnected — and which\n * the server re-checks against the caller's tenant on the way back in.\n */\nexport interface IntegrationAccount {\n id: string;\n status: string;\n connectedAt?: string;\n updatedAt?: string;\n /** True when the account exists but can no longer run tools. */\n needsReconnect?: boolean;\n statusReason?: string;\n}\n\n/**\n * One value the end user is asked for before an account can be connected —\n * their API key, the subdomain of their instance.\n *\n * Comes from the provider's own catalogue, so the form is rendered from this\n * rather than from anything app-specific: most apps do not authenticate with\n * credentials Devic holds, and there are hundreds of them.\n */\nexport interface IntegrationAuthField {\n name: string;\n label: string;\n type: string;\n required: boolean;\n description?: string;\n /** Prefilled — usually a provider endpoint most accounts should keep. */\n default?: string;\n /** Mask it on screen. */\n secret: boolean;\n}\n\n/**\n * One way of connecting an app.\n *\n * `redirect` schemes send the user to the provider; the rest are connected\n * with the values they type, without ever leaving the page.\n *\n * There is deliberately no field for the *application's* credentials: the\n * OAuth application belongs to the developer who embedded this widget, is\n * registered once for every tenant, and is never the end user's to supply.\n */\nexport interface IntegrationAuthScheme {\n /** The provider's own name for it: `OAUTH2`, `API_KEY`, … */\n mode: string;\n /** Credentials for this scheme are held for you — nothing to fill in. */\n composioManaged: boolean;\n redirect: boolean;\n /** What this account supplies. Empty for a scheme that asks nothing. */\n accountFields: IntegrationAuthField[];\n /** The provider's own setup guide, when there is one. */\n guideUrl?: string;\n}\n\n/**\n * The answer when connecting needs values that were not sent.\n *\n * `stage` decides who can act on it: `account` is the end user, and the form\n * asks them. `app` is the developer's OAuth application, which the end user\n * cannot register — so that case is shown as \"not available yet\" instead of a\n * form asking a stranger for someone else's client secret.\n */\nexport interface IntegrationSetupRequired {\n code: \"INTEGRATION_SETUP_REQUIRED\";\n message: string;\n toolkit: string;\n authScheme: string;\n stage: \"app\" | \"account\";\n fields: IntegrationAuthField[];\n guideUrl?: string;\n}\n\n/**\n * An app the assistant offers to its tenants, with the accounts THIS tenant\n * has connected. Never another tenant's.\n */\nexport interface Integration {\n /** App slug, e.g. `gmail`. */\n app: string;\n name: string;\n description?: string;\n logo?: string;\n /** True when at least one account is active. */\n connected: boolean;\n accounts: IntegrationAccount[];\n /** Event types the developer allows this tenant to switch on. */\n availableTriggers?: string[];\n}\n\n// ── MCP servers the end user connects for themselves ──────────────────────\n\nexport type TenantMcpAuthMode = \"oauth\" | \"header\" | \"none\";\n\n/** One of the end user's own MCP connections. */\nexport interface TenantMcpConnection {\n id: string;\n /**\n * What to put in `disabledIntegrations` to have this server sit a message\n * out. Sent by the API so the prefix that separates it from an app slug lives\n * on the server, in one place.\n */\n toggleId?: string;\n name?: string;\n url: string;\n /** The developer's template this came from, when it came from one. */\n templateId?: string;\n authMode?: TenantMcpAuthMode;\n status: \"pending_auth\" | \"active\" | \"error\";\n toolCount?: number;\n tools?: string[];\n lastProbeStatus?: string;\n lastProbeError?: string;\n lastProbeTimestampMs?: number;\n /** Connected for the whole tenant, so every end user of it shares this. */\n shared: boolean;\n /** True when this end user may use it but not change or remove it. */\n readOnly: boolean;\n}\n\n/**\n * One row of the MCP panel: either a server the developer offers ready to\n * connect, or one this end user added.\n *\n * A single list rather than two, because that is what the panel draws — keeping\n * \"offered\" and \"connected\" apart would leave them out of step for a moment\n * after every connect.\n */\nexport interface TenantMcpServer {\n source: \"template\" | \"custom\";\n templateId?: string;\n name: string;\n url: string;\n description?: string;\n logoUrl?: string;\n authMode?: TenantMcpAuthMode;\n /** Header the credential travels in, for `header` servers. */\n headerName?: string;\n /** Whether the end user may supply their own OAuth application. */\n allowClientCredentials?: boolean;\n /** Null until this tenant connects it. */\n connection: TenantMcpConnection | null;\n}\n\nexport interface TenantMcpListing {\n offered: boolean;\n /** Whether adding a server of one's own is permitted. */\n allowCustom: boolean;\n limits: { maxServers: number; maxToolsPerServer: number; used: number };\n servers: TenantMcpServer[];\n}\n\n/** Credentials the end user supplies when connecting a server. */\nexport interface TenantMcpAuthInput {\n mode?: TenantMcpAuthMode;\n headerName?: string;\n headerValue?: string;\n upstreamOAuth?: { clientId?: string; clientSecret?: string; scopes?: string[] };\n}\n\n/**\n * What connecting answers with.\n *\n * `status: \"active\"` means it is done. `authorizationUrl` must be opened in a\n * popup. `requiresClientCredentials` means the server has no dynamic client\n * registration and the end user has to register an OAuth application with it\n * themselves, authorising `callbackUrl` as the redirect URI.\n */\nexport interface TenantMcpConnectResult {\n id: string;\n status: \"pending_auth\" | \"active\" | \"error\";\n toolCount?: number;\n authorizationUrl?: string;\n requiresClientCredentials?: boolean;\n callbackUrl?: string;\n error?: string;\n}\n"],"names":["AgentThreadState"],"mappings":";;AAsCA;AACM,SAAU,oBAAoB,CAAC,IAAiB,EAAA;IAKpD,OAAO;QACL,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,WAAW,IAAI,EAAE;QACvC,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,IAAI,OAAO;KAC5C;AACH;AA2tBA;;AAEG;AACSA;AAAZ,CAAA,UAAY,gBAAgB,EAAA;AAC1B,IAAA,gBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACjB,IAAA,gBAAA,CAAA,YAAA,CAAA,GAAA,YAAyB;AACzB,IAAA,gBAAA,CAAA,WAAA,CAAA,GAAA,WAAuB;AACvB,IAAA,gBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACjB,IAAA,gBAAA,CAAA,YAAA,CAAA,GAAA,YAAyB;AACzB,IAAA,gBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACjB,IAAA,gBAAA,CAAA,qBAAA,CAAA,GAAA,qBAA2C;AAC3C,IAAA,gBAAA,CAAA,mBAAA,CAAA,GAAA,mBAAuC;AACvC,IAAA,gBAAA,CAAA,sBAAA,CAAA,GAAA,sBAA6C;AAC7C,IAAA,gBAAA,CAAA,mBAAA,CAAA,GAAA,mBAAuC;AACvC,IAAA,gBAAA,CAAA,YAAA,CAAA,GAAA,YAAyB;AACzB,IAAA,gBAAA,CAAA,mBAAA,CAAA,GAAA,mBAAuC;AACzC,CAAC,EAbWA,wBAAgB,KAAhBA,wBAAgB,GAAA,EAAA,CAAA,CAAA;;"}
1
+ {"version":3,"file":"types.js","sources":["../../../../src/api/types.ts"],"sourcesContent":["import type { AvatarStyle } from '../utils/avatar';\n\nimport type React from 'react';\n\n/**\n * File attachment for messages\n */\nexport interface ChatFile {\n name: string;\n downloadUrl?: string;\n fileType?: 'image' | 'document' | 'audio' | 'video' | 'other';\n}\n\n/**\n * Attachment as it appears on a message.\n *\n * Two shapes reach the UI for the same thing: the optimistic message built\n * locally on send uses `url`/`type`, while the history returned by the API\n * carries the stored `downloadUrl`/`fileType`. Both are accepted here; use\n * `normalizeMessageFile` before reading them.\n */\nexport interface MessageFile {\n name: string;\n url?: string;\n type?: string;\n downloadUrl?: string;\n fileType?: string;\n}\n\n/**\n * Message content structure\n */\nexport interface MessageContent {\n /**\n * The message text.\n *\n * Declared as a string because that is what it is for every role a reader\n * cares about, but do not trust it blindly on a `guard_rail` message:\n * conversations stopped by a guardrail before the backend fix carry the raw\n * provider result object here instead. Guard a `typeof x === 'string'` check\n * around anything that treats it as text.\n */\n message?: string;\n data?: any;\n files?: MessageFile[];\n}\n\n/** Collapse either attachment shape into a single one the UI can render. */\nexport function normalizeMessageFile(file: MessageFile): {\n name: string;\n url: string;\n type: string;\n} {\n return {\n name: file.name,\n url: file.url || file.downloadUrl || '',\n type: file.type || file.fileType || 'other',\n };\n}\n\n/**\n * Tool call from the model\n */\nexport interface ToolCall {\n id: string;\n type: 'function';\n function: {\n name: string;\n arguments: string;\n };\n}\n\n/**\n * Chat message structure\n */\nexport interface ChatMessage {\n uid: string;\n role: 'user' | 'assistant' | 'developer' | 'system' | 'tool' | 'guard_rail';\n content: MessageContent;\n timestamp: number;\n chatUid?: string;\n tool_calls?: ToolCall[];\n tool_call_id?: string;\n summary?: string;\n /**\n * Where `content.message` came from, when the model did not write it.\n * `'finish_tool'`: the assistant is configured to require a tool call to\n * finish (\"Require Tool Use to Finish\") and the backend lifted the reply from\n * the finish tool's `message` argument, so it can be read without parsing\n * tool calls. Absent on replies the model wrote itself — use it to label the\n * bubble as produced by the tool.\n */\n contentSource?: string;\n /**\n * Id of a speech-to-text transcript (from POST /api/v1/whisper) that seeded\n * this message. Present on user messages dictated by voice; the chat can use\n * it to fetch the source audio (GET /api/v1/whisper/:transcriptId) and offer\n * playback.\n */\n transcriptId?: string;\n /**\n * Original server uid, present when the UI adopted an optimistic uid for\n * this message to keep React keys stable. Server-side references (e.g.\n * memory recall anchors) match against it.\n */\n serverUid?: string;\n /**\n * Client-side only: the conversation was busy when this message was sent, so\n * it was accepted into the queue and is waiting its turn. Drawn as a message\n * that has not landed rather than as part of the conversation. Falls away on\n * its own once the message comes back inside the history.\n */\n queued?: boolean;\n /**\n * Client-side only: when this message was accepted into the queue. Used to\n * tell \"the server has not reported it yet\" from \"the server no longer has\n * it\", which the timestamp is the only honest way to decide.\n */\n queuedAt?: number;\n}\n\n/**\n * Previous conversation message for initialization\n */\nexport interface PreviousMessage {\n message: string;\n role: 'user' | 'assistant';\n}\n\n/**\n * Model interface tool schema following OpenAI function calling format\n */\nexport interface ModelInterfaceToolSchema {\n type: 'function';\n function: {\n name: string;\n description: string;\n parameters: {\n type: 'object';\n properties: Record<string, any>;\n required?: string[];\n };\n };\n}\n\n/**\n * Props passed to a response widget component.\n * The widget is responsible for collecting the user's response and\n * calling `submit` with the payload to resolve the tool call.\n */\nexport interface ResponseWidgetProps {\n /** The tool call this widget is responding to */\n toolCall: ToolCall;\n /** Parsed arguments from the tool call */\n params: any;\n /** Submit the tool response payload (sent as the tool call result to the model) */\n submit: (response: any) => void;\n /** Cancel the tool call. Sends an error response so the model can continue. */\n cancel?: (reason?: string) => void;\n /** Whether the widget is currently submitting */\n isSubmitting?: boolean;\n}\n\n/**\n * Interactive response widget configuration for a client-side tool.\n *\n * When the model calls a tool configured with a `responseWidget`, the\n * widget is rendered in the chat UI instead of executing a callback.\n * The user interacts with the widget, which calls `submit(response)` to\n * define the tool response sent back to the model.\n *\n * - `render: 'inline'` renders the widget in the message thread at the\n * position of the tool call. The text input remains enabled.\n * - `render: 'input'` replaces the chat input area with the widget\n * while it is pending. The text input is disabled until submission.\n */\nexport interface ResponseWidgetConfig {\n /** Where to render the widget */\n render: 'inline' | 'input';\n /** The widget component */\n component: React.ComponentType<ResponseWidgetProps>;\n}\n\n/**\n * Model interface tool definition for client-side tools.\n *\n * A tool must provide either a `callback` (executed automatically when\n * the model invokes the tool) or a `responseWidget` (renders UI for\n * the user to produce the tool response). Providing both is an error.\n */\nexport interface ModelInterfaceTool {\n toolName: string;\n schema: ModelInterfaceToolSchema;\n /** Executed automatically when the model calls this tool */\n callback?: (params: any) => Promise<any> | any;\n /** Interactive widget that collects the user's tool response */\n responseWidget?: ResponseWidgetConfig;\n}\n\n/**\n * Tool call response to send back to the API\n */\nexport interface ToolCallResponse {\n tool_call_id: string;\n content: any;\n role: 'tool';\n /**\n * The client-side tools still on offer for the rest of the turn. The API\n * reads them off the first response of the batch: leaving them out drops\n * the tools from the continuation, so the model cannot call them again.\n */\n tools?: ModelInterfaceToolSchema[];\n}\n\n/**\n * DTO for sending messages to the assistant\n */\nexport interface ProcessMessageDto {\n message: string;\n chatUid?: string;\n userName?: string;\n files?: ChatFile[];\n /** Tags to associate with this chat (top-level, distinct from `metadata`). */\n tags?: string[];\n metadata?: {\n promptTemplateParams?: Record<string, any>;\n tenantToken?: string;\n [key: string]: any;\n };\n tenantId?: string;\n previousConversation?: PreviousMessage[];\n enabledTools?: string[];\n provider?: string;\n model?: string;\n // Model interface protocol fields\n tools?: ModelInterfaceToolSchema[];\n applicationState?: Record<string, any>;\n skipSummarization?: boolean;\n /**\n * Id of a speech-to-text transcript (from POST /api/v1/whisper) that seeded\n * this message. Sent so the conversation keeps a link to the original audio.\n */\n transcriptId?: string;\n}\n\n/**\n * Response from the /whisper speech-to-text endpoint.\n */\nexport interface WhisperTranscriptionResponse {\n /** Public id of the transcript; send it back as ProcessMessageDto.transcriptId. */\n transcriptId: string;\n /** Transcribed text. */\n text: string;\n /** Language hint used, if any. */\n language?: string;\n /** Download URL of the source audio. */\n audioUrl?: string;\n /** Transcription model used. */\n model?: string;\n}\n\n/**\n * Response from the assistant\n */\nexport interface AssistantResponse {\n messages: ChatMessage[];\n chatUid: string;\n inputTokens?: number;\n outputTokens?: number;\n}\n\n/**\n * Async mode response\n */\nexport interface AsyncResponse {\n chatUid: string;\n message?: string;\n error?: string;\n /**\n * The conversation could not take the message right now, so it was queued\n * instead of starting a run of its own. Still an acceptance: the answer comes\n * later, and may cover several messages at once.\n */\n queued?: boolean;\n /** How many messages are queued on this conversation, this one included. */\n queuePosition?: number;\n /** When the queued message reaches the model. */\n willProcess?: QueueDisposition;\n}\n\n/**\n * When a queued message will reach the model.\n *\n * `after_delay` is the one that is not about being busy: an idle conversation\n * on an assistant with an input delay collects what is written during the\n * window, so a message can come back queued with nothing in flight at all.\n */\nexport type QueueDisposition = 'after_delay' | 'next_turn' | 'on_resume';\n\n/** Response of the stop endpoint. */\nexport interface StopChatResponse {\n chatUid: string;\n message: string;\n /**\n * Queued messages the stop threw away — answering them would be the opposite\n * of what was asked. Handed back so their text can be put where the user\n * wrote it. Absent on an API older than this, and when nothing was queued.\n */\n discardedMessages?: ChatMessage[];\n}\n\n/**\n * Real-time chat history status.\n * `limit_exceeded` means the message was blocked before reaching the LLM\n * because a configured tenant/subtenant usage limit was reached.\n */\nexport type RealtimeStatus =\n | 'processing'\n | 'completed'\n | 'error'\n | 'waiting_for_tool_response'\n | 'handed_off'\n | 'limit_exceeded'\n /** Collecting messages during the assistant's input delay, before any run. */\n | 'buffering';\n\n/**\n * Details of a tenant/subtenant usage limit that blocked a message.\n * Returned on the realtime endpoint when status is `limit_exceeded`, and on\n * the HTTP 429 body (`details`) when a synchronous request is blocked.\n */\nexport interface TenantLimitExceeded {\n /** Human-readable message describing the block. */\n message?: string;\n /** The rule that triggered the block (scope, metric, window, limit…). */\n blockingRule?: {\n scope?: 'tenant' | 'subtenant';\n subtenantId?: string;\n metric?: 'tokens' | 'cost';\n windowUnit?: 'hour' | 'day' | 'week' | 'month';\n windowEvery?: number;\n limit?: number;\n };\n /** Current consumption in the blocking window. */\n current?: number;\n /** The limit that was reached. */\n limit?: number;\n /** Epoch ms when the blocking window resets and usage is allowed again. */\n resetsAt?: number;\n}\n\n/** One fact a long-term-memory recall surfaced. */\nexport interface RecalledMemoryFact {\n fact: string;\n relation: string;\n /** Source entity name of the graph edge, when the fact connects two. */\n source: string | null;\n /** Target entity name of the graph edge, when the fact connects two. */\n target: string | null;\n /** ISO date the fact became valid, if known. */\n validAt: string | null;\n}\n\n/** One graph entity a long-term-memory recall surfaced. */\nexport interface RecalledMemoryEntity {\n id: string;\n name: string;\n type: string;\n summary: string | null;\n}\n\n/** One previous-session turn a conversation-start recall carried over. */\nexport interface RecalledMemoryTurn {\n role: string;\n content: string;\n}\n\n/**\n * One structured long-term-memory recall event of a conversation: the facts,\n * entities and previous-session turns a recall surfaced, plus the uid of the\n * message that brought it in (`messageUid`: the initial user message, or the\n * assistant message carrying the memory tool call — resolvable through\n * `toolCallId` while the run is still in flight).\n */\nexport interface RecalledMemoryRecord {\n uid: string;\n messageUid?: string;\n toolCallId?: string;\n source:\n | 'conversation_start'\n | 'search_memory'\n | 'search_memory_nodes'\n | 'explore_memory_graph';\n query?: string;\n facts?: RecalledMemoryFact[];\n entities?: RecalledMemoryEntity[];\n turns?: RecalledMemoryTurn[];\n timestampMs: number;\n}\n\n/**\n * Snapshot of the core-memory block a conversation saw (audit trail): the\n * render revision plus the injected entries as structured items.\n */\nexport interface CoreMemorySnapshot {\n uid: string;\n revision: string;\n items: Array<{\n id: number;\n section: string;\n content: string;\n pinned: boolean;\n source: string;\n }>;\n entries: number;\n omitted: number;\n chars: number;\n timestampMs: number;\n}\n\n/**\n * Real-time chat history response\n */\nexport interface RealtimeChatHistory {\n chatUID: string;\n clientUID: string;\n chatHistory: ChatMessage[];\n status: RealtimeStatus;\n lastUpdatedAt: number;\n pendingToolCalls?: ToolCall[];\n handedOffSubThreadId?: string;\n /** Present only when status is `limit_exceeded`. */\n limitExceeded?: TenantLimitExceeded;\n /**\n * Memory-recall events of the in-flight run — lets the UI show what the\n * assistant is recalling while the response is still processing.\n */\n recalledMemories?: RecalledMemoryRecord[];\n /**\n * Messages accepted into this conversation that the model has not seen yet.\n * Non-zero means more is coming: a `completed` status with messages still\n * queued is not the end of the exchange.\n */\n queuedMessages?: number;\n /**\n * The queued messages themselves. This is the conversation's queue, not the\n * caller's — it can include messages the same conversation received through\n * another channel. Absent on an API that does not return them, in which case\n * the widget falls back to its own optimistic copies.\n */\n pendingUserMessages?: ChatMessage[];\n /**\n * Compaction checkpoints of the in-flight run. A conversation that compacts\n * mid-run stops sending the messages above the cut immediately, so these\n * arrive here before they are persisted on the conversation.\n */\n compactions?: CompactionCheckpoint[];\n /** The compaction running right now, if any. */\n compaction?: CompactionActivity;\n}\n\n/**\n * A single usage rule with its current consumption (from GET\n * /api/v1/tenant-usage/:tenantId[/subtenants/:subtenantId]).\n */\nexport interface TenantUsageRule {\n scope: 'tenant' | 'subtenant';\n subtenantId?: string;\n metric: 'tokens' | 'cost';\n windowUnit: 'hour' | 'day' | 'week' | 'month';\n windowEvery: number;\n /** Configured limit for the window. */\n limit: number;\n /** Current consumption in the active window. */\n current: number;\n /** Utilization percentage (0..100, capped). */\n percent: number;\n /** Epoch ms when the active window resets. */\n resetsAt?: number;\n /** Where the rule comes from ('tier' | 'adhoc'). */\n origin?: string;\n /** Tier the rule belongs to, if any. */\n tierId?: string;\n}\n\n/**\n * Response of GET /api/v1/tenant-usage/:tenantId[/subtenants/:subtenantId]:\n * the effective usage rules with their current consumption + the active tier.\n */\nexport interface TenantUsage {\n tenantId: string;\n subtenantId?: string;\n tierId?: string;\n usage: TenantUsageRule[];\n}\n\n/**\n * A durable per-window usage history row (from GET\n * /api/v1/tenant-usage/:tenantId/history).\n */\nexport interface TenantUsageHistoryRow {\n clientUID: string;\n tenantId: string;\n subtenantId: string;\n scope: 'tenant' | 'subtenant';\n metric: 'tokens' | 'cost';\n windowUnit: 'hour' | 'day' | 'week' | 'month';\n windowEvery: number;\n windowKey: string;\n windowStart: number;\n windowEnd: number;\n /** Counted consumption (enforced). */\n consumption: number;\n /** Exempt consumption that did not count toward the limit, if any. */\n exemptConsumption?: number;\n limit: number;\n percent: number;\n tierId?: string;\n origin?: string;\n capturedAt: number;\n}\n\n/**\n * Options for querying tenant usage history.\n */\nexport interface TenantUsageHistoryQuery {\n subtenantId?: string;\n scope?: 'tenant' | 'subtenant';\n metric?: 'tokens' | 'cost';\n windowUnit?: 'hour' | 'day' | 'week' | 'month';\n /** Epoch ms lower bound (windowEnd >= from). */\n from?: number;\n /** Epoch ms upper bound (windowEnd <= to). */\n to?: number;\n limit?: number;\n skip?: number;\n}\n\n/**\n * Chat history structure\n */\n/** A concrete value carried verbatim through a compaction. */\nexport interface CompactionFact {\n kind: string;\n value: string;\n label?: string;\n}\n\n/** The structured body a compaction produced. */\nexport interface CompactionSummary {\n goal?: string;\n constraints?: string[];\n inProgress?: string;\n pending?: string[];\n decisions?: string[];\n data?: Array<{ label: string; value: string }>;\n done?: string[];\n openQuestions?: string[];\n /** Fallback when the model answered without structure. */\n raw?: string;\n}\n\n/**\n * One compaction of a conversation: the messages before its boundary folded\n * into a written summary plus the identifiers, paths and urls lifted out of\n * them verbatim. From then on the model receives the checkpoint instead of\n * those messages — which are still in the conversation, and still shown.\n *\n * Only the newest checkpoint is in force: each compaction merges the previous\n * summary into itself.\n */\nexport interface CompactionCheckpoint {\n uid: string;\n /** 1 for the first compaction of the conversation, 2 for the next… */\n index: number;\n timestampMs: number;\n trigger: 'auto' | 'manual';\n /** First message that still travels verbatim. */\n firstKeptMessageUid?: string;\n /** Last folded message: where the widget belongs in the conversation. */\n anchorMessageUid?: string;\n compactedMessageCount: number;\n summary: CompactionSummary;\n facts: CompactionFact[];\n tokensBefore: number;\n tokensAfter: number;\n provider?: string;\n model?: string;\n cost?: number;\n}\n\n/**\n * A compaction happening right now, from the realtime endpoint.\n *\n * A compaction is a model call of its own, taken between two assistant\n * messages, so a client that only knows `processing` shows a conversation\n * that appears to have stalled for a few seconds. Present while it runs and\n * on the single update that reports it finished.\n */\nexport interface CompactionActivity {\n state: 'running' | 'completed';\n startedAt: number;\n /**\n * What this pass is folding: the messages new since the last checkpoint.\n * Not the conversation's totals — a checkpoint's own\n * `compactedMessageCount` and `tokensBefore` are cumulative across every\n * compaction, so the two are on different scales and must not be paired.\n */\n messageCount: number;\n tokensBefore: number;\n /** Which checkpoint the pass produced, once it is done. */\n index?: number;\n finishedAt?: number;\n}\n\nexport interface ChatHistory {\n chatUID: string;\n clientUID: string;\n userUID: string;\n chatContent: ChatMessage[];\n name?: string;\n assistantSpecializationIdentifier: string;\n creationTimestampMs: number;\n lastEditTimestampMs?: number;\n llm?: string;\n inputTokens?: number;\n outputTokens?: number;\n metadata?: Record<string, any>;\n tenantId?: string;\n handedOff?: boolean;\n handedOffSubThreadId?: string;\n handedOffToolCallId?: string;\n /** Structured long-term-memory recall events of the conversation. */\n recalledMemories?: RecalledMemoryRecord[];\n /** Audit trail of the core-memory blocks the conversation saw. */\n coreMemories?: CoreMemorySnapshot[];\n /** Compaction checkpoints of the conversation, oldest first. */\n compactions?: CompactionCheckpoint[];\n}\n\n/** One core memory entry (the always-injected tier), as returned by the memory API. */\nexport interface CoreMemoryEntry {\n id: number;\n section: string;\n content: string;\n source: string;\n pinned: boolean;\n supersedes: number | null;\n archivedAt: string | null;\n createdAt?: string;\n updatedAt?: string;\n}\n\n/** Deployment caps of the core memory tier. */\nexport interface CoreMemoryLimits {\n maxChars: number;\n maxEntries: number;\n maxEntryChars: number;\n}\n\n/**\n * Response of GET /api/v1/memory/assistants/:identifier/core — the entries\n * of the bucket the assistant resolves for a tenant/subtenant combination.\n */\nexport interface CoreMemoryList {\n /** False when the assistant does not have the core memory tier enabled. */\n enabled: boolean;\n /** The resolved bucket tuple (tenant/subtenant/owner dimensions). */\n bucket: { tenantId?: string; subtenantId?: string; entityId?: string };\n entries: CoreMemoryEntry[];\n limits?: CoreMemoryLimits;\n}\n\n/**\n * Assistant specialization info\n */\nexport interface AssistantSpecialization {\n identifier: string;\n name: string;\n description: string;\n state: 'active' | 'inactive' | 'coming_soon';\n imgUrl?: string;\n /** Pinned style of the generated avatar shown when there is no imgUrl. */\n avatarStyle?: AvatarStyle;\n availableToolsGroups?: Array<{\n name: string;\n description?: string;\n uid?: string;\n iconUrl?: string;\n tools?: Array<{\n name: string;\n description: string;\n }>;\n }>;\n model?: string;\n isCustom?: boolean;\n creationTimestampMs?: number;\n /**\n * Whether this assistant offers MCP servers of the tenant's own.\n *\n * Same contract as `tenantIntegrations` below, absence included.\n */\n tenantMcpServers?: {\n enabled: boolean;\n /** Servers listed ready to connect. Says nothing about how many are connected. */\n count?: number;\n };\n /**\n * Whether this assistant offers connected apps to its tenants.\n *\n * **Absent means \"cannot tell\", not \"no\"** — an API older than this field\n * says nothing, and treating silence as a no would hide the connected-apps\n * button from anyone whose deployment has not caught up yet.\n */\n tenantIntegrations?: {\n enabled: boolean;\n /**\n * How many apps the catalogue offers. An upper bound — the listing drops\n * any the provider cannot resolve — and enough to size a placeholder.\n */\n count?: number;\n };\n /**\n * Whether this assistant accepts messages sent while the conversation is\n * busy, queueing them instead of refusing them.\n *\n * **Absent means no**, unlike `tenantIntegrations` above. Promising a queue\n * that does not exist is paid for with a 409 and with the user's text left in\n * the air, so silence is read as the safe answer rather than as the open one.\n */\n messageQueueEnabled?: boolean;\n /** How many messages may wait at once before further sends are refused. */\n maxQueuedMessages?: number;\n}\n\n/**\n * Summary of a conversation for listing\n */\nexport interface ConversationSummary {\n chatUID: string;\n name?: string;\n creationTimestampMs: number;\n lastEditTimestampMs?: number;\n}\n\nexport interface ListConversationsResponse {\n histories: ConversationSummary[];\n total: number;\n offset: number;\n limit: number;\n}\n\n/**\n * API error response\n */\nexport interface ApiError {\n statusCode: number;\n message: string;\n error?: string;\n /** Optional structured details (e.g. usage-limit blocking info on a 429). */\n details?: any;\n}\n\n/**\n * Feedback submission request\n */\nexport interface FeedbackSubmission {\n messageId: string;\n feedback?: boolean;\n feedbackComment?: string;\n feedbackData?: Record<string, any>;\n}\n\n/**\n * Feedback entry response\n */\nexport interface FeedbackEntry {\n _id: string;\n requestId: string;\n chatUID?: string;\n threadId?: string;\n agentId?: string;\n feedback?: boolean;\n feedbackComment?: string;\n feedbackData?: Record<string, any>;\n creationTimestamp: string;\n lastEditTimestamp?: string;\n}\n\n/**\n * Agent thread states\n */\nexport enum AgentThreadState {\n QUEUED = 'queued',\n PROCESSING = 'processing',\n COMPLETED = 'completed',\n FAILED = 'failed',\n TERMINATED = 'terminated',\n PAUSED = 'paused',\n PAUSED_FOR_APPROVAL = 'paused_for_approval',\n APPROVAL_REJECTED = 'approval_rejected',\n WAITING_FOR_RESPONSE = 'waiting_for_response',\n PAUSED_FOR_RESUME = 'paused_for_resume',\n HANDED_OFF = 'handed_off',\n GUARDRAIL_TRIGGER = 'guardrail_trigger',\n}\n\n/**\n * Task within an agent thread\n */\nexport interface AgentTaskDto {\n _id?: string;\n title?: string;\n description?: string;\n completed: boolean;\n}\n\n/**\n * Agent thread DTO\n */\nexport interface AgentThreadDto {\n _id?: string;\n agentId: string;\n state: AgentThreadState;\n threadContent: ChatMessage[];\n tasks?: AgentTaskDto[];\n finishReason?: string;\n pausedReason?: string;\n name?: string;\n creationTimestampMs?: number;\n lastEditTimestampMs?: number;\n pauseUntil?: number;\n isSubthread?: boolean;\n parentThreadId?: string;\n subThreadToolCallId?: string;\n parentAgentId?: string;\n}\n\n/**\n * Agent details\n */\nexport interface AgentDto {\n _id?: string;\n name: string;\n description?: string;\n imgUrl?: string;\n /** Pinned style of the generated avatar shown when there is no imgUrl. */\n avatarStyle?: AvatarStyle;\n agentId?: string;\n}\n\n/**\n * Hand-off tool response content\n */\nexport interface HandOffToolResponse {\n response: string;\n subthreadId: string;\n}\n\n/**\n * Represents a single tool call within a tool group\n */\nexport interface ToolGroupCall {\n name: string;\n input: any;\n output: any;\n toolCallId: string;\n}\n\n/**\n * Configuration for grouping consecutive tool calls under a single renderer\n */\nexport interface ToolGroupConfig {\n tools: string[];\n renderer: (calls: ToolGroupCall[]) => React.ReactNode;\n}\n\n/**\n * One of the end user's connected accounts for an app.\n *\n * The provider's own identifiers do not travel here beyond `id`, which the\n * client needs in order to name the account it wants disconnected — and which\n * the server re-checks against the caller's tenant on the way back in.\n */\nexport interface IntegrationAccount {\n id: string;\n status: string;\n connectedAt?: string;\n updatedAt?: string;\n /** True when the account exists but can no longer run tools. */\n needsReconnect?: boolean;\n statusReason?: string;\n}\n\n/**\n * One value the end user is asked for before an account can be connected —\n * their API key, the subdomain of their instance.\n *\n * Comes from the provider's own catalogue, so the form is rendered from this\n * rather than from anything app-specific: most apps do not authenticate with\n * credentials Devic holds, and there are hundreds of them.\n */\nexport interface IntegrationAuthField {\n name: string;\n label: string;\n type: string;\n required: boolean;\n description?: string;\n /** Prefilled — usually a provider endpoint most accounts should keep. */\n default?: string;\n /** Mask it on screen. */\n secret: boolean;\n}\n\n/**\n * One way of connecting an app.\n *\n * `redirect` schemes send the user to the provider; the rest are connected\n * with the values they type, without ever leaving the page.\n *\n * There is deliberately no field for the *application's* credentials: the\n * OAuth application belongs to the developer who embedded this widget, is\n * registered once for every tenant, and is never the end user's to supply.\n */\nexport interface IntegrationAuthScheme {\n /** The provider's own name for it: `OAUTH2`, `API_KEY`, … */\n mode: string;\n /** Credentials for this scheme are held for you — nothing to fill in. */\n composioManaged: boolean;\n redirect: boolean;\n /** What this account supplies. Empty for a scheme that asks nothing. */\n accountFields: IntegrationAuthField[];\n /** The provider's own setup guide, when there is one. */\n guideUrl?: string;\n}\n\n/**\n * The answer when connecting needs values that were not sent.\n *\n * `stage` decides who can act on it: `account` is the end user, and the form\n * asks them. `app` is the developer's OAuth application, which the end user\n * cannot register — so that case is shown as \"not available yet\" instead of a\n * form asking a stranger for someone else's client secret.\n */\nexport interface IntegrationSetupRequired {\n code: \"INTEGRATION_SETUP_REQUIRED\";\n message: string;\n toolkit: string;\n authScheme: string;\n stage: \"app\" | \"account\";\n fields: IntegrationAuthField[];\n guideUrl?: string;\n}\n\n/**\n * An app the assistant offers to its tenants, with the accounts THIS tenant\n * has connected. Never another tenant's.\n */\nexport interface Integration {\n /** App slug, e.g. `gmail`. */\n app: string;\n name: string;\n description?: string;\n logo?: string;\n /** True when at least one account is active. */\n connected: boolean;\n accounts: IntegrationAccount[];\n /** Event types the developer allows this tenant to switch on. */\n availableTriggers?: string[];\n}\n\n// ── MCP servers the end user connects for themselves ──────────────────────\n\nexport type TenantMcpAuthMode = \"oauth\" | \"header\" | \"none\";\n\n/** One of the end user's own MCP connections. */\nexport interface TenantMcpConnection {\n id: string;\n /**\n * What to put in `disabledIntegrations` to have this server sit a message\n * out. Sent by the API so the prefix that separates it from an app slug lives\n * on the server, in one place.\n */\n toggleId?: string;\n name?: string;\n url: string;\n /** The developer's template this came from, when it came from one. */\n templateId?: string;\n authMode?: TenantMcpAuthMode;\n status: \"pending_auth\" | \"active\" | \"error\";\n toolCount?: number;\n tools?: string[];\n lastProbeStatus?: string;\n lastProbeError?: string;\n lastProbeTimestampMs?: number;\n /** Connected for the whole tenant, so every end user of it shares this. */\n shared: boolean;\n /** True when this end user may use it but not change or remove it. */\n readOnly: boolean;\n}\n\n/**\n * One row of the MCP panel: either a server the developer offers ready to\n * connect, or one this end user added.\n *\n * A single list rather than two, because that is what the panel draws — keeping\n * \"offered\" and \"connected\" apart would leave them out of step for a moment\n * after every connect.\n */\nexport interface TenantMcpServer {\n source: \"template\" | \"custom\";\n templateId?: string;\n name: string;\n url: string;\n description?: string;\n logoUrl?: string;\n authMode?: TenantMcpAuthMode;\n /** Header the credential travels in, for `header` servers. */\n headerName?: string;\n /** Whether the end user may supply their own OAuth application. */\n allowClientCredentials?: boolean;\n /** Null until this tenant connects it. */\n connection: TenantMcpConnection | null;\n}\n\nexport interface TenantMcpListing {\n offered: boolean;\n /** Whether adding a server of one's own is permitted. */\n allowCustom: boolean;\n limits: { maxServers: number; maxToolsPerServer: number; used: number };\n servers: TenantMcpServer[];\n}\n\n/** Credentials the end user supplies when connecting a server. */\nexport interface TenantMcpAuthInput {\n mode?: TenantMcpAuthMode;\n headerName?: string;\n headerValue?: string;\n upstreamOAuth?: { clientId?: string; clientSecret?: string; scopes?: string[] };\n}\n\n/**\n * What connecting answers with.\n *\n * `status: \"active\"` means it is done. `authorizationUrl` must be opened in a\n * popup. `requiresClientCredentials` means the server has no dynamic client\n * registration and the end user has to register an OAuth application with it\n * themselves, authorising `callbackUrl` as the redirect URI.\n */\nexport interface TenantMcpConnectResult {\n id: string;\n status: \"pending_auth\" | \"active\" | \"error\";\n toolCount?: number;\n authorizationUrl?: string;\n requiresClientCredentials?: boolean;\n callbackUrl?: string;\n error?: string;\n}\n"],"names":["AgentThreadState"],"mappings":";;AA+CA;AACM,SAAU,oBAAoB,CAAC,IAAiB,EAAA;IAKpD,OAAO;QACL,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,WAAW,IAAI,EAAE;QACvC,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,IAAI,OAAO;KAC5C;AACH;AA2tBA;;AAEG;AACSA;AAAZ,CAAA,UAAY,gBAAgB,EAAA;AAC1B,IAAA,gBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACjB,IAAA,gBAAA,CAAA,YAAA,CAAA,GAAA,YAAyB;AACzB,IAAA,gBAAA,CAAA,WAAA,CAAA,GAAA,WAAuB;AACvB,IAAA,gBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACjB,IAAA,gBAAA,CAAA,YAAA,CAAA,GAAA,YAAyB;AACzB,IAAA,gBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACjB,IAAA,gBAAA,CAAA,qBAAA,CAAA,GAAA,qBAA2C;AAC3C,IAAA,gBAAA,CAAA,mBAAA,CAAA,GAAA,mBAAuC;AACvC,IAAA,gBAAA,CAAA,sBAAA,CAAA,GAAA,sBAA6C;AAC7C,IAAA,gBAAA,CAAA,mBAAA,CAAA,GAAA,mBAAuC;AACvC,IAAA,gBAAA,CAAA,YAAA,CAAA,GAAA,YAAyB;AACzB,IAAA,gBAAA,CAAA,mBAAA,CAAA,GAAA,mBAAuC;AACzC,CAAC,EAbWA,wBAAgB,KAAhBA,wBAAgB,GAAA,EAAA,CAAA,CAAA;;"}
@@ -3,6 +3,7 @@
3
3
  var jsxRuntime = require('react/jsx-runtime');
4
4
  var React = require('react');
5
5
  var useAICommandBar = require('./useAICommandBar.js');
6
+ var useTranslations = require('../../i18n/useTranslations.js');
6
7
  var MessageActions = require('../Feedback/MessageActions.js');
7
8
  var DevicContext = require('../../provider/DevicContext.js');
8
9
  var client = require('../../api/client.js');
@@ -74,6 +75,7 @@ const DEFAULT_OPTIONS = {
74
75
  commands: undefined,
75
76
  showHistoryCommand: true,
76
77
  toolGroups: undefined,
78
+ translations: undefined,
77
79
  };
78
80
  /**
79
81
  * AI Command Bar component - a floating input for quick AI interactions
@@ -95,6 +97,7 @@ const DEFAULT_OPTIONS = {
95
97
  const AICommandBar = React.forwardRef(function AICommandBar(props, ref) {
96
98
  const { assistantId, apiKey, baseUrl, pollingInterval, tenantId, tenantMetadata, tags, options = {}, isVisible: controlledVisible, onVisibilityChange, onExecute = 'callback', chatDrawerRef, onResponse, modelInterfaceTools, onSubmit, onToolCall, onError, onOpen, onClose, className, } = props;
97
99
  const mergedOptions = React.useMemo(() => ({ ...DEFAULT_OPTIONS, ...options }), [options]);
100
+ const t = useTranslations.useTranslations(mergedOptions.translations);
98
101
  const hook = useAICommandBar.useAICommandBar({
99
102
  assistantId,
100
103
  apiKey,
@@ -316,14 +319,14 @@ const AICommandBar = React.forwardRef(function AICommandBar(props, ref) {
316
319
  return (jsxRuntime.jsxs("div", { className: "devic-command-bar-result-tool-item", children: [customIcon ? (jsxRuntime.jsx("span", { className: "devic-command-bar-result-tool-icon", children: customIcon })) : (jsxRuntime.jsx(CheckIcon, { className: "devic-command-bar-result-tool-icon" })), jsxRuntime.jsx("span", { className: "devic-command-bar-result-tool-name", children: tc.summary || tc.name })] }, tc.id));
317
320
  });
318
321
  };
319
- return (jsxRuntime.jsxs("div", { ref: containerRef, className: `devic-command-bar-container ${className || ''}`, "data-position": mergedOptions.position, "data-visible": hook.isVisible, style: containerStyle, children: [hook.showingCommands && hook.filteredCommands.length > 0 && (jsxRuntime.jsxs("div", { className: "devic-command-bar-dropdown", children: [jsxRuntime.jsxs("div", { className: "devic-command-bar-dropdown-header", children: [jsxRuntime.jsx("span", { children: "Commands" }), jsxRuntime.jsxs("span", { className: "devic-command-bar-dropdown-hint", children: [jsxRuntime.jsx("kbd", { children: "\u2191" }), jsxRuntime.jsx("kbd", { children: "\u2193" }), " to navigate, ", jsxRuntime.jsx("kbd", { children: "Enter" }), " to select"] })] }), jsxRuntime.jsx("div", { className: "devic-command-bar-dropdown-list", children: hook.filteredCommands.map((cmd, index) => (jsxRuntime.jsxs("div", { className: "devic-command-bar-dropdown-item", "data-selected": index === hook.selectedCommandIndex, onClick: () => hook.selectCommand(cmd), onMouseEnter: () => { }, children: [cmd.icon && (jsxRuntime.jsx("span", { className: "devic-command-bar-dropdown-icon", children: cmd.icon })), jsxRuntime.jsxs("span", { className: "devic-command-bar-dropdown-keyword", children: ["/", cmd.keyword] }), jsxRuntime.jsx("span", { className: "devic-command-bar-dropdown-desc", children: cmd.description })] }, cmd.keyword))) })] })), hook.showingHistory && (jsxRuntime.jsxs("div", { className: "devic-command-bar-dropdown", children: [jsxRuntime.jsxs("div", { className: "devic-command-bar-dropdown-header", children: [jsxRuntime.jsx("span", { children: "Command History" }), hook.history.length > 0 && (jsxRuntime.jsx("button", { className: "devic-command-bar-dropdown-clear", onClick: () => {
320
- hook.clearHistory();
322
+ return (jsxRuntime.jsx(useTranslations.DevicTranslationsProvider, { translations: mergedOptions.translations, children: jsxRuntime.jsxs("div", { ref: containerRef, className: `devic-command-bar-container ${className || ''}`, "data-position": mergedOptions.position, "data-visible": hook.isVisible, style: containerStyle, children: [hook.showingCommands && hook.filteredCommands.length > 0 && (jsxRuntime.jsxs("div", { className: "devic-command-bar-dropdown", children: [jsxRuntime.jsxs("div", { className: "devic-command-bar-dropdown-header", children: [jsxRuntime.jsx("span", { children: t('Commands') }), jsxRuntime.jsxs("span", { className: "devic-command-bar-dropdown-hint", children: [jsxRuntime.jsx("kbd", { children: "\u2191" }), jsxRuntime.jsx("kbd", { children: "\u2193" }), " ", t('to navigate,'), " ", jsxRuntime.jsx("kbd", { children: "Enter" }), ' ', t('to select')] })] }), jsxRuntime.jsx("div", { className: "devic-command-bar-dropdown-list", children: hook.filteredCommands.map((cmd, index) => (jsxRuntime.jsxs("div", { className: "devic-command-bar-dropdown-item", "data-selected": index === hook.selectedCommandIndex, onClick: () => hook.selectCommand(cmd), onMouseEnter: () => { }, children: [cmd.icon && (jsxRuntime.jsx("span", { className: "devic-command-bar-dropdown-icon", children: cmd.icon })), jsxRuntime.jsxs("span", { className: "devic-command-bar-dropdown-keyword", children: ["/", cmd.keyword] }), jsxRuntime.jsx("span", { className: "devic-command-bar-dropdown-desc", children: cmd.description })] }, cmd.keyword))) })] })), hook.showingHistory && (jsxRuntime.jsxs("div", { className: "devic-command-bar-dropdown", children: [jsxRuntime.jsxs("div", { className: "devic-command-bar-dropdown-header", children: [jsxRuntime.jsx("span", { children: t('Command History') }), hook.history.length > 0 && (jsxRuntime.jsx("button", { className: "devic-command-bar-dropdown-clear", onClick: () => {
323
+ hook.clearHistory();
324
+ hook.setShowingHistory(false);
325
+ }, type: "button", children: t('Clear') }))] }), jsxRuntime.jsx("div", { className: "devic-command-bar-dropdown-list", style: resultMessageStyle, children: hook.history.length === 0 ? (jsxRuntime.jsx("div", { className: "devic-command-bar-dropdown-empty", children: t('No history yet') })) : (hook.history.map((item, index) => (jsxRuntime.jsxs("div", { className: "devic-command-bar-dropdown-item devic-command-bar-history-item", onClick: () => {
321
326
  hook.setShowingHistory(false);
322
- }, type: "button", children: "Clear" }))] }), jsxRuntime.jsx("div", { className: "devic-command-bar-dropdown-list", style: resultMessageStyle, children: hook.history.length === 0 ? (jsxRuntime.jsx("div", { className: "devic-command-bar-dropdown-empty", children: "No history yet" })) : (hook.history.map((item, index) => (jsxRuntime.jsxs("div", { className: "devic-command-bar-dropdown-item devic-command-bar-history-item", onClick: () => {
323
- hook.setShowingHistory(false);
324
- hook.setInputValue(item);
325
- hook.focus();
326
- }, children: [jsxRuntime.jsx(HistoryIcon, { className: "devic-command-bar-dropdown-icon" }), jsxRuntime.jsx("span", { className: "devic-command-bar-history-text", children: item })] }, `${item}-${index}`)))) })] })), mergedOptions.showResultCard && hook.result && !hook.showingHistory && !hook.showingCommands && (jsxRuntime.jsxs("div", { className: "devic-command-bar-result", children: [hook.result.toolCalls.length > 0 && (jsxRuntime.jsxs("div", { className: "devic-command-bar-result-tools", children: [jsxRuntime.jsxs("div", { className: "devic-command-bar-result-tools-header", "data-expanded": toolsExpanded, onClick: () => setToolsExpanded(!toolsExpanded), children: [jsxRuntime.jsx(ChevronIcon, { className: "devic-command-bar-result-tools-chevron" }), jsxRuntime.jsx("span", { children: "Tool calls" }), jsxRuntime.jsx("span", { className: "devic-command-bar-result-tools-count", children: hook.result.toolCalls.length })] }), jsxRuntime.jsx("div", { className: "devic-command-bar-result-tools-list", "data-expanded": toolsExpanded, children: renderToolCallItems(hook.result.toolCalls, mergedOptions) })] })), jsxRuntime.jsx("div", { className: "devic-command-bar-result-message", style: resultMessageStyle, children: hook.result.message.content?.message || (jsxRuntime.jsx("span", { className: "devic-command-bar-result-empty", children: "No response" })) }), jsxRuntime.jsx("div", { className: "devic-cmd-result-actions", children: jsxRuntime.jsx(MessageActions.MessageActions, { messageId: hook.result.message.uid, messageContent: hook.result.message.content?.message, currentFeedback: feedbackState, onFeedback: handleFeedback, showCopy: true, showFeedback: true, theme: feedbackTheme }) })] })), hook.error && !hook.isProcessing && (jsxRuntime.jsx("div", { className: "devic-command-bar-error", children: hook.error.message })), jsxRuntime.jsxs("div", { className: "devic-command-bar", style: barStyle, children: [jsxRuntime.jsx("div", { className: "devic-command-bar-icon", children: hook.isProcessing ? (jsxRuntime.jsx("div", { className: "devic-command-bar-spinner" })) : (mergedOptions.icon || jsxRuntime.jsx(SparklesIcon, {})) }), hook.isProcessing ? (jsxRuntime.jsxs("div", { className: "devic-command-bar-summary", children: [hook.currentToolSummary || mergedOptions.processingMessage, "..."] })) : (jsxRuntime.jsx("input", { ref: hook.inputRef, type: "text", className: "devic-command-bar-input", placeholder: mergedOptions.placeholder, value: hook.inputValue, onChange: (e) => hook.setInputValue(e.target.value), onKeyDown: hook.handleKeyDown })), mergedOptions.showShortcutHint && mergedOptions.shortcut && !hook.isProcessing && (jsxRuntime.jsx("div", { className: "devic-command-bar-shortcut", children: useAICommandBar.formatShortcut(mergedOptions.shortcut) }))] })] }));
327
+ hook.setInputValue(item);
328
+ hook.focus();
329
+ }, children: [jsxRuntime.jsx(HistoryIcon, { className: "devic-command-bar-dropdown-icon" }), jsxRuntime.jsx("span", { className: "devic-command-bar-history-text", children: item })] }, `${item}-${index}`)))) })] })), mergedOptions.showResultCard && hook.result && !hook.showingHistory && !hook.showingCommands && (jsxRuntime.jsxs("div", { className: "devic-command-bar-result", children: [hook.result.toolCalls.length > 0 && (jsxRuntime.jsxs("div", { className: "devic-command-bar-result-tools", children: [jsxRuntime.jsxs("div", { className: "devic-command-bar-result-tools-header", "data-expanded": toolsExpanded, onClick: () => setToolsExpanded(!toolsExpanded), children: [jsxRuntime.jsx(ChevronIcon, { className: "devic-command-bar-result-tools-chevron" }), jsxRuntime.jsx("span", { children: t('Tool calls') }), jsxRuntime.jsx("span", { className: "devic-command-bar-result-tools-count", children: hook.result.toolCalls.length })] }), jsxRuntime.jsx("div", { className: "devic-command-bar-result-tools-list", "data-expanded": toolsExpanded, children: renderToolCallItems(hook.result.toolCalls, mergedOptions) })] })), jsxRuntime.jsx("div", { className: "devic-command-bar-result-message", style: resultMessageStyle, children: hook.result.message.content?.message || (jsxRuntime.jsx("span", { className: "devic-command-bar-result-empty", children: t('No response') })) }), jsxRuntime.jsx("div", { className: "devic-cmd-result-actions", children: jsxRuntime.jsx(MessageActions.MessageActions, { messageId: hook.result.message.uid, messageContent: hook.result.message.content?.message, currentFeedback: feedbackState, onFeedback: handleFeedback, showCopy: true, showFeedback: true, theme: feedbackTheme }) })] })), hook.error && !hook.isProcessing && (jsxRuntime.jsx("div", { className: "devic-command-bar-error", children: hook.error.message })), jsxRuntime.jsxs("div", { className: "devic-command-bar", style: barStyle, children: [jsxRuntime.jsx("div", { className: "devic-command-bar-icon", children: hook.isProcessing ? (jsxRuntime.jsx("div", { className: "devic-command-bar-spinner" })) : (mergedOptions.icon || jsxRuntime.jsx(SparklesIcon, {})) }), hook.isProcessing ? (jsxRuntime.jsxs("div", { className: "devic-command-bar-summary", children: [hook.currentToolSummary || t(mergedOptions.processingMessage), "..."] })) : (jsxRuntime.jsx("input", { ref: hook.inputRef, type: "text", className: "devic-command-bar-input", placeholder: t(mergedOptions.placeholder), value: hook.inputValue, onChange: (e) => hook.setInputValue(e.target.value), onKeyDown: hook.handleKeyDown })), mergedOptions.showShortcutHint && mergedOptions.shortcut && !hook.isProcessing && (jsxRuntime.jsx("div", { className: "devic-command-bar-shortcut", children: useAICommandBar.formatShortcut(mergedOptions.shortcut) }))] })] }) }));
327
330
  });
328
331
  /**
329
332
  * Sparkles icon (default)